agent-inspect 6.14.1 → 6.15.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 (79) hide show
  1. package/CHANGELOG.md +14 -2
  2. package/README.md +1 -1
  3. package/docs/API.md +19 -3
  4. package/docs/KNOWN-ISSUES.md +2 -1
  5. package/package.json +2 -2
  6. package/packages/cli/dist/{chunk-MEO2Z3KE.mjs → chunk-LFSBMUCD.mjs} +316 -41
  7. package/packages/cli/dist/chunk-LFSBMUCD.mjs.map +1 -0
  8. package/packages/cli/dist/index.cjs +388 -42
  9. package/packages/cli/dist/index.cjs.map +1 -1
  10. package/packages/cli/dist/index.mjs +59 -6
  11. package/packages/cli/dist/index.mjs.map +1 -1
  12. package/packages/cli/dist/{src-6VZNGIF6.mjs → src-5J2HPOJ3.mjs} +3 -3
  13. package/packages/cli/dist/{src-6VZNGIF6.mjs.map → src-5J2HPOJ3.mjs.map} +1 -1
  14. package/packages/core/dist/advanced.cjs +268 -24
  15. package/packages/core/dist/advanced.cjs.map +1 -1
  16. package/packages/core/dist/advanced.d.cts +18 -10
  17. package/packages/core/dist/advanced.d.ts +18 -10
  18. package/packages/core/dist/advanced.mjs +7 -6
  19. package/packages/core/dist/advanced.mjs.map +1 -1
  20. package/packages/core/dist/checks.cjs +221 -22
  21. package/packages/core/dist/checks.cjs.map +1 -1
  22. package/packages/core/dist/checks.d.cts +18 -8
  23. package/packages/core/dist/checks.d.ts +18 -8
  24. package/packages/core/dist/checks.mjs +2 -1
  25. package/packages/core/dist/chunk-AK5EN4U2.mjs +174 -0
  26. package/packages/core/dist/chunk-AK5EN4U2.mjs.map +1 -0
  27. package/packages/core/dist/chunk-FWK3Q3OJ.mjs +56 -0
  28. package/packages/core/dist/chunk-FWK3Q3OJ.mjs.map +1 -0
  29. package/packages/core/dist/{chunk-CTA6XNDP.mjs → chunk-HT54OLPE.mjs} +54 -7
  30. package/packages/core/dist/chunk-HT54OLPE.mjs.map +1 -0
  31. package/packages/core/dist/{chunk-BS2QCAJX.mjs → chunk-NF4ZHNTC.mjs} +169 -25
  32. package/packages/core/dist/chunk-NF4ZHNTC.mjs.map +1 -0
  33. package/packages/core/dist/{chunk-UOPVGCOB.mjs → chunk-NXQF73EC.mjs} +3 -3
  34. package/packages/core/dist/{chunk-UOPVGCOB.mjs.map → chunk-NXQF73EC.mjs.map} +1 -1
  35. package/packages/core/dist/{chunk-LFWZEO2L.mjs → chunk-SGL4JGCD.mjs} +3 -3
  36. package/packages/core/dist/{chunk-LFWZEO2L.mjs.map → chunk-SGL4JGCD.mjs.map} +1 -1
  37. package/packages/core/dist/{context-BHAgRjOe.d.cts → context-Ca5yK8Cs.d.cts} +3 -3
  38. package/packages/core/dist/{context-Blyjb5my.d.ts → context-D6cS4XIL.d.ts} +3 -3
  39. package/packages/core/dist/diff.d.cts +3 -3
  40. package/packages/core/dist/diff.d.ts +3 -3
  41. package/packages/core/dist/exporters.d.cts +3 -3
  42. package/packages/core/dist/exporters.d.ts +3 -3
  43. package/packages/core/dist/exporters.mjs +1 -1
  44. package/packages/core/dist/index-B259NKkH.d.cts +102 -0
  45. package/packages/core/dist/index-B9ZGvUVL.d.ts +102 -0
  46. package/packages/core/dist/{index-Bu_vOjql.d.ts → index-BsCcOKxy.d.ts} +4 -4
  47. package/packages/core/dist/{index-CmXMS-MF.d.cts → index-Xk9X-yjY.d.cts} +4 -4
  48. package/packages/core/dist/index.d.cts +6 -6
  49. package/packages/core/dist/index.d.ts +6 -6
  50. package/packages/core/dist/{inspect-event-DVg84S4v.d.cts → inspect-event-DRthdZlf.d.cts} +9 -0
  51. package/packages/core/dist/{inspect-event-DVg84S4v.d.ts → inspect-event-DRthdZlf.d.ts} +9 -0
  52. package/packages/core/dist/{log-config-BG1WmWf2.d.cts → log-config-CFlIJHTf.d.cts} +1 -1
  53. package/packages/core/dist/{log-config-Ck0aT_Ou.d.ts → log-config-OZRfpHED.d.ts} +1 -1
  54. package/packages/core/dist/logs.cjs +95 -15
  55. package/packages/core/dist/logs.cjs.map +1 -1
  56. package/packages/core/dist/logs.d.cts +3 -3
  57. package/packages/core/dist/logs.d.ts +3 -3
  58. package/packages/core/dist/logs.mjs +2 -2
  59. package/packages/core/dist/{persisted-inspect-event-ChE7pGb7.d.ts → persisted-inspect-event-BVucFVrP.d.ts} +1 -1
  60. package/packages/core/dist/{persisted-inspect-event-d-mSP8kd.d.cts → persisted-inspect-event-CVZWZldL.d.cts} +1 -1
  61. package/packages/core/dist/persisted.cjs +95 -15
  62. package/packages/core/dist/persisted.cjs.map +1 -1
  63. package/packages/core/dist/persisted.d.cts +5 -5
  64. package/packages/core/dist/persisted.d.ts +5 -5
  65. package/packages/core/dist/persisted.mjs +3 -3
  66. package/packages/core/dist/readers.cjs +203 -18
  67. package/packages/core/dist/readers.cjs.map +1 -1
  68. package/packages/core/dist/readers.d.cts +27 -78
  69. package/packages/core/dist/readers.d.ts +27 -78
  70. package/packages/core/dist/readers.mjs +4 -3
  71. package/packages/core/dist/{types-MuwXSJ4b.d.ts → types--ainI31J.d.ts} +1 -1
  72. package/packages/core/dist/{types-BLX3tiOW.d.cts → types-UnrNaTo2.d.cts} +1 -1
  73. package/packages/core/dist/writers.d.cts +2 -2
  74. package/packages/core/dist/writers.d.ts +2 -2
  75. package/packages/cli/dist/chunk-MEO2Z3KE.mjs.map +0 -1
  76. package/packages/core/dist/chunk-BS2QCAJX.mjs.map +0 -1
  77. package/packages/core/dist/chunk-CTA6XNDP.mjs.map +0 -1
  78. package/packages/core/dist/chunk-T5MASTIW.mjs +0 -94
  79. package/packages/core/dist/chunk-T5MASTIW.mjs.map +0 -1
