agent-inspect 1.8.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 CHANGED
@@ -1,7 +1,15 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.9.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 309350e: Release v1.9.0 adoption leverage with the private harness workspace, explain dry-run/local analysis, promoted adapter adoption paths, and the v2 root API slimming plan.
8
+
3
9
  ## 1.8.0
4
10
 
11
+ Released **2026-06-27**.
12
+
5
13
  ### Minor Changes
6
14
 
7
15
  - 0bee42c: Release v1.8.0 with OpenAI Agents trace processor support, optional Vitest/Jest reporter packages kept private, deterministic CI release checks, and the validated local-first reporting improvements from the v1.8 release train.
package/README.md CHANGED
@@ -1,12 +1,12 @@
1
1
  # agent-inspect
2
2
 
3
- **Local execution trees for TypeScript AI agents.**
3
+ **Trace, check, and safely share TypeScript AI agent runs locally.**
4
4
 
5
- agent-inspect helps you understand what happened inside an AI agent run **locally**. It turns manual steps, tool calls, LLM calls, structured logs, failures, durations, and run metadata into **readable execution trees** you can inspect from the terminal.
5
+ agent-inspect helps you understand what happened inside an AI agent run without sending traces to a hosted service. It turns framework events, observed objects/classes, manual steps, tool calls, LLM calls, structured logs, failures, durations, and run metadata into readable local execution trees.
6
6
 
7
7
  It is built for TypeScript/Node.js developers and teams shipping real agentic products — not just toy demos. Use it for **local TypeScript agent debugging**, **eval iteration**, and **CI trace artifacts**. It **complements** production observability platforms; it does **not** replace them.
8
8
 
9
- The tool starts with **manual traces** and **existing structured logs**, and extends into **optional framework callbacks** and **standards-aligned local export** without turning the core into a SaaS or a vendor pipeline.
9
+ The default loop is local-first: capture a trace, inspect/report/diff it, run deterministic checks in CI, then export a redacted copy only when you choose to share.
10
10
 
11
11
  **No account. No cloud upload. No dashboard required.**
12
12
 
@@ -22,7 +22,7 @@ agent-inspect gives those runs **structure**: an **execution tree** you can read
22
22
 
23
23
  ## Install
24
24
 
25
- Current npm release: **1.7.0** (`agent-inspect`, `@agent-inspect/ai-sdk`, `@agent-inspect/langchain`, `@agent-inspect/tui` — all aligned).
25
+ Current npm release: **1.8.0** (`agent-inspect`, `@agent-inspect/ai-sdk`, `@agent-inspect/langchain`, `@agent-inspect/tui`, `@agent-inspect/openai-agents` — all aligned).
26
26
 
