agent-inspect 4.2.0 → 4.4.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 (97) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/docs/API.md +3 -0
  3. package/docs/CLI.md +36 -0
  4. package/docs/SCHEMA.md +27 -1
  5. package/package.json +1 -1
  6. package/packages/cli/dist/{chunk-5VSPJEZ7.mjs → chunk-ORHDQUT6.mjs} +385 -10
  7. package/packages/cli/dist/chunk-ORHDQUT6.mjs.map +1 -0
  8. package/packages/cli/dist/index.cjs +2548 -1567
  9. package/packages/cli/dist/index.cjs.map +1 -1
  10. package/packages/cli/dist/index.mjs +2028 -1495
  11. package/packages/cli/dist/index.mjs.map +1 -1
  12. package/packages/cli/dist/{src-VQT7QLGV.mjs → src-FJOHPC4X.mjs} +3 -3
  13. package/packages/cli/dist/{src-VQT7QLGV.mjs.map → src-FJOHPC4X.mjs.map} +1 -1
  14. package/packages/core/dist/advanced.cjs +397 -12
  15. package/packages/core/dist/advanced.cjs.map +1 -1
  16. package/packages/core/dist/advanced.d.cts +105 -9
  17. package/packages/core/dist/advanced.d.ts +105 -9
  18. package/packages/core/dist/advanced.mjs +219 -17
  19. package/packages/core/dist/advanced.mjs.map +1 -1
  20. package/packages/core/dist/checks.cjs +117 -18
  21. package/packages/core/dist/checks.cjs.map +1 -1
  22. package/packages/core/dist/checks.d.cts +11 -3
  23. package/packages/core/dist/checks.d.ts +11 -3
  24. package/packages/core/dist/checks.mjs +42 -1
  25. package/packages/core/dist/checks.mjs.map +1 -1
  26. package/packages/core/dist/{chunk-2ZXEMWGK.mjs → chunk-3USJVBLA.mjs} +3 -3
  27. package/packages/core/dist/{chunk-2ZXEMWGK.mjs.map → chunk-3USJVBLA.mjs.map} +1 -1
  28. package/packages/core/dist/{chunk-HY7H3CQM.mjs → chunk-CAWPF22J.mjs} +4 -3
  29. package/packages/core/dist/chunk-CAWPF22J.mjs.map +1 -0
  30. package/packages/core/dist/{chunk-XUNJMAPD.mjs → chunk-KNYL56KZ.mjs} +38 -3
  31. package/packages/core/dist/chunk-KNYL56KZ.mjs.map +1 -0
  32. package/packages/core/dist/{chunk-IZBJAZGF.mjs → chunk-P366CCL2.mjs} +34 -3
  33. package/packages/core/dist/chunk-P366CCL2.mjs.map +1 -0
  34. package/packages/core/dist/{chunk-4JVGFNQH.mjs → chunk-ULCGIRTC.mjs} +95 -8
  35. package/packages/core/dist/chunk-ULCGIRTC.mjs.map +1 -0
  36. package/packages/core/dist/chunk-VFO76UH3.mjs +228 -0
  37. package/packages/core/dist/chunk-VFO76UH3.mjs.map +1 -0
  38. package/packages/core/dist/{chunk-NQZPZ2FN.mjs → chunk-WRE4CNPF.mjs} +6 -3
  39. package/packages/core/dist/chunk-WRE4CNPF.mjs.map +1 -0
  40. package/packages/core/dist/{chunk-A4V2H3YU.mjs → chunk-ZWA5RWMV.mjs} +40 -4
  41. package/packages/core/dist/chunk-ZWA5RWMV.mjs.map +1 -0
  42. package/packages/core/dist/{context-DjY-jvQk.d.cts → context-BbfkMYjz.d.cts} +5 -3
  43. package/packages/core/dist/{context-BDZmi53V.d.ts → context-Cp8NRbBX.d.ts} +5 -3
  44. package/packages/core/dist/diff.cjs.map +1 -1
  45. package/packages/core/dist/diff.d.cts +3 -3
  46. package/packages/core/dist/diff.d.ts +3 -3
  47. package/packages/core/dist/diff.mjs +1 -1
  48. package/packages/core/dist/exporters.cjs +137 -1
  49. package/packages/core/dist/exporters.cjs.map +1 -1
  50. package/packages/core/dist/exporters.d.cts +6 -3
  51. package/packages/core/dist/exporters.d.ts +6 -3
  52. package/packages/core/dist/exporters.mjs +71 -6
  53. package/packages/core/dist/exporters.mjs.map +1 -1
  54. package/packages/core/dist/index.cjs +181 -6
  55. package/packages/core/dist/index.cjs.map +1 -1
  56. package/packages/core/dist/index.d.cts +14 -7
  57. package/packages/core/dist/index.d.ts +14 -7
  58. package/packages/core/dist/index.mjs +51 -7
  59. package/packages/core/dist/index.mjs.map +1 -1
  60. package/packages/core/dist/{inspect-event-CYAV7Hxm.d.cts → inspect-event-IqwOHbGo.d.cts} +1 -1
  61. package/packages/core/dist/{inspect-event-CYAV7Hxm.d.ts → inspect-event-IqwOHbGo.d.ts} +1 -1
  62. package/packages/core/dist/{log-config-BNQ9UTmP.d.cts → log-config-CW8w5YQ9.d.cts} +1 -1
  63. package/packages/core/dist/{log-config-D3Yp1SZN.d.ts → log-config-SRA4xTp8.d.ts} +1 -1
  64. package/packages/core/dist/logs.d.cts +3 -3
  65. package/packages/core/dist/logs.d.ts +3 -3
  66. package/packages/core/dist/{persisted-inspect-event-BLvb0jSX.d.ts → persisted-inspect-event-DruwqARZ.d.ts} +1 -1
  67. package/packages/core/dist/{persisted-inspect-event-D5SjBz9b.d.cts → persisted-inspect-event-Gd-W8vB7.d.cts} +1 -1
  68. package/packages/core/dist/persisted.cjs +67 -1
  69. package/packages/core/dist/persisted.cjs.map +1 -1
  70. package/packages/core/dist/persisted.d.cts +5 -5
  71. package/packages/core/dist/persisted.d.ts +5 -5
  72. package/packages/core/dist/persisted.mjs +3 -3
  73. package/packages/core/dist/readers.cjs +72 -3
  74. package/packages/core/dist/readers.cjs.map +1 -1
  75. package/packages/core/dist/readers.d.cts +2 -2
  76. package/packages/core/dist/readers.d.ts +2 -2
  77. package/packages/core/dist/readers.mjs +5 -5
  78. package/packages/core/dist/readers.mjs.map +1 -1
  79. package/packages/core/dist/{types-CQun9LW6.d.ts → types-B1X87dUW.d.cts} +16 -2
  80. package/packages/core/dist/{types-C-llnPH0.d.cts → types-BVkjSd0q.d.ts} +16 -2
  81. package/packages/core/dist/types-CvsKGweN.d.cts +12 -0
  82. package/packages/core/dist/types-CvsKGweN.d.ts +12 -0
  83. package/packages/core/dist/writers.cjs +2 -1
  84. package/packages/core/dist/writers.cjs.map +1 -1
  85. package/packages/core/dist/writers.d.cts +2 -2
  86. package/packages/core/dist/writers.d.ts +2 -2
  87. package/packages/core/dist/writers.mjs +3 -4
  88. package/packages/core/dist/writers.mjs.map +1 -1
  89. package/packages/cli/dist/chunk-5VSPJEZ7.mjs.map +0 -1
  90. package/packages/core/dist/chunk-4JVGFNQH.mjs.map +0 -1
  91. package/packages/core/dist/chunk-A4V2H3YU.mjs.map +0 -1
  92. package/packages/core/dist/chunk-EDTQHZPM.mjs +0 -88
  93. package/packages/core/dist/chunk-EDTQHZPM.mjs.map +0 -1
  94. package/packages/core/dist/chunk-HY7H3CQM.mjs.map +0 -1
  95. package/packages/core/dist/chunk-IZBJAZGF.mjs.map +0 -1
  96. package/packages/core/dist/chunk-NQZPZ2FN.mjs.map +0 -1
  97. package/packages/core/dist/chunk-XUNJMAPD.mjs.map +0 -1
