@wirecat/tg-cli 0.133.0 → 0.135.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 (153) hide show
  1. package/README.md +2 -3
  2. package/contracts/wirecat.json +82 -2
  3. package/dist/bin/tg.js +2 -2
  4. package/dist/bot/generated/types.d.ts +188 -0
  5. package/dist/bot/generated/types.d.ts.map +1 -1
  6. package/dist/bundle/{adapter-GSGX3WBH.js → adapter-OHJF6PB5.js} +104 -69
  7. package/dist/bundle/agent-QPF2KU4I.js +37 -0
  8. package/dist/bundle/{all-profiles-VOCJ55YH.js → all-profiles-LQ73BIFB.js} +62 -20
  9. package/dist/bundle/{anthropic-J6CTLU3W.js → anthropic-YYBMT2HD.js} +5 -5
  10. package/dist/bundle/{app-server-GVFGA4TJ.js → app-server-HV4C4CSA.js} +72 -62
  11. package/dist/bundle/{bot-api-LWONPIGK.js → bot-api-URQXWMVR.js} +73 -92
  12. package/dist/bundle/{bot-history-XOW7Y2GC.js → bot-history-FRLCHPDQ.js} +23 -22
  13. package/dist/bundle/{bun-436CH6CP.js → bun-J3ML43BO.js} +2 -2
  14. package/dist/bundle/{bun-sqlite-ZLB5RK5Q.js → bun-sqlite-ZNB2B2DL.js} +6 -6
  15. package/dist/bundle/{chunk-UGS57TT5.js → chunk-24G3SEXH.js} +2 -2
  16. package/dist/bundle/chunk-27F6QBPY.js +555 -0
  17. package/dist/bundle/{chunk-6VCSOQFL.js → chunk-2OFCIF2W.js} +2 -2
  18. package/dist/bundle/{chunk-VGN5YXYI.js → chunk-2U7XA4IH.js} +2 -100
  19. package/dist/bundle/{chunk-LBZEZO32.js → chunk-4CLSIEWN.js} +65 -43
  20. package/dist/bundle/chunk-5CEKH6R6.js +340 -0
  21. package/dist/bundle/{chunk-SMI2EUH4.js → chunk-5WEEK65F.js} +1 -1
  22. package/dist/bundle/{chunk-OX73ERZW.js → chunk-6VWVYPH2.js} +3 -4
  23. package/dist/bundle/{chunk-5HKPQPD4.js → chunk-6WS474NQ.js} +6 -6
  24. package/dist/bundle/{chunk-IYAXLLGR.js → chunk-7GWOGEWJ.js} +6 -6
  25. package/dist/bundle/{chunk-TPD37ECC.js → chunk-AMRMU23L.js} +16 -3
  26. package/dist/bundle/{chunk-ZHO3TPHM.js → chunk-B2UXNYCD.js} +30 -15
  27. package/dist/bundle/{chunk-YY6FGKGD.js → chunk-B4ZMFU5I.js} +2 -2
  28. package/dist/bundle/{chunk-54WLIPIQ.js → chunk-BFKPMG5T.js} +1 -1
  29. package/dist/bundle/{chunk-KHUXDSXN.js → chunk-BQSODAU3.js} +1 -1
  30. package/dist/bundle/{chunk-N3JUHGKM.js → chunk-BXUMZWMN.js} +3786 -3364
  31. package/dist/bundle/{chunk-VTQMR3XG.js → chunk-E2VIO7RY.js} +3 -3
  32. package/dist/bundle/{chunk-UZ63ORMY.js → chunk-F5FOS64B.js} +4 -4
  33. package/dist/bundle/{chunk-LIQMUDIZ.js → chunk-GCUFGDKE.js} +2 -2
  34. package/dist/bundle/chunk-GUERS64O.js +108 -0
  35. package/dist/bundle/{chunk-5LRTYBZW.js → chunk-HILS2UL7.js} +12 -12
  36. package/dist/bundle/{chunk-6S77EKZU.js → chunk-IOJOLV25.js} +17 -15
  37. package/dist/bundle/{chunk-IBCXEVNY.js → chunk-JBS4VPAX.js} +3 -3
  38. package/dist/bundle/{chunk-5L44DSHV.js → chunk-K5QGBYDL.js} +4 -4
  39. package/dist/bundle/{chunk-NO2LIHWA.js → chunk-KKXF6TSS.js} +1 -1
  40. package/dist/bundle/chunk-L2ZQDTDU.js +7 -0
  41. package/dist/bundle/{chunk-HB5DP6L5.js → chunk-LFPUW7DR.js} +18 -18
  42. package/dist/bundle/{chunk-QWO7L4UH.js → chunk-LGYATGQI.js} +7 -7
  43. package/dist/bundle/{chunk-IH4Z3KZU.js → chunk-MA27675E.js} +2 -2
  44. package/dist/bundle/{chunk-6H2NW6HK.js → chunk-MDI7554C.js} +3 -3
  45. package/dist/bundle/{chunk-KVFUH5IT.js → chunk-MMZ4QAKJ.js} +1 -1
  46. package/dist/bundle/{chunk-XOX4BX5A.js → chunk-MOPBEBVS.js} +4 -4
  47. package/dist/bundle/{chunk-XKOMP3HV.js → chunk-MPRXUTIK.js} +6 -6
  48. package/dist/bundle/{chunk-QYLZD4DS.js → chunk-N7F5KT6U.js} +1 -1
  49. package/dist/bundle/{chunk-KUA24HWG.js → chunk-NBP6LXSY.js} +2 -2
  50. package/dist/bundle/{chunk-UQYL6TJ7.js → chunk-NP46ZKQW.js} +4 -4
  51. package/dist/bundle/{chunk-QGWISM4W.js → chunk-NRSJXUUO.js} +34 -28
  52. package/dist/bundle/{chunk-7NYP4RBO.js → chunk-NVWZ7S3I.js} +2294 -1221
  53. package/dist/bundle/chunk-OBIMTRA7.js +80 -0
  54. package/dist/bundle/{chunk-VWJTYAIQ.js → chunk-OQJURSRL.js} +17 -17
  55. package/dist/bundle/chunk-OU3WN4YH.js +50 -0
  56. package/dist/bundle/{chunk-VCAOH45X.js → chunk-PBK2ECXT.js} +1 -1
  57. package/dist/bundle/{chunk-TTDZVWDU.js → chunk-PHAFT2BO.js} +1 -1
  58. package/dist/bundle/{chunk-NTWXL2QV.js → chunk-PKIGE4NE.js} +2 -2
  59. package/dist/bundle/{chunk-5D4AEUVA.js → chunk-PL5P7UKW.js} +434 -1
  60. package/dist/bundle/{chunk-NAXOT35J.js → chunk-QBRQLOZA.js} +3 -3
  61. package/dist/bundle/{chunk-RABUG4KA.js → chunk-QD4MTOI7.js} +511 -472
  62. package/dist/bundle/{chunk-LOS4D6ZB.js → chunk-QHQ52UMF.js} +159 -569
  63. package/dist/bundle/{chunk-6CHIGUCY.js → chunk-R2G3MWEF.js} +31 -20
  64. package/dist/bundle/{chunk-THYGLTRB.js → chunk-RCEP5OXD.js} +7 -7
  65. package/dist/bundle/chunk-RHJ2VGHV.js +353 -0
  66. package/dist/bundle/{chunk-QVGEL66U.js → chunk-RXBKVNOK.js} +53 -11
  67. package/dist/bundle/{chunk-ZYAHZKYF.js → chunk-RZ7POTFA.js} +3 -3
  68. package/dist/bundle/{chunk-KEN4B57V.js → chunk-S7PIM4GG.js} +2 -2
  69. package/dist/bundle/{chunk-BXVB42KJ.js → chunk-SIDGH56R.js} +2 -2
  70. package/dist/bundle/{chunk-XDQU5HBO.js → chunk-SRMELB6Q.js} +12 -12
  71. package/dist/bundle/{chunk-SMU6NA7F.js → chunk-SVPNU7PD.js} +4 -4
  72. package/dist/bundle/{chunk-JPNVEPS4.js → chunk-TB2MG6PE.js} +2351 -2028
  73. package/dist/bundle/{chunk-JGMXBAGH.js → chunk-UN5TH2CG.js} +156 -434
  74. package/dist/bundle/{chunk-YAPDU3SV.js → chunk-V3ZWYMXT.js} +1 -1
  75. package/dist/bundle/{chunk-7NF3V5L2.js → chunk-VFU25P57.js} +4 -4
  76. package/dist/bundle/{chunk-LQQSDGQ6.js → chunk-VJEMCJPL.js} +56 -46
  77. package/dist/bundle/{chunk-UIAKLELF.js → chunk-VK2NDTBS.js} +94 -64
  78. package/dist/bundle/{chunk-UKBK2VWZ.js → chunk-W6A2OZ3C.js} +232 -176
  79. package/dist/bundle/{chunk-IPPCQ7IK.js → chunk-WDI6LA4X.js} +2 -2
  80. package/dist/bundle/{chunk-N7QREPZW.js → chunk-WTGRQGQL.js} +16 -9
  81. package/dist/bundle/{chunk-57KJ3TRS.js → chunk-WUCTF2XE.js} +9 -9
  82. package/dist/bundle/{chunk-JKSD43L7.js → chunk-WZCRCCOZ.js} +6 -6
  83. package/dist/bundle/{chunk-H7ML7X3G.js → chunk-XB6O445X.js} +144 -10
  84. package/dist/bundle/{chunk-O6JUVATT.js → chunk-XKFES4EM.js} +35 -12
  85. package/dist/bundle/chunk-YBUX6EAK.js +388 -0
  86. package/dist/bundle/{chunk-WCYKVX3B.js → chunk-YMRL7MYS.js} +7 -7
  87. package/dist/bundle/{chunk-M6QOM6SL.js → chunk-Z6M6NZUX.js} +1 -1
  88. package/dist/bundle/chunk-ZCDRXKCR.js +727 -0
  89. package/dist/bundle/{chunk-6A44ZZFC.js → chunk-ZJ3S4S6H.js} +43 -64
  90. package/dist/bundle/{chunk-TCI7I6YF.js → chunk-ZL7TJXFL.js} +11 -25
  91. package/dist/bundle/{chunk-2KQDJHF3.js → chunk-ZMBVZWUW.js} +29 -1
  92. package/dist/bundle/{chunk-OWY52JBO.js → chunk-ZMTASSIB.js} +7 -7
  93. package/dist/bundle/{chunk-D2SJLZSH.js → chunk-ZQ5ERQHO.js} +2 -2
  94. package/dist/bundle/{chunk-CEJYNB3I.js → chunk-ZWVDXVG3.js} +4 -4
  95. package/dist/bundle/command-contract-K4MU32K6.js +37 -0
  96. package/dist/bundle/{command-server-entry-AE27QXTE.js → command-server-entry-XP6BVJIK.js} +27 -27
  97. package/dist/bundle/{decode-RQPPZ72F.js → decode-TUB45ALX.js} +5 -5
  98. package/dist/bundle/{dispatch-KQO2MCSH.js → dispatch-ICPUKMEG.js} +8 -8
  99. package/dist/bundle/dist-PAKDDIBT.js +191 -0
  100. package/dist/bundle/{echarts-FZRIACN4.js → echarts-HJ7D7XTM.js} +2 -2
  101. package/dist/bundle/{embed-TOSWWMDL.js → embed-4QDN36YF.js} +6 -6
  102. package/dist/bundle/{embedder-JHIQSBGD.js → embedder-Q7ID2LEG.js} +9 -9
  103. package/dist/bundle/{entry-DU4KRXTG.js → entry-Z6VRZP7F.js} +9 -9
  104. package/dist/bundle/{failure-3YC3YGYO.js → failure-PEPNEEK7.js} +2 -2
  105. package/dist/bundle/{first-run-DQQT4FID.js → first-run-GKBEHAAX.js} +12 -12
  106. package/dist/bundle/first-screen-IA3ONZ75.js +37 -0
  107. package/dist/bundle/{instructions-WI64CJQ6.js → instructions-26ZXYYMY.js} +1 -1
  108. package/dist/bundle/{mcp-VMS6PBCU.js → mcp-KGWT6TGO.js} +2 -2
  109. package/dist/bundle/meeting-combined-KUV2HP52.js +23 -0
  110. package/dist/bundle/{meeting-model-XNRSREIK.js → meeting-model-JB7X4CA3.js} +11 -11
  111. package/dist/bundle/{meeting-semantic-OOSCHQMB.js → meeting-semantic-MQNUVG33.js} +6 -6
  112. package/dist/bundle/{node-JLKDNVKV.js → node-RIANITAT.js} +2 -2
  113. package/dist/bundle/{node-sqlite-YOGH26O2.js → node-sqlite-I2P26Z3S.js} +7 -7
  114. package/dist/bundle/{oauth-FOMXM5HP.js → oauth-GFMJL2ZZ.js} +8 -8
  115. package/dist/bundle/{open-SM2UXUKM.js → open-CWVYEFNN.js} +5 -5
  116. package/dist/bundle/{openai-J2H7S6ZF.js → openai-PQLK7YTJ.js} +15 -15
  117. package/dist/bundle/{process-HI7OZBOI.js → process-P4D4KFWE.js} +1 -1
  118. package/dist/bundle/{program-VY4HFU25.js → program-MF4QZJKH.js} +70 -64
  119. package/dist/bundle/{prompt-NUUVFMOF.js → prompt-JWIOYU53.js} +5 -5
  120. package/dist/bundle/{proxy-transport-AN4VMRRN.js → proxy-transport-DWY6ABVT.js} +5 -5
  121. package/dist/bundle/{recognize-MALJHPDI.js → recognize-IPJL4CQZ.js} +4 -4
  122. package/dist/bundle/{remote-QUDRSTS2.js → remote-DVY6F6YO.js} +9 -9
  123. package/dist/bundle/{rerank-2DSO3D3S.js → rerank-XSPWLBIO.js} +7 -7
  124. package/dist/bundle/{serve-NCJ52MY3.js → serve-AJAVEH2M.js} +15 -15
  125. package/dist/bundle/server-GGXUR5BZ.js +78 -0
  126. package/dist/bundle/{server-Y3M544AM.js → server-GII7NIKF.js} +65 -54
  127. package/dist/bundle/{sqlite-runtime-NJUSXVKK.js → sqlite-runtime-KFDYJTUO.js} +6 -6
  128. package/dist/bundle/{state-AVOWQVET.js → state-76OJSCQC.js} +6 -6
  129. package/dist/bundle/{store-MMIYOL4H.js → store-2KJS4YMH.js} +28 -17
  130. package/dist/bundle/{store-BZ5ICDRP.js → store-FBP2J23G.js} +20 -19
  131. package/dist/bundle/store-maintenance-command-NUWOUZ62.js +65 -0
  132. package/dist/bundle/surface-EGSHCISG.js +64 -0
  133. package/dist/bundle/tg.js +13 -13
  134. package/dist/telegram/adapter.d.ts +9 -2
  135. package/dist/telegram/adapter.d.ts.map +1 -1
  136. package/dist/telegram/adapter.js +5 -6
  137. package/dist/telegram/adapter.js.map +1 -1
  138. package/dist/telegram/messages.d.ts +12 -0
  139. package/dist/telegram/messages.d.ts.map +1 -1
  140. package/dist/telegram/messages.js +40 -0
  141. package/dist/telegram/messages.js.map +1 -1
  142. package/dist/version.d.ts +1 -1
  143. package/dist/version.js +1 -1
  144. package/package.json +3 -3
  145. package/skills/tg-cli/SKILL.md +7 -4
  146. package/skills/tg-cli/references/messages.md +5 -1
  147. package/skills/tg-cli/references/search.md +2 -0
  148. package/dist/bundle/chunk-SHTHNBHG.js +0 -2
  149. package/dist/bundle/command-contract-TQIARAB4.js +0 -37
  150. package/dist/bundle/first-screen-7N4CTZSA.js +0 -37
  151. package/dist/bundle/meeting-combined-3RAOFQ7M.js +0 -23
  152. package/dist/bundle/server-CHGON5I2.js +0 -70
  153. package/dist/bundle/store-maintenance-command-VKZ4WHUB.js +0 -61
