agent-inspect 6.9.0 → 6.11.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.
Files changed (35) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +1 -1
  3. package/docs/BUNDLES.md +31 -9
  4. package/docs/CI-ARTIFACTS.md +10 -1
  5. package/docs/CLI.md +22 -2
  6. package/package.json +1 -1
  7. package/packages/cli/dist/{chunk-WQ5XMFH2.mjs → chunk-XTAA733P.mjs} +1756 -149
  8. package/packages/cli/dist/chunk-XTAA733P.mjs.map +1 -0
  9. package/packages/cli/dist/index.cjs +10634 -8880
  10. package/packages/cli/dist/index.cjs.map +1 -1
  11. package/packages/cli/dist/index.mjs +729 -708
  12. package/packages/cli/dist/index.mjs.map +1 -1
  13. package/packages/cli/dist/{src-C4EUHTER.mjs → src-G7PM24W2.mjs} +3 -3
  14. package/packages/cli/dist/{src-C4EUHTER.mjs.map → src-G7PM24W2.mjs.map} +1 -1
  15. package/packages/core/dist/advanced.cjs +1846 -12
  16. package/packages/core/dist/advanced.cjs.map +1 -1
  17. package/packages/core/dist/advanced.d.cts +373 -4
  18. package/packages/core/dist/advanced.d.ts +373 -4
  19. package/packages/core/dist/advanced.mjs +1307 -12
  20. package/packages/core/dist/advanced.mjs.map +1 -1
  21. package/packages/core/dist/chunk-F7STQ5JF.mjs +479 -0
  22. package/packages/core/dist/chunk-F7STQ5JF.mjs.map +1 -0
  23. package/packages/core/dist/{chunk-KDDU2R5P.mjs → chunk-LFWZEO2L.mjs} +2 -2
  24. package/packages/core/dist/{chunk-KDDU2R5P.mjs.map → chunk-LFWZEO2L.mjs.map} +1 -1
  25. package/packages/core/dist/diff.mjs +3 -477
  26. package/packages/core/dist/diff.mjs.map +1 -1
  27. package/packages/core/dist/exporters.cjs.map +1 -1
  28. package/packages/core/dist/exporters.mjs +1 -1
  29. package/packages/core/dist/reporters.cjs +25 -0
  30. package/packages/core/dist/reporters.cjs.map +1 -1
  31. package/packages/core/dist/reporters.d.cts +16 -2
  32. package/packages/core/dist/reporters.d.ts +16 -2
  33. package/packages/core/dist/reporters.mjs +24 -1
  34. package/packages/core/dist/reporters.mjs.map +1 -1
  35. package/packages/cli/dist/chunk-WQ5XMFH2.mjs.map +0 -1
@@ -711,6 +711,15 @@ function persistedInspectEventToTraceEvents(event) {
711
711
  }
712
712
  return fromNativeStep(event);
713
713
  }
714
+ function persistedInspectEventsToTraceEvents(events, options) {
715
+ const out = [];
716
+ events.forEach((event, index) => {
717
+ const rows = persistedInspectEventToTraceEvents(event);
718
+ if (rows.length === 0 && options?.eventIndex !== void 0) ;
719
+ out.push(...rows);
720
+ });
721
+ return out;
722
+ }
714
723
 
715
724
  // node_modules/.pnpm/nanoid@5.1.11/node_modules/nanoid/url-alphabet/index.js
716
725
  var urlAlphabet = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
@@ -2131,6 +2140,20 @@ function extractOutcomesFromPersistedEvents(events) {
2131
2140
  }
2132
2141
  return out.sort((a, b) => a.observedAt - b.observedAt || a.name.localeCompare(b.name));
2133
2142
  }
