@wirecat/amo-cli 0.6.0 → 0.8.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 (282) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/README.md +2 -2
  3. package/contracts/wirecat.json +14 -0
  4. package/dist/amo/button.js +1 -1
  5. package/dist/amo/json.js +1 -1
  6. package/dist/amo/oauth.js +1 -2
  7. package/dist/amo/transport.js +1 -2
  8. package/dist/api-keys.js +1 -1
  9. package/dist/bin/amo.js +11 -11
  10. package/dist/bundle/amo.js +5 -183
  11. package/dist/bundle/{chunk-FYOPPKAN.js → chunk-3HWD4BKU.js} +4 -6
  12. package/dist/bundle/{chunk-GOCMJBEE.js → chunk-4EXURQQQ.js} +21 -19
  13. package/dist/bundle/{chunk-SWCJM3YD.js → chunk-6ZPPFFIH.js} +3 -3
  14. package/dist/bundle/chunk-AEWYRB6F.js +8 -0
  15. package/dist/bundle/{chunk-RNWUCAJJ.js → chunk-PVVSHDMQ.js} +7 -15
  16. package/dist/bundle/chunk-SV4CS5TA.js +76 -0
  17. package/dist/bundle/program-RA6QICVH.js +2352 -0
  18. package/dist/bundle/{instructions-4H7UREH2.js → source-C65ZJUTW.js} +5 -6
  19. package/dist/bundle/store-35UXUNVG.js +12 -0
  20. package/dist/bundle/writer-I7GBI3VE.js +12 -0
  21. package/dist/commands/account.js +1 -1
  22. package/dist/commands/api.js +1 -3
  23. package/dist/commands/crm-shared.js +2 -3
  24. package/dist/commands/schedule.js +1 -1
  25. package/dist/commands/session.js +1 -3
  26. package/dist/commands/write.js +1 -2
  27. package/dist/config.js +1 -2
  28. package/dist/context.js +1 -2
  29. package/dist/crm/activities.js +1 -1
  30. package/dist/crm/records.js +1 -1
  31. package/dist/crm/source.js +1 -1
  32. package/dist/crm/writer.js +1 -1
  33. package/dist/identity.js +4 -0
  34. package/dist/program.js +1 -2
  35. package/dist/setup/flow.js +1 -1
  36. package/dist/store.js +1 -1
  37. package/dist/version.js +1 -1
  38. package/dist/whoami.js +1 -1
  39. package/package.json +3 -3
  40. package/scenarios/first-sync.md +13 -11
  41. package/scenarios/keep-in-sync.md +7 -6
  42. package/scenarios/safe-agent-writes.md +10 -9
  43. package/dist/amo/account.d.ts +0 -18
  44. package/dist/amo/account.d.ts.map +0 -1
  45. package/dist/amo/account.js.map +0 -1
  46. package/dist/amo/allow-list.d.ts +0 -31
  47. package/dist/amo/allow-list.d.ts.map +0 -1
  48. package/dist/amo/allow-list.js.map +0 -1
  49. package/dist/amo/button.d.ts +0 -53
  50. package/dist/amo/button.d.ts.map +0 -1
  51. package/dist/amo/button.js.map +0 -1
  52. package/dist/amo/errors.d.ts +0 -12
  53. package/dist/amo/errors.d.ts.map +0 -1
  54. package/dist/amo/errors.js.map +0 -1
  55. package/dist/amo/json.d.ts +0 -3
  56. package/dist/amo/json.d.ts.map +0 -1
  57. package/dist/amo/json.js.map +0 -1
  58. package/dist/amo/oauth.d.ts +0 -64
  59. package/dist/amo/oauth.d.ts.map +0 -1
  60. package/dist/amo/oauth.js.map +0 -1
  61. package/dist/amo/operation.d.ts +0 -45
  62. package/dist/amo/operation.d.ts.map +0 -1
  63. package/dist/amo/operation.js.map +0 -1
  64. package/dist/amo/operations.d.ts +0 -3
  65. package/dist/amo/operations.d.ts.map +0 -1
  66. package/dist/amo/operations.js.map +0 -1
  67. package/dist/amo/routes.d.ts +0 -67
  68. package/dist/amo/routes.d.ts.map +0 -1
  69. package/dist/amo/routes.js.map +0 -1
  70. package/dist/amo/transport.d.ts +0 -62
  71. package/dist/amo/transport.d.ts.map +0 -1
  72. package/dist/amo/transport.js.map +0 -1
  73. package/dist/api-keys.d.ts +0 -47
  74. package/dist/api-keys.d.ts.map +0 -1
  75. package/dist/api-keys.js.map +0 -1
  76. package/dist/bin/amo.d.ts +0 -3
  77. package/dist/bin/amo.d.ts.map +0 -1
  78. package/dist/bin/amo.js.map +0 -1
  79. package/dist/bundle/agent-VVACEKSX.js +0 -42
  80. package/dist/bundle/all-profiles-QNUKL4NA.js +0 -320
  81. package/dist/bundle/anthropic-PQN6MNP7.js +0 -90
  82. package/dist/bundle/app-server-Q2QEA7GP.js +0 -258
  83. package/dist/bundle/areas-27FRPBF3.js +0 -71
  84. package/dist/bundle/bun-F4M4KCNA.js +0 -169
  85. package/dist/bundle/bun-sqlite-P5IDBDVR.js +0 -75
  86. package/dist/bundle/chunk-22KAQPX7.js +0 -58
  87. package/dist/bundle/chunk-2JGNMZ55.js +0 -338
  88. package/dist/bundle/chunk-2VDHC7QO.js +0 -288
  89. package/dist/bundle/chunk-34ZOMVUK.js +0 -185
  90. package/dist/bundle/chunk-3J3EDSXF.js +0 -1939
  91. package/dist/bundle/chunk-3TYER5IK.js +0 -80
  92. package/dist/bundle/chunk-5NGLCDYQ.js +0 -106
  93. package/dist/bundle/chunk-5SQTHOBI.js +0 -12313
  94. package/dist/bundle/chunk-6GE36KUE.js +0 -360
  95. package/dist/bundle/chunk-6GZKY3HV.js +0 -3752
  96. package/dist/bundle/chunk-6OV2TRGF.js +0 -362
  97. package/dist/bundle/chunk-7CPIZFOE.js +0 -460
  98. package/dist/bundle/chunk-A5K2NU3K.js +0 -37780
  99. package/dist/bundle/chunk-ADLS6FVG.js +0 -24600
  100. package/dist/bundle/chunk-AEC4H5WZ.js +0 -259
  101. package/dist/bundle/chunk-APBEDWOE.js +0 -1718
  102. package/dist/bundle/chunk-AQ5RIOUE.js +0 -633
  103. package/dist/bundle/chunk-B7L5MSRP.js +0 -136
  104. package/dist/bundle/chunk-C7JPYWYQ.js +0 -77
  105. package/dist/bundle/chunk-D72URWJE.js +0 -532
  106. package/dist/bundle/chunk-DFDN6AUB.js +0 -21
  107. package/dist/bundle/chunk-DIZEHPS6.js +0 -1347
  108. package/dist/bundle/chunk-DNCLQPOM.js +0 -7
  109. package/dist/bundle/chunk-DPV53EZC.js +0 -206
  110. package/dist/bundle/chunk-DUPCDJ3W.js +0 -357
  111. package/dist/bundle/chunk-DWT24UVR.js +0 -388
  112. package/dist/bundle/chunk-DXWJORSY.js +0 -1703
  113. package/dist/bundle/chunk-DY3PLWIH.js +0 -332
  114. package/dist/bundle/chunk-DYWHAJRK.js +0 -1259
  115. package/dist/bundle/chunk-EH6ZEJGT.js +0 -932
  116. package/dist/bundle/chunk-EXRM3ML4.js +0 -76
  117. package/dist/bundle/chunk-FFER7KJI.js +0 -407
  118. package/dist/bundle/chunk-FIP2DG7W.js +0 -64
  119. package/dist/bundle/chunk-FTH6WGYO.js +0 -24
  120. package/dist/bundle/chunk-FWRLGIF6.js +0 -5304
  121. package/dist/bundle/chunk-G3N2RHGF.js +0 -738
  122. package/dist/bundle/chunk-G46PNDWL.js +0 -58
  123. package/dist/bundle/chunk-G6NY7LFB.js +0 -230
  124. package/dist/bundle/chunk-GRGCZSES.js +0 -1007
  125. package/dist/bundle/chunk-GVSKLZRD.js +0 -30
  126. package/dist/bundle/chunk-GZ7WBU5Y.js +0 -18
  127. package/dist/bundle/chunk-HN2LCLGT.js +0 -1068
  128. package/dist/bundle/chunk-HO4JGD4Q.js +0 -16
  129. package/dist/bundle/chunk-HOF7GQWW.js +0 -142
  130. package/dist/bundle/chunk-HUAHLO6N.js +0 -29
  131. package/dist/bundle/chunk-IDCZ4LWS.js +0 -150
  132. package/dist/bundle/chunk-IN3VL7UU.js +0 -560
  133. package/dist/bundle/chunk-ISQ23VKV.js +0 -123
  134. package/dist/bundle/chunk-JVBCQHCS.js +0 -80
  135. package/dist/bundle/chunk-K5W7YEHB.js +0 -9541
  136. package/dist/bundle/chunk-KAFSS35C.js +0 -193
  137. package/dist/bundle/chunk-KLRCTMES.js +0 -100
  138. package/dist/bundle/chunk-KYRYD4CR.js +0 -38
  139. package/dist/bundle/chunk-LBZSURLL.js +0 -798
  140. package/dist/bundle/chunk-LC7ZD2RW.js +0 -92
  141. package/dist/bundle/chunk-LH6FJYMO.js +0 -334
  142. package/dist/bundle/chunk-LJKINNWC.js +0 -209
  143. package/dist/bundle/chunk-M36XP74N.js +0 -86
  144. package/dist/bundle/chunk-MNPGZCKE.js +0 -361
  145. package/dist/bundle/chunk-MRPMORLH.js +0 -353
  146. package/dist/bundle/chunk-NNREILWP.js +0 -189
  147. package/dist/bundle/chunk-NSOY4FMN.js +0 -159
  148. package/dist/bundle/chunk-OEEWVKJX.js +0 -53
  149. package/dist/bundle/chunk-OGJFDKDL.js +0 -161
  150. package/dist/bundle/chunk-PATZAYFZ.js +0 -453
  151. package/dist/bundle/chunk-PCR6GFNP.js +0 -1171
  152. package/dist/bundle/chunk-PL5P7UKW.js +0 -25216
  153. package/dist/bundle/chunk-Q4MH2O5E.js +0 -108
  154. package/dist/bundle/chunk-QFOP3KUP.js +0 -2603
  155. package/dist/bundle/chunk-QQRJEWKB.js +0 -1197
  156. package/dist/bundle/chunk-S6JG4YUH.js +0 -72
  157. package/dist/bundle/chunk-SDVUGWD7.js +0 -614
  158. package/dist/bundle/chunk-SEFE6PGL.js +0 -218
  159. package/dist/bundle/chunk-SYRDEMQE.js +0 -68141
  160. package/dist/bundle/chunk-SYYQZDHJ.js +0 -95
  161. package/dist/bundle/chunk-T3W4V4A6.js +0 -63
  162. package/dist/bundle/chunk-TCT5D2X2.js +0 -6848
  163. package/dist/bundle/chunk-TES7MB6I.js +0 -82
  164. package/dist/bundle/chunk-TXDR6YSF.js +0 -23
  165. package/dist/bundle/chunk-TY7NDMFY.js +0 -46
  166. package/dist/bundle/chunk-U6XPWCWM.js +0 -133
  167. package/dist/bundle/chunk-UFKC7TIX.js +0 -28404
  168. package/dist/bundle/chunk-UNWF3TH5.js +0 -274
  169. package/dist/bundle/chunk-W3BOR6AT.js +0 -2333
  170. package/dist/bundle/chunk-WIHN3ELW.js +0 -2793
  171. package/dist/bundle/chunk-X76RS6JO.js +0 -1043
  172. package/dist/bundle/chunk-Y5E2WNWB.js +0 -35
  173. package/dist/bundle/chunk-YF3S26TS.js +0 -4172
  174. package/dist/bundle/chunk-ZCQ4H7CA.js +0 -54
  175. package/dist/bundle/chunk-ZOZV32IR.js +0 -170
  176. package/dist/bundle/chunk-ZTKHXDEU.js +0 -52
  177. package/dist/bundle/chunk-ZVVMGPBJ.js +0 -50
  178. package/dist/bundle/cli-EAD3WZLR.js +0 -1254
  179. package/dist/bundle/command-contract-SMEJ2ICG.js +0 -40
  180. package/dist/bundle/command-server-entry-YTZP6I4T.js +0 -169
  181. package/dist/bundle/decode-57BE5OBT.js +0 -296
  182. package/dist/bundle/dispatch-56FECRCU.js +0 -411
  183. package/dist/bundle/dist-PAKDDIBT.js +0 -191
  184. package/dist/bundle/dist-T54K3FJV.js +0 -7577
  185. package/dist/bundle/echarts-QMAA7HH5.js +0 -42501
  186. package/dist/bundle/embed-NFGFYUO4.js +0 -37
  187. package/dist/bundle/embedder-SRBOJMXX.js +0 -110
  188. package/dist/bundle/failure-WDSX6H3B.js +0 -24
  189. package/dist/bundle/first-run-HWRUL2GR.js +0 -28
  190. package/dist/bundle/first-screen-ATN4D3FQ.js +0 -41
  191. package/dist/bundle/mcp-5HFPWC3W.js +0 -167
  192. package/dist/bundle/meeting-combined-BGDEHCWY.js +0 -26
  193. package/dist/bundle/meeting-model-WWGVRXPL.js +0 -24
  194. package/dist/bundle/meeting-semantic-ZQ47BL2Z.js +0 -21
  195. package/dist/bundle/node-P3PUHKYH.js +0 -176
  196. package/dist/bundle/node-P4E63KXA.js +0 -2340
  197. package/dist/bundle/node-TLZSIHIJ.js +0 -21
  198. package/dist/bundle/node-sqlite-JOTSNH3P.js +0 -73
  199. package/dist/bundle/oauth-XPSAL6VO.js +0 -19
  200. package/dist/bundle/open-PO52FVA5.js +0 -22
  201. package/dist/bundle/openai-WITYLMY5.js +0 -237
  202. package/dist/bundle/process-AFIXYXWL.js +0 -91
  203. package/dist/bundle/program-JODTZNBZ.js +0 -4920
  204. package/dist/bundle/prompt-XORLAXHY.js +0 -16
  205. package/dist/bundle/recognize-JKMZHDYS.js +0 -25
  206. package/dist/bundle/remote-3IMEJTEH.js +0 -30
  207. package/dist/bundle/rerank-3F2E6NNN.js +0 -51
  208. package/dist/bundle/serve-6BWU3NMB.js +0 -198
  209. package/dist/bundle/server-GPSB5WFG.js +0 -220
  210. package/dist/bundle/server-HMCC64ZU.js +0 -88
  211. package/dist/bundle/source-E72OS27D.js +0 -47
  212. package/dist/bundle/sqlite-runtime-YHYQDUXE.js +0 -19
  213. package/dist/bundle/state-R7W4U6T4.js +0 -35
  214. package/dist/bundle/store-HTVRL7FB.js +0 -312
  215. package/dist/bundle/store-IWW6U6QN.js +0 -34
  216. package/dist/bundle/store-TBZ3ZS6H.js +0 -186
  217. package/dist/bundle/store-maintenance-command-CJM2VLMW.js +0 -75
  218. package/dist/bundle/surface-5GBWNYBE.js +0 -74
  219. package/dist/bundle/writer-TW2Q55VJ.js +0 -49
  220. package/dist/commands/account.d.ts +0 -4
  221. package/dist/commands/account.d.ts.map +0 -1
  222. package/dist/commands/account.js.map +0 -1
  223. package/dist/commands/api.d.ts +0 -3
  224. package/dist/commands/api.d.ts.map +0 -1
  225. package/dist/commands/api.js.map +0 -1
  226. package/dist/commands/crm-shared.d.ts +0 -8
  227. package/dist/commands/crm-shared.d.ts.map +0 -1
  228. package/dist/commands/crm-shared.js.map +0 -1
  229. package/dist/commands/schedule.d.ts +0 -3
  230. package/dist/commands/schedule.d.ts.map +0 -1
  231. package/dist/commands/schedule.js.map +0 -1
  232. package/dist/commands/session.d.ts +0 -35
  233. package/dist/commands/session.d.ts.map +0 -1
  234. package/dist/commands/session.js.map +0 -1
  235. package/dist/commands/write.d.ts +0 -14
  236. package/dist/commands/write.d.ts.map +0 -1
  237. package/dist/commands/write.js.map +0 -1
  238. package/dist/config.d.ts +0 -4
  239. package/dist/config.d.ts.map +0 -1
  240. package/dist/config.js.map +0 -1
  241. package/dist/context.d.ts +0 -62
  242. package/dist/context.d.ts.map +0 -1
  243. package/dist/context.js.map +0 -1
  244. package/dist/crm/activities.d.ts +0 -32
  245. package/dist/crm/activities.d.ts.map +0 -1
  246. package/dist/crm/activities.js.map +0 -1
  247. package/dist/crm/records.d.ts +0 -20
  248. package/dist/crm/records.d.ts.map +0 -1
  249. package/dist/crm/records.js.map +0 -1
  250. package/dist/crm/source.d.ts +0 -41
  251. package/dist/crm/source.d.ts.map +0 -1
  252. package/dist/crm/source.js.map +0 -1
  253. package/dist/crm/writer.d.ts +0 -14
  254. package/dist/crm/writer.d.ts.map +0 -1
  255. package/dist/crm/writer.js.map +0 -1
  256. package/dist/identity.d.ts +0 -7
  257. package/dist/identity.d.ts.map +0 -1
  258. package/dist/identity.js.map +0 -1
  259. package/dist/index.d.ts +0 -3
  260. package/dist/index.d.ts.map +0 -1
  261. package/dist/index.js.map +0 -1
  262. package/dist/program.d.ts +0 -6
  263. package/dist/program.d.ts.map +0 -1
  264. package/dist/program.js.map +0 -1
  265. package/dist/reasons.d.ts +0 -10
  266. package/dist/reasons.d.ts.map +0 -1
  267. package/dist/reasons.js.map +0 -1
  268. package/dist/setup/flow.d.ts +0 -2
  269. package/dist/setup/flow.d.ts.map +0 -1
  270. package/dist/setup/flow.js.map +0 -1
  271. package/dist/store.d.ts +0 -15
  272. package/dist/store.d.ts.map +0 -1
  273. package/dist/store.js.map +0 -1
  274. package/dist/version.d.ts +0 -2
  275. package/dist/version.d.ts.map +0 -1
  276. package/dist/version.js.map +0 -1
  277. package/dist/wcat.d.ts +0 -3
  278. package/dist/wcat.d.ts.map +0 -1
  279. package/dist/wcat.js.map +0 -1
  280. package/dist/whoami.d.ts +0 -24
  281. package/dist/whoami.d.ts.map +0 -1
  282. package/dist/whoami.js.map +0 -1
