agent-inspect 1.9.0 → 2.0.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 +6 -0
- package/README.md +13 -9
- package/docs/ADAPTER-CONFORMANCE.md +1 -1
- package/docs/API.md +30 -29
- package/docs/CLI.md +41 -11
- package/docs/EXPORTS.md +1 -1
- package/docs/GETTING-STARTED.md +2 -1
- package/docs/KNOWN-ISSUES.md +8 -3
- package/docs/LIMITATIONS.md +6 -6
- package/docs/MIGRATION.md +8 -8
- package/docs/SCHEMA.md +29 -12
- package/package.json +1 -1
- package/packages/cli/dist/index.cjs +7135 -7481
- package/packages/cli/dist/index.cjs.map +1 -1
- package/packages/cli/dist/index.mjs +7135 -7481
- package/packages/cli/dist/index.mjs.map +1 -1
- package/packages/core/dist/advanced.cjs +2047 -26
- package/packages/core/dist/advanced.cjs.map +1 -1
- package/packages/core/dist/advanced.d.cts +346 -196
- package/packages/core/dist/advanced.d.ts +346 -196
- package/packages/core/dist/advanced.mjs +628 -5
- package/packages/core/dist/advanced.mjs.map +1 -1
- package/packages/core/dist/checks.d.cts +1 -1
- package/packages/core/dist/checks.d.ts +1 -1
- package/packages/core/dist/chunk-2ZXEMWGK.mjs +549 -0
- package/packages/core/dist/chunk-2ZXEMWGK.mjs.map +1 -0
- package/packages/core/dist/{chunk-57S5D6HR.mjs → chunk-4JVGFNQH.mjs} +50 -6
- package/packages/core/dist/chunk-4JVGFNQH.mjs.map +1 -0
- package/packages/core/dist/{chunk-6QSLZCBJ.mjs → chunk-A4V2H3YU.mjs} +329 -163
- package/packages/core/dist/chunk-A4V2H3YU.mjs.map +1 -0
- package/packages/core/dist/{chunk-74XZ6N7Q.mjs → chunk-IZBJAZGF.mjs} +12 -4
- package/packages/core/dist/chunk-IZBJAZGF.mjs.map +1 -0
- package/packages/core/dist/{chunk-VTIB5MDK.mjs → chunk-NQZPZ2FN.mjs} +15 -10
- package/packages/core/dist/chunk-NQZPZ2FN.mjs.map +1 -0
- package/packages/core/dist/{chunk-TZISEVLQ.mjs → chunk-XUNJMAPD.mjs} +3 -3
- package/packages/core/dist/{chunk-TZISEVLQ.mjs.map → chunk-XUNJMAPD.mjs.map} +1 -1
- package/packages/core/dist/context-CSKnzpXR.d.cts +177 -0
- package/packages/core/dist/context-yv2VSDQF.d.ts +177 -0
- package/packages/core/dist/diff.d.cts +2 -2
- package/packages/core/dist/diff.d.ts +2 -2
- package/packages/core/dist/diff.mjs +473 -3
- package/packages/core/dist/diff.mjs.map +1 -1
- package/packages/core/dist/exporters.cjs +691 -0
- package/packages/core/dist/exporters.cjs.map +1 -1
- package/packages/core/dist/exporters.d.cts +24 -3
- package/packages/core/dist/exporters.d.ts +24 -3
- package/packages/core/dist/exporters.mjs +1113 -3
- package/packages/core/dist/exporters.mjs.map +1 -1
- package/packages/core/dist/index.cjs +1385 -8168
- package/packages/core/dist/index.cjs.map +1 -1
- package/packages/core/dist/index.d.cts +8 -350
- package/packages/core/dist/index.d.ts +8 -350
- package/packages/core/dist/index.mjs +18 -1478
- package/packages/core/dist/index.mjs.map +1 -1
- package/packages/core/dist/{log-config-DanPV3P9.d.cts → log-config-8aE5Kxtr.d.cts} +1 -1
- package/packages/core/dist/{log-config-BPHS4Sds.d.ts → log-config-DVimQJho.d.ts} +1 -1
- package/packages/core/dist/logs.d.cts +2 -2
- package/packages/core/dist/logs.d.ts +2 -2
- package/packages/core/dist/logs.mjs +785 -2
- package/packages/core/dist/logs.mjs.map +1 -1
- package/packages/core/dist/{persisted-inspect-event-Cw7TeYGr.d.ts → persisted-inspect-event-D-WpXeZX.d.ts} +14 -5
- package/packages/core/dist/{persisted-inspect-event-DHPfzUd8.d.cts → persisted-inspect-event-DHcHPUKv.d.cts} +14 -5
- package/packages/core/dist/persisted.cjs +11 -1
- package/packages/core/dist/persisted.cjs.map +1 -1
- package/packages/core/dist/persisted.d.cts +4 -4
- package/packages/core/dist/persisted.d.ts +4 -4
- package/packages/core/dist/persisted.mjs +150 -3
- package/packages/core/dist/persisted.mjs.map +1 -1
- package/packages/core/dist/readers.cjs +27 -10
- package/packages/core/dist/readers.cjs.map +1 -1
- package/packages/core/dist/readers.d.cts +1 -1
- package/packages/core/dist/readers.d.ts +1 -1
- package/packages/core/dist/readers.mjs +1580 -4
- package/packages/core/dist/readers.mjs.map +1 -1
- package/packages/core/dist/{types-Ap9uMdx_.d.ts → types-D-Y1kOU-.d.ts} +2 -2
- package/packages/core/dist/{types-B2-BU5CS.d.cts → types-DgMN3qow.d.cts} +2 -2
- package/packages/core/dist/writers.cjs +49 -3
- package/packages/core/dist/writers.cjs.map +1 -1
- package/packages/core/dist/writers.d.cts +1 -1
- package/packages/core/dist/writers.d.ts +1 -1
- package/packages/core/dist/writers.mjs +341 -4
- package/packages/core/dist/writers.mjs.map +1 -1
- package/packages/core/dist/chunk-57S5D6HR.mjs.map +0 -1
- package/packages/core/dist/chunk-6QSLZCBJ.mjs.map +0 -1
- package/packages/core/dist/chunk-6SZPTECC.mjs +0 -342
- package/packages/core/dist/chunk-6SZPTECC.mjs.map +0 -1
- package/packages/core/dist/chunk-74XZ6N7Q.mjs.map +0 -1
- package/packages/core/dist/chunk-HR7G62IE.mjs +0 -785
- package/packages/core/dist/chunk-HR7G62IE.mjs.map +0 -1
- package/packages/core/dist/chunk-TFLPUZ56.mjs +0 -1571
- package/packages/core/dist/chunk-TFLPUZ56.mjs.map +0 -1
- package/packages/core/dist/chunk-U2BGPESY.mjs +0 -150
- package/packages/core/dist/chunk-U2BGPESY.mjs.map +0 -1
- package/packages/core/dist/chunk-VTIB5MDK.mjs.map +0 -1
- package/packages/core/dist/chunk-Y56BPA3B.mjs +0 -990
- package/packages/core/dist/chunk-Y56BPA3B.mjs.map +0 -1
- package/packages/core/dist/chunk-YWAOOXLR.mjs +0 -475
- package/packages/core/dist/chunk-YWAOOXLR.mjs.map +0 -1
|
@@ -1,8 +1,50 @@
|
|
|
1
|
-
|
|
2
|
-
import { R as
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
|
|
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-CSKnzpXR.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-DgMN3qow.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-DgMN3qow.cjs';
|
|
4
|
+
import { a as InspectRunTree } from './inspect-event-CevRYp58.cjs';
|
|
5
|
+
export { A as AttributionConfidence, E as EventSource, c as InspectEvent, I as InspectKind, b as InspectNode } from './inspect-event-CevRYp58.cjs';
|
|
6
|
+
import { P as PersistedInspectEvent } from './persisted-inspect-event-DHcHPUKv.cjs';
|
|
7
|
+
import { Stats } from 'node:fs';
|
|
8
|
+
import './writers.cjs';
|
|
9
|
+
import './log-config-8aE5Kxtr.cjs';
|
|
10
|
+
|
|
11
|
+
interface ResolvedRedactionProfile {
|
|
12
|
+
profile: RedactionProfile;
|
|
13
|
+
extraKeys: readonly string[];
|
|
14
|
+
maxMetadataValueLengthCap?: number;
|
|
15
|
+
maxPreviewLengthCap?: number;
|
|
16
|
+
}
|
|
17
|
+
/** Resolves named profile behavior (keys + metadata string caps). */
|
|
18
|
+
declare function resolveRedactionProfile(profile?: RedactionProfile): ResolvedRedactionProfile;
|
|
19
|
+
|
|
20
|
+
/** Two spaces per nesting level in terminal output. */
|
|
21
|
+
declare const TERMINAL_INDENT = " ";
|
|
22
|
+
/** Max display length for names in terminal output. */
|
|
23
|
+
declare const MAX_TERMINAL_NAME_LENGTH = 80;
|
|
24
|
+
/** Max nesting depth used for indentation (prevents huge indents). */
|
|
25
|
+
declare const MAX_TERMINAL_DEPTH = 10;
|
|
26
|
+
/** Indentation string for a nesting depth (capped, never negative). */
|
|
27
|
+
declare function getIndent(depth: number): string;
|
|
28
|
+
/** Truncates a display name for terminal use; invalid input becomes `"unnamed"`. */
|
|
29
|
+
declare function formatTerminalName(name: string): string;
|
|
30
|
+
/** Renders a single step line (colored); does not consult silent mode. */
|
|
31
|
+
declare function renderStepLine(name: string, durationMs: number | undefined, status: StepStatus, depth?: number): string;
|
|
32
|
+
/** Renders an error summary line (no stack in MVP). */
|
|
33
|
+
declare function renderErrorLine(error: ErrorInfo, depth?: number): string;
|
|
34
|
+
/** Plain-text run summary lines (no chalk) for stable testing and CLI reuse. */
|
|
35
|
+
declare function renderRunSummary(durationMs: number, status: RunStatus, traceFilePath?: string): string[];
|
|
36
|
+
/** Prints run header with icon and dim run id. */
|
|
37
|
+
declare function printRunStart(runId: string, name: string): void;
|
|
38
|
+
/** Prints a running step line. */
|
|
39
|
+
declare function printStepStart(name: string, depth?: number): void;
|
|
40
|
+
/** Prints a completed step line with duration and status icon. */
|
|
41
|
+
declare function printStepComplete(name: string, durationMs: number, status: StepStatus, depth?: number): void;
|
|
42
|
+
/** Prints a structured error line (message only, no stack). */
|
|
43
|
+
declare function printError(error: ErrorInfo, depth?: number): void;
|
|
44
|
+
/** Prints run completion summary and optional trace path. */
|
|
45
|
+
declare function printRunComplete(_name: string, _runId: string, durationMs: number, status: RunStatus, traceFilePath?: string): void;
|
|
46
|
+
/** Prints which step failed. */
|
|
47
|
+
declare function printFailedAt(stepName: string): void;
|
|
6
48
|
|
|
7
49
|
/** Default folder under the user home for AgentInspect data. */
|
|
8
50
|
declare const DEFAULT_TRACE_DIR_NAME = ".agent-inspect";
|
|
@@ -55,200 +97,308 @@ declare function truncateName(name: string, maxLength?: number): string;
|
|
|
55
97
|
*/
|
|
56
98
|
declare function warn(message: string, error?: unknown): void;
|
|
57
99
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
100
|
+
/**
|
|
101
|
+
* Strict MVP validation before writing JSONL. Rejects empty ids, non-finite times, and malformed payloads.
|
|
102
|
+
*/
|
|
103
|
+
declare function validateEvent(event: unknown): event is TraceEvent;
|
|
104
|
+
/** Serializes a trace line as compact JSON without a trailing newline. */
|
|
105
|
+
declare function serializeEvent(event: TraceEvent): string;
|
|
106
|
+
/**
|
|
107
|
+
* Creates (or truncates) an empty JSONL file for a run. Uses {@link ensureTraceDir} then {@link getTraceFilePath}.
|
|
108
|
+
* On failure, retries once under {@link FALLBACK_TRACE_DIR}.
|
|
109
|
+
*/
|
|
110
|
+
declare function initializeTraceFile(runId: string, traceDir: string): Promise<string | undefined>;
|
|
111
|
+
declare function writeTraceEvent(event: TraceEvent, traceDir: string): Promise<void>;
|
|
112
|
+
/**
|
|
113
|
+
* Reads raw JSONL file contents for a run, or `undefined` if missing or unreadable.
|
|
114
|
+
*/
|
|
115
|
+
declare function readTraceFile(runId: string, traceDir: string): Promise<string | undefined>;
|
|
116
|
+
/**
|
|
117
|
+
* Parses JSONL into validated {@link TraceEvent} rows (v0.1 native or v0.2 normalized).
|
|
118
|
+
* Invalid lines are skipped with a warning.
|
|
119
|
+
*/
|
|
120
|
+
declare function readTraceEvents(runId: string, traceDir: string): Promise<TraceEvent[]>;
|
|
121
|
+
/**
|
|
122
|
+
* Lists `.jsonl` file names in `traceDir`, newest by mtime first (name sort as tie-breaker).
|
|
123
|
+
*/
|
|
124
|
+
declare function listTraceFiles(traceDir: string): Promise<string[]>;
|
|
125
|
+
/** Maps a `.jsonl` file name to its run id (basename only; no traversal). */
|
|
126
|
+
declare function getRunIdFromTraceFileName(fileName: string): string | undefined;
|
|
127
|
+
|
|
128
|
+
type TraceJsonlFormat = "0.1" | "0.2" | "1.0" | "mixed" | "empty";
|
|
129
|
+
type ParsedTraceJsonlRow = {
|
|
130
|
+
format: "0.1";
|
|
131
|
+
event: TraceEvent;
|
|
132
|
+
sourceLine: number;
|
|
133
|
+
} | {
|
|
134
|
+
format: "0.2";
|
|
135
|
+
event: PersistedInspectEvent;
|
|
136
|
+
sourceLine: number;
|
|
137
|
+
} | {
|
|
138
|
+
format: "1.0";
|
|
139
|
+
event: PersistedInspectEvent;
|
|
140
|
+
sourceLine: number;
|
|
141
|
+
};
|
|
142
|
+
interface ParseTraceJsonlResult {
|
|
143
|
+
format: TraceJsonlFormat;
|
|
144
|
+
/** Count of valid source JSONL rows before any one-to-many normalization. */
|
|
145
|
+
sourceEventCount: number;
|
|
146
|
+
events: TraceEvent[];
|
|
147
|
+
persisted: PersistedInspectEvent[];
|
|
148
|
+
/** Valid source rows in JSONL order, before cross-version normalization. */
|
|
149
|
+
rows: ParsedTraceJsonlRow[];
|
|
150
|
+
}
|
|
151
|
+
interface ParseTraceJsonlOptions {
|
|
152
|
+
validate?: (value: unknown) => value is TraceEvent;
|
|
153
|
+
/** Emit parse warnings through the standard AgentInspect warning channel (default true). */
|
|
154
|
+
warnings?: boolean;
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Parses JSONL content into normalized v0.1 {@link TraceEvent} rows.
|
|
158
|
+
* Accepts homogenous v0.1, v0.2, or v1.0 files; mixed files are converted with a warning.
|
|
159
|
+
*/
|
|
160
|
+
declare function parseTraceJsonl(raw: string, options?: ParseTraceJsonlOptions): ParseTraceJsonlResult;
|
|
161
|
+
/**
|
|
162
|
+
* Returns a user-facing message when a trace file uses an unsupported schema version.
|
|
163
|
+
*/
|
|
164
|
+
declare function unknownTraceFormatMessage(): string;
|
|
165
|
+
|
|
166
|
+
interface TraceDirectoryOptions {
|
|
167
|
+
dir?: string;
|
|
168
|
+
}
|
|
169
|
+
declare function resolveTraceDir(options?: TraceDirectoryOptions): string;
|
|
170
|
+
declare class TraceDirectory {
|
|
171
|
+
#private;
|
|
172
|
+
constructor(options?: TraceDirectoryOptions);
|
|
173
|
+
getPath(filename?: string): string;
|
|
174
|
+
list(): Promise<string[]>;
|
|
175
|
+
getFileStats(filename: string): Promise<Stats>;
|
|
63
176
|
}
|
|
64
|
-
/** Resolves named profile behavior (keys + metadata string caps). */
|
|
65
|
-
declare function resolveRedactionProfile(profile?: RedactionProfile): ResolvedRedactionProfile;
|
|
66
177
|
|
|
67
|
-
|
|
68
|
-
declare
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
178
|
+
declare function extractMetadata(filePath: string, _quickScan?: boolean): Promise<TraceMetadata>;
|
|
179
|
+
declare function buildRunSummary(events: TraceEvent[]): RunSummary;
|
|
180
|
+
|
|
181
|
+
interface TraceFilterOptions {
|
|
182
|
+
status?: TraceMetadataStatus;
|
|
183
|
+
name?: string;
|
|
184
|
+
since?: string;
|
|
185
|
+
limit?: number;
|
|
186
|
+
}
|
|
187
|
+
declare function filterTraces(traces: TraceMetadata[], options: TraceFilterOptions): TraceMetadata[];
|
|
188
|
+
|
|
189
|
+
type TimelineFocus = "all" | "slow";
|
|
190
|
+
interface TimelineEntry {
|
|
191
|
+
stepId: string;
|
|
192
|
+
name: string;
|
|
193
|
+
type: StepType;
|
|
194
|
+
status: StepStatus;
|
|
195
|
+
depth: number;
|
|
196
|
+
startedAt: number;
|
|
197
|
+
offsetMs: number;
|
|
198
|
+
durationMs?: number;
|
|
199
|
+
isError: boolean;
|
|
200
|
+
slow?: boolean;
|
|
201
|
+
streaming?: {
|
|
202
|
+
chunkCount?: number;
|
|
203
|
+
streamDurationMs?: number;
|
|
204
|
+
streamedCharCount?: number;
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
interface RunTimeline {
|
|
208
|
+
runId: string;
|
|
209
|
+
name?: string;
|
|
210
|
+
status: TraceMetadataStatus;
|
|
211
|
+
startedAt?: number;
|
|
212
|
+
endedAt?: number;
|
|
213
|
+
durationMs?: number;
|
|
214
|
+
correlation?: {
|
|
215
|
+
correlationId?: string;
|
|
216
|
+
requestId?: string;
|
|
217
|
+
decisionId?: string;
|
|
218
|
+
groupId?: string;
|
|
219
|
+
};
|
|
220
|
+
entries: TimelineEntry[];
|
|
221
|
+
}
|
|
222
|
+
interface TimelineOptions {
|
|
223
|
+
focus?: TimelineFocus;
|
|
224
|
+
slowTopN?: number;
|
|
225
|
+
}
|
|
226
|
+
declare function buildRunTimeline(events: TraceEvent[], options?: TimelineOptions): RunTimeline;
|
|
227
|
+
interface RenderTimelineOptions {
|
|
228
|
+
focus?: TimelineFocus;
|
|
229
|
+
}
|
|
230
|
+
declare function renderTimeline(timeline: RunTimeline, options?: RenderTimelineOptions): string;
|
|
231
|
+
|
|
232
|
+
interface RunWhatSummary {
|
|
233
|
+
runId: string;
|
|
234
|
+
name?: string;
|
|
235
|
+
status: TraceMetadataStatus;
|
|
236
|
+
durationMs?: number;
|
|
237
|
+
totalSteps: number;
|
|
238
|
+
llmSteps: number;
|
|
239
|
+
toolSteps: number;
|
|
240
|
+
logicSteps: number;
|
|
241
|
+
errorSteps: number;
|
|
242
|
+
maxDepth: number;
|
|
243
|
+
longestStep?: {
|
|
244
|
+
name: string;
|
|
245
|
+
durationMs: number;
|
|
246
|
+
type: string;
|
|
247
|
+
};
|
|
248
|
+
totalTokens?: {
|
|
249
|
+
input: number;
|
|
250
|
+
output: number;
|
|
251
|
+
total?: number;
|
|
252
|
+
cached?: number;
|
|
253
|
+
};
|
|
254
|
+
correlation?: TraceCorrelationMetadata;
|
|
255
|
+
failedStepNames: string[];
|
|
256
|
+
runErrorMessage?: string;
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* Build a concise inspection summary for `what` / report workflows.
|
|
260
|
+
* Read-only over in-memory v0.1 {@link TraceEvent} rows.
|
|
261
|
+
*/
|
|
262
|
+
declare function buildRunWhatSummary(events: TraceEvent[]): RunWhatSummary;
|
|
263
|
+
interface RenderWhatOptions {
|
|
264
|
+
/** Include correlation ids when present (default true). */
|
|
265
|
+
correlation?: boolean;
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* Render a human-readable `what` summary (plain text, no ANSI).
|
|
269
|
+
*/
|
|
270
|
+
declare function renderRunWhat(summary: RunWhatSummary, options?: RenderWhatOptions): string;
|
|
271
|
+
|
|
272
|
+
type ExplainMode = "dry-run" | "local";
|
|
273
|
+
interface ExplainFact {
|
|
274
|
+
id: string;
|
|
275
|
+
label: string;
|
|
276
|
+
value: unknown;
|
|
277
|
+
source: "trace";
|
|
278
|
+
confidence: "observed";
|
|
279
|
+
}
|
|
280
|
+
interface ExplainInference {
|
|
281
|
+
id: string;
|
|
282
|
+
label: string;
|
|
283
|
+
text: string;
|
|
284
|
+
evidence: string[];
|
|
285
|
+
confidence: "deterministic";
|
|
286
|
+
}
|
|
287
|
+
interface ExplainResult {
|
|
288
|
+
mode: ExplainMode;
|
|
289
|
+
runId: string;
|
|
290
|
+
name?: string;
|
|
291
|
+
status?: string;
|
|
77
292
|
redactionProfile: RedactionProfile;
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
/** Resolves {@link InspectRunOptions} trace safety fields with safe defaults. */
|
|
85
|
-
declare function resolveTraceSafetyOptions(options?: Pick<InspectRunOptions, "redact" | "redactionProfile" | "maxEventBytes" | "maxMetadataValueLength" | "maxPreviewLength">): TraceSafetyOptions;
|
|
86
|
-
/** Redacts (when enabled) and truncates metadata values for disk persistence. */
|
|
87
|
-
declare function prepareMetadataForDisk(metadata: Record<string, unknown> | StepMetadata, opts: TraceSafetyOptions): Record<string, unknown>;
|
|
88
|
-
/**
|
|
89
|
-
* Applies redaction, metadata truncation, and final serialized size bounds.
|
|
90
|
-
* Never throws; returns a schema-valid event or a minimally truncated variant.
|
|
91
|
-
*/
|
|
92
|
-
declare function prepareTraceEventForDisk(event: TraceEvent, opts: TraceSafetyOptions): TraceEvent;
|
|
93
|
-
|
|
94
|
-
/** Returns the active run context, without internal step fields. */
|
|
95
|
-
declare function getCurrentContext(): ExecutionContext | undefined;
|
|
96
|
-
/** Active `runId` when inside `runWithContext`, else `undefined`. */
|
|
97
|
-
declare function getCurrentRunId(): string | undefined;
|
|
98
|
-
/**
|
|
99
|
-
* Correlation metadata for the active run (`correlationId`, `requestId`, `decisionId`, `groupId`).
|
|
100
|
-
* `undefined` outside `inspectRun` / `maybeInspectRun` or when no correlation fields were set.
|
|
101
|
-
*/
|
|
102
|
-
declare function getCurrentCorrelationMetadata(): TraceCorrelationMetadata | undefined;
|
|
103
|
-
/** Active `runName` when inside `runWithContext`, else `undefined`. */
|
|
104
|
-
declare function getCurrentRunName(): string | undefined;
|
|
105
|
-
/**
|
|
106
|
-
* Active step id in this async scope (parent for nested `step()` calls).
|
|
107
|
-
* `undefined` at run root or outside any run.
|
|
108
|
-
*/
|
|
109
|
-
declare function getCurrentStepId(): string | undefined;
|
|
110
|
-
/** Alias of {@link getCurrentStepId} for readability in step instrumentation. */
|
|
111
|
-
declare function getParentStepId(): string | undefined;
|
|
112
|
-
/**
|
|
113
|
-
* Nesting depth: `0` at run root, increments by one per nested `runWithStepContext`.
|
|
114
|
-
* Returns `0` outside any run.
|
|
115
|
-
*/
|
|
116
|
-
declare function getCurrentDepth(): number;
|
|
117
|
-
declare function hasActiveContext(): boolean;
|
|
118
|
-
declare function getTraceDirFromContext(): string | undefined;
|
|
119
|
-
declare function isSilentContext(): boolean;
|
|
120
|
-
/** Resolved trace safety settings for the active run (redaction + size bounds). */
|
|
121
|
-
declare function getTraceSafetyFromContext(): TraceSafetyOptions | undefined;
|
|
122
|
-
/**
|
|
123
|
-
* Runs `fn` with a fresh AgentInspect run context (depth 0, no active step).
|
|
124
|
-
* Propagates sync/async results and rejections; does not swallow user errors.
|
|
125
|
-
*/
|
|
126
|
-
declare function runWithContext<T>(context: ExecutionContext, fn: () => Promise<T> | T, traceSafety?: TraceSafetyOptions): Promise<T>;
|
|
127
|
-
/**
|
|
128
|
-
* Runs `fn` with `stepId` as the active step (incremented depth).
|
|
129
|
-
* If no run is active, runs `fn` without altering async context.
|
|
130
|
-
*/
|
|
131
|
-
declare function runWithStepContext<T>(stepId: string, fn: () => Promise<T> | T): Promise<T>;
|
|
132
|
-
|
|
133
|
-
interface InspectorRuntimeOptions {
|
|
134
|
-
enabled?: boolean;
|
|
135
|
-
writer?: TraceWriter;
|
|
136
|
-
traceSafety?: TraceSafetyOptions;
|
|
137
|
-
}
|
|
138
|
-
interface InspectorRuntimeContext extends ExecutionContext {
|
|
139
|
-
runtimeId: string;
|
|
140
|
-
}
|
|
141
|
-
interface InspectorRuntimeDiagnostics {
|
|
142
|
-
instrumentationErrors: number;
|
|
143
|
-
lastInstrumentationError?: string;
|
|
144
|
-
writerStats?: TraceWriterStats;
|
|
145
|
-
}
|
|
146
|
-
interface InspectorRuntime {
|
|
147
|
-
readonly runtimeId: string;
|
|
148
|
-
readonly enabled: boolean;
|
|
149
|
-
runWithContext<T>(context: ExecutionContext, fn: () => Promise<T> | T): Promise<T>;
|
|
150
|
-
runWithStepContext<T>(stepId: string, fn: () => Promise<T> | T): Promise<T>;
|
|
151
|
-
getCurrentContext(): InspectorRuntimeContext | undefined;
|
|
152
|
-
getCurrentCorrelationMetadata(): TraceCorrelationMetadata | undefined;
|
|
153
|
-
getCurrentStepId(): string | undefined;
|
|
154
|
-
getCurrentDepth(): number;
|
|
155
|
-
getTraceSafety(): TraceSafetyOptions;
|
|
156
|
-
write(event: PersistedInspectEvent): Promise<void>;
|
|
157
|
-
flush(): Promise<void>;
|
|
158
|
-
close(): Promise<void>;
|
|
159
|
-
getDiagnostics(): InspectorRuntimeDiagnostics;
|
|
160
|
-
}
|
|
161
|
-
declare function createInspectorRuntime(options?: InspectorRuntimeOptions): InspectorRuntime;
|
|
162
|
-
|
|
163
|
-
interface InspectorCaptureOptions {
|
|
164
|
-
onSuccess?: "none" | "metadata-only";
|
|
165
|
-
onError?: "none" | "metadata-only";
|
|
166
|
-
}
|
|
167
|
-
interface CreateInspectorOptions {
|
|
168
|
-
enabled?: boolean;
|
|
169
|
-
writer?: TraceWriter;
|
|
170
|
-
/**
|
|
171
|
-
* Context metadata only. Does not configure writer output; use
|
|
172
|
-
* `fileWriter({ dir })` or another explicit writer for persistence paths.
|
|
173
|
-
*
|
|
174
|
-
* @experimental
|
|
175
|
-
*/
|
|
176
|
-
traceDir?: string;
|
|
177
|
-
/**
|
|
178
|
-
* Context metadata only for compatibility with existing terminal helpers.
|
|
179
|
-
* `createInspector()` does not print lifecycle output.
|
|
180
|
-
*
|
|
181
|
-
* @experimental
|
|
182
|
-
*/
|
|
183
|
-
silent?: boolean;
|
|
184
|
-
metadata?: Record<string, unknown>;
|
|
293
|
+
facts: ExplainFact[];
|
|
294
|
+
inferences: ExplainInference[];
|
|
295
|
+
notes: string[];
|
|
296
|
+
}
|
|
297
|
+
interface ExplainOptions {
|
|
298
|
+
mode?: ExplainMode;
|
|
185
299
|
redactionProfile?: RedactionProfile;
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
traceSafety?: TraceSafetyOptions;
|
|
194
|
-
}
|
|
195
|
-
interface InspectorRunOptions {
|
|
196
|
-
runId?: string;
|
|
197
|
-
traceDir?: string;
|
|
198
|
-
silent?: boolean;
|
|
199
|
-
metadata?: Record<string, unknown>;
|
|
200
|
-
}
|
|
201
|
-
interface InspectorStepOptions {
|
|
202
|
-
type?: StepType;
|
|
203
|
-
metadata?: StepMetadata;
|
|
204
|
-
}
|
|
205
|
-
type InspectorObserveOptions = InspectorStepOptions;
|
|
206
|
-
interface Inspector {
|
|
207
|
-
/**
|
|
208
|
-
* Low-level runtime access is retained for v1.6 compatibility. Prefer
|
|
209
|
-
* `getDiagnostics()` unless you need advanced runtime context primitives.
|
|
210
|
-
*
|
|
211
|
-
* @experimental
|
|
212
|
-
*/
|
|
213
|
-
readonly runtime: InspectorRuntime;
|
|
214
|
-
run<T>(name: string, fn: () => T | Promise<T>, options?: InspectorRunOptions): Promise<T>;
|
|
215
|
-
step<T>(name: string, fn: () => T | Promise<T>, options?: InspectorStepOptions): Promise<T>;
|
|
216
|
-
tool<T>(name: string, fn: () => T | Promise<T>, options?: InspectorStepOptions): Promise<T>;
|
|
217
|
-
llm<T>(name: string, fn: () => T | Promise<T>, options?: InspectorStepOptions): Promise<T>;
|
|
218
|
-
observe<TFunction extends (...args: any[]) => any>(name: string, fn: TFunction, options?: InspectorObserveOptions): (...args: Parameters<TFunction>) => Promise<Awaited<ReturnType<TFunction>>>;
|
|
219
|
-
getDiagnostics(): ReturnType<InspectorRuntime["getDiagnostics"]>;
|
|
220
|
-
flush(): Promise<void>;
|
|
221
|
-
close(): Promise<void>;
|
|
222
|
-
}
|
|
223
|
-
declare function createInspector(options?: CreateInspectorOptions): Inspector;
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* Build a local, deterministic explanation payload from a reader-selected run.
|
|
303
|
+
*
|
|
304
|
+
* This helper performs no network I/O and does not call a model provider.
|
|
305
|
+
*/
|
|
306
|
+
declare function buildLocalExplanation(run: InspectRunTree, options?: ExplainOptions): ExplainResult;
|
|
224
307
|
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
308
|
+
interface DurationStats {
|
|
309
|
+
minMs?: number;
|
|
310
|
+
maxMs?: number;
|
|
311
|
+
avgMs?: number;
|
|
312
|
+
p50Ms?: number;
|
|
313
|
+
p95Ms?: number;
|
|
314
|
+
}
|
|
315
|
+
interface TraceStatsRankedRun {
|
|
316
|
+
runId: string;
|
|
317
|
+
name?: string;
|
|
318
|
+
durationMs?: number;
|
|
319
|
+
status: string;
|
|
320
|
+
}
|
|
321
|
+
interface TraceStatsRankedStep {
|
|
322
|
+
runId: string;
|
|
323
|
+
stepName: string;
|
|
324
|
+
stepType: string;
|
|
325
|
+
durationMs: number;
|
|
326
|
+
}
|
|
327
|
+
interface TraceStats {
|
|
328
|
+
traceDir: string;
|
|
329
|
+
since?: string;
|
|
330
|
+
correlationId?: string;
|
|
331
|
+
groupId?: string;
|
|
332
|
+
totalRuns: number;
|
|
333
|
+
successCount: number;
|
|
334
|
+
errorCount: number;
|
|
335
|
+
runningCount: number;
|
|
336
|
+
unknownCount: number;
|
|
337
|
+
errorRate: number;
|
|
338
|
+
duration: DurationStats;
|
|
339
|
+
totalSteps: number;
|
|
340
|
+
avgStepsPerRun: number;
|
|
341
|
+
totalLlmSteps: number;
|
|
342
|
+
totalToolSteps: number;
|
|
343
|
+
totalErrorSteps: number;
|
|
344
|
+
slowestRuns: TraceStatsRankedRun[];
|
|
345
|
+
slowestSteps: TraceStatsRankedStep[];
|
|
346
|
+
}
|
|
347
|
+
interface TraceStatsOptions {
|
|
348
|
+
traceDir: string;
|
|
349
|
+
since?: string;
|
|
350
|
+
correlationId?: string;
|
|
351
|
+
groupId?: string;
|
|
352
|
+
slowRunLimit?: number;
|
|
353
|
+
slowStepLimit?: number;
|
|
354
|
+
}
|
|
355
|
+
declare function buildTraceStats(metas: TraceMetadata[], options: TraceStatsOptions): Promise<TraceStats>;
|
|
356
|
+
declare function renderTraceStats(stats: TraceStats): string;
|
|
357
|
+
|
|
358
|
+
interface TraceSearchOptions {
|
|
359
|
+
traceDir: string;
|
|
360
|
+
since?: string;
|
|
361
|
+
status?: "success" | "error" | "running" | "unknown";
|
|
362
|
+
kind?: string;
|
|
363
|
+
type?: string;
|
|
364
|
+
name?: string;
|
|
365
|
+
tool?: string;
|
|
366
|
+
duration?: string;
|
|
367
|
+
limit?: number;
|
|
368
|
+
}
|
|
369
|
+
interface TraceSearchResult {
|
|
370
|
+
runId: string;
|
|
371
|
+
runName?: string;
|
|
372
|
+
runStatus: string;
|
|
373
|
+
stepId?: string;
|
|
374
|
+
stepName?: string;
|
|
375
|
+
stepType?: string;
|
|
376
|
+
timestamp?: number;
|
|
377
|
+
durationMs?: number;
|
|
378
|
+
matchReason: string;
|
|
379
|
+
matchedFields: string[];
|
|
380
|
+
filePath: string;
|
|
381
|
+
}
|
|
382
|
+
interface ParsedDurationFilter {
|
|
383
|
+
op: ">" | ">=" | "<" | "<=";
|
|
384
|
+
ms: number;
|
|
385
|
+
}
|
|
386
|
+
declare function parseDurationFilter(expr: string): ParsedDurationFilter;
|
|
387
|
+
declare function searchTraces(metas: TraceMetadata[], options: TraceSearchOptions): Promise<TraceSearchResult[]>;
|
|
388
|
+
declare function loadTraceMetadataList(_traceDir: string, fileNames: string[], getPath: (fileName: string) => string): Promise<TraceMetadata[]>;
|
|
389
|
+
|
|
390
|
+
/**
|
|
391
|
+
* Safety check for cleanup workflows: returns true only when the file appears to be an AgentInspect trace.
|
|
392
|
+
* This should be conservative: false positives are more dangerous than false negatives.
|
|
393
|
+
*/
|
|
394
|
+
declare function isAgentInspectTrace(filePath: string): Promise<boolean>;
|
|
395
|
+
|
|
396
|
+
/**
|
|
397
|
+
* v0.2 shared duration utilities.
|
|
398
|
+
*
|
|
399
|
+
* `parseDuration` is used for filters such as "since" / "older-than".
|
|
400
|
+
* `formatDuration` is used for compact display in CLI and summaries.
|
|
401
|
+
*/
|
|
402
|
+
declare function parseDuration(duration: string): number;
|
|
253
403
|
|
|
254
|
-
export { type
|
|
404
|
+
export { DEFAULT_TRACE_DIR_NAME, type DurationStats, ErrorInfo, type ExplainFact, type ExplainInference, type ExplainMode, type ExplainOptions, type ExplainResult, FALLBACK_TRACE_DIR, 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, RunStatus, RunSummary, type RunTimeline, type RunWhatSummary, 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 TraceStats, type TraceStatsOptions, type TraceStatsRankedRun, type TraceStatsRankedStep, buildLocalExplanation, buildRunSummary, buildRunTimeline, buildRunWhatSummary, buildTraceStats, createRunId, createStepId, ensureTraceDir, extractMetadata, filterTraces, formatDuration, formatError, formatTerminalName, formatTimestamp, getDefaultTraceDir, getIndent, getRunIdFromTraceFileName, getTraceFilePath, initializeTraceFile, isAgentInspectTrace, listTraceFiles, loadTraceMetadataList, parseDuration, parseDurationFilter, parseTraceJsonl, printError, printFailedAt, printRunComplete, printRunStart, printStepComplete, printStepStart, readTraceEvents, readTraceFile, renderErrorLine, renderRunSummary, renderRunWhat, renderStepLine, renderTimeline, renderTraceStats, resolveRedactionProfile, resolveTraceDir, searchTraces, serializeEvent, truncateName, unknownTraceFormatMessage, validateEvent, warn, writeTraceEvent };
|