agentix-cli 0.44.0 → 0.45.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 (40) hide show
  1. package/apps/mac-helper/Resources/AppIcon.png +0 -0
  2. package/dist/{agent-3XDPLWMX.js → agent-BCZRXLZ6.js} +2 -2
  3. package/dist/{board-dashboard-OYGL7Z7X.js → board-dashboard-U5YP4HWE.js} +110 -114
  4. package/dist/board-dashboard-U5YP4HWE.js.map +1 -0
  5. package/dist/{chunk-7HHVZJO4.js → chunk-3RCFDI52.js} +202 -173
  6. package/dist/chunk-3RCFDI52.js.map +1 -0
  7. package/dist/chunk-CQR6C5FU.js +23 -0
  8. package/dist/chunk-CQR6C5FU.js.map +1 -0
  9. package/dist/{chunk-BTGPZ6B7.js → chunk-CQRSSVWG.js} +2 -2
  10. package/dist/{chunk-Q3Q6FTFY.js → chunk-DYSVG6T3.js} +141 -141
  11. package/dist/{chunk-Q3Q6FTFY.js.map → chunk-DYSVG6T3.js.map} +1 -1
  12. package/dist/chunk-MX5GCR7Y.js +36 -0
  13. package/dist/chunk-MX5GCR7Y.js.map +1 -0
  14. package/dist/chunk-Z7LNSHG3.js +182 -0
  15. package/dist/chunk-Z7LNSHG3.js.map +1 -0
  16. package/dist/cli.js +1 -1
  17. package/dist/compaction-QXU3A4LQ.js +28 -0
  18. package/dist/compaction-QXU3A4LQ.js.map +1 -0
  19. package/dist/index.d.ts +99 -14
  20. package/dist/index.js +1 -1
  21. package/dist/memory-extract-3TO7UC5B.js +2 -0
  22. package/dist/{program-HGI5C2MP.js → program-4RO4NCBU.js} +2 -2
  23. package/dist/{registry-5QOY65FS.js → registry-OUJ6HT5D.js} +2 -2
  24. package/package.json +1 -1
  25. package/dist/board-dashboard-OYGL7Z7X.js.map +0 -1
  26. package/dist/chunk-77OV7346.js +0 -23
  27. package/dist/chunk-77OV7346.js.map +0 -1
  28. package/dist/chunk-7HHVZJO4.js.map +0 -1
  29. package/dist/chunk-P2Y7DFFP.js +0 -36
  30. package/dist/chunk-P2Y7DFFP.js.map +0 -1
  31. package/dist/chunk-T76YTN34.js +0 -178
  32. package/dist/chunk-T76YTN34.js.map +0 -1
  33. package/dist/compaction-FD4R23HZ.js +0 -28
  34. package/dist/compaction-FD4R23HZ.js.map +0 -1
  35. package/dist/memory-extract-F5ZHWY5E.js +0 -2
  36. /package/dist/{agent-3XDPLWMX.js.map → agent-BCZRXLZ6.js.map} +0 -0
  37. /package/dist/{chunk-BTGPZ6B7.js.map → chunk-CQRSSVWG.js.map} +0 -0
  38. /package/dist/{memory-extract-F5ZHWY5E.js.map → memory-extract-3TO7UC5B.js.map} +0 -0
  39. /package/dist/{program-HGI5C2MP.js.map → program-4RO4NCBU.js.map} +0 -0
  40. /package/dist/{registry-5QOY65FS.js.map → registry-OUJ6HT5D.js.map} +0 -0
