blade-code 0.11.5 → 0.11.6

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 (50) hide show
  1. package/dist/blade.js +2 -2
  2. package/dist/{chunk-tj7ytet5.js → chunk-0vw2xj0h.js} +1 -1
  3. package/dist/chunk-2s1gmqh4.js +1 -0
  4. package/dist/{chunk-j08fc7cy.js → chunk-5vh8zyjz.js} +1 -1
  5. package/dist/{chunk-amzpb8s5.js → chunk-6h1x1m4f.js} +1 -1
  6. package/dist/{chunk-v7pw7a8q.js → chunk-6jjpj5ge.js} +1 -1
  7. package/dist/{chunk-gmparnqt.js → chunk-6sk6chsm.js} +1 -1
  8. package/dist/{chunk-g4k4tnsq.js → chunk-87bd1w02.js} +1 -1
  9. package/dist/{chunk-fj06d4kk.js → chunk-8d1vekke.js} +1 -1
  10. package/dist/{chunk-c08qbh8h.js → chunk-8yh4mn8a.js} +1 -1
  11. package/dist/{chunk-nefvj18m.js → chunk-a1y938pg.js} +1 -1
  12. package/dist/{chunk-qk7n9j5k.js → chunk-acxyw1ej.js} +1 -1
  13. package/dist/{chunk-v63e33me.js → chunk-aq7e74mn.js} +2 -2
  14. package/dist/{chunk-14mtvq2m.js → chunk-avrnqtca.js} +1 -1
  15. package/dist/chunk-bzwxh6nq.js +2 -0
  16. package/dist/{chunk-2x63c1gx.js → chunk-cfxs7jdk.js} +1 -1
  17. package/dist/{chunk-6eznxwsv.js → chunk-fprmcxd6.js} +1 -1
  18. package/dist/{chunk-6wzwkjep.js → chunk-ftk0ytf8.js} +1 -1
  19. package/dist/{chunk-5j824kxz.js → chunk-hxwzdkwp.js} +1 -1
  20. package/dist/{chunk-ccpejbed.js → chunk-mhv4q5sg.js} +1 -1
  21. package/dist/{chunk-yscyr8zw.js → chunk-n32pbwyk.js} +410 -405
  22. package/dist/{chunk-4cywnksk.js → chunk-nh301gpr.js} +1 -1
  23. package/dist/{chunk-0bzhkqpe.js → chunk-nneh4gkw.js} +1 -1
  24. package/dist/{chunk-27cw0k2s.js → chunk-nznd7549.js} +1 -1
  25. package/dist/chunk-p9dvggw1.js +1 -0
  26. package/dist/{chunk-wr5qr81z.js → chunk-qexnx2v2.js} +1 -1
  27. package/dist/{chunk-mjqwnekv.js → chunk-qfp7emtk.js} +1 -1
  28. package/dist/{chunk-3054z3md.js → chunk-rgxknntk.js} +1 -1
  29. package/dist/{chunk-nmbgg7j5.js → chunk-s2ner5gp.js} +1 -1
  30. package/dist/{chunk-xcy0tfmt.js → chunk-sb12h5yv.js} +1 -1
  31. package/dist/{chunk-0ykg98p7.js → chunk-t39n33ek.js} +1 -1
  32. package/dist/{chunk-eefqxc4t.js → chunk-vgkcck5q.js} +1 -1
  33. package/dist/{chunk-n39gsnzc.js → chunk-vnxj21sa.js} +1 -1
  34. package/dist/{chunk-87bak5n5.js → chunk-vp4rdvvw.js} +1 -1
  35. package/dist/{chunk-03rdr8mr.js → chunk-xmp1ve8a.js} +1 -1
  36. package/dist/{chunk-cmk9vr5m.js → chunk-y7zh1sq6.js} +1 -1
  37. package/dist/{chunk-n0v7ce3r.js → chunk-yg81xx37.js} +1 -1
  38. package/dist/{chunk-39pjywan.js → chunk-yh28byeh.js} +1 -1
  39. package/dist/{chunk-gpj33m14.js → chunk-zzacj0n9.js} +1 -1
  40. package/package.json +2 -2
  41. package/vendor/ripgrep/README.md +6 -10
  42. package/vendor/ripgrep/darwin-arm64/rg +0 -0
  43. package/vendor/ripgrep/darwin-x64/rg +0 -0
  44. package/vendor/ripgrep/linux-arm64/rg +0 -0
  45. package/vendor/ripgrep/linux-x64/rg +0 -0
  46. package/vendor/ripgrep/win32-x64/rg.exe +0 -0
  47. package/dist/chunk-8r6xncb3.js +0 -1
  48. package/dist/chunk-cc9vbgqc.js +0 -2
  49. package/dist/chunk-xez8apfk.js +0 -1
  50. package/vendor/ripgrep/.gitignore +0 -12
