(
compactData: {
trigger: 'manual' | 'auto'
compactSummary: string
},
signal?: AbortSignal,
timeoutMs: number = TOOL_HOOK_EXECUTION_TIMEOUT_MS,
)
| 4032 | * @returns Object with optional userDisplayMessage |
| 4033 | */ |
| 4034 | export async function executePostCompactHooks( |
| 4035 | compactData: { |
| 4036 | trigger: 'manual' | 'auto' |
| 4037 | compactSummary: string |
| 4038 | }, |
| 4039 | signal?: AbortSignal, |
| 4040 | timeoutMs: number = TOOL_HOOK_EXECUTION_TIMEOUT_MS, |
| 4041 | ): Promise<{ |
| 4042 | userDisplayMessage?: string |
| 4043 | }> { |
| 4044 | const hookInput: PostCompactHookInput = { |
| 4045 | ...createBaseHookInput(undefined), |
| 4046 | hook_event_name: 'PostCompact', |
| 4047 | trigger: compactData.trigger, |
| 4048 | compact_summary: compactData.compactSummary, |
| 4049 | } |
| 4050 | |
| 4051 | const results = await executeHooksOutsideREPL({ |
| 4052 | hookInput, |
| 4053 | matchQuery: compactData.trigger, |
| 4054 | signal, |
| 4055 | timeoutMs, |
| 4056 | }) |
| 4057 | |
| 4058 | if (results.length === 0) { |
| 4059 | return {} |
| 4060 | } |
| 4061 | |
| 4062 | const displayMessages: string[] = [] |
| 4063 | for (const result of results) { |
| 4064 | if (result.succeeded) { |
| 4065 | if (result.output.trim()) { |
| 4066 | displayMessages.push( |
| 4067 | `PostCompact [${result.command}] completed successfully: ${result.output.trim()}`, |
| 4068 | ) |
| 4069 | } else { |
| 4070 | displayMessages.push( |
| 4071 | `PostCompact [${result.command}] completed successfully`, |
| 4072 | ) |
| 4073 | } |
| 4074 | } else { |
| 4075 | if (result.output.trim()) { |
| 4076 | displayMessages.push( |
| 4077 | `PostCompact [${result.command}] failed: ${result.output.trim()}`, |
| 4078 | ) |
| 4079 | } else { |
| 4080 | displayMessages.push(`PostCompact [${result.command}] failed`) |
| 4081 | } |
| 4082 | } |
| 4083 | } |
| 4084 | |
| 4085 | return { |
| 4086 | userDisplayMessage: |
| 4087 | displayMessages.length > 0 ? displayMessages.join('\n') : undefined, |
| 4088 | } |
| 4089 | } |
| 4090 | |
| 4091 | /** |
no test coverage detected