agent-inspect 1.0.3 → 1.2.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,5 +1,74 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 5a7f785: v1.2.0: experimental persisted-event foundation (`PersistedInspectEvent` schemaVersion 0.2), validators, TraceEvent/InspectEvent converters, in-memory tree bridge, v0.2 fixtures, and docs. Manual trace writing remains schemaVersion 0.1; no storage or CLI behavior change.
8
+
9
+ ## 1.2.0 — Unreleased
10
+
11
+ ### Added
12
+
13
+ - Added experimental `PersistedInspectEvent` model (`schemaVersion: "0.2"`) as a source-agnostic event foundation.
14
+ - Added validator for persisted events (`isPersistedInspectEvent`).
15
+ - Added converters from legacy `schemaVersion: "0.1"` manual trace events to persisted events.
16
+ - Added converters between `InspectEvent` and `PersistedInspectEvent`.
17
+ - Added in-memory helpers to build run trees from persisted events (`persistedInspectEventsToRunTrees`, `traceEventsToPersistedRunTrees`).
18
+ - Added canonical v0.2 fixture samples under `fixtures/traces-v0.2/`.
19
+
20
+ ### Notes
21
+
22
+ - Existing manual trace writing remains `schemaVersion: "0.1"`.
23
+ - v0.2 is not written by default in this release.
24
+ - CLI read/write behavior is unchanged.
25
+ - No vendor upload, hosted dashboard, OTLP HTTP sink, replay engine, or cost engine was added.
26
+
27
+ ## 1.1.0
28
+
29
+ Changeset `21ecc6f`: env-gated tracing, trace safety (redaction + size bounds), LangChain JSONL persistence, logging recipes, CJS/ESM type export compatibility, community docs.
30
+
31
+ ### Added
32
+
33
+ - Added env-gated tracing with `maybeInspectRun()` using `AGENT_INSPECT`.
34
+ - Added `enabled` option for `inspectRun` passthrough when tracing should be skipped.
35
+ - Added default-on persisted trace safety for manual traces, including metadata redaction and event size bounds.
36
+ - Added optional LangChain JSONL persistence with `persist: true` in `@agent-inspect/langchain`.
37
+ - Added production-shaped logging guidance with pino, log4js, and NestJS JSON logging recipes.
38
+ - Added community contribution scaffold, issue templates, and good-first-issue guidance.
39
+
40
+ ### Fixed
41
+
42
+ - Fixed conditional type exports for ESM and CommonJS TypeScript consumers.
43
+ - Improved package compatibility for TypeScript Node16/NodeNext consumers using `import` and `require`.
44
+ - Updated public docs to avoid treating `docs-local` as primary contributor/user documentation.
45
+ - Updated stale docs around LangChain persistence, redaction, and package boundaries.
46
+
47
+ ### Security
48
+
49
+ - Redacts sensitive manual trace metadata before disk by default.
50
+ - Allows explicit opt-out with `redact: false`.
51
+ - Bounds persisted event and metadata size to reduce accidental large trace files.
52
+ - Keeps JSON logs first-class and log4js parsing best-effort without unsafe JavaScript object parsing.
53
+
54
+ ### Documentation
55
+
56
+ - Added/updated logging playbook for structured JSON logs ([docs/LOGGING-PLAYBOOK.md](docs/LOGGING-PLAYBOOK.md)).
57
+ - Updated public roadmap after the 1.1.0 release (Released recently / Now / Next / Future).
58
+ - Updated contributor/community docs for package boundaries and optional packages.
59
+ - Added clearer community onboarding and issue-draft guidance.
60
+
61
+ ### Notes
62
+
63
+ - LangChain adapter APIs remain experimental.
64
+ - `persist: false` remains the default for `@agent-inspect/langchain`; `persist: true` is opt-in.
65
+ - Existing manual trace schema remains `schemaVersion: "0.1"`.
66
+ - Existing event names remain `run_started`, `run_completed`, `step_started`, and `step_completed`.
67
+ - There is still no `step_failed` event; failures are represented as `step_completed` with `status: "error"`.
68
+ - JSON logs remain first-class; log4js text parsing remains best-effort.
69
+ - No vendor upload, network sink, dashboard, replay engine, or cost engine was added.
70
+ - Root `agent-inspect` runtime dependencies remain `chalk`, `commander`, and `nanoid` only.
71
+
3
72
  ## 1.0.3
4
73
 
5
74
  ### Patch Changes
@@ -20,16 +89,6 @@
20
89
 
21
90
  - 575b093: docs: onboarding polish
22
91
 
23
- ## Unreleased
24
-
25
- ### Documentation
26
-
27
- - Improved README onboarding for new users.
28
- - Added comparison guide.
29
- - Added log-to-tree quickstart.
30
- - Added a quickstart demo example.
31
- - Clarified docs organization between user-facing `docs/` and internal `docs-local/`.
32
-
33
92
  ## 1.0.0
