agent-inspect 1.4.0 → 1.6.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 (111) hide show
  1. package/CHANGELOG.md +63 -0
  2. package/README.md +34 -6
  3. package/docs/ADAPTERS.md +6 -0
  4. package/docs/API.md +132 -9
  5. package/docs/ARCHITECTURE.md +4 -0
  6. package/docs/CLI.md +98 -5
  7. package/docs/DIFF.md +8 -0
  8. package/docs/EXPORTS.md +13 -0
  9. package/docs/GETTING-STARTED.md +19 -1
  10. package/docs/KNOWN-ISSUES.md +8 -1
  11. package/docs/LIMITATIONS.md +13 -2
  12. package/docs/LOGS.md +22 -0
  13. package/docs/SCHEMA.md +19 -7
  14. package/docs/SCREENSHOTS.md +190 -9
  15. package/package.json +71 -1
  16. package/packages/cli/dist/index.cjs +7121 -3986
  17. package/packages/cli/dist/index.cjs.map +1 -1
  18. package/packages/cli/dist/index.mjs +7122 -3987
  19. package/packages/cli/dist/index.mjs.map +1 -1
  20. package/packages/core/dist/advanced.cjs +2258 -0
  21. package/packages/core/dist/advanced.cjs.map +1 -0
  22. package/packages/core/dist/advanced.d.cts +254 -0
  23. package/packages/core/dist/advanced.d.ts +254 -0
  24. package/packages/core/dist/advanced.mjs +11 -0
  25. package/packages/core/dist/advanced.mjs.map +1 -0
  26. package/packages/core/dist/chunk-57S5D6HR.mjs +655 -0
  27. package/packages/core/dist/chunk-57S5D6HR.mjs.map +1 -0
  28. package/packages/core/dist/chunk-6QSLZCBJ.mjs +743 -0
  29. package/packages/core/dist/chunk-6QSLZCBJ.mjs.map +1 -0
  30. package/packages/core/dist/chunk-6SZPTECC.mjs +342 -0
  31. package/packages/core/dist/chunk-6SZPTECC.mjs.map +1 -0
  32. package/packages/core/dist/chunk-74XZ6N7Q.mjs +409 -0
  33. package/packages/core/dist/chunk-74XZ6N7Q.mjs.map +1 -0
  34. package/packages/core/dist/chunk-7TGZLWEE.mjs +35 -0
  35. package/packages/core/dist/chunk-7TGZLWEE.mjs.map +1 -0
  36. package/packages/core/dist/chunk-BT7CATSD.mjs +497 -0
  37. package/packages/core/dist/chunk-BT7CATSD.mjs.map +1 -0
  38. package/packages/core/dist/chunk-E5F2LQCX.mjs +83 -0
  39. package/packages/core/dist/chunk-E5F2LQCX.mjs.map +1 -0
  40. package/packages/core/dist/chunk-EDTQHZPM.mjs +88 -0
  41. package/packages/core/dist/chunk-EDTQHZPM.mjs.map +1 -0
  42. package/packages/core/dist/chunk-HR7G62IE.mjs +785 -0
  43. package/packages/core/dist/chunk-HR7G62IE.mjs.map +1 -0
  44. package/packages/core/dist/chunk-HY7H3CQM.mjs +127 -0
  45. package/packages/core/dist/chunk-HY7H3CQM.mjs.map +1 -0
  46. package/packages/core/dist/chunk-S4YWKV4G.mjs +48 -0
  47. package/packages/core/dist/chunk-S4YWKV4G.mjs.map +1 -0
  48. package/packages/core/dist/chunk-TFLPUZ56.mjs +1571 -0
  49. package/packages/core/dist/chunk-TFLPUZ56.mjs.map +1 -0
  50. package/packages/core/dist/chunk-TZISEVLQ.mjs +390 -0
  51. package/packages/core/dist/chunk-TZISEVLQ.mjs.map +1 -0
  52. package/packages/core/dist/chunk-U2BGPESY.mjs +150 -0
  53. package/packages/core/dist/chunk-U2BGPESY.mjs.map +1 -0
  54. package/packages/core/dist/chunk-VTIB5MDK.mjs +304 -0
  55. package/packages/core/dist/chunk-VTIB5MDK.mjs.map +1 -0
  56. package/packages/core/dist/chunk-VU6O5QAH.mjs +99 -0
  57. package/packages/core/dist/chunk-VU6O5QAH.mjs.map +1 -0
  58. package/packages/core/dist/chunk-Y56BPA3B.mjs +990 -0
  59. package/packages/core/dist/chunk-Y56BPA3B.mjs.map +1 -0
  60. package/packages/core/dist/chunk-YWAOOXLR.mjs +475 -0
  61. package/packages/core/dist/chunk-YWAOOXLR.mjs.map +1 -0
  62. package/packages/core/dist/diff.cjs +993 -0
  63. package/packages/core/dist/diff.cjs.map +1 -0
  64. package/packages/core/dist/diff.d.cts +82 -0
  65. package/packages/core/dist/diff.d.ts +82 -0
  66. package/packages/core/dist/diff.mjs +5 -0
  67. package/packages/core/dist/diff.mjs.map +1 -0
  68. package/packages/core/dist/exporters.cjs +1228 -0
  69. package/packages/core/dist/exporters.cjs.map +1 -0
  70. package/packages/core/dist/exporters.d.cts +114 -0
  71. package/packages/core/dist/exporters.d.ts +114 -0
  72. package/packages/core/dist/exporters.mjs +6 -0
  73. package/packages/core/dist/exporters.mjs.map +1 -0
  74. package/packages/core/dist/index.cjs +5542 -2218
  75. package/packages/core/dist/index.cjs.map +1 -1
  76. package/packages/core/dist/index.d.cts +113 -908
  77. package/packages/core/dist/index.d.ts +113 -908
  78. package/packages/core/dist/index.mjs +1048 -5403
  79. package/packages/core/dist/index.mjs.map +1 -1
  80. package/packages/core/dist/inspect-event-Des4JDHo.d.cts +41 -0
  81. package/packages/core/dist/inspect-event-Des4JDHo.d.ts +41 -0
  82. package/packages/core/dist/log-config-BnH8Ykcb.d.cts +33 -0
  83. package/packages/core/dist/log-config-C1GcJPIM.d.ts +33 -0
  84. package/packages/core/dist/logs.cjs +1007 -0
  85. package/packages/core/dist/logs.cjs.map +1 -0
  86. package/packages/core/dist/logs.d.cts +138 -0
  87. package/packages/core/dist/logs.d.ts +138 -0
  88. package/packages/core/dist/logs.mjs +6 -0
  89. package/packages/core/dist/logs.mjs.map +1 -0
  90. package/packages/core/dist/persisted-inspect-event-0kaRADsp.d.cts +56 -0
  91. package/packages/core/dist/persisted-inspect-event-DiFto0K2.d.ts +56 -0
  92. package/packages/core/dist/persisted.cjs +1055 -0
  93. package/packages/core/dist/persisted.cjs.map +1 -0
  94. package/packages/core/dist/persisted.d.cts +111 -0
  95. package/packages/core/dist/persisted.d.ts +111 -0
  96. package/packages/core/dist/persisted.mjs +7 -0
  97. package/packages/core/dist/persisted.mjs.map +1 -0
  98. package/packages/core/dist/readers.cjs +2590 -0
  99. package/packages/core/dist/readers.cjs.map +1 -0
  100. package/packages/core/dist/readers.d.cts +80 -0
  101. package/packages/core/dist/readers.d.ts +80 -0
  102. package/packages/core/dist/readers.mjs +9 -0
  103. package/packages/core/dist/readers.mjs.map +1 -0
  104. package/packages/core/dist/types-DB8jB6Jg.d.cts +232 -0
  105. package/packages/core/dist/types-tSix7tfv.d.ts +232 -0
  106. package/packages/core/dist/writers.cjs +997 -0
  107. package/packages/core/dist/writers.cjs.map +1 -0
  108. package/packages/core/dist/writers.d.cts +62 -0
  109. package/packages/core/dist/writers.d.ts +62 -0
  110. package/packages/core/dist/writers.mjs +9 -0
  111. package/packages/core/dist/writers.mjs.map +1 -0
