@wirecat/tg-cli 0.101.0 → 0.102.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 (95) hide show
  1. package/dist/bin/tg.js +1 -1
  2. package/dist/bot/transport.d.ts.map +1 -1
  3. package/dist/bot/transport.js +14 -17
  4. package/dist/bot/transport.js.map +1 -1
  5. package/dist/bundle/{adapter-A3VD4Y6Z.js → adapter-M2HRSFFL.js} +90 -28
  6. package/dist/bundle/{all-profiles-UPVNHXB2.js → all-profiles-GOD2QNTK.js} +29 -8
  7. package/dist/bundle/{anthropic-IRKNWPIB.js → anthropic-LKU7RWMA.js} +3 -3
  8. package/dist/bundle/{bot-api-UNTQG2M5.js → bot-api-X3MPFVPL.js} +42 -46
  9. package/dist/bundle/{bot-history-V4RTY5K7.js → bot-history-OUMVVG22.js} +10 -10
  10. package/dist/bundle/{bun-2JZPG2NL.js → bun-LIZ6MKFS.js} +2 -2
  11. package/dist/bundle/{bun-sqlite-TZHKM225.js → bun-sqlite-2IFQYQ44.js} +2 -2
  12. package/dist/bundle/{chunk-VA5YEJS3.js → chunk-264DAFJV.js} +4 -4
  13. package/dist/bundle/{chunk-ZV24I2UJ.js → chunk-2SUTCDGO.js} +1 -1
  14. package/dist/bundle/{chunk-BX6HH4F6.js → chunk-334UBWOB.js} +10 -10
  15. package/dist/bundle/{chunk-2DGOFLDA.js → chunk-4PDEQL6T.js} +1 -1
  16. package/dist/bundle/chunk-4QB4WDLT.js +922 -0
  17. package/dist/bundle/{chunk-MLLJ74LM.js → chunk-5D6OJREA.js} +1 -1
  18. package/dist/bundle/{chunk-RF54YDBB.js → chunk-5DFGJPT6.js} +4 -4
  19. package/dist/bundle/{chunk-TGREFJVA.js → chunk-5VSR5ENL.js} +7 -7
  20. package/dist/bundle/{chunk-VCGL2ETF.js → chunk-AUOXTGTU.js} +1 -1
  21. package/dist/bundle/{chunk-X4Y2ROJI.js → chunk-BBC546ZA.js} +91 -2
  22. package/dist/bundle/{chunk-QOWSVDPZ.js → chunk-BQYTIYGB.js} +106 -95
  23. package/dist/bundle/{chunk-XCKD54TN.js → chunk-CLWYQNSC.js} +5 -5
  24. package/dist/bundle/{chunk-7CBUCTB6.js → chunk-CRZPQQHE.js} +27 -33
  25. package/dist/bundle/chunk-DE7LFMY2.js +440 -0
  26. package/dist/bundle/{chunk-ODSVNH3H.js → chunk-ENE5CSVY.js} +2373 -1266
  27. package/dist/bundle/{chunk-G2US6LJB.js → chunk-ERQDBK5I.js} +1 -1
  28. package/dist/bundle/{chunk-W2336E7Y.js → chunk-F2TG3BA2.js} +4 -4
  29. package/dist/bundle/{chunk-DYNSP6FW.js → chunk-FBWOQMPE.js} +1442 -769
  30. package/dist/bundle/{chunk-5TPT2S2Z.js → chunk-FOUE7XLK.js} +1 -1
  31. package/dist/bundle/{chunk-RVCS7Q3A.js → chunk-GSKFAE3I.js} +1287 -512
  32. package/dist/bundle/{chunk-6IPY2QRG.js → chunk-HLAZ65AW.js} +1 -1
  33. package/dist/bundle/{chunk-A5JSTZZZ.js → chunk-JFSVXMN6.js} +2 -2
  34. package/dist/bundle/{chunk-N5UFBWDM.js → chunk-M5UH5CF3.js} +5 -7
  35. package/dist/bundle/{chunk-F7TDFWXY.js → chunk-MGG7JSNO.js} +2 -2
  36. package/dist/bundle/{chunk-H6OXALTJ.js → chunk-OCWARAFE.js} +1 -1
  37. package/dist/bundle/{chunk-S7ZNLLY5.js → chunk-OHBHHBYL.js} +2 -2
  38. package/dist/bundle/{chunk-5GKXETRP.js → chunk-PSH7K6TL.js} +610 -51
  39. package/dist/bundle/{chunk-VYDTI254.js → chunk-Q2NYEX4A.js} +53 -34
  40. package/dist/bundle/{chunk-G3ZRY436.js → chunk-QEPZUFPL.js} +46 -46
  41. package/dist/bundle/{chunk-BXQS5RCE.js → chunk-QL7CQ6VZ.js} +253 -78
  42. package/dist/bundle/{chunk-NC5WS7OP.js → chunk-SRU3OF4R.js} +1 -1
  43. package/dist/bundle/{chunk-PUBS2F5J.js → chunk-TV5DGHBT.js} +242 -242
  44. package/dist/bundle/{chunk-ZEOCU24Z.js → chunk-TXBUDJ3P.js} +1 -1
  45. package/dist/bundle/{chunk-ACGTFLEB.js → chunk-U4RRZUNP.js} +8 -8
  46. package/dist/bundle/{chunk-LPB2MDUW.js → chunk-UK3GAN7Q.js} +6 -6
  47. package/dist/bundle/{chunk-UN6CKIBN.js → chunk-UR6ASUSG.js} +8 -5
  48. package/dist/bundle/{chunk-U46UNBMT.js → chunk-V52SBQYF.js} +236 -13
  49. package/dist/bundle/{chunk-S2JSZWEC.js → chunk-VUJ34PEQ.js} +9 -9
  50. package/dist/bundle/{chunk-QYVVRQTN.js → chunk-W5EB4JLV.js} +2 -2
  51. package/dist/bundle/{chunk-3KHKYYCR.js → chunk-WMOEOVWZ.js} +1 -0
  52. package/dist/bundle/{chunk-VRSN7VLO.js → chunk-WVEHUKCZ.js} +1 -1
  53. package/dist/bundle/{chunk-64DK7S4F.js → chunk-XXTJUZMB.js} +1 -1
  54. package/dist/bundle/{chunk-54R2GDQ3.js → chunk-Y4XSWI22.js} +3 -3
  55. package/dist/bundle/{chunk-4ZS73HTJ.js → chunk-YHB57PFN.js} +1 -1
  56. package/dist/bundle/{chunk-G77QOTXE.js → chunk-ZRNRQFTF.js} +1 -1
  57. package/dist/bundle/{command-contract-TKDI7E56.js → command-contract-A6VZN3ZR.js} +11 -11
  58. package/dist/bundle/{echarts-QZ6PR3VC.js → echarts-27W2CIBD.js} +2 -2
  59. package/dist/bundle/{embed-UBXCXSRD.js → embed-FGJ273X2.js} +2 -2
  60. package/dist/bundle/{embedder-B4ZTKC23.js → embedder-7ELL3CQ3.js} +5 -5
  61. package/dist/bundle/{entry-BTUTHO5M.js → entry-SEE5YWIX.js} +3 -3
  62. package/dist/bundle/{first-run-UC4HRIFV.js → first-run-BD7FEC3W.js} +5 -5
  63. package/dist/bundle/{first-screen-SMCX6YKY.js → first-screen-ASZV6LSA.js} +12 -12
  64. package/dist/bundle/{identity-QSDEGDH7.js → identity-QR4F42T6.js} +1 -1
  65. package/dist/bundle/{instructions-BBGLZKO3.js → instructions-L74K64PV.js} +1 -1
  66. package/dist/bundle/{node-LZZX22VR.js → node-RSL3HANO.js} +2 -2
  67. package/dist/bundle/{node-sqlite-BPGT6T5U.js → node-sqlite-7R3PYQGJ.js} +2 -2
  68. package/dist/bundle/{oauth-XNE2KPKJ.js → oauth-4ESGXF6U.js} +5 -5
  69. package/dist/bundle/{open-SXGYZLB5.js → open-DFYEUGTA.js} +1 -1
  70. package/dist/bundle/{process-GPUXC4PG.js → process-RMV3AKLB.js} +1 -1
  71. package/dist/bundle/{program-NEXEAL7T.js → program-PIUYQHBF.js} +54 -59
  72. package/dist/bundle/{prompt-SORGLEYI.js → prompt-H7GYQQLL.js} +2 -2
  73. package/dist/bundle/{recognize-UJBXORVD.js → recognize-3GMOLZF4.js} +3 -3
  74. package/dist/bundle/{remote-W72AR7KH.js → remote-IRWTCI2B.js} +3 -3
  75. package/dist/bundle/{rerank-3Y2VZM3J.js → rerank-W3OSXXBN.js} +3 -3
  76. package/dist/bundle/{serve-VDZIVOPR.js → serve-ZCPO44NO.js} +7 -7
  77. package/dist/bundle/{server-ZFHN4GUF.js → server-FXU4QFRB.js} +35 -32
  78. package/dist/bundle/{server-BERXP4GW.js → server-YWL4HDOP.js} +68 -59
  79. package/dist/bundle/{state-DGR4EE3E.js → state-MJPTDIB5.js} +3 -3
  80. package/dist/bundle/{store-MRCFSCZD.js → store-6VNQG56O.js} +7 -7
  81. package/dist/bundle/store-maintenance-command-62TQTMER.js +43 -0
  82. package/dist/bundle/tg.js +2 -2
  83. package/dist/telegram/sending.d.ts.map +1 -1
  84. package/dist/telegram/sending.js +52 -3
  85. package/dist/telegram/sending.js.map +1 -1
  86. package/dist/version.d.ts +1 -1
  87. package/dist/version.js +1 -1
  88. package/package.json +2 -2
  89. package/dist/bundle/chunk-22PQUX72.js +0 -190
  90. package/dist/bundle/chunk-CJ6IYCYP.js +0 -583
  91. package/dist/bundle/chunk-NKJJJAIJ.js +0 -237
  92. package/dist/bundle/chunk-NMGO6LW6.js +0 -1950
  93. package/dist/bundle/chunk-OILBDLWL.js +0 -724
  94. package/dist/bundle/chunk-OPBTNQ35.js +0 -1007
  95. package/dist/bundle/store-maintenance-command-DCMZDMYS.js +0 -46
@@ -1,47 +1,30 @@
1
1
  import { createRequire as __tgRequire } from "node:module";
2
2
  const require = __tgRequire(import.meta.url);
3
- import {
4
- CEILING_KEY,
5
- COMMAND_PATH_KEY,
6
- LEVELS,
7
- LOG_ATTRIBUTES,
8
- RESOURCES,
9
- RESOURCE_KEY,
10
- assertOverridesTighten,
11
- currentRun,
12
- enclosingTraceId,
13
- fieldsOf,
14
- inRun,
15
- keyForCommand,
16
- layerPermissions,
17
- logAttributes,
18
- newRunId,
19
- permissionOverrides,
20
- projectFields,
21
- resolveOutput,
22
- runsDirFor,
23
- snakeLogger,
24
- startRun,
25
- stopWrites,
26
- traceOf,
27
- typedCommand,
28
- useAsProcessRun,
29
- withWriteScope
30
- } from "./chunk-OPBTNQ35.js";
31
3
  import {
32
4
  count,
33
5
  id,
34
6
  text,
35
7
  time
36
- } from "./chunk-54R2GDQ3.js";
8
+ } from "./chunk-Y4XSWI22.js";
9
+ import {
10
+ currentCaller,
11
+ endpointTemplate,
12
+ errorDetailOf,
13
+ framesOf,
14
+ isCliFailure,
15
+ keepsSuccess,
16
+ providerErrorKey,
17
+ renderEvent,
18
+ runContextOf
19
+ } from "./chunk-DE7LFMY2.js";
37
20
  import {
38
21
  permissionCeiling
39
- } from "./chunk-S7ZNLLY5.js";
22
+ } from "./chunk-OHBHHBYL.js";
40
23
  import {
41
24
  envName,
42
25
  readOnlyLockOf,
43
26
  readOnlyRefusal
44
- } from "./chunk-ZV24I2UJ.js";
27
+ } from "./chunk-2SUTCDGO.js";
45
28
  import {
46
29
  FIELD_TYPES,
47
30
  QUERY_BACKENDS,
@@ -50,20 +33,24 @@ import {
50
33
  TASK_STATES,
51
34
  TASK_TYPES,
52
35
  describeQuery
53
- } from "./chunk-G3ZRY436.js";
36
+ } from "./chunk-QEPZUFPL.js";
54
37
  import {
55
38
  sharedConfigPath
56
- } from "./chunk-W2336E7Y.js";
39
+ } from "./chunk-F2TG3BA2.js";
57
40
  import {
58
41
  storePath
59
- } from "./chunk-G77QOTXE.js";
42
+ } from "./chunk-ZRNRQFTF.js";
60
43
  import {
61
44
  configFilePath,
62
45
  createRecordLog,
46
+ createRenderer,
63
47
  exitCodeOfAnswer,
48
+ fieldsOf,
64
49
  processStreams,
50
+ projectFields,
65
51
  resolvePaths,
66
52
  saveConfigFile,
53
+ singleLine,
67
54
  writeSecurely
68
55
  } from "./chunk-DG62L57H.js";