@@ -0,0 +1,23 @@
1
+ var g=new Set(["cron","a2a","workflow","selftest"]),m=[[/^User:\s*You are\s/i,"role brief"],[/^User:\s*(Run|Execute)\s/i,"run instruction"],[/^User:\s*\[MISSED RUN/i,"missed cron run"],[/^User:\s*(\[[^\]]{0,40}\]:?\s*)?\[Recent group conversation\]/i,"group chat dump"]];function p(e){if(e.responseLength<=50)return{capture:!1,reason:"response too short"};let o=(e.channel??"").toLowerCase().split("@")[0];if(g.has(o))return{capture:!1,reason:`machine channel: ${o}`};let r=e.content.slice(0,400);for(let[s,u]of m)if(s.test(r))return{capture:!1,reason:u};return{capture:!0}}var y=new Set(["cli","chat-cli","exec","tui","dashboard","admin","test-drive","workflow-editor","voice","opencode","mcp","ntfy"]),w=new Set(["telegram","whatsapp","slack","discord","gitlab","github","api","a2a","mesh","subagent","compaction","cron","workflow","business","heartbeat","selftest"]);function c(e){let t=(e??"").toLowerCase().split("@")[0];return y.has(t)?"operator":w.has(t)?"internal":"external"}var b=[/\bglpat-[A-Za-z0-9_-]{16,}/,/\bgh[pousr]_[A-Za-z0-9]{30,}/,/\bgithub_pat_[A-Za-z0-9_]{20,}/,/\bsk-ant-[A-Za-z0-9_-]{16,}/,/\bsk-(proj-)?[A-Za-z0-9_-]{20,}/,/\bxox[abprs]-[A-Za-z0-9-]{10,}/,/\bAKIA[0-9A-Z]{16}\b/,/\bAIza[0-9A-Za-z_-]{35}\b/,/\b\d{8,10}:[A-Za-z0-9_-]{35}\b/,/-----BEGIN [A-Z ]*PRIVATE KEY-----/,/\beyJ[A-Za-z0-9_-]{10,}\.eyJ[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}/,/\b(password|passwd|pwd|secret|api[_-]?key|access[_-]?key|token)\s*[:=]\s*["']?[^\s"',;]{8,}/i,/\b[a-z][a-z0-9+.-]*:\/\/[^\s:/@]+:[^\s:/@]{6,}@/i];function i(e){return b.some(t=>t.test(e))}function A(e){return e.source.trust??c(e.source.channel)}function R(e){return e==="external"?"held":void 0}function _(e){return e.category==="secret"||i(e.content)||e.review==="rejected"||e.review==="held"?!1:A(e)==="external"?e.review==="approved":!0}var v="claude-haiku-4-20250514",x=`You are a memory extraction system for an AI agent. Given a conversation exchange, extract facts worth remembering for future conversations across different chat sessions.
2
+
3
+ Extract ONLY facts that would help the agent in FUTURE, DIFFERENT conversations:
4
+ - User preferences and instructions ("never do X", "always use Y")
5
+ - Commitments the agent made ("I will deploy by Friday")
6
+ - Relationships ("Alex is the admin", "Marketing handles content")
7
+ - Task state ("GitLab tokens need deploying to peer-server")
8
+ - Important facts about infrastructure, config, or processes
9
+
10
+ SKIP:
11
+ - Credentials of any kind: passwords, tokens, API keys, private keys, connection strings. Never repeat one, not even partly. At most note that a credential exists and where it is kept, without its value.
12
+ - Routine greetings, acknowledgments, status updates
13
+ - Information derivable from code or config files
14
+ - Transient conversation flow ("let me check", "here's what I found")
15
+ - Facts already obvious from the agent's system prompt
16
+
17
+ For each fact, output a JSON array:
18
+ [{"category":"fact|preference|commitment|task-state","content":"concise fact, 1-2 sentences","keywords":["keyword1","keyword2"]}]
19
+
20
+ If nothing worth remembering, output: []`;async function F(e,t,o,r,s){if(t.length<20&&o.length<50||!p({channel:r.channel,content:`User: ${t}`,responseLength:o.length}).capture)return;let{createProvider:d}=await import("./providers-KO2DODIO.js"),l=(await d("claude").generate([{role:"system",content:x},{role:"user",content:`${r.sender} (via ${r.channel}): ${t}
21
+
22
+ Agent: ${o}`}],{model:v,maxTokens:512})).content.trim().match(/\[[\s\S]*\]/);if(!l)return;let a=JSON.parse(l[0]);if(!Array.isArray(a)||a.length===0)return;let f=new Date().toISOString().slice(0,10),h=c(r.channel);for(let n of a)typeof n?.content=="string"&&(n.category==="secret"||i(n.content)||s.hasSimilar(e,n.content)||s.addMemory(e,{agentId:e,category:n.category,content:n.content,keywords:n.keywords||[],source:{...r,date:f,trust:h},expiresAt:n.category==="task-state"?new Date(Date.now()+7*24*60*60*1e3).toISOString():void 0}));Math.random()<.02&&s.prune(e)}export{p as a,c as b,i as c,A as d,R as e,_ as f,F as g};
23
+ //# sourceMappingURL=chunk-CQR6C5FU.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/wiki/capture-filter.ts","../src/agents/memory-trust.ts","../src/agents/memory-extract.ts"],"sourcesContent":["// What deserves to become a raw wiki entry.\n//\n// Until now the only gate was `response.content.length > 50`. Every agent\n// task was captured, with the task's own message as the \"User:\" half — so\n// a cron's prompt became an entry, a role brief became an entry, and a\n// \"[MISSED RUN]\" notice became an entry.\n//\n// Measured over the 10,703 entries that produced: 30% arrived on a\n// machine-origin channel, 33% are prompt-shaped, and 47.5% are one or\n// both. That is the bulk of a corpus that has yielded 257 articles and is\n// read about three times a quarter.\n//\n// These rules are deterministic and free. They are deliberately\n// conservative — each one describes a shape that cannot contain knowledge\n// about the world, rather than guessing at value. Judging whether the\n// REMAINDER is worth keeping is a different question, and belongs to the\n// entry-triage seat, which costs money and can be wrong.\n\n/** Channels where both sides of the exchange are machines. A cron's\n * prompt is configuration, and its reply is a status report. */\nconst MACHINE_CHANNELS = new Set([\"cron\", \"a2a\", \"workflow\", \"selftest\"])\n\n/** Shapes that are an instruction to an agent, not a record of anything.\n * Anchored at the start of the captured content, which always begins\n * \"User: \" followed by the task message. */\nconst PROMPT_SHAPES: Array<[RegExp, string]> = [\n [/^User:\\s*You are\\s/i, \"role brief\"],\n [/^User:\\s*(Run|Execute)\\s/i, \"run instruction\"],\n [/^User:\\s*\\[MISSED RUN/i, \"missed cron run\"],\n // The bracketed prefix varies: some arrive as \"[Group, 09:43]: [Recent\n // group conversation]\". Anchoring on the bare marker missed 367 entries\n // in the first purge, so allow one leading bracketed segment.\n [/^User:\\s*(\\[[^\\]]{0,40}\\]:?\\s*)?\\[Recent group conversation\\]/i, \"group chat dump\"],\n]\n\nexport interface CaptureDecision {\n capture: boolean\n /** Why it was rejected, for logging and for counting what the filter\n * actually removes once it is live. */\n reason?: string\n}\n\nexport function shouldCaptureEntry(input: {\n channel: string | undefined\n content: string\n responseLength: number\n}): CaptureDecision {\n if (input.responseLength <= 50) return { capture: false, reason: \"response too short\" }\n\n const channel = (input.channel ?? \"\").toLowerCase()\n // Channels carry a node suffix: \"telegram@peer-server\".\n const base = channel.split(\"@\")[0]\n if (MACHINE_CHANNELS.has(base)) return { capture: false, reason: `machine channel: ${base}` }\n\n const head = input.content.slice(0, 400)\n for (const [shape, reason] of PROMPT_SHAPES) {\n if (shape.test(head)) return { capture: false, reason }\n }\n\n return { capture: true }\n}\n","// --- What extracted memory may keep, and what it may inject ---\n//\n// Facts are extracted from conversations after every reply and injected\n// into later tasks of the same agent, in any chat. Three rules keep that\n// from becoming a leak or a persistent prompt injection:\n//\n// 1. Secrets are never stored or injected. A credential pasted into one\n// chat must not follow the agent into every other chat.\n// 2. Every fact records how far its source can be trusted, from the\n// channel it came through.\n// 3. Facts from external sources (webhooks, public widgets, anything\n// unknown) are held out of injection until someone approves them:\n// anybody can write to those channels.\n//\n// Pure functions, unit tested.\n\nexport type SourceTrust =\n /** Only the operator can reach it: CLI, dashboard, local voice and TUI. */\n | \"operator\"\n /** Authenticated people or peers: allow-listed chat senders, forge\n * project members, mesh callers. */\n | \"internal\"\n /** Anyone can write to it. */\n | \"external\"\n\nexport type FactReview = \"held\" | \"approved\" | \"rejected\"\n\nconst OPERATOR_CHANNELS = new Set([\n \"cli\", \"chat-cli\", \"exec\", \"tui\", \"dashboard\", \"admin\", \"test-drive\",\n \"workflow-editor\", \"voice\", \"opencode\", \"mcp\", \"ntfy\",\n])\n\n/** People behind an allow-list or project membership, mesh peers, and\n * this node's own automation. New extraction skips the machine channels\n * (cron, workflow, a2a) anyway; older facts from them keep working. */\nconst INTERNAL_CHANNELS = new Set([\n \"telegram\", \"whatsapp\", \"slack\", \"discord\", \"gitlab\", \"github\",\n \"api\", \"a2a\", \"mesh\", \"subagent\", \"compaction\",\n \"cron\", \"workflow\", \"business\", \"heartbeat\", \"selftest\",\n])\n\n/** Trust for a fact's source channel. Channels carry a node suffix\n * (\"telegram@peer-server\"). Anything else, including web-chat,\n * public-api, webhooks and channels added later, is external. */\nexport function trustForChannel(channel: string | undefined): SourceTrust {\n const base = (channel ?? \"\").toLowerCase().split(\"@\")[0]\n if (OPERATOR_CHANNELS.has(base)) return \"operator\"\n if (INTERNAL_CHANNELS.has(base)) return \"internal\"\n return \"external\"\n}\n\n// Shapes of credentials. Deliberately specific: each pattern is a known\n// token format or an explicit assignment, so ordinary prose about \"the\n// token\" or \"a password reset\" is not caught.\nconst SECRET_PATTERNS: RegExp[] = [\n /\\bglpat-[A-Za-z0-9_-]{16,}/, // GitLab PAT\n /\\bgh[pousr]_[A-Za-z0-9]{30,}/, // GitHub tokens\n /\\bgithub_pat_[A-Za-z0-9_]{20,}/,\n /\\bsk-ant-[A-Za-z0-9_-]{16,}/, // Anthropic\n /\\bsk-(proj-)?[A-Za-z0-9_-]{20,}/, // OpenAI-style\n /\\bxox[abprs]-[A-Za-z0-9-]{10,}/, // Slack\n /\\bAKIA[0-9A-Z]{16}\\b/, // AWS access key\n /\\bAIza[0-9A-Za-z_-]{35}\\b/, // Google API key\n /\\b\\d{8,10}:[A-Za-z0-9_-]{35}\\b/, // Telegram bot token\n /-----BEGIN [A-Z ]*PRIVATE KEY-----/,\n /\\beyJ[A-Za-z0-9_-]{10,}\\.eyJ[A-Za-z0-9_-]{10,}\\.[A-Za-z0-9_-]{10,}/, // JWT\n /\\b(password|passwd|pwd|secret|api[_-]?key|access[_-]?key|token)\\s*[:=]\\s*[\"']?[^\\s\"',;]{8,}/i,\n /\\b[a-z][a-z0-9+.-]*:\\/\\/[^\\s:/@]+:[^\\s:/@]{6,}@/i, // URL with user:password@\n]\n\nexport function containsSecret(text: string): boolean {\n return SECRET_PATTERNS.some((p) => p.test(text))\n}\n\n/** The fields of a stored fact this module reads. Older facts have no\n * trust or review; trust then comes from their source channel. */\nexport interface FactTrustFields {\n category: string\n content: string\n source: { channel: string; trust?: SourceTrust }\n review?: FactReview\n}\n\nexport function factTrust(f: FactTrustFields): SourceTrust {\n return f.source.trust ?? trustForChannel(f.source.channel)\n}\n\n/** Whether a new fact from this source waits for review before use. */\nexport function initialReview(trust: SourceTrust): FactReview | undefined {\n return trust === \"external\" ? \"held\" : undefined\n}\n\n/** Whether a stored fact may be injected into a prompt. */\nexport function isInjectable(f: FactTrustFields): boolean {\n if (f.category === \"secret\" || containsSecret(f.content)) return false\n if (f.review === \"rejected\" || f.review === \"held\") return false\n if (factTrust(f) === \"external\") return f.review === \"approved\"\n return true\n}\n","import type { MemoryStore } from \"./memory-store\"\nimport { shouldCaptureEntry } from \"@/wiki/capture-filter\"\nimport { containsSecret, trustForChannel } from \"./memory-trust\"\n\n// --- Haiku-powered memory extraction ---\n// Fire-and-forget after each agent response.\n// Extracts memorable facts and writes them to the persistent store.\n\nconst EXTRACTION_MODEL = \"claude-haiku-4-20250514\"\n\nconst EXTRACTION_PROMPT = `You are a memory extraction system for an AI agent. Given a conversation exchange, extract facts worth remembering for future conversations across different chat sessions.\n\nExtract ONLY facts that would help the agent in FUTURE, DIFFERENT conversations:\n- User preferences and instructions (\"never do X\", \"always use Y\")\n- Commitments the agent made (\"I will deploy by Friday\")\n- Relationships (\"Alex is the admin\", \"Marketing handles content\")\n- Task state (\"GitLab tokens need deploying to peer-server\")\n- Important facts about infrastructure, config, or processes\n\nSKIP:\n- Credentials of any kind: passwords, tokens, API keys, private keys, connection strings. Never repeat one, not even partly. At most note that a credential exists and where it is kept, without its value.\n- Routine greetings, acknowledgments, status updates\n- Information derivable from code or config files\n- Transient conversation flow (\"let me check\", \"here's what I found\")\n- Facts already obvious from the agent's system prompt\n\nFor each fact, output a JSON array:\n[{\"category\":\"fact|preference|commitment|task-state\",\"content\":\"concise fact, 1-2 sentences\",\"keywords\":[\"keyword1\",\"keyword2\"]}]\n\nIf nothing worth remembering, output: []`\n\nexport async function extractMemories(\n agentId: string,\n userMessage: string,\n agentResponse: string,\n source: { channel: string; chatId: string; sender: string },\n store: MemoryStore,\n): Promise<void> {\n // Skip very short exchanges (unlikely to contain memorable facts)\n if (userMessage.length < 20 && agentResponse.length < 50) return\n\n // Same gate as wiki capture: machine channels (cron, a2a, workflow) and\n // prompt-shaped messages hold configuration, not facts about the world.\n const gate = shouldCaptureEntry({\n channel: source.channel,\n content: `User: ${userMessage}`,\n responseLength: agentResponse.length,\n })\n if (!gate.capture) return\n\n const { createProvider } = await import(\"@/agent/providers\")\n const provider = createProvider(\"claude\")\n\n const result = await provider.generate(\n [\n { role: \"system\", content: EXTRACTION_PROMPT },\n {\n role: \"user\",\n content: `${source.sender} (via ${source.channel}): ${userMessage}\\n\\nAgent: ${agentResponse}`,\n },\n ],\n { model: EXTRACTION_MODEL, maxTokens: 512 },\n )\n\n // Parse JSON array from response\n const content = result.content.trim()\n const jsonMatch = content.match(/\\[[\\s\\S]*\\]/)\n if (!jsonMatch) return\n\n const facts = JSON.parse(jsonMatch[0]) as Array<{\n category: string\n content: string\n keywords: string[]\n }>\n\n if (!Array.isArray(facts) || facts.length === 0) return\n\n const date = new Date().toISOString().slice(0, 10)\n const trust = trustForChannel(source.channel)\n\n for (const fact of facts) {\n if (typeof fact?.content !== \"string\") continue\n // The prompt says never to extract credentials; this holds when the\n // model does it anyway. addMemory refuses them too.\n if (fact.category === \"secret\" || containsSecret(fact.content)) continue\n // Skip duplicates\n if (store.hasSimilar(agentId, fact.content)) continue\n\n store.addMemory(agentId, {\n agentId,\n category: fact.category as any,\n content: fact.content,\n keywords: fact.keywords || [],\n source: { ...source, date, trust },\n expiresAt: fact.category === \"task-state\"\n ? new Date(Date.now() + 7 * 24 * 60 * 60 * 1000).toISOString()\n : undefined,\n })\n }\n\n // Prune occasionally (every ~50 calls, probabilistic)\n if (Math.random() < 0.02) {\n store.prune(agentId)\n }\n}\n"],"mappings":"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","names":["MACHINE_CHANNELS","PROMPT_SHAPES","shouldCaptureEntry","input","base","head","shape","reason","OPERATOR_CHANNELS","INTERNAL_CHANNELS","trustForChannel","channel","base","SECRET_PATTERNS","containsSecret","text","p","factTrust","f","initialReview","trust","isInjectable","EXTRACTION_MODEL","EXTRACTION_PROMPT","extractMemories","agentId","userMessage","agentResponse","source","store","shouldCaptureEntry","createProvider","jsonMatch","facts","date","trust","trustForChannel","fact","containsSecret"]}
@@ -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-2SJHSSJS.js"),{getGlobalRegistry:i}=await import("./registry-5QOY65FS.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-2SJHSSJS.js"),{getGlobalRegistry:i}=await import("./registry-OUJ6HT5D.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-BTGPZ6B7.js.map
126
+ //# sourceMappingURL=chunk-CQRSSVWG.js.map