@@ -1,13 +1,14 @@
1
- export { C as CreateInspectorOptions, D as DEFAULT_MAX_EVENT_BYTES, f as DEFAULT_MAX_METADATA_VALUE_LENGTH, h as DEFAULT_MAX_PREVIEW_LENGTH, I as Inspector, a as InspectorCaptureOptions, b as InspectorObserveOptions, c as InspectorRunOptions, i as InspectorRuntime, j as InspectorRuntimeContext, k as InspectorRuntimeDiagnostics, l as InspectorRuntimeOptions, d as InspectorStepOptions, T as TraceSafetyOptions, e as createInspector, n as createInspectorRuntime, o as getCurrentContext, g as getCurrentCorrelationMetadata, p as getCurrentDepth, q as getCurrentRunId, r as getCurrentRunName, s as getCurrentStepId, t as getParentStepId, u as getTraceDirFromContext, v as getTraceSafetyFromContext, w as hasActiveContext, x as isAgentInspectEnabled, y as isSilentContext, m as maybeInspectRun, z as prepareMetadataForDisk, A as prepareTraceEventForDisk, B as resolveTraceSafetyOptions, E as runWithContext, F as runWithStepContext } from './context-DjY-jvQk.cjs';
2
- import { R as RedactionProfile, E as ErrorInfo, b as RunStatus, e as StepStatus, h as TraceEvent, j as RunSummary, k as TraceMetadata, l as TraceMetadataStatus, f as StepType, g as TraceCorrelationMetadata } from './types-C-llnPH0.cjs';
3
- export { A as ActiveStepContext, i as ExecutionContext, I as InspectRunOptions, O as ObserveOptions, a as Run, m as RunCompletedEvent, n as RunStartedEvent, c as Step, o as StepCompletedEvent, d as StepMetadata, S as StepOptions, p as StepStartedEvent, T as TokenMetadata, q as TraceEventBase, r as TraceSchemaVersion, s as isStepStatus, t as isStepType, u as isTraceEvent } from './types-C-llnPH0.cjs';
4
- import { b as InspectRunTree } from './inspect-event-CYAV7Hxm.cjs';
5
- export { A as AttributionConfidence, E as EventSource, a as InspectEvent, I as InspectKind, c as InspectNode } from './inspect-event-CYAV7Hxm.cjs';
6
- import { P as PersistedInspectEvent } from './persisted-inspect-event-D5SjBz9b.cjs';
1
+ export { C as CreateInspectorOptions, D as DEFAULT_MAX_EVENT_BYTES, f as DEFAULT_MAX_METADATA_VALUE_LENGTH, h as DEFAULT_MAX_PREVIEW_LENGTH, I as Inspector, a as InspectorCaptureOptions, b as InspectorObserveOptions, c as InspectorRunOptions, i as InspectorRuntime, j as InspectorRuntimeContext, k as InspectorRuntimeDiagnostics, l as InspectorRuntimeOptions, d as InspectorStepOptions, T as TraceSafetyOptions, e as createInspector, n as createInspectorRuntime, o as getCurrentContext, g as getCurrentCorrelationMetadata, p as getCurrentDepth, q as getCurrentRunId, r as getCurrentRunName, s as getCurrentStepId, t as getParentStepId, u as getTraceDirFromContext, v as getTraceSafetyFromContext, w as hasActiveContext, x as isAgentInspectEnabled, y as isSilentContext, m as maybeInspectRun, z as prepareMetadataForDisk, A as prepareTraceEventForDisk, B as resolveTraceSafetyOptions, E as runWithContext, F as runWithStepContext } from './context-BbfkMYjz.cjs';
2
+ import { R as RedactionProfile, E as ErrorInfo, b as RunStatus, e as StepStatus, h as TraceEvent, j as RunSummary, k as TraceMetadata, l as TraceMetadataStatus, f as StepType, g as TraceCorrelationMetadata } from './types-B1X87dUW.cjs';
3
+ export { A as ActiveStepContext, i as ExecutionContext, I as InspectRunOptions, O as ObserveOptions, a as Run, m as RunCompletedEvent, n as RunStartedEvent, c as Step, o as StepCompletedEvent, d as StepMetadata, S as StepOptions, p as StepStartedEvent, T as TokenMetadata, q as TraceEventBase, r as TraceSchemaVersion, s as isStepStatus, t as isStepType, u as isTraceEvent } from './types-B1X87dUW.cjs';
4
+ import { b as InspectRunTree } from './inspect-event-IqwOHbGo.cjs';
5
+ export { A as AttributionConfidence, E as EventSource, a as InspectEvent, I as InspectKind, c as InspectNode } from './inspect-event-IqwOHbGo.cjs';
6
+ import { P as PersistedInspectEvent } from './persisted-inspect-event-Gd-W8vB7.cjs';
7
7
  import { Stats } from 'node:fs';
8
8
  import { TraceCheckResult, TraceCheckStatus } from './checks.cjs';
9
9
  import './writers.cjs';
10
- import './log-config-BNQ9UTmP.cjs';
10
+ import './types-CvsKGweN.cjs';
11
+ import './log-config-CW8w5YQ9.cjs';
11
12
  import './readers.cjs';
12
13
 
