agent-inspect 6.17.5 → 6.17.7

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.
@@ -13,8 +13,9 @@ var readline = require('readline');
13
13
  var url = require('url');
14
14
  var module$1 = require('module');
15
15
  var commander = require('commander');
16
- var http = require('http');
17
16
  var child_process = require('child_process');
17
+ var util = require('util');
18
+ var http = require('http');
18
19
 
19
20
  var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
20
21
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
@@ -3019,29 +3020,30 @@ async function searchTraces(metas, options) {
3019
3020
  }
3020
3021
  function matchRunLevel(m, opts) {
3021
3022
  if (opts.stepTypeFilter || opts.toolQuery) return [];
3022
- const out = [];
3023
+ if (opts.statusFilter && m.status !== opts.statusFilter) return [];
3024
+ if (opts.nameQuery && !nameMatches(m.name ?? m.runId, opts.nameQuery)) {
3025
+ return [];
3026
+ }
3027
+ if (opts.durationFilter && !durationMatches(m.durationMs, opts.durationFilter)) {
3028
+ return [];
3029
+ }
3023
3030
  const fields = [];
3024
- if (opts.statusFilter && m.status === opts.statusFilter) {
3025
- fields.push("run.status");
3026
- }
3027
- if (opts.nameQuery && nameMatches(m.name ?? m.runId, opts.nameQuery)) {
3028
- fields.push("run.name");
3029
- }
3030
- if (opts.durationFilter && durationMatches(m.durationMs, opts.durationFilter)) {
3031
- fields.push("run.durationMs");
3032
- }
3033
- if (fields.length === 0) return out;
3034
- out.push({
3035
- runId: m.runId,
3036
- runName: m.name,
3037
- runStatus: m.status,
3038
- timestamp: m.startedAt,
3039
- durationMs: m.durationMs,
3040
- matchReason: `run match: ${fields.join(", ")}`,
3041
- matchedFields: fields,
3042
- filePath: m.filePath
3043
- });
3044
- return out;
3031
+ if (opts.statusFilter) fields.push("run.status");
3032
+ if (opts.nameQuery) fields.push("run.name");
3033
+ if (opts.durationFilter) fields.push("run.durationMs");
3034
+ if (fields.length === 0) return [];
3035
+ return [
3036
+ {
3037
+ runId: m.runId,
3038
+ runName: m.name,
3039
+ runStatus: m.status,
3040
+ timestamp: m.startedAt,
3041
+ durationMs: m.durationMs,
3042
+ matchReason: `run match: ${fields.join(", ")}`,
3043
+ matchedFields: fields,
3044
+ filePath: m.filePath
3045
+ }
3046
+ ];
3045
3047
  }
