agent-inspect 1.3.0 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/CHANGELOG.md +47 -4
  2. package/README.md +59 -37
  3. package/docs/ADAPTERS.md +117 -31
  4. package/docs/API.md +24 -6
  5. package/docs/CLI.md +126 -1
  6. package/docs/DIFF.md +8 -0
  7. package/docs/EXPORTS.md +86 -15
  8. package/docs/GETTING-STARTED.md +48 -2
  9. package/docs/KNOWN-ISSUES.md +6 -0
  10. package/docs/LIMITATIONS.md +11 -3
  11. package/docs/LOGS.md +22 -0
  12. package/docs/SCHEMA.md +8 -5
  13. package/docs/SCREENSHOTS.md +190 -9
  14. package/package.json +51 -1
  15. package/packages/cli/dist/index.cjs +3253 -1662
  16. package/packages/cli/dist/index.cjs.map +1 -1
  17. package/packages/cli/dist/index.mjs +3253 -1662
  18. package/packages/cli/dist/index.mjs.map +1 -1
  19. package/packages/core/dist/advanced.cjs +1437 -0
  20. package/packages/core/dist/advanced.cjs.map +1 -0
  21. package/packages/core/dist/advanced.d.cts +159 -0
  22. package/packages/core/dist/advanced.d.ts +159 -0
  23. package/packages/core/dist/advanced.mjs +8 -0
  24. package/packages/core/dist/advanced.mjs.map +1 -0
  25. package/packages/core/dist/chunk-5EMIZZXD.mjs +907 -0
  26. package/packages/core/dist/chunk-5EMIZZXD.mjs.map +1 -0
  27. package/packages/core/dist/chunk-7TGZLWEE.mjs +35 -0
  28. package/packages/core/dist/chunk-7TGZLWEE.mjs.map +1 -0
  29. package/packages/core/dist/chunk-BT7CATSD.mjs +497 -0
  30. package/packages/core/dist/chunk-BT7CATSD.mjs.map +1 -0
  31. package/packages/core/dist/chunk-E5F2LQCX.mjs +83 -0
  32. package/packages/core/dist/chunk-E5F2LQCX.mjs.map +1 -0
  33. package/packages/core/dist/chunk-EDTQHZPM.mjs +88 -0
  34. package/packages/core/dist/chunk-EDTQHZPM.mjs.map +1 -0
  35. package/packages/core/dist/chunk-HY7H3CQM.mjs +127 -0
  36. package/packages/core/dist/chunk-HY7H3CQM.mjs.map +1 -0
  37. package/packages/core/dist/chunk-Q6EPNB3V.mjs +539 -0
  38. package/packages/core/dist/chunk-Q6EPNB3V.mjs.map +1 -0
  39. package/packages/core/dist/chunk-QPAU2TPA.mjs +785 -0
  40. package/packages/core/dist/chunk-QPAU2TPA.mjs.map +1 -0
  41. package/packages/core/dist/chunk-QX3ZMPUF.mjs +451 -0
  42. package/packages/core/dist/chunk-QX3ZMPUF.mjs.map +1 -0
  43. package/packages/core/dist/chunk-VU6O5QAH.mjs +99 -0
  44. package/packages/core/dist/chunk-VU6O5QAH.mjs.map +1 -0
  45. package/packages/core/dist/chunk-XDBND27A.mjs +975 -0
  46. package/packages/core/dist/chunk-XDBND27A.mjs.map +1 -0
  47. package/packages/core/dist/chunk-YWAOOXLR.mjs +475 -0
  48. package/packages/core/dist/chunk-YWAOOXLR.mjs.map +1 -0
  49. package/packages/core/dist/diff.cjs +993 -0
  50. package/packages/core/dist/diff.cjs.map +1 -0
  51. package/packages/core/dist/diff.d.cts +81 -0
  52. package/packages/core/dist/diff.d.ts +81 -0
  53. package/packages/core/dist/diff.mjs +5 -0
  54. package/packages/core/dist/diff.mjs.map +1 -0
  55. package/packages/core/dist/exporters.cjs +1228 -0
  56. package/packages/core/dist/exporters.cjs.map +1 -0
  57. package/packages/core/dist/exporters.d.cts +113 -0
  58. package/packages/core/dist/exporters.d.ts +113 -0
  59. package/packages/core/dist/exporters.mjs +6 -0
  60. package/packages/core/dist/exporters.mjs.map +1 -0
  61. package/packages/core/dist/index.cjs +2982 -1829
  62. package/packages/core/dist/index.cjs.map +1 -1
  63. package/packages/core/dist/index.d.cts +201 -892
  64. package/packages/core/dist/index.d.ts +201 -892
  65. package/packages/core/dist/index.mjs +780 -4620
  66. package/packages/core/dist/index.mjs.map +1 -1
  67. package/packages/core/dist/log-config-BzGmDYum.d.cts +71 -0
  68. package/packages/core/dist/log-config-BzGmDYum.d.ts +71 -0
  69. package/packages/core/dist/logs.cjs +1007 -0
  70. package/packages/core/dist/logs.cjs.map +1 -0
  71. package/packages/core/dist/logs.d.cts +137 -0
  72. package/packages/core/dist/logs.d.ts +137 -0
  73. package/packages/core/dist/logs.mjs +6 -0
  74. package/packages/core/dist/logs.mjs.map +1 -0
  75. package/packages/core/dist/persisted.cjs +1057 -0
  76. package/packages/core/dist/persisted.cjs.map +1 -0
  77. package/packages/core/dist/persisted.d.cts +160 -0
  78. package/packages/core/dist/persisted.d.ts +160 -0
  79. package/packages/core/dist/persisted.mjs +5 -0
  80. package/packages/core/dist/persisted.mjs.map +1 -0
  81. package/packages/core/dist/types-Bkt7LS01.d.ts +226 -0
  82. package/packages/core/dist/types-CNbheSdk.d.cts +226 -0
