@wirecat/amo-cli 0.2.0 → 0.4.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 (183) hide show
  1. package/CHANGELOG.md +47 -0
  2. package/README.md +19 -14
  3. package/contracts/wirecat.json +58 -19
  4. package/dist/amo/button.d.ts +53 -0
  5. package/dist/amo/button.d.ts.map +1 -0
  6. package/dist/amo/button.js +234 -0
  7. package/dist/amo/button.js.map +1 -0
  8. package/dist/amo/oauth.d.ts +12 -3
  9. package/dist/amo/oauth.d.ts.map +1 -1
  10. package/dist/amo/oauth.js +19 -6
  11. package/dist/amo/oauth.js.map +1 -1
  12. package/dist/bin/amo.js +2 -2
  13. package/dist/bundle/agent-43BMVBX2.js +40 -0
  14. package/dist/bundle/{all-profiles-3KQVWDV4.js → all-profiles-PRNXEZRH.js} +63 -21
  15. package/dist/bundle/amo.js +28 -26
  16. package/dist/bundle/{anthropic-N5NOX7K7.js → anthropic-FDI24DU2.js} +5 -5
  17. package/dist/bundle/{app-server-2MST5EZ5.js → app-server-WAKJVDLN.js} +79 -68
  18. package/dist/bundle/{bun-4NHWOFX2.js → bun-YPXUXMBI.js} +2 -2
  19. package/dist/bundle/{bun-sqlite-DRSXPWPR.js → bun-sqlite-UBQ5M47X.js} +6 -6
  20. package/dist/bundle/chunk-23AQD7JU.js +559 -0
  21. package/dist/bundle/{chunk-2I5UVMLW.js → chunk-2AIG2SSJ.js} +1733 -1160
  22. package/dist/bundle/{chunk-DQV2IKCF.js → chunk-2UJ7ZZZC.js} +10 -3
  23. package/dist/bundle/{chunk-ODNQU7DH.js → chunk-3K6T2G52.js} +43 -64
  24. package/dist/bundle/chunk-3PCVQCCV.js +108 -0
  25. package/dist/bundle/{chunk-UMVRT7VQ.js → chunk-3WG4MTQI.js} +1 -1
  26. package/dist/bundle/chunk-4PQECIU2.js +30 -0
  27. package/dist/bundle/{chunk-T2UDLX76.js → chunk-5HZMXHRH.js} +6 -6
  28. package/dist/bundle/{chunk-P3WQRTYZ.js → chunk-5II6TAJE.js} +1 -1
  29. package/dist/bundle/{chunk-RPWAJYI6.js → chunk-5SJEJYQZ.js} +3 -3
  30. package/dist/bundle/{chunk-5QFHNBGB.js → chunk-6PILR4AX.js} +2 -2
  31. package/dist/bundle/{chunk-TNUFLULO.js → chunk-6QMSKJB4.js} +8 -8
  32. package/dist/bundle/{chunk-5RLUHTK6.js → chunk-745FMNI5.js} +1 -1
  33. package/dist/bundle/{chunk-AUBB72VF.js → chunk-7OVTUADG.js} +41 -10
  34. package/dist/bundle/{chunk-7U5HJEPZ.js → chunk-A4W7J6VN.js} +34 -22
  35. package/dist/bundle/chunk-ABMPZL2P.js +734 -0
  36. package/dist/bundle/{chunk-EROSAUNP.js → chunk-AN6IJYH3.js} +5 -5
  37. package/dist/bundle/{chunk-SZ2V62HB.js → chunk-AP3CWDRK.js} +2 -2
  38. package/dist/bundle/{chunk-ESZSMZKT.js → chunk-ASU63X5C.js} +2 -2
  39. package/dist/bundle/{chunk-EPOV5UIO.js → chunk-BCIZAUDV.js} +11 -11
  40. package/dist/bundle/{chunk-7PKFYX7V.js → chunk-CEBX63XY.js} +8 -8
  41. package/dist/bundle/{chunk-7GTUZY7M.js → chunk-CYHIM5SL.js} +3 -3
  42. package/dist/bundle/chunk-DWA5TZMP.js +209 -0
  43. package/dist/bundle/{chunk-LDEBZ3IX.js → chunk-DWD3KDJA.js} +1 -1
  44. package/dist/bundle/{chunk-GQ7VFIYM.js → chunk-E3EWS6DF.js} +23 -7
  45. package/dist/bundle/{chunk-NJYAL3UW.js → chunk-EAX5RO7S.js} +1 -1
  46. package/dist/bundle/{chunk-LJQUYECN.js → chunk-EBNCUQLV.js} +1 -1
  47. package/dist/bundle/{chunk-UBRREVLJ.js → chunk-ELAKOEIO.js} +2 -2
  48. package/dist/bundle/{chunk-DAY6TSPF.js → chunk-FEUNZG7U.js} +62 -50
  49. package/dist/bundle/{chunk-63F65DHU.js → chunk-FQRP6JWX.js} +2 -2
  50. package/dist/bundle/{chunk-SMSTGO2G.js → chunk-G3LAYJJJ.js} +4 -4
  51. package/dist/bundle/{chunk-LGQXGOPJ.js → chunk-GBQ76X6T.js} +2 -2
  52. package/dist/bundle/{chunk-CHUKWON6.js → chunk-GJBOZAUD.js} +3 -3
  53. package/dist/bundle/{chunk-A33TIM5D.js → chunk-GMHRPX5M.js} +225 -225
  54. package/dist/bundle/{chunk-O2UCU52O.js → chunk-GQKEMBM6.js} +171 -569
  55. package/dist/bundle/{chunk-EQUKVVHX.js → chunk-HDZNSOV5.js} +7 -7
  56. package/dist/bundle/{chunk-ZM7I52EP.js → chunk-HZZ56JO7.js} +3 -4
  57. package/dist/bundle/{chunk-XQL7FEF4.js → chunk-IBEHYGG6.js} +9 -9
  58. package/dist/bundle/{chunk-U7RLVJ34.js → chunk-IPNIF5JE.js} +4 -4
  59. package/dist/bundle/{chunk-QDMXZZG4.js → chunk-KBAOJISR.js} +18 -8
  60. package/dist/bundle/{chunk-ADEWU4P4.js → chunk-KORZEYZN.js} +1 -1
  61. package/dist/bundle/{chunk-JMDLPBXK.js → chunk-KQZTX4LM.js} +17 -17
  62. package/dist/bundle/{chunk-NHXJYS4R.js → chunk-KRD375P7.js} +32 -28
  63. package/dist/bundle/{chunk-ULXQ5MJM.js → chunk-LAR2DLTI.js} +4 -4
  64. package/dist/bundle/{chunk-NC76INB2.js → chunk-LZ4IWN43.js} +3088 -2266
  65. package/dist/bundle/{chunk-BVMNXI53.js → chunk-M33XHJTM.js} +25 -25
  66. package/dist/bundle/{chunk-WCYCUTSK.js → chunk-M54YKD3I.js} +7 -7
  67. package/dist/bundle/{chunk-LSND5QYI.js → chunk-MW7HUD6R.js} +9 -9
  68. package/dist/bundle/{chunk-AHJ4W2IL.js → chunk-NFWD4QX3.js} +2 -2
  69. package/dist/bundle/{chunk-PM77PRB6.js → chunk-NKYWQTS2.js} +189 -163
  70. package/dist/bundle/{chunk-LRBPT7LQ.js → chunk-NXNUCGGO.js} +6 -6
  71. package/dist/bundle/{chunk-5D4Z2B5B.js → chunk-O3WE5IGP.js} +9 -9
  72. package/dist/bundle/chunk-OYMHPQF7.js +52 -0
  73. package/dist/bundle/{chunk-VVHRQ46X.js → chunk-PIOR6PIO.js} +2 -2
  74. package/dist/bundle/{chunk-5D4AEUVA.js → chunk-PL5P7UKW.js} +434 -1
  75. package/dist/bundle/{chunk-XEFAMLSD.js → chunk-PL7TNKAY.js} +3 -3
  76. package/dist/bundle/chunk-PLU2IQXC.js +80 -0
  77. package/dist/bundle/{chunk-73CXFE36.js → chunk-QGFURWEP.js} +29 -1
  78. package/dist/bundle/{chunk-CDY2NJFE.js → chunk-RQPB2BSH.js} +2 -2
  79. package/dist/bundle/{chunk-QRQYUHCZ.js → chunk-S6DTLAOB.js} +12 -12
  80. package/dist/bundle/{chunk-DJD7TBYG.js → chunk-SCMB4LI6.js} +76 -74
  81. package/dist/bundle/{chunk-TGEQNS6G.js → chunk-SFZVMKB6.js} +1 -1
  82. package/dist/bundle/{chunk-PFO76YFP.js → chunk-SHOSFYI7.js} +18 -18
  83. package/dist/bundle/{chunk-5SBLU7D7.js → chunk-SMM7GS4Q.js} +1 -1
  84. package/dist/bundle/{chunk-EQ7A6NA6.js → chunk-SNBYFQHT.js} +1 -1
  85. package/dist/bundle/{chunk-GNTJMB6X.js → chunk-SZX7EPPY.js} +4 -4
  86. package/dist/bundle/{chunk-VX37MPTJ.js → chunk-TCSVW7BA.js} +1 -1
  87. package/dist/bundle/{chunk-P5LYZRKW.js → chunk-TEGQVVCZ.js} +1992 -885
  88. package/dist/bundle/{chunk-Q2VNBY4Y.js → chunk-TIR3AB35.js} +758 -1205
  89. package/dist/bundle/{chunk-5HGGG3QO.js → chunk-U46RNOEQ.js} +16 -3
  90. package/dist/bundle/{chunk-Y37A3232.js → chunk-UCM7C773.js} +130 -8
  91. package/dist/bundle/{chunk-L6AFE73L.js → chunk-UEN5NWNW.js} +1 -1
  92. package/dist/bundle/{chunk-6RS7OYTD.js → chunk-V2QWX6B3.js} +3 -3
  93. package/dist/bundle/{chunk-3IRJDH2U.js → chunk-V5SETIQK.js} +2 -100
  94. package/dist/bundle/{chunk-JR6TSMFX.js → chunk-VEFAYLKX.js} +103 -70
  95. package/dist/bundle/{chunk-CUZRHF34.js → chunk-VG26HDKH.js} +4 -4
  96. package/dist/bundle/{chunk-4ZAK773N.js → chunk-VG2ERHFJ.js} +3 -3
  97. package/dist/bundle/{chunk-CHH42KI4.js → chunk-WAFB3IWJ.js} +8 -8
  98. package/dist/bundle/{chunk-5Z5PEEKP.js → chunk-WASBOYI2.js} +4 -4
  99. package/dist/bundle/{chunk-DXGGCGRP.js → chunk-WEWJA42Q.js} +14 -14
  100. package/dist/bundle/chunk-WR2FPZTE.js +353 -0
  101. package/dist/bundle/chunk-XEYT2EQT.js +338 -0
  102. package/dist/bundle/{chunk-DOSJONCX.js → chunk-YFRTEJ6V.js} +7 -7
  103. package/dist/bundle/{chunk-XRTD2GCU.js → chunk-YHVHDRED.js} +19 -258
  104. package/dist/bundle/{chunk-JH3UOHRE.js → chunk-YREKMP24.js} +4 -4
  105. package/dist/bundle/{chunk-V77XNPXG.js → chunk-Z2B3VNRI.js} +11 -11
  106. package/dist/bundle/{chunk-FKR3M62D.js → chunk-ZJC2XJQC.js} +13 -13
  107. package/dist/bundle/{chunk-5E5R65CA.js → chunk-ZKRWNL4T.js} +2 -2
  108. package/dist/bundle/{cli-QVWTXADI.js → cli-QDPKC2HJ.js} +150 -103
  109. package/dist/bundle/command-contract-KWNCP3MQ.js +39 -0
  110. package/dist/bundle/{command-server-entry-5VL5U5EE.js → command-server-entry-TX7WNN7G.js} +28 -28
  111. package/dist/bundle/{decode-SQ5WGNDX.js → decode-BLPC7OYE.js} +5 -5
  112. package/dist/bundle/{dispatch-LA4DFXJD.js → dispatch-5JUT55CS.js} +8 -8
  113. package/dist/bundle/dist-PAKDDIBT.js +191 -0
  114. package/dist/bundle/{echarts-25Z3RINX.js → echarts-54D3FOCL.js} +2 -2
  115. package/dist/bundle/{embed-BNOTNXMA.js → embed-O7KMDYM7.js} +6 -6
  116. package/dist/bundle/{embedder-BCUT7KKV.js → embedder-4PE67CLX.js} +9 -9
  117. package/dist/bundle/{failure-PKAC6XCT.js → failure-NNQYTB3Z.js} +2 -2
  118. package/dist/bundle/{first-run-EO5K5GME.js → first-run-EAU5SHBI.js} +12 -12
  119. package/dist/bundle/first-screen-APSNGZYZ.js +39 -0
  120. package/dist/bundle/{instructions-VLM3QAYB.js → instructions-ONXP5DZQ.js} +1 -1
  121. package/dist/bundle/{mcp-7ILNMJH5.js → mcp-ZNULRPZ4.js} +2 -2
  122. package/dist/bundle/meeting-combined-W2XIYXFU.js +24 -0
  123. package/dist/bundle/{meeting-model-GHMMUQ34.js → meeting-model-FWIZRKVN.js} +11 -11
  124. package/dist/bundle/{meeting-semantic-BMP6323L.js → meeting-semantic-M4YVJ57W.js} +6 -6
  125. package/dist/bundle/{node-CT3N3TNL.js → node-UTQCYQF5.js} +2 -2
  126. package/dist/bundle/{node-sqlite-MELD2SBX.js → node-sqlite-APJG6MGL.js} +7 -7
  127. package/dist/bundle/{oauth-YBH5OKC2.js → oauth-TY7RMIBL.js} +8 -8
  128. package/dist/bundle/{open-WNSBWTAG.js → open-WDVEQL75.js} +5 -5
  129. package/dist/bundle/{openai-XSNMNLW6.js → openai-H5UJHSEZ.js} +15 -15
  130. package/dist/bundle/{process-I2QKOMM7.js → process-MGMXXPMY.js} +1 -1
  131. package/dist/bundle/{program-G6O3IJR2.js → program-IF36C6VR.js} +969 -1127
  132. package/dist/bundle/{prompt-SOG4AKPM.js → prompt-4RLIWLMF.js} +5 -5
  133. package/dist/bundle/{recognize-WMQLWMXH.js → recognize-UIRTMWM4.js} +4 -4
  134. package/dist/bundle/{remote-4BTFOLFY.js → remote-L3MNWZQK.js} +9 -9
  135. package/dist/bundle/{rerank-LJ3TWRNV.js → rerank-F4KZQTY6.js} +7 -7
  136. package/dist/bundle/{serve-B6UANKXN.js → serve-37AUYTWS.js} +10 -10
  137. package/dist/bundle/server-CRF4QSZR.js +86 -0
  138. package/dist/bundle/{server-YRH6GJ5Z.js → server-UBG676ZJ.js} +73 -61
  139. package/dist/bundle/source-Z7GH7T4B.js +44 -0
  140. package/dist/bundle/{sqlite-runtime-R7QFWFE7.js → sqlite-runtime-CI3RW7VA.js} +6 -6
  141. package/dist/bundle/{state-DIJ5YUOE.js → state-JOHLSLUO.js} +6 -6
  142. package/dist/bundle/{store-MYTYDV6A.js → store-2MBG4IUS.js} +28 -21
  143. package/dist/bundle/{store-6WFWW7EC.js → store-OSOUXBYL.js} +28 -23
  144. package/dist/bundle/store-SNW6U32Y.js +34 -0
  145. package/dist/bundle/store-maintenance-command-W7V54SLT.js +73 -0
  146. package/dist/bundle/surface-ESJS2FUI.js +72 -0
  147. package/dist/bundle/writer-BJDQMKUV.js +46 -0
  148. package/dist/commands/account.d.ts +3 -2
  149. package/dist/commands/account.d.ts.map +1 -1
  150. package/dist/commands/account.js +38 -77
  151. package/dist/commands/account.js.map +1 -1
  152. package/dist/commands/crm-shared.d.ts.map +1 -1
  153. package/dist/commands/crm-shared.js +2 -0
  154. package/dist/commands/crm-shared.js.map +1 -1
  155. package/dist/commands/session.d.ts +23 -6
  156. package/dist/commands/session.d.ts.map +1 -1
  157. package/dist/commands/session.js +122 -77
  158. package/dist/commands/session.js.map +1 -1
  159. package/dist/identity.js +1 -1
  160. package/dist/identity.js.map +1 -1
  161. package/dist/program.d.ts.map +1 -1
  162. package/dist/program.js +0 -2
  163. package/dist/program.js.map +1 -1
  164. package/dist/reasons.js +2 -2
  165. package/dist/reasons.js.map +1 -1
  166. package/dist/setup/flow.d.ts.map +1 -1
  167. package/dist/setup/flow.js +74 -4
  168. package/dist/setup/flow.js.map +1 -1
  169. package/dist/setup/texts.en.json +22 -1
  170. package/dist/setup/texts.es.json +22 -1
  171. package/dist/setup/texts.ru.json +22 -1
  172. package/dist/version.d.ts +1 -1
  173. package/dist/version.js +1 -1
  174. package/package.json +3 -3
  175. package/skills/amo-cli/references/setup.md +8 -2
  176. package/dist/bundle/command-contract-QBUQBXH7.js +0 -39
  177. package/dist/bundle/first-screen-GMN3T6RW.js +0 -39
  178. package/dist/bundle/meeting-combined-LAMF7S2B.js +0 -24
  179. package/dist/bundle/server-S6XD6V6E.js +0 -77
  180. package/dist/bundle/source-DGFTA2TN.js +0 -42
  181. package/dist/bundle/store-CHWY2USQ.js +0 -32
  182. package/dist/bundle/store-maintenance-command-B5TMKFMG.js +0 -68
  183. package/dist/bundle/writer-GP7VIMAU.js +0 -44