27
27
  ```bash
28
28
  npm install agent-inspect
@@ -40,10 +40,110 @@ npx agent-inspect --help
40
40
 
41
41
  For a clean npm/pnpm install checklist with ESM, CJS, and CLI checks, see [Clean install smoke test](docs/INSTALL-SMOKE-TEST.md).
42
42
 
43
- ## 60-second quickstart
43
+ ## Three adoption paths
44
+
45
+ Already using AI SDK, OpenAI Agents JS, LangChain, or LangGraph-through-LangChain? Start with **Path B** for framework-native local traces before adding manual instrumentation.
46
+
47
+ ### Path A — Observe an existing object/class
48
+
49
+ Use `observe()` when you already have an agent-like object with a `run`, `execute`, or `invoke` method.
44
50
 
45
51
  Create `demo.mjs`:
46
52
 
53
+ ```js
54
+ import { observe } from "agent-inspect";
55
+
56
+ class SupportAgent {
57
+ async run(input) {
58
+ return {
59
+ answer: `Answering: ${input.question}`,
60
+ };
61
+ }
62
+ }
63
+
64
+ const agent = observe(new SupportAgent(), {
65
+ traceDir: "./.agent-inspect",
66
+ });
67
+
68
+ await agent.run({
69
+ question: "How do refunds work?",
70
+ });
71
+ ```
72
+
73
+ Run it, then inspect the trace:
74
+
75
+ ```bash
76
+ node demo.mjs
77
+ npx agent-inspect list --dir ./.agent-inspect
78
+ npx agent-inspect view <run-id> --dir ./.agent-inspect
79
+ ```
80
+
81
+ ### Path B — Use a framework adapter
82
+
83
+ Optional adapters keep framework dependencies out of the root package and write local traces only when configured.
84
+
85
+ AI SDK local telemetry:
86
+
87
+ ```ts
88
+ import { generateText } from "ai";
89
+ import { agentInspect } from "@agent-inspect/ai-sdk";
90
+
91
+ await generateText({
92
+ model,
93
+ prompt,
94
+ experimental_telemetry: {
95
+ isEnabled: true,
96
+ recordInputs: false,
97
+ recordOutputs: false,
98
+ integrations: [
99
+ agentInspect({
100
+ traceDir: "./.agent-inspect",
101
+ runName: "support-agent",
102
+ capture: "metadata-only",
103
+ }),
104
+ ],
105
+ },
106
+ });
107
+ ```
108
+
109
+ OpenAI Agents local-only processor:
110
+
111
+ ```ts
112
+ import { setTraceProcessors } from "@openai/agents";
113
+ import { agentInspectProcessor } from "@agent-inspect/openai-agents";
114
+
115
+ setTraceProcessors([
116
+ agentInspectProcessor({
117
+ traceDir: "./.agent-inspect",
118
+ workflowName: "support-agent",
119
+ capture: "metadata-only",
120
+ }),
121
+ ]);
122
+ ```
123
+
124
+ LangChain callback adapter:
125
+
126
+ ```ts
127
+ import { AgentInspectCallback } from "@agent-inspect/langchain";
128
+
129
+ const callback = new AgentInspectCallback({
130
+ runName: "support-agent",
131
+ traceDir: "./.agent-inspect",
132
+ persist: true,
133
+ capture: "metadata-only",
134
+ });
135
+
136
+ await agent.invoke(input, { callbacks: [callback] });
137
+ ```
138
+
139
+ See [docs/ADAPTERS.md](docs/ADAPTERS.md).
140
+
141
+ No-network recipes: [ai-sdk-local-telemetry](examples/recipes/ai-sdk-local-telemetry/), [openai-agents-local-tracing](examples/recipes/openai-agents-local-tracing/), and [langgraph-callback-local](examples/recipes/langgraph-callback-local/).
142
+
143
+ ### Path C — Manually instrument custom flows
144
+
145
+ Use `inspectRun` and `step` when you want explicit names, custom nesting, or flows that are not object/class shaped.
146
+
47
147
  ```js
48
148
  import { inspectRun, step } from "agent-inspect";
49
149
 
@@ -71,15 +171,6 @@ await inspectRun(
71
171
  );
72
172
  ```
73
173
 
74
- Run it, then inspect the trace:
75
-
76
- ```bash
77
- node demo.mjs
78
- npx agent-inspect list --dir ./.agent-inspect
79
- npx agent-inspect view <run-id> --dir ./.agent-inspect
80
- npx agent-inspect view <run-id> --dir ./.agent-inspect --summary
81
- ```
82
-
83
174
  Full flow:
84
175
 
85
176
  ```bash
@@ -99,6 +190,31 @@ support-agent
99
190
 
100
191
  A runnable copy lives in [examples/00-quickstart-demo](examples/00-quickstart-demo/README.md).
101
192
 
193
+ Use the root import for stable beginner APIs:
194
+
195
+ ```ts
196
+ import {
197
+ observe,
198
+ inspectRun,
199
+ maybeInspectRun,
200
+ step,
201
+ getCurrentCorrelationMetadata,
202
+ } from "agent-inspect";
203
+ ```
204
+
205
+ Use subpaths for advanced, experimental, or lower-level workflows:
206
+
207
+ ```ts
208
+ import { openTrace } from "agent-inspect/readers";
209
+ import { memoryWriter } from "agent-inspect/writers";
210
+ import { runTraceChecks } from "agent-inspect/checks";
211
+ import { diffTraceEvents } from "agent-inspect/diff";
212
+ import { exportMarkdown } from "agent-inspect/exporters";
213
+ import { parseLogsToTrees } from "agent-inspect/logs";
214
+ import { traceEventsToPersistedInspectEvents } from "agent-inspect/persisted";
215
+ import { createInspector } from "agent-inspect/advanced";
216
+ ```
217
+
102
218
  **Env-gated tracing** (eval harnesses, CI): use `maybeInspectRun` and set `AGENT_INSPECT=1` when you want a trace — otherwise no files are written.
103
219
 
