agent-inspect 1.7.0 → 1.9.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.
- package/CHANGELOG.md +21 -1
- package/README.md +145 -21
- package/docs/ADAPTER-CONFORMANCE.md +7 -3
- package/docs/ADAPTERS.md +155 -5
- package/docs/API.md +214 -26
- package/docs/CLI.md +189 -7
- package/docs/GETTING-STARTED.md +71 -16
- package/docs/KNOWN-ISSUES.md +7 -1
- package/docs/LIMITATIONS.md +7 -1
- package/docs/LOG-TO-TREE-QUICKSTART.md +1 -2
- package/docs/MIGRATION.md +67 -0
- package/docs/SCHEMA.md +1 -0
- package/package.json +12 -2
- package/packages/cli/dist/index.cjs +2454 -140
- package/packages/cli/dist/index.cjs.map +1 -1
- package/packages/cli/dist/index.mjs +2454 -140
- package/packages/cli/dist/index.mjs.map +1 -1
- package/packages/core/dist/advanced.d.cts +4 -4
- package/packages/core/dist/advanced.d.ts +4 -4
- package/packages/core/dist/checks.cjs +1535 -0
- package/packages/core/dist/checks.cjs.map +1 -0
- package/packages/core/dist/checks.d.cts +585 -0
- package/packages/core/dist/checks.d.ts +585 -0
- package/packages/core/dist/checks.mjs +1512 -0
- package/packages/core/dist/checks.mjs.map +1 -0
- package/packages/core/dist/diff.d.cts +3 -3
- package/packages/core/dist/diff.d.ts +3 -3
- package/packages/core/dist/exporters.d.cts +3 -3
- package/packages/core/dist/exporters.d.ts +3 -3
- package/packages/core/dist/index.cjs +146 -0
- package/packages/core/dist/index.cjs.map +1 -1
- package/packages/core/dist/index.d.cts +44 -7
- package/packages/core/dist/index.d.ts +44 -7
- package/packages/core/dist/index.mjs +148 -1
- package/packages/core/dist/index.mjs.map +1 -1
- package/packages/core/dist/{inspect-event-Des4JDHo.d.cts → inspect-event-CevRYp58.d.cts} +1 -1
- package/packages/core/dist/{inspect-event-Des4JDHo.d.ts → inspect-event-CevRYp58.d.ts} +1 -1
- package/packages/core/dist/{log-config-C1GcJPIM.d.ts → log-config-BPHS4Sds.d.ts} +1 -1
- package/packages/core/dist/{log-config-BnH8Ykcb.d.cts → log-config-DanPV3P9.d.cts} +1 -1
- package/packages/core/dist/logs.d.cts +3 -3
- package/packages/core/dist/logs.d.ts +3 -3
- package/packages/core/dist/{persisted-inspect-event-DiFto0K2.d.ts → persisted-inspect-event-Cw7TeYGr.d.ts} +1 -1
- package/packages/core/dist/{persisted-inspect-event-0kaRADsp.d.cts → persisted-inspect-event-DHPfzUd8.d.cts} +1 -1
- package/packages/core/dist/persisted.d.cts +5 -5
- package/packages/core/dist/persisted.d.ts +5 -5
- package/packages/core/dist/readers.d.cts +2 -2
- package/packages/core/dist/readers.d.ts +2 -2
- package/packages/core/dist/{types-tSix7tfv.d.ts → types-Ap9uMdx_.d.ts} +1 -1
- package/packages/core/dist/{types-DB8jB6Jg.d.cts → types-B2-BU5CS.d.cts} +1 -1
- package/packages/core/dist/writers.d.cts +2 -2
- package/packages/core/dist/writers.d.ts +2 -2
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { T as TraceEvent, R as RunSummary, a as TraceMetadata, b as TraceMetadataStatus, S as StepType, c as StepStatus, d as TraceCorrelationMetadata, e as RedactionProfile, I as InspectRunOptions, f as StepOptions, O as ObserveOptions } from './types-
|
|
2
|
-
export { A as ActiveStepContext, E as ErrorInfo, g as ExecutionContext, h as Run, i as RunCompletedEvent, j as RunStartedEvent, k as RunStatus, l as Step, m as StepCompletedEvent, n as StepMetadata, o as StepStartedEvent, p as TokenMetadata, q as TraceEventBase, r as TraceSchemaVersion, s as isStepStatus, t as isStepType, u as isTraceEvent } from './types-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { T as TraceEvent, R as RunSummary, a as TraceMetadata, b as TraceMetadataStatus, S as StepType, c as StepStatus, d as TraceCorrelationMetadata, e as RedactionProfile, I as InspectRunOptions, f as StepOptions, O as ObserveOptions } from './types-B2-BU5CS.cjs';
|
|
2
|
+
export { A as ActiveStepContext, E as ErrorInfo, g as ExecutionContext, h as Run, i as RunCompletedEvent, j as RunStartedEvent, k as RunStatus, l as Step, m as StepCompletedEvent, n as StepMetadata, o as StepStartedEvent, p as TokenMetadata, q as TraceEventBase, r as TraceSchemaVersion, s as isStepStatus, t as isStepType, u as isTraceEvent } from './types-B2-BU5CS.cjs';
|
|
3
|
+
import { a as InspectRunTree } from './inspect-event-CevRYp58.cjs';
|
|
4
|
+
export { A as AttributionConfidence, E as EventSource, c as InspectEvent, I as InspectKind, b as InspectNode } from './inspect-event-CevRYp58.cjs';
|
|
5
|
+
import { P as PersistedInspectEvent } from './persisted-inspect-event-DHPfzUd8.cjs';
|
|
6
|
+
export { a as PersistedEventSource, b as PersistedEventSourceType, c as PersistedEventStatus, d as PersistedInspectError, e as PersistedSchemaVersion, f as PersistedTokenUsage, g as PersistedTraceContext, i as isPersistedInspectEvent } from './persisted-inspect-event-DHPfzUd8.cjs';
|
|
6
7
|
export { InspectEventToPersistedOptions, PersistedToInspectEventOptions, PersistedToTraceEventOptions, PersistedTreeBridgeOptions, TraceEventToPersistedOptions, inspectEventToPersistedInspectEvent, inspectEventsToPersistedInspectEvents, persistedInspectEventToInspectEvent, persistedInspectEventToTraceEvents, persistedInspectEventsToInspectEvents, persistedInspectEventsToRunTrees, persistedInspectEventsToTraceEvents, traceEventToPersistedInspectEvent, traceEventsToPersistedInspectEvents, traceEventsToPersistedRunTrees } from './persisted.cjs';
|
|
7
|
-
export { L as LogEventMapping, a as LogIngestConfig, R as RedactionRule, b as RedactionStrategy } from './log-config-
|
|
8
|
+
export { L as LogEventMapping, a as LogIngestConfig, R as RedactionRule, b as RedactionStrategy } from './log-config-DanPV3P9.cjs';
|
|
8
9
|
export { DEFAULT_LOG_INGEST_CONFIG, DEFAULT_REDACT_KEYS, EventNormalizer, JsonLogParser, LiveLogAccumulator, LiveLogAccumulatorOptions, LiveLogUpdate, Log4jsParser, LogSourceFormat, LogToTreeResult, NormalizeOptions, ParseLogLineOptions, ParseLogsOptions, ParseResult, ParserWarning, ParserWarningCode, RawLogRecord, Redactor, RedactorOptions, RenderTreeOptions, TreeBuilder, TreeBuilderOptions, loadLogIngestConfig, matchMapping, mergeLogIngestConfig, parseLogLine, parseLogsToTrees, renderRunTree, renderRunTrees, wildcardMatch } from './logs.cjs';
|
|
9
10
|
export { CreateInspectorOptions, DEFAULT_MAX_EVENT_BYTES, DEFAULT_MAX_METADATA_VALUE_LENGTH, DEFAULT_MAX_PREVIEW_LENGTH, DEFAULT_TRACE_DIR_NAME, FALLBACK_TRACE_DIR, Inspector, InspectorCaptureOptions, InspectorObserveOptions, InspectorRunOptions, InspectorRuntime, InspectorRuntimeContext, InspectorRuntimeDiagnostics, InspectorRuntimeOptions, InspectorStepOptions, MAX_NAME_LENGTH, MAX_TERMINAL_DEPTH, MAX_TERMINAL_NAME_LENGTH, RUNS_DIR_NAME, ResolvedRedactionProfile, TERMINAL_INDENT, TraceSafetyOptions, createInspector, createInspectorRuntime, createRunId, createStepId, ensureTraceDir, formatDuration, formatError, formatTerminalName, formatTimestamp, getCurrentContext, getCurrentCorrelationMetadata, getCurrentDepth, getCurrentRunId, getCurrentRunName, getCurrentStepId, getDefaultTraceDir, getIndent, getParentStepId, getTraceDirFromContext, getTraceFilePath, getTraceSafetyFromContext, hasActiveContext, isSilentContext, prepareMetadataForDisk, prepareTraceEventForDisk, printError, printFailedAt, printRunComplete, printRunStart, printStepComplete, printStepStart, renderErrorLine, renderRunSummary, renderStepLine, resolveRedactionProfile, resolveTraceSafetyOptions, runWithContext, runWithStepContext, truncateName, warn } from './advanced.cjs';
|
|
10
11
|
import { Stats } from 'node:fs';
|
|
@@ -202,6 +203,42 @@ interface ReportResult {
|
|
|
202
203
|
*/
|
|
203
204
|
declare function buildRunReport(events: TraceEvent[], options: ReportOptions): ReportResult;
|
|
204
205
|
|
|
206
|
+
type ExplainMode = "dry-run" | "local";
|
|
207
|
+
interface ExplainFact {
|
|
208
|
+
id: string;
|
|
209
|
+
label: string;
|
|
210
|
+
value: unknown;
|
|
211
|
+
source: "trace";
|
|
212
|
+
confidence: "observed";
|
|
213
|
+
}
|
|
214
|
+
interface ExplainInference {
|
|
215
|
+
id: string;
|
|
216
|
+
label: string;
|
|
217
|
+
text: string;
|
|
218
|
+
evidence: string[];
|
|
219
|
+
confidence: "deterministic";
|
|
220
|
+
}
|
|
221
|
+
interface ExplainResult {
|
|
222
|
+
mode: ExplainMode;
|
|
223
|
+
runId: string;
|
|
224
|
+
name?: string;
|
|
225
|
+
status?: string;
|
|
226
|
+
redactionProfile: RedactionProfile;
|
|
227
|
+
facts: ExplainFact[];
|
|
228
|
+
inferences: ExplainInference[];
|
|
229
|
+
notes: string[];
|
|
230
|
+
}
|
|
231
|
+
interface ExplainOptions {
|
|
232
|
+
mode?: ExplainMode;
|
|
233
|
+
redactionProfile?: RedactionProfile;
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Build a local, deterministic explanation payload from a reader-selected run.
|
|
237
|
+
*
|
|
238
|
+
* This helper performs no network I/O and does not call a model provider.
|
|
239
|
+
*/
|
|
240
|
+
declare function buildLocalExplanation(run: InspectRunTree, options?: ExplainOptions): ExplainResult;
|
|
241
|
+
|
|
205
242
|
interface DurationStats {
|
|
206
243
|
minMs?: number;
|
|
207
244
|
maxMs?: number;
|
|
@@ -347,4 +384,4 @@ declare const step: StepFunction;
|
|
|
347
384
|
*/
|
|
348
385
|
declare function observe<T>(agent: T, options?: ObserveOptions): T;
|
|
349
386
|
|
|
350
|
-
export { type DurationStats, InspectRunOptions, ObserveOptions, type ParseTraceJsonlOptions, type ParseTraceJsonlResult, type ParsedDurationFilter, PersistedInspectEvent, RedactionProfile, type RenderTimelineOptions, type RenderWhatOptions, type ReportFormat, type ReportOptions, type ReportResult, RunSummary, type RunTimeline, type RunWhatSummary, StepOptions, StepStatus, StepType, type TimelineEntry, type TimelineFocus, type TimelineOptions, TraceCorrelationMetadata, TraceDirectory, type TraceDirectoryOptions, TraceEvent, type TraceFilterOptions, type TraceJsonlFormat, TraceMetadata, TraceMetadataStatus, type TraceSearchOptions, type TraceSearchResult, type TraceStats, type TraceStatsOptions, type TraceStatsRankedRun, type TraceStatsRankedStep, buildRunReport, buildRunSummary, buildRunTimeline, buildRunWhatSummary, buildTraceStats, extractMetadata, filterTraces, getRunIdFromTraceFileName, initializeTraceFile, inspectRun, isAgentInspectEnabled, isAgentInspectTrace, listTraceFiles, loadTraceMetadataList, maybeInspectRun, observe, parseDuration, parseDurationFilter, parseTraceJsonl, readTraceEvents, readTraceFile, renderRunWhat, renderTimeline, renderTraceStats, resolveTraceDir, searchTraces, serializeEvent, step, unknownTraceFormatMessage, validateEvent, writeTraceEvent };
|
|
387
|
+
export { type DurationStats, type ExplainFact, type ExplainInference, type ExplainMode, type ExplainOptions, type ExplainResult, InspectRunOptions, InspectRunTree, ObserveOptions, type ParseTraceJsonlOptions, type ParseTraceJsonlResult, type ParsedDurationFilter, PersistedInspectEvent, RedactionProfile, type RenderTimelineOptions, type RenderWhatOptions, type ReportFormat, type ReportOptions, type ReportResult, RunSummary, type RunTimeline, type RunWhatSummary, StepOptions, StepStatus, StepType, type TimelineEntry, type TimelineFocus, type TimelineOptions, TraceCorrelationMetadata, TraceDirectory, type TraceDirectoryOptions, TraceEvent, type TraceFilterOptions, type TraceJsonlFormat, TraceMetadata, TraceMetadataStatus, type TraceSearchOptions, type TraceSearchResult, type TraceStats, type TraceStatsOptions, type TraceStatsRankedRun, type TraceStatsRankedStep, buildLocalExplanation, buildRunReport, buildRunSummary, buildRunTimeline, buildRunWhatSummary, buildTraceStats, extractMetadata, filterTraces, getRunIdFromTraceFileName, initializeTraceFile, inspectRun, isAgentInspectEnabled, isAgentInspectTrace, listTraceFiles, loadTraceMetadataList, maybeInspectRun, observe, parseDuration, parseDurationFilter, parseTraceJsonl, readTraceEvents, readTraceFile, renderRunWhat, renderTimeline, renderTraceStats, resolveTraceDir, searchTraces, serializeEvent, step, unknownTraceFormatMessage, validateEvent, writeTraceEvent };
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { T as TraceEvent, R as RunSummary, a as TraceMetadata, b as TraceMetadataStatus, S as StepType, c as StepStatus, d as TraceCorrelationMetadata, e as RedactionProfile, I as InspectRunOptions, f as StepOptions, O as ObserveOptions } from './types-
|
|
2
|
-
export { A as ActiveStepContext, E as ErrorInfo, g as ExecutionContext, h as Run, i as RunCompletedEvent, j as RunStartedEvent, k as RunStatus, l as Step, m as StepCompletedEvent, n as StepMetadata, o as StepStartedEvent, p as TokenMetadata, q as TraceEventBase, r as TraceSchemaVersion, s as isStepStatus, t as isStepType, u as isTraceEvent } from './types-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { T as TraceEvent, R as RunSummary, a as TraceMetadata, b as TraceMetadataStatus, S as StepType, c as StepStatus, d as TraceCorrelationMetadata, e as RedactionProfile, I as InspectRunOptions, f as StepOptions, O as ObserveOptions } from './types-Ap9uMdx_.js';
|
|
2
|
+
export { A as ActiveStepContext, E as ErrorInfo, g as ExecutionContext, h as Run, i as RunCompletedEvent, j as RunStartedEvent, k as RunStatus, l as Step, m as StepCompletedEvent, n as StepMetadata, o as StepStartedEvent, p as TokenMetadata, q as TraceEventBase, r as TraceSchemaVersion, s as isStepStatus, t as isStepType, u as isTraceEvent } from './types-Ap9uMdx_.js';
|
|
3
|
+
import { a as InspectRunTree } from './inspect-event-CevRYp58.js';
|
|
4
|
+
export { A as AttributionConfidence, E as EventSource, c as InspectEvent, I as InspectKind, b as InspectNode } from './inspect-event-CevRYp58.js';
|
|
5
|
+
import { P as PersistedInspectEvent } from './persisted-inspect-event-Cw7TeYGr.js';
|
|
6
|
+
export { a as PersistedEventSource, b as PersistedEventSourceType, c as PersistedEventStatus, d as PersistedInspectError, e as PersistedSchemaVersion, f as PersistedTokenUsage, g as PersistedTraceContext, i as isPersistedInspectEvent } from './persisted-inspect-event-Cw7TeYGr.js';
|
|
6
7
|
export { InspectEventToPersistedOptions, PersistedToInspectEventOptions, PersistedToTraceEventOptions, PersistedTreeBridgeOptions, TraceEventToPersistedOptions, inspectEventToPersistedInspectEvent, inspectEventsToPersistedInspectEvents, persistedInspectEventToInspectEvent, persistedInspectEventToTraceEvents, persistedInspectEventsToInspectEvents, persistedInspectEventsToRunTrees, persistedInspectEventsToTraceEvents, traceEventToPersistedInspectEvent, traceEventsToPersistedInspectEvents, traceEventsToPersistedRunTrees } from './persisted.js';
|
|
7
|
-
export { L as LogEventMapping, a as LogIngestConfig, R as RedactionRule, b as RedactionStrategy } from './log-config-
|
|
8
|
+
export { L as LogEventMapping, a as LogIngestConfig, R as RedactionRule, b as RedactionStrategy } from './log-config-BPHS4Sds.js';
|
|
8
9
|
export { DEFAULT_LOG_INGEST_CONFIG, DEFAULT_REDACT_KEYS, EventNormalizer, JsonLogParser, LiveLogAccumulator, LiveLogAccumulatorOptions, LiveLogUpdate, Log4jsParser, LogSourceFormat, LogToTreeResult, NormalizeOptions, ParseLogLineOptions, ParseLogsOptions, ParseResult, ParserWarning, ParserWarningCode, RawLogRecord, Redactor, RedactorOptions, RenderTreeOptions, TreeBuilder, TreeBuilderOptions, loadLogIngestConfig, matchMapping, mergeLogIngestConfig, parseLogLine, parseLogsToTrees, renderRunTree, renderRunTrees, wildcardMatch } from './logs.js';
|
|
9
10
|
export { CreateInspectorOptions, DEFAULT_MAX_EVENT_BYTES, DEFAULT_MAX_METADATA_VALUE_LENGTH, DEFAULT_MAX_PREVIEW_LENGTH, DEFAULT_TRACE_DIR_NAME, FALLBACK_TRACE_DIR, Inspector, InspectorCaptureOptions, InspectorObserveOptions, InspectorRunOptions, InspectorRuntime, InspectorRuntimeContext, InspectorRuntimeDiagnostics, InspectorRuntimeOptions, InspectorStepOptions, MAX_NAME_LENGTH, MAX_TERMINAL_DEPTH, MAX_TERMINAL_NAME_LENGTH, RUNS_DIR_NAME, ResolvedRedactionProfile, TERMINAL_INDENT, TraceSafetyOptions, createInspector, createInspectorRuntime, createRunId, createStepId, ensureTraceDir, formatDuration, formatError, formatTerminalName, formatTimestamp, getCurrentContext, getCurrentCorrelationMetadata, getCurrentDepth, getCurrentRunId, getCurrentRunName, getCurrentStepId, getDefaultTraceDir, getIndent, getParentStepId, getTraceDirFromContext, getTraceFilePath, getTraceSafetyFromContext, hasActiveContext, isSilentContext, prepareMetadataForDisk, prepareTraceEventForDisk, printError, printFailedAt, printRunComplete, printRunStart, printStepComplete, printStepStart, renderErrorLine, renderRunSummary, renderStepLine, resolveRedactionProfile, resolveTraceSafetyOptions, runWithContext, runWithStepContext, truncateName, warn } from './advanced.js';
|
|
10
11
|
import { Stats } from 'node:fs';
|
|
@@ -202,6 +203,42 @@ interface ReportResult {
|
|
|
202
203
|
*/
|
|
203
204
|
declare function buildRunReport(events: TraceEvent[], options: ReportOptions): ReportResult;
|
|
204
205
|
|
|
206
|
+
type ExplainMode = "dry-run" | "local";
|
|
207
|
+
interface ExplainFact {
|
|
208
|
+
id: string;
|
|
209
|
+
label: string;
|
|
210
|
+
value: unknown;
|
|
211
|
+
source: "trace";
|
|
212
|
+
confidence: "observed";
|
|
213
|
+
}
|
|
214
|
+
interface ExplainInference {
|
|
215
|
+
id: string;
|
|
216
|
+
label: string;
|
|
217
|
+
text: string;
|
|
218
|
+
evidence: string[];
|
|
219
|
+
confidence: "deterministic";
|
|
220
|
+
}
|
|
221
|
+
interface ExplainResult {
|
|
222
|
+
mode: ExplainMode;
|
|
223
|
+
runId: string;
|
|
224
|
+
name?: string;
|
|
225
|
+
status?: string;
|
|
226
|
+
redactionProfile: RedactionProfile;
|
|
227
|
+
facts: ExplainFact[];
|
|
228
|
+
inferences: ExplainInference[];
|
|
229
|
+
notes: string[];
|
|
230
|
+
}
|
|
231
|
+
interface ExplainOptions {
|
|
232
|
+
mode?: ExplainMode;
|
|
233
|
+
redactionProfile?: RedactionProfile;
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Build a local, deterministic explanation payload from a reader-selected run.
|
|
237
|
+
*
|
|
238
|
+
* This helper performs no network I/O and does not call a model provider.
|
|
239
|
+
*/
|
|
240
|
+
declare function buildLocalExplanation(run: InspectRunTree, options?: ExplainOptions): ExplainResult;
|
|
241
|
+
|
|
205
242
|
interface DurationStats {
|
|
206
243
|
minMs?: number;
|
|
207
244
|
maxMs?: number;
|
|
@@ -347,4 +384,4 @@ declare const step: StepFunction;
|
|
|
347
384
|
*/
|
|
348
385
|
declare function observe<T>(agent: T, options?: ObserveOptions): T;
|
|
349
386
|
|
|
350
|
-
export { type DurationStats, InspectRunOptions, ObserveOptions, type ParseTraceJsonlOptions, type ParseTraceJsonlResult, type ParsedDurationFilter, PersistedInspectEvent, RedactionProfile, type RenderTimelineOptions, type RenderWhatOptions, type ReportFormat, type ReportOptions, type ReportResult, RunSummary, type RunTimeline, type RunWhatSummary, StepOptions, StepStatus, StepType, type TimelineEntry, type TimelineFocus, type TimelineOptions, TraceCorrelationMetadata, TraceDirectory, type TraceDirectoryOptions, TraceEvent, type TraceFilterOptions, type TraceJsonlFormat, TraceMetadata, TraceMetadataStatus, type TraceSearchOptions, type TraceSearchResult, type TraceStats, type TraceStatsOptions, type TraceStatsRankedRun, type TraceStatsRankedStep, buildRunReport, buildRunSummary, buildRunTimeline, buildRunWhatSummary, buildTraceStats, extractMetadata, filterTraces, getRunIdFromTraceFileName, initializeTraceFile, inspectRun, isAgentInspectEnabled, isAgentInspectTrace, listTraceFiles, loadTraceMetadataList, maybeInspectRun, observe, parseDuration, parseDurationFilter, parseTraceJsonl, readTraceEvents, readTraceFile, renderRunWhat, renderTimeline, renderTraceStats, resolveTraceDir, searchTraces, serializeEvent, step, unknownTraceFormatMessage, validateEvent, writeTraceEvent };
|
|
387
|
+
export { type DurationStats, type ExplainFact, type ExplainInference, type ExplainMode, type ExplainOptions, type ExplainResult, InspectRunOptions, InspectRunTree, ObserveOptions, type ParseTraceJsonlOptions, type ParseTraceJsonlResult, type ParsedDurationFilter, PersistedInspectEvent, RedactionProfile, type RenderTimelineOptions, type RenderWhatOptions, type ReportFormat, type ReportOptions, type ReportResult, RunSummary, type RunTimeline, type RunWhatSummary, StepOptions, StepStatus, StepType, type TimelineEntry, type TimelineFocus, type TimelineOptions, TraceCorrelationMetadata, TraceDirectory, type TraceDirectoryOptions, TraceEvent, type TraceFilterOptions, type TraceJsonlFormat, TraceMetadata, TraceMetadataStatus, type TraceSearchOptions, type TraceSearchResult, type TraceStats, type TraceStatsOptions, type TraceStatsRankedRun, type TraceStatsRankedStep, buildLocalExplanation, buildRunReport, buildRunSummary, buildRunTimeline, buildRunWhatSummary, buildTraceStats, extractMetadata, filterTraces, getRunIdFromTraceFileName, initializeTraceFile, inspectRun, isAgentInspectEnabled, isAgentInspectTrace, listTraceFiles, loadTraceMetadataList, maybeInspectRun, observe, parseDuration, parseDurationFilter, parseTraceJsonl, readTraceEvents, readTraceFile, renderRunWhat, renderTimeline, renderTraceStats, resolveTraceDir, searchTraces, serializeEvent, step, unknownTraceFormatMessage, validateEvent, writeTraceEvent };
|
|
@@ -11,7 +11,9 @@ export { compactAttributes, escapeHtml, escapeMarkdown, flattenTree, safeString,
|
|
|
11
11
|
export { bufferedFileWriter, compositeWriter, fileWriter, memoryWriter, nullWriter } from './chunk-6SZPTECC.mjs';
|
|
12
12
|
import { readTraceEventsFromFile, resolveTraceSafetyOptions, prepareTraceEventForDisk, writeTraceEvent, initializeTraceFile } from './chunk-57S5D6HR.mjs';
|
|
13
13
|
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-57S5D6HR.mjs';
|
|
14
|
+
import { resolveRedactionProfile } from './chunk-EDTQHZPM.mjs';
|
|
14
15
|
export { resolveRedactionProfile } from './chunk-EDTQHZPM.mjs';
|
|
16
|
+
import { Redactor } from './chunk-VU6O5QAH.mjs';
|
|
15
17
|
export { DEFAULT_REDACT_KEYS, Redactor } from './chunk-VU6O5QAH.mjs';
|
|
16
18
|
export { DEFAULT_TRACE_READERS, TraceReadError, agentInspectJsonlReader, detectTraceFormat, openTrace, readTrace } from './chunk-TFLPUZ56.mjs';
|
|
17
19
|
export { persistedInspectEventToInspectEvent, persistedInspectEventsToInspectEvents, persistedInspectEventsToRunTrees, traceEventToPersistedInspectEvent, traceEventsToPersistedInspectEvents, traceEventsToPersistedRunTrees } from './chunk-TZISEVLQ.mjs';
|
|
@@ -757,6 +759,151 @@ ${attrsSection}
|
|
|
757
759
|
};
|
|
758
760
|
}
|
|
759
761
|
|
|
762
|
+
// packages/core/src/explain.ts
|
|
763
|
+
function flatten(nodes, out = []) {
|
|
764
|
+
for (const node of nodes) {
|
|
765
|
+
out.push({ node, index: out.length + 1 });
|
|
766
|
+
flatten(node.children, out);
|
|
767
|
+
}
|
|
768
|
+
return out;
|
|
769
|
+
}
|
|
770
|
+
function redactValue(redactor, key, value) {
|
|
771
|
+
return redactor.redactValue(key, value);
|
|
772
|
+
}
|
|
773
|
+
function fact(id, label, value, redactor) {
|
|
774
|
+
return {
|
|
775
|
+
id,
|
|
776
|
+
label,
|
|
777
|
+
value: redactValue(redactor, id.split(".").at(-1) ?? id, value),
|
|
778
|
+
source: "trace",
|
|
779
|
+
confidence: "observed"
|
|
780
|
+
};
|
|
781
|
+
}
|
|
782
|
+
function topKinds(run) {
|
|
783
|
+
return Object.entries(run.metadata.kinds).filter(([, count]) => count > 0).sort((a, b) => {
|
|
784
|
+
if (b[1] !== a[1]) return b[1] - a[1];
|
|
785
|
+
return a[0].localeCompare(b[0]);
|
|
786
|
+
}).slice(0, 5).map(([kind, count]) => `${kind}:${count}`);
|
|
787
|
+
}
|
|
788
|
+
function countErrorNodes(nodes) {
|
|
789
|
+
return nodes.filter((entry) => entry.node.event.status === "error").length;
|
|
790
|
+
}
|
|
791
|
+
function slowestNode(nodes) {
|
|
792
|
+
return nodes.filter((entry) => entry.node.event.durationMs !== void 0).sort((a, b) => {
|
|
793
|
+
const delta = (b.node.event.durationMs ?? 0) - (a.node.event.durationMs ?? 0);
|
|
794
|
+
return delta !== 0 ? delta : a.index - b.index;
|
|
795
|
+
})[0];
|
|
796
|
+
}
|
|
797
|
+
function attributeFacts(nodes, redactor) {
|
|
798
|
+
const facts = [];
|
|
799
|
+
for (const entry of nodes) {
|
|
800
|
+
const attrs = entry.node.event.attributes;
|
|
801
|
+
if (attrs === void 0) continue;
|
|
802
|
+
for (const key of Object.keys(attrs).sort()) {
|
|
803
|
+
facts.push({
|
|
804
|
+
id: `node.${entry.index}.attributes.${key}`,
|
|
805
|
+
label: `${entry.node.event.name} attribute ${key}`,
|
|
806
|
+
value: redactValue(redactor, key, attrs[key]),
|
|
807
|
+
source: "trace",
|
|
808
|
+
confidence: "observed"
|
|
809
|
+
});
|
|
810
|
+
if (facts.length >= 8) return facts;
|
|
811
|
+
}
|
|
812
|
+
}
|
|
813
|
+
return facts;
|
|
814
|
+
}
|
|
815
|
+
function buildFacts(run, redactor) {
|
|
816
|
+
const nodes = flatten(run.children);
|
|
817
|
+
const facts = [
|
|
818
|
+
fact("run.id", "Run id", run.runId, redactor),
|
|
819
|
+
fact("run.name", "Run name", run.name ?? run.runId, redactor),
|
|
820
|
+
fact("run.status", "Run status", run.status ?? "unknown", redactor),
|
|
821
|
+
fact("run.totalEvents", "Total events", run.metadata.totalEvents, redactor),
|
|
822
|
+
fact("run.stepCount", "Top-level step count", run.children.length, redactor),
|
|
823
|
+
fact("run.nodeCount", "Total node count", nodes.length, redactor),
|
|
824
|
+
fact("run.errorNodeCount", "Error node count", countErrorNodes(nodes), redactor),
|
|
825
|
+
fact("run.kinds", "Observed kind mix", topKinds(run), redactor)
|
|
826
|
+
];
|
|
827
|
+
if (run.durationMs !== void 0) {
|
|
828
|
+
facts.push(fact("run.durationMs", "Run duration milliseconds", run.durationMs, redactor));
|
|
829
|
+
}
|
|
830
|
+
const slowest = slowestNode(nodes);
|
|
831
|
+
if (slowest !== void 0) {
|
|
832
|
+
facts.push(
|
|
833
|
+
fact("run.slowestNode", "Slowest observed node", {
|
|
834
|
+
name: slowest.node.event.name,
|
|
835
|
+
kind: slowest.node.event.kind,
|
|
836
|
+
durationMs: slowest.node.event.durationMs
|
|
837
|
+
}, redactor)
|
|
838
|
+
);
|
|
839
|
+
}
|
|
840
|
+
facts.push(...attributeFacts(nodes, redactor));
|
|
841
|
+
return facts;
|
|
842
|
+
}
|
|
843
|
+
function buildInferences(run, facts) {
|
|
844
|
+
const inferences = [];
|
|
845
|
+
const errorFact = facts.find((item) => item.id === "run.errorNodeCount");
|
|
846
|
+
const kindFact = facts.find((item) => item.id === "run.kinds");
|
|
847
|
+
const durationFact = facts.find((item) => item.id === "run.durationMs");
|
|
848
|
+
const errorNodeCount = typeof errorFact?.value === "number" ? errorFact.value : 0;
|
|
849
|
+
if (run.status === "error" || errorNodeCount > 0) {
|
|
850
|
+
inferences.push({
|
|
851
|
+
id: "outcome.error",
|
|
852
|
+
label: "Outcome",
|
|
853
|
+
text: "The run recorded an error status or at least one error node.",
|
|
854
|
+
evidence: ["run.status", "run.errorNodeCount"],
|
|
855
|
+
confidence: "deterministic"
|
|
856
|
+
});
|
|
857
|
+
} else if (run.status === "ok") {
|
|
858
|
+
inferences.push({
|
|
859
|
+
id: "outcome.success",
|
|
860
|
+
label: "Outcome",
|
|
861
|
+
text: "The run completed without observed error nodes.",
|
|
862
|
+
evidence: ["run.status", "run.errorNodeCount"],
|
|
863
|
+
confidence: "deterministic"
|
|
864
|
+
});
|
|
865
|
+
}
|
|
866
|
+
if (kindFact !== void 0) {
|
|
867
|
+
inferences.push({
|
|
868
|
+
id: "shape.kind-mix",
|
|
869
|
+
label: "Trace shape",
|
|
870
|
+
text: "The explanation is based on the observed event kind mix, not generated content.",
|
|
871
|
+
evidence: [kindFact.id],
|
|
872
|
+
confidence: "deterministic"
|
|
873
|
+
});
|
|
874
|
+
}
|
|
875
|
+
if (durationFact !== void 0) {
|
|
876
|
+
inferences.push({
|
|
877
|
+
id: "timing.duration",
|
|
878
|
+
label: "Timing",
|
|
879
|
+
text: "Timing claims are limited to persisted duration fields in the trace.",
|
|
880
|
+
evidence: [durationFact.id],
|
|
881
|
+
confidence: "deterministic"
|
|
882
|
+
});
|
|
883
|
+
}
|
|
884
|
+
return inferences;
|
|
885
|
+
}
|
|
886
|
+
function buildLocalExplanation(run, options = {}) {
|
|
887
|
+
const redactionProfile = options.redactionProfile ?? "local";
|
|
888
|
+
const resolved = resolveRedactionProfile(redactionProfile);
|
|
889
|
+
const redactor = new Redactor({ extraKeys: resolved.extraKeys });
|
|
890
|
+
const mode = options.mode ?? "local";
|
|
891
|
+
const facts = buildFacts(run, redactor);
|
|
892
|
+
return {
|
|
893
|
+
mode,
|
|
894
|
+
runId: String(redactValue(redactor, "runId", run.runId)),
|
|
895
|
+
...run.name !== void 0 ? { name: String(redactValue(redactor, "name", run.name)) } : {},
|
|
896
|
+
...run.status !== void 0 ? { status: run.status } : {},
|
|
897
|
+
redactionProfile,
|
|
898
|
+
facts,
|
|
899
|
+
inferences: mode === "dry-run" ? [] : buildInferences(run, facts),
|
|
900
|
+
notes: [
|
|
901
|
+
"Generated locally without provider or network calls.",
|
|
902
|
+
"Facts are observed from normalized trace data; inferences are deterministic labels."
|
|
903
|
+
]
|
|
904
|
+
};
|
|
905
|
+
}
|
|
906
|
+
|
|
760
907
|
// packages/core/src/stats.ts
|
|
761
908
|
function percentile(sorted, p) {
|
|
762
909
|
if (sorted.length === 0) return void 0;
|
|
@@ -1521,6 +1668,6 @@ function observe(agent, options) {
|
|
|
1521
1668
|
}
|
|
1522
1669
|
}
|
|
1523
1670
|
|
|
1524
|
-
export { TraceDirectory, buildRunReport, buildRunSummary, buildRunTimeline, buildRunWhatSummary, buildTraceStats, extractMetadata, filterTraces, inspectRun, isAgentInspectEnabled, isAgentInspectTrace, loadTraceMetadataList, maybeInspectRun, observe, parseDurationFilter, renderRunWhat, renderTimeline, renderTraceStats, resolveTraceDir, searchTraces, step };
|
|
1671
|
+
export { TraceDirectory, buildLocalExplanation, buildRunReport, buildRunSummary, buildRunTimeline, buildRunWhatSummary, buildTraceStats, extractMetadata, filterTraces, inspectRun, isAgentInspectEnabled, isAgentInspectTrace, loadTraceMetadataList, maybeInspectRun, observe, parseDurationFilter, renderRunWhat, renderTimeline, renderTraceStats, resolveTraceDir, searchTraces, step };
|
|
1525
1672
|
//# sourceMappingURL=index.mjs.map
|
|
1526
1673
|
//# sourceMappingURL=index.mjs.map
|