agent-inspect 1.7.0 → 1.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/CHANGELOG.md +21 -1
  2. package/README.md +145 -21
  3. package/docs/ADAPTER-CONFORMANCE.md +7 -3
  4. package/docs/ADAPTERS.md +155 -5
  5. package/docs/API.md +214 -26
  6. package/docs/CLI.md +189 -7
  7. package/docs/GETTING-STARTED.md +71 -16
  8. package/docs/KNOWN-ISSUES.md +7 -1
  9. package/docs/LIMITATIONS.md +7 -1
  10. package/docs/LOG-TO-TREE-QUICKSTART.md +1 -2
  11. package/docs/MIGRATION.md +67 -0
  12. package/docs/SCHEMA.md +1 -0
  13. package/package.json +12 -2
  14. package/packages/cli/dist/index.cjs +2454 -140
  15. package/packages/cli/dist/index.cjs.map +1 -1
  16. package/packages/cli/dist/index.mjs +2454 -140
  17. package/packages/cli/dist/index.mjs.map +1 -1
  18. package/packages/core/dist/advanced.d.cts +4 -4
  19. package/packages/core/dist/advanced.d.ts +4 -4
  20. package/packages/core/dist/checks.cjs +1535 -0
  21. package/packages/core/dist/checks.cjs.map +1 -0
  22. package/packages/core/dist/checks.d.cts +585 -0
  23. package/packages/core/dist/checks.d.ts +585 -0
  24. package/packages/core/dist/checks.mjs +1512 -0
  25. package/packages/core/dist/checks.mjs.map +1 -0
  26. package/packages/core/dist/diff.d.cts +3 -3
  27. package/packages/core/dist/diff.d.ts +3 -3
  28. package/packages/core/dist/exporters.d.cts +3 -3
  29. package/packages/core/dist/exporters.d.ts +3 -3
  30. package/packages/core/dist/index.cjs +146 -0
  31. package/packages/core/dist/index.cjs.map +1 -1
  32. package/packages/core/dist/index.d.cts +44 -7
  33. package/packages/core/dist/index.d.ts +44 -7
  34. package/packages/core/dist/index.mjs +148 -1
  35. package/packages/core/dist/index.mjs.map +1 -1
  36. package/packages/core/dist/{inspect-event-Des4JDHo.d.cts → inspect-event-CevRYp58.d.cts} +1 -1
  37. package/packages/core/dist/{inspect-event-Des4JDHo.d.ts → inspect-event-CevRYp58.d.ts} +1 -1
  38. package/packages/core/dist/{log-config-C1GcJPIM.d.ts → log-config-BPHS4Sds.d.ts} +1 -1
  39. package/packages/core/dist/{log-config-BnH8Ykcb.d.cts → log-config-DanPV3P9.d.cts} +1 -1
  40. package/packages/core/dist/logs.d.cts +3 -3
  41. package/packages/core/dist/logs.d.ts +3 -3
  42. package/packages/core/dist/{persisted-inspect-event-DiFto0K2.d.ts → persisted-inspect-event-Cw7TeYGr.d.ts} +1 -1
  43. package/packages/core/dist/{persisted-inspect-event-0kaRADsp.d.cts → persisted-inspect-event-DHPfzUd8.d.cts} +1 -1
  44. package/packages/core/dist/persisted.d.cts +5 -5
  45. package/packages/core/dist/persisted.d.ts +5 -5
  46. package/packages/core/dist/readers.d.cts +2 -2
  47. package/packages/core/dist/readers.d.ts +2 -2
  48. package/packages/core/dist/{types-tSix7tfv.d.ts → types-Ap9uMdx_.d.ts} +1 -1
  49. package/packages/core/dist/{types-DB8jB6Jg.d.cts → types-B2-BU5CS.d.cts} +1 -1
  50. package/packages/core/dist/writers.d.cts +2 -2
  51. package/packages/core/dist/writers.d.ts +2 -2
