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.
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { createSafetyRawContentRule, createSafetyRedactionRule, createSafetySecretPatternRule, createSafetyOversizedAttributeRule, resolveTraceDir, parseDuration, buildSessionIndex, resolveBundleRunIds, getTraceFilePath, openTrace, sha256Hex, collectTraceSchemaVersions, aggregateBundleSafeStatus, bundleFailsOnSafety, bundleRunAssetRelativePath, buildPlaceholderArtifact, EVIDENCE_HTML_FILENAME, EVIDENCE_MANIFEST_FILENAME, buildBundleMetadata, buildBundleSummaryMarkdown, buildEvidenceHtmlShell, buildEvidenceProvenanceViewHtml, EVIDENCE_FORMAT_VERSION, inferEvidenceFileRole, buildEvidenceSafetyViewHtml, buildEvidenceDiffViewHtml, buildEvidenceCircuitViewHtml, buildEvidenceOutcomesViewHtml, buildEvidenceContractsViewHtml, buildEvidenceToolsLlmViewHtml, buildEvidenceCausalFailureViewHtml, buildEvidenceTimelineViewHtml, buildEvidenceTreeViewHtml, buildEvidenceManifest, serializeEvidenceManifest, buildZipArchive, assertBundlePathContained, enrichSessionRunRecord, normalizeBundleOutputPath, sanitizeBundleRunId, defaultBundleOutputPath, runTraceChecks, assertEvidenceRelativePath, TraceDirectory, loadTraceMetadataList, loadSessionRunRecords, TraceReadError, resolveRedactionProfile, applyProfileMetadataCaps, Redactor, flattenTree, escapeHtml, safeString, compactAttributes, stableJson, escapeMarkdown, truncateStringForProfile, extractMetadata, filterTraces, truncateName, buildRunSummary, formatDuration, formatTimestamp, isAgentInspectTrace, filterMetasBySessionScope, aggregateSessionCheckResults, createBaselineRegressionRule, summarizeSemanticParity, buildEvidenceCiPackage, verifyEvidenceDirectory, diffTraceEvents, renderRunDiff, buildRunTimeline, renderTimeline, buildTraceStats, renderTraceStats, parseDurationFilter, searchTraces, formatStepLabel, buildActivitySummary, renderActivitySummaryHuman, buildRunWhatSummary, renderRunWhat, buildLocalExplanation, resolveSuiteTemplate, defaultSuiteConfigTemplate, loadSuiteConfig, validateSuiteConfig, runSuite, renderSuiteReport, analyzeCohort, renderCohortReport, gateHasThresholds, runGate, renderGateReport, persistedInspectEventsToTraceEvents, renderStepLine, renderErrorLine, getIndent, TreeBuilder, zeroKinds, validateEvent, traceEventToPersistedInspectEvent, isPersistedInspectEvent, createRunStatusRule, createStructureOrphanRule, createStructureCycleRule, createRunDurationRule, createMaxStepDurationRule, createRequireCompletedRule, createStallDetectionRule, createObservedOutcomeRule, createRunDepthRule, createToolUsageRule, createLlmUsageRule, createStructureRelationshipRule, createStructureParallelWidthRule, summarizeObservedOutcomes, extractOutcomesFromTraceEvents, renderObservedOutcomesMarkdown, renderObservedOutcomesHtml, DEFAULT_SUITE_ARTIFACTS_DIR, parseCohortMetricList, COHORT_METRIC_IDS, parseGateList, nanoid, diffRuns, manualTraceEventsToComparableRun } from './chunk-GOHYSE7W.mjs';
2
+ import { createSafetyRawContentRule, createSafetyRedactionRule, createSafetySecretPatternRule, createSafetyOversizedAttributeRule, resolveTraceDir, parseDuration, buildSessionIndex, resolveBundleRunIds, getTraceFilePath, openTrace, sha256Hex, collectTraceSchemaVersions, aggregateBundleSafeStatus, bundleFailsOnSafety, bundleRunAssetRelativePath, buildPlaceholderArtifact, EVIDENCE_HTML_FILENAME, EVIDENCE_MANIFEST_FILENAME, buildBundleMetadata, buildBundleSummaryMarkdown, buildEvidenceHtmlShell, buildEvidenceProvenanceViewHtml, EVIDENCE_FORMAT_VERSION, inferEvidenceFileRole, buildEvidenceSafetyViewHtml, buildEvidenceDiffViewHtml, buildEvidenceCircuitViewHtml, buildEvidenceOutcomesViewHtml, buildEvidenceContractsViewHtml, buildEvidenceToolsLlmViewHtml, buildEvidenceCausalFailureViewHtml, buildEvidenceTimelineViewHtml, buildEvidenceTreeViewHtml, buildEvidenceManifest, serializeEvidenceManifest, buildZipArchive, assertBundlePathContained, enrichSessionRunRecord, normalizeBundleOutputPath, sanitizeBundleRunId, defaultBundleOutputPath, runTraceChecks, assertEvidenceRelativePath, TraceDirectory, loadTraceMetadataList, loadSessionRunRecords, TraceReadError, resolveRedactionProfile, applyProfileMetadataCaps, Redactor, flattenTree, escapeHtml, safeString, compactAttributes, stableJson, escapeMarkdown, truncateStringForProfile, extractMetadata, filterTraces, truncateName, buildRunSummary, formatDuration, formatTimestamp, isAgentInspectTrace, filterMetasBySessionScope, aggregateSessionCheckResults, createBaselineRegressionRule, summarizeSemanticParity, buildEvidenceCiPackage, verifyEvidenceDirectory, diffTraceEvents, renderRunDiff, buildRunTimeline, renderTimeline, buildTraceStats, renderTraceStats, parseDurationFilter, searchTraces, formatStepLabel, buildActivitySummary, renderActivitySummaryHuman, buildRunWhatSummary, renderRunWhat, buildLocalExplanation, resolveSuiteTemplate, defaultSuiteConfigTemplate, loadSuiteConfig, validateSuiteConfig, runSuite, renderSuiteReport, analyzeCohort, renderCohortReport, gateHasThresholds, runGate, renderGateReport, persistedInspectEventsToTraceEvents, renderStepLine, renderErrorLine, getIndent, TreeBuilder, zeroKinds, validateEvent, traceEventToPersistedInspectEvent, isPersistedInspectEvent, createRunStatusRule, createStructureOrphanRule, createStructureCycleRule, createRunDurationRule, createMaxStepDurationRule, createRequireCompletedRule, createStallDetectionRule, createObservedOutcomeRule, createRunDepthRule, createToolUsageRule, createLlmUsageRule, createStructureRelationshipRule, createStructureParallelWidthRule, summarizeObservedOutcomes, extractOutcomesFromTraceEvents, renderObservedOutcomesMarkdown, renderObservedOutcomesHtml, DEFAULT_SUITE_ARTIFACTS_DIR, parseCohortMetricList, COHORT_METRIC_IDS, parseGateList, nanoid, diffRuns, manualTraceEventsToComparableRun } from './chunk-25LUDS4T.mjs';
3
3
  import { realpathSync, constants as constants$1, existsSync, readFileSync } from 'fs';
