agent-inspect 1.8.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 +14 -0
- package/README.md +146 -23
- package/docs/ADAPTER-CONFORMANCE.md +1 -1
- package/docs/ADAPTERS.md +41 -6
- package/docs/API.md +123 -36
- package/docs/CLI.md +75 -11
- package/docs/EXPORTS.md +1 -1
- package/docs/GETTING-STARTED.md +72 -16
- package/docs/KNOWN-ISSUES.md +8 -3
- package/docs/LIMITATIONS.md +6 -6
- package/docs/LOG-TO-TREE-QUICKSTART.md +1 -2
- package/docs/MIGRATION.md +67 -0
- package/docs/SCHEMA.md +29 -12
- package/package.json +2 -2
- package/packages/cli/dist/index.cjs +7604 -7660
- package/packages/cli/dist/index.cjs.map +1 -1
- package/packages/cli/dist/index.mjs +7604 -7660
- 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 -8022
- package/packages/core/dist/index.cjs.map +1 -1
- package/packages/core/dist/index.d.cts +8 -313
- package/packages/core/dist/index.d.ts +8 -313
- package/packages/core/dist/index.mjs +18 -1331
- 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
package/docs/API.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# API
|
|
1
|
+
# API
|
|
2
2
|
|
|
3
3
|
This document describes the **public TypeScript API surface** of AgentInspect and classifies each area as **stable** or **experimental**.
|
|
4
4
|
|
|
@@ -6,24 +6,54 @@ AgentInspect is a **local-first execution-tree debugger**. It is not a SaaS, not
|
|
|
6
6
|
|
|
7
7
|
## 1. Stability policy
|
|
8
8
|
|
|
9
|
-
- **Stable**: intended to
|
|
10
|
-
- **Experimental**: available for adoption, but subject to refinement (including naming/shape changes) before a future stability declaration.
|
|
9
|
+
- **Stable**: intended to stay compatible within the current major version.
|
|
10
|
+
- **Experimental**: available for adoption, but subject to refinement (including naming/shape changes) before a future stability declaration.
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
Use the root import for stable beginner APIs. Use subpaths for advanced, experimental, or lower-level workflows.
|
|
13
|
+
|
|
14
|
+
```ts
|
|
15
|
+
import {
|
|
16
|
+
createInspector,
|
|
17
|
+
observe,
|
|
18
|
+
inspectRun,
|
|
19
|
+
maybeInspectRun,
|
|
20
|
+
step,
|
|
21
|
+
getCurrentCorrelationMetadata,
|
|
22
|
+
} from "agent-inspect";
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
**v2 root API contract:** do not add new root exports casually. Advanced, experimental, and lower-level helpers belong on the subpath where the API lives. The stable root value set is:
|
|
26
|
+
|
|
27
|
+
```ts
|
|
28
|
+
import {
|
|
29
|
+
createInspector,
|
|
30
|
+
observe,
|
|
31
|
+
inspectRun,
|
|
32
|
+
maybeInspectRun,
|
|
33
|
+
step,
|
|
34
|
+
getCurrentCorrelationMetadata,
|
|
35
|
+
} from "agent-inspect";
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
**Subpath exports:** Subpaths (`/logs`, `/exporters`, `/persisted`, `/diff`, `/advanced`, `/writers`, `/readers`, `/checks`) narrow the import surface for experimental and advanced APIs. Design history: [API-BOUNDARY-V1.5.md](./implementation/API-BOUNDARY-V1.5.md).
|
|
13
39
|
|
|
14
40
|
```ts
|
|
15
|
-
import { inspectRun, step } from "agent-inspect";
|
|
16
41
|
import { parseLogsToTrees } from "agent-inspect/logs";
|
|
17
42
|
import { exportMarkdown } from "agent-inspect/exporters";
|
|
18
43
|
import { memoryWriter } from "agent-inspect/writers";
|
|
19
44
|
import { openTrace } from "agent-inspect/readers";
|
|
45
|
+
import { runTraceChecks } from "agent-inspect/checks";
|
|
46
|
+
import { diffTraceEvents } from "agent-inspect/diff";
|
|
47
|
+
import { traceEventsToPersistedInspectEvents } from "agent-inspect/persisted";
|
|
48
|
+
import { createInspectorRuntime } from "agent-inspect/advanced";
|
|
20
49
|
```
|
|
21
50
|
|
|
22
51
|
Notes:
|
|
23
52
|
|
|
24
|
-
- The core guarantee
|
|
53
|
+
- The core guarantee is **stable local debugging**: manual tracing + CLI inspection.
|
|
25
54
|
- Export formats (OpenInference / OTLP JSON) are **local-only** and **compatibility-oriented**. They do **not** upload anywhere.
|
|
26
|
-
- There are **zero production sinks
|
|
55
|
+
- There are **zero production sinks**; sink/uploader APIs are not stable.
|
|
56
|
+
- Advanced APIs are available from `agent-inspect/advanced`, `agent-inspect/readers`, `agent-inspect/writers`, `agent-inspect/checks`, `agent-inspect/diff`, `agent-inspect/exporters`, `agent-inspect/logs`, and `agent-inspect/persisted`.
|
|
27
57
|
|
|
28
58
|
## 2. Stable core APIs (manual tracing)
|
|
29
59
|
|
|
@@ -32,7 +62,13 @@ These are the recommended entry points for manual instrumentation. They are desi
|
|
|
32
62
|
Import from `agent-inspect`:
|
|
33
63
|
|
|
34
64
|
```ts
|
|
35
|
-
import {
|
|
65
|
+
import {
|
|
66
|
+
observe,
|
|
67
|
+
inspectRun,
|
|
68
|
+
maybeInspectRun,
|
|
69
|
+
step,
|
|
70
|
+
getCurrentCorrelationMetadata,
|
|
71
|
+
} from "agent-inspect";
|
|
36
72
|
```
|
|
37
73
|
|
|
38
74
|
- **`inspectRun(name, fn, options?)`**: wraps a workflow in a local JSONL trace (`run_started` / `run_completed`), prints terminal progress, and swallows instrumentation failures (user errors are re-thrown). **Traces by default** when `enabled` is omitted or `true`. Pass **`enabled: false`** to run `fn` with no trace file, no execution context, and no terminal output.
|
|
@@ -43,14 +79,14 @@ import { inspectRun, maybeInspectRun, step, observe } from "agent-inspect";
|
|
|
43
79
|
- **`maxEventBytes`**: max UTF-8 bytes per serialized JSONL event (default `65536`). Oversized events are truncated; instrumentation never throws into user code.
|
|
44
80
|
- **Correlation metadata (v1.3.0+):** optional `correlationId`, `requestId`, `decisionId`, and `groupId` strings. When set, they are written on `run_started.metadata` (not on every step). Top-level correlation options override the same keys in `options.metadata`. Useful for eval cases, CI job IDs, request tracing, and `stats --correlation-id` / `--group-id`. They are **metadata only** — they do not replace `runId`. Treat sensitive IDs as trace data before sharing exports.
|
|
45
81
|
- **`maybeInspectRun(name, fn, options?)`**: same as `inspectRun` when tracing is enabled; otherwise passthrough. Enablement: explicit **`options.enabled`** wins; when omitted, reads **`AGENT_INSPECT`** (`1`, `true`, `yes`, `on`, `enabled` — case-insensitive). Unset or other values disable tracing. Use in eval harnesses, CI, or jobs where tracing should be toggled by environment.
|
|
46
|
-
- **`isAgentInspectEnabled(value?)`**: returns whether a string (or `process.env.AGENT_INSPECT`) matches an enable token.
|
|
82
|
+
- **`isAgentInspectEnabled(value?)`**: advanced helper available from `agent-inspect/advanced`; returns whether a string (or `process.env.AGENT_INSPECT`) matches an enable token.
|
|
47
83
|
- **`step(name, fn, options?)`**: traces a named unit of work inside `inspectRun` (`step_started` / `step_completed`). Step `metadata` inherits the parent run's redaction and size-bound settings.
|
|
48
84
|
- **`step.llm(model, fn)`**: convenience wrapper (`type: "llm"`, `metadata.model`).
|
|
49
85
|
- **`step.tool(toolName, fn)`**: convenience wrapper (`type: "tool"`, `metadata.toolName`).
|
|
50
86
|
- **`observe(agent, options?)`**: proxy wrapper that traces top-level `run` / `execute` / `invoke` methods via `inspectRun`.
|
|
51
87
|
- **`getCurrentCorrelationMetadata()`**: returns active run correlation fields (`correlationId`, `requestId`, `decisionId`, `groupId`) inside `inspectRun` / `maybeInspectRun`; `undefined` outside a traced run or when none were set.
|
|
52
88
|
- **`RedactionProfile`**: `"local" | "share" | "strict"` — see `redactionProfile` on `InspectRunOptions` and `ExportOptions`.
|
|
53
|
-
- **`resolveRedactionProfile(profile?)`**: resolves profile extra keys and metadata caps
|
|
89
|
+
- **`resolveRedactionProfile(profile?)`**: advanced helper available from `agent-inspect/advanced`; resolves profile extra keys and metadata caps for integrations.
|
|
54
90
|
|
|
55
91
|
## 3. Stable local inspection APIs
|
|
56
92
|
|
|
@@ -90,7 +126,7 @@ These APIs support local workflows like listing traces, extracting metadata/summ
|
|
|
90
126
|
|
|
91
127
|
## 5. Experimental log parsing APIs
|
|
92
128
|
|
|
93
|
-
These are compatibility-oriented utilities for turning structured logs into normalized `InspectEvent` and grouped trees. They remain conservative: **no eval**, **no parsing JS object literals**, JSON logs first-class, log4js best-effort.
|
|
129
|
+
Advanced ingestion: use this when your app already emits structured logs. These are compatibility-oriented utilities for turning structured logs into normalized `InspectEvent` and grouped trees. They remain conservative: **no eval**, **no parsing JS object literals**, JSON logs first-class, log4js best-effort.
|
|
94
130
|
|
|
95
131
|
- **`parseLogsToTrees`**
|
|
96
132
|
- **`JsonLogParser`**, **`Log4jsParser`**
|
|
@@ -152,7 +188,7 @@ Rationale: v1.x includes one official adapter and **zero production sinks**, so
|
|
|
152
188
|
|
|
153
189
|
## 11. Experimental `@agent-inspect/ai-sdk` APIs
|
|
154
190
|
|
|
155
|
-
`@agent-inspect/ai-sdk` is an optional
|
|
191
|
+
`@agent-inspect/ai-sdk` is an optional adapter package for Vercel AI SDK v6 telemetry integrations. It is experimental and published as part of the aligned v1.8.0 package set.
|
|
156
192
|
|
|
157
193
|
Import from `@agent-inspect/ai-sdk`:
|
|
158
194
|
|
|
@@ -188,7 +224,7 @@ Recipe: [examples/recipes/ai-sdk-local-telemetry](../examples/recipes/ai-sdk-loc
|
|
|
188
224
|
|
|
189
225
|
## 12. Experimental `@agent-inspect/vitest` APIs
|
|
190
226
|
|
|
191
|
-
`@agent-inspect/vitest` is an optional experimental package for local Vitest failure artifacts.
|
|
227
|
+
`@agent-inspect/vitest` is an optional experimental workspace package for local Vitest failure artifacts. It remains private/unpublished. It does not add a Vitest dependency to root/core, does not upload artifacts, and does not infer trace relationships by timestamp.
|
|
192
228
|
|
|
193
229
|
Import from `@agent-inspect/vitest`:
|
|
194
230
|
|
|
@@ -220,7 +256,7 @@ Artifacts are safe structural summaries. They include bounded test identity, sta
|
|
|
220
256
|
|
|
221
257
|
## 13. Experimental `@agent-inspect/jest` APIs
|
|
222
258
|
|
|
223
|
-
`@agent-inspect/jest` is an optional experimental package for local Jest failure artifacts.
|
|
259
|
+
`@agent-inspect/jest` is an optional experimental workspace package for local Jest failure artifacts. It remains private/unpublished. It does not add a Jest dependency to root/core, does not upload artifacts, and does not infer trace relationships by timestamp.
|
|
224
260
|
|
|
225
261
|
Import from `@agent-inspect/jest`:
|
|
226
262
|
|
|
@@ -262,7 +298,7 @@ Artifacts are safe structural summaries. They include bounded test identity, sta
|
|
|
262
298
|
|
|
263
299
|
## 14. Experimental `@agent-inspect/openai-agents` APIs
|
|
264
300
|
|
|
265
|
-
`@agent-inspect/openai-agents` is an optional experimental package for OpenAI Agents JS tracing processor integration.
|
|
301
|
+
`@agent-inspect/openai-agents` is an optional experimental package for OpenAI Agents JS tracing processor integration. It is public in the aligned v1.8.0 package set and records runtime metadata locally.
|
|
266
302
|
|
|
267
303
|
Import from `@agent-inspect/openai-agents`:
|
|
268
304
|
|
|
@@ -293,29 +329,29 @@ The processor records local v0.2 persisted events for trace/run, agent, generati
|
|
|
293
329
|
|
|
294
330
|
## 15. Experimental persisted-event foundation (v1.2.0)
|
|
295
331
|
|
|
296
|
-
These helpers expose the **source-agnostic `PersistedInspectEvent` model
|
|
332
|
+
These helpers expose the **source-agnostic `PersistedInspectEvent` model**. They are **local-only** and support v0.2 compatibility plus the stable schema 1.0 persisted contract.
|
|
297
333
|
|
|
298
|
-
Import from `agent-inspect`:
|
|
334
|
+
Import from `agent-inspect/persisted`:
|
|
299
335
|
|
|
300
336
|
| API | Role |
|
|
301
337
|
| --- | ---- |
|
|
302
|
-
| `isPersistedInspectEvent` | Runtime validator for
|
|
338
|
+
| `isPersistedInspectEvent` | Runtime validator for supported persisted events |
|
|
303
339
|
| `traceEventToPersistedInspectEvent` | Convert one v0.1 `TraceEvent` |
|
|
304
340
|
| `traceEventsToPersistedInspectEvents` | Batch v0.1 → v0.2 |
|
|
305
341
|
| `inspectEventToPersistedInspectEvent` | Convert one in-memory `InspectEvent` |
|
|
306
|
-
| `inspectEventsToPersistedInspectEvents` | Batch `InspectEvent` →
|
|
307
|
-
| `persistedInspectEventToInspectEvent` | Convert one
|
|
308
|
-
| `persistedInspectEventsToInspectEvents` | Batch
|
|
309
|
-
| `persistedInspectEventsToRunTrees` | Build `InspectRunTree[]` from
|
|
342
|
+
| `inspectEventsToPersistedInspectEvents` | Batch `InspectEvent` → persisted events |
|
|
343
|
+
| `persistedInspectEventToInspectEvent` | Convert one persisted event to `InspectEvent` |
|
|
344
|
+
| `persistedInspectEventsToInspectEvents` | Batch persisted events → `InspectEvent` |
|
|
345
|
+
| `persistedInspectEventsToRunTrees` | Build `InspectRunTree[]` from persisted events (via `TreeBuilder`) |
|
|
310
346
|
| `traceEventsToPersistedRunTrees` | v0.1 `TraceEvent[]` → persisted model → trees |
|
|
311
347
|
|
|
312
348
|
Related types: `PersistedInspectEvent`, `PersistedEventSourceType`, `PersistedEventStatus`, `TraceEventToPersistedOptions`, `InspectEventToPersistedOptions`, `PersistedToInspectEventOptions`, `PersistedTreeBridgeOptions`.
|
|
313
349
|
|
|
314
350
|
**Notes:**
|
|
315
351
|
|
|
316
|
-
- Manual trace **writing** remains `schemaVersion: "0.1"`.
|
|
317
|
-
-
|
|
318
|
-
- Inspection read paths normalize v0.1
|
|
352
|
+
- Manual global trace **writing** remains `schemaVersion: "0.1"`.
|
|
353
|
+
- `createInspector()` and built-in persisted writer paths target schema 1.0 rows.
|
|
354
|
+
- Inspection read paths normalize v0.1, v0.2, and v1.0 JSONL for local CLI/API use. v0.2 remains a compatibility foundation.
|
|
319
355
|
|
|
320
356
|
## 16. Local observability helpers (v1.4.0+)
|
|
321
357
|
|
|
@@ -338,7 +374,7 @@ Report redaction profiles are key-based safeguards applied to the complete rende
|
|
|
338
374
|
|
|
339
375
|
## 18. Experimental trace writers (v1.6)
|
|
340
376
|
|
|
341
|
-
Trace writers are the
|
|
377
|
+
Trace writers are the local persistence contract for tests, adapters, and `createInspector()` workflows.
|
|
342
378
|
|
|
343
379
|
Import from `agent-inspect/writers`:
|
|
344
380
|
|
|
@@ -360,7 +396,7 @@ import type {
|
|
|
360
396
|
```
|
|
361
397
|
|
|
362
398
|
- **`TraceWriter`**: async `write(event)`, optional `flush()`, optional `close()`, optional `getStats()`.
|
|
363
|
-
- **`fileWriter({ dir?, filePath? })`**: appends
|
|
399
|
+
- **`fileWriter({ dir?, filePath? })`**: appends `PersistedInspectEvent` JSONL rows to local disk. `createInspector()` emits schema 1.0 rows by default; compatibility adapters may still pass readable v0.2 rows. By default it derives one file per `event.runId`; `filePath` writes all events to an explicit local file. Filesystem and serialization failures are reflected in writer stats instead of being thrown into application code.
|
|
364
400
|
- **`bufferedFileWriter({ dir?, filePath?, maxQueueSize?, flushIntervalMs?, maxBatchSize?, overflow? })`**: buffers local JSONL writes with bounded queue behavior. Overflow supports `drop-oldest` and `drop-newest`; neither mode throws into application code.
|
|
365
401
|
- **`compositeWriter([...writers])`**: fans out events to multiple explicit local/custom writers. A failing child writer does not prevent other children from receiving events; failures are reflected in composite stats.
|
|
366
402
|
- **`memoryWriter()`**: stores cloned `PersistedInspectEvent` rows in memory for tests, adapter fixtures, and eval harnesses.
|
|
@@ -370,12 +406,12 @@ No network writer or vendor sink exists in this package.
|
|
|
370
406
|
|
|
371
407
|
## 19. Experimental inspector API/runtime (v1.6)
|
|
372
408
|
|
|
373
|
-
`createInspector()` is the
|
|
409
|
+
`createInspector()` is the public instance API for local-first tracing with explicit writers. It owns an instance-specific runtime context, records schema 1.0 persisted inspect events, preserves application return values/errors, and exposes diagnostics plus deterministic `flush()`/`close()` lifecycle hooks.
|
|
374
410
|
|
|
375
|
-
Import from `agent-inspect
|
|
411
|
+
Import from `agent-inspect`:
|
|
376
412
|
|
|
377
413
|
```ts
|
|
378
|
-
import { createInspector } from "agent-inspect
|
|
414
|
+
import { createInspector } from "agent-inspect";
|
|
379
415
|
import { memoryWriter } from "agent-inspect/writers";
|
|
380
416
|
|
|
381
417
|
const writer = memoryWriter();
|
|
@@ -406,9 +442,9 @@ Public methods:
|
|
|
406
442
|
|
|
407
443
|
`traceDir` and `silent` on `createInspector()` are context metadata for compatibility with existing helpers. They do not configure persistence or terminal output. Prefer writer-owned output configuration such as `fileWriter({ dir })` or `fileWriter({ filePath })`.
|
|
408
444
|
|
|
409
|
-
`createInspectorRuntime()` is
|
|
445
|
+
`createInspectorRuntime()` is available from `agent-inspect/advanced` as the low-level isolation primitive. Most users should prefer `createInspector()` and `inspector.getDiagnostics()`.
|
|
410
446
|
|
|
411
|
-
|
|
447
|
+
The low-level runtime helpers remain on `agent-inspect/advanced`. These APIs do not add a default network writer or vendor sink.
|
|
412
448
|
|
|
413
449
|
## 20. Experimental trace readers (v1.6)
|
|
414
450
|
|
|
@@ -461,16 +497,67 @@ The checks API is experimental in v1.x. The `agent-inspect check` CLI uses this
|
|
|
461
497
|
|
|
462
498
|
Recipes: [deterministic-ci-checks](../examples/recipes/deterministic-ci-checks/README.md) for check/baseline/artifact workflows, and [test-reporter-artifacts](../examples/recipes/test-reporter-artifacts/README.md) for Vitest/Jest reporter configuration patterns.
|
|
463
499
|
|
|
464
|
-
## 22.
|
|
500
|
+
## 22. Experimental local explain APIs (v1.9)
|
|
501
|
+
|
|
502
|
+
`buildLocalExplanation()` creates a deterministic local explanation payload from a reader-selected `InspectRunTree`. It performs no network I/O, does not call model providers, and separates observed facts from deterministic inference labels.
|
|
503
|
+
|
|
504
|
+
Import from `agent-inspect`:
|
|
505
|
+
|
|
506
|
+
```ts
|
|
507
|
+
import { buildLocalExplanation } from "agent-inspect/advanced";
|
|
508
|
+
```
|
|
509
|
+
|
|
510
|
+
- **`buildLocalExplanation(run, options?)`**:
|
|
511
|
+
- **`mode: "dry-run"`**: returns redacted observed facts and no inference labels.
|
|
512
|
+
- **`mode: "local"`** (default): returns observed facts plus deterministic local inference labels.
|
|
513
|
+
- **`redactionProfile`**: `local`, `share`, or `strict`; profile keys are redacted before the payload is returned.
|
|
514
|
+
|
|
515
|
+
CLI wrapper: `agent-inspect explain <trace-path-or-run-id> --dry-run --json`.
|
|
516
|
+
|
|
517
|
+
Provider design gate:
|
|
518
|
+
|
|
519
|
+
- No provider payload is submitted in v1.9 implementation chunks; `--provider <provider>` is reserved and rejected with `PROVIDER_NOT_IMPLEMENTED`.
|
|
520
|
+
- The reviewable provider payload contract is the `ExplainResult` object: `mode`, `runId`, optional `name` / `status`, `redactionProfile`, `facts`, `inferences`, and `notes`.
|
|
521
|
+
- Provider implementations must require explicit provider selection and documented environment requirements. The current local API reads no provider credentials.
|
|
522
|
+
- Provider prompts must use redacted facts only, label inferred claims, and must not request raw chain-of-thought.
|
|
523
|
+
- Provider packages or SDKs must not become root/core runtime dependencies.
|
|
524
|
+
|
|
525
|
+
## 23. Experimental `@agent-inspect/harness` APIs
|
|
526
|
+
|
|
527
|
+
`@agent-inspect/harness` is a private experimental workspace package during the v1.9 release train. It provides a no-framework fixture runner for local targets and recipes; first public package publication remains a manual maintainer gate.
|
|
528
|
+
|
|
529
|
+
Import from `@agent-inspect/harness` inside the workspace:
|
|
530
|
+
|
|
531
|
+
```ts
|
|
532
|
+
import { createFixtureRunner, defineTarget } from "@agent-inspect/harness";
|
|
533
|
+
```
|
|
534
|
+
|
|
535
|
+
- **`defineTarget(definition)`**: returns a typed target definition with `resolve(app, context)` and `invoke(target, input, context)` hooks.
|
|
536
|
+
- **`createFixtureRunner(options)`**: returns a local runner with:
|
|
537
|
+
- **`listTargets()`**: deterministic target metadata listing.
|
|
538
|
+
- **`runTarget(name, input, options?)`**: bootstrap, resolve, invoke, and shutdown lifecycle.
|
|
539
|
+
- **`runFromArgv(argv?, io?)`**: CLI-friendly execution with target listing, JSON fixture files, JSON stdin, JSON stdout, stderr summaries, trace flags, and expected-output comparison.
|
|
540
|
+
- **`getDiagnostics()`**: deterministic diagnostics for missing targets, bootstrap failures, resolve failures, invocation failures, and shutdown failures.
|
|
541
|
+
- **`trace`** options use existing AgentInspect local APIs only:
|
|
542
|
+
- **`mode: "run-if-enabled"`** (default): uses `maybeInspectRun()` and writes no trace unless `options.enabled` or `AGENT_INSPECT` enables tracing.
|
|
543
|
+
- **`mode: "run"`**: explicitly wraps the target invocation in `inspectRun()`.
|
|
544
|
+
- **`mode: "observe"`**: proxies the resolved target with `observe()` for `run` / `execute` / `invoke` methods when enabled.
|
|
545
|
+
- **`mode: "off"`**: invokes the target without AgentInspect tracing.
|
|
546
|
+
|
|
547
|
+
The harness package does not add root/core dependencies, does not upload traces, does not call providers, and does not capture raw prompts or outputs by itself. It writes only local AgentInspect traces when explicitly enabled by runner options or environment-gated tracing.
|
|
548
|
+
|
|
549
|
+
Recipes: [harness-basic](../examples/recipes/harness-basic/README.md) and [harness-adapter-local](../examples/recipes/harness-adapter-local/README.md).
|
|
550
|
+
|
|
551
|
+
## 24. Deprecated APIs
|
|
465
552
|
|
|
466
553
|
No deprecated APIs are declared as of 1.4.0.
|
|
467
554
|
|
|
468
|
-
##
|
|
555
|
+
## 25. Removal / deprecation policy
|
|
469
556
|
|
|
470
|
-
- Stable APIs are not removed
|
|
557
|
+
- Stable APIs are not removed within the current major version.
|
|
471
558
|
- If removal is necessary, the API should be **deprecated** first, documented, and kept for a reasonable window (target: at least one minor line) unless security requires faster action.
|
|
472
559
|
|
|
473
|
-
##
|
|
560
|
+
## 26. Backward compatibility policy
|
|
474
561
|
|
|
475
562
|
- Manual trace JSONL (`schemaVersion: "0.1"`) remains readable.
|
|
476
563
|
- Additive schema changes are allowed in minor versions.
|
package/docs/CLI.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# CLI
|
|
1
|
+
# CLI
|
|
2
2
|
|
|
3
3
|
This document describes the **stable CLI surface** of AgentInspect.
|
|
4
4
|
|
|
@@ -26,6 +26,7 @@ Core commands:
|
|
|
26
26
|
- `tail` — live-tail logs into updating local trees
|
|
27
27
|
- `export` — export manual traces to Markdown/HTML/OpenInference/OTLP JSON (local only)
|
|
28
28
|
- `open` — read supported local trace files, directories, or stdin through the canonical reader pipeline
|
|
29
|
+
- `migrate` — convert one local AgentInspect JSONL file to schema 1.0 with dry-run or explicit output
|
|
29
30
|
- `check` — run deterministic local trace checks with stable JSON and exit codes
|
|
30
31
|
- `scan` — best-effort local safety scan for trace capture risks
|
|
31
32
|
- `verify-safe` — best-effort local trace safety verification
|
|
@@ -36,6 +37,7 @@ Core commands:
|
|
|
36
37
|
- `search` — deterministic local search over traces
|
|
37
38
|
- `what` — concise summary of a single run (local JSONL)
|
|
38
39
|
- `report` — markdown or HTML inspection report for a single run
|
|
40
|
+
- `explain` — deterministic local facts/inferences for a trace, with dry-run payloads
|
|
39
41
|
|
|
40
42
|
## 2. Environment variables
|
|
41
43
|
|
|
@@ -138,7 +140,7 @@ Recommendation: run with `--dry-run` first.
|
|
|
138
140
|
|
|
139
141
|
### 6.4 `logs`
|
|
140
142
|
|
|
141
|
-
|
|
143
|
+
Advanced ingestion: use this when your app already emits structured logs. Parse those logs into local execution trees.
|
|
142
144
|
|
|
143
145
|
```bash
|
|
144
146
|
agent-inspect logs <file> [options]
|
|
@@ -242,7 +244,36 @@ cat packages/core/test/fixtures/openinference-basic.json | npx agent-inspect ope
|
|
|
242
244
|
|
|
243
245
|
When a directory or payload contains multiple runs, `open` lists the run ids and exits until you pass `--run <run-id>`.
|
|
244
246
|
|
|
245
|
-
### 6.8 `
|
|
247
|
+
### 6.8 `migrate`
|
|
248
|
+
|
|
249
|
+
Convert one local AgentInspect JSONL trace file to the stable schema 1.0 persisted contract. This command is local and non-destructive by default: it does not upload traces, run agents, mutate the input file, or overwrite originals.
|
|
250
|
+
|
|
251
|
+
```bash
|
|
252
|
+
agent-inspect migrate <input.jsonl> --to 1.0 --dry-run
|
|
253
|
+
agent-inspect migrate <input.jsonl> --to 1.0 --output <output.jsonl>
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
Options:
|
|
257
|
+
|
|
258
|
+
- `--to 1.0`: required target schema version
|
|
259
|
+
- `--dry-run`: print deterministic counts and warnings without writing output
|
|
260
|
+
- `-o, --output <path>`: write migrated schema 1.0 JSONL to a separate file
|
|
261
|
+
- `--force`: accepted only for explicit output validation; input overwrite is still refused
|
|
262
|
+
|
|
263
|
+
Input support:
|
|
264
|
+
|
|
265
|
+
- v0.1 manual trace rows are converted to schema 1.0 persisted rows.
|
|
266
|
+
- v0.2 and v1.0 persisted rows are preserved/upgraded through the shared persisted contract.
|
|
267
|
+
- malformed JSON and unsupported schema rows are reported as line warnings.
|
|
268
|
+
|
|
269
|
+
Examples:
|
|
270
|
+
|
|
271
|
+
```bash
|
|
272
|
+
npx agent-inspect migrate fixtures/traces/minimal-success.jsonl --to 1.0 --dry-run
|
|
273
|
+
npx agent-inspect migrate fixtures/traces/minimal-success.jsonl --to 1.0 --output fixtures/traces/minimal-success.v1.jsonl
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
### 6.9 `check`
|
|
246
277
|
|
|
247
278
|
Run deterministic checks against a local trace. This command is local and read-only: it does not rerun agents, call models, upload traces, or mutate input files.
|
|
248
279
|
|
|
@@ -291,7 +322,7 @@ npx agent-inspect check trace.jsonl --max-duration-ms 30000 --required-tool sear
|
|
|
291
322
|
|
|
292
323
|
Recipe: [examples/recipes/deterministic-ci-checks](../examples/recipes/deterministic-ci-checks/README.md)
|
|
293
324
|
|
|
294
|
-
### 6.
|
|
325
|
+
### 6.10 `scan` and `verify-safe`
|
|
295
326
|
|
|
296
327
|
Run best-effort local safety verification for supported trace inputs. These commands are local and read-only: they do not rerun agents, call models, upload traces, mutate input files, or certify compliance.
|
|
297
328
|
|
|
@@ -330,7 +361,7 @@ npx agent-inspect verify-safe minimal-success --dir fixtures/traces
|
|
|
330
361
|
npx agent-inspect verify-safe trace.jsonl --max-string-length 8192 --json
|
|
331
362
|
```
|
|
332
363
|
|
|
333
|
-
### 6.
|
|
364
|
+
### 6.11 `artifacts`
|
|
334
365
|
|
|
335
366
|
Create deterministic local CI artifacts for supported trace inputs. This command is local and read-only for trace inputs: it does not rerun agents, call models, upload files, use GitHub APIs, or mutate repository state. It writes only to `--output-dir` and, when requested, a local step-summary file.
|
|
336
367
|
|
|
@@ -370,7 +401,7 @@ npx agent-inspect artifacts candidate.jsonl --baseline baseline.jsonl --output-d
|
|
|
370
401
|
|
|
371
402
|
Recipe and sample workflow: [examples/recipes/deterministic-ci-checks](../examples/recipes/deterministic-ci-checks/README.md)
|
|
372
403
|
|
|
373
|
-
### 6.
|
|
404
|
+
### 6.12 `diff`
|
|
374
405
|
|
|
375
406
|
Compare two manual trace runs. Diff is **local** and **read-only** (does not rerun agents).
|
|
376
407
|
|
|
@@ -434,7 +465,7 @@ Differences:
|
|
|
434
465
|
|
|
435
466
|
More examples, including timing-only and structure-only diffs, are in `docs/DIFF.md`.
|
|
436
467
|
|
|
437
|
-
### 6.
|
|
468
|
+
### 6.13 `timeline`
|
|
438
469
|
|
|
439
470
|
Chronological step list for one manual trace. Read-only; does not mutate JSONL files.
|
|
440
471
|
|
|
@@ -450,7 +481,7 @@ Options:
|
|
|
450
481
|
|
|
451
482
|

|
|
452
483
|
|
|
453
|
-
### 6.
|
|
484
|
+
### 6.14 `stats`
|
|
454
485
|
|
|
455
486
|
Local aggregate statistics over trace files in a directory. Read-only.
|
|
456
487
|
|
|
@@ -470,7 +501,7 @@ Options:
|
|
|
470
501
|
|
|
471
502
|
Use `--correlation-id` or `--group-id` to filter runs by `run_started` metadata (see [API.md](./API.md)).
|
|
472
503
|
|
|
473
|
-
### 6.
|
|
504
|
+
### 6.15 `search`
|
|
474
505
|
|
|
475
506
|
Deterministic search over local traces (substring / exact filters). No semantic search.
|
|
476
507
|
|
|
@@ -500,7 +531,7 @@ npx agent-inspect search --duration ">100ms" --json
|
|
|
500
531
|
|
|
501
532
|

|
|
502
533
|
|
|
503
|
-
### 6.
|
|
534
|
+
### 6.16 `what`
|
|
504
535
|
|
|
505
536
|
Concise human-readable summary of one local trace run. Read-only; accepts v0.1 manual JSONL and v0.2 persisted-event JSONL through the shared dual-format normalization path. Vocabulary: [TRACE-VOCABULARY-V1.5.md](./proposals/TRACE-VOCABULARY-V1.5.md).
|
|
506
537
|
|
|
@@ -529,7 +560,7 @@ Outcome: Completed successfully.
|
|
|
529
560
|
Slowest: plan (100ms, logic)
|
|
530
561
|
```
|
|
531
562
|
|
|
532
|
-
### 6.
|
|
563
|
+
### 6.17 `report`
|
|
533
564
|
|
|
534
565
|
Generate a local inspection report combining **what happened**, **timeline**, and **execution tree** sections. The command reads local v0.1 manual JSONL and v0.2 persisted-event JSONL through the shared dual-format normalization path without mutating them. Distinct from `export` (which targets shareable tree snapshots and standards formats).
|
|
535
566
|
|
|
@@ -554,6 +585,39 @@ Example:
|
|
|
554
585
|
npx agent-inspect report minimal-success --dir fixtures/traces --format html -o report.html
|
|
555
586
|
```
|
|
556
587
|
|
|
588
|
+
### 6.18 `explain`
|
|
589
|
+
|
|
590
|
+
Explain a local trace using deterministic facts and local inference labels. This command reads through the same local reader pipeline as `open` / `check`; it does not call a model provider, upload traces, replay agents, or mutate input files.
|
|
591
|
+
|
|
592
|
+
```bash
|
|
593
|
+
agent-inspect explain <trace-path-or-run-id> [options]
|
|
594
|
+
```
|
|
595
|
+
|
|
596
|
+
Options:
|
|
597
|
+
|
|
598
|
+
- `--dir <path>` — trace directory for run-id lookup
|
|
599
|
+
- `--format <agent-inspect-jsonl|openinference-json|otlp-json>` — explicit input format
|
|
600
|
+
- `--run <run-id>` — select a run when the trace contains multiple runs
|
|
601
|
+
- `--dry-run` — emit only the redacted facts payload, with no local inference labels
|
|
602
|
+
- `--provider <provider>` — reserved for an explicit future provider mode; currently rejected without network calls
|
|
603
|
+
- `--json` — print deterministic JSON output
|
|
604
|
+
- `--redaction-profile <local|share|strict>` — key-based redaction profile for the explanation payload (default `local`)
|
|
605
|
+
|
|
606
|
+
Examples:
|
|
607
|
+
|
|
608
|
+
```bash
|
|
609
|
+
npx agent-inspect explain minimal-success --dir fixtures/traces
|
|
610
|
+
npx agent-inspect explain fixtures/traces/minimal-success.jsonl --dry-run --json --redaction-profile strict
|
|
611
|
+
```
|
|
612
|
+
|
|
613
|
+
Provider design gate:
|
|
614
|
+
|
|
615
|
+
- Current behavior is local only. `--provider <provider>` exits with a user-facing `PROVIDER_NOT_IMPLEMENTED` error and performs no provider call.
|
|
616
|
+
- `--dry-run --json` is the payload review surface. The provider payload contract is the returned `explanation` object: `mode`, `runId`, optional `name` / `status`, `redactionProfile`, `facts`, `inferences`, and `notes`.
|
|
617
|
+
- Provider chunks must require explicit provider selection, document required environment variables, and keep credentials out of trace data and dry-run output.
|
|
618
|
+
- Provider prompts must ask for concise explanations from redacted facts only. They must not request, expose, or preserve raw chain-of-thought.
|
|
619
|
+
- Cloud provider behavior is never selected by default and must be reviewed before implementation. Local provider support must still be explicit and opt-in.
|
|
620
|
+
|
|
557
621
|
## 7. Optional TUI behavior
|
|
558
622
|
|
|
559
623
|
`view --tui` delegates to `@agent-inspect/tui` and requires an interactive terminal. If the package is not installed, the CLI prints a short install hint.
|
package/docs/EXPORTS.md
CHANGED
|
@@ -75,7 +75,7 @@ Experimental helpers (local-only):
|
|
|
75
75
|
- `exportMarkdown`, `exportHtml`, `exportOpenInference`, `exportOtlpJson`
|
|
76
76
|
- `validateExport`, `validateExportContent`
|
|
77
77
|
|
|
78
|
-
See [API.md](./API.md) §7.
|
|
78
|
+
Import these from `agent-inspect/exporters`. See [API.md](./API.md) §7.
|
|
79
79
|
|
|
80
80
|
## What not to share
|
|
81
81
|
|