2143
+ function summarizeObservedOutcomes(outcomes) {
2144
+ const summary = {
2145
+ total: outcomes.length,
2146
+ passed: 0,
2147
+ failed: 0,
2148
+ unknown: 0,
2149
+ skipped: 0,
2150
+ outcomes: [...outcomes]
2151
+ };
2152
+ for (const outcome of outcomes) {
2153
+ summary[outcome.status] += 1;
2154
+ }
2155
+ return summary;
2156
+ }
2134
2157
  function outcomesMatchingStatus(outcomes, statuses) {
2135
2158
  const set = new Set(statuses);
2136
2159
  return outcomes.filter((outcome) => set.has(outcome.status));
@@ -2140,6 +2163,18 @@ function parseObservationFilter(value) {
2140
2163
  return parseObservedOutcomeStatus(value);
2141
2164
  }
2142
2165
 
2166
+ // packages/core/src/outcomes/render.ts
2167
+ function renderObservedOutcomesHtml(summary) {
2168
+ if (summary.total === 0) {
2169
+ return "<p>No observed outcomes recorded for this run.</p>";
2170
+ }
2171
+ const rows = summary.outcomes.map((outcome) => {
2172
+ const esc = (v) => v.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;");
2173
+ return `<tr><td>${esc(outcome.name)}</td><td>${esc(outcome.status)}</td><td>${esc(outcome.expectation)}</td><td>${esc(outcome.method ?? "-")}</td></tr>`;
2174
+ }).join("");
2175
+ return `<p>Total: ${summary.total} (passed ${summary.passed}, failed ${summary.failed}, unknown ${summary.unknown}, skipped ${summary.skipped})</p><table><thead><tr><th>Name</th><th>Status</th><th>Expectation</th><th>Method</th></tr></thead><tbody>${rows}</tbody></table>`;
2176
+ }
2177
+
2143
2178
  // packages/core/src/inspector.ts
2144
2179
  var INSPECTOR_PERSISTED_SCHEMA_VERSION = "1.0";
2145
2180
  function normalizeName2(name, fallback) {
@@ -3898,6 +3933,148 @@ function renderRunWhat(summary, options = {}) {
3898
3933
  return lines.join("\n");
3899
3934
  }
3900
3935
 
3936
+ // packages/core/src/causal-failure.ts
3937
+ function runIdFromEvents(events) {
3938
+ for (const event of events) {
3939
+ if ("runId" in event && typeof event.runId === "string") return event.runId;
3940
+ }
3941
+ return void 0;
3942
+ }
3943
+ function noneResult(runId, rationale) {
3944
+ return {
3945
+ kind: "none",
3946
+ evidenceIds: [],
3947
+ rationale,
3948
+ orderIndex: 0,
3949
+ runId,
3950
+ engine: "conservative-causal-v1"
3951
+ };
3952
+ }
3953
+ function findFirstCausalFailure(events, options = {}) {
3954
+ const runId = runIdFromEvents(events);
3955
+ const timeline = buildRunTimeline(events);
3956
+ const firstError = timeline.entries.find((entry) => entry.isError);
3957
+ if (firstError) {
3958
+ return {
3959
+ kind: "explicit_error_event",
3960
+ evidenceIds: [firstError.stepId],
3961
+ rationale: "First timeline step with status error (explicit failure; no timing-only inference).",
3962
+ orderIndex: 1,
3963
+ runId: timeline.runId || runId,
3964
+ primary: {
3965
+ stepId: firstError.stepId,
3966
+ name: firstError.name
3967
+ },
3968
+ relationship: { role: "self", relatedIds: [] },
3969
+ engine: "conservative-causal-v1"
3970
+ };
3971
+ }
3972
+ const runCompletedError = events.find(
3973
+ (event) => event.event === "run_completed" && event.status === "error"
3974
+ );
3975
+ if (runCompletedError) {
3976
+ return {
3977
+ kind: "explicit_error_event",
3978
+ evidenceIds: [runCompletedError.runId],
3979
+ rationale: "Run completed with status error and no earlier errored step.",
3980
+ orderIndex: 1,
3981
+ runId: runCompletedError.runId,
3982
+ primary: { name: "run", stepId: runCompletedError.runId },
3983
+ relationship: { role: "self", relatedIds: [] },
3984
+ engine: "conservative-causal-v1"
3985
+ };
3986
+ }
3987
+ const outcomes = extractOutcomesFromTraceEvents(events);
3988
+ const failedOutcome = outcomes.find((outcome) => outcome.status === "failed");
3989
+ if (failedOutcome) {
3990
+ const evidenceIds = [failedOutcome.outcomeId];
3991
+ if (failedOutcome.parentId) evidenceIds.push(failedOutcome.parentId);
3992
+ return {
3993
+ kind: "failed_observed_outcome",
3994
+ evidenceIds,
3995
+ rationale: "First observed outcome with status failed.",
3996
+ orderIndex: 2,
3997
+ runId: failedOutcome.runId || runId,
3998
+ primary: {
3999
+ outcomeId: failedOutcome.outcomeId,
4000
+ stepId: failedOutcome.parentId,
4001
+ name: failedOutcome.name
4002
+ },
4003
+ relationship: failedOutcome.parentId ? { role: "child", relatedIds: [failedOutcome.parentId] } : { role: "self", relatedIds: [] },
4004
+ engine: "conservative-causal-v1"
4005
+ };
4006
+ }
4007
+ const contractFail = (options.contractFindings ?? []).find(
4008
+ (finding) => finding.status === "fail" && (finding.evidenceIds?.length ?? 0) > 0
4009
+ );
4010
+ if (contractFail) {
4011
+ const evidenceIds = [...contractFail.evidenceIds ?? []];
4012
+ return {
4013
+ kind: "contract_failure",
4014
+ evidenceIds,
4015
+ rationale: contractFail.message ?? `Contract rule ${contractFail.ruleId} failed with linked evidence ids.`,
4016
+ orderIndex: 3,
4017
+ runId,
4018
+ primary: {
4019
+ ruleId: contractFail.ruleId,
4020
+ stepId: evidenceIds[0],
4021
+ name: contractFail.ruleId
4022
+ },
4023
+ relationship: { role: "self", relatedIds: [] },
4024
+ engine: "conservative-causal-v1"
4025
+ };
4026
+ }
4027
+ const completed = events.filter(
4028
+ (event) => event.event === "step_completed"
4029
+ );
4030
+ const started = events.filter(
4031
+ (event) => event.event === "step_started"
4032
+ );
4033
+ const parentByStep = /* @__PURE__ */ new Map();
4034
+ for (const start of started) {
4035
+ parentByStep.set(start.stepId, start.parentId);
4036
+ }
4037
+ const errorSteps = completed.filter((event) => event.status === "error");
4038
+ if (errorSteps.length > 0) {
4039
+ const sorted = [...errorSteps].sort((a, b) => {
4040
+ const depth = (id) => {
4041
+ let d = 0;
4042
+ let cur = id;
4043
+ const seen = /* @__PURE__ */ new Set();
4044
+ while (cur && parentByStep.has(cur) && !seen.has(cur)) {
4045
+ seen.add(cur);
4046
+ const parent = parentByStep.get(cur);
4047
+ if (!parent) break;
4048
+ d += 1;
4049
+ cur = parent;
4050
+ }
4051
+ return d;
4052
+ };
4053
+ return depth(b.stepId) - depth(a.stepId);
4054
+ });
4055
+ const tip = sorted[0];
4056
+ const parentId = parentByStep.get(tip.stepId);
4057
+ const relatedIds = parentId ? [parentId] : [];
4058
+ return {
4059
+ kind: "failed_ancestor_or_child",
4060
+ evidenceIds: [tip.stepId, ...relatedIds],
4061
+ rationale: parentId ? "Deepest explicit error step with parent link (nearest ancestor relationship)." : "Explicit error step used as structural tip (no parent id).",
4062
+ orderIndex: 4,
4063
+ runId: tip.runId || runId,
4064
+ primary: { stepId: tip.stepId, name: started.find((s) => s.stepId === tip.stepId)?.name },
4065
+ relationship: {
4066
+ role: parentId ? "child" : "self",
4067
+ relatedIds
4068
+ },
4069
+ engine: "conservative-causal-v1"
4070
+ };
4071
+ }
4072
+ return noneResult(
4073
+ runId,
4074
+ "No explicit error event, failed outcome, or linked contract failure; refusing timing-only inference."
4075
+ );
4076
+ }
4077
+
3901
4078
  // packages/core/src/explain.ts
3902
4079
  function toDisplayStatus(status) {
3903
4080
  if (status === "ok") return "success";
@@ -4986,12 +5163,12 @@ function buildCriticalPath(runs, handoffs) {
4986
5163
  handoffs.filter((edge) => edge.confidence === "explicit").map((edge) => edge.from)
4987
5164
  );
4988
5165
  const ordered = [...runs].sort(compareRuns);
4989
- const path12 = [];
5166
+ const path14 = [];
4990
5167
  const visited = /* @__PURE__ */ new Set();
4991
5168
  const pushRun = (run, confidence, source) => {
4992
5169
  if (visited.has(run.runId)) return;
4993
5170
  visited.add(run.runId);
4994
- path12.push({
5171
+ path14.push({
4995
5172
  runId: run.runId,
4996
5173
  name: run.name,
4997
5174
  startedAt: run.startedAt,
@@ -5016,7 +5193,7 @@ function buildCriticalPath(runs, handoffs) {
5016
5193
  const confidence = explicitTargets.has(run.runId) || explicitSources.has(run.runId) ? "explicit" : "correlated";
5017
5194
  pushRun(run, confidence, confidence === "explicit" ? "manual" : "inferred");
5018
5195
  }
5019
- return path12;
5196
+ return path14;
5020
5197
  }
5021
5198
  function metaRunIdMatches(run, token, runById) {
5022
5199
  const meta = extractSessionWorkflowMetadata(run.metadata);
@@ -5326,13 +5503,13 @@ function assertBundlePathContained(outputDir, relativePath) {
5326
5503
  }
5327
5504
  return resolved;
5328
5505
  }
5329
- function normalizeBundleOutputPath(out) {
5506
+ function normalizeBundleOutputPath(out, options) {
5330
5507
  const trimmed = out.trim();
5331
5508
  if (trimmed === "") {
5332
5509
  throw new Error("--out requires a non-empty path.");
5333
5510
  }
5334
5511
  const resolved = path5__default.default.resolve(trimmed);
5335
- if (resolved.toLowerCase().endsWith(".zip")) {
5512
+ if (options?.preserveZipExtension !== true && resolved.toLowerCase().endsWith(".zip")) {
5336
5513
  return resolved.slice(0, -4);
5337
5514
  }
5338
5515
  return resolved;
@@ -5343,6 +5520,1634 @@ function defaultBundleOutputPath(runIds) {
5343
5520
  return path5__default.default.resolve(`agent-inspect-bundle-${label}-${stamp}`);
5344
5521
  }
5345
5522
 
5523
+ // packages/core/src/evidence/types.ts
5524
+ var EVIDENCE_FORMAT_VERSION = "1.0";
5525
+ var EVIDENCE_ASSESSMENT_NOTE = "Best-effort local safety verification only; not a compliance certification.";
5526
+ var EVIDENCE_MANIFEST_FILENAME = "evidence.json";
5527
+ var SHA256_RE = /^[a-f0-9]{64}$/i;
5528
+ function sha256Hex(data) {
5529
+ const hash = crypto.createHash("sha256");
5530
+ if (typeof data === "string") {
5531
+ hash.update(data, "utf8");
5532
+ } else {
5533
+ hash.update(data);
5534
+ }
5535
+ return hash.digest("hex");
5536
+ }
5537
+ function isSha256Hex(value) {
5538
+ return SHA256_RE.test(value);
5539
+ }
5540
+ function sha256Equals(expected, actual) {
5541
+ if (!isSha256Hex(expected) || !isSha256Hex(actual)) {
5542
+ return false;
5543
+ }
5544
+ const a = expected.toLowerCase();
5545
+ const b = actual.toLowerCase();
5546
+ if (a.length !== b.length) return false;
5547
+ let mismatch = 0;
5548
+ for (let i = 0; i < a.length; i += 1) {
5549
+ mismatch |= a.charCodeAt(i) ^ b.charCodeAt(i);
5550
+ }
5551
+ return mismatch === 0;
5552
+ }
5553
+ function assertEvidenceRelativePath(relativePath) {
5554
+ if (typeof relativePath !== "string" || relativePath.trim() === "") {
5555
+ throw new Error("Evidence file path must be a non-empty relative path.");
5556
+ }
5557
+ const trimmed = relativePath.trim().replaceAll("\\", "/");
5558
+ if (path5__default.default.isAbsolute(trimmed) || trimmed.startsWith("/")) {
5559
+ throw new Error(`Evidence file path must be relative: ${relativePath}`);
5560
+ }
5561
+ const parts = trimmed.split("/").filter((part) => part !== "");
5562
+ if (parts.length === 0) {
5563
+ throw new Error(`Evidence file path must be relative: ${relativePath}`);
5564
+ }
5565
+ for (const part of parts) {
5566
+ if (part === "." || part === "..") {
5567
+ throw new Error(`Evidence file path must not contain "." or "..": ${relativePath}`);
5568
+ }
5569
+ }
5570
+ return parts.join("/");
5571
+ }
5572
+
5573
+ // packages/core/src/evidence/manifest.ts
5574
+ function stable(value) {
5575
+ if (Array.isArray(value)) return value.map(stable);
5576
+ if (value === null || typeof value !== "object") return value;
5577
+ const record = value;
5578
+ return Object.fromEntries(
5579
+ Object.keys(record).sort((a, b) => a.localeCompare(b)).map((key) => [key, stable(record[key])])
5580
+ );
5581
+ }
5582
+ function serializeEvidenceManifest(manifest) {
5583
+ return `${JSON.stringify(stable(manifest), null, 2)}
5584
+ `;
5585
+ }
5586
+ function inferEvidenceFileRole(relativePath) {
5587
+ const normalized = assertEvidenceRelativePath(relativePath);
5588
+ const base = normalized.includes("/") ? normalized.slice(normalized.lastIndexOf("/") + 1) : normalized;
5589
+ if (base === "evidence.html" || base === "trace.html" || base.endsWith(".html")) {
5590
+ return "report";
5591
+ }
5592
+ if (base === "trace.jsonl" || base.endsWith(".jsonl")) {
5593
+ return "redacted-trace";
5594
+ }
5595
+ if (base === "check-results.json") {
5596
+ return "checks";
5597
+ }
5598
+ if (base === "redaction-report.json") {
5599
+ return "redaction-report";
5600
+ }
5601
+ if (base === "summary.md") {
5602
+ return "summary";
5603
+ }
5604
+ return "other";
5605
+ }
5606
+ function buildEvidenceFileEntries(files) {
5607
+ const byPath = /* @__PURE__ */ new Map();
5608
+ for (const file of files) {
5609
+ const relativePath = assertEvidenceRelativePath(file.path);
5610
+ if (relativePath === EVIDENCE_MANIFEST_FILENAME) {
5611
+ throw new Error(
5612
+ `Do not include ${EVIDENCE_MANIFEST_FILENAME} in packaged file hashes (self-hash is undefined).`
5613
+ );
5614
+ }
5615
+ if (byPath.has(relativePath)) {
5616
+ throw new Error(`Duplicate evidence file path: ${relativePath}`);
5617
+ }
5618
+ byPath.set(relativePath, {
5619
+ path: relativePath,
5620
+ sha256: sha256Hex(file.content),
5621
+ role: file.role ?? inferEvidenceFileRole(relativePath)
5622
+ });
5623
+ }
5624
+ return [...byPath.values()].sort((a, b) => a.path.localeCompare(b.path));
5625
+ }
5626
+ function buildEvidenceManifest(parts) {
5627
+ const runIds = [...parts.runIds];
5628
+ if (runIds.length === 0) {
5629
+ throw new Error("Evidence manifest requires at least one run id.");
5630
+ }
5631
+ for (const item of parts.sourceHashes) {
5632
+ if (!runIds.includes(item.runId)) {
5633
+ throw new Error(`sourceHashes runId "${item.runId}" is not listed in source.runIds.`);
5634
+ }
5635
+ if (item.algorithm !== "sha256") {
5636
+ throw new Error(`Unsupported source hash algorithm: ${item.algorithm}`);
5637
+ }
5638
+ }
5639
+ const assessment = {
5640
+ status: parts.assessmentStatus,
5641
+ note: parts.note ?? EVIDENCE_ASSESSMENT_NOTE
5642
+ };
5643
+ if (parts.sourceStatus !== void 0) {
5644
+ assessment.sourceStatus = parts.sourceStatus;
5645
+ }
5646
+ return {
5647
+ evidenceFormatVersion: EVIDENCE_FORMAT_VERSION,
5648
+ generator: {
5649
+ name: parts.generatorName ?? "agent-inspect",
5650
+ version: parts.generatorVersion
5651
+ },
5652
+ createdAt: parts.createdAt ?? (/* @__PURE__ */ new Date()).toISOString(),
5653
+ source: {
5654
+ runIds,
5655
+ traceSchemaVersions: [...parts.traceSchemaVersions].sort((a, b) => a.localeCompare(b)),
5656
+ sourceHashes: [...parts.sourceHashes].sort((a, b) => a.runId.localeCompare(b.runId))
5657
+ },
5658
+ policy: {
5659
+ redactionProfile: parts.redactionProfile,
5660
+ verificationPolicy: parts.verificationPolicy ?? parts.redactionProfile
5661
+ },
5662
+ assessment,
5663
+ files: buildEvidenceFileEntries(parts.files)
5664
+ };
5665
+ }
5666
+ function validateEvidenceManifest(value) {
5667
+ if (value === null || typeof value !== "object" || Array.isArray(value)) {
5668
+ throw new Error("Evidence manifest must be a JSON object.");
5669
+ }
5670
+ const record = value;
5671
+ if (record.evidenceFormatVersion !== EVIDENCE_FORMAT_VERSION) {
5672
+ throw new Error(
5673
+ `Unsupported evidenceFormatVersion: ${String(record.evidenceFormatVersion)}`
5674
+ );
5675
+ }
5676
+ const generator = record.generator;
5677
+ if (generator === null || typeof generator !== "object" || Array.isArray(generator) || typeof generator.name !== "string" || typeof generator.version !== "string") {
5678
+ throw new Error("Evidence manifest requires generator.name and generator.version.");
5679
+ }
5680
+ const source = record.source;
5681
+ if (source === null || typeof source !== "object" || Array.isArray(source)) {
5682
+ throw new Error("Evidence manifest requires source.");
5683
+ }
5684
+ const sourceRecord = source;
5685
+ if (!Array.isArray(sourceRecord.runIds) || sourceRecord.runIds.length === 0) {
5686
+ throw new Error("Evidence manifest source.runIds must be a non-empty array.");
5687
+ }
5688
+ if (!Array.isArray(sourceRecord.traceSchemaVersions)) {
5689
+ throw new Error("Evidence manifest source.traceSchemaVersions must be an array.");
5690
+ }
5691
+ if (!Array.isArray(sourceRecord.sourceHashes)) {
5692
+ throw new Error("Evidence manifest source.sourceHashes must be an array.");
5693
+ }
5694
+ const policy = record.policy;
5695
+ if (policy === null || typeof policy !== "object" || Array.isArray(policy)) {
5696
+ throw new Error("Evidence manifest requires policy.");
5697
+ }
5698
+ const assessment = record.assessment;
5699
+ if (assessment === null || typeof assessment !== "object" || Array.isArray(assessment) || typeof assessment.status !== "string") {
5700
+ throw new Error("Evidence manifest requires assessment.status.");
5701
+ }
5702
+ if (!Array.isArray(record.files) || record.files.length === 0) {
5703
+ throw new Error("Evidence manifest files must be a non-empty array.");
5704
+ }
5705
+ for (const file of record.files) {
5706
+ if (file === null || typeof file !== "object" || Array.isArray(file)) {
5707
+ throw new Error("Evidence manifest file entries must be objects.");
5708
+ }
5709
+ const entry = file;
5710
+ if (typeof entry.path !== "string") {
5711
+ throw new Error("Evidence file entry requires path.");
5712
+ }
5713
+ assertEvidenceRelativePath(entry.path);
5714
+ if (typeof entry.sha256 !== "string" || !/^[a-f0-9]{64}$/i.test(entry.sha256)) {
5715
+ throw new Error(`Evidence file entry requires sha256 hex for ${entry.path}.`);
5716
+ }
5717
+ }
5718
+ return value;
5719
+ }
5720
+ function parseEvidenceManifestJson(text) {
5721
+ let parsed;
5722
+ try {
5723
+ parsed = JSON.parse(text);
5724
+ } catch (error) {
5725
+ const message = error instanceof Error ? error.message : String(error);
5726
+ throw new Error(`Evidence manifest is not valid JSON: ${message}`);
5727
+ }
5728
+ return validateEvidenceManifest(parsed);
5729
+ }
5730
+ function collectTraceSchemaVersions(jsonl) {
5731
+ const versions = /* @__PURE__ */ new Set();
5732
+ for (const line of jsonl.split(/\r?\n/)) {
5733
+ const trimmed = line.trim();
5734
+ if (trimmed === "") continue;
5735
+ try {
5736
+ const row = JSON.parse(trimmed);
5737
+ if (typeof row.schemaVersion === "string" && row.schemaVersion.trim() !== "") {
5738
+ versions.add(row.schemaVersion.trim());
5739
+ }
5740
+ } catch {
5741
+ }
5742
+ }
5743
+ return [...versions].sort((a, b) => a.localeCompare(b));
5744
+ }
5745
+
5746
+ // packages/core/src/exporters/helpers.ts
5747
+ function escapeHtml(value) {
5748
+ return value.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
5749
+ }
5750
+ function sortKeysDeep(input) {
5751
+ if (input === null || typeof input !== "object") return input;
5752
+ if (Array.isArray(input)) return input.map(sortKeysDeep);
5753
+ const o = input;
5754
+ const out = {};
5755
+ for (const k of Object.keys(o).sort()) {
5756
+ out[k] = sortKeysDeep(o[k]);
5757
+ }
5758
+ return out;
5759
+ }
5760
+ function stableJson(value, pretty) {
5761
+ const sorted = sortKeysDeep(value);
5762
+ return JSON.stringify(sorted);
5763
+ }
5764
+ function flattenTree(tree) {
5765
+ const out = [];
5766
+ function walk(nodes) {
5767
+ for (const n of nodes) {
5768
+ out.push(n);
5769
+ if (n.children.length > 0) walk(n.children);
5770
+ }
5771
+ }
5772
+ walk(tree.children);
5773
+ return out;
5774
+ }
5775
+
5776
+ // packages/core/src/evidence/views.ts
5777
+ function renderTreeHtml(nodes, ulClass = "tree") {
5778
+ if (nodes.length === 0) return "";
5779
+ const parts = [`<ul class="${ulClass}">`];
5780
+ for (const n of nodes) {
5781
+ const ev = n.event;
5782
+ const status = ev.status ?? "?";
5783
+ const dur = ev.durationMs !== void 0 && Number.isFinite(ev.durationMs) ? `${ev.durationMs}ms` : "-";
5784
+ const errClass = ev.status === "error" ? " is-error" : "";
5785
+ parts.push(`<li class="tree-node${errClass}">`);
5786
+ parts.push(
5787
+ `<span class="nm">${escapeHtml(ev.name)}</span> <span class="meta">[${escapeHtml(ev.kind)}] ${escapeHtml(status)} (${escapeHtml(dur)})</span>`
5788
+ );
5789
+ if (n.children.length > 0) {
5790
+ parts.push(renderTreeHtml(n.children, "tree nested"));
5791
+ }
5792
+ parts.push("</li>");
5793
+ }
5794
+ parts.push("</ul>");
5795
+ return parts.join("");
5796
+ }
5797
+ function buildEvidenceTreeViewHtml(trees) {
5798
+ if (trees.length === 0) {
5799
+ return `<p class="muted">No execution trees available.</p>`;
5800
+ }
5801
+ const parts = [];
5802
+ for (const tree of trees) {
5803
+ parts.push(`<article class="run-block">`);
5804
+ parts.push(`<h3><code>${escapeHtml(tree.runId)}</code></h3>`);
5805
+ if (tree.name) {
5806
+ parts.push(`<p class="muted">Name: ${escapeHtml(tree.name)}</p>`);
5807
+ }
5808
+ parts.push(
5809
+ `<p>Status: <strong>${escapeHtml(String(tree.status ?? "unknown"))}</strong>${tree.durationMs !== void 0 ? ` \xB7 ${escapeHtml(String(tree.durationMs))}ms` : ""}</p>`
5810
+ );
5811
+ parts.push(
5812
+ tree.children.length > 0 ? renderTreeHtml(tree.children) : `<p class="muted">No steps recorded.</p>`
5813
+ );
5814
+ parts.push(`</article>`);
5815
+ }
5816
+ return parts.join("\n");
5817
+ }
5818
+ function timelineRows(tree) {
5819
+ const flat = flattenTree(tree);
5820
+ const origin = tree.startedAt ?? flat.reduce((min, n) => {
5821
+ const t = n.event.timestamp;
5822
+ if (!Number.isFinite(t)) return min;
5823
+ return min === void 0 ? t : Math.min(min, t);
5824
+ }, void 0) ?? 0;
5825
+ return flat.filter((n) => n.event.kind !== "RUN").map((n) => {
5826
+ const started = Number.isFinite(n.event.timestamp) ? n.event.timestamp : origin;
5827
+ const durationMs2 = n.event.durationMs !== void 0 && Number.isFinite(n.event.durationMs) ? Math.max(0, n.event.durationMs) : 0;
5828
+ return {
5829
+ name: n.event.name,
5830
+ kind: n.event.kind,
5831
+ status: n.event.status ?? "?",
5832
+ offsetMs: Math.max(0, started - origin),
5833
+ durationMs: durationMs2,
5834
+ isError: n.event.status === "error"
5835
+ };
5836
+ }).sort((a, b) => a.offsetMs - b.offsetMs || a.name.localeCompare(b.name));
5837
+ }
5838
+ function buildEvidenceTimelineViewHtml(trees) {
5839
+ if (trees.length === 0) {
5840
+ return `<p class="muted">No timeline data available.</p>`;
5841
+ }
5842
+ const parts = [];
5843
+ for (const tree of trees) {
5844
+ const rows = timelineRows(tree);
5845
+ const maxEnd = rows.reduce(
5846
+ (max, row) => Math.max(max, row.offsetMs + Math.max(row.durationMs, 1)),
5847
+ 1
5848
+ );
5849
+ parts.push(`<article class="run-block">`);
5850
+ parts.push(`<h3><code>${escapeHtml(tree.runId)}</code></h3>`);
5851
+ if (rows.length === 0) {
5852
+ parts.push(`<p class="muted">No step timings recorded.</p>`);
5853
+ } else {
5854
+ parts.push(`<div class="waterfall" role="list">`);
5855
+ for (const row of rows) {
5856
+ const left = row.offsetMs / maxEnd * 100;
5857
+ const width = Math.max(0.8, Math.max(row.durationMs, 1) / maxEnd * 100);
5858
+ const err = row.isError ? " is-error" : "";
5859
+ parts.push(
5860
+ `<div class="wf-row${err}" role="listitem"><div class="wf-label"><span class="nm">${escapeHtml(row.name)}</span> <span class="meta">[${escapeHtml(row.kind)}] ${escapeHtml(row.status)} \xB7 ${escapeHtml(String(row.durationMs))}ms @+${escapeHtml(String(row.offsetMs))}ms</span></div><div class="wf-track"><span class="wf-bar" style="left:${left.toFixed(2)}%;width:${width.toFixed(2)}%"></span></div></div>`
5861
+ );
5862
+ }
5863
+ parts.push(`</div>`);
5864
+ }
5865
+ parts.push(`</article>`);
5866
+ }
5867
+ return parts.join("\n");
5868
+ }
5869
+ function findNodeByEventId(nodes, eventId) {
5870
+ for (const node of nodes) {
5871
+ if (node.event.eventId === eventId) return node;
5872
+ const child = findNodeByEventId(node.children, eventId);
5873
+ if (child) return child;
5874
+ }
5875
+ return void 0;
5876
+ }
5877
+ function buildAncestorChain(tree, failure) {
5878
+ const chain = [failure];
5879
+ let parentId = failure.event.parentId;
5880
+ const guard = /* @__PURE__ */ new Set([failure.event.eventId]);
5881
+ while (parentId && !guard.has(parentId)) {
5882
+ guard.add(parentId);
5883
+ const parent = findNodeByEventId(tree.children, parentId);
5884
+ if (!parent) break;
5885
+ chain.unshift(parent);
5886
+ parentId = parent.event.parentId;
5887
+ }
5888
+ return chain;
5889
+ }
5890
+ function buildEvidenceCausalFailureViewHtml(trees) {
5891
+ if (trees.length === 0) {
5892
+ return `<p class="muted">No runs available for causal analysis.</p>`;
5893
+ }
5894
+ const parts = [];
5895
+ for (const tree of trees) {
5896
+ parts.push(`<article class="run-block">`);
5897
+ parts.push(`<h3><code>${escapeHtml(tree.runId)}</code></h3>`);
5898
+ const errors = flattenTree(tree).filter((n) => n.event.status === "error" || n.event.kind === "ERROR").sort((a, b) => a.event.timestamp - b.event.timestamp);
5899
+ if (errors.length === 0) {
5900
+ parts.push(
5901
+ `<p class="muted">No error-status events found. Run status: <strong>${escapeHtml(String(tree.status ?? "unknown"))}</strong>.</p>`
5902
+ );
5903
+ parts.push(`</article>`);
5904
+ continue;
5905
+ }
5906
+ const first = errors[0];
5907
+ const chain = buildAncestorChain(tree, first);
5908
+ parts.push(`<p>First error by timestamp:</p>`);
5909
+ parts.push(`<ol class="causal-chain">`);
5910
+ for (const node of chain) {
5911
+ const isTip = node.event.eventId === first.event.eventId;
5912
+ const msg = typeof node.event.attributes?.message === "string" ? node.event.attributes.message : typeof node.event.attributes?.error === "string" ? node.event.attributes.error : void 0;
5913
+ parts.push(
5914
+ `<li class="${isTip ? "causal-tip" : ""}"><span class="nm">${escapeHtml(node.event.name)}</span> <span class="meta">[${escapeHtml(node.event.kind)}] ${escapeHtml(node.event.status ?? "?")} \xB7 ${escapeHtml(node.event.eventId)}</span>${msg ? `<div class="causal-msg">${escapeHtml(msg.slice(0, 400))}</div>` : ""}</li>`
5915
+ );
5916
+ }
5917
+ parts.push(`</ol>`);
5918
+ if (errors.length > 1) {
5919
+ parts.push(
5920
+ `<p class="muted">${escapeHtml(String(errors.length - 1))} additional error event(s) not shown in the primary chain.</p>`
5921
+ );
5922
+ }
5923
+ parts.push(`</article>`);
5924
+ }
5925
+ return parts.join("\n");
5926
+ }
5927
+ var EVIDENCE_VIEW_CSS = `
5928
+ ul.tree{list-style:none;padding-left:1rem;margin:.5rem 0}
5929
+ ul.tree.nested{padding-left:1.25rem;border-left:1px solid var(--line);margin:.25rem 0}
5930
+ .tree-node.is-error .nm,.wf-row.is-error .nm,.causal-tip .nm{color:var(--unsafe)}
5931
+ .waterfall{display:flex;flex-direction:column;gap:.45rem;max-width:52rem}
5932
+ .wf-row{display:grid;grid-template-columns:minmax(10rem,18rem) 1fr;gap:.6rem;align-items:center}
5933
+ .wf-track{position:relative;height:.7rem;background:#e8e8e4;border-radius:.25rem;overflow:hidden}
5934
+ .wf-bar{position:absolute;top:0;bottom:0;background:var(--accent);border-radius:.25rem}
5935
+ .wf-row.is-error .wf-bar{background:var(--unsafe)}
5936
+ .causal-chain{max-width:44rem}
5937
+ .causal-msg{margin:.25rem 0 0;color:var(--muted);font-size:.92rem}
5938
+ .run-block{margin:0 0 1.25rem;padding-bottom:1rem;border-bottom:1px solid var(--line)}
5939
+ .run-block:last-child{border-bottom:0}
5940
+ @media (max-width:720px){
5941
+ .wf-row{grid-template-columns:1fr}
5942
+ }
5943
+ `.trim();
5944
+
5945
+ // packages/core/src/evidence/html-shell.ts
5946
+ var EVIDENCE_HTML_FILENAME = "evidence.html";
5947
+ var EVIDENCE_HTML_NOTE = "Generated locally by AgentInspect. Share-checked evidence for review \u2014 not a compliance or security certification.";
5948
+ var EVIDENCE_VIEW_IDS = [
5949
+ "summary",
5950
+ "tree",
5951
+ "timeline",
5952
+ "causal",
5953
+ "tools-llm",
5954
+ "outcomes",
5955
+ "contracts",
5956
+ "circuit",
5957
+ "diff",
5958
+ "safety",
5959
+ "provenance"
5960
+ ];
5961
+ function statusClass(status) {
5962
+ if (status === "SAFE") return "st-safe";
5963
+ if (status === "SAFE WITH WARNINGS") return "st-warn";
5964
+ if (status === "UNSAFE") return "st-unsafe";
5965
+ return "st-unknown";
5966
+ }
5967
+ function viewLabel(id) {
5968
+ switch (id) {
5969
+ case "summary":
5970
+ return "Summary";
5971
+ case "tree":
5972
+ return "Tree";
5973
+ case "timeline":
5974
+ return "Timeline";
5975
+ case "causal":
5976
+ return "Causal failure";
5977
+ case "tools-llm":
5978
+ return "Tools / LLM";
5979
+ case "outcomes":
5980
+ return "Outcomes";
5981
+ case "contracts":
5982
+ return "Contracts / checks";
5983
+ case "circuit":
5984
+ return "Circuit / guardrails";
5985
+ case "diff":
5986
+ return "Diff";
5987
+ case "safety":
5988
+ return "Safety / redaction";
5989
+ case "provenance":
5990
+ return "Provenance";
5991
+ default: {
5992
+ const _exhaustive = id;
5993
+ return _exhaustive;
5994
+ }
5995
+ }
5996
+ }
5997
+ function encodeEmbeddedEvidenceJson(value) {
5998
+ return JSON.stringify(value).replace(/</g, "\\u003c").replace(/>/g, "\\u003e");
5999
+ }
6000
+ function buildEmbeddedPayload(input) {
6001
+ return {
6002
+ evidenceFormatVersion: input.evidenceFormatVersion ?? "1.0",
6003
+ generator: {
6004
+ name: input.generatorName,
6005
+ version: input.generatorVersion
6006
+ },
6007
+ createdAt: input.createdAt,
6008
+ runIds: [...input.runIds],
6009
+ assessment: {
6010
+ status: input.assessmentStatus,
6011
+ ...input.sourceStatus !== void 0 ? { sourceStatus: input.sourceStatus } : {}
6012
+ },
6013
+ policy: {
6014
+ redactionProfile: input.redactionProfile,
6015
+ verificationPolicy: input.verificationPolicy
6016
+ },
6017
+ checkSummary: input.checkSummary
6018
+ };
6019
+ }
6020
+ function buildEvidenceHtmlShell(input) {
6021
+ if (input.runIds.length === 0) {
6022
+ throw new Error("Evidence HTML shell requires at least one run id.");
6023
+ }
6024
+ const maxChars = input.maxEmbeddedJsonChars ?? 64 * 1024;
6025
+ let embedded = encodeEmbeddedEvidenceJson(buildEmbeddedPayload(input));
6026
+ if (embedded.length > maxChars) {
6027
+ embedded = encodeEmbeddedEvidenceJson({
6028
+ truncated: true,
6029
+ evidenceFormatVersion: input.evidenceFormatVersion ?? "1.0",
6030
+ runIds: [...input.runIds],
6031
+ assessment: { status: input.assessmentStatus },
6032
+ note: "Embedded payload truncated to bound; open evidence.json / trace files for full detail."
6033
+ });
6034
+ }
6035
+ const title = escapeHtml(input.title ?? "AgentInspect evidence");
6036
+ const runList = input.runIds.map((id) => `<li><code>${escapeHtml(id)}</code></li>`).join("");
6037
+ const summaryBody = input.summaryText !== void 0 && input.summaryText.trim() !== "" ? `<pre class="summary-md">${escapeHtml(input.summaryText)}</pre>` : `<p class="muted">Open <code>summary.md</code> in this bundle for the full text summary.</p>`;
6038
+ const checkRows = input.checkSummary?.runs.map(
6039
+ (run) => `<tr><td><code>${escapeHtml(run.runId)}</code></td><td class="${statusClass(run.status)}">${escapeHtml(run.status)}</td><td>${run.errors}</td><td>${run.warnings}</td><td>${run.findings}</td></tr>`
6040
+ ).join("") ?? "";
6041
+ const nav = EVIDENCE_VIEW_IDS.map(
6042
+ (id) => `<a class="nav-link" href="#view-${id}" data-view="${id}">${escapeHtml(viewLabel(id))}</a>`
6043
+ ).join("\n");
6044
+ const stubPanels = EVIDENCE_VIEW_IDS.filter((id) => id !== "summary").map((id) => {
6045
+ const body = input.viewBodies?.[id];
6046
+ if (body !== void 0 && body.trim() !== "") {
6047
+ return ` <section id="view-${id}" class="panel" hidden>
6048
+ <h2>${escapeHtml(viewLabel(id))}</h2>
6049
+ ${body}
6050
+ </section>`;
6051
+ }
6052
+ return ` <section id="view-${id}" class="panel" hidden>
6053
+ <h2>${escapeHtml(viewLabel(id))}</h2>
6054
+ <p class="muted">This view will be filled in a later AgentInspect 6.10 release. The shell is offline-ready.</p>
6055
+ </section>`;
6056
+ }).join("\n");
6057
+ return `<!doctype html>
6058
+ <html lang="en">
6059
+ <head>
6060
+ <meta charset="utf-8"/>
6061
+ <meta name="viewport" content="width=device-width, initial-scale=1"/>
6062
+ <meta http-equiv="Content-Security-Policy" content="default-src 'none'; style-src 'unsafe-inline'; script-src 'unsafe-inline'; img-src data:; base-uri 'none'; form-action 'none'; frame-ancestors 'none'"/>
6063
+ <meta name="referrer" content="no-referrer"/>
6064
+ <title>${title}</title>
6065
+ <style>
6066
+ :root{--bg:#f7f7f5;--fg:#1a1a1a;--muted:#5c5c5c;--line:#d8d8d4;--accent:#0b5fff;--safe:#0a7a3e;--warn:#9a6700;--unsafe:#b42318;--unknown:#5c5c5c}
6067
+ *{box-sizing:border-box}
6068
+ body{margin:0;font-family:ui-sans-serif,system-ui,-apple-system,Segoe UI,sans-serif;background:var(--bg);color:var(--fg);line-height:1.5}
6069
+ a{color:var(--accent)}
6070
+ header{padding:1.25rem 1.5rem;border-bottom:1px solid var(--line);background:#fff}
6071
+ header h1{margin:0 0 .35rem;font-size:1.35rem}
6072
+ .note{margin:0;color:var(--muted);font-size:.92rem;max-width:52rem}
6073
+ .layout{display:grid;grid-template-columns:14rem 1fr;min-height:70vh}
6074
+ nav{padding:1rem;border-right:1px solid var(--line);background:#fff}
6075
+ nav .nav-link{display:block;padding:.4rem .55rem;margin:0 0 .2rem;border-radius:.35rem;text-decoration:none;color:inherit}
6076
+ nav .nav-link:hover,nav .nav-link:focus{background:#eef3ff;outline:2px solid var(--accent);outline-offset:1px}
6077
+ main{padding:1.25rem 1.5rem}
6078
+ .panel[hidden]{display:none}
6079
+ .badge{display:inline-block;padding:.15rem .55rem;border-radius:.3rem;font-size:.85rem;font-weight:600}
6080
+ .st-safe{color:var(--safe)}.st-warn{color:var(--warn)}.st-unsafe{color:var(--unsafe)}.st-unknown{color:var(--unknown)}
6081
+ table{border-collapse:collapse;width:100%;max-width:48rem;background:#fff}
6082
+ th,td{border:1px solid var(--line);padding:.4rem .55rem;text-align:left;vertical-align:top}
6083
+ th{background:#f0f0ec}
6084
+ .summary-md,pre.data{white-space:pre-wrap;word-break:break-word;background:#fff;border:1px solid var(--line);padding:.75rem;max-width:52rem}
6085
+ .muted{color:var(--muted)}
6086
+ ul.runs{margin:.4rem 0 1rem;padding-left:1.2rem}
6087
+ @media print{
6088
+ nav{display:none}
6089
+ .layout{display:block}
6090
+ .panel[hidden]{display:block!important;page-break-before:always}
6091
+ header{border:0}
6092
+ }
6093
+ @media (max-width:720px){
6094
+ .layout{grid-template-columns:1fr}
6095
+ nav{border-right:0;border-bottom:1px solid var(--line);display:flex;flex-wrap:wrap;gap:.25rem}
6096
+ }
6097
+ ${EVIDENCE_VIEW_CSS}
6098
+ </style>
6099
+ </head>
6100
+ <body>
6101
+ <header>
6102
+ <h1>${title}</h1>
6103
+ <p class="note">${escapeHtml(EVIDENCE_HTML_NOTE)}</p>
6104
+ </header>
6105
+ <div class="layout">
6106
+ <nav aria-label="Evidence views">
6107
+ ${nav}
6108
+ </nav>
6109
+ <main id="main">
6110
+ <section id="view-summary" class="panel" tabindex="-1">
6111
+ <h2>Summary</h2>
6112
+ <p>Artifact status: <span class="badge ${statusClass(input.assessmentStatus)}">${escapeHtml(input.assessmentStatus)}</span>
6113
+ ${input.sourceStatus !== void 0 ? ` \xB7 Source status: <span class="badge ${statusClass(input.sourceStatus)}">${escapeHtml(input.sourceStatus)}</span>` : ""}</p>
6114
+ <p>Profile: <code>${escapeHtml(input.redactionProfile)}</code> \xB7 Verification: <code>${escapeHtml(input.verificationPolicy)}</code></p>
6115
+ <p>Generator: <code>${escapeHtml(input.generatorName)}@${escapeHtml(input.generatorVersion)}</code>
6116
+ ${input.createdAt ? ` \xB7 Created: <code>${escapeHtml(input.createdAt)}</code>` : ""}</p>
6117
+ <h3>Runs</h3>
6118
+ <ul class="runs">${runList}</ul>
6119
+ ${checkRows ? `<h3>Check summary</h3>
6120
+ <table>
6121
+ <thead><tr><th>runId</th><th>artifact</th><th>errors</th><th>warnings</th><th>findings</th></tr></thead>
6122
+ <tbody>${checkRows}</tbody>
6123
+ </table>` : ""}
6124
+ <h3>Text summary</h3>
6125
+ ${summaryBody}
6126
+ </section>
6127
+ ${stubPanels}
6128
+ </main>
6129
+ </div>
6130
+ <script type="application/json" id="ai-evidence-data">${embedded}</script>
6131
+ <script>
6132
+ (function(){
6133
+ var links=document.querySelectorAll("nav .nav-link");
6134
+ var panels=document.querySelectorAll("main .panel");
6135
+ function show(id){
6136
+ for(var i=0;i<panels.length;i++){
6137
+ var p=panels[i];
6138
+ var on=p.id==="view-"+id;
6139
+ if(on){p.removeAttribute("hidden");}else{p.setAttribute("hidden","");}
6140
+ }
6141
+ for(var j=0;j<links.length;j++){
6142
+ var a=links[j];
6143
+ if(a.getAttribute("data-view")===id){a.setAttribute("aria-current","page");}
6144
+ else{a.removeAttribute("aria-current");}
6145
+ }
6146
+ }
6147
+ for(var k=0;k<links.length;k++){
6148
+ links[k].addEventListener("click",function(ev){
6149
+ var id=ev.currentTarget.getAttribute("data-view");
6150
+ if(!id)return;
6151
+ ev.preventDefault();
6152
+ if(history.replaceState){history.replaceState(null,"","#view-"+id);}
6153
+ show(id);
6154
+ var panel=document.getElementById("view-"+id);
6155
+ if(panel)panel.focus();
6156
+ });
6157
+ }
6158
+ var hash=(location.hash||"").replace(/^#view-/,"");
6159
+ var initial="summary";
6160
+ for(var n=0;n<links.length;n++){
6161
+ if(links[n].getAttribute("data-view")===hash){initial=hash;break;}
6162
+ }
6163
+ show(initial);
6164
+ })();
6165
+ </script>
6166
+ </body>
6167
+ </html>
6168
+ `;
6169
+ }
6170
+ function buildEvidenceHtmlShellFromManifest(manifest, extras) {
6171
+ return buildEvidenceHtmlShell({
6172
+ title: extras?.title,
6173
+ runIds: manifest.source.runIds,
6174
+ assessmentStatus: manifest.assessment.status,
6175
+ sourceStatus: manifest.assessment.sourceStatus,
6176
+ redactionProfile: manifest.policy.redactionProfile,
6177
+ verificationPolicy: manifest.policy.verificationPolicy,
6178
+ generatorName: manifest.generator.name,
6179
+ generatorVersion: manifest.generator.version,
6180
+ createdAt: manifest.createdAt,
6181
+ evidenceFormatVersion: manifest.evidenceFormatVersion,
6182
+ summaryText: extras?.summaryText,
6183
+ checkSummary: extras?.checkSummary,
6184
+ viewBodies: extras?.viewBodies
6185
+ });
6186
+ }
6187
+
6188
+ // packages/core/src/diff/comparable.ts
6189
+ function extractOutputPreview(meta) {
6190
+ if (meta === void 0) return void 0;
6191
+ if ("outputPreview" in meta) return meta.outputPreview;
6192
+ if ("resultPreview" in meta) return meta.resultPreview;
6193
+ return void 0;
6194
+ }
6195
+ function mapStepStatus(s) {
6196
+ if (s === void 0) return "running";
6197
+ return s;
6198
+ }
6199
+ function manualTraceEventsToComparableRun(events) {
6200
+ const started = events.find((e) => e.event === "run_started");
6201
+ if (!started || started.event !== "run_started") {
6202
+ throw new Error("Invalid trace: missing run_started");
6203
+ }
6204
+ const rs = started;
6205
+ const runId = rs.runId;
6206
+ const completedAll = events.filter((e) => e.event === "run_completed");
6207
+ const lastCompleted = completedAll[completedAll.length - 1];
6208
+ let runStatus;
6209
+ if (lastCompleted === void 0) runStatus = "running";
6210
+ else runStatus = lastCompleted.status;
6211
+ const durationMs2 = lastCompleted !== void 0 && Number.isFinite(lastCompleted.durationMs) ? lastCompleted.durationMs : void 0;
6212
+ const steps = /* @__PURE__ */ new Map();
6213
+ let order = 0;
6214
+ for (const e of events) {
6215
+ if (e.event !== "step_started") continue;
6216
+ const s = e;
6217
+ const meta = s.metadata ? { ...s.metadata } : void 0;
6218
+ steps.set(s.stepId, {
6219
+ id: s.stepId,
6220
+ parentId: s.parentId,
6221
+ name: s.name,
6222
+ type: s.type,
6223
+ order: order++,
6224
+ timestamp: s.timestamp,
6225
+ metadata: meta
6226
+ });
6227
+ }
6228
+ for (const e of events) {
6229
+ if (e.event !== "step_completed") continue;
6230
+ const acc = steps.get(e.stepId);
6231
+ if (!acc) continue;
6232
+ acc.status = e.status;
6233
+ acc.durationMs = e.durationMs;
6234
+ if (e.error?.message) acc.errorMsg = e.error.message;
6235
+ const extra = e;
6236
+ if (extra.metadata !== void 0 && typeof extra.metadata === "object") {
6237
+ acc.metadata = { ...acc.metadata ?? {}, ...extra.metadata };
6238
+ }
6239
+ }
6240
+ const nodes = /* @__PURE__ */ new Map();
6241
+ for (const acc of steps.values()) {
6242
+ let meta = acc.metadata ? { ...acc.metadata } : void 0;
6243
+ if (acc.parentId !== void 0 && !steps.has(acc.parentId)) {
6244
+ meta = { ...meta ?? {}, agent_inspect_diff_parent_missing: true };
6245
+ }
6246
+ const outputPreview = extractOutputPreview(meta);
6247
+ if (meta !== void 0 && ("outputPreview" in meta || "resultPreview" in meta)) {
6248
+ delete meta.outputPreview;
6249
+ delete meta.resultPreview;
6250
+ }
6251
+ const sc = {
6252
+ id: acc.id,
6253
+ name: acc.name,
6254
+ type: acc.type,
6255
+ status: mapStepStatus(acc.status),
6256
+ durationMs: acc.durationMs,
6257
+ error: acc.errorMsg,
6258
+ metadata: meta && Object.keys(meta).length > 0 ? meta : void 0,
6259
+ outputPreview,
6260
+ children: []
6261
+ };
6262
+ nodes.set(acc.id, sc);
6263
+ }
6264
+ const roots = [];
6265
+ const sortByOrder = (a, b) => {
6266
+ const oa = steps.get(a.id)?.order ?? 0;
6267
+ const ob = steps.get(b.id)?.order ?? 0;
6268
+ return oa - ob;
6269
+ };
6270
+ for (const acc of steps.values()) {
6271
+ const node = nodes.get(acc.id);
6272
+ if (acc.parentId !== void 0 && nodes.has(acc.parentId)) {
6273
+ nodes.get(acc.parentId).children.push(node);
6274
+ } else {
6275
+ roots.push(node);
6276
+ }
6277
+ }
6278
+ roots.sort(sortByOrder);
6279
+ for (const n of nodes.values()) {
6280
+ n.children.sort(sortByOrder);
6281
+ }
6282
+ return {
6283
+ runId,
6284
+ name: rs.name,
6285
+ status: runStatus,
6286
+ durationMs: durationMs2,
6287
+ steps: roots
6288
+ };
6289
+ }
6290
+
6291
+ // packages/core/src/diff/engine.ts
6292
+ var DEFAULT_THRESHOLD_MS = 0;
6293
+ function pathSeg(step, index) {
6294
+ return { index, name: step.name, stepId: step.id };
6295
+ }
6296
+ function buildPath(segments) {
6297
+ return { path: [...segments] };
6298
+ }
6299
+ function pairSteps(left, right) {
6300
+ const usedRight = /* @__PURE__ */ new Set();
6301
+ const pairs = [];
6302
+ for (let i = 0; i < left.length; i++) {
6303
+ const L = left[i];
6304
+ let R = right.find((r) => !usedRight.has(r.id) && r.id === L.id);
6305
+ if (R === void 0 && i < right.length && !usedRight.has(right[i].id)) {
6306
+ const cand = right[i];
6307
+ if (cand.name === L.name && (cand.type ?? "") === (L.type ?? "")) {
6308
+ R = cand;
6309
+ }
6310
+ }
6311
+ if (R === void 0) {
6312
+ R = right.find(
6313
+ (r) => !usedRight.has(r.id) && r.name === L.name && (r.type ?? "") === (L.type ?? "")
6314
+ );
6315
+ }
6316
+ if (R !== void 0) {
6317
+ usedRight.add(R.id);
6318
+ pairs.push([L, R]);
6319
+ } else {
6320
+ pairs.push([L, void 0]);
6321
+ }
6322
+ }
6323
+ for (const R of right) {
6324
+ if (!usedRight.has(R.id)) {
6325
+ pairs.push([void 0, R]);
6326
+ }
6327
+ }
6328
+ return pairs;
6329
+ }
6330
+ function compareLeafSteps(L, R, segments, opts, out) {
6331
+ const path14 = buildPath(segments);
6332
+ if (L.name !== R.name) {
6333
+ out.push({
6334
+ kind: "structure",
6335
+ severity: "warning",
6336
+ message: "Step name differs",
6337
+ path: path14,
6338
+ left: L.name,
6339
+ right: R.name
6340
+ });
6341
+ }
6342
+ if ((L.type ?? "") !== (R.type ?? "")) {
6343
+ out.push({
6344
+ kind: "step-type",
6345
+ severity: "warning",
6346
+ message: "Step type differs",
6347
+ path: path14,
6348
+ left: L.type,
6349
+ right: R.type
6350
+ });
6351
+ }
6352
+ if ((L.status ?? "") !== (R.status ?? "")) {
6353
+ out.push({
6354
+ kind: "step-status",
6355
+ severity: "warning",
6356
+ message: "Step status differs",
6357
+ path: path14,
6358
+ left: L.status,
6359
+ right: R.status
6360
+ });
6361
+ }
6362
+ const le = L.error ?? "";
6363
+ const re = R.error ?? "";
6364
+ if (le !== re) {
6365
+ out.push({
6366
+ kind: "error",
6367
+ severity: "error",
6368
+ message: "Step error message differs",
6369
+ path: path14,
6370
+ left: le || void 0,
6371
+ right: re || void 0
6372
+ });
6373
+ }
6374
+ if (!opts.ignoreDuration) {
6375
+ const ld = L.durationMs;
6376
+ const rd = R.durationMs;
6377
+ const th = opts.durationThresholdMs;
6378
+ let differs = false;
6379
+ if (ld === void 0 && rd === void 0) differs = false;
6380
+ else if (ld === void 0 || rd === void 0) differs = true;
6381
+ else differs = Math.abs(ld - rd) > th;
6382
+ if (differs) {
6383
+ out.push({
6384
+ kind: "duration",
6385
+ severity: "info",
6386
+ message: "Step duration differs",
6387
+ path: path14,
6388
+ left: ld,
6389
+ right: rd
6390
+ });
6391
+ }
6392
+ }
6393
+ const lm = stableJson(L.metadata ?? {});
6394
+ const rm = stableJson(R.metadata ?? {});
6395
+ if (lm !== rm) {
6396
+ out.push({
6397
+ kind: "metadata",
6398
+ severity: "info",
6399
+ message: "Step metadata differs",
6400
+ path: path14,
6401
+ left: L.metadata,
6402
+ right: R.metadata
6403
+ });
6404
+ }
6405
+ const lo = stableJson(L.outputPreview ?? null);
6406
+ const ro = stableJson(R.outputPreview ?? null);
6407
+ if (lo !== ro) {
6408
+ out.push({
6409
+ kind: "output",
6410
+ severity: "info",
6411
+ message: "Output preview differs",
6412
+ path: path14,
6413
+ left: L.outputPreview,
6414
+ right: R.outputPreview
6415
+ });
6416
+ }
6417
+ }
6418
+ function compareRecursive(L, R, segments, opts, out) {
6419
+ compareLeafSteps(L, R, segments, opts, out);
6420
+ const pairs = pairSteps(L.children, R.children);
6421
+ let ci = 0;
6422
+ for (const [lch, rch] of pairs) {
6423
+ if (lch !== void 0 && rch !== void 0) {
6424
+ compareRecursive(lch, rch, [...segments, pathSeg(lch, ci)], opts, out);
6425
+ } else if (lch !== void 0) {
6426
+ out.push({
6427
+ kind: "step-removed",
6428
+ severity: "warning",
6429
+ message: `Step only in left run: ${lch.name}`,
6430
+ path: buildPath([...segments, pathSeg(lch, ci)]),
6431
+ left: lch.id,
6432
+ right: void 0
6433
+ });
6434
+ } else if (rch !== void 0) {
6435
+ out.push({
6436
+ kind: "step-added",
6437
+ severity: "warning",
6438
+ message: `Step only in right run: ${rch.name}`,
6439
+ path: buildPath([...segments, pathSeg(rch, ci)]),
6440
+ left: void 0,
6441
+ right: rch.id
6442
+ });
6443
+ }
6444
+ ci += 1;
6445
+ }
6446
+ }
6447
+ function mergeDiffDefaults(options) {
6448
+ return {
6449
+ ignoreDuration: false,
6450
+ durationThresholdMs: DEFAULT_THRESHOLD_MS,
6451
+ focus: "all",
6452
+ check: "all"
6453
+ };
6454
+ }
6455
+ function kindMatchesFilter(kind, merged) {
6456
+ return true;
6457
+ }
6458
+ function diffRuns(left, right, options) {
6459
+ const merged = mergeDiffDefaults();
6460
+ const opts = {
6461
+ ignoreDuration: merged.ignoreDuration,
6462
+ durationThresholdMs: merged.durationThresholdMs
6463
+ };
6464
+ const raw = [];
6465
+ if ((left.status ?? "") !== (right.status ?? "")) {
6466
+ raw.push({
6467
+ kind: "run-status",
6468
+ severity: "warning",
6469
+ message: "Run completion status differs",
6470
+ left: left.status,
6471
+ right: right.status
6472
+ });
6473
+ }
6474
+ {
6475
+ const ld = left.durationMs;
6476
+ const rd = right.durationMs;
6477
+ const th = merged.durationThresholdMs;
6478
+ let differs = false;
6479
+ if (ld === void 0 && rd === void 0) differs = false;
6480
+ else if (ld === void 0 || rd === void 0) differs = true;
6481
+ else differs = Math.abs(ld - rd) > th;
6482
+ if (differs) {
6483
+ raw.push({
6484
+ kind: "duration",
6485
+ severity: "info",
6486
+ message: "Run duration differs",
6487
+ left: ld,
6488
+ right: rd
6489
+ });
6490
+ }
6491
+ }
6492
+ const pairs = pairSteps(left.steps, right.steps);
6493
+ let idx = 0;
6494
+ for (const [ls, rs] of pairs) {
6495
+ if (ls !== void 0 && rs !== void 0) {
6496
+ compareRecursive(ls, rs, [pathSeg(ls, idx)], opts, raw);
6497
+ idx += 1;
6498
+ } else if (ls !== void 0) {
6499
+ raw.push({
6500
+ kind: "step-removed",
6501
+ severity: "warning",
6502
+ message: `Step only in left run: ${ls.name}`,
6503
+ path: buildPath([pathSeg(ls, idx)]),
6504
+ left: ls.id,
6505
+ right: void 0
6506
+ });
6507
+ idx += 1;
6508
+ } else if (rs !== void 0) {
6509
+ raw.push({
6510
+ kind: "step-added",
6511
+ severity: "warning",
6512
+ message: `Step only in right run: ${rs.name}`,
6513
+ path: buildPath([pathSeg(rs, idx)]),
6514
+ left: void 0,
6515
+ right: rs.id
6516
+ });
6517
+ idx += 1;
6518
+ }
6519
+ }
6520
+ const differences = raw.filter((d) => kindMatchesFilter(d.kind));
6521
+ let errors = 0;
6522
+ let warnings = 0;
6523
+ let info = 0;
6524
+ for (const d of differences) {
6525
+ if (d.severity === "error") errors += 1;
6526
+ else if (d.severity === "warning") warnings += 1;
6527
+ else info += 1;
6528
+ }
6529
+ const firstVisible = differences[0];
6530
+ const firstDivergence = firstVisible !== void 0 ? {
6531
+ kind: "first-divergence",
6532
+ severity: firstVisible.severity,
6533
+ message: `First divergence: ${firstVisible.message}`,
6534
+ path: firstVisible.path,
6535
+ left: firstVisible.left,
6536
+ right: firstVisible.right
6537
+ } : void 0;
6538
+ const summary = {
6539
+ leftRunId: left.runId,
6540
+ rightRunId: right.runId,
6541
+ totalDifferences: differences.length,
6542
+ errors,
6543
+ warnings,
6544
+ info,
6545
+ firstDivergence
6546
+ };
6547
+ return { summary, differences };
6548
+ }
6549
+
6550
+ // packages/core/src/diff/renderer.ts
6551
+ function formatPath(path14) {
6552
+ if (path14 === void 0 || path14.path.length === 0) {
6553
+ return "(run)";
6554
+ }
6555
+ return path14.path.map((s) => s.name).join(" > ");
6556
+ }
6557
+ function formatValue(v, verbose) {
6558
+ if (v === void 0) return "(undefined)";
6559
+ if (typeof v === "string") return v;
6560
+ if (typeof v === "number" || typeof v === "boolean") return String(v);
6561
+ const s = JSON.stringify(v);
6562
+ if (s.length <= 120) return s;
6563
+ return `${s.slice(0, 117)}...`;
6564
+ }
6565
+ function renderRunDiff(result, options) {
6566
+ const json = options?.json === true;
6567
+ if (json) {
6568
+ return JSON.stringify(result, null, 2);
6569
+ }
6570
+ const sev = (s, level) => {
6571
+ return s;
6572
+ };
6573
+ const lines = [];
6574
+ const { summary } = result;
6575
+ lines.push("Run diff");
6576
+ lines.push(`Left: ${summary.leftRunId}`);
6577
+ lines.push(`Right: ${summary.rightRunId}`);
6578
+ lines.push("");
6579
+ lines.push("Summary:");
6580
+ lines.push(` Differences: ${summary.totalDifferences}`);
6581
+ lines.push(` Errors: ${summary.errors}`);
6582
+ lines.push(` Warnings: ${summary.warnings}`);
6583
+ lines.push(` Info: ${summary.info}`);
6584
+ lines.push("");
6585
+ const fd = summary.firstDivergence;
6586
+ const firstKind = result.differences[0]?.kind;
6587
+ if (fd !== void 0) {
6588
+ lines.push("First divergence:");
6589
+ const where = formatPath(fd.path);
6590
+ const displayKind = firstKind ?? fd.kind;
6591
+ lines.push(` ${displayKind} at ${where}`);
6592
+ if (fd.left !== void 0 || fd.right !== void 0) {
6593
+ lines.push(` left: ${formatValue(fd.left)}`);
6594
+ lines.push(` right: ${formatValue(fd.right)}`);
6595
+ }
6596
+ lines.push("");
6597
+ }
6598
+ lines.push("Differences:");
6599
+ if (result.differences.length === 0) {
6600
+ lines.push(" (none)");
6601
+ return lines.join("\n");
6602
+ }
6603
+ const showSides = (kind) => [
6604
+ "run-status",
6605
+ "step-status",
6606
+ "error",
6607
+ "duration",
6608
+ "step-type",
6609
+ "structure",
6610
+ "step-added",
6611
+ "step-removed"
6612
+ ].includes(kind);
6613
+ for (const d of result.differences) {
6614
+ const tag = sev(`[${d.severity}]`, d.severity);
6615
+ const pathStr = d.path !== void 0 ? ` ${formatPath(d.path)}` : "";
6616
+ lines.push(` ${tag} ${d.kind}${pathStr}`);
6617
+ lines.push(` ${d.message}`);
6618
+ if (d.left !== void 0 || d.right !== void 0) {
6619
+ if (showSides(d.kind)) {
6620
+ lines.push(` left: ${formatValue(d.left)}`);
6621
+ lines.push(` right: ${formatValue(d.right)}`);
6622
+ }
6623
+ }
6624
+ }
6625
+ return lines.join("\n");
6626
+ }
6627
+
6628
+ // packages/core/src/diff/index.ts
6629
+ function diffTraceEvents(leftEvents, rightEvents, options) {
6630
+ const left = manualTraceEventsToComparableRun(leftEvents);
6631
+ const right = manualTraceEventsToComparableRun(rightEvents);
6632
+ return diffRuns(left, right);
6633
+ }
6634
+
6635
+ // packages/core/src/evidence/views-contract.ts
6636
+ function boundMessage(message, max = 200) {
6637
+ const trimmed = message.trim();
6638
+ if (trimmed.length <= max) return trimmed;
6639
+ return `${trimmed.slice(0, max)}\u2026`;
6640
+ }
6641
+ function buildEvidenceContractsViewHtml(input) {
6642
+ const rows = input.runs.map(
6643
+ (run) => `<tr><td><code>${escapeHtml(run.runId)}</code></td><td>${escapeHtml(run.status)}</td><td>${escapeHtml(run.sourceStatus ?? "\u2014")}</td><td>${run.errors}</td><td>${run.warnings}</td><td>${run.findings}</td></tr>`
6644
+ ).join("");
6645
+ const findings = input.findingSummaries ?? [];
6646
+ const findingRows = findings.length === 0 ? `<p class="muted">No structured check findings recorded for the redacted artifact.</p>` : `<table>
6647
+ <thead><tr><th>runId</th><th>severity</th><th>rule</th><th>category</th><th>detector</th><th>message</th></tr></thead>
6648
+ <tbody>${findings.map(
6649
+ (f) => `<tr><td><code>${escapeHtml(f.runId)}</code></td><td>${escapeHtml(f.severity)}</td><td><code>${escapeHtml(f.ruleId)}</code></td><td>${escapeHtml(f.category ?? "\u2014")}</td><td>${escapeHtml(f.detector ?? "\u2014")}</td><td>${escapeHtml(boundMessage(f.message))}</td></tr>`
6650
+ ).join("")}</tbody>
6651
+ </table>`;
6652
+ return `<p>Aggregate artifact status: <strong>${escapeHtml(input.aggregateStatus)}</strong></p>
6653
+ <table>
6654
+ <thead><tr><th>runId</th><th>artifact</th><th>source</th><th>errors</th><th>warnings</th><th>findings</th></tr></thead>
6655
+ <tbody>${rows}</tbody>
6656
+ </table>
6657
+ <h3>Finding summaries</h3>
6658
+ ${findingRows}
6659
+ <p class="muted">TraceContract / check details are best-effort local results \u2014 not a compliance certification.</p>`;
6660
+ }
6661
+ function buildEvidenceOutcomesViewHtml(runs) {
6662
+ if (runs.length === 0) {
6663
+ return `<p class="muted">No runs available for outcome extraction.</p>`;
6664
+ }
6665
+ const parts = [];
6666
+ for (const run of runs) {
6667
+ const forRun = run.events.filter((event) => event.runId === run.runId);
6668
+ const summary = summarizeObservedOutcomes(extractOutcomesFromPersistedEvents(forRun));
6669
+ parts.push(`<article class="run-block">`);
6670
+ parts.push(`<h3><code>${escapeHtml(run.runId)}</code></h3>`);
6671
+ parts.push(renderObservedOutcomesHtml(summary));
6672
+ parts.push(`</article>`);
6673
+ }
6674
+ return parts.join("\n");
6675
+ }
6676
+ function buildEvidenceDiffViewHtml(parts) {
6677
+ if (parts === void 0 || parts.leftEvents.length === 0 || parts.rightEvents.length === 0) {
6678
+ return `<p class="muted">No baseline/candidate pair was supplied for this evidence bundle. Attach two runs (or a reporter baseline) to populate this view.</p>`;
6679
+ }
6680
+ try {
6681
+ const left = persistedInspectEventsToTraceEvents(
6682
+ parts.leftEvents.filter((e) => e.runId === parts.leftRunId)
6683
+ );
6684
+ const right = persistedInspectEventsToTraceEvents(
6685
+ parts.rightEvents.filter((e) => e.runId === parts.rightRunId)
6686
+ );
6687
+ if (left.length === 0 || right.length === 0) {
6688
+ return `<p class="muted">Could not normalize both runs for diff (missing v0.1-compatible events).</p>`;
6689
+ }
6690
+ const result = diffTraceEvents(left, right);
6691
+ const text = renderRunDiff(result, { color: false, verbose: false });
6692
+ return `<p>Comparing <code>${escapeHtml(parts.leftRunId)}</code> \u2192 <code>${escapeHtml(parts.rightRunId)}</code></p>
6693
+ <pre class="summary-md">${escapeHtml(text)}</pre>`;
6694
+ } catch (error) {
6695
+ const message = error instanceof Error ? error.message : String(error);
6696
+ return `<p class="muted">Diff unavailable: ${escapeHtml(message)}</p>`;
6697
+ }
6698
+ }
6699
+
6700
+ // packages/core/src/evidence/views-safety.ts
6701
+ function buildEvidenceSafetyViewHtml(input) {
6702
+ const findingRows = (input.findingSummaries ?? []).length === 0 ? `<p class="muted">No safety findings on the redacted artifact.</p>` : `<table>
6703
+ <thead><tr><th>runId</th><th>severity</th><th>category</th><th>detector</th><th>action</th><th>message</th></tr></thead>
6704
+ <tbody>${(input.findingSummaries ?? []).map((f) => {
6705
+ const msg = f.message.length > 160 ? `${f.message.slice(0, 160)}\u2026` : f.message;
6706
+ return `<tr><td><code>${escapeHtml(f.runId)}</code></td><td>${escapeHtml(f.severity)}</td><td>${escapeHtml(f.category ?? "\u2014")}</td><td>${escapeHtml(f.detector ?? "\u2014")}</td><td>${escapeHtml(f.action ?? "\u2014")}</td><td>${escapeHtml(msg)}</td></tr>`;
6707
+ }).join("")}</tbody>
6708
+ </table>`;
6709
+ const redactionBlock = input.redaction === void 0 ? `<p class="muted">No redaction report attached.</p>` : `<p>Total redaction findings: <strong>${input.redaction.totalFindings}</strong></p>
6710
+ <ul>${input.redaction.runs.map(
6711
+ (run) => `<li><code>${escapeHtml(run.runId)}</code>: ${run.findings} finding(s); detectors: ${escapeHtml(run.detectors.join(", ") || "none")}</li>`
6712
+ ).join("")}</ul>`;
6713
+ return `<p>Artifact status: <strong>${escapeHtml(String(input.artifactStatus))}</strong>
6714
+ ${input.sourceStatus !== void 0 ? ` \xB7 Source status: <strong>${escapeHtml(String(input.sourceStatus))}</strong>` : ""}</p>
6715
+ <p>Redaction profile: <code>${escapeHtml(input.redactionProfile)}</code> \xB7 Verification: <code>${escapeHtml(input.verificationPolicy)}</code></p>
6716
+ <h3>Redaction</h3>
6717
+ ${redactionBlock}
6718
+ <h3>Safety findings (artifact)</h3>
6719
+ ${findingRows}
6720
+ <p class="muted">Best-effort local verification only \u2014 not a compliance certification. Gate sharing on artifact status.</p>`;
6721
+ }
6722
+ function buildEvidenceProvenanceViewHtml(input) {
6723
+ const hashes = input.sourceHashes.length === 0 ? `<p class="muted">No source hashes recorded.</p>` : `<table>
6724
+ <thead><tr><th>runId</th><th>algorithm</th><th>hash</th></tr></thead>
6725
+ <tbody>${input.sourceHashes.map(
6726
+ (h) => `<tr><td><code>${escapeHtml(h.runId)}</code></td><td>${escapeHtml(h.algorithm)}</td><td><code>${escapeHtml(h.hash)}</code></td></tr>`
6727
+ ).join("")}</tbody>
6728
+ </table>`;
6729
+ const files = input.packagedFiles.length === 0 ? `<p class="muted">No packaged files listed.</p>` : `<ul>${input.packagedFiles.map(
6730
+ (f) => `<li><code>${escapeHtml(f.path)}</code>${f.role ? ` <span class="meta">(${escapeHtml(f.role)})</span>` : ""}</li>`
6731
+ ).join("")}</ul>`;
6732
+ return `<p>Generator: <code>${escapeHtml(input.generatorName)}@${escapeHtml(input.generatorVersion)}</code>
6733
+ \xB7 Evidence format: <code>${escapeHtml(input.evidenceFormatVersion)}</code>
6734
+ ${input.createdAt ? ` \xB7 Created: <code>${escapeHtml(input.createdAt)}</code>` : ""}</p>
6735
+ <p>Runs: ${input.runIds.map((id) => `<code>${escapeHtml(id)}</code>`).join(", ")}</p>
6736
+ <p>Trace schema versions: ${input.traceSchemaVersions.length > 0 ? input.traceSchemaVersions.map((v) => `<code>${escapeHtml(v)}</code>`).join(", ") : '<span class="muted">unknown</span>'}</p>
6737
+ <h3>Source hashes (pre-redaction input)</h3>
6738
+ ${hashes}
6739
+ <h3>Packaged files</h3>
6740
+ ${files}
6741
+ <p class="muted">${escapeHtml(input.note ?? "Reader/mapping losses are reported elsewhere when present; relationships are never invented without confidence policy.")}</p>`;
6742
+ }
6743
+ function buildEvidenceToolsLlmViewHtml(trees) {
6744
+ if (trees.length === 0) {
6745
+ return `<p class="muted">No runs available for tool/LLM metadata.</p>`;
6746
+ }
6747
+ const parts = [];
6748
+ for (const tree of trees) {
6749
+ const nodes = flattenTree(tree).filter(
6750
+ (n) => n.event.kind === "TOOL" || n.event.kind === "LLM" || n.event.kind === "AGENT"
6751
+ );
6752
+ parts.push(`<article class="run-block">`);
6753
+ parts.push(`<h3><code>${escapeHtml(tree.runId)}</code></h3>`);
6754
+ if (nodes.length === 0) {
6755
+ parts.push(`<p class="muted">No TOOL/LLM/AGENT events in this run.</p>`);
6756
+ } else {
6757
+ parts.push(`<table>
6758
+ <thead><tr><th>name</th><th>kind</th><th>status</th><th>durationMs</th></tr></thead>
6759
+ <tbody>${nodes.map((n) => {
6760
+ const dur = n.event.durationMs !== void 0 && Number.isFinite(n.event.durationMs) ? String(n.event.durationMs) : "\u2014";
6761
+ return `<tr><td>${escapeHtml(n.event.name)}</td><td>${escapeHtml(n.event.kind)}</td><td>${escapeHtml(n.event.status ?? "?")}</td><td>${escapeHtml(dur)}</td></tr>`;
6762
+ }).join("")}</tbody>
6763
+ </table>`);
6764
+ }
6765
+ parts.push(`</article>`);
6766
+ }
6767
+ return parts.join("\n");
6768
+ }
6769
+ function buildEvidenceCircuitViewHtml(parts) {
6770
+ const findings = parts?.findings ?? [];
6771
+ if (findings.length === 0) {
6772
+ return `<p class="muted">No circuit or guardrail findings were attached to this evidence bundle.</p>`;
6773
+ }
6774
+ return `<table>
6775
+ <thead><tr><th>runId</th><th>name</th><th>status</th><th>detail</th></tr></thead>
6776
+ <tbody>${findings.map(
6777
+ (f) => `<tr><td><code>${escapeHtml(f.runId)}</code></td><td>${escapeHtml(f.name)}</td><td>${escapeHtml(f.status)}</td><td>${escapeHtml(f.detail ?? "\u2014")}</td></tr>`
6778
+ ).join("")}</tbody>
6779
+ </table>`;
6780
+ }
6781
+
6782
+ // packages/core/src/evidence/zip.ts
6783
+ var CRC_TABLE = (() => {
6784
+ const table = new Uint32Array(256);
6785
+ for (let n = 0; n < 256; n += 1) {
6786
+ let c = n;
6787
+ for (let k = 0; k < 8; k += 1) {
6788
+ c = c & 1 ? 3988292384 ^ c >>> 1 : c >>> 1;
6789
+ }
6790
+ table[n] = c >>> 0;
6791
+ }
6792
+ return table;
6793
+ })();
6794
+ function crc32(data) {
6795
+ let crc = 4294967295;
6796
+ for (let i = 0; i < data.length; i += 1) {
6797
+ crc = CRC_TABLE[(crc ^ data[i]) & 255] ^ crc >>> 8;
6798
+ }
6799
+ return (crc ^ 4294967295) >>> 0;
6800
+ }
6801
+ function toBytes(content) {
6802
+ return typeof content === "string" ? Buffer.from(content, "utf8") : content;
6803
+ }
6804
+ function u16(value) {
6805
+ const buf = Buffer.alloc(2);
6806
+ buf.writeUInt16LE(value >>> 0, 0);
6807
+ return buf;
6808
+ }
6809
+ function u32(value) {
6810
+ const buf = Buffer.alloc(4);
6811
+ buf.writeUInt32LE(value >>> 0, 0);
6812
+ return buf;
6813
+ }
6814
+ function buildZipArchive(entries) {
6815
+ if (entries.length === 0) {
6816
+ throw new Error("ZIP archive requires at least one entry.");
6817
+ }
6818
+ const locals = [];
6819
+ const centrals = [];
6820
+ let offset = 0;
6821
+ const seen = /* @__PURE__ */ new Set();
6822
+ for (const entry of entries) {
6823
+ const name = assertEvidenceRelativePath(entry.path);
6824
+ if (seen.has(name)) {
6825
+ throw new Error(`Duplicate ZIP entry path: ${name}`);
6826
+ }
6827
+ seen.add(name);
6828
+ const nameBytes = Buffer.from(name, "utf8");
6829
+ const data = toBytes(entry.content);
6830
+ const checksum = crc32(data);
6831
+ const size = data.byteLength;
6832
+ const local = Buffer.concat([
6833
+ u32(67324752),
6834
+ u16(20),
6835
+ // version needed
6836
+ u16(0),
6837
+ // flags
6838
+ u16(0),
6839
+ // method STORE
6840
+ u16(0),
6841
+ // time
6842
+ u16(0),
6843
+ // date
6844
+ u32(checksum),
6845
+ u32(size),
6846
+ u32(size),
6847
+ u16(nameBytes.length),
6848
+ u16(0),
6849
+ // extra length
6850
+ nameBytes,
6851
+ Buffer.from(data)
6852
+ ]);
6853
+ const central = Buffer.concat([
6854
+ u32(33639248),
6855
+ u16(20),
6856
+ // version made by
6857
+ u16(20),
6858
+ // version needed
6859
+ u16(0),
6860
+ u16(0),
6861
+ u16(0),
6862
+ u16(0),
6863
+ u32(checksum),
6864
+ u32(size),
6865
+ u32(size),
6866
+ u16(nameBytes.length),
6867
+ u16(0),
6868
+ u16(0),
6869
+ u16(0),
6870
+ u16(0),
6871
+ u32(0),
6872
+ u32(offset),
6873
+ nameBytes
6874
+ ]);
6875
+ locals.push(local);
6876
+ centrals.push(central);
6877
+ offset += local.length;
6878
+ }
6879
+ const centralDir = Buffer.concat(centrals);
6880
+ const end = Buffer.concat([
6881
+ u32(101010256),
6882
+ u16(0),
6883
+ u16(0),
6884
+ u16(entries.length),
6885
+ u16(entries.length),
6886
+ u32(centralDir.length),
6887
+ u32(offset),
6888
+ u16(0)
6889
+ ]);
6890
+ return Buffer.concat([...locals, centralDir, end]);
6891
+ }
6892
+ async function listFilesRecursive(root) {
6893
+ const out = [];
6894
+ async function walk(dir) {
6895
+ const entries = await promises.readdir(dir, { withFileTypes: true });
6896
+ for (const entry of entries) {
6897
+ const abs = path5__default.default.join(dir, entry.name);
6898
+ if (entry.isDirectory()) {
6899
+ await walk(abs);
6900
+ } else if (entry.isFile()) {
6901
+ const rel = path5__default.default.relative(root, abs).split(path5__default.default.sep).join("/");
6902
+ out.push(rel);
6903
+ }
6904
+ }
6905
+ }
6906
+ await walk(root);
6907
+ return out.sort((a, b) => a.localeCompare(b));
6908
+ }
6909
+ async function verifyEvidenceDirectory(rootPath, options = {}) {
6910
+ const unexpectedMode = options.unexpectedFiles ?? "fail";
6911
+ const root = path5__default.default.resolve(rootPath);
6912
+ const issues = [];
6913
+ let rootStat;
6914
+ try {
6915
+ rootStat = await promises.stat(root);
6916
+ } catch (error) {
6917
+ const message = error instanceof Error ? error.message : String(error);
6918
+ return {
6919
+ ok: false,
6920
+ status: "fail",
6921
+ root,
6922
+ issues: [{ code: "io_error", severity: "error", message: `Cannot read path: ${message}` }],
6923
+ checkedFiles: 0
6924
+ };
6925
+ }
6926
+ if (!rootStat.isDirectory()) {
6927
+ return {
6928
+ ok: false,
6929
+ status: "fail",
6930
+ root,
6931
+ issues: [
6932
+ {
6933
+ code: "io_error",
6934
+ severity: "error",
6935
+ message: "Evidence verify expects a directory containing evidence.json (unpack ZIP first)."
6936
+ }
6937
+ ],
6938
+ checkedFiles: 0
6939
+ };
6940
+ }
6941
+ const manifestPath = path5__default.default.join(root, EVIDENCE_MANIFEST_FILENAME);
6942
+ let manifestText;
6943
+ try {
6944
+ manifestText = await promises.readFile(manifestPath, "utf-8");
6945
+ } catch {
6946
+ return {
6947
+ ok: false,
6948
+ status: "fail",
6949
+ root,
6950
+ issues: [
6951
+ {
6952
+ code: "manifest_missing",
6953
+ severity: "error",
6954
+ message: `Missing ${EVIDENCE_MANIFEST_FILENAME}`,
6955
+ path: EVIDENCE_MANIFEST_FILENAME
6956
+ }
6957
+ ],
6958
+ checkedFiles: 0
6959
+ };
6960
+ }
6961
+ let manifest;
6962
+ try {
6963
+ manifest = parseEvidenceManifestJson(manifestText);
6964
+ } catch (error) {
6965
+ const message = error instanceof Error ? error.message : String(error);
6966
+ return {
6967
+ ok: false,
6968
+ status: "fail",
6969
+ root,
6970
+ issues: [
6971
+ {
6972
+ code: "manifest_invalid",
6973
+ severity: "error",
6974
+ message,
6975
+ path: EVIDENCE_MANIFEST_FILENAME
6976
+ }
6977
+ ],
6978
+ checkedFiles: 0
6979
+ };
6980
+ }
6981
+ if (!manifest.assessment?.status) {
6982
+ issues.push({
6983
+ code: "assessment_missing",
6984
+ severity: "error",
6985
+ message: "Manifest assessment.status is required."
6986
+ });
6987
+ }
6988
+ if (!manifest.generator?.name || !manifest.generator?.version) {
6989
+ issues.push({
6990
+ code: "provenance_missing",
6991
+ severity: "error",
6992
+ message: "Manifest generator.name and generator.version are required."
6993
+ });
6994
+ }
6995
+ if (!manifest.source?.runIds?.length) {
6996
+ issues.push({
6997
+ code: "provenance_missing",
6998
+ severity: "error",
6999
+ message: "Manifest source.runIds must be non-empty."
7000
+ });
7001
+ }
7002
+ const listed = /* @__PURE__ */ new Set();
7003
+ for (const file of manifest.files) {
7004
+ let rel;
7005
+ try {
7006
+ rel = assertEvidenceRelativePath(file.path);
7007
+ } catch (error) {
7008
+ const message = error instanceof Error ? error.message : String(error);
7009
+ issues.push({
7010
+ code: "path_unsafe",
7011
+ severity: "error",
7012
+ message,
7013
+ path: file.path
7014
+ });
7015
+ continue;
7016
+ }
7017
+ if (rel === EVIDENCE_MANIFEST_FILENAME) {
7018
+ issues.push({
7019
+ code: "manifest_invalid",
7020
+ severity: "error",
7021
+ message: `${EVIDENCE_MANIFEST_FILENAME} must not list itself in files[].`,
7022
+ path: rel
7023
+ });
7024
+ continue;
7025
+ }
7026
+ listed.add(rel);
7027
+ const abs = path5__default.default.join(root, ...rel.split("/"));
7028
+ let bytes;
7029
+ try {
7030
+ bytes = await promises.readFile(abs);
7031
+ } catch {
7032
+ issues.push({
7033
+ code: "file_missing",
7034
+ severity: "error",
7035
+ message: `Listed file missing: ${rel}`,
7036
+ path: rel
7037
+ });
7038
+ continue;
7039
+ }
7040
+ const actual = sha256Hex(bytes);
7041
+ if (!sha256Equals(file.sha256, actual)) {
7042
+ issues.push({
7043
+ code: "hash_mismatch",
7044
+ severity: "error",
7045
+ message: `SHA-256 mismatch for ${rel}`,
7046
+ path: rel
7047
+ });
7048
+ }
7049
+ }
7050
+ let onDisk = [];
7051
+ try {
7052
+ onDisk = await listFilesRecursive(root);
7053
+ } catch (error) {
7054
+ const message = error instanceof Error ? error.message : String(error);
7055
+ issues.push({ code: "io_error", severity: "error", message });
7056
+ }
7057
+ for (const rel of onDisk) {
7058
+ if (rel === EVIDENCE_MANIFEST_FILENAME) continue;
7059
+ if (listed.has(rel)) continue;
7060
+ if (unexpectedMode === "ignore") continue;
7061
+ issues.push({
7062
+ code: "file_unexpected",
7063
+ severity: unexpectedMode === "warn" ? "warning" : "error",
7064
+ message: `Unexpected file not listed in manifest: ${rel}`,
7065
+ path: rel
7066
+ });
7067
+ }
7068
+ const hasError = issues.some((issue) => issue.severity === "error");
7069
+ return {
7070
+ ok: !hasError,
7071
+ status: hasError ? "fail" : "pass",
7072
+ root,
7073
+ manifest,
7074
+ issues,
7075
+ checkedFiles: listed.size
7076
+ };
7077
+ }
7078
+
7079
+ // packages/core/src/evidence/ci.ts
7080
+ function asMap(value) {
7081
+ if (value instanceof Map) return new Map(value);
7082
+ return new Map(Object.entries(value));
7083
+ }
7084
+ function buildEvidenceCiPackage(input) {
7085
+ const sources = asMap(input.sourceContents);
7086
+ const sourceHashes = input.runIds.map((runId) => ({
7087
+ runId,
7088
+ algorithm: "sha256",
7089
+ hash: sha256Hex(sources.get(runId) ?? "")
7090
+ }));
7091
+ const schemaVersions = /* @__PURE__ */ new Set();
7092
+ for (const content of sources.values()) {
7093
+ for (const version of collectTraceSchemaVersions(content)) {
7094
+ schemaVersions.add(version);
7095
+ }
7096
+ }
7097
+ for (const version of collectTraceSchemaVersions(input.redactedTraceJsonl)) {
7098
+ schemaVersions.add(version);
7099
+ }
7100
+ const createdAt = input.createdAt ?? (/* @__PURE__ */ new Date()).toISOString();
7101
+ const evidenceHtml = buildEvidenceHtmlShell({
7102
+ title: "AgentInspect evidence",
7103
+ runIds: input.runIds,
7104
+ assessmentStatus: input.assessmentStatus,
7105
+ sourceStatus: input.sourceStatus,
7106
+ redactionProfile: input.redactionProfile,
7107
+ verificationPolicy: input.redactionProfile,
7108
+ generatorName: "agent-inspect",
7109
+ generatorVersion: input.generatorVersion,
7110
+ createdAt,
7111
+ summaryText: input.summaryText,
7112
+ checkSummary: {
7113
+ aggregateStatus: input.assessmentStatus,
7114
+ runs: input.runIds.map((runId) => ({
7115
+ runId,
7116
+ status: input.assessmentStatus,
7117
+ sourceStatus: input.sourceStatus,
7118
+ errors: input.assessmentStatus === "UNSAFE" || input.assessmentStatus === "UNKNOWN" ? 1 : 0,
7119
+ warnings: input.assessmentStatus === "SAFE WITH WARNINGS" ? 1 : 0,
7120
+ findings: 0
7121
+ }))
7122
+ }
7123
+ });
7124
+ const packaged = [
7125
+ { path: EVIDENCE_HTML_FILENAME, content: evidenceHtml },
7126
+ { path: "check-results.json", content: input.checkResultsJson },
7127
+ { path: "trace.jsonl", content: input.redactedTraceJsonl }
7128
+ ];
7129
+ const manifest = buildEvidenceManifest({
7130
+ generatorVersion: input.generatorVersion,
7131
+ runIds: input.runIds,
7132
+ traceSchemaVersions: [...schemaVersions].sort((a, b) => a.localeCompare(b)),
7133
+ sourceHashes,
7134
+ redactionProfile: input.redactionProfile,
7135
+ verificationPolicy: input.redactionProfile,
7136
+ assessmentStatus: input.assessmentStatus,
7137
+ sourceStatus: input.sourceStatus,
7138
+ files: packaged,
7139
+ createdAt,
7140
+ note: EVIDENCE_ASSESSMENT_NOTE
7141
+ });
7142
+ return {
7143
+ "evidence.html": evidenceHtml,
7144
+ "evidence.json": serializeEvidenceManifest(manifest),
7145
+ "check-results.json": input.checkResultsJson,
7146
+ "trace.jsonl": input.redactedTraceJsonl,
7147
+ manifest
7148
+ };
7149
+ }
7150
+
5346
7151
  // packages/core/src/suite/types.ts
5347
7152
  var DEFAULT_SUITE_CONFIG_NAMES = [
5348
7153
  "agent-inspect.suite.json",
@@ -5866,7 +7671,7 @@ function stripPrefix(name, prefixes) {
5866
7671
  }
5867
7672
  return name;
5868
7673
  }
5869
- function eventEvidence(event, path12) {
7674
+ function eventEvidence(event, path14) {
5870
7675
  return {
5871
7676
  runId: event.runId,
5872
7677
  eventId: event.eventId,
@@ -5876,7 +7681,7 @@ function eventEvidence(event, path12) {
5876
7681
  kind: event.kind,
5877
7682
  name: event.name,
5878
7683
  status: event.status,
5879
- ...path12 ? { path: path12 } : {}
7684
+ ...path14 ? { path: path14 } : {}
5880
7685
  };
5881
7686
  }
5882
7687
  function runEvidence(run) {
@@ -9080,11 +10885,6 @@ async function analyzeCohort(runsInput, options) {
9080
10885
  };
9081
10886
  }
9082
10887
 
9083
- // packages/core/src/exporters/helpers.ts
9084
- function escapeHtml(value) {
9085
- return value.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
9086
- }
9087
-
9088
10888
  // packages/core/src/cohort/render.ts
9089
10889
  function formatRate(value) {
9090
10890
  if (value === void 0) return "n/a";
@@ -9716,6 +11516,12 @@ exports.DEFAULT_MAX_PREVIEW_LENGTH = DEFAULT_MAX_PREVIEW_LENGTH;
9716
11516
  exports.DEFAULT_SUITE_ARTIFACTS_DIR = DEFAULT_SUITE_ARTIFACTS_DIR;
9717
11517
  exports.DEFAULT_SUITE_CONFIG_NAMES = DEFAULT_SUITE_CONFIG_NAMES;
9718
11518
  exports.DEFAULT_TRACE_DIR_NAME = DEFAULT_TRACE_DIR_NAME;
11519
+ exports.EVIDENCE_ASSESSMENT_NOTE = EVIDENCE_ASSESSMENT_NOTE;
11520
+ exports.EVIDENCE_FORMAT_VERSION = EVIDENCE_FORMAT_VERSION;
11521
+ exports.EVIDENCE_HTML_FILENAME = EVIDENCE_HTML_FILENAME;
11522
+ exports.EVIDENCE_MANIFEST_FILENAME = EVIDENCE_MANIFEST_FILENAME;
11523
+ exports.EVIDENCE_VIEW_CSS = EVIDENCE_VIEW_CSS;
11524
+ exports.EVIDENCE_VIEW_IDS = EVIDENCE_VIEW_IDS;
9719
11525
  exports.FALLBACK_TRACE_DIR = FALLBACK_TRACE_DIR;
9720
11526
  exports.MAX_NAME_LENGTH = MAX_NAME_LENGTH;
9721
11527
  exports.MAX_TERMINAL_DEPTH = MAX_TERMINAL_DEPTH;
@@ -9729,9 +11535,25 @@ exports.aggregateBundleSafeStatus = aggregateBundleSafeStatus;
9729
11535
  exports.aggregateSessionCheckResults = aggregateSessionCheckResults;
9730
11536
  exports.analyzeCohort = analyzeCohort;
9731
11537
  exports.assertBundlePathContained = assertBundlePathContained;
11538
+ exports.assertEvidenceRelativePath = assertEvidenceRelativePath;
9732
11539
  exports.buildActivitySummary = buildActivitySummary;
9733
11540
  exports.buildBundleMetadata = buildBundleMetadata;
9734
11541
  exports.buildBundleSummaryMarkdown = buildBundleSummaryMarkdown;
11542
+ exports.buildEvidenceCausalFailureViewHtml = buildEvidenceCausalFailureViewHtml;
11543
+ exports.buildEvidenceCiPackage = buildEvidenceCiPackage;
11544
+ exports.buildEvidenceCircuitViewHtml = buildEvidenceCircuitViewHtml;
11545
+ exports.buildEvidenceContractsViewHtml = buildEvidenceContractsViewHtml;
11546
+ exports.buildEvidenceDiffViewHtml = buildEvidenceDiffViewHtml;
11547
+ exports.buildEvidenceFileEntries = buildEvidenceFileEntries;
11548
+ exports.buildEvidenceHtmlShell = buildEvidenceHtmlShell;
11549
+ exports.buildEvidenceHtmlShellFromManifest = buildEvidenceHtmlShellFromManifest;
11550
+ exports.buildEvidenceManifest = buildEvidenceManifest;
11551
+ exports.buildEvidenceOutcomesViewHtml = buildEvidenceOutcomesViewHtml;
11552
+ exports.buildEvidenceProvenanceViewHtml = buildEvidenceProvenanceViewHtml;
11553
+ exports.buildEvidenceSafetyViewHtml = buildEvidenceSafetyViewHtml;
11554
+ exports.buildEvidenceTimelineViewHtml = buildEvidenceTimelineViewHtml;
11555
+ exports.buildEvidenceToolsLlmViewHtml = buildEvidenceToolsLlmViewHtml;
11556
+ exports.buildEvidenceTreeViewHtml = buildEvidenceTreeViewHtml;
9735
11557
  exports.buildLocalExplanation = buildLocalExplanation;
9736
11558
  exports.buildPlaceholderArtifact = buildPlaceholderArtifact;
9737
11559
  exports.buildRunSummary = buildRunSummary;
@@ -9739,8 +11561,10 @@ exports.buildRunTimeline = buildRunTimeline;
9739
11561
  exports.buildRunWhatSummary = buildRunWhatSummary;
9740
11562
  exports.buildSessionIndex = buildSessionIndex;
9741
11563
  exports.buildTraceStats = buildTraceStats;
11564
+ exports.buildZipArchive = buildZipArchive;
9742
11565
  exports.bundleFailsOnSafety = bundleFailsOnSafety;
9743
11566
  exports.bundleRunAssetRelativePath = bundleRunAssetRelativePath;
11567
+ exports.collectTraceSchemaVersions = collectTraceSchemaVersions;
9744
11568
  exports.compareCohortAggregates = compareCohortAggregates;
9745
11569
  exports.createInspector = createInspector;
9746
11570
  exports.createInspectorRuntime = createInspectorRuntime;
@@ -9749,6 +11573,7 @@ exports.createStepId = createStepId;
9749
11573
  exports.defaultBundleOutputPath = defaultBundleOutputPath;
9750
11574
  exports.defaultSuiteConfigTemplate = defaultSuiteConfigTemplate;
9751
11575
  exports.deriveSessionStatus = deriveSessionStatus;
11576
+ exports.encodeEmbeddedEvidenceJson = encodeEmbeddedEvidenceJson;
9752
11577
  exports.enrichSessionRunRecord = enrichSessionRunRecord;
9753
11578
  exports.enrichSessionSummary = enrichSessionSummary;
9754
11579
  exports.ensureTraceDir = ensureTraceDir;
@@ -9758,6 +11583,7 @@ exports.extractOutcomesFromTraceEvents = extractOutcomesFromTraceEvents;
9758
11583
  exports.extractSessionWorkflowMetadata = extractSessionWorkflowMetadata;
9759
11584
  exports.filterMetasBySessionScope = filterMetasBySessionScope;
9760
11585
  exports.filterTraces = filterTraces;
11586
+ exports.findFirstCausalFailure = findFirstCausalFailure;
9761
11587
  exports.formatDuration = formatDuration2;
9762
11588
  exports.formatError = formatError;
9763
11589
  exports.formatTerminalName = formatTerminalName;
@@ -9779,9 +11605,11 @@ exports.getTraceFilePath = getTraceFilePath;
9779
11605
  exports.getTraceSafetyFromContext = getTraceSafetyFromContext;
9780
11606
  exports.groupSessionCohorts = groupSessionCohorts;
9781
11607
  exports.hasActiveContext = hasActiveContext;
11608
+ exports.inferEvidenceFileRole = inferEvidenceFileRole;
9782
11609
  exports.initializeTraceFile = initializeTraceFile;
9783
11610
  exports.isAgentInspectEnabled = isAgentInspectEnabled;
9784
11611
  exports.isAgentInspectTrace = isAgentInspectTrace;
11612
+ exports.isSha256Hex = isSha256Hex;
9785
11613
  exports.isSilentContext = isSilentContext;
9786
11614
  exports.isStepStatus = isStepStatus;
9787
11615
  exports.isStepType = isStepType;
@@ -9797,6 +11625,7 @@ exports.normalizeSuiteConfig = normalizeSuiteConfig;
9797
11625
  exports.parseCohortMetricList = parseCohortMetricList;
9798
11626
  exports.parseDuration = parseDuration;
9799
11627
  exports.parseDurationFilter = parseDurationFilter;
11628
+ exports.parseEvidenceManifestJson = parseEvidenceManifestJson;
9800
11629
  exports.parseGateList = parseGateList;
9801
11630
  exports.parseGateNumber = parseGateNumber;
9802
11631
  exports.parseGroupBySpec = parseGroupBySpec;
@@ -9840,13 +11669,18 @@ exports.runWithStepContext = runWithStepContext;
9840
11669
  exports.sanitizeBundleRunId = sanitizeBundleRunId;
9841
11670
  exports.searchTraces = searchTraces;
9842
11671
  exports.serializeEvent = serializeEvent;
11672
+ exports.serializeEvidenceManifest = serializeEvidenceManifest;
9843
11673
  exports.sessionKeyForRun = sessionKeyForRun;
11674
+ exports.sha256Equals = sha256Equals;
11675
+ exports.sha256Hex = sha256Hex;
9844
11676
  exports.toMetadataSafeStatus = toMetadataSafeStatus;
9845
11677
  exports.traceMetasToSessionRunRecords = traceMetasToSessionRunRecords;
9846
11678
  exports.truncateName = truncateName;
9847
11679
  exports.unknownTraceFormatMessage = unknownTraceFormatMessage;
9848
11680
  exports.validateEvent = validateEvent;
11681
+ exports.validateEvidenceManifest = validateEvidenceManifest;
9849
11682
  exports.validateSuiteConfig = validateSuiteConfig;
11683
+ exports.verifyEvidenceDirectory = verifyEvidenceDirectory;
9850
11684
  exports.warn = warn;
9851
11685
  exports.writeTraceEvent = writeTraceEvent;
9852
11686
  //# sourceMappingURL=advanced.cjs.map