blade-code 0.10.128 → 0.10.130
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.
- package/dist/blade.js +2 -2
- package/dist/chunk-0z9nqbd0.js +2 -0
- package/dist/chunk-1bb4h5gf.js +1 -0
- package/dist/chunk-2bnpn8be.js +1 -0
- package/dist/{chunk-xzfc1s6k.js → chunk-2y1qngw7.js} +1 -1
- package/dist/{chunk-jy0vfp8a.js → chunk-42h7kj6p.js} +1 -1
- package/dist/{chunk-ted1hyvb.js → chunk-44jtpg8y.js} +1 -1
- package/dist/chunk-4sxxvtn4.js +1 -0
- package/dist/chunk-51qc7n8t.js +1 -0
- package/dist/{chunk-z3hpstky.js → chunk-53h87fmt.js} +1 -1
- package/dist/{chunk-y93nqyqd.js → chunk-55hq1ps4.js} +2 -2
- package/dist/{chunk-9n90djh7.js → chunk-5a17mdjd.js} +2 -2
- package/dist/{chunk-pq6g92cz.js → chunk-6p6ts4kv.js} +2 -2
- package/dist/{chunk-sca5q3tt.js → chunk-77efqpdc.js} +1 -1
- package/dist/chunk-7jj607dg.js +94 -0
- package/dist/{chunk-yqqeh12b.js → chunk-8a6nrqdc.js} +2 -2
- package/dist/{chunk-10w2pj3r.js → chunk-93x9xbew.js} +1 -1
- package/dist/{chunk-1aw643j2.js → chunk-9et78e3v.js} +2 -2
- package/dist/chunk-9gs4eqt8.js +1 -0
- package/dist/chunk-9s8saznq.js +1 -0
- package/dist/{chunk-fa0pyv9k.js → chunk-9yqadjea.js} +2 -2
- package/dist/{chunk-a7gghhvn.js → chunk-a4jetpj8.js} +18 -18
- package/dist/{chunk-yqpej45c.js → chunk-a60cmnmz.js} +2 -2
- package/dist/{chunk-8hd4vd20.js → chunk-aaxc81jc.js} +1 -1
- package/dist/{chunk-xejvs1fk.js → chunk-agda17kj.js} +1 -1
- package/dist/{chunk-c47db31j.js → chunk-ajsw4te2.js} +2 -2
- package/dist/{chunk-r04vwtej.js → chunk-ar5np5h5.js} +2 -2
- package/dist/chunk-b8m7zc7t.js +170 -0
- package/dist/chunk-bcre3557.js +1 -0
- package/dist/{chunk-atema2rc.js → chunk-dfjmvj3d.js} +2 -2
- package/dist/chunk-dkgaxmsp.js +10 -0
- package/dist/{chunk-mkvvyq49.js → chunk-e1d0e6t6.js} +2 -2
- package/dist/{chunk-s7axaw78.js → chunk-edtxcqxa.js} +1 -1
- package/dist/chunk-f8gb685p.js +2 -0
- package/dist/chunk-fjv2vede.js +1 -0
- package/dist/{chunk-zfyg3888.js → chunk-g4xny949.js} +1 -1
- package/dist/chunk-gfbkrk60.js +338 -0
- package/dist/{chunk-12hdakw4.js → chunk-gmqpfm52.js} +2 -2
- package/dist/{chunk-skv2gb99.js → chunk-grhsv55v.js} +2 -2
- package/dist/chunk-gzz0gnmv.js +1 -0
- package/dist/chunk-h1wphqkc.js +1 -0
- package/dist/{chunk-6v2hhgka.js → chunk-hhg1zcbq.js} +2 -2
- package/dist/{chunk-9hnfz9bx.js → chunk-hw1gbr11.js} +1 -1
- package/dist/{chunk-nx8xb7dm.js → chunk-jkfkyedn.js} +1 -1
- package/dist/chunk-kd3k1q9z.js +1 -0
- package/dist/{chunk-n8w1jxsh.js → chunk-kfkvdj49.js} +1 -1
- package/dist/chunk-m9mw8ppy.js +1 -0
- package/dist/{chunk-xshrj2nd.js → chunk-mdew58v9.js} +1 -1
- package/dist/{chunk-n4q6fvqe.js → chunk-mvm1rzc4.js} +2 -2
- package/dist/{chunk-qm632an7.js → chunk-p00f53yq.js} +1 -1
- package/dist/{chunk-p7349xay.js → chunk-p2sp2e0a.js} +2 -2
- package/dist/chunk-pj69j4zp.js +2 -0
- package/dist/{chunk-41byj2h8.js → chunk-pk11fexz.js} +2 -2
- package/dist/chunk-qahz5x5c.js +14 -0
- package/dist/{chunk-6m4sqwj0.js → chunk-qcvxff27.js} +2 -2
- package/dist/{chunk-p2rxrxct.js → chunk-r9tawy93.js} +3 -3
- package/dist/{chunk-rz2wc93t.js → chunk-s2atpv23.js} +4 -4
- package/dist/chunk-saedy6bj.js +1 -0
- package/dist/{chunk-fgbqm2jh.js → chunk-sfe4810k.js} +1 -1
- package/dist/{chunk-96w8ay2h.js → chunk-sj1dzeta.js} +1 -1
- package/dist/chunk-sn71fsm5.js +1 -0
- package/dist/{chunk-yysqw1cq.js → chunk-ss4sncn3.js} +2 -2
- package/dist/chunk-ss86eq2h.js +23 -0
- package/dist/{chunk-ektgnqmh.js → chunk-sx77dpxw.js} +1 -1
- package/dist/chunk-t4apxzp1.js +2 -0
- package/dist/chunk-te6203yf.js +1 -0
- package/dist/{chunk-gxwkwkhp.js → chunk-tkydv9k8.js} +1 -1
- package/dist/{chunk-60he05xs.js → chunk-tw5fr07c.js} +2 -2
- package/dist/{chunk-q3y3s16v.js → chunk-v52wc8yg.js} +2 -2
- package/dist/{chunk-b408cqg1.js → chunk-v5hzk7j2.js} +2 -2
- package/dist/{chunk-v4nqv1pr.js → chunk-v94ztjtp.js} +385 -385
- package/dist/{chunk-85jv1sr7.js → chunk-xa9k5pjt.js} +2 -2
- package/dist/{chunk-mvgmsjwq.js → chunk-z03dtyh6.js} +1 -1
- package/dist/{chunk-jxc67ydz.js → chunk-zc91c7b5.js} +2 -2
- package/dist/{chunk-mm05y2c5.js → chunk-zkzhm39s.js} +1 -1
- package/dist/{chunk-1xg7qx35.js → chunk-zwjrensv.js} +1 -1
- package/dist/web/assets/ChatView-Bg36FUaj.js +53 -0
- package/dist/web/assets/{CodeBlockHighlighter-0VOa5Mes.js → CodeBlockHighlighter-D5rB73Eo.js} +2 -2
- package/dist/web/assets/FilePreview-BxaBSmap.js +65 -0
- package/dist/web/assets/KanbanBoard-B4gx3JMo.js +16 -0
- package/dist/web/assets/{MarkdownRenderer-3g4TPTeI.js → MarkdownRenderer-BRH7LHhN.js} +3 -3
- package/dist/web/assets/ScrollArea-DikU3QeQ.js +1 -0
- package/dist/web/assets/SessionHistorySurface-DG80d6-F.js +6 -0
- package/dist/web/assets/{SettingsModal-3GMy6V-E.js → SettingsModal-Bxqkok81.js} +3 -3
- package/dist/web/assets/Sidebar-DGaHGcHx.js +31 -0
- package/dist/web/assets/TaskSwitcher-DOnLPurk.js +26 -0
- package/dist/web/assets/TerminalPanel-BzhCF9vw.js +6 -0
- package/dist/web/assets/archive-BiDGrqry.js +6 -0
- package/dist/web/assets/{arrow-left-03GxbYI7.js → arrow-left-BY-esOAP.js} +1 -1
- package/dist/web/assets/{calendar-clock-8W4ostX1.js → calendar-clock-BCyxvfVt.js} +1 -1
- package/dist/web/assets/chevron-right-Bg-10yuN.js +6 -0
- package/dist/web/assets/{chevrons-up-down-BboZzEAk.js → chevrons-up-down-M5SAJq7T.js} +1 -1
- package/dist/web/assets/{clock-3-aXgeptZP.js → clock-3-v-nHTA0A.js} +1 -1
- package/dist/web/assets/copy-p1zc_rjZ.js +6 -0
- package/dist/web/assets/download-D_-kbJXR.js +6 -0
- package/dist/web/assets/{external-link-UkIIC2ds.js → external-link-wSGTIqe3.js} +1 -1
- package/dist/web/assets/{folder-BOCc5dv2.js → folder-Ltm9jCS5.js} +1 -1
- package/dist/web/assets/index-B4186fIT.css +1 -0
- package/dist/web/assets/index-_xnlrekR.js +210 -0
- package/dist/web/assets/{pause-DVIT6IIr.js → pause-_LvCZkxM.js} +1 -1
- package/dist/web/assets/pencil-DB6ICr_h.js +6 -0
- package/dist/web/assets/{play-DsdF5dji.js → play-BRXP1rHJ.js} +1 -1
- package/dist/web/assets/plus-BqvjEpLw.js +6 -0
- package/dist/web/assets/session-events-AGMXvPey.js +22 -0
- package/dist/web/assets/settings-LfQbDvBA.js +6 -0
- package/dist/web/assets/teamService-B5FnUcet.js +1 -0
- package/dist/web/assets/terminal-By4sO9Gw.js +6 -0
- package/dist/web/assets/vendor-radix-D6QrtXqd.js +45 -0
- package/dist/web/index.html +3 -3
- package/package.json +1 -1
- package/dist/chunk-0ktte40x.js +0 -185
- package/dist/chunk-1acb8fwq.js +0 -120
- package/dist/chunk-3pwqqk7w.js +0 -1
- package/dist/chunk-3q7g9206.js +0 -1
- package/dist/chunk-562w5zc6.js +0 -2
- package/dist/chunk-5x56nka1.js +0 -1
- package/dist/chunk-7hajkvde.js +0 -1
- package/dist/chunk-9wptwfmg.js +0 -1
- package/dist/chunk-ap01rwg0.js +0 -169
- package/dist/chunk-cm8fy1jn.js +0 -1
- package/dist/chunk-dp4r5bay.js +0 -1
- package/dist/chunk-dtxza4zh.js +0 -1
- package/dist/chunk-hd7bxzvy.js +0 -1
- package/dist/chunk-hks48s9k.js +0 -1
- package/dist/chunk-hmncnf7p.js +0 -1
- package/dist/chunk-j6fj679p.js +0 -10
- package/dist/chunk-m8czdpyg.js +0 -1
- package/dist/chunk-p5awnndq.js +0 -8
- package/dist/chunk-s7peh6kf.js +0 -2
- package/dist/chunk-ws6gtw33.js +0 -1
- package/dist/chunk-wtmhqy5s.js +0 -1
- package/dist/chunk-xnstybjm.js +0 -2
- package/dist/chunk-xpdtg9h9.js +0 -23
- package/dist/chunk-z2jwm4s8.js +0 -1
- package/dist/web/assets/ChatView-DCHnicTP.js +0 -58
- package/dist/web/assets/FilePreview-C_3KHzzj.js +0 -65
- package/dist/web/assets/KanbanBoard-D_NTkUnD.js +0 -16
- package/dist/web/assets/TaskSwitcher-eCdxu5Eo.js +0 -26
- package/dist/web/assets/TerminalPanel-9q9Trmv9.js +0 -6
- package/dist/web/assets/index-DGf6Z2kM.css +0 -1
- package/dist/web/assets/index-DaiT-mmo.js +0 -275
- package/dist/web/assets/session-events-CWzF04l4.js +0 -22
- package/dist/web/assets/teamService-BliaDj1Z.js +0 -1
- package/dist/web/assets/vendor-radix-Bc1_Q9tz.js +0 -45
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{Mj as F,ok as $}from"./chunk-pj69j4zp.js";import{promises as J}from"node:fs";import Q from"node:path";import{Mutex as U}from"async-mutex";import w from"write-file-atomic";var X=1;function D(k){if(!k||typeof k!=="object"||Array.isArray(k))return!1;let q=k;return typeof q.path==="string"&&Q.isAbsolute(q.path)&&typeof q.boundAt==="string"}async function Z(k){if(!Q.isAbsolute(k))throw Error("Project path must be absolute");let q=await J.realpath(k);if(!(await J.stat(q)).isDirectory())throw Error("Project path must be a directory");return q}class K{filePath;mutex=new U;constructor(k=Q.join(F(),"bound-projects.json")){this.filePath=k}async list(k){let q=await this.read(),z=await Z(k),H=new Map;for(let C of q.projects)H.set(C.path,C);if(!H.has(z))H.set(z,{path:z,boundAt:new Date(0).toISOString()});return(await Promise.all([...H.values()].map(async(C)=>{let L=!1;try{L=(await J.stat(C.path)).isDirectory()}catch{}return{path:C.path,name:Q.basename(C.path)||C.path,...L?{gitBranch:$(C.path)}:{},available:L,isCurrent:C.path===z,boundAt:C.boundAt}}))).sort((C,L)=>{if(C.isCurrent!==L.isCurrent)return C.isCurrent?-1:1;return C.name.localeCompare(L.name)})}async bind(k,q){return this.mutex.runExclusive(async()=>{let z=await Z(k),H=await this.read(),W=H.projects.find((M)=>M.path===z),C=W??{path:z,boundAt:new Date().toISOString()};if(!W)H.projects.push(C),await this.write(H);let L=await Z(q),A=$(z);return{path:z,name:Q.basename(z)||z,...A?{gitBranch:A}:{},available:!0,isCurrent:z===L,boundAt:C.boundAt}})}async unbind(k){return this.mutex.runExclusive(async()=>{if(!Q.isAbsolute(k))throw Error("Project path must be absolute");let q=await J.realpath(k).catch(()=>Q.resolve(k)),z=await this.read(),H=z.projects.filter((W)=>W.path!==q);if(H.length===z.projects.length)return!1;return z.projects=H,await this.write(z),!0})}async read(){try{let k=await J.readFile(this.filePath,"utf8"),q=JSON.parse(k);if(q.version!==X||!Array.isArray(q.projects))return{version:X,projects:[]};return{version:X,projects:q.projects.filter(D)}}catch(k){if(k.code==="ENOENT"||k instanceof SyntaxError)return{version:X,projects:[]};throw k}}async write(k){let q=Q.dirname(this.filePath);await J.mkdir(q,{recursive:!0,mode:448}),await J.chmod(q,448),await w(this.filePath,`${JSON.stringify(k,null,2)}
|
|
2
2
|
`,{mode:384}),await J.chmod(this.filePath,384)}}var _=new K;
|
|
3
|
-
export{_ as
|
|
3
|
+
export{_ as j};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Af as d,Bf as e,Cf as f,Df as g,Ef as h,Ff as i,Gf as j,Hf as k,If as l,Jf as m,Kf as n,Lf as o,Mf as p,Nf as q,xf as a,yf as b,zf as c}from"./chunk-zc91c7b5.js";import"./chunk-v508x7cg.js";import"./chunk-mdew58v9.js";import"./chunk-hhg1zcbq.js";import"./chunk-jkfkyedn.js";import"./chunk-f8gb685p.js";import"./chunk-44jtpg8y.js";import"./chunk-sj1dzeta.js";import"./chunk-2y1qngw7.js";import"./chunk-ar5np5h5.js";import"./chunk-dfjmvj3d.js";import"./chunk-tkydv9k8.js";import"./chunk-v5hzk7j2.js";import"./chunk-qcvxff27.js";import"./chunk-zwjrensv.js";import"./chunk-pj69j4zp.js";import"./chunk-zkzhm39s.js";export{a as vanillaStore,c as sessionActions,l as getThinkingModeEnabled,b as getState,n as getServiceTier,o as getResponseVerbosity,m as getReasoningEffort,j as getModelById,e as getMessages,k as getMcpServers,i as getCurrentModel,f as getConfig,p as getCommunicationStyle,h as getAllModels,g as ensureStoreInitialized,q as configActions,d as appActions};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Nd as a,Od as b,Pd as c,Qd as d,Rd as e,Sd as f,Td as g}from"./chunk-7jj607dg.js";import"./chunk-53h87fmt.js";import"./chunk-gfbkrk60.js";import"./chunk-0z9nqbd0.js";import"./chunk-edtxcqxa.js";import"./chunk-aaxc81jc.js";import"./chunk-g4xny949.js";import"./chunk-f8gb685p.js";import"./chunk-44jtpg8y.js";import"./chunk-sj1dzeta.js";import"./chunk-ar5np5h5.js";import"./chunk-tkydv9k8.js";import"./chunk-v5hzk7j2.js";import"./chunk-pj69j4zp.js";import"./chunk-zkzhm39s.js";export{b as __setSessionSnapshotIOForTesting,c as __resetSessionSnapshotIOForTesting,g as SessionService,d as SessionMissingCreationError,e as SessionArchivedError,f as SessionArchiveConflictError,a as STALE_EMPTY_SESSION_AGE_MS};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{zi as K}from"./chunk-jkfkyedn.js";import{Ai as wt,Bi as ft}from"./chunk-f8gb685p.js";import{Ii as I}from"./chunk-44jtpg8y.js";import{Ji as bn,Ki as _n,Li as T}from"./chunk-sj1dzeta.js";import{$i as Ft,Pi as tt,Qi as Dt,Ri as Bt,Vi as Gt,Wi as et,Xi as Kt,Yi as Ht,Zi as Yt,_i as cn,aj as qt,bj as Mt,cj as Vt,dj as Jt,ej as _t,fj as Qt,gj as jt,hj as Wt,ij as Zt,jj as kt,kj as yt}from"./chunk-2y1qngw7.js";import{oj as Un}from"./chunk-ar5np5h5.js";import{rj as zt,uj as v}from"./chunk-dfjmvj3d.js";import{Cj as xn,Dj as Cn}from"./chunk-v5hzk7j2.js";import{Jj as a}from"./chunk-qcvxff27.js";import{Mj as Ln}from"./chunk-pj69j4zp.js";var lt=/^[\x21\x23-\x5b\x5d-\x7e]+$/;function vt(n){return n==="127.0.0.1"||n==="[::1]"||n.toLowerCase()==="localhost"}function p(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:"&&vt(e.hostname)))throw Error(`${t} requires HTTPS; HTTP is allowed only for loopback servers`);return e}var B=async(n,t)=>{p(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 nn(n){let t=n.oauth;if(!t)return;let e=t;for(let E of["clientSecret","authorizationUrl","tokenUrl","redirectUri"])if(e[E]!==void 0)throw Error(`MCP OAuth "${E}" 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(p(n.url,"MCP OAuth server URL"),Object.keys(n.headers??{}).find((E)=>E.toLowerCase()==="authorization"))throw Error("MCP OAuth cannot be combined with a configured Authorization header");let _=t.clientId?.trim();if(_&&_.length>4096)throw Error("MCP OAuth clientId exceeds 4096 characters");let S=t.scopes?.map((E)=>E.trim());if(S){if(S.length>32)throw Error("MCP OAuth supports at most 32 scopes");if(S.some((E)=>!E||E.length>128||!lt.test(E)))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 r=t.callbackPort;if(r!==void 0&&(!Number.isInteger(r)||r<1024||r>65535))throw Error("MCP OAuth callbackPort must be between 1024 and 65535");return{enabled:!0,..._?{clientId:_}:{},...S?.length?{scopes:S}:{},...r!==void 0?{callbackPort:r}:{}}}import{randomUUID as Sn}from"node:crypto";import Te from"node:http";import{auth as dn}from"@modelcontextprotocol/sdk/client/auth.js";import se from"open";import{createHash as ne,randomUUID as te}from"node:crypto";import{constants as tn,promises as b}from"node:fs";import en from"node:path";import ee from"write-file-atomic";var Nn=1,Me=1048576,_e=5000,re=50,Se=/^[a-f0-9]{64}$/,Ee=T.Object({client_id:T.String({minLength:1,maxLength:4096})},{additionalProperties:!0}),ue=T.Object({access_token:T.String({minLength:1,maxLength:65536}),token_type:T.String({minLength:1,maxLength:64}),expires_in:T.Optional(T.Number({minimum:0})),refresh_token:T.Optional(T.String({minLength:1,maxLength:65536})),scope:T.Optional(T.String({maxLength:16384})),id_token:T.Optional(T.String({minLength:1,maxLength:262144}))},{additionalProperties:!1}),oe=T.Unsafe({type:"object",properties:{authorizationServerUrl:T.String({format:"uri"}),resourceMetadataUrl:T.Optional(T.String({format:"uri"})),resourceMetadata:T.Optional(T.Unknown()),authorizationServerMetadata:T.Optional(T.Unknown())},required:["authorizationServerUrl"],additionalProperties:!1}),an=T.Object({serverUrl:T.String({format:"uri"}),clientId:T.Optional(T.String({minLength:1,maxLength:4096})),clientInformation:T.Optional(Ee),tokens:T.Optional(ue),tokenExpiresAt:T.Optional(T.Number({minimum:0})),discoveryState:T.Optional(oe),updatedAt:T.String({format:"date-time"})},{additionalProperties:!1}),gn=T.Object({version:T.Literal(Nn),credentials:T.Record(T.String(),an)},{additionalProperties:!1});function G(n,t){return n instanceof Error&&"code"in n&&n.code===t}function me(n){if(!Number.isInteger(n)||n<=0)return!1;try{return process.kill(n,0),!0}catch(t){return G(t,"EPERM")}}function Mn(n){return structuredClone(n)}function In(n){if(Object.keys(n.credentials).some((t)=>!Se.test(t)))throw Error("MCP OAuth credential store contains an invalid identity")}function H(n){let t=new URL(n);return t.hash="",t.toString()}function rn(n,t,e=[]){return ne("sha256").update(JSON.stringify({serverUrl:H(n),clientId:t?.trim()||null,scopes:[...e].sort()})).digest("hex")}class f{static locks=new K;stateRoot;tokenFilePath;constructor(n=Ln()){this.stateRoot=en.join(n,"mcp"),this.tokenFilePath=en.join(this.stateRoot,"oauth-credentials.json")}static coordinationStatsForTests(){return this.locks.getStats()}async getCredential(n){return f.locks.runExclusive(this.tokenFilePath,async()=>{let e=(await this.readStore()).credentials[n];return e?Mn(e):null})}async updateCredential(n,t){return this.runMutation(async(e)=>{let M=e.credentials[n],_=await t(M?Mn(M):null);if(_)e.credentials[n]=_n(an,_);else delete e.credentials[n];return _?Mn(e.credentials[n]):null})}async deleteCredential(n){await this.updateCredential(n,()=>null)}async listCredentialIds(){return f.locks.runExclusive(this.tokenFilePath,async()=>Object.keys((await this.readStore()).credentials).sort())}async runMutation(n){return f.locks.runExclusive(this.tokenFilePath,async()=>{let t=await this.acquireStoreLock();try{let e=await this.readStore(),M=await n(e);return await this.writeStore(e),M}finally{await t()}})}async ensureStateRoot(){await b.mkdir(this.stateRoot,{recursive:!0,mode:448});let n=await b.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 b.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>Me)throw Error("MCP OAuth credential store exceeds the 1 MiB limit");let t=JSON.parse(await b.readFile(this.tokenFilePath,"utf8")),e=bn(gn,t);if(!e.success)throw Error("MCP OAuth credential store has an invalid schema");return In(e.data),e.data}catch(n){if(G(n,"ENOENT"))return{version:Nn,credentials:{}};throw n}}async writeStore(n){await this.ensureStateRoot();let t=_n(gn,n);In(t),await ee(this.tokenFilePath,`${JSON.stringify(t,null,2)}
|
|
2
2
|
`,{mode:384,encoding:"utf8"}),await b.chmod(this.tokenFilePath,384)}async acquireStoreLock(){await this.ensureStateRoot();let n=en.join(this.stateRoot,".oauth-credentials.lock"),t=te(),e=Date.now()+_e;while(Date.now()<e)try{let M=await b.open(n,tn.O_CREAT|tn.O_EXCL|tn.O_WRONLY,384);return await M.writeFile(`${JSON.stringify({version:1,pid:process.pid,token:t,createdAt:new Date().toISOString()})}
|
|
3
3
|
`,"utf8"),await M.close(),async()=>{try{if(JSON.parse(await b.readFile(n,"utf8")).token===t)await b.unlink(n)}catch(_){if(!G(_,"ENOENT"))throw _}}}catch(M){if(!G(M,"EEXIST"))throw M;await this.removeDeadLock(n),await new Promise((_)=>setTimeout(_,re))}throw Error("MCP OAuth credential store is busy; retry the operation")}async removeDeadLock(n){let t=await b.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 b.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(!me(e.pid))await b.unlink(n)}}var wn="127.0.0.1",fn=7777,Pn="/oauth/callback",Ae=300000;class En 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 hn extends Error{constructor(n){super(`MCP OAuth credentials are unavailable in this runtime for server "${n}"`);this.name="McpOAuthUnavailableError"}}function ce(n){let t=n?"Authentication complete":"Authentication failed";return`<!doctype html>
|
|
4
4
|
<html lang="en">
|
|
@@ -41,4 +41,4 @@ ${e.map((M)=>` - ${M}`).join(`
|
|
|
41
41
|
]
|
|
42
42
|
}
|
|
43
43
|
`)}}function W_(n,t={}){let e={...n};if(t.debug!==void 0)e.debug=t.debug===""?!0:t.debug;if(t.model){if(!n.models.some((_)=>_.id===t.model))throw Error(`模型配置未找到: ${t.model}`);e.currentModelId=t.model}if(t.yolo===!0)e.permissionMode="yolo";else if(t.permissionMode!==void 0)e.permissionMode=t.permissionMode;if(t.maxTurns!==void 0)e.maxTurns=t.maxTurns;if(t.maxConcurrentTasks!==void 0)e.maxConcurrentTasks=t.maxConcurrentTasks;if(t.maxQueuedTasks!==void 0)e.maxQueuedTasks=t.maxQueuedTasks;if(t.maxQueuedTaskBytes!==void 0)e.maxQueuedTaskBytes=t.maxQueuedTaskBytes;if(t.maxResidentSessionRuntimes!==void 0)e.maxResidentSessionRuntimes=t.maxResidentSessionRuntimes;if(t.sessionRuntimeIdleMs!==void 0)e.sessionRuntimeIdleMs=t.sessionRuntimeIdleMs;if(t.maxResidentSessionProjections!==void 0)e.maxResidentSessionProjections=t.maxResidentSessionProjections;if(t.sessionProjectionIdleMs!==void 0)e.sessionProjectionIdleMs=t.sessionProjectionIdleMs;return e.systemPrompt=t.systemPrompt,e.appendSystemPrompt=t.appendSystemPrompt,e.model=t.model,e.resumeSessionId=t.sessionId,e.forkSession=t.forkSession,e.allowedTools=t.allowedTools,e.disallowedTools=t.disallowedTools,e.mcpConfigPaths=t.mcpConfig,e.strictMcpConfig=t.strictMcpConfig,e.addDirs=t.addDir,e.outputFormat=t.outputFormat,e.inputFormat=t.inputFormat,e.print=t.print,e.includePartialMessages=t.includePartialMessages,e.replayUserMessages=t.replayUserMessages,e.agentsConfig=t.agents,e.settingSources=t.settingSources,e}
|
|
44
|
-
export{B as
|
|
44
|
+
export{B as jh,nn as kh,f as lh,En as mh,hn as nh,C as oh,ot as ph,VM as qh,W as rh,jM as sh,WM as th,ZM as uh,ct as vh,Ce as wh,kM as xh,he as yh,yM as zh,Pt as Ah,n_ as Bh,t_ as Ch,M_ as Dh,__ as Eh,r_ as Fh,Ct as Gh,S_ as Hh,E_ as Ih,u_ as Jh,o_ as Kh,Y as Lh,Rn as Mh,F as Nh,q as Oh,Xn as Ph,V as Qh,TM as Rh,sM as Sh,J as Th,Q as Uh,h as Vh,xM as Wh,zn as Xh,Dn as Yh,hM as Zh,Bn as _h,Gn as $h,Kn as ai,Hn as bi,Yn as ci,Fn as di,XM as ei,qn as fi,Vn as gi,Jn as hi,Qn as ii,jn as ji,Wn as ki,Zn as li,kn as mi,yn as ni,ln as oi,vn as pi,nt as qi,s as ri,d as si,Le as ti,z as ui,l as vi,X as wi,W_ as xi};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{Oa as H}from"./chunk-tw5fr07c.js";import"./chunk-77efqpdc.js";import"./chunk-53h87fmt.js";import{Hf as $,Nf as T}from"./chunk-zc91c7b5.js";import"./chunk-v508x7cg.js";import"./chunk-mdew58v9.js";import"./chunk-r9tawy93.js";import"./chunk-g4xny949.js";import"./chunk-hhg1zcbq.js";import"./chunk-jkfkyedn.js";import"./chunk-f8gb685p.js";import{Ii as k}from"./chunk-44jtpg8y.js";import"./chunk-sj1dzeta.js";import"./chunk-2y1qngw7.js";import"./chunk-ar5np5h5.js";import"./chunk-dfjmvj3d.js";import"./chunk-tkydv9k8.js";import"./chunk-v5hzk7j2.js";import"./chunk-qcvxff27.js";import"./chunk-zwjrensv.js";import"./chunk-pj69j4zp.js";import"./chunk-zkzhm39s.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,2 +1,2 @@
|
|
|
1
1
|
var F;((D)=>{D.DEFAULT="default";D.AUTO_EDIT="autoEdit";D.YOLO="yolo";D.PLAN="plan"})(F||={});import{Mutex as G}from"async-mutex";class H{entries=new Map;async runExclusive(C,E){let B=this.entries.get(C);if(!B)B={mutex:new G,operations:0},this.entries.set(C,B);B.operations++;try{return await B.mutex.runExclusive(E)}finally{if(B.operations--,B.operations===0&&this.entries.get(C)===B)this.entries.delete(C)}}getStats(){let C=0;for(let E of this.entries.values())C+=E.operations;return{keys:this.entries.size,operations:C}}}
|
|
2
|
-
export{F as
|
|
2
|
+
export{F as yi,H as zi};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{_f as a}from"./chunk-ajsw4te2.js";import"./chunk-2y1qngw7.js";import"./chunk-ar5np5h5.js";import"./chunk-dfjmvj3d.js";import"./chunk-tkydv9k8.js";import"./chunk-pj69j4zp.js";import"./chunk-zkzhm39s.js";export{a as createChatServiceAsync};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{k as o}from"./chunk-p2sp2e0a.js";import"./chunk-v5hzk7j2.js";import"./chunk-zkzhm39s.js";import{execSync as r}from"child_process";var l={command:"update",describe:"Check for updates and install if available",handler:async()=>{console.log("Checking for updates...");try{let e=await o(!0);if(console.log(`Current version: ${e.currentVersion}`),e.error){console.log(`Warning: ${e.error}`);return}if(e.latestVersion)console.log(`Latest version: ${e.latestVersion}`);if(e.hasUpdate&&e.latestVersion){console.log(""),console.log(`\x1B[33mUpdate available: ${e.currentVersion} -> ${e.latestVersion}\x1B[0m`),console.log(""),console.log("Updating...");try{r("npm install -g blade-code@latest --registry https://registry.npmjs.org",{stdio:"inherit"}),console.log(""),console.log("Update complete!")}catch(t){console.error("Error: Update failed. Please run manually:"),console.error(" npm install -g blade-code@latest"),process.exit(1)}}else console.log("You are running the latest version of Blade")}catch(e){console.error(`Error: Failed to check for updates: ${e instanceof Error?e.message:"未知错误"}`),process.exit(1)}}};export{l as updateCommands};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{$f as a,ag as b,bg as c}from"./chunk-mvm1rzc4.js";import"./chunk-edtxcqxa.js";import"./chunk-dfjmvj3d.js";import"./chunk-tkydv9k8.js";import"./chunk-pj69j4zp.js";import"./chunk-zkzhm39s.js";export{b as resolveModelConfig,c as getModelDisplayName,a as getModelApiKeyEnvironmentVariable};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import{nanoid as q}from"nanoid";var u=/^[A-Za-z0-9][A-Za-z0-9._-]*$/;function B(j="session",m=21){if(!u.test(j))throw Error(`Invalid session ID prefix: ${j}`);return`${j}-${q(m)}`}
|
|
2
|
-
export{B as
|
|
2
|
+
export{B as Of};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
2
|
-
export{D as
|
|
1
|
+
import{dg as B}from"./chunk-edtxcqxa.js";import{uj as Y}from"./chunk-dfjmvj3d.js";import{Aj as $,xj as Z}from"./chunk-tkydv9k8.js";import{createHash as H}from"node:crypto";var N="fast-mode-2026-02-01";function R(q,x,z){if(x.api!=="anthropic-messages"||z.providerValue!=="fast")return q;let J={...q},w=Object.keys(J).find((G)=>G.toLowerCase()==="anthropic-beta")??"anthropic-beta",Q=new Set((J[w]??"").split(",").map((G)=>G.trim()).filter(Boolean));return Q.add(N),J[w]=[...Q].join(","),J}function D(q){return`BLADE_MODEL_API_KEY_${H("sha256").update(q).digest("hex").slice(0,32).toUpperCase()}`}function F(q,x){if(!q.fallbackModels?.length)return;return q.fallbackModels.map((z)=>{let J=(x.models??[]).filter((G)=>G.provider===z.provider&&G.model===z.model),w=z.configId?(x.models??[]).find((G)=>G.id===z.configId):J.length===1?J[0]:void 0;if(z.configId&&!w)throw Error(`Unknown fallback model config ID: ${z.configId}`);if(w&&(w.provider!==z.provider||w.model!==z.model))throw Error(`Fallback model config ${w.id} does not match ${z.provider}/${z.model}`);if(!z.configId&&J.length>1)throw Error(`Fallback model ${z.provider}/${z.model} is ambiguous; set configId`);if(!w)return z;let Q=w.provider===q.provider;return{...z,configId:w.id,channel:{apiKey:process.env[D(w.id)]??(Q?process.env.BLADE_API_KEY:void 0),baseUrl:w.overrides?.baseUrl??(Q?process.env.BLADE_BASE_URL:void 0),temperature:w.overrides?.temperature??x.temperature,maxOutputTokens:w.overrides?.maxOutputTokens,timeout:w.overrides?.timeout??x.timeout,streamIdleTimeout:w.overrides?.streamIdleTimeout,apiVersion:w.overrides?.apiVersion,customHeaders:w.overrides?.customHeaders,enablePromptCaching:w.overrides?.enablePromptCaching}}})}function h(q,x,z,J=Y(),w="auto",Q="auto"){let G=J.resolveConfig(q),U=B(G,z),W=$(G,w),X=Z(G,Q),L=q.overrides;return{config:q,model:G,displayName:q.displayName??G.name,chat:{provider:q.provider,model:q.model,apiKey:process.env[D(q.id)]??process.env.BLADE_API_KEY,baseUrl:process.env.BLADE_BASE_URL??L?.baseUrl,temperature:L?.temperature??x.temperature,maxContextTokens:G.contextWindow,maxOutputTokens:L?.maxOutputTokens,timeout:L?.timeout??x.timeout,streamIdleTimeout:L?.streamIdleTimeout,reasoningEnabled:U.effective!=="off",...U.effective==="off"?{}:{reasoningEffort:U.effective},...W.providerValue?{serviceTier:W.providerValue}:{},...X.providerValue?{responseVerbosity:X.providerValue}:{},fallbackModels:F(q,x),enablePromptCaching:L?.enablePromptCaching,customHeaders:R(L?.customHeaders,G,W),apiVersion:L?.apiVersion,maxRetries:L?.maxRetries,providerCircuitBreakerOpenMs:x.providerCircuitBreakerOpenMs,providerRequestConcurrency:x.providerRequestConcurrency,providerGlobalConcurrency:x.providerGlobalConcurrency,providerOwnerConcurrency:x.providerOwnerConcurrency,providerRequestAdmissionMs:x.providerRequestAdmissionMs,providerRequestPendingBytes:x.providerRequestPendingBytes,modelCatalog:J},reasoning:U,serviceTier:W,responseVerbosity:X}}function j(q,x=Y()){try{return q.displayName??x.getModel(q.provider,q.model).name}catch{return q.displayName??q.model}}
|
|
2
|
+
export{D as $f,h as ag,j as bg};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{Ca as h,Ea as f,Fa as k}from"./chunk-6p6ts4kv.js";import"./chunk-zkzhm39s.js";var p={command:"status",describe:"Check the pinned Playwright Chromium installation",handler:async()=>{let c=await f();if(console.log(`Playwright: ${c.playwrightVersion}`),console.log(`Chromium executable: ${c.executablePath}`),!c.installed){console.error(`Chromium: unavailable (${c.error??"unknown error"})`),console.error(`Install with: ${h}`),process.exitCode=1;return}console.log(`Chromium: ${c.browserVersion}`),console.log("Status: ready")}},q={command:"install",describe:"Install Chromium for the pinned Playwright runtime",handler:async()=>{try{await k();let c=await f();if(!c.installed)throw Error(c.error??"Chromium is not runnable after installation");console.log(`Chromium installed: Playwright ${c.playwrightVersion}, ${c.browserVersion}`)}catch(c){console.error(`Browser installation failed: ${c instanceof Error?c.message:String(c)}`),process.exitCode=1}}},x={command:"browser",describe:"Manage the native Browser Tool runtime",builder:(c)=>c.command(p).command(q).demandCommand(1).strict(),handler:()=>{return}};export{p as browserStatusCommand,q as browserInstallCommand,x as browserCommands};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
2
|
-
export{_ as
|
|
1
|
+
import{Cj as S}from"./chunk-v5hzk7j2.js";import{rk as f}from"./chunk-zkzhm39s.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
|
+
export{_ as k,u as l,g as m,C as n,V as o};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import*as z from"node:os";import*as x from"node:path";function F(){return process.env.BLADE_STORAGE_ROOT||x.join(z.homedir(),".blade")}import{AsyncLocalStorage as Lq}from"node:async_hooks";import{createHash as Vq}from"node:crypto";import{lstat as L,mkdir as Cq,readdir as bq,realpath as N}from"node:fs/promises";import Z from"node:path";import{createHash as Gq}from"node:crypto";var E=new WeakSet,j=new WeakSet,Jq={"not-absolute":"ACP remote file path must be absolute","style-mismatch":"ACP remote file path does not match the expected style","drive-relative":"ACP remote file path cannot be drive-relative","root-relative":"ACP remote file path cannot be root-relative","unc-not-supported":"ACP remote file path must be absolute; UNC paths are not supported","device-namespace-not-supported":"ACP remote file path device namespaces are not supported","trailing-dot-or-space":"ACP remote file path components cannot end with a dot or space","alternate-data-stream":"ACP remote file path alternate data streams are not supported","reserved-device-name":"ACP remote file path reserved device names are not supported","short-name-alias":"ACP remote file path short-name aliases are not supported","invalid-character":"ACP remote file path contains characters that are not supported"},Oq=new Set(["CON","PRN","AUX","NUL","CONIN$","CONOUT$","COM1","COM2","COM3","COM4","COM5","COM6","COM7","COM8","COM9","LPT1","LPT2","LPT3","LPT4","LPT5","LPT6","LPT7","LPT8","LPT9","COM¹","COM²","COM³","LPT¹","LPT²","LPT³"]);class _ extends Error{reason;style;name="AcpRemotePathError";code="acp_remote_path_invalid";constructor(q,G){super(Jq[q]);this.reason=q;this.style=G;Object.setPrototypeOf(this,new.target.prototype)}toJSON(){return{name:this.name,code:this.code,reason:this.reason,style:this.style,message:this.message}}}class V extends Error{name="AcpRemotePathIdentityError";code="acp_remote_path_identity_invalid";constructor(){super("ACP remote path identity is invalid");Object.setPrototypeOf(this,new.target.prototype)}}function Qq(q){if(!E.has(q))throw new V}function Uq(q){if(!j.has(q))throw new V;if(Qq(q.workspace),q.style!==q.workspace.style)throw new V}function gq(q){Uq(q);let G=Object.freeze({style:q.style,workspace:q.workspace});return j.add(G),G}function Rq(q){let G=C(q),J=Object.freeze({style:G.style,workspace:G});return j.add(J),J}function C(q,G){let J=W(q,G);if(J.kind==="error")throw new _(J.reason,J.style);let O=J.style==="win32"?Yq(q):Xq(q);return k(J.style,O)}function Sq(q,G){let J=C(q),O=J.style==="win32"?Fq(J.wirePath,G):_q(J.wirePath,G);return k(J.style,O)}function W(q,G){if(R(q))return{kind:"error",reason:"device-namespace-not-supported",style:"win32"};if(g(q))return{kind:"error",reason:"unc-not-supported",style:G==="posix"?"posix":"win32"};if(S(q))return{kind:"error",reason:"unc-not-supported",style:"win32"};if(P(q)){if(G==="posix")return{kind:"error",reason:"style-mismatch",style:"posix"};return{kind:"absolute",style:"win32"}}if(Mq(q))return{kind:"error",reason:"drive-relative",style:"win32"};if(q.startsWith("\\"))return{kind:"error",reason:"root-relative",style:"win32"};if(q.startsWith("/")){if(G==="win32")return{kind:"error",reason:"style-mismatch",style:"win32"};return{kind:"absolute",style:"posix"}}return{kind:"error",reason:"not-absolute",style:"unknown"}}function k(q,G){let J=q==="win32"?G.toUpperCase():G,O=Object.freeze({style:q,wirePath:G,exactIdentity:I("acp-remote-exact-path",q,G),collisionIdentity:I("acp-remote-collision-path",q,J)});return E.add(O),O}function I(q,G,J){return`${q}:${Gq("sha256").update(`${G}\x00${J}`).digest("hex")}`}function Xq(q){let G=q.split("/"),J=[];for(let O of G.slice(1)){if(O.length===0||O===".")continue;if(O===".."){if(J.length>0)J.pop();continue}A(O),J.push(O)}return J.length===0?"/":`/${J.join("/")}`}function Yq(q){let G=q[0].toUpperCase(),J=Bq(q),O=[],Q="";for(let U of q.slice(2)){if(m(U)){if(Q.length>0)v(O,Q),Q="";continue}Q+=U}if(Q.length>0)v(O,Q);if(J&&O.length>0)throw new _("trailing-dot-or-space","win32");if(O.length===0)return`${G}:\\`;return`${G}:\\${O.join("\\")}`}function Zq(q,G){let J=q==="/"?[]:q.slice(1).split("/"),O=[...J];for(let Q of G.split("/")){if(Q.length===0||Q===".")continue;if(Q===".."){if(O.length===J.length)throw new _("not-absolute","posix");O.pop();continue}A(Q),O.push(Q)}return O.length===0?"/":`/${O.join("/")}`}function _q(q,G){if(R(G))throw new _("device-namespace-not-supported","win32");if(g(G))throw new _("unc-not-supported","posix");if(S(G))throw new _("unc-not-supported","win32");if(P(G)||G.startsWith("/"))throw new _("style-mismatch","posix");return Zq(q,G)}function $q(q,G){let J=q.indexOf("\\"),O=J===q.length-1?[]:q.slice(J+1).split("\\"),Q=[...O],U="";for(let K of G){if(m(K)){if(U.length>0)y(O.length,Q,U),U="";continue}U+=K}if(U.length>0)y(O.length,Q,U);let $=q.slice(0,J+1);if(Q.length===0)return $;return`${$}${Q.join("\\")}`}function Fq(q,G){let J=W(G,"win32");if(J.kind==="absolute")throw new _("style-mismatch","win32");if(J.reason!=="not-absolute")throw new _(J.reason,J.style);return $q(q,G)}function y(q,G,J){if(J===".")return;if(J===".."){if(G.length===q)throw new _("not-absolute","win32");G.pop();return}f(J),G.push(J)}function v(q,G){if(G===".")return;if(G===".."){if(q.length>0)q.pop();return}f(G),q.push(G)}function A(q){if(q.includes("\x00"))throw new _("invalid-character","posix")}function f(q){let G=Hq(q),J=Kq(G);if(J!==void 0&&Oq.has(J.toUpperCase()))throw new _("reserved-device-name","win32");if(G!==q)throw new _("trailing-dot-or-space","win32");if(q.includes(":"))throw new _("alternate-data-stream","win32");if(/~\d/u.test(q))throw new _("short-name-alias","win32");for(let O of q){let Q=O.codePointAt(0);if(Q===void 0||Q===0||Q>=1&&Q<=31||'<>"|?*'.includes(O))throw new _("invalid-character","win32")}}function Hq(q){let G=q.length;while(G>0){let J=q[G-1];if(J!=="."&&J!==" ")break;G-=1}return q.slice(0,G)}function Kq(q){if(q.length===0)return;let G=q.indexOf(".");return G===-1?q:q.slice(0,G)}function g(q){return q.startsWith("//")||q.startsWith("/\\")}function R(q){return/^([\\/]){2}[?.][\\/]/u.test(q)}function S(q){return/^[\\/]{2}/u.test(q)}function P(q){return/^[A-Za-z]:[\\/]/u.test(q)}function Mq(q){return/^[A-Za-z]:(?![\\/])/u.test(q)}function m(q){return q==="\\"||q==="/"}function Bq(q){if(q.length<=3)return!1;let G=q[q.length-1];return G==="\\"||G==="/"}var H="acp-remote-workspaces",d=/^[a-f0-9]{64}$/,b=new Map,h=new Lq,Nq;class X extends Error{name="AcpRemoteWorkspaceStateError";code="acp_remote_workspace_state_invalid";constructor(q){super(`ACP remote workspace durable state is invalid (${q})`);Object.setPrototypeOf(this,new.target.prototype)}}function iq(q){return{version:1,kind:"acp-remote",style:q.style,wirePath:q.workspace.wirePath,exactIdentity:q.workspace.exactIdentity,collisionIdentity:q.workspace.collisionIdentity}}function Tq(q){if(!q||typeof q!=="object"||Array.isArray(q))throw new X("descriptor-shape");let G=q;if(G.version!==1)throw new X("descriptor-version");if(G.kind!=="acp-remote")throw new X("descriptor-kind");if(G.style!=="posix"&&G.style!=="win32")throw new X("descriptor-style");if(typeof G.wirePath!=="string"||typeof G.exactIdentity!=="string"||typeof G.collisionIdentity!=="string")throw new X("descriptor-shape");let J;try{J=C(G.wirePath,G.style)}catch{throw new X("descriptor-wire-path")}if(J.exactIdentity!==G.exactIdentity||J.collisionIdentity!==G.collisionIdentity)throw new X("descriptor-identity");return{version:1,kind:"acp-remote",style:G.style,wirePath:J.wirePath,exactIdentity:J.exactIdentity,collisionIdentity:J.collisionIdentity}}function cq(q,G=F()){if(typeof q!=="string"||!/^acp-remote-collision-path:[a-f0-9]{64}$/.test(q))throw new X("descriptor-collision-identity");let J=Z.resolve(G),O=Vq("sha256").update(`acp-remote-host-state\x00${q}`).digest("hex");return Z.join(J,H,O)}async function sq(q){let G=Z.resolve(F());await jq(q,G)}async function rq(q,G){let J=Z.resolve(F());return s(q,J,G)}async function oq(q,G){let J=String(q);if(Z.dirname(G)!==J)throw new X("state-file-path");let O=await L(G);if(O.isSymbolicLink()||!O.isFile())throw new X("state-file-type");if(typeof process.getuid==="function"&&O.uid!==process.getuid())throw new X("state-file-owner");let Q=typeof O.mode==="bigint"?Number(O.mode&BigInt(511)):O.mode&511;if(process.platform!=="win32"&&Q!==384)throw new X("state-file-mode");await M(G,J,Z.basename(G))}async function aq(q,G,J){let O=String(q);if(Z.dirname(G)!==O)throw new X("state-file-path");let[Q,U]=await Promise.all([J.stat({bigint:!0}),L(G,{bigint:!0})]);if(U.isSymbolicLink()||!U.isFile()||!Q.isFile()||U.dev!==Q.dev||U.ino!==Q.ino)throw new X("state-file-replaced");if(typeof process.getuid==="function"&&(Number(U.uid)!==process.getuid()||Number(Q.uid)!==process.getuid()))throw new X("state-file-owner");let $=Number(U.mode&BigInt(511)),K=Number(Q.mode&BigInt(511));if(process.platform!=="win32"&&($!==384||K!==384))throw new X("state-file-mode");await M(G,O,Z.basename(G))}function tq(q,G,J,O){let Q=q[0];if(Q?.type!=="session_created"||Q.sessionId!==G||Q.data.sessionId!==G||Q.cwd!==J||Q.projectPath!==J)throw new X("remote-session-identity");if(O){let U=Tq(Q.data.remoteWorkspace);if(U.version!==O.version||U.kind!==O.kind||U.style!==O.style||U.wirePath!==O.wirePath||U.exactIdentity!==O.exactIdentity||U.collisionIdentity!==O.collisionIdentity)throw new X("remote-session-workspace")}for(let U of q)if(U.sessionId!==G||U.cwd!==J||U.projectPath!==J)throw new X("remote-session-event-identity");return Q}function n(q){return d.test(q)}async function p(q=F()){let G=Z.resolve(q);return u(`${G}\x00${H}`,async()=>{let J=Z.join(G,H),O;try{O=await c(G,(U)=>bq(U,{withFileTypes:!0}))}catch(U){if(U.code==="ENOENT")return[];throw U}await Nq?.();let Q=[];for(let U of O){if(!n(U.name))continue;let $=Z.join(J,U.name);try{let K=await s($,G,async(qq)=>qq);Q.push(K)}catch(K){if(K.code==="ENOENT")throw new X("protected-root-missing");throw K}}return Q.sort((U,$)=>U.localeCompare($))})}function i(q,G){if(typeof q!=="string"||!Z.isAbsolute(q))throw new X("protected-root-shape");let J=Z.resolve(q);if(J!==q)throw new X("protected-root-shape");let O=Z.relative(G,J),Q=`${H}${Z.sep}`;if(O===""||O===H||!O.startsWith(Q)||O.includes(`${Z.sep}..`)||O.startsWith(`..${Z.sep}`)||Z.isAbsolute(O))throw new X("protected-root-shape");let U=O.split(Z.sep);if(U.length!==2||U[0]!==H)throw new X("protected-root-shape");if(!d.test(U[1]??""))throw new X("protected-root-digest");return{storageRoot:G,digest:U[1]}}async function c(q,G){await r(q,q);let J=Z.join(q,H);try{await D(J,q),await M(J,q,H)}catch(O){if(O.code==="ENOENT")throw O;throw O}return G(J)}async function jq(q,G){await u(q,async()=>{let J=i(q,G);if(J.storageRoot!==G)throw new X("storage-root-mismatch");await r(J.storageRoot,G);let O=Z.join(J.storageRoot,H);await l(O,J.storageRoot),await M(O,G,H);let Q=Z.join(O,J.digest);await l(Q,O),await M(Q,O,J.digest)})}async function s(q,G,J){return u(q,async()=>{let O=i(q,G);if(O.storageRoot!==G)throw new X("storage-root-mismatch");let Q=Z.join(O.storageRoot,H);await c(G,async($)=>{if($!==Q)throw new X("protected-root-shape")});let U=Z.join(Q,O.digest);return await D(U,Q),await M(U,Q,O.digest),J(U)})}async function l(q,G){try{let J=await L(q);o(J,q)}catch(J){if(J.code!=="ENOENT")throw J;await Cq(q,{recursive:!1,mode:448})}await D(q,G)}async function D(q,G){let J=await L(q);o(J,q),await M(q,G,Z.basename(q))}async function r(q,G){let J=await L(q);Dq(J,q),await uq(q,G)}function Dq(q,G){a(q,G);let J=t(q);if(process.platform!=="win32"&&((J&448)!==448||(J&18)!==0))throw new X("protected-root-mode")}function o(q,G){a(q,G);let J=t(q);if(process.platform!=="win32"&&J!==448)throw new X("protected-root-mode")}function a(q,G){if(q.isSymbolicLink()||!q.isDirectory())throw new X("protected-root-symlink");if(typeof process.getuid==="function"&&q.uid!==process.getuid())throw new X("protected-root-owner");if(G.includes(`..${Z.sep}`))throw new X("protected-root-shape")}function t(q){return typeof q.mode==="bigint"?Number(q.mode&BigInt(511)):q.mode&511}async function M(q,G,J){let O=await N(q),Q=await N(G),U=Z.join(Q,J);if(O!==U)throw new X("protected-root-realpath")}async function uq(q,G){let J=await N(q),O=await N(G);if(J!==O)throw new X("protected-root-realpath")}async function u(q,G){let J=h.getStore();if(J?.has(q))throw new X("state-root-reentry");let O=b.get(q)??Promise.resolve(),Q=new Set(J??[]);Q.add(q);let U=O.catch(()=>{return}).then(()=>h.run(Q,G)),$=U.then(()=>{return},()=>{return});b.set(q,$);try{return await U}finally{if(b.get(q)===$)b.delete(q)}}import{execSync as wq}from"node:child_process";import{createHash as zq}from"node:crypto";import{realpathSync as xq}from"node:fs";import{readdir as Iq}from"node:fs/promises";import*as Y from"node:path";function yq(q){return Y.resolve(q).replace(/[/\\]/g,"-").replace(/:/g,"_")}function vq(q){let G=q.replace(/_/g,":");if(G.startsWith("-"))G="/"+G.slice(1);return G.replace(/-/g,"/")}function Eq(q){let G=yq(q);return Y.join(F(),"projects",G)}function e(q){let G=Y.resolve(q),J=[];while(!0)try{return Y.resolve(xq.native(G),...J.reverse())}catch(O){let Q=O.code;if(Q!=="ENOENT"&&Q!=="ENOTDIR")throw O;let U=Y.dirname(G);if(U===G)return Y.resolve(q);J.push(Y.basename(G)),G=U}}function XG(q,G="projectPath"){if(!Y.isAbsolute(q))throw Error(`${G} must be absolute`);let J=Y.resolve(q),O=e(J),Q=Y.join(e(F()),"acp-remote-workspaces"),U=Y.relative(Q,O),$=U.split(Y.sep)[0];if(U===""||U!==".."&&!Y.isAbsolute(U)&&!U.startsWith(`..${Y.sep}`)&&$!==void 0&&/^[a-f0-9]{64}$/i.test($))throw Error(`${G} must reference a local workspace`);return J}function w(q){return Eq(q)}function T(q){return String(q)}function Wq(q){return typeof q==="string"&&q!=="."&&q!==".."&&/^[A-Za-z0-9_-][A-Za-z0-9._-]{0,199}$/.test(q)}function B(q){if(!Wq(q))throw Error(`Invalid session ID: ${q}`)}function YG(q,G){return B(G),Y.join(w(q),`${G}.jsonl`)}function ZG(q,G){return B(G),Y.join(T(q),`${G}.jsonl`)}function _G(q,G){return B(G),Y.join(w(q),`${G}.inbox.json`)}function $G(q,G){return B(G),Y.join(T(q),`${G}.inbox.json`)}function FG(q,G){return B(G),Y.join(w(q),`${G}.goal.json`)}function HG(q,G){return B(G),Y.join(T(q),`${G}.goal.json`)}function KG(q,G){B(G);let J=zq("sha256").update(G).digest("hex");return Y.join(T(q),`.session-lease-${J}.lock`)}function MG(q){try{return wq("git rev-parse --abbrev-ref HEAD",{cwd:q,encoding:"utf-8",stdio:["ignore","pipe","ignore"]}).trim()||void 0}catch{return}}async function kq(){try{let q=Y.join(F(),"projects");return(await Iq(q,{withFileTypes:!0})).filter((J)=>J.isDirectory()).map((J)=>J.name)}catch{return[]}}async function BG(){let q=Y.resolve(F()),G=await kq().then((O)=>O.map((Q)=>({storagePath:Y.join(q,"projects",Q),projectPath:vq(Q),kind:"local"}))).catch(()=>[]),J=await p().then((O)=>O.map((Q)=>({storagePath:String(Q),projectPath:String(Q),kind:"acp-remote"})));return[...G,...J]}
|
|
2
|
+
export{F as Mj,_ as Nj,Qq as Oj,Uq as Pj,gq as Qj,Rq as Rj,C as Sj,Sq as Tj,X as Uj,iq as Vj,Tq as Wj,cq as Xj,sq as Yj,rq as Zj,oq as _j,aq as $j,tq as ak,p as bk,vq as ck,Eq as dk,XG as ek,Wq as fk,B as gk,YG as hk,ZG as ik,_G as jk,$G as kk,FG as lk,HG as mk,KG as nk,MG as ok,kq as pk,BG as qk};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{ff as v}from"./chunk-gmqpfm52.js";import{yf as e}from"./chunk-zc91c7b5.js";import{Lh as y,Nh as D,Oh as h,Qh as A,Xh as P,Yh as T,_h as E,ai as _,bi as f,di as C,hi as S,ii as m,ji as c,ki as p,mi as u,ni as d,ri as l,wi as i,xi as t}from"./chunk-hhg1zcbq.js";import{yi as Y}from"./chunk-jkfkyedn.js";import{Gi as X}from"./chunk-44jtpg8y.js";import{Ji as x,Li as k,Oi as Z}from"./chunk-sj1dzeta.js";import{$i as I,Qi as U,Ri as L,Xi as M,Yi as O,_i as $,aj as G,cj as N,dj as j,fj as F,gj as R}from"./chunk-2y1qngw7.js";import{oj as s}from"./chunk-ar5np5h5.js";import{promises as a}from"node:fs";import g from"node:path";var r=["systemPrompt","appendSystemPrompt","initialMessage","resumeSessionId","forkSession","allowedTools","disallowedTools","mcpConfigPaths","strictMcpConfig","model","addDirs","outputFormat","inputFormat","print","includePartialMessages","replayUserMessages","agentsConfig","settingSources"],kk=new Set([...Object.keys(l),...r,"providerRequestConcurrency","providerGlobalConcurrency","providerOwnerConcurrency"]),W=k.Number({exclusiveMinimum:0}),z=k.String({minLength:1}),b=k.Array(k.String()),qk=k.Object({currentModelId:k.Optional(k.String()),modelProviders:k.Optional(k.Record(z,k.Object({name:z,baseUrl:z,wireApi:Z(["openai-completions","anthropic-messages"]),apiKeyEnv:k.Optional(z)}))),models:k.Optional(k.Array(k.Object({id:z,displayName:k.Optional(z),provider:z,model:z,overrides:k.Optional(k.Object({baseUrl:k.Optional(k.String()),temperature:k.Optional(k.Number()),maxOutputTokens:k.Optional(W),timeout:k.Optional(W),streamIdleTimeout:k.Optional(k.Number({minimum:1000})),apiVersion:k.Optional(k.String()),customHeaders:k.Optional(k.Record(k.String(),k.String())),maxRetries:k.Optional(k.Integer({minimum:0})),enablePromptCaching:k.Optional(k.Boolean())})),fallbackModels:k.Optional(k.Array(k.Object({provider:z,model:z,configId:k.Optional(z)})))}))),temperature:k.Optional(k.Number()),maxOutputTokens:k.Optional(W),stream:k.Optional(k.Boolean()),topP:k.Optional(k.Number()),topK:k.Optional(k.Number()),timeout:k.Optional(W),bashForegroundHandoffMs:k.Optional(k.Union([k.Literal(0),k.Integer({minimum:P,maximum:T})])),providerForegroundRecoveryMs:k.Optional(k.Union([k.Literal(0),k.Integer({minimum:U,maximum:L})])),providerCircuitBreakerOpenMs:k.Optional(k.Union([k.Literal(0),k.Integer({minimum:M,maximum:O})])),providerRequestConcurrency:k.Optional(k.Integer({minimum:$,maximum:I})),providerGlobalConcurrency:k.Optional(k.Integer({minimum:$,maximum:G})),providerOwnerConcurrency:k.Optional(k.Integer({minimum:$,maximum:G})),providerRequestAdmissionMs:k.Optional(k.Union([k.Literal(0),k.Integer({minimum:N,maximum:j})])),providerRequestPendingBytes:k.Optional(k.Integer({minimum:F,maximum:R})),agentTeamsEnabled:k.Optional(k.Boolean()),codeTheme:k.Optional(k.String()),uiTheme:k.Optional(Z(["light","dark","system"])),language:k.Optional(k.String()),fontSize:k.Optional(W),autoSaveSessions:k.Optional(k.Boolean()),notifyBuild:k.Optional(k.Boolean()),notifyErrors:k.Optional(k.Boolean()),notifySounds:k.Optional(k.Boolean()),privacyTelemetry:k.Optional(k.Boolean()),privacyCrash:k.Optional(k.Boolean()),debug:k.Optional(k.Union([k.Boolean(),k.String()])),mcpEnabled:k.Optional(k.Boolean()),mcpServers:k.Optional(k.Record(k.String(),k.Record(k.String(),k.Unknown()))),lspServers:k.Optional(k.Record(z,k.Object({command:z,args:k.Optional(k.Array(k.String())),extensionToLanguage:k.Record(z,z),env:k.Optional(k.Record(k.String(),k.String())),initializationOptions:k.Optional(k.Unknown()),settings:k.Optional(k.Unknown()),enabled:k.Optional(k.Boolean()),priority:k.Optional(k.Integer()),startupTimeout:k.Optional(k.Integer({minimum:100})),shutdownTimeout:k.Optional(k.Integer({minimum:100})),requestTimeout:k.Optional(k.Integer({minimum:100})),diagnosticWaitTimeout:k.Optional(k.Integer({minimum:0})),maxRestarts:k.Optional(k.Integer({minimum:0,maximum:10}))}))),permissionMode:k.Optional(k.Enum(Y)),maxTurns:k.Optional(k.Integer({minimum:-1})),maxConcurrentTasks:k.Optional(k.Integer({minimum:S,maximum:m})),maxQueuedTasks:k.Optional(k.Integer({minimum:c,maximum:p})),maxQueuedTaskBytes:k.Optional(k.Integer({minimum:u,maximum:d})),maxResidentSessionRuntimes:k.Optional(k.Integer({minimum:E,maximum:_})),sessionRuntimeIdleMs:k.Optional(k.Integer({minimum:f,maximum:C})),maxResidentSessionProjections:k.Optional(k.Integer({minimum:y,maximum:D})),sessionProjectionIdleMs:k.Optional(k.Integer({minimum:h,maximum:A})),systemPrompt:k.Optional(k.String()),appendSystemPrompt:k.Optional(k.String()),initialMessage:k.Optional(k.String()),resumeSessionId:k.Optional(k.String()),forkSession:k.Optional(k.Boolean()),allowedTools:k.Optional(k.Array(z)),disallowedTools:k.Optional(k.Array(z)),mcpConfigPaths:k.Optional(k.Array(z)),strictMcpConfig:k.Optional(k.Boolean()),model:k.Optional(z),addDirs:k.Optional(k.Array(z)),outputFormat:k.Optional(Z(["text","json","stream-json","jsonl"])),inputFormat:k.Optional(Z(["text","stream-json"])),print:k.Optional(k.Boolean()),includePartialMessages:k.Optional(k.Boolean()),replayUserMessages:k.Optional(k.Boolean()),agentsConfig:k.Optional(k.String()),settingSources:k.Optional(k.String()),permissions:k.Optional(k.Object({allow:k.Optional(b),ask:k.Optional(b),deny:k.Optional(b)})),env:k.Optional(k.Record(k.String(),k.String())),hooks:k.Optional(k.Record(k.String(),k.Unknown())),enabledPlugins:k.Optional(k.Record(z,k.Boolean())),pluginSourcePolicy:k.Optional(k.Object({restrictToAllowedSources:k.Optional(k.Boolean()),requireGitCommitSha:k.Optional(k.Boolean()),allowedGitHosts:k.Optional(k.Array(z)),allowedMarketplaces:k.Optional(k.Array(z)),allowedLocalRoots:k.Optional(k.Array(z))})),disableAllHooks:k.Optional(k.Boolean())}),wk=[["systemPrompt","systemPrompt"],["appendSystemPrompt","appendSystemPrompt"],["initialMessage","initialMessage"],["resumeSessionId","sessionId"],["forkSession","forkSession"],["allowedTools","allowedTools"],["disallowedTools","disallowedTools"],["mcpConfigPaths","mcpConfig"],["strictMcpConfig","strictMcpConfig"],["model","model"],["addDirs","addDir"],["outputFormat","outputFormat"],["inputFormat","inputFormat"],["print","print"],["includePartialMessages","includePartialMessages"],["replayUserMessages","replayUserMessages"],["agentsConfig","agents"],["settingSources","settingSources"],["permissionMode","permissionMode"],["maxTurns","maxTurns"],["maxConcurrentTasks","maxConcurrentTasks"],["maxQueuedTasks","maxQueuedTasks"],["maxQueuedTaskBytes","maxQueuedTaskBytes"],["maxResidentSessionRuntimes","maxResidentSessionRuntimes"],["sessionRuntimeIdleMs","sessionRuntimeIdleMs"],["maxResidentSessionProjections","maxResidentSessionProjections"],["sessionProjectionIdleMs","sessionProjectionIdleMs"]];function V(q,B){let w;try{w=JSON.parse(q)}catch(H){let K=H instanceof Error?`: ${H.message}`:"";throw Error(`Invalid JSON provided to --settings (${B})${K}`)}if(!w||typeof w!=="object"||Array.isArray(w))throw Error("--settings must contain a JSON object");for(let H of Object.keys(w))if(!kk.has(H))throw Error(`Unknown --settings field: ${H}`);let J=x(qk,w);if(!J.success){let H=J.error.issues.map((K)=>`${K.path.join(".")||"settings"}: ${K.message}`).join("; ");throw Error(`Invalid --settings value: ${H}`)}return J.data}async function n(q){if(q===void 0)return;let B=q.trim();if(!B)throw Error("--settings requires a JSON object or file path");if(B.startsWith("{"))return V(B,"inline JSON");let w=g.resolve(X(),B),J;try{J=await a.readFile(w,"utf8")}catch(H){let K=H instanceof Error?`: ${H.message}`:"";throw Error(`Unable to read --settings file ${w}${K}`)}return V(J,w)}function o(q,B){if(!B)return;let w=B;for(let[J,H]of wk){if(J==="permissionMode"&&q.yolo===!0)continue;if(q[H]===void 0&&w[J]!==void 0)q[H]=w[J]}}var Q=s("General"),Uk=(q)=>{if(q.yolo){if(q.permissionMode&&q.permissionMode!=="yolo")throw Error("Cannot use both --yolo and --permission-mode with different values");q.permissionMode="yolo"}if(Array.isArray(q.allowedTools))q.allowedTools=q.allowedTools.flatMap((B)=>B.split(",").map((w)=>w.trim()).filter((w)=>w.length>0));if(Array.isArray(q.disallowedTools))q.disallowedTools=q.disallowedTools.flatMap((B)=>B.split(",").map((w)=>w.trim()).filter((w)=>w.length>0));if(Array.isArray(q.allowedTools)&&Array.isArray(q.disallowedTools)){let B=q.allowedTools.filter((w)=>q.disallowedTools.includes(w));if(B.length>0)throw Error(`Tools cannot be both allowed and disallowed: ${B.join(", ")}`)}},Lk=async(q)=>{let B=await n(typeof q.settings==="string"?q.settings:void 0);if(o(q,B),typeof q.agents==="string")v(q.agents);zk(q);try{let J=await i.getInstance().initialize(B),H=t(J,q);if(e().config.actions.setConfig(H),q.debug)Q.info("[CLI] 配置已加载到 Store")}catch(w){Q.error("[CLI] [FAIL] 配置初始化失败",w instanceof Error?w.message:w),console.error(`
|
|
2
2
|
[FAIL] 配置初始化失败
|
|
3
3
|
`),console.error("原因:",w instanceof Error?w.message:"未知错误"),console.error(`
|
|
4
4
|
请检查:`),console.error(" 1. 配置文件格式是否正确 (~/.blade/config.json)"),console.error(" 2. 是否需要运行 blade 进行首次配置"),console.error(` 3. 配置文件权限是否正确
|
|
5
5
|
`),process.exit(1)}};function zk(q){if(q.continue&&q.resume)throw Error("Cannot use both --continue and --resume flags simultaneously");if(q.forkSession&&!q.continue&&!q.resume)throw Error("--fork-session requires --resume or --continue");if(q.sessionId&&(q.continue||q.resume)&&!q.forkSession)throw Error("--session-id can only be combined with --resume or --continue when --fork-session is set")}var Mk=(q)=>{if(q.jsonSchema&&q.outputSchema)throw Error("--json-schema cannot be combined with --output-schema");if((q.jsonSchema||q.outputSchema)&&!q.print&&!q.headless)throw Error("--json-schema and --output-schema can only be used with --print or --headless");if(q.outputFormat&&q.outputFormat!=="text"&&!q.print&&!q.headless)throw Error("--output-format can only be used with --print or --headless");if(q.headless&&q.outputFormat&&!["text","jsonl"].includes(q.outputFormat))throw Error(`--headless only supports --output-format text|jsonl, but got "${q.outputFormat}". Use --print for json|stream-json support.`);if(q.print&&q.outputFormat&&!["text","json","stream-json"].includes(q.outputFormat))throw Error(`--print only supports --output-format text|json|stream-json, but got "${q.outputFormat}". Use --headless for jsonl support.`);if(q.inputFormat==="stream-json"&&q.print)Q.warn("[WARN] Warning: stream-json input format may not work as expected with --print")};
|
|
6
|
-
export{Uk as
|
|
6
|
+
export{Uk as cf,Lk as df,Mk as ef};
|