34
93
 
35
94
  ### Stable local tracing
package/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
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.
6
6
 
7
- It is built for TypeScript/Node.js developers and teams shipping real agentic products — not just toy demos. Use it **before** a hosted observability platform, **alongside** one, or as the **local debugging layer** underneath enterprise observability.
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
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.
10
10
 
@@ -20,6 +20,8 @@ agent-inspect gives those runs **structure**: an **execution tree** you can read
20
20
 
21
21
  ## Install
22
22
 
23
+ Current npm release: **1.1.0**.
24
+
23
25
  ```bash
24
26
  npm install agent-inspect
25
27
  ```
@@ -34,6 +36,8 @@ Verify the CLI is available:
34
36
  npx agent-inspect --help
35
37
  ```
36
38
 
39
+ For a clean npm/pnpm install checklist with ESM, CJS, and CLI checks, see [Clean install smoke test](docs/INSTALL-SMOKE-TEST.md).
40
+
37
41
  ## 60-second quickstart
38
42
 
39
43
  Create `demo.mjs`:
@@ -133,7 +137,7 @@ npx agent-inspect logs ./agent.log --config agent-inspect.logs.json
133
137
  - **Flat timeline by default**; nesting when parent relationships are explicit or configured.
134
138
  - **Confidence labels** (`explicit`, `correlated`, `heuristic`, `unknown`) describe how attribution was inferred.
135
139
 
136
- More detail: [docs/LOGS.md](docs/LOGS.md) · [docs/LOG-TO-TREE-QUICKSTART.md](docs/LOG-TO-TREE-QUICKSTART.md).
140
+ 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).
137
141
 
138
142
  ## CLI at a glance
139
143
 
@@ -153,14 +157,14 @@ Full flags and behavior: [docs/CLI.md](docs/CLI.md).
153
157
 
154
158
  - Debug a **failed tool call** or thrown error in a support or ops agent.
155
159
  - See **which step dominated latency** in a multi-step planner or RAG pipeline.
156
- - **Diff two runs** after a prompt, model, or routing change.
160
+ - **Diff two runs** after a prompt, model, or routing change (see [diff examples](docs/DIFF.md)).
157
161
  - Point **`logs`** / **`tail`** at existing job or service logs to get a **local execution view** without shipping data upstream.
158
162
  - **Export** a run to Markdown for a PR, postmortem, or internal thread — then review before sharing.
159
163
  - Keep traces **on disk** while still using enterprise observability elsewhere.
160
164
 
161
- ## What v1.0 stabilizes
165
+ ## Stable foundation (AgentInspect 1.x)
162
166
 
163
- **agent-inspect 1.0** stabilizes the **local debugging foundation**:
167
+ **agent-inspect 1.x** (current: **1.1.0**) stabilizes the **local debugging foundation**:
164
168
 
165
169
  - Instrument a run with `inspectRun` and `step`
166
170
  - Write **local JSONL traces** (`schemaVersion: "0.1"` — compatibility retained)
@@ -173,7 +177,7 @@ Pass `enabled: false` to `inspectRun` for a no-trace passthrough. Use `maybeInsp
173
177
 
174
178
  **Stable CLI workflows:** `agent-inspect list`, `agent-inspect view`, `agent-inspect clean`.
175
179
 
176
- **Also included in 1.0** as local-first extensions:
180
+ **Also included in 1.x** as local-first extensions:
177
181
 
178
182
  - Structured log inspection: **`logs`**
179
183
  - Live log tailing: **`tail`**
@@ -189,7 +193,7 @@ Pass `enabled: false` to `inspectRun` for a no-trace passthrough. Use `maybeInsp
189
193
 
190
194
  ### LangChain callback adapter (`@agent-inspect/langchain`)
191
195
 
192
- Optional package: official **LangChain.js callbacks** (`BaseCallbackHandler`), **metadata-oriented by default**, **no monkey-patching**, **no vendor sink**. The LangChain adapter is available in 1.0, but its programmatic API remains experimental and may evolve independently of the stable core tracing API.
196
+ Optional package: official **LangChain.js callbacks** (`BaseCallbackHandler`), **metadata-oriented by default**, **no monkey-patching**, **no vendor sink**. The LangChain adapter ships with 1.x; its programmatic API remains experimental and may evolve independently of the stable core tracing API.
193
197
 
194
198
  ```bash
195
199
  pnpm add agent-inspect @agent-inspect/langchain @langchain/core
@@ -199,12 +203,18 @@ pnpm add agent-inspect @agent-inspect/langchain @langchain/core
199
203
  import { AgentInspectCallback } from "@agent-inspect/langchain";
200
204
 
