agent-inspect 2.3.0 → 2.4.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 (42) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/README.md +33 -4
  3. package/docs/ADAPTERS.md +47 -0
  4. package/docs/CLI.md +54 -1
  5. package/docs/SCHEMA.md +1 -0
  6. package/package.json +2 -2
  7. package/packages/cli/dist/index.cjs +757 -14
  8. package/packages/cli/dist/index.cjs.map +1 -1
  9. package/packages/cli/dist/index.mjs +757 -14
  10. package/packages/cli/dist/index.mjs.map +1 -1
  11. package/packages/core/dist/advanced.cjs +581 -3
  12. package/packages/core/dist/advanced.cjs.map +1 -1
  13. package/packages/core/dist/advanced.d.cts +172 -8
  14. package/packages/core/dist/advanced.d.ts +172 -8
  15. package/packages/core/dist/advanced.mjs +572 -4
  16. package/packages/core/dist/advanced.mjs.map +1 -1
  17. package/packages/core/dist/checks.d.cts +2 -2
  18. package/packages/core/dist/checks.d.ts +2 -2
  19. package/packages/core/dist/{context-yv2VSDQF.d.ts → context-BDZmi53V.d.ts} +3 -3
  20. package/packages/core/dist/{context-CSKnzpXR.d.cts → context-DjY-jvQk.d.cts} +3 -3
  21. package/packages/core/dist/diff.d.cts +3 -3
  22. package/packages/core/dist/diff.d.ts +3 -3
  23. package/packages/core/dist/exporters.d.cts +3 -3
  24. package/packages/core/dist/exporters.d.ts +3 -3
  25. package/packages/core/dist/index.d.cts +6 -6
  26. package/packages/core/dist/index.d.ts +6 -6
  27. package/packages/core/dist/{inspect-event-CevRYp58.d.cts → inspect-event-CYAV7Hxm.d.cts} +1 -1
  28. package/packages/core/dist/{inspect-event-CevRYp58.d.ts → inspect-event-CYAV7Hxm.d.ts} +1 -1
  29. package/packages/core/dist/{log-config-8aE5Kxtr.d.cts → log-config-BNQ9UTmP.d.cts} +1 -1
  30. package/packages/core/dist/{log-config-DVimQJho.d.ts → log-config-D3Yp1SZN.d.ts} +1 -1
  31. package/packages/core/dist/logs.d.cts +3 -3
  32. package/packages/core/dist/logs.d.ts +3 -3
  33. package/packages/core/dist/{persisted-inspect-event-D-WpXeZX.d.ts → persisted-inspect-event-BLvb0jSX.d.ts} +1 -1
  34. package/packages/core/dist/{persisted-inspect-event-DHcHPUKv.d.cts → persisted-inspect-event-D5SjBz9b.d.cts} +1 -1
  35. package/packages/core/dist/persisted.d.cts +5 -5
  36. package/packages/core/dist/persisted.d.ts +5 -5
  37. package/packages/core/dist/readers.d.cts +2 -2
  38. package/packages/core/dist/readers.d.ts +2 -2
  39. package/packages/core/dist/{types-DgMN3qow.d.cts → types-C-llnPH0.d.cts} +1 -1
  40. package/packages/core/dist/{types-D-Y1kOU-.d.ts → types-CQun9LW6.d.ts} +1 -1
  41. package/packages/core/dist/writers.d.cts +2 -2
  42. package/packages/core/dist/writers.d.ts +2 -2
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## 2.4.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 483168d: Release v2.4.0 with sessions workflow navigation and MCP client telemetry.
8
+
9
+ This train adds multi-run session indexing on `agent-inspect/advanced`, `sessions` / `session` CLI, session-aware `search` and `check`, and the new `@agent-inspect/mcp` package for local MCP client `tools/list` and `tools/call` tracing. No schema break, no MCP gateway/server, and no default network behavior.
10
+
3
11
  ## 2.3.0
4
12
 
5
13
  ### Minor Changes
@@ -18,6 +26,14 @@
18
26
 
19
27
  ## Unreleased
20
28
 