104
220
  ```ts
@@ -111,7 +227,7 @@ await maybeInspectRun("eval-case-42", async () => runAgent());
111
227
  AGENT_INSPECT=1 node eval-runner.mjs
112
228
  ```
113
229
 
114
- ## What you can do today (v1.7.0)
230
+ ## What you can do today (v1.8.0)
115
231
 
116
232
  - **Trace manually** with `inspectRun`, `step`, `step.llm`, `step.tool`, and `observe` — local JSONL under `.agent-inspect/` by default.
117
233
  - **Toggle tracing** with `maybeInspectRun` and `AGENT_INSPECT=1` in eval harnesses or CI.
@@ -122,9 +238,10 @@ AGENT_INSPECT=1 node eval-runner.mjs
122
238
  - **Parse structured logs** you already emit (JSON first-class; log4js best-effort).
123
239
  - **Optional LangChain adapter** — metadata-only by default; optional `persist: true` and `stream: true` streaming metadata (no full token capture by default).
124
240
  - **Optional AI SDK adapter** — experimental `@agent-inspect/ai-sdk` telemetry integration for AI SDK v6; metadata-only by default with `recordInputs: false` and `recordOutputs: false`.
241
+ - **Optional OpenAI Agents adapter** — experimental `@agent-inspect/openai-agents` trace processor for local OpenAI Agents JS trace processing.
125
242
  - **Optional TUI** — `view --tui` when `@agent-inspect/tui` is installed.
126
243
  - **Persisted-event foundation (v1.2.0+)** — in-memory `PersistedInspectEvent` converters; manual writing stays `schemaVersion: "0.1"`.
127
- - **Experimental v1.6.0 APIs** — `agent-inspect/writers`, `agent-inspect/readers`, `createInspector()`, and `agent-inspect open` for local AgentInspect/OpenInference/OTLP ingestion.
244
+ - **Experimental subpaths** — `agent-inspect/readers`, `/writers`, `/checks`, `/diff`, `/exporters`, `/logs`, `/persisted`, and `/advanced` for advanced local workflows.
128
245
 
129
246
  Nothing uploads traces by default. Review exports before sharing — see [safe trace sharing](docs/SAFE-TRACE-SHARING.md).
130
247
 
