agent-inspect 6.31.33 → 6.31.34

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 (40) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +1 -1
  3. package/package.json +1 -1
  4. package/packages/cli/dist/{chunk-AILSHDEF.mjs → chunk-6TXW53UR.mjs} +32 -17
  5. package/packages/cli/dist/chunk-6TXW53UR.mjs.map +1 -0
  6. package/packages/cli/dist/index.cjs +91 -31
  7. package/packages/cli/dist/index.cjs.map +1 -1
  8. package/packages/cli/dist/index.mjs +64 -19
  9. package/packages/cli/dist/index.mjs.map +1 -1
  10. package/packages/cli/dist/{src-SP36M4VB.mjs → src-GCLC4DIC.mjs} +3 -3
  11. package/packages/cli/dist/{src-SP36M4VB.mjs.map → src-GCLC4DIC.mjs.map} +1 -1
  12. package/packages/core/dist/advanced.cjs +3 -2
  13. package/packages/core/dist/advanced.cjs.map +1 -1
  14. package/packages/core/dist/advanced.mjs +9 -9
  15. package/packages/core/dist/checks.cjs +27 -13
  16. package/packages/core/dist/checks.cjs.map +1 -1
  17. package/packages/core/dist/checks.mjs +3 -3
  18. package/packages/core/dist/{chunk-6S666BF4.mjs → chunk-2SKAI5ZN.mjs} +3 -3
  19. package/packages/core/dist/{chunk-6S666BF4.mjs.map → chunk-2SKAI5ZN.mjs.map} +1 -1
  20. package/packages/core/dist/{chunk-FBPDF7HO.mjs → chunk-6F6KLGCR.mjs} +3 -3
  21. package/packages/core/dist/{chunk-FBPDF7HO.mjs.map → chunk-6F6KLGCR.mjs.map} +1 -1
  22. package/packages/core/dist/{chunk-EMDJLFRK.mjs → chunk-CXC7L4PY.mjs} +30 -16
  23. package/packages/core/dist/chunk-CXC7L4PY.mjs.map +1 -0
  24. package/packages/core/dist/{chunk-RB6WANSW.mjs → chunk-PU3FF5AP.mjs} +5 -4
  25. package/packages/core/dist/chunk-PU3FF5AP.mjs.map +1 -0
  26. package/packages/core/dist/{chunk-VIEJJ5JB.mjs → chunk-X5RP2E2H.mjs} +4 -4
  27. package/packages/core/dist/{chunk-VIEJJ5JB.mjs.map → chunk-X5RP2E2H.mjs.map} +1 -1
  28. package/packages/core/dist/exporters.cjs +33 -9
  29. package/packages/core/dist/exporters.cjs.map +1 -1
  30. package/packages/core/dist/exporters.mjs +33 -10
  31. package/packages/core/dist/exporters.mjs.map +1 -1
  32. package/packages/core/dist/index.cjs +3 -2
  33. package/packages/core/dist/index.cjs.map +1 -1
  34. package/packages/core/dist/index.mjs +4 -4
  35. package/packages/core/dist/writers.cjs +3 -2
  36. package/packages/core/dist/writers.cjs.map +1 -1
  37. package/packages/core/dist/writers.mjs +1 -1
  38. package/packages/cli/dist/chunk-AILSHDEF.mjs.map +0 -1
  39. package/packages/core/dist/chunk-EMDJLFRK.mjs.map +0 -1
  40. package/packages/core/dist/chunk-RB6WANSW.mjs.map +0 -1
