agent-inspect 1.2.0 → 1.3.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.
- package/CHANGELOG.md +25 -3
- package/README.md +6 -5
- package/docs/ADAPTERS.md +22 -1
- package/docs/API.md +11 -3
- package/docs/ARCHITECTURE.md +1 -1
- package/docs/CLI.md +9 -1
- package/docs/EXPORTS.md +14 -0
- package/docs/LIMITATIONS.md +11 -0
- package/docs/SCHEMA.md +1 -0
- package/package.json +1 -1
- package/packages/cli/dist/index.cjs +271 -14
- package/packages/cli/dist/index.cjs.map +1 -1
- package/packages/cli/dist/index.mjs +271 -14
- package/packages/cli/dist/index.mjs.map +1 -1
- package/packages/core/dist/index.cjs +315 -14
- package/packages/core/dist/index.cjs.map +1 -1
- package/packages/core/dist/index.d.cts +51 -3
- package/packages/core/dist/index.d.ts +51 -3
- package/packages/core/dist/index.mjs +313 -15
- package/packages/core/dist/index.mjs.map +1 -1
|
@@ -183,6 +183,51 @@ function isPersistedInspectEvent(value) {
|
|
|
183
183
|
return true;
|
|
184
184
|
}
|
|
185
185
|
|
|
186
|
+
// packages/core/src/correlation-metadata.ts
|
|
187
|
+
var TRACE_CORRELATION_KEYS = [
|
|
188
|
+
"correlationId",
|
|
189
|
+
"requestId",
|
|
190
|
+
"decisionId",
|
|
191
|
+
"groupId"
|
|
192
|
+
];
|
|
193
|
+
function isNonEmptyString2(value) {
|
|
194
|
+
return typeof value === "string" && value.length > 0;
|
|
195
|
+
}
|
|
196
|
+
function extractCorrelationMetadata(record) {
|
|
197
|
+
if (!record) {
|
|
198
|
+
return void 0;
|
|
199
|
+
}
|
|
200
|
+
const out = {};
|
|
201
|
+
let found = false;
|
|
202
|
+
for (const key of TRACE_CORRELATION_KEYS) {
|
|
203
|
+
const value = record[key];
|
|
204
|
+
if (isNonEmptyString2(value)) {
|
|
205
|
+
out[key] = value;
|
|
206
|
+
found = true;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
return found ? out : void 0;
|
|
210
|
+
}
|
|
211
|
+
function buildRunStartedMetadata(options) {
|
|
212
|
+
if (!options) {
|
|
213
|
+
return void 0;
|
|
214
|
+
}
|
|
215
|
+
const merged = options.metadata !== void 0 ? { ...options.metadata } : {};
|
|
216
|
+
if (isNonEmptyString2(options.correlationId)) {
|
|
217
|
+
merged.correlationId = options.correlationId;
|
|
218
|
+
}
|
|
219
|
+
if (isNonEmptyString2(options.requestId)) {
|
|
220
|
+
merged.requestId = options.requestId;
|
|
221
|
+
}
|
|
222
|
+
if (isNonEmptyString2(options.decisionId)) {
|
|
223
|
+
merged.decisionId = options.decisionId;
|
|
224
|
+
}
|
|
225
|
+
if (isNonEmptyString2(options.groupId)) {
|
|
226
|
+
merged.groupId = options.groupId;
|
|
227
|
+
}
|
|
228
|
+
return Object.keys(merged).length > 0 ? merged : void 0;
|
|
229
|
+
}
|
|
230
|
+
|
|
186
231
|
// packages/core/src/persisted/from-trace-event.ts
|
|
187
232
|
function sanitizeIdPart(value) {
|
|
188
233
|
return value.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
@@ -289,9 +334,14 @@ function traceEventToPersistedInspectEvent(event, options) {
|
|
|
289
334
|
switch (event.event) {
|
|
290
335
|
case "run_started": {
|
|
291
336
|
const tsStart = toIsoTimestamp(event.startTime);
|
|
337
|
+
const correlation = extractCorrelationMetadata(event.metadata);
|
|
292
338
|
const attributes = compactAttributes({
|
|
293
339
|
legacyEvent: "run_started",
|
|
294
340
|
metadata: event.metadata !== void 0 ? { ...event.metadata } : void 0,
|
|
341
|
+
correlationId: correlation?.correlationId,
|
|
342
|
+
requestId: correlation?.requestId,
|
|
343
|
+
decisionId: correlation?.decisionId,
|
|
344
|
+
groupId: correlation?.groupId,
|
|
295
345
|
invalidTimestamp: tsMain.invalidTimestamp || tsStart.invalidTimestamp ? true : void 0
|
|
296
346
|
});
|
|
297
347
|
return {
|
|
@@ -1128,7 +1178,7 @@ function stableHash(value) {
|
|
|
1128
1178
|
const h = crypto.createHash("sha256").update(value, "utf8").digest("hex");
|
|
1129
1179
|
return h.slice(0, 8);
|
|
1130
1180
|
}
|
|
1131
|
-
function compileRules(rules) {
|
|
1181
|
+
function compileRules(rules, extraKeys) {
|
|
1132
1182
|
const out = /* @__PURE__ */ new Map();
|
|
1133
1183
|
const set = (r) => {
|
|
1134
1184
|
const k = toKey(r.key);
|
|
@@ -1137,6 +1187,11 @@ function compileRules(rules) {
|
|
|
1137
1187
|
for (const k of DEFAULT_REDACT_KEYS) {
|
|
1138
1188
|
set({ key: k, strategy: "full" });
|
|
1139
1189
|
}
|
|
1190
|
+
for (const k of extraKeys ?? []) {
|
|
1191
|
+
if (typeof k === "string" && k.length > 0) {
|
|
1192
|
+
set({ key: k, strategy: "full" });
|
|
1193
|
+
}
|
|
1194
|
+
}
|
|
1140
1195
|
for (const r of rules ?? []) {
|
|
1141
1196
|
if (typeof r === "string") {
|
|
1142
1197
|
set({ key: r, strategy: "full" });
|
|
@@ -1154,7 +1209,7 @@ function compileRules(rules) {
|
|
|
1154
1209
|
var Redactor = class {
|
|
1155
1210
|
#rules;
|
|
1156
1211
|
constructor(options) {
|
|
1157
|
-
this.#rules = compileRules(options?.rules);
|
|
1212
|
+
this.#rules = compileRules(options?.rules, options?.extraKeys);
|
|
1158
1213
|
}
|
|
1159
1214
|
redactValue(key, value) {
|
|
1160
1215
|
const k = toKey(key);
|
|
@@ -1859,6 +1914,91 @@ function warn(message, error) {
|
|
|
1859
1914
|
}
|
|
1860
1915
|
console.warn(`${base}: ${formatError(error).message}`);
|
|
1861
1916
|
}
|
|
1917
|
+
|
|
1918
|
+
// packages/core/src/redaction-profiles.ts
|
|
1919
|
+
var SHARE_PROFILE_EXTRA_KEYS = [
|
|
1920
|
+
"userEmail",
|
|
1921
|
+
"customerEmail",
|
|
1922
|
+
"phone",
|
|
1923
|
+
"phoneNumber",
|
|
1924
|
+
"address",
|
|
1925
|
+
"ip",
|
|
1926
|
+
"ipAddress",
|
|
1927
|
+
"sessionId",
|
|
1928
|
+
"requestId",
|
|
1929
|
+
"correlationId",
|
|
1930
|
+
"decisionId",
|
|
1931
|
+
"groupId",
|
|
1932
|
+
"customerId",
|
|
1933
|
+
"userId",
|
|
1934
|
+
"accountId",
|
|
1935
|
+
"tenantId",
|
|
1936
|
+
"orgId",
|
|
1937
|
+
"organizationId",
|
|
1938
|
+
"traceId",
|
|
1939
|
+
"spanId",
|
|
1940
|
+
"parentSpanId"
|
|
1941
|
+
];
|
|
1942
|
+
var STRICT_PROFILE_EXTRA_KEYS = [
|
|
1943
|
+
"prompt",
|
|
1944
|
+
"completion",
|
|
1945
|
+
"input",
|
|
1946
|
+
"output",
|
|
1947
|
+
"inputPreview",
|
|
1948
|
+
"outputPreview",
|
|
1949
|
+
"message",
|
|
1950
|
+
"messages",
|
|
1951
|
+
"transcript",
|
|
1952
|
+
"context",
|
|
1953
|
+
"document",
|
|
1954
|
+
"documents",
|
|
1955
|
+
"chunk",
|
|
1956
|
+
"chunks",
|
|
1957
|
+
"retrieval",
|
|
1958
|
+
"query"
|
|
1959
|
+
];
|
|
1960
|
+
function resolveRedactionProfile(profile = "local") {
|
|
1961
|
+
switch (profile) {
|
|
1962
|
+
case "local":
|
|
1963
|
+
return { profile: "local", extraKeys: [] };
|
|
1964
|
+
case "share":
|
|
1965
|
+
return {
|
|
1966
|
+
profile: "share",
|
|
1967
|
+
extraKeys: SHARE_PROFILE_EXTRA_KEYS,
|
|
1968
|
+
maxMetadataValueLengthCap: 500,
|
|
1969
|
+
maxPreviewLengthCap: 200
|
|
1970
|
+
};
|
|
1971
|
+
case "strict":
|
|
1972
|
+
return {
|
|
1973
|
+
profile: "strict",
|
|
1974
|
+
extraKeys: [...SHARE_PROFILE_EXTRA_KEYS, ...STRICT_PROFILE_EXTRA_KEYS],
|
|
1975
|
+
maxMetadataValueLengthCap: 200,
|
|
1976
|
+
maxPreviewLengthCap: 80
|
|
1977
|
+
};
|
|
1978
|
+
default:
|
|
1979
|
+
return { profile: "local", extraKeys: [] };
|
|
1980
|
+
}
|
|
1981
|
+
}
|
|
1982
|
+
function isPreviewKey(key) {
|
|
1983
|
+
return key.toLowerCase().includes("preview");
|
|
1984
|
+
}
|
|
1985
|
+
function applyProfileMetadataCaps(maxMetadataValueLength, maxPreviewLength, resolved) {
|
|
1986
|
+
let meta = maxMetadataValueLength;
|
|
1987
|
+
let preview = maxPreviewLength;
|
|
1988
|
+
if (resolved.maxMetadataValueLengthCap !== void 0) {
|
|
1989
|
+
meta = Math.min(meta, resolved.maxMetadataValueLengthCap);
|
|
1990
|
+
}
|
|
1991
|
+
if (resolved.maxPreviewLengthCap !== void 0) {
|
|
1992
|
+
preview = Math.min(preview, resolved.maxPreviewLengthCap);
|
|
1993
|
+
}
|
|
1994
|
+
return { maxMetadataValueLength: meta, maxPreviewLength: preview };
|
|
1995
|
+
}
|
|
1996
|
+
function truncateStringForProfile(value, key, maxMetadataValueLength, maxPreviewLength) {
|
|
1997
|
+
const max = isPreviewKey(key) ? maxPreviewLength : maxMetadataValueLength;
|
|
1998
|
+
if (max <= 0) return "\u2026";
|
|
1999
|
+
if (value.length <= max) return value;
|
|
2000
|
+
return `${value.slice(0, max)}\u2026`;
|
|
2001
|
+
}
|
|
1862
2002
|
function isRecord7(value) {
|
|
1863
2003
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1864
2004
|
}
|
|
@@ -2062,7 +2202,7 @@ var DEFAULT_MAX_EVENT_BYTES = 65536;
|
|
|
2062
2202
|
function isRecord8(value) {
|
|
2063
2203
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
2064
2204
|
}
|
|
2065
|
-
function
|
|
2205
|
+
function isPreviewKey2(key) {
|
|
2066
2206
|
return key.toLowerCase().includes("preview");
|
|
2067
2207
|
}
|
|
2068
2208
|
function truncateString(value, maxLen) {
|
|
@@ -2085,11 +2225,28 @@ function resolveTraceSafetyOptions(options) {
|
|
|
2085
2225
|
redactEnabled = true;
|
|
2086
2226
|
redactionRules = redact.rules;
|
|
2087
2227
|
}
|
|
2228
|
+
const profile = options?.redactionProfile ?? "local";
|
|
2229
|
+
const resolvedProfile = resolveRedactionProfile(profile);
|
|
2230
|
+
const userMaxMetadata = typeof options?.maxMetadataValueLength === "number" && Number.isFinite(options.maxMetadataValueLength) && options.maxMetadataValueLength >= 0 ? Math.floor(options.maxMetadataValueLength) : void 0;
|
|
2231
|
+
const userMaxPreview = typeof options?.maxPreviewLength === "number" && Number.isFinite(options.maxPreviewLength) && options.maxPreviewLength >= 0 ? Math.floor(options.maxPreviewLength) : void 0;
|
|
2232
|
+
let maxMetadataValueLength = userMaxMetadata ?? DEFAULT_MAX_METADATA_VALUE_LENGTH;
|
|
2233
|
+
let maxPreviewLength = userMaxPreview ?? DEFAULT_MAX_PREVIEW_LENGTH;
|
|
2234
|
+
if (redactEnabled && profile !== "local") {
|
|
2235
|
+
const capped = applyProfileMetadataCaps(
|
|
2236
|
+
maxMetadataValueLength,
|
|
2237
|
+
maxPreviewLength,
|
|
2238
|
+
resolvedProfile
|
|
2239
|
+
);
|
|
2240
|
+
maxMetadataValueLength = capped.maxMetadataValueLength;
|
|
2241
|
+
maxPreviewLength = capped.maxPreviewLength;
|
|
2242
|
+
}
|
|
2088
2243
|
return {
|
|
2089
2244
|
redactEnabled,
|
|
2090
2245
|
redactionRules,
|
|
2091
|
-
|
|
2092
|
-
|
|
2246
|
+
redactionProfile: profile,
|
|
2247
|
+
profileExtraKeys: redactEnabled ? resolvedProfile.extraKeys : [],
|
|
2248
|
+
maxMetadataValueLength,
|
|
2249
|
+
maxPreviewLength,
|
|
2093
2250
|
maxEventBytes: typeof options?.maxEventBytes === "number" && Number.isFinite(options.maxEventBytes) && options.maxEventBytes > 0 ? Math.floor(options.maxEventBytes) : DEFAULT_MAX_EVENT_BYTES
|
|
2094
2251
|
};
|
|
2095
2252
|
}
|
|
@@ -2097,7 +2254,7 @@ function boundMetadataValue(key, value, opts, seen, depth) {
|
|
|
2097
2254
|
if (depth > 32) return "[MaxDepth]";
|
|
2098
2255
|
if (value === null || typeof value !== "object") {
|
|
2099
2256
|
if (typeof value === "string") {
|
|
2100
|
-
const max =
|
|
2257
|
+
const max = isPreviewKey2(key) ? opts.maxPreviewLength : opts.maxMetadataValueLength;
|
|
2101
2258
|
return truncateString(value, max);
|
|
2102
2259
|
}
|
|
2103
2260
|
return value;
|
|
@@ -2123,7 +2280,10 @@ function boundMetadataValue(key, value, opts, seen, depth) {
|
|
|
2123
2280
|
}
|
|
2124
2281
|
function redactMetadata(metadata, opts) {
|
|
2125
2282
|
if (!opts.redactEnabled) return { ...metadata };
|
|
2126
|
-
const redactor = new Redactor({
|
|
2283
|
+
const redactor = new Redactor({
|
|
2284
|
+
rules: opts.redactionRules,
|
|
2285
|
+
extraKeys: opts.profileExtraKeys
|
|
2286
|
+
});
|
|
2127
2287
|
return redactor.redactRecord(metadata);
|
|
2128
2288
|
}
|
|
2129
2289
|
function prepareMetadataForDisk(metadata, opts) {
|
|
@@ -2295,6 +2455,13 @@ function getCurrentRunId() {
|
|
|
2295
2455
|
return void 0;
|
|
2296
2456
|
}
|
|
2297
2457
|
}
|
|
2458
|
+
function getCurrentCorrelationMetadata() {
|
|
2459
|
+
try {
|
|
2460
|
+
return extractCorrelationMetadata(storage.getStore()?.metadata);
|
|
2461
|
+
} catch {
|
|
2462
|
+
return void 0;
|
|
2463
|
+
}
|
|
2464
|
+
}
|
|
2298
2465
|
function getCurrentRunName() {
|
|
2299
2466
|
try {
|
|
2300
2467
|
return storage.getStore()?.runName;
|
|
@@ -3938,12 +4105,13 @@ async function inspectRun(name, fn, options) {
|
|
|
3938
4105
|
const runId = createRunId();
|
|
3939
4106
|
const traceDir = resolveTraceDir({ dir: options?.traceDir });
|
|
3940
4107
|
const traceSafety = resolveTraceSafetyOptions(options);
|
|
4108
|
+
const runMetadata = buildRunStartedMetadata(options);
|
|
3941
4109
|
const context = {
|
|
3942
4110
|
runId,
|
|
3943
4111
|
runName,
|
|
3944
4112
|
traceDir,
|
|
3945
4113
|
silent: options?.silent ?? false,
|
|
3946
|
-
metadata:
|
|
4114
|
+
metadata: runMetadata
|
|
3947
4115
|
};
|
|
3948
4116
|
return runWithContext(context, async () => {
|
|
3949
4117
|
const startTime = Date.now();
|
|
@@ -3959,7 +4127,7 @@ async function inspectRun(name, fn, options) {
|
|
|
3959
4127
|
runId,
|
|
3960
4128
|
name: runName,
|
|
3961
4129
|
startTime,
|
|
3962
|
-
...
|
|
4130
|
+
...runMetadata !== void 0 ? { metadata: runMetadata } : {}
|
|
3963
4131
|
};
|
|
3964
4132
|
await writeTraceEvent(
|
|
3965
4133
|
prepareTraceEventForDisk(started, traceSafety),
|
|
@@ -4244,6 +4412,134 @@ function observe(agent, options) {
|
|
|
4244
4412
|
// packages/core/src/exporters/types.ts
|
|
4245
4413
|
var EXPORT_PAYLOAD_VERSION = "0.1.2";
|
|
4246
4414
|
|
|
4415
|
+
// packages/core/src/exporters/redact-export.ts
|
|
4416
|
+
function isRecord10(value) {
|
|
4417
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
4418
|
+
}
|
|
4419
|
+
function deepClone(value) {
|
|
4420
|
+
if (value === null || typeof value !== "object") {
|
|
4421
|
+
return value;
|
|
4422
|
+
}
|
|
4423
|
+
if (Array.isArray(value)) {
|
|
4424
|
+
return value.map((item) => deepClone(item));
|
|
4425
|
+
}
|
|
4426
|
+
const out = {};
|
|
4427
|
+
for (const [k, v] of Object.entries(value)) {
|
|
4428
|
+
out[k] = deepClone(v);
|
|
4429
|
+
}
|
|
4430
|
+
return out;
|
|
4431
|
+
}
|
|
4432
|
+
function boundAttributeValues(record, maxMetadataValueLength, maxPreviewLength, seen, depth) {
|
|
4433
|
+
if (depth > 32) {
|
|
4434
|
+
return { truncated: true, reason: "maxDepth" };
|
|
4435
|
+
}
|
|
4436
|
+
const out = {};
|
|
4437
|
+
for (const [key, value] of Object.entries(record)) {
|
|
4438
|
+
out[key] = boundValue(value, key, maxMetadataValueLength, maxPreviewLength, seen, depth);
|
|
4439
|
+
}
|
|
4440
|
+
return out;
|
|
4441
|
+
}
|
|
4442
|
+
function boundValue(value, key, maxMetadataValueLength, maxPreviewLength, seen, depth) {
|
|
4443
|
+
if (value === null || typeof value !== "object") {
|
|
4444
|
+
if (typeof value === "string") {
|
|
4445
|
+
return truncateStringForProfile(
|
|
4446
|
+
value,
|
|
4447
|
+
key,
|
|
4448
|
+
maxMetadataValueLength,
|
|
4449
|
+
maxPreviewLength
|
|
4450
|
+
);
|
|
4451
|
+
}
|
|
4452
|
+
return value;
|
|
4453
|
+
}
|
|
4454
|
+
if (seen.has(value)) return "[Circular]";
|
|
4455
|
+
seen.add(value);
|
|
4456
|
+
if (Array.isArray(value)) {
|
|
4457
|
+
return value.slice(0, 50).map(
|
|
4458
|
+
(item, index) => boundValue(
|
|
4459
|
+
item,
|
|
4460
|
+
String(index),
|
|
4461
|
+
maxMetadataValueLength,
|
|
4462
|
+
maxPreviewLength,
|
|
4463
|
+
seen,
|
|
4464
|
+
depth + 1
|
|
4465
|
+
)
|
|
4466
|
+
);
|
|
4467
|
+
}
|
|
4468
|
+
return boundAttributeValues(
|
|
4469
|
+
value,
|
|
4470
|
+
maxMetadataValueLength,
|
|
4471
|
+
maxPreviewLength,
|
|
4472
|
+
seen,
|
|
4473
|
+
depth + 1
|
|
4474
|
+
);
|
|
4475
|
+
}
|
|
4476
|
+
function redactEventAttributes(attrs, redactor, maxMetadataValueLength, maxPreviewLength) {
|
|
4477
|
+
if (!attrs || Object.keys(attrs).length === 0) {
|
|
4478
|
+
return attrs;
|
|
4479
|
+
}
|
|
4480
|
+
const redacted = redactor.redactRecord(attrs);
|
|
4481
|
+
const seen = /* @__PURE__ */ new WeakSet();
|
|
4482
|
+
const bounded = boundAttributeValues(
|
|
4483
|
+
redacted,
|
|
4484
|
+
maxMetadataValueLength,
|
|
4485
|
+
maxPreviewLength,
|
|
4486
|
+
seen,
|
|
4487
|
+
0
|
|
4488
|
+
);
|
|
4489
|
+
const err = bounded.error;
|
|
4490
|
+
if (isRecord10(err) && typeof err.message === "string") {
|
|
4491
|
+
bounded.error = {
|
|
4492
|
+
...err,
|
|
4493
|
+
message: truncateStringForProfile(
|
|
4494
|
+
err.message,
|
|
4495
|
+
"message",
|
|
4496
|
+
maxMetadataValueLength,
|
|
4497
|
+
maxPreviewLength
|
|
4498
|
+
),
|
|
4499
|
+
...typeof err.stack === "string" ? {
|
|
4500
|
+
stack: truncateStringForProfile(
|
|
4501
|
+
err.stack,
|
|
4502
|
+
"stack",
|
|
4503
|
+
maxMetadataValueLength,
|
|
4504
|
+
maxPreviewLength
|
|
4505
|
+
)
|
|
4506
|
+
} : {}
|
|
4507
|
+
};
|
|
4508
|
+
}
|
|
4509
|
+
return bounded;
|
|
4510
|
+
}
|
|
4511
|
+
function redactRunTreeForExport(tree, options) {
|
|
4512
|
+
const profile = options?.redactionProfile ?? "local";
|
|
4513
|
+
if (profile === "local") {
|
|
4514
|
+
return deepClone(tree);
|
|
4515
|
+
}
|
|
4516
|
+
const resolved = resolveRedactionProfile(profile);
|
|
4517
|
+
const { maxMetadataValueLength, maxPreviewLength } = applyProfileMetadataCaps(
|
|
4518
|
+
2e3,
|
|
4519
|
+
500,
|
|
4520
|
+
resolved
|
|
4521
|
+
);
|
|
4522
|
+
const redactor = new Redactor({ extraKeys: resolved.extraKeys });
|
|
4523
|
+
const clone = deepClone(tree);
|
|
4524
|
+
function walk(nodes) {
|
|
4525
|
+
for (const node of nodes) {
|
|
4526
|
+
if (node.event.attributes !== void 0) {
|
|
4527
|
+
node.event.attributes = redactEventAttributes(
|
|
4528
|
+
node.event.attributes,
|
|
4529
|
+
redactor,
|
|
4530
|
+
maxMetadataValueLength,
|
|
4531
|
+
maxPreviewLength
|
|
4532
|
+
);
|
|
4533
|
+
}
|
|
4534
|
+
if (node.children.length > 0) {
|
|
4535
|
+
walk(node.children);
|
|
4536
|
+
}
|
|
4537
|
+
}
|
|
4538
|
+
}
|
|
4539
|
+
walk(clone.children);
|
|
4540
|
+
return clone;
|
|
4541
|
+
}
|
|
4542
|
+
|
|
4247
4543
|
// packages/core/src/exporters/html-exporter.ts
|
|
4248
4544
|
function renderTreeHtml(nodes, ulClass = "tree") {
|
|
4249
4545
|
if (nodes.length === 0) return "";
|
|
@@ -4980,20 +5276,22 @@ function mergeExportDefaults(options) {
|
|
|
4980
5276
|
includeErrors: options.includeErrors ?? true,
|
|
4981
5277
|
pretty: options.pretty ?? true,
|
|
4982
5278
|
redacted: options.redacted ?? true,
|
|
4983
|
-
maxAttributeLength: options.maxAttributeLength ?? 500
|
|
5279
|
+
maxAttributeLength: options.maxAttributeLength ?? 500,
|
|
5280
|
+
redactionProfile: options.redactionProfile ?? "local"
|
|
4984
5281
|
};
|
|
4985
5282
|
}
|
|
4986
5283
|
function exportRunTree(tree, options) {
|
|
4987
5284
|
const opts = mergeExportDefaults(options);
|
|
5285
|
+
const exportTree = opts.redactionProfile === "local" ? tree : redactRunTreeForExport(tree, { redactionProfile: opts.redactionProfile });
|
|
4988
5286
|
switch (opts.format) {
|
|
4989
5287
|
case "markdown":
|
|
4990
|
-
return exportMarkdown(
|
|
5288
|
+
return exportMarkdown(exportTree, opts);
|
|
4991
5289
|
case "html":
|
|
4992
|
-
return exportHtml(
|
|
5290
|
+
return exportHtml(exportTree, opts);
|
|
4993
5291
|
case "openinference":
|
|
4994
|
-
return exportOpenInference(
|
|
5292
|
+
return exportOpenInference(exportTree, opts);
|
|
4995
5293
|
case "otlp-json":
|
|
4996
|
-
return exportOtlpJson(
|
|
5294
|
+
return exportOtlpJson(exportTree, opts);
|
|
4997
5295
|
default: {
|
|
4998
5296
|
const _x = opts.format;
|
|
4999
5297
|
throw new Error(`Unsupported export format: ${String(_x)}`);
|
|
@@ -5010,6 +5308,6 @@ function validateExport(result) {
|
|
|
5010
5308
|
};
|
|
5011
5309
|
}
|
|
5012
5310
|
|
|
5013
|
-
export { DEFAULT_LOG_INGEST_CONFIG, DEFAULT_MAX_EVENT_BYTES, DEFAULT_MAX_METADATA_VALUE_LENGTH, DEFAULT_MAX_PREVIEW_LENGTH, DEFAULT_REDACT_KEYS, DEFAULT_TRACE_DIR_NAME, EXPORT_PAYLOAD_VERSION, EventNormalizer, FALLBACK_TRACE_DIR, JsonLogParser, LiveLogAccumulator, Log4jsParser, MAX_NAME_LENGTH, MAX_TERMINAL_DEPTH, MAX_TERMINAL_NAME_LENGTH, RUNS_DIR_NAME, Redactor, TERMINAL_INDENT, TraceDirectory, TreeBuilder, buildRunSummary, compactAttributes4 as compactAttributes, createRunId, createStepId, diffRuns, diffTraceEvents, ensureTraceDir, escapeHtml, escapeMarkdown, exportHtml, exportMarkdown, exportOpenInference, exportOtlpJson, exportRunTree, extractMetadata, filterTraces, flattenTree, formatDuration2 as formatDuration, formatError, formatTerminalName, formatTimestamp, getCurrentContext, getCurrentDepth, getCurrentRunId, getCurrentRunName, getCurrentStepId, getDefaultTraceDir, getIndent, getParentStepId, getRunIdFromTraceFileName, getTraceDirFromContext, getTraceFilePath, getTraceSafetyFromContext, hasActiveContext, initializeTraceFile, inspectEventToPersistedInspectEvent, inspectEventsToPersistedInspectEvents, inspectRun, isAgentInspectEnabled, isAgentInspectTrace, isPersistedInspectEvent, isSilentContext, isStepStatus, isStepType, isTraceEvent, listTraceFiles, loadLogIngestConfig, manualTraceEventsToComparableRun, manualTraceEventsToRunTree, matchMapping, maybeInspectRun, mergeExportDefaults, mergeLogIngestConfig, observe, parseDuration, parseLogLine, parseLogsToTrees, persistedInspectEventToInspectEvent, persistedInspectEventsToInspectEvents, persistedInspectEventsToRunTrees, prepareMetadataForDisk, prepareTraceEventForDisk, printError, printFailedAt, printRunComplete, printRunStart, printStepComplete, printStepStart, readTraceEvents, readTraceFile, renderErrorLine, renderRunDiff, renderRunSummary, renderRunTree, renderRunTrees, renderStepLine, resolveTraceDir, resolveTraceSafetyOptions, runWithContext, runWithStepContext, safeString2 as safeString, serializeEvent, stableJson, step, summarizeTree, traceEventToPersistedInspectEvent, traceEventsToPersistedInspectEvents, traceEventsToPersistedRunTrees, truncateName, validateEvent, validateExport, validateExportContent, warn, wildcardMatch, writeTraceEvent };
|
|
5311
|
+
export { DEFAULT_LOG_INGEST_CONFIG, DEFAULT_MAX_EVENT_BYTES, DEFAULT_MAX_METADATA_VALUE_LENGTH, DEFAULT_MAX_PREVIEW_LENGTH, DEFAULT_REDACT_KEYS, DEFAULT_TRACE_DIR_NAME, EXPORT_PAYLOAD_VERSION, EventNormalizer, FALLBACK_TRACE_DIR, JsonLogParser, LiveLogAccumulator, Log4jsParser, MAX_NAME_LENGTH, MAX_TERMINAL_DEPTH, MAX_TERMINAL_NAME_LENGTH, RUNS_DIR_NAME, Redactor, TERMINAL_INDENT, TraceDirectory, TreeBuilder, buildRunSummary, compactAttributes4 as compactAttributes, createRunId, createStepId, diffRuns, diffTraceEvents, ensureTraceDir, escapeHtml, escapeMarkdown, exportHtml, exportMarkdown, exportOpenInference, exportOtlpJson, exportRunTree, extractMetadata, filterTraces, flattenTree, formatDuration2 as formatDuration, formatError, formatTerminalName, formatTimestamp, getCurrentContext, getCurrentCorrelationMetadata, getCurrentDepth, getCurrentRunId, getCurrentRunName, getCurrentStepId, getDefaultTraceDir, getIndent, getParentStepId, getRunIdFromTraceFileName, getTraceDirFromContext, getTraceFilePath, getTraceSafetyFromContext, hasActiveContext, initializeTraceFile, inspectEventToPersistedInspectEvent, inspectEventsToPersistedInspectEvents, inspectRun, isAgentInspectEnabled, isAgentInspectTrace, isPersistedInspectEvent, isSilentContext, isStepStatus, isStepType, isTraceEvent, listTraceFiles, loadLogIngestConfig, manualTraceEventsToComparableRun, manualTraceEventsToRunTree, matchMapping, maybeInspectRun, mergeExportDefaults, mergeLogIngestConfig, observe, parseDuration, parseLogLine, parseLogsToTrees, persistedInspectEventToInspectEvent, persistedInspectEventsToInspectEvents, persistedInspectEventsToRunTrees, prepareMetadataForDisk, prepareTraceEventForDisk, printError, printFailedAt, printRunComplete, printRunStart, printStepComplete, printStepStart, readTraceEvents, readTraceFile, redactRunTreeForExport, renderErrorLine, renderRunDiff, renderRunSummary, renderRunTree, renderRunTrees, renderStepLine, resolveRedactionProfile, resolveTraceDir, resolveTraceSafetyOptions, runWithContext, runWithStepContext, safeString2 as safeString, serializeEvent, stableJson, step, summarizeTree, traceEventToPersistedInspectEvent, traceEventsToPersistedInspectEvents, traceEventsToPersistedRunTrees, truncateName, validateEvent, validateExport, validateExportContent, warn, wildcardMatch, writeTraceEvent };
|
|
5014
5312
|
//# sourceMappingURL=index.mjs.map
|
|
5015
5313
|
//# sourceMappingURL=index.mjs.map
|