blade-code 0.11.6 → 0.11.8

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 (42) hide show
  1. package/dist/blade.js +2 -2
  2. package/dist/{chunk-vp4rdvvw.js → chunk-0e9nrf53.js} +1 -1
  3. package/dist/{chunk-vgkcck5q.js → chunk-14jd0cj6.js} +1 -1
  4. package/dist/{chunk-sb12h5yv.js → chunk-1crgzzz7.js} +53 -53
  5. package/dist/{chunk-6sk6chsm.js → chunk-1gr9vqy1.js} +1 -1
  6. package/dist/{chunk-nneh4gkw.js → chunk-22py5y1p.js} +1 -1
  7. package/dist/{chunk-t39n33ek.js → chunk-29t2wbwt.js} +1 -1
  8. package/dist/{chunk-s2ner5gp.js → chunk-2fj047zf.js} +1 -1
  9. package/dist/{chunk-a1y938pg.js → chunk-34y4z9ns.js} +1 -1
  10. package/dist/{chunk-8yh4mn8a.js → chunk-3m8949fr.js} +1 -1
  11. package/dist/{chunk-vnxj21sa.js → chunk-3t655nhk.js} +99 -97
  12. package/dist/{chunk-0vw2xj0h.js → chunk-53twn9t2.js} +1 -1
  13. package/dist/{chunk-aq7e74mn.js → chunk-547g7bq5.js} +2 -2
  14. package/dist/{chunk-yg81xx37.js → chunk-5q2gp1bb.js} +1 -1
  15. package/dist/{chunk-qexnx2v2.js → chunk-74vmjngm.js} +1 -1
  16. package/dist/{chunk-xmp1ve8a.js → chunk-7876fd4b.js} +1 -1
  17. package/dist/{chunk-6h1x1m4f.js → chunk-8r8fp09p.js} +1 -1
  18. package/dist/{chunk-hxwzdkwp.js → chunk-926rkw87.js} +1 -1
  19. package/dist/{chunk-6jjpj5ge.js → chunk-ayqqhefz.js} +1 -1
  20. package/dist/{chunk-y7zh1sq6.js → chunk-b0smnpzh.js} +1 -1
  21. package/dist/{chunk-bzwxh6nq.js → chunk-c1331rdc.js} +1 -1
  22. package/dist/{chunk-mhv4q5sg.js → chunk-de3wa8nq.js} +1 -1
  23. package/dist/{chunk-acxyw1ej.js → chunk-dgypy6yt.js} +1 -1
  24. package/dist/{chunk-n32pbwyk.js → chunk-e613h191.js} +3 -3
  25. package/dist/{chunk-5vh8zyjz.js → chunk-erget6wk.js} +1 -1
  26. package/dist/{chunk-qfp7emtk.js → chunk-hdy7b6zw.js} +1 -1
  27. package/dist/{chunk-nh301gpr.js → chunk-j5e589we.js} +1 -1
  28. package/dist/chunk-jbp9wt3f.js +1 -0
  29. package/dist/chunk-kz842bqy.js +1 -0
  30. package/dist/{chunk-nznd7549.js → chunk-m8sttgjc.js} +1 -1
  31. package/dist/{chunk-87bd1w02.js → chunk-mmwqe49e.js} +1 -1
  32. package/dist/{chunk-cfxs7jdk.js → chunk-np5t59fa.js} +1 -1
  33. package/dist/{chunk-ftk0ytf8.js → chunk-nr5s7qtp.js} +1 -1
  34. package/dist/{chunk-zzacj0n9.js → chunk-rcfef8qj.js} +1 -1
  35. package/dist/{chunk-rgxknntk.js → chunk-re6hbrmb.js} +1 -1
  36. package/dist/{chunk-avrnqtca.js → chunk-rh1q6srx.js} +1 -1
  37. package/dist/{chunk-yh28byeh.js → chunk-rwtsvy5y.js} +1 -1
  38. package/dist/{chunk-8d1vekke.js → chunk-s7jd42xp.js} +1 -1
  39. package/dist/{chunk-fprmcxd6.js → chunk-vjvw3v6b.js} +1 -1
  40. package/package.json +1 -1
  41. package/dist/chunk-2s1gmqh4.js +0 -1
  42. package/dist/chunk-p9dvggw1.js +0 -1