package/CHANGELOG.md CHANGED
@@ -1,12 +1,55 @@
1
1
  # Changelog
2
2
 
3
- ## 1.3.0
3
+ ## 1.5.0
4
+
5
+ Released **2026-06-24**.
6
+
7
+ ### Added
8
+
9
+ - Added non-breaking package subpath exports: `agent-inspect/advanced`, `/persisted`, `/logs`, `/exporters`, `/diff` (root `"."` export unchanged).
10
+ - Added `agent-inspect what <runId>` — concise local run summary (`--json`, `--no-correlation`).
11
+ - Added `agent-inspect report <runId>` — markdown/HTML inspection report (`what` + timeline + execution tree).
12
+ - Added core helpers: `buildRunWhatSummary`, `renderRunWhat`, `buildRunReport`.
13
+ - Added canonical dual-format read path: `parseTraceJsonl`, `persistedInspectEventToTraceEvents`; `readTraceEvents` accepts v0.1 and v0.2 JSONL.
14
+ - Added [TRACE-VOCABULARY-V1.5.md](docs/proposals/TRACE-VOCABULARY-V1.5.md) RFC and `fixtures/traces-v0.2/llm-tokens-and-streaming.jsonl`.
15
+ - Added [what-report-inspect recipe](examples/recipes/what-report-inspect/) and CI artifact updates for `what`/`report`.
16
+
17
+ ### Changed
18
+
19
+ - Inspection CLI commands (`view`, `timeline`, `stats`, `search`, `diff`, `export`, `what`, `report`) use shared dual-format read path (v0.1 + v0.2).
20
+
21
+ ### Notes
4
22
 
5
- ### Minor Changes
23
+ - Manual trace writing remains `schemaVersion: "0.1"`.
24
+ - v0.2 read is normalization for inspection — not a write-path switch.
25
+ - Token fields in reports are user-supplied metadata only; core does not count tokens.
26
+ - No vendor upload, hosted dashboard, or cost engine.
27
+ - Linked release aligns `@agent-inspect/tui` with `agent-inspect` and `@agent-inspect/langchain` (all **1.5.0**).
6
28
 
7
- - 503d240: Correlation metadata, redaction profiles for share-safe exports, and LangChain streaming metadata support.
29
+ ## 1.4.0
30
+
31
+ Released **2026-06-12**.
32
+
33
+ ### Added
34
+
35
+ - Added `docs/CI-ARTIFACTS.md` and `examples/recipes/github-actions-artifact/` for CI trace artifact workflows.
36
+ - Added `agent-inspect timeline <runId>` — chronological local run view (`--json`, `--focus slow`).
37
+ - Added `agent-inspect stats` — local aggregate stats (`--since`, `--correlation-id`, `--group-id`, `--json`).
38
+ - Added `agent-inspect search` — deterministic local trace search (`--status`, `--kind`, `--name`, `--tool`, `--duration`, `--json`).
39
+ - Added core helpers: `buildRunTimeline`, `buildTraceStats`, `searchTraces`.
40
+
41
+ ### Notes
42
+
43
+ - CI artifact upload is configured in user CI (e.g. GitHub Actions `upload-artifact`) — AgentInspect does not upload.
44
+ - Search is exact/contains matching only — no semantic search or index database.
45
+ - Stats/search scan local files linearly — intended for developer-machine scale.
46
+ - No Vitest/Jest reporter package in this release.
47
+ - Manual trace writing remains `schemaVersion: "0.1"`.
48
+ - Linked release aligns `@agent-inspect/tui` with `agent-inspect` and `@agent-inspect/langchain` (all **1.4.0**).
49
+
50
+ ## 1.3.0
8
51
 
9
- ## 1.3.0 — Unreleased
52
+ Released **2026-06-12**.
10
53
 
11
54
  ### Added
12
55
 
package/README.md CHANGED
@@ -10,6 +10,8 @@ The tool starts with **manual traces** and **existing structured logs**, and ext
10
10
 
11
11
  **No account. No cloud upload. No dashboard required.**
12
12
 
13
+ **Visual demos:** [docs/SCREENSHOTS.md](docs/SCREENSHOTS.md) — curated terminal recordings (synthetic fixtures only).
14
+
13
15
  ## Why agent-inspect exists
14
16
 
15
17
  AI agents are no longer single function calls. They plan, call tools, invoke LLMs, branch, retry, fail, and run work in parallel. **Console logs are flat**; reconstructing causality from a wall of lines is slow and error-prone.
@@ -20,7 +22,7 @@ agent-inspect gives those runs **structure**: an **execution tree** you can read
20
22
 
21
23
  ## Install
22
24
 
23
- Current npm release: **1.2.0**.
25
+ Current npm release: **1.5.0** (`agent-inspect`, `@agent-inspect/langchain`, `@agent-inspect/tui` — all aligned).
24
26
 
25
27
  ```bash
26
28
  npm install agent-inspect
@@ -109,10 +111,29 @@ await maybeInspectRun("eval-case-42", async () => runAgent());
109
111
  AGENT_INSPECT=1 node eval-runner.mjs
110
112
  ```
111
113
 
