blade-code 0.10.71 → 0.10.72

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 (108) hide show
  1. package/dist/blade.js +2 -2
  2. package/dist/{chunk-fcv8b6ny.js → chunk-06y3rada.js} +2 -2
  3. package/dist/{chunk-k0pa8874.js → chunk-0kat01bw.js} +1 -1
  4. package/dist/{chunk-th4jjfgm.js → chunk-0qj8jfj1.js} +1 -1
  5. package/dist/{chunk-ahg9vjb6.js → chunk-11gdqmbm.js} +1 -1
  6. package/dist/chunk-139s7p91.js +1 -0
  7. package/dist/{chunk-zvz2cnt4.js → chunk-18atvz38.js} +1 -1
  8. package/dist/{chunk-9hchc346.js → chunk-28wsyv32.js} +1 -1
  9. package/dist/{chunk-rm9hbew3.js → chunk-2d2bcyn1.js} +1 -1
  10. package/dist/{chunk-0tm20v38.js → chunk-2fd5trh8.js} +2 -2
  11. package/dist/{chunk-cdy9efgm.js → chunk-2sdnmxts.js} +1 -1
  12. package/dist/chunk-2vkzwqv0.js +1 -0
  13. package/dist/chunk-41smvqs8.js +1 -0
  14. package/dist/{chunk-hat9v5c5.js → chunk-4wvsg8cc.js} +1 -1
  15. package/dist/{chunk-6pyktfa4.js → chunk-4xpj0d6y.js} +1 -1
  16. package/dist/{chunk-byqxaa9v.js → chunk-5va3hhfp.js} +1 -1
  17. package/dist/chunk-61arrvhp.js +1 -0
  18. package/dist/{chunk-yn51162x.js → chunk-6j3k4v08.js} +1 -1
  19. package/dist/{chunk-s7jsadnc.js → chunk-6j9t1xbh.js} +2 -2
  20. package/dist/{chunk-nx31fkkf.js → chunk-6v7f2cv9.js} +53 -53
  21. package/dist/{chunk-j9q1wyxg.js → chunk-7am1z065.js} +1 -1
  22. package/dist/{chunk-2428hhvj.js → chunk-7hf1k2c9.js} +2 -2
  23. package/dist/chunk-8geywf8q.js +1 -0
  24. package/dist/{chunk-wrfay5r3.js → chunk-91qsjpm6.js} +2 -2
  25. package/dist/{chunk-1je1xw6v.js → chunk-a38chc6z.js} +18 -18
  26. package/dist/{chunk-0vrgrw71.js → chunk-awj9aqjy.js} +2 -2
  27. package/dist/chunk-bqz8wera.js +1 -0
  28. package/dist/chunk-brm24s69.js +2 -0
  29. package/dist/{chunk-r9d4mjxj.js → chunk-bs77d8hn.js} +1 -1
  30. package/dist/{chunk-mtphps19.js → chunk-c4j2anbm.js} +2 -2
  31. package/dist/{chunk-82htkvz8.js → chunk-ccgq8nrm.js} +2 -2
  32. package/dist/{chunk-be30r8an.js → chunk-cqeqjtxn.js} +1 -1
  33. package/dist/{chunk-93tvxmqg.js → chunk-cyjnza5n.js} +4 -4
  34. package/dist/chunk-d9a0g85f.js +1 -0
  35. package/dist/{chunk-1pjkgfez.js → chunk-e0hf1317.js} +1 -1
  36. package/dist/chunk-e4ynb9qf.js +1 -0
  37. package/dist/chunk-e6ezndyf.js +22 -0
  38. package/dist/{chunk-jzntxp7f.js → chunk-eh4h7fmr.js} +2 -2
  39. package/dist/chunk-eh9gdzk5.js +160 -0
  40. package/dist/chunk-emqbb5xh.js +1 -0
  41. package/dist/{chunk-h0ft81a3.js → chunk-g8425xh4.js} +1 -1
  42. package/dist/{chunk-t2wgf9tq.js → chunk-gv3ed5gw.js} +2 -2
  43. package/dist/chunk-gzysna9c.js +1 -0
  44. package/dist/{chunk-axtzde5k.js → chunk-hhk5ecpv.js} +2 -2
  45. package/dist/{chunk-gtcxybv5.js → chunk-hhvkzn6m.js} +1 -1
  46. package/dist/{chunk-d3ttqmyt.js → chunk-hryhnmwv.js} +277 -262
  47. package/dist/{chunk-2px6hzdc.js → chunk-hwjmm2br.js} +2 -2
  48. package/dist/{chunk-9q852bsc.js → chunk-j0yvwrd7.js} +2 -2
  49. package/dist/{chunk-m57w4p91.js → chunk-jyds9m8p.js} +1 -1
  50. package/dist/{chunk-v0rsz1rt.js → chunk-m6qgme8k.js} +1 -1
  51. package/dist/{chunk-97aywyzn.js → chunk-mhyat4mq.js} +2 -2
  52. package/dist/{chunk-qgrq04hb.js → chunk-mp4bfn57.js} +1 -1
  53. package/dist/chunk-mrh3vs01.js +2 -0
  54. package/dist/chunk-ph5rn44j.js +1 -0
  55. package/dist/chunk-pqhjrdnq.js +10 -0
  56. package/dist/{chunk-0j22w4wh.js → chunk-q6daf441.js} +1 -1
  57. package/dist/{chunk-0wxkymqv.js → chunk-s9brgcgs.js} +1 -1
  58. package/dist/{chunk-trn6r1g3.js → chunk-ss1znmv0.js} +1 -1
  59. package/dist/{chunk-3hy06st1.js → chunk-tms0pr01.js} +2 -2
  60. package/dist/chunk-v7phc78b.js +1 -0
  61. package/dist/{chunk-t8xmh4w2.js → chunk-wvg81sd9.js} +1 -1
  62. package/dist/{chunk-x9tvjkjv.js → chunk-x4hh8yqg.js} +1 -1
  63. package/dist/{chunk-dwb2nmms.js → chunk-xahapj98.js} +1 -1
  64. package/dist/{chunk-s77sbxr7.js → chunk-xszsveq1.js} +1 -1
  65. package/dist/{chunk-azw0jckv.js → chunk-y858e8pb.js} +2 -2
  66. package/dist/{chunk-bjqjdw34.js → chunk-yhnr8vdb.js} +2 -2
  67. package/dist/{chunk-cff9gphh.js → chunk-yjj7q7hy.js} +1 -1
  68. package/dist/{chunk-zdnk7qtn.js → chunk-ypwjzw5x.js} +2 -2
  69. package/dist/{chunk-4ke8k0xw.js → chunk-z7vj2xrg.js} +3 -3
  70. package/dist/{chunk-5te2jqt3.js → chunk-zac26wwd.js} +1 -1
  71. package/dist/{chunk-wfy851et.js → chunk-zf96d5we.js} +1 -1
  72. package/dist/chunk-zqxj65xc.js +1 -0
  73. package/dist/chunk-zssys78z.js +1 -0
  74. package/dist/web/assets/ChatView-CgUC5rxo.js +18 -0
  75. package/dist/web/assets/{CodeBlockHighlighter-Dy7QpAmC.js → CodeBlockHighlighter-B5DRAEhB.js} +1 -1
  76. package/dist/web/assets/{FilePreview-BI3nkxz1.js → FilePreview-DSpvLsjW.js} +1 -1
  77. package/dist/web/assets/{KanbanBoard-D5dYOyPH.js → KanbanBoard-6K7IeCXi.js} +1 -1
  78. package/dist/web/assets/{MarkdownRenderer-Da1vB81L.js → MarkdownRenderer-D6LiW9kF.js} +3 -3
  79. package/dist/web/assets/{SettingsModal-jcCFqLqS.js → SettingsModal-CFHxLfuL.js} +1 -1
  80. package/dist/web/assets/{TaskSwitcher-CQ--jOLB.js → TaskSwitcher-Bng9nDed.js} +1 -1
  81. package/dist/web/assets/{TerminalPanel-CWzjEXOb.js → TerminalPanel-BnyQZwkN.js} +1 -1
  82. package/dist/web/assets/index-CDdYV8kB.css +1 -0
  83. package/dist/web/assets/index-DId2GJVO.js +11 -0
  84. package/dist/web/assets/{vendor-icons-B63aW_OM.js → vendor-icons-C927DZlr.js} +41 -36
  85. package/dist/web/index.html +3 -3
  86. package/package.json +1 -1
  87. package/dist/chunk-1w83z8j0.js +0 -1
  88. package/dist/chunk-3as0bkqy.js +0 -1
  89. package/dist/chunk-4pexpa3h.js +0 -160
  90. package/dist/chunk-8j568nm6.js +0 -1
  91. package/dist/chunk-92x15fzx.js +0 -2
  92. package/dist/chunk-ckqpt15b.js +0 -1
  93. package/dist/chunk-fcmgwzrj.js +0 -10
  94. package/dist/chunk-gvbx0t4j.js +0 -1
  95. package/dist/chunk-j0p54tqt.js +0 -1
  96. package/dist/chunk-n827nys9.js +0 -1
  97. package/dist/chunk-nwzpnx7m.js +0 -22
  98. package/dist/chunk-qnsvae10.js +0 -1
  99. package/dist/chunk-sp3bn8qh.js +0 -1
  100. package/dist/chunk-v7p533ff.js +0 -1
  101. package/dist/chunk-vthgpdbd.js +0 -1
  102. package/dist/chunk-wneeq8cr.js +0 -1
  103. package/dist/chunk-xdz5zrjt.js +0 -1
  104. package/dist/chunk-xz6y0w4n.js +0 -2
  105. package/dist/chunk-xzz69esf.js +0 -1
  106. package/dist/web/assets/ChatView-BVrhnE2j.js +0 -18
  107. package/dist/web/assets/index-BOgOL4hG.js +0 -11
  108. package/dist/web/assets/index-DbWgTuT3.css +0 -1
