@wirecat/tg-cli 0.100.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 (117) hide show
  1. package/README.md +3 -3
  2. package/dist/bin/tg.js +1 -1
  3. package/dist/bot/transport.d.ts.map +1 -1
  4. package/dist/bot/transport.js +14 -17
  5. package/dist/bot/transport.js.map +1 -1
  6. package/dist/bundle/{adapter-2LVPMFKF.js → adapter-M2HRSFFL.js} +95 -33
  7. package/dist/bundle/{all-profiles-BLTK2AAB.js → all-profiles-GOD2QNTK.js} +42 -12
  8. package/dist/bundle/{anthropic-RJE4XEOO.js → anthropic-LKU7RWMA.js} +5 -5
  9. package/dist/bundle/{bot-api-4XM3NVWG.js → bot-api-X3MPFVPL.js} +49 -53
  10. package/dist/bundle/{bot-history-WVM5GEQN.js → bot-history-OUMVVG22.js} +15 -15
  11. package/dist/bundle/{bun-UZXO2LRQ.js → bun-LIZ6MKFS.js} +2 -2
  12. package/dist/bundle/{bun-sqlite-GJLGSQIT.js → bun-sqlite-2IFQYQ44.js} +4 -4
  13. package/dist/bundle/chunk-264DAFJV.js +161 -0
  14. package/dist/bundle/{chunk-ASDZHG5I.js → chunk-2SUTCDGO.js} +2 -2
  15. package/dist/bundle/{chunk-2IM4M7Q2.js → chunk-2XBSVRT2.js} +1 -1
  16. package/dist/bundle/{chunk-Q26JMPBP.js → chunk-334UBWOB.js} +11 -11
  17. package/dist/bundle/{chunk-MQNFEVAH.js → chunk-4PDEQL6T.js} +2 -2
  18. package/dist/bundle/chunk-4QB4WDLT.js +922 -0
  19. package/dist/bundle/{chunk-66E5QDLH.js → chunk-5D6OJREA.js} +1 -1
  20. package/dist/bundle/{chunk-RDQMV6EU.js → chunk-5DFGJPT6.js} +4 -4
  21. package/dist/bundle/{chunk-GTURDJJD.js → chunk-5KU4UQBM.js} +1 -1
  22. package/dist/bundle/{chunk-JSKT5UZX.js → chunk-5VSR5ENL.js} +8 -8
  23. package/dist/bundle/{chunk-DN4QUTWU.js → chunk-AUOXTGTU.js} +1 -1
  24. package/dist/bundle/{chunk-X4Y2ROJI.js → chunk-BBC546ZA.js} +91 -2
  25. package/dist/bundle/{chunk-RER6DAHP.js → chunk-BQYTIYGB.js} +171 -148
  26. package/dist/bundle/{chunk-3S5CL55R.js → chunk-CLWYQNSC.js} +6 -6
  27. package/dist/bundle/{chunk-I6WZJVRT.js → chunk-CRZPQQHE.js} +59 -46
  28. package/dist/bundle/chunk-DE7LFMY2.js +440 -0
  29. package/dist/bundle/{chunk-GYEOQS2D.js → chunk-DG62L57H.js} +17 -17
  30. package/dist/bundle/{chunk-QU2FJMFB.js → chunk-ENE5CSVY.js} +2903 -1490
  31. package/dist/bundle/{chunk-P26LWFNZ.js → chunk-ERQDBK5I.js} +1 -1
  32. package/dist/bundle/{chunk-UD4DOZCN.js → chunk-F2TG3BA2.js} +6 -6
  33. package/dist/bundle/{chunk-4U7QOFDA.js → chunk-FBWOQMPE.js} +1698 -816
  34. package/dist/bundle/{chunk-JFJVS5JC.js → chunk-FOUE7XLK.js} +2 -2
  35. package/dist/bundle/{chunk-3QDPV34J.js → chunk-GSKFAE3I.js} +1297 -518
  36. package/dist/bundle/{chunk-BAIZAZ6Q.js → chunk-HLAZ65AW.js} +2 -2
  37. package/dist/bundle/{chunk-LI7TXFLS.js → chunk-JFSVXMN6.js} +3 -3
  38. package/dist/bundle/{chunk-6VEOR6GD.js → chunk-M5UH5CF3.js} +6 -8
  39. package/dist/bundle/{chunk-HXTTDIL7.js → chunk-MGG7JSNO.js} +3 -3
  40. package/dist/bundle/{chunk-6YLT4YVJ.js → chunk-OCWARAFE.js} +2 -2
  41. package/dist/bundle/{chunk-WE3LBRMB.js → chunk-OEJ5DMCX.js} +7 -7
  42. package/dist/bundle/{chunk-SGJYU3SB.js → chunk-OHBHHBYL.js} +3 -3
  43. package/dist/bundle/{chunk-2MXQ2EUN.js → chunk-PSH7K6TL.js} +617 -57
  44. package/dist/bundle/{chunk-H3X5LS6U.js → chunk-PYTOIDSM.js} +4 -4
  45. package/dist/bundle/{chunk-ATZ44Z77.js → chunk-Q2NYEX4A.js} +150 -52
  46. package/dist/bundle/{chunk-KE6L2UEG.js → chunk-QEPZUFPL.js} +70 -61
  47. package/dist/bundle/{chunk-CV5ASHTW.js → chunk-QL7CQ6VZ.js} +255 -80
  48. package/dist/bundle/{chunk-THVNP6S6.js → chunk-SRU3OF4R.js} +2 -2
  49. package/dist/bundle/{chunk-OOOV3JBZ.js → chunk-TV5DGHBT.js} +953 -677
  50. package/dist/bundle/{chunk-A7OBVRJV.js → chunk-TXBUDJ3P.js} +3 -3
  51. package/dist/bundle/{chunk-OW3COBN5.js → chunk-U4RRZUNP.js} +9 -9
  52. package/dist/bundle/{chunk-WKOY3POD.js → chunk-UK3GAN7Q.js} +7 -7
  53. package/dist/bundle/{chunk-BL36RR34.js → chunk-UR6ASUSG.js} +10 -7
  54. package/dist/bundle/{chunk-4VBDVZNE.js → chunk-V52SBQYF.js} +242 -19
  55. package/dist/bundle/{chunk-4YCLWWZ3.js → chunk-VUJ34PEQ.js} +11 -11
  56. package/dist/bundle/{chunk-2XUGPE5W.js → chunk-W5EB4JLV.js} +3 -3
  57. package/dist/bundle/{chunk-3KHKYYCR.js → chunk-WMOEOVWZ.js} +1 -0
  58. package/dist/bundle/{chunk-UMLPXNJI.js → chunk-WVEHUKCZ.js} +1 -1
  59. package/dist/bundle/{chunk-SYPL4PHV.js → chunk-XXTJUZMB.js} +1 -1
  60. package/dist/bundle/{chunk-SMJTL5U7.js → chunk-Y4XSWI22.js} +6 -4
  61. package/dist/bundle/{chunk-HKT5EOT5.js → chunk-YHB57PFN.js} +1 -1
  62. package/dist/bundle/{chunk-BZANDKWT.js → chunk-ZJVZXJOG.js} +2 -2
  63. package/dist/bundle/{chunk-QY3YOOTP.js → chunk-ZRNRQFTF.js} +2 -2
  64. package/dist/bundle/command-contract-A6VZN3ZR.js +31 -0
  65. package/dist/bundle/{echarts-YHSYUWLY.js → echarts-27W2CIBD.js} +2 -2
  66. package/dist/bundle/{embed-3HGI2XIW.js → embed-FGJ273X2.js} +4 -4
  67. package/dist/bundle/{embedder-2CJMZETJ.js → embedder-7ELL3CQ3.js} +7 -7
  68. package/dist/bundle/{entry-UVE53OV3.js → entry-SEE5YWIX.js} +5 -5
  69. package/dist/bundle/{first-run-6GYC2QS3.js → first-run-BD7FEC3W.js} +9 -9
  70. package/dist/bundle/first-screen-ASZV6LSA.js +29 -0
  71. package/dist/bundle/{identity-HEV5E57G.js → identity-QR4F42T6.js} +3 -3
  72. package/dist/bundle/{instructions-5UVAXSQV.js → instructions-L74K64PV.js} +1 -1
  73. package/dist/bundle/{mcp-NWXBVNUA.js → mcp-4Y37G2UY.js} +2 -2
  74. package/dist/bundle/{node-YHYEGYVE.js → node-RSL3HANO.js} +2 -2
  75. package/dist/bundle/{node-sqlite-CQ33A3R2.js → node-sqlite-7R3PYQGJ.js} +4 -4
  76. package/dist/bundle/{oauth-OB3JFAD7.js → oauth-4ESGXF6U.js} +7 -7
  77. package/dist/bundle/{open-JHGZIXU2.js → open-DFYEUGTA.js} +3 -3
  78. package/dist/bundle/{process-PSKS3N5B.js → process-RMV3AKLB.js} +1 -1
  79. package/dist/bundle/{program-RPYVPNRX.js → program-PIUYQHBF.js} +62 -67
  80. package/dist/bundle/{prompt-7BXUMJGG.js → prompt-H7GYQQLL.js} +4 -4
  81. package/dist/bundle/{proxy-transport-3EEMW2HW.js → proxy-transport-G4MA6BGU.js} +4 -4
  82. package/dist/bundle/{recognize-YMZPL47R.js → recognize-3GMOLZF4.js} +5 -5
  83. package/dist/bundle/{remote-LQ3Q22NG.js → remote-IRWTCI2B.js} +5 -5
  84. package/dist/bundle/{rerank-SM7IYVXJ.js → rerank-W3OSXXBN.js} +5 -5
  85. package/dist/bundle/{serve-GHUEP5H5.js → serve-ZCPO44NO.js} +24 -9
  86. package/dist/bundle/{server-A45HVXQY.js → server-FXU4QFRB.js} +42 -39
  87. package/dist/bundle/{server-K2BQPPHN.js → server-YWL4HDOP.js} +77 -68
  88. package/dist/bundle/{state-WIOL52GZ.js → state-MJPTDIB5.js} +9 -5
  89. package/dist/bundle/{store-XE5AKUJZ.js → store-6VNQG56O.js} +10 -10
  90. package/dist/bundle/store-maintenance-command-62TQTMER.js +43 -0
  91. package/dist/bundle/tg.js +4 -4
  92. package/dist/commands/context.d.ts.map +1 -1
  93. package/dist/commands/context.js +2 -0
  94. package/dist/commands/context.js.map +1 -1
  95. package/dist/program.js +1 -1
  96. package/dist/program.js.map +1 -1
  97. package/dist/telegram/errors.js +1 -1
  98. package/dist/telegram/errors.js.map +1 -1
  99. package/dist/telegram/sending.d.ts.map +1 -1
  100. package/dist/telegram/sending.js +52 -3
  101. package/dist/telegram/sending.js.map +1 -1
  102. package/dist/version.d.ts +1 -1
  103. package/dist/version.js +1 -1
  104. package/install/windows.ps1 +1 -1
  105. package/package.json +3 -3
  106. package/skills/tg-cli/SKILL.md +4 -4
  107. package/dist/bundle/chunk-3N6LXAPE.js +0 -724
  108. package/dist/bundle/chunk-DVOUKGFK.js +0 -1950
  109. package/dist/bundle/chunk-MUEXF4ME.js +0 -582
  110. package/dist/bundle/chunk-U7LXA4SO.js +0 -1007
  111. package/dist/bundle/chunk-V4JSVH4M.js +0 -190
  112. package/dist/bundle/chunk-YG7PNCSW.js +0 -230
  113. package/dist/bundle/chunk-Z2FHEIXN.js +0 -63
  114. package/dist/bundle/command-contract-AIVKJYIR.js +0 -31
  115. package/dist/bundle/first-screen-HRRLVLOG.js +0 -29
  116. package/dist/bundle/store-maintenance-command-YS5E7VUN.js +0 -46
  117. /package/dist/bundle/{chunk-3MVHRZWR.js → chunk-2SJOUK6J.js} +0 -0
