agent-inspect 1.0.2 → 1.1.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,62 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 21ecc6f: v1.1.0: env-gated tracing, trace safety (redaction + size bounds), LangChain JSONL persistence, logging recipes, CJS/ESM type export compatibility, community docs.
8
+
9
+ ## 1.1.0 — Unreleased
10
+
11
+ ### Added
12
+
13
+ - Added env-gated tracing with `maybeInspectRun()` using `AGENT_INSPECT`.
14
+ - Added `enabled` option for `inspectRun` passthrough when tracing should be skipped.
15
+ - Added default-on persisted trace safety for manual traces, including metadata redaction and event size bounds.
16
+ - Added optional LangChain JSONL persistence with `persist: true` in `@agent-inspect/langchain`.
17
+ - Added production-shaped logging guidance with pino, log4js, and NestJS JSON logging recipes.
18
+ - Added community contribution scaffold, issue templates, and good-first-issue guidance.
19
+
20
+ ### Fixed
21
+
22
+ - Fixed conditional type exports for ESM and CommonJS TypeScript consumers.
23
+ - Improved package compatibility for TypeScript Node16/NodeNext consumers using `import` and `require`.
24
+ - Updated public docs to avoid treating `docs-local` as primary contributor/user documentation.
25
+ - Updated stale docs around LangChain persistence, redaction, and package boundaries.
26
+
27
+ ### Security
28
+
29
+ - Redacts sensitive manual trace metadata before disk by default.
30
+ - Allows explicit opt-out with `redact: false`.
31
+ - Bounds persisted event and metadata size to reduce accidental large trace files.
32
+ - Keeps JSON logs first-class and log4js parsing best-effort without unsafe JavaScript object parsing.
33
+
34
+ ### Documentation
35
+
36
+ - Added/updated logging playbook for structured JSON logs ([docs/LOGGING-PLAYBOOK.md](docs/LOGGING-PLAYBOOK.md)).
37
+ - Updated public roadmap to separate completed v1.1-prep work from Now/Next/Future.
38
+ - Updated contributor/community docs for package boundaries and optional packages.
39
+ - Added clearer community onboarding and issue-draft guidance.
40
+
41
+ ### Notes
42
+
43
+ - LangChain adapter APIs remain experimental.
44
+ - `persist: false` remains the default for `@agent-inspect/langchain`; `persist: true` is opt-in.
45
+ - Existing manual trace schema remains `schemaVersion: "0.1"`.
46
+ - Existing event names remain `run_started`, `run_completed`, `step_started`, and `step_completed`.
47
+ - There is still no `step_failed` event; failures are represented as `step_completed` with `status: "error"`.
48
+ - JSON logs remain first-class; log4js text parsing remains best-effort.
49
+ - No vendor upload, network sink, dashboard, replay engine, or cost engine was added.
50
+ - Root `agent-inspect` runtime dependencies remain `chalk`, `commander`, and `nanoid` only.
51
+
52
+ ## 1.0.3
53
+
54
+ ### Patch Changes
55
+
56
+ - Add `enabled` option and `maybeInspectRun` helper for env-gated tracing (`AGENT_INSPECT`).
57
+ - Fix CJS/ESM conditional type exports for TypeScript consumers.
58
+ - Add community contributor scaffold and issue drafts.
59
+
3
60
  ## 1.0.2
4
61
 
5
62
  ### Patch Changes
@@ -12,16 +69,6 @@
12
69
 
13
70
  - 575b093: docs: onboarding polish
14
71
 
15
- ## Unreleased
16
-
17
- ### Documentation
18
-
19
- - Improved README onboarding for new users.
20
- - Added comparison guide.
21
- - Added log-to-tree quickstart.
22
- - Added a quickstart demo example.
23
- - Clarified docs organization between user-facing `docs/` and internal `docs-local/`.
24
-
25
72
  ## 1.0.0
26
73
 
27
74
  ### Stable local tracing
package/README.md CHANGED
@@ -93,6 +93,18 @@ support-agent
93
93
 
94
94
  A runnable copy lives in [examples/00-quickstart-demo](examples/00-quickstart-demo/README.md).
95
95
 
96
+ **Env-gated tracing** (eval harnesses, CI): use `maybeInspectRun` and set `AGENT_INSPECT=1` when you want a trace — otherwise no files are written.
97
+
98
+ ```ts
99
+ import { maybeInspectRun } from "agent-inspect";
100
+
101
+ await maybeInspectRun("eval-case-42", async () => runAgent());
102
+ ```
103
+
104
+ ```bash
105
+ AGENT_INSPECT=1 node eval-runner.mjs
106
+ ```
107
+
96
108
  ## What the trace shows