@@ -0,0 +1,102 @@
1
+ import { a as InspectRunTree } from './inspect-event-DRthdZlf.cjs';
2
+ import { P as PersistedInspectEvent } from './persisted-inspect-event-CVZWZldL.cjs';
3
+
4
+ type TraceInput = {
5
+ type: "file";
6
+ path: string;
7
+ } | {
8
+ type: "directory";
9
+ path: string;
10
+ } | {
11
+ type: "string";
12
+ content: string;
13
+ } | {
14
+ type: "buffer";
15
+ content: Buffer;
16
+ } | {
17
+ type: "stdin";
18
+ };
19
+ type TraceReadWarningSeverity = "info" | "warning" | "error";
20
+ interface TraceReadWarning {
21
+ code: string;
22
+ message: string;
23
+ severity?: TraceReadWarningSeverity;
24
+ sourceFile?: string;
25
+ line?: number;
26
+ field?: string;
27
+ }
28
+ interface TraceReadResult {
29
+ format: string;
30
+ events: PersistedInspectEvent[];
31
+ runs: InspectRunTree[];
32
+ warnings: TraceReadWarning[];
33
+ unsupportedFields: string[];
34
+ sourceFiles: string[];
35
+ }
36
+ interface TraceFormatCandidate {
37
+ format: string;
38
+ confidence: number;
39
+ readerName?: string;
40
+ description?: string;
41
+ warnings?: TraceReadWarning[];
42
+ }
43
+ type TraceFormatDetectionStatus = "detected" | "ambiguous" | "unsupported";
44
+ interface TraceFormatDetectionResult {
45
+ status: TraceFormatDetectionStatus;
46
+ format?: string;
47
+ candidates: TraceFormatCandidate[];
48
+ warnings: TraceReadWarning[];
49
+ }
50
+ interface TraceReaderDetectOptions {
51
+ format?: string;
52
+ }
53
+ interface TraceReaderReadOptions {
54
+ format?: string;
55
+ }
56
+ interface TraceReader {
57
+ readonly format: string;
58
+ readonly name?: string;
59
+ detect(input: TraceInput, options?: TraceReaderDetectOptions): TraceFormatCandidate | undefined | Promise<TraceFormatCandidate | undefined>;
60
+ read(input: TraceInput, options?: TraceReaderReadOptions): TraceReadResult | Promise<TraceReadResult>;
61
+ }
62
+ interface TraceReadOptions {
63
+ format?: string;
64
+ readers?: readonly TraceReader[];
65
+ }
66
+ type TraceReadErrorCode = "unsupported_format" | "ambiguous_format" | "reader_failed" | "invalid_input";
67
+ declare class TraceReadError extends Error {
68
+ readonly code: TraceReadErrorCode;
69
+ readonly warnings: TraceReadWarning[];
70
+ constructor(code: TraceReadErrorCode, message: string, warnings?: TraceReadWarning[]);
71
+ }
72
+ /**
73
+ * Runtime guard for structured TraceInput. Never throws WeakMap key errors for bare strings.
74
+ */
75
+ declare function assertTraceInput(input: unknown): asserts input is TraceInput;
76
+ declare const openInferenceJsonReader: TraceReader;
77
+ declare const otlpJsonReader: TraceReader;
78
+ declare const agentInspectJsonlReader: TraceReader;
79
+ declare const DEFAULT_TRACE_READERS: readonly TraceReader[];
80
+ declare function detectTraceFormat(input: TraceInput, options?: TraceReadOptions): Promise<TraceFormatDetectionResult>;
81
+ declare function readTrace(input: TraceInput, options?: TraceReadOptions): Promise<TraceReadResult>;
82
+ declare function openTrace(input: TraceInput, options?: TraceReadOptions): Promise<TraceReadResult>;
83
+ /**
84
+ * Open a single local trace file. Prefer this over passing a bare path string to `openTrace`.
85
+ *
86
+ * @experimental Additive convenience over `openTrace({ type: "file", path })`.
87
+ */
88
+ declare function openTraceFile(filePath: string, options?: TraceReadOptions): Promise<TraceReadResult>;
89
+ /**
90
+ * Open all `*.jsonl` files in a local directory (sorted, concatenated).
91
+ *
92
+ * @experimental Additive convenience over `openTrace({ type: "directory", path })`.
93
+ */
94
+ declare function openTraceDirectory(dirPath: string, options?: TraceReadOptions): Promise<TraceReadResult>;
95
+ /**
96
+ * Open an in-memory JSONL / supported text payload.
97
+ *
98
+ * @experimental Additive convenience over `openTrace({ type: "string", content })`.
99
+ */
100
+ declare function openTraceText(content: string, options?: TraceReadOptions): Promise<TraceReadResult>;
101
+
102
+ export { DEFAULT_TRACE_READERS as D, type TraceReadResult as T, type TraceReadWarning as a, type TraceFormatCandidate as b, type TraceFormatDetectionResult as c, type TraceFormatDetectionStatus as d, type TraceInput as e, TraceReadError as f, type TraceReadErrorCode as g, type TraceReadOptions as h, type TraceReadWarningSeverity as i, type TraceReader as j, type TraceReaderDetectOptions as k, type TraceReaderReadOptions as l, agentInspectJsonlReader as m, assertTraceInput as n, detectTraceFormat as o, openInferenceJsonReader as p, openTrace as q, openTraceDirectory as r, openTraceFile as s, openTraceText as t, otlpJsonReader as u, readTrace as v };
@@ -0,0 +1,102 @@
1
+ import { a as InspectRunTree } from './inspect-event-DRthdZlf.js';
2
+ import { P as PersistedInspectEvent } from './persisted-inspect-event-BVucFVrP.js';
3
+
4
+ type TraceInput = {
5
+ type: "file";
6
+ path: string;
7
+ } | {
8
+ type: "directory";
9
+ path: string;
10
+ } | {
11
+ type: "string";
12
+ content: string;
13
+ } | {
14
+ type: "buffer";
15
+ content: Buffer;
16
+ } | {
17
+ type: "stdin";
18
+ };
19
+ type TraceReadWarningSeverity = "info" | "warning" | "error";
20
+ interface TraceReadWarning {
21
+ code: string;
22
+ message: string;
23
+ severity?: TraceReadWarningSeverity;
24
+ sourceFile?: string;
25
+ line?: number;
26
+ field?: string;
27
+ }
28
+ interface TraceReadResult {
29
+ format: string;
30
+ events: PersistedInspectEvent[];
31
+ runs: InspectRunTree[];
32
+ warnings: TraceReadWarning[];
33
+ unsupportedFields: string[];
34
+ sourceFiles: string[];
35
+ }
36
+ interface TraceFormatCandidate {
37
+ format: string;
38
+ confidence: number;
39
+ readerName?: string;
40
+ description?: string;
41
+ warnings?: TraceReadWarning[];
42
+ }
43
+ type TraceFormatDetectionStatus = "detected" | "ambiguous" | "unsupported";
44
+ interface TraceFormatDetectionResult {
45
+ status: TraceFormatDetectionStatus;
46
+ format?: string;
47
+ candidates: TraceFormatCandidate[];
48
+ warnings: TraceReadWarning[];
49
+ }
50
+ interface TraceReaderDetectOptions {
51
+ format?: string;
52
+ }
53
+ interface TraceReaderReadOptions {
54
+ format?: string;
55
+ }
56
+ interface TraceReader {
57
+ readonly format: string;
58
+ readonly name?: string;
59
+ detect(input: TraceInput, options?: TraceReaderDetectOptions): TraceFormatCandidate | undefined | Promise<TraceFormatCandidate | undefined>;
60
+ read(input: TraceInput, options?: TraceReaderReadOptions): TraceReadResult | Promise<TraceReadResult>;
61
+ }
62
+ interface TraceReadOptions {
63
+ format?: string;
64
+ readers?: readonly TraceReader[];
65
+ }
66
+ type TraceReadErrorCode = "unsupported_format" | "ambiguous_format" | "reader_failed" | "invalid_input";
67
+ declare class TraceReadError extends Error {
68
+ readonly code: TraceReadErrorCode;
69
+ readonly warnings: TraceReadWarning[];
70
+ constructor(code: TraceReadErrorCode, message: string, warnings?: TraceReadWarning[]);
71
+ }
72
+ /**
73
+ * Runtime guard for structured TraceInput. Never throws WeakMap key errors for bare strings.
74
+ */
75
+ declare function assertTraceInput(input: unknown): asserts input is TraceInput;
76
+ declare const openInferenceJsonReader: TraceReader;
77
+ declare const otlpJsonReader: TraceReader;
78
+ declare const agentInspectJsonlReader: TraceReader;
79
+ declare const DEFAULT_TRACE_READERS: readonly TraceReader[];
80
+ declare function detectTraceFormat(input: TraceInput, options?: TraceReadOptions): Promise<TraceFormatDetectionResult>;
81
+ declare function readTrace(input: TraceInput, options?: TraceReadOptions): Promise<TraceReadResult>;
82
+ declare function openTrace(input: TraceInput, options?: TraceReadOptions): Promise<TraceReadResult>;
83
+ /**
84
+ * Open a single local trace file. Prefer this over passing a bare path string to `openTrace`.
85
+ *
86
+ * @experimental Additive convenience over `openTrace({ type: "file", path })`.
87
+ */
88
+ declare function openTraceFile(filePath: string, options?: TraceReadOptions): Promise<TraceReadResult>;
89
+ /**
90
+ * Open all `*.jsonl` files in a local directory (sorted, concatenated).
91
+ *
92
+ * @experimental Additive convenience over `openTrace({ type: "directory", path })`.
93
+ */
94
+ declare function openTraceDirectory(dirPath: string, options?: TraceReadOptions): Promise<TraceReadResult>;
95
+ /**
96
+ * Open an in-memory JSONL / supported text payload.
97
+ *
98
+ * @experimental Additive convenience over `openTrace({ type: "string", content })`.
99
+ */
100
+ declare function openTraceText(content: string, options?: TraceReadOptions): Promise<TraceReadResult>;
101
+
102
+ export { DEFAULT_TRACE_READERS as D, type TraceReadResult as T, type TraceReadWarning as a, type TraceFormatCandidate as b, type TraceFormatDetectionResult as c, type TraceFormatDetectionStatus as d, type TraceInput as e, TraceReadError as f, type TraceReadErrorCode as g, type TraceReadOptions as h, type TraceReadWarningSeverity as i, type TraceReader as j, type TraceReaderDetectOptions as k, type TraceReaderReadOptions as l, agentInspectJsonlReader as m, assertTraceInput as n, detectTraceFormat as o, openInferenceJsonReader as p, openTrace as q, openTraceDirectory as r, openTraceFile as s, openTraceText as t, otlpJsonReader as u, readTrace as v };
@@ -1,6 +1,6 @@
1
- import { TraceReadResult, TraceReadWarning } from './readers.js';
2
- import { a as InspectRunTree, b as InspectNode, A as AttributionConfidence } from './inspect-event-DVg84S4v.js';
3
- import { P as PersistedInspectEvent } from './persisted-inspect-event-ChE7pGb7.js';
1
+ import { T as TraceReadResult, a as TraceReadWarning } from './index-B9ZGvUVL.js';
2
+ import { a as InspectRunTree, b as InspectNode, A as AttributionConfidence } from './inspect-event-DRthdZlf.js';
3
+ import { P as PersistedInspectEvent } from './persisted-inspect-event-BVucFVrP.js';
4
4
  import { O as ObservedOutcomeStatus } from './types-B562HgN_.js';
