@likec4/mcp 1.54.0 → 1.55.0
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/README.md +5 -4
- package/dist/_chunks/libs/@hono/mcp.mjs +1 -1
- package/dist/_chunks/libs/@modelcontextprotocol/sdk.mjs +7 -7
- package/dist/_chunks/libs/nano-spawn.mjs +2 -2
- package/dist/_chunks/libs/p-timeout.mjs +1 -0
- package/dist/_chunks/libs/pathe.mjs +1 -1
- package/dist/_chunks/libs/tinyrainbow.mjs +1 -1
- package/dist/_chunks/src.mjs +1228 -0
- package/dist/cli.mjs +2 -0
- package/dist/index.mjs +1 -1250
- package/package.json +28 -30
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import e
|
|
2
|
-
`?e.slice(0,e.at(-2)===`\r`?-2:-1):e,P=async(e,
|
|
1
|
+
import{stripVTControlCharacters as e}from"node:util";import t from"node:path";import n from"node:process";import{fileURLToPath as r}from"node:url";import{spawn as i}from"node:child_process";import{on as a,once as o}from"node:events";import s from"node:fs/promises";import{pipeline as c}from"node:stream/promises";import*as l from"node:readline/promises";const u=t=>({start:n.hrtime.bigint(),command:t.map(t=>d(e(t))).join(` `),state:{stdout:``,stderr:``,output:``,isIterating:{},nonIterable:[!1,!1]}}),d=e=>/[^\w./-]/.test(e)?`'${e.replaceAll(`'`,`'\\''`)}'`:e,f=({stdin:e,stdout:i,stderr:a,stdio:o=[e,i,a],env:s,preferLocal:c,cwd:l=`.`,...u})=>{let d=l instanceof URL?r(l):t.resolve(l),f=s?{...n.env,...s}:void 0,m=o[0]?.string;return{...u,input:m,stdio:m===void 0?o:[`pipe`,...o.slice(1)],env:c?p(f??n.env,d):f,cwd:d}},p=({Path:e=``,PATH:n=e,...r},i)=>{let a=n.split(t.delimiter),o=m([],t.resolve(i)).map(e=>t.join(e,`node_modules/.bin`)).filter(e=>!a.includes(e));return{...r,PATH:[...o,n].filter(Boolean).join(t.delimiter)}},m=(e,n)=>e.at(-1)===n?e:m([...e,n],t.resolve(n,`..`)),h=async(e,t,n)=>await g(e,n)?[w(e),t.map(e=>C(e)),{...n,shell:!0}]:[e,t,n],g=async(e,{shell:t,cwd:r,env:i=n.env})=>n.platform===`win32`&&!t&&!await _(e,r,i),_=(e,t,{Path:n=``,PATH:r=n})=>S.some(t=>e.toLowerCase().endsWith(t))||x(e,t,r),v={},y=e=>(...t)=>v[t.join(`\0`)]??=e(...t),b=y(s.access),x=y(async(e,n,r)=>{let i=r.split(t.delimiter).filter(Boolean).map(e=>e.replace(/^"(.*)"$/,`$1`));try{await Promise.any([n,...i].flatMap(n=>S.map(r=>b(`${t.resolve(n,e)}${r}`))))}catch{return!1}return!0}),S=[`.exe`,`.com`],C=e=>w(w(`"${e.replaceAll(/(\\*)"/g,`$1$1\\"`).replace(/(\\*)$/,`$1$1`)}"`)),w=e=>e.replaceAll(/([()\][%!^"`<>&|;, *?])/g,`^$1`),T=async(e,{input:t},n)=>{let r=await e;t!==void 0&&r.stdin.end(t);let i=o(r,`close`);try{return await Promise.race([i,...r.stdio.filter(Boolean).map(e=>E(e))]),D(n,j(r)),M(n)}catch(e){throw await Promise.allSettled([i]),O(e,r,n)}},E=async e=>{for await(let[t]of a(e,`error`))if(![`ERR_STREAM_PREMATURE_CLOSE`,`EPIPE`].includes(t?.code))throw t},D=({command:e},{exitCode:t,signalName:n})=>{if(n!==void 0)throw new A(`Command was terminated with ${n}: ${e}`);if(t!==void 0)throw new A(`Command failed with exit code ${t}: ${e}`)},O=(e,t,n)=>Object.assign(k(e,n),j(t),M(n)),k=(e,{command:t})=>e instanceof A?e:new A(`Command failed: ${t}`,{cause:e});var A=class extends Error{name=`SubprocessError`};const j=({exitCode:e,signalCode:t})=>({...e<1?{}:{exitCode:e},...t===null?{}:{signalName:t}}),M=({state:{stdout:e,stderr:t,output:r},command:i,start:a})=>({stdout:N(e),stderr:N(t),output:N(r),command:i,durationMs:Number(n.hrtime.bigint()-a)/1e6}),N=e=>e.at(-1)===`
|
|
2
|
+
`?e.slice(0,e.at(-2)===`\r`?-2:-1):e,P=async(e,t,r,a)=>{try{[`node`,`node.exe`].includes(e.toLowerCase())&&(e=n.execPath,t=[...n.execArgv.filter(e=>!e.startsWith(`--inspect`)),...t]),[e,t,r]=await h(e,t,r),[e,t,r]=F(e,t,r);let s=i(e,t,r);return I(s.stdout,a,`stdout`),I(s.stderr,a,`stderr`),s.once(`error`,()=>{}),await o(s,`spawn`),s}catch(e){throw O(e,{},a)}},F=(e,t,n)=>n.shell&&t.length>0?[[e,...t].join(` `),[],n]:[e,t,n],I=(e,{state:t},n)=>{e&&(e.setEncoding(`utf8`),t.isIterating[n]||(t.isIterating[n]=!1,e.on(`data`,e=>{t[n]+=e,t.output+=e})))},L=async e=>{let[[t,n]]=await Promise.all([Promise.allSettled(e),R(e)]);if(n.reason)throw n.reason.pipedFrom=t.reason??t.value,n.reason;if(t.reason)throw t.reason;return{...n.value,pipedFrom:t.value}},R=async e=>{try{let[{stdout:t},{stdin:n}]=await Promise.all(e.map(({nodeChildProcess:e})=>e));if(n===null)throw Error(`The "stdin" option must be set on the first "spawn()" call in the pipeline.`);if(t===null)throw Error(`The "stdout" option must be set on the last "spawn()" call in the pipeline.`);c(t,n).catch(()=>{})}catch(t){throw await Promise.allSettled(e.map(({nodeChildProcess:e})=>z(e))),t}},z=async e=>{let{stdin:t}=await e;t.end()},B=async function*(e,{state:t},n,r){if(t.isIterating[n]===!1)throw Error(`The subprocess must be iterated right away, for example:
|
|
3
3
|
for await (const line of spawn(...)) { ... }`);t.isIterating[n]=!0;try{let{[n]:i}=await e.nodeChildProcess;if(!i){t.nonIterable[r]=!0;let e=t.nonIterable.every(Boolean)?"either the option `stdout` or `stderr`":`the option \`${n}\``;throw TypeError(`The subprocess cannot be iterated unless ${e} is 'pipe'.`)}V(e),yield*l.createInterface({input:i})}finally{await e}},V=async e=>{try{await e}catch{}},H=async function*({state:e},...t){try{let n=[];for(;t.length>0;){n=t.map((t,r)=>n[r]??U(t,r,e));let[{value:r,done:i},a]=await Promise.race(n.map((e,t)=>Promise.all([e,t]))),[o]=t.splice(a,1);n.splice(a,1),i||(t.push(o),yield r)}}finally{await Promise.all(t.map(e=>e.return()))}},U=async(e,t,{nonIterable:n})=>{try{return await e.next()}catch(r){return W(n,t)?e.return():e.throw(r)}},W=(e,t)=>e.every(Boolean)?t!==e.length-1:e[t];function G(e,t,n,r){let[i=[],a={}]=Array.isArray(t)?[t,n]:[[],t],o=u([e,...i]),s=f(a),c=P(e,i,s,o),l=T(c,s,o);Object.assign(l,{nodeChildProcess:c}),l=r?L([r,l]):l;let d=B(l,o,`stdout`,0),p=B(l,o,`stderr`,1);return Object.assign(l,{nodeChildProcess:c,stdout:d,stderr:p,[Symbol.asyncIterator]:()=>H(o,d,p),pipe:(e,t,n)=>G(e,t,n,l)})}export{A as n,G as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=class e extends Error{name=`TimeoutError`;constructor(t,n){super(t,n),Error.captureStackTrace?.(this,e)}};const t=e=>e.reason??new DOMException(`This operation was aborted.`,`AbortError`);function n(n,r){let{milliseconds:i,fallback:a,message:o,customTimers:s={setTimeout,clearTimeout},signal:c}=r,l,u,d=new Promise((r,d)=>{if(typeof i!=`number`||Math.sign(i)!==1)throw TypeError(`Expected \`milliseconds\` to be a positive number, got \`${i}\``);if(c?.aborted){d(t(c));return}if(c&&(u=()=>{d(t(c))},c.addEventListener(`abort`,u,{once:!0})),n.then(r,d),i===1/0)return;let f=new e;l=s.setTimeout.call(void 0,()=>{if(a){try{r(a())}catch(e){d(e)}return}typeof n.cancel==`function`&&n.cancel(),o===!1?r():o instanceof Error?d(o):(f.message=o??`Promise timed out after ${i} milliseconds`,d(f))},i)}).finally(()=>{d.clear(),u&&c&&c.removeEventListener(`abort`,u)});return d.clear=()=>{s.clearTimeout.call(void 0,l),l=void 0},d}export{n as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=/^[
|
|
1
|
+
const e=/^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/,t=function(t){return e.test(t)};globalThis.process?.platform;export{t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var e={reset:[0,0],bold:[1,22,`\x1B[22m\x1B[1m`],dim:[2,22,`\x1B[22m\x1B[2m`],italic:[3,23],underline:[4,24],inverse:[7,27],hidden:[8,28],strikethrough:[9,29],black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],gray:[90,39],bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],blackBright:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39],bgBlackBright:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]};function t(e){return String(e)}t.open=``,t.close=``;function n(){let e=typeof process<`u`?process:void 0,t=e?.env||{},n=t.FORCE_TTY!==`false`,r=e?.argv||[];return!(`NO_COLOR`in t||r.includes(`--no-color`))&&(`FORCE_COLOR`in t||r.includes(`--color`)||e?.platform===`win32`||n&&t.TERM!==`dumb`||`CI`in t)||typeof window<`u`&&!!window.chrome}function r(){let r
|
|
1
|
+
var e={reset:[0,0],bold:[1,22,`\x1B[22m\x1B[1m`],dim:[2,22,`\x1B[22m\x1B[2m`],italic:[3,23],underline:[4,24],inverse:[7,27],hidden:[8,28],strikethrough:[9,29],black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],gray:[90,39],bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],blackBright:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39],bgBlackBright:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]};function t(e){return String(e)}t.open=``,t.close=``;function n(){let e=typeof process<`u`?process:void 0,t=e?.env||{},n=t.FORCE_TTY!==`false`,r=e?.argv||[];return!(`NO_COLOR`in t||r.includes(`--no-color`))&&(`FORCE_COLOR`in t||r.includes(`--color`)||e?.platform===`win32`||n&&t.TERM!==`dumb`||`CI`in t)||typeof window<`u`&&!!window.chrome}function r({force:r}={}){let i=r||n(),a=(e,t,n,r)=>{let i=``,a=0;do i+=e.substring(a,r)+n,a=r+t.length,r=e.indexOf(t,a);while(~r);return i+e.substring(a)},o=(e,t,n=e)=>{let r=r=>{let i=String(r),o=i.indexOf(t,e.length);return~o?e+a(i,t,n,o)+t:e+i+t};return r.open=e,r.close=t,r},s={isColorSupported:i},c=e=>`\x1B[${e}m`;for(let n in e){let r=e[n];s[n]=i?o(c(r[0]),c(r[1]),r[2]):t}return s}var i=r();export{i as t};
|