( attachment: Attachment, )
| 3839 | } |
| 3840 | |
| 3841 | export function normalizeAttachmentForAPI( |
| 3842 | attachment: Attachment, |
| 3843 | ): UserMessage[] { |
| 3844 | if (isAgentSwarmsEnabled()) { |
| 3845 | if (attachment.type === 'teammate_mailbox') { |
| 3846 | return [ |
| 3847 | createUserMessage({ |
| 3848 | content: getTeammateMailbox().formatTeammateMessages( |
| 3849 | attachment.messages, |
| 3850 | ), |
| 3851 | isMeta: true, |
| 3852 | }), |
| 3853 | ] |
| 3854 | } |
| 3855 | if (attachment.type === 'team_context') { |
| 3856 | return [ |
| 3857 | createUserMessage({ |
| 3858 | content: `<system-reminder> |
| 3859 | # Team Coordination |
| 3860 | |
| 3861 | You are a teammate in team "${attachment.teamName}". |
| 3862 | |
| 3863 | **Your Identity:** |
| 3864 | - Name: ${attachment.agentName} |
| 3865 | |
| 3866 | **Team Resources:** |
| 3867 | - Team config: ${attachment.teamConfigPath} |
| 3868 | - Task list: ${attachment.taskListPath} |
| 3869 | |
| 3870 | **Team Leader:** The team lead's name is "team-lead". Send updates and completion notifications to them. |
| 3871 | |
| 3872 | Read 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. |
| 3873 | |
| 3874 | **IMPORTANT:** Always refer to teammates by their NAME (e.g., "team-lead", "analyzer", "researcher"), never by UUID. When messaging, use the name directly: |
| 3875 | |
| 3876 | \`\`\`json |
| 3877 | { |
| 3878 | "to": "team-lead", |
| 3879 | "message": "Your message here", |
| 3880 | "summary": "Brief 5-10 word preview" |
| 3881 | } |
| 3882 | \`\`\` |
| 3883 | </system-reminder>`, |
| 3884 | isMeta: true, |
| 3885 | }), |
| 3886 | ] |
| 3887 | } |
| 3888 | } |
| 3889 | |
| 3890 | // skill_discovery handled here (not in the switch) so the 'skill_discovery' |
| 3891 | // string literal lives inside a feature()-guarded block. A case label can't |
| 3892 | // be gated, but this pattern can — same approach as teammate_mailbox above. |
| 3893 | if (feature('EXPERIMENTAL_SKILL_SEARCH')) { |
| 3894 | if (attachment.type === 'skill_discovery') { |
| 3895 | if (attachment.skills.length === 0 && !attachment.gap) return [] |
| 3896 | const loaded = attachment.skills.filter(s => s.autoLoaded && s.content) |
| 3897 | const recommended = attachment.skills.filter(s => !s.autoLoaded) |
| 3898 | const loadedSections = loaded.map( |
no test coverage detected