@@ -25,7 +25,36 @@ pnpm build
25
25
  node packages/cli/dist/index.cjs --help
26
26
  ```
27
27
 
28
- ## 2. Basic manual trace
28
+ ## 2. Observe an existing object/class first
29
+
30
+ ```ts
31
+ import { observe } from "agent-inspect";
32
+
33
+ class SupportAgent {
34
+ async run(input: { question: string }) {
35
+ return {
36
+ answer: `Answering: ${input.question}`,
37
+ };
38
+ }
39
+ }
40
+
41
+ const agent = observe(new SupportAgent(), {
42
+ traceDir: "./.agent-inspect",
43
+ });
44
+
45
+ await agent.run({
46
+ question: "How do refunds work?",
47
+ });
48
+ ```
49
+
50
+ This writes a local JSONL trace with stable event names (`schemaVersion: "0.1"`) when the observed `run` method is called:
51
+
52
+ - `run_started`, `run_completed`
53
+ - `step_started`, `step_completed`
54
+
55
+ ## 3. Manually instrument custom flows
56
+
57
+ Use `inspectRun` and `step` when you want explicit step names, custom nesting, or a flow that is not shaped like an object/class method.
29
58
 
30
59
  ```ts
31
60
  import { inspectRun, step } from "agent-inspect";
@@ -37,10 +66,30 @@ await inspectRun("demo-agent", async () => {
37
66
  });
38
67
  ```
39
68
 
40
- This writes a local JSONL trace with stable event names (`schemaVersion: "0.1"`):
69
+ Use the root import for stable beginner APIs:
41
70
 
42
- - `run_started`, `run_completed`
43
- - `step_started`, `step_completed`
71
+ ```ts
72
+ import {
73
+ observe,
74
+ inspectRun,
75
+ maybeInspectRun,
76
+ step,
77
+ getCurrentCorrelationMetadata,
78
+ } from "agent-inspect";
79
+ ```
80
+
81
+ Use subpaths for advanced, experimental, or lower-level workflows:
82
+
83
+ ```ts
84
+ import { openTrace } from "agent-inspect/readers";
85
+ import { memoryWriter } from "agent-inspect/writers";
86
+ import { runTraceChecks } from "agent-inspect/checks";
87
+ import { diffTraceEvents } from "agent-inspect/diff";
88
+ import { exportMarkdown } from "agent-inspect/exporters";
89
+ import { parseLogsToTrees } from "agent-inspect/logs";
90
+ import { traceEventsToPersistedInspectEvents } from "agent-inspect/persisted";
91
+ import { createInspector } from "agent-inspect/advanced";
92
+ ```
44
93
 
45
94
  ### Always trace vs env-gated tracing
46
95
 
@@ -90,14 +139,14 @@ If `import` or `require` fails after install, see [KNOWN-ISSUES.md — Common in
90
139
 
91
140
  To skip tracing in code without env vars: `inspectRun(name, fn, { enabled: false })`.
92
141
 
93
- ## 3. View runs
142
+ ## 4. View runs
94
143
 
95
144
  ```bash
96
145
  agent-inspect list
97
146
  agent-inspect view <runId>
98
147
  ```
99
148
 
100
- ## 4. Clean old runs (safely)
149
+ ## 5. Clean old runs (safely)
101
150
 
102
151
  Always start with `--dry-run`:
103
152
 
@@ -106,7 +155,7 @@ agent-inspect clean --older-than 7d --dry-run
106
155
  agent-inspect clean --older-than 7d --yes
107
156
  ```
108
157
 
109
- ## 5. Parse existing logs
158
+ ## 6. Advanced ingestion: parse existing structured logs
110
159
 
111
160
  ```bash
112
161
  agent-inspect logs fixtures/logs/proactive-json.log \
@@ -114,7 +163,7 @@ agent-inspect logs fixtures/logs/proactive-json.log \
114
163
  --config fixtures/configs/proactive-agent-inspect.logs.json
115
164
  ```
116
165
 
