blade-code 0.10.101 → 0.10.102

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 (68) hide show
  1. package/dist/blade.js +2 -2
  2. package/dist/{chunk-fvfc95g3.js → chunk-00rps629.js} +2 -2
  3. package/dist/{chunk-z5a8ay9s.js → chunk-19xfer55.js} +1 -1
  4. package/dist/{chunk-kdatgrjy.js → chunk-1wgese5c.js} +1 -1
  5. package/dist/chunk-4t3h306m.js +6 -0
  6. package/dist/{chunk-dcjh1cj6.js → chunk-6kb69vkx.js} +1 -1
  7. package/dist/{chunk-2f5kkhan.js → chunk-6r6yzw44.js} +404 -402
  8. package/dist/{chunk-zydvg30x.js → chunk-6yezrqe7.js} +1 -1
  9. package/dist/{chunk-zjpph3ys.js → chunk-9018357g.js} +1 -1
  10. package/dist/{chunk-9ajkzcqj.js → chunk-9b0896bm.js} +1 -1
  11. package/dist/{chunk-qjv5kz7q.js → chunk-9n5ystr6.js} +14 -14
  12. package/dist/{chunk-jvxskq6a.js → chunk-a5jv8pn9.js} +1 -1
  13. package/dist/{chunk-bswjne5v.js → chunk-a8mgzsh7.js} +1 -1
  14. package/dist/chunk-anez8ekm.js +169 -0
  15. package/dist/{chunk-z0dmm227.js → chunk-b8n5mx53.js} +1 -1
  16. package/dist/{chunk-tazb5tze.js → chunk-c3zcqqb7.js} +1 -1
  17. package/dist/{chunk-2191220r.js → chunk-cpk84yrx.js} +1 -1
  18. package/dist/chunk-cwnaydst.js +1 -0
  19. package/dist/{chunk-n5jfmzp2.js → chunk-d7rg6t0n.js} +1 -1
  20. package/dist/{chunk-cjgpas7y.js → chunk-enwtex3j.js} +5 -5
  21. package/dist/{chunk-f8z5v101.js → chunk-ffp2rn7f.js} +1 -1
  22. package/dist/{chunk-tp5bep1y.js → chunk-fn9cse83.js} +1 -1
  23. package/dist/{chunk-2cg8f38t.js → chunk-fpx3462x.js} +1 -1
  24. package/dist/chunk-gdp02sqp.js +1 -0
  25. package/dist/{chunk-3an3vxzt.js → chunk-hexj26gw.js} +1 -1
  26. package/dist/{chunk-mzab7qak.js → chunk-kfmh3t1r.js} +1 -1
  27. package/dist/{chunk-nh4jy5cs.js → chunk-kt5jqaxp.js} +1 -1
  28. package/dist/{chunk-b4d43ap3.js → chunk-kwkkcs4y.js} +1 -1
  29. package/dist/{chunk-ykf4cqpg.js → chunk-m4wnqx0e.js} +4 -4
  30. package/dist/{chunk-twhf09qs.js → chunk-na3jmz7f.js} +1 -1
  31. package/dist/{chunk-8yt4nmyb.js → chunk-pdqczfn3.js} +1 -1
  32. package/dist/{chunk-8z9d0zd0.js → chunk-qw57eqns.js} +1 -1
  33. package/dist/{chunk-fqbc1ppx.js → chunk-rkk39efr.js} +1 -1
  34. package/dist/{chunk-qgjgjzbx.js → chunk-ryemn19e.js} +1 -1
  35. package/dist/{chunk-wbf4qcws.js → chunk-v6hffjwc.js} +2 -2
  36. package/dist/{chunk-j22d84s7.js → chunk-vw328ehw.js} +1 -1
  37. package/dist/{chunk-kfcs62nw.js → chunk-xy5fmskp.js} +1 -1
  38. package/dist/{chunk-vc7gh3wc.js → chunk-y3anmree.js} +1 -1
  39. package/dist/chunk-yx4802a0.js +2 -0
  40. package/dist/{chunk-3c01jje5.js → chunk-zxhv8xfp.js} +1 -1
  41. package/dist/{chunk-c663rajb.js → chunk-zy6vm5jm.js} +1 -1
  42. package/dist/web/assets/ChatView-C5kVDWL0.js +58 -0
  43. package/dist/web/assets/{CodeBlockHighlighter-DZcVFtJE.js → CodeBlockHighlighter-BxJu15oF.js} +1 -1
  44. package/dist/web/assets/{FilePreview-CzNS6kfM.js → FilePreview-BDNq89O6.js} +1 -1
  45. package/dist/web/assets/{KanbanBoard-cdh2g0r0.js → KanbanBoard-CCn0j1Ow.js} +1 -1
  46. package/dist/web/assets/{MarkdownRenderer-BqBOUlXa.js → MarkdownRenderer-15FrKNPV.js} +3 -3
  47. package/dist/web/assets/{SettingsModal-meSWhCOP.js → SettingsModal-DCL04xT_.js} +1 -1
  48. package/dist/web/assets/{TaskSwitcher-CiQi64Yl.js → TaskSwitcher-Gyn_K98p.js} +1 -1
  49. package/dist/web/assets/{TerminalPanel-Bze9t5mz.js → TerminalPanel-Cbh0NmHM.js} +1 -1
  50. package/dist/web/assets/{arrow-left-DpTnLOBT.js → arrow-left-wfNAFD9Y.js} +1 -1
  51. package/dist/web/assets/{calendar-clock-DlAXXpl_.js → calendar-clock-BbbqqtLj.js} +1 -1
  52. package/dist/web/assets/{chevrons-up-down-CmAktdaR.js → chevrons-up-down-uCUY_a67.js} +1 -1
  53. package/dist/web/assets/{clock-3-_w8nIuEK.js → clock-3-DfiIeEEf.js} +1 -1
  54. package/dist/web/assets/{external-link-AlymrIfc.js → external-link-CilEshFB.js} +1 -1
  55. package/dist/web/assets/{folder-CrxO-9Rc.js → folder-D9K0ykgI.js} +1 -1
  56. package/dist/web/assets/{index-JJH0FKfo.js → index-BKBXGV6s.js} +7 -7
  57. package/dist/web/assets/{pause-GQZaG_P3.js → pause-D4a4_iHl.js} +1 -1
  58. package/dist/web/assets/{play-BPhmPVpi.js → play-D9guMjPv.js} +1 -1
  59. package/dist/web/assets/{session-events-CO2pRY9U.js → session-events-DelJesUm.js} +19 -19
  60. package/dist/web/assets/{teamService-BqS4iOx0.js → teamService-CAVeS_dL.js} +1 -1
  61. package/dist/web/index.html +2 -2
  62. package/package.json +1 -1
  63. package/dist/chunk-2r0f3b4t.js +0 -1
  64. package/dist/chunk-as2ezx8p.js +0 -1
  65. package/dist/chunk-hz5rsfxv.js +0 -2
  66. package/dist/chunk-sa7t9kht.js +0 -6
  67. package/dist/chunk-tc9rq0st.js +0 -160
  68. package/dist/web/assets/ChatView-Cc4bXZ6x.js +0 -58
