agent-inspect 0.1.1 → 1.0.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/README.md CHANGED
@@ -26,6 +26,20 @@ agent-inspect is designed for inner-loop debugging, not as a replacement for pro
26
26
  npm install agent-inspect
27
27
  ```
28
28
 
29
+ ## Documentation (v1.0 stabilization)
30
+
31
+ - [Getting started](docs/GETTING-STARTED.md)
32
+ - [API reference](docs/API.md)
33
+ - [CLI reference](docs/CLI.md)
34
+ - [Schema reference](docs/SCHEMA.md)
35
+ - [Security policy](SECURITY.md)
36
+ - [Migration guide](docs/MIGRATION.md)
37
+ - [Release checklist](docs/RELEASE-CHECKLIST.md)
38
+ - [Changelog](CHANGELOG.md)
39
+ - [Known issues](docs/KNOWN-ISSUES.md)
40
+ - [Limitations](docs/LIMITATIONS.md)
41
+ - [V1 readiness checklist (non-binding)](docs/V1-READINESS-CHECKLIST.md)
42
+
29
43
  ## See your first trace
30
44
 
31
45
  Run a traced workflow, then inspect it with the CLI.
@@ -46,6 +60,53 @@ npx agent-inspect view run_abc123
46
60
 
47
61
  Replace `run_abc123` with the run id printed by `agent-inspect list`.
48
62
 
63
+ ### Optional TUI viewer
64
+
65
+ The core `agent-inspect` package stays lightweight and does not bundle Ink or React. For a keyboard-driven terminal UI over existing traces, install the optional package:
66
+
67
+ ```bash
68
+ pnpm add agent-inspect @agent-inspect/tui
69
+
70
+ npx agent-inspect view run_abc123 --tui
71
+ ```
72
+
73
+ The plain CLI remains the default. `--tui` requires an interactive terminal; for scripts or CI, use `agent-inspect view` or `agent-inspect view --json`. There is no live tail TUI yet.
74
+
75
+ ### Export traces
76
+
77
+ Export existing manual JSONL traces locally — **no upload**, **no vendor SDKs**. Markdown is handy for PRs and issues; HTML is a single offline file. OpenInference export is **OpenInference-compatible JSON** (not a guarantee for every backend). OTLP JSON uses **OTel GenAI-aligned attributes** where applicable and is **experimental** until validated against a specific collector.
78
+
79
+ ```bash
80
+ npx agent-inspect export run_abc123 --format markdown
81
+ npx agent-inspect export run_abc123 --format html -o run.html
82
+ npx agent-inspect export run_abc123 --format openinference -o trace.openinference.json
83
+ npx agent-inspect export run_abc123 --format otlp-json -o trace.otlp.json
84
+ npx agent-inspect export run_abc123 --format openinference --validate
85
+ ```
86
+
87
+ Review exported files for sensitive data before sharing. Attribute payloads are bounded and redacted by default; use `--include-attributes` only when you intend to share richer detail.
88
+
89
+ ### Compare runs
90
+
91
+ Diff is **local** and **read-only**: it compares two existing AgentInspect JSONL traces and does **not** rerun agents, mutate trace files, or write output traces. It does **not** claim semantic equivalence and does **not** call an LLM.
92
+
93
+ Finding differences does **not** change the exit code by default (exit code `1` is reserved for command errors such as a missing run).
94
+
95
+ ```bash
96
+ npx agent-inspect diff run_a run_b
97
+ npx agent-inspect diff run_a run_b --json
98
+ npx agent-inspect diff run_a run_b --ignore-duration
99
+ npx agent-inspect diff run_a run_b --duration-threshold 500ms
100
+ npx agent-inspect diff run_a run_b --focus errors
101
+ npx agent-inspect diff run_a run_b --check structure
102
+ ```
103
+
104
+ Useful for comparing passing vs failing runs and spotting the **first divergence** in execution order.
105
+
106
+ ### Fixtures and hardening (v0.9)
107
+
108
+ **v0.9** adds canonical [**fixtures/**](fixtures/README.md), validation (`pnpm fixtures:check`), **recipe examples** under [**examples/recipes/**](examples/recipes/README.md) (`pnpm recipes:check`), and docs aimed at adoption—not new tracing features. Recipes use mocks only and require no API keys or external services by default. Good starting points: **rag-pipeline**, **tool-failure-retry**, **proactive-agent-logs**. See [**Known issues**](docs/KNOWN-ISSUES.md), [**Limitations**](docs/LIMITATIONS.md), and the non-binding [**v1 readiness checklist**](docs/V1-READINESS-CHECKLIST.md).
109
+
49
110
  ## Minimal API
50
111
 
51
112
  ```ts