@@ -0,0 +1,340 @@
1
+ import { createRequire as __bundleRequire } from "node:module";
2
+ const require = __bundleRequire(import.meta.url);
3
+ import {
4
+ throughWrapper
5
+ } from "./chunk-ZCDRXKCR.js";
6
+ import {
7
+ environmentOf
8
+ } from "./chunk-W6A2OZ3C.js";
9
+ import {
10
+ readOnlyLockOf
11
+ } from "./chunk-S7PIM4GG.js";
12
+ import {
13
+ array,
14
+ boolean,
15
+ check,
16
+ pipe,
17
+ record,
18
+ safeParse,
19
+ strictObject,
20
+ string
21
+ } from "./chunk-RXBKVNOK.js";
22
+ import {
23
+ CliError
24
+ } from "./chunk-GCUFGDKE.js";
25
+ import {
26
+ __name
27
+ } from "./chunk-ZVVMGPBJ.js";
28
+
29
+ // node_modules/.pnpm/@wirecat+cli-core@0.718.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.126.1_commander@15_05e4e157d64d32ce6fc62270b9552a1d/node_modules/@wirecat/cli-core/dist/background/relay.js
30
+ import { createHash } from "node:crypto";
31
+ import { chmodSync, lstatSync, mkdirSync, rmSync } from "node:fs";
32
+ import { createConnection, createServer } from "node:net";
33
+ import { tmpdir } from "node:os";
34
+ import { dirname, isAbsolute, join } from "node:path";
35
+ import { PassThrough, Writable } from "node:stream";
36
+ var RELAY_PROTOCOL = 1;
37
+ var requestSchema = strictObject({
38
+ argv: array(string()),
39
+ env: record(string(), string()),
40
+ cwd: pipe(string(), check((path) => isAbsolute(path))),
41
+ tty: boolean(),
42
+ stdinTty: boolean()
43
+ });
44
+ var MAX_CLIENT_LINE = 1024 * 1024;
45
+ var MAX_SERVE_LINE = 64 * 1024 * 1024;
46
+ var MAX_SOCKET_PATH = 100;
47
+ var relayPath = /* @__PURE__ */ __name((lockPath) => {
48
+ const beside = lockPath.replace(/\.lock$/, ".sock");
49
+ if (beside.length <= MAX_SOCKET_PATH)
50
+ return beside;
51
+ const hash = createHash("sha256").update(beside).digest("hex").slice(0, 16);
52
+ const name = join(`wirecat-relay-${process.getuid?.() ?? "user"}`, `${hash}.sock`);
53
+ const temporary = join(tmpdir(), name);
54
+ if (temporary.length <= MAX_SOCKET_PATH || process.platform === "win32")
55
+ return temporary;
56
+ return join("/tmp", name);
57
+ }, "relayPath");
58
+ var privateDirectory = /* @__PURE__ */ __name((dir) => {
59
+ mkdirSync(dir, { recursive: true, mode: 448 });
60
+ const stat = lstatSync(dir);
61
+ const mine = process.getuid === void 0 || stat.uid === process.getuid();
62
+ if (!stat.isDirectory() || !mine || (stat.mode & 63) !== 0) {
63
+ throw new CliError("permission_error", `${dir} is not a private directory, so serve does not listen there`);
64
+ }
65
+ }, "privateDirectory");
66
+ var lines = /* @__PURE__ */ __name((socket, max, onLine, onTooLong) => {
67
+ let buffered = "";
68
+ socket.setEncoding("utf8");
69
+ socket.on("data", (chunk) => {
70
+ buffered += chunk;
71
+ for (let end = buffered.indexOf("\n"); end >= 0; end = buffered.indexOf("\n")) {
72
+ const line = buffered.slice(0, end);
73
+ buffered = buffered.slice(end + 1);
74
+ if (line)
75
+ onLine(line);
76
+ }
77
+ if (buffered.length > max)
78
+ onTooLong();
79
+ });
80
+ }, "lines");
81
+ var frame = /* @__PURE__ */ __name((socket, value) => {
82
+ if (!socket.destroyed)
83
+ socket.write(`${JSON.stringify(value)}
84
+ `);
85
+ }, "frame");
86
+ var listenRelay = /* @__PURE__ */ __name(async (path, run) => {
87
+ privateDirectory(dirname(path));
88
+ rmSync(path, { force: true });
89
+ const open = /* @__PURE__ */ new Set();
90
+ const running = /* @__PURE__ */ new Set();
91
+ const server = createServer((socket) => {
92
+ open.add(socket);
93
+ const stop = new AbortController();
94
+ const stdin = new PassThrough();
95
+ let started = false;
96
+ socket.on("error", () => {
97
+ });
98
+ socket.on("close", () => {
99
+ open.delete(socket);
100
+ stop.abort(new CliError("cancelled", "the client went away", { retryable: false }));
101
+ if (!stdin.writableEnded)
102
+ stdin.end();
103
+ });
104
+ lines(socket, MAX_CLIENT_LINE, (line) => {
105
+ let message;
106
+ try {
107
+ message = JSON.parse(line);
108
+ } catch {
109
+ socket.destroy();
110
+ return;
111
+ }
112
+ if (!started) {
113
+ started = true;
114
+ if (message.v !== RELAY_PROTOCOL) {
115
+ frame(socket, { diagnostic: `serve speaks relay protocol ${RELAY_PROTOCOL}; restart it`, exit: 1 });
116
+ socket.end();
117
+ return;
118
+ }
119
+ const parsed = safeParse(requestSchema, message.run);
120
+ if (!parsed.success) {
121
+ socket.destroy();
122
+ return;
123
+ }
124
+ stdin.isTTY = parsed.output.stdinTty;
125
+ if (parsed.output.stdinTty)
126
+ stdin.end();
127
+ const job = serve(socket, parsed.output, stdin, stop.signal, run);
128
+ running.add(job);
129
+ void job.then(() => running.delete(job), () => running.delete(job));
130
+ return;
131
+ }
132
+ if (typeof message.stdin === "string" && !stdin.writableEnded)
133
+ stdin.write(Buffer.from(message.stdin, "base64"));
134
+ if (message.stdinEnd === true && !stdin.writableEnded)
135
+ stdin.end();
136
+ }, () => socket.destroy());
137
+ });
138
+ await new Promise((resolve, reject) => {
139
+ server.once("error", reject);
140
+ server.listen(path, () => {
141
+ server.off("error", reject);
142
+ resolve();
143
+ });
144
+ });
145
+ chmodSync(path, 384);
146
+ return {
147
+ close: /* @__PURE__ */ __name(async () => {
148
+ for (const socket of open)
149
+ socket.destroy();
150
+ await new Promise((resolve) => server.close(() => resolve()));
151
+ await Promise.allSettled(running);
152
+ rmSync(path, { force: true });
153
+ }, "close")
154
+ };
155
+ }, "listenRelay");
156
+ var serve = /* @__PURE__ */ __name(async (socket, request, stdin, signal, run) => {
157
+ const streams = {
158
+ data: /* @__PURE__ */ __name((text) => frame(socket, { data: text }), "data"),
159
+ diagnostic: /* @__PURE__ */ __name((text) => frame(socket, { diagnostic: text }), "diagnostic"),
160
+ progress: /* @__PURE__ */ __name((text) => frame(socket, { progress: text }), "progress")
161
+ };
162
+ const stdout = new Writable({
163
+ write: /* @__PURE__ */ __name((chunk, _encoding, done) => {
164
+ frame(socket, { raw: Buffer.from(chunk).toString("base64") });
165
+ done();
166
+ }, "write")
167
+ });
168
+ let code = 1;
169
+ try {
170
+ code = await run(request, { streams, stdin, stdout, signal });
171
+ } finally {
172
+ frame(socket, { exit: code });
173
+ socket.end();
174
+ }
175
+ }, "serve");
176
+ var relayCommand = /* @__PURE__ */ __name((path, request, options) => new Promise((resolve, reject) => {
177
+ const { streams, stdin, stdout, signal, deadlineMs, writes, holder, listens = false } = options;
178
+ const socket = createConnection(path);
179
+ let connected = false;
180
+ let settled = false;
181
+ let timer;
182
+ const forward = /* @__PURE__ */ __name((chunk) => frame(socket, { stdin: Buffer.from(chunk).toString("base64") }), "forward");
183
+ const ended = /* @__PURE__ */ __name(() => frame(socket, { stdinEnd: true }), "ended");
184
+ const brokenPipe = /* @__PURE__ */ __name((error) => {
185
+ if (error.code === "EPIPE")
186
+ finish({ code: 0 });
187
+ }, "brokenPipe");
188
+ const finish = /* @__PURE__ */ __name((outcome) => {
189
+ if (settled)
190
+ return;
191
+ settled = true;
192
+ if (timer)
193
+ clearTimeout(timer);
194
+ stdout.off("error", brokenPipe);
195
+ signal.removeEventListener("abort", aborted);
196
+ stdin.off("data", forward).off("end", ended);
197
+ stdin.pause();
198
+ socket.destroy();
199
+ if ("code" in outcome)
200
+ resolve(outcome.code);
201
+ else
202
+ reject(outcome.error);
203
+ }, "finish");
204
+ 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");
205
+ const aborted = /* @__PURE__ */ __name(() => finish(listens ? { code: 0 } : { error: signal.reason }), "aborted");
206
+ if (signal.aborted)
207
+ return aborted();
208
+ signal.addEventListener("abort", aborted, { once: true });
209
+ stdout.on("error", brokenPipe);
210
+ if (deadlineMs !== void 0)
211
+ timer = setTimeout(() => finish({ error: stopped() }), deadlineMs);
212
+ socket.on("connect", () => {
213
+ connected = true;
214
+ frame(socket, { v: RELAY_PROTOCOL, run: request });
215
+ if (request.stdinTty)
216
+ ended();
217
+ else {
218
+ stdin.on("data", forward).once("end", ended);
219
+ stdin.resume();
220
+ }
221
+ });
222
+ socket.on("error", (error) => {
223
+ if (connected)
224
+ return finish({ error: stopped() });
225
+ finish({
226
+ 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 })
227
+ });
228
+ });
229
+ socket.on("close", () => finish({ error: stopped() }));
230
+ lines(socket, MAX_SERVE_LINE, (line) => {
231
+ let message;
232
+ try {
233
+ message = JSON.parse(line);
234
+ } catch {
235
+ return finish({ error: stopped() });
236
+ }
237
+ if (typeof message.data === "string")
238
+ streams.data(message.data);
239
+ if (typeof message.diagnostic === "string")
240
+ streams.diagnostic(message.diagnostic);
241
+ if (typeof message.progress === "string")
242
+ streams.progress?.(message.progress);
243
+ if (typeof message.raw === "string")
244
+ stdout.write(Buffer.from(message.raw, "base64"));
245
+ if (typeof message.exit === "number")
246
+ finish({ code: message.exit });
247
+ }, () => finish({ error: stopped() }));
248
+ }), "relayCommand");
249
+
250
+ // node_modules/.pnpm/@wirecat+cli-core@0.718.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.126.1_commander@15_05e4e157d64d32ce6fc62270b9552a1d/node_modules/@wirecat/cli-core/dist/cli/messenger/serve-relay.js
251
+ var lentConnection = /* @__PURE__ */ __name((connection, watchers) => throughWrapper(connection, {
252
+ close: /* @__PURE__ */ __name(async () => {
253
+ }, "close"),
254
+ feed: void 0,
255
+ storedChats: void 0,
256
+ listen: void 0,
257
+ listenHistory: void 0,
258
+ ...connection.watch && watchers ? {
259
+ // A watcher that throws (its output limit, a closed reader) ends its own watch, never serve's.
260
+ watch: /* @__PURE__ */ __name(async (onEvent, signal, onReady) => {
261
+ let watcher;
262
+ try {
263
+ await new Promise((resolve, reject) => {
264
+ watcher = /* @__PURE__ */ __name((event) => {
265
+ try {
266
+ onEvent(event);
267
+ } catch (error) {
268
+ reject(error);
269
+ }
270
+ }, "watcher");
271
+ watchers.add(watcher);
272
+ signal.addEventListener("abort", () => resolve(), { once: true });
273
+ onReady?.();
274
+ if (signal.aborted)
275
+ resolve();
276
+ });
277
+ } finally {
278
+ if (watcher)
279
+ watchers.delete(watcher);
280
+ }
281
+ }, "watch")
282
+ } : { watch: void 0 }
283
+ }), "lentConnection");
284
+ var serveRelay = /* @__PURE__ */ __name((command, messenger) => {
285
+ let held;
286
+ let relay;
287
+ const watchers = /* @__PURE__ */ new Set();
288
+ const borrowed = /* @__PURE__ */ __name(() => {
289
+ const connection = held;
290
+ if (!connection)
291
+ throw new CliError("provider_unavailable", "serve is not connected yet", { retryable: true });
292
+ return lentConnection(connection, watchers);
293
+ }, "borrowed");
294
+ return {
295
+ messenger: {
296
+ ...messenger,
297
+ connect: /* @__PURE__ */ __name(async (...args) => {
298
+ held = await messenger.connect(...args);
299
+ return held;
300
+ }, "connect")
301
+ },
302
+ arrived: /* @__PURE__ */ __name((event) => {
303
+ for (const watcher of watchers)
304
+ watcher(event);
305
+ }, "arrived"),
306
+ /** Listens beside the lock; the address goes into it, which is how a client finds it. */
307
+ open: /* @__PURE__ */ __name(async (lockPath, profile) => {
308
+ const environment = environmentOf(command);
309
+ const runCommand = environment.runCommand;
310
+ if (!runCommand)
311
+ return void 0;
312
+ const readOnly = readOnlyLockOf(messenger.app, environment.env ?? process.env);
313
+ const path = relayPath(lockPath);
314
+ relay = await listenRelay(path, (request, io) => runCommand(request.argv, {
315
+ env: {
316
+ ...request.env,
317
+ ...readOnly ? { [`${messenger.app.envPrefix}_READ_ONLY`]: "1" } : {}
318
+ },
319
+ streams: io.streams,
320
+ stdin: io.stdin,
321
+ stdout: io.stdout,
322
+ tty: request.tty,
323
+ signal: io.signal,
324
+ answer: /* @__PURE__ */ __name(() => null, "answer"),
325
+ relayed: { profile, cwd: request.cwd, connection: borrowed }
326
+ }));
327
+ return { path, protocol: RELAY_PROTOCOL };
328
+ }, "open"),
329
+ close: /* @__PURE__ */ __name(async () => {
330
+ await relay?.close();
331
+ }, "close")
332
+ };
333
+ }, "serveRelay");
334
+
335
+ export {
336
+ RELAY_PROTOCOL,
337
+ relayCommand,
338
+ lentConnection,
339
+ serveRelay
340
+ };
@@ -4,7 +4,7 @@ import {
4
4
  __name
5
5
  } from "./chunk-ZVVMGPBJ.js";
