blade-code 0.11.8 → 0.11.10

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 (43) hide show
  1. package/dist/blade.js +2 -2
  2. package/dist/{chunk-74vmjngm.js → chunk-0vet7np5.js} +1 -1
  3. package/dist/{chunk-j5e589we.js → chunk-113t7z1d.js} +1 -1
  4. package/dist/{chunk-926rkw87.js → chunk-123x4vv0.js} +1 -1
  5. package/dist/{chunk-2fj047zf.js → chunk-1j3y40wn.js} +1 -1
  6. package/dist/{chunk-hdy7b6zw.js → chunk-3ce55d11.js} +1 -1
  7. package/dist/{chunk-34y4z9ns.js → chunk-54mb3ar4.js} +1 -1
  8. package/dist/{chunk-0e9nrf53.js → chunk-58t96cyv.js} +1 -1
  9. package/dist/{chunk-1gr9vqy1.js → chunk-5tf0hs46.js} +1 -1
  10. package/dist/{chunk-7876fd4b.js → chunk-75an4n90.js} +1 -1
  11. package/dist/{chunk-ayqqhefz.js → chunk-7bvtz3mm.js} +1 -1
  12. package/dist/{chunk-de3wa8nq.js → chunk-7me3rm8n.js} +1 -1
  13. package/dist/{chunk-np5t59fa.js → chunk-8cr35jh6.js} +1 -1
  14. package/dist/{chunk-53twn9t2.js → chunk-8fasjabf.js} +1 -1
  15. package/dist/{chunk-vjvw3v6b.js → chunk-8hke5rc9.js} +1 -1
  16. package/dist/{chunk-m8sttgjc.js → chunk-8httqk7j.js} +1 -1
  17. package/dist/{chunk-3t655nhk.js → chunk-8tjh8nzm.js} +1 -1
  18. package/dist/{chunk-e613h191.js → chunk-8wk4q3bz.js} +363 -363
  19. package/dist/{chunk-8r8fp09p.js → chunk-am63xh9m.js} +1 -1
  20. package/dist/{chunk-1crgzzz7.js → chunk-bckm03fv.js} +53 -53
  21. package/dist/{chunk-erget6wk.js → chunk-d40j41s5.js} +1 -1
  22. package/dist/{chunk-14jd0cj6.js → chunk-geakn1sr.js} +1 -1
  23. package/dist/{chunk-s7jd42xp.js → chunk-j5nz7kb4.js} +1 -1
  24. package/dist/chunk-j63n860q.js +1 -0
  25. package/dist/{chunk-rwtsvy5y.js → chunk-jgmaytrk.js} +1 -1
  26. package/dist/{chunk-rcfef8qj.js → chunk-k5595spk.js} +1 -1
  27. package/dist/{chunk-dgypy6yt.js → chunk-k6knawfb.js} +9 -9
  28. package/dist/{chunk-b0smnpzh.js → chunk-katmqxmn.js} +1 -1
  29. package/dist/{chunk-rh1q6srx.js → chunk-kn7jya27.js} +1 -1
  30. package/dist/chunk-mnm8epn5.js +2 -0
  31. package/dist/{chunk-547g7bq5.js → chunk-mvyrhqrm.js} +2 -2
  32. package/dist/{chunk-22py5y1p.js → chunk-pt4reckf.js} +1 -1
  33. package/dist/chunk-se9tcqqv.js +1 -0
  34. package/dist/{chunk-re6hbrmb.js → chunk-t5hhrj1g.js} +1 -1
  35. package/dist/{chunk-5q2gp1bb.js → chunk-vh5za5en.js} +1 -1
  36. package/dist/{chunk-mmwqe49e.js → chunk-vhc0z5k0.js} +1 -1
  37. package/dist/{chunk-3m8949fr.js → chunk-vkabej0v.js} +1 -1
  38. package/dist/{chunk-29t2wbwt.js → chunk-yzw0e9a5.js} +1 -1
  39. package/dist/{chunk-nr5s7qtp.js → chunk-z7f2a75f.js} +1 -1
  40. package/package.json +1 -1
  41. package/dist/chunk-c1331rdc.js +0 -2
  42. package/dist/chunk-jbp9wt3f.js +0 -1
  43. package/dist/chunk-kz842bqy.js +0 -1