29
+ ### Draft v2.4.0 Notes
30
+
31
+ - Added session/workflow causality model and `agent-inspect/advanced` session index helpers (`buildSessionIndex`, scope/cohort helpers, session fixtures).
32
+ - Added `agent-inspect sessions` and `agent-inspect session` CLI for multi-run handoff/retry navigation with timeline, critical-path, diagnostics, and JSON output.
33
+ - Added session-aware `search --session` and `check --session` / `--group` with aggregated per-run evidence.
34
+ - Added public optional `@agent-inspect/mcp` for local MCP **client** `tools/list` and `tools/call` telemetry with bounded summaries and `source.type: mcp-client` metadata.
35
+ - No schema version change, no MCP gateway/server, no timestamp-only causality inference, and no root/core dependency on MCP SDKs.
36
+
21
37
  ### Draft v2.3.0 Notes
22
38
 
23
39
  - Hardened the official adapter paths for AI SDK, OpenAI Agents JS, and LangChain/LangGraph with no-network recipes, local-only defaults, clearer lifecycle coverage, and executable adapter conformance evidence.
package/README.md CHANGED
@@ -22,7 +22,7 @@ agent-inspect gives those runs **structure**: an **execution tree** you can read
22
22
 
23
23
  ## Install
24
24
 
25
- Current npm release line: **2.1.x** for the existing public packages. v2.1.0 adds deterministic local eval and reusable redaction utilities on top of the stable v2 trace contract: small root API, schema 1.0 persisted writer path, v0.1/v0.2/v1.0 read compatibility, and explicit non-destructive migration workflow.
25
+ Current npm release line: **2.3.x** for the existing public packages. **v2.4.0** (release prep) adds multi-run **session** navigation (`sessions` / `session` CLI), session-aware `search` and `check`, and optional **`@agent-inspect/mcp`** client telemetry all local-first on top of the stable v2 trace contract.
26
26
 
27
27
  ```bash
28
28
  npm install agent-inspect
@@ -334,13 +334,15 @@ AgentInspect is the **local-first trace workbench** for TypeScript AI agents:
334
334
 
335
335
  - Instrument runs with `inspectRun` and `step`
336
336
  - Write and read **local JSONL traces** (`schemaVersion: "0.1"` manual traces remain readable; schema 1.0 persisted rows are the v2 writer target)
337
- - Inspect with **`list`**, **`view`**, **`clean`**, **`logs`**, **`tail`**, **`export`**, **`diff`**, **`timeline`**, **`stats`**, **`search`**
337
+ - Inspect with **`list`**, **`view`**, **`clean`**, **`logs`**, **`tail`**, **`export`**, **`diff`**, **`timeline`**, **`stats`**, **`search`**, **`sessions`**, **`session`**
338
338
 
339
339
  **Stable root APIs:** `createInspector()`, `inspectRun()`, `maybeInspectRun()`, `step()`, `step.llm()`, `step.tool()`, `observe()`, `getCurrentCorrelationMetadata()`.
340
340
 
341
341
  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).
342
342
 
343
- **v2.3 train status:** adapter hardening is ready for release prep. AI SDK, OpenAI Agents JS, and LangChain/LangGraph paths have no-network recipes and executable conformance coverage. Mastra and NestJS framework packages remain demand-gated; NestJS is covered through structured-log ingestion.
343
+ **v2.4 train status:** session/workflow causality helpers ship on `agent-inspect/advanced` (`buildSessionIndex`, scope/cohort helpers). CLI adds `sessions`, `session`, `search --session`, and `check --session` / `--group`. Optional `@agent-inspect/mcp` wraps MCP client `tools/list` and `tools/call` as local tool steps with bounded summaries no gateway or server product.
344
+
345
+ **v2.3 shipped:** adapter hardening for AI SDK, OpenAI Agents JS, and LangChain/LangGraph with no-network recipes and executable conformance coverage. Mastra and NestJS framework packages remain demand-gated; NestJS is covered through structured-log ingestion.
344
346
 
345
347
  **Shipped in 2.2.0:** public optional Vitest/Jest reporter packages, shared `agent-inspect/reporters` helpers, and `agent-inspect ci-summary` for deterministic local reporter artifact summaries. Linked release aligns `agent-inspect`, `@agent-inspect/ai-sdk`, `@agent-inspect/langchain`, `@agent-inspect/tui`, `@agent-inspect/openai-agents`, `@agent-inspect/redact`, `@agent-inspect/eval`, `@agent-inspect/vitest`, and `@agent-inspect/jest` at **2.2.0**.
346
348
 
@@ -358,7 +360,7 @@ Pass `enabled: false` to `inspectRun` for a no-trace passthrough. Use `maybeInsp
358
360
 
359
361
  **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**.
360
362
 
