@wirecat/amo-cli 0.6.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 (282) hide show
  1. package/CHANGELOG.md +17 -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-AEWYRB6F.js +8 -0
  14. package/dist/bundle/{chunk-SWCJM3YD.js → chunk-GL7CRTHR.js} +3 -3
  15. package/dist/bundle/chunk-N2UB32VN.js +76 -0
  16. package/dist/bundle/{chunk-RNWUCAJJ.js → chunk-PVVSHDMQ.js} +7 -15
  17. package/dist/bundle/program-SQH3SPOW.js +2352 -0
  18. package/dist/bundle/{instructions-4H7UREH2.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 -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,338 +0,0 @@
1
- import { createRequire as __bundleRequire } from "node:module";
2
- const require = __bundleRequire(import.meta.url);
3
- import {
4
- throughWrapper
5
- } from "./chunk-GVSKLZRD.js";
6
- import {
7
- environmentOf,
8
- readOnlyLockOf
9
- } from "./chunk-5SQTHOBI.js";
10
- import {
11
- array,
12
- boolean,
13
- check,
14
- pipe,
15
- record,
16
- safeParse,
17
- strictObject,
18
- string
19
- } from "./chunk-QFOP3KUP.js";
20
- import {
21
- CliError
22
- } from "./chunk-S6JG4YUH.js";
23
- import {
24
- __name
25
- } from "./chunk-ZVVMGPBJ.js";
26
-
27
- // node_modules/.pnpm/@wirecat+cli-core@2.0.0_@wirecat+cli-base@1.0.0_commander@15.0.0_esbuild@0.28.2_typescr_a82f624c57005d53c3f072e45c3a3a86/node_modules/@wirecat/cli-core/dist/background/relay.js
28
- import { createHash } from "node:crypto";
29
- import { chmodSync, lstatSync, mkdirSync, rmSync } from "node:fs";
30
- import { createConnection, createServer } from "node:net";
31
- import { tmpdir } from "node:os";
32
- import { dirname, isAbsolute, join } from "node:path";
33
- import { PassThrough, Writable } from "node:stream";
34
- var RELAY_PROTOCOL = 1;
35
- var requestSchema = strictObject({
36
- argv: array(string()),
37
- env: record(string(), string()),
38
- cwd: pipe(string(), check((path) => isAbsolute(path))),
39
- tty: boolean(),
40
- stdinTty: boolean()
41
- });
42
- var MAX_CLIENT_LINE = 1024 * 1024;
43
- var MAX_SERVE_LINE = 64 * 1024 * 1024;
44
- var MAX_SOCKET_PATH = 100;
45
- var relayPath = /* @__PURE__ */ __name((lockPath) => {
46
- const beside = lockPath.replace(/\.lock$/, ".sock");
47
- if (beside.length <= MAX_SOCKET_PATH)
48
- return beside;
49
- const hash = createHash("sha256").update(beside).digest("hex").slice(0, 16);
50
- const name = join(`wirecat-relay-${process.getuid?.() ?? "user"}`, `${hash}.sock`);
51
- const temporary = join(tmpdir(), name);
52
- if (temporary.length <= MAX_SOCKET_PATH || process.platform === "win32")
53
- return temporary;
54
- return join("/tmp", name);
55
- }, "relayPath");
56
- var privateDirectory = /* @__PURE__ */ __name((dir) => {
57
- mkdirSync(dir, { recursive: true, mode: 448 });
58
- const stat = lstatSync(dir);
59
- const mine = process.getuid === void 0 || stat.uid === process.getuid();
60
- if (!stat.isDirectory() || !mine || (stat.mode & 63) !== 0) {
61
- throw new CliError("permission_error", `${dir} is not a private directory, so serve does not listen there`);
62
- }
63
- }, "privateDirectory");
64
- var lines = /* @__PURE__ */ __name((socket, max, onLine, onTooLong) => {
65
- let buffered = "";
66
- socket.setEncoding("utf8");
67
- socket.on("data", (chunk) => {
68
- buffered += chunk;
69
- for (let end = buffered.indexOf("\n"); end >= 0; end = buffered.indexOf("\n")) {
70
- const line = buffered.slice(0, end);
71
- buffered = buffered.slice(end + 1);
72
- if (line)
73
- onLine(line);
74
- }
75
- if (buffered.length > max)
76
- onTooLong();
77
- });
78
- }, "lines");
79
- var frame = /* @__PURE__ */ __name((socket, value) => {
80
- if (!socket.destroyed)
81
- socket.write(`${JSON.stringify(value)}
82
- `);
83
- }, "frame");
84
- var listenRelay = /* @__PURE__ */ __name(async (path, run) => {
85
- privateDirectory(dirname(path));
86
- rmSync(path, { force: true });
87
- const open = /* @__PURE__ */ new Set();
88
- const running = /* @__PURE__ */ new Set();
89
- const server = createServer((socket) => {
90
- open.add(socket);
91
- const stop = new AbortController();
92
- const stdin = new PassThrough();
93
- let started = false;
94
- socket.on("error", () => {
95
- });
96
- socket.on("close", () => {
97
- open.delete(socket);
98
- stop.abort(new CliError("cancelled", "the client went away", { retryable: false }));
99
- if (!stdin.writableEnded)
100
- stdin.end();
101
- });
102
- lines(socket, MAX_CLIENT_LINE, (line) => {
103
- let message;
104
- try {
105
- message = JSON.parse(line);
106
- } catch {
107
- socket.destroy();
108
- return;
109
- }
110
- if (!started) {
111
- started = true;
112
- if (message.v !== RELAY_PROTOCOL) {
113
- frame(socket, { diagnostic: `serve speaks relay protocol ${RELAY_PROTOCOL}; restart it`, exit: 1 });
114
- socket.end();
115
- return;
116
- }
117
- const parsed = safeParse(requestSchema, message.run);
118
- if (!parsed.success) {
119
- socket.destroy();
120
- return;
121
- }
122
- stdin.isTTY = parsed.output.stdinTty;
123
- if (parsed.output.stdinTty)
124
- stdin.end();
125
- const job = serve(socket, parsed.output, stdin, stop.signal, run);
126
- running.add(job);
127
- void job.then(() => running.delete(job), () => running.delete(job));
128
- return;
129
- }
130
- if (typeof message.stdin === "string" && !stdin.writableEnded)
131
- stdin.write(Buffer.from(message.stdin, "base64"));
132
- if (message.stdinEnd === true && !stdin.writableEnded)
133
- stdin.end();
134
- }, () => socket.destroy());
135
- });
136
- await new Promise((resolve, reject) => {
137
- server.once("error", reject);
138
- server.listen(path, () => {
139
- server.off("error", reject);
140
- resolve();
141
- });
142
- });
143
- chmodSync(path, 384);
144
- return {
145
- close: /* @__PURE__ */ __name(async () => {
146
- for (const socket of open)
147
- socket.destroy();
148
- await new Promise((resolve) => server.close(() => resolve()));
149
- await Promise.allSettled(running);
150
- rmSync(path, { force: true });
151
- }, "close")
152
- };
153
- }, "listenRelay");
154
- var serve = /* @__PURE__ */ __name(async (socket, request, stdin, signal, run) => {
155
- const streams = {
156
- data: /* @__PURE__ */ __name((text) => frame(socket, { data: text }), "data"),
157
- diagnostic: /* @__PURE__ */ __name((text) => frame(socket, { diagnostic: text }), "diagnostic"),
158
- progress: /* @__PURE__ */ __name((text) => frame(socket, { progress: text }), "progress")
159
- };
160
- const stdout = new Writable({
161
- write: /* @__PURE__ */ __name((chunk, _encoding, done) => {
162
- frame(socket, { raw: Buffer.from(chunk).toString("base64") });
163
- done();
164
- }, "write")
165
- });
166
- let code = 1;
167
- try {
168
- code = await run(request, { streams, stdin, stdout, signal });
169
- } finally {
170
- frame(socket, { exit: code });
171
- socket.end();
172
- }
173
- }, "serve");
174
- var relayCommand = /* @__PURE__ */ __name((path, request, options) => new Promise((resolve, reject) => {
175
- const { streams, stdin, stdout, signal, deadlineMs, writes, holder, listens = false } = options;
176
- const socket = createConnection(path);
177
- let connected = false;
178
- let settled = false;
179
- let timer;
180
- const forward = /* @__PURE__ */ __name((chunk) => frame(socket, { stdin: Buffer.from(chunk).toString("base64") }), "forward");
181
- const ended = /* @__PURE__ */ __name(() => frame(socket, { stdinEnd: true }), "ended");
182
- const brokenPipe = /* @__PURE__ */ __name((error) => {
183
- if (error.code === "EPIPE")
184
- finish({ code: 0 });
185
- }, "brokenPipe");
186
- const finish = /* @__PURE__ */ __name((outcome) => {
187
- if (settled)
188
- return;
189
- settled = true;
190
- if (timer)
191
- clearTimeout(timer);
192
- stdout.off("error", brokenPipe);
193
- signal.removeEventListener("abort", aborted);
194
- stdin.off("data", forward).off("end", ended);
195
- stdin.pause();
196
- socket.destroy();
197
- if ("code" in outcome)
198
- resolve(outcome.code);
199
- else
200
- reject(outcome.error);
201
- }, "finish");
202
- const stopped = /* @__PURE__ */ __name(() => writes ? new CliError("outcome_unknown", `${holder} stopped before the command finished; it may have run \u2014 check before repeating it`, { retryable: false }) : new CliError("provider_unavailable", `${holder} stopped before the command finished`, { retryable: true }), "stopped");
203
- const aborted = /* @__PURE__ */ __name(() => finish(listens ? { code: 0 } : { error: signal.reason }), "aborted");
204
- if (signal.aborted)
205
- return aborted();
206
- signal.addEventListener("abort", aborted, { once: true });
207
- stdout.on("error", brokenPipe);
208
- if (deadlineMs !== void 0)
209
- timer = setTimeout(() => finish({ error: stopped() }), deadlineMs);
210
- socket.on("connect", () => {
211
- connected = true;
212
- frame(socket, { v: RELAY_PROTOCOL, run: request });
213
- if (request.stdinTty)
214
- ended();
215
- else {
216
- stdin.on("data", forward).once("end", ended);
217
- stdin.resume();
218
- }
219
- });
220
- socket.on("error", (error) => {
221
- if (connected)
222
- return finish({ error: stopped() });
223
- finish({
224
- error: new CliError("provider_unavailable", `${holder} holds the connection but does not answer its relay (${error.code ?? error.message}) \u2014 restart it`, { retryable: false, sent: false })
225
- });
226
- });
227
- socket.on("close", () => finish({ error: stopped() }));
228
- lines(socket, MAX_SERVE_LINE, (line) => {
229
- let message;
230
- try {
231
- message = JSON.parse(line);
232
- } catch {
233
- return finish({ error: stopped() });
234
- }
235
- if (typeof message.data === "string")
236
- streams.data(message.data);
237
- if (typeof message.diagnostic === "string")
238
- streams.diagnostic(message.diagnostic);
239
- if (typeof message.progress === "string")
240
- streams.progress?.(message.progress);
241
- if (typeof message.raw === "string")
242
- stdout.write(Buffer.from(message.raw, "base64"));
243
- if (typeof message.exit === "number")
244
- finish({ code: message.exit });
245
- }, () => finish({ error: stopped() }));
246
- }), "relayCommand");
247
-
248
- // node_modules/.pnpm/@wirecat+cli-core@2.0.0_@wirecat+cli-base@1.0.0_commander@15.0.0_esbuild@0.28.2_typescr_a82f624c57005d53c3f072e45c3a3a86/node_modules/@wirecat/cli-core/dist/cli/messenger/serve-relay.js
249
- var lentConnection = /* @__PURE__ */ __name((connection, watchers) => throughWrapper(connection, {
250
- close: /* @__PURE__ */ __name(async () => {
251
- }, "close"),
252
- feed: void 0,
253
- storedChats: void 0,
254
- listen: void 0,
255
- listenHistory: void 0,
256
- ...connection.watch && watchers ? {
257
- // A watcher that throws (its output limit, a closed reader) ends its own watch, never serve's.
258
- watch: /* @__PURE__ */ __name(async (onEvent, signal, onReady) => {
259
- let watcher;
260
- try {
261
- await new Promise((resolve, reject) => {
262
- watcher = /* @__PURE__ */ __name((event) => {
263
- try {
264
- onEvent(event);
265
- } catch (error) {
266
- reject(error);
267
- }
268
- }, "watcher");
269
- watchers.add(watcher);
270
- signal.addEventListener("abort", () => resolve(), { once: true });
271
- onReady?.();
272
- if (signal.aborted)
273
- resolve();
274
- });
275
- } finally {
276
- if (watcher)
277
- watchers.delete(watcher);
278
- }
279
- }, "watch")
280
- } : { watch: void 0 }
281
- }), "lentConnection");
282
- var serveRelay = /* @__PURE__ */ __name((command, messenger) => {
283
- let held;
284
- let relay;
285
- const watchers = /* @__PURE__ */ new Set();
286
- const borrowed = /* @__PURE__ */ __name(() => {
287
- const connection = held;
288
- if (!connection)
289
- throw new CliError("provider_unavailable", "serve is not connected yet", { retryable: true });
290
- return lentConnection(connection, watchers);
291
- }, "borrowed");
292
- return {
293
- messenger: {
294
- ...messenger,
295
- connect: /* @__PURE__ */ __name(async (...args) => {
296
- held = await messenger.connect(...args);
297
- return held;
298
- }, "connect")
299
- },
300
- arrived: /* @__PURE__ */ __name((event) => {
301
- for (const watcher of watchers)
302
- watcher(event);
303
- }, "arrived"),
304
- /** Listens beside the lock; the address goes into it, which is how a client finds it. */
305
- open: /* @__PURE__ */ __name(async (lockPath, profile) => {
306
- const environment = environmentOf(command);
307
- const runCommand = environment.runCommand;
308
- if (!runCommand)
309
- return void 0;
310
- const readOnly = readOnlyLockOf(messenger.app, environment.env ?? process.env);
311
- const path = relayPath(lockPath);
312
- relay = await listenRelay(path, (request, io) => runCommand(request.argv, {
313
- env: {
314
- ...request.env,
315
- ...readOnly ? { [`${messenger.app.envPrefix}_READ_ONLY`]: "1" } : {}
316
- },
317
- streams: io.streams,
318
- stdin: io.stdin,
319
- stdout: io.stdout,
320
- tty: request.tty,
321
- signal: io.signal,
322
- answer: /* @__PURE__ */ __name(() => null, "answer"),
323
- relayed: { profile, cwd: request.cwd, connection: borrowed }
324
- }));
325
- return { path, protocol: RELAY_PROTOCOL };
326
- }, "open"),
327
- close: /* @__PURE__ */ __name(async () => {
328
- await relay?.close();
329
- }, "close")
330
- };
331
- }, "serveRelay");
332
-
333
- export {
334
- RELAY_PROTOCOL,
335
- relayCommand,
336
- lentConnection,
337
- serveRelay
338
- };
@@ -1,288 +0,0 @@
1
- import { createRequire as __bundleRequire } from "node:module";
2
- const require = __bundleRequire(import.meta.url);
3
- import {
4
- OAuthError,
5
- OAuthErrorCode
6
- } from "./chunk-PL5P7UKW.js";
7
- import {
8
- ACCESS_SECONDS,
9
- REFRESH_SECONDS,
10
- readStored
11
- } from "./chunk-OGJFDKDL.js";
12
- import {
13
- __name
14
- } from "./chunk-ZVVMGPBJ.js";
15
-
16
- // node_modules/.pnpm/@wirecat+cli-core@2.0.0_@wirecat+cli-base@1.0.0_commander@15.0.0_esbuild@0.28.2_typescr_a82f624c57005d53c3f072e45c3a3a86/node_modules/@wirecat/cli-core/dist/mcp/http/oauth.js
17
- import { createHash, randomBytes, randomInt, timingSafeEqual } from "node:crypto";
18
- import { chmodSync, mkdirSync, renameSync, rmSync, writeFileSync } from "node:fs";
19
- import { dirname } from "node:path";
20
- var AUTH_CODE_MS = 60 * 1e3;
21
- var LOGIN_CODE_MS = 10 * 60 * 1e3;
22
- var WRONG_TRIES = 5;
23
- var WRONG_CODE_WAIT_MS = 3e4;
24
- var MAX_CLIENTS = 10;
25
- var CODE_ALPHABET = "ABCDEFGHJKLMNPQRSTUVWXYZ23456789";
26
- var hash = /* @__PURE__ */ __name((value) => createHash("sha256").update(value).digest("base64url"), "hash");
27
- var secret = /* @__PURE__ */ __name(() => randomBytes(32).toString("base64url"), "secret");
28
- var same = /* @__PURE__ */ __name((given, expected) => {
29
- const left = Buffer.from(given);
30
- const right = Buffer.from(expected);
31
- return left.byteLength === right.byteLength && timingSafeEqual(left, right);
32
- }, "same");
33
- var tokenFile = /* @__PURE__ */ __name((path) => ({
34
- read: /* @__PURE__ */ __name(() => readStored(path), "read"),
35
- write: /* @__PURE__ */ __name((stored) => {
36
- mkdirSync(dirname(path), { recursive: true, mode: 448 });
37
- const temporary = `${path}.${randomBytes(16).toString("hex")}.tmp`;
38
- writeFileSync(temporary, JSON.stringify(stored), { mode: 384, flag: "wx" });
39
- chmodSync(temporary, 384);
40
- renameSync(temporary, path);
41
- }, "write")
42
- }), "tokenFile");
43
- var revokeAll = /* @__PURE__ */ __name((path) => rmSync(path, { force: true }), "revokeAll");
44
- var json = /* @__PURE__ */ __name((body, status = 200) => new Response(JSON.stringify(body), {
45
- status,
46
- headers: { "content-type": "application/json", "cache-control": "no-store" }
47
- }), "json");
48
- var oauthError = /* @__PURE__ */ __name((error, description, status = 400) => json({ error, error_description: description }, status), "oauthError");
49
- var escapeHtml = /* @__PURE__ */ __name((value) => value.replace(/[&<>"']/g, (character) => `&#${character.charCodeAt(0)};`), "escapeHtml");
50
- var redirectAllowed = /* @__PURE__ */ __name((uri) => {
51
- try {
52
- const url = new URL(uri);
53
- if (url.hash)
54
- return false;
55
- return url.protocol === "https:" || url.protocol === "http:" && ["localhost", "127.0.0.1"].includes(url.hostname);
56
- } catch {
57
- return false;
58
- }
59
- }, "redirectAllowed");
60
- var ownerLogin = /* @__PURE__ */ __name(({ issuer, resource, file, appName, reaches = `your ${appName} data`, onCode, now = /* @__PURE__ */ __name(() => Date.now(), "now") }) => {
61
- const store = tokenFile(file);
62
- const codes = /* @__PURE__ */ new Map();
63
- let login = { value: "", expires: 0 };
64
- let wrong = 0;
65
- let retryAt = 0;
66
- let renewal;
67
- const freshCode = /* @__PURE__ */ __name(() => {
68
- const part = /* @__PURE__ */ __name(() => Array.from({ length: 4 }, () => CODE_ALPHABET[randomInt(CODE_ALPHABET.length)]).join(""), "part");
69
- login = { value: `${part()}-${part()}`, expires: now() + LOGIN_CODE_MS };
70
- clearTimeout(renewal);
71
- renewal = setTimeout(freshCode, LOGIN_CODE_MS);
72
- renewal.unref();
73
- onCode(login.value, new Date(login.expires));
74
- }, "freshCode");
75
- freshCode();
76
- const base = issuer.pathname.replace(/\/+$/, "");
77
- const endpoint = /* @__PURE__ */ __name((path) => new URL(`${base}${path}`, issuer.origin).href, "endpoint");
78
- const metadata = {
79
- issuer: issuer.href,
80
- authorization_endpoint: endpoint("/authorize"),
81
- token_endpoint: endpoint("/token"),
82
- registration_endpoint: endpoint("/register"),
83
- response_types_supported: ["code"],
84
- grant_types_supported: ["authorization_code", "refresh_token"],
85
- code_challenge_methods_supported: ["S256"],
86
- token_endpoint_auth_methods_supported: ["none", "client_secret_post", "client_secret_basic"]
87
- };
88
- const issue = /* @__PURE__ */ __name((stored, clientId) => {
89
- const access = secret();
90
- const refresh = secret();
91
- const seconds = Math.floor(now() / 1e3);
92
- stored.tokens = stored.tokens.filter((one) => one.expiresAt > seconds);
93
- stored.tokens.push({ hash: hash(access), kind: "access", clientId, expiresAt: seconds + ACCESS_SECONDS }, { hash: hash(refresh), kind: "refresh", clientId, expiresAt: seconds + REFRESH_SECONDS });
94
- store.write(stored);
95
- return json({ access_token: access, token_type: "Bearer", expires_in: ACCESS_SECONDS, refresh_token: refresh });
96
- }, "issue");
97
- const clientOf = /* @__PURE__ */ __name((stored, request, form) => {
98
- let id = form.get("client_id") ?? "";
99
- let given = form.get("client_secret") ?? void 0;
100
- const basic = request.headers.get("authorization");
101
- if (basic?.startsWith("Basic ")) {
102
- const [user = "", password = ""] = Buffer.from(basic.slice(6), "base64").toString().split(":");
103
- id = decodeURIComponent(user);
104
- given = decodeURIComponent(password);
105
- }
106
- const client = stored.clients.find((one) => one.id === id);
107
- if (!client)
108
- return void 0;
109
- if (client.authMethod === "none")
110
- return client;
111
- return given !== void 0 && client.secretHash && same(hash(given), client.secretHash) ? client : void 0;
112
- }, "clientOf");
113
- const register = /* @__PURE__ */ __name(async (request) => {
114
- const body = await request.json().catch(() => null);
115
- const uris = Array.isArray(body?.redirect_uris) ? body.redirect_uris.filter((one) => typeof one === "string") : [];
116
- if (uris.length === 0 || !uris.every(redirectAllowed))
117
- return oauthError("invalid_redirect_uri", "redirect_uris must be https URLs");
118
- const requested = body?.token_endpoint_auth_method;
119
- const authMethod = requested === "client_secret_post" || requested === "client_secret_basic" ? requested : "none";
120
- const clientSecret = authMethod === "none" ? void 0 : secret();
121
- const name = typeof body?.client_name === "string" ? body.client_name.slice(0, 100) : void 0;
122
- const client = {
123
- id: secret(),
124
- redirectUris: uris,
125
- authMethod,
126
- issuedAt: Math.floor(now() / 1e3),
127
- ...name ? { name } : {},
128
- ...clientSecret ? { secretHash: hash(clientSecret) } : {}
129
- };
130
- const stored = store.read();
131
- const seconds = Math.floor(now() / 1e3);
132
- const holding = new Set(stored.tokens.filter((one) => one.expiresAt > seconds).map((one) => one.clientId));
133
- stored.clients.push(client);
134
- while (stored.clients.length > MAX_CLIENTS) {
135
- const idle = stored.clients.findIndex((one) => !holding.has(one.id));
136
- if (idle === -1)
137
- return oauthError("invalid_client_metadata", "too many logged-in apps \u2014 run mcp revoke first");
138
- stored.clients.splice(idle, 1);
139
- }
140
- store.write(stored);
141
- return json({
142
- client_id: client.id,
143
- client_id_issued_at: client.issuedAt,
144
- redirect_uris: uris,
145
- token_endpoint_auth_method: authMethod,
146
- grant_types: ["authorization_code", "refresh_token"],
147
- response_types: ["code"],
148
- ...name ? { client_name: name } : {},
149
- ...clientSecret ? { client_secret: clientSecret, client_secret_expires_at: 0 } : {}
150
- }, 201);
151
- }, "register");
152
- const page = /* @__PURE__ */ __name((params, client, message) => {
153
- const hidden = ["response_type", "client_id", "redirect_uri", "code_challenge", "code_challenge_method", "state"].map((name) => `<input type="hidden" name="${name}" value="${escapeHtml(params.get(name) ?? "")}">`).join("");
154
- const who = escapeHtml(client.name ?? "an application");
155
- const target = new URL(params.get("redirect_uri") ?? "");
156
- const html = `<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>${escapeHtml(appName)} login</title><style>body{font:16px system-ui,sans-serif;max-width:28rem;margin:3rem auto;padding:0 1rem;color:#1d2430}input[type=text]{font:20px ui-monospace,monospace;letter-spacing:.1em;width:100%;padding:.5rem;margin:.5rem 0 1rem;box-sizing:border-box}button{font:inherit;padding:.5rem 1rem}.error{color:#b42318}</style></head><body><h1>${escapeHtml(appName)}</h1><p>An app that calls itself <strong>${who}</strong> asks to reach ${escapeHtml(reaches)} through <code>${escapeHtml(appName)} mcp serve --http</code>.</p><p>After you allow it, the login goes to <strong>${escapeHtml(target.host)}</strong>. Allow only if that is the app you are connecting, such as chatgpt.com or claude.ai.</p><p>Type the code shown in WireCat Desktop, or in the terminal where the server runs. If you did not start this login, close this page.</p>${message ? `<p class="error">${escapeHtml(message)}</p>` : ""}<form method="post" action="${escapeHtml(`${base}/authorize`)}">${hidden}<label>Login code<input type="text" name="login_code" autocomplete="off" autofocus required></label><button type="submit">Allow</button></form></body></html>`;
157
- return new Response(html, {
158
- status: message ? 400 : 200,
159
- headers: {
160
- "content-type": "text/html; charset=utf-8",
161
- "cache-control": "no-store",
162
- "x-frame-options": "DENY",
163
- "content-security-policy": `default-src 'none'; style-src 'unsafe-inline'; form-action 'self' ${target.origin}; frame-ancestors 'none'`,
164
- // no-referrer makes the browser post this form with `Origin: null`, which the Origin check refuses.
165
- "referrer-policy": "same-origin"
166
- }
167
- });
168
- }, "page");
169
- const authorize = /* @__PURE__ */ __name(async (request) => {
170
- const params = request.method === "POST" ? new URLSearchParams(await request.text()) : new URL(request.url).searchParams;
171
- const stored = store.read();
172
- const client = stored.clients.find((one) => one.id === params.get("client_id"));
173
- const redirectUri = params.get("redirect_uri") ?? "";
174
- if (!client?.redirectUris.includes(redirectUri))
175
- return new Response("Unknown client or redirect address.", { status: 400 });
176
- if (params.get("response_type") !== "code" || params.get("code_challenge_method") !== "S256" || !params.get("code_challenge"))
177
- return new Response("This server needs response_type=code and PKCE with S256.", { status: 400 });
178
- if (request.method !== "POST")
179
- return page(params, client);
180
- const throttled = /* @__PURE__ */ __name(() => new Response("Too many wrong codes. Wait, then try the new code.", {
181
- status: 429,
182
- headers: { "retry-after": String(Math.ceil((retryAt - now()) / 1e3)) }
183
- }), "throttled");
184
- if (wrong >= WRONG_TRIES) {
185
- if (now() < retryAt)
186
- return throttled();
187
- wrong = 0;
188
- freshCode();
189
- }
190
- const typed = (params.get("login_code") ?? "").trim().toUpperCase();
191
- if (login.expires < now()) {
192
- freshCode();
193
- return page(params, client, "The code expired. A new one is shown in WireCat Desktop and in the terminal.");
194
- }
195
- if (!same(typed, login.value)) {
196
- wrong += 1;
197
- if (wrong >= WRONG_TRIES) {
198
- retryAt = now() + WRONG_CODE_WAIT_MS;
199
- return throttled();
200
- }
201
- return page(params, client, `Wrong code. Each code works for one login: after an app logs in, a new one appears in WireCat Desktop and in "${appName} mcp server status". ${WRONG_TRIES - wrong} tries left.`);
202
- }
203
- wrong = 0;
204
- freshCode();
205
- const code = secret();
206
- codes.set(hash(code), {
207
- clientId: client.id,
208
- redirectUri,
209
- challenge: params.get("code_challenge") ?? "",
210
- expires: now() + AUTH_CODE_MS
211
- });
212
- const target = new URL(redirectUri);
213
- target.searchParams.set("code", code);
214
- const state = params.get("state");
215
- if (state)
216
- target.searchParams.set("state", state);
217
- target.searchParams.set("iss", issuer.href);
218
- return new Response(null, { status: 302, headers: { location: target.href, "cache-control": "no-store" } });
219
- }, "authorize");
220
- const token = /* @__PURE__ */ __name(async (request) => {
221
- const form = new URLSearchParams(await request.text());
222
- const stored = store.read();
223
- const client = clientOf(stored, request, form);
224
- if (!client)
225
- return oauthError("invalid_client", "unknown client or wrong secret", 401);
226
- const requestedResource = form.get("resource");
227
- if (requestedResource && requestedResource !== resource.href)
228
- return oauthError("invalid_target", "this server issues tokens only for its own MCP endpoint");
229
- if (form.get("grant_type") === "authorization_code") {
230
- const key = hash(form.get("code") ?? "");
231
- const entry = codes.get(key);
232
- codes.delete(key);
233
- const verifier2 = form.get("code_verifier") ?? "";
234
- const challenge = createHash("sha256").update(verifier2).digest("base64url");
235
- if (!entry || entry.expires < now() || entry.clientId !== client.id || entry.redirectUri !== form.get("redirect_uri") || !same(challenge, entry.challenge))
236
- return oauthError("invalid_grant", "the code is wrong, used or expired");
237
- return issue(stored, client.id);
238
- }
239
- if (form.get("grant_type") === "refresh_token") {
240
- const key = hash(form.get("refresh_token") ?? "");
241
- const seconds = Math.floor(now() / 1e3);
242
- const found = stored.tokens.find((one) => one.kind === "refresh" && one.hash === key);
243
- if (!found || found.clientId !== client.id || found.expiresAt <= seconds)
244
- return oauthError("invalid_grant", "the refresh token is wrong, used or expired");
245
- stored.tokens = stored.tokens.filter((one) => one !== found);
246
- return issue(stored, client.id);
247
- }
248
- return oauthError("unsupported_grant_type", "use authorization_code or refresh_token");
249
- }, "token");
250
- const verifier = {
251
- verifyAccessToken: /* @__PURE__ */ __name(async (presented) => {
252
- const seconds = Math.floor(now() / 1e3);
253
- const stored = store.read();
254
- const found = stored.tokens.find((one) => one.kind === "access" && one.hash === hash(presented));
255
- if (!found || found.expiresAt <= seconds)
256
- throw new OAuthError(OAuthErrorCode.InvalidToken, "the token is unknown or expired");
257
- const clientName = stored.clients.find((one) => one.id === found.clientId)?.name;
258
- return {
259
- token: presented,
260
- clientId: found.clientId,
261
- scopes: [],
262
- expiresAt: found.expiresAt,
263
- resource,
264
- ...clientName ? { extra: { clientName } } : {}
265
- };
266
- }, "verifyAccessToken")
267
- };
268
- return {
269
- code: /* @__PURE__ */ __name(() => login.value, "code"),
270
- close: /* @__PURE__ */ __name(() => clearTimeout(renewal), "close"),
271
- metadata,
272
- verifier,
273
- handle: /* @__PURE__ */ __name(async (request, path = new URL(request.url).pathname) => {
274
- if (path === `${base}/register` && request.method === "POST")
275
- return register(request);
276
- if (path === `${base}/authorize` && (request.method === "GET" || request.method === "POST"))
277
- return authorize(request);
278
- if (path === `${base}/token` && request.method === "POST")
279
- return token(request);
280
- return void 0;
281
- }, "handle")
282
- };
283
- }, "ownerLogin");
284
-
285
- export {
286
- revokeAll,
287
- ownerLogin
288
- };