@@ -136,7 +253,7 @@ Each run produces a **JSONL** trace: `run_started` / `run_completed`, `step_star
136
253
 
137
254
  *Synthetic demo — [examples/02-nested-steps](examples/02-nested-steps/README.md). More visuals: [SCREENSHOTS.md](docs/SCREENSHOTS.md).*
138
255
 
139
- ## Works with structured logs you already have
256
+ ## Advanced ingestion: use this when your app already emits structured logs
140
257
 
141
258
  Many production systems already emit **line-delimited JSON** or text logs with embedded JSON (e.g. via **pino**, **winston**, **log4js**, **NestJS** loggers, job runners, or custom event streams). agent-inspect can turn those into **local grouped timelines/trees** without wrapping every function.
142
259
 
@@ -201,7 +318,7 @@ Full flags and behavior: [docs/CLI.md](docs/CLI.md).
201
318
 
202
319
  ## Stable foundation (AgentInspect 1.x)
203
320
 
204
- **agent-inspect 1.x** (current: **1.7.0**) is the **local-first trace workbench** for TypeScript AI agents:
321
+ **agent-inspect 1.x** (current: **1.8.0**) is the **local-first trace workbench** for TypeScript AI agents:
205
322
 
206
323
  - Instrument runs with `inspectRun` and `step`
207
324
  - Write **local JSONL traces** (`schemaVersion: "0.1"` — compatibility retained)
@@ -211,6 +328,8 @@ Full flags and behavior: [docs/CLI.md](docs/CLI.md).
211
328
 
212
329
  Pass `enabled: false` to `inspectRun` for a no-trace passthrough. Use `maybeInspectRun` with `AGENT_INSPECT=1` to toggle tracing in eval or CI — see [docs/API.md](docs/API.md).
213
330
 
331
+ **Shipped in 1.8.0:** experimental deterministic checks (`agent-inspect/checks` and `agent-inspect check`), safe-sharing workflows (`scan`, `verify-safe`, safe artifacts), and first public `@agent-inspect/openai-agents` package. Linked release aligns `agent-inspect`, `@agent-inspect/ai-sdk`, `@agent-inspect/langchain`, `@agent-inspect/tui`, and `@agent-inspect/openai-agents` at **1.8.0**.
332
+
214
333
  **Shipped in 1.7.0:** experimental `@agent-inspect/ai-sdk` telemetry integration for AI SDK v6 with a local no-network [ai-sdk-local-telemetry recipe](examples/recipes/ai-sdk-local-telemetry/), adapter conformance fixtures, OpenAI Agents/LangGraph support decisions, and local-first adapter docs. Examples keep `recordInputs: false`, `recordOutputs: false`, metadata-only capture, and no upload behavior. Linked release aligns `agent-inspect`, `@agent-inspect/ai-sdk`, `@agent-inspect/langchain`, and `@agent-inspect/tui` at **1.7.0**.
215
334
 
216
335
  **Shipped in 1.6.0:** experimental writer subpath (`agent-inspect/writers`), isolated `createInspector()` API via `agent-inspect/advanced`, local trace readers via `agent-inspect/readers`, OpenInference/OTLP JSON readers, universal `agent-inspect open`, and deterministic [runtime-and-ingestion recipe](examples/recipes/runtime-and-ingestion/). These remain local-only and do not add upload behavior. Linked release aligns all three then-published npm packages at **1.6.0**.
package/docs/ADAPTERS.md CHANGED
@@ -4,7 +4,7 @@ AgentInspect is **framework-agnostic** at its core. Optional adapter packages in
4
4
 
5
5
  ## Vercel AI SDK (`@agent-inspect/ai-sdk`)
6
6
 
7
- **Status:** experimental v1.7 adapter — optional package published in the v1.7.0 linked release.
7
+ **Status:** experimental adapter — optional package published in the aligned v1.8.0 package set.
8
8
 
9
9
  The v1.8 train has hardened lifecycle identity and parallel integration isolation. The adapter remains metadata-only: `capture: "preview"` and preview-only redaction options emit diagnostics and fall back to metadata-only capture until bounded free-text previews are implemented.
10
10
 
@@ -49,6 +49,34 @@ const result = await generateText({
49
49
 
50
50
  [examples/recipes/ai-sdk-local-telemetry](../examples/recipes/ai-sdk-local-telemetry/) uses AI SDK test utilities only (`MockLanguageModelV3`, `simulateReadableStream`) and writes local v0.2 adapter events for `agent-inspect open`.
51
51
 
52
+ ### Common host shapes
53
+
54
+ Use the same explicit telemetry block for route handlers, streaming, and tool calls. The adapter does not wrap providers or change host-call settings.
55
+
56
+ ```ts
57
+ const telemetry = {
58
+ isEnabled: true,
59
+ recordInputs: false,
60
+ recordOutputs: false,
61
+ integrations: [agentInspect({ traceDir: "./.agent-inspect", capture: "metadata-only" })],
62
+ };
63
+
64
+ // Next.js route or local handler
65
+ await generateText({ model, prompt, experimental_telemetry: telemetry });
66
+
67
+ // Streaming
68
+ await streamText({ model, prompt, experimental_telemetry: telemetry });
69
+
70
+ // Tool calls
71
+ await generateText({ model, prompt, tools, experimental_telemetry: telemetry });
72
+ ```
73
+
74
+ Review recipe output with:
75
+
76
+ ```bash
77
+ npx agent-inspect open ./examples/recipes/ai-sdk-local-telemetry/.agent-inspect-runs
78
+ ```
79
+
52
80
  Full API: [API.md](./API.md) §11.
53
81
 
54
82
  ---
@@ -181,6 +209,8 @@ LangGraph support is expected to ride through this same `@agent-inspect/langchai
181
209
 
182
210
  Future LangGraph examples must keep the same safety defaults: explicit callback installation, metadata-only capture, no raw prompt/output/tool payload capture by default, no hosted sink, and local persistence only when `persist: true` is set.
183
211
 
212
+ Runnable local recipe: [langgraph-callback-local](../examples/recipes/langgraph-callback-local).
213
+
184
214
  Decision note: [LANGGRAPH-ADAPTER-BOUNDARY.md](./proposals/LANGGRAPH-ADAPTER-BOUNDARY.md).
185
215
 
186
216
  ---
@@ -202,13 +232,13 @@ Requires an interactive terminal. See [API.md](./API.md) §10.
202
232
 
203
233
  ## Vitest (`@agent-inspect/vitest`)
204
234
 