6
6
 
7
- // node_modules/.pnpm/@wirecat+cli-core@0.681.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.106.0_commander@15_8d845c31697914d824aa80d8eec93941/node_modules/@wirecat/cli-core/dist/cli/command-server-argv.js
7
+ // node_modules/.pnpm/@wirecat+cli-core@0.718.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.126.1_commander@15_05e4e157d64d32ce6fc62270b9552a1d/node_modules/@wirecat/cli-core/dist/cli/command-server-argv.js
8
8
  var COMMAND_SERVER_ARGV = ["commands", "--serve"];
9
9
  var isCommandServer = /* @__PURE__ */ __name((args) => args.length === COMMAND_SERVER_ARGV.length && COMMAND_SERVER_ARGV.every((word, at) => args[at] === word), "isCommandServer");
10
10
 
@@ -4,9 +4,9 @@ import {
4
4
  __name
5
5
  } from "./chunk-ZVVMGPBJ.js";
6
6
 
7
- // node_modules/.pnpm/@wirecat+cli-core@0.681.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.106.0_commander@15_8d845c31697914d824aa80d8eec93941/node_modules/@wirecat/cli-core/dist/http/listen.js
7
+ // node_modules/.pnpm/@wirecat+cli-core@0.718.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.126.1_commander@15_05e4e157d64d32ce6fc62270b9552a1d/node_modules/@wirecat/cli-core/dist/http/listen.js
8
8
  import { createServer } from "node:http";