5
5
 
6
6
  /**
@@ -19,7 +19,7 @@ import { O as ObservedOutcomeStatus } from './types-B562HgN_.js';
19
19
  * @experimental
20
20
  */
21
21
  interface LogicalProjectionDiagnostic {
22
- code: "AI_LOGICAL_PAIR_AMBIGUOUS" | "AI_LOGICAL_PAIR_UNMATCHED_START" | "AI_LOGICAL_PAIR_UNMATCHED_COMPLETE" | "AI_LOGICAL_PARENT_REMAPPED" | "AI_LOGICAL_PARENT_UNRESOLVED";
22
+ code: "AI_LOGICAL_PAIR_AMBIGUOUS" | "AI_LOGICAL_PAIR_UNMATCHED_START" | "AI_LOGICAL_PAIR_UNMATCHED_COMPLETE" | "AI_LOGICAL_PARENT_REMAPPED" | "AI_LOGICAL_PARENT_UNRESOLVED" | "AI_LOGICAL_SELF_PARENT_REMOVED";
23
23
  message: string;
24
24
  eventIds?: readonly string[];
25
25
  }
@@ -1,6 +1,6 @@
1
- import { TraceReadResult, TraceReadWarning } from './readers.cjs';
2
- import { a as InspectRunTree, b as InspectNode, A as AttributionConfidence } from './inspect-event-DVg84S4v.cjs';
3
- import { P as PersistedInspectEvent } from './persisted-inspect-event-d-mSP8kd.cjs';
1
+ import { T as TraceReadResult, a as TraceReadWarning } from './index-B259NKkH.cjs';
2
+ import { a as InspectRunTree, b as InspectNode, A as AttributionConfidence } from './inspect-event-DRthdZlf.cjs';
3
+ import { P as PersistedInspectEvent } from './persisted-inspect-event-CVZWZldL.cjs';
4
4
  import { O as ObservedOutcomeStatus } from './types-B562HgN_.cjs';