205
- **Status:** experimental v1.8 reporter — optional workspace package, private/unpublished until release readiness.
235
+ **Status:** experimental workspace package, private/unpublished.
206
236
 
207
237
  ```bash
208
238
  npm install agent-inspect @agent-inspect/vitest vitest
209
239
  ```
210
240
 
211
- After publication, the reporter creates safe, structural artifacts for failed tests that explicitly attach AgentInspect trace metadata. It never guesses trace files by timestamp and does not read trace contents into artifacts.
241
+ The reporter creates safe, structural artifacts for failed tests that explicitly attach AgentInspect trace metadata. It never guesses trace files by timestamp and does not read trace contents into artifacts.
212
242
 
213
243
  ```ts
214
244
  import { createAgentInspectVitestReporter } from "@agent-inspect/vitest";
@@ -251,13 +281,13 @@ Full API: [API.md](./API.md) §12.
251
281
 
252
282
  ## Jest (`@agent-inspect/jest`)
253
283
 
254
- **Status:** experimental v1.8 reporter — optional workspace package, private/unpublished until release readiness.
284
+ **Status:** experimental workspace package, private/unpublished.
255
285
 
256
286
  ```bash
257
287
  npm install agent-inspect @agent-inspect/jest jest
258
288
  ```
259
289
 
260
- After publication, the reporter creates safe, structural artifacts for failed Jest assertions that explicitly attach AgentInspect trace metadata through a map or resolver. It never guesses trace files by timestamp and does not read trace contents into artifacts.
290
+ The reporter creates safe, structural artifacts for failed Jest assertions that explicitly attach AgentInspect trace metadata through a map or resolver. It never guesses trace files by timestamp and does not read trace contents into artifacts.
261
291
 
262
292
  ```js