@@ -269,8 +269,9 @@ var init_credential_value_patterns = __esm({
269
269
  /\beyJ[a-zA-Z0-9_-]{8,}\.[a-zA-Z0-9_-]{8,}\.[a-zA-Z0-9_-]{8,}\b/,
270
270
  /\b(?:sk-(?:proj-)?[a-zA-Z0-9_-]{16,}|sk-ant-[a-zA-Z0-9_-]{16,}|AIza[0-9A-Za-z_-]{20,})\b/,
271
271
  // Stripe secret / restricted keys use underscores (not sk-). Keep in sync with
272
- // packages/redact/src/index.ts + packages/core/src/checks DEFAULT_SECRET_PATTERNS (#520).
273
- /\b(?:sk|rk)_(?:live|test)_[A-Za-z0-9]{16,}\b/,
272
+ // packages/redact/src/index.ts + packages/core/src/checks DEFAULT_SECRET_PATTERNS (#520/#528).
273
+ // Use non-alnum lookarounds so underscore-adjacent forms (acct_sk_live_…, …_eu) match.
274
+ /(?<![A-Za-z0-9])(?:sk|rk)_(?:live|test)_[A-Za-z0-9]{16,}(?![A-Za-z0-9])/,
274
275
  /\bxox[abposr]-[A-Za-z0-9-]{10,}\b/,
275
276
  /\b(?:ghp|gho|ghu|ghs|ghr)_[A-Za-z0-9_]{20,}\b/,
276
277
  /\b(?:AKIA|ASIA)[A-Z0-9]{16}\b/,
@@ -6505,7 +6506,12 @@ function createStepOrderingRule(options) {
6505
6506
  const beforeRunning = semanticEvents(context).filter(
6506
6507
  (event) => event.kind === options.before.kind && event.status === "running" && stepEndpointName(event, options.before.kind) === options.before.name
6507
6508
  );
6508
- if (beforeEvents.length === 0 && afterEvents.length > 0 && beforeRunning.length > 0) {
6509
+ const afterRunning = semanticEvents(context).filter(
6510
+ (event) => event.kind === options.after.kind && event.status === "running" && stepEndpointName(event, options.after.kind) === options.after.name
6511
+ );
6512
+ const afterStarted = afterEvents.length > 0 || afterRunning.length > 0;
6513
+ const afterEvidenceEvent = afterEvents[0] ?? afterRunning[0];
6514
+ if (beforeRunning.length > 0 && afterStarted && afterEvidenceEvent !== void 0) {
6509
6515
  const endpointExpected2 = bothTools ? { before: options.before.name, after: options.after.name } : { before: options.before, after: options.after };
6510
6516
  return [
6511
6517
  failFinding(
@@ -6513,18 +6519,20 @@ function createStepOrderingRule(options) {
6513
6519
  `${subject} ${beforeLabel} started but never finished before ${afterLabel} ran.`,
6514
6520
  [
6515
6521
  ...beforeRunning.map((event) => eventEvidence(event)),
6516
- eventEvidence(afterEvents[0])
6522
+ eventEvidence(afterEvidenceEvent)
6517
6523
  ],
6518
6524
  { ...endpointExpected2, mode },
6519
6525
  {
6520
6526
  code: bothTools ? "tool.order.interval-unresolved" : "step.order.interval-unresolved",
6521
6527
  unfinishedBefore: true,
6522
- beforeStatus: "running"
6528
+ beforeStatus: "running",
6529
+ ...beforeEvents.length > 0 ? { finishedBeforeMasked: true } : {},
6530
+ ...afterEvents.length === 0 ? { afterStatus: "running" } : {}
6523
6531
  }
6524
6532
  )
6525
6533
  ];
6526
6534
  }
6527
- if (beforeEvents.length === 0 || afterEvents.length === 0) {
6535
+ if (beforeEvents.length === 0 || !afterStarted) {
6528
6536
  if (!requireEndpoints) return [];
6529
6537
  const findings = [];
6530
6538
  if (beforeEvents.length === 0) {
@@ -6548,7 +6556,7 @@ function createStepOrderingRule(options) {
6548
6556
  )
6549
6557
  );
6550
6558
  }
6551
- if (afterEvents.length === 0) {
6559
+ if (!afterStarted) {
6552
6560
  const otherKinds = otherKindsForStepName(
6553
6561
  context,
6554
6562
  options.after.kind,
@@ -6571,9 +6579,15 @@ function createStepOrderingRule(options) {
6571
6579
  }
6572
6580
  return findings;
6573
6581
  }
6574
- const encounter = finishedEvents(context).filter(
6575
- (event) => event.kind === options.before.kind && stepEndpointName(event, options.before.kind) === options.before.name || event.kind === options.after.kind && stepEndpointName(event, options.after.kind) === options.after.name
6576
- );
6582
+ const afterForOrder = afterEvents.length > 0 ? afterEvents : afterRunning;
6583
+ const encounter = [
6584
+ ...finishedEvents(context).filter(
6585
+ (event) => event.kind === options.before.kind && stepEndpointName(event, options.before.kind) === options.before.name || event.kind === options.after.kind && stepEndpointName(event, options.after.kind) === options.after.name
6586
+ ),
6587
+ ...afterEvents.length === 0 ? afterRunning.filter(
6588
+ (event) => !finishedEvents(context).some((finished) => finished.eventId === event.eventId)
6589
+ ) : []
6590
+ ];
6577
6591
  let beforeIndex;
6578
6592
  let afterIndex;
6579
6593
  for (const [position, event] of encounter.entries()) {
@@ -6604,7 +6618,7 @@ function createStepOrderingRule(options) {
6604
6618
  ];
6605
6619
  }
6606
6620
  const beforeEvent = beforeEvents[0];
6607
- const afterEvent = afterEvents[0];
6621
+ const afterEvent = afterForOrder[0];
6608
6622
  const beforeEnd = eventEndMs(beforeEvent);
6609
6623
  const afterStart = eventStartMs(afterEvent);
6610
6624
  const endpointExpected = bothTools ? { before: options.before.name, after: options.after.name } : { before: options.before, after: options.after };
@@ -6690,7 +6704,7 @@ function createStepOrderingRule(options) {
6690
6704
  latestBefore = { event, end };
6691
6705
  }
6692
6706
  }
6693
- for (const event of afterEvents) {
6707
+ for (const event of afterForOrder) {
6694
6708
  const start = eventStartMs(event);
6695
6709
  if (start === void 0) {
6696
6710
  missingAfterStarts += 1;
@@ -6719,7 +6733,7 @@ function createStepOrderingRule(options) {
6719
6733
  const tie = tiedEnd === tiedStart ? recordedTieOrder(
6720
6734
  context,
6721
6735
  beforeEvents.filter((event) => eventEndMs(event) === tiedEnd),
6722
- afterEvents.filter((event) => eventStartMs(event) === tiedStart)
6736
+ afterForOrder.filter((event) => eventStartMs(event) === tiedStart)
6723
6737
  ) : void 0;
6724
6738
  if (latestBefore.end > earliestAfter.start || tie !== void 0 && tie.inOrder !== true) {
6725
6739
  return [
@@ -7684,10 +7698,11 @@ var init_checks2 = __esm({
7684
7698
  DEFAULT_SECRET_PATTERNS = [
7685
7699
  { id: "bearer-token", pattern: /Bearer\s+[A-Za-z0-9._~+/-]{12,}=*/ },
7686
7700
  { id: "openai-key", pattern: /sk-[A-Za-z0-9_-]{16,}/ },
7687
- // Stripe + Slack: keep in sync with packages/redact + credential-value-patterns (#520).
7701
+ // Stripe + Slack: keep in sync with packages/redact + credential-value-patterns (#520/#528).
7702
+ // Non-alnum lookarounds so underscore-adjacent forms (acct_sk_live_…, …_eu) match.
7688
7703
  {
7689
7704
  id: "stripe-key",
7690
- pattern: /\b(?:sk|rk)_(?:live|test)_[A-Za-z0-9]{16,}\b/
7705
+ pattern: /(?<![A-Za-z0-9])(?:sk|rk)_(?:live|test)_[A-Za-z0-9]{16,}(?![A-Za-z0-9])/
7691
7706
  },
7692
7707
  { id: "slack-token", pattern: /\bxox[abposr]-[A-Za-z0-9-]{10,}\b/ },
7693
7708
  { id: "aws-access-key", pattern: /AKIA[0-9A-Z]{16}/ },
@@ -17464,7 +17479,7 @@ var init_src = __esm({
17464
17479
  });
17465
17480
 
17466
17481
  // package.json
17467
- var version = "6.31.33";
17482
+ var version = "6.31.34";
17468
17483
 
17469
17484
  // packages/cli/src/list.ts
17470
17485
  init_advanced();
@@ -19692,11 +19707,25 @@ function attemptIdOf3(event) {
19692
19707
  }
19693
19708
  return void 0;
19694
19709
  }
19710
+ function operationIdOf(event) {
19711
+ const direct = event.attributes?.operationId;
19712
+ if (typeof direct === "string" && direct.trim() !== "") return direct;
19713
+ const meta2 = event.attributes?.metadata;
19714
+ if (meta2 && typeof meta2 === "object" && !Array.isArray(meta2)) {
19715
+ const nested = meta2.operationId;
19716
+ if (typeof nested === "string" && nested.trim() !== "") return nested;
19717
+ }
19718
+ return void 0;
19719
+ }
19695
19720
  function lifecycleKey(event) {
19696
19721
  if (event.kind === "RUN") return `run:${event.runId}`;
19697
19722
  const stepId = stepIdOf2(event);
19698
- if (stepId !== void 0) return `step:${stepId}`;
19699
- return `event:${event.eventId}`;
19723
+ if (stepId === void 0) return `event:${event.eventId}`;
19724
+ const attemptId = attemptIdOf3(event);
19725
+ if (attemptId !== void 0) return `step:${stepId}:attempt:${attemptId}`;
19726
+ const operationId = operationIdOf(event);
19727
+ if (operationId !== void 0) return `step:${stepId}:op:${operationId}`;
19728
+ return `step:${stepId}`;
19700
19729
  }
19701
19730
  function isTerminal(status) {
19702
19731
  return status === "ok" || status === "error";
@@ -19747,6 +19776,12 @@ function joinSiblingGroup(group) {
19747
19776
  const others = group.filter(
19748
19777
  (n) => !isTerminal(n.event.status) && n.event.status !== "running"
19749
19778
  );
19779
+ const operationIds = new Set(
19780
+ group.map((n) => operationIdOf(n.event)).filter((id) => id !== void 0)
19781
+ );
19782
+ if (operationIds.size > 1) {
19783
+ return group;
19784
+ }
19750
19785
  const terminalStatuses = new Set(terminals.map((n) => n.event.status));
19751
19786
  if (terminalStatuses.size > 1) {
19752
19787
  return group;
@@ -19758,19 +19793,22 @@ function joinSiblingGroup(group) {
19758
19793
  const out = [];
19759
19794
  for (const terminal of terminals) {
19760
19795
  const terminalAttempt = attemptIdOf3(terminal.event);
19796
+ const terminalOp = operationIdOf(terminal.event);
19761
19797
  const terminalTs = eventTime3(terminal.event);
19762
- const candidate = runnings.find((r) => {
19798
+ const candidates = runnings.filter((r) => {
19763
19799
  if (usedRunning.has(r.event.eventId)) return false;
19764
19800
  if (eventTime3(r.event) > terminalTs) return false;
19801
+ const runningOp = operationIdOf(r.event);
19802
+ if (terminalOp !== void 0 && runningOp !== void 0 && terminalOp !== runningOp) {
19803
+ return false;
19804
+ }
19765
19805
  const runningAttempt = attemptIdOf3(r.event);
19766
19806
  if (terminalAttempt !== void 0) {
19767
19807
  return runningAttempt === terminalAttempt;
19768
19808
  }
19769
- if (runningAttempt !== void 0) {
19770
- return true;
19771
- }
19772
- return true;
19809
+ return runningAttempt === void 0;
19773
19810
  });
19811
+ const candidate = candidates.length === 1 ? candidates[0] : void 0;
19774
19812
  if (candidate) {
19775
19813
  usedRunning.add(candidate.event.eventId);
19776
19814
  out.push(joinOnePair(candidate, terminal));
@@ -22660,10 +22698,11 @@ var credentialDetectors = [
22660
22698
  severity: "error"
22661
22699
  }),
22662
22700
  // Stripe secret/restricted keys (underscore form). Keep in sync with
22663
- // packages/core/src/safety/credential-value-patterns.ts + checks DEFAULT_SECRET_PATTERNS (#520).
22701
+ // packages/core/src/safety/credential-value-patterns.ts + checks DEFAULT_SECRET_PATTERNS (#520/#528).
22702
+ // Non-alnum lookarounds so underscore-adjacent forms (acct_sk_live_…, …_eu) match.
22664
22703
  patternDetector({
22665
22704
  id: "value.stripeSecretKey",
22666
- pattern: /\b(?:sk|rk)_(?:live|test)_[A-Za-z0-9]{16,}\b/,
22705
+ pattern: /(?<![A-Za-z0-9])(?:sk|rk)_(?:live|test)_[A-Za-z0-9]{16,}(?![A-Za-z0-9])/,
22667
22706
  severity: "error"
22668
22707
  }),
22669
22708
  patternDetector({
@@ -24444,6 +24483,21 @@ function stableJson2(value) {
24444
24483
  return `${JSON.stringify(value, null, 2)}
24445
24484
  `;
24446
24485
  }
24486
+ function alignCheckResultsAggregateStatus(checkResultsJson, assessmentStatus) {
24487
+ let parsed;
24488
+ try {
24489
+ parsed = JSON.parse(checkResultsJson);
24490
+ } catch {
24491
+ return stableJson2({
24492
+ aggregateStatus: assessmentStatus,
24493
+ raw: checkResultsJson
24494
+ });
24495
+ }
24496
+ return stableJson2({
24497
+ ...parsed,
24498
+ aggregateStatus: assessmentStatus
24499
+ });
24500
+ }
24447
24501
  async function writeLocalEvidence(input3) {
24448
24502
  const profile = input3.redactionProfile ?? "share";
24449
24503
  const format = input3.format ?? "directory";
@@ -24482,6 +24536,10 @@ async function writeLocalEvidence(input3) {
24482
24536
  format: "agent-inspect-jsonl"
24483
24537
  });
24484
24538
  const assessmentStatus = residualStatusToEvidenceSafe(residual.status);
24539
+ const checkResultsJson = alignCheckResultsAggregateStatus(
24540
+ input3.checkResultsJson,
24541
+ assessmentStatus
24542
+ );
24485
24543
  const evidencePackage = buildEvidenceCiPackage({
24486
24544
  generatorVersion: version,
24487
24545
  runIds: input3.runIds,
@@ -24489,7 +24547,7 @@ async function writeLocalEvidence(input3) {
24489
24547
  redactedTraceJsonl: combined,
24490
24548
  redactionProfile: profile,
24491
24549
  assessmentStatus,
24492
- checkResultsJson: input3.checkResultsJson,
24550
+ checkResultsJson,
24493
24551
  ...input3.summaryText !== void 0 ? { summaryText: input3.summaryText } : {},
24494
24552
  ...input3.contractPackage !== void 0 ? { contractPackage: input3.contractPackage } : {}
24495
24553
  });
@@ -24550,12 +24608,12 @@ async function writeLocalEvidence(input3) {
24550
24608
  return baseDir;
24551
24609
  }
24552
24610
  function checkResultToEvidenceJson(result, runIds) {
24553
- const status = result.status === "pass" ? "SAFE" : result.status === "fail" ? "UNSAFE" : "UNKNOWN";
24554
24611
  return stableJson2({
24555
- aggregateStatus: status,
24612
+ aggregateStatus: "UNKNOWN",
24613
+ checkStatus: result.status,
24556
24614
  runs: runIds.map((runId) => ({
24557
24615
  runId,
24558
- status,
24616
+ checkStatus: result.status,
24559
24617
  errors: result.summary.errors,
24560
24618
  warnings: result.summary.warnings,
24561
24619
  findings: result.findings.length,
@@ -32608,10 +32666,12 @@ async function gateCommand(options = {}) {
32608
32666
  runIds: runIds.length > 0 ? runIds : ["gate"],
32609
32667
  sourceContents,
32610
32668
  ...gateOptions.traceDir !== void 0 ? { dir: gateOptions.traceDir } : {},
32611
- failed,
32669
+ // aggregateStatus is filled from residual assessment before hashing (#529).
32670
+ // Gate pass/fail stays in `gate` / process.exitCode, not aggregateStatus.
32612
32671
  checkResultsJson: `${JSON.stringify(
32613
32672
  {
32614
- aggregateStatus: failed ? "UNSAFE" : "SAFE",
32673
+ aggregateStatus: "UNKNOWN",
32674
+ gateStatus: failed ? "fail" : "pass",
32615
32675
  gate: result
32616
32676
  },
32617
32677
  null,