@wirecat/amo-cli 0.5.0 → 0.7.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 (281) hide show
  1. package/CHANGELOG.md +33 -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 +3 -5
  7. package/dist/amo/transport.js +3 -7
  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-3PYE55JY.js → chunk-3HWD4BKU.js} +4 -6
  12. package/dist/bundle/{chunk-M6VZXAJC.js → chunk-4EXURQQQ.js} +21 -19
  13. package/dist/bundle/chunk-AEWYRB6F.js +8 -0
  14. package/dist/bundle/{chunk-WUFX4TKA.js → chunk-GL7CRTHR.js} +3 -3
  15. package/dist/bundle/chunk-N2UB32VN.js +76 -0
  16. package/dist/bundle/{chunk-KZ2FIDI3.js → chunk-PVVSHDMQ.js} +7 -15
  17. package/dist/bundle/program-SQH3SPOW.js +2352 -0
  18. package/dist/bundle/{instructions-AMH5RWVJ.js → source-C65ZJUTW.js} +5 -6
  19. package/dist/bundle/store-SJ2TOUGU.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 -8
  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-EFMUK732.js +0 -41
  80. package/dist/bundle/all-profiles-PIWUQWBA.js +0 -320
  81. package/dist/bundle/anthropic-47CMXBPQ.js +0 -90
  82. package/dist/bundle/app-server-QRBQODF2.js +0 -257
  83. package/dist/bundle/areas-QVHVU57Z.js +0 -63
  84. package/dist/bundle/bun-OPDGMZZQ.js +0 -169
  85. package/dist/bundle/bun-sqlite-7I4X7CZW.js +0 -75
  86. package/dist/bundle/chunk-2JHVQMVC.js +0 -16
  87. package/dist/bundle/chunk-2XBDILVW.js +0 -53
  88. package/dist/bundle/chunk-3DEQUYEG.js +0 -185
  89. package/dist/bundle/chunk-3GX6KM2E.js +0 -5302
  90. package/dist/bundle/chunk-3HC5F3P7.js +0 -24
  91. package/dist/bundle/chunk-3YM4B2GT.js +0 -63
  92. package/dist/bundle/chunk-43OW5NTG.js +0 -338
  93. package/dist/bundle/chunk-43PMSR33.js +0 -357
  94. package/dist/bundle/chunk-4N7PP76S.js +0 -6848
  95. package/dist/bundle/chunk-4VN7RI4I.js +0 -1718
  96. package/dist/bundle/chunk-57HFPNMF.js +0 -189
  97. package/dist/bundle/chunk-5UTB3ADZ.js +0 -360
  98. package/dist/bundle/chunk-633NQY2R.js +0 -80
  99. package/dist/bundle/chunk-63N46DJU.js +0 -12278
  100. package/dist/bundle/chunk-6D4VWSJD.js +0 -259
  101. package/dist/bundle/chunk-6JTHXWPE.js +0 -64
  102. package/dist/bundle/chunk-6QGUK3H7.js +0 -161
  103. package/dist/bundle/chunk-6WS6GJ4V.js +0 -30
  104. package/dist/bundle/chunk-7IR2G5XY.js +0 -559
  105. package/dist/bundle/chunk-7IWIFVXH.js +0 -52
  106. package/dist/bundle/chunk-ABX7BBS4.js +0 -388
  107. package/dist/bundle/chunk-ADLS6FVG.js +0 -24600
  108. package/dist/bundle/chunk-ADTI5RUO.js +0 -1007
  109. package/dist/bundle/chunk-AKRIUNYP.js +0 -1197
  110. package/dist/bundle/chunk-BIKOE2IW.js +0 -614
  111. package/dist/bundle/chunk-BVVMIAQ6.js +0 -37727
  112. package/dist/bundle/chunk-CGW5R4UD.js +0 -362
  113. package/dist/bundle/chunk-D4NE7EON.js +0 -170
  114. package/dist/bundle/chunk-D72URWJE.js +0 -532
  115. package/dist/bundle/chunk-DFDN6AUB.js +0 -21
  116. package/dist/bundle/chunk-DNCLQPOM.js +0 -7
  117. package/dist/bundle/chunk-DPV53EZC.js +0 -206
  118. package/dist/bundle/chunk-DQ6S5TFZ.js +0 -9539
  119. package/dist/bundle/chunk-DSJ6EAOA.js +0 -4172
  120. package/dist/bundle/chunk-DVZ75WZJ.js +0 -3752
  121. package/dist/bundle/chunk-EH6ZEJGT.js +0 -932
  122. package/dist/bundle/chunk-EHK73OSW.js +0 -2017
  123. package/dist/bundle/chunk-FNV5HLHX.js +0 -1068
  124. package/dist/bundle/chunk-FV4GQNIK.js +0 -136
  125. package/dist/bundle/chunk-G2TU5RYY.js +0 -332
  126. package/dist/bundle/chunk-GDK7ETSB.js +0 -218
  127. package/dist/bundle/chunk-GGMAIIVE.js +0 -38
  128. package/dist/bundle/chunk-GLYWZQY4.js +0 -86
  129. package/dist/bundle/chunk-H4AFNENN.js +0 -1343
  130. package/dist/bundle/chunk-HOF7GQWW.js +0 -142
  131. package/dist/bundle/chunk-HSPEU6S7.js +0 -209
  132. package/dist/bundle/chunk-IA7LLLEI.js +0 -100
  133. package/dist/bundle/chunk-IB55P46L.js +0 -334
  134. package/dist/bundle/chunk-IG2TJQJ7.js +0 -79
  135. package/dist/bundle/chunk-JG6LCSEX.js +0 -407
  136. package/dist/bundle/chunk-JLXXUEAM.js +0 -72
  137. package/dist/bundle/chunk-JXT6GY4V.js +0 -1023
  138. package/dist/bundle/chunk-K7YY6SXR.js +0 -738
  139. package/dist/bundle/chunk-KEKXERBE.js +0 -67181
  140. package/dist/bundle/chunk-KZN2BG3P.js +0 -721
  141. package/dist/bundle/chunk-LKH3UKLO.js +0 -230
  142. package/dist/bundle/chunk-LZPKBN3C.js +0 -193
  143. package/dist/bundle/chunk-MDEPJZYJ.js +0 -106
  144. package/dist/bundle/chunk-NB7EOAUZ.js +0 -123
  145. package/dist/bundle/chunk-NISH4UXM.js +0 -58
  146. package/dist/bundle/chunk-NSKMNIY6.js +0 -460
  147. package/dist/bundle/chunk-PL5P7UKW.js +0 -25216
  148. package/dist/bundle/chunk-PPSAWFJD.js +0 -1293
  149. package/dist/bundle/chunk-Q7ICVP25.js +0 -18
  150. package/dist/bundle/chunk-QFOP3KUP.js +0 -2603
  151. package/dist/bundle/chunk-R53XXHEI.js +0 -76
  152. package/dist/bundle/chunk-RIMPFMZE.js +0 -1251
  153. package/dist/bundle/chunk-RN6RT5CB.js +0 -58
  154. package/dist/bundle/chunk-RRTMPSQR.js +0 -29
  155. package/dist/bundle/chunk-S4ZHQMNM.js +0 -133
  156. package/dist/bundle/chunk-S6JG4YUH.js +0 -72
  157. package/dist/bundle/chunk-TAVI73RW.js +0 -288
  158. package/dist/bundle/chunk-TLG6ECZ2.js +0 -54
  159. package/dist/bundle/chunk-TXDR6YSF.js +0 -23
  160. package/dist/bundle/chunk-TY7NDMFY.js +0 -46
  161. package/dist/bundle/chunk-U5RJJ2EC.js +0 -353
  162. package/dist/bundle/chunk-UDSL3MUU.js +0 -2333
  163. package/dist/bundle/chunk-V2CNGXWX.js +0 -798
  164. package/dist/bundle/chunk-VB7FZOYX.js +0 -633
  165. package/dist/bundle/chunk-VZ5PPYDG.js +0 -77
  166. package/dist/bundle/chunk-W5JRXIG6.js +0 -27995
  167. package/dist/bundle/chunk-WIHN3ELW.js +0 -2793
  168. package/dist/bundle/chunk-WOPVBRPV.js +0 -29
  169. package/dist/bundle/chunk-WXJYMMEL.js +0 -95
  170. package/dist/bundle/chunk-XCCU2E3Z.js +0 -274
  171. package/dist/bundle/chunk-XEQQJBBO.js +0 -92
  172. package/dist/bundle/chunk-XUT7DSM5.js +0 -108
  173. package/dist/bundle/chunk-Y5E2WNWB.js +0 -35
  174. package/dist/bundle/chunk-YWDFYQOU.js +0 -82
  175. package/dist/bundle/chunk-ZLUIRFJX.js +0 -780
  176. package/dist/bundle/chunk-ZVVMGPBJ.js +0 -50
  177. package/dist/bundle/cli-3NXOSENF.js +0 -1239
  178. package/dist/bundle/command-contract-LNSAV5LA.js +0 -39
  179. package/dist/bundle/command-server-entry-4ZQPNUL4.js +0 -168
  180. package/dist/bundle/decode-K7U7X5EL.js +0 -296
  181. package/dist/bundle/dispatch-56FECRCU.js +0 -411
  182. package/dist/bundle/dist-PAKDDIBT.js +0 -191
  183. package/dist/bundle/dist-T54K3FJV.js +0 -7577
  184. package/dist/bundle/echarts-O3TNDAXJ.js +0 -42501
  185. package/dist/bundle/embed-SWLVG73O.js +0 -37
  186. package/dist/bundle/embedder-EJN75BPV.js +0 -110
  187. package/dist/bundle/failure-WDSX6H3B.js +0 -24
  188. package/dist/bundle/first-run-WPGUUC4Z.js +0 -28
  189. package/dist/bundle/first-screen-JMNEUQ46.js +0 -40
  190. package/dist/bundle/mcp-5HFPWC3W.js +0 -167
  191. package/dist/bundle/meeting-combined-5TKG2RYD.js +0 -24
  192. package/dist/bundle/meeting-model-YXXNETKC.js +0 -24
  193. package/dist/bundle/meeting-semantic-U7EUB3ET.js +0 -21
  194. package/dist/bundle/node-EGMCBAO7.js +0 -176
  195. package/dist/bundle/node-P4E63KXA.js +0 -2340
  196. package/dist/bundle/node-TLZSIHIJ.js +0 -21
  197. package/dist/bundle/node-sqlite-YVOGMDSP.js +0 -73
  198. package/dist/bundle/oauth-2SNRBIJM.js +0 -19
  199. package/dist/bundle/open-ABCPY5IH.js +0 -22
  200. package/dist/bundle/openai-4D6PXJR7.js +0 -237
  201. package/dist/bundle/process-SGHEN6MQ.js +0 -91
  202. package/dist/bundle/program-CBDQBZZ3.js +0 -4971
  203. package/dist/bundle/prompt-2QUK5QST.js +0 -16
  204. package/dist/bundle/recognize-QMQSJRIH.js +0 -25
  205. package/dist/bundle/remote-U7TC2BLZ.js +0 -30
  206. package/dist/bundle/rerank-5UPVXGVV.js +0 -51
  207. package/dist/bundle/serve-VX6GUM6J.js +0 -198
  208. package/dist/bundle/server-FOPC6DJ3.js +0 -219
  209. package/dist/bundle/server-OIVNOMVK.js +0 -87
  210. package/dist/bundle/source-HWS5SJIV.js +0 -46
  211. package/dist/bundle/sqlite-runtime-77NKDEXN.js +0 -19
  212. package/dist/bundle/state-X2HU6GB2.js +0 -35
  213. package/dist/bundle/store-2U4U6KL4.js +0 -184
  214. package/dist/bundle/store-3CHPHFP7.js +0 -301
  215. package/dist/bundle/store-Z3747L5F.js +0 -34
  216. package/dist/bundle/store-maintenance-command-UOSZJTVP.js +0 -74
  217. package/dist/bundle/surface-MUT72QON.js +0 -73
  218. package/dist/bundle/writer-RBKQ64ZM.js +0 -48
  219. package/dist/commands/account.d.ts +0 -4
  220. package/dist/commands/account.d.ts.map +0 -1
  221. package/dist/commands/account.js.map +0 -1
  222. package/dist/commands/api.d.ts +0 -3
  223. package/dist/commands/api.d.ts.map +0 -1
  224. package/dist/commands/api.js.map +0 -1
  225. package/dist/commands/crm-shared.d.ts +0 -8
  226. package/dist/commands/crm-shared.d.ts.map +0 -1
  227. package/dist/commands/crm-shared.js.map +0 -1
  228. package/dist/commands/schedule.d.ts +0 -3
  229. package/dist/commands/schedule.d.ts.map +0 -1
  230. package/dist/commands/schedule.js.map +0 -1
  231. package/dist/commands/session.d.ts +0 -35
  232. package/dist/commands/session.d.ts.map +0 -1
  233. package/dist/commands/session.js.map +0 -1
  234. package/dist/commands/write.d.ts +0 -14
  235. package/dist/commands/write.d.ts.map +0 -1
  236. package/dist/commands/write.js.map +0 -1
  237. package/dist/config.d.ts +0 -4
  238. package/dist/config.d.ts.map +0 -1
  239. package/dist/config.js.map +0 -1
  240. package/dist/context.d.ts +0 -62
  241. package/dist/context.d.ts.map +0 -1
  242. package/dist/context.js.map +0 -1
  243. package/dist/crm/activities.d.ts +0 -32
  244. package/dist/crm/activities.d.ts.map +0 -1
  245. package/dist/crm/activities.js.map +0 -1
  246. package/dist/crm/records.d.ts +0 -20
  247. package/dist/crm/records.d.ts.map +0 -1
  248. package/dist/crm/records.js.map +0 -1
  249. package/dist/crm/source.d.ts +0 -41
  250. package/dist/crm/source.d.ts.map +0 -1
  251. package/dist/crm/source.js.map +0 -1
  252. package/dist/crm/writer.d.ts +0 -14
  253. package/dist/crm/writer.d.ts.map +0 -1
  254. package/dist/crm/writer.js.map +0 -1
  255. package/dist/identity.d.ts +0 -7
  256. package/dist/identity.d.ts.map +0 -1
  257. package/dist/identity.js.map +0 -1
  258. package/dist/index.d.ts +0 -3
  259. package/dist/index.d.ts.map +0 -1
  260. package/dist/index.js.map +0 -1
  261. package/dist/program.d.ts +0 -6
  262. package/dist/program.d.ts.map +0 -1
  263. package/dist/program.js.map +0 -1
  264. package/dist/reasons.d.ts +0 -10
  265. package/dist/reasons.d.ts.map +0 -1
  266. package/dist/reasons.js.map +0 -1
  267. package/dist/setup/flow.d.ts +0 -2
  268. package/dist/setup/flow.d.ts.map +0 -1
  269. package/dist/setup/flow.js.map +0 -1
  270. package/dist/store.d.ts +0 -15
  271. package/dist/store.d.ts.map +0 -1
  272. package/dist/store.js.map +0 -1
  273. package/dist/version.d.ts +0 -2
  274. package/dist/version.d.ts.map +0 -1
  275. package/dist/version.js.map +0 -1
  276. package/dist/wcat.d.ts +0 -3
  277. package/dist/wcat.d.ts.map +0 -1
  278. package/dist/wcat.js.map +0 -1
  279. package/dist/whoami.d.ts +0 -24
  280. package/dist/whoami.d.ts.map +0 -1
  281. package/dist/whoami.js.map +0 -1