114
+ ## What you can do today (v1.5.0)
115
+
116
+ - **Trace manually** with `inspectRun`, `step`, `step.llm`, `step.tool`, and `observe` — local JSONL under `.agent-inspect/` by default.
117
+ - **Toggle tracing** with `maybeInspectRun` and `AGENT_INSPECT=1` in eval harnesses or CI.
118
+ - **Correlate runs** with optional `correlationId`, `requestId`, `decisionId`, and `groupId` on `run_started` metadata.
119
+ - **Redact before disk** with default key-based redaction, or choose `redactionProfile`: `local`, `share`, or `strict`.
120
+ - **Inspect from the CLI** — `list`, `view`, `clean`, `logs`, `tail`, `export`, `diff`, `timeline`, `stats`, `search`, `what`, `report`.
121
+ - **Export share-safe copies** — `export --redaction-profile share` (or `strict`) writes local Markdown/HTML/OpenInference/OTLP JSON only.
122
+ - **Parse structured logs** you already emit (JSON first-class; log4js best-effort).
123
+ - **Optional LangChain adapter** — metadata-only by default; optional `persist: true` and `stream: true` streaming metadata (no full token capture by default).
124
+ - **Optional TUI** — `view --tui` when `@agent-inspect/tui` is installed.
125
+ - **Persisted-event foundation (v1.2.0+)** — in-memory `PersistedInspectEvent` converters; manual writing stays `schemaVersion: "0.1"`.
126
+
127
+ Nothing uploads traces by default. Review exports before sharing — see [safe trace sharing](docs/SAFE-TRACE-SHARING.md).
128
+
112
129
  ## What the trace shows
113
130
 
114
131
  Each run produces a **JSONL** trace: `run_started` / `run_completed`, `step_started` / `step_completed`, with **nested steps**, **tool/LLM** types where you use `step.tool` / `step.llm`, and **durations** on completed steps. Failures are recorded on `step_completed` with `status: "error"` (there is no separate `step_failed` event). See [docs/SCHEMA.md](docs/SCHEMA.md).
115
132
 
