blade-code 0.10.205 → 0.10.206

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 (142) hide show
  1. package/dist/blade.js +2 -2
  2. package/dist/chunk-09kqfdpa.js +3 -0
  3. package/dist/{chunk-efjjkha8.js → chunk-0ef47wgr.js} +2 -2
  4. package/dist/chunk-1j39te3t.js +23 -0
  5. package/dist/{chunk-fdr4fcrf.js → chunk-1n4v80hy.js} +1 -1
  6. package/dist/{chunk-ynd1v33f.js → chunk-28n945me.js} +2 -2
  7. package/dist/{chunk-ys8gysg8.js → chunk-28tzj187.js} +1 -1
  8. package/dist/{chunk-qtwgm95z.js → chunk-3crwyd2r.js} +3 -3
  9. package/dist/{chunk-zfxcef0z.js → chunk-50vwafn5.js} +1 -1
  10. package/dist/chunk-514va7ce.js +2 -0
  11. package/dist/{chunk-kkzznz4w.js → chunk-53vh6vpt.js} +1 -1
  12. package/dist/chunk-5k8k56f2.js +731 -0
  13. package/dist/{chunk-515yj7mt.js → chunk-65wc1h38.js} +1 -1
  14. package/dist/{chunk-xbs91jd8.js → chunk-67wy9mm7.js} +2 -2
  15. package/dist/chunk-6p0hkf4f.js +1 -0
  16. package/dist/{chunk-qdbbke8f.js → chunk-6xzk4hsg.js} +1 -1
  17. package/dist/chunk-793wjhvz.js +332 -0
  18. package/dist/{chunk-rtwd35gd.js → chunk-826xegd8.js} +2 -2
  19. package/dist/chunk-867bpjzg.js +1 -0
  20. package/dist/{chunk-zj1g4nbq.js → chunk-870szc6v.js} +1 -1
  21. package/dist/chunk-983hqzat.js +1 -0
  22. package/dist/{chunk-0eajnhrj.js → chunk-9kj19a8t.js} +1 -1
  23. package/dist/{chunk-430b319j.js → chunk-9sf1t8gw.js} +1 -1
  24. package/dist/chunk-9tpzmy8v.js +4 -0
  25. package/dist/chunk-af0m5227.js +1 -0
  26. package/dist/{chunk-f8kjdxz7.js → chunk-asgmmaec.js} +2 -2
  27. package/dist/{chunk-vz88tqtd.js → chunk-av799ng5.js} +2 -2
  28. package/dist/{chunk-bwe49m6n.js → chunk-az3rehz9.js} +360 -360
  29. package/dist/{chunk-p0wyhp5a.js → chunk-dnpkf5mv.js} +2 -2
  30. package/dist/chunk-dpg006xj.js +1 -0
  31. package/dist/{chunk-xmymx75h.js → chunk-e0ft3vwg.js} +1 -1
  32. package/dist/chunk-e45r1a8r.js +25 -0
  33. package/dist/{chunk-g01mth5d.js → chunk-ebpg1srd.js} +2 -2
  34. package/dist/{chunk-4wx5sya5.js → chunk-ed2hdrwe.js} +1 -1
  35. package/dist/{chunk-7ajvrtb3.js → chunk-erhaedch.js} +1 -1
  36. package/dist/{chunk-kehgewqh.js → chunk-ewwrss2w.js} +1 -1
  37. package/dist/{chunk-kf9gj2gn.js → chunk-fc1gz532.js} +2 -2
  38. package/dist/{chunk-9jz1q7bk.js → chunk-fd0a8h55.js} +2 -2
  39. package/dist/{chunk-qp2qc4p2.js → chunk-fnmqxhv1.js} +2 -2
  40. package/dist/chunk-g7tphxme.js +6 -0
  41. package/dist/{chunk-eg3ms291.js → chunk-gmpsfkgg.js} +1 -1
  42. package/dist/chunk-gpnkxh4c.js +1 -0
  43. package/dist/{chunk-b8ast0cp.js → chunk-gz84aewr.js} +1 -1
  44. package/dist/{chunk-xxbxc31z.js → chunk-h4k69z1b.js} +1 -1
  45. package/dist/{chunk-17d4m89n.js → chunk-h6ahwwpa.js} +2 -2
  46. package/dist/chunk-hpge30p8.js +8 -0
  47. package/dist/{chunk-1cy4ab77.js → chunk-hv8nt7wj.js} +1 -1
  48. package/dist/chunk-mtvbm7xe.js +1 -0
  49. package/dist/chunk-mys9mmcp.js +1 -0
  50. package/dist/{chunk-wezr6wfq.js → chunk-n34qsnks.js} +1 -1
  51. package/dist/chunk-n5jzmwhy.js +25 -0
  52. package/dist/chunk-new78c3h.js +1 -0
  53. package/dist/{chunk-8pd1hp4r.js → chunk-nj6kpdte.js} +2 -2
  54. package/dist/chunk-nng1xbsm.js +10 -0
  55. package/dist/{chunk-xyypxrad.js → chunk-p2y1zqsb.js} +2 -2
  56. package/dist/chunk-p8vpvx07.js +12 -0
  57. package/dist/{chunk-w42j9p3t.js → chunk-pdna2qvv.js} +2 -2
  58. package/dist/{chunk-gn9er641.js → chunk-pga8gxtf.js} +1 -1
  59. package/dist/chunk-pt0y4zrg.js +14 -0
  60. package/dist/{chunk-5zmp7p0n.js → chunk-q6abav45.js} +51 -51
  61. package/dist/chunk-r4em0ha7.js +1 -0
  62. package/dist/chunk-rdzbd5vk.js +1 -0
  63. package/dist/chunk-sbfe9vh3.js +94 -0
  64. package/dist/chunk-sqk8cnej.js +44 -0
  65. package/dist/{chunk-5yyp6njq.js → chunk-t0gm0pn1.js} +1 -1
  66. package/dist/{chunk-egss0m1x.js → chunk-tsm8rhmd.js} +1 -1
  67. package/dist/chunk-tzvb0nd2.js +2 -0
  68. package/dist/{chunk-kvp523gt.js → chunk-v4cxk10d.js} +1 -1
  69. package/dist/{chunk-ak5xvsxr.js → chunk-v5vx6nz9.js} +1 -1
  70. package/dist/{chunk-qq5y7b2r.js → chunk-vx2g1faw.js} +1 -1
  71. package/dist/chunk-w6zat4v4.js +1 -0
  72. package/dist/chunk-wsd3rn0q.js +1 -0
  73. package/dist/{chunk-c51wwnh2.js → chunk-xcq0cehr.js} +5 -6
  74. package/dist/chunk-yjjxv7fn.js +352 -0
  75. package/dist/{chunk-6169xxb4.js → chunk-yzf2jpam.js} +2 -2
  76. package/dist/web/assets/{ChatView-BF6HUrBw.js → ChatView-lUD-61n0.js} +4 -4
  77. package/dist/web/assets/{CodeBlockHighlighter-C4CgCiRf.js → CodeBlockHighlighter--TbfcBxW.js} +1 -1
  78. package/dist/web/assets/FilePreview-R6OKQPf2.js +55 -0
  79. package/dist/web/assets/{KanbanBoard-DDXB-yq1.js → KanbanBoard-BHOKtiv5.js} +1 -1
  80. package/dist/web/assets/{MarkdownRenderer-DS7RznBE.js → MarkdownRenderer-DqxNq8pa.js} +3 -3
  81. package/dist/web/assets/{ScrollArea-BM9NzGZM.js → ScrollArea-Dhu0B-zB.js} +1 -1
  82. package/dist/web/assets/{SessionHistorySurface-DnRySeLE.js → SessionHistorySurface-aZvoj3ma.js} +1 -1
  83. package/dist/web/assets/{SettingsModal-D5YLUtIo.js → SettingsModal-C7QBnIqa.js} +1 -1
  84. package/dist/web/assets/{Sidebar-BZC6OkDJ.js → Sidebar-Bznnq91x.js} +1 -1
  85. package/dist/web/assets/{TaskSwitcher-WewOkw5m.js → TaskSwitcher-DJczhDRp.js} +1 -1
  86. package/dist/web/assets/{TerminalPanel-C5SGdRNr.js → TerminalPanel-Vk4p0V3p.js} +1 -1
  87. package/dist/web/assets/{archive-DkczUU08.js → archive-0hLYBKQf.js} +1 -1
  88. package/dist/web/assets/{arrow-left-9pBiQwu7.js → arrow-left-CXb6Gqf3.js} +1 -1
  89. package/dist/web/assets/{calendar-clock-BFnUlxrU.js → calendar-clock-DiaFI9Jk.js} +1 -1
  90. package/dist/web/assets/{chevron-right-yCVkAEcj.js → chevron-right-CcPXH37D.js} +1 -1
  91. package/dist/web/assets/{clock-3-CcoWoRQs.js → clock-3-D6VR6gJc.js} +1 -1
  92. package/dist/web/assets/{copy-HJF0oQBS.js → copy-C3eUAQgp.js} +1 -1
  93. package/dist/web/assets/{download-DSBCIqk3.js → download-DHvS9tI3.js} +1 -1
  94. package/dist/web/assets/{external-link-zIgEO0KB.js → external-link-BDVaEuqY.js} +1 -1
  95. package/dist/web/assets/{folder-BdRo64o3.js → folder-B80Ac6rr.js} +1 -1
  96. package/dist/web/assets/index-VwIiNjc8.css +1 -0
  97. package/dist/web/assets/{index-BVDkKudh.js → index-YqughEZk.js} +4 -4
  98. package/dist/web/assets/{message-square-plus-3klTXO0S.js → message-square-plus-D15quyPH.js} +1 -1
  99. package/dist/web/assets/{pause-B9Q5JWvH.js → pause-BjMlj6Bx.js} +1 -1
  100. package/dist/web/assets/{pencil-CbYIz1b1.js → pencil-BMoJvcB7.js} +1 -1
  101. package/dist/web/assets/{play-CZMTj43e.js → play-BHh4py3p.js} +1 -1
  102. package/dist/web/assets/{plus-Cc7I8fhb.js → plus-DeFz_gQq.js} +1 -1
  103. package/dist/web/assets/session-events-DCHBz9We.js +25 -0
  104. package/dist/web/assets/{settings-DSF3exX2.js → settings-CI8xbId2.js} +1 -1
  105. package/dist/web/assets/{team-qfeJHL9s.js → team-zZ803hH9.js} +1 -1
  106. package/dist/web/assets/{teamService-Bs9qBKI8.js → teamService-CgLBXgmv.js} +1 -1
  107. package/dist/web/assets/{terminal-DQLqe-Ed.js → terminal-1WxSJ47E.js} +1 -1
  108. package/dist/web/index.html +2 -2
  109. package/package.json +1 -1
  110. package/dist/chunk-18swytk4.js +0 -25
  111. package/dist/chunk-3297ghav.js +0 -1
  112. package/dist/chunk-33ck9ryb.js +0 -1
  113. package/dist/chunk-4fa11h6f.js +0 -94
  114. package/dist/chunk-535s1mm8.js +0 -1
  115. package/dist/chunk-57939tb3.js +0 -8
  116. package/dist/chunk-6v0cdqkw.js +0 -1
  117. package/dist/chunk-8kwj6px8.js +0 -1
  118. package/dist/chunk-a8z11yd2.js +0 -3
  119. package/dist/chunk-aatfjx15.js +0 -2
  120. package/dist/chunk-b2ek44t5.js +0 -12
  121. package/dist/chunk-b9d0ex8n.js +0 -4
  122. package/dist/chunk-ccgtbzrz.js +0 -14
  123. package/dist/chunk-jgxfhk9k.js +0 -733
  124. package/dist/chunk-jhpwwwjt.js +0 -1
  125. package/dist/chunk-jjj86dej.js +0 -1
  126. package/dist/chunk-kejvty9z.js +0 -23
  127. package/dist/chunk-mhe1zppc.js +0 -1
  128. package/dist/chunk-pb1q26gw.js +0 -181
  129. package/dist/chunk-pc5f77qh.js +0 -1
  130. package/dist/chunk-pkx6kfy6.js +0 -1
  131. package/dist/chunk-qjptyj18.js +0 -1
  132. package/dist/chunk-shgxzmdw.js +0 -1
  133. package/dist/chunk-thytjs86.js +0 -44
  134. package/dist/chunk-tm3789m3.js +0 -2
  135. package/dist/chunk-tnmcrvk2.js +0 -25
  136. package/dist/chunk-wejthch2.js +0 -1
  137. package/dist/chunk-xv6ejk2z.js +0 -353
  138. package/dist/chunk-yvgef7rp.js +0 -10
  139. package/dist/chunk-zj48897e.js +0 -6
  140. package/dist/web/assets/FilePreview-BS4PgFKb.js +0 -55
  141. package/dist/web/assets/index-CaCifsSK.css +0 -1
  142. package/dist/web/assets/session-events-NEjosinC.js +0 -31