5
5
 
6
6
  /**
@@ -19,7 +19,7 @@ import { O as ObservedOutcomeStatus } from './types-B562HgN_.cjs';
19
19
  * @experimental
20
20
  */
21
21
  interface LogicalProjectionDiagnostic {
22
- code: "AI_LOGICAL_PAIR_AMBIGUOUS" | "AI_LOGICAL_PAIR_UNMATCHED_START" | "AI_LOGICAL_PAIR_UNMATCHED_COMPLETE" | "AI_LOGICAL_PARENT_REMAPPED" | "AI_LOGICAL_PARENT_UNRESOLVED";
22
+ code: "AI_LOGICAL_PAIR_AMBIGUOUS" | "AI_LOGICAL_PAIR_UNMATCHED_START" | "AI_LOGICAL_PAIR_UNMATCHED_COMPLETE" | "AI_LOGICAL_PARENT_REMAPPED" | "AI_LOGICAL_PARENT_UNRESOLVED" | "AI_LOGICAL_SELF_PARENT_REMOVED";
23
23
  message: string;
24
24
  eventIds?: readonly string[];
25
25
  }
@@ -1,10 +1,10 @@
1
- import { I as InspectRunOptions, S as StepOptions, O as ObserveOptions } from './types-BLX3tiOW.cjs';
2
- export { E as ErrorInfo, R as RedactionProfile, a as Run, b as RunStatus, c as Step, d as StepMetadata, e as StepStatus, f as StepType, T as TokenMetadata, g as TraceCorrelationMetadata } from './types-BLX3tiOW.cjs';
3
- export { C as CreateInspectorOptions, I as Inspector, a as InspectorCaptureOptions, b as InspectorObserveOptions, c as InspectorRunOptions, d as InspectorStepOptions, e as createInspector, g as getCurrentCorrelationMetadata, m as maybeInspectRun } from './context-BHAgRjOe.cjs';
1
+ import { I as InspectRunOptions, S as StepOptions, O as ObserveOptions } from './types-UnrNaTo2.cjs';
2
+ export { E as ErrorInfo, R as RedactionProfile, a as Run, b as RunStatus, c as Step, d as StepMetadata, e as StepStatus, f as StepType, T as TokenMetadata, g as TraceCorrelationMetadata } from './types-UnrNaTo2.cjs';
3
+ export { C as CreateInspectorOptions, I as Inspector, a as InspectorCaptureOptions, b as InspectorObserveOptions, c as InspectorRunOptions, d as InspectorStepOptions, e as createInspector, g as getCurrentCorrelationMetadata, m as maybeInspectRun } from './context-Ca5yK8Cs.cjs';
4
4
  import { a as ObserveOutcomeOptions } from './types-B562HgN_.cjs';