201
205
  const callback = new AgentInspectCallback({
202
- runName: "my-run",
206
+ runName: "support-agent",
207
+ traceDir: "./.agent-inspect",
208
+ persist: true,
203
209
  capture: "metadata-only",
204
210
  });
205
211
 
206
212
  await agent.invoke(input, { callbacks: [callback] });
213
+ // In-memory events still available:
207
214
  const events = callback.getEvents();
215
+ // Persisted runs are inspectable via CLI:
216
+ // npx agent-inspect list --dir ./.agent-inspect
217
+ // npx agent-inspect view <run-id> --dir ./.agent-inspect
208
218
  ```
209
219
 
210
220
  See [examples/08-langchain-adapter](examples/08-langchain-adapter/README.md) and [docs/ADAPTERS.md](docs/ADAPTERS.md).
@@ -236,6 +246,9 @@ The TUI is available as a separate optional package; its programmatic API is exp
236
246
  | [examples/recipes/tool-failure-retry](examples/recipes/tool-failure-retry) | Tool failure + retry |
237
247
  | [examples/recipes/multi-agent-handoff](examples/recipes/multi-agent-handoff) | Handoff |
238
248
  | [examples/recipes/proactive-agent-logs](examples/recipes/proactive-agent-logs) | Structured logs |
249
+ | [examples/recipes/pino-json-logs](examples/recipes/pino-json-logs) | pino-shaped JSON |
250
+ | [examples/recipes/log4js-json-layout](examples/recipes/log4js-json-layout) | log4js embedded JSON |
251
+ | [examples/recipes/nestjs-json-logging](examples/recipes/nestjs-json-logging) | NestJS JSON logs |
239
252
  | [examples/recipes/retry-fallback](examples/recipes/retry-fallback) | Fallback pattern |
240
253
  | [examples/recipes/parallel-tools](examples/recipes/parallel-tools) | Parallel tools |
241
254
 
@@ -245,10 +258,10 @@ The TUI is available as a separate optional package; its programmatic API is exp
245
258
 
246
259
  - **Local files by default** — no upload, no vendor sinks in core workflows.
247
260
  - **No API keys** required for core tracing and CLI inspection.
248
- - **Manual metadata** is user-controlled; traces and exports can contain sensitive data if you put it there.
261
+ - **Manual metadata** is user-controlled. By default, common sensitive keys are **redacted before disk**; pass `redact: false` to opt out. Long metadata is truncated and events are capped at 64 KiB per JSONL line. Review traces and exports before sharing.
249
262
  - **Review exports** before sharing (especially with richer attribute flags).
250
263
 
251
- See [SECURITY.md](SECURITY.md).
264
+ See [SECURITY.md](SECURITY.md) and the [safe trace sharing checklist](docs/SAFE-TRACE-SHARING.md).
252
265
 
253
266
  ## agent-inspect comparison
254
267
 
@@ -259,22 +272,36 @@ For a detailed comparison, see [Compare with other tools](docs/COMPARE.md).
259
272
  ## Documentation
260
273
 
261
274
  - [Getting started](docs/GETTING-STARTED.md)
275
+ - [Clean install smoke test](docs/INSTALL-SMOKE-TEST.md)
262
276
  - [API stability & experimental surfaces](docs/API.md)
263
277
  - [CLI reference](docs/CLI.md)
264
278
  - [Schema (`schemaVersion: "0.1"`)](docs/SCHEMA.md)
265
279
  - [Architecture (links to deeper design notes)](docs/ARCHITECTURE.md)
266
280
  - [Logs & tail](docs/LOGS.md)
267
281
  - [Log-to-tree quickstart](docs/LOG-TO-TREE-QUICKSTART.md)
282
+ - [Logging playbook](docs/LOGGING-PLAYBOOK.md)
268
283
  - [Exports](docs/EXPORTS.md)
269
284
  - [Diff](docs/DIFF.md)
270
285
  - [Adapters](docs/ADAPTERS.md)
271
286
  - [Compare with other tools](docs/COMPARE.md)
272
287
  - [Security](SECURITY.md)
288
+ - [Safe trace sharing checklist](docs/SAFE-TRACE-SHARING.md)
273
289
  - [Changelog](CHANGELOG.md)
274
290
  - [Known issues](docs/KNOWN-ISSUES.md)
275
291
  - [Limitations](docs/LIMITATIONS.md)
276
292
  - [Screenshot checklist (planned assets)](docs/SCREENSHOTS.md)
277
293
 
294
+ ## Contributing
295
+
296
+ AgentInspect welcomes docs, fixtures, examples, and carefully scoped CLI improvements.
297
+
298
+ - **Good first issues:** [GOOD-FIRST-ISSUES.md](GOOD-FIRST-ISSUES.md) — live batches [#7–#14](https://github.com/rajudandigam/agent-inspect/issues?q=is%3Aissue+is%3Aopen) and [#18–#30](https://github.com/rajudandigam/agent-inspect/issues/18) (comment on an issue before opening a PR)
299
+ - **Discussions:** [github.com/rajudandigam/agent-inspect/discussions](https://github.com/rajudandigam/agent-inspect/discussions) — feedback, stack survey, integration ideas
300
+ - **Roadmap:** [ROADMAP.md](ROADMAP.md) — Now / Next / Future direction (non-committal)
301
+ - **Contributing guide:** [CONTRIBUTING.md](CONTRIBUTING.md) — validation commands, PR expectations, scope boundaries
302
+
303
+ **Security:** Traces and logs may contain secrets. **Redact before sharing** in issues, Discussions, PRs, or exports. See [SECURITY.md](SECURITY.md) and the [safe trace sharing checklist](docs/SAFE-TRACE-SHARING.md).
304
+
278
305
  ## Development
279
306
 
280
307
  From a clone of this repo:
package/SECURITY.md CHANGED
@@ -63,11 +63,14 @@ AgentInspect aims to be safe-by-default for **log-derived attributes** and **exp
63
63
 
64
64
  Important limitations:
65
65
 
66
- - **Manual trace metadata is user-controlled.** If you attach secrets to `inspectRun({ metadata })` or step metadata, those values may appear in local trace files and could appear in some views/exports depending on your settings and what you choose to include.
66
+ - **Manual trace metadata is user-controlled.** By default, `inspectRun()` and `step()` **redact common sensitive keys** before writing JSONL (`authorization`, `cookie`, `token`, `apiKey`, `password`, `secret`, `email` case-insensitive). Pass **`redact: false`** to persist metadata as-is (explicit opt-out).
67
+ - **Non-sensitive metadata and custom keys** are still written locally. Do not attach secrets you are unwilling to store on disk, even with redaction enabled (custom key names may bypass defaults).
68
+ - **Size bounds** truncate long metadata values and cap serialized event size (default 64 KiB per line). Oversized events are truncated further or replaced with a `{ truncated: true, reason: "maxEventBytes" }` marker — instrumentation never throws into your app because of payload size.
69
+ - **`@agent-inspect/langchain` with `persist: true`** writes the same local JSONL format as manual traces. Default **`capture: "metadata-only"`** does not persist full prompts/outputs; use **`capture: "preview"`** only when you accept truncated previews on disk.
67
70
  - Always **review exported files** before sharing them externally.
68
71
  - Avoid committing trace directories (`.agent-inspect-runs/`) to source control.
69
72
 
70
- For redaction design details, see `docs-local/architecture/REDACTION.md`.
73
+ For a practical pre-share workflow, see `docs/SAFE-TRACE-SHARING.md`. For schema-level redaction notes, see `docs/SCHEMA.md` (redaction section) and `docs/API.md`.
71
74
 
72
75
  ## Dependency and security review process
73
76
 
package/docs/ADAPTERS.md CHANGED
@@ -5,11 +5,38 @@ AgentInspect is framework-agnostic at its core, but can optionally integrate wit
5
5
  - **LangChain.js adapter** (optional): `@agent-inspect/langchain`
6
6
  - Documented as **experimental** in `docs/API.md`
7
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
+ - **No monkey-patching**, **no vendor sinks**, **no network upload**
8
12
  - **Interactive TUI** (optional): `@agent-inspect/tui`
9
13
  - Documented as **experimental** in `docs/API.md`
10
14
  - Intended for CLI integration; programmatic TUI APIs may change
11
15
 
16
+ ### LangChain persistence model (Strategy A)
17
+
18
+ When `persist: true`:
19
+
20
+ 1. **Standalone callback session** — one AgentInspect run per `AgentInspectCallback` instance until the root LangChain run completes.
21
+ 2. **Inside `inspectRun`** — callback steps append to the active manual run (no extra `run_started` / `run_completed`).
22
+ 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).
23
+ 4. **Step types** — `LLM` → `llm`, `TOOL` → `tool`, `DECISION` → `decision`, other kinds → `logic`.
24
+
25
+ ```ts
26
+ const callback = new AgentInspectCallback({
27
+ runName: "support-agent",
28
+ traceDir: "./.agent-inspect",
29
+ persist: true,
30
+ capture: "metadata-only",
31
+ });
32
+ ```
33
+
34
+ ```bash
35
+ npx agent-inspect list --dir ./.agent-inspect
36
+ npx agent-inspect view <run-id> --dir ./.agent-inspect
37
+ ```
38
+
12
39
  See also:
13
40
  - `docs/MIGRATION.md` (what changed from early versions)
14
- - `docs-local/RELEASE-CHECKLIST.md` (maintainer-only release steps)
41
+ - `docs/API.md` (LangChain adapter options: `persist`, `capture`, `traceDir`)
15
42
 
package/docs/API.md CHANGED
@@ -1,4 +1,4 @@
1
- # API (AgentInspect 1.0)
1
+ # API (AgentInspect 1.x)
2
2
 
3
3
  This document describes the **public TypeScript API surface** of AgentInspect and classifies each area as **stable** or **experimental**.
4
4
 
@@ -11,9 +11,9 @@ AgentInspect is a **local-first execution-tree debugger**. It is not a SaaS, not
11
11
 
12
12
  Notes:
13
13
 
14
- - The core guarantee of v1.0 is **stable local debugging**: manual tracing + CLI inspection.
14
+ - The core guarantee of v1.x is **stable local debugging**: manual tracing + CLI inspection.
15
15
  - Export formats (OpenInference / OTLP JSON) are **local-only** and **compatibility-oriented**. They do **not** upload anywhere.
16
- - There are **zero production sinks** in v1.0; sink/uploader APIs are not stable.
16
+ - There are **zero production sinks** in v1.x; sink/uploader APIs are not stable.
17
17
 
18
18
  ## 2. Stable core APIs (manual tracing)
19
19
 
@@ -26,9 +26,13 @@ import { inspectRun, maybeInspectRun, step, observe } from "agent-inspect";
26
26
  ```