13
14
  interface ResolvedRedactionProfile {
@@ -369,6 +370,7 @@ interface TraceSearchOptions {
369
370
  limit?: number;
370
371
  session?: string;
371
372
  correlateGroup?: boolean;
373
+ observation?: string;
372
374
  }
373
375
  interface TraceSearchResult {
374
376
  runId: string;
@@ -563,7 +565,9 @@ declare function enrichSessionSummary(summary: Omit<SessionSummary, "status" | "
563
565
  */
564
566
  declare function buildActivitySummary(index: SessionIndex, options?: BuildActivitySummaryOptions): ActivitySummary;
565
567
  /** Renders a human activity summary for terminal output. */
566
- declare function renderActivitySummaryHuman(summary: ActivitySummary): string;
568
+ declare function renderActivitySummaryHuman(summary: ActivitySummary, options?: {
569
+ nowMs?: number;
570
+ }): string;
567
571
 
568
572
  /** Enriches trace metadata with run_started metadata for session indexing. */
569
573
  declare function enrichSessionRunRecord(meta: TraceMetadata): Promise<SessionRunRecord>;
@@ -643,4 +647,96 @@ declare function isAgentInspectTrace(filePath: string): Promise<boolean>;
643
647
  */
644
648
  declare function parseDuration(duration: string): number;
645
649
 
646
- export { type ActivityEntry, type ActivitySummary, type BuildActivitySummaryOptions, type BuildSessionIndexOptions, type CriticalPathStep, DEFAULT_TRACE_DIR_NAME, type DurationStats, type EnrichSessionSummaryOptions, ErrorInfo, type ExplainFact, type ExplainInference, type ExplainMode, type ExplainOptions, type ExplainResult, FALLBACK_TRACE_DIR, type GroupSessionCohortsOptions, type HandoffEdge, InspectRunTree, MAX_NAME_LENGTH, MAX_TERMINAL_DEPTH, MAX_TERMINAL_NAME_LENGTH, type ParseTraceJsonlOptions, type ParseTraceJsonlResult, type ParsedDurationFilter, RUNS_DIR_NAME, RedactionProfile, type RenderTimelineOptions, type RenderWhatOptions, type ResolvedRedactionProfile, type RetryLink, RunStatus, RunSummary, type RunTimeline, type RunWhatSummary, SESSION_WORKFLOW_KEYS, type SessionCheckSummary, type SessionCohort, type SessionCohortKind, type SessionConfidence, type SessionEdgeSource, type SessionGroup, type SessionIndex, type SessionLastError, type SessionRunRecord, type SessionScopeOptions, type SessionScopeResult, type SessionStatus, type SessionSummary, type SessionWarning, type SessionWorkflowKey, type SessionWorkflowMetadata, StepStatus, StepType, TERMINAL_INDENT, type TimelineEntry, type TimelineFocus, type TimelineOptions, TraceCorrelationMetadata, TraceDirectory, type TraceDirectoryOptions, TraceEvent, type TraceFilterOptions, type TraceJsonlFormat, TraceMetadata, TraceMetadataStatus, type TraceSearchOptions, type TraceSearchResult, type TraceSessionCheckResult, type TraceStats, type TraceStatsOptions, type TraceStatsRankedRun, type TraceStatsRankedStep, aggregateSessionCheckResults, buildActivitySummary, buildLocalExplanation, buildRunSummary, buildRunTimeline, buildRunWhatSummary, buildSessionIndex, buildTraceStats, createRunId, createStepId, deriveSessionStatus, enrichSessionRunRecord, enrichSessionSummary, ensureTraceDir, extractMetadata, extractSessionWorkflowMetadata, filterMetasBySessionScope, filterTraces, formatDuration, formatError, formatTerminalName, formatTimestamp, getDefaultTraceDir, getIndent, getRunIdFromTraceFileName, getTraceFilePath, groupSessionCohorts, initializeTraceFile, isAgentInspectTrace, listTraceFiles, loadSessionRunRecords, loadTraceMetadataList, parseDuration, parseDurationFilter, parseTraceJsonl, printError, printFailedAt, printRunComplete, printRunStart, printStepComplete, printStepStart, readTraceEvents, readTraceFile, renderActivitySummaryHuman, renderErrorLine, renderRunSummary, renderRunWhat, renderStepLine, renderTimeline, renderTraceStats, resolveRedactionProfile, resolveTraceDir, searchTraces, serializeEvent, sessionKeyForRun, traceMetasToSessionRunRecords, truncateName, unknownTraceFormatMessage, validateEvent, warn, writeTraceEvent };
650
+ /** Aggregate verify-safe status for a bundle. */
651
+ type BundleSafeStatus = "SAFE" | "SAFE WITH WARNINGS" | "UNSAFE" | "UNKNOWN";
652
+ /** Metadata-safe status (underscore form). */
653
+ type BundleSafeStatusMetadata = "SAFE" | "SAFE_WITH_WARNINGS" | "UNSAFE" | "UNKNOWN";
654
+ type BundleRedactionProfile = "local" | "share" | "strict";
655
+ interface BundleMetadata {
656
+ createdAt: string;
657
+ agentInspectVersion: string;
658
+ redactionProfile: BundleRedactionProfile;
659
+ sourceTraceCount: number;
660
+ runIds: string[];
661
+ safeStatus: BundleSafeStatusMetadata;
662
+ files: string[];
663
+ note: string;
664
+ sessionId?: string;
665
+ since?: string;
666
+ }
667
+ interface BundleRedactionReportRun {
668
+ runId: string;
669
+ findings: number;
670
+ detectors: string[];
671
+ }
672
+ interface BundleRedactionReport {
673
+ profile: BundleRedactionProfile;
674
+ totalFindings: number;
675
+ runs: BundleRedactionReportRun[];
676
+ }
677
+ interface BundleCheckRunResult {
678
+ runId: string;
679
+ status: BundleSafeStatus;
680
+ errors: number;
681
+ warnings: number;
682
+ findings: number;
683
+ }
684
+ interface BundleCheckResults {
685
+ aggregateStatus: BundleSafeStatus;
686
+ runs: BundleCheckRunResult[];
687
+ }
688
+ interface BundleResolveOptions {
689
+ runId?: string;
690
+ sessionId?: string;
691
+ since?: string;
692
+ }
693
+ interface BundleResolveResult {
694
+ runIds: string[];
695
+ sessionId?: string;
696
+ since?: string;
697
+ }
698
+ interface BundlePlaceholderArtifact {
699
+ status: "not_requested";
700
+ note: string;
701
+ }
702
+
703
+ /**
704
+ * Resolves which run ids belong in a bundle.
705
+ *
706
+ * @throws when target mode is missing, ambiguous, or yields zero runs.
707
+ */
708
+ declare function resolveBundleRunIds(index: SessionIndex, runs: readonly SessionRunRecord[], options: BundleResolveOptions): BundleResolveResult;
709
+
710
+ declare function buildBundleMetadata(parts: {
711
+ agentInspectVersion: string;
712
+ profile: BundleRedactionProfile;
713
+ resolve: BundleResolveResult;
714
+ checks: BundleCheckResults;
715
+ files: string[];
716
+ createdAt?: string;
717
+ }): BundleMetadata;
718
+ declare function buildPlaceholderArtifact(): BundlePlaceholderArtifact;
719
+
720
+ /**
721
+ * Builds a human-readable bundle summary for `summary.md`.
722
+ */
723
+ declare function buildBundleSummaryMarkdown(parts: {
724
+ metadata: BundleMetadata;
725
+ checks: BundleCheckResults;
726
+ redaction: BundleRedactionReport;
727
+ }): string;
728
+
729
+ declare function aggregateBundleSafeStatus(statuses: readonly BundleSafeStatus[]): BundleSafeStatus;
730
+ declare function toMetadataSafeStatus(status: BundleSafeStatus): BundleSafeStatusMetadata;
731
+ declare function bundleFailsOnSafety(status: BundleSafeStatus, allowUnsafe: boolean): boolean;
732
+
733
+ /**
734
+ * Normalizes bundle output path. Strips a `.zip` suffix (folder-first MVP).
735
+ */
736
+ declare function normalizeBundleOutputPath(out: string): string;
737
+ /**
738
+ * Default bundle directory when --out is omitted.
739
+ */
740
+ declare function defaultBundleOutputPath(runIds: readonly string[]): string;
741
+
742
+ export { type ActivityEntry, type ActivitySummary, type BuildActivitySummaryOptions, type BuildSessionIndexOptions, type BundleCheckResults, type BundleCheckRunResult, type BundleMetadata, type BundlePlaceholderArtifact, type BundleRedactionProfile, type BundleRedactionReport, type BundleRedactionReportRun, type BundleResolveOptions, type BundleResolveResult, type BundleSafeStatus, type BundleSafeStatusMetadata, type CriticalPathStep, DEFAULT_TRACE_DIR_NAME, type DurationStats, type EnrichSessionSummaryOptions, ErrorInfo, type ExplainFact, type ExplainInference, type ExplainMode, type ExplainOptions, type ExplainResult, FALLBACK_TRACE_DIR, type GroupSessionCohortsOptions, type HandoffEdge, InspectRunTree, MAX_NAME_LENGTH, MAX_TERMINAL_DEPTH, MAX_TERMINAL_NAME_LENGTH, type ParseTraceJsonlOptions, type ParseTraceJsonlResult, type ParsedDurationFilter, RUNS_DIR_NAME, RedactionProfile, type RenderTimelineOptions, type RenderWhatOptions, type ResolvedRedactionProfile, type RetryLink, RunStatus, RunSummary, type RunTimeline, type RunWhatSummary, SESSION_WORKFLOW_KEYS, type SessionCheckSummary, type SessionCohort, type SessionCohortKind, type SessionConfidence, type SessionEdgeSource, type SessionGroup, type SessionIndex, type SessionLastError, type SessionRunRecord, type SessionScopeOptions, type SessionScopeResult, type SessionStatus, type SessionSummary, type SessionWarning, type SessionWorkflowKey, type SessionWorkflowMetadata, StepStatus, StepType, TERMINAL_INDENT, type TimelineEntry, type TimelineFocus, type TimelineOptions, TraceCorrelationMetadata, TraceDirectory, type TraceDirectoryOptions, TraceEvent, type TraceFilterOptions, type TraceJsonlFormat, TraceMetadata, TraceMetadataStatus, type TraceSearchOptions, type TraceSearchResult, type TraceSessionCheckResult, type TraceStats, type TraceStatsOptions, type TraceStatsRankedRun, type TraceStatsRankedStep, aggregateBundleSafeStatus, aggregateSessionCheckResults, buildActivitySummary, buildBundleMetadata, buildBundleSummaryMarkdown, buildLocalExplanation, buildPlaceholderArtifact, buildRunSummary, buildRunTimeline, buildRunWhatSummary, buildSessionIndex, buildTraceStats, bundleFailsOnSafety, createRunId, createStepId, defaultBundleOutputPath, deriveSessionStatus, enrichSessionRunRecord, enrichSessionSummary, ensureTraceDir, extractMetadata, extractSessionWorkflowMetadata, filterMetasBySessionScope, filterTraces, formatDuration, formatError, formatTerminalName, formatTimestamp, getDefaultTraceDir, getIndent, getRunIdFromTraceFileName, getTraceFilePath, groupSessionCohorts, initializeTraceFile, isAgentInspectTrace, listTraceFiles, loadSessionRunRecords, loadTraceMetadataList, normalizeBundleOutputPath, parseDuration, parseDurationFilter, parseTraceJsonl, printError, printFailedAt, printRunComplete, printRunStart, printStepComplete, printStepStart, readTraceEvents, readTraceFile, renderActivitySummaryHuman, renderErrorLine, renderRunSummary, renderRunWhat, renderStepLine, renderTimeline, renderTraceStats, resolveBundleRunIds, resolveRedactionProfile, resolveTraceDir, searchTraces, serializeEvent, sessionKeyForRun, toMetadataSafeStatus, traceMetasToSessionRunRecords, truncateName, unknownTraceFormatMessage, validateEvent, warn, writeTraceEvent };
@@ -1,13 +1,14 @@
1
- export { C as CreateInspectorOptions, D as DEFAULT_MAX_EVENT_BYTES, f as DEFAULT_MAX_METADATA_VALUE_LENGTH, h as DEFAULT_MAX_PREVIEW_LENGTH, I as Inspector, a as InspectorCaptureOptions, b as InspectorObserveOptions, c as InspectorRunOptions, i as InspectorRuntime, j as InspectorRuntimeContext, k as InspectorRuntimeDiagnostics, l as InspectorRuntimeOptions, d as InspectorStepOptions, T as TraceSafetyOptions, e as createInspector, n as createInspectorRuntime, o as getCurrentContext, g as getCurrentCorrelationMetadata, p as getCurrentDepth, q as getCurrentRunId, r as getCurrentRunName, s as getCurrentStepId, t as getParentStepId, u as getTraceDirFromContext, v as getTraceSafetyFromContext, w as hasActiveContext, x as isAgentInspectEnabled, y as isSilentContext, m as maybeInspectRun, z as prepareMetadataForDisk, A as prepareTraceEventForDisk, B as resolveTraceSafetyOptions, E as runWithContext, F as runWithStepContext } from './context-BDZmi53V.js';
2
- import { R as RedactionProfile, E as ErrorInfo, b as RunStatus, e as StepStatus, h as TraceEvent, j as RunSummary, k as TraceMetadata, l as TraceMetadataStatus, f as StepType, g as TraceCorrelationMetadata } from './types-CQun9LW6.js';
3
- export { A as ActiveStepContext, i as ExecutionContext, I as InspectRunOptions, O as ObserveOptions, a as Run, m as RunCompletedEvent, n as RunStartedEvent, c as Step, o as StepCompletedEvent, d as StepMetadata, S as StepOptions, p as StepStartedEvent, T as TokenMetadata, q as TraceEventBase, r as TraceSchemaVersion, s as isStepStatus, t as isStepType, u as isTraceEvent } from './types-CQun9LW6.js';
4
- import { b as InspectRunTree } from './inspect-event-CYAV7Hxm.js';
5
- export { A as AttributionConfidence, E as EventSource, a as InspectEvent, I as InspectKind, c as InspectNode } from './inspect-event-CYAV7Hxm.js';
6
- import { P as PersistedInspectEvent } from './persisted-inspect-event-BLvb0jSX.js';
1
+ export { C as CreateInspectorOptions, D as DEFAULT_MAX_EVENT_BYTES, f as DEFAULT_MAX_METADATA_VALUE_LENGTH, h as DEFAULT_MAX_PREVIEW_LENGTH, I as Inspector, a as InspectorCaptureOptions, b as InspectorObserveOptions, c as InspectorRunOptions, i as InspectorRuntime, j as InspectorRuntimeContext, k as InspectorRuntimeDiagnostics, l as InspectorRuntimeOptions, d as InspectorStepOptions, T as TraceSafetyOptions, e as createInspector, n as createInspectorRuntime, o as getCurrentContext, g as getCurrentCorrelationMetadata, p as getCurrentDepth, q as getCurrentRunId, r as getCurrentRunName, s as getCurrentStepId, t as getParentStepId, u as getTraceDirFromContext, v as getTraceSafetyFromContext, w as hasActiveContext, x as isAgentInspectEnabled, y as isSilentContext, m as maybeInspectRun, z as prepareMetadataForDisk, A as prepareTraceEventForDisk, B as resolveTraceSafetyOptions, E as runWithContext, F as runWithStepContext } from './context-Cp8NRbBX.js';
2
+ import { R as RedactionProfile, E as ErrorInfo, b as RunStatus, e as StepStatus, h as TraceEvent, j as RunSummary, k as TraceMetadata, l as TraceMetadataStatus, f as StepType, g as TraceCorrelationMetadata } from './types-BVkjSd0q.js';
3
+ export { A as ActiveStepContext, i as ExecutionContext, I as InspectRunOptions, O as ObserveOptions, a as Run, m as RunCompletedEvent, n as RunStartedEvent, c as Step, o as StepCompletedEvent, d as StepMetadata, S as StepOptions, p as StepStartedEvent, T as TokenMetadata, q as TraceEventBase, r as TraceSchemaVersion, s as isStepStatus, t as isStepType, u as isTraceEvent } from './types-BVkjSd0q.js';
4
+ import { b as InspectRunTree } from './inspect-event-IqwOHbGo.js';
5
+ export { A as AttributionConfidence, E as EventSource, a as InspectEvent, I as InspectKind, c as InspectNode } from './inspect-event-IqwOHbGo.js';
6
+ import { P as PersistedInspectEvent } from './persisted-inspect-event-DruwqARZ.js';
7
7
  import { Stats } from 'node:fs';
8
8
  import { TraceCheckResult, TraceCheckStatus } from './checks.js';
9
9
  import './writers.js';
10
- import './log-config-D3Yp1SZN.js';
10
+ import './types-CvsKGweN.js';
11
+ import './log-config-SRA4xTp8.js';
11
12
  import './readers.js';
12
13
 
13
14
  interface ResolvedRedactionProfile {
@@ -369,6 +370,7 @@ interface TraceSearchOptions {
369
370
  limit?: number;
370
371
  session?: string;
371
372
  correlateGroup?: boolean;
373
+ observation?: string;
372
374
  }
373
375
  interface TraceSearchResult {
374
376
  runId: string;
@@ -563,7 +565,9 @@ declare function enrichSessionSummary(summary: Omit<SessionSummary, "status" | "
563
565
  */
564
566
  declare function buildActivitySummary(index: SessionIndex, options?: BuildActivitySummaryOptions): ActivitySummary;
565
567
  /** Renders a human activity summary for terminal output. */
566
- declare function renderActivitySummaryHuman(summary: ActivitySummary): string;
568
+ declare function renderActivitySummaryHuman(summary: ActivitySummary, options?: {
569
+ nowMs?: number;
570
+ }): string;
567
571
 
568
572
  /** Enriches trace metadata with run_started metadata for session indexing. */
569
573
  declare function enrichSessionRunRecord(meta: TraceMetadata): Promise<SessionRunRecord>;
@@ -643,4 +647,96 @@ declare function isAgentInspectTrace(filePath: string): Promise<boolean>;
643
647
  */
644
648
  declare function parseDuration(duration: string): number;
645
649
 
646
- export { type ActivityEntry, type ActivitySummary, type BuildActivitySummaryOptions, type BuildSessionIndexOptions, type CriticalPathStep, DEFAULT_TRACE_DIR_NAME, type DurationStats, type EnrichSessionSummaryOptions, ErrorInfo, type ExplainFact, type ExplainInference, type ExplainMode, type ExplainOptions, type ExplainResult, FALLBACK_TRACE_DIR, type GroupSessionCohortsOptions, type HandoffEdge, InspectRunTree, MAX_NAME_LENGTH, MAX_TERMINAL_DEPTH, MAX_TERMINAL_NAME_LENGTH, type ParseTraceJsonlOptions, type ParseTraceJsonlResult, type ParsedDurationFilter, RUNS_DIR_NAME, RedactionProfile, type RenderTimelineOptions, type RenderWhatOptions, type ResolvedRedactionProfile, type RetryLink, RunStatus, RunSummary, type RunTimeline, type RunWhatSummary, SESSION_WORKFLOW_KEYS, type SessionCheckSummary, type SessionCohort, type SessionCohortKind, type SessionConfidence, type SessionEdgeSource, type SessionGroup, type SessionIndex, type SessionLastError, type SessionRunRecord, type SessionScopeOptions, type SessionScopeResult, type SessionStatus, type SessionSummary, type SessionWarning, type SessionWorkflowKey, type SessionWorkflowMetadata, StepStatus, StepType, TERMINAL_INDENT, type TimelineEntry, type TimelineFocus, type TimelineOptions, TraceCorrelationMetadata, TraceDirectory, type TraceDirectoryOptions, TraceEvent, type TraceFilterOptions, type TraceJsonlFormat, TraceMetadata, TraceMetadataStatus, type TraceSearchOptions, type TraceSearchResult, type TraceSessionCheckResult, type TraceStats, type TraceStatsOptions, type TraceStatsRankedRun, type TraceStatsRankedStep, aggregateSessionCheckResults, buildActivitySummary, buildLocalExplanation, buildRunSummary, buildRunTimeline, buildRunWhatSummary, buildSessionIndex, buildTraceStats, createRunId, createStepId, deriveSessionStatus, enrichSessionRunRecord, enrichSessionSummary, ensureTraceDir, extractMetadata, extractSessionWorkflowMetadata, filterMetasBySessionScope, filterTraces, formatDuration, formatError, formatTerminalName, formatTimestamp, getDefaultTraceDir, getIndent, getRunIdFromTraceFileName, getTraceFilePath, groupSessionCohorts, initializeTraceFile, isAgentInspectTrace, listTraceFiles, loadSessionRunRecords, loadTraceMetadataList, parseDuration, parseDurationFilter, parseTraceJsonl, printError, printFailedAt, printRunComplete, printRunStart, printStepComplete, printStepStart, readTraceEvents, readTraceFile, renderActivitySummaryHuman, renderErrorLine, renderRunSummary, renderRunWhat, renderStepLine, renderTimeline, renderTraceStats, resolveRedactionProfile, resolveTraceDir, searchTraces, serializeEvent, sessionKeyForRun, traceMetasToSessionRunRecords, truncateName, unknownTraceFormatMessage, validateEvent, warn, writeTraceEvent };
650
+ /** Aggregate verify-safe status for a bundle. */
651
+ type BundleSafeStatus = "SAFE" | "SAFE WITH WARNINGS" | "UNSAFE" | "UNKNOWN";
652
+ /** Metadata-safe status (underscore form). */
653
+ type BundleSafeStatusMetadata = "SAFE" | "SAFE_WITH_WARNINGS" | "UNSAFE" | "UNKNOWN";
654
+ type BundleRedactionProfile = "local" | "share" | "strict";
655
+ interface BundleMetadata {
656
+ createdAt: string;
657
+ agentInspectVersion: string;
658
+ redactionProfile: BundleRedactionProfile;
659
+ sourceTraceCount: number;
660
+ runIds: string[];
661
+ safeStatus: BundleSafeStatusMetadata;
662
+ files: string[];
663
+ note: string;
664
+ sessionId?: string;
665
+ since?: string;
666
+ }
667
+ interface BundleRedactionReportRun {
668
+ runId: string;
669
+ findings: number;
670
+ detectors: string[];
671
+ }
672
+ interface BundleRedactionReport {
673
+ profile: BundleRedactionProfile;
674
+ totalFindings: number;
675
+ runs: BundleRedactionReportRun[];
676
+ }
677
+ interface BundleCheckRunResult {
678
+ runId: string;
679
+ status: BundleSafeStatus;
680
+ errors: number;
681
+ warnings: number;
682
+ findings: number;
683
+ }
684
+ interface BundleCheckResults {
685
+ aggregateStatus: BundleSafeStatus;
686
+ runs: BundleCheckRunResult[];
687
+ }
688
+ interface BundleResolveOptions {
689
+ runId?: string;
690
+ sessionId?: string;
691
+ since?: string;
692
+ }
693
+ interface BundleResolveResult {
694
+ runIds: string[];
695
+ sessionId?: string;
696
+ since?: string;
697
+ }
698
+ interface BundlePlaceholderArtifact {
699
+ status: "not_requested";
700
+ note: string;
701
+ }
702
+
703
+ /**
704
+ * Resolves which run ids belong in a bundle.
705
+ *
706
+ * @throws when target mode is missing, ambiguous, or yields zero runs.
707
+ */
708
+ declare function resolveBundleRunIds(index: SessionIndex, runs: readonly SessionRunRecord[], options: BundleResolveOptions): BundleResolveResult;
709
+
710
+ declare function buildBundleMetadata(parts: {
711
+ agentInspectVersion: string;
712
+ profile: BundleRedactionProfile;
713
+ resolve: BundleResolveResult;
714
+ checks: BundleCheckResults;
715
+ files: string[];
716
+ createdAt?: string;
717
+ }): BundleMetadata;
718
+ declare function buildPlaceholderArtifact(): BundlePlaceholderArtifact;
719
+
720
+ /**
721
+ * Builds a human-readable bundle summary for `summary.md`.
722
+ */
723
+ declare function buildBundleSummaryMarkdown(parts: {
724
+ metadata: BundleMetadata;
725
+ checks: BundleCheckResults;
726
+ redaction: BundleRedactionReport;
727
+ }): string;
728
+
729
+ declare function aggregateBundleSafeStatus(statuses: readonly BundleSafeStatus[]): BundleSafeStatus;
730
+ declare function toMetadataSafeStatus(status: BundleSafeStatus): BundleSafeStatusMetadata;
731
+ declare function bundleFailsOnSafety(status: BundleSafeStatus, allowUnsafe: boolean): boolean;
732
+
733
+ /**
734
+ * Normalizes bundle output path. Strips a `.zip` suffix (folder-first MVP).
735
+ */
736
+ declare function normalizeBundleOutputPath(out: string): string;
737
+ /**
738
+ * Default bundle directory when --out is omitted.
739
+ */
740
+ declare function defaultBundleOutputPath(runIds: readonly string[]): string;
741
+
742
+ export { type ActivityEntry, type ActivitySummary, type BuildActivitySummaryOptions, type BuildSessionIndexOptions, type BundleCheckResults, type BundleCheckRunResult, type BundleMetadata, type BundlePlaceholderArtifact, type BundleRedactionProfile, type BundleRedactionReport, type BundleRedactionReportRun, type BundleResolveOptions, type BundleResolveResult, type BundleSafeStatus, type BundleSafeStatusMetadata, type CriticalPathStep, DEFAULT_TRACE_DIR_NAME, type DurationStats, type EnrichSessionSummaryOptions, ErrorInfo, type ExplainFact, type ExplainInference, type ExplainMode, type ExplainOptions, type ExplainResult, FALLBACK_TRACE_DIR, type GroupSessionCohortsOptions, type HandoffEdge, InspectRunTree, MAX_NAME_LENGTH, MAX_TERMINAL_DEPTH, MAX_TERMINAL_NAME_LENGTH, type ParseTraceJsonlOptions, type ParseTraceJsonlResult, type ParsedDurationFilter, RUNS_DIR_NAME, RedactionProfile, type RenderTimelineOptions, type RenderWhatOptions, type ResolvedRedactionProfile, type RetryLink, RunStatus, RunSummary, type RunTimeline, type RunWhatSummary, SESSION_WORKFLOW_KEYS, type SessionCheckSummary, type SessionCohort, type SessionCohortKind, type SessionConfidence, type SessionEdgeSource, type SessionGroup, type SessionIndex, type SessionLastError, type SessionRunRecord, type SessionScopeOptions, type SessionScopeResult, type SessionStatus, type SessionSummary, type SessionWarning, type SessionWorkflowKey, type SessionWorkflowMetadata, StepStatus, StepType, TERMINAL_INDENT, type TimelineEntry, type TimelineFocus, type TimelineOptions, TraceCorrelationMetadata, TraceDirectory, type TraceDirectoryOptions, TraceEvent, type TraceFilterOptions, type TraceJsonlFormat, TraceMetadata, TraceMetadataStatus, type TraceSearchOptions, type TraceSearchResult, type TraceSessionCheckResult, type TraceStats, type TraceStatsOptions, type TraceStatsRankedRun, type TraceStatsRankedStep, aggregateBundleSafeStatus, aggregateSessionCheckResults, buildActivitySummary, buildBundleMetadata, buildBundleSummaryMarkdown, buildLocalExplanation, buildPlaceholderArtifact, buildRunSummary, buildRunTimeline, buildRunWhatSummary, buildSessionIndex, buildTraceStats, bundleFailsOnSafety, createRunId, createStepId, defaultBundleOutputPath, deriveSessionStatus, enrichSessionRunRecord, enrichSessionSummary, ensureTraceDir, extractMetadata, extractSessionWorkflowMetadata, filterMetasBySessionScope, filterTraces, formatDuration, formatError, formatTerminalName, formatTimestamp, getDefaultTraceDir, getIndent, getRunIdFromTraceFileName, getTraceFilePath, groupSessionCohorts, initializeTraceFile, isAgentInspectTrace, listTraceFiles, loadSessionRunRecords, loadTraceMetadataList, normalizeBundleOutputPath, parseDuration, parseDurationFilter, parseTraceJsonl, printError, printFailedAt, printRunComplete, printRunStart, printStepComplete, printStepStart, readTraceEvents, readTraceFile, renderActivitySummaryHuman, renderErrorLine, renderRunSummary, renderRunWhat, renderStepLine, renderTimeline, renderTraceStats, resolveBundleRunIds, resolveRedactionProfile, resolveTraceDir, searchTraces, serializeEvent, sessionKeyForRun, toMetadataSafeStatus, traceMetasToSessionRunRecords, truncateName, unknownTraceFormatMessage, validateEvent, warn, writeTraceEvent };
@@ -1,19 +1,19 @@
1
- export { MAX_TERMINAL_DEPTH, MAX_TERMINAL_NAME_LENGTH, TERMINAL_INDENT, TraceDirectory, createInspector, createInspectorRuntime, formatTerminalName, getCurrentContext, getCurrentCorrelationMetadata, getCurrentDepth, getCurrentRunId, getCurrentRunName, getCurrentStepId, getIndent, getParentStepId, getTraceDirFromContext, getTraceSafetyFromContext, hasActiveContext, isAgentInspectEnabled, isSilentContext, maybeInspectRun, printError, printFailedAt, printRunComplete, printRunStart, printStepComplete, printStepStart, renderErrorLine, renderRunSummary, renderStepLine, resolveTraceDir, runWithContext, runWithStepContext } from './chunk-A4V2H3YU.mjs';
2
- import { buildRunSummary, extractMetadata } from './chunk-2ZXEMWGK.mjs';
3
- export { buildRunSummary, buildRunTimeline, buildRunWhatSummary, extractMetadata, renderRunWhat, renderTimeline } from './chunk-2ZXEMWGK.mjs';
1
+ export { MAX_TERMINAL_DEPTH, MAX_TERMINAL_NAME_LENGTH, TERMINAL_INDENT, TraceDirectory, createInspector, createInspectorRuntime, formatTerminalName, getCurrentContext, getCurrentCorrelationMetadata, getCurrentDepth, getCurrentRunId, getCurrentRunName, getCurrentStepId, getIndent, getParentStepId, getTraceDirFromContext, getTraceSafetyFromContext, hasActiveContext, isAgentInspectEnabled, isSilentContext, maybeInspectRun, printError, printFailedAt, printRunComplete, printRunStart, printStepComplete, printStepStart, renderErrorLine, renderRunSummary, renderStepLine, resolveTraceDir, runWithContext, runWithStepContext } from './chunk-ZWA5RWMV.mjs';
2
+ import { buildRunSummary, extractMetadata } from './chunk-3USJVBLA.mjs';
3
+ export { buildRunSummary, buildRunTimeline, buildRunWhatSummary, extractMetadata, renderRunWhat, renderTimeline } from './chunk-3USJVBLA.mjs';
4
+ import { parseObservationFilter, extractOutcomesFromTraceEvents } from './chunk-VFO76UH3.mjs';
4
5
  import './chunk-BT7CATSD.mjs';
5
- import { readTraceEventsFromFile } from './chunk-4JVGFNQH.mjs';
6
- export { DEFAULT_MAX_EVENT_BYTES, DEFAULT_MAX_METADATA_VALUE_LENGTH, DEFAULT_MAX_PREVIEW_LENGTH, getRunIdFromTraceFileName, initializeTraceFile, listTraceFiles, prepareMetadataForDisk, prepareTraceEventForDisk, readTraceEvents, readTraceFile, resolveTraceSafetyOptions, serializeEvent, validateEvent, writeTraceEvent } from './chunk-4JVGFNQH.mjs';
7
- import { resolveRedactionProfile } from './chunk-EDTQHZPM.mjs';
8
- export { resolveRedactionProfile } from './chunk-EDTQHZPM.mjs';
6
+ import { resolveRedactionProfile, readTraceEventsFromFile } from './chunk-ULCGIRTC.mjs';
7
+ export { DEFAULT_MAX_EVENT_BYTES, DEFAULT_MAX_METADATA_VALUE_LENGTH, DEFAULT_MAX_PREVIEW_LENGTH, getRunIdFromTraceFileName, initializeTraceFile, listTraceFiles, prepareMetadataForDisk, prepareTraceEventForDisk, readTraceEvents, readTraceFile, resolveRedactionProfile, resolveTraceSafetyOptions, serializeEvent, validateEvent, writeTraceEvent } from './chunk-ULCGIRTC.mjs';
9
8
  import { Redactor } from './chunk-VU6O5QAH.mjs';
10
9
  import './chunk-S4YWKV4G.mjs';
11
- import { parseDuration, formatDuration, isTraceEvent } from './chunk-NQZPZ2FN.mjs';
12
- export { DEFAULT_TRACE_DIR_NAME, FALLBACK_TRACE_DIR, MAX_NAME_LENGTH, RUNS_DIR_NAME, createRunId, createStepId, ensureTraceDir, formatDuration, formatError, formatTimestamp, getDefaultTraceDir, getTraceFilePath, isStepStatus, isStepType, isTraceEvent, parseDuration, parseTraceJsonl, truncateName, unknownTraceFormatMessage, warn } from './chunk-NQZPZ2FN.mjs';
13
- import './chunk-IZBJAZGF.mjs';
10
+ import { parseDuration, formatDuration, isTraceEvent } from './chunk-WRE4CNPF.mjs';
11
+ export { DEFAULT_TRACE_DIR_NAME, FALLBACK_TRACE_DIR, MAX_NAME_LENGTH, RUNS_DIR_NAME, createRunId, createStepId, ensureTraceDir, formatDuration, formatError, formatTimestamp, getDefaultTraceDir, getTraceFilePath, isStepStatus, isStepType, isTraceEvent, parseDuration, parseTraceJsonl, truncateName, unknownTraceFormatMessage, warn } from './chunk-WRE4CNPF.mjs';
12
+ import './chunk-P366CCL2.mjs';
14
13
  import './chunk-7TGZLWEE.mjs';
15
14
  import { createReadStream } from 'fs';
16
15
  import { createInterface } from 'readline';
16
+ import path from 'path';
17
17
 
18
18
  // packages/core/src/trace-filter.ts
19
19
  function toLower(s) {
@@ -433,8 +433,9 @@ async function searchTraces(metas, options) {
433
433
  }
434
434
  const limit = options.limit ?? 50;
435
435
  const sessionId = options.session?.trim();
436
+ const observationStatus = parseObservationFilter(options.observation);
436
437
  const hasContentFilter = Boolean(
437
- options.status || stepTypeFilter || nameQuery || toolQuery || durationFilter
438
+ options.status || stepTypeFilter || nameQuery || toolQuery || durationFilter || observationStatus
438
439
  );
439
440
  const results = [];
440
441
  const sessionLabel = sessionId && sessionId !== "" ? sessionId : void 0;
@@ -479,6 +480,22 @@ async function searchTraces(metas, options) {
479
480
  statusFilter: options.status
480
481
  });
481
482
  results.push(...stepMatches);
483
+ if (observationStatus) {
484
+ const outcomes = extractOutcomesFromTraceEvents(events);
485
+ const matched = outcomes.filter((outcome) => outcome.status === observationStatus);
486
+ for (const outcome of matched) {
487
+ results.push({
488
+ runId: m.runId,
489
+ runName: m.name,
490
+ runStatus: m.status,
491
+ stepName: outcome.name,
492
+ timestamp: outcome.observedAt,
493
+ matchReason: `observation status=${outcome.status}`,
494
+ matchedFields: ["outcome.status", "outcome.name"],
495
+ filePath: m.filePath
496
+ });
497
+ }
498
+ }
482
499
  }
483
500
  results.sort((a, b) => {
484
501
  const ta = a.timestamp ?? 0;
@@ -867,9 +884,10 @@ function buildActivitySummary(index, options = {}) {
867
884
  entries
868
885
  };
869
886
  }
870
- function renderActivitySummaryHuman(summary) {
887
+ function renderActivitySummaryHuman(summary, options) {
871
888
  const lines = [];
872
- const todayStart = /* @__PURE__ */ new Date();
889
+ const nowMs = options?.nowMs ?? Date.now();
890
+ const todayStart = new Date(nowMs);
873
891
  todayStart.setHours(0, 0, 0, 0);
874
892
  const todayMs = todayStart.getTime();
875
893
  const today = summary.entries.filter(
@@ -1300,12 +1318,12 @@ function buildCriticalPath(runs, handoffs) {
1300
1318
  handoffs.filter((edge) => edge.confidence === "explicit").map((edge) => edge.from)
1301
1319
  );
1302
1320
  const ordered = [...runs].sort(compareRuns);
1303
- const path = [];
1321
+ const path2 = [];
1304
1322
  const visited = /* @__PURE__ */ new Set();
1305
1323
  const pushRun = (run, confidence, source) => {
1306
1324
  if (visited.has(run.runId)) return;
1307
1325
  visited.add(run.runId);
1308
- path.push({
1326
+ path2.push({
1309
1327
  runId: run.runId,
1310
1328
  name: run.name,
1311
1329
  startedAt: run.startedAt,
@@ -1330,7 +1348,7 @@ function buildCriticalPath(runs, handoffs) {
1330
1348
  const confidence = explicitTargets.has(run.runId) || explicitSources.has(run.runId) ? "explicit" : "correlated";
1331
1349
  pushRun(run, confidence, confidence === "explicit" ? "manual" : "inferred");
1332
1350
  }
1333
- return path;
1351
+ return path2;
1334
1352
  }
1335
1353
  function metaRunIdMatches(run, token, runById) {
1336
1354
  const meta = extractSessionWorkflowMetadata(run.metadata);
@@ -1450,6 +1468,190 @@ async function isAgentInspectTrace(filePath) {
1450
1468
  }
1451
1469
  }
1452
1470
 
1453
- export { SESSION_WORKFLOW_KEYS, aggregateSessionCheckResults, buildActivitySummary, buildLocalExplanation, buildSessionIndex, buildTraceStats, deriveSessionStatus, enrichSessionRunRecord, enrichSessionSummary, extractSessionWorkflowMetadata, filterMetasBySessionScope, filterTraces, groupSessionCohorts, isAgentInspectTrace, loadSessionRunRecords, loadTraceMetadataList, parseDurationFilter, renderActivitySummaryHuman, renderTraceStats, searchTraces, sessionKeyForRun, traceMetasToSessionRunRecords };
1471
+ // packages/core/src/bundle/resolve.ts
1472
+ function parseSinceCutoff(since) {
1473
+ const trimmed = since.trim();
1474
+ if (trimmed === "") {
1475
+ throw new Error("--since requires a non-empty duration (e.g. 24h, 7d).");
1476
+ }
1477
+ return Date.now() - parseDuration(trimmed);
1478
+ }
1479
+ function runActivityMs(run) {
1480
+ if (run.startedAt !== void 0 && Number.isFinite(run.startedAt)) return run.startedAt;
1481
+ if (run.endedAt !== void 0 && Number.isFinite(run.endedAt)) return run.endedAt;
1482
+ return void 0;
1483
+ }
1484
+ function runsInSinceWindow(runs, since) {
1485
+ const cutoff = parseSinceCutoff(since);
1486
+ const ids = [];
1487
+ for (const run of runs) {
1488
+ const activity = runActivityMs(run);
1489
+ if (activity !== void 0 && activity >= cutoff) {
1490
+ ids.push(run.runId);
1491
+ }
1492
+ }
1493
+ return ids.sort((a, b) => a.localeCompare(b));
1494
+ }
1495
+ function findSession(index, sessionId) {
1496
+ return index.sessions.find((session) => session.sessionId === sessionId);
1497
+ }
1498
+ function resolveBundleRunIds(index, runs, options) {
1499
+ const runId = options.runId?.trim();
1500
+ const sessionId = options.sessionId?.trim();
1501
+ const since = options.since?.trim();
1502
+ const modes = [runId ? 1 : 0, sessionId ? 1 : 0, since ? 1 : 0].reduce((a, b) => a + b, 0);
1503
+ if (modes === 0) {
1504
+ throw new Error(
1505
+ "bundle requires a run id, --session <sessionId>, or --since <duration>."
1506
+ );
1507
+ }
1508
+ if (modes > 1) {
1509
+ throw new Error(
1510
+ "bundle accepts only one target: a run id, --session, or --since (not combined)."
1511
+ );
1512
+ }
1513
+ if (runId) {
1514
+ const known = runs.some((run) => run.runId === runId);
1515
+ if (!known) {
1516
+ throw new Error(`Run "${runId}" was not found in the trace directory.`);
1517
+ }
1518
+ return { runIds: [runId] };
1519
+ }
1520
+ if (sessionId) {
1521
+ const session = findSession(index, sessionId);
1522
+ if (!session) {
1523
+ throw new Error(`Session "${sessionId}" was not found.`);
1524
+ }
1525
+ if (session.runIds.length === 0) {
1526
+ throw new Error(`Session "${sessionId}" has no runs to bundle.`);
1527
+ }
1528
+ return {
1529
+ runIds: [...session.runIds].sort((a, b) => a.localeCompare(b)),
1530
+ sessionId
1531
+ };
1532
+ }
1533
+ const runIds = runsInSinceWindow(runs, since);
1534
+ if (runIds.length === 0) {
1535
+ throw new Error(`No runs matched --since ${since}.`);
1536
+ }
1537
+ return { runIds, since };
1538
+ }
1539
+
1540
+ // packages/core/src/bundle/safety-status.ts
1541
+ function aggregateBundleSafeStatus(statuses) {
1542
+ if (statuses.length === 0) return "UNKNOWN";
1543
+ if (statuses.some((status) => status === "UNSAFE")) return "UNSAFE";
1544
+ if (statuses.some((status) => status === "UNKNOWN")) return "UNKNOWN";
1545
+ if (statuses.some((status) => status === "SAFE WITH WARNINGS")) return "SAFE WITH WARNINGS";
1546
+ return "SAFE";
1547
+ }
1548
+ function toMetadataSafeStatus(status) {
1549
+ if (status === "SAFE WITH WARNINGS") return "SAFE_WITH_WARNINGS";
1550
+ return status;
1551
+ }
1552
+ function bundleFailsOnSafety(status, allowUnsafe) {
1553
+ if (allowUnsafe) return false;
1554
+ return status === "UNSAFE" || status === "UNKNOWN";
1555
+ }
1556
+
1557
+ // packages/core/src/bundle/manifest.ts
1558
+ var BUNDLE_NOTE = "Generated locally by AgentInspect. Bundles are derived copies for review \u2014 not compliance or security certification. Review before sharing.";
1559
+ var PLACEHOLDER_NOTE = "No eval or performance artifacts were requested for this bundle.";
1560
+ function buildBundleMetadata(parts) {
1561
+ const aggregate = aggregateBundleSafeStatus(
1562
+ parts.checks.runs.map((run) => run.status)
1563
+ );
1564
+ return {
1565
+ createdAt: parts.createdAt ?? (/* @__PURE__ */ new Date()).toISOString(),
1566
+ agentInspectVersion: parts.agentInspectVersion,
1567
+ redactionProfile: parts.profile,
1568
+ sourceTraceCount: parts.resolve.runIds.length,
1569
+ runIds: [...parts.resolve.runIds],
1570
+ safeStatus: toMetadataSafeStatus(aggregate),
1571
+ files: [...parts.files].sort((a, b) => a.localeCompare(b)),
1572
+ note: BUNDLE_NOTE,
1573
+ ...parts.resolve.sessionId !== void 0 ? { sessionId: parts.resolve.sessionId } : {},
1574
+ ...parts.resolve.since !== void 0 ? { since: parts.resolve.since } : {}
1575
+ };
1576
+ }
1577
+ function buildPlaceholderArtifact() {
1578
+ return {
1579
+ status: "not_requested",
1580
+ note: PLACEHOLDER_NOTE
1581
+ };
1582
+ }
1583
+
1584
+ // packages/core/src/bundle/summary.ts
1585
+ function markdownTable(rows) {
1586
+ const lines = ["| Field | Value |", "| --- | --- |"];
1587
+ for (const [key, value] of rows) {
1588
+ lines.push(`| ${key} | ${value ?? "unknown"} |`);
1589
+ }
1590
+ return lines.join("\n");
1591
+ }
1592
+ function buildBundleSummaryMarkdown(parts) {
1593
+ const { metadata, checks, redaction } = parts;
1594
+ const lines = [
1595
+ "# AgentInspect trace bundle",
1596
+ "",
1597
+ metadata.note,
1598
+ "",
1599
+ "## Overview",
1600
+ "",
1601
+ markdownTable([
1602
+ ["Created", metadata.createdAt],
1603
+ ["AgentInspect", metadata.agentInspectVersion],
1604
+ ["Redaction profile", metadata.redactionProfile],
1605
+ ["Safe status", metadata.safeStatus],
1606
+ ["Source traces", metadata.sourceTraceCount],
1607
+ ["Runs", metadata.runIds.join(", ")],
1608
+ ...metadata.sessionId ? [["Session", metadata.sessionId]] : [],
1609
+ ...metadata.since ? [["Since", metadata.since]] : []
1610
+ ]),
1611
+ "",
1612
+ "## Safety checks",
1613
+ "",
1614
+ `Aggregate: **${checks.aggregateStatus}**`,
1615
+ ""
1616
+ ];
1617
+ for (const run of checks.runs) {
1618
+ lines.push(
1619
+ `- \`${run.runId}\`: ${run.status} (${run.findings} finding(s), ${run.errors} error(s), ${run.warnings} warning(s))`
1620
+ );
1621
+ }
1622
+ lines.push("", "## Redaction", "", `Total findings: ${redaction.totalFindings}`, "");
1623
+ for (const run of redaction.runs) {
1624
+ const detectors = run.detectors.length > 0 ? run.detectors.join(", ") : "none";
1625
+ lines.push(`- \`${run.runId}\`: ${run.findings} finding(s); detectors: ${detectors}`);
1626
+ }
1627
+ lines.push(
1628
+ "",
1629
+ "## Files",
1630
+ "",
1631
+ ...metadata.files.map((file) => `- \`${file}\``),
1632
+ "",
1633
+ "_Review every generated artifact before sharing outside your team._",
1634
+ ""
1635
+ );
1636
+ return lines.join("\n");
1637
+ }
1638
+ function normalizeBundleOutputPath(out) {
1639
+ const trimmed = out.trim();
1640
+ if (trimmed === "") {
1641
+ throw new Error("--out requires a non-empty path.");
1642
+ }
1643
+ const resolved = path.resolve(trimmed);
1644
+ if (resolved.toLowerCase().endsWith(".zip")) {
1645
+ return resolved.slice(0, -4);
1646
+ }
1647
+ return resolved;
1648
+ }
1649
+ function defaultBundleOutputPath(runIds) {
1650
+ const label = runIds.length === 1 ? runIds[0] : `multi-${runIds.length}`;
1651
+ const stamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
1652
+ return path.resolve(`agent-inspect-bundle-${label}-${stamp}`);
1653
+ }
1654
+
1655
+ export { SESSION_WORKFLOW_KEYS, aggregateBundleSafeStatus, aggregateSessionCheckResults, buildActivitySummary, buildBundleMetadata, buildBundleSummaryMarkdown, buildLocalExplanation, buildPlaceholderArtifact, buildSessionIndex, buildTraceStats, bundleFailsOnSafety, defaultBundleOutputPath, deriveSessionStatus, enrichSessionRunRecord, enrichSessionSummary, extractSessionWorkflowMetadata, filterMetasBySessionScope, filterTraces, groupSessionCohorts, isAgentInspectTrace, loadSessionRunRecords, loadTraceMetadataList, normalizeBundleOutputPath, parseDurationFilter, renderActivitySummaryHuman, renderTraceStats, resolveBundleRunIds, searchTraces, sessionKeyForRun, toMetadataSafeStatus, traceMetasToSessionRunRecords };
1454
1656
  //# sourceMappingURL=advanced.mjs.map
1455
1657
  //# sourceMappingURL=advanced.mjs.map