@wirecat/amo-cli 0.0.0-stage → 0.1.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 (294) hide show
  1. package/CHANGELOG.md +61 -0
  2. package/LICENSE +204 -0
  3. package/README.md +257 -2
  4. package/contracts/wirecat.json +1356 -0
  5. package/dist/amo/account.d.ts +18 -0
  6. package/dist/amo/account.d.ts.map +1 -0
  7. package/dist/amo/account.js +48 -0
  8. package/dist/amo/account.js.map +1 -0
  9. package/dist/amo/allow-list.d.ts +31 -0
  10. package/dist/amo/allow-list.d.ts.map +1 -0
  11. package/dist/amo/allow-list.js +106 -0
  12. package/dist/amo/allow-list.js.map +1 -0
  13. package/dist/amo/call.d.ts +24 -0
  14. package/dist/amo/call.d.ts.map +1 -0
  15. package/dist/amo/call.js +54 -0
  16. package/dist/amo/call.js.map +1 -0
  17. package/dist/amo/errors.d.ts +12 -0
  18. package/dist/amo/errors.d.ts.map +1 -0
  19. package/dist/amo/errors.js +72 -0
  20. package/dist/amo/errors.js.map +1 -0
  21. package/dist/amo/json.d.ts +3 -0
  22. package/dist/amo/json.d.ts.map +1 -0
  23. package/dist/amo/json.js +3 -0
  24. package/dist/amo/json.js.map +1 -0
  25. package/dist/amo/oauth.d.ts +55 -0
  26. package/dist/amo/oauth.d.ts.map +1 -0
  27. package/dist/amo/oauth.js +189 -0
  28. package/dist/amo/oauth.js.map +1 -0
  29. package/dist/amo/operation.d.ts +45 -0
  30. package/dist/amo/operation.d.ts.map +1 -0
  31. package/dist/amo/operation.js +119 -0
  32. package/dist/amo/operation.js.map +1 -0
  33. package/dist/amo/operations.d.ts +3 -0
  34. package/dist/amo/operations.d.ts.map +1 -0
  35. package/dist/amo/operations.js +1407 -0
  36. package/dist/amo/operations.js.map +1 -0
  37. package/dist/amo/routes.d.ts +67 -0
  38. package/dist/amo/routes.d.ts.map +1 -0
  39. package/dist/amo/routes.js +65 -0
  40. package/dist/amo/routes.js.map +1 -0
  41. package/dist/amo/transport.d.ts +62 -0
  42. package/dist/amo/transport.d.ts.map +1 -0
  43. package/dist/amo/transport.js +282 -0
  44. package/dist/amo/transport.js.map +1 -0
  45. package/dist/api-keys.d.ts +47 -0
  46. package/dist/api-keys.d.ts.map +1 -0
  47. package/dist/api-keys.js +224 -0
  48. package/dist/api-keys.js.map +1 -0
  49. package/dist/bin/amo.d.ts +3 -0
  50. package/dist/bin/amo.d.ts.map +1 -0
  51. package/dist/bin/amo.js +40 -0
  52. package/dist/bin/amo.js.map +1 -0
  53. package/dist/bundle/all-profiles-3KQVWDV4.js +278 -0
  54. package/dist/bundle/amo.js +198 -0
  55. package/dist/bundle/anthropic-N5NOX7K7.js +90 -0
  56. package/dist/bundle/app-server-2MST5EZ5.js +245 -0
  57. package/dist/bundle/bun-4NHWOFX2.js +169 -0
  58. package/dist/bundle/bun-sqlite-DRSXPWPR.js +75 -0
  59. package/dist/bundle/chunk-2I5UVMLW.js +3232 -0
  60. package/dist/bundle/chunk-3IRJDH2U.js +731 -0
  61. package/dist/bundle/chunk-4ZAK773N.js +100 -0
  62. package/dist/bundle/chunk-5D4AEUVA.js +24783 -0
  63. package/dist/bundle/chunk-5D4Z2B5B.js +334 -0
  64. package/dist/bundle/chunk-5E5R65CA.js +54 -0
  65. package/dist/bundle/chunk-5HGGG3QO.js +73 -0
  66. package/dist/bundle/chunk-5RLUHTK6.js +23 -0
  67. package/dist/bundle/chunk-5SBLU7D7.js +63 -0
  68. package/dist/bundle/chunk-5Z5PEEKP.js +206 -0
  69. package/dist/bundle/chunk-63F65DHU.js +29 -0
  70. package/dist/bundle/chunk-6RS7OYTD.js +64 -0
  71. package/dist/bundle/chunk-73CXFE36.js +88 -0
  72. package/dist/bundle/chunk-7GTUZY7M.js +170 -0
  73. package/dist/bundle/chunk-7PKFYX7V.js +189 -0
  74. package/dist/bundle/chunk-7U5HJEPZ.js +1400 -0
  75. package/dist/bundle/chunk-A33TIM5D.js +4172 -0
  76. package/dist/bundle/chunk-ADEWU4P4.js +38 -0
  77. package/dist/bundle/chunk-ADLS6FVG.js +24600 -0
  78. package/dist/bundle/chunk-AHJ4W2IL.js +106 -0
  79. package/dist/bundle/chunk-AUBB72VF.js +2572 -0
  80. package/dist/bundle/chunk-BVMNXI53.js +1266 -0
  81. package/dist/bundle/chunk-CDY2NJFE.js +136 -0
  82. package/dist/bundle/chunk-CHUKWON6.js +244 -0
  83. package/dist/bundle/chunk-CUZRHF34.js +230 -0
  84. package/dist/bundle/chunk-D72URWJE.js +532 -0
  85. package/dist/bundle/chunk-DAY6TSPF.js +786 -0
  86. package/dist/bundle/chunk-DFDN6AUB.js +21 -0
  87. package/dist/bundle/chunk-DJD7TBYG.js +2791 -0
  88. package/dist/bundle/chunk-DOSJONCX.js +1197 -0
  89. package/dist/bundle/chunk-DQV2IKCF.js +72 -0
  90. package/dist/bundle/chunk-DTA5YV5O.js +25 -0
  91. package/dist/bundle/chunk-DXGGCGRP.js +218 -0
  92. package/dist/bundle/chunk-EH6ZEJGT.js +932 -0
  93. package/dist/bundle/chunk-EPOV5UIO.js +185 -0
  94. package/dist/bundle/chunk-EQ7A6NA6.js +53 -0
  95. package/dist/bundle/chunk-EQUKVVHX.js +353 -0
  96. package/dist/bundle/chunk-EROSAUNP.js +133 -0
  97. package/dist/bundle/chunk-ESZSMZKT.js +82 -0
  98. package/dist/bundle/chunk-FKR3M62D.js +407 -0
  99. package/dist/bundle/chunk-GNTJMB6X.js +142 -0
  100. package/dist/bundle/chunk-GQ7VFIYM.js +316 -0
  101. package/dist/bundle/chunk-JH3UOHRE.js +161 -0
  102. package/dist/bundle/chunk-JMDLPBXK.js +1068 -0
  103. package/dist/bundle/chunk-JR6TSMFX.js +9435 -0
  104. package/dist/bundle/chunk-K5UU3IOR.js +27955 -0
  105. package/dist/bundle/chunk-L6AFE73L.js +18 -0
  106. package/dist/bundle/chunk-LDEBZ3IX.js +238 -0
  107. package/dist/bundle/chunk-LGQXGOPJ.js +58 -0
  108. package/dist/bundle/chunk-LJQUYECN.js +6848 -0
  109. package/dist/bundle/chunk-LRBPT7LQ.js +95 -0
  110. package/dist/bundle/chunk-LSND5QYI.js +460 -0
  111. package/dist/bundle/chunk-NHXJYS4R.js +1334 -0
  112. package/dist/bundle/chunk-NJYAL3UW.js +92 -0
  113. package/dist/bundle/chunk-NTLSWCJ5.js +1718 -0
  114. package/dist/bundle/chunk-O2UCU52O.js +4065 -0
  115. package/dist/bundle/chunk-ODNQU7DH.js +1028 -0
  116. package/dist/bundle/chunk-P3WQRTYZ.js +24 -0
  117. package/dist/bundle/chunk-P5LYZRKW.js +63373 -0
  118. package/dist/bundle/chunk-PFO76YFP.js +2003 -0
  119. package/dist/bundle/chunk-PM77PRB6.js +12269 -0
  120. package/dist/bundle/chunk-Q2VNBY4Y.js +38109 -0
  121. package/dist/bundle/chunk-QDMXZZG4.js +604 -0
  122. package/dist/bundle/chunk-QRQYUHCZ.js +761 -0
  123. package/dist/bundle/chunk-RPWAJYI6.js +2336 -0
  124. package/dist/bundle/chunk-SMSTGO2G.js +58 -0
  125. package/dist/bundle/chunk-SZ2V62HB.js +72 -0
  126. package/dist/bundle/chunk-T2UDLX76.js +259 -0
  127. package/dist/bundle/chunk-TGEQNS6G.js +16 -0
  128. package/dist/bundle/chunk-TNUFLULO.js +2333 -0
  129. package/dist/bundle/chunk-U7RLVJ34.js +274 -0
  130. package/dist/bundle/chunk-UBRREVLJ.js +72 -0
  131. package/dist/bundle/chunk-ULXQ5MJM.js +76 -0
  132. package/dist/bundle/chunk-UMVRT7VQ.js +46 -0
  133. package/dist/bundle/chunk-V77XNPXG.js +360 -0
  134. package/dist/bundle/chunk-VVHRQ46X.js +193 -0
  135. package/dist/bundle/chunk-VX37MPTJ.js +7 -0
  136. package/dist/bundle/chunk-WCYCUTSK.js +362 -0
  137. package/dist/bundle/chunk-XEFAMLSD.js +288 -0
  138. package/dist/bundle/chunk-XQL7FEF4.js +721 -0
  139. package/dist/bundle/chunk-XRTD2GCU.js +627 -0
  140. package/dist/bundle/chunk-Y37A3232.js +804 -0
  141. package/dist/bundle/chunk-Y5E2WNWB.js +35 -0
  142. package/dist/bundle/chunk-ZM7I52EP.js +78 -0
  143. package/dist/bundle/chunk-ZVVMGPBJ.js +50 -0
  144. package/dist/bundle/cli-KEGIR67U.js +1193 -0
  145. package/dist/bundle/command-contract-QBUQBXH7.js +39 -0
  146. package/dist/bundle/command-server-entry-5VL5U5EE.js +168 -0
  147. package/dist/bundle/decode-SQ5WGNDX.js +296 -0
  148. package/dist/bundle/dispatch-LA4DFXJD.js +411 -0
  149. package/dist/bundle/dist-XJGFOXYI.js +7577 -0
  150. package/dist/bundle/echarts-25Z3RINX.js +42501 -0
  151. package/dist/bundle/embed-BNOTNXMA.js +37 -0
  152. package/dist/bundle/embedder-BCUT7KKV.js +110 -0
  153. package/dist/bundle/failure-PKAC6XCT.js +24 -0
  154. package/dist/bundle/first-run-EO5K5GME.js +28 -0
  155. package/dist/bundle/first-screen-GMN3T6RW.js +39 -0
  156. package/dist/bundle/instructions-VLM3QAYB.js +11 -0
  157. package/dist/bundle/mcp-7ILNMJH5.js +167 -0
  158. package/dist/bundle/meeting-combined-LAMF7S2B.js +24 -0
  159. package/dist/bundle/meeting-model-GHMMUQ34.js +24 -0
  160. package/dist/bundle/meeting-semantic-BMP6323L.js +21 -0
  161. package/dist/bundle/node-CT3N3TNL.js +176 -0
  162. package/dist/bundle/node-P4E63KXA.js +2340 -0
  163. package/dist/bundle/node-TLZSIHIJ.js +21 -0
  164. package/dist/bundle/node-sqlite-MELD2SBX.js +73 -0
  165. package/dist/bundle/oauth-YBH5OKC2.js +19 -0
  166. package/dist/bundle/open-WNSBWTAG.js +22 -0
  167. package/dist/bundle/openai-XSNMNLW6.js +237 -0
  168. package/dist/bundle/process-I2QKOMM7.js +91 -0
  169. package/dist/bundle/program-VQQTSSAF.js +4940 -0
  170. package/dist/bundle/prompt-SOG4AKPM.js +16 -0
  171. package/dist/bundle/recognize-WMQLWMXH.js +25 -0
  172. package/dist/bundle/remote-4BTFOLFY.js +30 -0
  173. package/dist/bundle/rerank-LJ3TWRNV.js +51 -0
  174. package/dist/bundle/serve-B6UANKXN.js +198 -0
  175. package/dist/bundle/server-S6XD6V6E.js +77 -0
  176. package/dist/bundle/server-YRH6GJ5Z.js +206 -0
  177. package/dist/bundle/source-DGFTA2TN.js +42 -0
  178. package/dist/bundle/sqlite-runtime-R7QFWFE7.js +19 -0
  179. package/dist/bundle/state-DIJ5YUOE.js +35 -0
  180. package/dist/bundle/store-6WFWW7EC.js +294 -0
  181. package/dist/bundle/store-BPNIM4BF.js +32 -0
  182. package/dist/bundle/store-MYTYDV6A.js +177 -0
  183. package/dist/bundle/store-maintenance-command-B5TMKFMG.js +68 -0
  184. package/dist/bundle/writer-GP7VIMAU.js +44 -0
  185. package/dist/commands/account.d.ts +3 -0
  186. package/dist/commands/account.d.ts.map +1 -0
  187. package/dist/commands/account.js +86 -0
  188. package/dist/commands/account.js.map +1 -0
  189. package/dist/commands/api.d.ts +3 -0
  190. package/dist/commands/api.d.ts.map +1 -0
  191. package/dist/commands/api.js +224 -0
  192. package/dist/commands/api.js.map +1 -0
  193. package/dist/commands/comments.d.ts +3 -0
  194. package/dist/commands/comments.d.ts.map +1 -0
  195. package/dist/commands/comments.js +114 -0
  196. package/dist/commands/comments.js.map +1 -0
  197. package/dist/commands/crm-shared.d.ts +8 -0
  198. package/dist/commands/crm-shared.d.ts.map +1 -0
  199. package/dist/commands/crm-shared.js +111 -0
  200. package/dist/commands/crm-shared.js.map +1 -0
  201. package/dist/commands/schedule.d.ts +3 -0
  202. package/dist/commands/schedule.d.ts.map +1 -0
  203. package/dist/commands/schedule.js +9 -0
  204. package/dist/commands/schedule.js.map +1 -0
  205. package/dist/commands/session.d.ts +18 -0
  206. package/dist/commands/session.d.ts.map +1 -0
  207. package/dist/commands/session.js +265 -0
  208. package/dist/commands/session.js.map +1 -0
  209. package/dist/commands/write.d.ts +14 -0
  210. package/dist/commands/write.d.ts.map +1 -0
  211. package/dist/commands/write.js +36 -0
  212. package/dist/commands/write.js.map +1 -0
  213. package/dist/config.d.ts +4 -0
  214. package/dist/config.d.ts.map +1 -0
  215. package/dist/config.js +29 -0
  216. package/dist/config.js.map +1 -0
  217. package/dist/context.d.ts +62 -0
  218. package/dist/context.d.ts.map +1 -0
  219. package/dist/context.js +97 -0
  220. package/dist/context.js.map +1 -0
  221. package/dist/crm/activities.d.ts +32 -0
  222. package/dist/crm/activities.d.ts.map +1 -0
  223. package/dist/crm/activities.js +196 -0
  224. package/dist/crm/activities.js.map +1 -0
  225. package/dist/crm/records.d.ts +20 -0
  226. package/dist/crm/records.d.ts.map +1 -0
  227. package/dist/crm/records.js +175 -0
  228. package/dist/crm/records.js.map +1 -0
  229. package/dist/crm/source.d.ts +41 -0
  230. package/dist/crm/source.d.ts.map +1 -0
  231. package/dist/crm/source.js +673 -0
  232. package/dist/crm/source.js.map +1 -0
  233. package/dist/crm/writer.d.ts +14 -0
  234. package/dist/crm/writer.d.ts.map +1 -0
  235. package/dist/crm/writer.js +247 -0
  236. package/dist/crm/writer.js.map +1 -0
  237. package/dist/identity.d.ts +7 -0
  238. package/dist/identity.d.ts.map +1 -0
  239. package/dist/identity.js +33 -0
  240. package/dist/identity.js.map +1 -0
  241. package/dist/index.d.ts +3 -0
  242. package/dist/index.d.ts.map +1 -0
  243. package/dist/index.js +3 -0
  244. package/dist/index.js.map +1 -0
  245. package/dist/program.d.ts +6 -0
  246. package/dist/program.d.ts.map +1 -0
  247. package/dist/program.js +91 -0
  248. package/dist/program.js.map +1 -0
  249. package/dist/reasons.d.ts +10 -0
  250. package/dist/reasons.d.ts.map +1 -0
  251. package/dist/reasons.js +35 -0
  252. package/dist/reasons.js.map +1 -0
  253. package/dist/sample/comments.d.ts +61 -0
  254. package/dist/sample/comments.d.ts.map +1 -0
  255. package/dist/sample/comments.js +39 -0
  256. package/dist/sample/comments.js.map +1 -0
  257. package/dist/sample/records.d.ts +16 -0
  258. package/dist/sample/records.d.ts.map +1 -0
  259. package/dist/sample/records.js +22 -0
  260. package/dist/sample/records.js.map +1 -0
  261. package/dist/sample/transport.d.ts +42 -0
  262. package/dist/sample/transport.d.ts.map +1 -0
  263. package/dist/sample/transport.js +153 -0
  264. package/dist/sample/transport.js.map +1 -0
  265. package/dist/setup/flow.d.ts +2 -0
  266. package/dist/setup/flow.d.ts.map +1 -0
  267. package/dist/setup/flow.js +127 -0
  268. package/dist/setup/flow.js.map +1 -0
  269. package/dist/setup/texts.en.json +25 -0
  270. package/dist/setup/texts.es.json +25 -0
  271. package/dist/setup/texts.ru.json +25 -0
  272. package/dist/store.d.ts +15 -0
  273. package/dist/store.d.ts.map +1 -0
  274. package/dist/store.js +16 -0
  275. package/dist/store.js.map +1 -0
  276. package/dist/version.d.ts +2 -0
  277. package/dist/version.d.ts.map +1 -0
  278. package/dist/version.js +2 -0
  279. package/dist/version.js.map +1 -0
  280. package/dist/wcat.d.ts +3 -0
  281. package/dist/wcat.d.ts.map +1 -0
  282. package/dist/wcat.js +4 -0
  283. package/dist/wcat.js.map +1 -0
  284. package/dist/whoami.d.ts +24 -0
  285. package/dist/whoami.d.ts.map +1 -0
  286. package/dist/whoami.js +33 -0
  287. package/dist/whoami.js.map +1 -0
  288. package/package.json +85 -4
  289. package/skills/amo-cli/SKILL.md +116 -0
  290. package/skills/amo-cli/references/mcp.md +38 -0
  291. package/skills/amo-cli/references/output.md +42 -0
  292. package/skills/amo-cli/references/reading.md +77 -0
  293. package/skills/amo-cli/references/setup.md +59 -0
  294. package/skills/amo-cli/references/writing.md +85 -0
