MCPcopy Create free account
hub / github.com/HELPMEEADICE/doge-code / normalizeAttachmentForAPI

Function normalizeAttachmentForAPI

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

Source from the content-addressed store, hash-verified

3456}
3457
3458export function normalizeAttachmentForAPI(
3459 attachment: Attachment,
3460): UserMessage[] {
3461 if (isAgentSwarmsEnabled()) {
3462 if (attachment.type === 'teammate_mailbox') {
3463 return [
3464 createUserMessage({
3465 content: getTeammateMailbox().formatTeammateMessages(
3466 attachment.messages,
3467 ),
3468 isMeta: true,
3469 }),
3470 ]
3471 }
3472 if (attachment.type === 'team_context') {
3473 return [
3474 createUserMessage({
3475 content: `<system-reminder>
3476# Team Coordination
3477
3478You are a teammate in team "${attachment.teamName}".
3479
3480**Your Identity:**
3481- Name: ${attachment.agentName}
3482
3483**Team Resources:**
3484- Team config: ${attachment.teamConfigPath}
3485- Task list: ${attachment.taskListPath}
3486
3487**Team Leader:** The team lead's name is "team-lead". Send updates and completion notifications to them.
3488
3489Read 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.
3490
3491**IMPORTANT:** Always refer to teammates by their NAME (e.g., "team-lead", "analyzer", "researcher"), never by UUID. When messaging, use the name directly:
3492
3493\`\`\`json
3494{
3495 "to": "team-lead",
3496 "message": "Your message here",
3497 "summary": "Brief 5-10 word preview"
3498}
3499\`\`\`
3500</system-reminder>`,
3501 isMeta: true,
3502 }),
3503 ]
3504 }
3505 }
3506
3507
3508 // skill_discovery handled here (not in the switch) so the 'skill_discovery'
3509 // string literal lives inside a feature()-guarded block. A case label can't
3510 // be gated, but this pattern can — same approach as teammate_mailbox above.
3511 if (feature('EXPERIMENTAL_SKILL_SEARCH')) {
3512 if (attachment.type === 'skill_discovery') {
3513 if (attachment.skills.length === 0) return []
3514 const lines = attachment.skills.map(s => `- ${s.name}: ${s.description}`)
3515 return wrapMessagesInSystemReminder([

Callers 2

normalizeMessagesForAPIFunction · 0.85

Calls 15

isAgentSwarmsEnabledFunction · 0.85
createUserMessageFunction · 0.85
getTeammateMailboxFunction · 0.85
createToolUseMessageFunction · 0.85
quoteFunction · 0.85
createToolResultMessageFunction · 0.85
formatFileSizeFunction · 0.85
isTodoV2EnabledFunction · 0.85
memoryHeaderFunction · 0.85
wrapCommandTextFunction · 0.85
getPlanModeInstructionsFunction · 0.85

Tested by

no test coverage detected