@wirecat/tg-cli 0.107.0 → 0.109.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 (102) hide show
  1. package/dist/bin/tg.js +2 -2
  2. package/dist/bundle/{adapter-PN5AXCJ7.js → adapter-6JLFYFL5.js} +45 -44
  3. package/dist/bundle/{all-profiles-SDHNKZQQ.js → all-profiles-X7Y3T5S4.js} +8 -8
  4. package/dist/bundle/{anthropic-F3BXQLYB.js → anthropic-LGVXAADT.js} +5 -5
  5. package/dist/bundle/{app-server-XDKMWVCD.js → app-server-UI3AFSJX.js} +40 -39
  6. package/dist/bundle/{bot-api-YXJL4CEV.js → bot-api-TQYRNYJQ.js} +46 -45
  7. package/dist/bundle/{bot-history-SDLHR7PV.js → bot-history-DDNTNMNB.js} +15 -15
  8. package/dist/bundle/{bun-SMH7PKUS.js → bun-WXGS6HML.js} +2 -2
  9. package/dist/bundle/{bun-sqlite-KB6PSTWH.js → bun-sqlite-M6JEXKRT.js} +4 -4
  10. package/dist/bundle/{chunk-NCWB3KXP.js → chunk-25VC6U3A.js} +1 -1
  11. package/dist/bundle/{chunk-NUVHRCUK.js → chunk-2ILQYCBY.js} +390 -291
  12. package/dist/bundle/{chunk-X7M7YZPF.js → chunk-3PEZWXKO.js} +6 -6
  13. package/dist/bundle/{chunk-YSDA3EWT.js → chunk-4R4AH6FM.js} +117 -94
  14. package/dist/bundle/{chunk-TEHAIU6I.js → chunk-5SUFMBU5.js} +44 -44
  15. package/dist/bundle/chunk-76C5SSMR.js +379 -0
  16. package/dist/bundle/{chunk-STGY3EAZ.js → chunk-7AJ2IESO.js} +1 -1
  17. package/dist/bundle/{chunk-3UEFJ75D.js → chunk-7T7ILNCU.js} +2 -2
  18. package/dist/bundle/{chunk-O7VQHFMZ.js → chunk-AD3QPYI3.js} +2 -2
  19. package/dist/bundle/{chunk-IY7IEM56.js → chunk-AGVKIJB7.js} +6 -6
  20. package/dist/bundle/{chunk-OIHAM73W.js → chunk-BESIMQ5U.js} +1 -1
  21. package/dist/bundle/{chunk-CJJVFGFX.js → chunk-BHPCZCX7.js} +2 -2
  22. package/dist/bundle/{chunk-GJS26XEB.js → chunk-BZIZLEJN.js} +4 -4
  23. package/dist/bundle/{chunk-REJM262E.js → chunk-C3RX3UOE.js} +11 -11
  24. package/dist/bundle/{chunk-WXIGT6FY.js → chunk-CH2ESVV5.js} +22 -22
  25. package/dist/bundle/{chunk-DFZBGU4G.js → chunk-CHI6D4D6.js} +4 -4
  26. package/dist/bundle/{chunk-BYDDYOF4.js → chunk-CVLDXFRP.js} +8 -8
  27. package/dist/bundle/{chunk-MFS52LTZ.js → chunk-DLAFGSTN.js} +1 -1
  28. package/dist/bundle/{chunk-P4A27ETD.js → chunk-DO33KAMM.js} +94 -59
  29. package/dist/bundle/{chunk-GGAG3G7B.js → chunk-DZVYGBZB.js} +79 -56
  30. package/dist/bundle/{chunk-WAGDZB62.js → chunk-GUFM5RLW.js} +2 -2
  31. package/dist/bundle/{chunk-LA2OUJK5.js → chunk-IGIPIO4J.js} +11 -11
  32. package/dist/bundle/{chunk-5QBTHR57.js → chunk-INYO2QFW.js} +3 -3
  33. package/dist/bundle/{chunk-VMKPRAIB.js → chunk-IULYECPC.js} +12 -12
  34. package/dist/bundle/{chunk-DBZVF73F.js → chunk-IV2QWSPG.js} +2 -2
  35. package/dist/bundle/{chunk-YA44IPCS.js → chunk-KHKC236O.js} +2 -2
  36. package/dist/bundle/{chunk-TKCZYJAT.js → chunk-M62LF3QE.js} +2140 -1648
  37. package/dist/bundle/{chunk-RGNKRI5T.js → chunk-MF6NKU3Z.js} +81 -30
  38. package/dist/bundle/{chunk-MOZX3JX3.js → chunk-N56WXUCW.js} +2 -2
  39. package/dist/bundle/{chunk-T4SDOYPY.js → chunk-N5FSRC6H.js} +117 -70
  40. package/dist/bundle/{chunk-FG2QTYEF.js → chunk-NAVNCM5K.js} +1 -1
  41. package/dist/bundle/{chunk-NMTFZNFU.js → chunk-OHLMHBDI.js} +28 -28
  42. package/dist/bundle/{chunk-P5UG655O.js → chunk-P55L4S6N.js} +3 -3
  43. package/dist/bundle/{chunk-JZOXKRDG.js → chunk-P57R2P75.js} +7 -7
  44. package/dist/bundle/{chunk-BMXGEQDA.js → chunk-P5ILJ7MN.js} +5 -5
  45. package/dist/bundle/{chunk-PYRJO6B3.js → chunk-QQF7RDLR.js} +49 -24
  46. package/dist/bundle/{chunk-TFV4UPQZ.js → chunk-RD2NLJSU.js} +16 -4
  47. package/dist/bundle/{chunk-KROO42KC.js → chunk-S7B6MTXX.js} +6 -6
  48. package/dist/bundle/{chunk-NSQL3YRD.js → chunk-SH63Q4QR.js} +22 -22
  49. package/dist/bundle/{chunk-JAWXJILO.js → chunk-TMXNMO66.js} +3 -3
  50. package/dist/bundle/{chunk-44UANKAI.js → chunk-UIPBAT2T.js} +31 -14
  51. package/dist/bundle/{chunk-53RW4KLL.js → chunk-UUQ3BH2Z.js} +2 -2
  52. package/dist/bundle/{chunk-VMU4SGCE.js → chunk-VFVMB3NV.js} +8 -6
  53. package/dist/bundle/{chunk-AWBJSYX6.js → chunk-VYR2IIWW.js} +1 -1
  54. package/dist/bundle/{chunk-53QVFV34.js → chunk-WHYS6OSG.js} +2 -2
  55. package/dist/bundle/{chunk-WS3S7DXT.js → chunk-WNTXIQMB.js} +2 -2
  56. package/dist/bundle/{chunk-P5KMLJQR.js → chunk-XJVGCCQE.js} +666 -782
  57. package/dist/bundle/{chunk-67SRVSPU.js → chunk-XMMWKHNY.js} +26 -9
  58. package/dist/bundle/{chunk-A4DS5ANQ.js → chunk-YXCQ4DLZ.js} +1 -1
  59. package/dist/bundle/{chunk-465FPHSG.js → chunk-YYOIULA2.js} +8 -8
  60. package/dist/bundle/{chunk-WFG7KFM4.js → chunk-ZFMS5G4H.js} +2 -2
  61. package/dist/bundle/{chunk-BGVODG6P.js → chunk-ZHP44EML.js} +3 -3
  62. package/dist/bundle/{chunk-6FSG6QZH.js → chunk-ZMZKZL3Y.js} +1 -1
  63. package/dist/bundle/{chunk-H4LIQVPN.js → chunk-ZUOS7QUB.js} +11 -11
  64. package/dist/bundle/command-contract-E2MWR3T3.js +32 -0
  65. package/dist/bundle/{decode-WEP3HD56.js → decode-RKPOGPBE.js} +19 -17
  66. package/dist/bundle/{echarts-MRMILSAF.js → echarts-H5QQRBHI.js} +2 -2
  67. package/dist/bundle/{embed-LCLTUVUD.js → embed-7TVAPNP7.js} +5 -5
  68. package/dist/bundle/{embedder-O4WNEXUC.js → embedder-YOOHWWN6.js} +8 -8
  69. package/dist/bundle/{entry-7HDX6BDR.js → entry-SAKW5HEZ.js} +5 -5
  70. package/dist/bundle/{first-run-M7YVVQJS.js → first-run-C744N572.js} +9 -9
  71. package/dist/bundle/first-screen-7GKUEIWS.js +30 -0
  72. package/dist/bundle/{identity-EEMHQOTN.js → identity-NRWTZIQ4.js} +3 -3
  73. package/dist/bundle/{instructions-YIH3J4TI.js → instructions-6LWRAW47.js} +1 -1
  74. package/dist/bundle/{mcp-OQBZXELQ.js → mcp-WSGVVZWI.js} +2 -2
  75. package/dist/bundle/{node-YWT7RFN6.js → node-XN4PIVWW.js} +2 -2
  76. package/dist/bundle/node-sqlite-PCBGROGQ.js +62 -0
  77. package/dist/bundle/{oauth-CADZB7TT.js → oauth-PX6NGHUV.js} +6 -6
  78. package/dist/bundle/{open-AMRU27KK.js → open-BKJGJ6GX.js} +3 -3
  79. package/dist/bundle/openai-MJP7CZXP.js +250 -0
  80. package/dist/bundle/{process-JC76J5UD.js → process-4PRR3MLT.js} +1 -1
  81. package/dist/bundle/{program-FI6MTY2V.js → program-7YZUO42B.js} +48 -47
  82. package/dist/bundle/{prompt-SPYTHKHN.js → prompt-CILSZC2R.js} +4 -4
  83. package/dist/bundle/{proxy-transport-YSBYG26I.js → proxy-transport-FWGKTYBL.js} +4 -4
  84. package/dist/bundle/{recognize-G5VVM6MU.js → recognize-AVFDJAIL.js} +5 -3
  85. package/dist/bundle/{remote-Z3HW42CH.js → remote-2VYXGOM4.js} +6 -6
  86. package/dist/bundle/{rerank-QJ5NLZUU.js → rerank-6FU2JPCD.js} +6 -6
  87. package/dist/bundle/{serve-3I4C6Y5X.js → serve-3YQOHBR6.js} +8 -8
  88. package/dist/bundle/server-S2K4YDDG.js +56 -0
  89. package/dist/bundle/{server-2L4BONHN.js → server-TPK3LNEX.js} +32 -31
  90. package/dist/bundle/{state-IXZYPH46.js → state-LLUNBLZE.js} +5 -5
  91. package/dist/bundle/{store-KS4XIA2R.js → store-27FQ743G.js} +10 -10
  92. package/dist/bundle/store-maintenance-command-AFJMKEBK.js +45 -0
  93. package/dist/bundle/tg.js +4 -4
  94. package/dist/version.d.ts +1 -1
  95. package/dist/version.js +1 -1
  96. package/package.json +3 -3
  97. package/dist/bundle/command-contract-B4DA4MXP.js +0 -32
  98. package/dist/bundle/first-screen-MXW3UZFB.js +0 -30
  99. package/dist/bundle/node-sqlite-LVHTONMA.js +0 -46
  100. package/dist/bundle/server-7TJ337SR.js +0 -55
  101. package/dist/bundle/store-maintenance-command-I3L24P22.js +0 -44
  102. /package/dist/bundle/{chunk-O5EHUB2V.js → chunk-62EDJKGP.js} +0 -0