4
4
  import path18 from 'path';
5
5
  import { fileURLToPath, pathToFileURL } from 'url';
@@ -7,12 +7,13 @@ import { Command, Option } from 'commander';
7
7
  import { readFile, stat, mkdir, writeFile, unlink, appendFile, access, rm, open, readdir, constants } from 'fs/promises';
8
8
  import process2, { stdin, stdout } from 'process';
9
9
  import crypto, { createHash } from 'crypto';
10
+ import { execFile, spawn } from 'child_process';
11
+ import { promisify } from 'util';
10
12
  import { createServer } from 'http';
11
- import { spawn } from 'child_process';
12
13
  import { createRequire } from 'module';
13
14
 
14
15
  // package.json
15
- var version = "6.17.5";
16
+ var version = "6.17.7";
16
17
 
17
18
  // packages/cli/src/trace-dir-scale.ts
18
19
  var TRACE_COUNT_WARN = 1e3;
@@ -3352,7 +3353,7 @@ async function newestTraceMtimeMs(traceDir) {
3352
3353
  }
3353
3354
  async function loadSessionRuns(traceDir) {
3354
3355
  try {
3355
- const mod = await import('./src-OYGG7QAZ.mjs');
3356
+ const mod = await import('./src-2FS6BLR7.mjs');
3356
3357
  const dbPath = mod.resolveIndexDbPath(traceDir);
3357
3358
  const status = mod.indexStatus(dbPath);
3358
3359
  if (!status.healthy) {
@@ -3874,6 +3875,17 @@ function isCredentialSensitiveKey(key, sensitiveKeys) {
3874
3875
  return false;
3875
3876
  }
3876
3877
 
3878
+ // packages/redact/src/key-value-secret.ts
3879
+ var KEY_VALUE_SECRET_PATTERN_SOURCE = String.raw`\b(?:api[_-]?key|internal[_-]?token|access[_-]?token|auth[_-]?token|password|secret|token)=([^\s"'\\]{8,})`;
3880
+ var KEY_VALUE_SECRET_PATTERN = new RegExp(
3881
+ KEY_VALUE_SECRET_PATTERN_SOURCE,
3882
+ "i"
3883
+ );
3884
+ function valueContainsKeyValueSecret(value) {
3885
+ KEY_VALUE_SECRET_PATTERN.lastIndex = 0;
3886
+ return KEY_VALUE_SECRET_PATTERN.test(value);
3887
+ }
3888
+
3877
3889
  // packages/redact/src/index.ts
3878
3890
  var DEFAULT_REDACT_KEYS2 = [
3879
3891
  "authorization",
@@ -4080,6 +4092,15 @@ var credentialDetectors = [
4080
4092
  pattern: /-----BEGIN [A-Z ]*PRIVATE KEY-----[\s\S]*-----END [A-Z ]*PRIVATE KEY-----/,
4081
4093
  severity: "error"
4082
4094
  }),
4095
+ {
4096
+ id: "value.keyValueSecret",
4097
+ severity: "error",
4098
+ matchKind: "value",
4099
+ detect(input3) {
4100
+ if (typeof input3.value !== "string") return [];
4101
+ return valueContainsKeyValueSecret(input3.value) ? [{ action: "replace", severity: "error", matchKind: "value" }] : [];
4102
+ }
4103
+ },
4083
4104
  {
4084
4105
  id: "value.creditCard",
4085
4106
  severity: "error",
@@ -5786,6 +5807,7 @@ function mergeSafetyExtensions(result, read, options) {
5786
5807
  }
5787
5808
 
5788
5809
  // packages/cli/src/check.ts
5810
+ var execFileAsync = promisify(execFile);
5789
5811
  var DEFAULT_SELECT = ["run.status"];
5790
5812
  function uniqueSelectIds(ids) {
5791
5813
  const seen = /* @__PURE__ */ new Set();
@@ -5798,12 +5820,30 @@ function uniqueSelectIds(ids) {
5798
5820
  }
5799
5821
  return out;
5800
5822
  }
5823
+ function resolveForbiddenToolOptions(options) {
5824
+ const merged = [...options.forbiddenTool ?? [], ...options.forbidTool ?? []];
5825
+ const seen = /* @__PURE__ */ new Set();
5826
+ const out = [];
5827
+ for (const name of merged) {
5828
+ if (seen.has(name)) continue;
5829
+ seen.add(name);
5830
+ out.push(name);
5831
+ }
5832
+ return out;
5833
+ }
5834
+ function withResolvedForbiddenTools(options) {
5835
+ return {
5836
+ ...options,
5837
+ forbiddenTool: resolveForbiddenToolOptions(options),
5838
+ forbidTool: void 0
5839
+ };
5840
+ }
5801
5841
  function cliShorthandSelectIds(options) {
5802
5842
  const ids = [];
5803
5843
  if (options.failOnObservation !== void 0 && options.failOnObservation.trim() !== "") {
5804
5844
  ids.push("outcome.status");
5805
5845
  }
5806
- if ((options.requiredTool?.length ?? 0) > 0 || (options.forbiddenTool?.length ?? 0) > 0) {
5846
+ if ((options.requiredTool?.length ?? 0) > 0 || (options.forbiddenTool?.length ?? 0) > 0 || (options.forbidTool?.length ?? 0) > 0) {
5807
5847
  ids.push("tool.usage");
5808
5848
  }
5809
5849
  if ((options.allowedModel?.length ?? 0) > 0 || options.maxTotalTokens !== void 0) {
@@ -6232,8 +6272,7 @@ async function loadConfig(configPath) {
6232
6272
  const raw = await readFile(absolute, "utf-8");
6233
6273
  return parseCheckConfig(JSON.parse(raw));
6234
6274
  }
6235
- const mod = await import(pathToFileURL(absolute).href);
6236
- return parseCheckConfig("default" in mod ? mod.default : mod);
6275
+ return parseCheckConfig(await importJsCheckConfig(absolute));
6237
6276
  } catch (error) {
6238
6277
  if (error instanceof CheckConfigError) throw error;
6239
6278
  const message = error instanceof Error ? error.message : String(error);
@@ -6243,6 +6282,46 @@ async function loadConfig(configPath) {
6243
6282
  );
6244
6283
  }
6245
6284
  }
6285
+ async function importJsCheckConfig(absolute) {
6286
+ const href = pathToFileURL(absolute).href;
6287
+ if (!process.env.VITEST) {
6288
+ const mod = await import(
6289
+ /* @vite-ignore */
6290
+ href
6291
+ );
6292
+ return "default" in mod ? mod.default : mod;
6293
+ }
6294
+ const script = `
6295
+ const mod = await import(${JSON.stringify(href)});
6296
+ const value = "default" in mod ? mod.default : mod;
6297
+ process.stdout.write(JSON.stringify({ ok: true, value }));
6298
+ `;
6299
+ const env = { ...process.env };
6300
+ delete env.NODE_OPTIONS;
6301
+ delete env.VITEST;
6302
+ delete env.VITEST_WORKER_ID;
6303
+ const { stdout, stderr } = await execFileAsync(
6304
+ process.execPath,
6305
+ ["--input-type=module", "--eval", script],
6306
+ {
6307
+ encoding: "utf8",
6308
+ maxBuffer: 4 * 1024 * 1024,
6309
+ env
6310
+ }
6311
+ );
6312
+ try {
6313
+ const parsed = JSON.parse(stdout);
6314
+ if (parsed.ok !== true) {
6315
+ throw new Error(stderr.trim() || "Check config module did not return a value");
6316
+ }
6317
+ return parsed.value;
6318
+ } catch (error) {
6319
+ if (stderr.trim()) {
6320
+ throw new Error(stderr.trim());
6321
+ }
6322
+ throw error instanceof Error ? error : new Error(String(error));
6323
+ }
6324
+ }
6246
6325
  function normalizeConfig(config) {
6247
6326
  if (config.checks === void 0) return {};
6248
6327
  if (typeof config.checks !== "object" || Array.isArray(config.checks)) {
@@ -6485,6 +6564,7 @@ function readErrorResult(error) {
6485
6564
  );
6486
6565
  }
6487
6566
  async function checkCommand(target, options = {}, stdin = process.stdin) {
6567
+ options = withResolvedForbiddenTools(options);
6488
6568
  let result;
6489
6569
  let phase = "config";
6490
6570
  let evidenceRead;
@@ -11591,7 +11671,7 @@ function isModuleNotFound4(e) {
11591
11671
  }
11592
11672
  async function loadIndexSqlite() {
11593
11673
  try {
11594
- return await import('./src-OYGG7QAZ.mjs');
11674
+ return await import('./src-2FS6BLR7.mjs');
11595
11675
  } catch (e) {
11596
11676
  if (isModuleNotFound4(e)) {
11597
11677
  console.error(
@@ -12480,6 +12560,9 @@ function createCliProgram() {
12480
12560
  ]).option("--forbidden-tool <name>", "forbid a tool name (repeatable)", (value, previous = []) => [
12481
12561
  ...previous,
12482
12562
  value
12563
+ ]).option("--forbid-tool <name>", "alias for --forbidden-tool (repeatable)", (value, previous = []) => [
12564
+ ...previous,
12565
+ value
12483
12566
  ]).option("--allowed-model <model>", "allow an LLM model (repeatable)", (value, previous = []) => [
12484
12567
  ...previous,
12485
12568
  value