69
56
  import {
@@ -76,10 +63,9 @@ import {
76
63
  defineLogEvents,
77
64
  defineSteps,
78
65
  effectsSchema,
79
- errorCodes,
80
66
  getDotPath,
81
67
  integer,
82
- isContentKey,
68
+ isCliError,
83
69
  itemEnvelopeSchema,
84
70
  jsonlOf,
85
71
  lazy,
@@ -103,6 +89,7 @@ import {
103
89
  stepOf,
104
90
  strictObject,
105
91
  string,
92
+ traceIdOf,
106
93
  trim,
107
94
  union,
108
95
  unknown,
@@ -132,8 +119,8 @@ var snake = /* @__PURE__ */ __name((name) => name.replace(/[A-Z]/g, (letter) =>
132
119
  var stepTargets = /* @__PURE__ */ __name((root) => {
133
120
  const found = /* @__PURE__ */ new Map();
134
121
  const optionName = /* @__PURE__ */ __name((option) => snake((option.long ?? option.attributeName()).replace(/^--/, "")), "optionName");
135
- const visit2 = /* @__PURE__ */ __name((command, parents, above) => {
136
- const path2 = [...parents, command.name()];
122
+ const visit2 = /* @__PURE__ */ __name((command, parents2, above) => {
123
+ const path2 = [...parents2, command.name()];
137
124
  const options = [...above, ...command.options];
138
125
  const { effects } = metaOf(command);
139
126
  found.set(path2.join(" "), {
@@ -155,8 +142,8 @@ var describeAlone = /* @__PURE__ */ __name((command, known) => {
155
142
  }
156
143
  return found;
157
144
  }, "describeAlone");
158
- var describe = /* @__PURE__ */ __name((command, cli, parents, above, known) => {
159
- const path2 = [...parents, command.name()];
145
+ var describe = /* @__PURE__ */ __name((command, cli, parents2, above, known) => {
146
+ const path2 = [...parents2, command.name()];
160
147
  const args = command.registeredArguments.map(describeArgument);
161
148
  const options = describeOptions(command);
162
149
  const { origin = "handwritten", query, mcp, offline, ...meta } = metaOf(command);
@@ -3906,7 +3893,140 @@ var refuseJoinedPath = /* @__PURE__ */ __name((root, args, prefix = []) => {
3906
3893
  }
3907
3894
  }, "refuseJoinedPath");
3908
3895
 
3909
- // node_modules/.pnpm/@wirecat+cli-core@0.466.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.64.0_commander@15._f7e4048410ccbe1e801fd184c043d197/node_modules/@wirecat/cli-core/dist/cli/execution.js
3896
+ // node_modules/.pnpm/@wirecat+cli-core@0.467.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.64.0_commander@15._7a700db966f96e9df6d3178e7072efc2/node_modules/@wirecat/cli-core/dist/sends/guarded.js
3897
+ import { AsyncLocalStorage } from "node:async_hooks";
3898
+ var sentIds = /* @__PURE__ */ __name((typed, message) => ({
3899
+ messageId: message.id,
3900
+ ...message.chatId && message.chatId !== typed ? { resultChatId: message.chatId } : {}
3901
+ }), "sentIds");
3902
+ var current = new AsyncLocalStorage();
3903
+ var writesInFlight = new AsyncLocalStorage();
3904
+ var parents = /* @__PURE__ */ new WeakMap();
3905
+ var stopped = /* @__PURE__ */ new WeakMap();
3906
+ var scopesFor = /* @__PURE__ */ __name((scope = writesInFlight.getStore()) => {
3907
+ const result = [];
3908
+ for (let at = scope; at; at = parents.get(at))
3909
+ result.push(at);
3910
+ return result;
3911
+ }, "scopesFor");
3912
+ var withWriteScope = /* @__PURE__ */ __name((scope, body) => {
3913
+ const parent = writesInFlight.getStore();
3914
+ if (parent && parent !== scope)
3915
+ parents.set(scope, parent);
3916
+ return writesInFlight.run(scope, body);
3917
+ }, "withWriteScope");
3918
+ var stopWrites = /* @__PURE__ */ __name((scope, reason) => {
3919
+ stopped.set(scope, reason);
3920
+ for (const write of scope)
3921
+ write.cut();
3922
+ }, "stopWrites");
3923
+ var refuseStopped = /* @__PURE__ */ __name((scopes3) => {
3924
+ for (const scope of scopes3)
3925
+ if (stopped.has(scope))
3926
+ throw stopped.get(scope);
3927
+ }, "refuseStopped");
3928
+ var currentOperation = /* @__PURE__ */ __name(() => current.getStore(), "currentOperation");
3929
+ var guardedWrite = /* @__PURE__ */ __name(async (guard, attempt, act, settled2 = () => ({}), prepare) => {
3930
+ const scopes3 = scopesFor();
3931
+ refuseStopped(scopes3);
3932
+ try {
3933
+ await guard.ask?.(attempt);
3934
+ refuseStopped(scopes3);
3935
+ if (guard.reserve) {
3936
+ guard.check(attempt, { reserve: false });
3937
+ await guard.reserve(attempt);
3938
+ } else
3939
+ guard.check(attempt);
3940
+ } catch (error) {
3941
+ guard.record({ ...attempt, outcome: "refused", errorCode: codeOf(error) });
3942
+ throw error;
3943
+ }
3944
+ try {
3945
+ refuseStopped(scopes3);
3946
+ } catch (error) {
3947
+ guard.record({ ...attempt, outcome: "failed", errorCode: codeOf(error) });
3948
+ throw error;
3949
+ }
3950
+ let recorded2 = false;
3951
+ const once = /* @__PURE__ */ __name((entry) => {
3952
+ if (recorded2)
3953
+ return;
3954
+ recorded2 = true;
3955
+ guard.record(entry);
3956
+ }, "once");
3957
+ let cancelled = false;
3958
+ const flight = {
3959
+ operationId: attempt.operationId,
3960
+ preparing: prepare !== void 0,
3961
+ cut: /* @__PURE__ */ __name(() => {
3962
+ cancelled = true;
3963
+ once({
3964
+ ...attempt,
3965
+ outcome: flight.preparing ? "failed" : "outcome_unknown",
3966
+ errorCode: flight.preparing ? "timeout" : "outcome_unknown"
3967
+ });
3968
+ }, "cut")
3969
+ };
3970
+ for (const scope of scopes3)
3971
+ scope.add(flight);
3972
+ try {
3973
+ if (prepare !== void 0)
3974
+ await prepare();
3975
+ if (cancelled)
3976
+ throw new CliError("timeout", "the command ended before sending; nothing was sent", { sent: false });
3977
+ flight.preparing = false;
3978
+ const done = await current.run(attempt.operationId, act);
3979
+ if (cancelled)
3980
+ throw new CliError("outcome_unknown", "the command ended with a write in flight; check its result before continuing", { operation_id: attempt.operationId });
3981
+ once({ ...attempt, ...settled2(done), outcome: "sent" });
3982
+ return done;
3983
+ } catch (error) {
3984
+ const code = codeOf(error);
3985
+ once({ ...attempt, outcome: code === "outcome_unknown" ? "outcome_unknown" : "failed", errorCode: code });
3986
+ if (code === "outcome_unknown" && error instanceof Error)
3987
+ throw new CliError("outcome_unknown", error.message, {
3988
+ ...error.details,
3989
+ operation_id: attempt.operationId,
3990
+ retryable: false
3991
+ });
3992
+ if (flight.preparing && isCliError(error) && error.details.sent === void 0)
3993
+ throw new CliError(error.code, error.message, { ...error.details, sent: false });
3994
+ throw error;
3995
+ } finally {
3996
+ for (const scope of scopes3)
3997
+ scope.delete(flight);
3998
+ }
3999
+ }, "guardedWrite");
4000
+ var codeOf = /* @__PURE__ */ __name((error) => typeof error?.code === "string" ? error.code : "unknown", "codeOf");
4001
+
4002
+ // node_modules/.pnpm/@wirecat+cli-core@0.467.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.64.0_commander@15._7a700db966f96e9df6d3178e7072efc2/node_modules/@wirecat/cli-core/dist/cli/result-fields.js
4003
+ var named = /* @__PURE__ */ __name((work) => {
4004
+ try {
4005
+ return work();
4006
+ } catch (error) {
4007
+ if (error instanceof CliError && error.code === "validation_error")
4008
+ throw new CliError("validation_error", "--json takes comma-separated field paths, for example --json=id,text", {
4009
+ param: "--json"
4010
+ });
4011
+ throw error;
4012
+ }
4013
+ }, "named");
4014
+ var fieldsOf2 = /* @__PURE__ */ __name((value) => named(() => fieldsOf(value)), "fieldsOf");
4015
+ var projectCommands = /* @__PURE__ */ __name((commands, fields) => commands.map((command) => ({
4016
+ ...projectFields(command, fields),
4017
+ path: command.path,
4018
+ name: command.name,
4019
+ origin: command.origin,
4020
+ effects: command.effects,
4021
+ commands: projectCommands(command.commands, fields)
4022
+ })), "projectCommands");
4023
+ var projectFields2 = /* @__PURE__ */ __name((value, fields) => named(() => {
4024
+ if (value && typeof value === "object" && "cli" in value && typeof value.cli === "string" && "contract" in value && "commands" in value && Array.isArray(value.commands))
4025
+ return { ...value, commands: projectCommands(value.commands, fields) };
4026
+ return projectFields(value, fields);
4027
+ }), "projectFields");
4028
+
4029
+ // node_modules/.pnpm/@wirecat+cli-core@0.467.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.64.0_commander@15._7a700db966f96e9df6d3178e7072efc2/node_modules/@wirecat/cli-core/dist/cli/execution.js
3910
4030
  var DEFAULT_COMMAND_MS = 3e4;
3911
4031
  var DEFAULT_COOPERATIVE_MS = 5 * 6e4;
3912
4032
  var DEFAULT_AGENT_COOPERATIVE_MS = 45e3;
@@ -3923,7 +4043,7 @@ var execution = /* @__PURE__ */ __name((streams, { timeoutMs, fields, maxOutputB
3923
4043
  const closeables = /* @__PURE__ */ new Set();
3924
4044
  const closing = /* @__PURE__ */ new WeakMap();
3925
4045
  const originals = /* @__PURE__ */ new Map();
3926
- let paths = fields === void 0 ? void 0 : fieldsOf(fields);
4046
+ let paths = fields === void 0 ? void 0 : fieldsOf2(fields);
3927
4047
  let active = true;
3928
4048
  let bytes = 0;
3929
4049
  let timer;
@@ -3964,7 +4084,7 @@ var execution = /* @__PURE__ */ __name((streams, { timeoutMs, fields, maxOutputB
3964
4084
  start(timeoutMs);
3965
4085
  return {
3966
4086
  configure: /* @__PURE__ */ __name((options) => {
3967
- paths = options.fields === void 0 ? void 0 : fieldsOf(options.fields);
4087
+ paths = options.fields === void 0 ? void 0 : fieldsOf2(options.fields);
3968
4088
  maxOutputBytes = options.maxOutputBytes;
3969
4089
  }, "configure"),
3970
4090
  start,
@@ -3994,7 +4114,7 @@ var execution = /* @__PURE__ */ __name((streams, { timeoutMs, fields, maxOutputB
3994
4114
  let result = text2;
3995
4115
  if (paths) {
3996
4116
  try {
3997
- result = JSON.stringify(projectFields(JSON.parse(text2), paths));
4117
+ result = JSON.stringify(projectFields2(JSON.parse(text2), paths));
3998
4118
  } catch (error) {
3999
4119
  if (error instanceof CliError)
4000
4120
  throw error;
@@ -4004,8 +4124,8 @@ var execution = /* @__PURE__ */ __name((streams, { timeoutMs, fields, maxOutputB
4004
4124
  });
4005
4125
  }
4006
4126
  }
4007
- const size2 = Buffer.byteLength(result) + 1;
4008
- if (maxOutputBytes !== 0 && bytes + size2 > maxOutputBytes)
4127
+ const size = Buffer.byteLength(result) + 1;
4128
+ if (maxOutputBytes !== 0 && bytes + size > maxOutputBytes)
4009
4129
  throw new CliError("invalid_response", `machine output exceeds ${maxOutputBytes} bytes \u2014 reduce --limit, pick fields with --json=a,b or raise --max-output-bytes`, {
4010
4130
  retryable: false,
4011
4131
  reason: "output.too-large",
@@ -4013,7 +4133,7 @@ var execution = /* @__PURE__ */ __name((streams, { timeoutMs, fields, maxOutputB
4013
4133
  emitted_bytes: bytes,
4014
4134
  partial_output: bytes > 0
4015
4135
  });
4016
- bytes += size2;
4136
+ bytes += size;
4017
4137
  streams.data(result);
4018
4138
  }, "data"),
4019
4139
  diagnostic: /* @__PURE__ */ __name((text2) => {
@@ -4087,7 +4207,396 @@ var withAbort = /* @__PURE__ */ __name(async (signal, body) => {
4087
4207
  }
4088
4208
  }, "withAbort");
4089
4209
 
4090
- // node_modules/.pnpm/@wirecat+cli-core@0.466.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.64.0_commander@15._f7e4048410ccbe1e801fd184c043d197/node_modules/@wirecat/cli-core/dist/cli/messenger/accounts.js
4210
+ // node_modules/.pnpm/@wirecat+cli-core@0.467.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.64.0_commander@15._7a700db966f96e9df6d3178e7072efc2/node_modules/@wirecat/cli-core/dist/sends/permissions.js
4211
+ var LEVELS = ["deny", "readonly", "ask", "allow"];
4212
+ var DANGEROUS = /* @__PURE__ */ new Set(["messages.delete", "bot.messages.delete", "topics.delete", "chats.delete", "chats.clear"]);
4213
+ var skipFlagFor = /* @__PURE__ */ __name((key) => DANGEROUS.has(key) ? "--allow-dangerous" : "--yes", "skipFlagFor");
4214
+ var DEFAULT_PERMISSIONS = {
4215
+ "messages.delete": "ask",
4216
+ "account.sessions.end": "ask",
4217
+ "bot.messages.delete": "ask",
4218
+ "topics.enable": "ask",
4219
+ "topics.delete": "ask",
4220
+ "chats.delete": "ask",
4221
+ "chats.clear": "ask",
4222
+ // NEED-568: a rule writes to people with nobody typing a command; it waits for the owner's own allow.
4223
+ "replies.send": "deny",
4224
+ // NEED-1662: an agent that changes settings, schedules or recipients could lift its own limits; the owner opts in.
4225
+ "mcp.authority": "deny",
4226
+ // NEED-1663: writes no level stopped before, so MCP could not offer them; over MCP `ask` goes ahead.
4227
+ "store.backup": "ask",
4228
+ "store.restore": "ask",
4229
+ "store.migrate": "ask",
4230
+ "store.repair": "ask",
4231
+ "store.reset": "ask",
4232
+ "store.clear": "ask",
4233
+ "store.decrypt": "ask",
4234
+ "store.copies.delete": "ask",
4235
+ "server.start": "ask",
4236
+ "server.stop": "ask",
4237
+ "server.restart": "ask",
4238
+ "models.download": "ask",
4239
+ "images.models.download": "ask",
4240
+ "schedule.run": "ask",
4241
+ "schedule.exec": "ask",
4242
+ "doctor.reports.create": "ask"
4243
+ };
4244
+ var KEYED_UNDER_HOUSEKEEPING = new Set(Object.keys(DEFAULT_PERMISSIONS).filter((key) => /^(store|server|models|images|schedule|doctor)\./.test(key)));
4245
+ var AUTHORITY_KEY = "mcp.authority";
4246
+ var authorityAllowed = /* @__PURE__ */ __name((levels) => {
4247
+ const { level } = levelFor(levels, AUTHORITY_KEY);
4248
+ return level === "allow" || level === "ask";
4249
+ }, "authorityAllowed");
4250
+ var BOT_API_KEY = "bot.api";
4251
+ var isBotApi = /* @__PURE__ */ __name((path2) => path2[0] === "bot" && path2[1] === "api", "isBotApi");
4252
+ var botApiAllowed = /* @__PURE__ */ __name((levels) => {
4253
+ const { level } = levelFor(levels, BOT_API_KEY, { ...DEFAULT_PERMISSIONS, [BOT_API_KEY]: "deny" });
4254
+ return level === "allow" || level === "ask";
4255
+ }, "botApiAllowed");
4256
+ var RESOURCES = [
4257
+ "messages",
4258
+ "drafts",
4259
+ "reactions",
4260
+ "polls",
4261
+ "topics",
4262
+ "chats",
4263
+ "contacts",
4264
+ "account",
4265
+ "bot",
4266
+ "conversations",
4267
+ "tags",
4268
+ "mentions",
4269
+ "search",
4270
+ "searches",
4271
+ "tasks",
4272
+ "replies",
4273
+ "attachments",
4274
+ "stats",
4275
+ "store",
4276
+ "metadata",
4277
+ "mcp",
4278
+ "server",
4279
+ "models",
4280
+ "schedule",
4281
+ "doctor",
4282
+ "images"
4283
+ ];
4284
+ var layerPermissions = /* @__PURE__ */ __name((layers) => {
4285
+ const levels = {};
4286
+ const sources = {};
4287
+ for (const [from, layer] of layers) {
4288
+ const nearer = Object.keys(levels);
4289
+ for (const [key, level] of Object.entries(layer ?? {})) {
4290
+ if (nearer.some((named2) => key === named2 || key.startsWith(`${named2}.`)))
4291
+ continue;
4292
+ levels[key] = level;
4293
+ sources[key] = from;
4294
+ }
4295
+ }
4296
+ return { levels, sources };
4297
+ }, "layerPermissions");
4298
+ var CEILING_KEY = "*";
4299
+ var ALLOWED = { level: "allow", key: null };
4300
+ var ORDER = { deny: 0, readonly: 1, ask: 2, allow: 3 };
4301
+ var nearest = /* @__PURE__ */ __name((levels, key) => {
4302
+ for (let parts = key.split("."); parts.length > 0; parts = parts.slice(0, -1)) {
4303
+ const named2 = parts.join(".");
4304
+ const level = levels[named2];
4305
+ if (level)
4306
+ return { level, key: named2, depth: parts.length };
4307
+ }
4308
+ return void 0;
4309
+ }, "nearest");
4310
+ var levelFor = /* @__PURE__ */ __name((permissions, key, defaults = DEFAULT_PERMISSIONS) => {
4311
+ const found = profileLevel(permissions, key, defaults);
4312
+ const ceiling = permissions[CEILING_KEY];
4313
+ return ceiling && ORDER[ceiling] < ORDER[found.level] ? { level: ceiling, key: CEILING_KEY } : found;
4314
+ }, "levelFor");
4315
+ var profileLevel = /* @__PURE__ */ __name((permissions, key, defaults) => {
4316
+ const own = nearest(permissions, key);
4317
+ const builtIn = nearest(defaults, key);
4318
+ if (!builtIn || own && own.depth >= builtIn.depth)
4319
+ return own ? { level: own.level, key: own.key } : ALLOWED;
4320
+ if (!own || ORDER[builtIn.level] <= ORDER[own.level])
4321
+ return { level: builtIn.level, key: builtIn.key };
4322
+ return { level: own.level, key: own.key };
4323
+ }, "profileLevel");
4324
+ var CHAT_KEYS = {
4325
+ settings: "chats.update",
4326
+ "requests.accept": "chats.requests.confirm",
4327
+ "requests.decline": "chats.requests.reject",
4328
+ "link.create": "chats.links.create",
4329
+ "link.reset": "chats.links.reset",
4330
+ "link.revoke": "chats.links.remove",
4331
+ "link.update": "chats.links.update"
4332
+ };
4333
+ var ACCOUNT_KEYS = {
4334
+ "contact-add": "contacts.add",
4335
+ "contact-remove": "contacts.remove",
4336
+ "contact-import": "contacts.import",
4337
+ "contact-rename": "contacts.rename",
4338
+ "contact-block": "contacts.block",
4339
+ "contact-unblock": "contacts.unblock",
4340
+ profile: "account.update",
4341
+ "folder-create": "chats.folders.create",
4342
+ "folder-update": "chats.folders.update",
4343
+ "folder-delete": "chats.folders.delete",
4344
+ "folder-order": "chats.folders.order",
4345
+ "folder-join": "chats.folders.join",
4346
+ "sessions-end": "account.sessions.end",
4347
+ "chat-mute": "chats.mute",
4348
+ "chat-unmute": "chats.unmute",
4349
+ "chat-archive": "chats.archive",
4350
+ "chat-unarchive": "chats.unarchive",
4351
+ "chat-pin": "chats.pin",
4352
+ "chat-unpin": "chats.unpin",
4353
+ "chat-mark-unread": "chats.mark-unread",
4354
+ "message-star": "messages.star",
4355
+ "message-unstar": "messages.unstar",
4356
+ privacy: "account.privacy.set"
4357
+ };
4358
+ var KIND_KEYS = {
4359
+ message: "messages.send",
4360
+ forward: "messages.forward",
4361
+ edit: "messages.edit",
4362
+ pin: "messages.pin",
4363
+ reaction: "reactions",
4364
+ read: "chats.mark-read",
4365
+ delete: "messages.delete"
4366
+ };
4367
+ var keyForWrite = /* @__PURE__ */ __name((kind, action) => {
4368
+ if (kind === "chat")
4369
+ return CHAT_KEYS[action] ?? `chats.${action ?? "update"}`;
4370
+ if (kind === "account") {
4371
+ const key = ACCOUNT_KEYS[action];
4372
+ if (!key)
4373
+ throw new Error(`an account change without a known action: ${action}`);
4374
+ return key;
4375
+ }
4376
+ return KIND_KEYS[kind];
4377
+ }, "keyForWrite");
4378
+ var writeOfKey = /* @__PURE__ */ __name((key) => {
4379
+ const account = Object.entries(ACCOUNT_KEYS).find(([, named2]) => named2 === key)?.[0];
4380
+ if (account)
4381
+ return { kind: "account", action: account };
4382
+ const kind = Object.entries(KIND_KEYS).find(([, named2]) => named2 === key || key.startsWith(`${named2}.`))?.[0];
4383
+ if (kind)
4384
+ return { kind };
4385
+ if (key === "messages.unpin")
4386
+ return { kind: "pin" };
4387
+ if (key.startsWith("chats.")) {
4388
+ const action = Object.entries(CHAT_KEYS).find(([, named2]) => named2 === key)?.[0] ?? key.slice("chats.".length);
4389
+ return { kind: "chat", action };
4390
+ }
4391
+ return {};
4392
+ }, "writeOfKey");
4393
+ var NAMED_WRITE_KEYS = [
4394
+ "drafts",
4395
+ "store.gaps.repair",
4396
+ "messages.sync-first",
4397
+ "messages.server-search",
4398
+ "messages.press",
4399
+ "chats.start",
4400
+ "chats.app",
4401
+ "stats.messages.counters.sync",
4402
+ "stats.messages.show.sync-first",
4403
+ "stats.messages.top.sync-first",
4404
+ "stats.contacts.top.sync-first",
4405
+ "account.sessions.list",
4406
+ "attachments.extract",
4407
+ "attachments.move",
4408
+ "attachments.update",
4409
+ "bot.callbacks.answer",
4410
+ "bot.chats.action",
4411
+ "bot.chats.admins.add",
4412
+ "bot.chats.admins.remove",
4413
+ "bot.chats.leave",
4414
+ "bot.chats.members.remove",
4415
+ "bot.chats.moderate",
4416
+ "bot.messages.delete",
4417
+ "bot.messages.edit",
4418
+ "bot.messages.pin",
4419
+ "bot.messages.send",
4420
+ "bot.messages.unpin",
4421
+ "chats.admins.add",
4422
+ "chats.admins.remove",
4423
+ "chats.links.create",
4424
+ "chats.links.reset",
4425
+ "chats.links.remove",
4426
+ "chats.links.update",
4427
+ "chats.members.add",
4428
+ "chats.members.remove",
4429
+ "chats.moderate",
4430
+ "conversations.embeddings",
4431
+ "conversations.links",
4432
+ "polls.close",
4433
+ "polls.create",
4434
+ "polls.vote",
4435
+ "searches.clear",
4436
+ "searches.create",
4437
+ "searches.delete",
4438
+ "contacts.aliases.set",
4439
+ "contacts.aliases.remove",
4440
+ "contacts.notes.add",
4441
+ "contacts.notes.edit",
4442
+ "contacts.notes.remove",
4443
+ "tags.rebuild",
4444
+ "metadata.sync",
4445
+ "mentions.rebuild",
4446
+ "mentions.confirm",
4447
+ "mentions.reject",
4448
+ "tags.add",
4449
+ "tags.remove",
4450
+ "tasks.add",
4451
+ "tasks.claim",
4452
+ "tasks.close",
4453
+ "tasks.duplicates.defer",
4454
+ "tasks.duplicates.reject",
4455
+ "tasks.link",
4456
+ "tasks.merge",
4457
+ "tasks.update",
4458
+ "tasks.release",
4459
+ "tasks.scan",
4460
+ "tasks.unmerge",
4461
+ "topics.create",
4462
+ "topics.edit",
4463
+ "topics.enable"
4464
+ ];
4465
+ var WRITE_KEYS = [
4466
+ .../* @__PURE__ */ new Set([
4467
+ ...NAMED_WRITE_KEYS,
4468
+ ...Object.keys(DEFAULT_PERMISSIONS),
4469
+ ...Object.values(KIND_KEYS),
4470
+ ...Object.values(ACCOUNT_KEYS),
4471
+ ...Object.values(CHAT_KEYS)
4472
+ ])
4473
+ ];
4474
+ var HOUSEKEEPING = /* @__PURE__ */ new Set([
4475
+ "help",
4476
+ "guide",
4477
+ "config",
4478
+ "session",
4479
+ "doctor",
4480
+ "commands",
4481
+ "complete",
4482
+ "upgrade",
4483
+ "skill",
4484
+ "models",
4485
+ "server",
4486
+ // What a schedule runs is checked by its own key when it runs; an agent runs read-only.
4487
+ "schedule",
4488
+ "runs",
4489
+ "sends",
4490
+ "recipients",
4491
+ "flood",
4492
+ "mcp",
4493
+ // Its commands read the rules or flip the pause switch; what a rule sends is checked as `replies.send`.
4494
+ "replies"
4495
+ ]);
4496
+ var BOT_HOUSEKEEPING = /* @__PURE__ */ new Set(["auth", "list", "sends", "recipients", "mcp"]);
4497
+ var STORE_MAINTENANCE = /* @__PURE__ */ new Set(["info", "check", "copies"]);
4498
+ var SHOW_MESSAGES = /* @__PURE__ */ new Set(["inbox", "review", "watch", "serve", "store", "conversations"]);
4499
+ var readKeysForCommand = /* @__PURE__ */ __name((path2) => {
4500
+ if (path2[0] === "bot")
4501
+ return readKeysForCommand(path2.slice(1)).map((key2) => `bot.${key2}`);
4502
+ const key = keyForCommand(path2);
4503
+ if (!key)
4504
+ return [];
4505
+ if (path2[0] === "attachments" && path2[1] === "download")
4506
+ return [key, "messages", "chats"];
4507
+ if (path2[0] === "attachments" && (path2[1] === "extract" || path2[1] === "show"))
4508
+ return [key, "messages"];
4509
+ if (path2[0] === "store" && path2[1] === "gaps" && path2[2] === "repair")
4510
+ return [key, "messages"];
4511
+ if (path2[0] === "store" && ["reset", "clear", "decrypt"].includes(path2[1] ?? ""))
4512
+ return [key, "messages"];
4513
+ if (path2[0] === "search") {
4514
+ if (path2[1] === "notes")
4515
+ return [key];
4516
+ if (path2[1] === "topics")
4517
+ return [key, "topics"];
4518
+ if (path2[1] === "conversations")
4519
+ return [key, "messages", "conversations"];
4520
+ return [key, "messages"];
4521
+ }
4522
+ if (path2[0] !== "stats")
4523
+ return [key];
4524
+ const resource = path2[1] === "charts" ? "chats" : path2[1];
4525
+ return [
4526
+ .../* @__PURE__ */ new Set([
4527
+ key,
4528
+ "messages",
4529
+ ...["chats", "contacts", "tasks"].includes(resource ?? "") ? [resource] : []
4530
+ ])
4531
+ ];
4532
+ }, "readKeysForCommand");
4533
+ var keyForCommand = /* @__PURE__ */ __name((path2) => {
4534
+ if (path2.length === 0)
4535
+ return null;
4536
+ const [top, next] = path2;
4537
+ if (top === "bot") {
4538
+ if (next === void 0 || BOT_HOUSEKEEPING.has(next))
4539
+ return null;
4540
+ const inner = keyForCommand(path2.slice(1));
4541
+ return `bot.${inner ?? path2.slice(1).join(".")}`;
4542
+ }
4543
+ if (KEYED_UNDER_HOUSEKEEPING.has(path2.join(".")))
4544
+ return path2.join(".");
4545
+ if (top === void 0 || HOUSEKEEPING.has(top) || top === "search" && next === "runs")
4546
+ return null;
4547
+ if (top === "images" && next === "models")
4548
+ return null;
4549
+ if (top === "attachments" && (next === "check" || next === "jobs"))
4550
+ return null;
4551
+ if (top === "attachments" && next === "download")
4552
+ return "messages";
4553
+ if (top === "store" && next !== void 0 && STORE_MAINTENANCE.has(next))
4554
+ return null;
4555
+ if (top === "conversations" && next === "links")
4556
+ return path2[2] === "rebuild" ? "conversations.links.rebuild" : "conversations.links";
4557
+ if (top === "conversations" && (next === "embeddings" || next === "embed") || top === "images" && next === "embed" || top === "conversations" && next === "rebuild")
4558
+ return "conversations.embeddings";
4559
+ if (top === "attachments" && next === "list" || top === "chats" && next === "documents")
4560
+ return "messages";
4561
+ if (top === "mentions")
4562
+ return next === "rebuild" || next === "confirm" || next === "reject" ? `mentions.${next}` : "messages";
4563
+ if (top === "store" && (next === "gaps" || next === "jobs"))
4564
+ return path2.join(".");
4565
+ if (SHOW_MESSAGES.has(top) || top === "contacts" && (next === "context" || next === "prepare" || next === "events"))
4566
+ return "messages";
4567
+ if (RESOURCES.includes(top))
4568
+ return path2.join(".");
4569
+ return void 0;
4570
+ }, "keyForCommand");
4571
+ var RESOURCE_KEY = new RegExp(`^(${RESOURCES.join("|")})(\\.[a-z][a-z-]*)*$`);
4572
+ var COMMAND_PATH_KEY = /^[a-z][a-z-]*(\.[a-zA-Z][a-zA-Z-]*)*$/;
4573
+ var permissionOverrides = /* @__PURE__ */ __name((entries = [], shape = RESOURCE_KEY) => {
4574
+ const levels = {};
4575
+ const example = shape === RESOURCE_KEY ? "messages.send=allow" : "api=readonly";
4576
+ for (const entry of entries) {
4577
+ const [key = "", level = "", extra] = entry.split("=");
4578
+ if (!shape.test(key) || !LEVELS.includes(level) || extra !== void 0)
4579
+ throw new CliError("validation_error", `--permission takes a command path and level, e.g. ${example} (deny, readonly, ask, allow)`);
4580
+ levels[key] = level;
4581
+ }
4582
+ return levels;
4583
+ }, "permissionOverrides");
4584
+ var assertOverridesTighten = /* @__PURE__ */ __name((overrides, profile, defaults = DEFAULT_PERMISSIONS) => {
4585
+ for (const [key, level] of Object.entries(overrides)) {
4586
+ const under = Object.keys(profile).filter((named2) => named2.startsWith(`${key}.`));
4587
+ const lifted = [key, ...under].find((named2) => ORDER[level] > ORDER[levelFor(profile, named2, defaults).level]);
4588
+ if (lifted !== void 0)
4589
+ throw new CliError("validation_error", `--permission ${key}=${level} would loosen ${lifted} from ${levelFor(profile, lifted, defaults).level}; it only tightens \u2014 change the profile's permissions to loosen it`, { key, lifted });
4590
+ }
4591
+ }, "assertOverridesTighten");
4592
+ var assertRetentionEvidenceRead = /* @__PURE__ */ __name((permissions) => {
4593
+ for (const permission of ["stats.chats.retention", "chats"]) {
4594
+ if (levelFor(permissions, permission).level === "deny")
4595
+ throw new CliError("permission_error", `profile denies ${permission}`, { permission });
4596
+ }
4597
+ }, "assertRetentionEvidenceRead");
4598
+
4599
+ // node_modules/.pnpm/@wirecat+cli-core@0.467.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.64.0_commander@15._7a700db966f96e9df6d3178e7072efc2/node_modules/@wirecat/cli-core/dist/cli/messenger/accounts.js
4091
4600
  import { existsSync, readdirSync, readFileSync } from "node:fs";
4092
4601
  import { join } from "node:path";
4093
4602
  var accountFileFor = /* @__PURE__ */ __name((app, profile, env) => join(resolvePaths({ appName: app.appName, prefix: app.envPrefix, env }).state, "accounts", `${profile}.json`), "accountFileFor");
@@ -4109,249 +4618,85 @@ var profilesWithAccounts = /* @__PURE__ */ __name((app, env) => {
4109
4618
  }, "profilesWithAccounts");
4110
4619
  var profilesHere = /* @__PURE__ */ __name((app, configured, env) => [.../* @__PURE__ */ new Set([...configured, ...profilesWithAccounts(app, env)])].sort(), "profilesHere");
4111
4620
 
4112
- // node_modules/.pnpm/@wirecat+cli-core@0.466.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.64.0_commander@15._f7e4048410ccbe1e801fd184c043d197/node_modules/@wirecat/cli-core/dist/errors/failures.js
4113
- var isCliFailure = /* @__PURE__ */ __name((value) => value instanceof Error && value.name === "CliError" && errorCodes.includes(value.code), "isCliFailure");
4114
- var isCommanderFailure = /* @__PURE__ */ __name((value) => {
4115
- const { code, exitCode } = value ?? {};
4116
- return value instanceof Error && typeof code === "string" && code.startsWith("commander.") && typeof exitCode === "number";
4117
- }, "isCommanderFailure");
4118
- var failureKey = /* @__PURE__ */ __name((error) => isCliFailure(error) ? error.code : error instanceof Error ? error.name : "error", "failureKey");
4119
-
4120
- // node_modules/.pnpm/@wirecat+cli-core@0.466.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.64.0_commander@15._f7e4048410ccbe1e801fd184c043d197/node_modules/@wirecat/cli-core/dist/runs/error-detail.js
4121
- import { homedir } from "node:os";
4122
-
4123
- // node_modules/.pnpm/@wirecat+cli-core@0.466.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.64.0_commander@15._f7e4048410ccbe1e801fd184c043d197/node_modules/@wirecat/cli-core/dist/runs/events.js
4124
- var providerErrorKey = /* @__PURE__ */ __name((value) => typeof value === "string" && /^[A-Za-z][A-Za-z0-9._-]{0,63}$/.test(value) ? value : void 0, "providerErrorKey");
4125
- var renderEvent = /* @__PURE__ */ __name((event) => {
4126
- if (event.event === "warning") {
4127
- const counts = Object.entries(event.counts ?? {}).map(([field, count3]) => `${count3} ${field}`);
4128
- return [`${MARK.warning} ${(event.operation ?? "").padEnd(16)} ${event.code}`, ...counts, event.detail].filter(Boolean).join(" ");
4129
- }
4130
- const parts = [];
4131
- if (event.event === "cache") {
4132
- parts.push(event.reason);
4133
- if (event.ageMs !== void 0)
4134
- parts.push(`cached ${age(event.ageMs)}`);
4135
- } else {
4136
- if (event.opcode !== void 0)
4137
- parts.push(`op ${event.opcode}`, `seq ${event.seq}`);
4138
- if (event.method !== void 0 || event.endpointTemplate !== void 0)
4139
- parts.push([event.method, event.endpointTemplate].filter(Boolean).join(" "));
4140
- if (event.status !== void 0)
4141
- parts.push(`${event.status}`);
4142
- }
4143
- if (event.ids)
4144
- for (const [name, value] of Object.entries(event.ids))
4145
- parts.push(`${name} ${value}`);
4146
- if (event.event !== "cache") {
4147
- if (event.durationMs !== void 0)
4148
- parts.push(`${event.durationMs}ms`);
4149
- if (event.bytes !== void 0)
4150
- parts.push(size(event.bytes));
4151
- }
4152
- if (event.counts)
4153
- for (const [field, count3] of Object.entries(event.counts))
4154
- parts.push(`${count3} ${field}`);
4155
- if (event.event !== "cache") {
4156
- if (event.errorCode)
4157
- parts.push(event.errorCode);
4158
- if (event.providerError)
4159
- parts.push(event.providerError);
4160
- }
4161
- return `${MARK[event.event]} ${event.operation.padEnd(16)} ${parts.join(" ")}`.trimEnd();
4162
- }, "renderEvent");
4163
- var MARK = { request: "\u2192", response: "\u2190", cache: "\u2022", warning: "!" };
4164
- var age = /* @__PURE__ */ __name((ms) => ms < 1e3 ? `${ms}ms` : `${Math.round(ms / 1e3)}s`, "age");
4165
- var size = /* @__PURE__ */ __name((bytes) => bytes < 1e3 ? `${bytes} B` : `${(bytes / 1e3).toFixed(1)} kB`, "size");
4166
-
4167
- // node_modules/.pnpm/@wirecat+cli-core@0.466.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.64.0_commander@15._f7e4048410ccbe1e801fd184c043d197/node_modules/@wirecat/cli-core/dist/runs/secrets.js
4168
- var SECRET_WORDS = /* @__PURE__ */ new Set([
4169
- "authorization",
4170
- "cookie",
4171
- "credential",
4172
- "credentials",
4173
- "passphrase",
4174
- "password",
4175
- "passwd",
4176
- "pwd",
4177
- "pass",
4178
- "passcode",
4179
- "pin",
4180
- "otp",
4181
- "2fa",
4182
- "secret",
4183
- "token",
4184
- "contrase\xF1a",
4185
- "contrasena",
4186
- "clave",
4187
- "\u043F\u0430\u0440\u043E\u043B\u044C",
4188
- "\u043F\u0438\u043D",
4189
- "\u043A\u043E\u0434",
4190
- ...["api", "auth", "service", "account", "db", "database", "priv", "private", "client"].map((word) => `${word}key`),
4191
- ...["db", "database", "key"].map((word) => `${word}pass`)
4192
- ]);
4193
- var secretNamed = /* @__PURE__ */ __name((name) => {
4194
- const words = name.replace(/([a-z0-9])([A-Z])/g, "$1 $2").split(/[\s_.-]+/).map((word) => word.toLowerCase());
4195
- return words.some((word, at) => SECRET_WORDS.has(word) || SECRET_WORDS.has(word + (words[at + 1] ?? "")));
4196
- }, "secretNamed");
4197
- var START = "(?<![A-Za-z0-9_-])";
4198
- var END = "(?![A-Za-z0-9_-])";
4199
- var KNOWN_TOKENS = new RegExp(`${[
4200
- "gh[pousr]_[A-Za-z0-9]{36,}",
4201
- "github_pat_[A-Za-z0-9_]{22,}",
4202
- "sk-[A-Za-z0-9_-]{20,}",
4203
- "xox[abprs]-[A-Za-z0-9-]{10,}",
4204
- "(?:AKIA|ASIA)[A-Z0-9]{16}",
4205
- "AIza[A-Za-z0-9_-]{35}",
4206
- "(?:sk|rk)_(?:live|test)_[A-Za-z0-9]{10,}",
4207
- "npm_[A-Za-z0-9]{36}",
4208
- "eyJ[A-Za-z0-9_-]{5,}\\.eyJ[A-Za-z0-9_-]{5,}\\.[A-Za-z0-9_-]*"
4209
- ].map((pattern) => `${START}${pattern}${END}`).join("|")}|(?<!\\d)\\d{8,10}:[A-Za-z0-9_-]{35}${END}`, "g");
4210
- var PRIVATE_KEY = /-----BEGIN[A-Z ]* PRIVATE KEY-----[\s\S]*?(?:-----END[A-Z ]* PRIVATE KEY-----|$)/g;
4211
- var SCHEME = /(?<![A-Za-z])(Bearer|Basic)(\s+)(?![A-Z]?[a-z]+(?![A-Za-z0-9]))[A-Za-z0-9._~+/=-]{8,}/g;
4212
- var NAMED_PAIR = /(?<![\p{L}\p{N}])([\p{L}\p{N}_.-]*(?:token|pass|pwd|pin|otp|2fa|secret|credential|cookie|authorization|key|contrase|clave|пароль|пин|код)[\p{L}\p{N}_.-]*)(["']?\s*(?:=>|[:=])\s*["']?|\s+(?![\p{L}]+(?![\p{L}\p{N}])))((?:Bearer\s+|Basic\s+)?)([^\s"'&,;]+)/giu;
4213
- var looksRandom = /* @__PURE__ */ __name((run) => {
4214
- if (run.length < 20)
4215
- return false;
4216
- const classes = [/[a-z]/, /[A-Z]/, /\d/, /[^A-Za-z0-9]/].filter((kind) => kind.test(run)).length;
4217
- if (classes < 3)
4218
- return false;
4219
- let switches = 0;
4220
- for (let at = 1; at < run.length; at++) {
4221
- const [before, after] = [run[at - 1], run[at]];
4222
- if (/[a-z]/.test(before) && /[A-Z]/.test(after) || /[A-Z]/.test(before) && /[a-z]/.test(after))
4223
- switches += 1;
4224
- }
4225
- if (switches / run.length < 0.15)
4226
- return false;
4227
- const pieces = run.match(/[A-Z]?[a-z]+|[A-Z]+(?![a-z])|\d+/g) ?? [];
4228
- if (pieces.join("").length / Math.max(pieces.length, 1) >= 2.75)
4229
- return false;
4230
- return entropy(run) >= 3.5;
4231
- }, "looksRandom");
4232
- var entropy = /* @__PURE__ */ __name((text2) => {
4233
- const counts = /* @__PURE__ */ new Map();
4234
- for (const char of text2)
4235
- counts.set(char, (counts.get(char) ?? 0) + 1);
4236
- let bits = 0;
4237
- for (const count3 of counts.values())
4238
- bits -= count3 / text2.length * Math.log2(count3 / text2.length);
4239
- return bits;
4240
- }, "entropy");
4241
- var withoutSecrets = /* @__PURE__ */ __name((text2, mark = "[redacted]") => text2.replace(PRIVATE_KEY, mark).replace(KNOWN_TOKENS, mark).replace(SCHEME, `$1$2${mark}`).replace(NAMED_PAIR, (whole, name, separator, scheme) => secretNamed(name) ? `${name}${separator}${scheme}${mark}` : whole).replace(/[!-~]{20,}/g, (token) => (
4242
- // A URL or a path is somebody's address, not a key; a credential in one is caught by the rules above.
4243
- token.includes("://") || /^(?:\/|~\/|\.\.?\/)/.test(token) ? token : token.replace(RUN, (run) => looksRandom(run) ? mark : run.replace(HEX, (hex) => entropy(hex) >= 3 ? mark : hex))
4244
- )), "withoutSecrets");
4245
- var RUN = /(?<![A-Za-z0-9_+/-])[A-Za-z0-9_+/-]{20,}/g;
4246
- var HEX = /(?<![A-Za-z0-9])(?=[0-9]*[a-f])[0-9a-f]{20,}(?![A-Za-z0-9])/g;
4247
-
4248
- // node_modules/.pnpm/@wirecat+cli-core@0.466.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.64.0_commander@15._f7e4048410ccbe1e801fd184c043d197/node_modules/@wirecat/cli-core/dist/runs/error-detail.js
4249
- var MESSAGE_AT_MOST = 500;
4250
- var CAUSES_AT_MOST = 5;
4251
- var FRAMES_AT_MOST = 15;
4252
- var errorDetailOf = /* @__PURE__ */ __name((error, response) => {
4253
- const details = isCliFailure(error) ? { ...error.details } : {};
4254
- const thrown = error instanceof Error ? error : void 0;
4255
- const code = isCliFailure(error) ? error.code : codeOf(error);
4256
- const reason = typeof details.reason === "string" ? details.reason : void 0;
4257
- const message = thrown ? redactText(thrown.message) : void 0;
4258
- const operation = stringOf(details.operation) ?? response?.operation;
4259
- const status = numberOf(details.status) ?? response?.status;
4260
- const method = stringOf(details.method) ?? response?.method;
4261
- const endpoint2 = stringOf(details.endpoint) ?? response?.endpointTemplate;
4262
- const key = providerErrorKey(details.provider_error) ?? providerErrorKey(response?.providerError);
4263
- const protocol = key !== void 0 && method === void 0 && endpoint2 === void 0;
4264
- const http = method !== void 0 || endpoint2 !== void 0 || status !== void 0 && !protocol ? {
4265
- ...method === void 0 ? {} : { method: method.toUpperCase().slice(0, 16) },
4266
- ...endpoint2 === void 0 ? {} : { endpoint_template: endpointTemplate(endpoint2) },
4267
- ...status === void 0 ? {} : { status }
4268
- } : void 0;
4269
- const causes = causesOf(thrown?.cause ?? details.cause);
4270
- const stack = framesOf(thrown);
4621
+ // node_modules/.pnpm/@wirecat+cli-core@0.467.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.64.0_commander@15._7a700db966f96e9df6d3178e7072efc2/node_modules/@wirecat/cli-core/dist/output-detail.js
4622
+ var RARELY_SET = ["editedAt", "replyTo", "forwardedFrom", "reactions"];
4623
+ var BRIEF = ["locator", "chatTitle", "timestamp", "senderName", "excerpt", "score"];
4624
+ var isHit = /* @__PURE__ */ __name((value) => typeof value === "object" && value !== null && typeof value.locator === "string" && typeof value.text === "string", "isHit");
4625
+ var shaped = /* @__PURE__ */ __name((hit, detail) => {
4626
+ if (detail === "brief")
4627
+ return Object.fromEntries(BRIEF.flatMap((key) => hit[key] === void 0 || hit[key] === null ? [] : [[key, hit[key]]]));
4628
+ const { text: text2, providerMetadata, ...rest } = hit;
4629
+ for (const key of RARELY_SET)
4630
+ if (rest[key] === null)
4631
+ delete rest[key];
4632
+ const metadata = rest.email ? void 0 : providerMetadata;
4271
4633
  return {
4272
- class: classOf(error),
4273
- ...code === void 0 ? {} : { code },
4274
- ...reason === void 0 ? {} : { reason },
4275
- ...message ? { message } : {},
4276
- ...operation === void 0 ? {} : { operation },
4277
- ...http ? { http } : {},
4278
- ...key === void 0 ? {} : { provider: { key, ...protocol && status !== void 0 ? { code: status } : {} } },
4279
- ...causes.length > 0 ? { causes } : {},
4280
- ...stack.length > 0 ? { stack } : {}
4634
+ ...rest,
4635
+ ...typeof rest.excerpt === "string" ? {} : { text: text2 },
4636
+ ...metadata === void 0 ? {} : { providerMetadata: metadata }
4281
4637
  };
4282
- }, "errorDetailOf");
4283
- var stringOf = /* @__PURE__ */ __name((value) => typeof value === "string" && value.trim() !== "" ? value.trim() : void 0, "stringOf");
4284
- var numberOf = /* @__PURE__ */ __name((value) => typeof value === "number" && Number.isInteger(value) ? value : void 0, "numberOf");
4285
- var classOf = /* @__PURE__ */ __name((error) => {
4286
- if (!(error instanceof Error))
4287
- return error === null ? "null" : typeof error;
4288
- const constructed = error.constructor?.name;
4289
- return constructed && constructed !== "Error" && constructed !== error.name ? constructed : error.name;
4290
- }, "classOf");
4291
- var codeOf = /* @__PURE__ */ __name((error) => {
4292
- const code = error?.code;
4293
- return typeof code === "string" && /^[A-Za-z][A-Za-z0-9._-]{0,63}$/.test(code) ? code : void 0;
4294
- }, "codeOf");
4295
- var causesOf = /* @__PURE__ */ __name((first2) => {
4296
- const causes = [];
4297
- const seen = /* @__PURE__ */ new Set();
4298
- for (let cause = first2; cause !== void 0 && cause !== null && causes.length < CAUSES_AT_MOST; ) {
4299
- if (seen.has(cause))
4300
- break;
4301
- seen.add(cause);
4302
- const message = cause instanceof Error ? redactText(cause.message) : void 0;
4303
- causes.push({ class: classOf(cause), ...message ? { message } : {} });
4304
- cause = cause instanceof Error ? cause.cause : void 0;
4305
- }
4306
- return causes;
4307
- }, "causesOf");
4308
- var framesOf = /* @__PURE__ */ __name((error, limit = FRAMES_AT_MOST) => {
4309
- const stack = error instanceof Error && typeof error.stack === "string" ? error.stack : "";
4310
- return stack.split("\n").filter((line) => line.trimStart().startsWith("at ")).flatMap((line) => {
4311
- const match = /^\s*at (?:async )?(?:(.+?) \()?(.+?):(\d+):\d+\)?$/.exec(line);
4312
- if (!match)
4313
- return [];
4314
- const [, fn, path2 = "", lineNumber] = match;
4315
- if (path2.startsWith("node:"))
4316
- return [];
4317
- return [`${fn ?? "<anonymous>"} ${fileOf(path2)}:${lineNumber}`];
4318
- }).slice(0, limit);
4319
- }, "framesOf");
4320
- var fileOf = /* @__PURE__ */ __name((path2) => {
4321
- const plain2 = path2.replace(/^file:\/\//, "");
4322
- const packaged = /\/node_modules\/((?:@[^/]+\/)?[^/]+\/.+)$/.exec(plain2)?.[1];
4323
- if (packaged)
4324
- return packaged.replace(/\/(?:dist|src)\//, "/");
4325
- return /(?:^|\/)(?:dist|src)\/(.+)$/.exec(plain2)?.[1] ?? plain2.split("/").at(-1) ?? "?";
4326
- }, "fileOf");
4327
- var endpointTemplate = /* @__PURE__ */ __name((raw) => {
4328
- const trimmed = raw.trim().split(/[?#]/)[0] ?? "";
4329
- const origin = /^[a-z][a-z0-9+.-]*:\/\/(?:[^@/]*@)?([^/]*)/i.exec(trimmed);
4330
- const path2 = origin ? trimmed.slice(origin[0].length) : trimmed;
4331
- const scheme = origin ? `${trimmed.slice(0, trimmed.indexOf("://"))}://${origin[1]}` : "";
4332
- const segments = path2.split("/").map((segment) => {
4333
- if (segment === "" || /^[:{].+/.test(segment))
4334
- return segment;
4335
- if (/^bot\d+:/.test(segment) || /^\d{6,}:[\w-]{20,}$/.test(segment))
4336
- return ":token";
4337
- if (/^-?\d+$/.test(segment) || /^[0-9a-f-]{16,}$/i.test(segment))
4338
- return ":id";
4339
- if (!/^[A-Za-z0-9._~-]{1,40}$/.test(segment))
4340
- return ":value";
4341
- return segment;
4342
- });
4343
- return `${scheme}${segments.join("/")}`.slice(0, 300);
4344
- }, "endpointTemplate");
4345
- var INTERNATIONAL_PHONE = /\+\d[\d\s()-]{6,}\d/.source;
4346
- var BARE_PHONE = /(^|[^\w-])\d{11,15}\b/.source;
4347
- var redactText = /* @__PURE__ */ __name((text2) => {
4348
- const home = homedir();
4349
- let out = home && home !== "/" ? text2.split(home).join("~") : text2;
4350
- out = withoutSecrets(out.replace(/"[^"\n]*"|“[^”\n]*”|«[^»\n]*»/g, '"[redacted]"')).replace(/\b(bearer|basic|token|key|password|secret)(\s*[:=]\s*|\s+)[^\s'"]+/gi, "$1$2[redacted]").replace(/[\w.+-]+@[\w-]+\.[\w.-]+/g, "[email]").replace(new RegExp(INTERNATIONAL_PHONE, "g"), "[number]").replace(new RegExp(BARE_PHONE, "g"), "$1[number]").replace(/\bbot\d+:[\w-]+/g, "bot[token]").replace(/\b\d{6,}:[\w-]{20,}\b/g, "[token]").replace(/(\?|&)[^\s#]*/g, "$1[redacted]").replace(/\b[A-Za-z0-9_-]{40,}\b/g, "[redacted]");
4351
- return out.length > MESSAGE_AT_MOST ? `${out.slice(0, MESSAGE_AT_MOST)}\u2026` : out;
4352
- }, "redactText");
4638
+ }, "shaped");
4639
+ var atDetail = /* @__PURE__ */ __name((value, detail = "default") => {
4640
+ if (detail === "full")
4641
+ return value;
4642
+ if (Array.isArray(value))
4643
+ return value.map((item) => isHit(item) ? shaped(item, detail) : item);
4644
+ if (isHit(value))
4645
+ return shaped(value, detail);
4646
+ if (typeof value === "object" && value !== null && Array.isArray(value.items))
4647
+ return { ...value, items: atDetail(value.items, detail) };
4648
+ return value;
4649
+ }, "atDetail");
4650
+
4651
+ // node_modules/.pnpm/@wirecat+cli-core@0.467.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.64.0_commander@15._7a700db966f96e9df6d3178e7072efc2/node_modules/@wirecat/cli-core/dist/output.js
4652
+ var resolveOutput = /* @__PURE__ */ __name(({ json, jsonl, quiet, streams = processStreams, tty, color, fields, hitDetail, env = process.env, capture } = {}) => {
4653
+ const interactive = tty ?? process.stdout.isTTY === true;
4654
+ const format = jsonl ? "jsonl" : json || !interactive ? "json" : "pretty";
4655
+ const painted = format === "pretty" && (color ?? (env.NO_COLOR === void 0 && env.TERM !== "dumb" && !env.CI));
4656
+ const printing = createRenderer({ format, color: painted, streams });
4657
+ const rendered = capture ? { ...printing, result: capture, stream: /* @__PURE__ */ __name((items) => capture([...items]), "stream") } : printing;
4658
+ const level = hitDetail ?? (fields === void 0 ? "default" : "full");
4659
+ const standard = format === "pretty" ? rendered : {
4660
+ ...rendered,
4661
+ result: /* @__PURE__ */ __name((value) => rendered.result(atDetail(value, level)), "result"),
4662
+ stream: /* @__PURE__ */ __name((items) => rendered.stream(atDetail([...items], level)), "stream")
4663
+ };
4664
+ const created = standard;
4665
+ const paths = fields === void 0 ? void 0 : fieldsOf2(fields);
4666
+ const renderer = format === "pretty" ? oneLineFields(created) : paths ? {
4667
+ ...created,
4668
+ result: /* @__PURE__ */ __name((value) => created.result(projectFields2(value, paths)), "result"),
4669
+ stream: /* @__PURE__ */ __name((items) => created.stream([...items].map((item) => projectFields2(item, paths))), "stream")
4670
+ } : created;
4671
+ return { format, color: painted, streams, renderer: quiet ? silence(renderer) : renderer };
4672
+ }, "resolveOutput");
4673
+ var MULTI_LINE = /* @__PURE__ */ new Set(["text", "description"]);
4674
+ var oneLineFields = /* @__PURE__ */ __name((renderer) => ({
4675
+ ...renderer,
4676
+ result: /* @__PURE__ */ __name((value) => renderer.result(oneLine(value)), "result"),
4677
+ stream: /* @__PURE__ */ __name((items) => renderer.stream([...items].map((item) => oneLine(item))), "stream")
4678
+ }), "oneLineFields");
4679
+ var oneLine = /* @__PURE__ */ __name((value, key) => {
4680
+ if (typeof value === "string")
4681
+ return key !== void 0 && MULTI_LINE.has(key) ? value : singleLine(value);
4682
+ if (Array.isArray(value))
4683
+ return value.map((item) => oneLine(item, key));
4684
+ if (value !== null && typeof value === "object" && Object.getPrototypeOf(value) === Object.prototype) {
4685
+ return Object.fromEntries(Object.entries(value).map(([field, item]) => [field, oneLine(item, field)]));
4686
+ }
4687
+ return value;
4688
+ }, "oneLine");
4689
+ var silence = /* @__PURE__ */ __name((renderer) => ({
4690
+ ...renderer,
4691
+ note: /* @__PURE__ */ __name(() => {
4692
+ }, "note"),
4693
+ success: /* @__PURE__ */ __name(() => {
4694
+ }, "success"),
4695
+ warn: /* @__PURE__ */ __name(() => {
4696
+ }, "warn")
4697
+ }), "silence");
4353
4698
 
4354
- // node_modules/.pnpm/@wirecat+cli-core@0.466.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.64.0_commander@15._f7e4048410ccbe1e801fd184c043d197/node_modules/@wirecat/cli-core/dist/runs/log-events.js
4699
+ // node_modules/.pnpm/@wirecat+cli-core@0.467.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.64.0_commander@15._7a700db966f96e9df6d3178e7072efc2/node_modules/@wirecat/cli-core/dist/runs/log-events.js
4355
4700
  var CORE_LOG_EVENTS = defineLogEvents([
4356
4701
  { id: "provider.request", meaning: "a request went to the messenger", keys: ["operation"] },
4357
4702
  { id: "provider.response", meaning: "the messenger answered the request, or it failed", keys: ["operation"] },
@@ -4362,6 +4707,11 @@ var CORE_LOG_EVENTS = defineLogEvents([
4362
4707
  keys: ["operation", "reason"]
4363
4708
  },
4364
4709
  { id: "command.crashed", meaning: "a command failed on a bug; where, never what", keys: ["error_class", "frames"] },
4710
+ {
4711
+ id: "events.dropped",
4712
+ meaning: "the run reached its cap and counted the rest instead of writing them",
4713
+ keys: ["dropped", "counts"]
4714
+ },
4365
4715
  { id: "send.recorded", meaning: "a write the send guard saw, and how it ended", keys: ["outcome"] },
4366
4716
  { id: "job.start", meaning: "a background job started", keys: ["job"] },
4367
4717
  { id: "job.exit", meaning: "a background job ended", keys: ["job", "outcome"] },
@@ -4380,7 +4730,487 @@ var DIAGNOSTIC_LOG_EVENTS = {
4380
4730
  cache: "cache.answered"
4381
4731
  };
4382
4732
 
4383
- // node_modules/.pnpm/@wirecat+cli-core@0.466.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.64.0_commander@15._f7e4048410ccbe1e801fd184c043d197/node_modules/@wirecat/cli-core/dist/runs/recording.js
4733
+ // node_modules/.pnpm/@wirecat+cli-core@0.467.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.64.0_commander@15._7a700db966f96e9df6d3178e7072efc2/node_modules/@wirecat/cli-core/dist/runs/log-keys.js
4734
+ var snake2 = /* @__PURE__ */ __name((key) => key.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`), "snake");
4735
+ var camel = /* @__PURE__ */ __name((key) => key.replace(/_([a-z0-9])/g, (_, letter) => letter.toUpperCase()), "camel");
4736
+ var renamed = /* @__PURE__ */ __name((record2, name) => Object.fromEntries(Object.entries(record2).map(([key, value]) => [name(key), value])), "renamed");
4737
+ var logAttributes = /* @__PURE__ */ __name((event) => renamed(event, snake2), "logAttributes");
4738
+ var fromLogAttributes = /* @__PURE__ */ __name((attributes) => renamed(attributes, camel), "fromLogAttributes");
4739
+ var snakeLogger = /* @__PURE__ */ __name((logger) => ({
4740
+ debug: /* @__PURE__ */ __name((event, message) => logger.debug(logAttributes(event), message), "debug"),
4741
+ info: /* @__PURE__ */ __name((event, message) => logger.info(logAttributes(event), message), "info"),
4742
+ warn: /* @__PURE__ */ __name((event, message) => logger.warn(logAttributes(event), message), "warn"),
4743
+ error: /* @__PURE__ */ __name((event, message) => logger.error(logAttributes(event), message), "error")
4744
+ }), "snakeLogger");
4745
+
4746
+ // node_modules/.pnpm/@wirecat+cli-core@0.467.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.64.0_commander@15._7a700db966f96e9df6d3178e7072efc2/node_modules/@wirecat/cli-core/dist/runs/run.js
4747
+ import { randomUUID } from "node:crypto";
4748
+ import { appendFileSync, mkdirSync, readdirSync as readdirSync2, readFileSync as readFileSync2, rmSync, statSync, writeFileSync } from "node:fs";
4749
+ import { userInfo } from "node:os";
4750
+ import { join as join2, sep } from "node:path";
4751
+
4752
+ // node_modules/.pnpm/@wirecat+cli-core@0.467.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.64.0_commander@15._7a700db966f96e9df6d3178e7072efc2/node_modules/@wirecat/cli-core/dist/runs/log-attributes.js
4753
+ var diagnostic = {
4754
+ event: true,
4755
+ operation: true,
4756
+ opcode: true,
4757
+ seq: true,
4758
+ status: true,
4759
+ method: true,
4760
+ endpointTemplate: true,
4761
+ bytes: true,
4762
+ ids: true,
4763
+ counts: true,
4764
+ durationMs: true,
4765
+ outcome: true,
4766
+ errorCode: true,
4767
+ providerError: true,
4768
+ level: true,
4769
+ transport: true,
4770
+ attempt: true,
4771
+ waitMs: true,
4772
+ code: true,
4773
+ detail: true,
4774
+ reason: true,
4775
+ ageMs: true
4776
+ };
4777
+ var send = {
4778
+ profile: true,
4779
+ chatId: true,
4780
+ outcome: true,
4781
+ kind: true,
4782
+ action: true,
4783
+ people: true,
4784
+ messageId: true,
4785
+ key: true,
4786
+ count: true,
4787
+ forEveryone: true,
4788
+ sendId: true,
4789
+ operationId: true,
4790
+ parentOperationId: true,
4791
+ replyTo: true,
4792
+ threadId: true,
4793
+ sendAs: true,
4794
+ resultChatId: true,
4795
+ length: true,
4796
+ attachments: true,
4797
+ scheduledFor: true,
4798
+ notify: true,
4799
+ origin: true,
4800
+ reservation: true,
4801
+ errorCode: true
4802
+ };
4803
+ var background = [
4804
+ "job",
4805
+ "pid",
4806
+ "schedule",
4807
+ "exitCode",
4808
+ "tool",
4809
+ "tier",
4810
+ "actorType",
4811
+ "actorId",
4812
+ "agent",
4813
+ "targetType",
4814
+ "targetId"
4815
+ ];
4816
+ var crash = ["errorClass", "frames"];
4817
+ var dropped = ["dropped"];
4818
+ var LOG_ATTRIBUTES = [
4819
+ ...new Set([...Object.keys(diagnostic), ...Object.keys(send), ...background, ...crash, ...dropped].map((key) => Object.keys(logAttributes({ [key]: true }))[0]))
4820
+ ].sort();
4821
+
4822
+ // node_modules/.pnpm/@wirecat+cli-core@0.467.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.64.0_commander@15._7a700db966f96e9df6d3178e7072efc2/node_modules/@wirecat/cli-core/dist/runs/run.js
4823
+ var KEEP_RUNS_FOR_DAYS = 30;
4824
+ var KEEP_SUCCESSFUL_RUNS_FOR_DAYS = 7;
4825
+ var RUNS_SIZE_LIMIT_MB = 200;
4826
+ var runsDirFor = /* @__PURE__ */ __name((app, env = process.env) => join2(resolvePaths({ appName: app.appName, prefix: app.envPrefix, env }).state, "runs"), "runsDirFor");
4827
+ var startRun = /* @__PURE__ */ __name((options) => {
4828
+ const now = options.now ?? (() => /* @__PURE__ */ new Date());
4829
+ const startedAt = options.startedAt ?? now();
4830
+ const id2 = options.runId ?? newRunId(startedAt, options.command);
4831
+ const dir = join2(options.runsDir, day(startedAt), id2);
4832
+ pruneRuns(options.runsDir, {
4833
+ keepDays: options.keepDays ?? KEEP_RUNS_FOR_DAYS,
4834
+ keepSuccessDays: options.keepSuccessDays ?? KEEP_SUCCESSFUL_RUNS_FOR_DAYS,
4835
+ maxBytes: options.maxBytes ?? RUNS_SIZE_LIMIT_MB * 1024 * 1024,
4836
+ now: startedAt
4837
+ });
4838
+ refuseRealStateInTests(dir);
4839
+ const metadata = {
4840
+ runId: id2,
4841
+ command: options.command,
4842
+ ...options.profile === void 0 ? {} : { profile: options.profile },
4843
+ startedAt: startedAt.toISOString(),
4844
+ status: "running",
4845
+ cliVersion: options.cliVersion,
4846
+ runtime: runtime(),
4847
+ platform: process.platform,
4848
+ arch: process.arch,
4849
+ ...options.traceId === void 0 ? {} : { traceId: options.traceId },
4850
+ ...options.context
4851
+ };
4852
+ let file;
4853
+ const opened = /* @__PURE__ */ __name(() => {
4854
+ if (file)
4855
+ return file;
4856
+ mkdirSync(dir, { recursive: true, mode: 448 });
4857
+ const events = join2(dir, "events.jsonl");
4858
+ writeFileSync(events, "", { flag: "a", mode: 384 });
4859
+ file = snakeLogger(createRecordLog({
4860
+ to: events,
4861
+ runId: id2,
4862
+ command: options.command,
4863
+ resource: { service: options.service, version: options.cliVersion },
4864
+ allow: LOG_ATTRIBUTES,
4865
+ ...options.traceId === void 0 ? {} : { traceId: options.traceId },
4866
+ ...options.onError === void 0 ? {} : { onError: options.onError }
4867
+ }));
4868
+ writeRunFile(dir, metadata);
4869
+ return file;
4870
+ }, "opened");
4871
+ if (!options.lazy)
4872
+ opened();
4873
+ let finished = false;
4874
+ const operations = /* @__PURE__ */ new Set();
4875
+ const codes = /* @__PURE__ */ new Set();
4876
+ const noted = /* @__PURE__ */ __name((level) => (event, message) => {
4877
+ const { operation, errorCode, error_code, code } = event;
4878
+ if (typeof operation === "string")
4879
+ operations.add(operation);
4880
+ for (const value of [errorCode, error_code, code])
4881
+ if (typeof value === "string")
4882
+ codes.add(value);
4883
+ if (finished)
4884
+ return;
4885
+ opened()[level](event, message);
4886
+ }, "noted");
4887
+ const logger = { debug: noted("debug"), info: noted("info"), warn: noted("warn"), error: noted("error") };
4888
+ return {
4889
+ id: id2,
4890
+ dir,
4891
+ logger,
4892
+ finish: /* @__PURE__ */ __name(async (status, extra = {}) => {
4893
+ if (finished)
4894
+ return;
4895
+ finished = true;
4896
+ const completedAt = now();
4897
+ const final = {
4898
+ ...metadata,
4899
+ ...extra,
4900
+ status,
4901
+ completedAt: completedAt.toISOString(),
4902
+ durationMs: completedAt.getTime() - startedAt.getTime(),
4903
+ operations: [...operations].sort(),
4904
+ codes: [...codes].sort()
4905
+ };
4906
+ if (file || status !== "success") {
4907
+ opened();
4908
+ writeRunFile(dir, final);
4909
+ return;
4910
+ }
4911
+ try {
4912
+ mkdirSync(join2(dir, ".."), { recursive: true, mode: 448 });
4913
+ appendIndex(join2(dir, ".."), runFileOf(final));
4914
+ } catch (error) {
4915
+ options.onError?.(error);
4916
+ }
4917
+ }, "finish")
4918
+ };
4919
+ }, "startRun");
4920
+ var refuseRealStateInTests = /* @__PURE__ */ __name((dir, env = process.env) => {
4921
+ if (env.VITEST === void 0)
4922
+ return;
4923
+ let home;
4924
+ try {
4925
+ home = userInfo().homedir;
4926
+ } catch {
4927
+ return;
4928
+ }
4929
+ if (dir.startsWith(join2(home, ".local", "share") + sep))
4930
+ throw new Error(`a test opened a run in the real data folder: ${dir}`);
4931
+ }, "refuseRealStateInTests");
4932
+ var runtime = /* @__PURE__ */ __name(() => {
4933
+ const bun = process.versions.bun;
4934
+ return bun ? `bun ${bun}` : `node ${process.versions.node}`;
4935
+ }, "runtime");
4936
+ var newRunId = /* @__PURE__ */ __name((startedAt, command) => {
4937
+ const stamp = startedAt.toISOString().replace(/[-:]/g, "").replace(/\.\d+Z$/, "Z");
4938
+ const slug = command.replace(/[^a-z0-9]+/gi, "-").toLowerCase();
4939
+ return `${stamp}-${slug}-${randomUUID().slice(0, 6)}`;
4940
+ }, "newRunId");
4941
+ var INDEX = "index.jsonl";
4942
+ var appendIndex = /* @__PURE__ */ __name((dayDir, written) => {
4943
+ appendFileSync(join2(dayDir, INDEX), `${JSON.stringify(written)}
4944
+ `, { mode: 384 });
4945
+ }, "appendIndex");
4946
+ var writeRunFile = /* @__PURE__ */ __name((dir, metadata) => {
4947
+ const written = runFileOf(metadata);
4948
+ writeSecurely(join2(dir, "run.json"), `${JSON.stringify(written, null, 2)}
4949
+ `, 384);
4950
+ try {
4951
+ appendIndex(join2(dir, ".."), written);
4952
+ } catch {
4953
+ }
4954
+ }, "writeRunFile");
4955
+ var matchesListFilter = /* @__PURE__ */ __name((run, filter) => (filter.runId === void 0 || run.runId === filter.runId) && (filter.command === void 0 || run.command === filter.command) && (filter.profile === void 0 || run.profile === filter.profile) && (filter.status === void 0 || run.status === filter.status) && (filter.errorCode === void 0 || run.errorCode === filter.errorCode), "matchesListFilter");
4956
+ var listRuns = /* @__PURE__ */ __name((runsDir, { since, atLeast = Number.POSITIVE_INFINITY, filter = {} } = {}) => {
4957
+ const first2 = since === void 0 ? void 0 : day(new Date(since));
4958
+ const runs = [];
4959
+ for (const date of days(runsDir).sort().reverse()) {
4960
+ if (first2 !== void 0 && date < first2 || runs.length >= atLeast)
4961
+ break;
4962
+ for (const metadata of runsOfDay(join2(runsDir, date))) {
4963
+ if (matchesListFilter(metadata, filter))
4964
+ runs.push(metadata);
4965
+ }
4966
+ }
4967
+ return runs;
4968
+ }, "listRuns");
4969
+ var indexedRuns = /* @__PURE__ */ __name((dayDir) => {
4970
+ const latest = /* @__PURE__ */ new Map();
4971
+ let raw = "";
4972
+ try {
4973
+ raw = readFileSync2(join2(dayDir, INDEX), "utf8");
4974
+ } catch {
4975
+ }
4976
+ for (const line of raw.split("\n")) {
4977
+ if (line.trim() === "")
4978
+ continue;
4979
+ try {
4980
+ const metadata = metadataOf(JSON.parse(line));
4981
+ if (typeof metadata.runId === "string")
4982
+ latest.set(metadata.runId, metadata);
4983
+ } catch {
4984
+ }
4985
+ }
4986
+ return latest;
4987
+ }, "indexedRuns");
4988
+ var runsOfDay = /* @__PURE__ */ __name((dayDir) => {
4989
+ const latest = indexedRuns(dayDir);
4990
+ for (const entry of safeReaddir(dayDir)) {
4991
+ if (entry === INDEX || entry.startsWith(".") || latest.has(entry))
4992
+ continue;
4993
+ const metadata = readRun(join2(dayDir, entry));
4994
+ if (metadata)
4995
+ latest.set(metadata.runId, metadata);
4996
+ }
4997
+ return [...latest.values()].sort((a, b) => a.runId < b.runId ? 1 : a.runId > b.runId ? -1 : 0);
4998
+ }, "runsOfDay");
4999
+ var findRun = /* @__PURE__ */ __name((runsDir, id2) => {
5000
+ const stamped = /^(\d{4})(\d{2})(\d{2})T/.exec(id2);
5001
+ const likely = stamped ? [`${stamped[1]}-${stamped[2]}-${stamped[3]}`] : [];
5002
+ const dates = [.../* @__PURE__ */ new Set([...likely, ...days(runsDir)])];
5003
+ for (const date of dates) {
5004
+ const dir = join2(runsDir, date, id2);
5005
+ const metadata = readRun(dir);
5006
+ if (metadata)
5007
+ return { dir, metadata };
5008
+ }
5009
+ for (const date of dates) {
5010
+ const metadata = indexedRuns(join2(runsDir, date)).get(id2);
5011
+ if (metadata)
5012
+ return { dir: join2(runsDir, date, id2), metadata };
5013
+ }
5014
+ return void 0;
5015
+ }, "findRun");
5016
+ var readEvents = /* @__PURE__ */ __name((dir) => {
5017
+ let raw;
5018
+ try {
5019
+ raw = readFileSync2(join2(dir, "events.jsonl"), "utf8");
5020
+ } catch {
5021
+ return [];
5022
+ }
5023
+ const events = [];
5024
+ for (const line of raw.split("\n")) {
5025
+ if (line.trim() === "")
5026
+ continue;
5027
+ try {
5028
+ const parsed = JSON.parse(line);
5029
+ if (parsed !== null && typeof parsed === "object")
5030
+ events.push(eventOf(parsed));
5031
+ } catch {
5032
+ }
5033
+ }
5034
+ return events;
5035
+ }, "readEvents");
5036
+ var eventOf = /* @__PURE__ */ __name((line) => {
5037
+ const { attributes, time: time2, severity } = line;
5038
+ if (attributes === null || typeof attributes !== "object")
5039
+ return logAttributes(line);
5040
+ return { time: time2, severity, ...logAttributes(attributes) };
5041
+ }, "eventOf");
5042
+ var pruneRuns = /* @__PURE__ */ __name((runsDir, { keepDays, keepSuccessDays = keepDays, maxBytes, now }) => {
5043
+ const cutoff = day(new Date(now.getTime() - keepDays * DAY_MS));
5044
+ const successCutoff = day(new Date(now.getTime() - Math.min(keepSuccessDays, keepDays) * DAY_MS));
5045
+ let removed = 0;
5046
+ for (const date of days(runsDir)) {
5047
+ if (date >= cutoff) {
5048
+ if (date < successCutoff)
5049
+ dropSuccesses(join2(runsDir, date));
5050
+ continue;
5051
+ }
5052
+ try {
5053
+ rmSync(join2(runsDir, date), { recursive: true, force: true });
5054
+ removed += 1;
5055
+ } catch {
5056
+ }
5057
+ }
5058
+ if (maxBytes !== void 0)
5059
+ removed += fitSize(runsDir, maxBytes, now);
5060
+ return removed;
5061
+ }, "pruneRuns");
5062
+ var DAY_MS = 24 * 60 * 60 * 1e3;
5063
+ var SUCCESSES_DROPPED = ".successes-dropped";
5064
+ var SIZE_CHECKED = ".size-checked";
5065
+ var dropSuccesses = /* @__PURE__ */ __name((dayDir) => {
5066
+ const marker = join2(dayDir, SUCCESSES_DROPPED);
5067
+ try {
5068
+ statSync(marker);
5069
+ return;
5070
+ } catch {
5071
+ }
5072
+ try {
5073
+ const kept = [];
5074
+ for (const [id2, metadata] of indexedRuns(dayDir)) {
5075
+ if (metadata.status === "success")
5076
+ rmSync(join2(dayDir, id2), { recursive: true, force: true });
5077
+ else
5078
+ kept.push(JSON.stringify(runFileOf(metadata)));
5079
+ }
5080
+ for (const entry of safeReaddir(dayDir)) {
5081
+ if (entry === INDEX || entry.startsWith("."))
5082
+ continue;
5083
+ if (readRun(join2(dayDir, entry))?.status === "success")
5084
+ rmSync(join2(dayDir, entry), { recursive: true, force: true });
5085
+ }
5086
+ writeSecurely(join2(dayDir, INDEX), kept.map((line) => `${line}
5087
+ `).join(""), 384);
5088
+ writeFileSync(marker, "", { mode: 384 });
5089
+ } catch {
5090
+ }
5091
+ }, "dropSuccesses");
5092
+ var sizeOf = /* @__PURE__ */ __name((path2) => {
5093
+ let total = 0;
5094
+ for (const entry of safeReaddir(path2)) {
5095
+ const full = join2(path2, entry);
5096
+ try {
5097
+ const stat = statSync(full);
5098
+ total += stat.isDirectory() ? sizeOf(full) : stat.size;
5099
+ } catch {
5100
+ }
5101
+ }
5102
+ return total;
5103
+ }, "sizeOf");
5104
+ var fitSize = /* @__PURE__ */ __name((runsDir, maxBytes, now) => {
5105
+ const stamp = join2(runsDir, SIZE_CHECKED);
5106
+ const today = day(now);
5107
+ try {
5108
+ if (readFileSync2(stamp, "utf8").trim() === today)
5109
+ return 0;
5110
+ } catch {
5111
+ }
5112
+ const dates = days(runsDir).sort();
5113
+ const sizes = new Map(dates.map((date) => [date, sizeOf(join2(runsDir, date))]));
5114
+ let total = [...sizes.values()].reduce((sum, size) => sum + size, 0);
5115
+ let removed = 0;
5116
+ for (const date of dates) {
5117
+ if (total <= maxBytes || date === today)
5118
+ break;
5119
+ dropSuccesses(join2(runsDir, date));
5120
+ const after = sizeOf(join2(runsDir, date));
5121
+ total -= (sizes.get(date) ?? 0) - after;
5122
+ sizes.set(date, after);
5123
+ }
5124
+ for (const date of dates) {
5125
+ if (total <= maxBytes || date === today)
5126
+ break;
5127
+ try {
5128
+ rmSync(join2(runsDir, date), { recursive: true, force: true });
5129
+ total -= sizes.get(date) ?? 0;
5130
+ removed += 1;
5131
+ } catch {
5132
+ }
5133
+ }
5134
+ try {
5135
+ mkdirSync(runsDir, { recursive: true, mode: 448 });
5136
+ writeFileSync(stamp, today, { mode: 384 });
5137
+ } catch {
5138
+ }
5139
+ return removed;
5140
+ }, "fitSize");
5141
+ var day = /* @__PURE__ */ __name((date) => date.toISOString().slice(0, 10), "day");
5142
+ var days = /* @__PURE__ */ __name((runsDir) => safeReaddir(runsDir).filter((entry) => /^\d{4}-\d{2}-\d{2}$/.test(entry)), "days");
5143
+ var readRun = /* @__PURE__ */ __name((dir) => {
5144
+ try {
5145
+ return metadataOf(JSON.parse(readFileSync2(join2(dir, "run.json"), "utf8")));
5146
+ } catch {
5147
+ return void 0;
5148
+ }
5149
+ }, "readRun");
5150
+ var safeReaddir = /* @__PURE__ */ __name((dir) => {
5151
+ try {
5152
+ return readdirSync2(dir);
5153
+ } catch {
5154
+ return [];
5155
+ }
5156
+ }, "safeReaddir");
5157
+ var runFileOf = /* @__PURE__ */ __name(({ partial, ...metadata }) => ({
5158
+ ...logAttributes(metadata),
5159
+ ...partial ? { partial: { ...logAttributes(partial), failures: partial.failures.map((failure) => logAttributes(failure)) } } : {}
5160
+ }), "runFileOf");
5161
+ var metadataOf = /* @__PURE__ */ __name((parsed) => {
5162
+ const { partial, ...metadata } = fromLogAttributes(parsed);
5163
+ if (partial === null || typeof partial !== "object")
5164
+ return metadata;
5165
+ const { failures, ...rest } = fromLogAttributes(partial);
5166
+ return {
5167
+ ...metadata,
5168
+ partial: {
5169
+ ...rest,
5170
+ failures: Array.isArray(failures) ? failures.map((failure) => fromLogAttributes(failure)) : []
5171
+ }
5172
+ };
5173
+ }, "metadataOf");
5174
+
5175
+ // node_modules/.pnpm/@wirecat+cli-core@0.467.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.64.0_commander@15._7a700db966f96e9df6d3178e7072efc2/node_modules/@wirecat/cli-core/dist/runs/scope.js
5176
+ import { AsyncLocalStorage as AsyncLocalStorage2 } from "node:async_hooks";
5177
+ import { randomBytes } from "node:crypto";
5178
+ var scopes = new AsyncLocalStorage2();
5179
+ var processScope;
5180
+ var currentRun = /* @__PURE__ */ __name(() => {
5181
+ const scope = scopes.getStore();
5182
+ if (scope)
5183
+ return scope;
5184
+ processScope ??= {
5185
+ runId: newRunId(/* @__PURE__ */ new Date(), "process"),
5186
+ command: "",
5187
+ startedAt: Date.now(),
5188
+ ...traceOf(process.env)
5189
+ };
5190
+ return processScope;
5191
+ }, "currentRun");
5192
+ var inRun = /* @__PURE__ */ __name((scope, body) => scopes.run(scope, body), "inRun");
5193
+ var runEvent = /* @__PURE__ */ __name((event) => scopes.getStore()?.events?.(event), "runEvent");
5194
+ var typedCommand = /* @__PURE__ */ __name((tool, words, profile = currentRun().profile) => [tool, profile, words].filter((part) => part !== void 0 && part !== "").join(" "), "typedCommand");
5195
+ var useAsProcessRun = /* @__PURE__ */ __name((scope) => {
5196
+ processScope = scope;
5197
+ }, "useAsProcessRun");
5198
+ var processRun = /* @__PURE__ */ __name(() => processScope, "processRun");
5199
+ var enclosingTraceId = /* @__PURE__ */ __name(() => scopes.getStore()?.traceId, "enclosingTraceId");
5200
+ var traceOf = /* @__PURE__ */ __name((env) => {
5201
+ const traceId = traceIdOf(env.TRACEPARENT);
5202
+ return traceId === void 0 ? {} : { traceId };
5203
+ }, "traceOf");
5204
+ var childTrace = /* @__PURE__ */ __name(() => {
5205
+ const hex = /* @__PURE__ */ __name((bytes) => randomBytes(bytes).toString("hex"), "hex");
5206
+ const traceId = hex(16);
5207
+ return { traceId, traceparent: `00-${traceId}-${hex(8)}-01` };
5208
+ }, "childTrace");
5209
+ var attempts = new AsyncLocalStorage2();
5210
+ var withAttempt = /* @__PURE__ */ __name((attempt, work) => attempts.run(attempt, work), "withAttempt");
5211
+ var currentAttempt = /* @__PURE__ */ __name(() => attempts.getStore(), "currentAttempt");
5212
+
5213
+ // node_modules/.pnpm/@wirecat+cli-core@0.467.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.64.0_commander@15._7a700db966f96e9df6d3178e7072efc2/node_modules/@wirecat/cli-core/dist/runs/recording.js
4384
5214
  var recorded = /* @__PURE__ */ __name(async (options, body) => {
4385
5215
  const recording = startRecording(options);
4386
5216
  try {
@@ -4389,7 +5219,8 @@ var recorded = /* @__PURE__ */ __name(async (options, body) => {
4389
5219
  command: options.command,
4390
5220
  startedAt: Date.now(),
4391
5221
  ...options.profile === void 0 ? {} : { profile: options.profile },
4392
- ...recording.traceId ? { traceId: recording.traceId } : {}
5222
+ ...recording.traceId ? { traceId: recording.traceId } : {},
5223
+ events: recording.events
4393
5224
  };
4394
5225
  if (options.processRun)
4395
5226
  useAsProcessRun(scope);
@@ -4407,6 +5238,7 @@ var startRecording = /* @__PURE__ */ __name((options) => {
4407
5238
  const startedAt = now();
4408
5239
  const runId = newRunId(startedAt, options.command);
4409
5240
  const traceId = options.traceId ?? enclosingTraceId() ?? traceOf(options.env ?? process.env).traceId;
5241
+ const { argvIfFailed, ...context } = options.context ?? {};
4410
5242
  const open = /* @__PURE__ */ __name((extra = {}) => startRun({
4411
5243
  runsDir: options.runsDir ?? runsDirFor(options.app, options.env),
4412
5244
  runId,
@@ -4415,7 +5247,7 @@ var startRecording = /* @__PURE__ */ __name((options) => {
4415
5247
  service: options.app.command,
4416
5248
  cliVersion: options.app.version,
4417
5249
  ...traceId === void 0 ? {} : { traceId },
4418
- ...options.context ? { context: options.context } : {},
5250
+ ...options.context ? { context } : {},
4419
5251
  // The operation has happened or is under way, and failing the command now invites a retry
4420
5252
  // that sends twice.
4421
5253
  onError: /* @__PURE__ */ __name((error) => {
@@ -4423,46 +5255,64 @@ var startRecording = /* @__PURE__ */ __name((options) => {
4423
5255
  streams.diagnostic(options.format === "pretty" ? warning : JSON.stringify({ warning }));
4424
5256
  }, "onError"),
4425
5257
  ...options.keepDays === void 0 ? {} : { keepDays: options.keepDays },
5258
+ ...options.keepSuccessDays === void 0 ? {} : { keepSuccessDays: options.keepSuccessDays },
5259
+ ...options.maxBytes === void 0 ? {} : { maxBytes: options.maxBytes },
4426
5260
  now,
4427
5261
  ...extra
4428
5262
  }), "open");
4429
- const run = options.record ? open({ startedAt }) : void 0;
5263
+ const run = options.record ? open({ startedAt, lazy: true }) : void 0;
4430
5264
  const held = !run && options.keepFailed ? [] : void 0;
4431
- let requests = 0;
5265
+ const counted = { wire: 0, operation: 0 };
4432
5266
  let refused;
5267
+ const cap = capped();
5268
+ const requests = /* @__PURE__ */ __name(() => counted.wire > 0 ? counted.wire : counted.operation, "requests");
4433
5269
  const events = /* @__PURE__ */ __name((event) => {
4434
5270
  if (event.event === "request")
4435
- requests += 1;
5271
+ counted[event.level === "wire" ? "wire" : "operation"] += 1;
4436
5272
  if (event.event === "response" && event.outcome === "error")
4437
5273
  refused = event;
4438
5274
  if (options.trace)
4439
5275
  streams.diagnostic(options.format === "pretty" ? renderEvent(event) : JSON.stringify(logAttributes(event)));
4440
5276
  if (run)
4441
- logEvent(run, event);
5277
+ cap.log(run, event);
4442
5278
  if (held) {
4443
5279
  held.push(event);
4444
5280
  if (held.length > HELD_AT_MOST)
4445
5281
  held.shift();
4446
5282
  }
4447
5283
  }, "events");
5284
+ const keep = /* @__PURE__ */ __name((kept) => {
5285
+ for (const event of held ?? [])
5286
+ cap.log(kept, event);
5287
+ return kept;
5288
+ }, "keep");
4448
5289
  return {
4449
5290
  runId,
4450
5291
  ...traceId === void 0 ? {} : { traceId },
4451
5292
  events,
4452
5293
  succeed: /* @__PURE__ */ __name(async (answer) => {
4453
5294
  const partial = partialOutcome(answer);
4454
- const kept = run ?? (partial && held ? keep(open({ startedAt }), held) : void 0);
4455
- await kept?.finish(partial ? "partial" : "success", { requests, ...partial ? { partial } : {} });
5295
+ const kept = run ?? (partial && held ? keep(open({ startedAt })) : void 0);
5296
+ if (kept)
5297
+ cap.close(kept);
5298
+ await kept?.finish(partial ? "partial" : "success", {
5299
+ requests: requests(),
5300
+ ...cap.dropped(),
5301
+ ...partial ? { partial } : {}
5302
+ });
4456
5303
  }, "succeed"),
4457
5304
  fail: /* @__PURE__ */ __name(async (error) => {
4458
- const failed = run ?? (held ? keep(open({ startedAt }), held) : void 0);
5305
+ const failed = run ?? (held ? keep(open({ startedAt })) : void 0);
4459
5306
  if (failed) {
4460
5307
  if (!isCliFailure(error))
4461
5308
  failed.logger.error(crashOf(error));
5309
+ cap.close(failed);
4462
5310
  await failed.finish("failed", {
4463
- requests,
5311
+ requests: requests(),
5312
+ ...cap.dropped(),
4464
5313
  ...outcomeOf(error),
4465
5314
  error: errorDetailOf(error, refused),
5315
+ ...argvIfFailed ? { argv: argvIfFailed } : {},
4466
5316
  ...run ? {} : { keptBecauseFailed: true }
4467
5317
  });
4468
5318
  }
@@ -4474,11 +5324,33 @@ var startRecording = /* @__PURE__ */ __name((options) => {
4474
5324
  var settled = /* @__PURE__ */ new WeakSet();
4475
5325
  var wasSettled = /* @__PURE__ */ __name((error) => typeof error === "object" && error !== null && settled.has(error), "wasSettled");
4476
5326
  var HELD_AT_MOST = 500;
4477
- var keep = /* @__PURE__ */ __name((run, events) => {
4478
- for (const event of events)
4479
- logEvent(run, event);
4480
- return run;
4481
- }, "keep");
5327
+ var EVENTS_AT_MOST = 2e3;
5328
+ var EVENT_BYTES_AT_MOST = 1024 * 1024;
5329
+ var capped = /* @__PURE__ */ __name(() => {
5330
+ let lines = 0;
5331
+ let bytes = 0;
5332
+ let dropped2 = 0;
5333
+ const byOperation = {};
5334
+ return {
5335
+ log: /* @__PURE__ */ __name((run, event) => {
5336
+ const size = JSON.stringify(logAttributes(event)).length + 200;
5337
+ if (lines >= EVENTS_AT_MOST || bytes + size > EVENT_BYTES_AT_MOST) {
5338
+ dropped2 += 1;
5339
+ const operation = "operation" in event && event.operation ? event.operation : event.event;
5340
+ byOperation[operation] = (byOperation[operation] ?? 0) + 1;
5341
+ return;
5342
+ }
5343
+ lines += 1;
5344
+ bytes += size;
5345
+ logEvent(run, event);
5346
+ }, "log"),
5347
+ close: /* @__PURE__ */ __name((run) => {
5348
+ if (dropped2 > 0)
5349
+ run.logger.warn({ event: "events.dropped", dropped: dropped2, counts: byOperation });
5350
+ }, "close"),
5351
+ dropped: /* @__PURE__ */ __name(() => dropped2 > 0 ? { eventsDropped: dropped2 } : {}, "dropped")
5352
+ };
5353
+ }, "capped");
4482
5354
  var logEvent = /* @__PURE__ */ __name((run, event) => {
4483
5355
  const record2 = {
4484
5356
  ...event,
@@ -4523,151 +5395,7 @@ var partialOutcome = /* @__PURE__ */ __name((answer) => {
4523
5395
  return void 0;
4524
5396
  }, "partialOutcome");
4525
5397
 
4526
- // node_modules/.pnpm/@wirecat+cli-core@0.466.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.64.0_commander@15._f7e4048410ccbe1e801fd184c043d197/node_modules/@wirecat/cli-core/dist/runs/run-context.js
4527
- var REDACTED = "[redacted]";
4528
- var agentOf = /* @__PURE__ */ __name((env) => {
4529
- const named = env.AI_AGENT?.trim().split("_")[0];
4530
- const kind = (named && plainWord(named) ? named.toLowerCase() : void 0) ?? (env.CLAUDECODE ? "claude-code" : void 0) ?? (env.CODEX_THREAD_ID || env.CODEX_SESSION_ID || env.CODEX_SANDBOX ? "codex" : void 0) ?? (env.GEMINI_CLI ? "gemini-cli" : void 0) ?? (env.OPENCODE ? "opencode" : void 0) ?? (env.CURSOR_AGENT ? "cursor" : void 0) ?? // Only `exec` is the agent's own command: OpenClaw also sets `tui-local` for what the owner types in its TUI.
4531
- (env.OPENCLAW_SHELL?.trim() === "exec" ? "openclaw" : void 0);
4532
- if (!kind)
4533
- return void 0;
4534
- const session = sessionOf(kind, env);
4535
- return {
4536
- kind,
4537
- session_id: session && SESSION.test(session) ? session : null,
4538
- // OpenClaw passes the sender and chat ids of a chat-started run in this variable; only its presence is kept.
4539
- ...kind === "openclaw" && env.OPENCLAW_CHANNEL_CONTEXT?.trim() ? { from_chat: true } : {}
4540
- };
4541
- }, "agentOf");
4542
- var SESSION = /^[A-Za-z0-9._:-]{1,128}$/;
4543
- var SESSION_VARIABLE = {
4544
- "claude-code": "CLAUDE_CODE_SESSION_ID",
4545
- codex: "CODEX_THREAD_ID",
4546
- opencode: "OPENCODE_SESSION_ID",
4547
- "hermes-agent": "HERMES_SESSION_ID"
4548
- };
4549
- var sessionOf = /* @__PURE__ */ __name((kind, env) => {
4550
- const variable = SESSION_VARIABLE[kind];
4551
- return (variable === void 0 ? void 0 : env[variable]?.trim()) || void 0;
4552
- }, "sessionOf");
4553
- var plainWord = /* @__PURE__ */ __name((word) => /^[A-Za-z][A-Za-z0-9.-]{0,39}$/.test(word), "plainWord");
4554
- var secretInputs = /* @__PURE__ */ new WeakSet();
4555
- var secretInput = /* @__PURE__ */ __name((input) => {
4556
- secretInputs.add(input);
4557
- return input;
4558
- }, "secretInput");
4559
- var secretShaped = /* @__PURE__ */ __name((word) => /:\/\/[^/@\s:]+:[^/@\s]+@/.test(word) || /(^|[^A-Za-z0-9_-])[A-Za-z0-9_-]{40,}($|[^A-Za-z0-9_-])/.test(word), "secretShaped");
4560
- var withoutPhones = /* @__PURE__ */ __name((word) => word.replace(new RegExp(INTERNATIONAL_PHONE, "g"), REDACTED).replace(new RegExp(BARE_PHONE, "g"), `$1${REDACTED}`), "withoutPhones");
4561
- var maskArgv = /* @__PURE__ */ __name((program2, words, { keep: keep2 = false } = {}) => {
4562
- const argv = [];
4563
- let unknownCommand;
4564
- let current = program2;
4565
- let positional = 0;
4566
- let profileSeen = false;
4567
- let lost = false;
4568
- const raw = /* @__PURE__ */ __name((word) => keep2 && !secretShaped(word) ? withoutPhones(withoutSecrets(word, REDACTED)) : REDACTED, "raw");
4569
- const keptValue = /* @__PURE__ */ __name((name, value, input) => keep2 ? input && secretInputs.has(input) || secretNamed(name) ? REDACTED : raw(value) : maskedValue(name, value, input?.argChoices), "keptValue");
4570
- const optionFor = /* @__PURE__ */ __name((flag2) => {
4571
- for (let at = current; at; at = at.parent) {
4572
- const found = at.options.find((option) => option.long === flag2 || option.short === flag2);
4573
- if (found)
4574
- return found;
4575
- }
4576
- return void 0;
4577
- }, "optionFor");
4578
- for (let at = 0; at < words.length; at++) {
4579
- const word = words[at];
4580
- if (word === "--") {
4581
- argv.push("--");
4582
- for (let after = at + 1; after < words.length; after++)
4583
- argv.push(raw(words[after]));
4584
- break;
4585
- }
4586
- if (word.startsWith("-") && word.length > 1 && !NUMBER.test(word)) {
4587
- const equals = word.indexOf("=");
4588
- const flag2 = equals > 0 ? word.slice(0, equals) : word;
4589
- if (!/^--?[A-Za-z0-9][A-Za-z0-9-]*$/.test(flag2)) {
4590
- argv.push(raw(word));
4591
- continue;
4592
- }
4593
- const option = optionFor(flag2);
4594
- const name = option?.attributeName() ?? flag2.replace(/^-+/, "");
4595
- if (equals > 0) {
4596
- argv.push(`${flag2}=${keptValue(name, word.slice(equals + 1), option)}`);
4597
- continue;
4598
- }
4599
- argv.push(flag2);
4600
- if (!option && keep2 && secretNamed(name) && words[at + 1] !== void 0 && !words[at + 1]?.startsWith("-")) {
4601
- at += 1;
4602
- argv.push(REDACTED);
4603
- continue;
4604
- }
4605
- if (!option || !(option.required || option.optional))
4606
- continue;
4607
- const takes = /* @__PURE__ */ __name((next) => next !== void 0 && (option.required || !next.startsWith("-") || NUMBER.test(next)), "takes");
4608
- if (takes(words[at + 1])) {
4609
- at += 1;
4610
- argv.push(keptValue(name, words[at], option));
4611
- while (option.variadic && words[at + 1] !== void 0 && !words[at + 1].startsWith("-")) {
4612
- at += 1;
4613
- argv.push(keptValue(name, words[at], option));
4614
- }
4615
- }
4616
- continue;
4617
- }
4618
- if (!lost && positional === 0) {
4619
- const sub = current.commands.find((one) => one.name() === word || one.aliases().includes(word));
4620
- if (sub) {
4621
- argv.push(word);
4622
- current = sub;
4623
- continue;
4624
- }
4625
- if (current === program2 && !profileSeen) {
4626
- profileSeen = true;
4627
- argv.push(keep2 ? raw(word) : PROFILE.test(word) && withoutPhones(withoutSecrets(word)) === word ? word : REDACTED);
4628
- continue;
4629
- }
4630
- if (current.commands.length > 0 && current.registeredArguments.length === 0) {
4631
- lost = true;
4632
- unknownCommand = commandLike(word);
4633
- argv.push(keep2 ? raw(word) : unknownCommand);
4634
- continue;
4635
- }
4636
- }
4637
- const declared = lost ? void 0 : current.registeredArguments;
4638
- const argument = declared?.[Math.min(positional, declared.length - 1)];
4639
- positional += 1;
4640
- argv.push(secretInputs.has(current) ? REDACTED : argument ? keptValue(argument.name(), word, argument) : raw(word));
4641
- }
4642
- return { argv, ...unknownCommand === void 0 ? {} : { unknownCommand } };
4643
- }, "maskArgv");
4644
- var NUMBER = /^-?\d+(\.\d+)?$/;
4645
- var PROFILE = /^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/;
4646
- var commandLike = /* @__PURE__ */ __name((word) => /^[a-z][a-z0-9-]{0,31}$/i.test(word) && withoutSecrets(word) === word ? word : REDACTED, "commandLike");
4647
- var maskedValue = /* @__PURE__ */ __name((name, value, choices) => {
4648
- if (isContentKey(name))
4649
- return REDACTED;
4650
- if (name === "profile")
4651
- return PROFILE.test(value) ? value : REDACTED;
4652
- if (name === "json" || name === "fields")
4653
- return /^[a-z0-9_.,]{1,200}$/.test(value) ? value : REDACTED;
4654
- if (choices?.includes(value))
4655
- return value;
4656
- return safeShape(value) ? value : REDACTED;
4657
- }, "maskedValue");
4658
- var safeShape = /* @__PURE__ */ __name((value) => NUMBER.test(value) && !/^\d{11,}$/.test(value) || /^\d+(ms|s|m|h|d|w)$/.test(value) || /^\d{4}-\d{2}-\d{2}([T ]\d{2}:\d{2}(:\d{2}(\.\d+)?)?(Z|[+-]\d{2}:?\d{2})?)?$/.test(value) || value === "true" || value === "false", "safeShape");
4659
- var runContextOf = /* @__PURE__ */ __name(({ bin, command, program: program2, argv, env, recordInput = false }) => {
4660
- const masked = program2 && argv ? maskArgv(program2, argv, { keep: recordInput }) : void 0;
4661
- const agent = agentOf(env);
4662
- return {
4663
- cliCommand: command ? `${bin} ${command}` : bin,
4664
- ...masked ? { argv: masked.argv } : {},
4665
- ...masked?.unknownCommand === void 0 ? {} : { unknownCommand: masked.unknownCommand },
4666
- ...agent ? { agent } : {}
4667
- };
4668
- }, "runContextOf");
4669
-
4670
- // node_modules/.pnpm/@wirecat+cli-core@0.466.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.64.0_commander@15._f7e4048410ccbe1e801fd184c043d197/node_modules/@wirecat/cli-core/dist/cli/deadline.js
5398
+ // node_modules/.pnpm/@wirecat+cli-core@0.467.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.64.0_commander@15._7a700db966f96e9df6d3178e7072efc2/node_modules/@wirecat/cli-core/dist/cli/deadline.js
4671
5399
  var withDeadline = /* @__PURE__ */ __name(async (ms, closeables, body) => {
4672
5400
  if (ms === void 0)
4673
5401
  return body();
@@ -4693,7 +5421,7 @@ var withDeadline = /* @__PURE__ */ __name(async (ms, closeables, body) => {
4693
5421
  }
4694
5422
  }, "withDeadline");
4695
5423
 
4696
- // node_modules/.pnpm/@wirecat+cli-core@0.466.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.64.0_commander@15._f7e4048410ccbe1e801fd184c043d197/node_modules/@wirecat/cli-core/dist/cli/profile.js
5424
+ // node_modules/.pnpm/@wirecat+cli-core@0.467.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.64.0_commander@15._7a700db966f96e9df6d3178e7072efc2/node_modules/@wirecat/cli-core/dist/cli/profile.js
4697
5425
  var asFirstWord = /* @__PURE__ */ __name((profile) => `${profile} `, "asFirstWord");
4698
5426
  var PLAIN_NAME = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
4699
5427
  var isProfileName = /* @__PURE__ */ __name((word) => PLAIN_NAME.test(word), "isProfileName");
@@ -4758,10 +5486,10 @@ var sampleCommand = /* @__PURE__ */ __name((commands) => {
4758
5486
  return void 0;
4759
5487
  }, "sampleCommand");
4760
5488
 
4761
- // node_modules/.pnpm/@wirecat+cli-core@0.466.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.64.0_commander@15._f7e4048410ccbe1e801fd184c043d197/node_modules/@wirecat/cli-core/dist/cli/settings.js
5489
+ // node_modules/.pnpm/@wirecat+cli-core@0.467.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.64.0_commander@15._7a700db966f96e9df6d3178e7072efc2/node_modules/@wirecat/cli-core/dist/cli/settings.js
4762
5490
  import { existsSync as existsSync3 } from "node:fs";
4763
5491
 
4764
- // node_modules/.pnpm/@wirecat+cli-core@0.466.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.64.0_commander@15._f7e4048410ccbe1e801fd184c043d197/node_modules/@wirecat/cli-core/dist/models/endpoint.js
5492
+ // node_modules/.pnpm/@wirecat+cli-core@0.467.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.64.0_commander@15._7a700db966f96e9df6d3178e7072efc2/node_modules/@wirecat/cli-core/dist/models/endpoint.js
4765
5493
  var endpoint = /* @__PURE__ */ __name((value) => {
4766
5494
  try {
4767
5495
  const url2 = new URL(value);
@@ -4771,7 +5499,7 @@ var endpoint = /* @__PURE__ */ __name((value) => {
4771
5499
  }
4772
5500
  }, "endpoint");
4773
5501
 
4774
- // node_modules/.pnpm/@wirecat+cli-core@0.466.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.64.0_commander@15._f7e4048410ccbe1e801fd184c043d197/node_modules/@wirecat/cli-core/dist/models/settings.js
5502
+ // node_modules/.pnpm/@wirecat+cli-core@0.467.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.64.0_commander@15._7a700db966f96e9df6d3178e7072efc2/node_modules/@wirecat/cli-core/dist/models/settings.js
4775
5503
  var MODEL_FIELDS = ["provider", "model", "base_url"];
4776
5504
  var modelSettingsShape = record(pipe(string(), regex(/^[a-z][a-z0-9-]*$/)), strictObject({
4777
5505
  provider: optional(picklist(["off", "openai", "anthropic"])),
@@ -4840,7 +5568,7 @@ var modelTarget = /* @__PURE__ */ __name((settings, purpose) => {
4840
5568
  };
4841
5569
  }, "modelTarget");
4842
5570
 
4843
- // node_modules/.pnpm/@wirecat+cli-core@0.466.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.64.0_commander@15._f7e4048410ccbe1e801fd184c043d197/node_modules/@wirecat/cli-core/dist/analysis/settings.js
5571
+ // node_modules/.pnpm/@wirecat+cli-core@0.467.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.64.0_commander@15._7a700db966f96e9df6d3178e7072efc2/node_modules/@wirecat/cli-core/dist/analysis/settings.js
4844
5572
  var model = pipe(string(), trim(), minLength(1), maxLength(200));
4845
5573
  var url = pipe(string(), check(endpoint, "use an HTTP/S endpoint without credentials, query or fragment"));
4846
5574
  var AI_FIELDS = {
@@ -4884,7 +5612,7 @@ var resolveAISettings = /* @__PURE__ */ __name((prefix, layers, env) => {
4884
5612
  };
4885
5613
  }, "resolveAISettings");
4886
5614
 
4887
- // node_modules/.pnpm/@wirecat+cli-core@0.466.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.64.0_commander@15._f7e4048410ccbe1e801fd184c043d197/node_modules/@wirecat/cli-core/dist/domain/duration.js
5615
+ // node_modules/.pnpm/@wirecat+cli-core@0.467.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.64.0_commander@15._7a700db966f96e9df6d3178e7072efc2/node_modules/@wirecat/cli-core/dist/domain/duration.js
4888
5616
  var DURATION = /^(\d+)(ms|s|m|h|d)$/;
4889
5617
  var UNIT_MS = { ms: 1, s: 1e3, m: 6e4, h: 36e5, d: 864e5 };
4890
5618
  var parseDuration = /* @__PURE__ */ __name((value, source) => {
@@ -4898,7 +5626,7 @@ var parseDuration = /* @__PURE__ */ __name((value, source) => {
4898
5626
  return ms;
4899
5627
  }, "parseDuration");
4900
5628
 
4901
- // node_modules/.pnpm/@wirecat+cli-core@0.466.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.64.0_commander@15._f7e4048410ccbe1e801fd184c043d197/node_modules/@wirecat/cli-core/dist/embeddings/models.js
5629
+ // node_modules/.pnpm/@wirecat+cli-core@0.467.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.64.0_commander@15._7a700db966f96e9df6d3178e7072efc2/node_modules/@wirecat/cli-core/dist/embeddings/models.js
4902
5630
  var huggingFace = /* @__PURE__ */ __name((repository, commit) => (name) => `https://huggingface.co/${repository}/resolve/${commit}/${name}`, "huggingFace");
4903
5631
  var e5 = huggingFace("Xenova/multilingual-e5-small", "761b726dd34fb83930e26aab4e9ac3899aa1fa78");
4904
5632
  var gemma = huggingFace("onnx-community/embeddinggemma-300m-ONNX", "5090578d9565bb06545b4552f76e6bc2c93e4a66");
@@ -5057,8 +5785,8 @@ var rerankModel = /* @__PURE__ */ __name((id2) => {
5057
5785
  var vectorModelKey = /* @__PURE__ */ __name((model2) => `local:${model2.id}:${model2.dims}`, "vectorModelKey");
5058
5786
  var meaningFloor = /* @__PURE__ */ __name((key) => key === "local:e5-small:384" ? 0.8 : 0, "meaningFloor");
5059
5787
 
5060
- // node_modules/.pnpm/@wirecat+cli-core@0.466.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.64.0_commander@15._f7e4048410ccbe1e801fd184c043d197/node_modules/@wirecat/cli-core/dist/cli/config-issues.js
5061
- import { readFileSync as readFileSync2 } from "node:fs";
5788
+ // node_modules/.pnpm/@wirecat+cli-core@0.467.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.64.0_commander@15._7a700db966f96e9df6d3178e7072efc2/node_modules/@wirecat/cli-core/dist/cli/config-issues.js
5789
+ import { readFileSync as readFileSync3 } from "node:fs";
5062
5790
  var isNode = /* @__PURE__ */ __name((value) => typeof value === "object" && value !== null && !Array.isArray(value), "isNode");
5063
5791
  var SECTIONS = ["personal", "bot"];
5064
5792
  var SHELL_SAFE = /^[A-Za-z0-9_.:@-]*$/;
@@ -5165,8 +5893,8 @@ var failureOffset = /* @__PURE__ */ __name((text2) => {
5165
5893
  value();
5166
5894
  space();
5167
5895
  return at;
5168
- } catch (stopped) {
5169
- return typeof stopped === "number" ? stopped : at;
5896
+ } catch (stopped2) {
5897
+ return typeof stopped2 === "number" ? stopped2 : at;
5170
5898
  }
5171
5899
  }, "failureOffset");
5172
5900
  var parseConfigText = /* @__PURE__ */ __name((text2, file) => {
@@ -5237,7 +5965,7 @@ var schemaIssues = /* @__PURE__ */ __name((raw, schema, context) => {
5237
5965
  return [...found.values()];
5238
5966
  }
5239
5967
  }, "schemaIssues");
5240
- var scopes = /* @__PURE__ */ __name((raw) => {
5968
+ var scopes2 = /* @__PURE__ */ __name((raw) => {
5241
5969
  if (!isNode(raw))
5242
5970
  return [];
5243
5971
  const out = [];
@@ -5259,7 +5987,7 @@ var scopes = /* @__PURE__ */ __name((raw) => {
5259
5987
  addSection([name], raw[name]);
5260
5988
  return out;
5261
5989
  }, "scopes");
5262
- var savedPermissionKeys = /* @__PURE__ */ __name((raw) => scopes(raw).flatMap(([path2, scope]) => isNode(scope.permissions) ? Object.keys(scope.permissions).map((key) => ({ key, at: [...path2, "permissions", key] })) : []), "savedPermissionKeys");
5990
+ var savedPermissionKeys = /* @__PURE__ */ __name((raw) => scopes2(raw).flatMap(([path2, scope]) => isNode(scope.permissions) ? Object.keys(scope.permissions).map((key) => ({ key, at: [...path2, "permissions", key] })) : []), "savedPermissionKeys");
5263
5991
  var permissionIssues = /* @__PURE__ */ __name((saved, known, context) => saved.filter(({ key }) => !known.has(key)).map(({ at }) => locate("unknown_permission", at, context, (key) => `${key} names no command`)), "permissionIssues");
5264
5992
  var pathId = /* @__PURE__ */ __name((path2) => path2.join("\0"), "pathId");
5265
5993
  var prune = /* @__PURE__ */ __name((raw, paths) => {
@@ -5327,7 +6055,7 @@ var checkConfigText = /* @__PURE__ */ __name((text2, { file, tool, schema, known
5327
6055
  var wholeFile = /* @__PURE__ */ __name((file, what) => ({ kind: "invalid_value", file, what }), "wholeFile");
5328
6056
  var readConfigText = /* @__PURE__ */ __name((path2) => {
5329
6057
  try {
5330
- return { text: readFileSync2(path2, "utf8") };
6058
+ return { text: readFileSync3(path2, "utf8") };
5331
6059
  } catch (error) {
5332
6060
  const code = error.code;
5333
6061
  if (code === "ENOENT")
@@ -5347,9 +6075,9 @@ var readConfigFile = /* @__PURE__ */ __name((path2) => {
5347
6075
  return "issue" in parsed ? { issue: publicIssue(parsed.issue) } : parsed;
5348
6076
  }, "readConfigFile");
5349
6077
 
5350
- // node_modules/.pnpm/@wirecat+cli-core@0.466.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.64.0_commander@15._f7e4048410ccbe1e801fd184c043d197/node_modules/@wirecat/cli-core/dist/cli/default-config.js
5351
- import { existsSync as existsSync2, linkSync, mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
5352
- import { dirname, join as join2 } from "node:path";
6078
+ // node_modules/.pnpm/@wirecat+cli-core@0.467.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.64.0_commander@15._7a700db966f96e9df6d3178e7072efc2/node_modules/@wirecat/cli-core/dist/cli/default-config.js
6079
+ import { existsSync as existsSync2, linkSync, mkdirSync as mkdirSync2, mkdtempSync, rmSync as rmSync2, writeFileSync as writeFileSync2 } from "node:fs";
6080
+ import { dirname, join as join3 } from "node:path";
5353
6081
  var DEFAULT_CONFIG = {
5354
6082
  defaults: { limit: 20, keep_runs_for_days: 30, sends_per_hour: 30, update_check: true, skill_hint: true },
5355
6083
  profiles: {}
@@ -5358,11 +6086,11 @@ function ensureDefaultConfig(path2, config = DEFAULT_CONFIG) {
5358
6086
  if (existsSync2(path2))
5359
6087
  return;
5360
6088
  const directory = dirname(path2);
5361
- mkdirSync(directory, { recursive: true, mode: 448 });
5362
- const temporary = mkdtempSync(join2(directory, ".config-"));
5363
- const candidate = join2(temporary, "config.json");
6089
+ mkdirSync2(directory, { recursive: true, mode: 448 });
6090
+ const temporary = mkdtempSync(join3(directory, ".config-"));
6091
+ const candidate = join3(temporary, "config.json");
5364
6092
  try {
5365
- writeFileSync(candidate, `${JSON.stringify(config, null, 2)}
6093
+ writeFileSync2(candidate, `${JSON.stringify(config, null, 2)}
5366
6094
  `, { flag: "wx", mode: 384 });
5367
6095
  try {
5368
6096
  linkSync(candidate, path2);
@@ -5371,12 +6099,12 @@ function ensureDefaultConfig(path2, config = DEFAULT_CONFIG) {
5371
6099
  throw error;
5372
6100
  }
5373
6101
  } finally {
5374
- rmSync(temporary, { recursive: true, force: true });
6102
+ rmSync2(temporary, { recursive: true, force: true });
5375
6103
  }
5376
6104
  }
5377
6105
  __name(ensureDefaultConfig, "ensureDefaultConfig");
5378
6106
 
5379
- // node_modules/.pnpm/@wirecat+cli-core@0.466.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.64.0_commander@15._f7e4048410ccbe1e801fd184c043d197/node_modules/@wirecat/cli-core/dist/cli/settings.js
6107
+ // node_modules/.pnpm/@wirecat+cli-core@0.467.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.64.0_commander@15._7a700db966f96e9df6d3178e7072efc2/node_modules/@wirecat/cli-core/dist/cli/settings.js
5380
6108
  var DEFAULT_LIMIT = DEFAULT_CONFIG.defaults.limit;
5381
6109
  var DEFAULT_KEEP_RUNS_FOR_DAYS = DEFAULT_CONFIG.defaults.keep_runs_for_days;
5382
6110
  var DEFAULT_SENDS_PER_HOUR = DEFAULT_CONFIG.defaults.sends_per_hour;
@@ -5393,6 +6121,7 @@ var count2 = pipe(number(wholeNumber), integer(wholeNumber), minValue(1, wholeNu
5393
6121
  var zeroOrMore = plain("has to be a whole number, 0 or more");
5394
6122
  var countOrZero = pipe(number(zeroOrMore), integer(zeroOrMore), minValue(0, zeroOrMore));
5395
6123
  var flag = boolean(plain("has to be true or false"));
6124
+ var recordInputSetting = union([boolean(), literal("failed")], plain('has to be true, false or "failed"'));
5396
6125
  var wholeOrZero = /* @__PURE__ */ __name((text2, name) => {
5397
6126
  const value = Number(text2);
5398
6127
  if (!Number.isInteger(value) || value < 0)
@@ -5409,8 +6138,10 @@ var SHARED_PROFILE_ENTRIES = {
5409
6138
  color: optional(flag),
5410
6139
  sender_colors: optional(flag),
5411
6140
  record: optional(flag),
5412
- record_input: optional(flag),
6141
+ record_input: optional(recordInputSetting),
5413
6142
  keep_runs_for_days: optional(count2),
6143
+ keep_successful_runs_for_days: optional(count2),
6144
+ runs_size_limit_mb: optional(count2),
5414
6145
  permissions: optional(permissionLevels),
5415
6146
  sends_per_hour: optional(count2),
5416
6147
  requests_per_minute: optional(countOrZero),
@@ -5480,7 +6211,7 @@ var settingsFor = /* @__PURE__ */ __name((app, extension = {}) => {
5480
6211
  const defaultsOnlyKeys = Object.keys(defaultsOnly);
5481
6212
  const botOnlyKeys = Object.keys(BOT_ONLY_ENTRIES);
5482
6213
  const allSettings = [...Object.keys(profileEntries), ...botOnlyKeys, ...defaultsOnlyKeys];
5483
- const PROFILE2 = envName(app, "PROFILE");
6214
+ const PROFILE = envName(app, "PROFILE");
5484
6215
  const PROFILE_LOCK = envName(app, "PROFILE_LOCK");
5485
6216
  const TIMEOUT = envName(app, "TIMEOUT");
5486
6217
  const REQUESTS_PER_MINUTE = envName(app, "REQUESTS_PER_MINUTE");
@@ -5502,7 +6233,7 @@ var settingsFor = /* @__PURE__ */ __name((app, extension = {}) => {
5502
6233
  usableProfileName(lock);
5503
6234
  if (profile.value === lock)
5504
6235
  return profile;
5505
- if (profile.from === "first word" || profile.from === PROFILE2) {
6236
+ if (profile.from === "first word" || profile.from === PROFILE) {
5506
6237
  throw new CliError("permission_error", `this process is locked to profile ${lock} (${PROFILE_LOCK}) \u2014 profile "${profile.value}" is refused`);
5507
6238
  }
5508
6239
  return { value: lock, from: PROFILE_LOCK };
@@ -5513,7 +6244,7 @@ var settingsFor = /* @__PURE__ */ __name((app, extension = {}) => {
5513
6244
  const here = profilesOf(config, env);
5514
6245
  if (here.length === 0)
5515
6246
  throw new NoProfileHere(app);
5516
- throw new CliError("validation_error", `name a profile: \`${app.command} <profile> \u2026\` \u2014 profiles here: ${here.join(", ")} (or set ${PROFILE2})`, { profiles: here });
6247
+ throw new CliError("validation_error", `name a profile: \`${app.command} <profile> \u2026\` \u2014 profiles here: ${here.join(", ")} (or set ${PROFILE})`, { profiles: here });
5517
6248
  }, "unnamed");
5518
6249
  const profilesOf = /* @__PURE__ */ __name((config, env) => profilesHere(app, [...namedProfiles(config), ...extension.profiles?.(env) ?? []], env), "profilesOf");
5519
6250
  const resolveSettings = /* @__PURE__ */ __name((flags = {}, options = {}) => {
@@ -5530,12 +6261,12 @@ var settingsFor = /* @__PURE__ */ __name((app, extension = {}) => {
5530
6261
  throw new CliError("configuration_error", issueMessage(loaded.issues));
5531
6262
  const { config } = loaded;
5532
6263
  const lock = given(env[PROFILE_LOCK]);
5533
- const named = first([
6264
+ const named2 = first([
5534
6265
  ["first word", flags.profile],
5535
- [PROFILE2, given(env[PROFILE2])],
6266
+ [PROFILE, given(env[PROFILE])],
5536
6267
  [PROFILE_LOCK, lock]
5537
6268
  ], void 0);
5538
- const profile = locked(named.value === void 0 ? unnamed(config, env, options.needsProfile !== false) : { value: named.value, from: named.from }, lock);
6269
+ const profile = locked(named2.value === void 0 ? unnamed(config, env, options.needsProfile !== false) : { value: named2.value, from: named2.from }, lock);
5539
6270
  const kind = options.kind ?? "personal";
5540
6271
  const name = usableProfileName(profile.value);
5541
6272
  const configured = config.profiles[name] ?? {};
@@ -5550,7 +6281,7 @@ var settingsFor = /* @__PURE__ */ __name((app, extension = {}) => {
5550
6281
  const fromLayers = /* @__PURE__ */ __name((key, fallback, only = layers) => first(only.map(([from, scope]) => [from, scope?.[key]]), fallback), "fromLayers");
5551
6282
  const kindLayers = layers.filter(([from]) => from.startsWith(`config file: ${kind}.`));
5552
6283
  const limit = flags.limit === void 0 ? fromLayers("limit", DEFAULT_LIMIT) : { value: flags.limit, from: "flag" };
5553
- const record2 = flags.record === void 0 ? fromLayers("record", false) : { value: flags.record, from: "flag" };
6284
+ const record2 = flags.record === void 0 ? fromLayers("record", true) : { value: flags.record, from: "flag" };
5554
6285
  const timeoutMs = fromLayers("timeout_ms", void 0);
5555
6286
  const color = fromLayers("color", void 0);
5556
6287
  const senderColors = fromLayers("sender_colors", false);
@@ -5559,6 +6290,8 @@ var settingsFor = /* @__PURE__ */ __name((app, extension = {}) => {
5559
6290
  const searchReranker = fromLayers("search_reranker", DEFAULT_RERANK_MODEL);
5560
6291
  const recordInput = fromLayers("record_input", true);
5561
6292
  const keepRunsForDays = fromLayers("keep_runs_for_days", DEFAULT_KEEP_RUNS_FOR_DAYS);
6293
+ const keepSuccessfulRunsForDays = fromLayers("keep_successful_runs_for_days", KEEP_SUCCESSFUL_RUNS_FOR_DAYS);
6294
+ const runsSizeLimitMb = fromLayers("runs_size_limit_mb", RUNS_SIZE_LIMIT_MB);
5562
6295
  const readOnlyLock = readOnlyLockOf(app, env);
5563
6296
  const sendsPerHour = kind === "bot" ? fromLayers("sends_per_hour", Number.POSITIVE_INFINITY, kindLayers) : fromLayers("sends_per_hour", DEFAULT_SENDS_PER_HOUR);
5564
6297
  const paceFromEnv = given(env[REQUESTS_PER_MINUTE]);
@@ -5604,8 +6337,10 @@ var settingsFor = /* @__PURE__ */ __name((app, extension = {}) => {
5604
6337
  commandTimeoutMs: timeout.value === void 0 ? void 0 : (extension.parseDuration ?? parseDuration)(timeout.value, timeout.from === TIMEOUT ? TIMEOUT : "--timeout"),
5605
6338
  record: record2.value,
5606
6339
  recordInput: recordInput.value,
5607
- keepFailedRuns: record2.value || record2.from === "default",
6340
+ keepFailedRuns: record2.value || record2.from !== "flag",
5608
6341
  keepRunsForDays: keepRunsForDays.value,
6342
+ keepSuccessfulRunsForDays: keepSuccessfulRunsForDays.value,
6343
+ runsSizeLimitMb: runsSizeLimitMb.value,
5609
6344
  ...readOnlyLock ? { readOnlyLock } : {},
5610
6345
  permissions: permissions.levels,
5611
6346
  permissionSources: permissions.sources,
@@ -5633,6 +6368,8 @@ var settingsFor = /* @__PURE__ */ __name((app, extension = {}) => {
5633
6368
  record: record2.from,
5634
6369
  recordInput: recordInput.from,
5635
6370
  keepRunsForDays: keepRunsForDays.from,
6371
+ keepSuccessfulRunsForDays: keepSuccessfulRunsForDays.from,
6372
+ runsSizeLimitMb: runsSizeLimitMb.from,
5636
6373
  sendsPerHour: sendsPerHour.from,
5637
6374
  requestsPerMinute: requestsPerMinute.from,
5638
6375
  readOtherBots: readOtherBots.from,
@@ -5750,7 +6487,7 @@ var given = /* @__PURE__ */ __name((value) => {
5750
6487
  return trimmed === void 0 || trimmed === "" ? void 0 : trimmed;
5751
6488
  }, "given");
5752
6489
 
5753
- // node_modules/.pnpm/@wirecat+cli-core@0.466.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.64.0_commander@15._f7e4048410ccbe1e801fd184c043d197/node_modules/@wirecat/cli-core/dist/cli/context.js
6490
+ // node_modules/.pnpm/@wirecat+cli-core@0.467.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.64.0_commander@15._7a700db966f96e9df6d3178e7072efc2/node_modules/@wirecat/cli-core/dist/cli/context.js
5754
6491
  var setExitCode = /* @__PURE__ */ __name((command, code) => {
5755
6492
  const slot = environmentOf(command).exit;
5756
6493
  if (slot)
@@ -5822,13 +6559,22 @@ var baseContext = /* @__PURE__ */ __name((command, resolveSettings) => {
5822
6559
  program: rootOf(command),
5823
6560
  ...environment.argv ? { argv: environment.argv } : {},
5824
6561
  env,
5825
- recordInput: settings.recordInput !== false
6562
+ recordInput: settings.recordInput ?? true,
6563
+ caller: environment.agent?.caller ?? currentCaller()
5826
6564
  }),
5827
6565
  ...ranFor === void 0 ? {} : { profile: ranFor },
5828
- record: settings.record,
6566
+ record: keepsSuccess({
6567
+ record: settings.record,
6568
+ fromFlag: settings.sources?.record === "flag",
6569
+ env,
6570
+ caller: environment.agent?.caller ?? currentCaller(),
6571
+ persistent: metaOf(command).lifetime === "persistent"
6572
+ }),
5829
6573
  keepFailed: settings.keepFailedRuns,
5830
6574
  trace: settings.trace,
5831
6575
  keepDays: settings.keepRunsForDays,
6576
+ ...settings.keepSuccessfulRunsForDays === void 0 ? {} : { keepSuccessDays: settings.keepSuccessfulRunsForDays },
6577
+ ...settings.runsSizeLimitMb === void 0 ? {} : { maxBytes: settings.runsSizeLimitMb * 1024 * 1024 },
5832
6578
  processRun: !environment.agent,
5833
6579
  format,
5834
6580
  streams,
@@ -5843,12 +6589,12 @@ var baseContext = /* @__PURE__ */ __name((command, resolveSettings) => {
5843
6589
  }, "baseContext");
5844
6590
  var commandPath = /* @__PURE__ */ __name((command) => {
5845
6591
  const words = [];
5846
- for (let current = command; current?.parent; current = current.parent)
5847
- words.unshift(current.name());
6592
+ for (let current2 = command; current2?.parent; current2 = current2.parent)
6593
+ words.unshift(current2.name());
5848
6594
  return words.join(" ");
5849
6595
  }, "commandPath");
5850
6596
 
5851
- // node_modules/.pnpm/@wirecat+cli-core@0.466.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.64.0_commander@15._f7e4048410ccbe1e801fd184c043d197/node_modules/@wirecat/cli-core/dist/cli/effects.js
6597
+ // node_modules/.pnpm/@wirecat+cli-core@0.467.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.64.0_commander@15._7a700db966f96e9df6d3178e7072efc2/node_modules/@wirecat/cli-core/dist/cli/effects.js
5852
6598
  var REMOTE_READ = { remote: "read", local: "read" };
5853
6599
  var FETCH = { remote: "read", local: "write" };
5854
6600
  var REMOTE_WRITE = { remote: "write", local: "write" };
@@ -5939,7 +6685,7 @@ var refuseUnderReadOnly = /* @__PURE__ */ __name((command, what) => {
5939
6685
  throw readOnlyRefusal(lock, what);
5940
6686
  }, "refuseUnderReadOnly");
5941
6687
 
5942
- // node_modules/.pnpm/@wirecat+cli-core@0.466.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.64.0_commander@15._f7e4048410ccbe1e801fd184c043d197/node_modules/@wirecat/cli-core/dist/cli/steps.js
6688
+ // node_modules/.pnpm/@wirecat+cli-core@0.467.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.64.0_commander@15._7a700db966f96e9df6d3178e7072efc2/node_modules/@wirecat/cli-core/dist/cli/steps.js
5943
6689
  var STEPS2 = defineSteps([
5944
6690
  ...STEPS,
5945
6691
  {
@@ -6196,7 +6942,7 @@ var stepLine = /* @__PURE__ */ __name((root, step) => {
6196
6942
  ].join(" ");
6197
6943
  }, "stepLine");
6198
6944
 
6199
- // node_modules/.pnpm/@wirecat+cli-core@0.466.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.64.0_commander@15._f7e4048410ccbe1e801fd184c043d197/node_modules/@wirecat/cli-core/dist/cli/provider-refs.js
6945
+ // node_modules/.pnpm/@wirecat+cli-core@0.467.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.64.0_commander@15._7a700db966f96e9df6d3178e7072efc2/node_modules/@wirecat/cli-core/dist/cli/provider-refs.js
6200
6946
  var HIDDEN = /* @__PURE__ */ new Set(["providerRef", "provider_ref"]);
6201
6947
  var withoutProviderRefs = /* @__PURE__ */ __name((value) => strip(value), "withoutProviderRefs");
6202
6948
  var strip = /* @__PURE__ */ __name((value) => {
@@ -6210,9 +6956,9 @@ var strip = /* @__PURE__ */ __name((value) => {
6210
6956
  return Object.fromEntries(Object.entries(value).flatMap(([key, inner]) => HIDDEN.has(key) ? [] : [[key, strip(inner)]]));
6211
6957
  }, "strip");
6212
6958
 
6213
- // node_modules/.pnpm/@wirecat+cli-core@0.466.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.64.0_commander@15._f7e4048410ccbe1e801fd184c043d197/node_modules/@wirecat/cli-core/dist/cli/envelope.js
6959
+ // node_modules/.pnpm/@wirecat+cli-core@0.467.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.64.0_commander@15._7a700db966f96e9df6d3178e7072efc2/node_modules/@wirecat/cli-core/dist/cli/envelope.js
6214
6960
  var answerSchema = /* @__PURE__ */ __name((item = unknown()) => union([listEnvelopeSchema(item), itemEnvelopeSchema(item)]), "answerSchema");
6215
- var capped = /* @__PURE__ */ __name((steps) => steps.length > 0 ? { next: steps.slice(0, MAX_NEXT_STEPS) } : {}, "capped");
6961
+ var capped2 = /* @__PURE__ */ __name((steps) => steps.length > 0 ? { next: steps.slice(0, MAX_NEXT_STEPS) } : {}, "capped");
6216
6962
  var listOf = /* @__PURE__ */ __name((command, input) => {
6217
6963
  const { items, limit, has_more, cursor, paging, page, args = {}, next = [], missing, meta } = input;
6218
6964
  const byCursor = paging === "cursor" || cursor !== void 0;
@@ -6226,7 +6972,7 @@ var listOf = /* @__PURE__ */ __name((command, input) => {
6226
6972
  const body = {
6227
6973
  items,
6228
6974
  page: byCursor ? { mode: "cursor", limit, has_more, ...has_more && cursor !== void 0 ? { next_cursor: cursor } : {} } : { mode: "page", limit, has_more, ...has_more ? { next_page: (page ?? 1) + 1 } : {} },
6229
- ...capped([...more, ...next]),
6975
+ ...capped2([...more, ...next]),
6230
6976
  ...missing && missing.length > 0 ? { missing } : {},
6231
6977
  ...meta ? { meta } : {}
6232
6978
  };
@@ -6235,13 +6981,13 @@ var listOf = /* @__PURE__ */ __name((command, input) => {
6235
6981
  var itemOf = /* @__PURE__ */ __name((item, { next = [], missing, meta } = {}) => {
6236
6982
  const body = {
6237
6983
  item,
6238
- ...capped(next),
6984
+ ...capped2(next),
6239
6985
  ...missing && missing.length > 0 ? { missing } : {},
6240
6986
  ...meta ? { meta } : {}
6241
6987
  };
6242
6988
  return body;
6243
6989
  }, "itemOf");
6244
- var snake2 = /* @__PURE__ */ __name((key) => key.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`), "snake");
6990
+ var snake3 = /* @__PURE__ */ __name((key) => key.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`), "snake");
6245
6991
  var snakeKeysKeeping = /* @__PURE__ */ __name((verbatim) => {
6246
6992
  const kept = new Set(verbatim);
6247
6993
  const convert = /* @__PURE__ */ __name((value) => {
@@ -6252,7 +6998,7 @@ var snakeKeysKeeping = /* @__PURE__ */ __name((verbatim) => {
6252
6998
  return Object.fromEntries(Object.entries(value).flatMap(([key, inner]) => {
6253
6999
  if (inner === void 0)
6254
7000
  return [];
6255
- const name = snake2(key);
7001
+ const name = snake3(key);
6256
7002
  return [[name, kept.has(key) || kept.has(name) ? inner : convert(inner)]];
6257
7003
  }));
6258
7004
  }, "convert");
@@ -6332,7 +7078,7 @@ var printItem = /* @__PURE__ */ __name(({ renderer, format }, item) => {
6332
7078
  renderer.result(item);
6333
7079
  }, "printItem");
6334
7080
 
6335
- // node_modules/.pnpm/@wirecat+cli-core@0.466.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.64.0_commander@15._f7e4048410ccbe1e801fd184c043d197/node_modules/@wirecat/cli-core/dist/entities/store-table.js
7081
+ // node_modules/.pnpm/@wirecat+cli-core@0.467.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.64.0_commander@15._7a700db966f96e9df6d3178e7072efc2/node_modules/@wirecat/cli-core/dist/entities/store-table.js
6336
7082
  var TABLE_KINDS = ["data", "search_index", "search_index_part", "internal"];
6337
7083
  var storeTable = strictObject({
6338
7084
  name: text,
@@ -6341,7 +7087,7 @@ var storeTable = strictObject({
6341
7087
  bytes: optional(nullable(count))
6342
7088
  });
6343
7089
 
6344
- // node_modules/.pnpm/@wirecat+cli-core@0.466.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.64.0_commander@15._f7e4048410ccbe1e801fd184c043d197/node_modules/@wirecat/cli-core/dist/botcheck/reasons.js
7090
+ // node_modules/.pnpm/@wirecat+cli-core@0.467.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.64.0_commander@15._7a700db966f96e9df6d3178e7072efc2/node_modules/@wirecat/cli-core/dist/botcheck/reasons.js
6345
7091
  var WEIGHTS = {
6346
7092
  bot: 3,
6347
7093
  scam: 3,
@@ -6366,7 +7112,7 @@ var LINK = /https?:\/\/|t\.me\/|www\./i;
6366
7112
  var DIGITS = /\d{5,}/;
6367
7113
  var oddName = /* @__PURE__ */ __name((name) => !name?.trim() || DIGITS.test(name) || LINK.test(name), "oddName");
6368
7114
 
6369
- // node_modules/.pnpm/@wirecat+cli-core@0.466.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.64.0_commander@15._f7e4048410ccbe1e801fd184c043d197/node_modules/@wirecat/cli-core/dist/entities/task.js
7115
+ // node_modules/.pnpm/@wirecat+cli-core@0.467.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.64.0_commander@15._7a700db966f96e9df6d3178e7072efc2/node_modules/@wirecat/cli-core/dist/entities/task.js
6370
7116
  var closeSuggestion = strictObject({
6371
7117
  as: picklist(["done", "dismissed"]),
6372
7118
  /** The agent's name. */
@@ -6408,7 +7154,7 @@ var task = strictObject({
6408
7154
  updated_at: optional(time)
6409
7155
  });
6410
7156
 
6411
- // node_modules/.pnpm/@wirecat+cli-core@0.466.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.64.0_commander@15._f7e4048410ccbe1e801fd184c043d197/node_modules/@wirecat/cli-core/dist/entities/agenda.js
7157
+ // node_modules/.pnpm/@wirecat+cli-core@0.467.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.64.0_commander@15._7a700db966f96e9df6d3178e7072efc2/node_modules/@wirecat/cli-core/dist/entities/agenda.js
6412
7158
  var agendaChat = strictObject({
6413
7159
  chat: reference,
6414
7160
  title: nullable(text),
@@ -6468,7 +7214,7 @@ var agenda = strictObject({
6468
7214
  unlisted_categories: array(strictObject({ name: text, open_tasks: number() }))
6469
7215
  });
6470
7216
 
6471
- // node_modules/.pnpm/@wirecat+cli-core@0.466.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.64.0_commander@15._f7e4048410ccbe1e801fd184c043d197/node_modules/@wirecat/cli-core/dist/entities/conversation.js
7217
+ // node_modules/.pnpm/@wirecat+cli-core@0.467.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.64.0_commander@15._7a700db966f96e9df6d3178e7072efc2/node_modules/@wirecat/cli-core/dist/entities/conversation.js
6472
7218
  var conversation = strictObject({
6473
7219
  id,
6474
7220
  chat: reference,
@@ -6483,7 +7229,7 @@ var conversation = strictObject({
6483
7229
  rules_version: count
6484
7230
  });
6485
7231
 
6486
- // node_modules/.pnpm/@wirecat+cli-core@0.466.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.64.0_commander@15._f7e4048410ccbe1e801fd184c043d197/node_modules/@wirecat/cli-core/dist/entities/attachment.js
7232
+ // node_modules/.pnpm/@wirecat+cli-core@0.467.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.64.0_commander@15._7a700db966f96e9df6d3178e7072efc2/node_modules/@wirecat/cli-core/dist/entities/attachment.js
6487
7233
  var attachment = strictObject({
6488
7234
  /** The message it came with, as a locator; absent inside that message. */
6489
7235
  message: optional(reference),
@@ -6512,7 +7258,7 @@ var attachment = strictObject({
6512
7258
  }))))
6513
7259
  });
6514
7260
 
6515
- // node_modules/.pnpm/@wirecat+cli-core@0.466.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.64.0_commander@15._f7e4048410ccbe1e801fd184c043d197/node_modules/@wirecat/cli-core/dist/entities/tagging.js
7261
+ // node_modules/.pnpm/@wirecat+cli-core@0.467.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.64.0_commander@15._7a700db966f96e9df6d3178e7072efc2/node_modules/@wirecat/cli-core/dist/entities/tagging.js
6516
7262
  var tagging = strictObject({
6517
7263
  tag: text,
6518
7264
  type: picklist(TAG_TYPES),
@@ -6525,7 +7271,7 @@ var tagging = strictObject({
6525
7271
  created_at: time
6526
7272
  });
6527
7273
 
6528
- // node_modules/.pnpm/@wirecat+cli-core@0.466.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.64.0_commander@15._f7e4048410ccbe1e801fd184c043d197/node_modules/@wirecat/cli-core/dist/runs/record-log.js
7274
+ // node_modules/.pnpm/@wirecat+cli-core@0.467.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.64.0_commander@15._7a700db966f96e9df6d3178e7072efc2/node_modules/@wirecat/cli-core/dist/runs/record-log.js
6529
7275
  var recordLogFor = /* @__PURE__ */ __name((to, app, { traceId, command } = {}) => {
6530
7276
  const run = currentRun();
6531
7277
  const trace = traceId ?? run.traceId;
@@ -6557,18 +7303,31 @@ export {
6557
7303
  sharedCommand,
6558
7304
  customizeSharedCommand,
6559
7305
  refuseJoinedPath,
6560
- isCliFailure,
6561
- isCommanderFailure,
6562
- failureKey,
6563
- providerErrorKey,
7306
+ logAttributes,
7307
+ fromLogAttributes,
7308
+ LOG_ATTRIBUTES,
7309
+ runsDirFor,
7310
+ runtime,
7311
+ newRunId,
7312
+ listRuns,
7313
+ findRun,
7314
+ readEvents,
7315
+ currentRun,
7316
+ inRun,
7317
+ runEvent,
7318
+ typedCommand,
7319
+ useAsProcessRun,
7320
+ processRun,
7321
+ childTrace,
7322
+ withAttempt,
7323
+ currentAttempt,
6564
7324
  recorded,
6565
7325
  startRecording,
6566
7326
  wasSettled,
6567
- partialOutcome,
6568
- agentOf,
6569
- secretInput,
6570
- maskArgv,
6571
- runContextOf,
7327
+ sentIds,
7328
+ currentOperation,
7329
+ guardedWrite,
7330
+ codeOf,
6572
7331
  withDeadline,
6573
7332
  DEFAULT_COMMAND_MS,
6574
7333
  DEFAULT_COOPERATIVE_MS,
@@ -6598,6 +7357,22 @@ export {
6598
7357
  rerankModel,
6599
7358
  vectorModelKey,
6600
7359
  meaningFloor,
7360
+ LEVELS,
7361
+ skipFlagFor,
7362
+ DEFAULT_PERMISSIONS,
7363
+ AUTHORITY_KEY,
7364
+ authorityAllowed,
7365
+ BOT_API_KEY,
7366
+ isBotApi,
7367
+ botApiAllowed,
7368
+ CEILING_KEY,
7369
+ levelFor,
7370
+ keyForWrite,
7371
+ writeOfKey,
7372
+ WRITE_KEYS,
7373
+ readKeysForCommand,
7374
+ keyForCommand,
7375
+ assertRetentionEvidenceRead,
6601
7376
  permissionIssues,
6602
7377
  publicIssue,
6603
7378
  issueMessage,