#!/usr/bin/env node
import {a}from'./chunk-EKZDFEJW.js';import'./chunk-XHJ27CER.js';import*as n from'fs';import*as o from'path';import*as p from'js-yaml';var l={architect:"opus",security:"opus",reviewer:"sonnet",builder:"haiku",tester:"haiku"},c=class{name="claude-code-teams";tasksDir;constructor(t=process.cwd()){this.tasksDir=o.join(t,".paradigm","tasks","teams");}listModels(){return ["opus","sonnet","haiku"]}supportsParallel(){return  true}supportsMcp(){return  true}getTokenCost(t){return a[t]}async isAvailable(){if(!(process.env.CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS==="1"))return  false;let s=o.join(process.env.HOME||"",".claude");return n.existsSync(s)||process.env.CLAUDE_CODE==="1"||process.env.TERM_PROGRAM==="claude"}async*spawn(t,s){let e=this.generateTaskId(t.name),a=o.join(this.tasksDir,`${e}.yaml`);n.existsSync(this.tasksDir)||n.mkdirSync(this.tasksDir,{recursive:true});let i=this.buildTeammatePrompt(t,s),r=s.model||l[t.name]||"sonnet",u={id:e,provider:"claude-code-teams",agent:t.name,model:r,status:"pending",created:new Date().toISOString(),task:s.task,teammateConfig:{prompt:i,model:r,delegateMode:t.name==="architect"||t.name==="security",focus:t.focus},context:{symbols:s.context.symbols,handoffContext:s.context.handoffContext}};n.writeFileSync(a,p.dump(u)),yield {type:"text",content:`Agent Teams task created: ${e}
`,timestamp:new Date().toISOString()},yield {type:"text",content:this.buildSpawnInstruction(t,i,r),timestamp:new Date().toISOString()};let d={subject:`${t.name}: ${s.task.slice(0,80)}`,description:i,activeForm:`Running ${t.name} agent`};yield {type:"text",content:`
**Shared task list entry:**
\`\`\`json
${JSON.stringify(d,null,2)}
\`\`\`
`,timestamp:new Date().toISOString()},yield {type:"done",content:"Teammate task created. Team lead should spawn teammate with the prompt above.",usage:{input:0,output:0,total:0},timestamp:new Date().toISOString()};}generateTaskId(t){let s=Date.now(),e=Math.random().toString(36).substring(2,6);return `teams-${t}-${s}-${e}`}buildTeammatePrompt(t,s){let e=[],a={architect:"Design and spec only \u2014 do NOT write implementation code.",security:"Audit gates and security \u2014 do NOT make code changes.",builder:"Implement from spec \u2014 follow the architect's design exactly.",reviewer:"Review code and report issues \u2014 do NOT change implementation.",tester:"Run tests and verify gates \u2014 do NOT change implementation."};return e.push(`# ${t.name.toUpperCase()} Agent (Teammate)`),e.push(""),e.push("## Role"),e.push(t.role),e.push(""),e.push("## Constraint"),e.push(a[t.name]||"Complete the assigned task."),e.push(""),e.push("## Task"),e.push(s.task),e.push(""),s.context.symbols.length>0&&(e.push("## Symbols in Scope"),e.push(s.context.symbols.join(", ")),e.push("")),s.context.handoffContext&&(e.push("## Context from Previous Agent"),e.push(s.context.handoffContext),e.push("")),e.push("## Focus Areas"),e.push(`Read: ${t.focus.reads.join(", ")}`),e.push(`Write: ${t.focus.writes.join(", ")}`),e.push(""),e.push("## When Done"),e.push("Update your task status to completed and include a summary of what was accomplished."),e.push("If you need another agent to continue, send a message to the team lead."),e.join(`
`)}buildSpawnInstruction(t,s,e){let a=t.name==="architect"||t.name==="security";return `
---
**To spawn this teammate, the team lead should:**

1. Create a task in the shared task list:
   \`\`\`
   TaskCreate({
     subject: "${t.name}: ${t.role.split(`
`)[0].slice(0,50)}",
     description: "(full prompt above)",
     activeForm: "Running ${t.name} agent"
   })
   \`\`\`

2. The teammate will pick up the task and execute it${a?" (design/review only, no code changes)":""}.

3. When complete, the teammate updates the task status and sends results via the mailbox.

**Model:** ${e}
**Delegate mode:** ${a?"Yes (coordination only)":"No (implementation allowed)"}
---`}};export{c as ClaudeCodeTeamsProvider};