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
This commit is contained in:
Mario Zechner 2025-12-27 02:46:52 +01:00
parent 29fec7848e
commit 5fee9005b7
4 changed files with 18 additions and 11 deletions

View file

@ -9,11 +9,13 @@ describe("Documentation example", () => {
it("custom compaction example should type-check correctly", () => {
// This is the example from hooks.md - verify it compiles
const exampleHook = (pi: HookAPI) => {
pi.on("session", async (event, _ctx) => {
pi.on("session", async (event, ctx) => {
if (event.reason !== "before_compact") return;
// After narrowing, these should all be accessible
const { preparation, previousCompactions, sessionManager, modelRegistry, model } = event;
// sessionManager and modelRegistry come from ctx, not event
const { preparation, previousCompactions, model } = event;
const { sessionManager, modelRegistry } = ctx;
const { messagesToSummarize, messagesToKeep, tokensBefore, firstKeptEntryId, cutPoint } = preparation;
// Get previous summary from most recent compaction