@wirecat/amo-cli 0.6.0 → 0.7.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 +17 -0
- package/README.md +2 -2
- package/contracts/wirecat.json +14 -0
- package/dist/amo/button.js +1 -1
- package/dist/amo/json.js +1 -1
- package/dist/amo/oauth.js +1 -2
- package/dist/amo/transport.js +1 -2
- package/dist/api-keys.js +1 -1
- package/dist/bin/amo.js +11 -11
- package/dist/bundle/amo.js +5 -183
- package/dist/bundle/{chunk-FYOPPKAN.js → chunk-3HWD4BKU.js} +4 -6
- package/dist/bundle/{chunk-GOCMJBEE.js → chunk-4EXURQQQ.js} +21 -19
- package/dist/bundle/chunk-AEWYRB6F.js +8 -0
- package/dist/bundle/{chunk-SWCJM3YD.js → chunk-GL7CRTHR.js} +3 -3
- package/dist/bundle/chunk-N2UB32VN.js +76 -0
- package/dist/bundle/{chunk-RNWUCAJJ.js → chunk-PVVSHDMQ.js} +7 -15
- package/dist/bundle/program-SQH3SPOW.js +2352 -0
- package/dist/bundle/{instructions-4H7UREH2.js → source-C65ZJUTW.js} +5 -6
- package/dist/bundle/store-SJ2TOUGU.js +12 -0
- package/dist/bundle/writer-I7GBI3VE.js +12 -0
- package/dist/commands/account.js +1 -1
- package/dist/commands/api.js +1 -3
- package/dist/commands/crm-shared.js +2 -3
- package/dist/commands/schedule.js +1 -1
- package/dist/commands/session.js +1 -3
- package/dist/commands/write.js +1 -2
- package/dist/config.js +1 -2
- package/dist/context.js +1 -2
- package/dist/crm/activities.js +1 -1
- package/dist/crm/records.js +1 -1
- package/dist/crm/source.js +1 -1
- package/dist/crm/writer.js +1 -1
- package/dist/identity.js +4 -0
- package/dist/program.js +1 -2
- package/dist/setup/flow.js +1 -1
- package/dist/store.js +1 -1
- package/dist/version.js +1 -1
- package/dist/whoami.js +1 -1
- package/package.json +3 -3
- package/scenarios/first-sync.md +13 -11
- package/scenarios/keep-in-sync.md +7 -6
- package/scenarios/safe-agent-writes.md +10 -9
- package/dist/amo/account.d.ts +0 -18
- package/dist/amo/account.d.ts.map +0 -1
- package/dist/amo/account.js.map +0 -1
- package/dist/amo/allow-list.d.ts +0 -31
- package/dist/amo/allow-list.d.ts.map +0 -1
- package/dist/amo/allow-list.js.map +0 -1
- package/dist/amo/button.d.ts +0 -53
- package/dist/amo/button.d.ts.map +0 -1
- package/dist/amo/button.js.map +0 -1
- package/dist/amo/errors.d.ts +0 -12
- package/dist/amo/errors.d.ts.map +0 -1
- package/dist/amo/errors.js.map +0 -1
- package/dist/amo/json.d.ts +0 -3
- package/dist/amo/json.d.ts.map +0 -1
- package/dist/amo/json.js.map +0 -1
- package/dist/amo/oauth.d.ts +0 -64
- package/dist/amo/oauth.d.ts.map +0 -1
- package/dist/amo/oauth.js.map +0 -1
- package/dist/amo/operation.d.ts +0 -45
- package/dist/amo/operation.d.ts.map +0 -1
- package/dist/amo/operation.js.map +0 -1
- package/dist/amo/operations.d.ts +0 -3
- package/dist/amo/operations.d.ts.map +0 -1
- package/dist/amo/operations.js.map +0 -1
- package/dist/amo/routes.d.ts +0 -67
- package/dist/amo/routes.d.ts.map +0 -1
- package/dist/amo/routes.js.map +0 -1
- package/dist/amo/transport.d.ts +0 -62
- package/dist/amo/transport.d.ts.map +0 -1
- package/dist/amo/transport.js.map +0 -1
- package/dist/api-keys.d.ts +0 -47
- package/dist/api-keys.d.ts.map +0 -1
- package/dist/api-keys.js.map +0 -1
- package/dist/bin/amo.d.ts +0 -3
- package/dist/bin/amo.d.ts.map +0 -1
- package/dist/bin/amo.js.map +0 -1
- package/dist/bundle/agent-VVACEKSX.js +0 -42
- package/dist/bundle/all-profiles-QNUKL4NA.js +0 -320
- package/dist/bundle/anthropic-PQN6MNP7.js +0 -90
- package/dist/bundle/app-server-Q2QEA7GP.js +0 -258
- package/dist/bundle/areas-27FRPBF3.js +0 -71
- package/dist/bundle/bun-F4M4KCNA.js +0 -169
- package/dist/bundle/bun-sqlite-P5IDBDVR.js +0 -75
- package/dist/bundle/chunk-22KAQPX7.js +0 -58
- package/dist/bundle/chunk-2JGNMZ55.js +0 -338
- package/dist/bundle/chunk-2VDHC7QO.js +0 -288
- package/dist/bundle/chunk-34ZOMVUK.js +0 -185
- package/dist/bundle/chunk-3J3EDSXF.js +0 -1939
- package/dist/bundle/chunk-3TYER5IK.js +0 -80
- package/dist/bundle/chunk-5NGLCDYQ.js +0 -106
- package/dist/bundle/chunk-5SQTHOBI.js +0 -12313
- package/dist/bundle/chunk-6GE36KUE.js +0 -360
- package/dist/bundle/chunk-6GZKY3HV.js +0 -3752
- package/dist/bundle/chunk-6OV2TRGF.js +0 -362
- package/dist/bundle/chunk-7CPIZFOE.js +0 -460
- package/dist/bundle/chunk-A5K2NU3K.js +0 -37780
- package/dist/bundle/chunk-ADLS6FVG.js +0 -24600
- package/dist/bundle/chunk-AEC4H5WZ.js +0 -259
- package/dist/bundle/chunk-APBEDWOE.js +0 -1718
- package/dist/bundle/chunk-AQ5RIOUE.js +0 -633
- package/dist/bundle/chunk-B7L5MSRP.js +0 -136
- package/dist/bundle/chunk-C7JPYWYQ.js +0 -77
- package/dist/bundle/chunk-D72URWJE.js +0 -532
- package/dist/bundle/chunk-DFDN6AUB.js +0 -21
- package/dist/bundle/chunk-DIZEHPS6.js +0 -1347
- package/dist/bundle/chunk-DNCLQPOM.js +0 -7
- package/dist/bundle/chunk-DPV53EZC.js +0 -206
- package/dist/bundle/chunk-DUPCDJ3W.js +0 -357
- package/dist/bundle/chunk-DWT24UVR.js +0 -388
- package/dist/bundle/chunk-DXWJORSY.js +0 -1703
- package/dist/bundle/chunk-DY3PLWIH.js +0 -332
- package/dist/bundle/chunk-DYWHAJRK.js +0 -1259
- package/dist/bundle/chunk-EH6ZEJGT.js +0 -932
- package/dist/bundle/chunk-EXRM3ML4.js +0 -76
- package/dist/bundle/chunk-FFER7KJI.js +0 -407
- package/dist/bundle/chunk-FIP2DG7W.js +0 -64
- package/dist/bundle/chunk-FTH6WGYO.js +0 -24
- package/dist/bundle/chunk-FWRLGIF6.js +0 -5304
- package/dist/bundle/chunk-G3N2RHGF.js +0 -738
- package/dist/bundle/chunk-G46PNDWL.js +0 -58
- package/dist/bundle/chunk-G6NY7LFB.js +0 -230
- package/dist/bundle/chunk-GRGCZSES.js +0 -1007
- package/dist/bundle/chunk-GVSKLZRD.js +0 -30
- package/dist/bundle/chunk-GZ7WBU5Y.js +0 -18
- package/dist/bundle/chunk-HN2LCLGT.js +0 -1068
- package/dist/bundle/chunk-HO4JGD4Q.js +0 -16
- package/dist/bundle/chunk-HOF7GQWW.js +0 -142
- package/dist/bundle/chunk-HUAHLO6N.js +0 -29
- package/dist/bundle/chunk-IDCZ4LWS.js +0 -150
- package/dist/bundle/chunk-IN3VL7UU.js +0 -560
- package/dist/bundle/chunk-ISQ23VKV.js +0 -123
- package/dist/bundle/chunk-JVBCQHCS.js +0 -80
- package/dist/bundle/chunk-K5W7YEHB.js +0 -9541
- package/dist/bundle/chunk-KAFSS35C.js +0 -193
- package/dist/bundle/chunk-KLRCTMES.js +0 -100
- package/dist/bundle/chunk-KYRYD4CR.js +0 -38
- package/dist/bundle/chunk-LBZSURLL.js +0 -798
- package/dist/bundle/chunk-LC7ZD2RW.js +0 -92
- package/dist/bundle/chunk-LH6FJYMO.js +0 -334
- package/dist/bundle/chunk-LJKINNWC.js +0 -209
- package/dist/bundle/chunk-M36XP74N.js +0 -86
- package/dist/bundle/chunk-MNPGZCKE.js +0 -361
- package/dist/bundle/chunk-MRPMORLH.js +0 -353
- package/dist/bundle/chunk-NNREILWP.js +0 -189
- package/dist/bundle/chunk-NSOY4FMN.js +0 -159
- package/dist/bundle/chunk-OEEWVKJX.js +0 -53
- package/dist/bundle/chunk-OGJFDKDL.js +0 -161
- package/dist/bundle/chunk-PATZAYFZ.js +0 -453
- package/dist/bundle/chunk-PCR6GFNP.js +0 -1171
- package/dist/bundle/chunk-PL5P7UKW.js +0 -25216
- package/dist/bundle/chunk-Q4MH2O5E.js +0 -108
- package/dist/bundle/chunk-QFOP3KUP.js +0 -2603
- package/dist/bundle/chunk-QQRJEWKB.js +0 -1197
- package/dist/bundle/chunk-S6JG4YUH.js +0 -72
- package/dist/bundle/chunk-SDVUGWD7.js +0 -614
- package/dist/bundle/chunk-SEFE6PGL.js +0 -218
- package/dist/bundle/chunk-SYRDEMQE.js +0 -68141
- package/dist/bundle/chunk-SYYQZDHJ.js +0 -95
- package/dist/bundle/chunk-T3W4V4A6.js +0 -63
- package/dist/bundle/chunk-TCT5D2X2.js +0 -6848
- package/dist/bundle/chunk-TES7MB6I.js +0 -82
- package/dist/bundle/chunk-TXDR6YSF.js +0 -23
- package/dist/bundle/chunk-TY7NDMFY.js +0 -46
- package/dist/bundle/chunk-U6XPWCWM.js +0 -133
- package/dist/bundle/chunk-UFKC7TIX.js +0 -28404
- package/dist/bundle/chunk-UNWF3TH5.js +0 -274
- package/dist/bundle/chunk-W3BOR6AT.js +0 -2333
- package/dist/bundle/chunk-WIHN3ELW.js +0 -2793
- package/dist/bundle/chunk-X76RS6JO.js +0 -1043
- package/dist/bundle/chunk-Y5E2WNWB.js +0 -35
- package/dist/bundle/chunk-YF3S26TS.js +0 -4172
- package/dist/bundle/chunk-ZCQ4H7CA.js +0 -54
- package/dist/bundle/chunk-ZOZV32IR.js +0 -170
- package/dist/bundle/chunk-ZTKHXDEU.js +0 -52
- package/dist/bundle/chunk-ZVVMGPBJ.js +0 -50
- package/dist/bundle/cli-EAD3WZLR.js +0 -1254
- package/dist/bundle/command-contract-SMEJ2ICG.js +0 -40
- package/dist/bundle/command-server-entry-YTZP6I4T.js +0 -169
- package/dist/bundle/decode-57BE5OBT.js +0 -296
- package/dist/bundle/dispatch-56FECRCU.js +0 -411
- package/dist/bundle/dist-PAKDDIBT.js +0 -191
- package/dist/bundle/dist-T54K3FJV.js +0 -7577
- package/dist/bundle/echarts-QMAA7HH5.js +0 -42501
- package/dist/bundle/embed-NFGFYUO4.js +0 -37
- package/dist/bundle/embedder-SRBOJMXX.js +0 -110
- package/dist/bundle/failure-WDSX6H3B.js +0 -24
- package/dist/bundle/first-run-HWRUL2GR.js +0 -28
- package/dist/bundle/first-screen-ATN4D3FQ.js +0 -41
- package/dist/bundle/mcp-5HFPWC3W.js +0 -167
- package/dist/bundle/meeting-combined-BGDEHCWY.js +0 -26
- package/dist/bundle/meeting-model-WWGVRXPL.js +0 -24
- package/dist/bundle/meeting-semantic-ZQ47BL2Z.js +0 -21
- package/dist/bundle/node-P3PUHKYH.js +0 -176
- package/dist/bundle/node-P4E63KXA.js +0 -2340
- package/dist/bundle/node-TLZSIHIJ.js +0 -21
- package/dist/bundle/node-sqlite-JOTSNH3P.js +0 -73
- package/dist/bundle/oauth-XPSAL6VO.js +0 -19
- package/dist/bundle/open-PO52FVA5.js +0 -22
- package/dist/bundle/openai-WITYLMY5.js +0 -237
- package/dist/bundle/process-AFIXYXWL.js +0 -91
- package/dist/bundle/program-JODTZNBZ.js +0 -4920
- package/dist/bundle/prompt-XORLAXHY.js +0 -16
- package/dist/bundle/recognize-JKMZHDYS.js +0 -25
- package/dist/bundle/remote-3IMEJTEH.js +0 -30
- package/dist/bundle/rerank-3F2E6NNN.js +0 -51
- package/dist/bundle/serve-6BWU3NMB.js +0 -198
- package/dist/bundle/server-GPSB5WFG.js +0 -220
- package/dist/bundle/server-HMCC64ZU.js +0 -88
- package/dist/bundle/source-E72OS27D.js +0 -47
- package/dist/bundle/sqlite-runtime-YHYQDUXE.js +0 -19
- package/dist/bundle/state-R7W4U6T4.js +0 -35
- package/dist/bundle/store-HTVRL7FB.js +0 -312
- package/dist/bundle/store-IWW6U6QN.js +0 -34
- package/dist/bundle/store-TBZ3ZS6H.js +0 -186
- package/dist/bundle/store-maintenance-command-CJM2VLMW.js +0 -75
- package/dist/bundle/surface-5GBWNYBE.js +0 -74
- package/dist/bundle/writer-TW2Q55VJ.js +0 -49
- package/dist/commands/account.d.ts +0 -4
- package/dist/commands/account.d.ts.map +0 -1
- package/dist/commands/account.js.map +0 -1
- package/dist/commands/api.d.ts +0 -3
- package/dist/commands/api.d.ts.map +0 -1
- package/dist/commands/api.js.map +0 -1
- package/dist/commands/crm-shared.d.ts +0 -8
- package/dist/commands/crm-shared.d.ts.map +0 -1
- package/dist/commands/crm-shared.js.map +0 -1
- package/dist/commands/schedule.d.ts +0 -3
- package/dist/commands/schedule.d.ts.map +0 -1
- package/dist/commands/schedule.js.map +0 -1
- package/dist/commands/session.d.ts +0 -35
- package/dist/commands/session.d.ts.map +0 -1
- package/dist/commands/session.js.map +0 -1
- package/dist/commands/write.d.ts +0 -14
- package/dist/commands/write.d.ts.map +0 -1
- package/dist/commands/write.js.map +0 -1
- package/dist/config.d.ts +0 -4
- package/dist/config.d.ts.map +0 -1
- package/dist/config.js.map +0 -1
- package/dist/context.d.ts +0 -62
- package/dist/context.d.ts.map +0 -1
- package/dist/context.js.map +0 -1
- package/dist/crm/activities.d.ts +0 -32
- package/dist/crm/activities.d.ts.map +0 -1
- package/dist/crm/activities.js.map +0 -1
- package/dist/crm/records.d.ts +0 -20
- package/dist/crm/records.d.ts.map +0 -1
- package/dist/crm/records.js.map +0 -1
- package/dist/crm/source.d.ts +0 -41
- package/dist/crm/source.d.ts.map +0 -1
- package/dist/crm/source.js.map +0 -1
- package/dist/crm/writer.d.ts +0 -14
- package/dist/crm/writer.d.ts.map +0 -1
- package/dist/crm/writer.js.map +0 -1
- package/dist/identity.d.ts +0 -7
- package/dist/identity.d.ts.map +0 -1
- package/dist/identity.js.map +0 -1
- package/dist/index.d.ts +0 -3
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/program.d.ts +0 -6
- package/dist/program.d.ts.map +0 -1
- package/dist/program.js.map +0 -1
- package/dist/reasons.d.ts +0 -10
- package/dist/reasons.d.ts.map +0 -1
- package/dist/reasons.js.map +0 -1
- package/dist/setup/flow.d.ts +0 -2
- package/dist/setup/flow.d.ts.map +0 -1
- package/dist/setup/flow.js.map +0 -1
- package/dist/store.d.ts +0 -15
- package/dist/store.d.ts.map +0 -1
- package/dist/store.js.map +0 -1
- package/dist/version.d.ts +0 -2
- package/dist/version.d.ts.map +0 -1
- package/dist/version.js.map +0 -1
- package/dist/wcat.d.ts +0 -3
- package/dist/wcat.d.ts.map +0 -1
- package/dist/wcat.js.map +0 -1
- package/dist/whoami.d.ts +0 -24
- package/dist/whoami.d.ts.map +0 -1
- package/dist/whoami.js.map +0 -1
|
@@ -1,320 +0,0 @@
|
|
|
1
|
-
import { createRequire as __bundleRequire } from "node:module";
|
|
2
|
-
const require = __bundleRequire(import.meta.url);
|
|
3
|
-
import {
|
|
4
|
-
StdioServerTransport,
|
|
5
|
-
answeredWire,
|
|
6
|
-
serveStdio
|
|
7
|
-
} from "./chunk-AQ5RIOUE.js";
|
|
8
|
-
import {
|
|
9
|
-
CALLER_META_KEY,
|
|
10
|
-
PROXY_CLIENT_NAME,
|
|
11
|
-
callerOf
|
|
12
|
-
} from "./chunk-Q4MH2O5E.js";
|
|
13
|
-
import {
|
|
14
|
-
InMemoryTransport,
|
|
15
|
-
McpServer
|
|
16
|
-
} from "./chunk-PL5P7UKW.js";
|
|
17
|
-
import "./chunk-6OV2TRGF.js";
|
|
18
|
-
import "./chunk-3TYER5IK.js";
|
|
19
|
-
import "./chunk-LC7ZD2RW.js";
|
|
20
|
-
import "./chunk-DNCLQPOM.js";
|
|
21
|
-
import "./chunk-WIHN3ELW.js";
|
|
22
|
-
import {
|
|
23
|
-
errorObjectOf,
|
|
24
|
-
mcpErrorResult
|
|
25
|
-
} from "./chunk-QFOP3KUP.js";
|
|
26
|
-
import "./chunk-Y5E2WNWB.js";
|
|
27
|
-
import {
|
|
28
|
-
CliError
|
|
29
|
-
} from "./chunk-S6JG4YUH.js";
|
|
30
|
-
import {
|
|
31
|
-
__name
|
|
32
|
-
} from "./chunk-ZVVMGPBJ.js";
|
|
33
|
-
|
|
34
|
-
// node_modules/.pnpm/@wirecat+cli-core@2.0.0_@wirecat+cli-base@1.0.0_commander@15.0.0_esbuild@0.28.2_typescr_a82f624c57005d53c3f072e45c3a3a86/node_modules/@wirecat/cli-core/dist/mcp/all-profiles.js
|
|
35
|
-
import { spawn } from "node:child_process";
|
|
36
|
-
import { randomUUID } from "node:crypto";
|
|
37
|
-
var PROTOCOL = "2025-06-18";
|
|
38
|
-
var START_MS = 3e4;
|
|
39
|
-
var CHILD_IDLE_MS = 10 * 60 * 1e3;
|
|
40
|
-
var startChild = /* @__PURE__ */ __name((spec, note, onExit) => {
|
|
41
|
-
const child = spawn(spec.command, spec.args, { env: spec.env, stdio: "pipe" });
|
|
42
|
-
const pending = /* @__PURE__ */ new Map();
|
|
43
|
-
let next = 1;
|
|
44
|
-
let buffer = "";
|
|
45
|
-
let gone;
|
|
46
|
-
const fail = /* @__PURE__ */ __name((error) => {
|
|
47
|
-
gone ??= error;
|
|
48
|
-
for (const waiter of pending.values())
|
|
49
|
-
waiter.reject(error);
|
|
50
|
-
pending.clear();
|
|
51
|
-
}, "fail");
|
|
52
|
-
child.on("error", () => fail(new Error("the profile's MCP server could not be started")));
|
|
53
|
-
child.on("exit", () => {
|
|
54
|
-
fail(new Error("the profile's MCP server stopped"));
|
|
55
|
-
onExit();
|
|
56
|
-
});
|
|
57
|
-
child.stdin.on("error", () => fail(new Error("the profile's MCP server closed its input")));
|
|
58
|
-
child.stderr.setEncoding("utf8");
|
|
59
|
-
let errors = "";
|
|
60
|
-
child.stderr.on("data", (chunk) => {
|
|
61
|
-
const lines = (errors + chunk).split("\n");
|
|
62
|
-
errors = lines.pop() ?? "";
|
|
63
|
-
for (const line of lines)
|
|
64
|
-
if (line.trim())
|
|
65
|
-
note(line);
|
|
66
|
-
});
|
|
67
|
-
child.stdout.setEncoding("utf8");
|
|
68
|
-
child.stdout.on("data", (chunk) => {
|
|
69
|
-
buffer += chunk;
|
|
70
|
-
for (let at = buffer.indexOf("\n"); at !== -1; at = buffer.indexOf("\n")) {
|
|
71
|
-
const line = buffer.slice(0, at);
|
|
72
|
-
buffer = buffer.slice(at + 1);
|
|
73
|
-
let message;
|
|
74
|
-
try {
|
|
75
|
-
message = JSON.parse(line);
|
|
76
|
-
} catch {
|
|
77
|
-
continue;
|
|
78
|
-
}
|
|
79
|
-
if (message.method !== void 0 && message.id !== void 0) {
|
|
80
|
-
send({ id: message.id, error: { code: -32601, message: "not offered through the all-profiles server" } });
|
|
81
|
-
continue;
|
|
82
|
-
}
|
|
83
|
-
if (typeof message.id !== "number")
|
|
84
|
-
continue;
|
|
85
|
-
const waiter = pending.get(message.id);
|
|
86
|
-
if (!waiter)
|
|
87
|
-
continue;
|
|
88
|
-
pending.delete(message.id);
|
|
89
|
-
if (message.error)
|
|
90
|
-
waiter.reject(new Error(message.error.message ?? "the profile's MCP server refused"));
|
|
91
|
-
else
|
|
92
|
-
waiter.resolve(message.result ?? {});
|
|
93
|
-
}
|
|
94
|
-
});
|
|
95
|
-
const send = /* @__PURE__ */ __name((message) => child.stdin.write(`${JSON.stringify({ jsonrpc: "2.0", ...message })}
|
|
96
|
-
`), "send");
|
|
97
|
-
const request = /* @__PURE__ */ __name((method, params) => new Promise((resolve, reject) => {
|
|
98
|
-
if (gone)
|
|
99
|
-
return reject(gone);
|
|
100
|
-
const id = next++;
|
|
101
|
-
pending.set(id, { resolve, reject });
|
|
102
|
-
send({ id, method, params });
|
|
103
|
-
}), "request");
|
|
104
|
-
const close = /* @__PURE__ */ __name(() => new Promise((resolve) => {
|
|
105
|
-
if (child.exitCode !== null || child.signalCode !== null)
|
|
106
|
-
return resolve();
|
|
107
|
-
child.once("exit", () => resolve());
|
|
108
|
-
child.stdin.end();
|
|
109
|
-
}), "close");
|
|
110
|
-
const timer = setTimeout(() => fail(new Error("the profile's MCP server did not answer in time")), START_MS);
|
|
111
|
-
return request("initialize", {
|
|
112
|
-
protocolVersion: PROTOCOL,
|
|
113
|
-
capabilities: {},
|
|
114
|
-
clientInfo: { name: PROXY_CLIENT_NAME, version: "1" }
|
|
115
|
-
}).then(() => {
|
|
116
|
-
send({ method: "notifications/initialized" });
|
|
117
|
-
return { request, close };
|
|
118
|
-
}).catch(async (error) => {
|
|
119
|
-
await close();
|
|
120
|
-
throw error;
|
|
121
|
-
}).finally(() => clearTimeout(timer));
|
|
122
|
-
}, "startChild");
|
|
123
|
-
var pool = /* @__PURE__ */ __name((options) => {
|
|
124
|
-
const idleMs = options.idleMs ?? CHILD_IDLE_MS;
|
|
125
|
-
const note = options.note ?? (() => {
|
|
126
|
-
});
|
|
127
|
-
const running = /* @__PURE__ */ new Map();
|
|
128
|
-
const forget = /* @__PURE__ */ __name((profile, child) => {
|
|
129
|
-
const one = running.get(profile);
|
|
130
|
-
if (one?.child !== child)
|
|
131
|
-
return;
|
|
132
|
-
clearTimeout(one.timer);
|
|
133
|
-
running.delete(profile);
|
|
134
|
-
}, "forget");
|
|
135
|
-
const use = /* @__PURE__ */ __name(async (profile, work) => {
|
|
136
|
-
let one = running.get(profile);
|
|
137
|
-
if (!one) {
|
|
138
|
-
const child = startChild(options.child(profile), (line) => note(`${profile}: ${line}`), () => forget(profile, child));
|
|
139
|
-
child.catch(() => forget(profile, child));
|
|
140
|
-
one = { child };
|
|
141
|
-
running.set(profile, one);
|
|
142
|
-
}
|
|
143
|
-
clearTimeout(one.timer);
|
|
144
|
-
const entry = one;
|
|
145
|
-
try {
|
|
146
|
-
return await work(await entry.child);
|
|
147
|
-
} finally {
|
|
148
|
-
if (running.get(profile) === entry) {
|
|
149
|
-
entry.timer = setTimeout(() => {
|
|
150
|
-
forget(profile, entry.child);
|
|
151
|
-
void entry.child.then((child) => child.close()).catch(() => void 0);
|
|
152
|
-
}, idleMs);
|
|
153
|
-
entry.timer.unref();
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
}, "use");
|
|
157
|
-
const close = /* @__PURE__ */ __name(async () => {
|
|
158
|
-
const all = [...running.values()];
|
|
159
|
-
running.clear();
|
|
160
|
-
for (const one of all)
|
|
161
|
-
clearTimeout(one.timer);
|
|
162
|
-
await Promise.all(all.map((one) => one.child.then((child) => child.close()).catch(() => void 0)));
|
|
163
|
-
}, "close");
|
|
164
|
-
return { use, close };
|
|
165
|
-
}, "pool");
|
|
166
|
-
var withProfile = /* @__PURE__ */ __name((tool, profiles, name, signedIn = () => true) => {
|
|
167
|
-
const schema = tool.inputSchema;
|
|
168
|
-
const out = profiles.filter((profile) => !signedIn(profile));
|
|
169
|
-
const states = out.length === 0 ? "" : ` Signed in: ${profiles.filter(signedIn).join(", ") || "none"} \xB7 Not signed in: ${out.join(", ")}.`;
|
|
170
|
-
return {
|
|
171
|
-
...tool,
|
|
172
|
-
inputSchema: {
|
|
173
|
-
...tool.inputSchema,
|
|
174
|
-
properties: {
|
|
175
|
-
profile: profiles.length === 0 ? (
|
|
176
|
-
// An empty enum matches nothing, and a directory that checks the schema refuses the tool.
|
|
177
|
-
{
|
|
178
|
-
type: "string",
|
|
179
|
-
description: `Which ${name} account, by its profile. None is set up on this computer yet.`
|
|
180
|
-
}
|
|
181
|
-
) : {
|
|
182
|
-
type: "string",
|
|
183
|
-
enum: [...profiles],
|
|
184
|
-
oneOf: profiles.map((one) => ({ const: one, title: signedIn(one) ? one : `${one} \u2014 not signed in` })),
|
|
185
|
-
description: `Which ${name} account, by its profile. If the owner did not name one, ask which \u2014 never guess.${states}`
|
|
186
|
-
},
|
|
187
|
-
...schema.properties
|
|
188
|
-
},
|
|
189
|
-
required: ["profile", ...(schema.required ?? []).filter((field) => field !== "profile")]
|
|
190
|
-
}
|
|
191
|
-
};
|
|
192
|
-
}, "withProfile");
|
|
193
|
-
var refusal = /* @__PURE__ */ __name((code, text, details) => mcpErrorResult(errorObjectOf(new CliError(code, text, details), { effects: { remote: "none", local: "none" } })), "refusal");
|
|
194
|
-
var allProfilesServer = /* @__PURE__ */ __name((options) => {
|
|
195
|
-
const children = pool(options);
|
|
196
|
-
let listed;
|
|
197
|
-
const tools = /* @__PURE__ */ __name((profiles) => {
|
|
198
|
-
listed ??= children.use(profiles.find(signedIn) ?? profiles[0], (child) => child.request("tools/list", {})).then((answer) => answer.tools ?? []);
|
|
199
|
-
listed.catch(() => {
|
|
200
|
-
listed = void 0;
|
|
201
|
-
});
|
|
202
|
-
return listed;
|
|
203
|
-
}, "tools");
|
|
204
|
-
const signedIn = /* @__PURE__ */ __name((profile) => options.signedIn?.(profile) ?? true, "signedIn");
|
|
205
|
-
const build = /* @__PURE__ */ __name(() => {
|
|
206
|
-
const profiles = [...options.profiles()].sort();
|
|
207
|
-
const server = new McpServer({ name: options.command, version: options.version }, {
|
|
208
|
-
capabilities: { tools: {} },
|
|
209
|
-
// Read per session, as the profiles are: clients cut the instructions short, so this line comes first.
|
|
210
|
-
instructions: profiles.length === 0 && options.setup ? `${options.setup.charAt(0).toUpperCase()}${options.setup.slice(1)}.
|
|
211
|
-
${options.instructions}` : options.instructions
|
|
212
|
-
});
|
|
213
|
-
server.server.setRequestHandler("tools/list", async () => ({
|
|
214
|
-
tools: (profiles.length === 0 ? await options.catalogue?.() ?? [] : await tools(profiles)).map((one) => withProfile(one, profiles, options.name, signedIn))
|
|
215
|
-
}));
|
|
216
|
-
const callers = {
|
|
217
|
-
env: options.env ?? process.env,
|
|
218
|
-
client: /* @__PURE__ */ __name(() => server.server.getClientVersion(), "client"),
|
|
219
|
-
connectionId: randomUUID()
|
|
220
|
-
};
|
|
221
|
-
server.server.setRequestHandler("tools/call", async (request, ctx) => {
|
|
222
|
-
const { name, arguments: given = {}, _meta } = request.params;
|
|
223
|
-
const { profile, ...rest } = given;
|
|
224
|
-
if (profiles.length === 0)
|
|
225
|
-
return refusal("configuration_error", options.setup ?? `no ${options.command} profile on this computer yet.`);
|
|
226
|
-
if (typeof profile !== "string" || !profiles.includes(profile))
|
|
227
|
-
return refusal("validation_error", `${name} needs "profile", one of: ${profiles.join(", ")}. If the owner did not say which account, ask.`);
|
|
228
|
-
if (!signedIn(profile))
|
|
229
|
-
return refusal("authentication_error", options.signIn?.(profile) ?? `profile ${profile} is not signed in.`);
|
|
230
|
-
try {
|
|
231
|
-
return await children.use(profile, (child) => (
|
|
232
|
-
// Children are shared by every session, so each call names its own caller.
|
|
233
|
-
child.request("tools/call", {
|
|
234
|
-
name,
|
|
235
|
-
arguments: rest,
|
|
236
|
-
_meta: { ..._meta, [CALLER_META_KEY]: callerOf(ctx, name, callers) }
|
|
237
|
-
})
|
|
238
|
-
));
|
|
239
|
-
} catch (error) {
|
|
240
|
-
return refusal("outcome_unknown", `profile ${profile}: ${error instanceof Error ? error.message : String(error)}`);
|
|
241
|
-
}
|
|
242
|
-
});
|
|
243
|
-
return server;
|
|
244
|
-
}, "build");
|
|
245
|
-
return { build, close: /* @__PURE__ */ __name(() => children.close(), "close") };
|
|
246
|
-
}, "allProfilesServer");
|
|
247
|
-
var listedTools = /* @__PURE__ */ __name(async (server) => {
|
|
248
|
-
const [own, other] = InMemoryTransport.createLinkedPair();
|
|
249
|
-
const answers = /* @__PURE__ */ new Map();
|
|
250
|
-
other.onmessage = (message) => {
|
|
251
|
-
const { id, result, error } = message;
|
|
252
|
-
if (typeof id === "number")
|
|
253
|
-
answers.get(id)?.(result, error);
|
|
254
|
-
};
|
|
255
|
-
const ask = /* @__PURE__ */ __name((id, method, params) => new Promise((resolve, reject) => {
|
|
256
|
-
answers.set(id, (result, error) => error || !result ? reject(new Error(error?.message ?? `${method} had no answer`)) : resolve(result));
|
|
257
|
-
void other.send({ jsonrpc: "2.0", id, method, params });
|
|
258
|
-
}), "ask");
|
|
259
|
-
await server.connect(own);
|
|
260
|
-
try {
|
|
261
|
-
await ask(1, "initialize", {
|
|
262
|
-
protocolVersion: PROTOCOL,
|
|
263
|
-
capabilities: {},
|
|
264
|
-
clientInfo: { name: PROXY_CLIENT_NAME, version: "1" }
|
|
265
|
-
});
|
|
266
|
-
await other.send({ jsonrpc: "2.0", method: "notifications/initialized" });
|
|
267
|
-
const answer = await ask(2, "tools/list", {});
|
|
268
|
-
if (!Array.isArray(answer.tools))
|
|
269
|
-
throw new Error("the catalogue server listed no tools");
|
|
270
|
-
return answer.tools;
|
|
271
|
-
} finally {
|
|
272
|
-
await server.close();
|
|
273
|
-
}
|
|
274
|
-
}, "listedTools");
|
|
275
|
-
var serveAllProfilesOverStdio = /* @__PURE__ */ __name(async (options, io = {}) => {
|
|
276
|
-
const { build, close } = allProfilesServer(options);
|
|
277
|
-
const own = io.stdin !== void 0 && io.stdin !== process.stdin;
|
|
278
|
-
const wire = answeredWire(io.stdin ?? process.stdin, io.stdout ?? process.stdout);
|
|
279
|
-
const handle = serveStdio(build, {
|
|
280
|
-
transport: new StdioServerTransport(wire.input, wire.output),
|
|
281
|
-
onerror: /* @__PURE__ */ __name((error) => options.note?.(`mcp: ${error.message}`), "onerror")
|
|
282
|
-
});
|
|
283
|
-
await wire.finished(own ? io.signal : void 0);
|
|
284
|
-
try {
|
|
285
|
-
wire.release();
|
|
286
|
-
await handle.close();
|
|
287
|
-
} finally {
|
|
288
|
-
await close();
|
|
289
|
-
}
|
|
290
|
-
}, "serveAllProfilesOverStdio");
|
|
291
|
-
var serveAllProfilesOverHttp = /* @__PURE__ */ __name(async (options, http) => {
|
|
292
|
-
const { build, close } = allProfilesServer(options);
|
|
293
|
-
const { serveOverHttp } = await import("./serve-6BWU3NMB.js");
|
|
294
|
-
const listening = await serveOverHttp(build, {
|
|
295
|
-
...http,
|
|
296
|
-
appName: options.command,
|
|
297
|
-
onError: /* @__PURE__ */ __name((error) => options.note?.(`mcp: ${error.message}`), "onError")
|
|
298
|
-
}).catch(async (error) => {
|
|
299
|
-
await close();
|
|
300
|
-
throw error;
|
|
301
|
-
});
|
|
302
|
-
return {
|
|
303
|
-
url: listening.url,
|
|
304
|
-
close: /* @__PURE__ */ __name(async () => {
|
|
305
|
-
try {
|
|
306
|
-
await listening.close();
|
|
307
|
-
} finally {
|
|
308
|
-
await close();
|
|
309
|
-
}
|
|
310
|
-
}, "close")
|
|
311
|
-
};
|
|
312
|
-
}, "serveAllProfilesOverHttp");
|
|
313
|
-
export {
|
|
314
|
-
CHILD_IDLE_MS,
|
|
315
|
-
allProfilesServer,
|
|
316
|
-
listedTools,
|
|
317
|
-
serveAllProfilesOverHttp,
|
|
318
|
-
serveAllProfilesOverStdio,
|
|
319
|
-
withProfile
|
|
320
|
-
};
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import { createRequire as __bundleRequire } from "node:module";
|
|
2
|
-
const require = __bundleRequire(import.meta.url);
|
|
3
|
-
import {
|
|
4
|
-
EmptyAnswer,
|
|
5
|
-
checkedOptions,
|
|
6
|
-
messagesFor,
|
|
7
|
-
systemFor
|
|
8
|
-
} from "./chunk-EXRM3ML4.js";
|
|
9
|
-
import {
|
|
10
|
-
Anthropic
|
|
11
|
-
} from "./chunk-ADLS6FVG.js";
|
|
12
|
-
import "./chunk-WIHN3ELW.js";
|
|
13
|
-
import {
|
|
14
|
-
array,
|
|
15
|
-
literal,
|
|
16
|
-
optional,
|
|
17
|
-
picklist,
|
|
18
|
-
record,
|
|
19
|
-
strictObject,
|
|
20
|
-
string,
|
|
21
|
-
unknown
|
|
22
|
-
} from "./chunk-QFOP3KUP.js";
|
|
23
|
-
import "./chunk-Y5E2WNWB.js";
|
|
24
|
-
import "./chunk-S6JG4YUH.js";
|
|
25
|
-
import {
|
|
26
|
-
__name
|
|
27
|
-
} from "./chunk-ZVVMGPBJ.js";
|
|
28
|
-
|
|
29
|
-
// node_modules/.pnpm/@wirecat+cli-core@2.0.0_@wirecat+cli-base@1.0.0_commander@15.0.0_esbuild@0.28.2_typescr_a82f624c57005d53c3f072e45c3a3a86/node_modules/@wirecat/cli-core/dist/models/anthropic.js
|
|
30
|
-
var options = strictObject({
|
|
31
|
-
stop_sequences: optional(array(string())),
|
|
32
|
-
thinking: optional(strictObject({ type: picklist(["disabled", "adaptive"]) })),
|
|
33
|
-
output_config: optional(strictObject({
|
|
34
|
-
effort: optional(picklist(["low", "medium", "high"])),
|
|
35
|
-
format: optional(strictObject({ type: literal("json_schema"), schema: record(string(), unknown()) }))
|
|
36
|
-
}))
|
|
37
|
-
});
|
|
38
|
-
var anthropic = {
|
|
39
|
-
images: true,
|
|
40
|
-
baseUrl: "https://api.anthropic.com",
|
|
41
|
-
validate: /* @__PURE__ */ __name((given) => checkedOptions("anthropic", options, given), "validate"),
|
|
42
|
-
complete: /* @__PURE__ */ __name(async (target, request, checked, apiKey, fetcher) => {
|
|
43
|
-
const client = new Anthropic({
|
|
44
|
-
apiKey: apiKey ?? "",
|
|
45
|
-
authToken: null,
|
|
46
|
-
fetch: /* @__PURE__ */ __name((input, init) => fetcher(input, { ...init, redirect: "error" }), "fetch"),
|
|
47
|
-
baseURL: target.baseUrl,
|
|
48
|
-
maxRetries: 0,
|
|
49
|
-
logLevel: "off",
|
|
50
|
-
timeout: 12e4
|
|
51
|
-
});
|
|
52
|
-
const response = await client.messages.stream({
|
|
53
|
-
...checked,
|
|
54
|
-
model: target.model,
|
|
55
|
-
system: systemFor(request),
|
|
56
|
-
messages: [
|
|
57
|
-
...messagesFor(request),
|
|
58
|
-
...request.images === void 0 ? [] : [
|
|
59
|
-
{
|
|
60
|
-
role: "user",
|
|
61
|
-
content: [
|
|
62
|
-
{ type: "text", text: request.prompt },
|
|
63
|
-
...request.images.map((image) => ({
|
|
64
|
-
type: "image",
|
|
65
|
-
source: { type: "base64", media_type: image.mimeType, data: image.data }
|
|
66
|
-
}))
|
|
67
|
-
]
|
|
68
|
-
}
|
|
69
|
-
]
|
|
70
|
-
],
|
|
71
|
-
max_tokens: request.maxTokens
|
|
72
|
-
}).finalMessage();
|
|
73
|
-
if (response.stop_reason !== "end_turn")
|
|
74
|
-
throw new Error("incomplete response");
|
|
75
|
-
const text = response.content.filter((block) => block.type === "text").map((block) => block.text).join("");
|
|
76
|
-
if (text.trim() === "")
|
|
77
|
-
throw new EmptyAnswer();
|
|
78
|
-
return {
|
|
79
|
-
text,
|
|
80
|
-
usage: {
|
|
81
|
-
input: response.usage.input_tokens + (response.usage.cache_creation_input_tokens ?? 0) + (response.usage.cache_read_input_tokens ?? 0),
|
|
82
|
-
output: response.usage.output_tokens
|
|
83
|
-
},
|
|
84
|
-
tokens: response.usage.input_tokens + response.usage.output_tokens + (response.usage.cache_creation_input_tokens ?? 0) + (response.usage.cache_read_input_tokens ?? 0)
|
|
85
|
-
};
|
|
86
|
-
}, "complete")
|
|
87
|
-
};
|
|
88
|
-
export {
|
|
89
|
-
anthropic
|
|
90
|
-
};
|
|
@@ -1,258 +0,0 @@
|
|
|
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-LBZSURLL.js";
|
|
7
|
-
import {
|
|
8
|
-
mcpUrlOf
|
|
9
|
-
} from "./chunk-DIZEHPS6.js";
|
|
10
|
-
import {
|
|
11
|
-
skillResources
|
|
12
|
-
} from "./chunk-DWT24UVR.js";
|
|
13
|
-
import {
|
|
14
|
-
StdioServerTransport,
|
|
15
|
-
answeredWire,
|
|
16
|
-
serveStdio
|
|
17
|
-
} from "./chunk-AQ5RIOUE.js";
|
|
18
|
-
import "./chunk-GZ7WBU5Y.js";
|
|
19
|
-
import "./chunk-DYWHAJRK.js";
|
|
20
|
-
import "./chunk-MRPMORLH.js";
|
|
21
|
-
import {
|
|
22
|
-
runCommandForAgent,
|
|
23
|
-
toolsFromCommands
|
|
24
|
-
} from "./chunk-6GZKY3HV.js";
|
|
25
|
-
import "./chunk-ZTKHXDEU.js";
|
|
26
|
-
import "./chunk-2JGNMZ55.js";
|
|
27
|
-
import {
|
|
28
|
-
appInstructions
|
|
29
|
-
} from "./chunk-OEEWVKJX.js";
|
|
30
|
-
import {
|
|
31
|
-
answered,
|
|
32
|
-
failed,
|
|
33
|
-
registerCommands
|
|
34
|
-
} from "./chunk-IN3VL7UU.js";
|
|
35
|
-
import {
|
|
36
|
-
agentJson
|
|
37
|
-
} from "./chunk-LJKINNWC.js";
|
|
38
|
-
import "./chunk-A5K2NU3K.js";
|
|
39
|
-
import "./chunk-FFER7KJI.js";
|
|
40
|
-
import "./chunk-FWRLGIF6.js";
|
|
41
|
-
import "./chunk-ISQ23VKV.js";
|
|
42
|
-
import "./chunk-HOF7GQWW.js";
|
|
43
|
-
import "./chunk-TY7NDMFY.js";
|
|
44
|
-
import "./chunk-Q4MH2O5E.js";
|
|
45
|
-
import "./chunk-GVSKLZRD.js";
|
|
46
|
-
import "./chunk-G3N2RHGF.js";
|
|
47
|
-
import "./chunk-HUAHLO6N.js";
|
|
48
|
-
import {
|
|
49
|
-
McpServer
|
|
50
|
-
} from "./chunk-PL5P7UKW.js";
|
|
51
|
-
import "./chunk-EXRM3ML4.js";
|
|
52
|
-
import "./chunk-AEC4H5WZ.js";
|
|
53
|
-
import "./chunk-6GE36KUE.js";
|
|
54
|
-
import "./chunk-ZOZV32IR.js";
|
|
55
|
-
import {
|
|
56
|
-
mcpHttpMarker
|
|
57
|
-
} from "./chunk-OGJFDKDL.js";
|
|
58
|
-
import "./chunk-M36XP74N.js";
|
|
59
|
-
import "./chunk-U6XPWCWM.js";
|
|
60
|
-
import {
|
|
61
|
-
DEFAULT_OUTPUT_BYTES,
|
|
62
|
-
changesAuthorityAt,
|
|
63
|
-
describeProgram,
|
|
64
|
-
environmentOf,
|
|
65
|
-
fetchesOnlyAt,
|
|
66
|
-
judgedTargets,
|
|
67
|
-
readOnlyLockOf,
|
|
68
|
-
readsOverMcpAt,
|
|
69
|
-
rootOf2 as rootOf
|
|
70
|
-
} from "./chunk-5SQTHOBI.js";
|
|
71
|
-
import "./chunk-6OV2TRGF.js";
|
|
72
|
-
import "./chunk-22KAQPX7.js";
|
|
73
|
-
import "./chunk-LH6FJYMO.js";
|
|
74
|
-
import "./chunk-T3W4V4A6.js";
|
|
75
|
-
import "./chunk-HN2LCLGT.js";
|
|
76
|
-
import "./chunk-FIP2DG7W.js";
|
|
77
|
-
import "./chunk-SYRDEMQE.js";
|
|
78
|
-
import "./chunk-JVBCQHCS.js";
|
|
79
|
-
import "./chunk-DXWJORSY.js";
|
|
80
|
-
import "./chunk-W3BOR6AT.js";
|
|
81
|
-
import "./chunk-PCR6GFNP.js";
|
|
82
|
-
import "./chunk-3TYER5IK.js";
|
|
83
|
-
import "./chunk-IDCZ4LWS.js";
|
|
84
|
-
import "./chunk-34ZOMVUK.js";
|
|
85
|
-
import "./chunk-DY3PLWIH.js";
|
|
86
|
-
import "./chunk-GRGCZSES.js";
|
|
87
|
-
import "./chunk-UNWF3TH5.js";
|
|
88
|
-
import "./chunk-X76RS6JO.js";
|
|
89
|
-
import "./chunk-7CPIZFOE.js";
|
|
90
|
-
import "./chunk-TXDR6YSF.js";
|
|
91
|
-
import "./chunk-SDVUGWD7.js";
|
|
92
|
-
import "./chunk-3J3EDSXF.js";
|
|
93
|
-
import "./chunk-NSOY4FMN.js";
|
|
94
|
-
import "./chunk-HO4JGD4Q.js";
|
|
95
|
-
import "./chunk-MNPGZCKE.js";
|
|
96
|
-
import "./chunk-LC7ZD2RW.js";
|
|
97
|
-
import "./chunk-PATZAYFZ.js";
|
|
98
|
-
import "./chunk-YF3S26TS.js";
|
|
99
|
-
import "./chunk-DNCLQPOM.js";
|
|
100
|
-
import "./chunk-QQRJEWKB.js";
|
|
101
|
-
import "./chunk-D72URWJE.js";
|
|
102
|
-
import "./chunk-TES7MB6I.js";
|
|
103
|
-
import "./chunk-ZCQ4H7CA.js";
|
|
104
|
-
import "./chunk-SYYQZDHJ.js";
|
|
105
|
-
import "./chunk-KYRYD4CR.js";
|
|
106
|
-
import "./chunk-WIHN3ELW.js";
|
|
107
|
-
import {
|
|
108
|
-
mcpErrorResult
|
|
109
|
-
} from "./chunk-QFOP3KUP.js";
|
|
110
|
-
import "./chunk-Y5E2WNWB.js";
|
|
111
|
-
import {
|
|
112
|
-
CliError
|
|
113
|
-
} from "./chunk-S6JG4YUH.js";
|
|
114
|
-
import "./chunk-TCT5D2X2.js";
|
|
115
|
-
import {
|
|
116
|
-
__name
|
|
117
|
-
} from "./chunk-ZVVMGPBJ.js";
|
|
118
|
-
|
|
119
|
-
// node_modules/.pnpm/@wirecat+cli-core@2.0.0_@wirecat+cli-base@1.0.0_commander@15.0.0_esbuild@0.28.2_typescr_a82f624c57005d53c3f072e45c3a3a86/node_modules/@wirecat/cli-core/dist/mcp/app-server.js
|
|
120
|
-
var EXCLUDED = [["mcp"]];
|
|
121
|
-
var aliasesOf = /* @__PURE__ */ __name((root, path) => {
|
|
122
|
-
let at = root;
|
|
123
|
-
for (const name of path)
|
|
124
|
-
at = at?.commands.find((child) => child.name() === name);
|
|
125
|
-
const aliases = at?.aliases() ?? [];
|
|
126
|
-
return aliases.length > 0 ? { aliases } : {};
|
|
127
|
-
}, "aliasesOf");
|
|
128
|
-
var createAppServer = /* @__PURE__ */ __name((command, context, options) => {
|
|
129
|
-
const { app } = options;
|
|
130
|
-
const root = rootOf(command);
|
|
131
|
-
const environment = environmentOf(command);
|
|
132
|
-
if (!environment.runCommand)
|
|
133
|
-
throw new Error("the MCP server runs inside run(), which hands it the program");
|
|
134
|
-
const program = { run: environment.runCommand, commands: describeProgram(root) };
|
|
135
|
-
const flags = command.optsWithGlobals();
|
|
136
|
-
const overrides = flags.permission ?? [];
|
|
137
|
-
const { settings } = context;
|
|
138
|
-
const levels = /* @__PURE__ */ __name(() => options.resolveSettings(flags, { env: context.env }).permissions, "levels");
|
|
139
|
-
const readOnly = /* @__PURE__ */ __name(() => readOnlyLockOf(app, context.env) !== void 0, "readOnly");
|
|
140
|
-
const authority = changesAuthorityAt(root);
|
|
141
|
-
const fetches = fetchesOnlyAt(root);
|
|
142
|
-
const targets = judgedTargets(root);
|
|
143
|
-
const passed = Object.fromEntries(Object.entries(environment).filter(([key]) => !PER_RUN.has(key)));
|
|
144
|
-
const tools = toolsFromCommands(program.commands, {
|
|
145
|
-
includeUnavailable: true,
|
|
146
|
-
exclude: EXCLUDED,
|
|
147
|
-
levels: settings.permissions,
|
|
148
|
-
currentLevels: levels,
|
|
149
|
-
readOnly: readOnly(),
|
|
150
|
-
authority,
|
|
151
|
-
fetchOnly: readsOverMcpAt(root),
|
|
152
|
-
fetches,
|
|
153
|
-
permissions: options.permissions
|
|
154
|
-
});
|
|
155
|
-
const availability = /* @__PURE__ */ __name((one) => () => {
|
|
156
|
-
const permitted = one.availability?.() ?? { available: true };
|
|
157
|
-
if (!permitted.available)
|
|
158
|
-
return permitted;
|
|
159
|
-
return options.availability?.(one.path, settings.profile) ?? permitted;
|
|
160
|
-
}, "availability");
|
|
161
|
-
const commands = Object.fromEntries(tools.map((one) => [
|
|
162
|
-
one.command,
|
|
163
|
-
{
|
|
164
|
-
title: one.title,
|
|
165
|
-
description: one.description,
|
|
166
|
-
...one.keywords ? { keywords: one.keywords } : {},
|
|
167
|
-
...aliasesOf(root, one.path),
|
|
168
|
-
writes: one.writes,
|
|
169
|
-
availability: availability(one),
|
|
170
|
-
input: one.input,
|
|
171
|
-
run: /* @__PURE__ */ __name(async (input, ctx) => {
|
|
172
|
-
const own = options.availability?.(one.path, settings.profile);
|
|
173
|
-
if (own && !own.available)
|
|
174
|
-
return failed(new CliError("permission_error", `${one.command}: ${own.reason ?? "unavailable for this profile"}`, {
|
|
175
|
-
...own.permission ? { permission: own.permission } : {}
|
|
176
|
-
}), app.errors);
|
|
177
|
-
const traceparent = ctx?.mcpReq?._meta?.traceparent;
|
|
178
|
-
const env = typeof traceparent === "string" ? { ...context.env, TRACEPARENT: traceparent } : context.env;
|
|
179
|
-
const answer = await runCommandForAgent(program, one.path, input, {
|
|
180
|
-
profile: settings.profile,
|
|
181
|
-
readOnly: readOnly(),
|
|
182
|
-
env,
|
|
183
|
-
levels,
|
|
184
|
-
overrides,
|
|
185
|
-
authority,
|
|
186
|
-
fetches,
|
|
187
|
-
permissions: options.permissions,
|
|
188
|
-
environment: passed
|
|
189
|
-
});
|
|
190
|
-
if ("error" in answer)
|
|
191
|
-
return mcpErrorResult(JSON.parse(agentJson(answer.error)));
|
|
192
|
-
try {
|
|
193
|
-
return answered(envelope(one.command, answer.result), DEFAULT_OUTPUT_BYTES, targets);
|
|
194
|
-
} catch (error) {
|
|
195
|
-
return failed(error, app.errors);
|
|
196
|
-
}
|
|
197
|
-
}, "run")
|
|
198
|
-
}
|
|
199
|
-
]));
|
|
200
|
-
const skills = options.skill ? skillResources(app, options.skill) : [];
|
|
201
|
-
const skill = skills[0];
|
|
202
|
-
const build = /* @__PURE__ */ __name(() => {
|
|
203
|
-
const server = new McpServer({ name: app.command, version: app.version }, {
|
|
204
|
-
instructions: appInstructions({
|
|
205
|
-
command: app.command,
|
|
206
|
-
name: options.name,
|
|
207
|
-
profile: settings.profile,
|
|
208
|
-
untrusted: options.untrusted,
|
|
209
|
-
...skill ? { skill: skill.instruction } : {}
|
|
210
|
-
})
|
|
211
|
-
});
|
|
212
|
-
registerCommands(server, app.command, commands, app.errors, void 0, app.messenger);
|
|
213
|
-
for (const { uri, name, title, description, mimeType, read } of skills)
|
|
214
|
-
server.registerResource(name, uri, { title, description, mimeType }, read);
|
|
215
|
-
return server;
|
|
216
|
-
}, "build");
|
|
217
|
-
return { build, offered: Object.keys(commands) };
|
|
218
|
-
}, "createAppServer");
|
|
219
|
-
var serveAppOverStdio = /* @__PURE__ */ __name(async (command, context, options) => {
|
|
220
|
-
const { build } = createAppServer(command, context, options);
|
|
221
|
-
const { stdin, stdout, signal } = environmentOf(command);
|
|
222
|
-
const own = stdin && stdout && stdin !== process.stdin;
|
|
223
|
-
const wire = answeredWire(own ? stdin : process.stdin, own ? stdout : process.stdout);
|
|
224
|
-
const handle = serveStdio(build, {
|
|
225
|
-
transport: new StdioServerTransport(wire.input, wire.output),
|
|
226
|
-
onerror: /* @__PURE__ */ __name((error) => context.renderer.note(`mcp: ${error.message}`), "onerror")
|
|
227
|
-
});
|
|
228
|
-
await wire.finished(own ? signal : void 0);
|
|
229
|
-
wire.release();
|
|
230
|
-
await handle.close();
|
|
231
|
-
}, "serveAppOverStdio");
|
|
232
|
-
var serveAppOverHttp = /* @__PURE__ */ __name(async (command, context, options, http) => {
|
|
233
|
-
const { app } = options;
|
|
234
|
-
const { build } = createAppServer(command, context, options);
|
|
235
|
-
const { serveOverHttp } = await import("./serve-6BWU3NMB.js");
|
|
236
|
-
const listening = await serveOverHttp(build, {
|
|
237
|
-
...http,
|
|
238
|
-
appName: app.command,
|
|
239
|
-
reaches: `your ${options.name}`,
|
|
240
|
-
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"),
|
|
241
|
-
onError: /* @__PURE__ */ __name((error) => context.renderer.note(`mcp: ${error.message}`), "onError")
|
|
242
|
-
}).catch((error) => {
|
|
243
|
-
if (error.code === "EADDRINUSE")
|
|
244
|
-
throw new CliError("configuration_error", `port ${http.port} is in use \u2014 pass another with --port`);
|
|
245
|
-
throw error;
|
|
246
|
-
});
|
|
247
|
-
context.renderer.note(`serving on ${listening.url.href} \u2014 point your tunnel at it; connectors use ${mcpUrlOf(http.publicUrl).href}`);
|
|
248
|
-
await new Promise((resolve) => {
|
|
249
|
-
process.once("SIGINT", resolve);
|
|
250
|
-
process.once("SIGTERM", resolve);
|
|
251
|
-
});
|
|
252
|
-
await listening.close();
|
|
253
|
-
}, "serveAppOverHttp");
|
|
254
|
-
export {
|
|
255
|
-
createAppServer,
|
|
256
|
-
serveAppOverHttp,
|
|
257
|
-
serveAppOverStdio
|
|
258
|
-
};
|