MCPcopy Create free account
hub / github.com/Noumena-Network/code / getAsyncHookResponseAttachments

Function getAsyncHookResponseAttachments

src/utils/attachments.ts:3471–3525  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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

Callers 1

getAttachmentsFunction · 0.85

Calls 4

jsonStringifyFunction · 0.85
logForDebuggingFunction · 0.70

Tested by

no test coverage detected