@wirecat/tg-cli 0.114.0 → 0.116.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 (123) hide show
  1. package/dist/bin/tg.js +2 -2
  2. package/dist/bin/tg.js.map +1 -1
  3. package/dist/bot/transport.d.ts +10 -8
  4. package/dist/bot/transport.d.ts.map +1 -1
  5. package/dist/bot/transport.js +16 -2
  6. package/dist/bot/transport.js.map +1 -1
  7. package/dist/bundle/{adapter-YAEHX3QB.js → adapter-6CLMTQOV.js} +85 -56
  8. package/dist/bundle/{all-profiles-R5CW42HQ.js → all-profiles-R2UZMH24.js} +10 -8
  9. package/dist/bundle/{anthropic-F25RHYV2.js → anthropic-QKIPHV2Z.js} +6 -5
  10. package/dist/bundle/{app-server-FAG6FNXR.js → app-server-AZB2MFK6.js} +47 -43
  11. package/dist/bundle/{bot-api-KOIAXTQR.js → bot-api-2IM243J4.js} +53 -48
  12. package/dist/bundle/{bot-history-PRAOZEWC.js → bot-history-G6CRVCL2.js} +19 -17
  13. package/dist/bundle/{bun-XIMM6EHD.js → bun-JDKPISPX.js} +2 -2
  14. package/dist/bundle/{bun-sqlite-DSUCO4TR.js → bun-sqlite-X5PY5IQT.js} +5 -4
  15. package/dist/bundle/{chunk-CDCBFMEI.js → chunk-42GK3XRS.js} +2 -2
  16. package/dist/bundle/{chunk-YQ64ZNLD.js → chunk-4D5AUWAY.js} +28 -15
  17. package/dist/bundle/{chunk-IN25CJ3D.js → chunk-4IQZRW4O.js} +13 -13
  18. package/dist/bundle/{chunk-Y4LCSCSH.js → chunk-577MFPCP.js} +3 -3
  19. package/dist/bundle/{chunk-O7CBGHI7.js → chunk-5FCONCJO.js} +1 -1
  20. package/dist/bundle/{chunk-CS5DQ6KM.js → chunk-5VFPUOJO.js} +17 -14
  21. package/dist/bundle/{chunk-ZFMOPKPT.js → chunk-5ZIBAYIZ.js} +2 -2
  22. package/dist/bundle/{chunk-EARO464A.js → chunk-76CX2YPT.js} +210 -129
  23. package/dist/bundle/{chunk-E2IRSRTB.js → chunk-B4UOCWM4.js} +4 -2
  24. package/dist/bundle/{chunk-Y3AQHPAJ.js → chunk-BGMV66FC.js} +1 -1
  25. package/dist/bundle/{chunk-LPUFOWL3.js → chunk-D72URWJE.js} +1 -39
  26. package/dist/bundle/{chunk-WOQGUIXE.js → chunk-DP5LRU7K.js} +1 -1
  27. package/dist/bundle/chunk-EB2IULWB.js +72 -0
  28. package/dist/bundle/{chunk-4JOKO4IW.js → chunk-FDI4GOIP.js} +912 -493
  29. package/dist/bundle/{chunk-P4YBABUC.js → chunk-GV7ZJ33M.js} +6 -4
  30. package/dist/bundle/{chunk-C7K7AP6G.js → chunk-H72UEHNG.js} +69 -36
  31. package/dist/bundle/{chunk-2PAKHXIV.js → chunk-HBUJNNZD.js} +35 -35
  32. package/dist/bundle/{chunk-NTF34HJP.js → chunk-HK6SIIGG.js} +3 -3
  33. package/dist/bundle/{chunk-NUVBC3LJ.js → chunk-HLNYJPAB.js} +2 -2
  34. package/dist/bundle/{chunk-WIRDTH3J.js → chunk-HUOXUI2M.js} +22 -22
  35. package/dist/bundle/{chunk-RBC7JQ4Y.js → chunk-I6JF43YP.js} +5 -3
  36. package/dist/bundle/{chunk-OFDMD3YF.js → chunk-IR4S7POE.js} +8 -8
  37. package/dist/bundle/{chunk-3R43O3GG.js → chunk-JFTCOV37.js} +80 -24
  38. package/dist/bundle/{chunk-YPABTT7A.js → chunk-JJMQA272.js} +14 -89
  39. package/dist/bundle/{chunk-DQQEN3X4.js → chunk-K2RYCCTP.js} +4 -4
  40. package/dist/bundle/{chunk-OWHF6BON.js → chunk-K62YATVD.js} +6 -6
  41. package/dist/bundle/{chunk-6SPLZI5P.js → chunk-KA6EGOJY.js} +4 -4
  42. package/dist/bundle/chunk-KV4267S4.js +23 -0
  43. package/dist/bundle/{chunk-AL36NHO6.js → chunk-LFKEKSI5.js} +1043 -307
  44. package/dist/bundle/{chunk-7FOT4XD2.js → chunk-LSKGCJWD.js} +3426 -1298
  45. package/dist/bundle/{chunk-M3IWROIF.js → chunk-LXH3SKY3.js} +10 -8
  46. package/dist/bundle/{chunk-QCXYJKPF.js → chunk-MQ7MCVZV.js} +2 -2
  47. package/dist/bundle/{chunk-EQJG44KE.js → chunk-N42VUNTO.js} +2 -2
  48. package/dist/bundle/{chunk-KIZT2MI6.js → chunk-N6TIFJHW.js} +1 -1
  49. package/dist/bundle/{chunk-MQTTVQ3V.js → chunk-NL3PAFAE.js} +8 -8
  50. package/dist/bundle/{chunk-ULFTCR5W.js → chunk-NUYRMU56.js} +2 -2
  51. package/dist/bundle/{chunk-34USFPBF.js → chunk-OX6EWGSG.js} +185 -291
  52. package/dist/bundle/{chunk-KZQXOZFC.js → chunk-PPLFOIYX.js} +7 -20
  53. package/dist/bundle/{chunk-TTTDZOBW.js → chunk-PPSUA3IZ.js} +3 -3
  54. package/dist/bundle/{chunk-ALHKUQDZ.js → chunk-PXMHBTK3.js} +4 -4
  55. package/dist/bundle/{chunk-VVKEWWSO.js → chunk-QAKL3GXB.js} +1 -1
  56. package/dist/bundle/{chunk-I6BKSGZQ.js → chunk-QGL2UGML.js} +306 -190
  57. package/dist/bundle/{chunk-J5U2HKGZ.js → chunk-QHBVGKC3.js} +51 -30
  58. package/dist/bundle/{chunk-NJ2I4KFZ.js → chunk-R52RMHWF.js} +2 -2
  59. package/dist/bundle/chunk-RSDIPQXP.js +35 -0
  60. package/dist/bundle/{chunk-XDOPONC3.js → chunk-RSNGMNU5.js} +6 -6
  61. package/dist/bundle/{chunk-NKP3RUM4.js → chunk-SD5PUYKF.js} +14 -12
  62. package/dist/bundle/chunk-SKZ2E3WC.js +91 -0
  63. package/dist/bundle/{chunk-HA35XN2Z.js → chunk-T7CDLV33.js} +4 -4
  64. package/dist/bundle/{chunk-C34IDOA5.js → chunk-TZVL4U7U.js} +2 -2
  65. package/dist/bundle/{chunk-3EZ43DAF.js → chunk-UCSFO5GW.js} +3 -3
  66. package/dist/bundle/{chunk-NMVFFWF2.js → chunk-VQPLHOVQ.js} +9 -9
  67. package/dist/bundle/chunk-XBIPSSKI.js +166 -0
  68. package/dist/bundle/{chunk-VHO66SMY.js → chunk-XQUTJITP.js} +59 -57
  69. package/dist/bundle/{chunk-L4CMCC3V.js → chunk-Y6VWGJ4Q.js} +1 -1
  70. package/dist/bundle/{chunk-RFRI2HFT.js → chunk-YLRTLZF6.js} +1 -1
  71. package/dist/bundle/chunk-YPF6OS37.js +46 -0
  72. package/dist/bundle/{chunk-TKNCJMYN.js → chunk-YYKJN6H5.js} +946 -589
  73. package/dist/bundle/{chunk-5HKMEXVQ.js → chunk-ZDIAPICE.js} +4 -4
  74. package/dist/bundle/command-contract-DPXM4SZT.js +33 -0
  75. package/dist/bundle/{decode-7U4SXPAN.js → decode-W6YPTGJA.js} +7 -6
  76. package/dist/bundle/dispatch-H7EFNBEH.js +411 -0
  77. package/dist/bundle/{echarts-GKEZEAL7.js → echarts-YAWDIC5D.js} +2 -2
  78. package/dist/bundle/{embed-IDZDQMSW.js → embed-EN4UTLV5.js} +6 -5
  79. package/dist/bundle/{embedder-RY5R2PGO.js → embedder-HEKHRL7E.js} +11 -10
  80. package/dist/bundle/{entry-P6YZ3ZV6.js → entry-2KB6MTCG.js} +7 -6
  81. package/dist/bundle/failure-3DU3HLBQ.js +24 -0
  82. package/dist/bundle/first-run-LBG26WWO.js +27 -0
  83. package/dist/bundle/first-screen-TGTSLUI6.js +31 -0
  84. package/dist/bundle/{instructions-P5E34PQR.js → instructions-HA62QNPR.js} +1 -1
  85. package/dist/bundle/{mcp-FUSDPAOL.js → mcp-PPVOM4SE.js} +5 -3
  86. package/dist/bundle/{node-GKPRXS5Y.js → node-MZ2VWSQQ.js} +2 -2
  87. package/dist/bundle/{node-sqlite-VUXFVPJ6.js → node-sqlite-KNNS6DCM.js} +6 -5
  88. package/dist/bundle/{oauth-7SQIPMOY.js → oauth-KWUABBSQ.js} +7 -6
  89. package/dist/bundle/{open-W3BN2SIO.js → open-JXMCYCIV.js} +5 -4
  90. package/dist/bundle/{openai-LQTK3ZMC.js → openai-HL3IR4VT.js} +15 -14
  91. package/dist/bundle/{process-U2P5Z6UF.js → process-K2FICLWY.js} +1 -1
  92. package/dist/bundle/{program-DIPSLR6O.js → program-IFOMT4JS.js} +70 -57
  93. package/dist/bundle/{prompt-GESHKSM5.js → prompt-HVD3Q77P.js} +5 -4
  94. package/dist/bundle/{proxy-transport-C2EUUT32.js → proxy-transport-PA5SGMRY.js} +5 -4
  95. package/dist/bundle/{recognize-FEQTIJET.js → recognize-HHLVETKI.js} +4 -3
  96. package/dist/bundle/{remote-UXOPBPKS.js → remote-HUAKXJCS.js} +7 -6
  97. package/dist/bundle/{rerank-L4JM4REK.js → rerank-NWFIV7OF.js} +7 -6
  98. package/dist/bundle/{serve-DDWW44DB.js → serve-ANUKAJJN.js} +10 -9
  99. package/dist/bundle/{server-UTWBIZHB.js → server-7Q7WAOHO.js} +37 -34
  100. package/dist/bundle/server-HCQS4YDQ.js +60 -0
  101. package/dist/bundle/{state-EV7FGEK4.js → state-Y2AJ5XTP.js} +6 -5
  102. package/dist/bundle/{store-EXBUF4OG.js → store-S3IG5KWL.js} +15 -11
  103. package/dist/bundle/store-maintenance-command-V2WC4G6J.js +50 -0
  104. package/dist/bundle/tg.js +159 -14
  105. package/dist/commands/session.d.ts.map +1 -1
  106. package/dist/commands/session.js +7 -0
  107. package/dist/commands/session.js.map +1 -1
  108. package/dist/telegram/login.d.ts +2 -0
  109. package/dist/telegram/login.d.ts.map +1 -1
  110. package/dist/telegram/login.js +31 -2
  111. package/dist/telegram/login.js.map +1 -1
  112. package/dist/version.d.ts +1 -1
  113. package/dist/version.js +1 -1
  114. package/package.json +5 -4
  115. package/skills/tg-cli/SKILL.md +2 -0
  116. package/dist/bundle/chunk-TRRRRGMI.js +0 -18
  117. package/dist/bundle/command-contract-SOTDPG22.js +0 -31
  118. package/dist/bundle/first-run-66KTCVQK.js +0 -24
  119. package/dist/bundle/first-screen-NY46X6QU.js +0 -29
  120. package/dist/bundle/identity-GXVKGCNU.js +0 -11
  121. package/dist/bundle/server-ZI7WDAW6.js +0 -56
  122. package/dist/bundle/store-maintenance-command-UBZE2Z6T.js +0 -46
  123. /package/dist/bundle/{chunk-NUN6OGOV.js → chunk-LU3WKZBA.js} +0 -0
