blade-code 0.10.206 → 0.11.1

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 (171) hide show
  1. package/dist/blade.js +2 -2
  2. package/dist/{chunk-erhaedch.js → chunk-06hkf59s.js} +1 -1
  3. package/dist/{chunk-dnpkf5mv.js → chunk-0b83mt1c.js} +2 -2
  4. package/dist/{chunk-3crwyd2r.js → chunk-0wcnkxe8.js} +2 -2
  5. package/dist/{chunk-gz84aewr.js → chunk-1beqtjsw.js} +1 -1
  6. package/dist/chunk-1kxpnt9q.js +1 -0
  7. package/dist/{chunk-az3rehz9.js → chunk-25s0c8km.js} +399 -392
  8. package/dist/{chunk-v5vx6nz9.js → chunk-27bjk35b.js} +1 -1
  9. package/dist/{chunk-65wc1h38.js → chunk-2ftyzk83.js} +1 -1
  10. package/dist/chunk-2g3v9qpz.js +1 -0
  11. package/dist/{chunk-q6abav45.js → chunk-2vrsfb8p.js} +59 -59
  12. package/dist/{chunk-h6ahwwpa.js → chunk-30p7aff1.js} +1 -1
  13. package/dist/{chunk-ewwrss2w.js → chunk-3kszepm6.js} +1 -1
  14. package/dist/{chunk-28tzj187.js → chunk-3y2x6fb6.js} +1 -1
  15. package/dist/chunk-43gg1wdc.js +1 -0
  16. package/dist/{chunk-67wy9mm7.js → chunk-447ps2te.js} +2 -2
  17. package/dist/{chunk-9kj19a8t.js → chunk-4cdk4mds.js} +1 -1
  18. package/dist/{chunk-nj6kpdte.js → chunk-5034apfz.js} +2 -2
  19. package/dist/{chunk-28n945me.js → chunk-5bc4hwt9.js} +2 -2
  20. package/dist/{chunk-t0gm0pn1.js → chunk-5yyp6njq.js} +1 -1
  21. package/dist/chunk-72wn385d.js +1 -0
  22. package/dist/{chunk-n5jzmwhy.js → chunk-7eset766.js} +2 -2
  23. package/dist/{chunk-793wjhvz.js → chunk-7vzz3rsx.js} +5 -5
  24. package/dist/{chunk-h4k69z1b.js → chunk-80946c9a.js} +1 -1
  25. package/dist/chunk-8emp6ysb.js +1 -0
  26. package/dist/chunk-8evyh5t0.js +1 -0
  27. package/dist/chunk-8hdtssvs.js +1 -0
  28. package/dist/{chunk-5k8k56f2.js → chunk-8n3jythp.js} +11 -9
  29. package/dist/{chunk-870szc6v.js → chunk-8sth12hd.js} +1 -1
  30. package/dist/{chunk-1n4v80hy.js → chunk-9qxch6sy.js} +1 -1
  31. package/dist/{chunk-09kqfdpa.js → chunk-9ydrwcpy.js} +2 -2
  32. package/dist/{chunk-p8vpvx07.js → chunk-9yn01a90.js} +1 -1
  33. package/dist/chunk-a1tt14a2.js +2 -0
  34. package/dist/{chunk-tsm8rhmd.js → chunk-a731hdwa.js} +1 -1
  35. package/dist/{chunk-pga8gxtf.js → chunk-a74ynw4t.js} +1 -1
  36. package/dist/chunk-b36egepz.js +1 -0
  37. package/dist/{chunk-yjjxv7fn.js → chunk-dxq7462e.js} +2 -2
  38. package/dist/{chunk-gmpsfkgg.js → chunk-f552hzcx.js} +1 -1
  39. package/dist/{chunk-ebpg1srd.js → chunk-f6hc7t65.js} +2 -2
  40. package/dist/{chunk-vx2g1faw.js → chunk-fqxzzsgr.js} +1 -1
  41. package/dist/{chunk-p2y1zqsb.js → chunk-g0hhqxpg.js} +2 -2
  42. package/dist/{chunk-ed2hdrwe.js → chunk-gzbb747a.js} +1 -1
  43. package/dist/{chunk-pdna2qvv.js → chunk-h8w3ahnk.js} +2 -2
  44. package/dist/{chunk-sbfe9vh3.js → chunk-hmw99nm1.js} +7 -7
  45. package/dist/chunk-hrtf7dba.js +2 -0
  46. package/dist/chunk-j7dx054r.js +1 -0
  47. package/dist/chunk-j9ppeg6v.js +1 -0
  48. package/dist/chunk-jemb0vwa.js +1 -0
  49. package/dist/{chunk-6xzk4hsg.js → chunk-m30qwpe9.js} +1 -1
  50. package/dist/{chunk-v4cxk10d.js → chunk-m70cnaeg.js} +1 -1
  51. package/dist/{chunk-826xegd8.js → chunk-m8te4s8f.js} +2 -2
  52. package/dist/chunk-ms0wve9g.js +14 -0
  53. package/dist/{chunk-n34qsnks.js → chunk-n8qg68y2.js} +1 -1
  54. package/dist/{chunk-e45r1a8r.js → chunk-pm5ssr7m.js} +2 -2
  55. package/dist/chunk-r9m3b170.js +1 -0
  56. package/dist/{chunk-1j39te3t.js → chunk-rt3f4xjz.js} +1 -1
  57. package/dist/{chunk-9sf1t8gw.js → chunk-s1cch8tt.js} +1 -1
  58. package/dist/{chunk-tzvb0nd2.js → chunk-sa9fxss4.js} +1 -1
  59. package/dist/{chunk-e0ft3vwg.js → chunk-ta99scbr.js} +1 -1
  60. package/dist/chunk-tf1qz4q6.js +1 -0
  61. package/dist/{chunk-0ef47wgr.js → chunk-tqt5c2f5.js} +2 -2
  62. package/dist/{chunk-fd0a8h55.js → chunk-ts5xzefm.js} +2 -2
  63. package/dist/{chunk-g7tphxme.js → chunk-v17q4bsd.js} +2 -2
  64. package/dist/{chunk-fnmqxhv1.js → chunk-v1k6nvth.js} +1 -1
  65. package/dist/{chunk-hv8nt7wj.js → chunk-vbjgcn49.js} +1 -1
  66. package/dist/{chunk-53vh6vpt.js → chunk-wcps5gjm.js} +1 -1
  67. package/dist/{chunk-av799ng5.js → chunk-xcj23spc.js} +2 -2
  68. package/dist/chunk-xcy45yxx.js +8 -0
  69. package/dist/{chunk-fc1gz532.js → chunk-xseh3f4m.js} +2 -2
  70. package/dist/{chunk-9tpzmy8v.js → chunk-xz7dddaj.js} +1 -1
  71. package/dist/{chunk-xcq0cehr.js → chunk-xzva8y4e.js} +3 -3
  72. package/dist/chunk-y0wc0hef.js +10 -0
  73. package/dist/{chunk-sqk8cnej.js → chunk-yrr9mdjn.js} +2 -2
  74. package/dist/{chunk-50vwafn5.js → chunk-zfxcef0z.js} +1 -1
  75. package/dist/{chunk-asgmmaec.js → chunk-zjezws85.js} +2 -2
  76. package/dist/web/assets/ChatView-BA3kB_z1.js +17 -0
  77. package/dist/web/assets/CodeBlockHighlighter-B5kcdVCA.js +8 -0
  78. package/dist/web/assets/FilePreview-BQid6G2-.js +8 -0
  79. package/dist/web/assets/KanbanBoard-CTR7bMLa.js +1 -0
  80. package/dist/web/assets/MarkdownRenderer-d7DdyYdx.js +30 -0
  81. package/dist/web/assets/ScrollArea-D1tPWHKZ.js +1 -0
  82. package/dist/web/assets/SessionHistorySurface-Cv_jRoJr.js +1 -0
  83. package/dist/web/assets/SettingsModal-CFa2uCzI.js +5 -0
  84. package/dist/web/assets/Sidebar-DrRNJOgU.js +1 -0
  85. package/dist/web/assets/TaskSwitcher-C9AKJrl-.js +1 -0
  86. package/dist/web/assets/TerminalPanel-BxBGcuB9.js +1 -0
  87. package/dist/web/assets/archive-DNa9b1YE.js +1 -0
  88. package/dist/web/assets/arrow-left-BQh8jlfT.js +1 -0
  89. package/dist/web/assets/calendar-clock-CC7FeYTg.js +1 -0
  90. package/dist/web/assets/chevron-right-6ZTOJE0p.js +1 -0
  91. package/dist/web/assets/clock-3-P2q6i6vm.js +1 -0
  92. package/dist/web/assets/copy-C-KvzjCC.js +1 -0
  93. package/dist/web/assets/dist-DiQNoDMg.js +11 -0
  94. package/dist/web/assets/download-CJHn20x1.js +1 -0
  95. package/dist/web/assets/folder-DmyFehXD.js +1 -0
  96. package/dist/web/assets/index-BVEiHNFk.css +1 -0
  97. package/dist/web/assets/index-D-oma3Je.js +11 -0
  98. package/dist/web/assets/message-square-plus-CKu9bFq3.js +1 -0
  99. package/dist/web/assets/pause-D2FxNG-w.js +1 -0
  100. package/dist/web/assets/pencil-D6HI7KC8.js +1 -0
  101. package/dist/web/assets/play-4jKCDYR-.js +1 -0
  102. package/dist/web/assets/plus-C4p8E1Nk.js +1 -0
  103. package/dist/web/assets/preload-helper-BC9Zf9qO.js +1 -0
  104. package/dist/web/assets/rolldown-runtime-hePW80VL.js +1 -0
  105. package/dist/web/assets/session-events-CvFfHkFA.js +23 -0
  106. package/dist/web/assets/settings-fWlqCZ-U.js +1 -0
  107. package/dist/web/assets/team-qGS2kixH.js +1 -0
  108. package/dist/web/assets/teamService-DfIvlI2_.js +1 -0
  109. package/dist/web/assets/terminal-DZkEoiSb.js +1 -0
  110. package/dist/web/assets/triangle-alert-Detl9fRQ.js +1 -0
  111. package/dist/web/assets/vendor-radix-CHeA_3Pt.js +41 -0
  112. package/dist/web/assets/vendor-react-hNfZDUf2.js +9 -0
  113. package/dist/web/assets/vendor-xterm-CANZO_wP.js +16 -0
  114. package/dist/web/assets/vendor-xterm-CHOd7Rch.css +1 -0
  115. package/dist/web/index.html +6 -4
  116. package/package.json +11 -10
  117. package/dist/chunk-514va7ce.js +0 -2
  118. package/dist/chunk-6p0hkf4f.js +0 -1
  119. package/dist/chunk-867bpjzg.js +0 -1
  120. package/dist/chunk-983hqzat.js +0 -1
  121. package/dist/chunk-af0m5227.js +0 -1
  122. package/dist/chunk-dpg006xj.js +0 -1
  123. package/dist/chunk-gpnkxh4c.js +0 -1
  124. package/dist/chunk-hpge30p8.js +0 -8
  125. package/dist/chunk-mtvbm7xe.js +0 -1
  126. package/dist/chunk-mys9mmcp.js +0 -1
  127. package/dist/chunk-new78c3h.js +0 -1
  128. package/dist/chunk-nng1xbsm.js +0 -10
  129. package/dist/chunk-pt0y4zrg.js +0 -14
  130. package/dist/chunk-r4em0ha7.js +0 -1
  131. package/dist/chunk-rdzbd5vk.js +0 -1
  132. package/dist/chunk-w6zat4v4.js +0 -1
  133. package/dist/chunk-wsd3rn0q.js +0 -1
  134. package/dist/chunk-yzf2jpam.js +0 -2
  135. package/dist/web/assets/ChatView-lUD-61n0.js +0 -70
  136. package/dist/web/assets/CodeBlockHighlighter--TbfcBxW.js +0 -8
  137. package/dist/web/assets/FilePreview-R6OKQPf2.js +0 -55
  138. package/dist/web/assets/KanbanBoard-BHOKtiv5.js +0 -16
  139. package/dist/web/assets/MarkdownRenderer-DqxNq8pa.js +0 -30
  140. package/dist/web/assets/ScrollArea-Dhu0B-zB.js +0 -1
  141. package/dist/web/assets/SessionHistorySurface-aZvoj3ma.js +0 -6
  142. package/dist/web/assets/SettingsModal-C7QBnIqa.js +0 -20
  143. package/dist/web/assets/Sidebar-Bznnq91x.js +0 -31
  144. package/dist/web/assets/TaskSwitcher-DJczhDRp.js +0 -26
  145. package/dist/web/assets/TerminalPanel-Vk4p0V3p.js +0 -6
  146. package/dist/web/assets/archive-0hLYBKQf.js +0 -6
  147. package/dist/web/assets/arrow-left-CXb6Gqf3.js +0 -6
  148. package/dist/web/assets/calendar-clock-DiaFI9Jk.js +0 -6
  149. package/dist/web/assets/chevron-right-CcPXH37D.js +0 -6
  150. package/dist/web/assets/clock-3-D6VR6gJc.js +0 -6
  151. package/dist/web/assets/copy-C3eUAQgp.js +0 -6
  152. package/dist/web/assets/download-DHvS9tI3.js +0 -6
  153. package/dist/web/assets/external-link-BDVaEuqY.js +0 -11
  154. package/dist/web/assets/folder-B80Ac6rr.js +0 -11
  155. package/dist/web/assets/index-B5mUEr6D.js +0 -11
  156. package/dist/web/assets/index-VwIiNjc8.css +0 -1
  157. package/dist/web/assets/index-YqughEZk.js +0 -211
  158. package/dist/web/assets/message-square-plus-D15quyPH.js +0 -21
  159. package/dist/web/assets/pause-BjMlj6Bx.js +0 -6
  160. package/dist/web/assets/pencil-BMoJvcB7.js +0 -6
  161. package/dist/web/assets/play-BHh4py3p.js +0 -6
  162. package/dist/web/assets/plus-DeFz_gQq.js +0 -6
  163. package/dist/web/assets/session-events-DCHBz9We.js +0 -25
  164. package/dist/web/assets/settings-CI8xbId2.js +0 -6
  165. package/dist/web/assets/team-zZ803hH9.js +0 -6
  166. package/dist/web/assets/teamService-CgLBXgmv.js +0 -1
  167. package/dist/web/assets/terminal-1WxSJ47E.js +0 -6
  168. package/dist/web/assets/vendor-radix-D6QrtXqd.js +0 -45
  169. package/dist/web/assets/vendor-react-DofNRwfy.js +0 -49
  170. package/dist/web/assets/vendor-xterm-9CEnUXvW.css +0 -32
  171. package/dist/web/assets/vendor-xterm-DuYZoU4T.js +0 -49