97
109
 
98
110
  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).
@@ -121,7 +133,7 @@ npx agent-inspect logs ./agent.log --config agent-inspect.logs.json
121
133
  - **Flat timeline by default**; nesting when parent relationships are explicit or configured.
122
134
  - **Confidence labels** (`explicit`, `correlated`, `heuristic`, `unknown`) describe how attribution was inferred.
123
135
 
124
- More detail: [docs/LOGS.md](docs/LOGS.md) · [docs/LOG-TO-TREE-QUICKSTART.md](docs/LOG-TO-TREE-QUICKSTART.md).
136
+ 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).
125
137
 
126
138
  ## CLI at a glance
127
139
 
@@ -155,7 +167,9 @@ Full flags and behavior: [docs/CLI.md](docs/CLI.md).
155
167
  - Inspect runs with **`list`** and **`view`**
156
168
  - Safely remove old trace files with **`clean`**
157
169
 
158
- **Stable APIs:** `inspectRun()`, `step()`, `step.llm()`, `step.tool()`, `observe()`.
170
+ **Stable APIs:** `inspectRun()`, `maybeInspectRun()`, `step()`, `step.llm()`, `step.tool()`, `observe()`.
171
+
172
+ 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).
159
173
 
160
174
  **Stable CLI workflows:** `agent-inspect list`, `agent-inspect view`, `agent-inspect clean`.
161
175
 
@@ -185,12 +199,18 @@ pnpm add agent-inspect @agent-inspect/langchain @langchain/core
185
199
  import { AgentInspectCallback } from "@agent-inspect/langchain";
186
200
 
187
201
  const callback = new AgentInspectCallback({
188
- runName: "my-run",
202
+ runName: "support-agent",
203
+ traceDir: "./.agent-inspect",
204
+ persist: true,
189
205
  capture: "metadata-only",
190
206
  });
191
207
 
192
208
  await agent.invoke(input, { callbacks: [callback] });
209
+ // In-memory events still available:
193
210
  const events = callback.getEvents();
211
+ // Persisted runs are inspectable via CLI:
212
+ // npx agent-inspect list --dir ./.agent-inspect
213
+ // npx agent-inspect view <run-id> --dir ./.agent-inspect
194
214
  ```
195
215
 
196
216
  See [examples/08-langchain-adapter](examples/08-langchain-adapter/README.md) and [docs/ADAPTERS.md](docs/ADAPTERS.md).
@@ -222,6 +242,9 @@ The TUI is available as a separate optional package; its programmatic API is exp
222
242
  | [examples/recipes/tool-failure-retry](examples/recipes/tool-failure-retry) | Tool failure + retry |
223
243
  | [examples/recipes/multi-agent-handoff](examples/recipes/multi-agent-handoff) | Handoff |
224
244
  | [examples/recipes/proactive-agent-logs](examples/recipes/proactive-agent-logs) | Structured logs |
245
+ | [examples/recipes/pino-json-logs](examples/recipes/pino-json-logs) | pino-shaped JSON |
246
+ | [examples/recipes/log4js-json-layout](examples/recipes/log4js-json-layout) | log4js embedded JSON |
247
+ | [examples/recipes/nestjs-json-logging](examples/recipes/nestjs-json-logging) | NestJS JSON logs |
225
248
  | [examples/recipes/retry-fallback](examples/recipes/retry-fallback) | Fallback pattern |
226
249
  | [examples/recipes/parallel-tools](examples/recipes/parallel-tools) | Parallel tools |
227
250
 
@@ -231,7 +254,7 @@ The TUI is available as a separate optional package; its programmatic API is exp
231
254
 
232
255
  - **Local files by default** — no upload, no vendor sinks in core workflows.
233
256
  - **No API keys** required for core tracing and CLI inspection.
234
- - **Manual metadata** is user-controlled; traces and exports can contain sensitive data if you put it there.
257
+ - **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.
235
258
  - **Review exports** before sharing (especially with richer attribute flags).
236
259
 
237
260
  See [SECURITY.md](SECURITY.md).
@@ -251,6 +274,7 @@ For a detailed comparison, see [Compare with other tools](docs/COMPARE.md).
251
274
  - [Architecture (links to deeper design notes)](docs/ARCHITECTURE.md)
252
275
  - [Logs & tail](docs/LOGS.md)
253
276
  - [Log-to-tree quickstart](docs/LOG-TO-TREE-QUICKSTART.md)
277
+ - [Logging playbook](docs/LOGGING-PLAYBOOK.md)
254
278
  - [Exports](docs/EXPORTS.md)
255
279
  - [Diff](docs/DIFF.md)
256
280
  - [Adapters](docs/ADAPTERS.md)
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 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
@@ -22,11 +22,17 @@ These are the recommended entry points for manual instrumentation. They are desi
22
22
  Import from `agent-inspect`:
23
23
 
24
24
  ```ts