@@ -1,4 +1,4 @@
1
- import{jg as Y}from"./chunk-h0ft81a3.js";import{kg as Tn,lg as F,mg as o}from"./chunk-v0rsz1rt.js";import{qg as ct,rg as bt}from"./chunk-xz6y0w4n.js";import{wg as a}from"./chunk-k0pa8874.js";import{Dg as gt,Eg as Jn,Fg as it,Gg as Ct,Hg as Rt,Ig as On,Jg as zt,Kg as Bt,Lg as kn,Mg as Ut,Ng as Kt,Og as yn,Pg as Ht,Qg as Yt,Rg as qt,Sg as Vt,Tg as Gt,xg as Zn,yg as Xt,zg as pt}from"./chunk-6pyktfa4.js";import{Xg as dn}from"./chunk-t2wgf9tq.js";import{_g as $t,bh as J}from"./chunk-2px6hzdc.js";import{jh as an,kh as xn}from"./chunk-azw0jckv.js";import{qh as h}from"./chunk-jzntxp7f.js";import{Bh as mn}from"./chunk-9q852bsc.js";var Qt=/^[\x21\x23-\x5b\x5d-\x7e]+$/;function Dt(n){return n==="127.0.0.1"||n==="[::1]"||n.toLowerCase()==="localhost"}function C(n,t="MCP OAuth URL"){let M=new URL(n);if(M.username||M.password)throw Error(`${t} must not contain credentials`);if(M.protocol!=="https:"&&!(M.protocol==="http:"&&Dt(M.hostname)))throw Error(`${t} requires HTTPS; HTTP is allowed only for loopback servers`);return M}var K=async(n,t)=>{C(n,"MCP OAuth request URL");let M=await fetch(n,{...t,redirect:"manual"});if(M.status>=300&&M.status<400)throw await M.body?.cancel(),Error("MCP OAuth network requests must not follow redirects");return M};function O(n){let t=n.oauth;if(!t)return;let M=t;for(let u of["clientSecret","authorizationUrl","tokenUrl","redirectUri"])if(M[u]!==void 0)throw Error(`MCP OAuth "${u}" 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(C(n.url,"MCP OAuth server URL"),Object.keys(n.headers??{}).find((u)=>u.toLowerCase()==="authorization"))throw Error("MCP OAuth cannot be combined with a configured Authorization header");let r=t.clientId?.trim();if(r&&r.length>4096)throw Error("MCP OAuth clientId exceeds 4096 characters");let S=t.scopes?.map((u)=>u.trim());if(S){if(S.length>32)throw Error("MCP OAuth supports at most 32 scopes");if(S.some((u)=>!u||u.length>128||!Qt.test(u)))throw Error("MCP OAuth scopes contain an invalid value");if(new Set(S).size!==S.length)throw Error("MCP OAuth scopes must not contain duplicates")}let _=t.callbackPort;if(_!==void 0&&(!Number.isInteger(_)||_<1024||_>65535))throw Error("MCP OAuth callbackPort must be between 1024 and 65535");return{enabled:!0,...r?{clientId:r}:{},...S?.length?{scopes:S}:{},..._!==void 0?{callbackPort:_}:{}}}import{randomUUID as v}from"node:crypto";import tM from"node:http";import{auth as An}from"@modelcontextprotocol/sdk/client/auth.js";import MM from"open";import{createHash as Wt,randomUUID as Zt}from"node:crypto";import{constants as k,promises as P}from"node:fs";import y from"node:path";import Jt from"write-file-atomic";var on=1,Ot=1048576,kt=5000,yt=50,jt=/^[a-f0-9]{64}$/,Ft=o.Object({client_id:o.String({minLength:1,maxLength:4096})},{additionalProperties:!0}),lt=o.Object({access_token:o.String({minLength:1,maxLength:65536}),token_type:o.String({minLength:1,maxLength:64}),expires_in:o.Optional(o.Number({minimum:0})),refresh_token:o.Optional(o.String({minLength:1,maxLength:65536})),scope:o.Optional(o.String({maxLength:16384})),id_token:o.Optional(o.String({minLength:1,maxLength:262144}))},{additionalProperties:!1}),vt=o.Unsafe({type:"object",properties:{authorizationServerUrl:o.String({format:"uri"}),resourceMetadataUrl:o.Optional(o.String({format:"uri"})),resourceMetadata:o.Optional(o.Unknown()),authorizationServerMetadata:o.Optional(o.Unknown())},required:["authorizationServerUrl"],additionalProperties:!1}),sn=o.Object({serverUrl:o.String({format:"uri"}),clientId:o.Optional(o.String({minLength:1,maxLength:4096})),clientInformation:o.Optional(Ft),tokens:o.Optional(lt),tokenExpiresAt:o.Optional(o.Number({minimum:0})),discoveryState:o.Optional(vt),updatedAt:o.String({format:"date-time"})},{additionalProperties:!1}),un=o.Object({version:o.Literal(on),credentials:o.Record(o.String(),sn)},{additionalProperties:!1});function H(n,t){return n instanceof Error&&"code"in n&&n.code===t}function nM(n){if(!Number.isInteger(n)||n<=0)return!1;try{return process.kill(n,0),!0}catch(t){return H(t,"EPERM")}}function j(n){return structuredClone(n)}function En(n){if(Object.keys(n.credentials).some((t)=>!jt.test(t)))throw Error("MCP OAuth credential store contains an invalid identity")}function q(n){let t=new URL(n);return t.hash="",t.toString()}function l(n,t,M=[]){return Wt("sha256").update(JSON.stringify({serverUrl:q(n),clientId:t?.trim()||null,scopes:[...M].sort()})).digest("hex")}class I{static locks=new Y;stateRoot;tokenFilePath;constructor(n=mn()){this.stateRoot=y.join(n,"mcp"),this.tokenFilePath=y.join(this.stateRoot,"oauth-credentials.json")}static coordinationStatsForTests(){return this.locks.getStats()}async getCredential(n){return I.locks.runExclusive(this.tokenFilePath,async()=>{let M=(await this.readStore()).credentials[n];return M?j(M):null})}async updateCredential(n,t){return this.runMutation(async(M)=>{let e=M.credentials[n],r=await t(e?j(e):null);if(r)M.credentials[n]=F(sn,r);else delete M.credentials[n];return r?j(M.credentials[n]):null})}async deleteCredential(n){await this.updateCredential(n,()=>null)}async listCredentialIds(){return I.locks.runExclusive(this.tokenFilePath,async()=>Object.keys((await this.readStore()).credentials).sort())}async runMutation(n){return I.locks.runExclusive(this.tokenFilePath,async()=>{let t=await this.acquireStoreLock();try{let M=await this.readStore(),e=await n(M);return await this.writeStore(M),e}finally{await t()}})}async ensureStateRoot(){await P.mkdir(this.stateRoot,{recursive:!0,mode:448});let n=await P.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 P.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>Ot)throw Error("MCP OAuth credential store exceeds the 1 MiB limit");let t=JSON.parse(await P.readFile(this.tokenFilePath,"utf8")),M=Tn(un,t);if(!M.success)throw Error("MCP OAuth credential store has an invalid schema");return En(M.data),M.data}catch(n){if(H(n,"ENOENT"))return{version:on,credentials:{}};throw n}}async writeStore(n){await this.ensureStateRoot();let t=F(un,n);En(t),await Jt(this.tokenFilePath,`${JSON.stringify(t,null,2)}
1
+ import{og as Y}from"./chunk-g8425xh4.js";import{pg as Tn,qg as F,rg as o}from"./chunk-m6qgme8k.js";import{vg as ct,wg as bt}from"./chunk-mrh3vs01.js";import{Bg as a}from"./chunk-0kat01bw.js";import{Cg as Zn,Dg as Xt,Eg as pt,Ig as gt,Jg as Jn,Kg as it,Lg as Ct,Mg as Rt,Ng as On,Og as zt,Pg as Bt,Qg as kn,Rg as Ut,Sg as Kt,Tg as yn,Ug as Ht,Vg as Yt,Wg as qt,Xg as Vt,Yg as Gt}from"./chunk-4xpj0d6y.js";import{ah as dn}from"./chunk-gv3ed5gw.js";import{dh as $t,gh as J}from"./chunk-hwjmm2br.js";import{oh as an,ph as xn}from"./chunk-y858e8pb.js";import{vh as h}from"./chunk-eh4h7fmr.js";import{Gh as mn}from"./chunk-j0yvwrd7.js";var Qt=/^[\x21\x23-\x5b\x5d-\x7e]+$/;function Dt(n){return n==="127.0.0.1"||n==="[::1]"||n.toLowerCase()==="localhost"}function C(n,t="MCP OAuth URL"){let M=new URL(n);if(M.username||M.password)throw Error(`${t} must not contain credentials`);if(M.protocol!=="https:"&&!(M.protocol==="http:"&&Dt(M.hostname)))throw Error(`${t} requires HTTPS; HTTP is allowed only for loopback servers`);return M}var K=async(n,t)=>{C(n,"MCP OAuth request URL");let M=await fetch(n,{...t,redirect:"manual"});if(M.status>=300&&M.status<400)throw await M.body?.cancel(),Error("MCP OAuth network requests must not follow redirects");return M};function O(n){let t=n.oauth;if(!t)return;let M=t;for(let u of["clientSecret","authorizationUrl","tokenUrl","redirectUri"])if(M[u]!==void 0)throw Error(`MCP OAuth "${u}" 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(C(n.url,"MCP OAuth server URL"),Object.keys(n.headers??{}).find((u)=>u.toLowerCase()==="authorization"))throw Error("MCP OAuth cannot be combined with a configured Authorization header");let r=t.clientId?.trim();if(r&&r.length>4096)throw Error("MCP OAuth clientId exceeds 4096 characters");let S=t.scopes?.map((u)=>u.trim());if(S){if(S.length>32)throw Error("MCP OAuth supports at most 32 scopes");if(S.some((u)=>!u||u.length>128||!Qt.test(u)))throw Error("MCP OAuth scopes contain an invalid value");if(new Set(S).size!==S.length)throw Error("MCP OAuth scopes must not contain duplicates")}let _=t.callbackPort;if(_!==void 0&&(!Number.isInteger(_)||_<1024||_>65535))throw Error("MCP OAuth callbackPort must be between 1024 and 65535");return{enabled:!0,...r?{clientId:r}:{},...S?.length?{scopes:S}:{},..._!==void 0?{callbackPort:_}:{}}}import{randomUUID as v}from"node:crypto";import tM from"node:http";import{auth as An}from"@modelcontextprotocol/sdk/client/auth.js";import MM from"open";import{createHash as Wt,randomUUID as Zt}from"node:crypto";import{constants as k,promises as P}from"node:fs";import y from"node:path";import Jt from"write-file-atomic";var on=1,Ot=1048576,kt=5000,yt=50,jt=/^[a-f0-9]{64}$/,Ft=o.Object({client_id:o.String({minLength:1,maxLength:4096})},{additionalProperties:!0}),lt=o.Object({access_token:o.String({minLength:1,maxLength:65536}),token_type:o.String({minLength:1,maxLength:64}),expires_in:o.Optional(o.Number({minimum:0})),refresh_token:o.Optional(o.String({minLength:1,maxLength:65536})),scope:o.Optional(o.String({maxLength:16384})),id_token:o.Optional(o.String({minLength:1,maxLength:262144}))},{additionalProperties:!1}),vt=o.Unsafe({type:"object",properties:{authorizationServerUrl:o.String({format:"uri"}),resourceMetadataUrl:o.Optional(o.String({format:"uri"})),resourceMetadata:o.Optional(o.Unknown()),authorizationServerMetadata:o.Optional(o.Unknown())},required:["authorizationServerUrl"],additionalProperties:!1}),sn=o.Object({serverUrl:o.String({format:"uri"}),clientId:o.Optional(o.String({minLength:1,maxLength:4096})),clientInformation:o.Optional(Ft),tokens:o.Optional(lt),tokenExpiresAt:o.Optional(o.Number({minimum:0})),discoveryState:o.Optional(vt),updatedAt:o.String({format:"date-time"})},{additionalProperties:!1}),un=o.Object({version:o.Literal(on),credentials:o.Record(o.String(),sn)},{additionalProperties:!1});function H(n,t){return n instanceof Error&&"code"in n&&n.code===t}function nM(n){if(!Number.isInteger(n)||n<=0)return!1;try{return process.kill(n,0),!0}catch(t){return H(t,"EPERM")}}function j(n){return structuredClone(n)}function En(n){if(Object.keys(n.credentials).some((t)=>!jt.test(t)))throw Error("MCP OAuth credential store contains an invalid identity")}function q(n){let t=new URL(n);return t.hash="",t.toString()}function l(n,t,M=[]){return Wt("sha256").update(JSON.stringify({serverUrl:q(n),clientId:t?.trim()||null,scopes:[...M].sort()})).digest("hex")}class I{static locks=new Y;stateRoot;tokenFilePath;constructor(n=mn()){this.stateRoot=y.join(n,"mcp"),this.tokenFilePath=y.join(this.stateRoot,"oauth-credentials.json")}static coordinationStatsForTests(){return this.locks.getStats()}async getCredential(n){return I.locks.runExclusive(this.tokenFilePath,async()=>{let M=(await this.readStore()).credentials[n];return M?j(M):null})}async updateCredential(n,t){return this.runMutation(async(M)=>{let e=M.credentials[n],r=await t(e?j(e):null);if(r)M.credentials[n]=F(sn,r);else delete M.credentials[n];return r?j(M.credentials[n]):null})}async deleteCredential(n){await this.updateCredential(n,()=>null)}async listCredentialIds(){return I.locks.runExclusive(this.tokenFilePath,async()=>Object.keys((await this.readStore()).credentials).sort())}async runMutation(n){return I.locks.runExclusive(this.tokenFilePath,async()=>{let t=await this.acquireStoreLock();try{let M=await this.readStore(),e=await n(M);return await this.writeStore(M),e}finally{await t()}})}async ensureStateRoot(){await P.mkdir(this.stateRoot,{recursive:!0,mode:448});let n=await P.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 P.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>Ot)throw Error("MCP OAuth credential store exceeds the 1 MiB limit");let t=JSON.parse(await P.readFile(this.tokenFilePath,"utf8")),M=Tn(un,t);if(!M.success)throw Error("MCP OAuth credential store has an invalid schema");return En(M.data),M.data}catch(n){if(H(n,"ENOENT"))return{version:on,credentials:{}};throw n}}async writeStore(n){await this.ensureStateRoot();let t=F(un,n);En(t),await Jt(this.tokenFilePath,`${JSON.stringify(t,null,2)}
2
2
  `,{mode:384,encoding:"utf8"}),await P.chmod(this.tokenFilePath,384)}async acquireStoreLock(){await this.ensureStateRoot();let n=y.join(this.stateRoot,".oauth-credentials.lock"),t=Zt(),M=Date.now()+kt;while(Date.now()<M)try{let e=await P.open(n,k.O_CREAT|k.O_EXCL|k.O_WRONLY,384);return await e.writeFile(`${JSON.stringify({version:1,pid:process.pid,token:t,createdAt:new Date().toISOString()})}
3
3
  `,"utf8"),await e.close(),async()=>{try{if(JSON.parse(await P.readFile(n,"utf8")).token===t)await P.unlink(n)}catch(r){if(!H(r,"ENOENT"))throw r}}}catch(e){if(!H(e,"EEXIST"))throw e;await this.removeDeadLock(n),await new Promise((r)=>setTimeout(r,yt))}throw Error("MCP OAuth credential store is busy; retry the operation")}async removeDeadLock(n){let t=await P.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 M=JSON.parse(await P.readFile(n,"utf8"));if(typeof M.pid!=="number"||!Number.isInteger(M.pid)||M.pid<=0)throw Error("MCP OAuth credential lock owner is invalid");if(!nM(M.pid))await P.unlink(n)}}var cn="127.0.0.1",bn=7777,wn="/oauth/callback",eM=300000;class nn 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 Pn extends Error{constructor(n){super(`MCP OAuth credentials are unavailable in this runtime for server "${n}"`);this.name="McpOAuthUnavailableError"}}function rM(n){let t=n?"Authentication complete":"Authentication failed";return`<!doctype html>
4
4
  <html lang="en">
@@ -41,4 +41,4 @@ ${M.map((e)=>` - ${e}`).join(`
41
41
  ]
42
42
  }
43
43
  `)}}function Rr(n,t={}){let M={...n};if(t.debug!==void 0)M.debug=t.debug===""?!0:t.debug;if(t.model){if(!n.models.some((r)=>r.id===t.model))throw Error(`模型配置未找到: ${t.model}`);M.currentModelId=t.model}if(t.yolo===!0)M.permissionMode="yolo";else if(t.permissionMode!==void 0)M.permissionMode=t.permissionMode;if(t.maxTurns!==void 0)M.maxTurns=t.maxTurns;if(t.maxConcurrentTasks!==void 0)M.maxConcurrentTasks=t.maxConcurrentTasks;if(t.maxQueuedTasks!==void 0)M.maxQueuedTasks=t.maxQueuedTasks;if(t.maxQueuedTaskBytes!==void 0)M.maxQueuedTaskBytes=t.maxQueuedTaskBytes;if(t.maxResidentSessionRuntimes!==void 0)M.maxResidentSessionRuntimes=t.maxResidentSessionRuntimes;if(t.sessionRuntimeIdleMs!==void 0)M.sessionRuntimeIdleMs=t.sessionRuntimeIdleMs;return M.systemPrompt=t.systemPrompt,M.appendSystemPrompt=t.appendSystemPrompt,M.model=t.model,M.resumeSessionId=t.sessionId,M.forkSession=t.forkSession,M.allowedTools=t.allowedTools,M.disallowedTools=t.disallowedTools,M.mcpConfigPaths=t.mcpConfig,M.strictMcpConfig=t.strictMcpConfig,M.addDirs=t.addDir,M.outputFormat=t.outputFormat,M.inputFormat=t.inputFormat,M.print=t.print,M.includePartialMessages=t.includePartialMessages,M.replayUserMessages=t.replayUserMessages,M.agentsConfig=t.agents,M.settingSources=t.settingSources,M}
44
- export{K as ef,O as ff,I as gf,nn as hf,Pn as if,$ as jf,nt as kf,ge as lf,G as mf,Re as nf,ze as of,Be as pf,_t as qf,aM as rf,Ue as sf,xM as tf,Ke as uf,wt as vf,qe as wf,Ve as xf,Qe as yf,De as zf,We as Af,xt as Bf,Ze as Cf,Je as Df,Oe as Ef,ke as Ff,se as Gf,In as Hf,Nn as If,ce as Jf,$n as Kf,Xn as Lf,pn as Mf,gn as Nf,Cn as Of,Rn as Pf,we as Qf,zn as Rf,Bn as Sf,Un as Tf,Kn as Uf,Hn as Vf,Yn as Wf,qn as Xf,Vn as Yf,Gn as Zf,Qn as _f,Dn as $f,Wn as ag,s as bg,d as cg,EM as dg,B as eg,Z as fg,g as gg,Rr as hg};
44
+ export{K as jf,O as kf,I as lf,nn as mf,Pn as nf,$ as of,nt as pf,ge as qf,G as rf,Re as sf,ze as tf,Be as uf,_t as vf,aM as wf,Ue as xf,xM as yf,Ke as zf,wt as Af,qe as Bf,Ve as Cf,Qe as Df,De as Ef,We as Ff,xt as Gf,Ze as Hf,Je as If,Oe as Jf,ke as Kf,se as Lf,In as Mf,Nn as Nf,ce as Of,$n as Pf,Xn as Qf,pn as Rf,gn as Sf,Cn as Tf,Rn as Uf,we as Vf,zn as Wf,Bn as Xf,Un as Yf,Kn as Zf,Hn as _f,Yn as $f,qn as ag,Vn as bg,Gn as cg,Qn as dg,Dn as eg,Wn as fg,s as gg,d as hg,EM as ig,B as jg,Z as kg,g as lg,Rr as mg};
@@ -1,2 +1,2 @@
1
- import{jh as S}from"./chunk-azw0jckv.js";import{Dh as f}from"./chunk-wfy851et.js";import*as $ from"fs/promises";import*as K from"path";import j from"semver";import{ProxyAgent as H,fetch as I}from"undici";function R(){return process.env.HTTPS_PROXY||process.env.HTTP_PROXY||process.env.https_proxy||process.env.http_proxy}function N(){let q=R();if(q)try{return new H(q)}catch(z){console.warn(`[proxyFetch] Invalid proxy URL: ${q}`)}return}async function M(q,z={}){let{timeout:W=30000,signal:Q,...B}=z;if(Q?.aborted)throw new DOMException("The operation was aborted.","AbortError");let J=N(),X=new AbortController,Y=!1,F=setTimeout(()=>{Y=!0,X.abort()},W),b=()=>X.abort();Q?.addEventListener("abort",b);try{let Z={method:B.method,headers:B.headers,body:B.body,signal:X.signal,dispatcher:J};return await I(q.toString(),Z)}catch(Z){if(Z instanceof Error&&Z.name==="AbortError"){if(Y)throw Error(`Request timeout after ${W}ms`);throw Z}throw Z}finally{clearTimeout(F),Q?.removeEventListener("abort",b)}}var w="blade-code",y="https://cdn.jsdelivr.net/npm/blade-code@latest/CHANGELOG.md",G=K.join(process.env.HOME||process.env.USERPROFILE||".",".blade"),O=K.join(G,"version-cache.json"),P=3600000,k=`https://registry.npmjs.org/${w}/latest`;async function L(){try{if(process.env.BLADE_VERSION)return process.env.BLADE_VERSION;return S()}catch{return"unknown"}}async function T(){try{let q=await $.readFile(O,"utf-8"),z=JSON.parse(q);if(Date.now()-z.checkedAt<P)return z;return{...z,checkedAt:0}}catch{return null}}async function D(q){try{await $.mkdir(G,{recursive:!0,mode:493}),await $.writeFile(O,JSON.stringify(q,null,2))}catch{}}async function x(){try{let q=await M(k,{timeout:5000,headers:{Accept:"application/json"}});if(!q.ok)return null;return(await q.json()).version||null}catch{return null}}async function _(q=!1){let z=await L(),W=y;if(z==="unknown")return{currentVersion:z,latestVersion:null,hasUpdate:!1,shouldPrompt:!1,releaseNotesUrl:W,error:"Unable to determine current version"};let Q=await T(),B=Q?.skipUntilVersion,J=null;if(!q&&Q?.latestVersion&&Q.checkedAt>0)J=Q.latestVersion;else if(J=await x(),J)await D({latestVersion:J,checkedAt:Date.now(),skipUntilVersion:B});else if(Q?.latestVersion)await D({checkedAt:0,skipUntilVersion:B});if(!J||!j.valid(J))return{currentVersion:z,latestVersion:null,hasUpdate:!1,shouldPrompt:!1,releaseNotesUrl:W,error:"Unable to check for updates"};if(j.lt(J,z))J=z,await D({latestVersion:J,checkedAt:Date.now(),skipUntilVersion:B});let X=j.gt(J,z),Y=X;if(X&&B)Y=j.gt(J,B);return{currentVersion:z,latestVersion:J,hasUpdate:X,shouldPrompt:Y,releaseNotesUrl:W}}async function u(q){let z=await T();await D({latestVersion:z?.latestVersion??q,checkedAt:z?.checkedAt||Date.now(),skipUntilVersion:q})}function g(){return`npm install -g ${w}@latest --registry https://registry.npmjs.org`}async function C(){let{spawn:q}=await import("child_process");return new Promise((z)=>{let W=g(),Q=q(W,{stdio:"inherit",shell:!0});Q.on("close",(B)=>{if(B===0)z({success:!0,message:"Upgrade successful! Please restart blade."});else z({success:!1,message:`Upgrade failed (exit code: ${B})`})}),Q.on("error",(B)=>{z({success:!1,message:`Upgrade failed: ${B.message}`})})})}async function V(){try{let q=await _();return q.shouldPrompt?q:null}catch{return null}}
1
+ import{oh as S}from"./chunk-y858e8pb.js";import{Ih as f}from"./chunk-zf96d5we.js";import*as $ from"fs/promises";import*as K from"path";import j from"semver";import{ProxyAgent as H,fetch as I}from"undici";function R(){return process.env.HTTPS_PROXY||process.env.HTTP_PROXY||process.env.https_proxy||process.env.http_proxy}function N(){let q=R();if(q)try{return new H(q)}catch(z){console.warn(`[proxyFetch] Invalid proxy URL: ${q}`)}return}async function M(q,z={}){let{timeout:W=30000,signal:Q,...B}=z;if(Q?.aborted)throw new DOMException("The operation was aborted.","AbortError");let J=N(),X=new AbortController,Y=!1,F=setTimeout(()=>{Y=!0,X.abort()},W),b=()=>X.abort();Q?.addEventListener("abort",b);try{let Z={method:B.method,headers:B.headers,body:B.body,signal:X.signal,dispatcher:J};return await I(q.toString(),Z)}catch(Z){if(Z instanceof Error&&Z.name==="AbortError"){if(Y)throw Error(`Request timeout after ${W}ms`);throw Z}throw Z}finally{clearTimeout(F),Q?.removeEventListener("abort",b)}}var w="blade-code",y="https://cdn.jsdelivr.net/npm/blade-code@latest/CHANGELOG.md",G=K.join(process.env.HOME||process.env.USERPROFILE||".",".blade"),O=K.join(G,"version-cache.json"),P=3600000,k=`https://registry.npmjs.org/${w}/latest`;async function L(){try{if(process.env.BLADE_VERSION)return process.env.BLADE_VERSION;return S()}catch{return"unknown"}}async function T(){try{let q=await $.readFile(O,"utf-8"),z=JSON.parse(q);if(Date.now()-z.checkedAt<P)return z;return{...z,checkedAt:0}}catch{return null}}async function D(q){try{await $.mkdir(G,{recursive:!0,mode:493}),await $.writeFile(O,JSON.stringify(q,null,2))}catch{}}async function x(){try{let q=await M(k,{timeout:5000,headers:{Accept:"application/json"}});if(!q.ok)return null;return(await q.json()).version||null}catch{return null}}async function _(q=!1){let z=await L(),W=y;if(z==="unknown")return{currentVersion:z,latestVersion:null,hasUpdate:!1,shouldPrompt:!1,releaseNotesUrl:W,error:"Unable to determine current version"};let Q=await T(),B=Q?.skipUntilVersion,J=null;if(!q&&Q?.latestVersion&&Q.checkedAt>0)J=Q.latestVersion;else if(J=await x(),J)await D({latestVersion:J,checkedAt:Date.now(),skipUntilVersion:B});else if(Q?.latestVersion)await D({checkedAt:0,skipUntilVersion:B});if(!J||!j.valid(J))return{currentVersion:z,latestVersion:null,hasUpdate:!1,shouldPrompt:!1,releaseNotesUrl:W,error:"Unable to check for updates"};if(j.lt(J,z))J=z,await D({latestVersion:J,checkedAt:Date.now(),skipUntilVersion:B});let X=j.gt(J,z),Y=X;if(X&&B)Y=j.gt(J,B);return{currentVersion:z,latestVersion:J,hasUpdate:X,shouldPrompt:Y,releaseNotesUrl:W}}async function u(q){let z=await T();await D({latestVersion:z?.latestVersion??q,checkedAt:z?.checkedAt||Date.now(),skipUntilVersion:q})}function g(){return`npm install -g ${w}@latest --registry https://registry.npmjs.org`}async function C(){let{spawn:q}=await import("child_process");return new Promise((z)=>{let W=g(),Q=q(W,{stdio:"inherit",shell:!0});Q.on("close",(B)=>{if(B===0)z({success:!0,message:"Upgrade successful! Please restart blade."});else z({success:!1,message:`Upgrade failed (exit code: ${B})`})}),Q.on("error",(B)=>{z({success:!1,message:`Upgrade failed: ${B.message}`})})})}async function V(){try{let q=await _();return q.shouldPrompt?q:null}catch{return null}}
2
2
  export{_ as a,u as b,g as c,C as d,V as e};