Implement preCompact and add test

This commit is contained in:
DennisYu07 2026-03-04 18:53:16 -08:00
parent a5212123dc
commit 1ee871fc60
7 changed files with 1498 additions and 7 deletions

View file

@ -19,6 +19,7 @@ import type {
SessionEndReason,
AgentType,
PermissionMode,
PreCompactTrigger,
} from './types.js';
const debugLogger = createDebugLogger('TRUSTED_HOOKS');
@ -198,4 +199,20 @@ export class HookSystem {
? createHookOutput('PostToolUseFailure', result.finalOutput)
: undefined;
}
/**
* Fire a PreCompact event - called before conversation compaction
*/
async firePreCompactEvent(
trigger: PreCompactTrigger,
customInstructions: string = '',
): Promise<DefaultHookOutput | undefined> {
const result = await this.hookEventHandler.firePreCompactEvent(
trigger,
customInstructions,
);
return result.finalOutput
? createHookOutput('PreCompact', result.finalOutput)
: undefined;
}
}