@wirecat/yandex-disk-cli 0.0.0-stage → 0.1.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/CHANGELOG.md +25 -0
- package/LICENSE +204 -0
- package/README.md +243 -2
- package/contracts/wirecat.json +1554 -0
- package/dist/bin/ydisk.d.ts +3 -0
- package/dist/bin/ydisk.d.ts.map +1 -0
- package/dist/bin/ydisk.js +40 -0
- package/dist/bin/ydisk.js.map +1 -0
- package/dist/bundle/all-profiles-4OLZF3RT.js +279 -0
- package/dist/bundle/anthropic-DKB4OJXZ.js +91 -0
- package/dist/bundle/app-server-G4545SSV.js +247 -0
- package/dist/bundle/bun-RXEQKFED.js +169 -0
- package/dist/bundle/bun-sqlite-VHT5LN7U.js +76 -0
- package/dist/bundle/chunk-2BITUXGC.js +12289 -0
- package/dist/bundle/chunk-2CLWDQKA.js +39330 -0
- package/dist/bundle/chunk-2JFDOPKA.js +9575 -0
- package/dist/bundle/chunk-3GVI2MAO.js +106 -0
- package/dist/bundle/chunk-3SZBWBMI.js +131 -0
- package/dist/bundle/chunk-44VSEXW6.js +4054 -0
- package/dist/bundle/chunk-4YPRRQBE.js +95 -0
- package/dist/bundle/chunk-5COYRL5B.js +379 -0
- package/dist/bundle/chunk-5D4AEUVA.js +24783 -0
- package/dist/bundle/chunk-5DM7DIZL.js +1402 -0
- package/dist/bundle/chunk-6R2DVTVZ.js +24 -0
- package/dist/bundle/chunk-762BS35H.js +2787 -0
- package/dist/bundle/chunk-AG64V7AB.js +1233 -0
- package/dist/bundle/chunk-BC5HGIXB.js +334 -0
- package/dist/bundle/chunk-BH7LFEX7.js +36 -0
- package/dist/bundle/chunk-BLNPGY7N.js +53 -0
- package/dist/bundle/chunk-CNIA2LJF.js +372 -0
- package/dist/bundle/chunk-COSXMDC7.js +230 -0
- package/dist/bundle/chunk-D72URWJE.js +532 -0
- package/dist/bundle/chunk-D7FO33KU.js +785 -0
- package/dist/bundle/chunk-DFDN6AUB.js +21 -0
- package/dist/bundle/chunk-DJH26PQ3.js +1396 -0
- package/dist/bundle/chunk-DJPT7IUC.js +64567 -0
- package/dist/bundle/chunk-DTMSCZDW.js +209 -0
- package/dist/bundle/chunk-E6LGZ5LX.js +16 -0
- package/dist/bundle/chunk-E6YRIHS5.js +92 -0
- package/dist/bundle/chunk-EH6ZEJGT.js +932 -0
- package/dist/bundle/chunk-F3DDSZTF.js +78 -0
- package/dist/bundle/chunk-F4WWTQNL.js +188 -0
- package/dist/bundle/chunk-FDDAUASC.js +1028 -0
- package/dist/bundle/chunk-FMNPG6N2.js +170 -0
- package/dist/bundle/chunk-FOKJ4POB.js +274 -0
- package/dist/bundle/chunk-G22C7JG6.js +731 -0
- package/dist/bundle/chunk-GA442SYZ.js +161 -0
- package/dist/bundle/chunk-GEBSW7UK.js +6848 -0
- package/dist/bundle/chunk-GGRKWAOK.js +594 -0
- package/dist/bundle/chunk-HHINRNZA.js +788 -0
- package/dist/bundle/chunk-HUZCL33L.js +128 -0
- package/dist/bundle/chunk-IALSIQVT.js +142 -0
- package/dist/bundle/chunk-IOXR2QBX.js +398 -0
- package/dist/bundle/chunk-J5CXR6VX.js +63 -0
- package/dist/bundle/chunk-J5PWSTOX.js +82 -0
- package/dist/bundle/chunk-J7BVAEHR.js +364 -0
- package/dist/bundle/chunk-JH46HMZW.js +1334 -0
- package/dist/bundle/chunk-JOBO7F6W.js +52 -0
- package/dist/bundle/chunk-JXZ5B3L5.js +2333 -0
- package/dist/bundle/chunk-KBIAMDZN.js +66 -0
- package/dist/bundle/chunk-KFVDL2QS.js +146 -0
- package/dist/bundle/chunk-LNHTLSR5.js +288 -0
- package/dist/bundle/chunk-M24RAKMJ.js +58 -0
- package/dist/bundle/chunk-MDQ57Q3H.js +1197 -0
- package/dist/bundle/chunk-MGUEZYFA.js +5546 -0
- package/dist/bundle/chunk-MLXQ4X5L.js +206 -0
- package/dist/bundle/chunk-NQAKARHE.js +54 -0
- package/dist/bundle/chunk-OF7VVUDQ.js +23 -0
- package/dist/bundle/chunk-OQVPE3XK.js +324 -0
- package/dist/bundle/chunk-OR3QG7UR.js +259 -0
- package/dist/bundle/chunk-OUUYVROP.js +76 -0
- package/dist/bundle/chunk-PQBAM64O.js +168 -0
- package/dist/bundle/chunk-PYVIA7WF.js +88 -0
- package/dist/bundle/chunk-Q6HK3PHE.js +72 -0
- package/dist/bundle/chunk-QB3KECV2.js +218 -0
- package/dist/bundle/chunk-QGWXSFYN.js +73 -0
- package/dist/bundle/chunk-RC5QAAAE.js +29 -0
- package/dist/bundle/chunk-RMJ26HLB.js +18 -0
- package/dist/bundle/chunk-S4UUN6LD.js +1410 -0
- package/dist/bundle/chunk-T7ZUDA4C.js +72 -0
- package/dist/bundle/chunk-TRCSMVV5.js +72 -0
- package/dist/bundle/chunk-UD2BQEKA.js +46 -0
- package/dist/bundle/chunk-V4TL55GS.js +1068 -0
- package/dist/bundle/chunk-VJNWN5VU.js +4072 -0
- package/dist/bundle/chunk-VRRNBLMA.js +1227 -0
- package/dist/bundle/chunk-WUCMMNFJ.js +771 -0
- package/dist/bundle/chunk-XDESE3NY.js +44 -0
- package/dist/bundle/chunk-XFLCVHSQ.js +50 -0
- package/dist/bundle/chunk-XQUUANA2.js +24600 -0
- package/dist/bundle/chunk-Y5E2WNWB.js +35 -0
- package/dist/bundle/chunk-Z2QEON7B.js +2275 -0
- package/dist/bundle/chunk-ZMJ56GME.js +7 -0
- package/dist/bundle/chunk-ZTSB3D7Q.js +100 -0
- package/dist/bundle/chunk-ZVJWD3FK.js +38 -0
- package/dist/bundle/chunk-ZVVMGPBJ.js +50 -0
- package/dist/bundle/command-contract-YIOYGPJA.js +40 -0
- package/dist/bundle/command-server-entry-MHBQDXS4.js +169 -0
- package/dist/bundle/decode-NUGJIOUW.js +297 -0
- package/dist/bundle/definitions-AILHKEQT.js +2005 -0
- package/dist/bundle/dispatch-5LC4UEGY.js +411 -0
- package/dist/bundle/dist-4I2W6X2I.js +7577 -0
- package/dist/bundle/echarts-MHSH6PGC.js +42501 -0
- package/dist/bundle/embed-ZDXTHHYS.js +38 -0
- package/dist/bundle/embedder-XFEELFUL.js +111 -0
- package/dist/bundle/failure-5S7VPBYK.js +25 -0
- package/dist/bundle/first-run-JHCHT3RJ.js +29 -0
- package/dist/bundle/first-screen-FHGQ6QRV.js +40 -0
- package/dist/bundle/instructions-WKSMBUFX.js +11 -0
- package/dist/bundle/mcp-HS2ZDUVR.js +167 -0
- package/dist/bundle/mdast-util-from-markdown-R66F4HZA.js +1958 -0
- package/dist/bundle/mdast-util-gfm-LN2ELINH.js +2699 -0
- package/dist/bundle/meeting-combined-K4U4NYRZ.js +25 -0
- package/dist/bundle/meeting-model-KCEG6Y5O.js +26 -0
- package/dist/bundle/meeting-semantic-VYGSV3H6.js +22 -0
- package/dist/bundle/micromark-extension-gfm-5X7YT43T.js +1838 -0
- package/dist/bundle/node-CM6NC6UE.js +176 -0
- package/dist/bundle/node-KM3CUABH.js +2340 -0
- package/dist/bundle/node-TLZSIHIJ.js +21 -0
- package/dist/bundle/node-sqlite-5YDQ3LIJ.js +74 -0
- package/dist/bundle/notes-search-PGO7KM2U.js +62 -0
- package/dist/bundle/oauth-NY4C5UCK.js +20 -0
- package/dist/bundle/open-YNUTA6ZE.js +23 -0
- package/dist/bundle/openai-4CVT5PHH.js +241 -0
- package/dist/bundle/process-2XT3TL27.js +91 -0
- package/dist/bundle/program-FMIVF5T6.js +31904 -0
- package/dist/bundle/prompt-VNWY3H6S.js +17 -0
- package/dist/bundle/recognize-JS4PBPSZ.js +26 -0
- package/dist/bundle/remote-RCLFH4V2.js +32 -0
- package/dist/bundle/rerank-EG6VKYGO.js +52 -0
- package/dist/bundle/schemas-ED2LHKXK.js +645 -0
- package/dist/bundle/serve-AHG25QXB.js +199 -0
- package/dist/bundle/server-5FTB7WM3.js +78 -0
- package/dist/bundle/server-JNZVSAZE.js +209 -0
- package/dist/bundle/sqlite-runtime-XSZOAQPF.js +20 -0
- package/dist/bundle/state-XGVAJFF7.js +36 -0
- package/dist/bundle/store-OHSCWZEV.js +177 -0
- package/dist/bundle/store-PKSPKJXL.js +293 -0
- package/dist/bundle/store-maintenance-command-KAWGBSWK.js +69 -0
- package/dist/bundle/ydisk.js +183 -0
- package/dist/commands/api.d.ts +9 -0
- package/dist/commands/api.d.ts.map +1 -0
- package/dist/commands/api.js +59 -0
- package/dist/commands/api.js.map +1 -0
- package/dist/commands/comments.d.ts +3 -0
- package/dist/commands/comments.d.ts.map +1 -0
- package/dist/commands/comments.js +114 -0
- package/dist/commands/comments.js.map +1 -0
- package/dist/commands/files.d.ts +3 -0
- package/dist/commands/files.d.ts.map +1 -0
- package/dist/commands/files.js +272 -0
- package/dist/commands/files.js.map +1 -0
- package/dist/commands/library.d.ts +13 -0
- package/dist/commands/library.d.ts.map +1 -0
- package/dist/commands/library.js +118 -0
- package/dist/commands/library.js.map +1 -0
- package/dist/commands/session.d.ts +3 -0
- package/dist/commands/session.d.ts.map +1 -0
- package/dist/commands/session.js +99 -0
- package/dist/commands/session.js.map +1 -0
- package/dist/config.d.ts +18 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +62 -0
- package/dist/config.js.map +1 -0
- package/dist/context.d.ts +80 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/context.js +77 -0
- package/dist/context.js.map +1 -0
- package/dist/generated/definitions.d.ts +3 -0
- package/dist/generated/definitions.d.ts.map +1 -0
- package/dist/generated/definitions.js +2001 -0
- package/dist/generated/definitions.js.map +1 -0
- package/dist/generated/manifest.d.ts +6 -0
- package/dist/generated/manifest.d.ts.map +1 -0
- package/dist/generated/manifest.js +1473 -0
- package/dist/generated/manifest.js.map +1 -0
- package/dist/generated/schemas.d.ts +127 -0
- package/dist/generated/schemas.d.ts.map +1 -0
- package/dist/generated/schemas.js +545 -0
- package/dist/generated/schemas.js.map +1 -0
- package/dist/generated/types.d.ts +829 -0
- package/dist/generated/types.d.ts.map +1 -0
- package/dist/generated/types.js +5 -0
- package/dist/generated/types.js.map +1 -0
- package/dist/identity.d.ts +10 -0
- package/dist/identity.d.ts.map +1 -0
- package/dist/identity.js +33 -0
- package/dist/identity.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/program.d.ts +6 -0
- package/dist/program.d.ts.map +1 -0
- package/dist/program.js +65 -0
- package/dist/program.js.map +1 -0
- package/dist/sample/comments.d.ts +61 -0
- package/dist/sample/comments.d.ts.map +1 -0
- package/dist/sample/comments.js +39 -0
- package/dist/sample/comments.js.map +1 -0
- package/dist/sample/records.d.ts +16 -0
- package/dist/sample/records.d.ts.map +1 -0
- package/dist/sample/records.js +22 -0
- package/dist/sample/records.js.map +1 -0
- package/dist/sample/transport.d.ts +42 -0
- package/dist/sample/transport.d.ts.map +1 -0
- package/dist/sample/transport.js +153 -0
- package/dist/sample/transport.js.map +1 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +2 -0
- package/dist/version.js.map +1 -0
- package/dist/wcat.d.ts +3 -0
- package/dist/wcat.d.ts.map +1 -0
- package/dist/wcat.js +4 -0
- package/dist/wcat.js.map +1 -0
- package/dist/yandex/source.d.ts +39 -0
- package/dist/yandex/source.d.ts.map +1 -0
- package/dist/yandex/source.js +189 -0
- package/dist/yandex/source.js.map +1 -0
- package/dist/yandex/transport.d.ts +41 -0
- package/dist/yandex/transport.d.ts.map +1 -0
- package/dist/yandex/transport.js +152 -0
- package/dist/yandex/transport.js.map +1 -0
- package/dist/yandex/writes.d.ts +27 -0
- package/dist/yandex/writes.d.ts.map +1 -0
- package/dist/yandex/writes.js +61 -0
- package/dist/yandex/writes.js.map +1 -0
- package/package.json +88 -4
- package/skills/yandex-disk-cli/SKILL.md +46 -0
- package/skills/yandex-disk-cli/references/api/api-disk-operations-operation-id.md +13 -0
- package/skills/yandex-disk-cli/references/api/api-disk-public-resources.md +50 -0
- package/skills/yandex-disk-cli/references/api/api-disk-resources.md +171 -0
- package/skills/yandex-disk-cli/references/api/api-disk-trash-resources.md +48 -0
- package/skills/yandex-disk-cli/references/api/api-disk.md +13 -0
- package/skills/yandex-disk-cli/references/api.md +17 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ydisk.d.ts","sourceRoot":"","sources":["../../src/bin/ydisk.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// cli-dev bundle loader
|
|
3
|
+
import * as module from "node:module"
|
|
4
|
+
|
|
5
|
+
const words = process.argv.slice(2)
|
|
6
|
+
// As the CLI answers it, unless a test records the argv: then the CLI writes the record too.
|
|
7
|
+
if (
|
|
8
|
+
words.length === 1 &&
|
|
9
|
+
(words[0] === "--version" || words[0] === "-V") &&
|
|
10
|
+
!Object.keys(process.env).some((key) => key.endsWith("_TEST_ARGV_LOG"))
|
|
11
|
+
) {
|
|
12
|
+
process.stdout.write("0.1.0\n")
|
|
13
|
+
} else {
|
|
14
|
+
// Before the bundle compiles: the bundle's own call comes after its chunks.
|
|
15
|
+
module.enableCompileCache()
|
|
16
|
+
const serves = ((words) => {
|
|
17
|
+
const plain = words.filter((word) => !word.startsWith("-"));
|
|
18
|
+
return plain
|
|
19
|
+
.slice(0, 4)
|
|
20
|
+
.some((word, at) => word === "serve" || word === "watch" || (word === "mcp" && plain[at + 1] === undefined));
|
|
21
|
+
})(words)
|
|
22
|
+
if (serves && module.registerHooks) {
|
|
23
|
+
const bundle = new URL("../bundle/", import.meta.url).href
|
|
24
|
+
module.registerHooks({
|
|
25
|
+
resolve: (specifier, context, next) =>
|
|
26
|
+
specifier.startsWith("./") && context.parentURL?.startsWith(bundle)
|
|
27
|
+
? { url: new URL(specifier, context.parentURL).href, format: "module", shortCircuit: true }
|
|
28
|
+
: next(specifier, context),
|
|
29
|
+
})
|
|
30
|
+
}
|
|
31
|
+
const chunks = ["../bundle/all-profiles-4OLZF3RT.js","../bundle/anthropic-DKB4OJXZ.js","../bundle/app-server-G4545SSV.js","../bundle/bun-RXEQKFED.js","../bundle/bun-sqlite-VHT5LN7U.js","../bundle/decode-NUGJIOUW.js","../bundle/definitions-AILHKEQT.js","../bundle/dispatch-5LC4UEGY.js","../bundle/dist-4I2W6X2I.js","../bundle/echarts-MHSH6PGC.js","../bundle/embed-ZDXTHHYS.js","../bundle/embedder-XFEELFUL.js","../bundle/failure-5S7VPBYK.js","../bundle/first-screen-FHGQ6QRV.js","../bundle/instructions-WKSMBUFX.js","../bundle/mcp-HS2ZDUVR.js","../bundle/node-CM6NC6UE.js","../bundle/node-KM3CUABH.js","../bundle/node-TLZSIHIJ.js","../bundle/node-sqlite-5YDQ3LIJ.js","../bundle/notes-search-PGO7KM2U.js","../bundle/oauth-NY4C5UCK.js","../bundle/open-YNUTA6ZE.js","../bundle/openai-4CVT5PHH.js","../bundle/process-2XT3TL27.js","../bundle/program-FMIVF5T6.js","../bundle/prompt-VNWY3H6S.js","../bundle/recognize-JS4PBPSZ.js","../bundle/remote-RCLFH4V2.js","../bundle/rerank-EG6VKYGO.js","../bundle/schemas-ED2LHKXK.js","../bundle/serve-AHG25QXB.js","../bundle/server-5FTB7WM3.js","../bundle/server-JNZVSAZE.js","../bundle/sqlite-runtime-XSZOAQPF.js","../bundle/state-XGVAJFF7.js","../bundle/store-OHSCWZEV.js","../bundle/store-PKSPKJXL.js","../bundle/store-maintenance-command-KAWGBSWK.js"]
|
|
32
|
+
if (((words) => words
|
|
33
|
+
.filter((word) => !word.startsWith("-"))
|
|
34
|
+
.slice(0, 2)
|
|
35
|
+
.includes("upgrade"))(words)) await Promise.allSettled(chunks.map((chunk) => import(chunk)))
|
|
36
|
+
const running = import("../bundle/ydisk.js")
|
|
37
|
+
// After the server answers its first request, so it starts no later.
|
|
38
|
+
if (serves) setTimeout(() => void Promise.allSettled(chunks.map((chunk) => import(chunk))), 2000).unref()
|
|
39
|
+
await running
|
|
40
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ydisk.js","sourceRoot":"","sources":["../../src/bin/ydisk.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAA;AACxD,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA;AAExC,kBAAkB,EAAE,CAAA;AACpB,oGAAoG;AACpG,MAAM,YAAY,GAAG,YAAY,CAAC,EAAE,GAAG,EAAE,OAAO,CAAC,OAAO,EAAE,WAAW,EAAE,OAAO,CAAC,MAAM,CAAC,KAAK,KAAK,IAAI,EAAE,CAAC,CAAA;AACvG,MAAM,IAAI,GAAG,MAAM,SAAS,CAAC,OAAO,CAAC,CAAA;AACrC,IAAI,IAAI,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;IAC5B,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAA;AAC9B,CAAC;KAAM,CAAC;IACN,MAAM,EAAE,GAAG,EAAE,GAAG,MAAM,MAAM,CAAC,eAAe,CAAC,CAAA;IAC7C,OAAO,CAAC,QAAQ,GAAG,MAAM,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAA;AACrD,CAAC;AACD,YAAY,EAAE,CAAA"}
|
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
import { createRequire as __bundleRequire } from "node:module";
|
|
2
|
+
const require = __bundleRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
CALLER_META_KEY,
|
|
5
|
+
PROXY_CLIENT_NAME,
|
|
6
|
+
StdioServerTransport,
|
|
7
|
+
answeredWire,
|
|
8
|
+
callerOf,
|
|
9
|
+
serveStdio
|
|
10
|
+
} from "./chunk-G22C7JG6.js";
|
|
11
|
+
import {
|
|
12
|
+
McpServer
|
|
13
|
+
} from "./chunk-5D4AEUVA.js";
|
|
14
|
+
import "./chunk-J7BVAEHR.js";
|
|
15
|
+
import "./chunk-E6YRIHS5.js";
|
|
16
|
+
import "./chunk-TRCSMVV5.js";
|
|
17
|
+
import "./chunk-ZMJ56GME.js";
|
|
18
|
+
import "./chunk-762BS35H.js";
|
|
19
|
+
import {
|
|
20
|
+
errorObjectOf,
|
|
21
|
+
mcpErrorResult
|
|
22
|
+
} from "./chunk-AG64V7AB.js";
|
|
23
|
+
import "./chunk-S4UUN6LD.js";
|
|
24
|
+
import "./chunk-Y5E2WNWB.js";
|
|
25
|
+
import {
|
|
26
|
+
CliError
|
|
27
|
+
} from "./chunk-T7ZUDA4C.js";
|
|
28
|
+
import {
|
|
29
|
+
__name
|
|
30
|
+
} from "./chunk-ZVVMGPBJ.js";
|
|
31
|
+
|
|
32
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.692.0_@wirecat+cli-base@0.110.0_@scalar+openapi-upgrader@0.4.6_comm_daa46dda8170ab81fe68d59b38277e40/node_modules/@wirecat/cli-core/dist/mcp/all-profiles.js
|
|
33
|
+
import { spawn } from "node:child_process";
|
|
34
|
+
import { randomUUID } from "node:crypto";
|
|
35
|
+
var PROTOCOL = "2025-06-18";
|
|
36
|
+
var START_MS = 3e4;
|
|
37
|
+
var CHILD_IDLE_MS = 10 * 60 * 1e3;
|
|
38
|
+
var startChild = /* @__PURE__ */ __name((spec, note, onExit) => {
|
|
39
|
+
const child = spawn(spec.command, spec.args, { env: spec.env, stdio: "pipe" });
|
|
40
|
+
const pending = /* @__PURE__ */ new Map();
|
|
41
|
+
let next = 1;
|
|
42
|
+
let buffer = "";
|
|
43
|
+
let gone;
|
|
44
|
+
const fail = /* @__PURE__ */ __name((error) => {
|
|
45
|
+
gone ??= error;
|
|
46
|
+
for (const waiter of pending.values())
|
|
47
|
+
waiter.reject(error);
|
|
48
|
+
pending.clear();
|
|
49
|
+
}, "fail");
|
|
50
|
+
child.on("error", () => fail(new Error("the profile's MCP server could not be started")));
|
|
51
|
+
child.on("exit", () => {
|
|
52
|
+
fail(new Error("the profile's MCP server stopped"));
|
|
53
|
+
onExit();
|
|
54
|
+
});
|
|
55
|
+
child.stdin.on("error", () => fail(new Error("the profile's MCP server closed its input")));
|
|
56
|
+
child.stderr.setEncoding("utf8");
|
|
57
|
+
let errors = "";
|
|
58
|
+
child.stderr.on("data", (chunk) => {
|
|
59
|
+
const lines = (errors + chunk).split("\n");
|
|
60
|
+
errors = lines.pop() ?? "";
|
|
61
|
+
for (const line of lines)
|
|
62
|
+
if (line.trim())
|
|
63
|
+
note(line);
|
|
64
|
+
});
|
|
65
|
+
child.stdout.setEncoding("utf8");
|
|
66
|
+
child.stdout.on("data", (chunk) => {
|
|
67
|
+
buffer += chunk;
|
|
68
|
+
for (let at = buffer.indexOf("\n"); at !== -1; at = buffer.indexOf("\n")) {
|
|
69
|
+
const line = buffer.slice(0, at);
|
|
70
|
+
buffer = buffer.slice(at + 1);
|
|
71
|
+
let message;
|
|
72
|
+
try {
|
|
73
|
+
message = JSON.parse(line);
|
|
74
|
+
} catch {
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
if (message.method !== void 0 && message.id !== void 0) {
|
|
78
|
+
send({ id: message.id, error: { code: -32601, message: "not offered through the all-profiles server" } });
|
|
79
|
+
continue;
|
|
80
|
+
}
|
|
81
|
+
if (typeof message.id !== "number")
|
|
82
|
+
continue;
|
|
83
|
+
const waiter = pending.get(message.id);
|
|
84
|
+
if (!waiter)
|
|
85
|
+
continue;
|
|
86
|
+
pending.delete(message.id);
|
|
87
|
+
if (message.error)
|
|
88
|
+
waiter.reject(new Error(message.error.message ?? "the profile's MCP server refused"));
|
|
89
|
+
else
|
|
90
|
+
waiter.resolve(message.result ?? {});
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
const send = /* @__PURE__ */ __name((message) => child.stdin.write(`${JSON.stringify({ jsonrpc: "2.0", ...message })}
|
|
94
|
+
`), "send");
|
|
95
|
+
const request = /* @__PURE__ */ __name((method, params) => new Promise((resolve, reject) => {
|
|
96
|
+
if (gone)
|
|
97
|
+
return reject(gone);
|
|
98
|
+
const id = next++;
|
|
99
|
+
pending.set(id, { resolve, reject });
|
|
100
|
+
send({ id, method, params });
|
|
101
|
+
}), "request");
|
|
102
|
+
const close = /* @__PURE__ */ __name(() => new Promise((resolve) => {
|
|
103
|
+
if (child.exitCode !== null || child.signalCode !== null)
|
|
104
|
+
return resolve();
|
|
105
|
+
child.once("exit", () => resolve());
|
|
106
|
+
child.stdin.end();
|
|
107
|
+
}), "close");
|
|
108
|
+
const timer = setTimeout(() => fail(new Error("the profile's MCP server did not answer in time")), START_MS);
|
|
109
|
+
return request("initialize", {
|
|
110
|
+
protocolVersion: PROTOCOL,
|
|
111
|
+
capabilities: {},
|
|
112
|
+
clientInfo: { name: PROXY_CLIENT_NAME, version: "1" }
|
|
113
|
+
}).then(() => {
|
|
114
|
+
send({ method: "notifications/initialized" });
|
|
115
|
+
return { request, close };
|
|
116
|
+
}).catch(async (error) => {
|
|
117
|
+
await close();
|
|
118
|
+
throw error;
|
|
119
|
+
}).finally(() => clearTimeout(timer));
|
|
120
|
+
}, "startChild");
|
|
121
|
+
var pool = /* @__PURE__ */ __name((options) => {
|
|
122
|
+
const idleMs = options.idleMs ?? CHILD_IDLE_MS;
|
|
123
|
+
const note = options.note ?? (() => {
|
|
124
|
+
});
|
|
125
|
+
const running = /* @__PURE__ */ new Map();
|
|
126
|
+
const forget = /* @__PURE__ */ __name((profile, child) => {
|
|
127
|
+
const one = running.get(profile);
|
|
128
|
+
if (one?.child !== child)
|
|
129
|
+
return;
|
|
130
|
+
clearTimeout(one.timer);
|
|
131
|
+
running.delete(profile);
|
|
132
|
+
}, "forget");
|
|
133
|
+
const use = /* @__PURE__ */ __name(async (profile, work) => {
|
|
134
|
+
let one = running.get(profile);
|
|
135
|
+
if (!one) {
|
|
136
|
+
const child = startChild(options.child(profile), (line) => note(`${profile}: ${line}`), () => forget(profile, child));
|
|
137
|
+
child.catch(() => forget(profile, child));
|
|
138
|
+
one = { child };
|
|
139
|
+
running.set(profile, one);
|
|
140
|
+
}
|
|
141
|
+
clearTimeout(one.timer);
|
|
142
|
+
const entry = one;
|
|
143
|
+
try {
|
|
144
|
+
return await work(await entry.child);
|
|
145
|
+
} finally {
|
|
146
|
+
if (running.get(profile) === entry) {
|
|
147
|
+
entry.timer = setTimeout(() => {
|
|
148
|
+
forget(profile, entry.child);
|
|
149
|
+
void entry.child.then((child) => child.close()).catch(() => void 0);
|
|
150
|
+
}, idleMs);
|
|
151
|
+
entry.timer.unref();
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}, "use");
|
|
155
|
+
const close = /* @__PURE__ */ __name(async () => {
|
|
156
|
+
const all = [...running.values()];
|
|
157
|
+
running.clear();
|
|
158
|
+
for (const one of all)
|
|
159
|
+
clearTimeout(one.timer);
|
|
160
|
+
await Promise.all(all.map((one) => one.child.then((child) => child.close()).catch(() => void 0)));
|
|
161
|
+
}, "close");
|
|
162
|
+
return { use, close };
|
|
163
|
+
}, "pool");
|
|
164
|
+
var withProfile = /* @__PURE__ */ __name((tool, profiles, name, signedIn = () => true) => {
|
|
165
|
+
const schema = tool.inputSchema;
|
|
166
|
+
const out = profiles.filter((profile) => !signedIn(profile));
|
|
167
|
+
const states = out.length === 0 ? "" : ` Signed in: ${profiles.filter(signedIn).join(", ") || "none"} \xB7 Not signed in: ${out.join(", ")}.`;
|
|
168
|
+
return {
|
|
169
|
+
...tool,
|
|
170
|
+
inputSchema: {
|
|
171
|
+
...tool.inputSchema,
|
|
172
|
+
properties: {
|
|
173
|
+
profile: {
|
|
174
|
+
type: "string",
|
|
175
|
+
enum: [...profiles],
|
|
176
|
+
oneOf: profiles.map((profile) => ({
|
|
177
|
+
const: profile,
|
|
178
|
+
title: signedIn(profile) ? profile : `${profile} \u2014 not signed in`
|
|
179
|
+
})),
|
|
180
|
+
description: `Which ${name} account, by its profile. If the owner did not name one, ask which \u2014 never guess.${states}`
|
|
181
|
+
},
|
|
182
|
+
...schema.properties
|
|
183
|
+
},
|
|
184
|
+
required: ["profile", ...(schema.required ?? []).filter((field) => field !== "profile")]
|
|
185
|
+
}
|
|
186
|
+
};
|
|
187
|
+
}, "withProfile");
|
|
188
|
+
var refusal = /* @__PURE__ */ __name((code, text, details) => mcpErrorResult(errorObjectOf(new CliError(code, text, details), { effects: { remote: "none", local: "none" } })), "refusal");
|
|
189
|
+
var allProfilesServer = /* @__PURE__ */ __name((options) => {
|
|
190
|
+
const children = pool(options);
|
|
191
|
+
let listed;
|
|
192
|
+
const tools = /* @__PURE__ */ __name((profiles) => {
|
|
193
|
+
listed ??= children.use(profiles.find(signedIn) ?? profiles[0], (child) => child.request("tools/list", {})).then((answer) => answer.tools ?? []);
|
|
194
|
+
listed.catch(() => {
|
|
195
|
+
listed = void 0;
|
|
196
|
+
});
|
|
197
|
+
return listed;
|
|
198
|
+
}, "tools");
|
|
199
|
+
const signedIn = /* @__PURE__ */ __name((profile) => options.signedIn?.(profile) ?? true, "signedIn");
|
|
200
|
+
const build = /* @__PURE__ */ __name(() => {
|
|
201
|
+
const profiles = [...options.profiles()].sort();
|
|
202
|
+
const server = new McpServer({ name: options.command, version: options.version }, { capabilities: { tools: {} }, instructions: options.instructions });
|
|
203
|
+
server.server.setRequestHandler("tools/list", async () => ({
|
|
204
|
+
tools: profiles.length === 0 ? [] : (await tools(profiles)).map((one) => withProfile(one, profiles, options.name, signedIn))
|
|
205
|
+
}));
|
|
206
|
+
const callers = {
|
|
207
|
+
env: options.env ?? process.env,
|
|
208
|
+
client: /* @__PURE__ */ __name(() => server.server.getClientVersion(), "client"),
|
|
209
|
+
connectionId: randomUUID()
|
|
210
|
+
};
|
|
211
|
+
server.server.setRequestHandler("tools/call", async (request, ctx) => {
|
|
212
|
+
const { name, arguments: given = {}, _meta } = request.params;
|
|
213
|
+
const { profile, ...rest } = given;
|
|
214
|
+
if (typeof profile !== "string" || !profiles.includes(profile))
|
|
215
|
+
return refusal("validation_error", `${name} needs "profile", one of: ${profiles.join(", ")}. If the owner did not say which account, ask.`);
|
|
216
|
+
if (!signedIn(profile))
|
|
217
|
+
return refusal("authentication_error", options.signIn?.(profile) ?? `profile ${profile} is not signed in.`);
|
|
218
|
+
try {
|
|
219
|
+
return await children.use(profile, (child) => (
|
|
220
|
+
// Children are shared by every session, so each call names its own caller.
|
|
221
|
+
child.request("tools/call", {
|
|
222
|
+
name,
|
|
223
|
+
arguments: rest,
|
|
224
|
+
_meta: { ..._meta, [CALLER_META_KEY]: callerOf(ctx, name, callers) }
|
|
225
|
+
})
|
|
226
|
+
));
|
|
227
|
+
} catch (error) {
|
|
228
|
+
return refusal("outcome_unknown", `profile ${profile}: ${error instanceof Error ? error.message : String(error)}`);
|
|
229
|
+
}
|
|
230
|
+
});
|
|
231
|
+
return server;
|
|
232
|
+
}, "build");
|
|
233
|
+
return { build, close: /* @__PURE__ */ __name(() => children.close(), "close") };
|
|
234
|
+
}, "allProfilesServer");
|
|
235
|
+
var serveAllProfilesOverStdio = /* @__PURE__ */ __name(async (options, io = {}) => {
|
|
236
|
+
const { build, close } = allProfilesServer(options);
|
|
237
|
+
const own = io.stdin !== void 0 && io.stdin !== process.stdin;
|
|
238
|
+
const wire = answeredWire(io.stdin ?? process.stdin, io.stdout ?? process.stdout);
|
|
239
|
+
const handle = serveStdio(build, {
|
|
240
|
+
transport: new StdioServerTransport(wire.input, wire.output),
|
|
241
|
+
onerror: /* @__PURE__ */ __name((error) => options.note?.(`mcp: ${error.message}`), "onerror")
|
|
242
|
+
});
|
|
243
|
+
await wire.finished(own ? io.signal : void 0);
|
|
244
|
+
try {
|
|
245
|
+
wire.release();
|
|
246
|
+
await handle.close();
|
|
247
|
+
} finally {
|
|
248
|
+
await close();
|
|
249
|
+
}
|
|
250
|
+
}, "serveAllProfilesOverStdio");
|
|
251
|
+
var serveAllProfilesOverHttp = /* @__PURE__ */ __name(async (options, http) => {
|
|
252
|
+
const { build, close } = allProfilesServer(options);
|
|
253
|
+
const { serveOverHttp } = await import("./serve-AHG25QXB.js");
|
|
254
|
+
const listening = await serveOverHttp(build, {
|
|
255
|
+
...http,
|
|
256
|
+
appName: options.command,
|
|
257
|
+
onError: /* @__PURE__ */ __name((error) => options.note?.(`mcp: ${error.message}`), "onError")
|
|
258
|
+
}).catch(async (error) => {
|
|
259
|
+
await close();
|
|
260
|
+
throw error;
|
|
261
|
+
});
|
|
262
|
+
return {
|
|
263
|
+
url: listening.url,
|
|
264
|
+
close: /* @__PURE__ */ __name(async () => {
|
|
265
|
+
try {
|
|
266
|
+
await listening.close();
|
|
267
|
+
} finally {
|
|
268
|
+
await close();
|
|
269
|
+
}
|
|
270
|
+
}, "close")
|
|
271
|
+
};
|
|
272
|
+
}, "serveAllProfilesOverHttp");
|
|
273
|
+
export {
|
|
274
|
+
CHILD_IDLE_MS,
|
|
275
|
+
allProfilesServer,
|
|
276
|
+
serveAllProfilesOverHttp,
|
|
277
|
+
serveAllProfilesOverStdio,
|
|
278
|
+
withProfile
|
|
279
|
+
};
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { createRequire as __bundleRequire } from "node:module";
|
|
2
|
+
const require = __bundleRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
Anthropic
|
|
5
|
+
} from "./chunk-XQUUANA2.js";
|
|
6
|
+
import {
|
|
7
|
+
EmptyAnswer,
|
|
8
|
+
checkedOptions,
|
|
9
|
+
messagesFor,
|
|
10
|
+
systemFor
|
|
11
|
+
} from "./chunk-OUUYVROP.js";
|
|
12
|
+
import "./chunk-762BS35H.js";
|
|
13
|
+
import "./chunk-AG64V7AB.js";
|
|
14
|
+
import {
|
|
15
|
+
array,
|
|
16
|
+
literal,
|
|
17
|
+
optional,
|
|
18
|
+
picklist,
|
|
19
|
+
record,
|
|
20
|
+
strictObject,
|
|
21
|
+
string,
|
|
22
|
+
unknown
|
|
23
|
+
} from "./chunk-S4UUN6LD.js";
|
|
24
|
+
import "./chunk-Y5E2WNWB.js";
|
|
25
|
+
import "./chunk-T7ZUDA4C.js";
|
|
26
|
+
import {
|
|
27
|
+
__name
|
|
28
|
+
} from "./chunk-ZVVMGPBJ.js";
|
|
29
|
+
|
|
30
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.692.0_@wirecat+cli-base@0.110.0_@scalar+openapi-upgrader@0.4.6_comm_daa46dda8170ab81fe68d59b38277e40/node_modules/@wirecat/cli-core/dist/models/anthropic.js
|
|
31
|
+
var options = strictObject({
|
|
32
|
+
stop_sequences: optional(array(string())),
|
|
33
|
+
thinking: optional(strictObject({ type: picklist(["disabled", "adaptive"]) })),
|
|
34
|
+
output_config: optional(strictObject({
|
|
35
|
+
effort: optional(picklist(["low", "medium", "high"])),
|
|
36
|
+
format: optional(strictObject({ type: literal("json_schema"), schema: record(string(), unknown()) }))
|
|
37
|
+
}))
|
|
38
|
+
});
|
|
39
|
+
var anthropic = {
|
|
40
|
+
images: true,
|
|
41
|
+
baseUrl: "https://api.anthropic.com",
|
|
42
|
+
validate: /* @__PURE__ */ __name((given) => checkedOptions("anthropic", options, given), "validate"),
|
|
43
|
+
complete: /* @__PURE__ */ __name(async (target, request, checked, apiKey, fetcher) => {
|
|
44
|
+
const client = new Anthropic({
|
|
45
|
+
apiKey: apiKey ?? "",
|
|
46
|
+
authToken: null,
|
|
47
|
+
fetch: /* @__PURE__ */ __name((input, init) => fetcher(input, { ...init, redirect: "error" }), "fetch"),
|
|
48
|
+
baseURL: target.baseUrl,
|
|
49
|
+
maxRetries: 0,
|
|
50
|
+
logLevel: "off",
|
|
51
|
+
timeout: 12e4
|
|
52
|
+
});
|
|
53
|
+
const response = await client.messages.stream({
|
|
54
|
+
...checked,
|
|
55
|
+
model: target.model,
|
|
56
|
+
system: systemFor(request),
|
|
57
|
+
messages: [
|
|
58
|
+
...messagesFor(request),
|
|
59
|
+
...request.images === void 0 ? [] : [
|
|
60
|
+
{
|
|
61
|
+
role: "user",
|
|
62
|
+
content: [
|
|
63
|
+
{ type: "text", text: request.prompt },
|
|
64
|
+
...request.images.map((image) => ({
|
|
65
|
+
type: "image",
|
|
66
|
+
source: { type: "base64", media_type: image.mimeType, data: image.data }
|
|
67
|
+
}))
|
|
68
|
+
]
|
|
69
|
+
}
|
|
70
|
+
]
|
|
71
|
+
],
|
|
72
|
+
max_tokens: request.maxTokens
|
|
73
|
+
}).finalMessage();
|
|
74
|
+
if (response.stop_reason !== "end_turn")
|
|
75
|
+
throw new Error("incomplete response");
|
|
76
|
+
const text = response.content.filter((block) => block.type === "text").map((block) => block.text).join("");
|
|
77
|
+
if (text.trim() === "")
|
|
78
|
+
throw new EmptyAnswer();
|
|
79
|
+
return {
|
|
80
|
+
text,
|
|
81
|
+
usage: {
|
|
82
|
+
input: response.usage.input_tokens + (response.usage.cache_creation_input_tokens ?? 0) + (response.usage.cache_read_input_tokens ?? 0),
|
|
83
|
+
output: response.usage.output_tokens
|
|
84
|
+
},
|
|
85
|
+
tokens: response.usage.input_tokens + response.usage.output_tokens + (response.usage.cache_creation_input_tokens ?? 0) + (response.usage.cache_read_input_tokens ?? 0)
|
|
86
|
+
};
|
|
87
|
+
}, "complete")
|
|
88
|
+
};
|
|
89
|
+
export {
|
|
90
|
+
anthropic
|
|
91
|
+
};
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
import { createRequire as __bundleRequire } from "node:module";
|
|
2
|
+
const require = __bundleRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
PER_RUN,
|
|
5
|
+
envelope
|
|
6
|
+
} from "./chunk-HHINRNZA.js";
|
|
7
|
+
import {
|
|
8
|
+
mcpUrlOf
|
|
9
|
+
} from "./chunk-JH46HMZW.js";
|
|
10
|
+
import "./chunk-RMJ26HLB.js";
|
|
11
|
+
import {
|
|
12
|
+
answered,
|
|
13
|
+
failed,
|
|
14
|
+
registerCommands,
|
|
15
|
+
runCommandForAgent,
|
|
16
|
+
toolsFromCommands
|
|
17
|
+
} from "./chunk-44VSEXW6.js";
|
|
18
|
+
import {
|
|
19
|
+
agentJson,
|
|
20
|
+
skillResources
|
|
21
|
+
} from "./chunk-5DM7DIZL.js";
|
|
22
|
+
import {
|
|
23
|
+
StdioServerTransport,
|
|
24
|
+
answeredWire,
|
|
25
|
+
serveStdio
|
|
26
|
+
} from "./chunk-G22C7JG6.js";
|
|
27
|
+
import "./chunk-DJH26PQ3.js";
|
|
28
|
+
import "./chunk-2CLWDQKA.js";
|
|
29
|
+
import "./chunk-5COYRL5B.js";
|
|
30
|
+
import "./chunk-J5PWSTOX.js";
|
|
31
|
+
import "./chunk-PYVIA7WF.js";
|
|
32
|
+
import "./chunk-IALSIQVT.js";
|
|
33
|
+
import "./chunk-UD2BQEKA.js";
|
|
34
|
+
import {
|
|
35
|
+
appInstructions
|
|
36
|
+
} from "./chunk-BLNPGY7N.js";
|
|
37
|
+
import {
|
|
38
|
+
McpServer
|
|
39
|
+
} from "./chunk-5D4AEUVA.js";
|
|
40
|
+
import "./chunk-Z2QEON7B.js";
|
|
41
|
+
import "./chunk-BH7LFEX7.js";
|
|
42
|
+
import "./chunk-OUUYVROP.js";
|
|
43
|
+
import "./chunk-OR3QG7UR.js";
|
|
44
|
+
import "./chunk-DTMSCZDW.js";
|
|
45
|
+
import "./chunk-PQBAM64O.js";
|
|
46
|
+
import "./chunk-FMNPG6N2.js";
|
|
47
|
+
import {
|
|
48
|
+
mcpHttpMarker
|
|
49
|
+
} from "./chunk-GA442SYZ.js";
|
|
50
|
+
import "./chunk-QGWXSFYN.js";
|
|
51
|
+
import "./chunk-3SZBWBMI.js";
|
|
52
|
+
import {
|
|
53
|
+
DEFAULT_OUTPUT_BYTES,
|
|
54
|
+
changesAuthorityAt,
|
|
55
|
+
describeProgram,
|
|
56
|
+
environmentOf,
|
|
57
|
+
fetchesOnlyAt,
|
|
58
|
+
judgedTargets,
|
|
59
|
+
readsOverMcpAt,
|
|
60
|
+
rootOf2 as rootOf
|
|
61
|
+
} from "./chunk-2BITUXGC.js";
|
|
62
|
+
import "./chunk-J7BVAEHR.js";
|
|
63
|
+
import "./chunk-JOBO7F6W.js";
|
|
64
|
+
import {
|
|
65
|
+
readOnlyLockOf
|
|
66
|
+
} from "./chunk-IOXR2QBX.js";
|
|
67
|
+
import "./chunk-BC5HGIXB.js";
|
|
68
|
+
import "./chunk-J5CXR6VX.js";
|
|
69
|
+
import "./chunk-V4TL55GS.js";
|
|
70
|
+
import "./chunk-KBIAMDZN.js";
|
|
71
|
+
import "./chunk-DJPT7IUC.js";
|
|
72
|
+
import "./chunk-GGRKWAOK.js";
|
|
73
|
+
import "./chunk-JXZ5B3L5.js";
|
|
74
|
+
import "./chunk-WUCMMNFJ.js";
|
|
75
|
+
import "./chunk-E6LGZ5LX.js";
|
|
76
|
+
import "./chunk-D7FO33KU.js";
|
|
77
|
+
import "./chunk-E6YRIHS5.js";
|
|
78
|
+
import "./chunk-VRRNBLMA.js";
|
|
79
|
+
import "./chunk-TRCSMVV5.js";
|
|
80
|
+
import "./chunk-RC5QAAAE.js";
|
|
81
|
+
import "./chunk-VJNWN5VU.js";
|
|
82
|
+
import "./chunk-ZMJ56GME.js";
|
|
83
|
+
import "./chunk-HUZCL33L.js";
|
|
84
|
+
import "./chunk-Q6HK3PHE.js";
|
|
85
|
+
import "./chunk-CNIA2LJF.js";
|
|
86
|
+
import "./chunk-MDQ57Q3H.js";
|
|
87
|
+
import "./chunk-FDDAUASC.js";
|
|
88
|
+
import "./chunk-FOKJ4POB.js";
|
|
89
|
+
import "./chunk-OF7VVUDQ.js";
|
|
90
|
+
import "./chunk-D72URWJE.js";
|
|
91
|
+
import "./chunk-NQAKARHE.js";
|
|
92
|
+
import "./chunk-4YPRRQBE.js";
|
|
93
|
+
import "./chunk-ZVJWD3FK.js";
|
|
94
|
+
import "./chunk-762BS35H.js";
|
|
95
|
+
import {
|
|
96
|
+
mcpErrorResult
|
|
97
|
+
} from "./chunk-AG64V7AB.js";
|
|
98
|
+
import "./chunk-S4UUN6LD.js";
|
|
99
|
+
import "./chunk-Y5E2WNWB.js";
|
|
100
|
+
import {
|
|
101
|
+
CliError
|
|
102
|
+
} from "./chunk-T7ZUDA4C.js";
|
|
103
|
+
import "./chunk-GEBSW7UK.js";
|
|
104
|
+
import {
|
|
105
|
+
__name
|
|
106
|
+
} from "./chunk-ZVVMGPBJ.js";
|
|
107
|
+
|
|
108
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.692.0_@wirecat+cli-base@0.110.0_@scalar+openapi-upgrader@0.4.6_comm_daa46dda8170ab81fe68d59b38277e40/node_modules/@wirecat/cli-core/dist/mcp/app-server.js
|
|
109
|
+
var EXCLUDED = [["mcp"]];
|
|
110
|
+
var aliasesOf = /* @__PURE__ */ __name((root, path) => {
|
|
111
|
+
let at = root;
|
|
112
|
+
for (const name of path)
|
|
113
|
+
at = at?.commands.find((child) => child.name() === name);
|
|
114
|
+
const aliases = at?.aliases() ?? [];
|
|
115
|
+
return aliases.length > 0 ? { aliases } : {};
|
|
116
|
+
}, "aliasesOf");
|
|
117
|
+
var createAppServer = /* @__PURE__ */ __name((command, context, options) => {
|
|
118
|
+
const { app } = options;
|
|
119
|
+
const root = rootOf(command);
|
|
120
|
+
const environment = environmentOf(command);
|
|
121
|
+
if (!environment.runCommand)
|
|
122
|
+
throw new Error("the MCP server runs inside run(), which hands it the program");
|
|
123
|
+
const program = { run: environment.runCommand, commands: describeProgram(root) };
|
|
124
|
+
const flags = command.optsWithGlobals();
|
|
125
|
+
const overrides = flags.permission ?? [];
|
|
126
|
+
const { settings } = context;
|
|
127
|
+
const levels = /* @__PURE__ */ __name(() => options.resolveSettings(flags, { env: context.env }).permissions, "levels");
|
|
128
|
+
const readOnly = /* @__PURE__ */ __name(() => readOnlyLockOf(app, context.env) !== void 0, "readOnly");
|
|
129
|
+
const authority = changesAuthorityAt(root);
|
|
130
|
+
const fetches = fetchesOnlyAt(root);
|
|
131
|
+
const targets = judgedTargets(root);
|
|
132
|
+
const passed = Object.fromEntries(Object.entries(environment).filter(([key]) => !PER_RUN.has(key)));
|
|
133
|
+
const tools = toolsFromCommands(program.commands, {
|
|
134
|
+
includeUnavailable: true,
|
|
135
|
+
exclude: EXCLUDED,
|
|
136
|
+
levels: settings.permissions,
|
|
137
|
+
currentLevels: levels,
|
|
138
|
+
readOnly: readOnly(),
|
|
139
|
+
authority,
|
|
140
|
+
fetchOnly: readsOverMcpAt(root),
|
|
141
|
+
fetches,
|
|
142
|
+
permissions: options.permissions
|
|
143
|
+
});
|
|
144
|
+
const availability = /* @__PURE__ */ __name((one) => () => {
|
|
145
|
+
const permitted = one.availability?.() ?? { available: true };
|
|
146
|
+
if (!permitted.available)
|
|
147
|
+
return permitted;
|
|
148
|
+
return options.availability?.(one.path, settings.profile) ?? permitted;
|
|
149
|
+
}, "availability");
|
|
150
|
+
const commands = Object.fromEntries(tools.map((one) => [
|
|
151
|
+
one.command,
|
|
152
|
+
{
|
|
153
|
+
title: one.title,
|
|
154
|
+
description: one.description,
|
|
155
|
+
...one.keywords ? { keywords: one.keywords } : {},
|
|
156
|
+
...aliasesOf(root, one.path),
|
|
157
|
+
writes: one.writes,
|
|
158
|
+
availability: availability(one),
|
|
159
|
+
input: one.input,
|
|
160
|
+
run: /* @__PURE__ */ __name(async (input, ctx) => {
|
|
161
|
+
const own = options.availability?.(one.path, settings.profile);
|
|
162
|
+
if (own && !own.available)
|
|
163
|
+
return failed(new CliError("permission_error", `${one.command}: ${own.reason ?? "unavailable for this profile"}`, {
|
|
164
|
+
...own.permission ? { permission: own.permission } : {}
|
|
165
|
+
}), app.errors);
|
|
166
|
+
const traceparent = ctx?.mcpReq?._meta?.traceparent;
|
|
167
|
+
const env = typeof traceparent === "string" ? { ...context.env, TRACEPARENT: traceparent } : context.env;
|
|
168
|
+
const answer = await runCommandForAgent(program, one.path, input, {
|
|
169
|
+
profile: settings.profile,
|
|
170
|
+
readOnly: readOnly(),
|
|
171
|
+
env,
|
|
172
|
+
levels,
|
|
173
|
+
overrides,
|
|
174
|
+
authority,
|
|
175
|
+
fetches,
|
|
176
|
+
permissions: options.permissions,
|
|
177
|
+
environment: passed
|
|
178
|
+
});
|
|
179
|
+
if ("error" in answer)
|
|
180
|
+
return mcpErrorResult(JSON.parse(agentJson(answer.error)));
|
|
181
|
+
try {
|
|
182
|
+
return answered(envelope(one.command, answer.result), DEFAULT_OUTPUT_BYTES, targets);
|
|
183
|
+
} catch (error) {
|
|
184
|
+
return failed(error, app.errors);
|
|
185
|
+
}
|
|
186
|
+
}, "run")
|
|
187
|
+
}
|
|
188
|
+
]));
|
|
189
|
+
const skills = options.skill ? skillResources(app, options.skill) : [];
|
|
190
|
+
const skill = skills[0];
|
|
191
|
+
const build = /* @__PURE__ */ __name(() => {
|
|
192
|
+
const server = new McpServer({ name: app.command, version: app.version }, {
|
|
193
|
+
instructions: appInstructions({
|
|
194
|
+
command: app.command,
|
|
195
|
+
name: options.name,
|
|
196
|
+
profile: settings.profile,
|
|
197
|
+
untrusted: options.untrusted,
|
|
198
|
+
...skill ? { skill: skill.instruction } : {}
|
|
199
|
+
})
|
|
200
|
+
});
|
|
201
|
+
registerCommands(server, app.command, commands, app.errors, void 0, app.messenger);
|
|
202
|
+
for (const { uri, name, title, description, mimeType, read } of skills)
|
|
203
|
+
server.registerResource(name, uri, { title, description, mimeType }, read);
|
|
204
|
+
return server;
|
|
205
|
+
}, "build");
|
|
206
|
+
return { build, offered: Object.keys(commands) };
|
|
207
|
+
}, "createAppServer");
|
|
208
|
+
var serveAppOverStdio = /* @__PURE__ */ __name(async (command, context, options) => {
|
|
209
|
+
const { build } = createAppServer(command, context, options);
|
|
210
|
+
const { stdin, stdout, signal } = environmentOf(command);
|
|
211
|
+
const own = stdin && stdout && stdin !== process.stdin;
|
|
212
|
+
const wire = answeredWire(own ? stdin : process.stdin, own ? stdout : process.stdout);
|
|
213
|
+
const handle = serveStdio(build, {
|
|
214
|
+
transport: new StdioServerTransport(wire.input, wire.output),
|
|
215
|
+
onerror: /* @__PURE__ */ __name((error) => context.renderer.note(`mcp: ${error.message}`), "onerror")
|
|
216
|
+
});
|
|
217
|
+
await wire.finished(own ? signal : void 0);
|
|
218
|
+
wire.release();
|
|
219
|
+
await handle.close();
|
|
220
|
+
}, "serveAppOverStdio");
|
|
221
|
+
var serveAppOverHttp = /* @__PURE__ */ __name(async (command, context, options, http) => {
|
|
222
|
+
const { app } = options;
|
|
223
|
+
const { build } = createAppServer(command, context, options);
|
|
224
|
+
const { serveOverHttp } = await import("./serve-AHG25QXB.js");
|
|
225
|
+
const listening = await serveOverHttp(build, {
|
|
226
|
+
...http,
|
|
227
|
+
appName: app.command,
|
|
228
|
+
reaches: `your ${options.name}`,
|
|
229
|
+
onCode: /* @__PURE__ */ __name((code, expires) => context.renderer.note(context.env[mcpHttpMarker(app.envPrefix)] === void 0 ? `login code for a new browser app: ${code} (until ${expires.toTimeString().slice(0, 5)}; a new one after each login)` : `a new login code for a browser app: \`${app.command} ${context.settings.profile} mcp server status\``), "onCode"),
|
|
230
|
+
onError: /* @__PURE__ */ __name((error) => context.renderer.note(`mcp: ${error.message}`), "onError")
|
|
231
|
+
}).catch((error) => {
|
|
232
|
+
if (error.code === "EADDRINUSE")
|
|
233
|
+
throw new CliError("configuration_error", `port ${http.port} is in use \u2014 pass another with --port`);
|
|
234
|
+
throw error;
|
|
235
|
+
});
|
|
236
|
+
context.renderer.note(`serving on ${listening.url.href} \u2014 point your tunnel at it; connectors use ${mcpUrlOf(http.publicUrl).href}`);
|
|
237
|
+
await new Promise((resolve) => {
|
|
238
|
+
process.once("SIGINT", resolve);
|
|
239
|
+
process.once("SIGTERM", resolve);
|
|
240
|
+
});
|
|
241
|
+
await listening.close();
|
|
242
|
+
}, "serveAppOverHttp");
|
|
243
|
+
export {
|
|
244
|
+
createAppServer,
|
|
245
|
+
serveAppOverHttp,
|
|
246
|
+
serveAppOverStdio
|
|
247
|
+
};
|