blade-code 0.10.34 → 0.10.36

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 (104) hide show
  1. package/dist/blade.js +2 -2
  2. package/dist/chunk-09qkatb5.js +10 -0
  3. package/dist/{chunk-jdms602t.js → chunk-0dj2qm8a.js} +1 -1
  4. package/dist/{chunk-5knt529c.js → chunk-0evyrnx0.js} +2 -2
  5. package/dist/chunk-0m4s8r87.js +1612 -0
  6. package/dist/{chunk-sgyk3gq1.js → chunk-1raz6s2b.js} +2 -2
  7. package/dist/{chunk-64f79ce5.js → chunk-1t8ebwsp.js} +2 -2
  8. package/dist/{chunk-58gk92k3.js → chunk-250vpvr5.js} +1 -1
  9. package/dist/{chunk-pnjftj8t.js → chunk-2mvp3rqw.js} +2 -2
  10. package/dist/chunk-3pxn6gcj.js +1 -0
  11. package/dist/{chunk-b9y9mc7f.js → chunk-3rjmkaey.js} +1 -1
  12. package/dist/{chunk-1qj0qms6.js → chunk-4bbnytq5.js} +1 -1
  13. package/dist/chunk-4f1g8f6q.js +1 -0
  14. package/dist/{chunk-sexhm0r5.js → chunk-4s0c6tkd.js} +1 -1
  15. package/dist/{chunk-y9a1jwnv.js → chunk-4vq34v09.js} +2 -2
  16. package/dist/chunk-515mkr66.js +44 -0
  17. package/dist/chunk-5c5qh3ab.js +1 -0
  18. package/dist/{chunk-pgy1mtgw.js → chunk-5cgyevqj.js} +1 -1
  19. package/dist/chunk-5vkxcjn1.js +1 -0
  20. package/dist/chunk-5xc50n8e.js +1 -0
  21. package/dist/{chunk-dvf4cfye.js → chunk-6360fg4j.js} +1 -1
  22. package/dist/{chunk-16449n3m.js → chunk-6gcmfvfj.js} +2 -2
  23. package/dist/{chunk-dsxjgty6.js → chunk-6jpspf3v.js} +2 -2
  24. package/dist/chunk-738a282r.js +1 -0
  25. package/dist/{chunk-ag0z1q2q.js → chunk-7c5tnz4y.js} +1 -1
  26. package/dist/{chunk-vfecv6cv.js → chunk-8ft7j7aw.js} +1 -1
  27. package/dist/chunk-8m87dnk2.js +1 -0
  28. package/dist/{chunk-c23bewtt.js → chunk-93jx06kq.js} +1 -1
  29. package/dist/{chunk-00gwp388.js → chunk-95k17p11.js} +1 -1
  30. package/dist/{chunk-7a8k7ck4.js → chunk-95n8g52h.js} +1 -1
  31. package/dist/{chunk-v6x80gdg.js → chunk-99ywfge1.js} +1 -1
  32. package/dist/{chunk-3j6bsp1q.js → chunk-9g6rzbcv.js} +2 -2
  33. package/dist/{chunk-1ep6bcpc.js → chunk-a7pvtxvz.js} +1 -1
  34. package/dist/{chunk-fjbptkh2.js → chunk-acw8q8w9.js} +2 -2
  35. package/dist/{chunk-d90tnjst.js → chunk-atsw605q.js} +1 -1
  36. package/dist/{chunk-d3gx05ph.js → chunk-cc7dmst6.js} +3 -3
  37. package/dist/{chunk-p01t6c78.js → chunk-ck5tvxkj.js} +2 -2
  38. package/dist/{chunk-ysr3frmw.js → chunk-ckfc7j7m.js} +1 -1
  39. package/dist/chunk-cnctwxqn.js +1 -0
  40. package/dist/{chunk-2gca6fvf.js → chunk-e23sz81n.js} +2 -2
  41. package/dist/chunk-e5yage6p.js +1 -0
  42. package/dist/{chunk-ba2dky3s.js → chunk-ekzck3x7.js} +1 -1
  43. package/dist/{chunk-nq1wqpsx.js → chunk-g510tpqt.js} +1 -1
  44. package/dist/{chunk-fb80q06q.js → chunk-gy8esxaa.js} +2 -2
  45. package/dist/chunk-hh158y4e.js +6 -0
  46. package/dist/{chunk-t1z46fqz.js → chunk-hq18c6r9.js} +1 -1
  47. package/dist/{chunk-qd7r2w39.js → chunk-hq1wrf1g.js} +1 -1
  48. package/dist/chunk-j2tmdkmw.js +1 -0
  49. package/dist/{chunk-crwa61tq.js → chunk-m2w03hpc.js} +1 -1
  50. package/dist/{chunk-0kqp5z4v.js → chunk-m6dh31kb.js} +2 -2
  51. package/dist/{chunk-rjg5rq90.js → chunk-n4555gej.js} +1 -1
  52. package/dist/{chunk-2sdbj0zz.js → chunk-phgqzja3.js} +2 -2
  53. package/dist/chunk-psgt2pq7.js +6 -0
  54. package/dist/{chunk-fw1fm9cn.js → chunk-q15qd9x4.js} +1 -1
  55. package/dist/chunk-q3r0zfec.js +1 -0
  56. package/dist/chunk-qgez5vw6.js +2 -0
  57. package/dist/{chunk-5v642sh3.js → chunk-qggnvzkc.js} +2 -2
  58. package/dist/{chunk-7ryqs453.js → chunk-qvdcesry.js} +2 -2
  59. package/dist/{chunk-mr0xs5t4.js → chunk-qwrdss51.js} +1 -1
  60. package/dist/{chunk-h34g9v9z.js → chunk-qxvk42rf.js} +1 -1
  61. package/dist/{chunk-wz6atg87.js → chunk-rshbnfr8.js} +4 -4
  62. package/dist/chunk-rv6kca90.js +1 -0
  63. package/dist/{chunk-7afbvxqt.js → chunk-s4enbe93.js} +2 -2
  64. package/dist/chunk-thstqcg3.js +2 -0
  65. package/dist/{chunk-bx99mx3k.js → chunk-v11r4ahz.js} +1 -1
  66. package/dist/chunk-ve7kp9rr.js +1 -0
  67. package/dist/chunk-xf2kjb9a.js +1 -0
  68. package/dist/{chunk-vqqxjgf2.js → chunk-xrhtwcd0.js} +1 -1
  69. package/dist/chunk-y990fa4r.js +204 -0
  70. package/dist/{chunk-95jjpdh9.js → chunk-y9nq48st.js} +2 -2
  71. package/dist/{chunk-prqgpq92.js → chunk-zwt7f9ab.js} +1 -1
  72. package/dist/web/assets/{ChatView-B7_Um8KR.js → ChatView-Dx9j7CGg.js} +2 -2
  73. package/dist/web/assets/{CodeBlockHighlighter-JzE91vkT.js → CodeBlockHighlighter-CZADKR6S.js} +1 -1
  74. package/dist/web/assets/{FilePreview-BTbtoUBJ.js → FilePreview-BOIDa_oJ.js} +1 -1
  75. package/dist/web/assets/{MarkdownRenderer-IaPtOh2w.js → MarkdownRenderer-DXsfHVUX.js} +3 -3
  76. package/dist/web/assets/{SettingsModal-CPgWPfZ2.js → SettingsModal-lQveNhC6.js} +1 -1
  77. package/dist/web/assets/{TaskSwitcher-D4RZxQKp.js → TaskSwitcher-BSrmpJ2u.js} +1 -1
  78. package/dist/web/assets/{TerminalPanel-yWbQfbYa.js → TerminalPanel-BFre9Shc.js} +1 -1
  79. package/dist/web/assets/{index-BnCT8SxR.js → index-DGZjm9wT.js} +4 -4
  80. package/dist/web/assets/{session-events-BZao_jMQ.js → session-events-Dk20sSDo.js} +19 -19
  81. package/dist/web/index.html +2 -2
  82. package/package.json +1 -1
  83. package/dist/chunk-1142vwqa.js +0 -6
  84. package/dist/chunk-2c8d4q3y.js +0 -1
  85. package/dist/chunk-3ctcv013.js +0 -44
  86. package/dist/chunk-5f956qbf.js +0 -1
  87. package/dist/chunk-87ge6dkk.js +0 -2
  88. package/dist/chunk-958rac3y.js +0 -1
  89. package/dist/chunk-ap5qpeh4.js +0 -1
  90. package/dist/chunk-c6fq52m9.js +0 -1
  91. package/dist/chunk-dvyv53nz.js +0 -1
  92. package/dist/chunk-ecsj4njh.js +0 -1
  93. package/dist/chunk-epyys9aw.js +0 -6
  94. package/dist/chunk-g0gqxn3c.js +0 -2
  95. package/dist/chunk-h3cvnbah.js +0 -1
  96. package/dist/chunk-jh6b81rb.js +0 -10
  97. package/dist/chunk-mxffhqe5.js +0 -1610
  98. package/dist/chunk-qr8j2mr6.js +0 -1
  99. package/dist/chunk-s1j86hhh.js +0 -204
  100. package/dist/chunk-s3sv04hf.js +0 -1
  101. package/dist/chunk-sjc7bm23.js +0 -1
  102. package/dist/chunk-tvrxzsna.js +0 -1
  103. package/dist/chunk-vhpvt5v8.js +0 -1
  104. package/dist/chunk-zp9p9tk6.js +0 -1