117
- ## 6. Tail logs
166
+ ## 7. Tail logs
118
167
 
119
168
  For scripting/CI-style usage, `--once` reads and exits:
120
169
 
@@ -126,7 +175,7 @@ agent-inspect tail \
126
175
  --once
127
176
  ```
128
177
 
129
- ## 7. Export a run
178
+ ## 8. Export a run
130
179
 
131
180
  ```bash
132
181
  agent-inspect export minimal-success --dir fixtures/traces --format markdown
@@ -142,7 +191,7 @@ agent-inspect export minimal-success --dir fixtures/traces \
142
191
 
143
192
  Exports are **local-only** and do not upload anywhere. Review output before sharing — see [SAFE-TRACE-SHARING.md](./SAFE-TRACE-SHARING.md).
144
193
 
145
- ## 8. Local observability (v1.4.0+)
194
+ ## 9. Local observability (v1.4.0+)
146
195
 
147
196
  After traces exist under a directory:
148
197
 
@@ -154,17 +203,21 @@ agent-inspect search --dir ./.agent-inspect --status error --limit 10
154
203
 
155
204
  For CI artifact workflows, see [CI-ARTIFACTS.md](./CI-ARTIFACTS.md) and [github-actions-artifact recipe](../examples/recipes/github-actions-artifact/).
156
205
 
157
- ## 9. Diff two runs
206
+ ## 10. Diff two runs
158
207
 
159
208
  ```bash
160
209
  agent-inspect diff minimal-success minimal-error --dir fixtures/traces
161
210
  ```
162
211
 
163
- ## 9. Try recipes
212
+ ## 11. Try recipes
164
213
 
165
214
  See `examples/recipes/README.md`.
166
215
 
167
- ## 10. Optional LangChain adapter
216
+ ## 12. Optional framework adapters
217
+
218
+ See [ADAPTERS.md](./ADAPTERS.md) for AI SDK local telemetry, OpenAI Agents local-only processing, and LangChain callbacks.
219
+
220
+ ### LangChain
168
221
 
169
222
  `@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.
170
223
 
@@ -174,7 +227,7 @@ pnpm add @agent-inspect/langchain
174
227
 
175
228
  See [examples/08-langchain-adapter](../examples/08-langchain-adapter/README.md) and [docs/ADAPTERS.md](./ADAPTERS.md).
176
229
 
177
- ## 11. Optional TUI
230
+ ## 13. Optional TUI
178
231
 
179
232
  `@agent-inspect/tui` is optional and **experimental**. The CLI can invoke it with:
180
233
 
@@ -182,14 +235,16 @@ See [examples/08-langchain-adapter](../examples/08-langchain-adapter/README.md)
182
235
  agent-inspect view <runId> --tui
183
236
  ```
184
237
 
185
- ## 12. Safety notes
238
+ ## 14. Safety notes
186
239
 
240
+ - Nothing uploads by default; core tracing, readers, checks, and exports are local-first.
187
241
  - 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.
242
+ - Export redaction shapes a local copy and does not mutate the source trace; review exported files before sharing.
188
243
  - Persisted events are size-bounded by default (see `docs/API.md`).
189
244
  - Confidence labels are required to keep attribution honest.
190
245
  - AgentInspect is for local debugging, not production monitoring.
191
246
 
192
- ## 13. Next docs
247
+ ## 15. Next docs
193
248
 
194
249
  - [docs/API.md](./API.md)
195
250
  - [docs/CLI.md](./CLI.md)
@@ -23,7 +23,7 @@ AgentInspect is **local-first** and **CLI-first**. These behaviors are intention
23
23
 
24
24
  - **Vendor sinks** (hosted dashboards, Langfuse/Braintrust/New Relic/Datadog native uploads, OTLP gRPC streaming, etc.) are **not implemented** in the core packages described here.
25
25
  - **AI SDK adapter** (`@agent-inspect/ai-sdk`) is experimental and metadata-first. It depends on explicit AI SDK telemetry configuration and requires `recordInputs: false` / `recordOutputs: false` for the documented safe path.
