dal-code 1.0.56 → 1.0.58
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/CHANGELOG.md +8 -0
- package/dist/bundle/chunks/{anthropic-messages-HHQLDDZH.js → anthropic-messages-FOIJU7LX.js} +1 -1
- package/dist/bundle/chunks/{azure-openai-responses-S7VKEJTH.js → azure-openai-responses-7NBJZKX5.js} +1 -1
- package/dist/bundle/chunks/bedrock-converse-stream.js +1 -1
- package/dist/bundle/chunks/{chunk-QCT6OHUR.js → chunk-3QG7FIE4.js} +1 -1
- package/dist/bundle/chunks/chunk-4BOWD7PQ.js +1 -0
- package/dist/bundle/chunks/{chunk-UULAEZ3H.js → chunk-4PBY6OYS.js} +1 -1
- package/dist/bundle/chunks/{chunk-BIY5HTFI.js → chunk-5MF5GEDD.js} +1 -1
- package/dist/bundle/chunks/{chunk-3XMZ5UC3.js → chunk-B7KZDIWA.js} +1 -1
- package/dist/bundle/chunks/chunk-C5ELI234.js +17 -0
- package/dist/bundle/chunks/{chunk-RX6CC5RH.js → chunk-CCU76UL3.js} +443 -472
- package/dist/bundle/chunks/{chunk-PH42AQ66.js → chunk-DVEPGKL5.js} +1 -1
- package/dist/bundle/chunks/chunk-G5AMLGXC.js +1 -0
- package/dist/bundle/chunks/chunk-HF334NQU.js +21 -0
- package/dist/bundle/chunks/{chunk-Z64M4Q7A.js → chunk-IONGABQF.js} +1 -1
- package/dist/bundle/chunks/{chunk-F37JXTCY.js → chunk-JK74OC6W.js} +1 -1
- package/dist/bundle/chunks/chunk-JUUJCOIR.js +7 -0
- package/dist/bundle/chunks/chunk-JXAFVEE4.js +17 -0
- package/dist/bundle/chunks/chunk-LMZYTWXD.js +14 -0
- package/dist/bundle/chunks/chunk-NJDCSLWK.js +1 -0
- package/dist/bundle/chunks/{chunk-BCFLC6CK.js → chunk-NYSVXLKF.js} +1 -1
- package/dist/bundle/chunks/{chunk-P4IBZA6D.js → chunk-PMFHJN7I.js} +1 -1
- package/dist/bundle/chunks/chunk-QFBU27TM.js +30 -0
- package/dist/bundle/chunks/{chunk-SZZVJTVX.js → chunk-QU2VEHMW.js} +1 -1
- package/dist/bundle/chunks/chunk-SCZEDPDC.js +9 -0
- package/dist/bundle/chunks/{chunk-VGMP27KM.js → chunk-T5PI6B5P.js} +1 -1
- package/dist/bundle/chunks/{chunk-ZR6PGIL7.js → chunk-X7I3V6OA.js} +1 -1
- package/dist/bundle/chunks/{chunk-3HGUIN22.js → chunk-XQF5XDEM.js} +2 -2
- package/dist/bundle/chunks/{cli-TVPE43YN.js → cli-NQ7B7BGV.js} +1 -1
- package/dist/bundle/chunks/{cli-NGGC23SK.js → cli-RY666QAD.js} +1 -1
- package/dist/bundle/chunks/{cloudflare-workers-ai-system-one-RK2YCJXC.js → cloudflare-workers-ai-system-one-CFGOMWWZ.js} +1 -1
- package/dist/bundle/chunks/{execute-MGTKJB44.js → execute-NJRE4WBO.js} +2 -2
- package/dist/bundle/chunks/{google-generative-ai-ZPA4VBXP.js → google-generative-ai-ZA2RHPNE.js} +1 -1
- package/dist/bundle/chunks/{google-vertex-IWHW2RX7.js → google-vertex-Y2GRWOK7.js} +1 -1
- package/dist/bundle/chunks/{llama-cpp-classify-FXJM52Q3.js → llama-cpp-classify-G2JDOFHY.js} +1 -1
- package/dist/bundle/chunks/{mcp-RLFUDVHN.js → mcp-45D7KCZZ.js} +1 -1
- package/dist/bundle/chunks/{mistral-conversations-JXVPTO5Y.js → mistral-conversations-MLV32BRV.js} +1 -1
- package/dist/bundle/chunks/{office-RTREQQ7W.js → office-UBOUFRAU.js} +1 -1
- package/dist/bundle/chunks/{openai-codex-responses-EYW27UUE.js → openai-codex-responses-BDK3PY6G.js} +1 -1
- package/dist/bundle/chunks/{openai-completions-ROBKXDOC.js → openai-completions-BLXHKAB3.js} +1 -1
- package/dist/bundle/chunks/{openai-decisions-4T5LPJRA.js → openai-decisions-IGVID576.js} +1 -1
- package/dist/bundle/chunks/{openai-responses-ZVFZ75QW.js → openai-responses-KHZOEDF2.js} +1 -1
- package/dist/bundle/chunks/{openrouter-images-6VJYTLAX.js → openrouter-images-SA6PUASF.js} +1 -1
- package/dist/bundle/chunks/{pi-messages-Y6HBOGKH.js → pi-messages-3VAOLQ2Y.js} +1 -1
- package/dist/bundle/chunks/{review-USSKCVWP.js → review-RZXLHPUZ.js} +2 -2
- package/dist/bundle/chunks/{router-4JLK3BTT.js → router-YBVXODIL.js} +1 -1
- package/dist/bundle/chunks/runtime-FNCZJKOC.js +1 -0
- package/dist/bundle/chunks/sdk-X6RX7FNE.js +1 -0
- package/dist/bundle/chunks/{sync-UCHKAOUU.js → sync-CRV6BXXC.js} +3 -3
- package/dist/bundle/chunks/{typesafe-system-one-XPDE7VYD.js → typesafe-system-one-ER3DLYNF.js} +1 -1
- package/dist/bundle/chunks/usage-LMRFS2HV.js +1 -0
- package/dist/bundle/chunks/virtual-modules-XIUNRFOZ.js +1 -0
- package/dist/bundle/cli-runtime.js +1 -1
- package/dist/bundle/index.js +1 -1
- package/dist/bundle/rpc-entry.js +1 -1
- package/dist/node_modules/@dalcode/dal-advisor/package.json +3 -3
- package/dist/node_modules/@dalcode/dal-awake/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-bridge/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-capabilities/package.json +4 -4
- package/dist/node_modules/@dalcode/dal-codeindex/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-compat/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-dap/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-gateway/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-goal/package.json +3 -3
- package/dist/node_modules/@dalcode/dal-guard/package.json +4 -4
- package/dist/node_modules/@dalcode/dal-halo/package.json +1 -1
- package/dist/node_modules/@dalcode/dal-interactive/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-lang/package.json +3 -3
- package/dist/node_modules/@dalcode/dal-learn/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-learn/src/engine.js +3 -3
- package/dist/node_modules/@dalcode/dal-learn/src/index.js +11 -11
- package/dist/node_modules/@dalcode/dal-learn/src/lessons.js +4 -4
- package/dist/node_modules/@dalcode/dal-learn/src/project-map.js +2 -2
- package/dist/node_modules/@dalcode/dal-learn/src/signals.js +6 -6
- package/dist/node_modules/@dalcode/dal-learn/src/store.js +3 -3
- package/dist/node_modules/@dalcode/dal-lsp/package.json +4 -4
- package/dist/node_modules/@dalcode/dal-mcp/package.json +6 -6
- package/dist/node_modules/@dalcode/dal-office/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-pi-kit/dist/agent-dir.js +1 -0
- package/dist/node_modules/@dalcode/dal-pi-kit/dist/i18n.js +1 -1
- package/dist/node_modules/@dalcode/dal-pi-kit/dist/index.js +1 -1
- package/dist/node_modules/@dalcode/dal-pi-kit/package.json +1 -1
- package/dist/node_modules/@dalcode/dal-pi-kit/src/agent-dir.js +1 -0
- package/dist/node_modules/@dalcode/dal-pi-kit/src/i18n.js +1 -1
- package/dist/node_modules/@dalcode/dal-pi-kit/src/index.js +1 -1
- package/dist/node_modules/@dalcode/dal-plugins/package.json +4 -4
- package/dist/node_modules/@dalcode/dal-recall/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-remote/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-review/package.json +3 -3
- package/dist/node_modules/@dalcode/dal-rewind/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-router/package.json +6 -6
- package/dist/node_modules/@dalcode/dal-rtk/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-skills/package.json +3 -3
- package/dist/node_modules/@dalcode/dal-statusline/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-structured/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-subagent/package.json +5 -5
- package/dist/node_modules/@dalcode/dal-sync/package.json +4 -4
- package/dist/node_modules/@dalcode/dal-telemetry/package.json +4 -4
- package/dist/node_modules/@dalcode/dal-terminal/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-tool-catalog/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-usage/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-web/package.json +3 -3
- package/dist/node_modules/@dalcode/dal-workflow/package.json +2 -2
- package/dist/node_modules/@dalcode/deepailab/package.json +3 -3
- package/dist/node_modules/@earendil-works/pi-agent-core/package.json +3 -3
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/.manifest.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/openrouter.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/utils/version.d.ts +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/utils/version.js +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/package.json +3 -3
- package/dist/node_modules/@earendil-works/pi-codemode/package.json +1 -1
- package/dist/node_modules/@earendil-works/pi-coding-agent/package.json +1 -1
- package/dist/node_modules/@earendil-works/pi-mcp/package.json +1 -1
- package/dist/node_modules/@earendil-works/pi-schema/package.json +1 -1
- package/dist/node_modules/@earendil-works/pi-telemetry/package.json +1 -1
- package/dist/node_modules/@earendil-works/pi-tui/package.json +1 -1
- package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/examples/extensions/gondolin/package-lock.json +2 -2
- package/examples/extensions/gondolin/package.json +1 -1
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +1 -1
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
- package/dist/bundle/chunks/chunk-3YGHTGYM.js +0 -7
- package/dist/bundle/chunks/chunk-MKMLENQD.js +0 -17
- package/dist/bundle/chunks/chunk-SE42OS3U.js +0 -21
- package/dist/bundle/chunks/chunk-T3TEURLR.js +0 -30
- package/dist/bundle/chunks/chunk-XTN2LDU3.js +0 -9
- package/dist/bundle/chunks/runtime-G7F6UQLA.js +0 -1
- package/dist/bundle/chunks/sdk-CEIRR6KD.js +0 -1
- package/dist/bundle/chunks/usage-3ACOJWR3.js +0 -1
- package/dist/bundle/chunks/virtual-modules-P4JE2EA6.js +0 -1
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
var it=Object.defineProperty;var o=(e,t)=>it(e,"name",{value:t,configurable:!0});import{createRequire as st}from"node:module";const Vr=st(import.meta.url);import{fill as nt,getShellConfig as ot}from"./chunk-SE42OS3U.js";import{APP_TITLE as at,getAgentDir as U,getFileRevision as N,normalizePath as V,require_cross_spawn as lt,stripBom as te}from"./chunk-R47JBGS3.js";import{require_graceful_fs as fe}from"./chunk-XJFQKN3N.js";import{drainNewerDataFormatFiles as ut,t as ct,writeFileAtomicSync as pe}from"./chunk-SZZVJTVX.js";import{__commonJS as P,__require as re,__toESM as me}from"./chunk-JXWJOIH4.js";var dt=P({"node_modules/proper-lockfile/node_modules/retry/lib/retry_operation.js"(e,t){function r(i,s){typeof s=="boolean"&&(s={forever:s}),this._originalTimeouts=JSON.parse(JSON.stringify(i)),this._timeouts=i,this._options=s||{},this._maxRetryTime=s&&s.maxRetryTime||1/0,this._fn=null,this._errors=[],this._attempts=1,this._operationTimeout=null,this._operationTimeoutCb=null,this._timeout=null,this._operationStart=null,this._options.forever&&(this._cachedTimeouts=this._timeouts.slice(0))}o(r,"RetryOperation"),t.exports=r,r.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts},r.prototype.stop=function(){this._timeout&&clearTimeout(this._timeout),this._timeouts=[],this._cachedTimeouts=null},r.prototype.retry=function(i){if(this._timeout&&clearTimeout(this._timeout),!i)return!1;var s=new Date().getTime();if(i&&s-this._operationStart>=this._maxRetryTime)return this._errors.unshift(new Error("RetryOperation timeout occurred")),!1;this._errors.push(i);var n=this._timeouts.shift();if(n===void 0)if(this._cachedTimeouts)this._errors.splice(this._errors.length-1,this._errors.length),this._timeouts=this._cachedTimeouts.slice(0),n=this._timeouts.shift();else return!1;var a=this,l=setTimeout(function(){a._attempts++,a._operationTimeoutCb&&(a._timeout=setTimeout(function(){a._operationTimeoutCb(a._attempts)},a._operationTimeout),a._options.unref&&a._timeout.unref()),a._fn(a._attempts)},n);return this._options.unref&&l.unref(),!0},r.prototype.attempt=function(i,s){this._fn=i,s&&(s.timeout&&(this._operationTimeout=s.timeout),s.cb&&(this._operationTimeoutCb=s.cb));var n=this;this._operationTimeoutCb&&(this._timeout=setTimeout(function(){n._operationTimeoutCb()},n._operationTimeout)),this._operationStart=new Date().getTime(),this._fn(this._attempts)},r.prototype.try=function(i){console.log("Using RetryOperation.try() is deprecated"),this.attempt(i)},r.prototype.start=function(i){console.log("Using RetryOperation.start() is deprecated"),this.attempt(i)},r.prototype.start=r.prototype.try,r.prototype.errors=function(){return this._errors},r.prototype.attempts=function(){return this._attempts},r.prototype.mainError=function(){if(this._errors.length===0)return null;for(var i={},s=null,n=0,a=0;a<this._errors.length;a++){var l=this._errors[a],u=l.message,h=(i[u]||0)+1;i[u]=h,h>=n&&(s=l,n=h)}return s}}}),ht=P({"node_modules/proper-lockfile/node_modules/retry/lib/retry.js"(e){var t=dt();e.operation=function(r){var i=e.timeouts(r);return new t(i,{forever:r&&r.forever,unref:r&&r.unref,maxRetryTime:r&&r.maxRetryTime})},e.timeouts=function(r){if(r instanceof Array)return[].concat(r);var i={retries:10,factor:2,minTimeout:1*1e3,maxTimeout:1/0,randomize:!1};for(var s in r)i[s]=r[s];if(i.minTimeout>i.maxTimeout)throw new Error("minTimeout is greater than maxTimeout");for(var n=[],a=0;a<i.retries;a++)n.push(this.createTimeout(a,i));return r&&r.forever&&!n.length&&n.push(this.createTimeout(a,i)),n.sort(function(l,u){return l-u}),n},e.createTimeout=function(r,i){var s=i.randomize?Math.random()+1:1,n=Math.round(s*i.minTimeout*Math.pow(i.factor,r));return n=Math.min(n,i.maxTimeout),n},e.wrap=function(r,i,s){if(i instanceof Array&&(s=i,i=null),!s){s=[];for(var n in r)typeof r[n]=="function"&&s.push(n)}for(var a=0;a<s.length;a++){var l=s[a],u=r[l];r[l]=function(h){var f=e.operation(i),g=Array.prototype.slice.call(arguments,1),m=g.pop();g.push(function(w){f.retry(w)||(w&&(arguments[0]=f.mainError()),m.apply(this,arguments))}),f.attempt(function(){h.apply(r,g)})}.bind(r,u),r[l].options=i}}}}),ft=P({"node_modules/proper-lockfile/node_modules/retry/index.js"(e,t){t.exports=ht()}}),pt=P({"node_modules/signal-exit/signals.js"(e,t){t.exports=["SIGABRT","SIGALRM","SIGHUP","SIGINT","SIGTERM"],process.platform!=="win32"&&t.exports.push("SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT"),process.platform==="linux"&&t.exports.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT","SIGUNUSED")}}),mt=P({"node_modules/signal-exit/index.js"(e,t){var r=global.process,i=o(function(y){return y&&typeof y=="object"&&typeof y.removeListener=="function"&&typeof y.emit=="function"&&typeof y.reallyExit=="function"&&typeof y.listeners=="function"&&typeof y.kill=="function"&&typeof y.pid=="number"&&typeof y.on=="function"},"processOk");i(r)?(s=re("assert"),n=pt(),a=/^win/i.test(r.platform),l=re("events"),typeof l!="function"&&(l=l.EventEmitter),r.__signal_exit_emitter__?u=r.__signal_exit_emitter__:(u=r.__signal_exit_emitter__=new l,u.count=0,u.emitted={}),u.infinite||(u.setMaxListeners(1/0),u.infinite=!0),t.exports=function(y,p){if(!i(global.process))return function(){};s.equal(typeof y,"function","a callback must be provided for exit handler"),m===!1&&w();var c="exit";p&&p.alwaysLast&&(c="afterexit");var d=o(function(){u.removeListener(c,y),u.listeners("exit").length===0&&u.listeners("afterexit").length===0&&h()},"remove");return u.on(c,y),d},h=o(function(){!m||!i(global.process)||(m=!1,n.forEach(function(y){try{r.removeListener(y,g[y])}catch{}}),r.emit=b,r.reallyExit=v,u.count-=1)},"unload"),t.exports.unload=h,f=o(function(y,p,c){u.emitted[y]||(u.emitted[y]=!0,u.emit(y,p,c))},"emit"),g={},n.forEach(function(y){g[y]=function(){if(i(global.process)){var p=r.listeners(y);p.length===u.count&&(h(),f("exit",null,y),f("afterexit",null,y),a&&y==="SIGHUP"&&(y="SIGINT"),r.kill(r.pid,y))}}}),t.exports.signals=function(){return n},m=!1,w=o(function(){m||!i(global.process)||(m=!0,u.count+=1,n=n.filter(function(y){try{return r.on(y,g[y]),!0}catch{return!1}}),r.emit=S,r.reallyExit=x)},"load"),t.exports.load=w,v=r.reallyExit,x=o(function(y){i(global.process)&&(r.exitCode=y||0,f("exit",r.exitCode,null),f("afterexit",r.exitCode,null),v.call(r,r.exitCode))},"processReallyExit"),b=r.emit,S=o(function(y,p){if(y==="exit"&&i(global.process)){p!==void 0&&(r.exitCode=p);var c=b.apply(this,arguments);return f("exit",r.exitCode,null),f("afterexit",r.exitCode,null),c}else return b.apply(this,arguments)},"processEmit")):t.exports=function(){return function(){}};var s,n,a,l,u,h,f,g,m,w,v,x,b,S}}),yt=P({"node_modules/proper-lockfile/lib/mtime-precision.js"(e,t){"use strict";var r=Symbol();function i(n,a,l){let u=a[r];if(u)return a.stat(n,(f,g)=>{if(f)return l(f);l(null,g.mtime,u)});let h=new Date(Math.ceil(Date.now()/1e3)*1e3+5);a.utimes(n,h,h,f=>{if(f)return l(f);a.stat(n,(g,m)=>{if(g)return l(g);let w=m.mtime.getTime()%1e3===0?"s":"ms";Object.defineProperty(a,r,{value:w}),l(null,m.mtime,w)})})}o(i,"probe");function s(n){let a=Date.now();return n==="s"&&(a=Math.ceil(a/1e3)*1e3),new Date(a)}o(s,"getMtime"),t.exports.probe=i,t.exports.getMtime=s}}),gt=P({"node_modules/proper-lockfile/lib/lockfile.js"(e,t){"use strict";var r=re("path"),i=fe(),s=ft(),n=mt(),a=yt(),l={};function u(p,c){return c.lockfilePath||`${p}.lock`}o(u,"getLockFile");function h(p,c,d){if(!c.realpath)return d(null,r.resolve(p));c.fs.realpath(p,d)}o(h,"resolveCanonicalPath");function f(p,c,d){let E=u(p,c);c.fs.mkdir(E,C=>{if(!C)return a.probe(E,c.fs,(_,R,M)=>{if(_)return c.fs.rmdir(E,()=>{}),d(_);d(null,R,M)});if(C.code!=="EEXIST")return d(C);if(c.stale<=0)return d(Object.assign(new Error("Lock file is already being held"),{code:"ELOCKED",file:p}));c.fs.stat(E,(_,R)=>{if(_)return _.code==="ENOENT"?f(p,{...c,stale:0},d):d(_);if(!g(R,c))return d(Object.assign(new Error("Lock file is already being held"),{code:"ELOCKED",file:p}));m(p,c,M=>{if(M)return d(M);f(p,{...c,stale:0},d)})})})}o(f,"acquireLock");function g(p,c){return p.mtime.getTime()<Date.now()-c.stale}o(g,"isLockStale");function m(p,c,d){c.fs.rmdir(u(p,c),E=>{if(E&&E.code!=="ENOENT")return d(E);d()})}o(m,"removeLock");function w(p,c){let d=l[p];d.updateTimeout||(d.updateDelay=d.updateDelay||c.update,d.updateTimeout=setTimeout(()=>{d.updateTimeout=null,c.fs.stat(d.lockfilePath,(E,C)=>{let _=d.lastUpdate+c.stale<Date.now();if(E)return E.code==="ENOENT"||_?v(p,d,Object.assign(E,{code:"ECOMPROMISED"})):(d.updateDelay=1e3,w(p,c));if(d.mtime.getTime()!==C.mtime.getTime())return v(p,d,Object.assign(new Error("Unable to update lock within the stale threshold"),{code:"ECOMPROMISED"}));let R=a.getMtime(d.mtimePrecision);c.fs.utimes(d.lockfilePath,R,R,M=>{let Q=d.lastUpdate+c.stale<Date.now();if(!d.released){if(M)return M.code==="ENOENT"||Q?v(p,d,Object.assign(M,{code:"ECOMPROMISED"})):(d.updateDelay=1e3,w(p,c));d.mtime=R,d.lastUpdate=Date.now(),d.updateDelay=null,w(p,c)}})})},d.updateDelay),d.updateTimeout.unref&&d.updateTimeout.unref())}o(w,"updateLock");function v(p,c,d){c.released=!0,c.updateTimeout&&clearTimeout(c.updateTimeout),l[p]===c&&delete l[p],c.options.onCompromised(d)}o(v,"setLockAsCompromised");function x(p,c,d){c={stale:1e4,update:null,realpath:!0,retries:0,fs:i,onCompromised:o(E=>{throw E},"onCompromised"),...c},c.retries=c.retries||0,c.retries=typeof c.retries=="number"?{retries:c.retries}:c.retries,c.stale=Math.max(c.stale||0,2e3),c.update=c.update==null?c.stale/2:c.update||0,c.update=Math.max(Math.min(c.update,c.stale/2),1e3),h(p,c,(E,C)=>{if(E)return d(E);let _=s.operation(c.retries);_.attempt(()=>{f(C,c,(R,M,Q)=>{if(_.retry(R))return;if(R)return d(_.mainError());let rt=l[C]={lockfilePath:u(C,c),mtime:M,mtimePrecision:Q,options:c,lastUpdate:Date.now()};w(C,c),d(null,ee=>{if(rt.released)return ee&&ee(Object.assign(new Error("Lock is already released"),{code:"ERELEASED"}));b(C,{...c,realpath:!1},ee)})})})})}o(x,"lock");function b(p,c,d){c={fs:i,realpath:!0,...c},h(p,c,(E,C)=>{if(E)return d(E);let _=l[C];if(!_)return d(Object.assign(new Error("Lock is not acquired/owned by you"),{code:"ENOTACQUIRED"}));_.updateTimeout&&clearTimeout(_.updateTimeout),_.released=!0,delete l[C],m(C,c,d)})}o(b,"unlock");function S(p,c,d){c={stale:1e4,realpath:!0,fs:i,...c},c.stale=Math.max(c.stale||0,2e3),h(p,c,(E,C)=>{if(E)return d(E);c.fs.stat(u(C,c),(_,R)=>_?_.code==="ENOENT"?d(null,!1):d(_):d(null,!g(R,c)))})}o(S,"check");function y(){return l}o(y,"getLocks"),n(()=>{for(let p in l){let c=l[p].options;try{c.fs.rmdirSync(u(p,c))}catch{}}}),t.exports.lock=x,t.exports.unlock=b,t.exports.check=S,t.exports.getLocks=y}}),vt=P({"node_modules/proper-lockfile/lib/adapter.js"(e,t){"use strict";var r=fe();function i(l){let u=["mkdir","realpath","stat","rmdir","utimes"],h={...l};return u.forEach(f=>{h[f]=(...g)=>{let m=g.pop(),w;try{w=l[`${f}Sync`](...g)}catch(v){return m(v)}m(null,w)}}),h}o(i,"createSyncFs");function s(l){return(...u)=>new Promise((h,f)=>{u.push((g,m)=>{g?f(g):h(m)}),l(...u)})}o(s,"toPromise");function n(l){return(...u)=>{let h,f;if(u.push((g,m)=>{h=g,f=m}),l(...u),h)throw h;return f}}o(n,"toSync");function a(l){if(l={...l},l.fs=i(l.fs||r),typeof l.retries=="number"&&l.retries>0||l.retries&&typeof l.retries.retries=="number"&&l.retries.retries>0)throw Object.assign(new Error("Cannot use retries with the sync api"),{code:"ESYNC"});return l}o(a,"toSyncOptions"),t.exports={toPromise:s,toSync:n,toSyncOptions:a}}}),ye=P({"node_modules/proper-lockfile/index.js"(e,t){"use strict";var r=gt(),{toPromise:i,toSync:s,toSyncOptions:n}=vt();async function a(m,w){let v=await i(r.lock)(m,w);return i(v)}o(a,"lock");function l(m,w){let v=s(r.lock)(m,n(w));return s(v)}o(l,"lockSync");function u(m,w){return i(r.unlock)(m,w)}o(u,"unlock");function h(m,w){return s(r.unlock)(m,n(w))}o(h,"unlockSync");function f(m,w){return i(r.check)(m,w)}o(f,"check");function g(m,w){return s(r.check)(m,n(w))}o(g,"checkSync"),t.exports=a,t.exports.lock=a,t.exports.unlock=u,t.exports.lockSync=l,t.exports.unlockSync=h,t.exports.check=f,t.exports.checkSync=g}}),L={parseError:-32700,invalidRequest:-32600,methodNotFound:-32601,invalidParams:-32602,internalError:-32603},A=class extends Error{static{o(this,"McpError")}code;data;constructor(e,t,r){super(t),this.name="McpError",this.code=e,this.data=r}},I=class extends Error{static{o(this,"McpConnectionClosedError")}constructor(e="MCP connection closed"){super(e),this.name="McpConnectionClosedError"}},wt=class extends Error{static{o(this,"McpTimeoutError")}timeoutMs;constructor(e){super(`MCP request timed out after ${e}ms`),this.name="McpTimeoutError",this.timeoutMs=e}},ie=class extends Error{static{o(this,"McpAbortError")}constructor(e="MCP request aborted"){super(e),this.name="AbortError"}};function T(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}o(T,"isObject");function F(e){return e instanceof Error?e:new Error(String(e))}o(F,"toError");function B(e){return typeof e=="string"||typeof e=="number"&&Number.isFinite(e)}o(B,"isJsonRpcId");function se(e){return T(e)&&e.jsonrpc==="2.0"&&B(e.id)&&typeof e.method=="string"}o(se,"isJsonRpcRequest");function ge(e){return T(e)&&e.jsonrpc==="2.0"&&!("id"in e)&&typeof e.method=="string"}o(ge,"isJsonRpcNotification");function ne(e){return!T(e)||e.jsonrpc!=="2.0"||!B(e.id)?!1:"result"in e?!("error"in e):!("error"in e)||!T(e.error)?!1:typeof e.error.code=="number"&&typeof e.error.message=="string"}o(ne,"isJsonRpcResponse");function G(e){if(se(e)||ge(e)||ne(e))return e;throw new A(L.invalidRequest,"Invalid JSON-RPC message")}o(G,"parseJsonRpcMessage");var oe="2025-11-25",Et=[oe,"2025-06-18","2025-03-26","2024-11-05"],St=3e4,ve=1e3;function _t(e){if(!T(e)||typeof e.protocolVersion!="string"||!T(e.capabilities)||!T(e.serverInfo)||typeof e.serverInfo.name!="string"||typeof e.serverInfo.version!="string"||e.instructions!==void 0&&typeof e.instructions!="string")throw new A(L.invalidRequest,"Invalid MCP initialize result");return e}o(_t,"validateInitializeResult");function j(e){return new A(L.invalidRequest,e)}o(j,"invalid");function xt(e,t,r,i){let s=T(r)?r[t]:void 0;if(!T(r)||!Array.isArray(s))throw j(`Invalid MCP ${e} result`);for(let a of s)if(!T(a)||!i(a))throw j(`Invalid entry in MCP ${e} result`);let n=r.nextCursor===null||r.nextCursor===""?void 0:r.nextCursor;if(n!==void 0&&typeof n!="string")throw j(`Invalid MCP ${e} cursor`);return{items:s,...n===void 0?{}:{nextCursor:n}}}o(xt,"validateListPage");var bt=o(e=>typeof e.name=="string"&&T(e.inputSchema),"isTool"),we=o(e=>typeof e.uri=="string"&&(e.name===void 0||typeof e.name=="string"),"isResource"),Ee=o(e=>typeof e.uriTemplate=="string"&&(e.name===void 0||typeof e.name=="string"),"isResourceTemplate");function Se(e){return{...e,name:e.name??e.uri}}o(Se,"toResource");function _e(e){return{...e,name:e.name??e.uriTemplate}}o(_e,"toResourceTemplate");function xe(e){return e.nextCursor===void 0?{}:{nextCursor:e.nextCursor}}o(xe,"pageCursor");function Tt(e){if(!T(e)||!Array.isArray(e.contents))throw j("Invalid MCP resources/read result");for(let t of e.contents)if(!T(t)||typeof t.uri!="string"||typeof t.text!="string"&&typeof t.blob!="string")throw j("Invalid contents in MCP resources/read result");return e}o(Tt,"validateReadResourceResult");function Ct(e){if(!T(e)||e.content!==void 0&&!Array.isArray(e.content))throw new A(L.invalidRequest,"Invalid MCP tools/call result");return e.content===void 0?{...e,content:[]}:e}o(Ct,"validateCallToolResult");var Rt=class{static{o(this,"McpClient")}options;state="idle";transport;nextRequestId=1;serverInfoValue;serverCapabilitiesValue;instructionsValue;protocolVersionValue;pending=new Map;progressRequests=new Map;incoming=new Map;requestHandlers=new Map;notificationListeners=new Map;errorListeners=new Set;closeListeners=new Set;disposers=[];constructor(e){this.options=Object.freeze({...e}),this.requestHandlers.set("ping",()=>({}));let t=e.roots;t&&this.requestHandlers.set("roots/list",async()=>({roots:[...typeof t=="function"?await t():t]}))}get connectionState(){return this.state}get serverInfo(){return this.serverInfoValue}get serverCapabilities(){return this.serverCapabilitiesValue}get instructions(){return this.instructionsValue}get protocolVersion(){return this.protocolVersionValue}async connect(e){if(this.state!=="idle")throw new Error(`Cannot connect MCP client in ${this.state} state`);this.state="connecting",this.transport=e,this.disposers=[e.onMessage(t=>this.handleMessage(t)),e.onError(t=>this.emitError(t)),e.onClose(()=>this.handleTransportClose())];try{await e.start();let t={...this.options.capabilities};this.options.roots&&t.roots===void 0&&(t.roots={});let r=_t(await this.requestInternal("initialize",{protocolVersion:this.options.protocolVersion??oe,capabilities:t,clientInfo:{name:this.options.name,version:this.options.version,...this.options.title===void 0?{}:{title:this.options.title}}},{},!0));if(!Et.includes(r.protocolVersion))throw new Error(`MCP server selected unsupported protocol version ${r.protocolVersion}`);return this.protocolVersionValue=r.protocolVersion,this.serverInfoValue=r.serverInfo,this.serverCapabilitiesValue=r.capabilities,this.instructionsValue=r.instructions,e.setProtocolVersion?.(r.protocolVersion),await this.notifyInternal("notifications/initialized",void 0,!0),this.state="connected",r}catch(t){throw await this.close().catch(()=>{}),t}}request(e,t,r={}){return this.requestInternal(e,t,r,!1)}notify(e,t){return this.notifyInternal(e,t,!1)}setRequestHandler(e,t){return this.requestHandlers.set(e,t),()=>{this.requestHandlers.get(e)===t&&this.requestHandlers.delete(e)}}onNotification(e,t){let r=this.notificationListeners.get(e)??new Set;return this.notificationListeners.set(e,r),r.add(t),()=>{r.delete(t),r.size===0&&this.notificationListeners.delete(e)}}onError(e){return this.errorListeners.add(e),()=>this.errorListeners.delete(e)}onClose(e){return this.closeListeners.add(e),()=>this.closeListeners.delete(e)}async ping(e={}){await this.request("ping",void 0,e)}async listTools(e={}){return await this.listAll("tools/list","tools",bt,e)}async listResources(e={}){return(await this.listAll("resources/list","resources",we,e)).map(Se)}async listResourcesPage(e,t={}){let r=await this.listPage("resources/list","resources",we,e,t);return{resources:r.items.map(Se),...xe(r)}}async listResourceTemplates(e={}){return(await this.listAll("resources/templates/list","resourceTemplates",Ee,e)).map(_e)}async listResourceTemplatesPage(e,t={}){let r=await this.listPage("resources/templates/list","resourceTemplates",Ee,e,t);return{resourceTemplates:r.items.map(_e),...xe(r)}}async readResource(e,t={}){return Tt(await this.request("resources/read",{uri:e},t))}async listPage(e,t,r,i,s){return xt(e,t,await this.request(e,i===void 0?void 0:{cursor:i},s),r)}async listAll(e,t,r,i){let s=[],n=new Set,a;for(let l=0;l<ve;l++){let u=await this.listPage(e,t,r,a,i);if(s.push(...u.items),u.nextCursor===void 0)return s;if(n.has(u.nextCursor))throw new Error(`MCP ${e} returned duplicate cursor: ${u.nextCursor}`);n.add(u.nextCursor),a=u.nextCursor}throw new Error(`MCP ${e} exceeded ${ve} pages`)}async callTool(e,t,r={}){return Ct(await this.request("tools/call",{name:e,...t===void 0?{}:{arguments:t}},r))}async close(){let e=this.transport;this.transport=void 0,this.disposeTransportListeners(),this.markClosed(new I),await e?.close()}async requestInternal(e,t,r,i){let s=this.requireTransport(i);if(r.signal?.aborted)throw new ie;let n=this.nextRequestId++,a=r.onProgress?n:void 0,l=a===void 0?t:{...t,_meta:{...T(t?._meta)?t._meta:{},progressToken:a}},u={jsonrpc:"2.0",id:n,method:e,...l===void 0?{}:{params:l}};return new Promise((h,f)=>{let g={resolve:h,reject:f,timeoutMs:r.timeoutMs??this.options.requestTimeoutMs??St,timer:void 0,signal:r.signal,onAbort:o(()=>this.cancelPending(n,new ie,e!=="initialize",String(r.signal?.reason??"Aborted")),"onAbort"),sendController:new AbortController,cancellable:e!=="initialize",onProgress:r.onProgress,progressToken:a};this.pending.set(n,g),a!==void 0&&this.progressRequests.set(a,n),r.signal?.addEventListener("abort",g.onAbort,{once:!0}),this.armTimeout(n,g),s.send(u,{signal:g.sendController.signal}).catch(m=>this.cancelPending(n,m,!1))})}async notifyInternal(e,t,r){await this.requireTransport(r).send({jsonrpc:"2.0",method:e,...t===void 0?{}:{params:t}})}requireTransport(e){if(this.transport&&(this.state==="connected"||e&&this.state==="connecting"))return this.transport;throw new I(`MCP client is ${this.state}`)}handleMessage(e){if(ne(e)){this.handleResponse(e);return}if(se(e)){this.handleRequest(e);return}if(ge(e)){this.handleNotification(e.method,e.params);return}this.emitError(new A(L.invalidRequest,"Received invalid JSON-RPC message"))}handleResponse(e){let t=this.pending.get(e.id);if(!t){this.emitError(new Error(`Received response for unknown MCP request ${String(e.id)}`));return}this.removePending(e.id,t),"error"in e?t.reject(new A(e.error.code,e.error.message,e.error.data)):t.resolve(e.result)}async handleRequest(e){let t=this.transport;if(!t)return;let r=this.requestHandlers.get(e.method);if(!r){await t.send({jsonrpc:"2.0",id:e.id,error:{code:L.methodNotFound,message:`Method not found: ${e.method}`}}).catch(s=>this.emitError(s));return}let i=new AbortController;this.incoming.set(e.id,i);try{let s=await r(e.params,{signal:i.signal});await t.send({jsonrpc:"2.0",id:e.id,result:s??{}})}catch(s){let n=s instanceof A?{code:s.code,message:s.message,data:s.data}:{code:L.internalError,message:F(s).message};await t.send({jsonrpc:"2.0",id:e.id,error:n}).catch(a=>this.emitError(a))}finally{this.incoming.delete(e.id)}}handleNotification(e,t){e==="notifications/progress"?this.handleProgress(t):e==="notifications/cancelled"&&this.handleCancelled(t);for(let r of this.notificationListeners.get(e)??[])try{r(t)}catch(i){this.emitError(i)}}handleProgress(e){if(!T(e)||!B(e.progressToken)||typeof e.progress!="number")return;let t=this.progressRequests.get(e.progressToken),r=t===void 0?void 0:this.pending.get(t);if(!(t===void 0||!r)){this.armTimeout(t,r);try{r.onProgress?.(e)}catch(i){this.emitError(i)}}}handleCancelled(e){T(e)&&B(e.requestId)&&this.incoming.get(e.requestId)?.abort(e.reason)}armTimeout(e,t){t.timer&&clearTimeout(t.timer),!(!Number.isFinite(t.timeoutMs)||t.timeoutMs<=0)&&(t.timer=setTimeout(()=>{this.cancelPending(e,new wt(t.timeoutMs),t.cancellable,"Request timed out")},t.timeoutMs))}cancelPending(e,t,r,i){let s=this.pending.get(e);s&&(this.removePending(e,s),s.reject(t),r&&this.transport&&this.transport.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:e,...i?{reason:i}:{}}}).catch(n=>this.emitError(n)))}removePending(e,t){this.pending.delete(e),t.timer&&clearTimeout(t.timer),t.progressToken!==void 0&&this.progressRequests.delete(t.progressToken),t.signal?.removeEventListener("abort",t.onAbort),t.sendController.abort()}rejectPending(e){for(let[t,r]of this.pending)this.removePending(t,r),r.reject(e)}handleTransportClose(){this.markClosed(new I)}markClosed(e){let t=this.state==="closed";this.state="closed",this.rejectPending(e);for(let r of this.incoming.values())r.abort(e);if(this.incoming.clear(),!t)for(let r of[...this.closeListeners])try{r()}catch(i){this.emitError(i)}}emitError(e){let t=F(e);for(let r of this.errorListeners)r(t)}disposeTransportListeners(){for(let e of this.disposers.splice(0))e()}},Mt=me(lt(),1);import{spawn as Pt}from"node:child_process";import O from"node:process";var H=16*1024*1024,be=class{static{o(this,"TransportEvents")}messageListeners=new Set;errorListeners=new Set;closeListeners=new Set;closeEmitted=!1;onMessage(e){return this.messageListeners.add(e),()=>this.messageListeners.delete(e)}onError(e){return this.errorListeners.add(e),()=>this.errorListeners.delete(e)}onClose(e){return this.closeListeners.add(e),()=>this.closeListeners.delete(e)}emitMessage(e){for(let t of this.messageListeners)t(e)}emitError(e){let t=F(e);for(let r of this.errorListeners)r(t)}emitClose(){if(!this.closeEmitted){this.closeEmitted=!0;for(let e of this.closeListeners)e()}}},Lt=64*1024,At=class{static{o(this,"JsonRpcLineReader")}options;stdoutChunks=[];stdoutPendingBytes=0;stderrBuffer=Buffer.alloc(0);constructor(e){this.options=e}get stderr(){return this.stderrBuffer.toString("utf8")}readStdout(e){let t=Buffer.from(e.buffer,e.byteOffset,e.byteLength),r=this.options.maxMessageBytes??H,i=0;for(;;){let s=t.indexOf(10,i);if(s<0){i<t.length&&(this.stdoutChunks.push(Buffer.from(t.subarray(i))),this.stdoutPendingBytes+=t.length-i),this.stdoutPendingBytes>r&&(this.stdoutChunks=[],this.stdoutPendingBytes=0,this.options.onError(new Error(`MCP stdio message exceeds ${r} bytes`)));return}let n=t.subarray(i,s);if(this.stdoutChunks.length>0&&(this.stdoutChunks.push(n),n=Buffer.concat(this.stdoutChunks,this.stdoutPendingBytes+n.length),this.stdoutChunks=[],this.stdoutPendingBytes=0),i=s+1,n.length>r){this.options.onError(new Error(`MCP stdio message exceeds ${r} bytes`));continue}let a=n.toString("utf8").replace(/\r$/,"");if(a.trim())try{this.options.onMessage(G(JSON.parse(a)))}catch(l){this.options.onError(l)}}}readStderr(e){let t=this.options.maxStderrBytes??Lt;this.stderrBuffer=Buffer.concat([this.stderrBuffer,e]),this.stderrBuffer.length>t&&(this.stderrBuffer=this.stderrBuffer.subarray(-t)),this.options.onStderr?.(Buffer.from(e.buffer,e.byteOffset,e.byteLength).toString("utf8"))}end(){Buffer.concat(this.stdoutChunks).toString("utf8").trim()&&this.options.onError(new Error("MCP stdio server closed with an incomplete JSON-RPC message")),this.stdoutChunks=[],this.stdoutPendingBytes=0}},It=2e3,kt=500,z=O.platform!=="win32",ae=new Set,Te=!1;function le(e,t){let r=e.pid;if(O.platform==="win32"&&r!==void 0){if(e.exitCode!==null)return;Pt("taskkill",["/pid",String(r),"/T","/F"],{stdio:"ignore",windowsHide:!0}).on("error",()=>{});return}if(z&&r!==void 0)try{O.kill(-r,t);return}catch{}try{e.kill(t)}catch{}}o(le,"killProcessTree");function Ot(){Te||(Te=!0,O.once("exit",()=>{for(let e of ae)try{O.kill(-e,"SIGTERM")}catch{}}))}o(Ot,"installExitHook");var $t=class extends be{static{o(this,"StdioTransport")}options;child;lines;started=!1;closed=!1;constructor(e){super(),this.options=Object.freeze({...e,args:e.args?[...e.args]:void 0}),this.lines=new At({maxMessageBytes:this.options.maxMessageBytes,maxStderrBytes:this.options.maxStderrBytes,onStderr:this.options.onStderr,onMessage:o(t=>this.emitMessage(t),"onMessage"),onError:o(t=>this.emitError(t),"onError")})}get pid(){return this.child?.pid}get stderr(){return this.lines.stderr}async start(){if(this.started)throw new Error("MCP stdio transport already started");if(this.closed)throw new I;this.started=!0;let e=this.options.inheritEnv===!1?{...this.options.env}:{...O.env,...this.options.env},t=(0,Mt.default)(this.options.command,this.options.args??[],{cwd:this.options.cwd,env:e,stdio:["pipe","pipe",this.options.stderr==="inherit"?"inherit":"pipe"],windowsHide:!0,detached:z});this.child=t;let r=t.pid;z&&r!==void 0&&(Ot(),ae.add(r),t.once("close",()=>ae.delete(r))),t.stdout?.on("data",i=>this.lines.readStdout(i)),t.stdout?.on("error",i=>this.emitError(i)),t.stdin?.on("error",i=>{this.closed||this.emitError(i)}),t.stderr?.on("data",i=>this.lines.readStderr(i)),t.stderr?.on("error",i=>this.emitError(i)),t.on("close",()=>{this.child=void 0,this.lines.end(),this.emitClose()}),await new Promise((i,s)=>{let n=o(()=>{t.off("error",a),i()},"onSpawn"),a=o(l=>{t.off("spawn",n),s(l)},"onError");t.once("spawn",n),t.once("error",a)}),t.on("error",i=>{this.closed||this.emitError(i)})}async send(e){let t=this.child?.stdin;if(!this.started||this.closed||!t?.writable)throw new I;let r=`${JSON.stringify(e)}
|
|
2
|
-
`;await new Promise((i,s)=>{t.write(r,n=>n?s(n):i())})}async close(){if(this.closed)return;this.closed=!0;let e=this.child;if(!e){this.emitClose();return}if(!z&&(e.exitCode!==null||e.signalCode!==null)){e.stdin?.end();return}let t=this.options.closeTimeoutMs??It;await new Promise(r=>{let i=[];e.once("close",()=>{for(let n of i)clearTimeout(n);le(e,"SIGTERM"),r()});let s=Math.min(kt,t);i.push(setTimeout(()=>le(e,"SIGTERM"),s)),i.push(setTimeout(()=>le(e,"SIGKILL"),s+t)),e.stdin?.end()})}},Dt=8*1024,Ce=500,Nt=1e3,jt=3e4,qt=5;async function Ut(e,t){let r=e.getReader(),i=new TextDecoder,s="",n,a,l=[],u=0,h=t.maxEventBytes??H,f=o(()=>{if(l.length===0){n=void 0,a=void 0;return}let v=l.join(`
|
|
3
|
-
`);t.onEvent({...n?{event:n}:{},data:v,...a?{id:a}:{}}),n=void 0,a=void 0,l=[],u=0},"dispatch"),g=o(v=>{if(v===""){f();return}if(v.startsWith(":"))return;let x=v.indexOf(":"),b=x<0?v:v.slice(0,x),S=x<0?"":v.slice(x+1);if(S.startsWith(" ")&&(S=S.slice(1)),b==="data"){if(u+=Buffer.byteLength(S)+(l.length>0?1:0),u>h)throw new Error(`MCP SSE event exceeds ${h} bytes`);l.push(S)}else b==="event"?n=S:b==="id"&&!S.includes("\0")?(a=S,t.onId?.(S)):b==="retry"&&/^\d+$/.test(S)&&t.onRetry?.(Number(S))},"processLine"),m=!1,w=o(()=>{let v=0;for(let x=0;x<s.length;x++){let b=s[x];b!=="\r"&&b!==`
|
|
4
|
-
`||(g(s.slice(v,x)),b==="\r"&&(x+1<s.length?s[x+1]===`
|
|
5
|
-
`&&x++:m=!0),v=x+1)}s=s.slice(v)},"consumeLines");try{for(;;){let{done:x,value:b}=await r.read();if(x)break;let S=i.decode(b,{stream:!0});if(m&&S.length>0&&(S.startsWith(`
|
|
6
|
-
`)&&(S=S.slice(1)),m=!1),s+=S,w(),Buffer.byteLength(s)>h)throw new Error(`MCP SSE event exceeds ${h} bytes`)}let v=i.decode();m&&v.startsWith(`
|
|
7
|
-
`)&&(v=v.slice(1)),s+=v,w(),s&&g(s),f()}catch(v){throw await r.cancel().catch(()=>{}),v}finally{r.releaseLock()}}o(Ut,"consumeSseStream");var k=class extends Error{static{o(this,"McpHttpError")}status;body;constructor(e,t,r=""){super(t),this.name="McpHttpError",this.status=e,this.body=r}},Re=class extends k{static{o(this,"McpAuthRequiredError")}wwwAuthenticate;constructor(e,t=""){super(401,"MCP server requires authentication",t),this.name="McpAuthRequiredError",this.wwwAuthenticate=e.headers.get("www-authenticate")}},Me=class extends k{static{o(this,"McpSessionExpiredError")}constructor(e=""){super(404,"MCP session expired",e),this.name="McpSessionExpiredError"}};function Pe(e){return e.headers.get("content-type")?.split(";",1)[0]?.trim().toLowerCase()}o(Pe,"contentType");function Vt(e){return e.status===401?!0:e.status!==403?!1:/(?:^|[\s,])error="?insufficient_scope"?/i.test(e.headers.get("www-authenticate")??"")}o(Vt,"needsAuthorization");function Ft(e){return e===408||e===429||e>=500}o(Ft,"isTransientStatus");function $(e){return e.body?.cancel().catch(()=>{})??Promise.resolve()}o($,"discard");async function Le(e,t){if(!e.body)return{text:"",truncated:!1};let r=e.body.getReader(),i=new TextDecoder,s="",n=t;try{for(;;){let{done:a,value:l}=await r.read();if(a)return{text:s+i.decode(),truncated:!1};if(l.byteLength>n)return await r.cancel().catch(()=>{}),{text:s+i.decode(l.subarray(0,n),{stream:!0}),truncated:!0};n-=l.byteLength,s+=i.decode(l,{stream:!0})}}finally{r.releaseLock()}}o(Le,"readBodyText");function Bt(e,t){let r=t.trim(),i=r.length>Ce?`${r.slice(0,Ce-3)}...`:r;return`MCP HTTP request failed with status ${e}${i?`: ${i}`:""}`}o(Bt,"describeHttpFailure");var Gt=class extends be{static{o(this,"StreamableHttpTransport")}url;options;fetch;controller=new AbortController;started=!1;closed=!1;sessionIdValue;protocolVersion;getStreamStarted=!1;lastToken;constructor(e){super(),this.options=Object.freeze({...e,headers:e.headers?{...e.headers}:void 0}),this.url=new URL(e.url);let t=e.fetch??globalThis.fetch;this.fetch=(r,i)=>t(r,i)}get sessionId(){return this.sessionIdValue}async start(){if(this.started)throw new Error("MCP Streamable HTTP transport already started");if(this.closed)throw new I;this.started=!0}setProtocolVersion(e){this.protocolVersion=e}async send(e,{signal:t}={}){if(!this.started||this.closed)throw new I;let r=await this.authorizedFetch("POST",{headers:{accept:"application/json, text/event-stream","content-type":"application/json"},body:JSON.stringify(e)},t);if(await this.checkResponse(r),this.captureSession(r),!se(e)){await $(r),"method"in e&&e.method==="notifications/initialized"&&this.startGetStream();return}if(r.status===202||r.status===204)throw new k(r.status,`MCP server accepted request ${e.method} without a response`);let i=Pe(r);if(i==="application/json"){let s=this.options.maxMessageBytes??H,{text:n,truncated:a}=await Le(r,s);if(a)throw new Error(`MCP JSON response exceeds ${s} bytes`);let l=JSON.parse(n);for(let u of Array.isArray(l)?l:[l])this.emitMessage(G(u));return}if(i==="text/event-stream"&&r.body){this.consumeResponseStream(r.body,e.id);return}throw await $(r),new k(r.status,`Unsupported MCP response content type: ${i??"missing"}`)}async close(){if(!this.closed){if(this.closed=!0,this.controller.abort(),this.started&&this.sessionIdValue)try{let e=await this.fetch(this.url,{method:"DELETE",headers:this.buildHeaders({},this.lastToken),signal:AbortSignal.timeout(1e3)});await $(e)}catch{}this.emitClose()}}async authorizedFetch(e,t,r){let i=this.options.authProvider?.onUnauthorized?.bind(this.options.authProvider);for(let s=0;;s++){let{headers:n,token:a}=await this.headers(t.headers);if(r?.aborted)throw new ie;let l=await this.fetch(this.url,{method:e,headers:n,body:t.body,signal:this.controller.signal});if(s>0||!i||!Vt(l))return l;try{await i({response:l,serverUrl:this.url,fetch:this.fetch,token:a})}finally{await $(l)}}}async headers(e={}){let t=await this.options.authProvider?.token();return this.lastToken=t,{headers:this.buildHeaders(e,t),...t?{token:t}:{}}}buildHeaders(e,t){let r=new Headers(this.options.headers);for(let[i,s]of Object.entries(e))r.set(i,s);return this.sessionIdValue&&r.set("Mcp-Session-Id",this.sessionIdValue),this.protocolVersion&&r.set("MCP-Protocol-Version",this.protocolVersion),t&&r.set("Authorization",`Bearer ${t}`),r}captureSession(e){let t=e.headers.get("mcp-session-id");t&&(this.sessionIdValue=t)}async checkResponse(e){if(e.ok)return;let t=(await Le(e,Dt).catch(()=>({text:""}))).text;throw e.status===401?new Re(e,t):e.status===404&&this.sessionIdValue?new Me(t):new k(e.status,Bt(e.status,t),t)}async consumeSse(e,t,r){await Ut(e,{maxEventBytes:this.options.maxMessageBytes??H,onId:o(i=>{t.lastEventId=i},"onId"),onRetry:o(i=>{t.retryMs=i},"onRetry"),onEvent:o(i=>{if(t.received=!0,!i.data.trim()||i.event!==void 0&&i.event!=="message")return;let s;try{s=G(JSON.parse(i.data))}catch(n){this.emitError(n);return}r?.(s),this.emitMessage(s)},"onEvent")})}async consumeResponseStream(e,t){let r={lastEventId:void 0,retryMs:void 0,received:!1},i=!1,s=o(u=>{ne(u)&&u.id===t&&(i=!0)},"onMessage"),n=e,a;for(let u=0;;){if(n)try{await this.consumeSse(n,r,s),a=void 0}catch(h){a=h}if(i||this.closed)return;if(a!==void 0&&!this.isRetryable(a)||r.lastEventId===void 0||u>=this.maxRetries())break;if(r.received&&(u=0),r.received=!1,!await this.sleep(this.reconnectDelay(u++,r.retryMs)))return;try{n=await this.openSseStream(r.lastEventId)}catch(h){if(a=h,!this.isRetryable(h))break;n=void 0}}if(this.closed)return;let l=a===void 0?"stream ended without a response":F(a).message;this.emitMessage({jsonrpc:"2.0",id:t,error:{code:L.internalError,message:`MCP response stream failed: ${l}`}})}startGetStream(){this.options.openGetStream===!1||this.getStreamStarted||this.closed||(this.getStreamStarted=!0,this.runGetStream())}async runGetStream(){let e={lastEventId:void 0,retryMs:void 0,received:!1};for(let t=0;!this.closed;){try{let r=await this.openSseStream(e.lastEventId);if(!r)return;let i=Date.now();await this.consumeSse(r,e),(e.received||Date.now()-i>this.maxDelay())&&(t=0)}catch(r){if(this.closed)return;if(!this.isRetryable(r)){this.emitError(r);return}}if(e.received=!1,t>=this.maxRetries()){this.emitError(new Error("MCP server-to-client stream dropped and could not be reopened"));return}if(!await this.sleep(this.reconnectDelay(t++,e.retryMs)))return}}async openSseStream(e){let t=await this.authorizedFetch("GET",{headers:{accept:"text/event-stream",...e===void 0?{}:{"last-event-id":e}}});if(t.status===405){await $(t);return}await this.checkResponse(t),this.captureSession(t);let r=Pe(t);if(r!=="text/event-stream"||!t.body)throw await $(t),new k(t.status,`Unsupported MCP GET response content type: ${r??"missing"}`);return t.body}isRetryable(e){if(e instanceof k)return Ft(e.status);if(e instanceof TypeError)return!0;let t=e?.code;return typeof t=="string"&&(t.startsWith("E")||t.startsWith("UND_ERR"))}reconnectDelay(e,t){if(t!==void 0)return t;let r=this.options.reconnect?.initialDelayMs??Nt;return Math.min(r*2**e,this.maxDelay())}maxDelay(){return this.options.reconnect?.maxDelayMs??jt}maxRetries(){return this.options.reconnect?.maxRetries??qt}sleep(e){let t=this.controller.signal;return t.aborted?Promise.resolve(!1):new Promise(r=>{let i=o(()=>{clearTimeout(s),r(!1)},"onAbort"),s=setTimeout(()=>{t.removeEventListener("abort",i),r(!0)},e);s.unref?.(),t.addEventListener("abort",i,{once:!0})})}},Ht=/^[A-Za-z0-9_-]+$/;function zt(e,t,r={}){let i=o(u=>({kind:"invalid",error:u}),"invalid2");if(!Ht.test(e))return i(`invalid server name "${e}" (use letters, digits, "_" and "-")`);if(!ue(t))return i(`server "${e}" must be an object`);let s=Jt(t);if(s)return i(`server "${e}": ${s}`);let{type:n,url:a,command:l}=t;if(n==="sse")return i(`server "${e}": legacy SSE transport is not supported; use the streamable HTTP URL`);if(typeof a=="string"&&(n===void 0||n==="http"||n==="streamable-http")){let u=Wt(t,a,r);return u?i(`server "${e}": ${u}`):{kind:"http",config:t}}if(typeof l=="string"&&(n===void 0||n==="stdio")){let u=Xt(t);return u?i(`server "${e}": ${u}`):{kind:"stdio",config:t}}return i(`server "${e}" needs either "command" (stdio) or "url" (streamable HTTP)`)}o(zt,"validateMcpServerConfig");function ue(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}o(ue,"isRecord");function Jt(e){let{enabled:t,timeout:r,description:i}=e;if(t!==void 0&&typeof t!="boolean")return"enabled must be a boolean";if(i!==void 0&&typeof i!="string")return"description must be a string";if(r!==void 0&&(typeof r!="number"||!(r>0)))return"timeout must be a positive number of seconds"}o(Jt,"validateBaseFields");function Wt(e,t,r){return!URL.canParse(t)||!/^https?:$/.test(new URL(t).protocol)?"url must be an http or https URL":e.headers!==void 0&&!Ae(e.headers)?"headers must map names to strings":Yt(e.oauth,r)}o(Wt,"validateHttpFields");function Xt(e){let{args:t,env:r,cwd:i}=e;if(t!==void 0&&!(Array.isArray(t)&&t.every(s=>typeof s=="string")))return"args must be an array of strings";if(r!==void 0&&!Ae(r))return"env must map names to strings";if(i!==void 0&&typeof i!="string")return"cwd must be a string"}o(Xt,"validateStdioFields");function Ae(e){return ue(e)&&Object.values(e).every(t=>typeof t=="string")}o(Ae,"isStringRecord");var Ie=["localhost","127.0.0.1","[::1]"];function Yt(e,t){if(e===void 0)return;if(!ue(e))return"oauth must be an object";if(e.clientId!==void 0&&typeof e.clientId!="string")return"oauth.clientId must be a string";if(e.clientSecret!==void 0&&typeof e.clientSecret!="string")return"oauth.clientSecret must be a string";let r=e.callbackPort;if(r!==void 0&&(typeof r!="number"||!Number.isInteger(r)||r<1||r>65535))return"oauth.callbackPort must be a port number";if(e.callbackUrl!==void 0){if(typeof e.callbackUrl!="string"||!Kt(e.callbackUrl))return"oauth.callbackUrl must be an http URI on localhost, 127.0.0.1, or [::1] without query or fragment";let n=new URL(e.callbackUrl).port;if(n&&r!==void 0&&Number(n)!==r)return"oauth.callbackUrl and oauth.callbackPort name different ports"}if(e.scope!==void 0&&typeof e.scope!="string")return"oauth.scope must be a string";if(e.clientName!==void 0&&(typeof e.clientName!="string"||!e.clientName.trim()))return"oauth.clientName must be a non-empty string";let i=e.clientRegistration;if(i!==void 0&&i!=="auto"&&i!=="dcr"){if(i!=="cimd")return'oauth.clientRegistration must be "auto", "dcr", or "cimd"';if(e.clientId!==void 0||e.clientName!==void 0)return'oauth.clientRegistration "cimd" cannot be combined with oauth.clientId or oauth.clientName';if(!t.checkMetadataDocumentCallback)return'oauth.clientRegistration "cimd" is not supported: there are no Client ID Metadata Documents';let n=t.checkMetadataDocumentCallback(typeof e.callbackUrl=="string"?e.callbackUrl:void 0);if(n)return n}let s=e.authServerMetadataUrl;if(s!==void 0){let n=typeof s=="string"&&URL.canParse(s)?new URL(s):void 0;if(!n||!(n.protocol==="https:"||n.protocol==="http:"&&Ie.includes(n.hostname)))return"oauth.authServerMetadataUrl must be an https URL, or http on localhost, 127.0.0.1, or [::1]"}}o(Yt,"validateOAuth");function Kt(e){if(!URL.canParse(e))return!1;let t=new URL(e);return t.protocol==="http:"&&Ie.includes(t.hostname)&&t.search===""&&t.hash===""}o(Kt,"isLoopbackRedirectUri");function Zt(e){return e.command===void 0&&e.url===void 0&&e.type===void 0}o(Zt,"isMcpServerOverride");function Qt(e){return{...e,type:e.type??"object",...e.properties===void 0?{properties:{}}:{}}}o(Qt,"normalizeMcpInputSchema");import{createHash as er}from"node:crypto";var ke=64;function tr(e,t,r=()=>!1){let i=`mcp__${e}__${t}`.replace(/[^A-Za-z0-9_]/g,"_");if(i.length<=ke&&!r(i))return i;let s=er("sha256").update(`${e}\0${t}`).digest("hex").slice(0,8);return`${i.slice(0,ke-s.length-1)}_${s}`}o(tr,"createMcpToolName");function rr(e){return`mcp__${e.replace(/-/g,"_")}`}o(rr,"mcpNamespace");async function ir(e,t){let r=e.flatMap(a=>a.type==="text"?[a.text]:[]).join(`
|
|
8
|
-
`),i=sr(r,20480);if(!i)return{content:e};let s,n="";if(t)try{s=await t(r,".txt"),n=`
|
|
9
|
-
|
|
10
|
-
[Full output: ${s} (read it with offset/limit)]`}catch(a){n=`
|
|
11
|
-
|
|
12
|
-
[Could not save the full output: ${a instanceof Error?a.message:String(a)}]`}return{content:[{type:"text",text:`Warning: truncated output (original token count: ${Math.ceil(i.totalBytes/4)})
|
|
13
|
-
Total output lines: ${i.totalLines}
|
|
14
|
-
|
|
15
|
-
${i.content}${n}`},...e.filter(a=>a.type==="image")],...s?{fullOutputPath:s}:{}}}o(ir,"limitMcpContent");function sr(e,t){let r=Buffer.from(e,"utf-8");if(r.length<=t)return;let i=o(f=>f>=r.length||(r[f]&192)!==128,"isBoundary"),s=Math.floor(t/2);for(;s>0&&!i(s);)s--;let n=r.length-(t-Math.floor(t/2));for(;n<r.length&&!i(n);)n++;let a=r.subarray(0,s).toString("utf-8"),l=r.subarray(n).toString("utf-8"),u=Array.from(r.subarray(s,n).toString("utf-8")).length,h=e.split(`
|
|
16
|
-
`).length-(e.endsWith(`
|
|
17
|
-
`)?1:0);return{content:`${a}\u2026${u} chars truncated\u2026${l}`,totalBytes:r.length,totalLines:h}}o(sr,"truncateMiddle");function nr(e){switch(e.type){case"text":return{type:"text",text:e.text};case"image":return{type:"image",data:e.data,mimeType:e.mimeType};case"audio":return{type:"text",text:`[audio ${e.mimeType} omitted]`};case"resource_link":return{type:"text",text:`${e.name}: ${e.uri}`};case"resource":{let t=e.resource;return"text"in t?{type:"text",text:t.text}:t.mimeType?.startsWith("image/")?{type:"image",data:t.blob,mimeType:t.mimeType}:{type:"text",text:`[binary resource ${t.uri} (${t.mimeType??"unknown type"}) omitted]`}}default:return{type:"text",text:`[unsupported MCP content ${e.type}]`}}}o(nr,"blockToLlmContent");function or(e){let t=(e.content??[]).map(nr);return t.length===0&&e.structuredContent!==void 0&&t.push({type:"text",text:JSON.stringify(e.structuredContent,null,2)}),t}o(or,"toLlmContent");function Oe(e){let t=e.split("*").map(r=>r.replace(/[.+?^${}()|[\]\\]/g,"\\$&")).join(".*");return new RegExp(`^${t}$`)}o(Oe,"toolPatternRegExp");function ar(e){let t=new Set(e.filter(i=>!i.includes("*"))),r=e.filter(i=>i.includes("*")).map(Oe);return i=>t.has(i)||r.some(s=>s.test(i))}o(ar,"createToolNameMatcher");var $e="list_mcp_resources",De="list_mcp_resource_templates",Ne="read_mcp_resource",lr=new Set([$e,De,Ne]);function ur(e){return e.startsWith("mcp__")||lr.has(e)}o(ur,"isMcpToolName");var je=["codemode","deferred","direct","hidden"],cr={"codemode-deferred":"codemode"};function qe(e){if(e===void 0)return!0;let t=new URL(e);return t.hostname!=="[::1]"&&t.pathname==="/callback"}o(qe,"isClientMetadataDocumentCallback");function J(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}o(J,"isRecord2");function Ue(e){return typeof e=="string"&&je.includes(e)}o(Ue,"isExposure");function Ve(e){return typeof e=="string"?cr[e]??e:e}o(Ve,"resolveExposureAlias");function dr(e){let{exposure:t,toolExposure:r}=e,i={...e};return t!==void 0&&(i.exposure=Ve(t)),J(r)&&(i.toolExposure=Object.fromEntries(Object.entries(r).map(([s,n])=>[s,Ve(n)]))),i}o(dr,"resolveExposureAliases");function hr(e,t){let r=e.toolExposure??{},i=r[t];if(i!==void 0)return i;for(let[s,n]of Object.entries(r))if(s.includes("*")&&Oe(s).test(t))return n;return e.exposure??"codemode"}o(hr,"getMcpToolExposure");function fr(e){let{exposure:t,toolExposure:r}=e,i=je.map(s=>`"${s}"`).join(", ");if(t!==void 0&&!Ue(t))return`exposure must be one of ${i}`;if(r!==void 0){if(!J(r))return"toolExposure must map tool names to exposures";for(let[s,n]of Object.entries(r))if(!Ue(n))return`toolExposure "${s}" must be one of ${i}`}}o(fr,"checkExposures");var pr=["localhost","127.0.0.1","[::1]"];function mr(e,t){if(e===void 0)return;if(!J(e)||typeof e.provider!="string"||!e.provider)return"auth.provider must be a provider name";let r=new URL(t);if(r.protocol!=="https:"&&!pr.includes(r.hostname))return"auth requires an https URL, or http on localhost, 127.0.0.1, or [::1]"}o(mr,"checkAuth");function yr(e,t){let r=zt(e,J(t)?dr(t):t,{checkMetadataDocumentCallback:o(s=>qe(s)?void 0:'oauth.clientRegistration "cimd" requires oauth.callbackUrl on localhost or 127.0.0.1 with path /callback',"checkMetadataDocumentCallback")});if(r.kind==="invalid")return r.error;let i=fr(r.config)??(r.kind==="http"?mr(r.config.auth,r.config.url):void 0);return i?`server "${e}": ${i}`:r.config}o(yr,"validateMcpServerConfig2");var gr=class{static{o(this,"McpServerRegistry")}servers=new Map;changeListener;register(e){this.servers.set(e.name,e),this.changeListener?.()}unregister(e,t){this.servers.get(e)?.extensionPath===t&&(this.servers.delete(e),this.changeListener?.())}get(e){return this.servers.get(e)}list(){return[...this.servers.values()].map(e=>({...e,config:structuredClone(e.config)}))}setChangeListener(e){this.changeListener=e}};import{execSync as vr,spawnSync as wr}from"child_process";var ce=new Map,Er=/^[A-Za-z_][A-Za-z0-9_]*$/,Sr=/^[A-Za-z_][A-Za-z0-9_]*/;function D(e,t){if(!t)return;let r=e[e.length-1];if(r?.type==="literal"){r.value+=t;return}e.push({type:"literal",value:t})}o(D,"appendLiteral");function _r(e){let t=[],r=0;for(;r<e.length;){let i=e.indexOf("$",r);if(i<0){D(t,e.slice(r));break}D(t,e.slice(r,i));let s=e[i+1];if(s==="$"||s==="!"){D(t,s),r=i+2;continue}if(s==="{"){let a=e.indexOf("}",i+2);if(a<0){D(t,"$"),r=i+1;continue}let l=e.slice(i+2,a);Er.test(l)?t.push({type:"env",name:l}):D(t,e.slice(i,a+1)),r=a+1;continue}let n=e.slice(i+1).match(Sr);if(n){t.push({type:"env",name:n[0]}),r=i+1+n[0].length;continue}D(t,"$"),r=i+1}return t}o(_r,"parseConfigValueTemplate");function q(e){return e.startsWith("!")?{type:"command",config:e}:{type:"template",parts:_r(e)}}o(q,"parseConfigValueReference");function Fe(e,t){return t?.[e]||process.env[e]||void 0}o(Fe,"resolveEnvConfigValue");function xr(e){let t=[];for(let r of e)r.type!=="env"||t.includes(r.name)||t.push(r.name);return t}o(xr,"getTemplateEnvVarNames");function Be(e,t){let r="";for(let i of e){if(i.type==="literal"){r+=i.value;continue}let s=Fe(i.name,t);if(s===void 0)return;r+=s}return r}o(Be,"resolveTemplate");function Ge(e){let t=q(e);return t.type==="template"?xr(t.parts):[]}o(Ge,"getConfigValueEnvVarNames");function He(e,t){return Ge(e).filter(r=>Fe(r,t)===void 0)}o(He,"getMissingConfigValueEnvVarNames");function ze(e){return q(e).type==="command"}o(ze,"isCommandConfigValue");function br(e,t){return He(e,t).length===0}o(br,"isConfigValueConfigured");function Je(e,t){let r=q(e);return r.type==="command"?Cr(r.config):Be(r.parts,t)}o(Je,"resolveConfigValue");function Tr(e){try{let{shell:t,args:r,commandTransport:i}=ot(),s=i==="stdin",n=wr(t,s?r:[...r,e],{encoding:"utf-8",input:s?e:void 0,timeout:1e4,stdio:[s?"pipe":"ignore","pipe","ignore"],shell:!1,windowsHide:!0});return n.error?n.error.code==="ENOENT"?{executed:!1,value:void 0}:{executed:!0,value:void 0}:n.status!==0?{executed:!0,value:void 0}:{executed:!0,value:(n.stdout??"").trim()||void 0}}catch{return{executed:!1,value:void 0}}}o(Tr,"executeWithConfiguredShell");function We(e){try{return vr(e,{encoding:"utf-8",timeout:1e4,stdio:["ignore","pipe","ignore"]}).trim()||void 0}catch{return}}o(We,"executeWithDefaultShell");function Xe(e){let t=e.slice(1);return process.platform==="win32"?(()=>{let r=Tr(t);return r.executed?r.value:We(t)})():We(t)}o(Xe,"executeCommandUncached");function Cr(e){if(ce.has(e))return ce.get(e);let t=Xe(e);return ce.set(e,t),t}o(Cr,"executeCommand");function Rr(e,t){let r=q(e);return r.type==="command"?Xe(r.config):Be(r.parts,t)}o(Rr,"resolveConfigValueUncached");function Ye(e,t,r){let i=Rr(e,r);if(i!==void 0)return i;let s=q(e);if(s.type==="command")throw new Error(`Failed to resolve ${t} from shell command: ${s.config.slice(1)}`);if(s.type==="template"){let n=He(e,r);if(n.length===1)throw new Error(`Failed to resolve ${t} from environment variable: ${n[0]}`);if(n.length>1)throw new Error(`Failed to resolve ${t} from environment variables: ${n.join(", ")}`)}throw new Error(`Failed to resolve ${t}`)}o(Ye,"resolveConfigValueOrThrow");function Mr(e,t,r){if(!e)return;let i={};for(let[s,n]of Object.entries(e))i[s]=Ye(n,`${t} header "${s}"`,r);return Object.keys(i).length>0?i:void 0}o(Mr,"resolveHeadersOrThrow");var Ke=me(ye(),1);import{existsSync as W,mkdirSync as Pr,readFileSync as X,writeFileSync as Lr}from"fs";import{dirname as Ar,join as Y}from"path";import{setTimeout as Ze}from"timers/promises";function Qe(e){if(e.reason!==void 0)return e.reason;let t=new Error("The operation was aborted");return t.name="AbortError",t}o(Qe,"abortReason");function Ir(e){return e??new AbortController().signal}o(Ir,"operationSignal");function de(e,t){return t?t.aborted?(e.catch(()=>{}),Promise.reject(Qe(t))):new Promise((r,i)=>{let s=!1,n=o(()=>t.removeEventListener("abort",a),"cleanup"),a=o(()=>{s||(s=!0,n(),i(Qe(t)))},"onAbort");t.addEventListener("abort",a,{once:!0}),e.then(l=>{s||(s=!0,n(),r(l))},l=>{s||(s=!0,n(),i(l))}),t.aborted&&a()}):e}o(de,"raceWithAbortSignal");function kr(){return ut().map(e=>({type:"warning",message:nt(ct("{path} \u7531\u66F4\u65B0\u7248\u672C\u7684 {app} \u5199\u5165\uFF0C\u5F53\u524D\u7248\u672C\u53EA\u8BFB\uFF0C\u4E0D\u4F1A\u6539\u52A8\u5B83\uFF1B\u8BF7\u5347\u7EA7 {app}\u3002"),{path:e,app:at})}))}o(kr,"collectNewerDataFormatDiagnostics");var Or=5;function et(e){let t=e instanceof Error&&"code"in e?e.code:void 0;if(t==="ELOCKED"||t==="EPERM"&&process.platform==="win32")return t}o(et,"getRetryableLockErrorCode");var he={encoding:"utf-8",mode:384},K,tt=class{static{o(this,"FileAuthStorageBackend")}authPath;constructor(e=Y(U(),"auth.json")){this.authPath=V(e)}ensureParentDir(){let e=Ar(this.authPath);W(e)||Pr(e,{recursive:!0,mode:448})}ensureFileExists(){if(!W(this.authPath))try{Lr(this.authPath,"{}",{...he,flag:"wx"})}catch(e){if(e.code!=="EEXIST")throw e}}acquireLockSyncWithRetry(e){for(let t=1;;t++)try{return Ke.default.lockSync(e)}catch(r){if(!et(r)||t===100)throw r;let i=Date.now();for(;Date.now()-i<20;);}}withLock(e){this.ensureParentDir(),this.ensureFileExists();let t;try{t=this.acquireLockSyncWithRetry(this.authPath);let r=W(this.authPath)?X(this.authPath,"utf-8"):void 0,{result:i,next:s}=e(r);return s!==void 0&&pe(this.authPath,s,{mode:he.mode}),i}finally{t&&t()}}async acquireLockAsync(e,t){let r=Date.now()+3e4,i=0,s=0;for(;;){e?.throwIfAborted();let n;try{n=await Ke.default.lock(this.authPath,{retries:0,stale:3e4,onCompromised:t})}catch(a){e?.throwIfAborted();let l=et(a),u=r-Date.now();if(!l||u<=0||l==="EPERM"&&++s>Or)throw a;let h=Math.min(10*2**i,2e3/2);i++;let f=Math.min(Math.round(h*(1+Math.random())),u);e?await Ze(f,void 0,{signal:e}):await Ze(f);continue}return e?.aborted&&(await n(),e.throwIfAborted()),n}}async withLockAsync(e,t){t?.signal?.throwIfAborted(),this.ensureParentDir(),this.ensureFileExists();let r,i=!1,s,n=o(()=>{if(i)throw s??new Error("Auth storage lock was compromised")},"throwIfCompromised");try{r=await this.acquireLockAsync(t?.signal,h=>{i=!0,s=h}),n(),t?.signal?.throwIfAborted();let a=W(this.authPath)?X(this.authPath,"utf-8"):void 0,{result:l,next:u}=await e(a);return n(),t?.signal?.throwIfAborted(),u!==void 0&&pe(this.authPath,u,{mode:he.mode}),n(),l}finally{if(r)try{await r()}catch{}}}},$r=class{static{o(this,"ReadOnlyAuthStorage")}authPath;data;constructor(e=Y(U(),"auth.json")){this.authPath=V(e)}load(){if(this.data)return this.data;let e;try{e=JSON.parse(te(X(this.authPath,"utf-8")))}catch(t){if(t.code==="ENOENT")return this.data={},this.data;throw new Error(`Failed to read auth.json: ${t instanceof Error?t.message:String(t)}`)}if(typeof e!="object"||e===null||Array.isArray(e))throw new Error("Invalid auth.json: expected an object");for(let[t,r]of Object.entries(e)){if(typeof r!="object"||r===null||Array.isArray(r))throw new Error(`Invalid auth.json credential for provider "${t}"`);let i=r;if(i.type==="api_key"){let s=i.key===void 0||typeof i.key=="string",n=i.env===void 0||typeof i.env=="object"&&i.env!==null&&!Array.isArray(i.env)&&Object.values(i.env).every(a=>typeof a=="string");if(s&&n)continue}else if(i.type==="oauth"&&typeof i.access=="string"&&typeof i.refresh=="string"&&typeof i.expires=="number"&&Number.isFinite(i.expires))continue;throw new Error(`Invalid auth.json credential for provider "${t}"`)}return this.data=e,this.data}async read(e,t){t?.signal?.throwIfAborted();let r=this.load()[e];if(t?.signal?.throwIfAborted(),!!r)return r.type!=="api_key"||!r.key||ze(r.key)?structuredClone(r):{...r,key:Je(r.key,r.env)}}async list(e){e?.signal?.throwIfAborted();let t=Object.entries(this.load()).map(([r,i])=>({providerId:r,type:i.type}));return e?.signal?.throwIfAborted(),t}async modify(e,t,r){throw new Error("Read-only credential storage cannot modify auth.json")}async delete(e,t){throw new Error("Read-only credential storage cannot modify auth.json")}},Dr=class{static{o(this,"InMemoryAuthStorageBackend")}value;asyncChain=Promise.resolve();withLock(e){let{result:t,next:r}=e(this.value);return r!==void 0&&(this.value=r),t}withLockAsync(e,t){let r=this.asyncChain,i=(async()=>{await r.catch(()=>{}),t?.signal?.throwIfAborted();let{result:s,next:n}=await e(this.value);return t?.signal?.throwIfAborted(),n!==void 0&&(this.value=n),s})();return this.asyncChain=i.catch(()=>{}),de(i,t?.signal)}},Nr=class Z{static{o(this,"_AuthStorage")}storage;authPath;readState;constructor(t,r){if(this.storage=t,this.authPath=r,this.readState=r&&K?.authPath===r?K.readState:{data:{}},r&&!K&&(K={authPath:r,readState:this.readState}),r){let i=N(r);if(i!==void 0&&i===this.readState.revision)return}this.reload()}static create(t=Y(U(),"auth.json")){let r=V(t);return new Z(new tt(r),r)}static fromStorage(t){return new Z(t)}static inMemory(t={}){let r=new Dr;return r.withLock(()=>({result:void 0,next:JSON.stringify(t,null,2)})),Z.fromStorage(r)}parseStorageData(t){return t?JSON.parse(te(t)):{}}updateReadState(t,r){this.readState.data=t,this.readState.revision=r}reload(){let t,r;try{this.storage.withLock(i=>(t=i,r=this.authPath?N(this.authPath):void 0,{result:void 0})),this.updateReadState(this.parseStorageData(t),r)}catch{}}async reloadFromStorageAsync(t){return this.storage.withLockAsync(async r=>{let i=this.parseStorageData(r),s=this.authPath?N(this.authPath):void 0;return this.updateReadState(i,s),{result:i}},t)}async readLatestData(t){if(t?.signal?.throwIfAborted(),!this.authPath){let s=this.reloadFromStorageAsync(t);return t?.signal?s:s.catch(()=>this.readState.data)}let r=N(this.authPath);if(r!==void 0&&r===this.readState.revision)return this.readState.data;if(!this.readState.reload){let s=new AbortController,n={controller:s,promise:this.reloadFromStorageAsync({signal:s.signal}),readers:0};this.readState.reload=n,n.promise.then(()=>{this.readState.reload===n&&(this.readState.reload=void 0)},()=>{this.readState.reload===n&&(this.readState.reload=void 0)})}let i=this.readState.reload;i.readers++;try{let s=de(i.promise,t?.signal);return t?.signal?await s:await s.catch(()=>this.readState.data)}finally{i.readers--,i.readers===0&&this.readState.reload===i&&(this.readState.reload=void 0,i.controller.abort())}}async read(t,r){let i=(await this.readLatestData(r))[t];return r?.signal?.throwIfAborted(),i?.type!=="api_key"||i.key===void 0?i:{...i,key:Je(i.key,i.env)}}async modify(t,r,i){let s=this.readState.data,n,a=await this.storage.withLockAsync(async l=>{let u=this.parseStorageData(l),h=await r(u[t]);if(h===void 0)return s=u,n=this.authPath?N(this.authPath):void 0,{result:u[t]};let f={...u,[t]:h};return s=f,{result:h,next:JSON.stringify(f,null,2)}},i);return this.updateReadState(s,n),a}async delete(t,r){let i=this.readState.data;await this.storage.withLockAsync(async s=>{let n=this.parseStorageData(s);return delete n[t],i=n,{result:void 0,next:JSON.stringify(n,null,2)}},r),this.updateReadState(i)}async list(t){let r=Object.entries(await this.readLatestData(t));return t?.signal?.throwIfAborted(),r.map(([i,s])=>({providerId:i,type:s.type}))}};function jr(e,t=Y(U(),"auth.json")){try{return JSON.parse(te(X(V(t),"utf-8")))[e]}catch{return}}o(jr,"readStoredCredential");export{Nr as AuthStorage,tt as FileAuthStorageBackend,L as JSON_RPC_ERROR_CODES,oe as LATEST_PROTOCOL_VERSION,$e as LIST_MCP_RESOURCES_TOOL,De as LIST_MCP_RESOURCE_TEMPLATES_TOOL,Re as McpAuthRequiredError,Rt as McpClient,I as McpConnectionClosedError,A as McpError,k as McpHttpError,gr as McpServerRegistry,Me as McpSessionExpiredError,Ne as READ_MCP_RESOURCE_TOOL,$r as ReadOnlyAuthStorage,$t as StdioTransport,Gt as StreamableHttpTransport,kr as collectNewerDataFormatDiagnostics,tr as createMcpToolName,ar as createToolNameMatcher,Ge as getConfigValueEnvVarNames,hr as getMcpToolExposure,qe as isClientMetadataDocumentCallback,ze as isCommandConfigValue,br as isConfigValueConfigured,Zt as isMcpServerOverride,ur as isMcpToolName,T as isObject,ir as limitMcpContent,rr as mcpNamespace,Qt as normalizeMcpInputSchema,Ir as operationSignal,G as parseJsonRpcMessage,de as raceWithAbortSignal,jr as readStoredCredential,ye as require_proper_lockfile,Ye as resolveConfigValueOrThrow,Mr as resolveHeadersOrThrow,or as toLlmContent,yr as validateMcpServerConfig};
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
var J=Object.defineProperty;var l=(e,n)=>J(e,"name",{value:n,configurable:!0});import{createRequire as Q}from"node:module";const Ne=Q(import.meta.url);import{getBinDir as ee}from"./chunk-R47JBGS3.js";function te(e,n){return e.replace(/\{(\w+)\}/g,(t,r)=>r in n?String(n[r]):t)}l(te,"fill");var H=["*KEY*","*SECRET*","*TOKEN*","*PASSWORD*","*CREDENTIAL*","AWS_*","AZURE_*","GOOGLE_APPLICATION_CREDENTIALS","GH_*","GITHUB_TOKEN","NPM_TOKEN"],ne=["PATH","HOME","USER","LOGNAME","SHELL","TMPDIR","TMP","TEMP","LANG","LC_*","TERM","COLORTERM","NO_COLOR","TZ","XDG_*","SYSTEMROOT","WINDIR","COMSPEC","PATHEXT","USERPROFILE","APPDATA","LOCALAPPDATA"];function C(e){let n=e.map(t=>new RegExp(`^${t.replace(/[.+?^${}()|[\]\\]/g,"\\$&").replace(/\*/g,".*")}$`,"i"));return t=>n.some(r=>r.test(t))}l(C,"patternMatcher");var re=C(H),ie=C(ne);function B(e){return/^(DALCODE_|DAL_HOST_)/i.test(e)&&/(TOKEN|SECRET|KEY|PASSWORD|CREDENTIAL)/i.test(e)}l(B,"isDalCodeCredentialName");function se(e){let n={};for(let[t,r]of Object.entries(e))B(t)||(n[t]=r);return n}l(se,"withoutDalCodeCredentials");function k(e,n={}){let t=n.inherit??"all",r=C(n.include??[]),o=C(n.exclude??[]),u={};for(let[s,a]of Object.entries(e))t==="none"||t==="core"&&!ie(s)||B(s)||re(s)&&!r(s)||o(s)||(u[s]=a);for(let[s,a]of Object.entries(n.set??{}))B(s)||(u[s]=a);return u}l(k,"applyShellEnvironmentPolicy");var j={};function le(e){j=e??{}}l(le,"configureShellEnvironment");function oe(){return j}l(oe,"currentShellEnvironmentPolicy");import{accessSync as ae,constants as ue}from"node:fs";import{delimiter as G,join as he,win32 as T}from"node:path";import{spawn as fe,spawnSync as U}from"child_process";function ce(e){let n=T.normalize(e).toLowerCase(),t=process.env.SystemRoot;return t?/^[a-z]:[\\/]/i.test(t)?["System32","Sysnative"].some(r=>n===T.join(t,r,"bash.exe").toLowerCase()):!1:/^[a-z]:\\windows\\(?:system32|sysnative)\\bash\.exe$/.test(n)}l(ce,"isLegacyWslBashPath");function w(e){return ce(e)?{shell:e,args:["-s"],commandTransport:"stdin"}:{shell:e,args:["-c"]}}l(w,"getBashShellConfig");function P(e){try{return ae(e,ue.F_OK),!0}catch{return!1}}l(P,"shellPathExists");function O(e){if(process.platform==="win32"){try{let n=U("where",[e],{encoding:"utf-8",timeout:5e3,windowsHide:!0});if(n.status===0&&n.stdout){let t=n.stdout.trim().split(/\r?\n/)[0];if(t&&P(t))return t}}catch{}return null}try{let n=U("which",[e],{encoding:"utf-8",timeout:5e3});if(n.status===0&&n.stdout){let t=n.stdout.trim().split(/\r?\n/)[0];if(t)return t}}catch{}return null}l(O,"findExecutableOnPath");function de(e){if(e){if(P(e))return w(e);throw new Error(`Custom shell path not found: ${e}`)}if(process.platform==="win32"){let t=[],r=process.env.ProgramFiles;r&&t.push(`${r}\\Git\\bin\\bash.exe`);let o=process.env["ProgramFiles(x86)"];o&&t.push(`${o}\\Git\\bin\\bash.exe`);for(let s of t)if(P(s))return w(s);let u=O("bash.exe");if(u)return w(u);throw new Error(`No bash shell found. Options:
|
|
2
|
-
1. Install Git for Windows: https://git-scm.com/download/win
|
|
3
|
-
2. Add your bash to PATH (Cygwin, MSYS2, etc.)
|
|
4
|
-
3. Set shellPath in settings.json
|
|
5
|
-
|
|
6
|
-
Searched Git Bash in:
|
|
7
|
-
${t.map(s=>` ${s}`).join(`
|
|
8
|
-
`)}`)}if(P("/bin/bash"))return w("/bin/bash");let n=O("bash");return n?w(n):{shell:"sh",args:["-c"]}}l(de,"getShellConfig");var pe=["-NoProfile","-NonInteractive","-ExecutionPolicy","Bypass","-Command"];function ge(){if(process.platform!=="win32")throw new Error("The powershell tool is only available on Windows.");let e=O("pwsh.exe"),n=process.env.ProgramFiles;if(!e&&n){let r=T.join(n,"PowerShell","7","pwsh.exe");P(r)&&(e=r)}e??=O("powershell.exe");let t=process.env.SystemRoot;if(!e&&t){let r=T.join(t,"System32","WindowsPowerShell","v1.0","powershell.exe");P(r)&&(e=r)}if(!e)throw new Error("No PowerShell executable found. Install PowerShell or add powershell.exe/pwsh.exe to PATH.");return{shell:e,args:[...pe]}}l(ge,"getPowerShellConfig");function Le(){let e=k(process.env,oe()),n=ee(),t=Object.keys(e).find(u=>u.toLowerCase()==="path")??"PATH",r=e[t]??"",o=r.split(G).filter(Boolean).includes(n)?r:[n,r].filter(Boolean).join(G);return{...e,[t]:o}}l(Le,"getShellEnv");function me(e){return e.replace(/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F\u200B-\u200F\uFEFF\uFFF9-\uFFFB]/g,"")}l(me,"sanitizeBinaryOutput");var R=new Set;function Ee(e){R.add(e)}l(Ee,"trackDetachedChildPid");function Se(e){R.delete(e)}l(Se,"untrackDetachedChildPid");function Pe(){for(let e of R)W(e);R.clear()}l(Pe,"killTrackedDetachedChildren");function W(e){if(process.platform==="win32")try{fe(he(process.env.SystemRoot||"C:\\Windows","System32","taskkill.exe"),["/F","/T","/PID",String(e)],{stdio:"ignore",detached:!0,windowsHide:!0}).once("error",()=>{})}catch{}else{if(process.platform==="darwin")try{process.kill(-e,"SIGSTOP")}catch{}try{process.kill(-e,"SIGKILL")}catch{try{process.kill(e,"SIGKILL")}catch{}}}}l(W,"killProcessTree");var v=/\b(?:error|errors|fail|failed|failure|failing|fatal|panic|exception|traceback|assert(?:ion)?|denied|segfault)\b|✗|✘|×/i,K=[/^\s*[✓✔√]\s+\S/,/^\s*PASS\s+\S/,/^\s*ok \d+ - /,/\sPASSED(?:\s+\[\s*\d+%\])?\s*$/,/^\s*--- PASS: /,/^=== (?:RUN|PAUSE|CONT|NAME)\s/,/^test \S.* \.\.\. ok$/],we=/\bwarn(?:ing)?s?\b/i;function ye(e){let n=e.split(`
|
|
9
|
-
`).map(i=>{let h=i.lastIndexOf("\r",i.length-2);return h===-1?i:i.slice(h+1)}),t=n.filter(i=>K.some(h=>h.test(i))).length>=10,r=[],o=new Set,u=0,s=-1,a=0,d=0,c=0;for(let i of n){let h=v.test(i);if(t&&!h&&K.some(m=>m.test(i))){u++,s===-1&&(s=r.length,r.push(""));continue}let S=r.length>0?r[r.length-1]:void 0;if(!h&&i.trim()!==""&&i===S){c++,d++;continue}if(c>0&&(r.push(`[previous line repeated ${c} more times]`),c=0),!h&&we.test(i)){let m=i.trim();if(o.has(m)){a++;continue}o.add(m)}r.push(i)}c>0&&r.push(`[previous line repeated ${c} more times]`),s!==-1&&(r[s]=`[${u} passing test lines collapsed]`);let L=u+a+d,p=r.join(`
|
|
10
|
-
`);if(L<8||p.length>e.length*(1-.15))return;let f=[];return u>0&&f.push(`${u} passing test lines collapsed`),a>0&&f.push(`${a} duplicate warning lines removed`),d>0&&f.push(`${d} repeated lines collapsed`),{text:p,summary:f.join(", ")}}l(ye,"condenseShellOutput");function Ae(e=process.env){let n=e.DAL_TOOL_OUTPUT_CONDENSE?.trim().toLowerCase();return n==="0"||n==="off"||n==="false"}l(Ae,"outputCondenseDisabled");var D=2e3,N=50*1024,X=500;function I(e){if(e.length===0)return[];let n=e.split(`
|
|
11
|
-
`);return e.endsWith(`
|
|
12
|
-
`)&&n.pop(),n}l(I,"splitLinesForCounting");function Ce(e){return e<1024?`${e}B`:e<1024*1024?`${(e/1024).toFixed(1)}KB`:`${(e/(1024*1024)).toFixed(1)}MB`}l(Ce,"formatSize");function Be(e,n={}){let t=n.maxLines??D,r=n.maxBytes??N,o=Buffer.byteLength(e,"utf-8"),u=I(e),s=u.length;if(s<=t&&o<=r)return{content:e,truncated:!1,truncatedBy:null,totalLines:s,totalBytes:o,outputLines:s,outputBytes:o,lastLinePartial:!1,firstLineExceedsLimit:!1,maxLines:t,maxBytes:r};if(Buffer.byteLength(u[0],"utf-8")>r)return{content:"",truncated:!0,truncatedBy:"bytes",totalLines:s,totalBytes:o,outputLines:0,outputBytes:0,lastLinePartial:!1,firstLineExceedsLimit:!0,maxLines:t,maxBytes:r};let a=[],d=0,c="lines";for(let f=0;f<u.length&&f<t;f++){let i=u[f],h=Buffer.byteLength(i,"utf-8")+(f>0?1:0);if(d+h>r){c="bytes";break}a.push(i),d+=h}a.length>=t&&d<=r&&(c="lines");let L=a.join(`
|
|
13
|
-
`),p=Buffer.byteLength(L,"utf-8");return{content:L,truncated:!0,truncatedBy:c,totalLines:s,totalBytes:o,outputLines:a.length,outputBytes:p,lastLinePartial:!1,firstLineExceedsLimit:!1,maxLines:t,maxBytes:r}}l(Be,"truncateHead");function Te(e,n={}){let t=n.maxLines??D,r=n.maxBytes??N,o=Buffer.byteLength(e,"utf-8"),u=I(e),s=u.length;if(s<=t&&o<=r)return{content:e,truncated:!1,truncatedBy:null,totalLines:s,totalBytes:o,outputLines:s,outputBytes:o,lastLinePartial:!1,firstLineExceedsLimit:!1,maxLines:t,maxBytes:r};let a=[],d=0,c="lines",L=!1;for(let i=u.length-1;i>=0&&a.length<t;i--){let h=u[i],S=Buffer.byteLength(h,"utf-8")+(a.length>0?1:0);if(d+S>r){if(c="bytes",a.length===0){let m=Oe(h,r);a.unshift(m),d=Buffer.byteLength(m,"utf-8"),L=!0}break}a.unshift(h),d+=S}a.length>=t&&d<=r&&(c="lines");let p=a.join(`
|
|
14
|
-
`),f=Buffer.byteLength(p,"utf-8");return{content:p,truncated:!0,truncatedBy:c,totalLines:s,totalBytes:o,outputLines:a.length,outputBytes:f,lastLinePartial:L,firstLineExceedsLimit:!1,maxLines:t,maxBytes:r}}l(Te,"truncateTail");function Oe(e,n){let t=Buffer.from(e,"utf-8");if(t.length<=n)return e;let r=t.length-n;for(;r<t.length&&(t[r]&192)===128;)r++;return t.slice(r).toString("utf-8")}l(Oe,"truncateStringToBytesFromEnd");function Re(e,n=X){return e.length<=n?{text:e,wasTruncated:!1}:{text:`${z(e,n)}... [truncated]`,wasTruncated:!0}}l(Re,"truncateLine");function z(e,n){let t=Math.max(0,n);return Y(e.charCodeAt(t-1))&&x(e.charCodeAt(t))?e.slice(0,t-1):e.slice(0,t)}l(z,"sliceHead");function xe(e,n){if(n<=0)return"";let t=Math.max(0,e.length-n);return x(e.charCodeAt(t))&&Y(e.charCodeAt(t-1))?e.slice(t+1):e.slice(t)}l(xe,"sliceTail");function Y(e){return e>=55296&&e<=56319}l(Y,"isHighSurrogate");function x(e){return e>=56320&&e<=57343}l(x,"isLowSurrogate");var q=16e3,_e=.3,be=.1,V=240;function $e(e,n=q){let t=I(e),r=t.length;if(e.length<=n)return{content:e,truncated:!1,totalLines:r,totalChars:e.length,headLines:r,tailLines:0,omittedLines:0,rescuedLines:0};let o=Math.floor(n*_e),u=[],s=0,a=0;for(;a<t.length&&s+t[a].length+1<=o;)u.push(t[a]),s+=t[a].length+1,a++;let d=!1;a===0&&t.length>0&&(u.push(`${F(t[0],0,o)}\u2026`),s=o+1,d=!0);let c=Math.floor(n*be),L=n-s,p=[],f=0,i=t.length,h=d?1:a,S=L-c;for(;i>h&&f+t[i-1].length+1<=S;)i--,p.unshift(t[i]),f+=t[i].length+1;let m=!1;if(p.length===0&&i>h){let g=t[i-1];p.push(`\u2026${F(g,Math.max(0,g.length-S),g.length)}`),f=S,i--,m=!0}let E=[],_=0,y=0;for(let g=h;g<i;g++){let A=t[g];if(!v.test(A))continue;y++;let $=A.length>V?`${F(A,0,V)}\u2026`:A;_+$.length+1>c||(E.push({index:g,text:$}),_+=$.length+1)}if(!m){let g=L-_;for(;i>h&&f+t[i-1].length+1<=g;)i--,p.unshift(t[i]),f+=t[i].length+1,v.test(t[i])&&y--,E.length>0&&E[E.length-1].index===i&&E.pop()}let b=Math.max(0,i-h),M=Math.max(0,e.length-s-f),Z=E.length>0?`[... ${b} lines (${M} chars) omitted; ${E.length===y?"the":`${E.length} of the ${y}`} error-like lines among them:]
|
|
15
|
-
${E.map(g=>g.text).join(`
|
|
16
|
-
`)}
|
|
17
|
-
[... end of omitted part ...]`:`[... ${b} lines (${M} chars) omitted ...]`;return{content:`${u.join(`
|
|
18
|
-
`)}
|
|
19
|
-
${Z}
|
|
20
|
-
${p.join(`
|
|
21
|
-
`)}`,truncated:!0,totalLines:r,totalChars:e.length,headLines:u.length,tailLines:p.length,omittedLines:b,rescuedLines:E.length}}l($e,"truncateHeadTail");function F(e,n,t){let r=n,o=t;return r>0&&r<e.length&&x(e.charCodeAt(r))&&r++,o>0&&o<e.length&&x(e.charCodeAt(o))&&o--,e.slice(r,o)}l(F,"sliceChars");export{N as DEFAULT_MAX_BYTES,D as DEFAULT_MAX_LINES,H as DEFAULT_SHELL_ENV_EXCLUDES,X as GREP_MAX_LINE_LENGTH,q as SHELL_OUTPUT_MAX_CHARS,k as applyShellEnvironmentPolicy,ye as condenseShellOutput,le as configureShellEnvironment,te as fill,Ce as formatSize,ge as getPowerShellConfig,de as getShellConfig,Le as getShellEnv,B as isDalCodeCredentialName,W as killProcessTree,Pe as killTrackedDetachedChildren,Ae as outputCondenseDisabled,me as sanitizeBinaryOutput,z as sliceHead,xe as sliceTail,Ee as trackDetachedChildPid,Be as truncateHead,$e as truncateHeadTail,Re as truncateLine,Te as truncateTail,Se as untrackDetachedChildPid,se as withoutDalCodeCredentials};
|