27
27
 
28
28
  - **`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.
29
+ - **`redact`**: default `true` — redacts sensitive metadata keys before disk (`authorization`, `cookie`, `token`, `apiKey`, `password`, `secret`, `email`). Pass `false` to persist metadata as-is. Pass `{ rules?: RedactionRule[] }` for custom rules (defaults still apply).
30
+ - **`maxMetadataValueLength`**: max string length for metadata values (default `2000`).
31
+ - **`maxPreviewLength`**: max string length for preview-like keys containing `preview` (default `500`).
32
+ - **`maxEventBytes`**: max UTF-8 bytes per serialized JSONL event (default `65536`). Oversized events are truncated; instrumentation never throws into user code.
29
33
  - **`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.
30
34
  - **`isAgentInspectEnabled(value?)`**: returns whether a string (or `process.env.AGENT_INSPECT`) matches an enable token.
31
- - **`step(name, fn, options?)`**: traces a named unit of work inside `inspectRun` (`step_started` / `step_completed`).
35
+ - **`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.
32
36
  - **`step.llm(model, fn)`**: convenience wrapper (`type: "llm"`, `metadata.model`).
33
37
  - **`step.tool(toolName, fn)`**: convenience wrapper (`type: "tool"`, `metadata.toolName`).
34
38
  - **`observe(agent, options?)`**: proxy wrapper that traces top-level `run` / `execute` / `invoke` methods via `inspectRun`.
@@ -111,9 +115,16 @@ Diff is local and read-only. Programmatic diff surfaces are experimental until t
111
115
  `@agent-inspect/langchain` is an optional adapter package.
112
116
 
113
117
  - **`AgentInspectCallback`** (experimental)
118
+ - **`persist`**: default `false` — when `true`, maps callback lifecycle to schemaVersion `"0.1"` JSONL (`run_started` / `step_started` / `step_completed` / `run_completed`)
119
+ - **`runName`**: default `"langchain-agent"` for standalone persisted runs
120
+ - **`traceDir`**: defaults via `resolveTraceDir` / `AGENT_INSPECT_TRACE_DIR`
121
+ - **`capture`**: `"none"` | `"metadata-only"` (default) | `"preview"` (truncated previews, opt-in)
122
+ - **`redact`**: custom `RedactionRule[]` applied before disk (core defaults still apply via shared redactor)
123
+ - **`runId`**: optional id for standalone persisted runs
124
+ - In-memory **`getEvents()`** / **`clear()`** unchanged when `persist` is false
114
125
  - Metadata helpers: `extractModelName`, `extractTokenUsage`, `safePreview`, `toPlainMetadata`
115
126
 
116
- Rationale: v1.0 includes one official adapter and **zero production sinks**, so adapter surfaces remain experimental.
127
+ Rationale: v1.x includes one official adapter and **zero production sinks**, so adapter surfaces remain experimental.
117
128
 
118
129
  ## 10. Experimental `@agent-inspect/tui` APIs
119
130
 
@@ -121,23 +132,49 @@ Rationale: v1.0 includes one official adapter and **zero production sinks**, so
121
132
 
122
133
  - `runTraceViewer`, `loadTraceForTui`, `buildTuiTraceModel`, etc.
123
134
 
124
- ## 11. Deprecated APIs
135
+ ## 11. Experimental persisted-event foundation (v1.2.0)
125
136
 
126
- No deprecated APIs are declared in v1.0 Pass 1.
137
+ 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.
127
138
 
128
- ## 12. Removal / deprecation policy
139
+ Import from `agent-inspect`:
140
+
141
+ | API | Role |
142
+ | --- | ---- |
143
+ | `isPersistedInspectEvent` | Runtime validator for v0.2 persisted events |
144
+ | `traceEventToPersistedInspectEvent` | Convert one v0.1 `TraceEvent` |
145
+ | `traceEventsToPersistedInspectEvents` | Batch v0.1 → v0.2 |
146
+ | `inspectEventToPersistedInspectEvent` | Convert one in-memory `InspectEvent` |
147
+ | `inspectEventsToPersistedInspectEvents` | Batch `InspectEvent` → v0.2 |
148
+ | `persistedInspectEventToInspectEvent` | Convert one v0.2 event to `InspectEvent` |
149
+ | `persistedInspectEventsToInspectEvents` | Batch v0.2 → `InspectEvent` |
150
+ | `persistedInspectEventsToRunTrees` | Build `InspectRunTree[]` from v0.2 events (via `TreeBuilder`) |
151
+ | `traceEventsToPersistedRunTrees` | v0.1 `TraceEvent[]` → persisted model → trees |
152
+
153
+ Related types: `PersistedInspectEvent`, `PersistedEventSourceType`, `PersistedEventStatus`, `TraceEventToPersistedOptions`, `InspectEventToPersistedOptions`, `PersistedToInspectEventOptions`, `PersistedTreeBridgeOptions`.
154
+
155
+ **Notes:**
156
+
157
+ - Manual trace **writing** remains `schemaVersion: "0.1"`.
158
+ - v0.2 is **not written by default**; use converters and `fixtures/traces-v0.2/` samples for validation.
159
+ - Storage dual-read and CLI integration are future work.
160
+
161
+ ## 12. Deprecated APIs
162
+
163
+ No deprecated APIs are declared as of 1.1.0.
164
+
165
+ ## 13. Removal / deprecation policy
129
166
 
130
167
  - Stable APIs are not removed in v1.x.
131
168
  - 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.
132
169
 
133
- ## 13. Backward compatibility policy
170
+ ## 14. Backward compatibility policy
134
171
 
135
172
  - Manual trace JSONL (`schemaVersion: "0.1"`) remains readable.
136
173
  - Additive schema changes are allowed in minor versions.
137
174
  - Breaking changes require a major version.
138
175
  - Unknown fields should be ignored where safe.
139
176
 
140
- ## 14. Examples
177
+ ## 15. Examples
141
178
 
142
179
  ### Minimal manual trace
143
180
 
@@ -1,13 +1,49 @@
1
1
  ## Architecture
2
2
 
3
- This doc is a stable entry point for AgentInspect’s internal architecture and product boundaries.
3
+ AgentInspect is a **local-first execution-tree debugger**: manual traces and log ingest produce inspectable step trees stored as JSONL on disk (default `.agent-inspect-runs/`), with a CLI for list/view/clean/logs/tail/export/diff workflows.
4
4
 
5
- - **Canonical architecture overview**: see `docs-local/architecture/ARCHITECTURE.md`
6
- - **Event model**: `docs-local/architecture/EVENT-MODEL.md`
7
- - **Tree building rules**: `docs-local/architecture/TREE-BUILDING-RULES.md`
8
- - **Schema evolution policy**: `docs-local/architecture/SCHEMA-EVOLUTION.md`
9
- - **Dependency policy**: `docs-local/architecture/DEPENDENCY-POLICY.md`
10
- - **Redaction design**: `docs-local/architecture/REDACTION.md`
5
+ ### Package layout
11
6
 
12
- If you’re new, start with `docs/GETTING-STARTED.md`, then `docs/API.md`, `docs/CLI.md`, and `docs/SCHEMA.md`.
7
+ | Package | Published? | Role |
8
+ | -------- | ---------- | ---- |
9
+ | `agent-inspect` | Yes | Public tarball: core tracing APIs + CLI (`agent-inspect` binary) |
10
+ | `@agent-inspect/core` | No (private) | Tracing, storage, log parsing, export, diff |
11
+ | `@agent-inspect/cli` | No (private) | Commander CLI implementation |
12
+ | `@agent-inspect/langchain` | Yes (optional) | LangChain.js callback adapter (experimental) |
13
+ | `@agent-inspect/tui` | Yes (optional) | Ink/React terminal viewer (experimental) |
13
14
 
15
+ Root `agent-inspect` uses **conditional exports** for ESM/CJS TypeScript consumers (`import.types` / `require.types`). Heavy dependencies (LangChain, Ink/React) stay in optional packages.
16
+
17
+ ### Event model and schema
18
+
19
+ - Manual traces use **`schemaVersion: "0.1"`** JSONL events (`run_started`, `step_started`, `step_completed`, `run_completed`).
20
+ - Failures use `step_completed` with `status: "error"` — there is no `step_failed` event.
21
+ - Log-derived runs use confidence labels (`explicit`, `correlated`, `heuristic`, `unknown`) and conservative tree-building rules.
22
+ - **v1.2.0 persisted-event foundation (release-readiness):** source-agnostic `PersistedInspectEvent` helpers (`schemaVersion: "0.2"`) — types, validators, converters, and in-memory tree bridge. Existing **`TreeBuilder`** remains the canonical tree builder. v0.2 bridge works **in memory only**; storage dual-read and CLI integration are future work. See [proposals/UNIFIED-PERSISTED-INSPECT-EVENT.md](./proposals/UNIFIED-PERSISTED-INSPECT-EVENT.md) and [implementation/V1.2.0-RELEASE-READINESS.md](./implementation/V1.2.0-RELEASE-READINESS.md).
23
+
24
+ See [SCHEMA.md](./SCHEMA.md) for field reference and [API.md](./API.md) for public surfaces (stable vs experimental).
25
+
26
+ ### Safety and redaction
27
+
28
+ - Instrumentation must **not throw into user code**; trace safety failures degrade gracefully.
29
+ - **Manual metadata** is redacted before disk by default; `redact: false` opts out.
30
+ - **Size bounds** cap persisted event and metadata size.
31
+ - Log ingest: JSON first-class; log4js best-effort; no `eval` or JS object-literal parsing.
32
+
33
+ See [SECURITY.md](../SECURITY.md) and [LIMITATIONS.md](./LIMITATIONS.md).
34
+
35
+ ### Optional adapters
36
+
37
+ - **`@agent-inspect/langchain`**: in-memory by default; `persist: true` writes local JSONL. Experimental.
38
+ - **`@agent-inspect/tui`**: interactive viewer; isolated from root deps. Experimental.
39
+
40
+ See [ADAPTERS.md](./ADAPTERS.md).
41
+
42
+ ### Where to read next
43
+
44
+ - New users: [GETTING-STARTED.md](./GETTING-STARTED.md)
45
+ - CLI: [CLI.md](./CLI.md)
46
+ - Structured logs: [LOGS.md](./LOGS.md), [LOGGING-PLAYBOOK.md](./LOGGING-PLAYBOOK.md)
47
+ - Contributors: [CONTRIBUTING.md](../CONTRIBUTING.md), [docs/community/CONTRIBUTING.md](./community/CONTRIBUTING.md)
48
+
49
+ Maintainer-only internal docs under `docs-local/` may contain additional historical architecture depth; they are not required for contributors.
package/docs/CLI.md CHANGED
@@ -196,6 +196,53 @@ Options:
196
196
  - `--focus <all|errors|structure|outputs>`
197
197
  - `--check <all|structure|outputs|errors|timing>`
198
198
 
199
+ Fixture examples:
200
+
201
+ ```bash
202
+ agent-inspect diff minimal-success minimal-error --dir fixtures/traces
203
+ agent-inspect diff minimal-success long-running --dir fixtures/traces --check timing --duration-threshold 1ms
204
+ agent-inspect diff minimal-success nested-3-levels --dir fixtures/traces --check structure --ignore-duration
205
+ ```
206
+
207
+ **Simplified example output** (actual CLI formatting may differ slightly):
208
+
209
+ ```text
210
+ Run diff
211
+ Left: minimal-success
212
+ Right: minimal-error
213
+
214
+ Summary:
215
+ Differences: 4
216
+ Errors: 0
217
+ Warnings: 3
218
+ Info: 1
219
+
220
+ First divergence:
221
+ run-status at (run)
222
+ left: success
223
+ right: error
224
+
225
+ Differences:
226
+ [warning] run-status
227
+ Run completion status differs
228
+ left: success
229
+ right: error
230
+ [info] duration
231
+ Run duration differs
232
+ left: 120
233
+ right: 70
234
+ [warning] step-removed plan
235
+ Step only in left run: plan
236
+ left: step_root
237
+ right: (undefined)
238
+ [warning] step-added failing-step
239
+ Step only in right run: failing-step
240
+ left: (undefined)
241
+ right: step_fail
242
+ ```
243
+
244
+ More examples, including timing-only and structure-only diffs, are in `docs/DIFF.md`.
245
+
199
246
  ## 7. Optional TUI behavior
200
247
 
201
248
  `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