3046
3048
  function matchStepLevel(m, events, opts) {
3047
3049
  const out = [];
@@ -8417,7 +8419,11 @@ var init_checks2 = __esm({
8417
8419
  { id: "openai-key", pattern: /sk-[A-Za-z0-9_-]{16,}/ },
8418
8420
  { id: "aws-access-key", pattern: /AKIA[0-9A-Z]{16}/ },
8419
8421
  { id: "github-token", pattern: /gh[opsu]_[A-Za-z0-9_]{20,}/ },
8420
- { id: "key-value-secret", pattern: /(api[_-]?key|token|password|secret)=\S{8,}/i }
8422
+ // Keep in sync with packages/redact/src/key-value-secret.ts (KEY_VALUE_SECRET_PATTERN_SOURCE).
8423
+ {
8424
+ id: "key-value-secret",
8425
+ pattern: /\b(?:api[_-]?key|internal[_-]?token|access[_-]?token|auth[_-]?token|password|secret|token)=([^\s"'\\]{8,})/i
8426
+ }
8421
8427
  ];
8422
8428
  }
8423
8429
  });
@@ -12580,7 +12586,7 @@ var init_src = __esm({
12580
12586
  });
12581
12587
 
12582
12588
  // package.json
12583
- var version = "6.17.5";
12589
+ var version = "6.17.7";
12584
12590
 
12585
12591
  // packages/cli/src/list.ts
12586
12592
  init_advanced();
@@ -16527,6 +16533,17 @@ function isCredentialSensitiveKey2(key, sensitiveKeys) {
16527
16533
  return false;
16528
16534
  }
16529
16535
 
16536
+ // packages/redact/src/key-value-secret.ts
16537
+ var KEY_VALUE_SECRET_PATTERN_SOURCE = String.raw`\b(?:api[_-]?key|internal[_-]?token|access[_-]?token|auth[_-]?token|password|secret|token)=([^\s"'\\]{8,})`;
16538
+ var KEY_VALUE_SECRET_PATTERN = new RegExp(
16539
+ KEY_VALUE_SECRET_PATTERN_SOURCE,
16540
+ "i"
16541
+ );
16542
+ function valueContainsKeyValueSecret(value) {
16543
+ KEY_VALUE_SECRET_PATTERN.lastIndex = 0;
16544
+ return KEY_VALUE_SECRET_PATTERN.test(value);
16545
+ }
16546
+
16530
16547
  // packages/redact/src/index.ts
16531
16548
  var DEFAULT_REDACT_KEYS2 = [
16532
16549
  "authorization",
@@ -16733,6 +16750,15 @@ var credentialDetectors = [
16733
16750
  pattern: /-----BEGIN [A-Z ]*PRIVATE KEY-----[\s\S]*-----END [A-Z ]*PRIVATE KEY-----/,
16734
16751
  severity: "error"
16735
16752
  }),
16753
+ {
16754
+ id: "value.keyValueSecret",
16755
+ severity: "error",
16756
+ matchKind: "value",
16757
+ detect(input3) {
16758
+ if (typeof input3.value !== "string") return [];
16759
+ return valueContainsKeyValueSecret(input3.value) ? [{ action: "replace", severity: "error", matchKind: "value" }] : [];
16760
+ }
16761
+ },
16736
16762
  {
16737
16763
  id: "value.creditCard",
16738
16764
  severity: "error",
@@ -18456,6 +18482,7 @@ function mergeSafetyExtensions(result, read, options) {
18456
18482
  }
18457
18483
 
18458
18484
  // packages/cli/src/check.ts
18485
+ var execFileAsync = util.promisify(child_process.execFile);
18459
18486
  var DEFAULT_SELECT = ["run.status"];
18460
18487
  function uniqueSelectIds(ids) {
18461
18488
  const seen = /* @__PURE__ */ new Set();
@@ -18468,12 +18495,30 @@ function uniqueSelectIds(ids) {
18468
18495
  }
18469
18496
  return out;
18470
18497
  }
18498
+ function resolveForbiddenToolOptions(options) {
18499
+ const merged = [...options.forbiddenTool ?? [], ...options.forbidTool ?? []];
18500
+ const seen = /* @__PURE__ */ new Set();
18501
+ const out = [];
18502
+ for (const name of merged) {
18503
+ if (seen.has(name)) continue;
18504
+ seen.add(name);
18505
+ out.push(name);
18506
+ }
18507
+ return out;
18508
+ }
18509
+ function withResolvedForbiddenTools(options) {
18510
+ return {
18511
+ ...options,
18512
+ forbiddenTool: resolveForbiddenToolOptions(options),
18513
+ forbidTool: void 0
18514
+ };
18515
+ }
18471
18516
  function cliShorthandSelectIds(options) {
18472
18517
  const ids = [];
18473
18518
  if (options.failOnObservation !== void 0 && options.failOnObservation.trim() !== "") {
18474
18519
  ids.push("outcome.status");
18475
18520
  }
18476
- if ((options.requiredTool?.length ?? 0) > 0 || (options.forbiddenTool?.length ?? 0) > 0) {
18521
+ if ((options.requiredTool?.length ?? 0) > 0 || (options.forbiddenTool?.length ?? 0) > 0 || (options.forbidTool?.length ?? 0) > 0) {
18477
18522
  ids.push("tool.usage");
18478
18523
  }
18479
18524
  if ((options.allowedModel?.length ?? 0) > 0 || options.maxTotalTokens !== void 0) {
@@ -18902,8 +18947,7 @@ async function loadConfig(configPath) {
18902
18947
  const raw = await promises.readFile(absolute, "utf-8");
18903
18948
  return parseCheckConfig(JSON.parse(raw));
18904
18949
  }
18905
- const mod = await import(url.pathToFileURL(absolute).href);
18906
- return parseCheckConfig("default" in mod ? mod.default : mod);
18950
+ return parseCheckConfig(await importJsCheckConfig(absolute));
18907
18951
  } catch (error) {
18908
18952
  if (error instanceof CheckConfigError) throw error;
18909
18953
  const message = error instanceof Error ? error.message : String(error);
@@ -18913,6 +18957,46 @@ async function loadConfig(configPath) {
18913
18957
  );
18914
18958
  }
18915
18959
  }
18960
+ async function importJsCheckConfig(absolute) {
18961
+ const href = url.pathToFileURL(absolute).href;
18962
+ if (!process.env.VITEST) {
18963
+ const mod = await import(
18964
+ /* @vite-ignore */
18965
+ href
18966
+ );
18967
+ return "default" in mod ? mod.default : mod;
18968
+ }
18969
+ const script = `
18970
+ const mod = await import(${JSON.stringify(href)});
18971
+ const value = "default" in mod ? mod.default : mod;
18972
+ process.stdout.write(JSON.stringify({ ok: true, value }));
18973
+ `;
18974
+ const env2 = { ...process.env };
18975
+ delete env2.NODE_OPTIONS;
18976
+ delete env2.VITEST;
18977
+ delete env2.VITEST_WORKER_ID;
18978
+ const { stdout, stderr } = await execFileAsync(
18979
+ process.execPath,
18980
+ ["--input-type=module", "--eval", script],
18981
+ {
18982
+ encoding: "utf8",
18983
+ maxBuffer: 4 * 1024 * 1024,
18984
+ env: env2
18985
+ }
18986
+ );
18987
+ try {
18988
+ const parsed = JSON.parse(stdout);
18989
+ if (parsed.ok !== true) {
18990
+ throw new Error(stderr.trim() || "Check config module did not return a value");
18991
+ }
18992
+ return parsed.value;
18993
+ } catch (error) {
18994
+ if (stderr.trim()) {
18995
+ throw new Error(stderr.trim());
18996
+ }
18997
+ throw error instanceof Error ? error : new Error(String(error));
18998
+ }
18999
+ }
18916
19000
  function normalizeConfig(config) {
18917
19001
  if (config.checks === void 0) return {};
18918
19002
  if (typeof config.checks !== "object" || Array.isArray(config.checks)) {
@@ -19155,6 +19239,7 @@ function readErrorResult(error) {
19155
19239
  );
19156
19240
  }
19157
19241
  async function checkCommand(target, options = {}, stdin = process.stdin) {
19242
+ options = withResolvedForbiddenTools(options);
19158
19243
  let result;
19159
19244
  let phase = "config";
19160
19245
  let evidenceRead;
@@ -25183,6 +25268,9 @@ function createCliProgram() {
25183
25268
  ]).option("--forbidden-tool <name>", "forbid a tool name (repeatable)", (value, previous = []) => [
25184
25269
  ...previous,
25185
25270
  value
25271
+ ]).option("--forbid-tool <name>", "alias for --forbidden-tool (repeatable)", (value, previous = []) => [
25272
+ ...previous,
25273
+ value
25186
25274
  ]).option("--allowed-model <model>", "allow an LLM model (repeatable)", (value, previous = []) => [
25187
25275
  ...previous,
25188
25276
  value