@@ -1,42 +1,34 @@
1
1
  import { createRequire as __bundleRequire } from "node:module";
2
2
  const require = __bundleRequire(import.meta.url);
3
+ import {
4
+ errorCodes,
5
+ isCliError,
6
+ visibleControls
7
+ } from "./chunk-EB2IULWB.js";
3
8
  import {
4
9
  __name
5
10
  } from "./chunk-ZVVMGPBJ.js";
6
11
 
7
- // node_modules/.pnpm/@wirecat+cli-base@0.75.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/errors.js
8
- var errorCodes = [
9
- "validation_error",
10
- "configuration_error",
11
- "authentication_error",
12
- "permission_error",
13
- "not_found",
14
- "confirmation_required",
15
- "rate_limited",
16
- "timeout",
17
- "network_error",
18
- "provider_error",
19
- "provider_unavailable",
20
- "invalid_response",
21
- "outcome_unknown",
22
- "cancelled"
23
- ];
24
- var BRAND = /* @__PURE__ */ Symbol.for("@wirecat/cli-base/CliError");
25
- var CliError = class extends Error {
26
- static {
27
- __name(this, "CliError");
28
- }
29
- code;
30
- details;
31
- constructor(code, message, details = {}) {
32
- super(message);
33
- this.name = "CliError";
34
- this.code = code;
35
- this.details = details;
36
- Object.defineProperty(this, BRAND, { value: true });
37
- }
12
+ // node_modules/.pnpm/@wirecat+cli-base@0.77.1_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/exit-codes.js
13
+ var EXIT_CODES = {
14
+ validation_error: 2,
15
+ configuration_error: 3,
16
+ authentication_error: 4,
17
+ permission_error: 5,
18
+ not_found: 6,
19
+ confirmation_required: 7,
20
+ rate_limited: 8,
21
+ timeout: 9,
22
+ network_error: 10,
23
+ provider_error: 11,
24
+ provider_unavailable: 12,
25
+ invalid_response: 13,
26
+ outcome_unknown: 14,
27
+ conflict: 15,
28
+ cancelled: 130
38
29
  };
39
- var isCliError = /* @__PURE__ */ __name((value) => typeof value === "object" && value !== null && value[BRAND] === true, "isCliError");
30
+ var exitCodeFor = /* @__PURE__ */ __name((code) => EXIT_CODES[code], "exitCodeFor");
31
+ var GENERIC_FAILURE = 1;
40
32
 
41
33
  // node_modules/.pnpm/valibot@1.5.0_typescript@7.0.2/node_modules/valibot/dist/index.mjs
42
34
  var store$4;
@@ -1289,6 +1281,14 @@ function unwrap(schema) {
1289
1281
  }
1290
1282
  __name(unwrap, "unwrap");
1291
1283
 
1284
+ // node_modules/.pnpm/@wirecat+cli-base@0.77.1_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/standards/effects.js
1285
+ var EFFECT_LEVELS = ["none", "read", "write"];
1286
+ var effectsSchema = strictObject({
1287
+ remote: picklist(EFFECT_LEVELS),
1288
+ local: picklist(EFFECT_LEVELS)
1289
+ });
1290
+ var writes = /* @__PURE__ */ __name((effects) => effects === void 0 || effects.remote === "write" || effects.local === "write", "writes");
1291
+
1292
1292
  // node_modules/.pnpm/@valibot+to-json-schema@1.8.0_valibot@1.5.0_typescript@7.0.2_/node_modules/@valibot/to-json-schema/dist/index.mjs
1293
1293
  function addError(errors, message) {
1294
1294
  if (errors) {
@@ -1918,7 +1918,7 @@ function toStandardJsonSchema(schema) {
1918
1918
  }
1919
1919
  __name(toStandardJsonSchema, "toStandardJsonSchema");
1920
1920
 
1921
- // node_modules/.pnpm/@wirecat+cli-base@0.75.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/standards/registry.js
1921
+ // node_modules/.pnpm/@wirecat+cli-base@0.77.1_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/standards/registry.js
1922
1922
  var word = pipe(string(), regex(/^[a-z][a-z0-9]*(-[a-z0-9]+)*$/, "a lower-case word, words joined by -"));
1923
1923
  var SNAKE_CASE = /^[a-z][a-z0-9]*(_[a-z0-9]+)*$/;
1924
1924
  var text = pipe(string(), regex(/\S/, "must not be empty"));
@@ -1960,15 +1960,7 @@ var fill = /* @__PURE__ */ __name((template, values) => template.replace(PLACEHO
1960
1960
  return String(value);
1961
1961
  }), "fill");
1962
1962
 
1963
- // node_modules/.pnpm/@wirecat+cli-base@0.75.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/standards/effects.js
1964
- var EFFECT_LEVELS = ["none", "read", "write"];
1965
- var effectsSchema = strictObject({
1966
- remote: picklist(EFFECT_LEVELS),
1967
- local: picklist(EFFECT_LEVELS)
1968
- });
1969
- var writes = /* @__PURE__ */ __name((effects) => effects === void 0 || effects.remote === "write" || effects.local === "write", "writes");
1970
-
1971
- // node_modules/.pnpm/@wirecat+cli-base@0.75.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/standards/output.js
1963
+ // node_modules/.pnpm/@wirecat+cli-base@0.77.1_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/standards/output.js
1972
1964
  var MAX_NEXT_STEPS = 2;
1973
1965
  var COMPACT_FLAG = "--compact";
1974
1966
  var isoTime = pipe(string(), isoTimestamp("an ISO 8601 time in UTC"), endsWith("Z", "an ISO 8601 time in UTC, ending in `Z`"));
@@ -2044,6 +2036,17 @@ var metaSchema = strictObject({
2044
2036
  now_local: optional(localTime),
2045
2037
  window: optional(strictObject({ since: optional(isoTime), until: optional(isoTime) }))
2046
2038
  });
2039
+ var offsetOf = /* @__PURE__ */ __name((at, zone) => {
2040
+ const name = new Intl.DateTimeFormat("en-US", { timeZone: zone, timeZoneName: "longOffset" }).formatToParts(at).find((part) => part.type === "timeZoneName")?.value ?? "GMT";
2041
+ return name === "GMT" ? "+00:00" : name.slice(3);
2042
+ }, "offsetOf");
2043
+ var clockMeta = /* @__PURE__ */ __name((at, zone) => {
2044
+ const offset = offsetOf(at, zone);
2045
+ const sign = offset.startsWith("-") ? -1 : 1;
2046
+ const [hours = 0, minutes = 0] = offset.slice(1).split(":").map(Number);
2047
+ const wall = new Date(at + sign * (hours * 60 + minutes) * 6e4).toISOString().slice(0, -1);
2048
+ return { now: new Date(at).toISOString(), now_local: `${wall}${offset}`, timezone: zone };
2049
+ }, "clockMeta");
2047
2050
  var nextSteps = optional(pipe(array(nextStepSchema), maxLength(MAX_NEXT_STEPS)));
2048
2051
  var listEnvelopeSchema = /* @__PURE__ */ __name((item) => strictObject({
2049
2052
  items: array(item),
@@ -2069,7 +2072,7 @@ var jsonlOf = /* @__PURE__ */ __name(({ items, page, meta }) => [
2069
2072
  JSON.stringify({ type: "end", complete: meta.complete, ...meta.issues ? { issues: meta.issues } : {}, page })
2070
2073
  ].join("\n"), "jsonlOf");
2071
2074
 
2072
- // node_modules/.pnpm/@wirecat+cli-base@0.75.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/standards/errors.js
2075
+ // node_modules/.pnpm/@wirecat+cli-base@0.77.1_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/standards/errors.js
2073
2076
  var CRASH_CODE = "internal_error";
2074
2077
  var CRASH_REASON = "command.crashed";
2075
2078
  var errorObjectSchema = strictObject({
@@ -2152,11 +2155,17 @@ var BASE_REASONS = defineReasons([
2152
2155
  details: []
2153
2156
  },
2154
2157
  { reason: "outcome.unknown", code: "outcome_unknown", message: "it is not known whether it worked", details: [] },
2158
+ {
2159
+ reason: "write.conflict",
2160
+ code: "conflict",
2161
+ message: "it changed since it was read; read it again",
2162
+ details: []
2163
+ },
2155
2164
  { reason: "command.cancelled", code: "cancelled", message: "the command was cancelled", details: [] },
2156
2165
  { reason: CRASH_REASON, code: CRASH_CODE, message: "the command failed; this is a bug", details: [] }
2157
2166
  ]);
2158
2167
 
2159
- // node_modules/.pnpm/@wirecat+cli-base@0.75.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/standards/steps.js
2168
+ // node_modules/.pnpm/@wirecat+cli-base@0.77.1_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/standards/steps.js
2160
2169
  var SAME_COMMAND = "*";
2161
2170
  var commandPath = pipe(string(), regex(/^[a-z][a-z0-9-]*( [a-z][a-z0-9-]*)*$/, "a command path such as `messages sync`"));
2162
2171
  var stepSchema = union([
@@ -2235,88 +2244,157 @@ var STEPS = defineSteps([
2235
2244
  }
2236
2245
  ]);
2237
2246
 
2238
- // node_modules/.pnpm/@wirecat+cli-base@0.75.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/standards/log.js
2239
- var LOG_SEVERITIES = ["trace", "debug", "info", "warn", "error", "fatal"];
2240
- var logRecordSchema = strictObject({
2241
- time: isoTime,
2242
- severity: picklist(LOG_SEVERITIES),
2243
- /** The registered event id, `provider.request.failed`: never a sentence, so never content. */
2244
- body: string(),
2245
- run_id: text,
2246
- /** From an MCP caller's `_meta.traceparent`, when it sent one. */
2247
- trace_id: optional(pipe(string(), regex(/^[0-9a-f]{32}$/, "32 lower-case hex digits"))),
2248
- command: string(),
2249
- attributes: record(string(), unknown()),
2250
- resource: strictObject({ service: text, version: text })
2251
- });
2252
- var logEventSchema = strictObject({
2253
- id: dottedId,
2254
- meaning: text,
2255
- /** Attribute keys every record of this event carries. */
2256
- keys: array(string())
2257
- });
2258
- var defineLogEvents = /* @__PURE__ */ __name((input) => parseRegistry("log events", array(logEventSchema), input, (events) => [
2259
- ...duplicates(events.map((event) => event.id)).map((id) => `"${id}" is listed twice`),
2260
- ...events.flatMap((event) => duplicates(event.keys).map((key) => `${event.id}: key "${key}" is listed twice`))
2261
- ]), "defineLogEvents");
2262
- var LOG_EVENTS = defineLogEvents([
2263
- { id: "command.failed", meaning: "a command ended with an error", keys: ["code", "reason"] }
2264
- ]);
2265
- var LOG_ATTRIBUTE_KEYS = [
2266
- "code",
2267
- "count",
2268
- "durationMs",
2269
- "errorClass",
2270
- "errorCode",
2271
- "event",
2272
- "frames",
2273
- "operation",
2274
- "outcome",
2275
- "reason",
2276
- "status"
2277
- ];
2278
- var CONTENT_WORDS = /* @__PURE__ */ new Set([
2279
- "authorization",
2280
- "body",
2281
- "caption",
2282
- "content",
2283
- "cookie",
2284
- "credential",
2285
- "credentials",
2286
- "email",
2287
- "password",
2288
- "phone",
2289
- "query",
2290
- "secret",
2291
- "text",
2292
- "title",
2293
- "token"
2294
- ]);
2295
- var CONTENT_LAST_WORDS = /* @__PURE__ */ new Set(["message", "name"]);
2296
- var wordsOf = /* @__PURE__ */ __name((key) => key.replace(/([a-z0-9])([A-Z])/g, "$1 $2").split(/[\s_.-]+/).filter(Boolean).map((word2) => word2.toLowerCase()), "wordsOf");
2297
- var isContentKey = /* @__PURE__ */ __name((key) => {
2298
- const words = wordsOf(key);
2299
- return words.some((word2) => CONTENT_WORDS.has(word2)) || CONTENT_LAST_WORDS.has(words.at(-1) ?? "");
2300
- }, "isContentKey");
2301
- var TRACEPARENT = /^([0-9a-f]{2})-([0-9a-f]{32})-([0-9a-f]{16})-([0-9a-f]{2})(-.*)?$/;
2302
- var traceIdOf = /* @__PURE__ */ __name((traceparent) => {
2303
- if (typeof traceparent !== "string")
2304
- return void 0;
2305
- const match = TRACEPARENT.exec(traceparent.trim());
2306
- if (!match)
2247
+ // node_modules/.pnpm/@wirecat+cli-base@0.77.1_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/failure.js
2248
+ var recognise = /* @__PURE__ */ __name((failure) => {
2249
+ if (isCliError(failure))
2250
+ return failure;
2251
+ if (!(failure instanceof Error) || failure.name !== "CliError")
2307
2252
  return void 0;
2308
- const [, version, traceId = "", parentId = "", , rest] = match;
2309
- if (version === "ff" || version === "00" && rest !== void 0)
2253
+ const { code, details } = failure;
2254
+ if (!errorCodes.includes(code))
2310
2255
  return void 0;
2311
- if (/^0+$/.test(traceId) || /^0+$/.test(parentId))
2312
- return void 0;
2313
- return traceId;
2314
- }, "traceIdOf");
2256
+ return {
2257
+ code,
2258
+ message: failure.message,
2259
+ details: typeof details === "object" && details !== null ? details : {}
2260
+ };
2261
+ }, "recognise");
2262
+ var reasonFor = /* @__PURE__ */ __name((code, named, reasons) => reasons.find((entry) => entry.reason === named && entry.code === code) ?? BASE_REASONS.find((entry) => entry.reason === named && entry.code === code) ?? // The first base reason for each code is its fallback.
2263
+ BASE_REASONS.find((entry) => entry.code === code), "reasonFor");
2264
+ var nextFor = /* @__PURE__ */ __name((reason, details, context) => {
2265
+ const definition = reason.step ? context.steps?.find((step) => step.id === reason.step) : void 0;
2266
+ if (!definition)
2267
+ return [];
2268
+ const known = new Set(definition.kind === "command" ? definition.args.map((arg) => arg.name) : []);
2269
+ const args = Object.fromEntries(Object.entries(details).filter(([key, value]) => known.has(key) && value !== void 0));
2270
+ try {
2271
+ return [stepOf(definition, { args, ...context.targets ? { targets: context.targets } : {} })];
2272
+ } catch {
2273
+ return [];
2274
+ }
2275
+ }, "nextFor");
2276
+ var TRANSIENT = [
2277
+ "rate_limited",
2278
+ "timeout",
2279
+ "network_error",
2280
+ "provider_unavailable"
2281
+ ];
2282
+ var retryOf = /* @__PURE__ */ __name((code, details, effects) => {
2283
+ const transient = details.retryable !== false && (TRANSIENT.includes(code) || code === "provider_error" && details.retryable === true);
2284
+ const safe = code !== "outcome_unknown" && transient && (!writes(effects) || details.sent === false);
2285
+ const after = details.retry_after_ms;
2286
+ return safe && typeof after === "number" && Number.isInteger(after) && after >= 0 ? { safe, after_ms: after } : { safe };
2287
+ }, "retryOf");
2288
+ var errorObjectOf = /* @__PURE__ */ __name((failure, context = {}) => {
2289
+ const reasons = context.reasons ?? [];
2290
+ const recognised = recognise(failure);
2291
+ if (!recognised) {
2292
+ const reason2 = reasonFor(CRASH_CODE, CRASH_REASON, reasons);
2293
+ return {
2294
+ error: {
2295
+ code: CRASH_CODE,
2296
+ reason: reason2.reason,
2297
+ message: reason2.message,
2298
+ retry: { safe: false },
2299
+ ...context.runId ? { run_id: context.runId } : {}
2300
+ }
2301
+ };
2302
+ }
2303
+ const { code, message, details } = recognised;
2304
+ const reason = reasonFor(code, details.reason, reasons);
2305
+ const allowed = /* @__PURE__ */ new Set([...COMMON_DETAILS, ...context.details ?? [], ...reason.details]);
2306
+ allowed.delete("cause");
2307
+ const kept = Object.fromEntries(Object.entries(details).filter(([key, value]) => allowed.has(key) && value !== void 0));
2308
+ const next = nextFor(reason, details, context);
2309
+ const runId = context.runId ?? (typeof details.run_id === "string" ? details.run_id : void 0);
2310
+ return {
2311
+ error: {
2312
+ code,
2313
+ reason: reason.reason,
2314
+ message,
2315
+ ...typeof details.param === "string" ? { param: details.param } : {},
2316
+ ...Object.keys(kept).length > 0 ? { details: kept } : {},
2317
+ ...next.length > 0 ? { next } : {},
2318
+ retry: retryOf(code, details, context.effects),
2319
+ ...runId ? { run_id: runId } : {}
2320
+ }
2321
+ };
2322
+ }, "errorObjectOf");
2323
+ var exitCodeOfError = /* @__PURE__ */ __name(({ error }) => error.code === CRASH_CODE ? GENERIC_FAILURE : EXIT_CODES[error.code], "exitCodeOfError");
2324
+ var exitCodeOfAnswer = /* @__PURE__ */ __name((meta, partial2 = false) => {
2325
+ if (meta.complete || partial2)
2326
+ return 0;
2327
+ const code = meta.issues?.[0]?.code;
2328
+ return code === void 0 ? GENERIC_FAILURE : EXIT_CODES[code];
2329
+ }, "exitCodeOfAnswer");
2330
+ var kebab = /* @__PURE__ */ __name((name) => name.replaceAll("_", "-"), "kebab");
2331
+ var commandLine = /* @__PURE__ */ __name((cli, step) => [
2332
+ cli,
2333
+ step.command,
2334
+ ...Object.entries(step.args).map(([name, value]) => value === true ? `--${kebab(name)}` : `--${kebab(name)} ${JSON.stringify(value)}`)
2335
+ ].join(" "), "commandLine");
2336
+ var STACK_FRAMES = 10;
2337
+ var errorRecordOf = /* @__PURE__ */ __name((failure, object2, options) => {
2338
+ const thrown = failure instanceof Error ? failure : void 0;
2339
+ const { cause, ...details } = recognise(failure)?.details ?? {};
2340
+ const stack = thrown?.stack?.split("\n").slice(1, STACK_FRAMES + 1).map((line) => visibleControls(line.trim()));
2341
+ const reason = thrown?.cause ?? cause;
2342
+ return {
2343
+ time: (options.time ?? /* @__PURE__ */ new Date()).toISOString(),
2344
+ severity: "error",
2345
+ body: "command.failed",
2346
+ ...object2.error.run_id ? { run_id: object2.error.run_id } : {},
2347
+ command: options.command,
2348
+ attributes: {
2349
+ code: object2.error.code,
2350
+ reason: object2.error.reason,
2351
+ message: object2.error.message,
2352
+ ...Object.keys(details).length > 0 ? { details } : {},
2353
+ ...thrown ? { name: thrown.name, thrown_message: visibleControls(thrown.message) } : { thrown: String(failure) },
2354
+ ...reason === void 0 ? {} : { cause: visibleControls(reason instanceof Error ? reason.message : String(reason)) },
2355
+ ...stack && stack.length > 0 ? { stack } : {}
2356
+ },
2357
+ resource: { service: options.service, version: options.version }
2358
+ };
2359
+ }, "errorRecordOf");
2360
+ var renderError = /* @__PURE__ */ __name((object2, options) => {
2361
+ if (!options.interactive)
2362
+ return [JSON.stringify(object2), ...options.record ? [JSON.stringify(options.record)] : []].join("\n");
2363
+ const { message, next, run_id: runId } = object2.error;
2364
+ const step = next?.[0];
2365
+ return [
2366
+ `\u2717 ${visibleControls(message)}`,
2367
+ ...step?.kind === "command" ? [`\u2192 ${visibleControls(step.why)}: ${visibleControls(step.line ?? commandLine(options.cli, step))}`] : step ? [`\u2192 ${visibleControls(step.why)}`] : [],
2368
+ ...options.record ? [JSON.stringify(options.record, null, 2)] : runId ? [`details: ${options.cli} runs show ${runId}`] : []
2369
+ ].join("\n");
2370
+ }, "renderError");
2371
+ var mcpErrorResult = /* @__PURE__ */ __name((object2) => ({
2372
+ content: [{ type: "text", text: JSON.stringify(object2) }],
2373
+ structuredContent: object2,
2374
+ isError: true
2375
+ }), "mcpErrorResult");
2376
+ var catchCrashes = /* @__PURE__ */ __name((options) => {
2377
+ const target = options.target ?? process;
2378
+ const write = options.write ?? ((text2) => process.stderr.write(`${text2}
2379
+ `));
2380
+ const exit = options.exit ?? ((code) => process.exit(code));
2381
+ const crashed = /* @__PURE__ */ __name((failure) => {
2382
+ const object2 = errorObjectOf(failure, options);
2383
+ write(renderError(object2, { cli: options.cli, interactive: options.interactive }));
2384
+ exit(exitCodeOfError(object2));
2385
+ }, "crashed");
2386
+ target.on("uncaughtException", crashed);
2387
+ target.on("unhandledRejection", crashed);
2388
+ return () => {
2389
+ target.off("uncaughtException", crashed);
2390
+ target.off("unhandledRejection", crashed);
2391
+ };
2392
+ }, "catchCrashes");
2315
2393
 
2316
2394
  export {
2317
- errorCodes,
2318
- CliError,
2319
- isCliError,
2395
+ EXIT_CODES,
2396
+ exitCodeFor,
2397
+ GENERIC_FAILURE,
2320
2398
  getDotPath,
2321
2399
  check,
2322
2400
  description,
@@ -2369,6 +2447,7 @@ export {
2369
2447
  word,
2370
2448
  SNAKE_CASE,
2371
2449
  text,
2450
+ dottedId,
2372
2451
  RegistryError,
2373
2452
  parseRegistry,
2374
2453
  duplicates,
@@ -2378,20 +2457,22 @@ export {
2378
2457
  isoTime,
2379
2458
  reference,
2380
2459
  pageSchema,
2460
+ clockMeta,
2381
2461
  listEnvelopeSchema,
2382
2462
  itemEnvelopeSchema,
2383
2463
  jsonlOf,
2384
2464
  CRASH_CODE,
2385
- CRASH_REASON,
2386
2465
  errorObjectSchema,
2387
2466
  defineReasons,
2388
- COMMON_DETAILS,
2389
- BASE_REASONS,
2390
2467
  defineSteps,
2391
2468
  stepOf,
2392
2469
  STEPS,
2393
- defineLogEvents,
2394
- LOG_ATTRIBUTE_KEYS,
2395
- isContentKey,
2396
- traceIdOf
2470
+ retryOf,
2471
+ errorObjectOf,
2472
+ exitCodeOfError,
2473
+ exitCodeOfAnswer,
2474
+ errorRecordOf,
2475
+ renderError,
2476
+ mcpErrorResult,
2477
+ catchCrashes
2397
2478
  };
@@ -1,11 +1,13 @@
1
1
  import { createRequire as __bundleRequire } from "node:module";
2
2
  const require = __bundleRequire(import.meta.url);
3
3
  import {
4
- CliError,
5
4
  check,
6
5
  pipe,
7
6
  string
8
- } from "./chunk-EARO464A.js";
7
+ } from "./chunk-76CX2YPT.js";
8
+ import {
9
+ CliError
10
+ } from "./chunk-EB2IULWB.js";
9
11
  import {
10
12
  __name
11
13
  } 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.553.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.75.0_commander@15._c8fb11a0c49a39da33a9d557d170ff7b/node_modules/@wirecat/cli-core/dist/http/listen.js
7
+ // node_modules/.pnpm/@wirecat+cli-core@0.567.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.77.1_commander@15._f1cdf35b93ce465cee2c32ebaca13ce7/node_modules/@wirecat/cli-core/dist/http/listen.js
8
8
  import { createServer } from "node:http";
9
9
  import { Readable } from "node:stream";
10
10
  var MAX_BODY = 4 * 1024 * 1024;
@@ -527,44 +527,6 @@ var require_cross_spawn = __commonJS({
527
527
  }
528
528
  });
529
529
 
530
- // node_modules/.pnpm/@wirecat+cli-base@0.75.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/executable.js
531
- import { existsSync } from "node:fs";
532
- import { win32 } from "node:path";
533
- var variable = /* @__PURE__ */ __name((env, name) => Object.entries(env).find(([key]) => key.toUpperCase() === name)?.[1], "variable");
534
- var executableOnPath = /* @__PURE__ */ __name((command, env, platform = process.platform, exists = existsSync) => {
535
- if (platform !== "win32" || win32.isAbsolute(command))
536
- return command;
537
- if (/[\\/]/.test(command))
538
- return command;
539
- const extensions = win32.extname(command) ? [""] : (variable(env, "PATHEXT") ?? ".EXE;.COM;.CMD;.BAT").split(";").filter((ext) => /^\.[a-z0-9]+$/i.test(ext));
540
- for (const entry of (variable(env, "PATH") ?? "").split(";")) {
541
- const directory = entry.replace(/^"(.*)"$/, "$1");
542
- for (const extension of extensions) {
543
- const candidate = win32.join(directory, command + extension);
544
- if (exists(candidate))
545
- return candidate;
546
- }
547
- }
548
- return command;
549
- }, "executableOnPath");
550
- var executableEnvironment = /* @__PURE__ */ __name((env, platform = process.platform) => {
551
- if (platform !== "win32")
552
- return env;
553
- const configured = variable(env, "COMSPEC");
554
- const system = variable(env, "SYSTEMROOT");
555
- const shell = configured ? configured : system && win32.isAbsolute(system) ? win32.join(system, "System32", "cmd.exe") : void 0;
556
- if (!shell)
557
- return env;
558
- const result = { ...env };
559
- for (const key of Object.keys(result))
560
- if (key.toUpperCase() === "COMSPEC")
561
- delete result[key];
562
- result.comspec = shell;
563
- return result;
564
- }, "executableEnvironment");
565
-
566
530
  export {
567
- require_cross_spawn,
568
- executableOnPath,
569
- executableEnvironment
531
+ require_cross_spawn
570
532
  };
@@ -4,7 +4,7 @@ import {
4
4
  __name
5
5
  } from "./chunk-ZVVMGPBJ.js";
6
6
 
7
- // node_modules/.pnpm/@wirecat+cli-core@0.553.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.75.0_commander@15._c8fb11a0c49a39da33a9d557d170ff7b/node_modules/@wirecat/cli-core/dist/mcp/bot/instructions.js
7
+ // node_modules/.pnpm/@wirecat+cli-core@0.567.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.77.1_commander@15._f1cdf35b93ce465cee2c32ebaca13ce7/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.",
@@ -0,0 +1,72 @@
1
+ import { createRequire as __bundleRequire } from "node:module";
2
+ const require = __bundleRequire(import.meta.url);
3
+ import {
4
+ __name
5
+ } from "./chunk-ZVVMGPBJ.js";
6
+
7
+ // node_modules/.pnpm/@wirecat+cli-base@0.77.1_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/errors.js
8
+ var errorCodes = [
9
+ "validation_error",
10
+ "configuration_error",
11
+ "authentication_error",
12
+ "permission_error",
13
+ "not_found",
14
+ "confirmation_required",
15
+ "rate_limited",
16
+ "timeout",
17
+ "network_error",
18
+ "provider_error",
19
+ "provider_unavailable",
20
+ "invalid_response",
21
+ "outcome_unknown",
22
+ "conflict",
23
+ "cancelled"
24
+ ];
25
+ var BRAND = /* @__PURE__ */ Symbol.for("@wirecat/cli-base/CliError");
26
+ var CliError = class extends Error {
27
+ static {
28
+ __name(this, "CliError");
29
+ }
30
+ code;
31
+ details;
32
+ constructor(code, message, details = {}) {
33
+ super(message);
34
+ this.name = "CliError";
35
+ this.code = code;
36
+ this.details = details;
37
+ Object.defineProperty(this, BRAND, { value: true });
38
+ }
39
+ };
40
+ var isCliError = /* @__PURE__ */ __name((value) => typeof value === "object" && value !== null && value[BRAND] === true, "isCliError");
41
+
42
+ // node_modules/.pnpm/@wirecat+cli-base@0.77.1_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/sanitize.js
43
+ var CONTROL = (
44
+ // biome-ignore lint/suspicious/noControlCharactersInRegex: matching them is the whole point
45
+ /[\u0000-\u0008\u000B-\u001F\u007F-\u009F\u200B\u200E\u200F\u202A-\u202E\u2066-\u2069\uFEFF\u{E0000}-\u{E007F}]/gu
46
+ );
47
+ var SUBDIVISION_FLAG = /\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}/gu;
48
+ var LINE_BREAKS = /[\t\n\u2028\u2029]/g;
49
+ var escaped = /* @__PURE__ */ __name((c) => {
50
+ const code = c.codePointAt(0) ?? 0;
51
+ if (code > 65535)
52
+ return `\\u{${code.toString(16)}}`;
53
+ return code > 255 ? `\\u${code.toString(16).padStart(4, "0")}` : `\\x${code.toString(16).padStart(2, "0")}`;
54
+ }, "escaped");
55
+ var visibleControls = /* @__PURE__ */ __name((text) => {
56
+ let at = 0;
57
+ let result = "";
58
+ for (const flag of text.matchAll(SUBDIVISION_FLAG)) {
59
+ result += text.slice(at, flag.index).replace(CONTROL, escaped) + flag[0];
60
+ at = flag.index + flag[0].length;
61
+ }
62
+ return result + text.slice(at).replace(CONTROL, escaped);
63
+ }, "visibleControls");
64
+ var singleLine = /* @__PURE__ */ __name((text) => visibleControls(text).replace(LINE_BREAKS, escaped), "singleLine");
65
+
66
+ export {
67
+ errorCodes,
68
+ CliError,
69
+ isCliError,
70
+ visibleControls,
71
+ singleLine
72
+ };