@@ -0,0 +1,379 @@
1
+ import { createRequire as __bundleRequire } from "node:module";
2
+ const require = __bundleRequire(import.meta.url);
3
+ import {
4
+ CliError
5
+ } from "./chunk-XMMWKHNY.js";
6
+ import {
7
+ __name
8
+ } from "./chunk-ZVVMGPBJ.js";
9
+
10
+ // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/files/ordinary-file.js
11
+ import { constants } from "node:fs";
12
+ import { lstat, open } from "node:fs/promises";
13
+ var deviceOf = /* @__PURE__ */ __name((dev) => process.platform === "win32" ? BigInt.asUintN(32, dev) : dev, "deviceOf");
14
+ var sameIdentity = /* @__PURE__ */ __name((left, right) => left.ino === right.ino && deviceOf(left.dev) === deviceOf(right.dev), "sameIdentity");
15
+ var openOrdinaryFile = /* @__PURE__ */ __name(async (path, options = {}) => {
16
+ const before = await lstat(path, { bigint: true });
17
+ if (before.isSymbolicLink())
18
+ throw new CliError("validation_error", "archive path must be an ordinary file without a symlink");
19
+ if (!before.isFile())
20
+ throw new CliError("validation_error", "archive path must be an ordinary file");
21
+ const access = options.writable ? constants.O_RDWR : constants.O_RDONLY;
22
+ const flags = process.platform === "win32" ? access : access | (constants.O_NOFOLLOW ?? 0) | (constants.O_NONBLOCK ?? 0);
23
+ const file = await open(path, flags);
24
+ try {
25
+ const opened = await file.stat({ bigint: true });
26
+ const after = await lstat(path, { bigint: true });
27
+ if (!opened.isFile() || !after.isFile() || before.ino !== opened.ino || before.ino !== after.ino)
28
+ throw new CliError("validation_error", "archive file changed while opening");
29
+ if (process.platform === "win32" && before.dev === 0n && after.dev === 0n) {
30
+ const witness = await open(path, flags);
31
+ try {
32
+ const identified = await witness.stat({ bigint: true });
33
+ const final = await lstat(path, { bigint: true });
34
+ if (opened.dev === 0n || !identified.isFile() || !final.isFile() || !sameIdentity(identified, opened) || final.ino !== before.ino || final.dev !== 0n && deviceOf(final.dev) !== deviceOf(opened.dev))
35
+ throw new CliError("validation_error", "archive file changed while opening");
36
+ } finally {
37
+ await witness.close();
38
+ }
39
+ } else if (deviceOf(before.dev) !== deviceOf(opened.dev) || deviceOf(before.dev) !== deviceOf(after.dev)) {
40
+ throw new CliError("validation_error", "archive file changed while opening");
41
+ }
42
+ return file;
43
+ } catch (error) {
44
+ await file.close();
45
+ throw error;
46
+ }
47
+ }, "openOrdinaryFile");
48
+ var sameOrdinaryFile = /* @__PURE__ */ __name(async (path, created) => {
49
+ let file;
50
+ try {
51
+ file = await openOrdinaryFile(path);
52
+ } catch (error) {
53
+ if (error instanceof CliError || typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT")
54
+ return false;
55
+ throw error;
56
+ }
57
+ try {
58
+ return sameIdentity(created, await file.stat({ bigint: true }));
59
+ } finally {
60
+ await file.close();
61
+ }
62
+ }, "sameOrdinaryFile");
63
+ var syncDirectory = /* @__PURE__ */ __name(async (path) => {
64
+ if (process.platform === "win32")
65
+ return;
66
+ const directory = await open(path, constants.O_RDONLY | (constants.O_DIRECTORY ?? 0) | (constants.O_NOFOLLOW ?? 0));
67
+ try {
68
+ if (!(await directory.stat()).isDirectory())
69
+ throw new CliError("validation_error", "archive publication directory must be ordinary");
70
+ await directory.sync();
71
+ } finally {
72
+ await directory.close();
73
+ }
74
+ }, "syncDirectory");
75
+
76
+ // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/files/atomic-write.js
77
+ import { randomUUID } from "node:crypto";
78
+ import { constants as constants2 } from "node:fs";
79
+ import { link, open as open2, realpath, rename, unlink } from "node:fs/promises";
80
+ import { basename, dirname, join } from "node:path";
81
+ var openFolder = /* @__PURE__ */ __name((folder) => process.platform === "win32" ? Promise.resolve(void 0) : open2(folder, constants2.O_RDONLY | (constants2.O_DIRECTORY ?? 0) | (constants2.O_NOFOLLOW ?? 0)), "openFolder");
82
+ var writeFileAtomic = /* @__PURE__ */ __name(async (path, content, { mode = 384, overwrite = true, signal, beforePublish } = {}) => {
83
+ signal?.throwIfAborted();
84
+ const folder = await realpath(dirname(path));
85
+ const target = join(folder, basename(path));
86
+ const directory = await openFolder(folder);
87
+ try {
88
+ const temporary = join(folder, `.${basename(path)}.${randomUUID()}.tmp`);
89
+ let handle = await open2(temporary, "wx", mode);
90
+ let published = false;
91
+ try {
92
+ await handle.writeFile(content);
93
+ await handle.sync();
94
+ await handle.close();
95
+ handle = void 0;
96
+ signal?.throwIfAborted();
97
+ await beforePublish?.();
98
+ if (overwrite)
99
+ await rename(temporary, target);
100
+ else
101
+ await link(temporary, target);
102
+ published = overwrite;
103
+ await directory?.sync();
104
+ } finally {
105
+ await handle?.close().catch(() => void 0);
106
+ if (!published)
107
+ await unlink(temporary).catch(() => void 0);
108
+ }
109
+ } finally {
110
+ await directory?.close().catch(() => void 0);
111
+ }
112
+ }, "writeFileAtomic");
113
+
114
+ // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/files/bounded-utf8.js
115
+ var readBoundedUtf8File = /* @__PURE__ */ __name(async (path, { maxBytes }) => {
116
+ if (!Number.isSafeInteger(maxBytes) || maxBytes < 1 || maxBytes > 16 * 1024 * 1024)
117
+ throw new CliError("validation_error", "file maxBytes takes 1\u201316777216 bytes");
118
+ const file = await openOrdinaryFile(path);
119
+ try {
120
+ if ((await file.stat()).size > maxBytes)
121
+ throw new CliError("validation_error", "input file exceeds its byte budget");
122
+ const chunks = [], buffer = Buffer.alloc(Math.min(65536, maxBytes + 1));
123
+ let bytes = 0;
124
+ for (; ; ) {
125
+ const { bytesRead } = await file.read(buffer, 0, Math.min(buffer.length, maxBytes - bytes + 1), null);
126
+ if (bytesRead === 0)
127
+ break;
128
+ bytes += bytesRead;
129
+ if (bytes > maxBytes)
130
+ throw new CliError("validation_error", "input file exceeds its byte budget");
131
+ chunks.push(Buffer.from(buffer.subarray(0, bytesRead)));
132
+ }
133
+ try {
134
+ return new TextDecoder("utf-8", { fatal: true }).decode(Buffer.concat(chunks, bytes));
135
+ } catch {
136
+ throw new CliError("validation_error", "input file must contain valid UTF-8");
137
+ }
138
+ } finally {
139
+ await file.close();
140
+ }
141
+ }, "readBoundedUtf8File");
142
+
143
+ // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/files/lock.js
144
+ import { mkdir as mkdir2 } from "node:fs/promises";
145
+ import { basename as basename2, dirname as dirname2 } from "node:path";
146
+
147
+ // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/files/native-writer-lease.js
148
+ import { randomUUID as randomUUID2 } from "node:crypto";
149
+ import { lstat as lstat3, mkdir, open as open3, realpath as realpath3, rmdir as rmdir2, unlink as unlink4 } from "node:fs/promises";
150
+ import { hostname as hostname2 } from "node:os";
151
+ import { join as join3 } from "node:path";
152
+
153
+ // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/files/native-lease-inspection.js
154
+ import { lstat as lstat2, readdir, realpath as realpath2, unlink as unlink2 } from "node:fs/promises";
155
+ import { join as join2 } from "node:path";
156
+
157
+ // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/files/native-lease-owner.js
158
+ import { hostname } from "node:os";
159
+ var missingLeaseFile = /* @__PURE__ */ __name((error) => typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT", "missingLeaseFile");
160
+ var readLeaseOwner = /* @__PURE__ */ __name(async (path, name, signal) => {
161
+ signal?.throwIfAborted();
162
+ try {
163
+ const file = await openOrdinaryFile(path);
164
+ try {
165
+ if ((await file.stat()).size > 4096)
166
+ return null;
167
+ const buffer = Buffer.alloc(4097);
168
+ let size = 0;
169
+ while (size < buffer.length) {
170
+ signal?.throwIfAborted();
171
+ const { bytesRead } = await file.read(buffer, size, buffer.length - size, size);
172
+ if (bytesRead === 0)
173
+ break;
174
+ size += bytesRead;
175
+ }
176
+ signal?.throwIfAborted();
177
+ if (size > 4096)
178
+ return null;
179
+ const owner = JSON.parse(buffer.subarray(0, size).toString("utf8"));
180
+ if (owner?.version !== 1 || !Number.isSafeInteger(owner.pid) || owner.pid <= 0 || typeof owner.host !== "string" || !owner.host.trim() || !/^[a-f0-9-]{36}$/.test(owner.nonce) || name !== `${owner.pid}-${owner.nonce}.json`)
181
+ return null;
182
+ return owner;
183
+ } finally {
184
+ await file.close();
185
+ }
186
+ } catch {
187
+ signal?.throwIfAborted();
188
+ return null;
189
+ }
190
+ }, "readLeaseOwner");
191
+ var leaseOwnerStatus = /* @__PURE__ */ __name((owner) => {
192
+ if (owner.host !== hostname())
193
+ return "foreign";
194
+ try {
195
+ process.kill(owner.pid, 0);
196
+ return "active";
197
+ } catch (error) {
198
+ return typeof error === "object" && error !== null && "code" in error && error.code === "ESRCH" ? "stale" : "active";
199
+ }
200
+ }, "leaseOwnerStatus");
201
+
202
+ // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/files/native-lease-inspection.js
203
+ var leaseInspection = /* @__PURE__ */ __name((markerDirectory) => {
204
+ const inspect = /* @__PURE__ */ __name(async (destination, options = {}) => {
205
+ options.signal?.throwIfAborted();
206
+ const root = await realpath2(destination);
207
+ options.signal?.throwIfAborted();
208
+ const folder = join2(root, markerDirectory);
209
+ let names;
210
+ try {
211
+ if ((await lstat2(folder)).isSymbolicLink())
212
+ throw new Error("symlink");
213
+ names = await readdir(folder);
214
+ } catch (error) {
215
+ options.signal?.throwIfAborted();
216
+ if (missingLeaseFile(error))
217
+ return [];
218
+ throw new CliError("configuration_error", "archive lock directory could not be read");
219
+ }
220
+ options.signal?.throwIfAborted();
221
+ const result = [];
222
+ for (const name of names.sort()) {
223
+ options.signal?.throwIfAborted();
224
+ const owner = await readLeaseOwner(join2(folder, name), name, options.signal);
225
+ result.push({
226
+ name,
227
+ status: owner ? leaseOwnerStatus(owner) : "unrecognized",
228
+ pid: owner?.pid ?? null,
229
+ host: owner?.host ?? null
230
+ });
231
+ }
232
+ return result;
233
+ }, "inspect");
234
+ const recover = /* @__PURE__ */ __name(async (destination, options = {}) => {
235
+ options.signal?.throwIfAborted();
236
+ const root = await realpath2(destination);
237
+ const locks = await inspect(root, options);
238
+ const removed = [];
239
+ if (options.apply)
240
+ for (const lock of locks) {
241
+ options.signal?.throwIfAborted();
242
+ if (lock.status !== "stale")
243
+ continue;
244
+ const path = join2(root, markerDirectory, lock.name);
245
+ const owner = await readLeaseOwner(path, lock.name, options.signal);
246
+ if (!owner || leaseOwnerStatus(owner) !== "stale")
247
+ continue;
248
+ try {
249
+ await unlink2(path);
250
+ removed.push(lock.name);
251
+ } catch (error) {
252
+ if (!missingLeaseFile(error))
253
+ throw new CliError("configuration_error", "stale archive lock could not be removed");
254
+ }
255
+ }
256
+ return { locks, removed };
257
+ }, "recover");
258
+ return { inspect, recover };
259
+ }, "leaseInspection");
260
+
261
+ // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/files/native-lease-release.js
262
+ import { rmdir, unlink as unlink3 } from "node:fs/promises";
263
+ var ownedNativeLease = /* @__PURE__ */ __name((path, name, owner, folder, identity) => {
264
+ let releasing;
265
+ const held = /* @__PURE__ */ __name(async () => {
266
+ if (!await sameOrdinaryFile(path, identity))
267
+ return false;
268
+ const current = await readLeaseOwner(path, name);
269
+ return current?.host === owner.host && current.pid === owner.pid && current.nonce === owner.nonce;
270
+ }, "held");
271
+ const release = /* @__PURE__ */ __name(async () => {
272
+ if (!await held())
273
+ throw new CliError("configuration_error", "owned archive lock changed before release");
274
+ await unlink3(path);
275
+ await rmdir(folder).catch(() => void 0);
276
+ }, "release");
277
+ return {
278
+ held,
279
+ release: /* @__PURE__ */ __name(() => releasing ??= release().catch((error) => {
280
+ releasing = void 0;
281
+ throw error;
282
+ }), "release")
283
+ };
284
+ }, "ownedNativeLease");
285
+
286
+ // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/files/native-writer-lease.js
287
+ var validName = /* @__PURE__ */ __name((value) => typeof value === "string" && value.length > 0 && value !== "." && value !== ".." && !/[\\/\0:]/.test(value), "validName");
288
+ var nativeWriterLeaseStore = /* @__PURE__ */ __name((layout) => {
289
+ const { markerDirectory, legacyMarker } = layout;
290
+ if (!validName(markerDirectory) || legacyMarker !== void 0 && (!validName(legacyMarker) || legacyMarker === markerDirectory))
291
+ throw new CliError("validation_error", "archive lock layout requires distinct ordinary entry names");
292
+ const inspection = leaseInspection(markerDirectory);
293
+ return {
294
+ ...inspection,
295
+ acquire: /* @__PURE__ */ __name(async (destination, { signal } = {}) => {
296
+ signal?.throwIfAborted();
297
+ const root = await realpath3(destination);
298
+ signal?.throwIfAborted();
299
+ const folder = join3(root, markerDirectory);
300
+ const owner = { version: 1, pid: process.pid, host: hostname2(), nonce: randomUUID2() };
301
+ const name = `${owner.pid}-${owner.nonce}.json`;
302
+ const path = join3(folder, name);
303
+ const marker = /* @__PURE__ */ __name(async (attempt = 1) => {
304
+ await mkdir(folder, { recursive: true });
305
+ try {
306
+ if ((await lstat3(folder)).isSymbolicLink())
307
+ throw new CliError("validation_error", "archive lock directory must not be a symlink");
308
+ await inspection.recover(root, { apply: true, signal });
309
+ signal?.throwIfAborted();
310
+ return await open3(path, "wx", 384);
311
+ } catch (error) {
312
+ if (attempt < 5 && missingLeaseFile(error))
313
+ return marker(attempt + 1);
314
+ throw error;
315
+ }
316
+ }, "marker");
317
+ const file = await marker();
318
+ let retained = false;
319
+ let identity;
320
+ try {
321
+ identity = await file.stat({ bigint: true });
322
+ await file.writeFile(JSON.stringify(owner));
323
+ await file.sync();
324
+ await file.close();
325
+ signal?.throwIfAborted();
326
+ const inspected = await inspection.inspect(root, { signal });
327
+ const own = inspected.find((lock) => lock.name === name);
328
+ if (own?.status !== "active" || own.pid !== owner.pid || own.host !== owner.host)
329
+ throw new CliError("configuration_error", "archive writer lost its lock before acquisition");
330
+ const locks = inspected.filter((lock) => lock.name !== name);
331
+ if (locks.length)
332
+ return { status: "busy", locks };
333
+ if (legacyMarker) {
334
+ try {
335
+ await lstat3(join3(root, legacyMarker));
336
+ return { status: "legacy" };
337
+ } catch (error) {
338
+ if (!missingLeaseFile(error))
339
+ throw error;
340
+ }
341
+ }
342
+ signal?.throwIfAborted();
343
+ retained = true;
344
+ return { status: "acquired", lease: ownedNativeLease(path, name, owner, folder, identity) };
345
+ } finally {
346
+ await file.close().catch(() => void 0);
347
+ if (!retained) {
348
+ if (identity && await sameOrdinaryFile(path, identity))
349
+ await unlink4(path).catch(() => void 0);
350
+ await rmdir2(folder).catch(() => void 0);
351
+ }
352
+ }
353
+ }, "acquire")
354
+ };
355
+ }, "nativeWriterLeaseStore");
356
+
357
+ // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/files/lock.js
358
+ var acquireLock = /* @__PURE__ */ __name(async (path, { signal } = {}) => {
359
+ const folder = dirname2(path);
360
+ await mkdir2(folder, { recursive: true, mode: 448 });
361
+ const acquired = await nativeWriterLeaseStore({ markerDirectory: basename2(path) }).acquire(folder, {
362
+ ...signal ? { signal } : {}
363
+ });
364
+ if (acquired.status === "acquired")
365
+ return acquired.lease;
366
+ throw new CliError("validation_error", `${basename2(path)} is locked by another process`, {
367
+ reason: "file.locked",
368
+ ...acquired.status === "busy" ? { holders: acquired.locks } : {}
369
+ });
370
+ }, "acquireLock");
371
+
372
+ export {
373
+ writeFileAtomic,
374
+ openOrdinaryFile,
375
+ sameOrdinaryFile,
376
+ syncDirectory,
377
+ readBoundedUtf8File,
378
+ acquireLock
379
+ };
@@ -4,7 +4,7 @@ import {
4
4
  __name
5
5
  } from "./chunk-ZVVMGPBJ.js";
6
6
 
7
- // node_modules/.pnpm/@wirecat+cli-core@0.484.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.65.0_commander@15._745f5d1ffb248c61bc3ef77928e0c2a2/node_modules/@wirecat/cli-core/dist/mcp/stdio-wire.js
7
+ // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/mcp/stdio-wire.js
8
8
  import { PassThrough, Writable } from "node:stream";
9
9
  var lineReader = /* @__PURE__ */ __name((onMessage) => {
10
10
  let rest = "";
@@ -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-67SRVSPU.js";
5
+ } from "./chunk-XMMWKHNY.js";
6
6
  import {
7
7
  __name
8
8
  } from "./chunk-ZVVMGPBJ.js";
9
9
 
10
- // node_modules/.pnpm/@wirecat+cli-core@0.484.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.65.0_commander@15._745f5d1ffb248c61bc3ef77928e0c2a2/node_modules/@wirecat/cli-core/dist/ports/app.js
10
+ // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/ports/app.js
11
11
  var envName = /* @__PURE__ */ __name((app, name) => `${app.envPrefix}_${name}`, "envName");
12
12
  var readOnlyLockOf = /* @__PURE__ */ __name((app, env) => {
13
13
  const name = envName(app, "READ_ONLY");
@@ -10,12 +10,12 @@ import {
10
10
  optional,
11
11
  pipe,
12
12
  safeParse
13
- } from "./chunk-67SRVSPU.js";
13
+ } from "./chunk-XMMWKHNY.js";
14
14
  import {
15
15
  __name
16
16
  } from "./chunk-ZVVMGPBJ.js";
17
17
 
18
- // node_modules/.pnpm/@wirecat+cli-core@0.484.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.65.0_commander@15._745f5d1ffb248c61bc3ef77928e0c2a2/node_modules/@wirecat/cli-core/dist/models/options.js
18
+ // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/models/options.js
19
19
  var checkedOptions = /* @__PURE__ */ __name((provider, schema, options) => {
20
20
  const parsed = safeParse(schema, options);
21
21
  if (!parsed.success) {
@@ -2,23 +2,23 @@ import { createRequire as __bundleRequire } from "node:module";
2
2
  const require = __bundleRequire(import.meta.url);
3
3
  import {
4
4
  storePath
5
- } from "./chunk-53RW4KLL.js";
5
+ } from "./chunk-UUQ3BH2Z.js";
6
6
  import {
7
7
  resolvePaths,
8
8
  singleLine
9
- } from "./chunk-T4SDOYPY.js";
9
+ } from "./chunk-N5FSRC6H.js";
10
10
  import {
11
11
  CliError
12
- } from "./chunk-67SRVSPU.js";
12
+ } from "./chunk-XMMWKHNY.js";
13
13
  import {
14
14
  __name
15
15
  } from "./chunk-ZVVMGPBJ.js";
16
16
 
17
- // node_modules/.pnpm/@wirecat+cli-core@0.484.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.65.0_commander@15._745f5d1ffb248c61bc3ef77928e0c2a2/node_modules/@wirecat/cli-core/dist/store/shared-config.js
17
+ // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/shared-config.js
18
18
  import { mkdirSync, readFileSync, renameSync, statSync, writeFileSync } from "node:fs";
19
19
  import { dirname, join, resolve } from "node:path";
20
20
 
21
- // node_modules/.pnpm/@wirecat+cli-core@0.484.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.65.0_commander@15._745f5d1ffb248c61bc3ef77928e0c2a2/node_modules/@wirecat/cli-core/dist/domain/task-categories.js
21
+ // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/domain/task-categories.js
22
22
  var DEFAULT_TASK_CATEGORIES = [
23
23
  {
24
24
  name: "taxes",
@@ -773,7 +773,7 @@ var storedTaskCategories = /* @__PURE__ */ __name((json) => {
773
773
  }
774
774
  }, "storedTaskCategories");
775
775
 
776
- // node_modules/.pnpm/@wirecat+cli-core@0.484.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.65.0_commander@15._745f5d1ffb248c61bc3ef77928e0c2a2/node_modules/@wirecat/cli-core/dist/store/shared-config.js
776
+ // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/shared-config.js
777
777
  var SECTION = "task_categories";
778
778
  var sharedConfigPath = /* @__PURE__ */ __name((store, env = process.env) => {
779
779
  const paths = resolvePaths({ appName: "WireCat", prefix: "WIRECAT", env });
@@ -4,7 +4,7 @@ import {
4
4
  __name
5
5
  } from "./chunk-ZVVMGPBJ.js";
6
6
 
7
- // node_modules/.pnpm/@wirecat+cli-core@0.484.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.65.0_commander@15._745f5d1ffb248c61bc3ef77928e0c2a2/node_modules/@wirecat/cli-core/dist/mcp/bot/instructions.js
7
+ // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/mcp/bot/instructions.js
8
8
  var botInstructions = /* @__PURE__ */ __name(({ command, name, profile, writes, skill }) => [
9
9
  `The owner's ${name} bot "${profile}", through the official Bot API \u2014 not the owner's personal account. What it writes, people see as the bot.`,
10
10
  "Use these tools to read the chats this bot is in, find a message or a person, and \u2014 when the profile allows \u2014 write as the bot.",
@@ -2,7 +2,7 @@ import { createRequire as __bundleRequire } from "node:module";
2
2
  const require = __bundleRequire(import.meta.url);
3
3
  import {
4
4
  CliError
5
- } from "./chunk-67SRVSPU.js";
5
+ } from "./chunk-XMMWKHNY.js";
6
6
  import {
7
7
  importFrom
8
8
  } from "./chunk-Y5E2WNWB.js";
@@ -10,7 +10,7 @@ import {
10
10
  __name
11
11
  } from "./chunk-ZVVMGPBJ.js";
12
12
 
13
- // node_modules/.pnpm/@wirecat+cli-core@0.484.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.65.0_commander@15._745f5d1ffb248c61bc3ef77928e0c2a2/node_modules/@wirecat/cli-core/dist/store/vector-extension.js
13
+ // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/vector-extension.js
14
14
  import { readFileSync } from "node:fs";
15
15
  var musl = /* @__PURE__ */ __name(() => {
16
16
  if (process.platform !== "linux")
@@ -4,15 +4,15 @@ import {
4
4
  organization,
5
5
  project,
6
6
  reminder
7
- } from "./chunk-TFV4UPQZ.js";
7
+ } from "./chunk-RD2NLJSU.js";
8
8
  import {
9
9
  queryFieldsOf
10
- } from "./chunk-P4A27ETD.js";
10
+ } from "./chunk-DO33KAMM.js";
11
11
 
12
- // node_modules/.pnpm/@wirecat+cli-core@0.484.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.65.0_commander@15._745f5d1ffb248c61bc3ef77928e0c2a2/node_modules/@wirecat/cli-core/dist/store/sqlite/document-transfer/snapshot.js
12
+ // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/document-transfer/snapshot.js
13
13
  var MAX_BYTES = 16 * 1024 * 1024;
14
14
 
15
- // node_modules/.pnpm/@wirecat+cli-core@0.484.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.65.0_commander@15._745f5d1ffb248c61bc3ef77928e0c2a2/node_modules/@wirecat/cli-core/dist/store/knowledge-query.js
15
+ // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/knowledge-query.js
16
16
  var ORGANIZATIONS_QUERY = {
17
17
  entity: "organization",
18
18
  backend: "sql",
@@ -3,28 +3,28 @@ const require = __bundleRequire(import.meta.url);
3
3
  import {
4
4
  installerOf,
5
5
  updateCommand
6
- } from "./chunk-VMU4SGCE.js";
6
+ } from "./chunk-VFVMB3NV.js";
7
7
  import {
8
8
  QUESTIONS,
9
9
  readSetupAnswers,
10
10
  unanswered,
11
11
  writeSetupAnswers
12
- } from "./chunk-P5UG655O.js";
12
+ } from "./chunk-P55L4S6N.js";
13
13
  import {
14
14
  DEFAULT_STEMMERS,
15
15
  LANGUAGES
16
- } from "./chunk-465FPHSG.js";
16
+ } from "./chunk-YYOIULA2.js";
17
17
  import {
18
18
  sharedConfigPath
19
- } from "./chunk-IY7IEM56.js";
19
+ } from "./chunk-AGVKIJB7.js";
20
20
  import {
21
21
  storePath
22
- } from "./chunk-53RW4KLL.js";
22
+ } from "./chunk-UUQ3BH2Z.js";
23
23
  import {
24
24
  __name
25
25
  } from "./chunk-ZVVMGPBJ.js";
26
26
 
27
- // node_modules/.pnpm/@wirecat+cli-core@0.484.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.65.0_commander@15._745f5d1ffb248c61bc3ef77928e0c2a2/node_modules/@wirecat/cli-core/dist/cli/first-run.js
27
+ // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/cli/first-run.js
28
28
  import { spawnSync } from "node:child_process";
29
29
  import { accessSync, constants, realpathSync } from "node:fs";
30
30
  import { delimiter, join } from "node:path";
@@ -82,7 +82,7 @@ var suggested = /* @__PURE__ */ __name((env, contentLanguages) => {
82
82
  return (own.length ? own : LANGUAGES.filter(({ code }) => code === "en" || code === system)).map(({ name }) => name);
83
83
  }, "suggested");
84
84
  var askLanguages = /* @__PURE__ */ __name(async ({ command, env, io, contentLanguages }) => {
85
- const { openStore } = await import("./store-KS4XIA2R.js");
85
+ const { openStore } = await import("./store-27FQ743G.js");
86
86
  const store = await openStore({ env });
87
87
  let rebuild = false;
88
88
  try {
@@ -111,8 +111,8 @@ var askLanguages = /* @__PURE__ */ __name(async ({ command, env, io, contentLang
111
111
  if (!rebuild)
112
112
  return;
113
113
  const [{ openCache }, { buildStems }] = await Promise.all([
114
- import("./open-AMRU27KK.js"),
115
- import("./store-maintenance-command-I3L24P22.js")
114
+ import("./open-BKJGJ6GX.js"),
115
+ import("./store-maintenance-command-AFJMKEBK.js")
116
116
  ]);
117
117
  const database = await openCache(storePath(env));
118
118
  try {
@@ -124,7 +124,7 @@ var askLanguages = /* @__PURE__ */ __name(async ({ command, env, io, contentLang
124
124
  var askTools = /* @__PURE__ */ __name(async (run) => {
125
125
  const { command, env, io } = run;
126
126
  const installed = run.installed ?? ((name) => onPath(name, env));
127
- const { WIRECAT_TOOLS } = await import("./first-screen-MXW3UZFB.js");
127
+ const { WIRECAT_TOOLS } = await import("./first-screen-7GKUEIWS.js");
128
128
  const others = WIRECAT_TOOLS.filter((tool) => tool.command !== command);
129
129
  const missing = others.filter((tool) => !installed(tool.command));
130
130
  io.say("Other WireCat tools \u2014 they share this store, so one search finds everything:");
@@ -197,7 +197,7 @@ var setupAtStart = /* @__PURE__ */ __name(async (start) => {
197
197
  contentLanguages: start.contentLanguages,
198
198
  all: start.path[0] === "setup",
199
199
  io: {
200
- ask: /* @__PURE__ */ __name(async (prompt) => (await import("./prompt-SPYTHKHN.js")).readSecret(prompt, { input, echo: true }), "ask"),
200
+ ask: /* @__PURE__ */ __name(async (prompt) => (await import("./prompt-CILSZC2R.js")).readSecret(prompt, { input, echo: true }), "ask"),
201
201
  say: /* @__PURE__ */ __name((text) => process.stderr.write(`${text}
202
202
  `), "say")
203
203
  }