@@ -0,0 +1,2258 @@
1
+ 'use strict';
2
+
3
+ var async_hooks = require('async_hooks');
4
+ var crypto = require('crypto');
5
+ var promises = require('fs/promises');
6
+ var path = require('path');
7
+ var os = require('os');
8
+ var process2 = require('process');
9
+ var tty = require('tty');
10
+
11
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
12
+
13
+ var crypto__default = /*#__PURE__*/_interopDefault(crypto);
14
+ var path__default = /*#__PURE__*/_interopDefault(path);
15
+ var os__default = /*#__PURE__*/_interopDefault(os);
16
+ var process2__default = /*#__PURE__*/_interopDefault(process2);
17
+ var tty__default = /*#__PURE__*/_interopDefault(tty);
18
+
19
+ // packages/core/src/context.ts
20
+
21
+ // packages/core/src/correlation-metadata.ts
22
+ var TRACE_CORRELATION_KEYS = [
23
+ "correlationId",
24
+ "requestId",
25
+ "decisionId",
26
+ "groupId"
27
+ ];
28
+ function isNonEmptyString(value) {
29
+ return typeof value === "string" && value.length > 0;
30
+ }
31
+ function extractCorrelationMetadata(record) {
32
+ if (!record) {
33
+ return void 0;
34
+ }
35
+ const out = {};
36
+ let found = false;
37
+ for (const key of TRACE_CORRELATION_KEYS) {
38
+ const value = record[key];
39
+ if (isNonEmptyString(value)) {
40
+ out[key] = value;
41
+ found = true;
42
+ }
43
+ }
44
+ return found ? out : void 0;
45
+ }
46
+ var DEFAULT_REDACT_KEYS = [
47
+ "authorization",
48
+ "cookie",
49
+ "token",
50
+ "apiKey",
51
+ "password",
52
+ "secret",
53
+ "email"
54
+ ];
55
+ function isRecord(v) {
56
+ return typeof v === "object" && v !== null && !Array.isArray(v);
57
+ }
58
+ function toKey(s) {
59
+ return s.toLowerCase();
60
+ }
61
+ function stableHash(value) {
62
+ const h = crypto__default.default.createHash("sha256").update(value, "utf8").digest("hex");
63
+ return h.slice(0, 8);
64
+ }
65
+ function compileRules(rules, extraKeys) {
66
+ const out = /* @__PURE__ */ new Map();
67
+ const set = (r) => {
68
+ const k = toKey(r.key);
69
+ out.set(k, { ...r, key: k });
70
+ };
71
+ for (const k of DEFAULT_REDACT_KEYS) {
72
+ set({ key: k, strategy: "full" });
73
+ }
74
+ for (const k of extraKeys ?? []) {
75
+ if (typeof k === "string" && k.length > 0) {
76
+ set({ key: k, strategy: "full" });
77
+ }
78
+ }
79
+ for (const r of rules ?? []) {
80
+ if (typeof r === "string") {
81
+ set({ key: r, strategy: "full" });
82
+ continue;
83
+ }
84
+ const key = r.key;
85
+ if (r.strategy === "full") set({ key, strategy: "full" });
86
+ if (r.strategy === "hash") set({ key, strategy: "hash" });
87
+ if (r.strategy === "prefix") {
88
+ set({ key, strategy: "prefix", keep: typeof r.keep === "number" ? r.keep : 8 });
89
+ }
90
+ }
91
+ return [...out.values()];
92
+ }
93
+ var Redactor = class {
94
+ #rules;
95
+ constructor(options) {
96
+ this.#rules = compileRules(options?.rules, options?.extraKeys);
97
+ }
98
+ redactValue(key, value) {
99
+ const k = toKey(key);
100
+ const rule = this.#rules.find((r) => r.key === k);
101
+ if (!rule) {
102
+ return this.#redactNested(value);
103
+ }
104
+ if (rule.strategy === "full") return "[REDACTED]";
105
+ const asString = typeof value === "string" ? value : typeof value === "number" || typeof value === "boolean" || typeof value === "bigint" ? String(value) : void 0;
106
+ if (rule.strategy === "prefix") {
107
+ if (asString === void 0) return "[REDACTED]";
108
+ const keep = Math.max(0, Math.floor(rule.keep));
109
+ return asString.length <= keep ? `${asString}\u2026` : `${asString.slice(0, keep)}\u2026`;
110
+ }
111
+ if (rule.strategy === "hash") {
112
+ if (asString === void 0) return "[HASH:unknown]";
113
+ return `[HASH:${stableHash(asString)}]`;
114
+ }
115
+ return this.#redactNested(value);
116
+ }
117
+ redactRecord(record) {
118
+ const out = {};
119
+ for (const [k, v] of Object.entries(record)) {
120
+ out[k] = this.redactValue(k, v);
121
+ }
122
+ return out;
123
+ }
124
+ #redactNested(value) {
125
+ if (Array.isArray(value)) {
126
+ return value.map((v) => this.#redactNested(v));
127
+ }
128
+ if (isRecord(value)) {
129
+ const out = {};
130
+ for (const [k, v] of Object.entries(value)) {
131
+ out[k] = this.redactValue(k, v);
132
+ }
133
+ return out;
134
+ }
135
+ return value;
136
+ }
137
+ };
138
+
139
+ // packages/core/src/redaction-profiles.ts
140
+ var SHARE_PROFILE_EXTRA_KEYS = [
141
+ "userEmail",
142
+ "customerEmail",
143
+ "phone",
144
+ "phoneNumber",
145
+ "address",
146
+ "ip",
147
+ "ipAddress",
148
+ "sessionId",
149
+ "requestId",
150
+ "correlationId",
151
+ "decisionId",
152
+ "groupId",
153
+ "customerId",
154
+ "userId",
155
+ "accountId",
156
+ "tenantId",
157
+ "orgId",
158
+ "organizationId",
159
+ "traceId",
160
+ "spanId",
161
+ "parentSpanId"
162
+ ];
163
+ var STRICT_PROFILE_EXTRA_KEYS = [
164
+ "prompt",
165
+ "completion",
166
+ "input",
167
+ "output",
168
+ "inputPreview",
169
+ "outputPreview",
170
+ "message",
171
+ "messages",
172
+ "transcript",
173
+ "context",
174
+ "document",
175
+ "documents",
176
+ "chunk",
177
+ "chunks",
178
+ "retrieval",
179
+ "query"
180
+ ];
181
+ function resolveRedactionProfile(profile = "local") {
182
+ switch (profile) {
183
+ case "local":
184
+ return { profile: "local", extraKeys: [] };
185
+ case "share":
186
+ return {
187
+ profile: "share",
188
+ extraKeys: SHARE_PROFILE_EXTRA_KEYS,
189
+ maxMetadataValueLengthCap: 500,
190
+ maxPreviewLengthCap: 200
191
+ };
192
+ case "strict":
193
+ return {
194
+ profile: "strict",
195
+ extraKeys: [...SHARE_PROFILE_EXTRA_KEYS, ...STRICT_PROFILE_EXTRA_KEYS],
196
+ maxMetadataValueLengthCap: 200,
197
+ maxPreviewLengthCap: 80
198
+ };
199
+ default:
200
+ return { profile: "local", extraKeys: [] };
201
+ }
202
+ }
203
+ function applyProfileMetadataCaps(maxMetadataValueLength, maxPreviewLength, resolved) {
204
+ let meta = maxMetadataValueLength;
205
+ let preview = maxPreviewLength;
206
+ if (resolved.maxMetadataValueLengthCap !== void 0) {
207
+ meta = Math.min(meta, resolved.maxMetadataValueLengthCap);
208
+ }
209
+ if (resolved.maxPreviewLengthCap !== void 0) {
210
+ preview = Math.min(preview, resolved.maxPreviewLengthCap);
211
+ }
212
+ return { maxMetadataValueLength: meta, maxPreviewLength: preview };
213
+ }
214
+
215
+ // packages/core/src/types/persisted-inspect-event.ts
216
+ var INSPECT_KINDS = [
217
+ "RUN",
218
+ "AGENT",
219
+ "LLM",
220
+ "TOOL",
221
+ "CHAIN",
222
+ "RETRIEVER",
223
+ "DECISION",
224
+ "RESULT",
225
+ "ERROR",
226
+ "LOGIC",
227
+ "LOG"
228
+ ];
229
+ var ATTRIBUTION_CONFIDENCES = [
230
+ "explicit",
231
+ "correlated",
232
+ "heuristic",
233
+ "unknown"
234
+ ];
235
+ var PERSISTED_EVENT_SOURCE_TYPES = [
236
+ "manual",
237
+ "json-log",
238
+ "log4js",
239
+ "adapter",
240
+ "ai-sdk",
241
+ "otel"
242
+ ];
243
+ var PERSISTED_EVENT_STATUSES = [
244
+ "running",
245
+ "ok",
246
+ "error",
247
+ "unknown"
248
+ ];
249
+ function isRecord2(value) {
250
+ return typeof value === "object" && value !== null && !Array.isArray(value);
251
+ }
252
+ function isString(value) {
253
+ return typeof value === "string";
254
+ }
255
+ function isNonEmptyString2(value) {
256
+ return typeof value === "string" && value.length > 0;
257
+ }
258
+ function isOptionalString(value) {
259
+ return value === void 0 || isString(value);
260
+ }
261
+ function isNonNegativeNumber(value) {
262
+ return typeof value === "number" && Number.isFinite(value) && value >= 0;
263
+ }
264
+ function isOptionalNonNegativeNumber(value) {
265
+ return value === void 0 || isNonNegativeNumber(value);
266
+ }
267
+ function isInspectKind(value) {
268
+ return typeof value === "string" && INSPECT_KINDS.includes(value);
269
+ }
270
+ function isAttributionConfidence(value) {
271
+ return typeof value === "string" && ATTRIBUTION_CONFIDENCES.includes(value);
272
+ }
273
+ function isPersistedEventSourceType(value) {
274
+ return typeof value === "string" && PERSISTED_EVENT_SOURCE_TYPES.includes(value);
275
+ }
276
+ function isPersistedEventStatus(value) {
277
+ return typeof value === "string" && PERSISTED_EVENT_STATUSES.includes(value);
278
+ }
279
+ function isPersistedEventSource(value) {
280
+ if (!isRecord2(value)) return false;
281
+ if (!isPersistedEventSourceType(value.type)) return false;
282
+ if (!isOptionalString(value.name)) return false;
283
+ if (!isOptionalString(value.version)) return false;
284
+ return true;
285
+ }
286
+ function isPersistedInspectError(value) {
287
+ if (!isRecord2(value)) return false;
288
+ if (!isNonEmptyString2(value.message)) return false;
289
+ if (!isOptionalString(value.name)) return false;
290
+ if (!isOptionalString(value.code)) return false;
291
+ return true;
292
+ }
293
+ function isPersistedTokenUsage(value) {
294
+ if (!isRecord2(value)) return false;
295
+ if (!isOptionalNonNegativeNumber(value.input)) return false;
296
+ if (!isOptionalNonNegativeNumber(value.output)) return false;
297
+ if (!isOptionalNonNegativeNumber(value.total)) return false;
298
+ if (!isOptionalNonNegativeNumber(value.cached)) return false;
299
+ return true;
300
+ }
301
+ function isPersistedTraceContext(value) {
302
+ if (!isRecord2(value)) return false;
303
+ if (!isOptionalString(value.traceId)) return false;
304
+ if (!isOptionalString(value.spanId)) return false;
305
+ if (!isOptionalString(value.parentSpanId)) return false;
306
+ return true;
307
+ }
308
+ function isPersistedInspectEvent(value) {
309
+ if (!isRecord2(value)) return false;
310
+ if (value.schemaVersion !== "0.2") return false;
311
+ if (!isNonEmptyString2(value.eventId)) return false;
312
+ if (!isNonEmptyString2(value.runId)) return false;
313
+ if (!isInspectKind(value.kind)) return false;
314
+ if (!isNonEmptyString2(value.name)) return false;
315
+ if (!isNonEmptyString2(value.timestamp)) return false;
316
+ if (!isAttributionConfidence(value.confidence)) return false;
317
+ if (!isPersistedEventSource(value.source)) return false;
318
+ if (value.parentId !== void 0 && !isNonEmptyString2(value.parentId)) {
319
+ return false;
320
+ }
321
+ if (value.status !== void 0 && !isPersistedEventStatus(value.status)) {
322
+ return false;
323
+ }
324
+ if (!isOptionalString(value.startedAt)) return false;
325
+ if (!isOptionalString(value.endedAt)) return false;
326
+ if (value.durationMs !== void 0 && !isNonNegativeNumber(value.durationMs)) {
327
+ return false;
328
+ }
329
+ if (value.attributes !== void 0 && !isRecord2(value.attributes)) {
330
+ return false;
331
+ }
332
+ if (value.error !== void 0 && !isPersistedInspectError(value.error)) {
333
+ return false;
334
+ }
335
+ if (value.tokenUsage !== void 0 && !isPersistedTokenUsage(value.tokenUsage)) {
336
+ return false;
337
+ }
338
+ if (value.trace !== void 0 && !isPersistedTraceContext(value.trace)) {
339
+ return false;
340
+ }
341
+ return true;
342
+ }
343
+
344
+ // node_modules/.pnpm/nanoid@5.1.11/node_modules/nanoid/url-alphabet/index.js
345
+ var urlAlphabet = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
346
+
347
+ // node_modules/.pnpm/nanoid@5.1.11/node_modules/nanoid/index.js
348
+ var POOL_SIZE_MULTIPLIER = 128;
349
+ var pool;
350
+ var poolOffset;
351
+ function fillPool(bytes) {
352
+ if (bytes < 0 || bytes > 1024) throw new RangeError("Wrong ID size");
353
+ if (!pool || pool.length < bytes) {
354
+ pool = Buffer.allocUnsafe(bytes * POOL_SIZE_MULTIPLIER);
355
+ crypto.webcrypto.getRandomValues(pool);
356
+ poolOffset = 0;
357
+ } else if (poolOffset + bytes > pool.length) {
358
+ crypto.webcrypto.getRandomValues(pool);
359
+ poolOffset = 0;
360
+ }
361
+ poolOffset += bytes;
362
+ }
363
+ function nanoid(size = 21) {
364
+ fillPool(size |= 0);
365
+ let id = "";
366
+ for (let i = poolOffset - size; i < poolOffset; i++) {
367
+ id += urlAlphabet[pool[i] & 63];
368
+ }
369
+ return id;
370
+ }
371
+
372
+ // packages/core/src/utils/duration.ts
373
+ function formatDuration(ms) {
374
+ if (!Number.isFinite(ms)) {
375
+ return "0ms";
376
+ }
377
+ if (ms < 0) {
378
+ throw new Error(`formatDuration: ms must be non-negative (got ${ms})`);
379
+ }
380
+ if (ms < 1e3) {
381
+ return `${Math.floor(ms)}ms`;
382
+ }
383
+ if (ms < 6e4) {
384
+ return `${(ms / 1e3).toFixed(2)}s`;
385
+ }
386
+ if (ms < 36e5) {
387
+ return `${(ms / 6e4).toFixed(1)}m`;
388
+ }
389
+ return `${(ms / 36e5).toFixed(1)}h`;
390
+ }
391
+
392
+ // packages/core/src/utils.ts
393
+ var DEFAULT_TRACE_DIR_NAME = ".agent-inspect";
394
+ var RUNS_DIR_NAME = "runs";
395
+ var FALLBACK_TRACE_DIR = path__default.default.join(
396
+ os__default.default.tmpdir(),
397
+ "agent-inspect",
398
+ RUNS_DIR_NAME
399
+ );
400
+ var MAX_NAME_LENGTH = 100;
401
+ function createRunId() {
402
+ return `run_${nanoid(10)}`;
403
+ }
404
+ function createStepId() {
405
+ return `step_${nanoid(10)}`;
406
+ }
407
+ function formatDuration2(ms) {
408
+ return formatDuration(ms);
409
+ }
410
+ function formatTimestamp(timestamp) {
411
+ if (!Number.isFinite(timestamp)) {
412
+ return "Invalid date";
413
+ }
414
+ const d = new Date(timestamp);
415
+ if (Number.isNaN(d.getTime())) {
416
+ return "Invalid date";
417
+ }
418
+ const y = d.getFullYear();
419
+ const mo = String(d.getMonth() + 1).padStart(2, "0");
420
+ const day = String(d.getDate()).padStart(2, "0");
421
+ const h = String(d.getHours()).padStart(2, "0");
422
+ const min = String(d.getMinutes()).padStart(2, "0");
423
+ const s = String(d.getSeconds()).padStart(2, "0");
424
+ return `${y}-${mo}-${day} ${h}:${min}:${s}`;
425
+ }
426
+ function getDefaultTraceDir() {
427
+ const envDir = process.env.AGENT_INSPECT_TRACE_DIR;
428
+ if (typeof envDir === "string" && envDir.trim() !== "") {
429
+ return envDir.trim();
430
+ }
431
+ try {
432
+ const home = os__default.default.homedir();
433
+ if (typeof home !== "string" || home.trim() === "") {
434
+ return FALLBACK_TRACE_DIR;
435
+ }
436
+ return path__default.default.join(home, DEFAULT_TRACE_DIR_NAME, RUNS_DIR_NAME);
437
+ } catch {
438
+ return FALLBACK_TRACE_DIR;
439
+ }
440
+ }
441
+ function getTraceFilePath(runId, traceDir) {
442
+ const baseDir = traceDir ?? getDefaultTraceDir();
443
+ let safeId = typeof runId === "string" && runId.trim() !== "" ? runId.trim() : "run_unknown";
444
+ safeId = path__default.default.basename(safeId);
445
+ if (safeId === "" || safeId === "." || safeId === "..") {
446
+ safeId = "run_unknown";
447
+ }
448
+ return path__default.default.join(baseDir, `${safeId}.jsonl`);
449
+ }
450
+ async function ensureTraceDir(traceDir) {
451
+ const primary = path__default.default.resolve(traceDir);
452
+ try {
453
+ await promises.mkdir(primary, { recursive: true });
454
+ return primary;
455
+ } catch {
456
+ warn(`Failed to create trace directory: ${primary}`);
457
+ const fallback = path__default.default.resolve(FALLBACK_TRACE_DIR);
458
+ try {
459
+ await promises.mkdir(fallback, { recursive: true });
460
+ return fallback;
461
+ } catch {
462
+ warn(`Failed to create fallback trace directory: ${fallback}`);
463
+ return primary;
464
+ }
465
+ }
466
+ }
467
+ function formatError(error) {
468
+ if (error instanceof Error) {
469
+ const out = { message: error.message };
470
+ if (typeof error.stack === "string" && error.stack.length > 0) {
471
+ out.stack = error.stack;
472
+ }
473
+ return out;
474
+ }
475
+ if (typeof error === "string") {
476
+ return { message: error };
477
+ }
478
+ if (error === null) {
479
+ return { message: "Unknown error: null" };
480
+ }
481
+ if (error === void 0) {
482
+ return { message: "Unknown error: undefined" };
483
+ }
484
+ if (typeof error === "number" || typeof error === "boolean" || typeof error === "bigint") {
485
+ return { message: String(error) };
486
+ }
487
+ if (typeof error === "object") {
488
+ try {
489
+ return { message: JSON.stringify(error) };
490
+ } catch {
491
+ return { message: "Unknown error" };
492
+ }
493
+ }
494
+ return { message: "Unknown error" };
495
+ }
496
+ function truncateName(name, maxLength = MAX_NAME_LENGTH) {
497
+ if (typeof name !== "string" || name.trim() === "") {
498
+ return "unnamed";
499
+ }
500
+ const trimmed = name.trim();
501
+ if (trimmed.length <= maxLength) {
502
+ return trimmed;
503
+ }
504
+ const ellipsis = "...";
505
+ const head = Math.max(0, maxLength - ellipsis.length);
506
+ return `${trimmed.slice(0, head)}${ellipsis}`;
507
+ }
508
+ function warn(message, error) {
509
+ const base = `[AgentInspect] ${message}`;
510
+ if (error === void 0) {
511
+ console.warn(base);
512
+ return;
513
+ }
514
+ console.warn(`${base}: ${formatError(error).message}`);
515
+ }
516
+
517
+ // packages/core/src/storage.ts
518
+ function serializeEvent(event) {
519
+ try {
520
+ return JSON.stringify(event);
521
+ } catch {
522
+ return "";
523
+ }
524
+ }
525
+
526
+ // packages/core/src/trace-event-safety.ts
527
+ var DEFAULT_MAX_METADATA_VALUE_LENGTH = 2e3;
528
+ var DEFAULT_MAX_PREVIEW_LENGTH = 500;
529
+ var DEFAULT_MAX_EVENT_BYTES = 65536;
530
+ function isRecord3(value) {
531
+ return typeof value === "object" && value !== null && !Array.isArray(value);
532
+ }
533
+ function isPreviewKey(key) {
534
+ return key.toLowerCase().includes("preview");
535
+ }
536
+ function truncateString(value, maxLen) {
537
+ if (maxLen <= 0) return "\u2026";
538
+ if (value.length <= maxLen) return value;
539
+ return `${value.slice(0, maxLen)}\u2026`;
540
+ }
541
+ function byteLength(text) {
542
+ return Buffer.byteLength(text, "utf8");
543
+ }
544
+ function resolveTraceSafetyOptions(options) {
545
+ const redact = options?.redact;
546
+ let redactEnabled = true;
547
+ let redactionRules;
548
+ if (redact === false) {
549
+ redactEnabled = false;
550
+ } else if (redact === true || redact === void 0) {
551
+ redactEnabled = true;
552
+ } else if (isRecord3(redact)) {
553
+ redactEnabled = true;
554
+ redactionRules = redact.rules;
555
+ }
556
+ const profile = options?.redactionProfile ?? "local";
557
+ const resolvedProfile = resolveRedactionProfile(profile);
558
+ const userMaxMetadata = typeof options?.maxMetadataValueLength === "number" && Number.isFinite(options.maxMetadataValueLength) && options.maxMetadataValueLength >= 0 ? Math.floor(options.maxMetadataValueLength) : void 0;
559
+ const userMaxPreview = typeof options?.maxPreviewLength === "number" && Number.isFinite(options.maxPreviewLength) && options.maxPreviewLength >= 0 ? Math.floor(options.maxPreviewLength) : void 0;
560
+ let maxMetadataValueLength = userMaxMetadata ?? DEFAULT_MAX_METADATA_VALUE_LENGTH;
561
+ let maxPreviewLength = userMaxPreview ?? DEFAULT_MAX_PREVIEW_LENGTH;
562
+ if (redactEnabled && profile !== "local") {
563
+ const capped = applyProfileMetadataCaps(
564
+ maxMetadataValueLength,
565
+ maxPreviewLength,
566
+ resolvedProfile
567
+ );
568
+ maxMetadataValueLength = capped.maxMetadataValueLength;
569
+ maxPreviewLength = capped.maxPreviewLength;
570
+ }
571
+ return {
572
+ redactEnabled,
573
+ redactionRules,
574
+ redactionProfile: profile,
575
+ profileExtraKeys: redactEnabled ? resolvedProfile.extraKeys : [],
576
+ maxMetadataValueLength,
577
+ maxPreviewLength,
578
+ maxEventBytes: typeof options?.maxEventBytes === "number" && Number.isFinite(options.maxEventBytes) && options.maxEventBytes > 0 ? Math.floor(options.maxEventBytes) : DEFAULT_MAX_EVENT_BYTES
579
+ };
580
+ }
581
+ function boundMetadataValue(key, value, opts, seen, depth) {
582
+ if (depth > 32) return "[MaxDepth]";
583
+ if (typeof value === "bigint") {
584
+ return `${value.toString()}n`;
585
+ }
586
+ if (typeof value === "function") {
587
+ return "[Function]";
588
+ }
589
+ if (typeof value === "symbol") {
590
+ return "[Symbol]";
591
+ }
592
+ if (typeof value === "number" && !Number.isFinite(value)) {
593
+ return String(value);
594
+ }
595
+ if (value === void 0) {
596
+ return null;
597
+ }
598
+ if (value === null || typeof value !== "object") {
599
+ if (typeof value === "string") {
600
+ const max = isPreviewKey(key) ? opts.maxPreviewLength : opts.maxMetadataValueLength;
601
+ return truncateString(value, max);
602
+ }
603
+ return value;
604
+ }
605
+ if (seen.has(value)) return "[Circular]";
606
+ seen.add(value);
607
+ if (Array.isArray(value)) {
608
+ const maxItems = 50;
609
+ const out2 = value.slice(0, maxItems).map(
610
+ (item, index) => boundMetadataValue(String(index), item, opts, seen, depth + 1)
611
+ );
612
+ if (value.length > maxItems) {
613
+ out2.push(`\u2026(+${value.length - maxItems} more)`);
614
+ }
615
+ return out2;
616
+ }
617
+ const record = value;
618
+ const out = {};
619
+ try {
620
+ for (const [k, v] of Object.entries(record)) {
621
+ out[k] = boundMetadataValue(k, v, opts, seen, depth + 1);
622
+ }
623
+ } catch {
624
+ return { truncated: true, reason: "metadataEnumerationFailed" };
625
+ }
626
+ return out;
627
+ }
628
+ function redactMetadata(metadata, opts) {
629
+ if (!opts.redactEnabled) return { ...metadata };
630
+ const redactor = new Redactor({
631
+ rules: opts.redactionRules,
632
+ extraKeys: opts.profileExtraKeys
633
+ });
634
+ return redactor.redactRecord(metadata);
635
+ }
636
+ function prepareMetadataForDisk(metadata, opts) {
637
+ try {
638
+ const preBounded = boundMetadataValue(
639
+ "metadata",
640
+ metadata,
641
+ opts,
642
+ /* @__PURE__ */ new WeakSet(),
643
+ 0
644
+ );
645
+ const redacted = redactMetadata(
646
+ isRecord3(preBounded) ? preBounded : {},
647
+ opts
648
+ );
649
+ const bounded = boundMetadataValue(
650
+ "metadata",
651
+ redacted,
652
+ opts,
653
+ /* @__PURE__ */ new WeakSet(),
654
+ 0
655
+ );
656
+ return isRecord3(bounded) ? bounded : {};
657
+ } catch {
658
+ return { truncated: true, reason: "metadataPreparationFailed" };
659
+ }
660
+ }
661
+ function truncateErrorStack(event, maxLen) {
662
+ if (event.event !== "run_completed" && event.event !== "step_completed") {
663
+ return event;
664
+ }
665
+ if (!event.error?.stack || typeof event.error.stack !== "string") {
666
+ return event;
667
+ }
668
+ return {
669
+ ...event,
670
+ error: {
671
+ ...event.error,
672
+ stack: truncateString(event.error.stack, maxLen)
673
+ }
674
+ };
675
+ }
676
+ function replaceMetadataWithTruncationMarker(event, originalApproxBytes) {
677
+ const marker = {
678
+ truncated: true,
679
+ reason: "maxEventBytes",
680
+ originalApproxBytes
681
+ };
682
+ if (event.event === "run_started") {
683
+ return { ...event, metadata: marker };
684
+ }
685
+ if (event.event === "step_started") {
686
+ return { ...event, metadata: marker };
687
+ }
688
+ return event;
689
+ }
690
+ function shrinkMetadataLimits(opts, factor) {
691
+ return {
692
+ ...opts,
693
+ maxMetadataValueLength: Math.max(32, Math.floor(opts.maxMetadataValueLength * factor)),
694
+ maxPreviewLength: Math.max(16, Math.floor(opts.maxPreviewLength * factor))
695
+ };
696
+ }
697
+ function applyMetadataToEvent(event, metadata) {
698
+ if (event.event === "run_started") {
699
+ return { ...event, metadata };
700
+ }
701
+ if (event.event === "step_started") {
702
+ return { ...event, metadata };
703
+ }
704
+ return event;
705
+ }
706
+ function eventHasMetadata(event) {
707
+ return (event.event === "run_started" || event.event === "step_started") && event.metadata !== void 0;
708
+ }
709
+ function getEventMetadata(event) {
710
+ if (event.event === "run_started" || event.event === "step_started") {
711
+ return event.metadata;
712
+ }
713
+ return void 0;
714
+ }
715
+ function prepareTraceEventForDisk(event, opts) {
716
+ try {
717
+ let working = { ...event };
718
+ const rawMetadata = getEventMetadata(working);
719
+ if (rawMetadata !== void 0) {
720
+ const safe = prepareMetadataForDisk(rawMetadata, opts);
721
+ working = applyMetadataToEvent(working, safe);
722
+ }
723
+ let serialized = serializeEvent(working);
724
+ if (serialized === "") {
725
+ return working;
726
+ }
727
+ let bytes = byteLength(serialized);
728
+ if (bytes <= opts.maxEventBytes) {
729
+ return working;
730
+ }
731
+ if (rawMetadata !== void 0) {
732
+ for (const factor of [0.5, 0.25, 0.1]) {
733
+ const tighter = shrinkMetadataLimits(opts, factor);
734
+ const shrunk = prepareMetadataForDisk(rawMetadata, tighter);
735
+ working = applyMetadataToEvent(working, shrunk);
736
+ serialized = serializeEvent(working);
737
+ if (serialized !== "" && byteLength(serialized) <= opts.maxEventBytes) {
738
+ return working;
739
+ }
740
+ }
741
+ working = replaceMetadataWithTruncationMarker(working, bytes);
742
+ serialized = serializeEvent(working);
743
+ if (serialized !== "" && byteLength(serialized) <= opts.maxEventBytes) {
744
+ return working;
745
+ }
746
+ }
747
+ working = truncateErrorStack(working, Math.min(opts.maxMetadataValueLength, 500));
748
+ serialized = serializeEvent(working);
749
+ if (serialized !== "" && byteLength(serialized) <= opts.maxEventBytes) {
750
+ return working;
751
+ }
752
+ if (eventHasMetadata(working)) {
753
+ working = replaceMetadataWithTruncationMarker(working, bytes);
754
+ serialized = serializeEvent(working);
755
+ if (serialized !== "" && byteLength(serialized) <= opts.maxEventBytes) {
756
+ return working;
757
+ }
758
+ if (working.event === "run_started") {
759
+ const { metadata: _meta, ...rest } = working;
760
+ working = rest;
761
+ } else if (working.event === "step_started") {
762
+ const { metadata: _meta, ...rest } = working;
763
+ working = rest;
764
+ }
765
+ }
766
+ return working;
767
+ } catch {
768
+ if (event.event === "run_started" || event.event === "step_started") {
769
+ return applyMetadataToEvent(event, {
770
+ truncated: true,
771
+ reason: "prepareTraceEventFailed"
772
+ });
773
+ }
774
+ return event;
775
+ }
776
+ }
777
+ function safeGet(record, key) {
778
+ try {
779
+ return record[key];
780
+ } catch {
781
+ return void 0;
782
+ }
783
+ }
784
+ function optionalBoundedString(value, _key, opts) {
785
+ if (typeof value !== "string") return void 0;
786
+ return truncateString(value, opts.maxMetadataValueLength);
787
+ }
788
+ function requiredBoundedString(value, key, opts) {
789
+ const out = optionalBoundedString(value, key, opts);
790
+ return out && out.length > 0 ? out : void 0;
791
+ }
792
+ function preparePersistedSummaryForDisk(key, value, opts) {
793
+ try {
794
+ const redactor = new Redactor({
795
+ rules: opts.redactionRules,
796
+ extraKeys: opts.profileExtraKeys
797
+ });
798
+ const redacted = opts.redactEnabled ? redactor.redactValue(key, value) : value;
799
+ return boundMetadataValue(key, redacted, opts, /* @__PURE__ */ new WeakSet(), 0);
800
+ } catch {
801
+ return { truncated: true, reason: "summaryPreparationFailed" };
802
+ }
803
+ }
804
+ function preparePersistedErrorForDisk(value, opts) {
805
+ if (!isRecord3(value)) return void 0;
806
+ try {
807
+ const redactor = new Redactor({
808
+ rules: opts.redactionRules,
809
+ extraKeys: opts.profileExtraKeys
810
+ });
811
+ const rawMessage = safeGet(value, "message");
812
+ const redactedMessage = opts.redactEnabled ? redactor.redactValue("message", rawMessage) : rawMessage;
813
+ const boundedMessage = boundMetadataValue(
814
+ "message",
815
+ redactedMessage,
816
+ opts,
817
+ /* @__PURE__ */ new WeakSet(),
818
+ 0
819
+ );
820
+ const message = typeof boundedMessage === "string" && boundedMessage.length > 0 ? boundedMessage : "Unknown error";
821
+ const out = { message };
822
+ const name = optionalBoundedString(safeGet(value, "name"), "name", opts);
823
+ const code = optionalBoundedString(safeGet(value, "code"), "code", opts);
824
+ if (name !== void 0) out.name = name;
825
+ if (code !== void 0) out.code = code;
826
+ return out;
827
+ } catch {
828
+ return { message: "Error preparation failed" };
829
+ }
830
+ }
831
+ function prepareTokenUsage(value) {
832
+ if (!isRecord3(value)) return void 0;
833
+ const out = {};
834
+ for (const key of ["input", "output", "total", "cached"]) {
835
+ const item = safeGet(value, key);
836
+ if (typeof item === "number" && Number.isFinite(item) && item >= 0) {
837
+ out[key] = item;
838
+ }
839
+ }
840
+ return Object.keys(out).length > 0 ? out : void 0;
841
+ }
842
+ function prepareTraceContext(value, opts) {
843
+ if (!isRecord3(value)) return void 0;
844
+ const out = {};
845
+ const traceId = optionalBoundedString(safeGet(value, "traceId"), "traceId", opts);
846
+ const spanId = optionalBoundedString(safeGet(value, "spanId"), "spanId", opts);
847
+ const parentSpanId = optionalBoundedString(
848
+ safeGet(value, "parentSpanId"),
849
+ "parentSpanId",
850
+ opts
851
+ );
852
+ if (traceId !== void 0) out.traceId = traceId;
853
+ if (spanId !== void 0) out.spanId = spanId;
854
+ if (parentSpanId !== void 0) out.parentSpanId = parentSpanId;
855
+ return Object.keys(out).length > 0 ? out : void 0;
856
+ }
857
+ function serializedPersistedEvent(event) {
858
+ try {
859
+ return JSON.stringify(event);
860
+ } catch {
861
+ return void 0;
862
+ }
863
+ }
864
+ function persistedEventByteLength(event) {
865
+ const serialized = serializedPersistedEvent(event);
866
+ return serialized === void 0 ? void 0 : byteLength(serialized);
867
+ }
868
+ function minimalPersistedEvent(event, opts, originalApproxBytes) {
869
+ return {
870
+ schemaVersion: "0.2",
871
+ eventId: truncateString(event.eventId, 128),
872
+ runId: truncateString(event.runId, 128),
873
+ kind: event.kind,
874
+ name: truncateString(event.name, 128),
875
+ ...event.status !== void 0 ? { status: event.status } : {},
876
+ timestamp: truncateString(event.timestamp, 128),
877
+ confidence: event.confidence,
878
+ source: {
879
+ type: event.source.type,
880
+ ...event.source.name !== void 0 ? { name: truncateString(event.source.name, 128) } : {},
881
+ ...event.source.version !== void 0 ? { version: truncateString(event.source.version, 128) } : {}
882
+ },
883
+ attributes: {
884
+ truncated: true,
885
+ reason: "maxEventBytes",
886
+ originalApproxBytes,
887
+ maxEventBytes: opts.maxEventBytes
888
+ }
889
+ };
890
+ }
891
+ function tinyPersistedEvent(event) {
892
+ return {
893
+ schemaVersion: "0.2",
894
+ eventId: truncateString(event.eventId, 32),
895
+ runId: truncateString(event.runId, 32),
896
+ kind: event.kind,
897
+ name: truncateString(event.name, 32),
898
+ timestamp: truncateString(event.timestamp, 32),
899
+ confidence: event.confidence,
900
+ source: { type: event.source.type },
901
+ attributes: { truncated: true, reason: "maxEventBytes" }
902
+ };
903
+ }
904
+ function enforcePersistedEventSize(event, opts) {
905
+ const bytes = persistedEventByteLength(event);
906
+ if (bytes === void 0) return void 0;
907
+ if (bytes <= opts.maxEventBytes) return event;
908
+ const minimal = minimalPersistedEvent(event, opts, bytes);
909
+ const minimalBytes = persistedEventByteLength(minimal);
910
+ if (minimalBytes !== void 0 && minimalBytes <= opts.maxEventBytes) {
911
+ return minimal;
912
+ }
913
+ const tiny = tinyPersistedEvent(event);
914
+ return isPersistedInspectEvent(tiny) ? tiny : void 0;
915
+ }
916
+ function preparePersistedInspectEventForWrite(value, opts = resolveTraceSafetyOptions()) {
917
+ try {
918
+ if (!isRecord3(value)) return void 0;
919
+ const source = safeGet(value, "source");
920
+ if (!isRecord3(source)) return void 0;
921
+ const candidate = {
922
+ schemaVersion: safeGet(value, "schemaVersion"),
923
+ eventId: requiredBoundedString(safeGet(value, "eventId"), "eventId", opts) ?? "",
924
+ runId: requiredBoundedString(safeGet(value, "runId"), "runId", opts) ?? "",
925
+ kind: safeGet(value, "kind"),
926
+ name: requiredBoundedString(safeGet(value, "name"), "name", opts) ?? "",
927
+ timestamp: requiredBoundedString(safeGet(value, "timestamp"), "timestamp", opts) ?? "",
928
+ confidence: safeGet(value, "confidence"),
929
+ source: {
930
+ type: safeGet(source, "type")
931
+ }
932
+ };
933
+ const parentId = requiredBoundedString(safeGet(value, "parentId"), "parentId", opts);
934
+ const status = safeGet(value, "status");
935
+ const startedAt = optionalBoundedString(safeGet(value, "startedAt"), "startedAt", opts);
936
+ const endedAt = optionalBoundedString(safeGet(value, "endedAt"), "endedAt", opts);
937
+ const durationMs2 = safeGet(value, "durationMs");
938
+ const sourceName = optionalBoundedString(safeGet(source, "name"), "name", opts);
939
+ const sourceVersion = optionalBoundedString(safeGet(source, "version"), "version", opts);
940
+ if (parentId !== void 0) candidate.parentId = parentId;
941
+ if (status === "running" || status === "ok" || status === "error" || status === "unknown") {
942
+ candidate.status = status;
943
+ }
944
+ if (startedAt !== void 0) candidate.startedAt = startedAt;
945
+ if (endedAt !== void 0) candidate.endedAt = endedAt;
946
+ if (typeof durationMs2 === "number" && Number.isFinite(durationMs2) && durationMs2 >= 0) {
947
+ candidate.durationMs = durationMs2;
948
+ }
949
+ if (sourceName !== void 0) candidate.source.name = sourceName;
950
+ if (sourceVersion !== void 0) candidate.source.version = sourceVersion;
951
+ const attributes = safeGet(value, "attributes");
952
+ if (isRecord3(attributes)) {
953
+ candidate.attributes = prepareMetadataForDisk(attributes, opts);
954
+ }
955
+ if (safeGet(value, "inputSummary") !== void 0) {
956
+ candidate.inputSummary = preparePersistedSummaryForDisk(
957
+ "input",
958
+ safeGet(value, "inputSummary"),
959
+ opts
960
+ );
961
+ }
962
+ if (safeGet(value, "outputSummary") !== void 0) {
963
+ candidate.outputSummary = preparePersistedSummaryForDisk(
964
+ "output",
965
+ safeGet(value, "outputSummary"),
966
+ opts
967
+ );
968
+ }
969
+ const error = preparePersistedErrorForDisk(safeGet(value, "error"), opts);
970
+ if (error !== void 0) candidate.error = error;
971
+ const tokenUsage = prepareTokenUsage(safeGet(value, "tokenUsage"));
972
+ if (tokenUsage !== void 0) candidate.tokenUsage = tokenUsage;
973
+ const trace = prepareTraceContext(safeGet(value, "trace"), opts);
974
+ if (trace !== void 0) candidate.trace = trace;
975
+ if (!isPersistedInspectEvent(candidate)) return void 0;
976
+ return enforcePersistedEventSize(candidate, opts);
977
+ } catch {
978
+ return void 0;
979
+ }
980
+ }
981
+
982
+ // packages/core/src/context.ts
983
+ var storage = new async_hooks.AsyncLocalStorage();
984
+ function toPublicContext(ctx) {
985
+ return {
986
+ runId: ctx.runId,
987
+ runName: ctx.runName,
988
+ traceDir: ctx.traceDir,
989
+ silent: ctx.silent,
990
+ metadata: ctx.metadata
991
+ };
992
+ }
993
+ function invoke(fn) {
994
+ return new Promise((resolve, reject) => {
995
+ try {
996
+ Promise.resolve(fn()).then(resolve, reject);
997
+ } catch (e) {
998
+ reject(e);
999
+ }
1000
+ });
1001
+ }
1002
+ function getCurrentContext() {
1003
+ try {
1004
+ const s = storage.getStore();
1005
+ if (!s) return void 0;
1006
+ return toPublicContext(s);
1007
+ } catch {
1008
+ return void 0;
1009
+ }
1010
+ }
1011
+ function getCurrentRunId() {
1012
+ try {
1013
+ return storage.getStore()?.runId;
1014
+ } catch {
1015
+ return void 0;
1016
+ }
1017
+ }
1018
+ function getCurrentCorrelationMetadata() {
1019
+ try {
1020
+ return extractCorrelationMetadata(storage.getStore()?.metadata);
1021
+ } catch {
1022
+ return void 0;
1023
+ }
1024
+ }
1025
+ function getCurrentRunName() {
1026
+ try {
1027
+ return storage.getStore()?.runName;
1028
+ } catch {
1029
+ return void 0;
1030
+ }
1031
+ }
1032
+ function getCurrentStepId() {
1033
+ try {
1034
+ return storage.getStore()?.currentStepId;
1035
+ } catch {
1036
+ return void 0;
1037
+ }
1038
+ }
1039
+ function getParentStepId() {
1040
+ return getCurrentStepId();
1041
+ }
1042
+ function getCurrentDepth() {
1043
+ try {
1044
+ const d = storage.getStore()?.currentDepth;
1045
+ return typeof d === "number" && Number.isFinite(d) ? d : 0;
1046
+ } catch {
1047
+ return 0;
1048
+ }
1049
+ }
1050
+ function hasActiveContext() {
1051
+ try {
1052
+ return storage.getStore() !== void 0;
1053
+ } catch {
1054
+ return false;
1055
+ }
1056
+ }
1057
+ function getTraceDirFromContext() {
1058
+ try {
1059
+ return storage.getStore()?.traceDir;
1060
+ } catch {
1061
+ return void 0;
1062
+ }
1063
+ }
1064
+ function isSilentContext() {
1065
+ try {
1066
+ const s = storage.getStore();
1067
+ return s ? s.silent : false;
1068
+ } catch {
1069
+ return false;
1070
+ }
1071
+ }
1072
+ function getTraceSafetyFromContext() {
1073
+ try {
1074
+ return storage.getStore()?.traceSafety;
1075
+ } catch {
1076
+ return void 0;
1077
+ }
1078
+ }
1079
+ function runWithContext(context, fn, traceSafety = resolveTraceSafetyOptions()) {
1080
+ const runtime = {
1081
+ runId: context.runId,
1082
+ runName: context.runName,
1083
+ traceDir: context.traceDir,
1084
+ silent: context.silent,
1085
+ metadata: context.metadata,
1086
+ traceSafety,
1087
+ currentDepth: 0
1088
+ };
1089
+ return new Promise((resolve, reject) => {
1090
+ storage.run(runtime, () => {
1091
+ try {
1092
+ Promise.resolve(fn()).then(resolve, reject);
1093
+ } catch (e) {
1094
+ reject(e);
1095
+ }
1096
+ });
1097
+ });
1098
+ }
1099
+ function runWithStepContext(stepId, fn) {
1100
+ let parent;
1101
+ try {
1102
+ parent = storage.getStore();
1103
+ } catch {
1104
+ parent = void 0;
1105
+ }
1106
+ if (!parent) {
1107
+ return invoke(fn);
1108
+ }
1109
+ const derived = {
1110
+ runId: parent.runId,
1111
+ runName: parent.runName,
1112
+ traceDir: parent.traceDir,
1113
+ silent: parent.silent,
1114
+ metadata: parent.metadata,
1115
+ traceSafety: parent.traceSafety,
1116
+ currentStepId: stepId,
1117
+ currentDepth: parent.currentDepth + 1
1118
+ };
1119
+ return new Promise((resolve, reject) => {
1120
+ storage.run(derived, () => {
1121
+ try {
1122
+ Promise.resolve(fn()).then(resolve, reject);
1123
+ } catch (e) {
1124
+ reject(e);
1125
+ }
1126
+ });
1127
+ });
1128
+ }
1129
+ function invoke2(fn) {
1130
+ return new Promise((resolve, reject) => {
1131
+ try {
1132
+ Promise.resolve(fn()).then(resolve, reject);
1133
+ } catch (error) {
1134
+ reject(error);
1135
+ }
1136
+ });
1137
+ }
1138
+ function normalizeError(error) {
1139
+ if (error instanceof Error && error.message.trim() !== "") {
1140
+ return error.message;
1141
+ }
1142
+ if (typeof error === "string" && error.trim() !== "") {
1143
+ return error;
1144
+ }
1145
+ return "Unknown inspector runtime error";
1146
+ }
1147
+ var runtimeSequence = 0;
1148
+ function createRuntimeId() {
1149
+ runtimeSequence += 1;
1150
+ return `runtime_${runtimeSequence.toString(36)}`;
1151
+ }
1152
+ function publicContext(store) {
1153
+ return {
1154
+ runtimeId: store.runtimeId,
1155
+ runId: store.runId,
1156
+ runName: store.runName,
1157
+ traceDir: store.traceDir,
1158
+ silent: store.silent,
1159
+ metadata: store.metadata
1160
+ };
1161
+ }
1162
+ function createInspectorRuntime(options = {}) {
1163
+ const storage2 = new async_hooks.AsyncLocalStorage();
1164
+ const enabled = options.enabled ?? true;
1165
+ const runtimeId = createRuntimeId();
1166
+ const traceSafety = options.traceSafety ?? resolveTraceSafetyOptions();
1167
+ let closed = false;
1168
+ let instrumentationErrors = 0;
1169
+ let lastInstrumentationError;
1170
+ function recordInstrumentationError(error) {
1171
+ instrumentationErrors += 1;
1172
+ lastInstrumentationError = normalizeError(error);
1173
+ }
1174
+ function currentStore() {
1175
+ try {
1176
+ return storage2.getStore();
1177
+ } catch (error) {
1178
+ recordInstrumentationError(error);
1179
+ return void 0;
1180
+ }
1181
+ }
1182
+ const runtime = {
1183
+ runtimeId,
1184
+ enabled,
1185
+ runWithContext(context, fn) {
1186
+ if (!enabled) return invoke2(fn);
1187
+ const store = {
1188
+ runtimeId,
1189
+ runId: context.runId,
1190
+ runName: context.runName,
1191
+ traceDir: context.traceDir,
1192
+ silent: context.silent,
1193
+ metadata: context.metadata,
1194
+ traceSafety,
1195
+ currentDepth: 0
1196
+ };
1197
+ return new Promise((resolve, reject) => {
1198
+ storage2.run(store, () => {
1199
+ invoke2(fn).then(resolve, reject);
1200
+ });
1201
+ });
1202
+ },
1203
+ runWithStepContext(stepId, fn) {
1204
+ if (!enabled) return invoke2(fn);
1205
+ const parent = currentStore();
1206
+ if (!parent) return invoke2(fn);
1207
+ const store = {
1208
+ runtimeId,
1209
+ runId: parent.runId,
1210
+ runName: parent.runName,
1211
+ traceDir: parent.traceDir,
1212
+ silent: parent.silent,
1213
+ metadata: parent.metadata,
1214
+ traceSafety: parent.traceSafety,
1215
+ currentStepId: stepId,
1216
+ currentDepth: parent.currentDepth + 1
1217
+ };
1218
+ return new Promise((resolve, reject) => {
1219
+ storage2.run(store, () => {
1220
+ invoke2(fn).then(resolve, reject);
1221
+ });
1222
+ });
1223
+ },
1224
+ getCurrentContext() {
1225
+ const store = currentStore();
1226
+ return store ? publicContext(store) : void 0;
1227
+ },
1228
+ getCurrentCorrelationMetadata() {
1229
+ return extractCorrelationMetadata(currentStore()?.metadata);
1230
+ },
1231
+ getCurrentStepId() {
1232
+ return currentStore()?.currentStepId;
1233
+ },
1234
+ getCurrentDepth() {
1235
+ const depth = currentStore()?.currentDepth;
1236
+ return typeof depth === "number" && Number.isFinite(depth) ? depth : 0;
1237
+ },
1238
+ getTraceSafety() {
1239
+ return traceSafety;
1240
+ },
1241
+ async write(event) {
1242
+ if (!enabled || closed || !options.writer) return;
1243
+ try {
1244
+ const safe = preparePersistedInspectEventForWrite(event, traceSafety);
1245
+ if (safe === void 0) {
1246
+ recordInstrumentationError("Invalid persisted inspect event");
1247
+ return;
1248
+ }
1249
+ await options.writer.write(safe);
1250
+ } catch (error) {
1251
+ recordInstrumentationError(error);
1252
+ }
1253
+ },
1254
+ async flush() {
1255
+ if (!options.writer) return;
1256
+ try {
1257
+ await options.writer.flush?.();
1258
+ } catch (error) {
1259
+ recordInstrumentationError(error);
1260
+ }
1261
+ },
1262
+ async close() {
1263
+ if (closed) return;
1264
+ try {
1265
+ await options.writer?.close?.();
1266
+ } catch (error) {
1267
+ recordInstrumentationError(error);
1268
+ } finally {
1269
+ closed = true;
1270
+ }
1271
+ },
1272
+ getDiagnostics() {
1273
+ const diagnostics = {
1274
+ instrumentationErrors
1275
+ };
1276
+ if (lastInstrumentationError !== void 0) {
1277
+ diagnostics.lastInstrumentationError = lastInstrumentationError;
1278
+ }
1279
+ const writerStats = options.writer?.getStats?.();
1280
+ if (writerStats !== void 0) {
1281
+ diagnostics.writerStats = writerStats;
1282
+ }
1283
+ return diagnostics;
1284
+ }
1285
+ };
1286
+ return runtime;
1287
+ }
1288
+
1289
+ // packages/core/src/inspector.ts
1290
+ function normalizeName(name, fallback) {
1291
+ if (typeof name !== "string" || name.trim() === "") return fallback;
1292
+ return truncateName(name.trim(), 100);
1293
+ }
1294
+ function nowIso() {
1295
+ return (/* @__PURE__ */ new Date()).toISOString();
1296
+ }
1297
+ function durationMs(startedAt, endedAt) {
1298
+ return Math.max(0, Date.parse(endedAt) - Date.parse(startedAt));
1299
+ }
1300
+ function mergeMetadata(base, override) {
1301
+ if (base === void 0 && override === void 0) return void 0;
1302
+ return {
1303
+ ...base ?? {},
1304
+ ...override ?? {}
1305
+ };
1306
+ }
1307
+ function toPersistedError(error) {
1308
+ if (error instanceof Error) {
1309
+ return {
1310
+ name: error.name,
1311
+ message: error.message
1312
+ };
1313
+ }
1314
+ if (typeof error === "string") {
1315
+ return { message: error };
1316
+ }
1317
+ return { message: "Unknown error" };
1318
+ }
1319
+ function summarizeValue(value) {
1320
+ if (value === null) return { type: "null" };
1321
+ if (Array.isArray(value)) return { type: "array", length: value.length };
1322
+ if (typeof value === "string") return { type: "string", length: value.length };
1323
+ if (typeof value === "number") {
1324
+ return { type: "number", finite: Number.isFinite(value) };
1325
+ }
1326
+ if (typeof value === "bigint") return { type: "bigint" };
1327
+ if (typeof value === "boolean") return { type: "boolean" };
1328
+ if (typeof value === "undefined") return { type: "undefined" };
1329
+ if (typeof value === "symbol") return { type: "symbol" };
1330
+ if (typeof value === "function") {
1331
+ return { type: "function", name: value.name || void 0 };
1332
+ }
1333
+ if (typeof value === "object") {
1334
+ const record = value;
1335
+ let keyCount;
1336
+ try {
1337
+ keyCount = Object.keys(record).length;
1338
+ } catch {
1339
+ keyCount = void 0;
1340
+ }
1341
+ return {
1342
+ type: "object",
1343
+ constructorName: value?.constructor?.name,
1344
+ ...keyCount !== void 0 ? { keyCount } : {}
1345
+ };
1346
+ }
1347
+ return { type: typeof value };
1348
+ }
1349
+ function summarizeCapturedError(error) {
1350
+ if (error instanceof Error) {
1351
+ return { type: "error", name: error.name };
1352
+ }
1353
+ return summarizeValue(error);
1354
+ }
1355
+ function stepTypeToKind(type) {
1356
+ switch (type) {
1357
+ case "llm":
1358
+ return "LLM";
1359
+ case "tool":
1360
+ return "TOOL";
1361
+ case "decision":
1362
+ return "DECISION";
1363
+ case "run":
1364
+ return "RUN";
1365
+ default:
1366
+ return "LOGIC";
1367
+ }
1368
+ }
1369
+ function createInspector(options = {}) {
1370
+ const traceSafety = options.traceSafety ?? resolveTraceSafetyOptions({
1371
+ redactionProfile: options.redactionProfile
1372
+ });
1373
+ const runtime = createInspectorRuntime({
1374
+ enabled: options.enabled,
1375
+ writer: options.writer,
1376
+ traceSafety
1377
+ });
1378
+ async function write(event) {
1379
+ const safe = preparePersistedInspectEventForWrite(event, traceSafety);
1380
+ if (safe !== void 0) {
1381
+ await runtime.write(safe);
1382
+ }
1383
+ }
1384
+ async function run(name, fn, runOptions = {}) {
1385
+ if (typeof fn !== "function") {
1386
+ throw new TypeError("inspector.run requires `fn` to be a function");
1387
+ }
1388
+ if (options.enabled === false) {
1389
+ return Promise.resolve(fn());
1390
+ }
1391
+ const runName = normalizeName(name, "unnamed-run");
1392
+ const runId = runOptions.runId ?? createRunId();
1393
+ const traceDir = runOptions.traceDir ?? options.traceDir ?? getDefaultTraceDir();
1394
+ const metadata = mergeMetadata(options.metadata, runOptions.metadata);
1395
+ const startedAt = nowIso();
1396
+ return runtime.runWithContext(
1397
+ {
1398
+ runId,
1399
+ runName,
1400
+ traceDir,
1401
+ silent: runOptions.silent ?? options.silent ?? true,
1402
+ metadata
1403
+ },
1404
+ async () => {
1405
+ await write({
1406
+ schemaVersion: "0.2",
1407
+ eventId: `${runId}_started`,
1408
+ runId,
1409
+ kind: "RUN",
1410
+ name: runName,
1411
+ status: "running",
1412
+ timestamp: startedAt,
1413
+ startedAt,
1414
+ confidence: "explicit",
1415
+ source: { type: "manual", name: "createInspector" },
1416
+ attributes: {
1417
+ legacyEvent: "run_started",
1418
+ ...metadata !== void 0 ? { metadata } : {}
1419
+ }
1420
+ });
1421
+ try {
1422
+ const result = await Promise.resolve(fn());
1423
+ const endedAt = nowIso();
1424
+ await write({
1425
+ schemaVersion: "0.2",
1426
+ eventId: `${runId}_completed`,
1427
+ runId,
1428
+ kind: "RUN",
1429
+ name: runName,
1430
+ status: "ok",
1431
+ timestamp: endedAt,
1432
+ endedAt,
1433
+ durationMs: durationMs(startedAt, endedAt),
1434
+ confidence: "explicit",
1435
+ source: { type: "manual", name: "createInspector" },
1436
+ attributes: { legacyEvent: "run_completed" },
1437
+ ...options.capture?.onSuccess === "metadata-only" ? { outputSummary: summarizeValue(result) } : {}
1438
+ });
1439
+ return result;
1440
+ } catch (error) {
1441
+ const endedAt = nowIso();
1442
+ await write({
1443
+ schemaVersion: "0.2",
1444
+ eventId: `${runId}_completed`,
1445
+ runId,
1446
+ kind: "RUN",
1447
+ name: runName,
1448
+ status: "error",
1449
+ timestamp: endedAt,
1450
+ endedAt,
1451
+ durationMs: durationMs(startedAt, endedAt),
1452
+ confidence: "explicit",
1453
+ source: { type: "manual", name: "createInspector" },
1454
+ attributes: { legacyEvent: "run_completed" },
1455
+ ...options.capture?.onError === "metadata-only" ? { outputSummary: summarizeCapturedError(error) } : {},
1456
+ error: toPersistedError(error)
1457
+ });
1458
+ throw error;
1459
+ }
1460
+ }
1461
+ );
1462
+ }
1463
+ async function step(name, fn, stepOptions = {}) {
1464
+ if (typeof fn !== "function") {
1465
+ throw new TypeError("inspector.step requires `fn` to be a function");
1466
+ }
1467
+ if (options.enabled === false || !runtime.getCurrentContext()) {
1468
+ return Promise.resolve(fn());
1469
+ }
1470
+ const context = runtime.getCurrentContext();
1471
+ const stepName = normalizeName(name, "unnamed-step");
1472
+ const stepId = createStepId();
1473
+ const parentId = runtime.getCurrentStepId();
1474
+ const stepType = stepOptions.type ?? "logic";
1475
+ const startedAt = nowIso();
1476
+ const attributes = {
1477
+ legacyEvent: "step_started",
1478
+ stepId,
1479
+ stepType,
1480
+ ...stepOptions.metadata !== void 0 ? { metadata: stepOptions.metadata } : {}
1481
+ };
1482
+ await write({
1483
+ schemaVersion: "0.2",
1484
+ eventId: `${stepId}_started`,
1485
+ runId: context.runId,
1486
+ ...parentId !== void 0 ? { parentId } : {},
1487
+ kind: stepTypeToKind(stepType),
1488
+ name: stepName,
1489
+ status: "running",
1490
+ timestamp: startedAt,
1491
+ startedAt,
1492
+ confidence: "explicit",
1493
+ source: { type: "manual", name: "createInspector" },
1494
+ attributes
1495
+ });
1496
+ return runtime.runWithStepContext(stepId, async () => {
1497
+ try {
1498
+ const result = await Promise.resolve(fn());
1499
+ const endedAt = nowIso();
1500
+ await write({
1501
+ schemaVersion: "0.2",
1502
+ eventId: `${stepId}_completed`,
1503
+ runId: context.runId,
1504
+ kind: stepTypeToKind(stepType),
1505
+ name: stepName,
1506
+ status: "ok",
1507
+ timestamp: endedAt,
1508
+ endedAt,
1509
+ durationMs: durationMs(startedAt, endedAt),
1510
+ confidence: "explicit",
1511
+ source: { type: "manual", name: "createInspector" },
1512
+ attributes: {
1513
+ legacyEvent: "step_completed",
1514
+ stepId,
1515
+ stepType
1516
+ },
1517
+ ...options.capture?.onSuccess === "metadata-only" ? { outputSummary: summarizeValue(result) } : {}
1518
+ });
1519
+ return result;
1520
+ } catch (error) {
1521
+ const endedAt = nowIso();
1522
+ await write({
1523
+ schemaVersion: "0.2",
1524
+ eventId: `${stepId}_completed`,
1525
+ runId: context.runId,
1526
+ kind: stepTypeToKind(stepType),
1527
+ name: stepName,
1528
+ status: "error",
1529
+ timestamp: endedAt,
1530
+ endedAt,
1531
+ durationMs: durationMs(startedAt, endedAt),
1532
+ confidence: "explicit",
1533
+ source: { type: "manual", name: "createInspector" },
1534
+ attributes: {
1535
+ legacyEvent: "step_completed",
1536
+ stepId,
1537
+ stepType
1538
+ },
1539
+ ...options.capture?.onError === "metadata-only" ? { outputSummary: summarizeCapturedError(error) } : {},
1540
+ error: toPersistedError(error)
1541
+ });
1542
+ throw error;
1543
+ }
1544
+ });
1545
+ }
1546
+ const inspector = {
1547
+ runtime,
1548
+ run,
1549
+ step,
1550
+ tool(name, fn, toolOptions) {
1551
+ const toolName = normalizeName(name, "unknown-tool");
1552
+ return step(`tool:${toolName}`, fn, {
1553
+ ...toolOptions,
1554
+ type: "tool",
1555
+ metadata: {
1556
+ ...toolOptions?.metadata ?? {},
1557
+ toolName
1558
+ }
1559
+ });
1560
+ },
1561
+ llm(name, fn, llmOptions) {
1562
+ const model = normalizeName(name, "unknown-model");
1563
+ return step(`llm:${model}`, fn, {
1564
+ ...llmOptions,
1565
+ type: "llm",
1566
+ metadata: {
1567
+ ...llmOptions?.metadata ?? {},
1568
+ model
1569
+ }
1570
+ });
1571
+ },
1572
+ observe(name, fn, observeOptions) {
1573
+ return async (...args) => step(name, () => Promise.resolve(fn(...args)), observeOptions);
1574
+ },
1575
+ getDiagnostics() {
1576
+ return runtime.getDiagnostics();
1577
+ },
1578
+ flush() {
1579
+ return runtime.flush();
1580
+ },
1581
+ close() {
1582
+ return runtime.close();
1583
+ }
1584
+ };
1585
+ return inspector;
1586
+ }
1587
+
1588
+ // node_modules/.pnpm/chalk@5.6.2/node_modules/chalk/source/vendor/ansi-styles/index.js
1589
+ var ANSI_BACKGROUND_OFFSET = 10;
1590
+ var wrapAnsi16 = (offset = 0) => (code) => `\x1B[${code + offset}m`;
1591
+ var wrapAnsi256 = (offset = 0) => (code) => `\x1B[${38 + offset};5;${code}m`;
1592
+ var wrapAnsi16m = (offset = 0) => (red, green, blue) => `\x1B[${38 + offset};2;${red};${green};${blue}m`;
1593
+ var styles = {
1594
+ modifier: {
1595
+ reset: [0, 0],
1596
+ // 21 isn't widely supported and 22 does the same thing
1597
+ bold: [1, 22],
1598
+ dim: [2, 22],
1599
+ italic: [3, 23],
1600
+ underline: [4, 24],
1601
+ overline: [53, 55],
1602
+ inverse: [7, 27],
1603
+ hidden: [8, 28],
1604
+ strikethrough: [9, 29]
1605
+ },
1606
+ color: {
1607
+ black: [30, 39],
1608
+ red: [31, 39],
1609
+ green: [32, 39],
1610
+ yellow: [33, 39],
1611
+ blue: [34, 39],
1612
+ magenta: [35, 39],
1613
+ cyan: [36, 39],
1614
+ white: [37, 39],
1615
+ // Bright color
1616
+ blackBright: [90, 39],
1617
+ gray: [90, 39],
1618
+ // Alias of `blackBright`
1619
+ grey: [90, 39],
1620
+ // Alias of `blackBright`
1621
+ redBright: [91, 39],
1622
+ greenBright: [92, 39],
1623
+ yellowBright: [93, 39],
1624
+ blueBright: [94, 39],
1625
+ magentaBright: [95, 39],
1626
+ cyanBright: [96, 39],
1627
+ whiteBright: [97, 39]
1628
+ },
1629
+ bgColor: {
1630
+ bgBlack: [40, 49],
1631
+ bgRed: [41, 49],
1632
+ bgGreen: [42, 49],
1633
+ bgYellow: [43, 49],
1634
+ bgBlue: [44, 49],
1635
+ bgMagenta: [45, 49],
1636
+ bgCyan: [46, 49],
1637
+ bgWhite: [47, 49],
1638
+ // Bright color
1639
+ bgBlackBright: [100, 49],
1640
+ bgGray: [100, 49],
1641
+ // Alias of `bgBlackBright`
1642
+ bgGrey: [100, 49],
1643
+ // Alias of `bgBlackBright`
1644
+ bgRedBright: [101, 49],
1645
+ bgGreenBright: [102, 49],
1646
+ bgYellowBright: [103, 49],
1647
+ bgBlueBright: [104, 49],
1648
+ bgMagentaBright: [105, 49],
1649
+ bgCyanBright: [106, 49],
1650
+ bgWhiteBright: [107, 49]
1651
+ }
1652
+ };
1653
+ Object.keys(styles.modifier);
1654
+ var foregroundColorNames = Object.keys(styles.color);
1655
+ var backgroundColorNames = Object.keys(styles.bgColor);
1656
+ [...foregroundColorNames, ...backgroundColorNames];
1657
+ function assembleStyles() {
1658
+ const codes = /* @__PURE__ */ new Map();
1659
+ for (const [groupName, group] of Object.entries(styles)) {
1660
+ for (const [styleName, style] of Object.entries(group)) {
1661
+ styles[styleName] = {
1662
+ open: `\x1B[${style[0]}m`,
1663
+ close: `\x1B[${style[1]}m`
1664
+ };
1665
+ group[styleName] = styles[styleName];
1666
+ codes.set(style[0], style[1]);
1667
+ }
1668
+ Object.defineProperty(styles, groupName, {
1669
+ value: group,
1670
+ enumerable: false
1671
+ });
1672
+ }
1673
+ Object.defineProperty(styles, "codes", {
1674
+ value: codes,
1675
+ enumerable: false
1676
+ });
1677
+ styles.color.close = "\x1B[39m";
1678
+ styles.bgColor.close = "\x1B[49m";
1679
+ styles.color.ansi = wrapAnsi16();
1680
+ styles.color.ansi256 = wrapAnsi256();
1681
+ styles.color.ansi16m = wrapAnsi16m();
1682
+ styles.bgColor.ansi = wrapAnsi16(ANSI_BACKGROUND_OFFSET);
1683
+ styles.bgColor.ansi256 = wrapAnsi256(ANSI_BACKGROUND_OFFSET);
1684
+ styles.bgColor.ansi16m = wrapAnsi16m(ANSI_BACKGROUND_OFFSET);
1685
+ Object.defineProperties(styles, {
1686
+ rgbToAnsi256: {
1687
+ value(red, green, blue) {
1688
+ if (red === green && green === blue) {
1689
+ if (red < 8) {
1690
+ return 16;
1691
+ }
1692
+ if (red > 248) {
1693
+ return 231;
1694
+ }
1695
+ return Math.round((red - 8) / 247 * 24) + 232;
1696
+ }
1697
+ return 16 + 36 * Math.round(red / 255 * 5) + 6 * Math.round(green / 255 * 5) + Math.round(blue / 255 * 5);
1698
+ },
1699
+ enumerable: false
1700
+ },
1701
+ hexToRgb: {
1702
+ value(hex) {
1703
+ const matches = /[a-f\d]{6}|[a-f\d]{3}/i.exec(hex.toString(16));
1704
+ if (!matches) {
1705
+ return [0, 0, 0];
1706
+ }
1707
+ let [colorString] = matches;
1708
+ if (colorString.length === 3) {
1709
+ colorString = [...colorString].map((character) => character + character).join("");
1710
+ }
1711
+ const integer = Number.parseInt(colorString, 16);
1712
+ return [
1713
+ /* eslint-disable no-bitwise */
1714
+ integer >> 16 & 255,
1715
+ integer >> 8 & 255,
1716
+ integer & 255
1717
+ /* eslint-enable no-bitwise */
1718
+ ];
1719
+ },
1720
+ enumerable: false
1721
+ },
1722
+ hexToAnsi256: {
1723
+ value: (hex) => styles.rgbToAnsi256(...styles.hexToRgb(hex)),
1724
+ enumerable: false
1725
+ },
1726
+ ansi256ToAnsi: {
1727
+ value(code) {
1728
+ if (code < 8) {
1729
+ return 30 + code;
1730
+ }
1731
+ if (code < 16) {
1732
+ return 90 + (code - 8);
1733
+ }
1734
+ let red;
1735
+ let green;
1736
+ let blue;
1737
+ if (code >= 232) {
1738
+ red = ((code - 232) * 10 + 8) / 255;
1739
+ green = red;
1740
+ blue = red;
1741
+ } else {
1742
+ code -= 16;
1743
+ const remainder = code % 36;
1744
+ red = Math.floor(code / 36) / 5;
1745
+ green = Math.floor(remainder / 6) / 5;
1746
+ blue = remainder % 6 / 5;
1747
+ }
1748
+ const value = Math.max(red, green, blue) * 2;
1749
+ if (value === 0) {
1750
+ return 30;
1751
+ }
1752
+ let result = 30 + (Math.round(blue) << 2 | Math.round(green) << 1 | Math.round(red));
1753
+ if (value === 2) {
1754
+ result += 60;
1755
+ }
1756
+ return result;
1757
+ },
1758
+ enumerable: false
1759
+ },
1760
+ rgbToAnsi: {
1761
+ value: (red, green, blue) => styles.ansi256ToAnsi(styles.rgbToAnsi256(red, green, blue)),
1762
+ enumerable: false
1763
+ },
1764
+ hexToAnsi: {
1765
+ value: (hex) => styles.ansi256ToAnsi(styles.hexToAnsi256(hex)),
1766
+ enumerable: false
1767
+ }
1768
+ });
1769
+ return styles;
1770
+ }
1771
+ var ansiStyles = assembleStyles();
1772
+ var ansi_styles_default = ansiStyles;
1773
+ function hasFlag(flag, argv = globalThis.Deno ? globalThis.Deno.args : process2__default.default.argv) {
1774
+ const prefix = flag.startsWith("-") ? "" : flag.length === 1 ? "-" : "--";
1775
+ const position = argv.indexOf(prefix + flag);
1776
+ const terminatorPosition = argv.indexOf("--");
1777
+ return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
1778
+ }
1779
+ var { env } = process2__default.default;
1780
+ var flagForceColor;
1781
+ if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false") || hasFlag("color=never")) {
1782
+ flagForceColor = 0;
1783
+ } else if (hasFlag("color") || hasFlag("colors") || hasFlag("color=true") || hasFlag("color=always")) {
1784
+ flagForceColor = 1;
1785
+ }
1786
+ function envForceColor() {
1787
+ if ("FORCE_COLOR" in env) {
1788
+ if (env.FORCE_COLOR === "true") {
1789
+ return 1;
1790
+ }
1791
+ if (env.FORCE_COLOR === "false") {
1792
+ return 0;
1793
+ }
1794
+ return env.FORCE_COLOR.length === 0 ? 1 : Math.min(Number.parseInt(env.FORCE_COLOR, 10), 3);
1795
+ }
1796
+ }
1797
+ function translateLevel(level) {
1798
+ if (level === 0) {
1799
+ return false;
1800
+ }
1801
+ return {
1802
+ level,
1803
+ hasBasic: true,
1804
+ has256: level >= 2,
1805
+ has16m: level >= 3
1806
+ };
1807
+ }
1808
+ function _supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
1809
+ const noFlagForceColor = envForceColor();
1810
+ if (noFlagForceColor !== void 0) {
1811
+ flagForceColor = noFlagForceColor;
1812
+ }
1813
+ const forceColor = sniffFlags ? flagForceColor : noFlagForceColor;
1814
+ if (forceColor === 0) {
1815
+ return 0;
1816
+ }
1817
+ if (sniffFlags) {
1818
+ if (hasFlag("color=16m") || hasFlag("color=full") || hasFlag("color=truecolor")) {
1819
+ return 3;
1820
+ }
1821
+ if (hasFlag("color=256")) {
1822
+ return 2;
1823
+ }
1824
+ }
1825
+ if ("TF_BUILD" in env && "AGENT_NAME" in env) {
1826
+ return 1;
1827
+ }
1828
+ if (haveStream && !streamIsTTY && forceColor === void 0) {
1829
+ return 0;
1830
+ }
1831
+ const min = forceColor || 0;
1832
+ if (env.TERM === "dumb") {
1833
+ return min;
1834
+ }
1835
+ if (process2__default.default.platform === "win32") {
1836
+ const osRelease = os__default.default.release().split(".");
1837
+ if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
1838
+ return Number(osRelease[2]) >= 14931 ? 3 : 2;
1839
+ }
1840
+ return 1;
1841
+ }
1842
+ if ("CI" in env) {
1843
+ if (["GITHUB_ACTIONS", "GITEA_ACTIONS", "CIRCLECI"].some((key) => key in env)) {
1844
+ return 3;
1845
+ }
1846
+ if (["TRAVIS", "APPVEYOR", "GITLAB_CI", "BUILDKITE", "DRONE"].some((sign) => sign in env) || env.CI_NAME === "codeship") {
1847
+ return 1;
1848
+ }
1849
+ return min;
1850
+ }
1851
+ if ("TEAMCITY_VERSION" in env) {
1852
+ return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
1853
+ }
1854
+ if (env.COLORTERM === "truecolor") {
1855
+ return 3;
1856
+ }
1857
+ if (env.TERM === "xterm-kitty") {
1858
+ return 3;
1859
+ }
1860
+ if (env.TERM === "xterm-ghostty") {
1861
+ return 3;
1862
+ }
1863
+ if (env.TERM === "wezterm") {
1864
+ return 3;
1865
+ }
1866
+ if ("TERM_PROGRAM" in env) {
1867
+ const version = Number.parseInt((env.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
1868
+ switch (env.TERM_PROGRAM) {
1869
+ case "iTerm.app": {
1870
+ return version >= 3 ? 3 : 2;
1871
+ }
1872
+ case "Apple_Terminal": {
1873
+ return 2;
1874
+ }
1875
+ }
1876
+ }
1877
+ if (/-256(color)?$/i.test(env.TERM)) {
1878
+ return 2;
1879
+ }
1880
+ if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
1881
+ return 1;
1882
+ }
1883
+ if ("COLORTERM" in env) {
1884
+ return 1;
1885
+ }
1886
+ return min;
1887
+ }
1888
+ function createSupportsColor(stream, options = {}) {
1889
+ const level = _supportsColor(stream, {
1890
+ streamIsTTY: stream && stream.isTTY,
1891
+ ...options
1892
+ });
1893
+ return translateLevel(level);
1894
+ }
1895
+ var supportsColor = {
1896
+ stdout: createSupportsColor({ isTTY: tty__default.default.isatty(1) }),
1897
+ stderr: createSupportsColor({ isTTY: tty__default.default.isatty(2) })
1898
+ };
1899
+ var supports_color_default = supportsColor;
1900
+
1901
+ // node_modules/.pnpm/chalk@5.6.2/node_modules/chalk/source/utilities.js
1902
+ function stringReplaceAll(string, substring, replacer) {
1903
+ let index = string.indexOf(substring);
1904
+ if (index === -1) {
1905
+ return string;
1906
+ }
1907
+ const substringLength = substring.length;
1908
+ let endIndex = 0;
1909
+ let returnValue = "";
1910
+ do {
1911
+ returnValue += string.slice(endIndex, index) + substring + replacer;
1912
+ endIndex = index + substringLength;
1913
+ index = string.indexOf(substring, endIndex);
1914
+ } while (index !== -1);
1915
+ returnValue += string.slice(endIndex);
1916
+ return returnValue;
1917
+ }
1918
+ function stringEncaseCRLFWithFirstIndex(string, prefix, postfix, index) {
1919
+ let endIndex = 0;
1920
+ let returnValue = "";
1921
+ do {
1922
+ const gotCR = string[index - 1] === "\r";
1923
+ returnValue += string.slice(endIndex, gotCR ? index - 1 : index) + prefix + (gotCR ? "\r\n" : "\n") + postfix;
1924
+ endIndex = index + 1;
1925
+ index = string.indexOf("\n", endIndex);
1926
+ } while (index !== -1);
1927
+ returnValue += string.slice(endIndex);
1928
+ return returnValue;
1929
+ }
1930
+
1931
+ // node_modules/.pnpm/chalk@5.6.2/node_modules/chalk/source/index.js
1932
+ var { stdout: stdoutColor, stderr: stderrColor } = supports_color_default;
1933
+ var GENERATOR = /* @__PURE__ */ Symbol("GENERATOR");
1934
+ var STYLER = /* @__PURE__ */ Symbol("STYLER");
1935
+ var IS_EMPTY = /* @__PURE__ */ Symbol("IS_EMPTY");
1936
+ var levelMapping = [
1937
+ "ansi",
1938
+ "ansi",
1939
+ "ansi256",
1940
+ "ansi16m"
1941
+ ];
1942
+ var styles2 = /* @__PURE__ */ Object.create(null);
1943
+ var applyOptions = (object, options = {}) => {
1944
+ if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) {
1945
+ throw new Error("The `level` option should be an integer from 0 to 3");
1946
+ }
1947
+ const colorLevel = stdoutColor ? stdoutColor.level : 0;
1948
+ object.level = options.level === void 0 ? colorLevel : options.level;
1949
+ };
1950
+ var chalkFactory = (options) => {
1951
+ const chalk2 = (...strings) => strings.join(" ");
1952
+ applyOptions(chalk2, options);
1953
+ Object.setPrototypeOf(chalk2, createChalk.prototype);
1954
+ return chalk2;
1955
+ };
1956
+ function createChalk(options) {
1957
+ return chalkFactory(options);
1958
+ }
1959
+ Object.setPrototypeOf(createChalk.prototype, Function.prototype);
1960
+ for (const [styleName, style] of Object.entries(ansi_styles_default)) {
1961
+ styles2[styleName] = {
1962
+ get() {
1963
+ const builder = createBuilder(this, createStyler(style.open, style.close, this[STYLER]), this[IS_EMPTY]);
1964
+ Object.defineProperty(this, styleName, { value: builder });
1965
+ return builder;
1966
+ }
1967
+ };
1968
+ }
1969
+ styles2.visible = {
1970
+ get() {
1971
+ const builder = createBuilder(this, this[STYLER], true);
1972
+ Object.defineProperty(this, "visible", { value: builder });
1973
+ return builder;
1974
+ }
1975
+ };
1976
+ var getModelAnsi = (model, level, type, ...arguments_) => {
1977
+ if (model === "rgb") {
1978
+ if (level === "ansi16m") {
1979
+ return ansi_styles_default[type].ansi16m(...arguments_);
1980
+ }
1981
+ if (level === "ansi256") {
1982
+ return ansi_styles_default[type].ansi256(ansi_styles_default.rgbToAnsi256(...arguments_));
1983
+ }
1984
+ return ansi_styles_default[type].ansi(ansi_styles_default.rgbToAnsi(...arguments_));
1985
+ }
1986
+ if (model === "hex") {
1987
+ return getModelAnsi("rgb", level, type, ...ansi_styles_default.hexToRgb(...arguments_));
1988
+ }
1989
+ return ansi_styles_default[type][model](...arguments_);
1990
+ };
1991
+ var usedModels = ["rgb", "hex", "ansi256"];
1992
+ for (const model of usedModels) {
1993
+ styles2[model] = {
1994
+ get() {
1995
+ const { level } = this;
1996
+ return function(...arguments_) {
1997
+ const styler = createStyler(getModelAnsi(model, levelMapping[level], "color", ...arguments_), ansi_styles_default.color.close, this[STYLER]);
1998
+ return createBuilder(this, styler, this[IS_EMPTY]);
1999
+ };
2000
+ }
2001
+ };
2002
+ const bgModel = "bg" + model[0].toUpperCase() + model.slice(1);
2003
+ styles2[bgModel] = {
2004
+ get() {
2005
+ const { level } = this;
2006
+ return function(...arguments_) {
2007
+ const styler = createStyler(getModelAnsi(model, levelMapping[level], "bgColor", ...arguments_), ansi_styles_default.bgColor.close, this[STYLER]);
2008
+ return createBuilder(this, styler, this[IS_EMPTY]);
2009
+ };
2010
+ }
2011
+ };
2012
+ }
2013
+ var proto = Object.defineProperties(() => {
2014
+ }, {
2015
+ ...styles2,
2016
+ level: {
2017
+ enumerable: true,
2018
+ get() {
2019
+ return this[GENERATOR].level;
2020
+ },
2021
+ set(level) {
2022
+ this[GENERATOR].level = level;
2023
+ }
2024
+ }
2025
+ });
2026
+ var createStyler = (open, close, parent) => {
2027
+ let openAll;
2028
+ let closeAll;
2029
+ if (parent === void 0) {
2030
+ openAll = open;
2031
+ closeAll = close;
2032
+ } else {
2033
+ openAll = parent.openAll + open;
2034
+ closeAll = close + parent.closeAll;
2035
+ }
2036
+ return {
2037
+ open,
2038
+ close,
2039
+ openAll,
2040
+ closeAll,
2041
+ parent
2042
+ };
2043
+ };
2044
+ var createBuilder = (self, _styler, _isEmpty) => {
2045
+ const builder = (...arguments_) => applyStyle(builder, arguments_.length === 1 ? "" + arguments_[0] : arguments_.join(" "));
2046
+ Object.setPrototypeOf(builder, proto);
2047
+ builder[GENERATOR] = self;
2048
+ builder[STYLER] = _styler;
2049
+ builder[IS_EMPTY] = _isEmpty;
2050
+ return builder;
2051
+ };
2052
+ var applyStyle = (self, string) => {
2053
+ if (self.level <= 0 || !string) {
2054
+ return self[IS_EMPTY] ? "" : string;
2055
+ }
2056
+ let styler = self[STYLER];
2057
+ if (styler === void 0) {
2058
+ return string;
2059
+ }
2060
+ const { openAll, closeAll } = styler;
2061
+ if (string.includes("\x1B")) {
2062
+ while (styler !== void 0) {
2063
+ string = stringReplaceAll(string, styler.close, styler.open);
2064
+ styler = styler.parent;
2065
+ }
2066
+ }
2067
+ const lfIndex = string.indexOf("\n");
2068
+ if (lfIndex !== -1) {
2069
+ string = stringEncaseCRLFWithFirstIndex(string, closeAll, openAll, lfIndex);
2070
+ }
2071
+ return openAll + string + closeAll;
2072
+ };
2073
+ Object.defineProperties(createChalk.prototype, styles2);
2074
+ var chalk = createChalk();
2075
+ createChalk({ level: stderrColor ? stderrColor.level : 0 });
2076
+ var source_default = chalk;
2077
+
2078
+ // packages/core/src/terminal.ts
2079
+ var TERMINAL_INDENT = " ";
2080
+ var MAX_TERMINAL_NAME_LENGTH = 80;
2081
+ var MAX_TERMINAL_DEPTH = 10;
2082
+ function normalizeDepth(depth) {
2083
+ if (!Number.isFinite(depth) || depth < 0) {
2084
+ return 0;
2085
+ }
2086
+ return Math.min(Math.floor(depth), MAX_TERMINAL_DEPTH);
2087
+ }
2088
+ function safePrint(line = "") {
2089
+ try {
2090
+ console.log(line);
2091
+ } catch {
2092
+ }
2093
+ }
2094
+ function getIndent(depth) {
2095
+ return TERMINAL_INDENT.repeat(normalizeDepth(depth));
2096
+ }
2097
+ function formatTerminalName(name) {
2098
+ if (typeof name !== "string" || name.trim() === "") {
2099
+ return "unnamed";
2100
+ }
2101
+ return truncateName(name, MAX_TERMINAL_NAME_LENGTH);
2102
+ }
2103
+ function getStatusIcon(status) {
2104
+ if (status === "success") return source_default.green("\u2714");
2105
+ if (status === "error") return source_default.red("\u2716");
2106
+ return source_default.yellow("\u23F3");
2107
+ }
2108
+ function renderStepLine(name, durationMs2, status, depth) {
2109
+ try {
2110
+ const nm = formatTerminalName(name);
2111
+ const ind = getIndent(depth ?? 0);
2112
+ if (status === "running" && durationMs2 === void 0) {
2113
+ return `${ind}${source_default.yellow("\u23F3")} ${nm}`;
2114
+ }
2115
+ const hasDur = durationMs2 !== void 0 && Number.isFinite(durationMs2);
2116
+ const dur = hasDur ? formatDuration2(durationMs2) : void 0;
2117
+ if (status === "running") {
2118
+ return dur !== void 0 ? `${ind}${source_default.yellow("\u23F3")} ${nm} (${dur})` : `${ind}${source_default.yellow("\u23F3")} ${nm}`;
2119
+ }
2120
+ if (!hasDur || dur === void 0) {
2121
+ return `${ind}${source_default.yellow("\u23F3")} ${nm}`;
2122
+ }
2123
+ if (status === "success") {
2124
+ return `${ind}${getStatusIcon("success")} ${nm} (${dur})`;
2125
+ }
2126
+ return `${ind}${getStatusIcon("error")} ${nm} (${dur})`;
2127
+ } catch {
2128
+ return "";
2129
+ }
2130
+ }
2131
+ function renderErrorLine(error, depth) {
2132
+ try {
2133
+ const msg = typeof error.message === "string" ? error.message : "";
2134
+ const ind = getIndent((depth ?? 0) + 1);
2135
+ return `${ind}Error: ${msg}`;
2136
+ } catch {
2137
+ return "";
2138
+ }
2139
+ }
2140
+ function renderRunSummary(durationMs2, status, traceFilePath) {
2141
+ try {
2142
+ const dur = Number.isFinite(durationMs2) ? formatDuration2(durationMs2) : formatDuration2(0);
2143
+ const head = status === "error" ? `Failed in ${dur}` : `Completed in ${dur}`;
2144
+ const lines = [head];
2145
+ if (traceFilePath !== void 0 && traceFilePath.trim() !== "") {
2146
+ lines.push(`Trace: ${traceFilePath}`);
2147
+ }
2148
+ return lines;
2149
+ } catch {
2150
+ return [];
2151
+ }
2152
+ }
2153
+ function printRunStart(runId, name) {
2154
+ if (isSilentContext()) return;
2155
+ try {
2156
+ safePrint("");
2157
+ const header = `${source_default.cyan.bold("\u{1F50D} AgentInspect:")} ${formatTerminalName(name)} ${source_default.dim(`(${runId})`)}`;
2158
+ safePrint(header);
2159
+ } catch {
2160
+ }
2161
+ }
2162
+ function printStepStart(name, depth = 0) {
2163
+ if (isSilentContext()) return;
2164
+ try {
2165
+ safePrint(renderStepLine(name, void 0, "running", depth));
2166
+ } catch {
2167
+ }
2168
+ }
2169
+ function printStepComplete(name, durationMs2, status, depth = 0) {
2170
+ if (isSilentContext()) return;
2171
+ try {
2172
+ safePrint(renderStepLine(name, durationMs2, status, depth));
2173
+ } catch {
2174
+ }
2175
+ }
2176
+ function printError(error, depth = 0) {
2177
+ if (isSilentContext()) return;
2178
+ try {
2179
+ safePrint(renderErrorLine(error, depth));
2180
+ } catch {
2181
+ }
2182
+ }
2183
+ function printRunComplete(_name, _runId, durationMs2, status, traceFilePath) {
2184
+ if (isSilentContext()) return;
2185
+ try {
2186
+ const lines = renderRunSummary(durationMs2, status, traceFilePath);
2187
+ for (let i = 0; i < lines.length; i++) {
2188
+ const line = lines[i];
2189
+ if (i === 0) {
2190
+ const color = status === "error" ? source_default.red : status === "running" ? source_default.yellow : source_default.green;
2191
+ safePrint(color(line));
2192
+ } else {
2193
+ safePrint(source_default.dim(line));
2194
+ }
2195
+ }
2196
+ } catch {
2197
+ }
2198
+ }
2199
+ function printFailedAt(stepName) {
2200
+ if (isSilentContext()) return;
2201
+ try {
2202
+ safePrint(`Failed at: ${formatTerminalName(stepName)}`);
2203
+ } catch {
2204
+ }
2205
+ }
2206
+
2207
+ exports.DEFAULT_MAX_EVENT_BYTES = DEFAULT_MAX_EVENT_BYTES;
2208
+ exports.DEFAULT_MAX_METADATA_VALUE_LENGTH = DEFAULT_MAX_METADATA_VALUE_LENGTH;
2209
+ exports.DEFAULT_MAX_PREVIEW_LENGTH = DEFAULT_MAX_PREVIEW_LENGTH;
2210
+ exports.DEFAULT_TRACE_DIR_NAME = DEFAULT_TRACE_DIR_NAME;
2211
+ exports.FALLBACK_TRACE_DIR = FALLBACK_TRACE_DIR;
2212
+ exports.MAX_NAME_LENGTH = MAX_NAME_LENGTH;
2213
+ exports.MAX_TERMINAL_DEPTH = MAX_TERMINAL_DEPTH;
2214
+ exports.MAX_TERMINAL_NAME_LENGTH = MAX_TERMINAL_NAME_LENGTH;
2215
+ exports.RUNS_DIR_NAME = RUNS_DIR_NAME;
2216
+ exports.TERMINAL_INDENT = TERMINAL_INDENT;
2217
+ exports.createInspector = createInspector;
2218
+ exports.createInspectorRuntime = createInspectorRuntime;
2219
+ exports.createRunId = createRunId;
2220
+ exports.createStepId = createStepId;
2221
+ exports.ensureTraceDir = ensureTraceDir;
2222
+ exports.formatDuration = formatDuration2;
2223
+ exports.formatError = formatError;
2224
+ exports.formatTerminalName = formatTerminalName;
2225
+ exports.formatTimestamp = formatTimestamp;
2226
+ exports.getCurrentContext = getCurrentContext;
2227
+ exports.getCurrentCorrelationMetadata = getCurrentCorrelationMetadata;
2228
+ exports.getCurrentDepth = getCurrentDepth;
2229
+ exports.getCurrentRunId = getCurrentRunId;
2230
+ exports.getCurrentRunName = getCurrentRunName;
2231
+ exports.getCurrentStepId = getCurrentStepId;
2232
+ exports.getDefaultTraceDir = getDefaultTraceDir;
2233
+ exports.getIndent = getIndent;
2234
+ exports.getParentStepId = getParentStepId;
2235
+ exports.getTraceDirFromContext = getTraceDirFromContext;
2236
+ exports.getTraceFilePath = getTraceFilePath;
2237
+ exports.getTraceSafetyFromContext = getTraceSafetyFromContext;
2238
+ exports.hasActiveContext = hasActiveContext;
2239
+ exports.isSilentContext = isSilentContext;
2240
+ exports.prepareMetadataForDisk = prepareMetadataForDisk;
2241
+ exports.prepareTraceEventForDisk = prepareTraceEventForDisk;
2242
+ exports.printError = printError;
2243
+ exports.printFailedAt = printFailedAt;
2244
+ exports.printRunComplete = printRunComplete;
2245
+ exports.printRunStart = printRunStart;
2246
+ exports.printStepComplete = printStepComplete;
2247
+ exports.printStepStart = printStepStart;
2248
+ exports.renderErrorLine = renderErrorLine;
2249
+ exports.renderRunSummary = renderRunSummary;
2250
+ exports.renderStepLine = renderStepLine;
2251
+ exports.resolveRedactionProfile = resolveRedactionProfile;
2252
+ exports.resolveTraceSafetyOptions = resolveTraceSafetyOptions;
2253
+ exports.runWithContext = runWithContext;
2254
+ exports.runWithStepContext = runWithStepContext;
2255
+ exports.truncateName = truncateName;
2256
+ exports.warn = warn;
2257
+ //# sourceMappingURL=advanced.cjs.map
2258
+ //# sourceMappingURL=advanced.cjs.map