()
| 3462 | } |
| 3463 | |
| 3464 | async function getAsyncHookResponseAttachments(): Promise<Attachment[]> { |
| 3465 | const responses = await checkForAsyncHookResponses() |
| 3466 | |
| 3467 | if (responses.length === 0) { |
| 3468 | return [] |
| 3469 | } |
| 3470 | |
| 3471 | logForDebugging( |
| 3472 | `Hooks: getAsyncHookResponseAttachments found ${responses.length} responses`, |
| 3473 | ) |
| 3474 | |
| 3475 | const attachments = responses.map( |
| 3476 | ({ |
| 3477 | processId, |
| 3478 | response, |
| 3479 | hookName, |
| 3480 | hookEvent, |
| 3481 | toolName, |
| 3482 | pluginId, |
| 3483 | stdout, |
| 3484 | stderr, |
| 3485 | exitCode, |
| 3486 | }) => { |
| 3487 | logForDebugging( |
| 3488 | `Hooks: Creating attachment for ${processId} (${hookName}): ${jsonStringify(response)}`, |
| 3489 | ) |
| 3490 | return { |
| 3491 | type: 'async_hook_response' as const, |
| 3492 | processId, |
| 3493 | hookName, |
| 3494 | hookEvent, |
| 3495 | toolName, |
| 3496 | response, |
| 3497 | stdout, |
| 3498 | stderr, |
| 3499 | exitCode, |
| 3500 | } |
| 3501 | }, |
| 3502 | ) |
| 3503 | |
| 3504 | // Remove delivered hooks from registry to prevent re-processing |
| 3505 | if (responses.length > 0) { |
| 3506 | const processIds = responses.map(r => r.processId) |
| 3507 | removeDeliveredAsyncHooks(processIds) |
| 3508 | logForDebugging( |
| 3509 | `Hooks: Removed ${processIds.length} delivered hooks from registry`, |
| 3510 | ) |
| 3511 | } |
| 3512 | |
| 3513 | logForDebugging( |
| 3514 | `Hooks: getAsyncHookResponseAttachments found ${attachments.length} attachments`, |
| 3515 | ) |
| 3516 | |
| 3517 | return attachments |
| 3518 | } |
| 3519 | |
| 3520 | /** |
| 3521 | * Get teammate mailbox attachments for agent swarm communication |
no test coverage detected