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

Function normalizeAttachmentForAPI

src/utils/messages.ts:3553–4386  ·  view source on GitHub ↗
(
  attachment: Attachment,
)

Source from the content-addressed store, hash-verified

3551}
3552
3553export function normalizeAttachmentForAPI(
3554 attachment: Attachment,
3555): UserMessage[] {
3556 if (isAgentSwarmsEnabled()) {
3557 if (attachment.type === 'teammate_mailbox') {
3558 return [
3559 createUserMessage({
3560 content: getTeammateMailbox().formatTeammateMessages(
3561 attachment.messages,
3562 ),
3563 isMeta: true,
3564 }),
3565 ]
3566 }
3567 if (attachment.type === 'team_context') {
3568 return [
3569 createUserMessage({
3570 content: `<system-reminder>
3571# Team Coordination
3572
3573You are a teammate in team "${attachment.teamName}".
3574
3575**Your Identity:**
3576- Name: ${attachment.agentName}
3577
3578**Team Resources:**
3579- Team config: ${attachment.teamConfigPath}
3580- Task list: ${attachment.taskListPath}
3581
3582**Team Leader:** The team lead's name is "team-lead". Send updates and completion notifications to them.
3583
3584Read the team config to discover your teammates' names. Check the task list periodically. Create new tasks when work should be divided. Mark tasks resolved when complete.
3585
3586**IMPORTANT:** Always refer to teammates by their NAME (e.g., "team-lead", "analyzer", "researcher"), never by UUID. When messaging, use the name directly:
3587
3588\`\`\`json
3589{
3590 "to": "team-lead",
3591 "message": "Your message here",
3592 "summary": "Brief 5-10 word preview"
3593}
3594\`\`\`
3595</system-reminder>`,
3596 isMeta: true,
3597 }),
3598 ]
3599 }
3600 }
3601
3602
3603 // skill_discovery handled here (not in the switch) so the 'skill_discovery'
3604 // string literal lives inside a feature()-guarded block. A case label can't
3605 // be gated, but this pattern can — same approach as teammate_mailbox above.
3606 if (feature('EXPERIMENTAL_SKILL_SEARCH')) {
3607 if (attachment.type === 'skill_discovery') {
3608 if (attachment.skills.length === 0) return []
3609 const lines = attachment.skills.map(s => `- ${s.name}: ${s.description}`)
3610 return wrapMessagesInSystemReminder([

Callers 2

normalizeMessagesForAPIFunction · 0.85

Calls 15

isAgentSwarmsEnabledFunction · 0.85
getTeammateMailboxFunction · 0.85
createToolUseMessageFunction · 0.85
quoteFunction · 0.85
formatFileSizeFunction · 0.85
isTodoV2EnabledFunction · 0.85
memoryHeaderFunction · 0.85
wrapCommandTextFunction · 0.85
getPlanModeInstructionsFunction · 0.85
getAutoModeInstructionsFunction · 0.85
logMCPDebugFunction · 0.85

Tested by

no test coverage detected