@wirecat/mail-cli 0.0.0-stage → 0.1.1
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 +60 -0
- package/LICENSE +204 -0
- package/README.md +166 -2
- package/dist/bin/mail.d.ts +3 -0
- package/dist/bin/mail.d.ts.map +1 -0
- package/dist/bin/mail.js +36 -0
- package/dist/bin/mail.js.map +1 -0
- package/dist/bundle/all-profiles-TKMBELRZ.js +286 -0
- package/dist/bundle/anthropic-7LMUAEIZ.js +72 -0
- package/dist/bundle/app-server-JGMIJDD4.js +229 -0
- package/dist/bundle/bun-XRO6XJHQ.js +169 -0
- package/dist/bundle/bun-sqlite-Z54LEHVM.js +71 -0
- package/dist/bundle/chunk-2LLNPNMB.js +24 -0
- package/dist/bundle/chunk-3E3WA2L6.js +1932 -0
- package/dist/bundle/chunk-3KEVLSNN.js +138 -0
- package/dist/bundle/chunk-3KOA73LS.js +3416 -0
- package/dist/bundle/chunk-4E7BN3TC.js +122 -0
- package/dist/bundle/chunk-4FEMINO2.js +409 -0
- package/dist/bundle/chunk-52F5DWS5.js +27 -0
- package/dist/bundle/chunk-5BVIWP3S.js +71 -0
- package/dist/bundle/chunk-5D4AEUVA.js +24783 -0
- package/dist/bundle/chunk-5NYMNSSO.js +264 -0
- package/dist/bundle/chunk-6MAZWSC3.js +132 -0
- package/dist/bundle/chunk-75CWWETH.js +379 -0
- package/dist/bundle/chunk-7SXGLT6T.js +444 -0
- package/dist/bundle/chunk-BTQX2ZSZ.js +288 -0
- package/dist/bundle/chunk-CEW6KIFA.js +1193 -0
- package/dist/bundle/chunk-CH6RXYAX.js +82 -0
- package/dist/bundle/chunk-D72URWJE.js +532 -0
- package/dist/bundle/chunk-DFDN6AUB.js +21 -0
- package/dist/bundle/chunk-EOEDICIE.js +6848 -0
- package/dist/bundle/chunk-F6D6PJ34.js +100 -0
- package/dist/bundle/chunk-FDCGTODC.js +78 -0
- package/dist/bundle/chunk-FZ5FXIG6.js +18 -0
- package/dist/bundle/chunk-GAH7N7HO.js +8181 -0
- package/dist/bundle/chunk-GK4M2SUP.js +195 -0
- package/dist/bundle/chunk-GN62YOT5.js +161 -0
- package/dist/bundle/chunk-GQQJOH7A.js +7050 -0
- package/dist/bundle/chunk-GWDCKUBI.js +781 -0
- package/dist/bundle/chunk-HTQTIKWP.js +928 -0
- package/dist/bundle/chunk-IK5TH3O7.js +217 -0
- package/dist/bundle/chunk-J3QXTBD2.js +2742 -0
- package/dist/bundle/chunk-J6MSJLIW.js +45 -0
- package/dist/bundle/chunk-JBBZCTTF.js +76 -0
- package/dist/bundle/chunk-JVMVLITS.js +260 -0
- package/dist/bundle/chunk-K4FVKPDQ.js +525 -0
- package/dist/bundle/chunk-KHTO2Q6E.js +886 -0
- package/dist/bundle/chunk-KM7Q67Z3.js +63 -0
- package/dist/bundle/chunk-LQ37ALDJ.js +2416 -0
- package/dist/bundle/chunk-MNOIRJEO.js +2315 -0
- package/dist/bundle/chunk-MS53RALV.js +168 -0
- package/dist/bundle/chunk-NK7EB63L.js +36225 -0
- package/dist/bundle/chunk-NPGVOZVK.js +2 -0
- package/dist/bundle/chunk-OTUOZ33L.js +82 -0
- package/dist/bundle/chunk-P7P5MNAU.js +46 -0
- package/dist/bundle/chunk-QLEUNU6G.js +537 -0
- package/dist/bundle/chunk-QQB7WT7R.js +216 -0
- package/dist/bundle/chunk-QX7RCLRS.js +23 -0
- package/dist/bundle/chunk-T6464KYA.js +35130 -0
- package/dist/bundle/chunk-TE5U5OAM.js +73 -0
- package/dist/bundle/chunk-TI6VBZKJ.js +166 -0
- package/dist/bundle/chunk-TQFCPUIM.js +53 -0
- package/dist/bundle/chunk-TVREDYX4.js +3574 -0
- package/dist/bundle/chunk-TWPDVUBR.js +106 -0
- package/dist/bundle/chunk-TWTATDM7.js +461 -0
- package/dist/bundle/chunk-UH4DDRHA.js +2989 -0
- package/dist/bundle/chunk-VEIZZRQ5.js +630 -0
- package/dist/bundle/chunk-WLFLBWNH.js +54 -0
- package/dist/bundle/chunk-WXAXYJJ7.js +486 -0
- package/dist/bundle/chunk-XQUUANA2.js +24600 -0
- package/dist/bundle/chunk-Y5E2WNWB.js +35 -0
- package/dist/bundle/chunk-YO4CUH5E.js +33 -0
- package/dist/bundle/chunk-YPQQ5J4X.js +849 -0
- package/dist/bundle/chunk-Z34ICZA3.js +1028 -0
- package/dist/bundle/chunk-ZANYM66S.js +58 -0
- package/dist/bundle/chunk-ZD3WUGR2.js +142 -0
- package/dist/bundle/chunk-ZVVMGPBJ.js +50 -0
- package/dist/bundle/command-contract-WU434ZUL.js +34 -0
- package/dist/bundle/decode-YB3ZDTES.js +162 -0
- package/dist/bundle/dispatch-EUKKT3PD.js +411 -0
- package/dist/bundle/dist-A6GKSKFC.js +2072 -0
- package/dist/bundle/dist-HFUVURJG.js +7577 -0
- package/dist/bundle/echarts-YNGCOYHW.js +42501 -0
- package/dist/bundle/embed-LWNHIRBQ.js +37 -0
- package/dist/bundle/embedder-2LYD3U37.js +110 -0
- package/dist/bundle/failure-OAIC5VAP.js +24 -0
- package/dist/bundle/first-run-N3HJKGU7.js +27 -0
- package/dist/bundle/first-screen-4U2DMV3G.js +32 -0
- package/dist/bundle/instructions-GJHHFV64.js +11 -0
- package/dist/bundle/mail.js +166 -0
- package/dist/bundle/mcp-L7SRVDRN.js +167 -0
- package/dist/bundle/node-GFOH6FKP.js +176 -0
- package/dist/bundle/node-KM3CUABH.js +2340 -0
- package/dist/bundle/node-TLZSIHIJ.js +21 -0
- package/dist/bundle/node-sqlite-NBXQXBIU.js +63 -0
- package/dist/bundle/oauth-56EFO5AQ.js +19 -0
- package/dist/bundle/open-2V7QZQJP.js +21 -0
- package/dist/bundle/openai-V3SVACVL.js +251 -0
- package/dist/bundle/process-XVDX4SPD.js +91 -0
- package/dist/bundle/program-JTJB26P3.js +35542 -0
- package/dist/bundle/prompt-YKWAI222.js +14 -0
- package/dist/bundle/recognize-PAR66KVM.js +25 -0
- package/dist/bundle/remote-CE43TKXC.js +28 -0
- package/dist/bundle/rerank-M7S7P2TW.js +51 -0
- package/dist/bundle/serve-ENPMIV6J.js +197 -0
- package/dist/bundle/server-JRTHUCVY.js +63 -0
- package/dist/bundle/server-MBEZLVKZ.js +189 -0
- package/dist/bundle/sqlite-runtime-HVGDHBJJ.js +18 -0
- package/dist/bundle/state-QZSOSKBD.js +35 -0
- package/dist/bundle/store-2BUX6LVX.js +124 -0
- package/dist/bundle/store-UJ7SNKXI.js +141 -0
- package/dist/bundle/store-maintenance-command-I7V5C44K.js +52 -0
- package/dist/commands/account.d.ts +3 -0
- package/dist/commands/account.d.ts.map +1 -0
- package/dist/commands/account.js +47 -0
- package/dist/commands/account.js.map +1 -0
- package/dist/commands/context.d.ts +41 -0
- package/dist/commands/context.d.ts.map +1 -0
- package/dist/commands/context.js +52 -0
- package/dist/commands/context.js.map +1 -0
- package/dist/commands/folders.d.ts +3 -0
- package/dist/commands/folders.d.ts.map +1 -0
- package/dist/commands/folders.js +36 -0
- package/dist/commands/folders.js.map +1 -0
- package/dist/commands/login.d.ts +5 -0
- package/dist/commands/login.d.ts.map +1 -0
- package/dist/commands/login.js +21 -0
- package/dist/commands/login.js.map +1 -0
- package/dist/commands/mailbox.d.ts +16 -0
- package/dist/commands/mailbox.d.ts.map +1 -0
- package/dist/commands/mailbox.js +54 -0
- package/dist/commands/mailbox.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 +211 -0
- package/dist/commands/session.js.map +1 -0
- package/dist/commands/status.d.ts +3 -0
- package/dist/commands/status.d.ts.map +1 -0
- package/dist/commands/status.js +89 -0
- package/dist/commands/status.js.map +1 -0
- package/dist/commands/sync.d.ts +3 -0
- package/dist/commands/sync.d.ts.map +1 -0
- package/dist/commands/sync.js +190 -0
- package/dist/commands/sync.js.map +1 -0
- package/dist/config.d.ts +190 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +46 -0
- package/dist/config.js.map +1 -0
- package/dist/discovery.d.ts +42 -0
- package/dist/discovery.d.ts.map +1 -0
- package/dist/discovery.js +179 -0
- package/dist/discovery.js.map +1 -0
- package/dist/identity.d.ts +5 -0
- package/dist/identity.d.ts.map +1 -0
- package/dist/identity.js +16 -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/mail/imap-errors.d.ts +4 -0
- package/dist/mail/imap-errors.d.ts.map +1 -0
- package/dist/mail/imap-errors.js +41 -0
- package/dist/mail/imap-errors.js.map +1 -0
- package/dist/mail/imap-messages.d.ts +18 -0
- package/dist/mail/imap-messages.d.ts.map +1 -0
- package/dist/mail/imap-messages.js +66 -0
- package/dist/mail/imap-messages.js.map +1 -0
- package/dist/mail/imap.d.ts +67 -0
- package/dist/mail/imap.d.ts.map +1 -0
- package/dist/mail/imap.js +348 -0
- package/dist/mail/imap.js.map +1 -0
- package/dist/profile.d.ts +16 -0
- package/dist/profile.d.ts.map +1 -0
- package/dist/profile.js +31 -0
- package/dist/profile.js.map +1 -0
- package/dist/program.d.ts +6 -0
- package/dist/program.d.ts.map +1 -0
- package/dist/program.js +52 -0
- package/dist/program.js.map +1 -0
- package/dist/providers.d.ts +53 -0
- package/dist/providers.d.ts.map +1 -0
- package/dist/providers.js +106 -0
- package/dist/providers.js.map +1 -0
- package/dist/secret.d.ts +30 -0
- package/dist/secret.d.ts.map +1 -0
- package/dist/secret.js +68 -0
- package/dist/secret.js.map +1 -0
- package/dist/store.d.ts +12 -0
- package/dist/store.d.ts.map +1 -0
- package/dist/store.js +25 -0
- package/dist/store.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/package.json +83 -4
- package/skills/mail-cli/SKILL.md +27 -0
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
import { createRequire as __bundleRequire } from "node:module";
|
|
2
|
+
const require = __bundleRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
answeredWire
|
|
5
|
+
} from "./chunk-JBBZCTTF.js";
|
|
6
|
+
import {
|
|
7
|
+
CALLER_META_KEY,
|
|
8
|
+
PROXY_CLIENT_NAME,
|
|
9
|
+
StdioServerTransport,
|
|
10
|
+
callerOf,
|
|
11
|
+
serveStdio
|
|
12
|
+
} from "./chunk-VEIZZRQ5.js";
|
|
13
|
+
import {
|
|
14
|
+
McpServer
|
|
15
|
+
} from "./chunk-5D4AEUVA.js";
|
|
16
|
+
import "./chunk-7SXGLT6T.js";
|
|
17
|
+
import "./chunk-NPGVOZVK.js";
|
|
18
|
+
import "./chunk-J3QXTBD2.js";
|
|
19
|
+
import "./chunk-LQ37ALDJ.js";
|
|
20
|
+
import "./chunk-Y5E2WNWB.js";
|
|
21
|
+
import "./chunk-5BVIWP3S.js";
|
|
22
|
+
import {
|
|
23
|
+
__name
|
|
24
|
+
} from "./chunk-ZVVMGPBJ.js";
|
|
25
|
+
|
|
26
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.1_commander@15.0.0_esbuild@0.28.2_type_d5beb0101c7a90701cc33879a5be8d28/node_modules/@wirecat/cli-core/dist/mcp/all-profiles.js
|
|
27
|
+
import { spawn } from "node:child_process";
|
|
28
|
+
import { randomUUID } from "node:crypto";
|
|
29
|
+
var PROTOCOL = "2025-06-18";
|
|
30
|
+
var START_MS = 3e4;
|
|
31
|
+
var CHILD_IDLE_MS = 10 * 60 * 1e3;
|
|
32
|
+
var startChild = /* @__PURE__ */ __name((spec, note, onExit) => {
|
|
33
|
+
const child = spawn(spec.command, spec.args, { env: spec.env, stdio: "pipe" });
|
|
34
|
+
const pending = /* @__PURE__ */ new Map();
|
|
35
|
+
let next = 1;
|
|
36
|
+
let buffer = "";
|
|
37
|
+
let gone;
|
|
38
|
+
const fail = /* @__PURE__ */ __name((error) => {
|
|
39
|
+
gone ??= error;
|
|
40
|
+
for (const waiter of pending.values())
|
|
41
|
+
waiter.reject(error);
|
|
42
|
+
pending.clear();
|
|
43
|
+
}, "fail");
|
|
44
|
+
child.on("error", () => fail(new Error("the profile's MCP server could not be started")));
|
|
45
|
+
child.on("exit", () => {
|
|
46
|
+
fail(new Error("the profile's MCP server stopped"));
|
|
47
|
+
onExit();
|
|
48
|
+
});
|
|
49
|
+
child.stdin.on("error", () => fail(new Error("the profile's MCP server closed its input")));
|
|
50
|
+
child.stderr.setEncoding("utf8");
|
|
51
|
+
let errors = "";
|
|
52
|
+
child.stderr.on("data", (chunk) => {
|
|
53
|
+
const lines = (errors + chunk).split("\n");
|
|
54
|
+
errors = lines.pop() ?? "";
|
|
55
|
+
for (const line of lines)
|
|
56
|
+
if (line.trim())
|
|
57
|
+
note(line);
|
|
58
|
+
});
|
|
59
|
+
child.stdout.setEncoding("utf8");
|
|
60
|
+
child.stdout.on("data", (chunk) => {
|
|
61
|
+
buffer += chunk;
|
|
62
|
+
for (let at = buffer.indexOf("\n"); at !== -1; at = buffer.indexOf("\n")) {
|
|
63
|
+
const line = buffer.slice(0, at);
|
|
64
|
+
buffer = buffer.slice(at + 1);
|
|
65
|
+
let message;
|
|
66
|
+
try {
|
|
67
|
+
message = JSON.parse(line);
|
|
68
|
+
} catch {
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
if (message.method !== void 0 && message.id !== void 0) {
|
|
72
|
+
send({ id: message.id, error: { code: -32601, message: "not offered through the all-profiles server" } });
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
if (typeof message.id !== "number")
|
|
76
|
+
continue;
|
|
77
|
+
const waiter = pending.get(message.id);
|
|
78
|
+
if (!waiter)
|
|
79
|
+
continue;
|
|
80
|
+
pending.delete(message.id);
|
|
81
|
+
if (message.error)
|
|
82
|
+
waiter.reject(new Error(message.error.message ?? "the profile's MCP server refused"));
|
|
83
|
+
else
|
|
84
|
+
waiter.resolve(message.result ?? {});
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
const send = /* @__PURE__ */ __name((message) => child.stdin.write(`${JSON.stringify({ jsonrpc: "2.0", ...message })}
|
|
88
|
+
`), "send");
|
|
89
|
+
const request = /* @__PURE__ */ __name((method, params) => new Promise((resolve, reject) => {
|
|
90
|
+
if (gone)
|
|
91
|
+
return reject(gone);
|
|
92
|
+
const id = next++;
|
|
93
|
+
pending.set(id, { resolve, reject });
|
|
94
|
+
send({ id, method, params });
|
|
95
|
+
}), "request");
|
|
96
|
+
const close = /* @__PURE__ */ __name(() => new Promise((resolve) => {
|
|
97
|
+
if (child.exitCode !== null || child.signalCode !== null)
|
|
98
|
+
return resolve();
|
|
99
|
+
child.once("exit", () => resolve());
|
|
100
|
+
child.stdin.end();
|
|
101
|
+
}), "close");
|
|
102
|
+
const timer = setTimeout(() => fail(new Error("the profile's MCP server did not answer in time")), START_MS);
|
|
103
|
+
return request("initialize", {
|
|
104
|
+
protocolVersion: PROTOCOL,
|
|
105
|
+
capabilities: {},
|
|
106
|
+
clientInfo: { name: PROXY_CLIENT_NAME, version: "1" }
|
|
107
|
+
}).then(() => {
|
|
108
|
+
send({ method: "notifications/initialized" });
|
|
109
|
+
return { request, close };
|
|
110
|
+
}).catch(async (error) => {
|
|
111
|
+
await close();
|
|
112
|
+
throw error;
|
|
113
|
+
}).finally(() => clearTimeout(timer));
|
|
114
|
+
}, "startChild");
|
|
115
|
+
var pool = /* @__PURE__ */ __name((options) => {
|
|
116
|
+
const idleMs = options.idleMs ?? CHILD_IDLE_MS;
|
|
117
|
+
const note = options.note ?? (() => {
|
|
118
|
+
});
|
|
119
|
+
const running = /* @__PURE__ */ new Map();
|
|
120
|
+
const forget = /* @__PURE__ */ __name((profile, child) => {
|
|
121
|
+
const one = running.get(profile);
|
|
122
|
+
if (one?.child !== child)
|
|
123
|
+
return;
|
|
124
|
+
clearTimeout(one.timer);
|
|
125
|
+
running.delete(profile);
|
|
126
|
+
}, "forget");
|
|
127
|
+
const use = /* @__PURE__ */ __name(async (profile, work) => {
|
|
128
|
+
let one = running.get(profile);
|
|
129
|
+
if (!one) {
|
|
130
|
+
const child = startChild(options.child(profile), (line) => note(`${profile}: ${line}`), () => forget(profile, child));
|
|
131
|
+
child.catch(() => forget(profile, child));
|
|
132
|
+
one = { child };
|
|
133
|
+
running.set(profile, one);
|
|
134
|
+
}
|
|
135
|
+
clearTimeout(one.timer);
|
|
136
|
+
const entry = one;
|
|
137
|
+
try {
|
|
138
|
+
return await work(await entry.child);
|
|
139
|
+
} finally {
|
|
140
|
+
if (running.get(profile) === entry) {
|
|
141
|
+
entry.timer = setTimeout(() => {
|
|
142
|
+
forget(profile, entry.child);
|
|
143
|
+
void entry.child.then((child) => child.close()).catch(() => void 0);
|
|
144
|
+
}, idleMs);
|
|
145
|
+
entry.timer.unref();
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}, "use");
|
|
149
|
+
const close = /* @__PURE__ */ __name(async () => {
|
|
150
|
+
const all = [...running.values()];
|
|
151
|
+
running.clear();
|
|
152
|
+
for (const one of all)
|
|
153
|
+
clearTimeout(one.timer);
|
|
154
|
+
await Promise.all(all.map((one) => one.child.then((child) => child.close()).catch(() => void 0)));
|
|
155
|
+
}, "close");
|
|
156
|
+
return { use, close };
|
|
157
|
+
}, "pool");
|
|
158
|
+
var withProfile = /* @__PURE__ */ __name((tool, profiles, name, signedIn = () => true) => {
|
|
159
|
+
const schema = tool.inputSchema;
|
|
160
|
+
const out = profiles.filter((profile) => !signedIn(profile));
|
|
161
|
+
const states = out.length === 0 ? "" : ` Signed in: ${profiles.filter(signedIn).join(", ") || "none"} \xB7 Not signed in: ${out.join(", ")}.`;
|
|
162
|
+
return {
|
|
163
|
+
...tool,
|
|
164
|
+
inputSchema: {
|
|
165
|
+
...tool.inputSchema,
|
|
166
|
+
properties: {
|
|
167
|
+
profile: {
|
|
168
|
+
type: "string",
|
|
169
|
+
enum: [...profiles],
|
|
170
|
+
oneOf: profiles.map((profile) => ({
|
|
171
|
+
const: profile,
|
|
172
|
+
title: signedIn(profile) ? profile : `${profile} \u2014 not signed in`
|
|
173
|
+
})),
|
|
174
|
+
description: `Which ${name} account, by its profile. If the owner did not name one, ask which \u2014 never guess.${states}`
|
|
175
|
+
},
|
|
176
|
+
...schema.properties
|
|
177
|
+
},
|
|
178
|
+
required: ["profile", ...(schema.required ?? []).filter((field) => field !== "profile")]
|
|
179
|
+
}
|
|
180
|
+
};
|
|
181
|
+
}, "withProfile");
|
|
182
|
+
var refusal = /* @__PURE__ */ __name((text) => ({
|
|
183
|
+
isError: true,
|
|
184
|
+
content: [{ type: "text", text }]
|
|
185
|
+
}), "refusal");
|
|
186
|
+
var allProfilesServer = /* @__PURE__ */ __name((options) => {
|
|
187
|
+
const children = pool(options);
|
|
188
|
+
let listed;
|
|
189
|
+
const tools = /* @__PURE__ */ __name((profiles) => {
|
|
190
|
+
listed ??= children.use(profiles.find(signedIn) ?? profiles[0], (child) => child.request("tools/list", {})).then((answer) => answer.tools ?? []);
|
|
191
|
+
listed.catch(() => {
|
|
192
|
+
listed = void 0;
|
|
193
|
+
});
|
|
194
|
+
return listed;
|
|
195
|
+
}, "tools");
|
|
196
|
+
const signedIn = /* @__PURE__ */ __name((profile) => options.signedIn?.(profile) ?? true, "signedIn");
|
|
197
|
+
const build = /* @__PURE__ */ __name(() => {
|
|
198
|
+
const profiles = [...options.profiles()].sort();
|
|
199
|
+
const server = new McpServer({ name: options.command, version: options.version }, { capabilities: { tools: {} }, instructions: options.instructions });
|
|
200
|
+
server.server.setRequestHandler("tools/list", async () => ({
|
|
201
|
+
tools: profiles.length === 0 ? [] : (await tools(profiles)).map((one) => withProfile(one, profiles, options.name, signedIn))
|
|
202
|
+
}));
|
|
203
|
+
const callers = {
|
|
204
|
+
env: options.env ?? process.env,
|
|
205
|
+
client: /* @__PURE__ */ __name(() => server.server.getClientVersion(), "client"),
|
|
206
|
+
connectionId: randomUUID()
|
|
207
|
+
};
|
|
208
|
+
server.server.setRequestHandler("tools/call", async (request, ctx) => {
|
|
209
|
+
const { name, arguments: given = {}, _meta } = request.params;
|
|
210
|
+
const { profile, ...rest } = given;
|
|
211
|
+
if (typeof profile !== "string" || !profiles.includes(profile))
|
|
212
|
+
return refusal(`${name} needs "profile", one of: ${profiles.join(", ")}. If the owner did not say which account, ask.`);
|
|
213
|
+
if (!signedIn(profile))
|
|
214
|
+
return refusal(options.signIn?.(profile) ?? `profile ${profile} is not signed in.`);
|
|
215
|
+
try {
|
|
216
|
+
return await children.use(profile, (child) => (
|
|
217
|
+
// Children are shared by every session, so each call names its own caller.
|
|
218
|
+
child.request("tools/call", {
|
|
219
|
+
name,
|
|
220
|
+
arguments: rest,
|
|
221
|
+
_meta: { ..._meta, [CALLER_META_KEY]: callerOf(ctx, name, callers) }
|
|
222
|
+
})
|
|
223
|
+
));
|
|
224
|
+
} catch (error) {
|
|
225
|
+
return refusal(`profile ${profile}: ${error instanceof Error ? error.message : String(error)}`);
|
|
226
|
+
}
|
|
227
|
+
});
|
|
228
|
+
return server;
|
|
229
|
+
}, "build");
|
|
230
|
+
return { build, close: /* @__PURE__ */ __name(() => children.close(), "close") };
|
|
231
|
+
}, "allProfilesServer");
|
|
232
|
+
var serveAllProfilesOverStdio = /* @__PURE__ */ __name(async (options, io = {}) => {
|
|
233
|
+
const { build, close } = allProfilesServer(options);
|
|
234
|
+
const own = io.stdin !== void 0 && io.stdin !== process.stdin;
|
|
235
|
+
const wire = answeredWire(io.stdin ?? process.stdin, io.stdout ?? process.stdout);
|
|
236
|
+
const handle = serveStdio(build, {
|
|
237
|
+
transport: new StdioServerTransport(wire.input, wire.output),
|
|
238
|
+
onerror: /* @__PURE__ */ __name((error) => options.note?.(`mcp: ${error.message}`), "onerror")
|
|
239
|
+
});
|
|
240
|
+
const ended = await new Promise((resolve) => {
|
|
241
|
+
wire.ended.then(() => resolve("input"));
|
|
242
|
+
if (own)
|
|
243
|
+
io.signal?.addEventListener("abort", () => resolve("stopped"), { once: true });
|
|
244
|
+
else {
|
|
245
|
+
process.once("SIGINT", () => resolve("stopped"));
|
|
246
|
+
process.once("SIGTERM", () => resolve("stopped"));
|
|
247
|
+
}
|
|
248
|
+
});
|
|
249
|
+
try {
|
|
250
|
+
if (ended === "input")
|
|
251
|
+
await wire.answered();
|
|
252
|
+
wire.release();
|
|
253
|
+
await handle.close();
|
|
254
|
+
} finally {
|
|
255
|
+
await close();
|
|
256
|
+
}
|
|
257
|
+
}, "serveAllProfilesOverStdio");
|
|
258
|
+
var serveAllProfilesOverHttp = /* @__PURE__ */ __name(async (options, http) => {
|
|
259
|
+
const { build, close } = allProfilesServer(options);
|
|
260
|
+
const { serveOverHttp } = await import("./serve-ENPMIV6J.js");
|
|
261
|
+
const listening = await serveOverHttp(build, {
|
|
262
|
+
...http,
|
|
263
|
+
appName: options.command,
|
|
264
|
+
onError: /* @__PURE__ */ __name((error) => options.note?.(`mcp: ${error.message}`), "onError")
|
|
265
|
+
}).catch(async (error) => {
|
|
266
|
+
await close();
|
|
267
|
+
throw error;
|
|
268
|
+
});
|
|
269
|
+
return {
|
|
270
|
+
url: listening.url,
|
|
271
|
+
close: /* @__PURE__ */ __name(async () => {
|
|
272
|
+
try {
|
|
273
|
+
await listening.close();
|
|
274
|
+
} finally {
|
|
275
|
+
await close();
|
|
276
|
+
}
|
|
277
|
+
}, "close")
|
|
278
|
+
};
|
|
279
|
+
}, "serveAllProfilesOverHttp");
|
|
280
|
+
export {
|
|
281
|
+
CHILD_IDLE_MS,
|
|
282
|
+
allProfilesServer,
|
|
283
|
+
serveAllProfilesOverHttp,
|
|
284
|
+
serveAllProfilesOverStdio,
|
|
285
|
+
withProfile
|
|
286
|
+
};
|
|
@@ -0,0 +1,72 @@
|
|
|
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
|
+
checkedOptions
|
|
8
|
+
} from "./chunk-YO4CUH5E.js";
|
|
9
|
+
import {
|
|
10
|
+
messagesFor,
|
|
11
|
+
systemFor
|
|
12
|
+
} from "./chunk-J6MSJLIW.js";
|
|
13
|
+
import "./chunk-J3QXTBD2.js";
|
|
14
|
+
import {
|
|
15
|
+
array,
|
|
16
|
+
optional,
|
|
17
|
+
strictObject,
|
|
18
|
+
string
|
|
19
|
+
} from "./chunk-LQ37ALDJ.js";
|
|
20
|
+
import "./chunk-Y5E2WNWB.js";
|
|
21
|
+
import "./chunk-5BVIWP3S.js";
|
|
22
|
+
import {
|
|
23
|
+
__name
|
|
24
|
+
} from "./chunk-ZVVMGPBJ.js";
|
|
25
|
+
|
|
26
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.1_commander@15.0.0_esbuild@0.28.2_type_d5beb0101c7a90701cc33879a5be8d28/node_modules/@wirecat/cli-core/dist/models/anthropic.js
|
|
27
|
+
var options = strictObject({
|
|
28
|
+
stop_sequences: optional(array(string()))
|
|
29
|
+
});
|
|
30
|
+
var anthropic = {
|
|
31
|
+
images: true,
|
|
32
|
+
baseUrl: "https://api.anthropic.com",
|
|
33
|
+
validate: /* @__PURE__ */ __name((given) => checkedOptions("anthropic", options, given), "validate"),
|
|
34
|
+
complete: /* @__PURE__ */ __name(async (target, request, checked, apiKey, fetcher) => {
|
|
35
|
+
const client = new Anthropic({
|
|
36
|
+
apiKey: apiKey ?? "",
|
|
37
|
+
authToken: null,
|
|
38
|
+
fetch: /* @__PURE__ */ __name((input, init) => fetcher(input, { ...init, redirect: "error" }), "fetch"),
|
|
39
|
+
baseURL: target.baseUrl,
|
|
40
|
+
maxRetries: 0,
|
|
41
|
+
logLevel: "off",
|
|
42
|
+
timeout: 12e4
|
|
43
|
+
});
|
|
44
|
+
const response = await client.messages.stream({
|
|
45
|
+
...checked,
|
|
46
|
+
model: target.model,
|
|
47
|
+
system: systemFor(request),
|
|
48
|
+
messages: [
|
|
49
|
+
...messagesFor(request),
|
|
50
|
+
...request.images === void 0 ? [] : [
|
|
51
|
+
{
|
|
52
|
+
role: "user",
|
|
53
|
+
content: request.images.map((image) => ({
|
|
54
|
+
type: "image",
|
|
55
|
+
source: { type: "base64", media_type: image.mimeType, data: image.data }
|
|
56
|
+
}))
|
|
57
|
+
}
|
|
58
|
+
]
|
|
59
|
+
],
|
|
60
|
+
max_tokens: request.maxTokens
|
|
61
|
+
}).finalMessage();
|
|
62
|
+
if (response.stop_reason !== "end_turn")
|
|
63
|
+
throw new Error("incomplete response");
|
|
64
|
+
return {
|
|
65
|
+
text: response.content.filter((block) => block.type === "text").map((block) => block.text).join(""),
|
|
66
|
+
tokens: response.usage.input_tokens + response.usage.output_tokens + (response.usage.cache_creation_input_tokens ?? 0) + (response.usage.cache_read_input_tokens ?? 0)
|
|
67
|
+
};
|
|
68
|
+
}, "complete")
|
|
69
|
+
};
|
|
70
|
+
export {
|
|
71
|
+
anthropic
|
|
72
|
+
};
|
|
@@ -0,0 +1,229 @@
|
|
|
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-GWDCKUBI.js";
|
|
7
|
+
import {
|
|
8
|
+
answered,
|
|
9
|
+
failed,
|
|
10
|
+
registerCommands,
|
|
11
|
+
runCommandForAgent,
|
|
12
|
+
toolsFromCommands
|
|
13
|
+
} from "./chunk-3KOA73LS.js";
|
|
14
|
+
import {
|
|
15
|
+
mcpUrlOf
|
|
16
|
+
} from "./chunk-CEW6KIFA.js";
|
|
17
|
+
import {
|
|
18
|
+
agentJson,
|
|
19
|
+
skillResource
|
|
20
|
+
} from "./chunk-K4FVKPDQ.js";
|
|
21
|
+
import "./chunk-JVMVLITS.js";
|
|
22
|
+
import {
|
|
23
|
+
appInstructions
|
|
24
|
+
} from "./chunk-TQFCPUIM.js";
|
|
25
|
+
import {
|
|
26
|
+
answeredWire
|
|
27
|
+
} from "./chunk-JBBZCTTF.js";
|
|
28
|
+
import {
|
|
29
|
+
StdioServerTransport,
|
|
30
|
+
serveStdio
|
|
31
|
+
} from "./chunk-VEIZZRQ5.js";
|
|
32
|
+
import {
|
|
33
|
+
McpServer
|
|
34
|
+
} from "./chunk-5D4AEUVA.js";
|
|
35
|
+
import "./chunk-3E3WA2L6.js";
|
|
36
|
+
import "./chunk-T6464KYA.js";
|
|
37
|
+
import "./chunk-75CWWETH.js";
|
|
38
|
+
import "./chunk-WXAXYJJ7.js";
|
|
39
|
+
import "./chunk-J6MSJLIW.js";
|
|
40
|
+
import "./chunk-CH6RXYAX.js";
|
|
41
|
+
import "./chunk-MS53RALV.js";
|
|
42
|
+
import "./chunk-TVREDYX4.js";
|
|
43
|
+
import {
|
|
44
|
+
DEFAULT_OUTPUT_BYTES,
|
|
45
|
+
changesAuthorityAt,
|
|
46
|
+
describeProgram,
|
|
47
|
+
environmentOf,
|
|
48
|
+
fetchesOnlyAt,
|
|
49
|
+
judgedTargets,
|
|
50
|
+
readOnlyLockOf,
|
|
51
|
+
rootOf2 as rootOf
|
|
52
|
+
} from "./chunk-GQQJOH7A.js";
|
|
53
|
+
import "./chunk-QLEUNU6G.js";
|
|
54
|
+
import "./chunk-7SXGLT6T.js";
|
|
55
|
+
import "./chunk-ZD3WUGR2.js";
|
|
56
|
+
import "./chunk-P7P5MNAU.js";
|
|
57
|
+
import "./chunk-WLFLBWNH.js";
|
|
58
|
+
import {
|
|
59
|
+
mcpHttpMarker
|
|
60
|
+
} from "./chunk-GN62YOT5.js";
|
|
61
|
+
import "./chunk-TE5U5OAM.js";
|
|
62
|
+
import "./chunk-KM7Q67Z3.js";
|
|
63
|
+
import "./chunk-4E7BN3TC.js";
|
|
64
|
+
import "./chunk-YPQQ5J4X.js";
|
|
65
|
+
import "./chunk-6MAZWSC3.js";
|
|
66
|
+
import "./chunk-NK7EB63L.js";
|
|
67
|
+
import "./chunk-4FEMINO2.js";
|
|
68
|
+
import "./chunk-3KEVLSNN.js";
|
|
69
|
+
import "./chunk-UH4DDRHA.js";
|
|
70
|
+
import "./chunk-NPGVOZVK.js";
|
|
71
|
+
import "./chunk-MNOIRJEO.js";
|
|
72
|
+
import "./chunk-KHTO2Q6E.js";
|
|
73
|
+
import "./chunk-F6D6PJ34.js";
|
|
74
|
+
import "./chunk-EOEDICIE.js";
|
|
75
|
+
import "./chunk-QX7RCLRS.js";
|
|
76
|
+
import "./chunk-D72URWJE.js";
|
|
77
|
+
import "./chunk-Z34ICZA3.js";
|
|
78
|
+
import "./chunk-5NYMNSSO.js";
|
|
79
|
+
import "./chunk-FZ5FXIG6.js";
|
|
80
|
+
import "./chunk-J3QXTBD2.js";
|
|
81
|
+
import {
|
|
82
|
+
mcpErrorResult
|
|
83
|
+
} from "./chunk-LQ37ALDJ.js";
|
|
84
|
+
import "./chunk-Y5E2WNWB.js";
|
|
85
|
+
import {
|
|
86
|
+
CliError
|
|
87
|
+
} from "./chunk-5BVIWP3S.js";
|
|
88
|
+
import {
|
|
89
|
+
__name
|
|
90
|
+
} from "./chunk-ZVVMGPBJ.js";
|
|
91
|
+
|
|
92
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.1_commander@15.0.0_esbuild@0.28.2_type_d5beb0101c7a90701cc33879a5be8d28/node_modules/@wirecat/cli-core/dist/mcp/app-server.js
|
|
93
|
+
var EXCLUDED = [["mcp"]];
|
|
94
|
+
var createAppServer = /* @__PURE__ */ __name((command, context, options) => {
|
|
95
|
+
const { app } = options;
|
|
96
|
+
const root = rootOf(command);
|
|
97
|
+
const environment = environmentOf(command);
|
|
98
|
+
if (!environment.runCommand)
|
|
99
|
+
throw new Error("the MCP server runs inside run(), which hands it the program");
|
|
100
|
+
const program = { run: environment.runCommand, commands: describeProgram(root) };
|
|
101
|
+
const flags = command.optsWithGlobals();
|
|
102
|
+
const overrides = flags.permission ?? [];
|
|
103
|
+
const { settings } = context;
|
|
104
|
+
const levels = /* @__PURE__ */ __name(() => options.resolveSettings(flags, { env: context.env }).permissions, "levels");
|
|
105
|
+
const readOnly = /* @__PURE__ */ __name(() => readOnlyLockOf(app, context.env) !== void 0, "readOnly");
|
|
106
|
+
const authority = changesAuthorityAt(root);
|
|
107
|
+
const targets = judgedTargets(root);
|
|
108
|
+
const passed = Object.fromEntries(Object.entries(environment).filter(([key]) => !PER_RUN.has(key)));
|
|
109
|
+
const tools = toolsFromCommands(program.commands, {
|
|
110
|
+
includeUnavailable: true,
|
|
111
|
+
exclude: EXCLUDED,
|
|
112
|
+
levels: settings.permissions,
|
|
113
|
+
currentLevels: levels,
|
|
114
|
+
readOnly: readOnly(),
|
|
115
|
+
authority,
|
|
116
|
+
fetchOnly: fetchesOnlyAt(root),
|
|
117
|
+
permissions: options.permissions
|
|
118
|
+
});
|
|
119
|
+
const availability = /* @__PURE__ */ __name((one) => () => {
|
|
120
|
+
const permitted = one.availability?.() ?? { available: true };
|
|
121
|
+
if (!permitted.available)
|
|
122
|
+
return permitted;
|
|
123
|
+
return options.availability?.(one.path, settings.profile) ?? permitted;
|
|
124
|
+
}, "availability");
|
|
125
|
+
const commands = Object.fromEntries(tools.map((one) => [
|
|
126
|
+
one.command,
|
|
127
|
+
{
|
|
128
|
+
title: one.title,
|
|
129
|
+
description: one.description,
|
|
130
|
+
writes: one.writes,
|
|
131
|
+
availability: availability(one),
|
|
132
|
+
input: one.input,
|
|
133
|
+
run: /* @__PURE__ */ __name(async (input, ctx) => {
|
|
134
|
+
const own = options.availability?.(one.path, settings.profile);
|
|
135
|
+
if (own && !own.available)
|
|
136
|
+
return failed(new CliError("permission_error", `${one.command}: ${own.reason ?? "unavailable for this profile"}`, {
|
|
137
|
+
...own.permission ? { permission: own.permission } : {}
|
|
138
|
+
}), app.errors);
|
|
139
|
+
const traceparent = ctx?.mcpReq?._meta?.traceparent;
|
|
140
|
+
const env = typeof traceparent === "string" ? { ...context.env, TRACEPARENT: traceparent } : context.env;
|
|
141
|
+
const answer = await runCommandForAgent(program, one.path, input, {
|
|
142
|
+
profile: settings.profile,
|
|
143
|
+
readOnly: readOnly(),
|
|
144
|
+
env,
|
|
145
|
+
levels,
|
|
146
|
+
overrides,
|
|
147
|
+
authority,
|
|
148
|
+
permissions: options.permissions,
|
|
149
|
+
environment: passed
|
|
150
|
+
});
|
|
151
|
+
if ("error" in answer)
|
|
152
|
+
return mcpErrorResult(JSON.parse(agentJson(answer.error)));
|
|
153
|
+
try {
|
|
154
|
+
return answered(envelope(one.command, answer.result), DEFAULT_OUTPUT_BYTES, targets);
|
|
155
|
+
} catch (error) {
|
|
156
|
+
return failed(error, app.errors);
|
|
157
|
+
}
|
|
158
|
+
}, "run")
|
|
159
|
+
}
|
|
160
|
+
]));
|
|
161
|
+
const skill = options.skill ? skillResource(app, options.skill) : void 0;
|
|
162
|
+
const build = /* @__PURE__ */ __name(() => {
|
|
163
|
+
const server = new McpServer({ name: app.command, version: app.version }, {
|
|
164
|
+
instructions: appInstructions({
|
|
165
|
+
command: app.command,
|
|
166
|
+
name: options.name,
|
|
167
|
+
profile: settings.profile,
|
|
168
|
+
untrusted: options.untrusted,
|
|
169
|
+
...skill ? { skill: skill.instruction } : {}
|
|
170
|
+
})
|
|
171
|
+
});
|
|
172
|
+
registerCommands(server, app.command, commands, app.errors, void 0, app.messenger);
|
|
173
|
+
if (skill) {
|
|
174
|
+
const { uri, name, title, description, mimeType, read } = skill;
|
|
175
|
+
server.registerResource(name, uri, { title, description, mimeType }, read);
|
|
176
|
+
}
|
|
177
|
+
return server;
|
|
178
|
+
}, "build");
|
|
179
|
+
return { build, offered: Object.keys(commands) };
|
|
180
|
+
}, "createAppServer");
|
|
181
|
+
var serveAppOverStdio = /* @__PURE__ */ __name(async (command, context, options) => {
|
|
182
|
+
const { build } = createAppServer(command, context, options);
|
|
183
|
+
const { stdin, stdout, signal } = environmentOf(command);
|
|
184
|
+
const own = stdin && stdout && stdin !== process.stdin;
|
|
185
|
+
const wire = answeredWire(own ? stdin : process.stdin, own ? stdout : process.stdout);
|
|
186
|
+
const handle = serveStdio(build, {
|
|
187
|
+
transport: new StdioServerTransport(wire.input, wire.output),
|
|
188
|
+
onerror: /* @__PURE__ */ __name((error) => context.renderer.note(`mcp: ${error.message}`), "onerror")
|
|
189
|
+
});
|
|
190
|
+
const ended = await new Promise((resolve) => {
|
|
191
|
+
wire.ended.then(() => resolve("input"));
|
|
192
|
+
if (own)
|
|
193
|
+
signal?.addEventListener("abort", () => resolve("stopped"), { once: true });
|
|
194
|
+
else {
|
|
195
|
+
process.once("SIGINT", () => resolve("stopped"));
|
|
196
|
+
process.once("SIGTERM", () => resolve("stopped"));
|
|
197
|
+
}
|
|
198
|
+
});
|
|
199
|
+
if (ended === "input")
|
|
200
|
+
await wire.answered();
|
|
201
|
+
wire.release();
|
|
202
|
+
await handle.close();
|
|
203
|
+
}, "serveAppOverStdio");
|
|
204
|
+
var serveAppOverHttp = /* @__PURE__ */ __name(async (command, context, options, http) => {
|
|
205
|
+
const { app } = options;
|
|
206
|
+
const { build } = createAppServer(command, context, options);
|
|
207
|
+
const { serveOverHttp } = await import("./serve-ENPMIV6J.js");
|
|
208
|
+
const listening = await serveOverHttp(build, {
|
|
209
|
+
...http,
|
|
210
|
+
appName: app.command,
|
|
211
|
+
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"),
|
|
212
|
+
onError: /* @__PURE__ */ __name((error) => context.renderer.note(`mcp: ${error.message}`), "onError")
|
|
213
|
+
}).catch((error) => {
|
|
214
|
+
if (error.code === "EADDRINUSE")
|
|
215
|
+
throw new CliError("configuration_error", `port ${http.port} is in use \u2014 pass another with --port`);
|
|
216
|
+
throw error;
|
|
217
|
+
});
|
|
218
|
+
context.renderer.note(`serving on ${listening.url.href} \u2014 point your tunnel at it; connectors use ${mcpUrlOf(http.publicUrl).href}`);
|
|
219
|
+
await new Promise((resolve) => {
|
|
220
|
+
process.once("SIGINT", resolve);
|
|
221
|
+
process.once("SIGTERM", resolve);
|
|
222
|
+
});
|
|
223
|
+
await listening.close();
|
|
224
|
+
}, "serveAppOverHttp");
|
|
225
|
+
export {
|
|
226
|
+
createAppServer,
|
|
227
|
+
serveAppOverHttp,
|
|
228
|
+
serveAppOverStdio
|
|
229
|
+
};
|