picoclaw/pkg
is-Xiaoen 26f623ed32
feat(session): integrate JSONL persistence into agent loop (#1170)
* feat(session): add SessionStore interface and JSONL backend adapter

Extract a SessionStore interface from the methods the agent loop uses
(AddMessage, GetHistory, SetSummary, TruncateHistory, Save, etc.).
Both SessionManager and the new JSONLBackend satisfy this interface,
allowing the persistence layer to be swapped transparently.

JSONLBackend wraps memory.Store and maps its error-returning API to
the fire-and-forget contract that the agent loop expects — write
errors are logged, reads return empty defaults on failure. Save()
triggers compaction to reclaim space after logical truncation.

Part of #1169

* test(session): add JSONLBackend integration tests

8 tests covering the full SessionStore contract through the JSONL
backend: message roundtrip, tool calls, summary, truncation with
compaction, history replacement, empty sessions, session isolation,
and the complete summarization flow (SetSummary → TruncateHistory →
Save).

Includes compile-time interface satisfaction checks for both
SessionManager and JSONLBackend.

Part of #1169

* feat(agent): wire JSONL session store into agent loop

Replace the concrete *SessionManager field with the SessionStore
interface and initialize the JSONL backend by default. Legacy .json
session files are auto-migrated on first startup. Falls back to
SessionManager if the JSONL store cannot be initialized.

The agent loop code (loop.go) requires zero changes — all method
calls work identically through the interface.

Closes #1169

* fix(session): propagate compact error from Save

Save() was swallowing the error returned by Compact and always
returning nil. Callers checking Save's return value would never
see a compaction failure. Return the error directly so the agent
loop can log or handle it as needed.

* feat(session): add Close to SessionStore interface

Add Close() error to SessionStore so callers can release resources
through the interface. JSONLBackend already had Close; this adds
a no-op implementation to SessionManager for compatibility.

* fix(session): close session stores on shutdown and harden migration

- Add Close() to AgentInstance, AgentRegistry, and AgentLoop so JSONL
  file handles are released during gateway shutdown and CLI exit.
- Fall back to SessionManager when migration fails, preventing a split
  state where some sessions live in JSONL and others remain in JSON.
- Add defer agentLoop.Close() in the CLI agent command path.
- Document SessionStore interface methods (fire-and-forget contract).
2026-03-10 15:14:09 +08:00
..
agent feat(session): integrate JSONL persistence into agent loop (#1170) 2026-03-10 15:14:09 +08:00
auth feat(auth): add Anthropic OAuth setup-token login (#926) 2026-03-06 19:58:23 +08:00
bus chore: resolve conflicts with upstream/main 2026-02-28 12:21:54 +08:00
channels feat(channels): enhance QQ channel with group/typing/media support and URL sanitization (#1208) 2026-03-10 12:07:02 +08:00
commands feat: add /clear command to clear chat history (#1266) 2026-03-09 16:39:33 +08:00
config feat(channels): enhance QQ channel with group/typing/media support and URL sanitization (#1208) 2026-03-10 12:07:02 +08:00
constants refactor: replace bool map with set-style map for internal channels (#472) 2026-02-19 11:48:17 +01:00
cron feat(cron): add execution lifecycle logging (#1185) 2026-03-06 20:46:52 +08:00
devices refactor: cleanup dead code and turn on dead code detection in CI (#515) 2026-02-24 21:52:25 +08:00
fileutil refactor(pkg): move atomic file write to dedicated fileutil package 2026-02-24 23:57:13 +08:00
health chore: resolve conflicts with upstream/main 2026-02-28 12:21:54 +08:00
heartbeat enable dupl check 2026-03-01 18:17:32 +11:00
identity feat(identity): add unified user identity with canonical platform:id format 2026-02-23 06:56:48 +08:00
logger enable prealloc 2026-02-25 21:31:07 +11:00
mcp Feat/add tool enable or disable configuration (#1071) 2026-03-05 14:53:26 +08:00
media chore: resolve conflicts with upstream/main 2026-02-28 12:21:54 +08:00
memory fix(memory): fsync appended message for consistent durability 2026-03-04 19:21:34 +08:00
migrate feat: add Matrix channel support 2026-03-07 17:44:24 +00:00
providers * add minimax provider (#1273) 2026-03-09 18:43:58 +08:00
routing fix(routing): address review feedback on CJK estimation and observability 2026-03-06 13:10:20 +08:00
session feat(session): integrate JSONL persistence into agent loop (#1170) 2026-03-10 15:14:09 +08:00
skills refactor(skills): reuse shared HTTP retry helper 2026-03-05 19:10:36 +08:00
state fix: error check on state (#864) 2026-03-02 11:59:26 +11:00
tools feat(mcp): tool search tools (#1243) 2026-03-09 18:21:49 +01:00
utils feat(mcp): tool search tools (#1243) 2026-03-09 18:21:49 +01:00
voice Fix lint 2026-03-04 10:21:59 +00:00