9
- import { Readable } from "node:stream";
9
+ import { pipeline, Readable } from "node:stream";
10
10
  var MAX_BODY = 4 * 1024 * 1024;
11
11
  var TooLarge = class extends Error {
12
12
  static {
@@ -49,8 +49,7 @@ var send = /* @__PURE__ */ __name(async (response, outgoing) => {
49
49
  if (!response.body)
50
50
  return void outgoing.end();
51
51
  const body = Readable.fromWeb(response.body);
52
- outgoing.once("close", () => body.destroy());
53
- body.pipe(outgoing);
52
+ pipeline(body, outgoing, () => void 0);
54
53
  }, "send");
55
54
  var listen = /* @__PURE__ */ __name((handle, { host, port, maxBody = MAX_BODY }) => new Promise((resolve, reject) => {
56
55
  const server = createServer((incoming, outgoing) => {
@@ -5,27 +5,27 @@ import {
5
5
  openRemote,
6
6
  remoteKey,
7
7
  remoteModel
8
- } from "./chunk-57KJ3TRS.js";
8
+ } from "./chunk-WUCTF2XE.js";
9
9
  import {
10
10
  isTextModelInstalled,
11
11
  openEmbedder,
12
12
  textModelsDirectory
13
- } from "./chunk-6A44ZZFC.js";
13
+ } from "./chunk-ZJ3S4S6H.js";
14
14
  import {
15
15
  textModel,
16
16
  vectorModelKey
17
- } from "./chunk-JKSD43L7.js";
17
+ } from "./chunk-WZCRCCOZ.js";
18
18
  import {
19
19
  endpointFetch
20
- } from "./chunk-H7ML7X3G.js";
20
+ } from "./chunk-XB6O445X.js";
21
21
  import {
22
22
  CliError
23
- } from "./chunk-LIQMUDIZ.js";
23
+ } from "./chunk-GCUFGDKE.js";
24
24
  import {
25
25
  __name
26
26
  } from "./chunk-ZVVMGPBJ.js";
27
27
 
28
- // node_modules/.pnpm/@wirecat+cli-core@0.681.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.106.0_commander@15_8d845c31697914d824aa80d8eec93941/node_modules/@wirecat/cli-core/dist/services/meeting-model.js
28
+ // node_modules/.pnpm/@wirecat+cli-core@0.718.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.126.1_commander@15_05e4e157d64d32ce6fc62270b9552a1d/node_modules/@wirecat/cli-core/dist/services/meeting-model.js
29
29
  var integer = /* @__PURE__ */ __name((value, name, max) => {
30
30
  if (!Number.isSafeInteger(value) || value < 1 || value > max)
31
31
  throw new CliError("validation_error", `Invalid ${name}`);
@@ -2,15 +2,15 @@ import { createRequire as __bundleRequire } from "node:module";
2
2
  const require = __bundleRequire(import.meta.url);
3
3
  import {
4
4
  PRAGMAS
5
- } from "./chunk-KVFUH5IT.js";
5
+ } from "./chunk-MMZ4QAKJ.js";
6
6
  import {
7
7
  CliError
8
- } from "./chunk-LIQMUDIZ.js";
8
+ } from "./chunk-GCUFGDKE.js";
9
9
  import {
10
10
  __name
11
11
  } from "./chunk-ZVVMGPBJ.js";
12
12
 
13
- // node_modules/.pnpm/@wirecat+cli-core@0.681.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.106.0_commander@15_8d845c31697914d824aa80d8eec93941/node_modules/@wirecat/cli-core/dist/store/sqlite-warning.js
13
+ // node_modules/.pnpm/@wirecat+cli-core@0.718.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.126.1_commander@15_05e4e157d64d32ce6fc62270b9552a1d/node_modules/@wirecat/cli-core/dist/store/sqlite-warning.js
14
14
  var SQLITE_WARNING = "SQLite is an experimental feature";
15
15
  var quieted = /* @__PURE__ */ new WeakSet();
16
16
  var quietSqliteWarning = /* @__PURE__ */ __name((host = process) => {
@@ -31,7 +31,7 @@ var isSqliteWarning = /* @__PURE__ */ __name((warning, options) => {
31
31
  return name === "ExperimentalWarning" && message.startsWith(SQLITE_WARNING);
32
32
  }, "isSqliteWarning");
33
33
 
34
- // node_modules/.pnpm/@wirecat+cli-core@0.681.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.106.0_commander@15_8d845c31697914d824aa80d8eec93941/node_modules/@wirecat/cli-core/dist/store/open.js
34
+ // node_modules/.pnpm/@wirecat+cli-core@0.718.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.126.1_commander@15_05e4e157d64d32ce6fc62270b9552a1d/node_modules/@wirecat/cli-core/dist/store/open.js
35
35
  var openCache = /* @__PURE__ */ __name(async (path) => {
36
36
  const database = await openFile(path);
37
37
  try {
@@ -44,12 +44,12 @@ var openCache = /* @__PURE__ */ __name(async (path) => {
44
44
  }, "openCache");
45
45
  var openFile = /* @__PURE__ */ __name((path) => "Bun" in globalThis ? openUnderBun(path) : openUnderNode(path), "openFile");
46
46
  var openUnderBun = /* @__PURE__ */ __name(async (path) => {
47
- const { openWithBunSqlite } = await import("./bun-sqlite-ZLB5RK5Q.js");
47
+ const { openWithBunSqlite } = await import("./bun-sqlite-ZNB2B2DL.js");
48
48
  return await openWithBunSqlite(path);
49
49
  }, "openUnderBun");
50
50
  var openUnderNode = /* @__PURE__ */ __name(async (path) => {
51
51
  quietSqliteWarning();
52
- const { openWithNodeSqlite } = await import("./node-sqlite-YOGH26O2.js");
52
+ const { openWithNodeSqlite } = await import("./node-sqlite-I2P26Z3S.js");
53
53
  return openWithNodeSqlite(path);
54
54
  }, "openUnderNode");
55
55
  var runtime = /* @__PURE__ */ __name(() => {
@@ -2,16 +2,16 @@ import { createRequire as __bundleRequire } from "node:module";
2
2
  const require = __bundleRequire(import.meta.url);
3
3
  import {
4
4
  alive
5
- } from "./chunk-QYLZD4DS.js";
5
+ } from "./chunk-N7F5KT6U.js";
6
6
  import {
7
7
  resolvePaths,
8
8
  writeSecurely
9
- } from "./chunk-6CHIGUCY.js";
9
+ } from "./chunk-R2G3MWEF.js";
10
10
  import {
11
11
  __name
12
12
  } from "./chunk-ZVVMGPBJ.js";
13
13
 
14
- // node_modules/.pnpm/@wirecat+cli-core@0.681.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.106.0_commander@15_8d845c31697914d824aa80d8eec93941/node_modules/@wirecat/cli-core/dist/background/lock.js
14
+ // node_modules/.pnpm/@wirecat+cli-core@0.718.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.126.1_commander@15_05e4e157d64d32ce6fc62270b9552a1d/node_modules/@wirecat/cli-core/dist/background/lock.js
15
15
  import { existsSync, linkSync, mkdirSync, readdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
16
16
  import { dirname, join } from "node:path";
17
17
  var lockPath = /* @__PURE__ */ __name((app, profile, env) => join(resolvePaths({ appName: app.appName, prefix: app.envPrefix, env }).state, "serve", `${profile}.lock`), "lockPath");
@@ -53,6 +53,17 @@ var releaseLock = /* @__PURE__ */ __name((path, pid = process.pid) => {
53
53
  if (readLock(path)?.pid === pid)
54
54
  rmSync(path, { force: true });
55
55
  }, "releaseLock");
56
+ var currentPath = /* @__PURE__ */ __name((lock) => lock.replace(/\.lock$/, ".current"), "currentPath");
57
+ var markCurrent = /* @__PURE__ */ __name((lock, at = /* @__PURE__ */ new Date()) => writeSecurely(currentPath(lock), `${JSON.stringify({ at: at.toISOString() })}
58
+ `, 384), "markCurrent");
59
+ var readCurrent = /* @__PURE__ */ __name((lock) => {
60
+ try {
61
+ const { at } = JSON.parse(readFileSync(currentPath(lock), "utf8"));
62
+ return typeof at === "string" ? at : void 0;
63
+ } catch {
64
+ return void 0;
65
+ }
66
+ }, "readCurrent");
56
67
  var servingProfiles = /* @__PURE__ */ __name((app, env) => {
57
68
  const dir = dirname(lockPath(app, "default", env));
58
69
  if (!existsSync(dir))
@@ -69,5 +80,7 @@ export {
69
80
  holdLock,
70
81
  takeLock,
71
82
  releaseLock,
83
+ markCurrent,
84
+ readCurrent,
72
85
  servingProfiles
73
86
  };
@@ -2,12 +2,12 @@ import { createRequire as __bundleRequire } from "node:module";
2
2
  const require = __bundleRequire(import.meta.url);
3
3
  import {
4
4
  CliError
5
- } from "./chunk-LIQMUDIZ.js";
5
+ } from "./chunk-GCUFGDKE.js";
6
6
  import {
7
7
  __name
8
8
  } from "./chunk-ZVVMGPBJ.js";
9
9
 
10
- // node_modules/.pnpm/@wirecat+cli-core@0.681.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.106.0_commander@15_8d845c31697914d824aa80d8eec93941/node_modules/@wirecat/cli-core/dist/files/ordinary-file.js
10
+ // node_modules/.pnpm/@wirecat+cli-core@0.718.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.126.1_commander@15_05e4e157d64d32ce6fc62270b9552a1d/node_modules/@wirecat/cli-core/dist/files/ordinary-file.js
11
11
  import { constants } from "node:fs";
12
12
  import { lstat, open } from "node:fs/promises";
13
13
  var deviceOf = /* @__PURE__ */ __name((dev) => process.platform === "win32" ? BigInt.asUintN(32, dev) : dev, "deviceOf");
@@ -73,7 +73,7 @@ var syncDirectory = /* @__PURE__ */ __name(async (path) => {
73
73
  }
74
74
  }, "syncDirectory");
75
75
 
76
- // node_modules/.pnpm/@wirecat+cli-core@0.681.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.106.0_commander@15_8d845c31697914d824aa80d8eec93941/node_modules/@wirecat/cli-core/dist/files/atomic-write.js
76
+ // node_modules/.pnpm/@wirecat+cli-core@0.718.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.126.1_commander@15_05e4e157d64d32ce6fc62270b9552a1d/node_modules/@wirecat/cli-core/dist/files/atomic-write.js
77
77
  import { randomUUID } from "node:crypto";
78
78
  import { constants as constants2 } from "node:fs";
79
79
  import { link, open as open2, realpath, rename, unlink } from "node:fs/promises";
@@ -111,7 +111,7 @@ var writeFileAtomic = /* @__PURE__ */ __name(async (path, content, { mode = 384,
111
111
  }
112
112
  }, "writeFileAtomic");
113
113
 
114
- // node_modules/.pnpm/@wirecat+cli-core@0.681.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.106.0_commander@15_8d845c31697914d824aa80d8eec93941/node_modules/@wirecat/cli-core/dist/files/bounded-utf8.js
114
+ // node_modules/.pnpm/@wirecat+cli-core@0.718.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.126.1_commander@15_05e4e157d64d32ce6fc62270b9552a1d/node_modules/@wirecat/cli-core/dist/files/bounded-utf8.js
115
115
  var readBoundedUtf8File = /* @__PURE__ */ __name(async (path, { maxBytes }) => {
116
116
  if (!Number.isSafeInteger(maxBytes) || maxBytes < 1 || maxBytes > 16 * 1024 * 1024)
117
117
  throw new CliError("validation_error", "file maxBytes takes 1\u201316777216 bytes");
@@ -140,21 +140,21 @@ var readBoundedUtf8File = /* @__PURE__ */ __name(async (path, { maxBytes }) => {
140
140
  }
141
141
  }, "readBoundedUtf8File");
142
142
 
143
- // node_modules/.pnpm/@wirecat+cli-core@0.681.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.106.0_commander@15_8d845c31697914d824aa80d8eec93941/node_modules/@wirecat/cli-core/dist/files/lock.js
143
+ // node_modules/.pnpm/@wirecat+cli-core@0.718.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.126.1_commander@15_05e4e157d64d32ce6fc62270b9552a1d/node_modules/@wirecat/cli-core/dist/files/lock.js
144
144
  import { mkdir as mkdir2 } from "node:fs/promises";
145
145
  import { basename as basename2, dirname as dirname2 } from "node:path";
146
146
 
147
- // node_modules/.pnpm/@wirecat+cli-core@0.681.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.106.0_commander@15_8d845c31697914d824aa80d8eec93941/node_modules/@wirecat/cli-core/dist/files/native-writer-lease.js
147
+ // node_modules/.pnpm/@wirecat+cli-core@0.718.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.126.1_commander@15_05e4e157d64d32ce6fc62270b9552a1d/node_modules/@wirecat/cli-core/dist/files/native-writer-lease.js
148
148
  import { randomUUID as randomUUID2 } from "node:crypto";
149
149
  import { lstat as lstat3, mkdir, open as open3, realpath as realpath3, rmdir as rmdir2, unlink as unlink4 } from "node:fs/promises";
150
150
  import { hostname as hostname2 } from "node:os";
151
151
  import { join as join3 } from "node:path";
152
152
 
153
- // node_modules/.pnpm/@wirecat+cli-core@0.681.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.106.0_commander@15_8d845c31697914d824aa80d8eec93941/node_modules/@wirecat/cli-core/dist/files/native-lease-inspection.js
153
+ // node_modules/.pnpm/@wirecat+cli-core@0.718.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.126.1_commander@15_05e4e157d64d32ce6fc62270b9552a1d/node_modules/@wirecat/cli-core/dist/files/native-lease-inspection.js
154
154
  import { lstat as lstat2, readdir, realpath as realpath2, unlink as unlink2 } from "node:fs/promises";
155
155
  import { join as join2 } from "node:path";
156
156
 
157
- // node_modules/.pnpm/@wirecat+cli-core@0.681.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.106.0_commander@15_8d845c31697914d824aa80d8eec93941/node_modules/@wirecat/cli-core/dist/files/native-lease-owner.js
157
+ // node_modules/.pnpm/@wirecat+cli-core@0.718.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.126.1_commander@15_05e4e157d64d32ce6fc62270b9552a1d/node_modules/@wirecat/cli-core/dist/files/native-lease-owner.js
158
158
  import { hostname } from "node:os";
159
159
  var missingLeaseFile = /* @__PURE__ */ __name((error) => typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT", "missingLeaseFile");
160
160
  var readLeaseOwner = /* @__PURE__ */ __name(async (path, name, signal) => {
@@ -199,7 +199,7 @@ var leaseOwnerStatus = /* @__PURE__ */ __name((owner) => {
199
199
  }
200
200
  }, "leaseOwnerStatus");
201
201
 
202
- // node_modules/.pnpm/@wirecat+cli-core@0.681.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.106.0_commander@15_8d845c31697914d824aa80d8eec93941/node_modules/@wirecat/cli-core/dist/files/native-lease-inspection.js
202
+ // node_modules/.pnpm/@wirecat+cli-core@0.718.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.126.1_commander@15_05e4e157d64d32ce6fc62270b9552a1d/node_modules/@wirecat/cli-core/dist/files/native-lease-inspection.js
203
203
  var leaseInspection = /* @__PURE__ */ __name((markerDirectory) => {
204
204
  const inspect = /* @__PURE__ */ __name(async (destination, options = {}) => {
205
205
  options.signal?.throwIfAborted();
@@ -258,7 +258,7 @@ var leaseInspection = /* @__PURE__ */ __name((markerDirectory) => {
258
258
  return { inspect, recover };
259
259
  }, "leaseInspection");
260
260
 
261
- // node_modules/.pnpm/@wirecat+cli-core@0.681.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.106.0_commander@15_8d845c31697914d824aa80d8eec93941/node_modules/@wirecat/cli-core/dist/files/native-lease-release.js
261
+ // node_modules/.pnpm/@wirecat+cli-core@0.718.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.126.1_commander@15_05e4e157d64d32ce6fc62270b9552a1d/node_modules/@wirecat/cli-core/dist/files/native-lease-release.js
262
262
  import { rmdir, unlink as unlink3 } from "node:fs/promises";
263
263
  var ownedNativeLease = /* @__PURE__ */ __name((path, name, owner, folder, identity) => {
264
264
  let releasing;
@@ -283,7 +283,7 @@ var ownedNativeLease = /* @__PURE__ */ __name((path, name, owner, folder, identi
283
283
  };
284
284
  }, "ownedNativeLease");
285
285
 
286
- // node_modules/.pnpm/@wirecat+cli-core@0.681.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.106.0_commander@15_8d845c31697914d824aa80d8eec93941/node_modules/@wirecat/cli-core/dist/files/native-writer-lease.js
286
+ // node_modules/.pnpm/@wirecat+cli-core@0.718.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.126.1_commander@15_05e4e157d64d32ce6fc62270b9552a1d/node_modules/@wirecat/cli-core/dist/files/native-writer-lease.js
287
287
  var validName = /* @__PURE__ */ __name((value) => typeof value === "string" && value.length > 0 && value !== "." && value !== ".." && !/[\\/\0:]/.test(value), "validName");
288
288
  var nativeWriterLeaseStore = /* @__PURE__ */ __name((layout) => {
289
289
  const { markerDirectory, legacyMarker } = layout;
@@ -354,7 +354,7 @@ var nativeWriterLeaseStore = /* @__PURE__ */ __name((layout) => {
354
354
  };
355
355
  }, "nativeWriterLeaseStore");
356
356
 
357
- // node_modules/.pnpm/@wirecat+cli-core@0.681.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.106.0_commander@15_8d845c31697914d824aa80d8eec93941/node_modules/@wirecat/cli-core/dist/files/lock.js
357
+ // node_modules/.pnpm/@wirecat+cli-core@0.718.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.126.1_commander@15_05e4e157d64d32ce6fc62270b9552a1d/node_modules/@wirecat/cli-core/dist/files/lock.js
358
358
  var acquireLock = /* @__PURE__ */ __name(async (path, { signal } = {}) => {
359
359
  const folder = dirname2(path);
360
360
  await mkdir2(folder, { recursive: true, mode: 448 });
@@ -369,8 +369,23 @@ var acquireLock = /* @__PURE__ */ __name(async (path, { signal } = {}) => {
369
369
  });
370
370
  }, "acquireLock");
371
371
 
372
- // node_modules/.pnpm/@wirecat+cli-core@0.681.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.106.0_commander@15_8d845c31697914d824aa80d8eec93941/node_modules/@wirecat/cli-core/dist/files/safe-name.js
373
- import { basename as basename3 } from "node:path";
372
+ // node_modules/.pnpm/@wirecat+cli-core@0.718.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.126.1_commander@15_05e4e157d64d32ce6fc62270b9552a1d/node_modules/@wirecat/cli-core/dist/files/safe-name.js
373
+ import { basename as basename3, extname } from "node:path";
374
+ var MOST_NAME_BYTES = 200;
375
+ var bytesOf = /* @__PURE__ */ __name((text) => Buffer.byteLength(text, "utf8"), "bytesOf");
376
+ var shortened = /* @__PURE__ */ __name((name, most) => {
377
+ if (bytesOf(name) <= most)
378
+ return name;
379
+ const extension = extname(name);
380
+ const kept = bytesOf(extension) <= 32 ? extension : "";
381
+ let stem = "";
382
+ for (const character of name.slice(0, name.length - kept.length)) {
383
+ if (bytesOf(stem + character) + bytesOf(kept) > most)
384
+ break;
385
+ stem += character;
386
+ }
387
+ return stem + kept;
388
+ }, "shortened");
374
389
  var safeName = /* @__PURE__ */ __name((name, platform = process.platform) => {
375
390
  let plain = name === void 0 ? "" : basename3(name.replaceAll("\\", "/")).replace(/[\p{Cc}​-‏‪-‮⁦-⁩]/gu, "").replace(/^\.+/, "");
376
391
  if (platform === "win32") {
@@ -378,7 +393,7 @@ var safeName = /* @__PURE__ */ __name((name, platform = process.platform) => {
378
393
  if (/^(con|prn|aux|nul|com[1-9]|lpt[1-9])(?:\.|$)/i.test(plain))
379
394
  return void 0;
380
395
  }
381
- return plain === "" ? void 0 : plain;
396
+ return plain === "" ? void 0 : shortened(plain, MOST_NAME_BYTES);
382
397
  }, "safeName");
383
398
 
384
399
  export {
@@ -2,11 +2,11 @@ import { createRequire as __bundleRequire } from "node:module";
2
2
  const require = __bundleRequire(import.meta.url);
3
3
  import {
4
4
  openCache
5
- } from "./chunk-IYAXLLGR.js";
5
+ } from "./chunk-7GWOGEWJ.js";
6
6
  import {
7
7
  CliError,
8
8
  isCliError
9
- } from "./chunk-LIQMUDIZ.js";
9
+ } from "./chunk-GCUFGDKE.js";
10
10
  import {
11
11
  __name
12
12
  } from "./chunk-ZVVMGPBJ.js";
@@ -4,7 +4,7 @@ import {
4
4
  __name
5
5
  } from "./chunk-ZVVMGPBJ.js";
6
6
 
7
- // node_modules/.pnpm/@wirecat+cli-core@0.681.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.106.0_commander@15_8d845c31697914d824aa80d8eec93941/node_modules/@wirecat/cli-core/dist/mcp/instructions.js
7
+ // node_modules/.pnpm/@wirecat+cli-core@0.718.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.126.1_commander@15_05e4e157d64d32ce6fc62270b9552a1d/node_modules/@wirecat/cli-core/dist/mcp/instructions.js
8
8
  var instructions = /* @__PURE__ */ __name(({ command, name, profile, writes, skill }) => {
9
9
  const all = typeof profile !== "string";
10
10
  const offers = /* @__PURE__ */ __name((key) => all || writes.includes(key), "offers");