(
compactData: {
trigger: 'manual' | 'auto'
compactSummary: string
},
signal?: AbortSignal,
timeoutMs: number = TOOL_HOOK_EXECUTION_TIMEOUT_MS,
)
| 4127 | * @returns Object with optional userDisplayMessage |
| 4128 | */ |
| 4129 | export async function executePostCompactHooks( |
| 4130 | compactData: { |
| 4131 | trigger: 'manual' | 'auto' |
| 4132 | compactSummary: string |
| 4133 | }, |
| 4134 | signal?: AbortSignal, |
| 4135 | timeoutMs: number = TOOL_HOOK_EXECUTION_TIMEOUT_MS, |
| 4136 | ): Promise<{ |
| 4137 | userDisplayMessage?: string |
| 4138 | }> { |
| 4139 | const hookInput: PostCompactHookInput = { |
| 4140 | ...createBaseHookInput(undefined), |
| 4141 | hook_event_name: 'PostCompact', |
| 4142 | trigger: compactData.trigger, |
| 4143 | compact_summary: compactData.compactSummary, |
| 4144 | } |
| 4145 | |
| 4146 | const results = await executeHooksOutsideREPL({ |
| 4147 | hookInput, |
| 4148 | matchQuery: compactData.trigger, |
| 4149 | signal, |
| 4150 | timeoutMs, |
| 4151 | }) |
| 4152 | |
| 4153 | if (results.length === 0) { |
| 4154 | return {} |
| 4155 | } |
| 4156 | |
| 4157 | const displayMessages: string[] = [] |
| 4158 | for (const result of results) { |
| 4159 | if (result.succeeded) { |
| 4160 | if (result.output.trim()) { |
| 4161 | displayMessages.push( |
| 4162 | `PostCompact [${result.command}] completed successfully: ${result.output.trim()}`, |
| 4163 | ) |
| 4164 | } else { |
| 4165 | displayMessages.push( |
| 4166 | `PostCompact [${result.command}] completed successfully`, |
| 4167 | ) |
| 4168 | } |
| 4169 | } else { |
| 4170 | if (result.output.trim()) { |
| 4171 | displayMessages.push( |
| 4172 | `PostCompact [${result.command}] failed: ${result.output.trim()}`, |
| 4173 | ) |
| 4174 | } else { |
| 4175 | displayMessages.push(`PostCompact [${result.command}] failed`) |
| 4176 | } |
| 4177 | } |
| 4178 | } |
| 4179 | |
| 4180 | return { |
| 4181 | userDisplayMessage: |
| 4182 | displayMessages.length > 0 ? displayMessages.join('\n') : undefined, |
| 4183 | } |
| 4184 | } |
| 4185 | |
| 4186 | /** |
no test coverage detected