@wirecat/slack-cli 0.0.0-stage → 0.2.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 (275) hide show
  1. package/CHANGELOG.md +121 -0
  2. package/LICENSE +204 -0
  3. package/README.md +131 -2
  4. package/contracts/wirecat.json +5526 -0
  5. package/dist/bin/slack.d.ts +3 -0
  6. package/dist/bin/slack.d.ts.map +1 -0
  7. package/dist/bin/slack.js +40 -0
  8. package/dist/bin/slack.js.map +1 -0
  9. package/dist/bundle/agent-GOFXFUQP.js +37 -0
  10. package/dist/bundle/all-profiles-4C7VOT2D.js +320 -0
  11. package/dist/bundle/anthropic-ZD66TC5S.js +91 -0
  12. package/dist/bundle/app-server-QNCVEDMY.js +249 -0
  13. package/dist/bundle/bun-2FULBYXS.js +169 -0
  14. package/dist/bundle/bun-sqlite-PMS26ZUT.js +76 -0
  15. package/dist/bundle/chunk-2LB5BWC4.js +362 -0
  16. package/dist/bundle/chunk-2ZEYRHZV.js +18 -0
  17. package/dist/bundle/chunk-3IJ3THPV.js +7 -0
  18. package/dist/bundle/chunk-3IZF5ENR.js +61 -0
  19. package/dist/bundle/chunk-4HSVEQ3R.js +29 -0
  20. package/dist/bundle/chunk-4QPMHVM5.js +1007 -0
  21. package/dist/bundle/chunk-53LIHHXC.js +16 -0
  22. package/dist/bundle/chunk-5F36CXDM.js +794 -0
  23. package/dist/bundle/chunk-5LPREGD3.js +12636 -0
  24. package/dist/bundle/chunk-5R5YRYIP.js +1148 -0
  25. package/dist/bundle/chunk-5RSQTG7L.js +388 -0
  26. package/dist/bundle/chunk-5SXZETJF.js +170 -0
  27. package/dist/bundle/chunk-6PDQP5RM.js +50 -0
  28. package/dist/bundle/chunk-75BLNPN3.js +1197 -0
  29. package/dist/bundle/chunk-7BEO72EN.js +131 -0
  30. package/dist/bundle/chunk-7F6RNAIM.js +230 -0
  31. package/dist/bundle/chunk-AG7FP64Z.js +77 -0
  32. package/dist/bundle/chunk-BRXTN5LJ.js +338 -0
  33. package/dist/bundle/chunk-CABZAU37.js +319 -0
  34. package/dist/bundle/chunk-CCOSG3F2.js +24616 -0
  35. package/dist/bundle/chunk-CDTZSFTN.js +58 -0
  36. package/dist/bundle/chunk-CMZBCWND.js +1246 -0
  37. package/dist/bundle/chunk-CRQEEJNF.js +185 -0
  38. package/dist/bundle/chunk-CWYU4R65.js +358 -0
  39. package/dist/bundle/chunk-CZFR6JQX.js +52 -0
  40. package/dist/bundle/chunk-D72URWJE.js +532 -0
  41. package/dist/bundle/chunk-DFDN6AUB.js +21 -0
  42. package/dist/bundle/chunk-DVHX7R54.js +4072 -0
  43. package/dist/bundle/chunk-DYKOG7QR.js +9596 -0
  44. package/dist/bundle/chunk-ECDI42G6.js +100 -0
  45. package/dist/bundle/chunk-EH6ZEJGT.js +932 -0
  46. package/dist/bundle/chunk-ELY2TLCY.js +259 -0
  47. package/dist/bundle/chunk-ERRVUVKR.js +156 -0
  48. package/dist/bundle/chunk-FBWR4E5D.js +353 -0
  49. package/dist/bundle/chunk-GKS6KL57.js +6848 -0
  50. package/dist/bundle/chunk-H2COZZ55.js +2787 -0
  51. package/dist/bundle/chunk-HGXTEK7R.js +82 -0
  52. package/dist/bundle/chunk-HXLXM7HV.js +726 -0
  53. package/dist/bundle/chunk-IPP4N6HD.js +24 -0
  54. package/dist/bundle/chunk-IWTVR7S7.js +53 -0
  55. package/dist/bundle/chunk-IYJH75D4.js +63 -0
  56. package/dist/bundle/chunk-JCZLRT4Z.js +39 -0
  57. package/dist/bundle/chunk-JGRWMR5H.js +123 -0
  58. package/dist/bundle/chunk-JYRYQJBN.js +633 -0
  59. package/dist/bundle/chunk-KIKLDI74.js +161 -0
  60. package/dist/bundle/chunk-L4WO3XH6.js +2020 -0
  61. package/dist/bundle/chunk-LQDNUAK3.js +274 -0
  62. package/dist/bundle/chunk-LV5ONLQH.js +38 -0
  63. package/dist/bundle/chunk-M27Z23OZ.js +23 -0
  64. package/dist/bundle/chunk-M5XTZHXM.js +142 -0
  65. package/dist/bundle/chunk-MJBEGUIZ.js +76 -0
  66. package/dist/bundle/chunk-N4WOLGIV.js +2333 -0
  67. package/dist/bundle/chunk-N5K4OHPT.js +206 -0
  68. package/dist/bundle/chunk-NYAPUET7.js +108 -0
  69. package/dist/bundle/chunk-P4IFLOIK.js +218 -0
  70. package/dist/bundle/chunk-P6G2QTCD.js +288 -0
  71. package/dist/bundle/chunk-PL5P7UKW.js +25216 -0
  72. package/dist/bundle/chunk-PU7R6XNV.js +80 -0
  73. package/dist/bundle/chunk-QLLBACDR.js +72 -0
  74. package/dist/bundle/chunk-QP7XN5KX.js +407 -0
  75. package/dist/bundle/chunk-QY2F6A3D.js +557 -0
  76. package/dist/bundle/chunk-RLIT7VAZ.js +66 -0
  77. package/dist/bundle/chunk-S4UUN6LD.js +1410 -0
  78. package/dist/bundle/chunk-SKGAKI62.js +86 -0
  79. package/dist/bundle/chunk-SQMZP5MA.js +66653 -0
  80. package/dist/bundle/chunk-UB6NTICY.js +95 -0
  81. package/dist/bundle/chunk-UBHQO5HV.js +778 -0
  82. package/dist/bundle/chunk-UM4RKO24.js +106 -0
  83. package/dist/bundle/chunk-VAHFY732.js +1068 -0
  84. package/dist/bundle/chunk-VGDM4C3F.js +188 -0
  85. package/dist/bundle/chunk-VOUAKCPM.js +41181 -0
  86. package/dist/bundle/chunk-WCCFJ4Q6.js +3736 -0
  87. package/dist/bundle/chunk-WV6EXRDV.js +46 -0
  88. package/dist/bundle/chunk-WVAT5TGY.js +334 -0
  89. package/dist/bundle/chunk-WW76JMKE.js +1243 -0
  90. package/dist/bundle/chunk-XXOMUKC6.js +54 -0
  91. package/dist/bundle/chunk-Y5E2WNWB.js +35 -0
  92. package/dist/bundle/chunk-YDO6RJ2P.js +1337 -0
  93. package/dist/bundle/chunk-ZBCFZCJW.js +388 -0
  94. package/dist/bundle/chunk-ZVVMGPBJ.js +50 -0
  95. package/dist/bundle/command-contract-BWGRUY6L.js +37 -0
  96. package/dist/bundle/command-server-entry-BATOWE3Y.js +166 -0
  97. package/dist/bundle/decode-MZQGYXJH.js +297 -0
  98. package/dist/bundle/definitions-3EONB23J.js +8600 -0
  99. package/dist/bundle/dispatch-NYC4ARWX.js +411 -0
  100. package/dist/bundle/dist-AMLBQVKM.js +7577 -0
  101. package/dist/bundle/dist-PAKDDIBT.js +191 -0
  102. package/dist/bundle/echarts-7OYGL2GW.js +42501 -0
  103. package/dist/bundle/embed-4I25DVKZ.js +38 -0
  104. package/dist/bundle/embedder-YXKQHAZO.js +111 -0
  105. package/dist/bundle/emoji-4LYX3GOS.js +4271 -0
  106. package/dist/bundle/failure-3YOVYZTX.js +25 -0
  107. package/dist/bundle/first-run-2VL2BOV7.js +29 -0
  108. package/dist/bundle/first-screen-C7FIWZL2.js +37 -0
  109. package/dist/bundle/instructions-UMNDHXG2.js +11 -0
  110. package/dist/bundle/mcp-V27RHILF.js +167 -0
  111. package/dist/bundle/meeting-combined-LS6XO4JH.js +24 -0
  112. package/dist/bundle/meeting-model-VIR465CY.js +25 -0
  113. package/dist/bundle/meeting-semantic-H5J3OOF2.js +22 -0
  114. package/dist/bundle/node-JJ3WDCNJ.js +2340 -0
  115. package/dist/bundle/node-PYFPGL4E.js +176 -0
  116. package/dist/bundle/node-TLZSIHIJ.js +21 -0
  117. package/dist/bundle/node-sqlite-LFWPGDVP.js +74 -0
  118. package/dist/bundle/oauth-42VCSIVL.js +20 -0
  119. package/dist/bundle/open-XJ5R5LHC.js +23 -0
  120. package/dist/bundle/openai-RZBLV4HG.js +238 -0
  121. package/dist/bundle/process-DD6H3K7L.js +91 -0
  122. package/dist/bundle/program-OIYIBNSA.js +35443 -0
  123. package/dist/bundle/prompt-NQRDM5LY.js +17 -0
  124. package/dist/bundle/recognize-EM7H2IZS.js +26 -0
  125. package/dist/bundle/remote-Z6NU6QQA.js +31 -0
  126. package/dist/bundle/rerank-PNPCSPNF.js +52 -0
  127. package/dist/bundle/schemas-JMKNP4U3.js +2765 -0
  128. package/dist/bundle/serve-SQVGX76J.js +199 -0
  129. package/dist/bundle/server-NPJH45FZ.js +212 -0
  130. package/dist/bundle/server-Z4ZMGRAH.js +79 -0
  131. package/dist/bundle/slack.js +184 -0
  132. package/dist/bundle/sqlite-runtime-F3AJGAPN.js +20 -0
  133. package/dist/bundle/state-JT7ZFSXN.js +36 -0
  134. package/dist/bundle/store-FXGMHRF3.js +181 -0
  135. package/dist/bundle/store-J5ZL2USR.js +295 -0
  136. package/dist/bundle/store-maintenance-command-TIHOIKLZ.js +66 -0
  137. package/dist/bundle/surface-NW6T5OR6.js +65 -0
  138. package/dist/commands/api.d.ts +7 -0
  139. package/dist/commands/api.d.ts.map +1 -0
  140. package/dist/commands/api.js +49 -0
  141. package/dist/commands/api.js.map +1 -0
  142. package/dist/commands/session.d.ts +7 -0
  143. package/dist/commands/session.d.ts.map +1 -0
  144. package/dist/commands/session.js +26 -0
  145. package/dist/commands/session.js.map +1 -0
  146. package/dist/config.d.ts +24 -0
  147. package/dist/config.d.ts.map +1 -0
  148. package/dist/config.js +75 -0
  149. package/dist/config.js.map +1 -0
  150. package/dist/context.d.ts +59 -0
  151. package/dist/context.d.ts.map +1 -0
  152. package/dist/context.js +75 -0
  153. package/dist/context.js.map +1 -0
  154. package/dist/generated/definitions.d.ts +3 -0
  155. package/dist/generated/definitions.d.ts.map +1 -0
  156. package/dist/generated/definitions.js +8596 -0
  157. package/dist/generated/definitions.js.map +1 -0
  158. package/dist/generated/emoji.d.ts +2 -0
  159. package/dist/generated/emoji.d.ts.map +1 -0
  160. package/dist/generated/emoji.js +4265 -0
  161. package/dist/generated/emoji.js.map +1 -0
  162. package/dist/generated/manifest.d.ts +6 -0
  163. package/dist/generated/manifest.d.ts.map +1 -0
  164. package/dist/generated/manifest.js +6139 -0
  165. package/dist/generated/manifest.js.map +1 -0
  166. package/dist/generated/schemas.d.ts +631 -0
  167. package/dist/generated/schemas.d.ts.map +1 -0
  168. package/dist/generated/schemas.js +2426 -0
  169. package/dist/generated/schemas.js.map +1 -0
  170. package/dist/generated/types.d.ts +3220 -0
  171. package/dist/generated/types.d.ts.map +1 -0
  172. package/dist/generated/types.js +5 -0
  173. package/dist/generated/types.js.map +1 -0
  174. package/dist/identity.d.ts +29 -0
  175. package/dist/identity.d.ts.map +1 -0
  176. package/dist/identity.js +32 -0
  177. package/dist/identity.js.map +1 -0
  178. package/dist/index.d.ts +3 -0
  179. package/dist/index.d.ts.map +1 -0
  180. package/dist/index.js +3 -0
  181. package/dist/index.js.map +1 -0
  182. package/dist/messenger.d.ts +12 -0
  183. package/dist/messenger.d.ts.map +1 -0
  184. package/dist/messenger.js +184 -0
  185. package/dist/messenger.js.map +1 -0
  186. package/dist/program.d.ts +6 -0
  187. package/dist/program.d.ts.map +1 -0
  188. package/dist/program.js +116 -0
  189. package/dist/program.js.map +1 -0
  190. package/dist/reasons.d.ts +7 -0
  191. package/dist/reasons.d.ts.map +1 -0
  192. package/dist/reasons.js +20 -0
  193. package/dist/reasons.js.map +1 -0
  194. package/dist/setup/flow.d.ts +2 -0
  195. package/dist/setup/flow.d.ts.map +1 -0
  196. package/dist/setup/flow.js +83 -0
  197. package/dist/setup/flow.js.map +1 -0
  198. package/dist/setup/guide.d.ts +6 -0
  199. package/dist/setup/guide.d.ts.map +1 -0
  200. package/dist/setup/guide.js +13 -0
  201. package/dist/setup/guide.js.map +1 -0
  202. package/dist/setup/texts.d.ts +24 -0
  203. package/dist/setup/texts.d.ts.map +1 -0
  204. package/dist/setup/texts.js +24 -0
  205. package/dist/setup/texts.js.map +1 -0
  206. package/dist/slack/adapter.d.ts +36 -0
  207. package/dist/slack/adapter.d.ts.map +1 -0
  208. package/dist/slack/adapter.js +574 -0
  209. package/dist/slack/adapter.js.map +1 -0
  210. package/dist/slack/app-manifest.d.ts +25 -0
  211. package/dist/slack/app-manifest.d.ts.map +1 -0
  212. package/dist/slack/app-manifest.js +51 -0
  213. package/dist/slack/app-manifest.js.map +1 -0
  214. package/dist/slack/client.d.ts +45 -0
  215. package/dist/slack/client.d.ts.map +1 -0
  216. package/dist/slack/client.js +236 -0
  217. package/dist/slack/client.js.map +1 -0
  218. package/dist/slack/map.d.ts +437 -0
  219. package/dist/slack/map.d.ts.map +1 -0
  220. package/dist/slack/map.js +411 -0
  221. package/dist/slack/map.js.map +1 -0
  222. package/dist/slack/mrkdwn.d.ts +9 -0
  223. package/dist/slack/mrkdwn.d.ts.map +1 -0
  224. package/dist/slack/mrkdwn.js +56 -0
  225. package/dist/slack/mrkdwn.js.map +1 -0
  226. package/dist/slack/search.d.ts +24 -0
  227. package/dist/slack/search.d.ts.map +1 -0
  228. package/dist/slack/search.js +99 -0
  229. package/dist/slack/search.js.map +1 -0
  230. package/dist/slack/threads.d.ts +28 -0
  231. package/dist/slack/threads.d.ts.map +1 -0
  232. package/dist/slack/threads.js +56 -0
  233. package/dist/slack/threads.js.map +1 -0
  234. package/dist/slack/tokens.d.ts +17 -0
  235. package/dist/slack/tokens.d.ts.map +1 -0
  236. package/dist/slack/tokens.js +27 -0
  237. package/dist/slack/tokens.js.map +1 -0
  238. package/dist/slack/writes.d.ts +43 -0
  239. package/dist/slack/writes.d.ts.map +1 -0
  240. package/dist/slack/writes.js +277 -0
  241. package/dist/slack/writes.js.map +1 -0
  242. package/dist/version.d.ts +2 -0
  243. package/dist/version.d.ts.map +1 -0
  244. package/dist/version.js +2 -0
  245. package/dist/version.js.map +1 -0
  246. package/dist/wcat.d.ts +3 -0
  247. package/dist/wcat.d.ts.map +1 -0
  248. package/dist/wcat.js +4 -0
  249. package/dist/wcat.js.map +1 -0
  250. package/package.json +89 -4
  251. package/skills/slack-cli/SKILL.md +117 -0
  252. package/skills/slack-cli/references/api/api-admin.md +541 -0
  253. package/skills/slack-cli/references/api/api-api.md +13 -0
  254. package/skills/slack-cli/references/api/api-apps.md +78 -0
  255. package/skills/slack-cli/references/api/api-auth.md +18 -0
  256. package/skills/slack-cli/references/api/api-bots.md +12 -0
  257. package/skills/slack-cli/references/api/api-calls.md +68 -0
  258. package/skills/slack-cli/references/api/api-chat.md +123 -0
  259. package/skills/slack-cli/references/api/api-conversations.md +230 -0
  260. package/skills/slack-cli/references/api/api-dialog.md +13 -0
  261. package/skills/slack-cli/references/api/api-dnd.md +31 -0
  262. package/skills/slack-cli/references/api/api-emoji.md +8 -0
  263. package/skills/slack-cli/references/api/api-files.md +120 -0
  264. package/skills/slack-cli/references/api/api-migration.md +14 -0
  265. package/skills/slack-cli/references/api/api-pins.md +37 -0
  266. package/skills/slack-cli/references/api/api-reactions.md +58 -0
  267. package/skills/slack-cli/references/api/api-reminders.md +51 -0
  268. package/skills/slack-cli/references/api/api-search.md +18 -0
  269. package/skills/slack-cli/references/api/api-stars.md +42 -0
  270. package/skills/slack-cli/references/api/api-team.md +55 -0
  271. package/skills/slack-cli/references/api/api-usergroups.md +80 -0
  272. package/skills/slack-cli/references/api/api-users.md +101 -0
  273. package/skills/slack-cli/references/api/api-views.md +46 -0
  274. package/skills/slack-cli/references/api/api-workflows.md +36 -0
  275. package/skills/slack-cli/references/api.md +35 -0