@@ -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-U7LXA4SO.js";
31
3
  import {
32
4
  count,
33
5
  id,
34
6
  text,
35
7
  time
36
- } from "./chunk-SMJTL5U7.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-SGJYU3SB.js";
22
+ } from "./chunk-OHBHHBYL.js";
40
23
  import {
41
24
  envName,
42
25
  readOnlyLockOf,
43
26
  readOnlyRefusal
44
- } from "./chunk-ASDZHG5I.js";
27
+ } from "./chunk-2SUTCDGO.js";
45
28
  import {
46
29
  FIELD_TYPES,
47
30
  QUERY_BACKENDS,
@@ -50,22 +33,26 @@ import {
50
33
  TASK_STATES,
51
34
  TASK_TYPES,
52
35
  describeQuery
53
- } from "./chunk-KE6L2UEG.js";
36
+ } from "./chunk-QEPZUFPL.js";
54
37
  import {
55
38
  sharedConfigPath
56
- } from "./chunk-UD4DOZCN.js";
39
+ } from "./chunk-F2TG3BA2.js";
57
40
  import {
58
41
  storePath
59
- } from "./chunk-QY3YOOTP.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
- } from "./chunk-GYEOQS2D.js";
55
+ } from "./chunk-DG62L57H.js";
69
56
  import {
70
57
  CliError,
71
58
  MAX_NEXT_STEPS,
@@ -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,16 +89,17 @@ import {
103
89
  stepOf,
104
90
  strictObject,
105
91
  string,
92
+ traceIdOf,
106
93
  trim,
107
94
  union,
108
95
  unknown,
109
96
  writes
110
- } from "./chunk-WE3LBRMB.js";
97
+ } from "./chunk-OEJ5DMCX.js";
111
98
  import {
112
99
  __name
113
100
  } from "./chunk-AFV74GK3.js";
114
101
 
115
- // node_modules/.pnpm/@wirecat+cli-base@0.63.0_commander@15.0.0_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/commands/registry.js
102
+ // node_modules/.pnpm/@wirecat+cli-base@0.64.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/commands/registry.js
116
103
  var labels = /* @__PURE__ */ new WeakMap();