@@ -217,6 +278,41 @@ await agent.run("How do I reset my password?");
217
278
 
218
279
  `observe()` wraps top-level `run`, `execute`, and `invoke` methods. For internal detail, add manual `step()` calls inside the agent.
219
280
 
281
+ ## LangChain adapter (v0.5, experimental)
282
+
283
+ Install:
284
+
285
+ ```bash
286
+ pnpm add agent-inspect @agent-inspect/langchain @langchain/core
287
+ ```
288
+
289
+ `@langchain/core` is a **peer dependency** of `@agent-inspect/langchain`. The adapter uses official LangChain.js **callbacks** only (extends `BaseCallbackHandler`): **no** monkey-patching, **no** `agent-inspect/auto`, **no** vendor observability sinks.
290
+
291
+ ```ts
292
+ import { AgentInspectCallback } from "@agent-inspect/langchain";
293
+
294
+ const callback = new AgentInspectCallback({
295
+ runName: "support-agent-eval",
296
+ capture: "metadata-only",
297
+ });
298
+
299
+ await agent.invoke(input, {
300
+ callbacks: [callback],
301
+ });
302
+
303
+ const events = callback.getEvents();
304
+ ```
305
+
306
+ Behavior:
307
+
308
+ - **Metadata-only** capture by default (model, tags, token usage when present, counts). **No** full prompt/output capture by default.
309
+ - **Preview** mode is opt-in (`capture: "preview"`) with truncation via `maxPreviewChars` (default `200`).
310
+ - **Parent** links use LangChain `parentRunId`, surfaced as `parentId` on `InspectEvent` with `confidence: "explicit"`.
311
+ - **No** cost calculation; token fields are informational only.
312
+ - In this pass, events are collected **in memory** only (`getEvents()` / `clear()`). **No trace-file persistence** for adapter events yet; they are **not** written into v0.1 JSONL manual traces.
313
+
314
+ The API is **experimental** before v1.0. See [examples/08-langchain-adapter](examples/08-langchain-adapter).
315
+
220
316
  ## CLI
221
317
 
222
318
  List recent runs:
@@ -225,12 +321,83 @@ List recent runs:
225
321
  npx agent-inspect list
226
322
  ```
227
323
 
324
+ Common filters:
325
+
326
+ ```bash
327
+ npx agent-inspect list --status success
328
+ npx agent-inspect list --status error
329
+ npx agent-inspect list --status running
330
+ npx agent-inspect list --status unknown
331
+ npx agent-inspect list --name hotel
332
+ npx agent-inspect list --since 24h
333
+ npx agent-inspect list --json
334
+ ```
335
+
228
336
  View a run:
229
337
 
230
338
  ```bash
231
339
  npx agent-inspect view run_abc123