5
- import './log-config-BG1WmWf2.cjs';
6
- import './inspect-event-DVg84S4v.cjs';
7
- import './persisted-inspect-event-d-mSP8kd.cjs';
5
+ import './log-config-CFlIJHTf.cjs';
6
+ import './inspect-event-DRthdZlf.cjs';
7
+ import './persisted-inspect-event-CVZWZldL.cjs';
8
8
  import './writers.cjs';
9
9
 
10
10
  /**
@@ -1,10 +1,10 @@
1
- import { I as InspectRunOptions, S as StepOptions, O as ObserveOptions } from './types-MuwXSJ4b.js';
2
- export { E as ErrorInfo, R as RedactionProfile, a as Run, b as RunStatus, c as Step, d as StepMetadata, e as StepStatus, f as StepType, T as TokenMetadata, g as TraceCorrelationMetadata } from './types-MuwXSJ4b.js';
3
- export { C as CreateInspectorOptions, I as Inspector, a as InspectorCaptureOptions, b as InspectorObserveOptions, c as InspectorRunOptions, d as InspectorStepOptions, e as createInspector, g as getCurrentCorrelationMetadata, m as maybeInspectRun } from './context-Blyjb5my.js';
1
+ import { I as InspectRunOptions, S as StepOptions, O as ObserveOptions } from './types--ainI31J.js';
2
+ export { E as ErrorInfo, R as RedactionProfile, a as Run, b as RunStatus, c as Step, d as StepMetadata, e as StepStatus, f as StepType, T as TokenMetadata, g as TraceCorrelationMetadata } from './types--ainI31J.js';
3
+ export { C as CreateInspectorOptions, I as Inspector, a as InspectorCaptureOptions, b as InspectorObserveOptions, c as InspectorRunOptions, d as InspectorStepOptions, e as createInspector, g as getCurrentCorrelationMetadata, m as maybeInspectRun } from './context-D6cS4XIL.js';
4
4
  import { a as ObserveOutcomeOptions } from './types-B562HgN_.js';
5
- import './log-config-Ck0aT_Ou.js';
6
- import './inspect-event-DVg84S4v.js';
7
- import './persisted-inspect-event-ChE7pGb7.js';
5
+ import './log-config-OZRfpHED.js';
6
+ import './inspect-event-DRthdZlf.js';
7
+ import './persisted-inspect-event-BVucFVrP.js';
8
8
  import './writers.js';
9
9
 
10
10
  /**
@@ -23,6 +23,14 @@ interface InspectNode {
23
23
  children: InspectNode[];
24
24
  depth: number;
25
25
  }
26
+ /** Bounded parent/cycle summary for visibility-first tree building (6.14.2+). */
27
+ interface RelationshipSummary {
28
+ rootCount: number;
29
+ selfParentCount: number;
30
+ cycleCount: number;
31
+ unresolvedParentCount: number;
32
+ normalizedEdgeCount: number;
33
+ }
26
34
  interface InspectRunTree {
27
35
  runId: string;
28
36
  name?: string;
@@ -35,6 +43,7 @@ interface InspectRunTree {
35
43
  totalEvents: number;
36
44
  confidenceBreakdown: Record<AttributionConfidence, number>;
37
45
  kinds: Record<InspectKind, number>;
46
+ relationshipSummary?: RelationshipSummary;
38
47
  };
39
48
  }