@@ -1,6 +0,0 @@
1
- import{m as fq,n as Eq,o as Iq,p as Lq,q as Wq,r as Sq}from"./chunk-crwa61tq.js";import{t as Jq,u as r,v as o,w as n,x as m,y as t}from"./chunk-fw1fm9cn.js";import{L as Uq,N as _q,O as Mq,Q as qq,S as Pq}from"./chunk-mxffhqe5.js";import"./chunk-ag0z1q2q.js";import"./chunk-00gwp388.js";import{Ua as zq,hb as jq,qb as Hq}from"./chunk-s1j86hhh.js";import"./chunk-pgy1mtgw.js";import{Yb as Gq,ac as Dq,lc as g,wc as l}from"./chunk-16449n3m.js";import"./chunk-g0gqxn3c.js";import"./chunk-2sdbj0zz.js";import{Sc as Aq}from"./chunk-64f79ce5.js";import{Uc as xq,Vc as Rq,Wc as bq}from"./chunk-1142vwqa.js";import{Xc as Nq}from"./chunk-5v642sh3.js";import"./chunk-5knt529c.js";import{vd as Kq}from"./chunk-2gca6fvf.js";import"./chunk-v508x7cg.js";import"./chunk-d90tnjst.js";import"./chunk-y9a1jwnv.js";import"./chunk-dsxjgty6.js";import"./chunk-b9y9mc7f.js";import"./chunk-fjbptkh2.js";import"./chunk-3j6bsp1q.js";import"./chunk-t1z46fqz.js";import"./chunk-prqgpq92.js";import"./chunk-ysr3frmw.js";import"./chunk-d3gx05ph.js";import"./chunk-bx99mx3k.js";import"./chunk-3ctcv013.js";import{vf as Xq}from"./chunk-1ep6bcpc.js";import{Bf as U,wf as Bq,yf as q,zf as e}from"./chunk-c23bewtt.js";import"./chunk-87ge6dkk.js";import{If as h}from"./chunk-dvf4cfye.js";import"./chunk-7ryqs453.js";import"./chunk-pnjftj8t.js";import"./chunk-nq1wqpsx.js";import"./chunk-fb80q06q.js";import"./chunk-0kqp5z4v.js";import"./chunk-jdms602t.js";import"./chunk-95jjpdh9.js";import"./chunk-sexhm0r5.js";import AZ from"yargs";import{hideBin as xZ}from"yargs/helpers";function p($,V,D){if($.off){$.off(V,D);return}$.removeListener?.(V,D)}function Tq($,V){if(!$.once&&!$.on||!$.off&&!$.removeListener)throw Error("Writable returned false without an observable drain contract");return new Promise((D,Q)=>{let Z=!1,Y=()=>{p($,"drain",_),p($,"error",M),V.removeEventListener("abort",x)},j=(b)=>{if(Z)return;Z=!0,Y(),b()},_=()=>j(D),M=(b)=>j(()=>Q(b??Error("Writable emitted an error"))),x=()=>j(()=>Q(V.reason??Error("Writable drain aborted")));if(V.aborted){x();return}let R=$.once?.bind($)??$.on?.bind($);R?.("drain",_),R?.("error",M),V.addEventListener("abort",x,{once:!0})})}async function gq($,V,D){if($.destroyed||$.writableEnded)throw Error("Writable is already closed");if($.write(V)===!1)await Tq($,D)}class u{options;queues;sinkErrorListeners=[];failed=!1;closing=!1;handleAbort=()=>{this.fail(new m("aborted","Headless output was aborted",{cause:this.options.signal?.reason}))};constructor($,V={}){this.options=V;let D=(Q)=>new t({maxPendingItems:V.maxPendingItems??r,maxPendingBytes:V.maxPendingBytes??o,writeTimeoutMs:V.writeTimeoutMs??n,sizeOf:(Z)=>Buffer.byteLength(Z),write:(Z,Y)=>gq($[Q],Z,Y),onFailure:(Z)=>this.fail(Z)});if(this.queues={stdout:D("stdout"),stderr:D("stderr")},this.observeSinkErrors($.stdout),$.stderr!==$.stdout)this.observeSinkErrors($.stderr);if(V.signal?.addEventListener("abort",this.handleAbort,{once:!0}),V.signal?.aborted)this.handleAbort()}write($,V){return this.queues[$].offer(V).accepted}async flush(){await Promise.all([this.queues.stdout.flush(),this.queues.stderr.flush()])}close($){if(this.closing||this.failed)return;this.closing=!0,this.options.signal?.removeEventListener("abort",this.handleAbort),this.removeSinkErrorListeners(),this.queues.stdout.close($),this.queues.stderr.close($)}stats(){return{stdout:this.queues.stdout.stats(),stderr:this.queues.stderr.stats()}}observeSinkErrors($){if(!$.on||!$.off&&!$.removeListener)return;let V=(D)=>{this.fail(new m("write_failed","Headless writable failed",{cause:D??Error("Writable emitted an error")}))};$.on("error",V),this.sinkErrorListeners.push({writer:$,listener:V})}fail($){if(this.closing||this.failed)return;this.failed=!0,this.options.signal?.removeEventListener("abort",this.handleAbort),this.removeSinkErrorListeners(),this.queues.stdout.close($),this.queues.stderr.close($),this.options.onFailure?.($)}removeSinkErrorListeners(){for(let{writer:$,listener:V}of this.sinkErrorListeners.splice(0))p($,"error",V)}}var Zq=1;function z($){return q.Object({event_version:q.Literal(Zq),...$})}var wq=z({type:q.Literal("content_delta"),delta:q.String()}),cq=z({type:q.Literal("thinking_delta"),delta:q.String()}),dq=z({type:q.Literal("thinking"),content:q.String()}),mq=z({type:q.Literal("stream_end")}),pq=z({type:q.Literal("content"),content:q.String()}),uq=z({type:q.Literal("structured_output"),output:q.Record(q.String(),q.Unknown()),schema_digest:q.String({pattern:"^[a-f0-9]{64}$"})}),$q=U(["readonly","write","execute"]),lq=z({type:q.Literal("tool_start"),tool_name:q.String(),summary:q.String(),target:q.Optional(q.String()),tool_kind:q.Optional($q)}),vq=z({type:q.Literal("tool_progress"),tool_name:q.String(),message:q.String(),progress:q.Optional(q.Number()),total:q.Optional(q.Number())}),sq=z({type:q.Literal("tool_result"),tool_name:q.String(),summary:q.String(),target:q.Optional(q.String()),tool_kind:q.Optional($q),success:q.Optional(q.Boolean()),error_type:q.Optional(q.String()),error_message:q.Optional(q.String())}),iq=z({type:q.Literal("mcp_catalog_changed"),revision:q.Integer({minimum:1}),server_name:q.String(),added:q.Array(q.String()),removed:q.Array(q.String()),updated:q.Array(q.String())}),aq=z({type:q.Literal("mcp_content_changed"),revision:q.Integer({minimum:1}),server_name:q.String(),content_kind:U(["resources","resource_templates","prompts"]),added:q.Array(q.String()),removed:q.Array(q.String()),updated:q.Array(q.String())}),rq=z({type:q.Literal("mcp_resource_updated"),revision:q.Integer({minimum:1}),server_name:q.String(),uri:q.String()}),oq=z({type:q.Literal("mcp_connection_changed"),revision:q.Integer({minimum:1}),server_name:q.String(),phase:U(["reconnecting","recovered","failed"]),reason:q.String(),attempt:q.Integer({minimum:0}),max_attempts:q.Integer({minimum:0}),next_retry_at:q.Optional(q.Integer({minimum:0})),error:q.Optional(q.String())}),nq=z({type:q.Literal("mcp_log"),revision:q.Integer({minimum:1}),server_name:q.String(),level:U(["debug","info","notice","warning","error","critical","alert","emergency"]),logger:q.Optional(q.String()),message:q.String(),projected_bytes:q.Integer({minimum:0}),data_sha256:q.String(),truncated:q.Boolean(),details_omitted:q.Boolean(),timestamp:q.Integer({minimum:0}),synthetic:q.Optional(q.Boolean())}),tq=z({type:q.Literal("mcp_instructions_changed"),revision:q.Integer({minimum:0}),server_name:q.String(),action:U(["added","removed"]),reason:U(["snapshot","connection","disconnection"]),text:q.Optional(q.String()),source_bytes:q.Optional(q.Integer({minimum:0})),projected_bytes:q.Optional(q.Integer({minimum:0})),sha256:q.Optional(q.String()),truncated:q.Optional(q.Boolean()),details_omitted:q.Optional(q.Boolean())}),eq=z({type:q.Literal("mcp_task_changed"),revision:q.Integer({minimum:0}),task_id:q.String(),server_name:q.String(),tool_name:q.String(),status:U(["working","input_required","interrupted","completed","failed","cancelled"]),status_message:q.Optional(q.String()),created_at:q.Integer({minimum:0}),updated_at:q.Integer({minimum:0}),completed_at:q.Optional(q.Integer({minimum:0})),has_result:q.Boolean(),error:q.Optional(q.String())}),qZ=z({type:q.Literal("project_rules_loaded"),files:q.Array(q.Object({id:q.String(),relative_path:q.String(),source:U(["project","local"]),conditional:q.Boolean(),content_sha256:q.String({pattern:"^[a-f0-9]{64}$"})})),trigger_paths:q.Array(q.String()),blocked_write:q.Boolean()}),ZZ=z({type:q.Literal("user_shell_started"),execution_id:q.String(),command:q.String(),auxiliary:q.Boolean()}),$Z=z({type:q.Literal("user_shell_output"),execution_id:q.String(),stream:U(["stdout","stderr"]),chunk:q.String(),stream_truncated:q.Boolean()}),VZ=z({type:q.Literal("user_shell_completed"),execution_id:q.String(),message_id:q.String(),status:U(["completed","failed","aborted","timed_out","spawn_error"]),exit_code:q.Union([q.Integer(),q.Null()]),duration_ms:q.Number({minimum:0}),stdout:q.String(),stderr:q.String(),truncated:q.Boolean(),auxiliary:q.Boolean()}),YZ=z({type:q.Literal("phase"),phase:U(["turn","searching","inspecting","target_hit","executing","completed"]),status:U(["ongoing","hit","done"]),message:q.String(),turn:q.Optional(q.Number()),tool_name:q.Optional(q.String()),target:q.Optional(q.String())}),QZ=z({type:q.Literal("tool_detail"),tool_name:q.String(),detail:q.String()}),XZ=z({type:q.Literal("task_update"),tasks:q.Array(qq)}),BZ=z({type:q.Literal("goal"),state:U(["updated","cleared"]),goal_id:q.Optional(q.String()),status:q.Optional(U(["active","verifying","paused","blocked","usage_limited","budget_limited","complete"])),verification_attempt:q.Optional(q.Integer({minimum:1})),verification_status:q.Optional(U(["pending","pass","fail","partial"])),verifier_session_id:q.Optional(q.String()),verification_evidence_sha256:q.Optional(q.String({pattern:"^[a-f0-9]{64}$"}))}),KZ=z({type:q.Literal("subagent"),state:U(["spawned","completed"]),session_id:q.String(),subagent_type:q.Optional(q.String()),success:q.Optional(q.Boolean()),summary:q.Optional(q.String()),verification_verdict:q.Optional(U(["pass","fail","partial"])),resumed_from:q.Optional(q.String()),root_agent_id:q.Optional(q.String()),resume_depth:q.Optional(q.Integer({minimum:0}))}),GZ=z({type:q.Literal("token_usage"),input_tokens:q.Number(),output_tokens:q.Number(),total_tokens:q.Number(),max_context_tokens:q.Number(),cache_read_tokens:q.Optional(q.Number()),cache_write_tokens:q.Optional(q.Number()),cost_usd:q.Optional(q.Number())}),DZ=z({type:q.Literal("compacting"),state:U(["started","completed"]),reason:q.Optional(U(["threshold","context_limit","turn_limit","manual"])),strategy:q.Optional(U(["llm","fallback","snip"])),outcome:q.Optional(U(["completed","fallback","failed"])),pre_tokens:q.Optional(q.Number({minimum:0})),post_tokens:q.Optional(q.Number({minimum:0}))}),zZ=z({type:q.Literal("provider_retry"),phase:U(["scheduled","attempt","recovered","exhausted"]),attempt:q.Integer({minimum:0}),max_retries:q.Integer({minimum:0}),reason:U(["rate_limit","server_error","timeout","transport","stream_closed"]),status_code:q.Optional(q.Integer({minimum:100,maximum:599})),delay_ms:q.Optional(q.Integer({minimum:0})),next_retry_at:q.Optional(q.Integer({minimum:0}))}),jZ=z({type:q.Literal("provider_stall"),phase:U(["detected","recovered"]),stall_count:q.Integer({minimum:1}),duration_ms:q.Integer({minimum:0}),warning_after_ms:q.Integer({minimum:1}),timeout_ms:q.Integer({minimum:1}),output_started:q.Boolean()}),HZ=z({type:q.Literal("action_stationarity"),phase:U(["detected","recovered","halted"]),tool_name:q.String(),run_length:q.Integer({minimum:1}),nudge_threshold:q.Integer({minimum:1}),halt_threshold:q.Integer({minimum:1}),progress_aware:q.Boolean()}),UZ=z({type:q.Literal("turn_limit"),turns_count:q.Number(),action:q.Literal("continue")}),_Z=z({type:q.Literal("task_session"),session_id:q.String(),project_path:q.String(),source_project_path:q.String(),isolation:U(["local","worktree"]),worktree_branch:q.Optional(q.String()),base_commit:q.Optional(q.String())}),MZ=z({type:q.Literal("task_admission"),state:U(["queued","running"]),queue_position:q.Optional(q.Integer({minimum:1})),queue_depth:q.Integer({minimum:0}),in_flight:q.Integer({minimum:0}),max_concurrent_tasks:q.Integer({minimum:1})}),PZ=z({type:q.Literal("output"),content:q.String(),exit_code:q.Number()}),NZ=z({type:q.Literal("error"),message:q.String()}),cZ=e(q.Union([wq,cq,dq,mq,pq,uq,lq,vq,sq,iq,aq,rq,oq,nq,tq,eq,qZ,ZZ,$Z,VZ,YZ,QZ,XZ,BZ,KZ,GZ,DZ,zZ,jZ,HZ,UZ,_Z,MZ,PZ,NZ]));function Vq($,V){return{event_version:Zq,type:$,...V}}function RZ($){let V=new AbortController,D=(Y)=>{if(!V.signal.aborted)V.abort(Y)},Q=()=>D("interrupt"),Z=()=>D($?.signal?.reason);if($?.signal){if($.signal.addEventListener("abort",Z,{once:!0}),$.signal.aborted)Z()}else process.once("SIGINT",Q),process.once("SIGTERM",Q);return{signal:V.signal,abort:D,dispose:()=>{$?.signal?.removeEventListener("abort",Z),process.removeListener("SIGINT",Q),process.removeListener("SIGTERM",Q)}}}var bZ=U(["text","jsonl"]),JZ=q.Object({headless:q.Optional(q.Boolean()),message:q.Optional(q.String()),_:q.Optional(q.Array(q.Union([q.String(),q.Number()]))),model:q.Optional(q.String()),systemPrompt:q.Optional(q.String()),appendSystemPrompt:q.Optional(q.String()),verificationAgent:q.Optional(q.Boolean()),maxTurns:q.Optional(q.Refine(q.Integer(),($)=>$===-1||$>0,()=>"must be -1 (unlimited) or a positive integer")),permissionMode:q.Optional(q.Enum(Xq)),mcpConfig:q.Optional(q.Array(q.String())),strictMcpConfig:q.Optional(q.Boolean()),sessionId:q.Optional(q.String()),allowedTools:q.Optional(q.Array(q.String())),disallowedTools:q.Optional(q.Array(q.String())),agents:q.Optional(q.String()),continue:q.Optional(q.Boolean()),resume:q.Optional(q.Union([q.String(),q.Boolean()])),forkSession:q.Optional(q.Boolean()),taskIsolation:q.Optional(U(["local","worktree"])),outputFormat:q.Optional(bZ),jsonSchema:q.Optional(q.String()),outputSchema:q.Optional(q.String())});class Cq{openedThinking=!1;wroteAssistantContent=!1;markAssistantContent(){this.wroteAssistantContent=!0}setThinkingOpened($){this.openedThinking=$}hasOpenThinking(){return this.openedThinking}completeStream(){let $={openedThinking:this.openedThinking,wroteAssistantContent:this.wroteAssistantContent};return this.openedThinking=!1,this.wroteAssistantContent=!1,$}}function fZ($){return $.issues.map((V)=>`${V.path.join(".")||"options"}: ${V.message}`).join("; ")}function EZ($){let V=Bq(JZ,$);if(!V.success)throw Error(`Invalid headless options: ${fZ(V.error)}`);return V.data}function IZ($){return $.command("* [message]","Run full agent loop without Ink UI and print events to the terminal",(V)=>V.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(V)=>{if(!V.headless)return;let D=await hZ(V);process.exit(D)})}function H($,V=""){$.write(`${V}
2
- `)}function LZ($){return`[task] [${$.status}] ${$.subject}`}function WZ(){return{requestConfirmation:async($)=>$.type==="mcpElicitation"?{approved:!1,reason:"headless-mcp-elicitation-unavailable",elicitation:{action:"cancel"}}:$.type==="mcpSampling"?{approved:!1,reason:"headless-mcp-sampling-unavailable"}:{approved:!0,reason:"headless-auto-approved",scope:"session"}}}function SZ($){if(!($ instanceof Error))return"Unknown error";let Q=$.lastError??$;if(Q.responseBody)try{let j=JSON.parse(Q.responseBody)?.error?.message;if(j)return Q.statusCode?`${j} (HTTP ${Q.statusCode})`:j}catch{}let Z=$.message.match(/Last error:\s*(.+)$/);if(Z)return Z[1];return $.message}function CZ($){return $==="jsonl"?"jsonl":"text"}function Yq($,V){let D=(...Q)=>{for(let Z of Q){let Y=V[Z];if(typeof Y==="string"&&Y.trim()!=="")return Y}return};switch($){case"Read":case"Edit":case"Write":case"UndoEdit":return D("file_path");case"ApplyPatch":return"multi-file patch";case"NotebookEdit":return D("notebook_path");case"Grep":return D("path","pattern");case"Glob":return D("pattern");case"WebFetch":return D("url");case"WebSearch":return D("query");case"Bash":return D("command","description");case"Task":return D("description");case"LSP":return D("filePath","operation");case"EnterWorktree":return D("name");case"ExitWorktree":return D("action");default:return}}function OZ($,V,D,Q){let Z=new Set(["Glob","Grep","WebSearch","LS"]),Y=new Set(["Read","WebFetch"]);if(new Set(["Edit","Write","ApplyPatch","NotebookEdit","Bash","LSP","UndoEdit","EnterWorktree","ExitWorktree"]).has($)&&!Q.targetLocked)return{phase:"target_hit",status:"hit",message:`Target locked: ${V}`,shouldLockTarget:!0};if(Q.targetLocked)return{phase:"executing",status:"hit",message:D?`Working within target: ${V}`:`Executing: ${V}`,shouldLockTarget:!1};if(Z.has($))return{phase:"searching",status:"ongoing",message:`Still searching: ${V}`,shouldLockTarget:!1};if(Y.has($))return{phase:"inspecting",status:"ongoing",message:`Inspecting candidate: ${V}`,shouldLockTarget:!1};return{phase:"executing",status:Q.targetLocked?"hit":"ongoing",message:`Executing: ${V}`,shouldLockTarget:!1}}function Qq($,V,D=!1){let Q=(Z,Y)=>{$.stdout.write(`${JSON.stringify(Vq(Z,Y))}
3
- `)};return{contentDelta(Z){if(V==="jsonl"){Q("content_delta",{delta:Z});return}if(D)return;$.stdout.write(Z)},thinkingDelta(Z,Y){if(V==="jsonl")return Q("thinking_delta",{delta:Z}),Y;if(!Y)$.stderr.write("[thinking] ");return $.stderr.write(Z),!0},thinking(Z){if(V==="jsonl"){Q("thinking",{content:Z});return}H($.stderr,`[thinking] ${Z}`)},streamEnd(Z,Y){if(V==="jsonl"){Q("stream_end",{});return}if(Y)$.stderr.write(`
4
- `);if(Z)$.stdout.write(`
5
- `)},content(Z){if(V==="jsonl"){Q("content",{content:Z});return}H($.stdout,Z)},structuredOutput(Z){if(V==="jsonl"){Q("structured_output",{output:Z.output,schema_digest:Z.schemaDigest});return}H($.stdout,JSON.stringify(Z.output))},toolStart(Z,Y,j,_){if(V==="jsonl"){Q("tool_start",{tool_name:Z,summary:Y,target:j,tool_kind:_});return}H($.stderr,`[tool:start] ${Y}`)},toolProgress(Z,Y,j,_){if(V==="jsonl"){Q("tool_progress",{tool_name:Z,message:Y,progress:j,total:_});return}H($.stderr,`[tool:progress] ${Z}: ${Y}`)},toolResult(Z,Y,j,_,M){if(V==="jsonl"){Q("tool_result",{tool_name:Z,summary:Y,target:j,tool_kind:_,success:M?.success,error_type:M?.errorType,error_message:M?.errorMessage});return}H($.stderr,`[tool:result] ${Y}`)},mcpCatalogChanged(Z){if(V==="jsonl"){Q("mcp_catalog_changed",{revision:Z.revision,server_name:Z.serverName,added:Z.added,removed:Z.removed,updated:Z.updated});return}H($.stderr,`[mcp:catalog] r${Z.revision} ${Z.serverName} +${Z.added.length} -${Z.removed.length} ~${Z.updated.length}`)},mcpContentChanged(Z){if(V==="jsonl"){Q("mcp_content_changed",{revision:Z.revision,server_name:Z.serverName,content_kind:Z.contentKind==="resourceTemplates"?"resource_templates":Z.contentKind,added:Z.added,removed:Z.removed,updated:Z.updated});return}H($.stderr,`[mcp:${Z.contentKind}] r${Z.revision} ${Z.serverName} +${Z.added.length} -${Z.removed.length} ~${Z.updated.length}`)},mcpResourceUpdated(Z){if(V==="jsonl"){Q("mcp_resource_updated",{revision:Z.revision,server_name:Z.serverName,uri:Z.uri});return}H($.stderr,`[mcp:resource] r${Z.revision} ${Z.serverName} updated ${Z.uri}`)},mcpConnectionChanged(Z){if(V==="jsonl"){Q("mcp_connection_changed",{revision:Z.revision,server_name:Z.serverName,phase:Z.phase,reason:Z.reason,attempt:Z.attempt,max_attempts:Z.maxAttempts,...Z.nextRetryAt!==void 0?{next_retry_at:Z.nextRetryAt}:{},...Z.error?{error:Z.error}:{}});return}H($.stderr,`[mcp:connection] r${Z.revision} ${Z.serverName} ${Z.phase} ${Z.attempt}/${Z.maxAttempts}`)},mcpLog(Z){if(V==="jsonl"){Q("mcp_log",{revision:Z.revision,server_name:Z.serverName,level:Z.level,logger:Z.logger,message:Z.message,projected_bytes:Z.projectedBytes,data_sha256:Z.dataSha256,truncated:Z.truncated,details_omitted:Z.detailsOmitted,timestamp:Z.timestamp,synthetic:Z.synthetic});return}H($.stderr,`[mcp:log] ${Z.level} ${Z.serverName}${Z.logger?` logger=${Z.logger}`:""}: ${Z.message}`)},mcpInstructionsChanged(Z){if(V==="jsonl"){Q("mcp_instructions_changed",{revision:Z.revision,server_name:Z.serverName,action:Z.action,reason:Z.reason,text:Z.text,source_bytes:Z.sourceBytes,projected_bytes:Z.projectedBytes,sha256:Z.sha256,truncated:Z.truncated,details_omitted:Z.detailsOmitted});return}H($.stderr,`[mcp:instructions] ${Z.action} ${Z.serverName}${Z.truncated?" (truncated)":""}`)},mcpTaskChanged(Z){if(V==="jsonl"){Q("mcp_task_changed",{revision:Z.revision,task_id:Z.taskId,server_name:Z.serverName,tool_name:Z.toolName,status:Z.status,status_message:Z.statusMessage,created_at:Z.createdAt,updated_at:Z.updatedAt,completed_at:Z.completedAt,has_result:Z.hasResult,error:Z.error});return}H($.stderr,`[mcp:task] ${Z.taskId} ${Z.serverName}/${Z.toolName} `+Z.status)},projectRulesLoaded(Z){if(V==="jsonl"){Q("project_rules_loaded",{files:Z.files.map((Y)=>({id:Y.id,relative_path:Y.relativePath,source:Y.source,conditional:Y.conditional,content_sha256:Y.contentSha256})),trigger_paths:Z.triggerPaths,blocked_write:Z.blockedWrite});return}H($.stderr,`[project-rules] loaded ${Z.files.length} file(s)${Z.blockedWrite?" before write":""}`)},userShellStarted(Z,Y,j){if(V==="jsonl"){Q("user_shell_started",{execution_id:Z,command:Y,auxiliary:j});return}H($.stderr,`[user-shell:start] ${Y}`)},userShellOutput(Z,Y,j,_){if(V==="jsonl"){Q("user_shell_output",{execution_id:Z,stream:Y,chunk:j,stream_truncated:_});return}(Y==="stderr"?$.stderr:$.stdout).write(j)},userShellCompleted(Z){if(V==="jsonl"){Q("user_shell_completed",{execution_id:Z.executionId,message_id:Z.messageId,status:Z.record.status,exit_code:Z.record.exitCode,duration_ms:Z.record.durationMs,stdout:Z.record.stdout,stderr:Z.record.stderr,truncated:Z.record.truncated,auxiliary:Z.auxiliary});return}H($.stderr,`[user-shell:${Z.record.status}] exit=${Z.record.exitCode??"null"} ${Z.record.durationMs}ms`)},phase(Z,Y,j,_={}){if(V==="jsonl"){Q("phase",{phase:Z,status:Y,message:j,turn:_.turn,tool_name:_.toolName,target:_.target});return}H($.stderr,`[phase:${Z}] ${j}`)},toolDetail(Z,Y){if(V==="jsonl"){Q("tool_detail",{tool_name:Z,detail:Y});return}H($.stderr,Y)},taskUpdate(Z){if(V==="jsonl"){Q("task_update",{tasks:Z});return}for(let Y of Z)H($.stderr,LZ(Y))},goal(Z){if(V==="jsonl"){Q("goal",{state:Z.goal?"updated":"cleared",goal_id:Z.goal?.goalId,status:Z.goal?.status,verification_attempt:Z.goal?.completionVerification?.attempt,verification_status:Z.goal?.completionVerification?.status,verifier_session_id:Z.goal?.completionVerification?.verifierSessionId,verification_evidence_sha256:Z.goal?.completionVerification?.evidenceSha256});return}if(Z.goal)H($.stderr,`[goal:${Z.goal.status}] ${Z.goal.objective}`);else H($.stderr,"[goal:cleared]")},subagent(Z){let Y=Z.kind==="subagent_spawned";if(V==="jsonl"){Q("subagent",{state:Y?"spawned":"completed",session_id:Z.sessionId,subagent_type:Z.type,success:Y?void 0:Z.success,summary:Y?void 0:Z.summary,verification_verdict:Y?void 0:Z.verificationVerdict,resumed_from:Z.resumedFrom,root_agent_id:Z.rootAgentId,resume_depth:Z.resumeDepth});return}H($.stderr,`[subagent:${Y?"spawned":"completed"}] ${Z.sessionId}${Z.resumedFrom?` resumed from ${Z.resumedFrom}`:""}`)},tokenUsage(Z){if(V==="jsonl"){Q("token_usage",{input_tokens:Z.inputTokens,output_tokens:Z.outputTokens,total_tokens:Z.totalTokens,max_context_tokens:Z.maxContextTokens,cache_read_tokens:Z.cacheReadTokens,cache_write_tokens:Z.cacheWriteTokens,cost_usd:Z.costUsd});return}H($.stderr,`[tokens] in=${Z.inputTokens} out=${Z.outputTokens} total=${Z.totalTokens} / ${Z.maxContextTokens}`)},compacting(Z){let Y=Z.phase==="start";if(V==="jsonl"){Q("compacting",{state:Y?"started":"completed",reason:Z.reason,strategy:Z.strategy,outcome:Z.outcome,pre_tokens:Z.preTokens,post_tokens:Z.postTokens});return}H($.stderr,Y?`[context] compacting started${Z.reason?` (${Z.reason})`:""}`:`[context] compacting ${Z.outcome??"completed"}`)},providerRetry(Z){if(V==="jsonl"){Q("provider_retry",{phase:Z.phase,attempt:Z.attempt,max_retries:Z.maxRetries,reason:Z.reason,status_code:Z.statusCode,delay_ms:Z.delayMs,next_retry_at:Z.nextRetryAt});return}let Y=Z.delayMs!==void 0?` in ${Math.max(0,Math.ceil(Z.delayMs/1000))}s`:"";H($.stderr,`[provider-retry:${Z.phase}] ${Z.attempt}/${Z.maxRetries} ${Z.reason}${Y}`)},providerStall(Z){if(V==="jsonl"){Q("provider_stall",{phase:Z.phase,stall_count:Z.stallCount,duration_ms:Z.durationMs,warning_after_ms:Z.warningAfterMs,timeout_ms:Z.timeoutMs,output_started:Z.outputStarted});return}H($.stderr,`[provider-stall:${Z.phase}] ${Z.durationMs}ms / ${Z.timeoutMs}ms`)},actionStationarity(Z){if(V==="jsonl"){Q("action_stationarity",{phase:Z.phase,tool_name:Z.toolName,run_length:Z.runLength,nudge_threshold:Z.nudgeThreshold,halt_threshold:Z.haltThreshold,progress_aware:Z.progressAware});return}H($.stderr,`[action-stationarity:${Z.phase}] ${Z.toolName} ${Z.runLength}/${Z.haltThreshold}`)},turnLimit(Z){if(V==="jsonl"){Q("turn_limit",{turns_count:Z,action:"continue"});return}H($.stderr,`[turn-limit] continuing after ${Z} turns`)},taskSession(Z){if(V==="jsonl"){Q("task_session",{session_id:Z.sessionId,project_path:Z.projectPath,source_project_path:Z.sourceProjectPath,isolation:Z.isolation,worktree_branch:Z.worktreeBranch,base_commit:Z.baseCommit});return}H($.stderr,`[task:${Z.isolation}] ${Z.sessionId} ${Z.sourceProjectPath} -> ${Z.projectPath}${Z.worktreeBranch?` (${Z.worktreeBranch})`:""}`)},taskAdmission(Z){if(V==="jsonl"){Q("task_admission",{state:Z.state,queue_position:Z.queuePosition,queue_depth:Z.queueDepth,in_flight:Z.inFlight,max_concurrent_tasks:Z.maxConcurrentTasks});return}H($.stderr,Z.state==="queued"?`[task:queued] position ${Z.queuePosition??1}/${Z.queueDepth} (running ${Z.inFlight}/${Z.maxConcurrentTasks})`:`[task:running] admitted (running ${Z.inFlight}/${Z.maxConcurrentTasks})`)},output(Z,Y=0){if(V==="jsonl"){Q("output",{content:Z,exit_code:Y});return}H(Y===0?$.stdout:$.stderr,Z)},error(Z){if(V==="jsonl"){Q("error",{message:Z});return}H($.stderr,Z)}}}async function hZ($,V={stdout:process.stdout,stderr:process.stderr},D){let Q="text",Z=new Cq,Y={targetLocked:!1},j,_,M=RZ(D),x=!1,R=new u(V,{signal:M.signal,onFailure:(B)=>{x=!0,M.abort(B)}}),b={stdout:{write:(B)=>R.write("stdout",B)},stderr:{write:(B)=>R.write("stderr",B)}},K=Qq(b,Q),w=async()=>{try{return await R.flush(),!x}catch{return!1}},f=async(B)=>{return _?.(),_=void 0,await w()?B:1};try{let B=EZ($);Q=CZ(B.outputFormat);let E=await Wq(B);K=Qq(b,Q,Boolean(E)),await fq();let v=B.forkSession!==!0&&(B.continue===!0||typeof B.resume==="string"&&B.resume.length>0)?await Iq({message:B.message,_:B._,stdin:D?.stdin}):await Eq({...B,stdin:D?.stdin}),S=v===void 0,N=S?{mode:"agent",content:""}:await Lq(v);if(N.mode==="output"){if(N.content)K.output(N.content,N.exitCode??0);return await f(N.exitCode??0)}let k=N.content.trimStart().startsWith("!")?N.content.trimStart().slice(1).trim():void 0;if(k!==void 0&&B.taskIsolation)throw Error("User shell commands cannot be combined with --task-isolation");if(k!==void 0&&E)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:s,metadata:i}=await Sq({sessionId:B.sessionId,continue:B.continue,resume:B.resume,forkSession:B.forkSession,fallbackSessionPrefix:"headless"}),C=B.permissionMode??i?.permissionMode??"yolo",a=B.model&&B.model!=="inherit"?B.model:Kq()?.id,P=B.taskIsolation?await Jq.createSessionTask({sessionId:A,prompt:N.content,sourceProjectPath:h(),isolation:B.taskIsolation,dispatch:{version:1,prompt:N.content,sourceProjectPath:h(),isolation:B.taskIsolation,permissionMode:C,...a?{modelId:a}:{},...E?{outputSchema:E}:{}}}):void 0,J=P?.metadata.projectPath??i?.projectPath??h();if(!P)await l.setSessionPermissionMode(A,J,C);let Oq=P?!1:await Hq.cancelPendingNonInteractive(J,A);if(P)K.taskSession({sessionId:A,projectPath:J,sourceProjectPath:P.metadata.taskSourceProjectPath??h(),isolation:B.taskIsolation,worktreeBranch:P.metadata.taskWorktreeBranch,baseCommit:P.metadata.taskBaseCommit}),_=zq.subscribe((X)=>{if(X.type!=="task.status"||X.sessionId!==A||X.projectPath!==J||!["queued","running"].includes(String(X.properties.taskStatus))||typeof X.properties.taskQueueDepth!=="number"||typeof X.properties.taskInFlight!=="number"||typeof X.properties.taskConcurrencyLimit!=="number")return;K.taskAdmission({state:X.properties.taskStatus,queuePosition:typeof X.properties.taskQueuePosition==="number"?X.properties.taskQueuePosition:void 0,queueDepth:X.properties.taskQueueDepth,inFlight:X.properties.taskInFlight,maxConcurrentTasks:X.properties.taskConcurrencyLimit})});let hq={messages:Oq?await l.loadSessionModelContext(A,J):[...s],userId:"cli-user",sessionId:A,workspaceRoot:J,permissionMode:C,signal:M.signal,...P?.taskWorktree?{worktreeActive:!0}:{},confirmationHandler:WZ()};j=await Uq.create({sessionId:A,workspaceRoot:J,modelId:B.model,permissionMode:C,mcpConfig:B.mcpConfig,strictMcpConfig:B.strictMcpConfig,agents:B.agents?Nq(B.agents):void 0,...P?.taskWorktree?{taskWorktree:P.taskWorktree}:{},...P?.metadata.taskIsolation?{taskIsolation:P.metadata.taskIsolation}:{},...s.length>0?{sessionStart:{isResume:!0,resumeSessionId:A}}:{}});let F=S&&j.getPendingSteeringCount()>0,y=S&&!F?await j.getGoal():null,c=y?.status==="active"||y?.status==="verifying",I=S&&!F&&!c?await j.getRecoveredFinalResponse():void 0;if(S&&!F&&!c){if(!I)throw Error("No unfinished turn or active goal to resume");if(y)K.goal({kind:"goal_updated",goal:y});if(I.structuredOutput&&I.structuredOutputSchemaDigest)K.structuredOutput({kind:"structured_output",output:I.structuredOutput,schemaDigest:I.structuredOutputSchemaDigest});else K.content(I.content);return K.phase("completed","done","Recovered headless run completed"),await f(0)}if(k!==void 0){let X=await j.executeUserShellCommand(k,{signal:M.signal,onEvent:async(G)=>{if(G.type==="started")K.userShellStarted(G.executionId,G.command,G.auxiliary);else if(G.type==="output")K.userShellOutput(G.executionId,G.stream,G.chunk,G.streamTruncated);await w()}});return K.userShellCompleted(X),await f(X.record.status==="completed"?0:X.record.status==="aborted"?130:X.record.exitCode??1)}let kq=B.maxTurns??j.getConfig().maxTurns,Fq=P?.taskWorktree?[...new Set([...B.disallowedTools??[],"EnterWorktree","ExitWorktree"])]:B.disallowedTools,yq=await Pq.createWithRuntime(j,{sessionId:A,systemPrompt:B.systemPrompt,appendSystemPrompt:B.appendSystemPrompt,maxTurns:B.maxTurns,modelId:B.model,permissionMode:C,toolWhitelist:B.allowedTools,toolBlacklist:Fq,mcpConfig:B.mcpConfig,strictMcpConfig:B.strictMcpConfig}),d=await jq(yq.chatStream(N.content,hq,{stream:!0,signal:M.signal,maxTurns:B.maxTurns,builtinVerification:B.verificationAgent!==!1,outputSchema:E,pendingInputOnly:F,goalContinuationOnly:c,...kq===-1?{onTurnLimitReached:async(X)=>{return K.turnLimit(X.turnsCount),{continue:!0,reason:"headless-auto-continue"}}}:{}}),async(X)=>{switch(X.kind){case"content_delta":if(!E||Q==="jsonl")Z.markAssistantContent();K.contentDelta(X.delta);break;case"thinking_delta":Z.setThinkingOpened(K.thinkingDelta(X.delta,Z.hasOpenThinking()));break;case"stream_end":{let G=Z.completeStream();K.streamEnd(G.wroteAssistantContent,G.openedThinking);break}case"tool_start":{let G=X.toolCall;if(!("function"in G))break;if(G.function.name===g)break;if(["TaskCreate","TaskUpdate","TaskList"].includes(G.function.name))break;try{let L=JSON.parse(G.function.arguments),W=_q(G.function.name,L),O=Yq(G.function.name,L),T=OZ(G.function.name,W,O,Y);if(T.shouldLockTarget)Y.targetLocked=!0;K.phase(T.phase,T.status,T.message,{toolName:G.function.name,target:O}),K.toolStart(G.function.name,W,O,X.toolKind)}catch{K.phase(Y.targetLocked?"executing":"searching",Y.targetLocked?"hit":"ongoing",Y.targetLocked?`Working within target: ${G.function.name}`:`Still searching: ${G.function.name}`,{toolName:G.function.name}),K.toolStart(G.function.name,G.function.name,void 0,X.toolKind)}break}case"tool_progress":{let G=X.toolCall;if(!("function"in G))break;if(G.function.name===g)break;K.toolProgress(G.function.name,X.update.message,X.update.progress,X.update.total);break}case"tool_result":{let G=X.toolCall;if(!("function"in G))break;if(G.function.name===g)break;let L;try{let O=JSON.parse(G.function.arguments);L=Yq(G.function.name,O)}catch{L=void 0}let W=Dq(Mq(G.function.name,X.result),Gq);if(K.toolResult(G.function.name,W.summary,L,void 0,{success:X.result.success,errorType:X.result.error?.type,errorMessage:X.result.error?.message}),W.detail)K.toolDetail(G.function.name,W.detail);break}case"token_usage":K.tokenUsage(X.usage);break;case"compaction":K.compacting(X);break;case"task_update":K.taskUpdate(X.tasks);break;case"structured_output":K.structuredOutput(X);break;case"mcp_catalog_changed":K.mcpCatalogChanged(X);break;case"mcp_content_changed":K.mcpContentChanged(X);break;case"mcp_resource_updated":K.mcpResourceUpdated(X);break;case"mcp_connection_changed":K.mcpConnectionChanged(X);break;case"mcp_log":K.mcpLog(X);break;case"mcp_instructions_changed":K.mcpInstructionsChanged(X);break;case"mcp_task_changed":K.mcpTaskChanged(X);break;case"project_rules_loaded":K.projectRulesLoaded(X);break;case"steering_applied":case"follow_up_started":case"goal_continuation_started":break;case"goal_updated":K.goal(X);break;case"subagent_spawned":case"subagent_completed":K.subagent(X);break;case"model_fallback":break;case"provider_retry":K.providerRetry(X);break;case"provider_stall":K.providerStall(X);break;case"action_stationarity":K.actionStationarity(X);break;case"turn_start":if(X.turn===1)Y.targetLocked=!1;K.phase("turn",Y.targetLocked?"hit":"ongoing",`Turn ${X.turn} started`,{turn:X.turn});break;default:{let G=X}}await w()});if(d.metadata?.outputTruncated)K.error("[warning] 输出因达到 token 上限被截断,部分内容可能不完整。");if(!d.success)return K.error(`Error: ${d.error?.message??"Agent execution failed"}`),await f(1);return K.phase("completed","done","Headless run completed"),await f(0)}catch(B){if(!x){if(Z.hasOpenThinking()&&Q==="text")b.stderr.write(`
6
- `);K.error(`Error: ${SZ(B)}`)}return await f(1)}finally{_?.();try{await j?.dispose()}finally{R.close(),M.dispose()}}}async function z0(){if(!process.argv.slice(2).includes("--headless"))return!1;let{headless:D,"output-format":Q,"system-prompt":Z,"append-system-prompt":Y,"max-turns":j,..._}=Aq,M=AZ(xZ(process.argv)).scriptName("blade").strict(!1).options(_).middleware([Rq,xq,bq]);return IZ(M),await M.parse(),!0}export{hZ as runHeadless,z0 as handleHeadlessMode,JZ as HeadlessOptionsSchema};
@@ -1,2 +0,0 @@
1
- function c(b){return b!==void 0&&typeof b.pattern==="string"&&typeof b.search_path==="string"}function f(b){return b!==void 0&&b.kind==="edit"&&typeof b.matches_found==="number"}function g(b){return b==="readonly"}
2
- export{c as xc,f as yc,g as zc};
@@ -1 +0,0 @@
1
- import{Ld as a}from"./chunk-y9a1jwnv.js";import"./chunk-7ryqs453.js";import"./chunk-pnjftj8t.js";import"./chunk-nq1wqpsx.js";import"./chunk-95jjpdh9.js";import"./chunk-sexhm0r5.js";export{a as createChatServiceAsync};
@@ -1,10 +0,0 @@
1
- import{f as T,g as W,h as X,i as Y}from"./chunk-wz6atg87.js";import"./chunk-h34g9v9z.js";import"./chunk-1qj0qms6.js";import"./chunk-7a8k7ck4.js";import"./chunk-fw1fm9cn.js";import"./chunk-mxffhqe5.js";import"./chunk-ag0z1q2q.js";import"./chunk-00gwp388.js";import"./chunk-s1j86hhh.js";import"./chunk-pgy1mtgw.js";import"./chunk-16449n3m.js";import"./chunk-g0gqxn3c.js";import"./chunk-2sdbj0zz.js";import{Zc as R}from"./chunk-p01t6c78.js";import"./chunk-5knt529c.js";import{td as Q}from"./chunk-2gca6fvf.js";import"./chunk-v508x7cg.js";import"./chunk-d90tnjst.js";import"./chunk-y9a1jwnv.js";import"./chunk-dsxjgty6.js";import"./chunk-b9y9mc7f.js";import"./chunk-fjbptkh2.js";import"./chunk-3j6bsp1q.js";import"./chunk-t1z46fqz.js";import"./chunk-prqgpq92.js";import"./chunk-ysr3frmw.js";import"./chunk-d3gx05ph.js";import"./chunk-bx99mx3k.js";import"./chunk-3ctcv013.js";import"./chunk-1ep6bcpc.js";import"./chunk-c23bewtt.js";import"./chunk-87ge6dkk.js";import"./chunk-dvf4cfye.js";import"./chunk-7ryqs453.js";import"./chunk-pnjftj8t.js";import"./chunk-nq1wqpsx.js";import{_f as M}from"./chunk-fb80q06q.js";import"./chunk-0kqp5z4v.js";import"./chunk-jdms602t.js";import"./chunk-95jjpdh9.js";import"./chunk-sexhm0r5.js";import m from"chalk";import K from"open";var A=`
2
- ____ _ _
3
- | __ )| | __ _ __| | ___
4
- | _ \\| |/ _\` |/ _\` |/ _ \\
5
- | |_) | | (_| | (_| | __/
6
- |____/|_|\\__,_|\\__,_|\\___|
7
- `,C={command:"web",describe:"Start Blade server and open web interface",builder:T,handler:async(Z)=>{let H=W(Z);if(await Q(),!process.env.BLADE_SERVER_PASSWORD)console.log(m.yellow("[WARN] BLADE_SERVER_PASSWORD is not set; server is unsecured.")),console.log(m.gray(` Set this environment variable to enable Basic Auth.
8
- `));let F=await Y.listenAsync(H);if(console.log(m.cyan(A)),console.log(m.gray(` v${M()}
9
- `)),H.hostname==="0.0.0.0"){let q=`http://localhost:${F.port}`;console.log(m.blue.bold(" Local access: "),m.white(q));let x=X();for(let z of x)console.log(m.blue.bold(" Network access: "),m.white(`http://${z}:${F.port}`));K(q).catch(()=>{})}else{let q=F.url.toString();console.log(m.blue.bold(" Web interface: "),m.white(q)),K(q).catch(()=>{})}console.log(""),console.log(m.gray(` Press Ctrl+C to stop the server.
10
- `));let J,$=new Promise((q)=>{J=q}),b=R(async()=>{await F.stop(),J()});try{await $}finally{b(),await F.stop()}}};export{C as webCommand};