@@ -1,4 +1,4 @@
1
- import{Xb as Xt,Yb as En,Zb as yn,_b as bn}from"./chunk-8hprmrd5.js";import{og as Bt}from"./chunk-dcjh1cj6.js";import{Ag as mt,Cg as rn,Dg as Tn,Eg as B,Fg as dn,Gg as on,Hg as pn,Ig as lt,Jg as un,Kg as cn,Lg as Mn,Ng as S,Qg as wn,Rg as Gt,Sg as Ut,Tg as h,Ug as Ht,tg as xt,ug as vi,vg as sn,wg as zt,xg as U,yg as en,zg as gt}from"./chunk-z5a8ay9s.js";import{Bh as x,zh as X}from"./chunk-czcxx8tb.js";import{Nh as It}from"./chunk-9sx3vsyj.js";import{Bi as tn,Ci as nn}from"./chunk-8z9d0zd0.js";import{Vi as ns}from"./chunk-w9xfks7f.js";import{EventEmitter as fs}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 Jt extends Error{issues;type;constructor(t,i,n="validation_error"){super(t);this.issues=i;this.type=n;this.name="ToolValidationError"}}function Vt(t,i){let n=X(t,i);if(n.success)return n.data;let s=n.error.issues.map((r)=>({field:r.path.length>0?r.path.join("."):"root",message:An(r),value:r.value})),e=s.length===1?`参数验证失败 [${s[0].field}]: ${s[0].message}`:`参数验证失败 (${s.length} 个错误):
1
+ import{Xb as Xt,Yb as En,Zb as yn,_b as bn}from"./chunk-8hprmrd5.js";import{og as Bt}from"./chunk-6kb69vkx.js";import{Ag as mt,Cg as rn,Dg as Tn,Eg as B,Fg as dn,Gg as on,Hg as pn,Ig as lt,Jg as un,Kg as cn,Lg as Mn,Ng as S,Qg as wn,Rg as Gt,Sg as Ut,Tg as h,Ug as Ht,tg as xt,ug as vi,vg as sn,wg as zt,xg as U,yg as en,zg as gt}from"./chunk-19xfer55.js";import{Bh as x,zh as X}from"./chunk-czcxx8tb.js";import{Nh as It}from"./chunk-9sx3vsyj.js";import{Bi as tn,Ci as nn}from"./chunk-qw57eqns.js";import{Vi as ns}from"./chunk-w9xfks7f.js";import{EventEmitter as fs}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 Jt extends Error{issues;type;constructor(t,i,n="validation_error"){super(t);this.issues=i;this.type=n;this.name="ToolValidationError"}}function Vt(t,i){let n=X(t,i);if(n.success)return n.data;let s=n.error.issues.map((r)=>({field:r.path.length>0?r.path.join("."):"root",message:An(r),value:r.value})),e=s.length===1?`参数验证失败 [${s[0].field}]: ${s[0].message}`:`参数验证失败 (${s.length} 个错误):
2
2
  ${s.map((r)=>` - ${r.field}: ${r.message}`).join(`
3
3
  `)}`;throw new Jt(e,s)}function st(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 s of n)st(s);else st(n)}function et(t){let i=JSON.parse(JSON.stringify(t,(n,s)=>n.startsWith("~")?void 0:s));return st(i),i}class rt{toolName;params;executeFn;descriptionFn;affectedPathsFn;isRetrySafe;constructor(t,i,n,s,e,r=!1){this.toolName=t;this.params=i;this.executeFn=n;this.descriptionFn=s;this.affectedPathsFn=e;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 s={signal:t,updateOutput:i,...n};return this.executeFn(this.params,s)}}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=et(t.schema),n=t.description.short;if(t.description.long)n+=`
4
4
 
@@ -0,0 +1 @@
1
+ import{oe as a,pe as b}from"./chunk-vw328ehw.js";import"./chunk-qw57eqns.js";import"./chunk-w9xfks7f.js";export{a as globalOptions,b as cliConfig};
@@ -1 +1 @@
1
- import{h as o}from"./chunk-f8z5v101.js";import"./chunk-8z9d0zd0.js";import"./chunk-w9xfks7f.js";import{execSync as r}from"child_process";var l={command:"update",describe:"Check for updates and install if available",handler:async()=>{console.log("Checking for updates...");try{let e=await o(!0);if(console.log(`Current version: ${e.currentVersion}`),e.error){console.log(`Warning: ${e.error}`);return}if(e.latestVersion)console.log(`Latest version: ${e.latestVersion}`);if(e.hasUpdate&&e.latestVersion){console.log(""),console.log(`\x1B[33mUpdate available: ${e.currentVersion} -> ${e.latestVersion}\x1B[0m`),console.log(""),console.log("Updating...");try{r("npm install -g blade-code@latest --registry https://registry.npmjs.org",{stdio:"inherit"}),console.log(""),console.log("Update complete!")}catch(t){console.error("Error: Update failed. Please run manually:"),console.error(" npm install -g blade-code@latest"),process.exit(1)}}else console.log("You are running the latest version of Blade")}catch(e){console.error(`Error: Failed to check for updates: ${e instanceof Error?e.message:"未知错误"}`),process.exit(1)}}};export{l as updateCommands};
1
+ import{h as o}from"./chunk-ffp2rn7f.js";import"./chunk-qw57eqns.js";import"./chunk-w9xfks7f.js";import{execSync as r}from"child_process";var l={command:"update",describe:"Check for updates and install if available",handler:async()=>{console.log("Checking for updates...");try{let e=await o(!0);if(console.log(`Current version: ${e.currentVersion}`),e.error){console.log(`Warning: ${e.error}`);return}if(e.latestVersion)console.log(`Latest version: ${e.latestVersion}`);if(e.hasUpdate&&e.latestVersion){console.log(""),console.log(`\x1B[33mUpdate available: ${e.currentVersion} -> ${e.latestVersion}\x1B[0m`),console.log(""),console.log("Updating...");try{r("npm install -g blade-code@latest --registry https://registry.npmjs.org",{stdio:"inherit"}),console.log(""),console.log("Update complete!")}catch(t){console.error("Error: Update failed. Please run manually:"),console.error(" npm install -g blade-code@latest"),process.exit(1)}}else console.log("You are running the latest version of Blade")}catch(e){console.error(`Error: Failed to check for updates: ${e instanceof Error?e.message:"未知错误"}`),process.exit(1)}}};export{l as updateCommands};
@@ -1 +1 @@
1
- import{Kd as a,Ld as b,Md as c,Nd as d,Od as e,Pd as f,Qd as g}from"./chunk-zydvg30x.js";import"./chunk-s0tq8gyx.js";import"./chunk-hpjnk87v.js";import"./chunk-2hb222re.js";import"./chunk-qcy79mva.js";import"./chunk-c6tq09mt.js";import"./chunk-maebpz1j.js";import"./chunk-9sx3vsyj.js";import"./chunk-d8wzc602.js";import"./chunk-k7vv9vne.js";import"./chunk-8z9d0zd0.js";import"./chunk-q3vza5gt.js";import"./chunk-w9xfks7f.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{Kd as a,Ld as b,Md as c,Nd as d,Od as e,Pd as f,Qd as g}from"./chunk-6yezrqe7.js";import"./chunk-s0tq8gyx.js";import"./chunk-hpjnk87v.js";import"./chunk-2hb222re.js";import"./chunk-qcy79mva.js";import"./chunk-c6tq09mt.js";import"./chunk-maebpz1j.js";import"./chunk-9sx3vsyj.js";import"./chunk-d8wzc602.js";import"./chunk-k7vv9vne.js";import"./chunk-qw57eqns.js";import"./chunk-q3vza5gt.js";import"./chunk-w9xfks7f.js";export{b as __setSessionSnapshotIOForTesting,c as __resetSessionSnapshotIOForTesting,g as SessionService,d as SessionMissingCreationError,e as SessionArchivedError,f as SessionArchiveConflictError,a as STALE_EMPTY_SESSION_AGE_MS};
@@ -1,4 +1,4 @@
1
- import{Xf as b1,Yf as L0,Zf as z1,cg as N0}from"./chunk-fvfc95g3.js";import{hg as jO,ig as wO}from"./chunk-qcy79mva.js";import{lg as A1}from"./chunk-p0rvgzpx.js";import{mg as b0,og as J0}from"./chunk-dcjh1cj6.js";import{qh as S0,rh as GO,vh as I0}from"./chunk-z5a8ay9s.js";import{Bh as L,Eh as c1,zh as u}from"./chunk-czcxx8tb.js";import{Nh as M}from"./chunk-9sx3vsyj.js";import{ni as k,oi as S}from"./chunk-d8wzc602.js";import{Bi as u0}from"./chunk-8z9d0zd0.js";import{Ii as N}from"./chunk-cp7xsjj2.js";import H1 from"node:path";import LO from"node:path";import v0 from"node:fs";import W0 from"node:os";import E from"node:path";import dO from"yaml";var U1=2000,V1=50,j1=1000,Y4={type:"object",properties:{verdict:{type:"string",enum:["pass","fail","partial"]},summary:{type:"string",minLength:1,maxLength:U1},findings:{type:"array",maxItems:V1,items:{type:"string",minLength:1,maxLength:j1}}},required:["verdict","summary","findings"],additionalProperties:!1};function F1(O,$){let Q=O.trim().replaceAll(/\s+/g," ");if($)Q=Q.replaceAll($,".");return Q.replace(/\bBearer\s+[^\s"'`]+/gi,"Bearer [redacted]").replace(/\bsk-[A-Za-z0-9_-]{8,}\b/g,"[redacted-key]").replace(/\b(api(?:[_-]?|\s+)key|access(?:[_-]?|\s+)token|authorization|cookie|password|passwd|refresh(?:[_-]?|\s+)token|secret|session(?:[_-]?|\s+)token)\b(\s*[:=]\s*)([^\s,;]+)/gi,"$1$2[redacted]")}function hO(O){if(O.length<=N0)return O;let $=" [verification feedback truncated]",Q=O.slice(0,N0-$.length);if(/[\uD800-\uDBFF]$/.test(Q))Q=Q.slice(0,-1);return Q.trimEnd()+$}function B1(O){if(!O||typeof O!=="object"||Array.isArray(O))return;let $=O;if($.verdict!=="pass"&&$.verdict!=="fail"&&$.verdict!=="partial"||typeof $.summary!=="string"||!$.summary.trim()||$.summary.length>U1||!Array.isArray($.findings)||$.findings.length>V1||!$.findings.every((Q)=>typeof Q==="string"&&Q.trim().length>0&&Q.length<=j1))return;return{verdict:$.verdict,summary:$.summary.trim(),findings:$.findings.map((Q)=>Q.trim())}}function X4(O,$){let Q=B1(O);if(!Q)return;let Z=F1(Q.summary,$),J=Q.findings.map((K)=>F1(K,$));return hO([Z,J.length>0?`Findings:
1
+ import{Xf as b1,Yf as L0,Zf as z1,cg as N0}from"./chunk-00rps629.js";import{hg as jO,ig as wO}from"./chunk-qcy79mva.js";import{lg as A1}from"./chunk-p0rvgzpx.js";import{mg as b0,og as J0}from"./chunk-6kb69vkx.js";import{qh as S0,rh as GO,vh as I0}from"./chunk-19xfer55.js";import{Bh as L,Eh as c1,zh as u}from"./chunk-czcxx8tb.js";import{Nh as M}from"./chunk-9sx3vsyj.js";import{ni as k,oi as S}from"./chunk-d8wzc602.js";import{Bi as u0}from"./chunk-qw57eqns.js";import{Ii as N}from"./chunk-cp7xsjj2.js";import H1 from"node:path";import LO from"node:path";import v0 from"node:fs";import W0 from"node:os";import E from"node:path";import dO from"yaml";var U1=2000,V1=50,j1=1000,Y4={type:"object",properties:{verdict:{type:"string",enum:["pass","fail","partial"]},summary:{type:"string",minLength:1,maxLength:U1},findings:{type:"array",maxItems:V1,items:{type:"string",minLength:1,maxLength:j1}}},required:["verdict","summary","findings"],additionalProperties:!1};function F1(O,$){let Q=O.trim().replaceAll(/\s+/g," ");if($)Q=Q.replaceAll($,".");return Q.replace(/\bBearer\s+[^\s"'`]+/gi,"Bearer [redacted]").replace(/\bsk-[A-Za-z0-9_-]{8,}\b/g,"[redacted-key]").replace(/\b(api(?:[_-]?|\s+)key|access(?:[_-]?|\s+)token|authorization|cookie|password|passwd|refresh(?:[_-]?|\s+)token|secret|session(?:[_-]?|\s+)token)\b(\s*[:=]\s*)([^\s,;]+)/gi,"$1$2[redacted]")}function hO(O){if(O.length<=N0)return O;let $=" [verification feedback truncated]",Q=O.slice(0,N0-$.length);if(/[\uD800-\uDBFF]$/.test(Q))Q=Q.slice(0,-1);return Q.trimEnd()+$}function B1(O){if(!O||typeof O!=="object"||Array.isArray(O))return;let $=O;if($.verdict!=="pass"&&$.verdict!=="fail"&&$.verdict!=="partial"||typeof $.summary!=="string"||!$.summary.trim()||$.summary.length>U1||!Array.isArray($.findings)||$.findings.length>V1||!$.findings.every((Q)=>typeof Q==="string"&&Q.trim().length>0&&Q.length<=j1))return;return{verdict:$.verdict,summary:$.summary.trim(),findings:$.findings.map((Q)=>Q.trim())}}function X4(O,$){let Q=B1(O);if(!Q)return;let Z=F1(Q.summary,$),J=Q.findings.map((K)=>F1(K,$));return hO([Z,J.length>0?`Findings:
2
2
  ${J.map((K)=>`- ${K}`).join(`
3
3
  `)}`:""].filter(Boolean).join(`
4
4
 
@@ -1 +1 @@
1
- import{Ka as V,Ma as W,Na as O,db as J}from"./chunk-hz5rsfxv.js";import"./chunk-czcxx8tb.js";import"./chunk-maebpz1j.js";import{Nh as Q}from"./chunk-9sx3vsyj.js";import"./chunk-d8wzc602.js";import"./chunk-q3vza5gt.js";import"./chunk-w9xfks7f.js";import F from"chalk";var K=(f)=>typeof f==="string"&&f.length>0?f:void 0;function X(f){let z=K(f.cron),G=K(f.every),H=K(f.at);if([z,G,H].filter(Boolean).length!==1)throw Error("Provide exactly one of --cron, --every, or --at");if(z)return{kind:"cron",cron:z};if(G){let P=V(G);if(!P)throw Error(`Invalid --every value "${G}" (use e.g. 30m, 2h, 1d)`);return{kind:"interval",intervalMs:P}}let N=new Date(H);if(Number.isNaN(N.getTime()))throw Error(`Invalid --at value "${H}" (use an ISO timestamp)`);return{kind:"once",runAt:N.toISOString()}}var Y={command:"create <prompt>",describe:"创建定时任务",builder:(f)=>f.positional("prompt",{type:"string",describe:"定时任务运行时发送给 Agent 的提示词",demandOption:!0}).option("cron",{type:"string",describe:"5 段 cron 表达式(本地时区)"}).option("every",{type:"string",describe:"间隔(如 30m、2h、1d)"}).option("at",{type:"string",describe:"一次性运行的 ISO 时间点"}).option("project-path",{alias:["projectPath","project"],type:"string",describe:"目标项目路径(默认当前目录)"}).option("title",{type:"string",describe:"定时任务标题"}).option("model",{alias:"m",type:"string",describe:"模型 ID"}).option("permission-mode",{type:"string",choices:["default","autoEdit","yolo","plan"],default:"default",describe:"权限模式"}).option("isolation",{type:"string",choices:["local","worktree"],default:"worktree",describe:"执行隔离方式"}).example([['$0 schedule create "跑测试并汇报失败" --every 1h',"每小时运行一次"],['$0 schedule create "生成每日站会摘要" --cron "0 9 * * 1-5"',"工作日 9 点运行"]]),handler:async(f)=>{try{let z=X(f),G=W(z);if(G)throw Error(G);let H={prompt:f.prompt,projectPath:K(f.projectPath)??Q(),title:K(f.title),trigger:z,modelId:K(f.model),isolation:K(f.isolation)??"worktree",permissionMode:K(f.permissionMode)??"default",enabled:!0},B=await J.create(H);console.log(F.green(`✓ 已创建定时任务 ${B.id}`)),console.log(` ${O(B.trigger)}`),console.log(` 项目: ${B.projectPath}`),console.log(` 下次运行: ${B.nextRunAt?new Date(B.nextRunAt).toLocaleString():"(无)"}`),process.exit(0)}catch(z){console.error(F.red(`创建定时任务失败: ${z instanceof Error?z.message:z}`)),process.exit(1)}}},Z={command:"list",aliases:["ls"],describe:"列出所有定时任务",handler:async()=>{let f=await J.list();if(f.length===0)console.log(F.dim("尚无定时任务。使用 `blade schedule create` 创建。")),process.exit(0);for(let z of f){let G=z.enabled?F.green("启用"):F.dim("停用"),H=z.nextRunAt?new Date(z.nextRunAt).toLocaleString():"—",B=z.lastRunAt?`${new Date(z.lastRunAt).toLocaleString()} (${z.lastStatus??"?"})`:"从未";console.log(`${F.cyan(z.id)} [${G}] ${z.title??z.prompt.slice(0,40)}`),console.log(` ${O(z.trigger)} · 下次: ${H} · 上次: ${B} · 运行 ${z.runCount} 次`),console.log(F.dim(` 项目: ${z.projectPath}`))}process.exit(0)}},_={command:"show <id>",describe:"查看定时任务详情",builder:(f)=>f.positional("id",{type:"string",describe:"定时任务 ID",demandOption:!0}),handler:async(f)=>{let z=await J.get(f.id);if(!z)console.error(F.red(`未找到定时任务 ${f.id}`)),process.exit(1);console.log(JSON.stringify(z,null,2)),process.exit(0)}},$={command:"remove <id>",aliases:["rm"],describe:"删除定时任务",builder:(f)=>f.positional("id",{type:"string",describe:"定时任务 ID",demandOption:!0}),handler:async(f)=>{if(!await J.remove(f.id))console.error(F.red(`未找到定时任务 ${f.id}`)),process.exit(1);console.log(F.green(`✓ 已删除定时任务 ${f.id}`)),process.exit(0)}},q={command:"enable <id>",describe:"启用定时任务",builder:(f)=>f.positional("id",{type:"string",describe:"定时任务 ID",demandOption:!0}),handler:async(f)=>{if(!await J.setEnabled(f.id,!0))console.error(F.red(`未找到定时任务 ${f.id}`)),process.exit(1);console.log(F.green(`✓ 已启用定时任务 ${f.id}`)),process.exit(0)}},x={command:"disable <id>",describe:"停用定时任务",builder:(f)=>f.positional("id",{type:"string",describe:"定时任务 ID",demandOption:!0}),handler:async(f)=>{if(!await J.setEnabled(f.id,!1))console.error(F.red(`未找到定时任务 ${f.id}`)),process.exit(1);console.log(F.green(`✓ 已停用定时任务 ${f.id}`)),process.exit(0)}},D={command:"run <id>",describe:"立即运行定时任务(需要 blade serve)",builder:(f)=>f.positional("id",{type:"string",describe:"定时任务 ID",demandOption:!0}).option("server",{type:"string",default:process.env.BLADE_SERVER_URL??"http://127.0.0.1:4097",describe:"Blade server 地址"}),handler:async(f)=>{let z=f.id,G=(K(f.server)??"http://127.0.0.1:4097").replace(/\/$/,""),H={};if(process.env.BLADE_SERVER_PASSWORD){let B=process.env.BLADE_SERVER_USERNAME??"blade";H.Authorization=`Basic ${Buffer.from(`${B}:${process.env.BLADE_SERVER_PASSWORD}`).toString("base64")}`}try{let B=await fetch(`${G}/schedules/${encodeURIComponent(z)}/run`,{method:"POST",headers:H});if(!B.ok){let N=await B.json().catch(()=>{return});throw Error(N?.error?.message??`Schedule run failed (${B.status})`)}console.log(F.green(`✓ 已触发定时任务 ${z}`)),process.exit(0)}catch(B){console.error(F.red(`运行定时任务失败: ${B instanceof Error?B.message:B}`)),process.exit(1)}}},R={command:"schedule",describe:"管理定时任务",builder:(f)=>f.command(Y).command(Z).command(_).command($).command(q).command(x).command(D).demandCommand(1,"请提供子命令:create | list | show | remove | enable | disable | run"),handler:()=>{}};export{R as scheduleCommands};
1
+ import{Ka as V,Ma as W,Na as O,db as J}from"./chunk-yx4802a0.js";import"./chunk-czcxx8tb.js";import"./chunk-maebpz1j.js";import{Nh as Q}from"./chunk-9sx3vsyj.js";import"./chunk-d8wzc602.js";import"./chunk-q3vza5gt.js";import"./chunk-w9xfks7f.js";import F from"chalk";var K=(f)=>typeof f==="string"&&f.length>0?f:void 0;function X(f){let z=K(f.cron),G=K(f.every),H=K(f.at);if([z,G,H].filter(Boolean).length!==1)throw Error("Provide exactly one of --cron, --every, or --at");if(z)return{kind:"cron",cron:z};if(G){let P=V(G);if(!P)throw Error(`Invalid --every value "${G}" (use e.g. 30m, 2h, 1d)`);return{kind:"interval",intervalMs:P}}let N=new Date(H);if(Number.isNaN(N.getTime()))throw Error(`Invalid --at value "${H}" (use an ISO timestamp)`);return{kind:"once",runAt:N.toISOString()}}var Y={command:"create <prompt>",describe:"创建定时任务",builder:(f)=>f.positional("prompt",{type:"string",describe:"定时任务运行时发送给 Agent 的提示词",demandOption:!0}).option("cron",{type:"string",describe:"5 段 cron 表达式(本地时区)"}).option("every",{type:"string",describe:"间隔(如 30m、2h、1d)"}).option("at",{type:"string",describe:"一次性运行的 ISO 时间点"}).option("project-path",{alias:["projectPath","project"],type:"string",describe:"目标项目路径(默认当前目录)"}).option("title",{type:"string",describe:"定时任务标题"}).option("model",{alias:"m",type:"string",describe:"模型 ID"}).option("permission-mode",{type:"string",choices:["default","autoEdit","yolo","plan"],default:"default",describe:"权限模式"}).option("isolation",{type:"string",choices:["local","worktree"],default:"worktree",describe:"执行隔离方式"}).example([['$0 schedule create "跑测试并汇报失败" --every 1h',"每小时运行一次"],['$0 schedule create "生成每日站会摘要" --cron "0 9 * * 1-5"',"工作日 9 点运行"]]),handler:async(f)=>{try{let z=X(f),G=W(z);if(G)throw Error(G);let H={prompt:f.prompt,projectPath:K(f.projectPath)??Q(),title:K(f.title),trigger:z,modelId:K(f.model),isolation:K(f.isolation)??"worktree",permissionMode:K(f.permissionMode)??"default",enabled:!0},B=await J.create(H);console.log(F.green(`✓ 已创建定时任务 ${B.id}`)),console.log(` ${O(B.trigger)}`),console.log(` 项目: ${B.projectPath}`),console.log(` 下次运行: ${B.nextRunAt?new Date(B.nextRunAt).toLocaleString():"(无)"}`),process.exit(0)}catch(z){console.error(F.red(`创建定时任务失败: ${z instanceof Error?z.message:z}`)),process.exit(1)}}},Z={command:"list",aliases:["ls"],describe:"列出所有定时任务",handler:async()=>{let f=await J.list();if(f.length===0)console.log(F.dim("尚无定时任务。使用 `blade schedule create` 创建。")),process.exit(0);for(let z of f){let G=z.enabled?F.green("启用"):F.dim("停用"),H=z.nextRunAt?new Date(z.nextRunAt).toLocaleString():"—",B=z.lastRunAt?`${new Date(z.lastRunAt).toLocaleString()} (${z.lastStatus??"?"})`:"从未";console.log(`${F.cyan(z.id)} [${G}] ${z.title??z.prompt.slice(0,40)}`),console.log(` ${O(z.trigger)} · 下次: ${H} · 上次: ${B} · 运行 ${z.runCount} 次`),console.log(F.dim(` 项目: ${z.projectPath}`))}process.exit(0)}},_={command:"show <id>",describe:"查看定时任务详情",builder:(f)=>f.positional("id",{type:"string",describe:"定时任务 ID",demandOption:!0}),handler:async(f)=>{let z=await J.get(f.id);if(!z)console.error(F.red(`未找到定时任务 ${f.id}`)),process.exit(1);console.log(JSON.stringify(z,null,2)),process.exit(0)}},$={command:"remove <id>",aliases:["rm"],describe:"删除定时任务",builder:(f)=>f.positional("id",{type:"string",describe:"定时任务 ID",demandOption:!0}),handler:async(f)=>{if(!await J.remove(f.id))console.error(F.red(`未找到定时任务 ${f.id}`)),process.exit(1);console.log(F.green(`✓ 已删除定时任务 ${f.id}`)),process.exit(0)}},q={command:"enable <id>",describe:"启用定时任务",builder:(f)=>f.positional("id",{type:"string",describe:"定时任务 ID",demandOption:!0}),handler:async(f)=>{if(!await J.setEnabled(f.id,!0))console.error(F.red(`未找到定时任务 ${f.id}`)),process.exit(1);console.log(F.green(`✓ 已启用定时任务 ${f.id}`)),process.exit(0)}},x={command:"disable <id>",describe:"停用定时任务",builder:(f)=>f.positional("id",{type:"string",describe:"定时任务 ID",demandOption:!0}),handler:async(f)=>{if(!await J.setEnabled(f.id,!1))console.error(F.red(`未找到定时任务 ${f.id}`)),process.exit(1);console.log(F.green(`✓ 已停用定时任务 ${f.id}`)),process.exit(0)}},D={command:"run <id>",describe:"立即运行定时任务(需要 blade serve)",builder:(f)=>f.positional("id",{type:"string",describe:"定时任务 ID",demandOption:!0}).option("server",{type:"string",default:process.env.BLADE_SERVER_URL??"http://127.0.0.1:4097",describe:"Blade server 地址"}),handler:async(f)=>{let z=f.id,G=(K(f.server)??"http://127.0.0.1:4097").replace(/\/$/,""),H={};if(process.env.BLADE_SERVER_PASSWORD){let B=process.env.BLADE_SERVER_USERNAME??"blade";H.Authorization=`Basic ${Buffer.from(`${B}:${process.env.BLADE_SERVER_PASSWORD}`).toString("base64")}`}try{let B=await fetch(`${G}/schedules/${encodeURIComponent(z)}/run`,{method:"POST",headers:H});if(!B.ok){let N=await B.json().catch(()=>{return});throw Error(N?.error?.message??`Schedule run failed (${B.status})`)}console.log(F.green(`✓ 已触发定时任务 ${z}`)),process.exit(0)}catch(B){console.error(F.red(`运行定时任务失败: ${B instanceof Error?B.message:B}`)),process.exit(1)}}},R={command:"schedule",describe:"管理定时任务",builder:(f)=>f.command(Y).command(Z).command(_).command($).command(q).command(x).command(D).demandCommand(1,"请提供子命令:create | list | show | remove | enable | disable | run"),handler:()=>{}};export{R as scheduleCommands};