@@ -8,4 +8,131 @@ AgentInspect can compare two runs (manual traces) locally and render a diff summ
8
8
  Notes:
9
9
  - Programmatic diff APIs are documented as **experimental** in `docs/API.md`.
10
10
  - `diff` is read-only and does **not** rerun agents; “differences” do not necessarily imply failure (command errors do).
11
+ - `diff` reads local trace files only. It is useful for local debugging, but it is not production APM or hosted observability.
11
12
 
13
+ ## CLI examples
14
+
15
+ The examples below use the checked-in fixture traces, so they are safe to copy and run locally:
16
+
17
+ ```bash
18
+ agent-inspect diff minimal-success minimal-error --dir fixtures/traces
19
+ agent-inspect diff minimal-success long-running --dir fixtures/traces --check timing --duration-threshold 1ms
20
+ agent-inspect diff minimal-success nested-3-levels --dir fixtures/traces --check structure --ignore-duration
21
+ ```
22
+
23
+ If you are running from a source checkout before installing the package globally, use the built CLI path instead:
24
+
25
+ ```bash
26
+ node packages/cli/dist/index.cjs diff minimal-success minimal-error --dir fixtures/traces
27
+ ```
28
+
29
+ ### Success run vs error run
30
+
31
+ This compares a successful run with a run that ended in an error. It shows the run status change, a duration difference, and the step-level structure difference (`plan` removed, `failing-step` added).
32
+
33
+ **Simplified example output** (actual CLI formatting may differ slightly):
34
+
35
+ ```text
36
+ Run diff
37
+ Left: minimal-success
38
+ Right: minimal-error
39
+
40
+ Summary:
41
+ Differences: 4
42
+ Errors: 0
43
+ Warnings: 3
44
+ Info: 1
45
+
46
+ First divergence:
47
+ run-status at (run)
48
+ left: success
49
+ right: error
50
+
51
+ Differences:
52
+ [warning] run-status
53
+ Run completion status differs
54
+ left: success
55
+ right: error
56
+ [info] duration
57
+ Run duration differs
58
+ left: 120
59
+ right: 70
60
+ [warning] step-removed plan
61
+ Step only in left run: plan
62
+ left: step_root
63
+ right: (undefined)
64
+ [warning] step-added failing-step
65
+ Step only in right run: failing-step
66
+ left: (undefined)
67
+ right: step_fail
68
+ ```
69
+
70
+ ### Duration-only timing check
71
+
72
+ Use `--check timing` when you only want timing differences. `--duration-threshold` can hide tiny deltas.
73
+
74
+ ```bash
75
+ agent-inspect diff minimal-success long-running --dir fixtures/traces --check timing --duration-threshold 1ms
76
+ ```
77
+
78
+ **Simplified example output**:
79
+
80
+ ```text
81
+ Run diff
82
+ Left: minimal-success
83
+ Right: long-running
84
+
85
+ Summary:
86
+ Differences: 1
87
+ Errors: 0
88
+ Warnings: 0
89
+ Info: 1
90
+
91
+ First divergence:
92
+ duration at (run)
93
+ left: 120
94
+ right: 45
95
+
96
+ Differences:
97
+ [info] duration
98
+ Run duration differs
99
+ left: 120
100
+ right: 45
101
+ ```
102
+
103
+ ### Step structure / rename-style changes
104
+
105
+ When a prompt, model, or routing change renames or restructures steps, the current diff output represents that as `step-removed` plus `step-added`. Use `--ignore-duration` if the structure is what matters.
106
+
107
+ ```bash
108
+ agent-inspect diff minimal-success nested-3-levels --dir fixtures/traces --check structure --ignore-duration
109
+ ```
110
+
111
+ **Simplified example output**:
112
+
113
+ ```text
114
+ Run diff
115
+ Left: minimal-success
116
+ Right: nested-3-levels
117
+
118
+ Summary:
119
+ Differences: 2
120
+ Errors: 0
121
+ Warnings: 2
122
+ Info: 0
123
+
124
+ First divergence:
125
+ step-removed at plan
126
+ left: step_root
127
+ right: (undefined)
128
+
129
+ Differences:
130
+ [warning] step-removed plan
131
+ Step only in left run: plan
132
+ left: step_root
133
+ right: (undefined)
134
+ [warning] step-added outer
135
+ Step only in right run: outer
136
+ left: (undefined)
137
+ right: step_outer
138
+ ```
package/docs/EXPORTS.md CHANGED
@@ -4,7 +4,7 @@ AgentInspect supports local-only exports from run trees and traces. Exports are
4
4
 
5
5
  - **CLI usage**: `docs/CLI.md` (`export`)
6
6
  - **Schema + compatibility guarantees**: `docs/SCHEMA.md`
7
- - **Safety / redaction notes**: `docs/CLI.md`, `SECURITY.md`, and `docs-local/architecture/REDACTION.md`
7
+ - **Safety / redaction notes**: `docs/CLI.md`, `SECURITY.md`, and `docs/SCHEMA.md` (redaction section)
8
8
 
9
9
  Notes:
10
10
  - Export formats (Markdown/HTML/OpenInference/OTLP JSON) are documented as **experimental / compatibility-oriented** in `docs/API.md`.