263
293
  module.exports = {
@@ -294,7 +324,7 @@ Full API: [API.md](./API.md) §13.
294
324
 
295
325
  ## OpenAI Agents JS (`@agent-inspect/openai-agents`)
296
326
 
297
- **Status:** experimental v1.8 adapter — optional workspace package remains private/unpublished until the manual first-publication gate.
327
+ **Status:** experimental adapter — optional package published in the aligned v1.8.0 package set.
298
328
 
299
329
  The safe integration boundary is documented in [OPENAI-AGENTS-JS-TRACING.md](./proposals/OPENAI-AGENTS-JS-TRACING.md). Install the AgentInspect processor by replacing processors:
300
330
 
@@ -312,6 +342,11 @@ setTraceProcessors([
312
342
 
313
343
  Do not use `addTraceProcessor()` as the default AgentInspect path; that preserves the OpenAI default exporter in server runtimes. The processor does not auto-install itself, does not upload, and does not add OpenAI Agents dependencies to root/core.
314
344
 
345
+ Integration modes:
346
+
347
+ - **Local-only replacement:** `setTraceProcessors([agentInspectProcessor(...)])` replaces existing processors for the current process. This is the documented safe default when you want AgentInspect to own local trace output.
348
+ - **Additional processor:** `addTraceProcessor(agentInspectProcessor(...))` is an advanced, user-owned choice. It can preserve existing/default processors and any backend export behavior they already perform.
349
+
315
350
  - **No auto-install** — importing or constructing `agentInspectProcessor()` never calls `setTraceProcessors()` or `addTraceProcessor()`.
316
351
  - **No upload behavior** — the processor writes only to an explicit local writer or `traceDir`.
317
352
  - **Metadata-only by default** — records trace/span IDs, parentage, names, timing, status, errors, safe model/tool names, token counts, and bounded summaries.
package/docs/API.md CHANGED
@@ -9,14 +9,42 @@ AgentInspect is a **local-first execution-tree debugger**. It is not a SaaS, not
9
9
  - **Stable**: intended to be compatible across v1.x. Breaking changes require v2.0.
10
10
  - **Experimental**: available for adoption, but subject to refinement (including naming/shape changes) before a future stability declaration. Experimental APIs may change in v1.x.
11
11
 
12
- **1.x subpath exports:** Additive subpaths (`/logs`, `/exporters`, `/persisted`, `/diff`, `/advanced`, `/writers`, `/readers`) narrow the import surface for experimental and advanced APIs. Root `"."` imports remain valid through v1.x. Design: [API-BOUNDARY-V1.5.md](./implementation/API-BOUNDARY-V1.5.md).
12
+ Use the root import for stable beginner APIs. Use subpaths for advanced, experimental, or lower-level workflows.
13
+
14
+ ```ts
15
+ import {
16
+ observe,
17
+ inspectRun,
18
+ maybeInspectRun,
19
+ step,
20
+ getCurrentCorrelationMetadata,
21
+ } from "agent-inspect";
22
+ ```
23
+
24
+ **v1.9 root API direction:** do not add new root exports casually. Existing root imports keep working through v1.x for compatibility, but new advanced examples should use the subpath where the API lives. The intended stable root set for v2 is:
25
+
26
+ ```ts
27
+ import {
28
+ createInspector,
29
+ observe,
30
+ inspectRun,
31
+ maybeInspectRun,
32
+ step,
33
+ getCurrentCorrelationMetadata,
34
+ } from "agent-inspect";
35
+ ```
36
+
37
+ **1.x subpath exports:** Additive subpaths (`/logs`, `/exporters`, `/persisted`, `/diff`, `/advanced`, `/writers`, `/readers`, `/checks`) narrow the import surface for experimental and advanced APIs. Root `"."` imports remain valid through v1.x. Design: [API-BOUNDARY-V1.5.md](./implementation/API-BOUNDARY-V1.5.md).
13
38
 
14
39
  ```ts
15
- import { inspectRun, step } from "agent-inspect";
16
40
  import { parseLogsToTrees } from "agent-inspect/logs";
17
41
  import { exportMarkdown } from "agent-inspect/exporters";
18
42
  import { memoryWriter } from "agent-inspect/writers";
19
43
  import { openTrace } from "agent-inspect/readers";
44
+ import { runTraceChecks } from "agent-inspect/checks";
45
+ import { diffTraceEvents } from "agent-inspect/diff";
46
+ import { traceEventsToPersistedInspectEvents } from "agent-inspect/persisted";
47
+ import { createInspector } from "agent-inspect/advanced";
20
48
  ```
21
49
 
22
50
  Notes:
@@ -24,6 +52,7 @@ Notes:
24
52
  - The core guarantee of v1.x is **stable local debugging**: manual tracing + CLI inspection.
25
53
  - Export formats (OpenInference / OTLP JSON) are **local-only** and **compatibility-oriented**. They do **not** upload anywhere.
26
54
  - There are **zero production sinks** in v1.x; sink/uploader APIs are not stable.
55
+ - Advanced root exports in v1.x are compatibility aliases. Prefer `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` for new code.
27
56
 
28
57
  ## 2. Stable core APIs (manual tracing)
29
58
 
@@ -32,7 +61,13 @@ These are the recommended entry points for manual instrumentation. They are desi
32
61
  Import from `agent-inspect`:
33
62
 
34
63
  ```ts
35
- import { inspectRun, maybeInspectRun, step, observe } from "agent-inspect";
64
+ import {
65
+ observe,
66
+ inspectRun,
67
+ maybeInspectRun,
68
+ step,
69
+ getCurrentCorrelationMetadata,
70
+ } from "agent-inspect";
36
71
  ```
37
72
 
38
73
  - **`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.
@@ -90,7 +125,7 @@ These APIs support local workflows like listing traces, extracting metadata/summ
90
125
 
91
126
  ## 5. Experimental log parsing APIs
92
127
 
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.
128
+ 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
129
 
95
130
  - **`parseLogsToTrees`**
96
131
  - **`JsonLogParser`**, **`Log4jsParser`**
@@ -152,7 +187,7 @@ Rationale: v1.x includes one official adapter and **zero production sinks**, so
152
187
 
153
188
  ## 11. Experimental `@agent-inspect/ai-sdk` APIs
154
189
 
155
- `@agent-inspect/ai-sdk` is an optional v1.7 adapter package for Vercel AI SDK v6 telemetry integrations. It is experimental and published as part of the v1.7.0 linked release.
190
+ `@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
191
 
157
192
  Import from `@agent-inspect/ai-sdk`:
158
193
 
@@ -188,7 +223,7 @@ Recipe: [examples/recipes/ai-sdk-local-telemetry](../examples/recipes/ai-sdk-loc
188
223
 
189
224
  ## 12. Experimental `@agent-inspect/vitest` APIs
190
225
 
191
- `@agent-inspect/vitest` is an optional experimental package for local Vitest failure artifacts. In the v1.8 train it remains private/unpublished until release readiness. It does not add a Vitest dependency to root/core, does not upload artifacts, and does not infer trace relationships by timestamp.
226
+ `@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
227
 
193
228
  Import from `@agent-inspect/vitest`:
194
229
 
@@ -220,7 +255,7 @@ Artifacts are safe structural summaries. They include bounded test identity, sta
220
255
 
221
256
  ## 13. Experimental `@agent-inspect/jest` APIs
222
257
 
223
- `@agent-inspect/jest` is an optional experimental package for local Jest failure artifacts. In the v1.8 train it remains private/unpublished until release readiness. It does not add a Jest dependency to root/core, does not upload artifacts, and does not infer trace relationships by timestamp.
258
+ `@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
259
 
225
260
  Import from `@agent-inspect/jest`:
226
261
 
@@ -262,7 +297,7 @@ Artifacts are safe structural summaries. They include bounded test identity, sta
262
297
 
263
298
  ## 14. Experimental `@agent-inspect/openai-agents` APIs
264
299
 
265
- `@agent-inspect/openai-agents` is an optional experimental package for OpenAI Agents JS tracing processor integration. In the v1.8 train it remains private/unpublished until the manual first-publication gate, but runtime metadata mapping is implemented locally.
300
+ `@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
301
 
267
302
  Import from `@agent-inspect/openai-agents`:
268
303
 
@@ -295,7 +330,7 @@ The processor records local v0.2 persisted events for trace/run, agent, generati
295
330
 
296
331
  These helpers expose the **source-agnostic `PersistedInspectEvent` model** (`schemaVersion: "0.2"`). They are **local-only**, **in-memory**, and **do not change** storage write/read or CLI behavior in v1.2.0.
297
332
 
298
- Import from `agent-inspect`:
333
+ Import from `agent-inspect/persisted`:
299
334
 
300
335
  | API | Role |
301
336
  | --- | ---- |
@@ -461,16 +496,67 @@ The checks API is experimental in v1.x. The `agent-inspect check` CLI uses this
461
496
 
462
497
  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
498
 
464
- ## 22. Deprecated APIs
499
+ ## 22. Experimental local explain APIs (v1.9)
500
+
501
+ `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.
502
+
503
+ Import from `agent-inspect`:
504
+
505
+ ```ts
506
+ import { buildLocalExplanation } from "agent-inspect";
507
+ ```
508
+
509
+ - **`buildLocalExplanation(run, options?)`**:
510
+ - **`mode: "dry-run"`**: returns redacted observed facts and no inference labels.
511
+ - **`mode: "local"`** (default): returns observed facts plus deterministic local inference labels.
512
+ - **`redactionProfile`**: `local`, `share`, or `strict`; profile keys are redacted before the payload is returned.
513
+
514
+ CLI wrapper: `agent-inspect explain <trace-path-or-run-id> --dry-run --json`.
515
+
516
+ Provider design gate:
517
+
518
+ - No provider payload is submitted in v1.9 implementation chunks; `--provider <provider>` is reserved and rejected with `PROVIDER_NOT_IMPLEMENTED`.
519
+ - The reviewable provider payload contract is the `ExplainResult` object: `mode`, `runId`, optional `name` / `status`, `redactionProfile`, `facts`, `inferences`, and `notes`.
520
+ - Provider implementations must require explicit provider selection and documented environment requirements. The current local API reads no provider credentials.
521
+ - Provider prompts must use redacted facts only, label inferred claims, and must not request raw chain-of-thought.
522
+ - Provider packages or SDKs must not become root/core runtime dependencies.
523
+
524
+ ## 23. Experimental `@agent-inspect/harness` APIs
525
+
526
+ `@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.
527
+
528
+ Import from `@agent-inspect/harness` inside the workspace:
529
+
530
+ ```ts
531
+ import { createFixtureRunner, defineTarget } from "@agent-inspect/harness";
532
+ ```
533
+
534
+ - **`defineTarget(definition)`**: returns a typed target definition with `resolve(app, context)` and `invoke(target, input, context)` hooks.
535
+ - **`createFixtureRunner(options)`**: returns a local runner with:
536
+ - **`listTargets()`**: deterministic target metadata listing.
537
+ - **`runTarget(name, input, options?)`**: bootstrap, resolve, invoke, and shutdown lifecycle.
538
+ - **`runFromArgv(argv?, io?)`**: CLI-friendly execution with target listing, JSON fixture files, JSON stdin, JSON stdout, stderr summaries, trace flags, and expected-output comparison.
539
+ - **`getDiagnostics()`**: deterministic diagnostics for missing targets, bootstrap failures, resolve failures, invocation failures, and shutdown failures.
540
+ - **`trace`** options use existing AgentInspect local APIs only:
541
+ - **`mode: "run-if-enabled"`** (default): uses `maybeInspectRun()` and writes no trace unless `options.enabled` or `AGENT_INSPECT` enables tracing.
542
+ - **`mode: "run"`**: explicitly wraps the target invocation in `inspectRun()`.
543
+ - **`mode: "observe"`**: proxies the resolved target with `observe()` for `run` / `execute` / `invoke` methods when enabled.
544
+ - **`mode: "off"`**: invokes the target without AgentInspect tracing.
545
+
546
+ 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.
547
+
548
+ Recipes: [harness-basic](../examples/recipes/harness-basic/README.md) and [harness-adapter-local](../examples/recipes/harness-adapter-local/README.md).
549
+
550
+ ## 24. Deprecated APIs
465
551
 
466
552
  No deprecated APIs are declared as of 1.4.0.
467
553
 
468
- ## 23. Removal / deprecation policy
554
+ ## 25. Removal / deprecation policy
469
555
 
470
556
  - Stable APIs are not removed in v1.x.
471
557
  - 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
558
 
473
- ## 24. Backward compatibility policy
559
+ ## 26. Backward compatibility policy
474
560
 
475
561
  - Manual trace JSONL (`schemaVersion: "0.1"`) remains readable.
476
562
  - Additive schema changes are allowed in minor versions.
package/docs/CLI.md CHANGED
@@ -36,6 +36,7 @@ Core commands:
36
36
  - `search` — deterministic local search over traces
37
37
  - `what` — concise summary of a single run (local JSONL)
38
38
  - `report` — markdown or HTML inspection report for a single run
39
+ - `explain` — deterministic local facts/inferences for a trace, with dry-run payloads
39
40
 
40
41
  ## 2. Environment variables
41
42
 
@@ -138,7 +139,7 @@ Recommendation: run with `--dry-run` first.
138
139
 
139
140
  ### 6.4 `logs`
140
141
 
141
- Parse structured logs into local execution trees.
142
+ Advanced ingestion: use this when your app already emits structured logs. Parse those logs into local execution trees.
142
143
 
143
144
  ```bash
144
145
  agent-inspect logs <file> [options]
@@ -554,6 +555,39 @@ Example:
554
555
  npx agent-inspect report minimal-success --dir fixtures/traces --format html -o report.html
555
556
  ```
556
557
 
558
+ ### 6.17 `explain`
559
+
560
+ 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.
561
+
562
+ ```bash
563
+ agent-inspect explain <trace-path-or-run-id> [options]
564
+ ```
565
+
566
+ Options:
567
+
568
+ - `--dir <path>` — trace directory for run-id lookup
569
+ - `--format <agent-inspect-jsonl|openinference-json|otlp-json>` — explicit input format
570
+ - `--run <run-id>` — select a run when the trace contains multiple runs
571
+ - `--dry-run` — emit only the redacted facts payload, with no local inference labels
572
+ - `--provider <provider>` — reserved for an explicit future provider mode; currently rejected without network calls
573
+ - `--json` — print deterministic JSON output
574
+ - `--redaction-profile <local|share|strict>` — key-based redaction profile for the explanation payload (default `local`)
575
+
576
+ Examples:
577
+
578
+ ```bash
579
+ npx agent-inspect explain minimal-success --dir fixtures/traces
580
+ npx agent-inspect explain fixtures/traces/minimal-success.jsonl --dry-run --json --redaction-profile strict
581
+ ```
582
+
583
+ Provider design gate:
584
+
585
+ - Current behavior is local only. `--provider <provider>` exits with a user-facing `PROVIDER_NOT_IMPLEMENTED` error and performs no provider call.
586
+ - `--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`.
587
+ - Provider chunks must require explicit provider selection, document required environment variables, and keep credentials out of trace data and dry-run output.
588
+ - Provider prompts must ask for concise explanations from redacted facts only. They must not request, expose, or preserve raw chain-of-thought.
589
+ - Cloud provider behavior is never selected by default and must be reviewed before implementation. Local provider support must still be explicit and opt-in.
590
+
557
591
  ## 7. Optional TUI behavior
558
592
 
559
593
  `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.