40
49
 
@@ -23,6 +23,14 @@ interface InspectNode {
23
23
  children: InspectNode[];
24
24
  depth: number;
25
25
  }
26
+ /** Bounded parent/cycle summary for visibility-first tree building (6.14.2+). */
27
+ interface RelationshipSummary {
28
+ rootCount: number;
29
+ selfParentCount: number;
30
+ cycleCount: number;
31
+ unresolvedParentCount: number;
32
+ normalizedEdgeCount: number;
33
+ }
26
34
  interface InspectRunTree {
27
35
  runId: string;
28
36
  name?: string;
@@ -35,6 +43,7 @@ interface InspectRunTree {
35
43
  totalEvents: number;
36
44
  confidenceBreakdown: Record<AttributionConfidence, number>;
37
45
  kinds: Record<InspectKind, number>;
46
+ relationshipSummary?: RelationshipSummary;
38
47
  };
39
48
  }
40
49
 
@@ -1,4 +1,4 @@
1
- import { I as InspectKind } from './inspect-event-DVg84S4v.cjs';
1
+ import { I as InspectKind } from './inspect-event-DRthdZlf.cjs';
2
2
 
3
3
  interface LogEventMapping {
4
4
  kind?: InspectKind;
@@ -1,4 +1,4 @@
1
- import { I as InspectKind } from './inspect-event-DVg84S4v.js';
1
+ import { I as InspectKind } from './inspect-event-DRthdZlf.js';
2
2
 
3
3
  interface LogEventMapping {
4
4
  kind?: InspectKind;
@@ -634,6 +634,20 @@ var EventNormalizer = class {
634
634
  function inc(map, key) {
635
635
  map[key] = (map[key] ?? 0) + 1;
636
636
  }
637
+ function confidenceRank(confidence) {
638
+ switch (confidence) {
639
+ case "unknown":
640
+ return 0;
641
+ case "heuristic":
642
+ return 1;
643
+ case "correlated":
644
+ return 2;
645
+ case "explicit":
646
+ return 3;
647
+ default:
648
+ return 0;
649
+ }
650
+ }
637
651
  function computeRunStatus(events) {
638
652
  let runTerminal;
639
653
  let sawRunEvent = false;
@@ -654,6 +668,84 @@ function computeRunStatus(events) {
654
668
  }
655
669
  return hasRunning ? "running" : "ok";
656
670
  }
671
+ function linkNodesVisibilityFirst(nodes) {
672
+ let selfParentCount = 0;
673
+ let unresolvedParentCount = 0;
674
+ let normalizedEdgeCount = 0;
675
+ let cycleCount = 0;
676
+ const pending = [];
677
+ for (const node of nodes.values()) {
678
+ const parentId = node.event.parentId;
679
+ if (!parentId) continue;
680
+ if (parentId === node.event.eventId) {
681
+ selfParentCount += 1;
682
+ normalizedEdgeCount += 1;
683
+ continue;
684
+ }
685
+ if (!nodes.has(parentId)) {
686
+ unresolvedParentCount += 1;
687
+ continue;
688
+ }
689
+ pending.push({
690
+ childId: node.event.eventId,
691
+ parentId,
692
+ childTimestamp: node.event.timestamp,
693
+ childConfidence: node.event.confidence
694
+ });
695
+ }
696
+ pending.sort((a, b) => {
697
+ const conf = confidenceRank(b.childConfidence) - confidenceRank(a.childConfidence);
698
+ if (conf !== 0) return conf;
699
+ return a.childTimestamp - b.childTimestamp;
700
+ });
701
+ const parentOf = /* @__PURE__ */ new Map();
702
+ for (const edge of pending) {
703
+ parentOf.set(edge.childId, edge.parentId);
704
+ let cursor = edge.parentId;
705
+ const seen = /* @__PURE__ */ new Set([edge.childId]);
706
+ let cyclic = false;
707
+ while (cursor) {
708
+ if (seen.has(cursor)) {
709
+ cyclic = true;
710
+ break;
711
+ }
712
+ seen.add(cursor);
713
+ cursor = parentOf.get(cursor);
714
+ }
715
+ if (cyclic) {
716
+ parentOf.delete(edge.childId);
717
+ cycleCount += 1;
718
+ normalizedEdgeCount += 1;
719
+ }
720
+ }
721
+ for (const [childId, parentId] of parentOf) {
722
+ nodes.get(parentId).children.push(nodes.get(childId));
723
+ }
724
+ const roots = [];
725
+ for (const node of nodes.values()) {
726
+ if (!parentOf.has(node.event.eventId)) {
727
+ roots.push(node);
728
+ }
729
+ }
730
+ const assignDepth = (n, depth, stack) => {
731
+ if (stack.has(n.event.eventId)) return;
732
+ n.depth = depth;
733
+ stack.add(n.event.eventId);
734
+ for (const c of n.children) assignDepth(c, depth + 1, stack);
735
+ stack.delete(n.event.eventId);
736
+ };
737
+ for (const r of roots) assignDepth(r, 0, /* @__PURE__ */ new Set());
738
+ return {
739
+ roots,
740
+ summary: {
741
+ rootCount: roots.length,
742
+ selfParentCount,
743
+ cycleCount,
744
+ unresolvedParentCount,
745
+ normalizedEdgeCount
746
+ }
747
+ };
748
+ }
657
749
  var TreeBuilder = class {
658
750
  constructor(options) {
659
751
  void options?.config;
@@ -671,20 +763,7 @@ var TreeBuilder = class {
671
763
  for (const e of sorted) {
672
764
  nodes.set(e.eventId, { event: e, children: [], depth: 0 });
673
765
  }
674
- const roots = [];
675
- for (const node of nodes.values()) {
676
- const parentId = node.event.parentId;
677
- if (parentId && nodes.has(parentId)) {
678
- nodes.get(parentId).children.push(node);
679
- } else {
680
- roots.push(node);
681
- }
682
- }
683
- const assignDepth = (n, depth) => {
684
- n.depth = depth;
685
- for (const c of n.children) assignDepth(c, depth + 1);
686
- };
687
- for (const r of roots) assignDepth(r, 0);
766
+ const { roots, summary } = linkNodesVisibilityFirst(nodes);
688
767
  const confidenceBreakdown = {
689
768
  explicit: 0,
690
769
  correlated: 0,
@@ -712,7 +791,8 @@ var TreeBuilder = class {
712
791
  metadata: {
713
792
  totalEvents: sorted.length,
714
793
  confidenceBreakdown,
715
- kinds
794
+ kinds,
795
+ relationshipSummary: summary
716
796
  }
717
797
  });
718
798
  }