(
compactData: {
trigger: 'manual' | 'auto'
compactSummary: string
},
signal?: AbortSignal,
timeoutMs: number = TOOL_HOOK_EXECUTION_TIMEOUT_MS,
)
| 4191 | * @returns Object with optional userDisplayMessage |
| 4192 | */ |
| 4193 | export async function executePostCompactHooks( |
| 4194 | compactData: { |
| 4195 | trigger: 'manual' | 'auto' |
| 4196 | compactSummary: string |
| 4197 | }, |
| 4198 | signal?: AbortSignal, |
| 4199 | timeoutMs: number = TOOL_HOOK_EXECUTION_TIMEOUT_MS, |
| 4200 | ): Promise<{ |
| 4201 | userDisplayMessage?: string |
| 4202 | }> { |
| 4203 | const hookInput: PostCompactHookInput = { |
| 4204 | ...createBaseHookInput(undefined), |
| 4205 | hook_event_name: 'PostCompact', |
| 4206 | trigger: compactData.trigger, |
| 4207 | compact_summary: compactData.compactSummary, |
| 4208 | } |
| 4209 | |
| 4210 | const results = await executeHooksOutsideREPL({ |
| 4211 | hookInput, |
| 4212 | matchQuery: compactData.trigger, |
| 4213 | signal, |
| 4214 | timeoutMs, |
| 4215 | }) |
| 4216 | |
| 4217 | if (results.length === 0) { |
| 4218 | return {} |
| 4219 | } |
| 4220 | |
| 4221 | const displayMessages: string[] = [] |
| 4222 | for (const result of results) { |
| 4223 | if (result.succeeded) { |
| 4224 | if (result.output.trim()) { |
| 4225 | displayMessages.push( |
| 4226 | `PostCompact [${result.command}] completed successfully: ${result.output.trim()}`, |
| 4227 | ) |
| 4228 | } else { |
| 4229 | displayMessages.push( |
| 4230 | `PostCompact [${result.command}] completed successfully`, |
| 4231 | ) |
| 4232 | } |
| 4233 | } else { |
| 4234 | if (result.output.trim()) { |
| 4235 | displayMessages.push( |
| 4236 | `PostCompact [${result.command}] failed: ${result.output.trim()}`, |
| 4237 | ) |
| 4238 | } else { |
| 4239 | displayMessages.push(`PostCompact [${result.command}] failed`) |
| 4240 | } |
| 4241 | } |
| 4242 | } |
| 4243 | |
| 4244 | return { |
| 4245 | userDisplayMessage: |
| 4246 | displayMessages.length > 0 ? displayMessages.join('\n') : undefined, |
| 4247 | } |
| 4248 | } |
| 4249 | |
| 4250 | /** |
no test coverage detected