blade-code 0.10.12 → 0.10.13

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 (45) hide show
  1. package/dist/blade.js +2 -2
  2. package/dist/{chunk-cscm57tr.js → chunk-097zrzyy.js} +1 -1
  3. package/dist/{chunk-2wkt2w3f.js → chunk-0q7pvmvz.js} +1 -1
  4. package/dist/{chunk-2mmbqha8.js → chunk-45wpygt9.js} +1 -1
  5. package/dist/{chunk-vwwf7p7x.js → chunk-4em4jxj5.js} +1 -1
  6. package/dist/{chunk-86shv4yp.js → chunk-5vgjhqk9.js} +1 -1
  7. package/dist/{chunk-pz21tcah.js → chunk-5wnxafpf.js} +1 -1
  8. package/dist/{chunk-tadbcnwr.js → chunk-74wm5qnw.js} +1 -1
  9. package/dist/{chunk-zd3qxc5p.js → chunk-7s99zkve.js} +1 -1
  10. package/dist/{chunk-p5zstj8j.js → chunk-820ek28g.js} +1 -1
  11. package/dist/{chunk-4faz5tkt.js → chunk-8p5a371t.js} +1 -1
  12. package/dist/{chunk-vszmbnjh.js → chunk-8yypkbew.js} +1 -1
  13. package/dist/{chunk-e65vyfj7.js → chunk-97fyx4hr.js} +1 -1
  14. package/dist/{chunk-pmvfkre2.js → chunk-9ac3eajy.js} +1 -1
  15. package/dist/{chunk-vpz57h5x.js → chunk-a3mwn9zj.js} +1 -1
  16. package/dist/{chunk-86w8fd67.js → chunk-ab4sp3m4.js} +2 -2
  17. package/dist/{chunk-9e8fyt60.js → chunk-c477j84k.js} +1 -1
  18. package/dist/{chunk-jh4571hm.js → chunk-c9m16hqc.js} +1 -1
  19. package/dist/{chunk-evn886hs.js → chunk-cx0tdprs.js} +1 -1
  20. package/dist/{chunk-eqr25kxv.js → chunk-cy6emyt9.js} +1 -1
  21. package/dist/{chunk-vdgskayb.js → chunk-hf3dwmfa.js} +1 -1
  22. package/dist/{chunk-k7caqeew.js → chunk-j4rfyz81.js} +1 -1
  23. package/dist/{chunk-670th5hb.js → chunk-j8fkhkan.js} +1 -1
  24. package/dist/{chunk-63rg3mhn.js → chunk-k653znk8.js} +1 -1
  25. package/dist/{chunk-y2j96b3t.js → chunk-ke4n1nv5.js} +1 -1
  26. package/dist/{chunk-e2s6czgg.js → chunk-kfgv64hg.js} +1 -1
  27. package/dist/chunk-m6sg36pw.js +1 -0
  28. package/dist/{chunk-04wd6zez.js → chunk-nsxkd8bq.js} +1 -1
  29. package/dist/{chunk-pqgw6t9b.js → chunk-nysyp11q.js} +3 -3
  30. package/dist/{chunk-21zwc98r.js → chunk-p42cz164.js} +1 -1
  31. package/dist/{chunk-hb8krnp5.js → chunk-pmz455nq.js} +1 -1
  32. package/dist/{chunk-95zwz4q8.js → chunk-x9t4ryyf.js} +1 -1
  33. package/dist/{chunk-z24sj1r8.js → chunk-xjyctv33.js} +1 -1
  34. package/dist/{chunk-vaxcmm72.js → chunk-zgg0y0sy.js} +1 -1
  35. package/dist/web/assets/{ChatView-DG6MMrFK.js → ChatView-ucu62nNl.js} +6 -6
  36. package/dist/web/assets/{CodeBlockHighlighter-Cf3DBUGk.js → CodeBlockHighlighter-GS19h8wb.js} +1 -1
  37. package/dist/web/assets/{FilePreview-LvuYnyjv.js → FilePreview-BIjFuDdg.js} +1 -1
  38. package/dist/web/assets/{MarkdownRenderer-CkSbe36j.js → MarkdownRenderer-D-NrQgb1.js} +3 -3
  39. package/dist/web/assets/{SettingsModal-DBsb7E9J.js → SettingsModal-BNz9vyER.js} +1 -1
  40. package/dist/web/assets/{TaskSwitcher-Z0KWY8g9.js → TaskSwitcher-HnRA3Mj8.js} +1 -1
  41. package/dist/web/assets/{TerminalPanel-DVWTlxtd.js → TerminalPanel-Df2CK9n_.js} +1 -1
  42. package/dist/web/assets/{index-DWtXGF3o.js → index-DWTihvUI.js} +3 -3
  43. package/dist/web/index.html +1 -1
  44. package/package.json +1 -1
  45. package/dist/chunk-14rzj7js.js +0 -1
