@wirecat/drive-cli 0.43.0 → 0.45.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/bin/drive.js +35 -40
- package/dist/bundle/all-profiles-LTHNCWQW.js +26 -0
- package/dist/bundle/anthropic-NOJEF3V2.js +71 -0
- package/dist/bundle/bun-ADJVI4HY.js +169 -0
- package/dist/bundle/bun-sqlite-GNXLBF2A.js +70 -0
- package/dist/bundle/chunk-2FTZBZOB.js +2315 -0
- package/dist/bundle/chunk-2YU3CXFD.js +3391 -0
- package/dist/bundle/chunk-35GRI4DI.js +375 -0
- package/dist/bundle/chunk-37MAA6F2.js +5624 -0
- package/dist/bundle/chunk-3V6NPZY7.js +2352 -0
- package/dist/bundle/chunk-4TIC23D2.js +9 -0
- package/dist/bundle/chunk-4TQSNQVV.js +1071 -0
- package/dist/bundle/chunk-4UE7AVHZ.js +150 -0
- package/dist/bundle/chunk-5DPV7X27.js +663 -0
- package/dist/bundle/chunk-5FONRUG6.js +24805 -0
- package/dist/bundle/chunk-5ZVLM6YR.js +19 -0
- package/dist/bundle/chunk-64WJYT2F.js +3954 -0
- package/dist/bundle/chunk-65GGKAQ7.js +82 -0
- package/dist/bundle/chunk-66N2DGGC.js +515 -0
- package/dist/bundle/chunk-6KFA6HOM.js +2941 -0
- package/dist/bundle/chunk-6Y2BYFXQ.js +65 -0
- package/dist/bundle/chunk-7NCG2SHR.js +74 -0
- package/dist/bundle/chunk-7PVNJAQ2.js +73 -0
- package/dist/bundle/chunk-7XWUOCGW.js +190 -0
- package/dist/bundle/chunk-A6ZKTNTZ.js +168 -0
- package/dist/bundle/chunk-ADLS6FVG.js +24600 -0
- package/dist/bundle/chunk-AH3SNVCV.js +498 -0
- package/dist/bundle/chunk-AN3GVZTU.js +76 -0
- package/dist/bundle/chunk-BPBIBVFH.js +166 -0
- package/dist/bundle/chunk-C4XP5T73.js +264 -0
- package/dist/bundle/chunk-C6SMAEED.js +18102 -0
- package/dist/bundle/chunk-CDI67JSB.js +1092 -0
- package/dist/bundle/chunk-CEO5HPRL.js +25 -0
- package/dist/bundle/chunk-CFT7UHF6.js +15572 -0
- package/dist/bundle/chunk-DC4T3FNP.js +1913 -0
- package/dist/bundle/chunk-DCTXOMOR.js +35 -0
- package/dist/bundle/chunk-DFDN6AUB.js +21 -0
- package/dist/bundle/chunk-EVWXODYV.js +754 -0
- package/dist/bundle/chunk-GKHM6I64.js +2356 -0
- package/dist/bundle/chunk-GNI7INK6.js +18 -0
- package/dist/bundle/chunk-GTYY6BIE.js +58 -0
- package/dist/bundle/chunk-GX4WEMAG.js +164 -0
- package/dist/bundle/chunk-HA3WCVGY.js +8179 -0
- package/dist/bundle/chunk-HLONHTSG.js +281 -0
- package/dist/bundle/chunk-HOIUIKWS.js +236 -0
- package/dist/bundle/chunk-HTQTIKWP.js +928 -0
- package/dist/bundle/chunk-I5EJHKNC.js +111 -0
- package/dist/bundle/chunk-ICKNJIGE.js +31 -0
- package/dist/bundle/chunk-IGB5CJCA.js +62 -0
- package/dist/bundle/chunk-IP4OK7RQ.js +24 -0
- package/dist/bundle/chunk-IVQ6342B.js +2 -0
- package/dist/bundle/chunk-K4N2DKE5.js +17 -0
- package/dist/bundle/chunk-LNB7BIZL.js +844 -0
- package/dist/bundle/chunk-LVDHWNJF.js +193 -0
- package/dist/bundle/chunk-LW2G4U6W.js +570 -0
- package/dist/bundle/chunk-LWT55XC5.js +60 -0
- package/dist/bundle/chunk-LY26NW3I.js +6848 -0
- package/dist/bundle/chunk-MJR2OTO4.js +1714 -0
- package/dist/bundle/chunk-MWUITL6N.js +42 -0
- package/dist/bundle/chunk-N47CYWEM.js +454 -0
- package/dist/bundle/chunk-NKZ6V4JW.js +263 -0
- package/dist/bundle/chunk-NQ6LLDDC.js +161 -0
- package/dist/bundle/chunk-NZIHPYY5.js +215 -0
- package/dist/bundle/chunk-OECPFZLP.js +3541 -0
- package/dist/bundle/chunk-P5KGFT7U.js +18 -0
- package/dist/bundle/chunk-PDH2QQQV.js +484 -0
- package/dist/bundle/chunk-PIN5RZ3D.js +63 -0
- package/dist/bundle/chunk-PJDO7AFZ.js +421 -0
- package/dist/bundle/chunk-PWKXHDBQ.js +18078 -0
- package/dist/bundle/chunk-QLZGLPJL.js +100 -0
- package/dist/bundle/chunk-SBZB7HMU.js +1055 -0
- package/dist/bundle/chunk-SGOPYPVW.js +835 -0
- package/dist/bundle/chunk-TDC6JGDA.js +630 -0
- package/dist/bundle/chunk-TOYPN2XX.js +288 -0
- package/dist/bundle/chunk-UC44ZMQV.js +78 -0
- package/dist/bundle/chunk-V7GN5BI7.js +99 -0
- package/dist/bundle/chunk-VO4KOLQZ.js +119 -0
- package/dist/bundle/chunk-WPGCDWPU.js +1855 -0
- package/dist/bundle/chunk-WQMVSQPP.js +886 -0
- package/dist/bundle/chunk-WZUJKUBK.js +384 -0
- package/dist/bundle/chunk-X5DFDGWS.js +2 -0
- package/dist/bundle/chunk-XFLCVHSQ.js +50 -0
- package/dist/bundle/chunk-XPEWOPJR.js +431 -0
- package/dist/bundle/chunk-Y5E2WNWB.js +35 -0
- package/dist/bundle/chunk-Y5EJSZXV.js +220 -0
- package/dist/bundle/chunk-YE3J6DLY.js +106 -0
- package/dist/bundle/chunk-YFLKH3NZ.js +48 -0
- package/dist/bundle/chunk-YJX4X564.js +138 -0
- package/dist/bundle/chunk-YJZBJ2TM.js +71 -0
- package/dist/bundle/chunk-Z4O6C7WR.js +1973 -0
- package/dist/bundle/chunk-ZIHLE7LG.js +15992 -0
- package/dist/bundle/chunk-ZPMLLONT.js +1054 -0
- package/dist/bundle/chunk-ZQNXKWUY.js +35584 -0
- package/dist/bundle/chunk-ZS635F4O.js +45 -0
- package/dist/bundle/chunk-ZU732VCC.js +122 -0
- package/dist/bundle/chunk-ZVVMGPBJ.js +50 -0
- package/dist/bundle/command-contract-HX35D7KV.js +38 -0
- package/dist/bundle/dist-MWTMOYWT.js +7577 -0
- package/dist/bundle/dist-PY3MVR3G.js +21 -0
- package/dist/bundle/drive.js +50 -0
- package/dist/bundle/echarts-RFTK737T.js +42501 -0
- package/dist/bundle/embed-5NAGJUMD.js +37 -0
- package/dist/bundle/embedder-EWXLIGBY.js +110 -0
- package/dist/bundle/entry-YCPJ6H6U.js +15 -0
- package/dist/bundle/failure-XBWHHBEW.js +37 -0
- package/dist/bundle/first-run-LNAZDBB4.js +24 -0
- package/dist/bundle/first-screen-P5NNFJD7.js +36 -0
- package/dist/bundle/google-5FFKRHHC.js +32 -0
- package/dist/bundle/google-api-TJCFOOAP.js +82 -0
- package/dist/bundle/identity-53ZMPL2O.js +10 -0
- package/dist/bundle/instructions-FHNL7CMW.js +9 -0
- package/dist/bundle/login-VXXZZR6G.js +158 -0
- package/dist/bundle/mcp-2CJCJXSW.js +95 -0
- package/dist/bundle/mcp-F4XZO76F.js +507 -0
- package/dist/bundle/mcp-IXFC2VVR.js +165 -0
- package/dist/bundle/mdast-util-from-markdown-FXEPSNER.js +1958 -0
- package/dist/bundle/mdast-util-gfm-SZM5GBDF.js +2103 -0
- package/dist/bundle/micromark-extension-gfm-GRL24TU6.js +1838 -0
- package/dist/bundle/node-P4E63KXA.js +2340 -0
- package/dist/bundle/node-TLZSIHIJ.js +21 -0
- package/dist/bundle/node-ZMCACJVS.js +176 -0
- package/dist/bundle/node-sqlite-QJQ5S7KS.js +46 -0
- package/dist/bundle/oauth-TZFDPAFE.js +18 -0
- package/dist/bundle/open-IYM25QTL.js +20 -0
- package/dist/bundle/process-ZPTLNVQS.js +91 -0
- package/dist/bundle/program-YX7DZMPR.js +24100 -0
- package/dist/bundle/prompt-TGWTVIEK.js +13 -0
- package/dist/bundle/reasons-Q5LOQESQ.js +11 -0
- package/dist/bundle/recognize-AGPMWKIY.js +191 -0
- package/dist/bundle/remote-QV7QSLAK.js +28 -0
- package/dist/bundle/rerank-HZKJJCS4.js +51 -0
- package/dist/bundle/serve-NRJQOVT4.js +20 -0
- package/dist/bundle/server-2UQDEWTS.js +818 -0
- package/dist/bundle/server-R4JUHFSW.js +56 -0
- package/dist/bundle/services-NZQWVMOE.js +333 -0
- package/dist/bundle/sqlite-runtime-6MXHTYYU.js +17 -0
- package/dist/bundle/state-IF2FLTSY.js +34 -0
- package/dist/bundle/store-HBD54IRL.js +142 -0
- package/dist/bundle/store-HVIBXOXS.js +125 -0
- package/dist/bundle/store-maintenance-command-U3F4RGJB.js +57 -0
- package/dist/bundle/terminal-TFCTWLOS.js +11 -0
- package/dist/bundle/tokens-5D5YUA2Q.js +103 -0
- package/dist/commands/config.js +1 -1
- package/dist/commands/config.js.map +1 -1
- package/dist/commands/mcp.d.ts.map +1 -1
- package/dist/commands/mcp.js +106 -54
- package/dist/commands/mcp.js.map +1 -1
- package/dist/config.d.ts +3 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +3 -1
- package/dist/config.js.map +1 -1
- package/dist/contract-overrides.d.ts.map +1 -1
- package/dist/contract-overrides.js +123 -83
- package/dist/contract-overrides.js.map +1 -1
- package/dist/mcp.d.ts +14 -6
- package/dist/mcp.d.ts.map +1 -1
- package/dist/mcp.js +26 -12
- package/dist/mcp.js.map +1 -1
- package/dist/program.d.ts.map +1 -1
- package/dist/program.js +7 -5
- package/dist/program.js.map +1 -1
- package/dist/reasons.d.ts.map +1 -1
- package/dist/reasons.js +0 -1
- package/dist/reasons.js.map +1 -1
- package/dist/registry.d.ts +2 -2
- package/dist/registry.d.ts.map +1 -1
- package/dist/registry.js +8 -2
- package/dist/registry.js.map +1 -1
- package/dist/state.d.ts +6 -3
- package/dist/state.d.ts.map +1 -1
- package/dist/state.js +6 -3
- package/dist/state.js.map +1 -1
- package/dist/tokens.d.ts +4 -1
- package/dist/tokens.d.ts.map +1 -1
- package/dist/tokens.js +44 -8
- package/dist/tokens.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +7 -5
- package/scenarios/agent-access.md +2 -2
- package/skills/drive-cli/SKILL.md +2 -1
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import { createRequire as __bundleRequire } from "node:module";
|
|
2
|
+
const require = __bundleRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
listen
|
|
5
|
+
} from "./chunk-UC44ZMQV.js";
|
|
6
|
+
import {
|
|
7
|
+
ownerLogin
|
|
8
|
+
} from "./chunk-TOYPN2XX.js";
|
|
9
|
+
import {
|
|
10
|
+
WebStandardStreamableHTTPServerTransport,
|
|
11
|
+
createMcpHandler,
|
|
12
|
+
getOAuthProtectedResourceMetadataUrl,
|
|
13
|
+
hostHeaderValidationResponse,
|
|
14
|
+
isLegacyRequest,
|
|
15
|
+
oauthMetadataResponse,
|
|
16
|
+
requireBearerAuth
|
|
17
|
+
} from "./chunk-5FONRUG6.js";
|
|
18
|
+
import {
|
|
19
|
+
activityRecorder,
|
|
20
|
+
calledTools,
|
|
21
|
+
httpActivityFile,
|
|
22
|
+
httpLock
|
|
23
|
+
} from "./chunk-NQ6LLDDC.js";
|
|
24
|
+
import {
|
|
25
|
+
CliError
|
|
26
|
+
} from "./chunk-GKHM6I64.js";
|
|
27
|
+
import {
|
|
28
|
+
__name
|
|
29
|
+
} from "./chunk-ZVVMGPBJ.js";
|
|
30
|
+
|
|
31
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.469.0_@wirecat+cli-base@0.65.0_commander@15.0.0_typescript@7.0.2_vi_80b586dbc8b099637a6e461856c2ee6b/node_modules/@wirecat/cli-core/dist/mcp/http/serve.js
|
|
32
|
+
import { randomUUID } from "node:crypto";
|
|
33
|
+
var MCP_PATH = "/mcp";
|
|
34
|
+
var AS_METADATA = "/.well-known/oauth-authorization-server";
|
|
35
|
+
var LOCAL = ["localhost", "127.0.0.1"];
|
|
36
|
+
var MAX_SESSIONS = 20;
|
|
37
|
+
var MAX_LOGIN_BODY = 64 * 1024;
|
|
38
|
+
var SESSION_IDLE_MS = 60 * 60 * 1e3;
|
|
39
|
+
var sessionMissing = /* @__PURE__ */ __name(() => new Response(JSON.stringify({ jsonrpc: "2.0", error: { code: -32001, message: "Session not found" }, id: null }), {
|
|
40
|
+
status: 404,
|
|
41
|
+
headers: { "content-type": "application/json" }
|
|
42
|
+
}), "sessionMissing");
|
|
43
|
+
var legacySessions = /* @__PURE__ */ __name((build, now) => {
|
|
44
|
+
const sessions = /* @__PURE__ */ new Map();
|
|
45
|
+
const drop = /* @__PURE__ */ __name(async (id) => {
|
|
46
|
+
const one = sessions.get(id);
|
|
47
|
+
sessions.delete(id);
|
|
48
|
+
await one?.close();
|
|
49
|
+
}, "drop");
|
|
50
|
+
const handle = /* @__PURE__ */ __name(async (request, auth) => {
|
|
51
|
+
for (const [id2, one] of sessions)
|
|
52
|
+
if (now() - one.seen > SESSION_IDLE_MS)
|
|
53
|
+
await drop(id2);
|
|
54
|
+
const id = request.headers.get("mcp-session-id");
|
|
55
|
+
if (id) {
|
|
56
|
+
const known = sessions.get(id);
|
|
57
|
+
if (!known || known.clientId !== auth.clientId)
|
|
58
|
+
return sessionMissing();
|
|
59
|
+
known.seen = now();
|
|
60
|
+
return known.transport.handleRequest(request, { authInfo: auth });
|
|
61
|
+
}
|
|
62
|
+
const server = build();
|
|
63
|
+
const transport = new WebStandardStreamableHTTPServerTransport({
|
|
64
|
+
sessionIdGenerator: /* @__PURE__ */ __name(() => randomUUID(), "sessionIdGenerator"),
|
|
65
|
+
onsessionclosed: /* @__PURE__ */ __name((closed) => void sessions.delete(closed), "onsessionclosed")
|
|
66
|
+
});
|
|
67
|
+
await server.connect(transport);
|
|
68
|
+
const response = await transport.handleRequest(request, { authInfo: auth });
|
|
69
|
+
if (!transport.sessionId) {
|
|
70
|
+
await server.close();
|
|
71
|
+
return response;
|
|
72
|
+
}
|
|
73
|
+
sessions.set(transport.sessionId, { transport, close: /* @__PURE__ */ __name(() => server.close(), "close"), clientId: auth.clientId, seen: now() });
|
|
74
|
+
while (sessions.size > MAX_SESSIONS)
|
|
75
|
+
await drop(sessions.keys().next().value);
|
|
76
|
+
return response;
|
|
77
|
+
}, "handle");
|
|
78
|
+
return {
|
|
79
|
+
handle,
|
|
80
|
+
close: /* @__PURE__ */ __name(async () => {
|
|
81
|
+
for (const id of [...sessions.keys()])
|
|
82
|
+
await drop(id);
|
|
83
|
+
}, "close")
|
|
84
|
+
};
|
|
85
|
+
}, "legacySessions");
|
|
86
|
+
var metadataRequest = /* @__PURE__ */ __name((request, path, base) => {
|
|
87
|
+
const url = new URL(request.url);
|
|
88
|
+
const inserted = base && path === `${AS_METADATA}${base}`;
|
|
89
|
+
if (!inserted && url.pathname === path)
|
|
90
|
+
return request;
|
|
91
|
+
url.pathname = inserted ? AS_METADATA : path;
|
|
92
|
+
return new Request(url, { method: request.method, headers: request.headers });
|
|
93
|
+
}, "metadataRequest");
|
|
94
|
+
var toolsIn = /* @__PURE__ */ __name(async (request) => {
|
|
95
|
+
if (request.method !== "POST")
|
|
96
|
+
return [];
|
|
97
|
+
try {
|
|
98
|
+
return calledTools(await request.clone().json());
|
|
99
|
+
} catch {
|
|
100
|
+
return [];
|
|
101
|
+
}
|
|
102
|
+
}, "toolsIn");
|
|
103
|
+
var serveOverHttp = /* @__PURE__ */ __name(async (build, options) => {
|
|
104
|
+
const { publicUrl, port, tokenFile, appName, onCode, onError, now, lockFile, version } = options;
|
|
105
|
+
const lock = lockFile ? httpLock(lockFile, {
|
|
106
|
+
pid: process.pid,
|
|
107
|
+
startedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
108
|
+
port,
|
|
109
|
+
publicUrl: publicUrl.href,
|
|
110
|
+
...version ? { version } : {}
|
|
111
|
+
}) : void 0;
|
|
112
|
+
if (lock?.held)
|
|
113
|
+
throw new CliError("validation_error", `${appName} already serves MCP over HTTP for this profile on port ${lock.held.port} (PID ${lock.held.pid}, since ${lock.held.startedAt})`);
|
|
114
|
+
const base = publicUrl.pathname === "/" ? "" : publicUrl.pathname.replace(/\/+$/, "");
|
|
115
|
+
const issuer = new URL(`${publicUrl.origin}${base}`);
|
|
116
|
+
const resource = new URL(`${base}${MCP_PATH}`, publicUrl.origin);
|
|
117
|
+
const mcpPath = resource.pathname;
|
|
118
|
+
const publicPath = /* @__PURE__ */ __name((path) => base && path !== base && !path.startsWith(`${base}/`) && !path.startsWith("/.well-known/") ? `${base}${path}` : path, "publicPath");
|
|
119
|
+
const login = ownerLogin({
|
|
120
|
+
issuer,
|
|
121
|
+
resource,
|
|
122
|
+
file: tokenFile,
|
|
123
|
+
appName,
|
|
124
|
+
onCode: /* @__PURE__ */ __name((code, expires) => {
|
|
125
|
+
lock?.update({ loginCode: code, loginCodeExpiresAt: expires.toISOString() });
|
|
126
|
+
onCode(code, expires);
|
|
127
|
+
}, "onCode"),
|
|
128
|
+
...now ? { now } : {}
|
|
129
|
+
});
|
|
130
|
+
const insecure = issuer.protocol === "http:" && LOCAL.includes(issuer.hostname);
|
|
131
|
+
const mcp = createMcpHandler(build, { legacy: "reject", ...onError ? { onerror: onError } : {} });
|
|
132
|
+
const legacy = legacySessions(build, now ?? Date.now);
|
|
133
|
+
const bearer = requireBearerAuth({
|
|
134
|
+
verifier: login.verifier,
|
|
135
|
+
resourceMetadataUrl: getOAuthProtectedResourceMetadataUrl(resource)
|
|
136
|
+
});
|
|
137
|
+
const activity = activityRecorder(httpActivityFile(tokenFile), now);
|
|
138
|
+
const allowedHosts = [.../* @__PURE__ */ new Set([publicUrl.hostname, ...LOCAL])];
|
|
139
|
+
const allowedOrigins = [publicUrl.origin];
|
|
140
|
+
const listening = await listen(async (request) => {
|
|
141
|
+
const refused = hostHeaderValidationResponse(request, allowedHosts);
|
|
142
|
+
if (refused)
|
|
143
|
+
return refused;
|
|
144
|
+
const path = publicPath(new URL(request.url).pathname);
|
|
145
|
+
const discovery = oauthMetadataResponse(metadataRequest(request, path, base), {
|
|
146
|
+
oauthMetadata: login.metadata,
|
|
147
|
+
resourceServerUrl: resource,
|
|
148
|
+
resourceName: appName,
|
|
149
|
+
...insecure ? { dangerouslyAllowInsecureIssuerUrl: true } : {}
|
|
150
|
+
});
|
|
151
|
+
if (discovery)
|
|
152
|
+
return discovery;
|
|
153
|
+
if (Number(request.headers.get("content-length") ?? 0) > MAX_LOGIN_BODY && path !== mcpPath)
|
|
154
|
+
return new Response("Request too large", { status: 413 });
|
|
155
|
+
const origin = request.headers.get("origin");
|
|
156
|
+
if (origin && !allowedOrigins.includes(origin))
|
|
157
|
+
return new Response("Origin not allowed", { status: 403 });
|
|
158
|
+
const answered = await login.handle(request, path);
|
|
159
|
+
if (answered)
|
|
160
|
+
return answered;
|
|
161
|
+
if (path !== mcpPath)
|
|
162
|
+
return new Response("Not found", { status: 404 });
|
|
163
|
+
const auth = await bearer(request);
|
|
164
|
+
if (auth instanceof Response)
|
|
165
|
+
return auth;
|
|
166
|
+
activity.record(auth.clientId, await toolsIn(request));
|
|
167
|
+
return await isLegacyRequest(request) ? legacy.handle(request, auth) : mcp.fetch(request, { authInfo: auth });
|
|
168
|
+
}, { host: "127.0.0.1", port }).catch((error) => {
|
|
169
|
+
login.close();
|
|
170
|
+
lock?.release();
|
|
171
|
+
throw error;
|
|
172
|
+
});
|
|
173
|
+
lock?.update({ listeningAt: (/* @__PURE__ */ new Date()).toISOString() });
|
|
174
|
+
return {
|
|
175
|
+
url: listening.url,
|
|
176
|
+
close: /* @__PURE__ */ __name(async () => {
|
|
177
|
+
login.close();
|
|
178
|
+
activity.flush();
|
|
179
|
+
try {
|
|
180
|
+
await listening.close();
|
|
181
|
+
await legacy.close();
|
|
182
|
+
await mcp.close();
|
|
183
|
+
} finally {
|
|
184
|
+
lock?.release();
|
|
185
|
+
}
|
|
186
|
+
}, "close")
|
|
187
|
+
};
|
|
188
|
+
}, "serveOverHttp");
|
|
189
|
+
|
|
190
|
+
export {
|
|
191
|
+
MCP_PATH,
|
|
192
|
+
serveOverHttp
|
|
193
|
+
};
|