@@ -1 +1 @@
1
- import{Xj as a,Yj as b,Zj as c,_j as d}from"./chunk-bzwxh6nq.js";import"./chunk-gmpsfkgg.js";export{a as getVersion,b as getPackageName,c as getDescription,d as getCopyright};
1
+ import{Xj as a,Yj as b,Zj as c,_j as d}from"./chunk-c1331rdc.js";import"./chunk-gmpsfkgg.js";export{a as getVersion,b as getPackageName,c as getDescription,d as getCopyright};
@@ -1,4 +1,4 @@
1
- import"./chunk-v508x7cg.js";import{Ui as Q}from"./chunk-ftk0ytf8.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-bzwxh6nq.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-5vh8zyjz.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-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...
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,4 +1,4 @@
1
- import{Va as H}from"./chunk-qexnx2v2.js";import"./chunk-9qxch6sy.js";import"./chunk-skktstg8.js";import{cg as $,eg as T}from"./chunk-acxyw1ej.js";import"./chunk-x6k5ye1z.js";import"./chunk-v508x7cg.js";import"./chunk-8yh4mn8a.js";import"./chunk-ys8gysg8.js";import"./chunk-ftk0ytf8.js";import{Zi as k}from"./chunk-b22ab7yw.js";import"./chunk-amabfzc8.js";import"./chunk-m2x6pb4f.js";import"./chunk-saz6mwpq.js";import"./chunk-xhwdac1j.js";import"./chunk-0eajnhrj.js";import"./chunk-bzwxh6nq.js";import"./chunk-asgmmaec.js";import"./chunk-ed2hdrwe.js";import"./chunk-gmpsfkgg.js";import U from"os";import J from"path";function X(z){return typeof z==="string"?z:void 0}function N(z){if(!Array.isArray(z))return;let q=[];for(let K of z)if(typeof K==="string")q.push(K);else if(K!=null)q.push(String(K));return q}function b(){console.log(`
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(`
2
2
  blade mcp
3
3
  `),console.log(`管理 MCP 服务器
4
4
  `),console.log("Commands:"),console.log(" blade mcp add <name> <commandOrUrl> [args...] 添加 MCP 服务器"),console.log(" blade mcp remove <name> 删除 MCP 服务器 [aliases: rm]"),console.log(" blade mcp list 列出所有 MCP 服务器并检查健康状态 [aliases: ls]"),console.log(" blade mcp get <name> 获取服务器详情"),console.log(" blade mcp login <name> 登录远程 MCP OAuth"),console.log(" blade mcp logout <name> 清除远程 MCP OAuth 凭证"),console.log(` blade mcp add-json <name> <json> 从 JSON 字符串添加服务器
@@ -1,4 +1,4 @@
1
- import{Ac as En,xc as Ut,yc as fn,zc as yn}from"./chunk-9qxch6sy.js";import{Ah as xt}from"./chunk-8yh4mn8a.js";import{$h as S,Gh as Ot,Hh as vi,Jh as en,Kh as Bt,Lh as U,Mh as sn,Nh as St,Oh as gt,Qh as rn,Rh as Tn,Sh as B,Th as on,Uh as dn,Vh as pn,Wh as Lt,Xh as cn,Yh as un,Zh as Mn,ci as wn,di as Vt,ei as lt,fi as h,gi as jt}from"./chunk-ftk0ytf8.js";import{Zi as Zt}from"./chunk-b22ab7yw.js";import{Gj as X,Ij as g}from"./chunk-saz6mwpq.js";import{Xj as tn,Yj as nn}from"./chunk-bzwxh6nq.js";import{Jk as ne}from"./chunk-gmpsfkgg.js";import{EventEmitter as be}from"events";import Un from"node:path";function hn(t){if(t===void 0)return"undefined";if(typeof t==="string")return t;try{let i=JSON.stringify(t);return i===void 0?String(t):i}catch{return String(t)}}function An(t){let i=t;switch(t.code){case"type":return`类型错误:${t.message}`;case"required":return"缺少必需参数";case"minLength":return`字符串过短:${t.message}`;case"maxLength":return`字符串过长:${t.message}`;case"minimum":case"exclusiveMinimum":return`数值太小:${t.message}`;case"maximum":case"exclusiveMaximum":return`数值太大:${t.message}`;case"minItems":return`数组元素过少:${t.message}`;case"maxItems":return`数组元素过多:${t.message}`;case"format":return`格式错误:${t.message}`;case"enum":return`必须是枚举允许的值之一:${t.message}`;case"const":return`必须是指定的字面量值:${t.message}`;case"additionalProperties":case"unevaluatedProperties":return`包含未知参数:${t.message}`;case"anyOf":case"oneOf":return"不符合任何有效的类型定义";case"~refine":return t.message||"自定义验证失败";default:return t.message||`验证失败:${hn(i)}`}}class Yt extends Error{issues;type;constructor(t,i,n="validation_error"){super(t);this.issues=i;this.type=n;this.name="ToolValidationError"}}function Ft(t,i){let n=X(t,i);if(n.success)return n.data;let e=n.error.issues.map((r)=>({field:r.path.length>0?r.path.join("."):"root",message:An(r),value:r.value})),s=e.length===1?`参数验证失败 [${e[0].field}]: ${e[0].message}`:`参数验证失败 (${e.length} 个错误):
1
+ import{Ac as En,xc as Ut,yc as fn,zc as yn}from"./chunk-9qxch6sy.js";import{Ah as xt}from"./chunk-3m8949fr.js";import{$h as S,Gh as Ot,Hh as vi,Jh as en,Kh as Bt,Lh as U,Mh as sn,Nh as St,Oh as gt,Qh as rn,Rh as Tn,Sh as B,Th as on,Uh as dn,Vh as pn,Wh as Lt,Xh as cn,Yh as un,Zh as Mn,ci as wn,di as Vt,ei as lt,fi as h,gi as jt}from"./chunk-nr5s7qtp.js";import{Zi as Zt}from"./chunk-b22ab7yw.js";import{Gj as X,Ij as g}from"./chunk-saz6mwpq.js";import{Xj as tn,Yj as nn}from"./chunk-c1331rdc.js";import{Jk as ne}from"./chunk-gmpsfkgg.js";import{EventEmitter as be}from"events";import Un from"node:path";function hn(t){if(t===void 0)return"undefined";if(typeof t==="string")return t;try{let i=JSON.stringify(t);return i===void 0?String(t):i}catch{return String(t)}}function An(t){let i=t;switch(t.code){case"type":return`类型错误:${t.message}`;case"required":return"缺少必需参数";case"minLength":return`字符串过短:${t.message}`;case"maxLength":return`字符串过长:${t.message}`;case"minimum":case"exclusiveMinimum":return`数值太小:${t.message}`;case"maximum":case"exclusiveMaximum":return`数值太大:${t.message}`;case"minItems":return`数组元素过少:${t.message}`;case"maxItems":return`数组元素过多:${t.message}`;case"format":return`格式错误:${t.message}`;case"enum":return`必须是枚举允许的值之一:${t.message}`;case"const":return`必须是指定的字面量值:${t.message}`;case"additionalProperties":case"unevaluatedProperties":return`包含未知参数:${t.message}`;case"anyOf":case"oneOf":return"不符合任何有效的类型定义";case"~refine":return t.message||"自定义验证失败";default:return t.message||`验证失败:${hn(i)}`}}class Yt extends Error{issues;type;constructor(t,i,n="validation_error"){super(t);this.issues=i;this.type=n;this.name="ToolValidationError"}}function Ft(t,i){let n=X(t,i);if(n.success)return n.data;let e=n.error.issues.map((r)=>({field:r.path.length>0?r.path.join("."):"root",message:An(r),value:r.value})),s=e.length===1?`参数验证失败 [${e[0].field}]: ${e[0].message}`:`参数验证失败 (${e.length} 个错误):
2
2
  ${e.map((r)=>` - ${r.field}: ${r.message}`).join(`
3
3
  `)}`;throw new Yt(s,e)}function et(t){if(!t||typeof t!=="object")return;let i=t;if(i.type==="object"&&i.properties)i.required??=[],i.additionalProperties??=!1;for(let n of Object.values(i))if(Array.isArray(n))for(let e of n)et(e);else et(n)}function st(t){let i=JSON.parse(JSON.stringify(t,(n,e)=>n.startsWith("~")?void 0:e));return et(i),i}class rt{toolName;params;executeFn;descriptionFn;affectedPathsFn;isRetrySafe;constructor(t,i,n,e,s,r=!1){this.toolName=t;this.params=i;this.executeFn=n;this.descriptionFn=e;this.affectedPathsFn=s;this.isRetrySafe=r}getDescription(){if(this.descriptionFn)return this.descriptionFn(this.params);return`执行工具: ${this.toolName}`}getAffectedPaths(){if(this.affectedPathsFn)return this.affectedPathsFn(this.params);return[]}async execute(t,i,n){let e={signal:t,updateOutput:i,...n};return this.executeFn(this.params,e)}}function Jt(t){return{name:t.name,displayName:t.displayName,kind:t.kind,isConcurrencySafe:t.isConcurrencySafe??!1,isRetrySafe:t.isRetrySafe??!1,parallelism:t.parallelism??(t.isConcurrencySafe?"shared":"exclusive"),strict:t.strict??!1,description:t.description,version:t.version||"1.0.0",category:t.category,tags:t.tags||[],getFunctionDeclaration(){let i=st(t.schema),n=t.description.short;if(t.description.long)n+=`
4
4
 
@@ -1,4 +1,4 @@
1
- import{e as B3,f as x3,g as f3,h as r0,i as S3}from"./chunk-nh301gpr.js";import{j as o1}from"./chunk-870szc6v.js";import{w as t0,x as d2,y as T1,z as c1}from"./chunk-87bd1w02.js";import{A as c2,B as l2,C as i2,D as m0}from"./chunk-fprmcxd6.js";import{E as h2,F as _$,G as N$,H as B$,I as G0,J as x$}from"./chunk-nneh4gkw.js";import{$ as C2,Aa as N3,Da as U5,Ia as i3,N as m1,O as l3,R as T2,S as O1,T as i4,V as i1,W as p$,X as A4,Y as j4,Z as W0,_ as I2,aa as M$,ba as F1,da as S2,ea as P2,fa as b4,ga as N0,ha as B0,ka as C4,la as R4,ma as Q5,na as k2,oa as J2,pa as Z3,qa as J3,ra as Q3,sa as Y3,ta as X3,ua as V3,va as z3,wa as G3,xa as K3}from"./chunk-n32pbwyk.js";import{Pa as E$,Va as iO}from"./chunk-qexnx2v2.js";import{$a as E2,Ab as $$,Ya as Z2,_a as R2,ab as f2,gb as V4,jb as a3,kb as n4,lb as y2,mb as m2,nb as o3,ob as t3,pb as a4,qb as s3,rb as v0,sb as M3,tb as L3,ub as A3,vb as g2,wb as v2,xb as p2,yb as u2,zb as H$}from"./chunk-whxkwaz1.js";import{Ob as nO,Pb as i,Rb as m,Sb as q2,bc as _4,mc as g0}from"./chunk-vnxj21sa.js";import{xc as g1}from"./chunk-9qxch6sy.js";import{$d as I4,Hd as M2,Nc as D2,Rd as o0,Sd as q0,Zd as T4,_d as q4,ce as L1,fd as d$,fe as D4,jd as U4,ke as b2,le as M4,me as L4,ne as g}from"./chunk-6jjpj5ge.js";import{Le as L2,Se as A2,Te as j2}from"./chunk-s14zayxp.js";import{mf as b3,qf as T3,rf as q3,sf as I3,tf as C3,uf as p4,vf as R3,wf as E3}from"./chunk-b5cz00mt.js";import{Vf as Z5,Zf as LO,bg as k$,eg as tO}from"./chunk-acxyw1ej.js";import{fg as l1}from"./chunk-x6k5ye1z.js";import{yg as N2}from"./chunk-pm163dfm.js";import{Ag as D1}from"./chunk-cfxs7jdk.js";import{$g as x2,Jg as J5,Mg as $3,Qg as N1,Rg as B1,Vg as L5,Yg as O0,Zg as x1,bh as O$}from"./chunk-a1y938pg.js";import{uh as h$,vh as B2}from"./chunk-1cy4ab77.js";import{Ah as n0,zh as q$}from"./chunk-8yh4mn8a.js";import{Ai as F2,Ci as _2,Ih as B4,Pi as I$,Uh as R$,Ui as _1,ii as K2,li as w2,ni as H2,oi as W2,pi as g$,qi as v$,ri as W$,xi as U2}from"./chunk-ftk0ytf8.js";import{Zi as KO}from"./chunk-b22ab7yw.js";import{Aj as x4,xj as a1}from"./chunk-m2x6pb4f.js";import{Ej as OO,Gj as h,Ij as z,Jj as sO,Lj as GO}from"./chunk-saz6mwpq.js";import{Qj as P0}from"./chunk-xhwdac1j.js";import{Sj as S$,Tj as z2,Vj as P$,Wj as G2}from"./chunk-0eajnhrj.js";import{Xj as i0}from"./chunk-bzwxh6nq.js";import{ck as e4}from"./chunk-asgmmaec.js";import{Hk as A$,dk as n1,xk as WO,zk as k1}from"./chunk-ed2hdrwe.js";import{Jk as t4}from"./chunk-gmpsfkgg.js";var F8={port:{type:"number",describe:"Port to listen on (0 for auto)",default:0},hostname:{type:"string",describe:"Hostname to listen on",default:"127.0.0.1"},cors:{type:"array",describe:"Additional domains to allow for CORS",default:[]}};function _8(O){return{port:O.port??0,hostname:O.hostname??"127.0.0.1",cors:O.cors??[]}}import{existsSync as Z$,readFileSync as C1}from"node:fs";import{createServer as c6}from"node:http";import{networkInterfaces as l6}from"node:os";import{dirname as i6,extname as n6,join as f0}from"node:path";import{fileURLToPath as a6}from"node:url";import{brotliCompressSync as o6,gzipSync as t6,constants as s6}from"node:zlib";import{Hono as r6}from"hono";import{cors as e6}from"hono/cors";import{WebSocketServer as O8}from"ws";var l0=OO("Service"),y5=30000,m5=new Set(["completed","failed","cancelled","interrupted"]);class z4{dispatch;store;tickMs;timer;unsubscribeBus;ticking=!1;inFlight=new Set;constructor(O){this.dispatch=O.dispatch,this.store=O.store??H$.getInstance(),this.tickMs=O.tickMs??y5}start(){if(this.timer)return;l0.info("[TaskScheduler] Starting scheduler tick loop"),this.timer=setInterval(()=>{this.tick()},this.tickMs),this.timer.unref?.(),this.unsubscribeBus=m.subscribe((O)=>{if(O.type!=="task.status")return;let $=O.properties.taskStatus;if(typeof $!=="string"||!m5.has($))return;this.recordTerminalStatus(O.sessionId,$,typeof O.properties.taskStatusReason==="string"?O.properties.taskStatusReason:void 0)}),this.tick()}stop(){if(this.timer)clearInterval(this.timer),this.timer=void 0,this.unsubscribeBus?.(),this.unsubscribeBus=void 0,l0.info("[TaskScheduler] Stopped scheduler tick loop")}async tick(O=new Date){if(this.ticking)return;this.ticking=!0;try{let $=await this.store.list();for(let Z of $)await this.evaluate(Z,O)}catch($){l0.warn("[TaskScheduler] Tick failed:",$)}finally{this.ticking=!1}}async evaluate(O,$){if(!O.enabled)return;if(this.inFlight.has(O.id))return;if(O.expiresAt&&new Date(O.expiresAt).getTime()<=$.getTime()){await this.store.update(O.id,{enabled:!1,nextRunAt:null}),l0.info(`[TaskScheduler] Schedule ${O.id} expired; disabled`);return}if(!O.nextRunAt)return;if(!(new Date(O.nextRunAt).getTime()<=$.getTime()))return;await this.fire(O,$)}async fire(O,$=new Date,Z={}){if(this.inFlight.has(O.id))throw Error(`Schedule ${O.id} is already dispatching`);this.inFlight.add(O.id);let J=$.toISOString();try{let Y=await this.dispatch({prompt:O.prompt,title:O.title??g5(O),sourceProjectPath:O.projectPath,isolation:O.dispatch.isolation??"worktree",permissionMode:O.dispatch.permissionMode??"default",modelId:O.dispatch.modelId,reasoningEffort:O.dispatch.reasoningEffort,serviceTier:O.dispatch.serviceTier,responseVerbosity:O.dispatch.responseVerbosity,communicationStyle:O.dispatch.communicationStyle}),X=O.trigger.kind==="once"?null:Z.manual?O.nextRunAt?new Date(O.nextRunAt):null:V4(O.trigger,$,$);await this.store.update(O.id,{lastRunAt:J,lastRunSessionId:Y.session.sessionId,lastStatus:Y.status,lastError:void 0,runCount:O.runCount+1,nextRunAt:X?X.toISOString():null,enabled:O.trigger.kind==="once"?!1:O.enabled}),m.publish({sessionId:Y.session.sessionId,projectPath:O.projectPath},"schedule.fired",{scheduleId:O.id,firedAt:J,sessionId:Y.session.sessionId,runId:Y.runId,status:Y.status}),l0.info(`[TaskScheduler] Fired schedule ${O.id} -> session ${Y.session.sessionId} (${Y.status})`)}catch(Y){let X=Y instanceof Error?Y.message:String(Y);l0.warn(`[TaskScheduler] Schedule ${O.id} dispatch failed:`,Y);let G=O.trigger.kind==="once"?null:Z.manual?O.nextRunAt?new Date(O.nextRunAt):null:V4(O.trigger,$,$);await this.store.update(O.id,{lastRunAt:J,lastStatus:"error",lastError:X,nextRunAt:G?G.toISOString():null,enabled:O.trigger.kind==="once"?!1:O.enabled})}finally{this.inFlight.delete(O.id)}}async recordTerminalStatus(O,$,Z){let Y=(await this.store.list()).find((X)=>X.lastRunSessionId===O);if(!Y)return;await this.store.update(Y.id,{lastStatus:$,...Z?{lastError:Z}:{lastError:void 0}})}}function g5(O){return`Scheduled: ${O.prompt.trim().replace(/\s+/g," ").slice(0,60)}`}class wO extends Error{code;statusCode;details;constructor(O,$,Z=500,J){super($);this.code=O;this.statusCode=Z;this.details=J;this.name="BladeServerError"}toObject(){return{error:{code:this.code,message:this.message,...this.details?{details:this.details}:{}}}}}class c extends wO{constructor(O,$){super("NOT_FOUND",$?`${O} not found: ${$}`:`${O} not found`,404)}}class F extends wO{constructor(O){super("BAD_REQUEST",O,400)}}class v extends wO{constructor(O){super("CONFLICT",O,409)}}class eO extends wO{constructor(O,$){super("TOO_MANY_REQUESTS",O,429,$)}}class MO extends wO{constructor(O="Server is shutting down"){super("SERVICE_UNAVAILABLE",O,503)}}class b0 extends wO{constructor(O){super("SESSION_WORKSPACE_UNAVAILABLE","This session workspace is no longer available",409,{reason:O})}}class lO extends wO{constructor(){super("AMBIGUOUS_SESSION","Multiple workspaces contain this session ID; projectPath is required",409)}}class zO extends wO{constructor(O="Internal server error"){super("INTERNAL_ERROR",O,500)}}var j8=z.Object({error:z.Object({code:z.String(),message:z.String(),details:z.Optional(z.Record(z.String(),z.Unknown()))})});import{Hono as v5}from"hono";var G4=OO("Service"),p5=z.Object({updates:z.Record(z.String(),z.Any()),options:z.Optional(z.Object({scope:z.Optional(GO(["local","project","global"])),immediate:z.Optional(z.Boolean())}))});function u5(O){return{currentModelId:O.currentModelId,permissionMode:O.permissionMode,language:O.language,codeTheme:O.codeTheme,uiTheme:O.uiTheme,autoSaveSessions:O.autoSaveSessions,notifyBuild:O.notifyBuild,notifyErrors:O.notifyErrors,notifySounds:O.notifySounds,privacyTelemetry:O.privacyTelemetry,privacyCrash:O.privacyCrash,agentTeamsEnabled:O.agentTeamsEnabled===!0,communicationStyle:O.communicationStyle,maxConcurrentTasks:O.maxConcurrentTasks,maxQueuedTasks:O.maxQueuedTasks,maxQueuedTaskBytes:O.maxQueuedTaskBytes,maxResidentSessionRuntimes:O.maxResidentSessionRuntimes,sessionRuntimeIdleMs:O.sessionRuntimeIdleMs,maxResidentSessionProjections:O.maxResidentSessionProjections,sessionProjectionIdleMs:O.sessionProjectionIdleMs}}var U$=()=>{let O=new v5;return O.get("/",async($)=>{try{let Z=LO();return $.json(Z?u5(Z):{})}catch(Z){return G4.error("[ConfigRoutes] Failed to get config:",Z),$.json({})}}),O.put("/",async($)=>{try{let Z=await $.req.json(),J=h(p5,Z);if(!J.success)throw new F("Invalid config update format");let{updates:Y,options:X}=J.data;return await tO().updateConfig(Y,X),$.json({success:!0,updates:Y})}catch(Z){if(Z instanceof W$)throw new F(Z.message);throw G4.error("[ConfigRoutes] Failed to update config:",Z),Z}}),O.get("/permissions",async($)=>{try{let Z=LO();return $.json(Z?.permissions||{})}catch(Z){return G4.error("[ConfigRoutes] Failed to get permissions:",Z),$.json({})}}),O};import{Hono as d5}from"hono";import{streamSSE as c5}from"hono/streaming";function F$(O){let $="";if(O.id!==void 0)$+=`id: ${O.id}
1
+ import{e as B3,f as x3,g as f3,h as r0,i as S3}from"./chunk-j5e589we.js";import{j as o1}from"./chunk-870szc6v.js";import{w as t0,x as d2,y as T1,z as c1}from"./chunk-mmwqe49e.js";import{A as c2,B as l2,C as i2,D as m0}from"./chunk-vjvw3v6b.js";import{E as h2,F as _$,G as N$,H as B$,I as G0,J as x$}from"./chunk-22py5y1p.js";import{$ as C2,Aa as N3,Da as U5,Ia as i3,N as m1,O as l3,R as T2,S as O1,T as i4,V as i1,W as p$,X as A4,Y as j4,Z as W0,_ as I2,aa as M$,ba as F1,da as S2,ea as P2,fa as b4,ga as N0,ha as B0,ka as C4,la as R4,ma as Q5,na as k2,oa as J2,pa as Z3,qa as J3,ra as Q3,sa as Y3,ta as X3,ua as V3,va as z3,wa as G3,xa as K3}from"./chunk-e613h191.js";import{Pa as E$,Va as iO}from"./chunk-74vmjngm.js";import{$a as E2,Ab as $$,Ya as Z2,_a as R2,ab as f2,gb as V4,jb as a3,kb as n4,lb as y2,mb as m2,nb as o3,ob as t3,pb as a4,qb as s3,rb as v0,sb as M3,tb as L3,ub as A3,vb as g2,wb as v2,xb as p2,yb as u2,zb as H$}from"./chunk-whxkwaz1.js";import{Ob as nO,Pb as i,Rb as m,Sb as q2,bc as _4,mc as g0}from"./chunk-3t655nhk.js";import{xc as g1}from"./chunk-9qxch6sy.js";import{$d as I4,Hd as M2,Nc as D2,Rd as o0,Sd as q0,Zd as T4,_d as q4,ce as L1,fd as d$,fe as D4,jd as U4,ke as b2,le as M4,me as L4,ne as g}from"./chunk-ayqqhefz.js";import{Le as L2,Se as A2,Te as j2}from"./chunk-s14zayxp.js";import{mf as b3,qf as T3,rf as q3,sf as I3,tf as C3,uf as p4,vf as R3,wf as E3}from"./chunk-b5cz00mt.js";import{Vf as Z5,Zf as LO,bg as k$,eg as tO}from"./chunk-dgypy6yt.js";import{fg as l1}from"./chunk-x6k5ye1z.js";import{yg as N2}from"./chunk-pm163dfm.js";import{Ag as D1}from"./chunk-np5t59fa.js";import{$g as x2,Jg as J5,Mg as $3,Qg as N1,Rg as B1,Vg as L5,Yg as O0,Zg as x1,bh as O$}from"./chunk-34y4z9ns.js";import{uh as h$,vh as B2}from"./chunk-1cy4ab77.js";import{Ah as n0,zh as q$}from"./chunk-3m8949fr.js";import{Ai as F2,Ci as _2,Ih as B4,Pi as I$,Uh as R$,Ui as _1,ii as K2,li as w2,ni as H2,oi as W2,pi as g$,qi as v$,ri as W$,xi as U2}from"./chunk-nr5s7qtp.js";import{Zi as KO}from"./chunk-b22ab7yw.js";import{Aj as x4,xj as a1}from"./chunk-m2x6pb4f.js";import{Ej as OO,Gj as h,Ij as z,Jj as sO,Lj as GO}from"./chunk-saz6mwpq.js";import{Qj as P0}from"./chunk-xhwdac1j.js";import{Sj as S$,Tj as z2,Vj as P$,Wj as G2}from"./chunk-0eajnhrj.js";import{Xj as i0}from"./chunk-c1331rdc.js";import{ck as e4}from"./chunk-asgmmaec.js";import{Hk as A$,dk as n1,xk as WO,zk as k1}from"./chunk-ed2hdrwe.js";import{Jk as t4}from"./chunk-gmpsfkgg.js";var F8={port:{type:"number",describe:"Port to listen on (0 for auto)",default:0},hostname:{type:"string",describe:"Hostname to listen on",default:"127.0.0.1"},cors:{type:"array",describe:"Additional domains to allow for CORS",default:[]}};function _8(O){return{port:O.port??0,hostname:O.hostname??"127.0.0.1",cors:O.cors??[]}}import{existsSync as Z$,readFileSync as C1}from"node:fs";import{createServer as c6}from"node:http";import{networkInterfaces as l6}from"node:os";import{dirname as i6,extname as n6,join as f0}from"node:path";import{fileURLToPath as a6}from"node:url";import{brotliCompressSync as o6,gzipSync as t6,constants as s6}from"node:zlib";import{Hono as r6}from"hono";import{cors as e6}from"hono/cors";import{WebSocketServer as O8}from"ws";var l0=OO("Service"),y5=30000,m5=new Set(["completed","failed","cancelled","interrupted"]);class z4{dispatch;store;tickMs;timer;unsubscribeBus;ticking=!1;inFlight=new Set;constructor(O){this.dispatch=O.dispatch,this.store=O.store??H$.getInstance(),this.tickMs=O.tickMs??y5}start(){if(this.timer)return;l0.info("[TaskScheduler] Starting scheduler tick loop"),this.timer=setInterval(()=>{this.tick()},this.tickMs),this.timer.unref?.(),this.unsubscribeBus=m.subscribe((O)=>{if(O.type!=="task.status")return;let $=O.properties.taskStatus;if(typeof $!=="string"||!m5.has($))return;this.recordTerminalStatus(O.sessionId,$,typeof O.properties.taskStatusReason==="string"?O.properties.taskStatusReason:void 0)}),this.tick()}stop(){if(this.timer)clearInterval(this.timer),this.timer=void 0,this.unsubscribeBus?.(),this.unsubscribeBus=void 0,l0.info("[TaskScheduler] Stopped scheduler tick loop")}async tick(O=new Date){if(this.ticking)return;this.ticking=!0;try{let $=await this.store.list();for(let Z of $)await this.evaluate(Z,O)}catch($){l0.warn("[TaskScheduler] Tick failed:",$)}finally{this.ticking=!1}}async evaluate(O,$){if(!O.enabled)return;if(this.inFlight.has(O.id))return;if(O.expiresAt&&new Date(O.expiresAt).getTime()<=$.getTime()){await this.store.update(O.id,{enabled:!1,nextRunAt:null}),l0.info(`[TaskScheduler] Schedule ${O.id} expired; disabled`);return}if(!O.nextRunAt)return;if(!(new Date(O.nextRunAt).getTime()<=$.getTime()))return;await this.fire(O,$)}async fire(O,$=new Date,Z={}){if(this.inFlight.has(O.id))throw Error(`Schedule ${O.id} is already dispatching`);this.inFlight.add(O.id);let J=$.toISOString();try{let Y=await this.dispatch({prompt:O.prompt,title:O.title??g5(O),sourceProjectPath:O.projectPath,isolation:O.dispatch.isolation??"worktree",permissionMode:O.dispatch.permissionMode??"default",modelId:O.dispatch.modelId,reasoningEffort:O.dispatch.reasoningEffort,serviceTier:O.dispatch.serviceTier,responseVerbosity:O.dispatch.responseVerbosity,communicationStyle:O.dispatch.communicationStyle}),X=O.trigger.kind==="once"?null:Z.manual?O.nextRunAt?new Date(O.nextRunAt):null:V4(O.trigger,$,$);await this.store.update(O.id,{lastRunAt:J,lastRunSessionId:Y.session.sessionId,lastStatus:Y.status,lastError:void 0,runCount:O.runCount+1,nextRunAt:X?X.toISOString():null,enabled:O.trigger.kind==="once"?!1:O.enabled}),m.publish({sessionId:Y.session.sessionId,projectPath:O.projectPath},"schedule.fired",{scheduleId:O.id,firedAt:J,sessionId:Y.session.sessionId,runId:Y.runId,status:Y.status}),l0.info(`[TaskScheduler] Fired schedule ${O.id} -> session ${Y.session.sessionId} (${Y.status})`)}catch(Y){let X=Y instanceof Error?Y.message:String(Y);l0.warn(`[TaskScheduler] Schedule ${O.id} dispatch failed:`,Y);let G=O.trigger.kind==="once"?null:Z.manual?O.nextRunAt?new Date(O.nextRunAt):null:V4(O.trigger,$,$);await this.store.update(O.id,{lastRunAt:J,lastStatus:"error",lastError:X,nextRunAt:G?G.toISOString():null,enabled:O.trigger.kind==="once"?!1:O.enabled})}finally{this.inFlight.delete(O.id)}}async recordTerminalStatus(O,$,Z){let Y=(await this.store.list()).find((X)=>X.lastRunSessionId===O);if(!Y)return;await this.store.update(Y.id,{lastStatus:$,...Z?{lastError:Z}:{lastError:void 0}})}}function g5(O){return`Scheduled: ${O.prompt.trim().replace(/\s+/g," ").slice(0,60)}`}class wO extends Error{code;statusCode;details;constructor(O,$,Z=500,J){super($);this.code=O;this.statusCode=Z;this.details=J;this.name="BladeServerError"}toObject(){return{error:{code:this.code,message:this.message,...this.details?{details:this.details}:{}}}}}class c extends wO{constructor(O,$){super("NOT_FOUND",$?`${O} not found: ${$}`:`${O} not found`,404)}}class F extends wO{constructor(O){super("BAD_REQUEST",O,400)}}class v extends wO{constructor(O){super("CONFLICT",O,409)}}class eO extends wO{constructor(O,$){super("TOO_MANY_REQUESTS",O,429,$)}}class MO extends wO{constructor(O="Server is shutting down"){super("SERVICE_UNAVAILABLE",O,503)}}class b0 extends wO{constructor(O){super("SESSION_WORKSPACE_UNAVAILABLE","This session workspace is no longer available",409,{reason:O})}}class lO extends wO{constructor(){super("AMBIGUOUS_SESSION","Multiple workspaces contain this session ID; projectPath is required",409)}}class zO extends wO{constructor(O="Internal server error"){super("INTERNAL_ERROR",O,500)}}var j8=z.Object({error:z.Object({code:z.String(),message:z.String(),details:z.Optional(z.Record(z.String(),z.Unknown()))})});import{Hono as v5}from"hono";var G4=OO("Service"),p5=z.Object({updates:z.Record(z.String(),z.Any()),options:z.Optional(z.Object({scope:z.Optional(GO(["local","project","global"])),immediate:z.Optional(z.Boolean())}))});function u5(O){return{currentModelId:O.currentModelId,permissionMode:O.permissionMode,language:O.language,codeTheme:O.codeTheme,uiTheme:O.uiTheme,autoSaveSessions:O.autoSaveSessions,notifyBuild:O.notifyBuild,notifyErrors:O.notifyErrors,notifySounds:O.notifySounds,privacyTelemetry:O.privacyTelemetry,privacyCrash:O.privacyCrash,agentTeamsEnabled:O.agentTeamsEnabled===!0,communicationStyle:O.communicationStyle,maxConcurrentTasks:O.maxConcurrentTasks,maxQueuedTasks:O.maxQueuedTasks,maxQueuedTaskBytes:O.maxQueuedTaskBytes,maxResidentSessionRuntimes:O.maxResidentSessionRuntimes,sessionRuntimeIdleMs:O.sessionRuntimeIdleMs,maxResidentSessionProjections:O.maxResidentSessionProjections,sessionProjectionIdleMs:O.sessionProjectionIdleMs}}var U$=()=>{let O=new v5;return O.get("/",async($)=>{try{let Z=LO();return $.json(Z?u5(Z):{})}catch(Z){return G4.error("[ConfigRoutes] Failed to get config:",Z),$.json({})}}),O.put("/",async($)=>{try{let Z=await $.req.json(),J=h(p5,Z);if(!J.success)throw new F("Invalid config update format");let{updates:Y,options:X}=J.data;return await tO().updateConfig(Y,X),$.json({success:!0,updates:Y})}catch(Z){if(Z instanceof W$)throw new F(Z.message);throw G4.error("[ConfigRoutes] Failed to update config:",Z),Z}}),O.get("/permissions",async($)=>{try{let Z=LO();return $.json(Z?.permissions||{})}catch(Z){return G4.error("[ConfigRoutes] Failed to get permissions:",Z),$.json({})}}),O};import{Hono as d5}from"hono";import{streamSSE as c5}from"hono/streaming";function F$(O){let $="";if(O.id!==void 0)$+=`id: ${O.id}
2
2
  `;if(O.event!==void 0)$+=`event: ${O.event}
3
3
  `;for(let Z of O.data.split(/\r\n|\r|\n/))$+=`data: ${Z}
4
4
  `;if(O.retry!==void 0)$+=`retry: ${O.retry}
@@ -1,4 +1,4 @@
1
- import{Vf as N}from"./chunk-acxyw1ej.js";import{Ah as $}from"./chunk-8yh4mn8a.js";import{Zi as _}from"./chunk-b22ab7yw.js";import{Cj as Y,Ej as Z}from"./chunk-saz6mwpq.js";function X(){if(process.stdin.isTTY&&typeof process.stdin.setRawMode==="function")try{process.stdin.setRawMode(!1)}catch{}if(!process.stdout.isTTY)return;process.stdout.write("\x1B[<u"),process.stdout.write("\x1B[>4;0m"),process.stdout.write("\x1B[?2004l"),process.stdout.write("\x1B[?1004l"),process.stdout.write("\x1B[?1l\x1B>"),process.stdout.write("\x1B[?25h"),process.stdout.write("\x1B[0m")}var z=Z("Service");function E(b){switch(b){case"SIGINT":return"ctrl_c";case"esc":return"esc";case"uncaughtException":case"unhandledRejection":return"error";case"SIGTERM":case"normal":default:return"user_exit"}}class B{static instance=null;cleanupHandlers=[];isShuttingDown=!1;initialized=!1;lastSigintTime=0;SIGINT_DOUBLE_CLICK_WINDOW=3000;constructor(){}static getInstance(){if(!B.instance)B.instance=new B;return B.instance}initialize(){if(this.initialized){z.debug("[GracefulShutdown] 已初始化,跳过重复初始化");return}process.on("uncaughtException",(b)=>{this.handleFatalError("uncaughtException",b)}),process.on("unhandledRejection",(b)=>{let q=b instanceof Error?b:Error(String(b));this.handleFatalError("unhandledRejection",q)}),process.on("SIGTERM",()=>{z.info("[GracefulShutdown] 收到 SIGTERM 信号"),this.shutdown("SIGTERM",0)}),process.on("SIGINT",()=>{if(!process.stdin.isTTY||!process.stdout.isTTY){this.shutdown("SIGINT",0);return}let b=Date.now();if(b-this.lastSigintTime<this.SIGINT_DOUBLE_CLICK_WINDOW)z.info("[GracefulShutdown] 收到第二次 SIGINT 信号,执行退出"),this.shutdown("SIGINT",0);else z.info("[GracefulShutdown] 收到第一次 SIGINT 信号,再按一次退出"),this.lastSigintTime=b,console.log(`
1
+ import{Vf as N}from"./chunk-dgypy6yt.js";import{Ah as $}from"./chunk-3m8949fr.js";import{Zi as _}from"./chunk-b22ab7yw.js";import{Cj as Y,Ej as Z}from"./chunk-saz6mwpq.js";function X(){if(process.stdin.isTTY&&typeof process.stdin.setRawMode==="function")try{process.stdin.setRawMode(!1)}catch{}if(!process.stdout.isTTY)return;process.stdout.write("\x1B[<u"),process.stdout.write("\x1B[>4;0m"),process.stdout.write("\x1B[?2004l"),process.stdout.write("\x1B[?1004l"),process.stdout.write("\x1B[?1l\x1B>"),process.stdout.write("\x1B[?25h"),process.stdout.write("\x1B[0m")}var z=Z("Service");function E(b){switch(b){case"SIGINT":return"ctrl_c";case"esc":return"esc";case"uncaughtException":case"unhandledRejection":return"error";case"SIGTERM":case"normal":default:return"user_exit"}}class B{static instance=null;cleanupHandlers=[];isShuttingDown=!1;initialized=!1;lastSigintTime=0;SIGINT_DOUBLE_CLICK_WINDOW=3000;constructor(){}static getInstance(){if(!B.instance)B.instance=new B;return B.instance}initialize(){if(this.initialized){z.debug("[GracefulShutdown] 已初始化,跳过重复初始化");return}process.on("uncaughtException",(b)=>{this.handleFatalError("uncaughtException",b)}),process.on("unhandledRejection",(b)=>{let q=b instanceof Error?b:Error(String(b));this.handleFatalError("unhandledRejection",q)}),process.on("SIGTERM",()=>{z.info("[GracefulShutdown] 收到 SIGTERM 信号"),this.shutdown("SIGTERM",0)}),process.on("SIGINT",()=>{if(!process.stdin.isTTY||!process.stdout.isTTY){this.shutdown("SIGINT",0);return}let b=Date.now();if(b-this.lastSigintTime<this.SIGINT_DOUBLE_CLICK_WINDOW)z.info("[GracefulShutdown] 收到第二次 SIGINT 信号,执行退出"),this.shutdown("SIGINT",0);else z.info("[GracefulShutdown] 收到第一次 SIGINT 信号,再按一次退出"),this.lastSigintTime=b,console.log(`
2
2
  再按一次 Ctrl+C 退出
3
3
  `)}),this.initialized=!0,z.debug("[GracefulShutdown] 全局错误处理器已初始化")}registerCleanup(b){return this.cleanupHandlers.push(b),z.debug(`[GracefulShutdown] 注册清理函数,当前共 ${this.cleanupHandlers.length} 个`),()=>{let q=this.cleanupHandlers.indexOf(b);if(q!==-1)this.cleanupHandlers.splice(q,1),z.debug(`[GracefulShutdown] 取消注册清理函数,剩余 ${this.cleanupHandlers.length} 个`)}}handleFatalError(b,q){if(this.isShuttingDown){console.error(`[GracefulShutdown] 退出过程中发生额外错误 (${b}):`,q);return}if(console.error(""),console.error("═".repeat(60)),console.error(`Uncaught error (${b})`),console.error("═".repeat(60)),console.error(""),console.error("错误信息:",q.message),console.error(""),q.stack)console.error("堆栈跟踪:"),console.error(q.stack);console.error(""),console.error("═".repeat(60)),console.error(""),this.shutdown(b,1)}async shutdown(b,q=0){if(this.isShuttingDown){z.debug("[GracefulShutdown] 已在退出过程中,跳过重复退出");return}this.isShuttingDown=!0;try{N().command.actions.abort("process-shutdown")}catch(A){z.warn("[GracefulShutdown] Failed to abort the active command",A)}z.info(`[GracefulShutdown] 开始优雅退出 (原因: ${b})`);let Q=setTimeout(()=>{X(),process.exit(q)},5000);Q.unref?.();let U=4000,K;try{await Promise.race([this.runCleanupHandlers(),new Promise((A,J)=>{K=setTimeout(()=>{J(Error(`清理超时 (${U}ms)`))},U),K.unref?.()})])}catch(A){console.error("[GracefulShutdown] 清理过程中发生错误:",A)}finally{if(K)clearTimeout(K)}try{let A=$.getInstance(),J=N(),V=J.session?.sessionId||"unknown",W=J.session?.workspaceRoot||_();if(A.isEnabled(W,V)){let v=J.config?.config?.permissionMode||"default";await A.executeSessionEndHooks(E(b),{projectDir:W,sessionId:V,permissionMode:v})}}catch(A){console.error("[GracefulShutdown] SessionEnd hooks 执行失败:",A)}try{await Y()}catch{}clearTimeout(Q),X(),setTimeout(()=>{process.exit(q)},100)}async runCleanupHandlers(){let b=[...this.cleanupHandlers].reverse();for(let q of b)try{let F=q();if(F instanceof Promise)await F}catch(F){console.error("[GracefulShutdown] 清理函数执行失败:",F)}}isExiting(){return this.isShuttingDown}reset(){this.isShuttingDown=!1,this.cleanupHandlers=[],this.initialized=!1}}var O=()=>{return B.getInstance()},y=(b)=>{return O().registerCleanup(b)},j=()=>{O().initialize()},C=(b=0)=>{O().shutdown("normal",b)};
4
4
  export{O as Df,y as Ef,j as Ff,C as Gf};
@@ -1 +1 @@
1
- import{$g as i,Tg as a,Ug as b,Vg as c,Wg as d,Xg as e,Yg as f,Zg as g,_g as h,ah as j,bh as k}from"./chunk-a1y938pg.js";import"./chunk-kehgewqh.js";import"./chunk-kkzznz4w.js";import"./chunk-1cy4ab77.js";import"./chunk-7ajvrtb3.js";import"./chunk-8yh4mn8a.js";import"./chunk-ys8gysg8.js";import"./chunk-ftk0ytf8.js";import"./chunk-b22ab7yw.js";import"./chunk-amabfzc8.js";import"./chunk-m2x6pb4f.js";import"./chunk-saz6mwpq.js";import"./chunk-xhwdac1j.js";import"./chunk-0eajnhrj.js";import"./chunk-bzwxh6nq.js";import"./chunk-asgmmaec.js";import"./chunk-ed2hdrwe.js";import"./chunk-gmpsfkgg.js";export{g as withWorkspaceAgentResources,i as snapshotWorkspaceAgentResources,f as resolveWorkspaceAgentResources,k as resetWorkspaceAgentResources,d as refreshWorkspaceCommunicationStyles,h as getWorkspaceAgentResourceCacheStats,j as createEmptySessionAgentResources,e as configureInvocationPluginDirs,c as WorkspaceAgentResourceCapacityError,a as MAX_RESIDENT_WORKSPACE_AGENT_RESOURCES,b as MAX_ACTIVE_WORKSPACE_AGENT_RESOURCES};
1
+ import{$g as i,Tg as a,Ug as b,Vg as c,Wg as d,Xg as e,Yg as f,Zg as g,_g as h,ah as j,bh as k}from"./chunk-34y4z9ns.js";import"./chunk-kehgewqh.js";import"./chunk-kkzznz4w.js";import"./chunk-1cy4ab77.js";import"./chunk-7ajvrtb3.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 withWorkspaceAgentResources,i as snapshotWorkspaceAgentResources,f as resolveWorkspaceAgentResources,k as resetWorkspaceAgentResources,d as refreshWorkspaceCommunicationStyles,h as getWorkspaceAgentResourceCacheStats,j as createEmptySessionAgentResources,e as configureInvocationPluginDirs,c as WorkspaceAgentResourceCapacityError,a as MAX_RESIDENT_WORKSPACE_AGENT_RESOURCES,b as MAX_ACTIVE_WORKSPACE_AGENT_RESOURCES};
@@ -1,4 +1,4 @@
1
- import{Ae as O1,Be as n2,Ce as d2,De as J1,Ee as Q1,Fe as i2,Ge as Y1,He as V0,Ie as Z1,Je as G1,Le as r2,Se as o2,Te as Q0,_e as I_,af as V1,cf as a2,df as t2,ef as L1,ff as s2,ue as l2,ve as e,we as p2,xe as W1,ye as c2,ze as v}from"./chunk-s14zayxp.js";import{xg as h_}from"./chunk-pm163dfm.js";import{sh as l_}from"./chunk-1cy4ab77.js";import{Zi as f1}from"./chunk-b22ab7yw.js";import{Aj as E_,wj as u2,xj as h2,yj as F_,zj as r_}from"./chunk-m2x6pb4f.js";import{Ej as $0}from"./chunk-saz6mwpq.js";import{Rj as P_,Uj as u_}from"./chunk-0eajnhrj.js";import{Xj as __}from"./chunk-bzwxh6nq.js";import{Ak as P,Bk as m,Ck as E1,Dk as F1,Ek as N_,Fk as z1,Gk as k1,Hk as L_,dk as l,nk as r,ok as p,pk as m2,qk as c,rk as n,sk as v2,tk as Z0,uk as $1,vk as P2,wk as H_,xk as G0,yk as g_,zk as T}from"./chunk-ed2hdrwe.js";import{readdir as D_,readFile as Z_,rm as R_,stat as L0}from"node:fs/promises";import*as N from"node:path";import{nanoid as i}from"nanoid";import{createHash as G4,randomUUID as V4}from"node:crypto";import*as $_ from"node:fs/promises";import*as n_ from"node:path";import L4 from"proper-lockfile";function nX(_){return Object.freeze({kind:"local",root:_})}function dX(_,X){let $=r(X);if(p($.collisionIdentity)!==_)throw Error("ACP remote workspace durable state is invalid");return Object.freeze({kind:"acp-remote",root:_,descriptor:$})}function iX(_,X){return _.kind==="acp-remote"?`${_.kind}\x00${_.root}\x00${_.descriptor.exactIdentity}\x00${X}`:`${_.kind}\x00${_.root}\x00${X}`}async function G_(_,X){if(_.kind==="local")return X(H_(_.root));return c(_.root,($)=>X(String($),$))}async function rX(_,X,$){return G_(_,(W,J)=>$(J?{storageRoot:W,transcriptPath:m(J,X),inboxPath:F1(J,X),goalPath:z1(J,X),remoteScope:J}:{storageRoot:W,transcriptPath:P(_.root,X),inboxPath:E1(_.root,X),goalPath:N_(_.root,X)}))}import{execFileSync as W4}from"node:child_process";import{createHash as O4}from"node:crypto";import{readFileSync as J4}from"node:fs";var Q4=/^[a-f0-9]{64}$/;function D1(_){if(!_||typeof _!=="object")return!1;let X=_;return(X.platform==="linux"||X.platform==="darwin"||X.platform==="win32")&&typeof X.fingerprint==="string"&&Q4.test(X.fingerprint)}var R1={readFile:(_)=>J4(_,"utf8"),execFile:(_,X)=>W4(_,X,{encoding:"utf8",timeout:_==="powershell.exe"?3000:2000,windowsHide:!0})},Y4=(_)=>{try{return process.kill(_,0),!0}catch(X){return X instanceof Error&&"code"in X&&X.code==="EPERM"}};function F0(_,X){return{platform:_,fingerprint:O4("sha256").update(`${_}\x00${X}`).digest("hex")}}function Z4(_,X){let $=X.readFile(`/proc/${_}/stat`).trim(),W=$.lastIndexOf(")");if(W<0)throw Error("Invalid /proc process stat");let O=$.slice(W+2).split(/\s+/)[19];if(!O||!/^\d+$/.test(O))throw Error("Missing process start ticks");return O}function b_(_,X=process.platform,$=R1){if(!Number.isInteger(_)||_<=1)return;try{if(X==="linux")return F0(X,Z4(_,$));if(X==="darwin"){let W=$.execFile("ps",["-o","lstart=","-p",String(_)]).trim();return W?F0(X,W):void 0}if(X==="win32"){let W=`(Get-CimInstance Win32_Process -Filter "ProcessId = ${_}").CreationDate.ToUniversalTime().ToString('O')`,J=$.execFile("powershell.exe",["-NoProfile","-NonInteractive","-Command",W]).trim();return J?F0(X,J):void 0}}catch{return}return}function eX(_,X){return b_(_,X.platform)?.fingerprint===X.fingerprint}function _$(_,X,$=R1,W=Y4){if(!Number.isInteger(_)||_<=1)return!1;let J=b_(_,X.platform,$);if(J)return J.fingerprint===X.fingerprint;return!W(_)}var j1=1;function B4(_,X){let $=G4("sha256").update(X).digest("hex");return n_.join(H_(_),".locks",`${$}.lock`)}function A_(_,X){return _ instanceof Error&&"code"in _&&_.code===X}async function z0(_){try{let X=JSON.parse(await $_.readFile(_,"utf8"));if(X.version!==j1||typeof X.sessionId!=="string"||typeof X.ownerId!=="string"||!Number.isInteger(X.pid)||(X.pid??0)<=0||X.processIdentity!==void 0&&!D1(X.processIdentity)||typeof X.acquiredAt!=="string")return;return X}catch(X){if(A_(X,"ENOENT")||X instanceof SyntaxError)return;throw X}}async function w1(_){let X=await z0(_);if(X)return X;return await new Promise(($)=>setTimeout($,10)),z0(_)}function U4(_){try{return process.kill(_,0),!0}catch(X){return!A_(X,"ESRCH")}}async function x1(_,X){let $;try{return $=await $_.open(_,"wx",384),await $.writeFile(`${JSON.stringify(X)}
1
+ import{Ae as O1,Be as n2,Ce as d2,De as J1,Ee as Q1,Fe as i2,Ge as Y1,He as V0,Ie as Z1,Je as G1,Le as r2,Se as o2,Te as Q0,_e as I_,af as V1,cf as a2,df as t2,ef as L1,ff as s2,ue as l2,ve as e,we as p2,xe as W1,ye as c2,ze as v}from"./chunk-s14zayxp.js";import{xg as h_}from"./chunk-pm163dfm.js";import{sh as l_}from"./chunk-1cy4ab77.js";import{Zi as f1}from"./chunk-b22ab7yw.js";import{Aj as E_,wj as u2,xj as h2,yj as F_,zj as r_}from"./chunk-m2x6pb4f.js";import{Ej as $0}from"./chunk-saz6mwpq.js";import{Rj as P_,Uj as u_}from"./chunk-0eajnhrj.js";import{Xj as __}from"./chunk-c1331rdc.js";import{Ak as P,Bk as m,Ck as E1,Dk as F1,Ek as N_,Fk as z1,Gk as k1,Hk as L_,dk as l,nk as r,ok as p,pk as m2,qk as c,rk as n,sk as v2,tk as Z0,uk as $1,vk as P2,wk as H_,xk as G0,yk as g_,zk as T}from"./chunk-ed2hdrwe.js";import{readdir as D_,readFile as Z_,rm as R_,stat as L0}from"node:fs/promises";import*as N from"node:path";import{nanoid as i}from"nanoid";import{createHash as G4,randomUUID as V4}from"node:crypto";import*as $_ from"node:fs/promises";import*as n_ from"node:path";import L4 from"proper-lockfile";function nX(_){return Object.freeze({kind:"local",root:_})}function dX(_,X){let $=r(X);if(p($.collisionIdentity)!==_)throw Error("ACP remote workspace durable state is invalid");return Object.freeze({kind:"acp-remote",root:_,descriptor:$})}function iX(_,X){return _.kind==="acp-remote"?`${_.kind}\x00${_.root}\x00${_.descriptor.exactIdentity}\x00${X}`:`${_.kind}\x00${_.root}\x00${X}`}async function G_(_,X){if(_.kind==="local")return X(H_(_.root));return c(_.root,($)=>X(String($),$))}async function rX(_,X,$){return G_(_,(W,J)=>$(J?{storageRoot:W,transcriptPath:m(J,X),inboxPath:F1(J,X),goalPath:z1(J,X),remoteScope:J}:{storageRoot:W,transcriptPath:P(_.root,X),inboxPath:E1(_.root,X),goalPath:N_(_.root,X)}))}import{execFileSync as W4}from"node:child_process";import{createHash as O4}from"node:crypto";import{readFileSync as J4}from"node:fs";var Q4=/^[a-f0-9]{64}$/;function D1(_){if(!_||typeof _!=="object")return!1;let X=_;return(X.platform==="linux"||X.platform==="darwin"||X.platform==="win32")&&typeof X.fingerprint==="string"&&Q4.test(X.fingerprint)}var R1={readFile:(_)=>J4(_,"utf8"),execFile:(_,X)=>W4(_,X,{encoding:"utf8",timeout:_==="powershell.exe"?3000:2000,windowsHide:!0})},Y4=(_)=>{try{return process.kill(_,0),!0}catch(X){return X instanceof Error&&"code"in X&&X.code==="EPERM"}};function F0(_,X){return{platform:_,fingerprint:O4("sha256").update(`${_}\x00${X}`).digest("hex")}}function Z4(_,X){let $=X.readFile(`/proc/${_}/stat`).trim(),W=$.lastIndexOf(")");if(W<0)throw Error("Invalid /proc process stat");let O=$.slice(W+2).split(/\s+/)[19];if(!O||!/^\d+$/.test(O))throw Error("Missing process start ticks");return O}function b_(_,X=process.platform,$=R1){if(!Number.isInteger(_)||_<=1)return;try{if(X==="linux")return F0(X,Z4(_,$));if(X==="darwin"){let W=$.execFile("ps",["-o","lstart=","-p",String(_)]).trim();return W?F0(X,W):void 0}if(X==="win32"){let W=`(Get-CimInstance Win32_Process -Filter "ProcessId = ${_}").CreationDate.ToUniversalTime().ToString('O')`,J=$.execFile("powershell.exe",["-NoProfile","-NonInteractive","-Command",W]).trim();return J?F0(X,J):void 0}}catch{return}return}function eX(_,X){return b_(_,X.platform)?.fingerprint===X.fingerprint}function _$(_,X,$=R1,W=Y4){if(!Number.isInteger(_)||_<=1)return!1;let J=b_(_,X.platform,$);if(J)return J.fingerprint===X.fingerprint;return!W(_)}var j1=1;function B4(_,X){let $=G4("sha256").update(X).digest("hex");return n_.join(H_(_),".locks",`${$}.lock`)}function A_(_,X){return _ instanceof Error&&"code"in _&&_.code===X}async function z0(_){try{let X=JSON.parse(await $_.readFile(_,"utf8"));if(X.version!==j1||typeof X.sessionId!=="string"||typeof X.ownerId!=="string"||!Number.isInteger(X.pid)||(X.pid??0)<=0||X.processIdentity!==void 0&&!D1(X.processIdentity)||typeof X.acquiredAt!=="string")return;return X}catch(X){if(A_(X,"ENOENT")||X instanceof SyntaxError)return;throw X}}async function w1(_){let X=await z0(_);if(X)return X;return await new Promise(($)=>setTimeout($,10)),z0(_)}function U4(_){try{return process.kill(_,0),!0}catch(X){return!A_(X,"ESRCH")}}async function x1(_,X){let $;try{return $=await $_.open(_,"wx",384),await $.writeFile(`${JSON.stringify(X)}
2
2
  `,"utf8"),!0}catch(W){if(A_(W,"EEXIST"))return!1;if($)await $_.unlink(_).catch(()=>{return});throw W}finally{await $?.close().catch(()=>{return})}}class X_ extends Error{code="BLADE_SESSION_IN_USE";constructor(_){super(_?`Session is already active in another Blade process (PID ${_}). Stop that process or choose a different session.`:"Session is already active in another Blade process. Stop that process or choose a different session.");this.name="SessionInUseError"}}async function b1(_,X,$=!1){let W,J;try{J=await L4.lock(_,{realpath:!1,retries:$?{retries:50,minTimeout:10,maxTimeout:100,factor:1.2}:0,onCompromised:(Q)=>{W=Q}})}catch(Q){if(A_(Q,"ELOCKED"))throw new X_;throw Q}let O=()=>{if(W)throw W};try{O();let Q=await X(O);return O(),Q}finally{await J()}}class h{filePath;record;stateStorage;released=!1;constructor(_,X,$){this.filePath=_;this.record=X;this.stateStorage=$}static async acquireForStorage(_,X){if(X.kind==="local")return h.acquire(_,X.root);return G_(X,($,W)=>{if(!W||$!==X.root)throw Error("ACP remote session lease scope is invalid");return h.acquireRemote(_,W,X)})}static async acquire(_,X=f1()){return h.acquireAtPath(_,B4(X,_))}static async acquireRemote(_,X,$){let W=k1(X,_);try{await n(X,W)}catch(O){if(O.code!=="ENOENT")throw O}let J=await h.acquireAtPath(_,W);try{return await n(X,W),new h(W,J.record,$)}catch(O){throw await J.release(),O}}static async acquireAtPath(_,X){return await $_.mkdir(n_.dirname(X),{recursive:!0,mode:448}),b1(X,async($)=>{let W={version:j1,sessionId:_,ownerId:V4(),pid:process.pid,processIdentity:b_(process.pid),acquiredAt:new Date().toISOString()};if($(),await x1(X,W))return new h(X,W);let J=await w1(X);if(!J||J.sessionId!==_)throw new X_;if(U4(J.pid)){let O=J.processIdentity?b_(J.pid,J.processIdentity.platform):void 0;if(!O||O.fingerprint===J.processIdentity?.fingerprint)throw new X_(J.pid)}if($(),await $_.unlink(X).catch((O)=>{if(!A_(O,"ENOENT"))throw O}),$(),await x1(X,W))return new h(X,W);throw new X_((await w1(X))?.pid)})}async release(){if(this.released)return;let _=()=>b1(this.filePath,async(X)=>{if((await z0(this.filePath))?.ownerId!==this.record.ownerId)return;X(),await $_.unlink(this.filePath).catch((W)=>{if(!A_(W,"ENOENT"))throw W})},!0);if(this.stateStorage?.kind==="acp-remote")await G_(this.stateStorage,_);else await _();this.released=!0}}import{createHash as d_}from"node:crypto";import{constants as C_,promises as W_}from"node:fs";import Y_ from"node:path";import{Mutex as H4}from"async-mutex";var y1=128,S1=67108864,N4=24576,g1=65536,R0=1,h1=/^[a-f0-9]{64}$/,C4=/^[a-f0-9]{64}\.txt$/,l1=64,q4=new Set(["EBUSY","EAGAIN","EMFILE","ENFILE"]),o_=`
3
3
 
4
4
  ...[middle omitted; read the private prompt artifact for the complete request]...
@@ -1,2 +1,2 @@
1
- import{Xj as I}from"./chunk-bzwxh6nq.js";import{Jk as f}from"./chunk-gmpsfkgg.js";import*as j from"fs/promises";import*as S from"path";import X from"semver";import{ProxyAgent as R,fetch as k}from"undici";function x(){return process.env.HTTPS_PROXY||process.env.HTTP_PROXY||process.env.https_proxy||process.env.http_proxy}function L(){let z=x();if(z)try{return new R(z)}catch(q){console.warn(`[proxyFetch] Invalid proxy URL: ${z}`)}return}async function F(z,q,Z){let{timeout:W=30000,signal:J,...Q}=q;if(J?.aborted)throw new DOMException("The operation was aborted.","AbortError");let Y=L(),$=new AbortController,w=!1,y=setTimeout(()=>{w=!0,$.abort()},W),T=()=>$.abort();J?.addEventListener("abort",T);let D;try{let B={method:Q.method,headers:Q.headers,body:Q.body,signal:$.signal,dispatcher:Y};return D=await k(z.toString(),B),await Z(D)}catch(B){if(B instanceof Error&&B.name==="AbortError"){if(w)throw Error(`Request timeout after ${W}ms`);throw B}throw B}finally{if(clearTimeout(y),J?.removeEventListener("abort",T),$.abort(),D?.body&&!D.body.locked)await D.body.cancel().catch(()=>{return});await Y?.destroy?.().catch(()=>{return})}}var O="blade-code",G="https://cdn.jsdelivr.net/npm/blade-code@latest/CHANGELOG.md",H=S.join(process.env.HOME||process.env.USERPROFILE||".",".blade"),N=S.join(H,"version-cache.json"),_=3600000,g=`https://registry.npmjs.org/${O}/latest`,M=null;async function P(){try{if(process.env.BLADE_VERSION)return process.env.BLADE_VERSION;return I()}catch{return"unknown"}}async function b(){try{let z=await j.readFile(N,"utf-8"),q=JSON.parse(z);if(Date.now()-q.checkedAt<_)return q;return{...q,checkedAt:0}}catch{return null}}async function K(z){try{await j.mkdir(H,{recursive:!0,mode:493}),await j.writeFile(N,JSON.stringify(z,null,2))}catch{}}async function E(){try{return await F(g,{timeout:5000,headers:{Accept:"application/json"}},async(z)=>{if(!z.ok)return null;let q=await z.json();if(!q||typeof q!=="object"||!("version"in q))return null;return typeof q.version==="string"&&X.valid(q.version)?q.version:null})}catch{return null}}async function A(z=!1){let q=await P(),Z=G;if(q==="unknown")return{currentVersion:q,latestVersion:null,hasUpdate:!1,shouldPrompt:!1,releaseNotesUrl:Z,error:"Unable to determine current version"};let W=await b(),J=W?.skipUntilVersion,Q=null;if(!z&&W?.latestVersion&&W.checkedAt>0)Q=W.latestVersion;else if(Q=await E(),J=(await b())?.skipUntilVersion??J,Q)await K({latestVersion:Q,checkedAt:Date.now(),skipUntilVersion:J});else if(W?.latestVersion)await K({checkedAt:0,skipUntilVersion:J});if(!Q||!X.valid(Q))return{currentVersion:q,latestVersion:null,hasUpdate:!1,shouldPrompt:!1,releaseNotesUrl:Z,error:"Unable to check for updates"};if(X.lt(Q,q))Q=q,await K({latestVersion:Q,checkedAt:Date.now(),skipUntilVersion:J});let Y=X.gt(Q,q),$=Y;if(Y&&J)$=X.gt(Q,J);return{currentVersion:q,latestVersion:Q,hasUpdate:Y,shouldPrompt:$,releaseNotesUrl:Z}}async function V(z){let q=await b();await K({latestVersion:q?.latestVersion??z,checkedAt:q?.checkedAt||Date.now(),skipUntilVersion:z})}function v(){return`npm install -g ${O}@latest --registry https://registry.npmjs.org`}async function p(){let{spawn:z}=await import("child_process");return new Promise((q)=>{let Z=v(),W=z(Z,{stdio:"inherit",shell:!0});W.on("close",(J)=>{if(J===0)q({success:!0,message:"Upgrade successful! Please restart blade."});else q({success:!1,message:`Upgrade failed (exit code: ${J})`})}),W.on("error",(J)=>{q({success:!1,message:`Upgrade failed: ${J.message}`})})})}async function h(){try{let z=await b();if(!z?.latestVersion||!X.valid(z.latestVersion)||!z.checkedAt){if(!M)M=A(!0).then(()=>{return},()=>{return}).finally(()=>{M=null});return null}let q=await P();if(!X.valid(q)||!X.gt(z.latestVersion,q)||z.skipUntilVersion&&X.valid(z.skipUntilVersion)&&!X.gt(z.latestVersion,z.skipUntilVersion))return null;return{currentVersion:q,latestVersion:z.latestVersion,hasUpdate:!0,shouldPrompt:!0,releaseNotesUrl:G}}catch{return null}}
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}}
2
2
  export{A as k,V as l,v as m,p as n,h as o};
@@ -1,2 +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.6",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`}
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.8",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
2
  export{d as Xj,y as Yj,v as Zj,w as _j};
@@ -1 +1 @@
1
- import{a,b as i,c as l,d as m}from"./chunk-xmp1ve8a.js";import"./chunk-nh301gpr.js";import"./chunk-870szc6v.js";import"./chunk-87bd1w02.js";import"./chunk-fprmcxd6.js";import"./chunk-nneh4gkw.js";import"./chunk-n32pbwyk.js";import"./chunk-nad5spvc.js";import"./chunk-qexnx2v2.js";import"./chunk-whxkwaz1.js";import"./chunk-vnxj21sa.js";import"./chunk-9qxch6sy.js";import"./chunk-6jjpj5ge.js";import"./chunk-skktstg8.js";import"./chunk-s14zayxp.js";import"./chunk-b5cz00mt.js";import{Ef as n}from"./chunk-6h1x1m4f.js";import"./chunk-crv3sghv.js";import{_f as s}from"./chunk-acxyw1ej.js";import"./chunk-x6k5ye1z.js";import"./chunk-v508x7cg.js";import"./chunk-1g7c3f82.js";import"./chunk-3v9epq9s.js";import"./chunk-eexs73bz.js";import"./chunk-pm163dfm.js";import"./chunk-cfxs7jdk.js";import"./chunk-a1y938pg.js";import"./chunk-kehgewqh.js";import"./chunk-kkzznz4w.js";import"./chunk-1cy4ab77.js";import"./chunk-7ajvrtb3.js";import"./chunk-8yh4mn8a.js";import"./chunk-ys8gysg8.js";import"./chunk-ftk0ytf8.js";import"./chunk-b22ab7yw.js";import"./chunk-amabfzc8.js";import"./chunk-m2x6pb4f.js";import"./chunk-saz6mwpq.js";import"./chunk-xhwdac1j.js";import"./chunk-0eajnhrj.js";import"./chunk-bzwxh6nq.js";import"./chunk-asgmmaec.js";import"./chunk-ed2hdrwe.js";import"./chunk-gmpsfkgg.js";import v from"chalk";var C={command:"serve",describe:"Start a headless Blade server (no browser)",builder:a,handler:async(p)=>{let r=i(p);if(await s(),!process.env.BLADE_SERVER_PASSWORD)console.log(v.yellow("Warning: BLADE_SERVER_PASSWORD is not set; server is unsecured."));let e=await m.listenAsync(r);if(console.log(`Blade server listening on http://${e.hostname}:${e.port}`),r.hostname==="0.0.0.0"){let o=l();for(let g of o)console.log(` Network: http://${g}:${e.port}`)}let t,c=new Promise((o)=>{t=o}),d=n(async()=>{await e.stop(),t()});try{await c}finally{d(),await e.stop()}}};export{C as serveCommand};
1
+ import{a,b as i,c as l,d as m}from"./chunk-7876fd4b.js";import"./chunk-j5e589we.js";import"./chunk-870szc6v.js";import"./chunk-mmwqe49e.js";import"./chunk-vjvw3v6b.js";import"./chunk-22py5y1p.js";import"./chunk-e613h191.js";import"./chunk-nad5spvc.js";import"./chunk-74vmjngm.js";import"./chunk-whxkwaz1.js";import"./chunk-3t655nhk.js";import"./chunk-9qxch6sy.js";import"./chunk-ayqqhefz.js";import"./chunk-skktstg8.js";import"./chunk-s14zayxp.js";import"./chunk-b5cz00mt.js";import{Ef as n}from"./chunk-8r8fp09p.js";import"./chunk-crv3sghv.js";import{_f as s}from"./chunk-dgypy6yt.js";import"./chunk-x6k5ye1z.js";import"./chunk-v508x7cg.js";import"./chunk-1g7c3f82.js";import"./chunk-3v9epq9s.js";import"./chunk-eexs73bz.js";import"./chunk-pm163dfm.js";import"./chunk-np5t59fa.js";import"./chunk-34y4z9ns.js";import"./chunk-kehgewqh.js";import"./chunk-kkzznz4w.js";import"./chunk-1cy4ab77.js";import"./chunk-7ajvrtb3.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";import v from"chalk";var C={command:"serve",describe:"Start a headless Blade server (no browser)",builder:a,handler:async(p)=>{let r=i(p);if(await s(),!process.env.BLADE_SERVER_PASSWORD)console.log(v.yellow("Warning: BLADE_SERVER_PASSWORD is not set; server is unsecured."));let e=await m.listenAsync(r);if(console.log(`Blade server listening on http://${e.hostname}:${e.port}`),r.hostname==="0.0.0.0"){let o=l();for(let g of o)console.log(` Network: http://${g}:${e.port}`)}let t,c=new Promise((o)=>{t=o}),d=n(async()=>{await e.stop(),t()});try{await c}finally{d(),await e.stop()}}};export{C as serveCommand};
@@ -1,4 +1,4 @@
1
- import{fg as G0}from"./chunk-x6k5ye1z.js";import{Hh as Y0,Ri as l,Ui as Z0,si as W}from"./chunk-ftk0ytf8.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}
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
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(`
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(`
@@ -1,4 +1,4 @@
1
- import{Ka as UJ}from"./chunk-nad5spvc.js";import{Na as T,Oa as t0,Ta as AW,Ua as pY,Va as o0}from"./chunk-qexnx2v2.js";import{Ab as GV,Wa as Z5,Za as l3,bb as e3,cb as MX,db as AX,fb as BV,hb as KV,ib as C9}from"./chunk-whxkwaz1.js";import{Bb as o5,Cb as d7,Db as J1,Eb as i7,Fb as K2,Gb as MY,Hb as f1,Ib as zY,Jb as CY,Kb as qY,Lb as TY,Mb as RY,Nb as bQ,Pb as OX,Rb as V0,Tb as w2,Wb as c6,Yb as F3,Zb as l6,_b as i6,ac as TZ,bc as R$,hc as KW,ic as B8,jc as GW,kc as DW,lc as FX,nc as x1,oc as nX,tc as WQ,wc as VQ}from"./chunk-vnxj21sa.js";import{$c as h4,Cc as v$,Dc as mX,Ec as sJ,Fc as IJ,Gc as A1,Hc as QZ,Ic as O0,Jc as f2,Kc as O1,Lc as S4,Mc as k9,Nc as m6,Oc as p6,Pc as FY,Qc as OY,Rc as pX,Sc as HJ,Sd as W8,Tc as j1,Uc as WJ,Ud as P0,Vc as c8,Vd as _$,Wc as e$,Xc as $1,Yc as l2,Zc as c2,_c as i2,ad as g4,bd as d2,be as _W,cd as GJ,ce as EX,dd as m2,ed as l8,fd as E1,fe as XQ,gd as s1,hd as p2,id as o1,jd as t1,kd as u4,ke as iX,ld as e1,le as rX,md as d4,nd as m4,ne as o,od as k$,pd as p4,qd as jJ,rd as r2,sd as c4,td as l4,ud as i4,vd as r4,wd as EJ,xd as MJ,zd as AJ}from"./chunk-6jjpj5ge.js";import{oe as l,pe as AQ,qe as CQ,re as uZ,te as q2}from"./chunk-skktstg8.js";import{Me as v9,Ne as $$,Oe as G2,Pe as J9,Qe as cX,Re as lX,_e as FV,lf as OV,ve as qV,ye as wV}from"./chunk-s14zayxp.js";import{Hf as jZ,If as NZ}from"./chunk-crv3sghv.js";import{$f as F2,Uf as r6,Vf as N0,Wf as g,Zf as E0,_f as S6,ag as U1,bg as C3,cg as M2,dg as YQ,eg as H2}from"./chunk-acxyw1ej.js";import{fg as h1}from"./chunk-x6k5ye1z.js";import{hg as BW,jg as b3,kg as QQ,pg as JQ,qg as QW,rg as f6}from"./chunk-1g7c3f82.js";import{sg as a3}from"./chunk-3v9epq9s.js";import{vg as u0,wg as F1}from"./chunk-eexs73bz.js";import{xg as wW}from"./chunk-pm163dfm.js";import{Ag as IX,Bg as xX,Cg as hX,zg as yX}from"./chunk-cfxs7jdk.js";import{$g as k6,Dg as x6,Eg as h6,Fg as g6,Hg as u6,Ig as d6,Jg as q1,Kg as x$,Lg as b$,Mg as H$,Ng as t8,Og as Q2,Pg as U8,Qg as m1,Rg as p1,Sg as uX,Wg as Y9,Yg as d0,Zg as P$,ah as dX,bh as aX}from"./chunk-a1y938pg.js";import{dh as B1,fh as T$,gh as b6}from"./chunk-kehgewqh.js";import{hh as cJ,ih as Y2,jh as lJ,kh as s2,lh as iJ,mh as rJ,nh as $6,oh as e4,ph as nJ,qh as aJ,rh as t4}from"./chunk-kkzznz4w.js";import{sh as IW,uh as gX,vh as X8,wh as EZ}from"./chunk-1cy4ab77.js";import{Ah as y0,yh as _9}from"./chunk-8yh4mn8a.js";import{Bh as j4,Ch as f9,Dh as E4,Eh as c1}from"./chunk-ys8gysg8.js";import{Fi as lY,Gi as iY,Hh as HZ,Hi as rY,Ih as F$,Ii as nY,Ji as M3,Ki as aY,Li as H1,Mi as sY,Nh as UZ,Ni as oY,Oi as tY,Ph as q9,Qi as JZ,Si as oX,Ti as vX,Uh as MW,Ui as B0,Yh as zZ,_h as SX,ai as jY,bi as EY,si as v1,vi as DY}from"./chunk-ftk0ytf8.js";import{Xi as Q6,Zi as C}from"./chunk-b22ab7yw.js";import{xj as qX,zj as wX}from"./chunk-m2x6pb4f.js";import{Ej as $0,Gj as n4,Hj as Z2,Ij as G,Jj as fJ,Kj as f,Lj as h}from"./chunk-saz6mwpq.js";import{Pj as fX,Qj as kX}from"./chunk-xhwdac1j.js";import{Rj as hW,Uj as vW}from"./chunk-0eajnhrj.js";import{Xj as mW}from"./chunk-bzwxh6nq.js";import{bk as sX,ck as r0}from"./chunk-asgmmaec.js";import{Ek as pJ,dk as e,ek as L$,fk as B$,gk as a1,hk as $J,ik as u2,jk as Z$,kk as GY,nk as I4,wk as P4,zk as j$}from"./chunk-ed2hdrwe.js";import{Jk as z$}from"./chunk-gmpsfkgg.js";import{randomUUID as E8}from"crypto";import{randomUUID as IV}from"node:crypto";var SV=String.raw`
1
+ import{Ka as UJ}from"./chunk-nad5spvc.js";import{Na as T,Oa as t0,Ta as AW,Ua as pY,Va as o0}from"./chunk-74vmjngm.js";import{Ab as GV,Wa as Z5,Za as l3,bb as e3,cb as MX,db as AX,fb as BV,hb as KV,ib as C9}from"./chunk-whxkwaz1.js";import{Bb as o5,Cb as d7,Db as J1,Eb as i7,Fb as K2,Gb as MY,Hb as f1,Ib as zY,Jb as CY,Kb as qY,Lb as TY,Mb as RY,Nb as bQ,Pb as OX,Rb as V0,Tb as w2,Wb as c6,Yb as F3,Zb as l6,_b as i6,ac as TZ,bc as R$,hc as KW,ic as B8,jc as GW,kc as DW,lc as FX,nc as x1,oc as nX,tc as WQ,wc as VQ}from"./chunk-3t655nhk.js";import{$c as h4,Cc as v$,Dc as mX,Ec as sJ,Fc as IJ,Gc as A1,Hc as QZ,Ic as O0,Jc as f2,Kc as O1,Lc as S4,Mc as k9,Nc as m6,Oc as p6,Pc as FY,Qc as OY,Rc as pX,Sc as HJ,Sd as W8,Tc as j1,Uc as WJ,Ud as P0,Vc as c8,Vd as _$,Wc as e$,Xc as $1,Yc as l2,Zc as c2,_c as i2,ad as g4,bd as d2,be as _W,cd as GJ,ce as EX,dd as m2,ed as l8,fd as E1,fe as XQ,gd as s1,hd as p2,id as o1,jd as t1,kd as u4,ke as iX,ld as e1,le as rX,md as d4,nd as m4,ne as o,od as k$,pd as p4,qd as jJ,rd as r2,sd as c4,td as l4,ud as i4,vd as r4,wd as EJ,xd as MJ,zd as AJ}from"./chunk-ayqqhefz.js";import{oe as l,pe as AQ,qe as CQ,re as uZ,te as q2}from"./chunk-skktstg8.js";import{Me as v9,Ne as $$,Oe as G2,Pe as J9,Qe as cX,Re as lX,_e as FV,lf as OV,ve as qV,ye as wV}from"./chunk-s14zayxp.js";import{Hf as jZ,If as NZ}from"./chunk-crv3sghv.js";import{$f as F2,Uf as r6,Vf as N0,Wf as g,Zf as E0,_f as S6,ag as U1,bg as C3,cg as M2,dg as YQ,eg as H2}from"./chunk-dgypy6yt.js";import{fg as h1}from"./chunk-x6k5ye1z.js";import{hg as BW,jg as b3,kg as QQ,pg as JQ,qg as QW,rg as f6}from"./chunk-1g7c3f82.js";import{sg as a3}from"./chunk-3v9epq9s.js";import{vg as u0,wg as F1}from"./chunk-eexs73bz.js";import{xg as wW}from"./chunk-pm163dfm.js";import{Ag as IX,Bg as xX,Cg as hX,zg as yX}from"./chunk-np5t59fa.js";import{$g as k6,Dg as x6,Eg as h6,Fg as g6,Hg as u6,Ig as d6,Jg as q1,Kg as x$,Lg as b$,Mg as H$,Ng as t8,Og as Q2,Pg as U8,Qg as m1,Rg as p1,Sg as uX,Wg as Y9,Yg as d0,Zg as P$,ah as dX,bh as aX}from"./chunk-34y4z9ns.js";import{dh as B1,fh as T$,gh as b6}from"./chunk-kehgewqh.js";import{hh as cJ,ih as Y2,jh as lJ,kh as s2,lh as iJ,mh as rJ,nh as $6,oh as e4,ph as nJ,qh as aJ,rh as t4}from"./chunk-kkzznz4w.js";import{sh as IW,uh as gX,vh as X8,wh as EZ}from"./chunk-1cy4ab77.js";import{Ah as y0,yh as _9}from"./chunk-3m8949fr.js";import{Bh as j4,Ch as f9,Dh as E4,Eh as c1}from"./chunk-ys8gysg8.js";import{Fi as lY,Gi as iY,Hh as HZ,Hi as rY,Ih as F$,Ii as nY,Ji as M3,Ki as aY,Li as H1,Mi as sY,Nh as UZ,Ni as oY,Oi as tY,Ph as q9,Qi as JZ,Si as oX,Ti as vX,Uh as MW,Ui as B0,Yh as zZ,_h as SX,ai as jY,bi as EY,si as v1,vi as DY}from"./chunk-nr5s7qtp.js";import{Xi as Q6,Zi as C}from"./chunk-b22ab7yw.js";import{xj as qX,zj as wX}from"./chunk-m2x6pb4f.js";import{Ej as $0,Gj as n4,Hj as Z2,Ij as G,Jj as fJ,Kj as f,Lj as h}from"./chunk-saz6mwpq.js";import{Pj as fX,Qj as kX}from"./chunk-xhwdac1j.js";import{Rj as hW,Uj as vW}from"./chunk-0eajnhrj.js";import{Xj as mW}from"./chunk-c1331rdc.js";import{bk as sX,ck as r0}from"./chunk-asgmmaec.js";import{Ek as pJ,dk as e,ek as L$,fk as B$,gk as a1,hk as $J,ik as u2,jk as Z$,kk as GY,nk as I4,wk as P4,zk as j$}from"./chunk-ed2hdrwe.js";import{Jk as z$}from"./chunk-gmpsfkgg.js";import{randomUUID as E8}from"crypto";import{randomUUID as IV}from"node:crypto";var SV=String.raw`
2
2
  const { spawn } = require('node:child_process');
3
3
  const [ownerPidValue, command, ...args] = process.argv.slice(1);
4
4
  const ownerPid = Number(ownerPidValue);
@@ -872,7 +872,7 @@ ${l$}
872
872
  </approved-plan>
873
873
 
874
874
  IMPORTANT: Execute according to the approved plan above. Follow the steps exactly as specified.`;if(typeof b==="string")S2=b+P9;else S2=[...b,{type:"text",text:P9}]}k=yield*this.runLoop(S2,_,{...I,inputMessageId:void 0})}}finally{this.clearSkillContext()}if(!this.sessionRuntime||!y)return k;let a=v??await this.sessionRuntime.getGoal(),u=await this.sessionRuntime.recordGoalProgress({tokens:k.metadata?.tokensUsed??0,elapsedMs:k.metadata?.duration??0,turnId:y.id,...a?{goalId:a.goalId,objective:a.objective}:{},executionHostFailureCategory:k.metadata?.executionHostFailureCategory,prematureStopPattern:k.success?bY(k.finalMessage):void 0});if(u)yield{kind:"goal_updated",goal:u};if(!k.success||_.signal?.aborted){if(u=await this.sessionRuntime.pauseActiveGoal(_.signal?.aborted?"goal paused after user cancellation":k.error?.message??"goal paused after turn failure"),u)yield{kind:"goal_updated",goal:u}}if(k.success&&!_.signal?.aborted&&m<20)await this.sessionRuntime.waitForBackgroundSubagentFollowUp(y,_.signal);let m0=k.success&&!_.signal?.aborted&&m<20,z0=pK(k)||!k.success&&k.error?.type==="max_turns_exceeded";if(R=await this.sessionRuntime.finishTurn(y,{continuePending:m0,...z0?{acknowledgeInput:!0}:{},outcome:k.success&&!_.signal?.aborted?{status:"completed",turnsCount:k.metadata?.turnsCount??0,toolCallsCount:k.metadata?.toolCallsCount??0,durationMs:k.metadata?.duration??0,...k.metadata?.usage?{usage:k.metadata.usage}:{}}:{status:"aborted",cause:_.signal?.aborted?"cancelled":"failed",turnsCount:k.metadata?.turnsCount??0,toolCallsCount:k.metadata?.toolCallsCount??0,durationMs:k.metadata?.duration??0,...k.metadata?.usage?{usage:k.metadata.usage}:{}}}),R){m++,N=!0,M=!1,j=null,b="",c=void 0,A="",S=void 0,E=J0(),yield{kind:"follow_up_started",queued:this.sessionRuntime.getPendingSteeringCount(),recovered:this.sessionRuntime.getRecoveredSteeringCount(),messages:t(),queue:await this.sessionRuntime.getFollowUpQueueSnapshot()};continue}if(yield{kind:"follow_up_queue_changed",queue:await this.sessionRuntime.getFollowUpQueueSnapshot()},!k.success||_.signal?.aborted)return k;if(u=await this.sessionRuntime.getGoal(),!u||u.status!=="active"&&u.status!=="verifying")return k;let F0=await this.sessionRuntime.prepareGoalContinuation(u);if(!F0.ok){if(F0.goal)yield{kind:"goal_updated",goal:F0.goal};return{success:!1,error:{type:"goal_frontier_unavailable",message:F0.error.message},metadata:{turnsCount:k.metadata?.turnsCount??0,toolCallsCount:k.metadata?.toolCallsCount??0,duration:k.metadata?.duration??0}}}let f$=await this.sessionRuntime.beginGoalTurn(F0.goal);if(!f$)return k;j=f$.goal,w={...F0,goal:f$.goal},R=f$.handle,N=!1,M=!0,b=S5(j),c=void 0,E=void 0,yield{kind:"goal_frontier_updated",goal:j,frontier:F0.frontier,tasks:F0.tasks},yield{kind:"goal_continuation_started",goal:j,continuation:j.continuationCount,...j.prematureStop?{prematureStopPattern:j.prematureStop.pattern,prematureStopCount:j.prematureStop.consecutiveCount}:{}},yield{kind:"goal_updated",goal:j}}}finally{if(this.sessionRuntime&&R)await this.sessionRuntime.finishTurn(R)}}let O=typeof z==="string"?z:z.filter((b)=>b.type==="text").map((b)=>b.text).join(`
875
- `),L={id:this.generateTaskId(),type:"simple",prompt:O};return{success:!0,finalMessage:(await this.executeTask(L)).content,metadata:{turnsCount:1,toolCallsCount:0,duration:0}}}async chat($,J,Z){let{drainLoop:Y}=await import("./chunk-yh28byeh.js");return Y(this.chatStream($,J,Z))}async*runPlanLoop($,J,Z){s.debug("Processing Plan mode message...");let{prompt:Y}=await Z1({...J.workspaceKind==="acp-remote"?{workspaceAccess:"none"}:{projectPath:J.workspaceRoot||C()},mode:"plan",includeEnvironment:!0,environmentOptions:{...x1,workingDirectory:J.executionRoot??J.workspaceRoot??C()},language:this.config.language,availableSkills:this.agentResources?.skills.generateAvailableSkillsList(),communicationStyle:this.sessionRuntime?.getCommunicationStyleConfiguration().selection,communicationStyleCatalog:this.sessionRuntime?.getCommunicationStyleCatalog(),projectRuleCatalog:this.sessionRuntime?.getProjectRuleCatalog(),...J.workspaceKind==="acp-remote"?{}:{projectInstructionSourcePath:this.sessionRuntime?.projectRoot}}),Q;if(typeof $==="string")Q=t2($);else{let X=$.filter((W)=>W.type==="text");if(X.length>0){let W=X[0];Q=$.map((V)=>V===W?{type:"text",text:t2(W.text)}:V)}else Q=[{type:"text",text:t2("")},...$]}return yield*this.executeLoop(Q,J,Z,Y)}async*runLoop($,J,Z){s.debug("Processing enhanced chat message...");let Y=J.systemPrompt??await this.buildSystemPromptOnDemand(J);return yield*this.executeLoop($,J,Z,Y)}async buildSystemPromptOnDemand($){let J=this.runtimeOptions.systemPrompt,Z=this.runtimeOptions.appendSystemPrompt;return(await Z1({...$.workspaceKind==="acp-remote"?{workspaceAccess:"none"}:{projectPath:$.workspaceRoot||C()},replaceDefault:J,append:Z,includeEnvironment:!0,environmentOptions:{...x1,workingDirectory:$.executionRoot??$.workspaceRoot??C()},language:this.config.language,availableSkills:this.agentResources?.skills.generateAvailableSkillsList(),communicationStyle:this.sessionRuntime?.getCommunicationStyleConfiguration().selection,communicationStyleCatalog:this.sessionRuntime?.getCommunicationStyleCatalog(),projectRuleCatalog:this.sessionRuntime?.getProjectRuleCatalog(),...$.workspaceKind==="acp-remote"?{}:{projectInstructionSourcePath:this.sessionRuntime?.projectRoot}})).prompt}executeLoop($,J,Z,Y){if(!this.isInitialized)throw Error("Agent未初始化");let Q=this.buildLoopDependencies();return VQ(Q,$,J,Z,Y)}takeStartupAdoptedToolResultEvents(){return(this.sessionRuntime?.takeStartupAdoptedToolResults()??[]).flatMap(({call:J,result:Z})=>{let Y={id:J.toolCallId,type:"function",function:{name:J.toolName,arguments:JSON.stringify(J.input)}},Q=Z.metadata&&typeof Z.metadata==="object"&&!Array.isArray(Z.metadata)?Z.metadata:void 0,X=Z.error===void 0,W=Z.output,V={success:X,llmContent:typeof W==="string"||W!==null&&typeof W==="object"?W:W===null?Z.error?`Subagent execution failed: ${Z.error}.`:"":String(W),...Z.error?{error:{type:"execution_error",message:Z.error}}:{},...Q?{metadata:Q}:{}},H=[{kind:"tool_result",toolCall:Y,result:V}],U=WQ(Y,V);if(U)H.push(U);return H})}takeStartupRecoveryEvents(){let $=this.sessionRuntime?.getTurnRecoveryAssessment(),J=$?.state==="requires_attention"?$:this.sessionRuntime?.takeStartupTurnRecoveryAssessment(),Z=J&&J.state!=="none"?[{kind:"turn_recovery",assessment:J}]:[];return Z.push(...this.takeStartupAdoptedToolResultEvents()),Z}buildLoopDependencies(){return{chatService:this.chatService,toolExecutor:this.toolExecutor,executionEngine:this.executionEngine,config:this.config,runtimeOptions:this.runtimeOptions,currentModelMaxContextTokens:this.currentModelMaxContextTokens,activeSkillContext:this.activeSkillContext,onSkillActivated:($)=>{this.activeSkillContext=$,s.debug(`Skill "${$.skillName}" activated`+($.allowedTools?` with allowed tools: ${$.allowedTools.join(", ")}`:""))},onModelSwitch:($)=>this.switchModelIfNeeded($),applySkillToolRestrictions:($)=>this.applySkillToolRestrictions($),staticProjectRules:this.sessionRuntime?.getStaticProjectRules(),hydrateProjectRules:this.sessionRuntime?($)=>this.sessionRuntime.hydrateProjectRules($):void 0,resolveContextualProjectRules:this.sessionRuntime?($,J,Z,Y)=>this.sessionRuntime.resolveContextualProjectRules($,J,Z,Y):void 0}}async chatWithSystem($,J){if(!this.isInitialized)throw Error("Agent未初始化");let Z=[{role:"system",content:$},{role:"user",content:J}];return(await this.chatService.chat(Z)).content}getActiveTask(){return this.activeTask}getChatService(){return this.chatService}getContextManager(){return this.executionEngine?.getContextManager()}getStats(){return{initialized:this.isInitialized,activeTask:this.activeTask?.id,components:{chatService:this.chatService?"ready":"not_loaded",executionEngine:this.executionEngine?"ready":"not_loaded"}}}getAvailableTools(){return this.toolExecutor?this.toolExecutor.getRegistry().getAll():[]}getToolRegistry(){return this.toolExecutor.getRegistry()}applyToolWhitelist($){let J=this.toolExecutor.getRegistry(),Y=J.getAll().filter((Q)=>!$.includes(Q.name));for(let Q of Y)J.unregister(Q.name);s.debug(`Applied tool whitelist: ${$.join(", ")} (removed ${Y.length} tools)`)}applyToolBlacklist($){let J=this.toolExecutor.getRegistry(),Z=new Set($);for(let Y of J.getAll())if(Z.has(Y.name))J.unregister(Y.name);s.debug(`Applied tool blacklist: ${$.join(", ")}`)}getToolStats(){let $=this.getAvailableTools(),J=new Map;return $.forEach((Z)=>{let Y=J.get(Z.kind)||0;J.set(Z.kind,Y+1)}),{totalTools:$.length,toolsByKind:Object.fromEntries(J),toolNames:$.map((Z)=>Z.name)}}async destroy(){if(this.destroyPromise)return this.destroyPromise;return this.destroyPromise=(async()=>{this.log("销毁Agent..."),await this.activeOperations.shutdown("agent-destroy");try{await this.legacyMcpRegistry?.disconnectAll(),this.legacyMcpRegistry=void 0,this.log("Agent已销毁")}catch($){throw this.error("Agent销毁失败",$),$}finally{this.toolExecutor.dispose(),this.isInitialized=!1}})(),this.destroyPromise}syncRuntimeState(){if(!this.sessionRuntime)return;this.chatService=this.sessionRuntime.getChatService(),this.executionEngine=this.sessionRuntime.getExecutionEngine(),this.attachmentCollector=this.sessionRuntime.getAttachmentCollector(),this.currentModelId=this.sessionRuntime.getCurrentModelId(),this.currentModelMaxContextTokens=this.sessionRuntime.getCurrentModelMaxContextTokens()}generateTaskId(){return`task_${Date.now()}_${Math.random().toString(36).substring(2,9)}`}log($,J){s.debug(`[MainAgent] ${$}`,J||"")}error($,J){s.error(`[MainAgent] ${$}`,J||"")}async initializeSystemPrompt(){try{let $=this.runtimeOptions.systemPrompt,J=this.runtimeOptions.appendSystemPrompt,Z=await Z1({...this.sessionRuntime?.isRemoteWorkspace()?{workspaceAccess:"none"}:{projectPath:this.sessionRuntime?.workspaceRoot??C()},replaceDefault:$,append:J,includeEnvironment:!1,language:this.config.language,availableSkills:this.agentResources?.skills.generateAvailableSkillsList(),communicationStyle:this.sessionRuntime?.getCommunicationStyleConfiguration().selection,communicationStyleCatalog:this.sessionRuntime?.getCommunicationStyleCatalog(),projectRuleCatalog:this.sessionRuntime?.getProjectRuleCatalog(),...this.sessionRuntime?.isRemoteWorkspace()?{}:{projectInstructionSourcePath:this.sessionRuntime?.projectRoot},...this.sessionRuntime?{environmentOptions:{...x1,workingDirectory:this.sessionRuntime.executionRoot}}:{}});if(Z.prompt)this.log("系统提示配置验证成功"),s.debug(`[SystemPrompt] 可用来源: ${Z.sources.filter((Y)=>Y.loaded).map((Y)=>Y.name).join(", ")}`)}catch($){this.error("系统提示配置验证失败",$)}}async registerBuiltinTools(){try{let $=await v6({sessionId:"default",configDir:e(),workspaceRoot:C(),resourceRoot:C(),agentResources:this.agentResources});s.debug(`Registering ${$.length} builtin tools...`),this.toolExecutor.getRegistry().registerAll($);let J=this.toolExecutor.getRegistry().getAll().length;s.debug(`Builtin tools registered: ${J} tools`),s.debug(`[Tools] ${this.toolExecutor.getRegistry().getAll().map((Z)=>Z.name).join(", ")}`),await this.registerMcpTools()}catch($){throw s.error("Failed to register builtin tools:",$),$}}async registerMcpTools(){try{let $=await X6({workspaceRoot:C(),storeServers:this.config.mcpServers??{},cliConfigs:this.runtimeOptions.mcpConfig,strictCliConfig:this.runtimeOptions.strictMcpConfig});if(Object.keys($).length===0){s.debug("No MCP servers configured");return}let J=o0.createIsolated({artifactWriter:new o2(`legacy-${mK()}`)});this.legacyMcpRegistry=J;for(let[X,W]of Object.entries($))try{s.debug(`Connecting to MCP server: ${X}`),await J.registerServer(X,W),s.debug(`MCP server "${X}" connected`)}catch(V){s.warn(`Warning: MCP server "${X}" connection failed:`,V)}let Z=this.toolExecutor.getRegistry();Z.setMcpCatalogBarrier(()=>J.waitForCatalogIdle());let Y=J.getCatalogSnapshot();Z.replaceMcpTools(Y.tools),Z.registerAll(Z4(J));let Q=J.getInstructionsSnapshot();if(Z.queueMcpInstructionsChange({revision:Q.revision,reason:"snapshot",replace:!0,instructions:Q.instructions,removed:[]}),J.on("catalogChanged",(X)=>{Z.replaceMcpTools(X.tools,X)}),J.on("contentCatalogChanged",(X)=>{Z.queueMcpContentChange(X)}),J.on("resourceUpdated",(X)=>{Z.queueMcpResourceUpdated(X)}),J.on("connectionLifecycleChanged",(X)=>{Z.queueMcpConnectionChange(X)}),J.on("log",(X)=>{Z.queueMcpLog(X)}),J.on("instructionsChanged",(X)=>{Z.queueMcpInstructionsChange({revision:X.revision,reason:X.reason,replace:!1,instructions:X.action==="added"&&X.instruction?[{serverName:X.serverName,...X.instruction}]:[],removed:X.action==="removed"?[X.serverName]:[]})}),Y.tools.length>0)s.debug(`Registered ${Y.tools.length} MCP tools`),s.debug(`[MCP Tools] ${Y.tools.map((X)=>X.name).join(", ")}`)}catch($){s.warn("Failed to register MCP tools:",$)}}async loadSubagents(){let $=await d0(C());if(this.agentResources=k6($),this.subagentRegistry=this.agentResources.subagents,this.runtimeOptions.agents?.length)this.subagentRegistry.applyOverrides(this.runtimeOptions.agents);let J=this.subagentRegistry.getAllNames().length;if(J>0)s.debug(`Loaded ${J} subagents: ${this.subagentRegistry.getAllNames().join(", ")}`);else s.debug("No subagents configured")}applySkillToolRestrictions($){if(!this.activeSkillContext?.allowedTools)return $;let J=this.activeSkillContext.allowedTools;s.debug(`Applying Skill tool restrictions: ${J.join(", ")}`);let Z=$.filter((Y)=>{if(Y.name==="ReadPromptArtifact")return!0;return J.some((Q)=>{if(Q===Y.name)return!0;let X=Q.match(/^(\w+)\(.*\)$/);if(X&&X[1]===Y.name)return!0;return!1})});return s.debug(`Filtered tools: ${Z.map((Y)=>Y.name).join(", ")} (${Z.length}/${$.length})`),Z}clearSkillContext(){if(this.activeSkillContext)s.debug(`Skill "${this.activeSkillContext.skillName}" deactivated`),this.activeSkillContext=void 0}async processAtMentionsForContent($){if(!this.attachmentCollector)return $;if(typeof $==="string")return this.processAtMentions($);let J=[];for(let Y of $)if(Y.type==="text")J.push(Y.text);if(J.length===0)return $;let Z=J.join(`
875
+ `),L={id:this.generateTaskId(),type:"simple",prompt:O};return{success:!0,finalMessage:(await this.executeTask(L)).content,metadata:{turnsCount:1,toolCallsCount:0,duration:0}}}async chat($,J,Z){let{drainLoop:Y}=await import("./chunk-rwtsvy5y.js");return Y(this.chatStream($,J,Z))}async*runPlanLoop($,J,Z){s.debug("Processing Plan mode message...");let{prompt:Y}=await Z1({...J.workspaceKind==="acp-remote"?{workspaceAccess:"none"}:{projectPath:J.workspaceRoot||C()},mode:"plan",includeEnvironment:!0,environmentOptions:{...x1,workingDirectory:J.executionRoot??J.workspaceRoot??C()},language:this.config.language,availableSkills:this.agentResources?.skills.generateAvailableSkillsList(),communicationStyle:this.sessionRuntime?.getCommunicationStyleConfiguration().selection,communicationStyleCatalog:this.sessionRuntime?.getCommunicationStyleCatalog(),projectRuleCatalog:this.sessionRuntime?.getProjectRuleCatalog(),...J.workspaceKind==="acp-remote"?{}:{projectInstructionSourcePath:this.sessionRuntime?.projectRoot}}),Q;if(typeof $==="string")Q=t2($);else{let X=$.filter((W)=>W.type==="text");if(X.length>0){let W=X[0];Q=$.map((V)=>V===W?{type:"text",text:t2(W.text)}:V)}else Q=[{type:"text",text:t2("")},...$]}return yield*this.executeLoop(Q,J,Z,Y)}async*runLoop($,J,Z){s.debug("Processing enhanced chat message...");let Y=J.systemPrompt??await this.buildSystemPromptOnDemand(J);return yield*this.executeLoop($,J,Z,Y)}async buildSystemPromptOnDemand($){let J=this.runtimeOptions.systemPrompt,Z=this.runtimeOptions.appendSystemPrompt;return(await Z1({...$.workspaceKind==="acp-remote"?{workspaceAccess:"none"}:{projectPath:$.workspaceRoot||C()},replaceDefault:J,append:Z,includeEnvironment:!0,environmentOptions:{...x1,workingDirectory:$.executionRoot??$.workspaceRoot??C()},language:this.config.language,availableSkills:this.agentResources?.skills.generateAvailableSkillsList(),communicationStyle:this.sessionRuntime?.getCommunicationStyleConfiguration().selection,communicationStyleCatalog:this.sessionRuntime?.getCommunicationStyleCatalog(),projectRuleCatalog:this.sessionRuntime?.getProjectRuleCatalog(),...$.workspaceKind==="acp-remote"?{}:{projectInstructionSourcePath:this.sessionRuntime?.projectRoot}})).prompt}executeLoop($,J,Z,Y){if(!this.isInitialized)throw Error("Agent未初始化");let Q=this.buildLoopDependencies();return VQ(Q,$,J,Z,Y)}takeStartupAdoptedToolResultEvents(){return(this.sessionRuntime?.takeStartupAdoptedToolResults()??[]).flatMap(({call:J,result:Z})=>{let Y={id:J.toolCallId,type:"function",function:{name:J.toolName,arguments:JSON.stringify(J.input)}},Q=Z.metadata&&typeof Z.metadata==="object"&&!Array.isArray(Z.metadata)?Z.metadata:void 0,X=Z.error===void 0,W=Z.output,V={success:X,llmContent:typeof W==="string"||W!==null&&typeof W==="object"?W:W===null?Z.error?`Subagent execution failed: ${Z.error}.`:"":String(W),...Z.error?{error:{type:"execution_error",message:Z.error}}:{},...Q?{metadata:Q}:{}},H=[{kind:"tool_result",toolCall:Y,result:V}],U=WQ(Y,V);if(U)H.push(U);return H})}takeStartupRecoveryEvents(){let $=this.sessionRuntime?.getTurnRecoveryAssessment(),J=$?.state==="requires_attention"?$:this.sessionRuntime?.takeStartupTurnRecoveryAssessment(),Z=J&&J.state!=="none"?[{kind:"turn_recovery",assessment:J}]:[];return Z.push(...this.takeStartupAdoptedToolResultEvents()),Z}buildLoopDependencies(){return{chatService:this.chatService,toolExecutor:this.toolExecutor,executionEngine:this.executionEngine,config:this.config,runtimeOptions:this.runtimeOptions,currentModelMaxContextTokens:this.currentModelMaxContextTokens,activeSkillContext:this.activeSkillContext,onSkillActivated:($)=>{this.activeSkillContext=$,s.debug(`Skill "${$.skillName}" activated`+($.allowedTools?` with allowed tools: ${$.allowedTools.join(", ")}`:""))},onModelSwitch:($)=>this.switchModelIfNeeded($),applySkillToolRestrictions:($)=>this.applySkillToolRestrictions($),staticProjectRules:this.sessionRuntime?.getStaticProjectRules(),hydrateProjectRules:this.sessionRuntime?($)=>this.sessionRuntime.hydrateProjectRules($):void 0,resolveContextualProjectRules:this.sessionRuntime?($,J,Z,Y)=>this.sessionRuntime.resolveContextualProjectRules($,J,Z,Y):void 0}}async chatWithSystem($,J){if(!this.isInitialized)throw Error("Agent未初始化");let Z=[{role:"system",content:$},{role:"user",content:J}];return(await this.chatService.chat(Z)).content}getActiveTask(){return this.activeTask}getChatService(){return this.chatService}getContextManager(){return this.executionEngine?.getContextManager()}getStats(){return{initialized:this.isInitialized,activeTask:this.activeTask?.id,components:{chatService:this.chatService?"ready":"not_loaded",executionEngine:this.executionEngine?"ready":"not_loaded"}}}getAvailableTools(){return this.toolExecutor?this.toolExecutor.getRegistry().getAll():[]}getToolRegistry(){return this.toolExecutor.getRegistry()}applyToolWhitelist($){let J=this.toolExecutor.getRegistry(),Y=J.getAll().filter((Q)=>!$.includes(Q.name));for(let Q of Y)J.unregister(Q.name);s.debug(`Applied tool whitelist: ${$.join(", ")} (removed ${Y.length} tools)`)}applyToolBlacklist($){let J=this.toolExecutor.getRegistry(),Z=new Set($);for(let Y of J.getAll())if(Z.has(Y.name))J.unregister(Y.name);s.debug(`Applied tool blacklist: ${$.join(", ")}`)}getToolStats(){let $=this.getAvailableTools(),J=new Map;return $.forEach((Z)=>{let Y=J.get(Z.kind)||0;J.set(Z.kind,Y+1)}),{totalTools:$.length,toolsByKind:Object.fromEntries(J),toolNames:$.map((Z)=>Z.name)}}async destroy(){if(this.destroyPromise)return this.destroyPromise;return this.destroyPromise=(async()=>{this.log("销毁Agent..."),await this.activeOperations.shutdown("agent-destroy");try{await this.legacyMcpRegistry?.disconnectAll(),this.legacyMcpRegistry=void 0,this.log("Agent已销毁")}catch($){throw this.error("Agent销毁失败",$),$}finally{this.toolExecutor.dispose(),this.isInitialized=!1}})(),this.destroyPromise}syncRuntimeState(){if(!this.sessionRuntime)return;this.chatService=this.sessionRuntime.getChatService(),this.executionEngine=this.sessionRuntime.getExecutionEngine(),this.attachmentCollector=this.sessionRuntime.getAttachmentCollector(),this.currentModelId=this.sessionRuntime.getCurrentModelId(),this.currentModelMaxContextTokens=this.sessionRuntime.getCurrentModelMaxContextTokens()}generateTaskId(){return`task_${Date.now()}_${Math.random().toString(36).substring(2,9)}`}log($,J){s.debug(`[MainAgent] ${$}`,J||"")}error($,J){s.error(`[MainAgent] ${$}`,J||"")}async initializeSystemPrompt(){try{let $=this.runtimeOptions.systemPrompt,J=this.runtimeOptions.appendSystemPrompt,Z=await Z1({...this.sessionRuntime?.isRemoteWorkspace()?{workspaceAccess:"none"}:{projectPath:this.sessionRuntime?.workspaceRoot??C()},replaceDefault:$,append:J,includeEnvironment:!1,language:this.config.language,availableSkills:this.agentResources?.skills.generateAvailableSkillsList(),communicationStyle:this.sessionRuntime?.getCommunicationStyleConfiguration().selection,communicationStyleCatalog:this.sessionRuntime?.getCommunicationStyleCatalog(),projectRuleCatalog:this.sessionRuntime?.getProjectRuleCatalog(),...this.sessionRuntime?.isRemoteWorkspace()?{}:{projectInstructionSourcePath:this.sessionRuntime?.projectRoot},...this.sessionRuntime?{environmentOptions:{...x1,workingDirectory:this.sessionRuntime.executionRoot}}:{}});if(Z.prompt)this.log("系统提示配置验证成功"),s.debug(`[SystemPrompt] 可用来源: ${Z.sources.filter((Y)=>Y.loaded).map((Y)=>Y.name).join(", ")}`)}catch($){this.error("系统提示配置验证失败",$)}}async registerBuiltinTools(){try{let $=await v6({sessionId:"default",configDir:e(),workspaceRoot:C(),resourceRoot:C(),agentResources:this.agentResources});s.debug(`Registering ${$.length} builtin tools...`),this.toolExecutor.getRegistry().registerAll($);let J=this.toolExecutor.getRegistry().getAll().length;s.debug(`Builtin tools registered: ${J} tools`),s.debug(`[Tools] ${this.toolExecutor.getRegistry().getAll().map((Z)=>Z.name).join(", ")}`),await this.registerMcpTools()}catch($){throw s.error("Failed to register builtin tools:",$),$}}async registerMcpTools(){try{let $=await X6({workspaceRoot:C(),storeServers:this.config.mcpServers??{},cliConfigs:this.runtimeOptions.mcpConfig,strictCliConfig:this.runtimeOptions.strictMcpConfig});if(Object.keys($).length===0){s.debug("No MCP servers configured");return}let J=o0.createIsolated({artifactWriter:new o2(`legacy-${mK()}`)});this.legacyMcpRegistry=J;for(let[X,W]of Object.entries($))try{s.debug(`Connecting to MCP server: ${X}`),await J.registerServer(X,W),s.debug(`MCP server "${X}" connected`)}catch(V){s.warn(`Warning: MCP server "${X}" connection failed:`,V)}let Z=this.toolExecutor.getRegistry();Z.setMcpCatalogBarrier(()=>J.waitForCatalogIdle());let Y=J.getCatalogSnapshot();Z.replaceMcpTools(Y.tools),Z.registerAll(Z4(J));let Q=J.getInstructionsSnapshot();if(Z.queueMcpInstructionsChange({revision:Q.revision,reason:"snapshot",replace:!0,instructions:Q.instructions,removed:[]}),J.on("catalogChanged",(X)=>{Z.replaceMcpTools(X.tools,X)}),J.on("contentCatalogChanged",(X)=>{Z.queueMcpContentChange(X)}),J.on("resourceUpdated",(X)=>{Z.queueMcpResourceUpdated(X)}),J.on("connectionLifecycleChanged",(X)=>{Z.queueMcpConnectionChange(X)}),J.on("log",(X)=>{Z.queueMcpLog(X)}),J.on("instructionsChanged",(X)=>{Z.queueMcpInstructionsChange({revision:X.revision,reason:X.reason,replace:!1,instructions:X.action==="added"&&X.instruction?[{serverName:X.serverName,...X.instruction}]:[],removed:X.action==="removed"?[X.serverName]:[]})}),Y.tools.length>0)s.debug(`Registered ${Y.tools.length} MCP tools`),s.debug(`[MCP Tools] ${Y.tools.map((X)=>X.name).join(", ")}`)}catch($){s.warn("Failed to register MCP tools:",$)}}async loadSubagents(){let $=await d0(C());if(this.agentResources=k6($),this.subagentRegistry=this.agentResources.subagents,this.runtimeOptions.agents?.length)this.subagentRegistry.applyOverrides(this.runtimeOptions.agents);let J=this.subagentRegistry.getAllNames().length;if(J>0)s.debug(`Loaded ${J} subagents: ${this.subagentRegistry.getAllNames().join(", ")}`);else s.debug("No subagents configured")}applySkillToolRestrictions($){if(!this.activeSkillContext?.allowedTools)return $;let J=this.activeSkillContext.allowedTools;s.debug(`Applying Skill tool restrictions: ${J.join(", ")}`);let Z=$.filter((Y)=>{if(Y.name==="ReadPromptArtifact")return!0;return J.some((Q)=>{if(Q===Y.name)return!0;let X=Q.match(/^(\w+)\(.*\)$/);if(X&&X[1]===Y.name)return!0;return!1})});return s.debug(`Filtered tools: ${Z.map((Y)=>Y.name).join(", ")} (${Z.length}/${$.length})`),Z}clearSkillContext(){if(this.activeSkillContext)s.debug(`Skill "${this.activeSkillContext.skillName}" deactivated`),this.activeSkillContext=void 0}async processAtMentionsForContent($){if(!this.attachmentCollector)return $;if(typeof $==="string")return this.processAtMentions($);let J=[];for(let Y of $)if(Y.type==="text")J.push(Y.text);if(J.length===0)return $;let Z=J.join(`
876
876
  `);try{let Y=await this.attachmentCollector.collect(Z);if(Y.length===0)return $;s.debug(`Processed ${Y.length} @ file mentions in multimodal message`);let Q=this.buildAttachmentText(Y);if(!Q)return $;return[...$,{type:"text",text:Q}]}catch(Y){return s.error("Failed to process @ mentions in multimodal message:",Y),$}}buildAttachmentText($){let J=[],Z=[];for(let Q of $)if(Q.type==="file"){let X=Q.metadata?.lineRange?` (lines ${Q.metadata.lineRange.start}${Q.metadata.lineRange.end?`-${Q.metadata.lineRange.end}`:""})`:"";J.push(`<file path="${Q.path}"${X?` range="${X}"`:""}>`,Q.content,"</file>")}else if(Q.type==="directory")J.push(`<directory path="${Q.path}">`,Q.content,"</directory>");else if(Q.type==="error")Z.push(`- @${Q.path}: ${Q.error}`);let Y="";if(J.length>0)Y+=`
877
877
 
878
878
  <system-reminder>
@@ -1689,7 +1689,7 @@ ${Z}
1689
1689
  `)),{success:!0,message:"Schedules listed",content:H.join(`
1690
1690
  `)}}case"create":{let V=kF(X);if("error"in V)return Y.sendMessage(`创建失败:${V.error}`),{success:!1,error:V.error};let H={prompt:V.prompt,projectPath:W,trigger:V.trigger,isolation:"worktree",permissionMode:"default",enabled:!0};try{let U=await $.create(H),z=U.nextRunAt?new Date(U.nextRunAt).toLocaleString():"(无)";return Y.sendMessage(`[OK] 已创建定时任务 \`${U.id}\`
1691
1691
  ${C9(U.trigger)} · 下次运行: ${z}`),{success:!0,message:`Schedule ${U.id} created`}}catch(U){let z=U instanceof Error?U.message:String(U);return Y.sendMessage(`创建失败:${z}`),{success:!1,error:z}}}case"remove":case"rm":{let V=X[0];if(!V)return Y.sendMessage("用法:/schedule remove <id>"),{success:!1,error:"Missing schedule id"};let H=await $.remove(V);return Y.sendMessage(H?`[OK] 已删除 \`${V}\``:`未找到 \`${V}\``),{success:H,message:H?"Removed":"Not found"}}case"enable":case"disable":{let V=X[0];if(!V)return Y.sendMessage(`用法:/schedule ${Q} <id>`),{success:!1,error:"Missing schedule id"};let H=await $.setEnabled(V,Q==="enable");return Y.sendMessage(H?`[OK] 已${Q==="enable"?"启用":"停用"} \`${V}\``:`未找到 \`${V}\``),{success:Boolean(H),message:H?"Updated":"Not found"}}case"run":{let V=X[0];if(!V)return Y.sendMessage("用法:/schedule run <id>"),{success:!1,error:"Missing schedule id"};try{return await vF(V),Y.sendMessage(`[OK] 已触发 \`${V}\``),{success:!0,message:"Schedule triggered"}}catch(H){let U=H instanceof Error?H.message:String(H);return Y.sendMessage(`运行失败:${U}`),{success:!1,error:U}}}default:return Y.sendMessage(`未知子命令: ${Q}
1692
- 使用 /schedule 查看帮助`),{success:!1,error:`Unknown subcommand: ${Q}`}}}}}var DV=yF();import*as R2 from"node:fs/promises";import*as P2 from"node:path";async function LV($,J={}){let{maxResults:Z=20,caseSensitive:Y=!1,projectPath:Q,storagePath:X}=J,W=X??P4(Q??C());if(!X){let K=await IF($,Q??C(),Z,Y);if(K)return K}let V;try{V=(await R2.readdir(W)).filter((D)=>D.endsWith(".jsonl")&&!D.startsWith("agent_")).map((D)=>P2.join(W,D))}catch{return[]}let U=(await Promise.all(V.map(async(K)=>{try{let D=await R2.stat(K);return{path:K,mtime:D.mtimeMs}}catch{return null}}))).filter((K)=>K!==null).sort((K,D)=>D.mtime-K.mtime).map((K)=>K.path),z=[],B=Y?$:$.toLowerCase();for(let K of U){if(z.length>=Z)break;let D=P2.basename(K,".jsonl"),q=await xF(K,B,Y,D);if(z.push(...q),z.length>=Z){z.length=Z;break}}return z}async function IF($,J,Z,Y){try{let{syncAll:Q}=await import("./chunk-hb680ebj.js"),X=await FV();if(!X)return null;let{SessionService:W}=await import("./chunk-5vh8zyjz.js");await Q(X,W.projectionDeriverForSearch());let V=P2.resolve(J),H=OV(X,$,V,Z*4),U=Y?$:$.toLowerCase(),z=[];for(let B of H){if(B.role!=="user"&&B.role!=="assistant")continue;let K=T9(B.text,U,Y,B.session_id,B.role,B.timestamp??void 0,0);if(K)z.push(K);if(z.length>=Z)break}return z}catch{return null}}async function xF($,J,Z,Y){try{let Q=await R2.readFile($,"utf8"),W=Q.split(`
1692
+ 使用 /schedule 查看帮助`),{success:!1,error:`Unknown subcommand: ${Q}`}}}}}var DV=yF();import*as R2 from"node:fs/promises";import*as P2 from"node:path";async function LV($,J={}){let{maxResults:Z=20,caseSensitive:Y=!1,projectPath:Q,storagePath:X}=J,W=X??P4(Q??C());if(!X){let K=await IF($,Q??C(),Z,Y);if(K)return K}let V;try{V=(await R2.readdir(W)).filter((D)=>D.endsWith(".jsonl")&&!D.startsWith("agent_")).map((D)=>P2.join(W,D))}catch{return[]}let U=(await Promise.all(V.map(async(K)=>{try{let D=await R2.stat(K);return{path:K,mtime:D.mtimeMs}}catch{return null}}))).filter((K)=>K!==null).sort((K,D)=>D.mtime-K.mtime).map((K)=>K.path),z=[],B=Y?$:$.toLowerCase();for(let K of U){if(z.length>=Z)break;let D=P2.basename(K,".jsonl"),q=await xF(K,B,Y,D);if(z.push(...q),z.length>=Z){z.length=Z;break}}return z}async function IF($,J,Z,Y){try{let{syncAll:Q}=await import("./chunk-hb680ebj.js"),X=await FV();if(!X)return null;let{SessionService:W}=await import("./chunk-erget6wk.js");await Q(X,W.projectionDeriverForSearch());let V=P2.resolve(J),H=OV(X,$,V,Z*4),U=Y?$:$.toLowerCase(),z=[];for(let B of H){if(B.role!=="user"&&B.role!=="assistant")continue;let K=T9(B.text,U,Y,B.session_id,B.role,B.timestamp??void 0,0);if(K)z.push(K);if(z.length>=Z)break}return z}catch{return null}}async function xF($,J,Z,Y){try{let Q=await R2.readFile($,"utf8"),W=Q.split(`
1693
1693
  `).flatMap((B,K)=>{if(!B.trim())return[];try{return[{event:JSON.parse(B),index:K}]}catch{return[]}});if(!W.some(({event:B})=>B.type==="session_created"))return hF(W,J,Z,Y);let H=new Map(W.flatMap(({event:B,index:K})=>typeof B.id==="string"?[[B.id,K+1]]:[])),U=qV(wV(Q,$)),z=new Map;for(let B of U){if(B.type==="message_created"&&(B.data.role==="user"||B.data.role==="assistant"))z.set(B.data.messageId,{role:B.data.role,content:[],timestamp:B.timestamp,lineNumber:H.get(B.id)??0});if(B.type==="part_created"&&B.data.partType==="text"){let K=z.get(B.data.messageId),D=B.data.payload.text;if(K&&typeof D==="string")K.content.push(D)}}return[...z.values()].flatMap((B)=>{let K=T9(B.content.join(" "),J,Z,Y,B.role,B.timestamp,B.lineNumber);return K?[K]:[]})}catch{return[]}}function hF($,J,Z,Y){return $.flatMap(({event:Q,index:X})=>{if(Q.type!=="message")return[];let W=Q.message;if(W?.role!=="user"&&W?.role!=="assistant"||!W.content)return[];let V=typeof W.content==="string"?W.content:Array.isArray(W.content)?W.content.filter((U)=>typeof U==="object"&&U!==null&&U.type==="text"&&typeof U.text==="string").map((U)=>U.text).join(" "):"",H=T9(V,J,Z,Y,W.role,typeof Q.timestamp==="string"?Q.timestamp:void 0,X+1);return H?[H]:[]})}function T9($,J,Z,Y,Q,X,W){if(!$)return;let V=Z?$:$.toLowerCase();if(!V.includes(J))return;let H=V.indexOf(J),U=Math.max(0,H-80),z=Math.min($.length,H+J.length+80);return{sessionId:Y,role:Q,content:(U>0?"...":"")+$.slice(U,z).replace(/\n/g," ")+(z<$.length?"...":""),timestamp:X,lineNumber:W}}function _V($){if($.length===0)return"没有找到匹配的历史记录";let J=[`**找到 ${$.length} 条匹配:**
1694
1694
  `];for(let Z of $){let Y=Z.timestamp?new Date(Z.timestamp).toLocaleString("zh-CN",{timeZone:"Asia/Shanghai"}):"?",Q=Z.role==="user"?"\uD83D\uDC64":"\uD83E\uDD16";J.push(`${Q} \`${Z.sessionId.slice(0,8)}\` (${Y})`),J.push(` ${Z.content}`),J.push("")}return J.join(`
1695
1695
  `)}var gF={name:"search",description:"Search past session transcripts",fullDescription:"搜索历史会话记录,查找过去的对话内容",usage:"/search <keyword>",aliases:["find","history"],category:"Session",examples:['/search 断路器 - 搜索包含"断路器"的历史对话',"/search edit tool - 搜索 edit tool 相关讨论"],async handler($,J){let Z=i(J);if($.length===0)return Z.sendMessage("**用法:** `/search <关键词>`\n\n在历史会话中搜索包含指定关键词的对话"),{success:!0,message:"显示帮助"};let Y=$.join(" ");Z.sendMessage(`正在搜索: "${Y}" ...`);try{let Q=await LV(Y,{maxResults:15,projectPath:J.cwd}),X=_V(Q);return Z.sendMessage(X),{success:!0,message:`found ${Q.length} results`,data:{matches:Q.length}}}catch(Q){let X=Q instanceof Error?Q.message:"未知错误";return Z.sendMessage(`搜索失败: ${X}`),{success:!1,error:X}}}},NV=gF;var uF={name:"skills",description:"查看所有可用的 Skills",fullDescription:"显示所有已发现的 Skills 及其详细信息,包括名称、描述、来源和允许的工具。",usage:"/skills",category:"system",examples:["/skills"],handler:async($,J)=>{try{let Z=J.workspaceRoot??J.cwd;return await P$(Z,async(Y)=>{await Y.skills.refresh(),p1(Z),await m1(Z)}),{success:!0,message:"show_skills_manager",data:{action:"show_skills_manager"}}}catch(Z){let Y=`获取 Skills 失败: ${Z instanceof Error?Z.message:"未知错误"}`;return g().addAssistantMessage(Y),{success:!1,error:Y}}}},bV=uF;import dF from"node:path";function O8($){if($<1000)return`${$}ms`;let J=Math.floor($/1000);if(J<60)return`${J}s`;let Z=Math.floor(J/60);if(Z<60)return`${Z}m ${J%60}s`;return`${Math.floor(Z/60)}h ${Z%60}m`}function jV($){switch($){case"running":return"[RUNNING]";case"completed":case"exited":return"[OK]";case"failed":case"error":return"[FAIL]";case"killed":case"cancelled":return"[STOPPED]";default:return"[?]"}}function EV($,J){if($.length<=J)return $;return $.slice(0,J-3)+"..."}async function mF($,J){let Z=i(J),Y=$[0],Q=Y0.getInstance(),X=D0.getInstance(),W=J.sessionId??"",V=J.sessionId?{sessionId:J.sessionId,projectPath:dF.resolve(J.workspaceRoot??J.cwd)}:void 0;if(Y==="resume"){let D=$[1],q=$.slice(2).join(" ").trim();if(!D||!q)return{success:!1,error:"Usage: /tasks resume <agentId> <prompt>"};if(!J.subagents)return{success:!1,error:"This surface does not own a subagent runtime"};let w=await J.subagents.resume(D,q),O=`Resumed \`${D}\` as \`${w.session.id}\` (depth ${w.session.resumeDepth}).`;return Z.sendMessage(O),{success:!0,message:O,data:{action:"subagent_resumed",sourceAgentId:D,subagent:w.session}}}if(Y==="clean"){let D=X.cleanupExpiredSessionsForParent(V??W,0);return Z.sendMessage(`已清理 ${D} 个已完成的 Agent 会话`),{success:!0,message:`Cleaned ${D} agent sessions`}}let H=[`**后台任务列表**
@@ -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-6jjpj5ge.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-bzwxh6nq.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-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};