@wirecat/zoom-cli 0.56.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.
Files changed (145) hide show
  1. package/README.md +1 -1
  2. package/dist/bin/zm.js +35 -5
  3. package/dist/bundle/all-profiles-EKHWTGOY.js +25 -0
  4. package/dist/bundle/answer-policy-KH2IFXPN.js +96 -0
  5. package/dist/bundle/anthropic-VL54IUGF.js +70 -0
  6. package/dist/bundle/bun-ADJVI4HY.js +169 -0
  7. package/dist/bundle/bun-sqlite-2SDA3YOT.js +69 -0
  8. package/dist/bundle/chunk-2IKY7VBH.js +9 -0
  9. package/dist/bundle/chunk-2WOGZDZG.js +431 -0
  10. package/dist/bundle/chunk-4R7HYNZS.js +73 -0
  11. package/dist/bundle/chunk-4VCA7QU3.js +538 -0
  12. package/dist/bundle/chunk-4YLS4YLS.js +29 -0
  13. package/dist/bundle/chunk-5D4AEUVA.js +24783 -0
  14. package/dist/bundle/chunk-5F7IOESV.js +281 -0
  15. package/dist/bundle/chunk-5QESMCQK.js +122 -0
  16. package/dist/bundle/chunk-6M6FJV5D.js +138 -0
  17. package/dist/bundle/chunk-6MX5T6AQ.js +17 -0
  18. package/dist/bundle/chunk-6P3YHT54.js +385 -0
  19. package/dist/bundle/chunk-7A6PZUDR.js +938 -0
  20. package/dist/bundle/chunk-7GUG6UZS.js +884 -0
  21. package/dist/bundle/chunk-7JZJMHQY.js +487 -0
  22. package/dist/bundle/chunk-A4ETXPMZ.js +98 -0
  23. package/dist/bundle/chunk-ADLS6FVG.js +24600 -0
  24. package/dist/bundle/chunk-AE4BOXH7.js +5292 -0
  25. package/dist/bundle/chunk-AN3GVZTU.js +76 -0
  26. package/dist/bundle/chunk-BAYNCCNM.js +215 -0
  27. package/dist/bundle/chunk-BW2WPOXP.js +166 -0
  28. package/dist/bundle/chunk-BW52AJ4R.js +3387 -0
  29. package/dist/bundle/chunk-CB5UTASG.js +18 -0
  30. package/dist/bundle/chunk-CLMXBW53.js +1028 -0
  31. package/dist/bundle/chunk-DCTXOMOR.js +35 -0
  32. package/dist/bundle/chunk-DFDN6AUB.js +21 -0
  33. package/dist/bundle/chunk-EOQFWJJD.js +1095 -0
  34. package/dist/bundle/chunk-G4R4ZIGD.js +3569 -0
  35. package/dist/bundle/chunk-G4VZDINN.js +161 -0
  36. package/dist/bundle/chunk-GARCOIB6.js +409 -0
  37. package/dist/bundle/chunk-GKMGS7G5.js +1938 -0
  38. package/dist/bundle/chunk-HCNMFFG3.js +82 -0
  39. package/dist/bundle/chunk-HG5KRV55.js +1970 -0
  40. package/dist/bundle/chunk-HKYLSIZ2.js +82 -0
  41. package/dist/bundle/chunk-HTQTIKWP.js +928 -0
  42. package/dist/bundle/chunk-I4VQDXFR.js +100 -0
  43. package/dist/bundle/chunk-ICSKEDPI.js +36139 -0
  44. package/dist/bundle/chunk-IP4OK7RQ.js +24 -0
  45. package/dist/bundle/chunk-IVQ6342B.js +2 -0
  46. package/dist/bundle/chunk-K72SEMYI.js +160 -0
  47. package/dist/bundle/chunk-LHRCJYFC.js +19 -0
  48. package/dist/bundle/chunk-LPTIQLDW.js +192 -0
  49. package/dist/bundle/chunk-LQ3T2ZIX.js +124 -0
  50. package/dist/bundle/chunk-LSVI3A5X.js +836 -0
  51. package/dist/bundle/chunk-LW2G4U6W.js +570 -0
  52. package/dist/bundle/chunk-LXB6ONWC.js +3517 -0
  53. package/dist/bundle/chunk-LY26NW3I.js +6848 -0
  54. package/dist/bundle/chunk-MAEFLDHG.js +6092 -0
  55. package/dist/bundle/chunk-MZH4GDR4.js +45 -0
  56. package/dist/bundle/chunk-NN5B24KP.js +1109 -0
  57. package/dist/bundle/chunk-NO7CJEYV.js +22 -0
  58. package/dist/bundle/chunk-NTDWAAGL.js +18435 -0
  59. package/dist/bundle/chunk-NW3X3G5X.js +264 -0
  60. package/dist/bundle/chunk-O66V2WHK.js +48 -0
  61. package/dist/bundle/chunk-OCGPZHXW.js +25 -0
  62. package/dist/bundle/chunk-OIHDCGV4.js +151 -0
  63. package/dist/bundle/chunk-OVSWVPXL.js +8190 -0
  64. package/dist/bundle/chunk-PIN5RZ3D.js +63 -0
  65. package/dist/bundle/chunk-QLIB3PEC.js +1146 -0
  66. package/dist/bundle/chunk-QTR6D5HT.js +58 -0
  67. package/dist/bundle/chunk-QUJPQMHJ.js +2315 -0
  68. package/dist/bundle/chunk-R3HPOCZD.js +188 -0
  69. package/dist/bundle/chunk-RMV4C2YL.js +482 -0
  70. package/dist/bundle/chunk-RRRBMQ2E.js +844 -0
  71. package/dist/bundle/chunk-S4S7E54J.js +60 -0
  72. package/dist/bundle/chunk-SB6WOSHG.js +1109 -0
  73. package/dist/bundle/chunk-SE75DPBY.js +31 -0
  74. package/dist/bundle/chunk-SQJ7EH2D.js +97 -0
  75. package/dist/bundle/chunk-TKCHUT2H.js +422 -0
  76. package/dist/bundle/chunk-TLQUKHEM.js +193 -0
  77. package/dist/bundle/chunk-TZ2MKETI.js +100 -0
  78. package/dist/bundle/chunk-UC44ZMQV.js +78 -0
  79. package/dist/bundle/chunk-UI5UTMSZ.js +275 -0
  80. package/dist/bundle/chunk-VPPYYWOH.js +630 -0
  81. package/dist/bundle/chunk-WJHK5D7Z.js +35612 -0
  82. package/dist/bundle/chunk-WQ24UC44.js +239 -0
  83. package/dist/bundle/chunk-X5DFDGWS.js +2 -0
  84. package/dist/bundle/chunk-Y5E2WNWB.js +35 -0
  85. package/dist/bundle/chunk-YB4DMKYX.js +119 -0
  86. package/dist/bundle/chunk-Z4TZ6TAF.js +288 -0
  87. package/dist/bundle/chunk-ZVVMGPBJ.js +50 -0
  88. package/dist/bundle/cli-72EQATJF.js +825 -0
  89. package/dist/bundle/command-contract-4MHSZUN3.js +38 -0
  90. package/dist/bundle/config-GFIJK6G2.js +79 -0
  91. package/dist/bundle/dist-IBNHCQXT.js +136 -0
  92. package/dist/bundle/dist-XUFQCJXW.js +7577 -0
  93. package/dist/bundle/echarts-RFTK737T.js +42501 -0
  94. package/dist/bundle/embed-7QYA2ZZE.js +35 -0
  95. package/dist/bundle/embedder-YNN6PCHG.js +108 -0
  96. package/dist/bundle/first-run-EVSRQKZJ.js +23 -0
  97. package/dist/bundle/first-screen-RG4GUKW7.js +36 -0
  98. package/dist/bundle/folders-JEPOMYM4.js +13 -0
  99. package/dist/bundle/instructions-FHNL7CMW.js +9 -0
  100. package/dist/bundle/main-NYGJXPH7.js +130 -0
  101. package/dist/bundle/mcp-IXFC2VVR.js +165 -0
  102. package/dist/bundle/mcp-VGSZDCKK.js +189 -0
  103. package/dist/bundle/mcp-XKP2PXLS.js +92 -0
  104. package/dist/bundle/meetings-IBPI4MM4.js +215 -0
  105. package/dist/bundle/node-P4E63KXA.js +2340 -0
  106. package/dist/bundle/node-TLZSIHIJ.js +21 -0
  107. package/dist/bundle/node-ZMCACJVS.js +176 -0
  108. package/dist/bundle/node-sqlite-ZNGOBA5Q.js +45 -0
  109. package/dist/bundle/oauth-Q6LKF7DB.js +17 -0
  110. package/dist/bundle/open-LJ332Y5O.js +19 -0
  111. package/dist/bundle/output-file-RYQZ3RTE.js +63 -0
  112. package/dist/bundle/process-ZPTLNVQS.js +91 -0
  113. package/dist/bundle/program-IBRQBQ6W.js +5845 -0
  114. package/dist/bundle/prompt-RT7GUUXH.js +12 -0
  115. package/dist/bundle/recognize-QXGE7YJH.js +190 -0
  116. package/dist/bundle/remote-FD4MZQV3.js +26 -0
  117. package/dist/bundle/rerank-V6AVV755.js +49 -0
  118. package/dist/bundle/run-log-RE2EI3UU.js +111 -0
  119. package/dist/bundle/serve-HIJTFAW7.js +19 -0
  120. package/dist/bundle/server-3QOXOYYL.js +53 -0
  121. package/dist/bundle/server-WLJCU7KK.js +812 -0
  122. package/dist/bundle/services-KC5KQFBS.js +330 -0
  123. package/dist/bundle/speech-5JOXLYDA.js +44 -0
  124. package/dist/bundle/state-PPGRB3T6.js +33 -0
  125. package/dist/bundle/store-LODVDPK3.js +141 -0
  126. package/dist/bundle/store-WB5BICTG.js +124 -0
  127. package/dist/bundle/store-connection-EG6Z5ITP.js +76 -0
  128. package/dist/bundle/store-maintenance-command-Q5WMFUZ2.js +54 -0
  129. package/dist/bundle/streaming-UGFFNOXL.js +15 -0
  130. package/dist/bundle/tokens-AF5CPY2F.js +17 -0
  131. package/dist/bundle/zm.js +8 -0
  132. package/dist/contract-overrides.d.ts.map +1 -1
  133. package/dist/contract-overrides.js +18 -16
  134. package/dist/contract-overrides.js.map +1 -1
  135. package/dist/mcp-command.d.ts +3 -2
  136. package/dist/mcp-command.d.ts.map +1 -1
  137. package/dist/mcp-command.js +62 -10
  138. package/dist/mcp-command.js.map +1 -1
  139. package/dist/program-bindings.d.ts.map +1 -1
  140. package/dist/program-bindings.js +1 -0
  141. package/dist/program-bindings.js.map +1 -1
  142. package/dist/version.d.ts +1 -1
  143. package/dist/version.js +1 -1
  144. package/package.json +7 -5
  145. package/skills/zoom-cli/SKILL.md +2 -0