25
- import { inspectRun, step, observe } from "agent-inspect";
25
+ import { inspectRun, maybeInspectRun, step, observe } from "agent-inspect";
26
26
  ```
27
27
 
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).
29
- - **`step(name, fn, options?)`**: traces a named unit of work inside `inspectRun` (`step_started` / `step_completed`).
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.
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.
34
+ - **`isAgentInspectEnabled(value?)`**: returns whether a string (or `process.env.AGENT_INSPECT`) matches an enable token.
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.
30
36
  - **`step.llm(model, fn)`**: convenience wrapper (`type: "llm"`, `metadata.model`).
31
37
  - **`step.tool(toolName, fn)`**: convenience wrapper (`type: "tool"`, `metadata.toolName`).
32
38
  - **`observe(agent, options?)`**: proxy wrapper that traces top-level `run` / `execute` / `invoke` methods via `inspectRun`.
@@ -109,6 +115,13 @@ Diff is local and read-only. Programmatic diff surfaces are experimental until t
109
115
  `@agent-inspect/langchain` is an optional adapter package.
110
116
 
111
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
112
125
  - Metadata helpers: `extractModelName`, `extractTokenUsage`, `safePreview`, `toPlainMetadata`
113
126
 
114
127
  Rationale: v1.0 includes one official adapter and **zero production sinks**, so adapter surfaces remain experimental.
@@ -1,13 +1,48 @@
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
+
23
+ See [SCHEMA.md](./SCHEMA.md) for field reference and [API.md](./API.md) for public surfaces (stable vs experimental).
24
+
25
+ ### Safety and redaction
26
+
27
+ - Instrumentation must **not throw into user code**; trace safety failures degrade gracefully.
28
+ - **Manual metadata** is redacted before disk by default; `redact: false` opts out.
29
+ - **Size bounds** cap persisted event and metadata size.
30
+ - Log ingest: JSON first-class; log4js best-effort; no `eval` or JS object-literal parsing.
31
+
32
+ See [SECURITY.md](../SECURITY.md) and [LIMITATIONS.md](./LIMITATIONS.md).
33
+
34
+ ### Optional adapters
35
+
36
+ - **`@agent-inspect/langchain`**: in-memory by default; `persist: true` writes local JSONL. Experimental.
37
+ - **`@agent-inspect/tui`**: interactive viewer; isolated from root deps. Experimental.
38
+
39
+ See [ADAPTERS.md](./ADAPTERS.md).
40
+
41
+ ### Where to read next
42
+
43
+ - New users: [GETTING-STARTED.md](./GETTING-STARTED.md)
44
+ - CLI: [CLI.md](./CLI.md)
45
+ - Structured logs: [LOGS.md](./LOGS.md), [LOGGING-PLAYBOOK.md](./LOGGING-PLAYBOOK.md)
46
+ - Contributors: [CONTRIBUTING.md](../CONTRIBUTING.md), [docs/community/CONTRIBUTING.md](./community/CONTRIBUTING.md)
47
+
48
+ Maintainer-only internal docs under `docs-local/` may contain additional historical architecture depth; they are not required for contributors.
package/docs/CLI.md CHANGED
@@ -31,6 +31,7 @@ Core commands:
31
31
 
32
32
  - **`AGENT_INSPECT_TRACE_DIR`**: default directory for manual trace files (`.jsonl`) when not passed via `--dir` (or API options).
33
33
  - **`AGENT_INSPECT_SILENT`**: when `true`, suppresses live terminal tree output during manual tracing (`inspectRun` / `step`). Trace files are still written.
34
+ - **`AGENT_INSPECT`**: enables manual tracing for **`maybeInspectRun`** when set to `1`, `true`, `yes`, `on`, or `enabled` (case-insensitive). Unset or any other value disables tracing. Does **not** change default **`inspectRun`** behavior (which always traces unless `enabled: false` is passed in code). No network upload — local JSONL only.
34
35
 
35
36
  ## 3. Exit code policy
36
37
 
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`.
@@ -38,6 +38,28 @@ This writes a local JSONL trace with stable v1.0 event names:
38
38
  - `run_started`, `run_completed`