@@ -1,4 +1,4 @@
1
- import{w as QH,x as YH,z as a}from"./chunk-g4k4tnsq.js";import{A as uz,B as gz,C as cz,D as S}from"./chunk-6eznxwsv.js";import{E as JH,F as Rz,G as Sz,H as Mz,I as Iz,J as hz}from"./chunk-0bzhkqpe.js";import{$ as qz,Ea as yz,Fa as kz,Ga as Cz,Ha as fz,Q as R,_ as Ez,ha as Tz,ka as Pz,la as xz,oa as bz}from"./chunk-yscyr8zw.js";import"./chunk-nad5spvc.js";import{Va as HH}from"./chunk-wr5qr81z.js";import{$a as i,Xa as Oz,cb as r}from"./chunk-whxkwaz1.js";import{Rb as Nz,bc as Az,mc as l}from"./chunk-n39gsnzc.js";import{xc as m}from"./chunk-9qxch6sy.js";import{$d as Fz,Hd as _z,Rd as I,Sd as d,Td as Vz,Yd as Dz,ae as Kz,ce as M,fe as jz,ke as wz,ne as K}from"./chunk-v7pw7a8q.js";import"./chunk-skktstg8.js";import{Le as Uz,Se as n,Te as Gz}from"./chunk-s14zayxp.js";import"./chunk-b5cz00mt.js";import{Ef as ZH}from"./chunk-amzpb8s5.js";import"./chunk-crv3sghv.js";import{Zf as sz,_f as tz}from"./chunk-qk7n9j5k.js";import{fg as zz}from"./chunk-x6k5ye1z.js";import"./chunk-v508x7cg.js";import{kg as Bz}from"./chunk-1g7c3f82.js";import{sg as p}from"./chunk-3v9epq9s.js";import"./chunk-eexs73bz.js";import{xg as ez}from"./chunk-pm163dfm.js";import"./chunk-2x63c1gx.js";import"./chunk-nefvj18m.js";import"./chunk-kehgewqh.js";import"./chunk-kkzznz4w.js";import{sh as zH}from"./chunk-1cy4ab77.js";import"./chunk-7ajvrtb3.js";import"./chunk-c08qbh8h.js";import"./chunk-ys8gysg8.js";import{Ai as oz,xi as nz}from"./chunk-6wzwkjep.js";import{Zi as e}from"./chunk-b22ab7yw.js";import"./chunk-amabfzc8.js";import{Aj as v,wj as g,xj as Wz,zj as c}from"./chunk-m2x6pb4f.js";import{Ej as h}from"./chunk-saz6mwpq.js";import"./chunk-xhwdac1j.js";import{Rj as rz,Uj as az}from"./chunk-0eajnhrj.js";import"./chunk-cc9vbgqc.js";import"./chunk-asgmmaec.js";import{dk as Lz,ek as lz,ik as Hz,mk as Jz,nk as iz,ok as Qz}from"./chunk-ed2hdrwe.js";import"./chunk-gmpsfkgg.js";import{Readable as NH,Writable as AH}from"node:stream";import*as f from"@agentclientprotocol/sdk";import o from"node:path";import{PROTOCOL_VERSION as DH,RequestError as C}from"@agentclientprotocol/sdk";import{RequestError as vz}from"@agentclientprotocol/sdk";import{nanoid as u}from"nanoid";var G=h("Agent");function P(z){return Object.freeze({kind:"local",hostStateRoot:z,executionRoot:z,hostResourceRoot:z})}function Xz(z){if(!z)return{};return Object.fromEntries(z.map((H)=>[H.name,H.value]))}function LH(z){if("command"in z)return{type:"stdio",command:z.command,args:z.args,env:Xz(z.env)};if("url"in z)return{type:z.type,url:z.url,headers:Xz("headers"in z?z.headers:void 0)};return null}function WH(z){let H={};for(let J of z){let Y=LH(J);if(Y)H[J.name]=Y}return H}function pz(z){if(typeof z==="string")return z?[{type:"text",text:z}]:[];return z.flatMap((H)=>{if(H.type==="text")return H.text?[{type:"text",text:H.text}]:[];let J=H.image_url.url,Y=/^data:([^;,]+);base64,(.+)$/s.exec(J);if(!Y)return[{type:"text",text:"[Image]"}];return[{type:"image",mimeType:Y[1]??"image/png",data:Y[2]??""}]})}function BH(z){let H=Gz(z.metadata);return H?[{type:"text",text:n(H)}]:pz(z.content)}function _H(z){return[`Status: ${z.status}`,`Exit code: ${z.exitCode??"null"}`,`Duration: ${(z.durationMs/1000).toFixed(3)} seconds`].join(`
1
+ import{w as QH,x as YH,z as a}from"./chunk-87bd1w02.js";import{A as uz,B as gz,C as cz,D as S}from"./chunk-fprmcxd6.js";import{E as JH,F as Rz,G as Sz,H as Mz,I as Iz,J as hz}from"./chunk-nneh4gkw.js";import{$ as qz,Ea as yz,Fa as kz,Ga as Cz,Ha as fz,Q as R,_ as Ez,ha as Tz,ka as Pz,la as xz,oa as bz}from"./chunk-n32pbwyk.js";import"./chunk-nad5spvc.js";import{Va as HH}from"./chunk-qexnx2v2.js";import{$a as i,Xa as Oz,cb as r}from"./chunk-whxkwaz1.js";import{Rb as Nz,bc as Az,mc as l}from"./chunk-vnxj21sa.js";import{xc as m}from"./chunk-9qxch6sy.js";import{$d as Fz,Hd as _z,Rd as I,Sd as d,Td as Vz,Yd as Dz,ae as Kz,ce as M,fe as jz,ke as wz,ne as K}from"./chunk-6jjpj5ge.js";import"./chunk-skktstg8.js";import{Le as Uz,Se as n,Te as Gz}from"./chunk-s14zayxp.js";import"./chunk-b5cz00mt.js";import{Ef as ZH}from"./chunk-6h1x1m4f.js";import"./chunk-crv3sghv.js";import{Zf as sz,_f as tz}from"./chunk-acxyw1ej.js";import{fg as zz}from"./chunk-x6k5ye1z.js";import"./chunk-v508x7cg.js";import{kg as Bz}from"./chunk-1g7c3f82.js";import{sg as p}from"./chunk-3v9epq9s.js";import"./chunk-eexs73bz.js";import{xg as ez}from"./chunk-pm163dfm.js";import"./chunk-cfxs7jdk.js";import"./chunk-a1y938pg.js";import"./chunk-kehgewqh.js";import"./chunk-kkzznz4w.js";import{sh as zH}from"./chunk-1cy4ab77.js";import"./chunk-7ajvrtb3.js";import"./chunk-8yh4mn8a.js";import"./chunk-ys8gysg8.js";import{Ai as oz,xi as nz}from"./chunk-ftk0ytf8.js";import{Zi as e}from"./chunk-b22ab7yw.js";import"./chunk-amabfzc8.js";import{Aj as v,wj as g,xj as Wz,zj as c}from"./chunk-m2x6pb4f.js";import{Ej as h}from"./chunk-saz6mwpq.js";import"./chunk-xhwdac1j.js";import{Rj as rz,Uj as az}from"./chunk-0eajnhrj.js";import"./chunk-bzwxh6nq.js";import"./chunk-asgmmaec.js";import{dk as Lz,ek as lz,ik as Hz,mk as Jz,nk as iz,ok as Qz}from"./chunk-ed2hdrwe.js";import"./chunk-gmpsfkgg.js";import{Readable as NH,Writable as AH}from"node:stream";import*as f from"@agentclientprotocol/sdk";import o from"node:path";import{PROTOCOL_VERSION as DH,RequestError as C}from"@agentclientprotocol/sdk";import{RequestError as vz}from"@agentclientprotocol/sdk";import{nanoid as u}from"nanoid";var G=h("Agent");function P(z){return Object.freeze({kind:"local",hostStateRoot:z,executionRoot:z,hostResourceRoot:z})}function Xz(z){if(!z)return{};return Object.fromEntries(z.map((H)=>[H.name,H.value]))}function LH(z){if("command"in z)return{type:"stdio",command:z.command,args:z.args,env:Xz(z.env)};if("url"in z)return{type:z.type,url:z.url,headers:Xz("headers"in z?z.headers:void 0)};return null}function WH(z){let H={};for(let J of z){let Y=LH(J);if(Y)H[J.name]=Y}return H}function pz(z){if(typeof z==="string")return z?[{type:"text",text:z}]:[];return z.flatMap((H)=>{if(H.type==="text")return H.text?[{type:"text",text:H.text}]:[];let J=H.image_url.url,Y=/^data:([^;,]+);base64,(.+)$/s.exec(J);if(!Y)return[{type:"text",text:"[Image]"}];return[{type:"image",mimeType:Y[1]??"image/png",data:Y[2]??""}]})}function BH(z){let H=Gz(z.metadata);return H?[{type:"text",text:n(H)}]:pz(z.content)}function _H(z){return[`Status: ${z.status}`,`Exit code: ${z.exitCode??"null"}`,`Duration: ${(z.durationMs/1000).toFixed(3)} seconds`].join(`
2
2
  `)}function UH(z){if(!Bz(z)||z.reason!=="queue_full"||z.resource!=="pending_count"&&z.resource!=="pending_bytes")return;return{...I("capacity"),resource:z.resource}}function GH(z){if(!(z instanceof vz)||!z.data||typeof z.data!=="object")return;let H=z.data;if(!Vz(H.taskFailure)||H.toolExecutionStarted!==!1||!Number.isInteger(H.toolCallsCount)||H.toolCallsCount<0||H.outputStarted!==!1)return;return{taskFailure:H.taskFailure,toolExecutionStarted:H.toolExecutionStarted,toolCallsCount:H.toolCallsCount,outputStarted:H.outputStarted}}function VH(z){return{version:z.version,pending:z.pending,mutable:z.mutable,locked:z.locked,internal:z.internal}}class x{id;roots;connection;clientCapabilities;options;agent=null;runtime=null;pendingPrompt=null;pendingPromptCompletion=null;pendingUserShell=null;pendingUserShellCompletion=null;pendingSideConversation=null;pendingSideConversationCompletion=null;pendingResumeRequested=!1;pendingResumeAttempt=0;projectedPendingResumeInputIds=new Set;pendingResumeRecoveryStartedAt=0;pendingResumeInFlight=!1;pendingResumeScheduled=!1;pendingResumeGeneration=0;pendingResumeTimer=null;pendingResumeCompletion=null;pendingResumeNextDelayMs=null;availableCommandsTimer=null;taskStatusUnsubscribe;lastTurnActivityGeneration;lastTurnActivityRevision=-1;destroyed=!1;destroyFinished=!1;destroyPromise;serviceRegistration;messages;contextMessages;mode;updateEgress;constructor(z,H,J,Y,X={}){this.id=z;this.roots=H;this.connection=J;this.clientCapabilities=Y;this.options=X;this.messages=[...X.initialMessages??[]],this.contextMessages=[...this.messages],this.mode=this.mapPermissionModeToMode(X.permissionMode),this.updateEgress=new hz({maxPendingItems:Rz,maxPendingBytes:Sz,writeTimeoutMs:Mz,signal:J.signal,sizeOf:(L)=>Buffer.byteLength(JSON.stringify(L)),write:async(L)=>{await J.sessionUpdate(L)},onFailure:(L)=>this.handleUpdateEgressFailure(L)})}async refreshPersistedMessages(){let[z,H]=await Promise.all([this.loadPersistedMessages(),this.loadPersistedModelContext()]);if(z.length>0)this.messages=z;if(H.length>0)this.contextMessages=H}async loadModelContextOr(z){let H=await this.loadPersistedModelContext();return H.length>0?H:[...z]}loadPersistedMessages(){return this.roots.kind==="acp-remote"?K.loadRemoteSession(this.id,this.roots.hostStateRoot,this.roots.descriptor):K.loadSession(this.id,this.roots.hostStateRoot)}loadPersistedModelContext(){return this.roots.kind==="acp-remote"?K.loadRemoteSessionModelContext(this.id,this.roots.hostStateRoot,this.roots.descriptor):K.loadSessionModelContext(this.id,this.roots.hostStateRoot)}async persistMetadataUpdate(z,H=z){if(this.roots.kind==="acp-remote"){await K.updateRemoteSessionMetadata(this.id,this.roots.hostStateRoot,this.roots.descriptor,z);return}try{await K.updateSessionMetadata(this.id,this.roots.hostStateRoot,z)}catch(J){if(!(J instanceof wz)&&J.code!=="ENOENT")throw J;await K.createSessionMetadata(this.id,this.roots.hostStateRoot,{taskStatus:"completed",...H})}}async persistPermissionMode(z){if(this.roots.kind==="acp-remote"){await K.updateRemoteSessionMetadata(this.id,this.roots.hostStateRoot,this.roots.descriptor,{permissionMode:z});return}await K.setSessionPermissionMode(this.id,this.roots.hostStateRoot,z)}mapPermissionModeToMode(z){switch(z){case"yolo":return"yolo";case"autoEdit":return"auto-edit";case"plan":return"plan";case"default":default:return"default"}}createAgent(){if(!this.runtime)throw Error("Session runtime is unavailable");return bz.createWithRuntime(this.runtime,{sessionId:this.id,...this.options.taskWorktree?{toolBlacklist:["EnterWorktree","ExitWorktree"]}:{}})}async initialize(){G.debug(`[AcpSession ${this.id}] Initializing...`),await this.persistPermissionMode(this.mapModeToPermissionMode()??"default");let z=R.initializeSession(this.connection,this.id,this.clientCapabilities,this.roots.executionRoot,async($)=>{await this.sendUpdateAndWait($)},this.roots.kind==="acp-remote"?this.roots.profile:void 0);if(z)this.serviceRegistration=z;if(G.debug(`[AcpSession ${this.id}] ACP service context initialized`),this.roots.kind==="local"?await l.resolvePendingWithHandler(this.roots.hostStateRoot,this.id,{requestConfirmation:($)=>this.requestPermission($)}):!1)await this.refreshPersistedMessages();else if((this.options.initialMessages?.length??0)>0)this.contextMessages=await this.loadModelContextOr(this.options.initialMessages??[]);let J=this.options.mcpServers?WH(this.options.mcpServers):void 0,Y=R.getTerminalService(this.id),X=this.roots.kind==="acp-remote"?{kind:"acp-remote",executionRoot:this.roots.executionRoot,resourceRoot:this.roots.hostResourceRoot,readTextFile:this.clientCapabilities?.fs?.readTextFile===!0,writeTextFile:this.clientCapabilities?.fs?.writeTextFile===!0,terminal:this.clientCapabilities?.terminal===!0,descriptor:this.roots.descriptor}:void 0;if(this.runtime=await Tz.create({sessionId:this.id,workspaceRoot:this.roots.hostStateRoot,...X?{workspace:X}:{},permissionMode:this.mapModeToPermissionMode(),...J?{mcpServers:J}:{},...this.options.taskWorktree?{taskWorktree:this.options.taskWorktree}:{},...this.options.taskIsolation?{taskIsolation:this.options.taskIsolation}:{},userShellExecutor:{execute:async($,_)=>{let U=await Y.execute($,{cwd:_.cwd,env:_.env,timeout:_.timeoutMs,signal:_.signal,allowLocalFallback:!1,onOutput:(V)=>_.onOutput?.("stdout",V)});return{exitCode:U.exitCode,stdout:U.stdout,stderr:U.stderr,...U.error?{error:U.error}:{},timedOut:U.failureKind==="timeout",aborted:U.failureKind==="aborted"}}},...(this.options.initialMessages?.length??0)>0?{sessionStart:{isResume:!0,resumeSessionId:this.id}}:{}}),this.roots.kind==="local"?await S.recoverInterrupted(this.roots.hostStateRoot,this.id,this.runtime):!1)await this.refreshPersistedMessages();if(this.agent=await this.createAgent(),this.roots.kind==="local")await kz(this.roots.hostStateRoot);G.debug(`[AcpSession ${this.id}] Agent created successfully`),this.taskStatusUnsubscribe?.(),this.taskStatusUnsubscribe=Nz.subscribe(($)=>{if($.sessionId!==this.id||$.projectPath!==this.roots.hostStateRoot)return;if($.type==="subagent.completion.queued"){this.sendUpdate({sessionUpdate:"session_info_update",updatedAt:new Date().toISOString(),_meta:{"blade/backgroundSubagentCompletion":$.properties}}),this.requestPendingResume();return}if($.type==="follow_up.queue.changed"){let _=i.safeParse($.properties.queue);if(_.success)this.sendFollowUpQueueSnapshot(_.data);return}if($.type==="provider.recovery"){let _=p.safeParse($.properties.recovery);if(!_.success)return;this.sendProviderRecoveryProjection(_.data);return}if($.type==="turn.activity"){let _=r.safeParse($.properties.activity);if(!_.success)return;this.sendTurnActivityProjection(_.data);return}if($.type==="task.delivery"){if(!$.properties.taskDelivery||typeof $.properties.taskDelivery!=="object")return;this.sendUpdate({sessionUpdate:"session_info_update",updatedAt:typeof $.properties.updatedAt==="string"?$.properties.updatedAt:new Date().toISOString(),_meta:{"blade/taskDelivery":$.properties.taskDelivery,...$.properties.taskWorktreeRemoved===!0?{"blade/taskWorktreeRemoved":!0}:{}}});return}if($.type.startsWith("team.")){let{teamName:_,messageId:U,content:V}=$.properties,T=$.properties.metadata;if($.type==="team.message.received"&&typeof _==="string"&&typeof U==="string"&&typeof V==="string"&&qz(T,{messageId:U,teamName:_}))(async()=>{let E=await this.runtime?.enqueueSteering(V,{allowBeforeTurn:!0,messageId:U,origin:"team_message",metadata:T});if(!E?.accepted)return;if(E.queue)this.sendFollowUpQueueSnapshot(E.queue);if(await new Ez(_,Lz()).markDelivered([U]),E.delivery==="next_turn")this.requestPendingResume()})().catch((E)=>{G.warn(`[AcpSession ${this.id}] Failed to deliver teammate message`,E)});this.sendUpdate({sessionUpdate:"session_info_update",updatedAt:new Date().toISOString(),_meta:{"blade/teamEvent":{type:$.type,...$.properties}}});return}if($.type!=="task.status")return;this.sendUpdate({sessionUpdate:"session_info_update",updatedAt:typeof $.properties.updatedAt==="string"?$.properties.updatedAt:new Date().toISOString(),_meta:{"blade/taskStatus":$.properties.taskStatus,...typeof $.properties.taskStatusReason==="string"?{"blade/taskStatusReason":$.properties.taskStatusReason}:{},...$.properties.taskFailure&&typeof $.properties.taskFailure==="object"?{"blade/taskFailure":$.properties.taskFailure}:{},...typeof $.properties.taskStartedAt==="string"?{"blade/taskStartedAt":$.properties.taskStartedAt}:{},...typeof $.properties.taskCompletedAt==="string"?{"blade/taskCompletedAt":$.properties.taskCompletedAt}:{},...$.properties.taskDiffStat&&typeof $.properties.taskDiffStat==="object"?{"blade/taskDiffStat":$.properties.taskDiffStat}:{},...typeof $.properties.taskQueuePosition==="number"?{"blade/taskQueuePosition":$.properties.taskQueuePosition}:{},...typeof $.properties.taskQueueDepth==="number"?{"blade/taskQueueDepth":$.properties.taskQueueDepth}:{},...typeof $.properties.taskConcurrencyLimit==="number"?{"blade/taskConcurrencyLimit":$.properties.taskConcurrencyLimit}:{},...typeof $.properties.taskInFlight==="number"?{"blade/taskInFlight":$.properties.taskInFlight}:{}}})});let Q=await this.runtime.getGoal(),W=this.runtime.getPendingSteeringCount()>0,B=Q?.status==="active"||Q?.status==="verifying";if(W||B)this.requestPendingResume({defer:this.options.initialMessages!==void 0});else{let $=this.runtime.getTurnRecoveryAssessment();if($.state!=="none")this.sendUpdate({sessionUpdate:"session_info_update",updatedAt:new Date().toISOString(),_meta:{"blade/turnRecovery":$}})}}async replayHistory(){for(let H of this.messages){if(!this.canSendUpdates())return;if(!Uz(H))continue;if(Kz(H)&&typeof H.content==="string"){if(!await this.sendUpdateAndWait({sessionUpdate:"agent_message_chunk",content:{type:"text",text:`
3
3
 
4
4
  recap: ${H.content}
@@ -1,4 +1,4 @@
1
- import{Bc as b4}from"./chunk-9qxch6sy.js";import{Ad as f2,Bd as k2,Cc as D$,Cd as w6,Dd as U6,Ec as j$,Fc as S2,Gc as r1,Ic as H$,Jd as M2,Kd as A4,Ld as E4,Md as V6,Nd as e1,Od as S4,Pd as T4,Qd as d1,Ud as sJ,ae as i2,ce as h0,ee as k6,fe as o1,ge as M6,ne as W1,yd as T2}from"./chunk-v7pw7a8q.js";import{se as y4}from"./chunk-skktstg8.js";import{Ke as q0,Le as c2,ve as F0,ye as U2,ze as s1}from"./chunk-s14zayxp.js";import{fg as n2}from"./chunk-x6k5ye1z.js";import{gg as N4,hg as x0,ig as G4,jg as rJ,lg as u1,mg as f6,ng as nJ,og as oJ,rg as aJ}from"./chunk-1g7c3f82.js";import{ch as Z$,dh as c0,gh as _4}from"./chunk-kehgewqh.js";import{lh as Y4,ph as H2}from"./chunk-kkzznz4w.js";import{Ah as T$}from"./chunk-c08qbh8h.js";import{Ih as M$}from"./chunk-6wzwkjep.js";import{Zi as H0}from"./chunk-b22ab7yw.js";import{Ej as G0}from"./chunk-saz6mwpq.js";import{Xj as E2}from"./chunk-cc9vbgqc.js";import{Ak as y2,Ck as b2,Hk as A2,dk as _2,sk as q2,tk as F2,wk as fJ,zk as NJ}from"./chunk-ed2hdrwe.js";import{Jk as dZ}from"./chunk-gmpsfkgg.js";function A$($){return $.role==="system"&&Array.isArray($.content)}function b$($){if($.role!=="system"||!$.metadata||Array.isArray($.metadata))return!1;return typeof $.metadata==="object"&&$.metadata.contextualProjectRules===!0}class x1{systemMessages;_contextualSystemMessages;_history;_pending=[];_contextRevision=0;context;constructor($,Z){this.context=$;let J=$.messages.find(A$);if(this._contextualSystemMessages=$.messages.filter(b$),J)this.systemMessages=[J,...this._contextualSystemMessages];else if(Z)this.systemMessages=[{role:"system",content:[{type:"text",text:Z,providerOptions:{anthropic:{cacheControl:{type:"ephemeral"}}}}]},...this._contextualSystemMessages];else this.systemMessages=[...this._contextualSystemMessages];this._history=$.messages.filter((W)=>!A$(W)&&!b$(W))}get historyLength(){return this._history.length}get pending(){return this._pending}get contextRevision(){return this._contextRevision}toLLMMessages(){return[...this.systemMessages,...this._history,...this._pending]}getHistory(){return this._history}appendUser($){this._pending.push($)}appendAssistant($){this._pending.push($)}appendToolResult($){this._pending.push($)}appendContextualProjectInstructions($){if(!b$($))throw Error("Contextual project instructions require safe metadata");this._contextualSystemMessages.push($),this.systemMessages.push($)}syncContextualSystemMessages(){let $=this.systemMessages.filter(A$);this.systemMessages.splice(0,this.systemMessages.length,...$,...this._contextualSystemMessages)}appendControl($,Z){if($==="system")throw Error("Cannot append system control message via appendControl. Use constructor for root system prompt.");this._pending.push({...Z,metadata:{...Z.metadata&&typeof Z.metadata==="object"&&!Array.isArray(Z.metadata)?Z.metadata:{},...q0}})}appendDurableControl($){if(!$.id||$.role!=="user")throw Error("Durable control messages require a user role and identity");if(this._history.some((Z)=>Z.id===$.id))return;this._history.push($)}appendToHistory($){this._history.push($)}commitPending(){if(this._pending.length>0)this._history.push(...this._pending),this._pending=[]}replaceHistory($){this._history=$.filter((Z)=>!A$(Z)&&!b$(Z)),this._contextRevision++}restoreDurableHistory($){this._contextualSystemMessages=$.filter(b$),this._history=$.filter((Z)=>!A$(Z)&&!b$(Z)),this._pending=[],this.syncContextualSystemMessages(),this._contextRevision++}removeMessages($){let Z=[this._history.length,this._pending.length,this._contextualSystemMessages.length];if(this._history=this._history.filter((J)=>!$(J)),this._pending=this._pending.filter((J)=>!$(J)),this._contextualSystemMessages=this._contextualSystemMessages.filter((J)=>!$(J)),this.syncContextualSystemMessages(),this._history.length!==Z[0]||this._pending.length!==Z[1]||this._contextualSystemMessages.length!==Z[2])this._contextRevision++}writeback(){this.commitPending(),this.context.messages=[...this._contextualSystemMessages,...this._history]}}function JJ($){if($.isSubagent)return"continue";if(!$.budget||$.budget<=0)return"continue";if($.consecutiveContinuations>=3&&$.lastOutputDelta<500)return"stop";if($.usage/$.budget>=0.9)return"stop";return"continue"}function WJ($){return{budget:$.budget,usage:0,consecutiveContinuations:0,lastOutputDelta:0,isSubagent:$.isSubagent??!1}}function YJ($,Z,J){return{...$,usage:$.usage+Z,lastOutputDelta:Z,consecutiveContinuations:J?$.consecutiveContinuations+1:0}}import X$ from"node:path";var g4=new Set(["GOEXPERIMENT","GOOS","GOARCH","CGO_ENABLED","GO111MODULE","RUST_BACKTRACE","RUST_LOG","NODE_ENV","PYTHONUNBUFFERED","PYTHONDONTWRITEBYTECODE","GIT_TERMINAL_PROMPT","LANG","LANGUAGE","LC_ALL","LC_CTYPE","LC_TIME","CHARSET","TERM","COLORTERM","NO_COLOR","FORCE_COLOR","TZ","LS_COLORS","LSCOLORS","GREP_COLOR","GREP_COLORS"]),m4=/^(LD_.+|DYLD_.+|PATH)$/,KJ=/^([A-Za-z_][A-Za-z0-9_]*)=([\w./:@-]*)$/;function e$($){let Z=$;while(!0){let J=Z.match(/^(\S+)[ \t]+([\s\S]*)$/);if(!J)break;let W=J[1],Y=J[2],K=W.match(KJ);if(!K)break;let Q=K[1];if(!g4.has(Q))break;Z=Y}return Z}function jW($){let Z=$;while(!0){let J=Z.match(/^(\S+)[ \t]+([\s\S]*)$/);if(!J)break;let W=J[1],Y=J[2],K=W.match(KJ);if(!K)break;let Q=K[1];if(m4.test(Q))break;Z=Y}return Z}var u4=[/^timeout[ \t]+(?:--foreground[ \t]+|--preserve-status[ \t]+|-v[ \t]+|--verbose[ \t]+|-k[ \t]+\S+[ \t]+|--kill-after[= ]\S+[ \t]+|-s[ \t]+\S+[ \t]+|--signal[= ]\S+[ \t]+)*\S+[ \t]+/,/^time[ \t]+/,/^nice[ \t]+(?:-n[ \t]+\d+[ \t]+|-\d+[ \t]+)?/,/^nohup[ \t]+/];function MZ($){let Z=$,J=!0;while(J){J=!1;for(let W of u4){let Y=Z.match(W);if(Y){Z=Z.slice(Y[0].length),J=!0;break}}if(Z.startsWith("-- "))Z=Z.slice(3),J=!0}return Z}function $1($){let Z=[],J="",W=!1,Y=!1,K=!1;for(let Q=0;Q<$.length;Q++){let X=$[Q];if(K){J+=X,K=!1;continue}if(X==="\\"&&!W){J+=X,K=!0;continue}if(X==="'"&&!Y){W=!W,J+=X;continue}if(X==='"'&&!W){Y=!Y,J+=X;continue}if(W||Y){J+=X;continue}if(X==="|"){if(Q+1<$.length&&$[Q+1]==="|"){if(J.trim())Z.push(J.trim());J="",Q++;continue}return null}if(X===">"||X==="<")return null;if(X==="&"&&Q+1<$.length&&$[Q+1]==="&"){if(J.trim())Z.push(J.trim());J="",Q++;continue}if(X==="&")return null;if(X===";"){if(J.trim())Z.push(J.trim());J="";continue}J+=X}if(J.trim())Z.push(J.trim());return Z.length>0?Z:null}function QJ($){let Z=!1,J=!1,W=!1;for(let Y=0;Y<$.length;Y++){let K=$[Y];if(W){W=!1;continue}if(K==="\\"&&!Z){W=!0;continue}if(K==="'"&&!J){Z=!Z;continue}if(K==='"'&&!Z){J=!J;continue}if(Z)continue;if(K==="$"){let Q=$[Y+1];if(Q&&/[A-Za-z_@*#?!$0-9({]/.test(Q))return!0}if(K==="`")return!0;if(J)continue;if(K==="|")return!0;if(K===">"||K==="<")return!0;if(K==="{"){let Q=$.slice(Y);if(/^\{[^}]*,[^}]*\}/.test(Q)||/^\{[^}]*\.\.[^}]*\}/.test(Q))return!0}}return!1}function Q$($){let Z=[],J="",W=!1,Y=!1,K=!1;for(let Q=0;Q<$.length;Q++){let X=$[Q];if(K){J+=X,K=!1;continue}if(X==="\\"&&!W){if(K=!0,Y){let H=$[Q+1];if(H&&'$`"\\'.includes(H))continue;J+=X,K=!1}continue}if(X==="'"&&!Y){W=!W;continue}if(X==='"'&&!W){Y=!Y;continue}if(!W&&!Y&&/[ \t]/.test(X)){if(J)Z.push(J),J="";continue}J+=X}if(J)Z.push(J);return Z}var d4=new Set(["npm","pnpm","yarn","bun"]),XJ=new Set(["biome","eslint","jest","mypy","pyright","pytest","ruff","tsc","vitest"]),c4=new Set(["-u","--fix","--update","--update-snapshot","--updateSnapshot","--watch","--watchAll","--write"]),i4=/[ \t]*;[ \t]*echo[ \t]+"[A-Za-z0-9 _:=.-]*(?:\$\{PIPESTATUS\[0\]\}|\$\?)[A-Za-z0-9 _:=.-]*"[ \t]*$/;function l4($){return $!==void 0&&/^(?:test|lint|build|type-?check)(?::[\w.-]+)*$/i.test($)}function HJ($){return $.replace(/\s+2>&1\s*$/,"").trim()}function r4($,Z,J){if(!J||Z.length!==2)return;let W=/^(.+?)[ \t]+&&[ \t]+([\s\S]+)$/.exec($);if(!W)return;let Y=Q$(W[1]??"");if(Y.length!==2||Y[0]!=="cd")return;let K=Y[1];if(!K||K==="-")return;let Q=X$.isAbsolute(K)?X$.resolve(K):X$.resolve(J,K);if(!H$.isWithinWorkspace(Q,J))return;return W[2]?.trim()||void 0}function n4($){let Z=[],J=!1,W=!1,Y=!1;for(let K=0;K<$.length;K++){let Q=$[K];if(Y){Y=!1;continue}if(Q==="\\"&&!J){Y=!0;continue}if(Q==="'"&&!W){J=!J;continue}if(Q==='"'&&!J){W=!W;continue}if(Q!=="|"||J||W)continue;if($[K+1]==="|")return;Z.push(K)}return Z}function o4($){let Z=Q$($),[J,W,Y]=Z;if(J!=="head"&&J!=="tail")return!1;if(Z.length===1)return!0;let K=(Q)=>Q!==void 0&&/^[1-9]\d{0,4}$/.test(Q);if(Z.length===2)return W?.startsWith("--lines=")&&K(W.slice(8))||W?.startsWith("-")&&K(W.slice(1));return Z.length===3&&(W==="-n"||W==="--lines")&&K(Y)}function a4($){let Z=HJ($.replace(i4,"").trim()),J=n4(Z);if(!J)return;if(J.length===0)return VJ(Z);if(J.length!==1)return;let W=J[0];if(W===void 0)return;let Y=HJ(Z.slice(0,W).trim()),K=Z.slice(W+1).trim();if(!Y||!o4(K))return;return VJ(Y)}function VJ($){let J=$1($)?.at(-1);if(!J)return $;let W=Q$(J),[Y,K]=W;if(!(Y==="vitest"||(Y==="npx"||Y==="bunx")&&K==="vitest")||W.some((X)=>X==="--configLoader"||X.startsWith("--configLoader=")))return $;return`${$} --configLoader runner`}function E$($,Z){let J=a4($);if(!J)return!1;let W=e$(J),Y=$1(W);if(!Y||QJ(W)||/[\r\n]/.test(W))return!1;let K=Y.length===1?Y[0]:r4(W,Y,Z);if(!K)return!1;let Q=Q$(K);if(Q.length===0||Q.some((V)=>[...c4].some((j)=>V===j||V.startsWith(`${j}=`))))return!1;let[X,H,z]=Q;if(d4.has(X??""))return l4(H==="run"?z:H)||H==="--test";if((X==="npx"||X==="bunx")&&XJ.has(H??""))return!0;if(XJ.has(X??""))return!0;if(X==="node"&&H==="--test")return!0;if(X==="go"&&["build","test","vet"].includes(H??""))return!0;return X==="cargo"&&["build","check","clippy","test"].includes(H??"")}function LW($,Z){if($===void 0)return!0;if(typeof $!=="string"||$.split(/[\\/]/).includes(".."))return!1;if(!Z)return!X$.isAbsolute($);let J=X$.isAbsolute($)?X$.resolve($):X$.resolve(Z,$);return H$.isWithinWorkspace(J,Z)}var RZ=G0("Agent"),s4=3;function xZ($,Z,J){if($!=="length")return{action:"none"};if(Z>=s4)return{action:"truncated"};if(JJ(J)==="stop")return RZ.info("[Loop] Token budget: diminishing returns detected, skipping recovery"),{action:"budget_stop"};return{action:"recover"}}var t4=[/:\s*$/,/:\s*$/,/\.\.\.\s*$/,/让我(先|来|开始|查看|检查|修复)/,/Let me (first|start|check|look|fix)/i,/I('ll| will) (now |)(create|write|edit|update|modify|fix|add|implement)/i,/我(现在就|来|要)(创建|写入|编辑|修改|修复|添加|实现)/,/\d+\.\s+(First|Next|Then|Finally)/i],e4=/```[\s\S]{50,}```/,zJ="请执行你提到的操作,不要只是描述。使用 Edit/Write/ApplyPatch/Bash 工具来实际修改文件。",$5=2;function IZ($,Z,J=!0){if(!$||Z>=$5)return{action:"none"};if(!J&&e4.test($))return{action:"retry",prompt:zJ};let W=$.slice(-200),Y=W.match(/```/g);if(Y&&Y.length%2!==0)return{action:"none"};if(t4.some((Q)=>Q.test(W)))return{action:"retry",prompt:zJ};return{action:"none"}}var I1=2,Z5="The model returned tool-call JSON as text instead of completing the requested tool workflow.",J5="The previous response contained tool-call JSON as ordinary text. It did not execute a tool. If the requested operation is still needed, use the native tool-call interface with an available tool. If it already succeeded, use the recorded result to answer instead of repeating the operation. Do not return another tool-call JSON envelope as your final answer.";function hZ($,Z,J,W){if(!$||$.length>65536||J.length===0)return{action:"none"};let Y=Z.replace(/```[\s\S]*?(?:```|$)/g,"").replace(/^\s*>.*$/gm,"");if(/\b(?:example|schema|serialize|serialization|quote|print|illustrate|verbatim)\b|示例|样例|序列化|引用原文/i.test(Y)||/\b(?:explain|show|return|output)\b[^.!?\n]{0,80}\b(?:json|tool.calls?)\b|(?:解释|展示|输出|返回)[^。!?\n]{0,40}(?:JSON|工具调用格式)/i.test(Y)||/\b(?:do not|don't|never)\s+(?:use|call|invoke|execute)\s+(?:any\s+)?tools?\b|不要(?:使用|调用|执行)(?:任何)?工具/i.test(Y))return{action:"none"};let K;try{K=JSON.parse($)}catch{return{action:"none"}}if(!K||typeof K!=="object"||Array.isArray(K)||Object.keys(K).length!==1||!("tool_calls"in K)||!Array.isArray(K.tool_calls)||K.tool_calls.length===0||K.tool_calls.length>32)return{action:"none"};let Q=new Set;for(let X of K.tool_calls){if(!X||typeof X!=="object"||Array.isArray(X))return{action:"none"};let H="function"in X;if(Object.keys(X).some((G)=>!["id","type",...H?["function"]:["name","arguments"]].includes(G)))return{action:"none"};if("type"in X&&X.type!=="function")return{action:"none"};let z=H?X.function:X;if(!z||typeof z!=="object"||Array.isArray(z)||!("name"in z)||typeof z.name!=="string"||!("arguments"in z))return{action:"none"};if(H&&Object.keys(z).some((G)=>G!=="name"&&G!=="arguments"))return{action:"none"};if(!J.includes(z.name))return{action:"none"};let V=z.arguments;if(typeof V!=="string"&&(!V||typeof V!=="object"||Array.isArray(V)))return{action:"none"};let j=z.name.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),B=new RegExp(`(?:^|[.!?。!?;;\\n])\\s*(?:please\\s+)?(?:call|invoke|execute|run|use)\\s+(?:the\\s+)?(?:tool\\s+)?[\`"']?${j}(?![\\w:-])|(?:^|[。!?;\\n])\\s*(?:请)?(?:调用|使用|执行)\\s*(?:工具\\s*)?[\`"']?${j}(?![\\w:-])`,"i"),w=new RegExp(`(?:do not|don't|never)\\s+(?:call|invoke|execute|run|use)\\s+(?:the\\s+)?(?:tool\\s+)?[\`"']?${j}(?![\\w:-])|(?:不要|禁止)(?:调用|使用|执行)\\s*(?:工具\\s*)?[\`"']?${j}(?![\\w:-])`,"i");if(!B.test(Y)||w.test(Y))return{action:"none"};Q.add(z.name)}return W<I1?{action:"retry",prompt:J5,...Q.size===1?{toolName:[...Q][0]}:{}}:{action:"fail",message:Z5}}var W5=[/\b(?:run|execute|rerun|re-run)\b[\s\S]{0,60}\b(?:tests?|test suite|lint|type-?check|build)\b/i,/\b(?:npm|pnpm|yarn|bun)\s+(?:run\s+)?(?:test|lint|build|type-?check)\b/i,/(?:运行|执行|跑|重新运行).{0,30}(?:测试|单测|集成测试|检查|构建)/],BJ={test:/\b(?:tests?|test suite)\b|(?:测试|单测|集成测试)/i,lint:/\blint(?:ing)?\b/i,"type-check":/\btype[\s-]?check(?:ing)?\b|\btsc\b|类型检查/i,build:/\bbuild\b|构建/i},Y5={test:/(?:^|\s)(?:npm|pnpm|yarn|bun)\s+(?:run\s+)?test\b|(?:^|\s)(?:node|bun)\s+--test\b|(?:^|\s)(?:vitest|jest|pytest|go\s+test|cargo\s+test)\b/i,lint:/(?:^|\s)(?:npm|pnpm|yarn|bun)\s+(?:run\s+)?lint\b/i,"type-check":/(?:^|\s)(?:npm|pnpm|yarn|bun)\s+(?:run\s+)?type-?check\b|(?:^|\s)tsc\b/i,build:/(?:^|\s)(?:npm|pnpm|yarn|bun)\s+(?:run\s+)?build\b/i},K5="The user explicitly required verification, but it has not run successfully. Do not finish or explain. Your next action must be a Bash tool call that runs the requested test, lint, type-check, or build command. Inspect the command result and fix any failure before finishing.",Q5="Required verification did not run successfully before the retry limit.",X5=3;function DJ($,Z,J,W){if(!J.success)return;if(["Edit","Write","ApplyPatch","NotebookEdit"].includes(Z)){$.clear();return}if(Z==="Bash"&&typeof J.metadata?.command==="string"&&J.metadata.exit_code===0&&E$(J.metadata.command,W)){$.add(J.metadata.command);return}if(!["Task","TaskOutput"].includes(Z))return;let Y=J.metadata?.verificationCommands;if(!Array.isArray(Y))return;for(let K of Y)if(typeof K==="string"&&E$(K,W))$.add(K)}function vZ($,Z,J){if(!$||!W5.some((H)=>H.test($)))return{action:"none"};let W=Object.keys(BJ).filter((H)=>BJ[H].test($)),Y=[...Z],K=W.filter((H)=>!Y.some((z)=>Y5[H].test(z)));if(W.length>0?K.length===0:Y.some((H)=>E$(H)))return{action:"none"};if(J>=X5)return{action:"fail",message:Q5};let X=W.length>1&&K.length>0?` Missing successful verification categories: ${K.join(", ")}.`:"";return{action:"retry",prompt:`${K5}${X}`}}var H5=[/\bdelegate\b[\s\S]{0,120}\b(?:Task tool|subagent|agent)\b/i,/\b(?:call|use|invoke)\b[\s\S]{0,80}\bTask tool\b/i,/(?:委派|交给|调用|使用).{0,60}(?:Task|子代理|子智能体)/],wJ=[/\b(?:do not|don't|never)\s+(?:delegate|call|use|invoke)\b/i,/(?:不要|禁止|无需)(?:委派|调用|使用).{0,20}(?:Task|子代理|子智能体)?/];function UJ($){return typeof $==="string"&&wJ.some((Z)=>Z.test($))}var V5=[/\b(?:call|use|invoke)\b[\s\S]{0,30}\bTask(?: tool)?\b[\s\S]{0,30}\bexactly once\b/i,/\bexactly once\b[\s\S]{0,30}\b(?:call|use|invoke)\b[\s\S]{0,30}\bTask(?: tool)?\b/i,/\bexactly one\b[\s\S]{0,30}\bTask(?: tool)? calls?\b/i,/(?:Task|子代理).{0,20}(?:恰好|仅|只)(?:调用|使用)?一次/,/(?:恰好|仅|只)(?:调用|使用)?一次.{0,20}(?:Task|子代理)/],z5=[/\b(?:do not|don't|never)\s+(?:call|use|invoke)\s+(?:the\s+)?Task\b[\s\S]{0,30}\bexactly once\b/i,/\bTask\b[\s\S]{0,30}\b(?:does not|doesn't|need not)\b[\s\S]{0,30}\bexactly once\b/i,/\bmultiple\s+Task(?: tool)?\s+calls?\s+(?:are\s+)?allowed\b/i,/(?:不要|禁止).{0,12}(?:Task|子代理).{0,12}(?:恰好|仅|只)(?:调用|使用)?一次/];function B5($){if(typeof $!=="string")return;if(z5.some((Z)=>Z.test($)))return"multiple-allowed";return V5.some((Z)=>Z.test($))?"required":void 0}function Z1($){for(let Z of $){let J=B5(Z);if(J!==void 0)return J==="required"}return!1}var j5="The user explicitly required delegation, but no Task tool call completed successfully. Do not solve the task directly or explain. Your next action must be a Task tool call using the requested subagent.",D5="Required delegation did not complete before the retry limit.",w5=3;function GJ($,Z,J){let W=(typeof $==="string"?[$]:$??[]).map((Q)=>Q.trim()).filter(Boolean),Y=Z1(W),K=!1;if(!Y)for(let Q of W){if(wJ.some((X)=>X.test(Q)))break;if(H5.some((X)=>X.test(Q))){K=!0;break}}if(W.length===0||!Y&&!K||Z.has("Task"))return{action:"none"};if(J>=w5)return{action:"fail",message:D5};return{action:"retry",prompt:j5}}var U5=[/\b(?:use|create|enter|start|work\s+(?:in|inside))\b.{0,60}\bworktree\b/i,/(?:使用|创建|进入).{0,30}(?:worktree|工作树)/i],G5=[/\b(?:exit|leave)\b.{0,40}\bworktree\b/i,/\bworktree\b.{0,60}\b(?:action\s+)?(?:keep|remove)\b/i,/(?:退出|离开).{0,30}(?:worktree|工作树)/i],L5=[/\b(?:do not|don't|never|must not|should not)\b[^.!?;\n]{0,80}\b(?:git\s+)?worktree\b/gi,/\bwithout\b[^.!?;\n]{0,60}\b(?:git\s+)?worktree\b/gi,/(?:不要|禁止|不得|无需)[^。!?;\n]{0,50}(?:worktree|工作树)/gi];function LJ($){return L5.reduce((Z,J)=>Z.replace(J," "),$)}function h1($){if(typeof $!=="string")return!1;let Z=LJ($);return U5.some((J)=>J.test(Z))}var q5="The user explicitly required git worktree isolation, but EnterWorktree has not completed successfully. Do not continue in the original workspace. Your next action must be an EnterWorktree tool call. Wait for its result before using file or Bash tools.",F5="The user explicitly required leaving the managed worktree, but ExitWorktree has not completed successfully. Do not finish or explain. Your next action must be an ExitWorktree tool call using the action requested by the user.",O5="Required worktree lifecycle did not complete before the retry limit.",P5=3;function qJ($,Z,J){if(!$)return{action:"none"};let W=LJ($);if(!h1(W))return{action:"none"};let Y=G5.some((Q)=>Q.test(W));if(Z.has("TaskWorktree"))return{action:"none"};let K=!Z.has("EnterWorktree")?"EnterWorktree":Y&&!Z.has("ExitWorktree")?"ExitWorktree":void 0;if(!K)return{action:"none"};if(J>=P5)return{action:"fail",message:O5};return{action:"retry",tool:K,prompt:K==="EnterWorktree"?q5:F5}}var jJ=30000;async function CZ($){try{let J=T$.getInstance().executeStopHooks({projectDir:$.workspaceRoot??H0(),sessionId:$.sessionId,permissionMode:$.permissionMode,reason:$.reason,abortSignal:$.abortSignal}),W,Y=new Promise((K)=>{W=setTimeout(()=>K("timeout"),jJ)});try{let K=await Promise.race([J,Y]);if(K==="timeout")return RZ.warn(`[Loop] Stop hook 超时 (${jJ}ms),按 shouldStop: true 处理`),{action:"stop"};let Q=K;if(!Q.shouldStop)return{action:"continue",reason:Q.continueReason};return{action:"stop"}}finally{clearTimeout(W)}}catch(Z){return RZ.warn("[Loop] Stop hook execution failed:",Z),{action:"stop"}}}async function N5($,Z){let J;while(!(J=await $.next()).done)if(Z)await Z(J.value);return J.value}var _5=[/<system-reminder>[\s\S]*?<\/system-reminder>/gi,/<file[^>]*>[\s\S]*?<\/file>/gi,/<hooks_context>[\s\S]*?<\/hooks_context>/gi,/<[^>]+>/g];function y5($){if(typeof $==="string")return $;if(Array.isArray($))return $.map((Z)=>{if(typeof Z==="string")return Z;if(Z&&typeof Z==="object"&&"text"in Z){let J=Z.text;return typeof J==="string"?J:""}return""}).join(" ");return""}function b5($){let Z=$;for(let H of _5)Z=Z.replace(H," ");Z=Z.replace(/^\s*\/[a-zA-Z][\w-]*\s+/,"");let J=Z.replace(/\s+/g," ").trim();if(!J)return"";let W=J.match(/^(.+?)(?:[.!?]\s|[。!?](?=\S|$)|$)/),Y=W&&W[1].length>=6?W[1]:J;if(Y=Y.trim().replace(/[\s.。!!??,,;;::-]+$/,""),Y.length<=60)return Y;let K=Y.slice(0,60),Q=K.lastIndexOf(" ");return`${(Q>36?K.slice(0,Q):K).trimEnd()}…`}function FJ($){return b5(y5($))}import{EventEmitter as A5}from"events";import OJ from"node:path";function pZ($){if(NJ($.sessionId),!OJ.isAbsolute($.projectPath))throw Error("projectPath must be absolute");return{sessionId:$.sessionId,projectPath:OJ.resolve($.projectPath)}}function PJ($){let Z=pZ($);return JSON.stringify([Z.projectPath,Z.sessionId])}function fW($,Z){return PJ($)===PJ(Z)}class f$ extends A5{static instance;constructor(){super();this.setMaxListeners(100)}static getInstance(){if(!f$.instance)f$.instance=new f$;return f$.instance}publish($,Z,J,W){let Y=pZ($);this.emit("event",{sessionId:Y.sessionId,projectPath:Y.projectPath,type:Z,...W!==void 0?{seq:W}:{},properties:J})}subscribe($){return this.on("event",$),()=>this.off("event",$)}}var J1=f$.getInstance();var a0=G0("Agent"),v1=new Set;async function E5($,Z){let J=$.sessionId;if(!J||$.subagentInfo)return;if(v1.has(J))return;if(v1.size>=5000)v1.clear();v1.add(J);try{let W=$.workspaceRoot,Y=await W1.findSessionMetadata(J,W);if(!Y)return;if(Y.title&&Y.title.trim())return;let K=FJ(Z);if(!K)return;await W1.updateSessionMetadata(J,Y.projectPath,{title:K}),J1.publish({sessionId:J,projectPath:Y.projectPath},"session.updated",{title:K})}catch(W){a0.debug?.("[Loop] 自动生成会话标题失败:",W)}}var gZ=`<turn_aborted>
1
+ import{Bc as b4}from"./chunk-9qxch6sy.js";import{Ad as f2,Bd as k2,Cc as D$,Cd as w6,Dd as U6,Ec as j$,Fc as S2,Gc as r1,Ic as H$,Jd as M2,Kd as A4,Ld as E4,Md as V6,Nd as e1,Od as S4,Pd as T4,Qd as d1,Ud as sJ,ae as i2,ce as h0,ee as k6,fe as o1,ge as M6,ne as W1,yd as T2}from"./chunk-6jjpj5ge.js";import{se as y4}from"./chunk-skktstg8.js";import{Ke as q0,Le as c2,ve as F0,ye as U2,ze as s1}from"./chunk-s14zayxp.js";import{fg as n2}from"./chunk-x6k5ye1z.js";import{gg as N4,hg as x0,ig as G4,jg as rJ,lg as u1,mg as f6,ng as nJ,og as oJ,rg as aJ}from"./chunk-1g7c3f82.js";import{ch as Z$,dh as c0,gh as _4}from"./chunk-kehgewqh.js";import{lh as Y4,ph as H2}from"./chunk-kkzznz4w.js";import{Ah as T$}from"./chunk-8yh4mn8a.js";import{Ih as M$}from"./chunk-ftk0ytf8.js";import{Zi as H0}from"./chunk-b22ab7yw.js";import{Ej as G0}from"./chunk-saz6mwpq.js";import{Xj as E2}from"./chunk-bzwxh6nq.js";import{Ak as y2,Ck as b2,Hk as A2,dk as _2,sk as q2,tk as F2,wk as fJ,zk as NJ}from"./chunk-ed2hdrwe.js";import{Jk as dZ}from"./chunk-gmpsfkgg.js";function A$($){return $.role==="system"&&Array.isArray($.content)}function b$($){if($.role!=="system"||!$.metadata||Array.isArray($.metadata))return!1;return typeof $.metadata==="object"&&$.metadata.contextualProjectRules===!0}class x1{systemMessages;_contextualSystemMessages;_history;_pending=[];_contextRevision=0;context;constructor($,Z){this.context=$;let J=$.messages.find(A$);if(this._contextualSystemMessages=$.messages.filter(b$),J)this.systemMessages=[J,...this._contextualSystemMessages];else if(Z)this.systemMessages=[{role:"system",content:[{type:"text",text:Z,providerOptions:{anthropic:{cacheControl:{type:"ephemeral"}}}}]},...this._contextualSystemMessages];else this.systemMessages=[...this._contextualSystemMessages];this._history=$.messages.filter((W)=>!A$(W)&&!b$(W))}get historyLength(){return this._history.length}get pending(){return this._pending}get contextRevision(){return this._contextRevision}toLLMMessages(){return[...this.systemMessages,...this._history,...this._pending]}getHistory(){return this._history}appendUser($){this._pending.push($)}appendAssistant($){this._pending.push($)}appendToolResult($){this._pending.push($)}appendContextualProjectInstructions($){if(!b$($))throw Error("Contextual project instructions require safe metadata");this._contextualSystemMessages.push($),this.systemMessages.push($)}syncContextualSystemMessages(){let $=this.systemMessages.filter(A$);this.systemMessages.splice(0,this.systemMessages.length,...$,...this._contextualSystemMessages)}appendControl($,Z){if($==="system")throw Error("Cannot append system control message via appendControl. Use constructor for root system prompt.");this._pending.push({...Z,metadata:{...Z.metadata&&typeof Z.metadata==="object"&&!Array.isArray(Z.metadata)?Z.metadata:{},...q0}})}appendDurableControl($){if(!$.id||$.role!=="user")throw Error("Durable control messages require a user role and identity");if(this._history.some((Z)=>Z.id===$.id))return;this._history.push($)}appendToHistory($){this._history.push($)}commitPending(){if(this._pending.length>0)this._history.push(...this._pending),this._pending=[]}replaceHistory($){this._history=$.filter((Z)=>!A$(Z)&&!b$(Z)),this._contextRevision++}restoreDurableHistory($){this._contextualSystemMessages=$.filter(b$),this._history=$.filter((Z)=>!A$(Z)&&!b$(Z)),this._pending=[],this.syncContextualSystemMessages(),this._contextRevision++}removeMessages($){let Z=[this._history.length,this._pending.length,this._contextualSystemMessages.length];if(this._history=this._history.filter((J)=>!$(J)),this._pending=this._pending.filter((J)=>!$(J)),this._contextualSystemMessages=this._contextualSystemMessages.filter((J)=>!$(J)),this.syncContextualSystemMessages(),this._history.length!==Z[0]||this._pending.length!==Z[1]||this._contextualSystemMessages.length!==Z[2])this._contextRevision++}writeback(){this.commitPending(),this.context.messages=[...this._contextualSystemMessages,...this._history]}}function JJ($){if($.isSubagent)return"continue";if(!$.budget||$.budget<=0)return"continue";if($.consecutiveContinuations>=3&&$.lastOutputDelta<500)return"stop";if($.usage/$.budget>=0.9)return"stop";return"continue"}function WJ($){return{budget:$.budget,usage:0,consecutiveContinuations:0,lastOutputDelta:0,isSubagent:$.isSubagent??!1}}function YJ($,Z,J){return{...$,usage:$.usage+Z,lastOutputDelta:Z,consecutiveContinuations:J?$.consecutiveContinuations+1:0}}import X$ from"node:path";var g4=new Set(["GOEXPERIMENT","GOOS","GOARCH","CGO_ENABLED","GO111MODULE","RUST_BACKTRACE","RUST_LOG","NODE_ENV","PYTHONUNBUFFERED","PYTHONDONTWRITEBYTECODE","GIT_TERMINAL_PROMPT","LANG","LANGUAGE","LC_ALL","LC_CTYPE","LC_TIME","CHARSET","TERM","COLORTERM","NO_COLOR","FORCE_COLOR","TZ","LS_COLORS","LSCOLORS","GREP_COLOR","GREP_COLORS"]),m4=/^(LD_.+|DYLD_.+|PATH)$/,KJ=/^([A-Za-z_][A-Za-z0-9_]*)=([\w./:@-]*)$/;function e$($){let Z=$;while(!0){let J=Z.match(/^(\S+)[ \t]+([\s\S]*)$/);if(!J)break;let W=J[1],Y=J[2],K=W.match(KJ);if(!K)break;let Q=K[1];if(!g4.has(Q))break;Z=Y}return Z}function jW($){let Z=$;while(!0){let J=Z.match(/^(\S+)[ \t]+([\s\S]*)$/);if(!J)break;let W=J[1],Y=J[2],K=W.match(KJ);if(!K)break;let Q=K[1];if(m4.test(Q))break;Z=Y}return Z}var u4=[/^timeout[ \t]+(?:--foreground[ \t]+|--preserve-status[ \t]+|-v[ \t]+|--verbose[ \t]+|-k[ \t]+\S+[ \t]+|--kill-after[= ]\S+[ \t]+|-s[ \t]+\S+[ \t]+|--signal[= ]\S+[ \t]+)*\S+[ \t]+/,/^time[ \t]+/,/^nice[ \t]+(?:-n[ \t]+\d+[ \t]+|-\d+[ \t]+)?/,/^nohup[ \t]+/];function MZ($){let Z=$,J=!0;while(J){J=!1;for(let W of u4){let Y=Z.match(W);if(Y){Z=Z.slice(Y[0].length),J=!0;break}}if(Z.startsWith("-- "))Z=Z.slice(3),J=!0}return Z}function $1($){let Z=[],J="",W=!1,Y=!1,K=!1;for(let Q=0;Q<$.length;Q++){let X=$[Q];if(K){J+=X,K=!1;continue}if(X==="\\"&&!W){J+=X,K=!0;continue}if(X==="'"&&!Y){W=!W,J+=X;continue}if(X==='"'&&!W){Y=!Y,J+=X;continue}if(W||Y){J+=X;continue}if(X==="|"){if(Q+1<$.length&&$[Q+1]==="|"){if(J.trim())Z.push(J.trim());J="",Q++;continue}return null}if(X===">"||X==="<")return null;if(X==="&"&&Q+1<$.length&&$[Q+1]==="&"){if(J.trim())Z.push(J.trim());J="",Q++;continue}if(X==="&")return null;if(X===";"){if(J.trim())Z.push(J.trim());J="";continue}J+=X}if(J.trim())Z.push(J.trim());return Z.length>0?Z:null}function QJ($){let Z=!1,J=!1,W=!1;for(let Y=0;Y<$.length;Y++){let K=$[Y];if(W){W=!1;continue}if(K==="\\"&&!Z){W=!0;continue}if(K==="'"&&!J){Z=!Z;continue}if(K==='"'&&!Z){J=!J;continue}if(Z)continue;if(K==="$"){let Q=$[Y+1];if(Q&&/[A-Za-z_@*#?!$0-9({]/.test(Q))return!0}if(K==="`")return!0;if(J)continue;if(K==="|")return!0;if(K===">"||K==="<")return!0;if(K==="{"){let Q=$.slice(Y);if(/^\{[^}]*,[^}]*\}/.test(Q)||/^\{[^}]*\.\.[^}]*\}/.test(Q))return!0}}return!1}function Q$($){let Z=[],J="",W=!1,Y=!1,K=!1;for(let Q=0;Q<$.length;Q++){let X=$[Q];if(K){J+=X,K=!1;continue}if(X==="\\"&&!W){if(K=!0,Y){let H=$[Q+1];if(H&&'$`"\\'.includes(H))continue;J+=X,K=!1}continue}if(X==="'"&&!Y){W=!W;continue}if(X==='"'&&!W){Y=!Y;continue}if(!W&&!Y&&/[ \t]/.test(X)){if(J)Z.push(J),J="";continue}J+=X}if(J)Z.push(J);return Z}var d4=new Set(["npm","pnpm","yarn","bun"]),XJ=new Set(["biome","eslint","jest","mypy","pyright","pytest","ruff","tsc","vitest"]),c4=new Set(["-u","--fix","--update","--update-snapshot","--updateSnapshot","--watch","--watchAll","--write"]),i4=/[ \t]*;[ \t]*echo[ \t]+"[A-Za-z0-9 _:=.-]*(?:\$\{PIPESTATUS\[0\]\}|\$\?)[A-Za-z0-9 _:=.-]*"[ \t]*$/;function l4($){return $!==void 0&&/^(?:test|lint|build|type-?check)(?::[\w.-]+)*$/i.test($)}function HJ($){return $.replace(/\s+2>&1\s*$/,"").trim()}function r4($,Z,J){if(!J||Z.length!==2)return;let W=/^(.+?)[ \t]+&&[ \t]+([\s\S]+)$/.exec($);if(!W)return;let Y=Q$(W[1]??"");if(Y.length!==2||Y[0]!=="cd")return;let K=Y[1];if(!K||K==="-")return;let Q=X$.isAbsolute(K)?X$.resolve(K):X$.resolve(J,K);if(!H$.isWithinWorkspace(Q,J))return;return W[2]?.trim()||void 0}function n4($){let Z=[],J=!1,W=!1,Y=!1;for(let K=0;K<$.length;K++){let Q=$[K];if(Y){Y=!1;continue}if(Q==="\\"&&!J){Y=!0;continue}if(Q==="'"&&!W){J=!J;continue}if(Q==='"'&&!J){W=!W;continue}if(Q!=="|"||J||W)continue;if($[K+1]==="|")return;Z.push(K)}return Z}function o4($){let Z=Q$($),[J,W,Y]=Z;if(J!=="head"&&J!=="tail")return!1;if(Z.length===1)return!0;let K=(Q)=>Q!==void 0&&/^[1-9]\d{0,4}$/.test(Q);if(Z.length===2)return W?.startsWith("--lines=")&&K(W.slice(8))||W?.startsWith("-")&&K(W.slice(1));return Z.length===3&&(W==="-n"||W==="--lines")&&K(Y)}function a4($){let Z=HJ($.replace(i4,"").trim()),J=n4(Z);if(!J)return;if(J.length===0)return VJ(Z);if(J.length!==1)return;let W=J[0];if(W===void 0)return;let Y=HJ(Z.slice(0,W).trim()),K=Z.slice(W+1).trim();if(!Y||!o4(K))return;return VJ(Y)}function VJ($){let J=$1($)?.at(-1);if(!J)return $;let W=Q$(J),[Y,K]=W;if(!(Y==="vitest"||(Y==="npx"||Y==="bunx")&&K==="vitest")||W.some((X)=>X==="--configLoader"||X.startsWith("--configLoader=")))return $;return`${$} --configLoader runner`}function E$($,Z){let J=a4($);if(!J)return!1;let W=e$(J),Y=$1(W);if(!Y||QJ(W)||/[\r\n]/.test(W))return!1;let K=Y.length===1?Y[0]:r4(W,Y,Z);if(!K)return!1;let Q=Q$(K);if(Q.length===0||Q.some((V)=>[...c4].some((j)=>V===j||V.startsWith(`${j}=`))))return!1;let[X,H,z]=Q;if(d4.has(X??""))return l4(H==="run"?z:H)||H==="--test";if((X==="npx"||X==="bunx")&&XJ.has(H??""))return!0;if(XJ.has(X??""))return!0;if(X==="node"&&H==="--test")return!0;if(X==="go"&&["build","test","vet"].includes(H??""))return!0;return X==="cargo"&&["build","check","clippy","test"].includes(H??"")}function LW($,Z){if($===void 0)return!0;if(typeof $!=="string"||$.split(/[\\/]/).includes(".."))return!1;if(!Z)return!X$.isAbsolute($);let J=X$.isAbsolute($)?X$.resolve($):X$.resolve(Z,$);return H$.isWithinWorkspace(J,Z)}var RZ=G0("Agent"),s4=3;function xZ($,Z,J){if($!=="length")return{action:"none"};if(Z>=s4)return{action:"truncated"};if(JJ(J)==="stop")return RZ.info("[Loop] Token budget: diminishing returns detected, skipping recovery"),{action:"budget_stop"};return{action:"recover"}}var t4=[/:\s*$/,/:\s*$/,/\.\.\.\s*$/,/让我(先|来|开始|查看|检查|修复)/,/Let me (first|start|check|look|fix)/i,/I('ll| will) (now |)(create|write|edit|update|modify|fix|add|implement)/i,/我(现在就|来|要)(创建|写入|编辑|修改|修复|添加|实现)/,/\d+\.\s+(First|Next|Then|Finally)/i],e4=/```[\s\S]{50,}```/,zJ="请执行你提到的操作,不要只是描述。使用 Edit/Write/ApplyPatch/Bash 工具来实际修改文件。",$5=2;function IZ($,Z,J=!0){if(!$||Z>=$5)return{action:"none"};if(!J&&e4.test($))return{action:"retry",prompt:zJ};let W=$.slice(-200),Y=W.match(/```/g);if(Y&&Y.length%2!==0)return{action:"none"};if(t4.some((Q)=>Q.test(W)))return{action:"retry",prompt:zJ};return{action:"none"}}var I1=2,Z5="The model returned tool-call JSON as text instead of completing the requested tool workflow.",J5="The previous response contained tool-call JSON as ordinary text. It did not execute a tool. If the requested operation is still needed, use the native tool-call interface with an available tool. If it already succeeded, use the recorded result to answer instead of repeating the operation. Do not return another tool-call JSON envelope as your final answer.";function hZ($,Z,J,W){if(!$||$.length>65536||J.length===0)return{action:"none"};let Y=Z.replace(/```[\s\S]*?(?:```|$)/g,"").replace(/^\s*>.*$/gm,"");if(/\b(?:example|schema|serialize|serialization|quote|print|illustrate|verbatim)\b|示例|样例|序列化|引用原文/i.test(Y)||/\b(?:explain|show|return|output)\b[^.!?\n]{0,80}\b(?:json|tool.calls?)\b|(?:解释|展示|输出|返回)[^。!?\n]{0,40}(?:JSON|工具调用格式)/i.test(Y)||/\b(?:do not|don't|never)\s+(?:use|call|invoke|execute)\s+(?:any\s+)?tools?\b|不要(?:使用|调用|执行)(?:任何)?工具/i.test(Y))return{action:"none"};let K;try{K=JSON.parse($)}catch{return{action:"none"}}if(!K||typeof K!=="object"||Array.isArray(K)||Object.keys(K).length!==1||!("tool_calls"in K)||!Array.isArray(K.tool_calls)||K.tool_calls.length===0||K.tool_calls.length>32)return{action:"none"};let Q=new Set;for(let X of K.tool_calls){if(!X||typeof X!=="object"||Array.isArray(X))return{action:"none"};let H="function"in X;if(Object.keys(X).some((G)=>!["id","type",...H?["function"]:["name","arguments"]].includes(G)))return{action:"none"};if("type"in X&&X.type!=="function")return{action:"none"};let z=H?X.function:X;if(!z||typeof z!=="object"||Array.isArray(z)||!("name"in z)||typeof z.name!=="string"||!("arguments"in z))return{action:"none"};if(H&&Object.keys(z).some((G)=>G!=="name"&&G!=="arguments"))return{action:"none"};if(!J.includes(z.name))return{action:"none"};let V=z.arguments;if(typeof V!=="string"&&(!V||typeof V!=="object"||Array.isArray(V)))return{action:"none"};let j=z.name.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),B=new RegExp(`(?:^|[.!?。!?;;\\n])\\s*(?:please\\s+)?(?:call|invoke|execute|run|use)\\s+(?:the\\s+)?(?:tool\\s+)?[\`"']?${j}(?![\\w:-])|(?:^|[。!?;\\n])\\s*(?:请)?(?:调用|使用|执行)\\s*(?:工具\\s*)?[\`"']?${j}(?![\\w:-])`,"i"),w=new RegExp(`(?:do not|don't|never)\\s+(?:call|invoke|execute|run|use)\\s+(?:the\\s+)?(?:tool\\s+)?[\`"']?${j}(?![\\w:-])|(?:不要|禁止)(?:调用|使用|执行)\\s*(?:工具\\s*)?[\`"']?${j}(?![\\w:-])`,"i");if(!B.test(Y)||w.test(Y))return{action:"none"};Q.add(z.name)}return W<I1?{action:"retry",prompt:J5,...Q.size===1?{toolName:[...Q][0]}:{}}:{action:"fail",message:Z5}}var W5=[/\b(?:run|execute|rerun|re-run)\b[\s\S]{0,60}\b(?:tests?|test suite|lint|type-?check|build)\b/i,/\b(?:npm|pnpm|yarn|bun)\s+(?:run\s+)?(?:test|lint|build|type-?check)\b/i,/(?:运行|执行|跑|重新运行).{0,30}(?:测试|单测|集成测试|检查|构建)/],BJ={test:/\b(?:tests?|test suite)\b|(?:测试|单测|集成测试)/i,lint:/\blint(?:ing)?\b/i,"type-check":/\btype[\s-]?check(?:ing)?\b|\btsc\b|类型检查/i,build:/\bbuild\b|构建/i},Y5={test:/(?:^|\s)(?:npm|pnpm|yarn|bun)\s+(?:run\s+)?test\b|(?:^|\s)(?:node|bun)\s+--test\b|(?:^|\s)(?:vitest|jest|pytest|go\s+test|cargo\s+test)\b/i,lint:/(?:^|\s)(?:npm|pnpm|yarn|bun)\s+(?:run\s+)?lint\b/i,"type-check":/(?:^|\s)(?:npm|pnpm|yarn|bun)\s+(?:run\s+)?type-?check\b|(?:^|\s)tsc\b/i,build:/(?:^|\s)(?:npm|pnpm|yarn|bun)\s+(?:run\s+)?build\b/i},K5="The user explicitly required verification, but it has not run successfully. Do not finish or explain. Your next action must be a Bash tool call that runs the requested test, lint, type-check, or build command. Inspect the command result and fix any failure before finishing.",Q5="Required verification did not run successfully before the retry limit.",X5=3;function DJ($,Z,J,W){if(!J.success)return;if(["Edit","Write","ApplyPatch","NotebookEdit"].includes(Z)){$.clear();return}if(Z==="Bash"&&typeof J.metadata?.command==="string"&&J.metadata.exit_code===0&&E$(J.metadata.command,W)){$.add(J.metadata.command);return}if(!["Task","TaskOutput"].includes(Z))return;let Y=J.metadata?.verificationCommands;if(!Array.isArray(Y))return;for(let K of Y)if(typeof K==="string"&&E$(K,W))$.add(K)}function vZ($,Z,J){if(!$||!W5.some((H)=>H.test($)))return{action:"none"};let W=Object.keys(BJ).filter((H)=>BJ[H].test($)),Y=[...Z],K=W.filter((H)=>!Y.some((z)=>Y5[H].test(z)));if(W.length>0?K.length===0:Y.some((H)=>E$(H)))return{action:"none"};if(J>=X5)return{action:"fail",message:Q5};let X=W.length>1&&K.length>0?` Missing successful verification categories: ${K.join(", ")}.`:"";return{action:"retry",prompt:`${K5}${X}`}}var H5=[/\bdelegate\b[\s\S]{0,120}\b(?:Task tool|subagent|agent)\b/i,/\b(?:call|use|invoke)\b[\s\S]{0,80}\bTask tool\b/i,/(?:委派|交给|调用|使用).{0,60}(?:Task|子代理|子智能体)/],wJ=[/\b(?:do not|don't|never)\s+(?:delegate|call|use|invoke)\b/i,/(?:不要|禁止|无需)(?:委派|调用|使用).{0,20}(?:Task|子代理|子智能体)?/];function UJ($){return typeof $==="string"&&wJ.some((Z)=>Z.test($))}var V5=[/\b(?:call|use|invoke)\b[\s\S]{0,30}\bTask(?: tool)?\b[\s\S]{0,30}\bexactly once\b/i,/\bexactly once\b[\s\S]{0,30}\b(?:call|use|invoke)\b[\s\S]{0,30}\bTask(?: tool)?\b/i,/\bexactly one\b[\s\S]{0,30}\bTask(?: tool)? calls?\b/i,/(?:Task|子代理).{0,20}(?:恰好|仅|只)(?:调用|使用)?一次/,/(?:恰好|仅|只)(?:调用|使用)?一次.{0,20}(?:Task|子代理)/],z5=[/\b(?:do not|don't|never)\s+(?:call|use|invoke)\s+(?:the\s+)?Task\b[\s\S]{0,30}\bexactly once\b/i,/\bTask\b[\s\S]{0,30}\b(?:does not|doesn't|need not)\b[\s\S]{0,30}\bexactly once\b/i,/\bmultiple\s+Task(?: tool)?\s+calls?\s+(?:are\s+)?allowed\b/i,/(?:不要|禁止).{0,12}(?:Task|子代理).{0,12}(?:恰好|仅|只)(?:调用|使用)?一次/];function B5($){if(typeof $!=="string")return;if(z5.some((Z)=>Z.test($)))return"multiple-allowed";return V5.some((Z)=>Z.test($))?"required":void 0}function Z1($){for(let Z of $){let J=B5(Z);if(J!==void 0)return J==="required"}return!1}var j5="The user explicitly required delegation, but no Task tool call completed successfully. Do not solve the task directly or explain. Your next action must be a Task tool call using the requested subagent.",D5="Required delegation did not complete before the retry limit.",w5=3;function GJ($,Z,J){let W=(typeof $==="string"?[$]:$??[]).map((Q)=>Q.trim()).filter(Boolean),Y=Z1(W),K=!1;if(!Y)for(let Q of W){if(wJ.some((X)=>X.test(Q)))break;if(H5.some((X)=>X.test(Q))){K=!0;break}}if(W.length===0||!Y&&!K||Z.has("Task"))return{action:"none"};if(J>=w5)return{action:"fail",message:D5};return{action:"retry",prompt:j5}}var U5=[/\b(?:use|create|enter|start|work\s+(?:in|inside))\b.{0,60}\bworktree\b/i,/(?:使用|创建|进入).{0,30}(?:worktree|工作树)/i],G5=[/\b(?:exit|leave)\b.{0,40}\bworktree\b/i,/\bworktree\b.{0,60}\b(?:action\s+)?(?:keep|remove)\b/i,/(?:退出|离开).{0,30}(?:worktree|工作树)/i],L5=[/\b(?:do not|don't|never|must not|should not)\b[^.!?;\n]{0,80}\b(?:git\s+)?worktree\b/gi,/\bwithout\b[^.!?;\n]{0,60}\b(?:git\s+)?worktree\b/gi,/(?:不要|禁止|不得|无需)[^。!?;\n]{0,50}(?:worktree|工作树)/gi];function LJ($){return L5.reduce((Z,J)=>Z.replace(J," "),$)}function h1($){if(typeof $!=="string")return!1;let Z=LJ($);return U5.some((J)=>J.test(Z))}var q5="The user explicitly required git worktree isolation, but EnterWorktree has not completed successfully. Do not continue in the original workspace. Your next action must be an EnterWorktree tool call. Wait for its result before using file or Bash tools.",F5="The user explicitly required leaving the managed worktree, but ExitWorktree has not completed successfully. Do not finish or explain. Your next action must be an ExitWorktree tool call using the action requested by the user.",O5="Required worktree lifecycle did not complete before the retry limit.",P5=3;function qJ($,Z,J){if(!$)return{action:"none"};let W=LJ($);if(!h1(W))return{action:"none"};let Y=G5.some((Q)=>Q.test(W));if(Z.has("TaskWorktree"))return{action:"none"};let K=!Z.has("EnterWorktree")?"EnterWorktree":Y&&!Z.has("ExitWorktree")?"ExitWorktree":void 0;if(!K)return{action:"none"};if(J>=P5)return{action:"fail",message:O5};return{action:"retry",tool:K,prompt:K==="EnterWorktree"?q5:F5}}var jJ=30000;async function CZ($){try{let J=T$.getInstance().executeStopHooks({projectDir:$.workspaceRoot??H0(),sessionId:$.sessionId,permissionMode:$.permissionMode,reason:$.reason,abortSignal:$.abortSignal}),W,Y=new Promise((K)=>{W=setTimeout(()=>K("timeout"),jJ)});try{let K=await Promise.race([J,Y]);if(K==="timeout")return RZ.warn(`[Loop] Stop hook 超时 (${jJ}ms),按 shouldStop: true 处理`),{action:"stop"};let Q=K;if(!Q.shouldStop)return{action:"continue",reason:Q.continueReason};return{action:"stop"}}finally{clearTimeout(W)}}catch(Z){return RZ.warn("[Loop] Stop hook execution failed:",Z),{action:"stop"}}}async function N5($,Z){let J;while(!(J=await $.next()).done)if(Z)await Z(J.value);return J.value}var _5=[/<system-reminder>[\s\S]*?<\/system-reminder>/gi,/<file[^>]*>[\s\S]*?<\/file>/gi,/<hooks_context>[\s\S]*?<\/hooks_context>/gi,/<[^>]+>/g];function y5($){if(typeof $==="string")return $;if(Array.isArray($))return $.map((Z)=>{if(typeof Z==="string")return Z;if(Z&&typeof Z==="object"&&"text"in Z){let J=Z.text;return typeof J==="string"?J:""}return""}).join(" ");return""}function b5($){let Z=$;for(let H of _5)Z=Z.replace(H," ");Z=Z.replace(/^\s*\/[a-zA-Z][\w-]*\s+/,"");let J=Z.replace(/\s+/g," ").trim();if(!J)return"";let W=J.match(/^(.+?)(?:[.!?]\s|[。!?](?=\S|$)|$)/),Y=W&&W[1].length>=6?W[1]:J;if(Y=Y.trim().replace(/[\s.。!!??,,;;::-]+$/,""),Y.length<=60)return Y;let K=Y.slice(0,60),Q=K.lastIndexOf(" ");return`${(Q>36?K.slice(0,Q):K).trimEnd()}…`}function FJ($){return b5(y5($))}import{EventEmitter as A5}from"events";import OJ from"node:path";function pZ($){if(NJ($.sessionId),!OJ.isAbsolute($.projectPath))throw Error("projectPath must be absolute");return{sessionId:$.sessionId,projectPath:OJ.resolve($.projectPath)}}function PJ($){let Z=pZ($);return JSON.stringify([Z.projectPath,Z.sessionId])}function fW($,Z){return PJ($)===PJ(Z)}class f$ extends A5{static instance;constructor(){super();this.setMaxListeners(100)}static getInstance(){if(!f$.instance)f$.instance=new f$;return f$.instance}publish($,Z,J,W){let Y=pZ($);this.emit("event",{sessionId:Y.sessionId,projectPath:Y.projectPath,type:Z,...W!==void 0?{seq:W}:{},properties:J})}subscribe($){return this.on("event",$),()=>this.off("event",$)}}var J1=f$.getInstance();var a0=G0("Agent"),v1=new Set;async function E5($,Z){let J=$.sessionId;if(!J||$.subagentInfo)return;if(v1.has(J))return;if(v1.size>=5000)v1.clear();v1.add(J);try{let W=$.workspaceRoot,Y=await W1.findSessionMetadata(J,W);if(!Y)return;if(Y.title&&Y.title.trim())return;let K=FJ(Z);if(!K)return;await W1.updateSessionMetadata(J,Y.projectPath,{title:K}),J1.publish({sessionId:J,projectPath:Y.projectPath},"session.updated",{title:K})}catch(W){a0.debug?.("[Loop] 自动生成会话标题失败:",W)}}var gZ=`<turn_aborted>
2
2
  The previous turn was interrupted. Commands or tool calls may have partially completed; inspect the workspace and running processes before retrying.
3
3
  </turn_aborted>`,V$="Tool execution was blocked because its durable call record could not be committed. No tool side effect was started.",_J="Tool execution completed, but its durable result record could not be committed. Further model and tool execution was stopped. The operation may have completed; inspect external state before retrying.";class k$ extends Error{phase;constructor($,Z){super($==="user_message"?"Conversation input could not be committed. No further model request was started.":"Model output could not be committed. The run was stopped before any further model request or successful completion.",Z);this.phase=$;this.name="DurableConversationPersistenceError"}}function z$($){return $.executionEngine?.getContextManager()}async function d0($,Z,J,W=null,Y,K={}){let Q=K.required??$.executionEngine!==void 0;try{let X=z$($),H=typeof J==="string"?J.trim()!=="":J.some((z)=>z.type==="text"?z.text.trim()!=="":!0);if(X&&Z.sessionId&&H){let z=await X.saveMessage(Z.sessionId,"user",J,W,Y,Z.subagentInfo);if(Q&&!z)throw Error("Durable user-message commit returned no identity");if(Y?.clientVisible!==!1)E5(Z,J);return z}if(Q&&Z.sessionId&&H)throw Error("Durable user-message storage is unavailable")}catch(X){if(a0.warn("[Loop] 保存用户消息失败:",X),Q)throw new k$("user_message",{cause:X})}return null}async function _0($,Z,J,W,Y,K,Q={}){let X=Q.required??$.executionEngine!==void 0;try{let H=z$($),z=Boolean(J.trim()||Y?.trim());if(H&&Z.sessionId&&z){let V=await H.saveMessage(Z.sessionId,"assistant",J,W,K,Z.subagentInfo,Y);if(X&&!V)throw Error("Durable assistant-message commit returned no identity");return V}if(X&&Z.sessionId&&z)throw Error("Durable assistant-message storage is unavailable")}catch(H){if(a0.warn("[Loop] 保存助手消息失败:",H),X)throw new k$("assistant_message",{cause:H})}return null}async function yJ($,Z,J){try{let W=z$($);if(W&&Z.sessionId)return await W.saveMessage(Z.sessionId,"system",gZ,J,void 0,Z.subagentInfo)}catch(W){a0.warn("[Loop] 保存中断边界失败:",W)}return null}async function bJ($,Z,J,W,Y){try{let K=z$($);if(!K||!Z.sessionId||J.length===0)return null;return await K.saveMessage(Z.sessionId,"system",`<contextual-project-instructions-ref count="${J.length}" />`,Y,{contextualProjectRules:!0,ruleReferences:JSON.parse(JSON.stringify(J.map((Q)=>({...Q})))),triggerPaths:[...W]},Z.subagentInfo)}catch(K){a0.warn("[Loop] 保存 contextual project rules provenance 失败:",K)}return null}async function mZ($,Z,J,W,Y,K={}){try{let Q=z$($);if(Q&&Z.sessionId){let X=await Q.saveToolUse(Z.sessionId,J,W,Y,Z.subagentInfo,K.providerToolCallId);if(K.required&&!X)throw Error("Durable tool-use commit returned no identity");return X}if(K.required&&Z.sessionId)throw Error("Durable tool-use storage is unavailable")}catch(Q){if(a0.warn("[Loop] 保存工具调用失败:",Q),K.required)throw Q}return null}async function C1($,Z,J,W,Y,K,Q,X,H,z={}){try{let V=z$($);if(V&&Z.sessionId){let j=await V.saveToolResult(Z.sessionId,J,W,Y,K,Q,Z.subagentInfo,X,H);if(z.required&&!j)throw Error("Durable tool-result commit returned no identity");return j}if(z.required&&Z.sessionId)throw Error("Durable tool-result storage is unavailable")}catch(V){if(a0.warn("[Loop] 保存工具结果失败:",V),z.required)throw V}return null}async function Y1($,Z,J,W,Y={}){try{let K=z$($);if(K&&Z.sessionId){let Q=await K.saveCompaction(Z.sessionId,J,W,null);if(Y.required&&!Q)throw Error("Compaction checkpoint commit returned no identity");return Q||null}if(Y.required&&Z.sessionId)throw Error("Compaction checkpoint storage is unavailable")}catch(K){if(a0.warn("[Loop] 保存压缩数据失败:",K),Y.required)throw K}return null}async function Q0($){let{deps:Z,context:J,state:W,assistantContent:Y,assistantReasoningContent:K,lastMessageUuid:Q,controlPrompt:X}=$;W.appendAssistant({role:"assistant",content:Y,reasoningContent:K});let H=Q,z=await _0(Z,J,Y,H,K);if(z)H=z;if(X!==void 0){let V={role:"user",content:X,metadata:q0};W.appendControl("user",V);let j=await d0(Z,J,X,H,q0);if(j)H=j}return H}import{createHash as R6}from"node:crypto";import{promises as J8}from"node:fs";import W8 from"node:path";import{nanoid as t0}from"nanoid";import*as a from"node:fs/promises";import*as s0 from"node:path";import EJ from"write-file-atomic";var AJ={enabled:!0,maxIndexLines:200};var S5="memory",uZ="MEMORY.md",cZ="<!-- blade:auto-memory-topics:start -->",p1="<!-- blade:auto-memory-topics:end -->",T5={realpath:!1,retries:{retries:5,factor:1.2,minTimeout:20,maxTimeout:100,randomize:!0}},f5=new M$,SJ;function kJ($){return $.trim().replace(/\s+/g," ")}function k5($){return kJ($.replace(/^- \[\d{4}-\d{2}-\d{2}\] /,""))}function M5($){return[cZ,"## Auto-consolidated topics",...$.map((Z)=>`- [${Z}](${Z}.md)`),p1].join(`
4
4
  `)}function R5($,Z){let J=M5(Z),W=$.indexOf(cZ),Y=$.indexOf(p1,Math.max(0,W));if(W>=0&&Y>=W)return $.slice(0,W)+J+$.slice(Y+p1.length);if(!$)return`${J}
@@ -1,4 +1,4 @@
1
- import{p as g,q as R,r as c,s as v,t as d,u as m,v as l}from"./chunk-0ykg98p7.js";import{ha as O,oa as h}from"./chunk-yscyr8zw.js";import"./chunk-nad5spvc.js";import"./chunk-wr5qr81z.js";import"./chunk-whxkwaz1.js";import{bc as w,mc as _}from"./chunk-n39gsnzc.js";import"./chunk-9qxch6sy.js";import{ne as L}from"./chunk-v7pw7a8q.js";import"./chunk-skktstg8.js";import{Se as P}from"./chunk-s14zayxp.js";import"./chunk-b5cz00mt.js";import{xf as y}from"./chunk-3054z3md.js";import{Af as I,Bf as S,zf as C}from"./chunk-gmparnqt.js";import{Cf as M}from"./chunk-yjdyzb5z.js";import"./chunk-crv3sghv.js";import{Zf as A}from"./chunk-qk7n9j5k.js";import"./chunk-x6k5ye1z.js";import"./chunk-v508x7cg.js";import"./chunk-1g7c3f82.js";import"./chunk-3v9epq9s.js";import"./chunk-eexs73bz.js";import"./chunk-pm163dfm.js";import"./chunk-2x63c1gx.js";import"./chunk-nefvj18m.js";import"./chunk-kehgewqh.js";import"./chunk-kkzznz4w.js";import"./chunk-1cy4ab77.js";import"./chunk-7ajvrtb3.js";import"./chunk-c08qbh8h.js";import"./chunk-ys8gysg8.js";import{Fh as F}from"./chunk-6wzwkjep.js";import{Zi as z}from"./chunk-b22ab7yw.js";import"./chunk-amabfzc8.js";import"./chunk-m2x6pb4f.js";import"./chunk-saz6mwpq.js";import"./chunk-xhwdac1j.js";import"./chunk-0eajnhrj.js";import"./chunk-cc9vbgqc.js";import"./chunk-asgmmaec.js";import"./chunk-ed2hdrwe.js";import"./chunk-gmpsfkgg.js";import i from"yargs";import{hideBin as e}from"yargs/helpers";var s=new Set(Object.values(F));function t(j){if(j&&s.has(j))return j;return}function x(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)}
1
+ import{p as g,q as R,r as c,s as v,t as d,u as m,v as l}from"./chunk-t39n33ek.js";import{ha as O,oa as h}from"./chunk-n32pbwyk.js";import"./chunk-nad5spvc.js";import"./chunk-qexnx2v2.js";import"./chunk-whxkwaz1.js";import{bc as w,mc as _}from"./chunk-vnxj21sa.js";import"./chunk-9qxch6sy.js";import{ne as L}from"./chunk-6jjpj5ge.js";import"./chunk-skktstg8.js";import{Se as P}from"./chunk-s14zayxp.js";import"./chunk-b5cz00mt.js";import{xf as y}from"./chunk-rgxknntk.js";import{Af as I,Bf as S,zf as C}from"./chunk-6sk6chsm.js";import{Cf as M}from"./chunk-yjdyzb5z.js";import"./chunk-crv3sghv.js";import{Zf as A}from"./chunk-acxyw1ej.js";import"./chunk-x6k5ye1z.js";import"./chunk-v508x7cg.js";import"./chunk-1g7c3f82.js";import"./chunk-3v9epq9s.js";import"./chunk-eexs73bz.js";import"./chunk-pm163dfm.js";import"./chunk-cfxs7jdk.js";import"./chunk-a1y938pg.js";import"./chunk-kehgewqh.js";import"./chunk-kkzznz4w.js";import"./chunk-1cy4ab77.js";import"./chunk-7ajvrtb3.js";import"./chunk-8yh4mn8a.js";import"./chunk-ys8gysg8.js";import{Fh as F}from"./chunk-ftk0ytf8.js";import{Zi as z}from"./chunk-b22ab7yw.js";import"./chunk-amabfzc8.js";import"./chunk-m2x6pb4f.js";import"./chunk-saz6mwpq.js";import"./chunk-xhwdac1j.js";import"./chunk-0eajnhrj.js";import"./chunk-bzwxh6nq.js";import"./chunk-asgmmaec.js";import"./chunk-ed2hdrwe.js";import"./chunk-gmpsfkgg.js";import i from"yargs";import{hideBin as e}from"yargs/helpers";var s=new Set(Object.values(F));function t(j){if(j&&s.has(j))return j;return}function x(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
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
3
  `);else j.io.stdout.write(`${j.response}
4
4
  `)}function o(j){return j.command("* [message]","Print response and exit (useful for pipes)",(q)=>q.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(q)=>{if(!q.p)return;let G=await jj(q);process.exit(G)})}async function jj(j,q=process){let G;try{await g();let U=j.forkSession!==!0&&(j.continue===!0||typeof j.resume==="string"&&j.resume.length>0)?await c({message:j.message,_:j._}):await R({message:j.message,_:j._,defaultMessage:"Hello"}),Y=U===void 0,K=Y?{mode:"agent",content:""}:await v(U);if(K.mode==="output"){if(K.content)q.stdout.write(`${K.content}
@@ -1,4 +1,4 @@
1
- import{e as B3,f as x3,g as f3,h as r0,i as S3}from"./chunk-4cywnksk.js";import{j as o1}from"./chunk-870szc6v.js";import{w as t0,x as d2,y as T1,z as c1}from"./chunk-g4k4tnsq.js";import{A as c2,B as l2,C as i2,D as m0}from"./chunk-6eznxwsv.js";import{E as h2,F as _$,G as N$,H as B$,I as G0,J as x$}from"./chunk-0bzhkqpe.js";import{$ as C2,Aa as N3,Da as U5,Ia as i3,N as m1,O as l3,R as T2,S as O1,T as i4,V as i1,W as p$,X as A4,Y as j4,Z as W0,_ as I2,aa as M$,ba as F1,da as S2,ea as P2,fa as b4,ga as N0,ha as B0,ka as C4,la as R4,ma as Q5,na as k2,oa as J2,pa as Z3,qa as J3,ra as Q3,sa as Y3,ta as X3,ua as V3,va as z3,wa as G3,xa as K3}from"./chunk-yscyr8zw.js";import{Pa as E$,Va as iO}from"./chunk-wr5qr81z.js";import{$a as E2,Ab as $$,Ya as Z2,_a as R2,ab as f2,gb as V4,jb as a3,kb as n4,lb as y2,mb as m2,nb as o3,ob as t3,pb as a4,qb as s3,rb as v0,sb as M3,tb as L3,ub as A3,vb as g2,wb as v2,xb as p2,yb as u2,zb as H$}from"./chunk-whxkwaz1.js";import{Ob as nO,Pb as i,Rb as m,Sb as q2,bc as _4,mc as g0}from"./chunk-n39gsnzc.js";import{xc as g1}from"./chunk-9qxch6sy.js";import{$d as I4,Hd as M2,Nc as D2,Rd as o0,Sd as q0,Zd as T4,_d as q4,ce as L1,fd as d$,fe as D4,jd as U4,ke as b2,le as M4,me as L4,ne as g}from"./chunk-v7pw7a8q.js";import{Le as L2,Se as A2,Te as j2}from"./chunk-s14zayxp.js";import{mf as b3,qf as T3,rf as q3,sf as I3,tf as C3,uf as p4,vf as R3,wf as E3}from"./chunk-b5cz00mt.js";import{Vf as Z5,Zf as LO,bg as k$,eg as tO}from"./chunk-qk7n9j5k.js";import{fg as l1}from"./chunk-x6k5ye1z.js";import{yg as N2}from"./chunk-pm163dfm.js";import{Ag as D1}from"./chunk-2x63c1gx.js";import{$g as x2,Jg as J5,Mg as $3,Qg as N1,Rg as B1,Vg as L5,Yg as O0,Zg as x1,bh as O$}from"./chunk-nefvj18m.js";import{uh as h$,vh as B2}from"./chunk-1cy4ab77.js";import{Ah as n0,zh as q$}from"./chunk-c08qbh8h.js";import{Ai as F2,Ci as _2,Ih as B4,Pi as I$,Uh as R$,Ui as _1,ii as K2,li as w2,ni as H2,oi as W2,pi as g$,qi as v$,ri as W$,xi as U2}from"./chunk-6wzwkjep.js";import{Zi as KO}from"./chunk-b22ab7yw.js";import{Aj as x4,xj as a1}from"./chunk-m2x6pb4f.js";import{Ej as OO,Gj as h,Ij as z,Jj as sO,Lj as GO}from"./chunk-saz6mwpq.js";import{Qj as P0}from"./chunk-xhwdac1j.js";import{Sj as S$,Tj as z2,Vj as P$,Wj as G2}from"./chunk-0eajnhrj.js";import{Xj as i0}from"./chunk-cc9vbgqc.js";import{ck as e4}from"./chunk-asgmmaec.js";import{Hk as A$,dk as n1,xk as WO,zk as k1}from"./chunk-ed2hdrwe.js";import{Jk as t4}from"./chunk-gmpsfkgg.js";var F8={port:{type:"number",describe:"Port to listen on (0 for auto)",default:0},hostname:{type:"string",describe:"Hostname to listen on",default:"127.0.0.1"},cors:{type:"array",describe:"Additional domains to allow for CORS",default:[]}};function _8(O){return{port:O.port??0,hostname:O.hostname??"127.0.0.1",cors:O.cors??[]}}import{existsSync as Z$,readFileSync as C1}from"node:fs";import{createServer as c6}from"node:http";import{networkInterfaces as l6}from"node:os";import{dirname as i6,extname as n6,join as f0}from"node:path";import{fileURLToPath as a6}from"node:url";import{brotliCompressSync as o6,gzipSync as t6,constants as s6}from"node:zlib";import{Hono as r6}from"hono";import{cors as e6}from"hono/cors";import{WebSocketServer as O8}from"ws";var l0=OO("Service"),y5=30000,m5=new Set(["completed","failed","cancelled","interrupted"]);class z4{dispatch;store;tickMs;timer;unsubscribeBus;ticking=!1;inFlight=new Set;constructor(O){this.dispatch=O.dispatch,this.store=O.store??H$.getInstance(),this.tickMs=O.tickMs??y5}start(){if(this.timer)return;l0.info("[TaskScheduler] Starting scheduler tick loop"),this.timer=setInterval(()=>{this.tick()},this.tickMs),this.timer.unref?.(),this.unsubscribeBus=m.subscribe((O)=>{if(O.type!=="task.status")return;let $=O.properties.taskStatus;if(typeof $!=="string"||!m5.has($))return;this.recordTerminalStatus(O.sessionId,$,typeof O.properties.taskStatusReason==="string"?O.properties.taskStatusReason:void 0)}),this.tick()}stop(){if(this.timer)clearInterval(this.timer),this.timer=void 0,this.unsubscribeBus?.(),this.unsubscribeBus=void 0,l0.info("[TaskScheduler] Stopped scheduler tick loop")}async tick(O=new Date){if(this.ticking)return;this.ticking=!0;try{let $=await this.store.list();for(let Z of $)await this.evaluate(Z,O)}catch($){l0.warn("[TaskScheduler] Tick failed:",$)}finally{this.ticking=!1}}async evaluate(O,$){if(!O.enabled)return;if(this.inFlight.has(O.id))return;if(O.expiresAt&&new Date(O.expiresAt).getTime()<=$.getTime()){await this.store.update(O.id,{enabled:!1,nextRunAt:null}),l0.info(`[TaskScheduler] Schedule ${O.id} expired; disabled`);return}if(!O.nextRunAt)return;if(!(new Date(O.nextRunAt).getTime()<=$.getTime()))return;await this.fire(O,$)}async fire(O,$=new Date,Z={}){if(this.inFlight.has(O.id))throw Error(`Schedule ${O.id} is already dispatching`);this.inFlight.add(O.id);let J=$.toISOString();try{let Y=await this.dispatch({prompt:O.prompt,title:O.title??g5(O),sourceProjectPath:O.projectPath,isolation:O.dispatch.isolation??"worktree",permissionMode:O.dispatch.permissionMode??"default",modelId:O.dispatch.modelId,reasoningEffort:O.dispatch.reasoningEffort,serviceTier:O.dispatch.serviceTier,responseVerbosity:O.dispatch.responseVerbosity,communicationStyle:O.dispatch.communicationStyle}),X=O.trigger.kind==="once"?null:Z.manual?O.nextRunAt?new Date(O.nextRunAt):null:V4(O.trigger,$,$);await this.store.update(O.id,{lastRunAt:J,lastRunSessionId:Y.session.sessionId,lastStatus:Y.status,lastError:void 0,runCount:O.runCount+1,nextRunAt:X?X.toISOString():null,enabled:O.trigger.kind==="once"?!1:O.enabled}),m.publish({sessionId:Y.session.sessionId,projectPath:O.projectPath},"schedule.fired",{scheduleId:O.id,firedAt:J,sessionId:Y.session.sessionId,runId:Y.runId,status:Y.status}),l0.info(`[TaskScheduler] Fired schedule ${O.id} -> session ${Y.session.sessionId} (${Y.status})`)}catch(Y){let X=Y instanceof Error?Y.message:String(Y);l0.warn(`[TaskScheduler] Schedule ${O.id} dispatch failed:`,Y);let G=O.trigger.kind==="once"?null:Z.manual?O.nextRunAt?new Date(O.nextRunAt):null:V4(O.trigger,$,$);await this.store.update(O.id,{lastRunAt:J,lastStatus:"error",lastError:X,nextRunAt:G?G.toISOString():null,enabled:O.trigger.kind==="once"?!1:O.enabled})}finally{this.inFlight.delete(O.id)}}async recordTerminalStatus(O,$,Z){let Y=(await this.store.list()).find((X)=>X.lastRunSessionId===O);if(!Y)return;await this.store.update(Y.id,{lastStatus:$,...Z?{lastError:Z}:{lastError:void 0}})}}function g5(O){return`Scheduled: ${O.prompt.trim().replace(/\s+/g," ").slice(0,60)}`}class wO extends Error{code;statusCode;details;constructor(O,$,Z=500,J){super($);this.code=O;this.statusCode=Z;this.details=J;this.name="BladeServerError"}toObject(){return{error:{code:this.code,message:this.message,...this.details?{details:this.details}:{}}}}}class c extends wO{constructor(O,$){super("NOT_FOUND",$?`${O} not found: ${$}`:`${O} not found`,404)}}class F extends wO{constructor(O){super("BAD_REQUEST",O,400)}}class v extends wO{constructor(O){super("CONFLICT",O,409)}}class eO extends wO{constructor(O,$){super("TOO_MANY_REQUESTS",O,429,$)}}class MO extends wO{constructor(O="Server is shutting down"){super("SERVICE_UNAVAILABLE",O,503)}}class b0 extends wO{constructor(O){super("SESSION_WORKSPACE_UNAVAILABLE","This session workspace is no longer available",409,{reason:O})}}class lO extends wO{constructor(){super("AMBIGUOUS_SESSION","Multiple workspaces contain this session ID; projectPath is required",409)}}class zO extends wO{constructor(O="Internal server error"){super("INTERNAL_ERROR",O,500)}}var j8=z.Object({error:z.Object({code:z.String(),message:z.String(),details:z.Optional(z.Record(z.String(),z.Unknown()))})});import{Hono as v5}from"hono";var G4=OO("Service"),p5=z.Object({updates:z.Record(z.String(),z.Any()),options:z.Optional(z.Object({scope:z.Optional(GO(["local","project","global"])),immediate:z.Optional(z.Boolean())}))});function u5(O){return{currentModelId:O.currentModelId,permissionMode:O.permissionMode,language:O.language,codeTheme:O.codeTheme,uiTheme:O.uiTheme,autoSaveSessions:O.autoSaveSessions,notifyBuild:O.notifyBuild,notifyErrors:O.notifyErrors,notifySounds:O.notifySounds,privacyTelemetry:O.privacyTelemetry,privacyCrash:O.privacyCrash,agentTeamsEnabled:O.agentTeamsEnabled===!0,communicationStyle:O.communicationStyle,maxConcurrentTasks:O.maxConcurrentTasks,maxQueuedTasks:O.maxQueuedTasks,maxQueuedTaskBytes:O.maxQueuedTaskBytes,maxResidentSessionRuntimes:O.maxResidentSessionRuntimes,sessionRuntimeIdleMs:O.sessionRuntimeIdleMs,maxResidentSessionProjections:O.maxResidentSessionProjections,sessionProjectionIdleMs:O.sessionProjectionIdleMs}}var U$=()=>{let O=new v5;return O.get("/",async($)=>{try{let Z=LO();return $.json(Z?u5(Z):{})}catch(Z){return G4.error("[ConfigRoutes] Failed to get config:",Z),$.json({})}}),O.put("/",async($)=>{try{let Z=await $.req.json(),J=h(p5,Z);if(!J.success)throw new F("Invalid config update format");let{updates:Y,options:X}=J.data;return await tO().updateConfig(Y,X),$.json({success:!0,updates:Y})}catch(Z){if(Z instanceof W$)throw new F(Z.message);throw G4.error("[ConfigRoutes] Failed to update config:",Z),Z}}),O.get("/permissions",async($)=>{try{let Z=LO();return $.json(Z?.permissions||{})}catch(Z){return G4.error("[ConfigRoutes] Failed to get permissions:",Z),$.json({})}}),O};import{Hono as d5}from"hono";import{streamSSE as c5}from"hono/streaming";function F$(O){let $="";if(O.id!==void 0)$+=`id: ${O.id}
1
+ import{e as B3,f as x3,g as f3,h as r0,i as S3}from"./chunk-nh301gpr.js";import{j as o1}from"./chunk-870szc6v.js";import{w as t0,x as d2,y as T1,z as c1}from"./chunk-87bd1w02.js";import{A as c2,B as l2,C as i2,D as m0}from"./chunk-fprmcxd6.js";import{E as h2,F as _$,G as N$,H as B$,I as G0,J as x$}from"./chunk-nneh4gkw.js";import{$ as C2,Aa as N3,Da as U5,Ia as i3,N as m1,O as l3,R as T2,S as O1,T as i4,V as i1,W as p$,X as A4,Y as j4,Z as W0,_ as I2,aa as M$,ba as F1,da as S2,ea as P2,fa as b4,ga as N0,ha as B0,ka as C4,la as R4,ma as Q5,na as k2,oa as J2,pa as Z3,qa as J3,ra as Q3,sa as Y3,ta as X3,ua as V3,va as z3,wa as G3,xa as K3}from"./chunk-n32pbwyk.js";import{Pa as E$,Va as iO}from"./chunk-qexnx2v2.js";import{$a as E2,Ab as $$,Ya as Z2,_a as R2,ab as f2,gb as V4,jb as a3,kb as n4,lb as y2,mb as m2,nb as o3,ob as t3,pb as a4,qb as s3,rb as v0,sb as M3,tb as L3,ub as A3,vb as g2,wb as v2,xb as p2,yb as u2,zb as H$}from"./chunk-whxkwaz1.js";import{Ob as nO,Pb as i,Rb as m,Sb as q2,bc as _4,mc as g0}from"./chunk-vnxj21sa.js";import{xc as g1}from"./chunk-9qxch6sy.js";import{$d as I4,Hd as M2,Nc as D2,Rd as o0,Sd as q0,Zd as T4,_d as q4,ce as L1,fd as d$,fe as D4,jd as U4,ke as b2,le as M4,me as L4,ne as g}from"./chunk-6jjpj5ge.js";import{Le as L2,Se as A2,Te as j2}from"./chunk-s14zayxp.js";import{mf as b3,qf as T3,rf as q3,sf as I3,tf as C3,uf as p4,vf as R3,wf as E3}from"./chunk-b5cz00mt.js";import{Vf as Z5,Zf as LO,bg as k$,eg as tO}from"./chunk-acxyw1ej.js";import{fg as l1}from"./chunk-x6k5ye1z.js";import{yg as N2}from"./chunk-pm163dfm.js";import{Ag as D1}from"./chunk-cfxs7jdk.js";import{$g as x2,Jg as J5,Mg as $3,Qg as N1,Rg as B1,Vg as L5,Yg as O0,Zg as x1,bh as O$}from"./chunk-a1y938pg.js";import{uh as h$,vh as B2}from"./chunk-1cy4ab77.js";import{Ah as n0,zh as q$}from"./chunk-8yh4mn8a.js";import{Ai as F2,Ci as _2,Ih as B4,Pi as I$,Uh as R$,Ui as _1,ii as K2,li as w2,ni as H2,oi as W2,pi as g$,qi as v$,ri as W$,xi as U2}from"./chunk-ftk0ytf8.js";import{Zi as KO}from"./chunk-b22ab7yw.js";import{Aj as x4,xj as a1}from"./chunk-m2x6pb4f.js";import{Ej as OO,Gj as h,Ij as z,Jj as sO,Lj as GO}from"./chunk-saz6mwpq.js";import{Qj as P0}from"./chunk-xhwdac1j.js";import{Sj as S$,Tj as z2,Vj as P$,Wj as G2}from"./chunk-0eajnhrj.js";import{Xj as i0}from"./chunk-bzwxh6nq.js";import{ck as e4}from"./chunk-asgmmaec.js";import{Hk as A$,dk as n1,xk as WO,zk as k1}from"./chunk-ed2hdrwe.js";import{Jk as t4}from"./chunk-gmpsfkgg.js";var F8={port:{type:"number",describe:"Port to listen on (0 for auto)",default:0},hostname:{type:"string",describe:"Hostname to listen on",default:"127.0.0.1"},cors:{type:"array",describe:"Additional domains to allow for CORS",default:[]}};function _8(O){return{port:O.port??0,hostname:O.hostname??"127.0.0.1",cors:O.cors??[]}}import{existsSync as Z$,readFileSync as C1}from"node:fs";import{createServer as c6}from"node:http";import{networkInterfaces as l6}from"node:os";import{dirname as i6,extname as n6,join as f0}from"node:path";import{fileURLToPath as a6}from"node:url";import{brotliCompressSync as o6,gzipSync as t6,constants as s6}from"node:zlib";import{Hono as r6}from"hono";import{cors as e6}from"hono/cors";import{WebSocketServer as O8}from"ws";var l0=OO("Service"),y5=30000,m5=new Set(["completed","failed","cancelled","interrupted"]);class z4{dispatch;store;tickMs;timer;unsubscribeBus;ticking=!1;inFlight=new Set;constructor(O){this.dispatch=O.dispatch,this.store=O.store??H$.getInstance(),this.tickMs=O.tickMs??y5}start(){if(this.timer)return;l0.info("[TaskScheduler] Starting scheduler tick loop"),this.timer=setInterval(()=>{this.tick()},this.tickMs),this.timer.unref?.(),this.unsubscribeBus=m.subscribe((O)=>{if(O.type!=="task.status")return;let $=O.properties.taskStatus;if(typeof $!=="string"||!m5.has($))return;this.recordTerminalStatus(O.sessionId,$,typeof O.properties.taskStatusReason==="string"?O.properties.taskStatusReason:void 0)}),this.tick()}stop(){if(this.timer)clearInterval(this.timer),this.timer=void 0,this.unsubscribeBus?.(),this.unsubscribeBus=void 0,l0.info("[TaskScheduler] Stopped scheduler tick loop")}async tick(O=new Date){if(this.ticking)return;this.ticking=!0;try{let $=await this.store.list();for(let Z of $)await this.evaluate(Z,O)}catch($){l0.warn("[TaskScheduler] Tick failed:",$)}finally{this.ticking=!1}}async evaluate(O,$){if(!O.enabled)return;if(this.inFlight.has(O.id))return;if(O.expiresAt&&new Date(O.expiresAt).getTime()<=$.getTime()){await this.store.update(O.id,{enabled:!1,nextRunAt:null}),l0.info(`[TaskScheduler] Schedule ${O.id} expired; disabled`);return}if(!O.nextRunAt)return;if(!(new Date(O.nextRunAt).getTime()<=$.getTime()))return;await this.fire(O,$)}async fire(O,$=new Date,Z={}){if(this.inFlight.has(O.id))throw Error(`Schedule ${O.id} is already dispatching`);this.inFlight.add(O.id);let J=$.toISOString();try{let Y=await this.dispatch({prompt:O.prompt,title:O.title??g5(O),sourceProjectPath:O.projectPath,isolation:O.dispatch.isolation??"worktree",permissionMode:O.dispatch.permissionMode??"default",modelId:O.dispatch.modelId,reasoningEffort:O.dispatch.reasoningEffort,serviceTier:O.dispatch.serviceTier,responseVerbosity:O.dispatch.responseVerbosity,communicationStyle:O.dispatch.communicationStyle}),X=O.trigger.kind==="once"?null:Z.manual?O.nextRunAt?new Date(O.nextRunAt):null:V4(O.trigger,$,$);await this.store.update(O.id,{lastRunAt:J,lastRunSessionId:Y.session.sessionId,lastStatus:Y.status,lastError:void 0,runCount:O.runCount+1,nextRunAt:X?X.toISOString():null,enabled:O.trigger.kind==="once"?!1:O.enabled}),m.publish({sessionId:Y.session.sessionId,projectPath:O.projectPath},"schedule.fired",{scheduleId:O.id,firedAt:J,sessionId:Y.session.sessionId,runId:Y.runId,status:Y.status}),l0.info(`[TaskScheduler] Fired schedule ${O.id} -> session ${Y.session.sessionId} (${Y.status})`)}catch(Y){let X=Y instanceof Error?Y.message:String(Y);l0.warn(`[TaskScheduler] Schedule ${O.id} dispatch failed:`,Y);let G=O.trigger.kind==="once"?null:Z.manual?O.nextRunAt?new Date(O.nextRunAt):null:V4(O.trigger,$,$);await this.store.update(O.id,{lastRunAt:J,lastStatus:"error",lastError:X,nextRunAt:G?G.toISOString():null,enabled:O.trigger.kind==="once"?!1:O.enabled})}finally{this.inFlight.delete(O.id)}}async recordTerminalStatus(O,$,Z){let Y=(await this.store.list()).find((X)=>X.lastRunSessionId===O);if(!Y)return;await this.store.update(Y.id,{lastStatus:$,...Z?{lastError:Z}:{lastError:void 0}})}}function g5(O){return`Scheduled: ${O.prompt.trim().replace(/\s+/g," ").slice(0,60)}`}class wO extends Error{code;statusCode;details;constructor(O,$,Z=500,J){super($);this.code=O;this.statusCode=Z;this.details=J;this.name="BladeServerError"}toObject(){return{error:{code:this.code,message:this.message,...this.details?{details:this.details}:{}}}}}class c extends wO{constructor(O,$){super("NOT_FOUND",$?`${O} not found: ${$}`:`${O} not found`,404)}}class F extends wO{constructor(O){super("BAD_REQUEST",O,400)}}class v extends wO{constructor(O){super("CONFLICT",O,409)}}class eO extends wO{constructor(O,$){super("TOO_MANY_REQUESTS",O,429,$)}}class MO extends wO{constructor(O="Server is shutting down"){super("SERVICE_UNAVAILABLE",O,503)}}class b0 extends wO{constructor(O){super("SESSION_WORKSPACE_UNAVAILABLE","This session workspace is no longer available",409,{reason:O})}}class lO extends wO{constructor(){super("AMBIGUOUS_SESSION","Multiple workspaces contain this session ID; projectPath is required",409)}}class zO extends wO{constructor(O="Internal server error"){super("INTERNAL_ERROR",O,500)}}var j8=z.Object({error:z.Object({code:z.String(),message:z.String(),details:z.Optional(z.Record(z.String(),z.Unknown()))})});import{Hono as v5}from"hono";var G4=OO("Service"),p5=z.Object({updates:z.Record(z.String(),z.Any()),options:z.Optional(z.Object({scope:z.Optional(GO(["local","project","global"])),immediate:z.Optional(z.Boolean())}))});function u5(O){return{currentModelId:O.currentModelId,permissionMode:O.permissionMode,language:O.language,codeTheme:O.codeTheme,uiTheme:O.uiTheme,autoSaveSessions:O.autoSaveSessions,notifyBuild:O.notifyBuild,notifyErrors:O.notifyErrors,notifySounds:O.notifySounds,privacyTelemetry:O.privacyTelemetry,privacyCrash:O.privacyCrash,agentTeamsEnabled:O.agentTeamsEnabled===!0,communicationStyle:O.communicationStyle,maxConcurrentTasks:O.maxConcurrentTasks,maxQueuedTasks:O.maxQueuedTasks,maxQueuedTaskBytes:O.maxQueuedTaskBytes,maxResidentSessionRuntimes:O.maxResidentSessionRuntimes,sessionRuntimeIdleMs:O.sessionRuntimeIdleMs,maxResidentSessionProjections:O.maxResidentSessionProjections,sessionProjectionIdleMs:O.sessionProjectionIdleMs}}var U$=()=>{let O=new v5;return O.get("/",async($)=>{try{let Z=LO();return $.json(Z?u5(Z):{})}catch(Z){return G4.error("[ConfigRoutes] Failed to get config:",Z),$.json({})}}),O.put("/",async($)=>{try{let Z=await $.req.json(),J=h(p5,Z);if(!J.success)throw new F("Invalid config update format");let{updates:Y,options:X}=J.data;return await tO().updateConfig(Y,X),$.json({success:!0,updates:Y})}catch(Z){if(Z instanceof W$)throw new F(Z.message);throw G4.error("[ConfigRoutes] Failed to update config:",Z),Z}}),O.get("/permissions",async($)=>{try{let Z=LO();return $.json(Z?.permissions||{})}catch(Z){return G4.error("[ConfigRoutes] Failed to get permissions:",Z),$.json({})}}),O};import{Hono as d5}from"hono";import{streamSSE as c5}from"hono/streaming";function F$(O){let $="";if(O.id!==void 0)$+=`id: ${O.id}
2
2
  `;if(O.event!==void 0)$+=`event: ${O.event}
3
3
  `;for(let Z of O.data.split(/\r\n|\r|\n/))$+=`data: ${Z}
4
4
  `;if(O.retry!==void 0)$+=`retry: ${O.retry}
@@ -1,2 +1,2 @@
1
- import{Xj as I}from"./chunk-cc9vbgqc.js";import{Jk as f}from"./chunk-gmpsfkgg.js";import*as j from"fs/promises";import*as S from"path";import X from"semver";import{ProxyAgent as R,fetch as k}from"undici";function x(){return process.env.HTTPS_PROXY||process.env.HTTP_PROXY||process.env.https_proxy||process.env.http_proxy}function L(){let z=x();if(z)try{return new R(z)}catch(q){console.warn(`[proxyFetch] Invalid proxy URL: ${z}`)}return}async function F(z,q,Z){let{timeout:W=30000,signal:J,...Q}=q;if(J?.aborted)throw new DOMException("The operation was aborted.","AbortError");let Y=L(),$=new AbortController,w=!1,y=setTimeout(()=>{w=!0,$.abort()},W),T=()=>$.abort();J?.addEventListener("abort",T);let D;try{let B={method:Q.method,headers:Q.headers,body:Q.body,signal:$.signal,dispatcher:Y};return D=await k(z.toString(),B),await Z(D)}catch(B){if(B instanceof Error&&B.name==="AbortError"){if(w)throw Error(`Request timeout after ${W}ms`);throw B}throw B}finally{if(clearTimeout(y),J?.removeEventListener("abort",T),$.abort(),D?.body&&!D.body.locked)await D.body.cancel().catch(()=>{return});await Y?.destroy?.().catch(()=>{return})}}var O="blade-code",G="https://cdn.jsdelivr.net/npm/blade-code@latest/CHANGELOG.md",H=S.join(process.env.HOME||process.env.USERPROFILE||".",".blade"),N=S.join(H,"version-cache.json"),_=3600000,g=`https://registry.npmjs.org/${O}/latest`,M=null;async function P(){try{if(process.env.BLADE_VERSION)return process.env.BLADE_VERSION;return I()}catch{return"unknown"}}async function b(){try{let z=await j.readFile(N,"utf-8"),q=JSON.parse(z);if(Date.now()-q.checkedAt<_)return q;return{...q,checkedAt:0}}catch{return null}}async function K(z){try{await j.mkdir(H,{recursive:!0,mode:493}),await j.writeFile(N,JSON.stringify(z,null,2))}catch{}}async function E(){try{return await F(g,{timeout:5000,headers:{Accept:"application/json"}},async(z)=>{if(!z.ok)return null;let q=await z.json();if(!q||typeof q!=="object"||!("version"in q))return null;return typeof q.version==="string"&&X.valid(q.version)?q.version:null})}catch{return null}}async function A(z=!1){let q=await P(),Z=G;if(q==="unknown")return{currentVersion:q,latestVersion:null,hasUpdate:!1,shouldPrompt:!1,releaseNotesUrl:Z,error:"Unable to determine current version"};let W=await b(),J=W?.skipUntilVersion,Q=null;if(!z&&W?.latestVersion&&W.checkedAt>0)Q=W.latestVersion;else if(Q=await E(),J=(await b())?.skipUntilVersion??J,Q)await K({latestVersion:Q,checkedAt:Date.now(),skipUntilVersion:J});else if(W?.latestVersion)await K({checkedAt:0,skipUntilVersion:J});if(!Q||!X.valid(Q))return{currentVersion:q,latestVersion:null,hasUpdate:!1,shouldPrompt:!1,releaseNotesUrl:Z,error:"Unable to check for updates"};if(X.lt(Q,q))Q=q,await K({latestVersion:Q,checkedAt:Date.now(),skipUntilVersion:J});let Y=X.gt(Q,q),$=Y;if(Y&&J)$=X.gt(Q,J);return{currentVersion:q,latestVersion:Q,hasUpdate:Y,shouldPrompt:$,releaseNotesUrl:Z}}async function V(z){let q=await b();await K({latestVersion:q?.latestVersion??z,checkedAt:q?.checkedAt||Date.now(),skipUntilVersion:z})}function v(){return`npm install -g ${O}@latest --registry https://registry.npmjs.org`}async function p(){let{spawn:z}=await import("child_process");return new Promise((q)=>{let Z=v(),W=z(Z,{stdio:"inherit",shell:!0});W.on("close",(J)=>{if(J===0)q({success:!0,message:"Upgrade successful! Please restart blade."});else q({success:!1,message:`Upgrade failed (exit code: ${J})`})}),W.on("error",(J)=>{q({success:!1,message:`Upgrade failed: ${J.message}`})})})}async function h(){try{let z=await b();if(!z?.latestVersion||!X.valid(z.latestVersion)||!z.checkedAt){if(!M)M=A(!0).then(()=>{return},()=>{return}).finally(()=>{M=null});return null}let q=await P();if(!X.valid(q)||!X.gt(z.latestVersion,q)||z.skipUntilVersion&&X.valid(z.skipUntilVersion)&&!X.gt(z.latestVersion,z.skipUntilVersion))return null;return{currentVersion:q,latestVersion:z.latestVersion,hasUpdate:!0,shouldPrompt:!0,releaseNotesUrl:G}}catch{return null}}
1
+ import{Xj as I}from"./chunk-bzwxh6nq.js";import{Jk as f}from"./chunk-gmpsfkgg.js";import*as j from"fs/promises";import*as S from"path";import X from"semver";import{ProxyAgent as R,fetch as k}from"undici";function x(){return process.env.HTTPS_PROXY||process.env.HTTP_PROXY||process.env.https_proxy||process.env.http_proxy}function L(){let z=x();if(z)try{return new R(z)}catch(q){console.warn(`[proxyFetch] Invalid proxy URL: ${z}`)}return}async function F(z,q,Z){let{timeout:W=30000,signal:J,...Q}=q;if(J?.aborted)throw new DOMException("The operation was aborted.","AbortError");let Y=L(),$=new AbortController,w=!1,y=setTimeout(()=>{w=!0,$.abort()},W),T=()=>$.abort();J?.addEventListener("abort",T);let D;try{let B={method:Q.method,headers:Q.headers,body:Q.body,signal:$.signal,dispatcher:Y};return D=await k(z.toString(),B),await Z(D)}catch(B){if(B instanceof Error&&B.name==="AbortError"){if(w)throw Error(`Request timeout after ${W}ms`);throw B}throw B}finally{if(clearTimeout(y),J?.removeEventListener("abort",T),$.abort(),D?.body&&!D.body.locked)await D.body.cancel().catch(()=>{return});await Y?.destroy?.().catch(()=>{return})}}var O="blade-code",G="https://cdn.jsdelivr.net/npm/blade-code@latest/CHANGELOG.md",H=S.join(process.env.HOME||process.env.USERPROFILE||".",".blade"),N=S.join(H,"version-cache.json"),_=3600000,g=`https://registry.npmjs.org/${O}/latest`,M=null;async function P(){try{if(process.env.BLADE_VERSION)return process.env.BLADE_VERSION;return I()}catch{return"unknown"}}async function b(){try{let z=await j.readFile(N,"utf-8"),q=JSON.parse(z);if(Date.now()-q.checkedAt<_)return q;return{...q,checkedAt:0}}catch{return null}}async function K(z){try{await j.mkdir(H,{recursive:!0,mode:493}),await j.writeFile(N,JSON.stringify(z,null,2))}catch{}}async function E(){try{return await F(g,{timeout:5000,headers:{Accept:"application/json"}},async(z)=>{if(!z.ok)return null;let q=await z.json();if(!q||typeof q!=="object"||!("version"in q))return null;return typeof q.version==="string"&&X.valid(q.version)?q.version:null})}catch{return null}}async function A(z=!1){let q=await P(),Z=G;if(q==="unknown")return{currentVersion:q,latestVersion:null,hasUpdate:!1,shouldPrompt:!1,releaseNotesUrl:Z,error:"Unable to determine current version"};let W=await b(),J=W?.skipUntilVersion,Q=null;if(!z&&W?.latestVersion&&W.checkedAt>0)Q=W.latestVersion;else if(Q=await E(),J=(await b())?.skipUntilVersion??J,Q)await K({latestVersion:Q,checkedAt:Date.now(),skipUntilVersion:J});else if(W?.latestVersion)await K({checkedAt:0,skipUntilVersion:J});if(!Q||!X.valid(Q))return{currentVersion:q,latestVersion:null,hasUpdate:!1,shouldPrompt:!1,releaseNotesUrl:Z,error:"Unable to check for updates"};if(X.lt(Q,q))Q=q,await K({latestVersion:Q,checkedAt:Date.now(),skipUntilVersion:J});let Y=X.gt(Q,q),$=Y;if(Y&&J)$=X.gt(Q,J);return{currentVersion:q,latestVersion:Q,hasUpdate:Y,shouldPrompt:$,releaseNotesUrl:Z}}async function V(z){let q=await b();await K({latestVersion:q?.latestVersion??z,checkedAt:q?.checkedAt||Date.now(),skipUntilVersion:z})}function v(){return`npm install -g ${O}@latest --registry https://registry.npmjs.org`}async function p(){let{spawn:z}=await import("child_process");return new Promise((q)=>{let Z=v(),W=z(Z,{stdio:"inherit",shell:!0});W.on("close",(J)=>{if(J===0)q({success:!0,message:"Upgrade successful! Please restart blade."});else q({success:!1,message:`Upgrade failed (exit code: ${J})`})}),W.on("error",(J)=>{q({success:!1,message:`Upgrade failed: ${J.message}`})})})}async function h(){try{let z=await b();if(!z?.latestVersion||!X.valid(z.latestVersion)||!z.checkedAt){if(!M)M=A(!0).then(()=>{return},()=>{return}).finally(()=>{M=null});return null}let q=await P();if(!X.valid(q)||!X.gt(z.latestVersion,q)||z.skipUntilVersion&&X.valid(z.skipUntilVersion)&&!X.gt(z.latestVersion,z.skipUntilVersion))return null;return{currentVersion:q,latestVersion:z.latestVersion,hasUpdate:!0,shouldPrompt:!0,releaseNotesUrl:G}}catch{return null}}
2
2
  export{A as k,V as l,v as m,p as n,h as o};
@@ -1,4 +1,4 @@
1
- import{Va as H}from"./chunk-wr5qr81z.js";import"./chunk-9qxch6sy.js";import"./chunk-skktstg8.js";import{cg as $,eg as T}from"./chunk-qk7n9j5k.js";import"./chunk-x6k5ye1z.js";import"./chunk-v508x7cg.js";import"./chunk-c08qbh8h.js";import"./chunk-ys8gysg8.js";import"./chunk-6wzwkjep.js";import{Zi as k}from"./chunk-b22ab7yw.js";import"./chunk-amabfzc8.js";import"./chunk-m2x6pb4f.js";import"./chunk-saz6mwpq.js";import"./chunk-xhwdac1j.js";import"./chunk-0eajnhrj.js";import"./chunk-cc9vbgqc.js";import"./chunk-asgmmaec.js";import"./chunk-ed2hdrwe.js";import"./chunk-gmpsfkgg.js";import U from"os";import J from"path";function X(z){return typeof z==="string"?z:void 0}function N(z){if(!Array.isArray(z))return;let q=[];for(let K of z)if(typeof K==="string")q.push(K);else if(K!=null)q.push(String(K));return q}function b(){console.log(`
1
+ import{Va as H}from"./chunk-qexnx2v2.js";import"./chunk-9qxch6sy.js";import"./chunk-skktstg8.js";import{cg as $,eg as T}from"./chunk-acxyw1ej.js";import"./chunk-x6k5ye1z.js";import"./chunk-v508x7cg.js";import"./chunk-8yh4mn8a.js";import"./chunk-ys8gysg8.js";import"./chunk-ftk0ytf8.js";import{Zi as k}from"./chunk-b22ab7yw.js";import"./chunk-amabfzc8.js";import"./chunk-m2x6pb4f.js";import"./chunk-saz6mwpq.js";import"./chunk-xhwdac1j.js";import"./chunk-0eajnhrj.js";import"./chunk-bzwxh6nq.js";import"./chunk-asgmmaec.js";import"./chunk-ed2hdrwe.js";import"./chunk-gmpsfkgg.js";import U from"os";import J from"path";function X(z){return typeof z==="string"?z:void 0}function N(z){if(!Array.isArray(z))return;let q=[];for(let K of z)if(typeof K==="string")q.push(K);else if(K!=null)q.push(String(K));return q}function b(){console.log(`
2
2
  blade mcp
3
3
  `),console.log(`管理 MCP 服务器
4
4
  `),console.log("Commands:"),console.log(" blade mcp add <name> <commandOrUrl> [args...] 添加 MCP 服务器"),console.log(" blade mcp remove <name> 删除 MCP 服务器 [aliases: rm]"),console.log(" blade mcp list 列出所有 MCP 服务器并检查健康状态 [aliases: ls]"),console.log(" blade mcp get <name> 获取服务器详情"),console.log(" blade mcp login <name> 登录远程 MCP OAuth"),console.log(" blade mcp logout <name> 清除远程 MCP OAuth 凭证"),console.log(` blade mcp add-json <name> <json> 从 JSON 字符串添加服务器
@@ -1 +1 @@
1
- import{$b as d,Ub as a,Vb as b,Xb as c,ac as e,bc as f,cc as g,dc as h,ec as i,fc as j,gc as k,pc as l,qc as m,rc as n,sc as o,uc as p,vc as q,wc as r}from"./chunk-n39gsnzc.js";import"./chunk-9qxch6sy.js";import"./chunk-v7pw7a8q.js";import"./chunk-skktstg8.js";import"./chunk-s14zayxp.js";import"./chunk-b5cz00mt.js";import"./chunk-x6k5ye1z.js";import"./chunk-v508x7cg.js";import"./chunk-1g7c3f82.js";import"./chunk-3v9epq9s.js";import"./chunk-pm163dfm.js";import"./chunk-kehgewqh.js";import"./chunk-kkzznz4w.js";import"./chunk-1cy4ab77.js";import"./chunk-c08qbh8h.js";import"./chunk-ys8gysg8.js";import"./chunk-6wzwkjep.js";import"./chunk-b22ab7yw.js";import"./chunk-amabfzc8.js";import"./chunk-m2x6pb4f.js";import"./chunk-saz6mwpq.js";import"./chunk-xhwdac1j.js";import"./chunk-0eajnhrj.js";import"./chunk-cc9vbgqc.js";import"./chunk-asgmmaec.js";import"./chunk-ed2hdrwe.js";import"./chunk-gmpsfkgg.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};
1
+ import{$b as d,Ub as a,Vb as b,Xb as c,ac as e,bc as f,cc as g,dc as h,ec as i,fc as j,gc as k,pc as l,qc as m,rc as n,sc as o,uc as p,vc as q,wc as r}from"./chunk-vnxj21sa.js";import"./chunk-9qxch6sy.js";import"./chunk-6jjpj5ge.js";import"./chunk-skktstg8.js";import"./chunk-s14zayxp.js";import"./chunk-b5cz00mt.js";import"./chunk-x6k5ye1z.js";import"./chunk-v508x7cg.js";import"./chunk-1g7c3f82.js";import"./chunk-3v9epq9s.js";import"./chunk-pm163dfm.js";import"./chunk-kehgewqh.js";import"./chunk-kkzznz4w.js";import"./chunk-1cy4ab77.js";import"./chunk-8yh4mn8a.js";import"./chunk-ys8gysg8.js";import"./chunk-ftk0ytf8.js";import"./chunk-b22ab7yw.js";import"./chunk-amabfzc8.js";import"./chunk-m2x6pb4f.js";import"./chunk-saz6mwpq.js";import"./chunk-xhwdac1j.js";import"./chunk-0eajnhrj.js";import"./chunk-bzwxh6nq.js";import"./chunk-asgmmaec.js";import"./chunk-ed2hdrwe.js";import"./chunk-gmpsfkgg.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};
@@ -1 +1 @@
1
- import{Ag as b,Bg as c,Cg as d,zg as a}from"./chunk-2x63c1gx.js";import"./chunk-6wzwkjep.js";import"./chunk-b22ab7yw.js";import"./chunk-amabfzc8.js";import"./chunk-m2x6pb4f.js";import"./chunk-saz6mwpq.js";import"./chunk-xhwdac1j.js";import"./chunk-0eajnhrj.js";import"./chunk-cc9vbgqc.js";import"./chunk-asgmmaec.js";import"./chunk-ed2hdrwe.js";import"./chunk-gmpsfkgg.js";export{c as snapshotWorkspaceModelResources,b as resolveWorkspaceModelResources,d as createProcessModelResources,a as cloneWorkspaceModelConfig};
1
+ import{Ag as b,Bg as c,Cg as d,zg as a}from"./chunk-cfxs7jdk.js";import"./chunk-ftk0ytf8.js";import"./chunk-b22ab7yw.js";import"./chunk-amabfzc8.js";import"./chunk-m2x6pb4f.js";import"./chunk-saz6mwpq.js";import"./chunk-xhwdac1j.js";import"./chunk-0eajnhrj.js";import"./chunk-bzwxh6nq.js";import"./chunk-asgmmaec.js";import"./chunk-ed2hdrwe.js";import"./chunk-gmpsfkgg.js";export{c as snapshotWorkspaceModelResources,b as resolveWorkspaceModelResources,d as createProcessModelResources,a as cloneWorkspaceModelConfig};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "blade-code",
3
- "version": "0.11.5",
3
+ "version": "0.11.6",
4
4
  "private": false,
5
5
  "description": "🗡️ Blade Code - 智能代码助手命令行工具",
6
6
  "type": "module",
@@ -42,7 +42,7 @@
42
42
  "type-check": "tsc --noEmit",
43
43
  "format:check": "biome format src tests",
44
44
  "ready": "node scripts/run-bun.js run scripts/qualify.ts production",
45
- "prepack": "node scripts/run-bun.js run build",
45
+ "prepack": "node scripts/download-ripgrep.js && node scripts/run-bun.js run build",
46
46
  "release": "node scripts/release.js",
47
47
  "release:dry": "node scripts/release.js --dry-run",
48
48
  "release:major": "node scripts/release.js --major",
@@ -27,7 +27,8 @@ vendor/ripgrep/
27
27
  ### 自动下载(推荐)
28
28
 
29
29
  ```bash
30
- npm run vendor:ripgrep
30
+ # 在 packages/cli 目录执行;省略版本号时使用脚本内置的默认版本
31
+ node scripts/download-ripgrep.js [版本号]
31
32
  ```
32
33
 
33
34
  ### 手动下载
@@ -44,16 +45,11 @@ npm run vendor:ripgrep
44
45
  ### 清理
45
46
 
46
47
  ```bash
47
- npm run vendor:ripgrep:clean
48
+ rm -rf vendor/ripgrep/*/
48
49
  ```
49
50
 
50
51
  ## 注意事项
51
52
 
52
- - 这些文件是**可选的**
53
- - Grep 工具会自动降级到其他搜索方案
54
- - 包含这些文件会增加 npm 包体积 ~40-50 MB
55
- - 这些文件已添加到 `.gitignore`
56
-
57
- ## 更多信息
58
-
59
- 详细文档请参考: [docs/development/implementation/grep-tool.md](../../docs/development/implementation/grep-tool.md)
53
+ - `npm pack` / `npm publish` 会经 `prepack` 自动下载并校验这些文件,随 npm 包发布(解压后约 21 MB)
54
+ - 二进制不提交到 git(见 `.gitignore`);`.npmignore` 让 npm 打包时不套用 `.gitignore`
55
+ - Grep 工具优先使用系统 rg,其次是这里的内置版本,都不可用时降级到其他搜索方案
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -1 +0,0 @@
1
- import{k as a,l as b,m as c,n as d,o as e}from"./chunk-cmk9vr5m.js";import"./chunk-cc9vbgqc.js";import"./chunk-gmpsfkgg.js";export{b as setSkipUntilVersion,d as performUpgrade,c as getUpgradeCommand,e as checkVersionOnStartup,a as checkVersion};
@@ -1,2 +0,0 @@
1
- import{readFileSync as c}from"node:fs";import{dirname as n,join as l}from"node:path";import{fileURLToPath as a}from"node:url";var e={name:"blade-code",version:"0.11.5",private:!1,description:"🗡️ Blade Code - 智能代码助手命令行工具",type:"module",bin:{blade:"dist/blade.js"},files:["dist","vendor/ripgrep/**","README.md"],scripts:{dev:"node scripts/run-bun.js --watch src/blade.tsx","dev:serve":"node scripts/run-bun.js --watch src/blade.tsx serve --port 4097",build:"rm -rf dist && node scripts/run-bun.js run scripts/build.ts",start:"node scripts/run-bun.js run dist/blade.js",test:"node scripts/test.js","test:all":"node scripts/test.js all","test:unit":"node scripts/test.js unit","test:integration":"node scripts/test.js integration","test:real-api":"node scripts/test.js realApi","test:real-api:qualification":"node scripts/test.js realApiQualification","test:cli":"node scripts/test.js cli","test:headless-core":"node scripts/test.js headlessCore","test:e2e":"node scripts/test.js e2e","test:performance":"node scripts/test.js performance","test:snapshot":"node scripts/test.js snapshot","test:security":"node scripts/test.js security","browser:install":"playwright install chromium","browser:check":"node scripts/run-bun.js run scripts/browser-check.ts","test:coverage":"node scripts/test.js all --coverage","test:watch":"vitest --watch --config vitest.config.ts","qualify:local":"node scripts/run-bun.js run scripts/qualify.ts local","qualify:production":"node scripts/run-bun.js run scripts/qualify.ts production","benchmark:repo":"node scripts/run-bun.js run scripts/run-real-repo-benchmark.ts","test:update-snapshots":"node scripts/test.js snapshot --update",lint:"biome lint src tests","lint:fix":"biome lint --write src tests","type-check":"tsc --noEmit","format:check":"biome format src tests",ready:"node scripts/run-bun.js run scripts/qualify.ts production",prepack:"node scripts/run-bun.js run build",release:"node scripts/release.js","release:dry":"node scripts/release.js --dry-run","release:major":"node scripts/release.js --major","release:minor":"node scripts/release.js --minor","release:patch":"node scripts/release.js --patch"},keywords:["cli","blade","ai","assistant","agent","llm"],author:"echoVic",license:"MIT",repository:{type:"git",url:"git+https://github.com/echoVic/blade-code.git"},homepage:"https://github.com/echoVic/blade-code#readme",bugs:{url:"https://github.com/echoVic/blade-code/issues"},engines:{node:">=22.19.0"},optionalDependencies:{"@vscode/ripgrep":"^1.18.0","better-sqlite3":"^11.8.1","bun-pty":"^0.4.8","node-pty":"1.1.0"},dependencies:{"@agentclientprotocol/sdk":"^1.3.0","@anthropic-ai/sandbox-runtime":"0.0.67","@earendil-works/pi-ai":"0.86.1","@inkjs/ui":"^2.0.0","@modelcontextprotocol/sdk":"^1.30.0",ahooks:"^3.9.7",ajv:"^8.17.1","ansi-escapes":"^7.3.0","async-mutex":"^0.5.0",axios:"^1.19.0",chalk:"^6.0.0",diff:"^8.0.4","fast-glob":"^3.3.3","fuse.js":"^7.5.0","gray-matter":"^4.0.3",hono:"^4.13.0",ink:"npm:@jrichman/ink@6.4.10","ink-big-text":"^2.0.0","ink-gradient":"^3.0.0","ink-select-input":"^6.2.0","ink-spinner":"^5.0.0","ink-text-input":"^6.0.0","js-tiktoken":"^1.0.21","lodash-es":"^4.18.1",lowlight:"^3.3.0","lru-cache":"^11.5.2",nanoid:"^5.1.16",open:"^10.1.2",pathe:"^2.0.3",picomatch:"^4.0.5",playwright:"1.63.0","proper-lockfile":"^4.1.2",react:"19.2.4","react-dom":"19.2.4",semver:"^7.8.5","string-width":"^8.2.2",typebox:"1.3.10",undici:"^8.10.2","vscode-jsonrpc":"8.2.1","vscode-languageserver-protocol":"3.17.5","vscode-languageserver-types":"3.17.5","wrap-ansi":"^9.0.2","write-file-atomic":"^7.0.1",ws:"^8.21.2",yaml:"^2.9.0",yargs:"^18.1.0",zustand:"^5.0.14"},devDependencies:{"@biomejs/biome":"2.5.7","@types/bun":"^1.3.14","@types/json-schema":"^7.0.15","@types/lodash-es":"^4.17.12","@types/node":"^22.15.24","@types/picomatch":"^4.0.3","@types/proper-lockfile":"^4.1.4","@types/react":"19.2.10","@types/react-dom":"19.2.3","@types/semver":"^7.8.0","@types/write-file-atomic":"^4.0.3","@types/ws":"^8.18.1","@types/yargs":"^17.0.35","@vitest/coverage-v8":"^5.0.1",jsdom:"^26.0.0",typescript:"^5.9.2",vitest:"^5.0.1"}};var s;function i(){if(s)return s;let r=n(a(import.meta.url));for(let o=0;o<5;o++){try{let t=JSON.parse(c(l(r,"package.json"),"utf8"));if(t.name===e.name&&typeof t.version==="string"&&typeof t.description==="string")return s=t,s}catch{}r=n(r)}return s={name:e.name,version:process.env.BLADE_VERSION??e.version,description:e.description},s}function d(){return i().version}function y(){return i().name}function v(){return i().description}function w(){return`v${d()} © 2025 Blade Code`}
2
- export{d as Xj,y as Yj,v as Zj,w as _j};
@@ -1 +0,0 @@
1
- import{xf as a,yf as b}from"./chunk-3054z3md.js";import"./chunk-cc9vbgqc.js";import"./chunk-gmpsfkgg.js";export{a as globalOptions,b as cliConfig};
@@ -1,12 +0,0 @@
1
- # 忽略所有平台的二进制文件(这些文件很大,不应该提交到 git)
2
- # 用户可以通过运行 npm run vendor:ripgrep 来下载它们
3
-
4
- darwin-arm64/
5
- darwin-x64/
6
- linux-arm64/
7
- linux-x64/
8
- win32-x64/
9
-
10
- # 但保留 README.md
11
- !README.md
12
- !.gitignore