agentix-cli 0.52.1 → 0.53.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (106) hide show
  1. package/dist/{App-X6FGYBLX.js → App-R62ZQVSF.js} +2 -2
  2. package/dist/{ChatApp-XMUOXQ2M.js → ChatApp-AS567EFE.js} +2 -2
  3. package/dist/{agent-KKVMU3VB.js → agent-H4NB4BUA.js} +2 -2
  4. package/dist/{board-dashboard-KETIFTBD.js → board-dashboard-E3MUVNVQ.js} +446 -144
  5. package/dist/board-dashboard-E3MUVNVQ.js.map +1 -0
  6. package/dist/{chunk-3IUU4YFI.js → chunk-47EEUZBK.js} +5 -5
  7. package/dist/{chunk-3IUU4YFI.js.map → chunk-47EEUZBK.js.map} +1 -1
  8. package/dist/{chunk-B5UA3X6E.js → chunk-6OOK7Y4S.js} +2 -2
  9. package/dist/{chunk-E57WKMRR.js → chunk-7DPKPBRJ.js} +2 -2
  10. package/dist/{chunk-AKAM4BNC.js → chunk-7OWXFLAM.js} +13 -13
  11. package/dist/{chunk-AWRRBNWQ.js → chunk-C5JXPMTW.js} +2 -2
  12. package/dist/{chunk-H7R3F2CO.js → chunk-CCMM5TP4.js} +2 -2
  13. package/dist/{chunk-WCNKTV6G.js → chunk-D4HAR3L3.js} +14 -14
  14. package/dist/chunk-D4HAR3L3.js.map +1 -0
  15. package/dist/{chunk-7BQQWI4T.js → chunk-FS4WBYY3.js} +2 -2
  16. package/dist/chunk-FSZXY53Z.js +7 -0
  17. package/dist/chunk-FSZXY53Z.js.map +1 -0
  18. package/dist/{chunk-64UYAWAK.js → chunk-IDYP7G7Z.js} +6 -6
  19. package/dist/chunk-IDYP7G7Z.js.map +1 -0
  20. package/dist/{chunk-7NF45XCM.js → chunk-KB7YIM3W.js} +2 -2
  21. package/dist/{chunk-XOUIZBAQ.js → chunk-KFG6WWFS.js} +2 -2
  22. package/dist/{chunk-YPPTPBBV.js → chunk-KJWBQZT7.js} +2 -2
  23. package/dist/{chunk-MHBUAU2B.js → chunk-NF52Q3TV.js} +2 -2
  24. package/dist/{chunk-YS3Z2Z64.js → chunk-OMTRHHZJ.js} +13 -13
  25. package/dist/chunk-OMTRHHZJ.js.map +1 -0
  26. package/dist/{chunk-QDPLR3SB.js → chunk-OV35MJKS.js} +2 -2
  27. package/dist/{chunk-QZ4M2KAC.js → chunk-PGJL5V6Y.js} +2 -2
  28. package/dist/{chunk-76NNONUJ.js → chunk-QU6ZUKAD.js} +2 -2
  29. package/dist/chunk-SABOPOYX.js +1111 -0
  30. package/dist/chunk-SABOPOYX.js.map +1 -0
  31. package/dist/{chunk-NKSCUCVZ.js → chunk-TH5KNJLA.js} +2 -2
  32. package/dist/{chunk-7M7VJMGP.js → chunk-VD4TMPJI.js} +2 -2
  33. package/dist/cli.js +1 -1
  34. package/dist/client-XTQDYMOX.js +2 -0
  35. package/dist/{config-FGCJVXYX.js → config-3SW4V44Z.js} +2 -2
  36. package/dist/config-mutator-H32FXUYJ.js +2 -0
  37. package/dist/doctor-J6RCHFVE.js +2 -0
  38. package/dist/index.d.ts +42 -0
  39. package/dist/index.js +1 -1
  40. package/dist/program-SQTOPCQW.js +2 -0
  41. package/dist/{promote-NBFF7ZIW.js → promote-DJFMTLRC.js} +2 -2
  42. package/dist/query-UAZUMU4N.js +2 -0
  43. package/dist/{registry-5ZP3ZNSH.js → registry-4OUBA2TY.js} +2 -2
  44. package/dist/{request-planner-ZEXFARZE.js → request-planner-2H7HCUCZ.js} +2 -2
  45. package/dist/{review-candidates-F2HNH2TZ.js → review-candidates-U7R64OCS.js} +2 -2
  46. package/dist/{routing-XSRZ7V23.js → routing-LVQH6WOJ.js} +2 -2
  47. package/dist/schedule-tool-2BONJVCJ.js +2 -0
  48. package/dist/scheduler-7CEXDECA.js +2 -0
  49. package/dist/{seat-IPDLEUI5.js → seat-2KGFNCIW.js} +2 -2
  50. package/dist/{select-BYOX63CR.js → select-XGK27RPP.js} +2 -2
  51. package/dist/set-enabled-7YGN2FAZ.js +2 -0
  52. package/dist/set-enabled-7YGN2FAZ.js.map +1 -0
  53. package/dist/{tool-WW4YCMSP.js → tool-HKDIZ6I4.js} +2 -2
  54. package/dist/wiki-6YT7B5HU.js +2 -0
  55. package/package.json +1 -1
  56. package/dist/board-dashboard-KETIFTBD.js.map +0 -1
  57. package/dist/chunk-64UYAWAK.js.map +0 -1
  58. package/dist/chunk-6BXKZY76.js +0 -7
  59. package/dist/chunk-6BXKZY76.js.map +0 -1
  60. package/dist/chunk-7PK32QT5.js +0 -1107
  61. package/dist/chunk-7PK32QT5.js.map +0 -1
  62. package/dist/chunk-WCNKTV6G.js.map +0 -1
  63. package/dist/chunk-YS3Z2Z64.js.map +0 -1
  64. package/dist/client-AVQSLPIZ.js +0 -2
  65. package/dist/config-mutator-5JSG3CHW.js +0 -2
  66. package/dist/doctor-VITHTLEC.js +0 -2
  67. package/dist/program-MNFDOQGQ.js +0 -2
  68. package/dist/query-XCXR57IV.js +0 -2
  69. package/dist/schedule-tool-AKCVLCWK.js +0 -2
  70. package/dist/scheduler-BEGZJWJU.js +0 -2
  71. package/dist/wiki-IVJJQUKB.js +0 -2
  72. /package/dist/{App-X6FGYBLX.js.map → App-R62ZQVSF.js.map} +0 -0
  73. /package/dist/{ChatApp-XMUOXQ2M.js.map → ChatApp-AS567EFE.js.map} +0 -0
  74. /package/dist/{agent-KKVMU3VB.js.map → agent-H4NB4BUA.js.map} +0 -0
  75. /package/dist/{chunk-B5UA3X6E.js.map → chunk-6OOK7Y4S.js.map} +0 -0
  76. /package/dist/{chunk-E57WKMRR.js.map → chunk-7DPKPBRJ.js.map} +0 -0
  77. /package/dist/{chunk-AKAM4BNC.js.map → chunk-7OWXFLAM.js.map} +0 -0
  78. /package/dist/{chunk-AWRRBNWQ.js.map → chunk-C5JXPMTW.js.map} +0 -0
  79. /package/dist/{chunk-H7R3F2CO.js.map → chunk-CCMM5TP4.js.map} +0 -0
  80. /package/dist/{chunk-7BQQWI4T.js.map → chunk-FS4WBYY3.js.map} +0 -0
  81. /package/dist/{chunk-7NF45XCM.js.map → chunk-KB7YIM3W.js.map} +0 -0
  82. /package/dist/{chunk-XOUIZBAQ.js.map → chunk-KFG6WWFS.js.map} +0 -0
  83. /package/dist/{chunk-YPPTPBBV.js.map → chunk-KJWBQZT7.js.map} +0 -0
  84. /package/dist/{chunk-MHBUAU2B.js.map → chunk-NF52Q3TV.js.map} +0 -0
  85. /package/dist/{chunk-QDPLR3SB.js.map → chunk-OV35MJKS.js.map} +0 -0
  86. /package/dist/{chunk-QZ4M2KAC.js.map → chunk-PGJL5V6Y.js.map} +0 -0
  87. /package/dist/{chunk-76NNONUJ.js.map → chunk-QU6ZUKAD.js.map} +0 -0
  88. /package/dist/{chunk-NKSCUCVZ.js.map → chunk-TH5KNJLA.js.map} +0 -0
  89. /package/dist/{chunk-7M7VJMGP.js.map → chunk-VD4TMPJI.js.map} +0 -0
  90. /package/dist/{client-AVQSLPIZ.js.map → client-XTQDYMOX.js.map} +0 -0
  91. /package/dist/{config-FGCJVXYX.js.map → config-3SW4V44Z.js.map} +0 -0
  92. /package/dist/{config-mutator-5JSG3CHW.js.map → config-mutator-H32FXUYJ.js.map} +0 -0
  93. /package/dist/{doctor-VITHTLEC.js.map → doctor-J6RCHFVE.js.map} +0 -0
  94. /package/dist/{program-MNFDOQGQ.js.map → program-SQTOPCQW.js.map} +0 -0
  95. /package/dist/{promote-NBFF7ZIW.js.map → promote-DJFMTLRC.js.map} +0 -0
  96. /package/dist/{query-XCXR57IV.js.map → query-UAZUMU4N.js.map} +0 -0
  97. /package/dist/{registry-5ZP3ZNSH.js.map → registry-4OUBA2TY.js.map} +0 -0
  98. /package/dist/{request-planner-ZEXFARZE.js.map → request-planner-2H7HCUCZ.js.map} +0 -0
  99. /package/dist/{review-candidates-F2HNH2TZ.js.map → review-candidates-U7R64OCS.js.map} +0 -0
  100. /package/dist/{routing-XSRZ7V23.js.map → routing-LVQH6WOJ.js.map} +0 -0
  101. /package/dist/{schedule-tool-AKCVLCWK.js.map → schedule-tool-2BONJVCJ.js.map} +0 -0
  102. /package/dist/{scheduler-BEGZJWJU.js.map → scheduler-7CEXDECA.js.map} +0 -0
  103. /package/dist/{seat-IPDLEUI5.js.map → seat-2KGFNCIW.js.map} +0 -0
  104. /package/dist/{select-BYOX63CR.js.map → select-XGK27RPP.js.map} +0 -0
  105. /package/dist/{tool-WW4YCMSP.js.map → tool-HKDIZ6I4.js.map} +0 -0
  106. /package/dist/{wiki-IVJJQUKB.js.map → wiki-6YT7B5HU.js.map} +0 -0