@@ -1,411 +0,0 @@
1
- import { createRequire as __bundleRequire } from "node:module";
2
- const require = __bundleRequire(import.meta.url);
3
- import {
4
- require_cross_spawn
5
- } from "./chunk-D72URWJE.js";
6
- import {
7
- BUILT_IN_COMMANDS,
8
- DESCRIBE_FLAG,
9
- DESCRIBE_MAX_BYTES,
10
- FIRST_PARTY_TOOLS,
11
- PROGRAM_PREFIX,
12
- TOOL_NAME,
13
- fileState,
14
- parseDescribe,
15
- shimFiles,
16
- writeShim
17
- } from "./chunk-DPV53EZC.js";
18
- import "./chunk-Y5E2WNWB.js";
19
- import {
20
- CliError
21
- } from "./chunk-S6JG4YUH.js";
22
- import {
23
- __name,
24
- __toESM
25
- } from "./chunk-ZVVMGPBJ.js";
26
-
27
- // node_modules/.pnpm/@wirecat+cli-base@1.0.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/wcat/dispatch.js
28
- var import_cross_spawn2 = __toESM(require_cross_spawn(), 1);
29
- import { randomUUID } from "node:crypto";
30
- import { constants } from "node:os";
31
-
32
- // node_modules/.pnpm/@wirecat+cli-base@1.0.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/wcat/path.js
33
- import { readdirSync, statSync } from "node:fs";
34
- import { join } from "node:path";
35
- var variable = /* @__PURE__ */ __name((env, name, platform) => platform === "win32" ? Object.entries(env).find(([key]) => key.toUpperCase() === name)?.[1] : env[name], "variable");
36
- var pathEntries = /* @__PURE__ */ __name(({ env, platform }) => {
37
- const raw = variable(env, "PATH", platform) ?? "";
38
- const entries = raw.split(platform === "win32" ? ";" : ":").map((entry) => entry.replace(/^"(.*)"$/, "$1"));
39
- const seen = /* @__PURE__ */ new Set();
40
- return entries.filter((entry) => {
41
- const key = platform === "win32" ? entry.toLowerCase().replace(/[\\/]+$/, "") : entry.replace(/\/+$/, "");
42
- if (entry === "" || seen.has(key))
43
- return false;
44
- seen.add(key);
45
- return true;
46
- });
47
- }, "pathEntries");
48
- var programExtensions = /* @__PURE__ */ __name(({ env, platform }) => platform === "win32" ? (variable(env, "PATHEXT", platform) ?? ".COM;.EXE;.BAT;.CMD").split(";").filter((ext) => /^\.[a-z0-9]+$/i.test(ext)).map((ext) => ext.toLowerCase()) : [""], "programExtensions");
49
- var isProgram = /* @__PURE__ */ __name((path, platform) => {
50
- try {
51
- const stat = statSync(path);
52
- return stat.isFile() && (platform === "win32" || (stat.mode & 73) !== 0);
53
- } catch {
54
- return false;
55
- }
56
- }, "isProgram");
57
- var findOnPath = /* @__PURE__ */ __name((command, search) => {
58
- const extensions = programExtensions(search);
59
- return pathEntries(search).flatMap((dir) => {
60
- for (const extension of extensions) {
61
- const path = join(dir, command + extension);
62
- if (isProgram(path, search.platform))
63
- return [path];
64
- }
65
- return [];
66
- });
67
- }, "findOnPath");
68
- var findTools = /* @__PURE__ */ __name((search) => {
69
- const extensions = programExtensions(search);
70
- const tools = /* @__PURE__ */ new Map();
71
- for (const dir of pathEntries(search)) {
72
- let files;
73
- try {
74
- files = readdirSync(dir);
75
- } catch {
76
- continue;
77
- }
78
- const here = /* @__PURE__ */ new Map();
79
- for (const file of files) {
80
- if (!(search.platform === "win32" ? file.toLowerCase() : file).startsWith(PROGRAM_PREFIX))
81
- continue;
82
- const extension = extensions.find((ext) => ext !== "" && file.toLowerCase().endsWith(ext)) ?? "";
83
- if (search.platform === "win32" && extension === "")
84
- continue;
85
- const base = search.platform === "win32" ? file.toLowerCase() : file;
86
- const name = base.slice(PROGRAM_PREFIX.length, base.length - extension.length);
87
- if (!TOOL_NAME.test(name))
88
- continue;
89
- const best = here.get(name);
90
- const rank = /* @__PURE__ */ __name((path2) => extensions.findIndex((ext) => path2.toLowerCase().endsWith(ext)), "rank");
91
- const path = join(dir, file);
92
- if (best !== void 0 && rank(best) <= rank(path))
93
- continue;
94
- if (isProgram(path, search.platform))
95
- here.set(name, path);
96
- }
97
- for (const [name, path] of here)
98
- tools.set(name, [...tools.get(name) ?? [], path]);
99
- }
100
- return new Map([...tools].sort(([a], [b]) => a < b ? -1 : 1));
101
- }, "findTools");
102
- var isBuiltIn = /* @__PURE__ */ __name((name) => name === "wcat" || BUILT_IN_COMMANDS.includes(name), "isBuiltIn");
103
-
104
- // node_modules/.pnpm/@wirecat+cli-base@1.0.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/wcat/probe.js
105
- var import_cross_spawn = __toESM(require_cross_spawn(), 1);
106
- import { readFileSync } from "node:fs";
107
- var probeDescribe = /* @__PURE__ */ __name((path, { env, timeoutMs }) => new Promise((resolve) => {
108
- let child;
109
- try {
110
- child = (0, import_cross_spawn.default)(path, [DESCRIBE_FLAG], { stdio: ["ignore", "pipe", "ignore"], env, windowsHide: true });
111
- } catch {
112
- resolve(void 0);
113
- return;
114
- }
115
- const chunks = [];
116
- let size = 0;
117
- let settled = false;
118
- const settle = /* @__PURE__ */ __name((answer) => {
119
- if (settled)
120
- return;
121
- settled = true;
122
- clearTimeout(timer);
123
- resolve(answer);
124
- }, "settle");
125
- const giveUp = /* @__PURE__ */ __name(() => {
126
- child.kill();
127
- child.stdout?.destroy();
128
- child.unref();
129
- settle(void 0);
130
- }, "giveUp");
131
- const timer = setTimeout(giveUp, timeoutMs);
132
- child.stdout?.on("data", (chunk) => {
133
- size += chunk.length;
134
- if (size > DESCRIBE_MAX_BYTES)
135
- giveUp();
136
- else
137
- chunks.push(chunk);
138
- });
139
- child.once("error", () => settle(void 0));
140
- child.once("close", (code) => settle(code === 0 ? parseDescribe(Buffer.concat(chunks).toString("utf8")) : void 0));
141
- }), "probeDescribe");
142
- var baseVersion = /* @__PURE__ */ __name(() => {
143
- try {
144
- const raw = readFileSync(new URL("../../package.json", new URL("wcat/probe.js", import.meta.resolve("@wirecat/cli-base")).href), "utf8");
145
- const { name, version } = JSON.parse(raw);
146
- return name === "@wirecat/cli-base" && typeof version === "string" ? version : "unknown";
147
- } catch {
148
- return "unknown";
149
- }
150
- }, "baseVersion");
151
-
152
- // node_modules/.pnpm/@wirecat+cli-base@1.0.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/wcat/shortcuts.js
153
- import { closeSync, openSync, readSync, realpathSync, rmSync } from "node:fs";
154
- import { basename, dirname } from "node:path";
155
- var WIRECAT_PACKAGE = /node_modules[\\/]+@wirecat[\\/]/;
156
- var isWirecatPackage = /* @__PURE__ */ __name((path) => {
157
- try {
158
- if (WIRECAT_PACKAGE.test(realpathSync(path)))
159
- return true;
160
- const buffer = Buffer.alloc(16 * 1024);
161
- const fd = openSync(path, "r");
162
- try {
163
- const read = readSync(fd, buffer, 0, buffer.length, 0);
164
- return WIRECAT_PACKAGE.test(buffer.subarray(0, read).toString("latin1"));
165
- } finally {
166
- closeSync(fd);
167
- }
168
- } catch {
169
- return false;
170
- }
171
- }, "isWirecatPackage");
172
- var ourShortcut = /* @__PURE__ */ __name((path) => {
173
- const state = fileState(path);
174
- return state.state === "ours" && state.mark.kind === "shortcut";
175
- }, "ourShortcut");
176
- var statusOf = /* @__PURE__ */ __name((name, program, search) => {
177
- const files = shimFiles("shortcut", {
178
- dir: dirname(program),
179
- name,
180
- target: basename(program),
181
- platform: search.platform
182
- });
183
- const named = findOnPath(name, search);
184
- const made = [...files.map((file) => file.path), ...named].find(ourShortcut);
185
- if (made)
186
- return { name, status: "made", path: made, program };
187
- const first = named[0];
188
- if (first === void 0)
189
- return { name, status: "free", program };
190
- return { name, status: isWirecatPackage(first) ? "package" : "taken", path: first, program };
191
- }, "statusOf");
192
- var changeFile = /* @__PURE__ */ __name((path, change) => {
193
- try {
194
- change();
195
- } catch (error) {
196
- throw new CliError("permission_error", `could not change ${path}: ${error.code ?? error}`, {
197
- reason: "access.denied"
198
- });
199
- }
200
- }, "changeFile");
201
- var installedPrograms = /* @__PURE__ */ __name((search) => new Map([...findTools(search)].filter(([name]) => !isBuiltIn(name))), "installedPrograms");
202
- var chosen = /* @__PURE__ */ __name((names, search) => {
203
- const installed = installedPrograms(search);
204
- if (names === void 0 || names.length === 0)
205
- return [...installed].map(([name, paths]) => [name, paths[0]]);
206
- const missing = names.filter((name) => !installed.has(name));
207
- if (missing.length > 0)
208
- throw new CliError("not_found", `not installed: ${missing.map((name) => `wcat-${name}`).join(", ")}`, {
209
- reason: "tool.not-installed",
210
- tool: missing[0],
211
- installed: [...installed.keys()]
212
- });
213
- return [...new Set(names)].map((name) => [name, installed.get(name)[0]]);
214
- }, "chosen");
215
- var listShortcuts = /* @__PURE__ */ __name((search, names) => chosen(names, search).map(([name, program]) => statusOf(name, program, search)), "listShortcuts");
216
- var addShortcuts = /* @__PURE__ */ __name((search, names) => listShortcuts(search, names).map((shortcut) => {
217
- if (shortcut.status !== "free")
218
- return { ...shortcut, changed: false };
219
- const files = shimFiles("shortcut", {
220
- dir: dirname(shortcut.program),
221
- name: shortcut.name,
222
- target: basename(shortcut.program),
223
- platform: search.platform
224
- });
225
- for (const file of files)
226
- changeFile(file.path, () => writeShim(file));
227
- return { ...shortcut, status: "made", path: files[0]?.path, changed: true };
228
- }), "addShortcuts");
229
- var removeShortcuts = /* @__PURE__ */ __name((search, names) => listShortcuts(search, names).map((shortcut) => {
230
- if (shortcut.status !== "made")
231
- return { ...shortcut, changed: false };
232
- const files = shimFiles("shortcut", {
233
- dir: dirname(shortcut.path),
234
- name: shortcut.name,
235
- target: basename(shortcut.program),
236
- platform: search.platform
237
- });
238
- for (const file of files)
239
- if (ourShortcut(file.path))
240
- changeFile(file.path, () => rmSync(file.path, { force: true }));
241
- return { ...statusOf(shortcut.name, shortcut.program, search), changed: true };
242
- }), "removeShortcuts");
243
-
244
- // node_modules/.pnpm/@wirecat+cli-base@1.0.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/wcat/dispatch.js
245
- var DEFAULT_DESCRIBE_TIMEOUT_MS = 2e3;
246
- var listTools = /* @__PURE__ */ __name(async (context) => {
247
- const installed = installedPrograms(context);
248
- const timeoutMs = context.describeTimeoutMs ?? DEFAULT_DESCRIBE_TIMEOUT_MS;
249
- const found = await Promise.all([...installed].map(async ([name, paths]) => {
250
- const [path, ...shadowed] = paths;
251
- const own = context.self?.command === name ? context.self : void 0;
252
- const described = own ?? await probeDescribe(path, { env: context.env, timeoutMs });
253
- return {
254
- name,
255
- installed: true,
256
- path,
257
- ...described?.version ? { version: described.version } : {},
258
- ...described?.description ? { description: described.description } : {},
259
- ...described?.docs ? { docs_url: described.docs } : {},
260
- ...shadowed.length > 0 ? { shadowed } : {}
261
- };
262
- }));
263
- const missing = FIRST_PARTY_TOOLS.filter((tool) => tool.package && !installed.has(tool.name)).map((tool) => ({
264
- name: tool.name,
265
- installed: false,
266
- package: tool.package,
267
- install: `npm install -g ${tool.package}`
268
- }));
269
- return [...found, ...missing];
270
- }, "listTools");
271
- var envelope = /* @__PURE__ */ __name((items, started) => ({
272
- items,
273
- page: { mode: "page", limit: Math.max(items.length, 1), has_more: false },
274
- meta: { run_id: randomUUID(), duration_ms: Math.max(0, Math.round(performance.now() - started)), complete: true }
275
- }), "envelope");
276
- var column = /* @__PURE__ */ __name((rows) => {
277
- const widths = rows[0]?.map((_, at) => rows.reduce((wide, row) => Math.max(wide, (row[at] ?? "").length), 0)) ?? [];
278
- return rows.map((row) => ` ${row.map((cell, at) => cell.padEnd(widths[at] ?? 0)).join(" ")}`.trimEnd());
279
- }, "column");
280
- var USAGE = [
281
- "wcat <tool> [arguments] run a tool: wcat tg --help",
282
- "wcat shortcuts [add|remove] [tool...] short names, such as tg, for installed tools",
283
- "wcat --json the list below as JSON"
284
- ];
285
- var listText = /* @__PURE__ */ __name((tools) => {
286
- const installed = tools.filter((tool) => tool.installed);
287
- const missing = tools.filter((tool) => !tool.installed);
288
- return [
289
- "wcat runs WireCat tools, and any other wcat-<name> program on PATH.",
290
- "",
291
- ...USAGE,
292
- "",
293
- installed.length > 0 ? "Installed:" : "Installed: none",
294
- ...column(installed.map((tool) => [tool.name, tool.version ?? "", tool.description ?? "(no description)"])),
295
- ...missing.length > 0 ? ["", "Not installed:", ...column(missing.map((tool) => [tool.name, tool.install ?? ""]))] : [],
296
- ""
297
- ].join("\n");
298
- }, "listText");
299
- var shadowWarnings = /* @__PURE__ */ __name((tools) => tools.filter((tool) => tool.shadowed).map((tool) => `wcat: ${(tool.shadowed?.length ?? 0) + 1} programs are named ${PROGRAM_PREFIX}${tool.name}; wcat runs the first:
300
- ${[tool.path, ...tool.shadowed ?? []].map((path) => ` ${path}`).join("\n")}
301
- `).join(""), "shadowWarnings");
302
- var shortcutText = /* @__PURE__ */ __name((shortcuts2) => {
303
- if (shortcuts2.length === 0)
304
- return "No wcat-<name> programs are installed.\n";
305
- const said = /* @__PURE__ */ __name((shortcut) => {
306
- switch (shortcut.status) {
307
- case "made":
308
- return `made: ${shortcut.path}`;
309
- case "free":
310
- return shortcut.changed ? "removed" : "free: wcat shortcuts add makes it";
311
- case "package":
312
- return `installed by the package: ${shortcut.path}`;
313
- case "taken":
314
- return `taken by ${shortcut.path}`;
315
- }
316
- }, "said");
317
- return `${column(shortcuts2.map((shortcut) => [shortcut.name, said(shortcut)])).join("\n")}
318
- `;
319
- }, "shortcutText");
320
- var signalNumber = /* @__PURE__ */ __name((signal) => constants.signals[signal] ?? 1, "signalNumber");
321
- var runTool = /* @__PURE__ */ __name((path, args, context) => new Promise((resolve, reject) => {
322
- const signals = context.signals ?? process;
323
- const child = (0, import_cross_spawn2.default)(path, [...args], { stdio: "inherit", env: context.env });
324
- const pass = /* @__PURE__ */ __name((signal) => () => child.kill(signal), "pass");
325
- const term = pass("SIGTERM");
326
- const hup = pass("SIGHUP");
327
- const ignore = /* @__PURE__ */ __name(() => {
328
- }, "ignore");
329
- signals.on("SIGTERM", term).on("SIGHUP", hup).on("SIGINT", ignore);
330
- const done = /* @__PURE__ */ __name(() => signals.off("SIGTERM", term).off("SIGHUP", hup).off("SIGINT", ignore), "done");
331
- child.once("error", (error) => {
332
- done();
333
- reject(new CliError("configuration_error", `could not start ${path}: ${error.message}`));
334
- });
335
- child.once("exit", (code, signal) => {
336
- done();
337
- resolve(code ?? (signal ? 128 + signalNumber(signal) : 1));
338
- });
339
- }), "runTool");
340
- var fail = /* @__PURE__ */ __name(async (error, json, context) => {
341
- const { errorObjectOf, exitCodeOfError, renderError } = await import("./failure-WDSX6H3B.js");
342
- const object = errorObjectOf(error);
343
- context.stderr.write(`${renderError(object, { cli: "wcat", interactive: !json })}
344
- `);
345
- return exitCodeOfError(object);
346
- }, "fail");
347
- var shortcuts = /* @__PURE__ */ __name(async (args, json, context) => {
348
- const [action, ...names] = args;
349
- const started = performance.now();
350
- const result = action === "add" ? addShortcuts(context, names) : action === "remove" ? removeShortcuts(context, names) : action === void 0 || action === "list" ? listShortcuts(context, names) : void 0;
351
- if (result === void 0)
352
- throw new CliError("validation_error", `wcat shortcuts takes list, add or remove, not "${action}"`, {
353
- reason: "input.invalid"
354
- });
355
- context.stdout.write(json ? `${JSON.stringify(envelope(result, started))}
356
- ` : shortcutText(result));
357
- return 0;
358
- }, "shortcuts");
359
- var runWcat = /* @__PURE__ */ __name(async (args, context) => {
360
- const [first, ...rest] = args;
361
- const json = args.includes("--json");
362
- const words = args.filter((word) => word !== "--json");
363
- const started = performance.now();
364
- try {
365
- if (first === "--version" || first === "-V" || first === "version") {
366
- const tools = await listTools(context);
367
- const by = context.self ? `, run by ${PROGRAM_PREFIX}${context.self.command} ${context.self.version}` : "";
368
- context.stdout.write(`wcat ${baseVersion()} (@wirecat/cli-base${by})
369
-
370
- ${listText(tools)}`);
371
- return 0;
372
- }
373
- if (words.length === 0 || first === "--help" || first === "-h" || first === "help") {
374
- const tools = await listTools(context);
375
- if (json)
376
- context.stdout.write(`${JSON.stringify(envelope(tools, started))}
377
- `);
378
- else {
379
- context.stderr.write(shadowWarnings(tools));
380
- context.stdout.write(listText(tools));
381
- }
382
- return 0;
383
- }
384
- if (first === "shortcuts")
385
- return await shortcuts(words.slice(1), json, context);
386
- if (BUILT_IN_COMMANDS.includes(first))
387
- throw new CliError("validation_error", `wcat ${first} is reserved for a later version of wcat`, {
388
- reason: "input.invalid"
389
- });
390
- if (first?.startsWith("-"))
391
- throw new CliError("validation_error", `wcat does not take ${first} before a tool's name`, {
392
- reason: "input.invalid"
393
- });
394
- const name = first;
395
- const [path, ...shadowed] = TOOL_NAME.test(name) ? findOnPath(`${PROGRAM_PREFIX}${name}`, context) : [];
396
- if (path === void 0) {
397
- const installed = [...installedPrograms(context).keys()];
398
- throw new CliError("not_found", `no ${PROGRAM_PREFIX}${name} on PATH; installed: ${installed.length > 0 ? installed.join(", ") : "none"}`, { reason: "tool.not-installed", tool: name, installed });
399
- }
400
- if (shadowed.length > 0 && context.stderr.isTTY)
401
- context.stderr.write(shadowWarnings([{ name, installed: true, path, shadowed }]));
402
- return await runTool(path, rest, context);
403
- } catch (error) {
404
- return fail(error, json, context);
405
- }
406
- }, "runWcat");
407
- export {
408
- listTools,
409
- runTool,
410
- runWcat
411
- };
@@ -1,191 +0,0 @@
1
- import { createRequire as __bundleRequire } from "node:module";
2
- const require = __bundleRequire(import.meta.url);
3
- import {
4
- BAGGAGE_META_KEY,
5
- CLIENT_CAPABILITIES_META_KEY,
6
- CLIENT_INFO_META_KEY,
7
- DEFAULT_MAX_REQUEST_BODY_SIZE,
8
- DEFAULT_NEGOTIATED_PROTOCOL_VERSION,
9
- DEFAULT_REQUEST_TIMEOUT_MSEC,
10
- INTERNAL_ERROR,
11
- INVALID_PARAMS,
12
- INVALID_REQUEST,
13
- InMemoryServerEventBus,
14
- InMemoryTransport,
15
- JSONRPC_VERSION,
16
- LATEST_PROTOCOL_VERSION,
17
- LOG_LEVEL_META_KEY,
18
- METHOD_NOT_FOUND,
19
- McpServer,
20
- MissingRequiredClientCapabilityError,
21
- OAuthError,
22
- OAuthErrorCode,
23
- PARSE_ERROR,
24
- PROTOCOL_VERSION_META_KEY,
25
- PerRequestHTTPServerTransport,
26
- Protocol,
27
- ProtocolError,
28
- ProtocolErrorCode,
29
- RELATED_TASK_META_KEY,
30
- ReadBuffer,
31
- ResourceNotFoundError,
32
- ResourceTemplate,
33
- SERVER_INFO_META_KEY,
34
- STDIO_DEFAULT_MAX_BUFFER_SIZE,
35
- SUBSCRIPTION_ID_META_KEY,
36
- SUPPORTED_PROTOCOL_VERSIONS,
37
- SdkError,
38
- SdkErrorCode,
39
- SdkHttpError,
40
- Server,
41
- TRACEPARENT_META_KEY,
42
- TRACESTATE_META_KEY,
43
- UnsupportedProtocolVersionError,
44
- UriTemplate,
45
- UrlElicitationRequiredError,
46
- WebStandardStreamableHTTPServerTransport,
47
- acceptedContent,
48
- assertCompleteRequestPrompt,
49
- assertCompleteRequestResourceTemplate,
50
- bearerAuthChallengeResponse,
51
- buildOAuthProtectedResourceMetadata,
52
- checkResourceAllowed,
53
- classifyInboundRequest,
54
- completable,
55
- createFetchWithInit,
56
- createMcpHandler,
57
- createRequestStateCodec,
58
- deserializeMessage,
59
- fromJsonSchema,
60
- getDisplayName,
61
- getOAuthProtectedResourceMetadataUrl,
62
- hostHeaderValidationResponse,
63
- inputRequired,
64
- inputResponse,
65
- isCallToolResult,
66
- isCompletable,
67
- isInitializeRequest,
68
- isInitializedNotification,
69
- isInputRequiredResult,
70
- isJSONRPCErrorResponse,
71
- isJSONRPCNotification,
72
- isJSONRPCRequest,
73
- isJSONRPCResponse,
74
- isJSONRPCResultResponse,
75
- isJsonContentType,
76
- isLegacyRequest,
77
- isSpecType,
78
- isTaskAugmentedRequestParams,
79
- legacyStatelessFallback,
80
- localhostAllowedHostnames,
81
- localhostAllowedOrigins,
82
- mergeCapabilities,
83
- oauthMetadataResponse,
84
- originValidationResponse,
85
- parseJSONRPCMessage,
86
- preloadSchemas,
87
- readRequestBody,
88
- requireBearerAuth,
89
- requireScopes,
90
- resourceUrlFromServerUrl,
91
- serializeMessage,
92
- specTypeSchemas,
93
- validateHostHeader,
94
- validateOriginHeader,
95
- verifyBearerToken
96
- } from "./chunk-PL5P7UKW.js";
97
- import "./chunk-ZVVMGPBJ.js";
98
- export {
99
- BAGGAGE_META_KEY,
100
- CLIENT_CAPABILITIES_META_KEY,
101
- CLIENT_INFO_META_KEY,
102
- DEFAULT_MAX_REQUEST_BODY_SIZE,
103
- DEFAULT_NEGOTIATED_PROTOCOL_VERSION,
104
- DEFAULT_REQUEST_TIMEOUT_MSEC,
105
- INTERNAL_ERROR,
106
- INVALID_PARAMS,
107
- INVALID_REQUEST,
108
- InMemoryServerEventBus,
109
- InMemoryTransport,
110
- JSONRPC_VERSION,
111
- LATEST_PROTOCOL_VERSION,
112
- LOG_LEVEL_META_KEY,
113
- METHOD_NOT_FOUND,
114
- McpServer,
115
- MissingRequiredClientCapabilityError,
116
- OAuthError,
117
- OAuthErrorCode,
118
- PARSE_ERROR,
119
- PROTOCOL_VERSION_META_KEY,
120
- PerRequestHTTPServerTransport,
121
- Protocol,
122
- ProtocolError,
123
- ProtocolErrorCode,
124
- RELATED_TASK_META_KEY,
125
- ReadBuffer,
126
- ResourceNotFoundError,
127
- ResourceTemplate,
128
- SERVER_INFO_META_KEY,
129
- STDIO_DEFAULT_MAX_BUFFER_SIZE,
130
- SUBSCRIPTION_ID_META_KEY,
131
- SUPPORTED_PROTOCOL_VERSIONS,
132
- SdkError,
133
- SdkErrorCode,
134
- SdkHttpError,
135
- Server,
136
- TRACEPARENT_META_KEY,
137
- TRACESTATE_META_KEY,
138
- UnsupportedProtocolVersionError,
139
- UriTemplate,
140
- UrlElicitationRequiredError,
141
- WebStandardStreamableHTTPServerTransport,
142
- acceptedContent,
143
- assertCompleteRequestPrompt,
144
- assertCompleteRequestResourceTemplate,
145
- bearerAuthChallengeResponse,
146
- buildOAuthProtectedResourceMetadata,
147
- checkResourceAllowed,
148
- classifyInboundRequest,
149
- completable,
150
- createFetchWithInit,
151
- createMcpHandler,
152
- createRequestStateCodec,
153
- deserializeMessage,
154
- fromJsonSchema,
155
- getDisplayName,
156
- getOAuthProtectedResourceMetadataUrl,
157
- hostHeaderValidationResponse,
158
- inputRequired,
159
- inputResponse,
160
- isCallToolResult,
161
- isCompletable,
162
- isInitializeRequest,
163
- isInitializedNotification,
164
- isInputRequiredResult,
165
- isJSONRPCErrorResponse,
166
- isJSONRPCNotification,
167
- isJSONRPCRequest,
168
- isJSONRPCResponse,
169
- isJSONRPCResultResponse,
170
- isJsonContentType,
171
- isLegacyRequest,
172
- isSpecType,
173
- isTaskAugmentedRequestParams,
174
- legacyStatelessFallback,
175
- localhostAllowedHostnames,
176
- localhostAllowedOrigins,
177
- mergeCapabilities,
178
- oauthMetadataResponse,
179
- originValidationResponse,
180
- parseJSONRPCMessage,
181
- preloadSchemas,
182
- readRequestBody,
183
- requireBearerAuth,
184
- requireScopes,
185
- resourceUrlFromServerUrl,
186
- serializeMessage,
187
- specTypeSchemas,
188
- validateHostHeader,
189
- validateOriginHeader,
190
- verifyBearerToken
191
- };