@@ -0,0 +1,338 @@
1
+ import { createRequire as __bundleRequire } from "node:module";
2
+ const require = __bundleRequire(import.meta.url);
3
+ import {
4
+ throughWrapper
5
+ } from "./chunk-HXLXM7HV.js";
6
+ import {
7
+ environmentOf,
8
+ readOnlyLockOf
9
+ } from "./chunk-5LPREGD3.js";
10
+ import {
11
+ array,
12
+ boolean,
13
+ check,
14
+ pipe,
15
+ record,
16
+ safeParse,
17
+ strictObject,
18
+ string
19
+ } from "./chunk-S4UUN6LD.js";
20
+ import {
21
+ CliError
22
+ } from "./chunk-QLLBACDR.js";
23
+ import {
24
+ __name
25
+ } from "./chunk-ZVVMGPBJ.js";
26
+
27
+ // node_modules/.pnpm/@wirecat+cli-core@0.738.0_@wirecat+cli-base@0.132.0_@scalar+openapi-upgrader@0.4.6_comm_2f4ef0250212140e76029d09a7f79b43/node_modules/@wirecat/cli-core/dist/background/relay.js
28
+ import { createHash } from "node:crypto";
29
+ import { chmodSync, lstatSync, mkdirSync, rmSync } from "node:fs";
30
+ import { createConnection, createServer } from "node:net";
31
+ import { tmpdir } from "node:os";
32
+ import { dirname, isAbsolute, join } from "node:path";
33
+ import { PassThrough, Writable } from "node:stream";
34
+ var RELAY_PROTOCOL = 1;
35
+ var requestSchema = strictObject({
36
+ argv: array(string()),
37
+ env: record(string(), string()),
38
+ cwd: pipe(string(), check((path) => isAbsolute(path))),
39
+ tty: boolean(),
40
+ stdinTty: boolean()
41
+ });
42
+ var MAX_CLIENT_LINE = 1024 * 1024;
43
+ var MAX_SERVE_LINE = 64 * 1024 * 1024;
44
+ var MAX_SOCKET_PATH = 100;
45
+ var relayPath = /* @__PURE__ */ __name((lockPath) => {
46
+ const beside = lockPath.replace(/\.lock$/, ".sock");
47
+ if (beside.length <= MAX_SOCKET_PATH)
48
+ return beside;
49
+ const hash = createHash("sha256").update(beside).digest("hex").slice(0, 16);
50
+ const name = join(`wirecat-relay-${process.getuid?.() ?? "user"}`, `${hash}.sock`);
51
+ const temporary = join(tmpdir(), name);
52
+ if (temporary.length <= MAX_SOCKET_PATH || process.platform === "win32")
53
+ return temporary;
54
+ return join("/tmp", name);
55
+ }, "relayPath");
56
+ var privateDirectory = /* @__PURE__ */ __name((dir) => {
57
+ mkdirSync(dir, { recursive: true, mode: 448 });
58
+ const stat = lstatSync(dir);
59
+ const mine = process.getuid === void 0 || stat.uid === process.getuid();
60
+ if (!stat.isDirectory() || !mine || (stat.mode & 63) !== 0) {
61
+ throw new CliError("permission_error", `${dir} is not a private directory, so serve does not listen there`);
62
+ }
63
+ }, "privateDirectory");
64
+ var lines = /* @__PURE__ */ __name((socket, max, onLine, onTooLong) => {
65
+ let buffered = "";
66
+ socket.setEncoding("utf8");
67
+ socket.on("data", (chunk) => {
68
+ buffered += chunk;
69
+ for (let end = buffered.indexOf("\n"); end >= 0; end = buffered.indexOf("\n")) {
70
+ const line = buffered.slice(0, end);
71
+ buffered = buffered.slice(end + 1);
72
+ if (line)
73
+ onLine(line);
74
+ }
75
+ if (buffered.length > max)
76
+ onTooLong();
77
+ });
78
+ }, "lines");
79
+ var frame = /* @__PURE__ */ __name((socket, value) => {
80
+ if (!socket.destroyed)
81
+ socket.write(`${JSON.stringify(value)}
82
+ `);
83
+ }, "frame");
84
+ var listenRelay = /* @__PURE__ */ __name(async (path, run) => {
85
+ privateDirectory(dirname(path));
86
+ rmSync(path, { force: true });
87
+ const open = /* @__PURE__ */ new Set();
88
+ const running = /* @__PURE__ */ new Set();
89
+ const server = createServer((socket) => {
90
+ open.add(socket);
91
+ const stop = new AbortController();
92
+ const stdin = new PassThrough();
93
+ let started = false;
94
+ socket.on("error", () => {
95
+ });
96
+ socket.on("close", () => {
97
+ open.delete(socket);
98
+ stop.abort(new CliError("cancelled", "the client went away", { retryable: false }));
99
+ if (!stdin.writableEnded)
100
+ stdin.end();
101
+ });
102
+ lines(socket, MAX_CLIENT_LINE, (line) => {
103
+ let message;
104
+ try {
105
+ message = JSON.parse(line);
106
+ } catch {
107
+ socket.destroy();
108
+ return;
109
+ }
110
+ if (!started) {
111
+ started = true;
112
+ if (message.v !== RELAY_PROTOCOL) {
113
+ frame(socket, { diagnostic: `serve speaks relay protocol ${RELAY_PROTOCOL}; restart it`, exit: 1 });
114
+ socket.end();
115
+ return;
116
+ }
117
+ const parsed = safeParse(requestSchema, message.run);
118
+ if (!parsed.success) {
119
+ socket.destroy();
120
+ return;
121
+ }
122
+ stdin.isTTY = parsed.output.stdinTty;
123
+ if (parsed.output.stdinTty)
124
+ stdin.end();
125
+ const job = serve(socket, parsed.output, stdin, stop.signal, run);
126
+ running.add(job);
127
+ void job.then(() => running.delete(job), () => running.delete(job));
128
+ return;
129
+ }
130
+ if (typeof message.stdin === "string" && !stdin.writableEnded)
131
+ stdin.write(Buffer.from(message.stdin, "base64"));
132
+ if (message.stdinEnd === true && !stdin.writableEnded)
133
+ stdin.end();
134
+ }, () => socket.destroy());
135
+ });
136
+ await new Promise((resolve, reject) => {
137
+ server.once("error", reject);
138
+ server.listen(path, () => {
139
+ server.off("error", reject);
140
+ resolve();
141
+ });
142
+ });
143
+ chmodSync(path, 384);
144
+ return {
145
+ close: /* @__PURE__ */ __name(async () => {
146
+ for (const socket of open)
147
+ socket.destroy();
148
+ await new Promise((resolve) => server.close(() => resolve()));
149
+ await Promise.allSettled(running);
150
+ rmSync(path, { force: true });
151
+ }, "close")
152
+ };
153
+ }, "listenRelay");
154
+ var serve = /* @__PURE__ */ __name(async (socket, request, stdin, signal, run) => {
155
+ const streams = {
156
+ data: /* @__PURE__ */ __name((text) => frame(socket, { data: text }), "data"),
157
+ diagnostic: /* @__PURE__ */ __name((text) => frame(socket, { diagnostic: text }), "diagnostic"),
158
+ progress: /* @__PURE__ */ __name((text) => frame(socket, { progress: text }), "progress")
159
+ };
160
+ const stdout = new Writable({
161
+ write: /* @__PURE__ */ __name((chunk, _encoding, done) => {
162
+ frame(socket, { raw: Buffer.from(chunk).toString("base64") });
163
+ done();
164
+ }, "write")
165
+ });
166
+ let code = 1;
167
+ try {
168
+ code = await run(request, { streams, stdin, stdout, signal });
169
+ } finally {
170
+ frame(socket, { exit: code });
171
+ socket.end();
172
+ }
173
+ }, "serve");
174
+ var relayCommand = /* @__PURE__ */ __name((path, request, options) => new Promise((resolve, reject) => {
175
+ const { streams, stdin, stdout, signal, deadlineMs, writes, holder, listens = false } = options;
176
+ const socket = createConnection(path);
177
+ let connected = false;
178
+ let settled = false;
179
+ let timer;
180
+ const forward = /* @__PURE__ */ __name((chunk) => frame(socket, { stdin: Buffer.from(chunk).toString("base64") }), "forward");
181
+ const ended = /* @__PURE__ */ __name(() => frame(socket, { stdinEnd: true }), "ended");
182
+ const brokenPipe = /* @__PURE__ */ __name((error) => {
183
+ if (error.code === "EPIPE")
184
+ finish({ code: 0 });
185
+ }, "brokenPipe");
186
+ const finish = /* @__PURE__ */ __name((outcome) => {
187
+ if (settled)
188
+ return;
189
+ settled = true;
190
+ if (timer)
191
+ clearTimeout(timer);
192
+ stdout.off("error", brokenPipe);
193
+ signal.removeEventListener("abort", aborted);
194
+ stdin.off("data", forward).off("end", ended);
195
+ stdin.pause();
196
+ socket.destroy();
197
+ if ("code" in outcome)
198
+ resolve(outcome.code);
199
+ else
200
+ reject(outcome.error);
201
+ }, "finish");
202
+ const stopped = /* @__PURE__ */ __name(() => writes ? new CliError("outcome_unknown", `${holder} stopped before the command finished; it may have run \u2014 check before repeating it`, { retryable: false }) : new CliError("provider_unavailable", `${holder} stopped before the command finished`, { retryable: true }), "stopped");
203
+ const aborted = /* @__PURE__ */ __name(() => finish(listens ? { code: 0 } : { error: signal.reason }), "aborted");
204
+ if (signal.aborted)
205
+ return aborted();
206
+ signal.addEventListener("abort", aborted, { once: true });
207
+ stdout.on("error", brokenPipe);
208
+ if (deadlineMs !== void 0)
209
+ timer = setTimeout(() => finish({ error: stopped() }), deadlineMs);
210
+ socket.on("connect", () => {
211
+ connected = true;
212
+ frame(socket, { v: RELAY_PROTOCOL, run: request });
213
+ if (request.stdinTty)
214
+ ended();
215
+ else {
216
+ stdin.on("data", forward).once("end", ended);
217
+ stdin.resume();
218
+ }
219
+ });
220
+ socket.on("error", (error) => {
221
+ if (connected)
222
+ return finish({ error: stopped() });
223
+ finish({
224
+ error: new CliError("provider_unavailable", `${holder} holds the connection but does not answer its relay (${error.code ?? error.message}) \u2014 restart it`, { retryable: false, sent: false })
225
+ });
226
+ });
227
+ socket.on("close", () => finish({ error: stopped() }));
228
+ lines(socket, MAX_SERVE_LINE, (line) => {
229
+ let message;
230
+ try {
231
+ message = JSON.parse(line);
232
+ } catch {
233
+ return finish({ error: stopped() });
234
+ }
235
+ if (typeof message.data === "string")
236
+ streams.data(message.data);
237
+ if (typeof message.diagnostic === "string")
238
+ streams.diagnostic(message.diagnostic);
239
+ if (typeof message.progress === "string")
240
+ streams.progress?.(message.progress);
241
+ if (typeof message.raw === "string")
242
+ stdout.write(Buffer.from(message.raw, "base64"));
243
+ if (typeof message.exit === "number")
244
+ finish({ code: message.exit });
245
+ }, () => finish({ error: stopped() }));
246
+ }), "relayCommand");
247
+
248
+ // node_modules/.pnpm/@wirecat+cli-core@0.738.0_@wirecat+cli-base@0.132.0_@scalar+openapi-upgrader@0.4.6_comm_2f4ef0250212140e76029d09a7f79b43/node_modules/@wirecat/cli-core/dist/cli/messenger/serve-relay.js
249
+ var lentConnection = /* @__PURE__ */ __name((connection, watchers) => throughWrapper(connection, {
250
+ close: /* @__PURE__ */ __name(async () => {
251
+ }, "close"),
252
+ feed: void 0,
253
+ storedChats: void 0,
254
+ listen: void 0,
255
+ listenHistory: void 0,
256
+ ...connection.watch && watchers ? {
257
+ // A watcher that throws (its output limit, a closed reader) ends its own watch, never serve's.
258
+ watch: /* @__PURE__ */ __name(async (onEvent, signal, onReady) => {
259
+ let watcher;
260
+ try {
261
+ await new Promise((resolve, reject) => {
262
+ watcher = /* @__PURE__ */ __name((event) => {
263
+ try {
264
+ onEvent(event);
265
+ } catch (error) {
266
+ reject(error);
267
+ }
268
+ }, "watcher");
269
+ watchers.add(watcher);
270
+ signal.addEventListener("abort", () => resolve(), { once: true });
271
+ onReady?.();
272
+ if (signal.aborted)
273
+ resolve();
274
+ });
275
+ } finally {
276
+ if (watcher)
277
+ watchers.delete(watcher);
278
+ }
279
+ }, "watch")
280
+ } : { watch: void 0 }
281
+ }), "lentConnection");
282
+ var serveRelay = /* @__PURE__ */ __name((command, messenger) => {
283
+ let held;
284
+ let relay;
285
+ const watchers = /* @__PURE__ */ new Set();
286
+ const borrowed = /* @__PURE__ */ __name(() => {
287
+ const connection = held;
288
+ if (!connection)
289
+ throw new CliError("provider_unavailable", "serve is not connected yet", { retryable: true });
290
+ return lentConnection(connection, watchers);
291
+ }, "borrowed");
292
+ return {
293
+ messenger: {
294
+ ...messenger,
295
+ connect: /* @__PURE__ */ __name(async (...args) => {
296
+ held = await messenger.connect(...args);
297
+ return held;
298
+ }, "connect")
299
+ },
300
+ arrived: /* @__PURE__ */ __name((event) => {
301
+ for (const watcher of watchers)
302
+ watcher(event);
303
+ }, "arrived"),
304
+ /** Listens beside the lock; the address goes into it, which is how a client finds it. */
305
+ open: /* @__PURE__ */ __name(async (lockPath, profile) => {
306
+ const environment = environmentOf(command);
307
+ const runCommand = environment.runCommand;
308
+ if (!runCommand)
309
+ return void 0;
310
+ const readOnly = readOnlyLockOf(messenger.app, environment.env ?? process.env);
311
+ const path = relayPath(lockPath);
312
+ relay = await listenRelay(path, (request, io) => runCommand(request.argv, {
313
+ env: {
314
+ ...request.env,
315
+ ...readOnly ? { [`${messenger.app.envPrefix}_READ_ONLY`]: "1" } : {}
316
+ },
317
+ streams: io.streams,
318
+ stdin: io.stdin,
319
+ stdout: io.stdout,
320
+ tty: request.tty,
321
+ signal: io.signal,
322
+ answer: /* @__PURE__ */ __name(() => null, "answer"),
323
+ relayed: { profile, cwd: request.cwd, connection: borrowed }
324
+ }));
325
+ return { path, protocol: RELAY_PROTOCOL };
326
+ }, "open"),
327
+ close: /* @__PURE__ */ __name(async () => {
328
+ await relay?.close();
329
+ }, "close")
330
+ };
331
+ }, "serveRelay");
332
+
333
+ export {
334
+ RELAY_PROTOCOL,
335
+ relayCommand,
336
+ lentConnection,
337
+ serveRelay
338
+ };
@@ -0,0 +1,319 @@
1
+ import { createRequire as __bundleRequire } from "node:module";
2
+ const require = __bundleRequire(import.meta.url);
3
+ import {
4
+ wrapAnsi
5
+ } from "./chunk-EH6ZEJGT.js";
6
+ import {
7
+ WIRECAT_TOOLS
8
+ } from "./chunk-JGRWMR5H.js";
9
+ import {
10
+ commandPathOf,
11
+ outputOf
12
+ } from "./chunk-7BEO72EN.js";
13
+ import {
14
+ Command,
15
+ Help,
16
+ NO_EFFECTS,
17
+ Option,
18
+ annotate,
19
+ commandAt,
20
+ environmentOf,
21
+ metaOf,
22
+ takesProfile
23
+ } from "./chunk-5LPREGD3.js";
24
+ import {
25
+ writes
26
+ } from "./chunk-CMZBCWND.js";
27
+ import {
28
+ CliError
29
+ } from "./chunk-QLLBACDR.js";
30
+ import {
31
+ __name
32
+ } from "./chunk-ZVVMGPBJ.js";
33
+
34
+ // node_modules/.pnpm/@wirecat+cli-core@0.738.0_@wirecat+cli-base@0.132.0_@scalar+openapi-upgrader@0.4.6_comm_2f4ef0250212140e76029d09a7f79b43/node_modules/@wirecat/cli-core/dist/cli/help/command-help.js
35
+ var ARGUMENT_KINDS = {
36
+ chat: "chat",
37
+ chats: "chat",
38
+ message: "message",
39
+ messages: "message",
40
+ post: "message",
41
+ person: "person",
42
+ people: "person",
43
+ task: "task",
44
+ meeting: "meeting",
45
+ folder: "folder",
46
+ folders: "folder",
47
+ topic: "topic",
48
+ note: "note",
49
+ document: "document",
50
+ model: "model"
51
+ };
52
+ var ENTITY_KINDS = {
53
+ message: "message",
54
+ message_link: "message",
55
+ chat: "chat",
56
+ contact: "person",
57
+ member: "person",
58
+ person: "person",
59
+ task: "task",
60
+ meeting: "meeting",
61
+ meeting_details: "meeting",
62
+ meeting_hit: "meeting",
63
+ meeting_summary: "meeting",
64
+ folder: "folder",
65
+ topic: "topic",
66
+ note: "note",
67
+ document: "document",
68
+ model: "model"
69
+ };
70
+ var HOME = {
71
+ chat: "chats",
72
+ message: "messages",
73
+ person: "contacts",
74
+ task: "tasks",
75
+ meeting: "meetings",
76
+ folder: "folders",
77
+ topic: "topics",
78
+ note: "notes",
79
+ document: "documents",
80
+ model: "models"
81
+ };
82
+ var SAMPLES = {
83
+ chat: "Team",
84
+ message: "1234",
85
+ post: "1234",
86
+ person: "Anna",
87
+ people: "Anna",
88
+ task: "12",
89
+ meeting: "123",
90
+ folder: "Work",
91
+ topic: "General",
92
+ model: "default",
93
+ query: '"invoice"',
94
+ text: '"on my way"',
95
+ title: '"Weekly sync"',
96
+ name: "daily",
97
+ id: "1",
98
+ file: "./report.pdf",
99
+ link: "https://example.com/join/abc",
100
+ url: "https://example.com",
101
+ since: "1d",
102
+ duration: "1d",
103
+ limit: "20"
104
+ };
105
+ var MAX_NEXT = 3;
106
+ var choices = /* @__PURE__ */ new WeakMap();
107
+ var kindOfArgument = /* @__PURE__ */ __name((argument) => ARGUMENT_KINDS[argument.name()], "kindOfArgument");
108
+ var runs = /* @__PURE__ */ __name((command) => command.commands.length === 0 || Boolean(command._actionHandler), "runs");
109
+ var leaves = /* @__PURE__ */ __name((command) => command.commands.filter((child) => !child._hidden).flatMap((child) => [...runs(child) ? [child] : [], ...leaves(child)]), "leaves");
110
+ var rootOf = /* @__PURE__ */ __name((command) => {
111
+ let at = command;
112
+ while (at.parent)
113
+ at = at.parent;
114
+ return at;
115
+ }, "rootOf");
116
+ var call = /* @__PURE__ */ __name((command) => [
117
+ rootOf(command).name(),
118
+ ...commandPathOf(command),
119
+ ...command.registeredArguments.map((one) => one.required ? `<${one.name()}>` : `[${one.name()}]`)
120
+ ].join(" "), "call");
121
+ var fieldsOf = /* @__PURE__ */ __name((schema) => {
122
+ const variants = schema.anyOf;
123
+ if (variants)
124
+ return variants.flatMap(fieldsOf);
125
+ const required = schema.required ?? [];
126
+ return [...required, ...Object.keys(schema.properties ?? {})];
127
+ }, "fieldsOf");
128
+ var returnsOf = /* @__PURE__ */ __name((command) => {
129
+ const output = metaOf(command).output;
130
+ const { item, coverage } = outputOf(command);
131
+ if (!output || coverage !== "declared-entity")
132
+ return "";
133
+ const fields = [...new Set(fieldsOf(item))];
134
+ const noun = (output.view ? `${output.entity} ${output.view}` : output.entity).replaceAll("_", " ");
135
+ const more = fields.length > 8 ? `, and ${fields.length - 8} more` : "";
136
+ const root = rootOf(command);
137
+ const schema = commandAt(root, "commands info") ? `; every field: ${root.name()} commands info ${commandPathOf(command).join(" ")}` : "";
138
+ return `${noun} \u2014 ${fields.slice(0, 8).join(", ")}${more}${schema}`;
139
+ }, "returnsOf");
140
+ var nextOf = /* @__PURE__ */ __name((command) => {
141
+ const root = rootOf(command);
142
+ const choice = choices.get(command) ?? {};
143
+ const drop = new Set(choice.drop ?? []);
144
+ const pinned = (choice.pin ?? []).flatMap((path) => commandAt(root, path) ?? []);
145
+ const output = metaOf(command).output;
146
+ const kind = output ? ENTITY_KINDS[output.entity] : void 0;
147
+ const all = leaves(root);
148
+ const derived = kind ? all.filter((other) => other !== command && !pinned.includes(other)).filter((other) => other.registeredArguments.some((argument) => kindOfArgument(argument) === kind)).map((other, order) => ({ other, order })).sort((a, b) => {
149
+ const rank = /* @__PURE__ */ __name((other) => [
150
+ Number(writes(metaOf(other).effects)),
151
+ Number(!other.registeredArguments.some((one) => one.required && kindOfArgument(one) === kind)),
152
+ Number(commandPathOf(other)[0] !== HOME[kind]),
153
+ Number(other.parent !== command.parent)
154
+ ], "rank");
155
+ const [left, right] = [rank(a.other), rank(b.other)];
156
+ return left.reduce((found, value, at) => found || value - (right[at] ?? 0), 0) || a.order - b.order;
157
+ }).map(({ other }) => other) : [];
158
+ return [...pinned, ...derived].filter((other) => !drop.has(commandPathOf(other).join(" "))).slice(0, MAX_NEXT);
159
+ }, "nextOf");
160
+ var sample = /* @__PURE__ */ __name((name) => SAMPLES[name] ?? `<${name}>`, "sample");
161
+ var generatedExample = /* @__PURE__ */ __name((command) => {
162
+ const { query } = metaOf(command);
163
+ const words = command.registeredArguments.flatMap((argument) => {
164
+ const name = argument.name();
165
+ if (name === "query" && query)
166
+ return [];
167
+ if (!argument.required && SAMPLES[name] === void 0)
168
+ return [];
169
+ return [argument.argChoices?.[0] ?? sample(name)];
170
+ });
171
+ const options = command.options.filter((option) => option.mandatory).flatMap((option) => {
172
+ const flag = option.long ?? option.short ?? option.flags;
173
+ const placeholder = /[<[]([^>\]]+)[>\]]/.exec(option.flags)?.[1];
174
+ if (!(option.required || option.optional))
175
+ return [flag];
176
+ return [flag, option.argChoices?.[0] ?? sample(placeholder ?? option.attributeName())];
177
+ });
178
+ return [rootOf(command).name(), ...commandPathOf(command), ...words, ...options].join(" ");
179
+ }, "generatedExample");
180
+ var profiled = /* @__PURE__ */ new WeakSet();
181
+ var EXAMPLE_PROFILE = "personal";
182
+ var withProfile = /* @__PURE__ */ __name((command, example) => {
183
+ const root = rootOf(command);
184
+ const top = commandPathOf(command)[0];
185
+ if (!profiled.has(root) || top === void 0 || !takesProfile(command))
186
+ return example;
187
+ if (example.split(" ").includes("--profiles"))
188
+ return example;
189
+ const prefix = `${root.name()} ${top}`;
190
+ return example === prefix || example.startsWith(`${prefix} `) ? `${root.name()} ${EXAMPLE_PROFILE} ${example.slice(root.name().length + 1)}` : example;
191
+ }, "withProfile");
192
+ var commandHelp = /* @__PURE__ */ __name((command) => {
193
+ const written = metaOf(command).examples ?? [];
194
+ return {
195
+ returns: returnsOf(command),
196
+ next: nextOf(command).map(call),
197
+ examples: (written.length > 0 ? written : [generatedExample(command)]).map((one) => withProfile(command, one)),
198
+ origin: written.length > 0 ? "written" : "generated"
199
+ };
200
+ }, "commandHelp");
201
+ var LABEL = 15;
202
+ var commandHelpText = /* @__PURE__ */ __name((command) => {
203
+ const { returns, next, examples } = commandHelp(command);
204
+ const rows = /* @__PURE__ */ __name((label, values) => values.map((value, at) => `${(at === 0 ? label : "").padEnd(LABEL)}${value}`), "rows");
205
+ const availability = environmentOf(command).discoveryAvailability?.({
206
+ ...metaOf(command),
207
+ path: commandPathOf(command)
208
+ });
209
+ const profileMatters = profiled.has(rootOf(command)) && takesProfile(command);
210
+ const access = !availability ? [] : availability.available ? profileMatters ? rows("Availability:", ["available for this profile"]) : [] : rows("Availability:", [`unavailable \u2014 ${availability.reason}`]);
211
+ return [
212
+ "",
213
+ ...access,
214
+ ...rows("Returns:", returns ? [returns] : []),
215
+ ...rows("Next usually:", next),
216
+ ...rows("Example:", examples),
217
+ ""
218
+ ].join("\n");
219
+ }, "commandHelpText");
220
+ var installCommandHelp = /* @__PURE__ */ __name((program, { profile = true } = {}) => {
221
+ if (profile)
222
+ profiled.add(program);
223
+ for (const command of leaves(program))
224
+ command.addHelpText("after", () => commandHelpText(command));
225
+ }, "installCommandHelp");
226
+
227
+ // node_modules/.pnpm/@wirecat+cli-core@0.738.0_@wirecat+cli-base@0.132.0_@scalar+openapi-upgrader@0.4.6_comm_2f4ef0250212140e76029d09a7f79b43/node_modules/@wirecat/cli-core/dist/cli/help/first-screen.js
228
+ var WIDTH = 100;
229
+ var widest = /* @__PURE__ */ __name((texts) => texts.reduce((most, text) => Math.max(most, text.length), 0), "widest");
230
+ var block = /* @__PURE__ */ __name((title, rows, column) => rows.length === 0 ? [] : ["", `${title}:`, ...rows.map(([left, right]) => ` ${left.padEnd(column)}${right}`)], "block");
231
+ var TOPICS = [
232
+ ["--json", "output"],
233
+ ["--offline", "offline"],
234
+ ["--timeout", "timeouts"],
235
+ ["--dry-run", "dry run"]
236
+ ];
237
+ var optionTopics = /* @__PURE__ */ __name((program) => {
238
+ const longs = new Set(program.options.map((option) => option.long));
239
+ const topics = TOPICS.filter(([long]) => longs.has(long)).map(([, topic]) => topic);
240
+ return topics.length > 0 ? topics.join(", ") : "the options every command takes";
241
+ }, "optionTopics");
242
+ var pointers = /* @__PURE__ */ __name((program, cli, start, profile) => {
243
+ const has = /* @__PURE__ */ __name((path) => commandAt(program, path) !== void 0, "has");
244
+ const next = [
245
+ has("commands") ? [`${cli} commands`, "every command, by section"] : void 0,
246
+ has("guide") ? [`${cli} guide`, "scenarios: command sequences for common tasks"] : void 0,
247
+ [`${cli} help options`, optionTopics(program)]
248
+ ].filter((row) => row !== void 0);
249
+ const rows = [
250
+ ...start ? [["Start here:", start, profile ? "(any profile name works)" : ""]] : [],
251
+ ...has("account list") ? [["", `${cli} account list`, "your profiles and their logged-in accounts"]] : [],
252
+ ...next.map(([command = "", does = ""], at) => [at === 0 ? "Next:" : "", command, does]),
253
+ ...has("skill show") ? [["For agents:", `${cli} skill show`, "rules and the discovery loop"]] : []
254
+ ];
255
+ const width = widest(rows.map(([, command]) => command)) + 2;
256
+ return ["", ...rows.map(([label, command, does]) => `${label.padEnd(14)}${command.padEnd(width)}${does}`.trimEnd())];
257
+ }, "pointers");
258
+ var firstScreen = /* @__PURE__ */ __name((program, screen = {}) => {
259
+ const cli = program.name();
260
+ const profile = screen.profile !== false;
261
+ const pitch = screen.pitch ?? program.description().split("\n")[0] ?? "";
262
+ const can = (screen.can ?? []).map(({ command, does }) => [command, does]);
263
+ const works = WIRECAT_TOOLS.filter((tool) => tool.command !== cli).map(({ command, shown, does }) => [shown ?? command, does]);
264
+ const column = Math.max(22, widest([...can, ...works].map(([left]) => left))) + 2;
265
+ const start = screen.start ?? (commandAt(program, "setup") ? `${cli} ${EXAMPLE_PROFILE} setup` : void 0);
266
+ return [
267
+ wrapAnsi(`${cli} \u2014 ${pitch}`, WIDTH),
268
+ "",
269
+ `Usage: ${cli} ${profile ? "<profile> " : ""}<command> [options]`,
270
+ ...profile ? ["Account commands start with your profile, a name you choose; none is ever assumed."] : [],
271
+ ...block("What you can do", can, column),
272
+ ...block("Works with", works, column),
273
+ ...pointers(program, cli, start, profile),
274
+ ""
275
+ ].join("\n");
276
+ }, "firstScreen");
277
+ var optionsScreen = /* @__PURE__ */ __name((program) => {
278
+ const helper = program.createHelp();
279
+ const width = helper.longestOptionTermLength(program, helper);
280
+ return [
281
+ `Options for every ${program.name()} command:`,
282
+ ...helper.visibleOptions(program).map((option) => helper.formatItem(helper.optionTerm(option), width, helper.optionDescription(option), helper)),
283
+ ""
284
+ ].join("\n");
285
+ }, "optionsScreen");
286
+ var installHelp = /* @__PURE__ */ __name((program, screen = {}) => {
287
+ let full = false;
288
+ const own = program.configureHelp();
289
+ program.configureHelp({
290
+ ...own,
291
+ // Commander copies this configuration to children made with `.command()`, so only the root gets the screen.
292
+ formatHelp: /* @__PURE__ */ __name((command, helper) => command === program && !full ? firstScreen(program, screen) : (own.formatHelp ?? Help.prototype.formatHelp).call(helper, command, helper), "formatHelp")
293
+ });
294
+ installCommandHelp(program, { profile: screen.profile !== false });
295
+ program.addOption(new Option("--help-all", "the full help: every command and option").hideHelp());
296
+ program.on("option:help-all", () => {
297
+ full = true;
298
+ program.help();
299
+ });
300
+ if (program.commands.some((command) => command.name() === "help"))
301
+ return program;
302
+ const help = annotate(new Command("help"), { effects: NO_EFFECTS, mcp: false }).description("this screen; help options: the options for every command; help <command>: that command's help").argument("[topic...]", "options, or a command path").action((topic) => {
303
+ if (topic.length === 0)
304
+ return program.outputHelp();
305
+ if (topic.length === 1 && topic[0] === "options")
306
+ return program.configureOutput().writeOut?.(optionsScreen(program));
307
+ const command = commandAt(program, topic.join(" "));
308
+ if (!command)
309
+ throw new CliError("validation_error", `no command "${topic.join(" ")}" \u2014 run \`${program.name()} help\`, or \`${program.name()} help options\``, { available: program.commands.map((one) => one.name()).filter((name) => name !== "help") });
310
+ command.outputHelp();
311
+ });
312
+ program.addCommand(help, { hidden: true });
313
+ return program;
314
+ }, "installHelp");
315
+
316
+ export {
317
+ firstScreen,
318
+ installHelp
319
+ };