@@ -1,4 +1,4 @@
1
- import{q as _,r as W}from"./chunk-2AXFYDWF.js";import{b as Y,c as I,d as O}from"./chunk-AQASR6KR.js";import{b as F}from"./chunk-DP7RTNDM.js";import{e as E}from"./chunk-YPPTPBBV.js";import{b as L}from"./chunk-64P4QHSZ.js";import{createHash as ee}from"crypto";import{existsSync as H,readdirSync as te,readFileSync as re,writeFileSync as ne}from"fs";import{resolve as P}from"path";function be(n,r,s,t,o,i,c=""){return Z(r,s,t,o,i,c)}function Z(n,r,s,t,o,i=""){let c=r?`
1
+ import{q as _,r as W}from"./chunk-2AXFYDWF.js";import{b as Y,c as I,d as O}from"./chunk-AQASR6KR.js";import{b as F}from"./chunk-DP7RTNDM.js";import{e as E}from"./chunk-KJWBQZT7.js";import{b as L}from"./chunk-64P4QHSZ.js";import{createHash as ee}from"crypto";import{existsSync as H,readdirSync as te,readFileSync as re,writeFileSync as ne}from"fs";import{resolve as P}from"path";function be(n,r,s,t,o,i,c=""){return Z(r,s,t,o,i,c)}function Z(n,r,s,t,o,i=""){let c=r?`
2
2
  ## Worldview
3
3
 
4
4
  ${r}
@@ -240,4 +240,4 @@ ${g}`}var x="memory-promoter",oe=["project","reference","feedback"],K="_memory-p
240
240
  Re-emit the FULL corrected JSON object \u2014 same structure, fixed issues, valid JSON only.`:n,y=await t(`${a}/task`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({agent:r.viaAgent,message:h,freshSession:s===null,context:{channel:"api",chatId:r.chatId??"memory-promote"}}),signal:i.signal});if(!y.ok){let f=await y.text().catch(()=>"");throw new Error(`agent /task ${y.status}: ${f.slice(0,500)}`)}let w=await y.json();if(w.error)throw new Error(`agent reported error: ${w.error}`);let b=String(w.content??"").trim();if(!b)throw new Error("agent returned empty content");return b}if(!r.model)throw new Error("callPromotionLlm: viaAgent or model is required");let p=process.env.ANTHROPIC_API_KEY;if(!p)throw new Error("ANTHROPIC_API_KEY not set; use --via <agentId> instead");let u=[{role:"user",content:n}];s&&(u.push({role:"assistant",content:"(previous attempt; will retry with corrections)"}),u.push({role:"user",content:`Your previous response failed validation: ${s}
241
241
  Re-emit the FULL corrected JSON object.`}));let g=await t(me,{method:"POST",headers:{"Content-Type":"application/json","x-api-key":p,"anthropic-version":ge},body:JSON.stringify({model:r.model,max_tokens:8e3,messages:u}),signal:i.signal});if(!g.ok){let a=await g.text().catch(()=>"");throw new Error(`anthropic API ${g.status}: ${a.slice(0,500)}`)}let l=await g.json(),e=(Array.isArray(l.content)?l.content:[]).filter(a=>a?.type==="text").map(a=>a.text).join(`
242
242
  `).trim();if(!e)throw new Error("anthropic API returned no text content");return e}finally{clearTimeout(c)}}async function Se(n={}){let r=n.wikiDir??P(process.cwd(),".agentx","wiki"),s=n.memoryRoot??P(process.cwd(),".agentx"),t=n.log??(()=>{}),o=n.now??Date.now(),i={candidates:[],clusters:[],proposed:[],skipped:[],gaps:[],warnings:[],errors:[],dryRun:!n.commit},c=new E(r,(...m)=>t(m.map(String).join(" "))),p=c.rebuildIndex(),u=z(r),g=[...ce(s),...n.extraCandidates??[]];if(i.candidates=de(g,p,u,{types:n.types,sinceMs:n.sinceMs,agentFilter:n.agentFilter,now:o,max:n.max}),i.candidates.length===0)return t("no unpromoted memories in window"),i;if(i.clusters=le(i.candidates),i.dryRun)return i;let l=p.articles.map(m=>({title:m.title,path:m.path,type:m.type})),d=c.getWorldview()??"",e=n.budgetTokens??ue,a=i.clusters,h=D(x,a,l,d);for(;R(h)>e&&a.length>1;)a=a.slice(0,-1),h=D(x,a,l,d);if(R(h)>e)return i.errors.push(`judge prompt (~${R(h)} tokens) exceeds the ${e}-token budget even with one cluster`),i;a.length<i.clusters.length&&i.warnings.push(`token budget: judged ${a.length} of ${i.clusters.length} clusters; the rest wait for the next run`);let y=a.flatMap(m=>m.candidates),w=new Set(y.map(m=>m.stamp)),b=n.chatId??`memory-promote-${new Date(o).toISOString().slice(0,10)}`,f=B(await G(h,{...n,chatId:b}),w);if("error"in f&&(t(`parse failed (${f.error}) \u2014 retrying with feedback`),f=B(await G(h,{...n,chatId:b},f.error),w)),"error"in f)return i.errors.push(`LLM response unusable after retry: ${f.error}`),i;i.warnings.push(...f.warnings),i.gaps=f.gaps;let v=new Date(o).toISOString(),k=[],T=new Map(y.map(m=>[m.stamp,m]));for(let m of f.articles){let A=c.readArticle(m.path);if(A&&!c.canWrite(A.meta,x)){i.errors.push(`write denied for "${m.path}" (owned by ${A.meta.owner??"?"})`);continue}let M=fe(m.promotedFrom,T),S={id:Y(o,m.path),createdAt:v,status:"pending",article:m,evidence:M,...A?{replaces:{lastUpdated:A.meta.lastUpdated,contentHash:V(A.content)}}:{}};I(r,S),i.proposed.push({id:S.id,path:m.path,title:m.title,type:m.type,stamps:m.promotedFrom,agents:M.agents,occurrences:M.occurrences});for(let X of m.promotedFrom)k.push({stamp:X,decision:"proposed",article:m.path,proposal:S.id,at:v})}for(let m of f.skipped)k.push({stamp:m.stamp,decision:"skipped",reason:m.reason,at:v}),i.skipped.push(m);return k.length&&C(r,k),i}var ue=6e4;function R(n){return Math.ceil(n.length/4)}function V(n){return ee("sha256").update(n).digest("hex").slice(0,16)}var he=600;function ye(n){return n.startsWith("review:")?"review":n.startsWith(j)?"failure":"memory"}function fe(n,r){let s=[];for(let t of n){let o=r.get(t);o&&s.push({stamp:t,kind:ye(t),agentId:o.agentId,type:o.memory.type,name:o.memory.name,description:o.memory.description,...o.occurrences?{occurrences:o.occurrences}:{},...o.sessions?.length?{sessions:o.sessions}:{},...o.tasks?.length?{tasks:o.tasks}:{},...o.failure?{failure:o.failure}:{},...o.memory.author?{author:o.memory.author}:{},...o.memory.taskId?{taskId:o.memory.taskId}:{},updatedAt:o.memory.updatedAt,excerpt:o.memory.body.slice(0,he)})}return{agents:[...new Set(s.map(t=>t.agentId))].sort(),occurrences:Math.max(1,...s.map(t=>t.occurrences??1)),sources:s}}function Ee(n,r,s={}){let t=O(n,r);if(!t)return{ok:!1,error:`no proposal "${r}"`};if(t.status!=="pending")return{ok:!1,error:`proposal "${r}" is already ${t.status}`};let o=s.log??(()=>{}),i=new E(n,(...a)=>o(a.map(String).join(" "))),{article:c}=t,p=i.readArticle(c.path);if(!s.force){if(p&&!t.replaces)return{ok:!1,error:`"${c.path}" was created after this proposal; review it, then approve with --force`};if(p&&t.replaces&&V(p.content)!==t.replaces.contentHash)return{ok:!1,error:`"${c.path}" changed since this proposal; review it, then approve with --force`}}let u=s.now??Date.now(),g=new Date(u).toISOString().slice(0,10);if(!i.writeArticle(c.path,{title:c.title,type:L(c.type)?c.type:void 0,related:c.related,tags:c.tags,owner:x,access:"public",created:p?.meta.created??g,lastUpdated:g,sources:ae(p?.meta.sources,c.promotedFrom)},c.content,x))return{ok:!1,error:`write denied for "${c.path}" (owned by ${p?.meta.owner??"?"})`};let d=new Date(u).toISOString();C(n,c.promotedFrom.map(a=>({stamp:a,decision:"promoted",article:c.path,proposal:r,at:d}))),i.rebuildIndex();let e={...t,status:"approved",decidedBy:s.by??"operator",decidedAt:d};return I(n,e),{ok:!0,proposal:e}}function Oe(n,r,s={}){let t=O(n,r);if(!t)return{ok:!1,error:`no proposal "${r}"`};if(t.status!=="pending")return{ok:!1,error:`proposal "${r}" is already ${t.status}`};let o=new Date(s.now??Date.now()).toISOString();C(n,t.article.promotedFrom.map(c=>({stamp:c,decision:"rejected",article:t.article.path,proposal:r,reason:s.reason,at:o})));let i={...t,status:"rejected",decidedBy:s.by??"operator",decidedAt:o,...s.reason?{reason:s.reason}:{}};return I(n,i),{ok:!0,proposal:i}}export{be as a,x as b,oe as c,K as d,q as e,ie as f,$ as g,ae as h,ce as i,z as j,C as k,le as l,B as m,de as n,G as o,Se as p,R as q,ye as r,fe as s,Ee as t,Oe as u};
