MCPcopy Create free account
hub / github.com/AnukarOP/claude-code-leaked / normalizeAttachmentForAPI

Function normalizeAttachmentForAPI

source code/utils/messages.ts:3455–4288  ·  view source on GitHub ↗
(
  attachment: Attachment,
)

Source from the content-addressed store, hash-verified

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