117
104
  var annotate = /* @__PURE__ */ __name((command, meta) => {
118
105
  labels.set(command, { ...labels.get(command), ...meta });
@@ -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);
@@ -3613,7 +3600,7 @@ __name(useColor, "useColor");
3613
3600
  // node_modules/.pnpm/commander@15.0.0/node_modules/commander/index.js
3614
3601
  var program = new Command();
3615
3602
 
3616
- // node_modules/.pnpm/@wirecat+cli-base@0.63.0_commander@15.0.0_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/commands/contracts.js
3603
+ // node_modules/.pnpm/@wirecat+cli-base@0.64.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/commands/contracts.js
3617
3604
  import { isDeepStrictEqual } from "node:util";
3618
3605
  var protectedCommands = /* @__PURE__ */ new WeakMap();
3619
3606
  var hasSharedContract = /* @__PURE__ */ __name((command) => protectedCommands.has(command), "hasSharedContract");
@@ -3815,7 +3802,7 @@ var customizeSharedCommand = /* @__PURE__ */ __name((reference2, reason, build,
3815
3802
  return command;
3816
3803
  }, "customizeSharedCommand");
3817
3804
 
3818
- // node_modules/.pnpm/@wirecat+cli-base@0.63.0_commander@15.0.0_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/commands/document.js
3805
+ // node_modules/.pnpm/@wirecat+cli-base@0.64.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/commands/document.js
3819
3806
  var argumentInfoSchema = object({
3820
3807
  name: string(),
3821
3808
  required: boolean(),
@@ -3888,7 +3875,7 @@ var commandsDocumentSchema = strictObject({
3888
3875
  exit_codes: record(string(), pipe(number(), integer()))
3889
3876
  });
3890
3877
 
3891
- // node_modules/.pnpm/@wirecat+cli-base@0.63.0_commander@15.0.0_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/commands/index.js
3878
+ // node_modules/.pnpm/@wirecat+cli-base@0.64.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/commands/index.js
3892
3879
  var refuseJoinedPath = /* @__PURE__ */ __name((root, args, prefix = []) => {
3893
3880
  let command = root;
3894
3881
  const path2 = [];
@@ -3906,8 +3893,143 @@ var refuseJoinedPath = /* @__PURE__ */ __name((root, args, prefix = []) => {
3906
3893
  }
3907
3894
  }, "refuseJoinedPath");
3908
3895
 
3909
- // node_modules/.pnpm/@wirecat+cli-core@0.452.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.63.0_commander@15._e609b9d6c8060966368a91e843fe8bd2/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;
4031
+ var DEFAULT_COOPERATIVE_MS = 5 * 6e4;
4032
+ var DEFAULT_AGENT_COOPERATIVE_MS = 45e3;
3911
4033
  var DEFAULT_OUTPUT_BYTES = 4 * 1024 * 1024;
3912
4034
  var byteCount = /* @__PURE__ */ __name((value, option, zero = false) => {
3913
4035
  const result = Number(value);
@@ -3921,7 +4043,7 @@ var execution = /* @__PURE__ */ __name((streams, { timeoutMs, fields, maxOutputB
3921
4043
  const closeables = /* @__PURE__ */ new Set();
3922
4044
  const closing = /* @__PURE__ */ new WeakMap();
3923
4045
  const originals = /* @__PURE__ */ new Map();
3924
- let paths = fields === void 0 ? void 0 : fieldsOf(fields);
4046
+ let paths = fields === void 0 ? void 0 : fieldsOf2(fields);
3925
4047
  let active = true;
3926
4048
  let bytes = 0;
3927
4049
  let timer;
@@ -3962,7 +4084,7 @@ var execution = /* @__PURE__ */ __name((streams, { timeoutMs, fields, maxOutputB
3962
4084
  start(timeoutMs);
3963
4085
  return {
3964
4086
  configure: /* @__PURE__ */ __name((options) => {
3965
- paths = options.fields === void 0 ? void 0 : fieldsOf(options.fields);
4087
+ paths = options.fields === void 0 ? void 0 : fieldsOf2(options.fields);
3966
4088
  maxOutputBytes = options.maxOutputBytes;
3967
4089
  }, "configure"),
3968
4090
  start,
@@ -3992,7 +4114,7 @@ var execution = /* @__PURE__ */ __name((streams, { timeoutMs, fields, maxOutputB
3992
4114
  let result = text2;
3993
4115
  if (paths) {
3994
4116
  try {
3995
- result = JSON.stringify(projectFields(JSON.parse(text2), paths));
4117
+ result = JSON.stringify(projectFields2(JSON.parse(text2), paths));
3996
4118
  } catch (error) {
3997
4119
  if (error instanceof CliError)
3998
4120
  throw error;
@@ -4002,8 +4124,8 @@ var execution = /* @__PURE__ */ __name((streams, { timeoutMs, fields, maxOutputB
4002
4124
  });
4003
4125
  }
4004
4126
  }
4005
- const size2 = Buffer.byteLength(result) + 1;
4006
- if (maxOutputBytes !== 0 && bytes + size2 > maxOutputBytes)
4127
+ const size = Buffer.byteLength(result) + 1;
4128
+ if (maxOutputBytes !== 0 && bytes + size > maxOutputBytes)
4007
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`, {
4008
4130
  retryable: false,
4009
4131
  reason: "output.too-large",
@@ -4011,7 +4133,7 @@ var execution = /* @__PURE__ */ __name((streams, { timeoutMs, fields, maxOutputB
4011
4133
  emitted_bytes: bytes,
4012
4134
  partial_output: bytes > 0
4013
4135
  });
4014
- bytes += size2;
4136
+ bytes += size;
4015
4137
  streams.data(result);
4016
4138
  }, "data"),
4017
4139
  diagnostic: /* @__PURE__ */ __name((text2) => {
@@ -4085,7 +4207,396 @@ var withAbort = /* @__PURE__ */ __name(async (signal, body) => {
4085
4207
  }
4086
4208
  }, "withAbort");
4087
4209
 
4088
- // node_modules/.pnpm/@wirecat+cli-core@0.452.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.63.0_commander@15._e609b9d6c8060966368a91e843fe8bd2/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
4089
4600
  import { existsSync, readdirSync, readFileSync } from "node:fs";
4090
4601
  import { join } from "node:path";
4091
4602
  var accountFileFor = /* @__PURE__ */ __name((app, profile, env) => join(resolvePaths({ appName: app.appName, prefix: app.envPrefix, env }).state, "accounts", `${profile}.json`), "accountFileFor");
@@ -4107,249 +4618,85 @@ var profilesWithAccounts = /* @__PURE__ */ __name((app, env) => {
4107
4618
  }, "profilesWithAccounts");
4108
4619
  var profilesHere = /* @__PURE__ */ __name((app, configured, env) => [.../* @__PURE__ */ new Set([...configured, ...profilesWithAccounts(app, env)])].sort(), "profilesHere");
4109
4620
 
4110
- // node_modules/.pnpm/@wirecat+cli-core@0.452.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.63.0_commander@15._e609b9d6c8060966368a91e843fe8bd2/node_modules/@wirecat/cli-core/dist/errors/failures.js
4111
- var isCliFailure = /* @__PURE__ */ __name((value) => value instanceof Error && value.name === "CliError" && errorCodes.includes(value.code), "isCliFailure");
4112
- var isCommanderFailure = /* @__PURE__ */ __name((value) => {
4113
- const { code, exitCode } = value ?? {};
4114
- return value instanceof Error && typeof code === "string" && code.startsWith("commander.") && typeof exitCode === "number";
4115
- }, "isCommanderFailure");
4116
- var failureKey = /* @__PURE__ */ __name((error) => isCliFailure(error) ? error.code : error instanceof Error ? error.name : "error", "failureKey");
4117
-
4118
- // node_modules/.pnpm/@wirecat+cli-core@0.452.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.63.0_commander@15._e609b9d6c8060966368a91e843fe8bd2/node_modules/@wirecat/cli-core/dist/runs/error-detail.js
4119
- import { homedir } from "node:os";
4120
-
4121
- // node_modules/.pnpm/@wirecat+cli-core@0.452.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.63.0_commander@15._e609b9d6c8060966368a91e843fe8bd2/node_modules/@wirecat/cli-core/dist/runs/events.js
4122
- var providerErrorKey = /* @__PURE__ */ __name((value) => typeof value === "string" && /^[A-Za-z][A-Za-z0-9._-]{0,63}$/.test(value) ? value : void 0, "providerErrorKey");
4123
- var renderEvent = /* @__PURE__ */ __name((event) => {
4124
- if (event.event === "warning") {
4125
- const counts = Object.entries(event.counts ?? {}).map(([field, count3]) => `${count3} ${field}`);
4126
- return [`${MARK.warning} ${(event.operation ?? "").padEnd(16)} ${event.code}`, ...counts, event.detail].filter(Boolean).join(" ");
4127
- }
4128
- const parts = [];
4129
- if (event.event === "cache") {
4130
- parts.push(event.reason);
4131
- if (event.ageMs !== void 0)
4132
- parts.push(`cached ${age(event.ageMs)}`);
4133
- } else {
4134
- if (event.opcode !== void 0)
4135
- parts.push(`op ${event.opcode}`, `seq ${event.seq}`);
4136
- if (event.method !== void 0 || event.endpointTemplate !== void 0)
4137
- parts.push([event.method, event.endpointTemplate].filter(Boolean).join(" "));
4138
- if (event.status !== void 0)
4139
- parts.push(`${event.status}`);
4140
- }
4141
- if (event.ids)
4142
- for (const [name, value] of Object.entries(event.ids))
4143
- parts.push(`${name} ${value}`);
4144
- if (event.event !== "cache") {
4145
- if (event.durationMs !== void 0)
4146
- parts.push(`${event.durationMs}ms`);
4147
- if (event.bytes !== void 0)
4148
- parts.push(size(event.bytes));
4149
- }
4150
- if (event.counts)
4151
- for (const [field, count3] of Object.entries(event.counts))
4152
- parts.push(`${count3} ${field}`);
4153
- if (event.event !== "cache") {
4154
- if (event.errorCode)
4155
- parts.push(event.errorCode);
4156
- if (event.providerError)
4157
- parts.push(event.providerError);
4158
- }
4159
- return `${MARK[event.event]} ${event.operation.padEnd(16)} ${parts.join(" ")}`.trimEnd();
4160
- }, "renderEvent");
4161
- var MARK = { request: "\u2192", response: "\u2190", cache: "\u2022", warning: "!" };
4162
- var age = /* @__PURE__ */ __name((ms) => ms < 1e3 ? `${ms}ms` : `${Math.round(ms / 1e3)}s`, "age");
4163
- var size = /* @__PURE__ */ __name((bytes) => bytes < 1e3 ? `${bytes} B` : `${(bytes / 1e3).toFixed(1)} kB`, "size");
4164
-
4165
- // node_modules/.pnpm/@wirecat+cli-core@0.452.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.63.0_commander@15._e609b9d6c8060966368a91e843fe8bd2/node_modules/@wirecat/cli-core/dist/runs/secrets.js
4166
- var SECRET_WORDS = /* @__PURE__ */ new Set([
4167
- "authorization",
4168
- "cookie",
4169
- "credential",
4170
- "credentials",
4171
- "passphrase",
4172
- "password",
4173
- "passwd",
4174
- "pwd",
4175
- "pass",
4176
- "passcode",
4177
- "pin",
4178
- "otp",
4179
- "2fa",
4180
- "secret",
4181
- "token",
4182
- "contrase\xF1a",
4183
- "contrasena",
4184
- "clave",
4185
- "\u043F\u0430\u0440\u043E\u043B\u044C",
4186
- "\u043F\u0438\u043D",
4187
- "\u043A\u043E\u0434",
4188
- ...["api", "auth", "service", "account", "db", "database", "priv", "private", "client"].map((word) => `${word}key`),
4189
- ...["db", "database", "key"].map((word) => `${word}pass`)
4190
- ]);
4191
- var secretNamed = /* @__PURE__ */ __name((name) => {
4192
- const words = name.replace(/([a-z0-9])([A-Z])/g, "$1 $2").split(/[\s_.-]+/).map((word) => word.toLowerCase());
4193
- return words.some((word, at) => SECRET_WORDS.has(word) || SECRET_WORDS.has(word + (words[at + 1] ?? "")));
4194
- }, "secretNamed");
4195
- var START = "(?<![A-Za-z0-9_-])";
4196
- var END = "(?![A-Za-z0-9_-])";
4197
- var KNOWN_TOKENS = new RegExp(`${[
4198
- "gh[pousr]_[A-Za-z0-9]{36,}",
4199
- "github_pat_[A-Za-z0-9_]{22,}",
4200
- "sk-[A-Za-z0-9_-]{20,}",
4201
- "xox[abprs]-[A-Za-z0-9-]{10,}",
4202
- "(?:AKIA|ASIA)[A-Z0-9]{16}",
4203
- "AIza[A-Za-z0-9_-]{35}",
4204
- "(?:sk|rk)_(?:live|test)_[A-Za-z0-9]{10,}",
4205
- "npm_[A-Za-z0-9]{36}",
4206
- "eyJ[A-Za-z0-9_-]{5,}\\.eyJ[A-Za-z0-9_-]{5,}\\.[A-Za-z0-9_-]*"
4207
- ].map((pattern) => `${START}${pattern}${END}`).join("|")}|(?<!\\d)\\d{8,10}:[A-Za-z0-9_-]{35}${END}`, "g");
4208
- var PRIVATE_KEY = /-----BEGIN[A-Z ]* PRIVATE KEY-----[\s\S]*?(?:-----END[A-Z ]* PRIVATE KEY-----|$)/g;
4209
- var SCHEME = /(?<![A-Za-z])(Bearer|Basic)(\s+)(?![A-Z]?[a-z]+(?![A-Za-z0-9]))[A-Za-z0-9._~+/=-]{8,}/g;
4210
- 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;
4211
- var looksRandom = /* @__PURE__ */ __name((run) => {
4212
- if (run.length < 20)
4213
- return false;
4214
- const classes = [/[a-z]/, /[A-Z]/, /\d/, /[^A-Za-z0-9]/].filter((kind) => kind.test(run)).length;
4215
- if (classes < 3)
4216
- return false;
4217
- let switches = 0;
4218
- for (let at = 1; at < run.length; at++) {
4219
- const [before, after] = [run[at - 1], run[at]];
4220
- if (/[a-z]/.test(before) && /[A-Z]/.test(after) || /[A-Z]/.test(before) && /[a-z]/.test(after))
4221
- switches += 1;
4222
- }
4223
- if (switches / run.length < 0.15)
4224
- return false;
4225
- const pieces = run.match(/[A-Z]?[a-z]+|[A-Z]+(?![a-z])|\d+/g) ?? [];
4226
- if (pieces.join("").length / Math.max(pieces.length, 1) >= 2.75)
4227
- return false;
4228
- return entropy(run) >= 3.5;
4229
- }, "looksRandom");
4230
- var entropy = /* @__PURE__ */ __name((text2) => {
4231
- const counts = /* @__PURE__ */ new Map();
4232
- for (const char of text2)
4233
- counts.set(char, (counts.get(char) ?? 0) + 1);
4234
- let bits = 0;
4235
- for (const count3 of counts.values())
4236
- bits -= count3 / text2.length * Math.log2(count3 / text2.length);
4237
- return bits;
4238
- }, "entropy");
4239
- 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) => (
4240
- // A URL or a path is somebody's address, not a key; a credential in one is caught by the rules above.
4241
- token.includes("://") || /^(?:\/|~\/|\.\.?\/)/.test(token) ? token : token.replace(RUN, (run) => looksRandom(run) ? mark : run.replace(HEX, (hex) => entropy(hex) >= 3 ? mark : hex))
4242
- )), "withoutSecrets");
4243
- var RUN = /(?<![A-Za-z0-9_+/-])[A-Za-z0-9_+/-]{20,}/g;
4244
- var HEX = /(?<![A-Za-z0-9])(?=[0-9]*[a-f])[0-9a-f]{20,}(?![A-Za-z0-9])/g;
4245
-
4246
- // node_modules/.pnpm/@wirecat+cli-core@0.452.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.63.0_commander@15._e609b9d6c8060966368a91e843fe8bd2/node_modules/@wirecat/cli-core/dist/runs/error-detail.js
4247
- var MESSAGE_AT_MOST = 500;
4248
- var CAUSES_AT_MOST = 5;
4249
- var FRAMES_AT_MOST = 15;
4250
- var errorDetailOf = /* @__PURE__ */ __name((error, response) => {
4251
- const details = isCliFailure(error) ? { ...error.details } : {};
4252
- const thrown = error instanceof Error ? error : void 0;
4253
- const code = isCliFailure(error) ? error.code : codeOf(error);
4254
- const reason = typeof details.reason === "string" ? details.reason : void 0;
4255
- const message = thrown ? redactText(thrown.message) : void 0;
4256
- const operation = stringOf(details.operation) ?? response?.operation;
4257
- const status = numberOf(details.status) ?? response?.status;
4258
- const method = stringOf(details.method) ?? response?.method;
4259
- const endpoint2 = stringOf(details.endpoint) ?? response?.endpointTemplate;
4260
- const key = providerErrorKey(details.provider_error) ?? providerErrorKey(response?.providerError);
4261
- const protocol = key !== void 0 && method === void 0 && endpoint2 === void 0;
4262
- const http = method !== void 0 || endpoint2 !== void 0 || status !== void 0 && !protocol ? {
4263
- ...method === void 0 ? {} : { method: method.toUpperCase().slice(0, 16) },
4264
- ...endpoint2 === void 0 ? {} : { endpoint_template: endpointTemplate(endpoint2) },
4265
- ...status === void 0 ? {} : { status }
4266
- } : void 0;
4267
- const causes = causesOf(thrown?.cause ?? details.cause);
4268
- 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;
4269
4633
  return {
4270
- class: classOf(error),
4271
- ...code === void 0 ? {} : { code },
4272
- ...reason === void 0 ? {} : { reason },
4273
- ...message ? { message } : {},
4274
- ...operation === void 0 ? {} : { operation },
4275
- ...http ? { http } : {},
4276
- ...key === void 0 ? {} : { provider: { key, ...protocol && status !== void 0 ? { code: status } : {} } },
4277
- ...causes.length > 0 ? { causes } : {},
4278
- ...stack.length > 0 ? { stack } : {}
4634
+ ...rest,
4635
+ ...typeof rest.excerpt === "string" ? {} : { text: text2 },
4636
+ ...metadata === void 0 ? {} : { providerMetadata: metadata }
4279
4637
  };
4280
- }, "errorDetailOf");
4281
- var stringOf = /* @__PURE__ */ __name((value) => typeof value === "string" && value.trim() !== "" ? value.trim() : void 0, "stringOf");
4282
- var numberOf = /* @__PURE__ */ __name((value) => typeof value === "number" && Number.isInteger(value) ? value : void 0, "numberOf");
4283
- var classOf = /* @__PURE__ */ __name((error) => {
4284
- if (!(error instanceof Error))
4285
- return error === null ? "null" : typeof error;
4286
- const constructed = error.constructor?.name;
4287
- return constructed && constructed !== "Error" && constructed !== error.name ? constructed : error.name;
4288
- }, "classOf");
4289
- var codeOf = /* @__PURE__ */ __name((error) => {
4290
- const code = error?.code;
4291
- return typeof code === "string" && /^[A-Za-z][A-Za-z0-9._-]{0,63}$/.test(code) ? code : void 0;
4292
- }, "codeOf");
4293
- var causesOf = /* @__PURE__ */ __name((first2) => {
4294
- const causes = [];
4295
- const seen = /* @__PURE__ */ new Set();
4296
- for (let cause = first2; cause !== void 0 && cause !== null && causes.length < CAUSES_AT_MOST; ) {
4297
- if (seen.has(cause))
4298
- break;
4299
- seen.add(cause);
4300
- const message = cause instanceof Error ? redactText(cause.message) : void 0;
4301
- causes.push({ class: classOf(cause), ...message ? { message } : {} });
4302
- cause = cause instanceof Error ? cause.cause : void 0;
4303
- }
4304
- return causes;
4305
- }, "causesOf");
4306
- var framesOf = /* @__PURE__ */ __name((error, limit = FRAMES_AT_MOST) => {
4307
- const stack = error instanceof Error && typeof error.stack === "string" ? error.stack : "";
4308
- return stack.split("\n").filter((line) => line.trimStart().startsWith("at ")).flatMap((line) => {
4309
- const match = /^\s*at (?:async )?(?:(.+?) \()?(.+?):(\d+):\d+\)?$/.exec(line);
4310
- if (!match)
4311
- return [];
4312
- const [, fn, path2 = "", lineNumber] = match;
4313
- if (path2.startsWith("node:"))
4314
- return [];
4315
- return [`${fn ?? "<anonymous>"} ${fileOf(path2)}:${lineNumber}`];
4316
- }).slice(0, limit);
4317
- }, "framesOf");
4318
- var fileOf = /* @__PURE__ */ __name((path2) => {
4319
- const plain2 = path2.replace(/^file:\/\//, "");
4320
- const packaged = /\/node_modules\/((?:@[^/]+\/)?[^/]+\/.+)$/.exec(plain2)?.[1];
4321
- if (packaged)
4322
- return packaged.replace(/\/(?:dist|src)\//, "/");
4323
- return /(?:^|\/)(?:dist|src)\/(.+)$/.exec(plain2)?.[1] ?? plain2.split("/").at(-1) ?? "?";
4324
- }, "fileOf");
4325
- var endpointTemplate = /* @__PURE__ */ __name((raw) => {
4326
- const trimmed = raw.trim().split(/[?#]/)[0] ?? "";
4327
- const origin = /^[a-z][a-z0-9+.-]*:\/\/(?:[^@/]*@)?([^/]*)/i.exec(trimmed);
4328
- const path2 = origin ? trimmed.slice(origin[0].length) : trimmed;
4329
- const scheme = origin ? `${trimmed.slice(0, trimmed.indexOf("://"))}://${origin[1]}` : "";
4330
- const segments = path2.split("/").map((segment) => {
4331
- if (segment === "" || /^[:{].+/.test(segment))
4332
- return segment;
4333
- if (/^bot\d+:/.test(segment) || /^\d{6,}:[\w-]{20,}$/.test(segment))
4334
- return ":token";
4335
- if (/^-?\d+$/.test(segment) || /^[0-9a-f-]{16,}$/i.test(segment))
4336
- return ":id";
4337
- if (!/^[A-Za-z0-9._~-]{1,40}$/.test(segment))
4338
- return ":value";
4339
- return segment;
4340
- });
4341
- return `${scheme}${segments.join("/")}`.slice(0, 300);
4342
- }, "endpointTemplate");
4343
- var INTERNATIONAL_PHONE = /\+\d[\d\s()-]{6,}\d/.source;
4344
- var BARE_PHONE = /(^|[^\w-])\d{11,15}\b/.source;
4345
- var redactText = /* @__PURE__ */ __name((text2) => {
4346
- const home = homedir();
4347
- let out = home && home !== "/" ? text2.split(home).join("~") : text2;
4348
- 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]");
4349
- return out.length > MESSAGE_AT_MOST ? `${out.slice(0, MESSAGE_AT_MOST)}\u2026` : out;
4350
- }, "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");
4351
4698
 
4352
- // node_modules/.pnpm/@wirecat+cli-core@0.452.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.63.0_commander@15._e609b9d6c8060966368a91e843fe8bd2/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
4353
4700
  var CORE_LOG_EVENTS = defineLogEvents([
4354
4701
  { id: "provider.request", meaning: "a request went to the messenger", keys: ["operation"] },
4355
4702
  { id: "provider.response", meaning: "the messenger answered the request, or it failed", keys: ["operation"] },
@@ -4360,6 +4707,11 @@ var CORE_LOG_EVENTS = defineLogEvents([
4360
4707
  keys: ["operation", "reason"]
4361
4708
  },
4362
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
+ },
4363
4715
  { id: "send.recorded", meaning: "a write the send guard saw, and how it ended", keys: ["outcome"] },
4364
4716
  { id: "job.start", meaning: "a background job started", keys: ["job"] },
4365
4717
  { id: "job.exit", meaning: "a background job ended", keys: ["job", "outcome"] },
@@ -4378,7 +4730,487 @@ var DIAGNOSTIC_LOG_EVENTS = {
4378
4730
  cache: "cache.answered"
4379
4731
  };
4380
4732
 
4381
- // node_modules/.pnpm/@wirecat+cli-core@0.452.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.63.0_commander@15._e609b9d6c8060966368a91e843fe8bd2/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
4382
5214
  var recorded = /* @__PURE__ */ __name(async (options, body) => {
4383
5215
  const recording = startRecording(options);
4384
5216
  try {
@@ -4387,7 +5219,8 @@ var recorded = /* @__PURE__ */ __name(async (options, body) => {
4387
5219
  command: options.command,
4388
5220
  startedAt: Date.now(),
4389
5221
  ...options.profile === void 0 ? {} : { profile: options.profile },
4390
- ...recording.traceId ? { traceId: recording.traceId } : {}
5222
+ ...recording.traceId ? { traceId: recording.traceId } : {},
5223
+ events: recording.events
4391
5224
  };
4392
5225
  if (options.processRun)
4393
5226
  useAsProcessRun(scope);
@@ -4405,6 +5238,7 @@ var startRecording = /* @__PURE__ */ __name((options) => {
4405
5238
  const startedAt = now();
4406
5239
  const runId = newRunId(startedAt, options.command);
4407
5240
  const traceId = options.traceId ?? enclosingTraceId() ?? traceOf(options.env ?? process.env).traceId;
5241
+ const { argvIfFailed, ...context } = options.context ?? {};
4408
5242
  const open = /* @__PURE__ */ __name((extra = {}) => startRun({
4409
5243
  runsDir: options.runsDir ?? runsDirFor(options.app, options.env),
4410
5244
  runId,
@@ -4413,7 +5247,7 @@ var startRecording = /* @__PURE__ */ __name((options) => {
4413
5247
  service: options.app.command,
4414
5248
  cliVersion: options.app.version,
4415
5249
  ...traceId === void 0 ? {} : { traceId },
4416
- ...options.context ? { context: options.context } : {},
5250
+ ...options.context ? { context } : {},
4417
5251
  // The operation has happened or is under way, and failing the command now invites a retry
4418
5252
  // that sends twice.
4419
5253
  onError: /* @__PURE__ */ __name((error) => {
@@ -4421,46 +5255,64 @@ var startRecording = /* @__PURE__ */ __name((options) => {
4421
5255
  streams.diagnostic(options.format === "pretty" ? warning : JSON.stringify({ warning }));
4422
5256
  }, "onError"),
4423
5257
  ...options.keepDays === void 0 ? {} : { keepDays: options.keepDays },
5258
+ ...options.keepSuccessDays === void 0 ? {} : { keepSuccessDays: options.keepSuccessDays },
5259
+ ...options.maxBytes === void 0 ? {} : { maxBytes: options.maxBytes },
4424
5260
  now,
4425
5261
  ...extra
4426
5262
  }), "open");
4427
- const run = options.record ? open({ startedAt }) : void 0;
5263
+ const run = options.record ? open({ startedAt, lazy: true }) : void 0;
4428
5264
  const held = !run && options.keepFailed ? [] : void 0;
4429
- let requests = 0;
5265
+ const counted = { wire: 0, operation: 0 };
4430
5266
  let refused;
5267
+ const cap = capped();
5268
+ const requests = /* @__PURE__ */ __name(() => counted.wire > 0 ? counted.wire : counted.operation, "requests");
4431
5269
  const events = /* @__PURE__ */ __name((event) => {
4432
5270
  if (event.event === "request")
4433
- requests += 1;
5271
+ counted[event.level === "wire" ? "wire" : "operation"] += 1;
4434
5272
  if (event.event === "response" && event.outcome === "error")
4435
5273
  refused = event;
4436
5274
  if (options.trace)
4437
5275
  streams.diagnostic(options.format === "pretty" ? renderEvent(event) : JSON.stringify(logAttributes(event)));
4438
5276
  if (run)
4439
- logEvent(run, event);
5277
+ cap.log(run, event);
4440
5278
  if (held) {
4441
5279
  held.push(event);
4442
5280
  if (held.length > HELD_AT_MOST)
4443
5281
  held.shift();
4444
5282
  }
4445
5283
  }, "events");
5284
+ const keep = /* @__PURE__ */ __name((kept) => {
5285
+ for (const event of held ?? [])
5286
+ cap.log(kept, event);
5287
+ return kept;
5288
+ }, "keep");
4446
5289
  return {
4447
5290
  runId,
4448
5291
  ...traceId === void 0 ? {} : { traceId },
4449
5292
  events,
4450
5293
  succeed: /* @__PURE__ */ __name(async (answer) => {
4451
5294
  const partial = partialOutcome(answer);
4452
- const kept = run ?? (partial && held ? keep(open({ startedAt }), held) : void 0);
4453
- 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
+ });
4454
5303
  }, "succeed"),
4455
5304
  fail: /* @__PURE__ */ __name(async (error) => {
4456
- const failed = run ?? (held ? keep(open({ startedAt }), held) : void 0);
5305
+ const failed = run ?? (held ? keep(open({ startedAt })) : void 0);
4457
5306
  if (failed) {
4458
5307
  if (!isCliFailure(error))
4459
5308
  failed.logger.error(crashOf(error));
5309
+ cap.close(failed);
4460
5310
  await failed.finish("failed", {
4461
- requests,
5311
+ requests: requests(),
5312
+ ...cap.dropped(),
4462
5313
  ...outcomeOf(error),
4463
5314
  error: errorDetailOf(error, refused),
5315
+ ...argvIfFailed ? { argv: argvIfFailed } : {},
4464
5316
  ...run ? {} : { keptBecauseFailed: true }
4465
5317
  });
4466
5318
  }
@@ -4472,11 +5324,33 @@ var startRecording = /* @__PURE__ */ __name((options) => {
4472
5324
  var settled = /* @__PURE__ */ new WeakSet();
4473
5325
  var wasSettled = /* @__PURE__ */ __name((error) => typeof error === "object" && error !== null && settled.has(error), "wasSettled");
4474
5326
  var HELD_AT_MOST = 500;
4475
- var keep = /* @__PURE__ */ __name((run, events) => {
4476
- for (const event of events)
4477
- logEvent(run, event);
4478
- return run;
4479
- }, "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");
4480
5354
  var logEvent = /* @__PURE__ */ __name((run, event) => {
4481
5355
  const record2 = {
4482
5356
  ...event,
@@ -4521,151 +5395,7 @@ var partialOutcome = /* @__PURE__ */ __name((answer) => {
4521
5395
  return void 0;
4522
5396
  }, "partialOutcome");
4523
5397
 
4524
- // node_modules/.pnpm/@wirecat+cli-core@0.452.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.63.0_commander@15._e609b9d6c8060966368a91e843fe8bd2/node_modules/@wirecat/cli-core/dist/runs/run-context.js
4525
- var REDACTED = "[redacted]";
4526
- var agentOf = /* @__PURE__ */ __name((env) => {
4527
- const named = env.AI_AGENT?.trim().split("_")[0];
4528
- 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.
4529
- (env.OPENCLAW_SHELL?.trim() === "exec" ? "openclaw" : void 0);
4530
- if (!kind)
4531
- return void 0;
4532
- const session = sessionOf(kind, env);
4533
- return {
4534
- kind,
4535
- session_id: session && SESSION.test(session) ? session : null,
4536
- // OpenClaw passes the sender and chat ids of a chat-started run in this variable; only its presence is kept.
4537
- ...kind === "openclaw" && env.OPENCLAW_CHANNEL_CONTEXT?.trim() ? { from_chat: true } : {}
4538
- };
4539
- }, "agentOf");
4540
- var SESSION = /^[A-Za-z0-9._:-]{1,128}$/;
4541
- var SESSION_VARIABLE = {
4542
- "claude-code": "CLAUDE_CODE_SESSION_ID",
4543
- codex: "CODEX_THREAD_ID",
4544
- opencode: "OPENCODE_SESSION_ID",
4545
- "hermes-agent": "HERMES_SESSION_ID"
4546
- };
4547
- var sessionOf = /* @__PURE__ */ __name((kind, env) => {
4548
- const variable = SESSION_VARIABLE[kind];
4549
- return (variable === void 0 ? void 0 : env[variable]?.trim()) || void 0;
4550
- }, "sessionOf");
4551
- var plainWord = /* @__PURE__ */ __name((word) => /^[A-Za-z][A-Za-z0-9.-]{0,39}$/.test(word), "plainWord");
4552
- var secretInputs = /* @__PURE__ */ new WeakSet();
4553
- var secretInput = /* @__PURE__ */ __name((input) => {
4554
- secretInputs.add(input);
4555
- return input;
4556
- }, "secretInput");
4557
- 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");
4558
- var withoutPhones = /* @__PURE__ */ __name((word) => word.replace(new RegExp(INTERNATIONAL_PHONE, "g"), REDACTED).replace(new RegExp(BARE_PHONE, "g"), `$1${REDACTED}`), "withoutPhones");
4559
- var maskArgv = /* @__PURE__ */ __name((program2, words, { keep: keep2 = false } = {}) => {
4560
- const argv = [];
4561
- let unknownCommand;
4562
- let current = program2;
4563
- let positional = 0;
4564
- let profileSeen = false;
4565
- let lost = false;
4566
- const raw = /* @__PURE__ */ __name((word) => keep2 && !secretShaped(word) ? withoutPhones(withoutSecrets(word, REDACTED)) : REDACTED, "raw");
4567
- const keptValue = /* @__PURE__ */ __name((name, value, input) => keep2 ? input && secretInputs.has(input) || secretNamed(name) ? REDACTED : raw(value) : maskedValue(name, value, input?.argChoices), "keptValue");
4568
- const optionFor = /* @__PURE__ */ __name((flag2) => {
4569
- for (let at = current; at; at = at.parent) {
4570
- const found = at.options.find((option) => option.long === flag2 || option.short === flag2);
4571
- if (found)
4572
- return found;
4573
- }
4574
- return void 0;
4575
- }, "optionFor");
4576
- for (let at = 0; at < words.length; at++) {
4577
- const word = words[at];
4578
- if (word === "--") {
4579
- argv.push("--");
4580
- for (let after = at + 1; after < words.length; after++)
4581
- argv.push(raw(words[after]));
4582
- break;
4583
- }
4584
- if (word.startsWith("-") && word.length > 1 && !NUMBER.test(word)) {
4585
- const equals = word.indexOf("=");
4586
- const flag2 = equals > 0 ? word.slice(0, equals) : word;
4587
- if (!/^--?[A-Za-z0-9][A-Za-z0-9-]*$/.test(flag2)) {
4588
- argv.push(raw(word));
4589
- continue;
4590
- }
4591
- const option = optionFor(flag2);
4592
- const name = option?.attributeName() ?? flag2.replace(/^-+/, "");
4593
- if (equals > 0) {
4594
- argv.push(`${flag2}=${keptValue(name, word.slice(equals + 1), option)}`);
4595
- continue;
4596
- }
4597
- argv.push(flag2);
4598
- if (!option && keep2 && secretNamed(name) && words[at + 1] !== void 0 && !words[at + 1]?.startsWith("-")) {
4599
- at += 1;
4600
- argv.push(REDACTED);
4601
- continue;
4602
- }
4603
- if (!option || !(option.required || option.optional))
4604
- continue;
4605
- const takes = /* @__PURE__ */ __name((next) => next !== void 0 && (option.required || !next.startsWith("-") || NUMBER.test(next)), "takes");
4606
- if (takes(words[at + 1])) {
4607
- at += 1;
4608
- argv.push(keptValue(name, words[at], option));
4609
- while (option.variadic && words[at + 1] !== void 0 && !words[at + 1].startsWith("-")) {
4610
- at += 1;
4611
- argv.push(keptValue(name, words[at], option));
4612
- }
4613
- }
4614
- continue;
4615
- }
4616
- if (!lost && positional === 0) {
4617
- const sub = current.commands.find((one) => one.name() === word || one.aliases().includes(word));
4618
- if (sub) {
4619
- argv.push(word);
4620
- current = sub;
4621
- continue;
4622
- }
4623
- if (current === program2 && !profileSeen) {
4624
- profileSeen = true;
4625
- argv.push(keep2 ? raw(word) : PROFILE.test(word) && withoutPhones(withoutSecrets(word)) === word ? word : REDACTED);
4626
- continue;
4627
- }
4628
- if (current.commands.length > 0 && current.registeredArguments.length === 0) {
4629
- lost = true;
4630
- unknownCommand = commandLike(word);
4631
- argv.push(keep2 ? raw(word) : unknownCommand);
4632
- continue;
4633
- }
4634
- }
4635
- const declared = lost ? void 0 : current.registeredArguments;
4636
- const argument = declared?.[Math.min(positional, declared.length - 1)];
4637
- positional += 1;
4638
- argv.push(secretInputs.has(current) ? REDACTED : argument ? keptValue(argument.name(), word, argument) : raw(word));
4639
- }
4640
- return { argv, ...unknownCommand === void 0 ? {} : { unknownCommand } };
4641
- }, "maskArgv");
4642
- var NUMBER = /^-?\d+(\.\d+)?$/;
4643
- var PROFILE = /^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/;
4644
- var commandLike = /* @__PURE__ */ __name((word) => /^[a-z][a-z0-9-]{0,31}$/i.test(word) && withoutSecrets(word) === word ? word : REDACTED, "commandLike");
4645
- var maskedValue = /* @__PURE__ */ __name((name, value, choices) => {
4646
- if (isContentKey(name))
4647
- return REDACTED;
4648
- if (name === "profile")
4649
- return PROFILE.test(value) ? value : REDACTED;
4650
- if (name === "json" || name === "fields")
4651
- return /^[a-z0-9_.,]{1,200}$/.test(value) ? value : REDACTED;
4652
- if (choices?.includes(value))
4653
- return value;
4654
- return safeShape(value) ? value : REDACTED;
4655
- }, "maskedValue");
4656
- 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");
4657
- var runContextOf = /* @__PURE__ */ __name(({ bin, command, program: program2, argv, env, recordInput = false }) => {
4658
- const masked = program2 && argv ? maskArgv(program2, argv, { keep: recordInput }) : void 0;
4659
- const agent = agentOf(env);
4660
- return {
4661
- cliCommand: command ? `${bin} ${command}` : bin,
4662
- ...masked ? { argv: masked.argv } : {},
4663
- ...masked?.unknownCommand === void 0 ? {} : { unknownCommand: masked.unknownCommand },
4664
- ...agent ? { agent } : {}
4665
- };
4666
- }, "runContextOf");
4667
-
4668
- // node_modules/.pnpm/@wirecat+cli-core@0.452.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.63.0_commander@15._e609b9d6c8060966368a91e843fe8bd2/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
4669
5399
  var withDeadline = /* @__PURE__ */ __name(async (ms, closeables, body) => {
4670
5400
  if (ms === void 0)
4671
5401
  return body();
@@ -4691,7 +5421,7 @@ var withDeadline = /* @__PURE__ */ __name(async (ms, closeables, body) => {
4691
5421
  }
4692
5422
  }, "withDeadline");
4693
5423
 
4694
- // node_modules/.pnpm/@wirecat+cli-core@0.452.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.63.0_commander@15._e609b9d6c8060966368a91e843fe8bd2/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
4695
5425
  var asFirstWord = /* @__PURE__ */ __name((profile) => `${profile} `, "asFirstWord");
4696
5426
  var PLAIN_NAME = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
4697
5427
  var isProfileName = /* @__PURE__ */ __name((word) => PLAIN_NAME.test(word), "isProfileName");
@@ -4756,10 +5486,10 @@ var sampleCommand = /* @__PURE__ */ __name((commands) => {
4756
5486
  return void 0;
4757
5487
  }, "sampleCommand");
4758
5488
 
4759
- // node_modules/.pnpm/@wirecat+cli-core@0.452.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.63.0_commander@15._e609b9d6c8060966368a91e843fe8bd2/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
4760
5490
  import { existsSync as existsSync3 } from "node:fs";
4761
5491
 
4762
- // node_modules/.pnpm/@wirecat+cli-core@0.452.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.63.0_commander@15._e609b9d6c8060966368a91e843fe8bd2/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
4763
5493
  var endpoint = /* @__PURE__ */ __name((value) => {
4764
5494
  try {
4765
5495
  const url2 = new URL(value);
@@ -4769,7 +5499,7 @@ var endpoint = /* @__PURE__ */ __name((value) => {
4769
5499
  }
4770
5500
  }, "endpoint");
4771
5501
 
4772
- // node_modules/.pnpm/@wirecat+cli-core@0.452.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.63.0_commander@15._e609b9d6c8060966368a91e843fe8bd2/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
4773
5503
  var MODEL_FIELDS = ["provider", "model", "base_url"];
4774
5504
  var modelSettingsShape = record(pipe(string(), regex(/^[a-z][a-z0-9-]*$/)), strictObject({
4775
5505
  provider: optional(picklist(["off", "openai", "anthropic"])),
@@ -4838,7 +5568,7 @@ var modelTarget = /* @__PURE__ */ __name((settings, purpose) => {
4838
5568
  };
4839
5569
  }, "modelTarget");
4840
5570
 
4841
- // node_modules/.pnpm/@wirecat+cli-core@0.452.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.63.0_commander@15._e609b9d6c8060966368a91e843fe8bd2/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
4842
5572
  var model = pipe(string(), trim(), minLength(1), maxLength(200));
4843
5573
  var url = pipe(string(), check(endpoint, "use an HTTP/S endpoint without credentials, query or fragment"));
4844
5574
  var AI_FIELDS = {
@@ -4882,7 +5612,7 @@ var resolveAISettings = /* @__PURE__ */ __name((prefix, layers, env) => {
4882
5612
  };
4883
5613
  }, "resolveAISettings");
4884
5614
 
4885
- // node_modules/.pnpm/@wirecat+cli-core@0.452.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.63.0_commander@15._e609b9d6c8060966368a91e843fe8bd2/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
4886
5616
  var DURATION = /^(\d+)(ms|s|m|h|d)$/;
4887
5617
  var UNIT_MS = { ms: 1, s: 1e3, m: 6e4, h: 36e5, d: 864e5 };
4888
5618
  var parseDuration = /* @__PURE__ */ __name((value, source) => {
@@ -4896,7 +5626,7 @@ var parseDuration = /* @__PURE__ */ __name((value, source) => {
4896
5626
  return ms;
4897
5627
  }, "parseDuration");
4898
5628
 
4899
- // node_modules/.pnpm/@wirecat+cli-core@0.452.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.63.0_commander@15._e609b9d6c8060966368a91e843fe8bd2/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
4900
5630
  var huggingFace = /* @__PURE__ */ __name((repository, commit) => (name) => `https://huggingface.co/${repository}/resolve/${commit}/${name}`, "huggingFace");
4901
5631
  var e5 = huggingFace("Xenova/multilingual-e5-small", "761b726dd34fb83930e26aab4e9ac3899aa1fa78");
4902
5632
  var gemma = huggingFace("onnx-community/embeddinggemma-300m-ONNX", "5090578d9565bb06545b4552f76e6bc2c93e4a66");
@@ -5055,8 +5785,8 @@ var rerankModel = /* @__PURE__ */ __name((id2) => {
5055
5785
  var vectorModelKey = /* @__PURE__ */ __name((model2) => `local:${model2.id}:${model2.dims}`, "vectorModelKey");
5056
5786
  var meaningFloor = /* @__PURE__ */ __name((key) => key === "local:e5-small:384" ? 0.8 : 0, "meaningFloor");
5057
5787
 
5058
- // node_modules/.pnpm/@wirecat+cli-core@0.452.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.63.0_commander@15._e609b9d6c8060966368a91e843fe8bd2/node_modules/@wirecat/cli-core/dist/cli/config-issues.js
5059
- 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";
5060
5790
  var isNode = /* @__PURE__ */ __name((value) => typeof value === "object" && value !== null && !Array.isArray(value), "isNode");
5061
5791
  var SECTIONS = ["personal", "bot"];
5062
5792
  var SHELL_SAFE = /^[A-Za-z0-9_.:@-]*$/;
@@ -5163,8 +5893,8 @@ var failureOffset = /* @__PURE__ */ __name((text2) => {
5163
5893
  value();
5164
5894
  space();
5165
5895
  return at;
5166
- } catch (stopped) {
5167
- return typeof stopped === "number" ? stopped : at;
5896
+ } catch (stopped2) {
5897
+ return typeof stopped2 === "number" ? stopped2 : at;
5168
5898
  }
5169
5899
  }, "failureOffset");
5170
5900
  var parseConfigText = /* @__PURE__ */ __name((text2, file) => {
@@ -5235,7 +5965,7 @@ var schemaIssues = /* @__PURE__ */ __name((raw, schema, context) => {
5235
5965
  return [...found.values()];
5236
5966
  }
5237
5967
  }, "schemaIssues");
5238
- var scopes = /* @__PURE__ */ __name((raw) => {
5968
+ var scopes2 = /* @__PURE__ */ __name((raw) => {
5239
5969
  if (!isNode(raw))
5240
5970
  return [];
5241
5971
  const out = [];
@@ -5257,7 +5987,7 @@ var scopes = /* @__PURE__ */ __name((raw) => {
5257
5987
  addSection([name], raw[name]);
5258
5988
  return out;
5259
5989
  }, "scopes");
5260
- 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");
5261
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");
5262
5992
  var pathId = /* @__PURE__ */ __name((path2) => path2.join("\0"), "pathId");
5263
5993
  var prune = /* @__PURE__ */ __name((raw, paths) => {
@@ -5325,7 +6055,7 @@ var checkConfigText = /* @__PURE__ */ __name((text2, { file, tool, schema, known
5325
6055
  var wholeFile = /* @__PURE__ */ __name((file, what) => ({ kind: "invalid_value", file, what }), "wholeFile");
5326
6056
  var readConfigText = /* @__PURE__ */ __name((path2) => {
5327
6057
  try {
5328
- return { text: readFileSync2(path2, "utf8") };
6058
+ return { text: readFileSync3(path2, "utf8") };
5329
6059
  } catch (error) {
5330
6060
  const code = error.code;
5331
6061
  if (code === "ENOENT")
@@ -5345,9 +6075,9 @@ var readConfigFile = /* @__PURE__ */ __name((path2) => {
5345
6075
  return "issue" in parsed ? { issue: publicIssue(parsed.issue) } : parsed;
5346
6076
  }, "readConfigFile");
5347
6077
 
5348
- // node_modules/.pnpm/@wirecat+cli-core@0.452.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.63.0_commander@15._e609b9d6c8060966368a91e843fe8bd2/node_modules/@wirecat/cli-core/dist/cli/default-config.js
5349
- import { existsSync as existsSync2, linkSync, mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
5350
- 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";
5351
6081
  var DEFAULT_CONFIG = {
5352
6082
  defaults: { limit: 20, keep_runs_for_days: 30, sends_per_hour: 30, update_check: true, skill_hint: true },
5353
6083
  profiles: {}
@@ -5356,11 +6086,11 @@ function ensureDefaultConfig(path2, config = DEFAULT_CONFIG) {
5356
6086
  if (existsSync2(path2))
5357
6087
  return;
5358
6088
  const directory = dirname(path2);
5359
- mkdirSync(directory, { recursive: true, mode: 448 });
5360
- const temporary = mkdtempSync(join2(directory, ".config-"));
5361
- 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");
5362
6092
  try {
5363
- writeFileSync(candidate, `${JSON.stringify(config, null, 2)}
6093
+ writeFileSync2(candidate, `${JSON.stringify(config, null, 2)}
5364
6094
  `, { flag: "wx", mode: 384 });
5365
6095
  try {
5366
6096
  linkSync(candidate, path2);
@@ -5369,12 +6099,12 @@ function ensureDefaultConfig(path2, config = DEFAULT_CONFIG) {
5369
6099
  throw error;
5370
6100
  }
5371
6101
  } finally {
5372
- rmSync(temporary, { recursive: true, force: true });
6102
+ rmSync2(temporary, { recursive: true, force: true });
5373
6103
  }
5374
6104
  }
5375
6105
  __name(ensureDefaultConfig, "ensureDefaultConfig");
5376
6106
 
5377
- // node_modules/.pnpm/@wirecat+cli-core@0.452.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.63.0_commander@15._e609b9d6c8060966368a91e843fe8bd2/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
5378
6108
  var DEFAULT_LIMIT = DEFAULT_CONFIG.defaults.limit;
5379
6109
  var DEFAULT_KEEP_RUNS_FOR_DAYS = DEFAULT_CONFIG.defaults.keep_runs_for_days;
5380
6110
  var DEFAULT_SENDS_PER_HOUR = DEFAULT_CONFIG.defaults.sends_per_hour;
@@ -5391,6 +6121,7 @@ var count2 = pipe(number(wholeNumber), integer(wholeNumber), minValue(1, wholeNu
5391
6121
  var zeroOrMore = plain("has to be a whole number, 0 or more");
5392
6122
  var countOrZero = pipe(number(zeroOrMore), integer(zeroOrMore), minValue(0, zeroOrMore));
5393
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"'));
5394
6125
  var wholeOrZero = /* @__PURE__ */ __name((text2, name) => {
5395
6126
  const value = Number(text2);
5396
6127
  if (!Number.isInteger(value) || value < 0)
@@ -5407,8 +6138,10 @@ var SHARED_PROFILE_ENTRIES = {
5407
6138
  color: optional(flag),
5408
6139
  sender_colors: optional(flag),
5409
6140
  record: optional(flag),
5410
- record_input: optional(flag),
6141
+ record_input: optional(recordInputSetting),
5411
6142
  keep_runs_for_days: optional(count2),
6143
+ keep_successful_runs_for_days: optional(count2),
6144
+ runs_size_limit_mb: optional(count2),
5412
6145
  permissions: optional(permissionLevels),
5413
6146
  sends_per_hour: optional(count2),
5414
6147
  requests_per_minute: optional(countOrZero),
@@ -5478,7 +6211,7 @@ var settingsFor = /* @__PURE__ */ __name((app, extension = {}) => {
5478
6211
  const defaultsOnlyKeys = Object.keys(defaultsOnly);
5479
6212
  const botOnlyKeys = Object.keys(BOT_ONLY_ENTRIES);
5480
6213
  const allSettings = [...Object.keys(profileEntries), ...botOnlyKeys, ...defaultsOnlyKeys];
5481
- const PROFILE2 = envName(app, "PROFILE");
6214
+ const PROFILE = envName(app, "PROFILE");
5482
6215
  const PROFILE_LOCK = envName(app, "PROFILE_LOCK");
5483
6216
  const TIMEOUT = envName(app, "TIMEOUT");
5484
6217
  const REQUESTS_PER_MINUTE = envName(app, "REQUESTS_PER_MINUTE");
@@ -5500,7 +6233,7 @@ var settingsFor = /* @__PURE__ */ __name((app, extension = {}) => {
5500
6233
  usableProfileName(lock);
5501
6234
  if (profile.value === lock)
5502
6235
  return profile;
5503
- if (profile.from === "first word" || profile.from === PROFILE2) {
6236
+ if (profile.from === "first word" || profile.from === PROFILE) {
5504
6237
  throw new CliError("permission_error", `this process is locked to profile ${lock} (${PROFILE_LOCK}) \u2014 profile "${profile.value}" is refused`);
5505
6238
  }
5506
6239
  return { value: lock, from: PROFILE_LOCK };
@@ -5511,7 +6244,7 @@ var settingsFor = /* @__PURE__ */ __name((app, extension = {}) => {
5511
6244
  const here = profilesOf(config, env);
5512
6245
  if (here.length === 0)
5513
6246
  throw new NoProfileHere(app);
5514
- 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 });
5515
6248
  }, "unnamed");
5516
6249
  const profilesOf = /* @__PURE__ */ __name((config, env) => profilesHere(app, [...namedProfiles(config), ...extension.profiles?.(env) ?? []], env), "profilesOf");
5517
6250
  const resolveSettings = /* @__PURE__ */ __name((flags = {}, options = {}) => {
@@ -5528,12 +6261,12 @@ var settingsFor = /* @__PURE__ */ __name((app, extension = {}) => {
5528
6261
  throw new CliError("configuration_error", issueMessage(loaded.issues));
5529
6262
  const { config } = loaded;
5530
6263
  const lock = given(env[PROFILE_LOCK]);
5531
- const named = first([
6264
+ const named2 = first([
5532
6265
  ["first word", flags.profile],
5533
- [PROFILE2, given(env[PROFILE2])],
6266
+ [PROFILE, given(env[PROFILE])],
5534
6267
  [PROFILE_LOCK, lock]
5535
6268
  ], void 0);
5536
- 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);
5537
6270
  const kind = options.kind ?? "personal";
5538
6271
  const name = usableProfileName(profile.value);
5539
6272
  const configured = config.profiles[name] ?? {};
@@ -5548,7 +6281,7 @@ var settingsFor = /* @__PURE__ */ __name((app, extension = {}) => {
5548
6281
  const fromLayers = /* @__PURE__ */ __name((key, fallback, only = layers) => first(only.map(([from, scope]) => [from, scope?.[key]]), fallback), "fromLayers");
5549
6282
  const kindLayers = layers.filter(([from]) => from.startsWith(`config file: ${kind}.`));
5550
6283
  const limit = flags.limit === void 0 ? fromLayers("limit", DEFAULT_LIMIT) : { value: flags.limit, from: "flag" };
5551
- 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" };
5552
6285
  const timeoutMs = fromLayers("timeout_ms", void 0);
5553
6286
  const color = fromLayers("color", void 0);
5554
6287
  const senderColors = fromLayers("sender_colors", false);
@@ -5557,6 +6290,8 @@ var settingsFor = /* @__PURE__ */ __name((app, extension = {}) => {
5557
6290
  const searchReranker = fromLayers("search_reranker", DEFAULT_RERANK_MODEL);
5558
6291
  const recordInput = fromLayers("record_input", true);
5559
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);
5560
6295
  const readOnlyLock = readOnlyLockOf(app, env);
5561
6296
  const sendsPerHour = kind === "bot" ? fromLayers("sends_per_hour", Number.POSITIVE_INFINITY, kindLayers) : fromLayers("sends_per_hour", DEFAULT_SENDS_PER_HOUR);
5562
6297
  const paceFromEnv = given(env[REQUESTS_PER_MINUTE]);
@@ -5602,8 +6337,10 @@ var settingsFor = /* @__PURE__ */ __name((app, extension = {}) => {
5602
6337
  commandTimeoutMs: timeout.value === void 0 ? void 0 : (extension.parseDuration ?? parseDuration)(timeout.value, timeout.from === TIMEOUT ? TIMEOUT : "--timeout"),
5603
6338
  record: record2.value,
5604
6339
  recordInput: recordInput.value,
5605
- keepFailedRuns: record2.value || record2.from === "default",
6340
+ keepFailedRuns: record2.value || record2.from !== "flag",
5606
6341
  keepRunsForDays: keepRunsForDays.value,
6342
+ keepSuccessfulRunsForDays: keepSuccessfulRunsForDays.value,
6343
+ runsSizeLimitMb: runsSizeLimitMb.value,
5607
6344
  ...readOnlyLock ? { readOnlyLock } : {},
5608
6345
  permissions: permissions.levels,
5609
6346
  permissionSources: permissions.sources,
@@ -5631,6 +6368,8 @@ var settingsFor = /* @__PURE__ */ __name((app, extension = {}) => {
5631
6368
  record: record2.from,
5632
6369
  recordInput: recordInput.from,
5633
6370
  keepRunsForDays: keepRunsForDays.from,
6371
+ keepSuccessfulRunsForDays: keepSuccessfulRunsForDays.from,
6372
+ runsSizeLimitMb: runsSizeLimitMb.from,
5634
6373
  sendsPerHour: sendsPerHour.from,
5635
6374
  requestsPerMinute: requestsPerMinute.from,
5636
6375
  readOtherBots: readOtherBots.from,
@@ -5748,7 +6487,7 @@ var given = /* @__PURE__ */ __name((value) => {
5748
6487
  return trimmed === void 0 || trimmed === "" ? void 0 : trimmed;
5749
6488
  }, "given");
5750
6489
 
5751
- // node_modules/.pnpm/@wirecat+cli-core@0.452.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.63.0_commander@15._e609b9d6c8060966368a91e843fe8bd2/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
5752
6491
  var setExitCode = /* @__PURE__ */ __name((command, code) => {
5753
6492
  const slot = environmentOf(command).exit;
5754
6493
  if (slot)
@@ -5820,13 +6559,22 @@ var baseContext = /* @__PURE__ */ __name((command, resolveSettings) => {
5820
6559
  program: rootOf(command),
5821
6560
  ...environment.argv ? { argv: environment.argv } : {},
5822
6561
  env,
5823
- recordInput: settings.recordInput !== false
6562
+ recordInput: settings.recordInput ?? true,
6563
+ caller: environment.agent?.caller ?? currentCaller()
5824
6564
  }),
5825
6565
  ...ranFor === void 0 ? {} : { profile: ranFor },
5826
- 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
+ }),
5827
6573
  keepFailed: settings.keepFailedRuns,
5828
6574
  trace: settings.trace,
5829
6575
  keepDays: settings.keepRunsForDays,
6576
+ ...settings.keepSuccessfulRunsForDays === void 0 ? {} : { keepSuccessDays: settings.keepSuccessfulRunsForDays },
6577
+ ...settings.runsSizeLimitMb === void 0 ? {} : { maxBytes: settings.runsSizeLimitMb * 1024 * 1024 },
5830
6578
  processRun: !environment.agent,
5831
6579
  format,
5832
6580
  streams,
@@ -5841,12 +6589,12 @@ var baseContext = /* @__PURE__ */ __name((command, resolveSettings) => {
5841
6589
  }, "baseContext");
5842
6590
  var commandPath = /* @__PURE__ */ __name((command) => {
5843
6591
  const words = [];
5844
- for (let current = command; current?.parent; current = current.parent)
5845
- words.unshift(current.name());
6592
+ for (let current2 = command; current2?.parent; current2 = current2.parent)
6593
+ words.unshift(current2.name());
5846
6594
  return words.join(" ");
5847
6595
  }, "commandPath");
5848
6596
 
5849
- // node_modules/.pnpm/@wirecat+cli-core@0.452.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.63.0_commander@15._e609b9d6c8060966368a91e843fe8bd2/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
5850
6598
  var REMOTE_READ = { remote: "read", local: "read" };
5851
6599
  var FETCH = { remote: "read", local: "write" };
5852
6600
  var REMOTE_WRITE = { remote: "write", local: "write" };
@@ -5937,7 +6685,7 @@ var refuseUnderReadOnly = /* @__PURE__ */ __name((command, what) => {
5937
6685
  throw readOnlyRefusal(lock, what);
5938
6686
  }, "refuseUnderReadOnly");
5939
6687
 
5940
- // node_modules/.pnpm/@wirecat+cli-core@0.452.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.63.0_commander@15._e609b9d6c8060966368a91e843fe8bd2/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
5941
6689
  var STEPS2 = defineSteps([
5942
6690
  ...STEPS,
5943
6691
  {
@@ -6194,7 +6942,7 @@ var stepLine = /* @__PURE__ */ __name((root, step) => {
6194
6942
  ].join(" ");
6195
6943
  }, "stepLine");
6196
6944
 
6197
- // node_modules/.pnpm/@wirecat+cli-core@0.452.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.63.0_commander@15._e609b9d6c8060966368a91e843fe8bd2/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
6198
6946
  var HIDDEN = /* @__PURE__ */ new Set(["providerRef", "provider_ref"]);
6199
6947
  var withoutProviderRefs = /* @__PURE__ */ __name((value) => strip(value), "withoutProviderRefs");
6200
6948
  var strip = /* @__PURE__ */ __name((value) => {
@@ -6208,9 +6956,9 @@ var strip = /* @__PURE__ */ __name((value) => {
6208
6956
  return Object.fromEntries(Object.entries(value).flatMap(([key, inner]) => HIDDEN.has(key) ? [] : [[key, strip(inner)]]));
6209
6957
  }, "strip");
6210
6958
 
6211
- // node_modules/.pnpm/@wirecat+cli-core@0.452.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.63.0_commander@15._e609b9d6c8060966368a91e843fe8bd2/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
6212
6960
  var answerSchema = /* @__PURE__ */ __name((item = unknown()) => union([listEnvelopeSchema(item), itemEnvelopeSchema(item)]), "answerSchema");
6213
- 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");
6214
6962
  var listOf = /* @__PURE__ */ __name((command, input) => {
6215
6963
  const { items, limit, has_more, cursor, paging, page, args = {}, next = [], missing, meta } = input;
6216
6964
  const byCursor = paging === "cursor" || cursor !== void 0;
@@ -6224,7 +6972,7 @@ var listOf = /* @__PURE__ */ __name((command, input) => {
6224
6972
  const body = {
6225
6973
  items,
6226
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 } : {} },
6227
- ...capped([...more, ...next]),
6975
+ ...capped2([...more, ...next]),
6228
6976
  ...missing && missing.length > 0 ? { missing } : {},
6229
6977
  ...meta ? { meta } : {}
6230
6978
  };
@@ -6233,13 +6981,13 @@ var listOf = /* @__PURE__ */ __name((command, input) => {
6233
6981
  var itemOf = /* @__PURE__ */ __name((item, { next = [], missing, meta } = {}) => {
6234
6982
  const body = {
6235
6983
  item,
6236
- ...capped(next),
6984
+ ...capped2(next),
6237
6985
  ...missing && missing.length > 0 ? { missing } : {},
6238
6986
  ...meta ? { meta } : {}
6239
6987
  };
6240
6988
  return body;
6241
6989
  }, "itemOf");
6242
- 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");
6243
6991
  var snakeKeysKeeping = /* @__PURE__ */ __name((verbatim) => {
6244
6992
  const kept = new Set(verbatim);
6245
6993
  const convert = /* @__PURE__ */ __name((value) => {
@@ -6250,7 +6998,7 @@ var snakeKeysKeeping = /* @__PURE__ */ __name((verbatim) => {
6250
6998
  return Object.fromEntries(Object.entries(value).flatMap(([key, inner]) => {
6251
6999
  if (inner === void 0)
6252
7000
  return [];
6253
- const name = snake2(key);
7001
+ const name = snake3(key);
6254
7002
  return [[name, kept.has(key) || kept.has(name) ? inner : convert(inner)]];
6255
7003
  }));
6256
7004
  }, "convert");
@@ -6330,7 +7078,7 @@ var printItem = /* @__PURE__ */ __name(({ renderer, format }, item) => {
6330
7078
  renderer.result(item);
6331
7079
  }, "printItem");
6332
7080
 
6333
- // node_modules/.pnpm/@wirecat+cli-core@0.452.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.63.0_commander@15._e609b9d6c8060966368a91e843fe8bd2/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
6334
7082
  var TABLE_KINDS = ["data", "search_index", "search_index_part", "internal"];
6335
7083
  var storeTable = strictObject({
6336
7084
  name: text,
@@ -6339,7 +7087,7 @@ var storeTable = strictObject({
6339
7087
  bytes: optional(nullable(count))
6340
7088
  });
6341
7089
 
6342
- // node_modules/.pnpm/@wirecat+cli-core@0.452.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.63.0_commander@15._e609b9d6c8060966368a91e843fe8bd2/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
6343
7091
  var WEIGHTS = {
6344
7092
  bot: 3,
6345
7093
  scam: 3,
@@ -6364,7 +7112,7 @@ var LINK = /https?:\/\/|t\.me\/|www\./i;
6364
7112
  var DIGITS = /\d{5,}/;
6365
7113
  var oddName = /* @__PURE__ */ __name((name) => !name?.trim() || DIGITS.test(name) || LINK.test(name), "oddName");
6366
7114
 
6367
- // node_modules/.pnpm/@wirecat+cli-core@0.452.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.63.0_commander@15._e609b9d6c8060966368a91e843fe8bd2/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
6368
7116
  var closeSuggestion = strictObject({
6369
7117
  as: picklist(["done", "dismissed"]),
6370
7118
  /** The agent's name. */
@@ -6406,7 +7154,7 @@ var task = strictObject({
6406
7154
  updated_at: optional(time)
6407
7155
  });
6408
7156
 
6409
- // node_modules/.pnpm/@wirecat+cli-core@0.452.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.63.0_commander@15._e609b9d6c8060966368a91e843fe8bd2/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
6410
7158
  var agendaChat = strictObject({
6411
7159
  chat: reference,
6412
7160
  title: nullable(text),
@@ -6466,7 +7214,7 @@ var agenda = strictObject({
6466
7214
  unlisted_categories: array(strictObject({ name: text, open_tasks: number() }))
6467
7215
  });
6468
7216
 
6469
- // node_modules/.pnpm/@wirecat+cli-core@0.452.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.63.0_commander@15._e609b9d6c8060966368a91e843fe8bd2/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
6470
7218
  var conversation = strictObject({
6471
7219
  id,
6472
7220
  chat: reference,
@@ -6481,7 +7229,7 @@ var conversation = strictObject({
6481
7229
  rules_version: count
6482
7230
  });
6483
7231
 
6484
- // node_modules/.pnpm/@wirecat+cli-core@0.452.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.63.0_commander@15._e609b9d6c8060966368a91e843fe8bd2/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
6485
7233
  var attachment = strictObject({
6486
7234
  /** The message it came with, as a locator; absent inside that message. */
6487
7235
  message: optional(reference),
@@ -6510,7 +7258,7 @@ var attachment = strictObject({
6510
7258
  }))))
6511
7259
  });
6512
7260
 
6513
- // node_modules/.pnpm/@wirecat+cli-core@0.452.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.63.0_commander@15._e609b9d6c8060966368a91e843fe8bd2/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
6514
7262
  var tagging = strictObject({
6515
7263
  tag: text,
6516
7264
  type: picklist(TAG_TYPES),
@@ -6523,7 +7271,7 @@ var tagging = strictObject({
6523
7271
  created_at: time
6524
7272
  });
6525
7273
 
6526
- // node_modules/.pnpm/@wirecat+cli-core@0.452.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.63.0_commander@15._e609b9d6c8060966368a91e843fe8bd2/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
6527
7275
  var recordLogFor = /* @__PURE__ */ __name((to, app, { traceId, command } = {}) => {
6528
7276
  const run = currentRun();
6529
7277
  const trace = traceId ?? run.traceId;
@@ -6555,20 +7303,35 @@ export {
6555
7303
  sharedCommand,
6556
7304
  customizeSharedCommand,
6557
7305
  refuseJoinedPath,
6558
- isCliFailure,
6559
- isCommanderFailure,
6560
- failureKey,
6561
- 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,
6562
7324
  recorded,
6563
7325
  startRecording,
6564
7326
  wasSettled,
6565
- partialOutcome,
6566
- agentOf,
6567
- secretInput,
6568
- maskArgv,
6569
- runContextOf,
7327
+ sentIds,
7328
+ currentOperation,
7329
+ guardedWrite,
7330
+ codeOf,
6570
7331
  withDeadline,
6571
7332
  DEFAULT_COMMAND_MS,
7333
+ DEFAULT_COOPERATIVE_MS,
7334
+ DEFAULT_AGENT_COOPERATIVE_MS,
6572
7335
  DEFAULT_OUTPUT_BYTES,
6573
7336
  byteCount,
6574
7337
  execution,
@@ -6594,6 +7357,22 @@ export {
6594
7357
  rerankModel,
6595
7358
  vectorModelKey,
6596
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,
6597
7376
  permissionIssues,
6598
7377
  publicIssue,
6599
7378
  issueMessage,