361
- **Roadmap beyond current release work:** v2.4 adds sessions/MCP telemetry, followed by guardrails, optional viewer/IDE surfaces, and conditional v3 extensibility. See [ROADMAP.md](ROADMAP.md).
363
+ **Roadmap beyond current release work:** v2.5 guardrails/circuit patterns, optional viewer/IDE surfaces, and conditional v3 extensibility. See [ROADMAP.md](ROADMAP.md).
362
364
 
363
365
  **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**.
364
366
 
@@ -412,6 +414,30 @@ const events = callback.getEvents();
412
414
 
413
415
  See [examples/08-langchain-adapter](examples/08-langchain-adapter/README.md) and [docs/ADAPTERS.md](docs/ADAPTERS.md).
414
416
 
417
+ ### MCP client telemetry (`@agent-inspect/mcp`)
418
+
419
+ Optional package for **local MCP client** tracing only. Wrap `tools/list` and `tools/call` so they emit tool steps with `source.type: mcp-client`, bounded argument summaries, server identity, and optional `sessionId` metadata.
420
+
421
+ ```bash
422
+ pnpm add agent-inspect @agent-inspect/mcp
423
+ ```
424
+
425
+ ```ts
426
+ import { inspectRun } from "agent-inspect";
427
+ import { wrapMcpClient } from "@agent-inspect/mcp";
428
+
429
+ const traced = wrapMcpClient(mcpClient, {
430
+ serverName: "docs-server",
431
+ sessionId: "sess-123",
432
+ });
433
+
434
+ await inspectRun("agent-with-mcp", async () => {
435
+ await traced.callTool({ name: "search", arguments: { query: "sessions" } });
436
+ });
437
+ ```
438
+
439
+ No-network recipe: [mcp-client-tracing](examples/recipes/mcp-client-tracing/). This is **not** an MCP server, gateway, or hosted broker — see [docs/ADAPTERS.md](docs/ADAPTERS.md).
440
+
415
441
  ### TUI viewer (`@agent-inspect/tui`)
416
442
 
417
443
  Optional **Ink/React** package, installed separately. Use with an interactive terminal:
@@ -458,6 +484,9 @@ Reporter artifact behavior and API details are documented in [docs/API.md](docs/
458
484
  | [examples/recipes/test-reporter-artifacts](examples/recipes/test-reporter-artifacts) | Vitest/Jest reporter artifact patterns |
459
485
  | [examples/recipes/what-report-inspect](examples/recipes/what-report-inspect/) | `what` + `report` inspection |
460
486
  | [examples/recipes/runtime-and-ingestion](examples/recipes/runtime-and-ingestion/) | v1.6 runtime writers + universal ingestion |
487
+ | [examples/recipes/mcp-client-tracing](examples/recipes/mcp-client-tracing) | v2.4 MCP client tool-call tracing |
488
+
489
+ **Multi-run sessions:** set `sessionId` (and optional handoff/retry metadata) on `run_started`, then browse with `npx agent-inspect sessions` and `npx agent-inspect session <id> --timeline`. See [SESSIONS-AND-WORKFLOW-CAUSALITY](docs/proposals/SESSIONS-AND-WORKFLOW-CAUSALITY.md).
461
490
 
462
491
  **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).
463
492
 
package/docs/ADAPTERS.md CHANGED
@@ -406,6 +406,53 @@ A future Nest helper remains demand-gated and must be narrower than a framework
406
406
 
407
407
  ---
408
408
 
