agent-inspect 6.31.2 → 6.31.4
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 +14 -0
- package/README.md +1 -1
- package/SECURITY.md +2 -0
- package/docs/GETTING-STARTED.md +2 -0
- package/docs/SAFE-TRACE-SHARING.md +1 -0
- package/package.json +1 -1
- package/packages/cli/dist/{chunk-SJ6FRNOE.mjs → chunk-LKEPABND.mjs} +86 -80
- package/packages/cli/dist/chunk-LKEPABND.mjs.map +1 -0
- package/packages/cli/dist/index.cjs +406 -93
- package/packages/cli/dist/index.cjs.map +1 -1
- package/packages/cli/dist/index.mjs +314 -16
- package/packages/cli/dist/index.mjs.map +1 -1
- package/packages/cli/dist/{src-YNEJOPRA.mjs → src-4WYF5RFI.mjs} +3 -3
- package/packages/cli/dist/{src-YNEJOPRA.mjs.map → src-4WYF5RFI.mjs.map} +1 -1
- package/packages/core/dist/advanced.cjs +97 -30
- package/packages/core/dist/advanced.cjs.map +1 -1
- package/packages/core/dist/advanced.mjs +13 -13
- package/packages/core/dist/checks.cjs +51 -49
- package/packages/core/dist/checks.cjs.map +1 -1
- package/packages/core/dist/checks.mjs +5 -5
- package/packages/core/dist/{chunk-PBNBQRXV.mjs → chunk-2KJR6X4V.mjs} +9 -9
- package/packages/core/dist/chunk-2KJR6X4V.mjs.map +1 -0
- package/packages/core/dist/{chunk-26YJSETN.mjs → chunk-7DHSWDKB.mjs} +19 -6
- package/packages/core/dist/chunk-7DHSWDKB.mjs.map +1 -0
- package/packages/core/dist/{chunk-BGF5JDJN.mjs → chunk-INE5IWLN.mjs} +3 -3
- package/packages/core/dist/{chunk-BGF5JDJN.mjs.map → chunk-INE5IWLN.mjs.map} +1 -1
- package/packages/core/dist/{chunk-ZFJ2ICTC.mjs → chunk-MTMTXTJL.mjs} +5 -5
- package/packages/core/dist/{chunk-ZFJ2ICTC.mjs.map → chunk-MTMTXTJL.mjs.map} +1 -1
- package/packages/core/dist/{chunk-KWBO36PH.mjs → chunk-NY4ILMXK.mjs} +4 -4
- package/packages/core/dist/{chunk-KWBO36PH.mjs.map → chunk-NY4ILMXK.mjs.map} +1 -1
- package/packages/core/dist/{chunk-WN5PT4GV.mjs → chunk-OSGNGRHF.mjs} +3 -3
- package/packages/core/dist/{chunk-WN5PT4GV.mjs.map → chunk-OSGNGRHF.mjs.map} +1 -1
- package/packages/core/dist/{chunk-CBPWLHNQ.mjs → chunk-PKDBFBJ7.mjs} +5 -76
- package/packages/core/dist/chunk-PKDBFBJ7.mjs.map +1 -0
- package/packages/core/dist/{chunk-VU6O5QAH.mjs → chunk-VLVCLAPB.mjs} +83 -5
- package/packages/core/dist/chunk-VLVCLAPB.mjs.map +1 -0
- package/packages/core/dist/exporters.cjs +224 -8
- package/packages/core/dist/exporters.cjs.map +1 -1
- package/packages/core/dist/exporters.mjs +125 -11
- package/packages/core/dist/exporters.mjs.map +1 -1
- package/packages/core/dist/index.cjs +97 -8
- package/packages/core/dist/index.cjs.map +1 -1
- package/packages/core/dist/index.mjs +6 -6
- package/packages/core/dist/logs.cjs +80 -2
- package/packages/core/dist/logs.cjs.map +1 -1
- package/packages/core/dist/logs.d.cts +2 -0
- package/packages/core/dist/logs.d.ts +2 -0
- package/packages/core/dist/logs.mjs +2 -2
- package/packages/core/dist/readers.cjs +2 -0
- package/packages/core/dist/readers.cjs.map +1 -1
- package/packages/core/dist/readers.mjs +2 -2
- package/packages/core/dist/writers.cjs +96 -8
- package/packages/core/dist/writers.cjs.map +1 -1
- package/packages/core/dist/writers.mjs +7 -8
- package/packages/core/dist/writers.mjs.map +1 -1
- package/packages/cli/dist/chunk-SJ6FRNOE.mjs.map +0 -1
- package/packages/core/dist/chunk-26YJSETN.mjs.map +0 -1
- package/packages/core/dist/chunk-CBPWLHNQ.mjs.map +0 -1
- package/packages/core/dist/chunk-PBNBQRXV.mjs.map +0 -1
- package/packages/core/dist/chunk-VU6O5QAH.mjs.map +0 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export { BUILTIN_MAPPING_LEDGERS, DEFAULT_TRACE_READERS, OPENINFERENCE_MAPPING_LEDGER, OTLP_JSON_MAPPING_LEDGER, TraceReadError, agentInspectJsonlReader, assertTraceInput, detectTraceFormat, getMappingLedger, openInferenceJsonReader, openTrace, openTraceDirectory, openTraceFile, openTraceText, otlpJsonReader, readTrace } from './chunk-
|
|
1
|
+
export { BUILTIN_MAPPING_LEDGERS, DEFAULT_TRACE_READERS, OPENINFERENCE_MAPPING_LEDGER, OTLP_JSON_MAPPING_LEDGER, TraceReadError, agentInspectJsonlReader, assertTraceInput, detectTraceFormat, getMappingLedger, openInferenceJsonReader, openTrace, openTraceDirectory, openTraceFile, openTraceText, otlpJsonReader, readTrace } from './chunk-OSGNGRHF.mjs';
|
|
2
2
|
export { PROGRAMMATIC_DIAGNOSTIC_SPECS, formatProgrammaticDiagnostic } from './chunk-FWK3Q3OJ.mjs';
|
|
3
3
|
import './chunk-Q5SLKV2Y.mjs';
|
|
4
4
|
import './chunk-S4YWKV4G.mjs';
|
|
5
5
|
import './chunk-AK5EN4U2.mjs';
|
|
6
|
-
import './chunk-
|
|
6
|
+
import './chunk-7DHSWDKB.mjs';
|
|
7
7
|
import './chunk-EE5Z2GQ3.mjs';
|
|
8
8
|
import './chunk-7TGZLWEE.mjs';
|
|
9
9
|
//# sourceMappingURL=readers.mjs.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var promises = require('fs/promises');
|
|
4
3
|
var path = require('path');
|
|
5
4
|
var crypto = require('crypto');
|
|
5
|
+
var promises = require('fs/promises');
|
|
6
6
|
var os = require('os');
|
|
7
7
|
|
|
8
8
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -12,6 +12,80 @@ var crypto__default = /*#__PURE__*/_interopDefault(crypto);
|
|
|
12
12
|
var os__default = /*#__PURE__*/_interopDefault(os);
|
|
13
13
|
|
|
14
14
|
// packages/core/src/writers/index.ts
|
|
15
|
+
|
|
16
|
+
// packages/core/src/safety/sensitive-key.ts
|
|
17
|
+
function keyHasExplicitSeparator(value) {
|
|
18
|
+
return /[_\-.]/.test(value);
|
|
19
|
+
}
|
|
20
|
+
function normalizeSensitiveKey(value) {
|
|
21
|
+
return value.replace(/([a-z0-9])([A-Z])/g, "$1_$2").toLowerCase().replace(/[^a-z0-9]+/g, "_").replace(/^_+|_+$/g, "");
|
|
22
|
+
}
|
|
23
|
+
var NON_CREDENTIAL_TOKEN_CONFIG_KEYS = new Set(
|
|
24
|
+
[
|
|
25
|
+
"tokens",
|
|
26
|
+
"max_tokens",
|
|
27
|
+
"min_tokens",
|
|
28
|
+
"ls_max_tokens",
|
|
29
|
+
"token_count",
|
|
30
|
+
"token_limit",
|
|
31
|
+
"token_budget",
|
|
32
|
+
"input_tokens",
|
|
33
|
+
"output_tokens",
|
|
34
|
+
"total_tokens",
|
|
35
|
+
"cached_tokens",
|
|
36
|
+
"prompt_tokens",
|
|
37
|
+
"completion_tokens"
|
|
38
|
+
].map(normalizeSensitiveKey)
|
|
39
|
+
);
|
|
40
|
+
var DEFAULT_CREDENTIAL_SENSITIVE_KEYS = [
|
|
41
|
+
"authorization",
|
|
42
|
+
"cookie",
|
|
43
|
+
"token",
|
|
44
|
+
"access_token",
|
|
45
|
+
"accesstoken",
|
|
46
|
+
"auth_token",
|
|
47
|
+
"authtoken",
|
|
48
|
+
"refresh_token",
|
|
49
|
+
"refreshtoken",
|
|
50
|
+
"id_token",
|
|
51
|
+
"idtoken",
|
|
52
|
+
"bearer_token",
|
|
53
|
+
"bearertoken",
|
|
54
|
+
"api_token",
|
|
55
|
+
"apitoken",
|
|
56
|
+
"apikey",
|
|
57
|
+
"api_key",
|
|
58
|
+
"password",
|
|
59
|
+
"secret",
|
|
60
|
+
"email"
|
|
61
|
+
];
|
|
62
|
+
function isTokenCredentialKey(normalized) {
|
|
63
|
+
if (NON_CREDENTIAL_TOKEN_CONFIG_KEYS.has(normalized)) return false;
|
|
64
|
+
if (normalized === "token") return true;
|
|
65
|
+
if (normalized.endsWith("tokens")) return false;
|
|
66
|
+
return normalized.endsWith("token");
|
|
67
|
+
}
|
|
68
|
+
function isCredentialSensitiveKey(key, sensitiveKeys = DEFAULT_CREDENTIAL_SENSITIVE_KEYS) {
|
|
69
|
+
if (!key) return false;
|
|
70
|
+
const normalized = normalizeSensitiveKey(key);
|
|
71
|
+
if (!normalized) return false;
|
|
72
|
+
if (NON_CREDENTIAL_TOKEN_CONFIG_KEYS.has(normalized)) return false;
|
|
73
|
+
const allowPrefixCompound = keyHasExplicitSeparator(key);
|
|
74
|
+
for (const sensitive of sensitiveKeys) {
|
|
75
|
+
const s = normalizeSensitiveKey(sensitive);
|
|
76
|
+
if (!s) continue;
|
|
77
|
+
if (s === "token") {
|
|
78
|
+
if (isTokenCredentialKey(normalized)) return true;
|
|
79
|
+
continue;
|
|
80
|
+
}
|
|
81
|
+
if (normalized === s) return true;
|
|
82
|
+
if (normalized.endsWith(`_${s}`)) return true;
|
|
83
|
+
if (allowPrefixCompound && normalized.startsWith(`${s}_`)) return true;
|
|
84
|
+
}
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// packages/core/src/logs/redactor.ts
|
|
15
89
|
var DEFAULT_REDACT_KEYS = [
|
|
16
90
|
"authorization",
|
|
17
91
|
"cookie",
|
|
@@ -35,7 +109,7 @@ function compileRules(rules, extraKeys) {
|
|
|
35
109
|
const out = /* @__PURE__ */ new Map();
|
|
36
110
|
const set = (r) => {
|
|
37
111
|
const k = toKey(r.key);
|
|
38
|
-
out.set(k, { ...r, key: k });
|
|
112
|
+
out.set(k, { ...r, key: k, raw: r.raw ?? r.key });
|
|
39
113
|
};
|
|
40
114
|
for (const k of DEFAULT_REDACT_KEYS) {
|
|
41
115
|
set({ key: k, strategy: "full" });
|
|
@@ -64,9 +138,13 @@ var Redactor = class {
|
|
|
64
138
|
constructor(options) {
|
|
65
139
|
this.#rules = compileRules(options?.rules, options?.extraKeys);
|
|
66
140
|
}
|
|
141
|
+
/** Field names this redactor treats as sensitive, for value-level helpers. */
|
|
142
|
+
get sensitiveKeys() {
|
|
143
|
+
return this.#rules.map((rule) => rule.raw ?? rule.key);
|
|
144
|
+
}
|
|
67
145
|
redactValue(key, value) {
|
|
68
146
|
const k = toKey(key);
|
|
69
|
-
const rule = this.#rules.find((r) => r.key === k);
|
|
147
|
+
const rule = this.#rules.find((r) => r.key === k) ?? this.#rules.find((r) => isCredentialSensitiveKey(key, [r.raw ?? r.key]));
|
|
70
148
|
if (!rule) {
|
|
71
149
|
return this.#redactNested(value);
|
|
72
150
|
}
|
|
@@ -106,7 +184,7 @@ var Redactor = class {
|
|
|
106
184
|
};
|
|
107
185
|
|
|
108
186
|
// packages/core/src/safety/credential-value-patterns.ts
|
|
109
|
-
var KEY_VALUE_SECRET_PATTERN = /\b(?:api[_-]?key|internal[_-]?token|access[_-]?token|auth[_-]?token|password|secret|token)=([^\s"'\\]{8,})/i;
|
|
187
|
+
var KEY_VALUE_SECRET_PATTERN = /\b(?:api[_-]?key|internal[_-]?token|access[_-]?token|auth[_-]?token|password|secret|token)=(?!\[(?:REDACTED(?::[^\]]*)?|HASH:[0-9a-f]{8})\](?![^\s"'\\&#?;/]))([^\s"'\\]{8,})/i;
|
|
110
188
|
var HIGH_CONFIDENCE_CREDENTIAL_PATTERNS = [
|
|
111
189
|
/^(?:basic|bearer|digest|apikey)\s+[a-z0-9._~+/=-]+$/i,
|
|
112
190
|
/\bbearer\s+[a-z0-9._~+/=-]{12,}\b/i,
|
|
@@ -332,6 +410,16 @@ function isPersistedInspectEvent(value) {
|
|
|
332
410
|
}
|
|
333
411
|
return true;
|
|
334
412
|
}
|
|
413
|
+
var TRACE_DIR_MODE = 448;
|
|
414
|
+
var TRACE_FILE_MODE = 384;
|
|
415
|
+
async function mkdirTraceDir(dirPath) {
|
|
416
|
+
await promises.mkdir(dirPath, { recursive: true, mode: TRACE_DIR_MODE });
|
|
417
|
+
}
|
|
418
|
+
async function appendTraceFile(filePath, data) {
|
|
419
|
+
await promises.appendFile(filePath, data, { encoding: "utf-8", mode: TRACE_FILE_MODE });
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
// packages/core/src/utils.ts
|
|
335
423
|
var DEFAULT_TRACE_DIR_NAME = ".agent-inspect";
|
|
336
424
|
var RUNS_DIR_NAME = "runs";
|
|
337
425
|
var FALLBACK_TRACE_DIR = path__default.default.join(
|
|
@@ -786,8 +874,8 @@ function serializeEvent2(event) {
|
|
|
786
874
|
}
|
|
787
875
|
async function appendEventLine(event, options) {
|
|
788
876
|
const filePath = resolveFilePath(event, options);
|
|
789
|
-
await
|
|
790
|
-
await
|
|
877
|
+
await mkdirTraceDir(path__default.default.dirname(filePath));
|
|
878
|
+
await appendTraceFile(filePath, serializeEvent2(event));
|
|
791
879
|
}
|
|
792
880
|
async function appendEventBatch(events, options) {
|
|
793
881
|
const byPath = /* @__PURE__ */ new Map();
|
|
@@ -811,8 +899,8 @@ async function appendEventBatch(events, options) {
|
|
|
811
899
|
let written = 0;
|
|
812
900
|
for (const [filePath, lines] of byPath) {
|
|
813
901
|
try {
|
|
814
|
-
await
|
|
815
|
-
await
|
|
902
|
+
await mkdirTraceDir(path__default.default.dirname(filePath));
|
|
903
|
+
await appendTraceFile(filePath, lines.join(""));
|
|
816
904
|
written += lines.length;
|
|
817
905
|
} catch (error) {
|
|
818
906
|
dropped += lines.length;
|