243
- //# sourceMappingURL=chunk-B5UA3X6E.js.map
243
+ //# sourceMappingURL=chunk-6OOK7Y4S.js.map
@@ -48,7 +48,7 @@ The "modified" field is optional and can contain updated values to pass forward.
48
48
  ... (output truncated)`:i;return s.exitCode!==0?{tool_use_id:e.id,content:`Command exited with code ${s.exitCode}:
49
49
  ${c}`,is_error:!0}:{tool_use_id:e.id,content:c||"(no output)"}}async editFile(e){let t=String(e.input.path||""),o=e.input.edits,n=ge.resolve(this.cwd,t);if(!o||o.length===0)return{tool_use_id:e.id,content:"No edits provided.",is_error:!0};let s=await W.checkFileWrite(t);if(s==="deny")return{tool_use_id:e.id,content:`File write blocked by permissions: ${t}`,is_error:!0};if(s==="skip")return{tool_use_id:e.id,content:`File write skipped (plan mode): ${t}`};if(f.has("pre:file-write")){let a=await f.execute("pre:file-write",{event:"pre:file-write",file:n,cwd:this.cwd});if(a.blocked)return{tool_use_id:e.id,content:a.message||`File edit blocked by pre:file-write hook: ${t}`,is_error:!0}}let i=await re.readFile(n,"utf8"),c=[];for(let a of o)i.includes(a.old_text)?(i=i.replace(a.old_text,a.new_text),c.push(`Replaced: "${a.old_text.slice(0,40)}..."`)):c.push(`Not found: "${a.old_text.slice(0,40)}..."`);return this.options.dryRun||await re.writeFile(n,i,"utf8"),f.has("post:file-write")&&await f.execute("post:file-write",{event:"post:file-write",file:n,fileContent:i,cwd:this.cwd}),{tool_use_id:e.id,content:`Edited ${t}:
