import{a as d,b as g}from"./chunk-74CEPOFO.js";import"./chunk-DXB73IDG.js";var c={name:"ag-message",summary:"inter-agent messaging",usage:"ag-message <send|broadcast|inbox> [args]",options:["  send      <from> <to> <message>","  broadcast <from> <team-name> <message>","  inbox     <agent-id>","  --help    display this help and exit"]},x={name:"ag-message",async execute(s,i){if(g(s))return d(c);let o=i.bash?.services?.teamManager;if(!o)return{stdout:"",stderr:`ag-message: team manager not available
`,exitCode:1};let r=s[0];if(!r)return{stdout:"",stderr:`Usage: ag-message <send|broadcast|inbox> [args]
`,exitCode:1};switch(r){case"send":{let t=s[1],e=s[2],a=s.slice(3).join(" ");return!t||!e||!a?{stdout:"",stderr:`Usage: ag-message send <from> <to> <message>
`,exitCode:1}:{stdout:`Sent ${o.sendMessage(t,e,a).id}: ${t} -> ${e}
`,stderr:"",exitCode:0}}case"broadcast":{let t=s[1],e=s[2],a=s.slice(3).join(" ");if(!t||!e||!a)return{stdout:"",stderr:`Usage: ag-message broadcast <from> <team-name> <message>
`,exitCode:1};try{return{stdout:`Broadcast to ${o.broadcast(t,e,a).length} agent(s) in ${e}
`,stderr:"",exitCode:0}}catch(n){return{stdout:"",stderr:`ag-message: ${n instanceof Error?n.message:String(n)}
`,exitCode:1}}}case"inbox":{let t=s[1];if(!t)return{stdout:"",stderr:`Usage: ag-message inbox <agent-id>
`,exitCode:1};let e=o.getInbox(t);if(e.length===0)return{stdout:`No messages.
`,stderr:"",exitCode:0};let a=`Inbox for ${t} (${e.length} message${e.length!==1?"s":""}):
`;for(let n of e){let m=new Date(n.timestamp).toISOString().slice(11,19);a+=`  [${m}] ${n.from}: ${n.content}
`}return{stdout:a,stderr:"",exitCode:0}}default:return{stdout:"",stderr:`ag-message: unknown subcommand: ${r}
`,exitCode:1}}}};export{x as agMessageCommand};