@@ -1,2 +0,0 @@
1
- import{Di as H,Ei as I}from"./chunk-thytjs86.js";import{Mutex as J}from"async-mutex";class B extends Error{limit;resource="resident_runtimes";retryable=!0;constructor(b){super("Session runtime capacity is full");this.limit=b;this.name="SessionRuntimeCapacityError"}}class D extends Error{constructor(){super("Session runtime residency is closed");this.name="SessionRuntimeResidencyClosedError"}}class A extends Error{constructor(b){super(`Session runtime residency already owns key: ${b}`);this.name="SessionRuntimeResidencyConflictError"}}class K{maxResident;idleMs;now;residents=new Map;reservations=new Map;operations=new J;nextGeneration=1;closed=!1;constructor(b){if(!H(b.maxResident))throw Error("Invalid max resident Session Runtime limit");if(!I(b.idleMs))throw Error("Invalid Session Runtime idle timeout");this.maxResident=b.maxResident,this.idleMs=b.idleMs,this.now=b.now??Date.now}acquire(b){let j=this.residents.get(b);if(!j||j.poisoned)return;return j.pins++,j.lastUsedAt=this.now(),this.createLease(j)}owns(b,j){let q=this.residents.get(b);return Boolean(q&&(j===void 0||q.value===j))}async reserve(b,j){if(!b.trim())throw Error("Session runtime residency key must not be blank");return this.operations.runExclusive(async()=>{if(this.closed)throw new D;if(this.residents.has(b)||this.reservations.has(b))throw new A(b);while(this.retainedCount()>=this.maxResident){if(!j.allowEviction)throw new B(this.maxResident);let z=this.oldestEvictableWebResident();if(!z)throw new B(this.maxResident);await this.disposeResident(z,!0)}let q={generation:this.allocateGeneration(),surface:j.surface};return this.reservations.set(b,q),this.createReservation(b,q)})}async remove(b,j){return this.operations.runExclusive(async()=>{let q=this.residents.get(b);if(!q||j!==void 0&&q.value!==j)return!1;if(q.pins>0)return!1;return await this.disposeResident(q,!0),!0})}async forget(b,j){return this.operations.runExclusive(async()=>{let q=this.residents.get(b);if(!q||j!==void 0&&q.value!==j||q.pins>0)return!1;return this.residents.delete(b),!0})}async sweepIdle(){return this.operations.runExclusive(async()=>{if(this.closed)return 0;let b=0;while(!0){let j=this.oldestIdleWebResident();if(!j)return b;await this.disposeResident(j,!0),b++}})}async disposeAll(){await this.operations.runExclusive(async()=>{this.closed=!0,this.reservations.clear();let b;for(let j of[...this.residents.values()])try{await this.disposeResident(j,!1)}catch(q){b??=q}if(this.residents.clear(),b!==void 0)throw b})}getStats(){let b=0;for(let j of this.residents.values())if(j.pins>0)b++;return{resident:this.residents.size,reserved:this.reservations.size,pinned:b,maxResident:this.maxResident}}retainedCount(){return this.residents.size+this.reservations.size}allocateGeneration(){let b=this.nextGeneration;return this.nextGeneration=this.nextGeneration===Number.MAX_SAFE_INTEGER?1:this.nextGeneration+1,b}createReservation(b,j){let q=!1;return{commit:(z)=>{if(q)throw new A(b);if(z.key!==b||z.surface!==j.surface||this.reservations.get(b)!==j||this.closed)throw this.reservations.delete(b),q=!0,this.closed?new D:new A(b);this.reservations.delete(b);let G={...z,generation:j.generation,pins:1,lastUsedAt:this.now(),poisoned:!1};return this.residents.set(b,G),q=!0,this.createLease(G)},cancel:()=>{if(q)return;if(this.reservations.get(b)===j)this.reservations.delete(b);q=!0}}}createLease(b){let j=!1;return{value:b.value,release:()=>{if(j)return;j=!0;let q=this.residents.get(b.key);if(q!==b||q.generation!==b.generation)return;q.pins=Math.max(0,q.pins-1),q.lastUsedAt=this.now()}}}oldestEvictableWebResident(){return this.sortedWebResidents().find((b)=>this.canEvict(b))}oldestIdleWebResident(){let b=this.now();return this.sortedWebResidents().find((j)=>b-j.lastUsedAt>=this.idleMs&&this.canEvict(j))}sortedWebResidents(){return[...this.residents.values()].filter((b)=>b.surface==="web").sort((b,j)=>b.lastUsedAt-j.lastUsedAt||b.generation-j.generation)}canEvict(b){if(b.pins>0||b.poisoned)return!1;try{return b.canEvict()}catch{return!1}}async disposeResident(b,j){if(this.residents.get(b.key)!==b)return;this.residents.delete(b.key);try{await b.dispose()}catch(q){if(j&&!this.closed&&!this.residents.has(b.key))b.lastUsedAt=this.now(),b.poisoned=!0,this.residents.set(b.key,b);throw q}}}
2
- export{B as v,K as w};
@@ -1,12 +0,0 @@
1
- import{p as c,q as v,r as d,s as m,t as l,u as a}from"./chunk-b9d0ex8n.js";import{da as O,ka as S}from"./chunk-bwe49m6n.js";import"./chunk-g01mth5d.js";import"./chunk-tnmcrvk2.js";import"./chunk-kf9gj2gn.js";import{Zb as M,ic as E}from"./chunk-pb1q26gw.js";import"./chunk-fdr4fcrf.js";import{ie as f}from"./chunk-4fa11h6f.js";import"./chunk-egss0m1x.js";import{Ne as h}from"./chunk-xv6ejk2z.js";import"./chunk-efjjkha8.js";import{sf as I}from"./chunk-9jz1q7bk.js";import{uf as y,vf as R,wf as g}from"./chunk-rtwd35gd.js";import{xf as C}from"./chunk-8pd1hp4r.js";import"./chunk-p0wyhp5a.js";import{Uf as w}from"./chunk-18swytk4.js";import"./chunk-5yyp6njq.js";import"./chunk-v508x7cg.js";import"./chunk-57939tb3.js";import"./chunk-ynd1v33f.js";import"./chunk-w42j9p3t.js";import"./chunk-zfxcef0z.js";import"./chunk-xyypxrad.js";import"./chunk-jgxfhk9k.js";import"./chunk-kehgewqh.js";import"./chunk-kkzznz4w.js";import"./chunk-1cy4ab77.js";import"./chunk-7ajvrtb3.js";import"./chunk-c51wwnh2.js";import"./chunk-ys8gysg8.js";import{Fh as A}from"./chunk-thytjs86.js";import"./chunk-tm3789m3.js";import{cj as P}from"./chunk-qdbbke8f.js";import"./chunk-wezr6wfq.js";import"./chunk-a8z11yd2.js";import"./chunk-qtwgm95z.js";import"./chunk-0eajnhrj.js";import"./chunk-6169xxb4.js";import"./chunk-f8kjdxz7.js";import"./chunk-4wx5sya5.js";import"./chunk-eg3ms291.js";import s from"yargs";import{hideBin as e}from"yargs/helpers";var i=new Set(Object.values(A));function t(j){if(j&&i.has(j))return j;return}function z(j){if(j.options.outputFormat==="json")j.io.stdout.write(`${JSON.stringify({response:j.response,...j.structuredOutput?{structured_output:j.structuredOutput,output_schema_digest:j.structuredOutputSchemaDigest}:{},input:j.requestInput,model:j.options.model,timestamp:new Date().toISOString()},null,2)}
2
- `);else if(j.options.outputFormat==="stream-json")j.io.stdout.write(`${JSON.stringify(j.structuredOutput?{type:"structured_output",output:j.structuredOutput,schema_digest:j.structuredOutputSchemaDigest}:{type:"response",content:j.response})}
3
- `);else j.io.stdout.write(`${j.response}
4
- `)}function n(j){return j.command("* [message]","Print response and exit (useful for pipes)",(B)=>B.positional("message",{describe:"Message to process",type:"string"}).option("p",{alias:"print",describe:"Print response and exit (useful for pipes)",type:"boolean"}).option("output-format",{describe:'Output format: "text", "json", "stream-json"',type:"string",default:"text"}).option("include-partial-messages",{describe:"Include partial message chunks as they arrive",type:"boolean"}).option("input-format",{describe:'Input format: "text", "stream-json"',type:"string",default:"text"}).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("model",{describe:"Model for the current session",type:"string"}).option("append-system-prompt",{describe:"Append a system prompt to the default system prompt",type:"string"}).option("system-prompt",{describe:"Replace the default system prompt",type:"string"}).option("max-turns",{alias:["maxTurns"],describe:"Maximum conversation turns (-1: unlimited, N>0: limit to N turns)",type:"number"}),async(B)=>{if(!B.p)return;let q=await o(B);process.exit(q)})}async function o(j,B=process){let q;try{await c();let D=j.forkSession!==!0&&(j.continue===!0||typeof j.resume==="string"&&j.resume.length>0)?await d({message:j.message,_:j._}):await v({message:j.message,_:j._,defaultMessage:"Hello"}),K=D===void 0,T=K?{mode:"agent",content:""}:await m(D);if(T.mode==="output"){if(T.content)B.stdout.write(`${T.content}
5
- `);return T.exitCode??0}let Q=T.content,W=await l(j),X=Q.trimStart().startsWith("!")?Q.trimStart().slice(1).trim():void 0;if(X!==void 0&&W)throw Error("Output schemas cannot be combined with user shell commands");let{sessionId:J,messages:r,metadata:G}=await a({sessionId:j.sessionId,continue:j.continue,resume:j.resume,forkSession:j.forkSession,fallbackSessionPrefix:"print"}),Y=G?.projectPath??P(),b=t(j.permissionMode)??G?.permissionMode??w()?.permissionMode??"default";await f.setSessionPermissionMode(J,Y,b);let N=await E.cancelPendingNonInteractive(Y,J)?await f.loadSessionModelContext(J,Y):r;q=await O.create({sessionId:J,workspaceRoot:Y,modelId:j.model,permissionMode:b,mcpConfig:j.mcpConfig,strictMcpConfig:j.strictMcpConfig,agents:j.agents?C(j.agents):void 0,...N.length>0?{sessionStart:{isResume:!0,resumeSessionId:J}}:{}});let Z=K&&q.getPendingSteeringCount()>0,k=K&&!Z?await q.getGoal():null,L=k?.status==="active"||k?.status==="verifying",U=q.getTurnRecoveryAssessment?.()??{state:"none"};if(K&&!Z&&!L&&U.state==="requires_attention")throw B.stderr.write(`[turn-recovery:${U.state}] ${U.turnId}
6
- `),Error("Turn recovery requires explicit user attention before continuation");let _=K&&!Z&&!L?await q.getRecoveredFinalResponse():void 0;if(K&&!Z&&!L){if(!_)throw Error("No unfinished turn or active goal to resume");let H=U;if(H.state!=="none")B.stderr.write(`[turn-recovery:${H.state}] ${H.turnId}
7
- `);return z({io:B,options:j,response:_.content,requestInput:Q,structuredOutput:_.structuredOutput,structuredOutputSchemaDigest:_.structuredOutputSchemaDigest}),0}if(X!==void 0){let H=await q.executeUserShellCommand(X);if(j.outputFormat==="json")B.stdout.write(`${JSON.stringify(H,null,2)}
8
- `);else if(j.outputFormat==="stream-json")B.stdout.write(`${JSON.stringify({type:"user_shell_completed",executionId:H.executionId,record:H.record})}
9
- `);else B.stdout.write(`${h(H.record)}
10
- `);return H.record.status==="completed"?0:H.record.status==="aborted"?130:H.record.exitCode??1}let x=await S.createWithRuntime(q,{sessionId:J,systemPrompt:j.systemPrompt,appendSystemPrompt:j.appendSystemPrompt,maxTurns:j.maxTurns,modelId:j.model,permissionMode:b,toolWhitelist:j.allowedTools,toolBlacklist:j.disallowedTools,mcpConfig:j.mcpConfig,strictMcpConfig:j.strictMcpConfig}),F={messages:[...N],userId:"cli-user",sessionId:J,workspaceRoot:Y,permissionMode:b},V=await M(W||K?x.chatStream(Q,F,{...W?{outputSchema:W}:{},pendingInputOnly:Z,goalContinuationOnly:L}):x.chatStream(Q,F),(H)=>{if(H.kind!=="turn_recovery")return;B.stderr.write(`[turn-recovery:${H.assessment.state}] ${H.assessment.turnId}
11
- `)});if(V.metadata?.recoveryAttention)throw Error("Turn recovery requires explicit user attention before continuation");if(!V.success)throw Error(V.error?.message??"Agent execution failed");let u=V.finalMessage||"",p=V.metadata?.structuredOutput;return z({io:B,options:j,response:u,requestInput:Q,structuredOutput:p,structuredOutputSchemaDigest:V.metadata?.structuredOutputSchemaDigest}),0}catch($){return B.stderr.write(`Error: ${$ instanceof Error?$.message:"未知错误"}
12
- `),1}finally{await q?.dispose()}}async function fj(){if(process.argv.slice(2).findIndex((q)=>q==="--print"||q==="-p")===-1)return!1;try{let{print:q,"output-format":$,"include-partial-messages":D,"input-format":K,"system-prompt":T,"append-system-prompt":Q,"max-turns":W,...X}=I,J=s(e(process.argv)).scriptName("blade").strict(!1).options(X).middleware([R,y,g]);return n(J),await J.parse(),!0}catch(q){console.error(`Print mode error: ${q instanceof Error?q.message:"未知错误"}`),process.exit(1)}}export{o as runPrint,fj as handlePrintMode};
@@ -1,4 +0,0 @@
1
- import{Aa as F,Ca as L}from"./chunk-bwe49m6n.js";import{_d as $,ae as B,ie as Q}from"./chunk-4fa11h6f.js";import{Yg as y}from"./chunk-jgxfhk9k.js";import{cj as V}from"./chunk-qdbbke8f.js";async function j(){await y(V())}async function I(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 K of z)G.push(K);return Buffer.concat(G).toString("utf-8").trim()}if(b.defaultMessage!==void 0)return b.defaultMessage;throw Error("No input provided")}async function M(b){let q=b.message||b._?.[0];if(typeof q==="string"&&q.trim())return q;let z=b.stdin??process.stdin;if(z.isTTY)return;let G=[];for await(let Z of z)G.push(Buffer.isBuffer(Z)?Z:Buffer.from(Z));return Buffer.concat(G).toString("utf-8").trim()||void 0}async function R(b){if(!F(b))return{mode:"agent",content:b};let q=await L(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:K}=z;return{mode:"agent",content:K?`Please use the "${G}" skill to help me with: ${K}`:`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 D,stat as H}from"node:fs/promises";import J from"node:path";function x(b,q){let z;try{z=JSON.parse(b)}catch(G){throw Error(`Invalid JSON output schema from ${q}`,{cause:G})}return B(z).schema}async function _(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 x(b.jsonSchema,"--json-schema");if(b.outputSchema===void 0)return;let q=J.resolve(b.outputSchema),z=await H(q);if(!z.isFile())throw Error(`Output schema path is not a regular file: ${q}`);if(z.size>$)throw Error(`Output schema exceeds ${$} bytes: ${q}`);return x(await D(q,"utf8"),q)}function N(b){if(!(b instanceof Error))return!1;return b.message.includes("未找到会话")||b.message.includes("ENOENT")||b.message.includes("no such file")}async function W(b){try{return await Q.loadSessionModelContext(b,V())}catch(q){if(N(q))return null;throw q}}async function C(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(),K=await Q.forkSession(b.resume,{newSessionId:b.sessionId,sourceProjectPath:G,targetProjectPath:G});return{...K,messages:await Q.loadSessionModelContext(K.sessionId,G)}}let[q,z]=await Promise.all([Q.loadSessionModelContext(b.resume),Q.findSessionMetadata(b.resume)]);return{sessionId:b.resume,messages:q,metadata:z}}if(b.continue){let q=b.forkSession?await Q.listSessions({cwd:V()}):await Q.listSessions();if(q.length>0){let z=q[0].sessionId;if(b.forkSession){let G=V(),K=await Q.forkSession(z,{newSessionId:b.sessionId,sourceProjectPath:G,targetProjectPath:G});return{...K,messages:await Q.loadSessionModelContext(K.sessionId,G)}}return{sessionId:z,messages:await Q.loadSessionModelContext(z),metadata:q[0]}}if(b.forkSession)throw Error("Cannot fork: no sessions are available to continue")}if(b.sessionId){let q=await W(b.sessionId);return{sessionId:b.sessionId,messages:q??[],...q?{metadata:await Q.findSessionMetadata(b.sessionId,V())}:{}}}return{sessionId:`${b.fallbackSessionPrefix}-${Date.now()}`,messages:[]}}
4
- export{j as p,I as q,M as r,R as s,_ as t,C as u};