@@ -0,0 +1,338 @@
1
+ import { createRequire as __bundleRequire } from "node:module";
2
+ const require = __bundleRequire(import.meta.url);
3
+ import {
4
+ throughWrapper
5
+ } from "./chunk-4PQECIU2.js";
6
+ import {
7
+ environmentOf,
8
+ readOnlyLockOf
9
+ } from "./chunk-NKYWQTS2.js";
10
+ import {
11
+ array,
12
+ boolean,
13
+ check,
14
+ pipe,
15
+ record,
16
+ safeParse,
17
+ strictObject,
18
+ string
19
+ } from "./chunk-7OVTUADG.js";
20
+ import {
21
+ CliError
22
+ } from "./chunk-AP3CWDRK.js";
23
+ import {
24
+ __name
25
+ } from "./chunk-ZVVMGPBJ.js";
26
+
27
+ // node_modules/.pnpm/@wirecat+cli-core@0.722.0_@wirecat+cli-base@0.127.0_commander@15.0.0_esbuild@0.28.2_typ_d2bed0cfbe6b4358c89d465b9e07afcb/node_modules/@wirecat/cli-core/dist/background/relay.js
28
+ import { createHash } from "node:crypto";
29
+ import { chmodSync, lstatSync, mkdirSync, rmSync } from "node:fs";
30
+ import { createConnection, createServer } from "node:net";
31
+ import { tmpdir } from "node:os";
32
+ import { dirname, isAbsolute, join } from "node:path";
33
+ import { PassThrough, Writable } from "node:stream";
34
+ var RELAY_PROTOCOL = 1;
35
+ var requestSchema = strictObject({
36
+ argv: array(string()),
37
+ env: record(string(), string()),
38
+ cwd: pipe(string(), check((path) => isAbsolute(path))),
39
+ tty: boolean(),
40
+ stdinTty: boolean()
41
+ });
42
+ var MAX_CLIENT_LINE = 1024 * 1024;
43
+ var MAX_SERVE_LINE = 64 * 1024 * 1024;
44
+ var MAX_SOCKET_PATH = 100;
45
+ var relayPath = /* @__PURE__ */ __name((lockPath) => {
46
+ const beside = lockPath.replace(/\.lock$/, ".sock");
47
+ if (beside.length <= MAX_SOCKET_PATH)
48
+ return beside;
49
+ const hash = createHash("sha256").update(beside).digest("hex").slice(0, 16);
50
+ const name = join(`wirecat-relay-${process.getuid?.() ?? "user"}`, `${hash}.sock`);
51
+ const temporary = join(tmpdir(), name);
52
+ if (temporary.length <= MAX_SOCKET_PATH || process.platform === "win32")
53
+ return temporary;
54
+ return join("/tmp", name);
55
+ }, "relayPath");
56
+ var privateDirectory = /* @__PURE__ */ __name((dir) => {
57
+ mkdirSync(dir, { recursive: true, mode: 448 });
58
+ const stat = lstatSync(dir);
59
+ const mine = process.getuid === void 0 || stat.uid === process.getuid();
60
+ if (!stat.isDirectory() || !mine || (stat.mode & 63) !== 0) {
61
+ throw new CliError("permission_error", `${dir} is not a private directory, so serve does not listen there`);
62
+ }
63
+ }, "privateDirectory");
64
+ var lines = /* @__PURE__ */ __name((socket, max, onLine, onTooLong) => {
65
+ let buffered = "";
66
+ socket.setEncoding("utf8");
67
+ socket.on("data", (chunk) => {
68
+ buffered += chunk;
69
+ for (let end = buffered.indexOf("\n"); end >= 0; end = buffered.indexOf("\n")) {
70
+ const line = buffered.slice(0, end);
71
+ buffered = buffered.slice(end + 1);
72
+ if (line)
73
+ onLine(line);
74
+ }
75
+ if (buffered.length > max)
76
+ onTooLong();
77
+ });
78
+ }, "lines");
79
+ var frame = /* @__PURE__ */ __name((socket, value) => {
80
+ if (!socket.destroyed)
81
+ socket.write(`${JSON.stringify(value)}
82
+ `);
83
+ }, "frame");
84
+ var listenRelay = /* @__PURE__ */ __name(async (path, run) => {
85
+ privateDirectory(dirname(path));
86
+ rmSync(path, { force: true });
87
+ const open = /* @__PURE__ */ new Set();
88
+ const running = /* @__PURE__ */ new Set();
89
+ const server = createServer((socket) => {
90
+ open.add(socket);
91
+ const stop = new AbortController();
92
+ const stdin = new PassThrough();
93
+ let started = false;
94
+ socket.on("error", () => {
95
+ });
96
+ socket.on("close", () => {
97
+ open.delete(socket);
98
+ stop.abort(new CliError("cancelled", "the client went away", { retryable: false }));
99
+ if (!stdin.writableEnded)
100
+ stdin.end();
101
+ });
102
+ lines(socket, MAX_CLIENT_LINE, (line) => {
103
+ let message;
104
+ try {
105
+ message = JSON.parse(line);
106
+ } catch {
107
+ socket.destroy();
108
+ return;
109
+ }
110
+ if (!started) {
111
+ started = true;
112
+ if (message.v !== RELAY_PROTOCOL) {
113
+ frame(socket, { diagnostic: `serve speaks relay protocol ${RELAY_PROTOCOL}; restart it`, exit: 1 });
114
+ socket.end();
115
+ return;
116
+ }
117
+ const parsed = safeParse(requestSchema, message.run);
118
+ if (!parsed.success) {
119
+ socket.destroy();
120
+ return;
121
+ }
122
+ stdin.isTTY = parsed.output.stdinTty;
123
+ if (parsed.output.stdinTty)
124
+ stdin.end();
125
+ const job = serve(socket, parsed.output, stdin, stop.signal, run);
126
+ running.add(job);
127
+ void job.then(() => running.delete(job), () => running.delete(job));
128
+ return;
129
+ }
130
+ if (typeof message.stdin === "string" && !stdin.writableEnded)
131
+ stdin.write(Buffer.from(message.stdin, "base64"));
132
+ if (message.stdinEnd === true && !stdin.writableEnded)
133
+ stdin.end();
134
+ }, () => socket.destroy());
135
+ });
136
+ await new Promise((resolve, reject) => {
137
+ server.once("error", reject);
138
+ server.listen(path, () => {
139
+ server.off("error", reject);
140
+ resolve();
141
+ });
142
+ });
143
+ chmodSync(path, 384);
144
+ return {
145
+ close: /* @__PURE__ */ __name(async () => {
146
+ for (const socket of open)
147
+ socket.destroy();
148
+ await new Promise((resolve) => server.close(() => resolve()));
149
+ await Promise.allSettled(running);
150
+ rmSync(path, { force: true });
151
+ }, "close")
152
+ };
153
+ }, "listenRelay");
154
+ var serve = /* @__PURE__ */ __name(async (socket, request, stdin, signal, run) => {
155
+ const streams = {
156
+ data: /* @__PURE__ */ __name((text) => frame(socket, { data: text }), "data"),
157
+ diagnostic: /* @__PURE__ */ __name((text) => frame(socket, { diagnostic: text }), "diagnostic"),
158
+ progress: /* @__PURE__ */ __name((text) => frame(socket, { progress: text }), "progress")
159
+ };
160
+ const stdout = new Writable({
161
+ write: /* @__PURE__ */ __name((chunk, _encoding, done) => {
162
+ frame(socket, { raw: Buffer.from(chunk).toString("base64") });
163
+ done();
164
+ }, "write")
165
+ });
166
+ let code = 1;
167
+ try {
168
+ code = await run(request, { streams, stdin, stdout, signal });
169
+ } finally {
170
+ frame(socket, { exit: code });
171
+ socket.end();
172
+ }
173
+ }, "serve");
174
+ var relayCommand = /* @__PURE__ */ __name((path, request, options) => new Promise((resolve, reject) => {
175
+ const { streams, stdin, stdout, signal, deadlineMs, writes, holder, listens = false } = options;
176
+ const socket = createConnection(path);
177
+ let connected = false;
178
+ let settled = false;
179
+ let timer;
180
+ const forward = /* @__PURE__ */ __name((chunk) => frame(socket, { stdin: Buffer.from(chunk).toString("base64") }), "forward");
181
+ const ended = /* @__PURE__ */ __name(() => frame(socket, { stdinEnd: true }), "ended");
182
+ const brokenPipe = /* @__PURE__ */ __name((error) => {
183
+ if (error.code === "EPIPE")
184
+ finish({ code: 0 });
185
+ }, "brokenPipe");
186
+ const finish = /* @__PURE__ */ __name((outcome) => {
187
+ if (settled)
188
+ return;
189
+ settled = true;
190
+ if (timer)
191
+ clearTimeout(timer);
192
+ stdout.off("error", brokenPipe);
193
+ signal.removeEventListener("abort", aborted);
194
+ stdin.off("data", forward).off("end", ended);
195
+ stdin.pause();
196
+ socket.destroy();
197
+ if ("code" in outcome)
198
+ resolve(outcome.code);
199
+ else
200
+ reject(outcome.error);
201
+ }, "finish");
202
+ const stopped = /* @__PURE__ */ __name(() => writes ? new CliError("outcome_unknown", `${holder} stopped before the command finished; it may have run \u2014 check before repeating it`, { retryable: false }) : new CliError("provider_unavailable", `${holder} stopped before the command finished`, { retryable: true }), "stopped");
203
+ const aborted = /* @__PURE__ */ __name(() => finish(listens ? { code: 0 } : { error: signal.reason }), "aborted");
204
+ if (signal.aborted)
205
+ return aborted();
206
+ signal.addEventListener("abort", aborted, { once: true });
207
+ stdout.on("error", brokenPipe);
208
+ if (deadlineMs !== void 0)
209
+ timer = setTimeout(() => finish({ error: stopped() }), deadlineMs);
210
+ socket.on("connect", () => {
211
+ connected = true;
212
+ frame(socket, { v: RELAY_PROTOCOL, run: request });
213
+ if (request.stdinTty)
214
+ ended();
215
+ else {
216
+ stdin.on("data", forward).once("end", ended);
217
+ stdin.resume();
218
+ }
219
+ });
220
+ socket.on("error", (error) => {
221
+ if (connected)
222
+ return finish({ error: stopped() });
223
+ finish({
224
+ error: new CliError("provider_unavailable", `${holder} holds the connection but does not answer its relay (${error.code ?? error.message}) \u2014 restart it`, { retryable: false, sent: false })
225
+ });
226
+ });
227
+ socket.on("close", () => finish({ error: stopped() }));
228
+ lines(socket, MAX_SERVE_LINE, (line) => {
229
+ let message;
230
+ try {
231
+ message = JSON.parse(line);
232
+ } catch {
233
+ return finish({ error: stopped() });
234
+ }
235
+ if (typeof message.data === "string")
236
+ streams.data(message.data);
237
+ if (typeof message.diagnostic === "string")
238
+ streams.diagnostic(message.diagnostic);
239
+ if (typeof message.progress === "string")
240
+ streams.progress?.(message.progress);
241
+ if (typeof message.raw === "string")
242
+ stdout.write(Buffer.from(message.raw, "base64"));
243
+ if (typeof message.exit === "number")
244
+ finish({ code: message.exit });
245
+ }, () => finish({ error: stopped() }));
246
+ }), "relayCommand");
247
+
248
+ // node_modules/.pnpm/@wirecat+cli-core@0.722.0_@wirecat+cli-base@0.127.0_commander@15.0.0_esbuild@0.28.2_typ_d2bed0cfbe6b4358c89d465b9e07afcb/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
+ };
@@ -2,24 +2,24 @@ import { createRequire as __bundleRequire } from "node:module";
2
2
  const require = __bundleRequire(import.meta.url);
