@wirecat/zoom-cli 0.55.0 → 0.57.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 +4 -4
- package/dist/bin/zm.js +35 -5
- package/dist/bundle/all-profiles-EKHWTGOY.js +25 -0
- package/dist/bundle/answer-policy-KH2IFXPN.js +96 -0
- package/dist/bundle/anthropic-VL54IUGF.js +70 -0
- package/dist/bundle/bun-ADJVI4HY.js +169 -0
- package/dist/bundle/bun-sqlite-2SDA3YOT.js +69 -0
- package/dist/bundle/chunk-2IKY7VBH.js +9 -0
- package/dist/bundle/chunk-2WOGZDZG.js +431 -0
- package/dist/bundle/chunk-4R7HYNZS.js +73 -0
- package/dist/bundle/chunk-4VCA7QU3.js +538 -0
- package/dist/bundle/chunk-4YLS4YLS.js +29 -0
- package/dist/bundle/chunk-5D4AEUVA.js +24783 -0
- package/dist/bundle/chunk-5F7IOESV.js +281 -0
- package/dist/bundle/chunk-5QESMCQK.js +122 -0
- package/dist/bundle/chunk-6M6FJV5D.js +138 -0
- package/dist/bundle/chunk-6MX5T6AQ.js +17 -0
- package/dist/bundle/chunk-6P3YHT54.js +385 -0
- package/dist/bundle/chunk-7A6PZUDR.js +938 -0
- package/dist/bundle/chunk-7GUG6UZS.js +884 -0
- package/dist/bundle/chunk-7JZJMHQY.js +487 -0
- package/dist/bundle/chunk-A4ETXPMZ.js +98 -0
- package/dist/bundle/chunk-ADLS6FVG.js +24600 -0
- package/dist/bundle/chunk-AE4BOXH7.js +5292 -0
- package/dist/bundle/chunk-AN3GVZTU.js +76 -0
- package/dist/bundle/chunk-BAYNCCNM.js +215 -0
- package/dist/bundle/chunk-BW2WPOXP.js +166 -0
- package/dist/bundle/chunk-BW52AJ4R.js +3387 -0
- package/dist/bundle/chunk-CB5UTASG.js +18 -0
- package/dist/bundle/chunk-CLMXBW53.js +1028 -0
- package/dist/bundle/chunk-DCTXOMOR.js +35 -0
- package/dist/bundle/chunk-DFDN6AUB.js +21 -0
- package/dist/bundle/chunk-EOQFWJJD.js +1095 -0
- package/dist/bundle/chunk-G4R4ZIGD.js +3569 -0
- package/dist/bundle/chunk-G4VZDINN.js +161 -0
- package/dist/bundle/chunk-GARCOIB6.js +409 -0
- package/dist/bundle/chunk-GKMGS7G5.js +1938 -0
- package/dist/bundle/chunk-HCNMFFG3.js +82 -0
- package/dist/bundle/chunk-HG5KRV55.js +1970 -0
- package/dist/bundle/chunk-HKYLSIZ2.js +82 -0
- package/dist/bundle/chunk-HTQTIKWP.js +928 -0
- package/dist/bundle/chunk-I4VQDXFR.js +100 -0
- package/dist/bundle/chunk-ICSKEDPI.js +36139 -0
- package/dist/bundle/chunk-IP4OK7RQ.js +24 -0
- package/dist/bundle/chunk-IVQ6342B.js +2 -0
- package/dist/bundle/chunk-K72SEMYI.js +160 -0
- package/dist/bundle/chunk-LHRCJYFC.js +19 -0
- package/dist/bundle/chunk-LPTIQLDW.js +192 -0
- package/dist/bundle/chunk-LQ3T2ZIX.js +124 -0
- package/dist/bundle/chunk-LSVI3A5X.js +836 -0
- package/dist/bundle/chunk-LW2G4U6W.js +570 -0
- package/dist/bundle/chunk-LXB6ONWC.js +3517 -0
- package/dist/bundle/chunk-LY26NW3I.js +6848 -0
- package/dist/bundle/chunk-MAEFLDHG.js +6092 -0
- package/dist/bundle/chunk-MZH4GDR4.js +45 -0
- package/dist/bundle/chunk-NN5B24KP.js +1109 -0
- package/dist/bundle/chunk-NO7CJEYV.js +22 -0
- package/dist/bundle/chunk-NTDWAAGL.js +18435 -0
- package/dist/bundle/chunk-NW3X3G5X.js +264 -0
- package/dist/bundle/chunk-O66V2WHK.js +48 -0
- package/dist/bundle/chunk-OCGPZHXW.js +25 -0
- package/dist/bundle/chunk-OIHDCGV4.js +151 -0
- package/dist/bundle/chunk-OVSWVPXL.js +8190 -0
- package/dist/bundle/chunk-PIN5RZ3D.js +63 -0
- package/dist/bundle/chunk-QLIB3PEC.js +1146 -0
- package/dist/bundle/chunk-QTR6D5HT.js +58 -0
- package/dist/bundle/chunk-QUJPQMHJ.js +2315 -0
- package/dist/bundle/chunk-R3HPOCZD.js +188 -0
- package/dist/bundle/chunk-RMV4C2YL.js +482 -0
- package/dist/bundle/chunk-RRRBMQ2E.js +844 -0
- package/dist/bundle/chunk-S4S7E54J.js +60 -0
- package/dist/bundle/chunk-SB6WOSHG.js +1109 -0
- package/dist/bundle/chunk-SE75DPBY.js +31 -0
- package/dist/bundle/chunk-SQJ7EH2D.js +97 -0
- package/dist/bundle/chunk-TKCHUT2H.js +422 -0
- package/dist/bundle/chunk-TLQUKHEM.js +193 -0
- package/dist/bundle/chunk-TZ2MKETI.js +100 -0
- package/dist/bundle/chunk-UC44ZMQV.js +78 -0
- package/dist/bundle/chunk-UI5UTMSZ.js +275 -0
- package/dist/bundle/chunk-VPPYYWOH.js +630 -0
- package/dist/bundle/chunk-WJHK5D7Z.js +35612 -0
- package/dist/bundle/chunk-WQ24UC44.js +239 -0
- package/dist/bundle/chunk-X5DFDGWS.js +2 -0
- package/dist/bundle/chunk-Y5E2WNWB.js +35 -0
- package/dist/bundle/chunk-YB4DMKYX.js +119 -0
- package/dist/bundle/chunk-Z4TZ6TAF.js +288 -0
- package/dist/bundle/chunk-ZVVMGPBJ.js +50 -0
- package/dist/bundle/cli-72EQATJF.js +825 -0
- package/dist/bundle/command-contract-4MHSZUN3.js +38 -0
- package/dist/bundle/config-GFIJK6G2.js +79 -0
- package/dist/bundle/dist-IBNHCQXT.js +136 -0
- package/dist/bundle/dist-XUFQCJXW.js +7577 -0
- package/dist/bundle/echarts-RFTK737T.js +42501 -0
- package/dist/bundle/embed-7QYA2ZZE.js +35 -0
- package/dist/bundle/embedder-YNN6PCHG.js +108 -0
- package/dist/bundle/first-run-EVSRQKZJ.js +23 -0
- package/dist/bundle/first-screen-RG4GUKW7.js +36 -0
- package/dist/bundle/folders-JEPOMYM4.js +13 -0
- package/dist/bundle/instructions-FHNL7CMW.js +9 -0
- package/dist/bundle/main-NYGJXPH7.js +130 -0
- package/dist/bundle/mcp-IXFC2VVR.js +165 -0
- package/dist/bundle/mcp-VGSZDCKK.js +189 -0
- package/dist/bundle/mcp-XKP2PXLS.js +92 -0
- package/dist/bundle/meetings-IBPI4MM4.js +215 -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-ZNGOBA5Q.js +45 -0
- package/dist/bundle/oauth-Q6LKF7DB.js +17 -0
- package/dist/bundle/open-LJ332Y5O.js +19 -0
- package/dist/bundle/output-file-RYQZ3RTE.js +63 -0
- package/dist/bundle/process-ZPTLNVQS.js +91 -0
- package/dist/bundle/program-IBRQBQ6W.js +5845 -0
- package/dist/bundle/prompt-RT7GUUXH.js +12 -0
- package/dist/bundle/recognize-QXGE7YJH.js +190 -0
- package/dist/bundle/remote-FD4MZQV3.js +26 -0
- package/dist/bundle/rerank-V6AVV755.js +49 -0
- package/dist/bundle/run-log-RE2EI3UU.js +111 -0
- package/dist/bundle/serve-HIJTFAW7.js +19 -0
- package/dist/bundle/server-3QOXOYYL.js +53 -0
- package/dist/bundle/server-WLJCU7KK.js +812 -0
- package/dist/bundle/services-KC5KQFBS.js +330 -0
- package/dist/bundle/speech-5JOXLYDA.js +44 -0
- package/dist/bundle/state-PPGRB3T6.js +33 -0
- package/dist/bundle/store-LODVDPK3.js +141 -0
- package/dist/bundle/store-WB5BICTG.js +124 -0
- package/dist/bundle/store-connection-EG6Z5ITP.js +76 -0
- package/dist/bundle/store-maintenance-command-Q5WMFUZ2.js +54 -0
- package/dist/bundle/streaming-UGFFNOXL.js +15 -0
- package/dist/bundle/tokens-AF5CPY2F.js +17 -0
- package/dist/bundle/zm.js +8 -0
- package/dist/commands.js +2 -2
- package/dist/commands.js.map +1 -1
- package/dist/config-issues.d.ts.map +1 -1
- package/dist/config-issues.js +3 -0
- package/dist/config-issues.js.map +1 -1
- package/dist/config.d.ts +3 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +23 -0
- package/dist/config.js.map +1 -1
- package/dist/contract-overrides.d.ts.map +1 -1
- package/dist/contract-overrides.js +34 -45
- package/dist/contract-overrides.js.map +1 -1
- package/dist/first-screen.js +1 -1
- package/dist/first-screen.js.map +1 -1
- package/dist/mcp-command.d.ts +5 -3
- package/dist/mcp-command.d.ts.map +1 -1
- package/dist/mcp-command.js +73 -15
- package/dist/mcp-command.js.map +1 -1
- package/dist/program-bindings.d.ts.map +1 -1
- package/dist/program-bindings.js +1 -0
- package/dist/program-bindings.js.map +1 -1
- package/dist/recording-archive.d.ts.map +1 -1
- package/dist/recording-archive.js +9 -4
- package/dist/recording-archive.js.map +1 -1
- package/dist/remote-http.d.ts +2 -0
- package/dist/remote-http.d.ts.map +1 -1
- package/dist/remote-http.js +21 -11
- package/dist/remote-http.js.map +1 -1
- package/dist/request-events.d.ts +12 -0
- package/dist/request-events.d.ts.map +1 -1
- package/dist/request-events.js +56 -4
- package/dist/request-events.js.map +1 -1
- package/dist/run.d.ts.map +1 -1
- package/dist/run.js +4 -1
- package/dist/run.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +7 -5
- package/skills/zoom-cli/SKILL.md +3 -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-Z4TZ6TAF.js";
|
|
9
|
+
import {
|
|
10
|
+
activityRecorder,
|
|
11
|
+
calledTools,
|
|
12
|
+
httpActivityFile,
|
|
13
|
+
httpLock
|
|
14
|
+
} from "./chunk-G4VZDINN.js";
|
|
15
|
+
import {
|
|
16
|
+
WebStandardStreamableHTTPServerTransport,
|
|
17
|
+
createMcpHandler,
|
|
18
|
+
getOAuthProtectedResourceMetadataUrl,
|
|
19
|
+
hostHeaderValidationResponse,
|
|
20
|
+
isLegacyRequest,
|
|
21
|
+
oauthMetadataResponse,
|
|
22
|
+
requireBearerAuth
|
|
23
|
+
} from "./chunk-5D4AEUVA.js";
|
|
24
|
+
import {
|
|
25
|
+
CliError
|
|
26
|
+
} from "./chunk-AE4BOXH7.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
|
+
};
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { createRequire as __bundleRequire } from "node:module";
|
|
2
|
+
const require = __bundleRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
CliError
|
|
5
|
+
} from "./chunk-AE4BOXH7.js";
|
|
6
|
+
import {
|
|
7
|
+
__name
|
|
8
|
+
} from "./chunk-ZVVMGPBJ.js";
|
|
9
|
+
|
|
10
|
+
// 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/store/driver.js
|
|
11
|
+
var PRAGMAS = `
|
|
12
|
+
PRAGMA busy_timeout = 5000;
|
|
13
|
+
PRAGMA journal_mode = WAL;
|
|
14
|
+
PRAGMA foreign_keys = ON;
|
|
15
|
+
`;
|
|
16
|
+
|
|
17
|
+
// 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/store/sqlite-warning.js
|
|
18
|
+
var SQLITE_WARNING = "SQLite is an experimental feature";
|
|
19
|
+
var quieted = /* @__PURE__ */ new WeakSet();
|
|
20
|
+
var quietSqliteWarning = /* @__PURE__ */ __name((host = process) => {
|
|
21
|
+
if (quieted.has(host))
|
|
22
|
+
return;
|
|
23
|
+
quieted.add(host);
|
|
24
|
+
const emit = host.emitWarning;
|
|
25
|
+
host.emitWarning = function(warning, ...rest) {
|
|
26
|
+
if (isSqliteWarning(warning, rest[0]))
|
|
27
|
+
return;
|
|
28
|
+
return Reflect.apply(emit, this, [warning, ...rest]);
|
|
29
|
+
};
|
|
30
|
+
}, "quietSqliteWarning");
|
|
31
|
+
var isSqliteWarning = /* @__PURE__ */ __name((warning, options) => {
|
|
32
|
+
const type = typeof options === "string" ? options : options?.type;
|
|
33
|
+
const name = typeof warning === "string" ? type : warning.name;
|
|
34
|
+
const message = typeof warning === "string" ? warning : warning.message;
|
|
35
|
+
return name === "ExperimentalWarning" && message.startsWith(SQLITE_WARNING);
|
|
36
|
+
}, "isSqliteWarning");
|
|
37
|
+
|
|
38
|
+
// 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/store/open.js
|
|
39
|
+
var openCache = /* @__PURE__ */ __name(async (path) => {
|
|
40
|
+
const database = await openFile(path);
|
|
41
|
+
try {
|
|
42
|
+
database.exec(PRAGMAS);
|
|
43
|
+
} catch (error) {
|
|
44
|
+
database.close();
|
|
45
|
+
throw error;
|
|
46
|
+
}
|
|
47
|
+
return database;
|
|
48
|
+
}, "openCache");
|
|
49
|
+
var openFile = /* @__PURE__ */ __name((path) => "Bun" in globalThis ? openUnderBun(path) : openUnderNode(path), "openFile");
|
|
50
|
+
var openUnderBun = /* @__PURE__ */ __name(async (path) => {
|
|
51
|
+
const { openWithBunSqlite } = await import("./bun-sqlite-2SDA3YOT.js");
|
|
52
|
+
return await openWithBunSqlite(path);
|
|
53
|
+
}, "openUnderBun");
|
|
54
|
+
var openUnderNode = /* @__PURE__ */ __name(async (path) => {
|
|
55
|
+
quietSqliteWarning();
|
|
56
|
+
const { openWithNodeSqlite } = await import("./node-sqlite-ZNGOBA5Q.js");
|
|
57
|
+
return openWithNodeSqlite(path);
|
|
58
|
+
}, "openUnderNode");
|
|
59
|
+
var runtime = /* @__PURE__ */ __name(() => {
|
|
60
|
+
const bun = globalThis.Bun;
|
|
61
|
+
return bun ? `Bun ${bun.version}` : `Node ${process.versions.node}`;
|
|
62
|
+
}, "runtime");
|
|
63
|
+
var CAPABILITY_STATEMENTS = [
|
|
64
|
+
`CREATE VIRTUAL TABLE temp.capability_words USING fts5(a, content = '', contentless_delete = 1,
|
|
65
|
+
tokenize = 'unicode61 remove_diacritics 2')`,
|
|
66
|
+
"CREATE VIRTUAL TABLE temp.capability_text USING fts5(a, tokenize = 'trigram')",
|
|
67
|
+
"DROP TABLE temp.capability_words",
|
|
68
|
+
"DROP TABLE temp.capability_text"
|
|
69
|
+
];
|
|
70
|
+
var assertStoreCapable = /* @__PURE__ */ __name((database, on = runtime()) => {
|
|
71
|
+
try {
|
|
72
|
+
for (const statement of CAPABILITY_STATEMENTS)
|
|
73
|
+
database.exec(statement);
|
|
74
|
+
} catch (error) {
|
|
75
|
+
const version = String(database.prepare("SELECT sqlite_version() AS version").get()?.version);
|
|
76
|
+
const remedy = on.startsWith("Bun") ? "Run it under Node 22.16 or newer instead" : "Update Node to 22.16 or newer, or run it under Bun";
|
|
77
|
+
throw new CliError("configuration_error", `the message store needs full-text search that this SQLite (${version}, ${on}) does not have. ${remedy}.`, { sqlite: version, runtime: on, cause: error instanceof Error ? error.message : String(error) });
|
|
78
|
+
}
|
|
79
|
+
}, "assertStoreCapable");
|
|
80
|
+
var capable;
|
|
81
|
+
var storeCapable = /* @__PURE__ */ __name(() => {
|
|
82
|
+
capable ??= openCache(":memory:").then((database) => {
|
|
83
|
+
try {
|
|
84
|
+
assertStoreCapable(database);
|
|
85
|
+
} finally {
|
|
86
|
+
database.close();
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
return capable;
|
|
90
|
+
}, "storeCapable");
|
|
91
|
+
|
|
92
|
+
export {
|
|
93
|
+
PRAGMAS,
|
|
94
|
+
quietSqliteWarning,
|
|
95
|
+
openCache,
|
|
96
|
+
openFile,
|
|
97
|
+
CAPABILITY_STATEMENTS,
|
|
98
|
+
assertStoreCapable,
|
|
99
|
+
storeCapable
|
|
100
|
+
};
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { createRequire as __bundleRequire } from "node:module";
|
|
2
|
+
const require = __bundleRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
__name
|
|
5
|
+
} from "./chunk-ZVVMGPBJ.js";
|
|
6
|
+
|
|
7
|
+
// 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/http/listen.js
|
|
8
|
+
import { createServer } from "node:http";
|
|
9
|
+
import { Readable } from "node:stream";
|
|
10
|
+
var MAX_BODY = 4 * 1024 * 1024;
|
|
11
|
+
var TooLarge = class extends Error {
|
|
12
|
+
static {
|
|
13
|
+
__name(this, "TooLarge");
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
var readBody = /* @__PURE__ */ __name((incoming, limit) => new Promise((resolve, reject) => {
|
|
17
|
+
if (Number(incoming.headers["content-length"] ?? 0) > limit)
|
|
18
|
+
return reject(new TooLarge());
|
|
19
|
+
const chunks = [];
|
|
20
|
+
let size = 0;
|
|
21
|
+
incoming.on("data", (chunk) => {
|
|
22
|
+
size += chunk.length;
|
|
23
|
+
if (size > limit) {
|
|
24
|
+
incoming.destroy();
|
|
25
|
+
reject(new TooLarge());
|
|
26
|
+
} else
|
|
27
|
+
chunks.push(chunk);
|
|
28
|
+
});
|
|
29
|
+
incoming.once("end", () => resolve(Buffer.concat(chunks)));
|
|
30
|
+
incoming.once("error", reject);
|
|
31
|
+
}), "readBody");
|
|
32
|
+
var toRequest = /* @__PURE__ */ __name(async (incoming, origin, maxBody) => {
|
|
33
|
+
const headers = new Headers();
|
|
34
|
+
for (const [name, value] of Object.entries(incoming.headers)) {
|
|
35
|
+
if (Array.isArray(value))
|
|
36
|
+
for (const one of value)
|
|
37
|
+
headers.append(name, one);
|
|
38
|
+
else if (value !== void 0)
|
|
39
|
+
headers.set(name, value);
|
|
40
|
+
}
|
|
41
|
+
const method = incoming.method ?? "GET";
|
|
42
|
+
const body = method === "GET" || method === "HEAD" ? void 0 : await readBody(incoming, maxBody);
|
|
43
|
+
if (body)
|
|
44
|
+
headers.set("content-length", String(body.length));
|
|
45
|
+
return new Request(new URL(incoming.url ?? "/", origin), { method, headers, ...body ? { body } : {} });
|
|
46
|
+
}, "toRequest");
|
|
47
|
+
var send = /* @__PURE__ */ __name(async (response, outgoing) => {
|
|
48
|
+
outgoing.writeHead(response.status, Object.fromEntries(response.headers));
|
|
49
|
+
if (!response.body)
|
|
50
|
+
return void outgoing.end();
|
|
51
|
+
const body = Readable.fromWeb(response.body);
|
|
52
|
+
outgoing.once("close", () => body.destroy());
|
|
53
|
+
body.pipe(outgoing);
|
|
54
|
+
}, "send");
|
|
55
|
+
var listen = /* @__PURE__ */ __name((handle, { host, port, maxBody = MAX_BODY }) => new Promise((resolve, reject) => {
|
|
56
|
+
const server = createServer((incoming, outgoing) => {
|
|
57
|
+
toRequest(incoming, `http://${host}`, maxBody).then(handle).then((response) => send(response, outgoing)).catch((error) => {
|
|
58
|
+
if (!outgoing.headersSent)
|
|
59
|
+
outgoing.writeHead(error instanceof TooLarge ? 413 : 500, { connection: "close" });
|
|
60
|
+
outgoing.end();
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
server.once("error", reject);
|
|
64
|
+
server.listen(port, host, () => {
|
|
65
|
+
const { port: bound } = server.address();
|
|
66
|
+
resolve({
|
|
67
|
+
url: new URL(`http://${host}:${bound}`),
|
|
68
|
+
close: /* @__PURE__ */ __name(() => new Promise((done) => {
|
|
69
|
+
server.close(() => done());
|
|
70
|
+
server.closeAllConnections();
|
|
71
|
+
}), "close")
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
}), "listen");
|
|
75
|
+
|
|
76
|
+
export {
|
|
77
|
+
listen
|
|
78
|
+
};
|
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
import { createRequire as __bundleRequire } from "node:module";
|
|
2
|
+
const require = __bundleRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
envName,
|
|
5
|
+
readOnlyLockOf
|
|
6
|
+
} from "./chunk-OCGPZHXW.js";
|
|
7
|
+
import {
|
|
8
|
+
CAPABILITY_STATEMENTS,
|
|
9
|
+
storeCapable
|
|
10
|
+
} from "./chunk-TZ2MKETI.js";
|
|
11
|
+
import {
|
|
12
|
+
CliError,
|
|
13
|
+
catchCrashes
|
|
14
|
+
} from "./chunk-AE4BOXH7.js";
|
|
15
|
+
import {
|
|
16
|
+
importFrom
|
|
17
|
+
} from "./chunk-Y5E2WNWB.js";
|
|
18
|
+
import {
|
|
19
|
+
__name
|
|
20
|
+
} from "./chunk-ZVVMGPBJ.js";
|
|
21
|
+
|
|
22
|
+
// 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/cli/entry.js
|
|
23
|
+
import { spawn as spawn2 } from "node:child_process";
|
|
24
|
+
|
|
25
|
+
// 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/sqlite-runtime.js
|
|
26
|
+
import { spawn, spawnSync } from "node:child_process";
|
|
27
|
+
import { readFileSync } from "node:fs";
|
|
28
|
+
import { dirname } from "node:path";
|
|
29
|
+
var RESTARTED = "CLI_MESSAGING_SQLITE_RESTARTED";
|
|
30
|
+
var USER_LIBRARY_PATH = "CLI_MESSAGING_USER_LD_LIBRARY_PATH";
|
|
31
|
+
var FORWARDED = ["SIGTERM", "SIGHUP", "SIGQUIT"];
|
|
32
|
+
var ensureSqlite = /* @__PURE__ */ __name(async (runtime = nodeRuntime()) => {
|
|
33
|
+
const { env } = runtime;
|
|
34
|
+
if (env[RESTARTED]) {
|
|
35
|
+
if (env[USER_LIBRARY_PATH] === void 0)
|
|
36
|
+
delete env.LD_LIBRARY_PATH;
|
|
37
|
+
else
|
|
38
|
+
env.LD_LIBRARY_PATH = env[USER_LIBRARY_PATH];
|
|
39
|
+
delete env[USER_LIBRARY_PATH];
|
|
40
|
+
delete env[RESTARTED];
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
if (runtime.bun || runtime.platform !== "linux")
|
|
44
|
+
return;
|
|
45
|
+
const maps = runtime.maps();
|
|
46
|
+
if (!maps.includes("libsqlite3"))
|
|
47
|
+
return;
|
|
48
|
+
if (await runtime.capable())
|
|
49
|
+
return;
|
|
50
|
+
const library = await runtime.library(maps.includes("ld-musl"));
|
|
51
|
+
if (!library)
|
|
52
|
+
return;
|
|
53
|
+
const restarted = {
|
|
54
|
+
...env,
|
|
55
|
+
LD_LIBRARY_PATH: [dirname(library.path), env.LD_LIBRARY_PATH].filter(Boolean).join(":"),
|
|
56
|
+
[RESTARTED]: "1"
|
|
57
|
+
};
|
|
58
|
+
if (env.LD_LIBRARY_PATH !== void 0)
|
|
59
|
+
restarted[USER_LIBRARY_PATH] = env.LD_LIBRARY_PATH;
|
|
60
|
+
if (!runtime.works(restarted, library.version))
|
|
61
|
+
return;
|
|
62
|
+
await runtime.restart(restarted);
|
|
63
|
+
}, "ensureSqlite");
|
|
64
|
+
var trialScript = /* @__PURE__ */ __name((version) => `
|
|
65
|
+
const { DatabaseSync } = await import("node:sqlite")
|
|
66
|
+
const database = new DatabaseSync(":memory:")
|
|
67
|
+
if (database.prepare("SELECT sqlite_version() AS v").get().v !== ${JSON.stringify(version)}) process.exit(1)
|
|
68
|
+
for (const statement of ${JSON.stringify(CAPABILITY_STATEMENTS)}) database.exec(statement)
|
|
69
|
+
`, "trialScript");
|
|
70
|
+
var nodeRuntime = /* @__PURE__ */ __name(() => ({
|
|
71
|
+
env: process.env,
|
|
72
|
+
platform: process.platform,
|
|
73
|
+
bun: "Bun" in globalThis,
|
|
74
|
+
maps: /* @__PURE__ */ __name(() => {
|
|
75
|
+
try {
|
|
76
|
+
return readFileSync("/proc/self/maps", "utf8");
|
|
77
|
+
} catch {
|
|
78
|
+
return "";
|
|
79
|
+
}
|
|
80
|
+
}, "maps"),
|
|
81
|
+
capable: /* @__PURE__ */ __name(() => storeCapable().then(() => true, () => false), "capable"),
|
|
82
|
+
library: /* @__PURE__ */ __name(async (musl) => {
|
|
83
|
+
try {
|
|
84
|
+
const { libraryFor, SQLITE_VERSION } = await importFrom(new URL("sqlite-runtime.js", import.meta.resolve("@wirecat/cli-core")).href, "@wirecat/cli-core-sqlite");
|
|
85
|
+
const path = libraryFor({ musl });
|
|
86
|
+
return path === void 0 ? void 0 : { path, version: SQLITE_VERSION };
|
|
87
|
+
} catch {
|
|
88
|
+
return void 0;
|
|
89
|
+
}
|
|
90
|
+
}, "library"),
|
|
91
|
+
works: /* @__PURE__ */ __name((env, version) => spawnSync(process.execPath, ["--no-warnings", "--input-type=module", "-e", trialScript(version)], {
|
|
92
|
+
env,
|
|
93
|
+
stdio: "ignore",
|
|
94
|
+
timeout: 1e4
|
|
95
|
+
}).status === 0, "works"),
|
|
96
|
+
restart: /* @__PURE__ */ __name((env) => relay(spawn(process.execPath, [...process.execArgv, ...process.argv.slice(1)], { env, stdio: "inherit" })), "restart")
|
|
97
|
+
}), "nodeRuntime");
|
|
98
|
+
var relay = /* @__PURE__ */ __name((child, host = process) => new Promise(() => {
|
|
99
|
+
for (const signal of FORWARDED)
|
|
100
|
+
host.on(signal, () => child.kill(signal));
|
|
101
|
+
host.on("SIGINT", () => {
|
|
102
|
+
});
|
|
103
|
+
child.on("error", () => host.exit(1));
|
|
104
|
+
child.on("exit", (code, signal) => {
|
|
105
|
+
if (signal) {
|
|
106
|
+
host.removeAllListeners(signal);
|
|
107
|
+
host.kill(host.pid, signal);
|
|
108
|
+
} else
|
|
109
|
+
host.exit(code ?? 1);
|
|
110
|
+
});
|
|
111
|
+
}), "relay");
|
|
112
|
+
|
|
113
|
+
// 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/cli/argv-log.js
|
|
114
|
+
import { appendFileSync } from "node:fs";
|
|
115
|
+
var logParsedArgv = /* @__PURE__ */ __name((file, action) => {
|
|
116
|
+
const words = [];
|
|
117
|
+
const options = [];
|
|
118
|
+
for (let at = action; at; at = at.parent) {
|
|
119
|
+
if (at.parent)
|
|
120
|
+
words.unshift(at.name());
|
|
121
|
+
for (const option of at.options) {
|
|
122
|
+
const key = option.attributeName();
|
|
123
|
+
if (at.getOptionValueSource(key) !== "cli" || !option.long)
|
|
124
|
+
continue;
|
|
125
|
+
if (option.negate === (at.getOptionValue(key) === false))
|
|
126
|
+
options.push(option.long);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
appendFileSync(file, `${JSON.stringify({ command: words.join(" "), options })}
|
|
130
|
+
`);
|
|
131
|
+
}, "logParsedArgv");
|
|
132
|
+
var logVersion = /* @__PURE__ */ __name((file) => {
|
|
133
|
+
appendFileSync(file, `${JSON.stringify({ command: "", options: ["--version"] })}
|
|
134
|
+
`);
|
|
135
|
+
}, "logVersion");
|
|
136
|
+
|
|
137
|
+
// 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/cli/entry.js
|
|
138
|
+
var processIo = /* @__PURE__ */ __name(() => ({
|
|
139
|
+
argv: process.argv,
|
|
140
|
+
env: process.env,
|
|
141
|
+
platform: process.platform,
|
|
142
|
+
stdin: process.stdin,
|
|
143
|
+
stdout: process.stdout,
|
|
144
|
+
stderr: process.stderr,
|
|
145
|
+
signals: process,
|
|
146
|
+
setExitCode: /* @__PURE__ */ __name((code) => {
|
|
147
|
+
process.exitCode = code;
|
|
148
|
+
}, "setExitCode"),
|
|
149
|
+
spawn: spawn2
|
|
150
|
+
}), "processIo");
|
|
151
|
+
var startCli = /* @__PURE__ */ __name(async (entry) => {
|
|
152
|
+
const io = { ...processIo(), ...entry.io };
|
|
153
|
+
const args = io.argv.slice(2);
|
|
154
|
+
if (args.length === 1 && (args[0] === "--version" || args[0] === "-V"))
|
|
155
|
+
return printVersion(entry.app, io);
|
|
156
|
+
const tty = io.stdout.isTTY === true;
|
|
157
|
+
const release = catchCrashes({
|
|
158
|
+
cli: entry.app.command,
|
|
159
|
+
interactive: entry.interactive?.(args, tty) ?? tty,
|
|
160
|
+
...entry.reasons ? { reasons: entry.reasons } : {},
|
|
161
|
+
target: io.signals
|
|
162
|
+
});
|
|
163
|
+
const controller = new AbortController();
|
|
164
|
+
let closed = false;
|
|
165
|
+
let unwritable = false;
|
|
166
|
+
const interrupted = /* @__PURE__ */ __name((signal) => () => controller.abort(new CliError("cancelled", `command interrupted by ${signal}`, { reason: signal, retryable: false })), "interrupted");
|
|
167
|
+
const sigint = interrupted("SIGINT");
|
|
168
|
+
const sigterm = interrupted("SIGTERM");
|
|
169
|
+
const outputFailed = /* @__PURE__ */ __name((error) => {
|
|
170
|
+
if (error.code === "EPIPE") {
|
|
171
|
+
closed = true;
|
|
172
|
+
controller.abort(new CliError("cancelled", "output pipe closed", { retryable: false }));
|
|
173
|
+
} else {
|
|
174
|
+
unwritable = true;
|
|
175
|
+
controller.abort(new CliError("configuration_error", "could not write command output"));
|
|
176
|
+
}
|
|
177
|
+
}, "outputFailed");
|
|
178
|
+
const headless = /* @__PURE__ */ __name((command) => {
|
|
179
|
+
const flags = command?.optsWithGlobals() ?? {};
|
|
180
|
+
return Boolean(flags.json || flags.jsonl || flags.input === false || io.env.CI) || !tty;
|
|
181
|
+
}, "headless");
|
|
182
|
+
const context = {
|
|
183
|
+
args,
|
|
184
|
+
env: io.env,
|
|
185
|
+
tty,
|
|
186
|
+
signal: controller.signal,
|
|
187
|
+
atStart: /* @__PURE__ */ __name(async (command) => {
|
|
188
|
+
if (command.optsWithGlobals().dryRun === true)
|
|
189
|
+
return;
|
|
190
|
+
const [{ setupAtStart }, { commandPathOf }] = await Promise.all([
|
|
191
|
+
import("./first-run-EVSRQKZJ.js"),
|
|
192
|
+
import("./command-contract-4MHSZUN3.js")
|
|
193
|
+
]);
|
|
194
|
+
await setupAtStart({
|
|
195
|
+
command: entry.app.command,
|
|
196
|
+
env: io.env,
|
|
197
|
+
contentLanguages: entry.app.contentLanguages,
|
|
198
|
+
path: commandPathOf(command),
|
|
199
|
+
headless: headless(command),
|
|
200
|
+
readOnlyLock: readOnlyLockOf(entry.app, io.env),
|
|
201
|
+
input: io.stdin
|
|
202
|
+
});
|
|
203
|
+
}, "atStart"),
|
|
204
|
+
ask: /* @__PURE__ */ __name(async (question, command) => {
|
|
205
|
+
if (headless(command) || io.stdin.isTTY !== true)
|
|
206
|
+
return false;
|
|
207
|
+
const { readSecret } = await import("./prompt-RT7GUUXH.js");
|
|
208
|
+
const answer = await readSecret(`${question} [y/N] `, {
|
|
209
|
+
input: io.stdin,
|
|
210
|
+
output: io.stderr,
|
|
211
|
+
echo: true,
|
|
212
|
+
signal: controller.signal
|
|
213
|
+
});
|
|
214
|
+
return /^(y|yes)$/i.test(answer.trim());
|
|
215
|
+
}, "ask"),
|
|
216
|
+
openBrowser: /* @__PURE__ */ __name((url, browser) => openBrowser(io, url, browser), "openBrowser"),
|
|
217
|
+
outputClosed: /* @__PURE__ */ __name(() => closed, "outputClosed")
|
|
218
|
+
};
|
|
219
|
+
let code;
|
|
220
|
+
try {
|
|
221
|
+
if (entry.sqlite)
|
|
222
|
+
await ensureSqlite();
|
|
223
|
+
io.signals.on("SIGINT", sigint).on("SIGTERM", sigterm);
|
|
224
|
+
io.stdout.on("error", outputFailed);
|
|
225
|
+
io.stderr.on("error", outputFailed);
|
|
226
|
+
const returned = await entry.run(context);
|
|
227
|
+
if (typeof returned === "number")
|
|
228
|
+
code = returned;
|
|
229
|
+
} catch (error) {
|
|
230
|
+
code = commanderExit(error) ?? entry.fail(error, context);
|
|
231
|
+
} finally {
|
|
232
|
+
io.signals.off("SIGINT", sigint).off("SIGTERM", sigterm);
|
|
233
|
+
release();
|
|
234
|
+
}
|
|
235
|
+
if (closed)
|
|
236
|
+
io.setExitCode(0);
|
|
237
|
+
else if (unwritable)
|
|
238
|
+
io.setExitCode(3);
|
|
239
|
+
else if (code !== void 0)
|
|
240
|
+
io.setExitCode(code);
|
|
241
|
+
}, "startCli");
|
|
242
|
+
var printVersion = /* @__PURE__ */ __name((app, io) => {
|
|
243
|
+
const argvLog = io.env[envName(app, "TEST_ARGV_LOG")];
|
|
244
|
+
if (argvLog)
|
|
245
|
+
logVersion(argvLog);
|
|
246
|
+
io.stdout.write(`${app.version}
|
|
247
|
+
`);
|
|
248
|
+
}, "printVersion");
|
|
249
|
+
var commanderExit = /* @__PURE__ */ __name((error) => {
|
|
250
|
+
if (!(error instanceof Error))
|
|
251
|
+
return void 0;
|
|
252
|
+
const { code, exitCode } = error;
|
|
253
|
+
if (typeof code !== "string" || !code.startsWith("commander.") || typeof exitCode !== "number")
|
|
254
|
+
return void 0;
|
|
255
|
+
if (exitCode === 0)
|
|
256
|
+
return 0;
|
|
257
|
+
return code === "commander.help" ? 2 : void 0;
|
|
258
|
+
}, "commanderExit");
|
|
259
|
+
var openBrowser = /* @__PURE__ */ __name((io, url, browser) => {
|
|
260
|
+
const [command, prefix] = browser !== void 0 ? [browser, []] : io.platform === "darwin" ? ["open", []] : io.platform === "win32" ? ["rundll32.exe", ["url.dll,FileProtocolHandler"]] : ["xdg-open", []];
|
|
261
|
+
return new Promise((resolve, reject) => {
|
|
262
|
+
const child = io.spawn(command, [...prefix, url], { detached: true, stdio: "ignore", windowsHide: true });
|
|
263
|
+
child.once("error", () => reject(new CliError("configuration_error", `could not start ${command} \u2014 open the printed URL in a browser`)));
|
|
264
|
+
child.once("spawn", () => {
|
|
265
|
+
child.unref();
|
|
266
|
+
resolve();
|
|
267
|
+
});
|
|
268
|
+
});
|
|
269
|
+
}, "openBrowser");
|
|
270
|
+
|
|
271
|
+
export {
|
|
272
|
+
logParsedArgv,
|
|
273
|
+
logVersion,
|
|
274
|
+
startCli
|
|
275
|
+
};
|