@@ -0,0 +1,35 @@
1
+ import { createRequire as __bundleRequire } from "node:module";
2
+ const require = __bundleRequire(import.meta.url);
3
+ import {
4
+ WARM_IDLE_MS,
5
+ defaultThreads,
6
+ isTextModelInstalled,
7
+ loadModel,
8
+ meanOf,
9
+ openEmbedder,
10
+ placedText,
11
+ runEmbedders,
12
+ textModelsDirectory,
13
+ truncated,
14
+ unit,
15
+ warmEmbedders
16
+ } from "./chunk-CLMXBW53.js";
17
+ import "./chunk-NW3X3G5X.js";
18
+ import "./chunk-CB5UTASG.js";
19
+ import "./chunk-AE4BOXH7.js";
20
+ import "./chunk-Y5E2WNWB.js";
21
+ import "./chunk-ZVVMGPBJ.js";
22
+ export {
23
+ WARM_IDLE_MS,
24
+ defaultThreads,
25
+ isTextModelInstalled,
26
+ loadModel,
27
+ meanOf,
28
+ openEmbedder,
29
+ placedText,
30
+ runEmbedders,
31
+ textModelsDirectory,
32
+ truncated,
33
+ unit,
34
+ warmEmbedders
35
+ };
@@ -0,0 +1,108 @@
1
+ import { createRequire as __bundleRequire } from "node:module";
2
+ const require = __bundleRequire(import.meta.url);
3
+ import {
4
+ openSession,
5
+ truncated,
6
+ unit
7
+ } from "./chunk-CLMXBW53.js";
8
+ import "./chunk-NW3X3G5X.js";
9
+ import "./chunk-CB5UTASG.js";
10
+ import {
11
+ CliError
12
+ } from "./chunk-AE4BOXH7.js";
13
+ import {
14
+ importFrom
15
+ } from "./chunk-Y5E2WNWB.js";
16
+ import {
17
+ __name
18
+ } from "./chunk-ZVVMGPBJ.js";
19
+
20
+ // 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/images/picture/embedder.js
21
+ import { readFileSync } from "node:fs";
22
+ import { join } from "node:path";
23
+
24
+ // 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/images/picture/preprocess.js
25
+ var SIZE = 224;
26
+ var MEAN = [0.48145466, 0.4578275, 0.40821073];
27
+ var STD = [0.26862954, 0.26130258, 0.27577711];
28
+ var importCanvas = /* @__PURE__ */ __name(async () => {
29
+ try {
30
+ return await importFrom(new URL("images/picture/preprocess.js", import.meta.resolve("@wirecat/cli-core")).href, "@napi-rs/canvas");
31
+ } catch {
32
+ throw new CliError("validation_error", "searching pictures needs the optional package @napi-rs/canvas to read an image \u2014 install it next to this tool");
33
+ }
34
+ }, "importCanvas");
35
+ var preprocess = /* @__PURE__ */ __name(async (bytes, load = importCanvas) => {
36
+ const { createCanvas, loadImage } = await load();
37
+ let image;
38
+ try {
39
+ image = await loadImage(bytes);
40
+ } catch {
41
+ throw new CliError("invalid_response", "the file is not an image this tool can read");
42
+ }
43
+ const scale = SIZE / Math.min(image.width, image.height);
44
+ const width = Math.max(SIZE, Math.round(image.width * scale));
45
+ const height = Math.max(SIZE, Math.round(image.height * scale));
46
+ const surface = createCanvas(SIZE, SIZE);
47
+ const context = surface.getContext("2d");
48
+ context.fillStyle = "#ffffff";
49
+ context.fillRect(0, 0, SIZE, SIZE);
50
+ context.imageSmoothingQuality = "high";
51
+ context.drawImage(image, 0, 0, image.width, image.height, Math.round((SIZE - width) / 2), Math.round((SIZE - height) / 2), width, height);
52
+ const { data } = context.getImageData(0, 0, SIZE, SIZE);
53
+ const plane = SIZE * SIZE;
54
+ const pixels = new Float32Array(3 * plane);
55
+ for (let at = 0; at < plane; at++) {
56
+ for (let channel = 0; channel < 3; channel++) {
57
+ pixels[channel * plane + at] = (data[at * 4 + channel] / 255 - MEAN[channel]) / STD[channel];
58
+ }
59
+ }
60
+ return pixels;
61
+ }, "preprocess");
62
+
63
+ // 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/images/picture/embedder.js
64
+ var openPictureEmbedder = /* @__PURE__ */ __name(async (model, directory, { threads = 4, canvas } = {}) => {
65
+ const { Tokenizer } = await importFrom(new URL("images/picture/embedder.js", import.meta.resolve("@wirecat/cli-core")).href, "@huggingface/tokenizers");
66
+ const path = /* @__PURE__ */ __name((name) => join(directory, model.id, name), "path");
67
+ const tokenizer = new Tokenizer(JSON.parse(readFileSync(path("tokenizer.json"), "utf8")), JSON.parse(readFileSync(path("tokenizer_config.json"), "utf8")));
68
+ const sessions = [];
69
+ const lazy = /* @__PURE__ */ __name((name) => {
70
+ let opened;
71
+ return () => {
72
+ opened ??= openSession(readFileSync(path(name)), threads).then((created) => {
73
+ sessions.push(created.session);
74
+ return created;
75
+ });
76
+ return opened;
77
+ };
78
+ }, "lazy");
79
+ const vision = lazy(model.vision);
80
+ const text = lazy(model.text);
81
+ return {
82
+ model,
83
+ embedImage: /* @__PURE__ */ __name(async (bytes) => {
84
+ const pixels = await preprocess(bytes, canvas);
85
+ const { ort, session } = await vision();
86
+ const output = await session.run({ pixel_values: new ort.Tensor("float32", pixels, [1, 3, SIZE, SIZE]) });
87
+ return unit(Float32Array.from(output.image_embeds?.data));
88
+ }, "embedImage"),
89
+ embedQuery: /* @__PURE__ */ __name(async (query) => {
90
+ const ids = truncated(tokenizer.encode(query.toLowerCase()).ids, model.maxTokens);
91
+ const shape = [1, ids.length];
92
+ const { ort, session } = await text();
93
+ const feeds = {
94
+ input_ids: new ort.Tensor("int64", BigInt64Array.from(ids, BigInt), shape)
95
+ };
96
+ if (session.inputNames.includes("attention_mask"))
97
+ feeds.attention_mask = new ort.Tensor("int64", new BigInt64Array(ids.length).fill(1n), shape);
98
+ const output = await session.run(feeds);
99
+ return unit(Float32Array.from(output.text_embeds?.data));
100
+ }, "embedQuery"),
101
+ close: /* @__PURE__ */ __name(async () => {
102
+ await Promise.all(sessions.map((session) => session.release()));
103
+ }, "close")
104
+ };
105
+ }, "openPictureEmbedder");
106
+ export {
107
+ openPictureEmbedder
108
+ };
@@ -0,0 +1,23 @@
1
+ import { createRequire as __bundleRequire } from "node:module";
2
+ const require = __bundleRequire(import.meta.url);
3
+ import {
4
+ askSetupQuestions,
5
+ asksAtStart,
6
+ setupAtStart,
7
+ systemLanguage
8
+ } from "./chunk-BAYNCCNM.js";
9
+ import "./chunk-OIHDCGV4.js";
10
+ import "./chunk-LW2G4U6W.js";
11
+ import "./chunk-S4S7E54J.js";
12
+ import "./chunk-QUJPQMHJ.js";
13
+ import "./chunk-7GUG6UZS.js";
14
+ import "./chunk-CB5UTASG.js";
15
+ import "./chunk-AE4BOXH7.js";
16
+ import "./chunk-Y5E2WNWB.js";
17
+ import "./chunk-ZVVMGPBJ.js";
18
+ export {
19
+ askSetupQuestions,
20
+ asksAtStart,
21
+ setupAtStart,
22
+ systemLanguage
23
+ };
@@ -0,0 +1,36 @@
1
+ import { createRequire as __bundleRequire } from "node:module";
2
+ const require = __bundleRequire(import.meta.url);
3
+ import {
4
+ WIRECAT_TOOLS,
5
+ firstScreen,
6
+ installHelp
7
+ } from "./chunk-7JZJMHQY.js";
8
+ import "./chunk-BW2WPOXP.js";
9
+ import "./chunk-G4R4ZIGD.js";
10
+ import "./chunk-MAEFLDHG.js";
11
+ import "./chunk-OCGPZHXW.js";
12
+ import "./chunk-PIN5RZ3D.js";
13
+ import "./chunk-2WOGZDZG.js";
14
+ import "./chunk-EOQFWJJD.js";
15
+ import "./chunk-NO7CJEYV.js";
16
+ import "./chunk-YB4DMKYX.js";
17
+ import "./chunk-S4S7E54J.js";
18
+ import "./chunk-HTQTIKWP.js";
19
+ import "./chunk-LQ3T2ZIX.js";
20
+ import "./chunk-TKCHUT2H.js";
21
+ import "./chunk-NW3X3G5X.js";
22
+ import "./chunk-6M6FJV5D.js";
23
+ import "./chunk-7GUG6UZS.js";
24
+ import "./chunk-4YLS4YLS.js";
25
+ import "./chunk-CB5UTASG.js";
26
+ import "./chunk-LXB6ONWC.js";
27
+ import "./chunk-LSVI3A5X.js";
28
+ import "./chunk-IVQ6342B.js";
29
+ import "./chunk-AE4BOXH7.js";
30
+ import "./chunk-Y5E2WNWB.js";
31
+ import "./chunk-ZVVMGPBJ.js";
32
+ export {
33
+ WIRECAT_TOOLS,
34
+ firstScreen,
35
+ installHelp
36
+ };
@@ -0,0 +1,13 @@
1
+ import { createRequire as __bundleRequire } from "node:module";
2
+ const require = __bundleRequire(import.meta.url);
3
+ import {
4
+ loginService,
5
+ zmPaths
6
+ } from "./chunk-6MX5T6AQ.js";
7
+ import "./chunk-AE4BOXH7.js";
8
+ import "./chunk-Y5E2WNWB.js";
9
+ import "./chunk-ZVVMGPBJ.js";
10
+ export {
11
+ loginService,
12
+ zmPaths
13
+ };
@@ -0,0 +1,9 @@
1
+ import { createRequire as __bundleRequire } from "node:module";
2
+ const require = __bundleRequire(import.meta.url);
3
+ import {
4
+ instructions
5
+ } from "./chunk-DCTXOMOR.js";
6
+ import "./chunk-ZVVMGPBJ.js";
7
+ export {
8
+ instructions
9
+ };
@@ -0,0 +1,130 @@
1
+ import { createRequire as __bundleRequire } from "node:module";
2
+ const require = __bundleRequire(import.meta.url);
3
+ import {
4
+ ZM
5
+ } from "./chunk-LHRCJYFC.js";
6
+ import {
7
+ VERSION
8
+ } from "./chunk-2IKY7VBH.js";
9
+ import {
10
+ startCli
11
+ } from "./chunk-UI5UTMSZ.js";
12
+ import "./chunk-OCGPZHXW.js";
13
+ import "./chunk-TZ2MKETI.js";
14
+ import {
15
+ CliError,
16
+ errorObjectOf,
17
+ exitCodeOfError,
18
+ isCliError,
19
+ readBatchInput,
20
+ renderError,
21
+ systemKeyring
22
+ } from "./chunk-AE4BOXH7.js";
23
+ import "./chunk-Y5E2WNWB.js";
24
+ import {
25
+ __name
26
+ } from "./chunk-ZVVMGPBJ.js";
27
+
28
+ // dist/bin/main.js
29
+ import { createReadStream } from "node:fs";
30
+ import { join } from "node:path";
31
+ import { createInterface } from "node:readline/promises";
32
+ import { addAbortSignal } from "node:stream";
33
+ import { fileURLToPath } from "node:url";
34
+ var answerPolicy;
35
+ await startCli({
36
+ app: ZM,
37
+ run: /* @__PURE__ */ __name(async (entry) => {
38
+ answerPolicy = await import("./answer-policy-KH2IFXPN.js");
39
+ const [{ runsDirFor }, { readConfig }, { loginService, zmPaths }, { writeExportFile }, { run }, { lazyRunLog }, { createStoreConnector }, { writeStream }, { TOKEN_LOG_ALLOW, TokenManager }] = await Promise.all([
40
+ import("./cli-72EQATJF.js"),
41
+ import("./config-GFIJK6G2.js"),
42
+ import("./folders-JEPOMYM4.js"),
43
+ import("./output-file-RYQZ3RTE.js"),
44
+ import("./program-IBRQBQ6W.js"),
45
+ import("./run-log-RE2EI3UU.js"),
46
+ import("./store-connection-EG6Z5ITP.js"),
47
+ import("./streaming-UGFFNOXL.js"),
48
+ import("./tokens-AF5CPY2F.js")
49
+ ]);
50
+ const paths = zmPaths();
51
+ const configPath = join(paths.config, "config.json");
52
+ const tokenRun = lazyRunLog({
53
+ runsDir: runsDirFor(ZM, entry.env),
54
+ command: "oauth token",
55
+ version: VERSION,
56
+ allow: TOKEN_LOG_ALLOW
57
+ });
58
+ let failed = true;
59
+ try {
60
+ const tokens = new TokenManager({
61
+ get clientId() {
62
+ return readConfig(configPath).clientId ?? "";
63
+ },
64
+ keyring: systemKeyring,
65
+ service: loginService(paths.config),
66
+ fetch,
67
+ log: tokenRun.log
68
+ });
69
+ const code = await run(entry.args, {
70
+ configPath,
71
+ recordingScheduleTarget: { runtime: process.execPath, cliPath: fileURLToPath(new URL("../bin/main.js", import.meta.url).href) },
72
+ tokens,
73
+ connectStore: createStoreConnector({ env: entry.env }),
74
+ fetch,
75
+ outputIsTTY: entry.tty,
76
+ env: entry.env,
77
+ signal: entry.signal,
78
+ writeFile: writeExportFile,
79
+ readBatchInput: /* @__PURE__ */ __name(async (path, signal) => {
80
+ signal?.throwIfAborted();
81
+ const input = path === "-" ? process.stdin : createReadStream(path, { signal });
82
+ if (signal && path === "-")
83
+ addAbortSignal(signal, input);
84
+ try {
85
+ return await readBatchInput(input, { signal });
86
+ } catch (error) {
87
+ signal?.throwIfAborted();
88
+ if (isCliError(error))
89
+ throw error;
90
+ throw new CliError("configuration_error", "could not read the batch input file or stdin");
91
+ }
92
+ }, "readBatchInput"),
93
+ streamData: /* @__PURE__ */ __name((text, signal) => writeStream(process.stdout, text, signal), "streamData"),
94
+ data: /* @__PURE__ */ __name((text) => process.stdout.write(text), "data"),
95
+ diagnostic: /* @__PURE__ */ __name((text) => {
96
+ if (!entry.outputClosed())
97
+ process.stderr.write(text);
98
+ }, "diagnostic"),
99
+ openBrowser: entry.openBrowser,
100
+ // entry.ask answers no without asking when stdout is not a terminal; leaving confirm out then says to add --yes.
101
+ confirm: entry.tty && process.stdin.isTTY && process.stderr.isTTY ? (question) => entry.ask(question) : void 0,
102
+ atStart: entry.atStart,
103
+ readPaste: process.stdin.isTTY ? async (signal) => {
104
+ const input = createInterface({ input: process.stdin, output: process.stderr });
105
+ try {
106
+ return await input.question("If the callback does not complete, paste code=\u2026&state=\u2026 here: ", {
107
+ signal
108
+ });
109
+ } finally {
110
+ input.close();
111
+ }
112
+ } : void 0
113
+ });
114
+ failed = code !== 0;
115
+ return code;
116
+ } finally {
117
+ await tokenRun.finish(failed ? "failed" : "success").catch(() => {
118
+ });
119
+ }
120
+ }, "run"),
121
+ fail: /* @__PURE__ */ __name((error, entry) => {
122
+ const diagnostic = /* @__PURE__ */ __name((text) => process.stderr.write(text), "diagnostic");
123
+ if (answerPolicy)
124
+ return answerPolicy.reportFailure(error, entry.args, { diagnostic, outputIsTTY: entry.tty });
125
+ const object = errorObjectOf(error);
126
+ diagnostic(`${renderError(object, { cli: ZM.command, interactive: entry.tty })}
127
+ `);
128
+ return exitCodeOfError(object);
129
+ }, "fail")
130
+ });
@@ -0,0 +1,165 @@
1
+ import { createRequire as __bundleRequire } from "node:module";
2
+ const require = __bundleRequire(import.meta.url);
3
+ import {
4
+ executableEnvironment,
5
+ executableOnPath,
6
+ require_cross_spawn
7
+ } from "./chunk-LW2G4U6W.js";
8
+ import {
9
+ __name,
10
+ __toESM
11
+ } from "./chunk-ZVVMGPBJ.js";
12
+
13
+ // node_modules/.pnpm/@wirecat+cli-base@0.65.0_commander@15.0.0_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/mcp/index.js
14
+ var import_cross_spawn = __toESM(require_cross_spawn(), 1);
15
+ var realRun = /* @__PURE__ */ __name((file, args) => {
16
+ const result = import_cross_spawn.default.sync(executableOnPath(file, process.env), args, {
17
+ encoding: "utf8",
18
+ timeout: 1e4,
19
+ maxBuffer: 256e3,
20
+ env: executableEnvironment(process.env)
21
+ });
22
+ return { status: result.status, error: result.error, stdout: result.stdout ?? "", stderr: result.stderr ?? "" };
23
+ }, "realRun");
24
+ var executable = /* @__PURE__ */ __name((client) => client === "codex" ? "codex" : "claude", "executable");
25
+ var presentIn = /* @__PURE__ */ __name((client, name, run) => {
26
+ const state = lookUp(client, name, run);
27
+ if (state === "unavailable")
28
+ throw new Error(`${executable(client)} is not installed or could not be started`);
29
+ return state === "registered";
30
+ }, "presentIn");
31
+ var setupArguments = /* @__PURE__ */ __name((client, name, entry) => {
32
+ const variables = Object.entries(entry.env ?? {}).flatMap(([key, value]) => ["--env", `${key}=${value}`]);
33
+ if (client === "codex")
34
+ return ["mcp", "add", name, ...variables, "--", entry.command, ...entry.args];
35
+ return ["mcp", "add", "--scope", "user", name, ...variables, "--", entry.command, ...entry.args];
36
+ }, "setupArguments");
37
+ var checkName = /* @__PURE__ */ __name((name) => {
38
+ if (!/^[a-zA-Z][a-zA-Z0-9_-]*$/.test(name))
39
+ throw new Error("the MCP name must be letters, digits, _ or -");
40
+ }, "checkName");
41
+ var lookUp = /* @__PURE__ */ __name((client, name, run) => {
42
+ const file = executable(client);
43
+ const existing = run(file, ["mcp", "get", name, ...client === "codex" ? ["--json"] : []]);
44
+ if (existing.error)
45
+ return "unavailable";
46
+ if (existing.status === 0)
47
+ return "registered";
48
+ if (!/No MCP server named/i.test(existing.stdout + existing.stderr)) {
49
+ throw new Error(`${file} could not check its MCP configuration`);
50
+ }
51
+ return "missing";
52
+ }, "lookUp");
53
+ var stdioEntryStatus = /* @__PURE__ */ __name((client, name, { run = realRun } = {}) => {
54
+ checkName(name);
55
+ return { client, name, state: lookUp(client, name, run) };
56
+ }, "stdioEntryStatus");
57
+ var removeArguments = /* @__PURE__ */ __name((client, name) => (
58
+ // Claude Code without a scope removes from whichever scope holds the name, which may be a project's own entry.
59
+ client === "codex" ? ["mcp", "remove", name] : ["mcp", "remove", "--scope", "user", name]
60
+ ), "removeArguments");
61
+ var removeStdioEntry = /* @__PURE__ */ __name((client, name, { run = realRun } = {}) => {
62
+ checkName(name);
63
+ if (!presentIn(client, name, run))
64
+ return { client, name, removed: false };
65
+ const file = executable(client);
66
+ const removed = run(file, removeArguments(client, name));
67
+ if (removed.status !== 0 || removed.error)
68
+ throw new Error(`${file} could not remove ${name}`);
69
+ return { client, name, removed: true };
70
+ }, "removeStdioEntry");
71
+ var installStdioEntry = /* @__PURE__ */ __name((client, name, entry, { run = realRun } = {}) => {
72
+ checkName(name);
73
+ if (!entry.command || entry.args.some((arg) => arg.includes("\0")))
74
+ throw new Error("invalid MCP command");
75
+ const file = executable(client);
76
+ if (presentIn(client, name, run))
77
+ throw new Error(`${name} is already configured in ${file}; remove it there first`);
78
+ const args = setupArguments(client, name, entry);
79
+ const added = run(file, args);
80
+ if (added.status !== 0 || added.error)
81
+ throw new Error(`${file} could not add ${name}`);
82
+ return { client, name, command: [entry.command, ...entry.args] };
83
+ }, "installStdioEntry");
84
+ var probeStdio = /* @__PURE__ */ __name(async (entry, { timeoutMs = 1e4, start = /* @__PURE__ */ __name((file, args, env) => (0, import_cross_spawn.default)(executableOnPath(file, env), args, {
85
+ env: executableEnvironment(env),
86
+ stdio: "pipe"
87
+ }), "start") } = {}) => {
88
+ const child = start(entry.command, entry.args, { ...process.env, ...entry.env });
89
+ let buffer = "";
90
+ let timer;
91
+ const pending = /* @__PURE__ */ new Map();
92
+ const request = /* @__PURE__ */ __name((id, method, params) => new Promise((resolve, reject) => {
93
+ pending.set(id, { resolve, reject });
94
+ child.stdin.write(`${JSON.stringify({ jsonrpc: "2.0", id, method, params })}
95
+ `);
96
+ }), "request");
97
+ const fail = /* @__PURE__ */ __name((error) => {
98
+ for (const waiter of pending.values())
99
+ waiter.reject(error);
100
+ pending.clear();
101
+ }, "fail");
102
+ child.on("error", () => fail(new Error("the MCP server could not be started")));
103
+ child.on("exit", () => fail(new Error("the MCP server exited before answering")));
104
+ child.stdin.on("error", () => fail(new Error("the MCP server closed its input")));
105
+ child.stdout.setEncoding("utf8");
106
+ child.stdout.on("data", (chunk) => {
107
+ buffer += chunk;
108
+ if (buffer.length > 1e6)
109
+ return fail(new Error("the MCP server sent too much output"));
110
+ for (let newline = buffer.indexOf("\n"); newline !== -1; newline = buffer.indexOf("\n")) {
111
+ const line = buffer.slice(0, newline);
112
+ buffer = buffer.slice(newline + 1);
113
+ try {
114
+ const value = JSON.parse(line);
115
+ if (typeof value.id !== "number")
116
+ continue;
117
+ const waiter = pending.get(value.id);
118
+ if (!waiter)
119
+ continue;
120
+ pending.delete(value.id);
121
+ if (value.error)
122
+ waiter.reject(new Error("the MCP server rejected the handshake"));
123
+ else
124
+ waiter.resolve(value.result ?? {});
125
+ } catch {
126
+ fail(new Error("the MCP server sent invalid JSON"));
127
+ }
128
+ }
129
+ });
130
+ try {
131
+ timer = setTimeout(() => fail(new Error("the MCP server did not answer in time")), timeoutMs);
132
+ await request(1, "initialize", {
133
+ protocolVersion: "2025-11-25",
134
+ capabilities: {},
135
+ clientInfo: { name: "cli-base-mcp-doctor", version: "1" }
136
+ });
137
+ child.stdin.write(`${JSON.stringify({ jsonrpc: "2.0", method: "notifications/initialized" })}
138
+ `);
139
+ const result = await request(2, "tools/list", {});
140
+ const tools = result.tools;
141
+ if (!Array.isArray(tools))
142
+ throw new Error("the MCP server returned no tool list");
143
+ const named = tools.filter((item) => item !== null && typeof item === "object" && "name" in item && typeof item.name === "string");
144
+ if (named.length !== tools.length)
145
+ throw new Error("the MCP server returned an invalid tool list");
146
+ return {
147
+ tools: named.map((item) => item.name),
148
+ potentialWrites: named.filter((item) => item.annotations?.readOnlyHint !== true).map((item) => item.name)
149
+ };
150
+ } finally {
151
+ if (timer)
152
+ clearTimeout(timer);
153
+ pending.clear();
154
+ child.stdin.end();
155
+ child.kill();
156
+ }
157
+ }, "probeStdio");
158
+ export {
159
+ installStdioEntry,
160
+ probeStdio,
161
+ removeArguments,
162
+ removeStdioEntry,
163
+ setupArguments,
164
+ stdioEntryStatus
165
+ };