26
- - **OpenAI Agents JS adapter** (`@agent-inspect/openai-agents`) is scaffold-only in the v1.7 train. Runtime span mapping is not implemented, and the safe future path is `setTraceProcessors()` rather than `addTraceProcessor()`.
26
+ - **OpenAI Agents JS adapter** (`@agent-inspect/openai-agents`) is experimental and remains private/unpublished until the v1.8 first-publication gate. Runtime metadata mapping is local-only; the safe install path is `setTraceProcessors()` rather than `addTraceProcessor()`.
27
27
  - **LangGraph support** is currently a documented boundary through `@agent-inspect/langchain`, not a dedicated package.
28
28
  - **LangChain adapter** captures **metadata-oriented** signals by default; it does not replace full framework observability.
29
29
  - **LangChain `stream: true`** records chunk counts and timing only — not a full token replay. Per-token JSONL events are not emitted.
@@ -93,6 +93,12 @@ pnpm compat:smoke
93
93
  - Fixture pattern: [test/consumer-fixtures/jest-cjs/](../../test/consumer-fixtures/jest-cjs/).
94
94
  - Full Jest runner smoke in CI is a documented follow-up — root package does not ship Jest as a devDependency.
95
95
 
96
+ ## v1.8 pre-release adoption notes
97
+
98
+ - `@agent-inspect/vitest` and `@agent-inspect/jest` are private/unpublished until the v1.8 release-readiness gate completes. The [test reporter artifact recipe](../examples/recipes/test-reporter-artifacts/README.md) documents the intended config shape without requiring those packages.
99
+ - `agent-inspect artifacts --github-summary` writes a local step-summary file only. It does not call GitHub APIs, open PR comments, upload artifacts, or mutate repository state.
100
+ - Baseline checks compare normalized structural facts from explicit candidate and baseline inputs. They are useful for CI regression evidence, not replay or semantic eval scoring.
101
+
96
102
  ### What to include in a bug report
97
103
 
98
104
  - Node.js version (`node -v`)
@@ -31,7 +31,7 @@ This document states what AgentInspect **does not** provide today. It complement
31
31
 
32
32
  - **AI SDK integration is explicit telemetry wiring.** Use `@agent-inspect/ai-sdk` through AI SDK `experimental_telemetry.integrations`; AgentInspect does not wrap providers, patch fetch, or enable telemetry globally.
33
33
  - **AI SDK privacy settings are caller-owned.** Examples set `recordInputs: false` and `recordOutputs: false`; leaving those enabled in user code can cause the AI SDK telemetry layer to include richer data before AgentInspect receives events.
34
- - **OpenAI Agents JS support is scaffold-only.** `@agent-inspect/openai-agents` documents the safe `setTraceProcessors()` boundary but does not map runtime spans yet and is not part of the v1.7 published package set.
34
+ - **OpenAI Agents JS support is experimental and not published yet.** `@agent-inspect/openai-agents` maps metadata-only runtime spans through the safe `setTraceProcessors()` boundary, remains private until the v1.8 first-publication gate, and does not capture raw payloads by default.
35
35
  - **LangGraph support is a boundary decision, not a separate package.** Initial support is expected through `@agent-inspect/langchain` callbacks unless no-network fixtures prove a separate package is needed.
36
36
  - **No root/core adapter dependencies.** AI SDK, OpenAI Agents, LangGraph, OpenTelemetry, and LangChain remain outside the root/core runtime dependency graph.
37
37
 
@@ -54,6 +54,12 @@ This document states what AgentInspect **does not** provide today. It complement
54
54
  - **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).
55
55
  - **Redaction is not encryption.** Local trace files remain readable on disk; treat `.agent-inspect-runs/` like any developer artifact that may contain operational data.
56
56
 