409
+ ## MCP client telemetry (`@agent-inspect/mcp`)
410
+
411
+ **Status:** experimental optional package — v2.4.0 train.
412
+
413
+ `@agent-inspect/mcp` traces **MCP client** `tools/list` and `tools/call` as local AgentInspect tool steps. It records server identity (name + URL hash), tool name, bounded argument/result summaries, duration, errors, and optional session metadata (`sessionId`, `toolCallId`, `mcpToolCallId`).
414
+
415
+ ### Install
416
+
417
+ ```bash
418
+ npm install agent-inspect @agent-inspect/mcp
419
+ ```
420
+
421
+ ### Wrap a client
422
+
423
+ ```ts
424
+ import { inspectRun } from "agent-inspect";
425
+ import { wrapMcpClient } from "@agent-inspect/mcp";
426
+
427
+ const traced = wrapMcpClient(mcpClient, {
428
+ serverName: "docs-server",
429
+ serverUrl: process.env.MCP_SERVER_URL,
430
+ sessionId: "sess-123",
431
+ });
432
+
433
+ await inspectRun("support-agent", async () => {
434
+ await traced.listTools?.();
435
+ await traced.callTool({ name: "search", arguments: { query: "refund policy" } });
436
+ });
437
+ ```
438
+
439
+ `wrapMcpClient` accepts any object matching the documented `McpClientLike` shape. It does **not** require `@modelcontextprotocol/sdk` at runtime.
440
+
441
+ ### Boundaries (v2.4)
442
+
443
+ | In scope | Out of scope |
444
+ | -------- | ------------ |
445
+ | Client-side `tools/list` and `tools/call` wrapping | MCP **server** implementation |
446
+ | Bounded summaries on tool step metadata | Gateway, proxy, or hosted MCP broker |
447
+ | `source.type: mcp-client` on tool steps | Invoking tools on behalf of the user from AgentInspect |
448
+ | Session metadata attachment when provided | Default trace upload |
449
+
450
+ Recipe: [examples/recipes/mcp-client-tracing](../examples/recipes/mcp-client-tracing/).
451
+
452
+ Session navigation for multi-run workflows uses `agent-inspect sessions` / `session` and optional `search --session` / `check --session` — see [CLI.md](./CLI.md) and [SESSIONS-AND-WORKFLOW-CAUSALITY.md](./proposals/SESSIONS-AND-WORKFLOW-CAUSALITY.md).
453
+
454
+ ---
455
+
409
456
  ## Future adapters (not shipped)
410
457
 
411
458
  Direction only — see [ROADMAP.md](../ROADMAP.md):
package/docs/CLI.md CHANGED
@@ -38,6 +38,8 @@ Core commands:
38
38
  - `timeline` — chronological view of one run (local JSONL)
39
39
  - `stats` — local aggregate stats over a trace directory
40
40
  - `search` — deterministic local search over traces
41
+ - `sessions` — list workflow sessions from trace metadata
42
+ - `session` — inspect one session (handoffs, retries, optional timeline)
41
43
  - `what` — concise summary of a single run (local JSONL)
42
44
  - `report` — markdown or HTML inspection report for a single run
43
45
  - `explain` — deterministic local facts/inferences for a trace, with dry-run payloads
@@ -305,6 +307,9 @@ Options:
305
307
  - `--max-duration-ms <number>`: add `run.duration`
306
308
  - `--required-tool <name>` / `--forbidden-tool <name>`: add `tool.usage`
307
309
  - `--allowed-model <model>` / `--max-total-tokens <number>`: add `llm.usage`
310
+ - `--session <id>`: check all runs in a workflow session (uses `--dir`; target may be `.`)
311
+ - `--group <id>`: check all runs sharing a `groupId` metadata value
312
+ - `--correlate-group`: when using `--session`, also match synthetic `group:` session keys
308
313
 
309
314
  By default, `check` runs `run.status`. Additional built-in rules can be selected with `--rule` or config when their options are available.
310
315
 
@@ -329,6 +334,7 @@ Examples:
329
334
  npx agent-inspect check fixtures/traces-v0.2/manual-basic.jsonl --json
330
335
  npx agent-inspect check minimal-success --dir fixtures/traces --rule run.status
331
336
  npx agent-inspect check trace.jsonl --max-duration-ms 30000 --required-tool search_docs --json
337
+ npx agent-inspect check . --dir ./.agent-inspect --session sess-handoff-001 --json
332
338
  ```
333
339
 
334
340
  Recipe: [examples/recipes/deterministic-ci-checks](../examples/recipes/deterministic-ci-checks/README.md)
@@ -634,6 +640,8 @@ Options:
634
640
  - `--tool <query>` — substring on tool step name or `metadata.toolName`
635
641
  - `--duration <expr>` — e.g. `>5s`, `>=500ms`
636
642
  - `--limit <number>` — default 50
643
+ - `--session <id>` — limit to runs in one workflow session
644
+ - `--correlate-group` — when using `--session`, also match synthetic `group:` keys
637
645
  - `--json`
638
646
 
639
647
  Examples:
@@ -642,11 +650,56 @@ Examples:
642
650
  npx agent-inspect search --status error --dir ./.agent-inspect
643
651
  npx agent-inspect search --kind tool --name search
644
652
  npx agent-inspect search --duration ">100ms" --json
653
+ npx agent-inspect search --session sess-retry-001 --dir ./.agent-inspect
645
654
  ```
646
655
 