133
+ ![Nested execution tree from a local JSONL trace](https://raw.githubusercontent.com/rajudandigam/agent-inspect/main/docs/assets/demos/execution-tree.gif)
134
+
135
+ *Synthetic demo — [examples/02-nested-steps](examples/02-nested-steps/README.md). More visuals: [SCREENSHOTS.md](docs/SCREENSHOTS.md).*
136
+
116
137
  ## Works with structured logs you already have
117
138
 
118
139
  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.
@@ -137,6 +158,8 @@ npx agent-inspect logs ./agent.log --config agent-inspect.logs.json
137
158
  - **Flat timeline by default**; nesting when parent relationships are explicit or configured.
138
159
  - **Confidence labels** (`explicit`, `correlated`, `heuristic`, `unknown`) describe how attribution was inferred.
139
160
 
161
+ **Visual:** JSON log → tree recording is [documented in SCREENSHOTS.md](docs/SCREENSHOTS.md#json-logs--tree) (re-record pending; command above is the canonical flow).
162
+
140
163
  More detail: [docs/LOGS.md](docs/LOGS.md) · [docs/LOG-TO-TREE-QUICKSTART.md](docs/LOG-TO-TREE-QUICKSTART.md) · [docs/LOGGING-PLAYBOOK.md](docs/LOGGING-PLAYBOOK.md) (pino, log4js, NestJS).
141
164
 
142
165
  ## CLI at a glance
@@ -150,6 +173,15 @@ More detail: [docs/LOGS.md](docs/LOGS.md) · [docs/LOG-TO-TREE-QUICKSTART.md](do
150
173
  | `tail` | Watch structured logs while the app runs |
151
174
  | `export` | Write Markdown / HTML / OpenInference-compatible JSON / OTLP JSON **locally** |
152
175
  | `diff` | Compare two local runs (read-only) |
176
+ | `timeline` | Chronological view of one run |
177
+ | `stats` | Local aggregates over a trace directory |
178
+ | `search` | Deterministic search over local traces |
179
+ | `what` | Concise summary of one run |
180
+ | `report` | Markdown/HTML inspection report (what + timeline + tree) |
181
+
182
+ ![Timeline with slow-step focus for one run](https://raw.githubusercontent.com/rajudandigam/agent-inspect/main/docs/assets/demos/timeline.gif)
183
+
184
+ *Synthetic demo — `agent-inspect timeline` on [fixtures/traces](fixtures/traces). Gallery: [SCREENSHOTS.md](docs/SCREENSHOTS.md).*
153
185
 
154
186
  Full flags and behavior: [docs/CLI.md](docs/CLI.md).
155
187
 
@@ -164,31 +196,29 @@ Full flags and behavior: [docs/CLI.md](docs/CLI.md).
164
196
 
165
197
  ## Stable foundation (AgentInspect 1.x)
166
198
 
167
- **agent-inspect 1.x** (current: **1.2.0**) stabilizes the **local debugging foundation**:
199
+ **agent-inspect 1.x** (current: **1.5.0**) is the **local-first trace workbench** for TypeScript AI agents:
168
200
 
169
- - Instrument a run with `inspectRun` and `step`
201
+ - Instrument runs with `inspectRun` and `step`
170
202
  - Write **local JSONL traces** (`schemaVersion: "0.1"` — compatibility retained)
171
- - Inspect runs with **`list`** and **`view`**
172
- - Safely remove old trace files with **`clean`**
203
+ - Inspect with **`list`**, **`view`**, **`clean`**, **`logs`**, **`tail`**, **`export`**, **`diff`**, **`timeline`**, **`stats`**, **`search`**
173
204
 
174
- **Stable APIs:** `inspectRun()`, `maybeInspectRun()`, `step()`, `step.llm()`, `step.tool()`, `observe()`.
205
+ **Stable APIs:** `inspectRun()`, `maybeInspectRun()`, `step()`, `step.llm()`, `step.tool()`, `observe()`, `getCurrentCorrelationMetadata()`.
175
206
 
176
- Pass `enabled: false` to `inspectRun` for a no-trace passthrough. Use `maybeInspectRun` with `AGENT_INSPECT=1` (or `true` / `yes` / `on` / `enabled`) to toggle tracing in eval or CI jobs — see [docs/API.md](docs/API.md).
207
+ 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).
177
208
 
178
- **Stable CLI workflows:** `agent-inspect list`, `agent-inspect view`, `agent-inspect clean`.
209
+ **Shipped in 1.5.0:** non-breaking subpath exports; `what` and `report` CLI; dual-format read path (v0.1 + v0.2 JSONL); [what-report-inspect recipe](examples/recipes/what-report-inspect/). Linked release aligns all three npm packages at **1.5.0**.
179
210
 
180
- **Also included in 1.x** as local-first extensions:
211
+ **Shipped in 1.4.0:** CI artifact recipe ([docs/CI-ARTIFACTS.md](docs/CI-ARTIFACTS.md)); `timeline`, `stats`, and `search` CLI; core helpers `buildRunTimeline`, `buildTraceStats`, `searchTraces`. Linked release aligns all three npm packages at **1.4.0**.
181
212
 
182
- - Structured log inspection: **`logs`**
183
- - Live log tailing: **`tail`**
184
- - Local exports: **`export`** (Markdown, HTML, OpenInference-compatible JSON, OTLP JSON — files only)
185
- - Local run comparison: **`diff`**
186
- - Optional **`@agent-inspect/langchain`** callback adapter
187
- - Optional **`@agent-inspect/tui`** terminal viewer
188
- - **Fixtures** and **recipes** for deterministic checks and adoption patterns
189
- - **v1.2.0** — experimental persisted-event foundation (`PersistedInspectEvent`, converters, in-memory tree bridge) for future source-agnostic local inspection. Manual trace writing remains **`schemaVersion: "0.1"`**; v0.2 is **not written by default**; CLI behavior unchanged; no vendor upload.
213
+ **Shipped in 1.3.0:** correlation metadata; redaction profiles (`local` / `share` / `strict`); `export --redaction-profile`; LangChain `stream: true` metadata (chunk counts, duration — no full token capture by default).
190
214
 
191
- **Honest boundaries:** programmatic log parsing, export, and diff APIs; LangChain and TUI programmatic surfaces; and OpenInference/OTLP JSON exports are **experimental or compatibility-oriented**. Nothing performs **vendor upload** by default.
215
+ **Also in 1.x** (local-first extensions):
216
+
217
+ - **v1.2.0** — experimental persisted-event foundation (`PersistedInspectEvent`, converters, in-memory tree bridge). Manual writing remains **`schemaVersion: "0.1"`**; v0.2 is **not written by default**.
218
+ - Optional **`@agent-inspect/langchain`** and **`@agent-inspect/tui`**
219
+ - **Fixtures** and **recipes** for deterministic adoption patterns
220
+
221
+ **Honest boundaries:** log parsing, export, diff, LangChain/TUI programmatic APIs, and OpenInference/OTLP JSON exports are **experimental or compatibility-oriented**. Nothing performs **vendor upload** by default.
192
222
 
193
223
  ## Optional packages
194
224
 
@@ -252,6 +282,7 @@ The TUI is available as a separate optional package; its programmatic API is exp
252
282
  | [examples/recipes/nestjs-json-logging](examples/recipes/nestjs-json-logging) | NestJS JSON logs |
253
283
  | [examples/recipes/retry-fallback](examples/recipes/retry-fallback) | Fallback pattern |
254
284
  | [examples/recipes/parallel-tools](examples/recipes/parallel-tools) | Parallel tools |
285
+ | [examples/recipes/github-actions-artifact](examples/recipes/github-actions-artifact) | CI trace artifacts |
255
286
 
256
287
  **Recipes** are deterministic and require **no external services** by default. Index: [examples/README.md](examples/README.md), [examples/recipes/README.md](examples/recipes/README.md).
257
288
 
@@ -272,25 +303,16 @@ For a detailed comparison, see [Compare with other tools](docs/COMPARE.md).
272
303
 
273
304
  ## Documentation
274
305
 
275
- - [Getting started](docs/GETTING-STARTED.md)
276
- - [Clean install smoke test](docs/INSTALL-SMOKE-TEST.md)
277
- - [API stability & experimental surfaces](docs/API.md)
278
- - [CLI reference](docs/CLI.md)
279
- - [Schema (`schemaVersion: "0.1"`)](docs/SCHEMA.md)
280
- - [Architecture (links to deeper design notes)](docs/ARCHITECTURE.md)
281
- - [Logs & tail](docs/LOGS.md)
282
- - [Log-to-tree quickstart](docs/LOG-TO-TREE-QUICKSTART.md)
283
- - [Logging playbook](docs/LOGGING-PLAYBOOK.md)
284
- - [Exports](docs/EXPORTS.md)
285
- - [Diff](docs/DIFF.md)
286
- - [Adapters](docs/ADAPTERS.md)
287
- - [Compare with other tools](docs/COMPARE.md)
288
- - [Security](SECURITY.md)
289
- - [Safe trace sharing checklist](docs/SAFE-TRACE-SHARING.md)
290
- - [Changelog](CHANGELOG.md) — **upcoming [1.3.0](CHANGELOG.md#130--unreleased)** on `main` (not yet on npm): correlation metadata, share-safe export profiles, LangChain streaming metadata
291
- - [Known issues](docs/KNOWN-ISSUES.md)
292
- - [Limitations](docs/LIMITATIONS.md)
293
- - [Screenshot checklist (planned assets)](docs/SCREENSHOTS.md)
306
+ | Start here | Reference | Safety & boundaries |
307
+ | ---------- | --------- | ------------------- |
308
+ | [Getting started](docs/GETTING-STARTED.md) | [API](docs/API.md) | [Safe trace sharing](docs/SAFE-TRACE-SHARING.md) |
309
+ | [Install smoke test](docs/INSTALL-SMOKE-TEST.md) | [CLI](docs/CLI.md) | [Security](SECURITY.md) |
310
+ | [Log-to-tree quickstart](docs/LOG-TO-TREE-QUICKSTART.md) | [Schema](docs/SCHEMA.md) | [Limitations](docs/LIMITATIONS.md) |
311
+ | [Logging playbook](docs/LOGGING-PLAYBOOK.md) | [Exports](docs/EXPORTS.md) | [Known issues](docs/KNOWN-ISSUES.md) |
312
+ | [CI artifacts](docs/CI-ARTIFACTS.md) | [Adapters](docs/ADAPTERS.md) | [Compare with other tools](docs/COMPARE.md) |
313
+ | [Visual demos](docs/SCREENSHOTS.md) | [Examples](examples/README.md) | |
314
+
315
+ Also: [Architecture](docs/ARCHITECTURE.md) · [Logs & tail](docs/LOGS.md) · [Diff](docs/DIFF.md) · [Changelog](CHANGELOG.md) · [Roadmap](ROADMAP.md) · [Contributing](CONTRIBUTING.md) · [Good first issues](GOOD-FIRST-ISSUES.md)
294
316
 
295
317
  ## Contributing
296
318
 
package/docs/ADAPTERS.md CHANGED
@@ -1,27 +1,38 @@
1
- ## Adapters
1
+ # Adapters
2
2
 
3
- AgentInspect is framework-agnostic at its core, but can optionally integrate with frameworks via adapter packages.
3
+ AgentInspect is **framework-agnostic** at its core. Optional adapter packages integrate specific frameworks without monkey-patching, vendor sinks, or network upload.
4
4
 
5
- - **LangChain.js adapter** (optional): `@agent-inspect/langchain`
6
- - Documented as **experimental** in `docs/API.md`
7
- - Requires `@langchain/core` as a peer dependency
8
- - **In-memory by default** (`getEvents()` / `clear()`)
9
- - **Optional JSONL persistence** (`persist: true`) maps callback lifecycle to schemaVersion `"0.1"` manual events (`run_started`, `step_started`, `step_completed`, `run_completed`) so `list` / `view` / `export` / `diff` work without a separate schema
10
- - **Metadata-only capture by default**; `capture: "preview"` is opt-in with truncation
11
- - **Optional streaming metadata** (`stream: true`) — chunk counts, timing, and bounded previews only; **no full token stream** captured by default
12
- - **No monkey-patching**, **no vendor sinks**, **no network upload**
13
- - **Interactive TUI** (optional): `@agent-inspect/tui`
14
- - Documented as **experimental** in `docs/API.md`
15
- - Intended for CLI integration; programmatic TUI APIs may change
5
+ ## LangChain.js (`@agent-inspect/langchain`)
16
6
 
17
- ### LangChain persistence model (Strategy A)
7
+ **Status:** experimental programmatic API may evolve independently of stable core tracing.
18
8
 
19
- When `persist: true`:
9
+ ### Install
20
10
 
21
- 1. **Standalone callback session** — one AgentInspect run per `AgentInspectCallback` instance until the root LangChain run completes.
22
- 2. **Inside `inspectRun`** callback steps append to the active manual run (no extra `run_started` / `run_completed`).
23
- 3. **Parent mapping** — LangChain `parentRunId` maps to AgentInspect `parentId` when the parent step was already persisted; unknown parents stay at run root (no invented hierarchy).
24
- 4. **Step types** — `LLM` → `llm`, `TOOL` → `tool`, `DECISION` → `decision`, other kinds → `logic`.
11
+ ```bash
12
+ npm install agent-inspect @agent-inspect/langchain @langchain/core
13
+ ```
14
+
15
+ ### Basic callback (in-memory)
16
+
17
+ ```ts
18
+ import { AgentInspectCallback } from "@agent-inspect/langchain";
19
+
20
+ const callback = new AgentInspectCallback({
21
+ runName: "support-agent",
22
+ capture: "metadata-only", // default
23
+ });
24
+
25
+ await agent.invoke(input, { callbacks: [callback] });
26
+
27
+ const events = callback.getEvents();
28
+ callback.clear();
29
+ ```
30
+
31
+ - **No monkey-patching** — pass the callback explicitly to LangChain.
32
+ - **Metadata-only by default** — does not capture full prompts/outputs unless you opt into `capture: "preview"`.
33
+ - **No vendor sink** — events stay in memory unless you set `persist: true`.
34
+
35
+ ### Persist to local JSONL
25
36
 
26
37
  ```ts
27
38
  const callback = new AgentInspectCallback({
@@ -30,23 +41,38 @@ const callback = new AgentInspectCallback({
30
41
  persist: true,
31
42
  capture: "metadata-only",
32
43
  });
44
+
45
+ await agent.invoke(input, { callbacks: [callback] });
33
46
  ```
34
47
 
35
48
  ```bash
36
49
  npx agent-inspect list --dir ./.agent-inspect
37
50
  npx agent-inspect view <run-id> --dir ./.agent-inspect
51
+ npx agent-inspect export <run-id> --format markdown --redaction-profile share
38
52
  ```
39
53
 
40
- ### LangChain streaming metadata (v1.3.0+)
54
+ ![LangChain callback with persist true writing inspectable JSONL](../assets/demos/langchain-persistence.gif)
55
+
56
+ *Synthetic demo — [examples/08-langchain-adapter](../../examples/08-langchain-adapter/README.md).*
57
+
58
+ **Persistence model (Strategy A):**
59
+
60
+ 1. **Standalone session** — one AgentInspect run per callback instance until the root LangChain run completes.
61
+ 2. **Inside `inspectRun`** — callback steps append to the active manual run (no extra `run_started` / `run_completed`).
62
+ 3. **Parent mapping** — LangChain `parentRunId` maps to AgentInspect `parentId` when the parent step was persisted; unknown parents stay at run root.
63
+ 4. **Step types** — `LLM` → `llm`, `TOOL` → `tool`, `DECISION` → `decision`, other kinds → `logic`.
64
+
65
+ Written events use `schemaVersion: "0.1"` manual trace names.
66
+
67
+ ### Capture modes
41
68
 
42
- When `stream: true` on `AgentInspectCallback`:
69
+ | `capture` | Behavior |
70
+ | --------- | -------- |
71
+ | `none` | Minimal metadata |
72
+ | `metadata-only` | **Default** — model names, token usage, timing; no full text |
73
+ | `preview` | Truncated previews via `maxPreviewChars` — review before sharing |
43
74
 
44
- - `handleLLMNewToken` updates **in-memory streaming stats** only (no per-token JSONL lines).
45
- - On LLM end/error, metadata such as `chunkCount`, `firstChunkAt`, `lastChunkAt`, `streamDurationMs`, and `streamedCharCount` attach to the LLM completion event.
46
- - **`capture: "metadata-only"`** (default) does **not** store token text.
47
- - **`capture: "preview"`** may include a **bounded** `streamPreview` via `maxStreamPreviewChars` (defaults to `maxPreviewChars`).
48
- - With **`persist: true`**, streaming metadata is written on the LLM `step_started` metadata at completion time (deferred write for streaming LLM steps).
49
- - Inspect persisted runs locally: `agent-inspect list`, `view`, `export --redaction-profile share`.
75
+ ### Streaming metadata (v1.3.0+)
50
76
 
51
77
  ```ts
52
78
  const callback = new AgentInspectCallback({
@@ -56,8 +82,68 @@ const callback = new AgentInspectCallback({
56
82
  });
57
83
  ```
58
84
 
59
- See also:
60
- - `docs/MIGRATION.md` (what changed from early versions)
61
- - `docs/API.md` (LangChain adapter options: `persist`, `capture`, `stream`, `traceDir`)
62
- - `docs/SAFE-TRACE-SHARING.md` (review exports before sharing)
85
+ When `stream: true`:
86
+
87
+ - `handleLLMNewToken` updates **in-memory stats only** no per-token JSONL lines.
88
+ - On LLM end/error: `chunkCount`, `firstChunkAt`, `lastChunkAt`, `streamDurationMs`, `streamedCharCount`.
89
+ - **`capture: "metadata-only"`** does **not** store raw token text.
90
+ - **`capture: "preview"`** may include bounded `streamPreview` via `maxStreamPreviewChars`.
91
+ - With **`persist: true`**, streaming metadata is written on the LLM step at completion (deferred write for streaming LLM steps).
92
+
93
+ Streaming metadata is for **local inspection and timing** — not replay or cassette playback.
94
+
95
+ ### Correlation inside `inspectRun`
96
+
97
+ When the callback runs inside `inspectRun` / `maybeInspectRun`, correlation fields from `getCurrentCorrelationMetadata()` attach to LLM lifecycle events.
98
+
99
+ ### Options reference
100
+
101
+ | Option | Default | Notes |
102
+ | ------ | ------- | ----- |
103
+ | `persist` | `false` | Write local JSONL |
104
+ | `runName` | `"langchain-agent"` | Standalone persisted run name |
105
+ | `traceDir` | from env / `.agent-inspect` | |
106
+ | `capture` | `"metadata-only"` | |
107
+ | `stream` | `false` | Streaming lifecycle metadata |
108
+ | `maxStreamPreviewChars` | `maxPreviewChars` | Bounds preview when `capture: "preview"` |
109
+ | `redact` | — | Custom `RedactionRule[]` before disk |
110
+
111
+ Full API: [API.md](./API.md) §9.
112
+
113
+ ### Example
114
+
115
+ [examples/08-langchain-adapter](../examples/08-langchain-adapter/README.md)
116
+
117
+ ---
118
+
119
+ ## TUI (`@agent-inspect/tui`)
120
+
121
+ **Status:** experimental programmatic API; CLI integration is the intended usage.
122
+
123
+ ```bash
124
+ npm install agent-inspect @agent-inspect/tui
125
+ npx agent-inspect view <run-id> --tui
126
+ ```
127
+
128
+ ![Optional Ink TUI viewer for a local trace](../assets/demos/tui-viewer.gif)
129
+
130
+ Requires an interactive terminal. See [API.md](./API.md) §10.
131
+
132
+ ---
133
+
134
+ ## Future adapters (not shipped)
135
+
136
+ Direction only — see [ROADMAP.md](../ROADMAP.md):
137
+
138
+ - **Vercel AI SDK** — optional callback-style adapter (metadata-first, no vendor sink)
139
+ - **NestJS / logging bridges** — deeper recipes or helper patterns beyond [LOGGING-PLAYBOOK.md](./LOGGING-PLAYBOOK.md)
140
+
141
+ No automatic universal instrumentation. Integrations remain explicit and opt-in.
142
+
143
+ ---
144
+
145
+ ## Related docs
63
146
 
147
+ - [API.md](./API.md) — adapter options and stability policy
148
+ - [SAFE-TRACE-SHARING.md](./SAFE-TRACE-SHARING.md) — review exports before sharing
149
+ - [LIMITATIONS.md](./LIMITATIONS.md) — LangChain streaming and metadata boundaries
package/docs/API.md CHANGED
@@ -9,6 +9,14 @@ 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
+ **v1.5.0 subpath exports:** Additive subpaths (`/logs`, `/exporters`, `/persisted`, `/diff`, `/advanced`) 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
+
14
+ ```ts
15
+ import { inspectRun, step } from "agent-inspect";
16
+ import { parseLogsToTrees } from "agent-inspect/logs";
17
+ import { exportMarkdown } from "agent-inspect/exporters";
18
+ ```
19
+
12
20
  Notes:
13
21
 
14
22
  - The core guarantee of v1.x is **stable local debugging**: manual tracing + CLI inspection.
@@ -31,7 +39,7 @@ import { inspectRun, maybeInspectRun, step, observe } from "agent-inspect";
31
39
  - **`maxMetadataValueLength`**: max string length for metadata values (default `2000`).
32
40
  - **`maxPreviewLength`**: max string length for preview-like keys containing `preview` (default `500`).
33
41
  - **`maxEventBytes`**: max UTF-8 bytes per serialized JSONL event (default `65536`). Oversized events are truncated; instrumentation never throws into user code.
34
- - **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 future stats/cohort views. They are **metadata only** — they do not replace `runId`. Treat sensitive IDs as trace data before sharing exports.
42
+ - **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.
35
43
  - **`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.
36
44
  - **`isAgentInspectEnabled(value?)`**: returns whether a string (or `process.env.AGENT_INSPECT`) matches an enable token.
37
45
  - **`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.
@@ -166,23 +174,33 @@ Related types: `PersistedInspectEvent`, `PersistedEventSourceType`, `PersistedEv
166
174
  - v0.2 is **not written by default**; use converters and `fixtures/traces-v0.2/` samples for validation.
167
175
  - Storage dual-read and CLI integration are future work.
168
176
 
169
- ## 12. Deprecated APIs
177
+ ## 12. Local observability helpers (v1.4.0)
178
+
179
+ Read-only helpers for timeline, stats, and search over manual `TraceEvent` JSONL. Local files only.
180
+
181
+ - **`buildRunTimeline`**, **`renderTimeline`** — chronological run view; types `RunTimeline`, `TimelineEntry`
182
+ - **`buildTraceStats`**, **`renderTraceStats`** — directory aggregates; type `TraceStats`
183
+ - **`searchTraces`**, **`parseDurationFilter`**, **`loadTraceMetadataList`** — deterministic search; types `TraceSearchResult`, `TraceSearchOptions`
184
+
185
+ CLI wrappers: `agent-inspect timeline`, `stats`, `search` — see [CLI.md](./CLI.md).
186
+
187
+ ## 13. Deprecated APIs
170
188
 
171
- No deprecated APIs are declared as of 1.2.0.
189
+ No deprecated APIs are declared as of 1.4.0.
172
190
 
173
- ## 13. Removal / deprecation policy
191
+ ## 14. Removal / deprecation policy
174
192
 
175
193
  - Stable APIs are not removed in v1.x.
176
194
  - 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.
177
195
 
178
- ## 14. Backward compatibility policy
196
+ ## 15. Backward compatibility policy
179
197
 
180
198
  - Manual trace JSONL (`schemaVersion: "0.1"`) remains readable.
181
199
  - Additive schema changes are allowed in minor versions.
182
200
  - Breaking changes require a major version.
183
201
  - Unknown fields should be ignored where safe.
184
202
 
185
- ## 15. Examples
203
+ ## 16. Examples
186
204
 
187
205
  ### Minimal manual trace
188
206
 
package/docs/CLI.md CHANGED
@@ -26,6 +26,11 @@ 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
  - `diff` — compare two manual traces (local, read-only)
29
+ - `timeline` — chronological view of one run (local JSONL)
30
+ - `stats` — local aggregate stats over a trace directory
31
+ - `search` — deterministic local search over traces
32
+ - `what` — concise summary of a single run (local JSONL)
33
+ - `report` — markdown or HTML inspection report for a single run
29
34
 
30
35
  ## 2. Environment variables
31
36
 
@@ -162,7 +167,7 @@ Important: `tail` is a local developer tool, not a production monitor.
162
167
 
163
168
  ### 6.6 `export`
164
169
 
165
- Export a manual trace run to local formats. **No upload**.
170
+ Export a manual trace run to local formats. **No upload.** Export redaction operates on a **copy** of the run tree — original JSONL files are not modified. Review every export before sharing, even with `--redaction-profile strict`.
166
171
 
167
172
  ```bash
168
173
  agent-inspect export <run-id> --format <markdown|html|openinference|otlp-json> [options]
@@ -251,6 +256,126 @@ Differences:
251
256
 
252
257
  More examples, including timing-only and structure-only diffs, are in `docs/DIFF.md`.
253
258
 
259
+ ### 6.8 `timeline`
260
+
261
+ Chronological step list for one manual trace. Read-only; does not mutate JSONL files.
262
+
263
+ ```bash
264
+ agent-inspect timeline <run-id> [options]
265
+ ```
266
+
267
+ Options:
268
+
269
+ - `--dir <path>`
270
+ - `--json` — structured `RunTimeline` JSON
271
+ - `--focus slow` — show only the slowest steps by duration (top N)
272
+
273
+ ![Timeline with slow-step focus](../assets/demos/timeline.gif)
274
+
275
+ ### 6.9 `stats`
276
+
277
+ Local aggregate statistics over trace files in a directory. Read-only.
278
+
279
+ ```bash
280
+ agent-inspect stats [options]
281
+ ```
282
+
283
+ Options:
284
+
285
+ - `--dir <path>`
286
+ - `--since <duration>` — e.g. `7d`, `24h`
287
+ - `--correlation-id <id>` — filter by `run_started.metadata.correlationId`
288
+ - `--group-id <id>` — filter by `run_started.metadata.groupId`
289
+ - `--json`
290
+
291
+ ![Directory-level stats over local traces](../assets/demos/stats.gif)
292
+
293
+ Use `--correlation-id` or `--group-id` to filter runs by `run_started` metadata (see [API.md](./API.md)).
294
+
295
+ ### 6.10 `search`
296
+
297
+ Deterministic search over local traces (substring / exact filters). No semantic search.
298
+
299
+ ```bash
300
+ agent-inspect search [options]
301
+ ```
302
+
303
+ Options:
304
+
305
+ - `--dir <path>`
306
+ - `--since <duration>`
307
+ - `--status <success|error|running|unknown>`
308
+ - `--kind <kind>` / `--type <type>` — manual step type (`llm`, `tool`, `logic`, …)
309
+ - `--name <query>` — substring on run or step name
310
+ - `--tool <query>` — substring on tool step name or `metadata.toolName`
311
+ - `--duration <expr>` — e.g. `>5s`, `>=500ms`
312
+ - `--limit <number>` — default 50
313
+ - `--json`
314
+
315
+ Examples:
316
+
317
+ ```bash
318
+ npx agent-inspect search --status error --dir ./.agent-inspect
319
+ npx agent-inspect search --kind tool --name search
320
+ npx agent-inspect search --duration ">100ms" --json
321
+ ```
322
+
323
+ ![Search traces by status error](../assets/demos/search.gif)
324
+
325
+ ### 6.11 `what`
326
+
327
+ Concise human-readable summary of one manual trace run. Read-only; uses local v0.1 JSONL (v0.2 dual-read lands in v1.5.0 Chunks 7–8). Vocabulary: [TRACE-VOCABULARY-V1.5.md](./proposals/TRACE-VOCABULARY-V1.5.md).
328
+
329
+ ```bash
330
+ agent-inspect what <run-id> [options]
331
+ ```
332
+
333
+ Options:
334
+
335
+ - `--dir <path>`
336
+ - `--json` — structured `RunWhatSummary` JSON
337
+ - `--no-correlation` — omit correlation ids from human output
338
+
339
+ Example:
340
+
341
+ ```bash
342
+ npx agent-inspect what minimal-success --dir fixtures/traces
343
+ ```
344
+
345
+ Sample output:
346
+
347
+ ```
348
+ What: minimal-success
349
+ Status: success · Duration: 120ms · Steps: 1 (1 logic)
350
+ Outcome: Completed successfully.
351
+ Slowest: plan (100ms, logic)
352
+ ```
353
+
354
+ ### 6.12 `report`
355
+
356
+ Generate a local inspection report combining **what happened**, **timeline**, and **execution tree** sections. Read-only over v0.1 JSONL. Distinct from `export` (which targets shareable tree snapshots and standards formats).
357
+
358
+ ```bash
359
+ agent-inspect report <run-id> [options]
360
+ ```
361
+
362
+ Options:
363
+
364
+ - `--dir <path>`
365
+ - `--format <markdown|html>` — default `markdown`
366
+ - `-o, --output <path>` — write to file
367
+ - `--json` — JSON wrapper (includes `content` when writing to stdout)
368
+ - `--include-attributes` — bounded attributes in tree section
369
+ - `--no-errors` — omit error details from tree section
370
+ - `--no-correlation` — omit correlation ids from what section
371
+ - `--redaction-profile <local|share|strict>` — tree section redaction (default `local`)
372
+
373
+ Example:
374
+
375
+ ```bash
376
+ npx agent-inspect report minimal-success --dir fixtures/traces --format html -o report.html
377
+ ```
378
+
254
379
  ## 7. Optional TUI behavior
255
380
 
256
381
  `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/DIFF.md CHANGED
@@ -10,6 +10,14 @@ Notes:
10
10
  - `diff` is read-only and does **not** rerun agents; “differences” do not necessarily imply failure (command errors do).
11
11
  - `diff` reads local trace files only. It is useful for local debugging, but it is not production APM or hosted observability.
12
12
 
13
+ ![Diff comparing a success run and an error run](assets/demos/diff-runs.gif)
14
+
15
+ ```bash
16
+ agent-inspect diff minimal-success minimal-error --dir fixtures/traces
17
+ ```
18
+
19
+ More visuals: [SCREENSHOTS.md](./SCREENSHOTS.md).
20
+
13
21
  ## CLI examples
14
22
 
15
23
  The examples below use the checked-in fixture traces, so they are safe to copy and run locally: