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