39
39
  - `step_started`, `step_completed`
40
40
 
41
+ ### Always trace vs env-gated tracing
42
+
43
+ Use **`inspectRun`** when you always want a local trace (default behavior).
44
+
45
+ Use **`maybeInspectRun`** in eval harnesses, CI, or production-shaped jobs where tracing should be toggled by environment:
46
+
47
+ ```ts
48
+ import { maybeInspectRun } from "agent-inspect";
49
+
50
+ await maybeInspectRun("eval-case-42", async () => {
51
+ return runAgent();
52
+ });
53
+ ```
54
+
55
+ ```bash
56
+ AGENT_INSPECT=1 node eval-runner.mjs
57
+ ```
58
+
59
+ Enable tokens: `1`, `true`, `yes`, `on`, `enabled` (case-insensitive). Explicit `enabled: true | false` in options overrides the env var.
60
+
61
+ To skip tracing in code without env vars: `inspectRun(name, fn, { enabled: false })`.
62
+
41
63
  ## 3. View runs
42
64
 
43
65
  ```bash
@@ -95,12 +117,14 @@ See `examples/recipes/README.md`.
95
117
 
96
118
  ## 10. Optional LangChain adapter
97
119
 
98
- `@agent-inspect/langchain` is optional and **experimental**:
120
+ `@agent-inspect/langchain` is optional and **experimental**. Events are **in-memory by default**; pass `persist: true` to write local JSONL traces inspectable by the CLI.
99
121
 
100
122
  ```bash
101
123
  pnpm add @agent-inspect/langchain