232
340
  ```
233
341
 
342
+ Alternate view modes:
343
+
344
+ ```bash
345
+ npx agent-inspect view run_abc123 --summary
346
+ npx agent-inspect view run_abc123 --metadata
347
+ npx agent-inspect view run_abc123 --errors-only
348
+ npx agent-inspect view run_abc123 --json --summary
349
+ ```
350
+
351
+ Safely clean up old traces (recommended: start with `--dry-run`):
352
+
353
+ ```bash
354
+ npx agent-inspect clean --older-than 7d --dry-run
355
+ npx agent-inspect clean --older-than 7d
356
+ npx agent-inspect clean --keep 100 --dry-run
357
+ npx agent-inspect clean --keep 100 --yes
358
+ npx agent-inspect clean --dir ./traces --older-than 7d --dry-run
359
+ ```
360
+
361
+ Safety notes:
362
+
363
+ - `clean` **verifies each file** as an AgentInspect trace before deleting.
364
+ - Arbitrary JSONL files are **not deleted**.
365
+ - Malformed JSONL files are **not deleted**.
366
+ - Without `--dry-run`, `clean` requires confirmation unless `--yes` is provided.
367
+ - In non-interactive terminals, deletion requires `--yes`.
368
+
369
+ Inspect structured logs:
370
+
371
+ ```bash
372
+ npx agent-inspect logs ./agent.log --format json
373
+ npx agent-inspect logs ./agent.log --format log4js
374
+ npx agent-inspect logs ./agent.log --format auto
375
+ npx agent-inspect logs ./agent.log --config agent-inspect.logs.json
376
+ npx agent-inspect logs ./agent.log --json
377
+ npx agent-inspect logs ./agent.log --summary
378
+ npx agent-inspect logs ./agent.log --warnings all
379
+ ```
380
+
381
+ Log ingestion notes:
382
+
383
+ - JSON logs are first-class.
384
+ - log4js text logs are best-effort: only embedded **valid JSON payloads** are supported.
385
+ - JavaScript object-literal payloads are intentionally unsupported.
386
+ - No eval is used.
387
+ - Flat timeline is default (nesting only with explicit `parentId`).
388
+ - Confidence labels explain attribution.
389
+ - Redaction is applied to sensitive attributes (based on config).
390
+
391
+ Live tail structured logs:
392
+
393
+ ```bash
394
+ npx agent-inspect tail --file ./agent.log --format json
395
+ npx agent-inspect tail --file ./agent.log --format log4js --config agent-inspect.logs.json
396
+ npm run dev 2>&1 | npx agent-inspect tail --format log4js --config agent-inspect.logs.json
397
+ npx agent-inspect tail --file ./agent.log --format auto --once
398
+ npx agent-inspect tail --file ./agent.log --json --once
399
+ ```
400
+
234
401
  Use a custom trace directory:
235
402
 
236
403
  ```bash
@@ -240,6 +407,12 @@ npx agent-inspect view run_abc123 --dir ./traces
240
407
 
241
408
  By default, traces are stored under `~/.agent-inspect/runs`.
242
409
 
410
+ You can also set a default trace directory with:
411
+
412
+ ```bash
413
+ AGENT_INSPECT_TRACE_DIR=./traces npx agent-inspect list
414
+ ```
415
+
243
416
  For local repo development after `pnpm build`:
244
417
 