647
656
  ![Search traces by status error](../assets/demos/search.gif)
648
657
 
649
- ### 6.19 `what`
658
+ ### 6.19 `sessions`
659
+
660
+ List workflow sessions grouped from local trace metadata (`sessionId`, optional `groupId` correlation). Read-only; no network.
661
+
662
+ ```bash
663
+ agent-inspect sessions [options]
664
+ ```
665
+
666
+ Options:
667
+
668
+ - `--dir <path>`
669
+ - `--correlate-group` — treat shared `groupId` as a synthetic session when `sessionId` is absent
670
+ - `--json` — `SessionIndex` JSON (`sessions`, `unscopedRunIds`, `warnings`)
671
+
672
+ Example:
673
+
674
+ ```bash
675
+ npx agent-inspect sessions --dir ./.agent-inspect
676
+ npx agent-inspect sessions --json
677
+ ```
678
+
679
+ ### 6.20 `session`
680
+
681
+ Inspect one workflow session: runs, handoffs, retries, and optional per-run timelines. Uses the same session index as `sessions`.
682
+
683
+ ```bash
684
+ agent-inspect session <session-id> [options]
685
+ ```
686
+
687
+ Options:
688
+
689
+ - `--dir <path>`
690
+ - `--timeline` — include per-run timelines (human or JSON `timelines`)
691
+ - `--critical-path` — include critical path section
692
+ - `--diagnostics` — include ambiguity warnings for the session
693
+ - `--json` — structured session view
694
+
695
+ Example:
696
+
697
+ ```bash
698
+ npx agent-inspect session sess-handoff-001 --timeline
699
+ npx agent-inspect session sess-retry-001 --critical-path --json
700
+ ```
701
+
702
+ ### 6.21 `what`
650
703
 
651
704
  Concise human-readable summary of one local trace run. Read-only; accepts v0.1 manual JSONL and v0.2 persisted-event JSONL through the shared dual-format normalization path. Vocabulary: [TRACE-VOCABULARY-V1.5.md](./proposals/TRACE-VOCABULARY-V1.5.md).
652
705
 
package/docs/SCHEMA.md CHANGED
@@ -131,6 +131,7 @@ Unknown status must **not** be treated as success.
131
131
 
132
132
  - Runs may include `metadata` on `run_started`.
133
133
  - **Correlation metadata (v1.3.0+):** optional `correlationId`, `requestId`, `decisionId`, and `groupId` on `run_started.metadata` when passed via `inspectRun` / `maybeInspectRun` options. Event names remain unchanged (`run_started`, `step_started`, `step_completed`, `run_completed`). `stats --correlation-id` and `--group-id` filter by these fields; `list` / `view` do not filter by correlation yet.
134
+ - **Session and workflow metadata (v2.4.0+, additive):** optional fields for multi-run causality — see [SESSIONS-AND-WORKFLOW-CAUSALITY.md](./proposals/SESSIONS-AND-WORKFLOW-CAUSALITY.md). Recommended placement: `run_started.metadata` (manual v0.1) or persisted `attributes` (v0.2/v1.0). Common keys: `sessionId`, `conversationId`, `parentGroupId`, `attempt`, `retryOf`, `handoffFrom`, `handoffTo`, `subAgentId`, `subAgentName`, `jobId`, `queueName`, `workflowName`, `workflowStep`, `toolCallId`, `mcpToolCallId`, `linkedStepId`. All optional; missing keys mean unknown. Readers must not infer handoff/retry links from timestamps alone. Existing traces without these fields remain fully readable.
134
135
  - Steps may include `metadata` on `step_started`.
135
136
  - Manual traces intentionally avoid full prompt/output capture by default.
136
137
  - **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`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-inspect",
3
- "version": "2.3.0",
3
+ "version": "2.4.0",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "description": "Local-first execution-tree debugger for TypeScript AI agents",
@@ -178,7 +178,7 @@
178
178
  },
179
179
  "scripts": {
180
180
  "clean": "pnpm -r exec -- rm -rf dist",
181
- "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 && pnpm exec tsup --config tsup.redact.config.ts && pnpm exec tsup --config tsup.eval.config.ts",
181
+ "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 && pnpm exec tsup --config tsup.redact.config.ts && pnpm exec tsup --config tsup.eval.config.ts && pnpm exec tsup --config tsup.mcp.config.ts",
182
182
  "typecheck": "tsc --noEmit",
183
183
  "test": "vitest run",
184
184
  "test:watch": "vitest",