50
50
  ${c.join(`
51
- `)}`}}async createFiles(e){let t=e.input,o=t.files||[];return{tool_use_id:e.id,content:t.summary||`Queued ${o.length} file(s) for creation.`,files:o}}async spawnAgent(e){let t=String(e.input.agent_id||""),o=String(e.input.prompt||""),n=Number(e.input.timeout_seconds)||300;if(!t||!o)return{tool_use_id:e.id,content:"agent_id and prompt are required.",is_error:!0};try{let{SubAgentManager:s}=await import("./subagent-XY5N7TUU.js"),{getGlobalRegistry:i}=await import("./registry-5ZP3ZNSH.js"),c=i();if(!c)return{tool_use_id:e.id,content:"Sub-agent spawning requires the daemon to be running.",is_error:!0};let p=await new s(c).spawn({targetAgentId:t,prompt:o,parentAgentId:"orchestrator",timeout:n*1e3});return p.success?{tool_use_id:e.id,content:`Sub-agent "${t}" completed (${Math.round(p.duration/1e3)}s):
51
+ `)}`}}async createFiles(e){let t=e.input,o=t.files||[];return{tool_use_id:e.id,content:t.summary||`Queued ${o.length} file(s) for creation.`,files:o}}async spawnAgent(e){let t=String(e.input.agent_id||""),o=String(e.input.prompt||""),n=Number(e.input.timeout_seconds)||300;if(!t||!o)return{tool_use_id:e.id,content:"agent_id and prompt are required.",is_error:!0};try{let{SubAgentManager:s}=await import("./subagent-XY5N7TUU.js"),{getGlobalRegistry:i}=await import("./registry-4OUBA2TY.js"),c=i();if(!c)return{tool_use_id:e.id,content:"Sub-agent spawning requires the daemon to be running.",is_error:!0};let p=await new s(c).spawn({targetAgentId:t,prompt:o,parentAgentId:"orchestrator",timeout:n*1e3});return p.success?{tool_use_id:e.id,content:`Sub-agent "${t}" completed (${Math.round(p.duration/1e3)}s):
52
52
 
53
53
  ${p.content}`}:{tool_use_id:e.id,content:`Sub-agent "${t}" failed: ${p.error}`,is_error:!0}}catch(s){return{tool_use_id:e.id,content:`Failed to spawn sub-agent: ${s.message}`,is_error:!0}}}async askUser(e){let t=String(e.input.question||""),o=e.input.options,n=t;return o?.length&&(n+=`
54
54
  Options: ${o.join(", ")}`),{tool_use_id:e.id,content:"Question sent to user.",followUp:n}}};async function Ae(r){let{provider:e,systemPrompt:t,messages:o,providerOptions:n,cwd:s,maxIterations:i=20,enabledTools:c,interactive:a=!0,overwrite:p=!1,dryRun:l=!1,onProgress:d,abortSignal:u}=r,m=u?{...n,abortSignal:u}:n;if(!e.generateRaw)return dt(r);let I=new se(s,{interactive:a,overwrite:p,dryRun:l,acmeContext:r.acmeContext,abortSignal:u}),D=be(c);if(r.acmeContext)for(let g of at)D.push({name:g.name,description:g.description,input_schema:g.input_schema});let E=new Set;if(r.mcpTools?.length)for(let g of r.mcpTools)D.push({name:g.name,description:g.description,input_schema:g.input_schema}),E.add(g.name);let C=o.filter(g=>g.role!=="system").map(g=>({role:g.role,content:g.content})),B=[],G=0,F=0,A=0,O="",j,_=0;for(;_<i;){if(_++,u?.aborted)throw new Error("cancelled");d?.({type:"iteration_start",iteration:_}),b.step(_,`Agentic loop iteration (${D.length} tools available)`);let g,M=!!e.generateRawStream&&!!d;try{if(M){let T=null,U=null,v="";for await(let x of e.generateRawStream(C,t,D,m))x.type==="text_delta"?(v+=x.text,d?.({type:"text_delta",text:x.text})):x.type==="thinking_delta"?d?.({type:"thinking_delta",text:x.text}):x.type==="raw_result"?T=x.result:x.type==="error"&&(U=x.error);if(U&&!T)throw new Error(U);if(!T)throw new Error("generateRawStream returned no raw_result event");g=T,g._streamedText=v}else g=await e.generateRaw(C,t,D,m)}catch(T){if(T.message?.includes("not available"))return dt(r);throw T}G+=g.usage.input_tokens+g.usage.output_tokens,F+=g.usage.input_tokens,A+=g.usage.output_tokens;let P=g._streamedText;for(let T of g.content)T.type==="text"&&(O+=T.text,P===void 0&&d?.({type:"text_delta",text:T.text}));if(P!==void 0&&delete g._streamedText,g.stop_reason==="end_turn"||g.stop_reason==="max_tokens")break;if(g.stop_reason==="tool_use"){let T=g.content.filter(v=>v.type==="tool_use");if(T.length===0)break;C.push({role:"assistant",content:g.content});let U=[];for(let v of T){d?.({type:"tool_call",name:v.name,id:v.id,input:v.input}),b.step(_,`Tool call: ${v.name}`);let x;if(E.has(v.name)&&r.mcpDispatch){let h=await r.mcpDispatch(v.name,v.input);x={tool_use_id:v.id,content:h.content,is_error:h.isError}}else x=await I.execute({name:v.name,id:v.id,input:v.input});d?.({type:"tool_result",name:v.name,id:v.id,content:x.content.slice(0,200),is_error:x.is_error}),x.files?.length&&(B.push(...x.files),d?.({type:"files_created",files:x.files})),x.followUp&&(j=x.followUp),U.push({type:"tool_result",tool_use_id:x.tool_use_id,content:x.content,is_error:x.is_error})}if(C.push({role:"user",content:U}),j)break;continue}break}return d?.({type:"complete",iterations:_,totalTokens:G}),{files:B,content:O,followUp:j,tokensUsed:G,inputTokens:F||void 0,outputTokens:A||void 0,iterations:_}}async function dt(r){let{provider:e,systemPrompt:t,messages:o,providerOptions:n,maxIterations:s=5}=r,c=[{role:"system",content:t+`
@@ -123,4 +123,4 @@ ${r.projectInstructions}`),r.memoryContext&&o.push(r.memoryContext),o.push(`# Ou
123
123
  Generate output appropriate for: ${e}. Use the \`create_files\` tool to output all files.`),o.join(`
124
124
 
125
125
  `)}export{qe as a,Vt as b,Yt as c,We as d,ze as e,Ve as f,Ye as g,Pe as h,ee as i,Re as j,le as k,te as l,Tt as m,oe as n,Mt as o,f as p,et as q,tt as r,Me as s,de as t,W as u,ne as v,it as w,Ee as x,$e as y,se as z,mt as A,Zn as B,er as C};
126
- //# sourceMappingURL=chunk-E57WKMRR.js.map
126
+ //# sourceMappingURL=chunk-7DPKPBRJ.js.map