245
418
  ```bash
@@ -272,13 +445,15 @@ cat ~/.agent-inspect/runs/run_abc123.jsonl | jq
272
445
 
273
446
  ## Runnable examples
274
447
 
275
- The repo includes five runnable MVP examples:
448
+ The repo includes five runnable MVP manual-tracing examples, the v0.3 structured log-to-tree example, and the v0.5 LangChain adapter example:
276
449
 
277
450
  - `examples/01-basic` — `inspectRun()` + `step()`
278
451
  - `examples/02-nested-steps` — nested execution tree hierarchy
279
452
  - `examples/03-parallel-steps` — `Promise.all` sibling isolation
280
453
  - `examples/04-error-handling` — failed steps and error traces
281
454
  - `examples/05-observe-wrapper` — `observe()` wrapper with internal steps
455
+ - `examples/06-log-to-tree` — v0.3 structured log-to-tree example (includes historical spike prototype and production `agent-inspect logs` usage)
456
+ - `examples/08-langchain-adapter` — v0.5 LangChain callback adapter (`@agent-inspect/langchain`), provider-free simulated lifecycle (install from repo root; see example README)
282
457
 
283
458
  Run one locally:
284
459
 
@@ -302,7 +477,7 @@ Supporting material:
302
477
 
303
478
  - [examples/README.md](examples/README.md)
304
479
 
305
- ## MVP scope
480
+ ## Original MVP scope
306
481
 
307
482
  Included:
308
483
 
@@ -314,14 +489,31 @@ Included:
314
489
  - JSONL traces
315
490
  - CLI `list` and `view`
316
491
 
492
+ Current scope also includes:
493
+
494
+ - CLI `clean` (safe deletion with verification)
495
+ - CLI `logs` (structured log-to-tree)
496
+ - CLI `tail` (live log tailing into grouped timelines)
497
+ - LangChain callback adapter via `@agent-inspect/langchain`
498
+ - Optional TUI viewer via `@agent-inspect/tui`
499
+ - Standards-aligned **local** exports (`export`: Markdown, HTML, OpenInference-compatible JSON, OTLP JSON mapping)
500
+ - Run diff / compare (`diff`: two local traces, read-only)
501
+ - Canonical **fixtures** under [`fixtures/`](fixtures/README.md) plus `pnpm fixtures:check` for deterministic samples
502
+
317
503
  Not included:
318
504
 
319
- - Framework adapters
320
- - Token or cost tracking
321
- - Replay
505
+ - Live TUI / streaming trace updates in the TUI
506
+ - Direct vendor sinks or uploads (Phoenix, Langfuse, Braintrust, New Relic, Datadog, …)
507
+ - Live OTLP streaming / OTLP gRPC
508
+ - Production monitoring platforms
509
+ - Additional framework adapters beyond LangChain
510
+ - Token cost calculation
511
+ - Replay / fork execution
322
512
  - SQLite
323
513
  - Dashboards
324
- - OpenTelemetry
514
+ - Multi-run statistical eval dashboards
515
+ - Semantic / LLM-powered trace comparison
516
+ - OpenTelemetry SDK instrumentation (exports are generated strings only)
325
517
 
326
518
  ## Development
327
519
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-inspect",
3
- "version": "0.1.1",
3
+ "version": "1.0.0",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "description": "Local-first execution-tree debugger for TypeScript AI agents",
@@ -62,16 +62,19 @@
62
62
  },
63
63
  "scripts": {
64
64
  "clean": "pnpm -r exec -- rm -rf dist",
65
- "build": "pnpm exec tsup --config tsup.core.config.ts && pnpm exec tsup --config tsup.cli.config.ts",
65
+ "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",
66
66
  "typecheck": "tsc --noEmit",
67
67
  "test": "vitest run",
68
68
  "test:watch": "vitest",
69
69
  "test:coverage": "vitest run --coverage",
70
70
  "size": "size-limit --config size-limit.config.mjs",
71
71
  "test:all": "pnpm run typecheck && pnpm run test && pnpm run build && pnpm run size",
72
- "prepublish:checks": "pnpm run typecheck && pnpm run test && pnpm run build && pnpm run size && pnpm run pack:smoke",
72
+ "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",
73
73
  "pack:dry-run": "pnpm run build && npm pack --dry-run",
74
74
  "pack:smoke": "pnpm run build && node scripts/package-smoke.mjs",
75
+ "fixtures:check": "node scripts/validate-fixtures.mjs",
76
+ "recipes:check": "node scripts/validate-recipes.mjs",
77
+ "perf:baseline": "node scripts/performance-baseline.mjs",
75
78
  "examples:check": "pnpm install && pnpm --filter agent-inspect-example-01-basic run start",
76
79
  "changeset": "changeset",
77
80
  "release": "changeset publish"