@@ -1,320 +0,0 @@
1
- import { createRequire as __bundleRequire } from "node:module";
2
- const require = __bundleRequire(import.meta.url);
3
- import {
4
- StdioServerTransport,
5
- answeredWire,
6
- serveStdio
7
- } from "./chunk-VB7FZOYX.js";
8
- import {
9
- CALLER_META_KEY,
10
- PROXY_CLIENT_NAME,
11
- callerOf
12
- } from "./chunk-XUT7DSM5.js";
13
- import {
14
- InMemoryTransport,
15
- McpServer
16
- } from "./chunk-PL5P7UKW.js";
17
- import "./chunk-CGW5R4UD.js";
18
- import "./chunk-JLXXUEAM.js";
19
- import "./chunk-XEQQJBBO.js";
20
- import "./chunk-DNCLQPOM.js";
21
- import "./chunk-WIHN3ELW.js";
22
- import {
23
- errorObjectOf,
24
- mcpErrorResult
25
- } from "./chunk-QFOP3KUP.js";
26
- import "./chunk-Y5E2WNWB.js";
27
- import {
28
- CliError
29
- } from "./chunk-S6JG4YUH.js";
30
- import {
31
- __name
32
- } from "./chunk-ZVVMGPBJ.js";
33
-
34
- // node_modules/.pnpm/@wirecat+cli-core@1.0.0_@wirecat+cli-base@1.0.0_commander@15.0.0_esbuild@0.28.2_typescr_dd5172c52281f8f1e2dd1d4e9555d5c3/node_modules/@wirecat/cli-core/dist/mcp/all-profiles.js
35
- import { spawn } from "node:child_process";
36
- import { randomUUID } from "node:crypto";
37
- var PROTOCOL = "2025-06-18";
38
- var START_MS = 3e4;
39
- var CHILD_IDLE_MS = 10 * 60 * 1e3;
40
- var startChild = /* @__PURE__ */ __name((spec, note, onExit) => {
41
- const child = spawn(spec.command, spec.args, { env: spec.env, stdio: "pipe" });
42
- const pending = /* @__PURE__ */ new Map();
43
- let next = 1;
44
- let buffer = "";
45
- let gone;
46
- const fail = /* @__PURE__ */ __name((error) => {
47
- gone ??= error;
48
- for (const waiter of pending.values())
49
- waiter.reject(error);
50
- pending.clear();
51
- }, "fail");
52
- child.on("error", () => fail(new Error("the profile's MCP server could not be started")));
53
- child.on("exit", () => {
54
- fail(new Error("the profile's MCP server stopped"));
55
- onExit();
56
- });
57
- child.stdin.on("error", () => fail(new Error("the profile's MCP server closed its input")));
58
- child.stderr.setEncoding("utf8");
59
- let errors = "";
60
- child.stderr.on("data", (chunk) => {
61
- const lines = (errors + chunk).split("\n");
62
- errors = lines.pop() ?? "";
63
- for (const line of lines)
64
- if (line.trim())
65
- note(line);
66
- });
67
- child.stdout.setEncoding("utf8");
68
- child.stdout.on("data", (chunk) => {
69
- buffer += chunk;
70
- for (let at = buffer.indexOf("\n"); at !== -1; at = buffer.indexOf("\n")) {
71
- const line = buffer.slice(0, at);
72
- buffer = buffer.slice(at + 1);
73
- let message;
74
- try {
75
- message = JSON.parse(line);
76
- } catch {
77
- continue;
78
- }
79
- if (message.method !== void 0 && message.id !== void 0) {
80
- send({ id: message.id, error: { code: -32601, message: "not offered through the all-profiles server" } });
81
- continue;
82
- }
83
- if (typeof message.id !== "number")
84
- continue;
85
- const waiter = pending.get(message.id);
86
- if (!waiter)
87
- continue;
88
- pending.delete(message.id);
89
- if (message.error)
90
- waiter.reject(new Error(message.error.message ?? "the profile's MCP server refused"));
91
- else
92
- waiter.resolve(message.result ?? {});
93
- }
94
- });
95
- const send = /* @__PURE__ */ __name((message) => child.stdin.write(`${JSON.stringify({ jsonrpc: "2.0", ...message })}
96
- `), "send");
97
- const request = /* @__PURE__ */ __name((method, params) => new Promise((resolve, reject) => {
98
- if (gone)
99
- return reject(gone);
100
- const id = next++;
101
- pending.set(id, { resolve, reject });
102
- send({ id, method, params });
103
- }), "request");
104
- const close = /* @__PURE__ */ __name(() => new Promise((resolve) => {
105
- if (child.exitCode !== null || child.signalCode !== null)
106
- return resolve();
107
- child.once("exit", () => resolve());
108
- child.stdin.end();
109
- }), "close");
110
- const timer = setTimeout(() => fail(new Error("the profile's MCP server did not answer in time")), START_MS);
111
- return request("initialize", {
112
- protocolVersion: PROTOCOL,
113
- capabilities: {},
114
- clientInfo: { name: PROXY_CLIENT_NAME, version: "1" }
115
- }).then(() => {
116
- send({ method: "notifications/initialized" });
117
- return { request, close };
118
- }).catch(async (error) => {
119
- await close();
120
- throw error;
121
- }).finally(() => clearTimeout(timer));
122
- }, "startChild");
123
- var pool = /* @__PURE__ */ __name((options) => {
124
- const idleMs = options.idleMs ?? CHILD_IDLE_MS;
125
- const note = options.note ?? (() => {
126
- });
127
- const running = /* @__PURE__ */ new Map();
128
- const forget = /* @__PURE__ */ __name((profile, child) => {
129
- const one = running.get(profile);
130
- if (one?.child !== child)
131
- return;
132
- clearTimeout(one.timer);
133
- running.delete(profile);
134
- }, "forget");
135
- const use = /* @__PURE__ */ __name(async (profile, work) => {
136
- let one = running.get(profile);
137
- if (!one) {
138
- const child = startChild(options.child(profile), (line) => note(`${profile}: ${line}`), () => forget(profile, child));
139
- child.catch(() => forget(profile, child));
140
- one = { child };
141
- running.set(profile, one);
142
- }
143
- clearTimeout(one.timer);
144
- const entry = one;
145
- try {
146
- return await work(await entry.child);
147
- } finally {
148
- if (running.get(profile) === entry) {
149
- entry.timer = setTimeout(() => {
150
- forget(profile, entry.child);
151
- void entry.child.then((child) => child.close()).catch(() => void 0);
152
- }, idleMs);
153
- entry.timer.unref();
154
- }
155
- }
156
- }, "use");
157
- const close = /* @__PURE__ */ __name(async () => {
158
- const all = [...running.values()];
159
- running.clear();
160
- for (const one of all)
161
- clearTimeout(one.timer);
162
- await Promise.all(all.map((one) => one.child.then((child) => child.close()).catch(() => void 0)));
163
- }, "close");
164
- return { use, close };
165
- }, "pool");
166
- var withProfile = /* @__PURE__ */ __name((tool, profiles, name, signedIn = () => true) => {
167
- const schema = tool.inputSchema;
168
- const out = profiles.filter((profile) => !signedIn(profile));
169
- const states = out.length === 0 ? "" : ` Signed in: ${profiles.filter(signedIn).join(", ") || "none"} \xB7 Not signed in: ${out.join(", ")}.`;
170
- return {
171
- ...tool,
172
- inputSchema: {
173
- ...tool.inputSchema,
174
- properties: {
175
- profile: profiles.length === 0 ? (
176
- // An empty enum matches nothing, and a directory that checks the schema refuses the tool.
177
- {
178
- type: "string",
179
- description: `Which ${name} account, by its profile. None is set up on this computer yet.`
180
- }
181
- ) : {
182
- type: "string",
183
- enum: [...profiles],
184
- oneOf: profiles.map((one) => ({ const: one, title: signedIn(one) ? one : `${one} \u2014 not signed in` })),
185
- description: `Which ${name} account, by its profile. If the owner did not name one, ask which \u2014 never guess.${states}`
186
- },
187
- ...schema.properties
188
- },
189
- required: ["profile", ...(schema.required ?? []).filter((field) => field !== "profile")]
190
- }
191
- };
192
- }, "withProfile");
193
- var refusal = /* @__PURE__ */ __name((code, text, details) => mcpErrorResult(errorObjectOf(new CliError(code, text, details), { effects: { remote: "none", local: "none" } })), "refusal");
194
- var allProfilesServer = /* @__PURE__ */ __name((options) => {
195
- const children = pool(options);
196
- let listed;
197
- const tools = /* @__PURE__ */ __name((profiles) => {
198
- listed ??= children.use(profiles.find(signedIn) ?? profiles[0], (child) => child.request("tools/list", {})).then((answer) => answer.tools ?? []);
199
- listed.catch(() => {
200
- listed = void 0;
201
- });
202
- return listed;
203
- }, "tools");
204
- const signedIn = /* @__PURE__ */ __name((profile) => options.signedIn?.(profile) ?? true, "signedIn");
205
- const build = /* @__PURE__ */ __name(() => {
206
- const profiles = [...options.profiles()].sort();
207
- const server = new McpServer({ name: options.command, version: options.version }, {
208
- capabilities: { tools: {} },
209
- // Read per session, as the profiles are: clients cut the instructions short, so this line comes first.
210
- instructions: profiles.length === 0 && options.setup ? `${options.setup.charAt(0).toUpperCase()}${options.setup.slice(1)}.
211
- ${options.instructions}` : options.instructions
212
- });
213
- server.server.setRequestHandler("tools/list", async () => ({
214
- tools: (profiles.length === 0 ? await options.catalogue?.() ?? [] : await tools(profiles)).map((one) => withProfile(one, profiles, options.name, signedIn))
215
- }));
216
- const callers = {
217
- env: options.env ?? process.env,
218
- client: /* @__PURE__ */ __name(() => server.server.getClientVersion(), "client"),
219
- connectionId: randomUUID()
220
- };
221
- server.server.setRequestHandler("tools/call", async (request, ctx) => {
222
- const { name, arguments: given = {}, _meta } = request.params;
223
- const { profile, ...rest } = given;
224
- if (profiles.length === 0)
225
- return refusal("configuration_error", options.setup ?? `no ${options.command} profile on this computer yet.`);
226
- if (typeof profile !== "string" || !profiles.includes(profile))
227
- return refusal("validation_error", `${name} needs "profile", one of: ${profiles.join(", ")}. If the owner did not say which account, ask.`);
228
- if (!signedIn(profile))
229
- return refusal("authentication_error", options.signIn?.(profile) ?? `profile ${profile} is not signed in.`);
230
- try {
231
- return await children.use(profile, (child) => (
232
- // Children are shared by every session, so each call names its own caller.
233
- child.request("tools/call", {
234
- name,
235
- arguments: rest,
236
- _meta: { ..._meta, [CALLER_META_KEY]: callerOf(ctx, name, callers) }
237
- })
238
- ));
239
- } catch (error) {
240
- return refusal("outcome_unknown", `profile ${profile}: ${error instanceof Error ? error.message : String(error)}`);
241
- }
242
- });
243
- return server;
244
- }, "build");
245
- return { build, close: /* @__PURE__ */ __name(() => children.close(), "close") };
246
- }, "allProfilesServer");
247
- var listedTools = /* @__PURE__ */ __name(async (server) => {
248
- const [own, other] = InMemoryTransport.createLinkedPair();
249
- const answers = /* @__PURE__ */ new Map();
250
- other.onmessage = (message) => {
251
- const { id, result, error } = message;
252
- if (typeof id === "number")
253
- answers.get(id)?.(result, error);
254
- };
255
- const ask = /* @__PURE__ */ __name((id, method, params) => new Promise((resolve, reject) => {
256
- answers.set(id, (result, error) => error || !result ? reject(new Error(error?.message ?? `${method} had no answer`)) : resolve(result));
257
- void other.send({ jsonrpc: "2.0", id, method, params });
258
- }), "ask");
259
- await server.connect(own);
260
- try {
261
- await ask(1, "initialize", {
262
- protocolVersion: PROTOCOL,
263
- capabilities: {},
264
- clientInfo: { name: PROXY_CLIENT_NAME, version: "1" }
265
- });
266
- await other.send({ jsonrpc: "2.0", method: "notifications/initialized" });
267
- const answer = await ask(2, "tools/list", {});
268
- if (!Array.isArray(answer.tools))
269
- throw new Error("the catalogue server listed no tools");
270
- return answer.tools;
271
- } finally {
272
- await server.close();
273
- }
274
- }, "listedTools");
275
- var serveAllProfilesOverStdio = /* @__PURE__ */ __name(async (options, io = {}) => {
276
- const { build, close } = allProfilesServer(options);
277
- const own = io.stdin !== void 0 && io.stdin !== process.stdin;
278
- const wire = answeredWire(io.stdin ?? process.stdin, io.stdout ?? process.stdout);
279
- const handle = serveStdio(build, {
280
- transport: new StdioServerTransport(wire.input, wire.output),
281
- onerror: /* @__PURE__ */ __name((error) => options.note?.(`mcp: ${error.message}`), "onerror")
282
- });
283
- await wire.finished(own ? io.signal : void 0);
284
- try {
285
- wire.release();
286
- await handle.close();
287
- } finally {
288
- await close();
289
- }
290
- }, "serveAllProfilesOverStdio");
291
- var serveAllProfilesOverHttp = /* @__PURE__ */ __name(async (options, http) => {
292
- const { build, close } = allProfilesServer(options);
293
- const { serveOverHttp } = await import("./serve-VX6GUM6J.js");
294
- const listening = await serveOverHttp(build, {
295
- ...http,
296
- appName: options.command,
297
- onError: /* @__PURE__ */ __name((error) => options.note?.(`mcp: ${error.message}`), "onError")
298
- }).catch(async (error) => {
299
- await close();
300
- throw error;
301
- });
302
- return {
303
- url: listening.url,
304
- close: /* @__PURE__ */ __name(async () => {
305
- try {
306
- await listening.close();
307
- } finally {
308
- await close();
309
- }
310
- }, "close")
311
- };
312
- }, "serveAllProfilesOverHttp");
313
- export {
314
- CHILD_IDLE_MS,
315
- allProfilesServer,
316
- listedTools,
317
- serveAllProfilesOverHttp,
318
- serveAllProfilesOverStdio,
319
- withProfile
320
- };
@@ -1,90 +0,0 @@
1
- import { createRequire as __bundleRequire } from "node:module";
2
- const require = __bundleRequire(import.meta.url);
3
- import {
4
- EmptyAnswer,
5
- checkedOptions,
6
- messagesFor,
7
- systemFor
8
- } from "./chunk-R53XXHEI.js";
9
- import {
10
- Anthropic
11
- } from "./chunk-ADLS6FVG.js";
12
- import "./chunk-WIHN3ELW.js";
13
- import {
14
- array,
15
- literal,
16
- optional,
17
- picklist,
18
- record,
19
- strictObject,
20
- string,
21
- unknown
22
- } from "./chunk-QFOP3KUP.js";
23
- import "./chunk-Y5E2WNWB.js";
24
- import "./chunk-S6JG4YUH.js";
25
- import {
26
- __name
27
- } from "./chunk-ZVVMGPBJ.js";
28
-
29
- // node_modules/.pnpm/@wirecat+cli-core@1.0.0_@wirecat+cli-base@1.0.0_commander@15.0.0_esbuild@0.28.2_typescr_dd5172c52281f8f1e2dd1d4e9555d5c3/node_modules/@wirecat/cli-core/dist/models/anthropic.js
30
- var options = strictObject({
31
- stop_sequences: optional(array(string())),
32
- thinking: optional(strictObject({ type: picklist(["disabled", "adaptive"]) })),
33
- output_config: optional(strictObject({
34
- effort: optional(picklist(["low", "medium", "high"])),
35
- format: optional(strictObject({ type: literal("json_schema"), schema: record(string(), unknown()) }))
36
- }))
37
- });
38
- var anthropic = {
39
- images: true,
40
- baseUrl: "https://api.anthropic.com",
41
- validate: /* @__PURE__ */ __name((given) => checkedOptions("anthropic", options, given), "validate"),
42
- complete: /* @__PURE__ */ __name(async (target, request, checked, apiKey, fetcher) => {
43
- const client = new Anthropic({
44
- apiKey: apiKey ?? "",
45
- authToken: null,
46
- fetch: /* @__PURE__ */ __name((input, init) => fetcher(input, { ...init, redirect: "error" }), "fetch"),
47
- baseURL: target.baseUrl,
48
- maxRetries: 0,
49
- logLevel: "off",
50
- timeout: 12e4
51
- });
52
- const response = await client.messages.stream({
53
- ...checked,
54
- model: target.model,
55
- system: systemFor(request),
56
- messages: [
57
- ...messagesFor(request),
58
- ...request.images === void 0 ? [] : [
59
- {
60
- role: "user",
61
- content: [
62
- { type: "text", text: request.prompt },
63
- ...request.images.map((image) => ({
64
- type: "image",
65
- source: { type: "base64", media_type: image.mimeType, data: image.data }
66
- }))
67
- ]
68
- }
69
- ]
70
- ],
71
- max_tokens: request.maxTokens
72
- }).finalMessage();
73
- if (response.stop_reason !== "end_turn")
74
- throw new Error("incomplete response");
75
- const text = response.content.filter((block) => block.type === "text").map((block) => block.text).join("");
76
- if (text.trim() === "")
77
- throw new EmptyAnswer();
78
- return {
79
- text,
80
- usage: {
81
- input: response.usage.input_tokens + (response.usage.cache_creation_input_tokens ?? 0) + (response.usage.cache_read_input_tokens ?? 0),
82
- output: response.usage.output_tokens
83
- },
84
- tokens: response.usage.input_tokens + response.usage.output_tokens + (response.usage.cache_creation_input_tokens ?? 0) + (response.usage.cache_read_input_tokens ?? 0)
85
- };
86
- }, "complete")
87
- };
88
- export {
89
- anthropic
90
- };
@@ -1,257 +0,0 @@
1
- import { createRequire as __bundleRequire } from "node:module";
2
- const require = __bundleRequire(import.meta.url);
3
- import {
4
- PER_RUN,
5
- envelope
6
- } from "./chunk-V2CNGXWX.js";
7
- import {
8
- mcpUrlOf
9
- } from "./chunk-H4AFNENN.js";
10
- import {
11
- skillResources
12
- } from "./chunk-ABX7BBS4.js";
13
- import {
14
- StdioServerTransport,
15
- answeredWire,
16
- serveStdio
17
- } from "./chunk-VB7FZOYX.js";
18
- import "./chunk-Q7ICVP25.js";
19
- import "./chunk-RIMPFMZE.js";
20
- import "./chunk-U5RJJ2EC.js";
21
- import {
22
- runCommandForAgent,
23
- toolsFromCommands
24
- } from "./chunk-DVZ75WZJ.js";
25
- import "./chunk-7IWIFVXH.js";
26
- import "./chunk-43OW5NTG.js";
27
- import {
28
- appInstructions
29
- } from "./chunk-2XBDILVW.js";
30
- import {
31
- answered,
32
- failed,
33
- registerCommands
34
- } from "./chunk-7IR2G5XY.js";
35
- import {
36
- agentJson
37
- } from "./chunk-HSPEU6S7.js";
38
- import "./chunk-BVVMIAQ6.js";
39
- import "./chunk-JG6LCSEX.js";
40
- import "./chunk-3GX6KM2E.js";
41
- import "./chunk-NB7EOAUZ.js";
42
- import "./chunk-HOF7GQWW.js";
43
- import "./chunk-TY7NDMFY.js";
44
- import "./chunk-XUT7DSM5.js";
45
- import "./chunk-6WS6GJ4V.js";
46
- import "./chunk-K7YY6SXR.js";
47
- import "./chunk-WOPVBRPV.js";
48
- import {
49
- McpServer
50
- } from "./chunk-PL5P7UKW.js";
51
- import "./chunk-R53XXHEI.js";
52
- import "./chunk-6D4VWSJD.js";
53
- import "./chunk-5UTB3ADZ.js";
54
- import "./chunk-D4NE7EON.js";
55
- import {
56
- mcpHttpMarker
57
- } from "./chunk-6QGUK3H7.js";
58
- import "./chunk-GLYWZQY4.js";
59
- import "./chunk-S4ZHQMNM.js";
60
- import {
61
- DEFAULT_OUTPUT_BYTES,
62
- changesAuthorityAt,
63
- describeProgram,
64
- environmentOf,
65
- fetchesOnlyAt,
66
- judgedTargets,
67
- readOnlyLockOf,
68
- readsOverMcpAt,
69
- rootOf2 as rootOf
70
- } from "./chunk-63N46DJU.js";
71
- import "./chunk-CGW5R4UD.js";
72
- import "./chunk-RN6RT5CB.js";
73
- import "./chunk-IB55P46L.js";
74
- import "./chunk-3YM4B2GT.js";
75
- import "./chunk-FNV5HLHX.js";
76
- import "./chunk-6JTHXWPE.js";
77
- import "./chunk-KEKXERBE.js";
78
- import "./chunk-UDSL3MUU.js";
79
- import "./chunk-633NQY2R.js";
80
- import "./chunk-KZN2BG3P.js";
81
- import "./chunk-PPSAWFJD.js";
82
- import "./chunk-JLXXUEAM.js";
83
- import "./chunk-3DEQUYEG.js";
84
- import "./chunk-G2TU5RYY.js";
85
- import "./chunk-ADTI5RUO.js";
86
- import "./chunk-XCCU2E3Z.js";
87
- import "./chunk-JXT6GY4V.js";
88
- import "./chunk-NSKMNIY6.js";
89
- import "./chunk-TXDR6YSF.js";
90
- import "./chunk-BIKOE2IW.js";
91
- import "./chunk-EHK73OSW.js";
92
- import "./chunk-IG2TJQJ7.js";
93
- import "./chunk-2JHVQMVC.js";
94
- import "./chunk-ZLUIRFJX.js";
95
- import "./chunk-XEQQJBBO.js";
96
- import "./chunk-RRTMPSQR.js";
97
- import "./chunk-DSJ6EAOA.js";
98
- import "./chunk-DNCLQPOM.js";
99
- import "./chunk-AKRIUNYP.js";
100
- import "./chunk-D72URWJE.js";
101
- import "./chunk-YWDFYQOU.js";
102
- import "./chunk-TLG6ECZ2.js";
103
- import "./chunk-WXJYMMEL.js";
104
- import "./chunk-GGMAIIVE.js";
105
- import "./chunk-WIHN3ELW.js";
106
- import {
107
- mcpErrorResult
108
- } from "./chunk-QFOP3KUP.js";
109
- import "./chunk-Y5E2WNWB.js";
110
- import {
111
- CliError
112
- } from "./chunk-S6JG4YUH.js";
113
- import "./chunk-4N7PP76S.js";
114
- import {
115
- __name
116
- } from "./chunk-ZVVMGPBJ.js";
117
-
118
- // node_modules/.pnpm/@wirecat+cli-core@1.0.0_@wirecat+cli-base@1.0.0_commander@15.0.0_esbuild@0.28.2_typescr_dd5172c52281f8f1e2dd1d4e9555d5c3/node_modules/@wirecat/cli-core/dist/mcp/app-server.js
119
- var EXCLUDED = [["mcp"]];
120
- var aliasesOf = /* @__PURE__ */ __name((root, path) => {
121
- let at = root;
122
- for (const name of path)
123
- at = at?.commands.find((child) => child.name() === name);
124
- const aliases = at?.aliases() ?? [];
125
- return aliases.length > 0 ? { aliases } : {};
126
- }, "aliasesOf");
127
- var createAppServer = /* @__PURE__ */ __name((command, context, options) => {
128
- const { app } = options;
129
- const root = rootOf(command);
130
- const environment = environmentOf(command);
131
- if (!environment.runCommand)
132
- throw new Error("the MCP server runs inside run(), which hands it the program");
133
- const program = { run: environment.runCommand, commands: describeProgram(root) };
134
- const flags = command.optsWithGlobals();
135
- const overrides = flags.permission ?? [];
136
- const { settings } = context;
137
- const levels = /* @__PURE__ */ __name(() => options.resolveSettings(flags, { env: context.env }).permissions, "levels");
138
- const readOnly = /* @__PURE__ */ __name(() => readOnlyLockOf(app, context.env) !== void 0, "readOnly");
139
- const authority = changesAuthorityAt(root);
140
- const fetches = fetchesOnlyAt(root);
141
- const targets = judgedTargets(root);
142
- const passed = Object.fromEntries(Object.entries(environment).filter(([key]) => !PER_RUN.has(key)));
143
- const tools = toolsFromCommands(program.commands, {
144
- includeUnavailable: true,
145
- exclude: EXCLUDED,
146
- levels: settings.permissions,
147
- currentLevels: levels,
148
- readOnly: readOnly(),
149
- authority,
150
- fetchOnly: readsOverMcpAt(root),
151
- fetches,
152
- permissions: options.permissions
153
- });
154
- const availability = /* @__PURE__ */ __name((one) => () => {
155
- const permitted = one.availability?.() ?? { available: true };
156
- if (!permitted.available)
157
- return permitted;
158
- return options.availability?.(one.path, settings.profile) ?? permitted;
159
- }, "availability");
160
- const commands = Object.fromEntries(tools.map((one) => [
161
- one.command,
162
- {
163
- title: one.title,
164
- description: one.description,
165
- ...one.keywords ? { keywords: one.keywords } : {},
166
- ...aliasesOf(root, one.path),
167
- writes: one.writes,
168
- availability: availability(one),
169
- input: one.input,
170
- run: /* @__PURE__ */ __name(async (input, ctx) => {
171
- const own = options.availability?.(one.path, settings.profile);
172
- if (own && !own.available)
173
- return failed(new CliError("permission_error", `${one.command}: ${own.reason ?? "unavailable for this profile"}`, {
174
- ...own.permission ? { permission: own.permission } : {}
175
- }), app.errors);
176
- const traceparent = ctx?.mcpReq?._meta?.traceparent;
177
- const env = typeof traceparent === "string" ? { ...context.env, TRACEPARENT: traceparent } : context.env;
178
- const answer = await runCommandForAgent(program, one.path, input, {
179
- profile: settings.profile,
180
- readOnly: readOnly(),
181
- env,
182
- levels,
183
- overrides,
184
- authority,
185
- fetches,
186
- permissions: options.permissions,
187
- environment: passed
188
- });
189
- if ("error" in answer)
190
- return mcpErrorResult(JSON.parse(agentJson(answer.error)));
191
- try {
192
- return answered(envelope(one.command, answer.result), DEFAULT_OUTPUT_BYTES, targets);
193
- } catch (error) {
194
- return failed(error, app.errors);
195
- }
196
- }, "run")
197
- }
198
- ]));
199
- const skills = options.skill ? skillResources(app, options.skill) : [];
200
- const skill = skills[0];
201
- const build = /* @__PURE__ */ __name(() => {
202
- const server = new McpServer({ name: app.command, version: app.version }, {
203
- instructions: appInstructions({
204
- command: app.command,
205
- name: options.name,
206
- profile: settings.profile,
207
- untrusted: options.untrusted,
208
- ...skill ? { skill: skill.instruction } : {}
209
- })
210
- });
211
- registerCommands(server, app.command, commands, app.errors, void 0, app.messenger);
212
- for (const { uri, name, title, description, mimeType, read } of skills)
213
- server.registerResource(name, uri, { title, description, mimeType }, read);
214
- return server;
215
- }, "build");
216
- return { build, offered: Object.keys(commands) };
217
- }, "createAppServer");
218
- var serveAppOverStdio = /* @__PURE__ */ __name(async (command, context, options) => {
219
- const { build } = createAppServer(command, context, options);
220
- const { stdin, stdout, signal } = environmentOf(command);
221
- const own = stdin && stdout && stdin !== process.stdin;
222
- const wire = answeredWire(own ? stdin : process.stdin, own ? stdout : process.stdout);
223
- const handle = serveStdio(build, {
224
- transport: new StdioServerTransport(wire.input, wire.output),
225
- onerror: /* @__PURE__ */ __name((error) => context.renderer.note(`mcp: ${error.message}`), "onerror")
226
- });
227
- await wire.finished(own ? signal : void 0);
228
- wire.release();
229
- await handle.close();
230
- }, "serveAppOverStdio");
231
- var serveAppOverHttp = /* @__PURE__ */ __name(async (command, context, options, http) => {
232
- const { app } = options;
233
- const { build } = createAppServer(command, context, options);
234
- const { serveOverHttp } = await import("./serve-VX6GUM6J.js");
235
- const listening = await serveOverHttp(build, {
236
- ...http,
237
- appName: app.command,
238
- reaches: `your ${options.name}`,
239
- onCode: /* @__PURE__ */ __name((code, expires) => context.renderer.note(context.env[mcpHttpMarker(app.envPrefix)] === void 0 ? `login code for a new browser app: ${code} (until ${expires.toTimeString().slice(0, 5)}; a new one after each login)` : `a new login code for a browser app: \`${app.command} ${context.settings.profile} mcp server status\``), "onCode"),
240
- onError: /* @__PURE__ */ __name((error) => context.renderer.note(`mcp: ${error.message}`), "onError")
241
- }).catch((error) => {
242
- if (error.code === "EADDRINUSE")
243
- throw new CliError("configuration_error", `port ${http.port} is in use \u2014 pass another with --port`);
244
- throw error;
245
- });
246
- context.renderer.note(`serving on ${listening.url.href} \u2014 point your tunnel at it; connectors use ${mcpUrlOf(http.publicUrl).href}`);
247
- await new Promise((resolve) => {
248
- process.once("SIGINT", resolve);
249
- process.once("SIGTERM", resolve);
250
- });
251
- await listening.close();
252
- }, "serveAppOverHttp");
253
- export {
254
- createAppServer,
255
- serveAppOverHttp,
256
- serveAppOverStdio
257
- };