57
+ ## Checks, artifacts, and test reporters
58
+
59
+ - **Checks are deterministic local rules, not compliance certification.** `check`, `scan`, and `verify-safe` surface bounded findings and diagnostics over supported local inputs; they do not prove a trace is safe for every sharing context.
60
+ - **Safe CI artifacts are structural summaries.** They avoid raw prompt/output/request/response/header/tool payload content by default, but teams should still review generated files before sharing.
61
+ - **Vitest/Jest reporters are optional and unpublished until release readiness in the v1.8 train.** The recipes document config patterns and explicit associations; consumers should install the packages only after publication.
62
+
57
63
  ## Execution semantics
58
64
 
59
65
  - **No replay / fork** of past runs from traces alone.
@@ -1,6 +1,6 @@
1
1
  ## Log-to-tree quickstart
2
2
 
3
- AgentInspect can inspect **structured logs** and render a local execution tree without requiring you to wrap every function in manual tracing.
3
+ Advanced ingestion: use this when your app already emits structured logs. AgentInspect can inspect those logs and render a local execution tree without requiring you to wrap every function in manual tracing.
4
4
 
5
5
  ## Example JSON log lines
6
6
 
@@ -53,4 +53,3 @@ See also:
53
53
  - `docs/LOGGING-PLAYBOOK.md` (pino / log4js / NestJS examples + fixtures)
54
54
  - `docs/SCHEMA.md` (log ingest config types + confidence)
55
55
  - `examples/recipes/pino-json-logs/`, `log4js-json-layout/`, `nestjs-json-logging/`
56
-
@@ -0,0 +1,67 @@
1
+ # Migration
2
+
3
+ AgentInspect 1.x keeps existing global APIs and published imports working. Manual trace writing remains `schemaVersion: "0.1"`, and v0.1/v0.2 traces remain readable.
4
+
5
+ ## From older 1.x docs
6
+
7
+ Prefer the current adoption order:
8
+
9
+ 1. Use `observe()` for an existing object/class.
10
+ 2. Use framework adapters when you already run AI SDK, OpenAI Agents, or LangChain.
11
+ 3. Use `inspectRun` and `step` when you need explicit custom spans.
12
+ 4. Use structured log parsing as advanced ingestion when your app already emits structured logs.
13
+
14
+ ## Imports
15
+
16
+ Use the root import for stable beginner APIs:
17
+
18
+ ```ts
19
+ import {
20
+ observe,
21
+ inspectRun,
22
+ maybeInspectRun,
23
+ step,
24
+ getCurrentCorrelationMetadata,
25
+ } from "agent-inspect";
26
+ ```
27
+
28
+ Use subpaths for advanced, experimental, or lower-level workflows:
29
+
30
+ ```ts
31
+ import { openTrace } from "agent-inspect/readers";
32
+ import { memoryWriter } from "agent-inspect/writers";
33
+ import { runTraceChecks } from "agent-inspect/checks";
34
+ import { diffTraceEvents } from "agent-inspect/diff";
35
+ import { exportMarkdown } from "agent-inspect/exporters";
36
+ import { parseLogsToTrees } from "agent-inspect/logs";
37
+ import { traceEventsToPersistedInspectEvents } from "agent-inspect/persisted";
38
+ import { createInspector } from "agent-inspect/advanced";
39
+ ```
40
+
41
+ ## v2 import preparation
42
+
43
+ No import changes are required for v1.x. To prepare for v2, keep beginner workflow APIs at the root and move advanced usage to subpaths now.
44
+
45
+ | 1.x root compatibility import | Preferred 1.x import for new code | v2 direction |
46
+ | --- | --- | --- |
47
+ | `inspectRun`, `maybeInspectRun`, `step`, `observe`, `getCurrentCorrelationMetadata` | `agent-inspect` | stays root |
48
+ | `createInspector` | `agent-inspect/advanced` | likely root and `/advanced` |
49
+ | `createInspectorRuntime` | `agent-inspect/advanced` | `/advanced` |
50
+ | `openTrace`, `readTrace`, `detectTraceFormat` | `agent-inspect/readers` | `/readers` |
51
+ | `memoryWriter`, `fileWriter`, `bufferedFileWriter`, `compositeWriter`, `nullWriter` | `agent-inspect/writers` | `/writers` |
52
+ | `runTraceChecks` and check types | `agent-inspect/checks` | `/checks` |
53
+ | `diffTraceEvents`, `diffRuns`, `renderRunDiff` | `agent-inspect/diff` | `/diff` |
54
+ | `exportMarkdown`, `exportHtml`, `exportOpenInference`, `exportOtlpJson` | `agent-inspect/exporters` | `/exporters` |
55
+ | `parseLogsToTrees`, log parsers, tree builders | `agent-inspect/logs` | `/logs` |
56
+ | persisted conversion helpers | `agent-inspect/persisted` | `/persisted` |
57
+
58
+ ## Safety
59
+
60
+ Nothing uploads by default. Manual metadata is redacted before disk by default, and export redaction applies to a local copy before you share it. Review traces and exports before posting them in issues, PRs, chats, or public docs.
61
+
62
+ ## Compatibility notes
63
+
64
+ - Existing `inspectRun`, `maybeInspectRun`, `step`, `step.llm`, `step.tool`, `observe`, and `getCurrentCorrelationMetadata` imports remain valid.
65
+ - Root/core does not require optional adapter dependencies.
66
+ - Optional adapter APIs are experimental and package-scoped.
67
+ - No destructive migration is required for existing trace directories.
package/docs/SCHEMA.md CHANGED
@@ -250,6 +250,7 @@ v1.6 adds experimental writer and reader surfaces without changing the stable ma
250
250
  - `agent-inspect/readers` and `agent-inspect open` read local AgentInspect JSONL, OpenInference JSON, and OTLP JSON inputs through compatibility adapters.