@@ -1 +1 @@
1
- import{eb as V,gb as W,hb as O,zb as J}from"./chunk-fc1gz532.js";import"./chunk-0ef47wgr.js";import"./chunk-28n945me.js";import"./chunk-53vh6vpt.js";import"./chunk-514va7ce.js";import{aj as Q}from"./chunk-6xzk4hsg.js";import"./chunk-09kqfdpa.js";import"./chunk-ed2hdrwe.js";import"./chunk-gmpsfkgg.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{Ab as J,fb as V,hb as W,ib as O}from"./chunk-xseh3f4m.js";import"./chunk-tqt5c2f5.js";import"./chunk-5bc4hwt9.js";import"./chunk-wcps5gjm.js";import{Yi as Q}from"./chunk-m30qwpe9.js";import"./chunk-hrtf7dba.js";import"./chunk-9ydrwcpy.js";import"./chunk-gzbb747a.js";import"./chunk-f552hzcx.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,2 +1,2 @@
1
- import{Wj as I}from"./chunk-yzf2jpam.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-a1tt14a2.js";import{Kk as f}from"./chunk-f552hzcx.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};
@@ -0,0 +1 @@
1
+ import{wf as a,xf as b}from"./chunk-ts5xzefm.js";import"./chunk-a1tt14a2.js";import"./chunk-f552hzcx.js";export{a as globalOptions,b as cliConfig};