3
3
  import {
4
4
  storePath
5
- } from "./chunk-5E5R65CA.js";
5
+ } from "./chunk-ZKRWNL4T.js";
6
6
  import {
7
7
  resolvePaths,
8
8
  writeSecurely
9
- } from "./chunk-DJD7TBYG.js";
9
+ } from "./chunk-SCMB4LI6.js";
10
10
  import {
11
11
  CliError,
12
12
  singleLine
13
- } from "./chunk-SZ2V62HB.js";
13
+ } from "./chunk-AP3CWDRK.js";
14
14
  import {
15
15
  __name
16
16
  } from "./chunk-ZVVMGPBJ.js";
17
17
 
18
- // 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/store/shared-config.js
18
+ // node_modules/.pnpm/@wirecat+cli-core@0.722.0_@wirecat+cli-base@0.127.0_commander@15.0.0_esbuild@0.28.2_typ_d2bed0cfbe6b4358c89d465b9e07afcb/node_modules/@wirecat/cli-core/dist/store/shared-config.js
19
19
  import { existsSync, mkdirSync, readFileSync, renameSync, statSync, writeFileSync } from "node:fs";
20
20
  import { dirname, join, resolve } from "node:path";
21
21
 
22
- // 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/domain/config-repair.js
22
+ // node_modules/.pnpm/@wirecat+cli-core@0.722.0_@wirecat+cli-base@0.127.0_commander@15.0.0_esbuild@0.28.2_typ_d2bed0cfbe6b4358c89d465b9e07afcb/node_modules/@wirecat/cli-core/dist/domain/config-repair.js
23
23
  var REPAIR_WORDS = {
24
24
  byte_order_mark: "an invisible byte-order mark at the start",
25
25
  comment: "a comment, which JSON does not allow",
@@ -303,7 +303,7 @@ var explainBrokenJson = /* @__PURE__ */ __name((text, result) => {
303
303
  return `line ${line}, column ${column}: ${why}${around(line)}; likely fix: ${fix ?? "correct that part by hand"}`;
304
304
  }, "explainBrokenJson");
305
305
 
306
- // 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/domain/task-categories.js
306
+ // node_modules/.pnpm/@wirecat+cli-core@0.722.0_@wirecat+cli-base@0.127.0_commander@15.0.0_esbuild@0.28.2_typ_d2bed0cfbe6b4358c89d465b9e07afcb/node_modules/@wirecat/cli-core/dist/domain/task-categories.js
307
307
  var DEFAULT_TASK_CATEGORIES = [
308
308
  {
309
309
  name: "taxes",
@@ -1058,7 +1058,7 @@ var storedTaskCategories = /* @__PURE__ */ __name((json) => {
1058
1058
  }
1059
1059
  }, "storedTaskCategories");
1060
1060
 
1061
- // 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/store/shared-config.js
1061
+ // node_modules/.pnpm/@wirecat+cli-core@0.722.0_@wirecat+cli-base@0.127.0_commander@15.0.0_esbuild@0.28.2_typ_d2bed0cfbe6b4358c89d465b9e07afcb/node_modules/@wirecat/cli-core/dist/store/shared-config.js
1062
1062
  var SECTION = "task_categories";
1063
1063
  var sharedConfigPath = /* @__PURE__ */ __name((store, env = process.env) => {
1064
1064
  const paths = resolvePaths({ appName: "WireCat", prefix: "WIRECAT", env });