251
251
  - OpenInference and OTLP JSON inputs are **not** a third AgentInspect persisted schema. They are local read formats normalized into inspection trees with warnings and unsupported-field reporting.
252
252
  - Reader and writer APIs perform no network upload and do not mutate source files.
253
+ - v1.8 checks, safety verification, baseline comparison, safe CI artifacts, and reporter artifacts are report layers over existing trace inputs. They do not change manual trace writing, introduce a third persisted trace model, or embed raw prompt/output/request/response/header/tool payload content in their default structural outputs.
253
254
 
254
255
  ## 16. Migration notes
255
256
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-inspect",
3
- "version": "1.7.0",
3
+ "version": "1.9.0",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "description": "Local-first execution-tree debugger for TypeScript AI agents",
@@ -95,6 +95,16 @@
95
95
  "types": "./packages/core/dist/readers.d.cts",
96
96
  "default": "./packages/core/dist/readers.cjs"
97
97
  }
98
+ },
99
+ "./checks": {
100
+ "import": {
101
+ "types": "./packages/core/dist/checks.d.ts",
102
+ "default": "./packages/core/dist/checks.mjs"
103
+ },
104
+ "require": {
105
+ "types": "./packages/core/dist/checks.d.cts",
106
+ "default": "./packages/core/dist/checks.cjs"
107
+ }
98
108
  }
99
109
  },
100
110
  "bin": {
@@ -158,7 +168,7 @@
158
168
  },
159
169
  "scripts": {
160
170
  "clean": "pnpm -r exec -- rm -rf dist",
161
- "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 && pnpm exec tsup --config tsup.ai-sdk.config.ts && pnpm exec tsup --config tsup.openai-agents.config.ts",
171
+ "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 && pnpm exec tsup --config tsup.ai-sdk.config.ts && pnpm exec tsup --config tsup.vitest.config.ts && pnpm exec tsup --config tsup.jest.config.ts && pnpm exec tsup --config tsup.openai-agents.config.ts && pnpm exec tsup --config tsup.harness.config.ts",
162
172
  "typecheck": "tsc --noEmit",
163
173
  "test": "vitest run",
164
174
  "test:watch": "vitest",