@@ -1 +1 @@
1
- import{he as a,ie as b,je as c,ke as d,le as e,me as f,ne as g}from"./chunk-ayqqhefz.js";import"./chunk-skktstg8.js";import"./chunk-s14zayxp.js";import"./chunk-b5cz00mt.js";import"./chunk-pm163dfm.js";import"./chunk-1cy4ab77.js";import"./chunk-ys8gysg8.js";import"./chunk-b22ab7yw.js";import"./chunk-m2x6pb4f.js";import"./chunk-saz6mwpq.js";import"./chunk-0eajnhrj.js";import"./chunk-c1331rdc.js";import"./chunk-ed2hdrwe.js";import"./chunk-gmpsfkgg.js";export{b as __setSessionSnapshotIOForTesting,c as __resetSessionSnapshotIOForTesting,g as SessionService,d as SessionMissingCreationError,e as SessionArchivedError,f as SessionArchiveConflictError,a as STALE_EMPTY_SESSION_AGE_MS};
1
+ import{he as a,ie as b,je as c,ke as d,le as e,me as f,ne as g}from"./chunk-7bvtz3mm.js";import"./chunk-skktstg8.js";import"./chunk-s14zayxp.js";import"./chunk-b5cz00mt.js";import"./chunk-pm163dfm.js";import"./chunk-1cy4ab77.js";import"./chunk-ys8gysg8.js";import"./chunk-b22ab7yw.js";import"./chunk-m2x6pb4f.js";import"./chunk-saz6mwpq.js";import"./chunk-0eajnhrj.js";import"./chunk-mnm8epn5.js";import"./chunk-ed2hdrwe.js";import"./chunk-gmpsfkgg.js";export{b as __setSessionSnapshotIOForTesting,c as __resetSessionSnapshotIOForTesting,g as SessionService,d as SessionMissingCreationError,e as SessionArchivedError,f as SessionArchiveConflictError,a as STALE_EMPTY_SESSION_AGE_MS};
@@ -1,4 +1,4 @@
1
- import{w as QH,x as YH,z as a}from"./chunk-mmwqe49e.js";import{A as uz,B as gz,C as cz,D as S}from"./chunk-vjvw3v6b.js";import{E as JH,F as Rz,G as Sz,H as Mz,I as Iz,J as hz}from"./chunk-22py5y1p.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-e613h191.js";import"./chunk-nad5spvc.js";import{Va as HH}from"./chunk-74vmjngm.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-3t655nhk.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-ayqqhefz.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-8r8fp09p.js";import"./chunk-crv3sghv.js";import{Zf as sz,_f as tz}from"./chunk-dgypy6yt.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-np5t59fa.js";import"./chunk-34y4z9ns.js";import"./chunk-kehgewqh.js";import"./chunk-kkzznz4w.js";import{sh as zH}from"./chunk-1cy4ab77.js";import"./chunk-7ajvrtb3.js";import"./chunk-3m8949fr.js";import"./chunk-ys8gysg8.js";import{Ai as oz,xi as nz}from"./chunk-nr5s7qtp.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-c1331rdc.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-vhc0z5k0.js";import{A as uz,B as gz,C as cz,D as S}from"./chunk-8hke5rc9.js";import{E as JH,F as Rz,G as Sz,H as Mz,I as Iz,J as hz}from"./chunk-pt4reckf.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-8wk4q3bz.js";import"./chunk-nad5spvc.js";import{Va as HH}from"./chunk-0vet7np5.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-8tjh8nzm.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-7bvtz3mm.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-am63xh9m.js";import"./chunk-crv3sghv.js";import{Zf as sz,_f as tz}from"./chunk-k6knawfb.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-8cr35jh6.js";import"./chunk-54mb3ar4.js";import"./chunk-kehgewqh.js";import"./chunk-kkzznz4w.js";import{sh as zH}from"./chunk-1cy4ab77.js";import"./chunk-7ajvrtb3.js";import"./chunk-vkabej0v.js";import"./chunk-ys8gysg8.js";import{Ai as oz,xi as nz}from"./chunk-z7f2a75f.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-mnm8epn5.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 +1 @@
1
- import{$f as h,Uf as a,Vf as b,Wf as c,Xf as d,Yf as e,Zf as f,_f as g,ag as i,bg as j,cg as k,dg as l,eg as m}from"./chunk-dgypy6yt.js";import"./chunk-x6k5ye1z.js";import"./chunk-v508x7cg.js";import"./chunk-nr5s7qtp.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-c1331rdc.js";import"./chunk-asgmmaec.js";import"./chunk-ed2hdrwe.js";import"./chunk-gmpsfkgg.js";export{a as vanillaStore,c as sessionActions,l as getThinkingModeEnabled,b as getState,j as getModelById,e as getMessages,k as getMcpServers,i as getCurrentModel,f as getConfig,h as getAllModels,g as ensureStoreInitialized,m as configActions,d as appActions};
1
+ import{$f as h,Uf as a,Vf as b,Wf as c,Xf as d,Yf as e,Zf as f,_f as g,ag as i,bg as j,cg as k,dg as l,eg as m}from"./chunk-k6knawfb.js";import"./chunk-x6k5ye1z.js";import"./chunk-v508x7cg.js";import"./chunk-z7f2a75f.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-mnm8epn5.js";import"./chunk-asgmmaec.js";import"./chunk-ed2hdrwe.js";import"./chunk-gmpsfkgg.js";export{a as vanillaStore,c as sessionActions,l as getThinkingModeEnabled,b as getState,j as getModelById,e as getMessages,k as getMcpServers,i as getCurrentModel,f as getConfig,h as getAllModels,g as ensureStoreInitialized,m as configActions,d as appActions};
@@ -0,0 +1 @@
1
+ import{k as a,l as b,m as c,n as d,o as e}from"./chunk-katmqxmn.js";import"./chunk-mnm8epn5.js";import"./chunk-gmpsfkgg.js";export{b as setSkipUntilVersion,d as performUpgrade,c as getUpgradeCommand,e as checkVersionOnStartup,a as checkVersion};
@@ -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-3t655nhk.js";import"./chunk-9qxch6sy.js";import"./chunk-ayqqhefz.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-3m8949fr.js";import"./chunk-ys8gysg8.js";import"./chunk-nr5s7qtp.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-c1331rdc.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-8tjh8nzm.js";import"./chunk-9qxch6sy.js";import"./chunk-7bvtz3mm.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-vkabej0v.js";import"./chunk-ys8gysg8.js";import"./chunk-z7f2a75f.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-mnm8epn5.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-np5t59fa.js";import"./chunk-nr5s7qtp.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-c1331rdc.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-8cr35jh6.js";import"./chunk-z7f2a75f.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-mnm8epn5.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,25 +1,25 @@
1
- import{fg as G0}from"./chunk-x6k5ye1z.js";import{Hh as Y0,Ri as l,Ui as Z0,si as W}from"./chunk-nr5s7qtp.js";import{Zi as z0}from"./chunk-b22ab7yw.js";import{Qj as u}from"./chunk-xhwdac1j.js";import{devtools as B0,subscribeWithSelector as q0}from"zustand/middleware";import{createStore as D0}from"zustand/vanilla";var o=[{id:"ayu-dark",label:"Ayu Dark",theme:{name:"ayu-dark",colors:{primary:"#ffcc66",secondary:"#bae67e",accent:"#73d0ff",success:"#bae67e",warning:"#ffcc66",error:"#ff3333",info:"#73d0ff",light:"#f0f0f0",dark:"#000000",muted:"#5c6773",highlight:"#2d323b",text:{primary:"#e6e1cf",secondary:"#bae67e",muted:"#5c6773",light:"#ffffff"},background:{primary:"#0f1419",secondary:"#14191f",dark:"#000000"},border:{light:"#2d323b",dark:"#000000"},syntax:{comment:"#5c6773",string:"#bae67e",number:"#ffcc66",keyword:"#ff8f40",function:"#73d0ff",variable:"#e6e1cf",operator:"#f29e74",type:"#73d0ff",tag:"#ff8f40",attr:"#ffd580",default:"#e6e1cf"}},spacing:{xs:0.25,sm:0.5,md:1,lg:1.5,xl:2},typography:{fontSize:{xs:0.75,sm:0.875,base:1,lg:1.125,xl:1.25,"2xl":1.5,"3xl":1.875},fontWeight:{light:300,normal:400,medium:500,semibold:600,bold:700}},borderRadius:{sm:0.125,base:0.25,lg:0.5,xl:0.75},boxShadow:{sm:"0 1px 2px 0 rgba(0, 0, 0, 0.2)",base:"0 1px 3px 0 rgba(0, 0, 0, 0.3), 0 1px 2px 0 rgba(0, 0, 0, 0.2)",lg:"0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -2px rgba(0, 0, 0, 0.2)"}},tags:["dark","popular"]},{id:"dracula",label:"Dracula",theme:{name:"dracula",colors:{primary:"#bd93f9",secondary:"#ffb86c",accent:"#ff79c6",success:"#50fa7b",warning:"#f1fa8c",error:"#ff5555",info:"#8be9fd",light:"#f8f8f2",dark:"#282a36",muted:"#6272a4",highlight:"#44475a",text:{primary:"#f8f8f2",secondary:"#f1fa8c",muted:"#6272a4",light:"#ffffff"},background:{primary:"#282a36",secondary:"#44475a",dark:"#21222c"},border:{light:"#44475a",dark:"#000000"},syntax:{comment:"#6272a4",string:"#f1fa8c",number:"#bd93f9",keyword:"#ff79c6",function:"#50fa7b",variable:"#f8f8f2",operator:"#ff79c6",type:"#8be9fd",tag:"#ff79c6",attr:"#50fa7b",default:"#f8f8f2"}},spacing:{xs:0.25,sm:0.5,md:1,lg:1.5,xl:2},typography:{fontSize:{xs:0.75,sm:0.875,base:1,lg:1.125,xl:1.25,"2xl":1.5,"3xl":1.875},fontWeight:{light:300,normal:400,medium:500,semibold:600,bold:700}},borderRadius:{sm:0.125,base:0.25,lg:0.5,xl:0.75},boxShadow:{sm:"0 1px 2px 0 rgba(40, 42, 54, 0.2)",base:"0 1px 3px 0 rgba(40, 42, 54, 0.3), 0 1px 2px 0 rgba(40, 42, 54, 0.2)",lg:"0 10px 15px -3px rgba(40, 42, 54, 0.3), 0 4px 6px -2px rgba(40, 42, 54, 0.2)"}},tags:["dark","popular"]},{id:"monokai",label:"Monokai",theme:{name:"monokai",colors:{primary:"#66d9ef",secondary:"#a6e22e",accent:"#f92672",success:"#a6e22e",warning:"#e6db74",error:"#f92672",info:"#66d9ef",light:"#f8f8f2",dark:"#272822",muted:"#75715e",highlight:"#3e3d32",text:{primary:"#f8f8f2",secondary:"#e6db74",muted:"#75715e",light:"#ffffff"},background:{primary:"#272822",secondary:"#3e3d32",dark:"#1e1f1c"},border:{light:"#3e3d32",dark:"#000000"},syntax:{comment:"#75715e",string:"#e6db74",number:"#ae81ff",keyword:"#f92672",function:"#a6e22e",variable:"#f8f8f2",operator:"#f92672",type:"#66d9ef",tag:"#f92672",attr:"#a6e22e",default:"#f8f8f2"}},spacing:{xs:0.25,sm:0.5,md:1,lg:1.5,xl:2},typography:{fontSize:{xs:0.75,sm:0.875,base:1,lg:1.125,xl:1.25,"2xl":1.5,"3xl":1.875},fontWeight:{light:300,normal:400,medium:500,semibold:600,bold:700}},borderRadius:{sm:0.125,base:0.25,lg:0.5,xl:0.75},boxShadow:{sm:"0 1px 2px 0 rgba(39, 40, 34, 0.2)",base:"0 1px 3px 0 rgba(39, 40, 34, 0.3), 0 1px 2px 0 rgba(39, 40, 34, 0.2)",lg:"0 10px 15px -3px rgba(39, 40, 34, 0.3), 0 4px 6px -2px rgba(39, 40, 34, 0.2)"}},tags:["dark","classic"]},{id:"nord",label:"Nord",theme:{name:"nord",colors:{primary:"#88c0d0",secondary:"#81a1c1",accent:"#b48ead",success:"#a3be8c",warning:"#ebcb8b",error:"#bf616a",info:"#88c0d0",light:"#eceff4",dark:"#2e3440",muted:"#4c566a",highlight:"#434c5e",text:{primary:"#eceff4",secondary:"#d8dee9",muted:"#4c566a",light:"#ffffff"},background:{primary:"#2e3440",secondary:"#3b4252",dark:"#242933"},border:{light:"#434c5e",dark:"#000000"},syntax:{comment:"#616e88",string:"#a3be8c",number:"#b48ead",keyword:"#81a1c1",function:"#88c0d0",variable:"#d8dee9",operator:"#81a1c1",type:"#8fbcbb",tag:"#81a1c1",attr:"#8fbcbb",default:"#eceff4"}},spacing:{xs:0.25,sm:0.5,md:1,lg:1.5,xl:2},typography:{fontSize:{xs:0.75,sm:0.875,base:1,lg:1.125,xl:1.25,"2xl":1.5,"3xl":1.875},fontWeight:{light:300,normal:400,medium:500,semibold:600,bold:700}},borderRadius:{sm:0.125,base:0.25,lg:0.5,xl:0.75},boxShadow:{sm:"0 1px 2px 0 rgba(46, 52, 64, 0.2)",base:"0 1px 3px 0 rgba(46, 52, 64, 0.3), 0 1px 2px 0 rgba(46, 52, 64, 0.2)",lg:"0 10px 15px -3px rgba(46, 52, 64, 0.3), 0 4px 6px -2px rgba(46, 52, 64, 0.2)"}},tags:["dark","minimal"]},{id:"solarized-light",label:"Solarized Light",theme:{name:"solarized-light",colors:{primary:"#268bd2",secondary:"#2aa198",accent:"#d33682",success:"#859900",warning:"#cb4b16",error:"#dc322f",info:"#268bd2",light:"#fdf6e3",dark:"#073642",muted:"#93a1a1",highlight:"#eee8d5",text:{primary:"#586e75",secondary:"#657b83",muted:"#93a1a1",light:"#002b36"},background:{primary:"#fdf6e3",secondary:"#eee8d5",dark:"#073642"},border:{light:"#eee8d5",dark:"#073642"},syntax:{comment:"#93a1a1",string:"#2aa198",number:"#d33682",keyword:"#859900",function:"#268bd2",variable:"#657b83",operator:"#859900",type:"#b58900",tag:"#268bd2",attr:"#93a1a1",default:"#657b83"}},spacing:{xs:0.25,sm:0.5,md:1,lg:1.5,xl:2},typography:{fontSize:{xs:0.75,sm:0.875,base:1,lg:1.125,xl:1.25,"2xl":1.5,"3xl":1.875},fontWeight:{light:300,normal:400,medium:500,semibold:600,bold:700}},borderRadius:{sm:0.125,base:0.25,lg:0.5,xl:0.75},boxShadow:{sm:"0 1px 2px 0 rgba(253, 246, 227, 0.2)",base:"0 1px 3px 0 rgba(253, 246, 227, 0.3), 0 1px 2px 0 rgba(253, 246, 227, 0.2)",lg:"0 10px 15px -3px rgba(253, 246, 227, 0.3), 0 4px 6px -2px rgba(253, 246, 227, 0.2)"}},tags:["light"]},{id:"solarized-dark",label:"Solarized Dark",theme:{name:"solarized-dark",colors:{primary:"#268bd2",secondary:"#2aa198",accent:"#d33682",success:"#859900",warning:"#b58900",error:"#dc322f",info:"#268bd2",light:"#fdf6e3",dark:"#073642",muted:"#586e75",highlight:"#073642",text:{primary:"#839496",secondary:"#93a1a1",muted:"#586e75",light:"#fdf6e3"},background:{primary:"#002b36",secondary:"#073642",dark:"#001f29"},border:{light:"#073642",dark:"#000000"},syntax:{comment:"#586e75",string:"#2aa198",number:"#d33682",keyword:"#859900",function:"#268bd2",variable:"#839496",operator:"#859900",type:"#b58900",tag:"#268bd2",attr:"#93a1a1",default:"#839496"}},spacing:{xs:0.25,sm:0.5,md:1,lg:1.5,xl:2},typography:{fontSize:{xs:0.75,sm:0.875,base:1,lg:1.125,xl:1.25,"2xl":1.5,"3xl":1.875},fontWeight:{light:300,normal:400,medium:500,semibold:600,bold:700}},borderRadius:{sm:0.125,base:0.25,lg:0.5,xl:0.75},boxShadow:{sm:"0 1px 2px 0 rgba(0, 43, 54, 0.2)",base:"0 1px 3px 0 rgba(0, 43, 54, 0.3), 0 1px 2px 0 rgba(0, 43, 54, 0.2)",lg:"0 10px 15px -3px rgba(0, 43, 54, 0.3), 0 4px 6px -2px rgba(0, 43, 54, 0.2)"}},tags:["dark"]},{id:"tokyo-night",label:"Tokyo Night",theme:{name:"tokyo-night",colors:{primary:"#7aa2f7",secondary:"#7dcfff",accent:"#bb9af7",success:"#9ece6a",warning:"#e0af68",error:"#f7768e",info:"#7aa2f7",light:"#c0caf5",dark:"#1a1b26",muted:"#565f89",highlight:"#292e42",text:{primary:"#a9b1d6",secondary:"#c0caf5",muted:"#565f89",light:"#ffffff"},background:{primary:"#1a1b26",secondary:"#292e42",dark:"#16161e"},border:{light:"#292e42",dark:"#000000"},syntax:{comment:"#565f89",string:"#9ece6a",number:"#ff9e64",keyword:"#bb9af7",function:"#7aa2f7",variable:"#c0caf5",operator:"#89ddff",type:"#7dcfff",tag:"#f7768e",attr:"#7aa2f7",default:"#a9b1d6"}},spacing:{xs:0.25,sm:0.5,md:1,lg:1.5,xl:2},typography:{fontSize:{xs:0.75,sm:0.875,base:1,lg:1.125,xl:1.25,"2xl":1.5,"3xl":1.875},fontWeight:{light:300,normal:400,medium:500,semibold:600,bold:700}},borderRadius:{sm:0.125,base:0.25,lg:0.5,xl:0.75},boxShadow:{sm:"0 1px 2px 0 rgba(26, 27, 38, 0.2)",base:"0 1px 3px 0 rgba(26, 27, 38, 0.3), 0 1px 2px 0 rgba(26, 27, 38, 0.2)",lg:"0 10px 15px -3px rgba(26, 27, 38, 0.3), 0 4px 6px -2px rgba(26, 27, 38, 0.2)"}},tags:["dark","popular"]},{id:"github",label:"GitHub",theme:{name:"github",colors:{primary:"#0969da",secondary:"#8250df",accent:"#bc4c00",success:"#1a7f37",warning:"#bc4c00",error:"#d1242f",info:"#0969da",light:"#f6f8fa",dark:"#24292f",muted:"#6e7781",highlight:"#ddf4ff",text:{primary:"#24292f",secondary:"#57606a",muted:"#6e7781",light:"#ffffff"},background:{primary:"#ffffff",secondary:"#f6f8fa",dark:"#24292f"},border:{light:"#d0d7de",dark:"#24292f"},syntax:{comment:"#6e7781",string:"#0a3069",number:"#0550ae",keyword:"#cf222e",function:"#8250df",variable:"#24292f",operator:"#cf222e",type:"#0550ae",tag:"#116329",attr:"#0550ae",default:"#24292f"}},spacing:{xs:0.25,sm:0.5,md:1,lg:1.5,xl:2},typography:{fontSize:{xs:0.75,sm:0.875,base:1,lg:1.125,xl:1.25,"2xl":1.5,"3xl":1.875},fontWeight:{light:300,normal:400,medium:500,semibold:600,bold:700}},borderRadius:{sm:0.125,base:0.25,lg:0.5,xl:0.75},boxShadow:{sm:"0 1px 2px 0 rgba(255, 255, 255, 0.2)",base:"0 1px 3px 0 rgba(255, 255, 255, 0.3), 0 1px 2px 0 rgba(255, 255, 255, 0.2)",lg:"0 10px 15px -3px rgba(255, 255, 255, 0.3), 0 4px 6px -2px rgba(255, 255, 255, 0.2)"}},tags:["light","minimal"]},{id:"gruvbox",label:"Gruvbox",theme:{name:"gruvbox",colors:{primary:"#83a598",secondary:"#8ec07c",accent:"#d3869b",success:"#b8bb26",warning:"#fabd2f",error:"#fb4934",info:"#83a598",light:"#fbf1c7",dark:"#282828",muted:"#928374",highlight:"#3c3836",text:{primary:"#ebdbb2",secondary:"#d5c4a1",muted:"#928374",light:"#ffffff"},background:{primary:"#282828",secondary:"#3c3836",dark:"#1d2021"},border:{light:"#3c3836",dark:"#000000"},syntax:{comment:"#928374",string:"#b8bb26",number:"#d3869b",keyword:"#fb4934",function:"#8ec07c",variable:"#ebdbb2",operator:"#fe8019",type:"#fabd2f",tag:"#fb4934",attr:"#b8bb26",default:"#ebdbb2"}},spacing:{xs:0.25,sm:0.5,md:1,lg:1.5,xl:2},typography:{fontSize:{xs:0.75,sm:0.875,base:1,lg:1.125,xl:1.25,"2xl":1.5,"3xl":1.875},fontWeight:{light:300,normal:400,medium:500,semibold:600,bold:700}},borderRadius:{sm:0.125,base:0.25,lg:0.5,xl:0.75},boxShadow:{sm:"0 1px 2px 0 rgba(40, 40, 40, 0.2)",base:"0 1px 3px 0 rgba(40, 40, 40, 0.3), 0 1px 2px 0 rgba(40, 40, 40, 0.2)",lg:"0 10px 15px -3px rgba(40, 40, 40, 0.3), 0 4px 6px -2px rgba(40, 40, 40, 0.2)"}},tags:["dark","warm"]},{id:"one-dark",label:"One Dark",theme:{name:"one-dark",colors:{primary:"#61afef",secondary:"#c678dd",accent:"#e5c07b",success:"#98c379",warning:"#e5c07b",error:"#e06c75",info:"#56b6c2",light:"#abb2bf",dark:"#282c34",muted:"#5c6370",highlight:"#3e4451",text:{primary:"#abb2bf",secondary:"#c6c8d0",muted:"#5c6370",light:"#ffffff"},background:{primary:"#282c34",secondary:"#3e4451",dark:"#21252b"},border:{light:"#3e4451",dark:"#000000"},syntax:{comment:"#5c6370",string:"#98c379",number:"#d19a66",keyword:"#c678dd",function:"#61afef",variable:"#e06c75",operator:"#56b6c2",type:"#e5c07b",tag:"#e06c75",attr:"#d19a66",default:"#abb2bf"}},spacing:{xs:0.25,sm:0.5,md:1,lg:1.5,xl:2},typography:{fontSize:{xs:0.75,sm:0.875,base:1,lg:1.125,xl:1.25,"2xl":1.5,"3xl":1.875},fontWeight:{light:300,normal:400,medium:500,semibold:600,bold:700}},borderRadius:{sm:0.125,base:0.25,lg:0.5,xl:0.75},boxShadow:{sm:"0 1px 2px 0 rgba(40, 44, 52, 0.2)",base:"0 1px 3px 0 rgba(40, 44, 52, 0.3), 0 1px 2px 0 rgba(40, 44, 52, 0.2)",lg:"0 10px 15px -3px rgba(40, 44, 52, 0.3), 0 4px 6px -2px rgba(40, 44, 52, 0.2)"}},tags:["dark","popular"]},{id:"catppuccin",label:"Catppuccin",theme:{name:"catppuccin",colors:{primary:"#89b4fa",secondary:"#cba6f7",accent:"#f5c2e7",success:"#a6e3a1",warning:"#f9e2af",error:"#f38ba8",info:"#89dceb",light:"#cdd6f4",dark:"#11111b",muted:"#6c7086",highlight:"#181825",text:{primary:"#cdd6f4",secondary:"#bac2de",muted:"#6c7086",light:"#ffffff"},background:{primary:"#1e1e2e",secondary:"#181825",dark:"#11111b"},border:{light:"#181825",dark:"#000000"},syntax:{comment:"#6c7086",string:"#a6e3a1",number:"#fab387",keyword:"#cba6f7",function:"#89b4fa",variable:"#cdd6f4",operator:"#89dceb",type:"#f5c2e7",tag:"#f38ba8",attr:"#89b4fa",default:"#cdd6f4"}},spacing:{xs:0.25,sm:0.5,md:1,lg:1.5,xl:2},typography:{fontSize:{xs:0.75,sm:0.875,base:1,lg:1.125,xl:1.25,"2xl":1.5,"3xl":1.875},fontWeight:{light:300,normal:400,medium:500,semibold:600,bold:700}},borderRadius:{sm:0.125,base:0.25,lg:0.5,xl:0.75},boxShadow:{sm:"0 1px 2px 0 rgba(30, 30, 46, 0.2)",base:"0 1px 3px 0 rgba(30, 30, 46, 0.3), 0 1px 2px 0 rgba(30, 30, 46, 0.2)",lg:"0 10px 15px -3px rgba(30, 30, 46, 0.3), 0 4px 6px -2px rgba(30, 30, 46, 0.2)"}},tags:["dark","pastel"]},{id:"rose-pine",label:"Rose Pine",theme:{name:"rose-pine",colors:{primary:"#9ccfd8",secondary:"#c4a7e7",accent:"#f6c177",success:"#31748f",warning:"#f6c177",error:"#eb6f92",info:"#9ccfd8",light:"#e0def4",dark:"#191724",muted:"#6e6a86",highlight:"#1f1d2e",text:{primary:"#e0def4",secondary:"#cecacd",muted:"#6e6a86",light:"#ffffff"},background:{primary:"#191724",secondary:"#1f1d2e",dark:"#12101a"},border:{light:"#1f1d2e",dark:"#000000"},syntax:{comment:"#6e6a86",string:"#9ccfd8",number:"#ea9a97",keyword:"#c4a7e7",function:"#31748f",variable:"#e0def4",operator:"#f6c177",type:"#9ccfd8",tag:"#eb6f92",attr:"#f6c177",default:"#e0def4"}},spacing:{xs:0.25,sm:0.5,md:1,lg:1.5,xl:2},typography:{fontSize:{xs:0.75,sm:0.875,base:1,lg:1.125,xl:1.25,"2xl":1.5,"3xl":1.875},fontWeight:{light:300,normal:400,medium:500,semibold:600,bold:700}},borderRadius:{sm:0.125,base:0.25,lg:0.5,xl:0.75},boxShadow:{sm:"0 1px 2px 0 rgba(25, 23, 36, 0.2)",base:"0 1px 3px 0 rgba(25, 23, 36, 0.3), 0 1px 2px 0 rgba(25, 23, 36, 0.2)",lg:"0 10px 15px -3px rgba(25, 23, 36, 0.3), 0 4px 6px -2px rgba(25, 23, 36, 0.2)"}},tags:["dark","elegant"]},{id:"kanagawa",label:"Kanagawa",theme:{name:"kanagawa",colors:{primary:"#8ba4b0",secondary:"#a292a3",accent:"#c47fd5",success:"#76946a",warning:"#c0a36e",error:"#c34043",info:"#7e9cd8",light:"#dcd7ba",dark:"#1f1f28",muted:"#727169",highlight:"#2a2a37",text:{primary:"#dcd7ba",secondary:"#c8c093",muted:"#727169",light:"#ffffff"},background:{primary:"#1f1f28",secondary:"#2a2a37",dark:"#16161d"},border:{light:"#2a2a37",dark:"#000000"},syntax:{comment:"#727169",string:"#98bb6c",number:"#d27e99",keyword:"#957fb8",function:"#7e9cd8",variable:"#dcd7ba",operator:"#c0a36e",type:"#7aa89f",tag:"#c34043",attr:"#7fb4ca",default:"#dcd7ba"}},spacing:{xs:0.25,sm:0.5,md:1,lg:1.5,xl:2},typography:{fontSize:{xs:0.75,sm:0.875,base:1,lg:1.125,xl:1.25,"2xl":1.5,"3xl":1.875},fontWeight:{light:300,normal:400,medium:500,semibold:600,bold:700}},borderRadius:{sm:0.125,base:0.25,lg:0.5,xl:0.75},boxShadow:{sm:"0 1px 2px 0 rgba(31, 31, 40, 0.2)",base:"0 1px 3px 0 rgba(31, 31, 40, 0.3), 0 1px 2px 0 rgba(31, 31, 40, 0.2)",lg:"0 10px 15px -3px rgba(31, 31, 40, 0.3), 0 4px 6px -2px rgba(31, 31, 40, 0.2)"}},tags:["dark","japanese"]}];var a=o;var n={primary:"#0066cc",secondary:"#6c757d",accent:"#e83e8c",success:"#28a745",warning:"#ffc107",error:"#dc3545",info:"#17a2b8",light:"#f8f9fa",dark:"#343a40",muted:"#6c757d",highlight:"#fff3cd",text:{primary:"#212529",secondary:"#6c757d",muted:"#6c757d",light:"#ffffff"},background:{primary:"#ffffff",secondary:"#f8f9fa",dark:"#343a40"},border:{light:"#dee2e6",dark:"#495057"},syntax:{comment:"#6c757d",string:"#28a745",number:"#e83e8c",keyword:"#007bff",function:"#17a2b8",variable:"#495057",operator:"#ffc107",type:"#007bff",tag:"#dc3545",attr:"#ffc107",default:"#212529"}},S={name:"default",colors:n,spacing:{xs:0.25,sm:0.5,md:1,lg:1.5,xl:2},typography:{fontSize:{xs:0.75,sm:0.875,base:1,lg:1.125,xl:1.25,"2xl":1.5,"3xl":1.875},fontWeight:{light:300,normal:400,medium:500,semibold:600,bold:700}},borderRadius:{sm:0.125,base:0.25,lg:0.5,xl:0.75},boxShadow:{sm:"0 1px 2px 0 rgba(0, 0, 0, 0.05)",base:"0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06)",lg:"0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05)"}},V0={...S,name:"dark",colors:{...n,text:{primary:"#ffffff",secondary:"#e2e8f0",muted:"#94a3b8",light:"#000000"},background:{primary:"#1e293b",secondary:"#334155",dark:"#0f172a"},border:{light:"#475569",dark:"#64748b"},syntax:{comment:"#94a3b8",string:"#34d399",number:"#f472b6",keyword:"#60a5fa",function:"#06b6d4",variable:"#e2e8f0",operator:"#fbbf24",type:"#60a5fa",tag:"#fb7185",attr:"#fbbf24",default:"#ffffff"}}};class s{currentTheme=S;themes=new Map;constructor(){this.themes.set("default",S),this.themes.set("dark",V0);for(let f of a)this.themes.set(f.id,f.theme)}setTheme(f){let y=this.themes.get(f);if(y)this.currentTheme=y;else throw Error(`Theme '${f}' not found`)}getTheme(){return this.currentTheme}getAvailableThemes(){return Array.from(this.themes.keys())}getCurrentThemeName(){return this.currentTheme.name}getThemeByName(f){return this.themes.get(f)}hasTheme(f){return this.themes.has(f)}}var e=new s;var H0={initializationStatus:"idle",initializationError:null,activeModal:"none",sessionSelectorData:void 0,sessionHistoryViewerData:void 0,taskAttentionStatus:"idle",taskAttentionUnreadKeys:[],followUpQueue:null,followUpQueueOwner:null,followUpQueueMutation:{pending:!1,supersededVersions:[]},modelEditorTarget:null,tasks:[],awaitingSecondCtrlC:!1,reasoningEffort:"off",serviceTier:"auto",responseVerbosity:"auto",communicationStyle:"auto",subagentProgress:null,subagentProgresses:{},sideConversation:null,teams:[]},g=(f)=>({...H0,actions:{setInitializationStatus:(y)=>{f((b)=>({app:{...b.app,initializationStatus:y}}))},setInitializationError:(y)=>{f((b)=>({app:{...b.app,initializationError:y}}))},setActiveModal:(y)=>{f((b)=>({app:{...b.app,activeModal:y}}))},showSessionSelector:(y,b="resume")=>{f((x)=>({app:{...x.app,activeModal:"sessionSelector",sessionSelectorData:{intent:b,sessions:y},sessionHistoryViewerData:void 0}}))},showSessionHistoryViewer:(y,b="resume")=>{f((x)=>({app:{...x.app,activeModal:"sessionHistoryViewer",sessionSelectorData:void 0,sessionHistoryViewerData:{intent:b,session:y}}}))},showModelEditWizard:(y)=>{f((b)=>({app:{...b.app,activeModal:"modelEditWizard",modelEditorTarget:y}}))},closeModal:()=>{f((y)=>({app:{...y.app,activeModal:"none",sessionSelectorData:void 0,sessionHistoryViewerData:void 0,modelEditorTarget:null}}))},setTasks:(y)=>{f((b)=>({app:{...b.app,tasks:y}}))},updateTask:(y)=>{f((b)=>({app:{...b.app,tasks:b.app.tasks.map((x)=>x.id===y.id?y:x)}}))},setAwaitingSecondCtrlC:(y)=>{f((b)=>({app:{...b.app,awaitingSecondCtrlC:y}}))},projectTaskAttentionState:(y,b,x)=>{f((p)=>({app:{...p.app,taskAttentionStatus:y,taskAttentionUnreadKeys:[...b],sessionSelectorData:y==="ready"&&p.app.activeModal==="sessionSelector"&&p.app.sessionSelectorData?{...p.app.sessionSelectorData,sessions:[...x]}:p.app.sessionSelectorData}}))},projectFollowUpQueue:(y,b)=>{f((x)=>{let p=[x.session.workspaceRoot,x.session.sessionId,""].join("\x00");if(b!==void 0&&!b.startsWith(p))return x;if(b!==void 0&&x.app.followUpQueueOwner!==null&&x.app.followUpQueueOwner!==b)return x;let h=x.app.followUpQueueMutation.supersededVersions??[];if(h.includes(y.version))return x;let F=x.app.followUpQueue&&x.app.followUpQueue.version!==y.version?[...h,x.app.followUpQueue.version].slice(-16):h;return{app:{...x.app,followUpQueue:y,followUpQueueOwner:b??x.app.followUpQueueOwner,followUpQueueMutation:{pending:x.app.followUpQueueMutation.pending,...x.app.followUpQueueMutation.messageId?{messageId:x.app.followUpQueueMutation.messageId}:{},supersededVersions:F}},command:{...x.command,followUpPresentations:Object.fromEntries(Object.entries(x.command.followUpPresentations).filter(([z])=>y.items.some((G)=>G.id===z)))}}})},claimFollowUpQueueOwner:(y)=>{f((b)=>{let x=[b.session.workspaceRoot,b.session.sessionId,""].join("\x00");if(!y.startsWith(x))return b;if(b.app.followUpQueueOwner===y)return b;return{app:{...b.app,followUpQueue:null,followUpQueueOwner:y,followUpQueueMutation:{pending:!1,supersededVersions:[]}},command:{...b.command,followUpPresentations:{}}}})},setFollowUpQueueMutation:(y,b)=>{f((x)=>{let p=[x.session.workspaceRoot,x.session.sessionId,""].join("\x00");if(b!==void 0&&!b.startsWith(p))return x;if(b!==void 0&&x.app.followUpQueueOwner!==null&&x.app.followUpQueueOwner!==b)return x;return{app:{...x.app,followUpQueueMutation:{...y,supersededVersions:y.supersededVersions??x.app.followUpQueueMutation.supersededVersions}}}})},clearFollowUpQueue:(y)=>{f((b)=>{if(y!==void 0&&b.app.followUpQueueOwner!==y)return b;return{app:{...b.app,followUpQueue:null,followUpQueueOwner:null,followUpQueueMutation:{pending:!1,supersededVersions:[]}},command:{...b.command,followUpPresentations:{}}}})},setReasoningEffort:(y)=>{f((b)=>({app:{...b.app,reasoningEffort:y}}))},setServiceTier:(y)=>{f((b)=>({app:{...b.app,serviceTier:y}}))},setResponseVerbosity:(y)=>{f((b)=>({app:{...b.app,responseVerbosity:y}}))},setCommunicationStyle:(y)=>{f((b)=>({app:{...b.app,communicationStyle:y}}))},setThinkingModeEnabled:(y)=>{f((b)=>({app:{...b.app,reasoningEffort:y?"auto":"off"}}))},toggleThinkingMode:()=>{f((y)=>({app:{...y.app,reasoningEffort:y.app.reasoningEffort==="off"?"auto":"off"}}))},startSubagentProgress:(y,b,x)=>{f((p)=>({app:{...p.app,subagentProgresses:{...p.app.subagentProgresses,[y]:{id:y,type:b,description:x,status:"running",startTime:Date.now()}},subagentProgress:{id:y,type:b,description:x,status:"running",startTime:Date.now()}}}))},updateSubagentTool:(y,b)=>{f((x)=>{let p=x.app.subagentProgresses[y];if(!p)return x;let h={...p,currentTool:b};return{app:{...x.app,subagentProgresses:{...x.app.subagentProgresses,[y]:h},subagentProgress:x.app.subagentProgress?.id===y?h:x.app.subagentProgress}}})},completeSubagentProgress:(y,b,x)=>{f((p)=>{let h=p.app.subagentProgresses[y];if(!h)return p;let F=x?.trim(),z={...h,status:b?"completed":"failed",currentTool:void 0,...!b&&F?{terminalSummary:F.slice(0,200)}:{}};return{app:{...p.app,subagentProgresses:{...p.app.subagentProgresses,[y]:z},subagentProgress:p.app.subagentProgress?.id===y?z:p.app.subagentProgress}}}),setTimeout(()=>{f((p)=>{let h=p.app.subagentProgresses[y];if(!h||h.status==="running")return p;let F={...p.app.subagentProgresses};delete F[y];let z=Object.values(F);return{app:{...p.app,subagentProgresses:F,subagentProgress:p.app.subagentProgress?.id===y?z[z.length-1]??null:p.app.subagentProgress}}})},1500)},startSideConversation:(y,b)=>{f((x)=>({app:{...x.app,sideConversation:{requestId:y,question:b,status:"loading"}}}))},completeSideConversation:(y,b)=>{f((x)=>{if(x.app.sideConversation?.requestId!==y)return x;return{app:{...x.app,sideConversation:{requestId:y,question:x.app.sideConversation.question,status:"completed",response:b.response,durationMs:b.durationMs}}}})},failSideConversation:(y,b)=>{f((x)=>{if(x.app.sideConversation?.requestId!==y)return x;return{app:{...x.app,sideConversation:{requestId:y,question:x.app.sideConversation.question,status:"error",error:b}}}})},dismissSideConversation:()=>{f((y)=>({app:{...y.app,sideConversation:null}}))},setTeams:(y)=>{f((b)=>({app:{...b.app,teams:y}}))}}});var U0={isProcessing:!1,abortController:null,followUpPresentations:{},recoveredSteeringCount:0},T=(f,y)=>({...U0,actions:{setProcessing:(b)=>{f((x)=>({command:{...x.command,isProcessing:b},...!b?{session:{...x.session,providerAdmission:null,providerCircuit:null,providerRetry:null,providerStall:null,providerRecovery:null,turnActivity:null,actionStationarity:null}}:{}}))},createAbortController:()=>{let b=y().command.abortController;if(b&&!b.signal.aborted)b.abort("interrupted-by-new-command");let x=new AbortController;return f((p)=>({command:{...p.command,abortController:x}})),x},getAbortController:()=>{return y().command.abortController},clearAbortController:(b)=>{let x=y().command.abortController;if(b!==void 0&&x!==b)return;f((p)=>({command:{...p.command,abortController:null}}))},abort:(b)=>{let{abortController:x}=y().command;if(x&&!x.signal.aborted)x.abort(b??"user-cancel");f((p)=>({command:{...p.command,isProcessing:!1},session:{...p.session,providerAdmission:null,providerCircuit:null,providerRetry:null,providerStall:null,providerRecovery:null,turnActivity:null,actionStationarity:null}}))},rememberFollowUpPresentation:(b,x)=>{f((p)=>({command:{...p.command,followUpPresentations:Object.fromEntries([...Object.entries(p.command.followUpPresentations),[b,x]].slice(-20))}}))},takeFollowUpPresentation:(b)=>{let x=y().command.followUpPresentations[b];if(!x)return;return f((p)=>({command:{...p.command,followUpPresentations:Object.fromEntries(Object.entries(p.command.followUpPresentations).filter(([h])=>h!==b))}})),x},clearFollowUpPresentations:()=>{f((b)=>({command:{...b.command,followUpPresentations:{}}}))},setRecoveredSteeringCount:(b)=>{f((x)=>({command:{...x.command,recoveredSteeringCount:Math.max(0,b)}}))}}});var j0={config:null},C=(f,y)=>({...j0,actions:{setConfig:(b)=>{u().configureModelProviders(b.modelProviders,b.models),f((x)=>({config:{...x.config,config:b}}))},updateConfig:(b)=>{let x=y().config.config;if(!x)throw Error(`[ConfigSlice] Config not initialized. Cannot update: ${JSON.stringify(b)}`);let p={...x,...b};if(b.modelProviders||b.models)u().configureModelProviders(p.modelProviders,p.models);f((h)=>({config:{...h.config,config:p}}))}}});var _0={currentFocus:"main-input",previousFocus:null},v=(f)=>({..._0,actions:{setFocus:(y)=>{f((b)=>({focus:{...b.focus,currentFocus:y,previousFocus:b.focus.currentFocus}}))},restorePreviousFocus:()=>{f((y)=>({focus:{...y.focus,currentFocus:y.focus.previousFocus||"main-input",previousFocus:null}}))}}});function I(f,y,b,x){let p=f.messages.find((F)=>F.id===y);if(p)return p;let h={id:y,role:b,content:"",timestamp:x};return f.messages.push(h),h}function t(f,y){let b=Date.parse(y.timestamp)||Date.now();switch(y.type){case"message_created":{let x=I(f,y.data.messageId,y.data.role,b),p=y.data.metadata;if(p&&typeof p==="object"&&!Array.isArray(p))x.metadata=p;return f}case"part_created":case"part_updated":{let{messageId:x,partType:p,payload:h,partId:F}=y.data,z=f.messages.find((G)=>G.id===x)??I(f,x,"assistant",b);if(p==="text"){let G=h.text??"";f.streamingText.delete(F),z.content=G}else if(p==="image")z.content=z.content?`${z.content}
2
- [Image]`:"[Image]";return f}default:return f}}function x0(f,y){if(y.channel!=="content")return f;let b=f.messages.find((h)=>h.id===y.messageId)??I(f,y.messageId,"assistant",Date.now()),p=(f.streamingText.get(y.partId)?.text??"")+y.delta;return f.streamingText.set(y.partId,{messageId:y.messageId,text:p}),b.content=p,f}function b0(f,y,b,x=0,p=0,h){let F=u(),z=h?F.models.getModel(h,f):F.models.getModels().find(($)=>$.id===f);if(!z)return 0;let G=z.cost,Z=y/1e6*G.input+b/1e6*G.output+x/1e6*G.cacheRead+p/1e6*G.cacheWrite;return Math.round(Z*1e6)/1e6}var J={codeBlock:/^```(\w+)?\s*$/,heading:/^ *(#{1,4}) +(.+)/,blockquote:/^(>+)\s?(.*)/,ulItem:/^([ \t]*)([-*+]) +(.+)/,olItem:/^([ \t]*)(\d+)\. +(.+)/,hr:/^ *([-*_] *){3,} *$/,table:/^\|(.+)\|$/,tableSeparator:/^\|[\s]*:?-+:?[\s]*(\|[\s]*:?-+:?[\s]*)+\|?$/,diffStart:/^<<<DIFF>>>$/,diffEnd:/^<<<\/DIFF>>>$/,commandMessage:/<command-message>(.*?)<\/command-message>/};function M0(f){let y=[],b=f.split(/\r?\n/),x=!1,p=[],h=null,F=0,z=!1,G=[],Z=[],$=!1,U=[],w=!1,Y=[],Q=0,X=!0;for(let j=0;j<b.length;j++){let H=b[j];if($){if(H.match(J.diffEnd)){try{let _=JSON.parse(U.join(`
1
+ import{fg as G0}from"./chunk-x6k5ye1z.js";import{Hh as Y0,Ri as l,Ui as Z0,si as W}from"./chunk-z7f2a75f.js";import{Zi as z0}from"./chunk-b22ab7yw.js";import{Qj as B}from"./chunk-xhwdac1j.js";import{devtools as q0,subscribeWithSelector as u0}from"zustand/middleware";import{createStore as D0}from"zustand/vanilla";var o=[{id:"ayu-dark",label:"Ayu Dark",theme:{name:"ayu-dark",colors:{primary:"#ffcc66",secondary:"#bae67e",accent:"#73d0ff",success:"#bae67e",warning:"#ffcc66",error:"#ff3333",info:"#73d0ff",light:"#f0f0f0",dark:"#000000",muted:"#5c6773",highlight:"#2d323b",text:{primary:"#e6e1cf",secondary:"#bae67e",muted:"#5c6773",light:"#ffffff"},background:{primary:"#0f1419",secondary:"#14191f",dark:"#000000"},border:{light:"#2d323b",dark:"#000000"},syntax:{comment:"#5c6773",string:"#bae67e",number:"#ffcc66",keyword:"#ff8f40",function:"#73d0ff",variable:"#e6e1cf",operator:"#f29e74",type:"#73d0ff",tag:"#ff8f40",attr:"#ffd580",default:"#e6e1cf"}},spacing:{xs:0.25,sm:0.5,md:1,lg:1.5,xl:2},typography:{fontSize:{xs:0.75,sm:0.875,base:1,lg:1.125,xl:1.25,"2xl":1.5,"3xl":1.875},fontWeight:{light:300,normal:400,medium:500,semibold:600,bold:700}},borderRadius:{sm:0.125,base:0.25,lg:0.5,xl:0.75},boxShadow:{sm:"0 1px 2px 0 rgba(0, 0, 0, 0.2)",base:"0 1px 3px 0 rgba(0, 0, 0, 0.3), 0 1px 2px 0 rgba(0, 0, 0, 0.2)",lg:"0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -2px rgba(0, 0, 0, 0.2)"}},tags:["dark","popular"]},{id:"dracula",label:"Dracula",theme:{name:"dracula",colors:{primary:"#bd93f9",secondary:"#ffb86c",accent:"#ff79c6",success:"#50fa7b",warning:"#f1fa8c",error:"#ff5555",info:"#8be9fd",light:"#f8f8f2",dark:"#282a36",muted:"#6272a4",highlight:"#44475a",text:{primary:"#f8f8f2",secondary:"#f1fa8c",muted:"#6272a4",light:"#ffffff"},background:{primary:"#282a36",secondary:"#44475a",dark:"#21222c"},border:{light:"#44475a",dark:"#000000"},syntax:{comment:"#6272a4",string:"#f1fa8c",number:"#bd93f9",keyword:"#ff79c6",function:"#50fa7b",variable:"#f8f8f2",operator:"#ff79c6",type:"#8be9fd",tag:"#ff79c6",attr:"#50fa7b",default:"#f8f8f2"}},spacing:{xs:0.25,sm:0.5,md:1,lg:1.5,xl:2},typography:{fontSize:{xs:0.75,sm:0.875,base:1,lg:1.125,xl:1.25,"2xl":1.5,"3xl":1.875},fontWeight:{light:300,normal:400,medium:500,semibold:600,bold:700}},borderRadius:{sm:0.125,base:0.25,lg:0.5,xl:0.75},boxShadow:{sm:"0 1px 2px 0 rgba(40, 42, 54, 0.2)",base:"0 1px 3px 0 rgba(40, 42, 54, 0.3), 0 1px 2px 0 rgba(40, 42, 54, 0.2)",lg:"0 10px 15px -3px rgba(40, 42, 54, 0.3), 0 4px 6px -2px rgba(40, 42, 54, 0.2)"}},tags:["dark","popular"]},{id:"monokai",label:"Monokai",theme:{name:"monokai",colors:{primary:"#66d9ef",secondary:"#a6e22e",accent:"#f92672",success:"#a6e22e",warning:"#e6db74",error:"#f92672",info:"#66d9ef",light:"#f8f8f2",dark:"#272822",muted:"#75715e",highlight:"#3e3d32",text:{primary:"#f8f8f2",secondary:"#e6db74",muted:"#75715e",light:"#ffffff"},background:{primary:"#272822",secondary:"#3e3d32",dark:"#1e1f1c"},border:{light:"#3e3d32",dark:"#000000"},syntax:{comment:"#75715e",string:"#e6db74",number:"#ae81ff",keyword:"#f92672",function:"#a6e22e",variable:"#f8f8f2",operator:"#f92672",type:"#66d9ef",tag:"#f92672",attr:"#a6e22e",default:"#f8f8f2"}},spacing:{xs:0.25,sm:0.5,md:1,lg:1.5,xl:2},typography:{fontSize:{xs:0.75,sm:0.875,base:1,lg:1.125,xl:1.25,"2xl":1.5,"3xl":1.875},fontWeight:{light:300,normal:400,medium:500,semibold:600,bold:700}},borderRadius:{sm:0.125,base:0.25,lg:0.5,xl:0.75},boxShadow:{sm:"0 1px 2px 0 rgba(39, 40, 34, 0.2)",base:"0 1px 3px 0 rgba(39, 40, 34, 0.3), 0 1px 2px 0 rgba(39, 40, 34, 0.2)",lg:"0 10px 15px -3px rgba(39, 40, 34, 0.3), 0 4px 6px -2px rgba(39, 40, 34, 0.2)"}},tags:["dark","classic"]},{id:"nord",label:"Nord",theme:{name:"nord",colors:{primary:"#88c0d0",secondary:"#81a1c1",accent:"#b48ead",success:"#a3be8c",warning:"#ebcb8b",error:"#bf616a",info:"#88c0d0",light:"#eceff4",dark:"#2e3440",muted:"#4c566a",highlight:"#434c5e",text:{primary:"#eceff4",secondary:"#d8dee9",muted:"#4c566a",light:"#ffffff"},background:{primary:"#2e3440",secondary:"#3b4252",dark:"#242933"},border:{light:"#434c5e",dark:"#000000"},syntax:{comment:"#616e88",string:"#a3be8c",number:"#b48ead",keyword:"#81a1c1",function:"#88c0d0",variable:"#d8dee9",operator:"#81a1c1",type:"#8fbcbb",tag:"#81a1c1",attr:"#8fbcbb",default:"#eceff4"}},spacing:{xs:0.25,sm:0.5,md:1,lg:1.5,xl:2},typography:{fontSize:{xs:0.75,sm:0.875,base:1,lg:1.125,xl:1.25,"2xl":1.5,"3xl":1.875},fontWeight:{light:300,normal:400,medium:500,semibold:600,bold:700}},borderRadius:{sm:0.125,base:0.25,lg:0.5,xl:0.75},boxShadow:{sm:"0 1px 2px 0 rgba(46, 52, 64, 0.2)",base:"0 1px 3px 0 rgba(46, 52, 64, 0.3), 0 1px 2px 0 rgba(46, 52, 64, 0.2)",lg:"0 10px 15px -3px rgba(46, 52, 64, 0.3), 0 4px 6px -2px rgba(46, 52, 64, 0.2)"}},tags:["dark","minimal"]},{id:"solarized-light",label:"Solarized Light",theme:{name:"solarized-light",colors:{primary:"#268bd2",secondary:"#2aa198",accent:"#d33682",success:"#859900",warning:"#cb4b16",error:"#dc322f",info:"#268bd2",light:"#fdf6e3",dark:"#073642",muted:"#93a1a1",highlight:"#eee8d5",text:{primary:"#586e75",secondary:"#657b83",muted:"#93a1a1",light:"#002b36"},background:{primary:"#fdf6e3",secondary:"#eee8d5",dark:"#073642"},border:{light:"#eee8d5",dark:"#073642"},syntax:{comment:"#93a1a1",string:"#2aa198",number:"#d33682",keyword:"#859900",function:"#268bd2",variable:"#657b83",operator:"#859900",type:"#b58900",tag:"#268bd2",attr:"#93a1a1",default:"#657b83"}},spacing:{xs:0.25,sm:0.5,md:1,lg:1.5,xl:2},typography:{fontSize:{xs:0.75,sm:0.875,base:1,lg:1.125,xl:1.25,"2xl":1.5,"3xl":1.875},fontWeight:{light:300,normal:400,medium:500,semibold:600,bold:700}},borderRadius:{sm:0.125,base:0.25,lg:0.5,xl:0.75},boxShadow:{sm:"0 1px 2px 0 rgba(253, 246, 227, 0.2)",base:"0 1px 3px 0 rgba(253, 246, 227, 0.3), 0 1px 2px 0 rgba(253, 246, 227, 0.2)",lg:"0 10px 15px -3px rgba(253, 246, 227, 0.3), 0 4px 6px -2px rgba(253, 246, 227, 0.2)"}},tags:["light"]},{id:"solarized-dark",label:"Solarized Dark",theme:{name:"solarized-dark",colors:{primary:"#268bd2",secondary:"#2aa198",accent:"#d33682",success:"#859900",warning:"#b58900",error:"#dc322f",info:"#268bd2",light:"#fdf6e3",dark:"#073642",muted:"#586e75",highlight:"#073642",text:{primary:"#839496",secondary:"#93a1a1",muted:"#586e75",light:"#fdf6e3"},background:{primary:"#002b36",secondary:"#073642",dark:"#001f29"},border:{light:"#073642",dark:"#000000"},syntax:{comment:"#586e75",string:"#2aa198",number:"#d33682",keyword:"#859900",function:"#268bd2",variable:"#839496",operator:"#859900",type:"#b58900",tag:"#268bd2",attr:"#93a1a1",default:"#839496"}},spacing:{xs:0.25,sm:0.5,md:1,lg:1.5,xl:2},typography:{fontSize:{xs:0.75,sm:0.875,base:1,lg:1.125,xl:1.25,"2xl":1.5,"3xl":1.875},fontWeight:{light:300,normal:400,medium:500,semibold:600,bold:700}},borderRadius:{sm:0.125,base:0.25,lg:0.5,xl:0.75},boxShadow:{sm:"0 1px 2px 0 rgba(0, 43, 54, 0.2)",base:"0 1px 3px 0 rgba(0, 43, 54, 0.3), 0 1px 2px 0 rgba(0, 43, 54, 0.2)",lg:"0 10px 15px -3px rgba(0, 43, 54, 0.3), 0 4px 6px -2px rgba(0, 43, 54, 0.2)"}},tags:["dark"]},{id:"tokyo-night",label:"Tokyo Night",theme:{name:"tokyo-night",colors:{primary:"#7aa2f7",secondary:"#7dcfff",accent:"#bb9af7",success:"#9ece6a",warning:"#e0af68",error:"#f7768e",info:"#7aa2f7",light:"#c0caf5",dark:"#1a1b26",muted:"#565f89",highlight:"#292e42",text:{primary:"#a9b1d6",secondary:"#c0caf5",muted:"#565f89",light:"#ffffff"},background:{primary:"#1a1b26",secondary:"#292e42",dark:"#16161e"},border:{light:"#292e42",dark:"#000000"},syntax:{comment:"#565f89",string:"#9ece6a",number:"#ff9e64",keyword:"#bb9af7",function:"#7aa2f7",variable:"#c0caf5",operator:"#89ddff",type:"#7dcfff",tag:"#f7768e",attr:"#7aa2f7",default:"#a9b1d6"}},spacing:{xs:0.25,sm:0.5,md:1,lg:1.5,xl:2},typography:{fontSize:{xs:0.75,sm:0.875,base:1,lg:1.125,xl:1.25,"2xl":1.5,"3xl":1.875},fontWeight:{light:300,normal:400,medium:500,semibold:600,bold:700}},borderRadius:{sm:0.125,base:0.25,lg:0.5,xl:0.75},boxShadow:{sm:"0 1px 2px 0 rgba(26, 27, 38, 0.2)",base:"0 1px 3px 0 rgba(26, 27, 38, 0.3), 0 1px 2px 0 rgba(26, 27, 38, 0.2)",lg:"0 10px 15px -3px rgba(26, 27, 38, 0.3), 0 4px 6px -2px rgba(26, 27, 38, 0.2)"}},tags:["dark","popular"]},{id:"github",label:"GitHub",theme:{name:"github",colors:{primary:"#0969da",secondary:"#8250df",accent:"#bc4c00",success:"#1a7f37",warning:"#bc4c00",error:"#d1242f",info:"#0969da",light:"#f6f8fa",dark:"#24292f",muted:"#6e7781",highlight:"#ddf4ff",text:{primary:"#24292f",secondary:"#57606a",muted:"#6e7781",light:"#ffffff"},background:{primary:"#ffffff",secondary:"#f6f8fa",dark:"#24292f"},border:{light:"#d0d7de",dark:"#24292f"},syntax:{comment:"#6e7781",string:"#0a3069",number:"#0550ae",keyword:"#cf222e",function:"#8250df",variable:"#24292f",operator:"#cf222e",type:"#0550ae",tag:"#116329",attr:"#0550ae",default:"#24292f"}},spacing:{xs:0.25,sm:0.5,md:1,lg:1.5,xl:2},typography:{fontSize:{xs:0.75,sm:0.875,base:1,lg:1.125,xl:1.25,"2xl":1.5,"3xl":1.875},fontWeight:{light:300,normal:400,medium:500,semibold:600,bold:700}},borderRadius:{sm:0.125,base:0.25,lg:0.5,xl:0.75},boxShadow:{sm:"0 1px 2px 0 rgba(255, 255, 255, 0.2)",base:"0 1px 3px 0 rgba(255, 255, 255, 0.3), 0 1px 2px 0 rgba(255, 255, 255, 0.2)",lg:"0 10px 15px -3px rgba(255, 255, 255, 0.3), 0 4px 6px -2px rgba(255, 255, 255, 0.2)"}},tags:["light","minimal"]},{id:"gruvbox",label:"Gruvbox",theme:{name:"gruvbox",colors:{primary:"#83a598",secondary:"#8ec07c",accent:"#d3869b",success:"#b8bb26",warning:"#fabd2f",error:"#fb4934",info:"#83a598",light:"#fbf1c7",dark:"#282828",muted:"#928374",highlight:"#3c3836",text:{primary:"#ebdbb2",secondary:"#d5c4a1",muted:"#928374",light:"#ffffff"},background:{primary:"#282828",secondary:"#3c3836",dark:"#1d2021"},border:{light:"#3c3836",dark:"#000000"},syntax:{comment:"#928374",string:"#b8bb26",number:"#d3869b",keyword:"#fb4934",function:"#8ec07c",variable:"#ebdbb2",operator:"#fe8019",type:"#fabd2f",tag:"#fb4934",attr:"#b8bb26",default:"#ebdbb2"}},spacing:{xs:0.25,sm:0.5,md:1,lg:1.5,xl:2},typography:{fontSize:{xs:0.75,sm:0.875,base:1,lg:1.125,xl:1.25,"2xl":1.5,"3xl":1.875},fontWeight:{light:300,normal:400,medium:500,semibold:600,bold:700}},borderRadius:{sm:0.125,base:0.25,lg:0.5,xl:0.75},boxShadow:{sm:"0 1px 2px 0 rgba(40, 40, 40, 0.2)",base:"0 1px 3px 0 rgba(40, 40, 40, 0.3), 0 1px 2px 0 rgba(40, 40, 40, 0.2)",lg:"0 10px 15px -3px rgba(40, 40, 40, 0.3), 0 4px 6px -2px rgba(40, 40, 40, 0.2)"}},tags:["dark","warm"]},{id:"one-dark",label:"One Dark",theme:{name:"one-dark",colors:{primary:"#61afef",secondary:"#c678dd",accent:"#e5c07b",success:"#98c379",warning:"#e5c07b",error:"#e06c75",info:"#56b6c2",light:"#abb2bf",dark:"#282c34",muted:"#5c6370",highlight:"#3e4451",text:{primary:"#abb2bf",secondary:"#c6c8d0",muted:"#5c6370",light:"#ffffff"},background:{primary:"#282c34",secondary:"#3e4451",dark:"#21252b"},border:{light:"#3e4451",dark:"#000000"},syntax:{comment:"#5c6370",string:"#98c379",number:"#d19a66",keyword:"#c678dd",function:"#61afef",variable:"#e06c75",operator:"#56b6c2",type:"#e5c07b",tag:"#e06c75",attr:"#d19a66",default:"#abb2bf"}},spacing:{xs:0.25,sm:0.5,md:1,lg:1.5,xl:2},typography:{fontSize:{xs:0.75,sm:0.875,base:1,lg:1.125,xl:1.25,"2xl":1.5,"3xl":1.875},fontWeight:{light:300,normal:400,medium:500,semibold:600,bold:700}},borderRadius:{sm:0.125,base:0.25,lg:0.5,xl:0.75},boxShadow:{sm:"0 1px 2px 0 rgba(40, 44, 52, 0.2)",base:"0 1px 3px 0 rgba(40, 44, 52, 0.3), 0 1px 2px 0 rgba(40, 44, 52, 0.2)",lg:"0 10px 15px -3px rgba(40, 44, 52, 0.3), 0 4px 6px -2px rgba(40, 44, 52, 0.2)"}},tags:["dark","popular"]},{id:"catppuccin",label:"Catppuccin",theme:{name:"catppuccin",colors:{primary:"#89b4fa",secondary:"#cba6f7",accent:"#f5c2e7",success:"#a6e3a1",warning:"#f9e2af",error:"#f38ba8",info:"#89dceb",light:"#cdd6f4",dark:"#11111b",muted:"#6c7086",highlight:"#181825",text:{primary:"#cdd6f4",secondary:"#bac2de",muted:"#6c7086",light:"#ffffff"},background:{primary:"#1e1e2e",secondary:"#181825",dark:"#11111b"},border:{light:"#181825",dark:"#000000"},syntax:{comment:"#6c7086",string:"#a6e3a1",number:"#fab387",keyword:"#cba6f7",function:"#89b4fa",variable:"#cdd6f4",operator:"#89dceb",type:"#f5c2e7",tag:"#f38ba8",attr:"#89b4fa",default:"#cdd6f4"}},spacing:{xs:0.25,sm:0.5,md:1,lg:1.5,xl:2},typography:{fontSize:{xs:0.75,sm:0.875,base:1,lg:1.125,xl:1.25,"2xl":1.5,"3xl":1.875},fontWeight:{light:300,normal:400,medium:500,semibold:600,bold:700}},borderRadius:{sm:0.125,base:0.25,lg:0.5,xl:0.75},boxShadow:{sm:"0 1px 2px 0 rgba(30, 30, 46, 0.2)",base:"0 1px 3px 0 rgba(30, 30, 46, 0.3), 0 1px 2px 0 rgba(30, 30, 46, 0.2)",lg:"0 10px 15px -3px rgba(30, 30, 46, 0.3), 0 4px 6px -2px rgba(30, 30, 46, 0.2)"}},tags:["dark","pastel"]},{id:"rose-pine",label:"Rose Pine",theme:{name:"rose-pine",colors:{primary:"#9ccfd8",secondary:"#c4a7e7",accent:"#f6c177",success:"#31748f",warning:"#f6c177",error:"#eb6f92",info:"#9ccfd8",light:"#e0def4",dark:"#191724",muted:"#6e6a86",highlight:"#1f1d2e",text:{primary:"#e0def4",secondary:"#cecacd",muted:"#6e6a86",light:"#ffffff"},background:{primary:"#191724",secondary:"#1f1d2e",dark:"#12101a"},border:{light:"#1f1d2e",dark:"#000000"},syntax:{comment:"#6e6a86",string:"#9ccfd8",number:"#ea9a97",keyword:"#c4a7e7",function:"#31748f",variable:"#e0def4",operator:"#f6c177",type:"#9ccfd8",tag:"#eb6f92",attr:"#f6c177",default:"#e0def4"}},spacing:{xs:0.25,sm:0.5,md:1,lg:1.5,xl:2},typography:{fontSize:{xs:0.75,sm:0.875,base:1,lg:1.125,xl:1.25,"2xl":1.5,"3xl":1.875},fontWeight:{light:300,normal:400,medium:500,semibold:600,bold:700}},borderRadius:{sm:0.125,base:0.25,lg:0.5,xl:0.75},boxShadow:{sm:"0 1px 2px 0 rgba(25, 23, 36, 0.2)",base:"0 1px 3px 0 rgba(25, 23, 36, 0.3), 0 1px 2px 0 rgba(25, 23, 36, 0.2)",lg:"0 10px 15px -3px rgba(25, 23, 36, 0.3), 0 4px 6px -2px rgba(25, 23, 36, 0.2)"}},tags:["dark","elegant"]},{id:"kanagawa",label:"Kanagawa",theme:{name:"kanagawa",colors:{primary:"#8ba4b0",secondary:"#a292a3",accent:"#c47fd5",success:"#76946a",warning:"#c0a36e",error:"#c34043",info:"#7e9cd8",light:"#dcd7ba",dark:"#1f1f28",muted:"#727169",highlight:"#2a2a37",text:{primary:"#dcd7ba",secondary:"#c8c093",muted:"#727169",light:"#ffffff"},background:{primary:"#1f1f28",secondary:"#2a2a37",dark:"#16161d"},border:{light:"#2a2a37",dark:"#000000"},syntax:{comment:"#727169",string:"#98bb6c",number:"#d27e99",keyword:"#957fb8",function:"#7e9cd8",variable:"#dcd7ba",operator:"#c0a36e",type:"#7aa89f",tag:"#c34043",attr:"#7fb4ca",default:"#dcd7ba"}},spacing:{xs:0.25,sm:0.5,md:1,lg:1.5,xl:2},typography:{fontSize:{xs:0.75,sm:0.875,base:1,lg:1.125,xl:1.25,"2xl":1.5,"3xl":1.875},fontWeight:{light:300,normal:400,medium:500,semibold:600,bold:700}},borderRadius:{sm:0.125,base:0.25,lg:0.5,xl:0.75},boxShadow:{sm:"0 1px 2px 0 rgba(31, 31, 40, 0.2)",base:"0 1px 3px 0 rgba(31, 31, 40, 0.3), 0 1px 2px 0 rgba(31, 31, 40, 0.2)",lg:"0 10px 15px -3px rgba(31, 31, 40, 0.3), 0 4px 6px -2px rgba(31, 31, 40, 0.2)"}},tags:["dark","japanese"]}];var a=o;var n={primary:"#0066cc",secondary:"#6c757d",accent:"#e83e8c",success:"#28a745",warning:"#ffc107",error:"#dc3545",info:"#17a2b8",light:"#f8f9fa",dark:"#343a40",muted:"#6c757d",highlight:"#fff3cd",text:{primary:"#212529",secondary:"#6c757d",muted:"#6c757d",light:"#ffffff"},background:{primary:"#ffffff",secondary:"#f8f9fa",dark:"#343a40"},border:{light:"#dee2e6",dark:"#495057"},syntax:{comment:"#6c757d",string:"#28a745",number:"#e83e8c",keyword:"#007bff",function:"#17a2b8",variable:"#495057",operator:"#ffc107",type:"#007bff",tag:"#dc3545",attr:"#ffc107",default:"#212529"}},S={name:"default",colors:n,spacing:{xs:0.25,sm:0.5,md:1,lg:1.5,xl:2},typography:{fontSize:{xs:0.75,sm:0.875,base:1,lg:1.125,xl:1.25,"2xl":1.5,"3xl":1.875},fontWeight:{light:300,normal:400,medium:500,semibold:600,bold:700}},borderRadius:{sm:0.125,base:0.25,lg:0.5,xl:0.75},boxShadow:{sm:"0 1px 2px 0 rgba(0, 0, 0, 0.05)",base:"0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06)",lg:"0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05)"}},V0={...S,name:"dark",colors:{...n,text:{primary:"#ffffff",secondary:"#e2e8f0",muted:"#94a3b8",light:"#000000"},background:{primary:"#1e293b",secondary:"#334155",dark:"#0f172a"},border:{light:"#475569",dark:"#64748b"},syntax:{comment:"#94a3b8",string:"#34d399",number:"#f472b6",keyword:"#60a5fa",function:"#06b6d4",variable:"#e2e8f0",operator:"#fbbf24",type:"#60a5fa",tag:"#fb7185",attr:"#fbbf24",default:"#ffffff"}}};class s{currentTheme=S;themes=new Map;constructor(){this.themes.set("default",S),this.themes.set("dark",V0);for(let f of a)this.themes.set(f.id,f.theme)}setTheme(f){let y=this.themes.get(f);if(y)this.currentTheme=y;else throw Error(`Theme '${f}' not found`)}getTheme(){return this.currentTheme}getAvailableThemes(){return Array.from(this.themes.keys())}getCurrentThemeName(){return this.currentTheme.name}getThemeByName(f){return this.themes.get(f)}hasTheme(f){return this.themes.has(f)}}var e=new s;var H0={initializationStatus:"idle",initializationError:null,activeModal:"none",sessionSelectorData:void 0,sessionHistoryViewerData:void 0,taskAttentionStatus:"idle",taskAttentionUnreadKeys:[],followUpQueue:null,followUpQueueOwner:null,followUpQueueMutation:{pending:!1,supersededVersions:[]},modelEditorTarget:null,tasks:[],awaitingSecondCtrlC:!1,reasoningEffort:"off",serviceTier:"auto",responseVerbosity:"auto",communicationStyle:"auto",subagentProgress:null,subagentProgresses:{},sideConversation:null,teams:[]},g=(f)=>({...H0,actions:{setInitializationStatus:(y)=>{f((b)=>({app:{...b.app,initializationStatus:y}}))},setInitializationError:(y)=>{f((b)=>({app:{...b.app,initializationError:y}}))},setActiveModal:(y)=>{f((b)=>({app:{...b.app,activeModal:y}}))},showSessionSelector:(y,b="resume")=>{f((x)=>({app:{...x.app,activeModal:"sessionSelector",sessionSelectorData:{intent:b,sessions:y},sessionHistoryViewerData:void 0}}))},showSessionHistoryViewer:(y,b="resume")=>{f((x)=>({app:{...x.app,activeModal:"sessionHistoryViewer",sessionSelectorData:void 0,sessionHistoryViewerData:{intent:b,session:y}}}))},showModelEditWizard:(y)=>{f((b)=>({app:{...b.app,activeModal:"modelEditWizard",modelEditorTarget:y}}))},closeModal:()=>{f((y)=>({app:{...y.app,activeModal:"none",sessionSelectorData:void 0,sessionHistoryViewerData:void 0,modelEditorTarget:null}}))},setTasks:(y)=>{f((b)=>({app:{...b.app,tasks:y}}))},updateTask:(y)=>{f((b)=>({app:{...b.app,tasks:b.app.tasks.map((x)=>x.id===y.id?y:x)}}))},setAwaitingSecondCtrlC:(y)=>{f((b)=>({app:{...b.app,awaitingSecondCtrlC:y}}))},projectTaskAttentionState:(y,b,x)=>{f((p)=>({app:{...p.app,taskAttentionStatus:y,taskAttentionUnreadKeys:[...b],sessionSelectorData:y==="ready"&&p.app.activeModal==="sessionSelector"&&p.app.sessionSelectorData?{...p.app.sessionSelectorData,sessions:[...x]}:p.app.sessionSelectorData}}))},projectFollowUpQueue:(y,b)=>{f((x)=>{let p=[x.session.workspaceRoot,x.session.sessionId,""].join("\x00");if(b!==void 0&&!b.startsWith(p))return x;if(b!==void 0&&x.app.followUpQueueOwner!==null&&x.app.followUpQueueOwner!==b)return x;let h=x.app.followUpQueueMutation.supersededVersions??[];if(h.includes(y.version))return x;let F=x.app.followUpQueue&&x.app.followUpQueue.version!==y.version?[...h,x.app.followUpQueue.version].slice(-16):h;return{app:{...x.app,followUpQueue:y,followUpQueueOwner:b??x.app.followUpQueueOwner,followUpQueueMutation:{pending:x.app.followUpQueueMutation.pending,...x.app.followUpQueueMutation.messageId?{messageId:x.app.followUpQueueMutation.messageId}:{},supersededVersions:F}},command:{...x.command,followUpPresentations:Object.fromEntries(Object.entries(x.command.followUpPresentations).filter(([z])=>y.items.some((G)=>G.id===z)))}}})},claimFollowUpQueueOwner:(y)=>{f((b)=>{let x=[b.session.workspaceRoot,b.session.sessionId,""].join("\x00");if(!y.startsWith(x))return b;if(b.app.followUpQueueOwner===y)return b;return{app:{...b.app,followUpQueue:null,followUpQueueOwner:y,followUpQueueMutation:{pending:!1,supersededVersions:[]}},command:{...b.command,followUpPresentations:{}}}})},setFollowUpQueueMutation:(y,b)=>{f((x)=>{let p=[x.session.workspaceRoot,x.session.sessionId,""].join("\x00");if(b!==void 0&&!b.startsWith(p))return x;if(b!==void 0&&x.app.followUpQueueOwner!==null&&x.app.followUpQueueOwner!==b)return x;return{app:{...x.app,followUpQueueMutation:{...y,supersededVersions:y.supersededVersions??x.app.followUpQueueMutation.supersededVersions}}}})},clearFollowUpQueue:(y)=>{f((b)=>{if(y!==void 0&&b.app.followUpQueueOwner!==y)return b;return{app:{...b.app,followUpQueue:null,followUpQueueOwner:null,followUpQueueMutation:{pending:!1,supersededVersions:[]}},command:{...b.command,followUpPresentations:{}}}})},setReasoningEffort:(y)=>{f((b)=>({app:{...b.app,reasoningEffort:y}}))},setServiceTier:(y)=>{f((b)=>({app:{...b.app,serviceTier:y}}))},setResponseVerbosity:(y)=>{f((b)=>({app:{...b.app,responseVerbosity:y}}))},setCommunicationStyle:(y)=>{f((b)=>({app:{...b.app,communicationStyle:y}}))},setThinkingModeEnabled:(y)=>{f((b)=>({app:{...b.app,reasoningEffort:y?"auto":"off"}}))},toggleThinkingMode:()=>{f((y)=>({app:{...y.app,reasoningEffort:y.app.reasoningEffort==="off"?"auto":"off"}}))},startSubagentProgress:(y,b,x)=>{f((p)=>({app:{...p.app,subagentProgresses:{...p.app.subagentProgresses,[y]:{id:y,type:b,description:x,status:"running",startTime:Date.now()}},subagentProgress:{id:y,type:b,description:x,status:"running",startTime:Date.now()}}}))},updateSubagentTool:(y,b)=>{f((x)=>{let p=x.app.subagentProgresses[y];if(!p)return x;let h={...p,currentTool:b};return{app:{...x.app,subagentProgresses:{...x.app.subagentProgresses,[y]:h},subagentProgress:x.app.subagentProgress?.id===y?h:x.app.subagentProgress}}})},completeSubagentProgress:(y,b,x)=>{f((p)=>{let h=p.app.subagentProgresses[y];if(!h)return p;let F=x?.trim(),z={...h,status:b?"completed":"failed",currentTool:void 0,...!b&&F?{terminalSummary:F.slice(0,200)}:{}};return{app:{...p.app,subagentProgresses:{...p.app.subagentProgresses,[y]:z},subagentProgress:p.app.subagentProgress?.id===y?z:p.app.subagentProgress}}}),setTimeout(()=>{f((p)=>{let h=p.app.subagentProgresses[y];if(!h||h.status==="running")return p;let F={...p.app.subagentProgresses};delete F[y];let z=Object.values(F);return{app:{...p.app,subagentProgresses:F,subagentProgress:p.app.subagentProgress?.id===y?z[z.length-1]??null:p.app.subagentProgress}}})},1500)},startSideConversation:(y,b)=>{f((x)=>({app:{...x.app,sideConversation:{requestId:y,question:b,status:"loading"}}}))},completeSideConversation:(y,b)=>{f((x)=>{if(x.app.sideConversation?.requestId!==y)return x;return{app:{...x.app,sideConversation:{requestId:y,question:x.app.sideConversation.question,status:"completed",response:b.response,durationMs:b.durationMs}}}})},failSideConversation:(y,b)=>{f((x)=>{if(x.app.sideConversation?.requestId!==y)return x;return{app:{...x.app,sideConversation:{requestId:y,question:x.app.sideConversation.question,status:"error",error:b}}}})},dismissSideConversation:()=>{f((y)=>({app:{...y.app,sideConversation:null}}))},setTeams:(y)=>{f((b)=>({app:{...b.app,teams:y}}))}}});var U0={isProcessing:!1,abortController:null,followUpPresentations:{},recoveredSteeringCount:0},T=(f,y)=>({...U0,actions:{setProcessing:(b)=>{f((x)=>({command:{...x.command,isProcessing:b},...!b?{session:{...x.session,providerAdmission:null,providerCircuit:null,providerRetry:null,providerStall:null,providerRecovery:null,turnActivity:null,actionStationarity:null}}:{}}))},createAbortController:()=>{let b=y().command.abortController;if(b&&!b.signal.aborted)b.abort("interrupted-by-new-command");let x=new AbortController;return f((p)=>({command:{...p.command,abortController:x}})),x},getAbortController:()=>{return y().command.abortController},clearAbortController:(b)=>{let x=y().command.abortController;if(b!==void 0&&x!==b)return;f((p)=>({command:{...p.command,abortController:null}}))},abort:(b)=>{let{abortController:x}=y().command;if(x&&!x.signal.aborted)x.abort(b??"user-cancel");f((p)=>({command:{...p.command,isProcessing:!1},session:{...p.session,providerAdmission:null,providerCircuit:null,providerRetry:null,providerStall:null,providerRecovery:null,turnActivity:null,actionStationarity:null}}))},rememberFollowUpPresentation:(b,x)=>{f((p)=>({command:{...p.command,followUpPresentations:Object.fromEntries([...Object.entries(p.command.followUpPresentations),[b,x]].slice(-20))}}))},takeFollowUpPresentation:(b)=>{let x=y().command.followUpPresentations[b];if(!x)return;return f((p)=>({command:{...p.command,followUpPresentations:Object.fromEntries(Object.entries(p.command.followUpPresentations).filter(([h])=>h!==b))}})),x},clearFollowUpPresentations:()=>{f((b)=>({command:{...b.command,followUpPresentations:{}}}))},setRecoveredSteeringCount:(b)=>{f((x)=>({command:{...x.command,recoveredSteeringCount:Math.max(0,b)}}))}}});var j0={config:null},C=(f,y)=>({...j0,actions:{setConfig:(b)=>{B().configureModelProviders(b.modelProviders,b.models),f((x)=>({config:{...x.config,config:b}}))},updateConfig:(b)=>{let x=y().config.config;if(!x)throw Error(`[ConfigSlice] Config not initialized. Cannot update: ${JSON.stringify(b)}`);let p={...x,...b};if(b.modelProviders||b.models)B().configureModelProviders(p.modelProviders,p.models);f((h)=>({config:{...h.config,config:p}}))}}});var _0={currentFocus:"main-input",previousFocus:null},v=(f)=>({..._0,actions:{setFocus:(y)=>{f((b)=>({focus:{...b.focus,currentFocus:y,previousFocus:b.focus.currentFocus}}))},restorePreviousFocus:()=>{f((y)=>({focus:{...y.focus,currentFocus:y.focus.previousFocus||"main-input",previousFocus:null}}))}}});function I(f,y,b,x){let p=f.messages.find((F)=>F.id===y);if(p)return p;let h={id:y,role:b,content:"",timestamp:x};return f.messages.push(h),h}function t(f,y){let b=Date.parse(y.timestamp)||Date.now();switch(y.type){case"message_created":{let x=I(f,y.data.messageId,y.data.role,b),p=y.data.metadata;if(p&&typeof p==="object"&&!Array.isArray(p))x.metadata=p;return f}case"part_created":case"part_updated":{let{messageId:x,partType:p,payload:h,partId:F}=y.data,z=f.messages.find((G)=>G.id===x)??I(f,x,"assistant",b);if(p==="text"){let G=h.text??"";f.streamingText.delete(F),z.content=G}else if(p==="image")z.content=z.content?`${z.content}
2
+ [Image]`:"[Image]";return f}default:return f}}function x0(f,y){if(y.channel!=="content")return f;let b=f.messages.find((h)=>h.id===y.messageId)??I(f,y.messageId,"assistant",Date.now()),p=(f.streamingText.get(y.partId)?.text??"")+y.delta;return f.streamingText.set(y.partId,{messageId:y.messageId,text:p}),b.content=p,f}function b0(f,y,b,x=0,p=0,h){let F=B(),z=h?F.models.getModel(h,f):F.models.getModels().find(($)=>$.id===f);if(!z)return 0;let G=z.cost,Z=y/1e6*G.input+b/1e6*G.output+x/1e6*G.cacheRead+p/1e6*G.cacheWrite;return Math.round(Z*1e6)/1e6}var J={codeBlock:/^```(\w+)?\s*$/,heading:/^ *(#{1,4}) +(.+)/,blockquote:/^(>+)\s?(.*)/,ulItem:/^([ \t]*)([-*+]) +(.+)/,olItem:/^([ \t]*)(\d+)\. +(.+)/,hr:/^ *([-*_] *){3,} *$/,table:/^\|(.+)\|$/,tableSeparator:/^\|[\s]*:?-+:?[\s]*(\|[\s]*:?-+:?[\s]*)+\|?$/,diffStart:/^<<<DIFF>>>$/,diffEnd:/^<<<\/DIFF>>>$/,commandMessage:/<command-message>(.*?)<\/command-message>/};function M0(f){let y=[],b=f.split(/\r?\n/),x=!1,p=[],h=null,F=0,z=!1,G=[],Z=[],$=!1,U=[],w=!1,Y=[],Q=0,X=!0;for(let j=0;j<b.length;j++){let H=b[j];if($){if(H.match(J.diffEnd)){try{let _=JSON.parse(U.join(`
3
3
  `));y.push({type:"diff",content:"",diffData:{patch:_.patch,startLine:_.startLine,matchLine:_.matchLine}})}catch(_){y.push({type:"text",content:U.join(`
4
4
  `)})}$=!1,U=[],X=!1;continue}U.push(H);continue}if(H.match(J.diffStart)){$=!0,U=[],X=!1;continue}if(x){let _=H.match(J.codeBlock),O=H.trim()==="```";if(_&&_[1])F++,p.push(H);else if(O)if(F>0)F--,p.push(H);else{let $0=p.join(`
5
- `);y.push({type:"code",content:$0,language:h||void 0}),x=!1,p=[],h=null,F=0,X=!1}else p.push(H);continue}let P=H.match(J.codeBlock);if(P){x=!0,h=P[1]||null,F=0,X=!1;continue}let q=H.match(J.table),r=H.match(J.tableSeparator);if(q&&!z){if(j+1<b.length){if(b[j+1].match(J.tableSeparator)){z=!0,G=q[1].split("|").map((O)=>O.trim()).filter((O)=>O.length>0),Z=[],X=!1;continue}}}if(z&&r)continue;if(z&&q){let _=q[1].split("|").map((O)=>O.trim()).filter((O)=>O.length>0);while(_.length<G.length)_.push("");if(_.length>G.length)_.length=G.length;Z.push(_);continue}if(z&&!q){if(G.length>0&&Z.length>0)y.push({type:"table",content:"",tableData:{headers:G,rows:Z}});z=!1,G=[],Z=[]}let N=H.match(J.blockquote);if(N){let _=N[1].length,O=N[2]||"";if(w&&_===Q)Y.push(O);else{if(w)y.push({type:"blockquote",content:Y.join(`
5
+ `);y.push({type:"code",content:$0,language:h||void 0}),x=!1,p=[],h=null,F=0,X=!1}else p.push(H);continue}let P=H.match(J.codeBlock);if(P){x=!0,h=P[1]||null,F=0,X=!1;continue}let u=H.match(J.table),r=H.match(J.tableSeparator);if(u&&!z){if(j+1<b.length){if(b[j+1].match(J.tableSeparator)){z=!0,G=u[1].split("|").map((O)=>O.trim()).filter((O)=>O.length>0),Z=[],X=!1;continue}}}if(z&&r)continue;if(z&&u){let _=u[1].split("|").map((O)=>O.trim()).filter((O)=>O.length>0);while(_.length<G.length)_.push("");if(_.length>G.length)_.length=G.length;Z.push(_);continue}if(z&&!u){if(G.length>0&&Z.length>0)y.push({type:"table",content:"",tableData:{headers:G,rows:Z}});z=!1,G=[],Z=[]}let N=H.match(J.blockquote);if(N){let _=N[1].length,O=N[2]||"";if(w&&_===Q)Y.push(O);else{if(w)y.push({type:"blockquote",content:Y.join(`
6
6
  `),blockquoteLevel:Q,blockquoteLines:[...Y]});w=!0,Q=_,Y=[O]}X=!1;continue}if(w)y.push({type:"blockquote",content:Y.join(`
7
7
  `),blockquoteLevel:Q,blockquoteLines:[...Y]}),w=!1,Y=[],Q=0;let R=H.match(J.heading);if(R){y.push({type:"heading",content:R[2],level:R[1].length}),X=!1;continue}let m=H.match(J.ulItem);if(m){y.push({type:"list",content:m[3],listType:"ul",marker:m[2],indentation:m[1].length}),X=!1;continue}let k=H.match(J.olItem);if(k){y.push({type:"list",content:k[3],listType:"ol",marker:k[2],indentation:k[1].length}),X=!1;continue}if(H.match(J.hr)){y.push({type:"hr",content:""}),X=!1;continue}if(H.trim().length===0){if(!X)y.push({type:"empty",content:""}),X=!0;continue}let i=H.match(J.commandMessage);if(i){y.push({type:"command-message",content:i[1]}),X=!1;continue}y.push({type:"text",content:H}),X=!1}if(x){let j=p.join(`
8
8
  `);y.push({type:"code",content:j,language:h||void 0})}if(z&&G.length>0&&Z.length>0)y.push({type:"table",content:"",tableData:{headers:G,rows:Z}});if(w&&Y.length>0)y.push({type:"blockquote",content:Y.join(`
9
- `),blockquoteLevel:Q,blockquoteLines:[...Y]});while(y.length>0&&y[y.length-1].type==="empty")y.pop();return y}var B=new Map;function W0(){return{inCodeBlock:!1,codeBlockContent:[],codeBlockLang:null,codeBlockDepth:0,inTable:!1,tableHeaders:[],tableRows:[],inDiff:!1,diffContent:[],inBlockquote:!1,blockquoteLines:[],blockquoteLevel:0,lastLineEmpty:!0,pendingTableHeader:null}}function K0(f){let y=B.get(f);if(y)return y;let b={state:W0(),blocks:[],pendingLine:"",finalized:!1};return B.set(f,b),b}function f0(f){return f.endsWith("\r")?f.slice(0,-1):f}function y0(f,y){if(f.tableHeaders.length>0&&f.tableRows.length>0)y.push({type:"table",content:"",tableData:{headers:f.tableHeaders,rows:f.tableRows}});f.inTable=!1,f.tableHeaders=[],f.tableRows=[]}function M(f,y){if(f.blockquoteLines.length>0)y.push({type:"blockquote",content:f.blockquoteLines.join(`
9
+ `),blockquoteLevel:Q,blockquoteLines:[...Y]});while(y.length>0&&y[y.length-1].type==="empty")y.pop();return y}var q=new Map;function W0(){return{inCodeBlock:!1,codeBlockContent:[],codeBlockLang:null,codeBlockDepth:0,inTable:!1,tableHeaders:[],tableRows:[],inDiff:!1,diffContent:[],inBlockquote:!1,blockquoteLines:[],blockquoteLevel:0,lastLineEmpty:!0,pendingTableHeader:null}}function K0(f){let y=q.get(f);if(y)return y;let b={state:W0(),blocks:[],pendingLine:"",finalized:!1};return q.set(f,b),b}function f0(f){return f.endsWith("\r")?f.slice(0,-1):f}function y0(f,y){if(f.tableHeaders.length>0&&f.tableRows.length>0)y.push({type:"table",content:"",tableData:{headers:f.tableHeaders,rows:f.tableRows}});f.inTable=!1,f.tableHeaders=[],f.tableRows=[]}function M(f,y){if(f.blockquoteLines.length>0)y.push({type:"blockquote",content:f.blockquoteLines.join(`
10
10
  `),blockquoteLevel:f.blockquoteLevel,blockquoteLines:[...f.blockquoteLines]});f.inBlockquote=!1,f.blockquoteLines=[],f.blockquoteLevel=0}function p0(f,y){let b=f.codeBlockContent.join(`
11
11
  `);y.push({type:"code",content:b,language:f.codeBlockLang||void 0}),f.inCodeBlock=!1,f.codeBlockContent=[],f.codeBlockLang=null,f.codeBlockDepth=0,f.lastLineEmpty=!1}function c(f,y,b=!0){let{state:x,blocks:p}=y;if(x.pendingTableHeader!==null){if(f.match(J.tableSeparator)){x.inTable=!0,x.tableHeaders=x.pendingTableHeader.slice(1,-1).split("|").map((Q)=>Q.trim()).filter((Q)=>Q.length>0),x.tableRows=[],x.pendingTableHeader=null,x.lastLineEmpty=!1;return}p.push({type:"text",content:x.pendingTableHeader}),x.pendingTableHeader=null,x.lastLineEmpty=!1}if(x.inDiff){if(f.match(J.diffEnd)){try{let Q=JSON.parse(x.diffContent.join(`
12
12
  `));p.push({type:"diff",content:"",diffData:{patch:Q.patch,startLine:Q.startLine,matchLine:Q.matchLine}})}catch(Q){p.push({type:"text",content:x.diffContent.join(`
13
13
  `)})}x.inDiff=!1,x.diffContent=[],x.lastLineEmpty=!1;return}x.diffContent.push(f);return}if(f.match(J.diffStart)){x.inDiff=!0,x.diffContent=[],x.lastLineEmpty=!1;return}if(x.inCodeBlock){let Q=f.match(J.codeBlock),X=f.trim()==="```";if(Q&&Q[1])x.codeBlockDepth++,x.codeBlockContent.push(f);else if(X)if(x.codeBlockDepth>0)x.codeBlockDepth--,x.codeBlockContent.push(f);else p0(x,p);else x.codeBlockContent.push(f);return}let h=f.match(J.codeBlock);if(h){x.inCodeBlock=!0,x.codeBlockLang=h[1]||null,x.codeBlockDepth=0,x.lastLineEmpty=!1;return}let F=f.match(J.table),z=f.match(J.tableSeparator);if(F&&!x.inTable){x.pendingTableHeader=f;return}if(x.inTable&&z)return;if(x.inTable&&F){let Q=F[1].split("|").map((X)=>X.trim()).filter((X)=>X.length>0);while(Q.length<x.tableHeaders.length)Q.push("");if(Q.length>x.tableHeaders.length)Q.length=x.tableHeaders.length;x.tableRows.push(Q);return}if(x.inTable&&!F){if(y0(x,p),b){c(f,y,!1);return}}let G=f.match(J.blockquote);if(G){let Q=G[1].length,X=G[2]||"";if(x.inBlockquote&&Q===x.blockquoteLevel)x.blockquoteLines.push(X);else{if(x.inBlockquote)M(x,p);x.inBlockquote=!0,x.blockquoteLevel=Q,x.blockquoteLines=[X]}x.lastLineEmpty=!1;return}if(x.inBlockquote)M(x,p);let Z=f.match(J.heading);if(Z){p.push({type:"heading",content:Z[2],level:Z[1].length}),x.lastLineEmpty=!1;return}let $=f.match(J.ulItem);if($){p.push({type:"list",content:$[3],listType:"ul",marker:$[2],indentation:$[1].length}),x.lastLineEmpty=!1;return}let U=f.match(J.olItem);if(U){p.push({type:"list",content:U[3],listType:"ol",marker:U[2],indentation:U[1].length}),x.lastLineEmpty=!1;return}if(f.match(J.hr)){p.push({type:"hr",content:""}),x.lastLineEmpty=!1;return}if(f.trim().length===0){if(!x.lastLineEmpty)p.push({type:"empty",content:""}),x.lastLineEmpty=!0;return}let Y=f.match(J.commandMessage);if(Y){p.push({type:"command-message",content:Y[1]}),x.lastLineEmpty=!1;return}p.push({type:"text",content:f}),x.lastLineEmpty=!1}function l0(f,y){if(!f||!y)return;let b=K0(f);if(b.finalized)return;let x=b.pendingLine+y,p=x.split(`
14
14
  `),h=x.endsWith(`
15
- `),F=h?p:p.slice(0,-1);b.pendingLine=h?"":p[p.length-1]??"";for(let z of F)c(f0(z),b)}function i0(f){let y=B.get(f);if(!y||y.finalized)return;if(y.pendingLine)c(f0(y.pendingLine),y),y.pendingLine="";if(y.state.pendingTableHeader!==null)y.blocks.push({type:"text",content:y.state.pendingTableHeader}),y.state.pendingTableHeader=null;if(y.state.inCodeBlock)p0(y.state,y.blocks);if(y.state.inTable)y0(y.state,y.blocks);if(y.state.inBlockquote)M(y.state,y.blocks);if(y.state.inDiff)y.blocks.push({type:"text",content:y.state.diffContent.join(`
16
- `)}),y.state.inDiff=!1,y.state.diffContent=[];while(y.blocks.length>0&&y.blocks[y.blocks.length-1].type==="empty")y.blocks.pop();y.finalized=!0}function o0(f){let y=B.get(f);if(!y||!y.finalized)return null;return y.blocks}function a0(f){let y=B.get(f);if(!y)return null;return y.blocks}function w0(f){let y=B.get(f);if(!y)return null;let b=[],x=y.state;if(x.inDiff)b.push("<<<DIFF>>>"),b.push(...x.diffContent);else if(x.inCodeBlock){let p=x.codeBlockLang?`\`\`\`${x.codeBlockLang}`:"```";b.push(p),b.push(...x.codeBlockContent)}else if(x.inTable){if(x.tableHeaders.length>0){b.push(`| ${x.tableHeaders.join(" | ")} |`),b.push(`| ${x.tableHeaders.map(()=>"---").join(" | ")} |`);for(let p of x.tableRows)b.push(`| ${p.join(" | ")} |`)}}else if(x.inBlockquote){let p=">".repeat(x.blockquoteLevel)+" ";for(let h of x.blockquoteLines)b.push(p+h)}else if(x.pendingTableHeader)b.push(x.pendingTableHeader);if(y.pendingLine)b.push(y.pendingLine);return b.length>0?b:null}function n0(f){let y=B.get(f);if(!y)return null;let b="text";if(y.state.inDiff)b="diff";else if(y.state.inCodeBlock)b="code";else if(y.state.inTable||y.state.pendingTableHeader)b="table";let x=w0(f);if(!x||x.length===0)return null;return{lines:x,mode:b}}function s0(f){B.delete(f)}function A(){B.clear()}var h0=2000,L=[];function O0(){let f=L;return L=[],f}var E={messages:[],streamingText:new Map};function u0(){E={messages:[],streamingText:new Map}}var Q0={inputTokens:0,outputTokens:0,totalTokens:0,maxContextTokens:0,totalInputTokens:0,totalOutputTokens:0,cacheReadTokens:0,cacheWriteTokens:0,turnCount:0,estimatedCostUsd:0},F0={sessionId:G0("tui"),workspaceRoot:z0(),messages:[],restoredContextMessages:null,restoredVisibleMessageCount:0,isCompacting:!1,currentCommand:null,error:null,isActive:!0,tokenUsage:{...Q0},currentThinkingContent:null,thinkingExpanded:!1,clearCount:0,historyExpanded:!1,expandedMessageCount:100,currentStreamingMessageId:null,currentStreamingChunks:[],currentStreamingLines:[],currentStreamingTail:"",currentStreamingLineCount:0,currentStreamingVersion:0,finalizingStreamingMessageId:null,providerAdmission:null,providerCircuit:null,providerRetry:null,providerStall:null,providerRecovery:null,turnActivity:null,actionStationarity:null},d=(f,y)=>({...F0,actions:{addMessage:(b)=>{f((x)=>({session:{...x.session,messages:[...x.session.messages,b],error:null}}))},addUserMessage:(b)=>{let x={id:`user-${Date.now()}-${Math.random()}`,role:"user",content:b,timestamp:Date.now()};y().session.actions.addMessage(x)},addAssistantMessage:(b,x)=>{let p={id:`assistant-${Date.now()}-${Math.random()}`,role:"assistant",content:b,timestamp:Date.now(),thinkingContent:x};y().session.actions.addMessage(p)},replaceLastAssistantMessage:(b)=>{f((x)=>{let p=x.session.messages.findLastIndex((h)=>h.role==="assistant");if(p<0)return{session:{...x.session,messages:[...x.session.messages,{id:`assistant-${Date.now()}-${Math.random()}`,role:"assistant",content:b,timestamp:Date.now()}]}};return{session:{...x.session,messages:x.session.messages.map((h,F)=>F===p?{...h,content:b}:h)}}})},addAssistantMessageAndClearThinking:(b)=>{let x=y().session.currentThinkingContent,p={id:`assistant-${Date.now()}-${Math.random()}`,role:"assistant",content:b,timestamp:Date.now(),thinkingContent:x||void 0};f((h)=>({session:{...h.session,messages:[...h.session.messages,p],currentThinkingContent:null,error:null}}))},addToolMessage:(b,x)=>{let p={id:`tool-${Date.now()}-${Math.random()}`,role:"tool",content:b,timestamp:Date.now(),metadata:x};y().session.actions.addMessage(p)},setCompacting:(b)=>{f((x)=>({session:{...x.session,isCompacting:b}}))},setCommand:(b)=>{f((x)=>({session:{...x.session,currentCommand:b}}))},setError:(b)=>{f((x)=>({session:{...x.session,error:b}}))},clearMessages:()=>{A(),f((b)=>({session:{...b.session,messages:[],restoredContextMessages:null,restoredVisibleMessageCount:0,error:null,clearCount:b.session.clearCount+1}}))},setCompactedContext:(b)=>{f((x)=>({session:{...x.session,restoredContextMessages:[...b],restoredVisibleMessageCount:x.session.messages.length}}))},resetSession:()=>{A(),f((b)=>({session:{...b.session,...F0,sessionId:b.session.sessionId,isActive:!0},app:{...b.app,followUpQueue:null,followUpQueueOwner:null,followUpQueueMutation:{pending:!1,supersededVersions:[]}},command:{...b.command,followUpPresentations:{}}}))},restoreSession:(b,x,p,h)=>{A(),f((F)=>({session:{...F.session,sessionId:b,workspaceRoot:h??F.session.workspaceRoot,messages:x,restoredContextMessages:p??null,restoredVisibleMessageCount:p?x.length:0,error:null,isActive:!0},app:{...F.app,followUpQueue:null,followUpQueueOwner:null,followUpQueueMutation:{pending:!1,supersededVersions:[]}},command:{...F.command,followUpPresentations:{}}}))},updateTokenUsage:(b)=>{f((x)=>{let p=x.session.tokenUsage,{costUsd:h,scope:F,...z}=b,G=Math.max(0,b.inputTokens??0),Z=Math.max(0,b.outputTokens??0),$=Math.max(0,b.cacheReadTokens??0),U=Math.max(0,b.cacheWriteTokens??0),w=p.totalInputTokens+G,Y=p.totalOutputTokens+Z,Q=p.cacheReadTokens+$,X=p.cacheWriteTokens+U,j=x.config?.config,H=j?.models?.find((r)=>r.id===j.currentModelId),P=H?.model??"",q=h??b0(P,Math.max(0,G-$-U),Z,$,U,H?.provider);return{session:{...x.session,tokenUsage:{...p,...F==="auxiliary"?{}:z,totalInputTokens:w,totalOutputTokens:Y,cacheReadTokens:Q,cacheWriteTokens:X,estimatedCostUsd:p.estimatedCostUsd+Math.max(0,q)}}}})},resetContextUsage:()=>{f((b)=>({session:{...b.session,tokenUsage:{...b.session.tokenUsage,inputTokens:0,outputTokens:0,totalTokens:0}}}))},resetTokenUsage:()=>{f((b)=>({session:{...b.session,tokenUsage:{...Q0}}}))},setCurrentThinkingContent:(b)=>{if(y().session.currentThinkingContent===b)return;f((x)=>({session:{...x.session,currentThinkingContent:b}}))},appendThinkingContent:(b)=>{f((x)=>({session:{...x.session,currentThinkingContent:(x.session.currentThinkingContent||"")+b}}))},setThinkingExpanded:(b)=>{f((x)=>({session:{...x.session,thinkingExpanded:b}}))},toggleThinkingExpanded:()=>{f((b)=>({session:{...b.session,thinkingExpanded:!b.session.thinkingExpanded}}))},setHistoryExpanded:(b)=>{f((x)=>({session:{...x.session,historyExpanded:b}}))},toggleHistoryExpanded:()=>{f((b)=>({session:{...b.session,historyExpanded:!b.session.historyExpanded}}))},setExpandedMessageCount:(b)=>{f((x)=>({session:{...x.session,expandedMessageCount:b}}))},incrementClearCount:()=>{f((b)=>({session:{...b.session,clearCount:b.session.clearCount+1}}))},startStreamingAssistantMessage:()=>{let b=`assistant-${Date.now()}-${Math.random()}`,x={id:b,role:"assistant",content:"",timestamp:Date.now()};return L=[],f((p)=>({session:{...p.session,messages:[...p.session.messages,x],currentStreamingMessageId:b,currentStreamingChunks:[],currentStreamingLines:[],currentStreamingTail:"",currentStreamingLineCount:0,currentStreamingVersion:0,error:null}})),b},appendAssistantContent:(b)=>{let x=y().session.currentStreamingMessageId,p=x??`assistant-${Date.now()}-${Math.random()}`;return L.push(b),f((h)=>{let F=(j)=>j.endsWith("\r")?j.slice(0,-1):j,z=x?h.session.currentStreamingLines:[],G=x?h.session.currentStreamingTail:"",Z=x?h.session.currentStreamingLineCount:0,$=x?h.session.currentStreamingVersion:0,w=(G+b).split(`
17
- `),Y=w.slice(0,-1).map(F),Q=F(w[w.length-1]??""),X=z;if(Y.length>0){if(X=[...z,...Y],X.length>h0){let j=X.length-h0;X=X.slice(j)}}return{session:{...h.session,currentStreamingMessageId:p,currentStreamingLines:X,currentStreamingTail:Q,currentStreamingLineCount:Z+Y.length,currentStreamingVersion:$+1,error:null}}}),p},finalizeStreamingMessage:(b,x)=>{let p=O0();f((h)=>{let F=h.session.currentStreamingMessageId,G=p.join("")+(b||""),Z=(h.session.currentThinkingContent||"")+(x||"");if(G.length>0){let $={id:F||`assistant-${Date.now()}-${Math.random()}`,role:"assistant",content:G,timestamp:Date.now(),thinkingContent:Z||void 0};return{session:{...h.session,messages:[...h.session.messages,$],currentStreamingMessageId:null,currentStreamingChunks:[],currentStreamingLines:[],currentStreamingTail:"",currentStreamingLineCount:0,currentStreamingVersion:0,currentThinkingContent:null,finalizingStreamingMessageId:$.id}}}return{session:{...h.session,currentStreamingMessageId:null,currentStreamingChunks:[],currentStreamingLines:[],currentStreamingTail:"",currentStreamingLineCount:0,currentStreamingVersion:0,currentThinkingContent:null,finalizingStreamingMessageId:h.session.finalizingStreamingMessageId}}})},clearFinalizingStreamingMessageId:()=>{f((b)=>({session:{...b.session,finalizingStreamingMessageId:null}}))},discardStreamingMessage:()=>{L=[],f((b)=>({session:{...b.session,currentStreamingMessageId:null,currentStreamingChunks:[],currentStreamingLines:[],currentStreamingTail:"",currentStreamingLineCount:0,currentStreamingVersion:0,finalizingStreamingMessageId:null}}))},setProviderAdmission:(b)=>{f((x)=>({session:{...x.session,providerAdmission:b}}))},setProviderCircuit:(b)=>{f((x)=>({session:{...x.session,providerCircuit:b}}))},setProviderRetry:(b)=>{f((x)=>({session:{...x.session,providerRetry:b}}))},setProviderStall:(b)=>{f((x)=>({session:{...x.session,providerStall:b}}))},setProviderRecovery:(b)=>{f((x)=>({session:{...x.session,providerRecovery:b}}))},setTurnActivity:(b)=>{f((x)=>({session:{...x.session,turnActivity:b}}))},setActionStationarity:(b)=>{f((x)=>({session:{...x.session,actionStationarity:b}}))},applyCommittedEvent:(b)=>{t(E,b),f((x)=>({session:{...x.session,messages:[...E.messages],error:null}}))},applyStreamingDelta:(b)=>{x0(E,b),f((x)=>({session:{...x.session,messages:[...E.messages]}}))},resetConversationProjection:()=>{u0()}}});var E0=D0()(B0(q0((...f)=>({session:d(...f),app:g(...f),config:C(...f),focus:v(...f),command:T(...f)})),{name:"BladeStore",enabled:!0})),V=()=>E0.getState(),_2=()=>V().session.actions,W2=()=>V().app.actions,K2=()=>V().session.messages,K=()=>V().config.config,D=null;async function w2(){if(K()!==null)return;if(D)return D;return D=(async()=>{try{let b=await Z0.getInstance().initialize();V().config.actions.setConfig(b)}catch(y){throw D=null,Error(`[FAIL] Store 未初始化且无法自动初始化
15
+ `),F=h?p:p.slice(0,-1);b.pendingLine=h?"":p[p.length-1]??"";for(let z of F)c(f0(z),b)}function i0(f){let y=q.get(f);if(!y||y.finalized)return;if(y.pendingLine)c(f0(y.pendingLine),y),y.pendingLine="";if(y.state.pendingTableHeader!==null)y.blocks.push({type:"text",content:y.state.pendingTableHeader}),y.state.pendingTableHeader=null;if(y.state.inCodeBlock)p0(y.state,y.blocks);if(y.state.inTable)y0(y.state,y.blocks);if(y.state.inBlockquote)M(y.state,y.blocks);if(y.state.inDiff)y.blocks.push({type:"text",content:y.state.diffContent.join(`
16
+ `)}),y.state.inDiff=!1,y.state.diffContent=[];while(y.blocks.length>0&&y.blocks[y.blocks.length-1].type==="empty")y.blocks.pop();y.finalized=!0}function o0(f){let y=q.get(f);if(!y||!y.finalized)return null;return y.blocks}function a0(f){let y=q.get(f);if(!y)return null;return y.blocks}function w0(f){let y=q.get(f);if(!y)return null;let b=[],x=y.state;if(x.inDiff)b.push("<<<DIFF>>>"),b.push(...x.diffContent);else if(x.inCodeBlock){let p=x.codeBlockLang?`\`\`\`${x.codeBlockLang}`:"```";b.push(p),b.push(...x.codeBlockContent)}else if(x.inTable){if(x.tableHeaders.length>0){b.push(`| ${x.tableHeaders.join(" | ")} |`),b.push(`| ${x.tableHeaders.map(()=>"---").join(" | ")} |`);for(let p of x.tableRows)b.push(`| ${p.join(" | ")} |`)}}else if(x.inBlockquote){let p=">".repeat(x.blockquoteLevel)+" ";for(let h of x.blockquoteLines)b.push(p+h)}else if(x.pendingTableHeader)b.push(x.pendingTableHeader);if(y.pendingLine)b.push(y.pendingLine);return b.length>0?b:null}function n0(f){let y=q.get(f);if(!y)return null;let b="text";if(y.state.inDiff)b="diff";else if(y.state.inCodeBlock)b="code";else if(y.state.inTable||y.state.pendingTableHeader)b="table";let x=w0(f);if(!x||x.length===0)return null;return{lines:x,mode:b}}function s0(f){q.delete(f)}function A(){q.clear()}var h0=2000,L=[];function O0(){let f=L;return L=[],f}var E={messages:[],streamingText:new Map};function B0(){E={messages:[],streamingText:new Map}}var Q0={inputTokens:0,outputTokens:0,totalTokens:0,maxContextTokens:0,totalInputTokens:0,totalOutputTokens:0,cacheReadTokens:0,cacheWriteTokens:0,turnCount:0,estimatedCostUsd:0},F0={sessionId:G0("tui"),workspaceRoot:z0(),messages:[],restoredContextMessages:null,restoredVisibleMessageCount:0,isCompacting:!1,currentCommand:null,error:null,isActive:!0,tokenUsage:{...Q0},currentThinkingContent:null,thinkingExpanded:!1,clearCount:0,historyExpanded:!1,expandedMessageCount:100,currentStreamingMessageId:null,currentStreamingChunks:[],currentStreamingLines:[],currentStreamingTail:"",currentStreamingLineCount:0,currentStreamingVersion:0,finalizingStreamingMessageId:null,providerAdmission:null,providerCircuit:null,providerRetry:null,providerStall:null,providerRecovery:null,turnActivity:null,actionStationarity:null,toolStatus:null},d=(f,y)=>({...F0,actions:{addMessage:(b)=>{f((x)=>({session:{...x.session,messages:[...x.session.messages,b],error:null}}))},addUserMessage:(b)=>{let x={id:`user-${Date.now()}-${Math.random()}`,role:"user",content:b,timestamp:Date.now()};y().session.actions.addMessage(x)},addAssistantMessage:(b,x)=>{let p={id:`assistant-${Date.now()}-${Math.random()}`,role:"assistant",content:b,timestamp:Date.now(),thinkingContent:x};y().session.actions.addMessage(p)},replaceLastAssistantMessage:(b)=>{f((x)=>{let p=x.session.messages.findLastIndex((h)=>h.role==="assistant");if(p<0)return{session:{...x.session,messages:[...x.session.messages,{id:`assistant-${Date.now()}-${Math.random()}`,role:"assistant",content:b,timestamp:Date.now()}]}};return{session:{...x.session,messages:x.session.messages.map((h,F)=>F===p?{...h,content:b}:h)}}})},addAssistantMessageAndClearThinking:(b)=>{let x=y().session.currentThinkingContent,p={id:`assistant-${Date.now()}-${Math.random()}`,role:"assistant",content:b,timestamp:Date.now(),thinkingContent:x||void 0};f((h)=>({session:{...h.session,messages:[...h.session.messages,p],currentThinkingContent:null,error:null}}))},addToolMessage:(b,x)=>{let p={id:`tool-${Date.now()}-${Math.random()}`,role:"tool",content:b,timestamp:Date.now(),metadata:x};y().session.actions.addMessage(p)},setCompacting:(b)=>{f((x)=>({session:{...x.session,isCompacting:b}}))},setCommand:(b)=>{f((x)=>({session:{...x.session,currentCommand:b}}))},setError:(b)=>{f((x)=>({session:{...x.session,error:b}}))},clearMessages:()=>{A(),f((b)=>({session:{...b.session,messages:[],restoredContextMessages:null,restoredVisibleMessageCount:0,error:null,clearCount:b.session.clearCount+1}}))},setCompactedContext:(b)=>{f((x)=>({session:{...x.session,restoredContextMessages:[...b],restoredVisibleMessageCount:x.session.messages.length}}))},resetSession:()=>{A(),f((b)=>({session:{...b.session,...F0,sessionId:b.session.sessionId,isActive:!0},app:{...b.app,followUpQueue:null,followUpQueueOwner:null,followUpQueueMutation:{pending:!1,supersededVersions:[]}},command:{...b.command,followUpPresentations:{}}}))},restoreSession:(b,x,p,h)=>{A(),f((F)=>({session:{...F.session,sessionId:b,workspaceRoot:h??F.session.workspaceRoot,messages:x,restoredContextMessages:p??null,restoredVisibleMessageCount:p?x.length:0,error:null,isActive:!0},app:{...F.app,followUpQueue:null,followUpQueueOwner:null,followUpQueueMutation:{pending:!1,supersededVersions:[]}},command:{...F.command,followUpPresentations:{}}}))},updateTokenUsage:(b)=>{f((x)=>{let p=x.session.tokenUsage,{costUsd:h,scope:F,...z}=b,G=Math.max(0,b.inputTokens??0),Z=Math.max(0,b.outputTokens??0),$=Math.max(0,b.cacheReadTokens??0),U=Math.max(0,b.cacheWriteTokens??0),w=p.totalInputTokens+G,Y=p.totalOutputTokens+Z,Q=p.cacheReadTokens+$,X=p.cacheWriteTokens+U,j=x.config?.config,H=j?.models?.find((r)=>r.id===j.currentModelId),P=H?.model??"",u=h??b0(P,Math.max(0,G-$-U),Z,$,U,H?.provider);return{session:{...x.session,tokenUsage:{...p,...F==="auxiliary"?{}:z,totalInputTokens:w,totalOutputTokens:Y,cacheReadTokens:Q,cacheWriteTokens:X,estimatedCostUsd:p.estimatedCostUsd+Math.max(0,u)}}}})},resetContextUsage:()=>{f((b)=>({session:{...b.session,tokenUsage:{...b.session.tokenUsage,inputTokens:0,outputTokens:0,totalTokens:0}}}))},resetTokenUsage:()=>{f((b)=>({session:{...b.session,tokenUsage:{...Q0}}}))},setCurrentThinkingContent:(b)=>{if(y().session.currentThinkingContent===b)return;f((x)=>({session:{...x.session,currentThinkingContent:b}}))},appendThinkingContent:(b)=>{f((x)=>({session:{...x.session,currentThinkingContent:(x.session.currentThinkingContent||"")+b}}))},setThinkingExpanded:(b)=>{f((x)=>({session:{...x.session,thinkingExpanded:b}}))},toggleThinkingExpanded:()=>{f((b)=>({session:{...b.session,thinkingExpanded:!b.session.thinkingExpanded}}))},setHistoryExpanded:(b)=>{f((x)=>({session:{...x.session,historyExpanded:b}}))},toggleHistoryExpanded:()=>{f((b)=>({session:{...b.session,historyExpanded:!b.session.historyExpanded}}))},setExpandedMessageCount:(b)=>{f((x)=>({session:{...x.session,expandedMessageCount:b}}))},incrementClearCount:()=>{f((b)=>({session:{...b.session,clearCount:b.session.clearCount+1}}))},startStreamingAssistantMessage:()=>{let b=`assistant-${Date.now()}-${Math.random()}`,x={id:b,role:"assistant",content:"",timestamp:Date.now()};return L=[],f((p)=>({session:{...p.session,messages:[...p.session.messages,x],currentStreamingMessageId:b,currentStreamingChunks:[],currentStreamingLines:[],currentStreamingTail:"",currentStreamingLineCount:0,currentStreamingVersion:0,error:null}})),b},appendAssistantContent:(b)=>{let x=y().session.currentStreamingMessageId,p=x??`assistant-${Date.now()}-${Math.random()}`;return L.push(b),f((h)=>{let F=(j)=>j.endsWith("\r")?j.slice(0,-1):j,z=x?h.session.currentStreamingLines:[],G=x?h.session.currentStreamingTail:"",Z=x?h.session.currentStreamingLineCount:0,$=x?h.session.currentStreamingVersion:0,w=(G+b).split(`
17
+ `),Y=w.slice(0,-1).map(F),Q=F(w[w.length-1]??""),X=z;if(Y.length>0){if(X=[...z,...Y],X.length>h0){let j=X.length-h0;X=X.slice(j)}}return{session:{...h.session,currentStreamingMessageId:p,currentStreamingLines:X,currentStreamingTail:Q,currentStreamingLineCount:Z+Y.length,currentStreamingVersion:$+1,error:null}}}),p},finalizeStreamingMessage:(b,x)=>{let p=O0();f((h)=>{let F=h.session.currentStreamingMessageId,G=p.join("")+(b||""),Z=(h.session.currentThinkingContent||"")+(x||"");if(G.length>0){let $={id:F||`assistant-${Date.now()}-${Math.random()}`,role:"assistant",content:G,timestamp:Date.now(),thinkingContent:Z||void 0};return{session:{...h.session,messages:[...h.session.messages,$],currentStreamingMessageId:null,currentStreamingChunks:[],currentStreamingLines:[],currentStreamingTail:"",currentStreamingLineCount:0,currentStreamingVersion:0,currentThinkingContent:null,finalizingStreamingMessageId:$.id}}}return{session:{...h.session,currentStreamingMessageId:null,currentStreamingChunks:[],currentStreamingLines:[],currentStreamingTail:"",currentStreamingLineCount:0,currentStreamingVersion:0,currentThinkingContent:null,finalizingStreamingMessageId:h.session.finalizingStreamingMessageId}}})},clearFinalizingStreamingMessageId:()=>{f((b)=>({session:{...b.session,finalizingStreamingMessageId:null}}))},discardStreamingMessage:()=>{L=[],f((b)=>({session:{...b.session,currentStreamingMessageId:null,currentStreamingChunks:[],currentStreamingLines:[],currentStreamingTail:"",currentStreamingLineCount:0,currentStreamingVersion:0,finalizingStreamingMessageId:null}}))},setProviderAdmission:(b)=>{f((x)=>({session:{...x.session,providerAdmission:b}}))},setProviderCircuit:(b)=>{f((x)=>({session:{...x.session,providerCircuit:b}}))},setProviderRetry:(b)=>{f((x)=>({session:{...x.session,providerRetry:b}}))},setProviderStall:(b)=>{f((x)=>({session:{...x.session,providerStall:b}}))},setProviderRecovery:(b)=>{f((x)=>({session:{...x.session,providerRecovery:b}}))},setTurnActivity:(b)=>{f((x)=>({session:{...x.session,turnActivity:b}}))},setActionStationarity:(b)=>{f((x)=>({session:{...x.session,actionStationarity:b}}))},setToolStatus:(b)=>{f((x)=>({session:{...x.session,toolStatus:b}}))},applyCommittedEvent:(b)=>{t(E,b),f((x)=>({session:{...x.session,messages:[...E.messages],error:null}}))},applyStreamingDelta:(b)=>{x0(E,b),f((x)=>({session:{...x.session,messages:[...E.messages]}}))},resetConversationProjection:()=>{B0()}}});var E0=D0()(q0(u0((...f)=>({session:d(...f),app:g(...f),config:C(...f),focus:v(...f),command:T(...f)})),{name:"BladeStore",enabled:!0})),V=()=>E0.getState(),_2=()=>V().session.actions,W2=()=>V().app.actions,K2=()=>V().session.messages,K=()=>V().config.config,D=null;async function w2(){if(K()!==null)return;if(D)return D;return D=(async()=>{try{let b=await Z0.getInstance().initialize();V().config.actions.setConfig(b)}catch(y){throw D=null,Error(`[FAIL] Store 未初始化且无法自动初始化
18
18
 
19
19
  `+`原因: ${y instanceof Error?y.message:"未知错误"}
20
20
 
21
21
  `+`请确保:
22
22
  `+`1. 配置文件格式正确 (~/.blade/config.json)
23
23
  `+`2. 运行 blade 进行首次配置
24
- `+"3. 配置文件权限正确")}finally{D=null}})(),D}var O2=()=>V().config.config?.models??[],u2=()=>{let f=K();if(!f)return;let y=f.currentModelId;return f.models.find((x)=>x.id===y)??f.models[0]},B2=(f)=>{let y=K();if(!y)return;return y.models.find((b)=>b.id===f)},q2=()=>V().config.config?.mcpServers??{},D2=()=>V().app.reasoningEffort!=="off",X0=()=>({setPermissionMode:async(f)=>{V().config.actions.updateConfig({permissionMode:f})},setTheme:async(f,y={})=>{try{e.setTheme(f)}catch{return}V().config.actions.updateConfig({codeTheme:f}),await W().save({codeTheme:f},{scope:"global",...y})},setLanguage:async(f,y={})=>{V().config.actions.updateConfig({language:f}),await W().save({language:f},{scope:"global",...y})},setDebug:async(f,y={})=>{V().config.actions.updateConfig({debug:f}),await W().save({debug:f},{scope:"global",...y})},setTemperature:async(f,y={})=>{V().config.actions.updateConfig({temperature:f}),await W().save({temperature:f},{scope:"global",...y})},updateConfig:async(f,y={})=>{let b=K();if(!b)throw Error("Config not initialized");let x={...b};V().config.actions.updateConfig(f);try{await W().save(f,y)}catch(p){throw V().config.actions.setConfig(x),p}},flush:async()=>{await W().flush()},appendPermissionAllowRule:async(f,y={})=>{let b=K();if(!b)throw Error("Config not initialized");let x=b.permissions?.allow||[];if(!x.includes(f)){let p=[...x,f];V().config.actions.updateConfig({permissions:{...b.permissions,allow:p}})}await W().appendPermissionRule(f,y)},appendLocalPermissionAllowRule:async(f,y={})=>{let b=K();if(!b)throw Error("Config not initialized");let x=b.permissions?.allow||[];if(!x.includes(f)){let p=[...x,f];V().config.actions.updateConfig({permissions:{...b.permissions,allow:p}})}await W().appendLocalPermissionRule(f,y)},setCurrentModel:async(f,y={})=>{let b=K();if(!b)throw Error("Config not initialized");if(!b.models.find((p)=>p.id===f))throw Error(`Model not found: ${f}`);V().config.actions.updateConfig({currentModelId:f}),await W().save({currentModelId:f},{scope:"global",...y})},addModel:async(f,y={})=>{let b=K();if(!b)throw Error("Config not initialized");let x="id"in f?f:{id:l(f,b.models),...f};if(b.models.find((z)=>z.provider===x.provider&&z.model===x.model))throw Error(`Model already configured: ${x.provider}/${x.model}`);let F={models:[...b.models,x]};if(b.models.length===0)F.currentModelId=x.id;return V().config.actions.updateConfig(F),await W().save(F,{scope:"global",...y}),x},addModelWithProvider:async(f,y,b={})=>{let x=K();if(!x)throw Error("Config not initialized");let p=f.provider;if(x.modelProviders[p])throw Error(`Model provider already configured: ${p}`);let h="id"in f?f:{id:l(f,x.models),...f};if(x.models.find(($)=>$.provider===p&&$.model===h.model))throw Error(`Model already configured: ${p}/${h.model}`);let z=x,G=[...x.models,h],Z={modelProviders:{...x.modelProviders,[p]:y},models:G};if(x.models.length===0)Z.currentModelId=h.id;u().registerModelProvider(p,y,[h.model]),V().config.actions.updateConfig(Z);try{return await W().save(Z,{scope:"global",...b}),h}catch($){throw V().config.actions.setConfig(z),u().configureModelProviders(z.modelProviders,z.models),$}},updateModelWithProvider:async(f,y,b,x={})=>{let p=K();if(!p)throw Error("Config not initialized");let h=y.provider;if(!h)throw Error("Model provider is required");if(p.modelProviders[h])throw Error(`Model provider already configured: ${h}`);let F=p.models.findIndex((U)=>U.id===f);if(F===-1)throw Error(`Model not found: ${f}`);let z={...p.models[F],...y};if(!z.model)throw Error("Model ID is required");let G=p,Z=[...p.models];Z[F]=z;let $={modelProviders:{...p.modelProviders,[h]:b},models:Z};u().registerModelProvider(h,b,[z.model]),V().config.actions.updateConfig($);try{await W().save($,{scope:"global",...x})}catch(U){throw V().config.actions.setConfig(G),u().configureModelProviders(G.modelProviders,G.models),U}},updateModelProvider:async(f,y,b={})=>{let x=K();if(!x)throw Error("Config not initialized");if(!x.modelProviders[f])throw Error(`Model provider not found: ${f}`);let p=x.models.filter((h)=>h.provider===f).map((h)=>h.model);u().registerModelProvider(f,y,p),await X0().updateConfig({modelProviders:{...x.modelProviders,[f]:y}},{scope:"global",immediate:!0,...b})},removeModelProvider:async(f,y={})=>{let b=K();if(!b)throw Error("Config not initialized");if(!b.modelProviders[f])throw Error(`Model provider not found: ${f}`);let x=b.models.filter((Y)=>Y.provider===f),p=b.models.filter((Y)=>Y.fallbackModels?.some((Q)=>Q.provider===f));if(!y.removeModels&&(x.length>0||p.length>0))throw Error(`Model provider is still referenced by ${x.length} model(s) and ${p.length} fallback configuration(s)`);let h=x.map((Y)=>Y.id),F=b.models.filter((Y)=>Y.provider!==f).map((Y)=>{let Q=Y.fallbackModels?.filter((H)=>H.provider!==f),{fallbackModels:X,...j}=Y;return Q?.length?{...j,fallbackModels:Q}:j});if(F.length===0)throw Error("Cannot remove the provider that owns the only model");let z={...b.modelProviders};delete z[f];let G={modelProviders:z,models:F};if(h.includes(b.currentModelId))G.currentModelId=F[0].id;let Z=u(),$=await Z.credentials.read(f);await Z.credentials.delete(f);let{removeModels:U,...w}=y;try{return await X0().updateConfig(G,{scope:"global",immediate:!0,...w}),{removedModelIds:h}}catch(Y){if($)await Z.credentials.modify(f,async()=>$);throw Y}},updateModel:async(f,y,b={})=>{let x=K();if(!x)throw Error("Config not initialized");let p=x.models.findIndex((F)=>F.id===f);if(p===-1)throw Error(`Model not found: ${f}`);let h=[...x.models];h[p]={...h[p],...y},V().config.actions.updateConfig({models:h}),await W().save({models:h},{scope:"global",...b})},removeModel:async(f,y={})=>{let b=K();if(!b)throw Error("Config not initialized");if(b.models.length===1)throw Error("Cannot remove the only model");let x=b.models.filter((h)=>h.id!==f),p={models:x};if(b.currentModelId===f)p.currentModelId=x[0].id;V().config.actions.updateConfig(p),await W().save(p,{scope:"global",...y})},addMcpServer:async(f,y,b={})=>{let x=K();if(!x)throw Error("Config not initialized");let p=x.mcpServers??{},h=Y0(y),F={...y,...h?{oauth:h}:{}},z={...p,[f]:F};V().config.actions.updateConfig({mcpServers:z}),await W().save({mcpServers:z},{scope:"project",...b})},removeMcpServer:async(f,y={})=>{let b=K();if(!b)throw Error("Config not initialized");let p={...b.mcpServers??{}};delete p[f],V().config.actions.updateConfig({mcpServers:p}),await W().save({mcpServers:p},{scope:"project",...y})}});
25
- export{a as Kf,e as Lf,J as Mf,M0 as Nf,l0 as Of,i0 as Pf,o0 as Qf,a0 as Rf,n0 as Sf,s0 as Tf,E0 as Uf,V as Vf,_2 as Wf,W2 as Xf,K2 as Yf,K as Zf,w2 as _f,O2 as $f,u2 as ag,B2 as bg,q2 as cg,D2 as dg,X0 as eg};
24
+ `+"3. 配置文件权限正确")}finally{D=null}})(),D}var O2=()=>V().config.config?.models??[],B2=()=>{let f=K();if(!f)return;let y=f.currentModelId;return f.models.find((x)=>x.id===y)??f.models[0]},q2=(f)=>{let y=K();if(!y)return;return y.models.find((b)=>b.id===f)},u2=()=>V().config.config?.mcpServers??{},D2=()=>V().app.reasoningEffort!=="off",X0=()=>({setPermissionMode:async(f)=>{V().config.actions.updateConfig({permissionMode:f})},setTheme:async(f,y={})=>{try{e.setTheme(f)}catch{return}V().config.actions.updateConfig({codeTheme:f}),await W().save({codeTheme:f},{scope:"global",...y})},setLanguage:async(f,y={})=>{V().config.actions.updateConfig({language:f}),await W().save({language:f},{scope:"global",...y})},setDebug:async(f,y={})=>{V().config.actions.updateConfig({debug:f}),await W().save({debug:f},{scope:"global",...y})},setTemperature:async(f,y={})=>{V().config.actions.updateConfig({temperature:f}),await W().save({temperature:f},{scope:"global",...y})},updateConfig:async(f,y={})=>{let b=K();if(!b)throw Error("Config not initialized");let x={...b};V().config.actions.updateConfig(f);try{await W().save(f,y)}catch(p){throw V().config.actions.setConfig(x),p}},flush:async()=>{await W().flush()},appendPermissionAllowRule:async(f,y={})=>{let b=K();if(!b)throw Error("Config not initialized");let x=b.permissions?.allow||[];if(!x.includes(f)){let p=[...x,f];V().config.actions.updateConfig({permissions:{...b.permissions,allow:p}})}await W().appendPermissionRule(f,y)},appendLocalPermissionAllowRule:async(f,y={})=>{let b=K();if(!b)throw Error("Config not initialized");let x=b.permissions?.allow||[];if(!x.includes(f)){let p=[...x,f];V().config.actions.updateConfig({permissions:{...b.permissions,allow:p}})}await W().appendLocalPermissionRule(f,y)},setCurrentModel:async(f,y={})=>{let b=K();if(!b)throw Error("Config not initialized");if(!b.models.find((p)=>p.id===f))throw Error(`Model not found: ${f}`);V().config.actions.updateConfig({currentModelId:f}),await W().save({currentModelId:f},{scope:"global",...y})},addModel:async(f,y={})=>{let b=K();if(!b)throw Error("Config not initialized");let x="id"in f?f:{id:l(f,b.models),...f};if(b.models.find((z)=>z.provider===x.provider&&z.model===x.model))throw Error(`Model already configured: ${x.provider}/${x.model}`);let F={models:[...b.models,x]};if(b.models.length===0)F.currentModelId=x.id;return V().config.actions.updateConfig(F),await W().save(F,{scope:"global",...y}),x},addModelWithProvider:async(f,y,b={})=>{let x=K();if(!x)throw Error("Config not initialized");let p=f.provider;if(x.modelProviders[p])throw Error(`Model provider already configured: ${p}`);let h="id"in f?f:{id:l(f,x.models),...f};if(x.models.find(($)=>$.provider===p&&$.model===h.model))throw Error(`Model already configured: ${p}/${h.model}`);let z=x,G=[...x.models,h],Z={modelProviders:{...x.modelProviders,[p]:y},models:G};if(x.models.length===0)Z.currentModelId=h.id;B().registerModelProvider(p,y,[h.model]),V().config.actions.updateConfig(Z);try{return await W().save(Z,{scope:"global",...b}),h}catch($){throw V().config.actions.setConfig(z),B().configureModelProviders(z.modelProviders,z.models),$}},updateModelWithProvider:async(f,y,b,x={})=>{let p=K();if(!p)throw Error("Config not initialized");let h=y.provider;if(!h)throw Error("Model provider is required");if(p.modelProviders[h])throw Error(`Model provider already configured: ${h}`);let F=p.models.findIndex((U)=>U.id===f);if(F===-1)throw Error(`Model not found: ${f}`);let z={...p.models[F],...y};if(!z.model)throw Error("Model ID is required");let G=p,Z=[...p.models];Z[F]=z;let $={modelProviders:{...p.modelProviders,[h]:b},models:Z};B().registerModelProvider(h,b,[z.model]),V().config.actions.updateConfig($);try{await W().save($,{scope:"global",...x})}catch(U){throw V().config.actions.setConfig(G),B().configureModelProviders(G.modelProviders,G.models),U}},updateModelProvider:async(f,y,b={})=>{let x=K();if(!x)throw Error("Config not initialized");if(!x.modelProviders[f])throw Error(`Model provider not found: ${f}`);let p=x.models.filter((h)=>h.provider===f).map((h)=>h.model);B().registerModelProvider(f,y,p),await X0().updateConfig({modelProviders:{...x.modelProviders,[f]:y}},{scope:"global",immediate:!0,...b})},removeModelProvider:async(f,y={})=>{let b=K();if(!b)throw Error("Config not initialized");if(!b.modelProviders[f])throw Error(`Model provider not found: ${f}`);let x=b.models.filter((Y)=>Y.provider===f),p=b.models.filter((Y)=>Y.fallbackModels?.some((Q)=>Q.provider===f));if(!y.removeModels&&(x.length>0||p.length>0))throw Error(`Model provider is still referenced by ${x.length} model(s) and ${p.length} fallback configuration(s)`);let h=x.map((Y)=>Y.id),F=b.models.filter((Y)=>Y.provider!==f).map((Y)=>{let Q=Y.fallbackModels?.filter((H)=>H.provider!==f),{fallbackModels:X,...j}=Y;return Q?.length?{...j,fallbackModels:Q}:j});if(F.length===0)throw Error("Cannot remove the provider that owns the only model");let z={...b.modelProviders};delete z[f];let G={modelProviders:z,models:F};if(h.includes(b.currentModelId))G.currentModelId=F[0].id;let Z=B(),$=await Z.credentials.read(f);await Z.credentials.delete(f);let{removeModels:U,...w}=y;try{return await X0().updateConfig(G,{scope:"global",immediate:!0,...w}),{removedModelIds:h}}catch(Y){if($)await Z.credentials.modify(f,async()=>$);throw Y}},updateModel:async(f,y,b={})=>{let x=K();if(!x)throw Error("Config not initialized");let p=x.models.findIndex((F)=>F.id===f);if(p===-1)throw Error(`Model not found: ${f}`);let h=[...x.models];h[p]={...h[p],...y},V().config.actions.updateConfig({models:h}),await W().save({models:h},{scope:"global",...b})},removeModel:async(f,y={})=>{let b=K();if(!b)throw Error("Config not initialized");if(b.models.length===1)throw Error("Cannot remove the only model");let x=b.models.filter((h)=>h.id!==f),p={models:x};if(b.currentModelId===f)p.currentModelId=x[0].id;V().config.actions.updateConfig(p),await W().save(p,{scope:"global",...y})},addMcpServer:async(f,y,b={})=>{let x=K();if(!x)throw Error("Config not initialized");let p=x.mcpServers??{},h=Y0(y),F={...y,...h?{oauth:h}:{}},z={...p,[f]:F};V().config.actions.updateConfig({mcpServers:z}),await W().save({mcpServers:z},{scope:"project",...b})},removeMcpServer:async(f,y={})=>{let b=K();if(!b)throw Error("Config not initialized");let p={...b.mcpServers??{}};delete p[f],V().config.actions.updateConfig({mcpServers:p}),await W().save({mcpServers:p},{scope:"project",...y})}});
25
+ export{a as Kf,e as Lf,J as Mf,M0 as Nf,l0 as Of,i0 as Pf,o0 as Qf,a0 as Rf,n0 as Sf,s0 as Tf,E0 as Uf,V as Vf,_2 as Wf,W2 as Xf,K2 as Yf,K as Zf,w2 as _f,O2 as $f,B2 as ag,q2 as bg,u2 as cg,D2 as dg,X0 as eg};
@@ -1,2 +1,2 @@
1
- import{Xj as I}from"./chunk-c1331rdc.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-mnm8epn5.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 +1 @@
1
- import{k as o}from"./chunk-b0smnpzh.js";import"./chunk-c1331rdc.js";import"./chunk-gmpsfkgg.js";import{execSync as r}from"child_process";var l={command:"update",describe:"Check for updates and install if available",handler:async()=>{console.log("Checking for updates...");try{let e=await o(!0);if(console.log(`Current version: ${e.currentVersion}`),e.error){console.log(`Warning: ${e.error}`);return}if(e.latestVersion)console.log(`Latest version: ${e.latestVersion}`);if(e.hasUpdate&&e.latestVersion){console.log(""),console.log(`\x1B[33mUpdate available: ${e.currentVersion} -> ${e.latestVersion}\x1B[0m`),console.log(""),console.log("Updating...");try{r("npm install -g blade-code@latest --registry https://registry.npmjs.org",{stdio:"inherit"}),console.log(""),console.log("Update complete!")}catch(t){console.error("Error: Update failed. Please run manually:"),console.error(" npm install -g blade-code@latest"),process.exit(1)}}else console.log("You are running the latest version of Blade")}catch(e){console.error(`Error: Failed to check for updates: ${e instanceof Error?e.message:"未知错误"}`),process.exit(1)}}};export{l as updateCommands};
1
+ import{k as o}from"./chunk-katmqxmn.js";import"./chunk-mnm8epn5.js";import"./chunk-gmpsfkgg.js";import{execSync as r}from"child_process";var l={command:"update",describe:"Check for updates and install if available",handler:async()=>{console.log("Checking for updates...");try{let e=await o(!0);if(console.log(`Current version: ${e.currentVersion}`),e.error){console.log(`Warning: ${e.error}`);return}if(e.latestVersion)console.log(`Latest version: ${e.latestVersion}`);if(e.hasUpdate&&e.latestVersion){console.log(""),console.log(`\x1B[33mUpdate available: ${e.currentVersion} -> ${e.latestVersion}\x1B[0m`),console.log(""),console.log("Updating...");try{r("npm install -g blade-code@latest --registry https://registry.npmjs.org",{stdio:"inherit"}),console.log(""),console.log("Update complete!")}catch(t){console.error("Error: Update failed. Please run manually:"),console.error(" npm install -g blade-code@latest"),process.exit(1)}}else console.log("You are running the latest version of Blade")}catch(e){console.error(`Error: Failed to check for updates: ${e instanceof Error?e.message:"未知错误"}`),process.exit(1)}}};export{l as updateCommands};
@@ -0,0 +1,2 @@
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.10",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/download-ripgrep.js && 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,4 +1,4 @@
1
- import"./chunk-v508x7cg.js";import{Ui as Q}from"./chunk-nr5s7qtp.js";import{Zi as L}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-c1331rdc.js";import"./chunk-asgmmaec.js";import"./chunk-ed2hdrwe.js";import{Jk as F}from"./chunk-gmpsfkgg.js";var K=[22,19,0];function T(G){let A=/^v?(\d+)\.(\d+)\.(\d+)/.exec(G);if(!A)return!1;let H=A.slice(1).map(Number);for(let z=0;z<K.length;z++){let B=H[z]??0,J=K[z];if(B!==J)return B>J}return!0}var X={command:"doctor",describe:"Check the health of your Blade installation",builder:(G)=>G.option("rebuild-index",{type:"boolean",default:!1,describe:"Rebuild the SQLite session index from JSONL transcripts"}),handler:async(G)=>{if(G.rebuildIndex){console.log(`Rebuilding session index from JSONL transcripts...
2
- `);try{let{rebuildProjectionIndex:z}=await import("./chunk-hb680ebj.js"),{SessionService:B}=await import("./chunk-erget6wk.js"),J=await z(B.projectionDeriverForSearch());if(J===null)console.log("[WARN] Session index unavailable (SQLite driver missing); reads fall back to JSONL scan.");else console.log(`[OK] Session index rebuilt: ${J} session(s) indexed.`)}catch(z){console.log("[FAIL] Session index rebuild failed"),console.log(` Error: ${z instanceof Error?z.message:"未知错误"}`),process.exit(1)}return}console.log(`Running Blade health check...
1
+ import"./chunk-v508x7cg.js";import{Ui as Q}from"./chunk-z7f2a75f.js";import{Zi as L}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-mnm8epn5.js";import"./chunk-asgmmaec.js";import"./chunk-ed2hdrwe.js";import{Jk as F}from"./chunk-gmpsfkgg.js";var K=[22,19,0];function T(G){let A=/^v?(\d+)\.(\d+)\.(\d+)/.exec(G);if(!A)return!1;let H=A.slice(1).map(Number);for(let z=0;z<K.length;z++){let B=H[z]??0,J=K[z];if(B!==J)return B>J}return!0}var X={command:"doctor",describe:"Check the health of your Blade installation",builder:(G)=>G.option("rebuild-index",{type:"boolean",default:!1,describe:"Rebuild the SQLite session index from JSONL transcripts"}),handler:async(G)=>{if(G.rebuildIndex){console.log(`Rebuilding session index from JSONL transcripts...
2
+ `);try{let{rebuildProjectionIndex:z}=await import("./chunk-hb680ebj.js"),{SessionService:B}=await import("./chunk-d40j41s5.js"),J=await z(B.projectionDeriverForSearch());if(J===null)console.log("[WARN] Session index unavailable (SQLite driver missing); reads fall back to JSONL scan.");else console.log(`[OK] Session index rebuilt: ${J} session(s) indexed.`)}catch(z){console.log("[FAIL] Session index rebuild failed"),console.log(` Error: ${z instanceof Error?z.message:"未知错误"}`),process.exit(1)}return}console.log(`Running Blade health check...
3
3
  `);let A=0;try{await Q.getInstance().initialize(),console.log("[OK] Configuration: OK")}catch(z){console.log("[FAIL] Configuration: FAILED"),console.log(` Error: ${z instanceof Error?z.message:"未知错误"}`),A++}let H=process.version;if(T(H))console.log(`[OK] Node.js version: ${H}`);else console.log(`[WARN] Node.js version: ${H} (required: >=22.19.0)`),A++;try{let z=await import("fs/promises"),B=L();await z.access(B,(await import("fs")).constants.R_OK|(await import("fs")).constants.W_OK),console.log("[OK] File system permissions: OK")}catch(z){console.log("[FAIL] File system permissions: FAILED"),console.log(" Error: Cannot read/write in current directory"),A++}try{await import("ink"),console.log("[OK] Dependencies: OK")}catch(z){console.log("[FAIL] Dependencies: FAILED"),console.log(" Error: Missing required dependencies"),A++}if(console.log(`
4
4
  Health Check Summary:`),A===0)console.log("All checks passed! Blade is ready to use.");else console.log(`Warning: Found ${A} issue(s). Please resolve them for optimal performance.`),process.exit(1)}};export{T as isSupportedNodeVersion,X as doctorCommands};
@@ -1,2 +1,2 @@
1
- import{Z as I}from"./chunk-e613h191.js";import{ne as M}from"./chunk-ayqqhefz.js";import P from"node:path";function w(s){let a=s.replace(/\s+/g," ").trim();return a.length<=72?a:`${a.slice(0,69)}...`}function W(s){let a=s.replace(/\s+/g," ").trim();return a.length<=500?a:`${a.slice(0,497)}...`}function A(s){return`task/${s.replace(/[^a-zA-Z0-9_-]/g,"-").slice(0,40)}`}class C{static async createSessionTask(s){if(!s.prompt.trim())throw Error("Task prompt must not be blank");if(!P.isAbsolute(s.sourceProjectPath))throw Error("Task source project path must be absolute");let a=P.resolve(s.sourceProjectPath),t;try{return t=s.isolation==="worktree"?await I.enter({sessionId:s.sessionId,workspaceRoot:a,name:A(s.sessionId)}):void 0,{metadata:await M.createSessionMetadata(s.sessionId,t?.workspaceRoot??a,{title:s.title?.trim()||w(s.prompt),taskPromptSummary:W(s.prompt),taskPriority:s.taskPriority,taskKind:s.taskKind,taskDueAt:s.taskDueAt,taskDispatch:s.dispatch,taskModelId:s.dispatch?.modelId,selectedModelId:s.dispatch?.modelId,permissionMode:s.dispatch?.permissionMode,reasoningEffort:s.dispatch?.reasoningEffort,serviceTier:s.dispatch?.serviceTier,responseVerbosity:s.dispatch?.responseVerbosity,communicationStyle:s.dispatch?.communicationStyle,communicationStyleDigest:s.dispatch?.communicationStyleDigest,projectInstructionsDigest:s.dispatch?.projectInstructionsDigest,taskRetriedFrom:s.retriedFrom,taskIsolation:s.isolation,taskSourceProjectPath:a,taskWorktree:t}),taskWorktree:t}}catch(k){if(t)await I.exit({sessionId:s.sessionId,action:"remove",discardChanges:!0}).catch(()=>{return});throw k}}}var $=256,V=8388608,x=30000;class i extends Error{kind;pendingItems;pendingBytes;constructor(s,a,t){super(a,t);this.kind=s;this.name="BoundedSerialEgressError",this.pendingItems=t?.pendingItems,this.pendingBytes=t?.pendingBytes}}function T(s){s.catch(()=>{return})}class K{options;pending=[];flushWaiters=[];pendingBytes=0;nextSequence=0;completedSequence=0;draining=!1;closed=!1;failure;activeWriteAbort;activeWriteStop;activeWriteTimeout;constructor(s){this.options=s;if(this.assertPositiveInteger(s.maxPendingItems,"maxPendingItems"),this.assertPositiveInteger(s.maxPendingBytes,"maxPendingBytes"),this.assertPositiveInteger(s.writeTimeoutMs,"writeTimeoutMs"),s.signal?.addEventListener("abort",this.handleAbort,{once:!0}),s.signal?.aborted)this.handleAbort()}offer(s){if(this.closed)return{accepted:!1,error:this.failure??new i("closed","Egress is already closed")};let a;try{a=this.options.sizeOf(s)}catch(h){return this.rejectAdmission(new i("invalid_size","Egress size calculation failed",{cause:h}))}if(!Number.isSafeInteger(a)||a<0)return this.rejectAdmission(new i("invalid_size","Egress size must be a non-negative safe integer"));if(a>this.options.maxPendingBytes)return this.rejectAdmission(new i("oversized",`Egress value requires ${a} bytes; limit is ${this.options.maxPendingBytes}`));if(this.pending.length>=this.options.maxPendingItems||this.pendingBytes+a>this.options.maxPendingBytes)return this.rejectAdmission(new i("overflow",`Egress pending limit exceeded (${this.pending.length} items, ${this.pendingBytes} bytes)`));let t,k,c=new Promise((h,m)=>{t=h,k=m});return T(c),this.nextSequence+=1,this.pending.push({value:s,bytes:a,sequence:this.nextSequence,resolve:t,reject:k,completion:c}),this.pendingBytes+=a,this.startDrain(),{accepted:!0,completion:c}}flush(){if(this.failure){let c=Promise.reject(this.failure);return T(c),c}let s=this.nextSequence;if(s<=this.completedSequence)return Promise.resolve();let a,t,k=new Promise((c,h)=>{a=c,t=h});return T(k),this.flushWaiters.push({targetSequence:s,resolve:a,reject:t}),k}close(s){let a=s instanceof i?s:new i("closed","Egress was closed",{cause:s});this.fail(a)}stats(){return{closed:this.closed,pendingItems:this.pending.length,pendingBytes:this.pendingBytes}}handleAbort=()=>{this.fail(new i("aborted","Egress was aborted",{cause:this.options.signal?.reason}))};rejectAdmission(s){return this.fail(s),{accepted:!1,error:s}}startDrain(){if(this.draining||this.closed)return;this.draining=!0;let s=this.drain();T(s)}async drain(){try{while(!this.closed){let s=this.pending[0];if(!s)return;try{await this.writeOne(s.value)}catch(a){this.fail(this.normalizeWriteError(a));return}if(this.closed||this.pending[0]!==s)return;this.pending.shift(),this.pendingBytes-=s.bytes,this.completedSequence=s.sequence,s.resolve(),this.settleFlushWaiters()}}finally{if(this.draining=!1,!this.closed&&this.pending.length>0)this.startDrain()}}async writeOne(s){let a=new AbortController;this.activeWriteAbort=a;let t,k,c=new Promise((S,f)=>{k=f});T(c),this.activeWriteStop=k;let h=Promise.resolve().then(()=>this.options.write(s,a.signal));T(h);let m=new Promise((S,f)=>{t=setTimeout(()=>{let D=new i("write_timeout",`Egress write timed out after ${this.options.writeTimeoutMs}ms`);a.abort(D),f(D)},this.options.writeTimeoutMs),this.activeWriteTimeout=t});T(m);try{await Promise.race([h,m,c])}finally{if(t!==void 0)clearTimeout(t);if(this.activeWriteTimeout===t)this.activeWriteTimeout=void 0;if(this.activeWriteAbort===a)this.activeWriteAbort=void 0;if(this.activeWriteStop===k)this.activeWriteStop=void 0}}normalizeWriteError(s){if(s instanceof i)return s;return new i("write_failed","Egress write failed",{cause:s})}fail(s){if(this.closed)return;if(s.pendingItems??=this.pending.length,s.pendingBytes??=this.pendingBytes,this.closed=!0,this.failure=s,this.options.signal?.removeEventListener("abort",this.handleAbort),this.activeWriteTimeout!==void 0)clearTimeout(this.activeWriteTimeout),this.activeWriteTimeout=void 0;this.activeWriteAbort?.abort(s),this.activeWriteStop?.(s),this.activeWriteAbort=void 0,this.activeWriteStop=void 0;let a=this.pending.splice(0);this.pendingBytes=0;for(let t of a)t.reject(s);for(let t of this.flushWaiters.splice(0))t.reject(s);try{this.options.onFailure?.(s)}catch{}}settleFlushWaiters(){for(let s=0;s<this.flushWaiters.length;){let a=this.flushWaiters[s];if(a.targetSequence>this.completedSequence){s+=1;continue}this.flushWaiters.splice(s,1),a.resolve()}}assertPositiveInteger(s,a){if(!Number.isSafeInteger(s)||s<=0)throw RangeError(`${a} must be a positive safe integer`)}}
1
+ import{Z as I}from"./chunk-8wk4q3bz.js";import{ne as M}from"./chunk-7bvtz3mm.js";import P from"node:path";function w(s){let a=s.replace(/\s+/g," ").trim();return a.length<=72?a:`${a.slice(0,69)}...`}function W(s){let a=s.replace(/\s+/g," ").trim();return a.length<=500?a:`${a.slice(0,497)}...`}function A(s){return`task/${s.replace(/[^a-zA-Z0-9_-]/g,"-").slice(0,40)}`}class C{static async createSessionTask(s){if(!s.prompt.trim())throw Error("Task prompt must not be blank");if(!P.isAbsolute(s.sourceProjectPath))throw Error("Task source project path must be absolute");let a=P.resolve(s.sourceProjectPath),t;try{return t=s.isolation==="worktree"?await I.enter({sessionId:s.sessionId,workspaceRoot:a,name:A(s.sessionId)}):void 0,{metadata:await M.createSessionMetadata(s.sessionId,t?.workspaceRoot??a,{title:s.title?.trim()||w(s.prompt),taskPromptSummary:W(s.prompt),taskPriority:s.taskPriority,taskKind:s.taskKind,taskDueAt:s.taskDueAt,taskDispatch:s.dispatch,taskModelId:s.dispatch?.modelId,selectedModelId:s.dispatch?.modelId,permissionMode:s.dispatch?.permissionMode,reasoningEffort:s.dispatch?.reasoningEffort,serviceTier:s.dispatch?.serviceTier,responseVerbosity:s.dispatch?.responseVerbosity,communicationStyle:s.dispatch?.communicationStyle,communicationStyleDigest:s.dispatch?.communicationStyleDigest,projectInstructionsDigest:s.dispatch?.projectInstructionsDigest,taskRetriedFrom:s.retriedFrom,taskIsolation:s.isolation,taskSourceProjectPath:a,taskWorktree:t}),taskWorktree:t}}catch(k){if(t)await I.exit({sessionId:s.sessionId,action:"remove",discardChanges:!0}).catch(()=>{return});throw k}}}var $=256,V=8388608,x=30000;class i extends Error{kind;pendingItems;pendingBytes;constructor(s,a,t){super(a,t);this.kind=s;this.name="BoundedSerialEgressError",this.pendingItems=t?.pendingItems,this.pendingBytes=t?.pendingBytes}}function T(s){s.catch(()=>{return})}class K{options;pending=[];flushWaiters=[];pendingBytes=0;nextSequence=0;completedSequence=0;draining=!1;closed=!1;failure;activeWriteAbort;activeWriteStop;activeWriteTimeout;constructor(s){this.options=s;if(this.assertPositiveInteger(s.maxPendingItems,"maxPendingItems"),this.assertPositiveInteger(s.maxPendingBytes,"maxPendingBytes"),this.assertPositiveInteger(s.writeTimeoutMs,"writeTimeoutMs"),s.signal?.addEventListener("abort",this.handleAbort,{once:!0}),s.signal?.aborted)this.handleAbort()}offer(s){if(this.closed)return{accepted:!1,error:this.failure??new i("closed","Egress is already closed")};let a;try{a=this.options.sizeOf(s)}catch(h){return this.rejectAdmission(new i("invalid_size","Egress size calculation failed",{cause:h}))}if(!Number.isSafeInteger(a)||a<0)return this.rejectAdmission(new i("invalid_size","Egress size must be a non-negative safe integer"));if(a>this.options.maxPendingBytes)return this.rejectAdmission(new i("oversized",`Egress value requires ${a} bytes; limit is ${this.options.maxPendingBytes}`));if(this.pending.length>=this.options.maxPendingItems||this.pendingBytes+a>this.options.maxPendingBytes)return this.rejectAdmission(new i("overflow",`Egress pending limit exceeded (${this.pending.length} items, ${this.pendingBytes} bytes)`));let t,k,c=new Promise((h,m)=>{t=h,k=m});return T(c),this.nextSequence+=1,this.pending.push({value:s,bytes:a,sequence:this.nextSequence,resolve:t,reject:k,completion:c}),this.pendingBytes+=a,this.startDrain(),{accepted:!0,completion:c}}flush(){if(this.failure){let c=Promise.reject(this.failure);return T(c),c}let s=this.nextSequence;if(s<=this.completedSequence)return Promise.resolve();let a,t,k=new Promise((c,h)=>{a=c,t=h});return T(k),this.flushWaiters.push({targetSequence:s,resolve:a,reject:t}),k}close(s){let a=s instanceof i?s:new i("closed","Egress was closed",{cause:s});this.fail(a)}stats(){return{closed:this.closed,pendingItems:this.pending.length,pendingBytes:this.pendingBytes}}handleAbort=()=>{this.fail(new i("aborted","Egress was aborted",{cause:this.options.signal?.reason}))};rejectAdmission(s){return this.fail(s),{accepted:!1,error:s}}startDrain(){if(this.draining||this.closed)return;this.draining=!0;let s=this.drain();T(s)}async drain(){try{while(!this.closed){let s=this.pending[0];if(!s)return;try{await this.writeOne(s.value)}catch(a){this.fail(this.normalizeWriteError(a));return}if(this.closed||this.pending[0]!==s)return;this.pending.shift(),this.pendingBytes-=s.bytes,this.completedSequence=s.sequence,s.resolve(),this.settleFlushWaiters()}}finally{if(this.draining=!1,!this.closed&&this.pending.length>0)this.startDrain()}}async writeOne(s){let a=new AbortController;this.activeWriteAbort=a;let t,k,c=new Promise((S,f)=>{k=f});T(c),this.activeWriteStop=k;let h=Promise.resolve().then(()=>this.options.write(s,a.signal));T(h);let m=new Promise((S,f)=>{t=setTimeout(()=>{let D=new i("write_timeout",`Egress write timed out after ${this.options.writeTimeoutMs}ms`);a.abort(D),f(D)},this.options.writeTimeoutMs),this.activeWriteTimeout=t});T(m);try{await Promise.race([h,m,c])}finally{if(t!==void 0)clearTimeout(t);if(this.activeWriteTimeout===t)this.activeWriteTimeout=void 0;if(this.activeWriteAbort===a)this.activeWriteAbort=void 0;if(this.activeWriteStop===k)this.activeWriteStop=void 0}}normalizeWriteError(s){if(s instanceof i)return s;return new i("write_failed","Egress write failed",{cause:s})}fail(s){if(this.closed)return;if(s.pendingItems??=this.pending.length,s.pendingBytes??=this.pendingBytes,this.closed=!0,this.failure=s,this.options.signal?.removeEventListener("abort",this.handleAbort),this.activeWriteTimeout!==void 0)clearTimeout(this.activeWriteTimeout),this.activeWriteTimeout=void 0;this.activeWriteAbort?.abort(s),this.activeWriteStop?.(s),this.activeWriteAbort=void 0,this.activeWriteStop=void 0;let a=this.pending.splice(0);this.pendingBytes=0;for(let t of a)t.reject(s);for(let t of this.flushWaiters.splice(0))t.reject(s);try{this.options.onFailure?.(s)}catch{}}settleFlushWaiters(){for(let s=0;s<this.flushWaiters.length;){let a=this.flushWaiters[s];if(a.targetSequence>this.completedSequence){s+=1;continue}this.flushWaiters.splice(s,1),a.resolve()}}assertPositiveInteger(s,a){if(!Number.isSafeInteger(s)||s<=0)throw RangeError(`${a} must be a positive safe integer`)}}
2
2
  export{C as E,$ as F,V as G,x as H,i as I,K as J};
@@ -0,0 +1 @@
1
+ import{xf as a,yf as b}from"./chunk-t5hhrj1g.js";import"./chunk-mnm8epn5.js";import"./chunk-gmpsfkgg.js";export{a as globalOptions,b as cliConfig};
@@ -1,2 +1,2 @@
1
- import{Xj as d,Zj as h}from"./chunk-c1331rdc.js";var q={debug:{alias:"d",type:"string",describe:'Enable debug mode with optional category filtering (e.g., "agent,ui" or "!chat,!loop")',group:"Debug Options:"},model:{type:"string",describe:"Override the current run model using a model config ID (TUI / print / headless)",group:"AI Options:"},print:{alias:"p",type:"boolean",describe:"Print response and exit (useful for pipes)",group:"Output Options:"},headless:{type:"boolean",describe:"Run full agent loop without Ink UI and print all events to the terminal",group:"Output Options:"},"output-format":{alias:["outputFormat"],type:"string",choices:["text","json","stream-json","jsonl"],default:"text",describe:"Output format: --print supports text|json|stream-json; --headless supports text|jsonl",group:"Output Options:"},"json-schema":{alias:["jsonSchema"],type:"string",describe:"Inline JSON Schema for the turn-scoped structured final response",group:"Output Options:"},"output-schema":{alias:["outputSchema"],type:"string",describe:"Path to a JSON Schema file for the structured final response",group:"Output Options:"},"include-partial-messages":{alias:["includePartialMessages"],type:"boolean",describe:"Include partial message chunks as they arrive",group:"Output Options:"},"input-format":{alias:["inputFormat"],type:"string",choices:["text","stream-json"],default:"text",describe:"Input format",group:"Input Options:"},"replay-user-messages":{alias:["replayUserMessages"],type:"boolean",describe:"Re-emit user messages from stdin",group:"Input Options:"},"allowed-tools":{alias:["allowedTools"],type:"array",string:!0,describe:"Comma or space-separated list of tool names to allow",group:"Security Options:"},"disallowed-tools":{alias:["disallowedTools"],type:"array",string:!0,describe:"Comma or space-separated list of tool names to deny",group:"Security Options:"},"mcp-config":{alias:["mcpConfig"],type:"array",string:!0,describe:"Load MCP servers from JSON files or strings",group:"MCP Options:"},"system-prompt":{alias:["systemPrompt"],type:"string",describe:"System prompt to use for the session (replaces default)",group:"AI Options:"},"append-system-prompt":{alias:["appendSystemPrompt"],type:"string",describe:"Append a system prompt to the default system prompt",group:"AI Options:"},"max-turns":{alias:["maxTurns"],type:"number",describe:"Maximum conversation turns (-1: unlimited, 0: disable chat, N>0: limit to N turns)",group:"AI Options:",default:void 0},"max-concurrent-tasks":{alias:["maxConcurrentTasks"],type:"number",describe:"Maximum top-level tasks running concurrently in this process",group:"AI Options:",default:void 0},"max-queued-tasks":{alias:["maxQueuedTasks"],type:"number",describe:"Maximum top-level tasks waiting for an admission slot",group:"AI Options:",default:void 0},"max-queued-task-bytes":{alias:["maxQueuedTaskBytes"],type:"number",describe:"Maximum retained bytes across queued top-level tasks",group:"AI Options:",default:void 0},"max-resident-session-runtimes":{alias:["maxResidentSessionRuntimes"],type:"number",describe:"Maximum initialized Session runtimes resident in this process",group:"AI Options:",default:void 0},"session-runtime-idle-ms":{alias:["sessionRuntimeIdleMs"],type:"number",describe:"Idle time before an evictable Web Session runtime is evicted",group:"AI Options:",default:void 0},"max-resident-session-projections":{alias:["maxResidentSessionProjections"],type:"number",describe:"Maximum resident Session projections retained in this process",group:"AI Options:",default:void 0},"session-projection-idle-ms":{alias:["sessionProjectionIdleMs"],type:"number",describe:"Idle time before an evictable Session projection is evicted",group:"AI Options:",default:void 0},"permission-mode":{alias:["permissionMode"],type:"string",choices:["default","autoEdit","yolo","plan"],describe:"Permission mode (default: ask for non-read tools, autoEdit: auto-approve edits, yolo: auto-approve all, plan: reserved)",group:"Security Options:"},yolo:{type:"boolean",describe:"Auto-approve all tools (shortcut for --permission-mode=yolo)",group:"Security Options:"},"trust-workspace":{alias:["trustWorkspace"],type:"boolean",describe:"Trust the current workspace before loading project models, MCP, LSP, permissions, or plugins",group:"Security Options:"},continue:{alias:"c",type:"boolean",describe:"Continue the most recent conversation",group:"Session Options:"},resume:{alias:"r",describe:"Resume a conversation - provide a session ID or interactively select a conversation to resume",group:"Session Options:",coerce:(b)=>{if(b===void 0||b===!0||b==="")return"true";return String(b)}},"fork-session":{alias:["forkSession"],type:"boolean",describe:"Create a new session ID when resuming",group:"Session Options:"},settings:{type:"string",describe:"Path to a settings JSON file or JSON string",group:"Configuration:"},"add-dir":{alias:["addDir"],type:"array",string:!0,describe:"Additional directories to allow tool access to",group:"Security Options:"},ide:{type:"boolean",describe:"Automatically connect to IDE on startup",group:"Integration:"},acp:{type:"boolean",describe:"Run in ACP (Agent Client Protocol) mode for IDE integration",group:"Integration:"},"strict-mcp-config":{alias:["strictMcpConfig"],type:"boolean",describe:"Only use MCP servers from --mcp-config",group:"MCP Options:"},"session-id":{alias:["sessionId"],type:"string",describe:"Use a specific session ID for the conversation",group:"Session Options:"},agents:{type:"string",describe:"JSON object defining custom agents",group:"AI Options:"},"setting-sources":{alias:["settingSources"],type:"string",describe:"Comma-separated list of setting sources to load",group:"Configuration:"},"plugin-dir":{alias:["pluginDir"],type:"array",string:!0,describe:"Load plugins from specified directories",group:"Plugin Options:"}},w={scriptName:"blade",usage:"$0 [command] [options]",description:h(),version:d(),locale:"en",showHelpOnFail:!0,demandCommand:!1,recommendCommands:!0,strict:!1};
1
+ import{Xj as d,Zj as h}from"./chunk-mnm8epn5.js";var q={debug:{alias:"d",type:"string",describe:'Enable debug mode with optional category filtering (e.g., "agent,ui" or "!chat,!loop")',group:"Debug Options:"},model:{type:"string",describe:"Override the current run model using a model config ID (TUI / print / headless)",group:"AI Options:"},print:{alias:"p",type:"boolean",describe:"Print response and exit (useful for pipes)",group:"Output Options:"},headless:{type:"boolean",describe:"Run full agent loop without Ink UI and print all events to the terminal",group:"Output Options:"},"output-format":{alias:["outputFormat"],type:"string",choices:["text","json","stream-json","jsonl"],default:"text",describe:"Output format: --print supports text|json|stream-json; --headless supports text|jsonl",group:"Output Options:"},"json-schema":{alias:["jsonSchema"],type:"string",describe:"Inline JSON Schema for the turn-scoped structured final response",group:"Output Options:"},"output-schema":{alias:["outputSchema"],type:"string",describe:"Path to a JSON Schema file for the structured final response",group:"Output Options:"},"include-partial-messages":{alias:["includePartialMessages"],type:"boolean",describe:"Include partial message chunks as they arrive",group:"Output Options:"},"input-format":{alias:["inputFormat"],type:"string",choices:["text","stream-json"],default:"text",describe:"Input format",group:"Input Options:"},"replay-user-messages":{alias:["replayUserMessages"],type:"boolean",describe:"Re-emit user messages from stdin",group:"Input Options:"},"allowed-tools":{alias:["allowedTools"],type:"array",string:!0,describe:"Comma or space-separated list of tool names to allow",group:"Security Options:"},"disallowed-tools":{alias:["disallowedTools"],type:"array",string:!0,describe:"Comma or space-separated list of tool names to deny",group:"Security Options:"},"mcp-config":{alias:["mcpConfig"],type:"array",string:!0,describe:"Load MCP servers from JSON files or strings",group:"MCP Options:"},"system-prompt":{alias:["systemPrompt"],type:"string",describe:"System prompt to use for the session (replaces default)",group:"AI Options:"},"append-system-prompt":{alias:["appendSystemPrompt"],type:"string",describe:"Append a system prompt to the default system prompt",group:"AI Options:"},"max-turns":{alias:["maxTurns"],type:"number",describe:"Maximum conversation turns (-1: unlimited, 0: disable chat, N>0: limit to N turns)",group:"AI Options:",default:void 0},"max-concurrent-tasks":{alias:["maxConcurrentTasks"],type:"number",describe:"Maximum top-level tasks running concurrently in this process",group:"AI Options:",default:void 0},"max-queued-tasks":{alias:["maxQueuedTasks"],type:"number",describe:"Maximum top-level tasks waiting for an admission slot",group:"AI Options:",default:void 0},"max-queued-task-bytes":{alias:["maxQueuedTaskBytes"],type:"number",describe:"Maximum retained bytes across queued top-level tasks",group:"AI Options:",default:void 0},"max-resident-session-runtimes":{alias:["maxResidentSessionRuntimes"],type:"number",describe:"Maximum initialized Session runtimes resident in this process",group:"AI Options:",default:void 0},"session-runtime-idle-ms":{alias:["sessionRuntimeIdleMs"],type:"number",describe:"Idle time before an evictable Web Session runtime is evicted",group:"AI Options:",default:void 0},"max-resident-session-projections":{alias:["maxResidentSessionProjections"],type:"number",describe:"Maximum resident Session projections retained in this process",group:"AI Options:",default:void 0},"session-projection-idle-ms":{alias:["sessionProjectionIdleMs"],type:"number",describe:"Idle time before an evictable Session projection is evicted",group:"AI Options:",default:void 0},"permission-mode":{alias:["permissionMode"],type:"string",choices:["default","autoEdit","yolo","plan"],describe:"Permission mode (default: ask for non-read tools, autoEdit: auto-approve edits, yolo: auto-approve all, plan: reserved)",group:"Security Options:"},yolo:{type:"boolean",describe:"Auto-approve all tools (shortcut for --permission-mode=yolo)",group:"Security Options:"},"trust-workspace":{alias:["trustWorkspace"],type:"boolean",describe:"Trust the current workspace before loading project models, MCP, LSP, permissions, or plugins",group:"Security Options:"},continue:{alias:"c",type:"boolean",describe:"Continue the most recent conversation",group:"Session Options:"},resume:{alias:"r",describe:"Resume a conversation - provide a session ID or interactively select a conversation to resume",group:"Session Options:",coerce:(b)=>{if(b===void 0||b===!0||b==="")return"true";return String(b)}},"fork-session":{alias:["forkSession"],type:"boolean",describe:"Create a new session ID when resuming",group:"Session Options:"},settings:{type:"string",describe:"Path to a settings JSON file or JSON string",group:"Configuration:"},"add-dir":{alias:["addDir"],type:"array",string:!0,describe:"Additional directories to allow tool access to",group:"Security Options:"},ide:{type:"boolean",describe:"Automatically connect to IDE on startup",group:"Integration:"},acp:{type:"boolean",describe:"Run in ACP (Agent Client Protocol) mode for IDE integration",group:"Integration:"},"strict-mcp-config":{alias:["strictMcpConfig"],type:"boolean",describe:"Only use MCP servers from --mcp-config",group:"MCP Options:"},"session-id":{alias:["sessionId"],type:"string",describe:"Use a specific session ID for the conversation",group:"Session Options:"},agents:{type:"string",describe:"JSON object defining custom agents",group:"AI Options:"},"setting-sources":{alias:["settingSources"],type:"string",describe:"Comma-separated list of setting sources to load",group:"Configuration:"},"plugin-dir":{alias:["pluginDir"],type:"array",string:!0,describe:"Load plugins from specified directories",group:"Plugin Options:"}},w={scriptName:"blade",usage:"$0 [command] [options]",description:h(),version:d(),locale:"en",showHelpOnFail:!0,demandCommand:!1,recommendCommands:!0,strict:!1};
2
2
  export{q as xf,w as yf};
@@ -1,4 +1,4 @@
1
- import{Va as H}from"./chunk-74vmjngm.js";import"./chunk-9qxch6sy.js";import"./chunk-skktstg8.js";import{cg as $,eg as T}from"./chunk-dgypy6yt.js";import"./chunk-x6k5ye1z.js";import"./chunk-v508x7cg.js";import"./chunk-3m8949fr.js";import"./chunk-ys8gysg8.js";import"./chunk-nr5s7qtp.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-c1331rdc.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-0vet7np5.js";import"./chunk-9qxch6sy.js";import"./chunk-skktstg8.js";import{cg as $,eg as T}from"./chunk-k6knawfb.js";import"./chunk-x6k5ye1z.js";import"./chunk-v508x7cg.js";import"./chunk-vkabej0v.js";import"./chunk-ys8gysg8.js";import"./chunk-z7f2a75f.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-mnm8epn5.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 字符串添加服务器