Mario Zechner
5fee9005b7
Fix tests for sessionManager/modelRegistry on context
...
- compaction-hooks-example.test.ts: get sessionManager/modelRegistry from ctx
- compaction-hooks.test.ts:
- Pass sessionManager/modelRegistry to HookRunner constructor
- Remove setSessionFile call
- Update tests to use session.sessionManager instead of event.sessionManager
2025-12-30 22:42:19 +01:00
Mario Zechner
9bba388ec5
Refactor SessionEventBase to pass sessionManager and modelRegistry
...
Breaking changes to hook types:
- SessionEventBase now passes sessionManager and modelRegistry directly
- before_compact: passes preparation, previousCompactions (newest first)
- before_switch: has targetSessionFile; switch: has previousSessionFile
- Removed resolveApiKey (use modelRegistry.getApiKey())
- getSessionFile() returns string | undefined for in-memory sessions
Updated:
- All session event emissions in agent-session.ts
- Hook examples (custom-compaction.ts, auto-commit-on-exit.ts, confirm-destructive.ts)
- Tests (compaction-hooks.test.ts, compaction-hooks-example.test.ts)
- export-html.ts guards for in-memory sessions
2025-12-30 22:42:18 +01:00
Mario Zechner
c58d5f20a4
Session tree structure with id/parentId linking
...
- Add TreeNode base type with id, parentId, timestamp
- Add *Content types for clean input/output separation
- Entry types are now TreeNode & *Content intersections
- SessionManager assigns id/parentId on save, tracks leafId
- Add migrateSessionEntries() for v1 to v2 conversion
- Migration runs on load, rewrites file
- buildSessionContext() uses tree traversal from leaf
- Compaction returns CompactionResult (content only)
- Hooks return compaction content, not full entries
- Add firstKeptEntryId to before_compact hook event
- Update mom package for tree fields
- Better error messages for compaction failures
2025-12-30 22:42:17 +01:00
Mario Zechner
d9a542763a
Improve before_compact hook: add messagesToKeep, replace apiKey with resolveApiKey
2025-12-24 12:41:22 +01:00
Nico Bailon
1e1a92ea47
Add before_compact hook event ( closes #281 ) ( #285 )
...
* Add before_compact hook event (closes #281 )
* Add compact hook event and documentation
- Add compact event that fires after compaction completes
- Update hooks.md with lifecycle diagram, field docs, and example
- Add CHANGELOG entry
- Add comprehensive test coverage (10 tests) for before_compact and compact events
- Tests cover: event emission, cancellation, custom entry, error handling, multiple hooks
2025-12-24 11:26:29 +01:00