@@ -0,0 +1,142 @@
1
+ import { createRequire as __bundleRequire } from "node:module";
2
+ const require = __bundleRequire(import.meta.url);
3
+ import {
4
+ executableEnvironment,
5
+ executableOnPath
6
+ } from "./chunk-UMVRT7VQ.js";
7
+ import {
8
+ require_cross_spawn
9
+ } from "./chunk-D72URWJE.js";
10
+ import {
11
+ loadConfigFile,
12
+ saveConfigFile
13
+ } from "./chunk-DJD7TBYG.js";
14
+ import {
15
+ number,
16
+ object,
17
+ optional,
18
+ string
19
+ } from "./chunk-AUBB72VF.js";
20
+ import {
21
+ __name,
22
+ __toESM
23
+ } from "./chunk-ZVVMGPBJ.js";
24
+
25
+ // node_modules/.pnpm/@wirecat+cli-base@0.113.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/update/index.js
26
+ var import_cross_spawn = __toESM(require_cross_spawn(), 1);
27
+ import { existsSync } from "node:fs";
28
+ var updateCommand = /* @__PURE__ */ __name((installer, packageName) => {
29
+ const target = `${packageName}@latest`;
30
+ switch (installer) {
31
+ // pnpm 11 installs only versions a day old (minimumReleaseAge 1440); a fix must reach users the day it ships.
32
+ // Only the package's own scope is exempt — every other dependency keeps the wait.
33
+ case "pnpm":
34
+ return ["pnpm", "add", "-g", target, `--config.minimumReleaseAgeExclude=${ownScope(packageName)}`];
35
+ case "npm":
36
+ return ["npm", "install", "-g", target];
37
+ case "bun":
38
+ return ["bun", "add", "-g", target];
39
+ default:
40
+ return void 0;
41
+ }
42
+ }, "updateCommand");
43
+ var ownScope = /* @__PURE__ */ __name((packageName) => packageName.startsWith("@") ? `${packageName.split("/", 1)[0]}/*` : packageName, "ownScope");
44
+ var isNewer = /* @__PURE__ */ __name((candidate, current) => {
45
+ const parse = /* @__PURE__ */ __name((version) => /^\d+\.\d+\.\d+$/.test(version) ? version.split(".").map(Number) : void 0, "parse");
46
+ const a = parse(candidate);
47
+ const b = parse(current);
48
+ if (!a || !b)
49
+ return false;
50
+ for (let i = 0; i < 3; i++) {
51
+ if (a[i] !== b[i])
52
+ return a[i] > b[i];
53
+ }
54
+ return false;
55
+ }, "isNewer");
56
+ var latestVersion = /* @__PURE__ */ __name(async (packageName, fetch, { timeoutMs = 1e3 } = {}) => {
57
+ try {
58
+ const response = await fetch(`https://registry.npmjs.org/${packageName}/latest`, {
59
+ signal: AbortSignal.timeout(timeoutMs),
60
+ headers: { accept: "application/json" }
61
+ });
62
+ if (!response.ok)
63
+ return void 0;
64
+ const { version } = await response.json();
65
+ return typeof version === "string" ? version : void 0;
66
+ } catch {
67
+ return void 0;
68
+ }
69
+ }, "latestVersion");
70
+ var CHECK_EVERY_MS = 24 * 60 * 60 * 1e3;
71
+ var mayNotify = /* @__PURE__ */ __name(({ format, stderrIsTTY, quiet, enabled, installer, env, offVariables = [] }) => enabled && format === "pretty" && stderrIsTTY && !quiet && updateCommand(installer, "any") !== void 0 && !env.CI && !env.NO_UPDATE_NOTIFIER && offVariables.every((name) => !env[name]), "mayNotify");
72
+ var updateState = object({
73
+ checkedAt: number(),
74
+ latest: optional(string()),
75
+ /** When the skill hint (`cli-base/skill`) was last shown — the other daily notice kept in this file. */
76
+ skillHintAt: optional(number())
77
+ });
78
+ var readNoticeState = /* @__PURE__ */ __name((path) => {
79
+ try {
80
+ return loadConfigFile(path, updateState, () => ({ checkedAt: 0 }));
81
+ } catch {
82
+ return { checkedAt: 0 };
83
+ }
84
+ }, "readNoticeState");
85
+ var readUpdateState = /* @__PURE__ */ __name((path) => {
86
+ const state = readNoticeState(path);
87
+ return state.checkedAt > 0 ? state : void 0;
88
+ }, "readUpdateState");
89
+ var writeUpdateState = /* @__PURE__ */ __name((path, state) => {
90
+ try {
91
+ saveConfigFile(path, { ...readNoticeState(path), ...state });
92
+ } catch {
93
+ }
94
+ }, "writeUpdateState");
95
+ var checkIsDue = /* @__PURE__ */ __name((state, now) => state === void 0 || now - state.checkedAt >= CHECK_EVERY_MS, "checkIsDue");
96
+ var spawnPlan = /* @__PURE__ */ __name(([command, ...args], platform = process.platform, env = process.env, exists = existsSync) => ({ file: executableOnPath(command, env, platform, exists), args, shell: false }), "spawnPlan");
97
+ var runUpdate = /* @__PURE__ */ __name((argv) => {
98
+ const { file, args, shell } = spawnPlan(argv);
99
+ const { status, error } = import_cross_spawn.default.sync(file, args, {
100
+ stdio: ["inherit", 2, 2],
101
+ shell,
102
+ env: executableEnvironment(process.env)
103
+ });
104
+ if (error)
105
+ throw new Error(`could not start ${argv[0]}: ${error.message}`);
106
+ return status ?? 1;
107
+ }, "runUpdate");
108
+ var updateNotice = /* @__PURE__ */ __name(async ({ argv, packageName, command, upgradeCommand = "upgrade", version, statePath, fetch, now = Date.now, ...context }) => {
109
+ try {
110
+ const path = commandWords(argv).slice(0, 2);
111
+ if (path.includes("complete") || path.includes(upgradeCommand))
112
+ return void 0;
113
+ if (!mayNotify(context))
114
+ return void 0;
115
+ const at = now();
116
+ let state = readUpdateState(statePath);
117
+ if (checkIsDue(state, at)) {
118
+ const found = await latestVersion(packageName, fetch, { timeoutMs: 1e3 });
119
+ const seen = found ?? state?.latest;
120
+ state = seen ? { checkedAt: at, latest: seen } : { checkedAt: at };
121
+ writeUpdateState(statePath, state);
122
+ }
123
+ return state?.latest && isNewer(state.latest, version) ? `${command} ${state.latest} is out \u2014 you have ${version}. \`${command} ${upgradeCommand}\` installs it.` : void 0;
124
+ } catch {
125
+ return void 0;
126
+ }
127
+ }, "updateNotice");
128
+ var commandWords = /* @__PURE__ */ __name((argv) => {
129
+ const end = argv.indexOf("--");
130
+ return argv.slice(0, end < 0 ? void 0 : end).filter((word) => !word.startsWith("-"));
131
+ }, "commandWords");
132
+
133
+ export {
134
+ updateCommand,
135
+ isNewer,
136
+ latestVersion,
137
+ CHECK_EVERY_MS,
138
+ readNoticeState,
139
+ writeUpdateState,
140
+ runUpdate,
141
+ updateNotice
142
+ };
@@ -0,0 +1,316 @@
1
+ import { createRequire as __bundleRequire } from "node:module";
2
+ const require = __bundleRequire(import.meta.url);
3
+ import {
4
+ CliError,
5
+ isCliError
6
+ } from "./chunk-SZ2V62HB.js";
7
+ import {
8
+ __name
9
+ } from "./chunk-ZVVMGPBJ.js";
10
+
11
+ // node_modules/.pnpm/@wirecat+cli-base@0.113.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/http/body.js
12
+ var interrupted = /* @__PURE__ */ __name((signal) => isCliError(signal.reason) ? signal.reason : new CliError(signal.reason instanceof Error && signal.reason.name === "TimeoutError" ? "timeout" : "cancelled", "HTTP response read was interrupted"), "interrupted");
13
+ var checked = /* @__PURE__ */ __name((signal) => {
14
+ if (signal?.aborted)
15
+ throw interrupted(signal);
16
+ }, "checked");
17
+ var abortable = /* @__PURE__ */ __name(async (pending, signal) => {
18
+ if (!signal)
19
+ return pending;
20
+ let abort = /* @__PURE__ */ __name(() => {
21
+ }, "abort");
22
+ const stopped = new Promise((_, reject) => {
23
+ abort = /* @__PURE__ */ __name(() => reject(interrupted(signal)), "abort");
24
+ signal.addEventListener("abort", abort, { once: true });
25
+ if (signal.aborted)
26
+ abort();
27
+ });
28
+ try {
29
+ return await Promise.race([pending, stopped]);
30
+ } finally {
31
+ signal.removeEventListener("abort", abort);
32
+ }
33
+ }, "abortable");
34
+ var readJsonResponse = /* @__PURE__ */ __name(async (response, options) => {
35
+ const { maxBytes, signal } = options ?? {};
36
+ if (!Number.isSafeInteger(maxBytes) || maxBytes < 1)
37
+ throw new CliError("validation_error", "maxBytes must be a positive safe integer");
38
+ if (signal !== void 0 && !(signal instanceof AbortSignal))
39
+ throw new CliError("validation_error", "signal must be an AbortSignal");
40
+ if (signal?.aborted) {
41
+ void response.body?.cancel().catch(() => {
42
+ });
43
+ throw interrupted(signal);
44
+ }
45
+ const length = response.headers.get("content-length");
46
+ if (length !== null && (!/^\d+$/.test(length) || Number(length) > maxBytes)) {
47
+ void response.body?.cancel().catch(() => {
48
+ });
49
+ throw new CliError("invalid_response", "HTTP response exceeds the byte budget");
50
+ }
51
+ if (!response.body)
52
+ throw new CliError("invalid_response", "HTTP response has no body");
53
+ if (response.body.locked)
54
+ throw new CliError("invalid_response", "HTTP response body is already in use");
55
+ const reader = response.body.getReader();
56
+ const chunks = [];
57
+ let bytes = 0;
58
+ try {
59
+ for (; ; ) {
60
+ checked(signal);
61
+ const part = await abortable(reader.read(), signal);
62
+ checked(signal);
63
+ if (part.done)
64
+ break;
65
+ if (!(part.value instanceof Uint8Array))
66
+ throw new CliError("invalid_response", "HTTP response is not bytes");
67
+ bytes += part.value.byteLength;
68
+ if (bytes > maxBytes)
69
+ throw new CliError("invalid_response", "HTTP response exceeds the byte budget");
70
+ if (part.value.byteLength)
71
+ chunks.push(new Uint8Array(part.value));
72
+ }
73
+ const body = new Uint8Array(bytes);
74
+ let offset = 0;
75
+ for (const chunk of chunks) {
76
+ body.set(chunk, offset);
77
+ offset += chunk.byteLength;
78
+ }
79
+ try {
80
+ return JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(body));
81
+ } catch {
82
+ throw new CliError("invalid_response", "HTTP response is not valid UTF-8 JSON");
83
+ }
84
+ } catch (error) {
85
+ checked(signal);
86
+ if (isCliError(error))
87
+ throw error;
88
+ throw new CliError("network_error", "HTTP response could not be read");
89
+ } finally {
90
+ void reader.cancel().catch(() => {
91
+ });
92
+ reader.releaseLock();
93
+ }
94
+ }, "readJsonResponse");
95
+
96
+ // node_modules/.pnpm/@wirecat+cli-base@0.113.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/http/hosts.js
97
+ var LABEL = "[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?";
98
+ var HOST_PATTERN = new RegExp(`^(?:${LABEL}(?:\\.${LABEL})*|\\*\\.${LABEL}(?:\\.${LABEL})+)$`);
99
+ var hostProblems = /* @__PURE__ */ __name((hosts) => [
100
+ ...hosts.filter((host) => !HOST_PATTERN.test(host) || host.length > 253).map((host) => `${JSON.stringify(host)} is not a host: a lower-case hostname with no scheme, port or path, or one leading *. before two labels or more`),
101
+ ...hosts.filter((host, at) => hosts.indexOf(host) !== at).map((host) => `${JSON.stringify(host)} is listed twice`)
102
+ ], "hostProblems");
103
+ var hostCovered = /* @__PURE__ */ __name((hostname, hosts) => {
104
+ const name = hostname.toLowerCase().replace(/\.$/, "");
105
+ return hosts.some((host) => host.startsWith("*.") ? name.endsWith(host.slice(1)) : name === host);
106
+ }, "hostCovered");
107
+
108
+ // node_modules/.pnpm/@wirecat+cli-base@0.113.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/http/fetch.js
109
+ var HOST_FETCH_TIMEOUT_MS = 3e4;
110
+ var REDIRECTS = 5;
111
+ var REDIRECT_STATUSES = /* @__PURE__ */ new Set([301, 302, 303, 307, 308]);
112
+ var CREDENTIAL_HEADERS = ["authorization", "cookie", "proxy-authorization"];
113
+ var NO_BODY = /* @__PURE__ */ new Set([204, 205, 304]);
114
+ var deadline = /* @__PURE__ */ __name((ms) => {
115
+ const controller = new AbortController();
116
+ const timer = setTimeout(() => controller.abort(new DOMException(`no answer within ${ms} ms`, "TimeoutError")), ms);
117
+ timer.unref?.();
118
+ return { signal: controller.signal, clear: /* @__PURE__ */ __name(() => clearTimeout(timer), "clear") };
119
+ }, "deadline");
120
+ var released = /* @__PURE__ */ __name((response, clear) => {
121
+ if (!response.body || NO_BODY.has(response.status) || response.status < 200 || response.status > 599) {
122
+ clear();
123
+ return response;
124
+ }
125
+ const { status, statusText, headers, url, redirected } = response;
126
+ const wrapped = new Response(response.body.pipeThrough(new TransformStream({ flush: clear })), {
127
+ status,
128
+ statusText,
129
+ headers
130
+ });
131
+ return Object.defineProperties(wrapped, { url: { value: url }, redirected: { value: redirected } });
132
+ }, "released");
133
+ var undeclared = /* @__PURE__ */ __name((url) => new CliError("configuration_error", `${url.hostname} is not a host this CLI declares: add "${url.hostname}" to \`hosts\` in its WCAT identity and run cli-dev manifest`, { reason: "network.host-undeclared", sent: false }), "undeclared");
134
+ var checked2 = /* @__PURE__ */ __name((url, hosts) => {
135
+ if (url.protocol !== "https:" && url.protocol !== "http:")
136
+ throw new CliError("validation_error", `only http and https are fetched, not ${url.protocol.replace(/:$/, "")}`, {
137
+ sent: false
138
+ });
139
+ if (!hostCovered(url.hostname, hosts))
140
+ throw undeclared(url);
141
+ return url;
142
+ }, "checked");
143
+ var NOT_SENT = /* @__PURE__ */ new Set(["EAI_AGAIN", "ENOTFOUND", "ECONNREFUSED"]);
144
+ var neverSent = /* @__PURE__ */ __name((error) => {
145
+ for (let at = error, depth = 0; at instanceof Error && depth < 4; at = at.cause, depth++) {
146
+ const code = at.code;
147
+ if (typeof code === "string" && NOT_SENT.has(code))
148
+ return true;
149
+ }
150
+ return false;
151
+ }, "neverSent");
152
+ var hostFetch = /* @__PURE__ */ __name((options) => {
153
+ const problems = hostProblems(options.hosts);
154
+ if (problems.length > 0)
155
+ throw new CliError("configuration_error", problems.join("; "));
156
+ const { hosts, fetch: send = globalThis.fetch, timeoutMs = HOST_FETCH_TIMEOUT_MS, redirects = REDIRECTS } = options;
157
+ return async (input, init = {}) => {
158
+ const request = input instanceof Request ? input : void 0;
159
+ let url = checked2(new URL(request?.url ?? String(input)), hosts);
160
+ const caller = init.signal ?? request?.signal;
161
+ const timeout = deadline(timeoutMs);
162
+ const signal = caller ? AbortSignal.any([caller, timeout.signal]) : timeout.signal;
163
+ const follow = (init.redirect ?? request?.redirect ?? "follow") === "follow";
164
+ let method = (init.method ?? request?.method ?? "GET").toUpperCase();
165
+ let body = init.body ?? request?.body ?? void 0;
166
+ const headers = new Headers(init.headers ?? request?.headers);
167
+ let answered = false;
168
+ try {
169
+ let response = await send(input, { ...init, signal, ...follow ? { redirect: "manual" } : {} });
170
+ answered = true;
171
+ for (let hop = 0; follow && REDIRECT_STATUSES.has(response.status); hop += 1) {
172
+ const location = response.headers.get("location");
173
+ if (!location)
174
+ return released(response, timeout.clear);
175
+ if (hop >= redirects)
176
+ throw new CliError("invalid_response", `more than ${redirects} redirects from ${url.hostname}`);
177
+ void response.body?.cancel().catch(() => {
178
+ });
179
+ const next = checked2(new URL(location, url), hosts);
180
+ if (response.status === 303 || (response.status === 301 || response.status === 302) && method === "POST") {
181
+ method = method === "HEAD" ? "HEAD" : "GET";
182
+ body = void 0;
183
+ headers.delete("content-type");
184
+ headers.delete("content-length");
185
+ } else if (body instanceof ReadableStream)
186
+ throw new CliError("invalid_response", `${url.hostname} redirected a streamed body, which cannot be sent again`);
187
+ if (next.origin !== url.origin)
188
+ for (const name of CREDENTIAL_HEADERS)
189
+ headers.delete(name);
190
+ url = next;
191
+ response = await send(url, { ...init, method, headers, body, signal, redirect: "manual" });
192
+ }
193
+ return released(response, timeout.clear);
194
+ } catch (error) {
195
+ timeout.clear();
196
+ if (isCliError(error))
197
+ throw error;
198
+ if (caller?.aborted)
199
+ throw isCliError(caller.reason) ? caller.reason : new CliError("cancelled", "request cancelled");
200
+ if (timeout.signal.aborted)
201
+ throw new CliError("timeout", `${url.hostname} did not answer within ${timeoutMs} ms`, { retryable: true });
202
+ throw new CliError("network_error", `${url.hostname} could not be reached`, {
203
+ retryable: true,
204
+ ...!answered && neverSent(error) ? { sent: false } : {}
205
+ });
206
+ }
207
+ };
208
+ }, "hostFetch");
209
+
210
+ // node_modules/.pnpm/@wirecat+cli-base@0.113.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/http/index.js
211
+ var parseRetryAfter = /* @__PURE__ */ __name((header, now) => {
212
+ if (!header)
213
+ return void 0;
214
+ const trimmed = header.trim();
215
+ if (/^\d+$/.test(trimmed))
216
+ return Number(trimmed) * 1e3;
217
+ const at = Date.parse(trimmed);
218
+ if (Number.isNaN(at))
219
+ return void 0;
220
+ const delta = at - now().getTime();
221
+ return delta > 0 ? delta : void 0;
222
+ }, "parseRetryAfter");
223
+ var parseRateLimitReset = /* @__PURE__ */ __name((header, now) => {
224
+ if (!header)
225
+ return void 0;
226
+ const seconds = Number(header.trim());
227
+ if (!Number.isFinite(seconds))
228
+ return void 0;
229
+ const delta = seconds * 1e3 - now().getTime();
230
+ return delta > 0 ? delta : void 0;
231
+ }, "parseRateLimitReset");
232
+ var providerWaitMs = /* @__PURE__ */ __name((headers, now) => parseRetryAfter(headers.get("retry-after"), now) ?? parseRateLimitReset(headers.get("x-ratelimit-reset"), now), "providerWaitMs");
233
+ var retryableStatus = /* @__PURE__ */ __name((status) => status === 408 || status === 429 || status >= 500, "retryableStatus");
234
+ var statusToCode = /* @__PURE__ */ __name((status) => {
235
+ if (status === 400 || status === 422)
236
+ return "validation_error";
237
+ if (status === 401)
238
+ return "authentication_error";
239
+ if (status === 403)
240
+ return "permission_error";
241
+ if (status === 404)
242
+ return "not_found";
243
+ if (status === 408)
244
+ return "timeout";
245
+ if (status === 429)
246
+ return "rate_limited";
247
+ if (status === 502 || status === 503 || status === 504)
248
+ return "provider_unavailable";
249
+ return "provider_error";
250
+ }, "statusToCode");
251
+
252
+ // node_modules/.pnpm/@wirecat+cli-core@0.691.0_@wirecat+cli-base@0.113.0_commander@15.0.0_esbuild@0.28.2_typ_9a2e508bb6f63e7e29f0d776540ec8fd/node_modules/@wirecat/cli-core/dist/models/endpoint.js
253
+ var endpoint = /* @__PURE__ */ __name((value) => {
254
+ try {
255
+ const url = new URL(value);
256
+ return ["https:", "http:"].includes(url.protocol) && !url.username && !url.password && !url.search && !url.hash;
257
+ } catch {
258
+ return false;
259
+ }
260
+ }, "endpoint");
261
+ var loopback = /* @__PURE__ */ __name((hostname) => hostname === "localhost" || hostname === "[::1]" || /^127(\.\d{1,3}){3}$/.test(hostname), "loopback");
262
+ var onThisComputer = /* @__PURE__ */ __name((value) => {
263
+ try {
264
+ return loopback(new URL(value).hostname);
265
+ } catch {
266
+ return false;
267
+ }
268
+ }, "onThisComputer");
269
+ var modelAddressAllowed = /* @__PURE__ */ __name((value) => endpoint(value) && (new URL(value).protocol === "https:" || onThisComputer(value)), "modelAddressAllowed");
270
+ var PLAIN_HTTP_REFUSED = "this address is not allowed: use https, or http only on this computer";
271
+ var literalFetch = /* @__PURE__ */ __name((hostname, timeoutMs) => async (input, init = {}) => {
272
+ const url = new URL(input instanceof Request ? input.url : String(input));
273
+ if (url.hostname !== hostname)
274
+ throw new CliError("configuration_error", `${url.hostname} is not the model address's host, ${hostname}`, {
275
+ reason: "network.host-undeclared",
276
+ sent: false
277
+ });
278
+ const deadline2 = AbortSignal.timeout(timeoutMs);
279
+ const signal = init.signal ? AbortSignal.any([init.signal, deadline2]) : deadline2;
280
+ try {
281
+ const response = await fetch(input, { ...init, signal, redirect: "manual" });
282
+ if (response.status >= 300 && response.status < 400) {
283
+ void response.body?.cancel().catch(() => {
284
+ });
285
+ throw new CliError("invalid_response", `${hostname} answered with a redirect, which is not followed`);
286
+ }
287
+ return response;
288
+ } catch (error) {
289
+ if (isCliError(error))
290
+ throw error;
291
+ if (init.signal?.aborted)
292
+ throw new CliError("cancelled", "request cancelled");
293
+ if (deadline2.aborted)
294
+ throw new CliError("timeout", `${hostname} did not answer within ${timeoutMs} ms`, { retryable: true });
295
+ throw new CliError("network_error", `${hostname} could not be reached`, { retryable: true });
296
+ }
297
+ }, "literalFetch");
298
+ var endpointFetch = /* @__PURE__ */ __name((address, timeoutMs) => {
299
+ const { hostname } = new URL(address);
300
+ if (hostname === "[::1]")
301
+ return fetch;
302
+ return hostname.startsWith("[") ? literalFetch(hostname, timeoutMs) : hostFetch({ hosts: [hostname], timeoutMs });
303
+ }, "endpointFetch");
304
+
305
+ export {
306
+ readJsonResponse,
307
+ hostFetch,
308
+ providerWaitMs,
309
+ retryableStatus,
310
+ statusToCode,
311
+ endpoint,
312
+ onThisComputer,
313
+ modelAddressAllowed,
314
+ PLAIN_HTTP_REFUSED,
315
+ endpointFetch
316
+ };
@@ -0,0 +1,161 @@
1
+ import { createRequire as __bundleRequire } from "node:module";
2
+ const require = __bundleRequire(import.meta.url);
3
+ import {
4
+ holdLock,
5
+ readLock,
6
+ releaseLock,
7
+ takeLock
8
+ } from "./chunk-5HGGG3QO.js";
9
+ import {
10
+ __name
11
+ } from "./chunk-ZVVMGPBJ.js";
12
+
13
+ // node_modules/.pnpm/@wirecat+cli-core@0.691.0_@wirecat+cli-base@0.113.0_commander@15.0.0_esbuild@0.28.2_typ_9a2e508bb6f63e7e29f0d776540ec8fd/node_modules/@wirecat/cli-core/dist/mcp/http/state.js
14
+ import { existsSync as existsSync2, readFileSync as readFileSync2 } from "node:fs";
15
+
16
+ // node_modules/.pnpm/@wirecat+cli-core@0.691.0_@wirecat+cli-base@0.113.0_commander@15.0.0_esbuild@0.28.2_typ_9a2e508bb6f63e7e29f0d776540ec8fd/node_modules/@wirecat/cli-core/dist/mcp/http/activity.js
17
+ import { randomBytes } from "node:crypto";
18
+ import { chmodSync, existsSync, mkdirSync, readFileSync, renameSync, writeFileSync } from "node:fs";
19
+ import { dirname } from "node:path";
20
+ var WRITE_EVERY_MS = 2e3;
21
+ var TOOL_NAME = /^[A-Za-z0-9_.-]{1,64}$/;
22
+ var httpActivityFile = /* @__PURE__ */ __name((tokenFile) => `${tokenFile.replace(/\.json$/, "")}.activity.json`, "httpActivityFile");
23
+ var localDay = /* @__PURE__ */ __name((ms) => {
24
+ const d = new Date(ms);
25
+ return `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, "0")}-${String(d.getDate()).padStart(2, "0")}`;
26
+ }, "localDay");
27
+ var readActivity = /* @__PURE__ */ __name((path) => {
28
+ if (!existsSync(path))
29
+ return {};
30
+ try {
31
+ const parsed = JSON.parse(readFileSync(path, "utf8"));
32
+ return parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : {};
33
+ } catch {
34
+ return {};
35
+ }
36
+ }, "readActivity");
37
+ var calledTools = /* @__PURE__ */ __name((body) => (Array.isArray(body) ? body : [body]).flatMap((message) => {
38
+ if (!message || typeof message !== "object")
39
+ return [];
40
+ const { method, params } = message;
41
+ const name = params?.name;
42
+ return method === "tools/call" && typeof name === "string" && TOOL_NAME.test(name) ? [name] : [];
43
+ }), "calledTools");
44
+ var activityRecorder = /* @__PURE__ */ __name((path, now = Date.now) => {
45
+ const activity = readActivity(path);
46
+ let timer;
47
+ const write = /* @__PURE__ */ __name(() => {
48
+ timer = void 0;
49
+ try {
50
+ mkdirSync(dirname(path), { recursive: true, mode: 448 });
51
+ const temporary = `${path}.${randomBytes(8).toString("hex")}.tmp`;
52
+ writeFileSync(temporary, JSON.stringify(activity), { mode: 384, flag: "wx" });
53
+ chmodSync(temporary, 384);
54
+ renameSync(temporary, path);
55
+ } catch {
56
+ }
57
+ }, "write");
58
+ return {
59
+ record: /* @__PURE__ */ __name((clientId, tools) => {
60
+ const at = now();
61
+ const iso = new Date(at).toISOString();
62
+ const day = localDay(at);
63
+ const before = activity[clientId];
64
+ const counted = before?.day === day ? before.toolCalls : 0;
65
+ const last = tools.at(-1);
66
+ activity[clientId] = {
67
+ lastRequestAt: iso,
68
+ day,
69
+ toolCalls: counted + tools.length,
70
+ ...last ? { lastTool: last, lastToolAt: iso } : before?.lastTool ? { lastTool: before.lastTool, ...before.lastToolAt ? { lastToolAt: before.lastToolAt } : {} } : {}
71
+ };
72
+ if (last) {
73
+ clearTimeout(timer);
74
+ write();
75
+ } else if (!timer) {
76
+ timer = setTimeout(write, WRITE_EVERY_MS);
77
+ timer.unref();
78
+ }
79
+ }, "record"),
80
+ flush: /* @__PURE__ */ __name(() => {
81
+ if (!timer)
82
+ return;
83
+ clearTimeout(timer);
84
+ write();
85
+ }, "flush")
86
+ };
87
+ }, "activityRecorder");
88
+
89
+ // node_modules/.pnpm/@wirecat+cli-core@0.691.0_@wirecat+cli-base@0.113.0_commander@15.0.0_esbuild@0.28.2_typ_9a2e508bb6f63e7e29f0d776540ec8fd/node_modules/@wirecat/cli-core/dist/mcp/http/state.js
90
+ var ACCESS_SECONDS = 60 * 60;
91
+ var REFRESH_SECONDS = 30 * 24 * 60 * 60;
92
+ var readStored = /* @__PURE__ */ __name((path) => existsSync2(path) ? JSON.parse(readFileSync2(path, "utf8")) : { clients: [], tokens: [] }, "readStored");
93
+ var mcpHttpMarker = /* @__PURE__ */ __name((envPrefix) => `${envPrefix}_MCP_HTTP`, "mcpHttpMarker");
94
+ var httpLogFile = /* @__PURE__ */ __name((tokenFile) => `${tokenFile.replace(/\.json$/, "")}.log`, "httpLogFile");
95
+ var httpLockFile = /* @__PURE__ */ __name((tokenFile) => `${tokenFile.replace(/\.json$/, "")}.lock`, "httpLockFile");
96
+ var httpLaunchFile = /* @__PURE__ */ __name((lockFile) => `${lockFile.replace(/\.lock$/, "")}.launch.json`, "httpLaunchFile");
97
+ var readHttpLaunch = /* @__PURE__ */ __name((path) => {
98
+ try {
99
+ const launch = JSON.parse(readFileSync2(path, "utf8"));
100
+ return typeof launch.invocation === "string" && Array.isArray(launch.argv) && launch.argv.every((word) => typeof word === "string") && typeof launch.env === "object" && launch.env !== null ? launch : void 0;
101
+ } catch {
102
+ return void 0;
103
+ }
104
+ }, "readHttpLaunch");
105
+ var readHttpLock = /* @__PURE__ */ __name((path) => {
106
+ const lock = readLock(path);
107
+ return lock && typeof lock.port === "number" && typeof lock.publicUrl === "string" ? lock : void 0;
108
+ }, "readHttpLock");
109
+ var httpLock = /* @__PURE__ */ __name((path, first) => {
110
+ let current = first;
111
+ const held = takeLock(path, current);
112
+ return {
113
+ held,
114
+ update: /* @__PURE__ */ __name((change) => {
115
+ current = { ...current, ...change };
116
+ holdLock(path, current);
117
+ }, "update"),
118
+ release: /* @__PURE__ */ __name(() => releaseLock(path), "release")
119
+ };
120
+ }, "httpLock");
121
+ var signedInClients = /* @__PURE__ */ __name((tokenFile, now = Date.now()) => {
122
+ const seconds = Math.floor(now / 1e3);
123
+ const { clients, tokens } = readStored(tokenFile);
124
+ const activity = readActivity(httpActivityFile(tokenFile));
125
+ const today = localDay(now);
126
+ const last = /* @__PURE__ */ new Map();
127
+ for (const token of tokens) {
128
+ if (token.expiresAt <= seconds)
129
+ continue;
130
+ const issued = token.expiresAt - (token.kind === "access" ? ACCESS_SECONDS : REFRESH_SECONDS);
131
+ last.set(token.clientId, Math.max(last.get(token.clientId) ?? 0, issued));
132
+ }
133
+ return clients.filter((client) => last.has(client.id)).map((client) => {
134
+ const did = activity[client.id];
135
+ return {
136
+ claimedName: client.name ?? null,
137
+ lastLoginAt: new Date((last.get(client.id) ?? 0) * 1e3).toISOString(),
138
+ lastRequestAt: did?.lastRequestAt ?? null,
139
+ lastTool: did?.lastTool ?? null,
140
+ lastToolAt: did?.lastToolAt ?? null,
141
+ toolCallsToday: did?.day === today ? did.toolCalls : 0
142
+ };
143
+ }).sort((a, b) => b.lastLoginAt.localeCompare(a.lastLoginAt));
144
+ }, "signedInClients");
145
+
146
+ export {
147
+ httpActivityFile,
148
+ calledTools,
149
+ activityRecorder,
150
+ ACCESS_SECONDS,
151
+ REFRESH_SECONDS,
152
+ readStored,
153
+ mcpHttpMarker,
154
+ httpLogFile,
155
+ httpLockFile,
156
+ httpLaunchFile,
157
+ readHttpLaunch,
158
+ readHttpLock,
159
+ httpLock,
160
+ signedInClients
161
+ };