blade-code 0.10.28 → 0.10.30
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.
- package/dist/blade.js +2 -2
- package/dist/{chunk-0pbvrw1c.js → chunk-0prp87ys.js} +1 -1
- package/dist/{chunk-6vfctcqp.js → chunk-0rwz7tm0.js} +1 -1
- package/dist/{chunk-axcaxcgk.js → chunk-1444wfhr.js} +2 -2
- package/dist/{chunk-2ycs4wce.js → chunk-1ggxyyar.js} +1 -1
- package/dist/{chunk-4y6pjd2n.js → chunk-1sswefqp.js} +2 -2
- package/dist/{chunk-t0n90d7w.js → chunk-1zpqxjj7.js} +2 -2
- package/dist/{chunk-stmsk0kz.js → chunk-2d35rmyg.js} +2 -2
- package/dist/chunk-2wdmt91f.js +1 -0
- package/dist/{chunk-0pcwv1h8.js → chunk-37se34rx.js} +1 -1
- package/dist/{chunk-yv2sdpxk.js → chunk-39gb49pv.js} +1 -1
- package/dist/chunk-3y97cpzv.js +1 -0
- package/dist/{chunk-287fabvz.js → chunk-48tz6s0s.js} +2 -2
- package/dist/{chunk-jvtzyba4.js → chunk-4djps7bz.js} +1 -1
- package/dist/{chunk-j9djsqqy.js → chunk-4p9cwr9s.js} +2 -2
- package/dist/{chunk-hbhcj665.js → chunk-4qtb8yf6.js} +2 -2
- package/dist/{chunk-k3wmp1xm.js → chunk-4qyhtrhx.js} +1 -1
- package/dist/chunk-56hphybe.js +1 -0
- package/dist/{chunk-69r9j0ms.js → chunk-5m5nxkfs.js} +1 -1
- package/dist/{chunk-1e9cpchh.js → chunk-64hndcnj.js} +41 -41
- package/dist/{chunk-d6a4qw1m.js → chunk-6h9d9ykg.js} +1 -1
- package/dist/{chunk-sh2kjand.js → chunk-6kc12pma.js} +1 -1
- package/dist/chunk-7brnbdq8.js +10 -0
- package/dist/{chunk-q4fy74fz.js → chunk-7e7zgzag.js} +2 -2
- package/dist/{chunk-9ev9k5bd.js → chunk-82jdnt03.js} +2 -2
- package/dist/{chunk-0xhd2mzm.js → chunk-8gv6hsrf.js} +2 -2
- package/dist/{chunk-tct2ybbh.js → chunk-9mamc250.js} +2 -2
- package/dist/{chunk-1ycv8b9t.js → chunk-9pww3s5m.js} +1 -1
- package/dist/chunk-a5yd0c77.js +1 -0
- package/dist/{chunk-wn60hv0w.js → chunk-b634n0ts.js} +199 -199
- package/dist/{chunk-a1a4351m.js → chunk-btfxa4w8.js} +2 -2
- package/dist/chunk-d38t0wa2.js +6 -0
- package/dist/{chunk-5wkv5g4v.js → chunk-d4327k1v.js} +1 -1
- package/dist/{chunk-djzy4zgc.js → chunk-d9gthet1.js} +2 -2
- package/dist/chunk-e269454y.js +1 -0
- package/dist/{chunk-sjbqm4be.js → chunk-e3qzedvj.js} +2 -2
- package/dist/{chunk-dny4h2gz.js → chunk-ej1z75jf.js} +1 -1
- package/dist/{chunk-p4hf7agx.js → chunk-ekv4hpy8.js} +2 -2
- package/dist/chunk-f90v5vza.js +1 -0
- package/dist/{chunk-dx5996qr.js → chunk-fr3kysfm.js} +1 -1
- package/dist/{chunk-xqapcfw3.js → chunk-gdp6fg4e.js} +1 -1
- package/dist/{chunk-a1ftc84p.js → chunk-h9c7xec5.js} +2 -2
- package/dist/{chunk-6qdwp1t3.js → chunk-hdr8bcxt.js} +1 -1
- package/dist/{chunk-rqvejn8x.js → chunk-heydawsf.js} +2 -2
- package/dist/chunk-j3k3xdac.js +1 -0
- package/dist/{chunk-gpa4y0xk.js → chunk-j7ebts5c.js} +1 -1
- package/dist/{chunk-gbmnbckj.js → chunk-kk071ywk.js} +2 -2
- package/dist/{chunk-cbyewxx4.js → chunk-kkpxmhjv.js} +3 -3
- package/dist/chunk-m3epqvpc.js +1 -0
- package/dist/{chunk-rf3jf275.js → chunk-m8jen593.js} +3 -3
- package/dist/{chunk-8djaj8m7.js → chunk-mbrgz77y.js} +2 -2
- package/dist/chunk-n1byt26d.js +4 -0
- package/dist/{chunk-ecvk8npm.js → chunk-p6s92zj1.js} +1 -1
- package/dist/chunk-pdkj959x.js +1 -0
- package/dist/chunk-pwwm04bc.js +1 -0
- package/dist/chunk-q9ghq6jw.js +204 -0
- package/dist/chunk-qs9wwe8d.js +9 -0
- package/dist/chunk-qv1v32ts.js +22 -0
- package/dist/{chunk-x3dche8v.js → chunk-rezjy4mp.js} +2 -2
- package/dist/{chunk-78bknnzt.js → chunk-rh5g6em4.js} +2 -2
- package/dist/{chunk-70kccy7a.js → chunk-s3zfyy7r.js} +1 -1
- package/dist/chunk-s6rdv601.js +2 -0
- package/dist/chunk-szmm21q9.js +1 -0
- package/dist/{chunk-2gre3vrn.js → chunk-vx8a7e1j.js} +2 -2
- package/dist/{chunk-tdevyej4.js → chunk-vz0zsct0.js} +1 -1
- package/dist/chunk-x96czg8t.js +1 -0
- package/dist/{chunk-p2j0wcca.js → chunk-x9940mcy.js} +2 -2
- package/dist/chunk-xh2c6ycd.js +1 -0
- package/dist/{chunk-taj3qfn3.js → chunk-xr033fd3.js} +1 -1
- package/dist/{chunk-ae7f5mh9.js → chunk-z5eaph4a.js} +1 -1
- package/dist/chunk-ze8rmhs1.js +1 -0
- package/dist/web/assets/{ChatView-BtSSERlQ.js → ChatView-CjEyCR8V.js} +3 -3
- package/dist/web/assets/{CodeBlockHighlighter-CAuanOO0.js → CodeBlockHighlighter-DZxXrhQO.js} +1 -1
- package/dist/web/assets/{FilePreview-BKQ-EBj3.js → FilePreview-8fbolCzV.js} +1 -1
- package/dist/web/assets/{MarkdownRenderer-BdYjJ_NM.js → MarkdownRenderer-Bfm5TG2z.js} +3 -3
- package/dist/web/assets/{SettingsModal-CB6hM8fT.js → SettingsModal-KATzS3Iy.js} +1 -1
- package/dist/web/assets/{TaskSwitcher-sSD4B7C_.js → TaskSwitcher-BrfN6F0-.js} +1 -1
- package/dist/web/assets/{TerminalPanel-ZnEoQU6o.js → TerminalPanel-sbqhmFcK.js} +1 -1
- package/dist/web/assets/{index-DtOztVFd.js → index-xB4mFHWl.js} +3 -3
- package/dist/web/index.html +1 -1
- package/package.json +1 -1
- package/dist/chunk-03633tsz.js +0 -10
- package/dist/chunk-1kxz32m6.js +0 -1
- package/dist/chunk-1sregjyz.js +0 -1
- package/dist/chunk-2byq2qja.js +0 -1
- package/dist/chunk-3t5gqr9e.js +0 -1
- package/dist/chunk-6znn1a5v.js +0 -1
- package/dist/chunk-7hjz5jjn.js +0 -9
- package/dist/chunk-8k9ark1n.js +0 -1
- package/dist/chunk-98rbxm1y.js +0 -22
- package/dist/chunk-apq6qqjg.js +0 -204
- package/dist/chunk-br9230a2.js +0 -2
- package/dist/chunk-hb9yjfja.js +0 -1
- package/dist/chunk-jk66yar2.js +0 -1
- package/dist/chunk-k52a3bq6.js +0 -1
- package/dist/chunk-n1qmwjmc.js +0 -1
- package/dist/chunk-p2yb40zk.js +0 -4
- package/dist/chunk-qewf02br.js +0 -1
- package/dist/chunk-qsj712zc.js +0 -1
- package/dist/chunk-ry7226b5.js +0 -6
- package/dist/chunk-x1a5wv45.js +0 -1
- package/dist/chunk-z516a7nx.js +0 -1
package/dist/chunk-br9230a2.js
DELETED
package/dist/chunk-hb9yjfja.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{Wf as a}from"./chunk-stmsk0kz.js";import"./chunk-5wkv5g4v.js";import"./chunk-rqvejn8x.js";import"./chunk-0pcwv1h8.js";export{a as WorkspaceTrustService};
|
package/dist/chunk-jk66yar2.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{$a as f,Sa as a,Ta as b,Va as c,Za as d,_a as e,ab as g,bb as h,cb as i,db as j,eb as k,jb as l,kb as m,lb as n,mb as o,nb as p,ob as q,pb as r}from"./chunk-apq6qqjg.js";import"./chunk-dny4h2gz.js";import"./chunk-p2j0wcca.js";import"./chunk-jvtzyba4.js";import"./chunk-x3dche8v.js";import"./chunk-sh2kjand.js";import"./chunk-hbhcj665.js";import"./chunk-tdevyej4.js";import"./chunk-0pbvrw1c.js";import"./chunk-1ycv8b9t.js";import"./chunk-rf3jf275.js";import"./chunk-70kccy7a.js";import"./chunk-xqapcfw3.js";import"./chunk-k3wmp1xm.js";import"./chunk-br9230a2.js";import"./chunk-2ycs4wce.js";import"./chunk-p4hf7agx.js";import"./chunk-0xhd2mzm.js";import"./chunk-69r9j0ms.js";import"./chunk-q4fy74fz.js";import"./chunk-5wkv5g4v.js";import"./chunk-rqvejn8x.js";import"./chunk-0pcwv1h8.js";export{g as saveUserMessage,i as saveToolUse,j as saveToolResult,k as saveCompaction,h as saveAssistantMessage,d as isRootSystemPrompt,m as handleTaskListUpdate,n as handleSkillActivation,o as extractModelSwitch,r as executeLoopGenerator,f as drainLoop,c as checkStopHook,a as checkOutputRecovery,b as checkIncompleteIntent,q as checkAndCompactInLoop,p as applyToolDomainEffects,l as StreamingToolExecutor,e as ConversationState};
|
package/dist/chunk-k52a3bq6.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{Qf as a,Rf as b,Sf as c,Tf as d,Uf as e,Vf as f}from"./chunk-q4fy74fz.js";import"./chunk-0pcwv1h8.js";export{b as getVersion,c as getPackageName,a as getPackageInfo,e as getFormattedVersion,d as getDescription,f as getCopyright};
|
package/dist/chunk-n1qmwjmc.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{Jc as a,Kc as b}from"./chunk-a1a4351m.js";import"./chunk-q4fy74fz.js";import"./chunk-0pcwv1h8.js";export{a as globalOptions,b as cliConfig};
|
package/dist/chunk-p2yb40zk.js
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import{$ as F,Z as y}from"./chunk-wn60hv0w.js";import{dc as Z,fc as x,nc as K}from"./chunk-p2j0wcca.js";import{de as $}from"./chunk-tct2ybbh.js";import{zf as V}from"./chunk-2ycs4wce.js";async function O(){await $(V())}async function j(b){let q=b.message||b._?.[0];if(typeof q==="string"&&q.trim())return q;let z=b.stdin??process.stdin;if(!z.isTTY){let G=[];for await(let Q of z)G.push(Q);return Buffer.concat(G).toString("utf-8").trim()}if(b.defaultMessage!==void 0)return b.defaultMessage;throw Error("No input provided")}async function I(b){if(!y(b))return{mode:"agent",content:b};let q=await F(b,{cwd:V(),surface:"headless",workspaceRoot:V()});if(!q.success)return{mode:"output",content:`Error: ${q.error||"未知错误"}`,exitCode:1};let z=q.data;if(z?.action==="invoke_skill"){let{skillName:G,skillArgs:Q}=z;return{mode:"agent",content:Q?`Please use the "${G}" skill to help me with: ${Q}`:`Please use the "${G}" skill.`}}if(z?.action==="invoke_custom_command"||z?.action==="invoke_plugin_command"){let G=z.processedContent;return{mode:"agent",content:`# Custom Command: /${z.commandName}
|
|
2
|
-
|
|
3
|
-
${G}`}}return{mode:"output",content:q.content||q.message||"",exitCode:0}}import{readFile as B,stat as D}from"node:fs/promises";import H from"node:path";function L(b,q){let z;try{z=JSON.parse(b)}catch(G){throw Error(`Invalid JSON output schema from ${q}`,{cause:G})}return x(z).schema}async function A(b){if(b.jsonSchema!==void 0&&b.outputSchema!==void 0)throw Error("--json-schema cannot be combined with --output-schema");if(b.jsonSchema!==void 0)return L(b.jsonSchema,"--json-schema");if(b.outputSchema===void 0)return;let q=H.resolve(b.outputSchema),z=await D(q);if(!z.isFile())throw Error(`Output schema path is not a regular file: ${q}`);if(z.size>Z)throw Error(`Output schema exceeds ${Z} bytes: ${q}`);return L(await B(q,"utf8"),q)}function J(b){if(!(b instanceof Error))return!1;return b.message.includes("未找到会话")||b.message.includes("ENOENT")||b.message.includes("no such file")}async function N(b){try{return await K.loadSessionModelContext(b,V())}catch(q){if(J(q))return null;throw q}}async function f(b){if(b.resume===!0||b.resume==="true")throw Error("--resume without a session ID is only supported in interactive UI mode");if(typeof b.resume==="string"&&b.resume.length>0){if(b.forkSession){let G=V(),Q=await K.forkSession(b.resume,{newSessionId:b.sessionId,sourceProjectPath:G,targetProjectPath:G});return{...Q,messages:await K.loadSessionModelContext(Q.sessionId,G)}}let[q,z]=await Promise.all([K.loadSessionModelContext(b.resume),K.findSessionMetadata(b.resume)]);return{sessionId:b.resume,messages:q,metadata:z}}if(b.continue){let q=b.forkSession?await K.listSessions({cwd:V()}):await K.listSessions();if(q.length>0){let z=q[0].sessionId;if(b.forkSession){let G=V(),Q=await K.forkSession(z,{newSessionId:b.sessionId,sourceProjectPath:G,targetProjectPath:G});return{...Q,messages:await K.loadSessionModelContext(Q.sessionId,G)}}return{sessionId:z,messages:await K.loadSessionModelContext(z),metadata:q[0]}}if(b.forkSession)throw Error("Cannot fork: no sessions are available to continue")}if(b.sessionId){let q=await N(b.sessionId);return{sessionId:b.sessionId,messages:q??[],...q?{metadata:await K.findSessionMetadata(b.sessionId,V())}:{}}}return{sessionId:`${b.fallbackSessionPrefix}-${Date.now()}`,messages:[]}}
|
|
4
|
-
export{O as m,j as n,I as o,A as p,f as q};
|
package/dist/chunk-qewf02br.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{be as a,ce as b,de as c,ee as d,fe as e}from"./chunk-tct2ybbh.js";import"./chunk-0pbvrw1c.js";import"./chunk-1ycv8b9t.js";import"./chunk-6vfctcqp.js";import"./chunk-rf3jf275.js";import"./chunk-70kccy7a.js";import"./chunk-2gre3vrn.js";import"./chunk-xqapcfw3.js";import"./chunk-k3wmp1xm.js";import"./chunk-br9230a2.js";import"./chunk-2ycs4wce.js";import"./chunk-p4hf7agx.js";import"./chunk-0xhd2mzm.js";import"./chunk-69r9j0ms.js";import"./chunk-q4fy74fz.js";import"./chunk-stmsk0kz.js";import"./chunk-5wkv5g4v.js";import"./chunk-rqvejn8x.js";import"./chunk-0pcwv1h8.js";export{d as snapshotWorkspaceAgentResources,c as resolveWorkspaceAgentResources,e as resetWorkspaceAgentResources,a as refreshWorkspaceCommunicationStyles,b as configureInvocationPluginDirs};
|
package/dist/chunk-qsj712zc.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a,b,c,d,e}from"./chunk-d6a4qw1m.js";import"./chunk-q4fy74fz.js";import"./chunk-0pcwv1h8.js";export{b as setSkipUntilVersion,d as performUpgrade,c as getUpgradeCommand,e as checkVersionOnStartup,a as checkVersion};
|
package/dist/chunk-ry7226b5.js
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import{m as Vq,n as Xq,o as Bq,p as Kq,q as jq}from"./chunk-p2yb40zk.js";import{s as $q}from"./chunk-sjbqm4be.js";import{F as o,H as n,I as t,K as g,L as e}from"./chunk-wn60hv0w.js";import"./chunk-4y6pjd2n.js";import"./chunk-t0n90d7w.js";import{$a as r,Ma as s,ib as a}from"./chunk-apq6qqjg.js";import"./chunk-dny4h2gz.js";import{Pb as v,Tb as i,cc as S,nc as O}from"./chunk-p2j0wcca.js";import"./chunk-jvtzyba4.js";import"./chunk-x3dche8v.js";import{Jc as Gq}from"./chunk-a1a4351m.js";import{Lc as Qq,Mc as Yq,Nc as Zq}from"./chunk-axcaxcgk.js";import{Oc as qq}from"./chunk-287fabvz.js";import"./chunk-djzy4zgc.js";import{md as l}from"./chunk-8djaj8m7.js";import"./chunk-v508x7cg.js";import"./chunk-sh2kjand.js";import"./chunk-hbhcj665.js";import"./chunk-j9djsqqy.js";import"./chunk-tdevyej4.js";import"./chunk-78bknnzt.js";import"./chunk-tct2ybbh.js";import"./chunk-0pbvrw1c.js";import"./chunk-1ycv8b9t.js";import"./chunk-6vfctcqp.js";import"./chunk-rf3jf275.js";import"./chunk-70kccy7a.js";import"./chunk-2gre3vrn.js";import{mf as m}from"./chunk-xqapcfw3.js";import{nf as u,pf as G,qf as w,sf as D}from"./chunk-k3wmp1xm.js";import"./chunk-br9230a2.js";import{zf as I}from"./chunk-2ycs4wce.js";import"./chunk-p4hf7agx.js";import"./chunk-0xhd2mzm.js";import"./chunk-69r9j0ms.js";import"./chunk-q4fy74fz.js";import"./chunk-stmsk0kz.js";import"./chunk-5wkv5g4v.js";import"./chunk-rqvejn8x.js";import"./chunk-0pcwv1h8.js";import eq from"yargs";import{hideBin as qG}from"yargs/helpers";var y=1;function K(Q){return G.Object({event_version:G.Literal(y),...Q})}var Mq=K({type:G.Literal("content_delta"),delta:G.String()}),Rq=K({type:G.Literal("thinking_delta"),delta:G.String()}),Pq=K({type:G.Literal("thinking"),content:G.String()}),Nq=K({type:G.Literal("stream_end")}),fq=K({type:G.Literal("content"),content:G.String()}),xq=K({type:G.Literal("structured_output"),output:G.Record(G.String(),G.Unknown()),schema_digest:G.String({pattern:"^[a-f0-9]{64}$"})}),T=D(["readonly","write","execute"]),Eq=K({type:G.Literal("tool_start"),tool_name:G.String(),summary:G.String(),target:G.Optional(G.String()),tool_kind:G.Optional(T)}),Iq=K({type:G.Literal("tool_progress"),tool_name:G.String(),message:G.String(),progress:G.Optional(G.Number()),total:G.Optional(G.Number())}),Jq=K({type:G.Literal("tool_result"),tool_name:G.String(),summary:G.String(),target:G.Optional(G.String()),tool_kind:G.Optional(T),success:G.Optional(G.Boolean()),error_type:G.Optional(G.String()),error_message:G.Optional(G.String())}),Lq=K({type:G.Literal("mcp_catalog_changed"),revision:G.Integer({minimum:1}),server_name:G.String(),added:G.Array(G.String()),removed:G.Array(G.String()),updated:G.Array(G.String())}),Wq=K({type:G.Literal("mcp_content_changed"),revision:G.Integer({minimum:1}),server_name:G.String(),content_kind:D(["resources","resource_templates","prompts"]),added:G.Array(G.String()),removed:G.Array(G.String()),updated:G.Array(G.String())}),Sq=K({type:G.Literal("mcp_resource_updated"),revision:G.Integer({minimum:1}),server_name:G.String(),uri:G.String()}),hq=K({type:G.Literal("mcp_connection_changed"),revision:G.Integer({minimum:1}),server_name:G.String(),phase:D(["reconnecting","recovered","failed"]),reason:G.String(),attempt:G.Integer({minimum:0}),max_attempts:G.Integer({minimum:0}),next_retry_at:G.Optional(G.Integer({minimum:0})),error:G.Optional(G.String())}),Oq=K({type:G.Literal("mcp_log"),revision:G.Integer({minimum:1}),server_name:G.String(),level:D(["debug","info","notice","warning","error","critical","alert","emergency"]),logger:G.Optional(G.String()),message:G.String(),projected_bytes:G.Integer({minimum:0}),data_sha256:G.String(),truncated:G.Boolean(),details_omitted:G.Boolean(),timestamp:G.Integer({minimum:0}),synthetic:G.Optional(G.Boolean())}),Cq=K({type:G.Literal("mcp_instructions_changed"),revision:G.Integer({minimum:0}),server_name:G.String(),action:D(["added","removed"]),reason:D(["snapshot","connection","disconnection"]),text:G.Optional(G.String()),source_bytes:G.Optional(G.Integer({minimum:0})),projected_bytes:G.Optional(G.Integer({minimum:0})),sha256:G.Optional(G.String()),truncated:G.Optional(G.Boolean()),details_omitted:G.Optional(G.Boolean())}),kq=K({type:G.Literal("mcp_task_changed"),revision:G.Integer({minimum:0}),task_id:G.String(),server_name:G.String(),tool_name:G.String(),status:D(["working","input_required","interrupted","completed","failed","cancelled"]),status_message:G.Optional(G.String()),created_at:G.Integer({minimum:0}),updated_at:G.Integer({minimum:0}),completed_at:G.Optional(G.Integer({minimum:0})),has_result:G.Boolean(),error:G.Optional(G.String())}),Fq=K({type:G.Literal("project_rules_loaded"),files:G.Array(G.Object({id:G.String(),relative_path:G.String(),source:D(["project","local"]),conditional:G.Boolean(),content_sha256:G.String({pattern:"^[a-f0-9]{64}$"})})),trigger_paths:G.Array(G.String()),blocked_write:G.Boolean()}),wq=K({type:G.Literal("user_shell_started"),execution_id:G.String(),command:G.String(),auxiliary:G.Boolean()}),gq=K({type:G.Literal("user_shell_output"),execution_id:G.String(),stream:D(["stdout","stderr"]),chunk:G.String(),stream_truncated:G.Boolean()}),yq=K({type:G.Literal("user_shell_completed"),execution_id:G.String(),message_id:G.String(),status:D(["completed","failed","aborted","timed_out","spawn_error"]),exit_code:G.Union([G.Integer(),G.Null()]),duration_ms:G.Number({minimum:0}),stdout:G.String(),stderr:G.String(),truncated:G.Boolean(),auxiliary:G.Boolean()}),Tq=K({type:G.Literal("phase"),phase:D(["turn","searching","inspecting","target_hit","executing","completed"]),status:D(["ongoing","hit","done"]),message:G.String(),turn:G.Optional(G.Number()),tool_name:G.Optional(G.String()),target:G.Optional(G.String())}),cq=K({type:G.Literal("tool_detail"),tool_name:G.String(),detail:G.String()}),dq=K({type:G.Literal("task_update"),tasks:G.Array(g)}),pq=K({type:G.Literal("goal"),state:D(["updated","cleared"]),goal_id:G.Optional(G.String()),status:G.Optional(D(["active","verifying","paused","blocked","usage_limited","budget_limited","complete"])),verification_attempt:G.Optional(G.Integer({minimum:1})),verification_status:G.Optional(D(["pending","pass","fail","partial"])),verifier_session_id:G.Optional(G.String()),verification_evidence_sha256:G.Optional(G.String({pattern:"^[a-f0-9]{64}$"}))}),mq=K({type:G.Literal("subagent"),state:D(["spawned","completed"]),session_id:G.String(),subagent_type:G.Optional(G.String()),success:G.Optional(G.Boolean()),summary:G.Optional(G.String()),verification_verdict:G.Optional(D(["pass","fail","partial"])),resumed_from:G.Optional(G.String()),root_agent_id:G.Optional(G.String()),resume_depth:G.Optional(G.Integer({minimum:0}))}),uq=K({type:G.Literal("token_usage"),input_tokens:G.Number(),output_tokens:G.Number(),total_tokens:G.Number(),max_context_tokens:G.Number(),cache_read_tokens:G.Optional(G.Number()),cache_write_tokens:G.Optional(G.Number()),cost_usd:G.Optional(G.Number())}),lq=K({type:G.Literal("compacting"),state:D(["started","completed"]),reason:G.Optional(D(["threshold","context_limit","turn_limit","manual"])),strategy:G.Optional(D(["llm","fallback","snip"])),outcome:G.Optional(D(["completed","fallback","failed"])),pre_tokens:G.Optional(G.Number({minimum:0})),post_tokens:G.Optional(G.Number({minimum:0}))}),vq=K({type:G.Literal("provider_retry"),phase:D(["scheduled","attempt","recovered","exhausted"]),attempt:G.Integer({minimum:0}),max_retries:G.Integer({minimum:0}),reason:D(["rate_limit","server_error","timeout","transport","stream_closed"]),status_code:G.Optional(G.Integer({minimum:100,maximum:599})),delay_ms:G.Optional(G.Integer({minimum:0})),next_retry_at:G.Optional(G.Integer({minimum:0}))}),iq=K({type:G.Literal("provider_stall"),phase:D(["detected","recovered"]),stall_count:G.Integer({minimum:1}),duration_ms:G.Integer({minimum:0}),warning_after_ms:G.Integer({minimum:1}),timeout_ms:G.Integer({minimum:1}),output_started:G.Boolean()}),sq=K({type:G.Literal("action_stationarity"),phase:D(["detected","recovered","halted"]),tool_name:G.String(),run_length:G.Integer({minimum:1}),nudge_threshold:G.Integer({minimum:1}),halt_threshold:G.Integer({minimum:1}),progress_aware:G.Boolean()}),rq=K({type:G.Literal("turn_limit"),turns_count:G.Number(),action:G.Literal("continue")}),aq=K({type:G.Literal("task_session"),session_id:G.String(),project_path:G.String(),source_project_path:G.String(),isolation:D(["local","worktree"]),worktree_branch:G.Optional(G.String()),base_commit:G.Optional(G.String())}),oq=K({type:G.Literal("task_admission"),state:D(["queued","running"]),queue_position:G.Optional(G.Integer({minimum:1})),queue_depth:G.Integer({minimum:0}),in_flight:G.Integer({minimum:0}),max_concurrent_tasks:G.Integer({minimum:1})}),nq=K({type:G.Literal("output"),content:G.String(),exit_code:G.Number()}),tq=K({type:G.Literal("error"),message:G.String()}),_G=w(G.Union([Mq,Rq,Pq,Nq,fq,xq,Eq,Iq,Jq,Lq,Wq,Sq,hq,Oq,Cq,kq,Fq,wq,gq,yq,Tq,cq,dq,pq,mq,uq,lq,vq,iq,sq,rq,aq,oq,nq,tq]));function c(Q,Y){return{event_version:y,type:Q,...Y}}function GG(Q){if(Q?.signal)return{signal:Q.signal,dispose:()=>{return}};let Y=new AbortController,z=()=>Y.abort("interrupt");return process.once("SIGINT",z),process.once("SIGTERM",z),{signal:Y.signal,dispose:()=>{process.removeListener("SIGINT",z),process.removeListener("SIGTERM",z)}}}var QG=D(["text","jsonl"]),YG=G.Object({headless:G.Optional(G.Boolean()),message:G.Optional(G.String()),_:G.Optional(G.Array(G.Union([G.String(),G.Number()]))),model:G.Optional(G.String()),systemPrompt:G.Optional(G.String()),appendSystemPrompt:G.Optional(G.String()),verificationAgent:G.Optional(G.Boolean()),maxTurns:G.Optional(G.Refine(G.Integer(),(Q)=>Q===-1||Q>0,()=>"must be -1 (unlimited) or a positive integer")),permissionMode:G.Optional(G.Enum(m)),mcpConfig:G.Optional(G.Array(G.String())),strictMcpConfig:G.Optional(G.Boolean()),sessionId:G.Optional(G.String()),allowedTools:G.Optional(G.Array(G.String())),disallowedTools:G.Optional(G.Array(G.String())),agents:G.Optional(G.String()),continue:G.Optional(G.Boolean()),resume:G.Optional(G.Union([G.String(),G.Boolean()])),forkSession:G.Optional(G.Boolean()),taskIsolation:G.Optional(D(["local","worktree"])),outputFormat:G.Optional(QG),jsonSchema:G.Optional(G.String()),outputSchema:G.Optional(G.String())});class Dq{openedThinking=!1;wroteAssistantContent=!1;markAssistantContent(){this.wroteAssistantContent=!0}setThinkingOpened(Q){this.openedThinking=Q}hasOpenThinking(){return this.openedThinking}completeStream(){let Q={openedThinking:this.openedThinking,wroteAssistantContent:this.wroteAssistantContent};return this.openedThinking=!1,this.wroteAssistantContent=!1,Q}}function ZG(Q){return Q.issues.map((Y)=>`${Y.path.join(".")||"options"}: ${Y.message}`).join("; ")}function $G(Q){let Y=u(YG,Q);if(!Y.success)throw Error(`Invalid headless options: ${ZG(Y.error)}`);return Y.data}function VG(Q){return Q.command("* [message]","Run full agent loop without Ink UI and print events to the terminal",(Y)=>Y.positional("message",{describe:"Message to process",type:"string"}).option("headless",{type:"boolean",describe:"Run full agent loop without Ink UI and print events to the terminal"}).option("model",{describe:"Model ID for this run",type:"string"}).option("system-prompt",{describe:"Replace the default system prompt",type:"string"}).option("append-system-prompt",{describe:"Append a system prompt to the default system prompt",type:"string"}).option("verification-agent",{describe:"Run the built-in independent verification agent after non-trivial changes",type:"boolean",default:!0}).option("max-turns",{alias:["maxTurns"],describe:"Maximum conversation turns (-1: unlimited, N>0: limit to N turns)",type:"number"}).option("output-format",{alias:["outputFormat"],choices:["text","jsonl"],describe:"Headless output format",type:"string"}).option("json-schema",{alias:["jsonSchema"],describe:"Inline JSON Schema for the structured final response",type:"string"}).option("output-schema",{alias:["outputSchema"],describe:"Path to a JSON Schema file for the structured final response",type:"string"}).option("task-isolation",{alias:["taskIsolation"],choices:["local","worktree"],describe:"Dispatch a new durable task in the selected workspace mode",type:"string"}),async(Y)=>{if(!Y.headless)return;let z=await bG(Y);process.exit(z)})}function j(Q,Y=""){Q.write(`${Y}
|
|
2
|
-
`)}function XG(Q){return`[task] [${Q.status}] ${Q.subject}`}function BG(){return{requestConfirmation:async(Q)=>Q.type==="mcpElicitation"?{approved:!1,reason:"headless-mcp-elicitation-unavailable",elicitation:{action:"cancel"}}:Q.type==="mcpSampling"?{approved:!1,reason:"headless-mcp-sampling-unavailable"}:{approved:!0,reason:"headless-auto-approved",scope:"session"}}}function KG(Q){if(!(Q instanceof Error))return"Unknown error";let V=Q.lastError??Q;if(V.responseBody)try{let b=JSON.parse(V.responseBody)?.error?.message;if(b)return V.statusCode?`${b} (HTTP ${V.statusCode})`:b}catch{}let q=Q.message.match(/Last error:\s*(.+)$/);if(q)return q[1];return Q.message}function jG(Q){return Q==="jsonl"?"jsonl":"text"}function d(Q,Y){let z=(...V)=>{for(let q of V){let Z=Y[q];if(typeof Z==="string"&&Z.trim()!=="")return Z}return};switch(Q){case"Read":case"Edit":case"Write":case"UndoEdit":return z("file_path");case"ApplyPatch":return"multi-file patch";case"NotebookEdit":return z("notebook_path");case"Grep":return z("path","pattern");case"Glob":return z("pattern");case"WebFetch":return z("url");case"WebSearch":return z("query");case"Bash":return z("command","description");case"Task":return z("description");case"LSP":return z("filePath","operation");case"EnterWorktree":return z("name");case"ExitWorktree":return z("action");default:return}}function DG(Q,Y,z,V){let q=new Set(["Glob","Grep","WebSearch","LS"]),Z=new Set(["Read","WebFetch"]);if(new Set(["Edit","Write","ApplyPatch","NotebookEdit","Bash","LSP","UndoEdit","EnterWorktree","ExitWorktree"]).has(Q)&&!V.targetLocked)return{phase:"target_hit",status:"hit",message:`Target locked: ${Y}`,shouldLockTarget:!0};if(V.targetLocked)return{phase:"executing",status:"hit",message:z?`Working within target: ${Y}`:`Executing: ${Y}`,shouldLockTarget:!1};if(q.has(Q))return{phase:"searching",status:"ongoing",message:`Still searching: ${Y}`,shouldLockTarget:!1};if(Z.has(Q))return{phase:"inspecting",status:"ongoing",message:`Inspecting candidate: ${Y}`,shouldLockTarget:!1};return{phase:"executing",status:V.targetLocked?"hit":"ongoing",message:`Executing: ${Y}`,shouldLockTarget:!1}}function p(Q,Y,z=!1){let V=(q,Z)=>{Q.stdout.write(`${JSON.stringify(c(q,Z))}
|
|
3
|
-
`)};return{contentDelta(q){if(Y==="jsonl"){V("content_delta",{delta:q});return}if(z)return;Q.stdout.write(q)},thinkingDelta(q,Z){if(Y==="jsonl")return V("thinking_delta",{delta:q}),Z;if(!Z)Q.stderr.write("[thinking] ");return Q.stderr.write(q),!0},thinking(q){if(Y==="jsonl"){V("thinking",{content:q});return}j(Q.stderr,`[thinking] ${q}`)},streamEnd(q,Z){if(Y==="jsonl"){V("stream_end",{});return}if(Z)Q.stderr.write(`
|
|
4
|
-
`);if(q)Q.stdout.write(`
|
|
5
|
-
`)},content(q){if(Y==="jsonl"){V("content",{content:q});return}j(Q.stdout,q)},structuredOutput(q){if(Y==="jsonl"){V("structured_output",{output:q.output,schema_digest:q.schemaDigest});return}j(Q.stdout,JSON.stringify(q.output))},toolStart(q,Z,b,H){if(Y==="jsonl"){V("tool_start",{tool_name:q,summary:Z,target:b,tool_kind:H});return}j(Q.stderr,`[tool:start] ${Z}`)},toolProgress(q,Z,b,H){if(Y==="jsonl"){V("tool_progress",{tool_name:q,message:Z,progress:b,total:H});return}j(Q.stderr,`[tool:progress] ${q}: ${Z}`)},toolResult(q,Z,b,H,M){if(Y==="jsonl"){V("tool_result",{tool_name:q,summary:Z,target:b,tool_kind:H,success:M?.success,error_type:M?.errorType,error_message:M?.errorMessage});return}j(Q.stderr,`[tool:result] ${Z}`)},mcpCatalogChanged(q){if(Y==="jsonl"){V("mcp_catalog_changed",{revision:q.revision,server_name:q.serverName,added:q.added,removed:q.removed,updated:q.updated});return}j(Q.stderr,`[mcp:catalog] r${q.revision} ${q.serverName} +${q.added.length} -${q.removed.length} ~${q.updated.length}`)},mcpContentChanged(q){if(Y==="jsonl"){V("mcp_content_changed",{revision:q.revision,server_name:q.serverName,content_kind:q.contentKind==="resourceTemplates"?"resource_templates":q.contentKind,added:q.added,removed:q.removed,updated:q.updated});return}j(Q.stderr,`[mcp:${q.contentKind}] r${q.revision} ${q.serverName} +${q.added.length} -${q.removed.length} ~${q.updated.length}`)},mcpResourceUpdated(q){if(Y==="jsonl"){V("mcp_resource_updated",{revision:q.revision,server_name:q.serverName,uri:q.uri});return}j(Q.stderr,`[mcp:resource] r${q.revision} ${q.serverName} updated ${q.uri}`)},mcpConnectionChanged(q){if(Y==="jsonl"){V("mcp_connection_changed",{revision:q.revision,server_name:q.serverName,phase:q.phase,reason:q.reason,attempt:q.attempt,max_attempts:q.maxAttempts,...q.nextRetryAt!==void 0?{next_retry_at:q.nextRetryAt}:{},...q.error?{error:q.error}:{}});return}j(Q.stderr,`[mcp:connection] r${q.revision} ${q.serverName} ${q.phase} ${q.attempt}/${q.maxAttempts}`)},mcpLog(q){if(Y==="jsonl"){V("mcp_log",{revision:q.revision,server_name:q.serverName,level:q.level,logger:q.logger,message:q.message,projected_bytes:q.projectedBytes,data_sha256:q.dataSha256,truncated:q.truncated,details_omitted:q.detailsOmitted,timestamp:q.timestamp,synthetic:q.synthetic});return}j(Q.stderr,`[mcp:log] ${q.level} ${q.serverName}${q.logger?` logger=${q.logger}`:""}: ${q.message}`)},mcpInstructionsChanged(q){if(Y==="jsonl"){V("mcp_instructions_changed",{revision:q.revision,server_name:q.serverName,action:q.action,reason:q.reason,text:q.text,source_bytes:q.sourceBytes,projected_bytes:q.projectedBytes,sha256:q.sha256,truncated:q.truncated,details_omitted:q.detailsOmitted});return}j(Q.stderr,`[mcp:instructions] ${q.action} ${q.serverName}${q.truncated?" (truncated)":""}`)},mcpTaskChanged(q){if(Y==="jsonl"){V("mcp_task_changed",{revision:q.revision,task_id:q.taskId,server_name:q.serverName,tool_name:q.toolName,status:q.status,status_message:q.statusMessage,created_at:q.createdAt,updated_at:q.updatedAt,completed_at:q.completedAt,has_result:q.hasResult,error:q.error});return}j(Q.stderr,`[mcp:task] ${q.taskId} ${q.serverName}/${q.toolName} `+q.status)},projectRulesLoaded(q){if(Y==="jsonl"){V("project_rules_loaded",{files:q.files.map((Z)=>({id:Z.id,relative_path:Z.relativePath,source:Z.source,conditional:Z.conditional,content_sha256:Z.contentSha256})),trigger_paths:q.triggerPaths,blocked_write:q.blockedWrite});return}j(Q.stderr,`[project-rules] loaded ${q.files.length} file(s)${q.blockedWrite?" before write":""}`)},userShellStarted(q,Z,b){if(Y==="jsonl"){V("user_shell_started",{execution_id:q,command:Z,auxiliary:b});return}j(Q.stderr,`[user-shell:start] ${Z}`)},userShellOutput(q,Z,b,H){if(Y==="jsonl"){V("user_shell_output",{execution_id:q,stream:Z,chunk:b,stream_truncated:H});return}(Z==="stderr"?Q.stderr:Q.stdout).write(b)},userShellCompleted(q){if(Y==="jsonl"){V("user_shell_completed",{execution_id:q.executionId,message_id:q.messageId,status:q.record.status,exit_code:q.record.exitCode,duration_ms:q.record.durationMs,stdout:q.record.stdout,stderr:q.record.stderr,truncated:q.record.truncated,auxiliary:q.auxiliary});return}j(Q.stderr,`[user-shell:${q.record.status}] exit=${q.record.exitCode??"null"} ${q.record.durationMs}ms`)},phase(q,Z,b,H={}){if(Y==="jsonl"){V("phase",{phase:q,status:Z,message:b,turn:H.turn,tool_name:H.toolName,target:H.target});return}j(Q.stderr,`[phase:${q}] ${b}`)},toolDetail(q,Z){if(Y==="jsonl"){V("tool_detail",{tool_name:q,detail:Z});return}j(Q.stderr,Z)},taskUpdate(q){if(Y==="jsonl"){V("task_update",{tasks:q});return}for(let Z of q)j(Q.stderr,XG(Z))},goal(q){if(Y==="jsonl"){V("goal",{state:q.goal?"updated":"cleared",goal_id:q.goal?.goalId,status:q.goal?.status,verification_attempt:q.goal?.completionVerification?.attempt,verification_status:q.goal?.completionVerification?.status,verifier_session_id:q.goal?.completionVerification?.verifierSessionId,verification_evidence_sha256:q.goal?.completionVerification?.evidenceSha256});return}if(q.goal)j(Q.stderr,`[goal:${q.goal.status}] ${q.goal.objective}`);else j(Q.stderr,"[goal:cleared]")},subagent(q){let Z=q.kind==="subagent_spawned";if(Y==="jsonl"){V("subagent",{state:Z?"spawned":"completed",session_id:q.sessionId,subagent_type:q.type,success:Z?void 0:q.success,summary:Z?void 0:q.summary,verification_verdict:Z?void 0:q.verificationVerdict,resumed_from:q.resumedFrom,root_agent_id:q.rootAgentId,resume_depth:q.resumeDepth});return}j(Q.stderr,`[subagent:${Z?"spawned":"completed"}] ${q.sessionId}${q.resumedFrom?` resumed from ${q.resumedFrom}`:""}`)},tokenUsage(q){if(Y==="jsonl"){V("token_usage",{input_tokens:q.inputTokens,output_tokens:q.outputTokens,total_tokens:q.totalTokens,max_context_tokens:q.maxContextTokens,cache_read_tokens:q.cacheReadTokens,cache_write_tokens:q.cacheWriteTokens,cost_usd:q.costUsd});return}j(Q.stderr,`[tokens] in=${q.inputTokens} out=${q.outputTokens} total=${q.totalTokens} / ${q.maxContextTokens}`)},compacting(q){let Z=q.phase==="start";if(Y==="jsonl"){V("compacting",{state:Z?"started":"completed",reason:q.reason,strategy:q.strategy,outcome:q.outcome,pre_tokens:q.preTokens,post_tokens:q.postTokens});return}j(Q.stderr,Z?`[context] compacting started${q.reason?` (${q.reason})`:""}`:`[context] compacting ${q.outcome??"completed"}`)},providerRetry(q){if(Y==="jsonl"){V("provider_retry",{phase:q.phase,attempt:q.attempt,max_retries:q.maxRetries,reason:q.reason,status_code:q.statusCode,delay_ms:q.delayMs,next_retry_at:q.nextRetryAt});return}let Z=q.delayMs!==void 0?` in ${Math.max(0,Math.ceil(q.delayMs/1000))}s`:"";j(Q.stderr,`[provider-retry:${q.phase}] ${q.attempt}/${q.maxRetries} ${q.reason}${Z}`)},providerStall(q){if(Y==="jsonl"){V("provider_stall",{phase:q.phase,stall_count:q.stallCount,duration_ms:q.durationMs,warning_after_ms:q.warningAfterMs,timeout_ms:q.timeoutMs,output_started:q.outputStarted});return}j(Q.stderr,`[provider-stall:${q.phase}] ${q.durationMs}ms / ${q.timeoutMs}ms`)},actionStationarity(q){if(Y==="jsonl"){V("action_stationarity",{phase:q.phase,tool_name:q.toolName,run_length:q.runLength,nudge_threshold:q.nudgeThreshold,halt_threshold:q.haltThreshold,progress_aware:q.progressAware});return}j(Q.stderr,`[action-stationarity:${q.phase}] ${q.toolName} ${q.runLength}/${q.haltThreshold}`)},turnLimit(q){if(Y==="jsonl"){V("turn_limit",{turns_count:q,action:"continue"});return}j(Q.stderr,`[turn-limit] continuing after ${q} turns`)},taskSession(q){if(Y==="jsonl"){V("task_session",{session_id:q.sessionId,project_path:q.projectPath,source_project_path:q.sourceProjectPath,isolation:q.isolation,worktree_branch:q.worktreeBranch,base_commit:q.baseCommit});return}j(Q.stderr,`[task:${q.isolation}] ${q.sessionId} ${q.sourceProjectPath} -> ${q.projectPath}${q.worktreeBranch?` (${q.worktreeBranch})`:""}`)},taskAdmission(q){if(Y==="jsonl"){V("task_admission",{state:q.state,queue_position:q.queuePosition,queue_depth:q.queueDepth,in_flight:q.inFlight,max_concurrent_tasks:q.maxConcurrentTasks});return}j(Q.stderr,q.state==="queued"?`[task:queued] position ${q.queuePosition??1}/${q.queueDepth} (running ${q.inFlight}/${q.maxConcurrentTasks})`:`[task:running] admitted (running ${q.inFlight}/${q.maxConcurrentTasks})`)},output(q,Z=0){if(Y==="jsonl"){V("output",{content:q,exit_code:Z});return}j(Z===0?Q.stdout:Q.stderr,q)},error(q){if(Y==="jsonl"){V("error",{message:q});return}j(Q.stderr,q)}}}async function bG(Q,Y={stdout:process.stdout,stderr:process.stderr},z){let V="text",q=p(Y,V),Z=new Dq,b={targetLocked:!1},H,M,J=GG(z);try{let B=$G(Q);V=jG(B.outputFormat);let P=await Kq(B);q=p(Y,V,Boolean(P)),await Vq();let bq=await Xq(B),_=await Bq(bq);if(_.mode==="output"){if(_.content)q.output(_.content,_.exitCode??0);return _.exitCode??0}let L=_.content.trimStart().startsWith("!")?_.content.trimStart().slice(1).trim():void 0;if(L!==void 0&&B.taskIsolation)throw Error("User shell commands cannot be combined with --task-isolation");if(L!==void 0&&P)throw Error("Output schemas cannot be combined with user shell commands");if(B.taskIsolation&&(B.continue||B.resume||B.forkSession))throw Error("--task-isolation cannot be combined with --continue, --resume, or --fork-session");let{sessionId:A,messages:C,metadata:k}=await jq({sessionId:B.sessionId,continue:B.continue,resume:B.resume,forkSession:B.forkSession,fallbackSessionPrefix:"headless"}),x=B.permissionMode??k?.permissionMode??"yolo",F=B.model&&B.model!=="inherit"?B.model:l()?.id,U=B.taskIsolation?await $q.createSessionTask({sessionId:A,prompt:_.content,sourceProjectPath:I(),isolation:B.taskIsolation,dispatch:{version:1,prompt:_.content,sourceProjectPath:I(),isolation:B.taskIsolation,permissionMode:x,...F?{modelId:F}:{},...P?{outputSchema:P}:{}}}):void 0,R=U?.metadata.projectPath??k?.projectPath??I();if(!U)await O.setSessionPermissionMode(A,R,x);let zq=U?!1:await a.cancelPendingNonInteractive(R,A);if(U)q.taskSession({sessionId:A,projectPath:R,sourceProjectPath:U.metadata.taskSourceProjectPath??I(),isolation:B.taskIsolation,worktreeBranch:U.metadata.taskWorktreeBranch,baseCommit:U.metadata.taskBaseCommit}),M=s.subscribe(($)=>{if($.type!=="task.status"||$.sessionId!==A||$.projectPath!==R||!["queued","running"].includes(String($.properties.taskStatus))||typeof $.properties.taskQueueDepth!=="number"||typeof $.properties.taskInFlight!=="number"||typeof $.properties.taskConcurrencyLimit!=="number")return;q.taskAdmission({state:$.properties.taskStatus,queuePosition:typeof $.properties.taskQueuePosition==="number"?$.properties.taskQueuePosition:void 0,queueDepth:$.properties.taskQueueDepth,inFlight:$.properties.taskInFlight,maxConcurrentTasks:$.properties.taskConcurrencyLimit})});let Hq={messages:zq?await O.loadSessionModelContext(A,R):[...C],userId:"cli-user",sessionId:A,workspaceRoot:R,permissionMode:x,signal:J.signal,...U?.taskWorktree?{worktreeActive:!0}:{},confirmationHandler:BG()};if(H=await o.create({sessionId:A,workspaceRoot:R,modelId:B.model,permissionMode:x,mcpConfig:B.mcpConfig,strictMcpConfig:B.strictMcpConfig,agents:B.agents?qq(B.agents):void 0,...U?.taskWorktree?{taskWorktree:U.taskWorktree}:{},...U?.metadata.taskIsolation?{taskIsolation:U.metadata.taskIsolation}:{},...C.length>0?{sessionStart:{isResume:!0,resumeSessionId:A}}:{}}),L!==void 0){let $=await H.executeUserShellCommand(L,{signal:J.signal,onEvent:(X)=>{if(X.type==="started")q.userShellStarted(X.executionId,X.command,X.auxiliary);else if(X.type==="output")q.userShellOutput(X.executionId,X.stream,X.chunk,X.streamTruncated)}});return q.userShellCompleted($),$.record.status==="completed"?0:$.record.status==="aborted"?130:$.record.exitCode??1}let Uq=B.maxTurns??H.getConfig().maxTurns,_q=U?.taskWorktree?[...new Set([...B.disallowedTools??[],"EnterWorktree","ExitWorktree"])]:B.disallowedTools,Aq=await e.createWithRuntime(H,{sessionId:A,systemPrompt:B.systemPrompt,appendSystemPrompt:B.appendSystemPrompt,maxTurns:B.maxTurns,modelId:B.model,permissionMode:x,toolWhitelist:B.allowedTools,toolBlacklist:_q,mcpConfig:B.mcpConfig,strictMcpConfig:B.strictMcpConfig}),h=await r(Aq.chatStream(_.content,Hq,{stream:!0,signal:J.signal,maxTurns:B.maxTurns,builtinVerification:B.verificationAgent!==!1,outputSchema:P,...Uq===-1?{onTurnLimitReached:async($)=>{return q.turnLimit($.turnsCount),{continue:!0,reason:"headless-auto-continue"}}}:{}}),async($)=>{switch($.kind){case"content_delta":if(!P||V==="jsonl")Z.markAssistantContent();q.contentDelta($.delta);break;case"thinking_delta":Z.setThinkingOpened(q.thinkingDelta($.delta,Z.hasOpenThinking()));break;case"stream_end":{let X=Z.completeStream();q.streamEnd(X.wroteAssistantContent,X.openedThinking);break}case"tool_start":{let X=$.toolCall;if(!("function"in X))break;if(X.function.name===S)break;if(["TaskCreate","TaskUpdate","TaskList"].includes(X.function.name))break;try{let N=JSON.parse(X.function.arguments),f=n(X.function.name,N),E=d(X.function.name,N),W=DG(X.function.name,f,E,b);if(W.shouldLockTarget)b.targetLocked=!0;q.phase(W.phase,W.status,W.message,{toolName:X.function.name,target:E}),q.toolStart(X.function.name,f,E,$.toolKind)}catch{q.phase(b.targetLocked?"executing":"searching",b.targetLocked?"hit":"ongoing",b.targetLocked?`Working within target: ${X.function.name}`:`Still searching: ${X.function.name}`,{toolName:X.function.name}),q.toolStart(X.function.name,X.function.name,void 0,$.toolKind)}break}case"tool_progress":{let X=$.toolCall;if(!("function"in X))break;if(X.function.name===S)break;q.toolProgress(X.function.name,$.update.message,$.update.progress,$.update.total);break}case"tool_result":{let X=$.toolCall;if(!("function"in X))break;if(X.function.name===S)break;let N;try{let E=JSON.parse(X.function.arguments);N=d(X.function.name,E)}catch{N=void 0}let f=i(t(X.function.name,$.result),v);if(q.toolResult(X.function.name,f.summary,N,void 0,{success:$.result.success,errorType:$.result.error?.type,errorMessage:$.result.error?.message}),f.detail)q.toolDetail(X.function.name,f.detail);break}case"token_usage":q.tokenUsage($.usage);break;case"compaction":q.compacting($);break;case"task_update":q.taskUpdate($.tasks);break;case"structured_output":q.structuredOutput($);break;case"mcp_catalog_changed":q.mcpCatalogChanged($);break;case"mcp_content_changed":q.mcpContentChanged($);break;case"mcp_resource_updated":q.mcpResourceUpdated($);break;case"mcp_connection_changed":q.mcpConnectionChanged($);break;case"mcp_log":q.mcpLog($);break;case"mcp_instructions_changed":q.mcpInstructionsChanged($);break;case"mcp_task_changed":q.mcpTaskChanged($);break;case"project_rules_loaded":q.projectRulesLoaded($);break;case"steering_applied":case"follow_up_started":case"goal_continuation_started":break;case"goal_updated":q.goal($);break;case"subagent_spawned":case"subagent_completed":q.subagent($);break;case"model_fallback":break;case"provider_retry":q.providerRetry($);break;case"provider_stall":q.providerStall($);break;case"action_stationarity":q.actionStationarity($);break;case"turn_start":if($.turn===1)b.targetLocked=!1;q.phase("turn",b.targetLocked?"hit":"ongoing",`Turn ${$.turn} started`,{turn:$.turn});break;default:{let X=$}}});if(h.metadata?.outputTruncated)q.error("[warning] 输出因达到 token 上限被截断,部分内容可能不完整。");if(!h.success)return q.error(`Error: ${h.error?.message??"Agent execution failed"}`),1;return q.phase("completed","done","Headless run completed"),0}catch(B){if(Z.hasOpenThinking()&&V==="text")Y.stderr.write(`
|
|
6
|
-
`);return q.error(`Error: ${KG(B)}`),1}finally{M?.();try{await H?.dispose()}finally{J.dispose()}}}async function pG(){if(!process.argv.slice(2).includes("--headless"))return!1;let{headless:z,"output-format":V,"system-prompt":q,"append-system-prompt":Z,"max-turns":b,...H}=Gq,M=eq(qG(process.argv)).scriptName("blade").strict(!1).options(H).middleware([Yq,Qq,Zq]);return VG(M),await M.parse(),!0}export{bG as runHeadless,pG as handleHeadlessMode,YG as HeadlessOptionsSchema};
|
package/dist/chunk-x1a5wv45.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{Bc as a,Cc as b,Dc as c,Ec as d,Fc as e,Gc as f,Hc as g,Ic as h}from"./chunk-x3dche8v.js";import"./chunk-p4hf7agx.js";import"./chunk-rqvejn8x.js";import"./chunk-0pcwv1h8.js";export{d as syncSession,e as syncAll,h as searchProjectionText,c as resetProjectionDbCache,f as removeSessionFromProjection,g as rebuildProjectionIndex,b as getProjectionDb,a as getIndexDbPath};
|
package/dist/chunk-z516a7nx.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{hc as a,ic as b,jc as c,kc as d,lc as e,mc as f,nc as g}from"./chunk-p2j0wcca.js";import"./chunk-jvtzyba4.js";import"./chunk-x3dche8v.js";import"./chunk-tdevyej4.js";import"./chunk-1ycv8b9t.js";import"./chunk-70kccy7a.js";import"./chunk-br9230a2.js";import"./chunk-2ycs4wce.js";import"./chunk-p4hf7agx.js";import"./chunk-69r9j0ms.js";import"./chunk-q4fy74fz.js";import"./chunk-rqvejn8x.js";import"./chunk-0pcwv1h8.js";export{b as __setSessionSnapshotIOForTesting,c as __resetSessionSnapshotIOForTesting,g as SessionService,d as SessionMissingCreationError,e as SessionArchivedError,f as SessionArchiveConflictError,a as STALE_EMPTY_SESSION_AGE_MS};
|