package/dist/blade.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import{Ac as W}from"./chunk-vpz57h5x.js";import{Dc as F,Ec as M}from"./chunk-ktf3bpmw.js";import"./chunk-z24sj1r8.js";import"./chunk-vmq248m7.js";import"./chunk-ybvdac8k.js";import"./chunk-e2s6czgg.js";import"./chunk-7wjy6kgt.js";import{de as T}from"./chunk-4dq9y7zn.js";import"./chunk-pz21tcah.js";import"./chunk-3aqdjrtm.js";import"./chunk-kvx3sb3z.js";import"./chunk-f4z3gkbs.js";import{hf as N,if as B}from"./chunk-5s123nbs.js";import"./chunk-s5666ta0.js";import"./chunk-dsj62dcg.js";import"./chunk-eqr25kxv.js";import"./chunk-gav4hxcv.js";import"./chunk-afkhzdfc.js";import"./chunk-363pgv1e.js";import{Mf as J}from"./chunk-g11hq0e5.js";import v from"node:path";var E=process.argv.slice(2),I=u(E),p=I!==null;if(I!==null)T.setGlobalDebug(I);function u(Q){for(let Y=0;Y<Q.length;Y+=1){let U=Q[Y];if(U==="--debug"||U==="-d"){let X=Q[Y+1];return X&&!X.startsWith("-")?X:!0}if(U.startsWith("--debug="))return U.slice(8)||!0}return null}function c(Q){return Q.length===1&&(Q[0]==="--version"||Q[0]==="-V")}function q(Q,...Y){return Q.some((U)=>Y.some((X)=>U===X||U.startsWith(`${X}=`)))}function m(Q,...Y){let U=[];for(let X=0;X<Q.length;X+=1){let G=Q[X],z=Y.find(($)=>G.startsWith(`${$}=`));if(z){let $=G.slice(z.length+1);if($)U.push($);continue}if(Y.includes(G)){let $=Q[X+1];if($&&!$.startsWith("-"))U.push($),X+=1}}return U}async function t(){if(c(E)){let{getVersion:K}=await import("./chunk-04wd6zez.js");console.log(K());return}let Q=process.cwd(),Y=F(Q);M(Y),N(B());let U=m(E,"--plugin-dir","--pluginDir");if(U.length>0){let{configureInvocationPluginDirs:K}=await import("./chunk-86shv4yp.js");K(U.map((Z)=>v.resolve(Q,Z)))}if(q(E,"--trust-workspace","--trustWorkspace")){let{WorkspaceTrustService:K}=await import("./chunk-fvrmjhz5.js");await K.getInstance().trust(B())}if(process.getuid&&process.getuid()===0){let K=!!process.env.SUDO_USER,Z=!!process.env.BLADE_ALLOW_ROOT;if(K&&!Z)console.error(""),console.error("Error: 请不要使用 sudo 运行 blade"),console.error(""),console.error("原因:"),console.error(" 使用 sudo 会创建属于 root 的配置文件,"),console.error(" 导致普通用户无法访问。"),console.error(""),console.error("正确用法:"),console.error(" blade # 直接运行,不要加 sudo"),console.error(""),console.error("如果遇到权限错误,请运行:"),console.error(" sudo chown -R $USER:$USER ~/.blade/"),console.error(""),console.error("如果你确实需要以 root 运行(容器/CI),设置环境变量:"),console.error(" BLADE_ALLOW_ROOT=1 blade"),console.error(""),process.exit(1)}if(q(E,"--headless")){let{handleHeadlessMode:K}=await import("./chunk-k7caqeew.js");if(await K())return}if(W(),q(E,"--print","-p")){let{handlePrintMode:K}=await import("./chunk-pmvfkre2.js");if(await K())return}if(E.includes("--acp")){let{runAcpIntegration:K}=await import("./chunk-y2j96b3t.js");await K();return}let[{default:X},{hideBin:G},{cliConfig:z,globalOptions:$},{loadConfiguration:_,validateOutput:D,validatePermissions:R},{doctorCommands:S},{installCommands:k},{mcpCommands:O},{projectsCommands:y},{scheduleCommands:b},{serveCommand:V},{updateCommands:P},{webCommand:x}]=await Promise.all([import("yargs"),import("yargs/helpers"),import("./chunk-14rzj7js.js"),import("./chunk-zd3qxc5p.js"),import("./chunk-86w8fd67.js"),import("./chunk-74shfpve.js"),import("./chunk-2wkt2w3f.js"),import("./chunk-mtk2tf9n.js"),import("./chunk-4zs5r4n4.js"),import("./chunk-2mmbqha8.js"),import("./chunk-xx1d9kfd.js"),import("./chunk-670th5hb.js")]),A=X(G(process.argv)).scriptName(z.scriptName).usage(z.usage).version(z.version).locale(z.locale).showHelpOnFail(z.showHelpOnFail).demandCommand(0,"").recommendCommands().strict(z.strict).parserConfiguration({"populate--":!0}).options($).middleware([_,R,D]).command(O).command(y).command(b).command(S).command(P).command(k).command(x).command(V).completion("completion",!1).help("help","Show help").alias("help","h").alias("version","V").fail((K,Z,L)=>{if(Z){if(console.error("An error occurred:"),console.error(Z.message),p&&Z.stack)console.error(`
2
+ import{Ac as W}from"./chunk-a3mwn9zj.js";import{Dc as F,Ec as M}from"./chunk-ktf3bpmw.js";import"./chunk-xjyctv33.js";import"./chunk-vmq248m7.js";import"./chunk-ybvdac8k.js";import"./chunk-kfgv64hg.js";import"./chunk-7wjy6kgt.js";import{de as T}from"./chunk-4dq9y7zn.js";import"./chunk-5wnxafpf.js";import"./chunk-3aqdjrtm.js";import"./chunk-kvx3sb3z.js";import"./chunk-f4z3gkbs.js";import{hf as N,if as B}from"./chunk-5s123nbs.js";import"./chunk-s5666ta0.js";import"./chunk-dsj62dcg.js";import"./chunk-cy6emyt9.js";import"./chunk-gav4hxcv.js";import"./chunk-afkhzdfc.js";import"./chunk-363pgv1e.js";import{Mf as J}from"./chunk-g11hq0e5.js";import v from"node:path";var E=process.argv.slice(2),I=u(E),p=I!==null;if(I!==null)T.setGlobalDebug(I);function u(Q){for(let Y=0;Y<Q.length;Y+=1){let U=Q[Y];if(U==="--debug"||U==="-d"){let X=Q[Y+1];return X&&!X.startsWith("-")?X:!0}if(U.startsWith("--debug="))return U.slice(8)||!0}return null}function c(Q){return Q.length===1&&(Q[0]==="--version"||Q[0]==="-V")}function q(Q,...Y){return Q.some((U)=>Y.some((X)=>U===X||U.startsWith(`${X}=`)))}function m(Q,...Y){let U=[];for(let X=0;X<Q.length;X+=1){let G=Q[X],z=Y.find(($)=>G.startsWith(`${$}=`));if(z){let $=G.slice(z.length+1);if($)U.push($);continue}if(Y.includes(G)){let $=Q[X+1];if($&&!$.startsWith("-"))U.push($),X+=1}}return U}async function t(){if(c(E)){let{getVersion:K}=await import("./chunk-nsxkd8bq.js");console.log(K());return}let Q=process.cwd(),Y=F(Q);M(Y),N(B());let U=m(E,"--plugin-dir","--pluginDir");if(U.length>0){let{configureInvocationPluginDirs:K}=await import("./chunk-5vgjhqk9.js");K(U.map((Z)=>v.resolve(Q,Z)))}if(q(E,"--trust-workspace","--trustWorkspace")){let{WorkspaceTrustService:K}=await import("./chunk-fvrmjhz5.js");await K.getInstance().trust(B())}if(process.getuid&&process.getuid()===0){let K=!!process.env.SUDO_USER,Z=!!process.env.BLADE_ALLOW_ROOT;if(K&&!Z)console.error(""),console.error("Error: 请不要使用 sudo 运行 blade"),console.error(""),console.error("原因:"),console.error(" 使用 sudo 会创建属于 root 的配置文件,"),console.error(" 导致普通用户无法访问。"),console.error(""),console.error("正确用法:"),console.error(" blade # 直接运行,不要加 sudo"),console.error(""),console.error("如果遇到权限错误,请运行:"),console.error(" sudo chown -R $USER:$USER ~/.blade/"),console.error(""),console.error("如果你确实需要以 root 运行(容器/CI),设置环境变量:"),console.error(" BLADE_ALLOW_ROOT=1 blade"),console.error(""),process.exit(1)}if(q(E,"--headless")){let{handleHeadlessMode:K}=await import("./chunk-j4rfyz81.js");if(await K())return}if(W(),q(E,"--print","-p")){let{handlePrintMode:K}=await import("./chunk-9ac3eajy.js");if(await K())return}if(E.includes("--acp")){let{runAcpIntegration:K}=await import("./chunk-ke4n1nv5.js");await K();return}let[{default:X},{hideBin:G},{cliConfig:z,globalOptions:$},{loadConfiguration:_,validateOutput:D,validatePermissions:R},{doctorCommands:S},{installCommands:k},{mcpCommands:O},{projectsCommands:y},{scheduleCommands:b},{serveCommand:V},{updateCommands:P},{webCommand:x}]=await Promise.all([import("yargs"),import("yargs/helpers"),import("./chunk-m6sg36pw.js"),import("./chunk-7s99zkve.js"),import("./chunk-ab4sp3m4.js"),import("./chunk-74shfpve.js"),import("./chunk-0q7pvmvz.js"),import("./chunk-mtk2tf9n.js"),import("./chunk-4zs5r4n4.js"),import("./chunk-45wpygt9.js"),import("./chunk-xx1d9kfd.js"),import("./chunk-j8fkhkan.js")]),A=X(G(process.argv)).scriptName(z.scriptName).usage(z.usage).version(z.version).locale(z.locale).showHelpOnFail(z.showHelpOnFail).demandCommand(0,"").recommendCommands().strict(z.strict).parserConfiguration({"populate--":!0}).options($).middleware([_,R,D]).command(O).command(y).command(b).command(S).command(P).command(k).command(x).command(V).completion("completion",!1).help("help","Show help").alias("help","h").alias("version","V").fail((K,Z,L)=>{if(Z){if(console.error("An error occurred:"),console.error(Z.message),p&&Z.stack)console.error(`
3
3
  Stack trace:`),console.error(Z.stack);else console.error(`
4
4
  Run with --debug to show the stack trace.`);process.exit(1)}if(K)console.error("Error: Invalid arguments:"),console.error(K),console.error(`
5
- Hint: Did you mean:`),L.showHelp(),process.exit(1)}).command("$0",!1,()=>{},async(K)=>{let Z=K._.slice(1),L=Z.length>0?Z.join(" "):void 0,h=import("./chunk-hxp5qs1x.js").then(({checkVersionOnStartup:C})=>C()),[{render:w},{createElement:f},{AppWrapper:j}]=await Promise.all([import("ink"),import("react"),import("./chunk-vwwf7p7x.js")]),H={...K,initialMessage:L,debug:K.debug,print:Boolean(K.print),versionCheckPromise:h};delete H._,delete H.$0,delete H.message,w(f(j,H),{patchConsole:!0,exitOnCtrlC:!1,alternateBuffer:!1})});try{await A.parse()}catch(K){console.error("Error: Parse error:",K),process.exit(1)}}if(J.main==J.module)t().catch(console.error);export{t as main};
5
+ Hint: Did you mean:`),L.showHelp(),process.exit(1)}).command("$0",!1,()=>{},async(K)=>{let Z=K._.slice(1),L=Z.length>0?Z.join(" "):void 0,h=import("./chunk-hxp5qs1x.js").then(({checkVersionOnStartup:C})=>C()),[{render:w},{createElement:f},{AppWrapper:j}]=await Promise.all([import("ink"),import("react"),import("./chunk-4em4jxj5.js")]),H={...K,initialMessage:L,debug:K.debug,print:Boolean(K.print),versionCheckPromise:h};delete H._,delete H.$0,delete H.message,w(f(j,H),{patchConsole:!0,exitOnCtrlC:!1,alternateBuffer:!1})});try{await A.parse()}catch(K){console.error("Error: Parse error:",K),process.exit(1)}}if(J.main==J.module)t().catch(console.error);export{t as main};
@@ -1 +1 @@
1
- import{$b as f,Wb as a,Xb as b,Yb as c,Zb as d,_b as e}from"./chunk-e65vyfj7.js";import"./chunk-4hawehmd.js";import"./chunk-8j01ssaf.js";import"./chunk-heqs3xan.js";import"./chunk-7wjy6kgt.js";import"./chunk-4dq9y7zn.js";import"./chunk-f4z3gkbs.js";import"./chunk-5s123nbs.js";import"./chunk-dsj62dcg.js";import"./chunk-eqr25kxv.js";import"./chunk-363pgv1e.js";import"./chunk-g11hq0e5.js";export{a as __setSessionSnapshotIOForTesting,b as __resetSessionSnapshotIOForTesting,f as SessionService,c as SessionMissingCreationError,d as SessionArchivedError,e as SessionArchiveConflictError};
1
+ import{$b as f,Wb as a,Xb as b,Yb as c,Zb as d,_b as e}from"./chunk-97fyx4hr.js";import"./chunk-4hawehmd.js";import"./chunk-8j01ssaf.js";import"./chunk-heqs3xan.js";import"./chunk-7wjy6kgt.js";import"./chunk-4dq9y7zn.js";import"./chunk-f4z3gkbs.js";import"./chunk-5s123nbs.js";import"./chunk-dsj62dcg.js";import"./chunk-cy6emyt9.js";import"./chunk-363pgv1e.js";import"./chunk-g11hq0e5.js";export{a as __setSessionSnapshotIOForTesting,b as __resetSessionSnapshotIOForTesting,f as SessionService,c as SessionMissingCreationError,d as SessionArchivedError,e as SessionArchiveConflictError};
@@ -1,4 +1,4 @@
1
- import{ka as H}from"./chunk-9e8fyt60.js";import"./chunk-095x2ykj.js";import{Zc as $,dd as T}from"./chunk-z24sj1r8.js";import"./chunk-vmq248m7.js";import"./chunk-ybvdac8k.js";import"./chunk-e2s6czgg.js";import"./chunk-7wjy6kgt.js";import"./chunk-4dq9y7zn.js";import"./chunk-pz21tcah.js";import"./chunk-3aqdjrtm.js";import"./chunk-kvx3sb3z.js";import"./chunk-f4z3gkbs.js";import{if as k}from"./chunk-5s123nbs.js";import"./chunk-s5666ta0.js";import"./chunk-dsj62dcg.js";import"./chunk-eqr25kxv.js";import"./chunk-gav4hxcv.js";import"./chunk-afkhzdfc.js";import"./chunk-363pgv1e.js";import"./chunk-g11hq0e5.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{ka as H}from"./chunk-c477j84k.js";import"./chunk-095x2ykj.js";import{Zc as $,dd as T}from"./chunk-xjyctv33.js";import"./chunk-vmq248m7.js";import"./chunk-ybvdac8k.js";import"./chunk-kfgv64hg.js";import"./chunk-7wjy6kgt.js";import"./chunk-4dq9y7zn.js";import"./chunk-5wnxafpf.js";import"./chunk-3aqdjrtm.js";import"./chunk-kvx3sb3z.js";import"./chunk-f4z3gkbs.js";import{if as k}from"./chunk-5s123nbs.js";import"./chunk-s5666ta0.js";import"./chunk-dsj62dcg.js";import"./chunk-cy6emyt9.js";import"./chunk-gav4hxcv.js";import"./chunk-afkhzdfc.js";import"./chunk-363pgv1e.js";import"./chunk-g11hq0e5.js";import U from"os";import J from"path";function X(z){return typeof z==="string"?z:void 0}function N(z){if(!Array.isArray(z))return;let q=[];for(let K of z)if(typeof K==="string")q.push(K);else if(K!=null)q.push(String(K));return q}function b(){console.log(`
2
2
  blade mcp
3
3
  `),console.log(`管理 MCP 服务器
4
4
  `),console.log("Commands:"),console.log(" blade mcp add <name> <commandOrUrl> [args...] 添加 MCP 服务器"),console.log(" blade mcp remove <name> 删除 MCP 服务器 [aliases: rm]"),console.log(" blade mcp list 列出所有 MCP 服务器并检查健康状态 [aliases: ls]"),console.log(" blade mcp get <name> 获取服务器详情"),console.log(" blade mcp login <name> 登录远程 MCP OAuth"),console.log(" blade mcp logout <name> 清除远程 MCP OAuth 凭证"),console.log(` blade mcp add-json <name> <json> 从 JSON 字符串添加服务器
@@ -1 +1 @@
1
- import{f as y,g as A,h as C,i as D}from"./chunk-p5zstj8j.js";import"./chunk-r76wc1cn.js";import"./chunk-z8c5rhdh.js";import"./chunk-tadbcnwr.js";import"./chunk-vszmbnjh.js";import"./chunk-pqgw6t9b.js";import"./chunk-9e8fyt60.js";import"./chunk-p4zt7ts9.js";import"./chunk-21zwc98r.js";import"./chunk-095x2ykj.js";import"./chunk-e65vyfj7.js";import"./chunk-4hawehmd.js";import"./chunk-ktf3bpmw.js";import{Vc as q}from"./chunk-z24sj1r8.js";import"./chunk-vmq248m7.js";import"./chunk-ybvdac8k.js";import"./chunk-ah97bmns.js";import"./chunk-2mzcxq6c.js";import"./chunk-8j01ssaf.js";import"./chunk-63rg3mhn.js";import"./chunk-evn886hs.js";import"./chunk-9tnaads5.js";import"./chunk-heqs3xan.js";import"./chunk-dpt56hah.js";import"./chunk-e2s6czgg.js";import"./chunk-7wjy6kgt.js";import"./chunk-4dq9y7zn.js";import"./chunk-pz21tcah.js";import"./chunk-3aqdjrtm.js";import"./chunk-kvx3sb3z.js";import"./chunk-f4z3gkbs.js";import"./chunk-5s123nbs.js";import"./chunk-s5666ta0.js";import"./chunk-dsj62dcg.js";import"./chunk-eqr25kxv.js";import"./chunk-gav4hxcv.js";import"./chunk-afkhzdfc.js";import"./chunk-363pgv1e.js";import"./chunk-g11hq0e5.js";import H from"chalk";var R={command:"serve",describe:"Start a headless Blade server (no browser)",builder:y,handler:async(E)=>{let f=A(E);if(await q(),!process.env.BLADE_SERVER_PASSWORD)console.log(H.yellow("Warning: BLADE_SERVER_PASSWORD is not set; server is unsecured."));let b=await D.listenAsync(f);if(console.log(`Blade server listening on http://${b.hostname}:${b.port}`),f.hostname==="0.0.0.0"){let F=C();for(let G of F)console.log(` Network: http://${G}:${b.port}`)}await new Promise(()=>{}),await b.stop()}};export{R as serveCommand};
1
+ import{f as y,g as A,h as C,i as D}from"./chunk-820ek28g.js";import"./chunk-r76wc1cn.js";import"./chunk-z8c5rhdh.js";import"./chunk-74wm5qnw.js";import"./chunk-8yypkbew.js";import"./chunk-nysyp11q.js";import"./chunk-c477j84k.js";import"./chunk-p4zt7ts9.js";import"./chunk-p42cz164.js";import"./chunk-095x2ykj.js";import"./chunk-97fyx4hr.js";import"./chunk-4hawehmd.js";import"./chunk-ktf3bpmw.js";import{Vc as q}from"./chunk-xjyctv33.js";import"./chunk-vmq248m7.js";import"./chunk-ybvdac8k.js";import"./chunk-ah97bmns.js";import"./chunk-2mzcxq6c.js";import"./chunk-8j01ssaf.js";import"./chunk-k653znk8.js";import"./chunk-cx0tdprs.js";import"./chunk-9tnaads5.js";import"./chunk-heqs3xan.js";import"./chunk-dpt56hah.js";import"./chunk-kfgv64hg.js";import"./chunk-7wjy6kgt.js";import"./chunk-4dq9y7zn.js";import"./chunk-5wnxafpf.js";import"./chunk-3aqdjrtm.js";import"./chunk-kvx3sb3z.js";import"./chunk-f4z3gkbs.js";import"./chunk-5s123nbs.js";import"./chunk-s5666ta0.js";import"./chunk-dsj62dcg.js";import"./chunk-cy6emyt9.js";import"./chunk-gav4hxcv.js";import"./chunk-afkhzdfc.js";import"./chunk-363pgv1e.js";import"./chunk-g11hq0e5.js";import H from"chalk";var R={command:"serve",describe:"Start a headless Blade server (no browser)",builder:y,handler:async(E)=>{let f=A(E);if(await q(),!process.env.BLADE_SERVER_PASSWORD)console.log(H.yellow("Warning: BLADE_SERVER_PASSWORD is not set; server is unsecured."));let b=await D.listenAsync(f);if(console.log(`Blade server listening on http://${b.hostname}:${b.port}`),f.hostname==="0.0.0.0"){let F=C();for(let G of F)console.log(` Network: http://${G}:${b.port}`)}await new Promise(()=>{}),await b.stop()}};export{R as serveCommand};
@@ -1,4 +1,4 @@
1
- import{b as cJ,c as xJ,d as uJ}from"./chunk-732n8xj6.js";import{j as t9,k as s9}from"./chunk-r76wc1cn.js";import{r as p8}from"./chunk-tadbcnwr.js";import{$ as h4,F as O$,H as R4,I as M4,L as $8,M as FJ,N as HJ,Q as WJ,R as LJ,W as L6,X as B6,Y as JY,Z as j4,ba as K6,t as G6,w as s2,x as a2,y as t4,z as QY}from"./chunk-pqgw6t9b.js";import{fa as M9,ga as C9,ha as I9,ka as $Y}from"./chunk-9e8fyt60.js";import"./chunk-p4zt7ts9.js";import{Va as x4,hb as u2}from"./chunk-21zwc98r.js";import{sb as Y8}from"./chunk-095x2ykj.js";import{$b as M0,Fb as E4,Kb as D8,Sb as T4,Tb as x2,Ub as v4,Yb as e$}from"./chunk-e65vyfj7.js";import"./chunk-4hawehmd.js";import{xc as mJ}from"./chunk-632rgzcf.js";import{Bc as I1,yc as Z8,zc as c8}from"./chunk-vpz57h5x.js";import"./chunk-ktf3bpmw.js";import{Fc as M$,Gc as d0,Hc as t1,Ic as RQ,Jc as k$,Kc as V8,Lc as a6,Mc as uQ,Nc as u9,Oc as i6,Pc as T$,Qc as Q1,Rc as sJ,Sc as r0,Tc as gJ,Uc as b2,Vc as Q8,Yc as D4,dd as m0}from"./chunk-z24sj1r8.js";import"./chunk-vmq248m7.js";import"./chunk-ybvdac8k.js";import"./chunk-ah97bmns.js";import{nd as lQ}from"./chunk-2mzcxq6c.js";import"./chunk-8j01ssaf.js";import"./chunk-63rg3mhn.js";import{Fd as NJ,Ld as eJ,wd as F6,zd as TJ}from"./chunk-evn886hs.js";import"./chunk-9tnaads5.js";import"./chunk-heqs3xan.js";import"./chunk-dpt56hah.js";import{$d as U1,Zd as IQ}from"./chunk-e2s6czgg.js";import"./chunk-7wjy6kgt.js";import{be as oJ,ee as o1}from"./chunk-4dq9y7zn.js";import{Ie as nJ,Se as _J,Te as tJ}from"./chunk-pz21tcah.js";import"./chunk-3aqdjrtm.js";import"./chunk-kvx3sb3z.js";import{cf as S$,df as j8,ef as TQ}from"./chunk-f4z3gkbs.js";import{if as u0}from"./chunk-5s123nbs.js";import{jf as i9,kf as o9,nf as D1}from"./chunk-s5666ta0.js";import"./chunk-dsj62dcg.js";import{zf as h9}from"./chunk-eqr25kxv.js";import{Af as sQ}from"./chunk-gav4hxcv.js";import"./chunk-afkhzdfc.js";import"./chunk-363pgv1e.js";import{Mf as CQ}from"./chunk-g11hq0e5.js";import{useMemoizedFn as f2}from"ahooks";import{useEffect as DX,useState as k2}from"react";import{useMemoizedFn as t0}from"ahooks";import{Box as K$}from"ink";import{useEffect as q$,useMemo as CX,useRef as I2}from"react";import{useShallow as ZY}from"zustand/react/shallow";import{useStore as YY}from"zustand";function Q0($){return YY(T$,$)}var XY=[],v$=()=>Q0(($)=>$.session.sessionId),C1=()=>Q0(($)=>$.session.workspaceRoot),eQ=()=>Q0(($)=>$.session.messages),$4=()=>Q0(($)=>$.session.clearCount),Q4=()=>Q0(($)=>$.session.isCompacting),J4=()=>Q0(($)=>$.session.tokenUsage.estimatedCostUsd),r1=()=>Q0(($)=>$.session.actions),Y4=()=>Q0(($)=>{let{inputTokens:Q,maxContextTokens:Y}=$.session.tokenUsage;if(Y<=0)return 100;let J=Math.max(0,100-Q/Y*100);return Math.round(J)}),Z4=()=>Q0(($)=>$.app.initializationStatus),X4=()=>Q0(($)=>$.app.initializationError),P8=()=>Q0(($)=>$.app.activeModal),G4=()=>Q0(($)=>$.app.tasks),K4=()=>Q0(($)=>$.app.modelEditorTarget),q4=()=>Q0(($)=>$.app.sessionSelectorData),U4=()=>Q0(($)=>$.app.awaitingSecondCtrlC),a1=()=>Q0(($)=>$.app.actions),y8=()=>Q0(($)=>$.app.initializationStatus==="ready"),z4=()=>Q0(($)=>$.app.tasks.length>0),f$=()=>Q0(($)=>$.config.config?.permissionMode||"default"),O4=()=>Q0(($)=>$.config.config?.models??XY),R8=()=>Q0(($)=>{let Q=$.config.config;if(!Q)return;let Y=Q.currentModelId;return Q.models.find((Z)=>Z.id===Y)??Q.models[0]}),M8=()=>Q0(($)=>$.config.config?.currentModelId),A0=()=>Q0(($)=>{return d0.getTheme()}),_4=()=>Q0(($)=>$.config.config?.theme??"default"),$1=()=>Q0(($)=>$.focus.currentFocus),N4=()=>Q0(($)=>$.focus.actions),i1=()=>Q0(($)=>$.command.isProcessing),F4=()=>Q0(($)=>$.command.actions),C8=()=>Q0(($)=>$.command.pendingCommands),H4=()=>Q0(($)=>$.command.recoveredSteeringCount),I8=()=>Q0(($)=>$.app.thinkingModeEnabled),T8=()=>Q0(($)=>$.app.reasoningEffort),v8=()=>Q0(($)=>$.app.serviceTier),f8=()=>Q0(($)=>$.app.responseVerbosity),k8=()=>Q0(($)=>$.app.communicationStyle),W4=()=>Q0(($)=>$.session.currentThinkingContent),L4=()=>Q0(($)=>$.session.thinkingExpanded),B4=()=>Q0(($)=>$.session.currentStreamingMessageId),w4=()=>Q0(ZY(($)=>({lines:$.session.currentStreamingLines,tail:$.session.currentStreamingTail,lineCount:$.session.currentStreamingLineCount,version:$.session.currentStreamingVersion}))),b4=()=>Q0(($)=>$.session.finalizingStreamingMessageId),A4=()=>Q0(($)=>$.session.historyExpanded),P4=()=>Q0(($)=>$.session.expandedMessageCount);import{useMemoizedFn as V$}from"ahooks";import{useEffect as p2,useRef as c4}from"react";function GY($){if(!($ instanceof Error))return"未知错误";let J=$.lastError??$;if(J.responseBody)try{let G=JSON.parse(J.responseBody)?.error?.message;if(G){let K=J.statusCode?` (HTTP ${J.statusCode})`:"";return`${G}${K}`}}catch{}let Z=$.message.match(/Last error:\s*(.+)$/);if(Z)return Z[1];return $.message}function KY($){if(!($ instanceof Error))return!1;return $.name==="AbortError"||$.message.includes("aborted")}function qY($){if(!($ instanceof Error))return!1;let Q=$.message;return Q.includes("can only concatenate str")||Q.includes("image_url")||Q.includes("multimodal")||Q.includes("vision")||Q.includes("does not support images")}function S8($){let Q=KY($),Y=qY($),J;if(Y)J="当前模型不支持图片理解功能。请切换到支持视觉能力的模型(如 Claude 4.5、GPT-5.2、Gemini 3 Pro、Qwen3-VL-Plus 等)后重试。";else J=GY($);return{displayMessage:J,isAbort:Q,isVisionNotSupported:Y}}import{appendFileSync as UY,mkdirSync as zY,writeFileSync as OY}from"node:fs";import _Y from"node:os";import j2 from"node:path";var y4=null;function NY(){let $=process.env.BLADE_STORAGE_ROOT||j2.join(_Y.homedir(),".blade");return j2.join($,"logs","stream-debug.log")}function FY($){if(y4===$)return;let Q=j2.dirname($);zY(Q,{recursive:!0,mode:493}),OY($,`=== Stream Debug Log Started: ${new Date().toISOString()} ===
1
+ import{b as cJ,c as xJ,d as uJ}from"./chunk-732n8xj6.js";import{j as t9,k as s9}from"./chunk-r76wc1cn.js";import{r as p8}from"./chunk-74wm5qnw.js";import{$ as h4,F as O$,H as R4,I as M4,L as $8,M as FJ,N as HJ,Q as WJ,R as LJ,W as L6,X as B6,Y as JY,Z as j4,ba as K6,t as G6,w as s2,x as a2,y as t4,z as QY}from"./chunk-nysyp11q.js";import{fa as M9,ga as C9,ha as I9,ka as $Y}from"./chunk-c477j84k.js";import"./chunk-p4zt7ts9.js";import{Va as x4,hb as u2}from"./chunk-p42cz164.js";import{sb as Y8}from"./chunk-095x2ykj.js";import{$b as M0,Fb as E4,Kb as D8,Sb as T4,Tb as x2,Ub as v4,Yb as e$}from"./chunk-97fyx4hr.js";import"./chunk-4hawehmd.js";import{xc as mJ}from"./chunk-632rgzcf.js";import{Bc as I1,yc as Z8,zc as c8}from"./chunk-a3mwn9zj.js";import"./chunk-ktf3bpmw.js";import{Fc as M$,Gc as d0,Hc as t1,Ic as RQ,Jc as k$,Kc as V8,Lc as a6,Mc as uQ,Nc as u9,Oc as i6,Pc as T$,Qc as Q1,Rc as sJ,Sc as r0,Tc as gJ,Uc as b2,Vc as Q8,Yc as D4,dd as m0}from"./chunk-xjyctv33.js";import"./chunk-vmq248m7.js";import"./chunk-ybvdac8k.js";import"./chunk-ah97bmns.js";import{nd as lQ}from"./chunk-2mzcxq6c.js";import"./chunk-8j01ssaf.js";import"./chunk-k653znk8.js";import{Fd as NJ,Ld as eJ,wd as F6,zd as TJ}from"./chunk-cx0tdprs.js";import"./chunk-9tnaads5.js";import"./chunk-heqs3xan.js";import"./chunk-dpt56hah.js";import{$d as U1,Zd as IQ}from"./chunk-kfgv64hg.js";import"./chunk-7wjy6kgt.js";import{be as oJ,ee as o1}from"./chunk-4dq9y7zn.js";import{Ie as nJ,Se as _J,Te as tJ}from"./chunk-5wnxafpf.js";import"./chunk-3aqdjrtm.js";import"./chunk-kvx3sb3z.js";import{cf as S$,df as j8,ef as TQ}from"./chunk-f4z3gkbs.js";import{if as u0}from"./chunk-5s123nbs.js";import{jf as i9,kf as o9,nf as D1}from"./chunk-s5666ta0.js";import"./chunk-dsj62dcg.js";import{zf as h9}from"./chunk-cy6emyt9.js";import{Af as sQ}from"./chunk-gav4hxcv.js";import"./chunk-afkhzdfc.js";import"./chunk-363pgv1e.js";import{Mf as CQ}from"./chunk-g11hq0e5.js";import{useMemoizedFn as f2}from"ahooks";import{useEffect as DX,useState as k2}from"react";import{useMemoizedFn as t0}from"ahooks";import{Box as K$}from"ink";import{useEffect as q$,useMemo as CX,useRef as I2}from"react";import{useShallow as ZY}from"zustand/react/shallow";import{useStore as YY}from"zustand";function Q0($){return YY(T$,$)}var XY=[],v$=()=>Q0(($)=>$.session.sessionId),C1=()=>Q0(($)=>$.session.workspaceRoot),eQ=()=>Q0(($)=>$.session.messages),$4=()=>Q0(($)=>$.session.clearCount),Q4=()=>Q0(($)=>$.session.isCompacting),J4=()=>Q0(($)=>$.session.tokenUsage.estimatedCostUsd),r1=()=>Q0(($)=>$.session.actions),Y4=()=>Q0(($)=>{let{inputTokens:Q,maxContextTokens:Y}=$.session.tokenUsage;if(Y<=0)return 100;let J=Math.max(0,100-Q/Y*100);return Math.round(J)}),Z4=()=>Q0(($)=>$.app.initializationStatus),X4=()=>Q0(($)=>$.app.initializationError),P8=()=>Q0(($)=>$.app.activeModal),G4=()=>Q0(($)=>$.app.tasks),K4=()=>Q0(($)=>$.app.modelEditorTarget),q4=()=>Q0(($)=>$.app.sessionSelectorData),U4=()=>Q0(($)=>$.app.awaitingSecondCtrlC),a1=()=>Q0(($)=>$.app.actions),y8=()=>Q0(($)=>$.app.initializationStatus==="ready"),z4=()=>Q0(($)=>$.app.tasks.length>0),f$=()=>Q0(($)=>$.config.config?.permissionMode||"default"),O4=()=>Q0(($)=>$.config.config?.models??XY),R8=()=>Q0(($)=>{let Q=$.config.config;if(!Q)return;let Y=Q.currentModelId;return Q.models.find((Z)=>Z.id===Y)??Q.models[0]}),M8=()=>Q0(($)=>$.config.config?.currentModelId),A0=()=>Q0(($)=>{return d0.getTheme()}),_4=()=>Q0(($)=>$.config.config?.theme??"default"),$1=()=>Q0(($)=>$.focus.currentFocus),N4=()=>Q0(($)=>$.focus.actions),i1=()=>Q0(($)=>$.command.isProcessing),F4=()=>Q0(($)=>$.command.actions),C8=()=>Q0(($)=>$.command.pendingCommands),H4=()=>Q0(($)=>$.command.recoveredSteeringCount),I8=()=>Q0(($)=>$.app.thinkingModeEnabled),T8=()=>Q0(($)=>$.app.reasoningEffort),v8=()=>Q0(($)=>$.app.serviceTier),f8=()=>Q0(($)=>$.app.responseVerbosity),k8=()=>Q0(($)=>$.app.communicationStyle),W4=()=>Q0(($)=>$.session.currentThinkingContent),L4=()=>Q0(($)=>$.session.thinkingExpanded),B4=()=>Q0(($)=>$.session.currentStreamingMessageId),w4=()=>Q0(ZY(($)=>({lines:$.session.currentStreamingLines,tail:$.session.currentStreamingTail,lineCount:$.session.currentStreamingLineCount,version:$.session.currentStreamingVersion}))),b4=()=>Q0(($)=>$.session.finalizingStreamingMessageId),A4=()=>Q0(($)=>$.session.historyExpanded),P4=()=>Q0(($)=>$.session.expandedMessageCount);import{useMemoizedFn as V$}from"ahooks";import{useEffect as p2,useRef as c4}from"react";function GY($){if(!($ instanceof Error))return"未知错误";let J=$.lastError??$;if(J.responseBody)try{let G=JSON.parse(J.responseBody)?.error?.message;if(G){let K=J.statusCode?` (HTTP ${J.statusCode})`:"";return`${G}${K}`}}catch{}let Z=$.message.match(/Last error:\s*(.+)$/);if(Z)return Z[1];return $.message}function KY($){if(!($ instanceof Error))return!1;return $.name==="AbortError"||$.message.includes("aborted")}function qY($){if(!($ instanceof Error))return!1;let Q=$.message;return Q.includes("can only concatenate str")||Q.includes("image_url")||Q.includes("multimodal")||Q.includes("vision")||Q.includes("does not support images")}function S8($){let Q=KY($),Y=qY($),J;if(Y)J="当前模型不支持图片理解功能。请切换到支持视觉能力的模型(如 Claude 4.5、GPT-5.2、Gemini 3 Pro、Qwen3-VL-Plus 等)后重试。";else J=GY($);return{displayMessage:J,isAbort:Q,isVisionNotSupported:Y}}import{appendFileSync as UY,mkdirSync as zY,writeFileSync as OY}from"node:fs";import _Y from"node:os";import j2 from"node:path";var y4=null;function NY(){let $=process.env.BLADE_STORAGE_ROOT||j2.join(_Y.homedir(),".blade");return j2.join($,"logs","stream-debug.log")}function FY($){if(y4===$)return;let Q=j2.dirname($);zY(Q,{recursive:!0,mode:493}),OY($,`=== Stream Debug Log Started: ${new Date().toISOString()} ===
2
2
  `),y4=$}function h2($,Q,Y){try{let J=NY();FY(J);let Z=new Date().toISOString(),X=Y?` | ${JSON.stringify(Y)}`:"",G=`[${Z}] [${$}] ${Q}${X}
3
3
  `;UY(J,G)}catch{}}var s$=o1("UI");function C4($,Q){let Y=!1;return(J)=>{switch(J.kind){case"content_delta":if(Y||$.signal.aborted)break;Q.contentDeltaCount++,Q.contentDeltaTotalLen+=J.delta.length,h2("loopEventHandler","onContentDelta",{callCount:Q.contentDeltaCount,deltaLen:J.delta.length,totalLen:Q.contentDeltaTotalLen}),$.streamingBuffer.batchAppendContent(J.delta);break;case"thinking_delta":if(Y||$.signal.aborted)break;if($.thinkingModeEnabled)$.streamingBuffer.batchAppendThinking(J.delta);break;case"stream_end":{if(s$.debug("[loopEventHandler] stream_end",{contentDeltaCount:Q.contentDeltaCount,contentDeltaTotalLen:Q.contentDeltaTotalLen,streamFinalized:Y,signalAborted:$.signal.aborted}),h2("loopEventHandler","onStreamEnd",{contentDeltaCallCount:Q.contentDeltaCount,contentDeltaTotalLen:Q.contentDeltaTotalLen,streamFinalized:Y,signalAborted:$.signal.aborted}),Y||$.signal.aborted){Y=!0;break}let{extraContent:Z,extraThinking:X}=$.streamingBuffer.drainPendingBuffers(),G=$.getStreamingMessageId();if(G){if(Z)k$(G,Z);V8(G)}$.sessionActions.finalizeStreamingMessage(Z,X),Y=!0;break}case"model_fallback":Y=!0,$.streamingBuffer.resetStreamingBuffers(),$.sessionActions.discardStreamingMessage(),$.sessionActions.setCurrentThinkingContent(null);break;case"tool_start":{let Z=J.toolCall;if(!("function"in Z))break;if(Z.function.name===D8)break;if(s$.debug("[loopEventHandler] tool_start",{toolName:Z.function.name,toolKind:J.toolKind}),["TaskCreate","TaskUpdate","TaskList"].includes(Z.function.name))break;try{let X=JSON.parse(Z.function.arguments),G=R4(Z.function.name,X);$.sessionActions.addToolMessage(G,{toolCallId:Z.id,toolName:Z.function.name,phase:"start",summary:G,params:X})}catch(X){s$.error("[loopEventHandler] onToolStart error:",X)}break}case"tool_progress":{let Z=J.toolCall;if(!("function"in Z))break;if(Z.function.name===D8)break;let X=J.update.total!==void 0?` ${Math.max(0,Math.min(100,Math.round((J.update.progress??0)/J.update.total*100)))}%`:"",G=`${Z.function.name}${X}: ${J.update.message}`;$.sessionActions.addToolMessage(G,{toolCallId:Z.id,toolName:Z.function.name,phase:"progress",summary:G});break}case"tool_result":{let Z=J.toolCall;if(!("function"in Z))break;if(Z.function.name===D8)break;s$.debug("[loopEventHandler] tool_result",{toolName:Z.function.name,success:J.result.success});let X=M4(Z.function.name,J.result);$.sessionActions.addToolMessage(X.summary,{toolCallId:Z.id,toolName:Z.function.name,phase:"complete",summary:X.summary,detail:X.detail});break}case"structured_output":$.sessionActions.replaceLastAssistantMessage(JSON.stringify(J.output,null,2));break;case"token_usage":$.sessionActions.updateTokenUsage(J.usage);break;case"compaction":if($.sessionActions.setCompacting(J.phase==="start"),J.phase==="end")$.sessionActions.resetContextUsage();break;case"turn_start":s$.debug("[loopEventHandler] turn_start",{turn:J.turn,maxTurns:J.maxTurns}),$.sessionActions.updateTokenUsage({turnCount:J.turn}),Y=!1;break;case"task_update":$.appActions.setTasks(J.tasks);break;case"mcp_catalog_changed":{let Z=`MCP catalog r${J.revision}: +${J.added.length} -${J.removed.length} ~${J.updated.length}`;$.sessionActions.addToolMessage(Z,{toolName:"MCP Catalog",phase:"complete",summary:Z,detail:[J.added.length>0?`Added: ${J.added.join(", ")}`:"",J.removed.length>0?`Removed: ${J.removed.join(", ")}`:"",J.updated.length>0?`Updated: ${J.updated.join(", ")}`:""].filter(Boolean).join(`
4
4
  `)});break}case"mcp_content_changed":{let Z=`MCP ${J.contentKind} r${J.revision}: +${J.added.length} -${J.removed.length} ~${J.updated.length}`;$.sessionActions.addToolMessage(Z,{toolName:"MCP Content",phase:"complete",summary:Z,detail:[J.added.length>0?`Added: ${J.added.join(", ")}`:"",J.removed.length>0?`Removed: ${J.removed.join(", ")}`:"",J.updated.length>0?`Updated: ${J.updated.join(", ")}`:""].filter(Boolean).join(`
@@ -1 +1 @@
1
- import{Jd as a,Kd as b,Ld as c,Md as d,Nd as e}from"./chunk-evn886hs.js";import"./chunk-9tnaads5.js";import"./chunk-heqs3xan.js";import"./chunk-dpt56hah.js";import"./chunk-e2s6czgg.js";import"./chunk-7wjy6kgt.js";import"./chunk-4dq9y7zn.js";import"./chunk-pz21tcah.js";import"./chunk-3aqdjrtm.js";import"./chunk-kvx3sb3z.js";import"./chunk-f4z3gkbs.js";import"./chunk-5s123nbs.js";import"./chunk-s5666ta0.js";import"./chunk-dsj62dcg.js";import"./chunk-eqr25kxv.js";import"./chunk-gav4hxcv.js";import"./chunk-afkhzdfc.js";import"./chunk-363pgv1e.js";import"./chunk-g11hq0e5.js";export{d as snapshotWorkspaceAgentResources,c as resolveWorkspaceAgentResources,e as resetWorkspaceAgentResources,a as refreshWorkspaceCommunicationStyles,b as configureInvocationPluginDirs};
1
+ import{Jd as a,Kd as b,Ld as c,Md as d,Nd as e}from"./chunk-cx0tdprs.js";import"./chunk-9tnaads5.js";import"./chunk-heqs3xan.js";import"./chunk-dpt56hah.js";import"./chunk-kfgv64hg.js";import"./chunk-7wjy6kgt.js";import"./chunk-4dq9y7zn.js";import"./chunk-5wnxafpf.js";import"./chunk-3aqdjrtm.js";import"./chunk-kvx3sb3z.js";import"./chunk-f4z3gkbs.js";import"./chunk-5s123nbs.js";import"./chunk-s5666ta0.js";import"./chunk-dsj62dcg.js";import"./chunk-cy6emyt9.js";import"./chunk-gav4hxcv.js";import"./chunk-afkhzdfc.js";import"./chunk-363pgv1e.js";import"./chunk-g11hq0e5.js";export{d as snapshotWorkspaceAgentResources,c as resolveWorkspaceAgentResources,e as resetWorkspaceAgentResources,a as refreshWorkspaceCommunicationStyles,b as configureInvocationPluginDirs};
@@ -1,4 +1,4 @@
1
- import{We as Zn,Xe as Jn}from"./chunk-3aqdjrtm.js";import{Ye as rn,Ze as D,_e as m}from"./chunk-kvx3sb3z.js";import{cf as pn,df as Nn}from"./chunk-f4z3gkbs.js";import{if as b}from"./chunk-5s123nbs.js";import{kf as Dn,nf as H}from"./chunk-s5666ta0.js";import{vf as fn,wf as En}from"./chunk-eqr25kxv.js";import{Af as P}from"./chunk-gav4hxcv.js";import{Kf as un}from"./chunk-363pgv1e.js";var Qn=/^[\x21\x23-\x5b\x5d-\x7e]+$/;function Wn(n){return n==="127.0.0.1"||n==="[::1]"||n.toLowerCase()==="localhost"}function I(n,t="MCP OAuth URL"){let e=new URL(n);if(e.username||e.password)throw Error(`${t} must not contain credentials`);if(e.protocol!=="https:"&&!(e.protocol==="http:"&&Wn(e.hostname)))throw Error(`${t} requires HTTPS; HTTP is allowed only for loopback servers`);return e}var B=async(n,t)=>{I(n,"MCP OAuth request URL");let e=await fetch(n,{...t,redirect:"manual"});if(e.status>=300&&e.status<400)throw await e.body?.cancel(),Error("MCP OAuth network requests must not follow redirects");return e};function q(n){let t=n.oauth;if(!t)return;let e=t;for(let _ of["clientSecret","authorizationUrl","tokenUrl","redirectUri"])if(e[_]!==void 0)throw Error(`MCP OAuth "${_}" is not supported; use standards-based discovery`);if(t.enabled!==!0)return{enabled:!1};if(n.type!=="http"&&n.type!=="sse")throw Error("MCP OAuth is supported only for HTTP and SSE transports");if(!n.url)throw Error("MCP OAuth requires an MCP server URL");if(I(n.url,"MCP OAuth server URL"),Object.keys(n.headers??{}).find((_)=>_.toLowerCase()==="authorization"))throw Error("MCP OAuth cannot be combined with a configured Authorization header");let u=t.clientId?.trim();if(u&&u.length>4096)throw Error("MCP OAuth clientId exceeds 4096 characters");let M=t.scopes?.map((_)=>_.trim());if(M){if(M.length>32)throw Error("MCP OAuth supports at most 32 scopes");if(M.some((_)=>!_||_.length>128||!Qn.test(_)))throw Error("MCP OAuth scopes contain an invalid value");if(new Set(M).size!==M.length)throw Error("MCP OAuth scopes must not contain duplicates")}let o=t.callbackPort;if(o!==void 0&&(!Number.isInteger(o)||o<1024||o>65535))throw Error("MCP OAuth callbackPort must be between 1024 and 65535");return{enabled:!0,...u?{clientId:u}:{},...M?.length?{scopes:M}:{},...o!==void 0?{callbackPort:o}:{}}}import{randomUUID as J}from"node:crypto";import st from"node:http";import{auth as _n}from"@modelcontextprotocol/sdk/client/auth.js";import St from"open";import{createHash as jn,randomUUID as Fn}from"node:crypto";import{constants as O,promises as A}from"node:fs";import Y from"node:path";import{Mutex as vn}from"async-mutex";import nt from"write-file-atomic";var Mn=1,tt=1048576,et=5000,ut=50,rt=/^[a-f0-9]{64}$/,Mt=m.Object({client_id:m.String({minLength:1,maxLength:4096})},{additionalProperties:!0}),ot=m.Object({access_token:m.String({minLength:1,maxLength:65536}),token_type:m.String({minLength:1,maxLength:64}),expires_in:m.Optional(m.Number({minimum:0})),refresh_token:m.Optional(m.String({minLength:1,maxLength:65536})),scope:m.Optional(m.String({maxLength:16384})),id_token:m.Optional(m.String({minLength:1,maxLength:262144}))},{additionalProperties:!1}),_t=m.Unsafe({type:"object",properties:{authorizationServerUrl:m.String({format:"uri"}),resourceMetadataUrl:m.Optional(m.String({format:"uri"})),resourceMetadata:m.Optional(m.Unknown()),authorizationServerMetadata:m.Optional(m.Unknown())},required:["authorizationServerUrl"],additionalProperties:!1}),on=m.Object({serverUrl:m.String({format:"uri"}),clientId:m.Optional(m.String({minLength:1,maxLength:4096})),clientInformation:m.Optional(Mt),tokens:m.Optional(ot),tokenExpiresAt:m.Optional(m.Number({minimum:0})),discoveryState:m.Optional(_t),updatedAt:m.String({format:"date-time"})},{additionalProperties:!1}),tn=m.Object({version:m.Literal(Mn),credentials:m.Record(m.String(),on)},{additionalProperties:!1});function l(n,t){return n instanceof Error&&"code"in n&&n.code===t}function it(n){if(!Number.isInteger(n)||n<=0)return!1;try{return process.kill(n,0),!0}catch(t){return l(t,"EPERM")}}function V(n){return structuredClone(n)}function en(n){if(Object.keys(n.credentials).some((t)=>!rt.test(t)))throw Error("MCP OAuth credential store contains an invalid identity")}function y(n){let t=new URL(n);return t.hash="",t.toString()}function Z(n,t,e=[]){return jn("sha256").update(JSON.stringify({serverUrl:y(n),clientId:t?.trim()||null,scopes:[...e].sort()})).digest("hex")}class x{static mutexes=new Map;stateRoot;tokenFilePath;mutex;constructor(n=un()){this.stateRoot=Y.join(n,"mcp"),this.tokenFilePath=Y.join(this.stateRoot,"oauth-credentials.json");let t=x.mutexes.get(this.tokenFilePath);if(!t)t=new vn,x.mutexes.set(this.tokenFilePath,t);this.mutex=t}async getCredential(n){return this.mutex.runExclusive(async()=>{let e=(await this.readStore()).credentials[n];return e?V(e):null})}async updateCredential(n,t){return this.runMutation(async(e)=>{let r=e.credentials[n],u=await t(r?V(r):null);if(u)e.credentials[n]=D(on,u);else delete e.credentials[n];return u?V(e.credentials[n]):null})}async deleteCredential(n){await this.updateCredential(n,()=>null)}async listCredentialIds(){return this.mutex.runExclusive(async()=>Object.keys((await this.readStore()).credentials).sort())}async runMutation(n){return this.mutex.runExclusive(async()=>{let t=await this.acquireStoreLock();try{let e=await this.readStore(),r=await n(e);return await this.writeStore(e),r}finally{await t()}})}async ensureStateRoot(){await A.mkdir(this.stateRoot,{recursive:!0,mode:448});let n=await A.lstat(this.stateRoot);if(!n.isDirectory()||n.isSymbolicLink())throw Error("MCP OAuth credential root must be a regular directory");if(process.getuid&&n.uid!==process.getuid())throw Error("MCP OAuth credential root must be owned by the current user");if((n.mode&63)!==0)throw Error("MCP OAuth credential root permissions must not allow group access")}async readStore(){try{let n=await A.lstat(this.tokenFilePath);if(!n.isFile()||n.isSymbolicLink())throw Error("MCP OAuth credential store must be a regular file");if(process.getuid&&n.uid!==process.getuid())throw Error("MCP OAuth credential store must be owned by the current user");if((n.mode&511)!==384)throw Error("MCP OAuth credential store permissions must be 0600");if(n.size>tt)throw Error("MCP OAuth credential store exceeds the 1 MiB limit");let t=JSON.parse(await A.readFile(this.tokenFilePath,"utf8")),e=rn(tn,t);if(!e.success)throw Error("MCP OAuth credential store has an invalid schema");return en(e.data),e.data}catch(n){if(l(n,"ENOENT"))return{version:Mn,credentials:{}};throw n}}async writeStore(n){await this.ensureStateRoot();let t=D(tn,n);en(t),await nt(this.tokenFilePath,`${JSON.stringify(t,null,2)}
1
+ import{We as Zn,Xe as Jn}from"./chunk-3aqdjrtm.js";import{Ye as rn,Ze as D,_e as m}from"./chunk-kvx3sb3z.js";import{cf as pn,df as Nn}from"./chunk-f4z3gkbs.js";import{if as b}from"./chunk-5s123nbs.js";import{kf as Dn,nf as H}from"./chunk-s5666ta0.js";import{vf as fn,wf as En}from"./chunk-cy6emyt9.js";import{Af as P}from"./chunk-gav4hxcv.js";import{Kf as un}from"./chunk-363pgv1e.js";var Qn=/^[\x21\x23-\x5b\x5d-\x7e]+$/;function Wn(n){return n==="127.0.0.1"||n==="[::1]"||n.toLowerCase()==="localhost"}function I(n,t="MCP OAuth URL"){let e=new URL(n);if(e.username||e.password)throw Error(`${t} must not contain credentials`);if(e.protocol!=="https:"&&!(e.protocol==="http:"&&Wn(e.hostname)))throw Error(`${t} requires HTTPS; HTTP is allowed only for loopback servers`);return e}var B=async(n,t)=>{I(n,"MCP OAuth request URL");let e=await fetch(n,{...t,redirect:"manual"});if(e.status>=300&&e.status<400)throw await e.body?.cancel(),Error("MCP OAuth network requests must not follow redirects");return e};function q(n){let t=n.oauth;if(!t)return;let e=t;for(let _ of["clientSecret","authorizationUrl","tokenUrl","redirectUri"])if(e[_]!==void 0)throw Error(`MCP OAuth "${_}" is not supported; use standards-based discovery`);if(t.enabled!==!0)return{enabled:!1};if(n.type!=="http"&&n.type!=="sse")throw Error("MCP OAuth is supported only for HTTP and SSE transports");if(!n.url)throw Error("MCP OAuth requires an MCP server URL");if(I(n.url,"MCP OAuth server URL"),Object.keys(n.headers??{}).find((_)=>_.toLowerCase()==="authorization"))throw Error("MCP OAuth cannot be combined with a configured Authorization header");let u=t.clientId?.trim();if(u&&u.length>4096)throw Error("MCP OAuth clientId exceeds 4096 characters");let M=t.scopes?.map((_)=>_.trim());if(M){if(M.length>32)throw Error("MCP OAuth supports at most 32 scopes");if(M.some((_)=>!_||_.length>128||!Qn.test(_)))throw Error("MCP OAuth scopes contain an invalid value");if(new Set(M).size!==M.length)throw Error("MCP OAuth scopes must not contain duplicates")}let o=t.callbackPort;if(o!==void 0&&(!Number.isInteger(o)||o<1024||o>65535))throw Error("MCP OAuth callbackPort must be between 1024 and 65535");return{enabled:!0,...u?{clientId:u}:{},...M?.length?{scopes:M}:{},...o!==void 0?{callbackPort:o}:{}}}import{randomUUID as J}from"node:crypto";import st from"node:http";import{auth as _n}from"@modelcontextprotocol/sdk/client/auth.js";import St from"open";import{createHash as jn,randomUUID as Fn}from"node:crypto";import{constants as O,promises as A}from"node:fs";import Y from"node:path";import{Mutex as vn}from"async-mutex";import nt from"write-file-atomic";var Mn=1,tt=1048576,et=5000,ut=50,rt=/^[a-f0-9]{64}$/,Mt=m.Object({client_id:m.String({minLength:1,maxLength:4096})},{additionalProperties:!0}),ot=m.Object({access_token:m.String({minLength:1,maxLength:65536}),token_type:m.String({minLength:1,maxLength:64}),expires_in:m.Optional(m.Number({minimum:0})),refresh_token:m.Optional(m.String({minLength:1,maxLength:65536})),scope:m.Optional(m.String({maxLength:16384})),id_token:m.Optional(m.String({minLength:1,maxLength:262144}))},{additionalProperties:!1}),_t=m.Unsafe({type:"object",properties:{authorizationServerUrl:m.String({format:"uri"}),resourceMetadataUrl:m.Optional(m.String({format:"uri"})),resourceMetadata:m.Optional(m.Unknown()),authorizationServerMetadata:m.Optional(m.Unknown())},required:["authorizationServerUrl"],additionalProperties:!1}),on=m.Object({serverUrl:m.String({format:"uri"}),clientId:m.Optional(m.String({minLength:1,maxLength:4096})),clientInformation:m.Optional(Mt),tokens:m.Optional(ot),tokenExpiresAt:m.Optional(m.Number({minimum:0})),discoveryState:m.Optional(_t),updatedAt:m.String({format:"date-time"})},{additionalProperties:!1}),tn=m.Object({version:m.Literal(Mn),credentials:m.Record(m.String(),on)},{additionalProperties:!1});function l(n,t){return n instanceof Error&&"code"in n&&n.code===t}function it(n){if(!Number.isInteger(n)||n<=0)return!1;try{return process.kill(n,0),!0}catch(t){return l(t,"EPERM")}}function V(n){return structuredClone(n)}function en(n){if(Object.keys(n.credentials).some((t)=>!rt.test(t)))throw Error("MCP OAuth credential store contains an invalid identity")}function y(n){let t=new URL(n);return t.hash="",t.toString()}function Z(n,t,e=[]){return jn("sha256").update(JSON.stringify({serverUrl:y(n),clientId:t?.trim()||null,scopes:[...e].sort()})).digest("hex")}class x{static mutexes=new Map;stateRoot;tokenFilePath;mutex;constructor(n=un()){this.stateRoot=Y.join(n,"mcp"),this.tokenFilePath=Y.join(this.stateRoot,"oauth-credentials.json");let t=x.mutexes.get(this.tokenFilePath);if(!t)t=new vn,x.mutexes.set(this.tokenFilePath,t);this.mutex=t}async getCredential(n){return this.mutex.runExclusive(async()=>{let e=(await this.readStore()).credentials[n];return e?V(e):null})}async updateCredential(n,t){return this.runMutation(async(e)=>{let r=e.credentials[n],u=await t(r?V(r):null);if(u)e.credentials[n]=D(on,u);else delete e.credentials[n];return u?V(e.credentials[n]):null})}async deleteCredential(n){await this.updateCredential(n,()=>null)}async listCredentialIds(){return this.mutex.runExclusive(async()=>Object.keys((await this.readStore()).credentials).sort())}async runMutation(n){return this.mutex.runExclusive(async()=>{let t=await this.acquireStoreLock();try{let e=await this.readStore(),r=await n(e);return await this.writeStore(e),r}finally{await t()}})}async ensureStateRoot(){await A.mkdir(this.stateRoot,{recursive:!0,mode:448});let n=await A.lstat(this.stateRoot);if(!n.isDirectory()||n.isSymbolicLink())throw Error("MCP OAuth credential root must be a regular directory");if(process.getuid&&n.uid!==process.getuid())throw Error("MCP OAuth credential root must be owned by the current user");if((n.mode&63)!==0)throw Error("MCP OAuth credential root permissions must not allow group access")}async readStore(){try{let n=await A.lstat(this.tokenFilePath);if(!n.isFile()||n.isSymbolicLink())throw Error("MCP OAuth credential store must be a regular file");if(process.getuid&&n.uid!==process.getuid())throw Error("MCP OAuth credential store must be owned by the current user");if((n.mode&511)!==384)throw Error("MCP OAuth credential store permissions must be 0600");if(n.size>tt)throw Error("MCP OAuth credential store exceeds the 1 MiB limit");let t=JSON.parse(await A.readFile(this.tokenFilePath,"utf8")),e=rn(tn,t);if(!e.success)throw Error("MCP OAuth credential store has an invalid schema");return en(e.data),e.data}catch(n){if(l(n,"ENOENT"))return{version:Mn,credentials:{}};throw n}}async writeStore(n){await this.ensureStateRoot();let t=D(tn,n);en(t),await nt(this.tokenFilePath,`${JSON.stringify(t,null,2)}
2
2
  `,{mode:384,encoding:"utf8"}),await A.chmod(this.tokenFilePath,384)}async acquireStoreLock(){await this.ensureStateRoot();let n=Y.join(this.stateRoot,".oauth-credentials.lock"),t=Fn(),e=Date.now()+et;while(Date.now()<e)try{let r=await A.open(n,O.O_CREAT|O.O_EXCL|O.O_WRONLY,384);return await r.writeFile(`${JSON.stringify({version:1,pid:process.pid,token:t,createdAt:new Date().toISOString()})}
3
3
  `,"utf8"),await r.close(),async()=>{try{if(JSON.parse(await A.readFile(n,"utf8")).token===t)await A.unlink(n)}catch(u){if(!l(u,"ENOENT"))throw u}}}catch(r){if(!l(r,"EEXIST"))throw r;await this.removeDeadLock(n),await new Promise((u)=>setTimeout(u,ut))}throw Error("MCP OAuth credential store is busy; retry the operation")}async removeDeadLock(n){let t=await A.lstat(n);if(!t.isFile()||t.isSymbolicLink())throw Error("MCP OAuth credential lock must be a regular file");if(process.getuid&&t.uid!==process.getuid()||(t.mode&511)!==384)throw Error("MCP OAuth credential lock ownership or permissions are invalid");let e=JSON.parse(await A.readFile(n,"utf8"));if(typeof e.pid!=="number"||!Number.isInteger(e.pid)||e.pid<=0)throw Error("MCP OAuth credential lock owner is invalid");if(!it(e.pid))await A.unlink(n)}}var sn="127.0.0.1",Sn=7777,mn="/oauth/callback",mt=300000;class Q extends Error{constructor(n){super(`MCP server "${n}" requires OAuth authorization; run "blade mcp login ${n}" or use the Web MCP panel`);this.name="McpOAuthAuthorizationRequiredError"}}class cn extends Error{constructor(n){super(`MCP OAuth credentials are unavailable in this runtime for server "${n}"`);this.name="McpOAuthUnavailableError"}}function ft(n){let t=n?"Authentication complete":"Authentication failed";return`<!doctype html>
4
4
  <html lang="en">
@@ -1,4 +1,4 @@
1
- import{G as P}from"./chunk-pqgw6t9b.js";import{gb as K}from"./chunk-21zwc98r.js";import{$b as B,Cb as G,Db as N,Eb as S,Fb as O,Gb as s}from"./chunk-e65vyfj7.js";import{ec as j}from"./chunk-4hawehmd.js";import{fd as q}from"./chunk-ybvdac8k.js";import{vd as v}from"./chunk-evn886hs.js";import{Gf as z}from"./chunk-363pgv1e.js";import R from"node:path";import{nanoid as cf}from"nanoid";import{execFile as I}from"node:child_process";import{createHash as p}from"node:crypto";import{lstat as o,readFile as ff,realpath as V}from"node:fs/promises";import A from"node:path";import{promisify as af}from"node:util";var tf=af(I),L=8388608,U=500,Y=200;async function y(n,a){try{return(await tf("git",["-c","core.pager=cat",...a],{cwd:n,encoding:"utf8",timeout:30000,maxBuffer:L+1024,env:{...process.env,GIT_CONFIG_NOSYSTEM:"1",GIT_PAGER:"cat",GIT_OPTIONAL_LOCKS:"0"}})).stdout}catch(f){let t=f instanceof Error&&f.message.includes("maxBuffer")?`Review target exceeds the ${L} byte limit`:f instanceof Error?f.message:String(f);throw Error(`Git review target failed: ${t}`)}}function Q(n,a){let f=n?.trim();if(!f||f.length>Y||f.includes("\x00")||f.includes(`
1
+ import{G as P}from"./chunk-nysyp11q.js";import{gb as K}from"./chunk-p42cz164.js";import{$b as B,Cb as G,Db as N,Eb as S,Fb as O,Gb as s}from"./chunk-97fyx4hr.js";import{ec as j}from"./chunk-4hawehmd.js";import{fd as q}from"./chunk-ybvdac8k.js";import{vd as v}from"./chunk-cx0tdprs.js";import{Gf as z}from"./chunk-363pgv1e.js";import R from"node:path";import{nanoid as cf}from"nanoid";import{execFile as I}from"node:child_process";import{createHash as p}from"node:crypto";import{lstat as o,readFile as ff,realpath as V}from"node:fs/promises";import A from"node:path";import{promisify as af}from"node:util";var tf=af(I),L=8388608,U=500,Y=200;async function y(n,a){try{return(await tf("git",["-c","core.pager=cat",...a],{cwd:n,encoding:"utf8",timeout:30000,maxBuffer:L+1024,env:{...process.env,GIT_CONFIG_NOSYSTEM:"1",GIT_PAGER:"cat",GIT_OPTIONAL_LOCKS:"0"}})).stdout}catch(f){let t=f instanceof Error&&f.message.includes("maxBuffer")?`Review target exceeds the ${L} byte limit`:f instanceof Error?f.message:String(f);throw Error(`Git review target failed: ${t}`)}}function Q(n,a){let f=n?.trim();if(!f||f.length>Y||f.includes("\x00")||f.includes(`
2
2
  `)||f.includes("\r"))throw Error(`${a} must contain 1-${Y} characters`);return f}function W(n){return n.split("\x00").filter(Boolean)}async function _(n,a){return(await y(n,["rev-parse","--verify",`${a}^{commit}`])).trim()}async function nf(n,a,f,t,g){let w=g,c=await V(n);for(let e of a){let $=A.resolve(c,e),l=A.relative(c,$);if(!l||l.startsWith("..")||A.isAbsolute(l))throw Error(`Untracked review path escapes the workspace: ${e}`);let i=await o($);if(!i.isFile()||i.isSymbolicLink())throw Error(`Untracked review target must be a regular file: ${e}`);if(w+=i.size,w>L)throw Error(`Review target exceeds ${L} bytes`);f.update("\x00untracked\x00"),f.update(l.replaceAll(A.sep,"/")),f.update("\x00");let b=await ff($);f.update(b);let m=Math.max(1,b.toString("utf8").split(`
3
3
  `).length);t.set(l.replaceAll(A.sep,"/"),[{start:1,end:m}])}}function M(n,a){let f=new Map,t,g,w,c,e=!1,$=(l,i)=>{let b=f.get(l)??[],m=b.at(-1);if(m&&i<=m.end+1)m.end=Math.max(m.end,i);else b.push({start:i,end:i});f.set(l,b)};for(let l of n.split(`
4
4
  `)){if(l.startsWith("--- ")){let i=l.slice(4).split("\t")[0]?.trim();t=i&&i!=="/dev/null"?i.replace(/^a\//,"").replaceAll("\\","/"):void 0;continue}if(l.startsWith("+++ ")){let i=l.slice(4).split("\t")[0]?.trim();e=i==="/dev/null",g=e?t:i?i.replace(/^b\//,"").replaceAll("\\","/"):void 0,w=void 0,c=void 0;continue}if(l.startsWith("@@ ")){let i=/-(\d+)(?:,\d+)? \+(\d+)(?:,\d+)?/.exec(l);w=i?Math.max(1,Number(i[1])):void 0,c=i?Math.max(1,Number(i[2])):void 0;continue}if(!g||w===void 0||c===void 0)continue;if(l.startsWith("+")&&!l.startsWith("+++"))$(g,c),c++;else if(l.startsWith("-")&&!l.startsWith("---"))$(g,e?w:c),w++;else if(!l.startsWith("\\"))w++,c++}for(let l of a)if(!f.has(l))f.set(l,[{start:1,end:1}]);return f}function D(n){if(n.length>U)throw Error(`Review target exceeds the ${U} file limit`)}class d{static async resolve(n,a){let f=await V(n);await y(f,["rev-parse","--is-inside-work-tree"]);let t=await _(f,"HEAD"),g=p("sha256");g.update(`kind\x00${a.kind}\x00head\x00${t}\x00`);let w="",c=[],e,$,l,i,b=new Map;switch(a.kind){case"uncommitted":{w=await y(f,["diff","--binary","--no-ext-diff","--relative","HEAD","--","."]);let m=W(await y(f,["diff","--name-only","-z","--relative","HEAD","--","."])),h=W(await y(f,["ls-files","--others","--exclude-standard","-z","--","."]));if(c=[...new Set([...m,...h])].sort(),D(c),c.length===0)throw Error("No uncommitted changes to review");g.update(w),b=M(w,m),await nf(f,h,g,b,Buffer.byteLength(w)),l="uncommitted changes",i=["Review the uncommitted working tree against HEAD.","Use git status --short, git diff --cached, and git diff, then inspect","every relevant untracked file listed by git status."].join(" ");break}case"base":{let m=Q(a.ref,"Base ref");e=await _(f,m);let h=(await y(f,["merge-base",e,t])).trim();if(w=await y(f,["diff","--binary","--no-ext-diff","--relative",`${h}..${t}`,"--","."]),c=W(await y(f,["diff","--name-only","-z","--relative",`${h}..${t}`,"--","."])),D(c),c.length===0)throw Error(`No changes between ${m} and HEAD`);g.update(w),g.update(`\x00merge-base\x00${h}`),b=M(w,c),l=`changes against ${m}`,i=`Review changes introduced by ${h}..${t}.`;break}case"commit":{let m=Q(a.ref,"Commit ref");if($=await _(f,m),w=await y(f,["show","--format=","--binary","--no-ext-diff","--relative",$,"--","."]),c=W(await y(f,["diff-tree","--root","--no-commit-id","--name-only","-r","-z",$,"--","."])),D(c),c.length===0)throw Error(`Commit has no changes in this workspace: ${m}`);g.update(w),g.update(`\x00commit\x00${$}`),b=M(w,c),l=`commit ${m}`,i=`Review only the changes introduced by commit ${$}.`;break}}if(Buffer.byteLength(w)>L)throw Error(`Review diff exceeds ${L} bytes`);return{info:{kind:a.kind,label:l,headSha:t,...e?{baseSha:e}:{},...$?{commitSha:$}:{},digest:g.digest("hex"),fileCount:c.length},instruction:i,changedLines:b}}}var wf=131072,X=50,E=new Set;function Z(n,a){return`${R.resolve(n)}\x00${a}`}function J(n){return`/review ${n.kind}${n.kind==="uncommitted"?"":` ${n.ref?.trim()??""}`}`}function C(n,a,f,t=!1){if(typeof n!=="string")throw Error(`${a} must be a string`);let g=n.trim();if(!t&&!g||g.length>f)throw Error(`${a} exceeds its allowed length`);return g}function lf(n,a,f){if(!n||typeof n!=="object"||Array.isArray(n))throw Error("Review finding must be an object");let t=n,g=typeof t.line==="number"&&Number.isInteger(t.line)?t.line:void 0,w=t.code_location??(typeof t.file==="string"&&g!==void 0?{path:t.file,line_start:g,line_end:g}:void 0);if(!w||typeof w!=="object"||Array.isArray(w))throw Error("Review finding has no code_location");let c=w,e=C(c.path,"Finding path",1000),$=R.posix.normalize(e.replaceAll("\\","/"));if(R.posix.isAbsolute($)||$===".."||$.startsWith("../"))throw Error("Review finding path must be workspace-relative");let l=R.resolve(a,$),i=R.relative(R.resolve(a),l);if(i.startsWith("..")||R.isAbsolute(i))throw Error("Review finding path escapes the workspace");let b=typeof t.severity==="string"?t.severity.toLowerCase():"",m=b==="critical"?0:b==="high"?1:b==="medium"?2:b==="low"?3:void 0,h=t.priority??m;if(h!==0&&h!==1&&h!==2&&h!==3)throw Error("Review finding priority must be 0-3");let x=t.confidence_score??t.confidence??0.8;if(typeof x!=="number"||!Number.isFinite(x)||x<0||x>1)throw Error("Review finding confidence_score must be between 0 and 1");let{line_start:r,line_end:u}=c;if(!Number.isInteger(r)||!Number.isInteger(u)||r<1||u<r||u-r>=10)throw Error("Review finding line range is invalid");let F=f.changedLines.get($);if(!F)throw Error("Review finding path is outside the review target");if(!F.some((T)=>r<=T.end&&u>=T.start))throw Error("Review finding line range does not overlap the changed lines");let k=C(t.title??`[P${h}] ${String(t.type??"Review finding").replaceAll("-"," ").replace(/\b\w/g,(T)=>T.toUpperCase())}`,"Finding title",120);if(!k.startsWith(`[P${h}] `))throw Error("Review finding title priority does not match priority");return{title:k,body:C(t.body??t.description,"Finding body",4000),priority:h,confidenceScore:x,codeLocation:{path:$,lineStart:r,lineEnd:u}}}function mf(n,a,f){if(Buffer.byteLength(n)>wf)throw Error("Review output exceeds the 128 KiB limit");let t=n.indexOf("{"),g=n.lastIndexOf("}");if(t<0||g<=t)throw Error("Reviewer did not return a JSON object");let w;try{w=JSON.parse(n.slice(t,g+1))}catch{throw Error("Reviewer returned invalid JSON")}if(!w||typeof w!=="object"||Array.isArray(w))throw Error("Reviewer output must be an object");let c=w;if(!Array.isArray(c.findings))throw Error("Reviewer output must contain findings");if(c.findings.length>X)throw Error(`Reviewer returned more than ${X} findings`);return{overallExplanation:C(c.overall_explanation??c.summary,"Review explanation",1e4,!0),findings:c.findings.map((e)=>lf(e,a,f))}}async function H(n,a){return new j(z(n,a)).readAll()}class gf{static async start(n){let{sessionId:a,projectPath:f,runtime:t,request:g,onEvent:w}=n;if(t.sessionId!==a||R.resolve(t.workspaceRoot)!==R.resolve(f))throw Error("Review runtime does not own the requested Session");if(t.hasTurnOwner())throw Error("Cannot start a review during an active turn");await B.assertSessionWritable(a,f);let c=Z(f,a);if(E.has(c))throw Error("Session already has an active review");let e=await H(f,a);if(N(e))throw Error("Session has an interrupted review that must be recovered");let $=g.instructions?.trim();if($&&$.length>4000)throw Error("Review instructions exceed 4,000 characters");let l=await d.resolve(f,g),i=cf(16),b=q("review"),m=new Date().toISOString(),h={reviewId:i,reviewerSessionId:b,target:l.info,startedAt:m},x=new K(f);await x.saveReviewStart(a,h),await x.saveMessage(a,"user",J(g),null,{codeReview:{reviewId:i,phase:"started",targetKind:l.info.kind,targetDigest:l.info.digest}}),await B.updateSessionMetadata(a,f,{taskStatus:"running",taskStatusReason:`Reviewing ${l.info.label}`,taskPromptSummary:J(g),taskStartedAt:m,taskCompletedAt:null,taskFailure:null}),E.add(c);let r=this.execute({...n,target:l,reviewId:i,reviewerSessionId:b,instructions:$,store:x,onEvent:w}).finally(()=>{E.delete(c)});return{reviewId:i,completion:r}}static async execute(n){let{sessionId:a,projectPath:f,runtime:t,request:g,signal:w,onEvent:c,target:e,reviewId:$,reviewerSessionId:l,instructions:i,store:b}=n,m;try{let x=[e.instruction,"Bash already starts in the review workspace. Never prefix a command with cd.",`Authoritative target digest: ${e.info.digest}`,`Changed file count: ${e.info.fileCount}`,i?`Additional review instructions:
@@ -1 +1 @@
1
- import{uc as a,vc as b,wc as c}from"./chunk-hb8krnp5.js";import"./chunk-632rgzcf.js";import"./chunk-z24sj1r8.js";import"./chunk-vmq248m7.js";import"./chunk-ybvdac8k.js";import"./chunk-dpt56hah.js";import"./chunk-4dq9y7zn.js";import"./chunk-pz21tcah.js";import"./chunk-3aqdjrtm.js";import"./chunk-kvx3sb3z.js";import"./chunk-f4z3gkbs.js";import"./chunk-5s123nbs.js";import"./chunk-s5666ta0.js";import"./chunk-dsj62dcg.js";import"./chunk-eqr25kxv.js";import"./chunk-gav4hxcv.js";import"./chunk-afkhzdfc.js";import"./chunk-363pgv1e.js";import"./chunk-g11hq0e5.js";export{a as validatePermissions,c as validateOutput,b as loadConfiguration};
1
+ import{uc as a,vc as b,wc as c}from"./chunk-pmz455nq.js";import"./chunk-632rgzcf.js";import"./chunk-xjyctv33.js";import"./chunk-vmq248m7.js";import"./chunk-ybvdac8k.js";import"./chunk-dpt56hah.js";import"./chunk-4dq9y7zn.js";import"./chunk-5wnxafpf.js";import"./chunk-3aqdjrtm.js";import"./chunk-kvx3sb3z.js";import"./chunk-f4z3gkbs.js";import"./chunk-5s123nbs.js";import"./chunk-s5666ta0.js";import"./chunk-dsj62dcg.js";import"./chunk-cy6emyt9.js";import"./chunk-gav4hxcv.js";import"./chunk-afkhzdfc.js";import"./chunk-363pgv1e.js";import"./chunk-g11hq0e5.js";export{a as validatePermissions,c as validateOutput,b as loadConfiguration};