102
124
  ```
103
125
 
126
+ See [examples/08-langchain-adapter](../examples/08-langchain-adapter/README.md) and [docs/ADAPTERS.md](./ADAPTERS.md).
127
+
104
128
  ## 11. Optional TUI
105
129
 
106
130
  `@agent-inspect/tui` is optional and **experimental**. The CLI can invoke it with:
@@ -111,18 +135,20 @@ agent-inspect view <runId> --tui
111
135
 
112
136
  ## 12. Safety notes
113
137
 
114
- - Redaction is on by default for log-derived attributes and exports.
138
+ - Redaction is on by default for log-derived attributes, **manual trace metadata (before disk)**, and exports. Pass `redact: false` to opt out of manual metadata redaction.
139
+ - Persisted events are size-bounded by default (see `docs/API.md`).
115
140
  - Confidence labels are required to keep attribution honest.
116
141
  - AgentInspect is for local debugging, not production monitoring.
117
142
 
118
143
  ## 13. Next docs
119
144
 
120
- - `docs/API.md`
121
- - `docs/CLI.md`
122
- - `docs/SCHEMA.md`
123
- - `docs/COMPARE.md`
124
- - `docs/LOG-TO-TREE-QUICKSTART.md`
125
- - `docs/KNOWN-ISSUES.md`
126
- - `docs/LIMITATIONS.md`
127
- - `docs-local/V1-READINESS-CHECKLIST.md`
145
+ - [docs/API.md](./API.md)
146
+ - [docs/CLI.md](./CLI.md)
147
+ - [docs/SCHEMA.md](./SCHEMA.md)
148
+ - [docs/LOGGING-PLAYBOOK.md](./LOGGING-PLAYBOOK.md)
149
+ - [docs/COMPARE.md](./COMPARE.md)
150
+ - [docs/LOG-TO-TREE-QUICKSTART.md](./LOG-TO-TREE-QUICKSTART.md)
151
+ - [docs/KNOWN-ISSUES.md](./KNOWN-ISSUES.md)
152
+ - [docs/LIMITATIONS.md](./LIMITATIONS.md)
153
+ - [ROADMAP.md](../ROADMAP.md)
128
154
 
@@ -15,6 +15,12 @@ This document states what AgentInspect **does not** provide today. It complement
15
15
  - **Log-derived runs** and **manual JSONL traces** may differ in fidelity (timestamps, nesting, confidence).
16
16
  - **Confidence labels** qualify inferred relationships; they do not guarantee correctness.
17
17
 
18
+ ## Trace safety bounds
19
+
20
+ - **Default metadata redaction** covers common sensitive keys only (exact key match, case-insensitive). Custom secret field names are not redacted unless you add rules via `redact: { rules: [...] }`.
21
+ - **Metadata truncation** applies to string values and nested structures; very large metadata may be replaced with a truncation marker when `maxEventBytes` is exceeded (default 64 KiB per JSONL line).
22
+ - **Redaction is not encryption.** Local trace files remain readable on disk; treat `.agent-inspect-runs/` like any developer artifact that may contain operational data.
23
+
18
24
  ## Execution semantics
19
25
 
20
26
  - **No replay / fork** of past runs from traces alone.
@@ -29,4 +35,4 @@ This document states what AgentInspect **does not** provide today. It complement
29
35
 
30
36
  - Designed for **developer machines** and **inner-loop debugging**, not petabyte log warehouses.
31
37
 
32
- For roadmap intent, see `docs-local/roadmap/VERSION-ROADMAP.md` and `docs-local/prd/v1.0-STABLE-LOCAL-INSPECTOR-PRD.md` (planning docs; not a promise of future features).
38
+ For roadmap intent, see [ROADMAP.md](../ROADMAP.md) (direction only not a delivery guarantee).
@@ -50,5 +50,7 @@ Run req_123
50
50
  See also:
51
51
  - `docs/CLI.md` (`logs`, `tail`)
52
52
  - `docs/LOGS.md`
53
+ - `docs/LOGGING-PLAYBOOK.md` (pino / log4js / NestJS examples + fixtures)
53
54
  - `docs/SCHEMA.md` (log ingest config types + confidence)
55
+ - `examples/recipes/pino-json-logs/`, `log4js-json-layout/`, `nestjs-json-logging/`
54
56
 
package/docs/LOGS.md CHANGED
@@ -4,8 +4,9 @@ AgentInspect can parse **existing logs** (line-delimited JSON, and best-effort l
4
4
 
5
5
  - **CLI usage**: `docs/CLI.md` (`logs`, `tail`)
6
6
  - **Quickstart**: `docs/LOG-TO-TREE-QUICKSTART.md`
7
- - **Log ingest config (field mapping + redaction)**: `docs-local/architecture/LOG-INGEST-CONFIG.md`
8
- - **Safety constraints** (no eval, no JS object parsing): `docs-local/architecture/ARCHITECTURE.md`
7
+ - **Production-shaped playbook**: `docs/LOGGING-PLAYBOOK.md` (pino, log4js, NestJS recipes)
8
+ - **Field mapping and redaction**: `docs/API.md` (log ingest APIs) and `docs/SCHEMA.md`
9
+ - **Safety constraints**: JSON logs first-class; log4js best-effort; no `eval`; no JavaScript object-literal parsing as a log interchange format (see `SECURITY.md`)
9
10
 
10
11
  Notes:
11
12
  - Log parsing APIs are documented as **experimental** in `docs/API.md`.
package/docs/SCHEMA.md CHANGED
@@ -131,6 +131,8 @@ Unknown status must **not** be treated as success.
131
131
  - Runs may include `metadata` on `run_started`.
132
132
  - Steps may include `metadata` on `step_started`.
133
133
  - Manual traces intentionally avoid full prompt/output capture by default.
134
+ - **Redaction (default on):** before disk, `inspectRun` / `step` redact sensitive keys using the shared `Redactor` defaults (`authorization`, `cookie`, `token`, `apiKey`, `password`, `secret`, `email`). Opt out with `redact: false`.
135
+ - **Size bounds:** long string values are truncated (`maxMetadataValueLength`, default 2000; preview-like keys use `maxPreviewLength`, default 500). Serialized events are capped at `maxEventBytes` (default 65536 UTF-8 bytes). If still too large, `metadata` may be replaced with `{ truncated: true, reason: "maxEventBytes", originalApproxBytes: number }`. Required event fields are never removed.
134
136
 
135
137
  ## 7. Additive fields and unknown fields
136
138
 
@@ -186,11 +188,15 @@ Log-derived trees must remain honest:
186
188
 
187
189
  ## 13. Redaction considerations
188
190
 
189
- Redaction is applied to log-derived attributes and to exports by default. **Manual trace metadata is user-controlled** and should be treated as potentially sensitive.
191
+ Redaction is applied to **log-derived attributes**, **manual trace metadata (before disk, by default)**, and **exports by default**.
192
+
193
+ - Manual metadata redaction uses exact key matching (case-insensitive), not substring matching.
194
+ - `redact: false` is an explicit opt-out; use only when you accept local persistence of metadata as provided.
195
+ - Local trace files can still contain sensitive data if you use non-default key names or opt out of redaction.
190
196
 
191
197
  Always review any exported content (Markdown/HTML/OpenInference/OTLP JSON) before sharing, especially if you enable richer attribute inclusion.
192
198
 
193
- See: `docs-local/architecture/REDACTION.md`.
199
+ See: `SECURITY.md` and `docs/API.md` (`InspectRunOptions.redact`, size bound options).
194
200
 
195
201
  ## 14. Migration notes
196
202
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-inspect",
3
- "version": "1.0.2",
3
+ "version": "1.1.0",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "description": "Local-first execution-tree debugger for TypeScript AI agents",
@@ -12,15 +12,19 @@
12
12
  "url": "https://github.com/rajudandigam/agent-inspect/issues"
13
13
  },
14
14
  "homepage": "https://github.com/rajudandigam/agent-inspect#readme",
15
- "packageManager": "pnpm@9.15.0",
16
15
  "main": "./packages/core/dist/index.cjs",
17
16
  "module": "./packages/core/dist/index.mjs",
18
17
  "types": "./packages/core/dist/index.d.ts",
19
18
  "exports": {
20
19
  ".": {
21
- "types": "./packages/core/dist/index.d.ts",
22
- "import": "./packages/core/dist/index.mjs",
23
- "require": "./packages/core/dist/index.cjs"
20
+ "import": {
21
+ "types": "./packages/core/dist/index.d.ts",
22
+ "default": "./packages/core/dist/index.mjs"
23
+ },
24
+ "require": {
25
+ "types": "./packages/core/dist/index.d.cts",
26
+ "default": "./packages/core/dist/index.cjs"
27
+ }
24
28
  }
25
29
  },
26
30
  "bin": {
@@ -71,6 +75,16 @@
71
75
  "nanoid": "^5.0.9",
72
76
  "commander": "^12.1.0"
73
77
  },
78
+ "devDependencies": {
79
+ "@changesets/cli": "^2.27.10",
80
+ "@size-limit/preset-small-lib": "^11.1.6",
81
+ "@types/node": "^22.10.2",
82
+ "@vitest/coverage-v8": "^2.1.8",
83
+ "size-limit": "^11.1.6",
84
+ "tsup": "^8.3.5",
85
+ "typescript": "^5.7.2",
86
+ "vitest": "^2.1.8"
87
+ },
74
88
  "scripts": {
75
89
  "clean": "pnpm -r exec -- rm -rf dist",
76
90
  "build": "pnpm exec tsup --config tsup.core.config.ts && pnpm exec tsup --config tsup.cli.config.ts && pnpm exec tsup --config tsup.langchain.config.ts && pnpm exec tsup --config tsup.tui.config.ts",
@@ -81,8 +95,6 @@
81
95
  "size": "size-limit --config size-limit.config.mjs",
82
96
  "test:all": "pnpm run typecheck && pnpm run test && pnpm run build && pnpm run size",
83
97
  "prepublish:checks": "pnpm run typecheck && pnpm run test && pnpm run test:coverage && pnpm run build && pnpm run fixtures:check && pnpm run recipes:check && pnpm run size && pnpm run pack:smoke",
84
- "prepublishOnly": "pnpm run prepublish:checks",
85
- "prepack": "pnpm run clean && pnpm run build",
86
98
  "pack:dry-run": "pnpm run build && npm pack --dry-run",
87
99
  "pack:smoke": "pnpm run build && node scripts/package-smoke.mjs",
88
100
  "fixtures:check": "node scripts/validate-fixtures.mjs",
@@ -91,15 +103,5 @@
91
103
  "examples:check": "pnpm install && pnpm --filter agent-inspect-example-01-basic run start",
92
104
  "changeset": "changeset",
93
105
  "release": "changeset publish"
94
- },
95
- "devDependencies": {
96
- "@changesets/cli": "^2.27.10",
97
- "@size-limit/preset-small-lib": "^11.1.6",
98
- "@types/node": "^22.10.2",
99
- "@vitest/coverage-v8": "^2.1.8",
100
- "size-limit": "^11.1.6",
101
- "tsup": "^8.3.5",
102
- "typescript": "^5.7.2",
103
- "vitest": "^2.1.8"
104
106
  }
105
- }
107
+ }