agent-inspect 0.1.2 → 1.0.1

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 ADDED
@@ -0,0 +1,99 @@
1
+ # Changelog
2
+
3
+ ## 1.0.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 575b093: docs: onboarding polish
8
+
9
+ ## Unreleased
10
+
11
+ ### Documentation
12
+
13
+ - Improved README onboarding for new users.
14
+ - Added comparison guide.
15
+ - Added log-to-tree quickstart.
16
+ - Added a quickstart demo example.
17
+ - Clarified docs organization between user-facing `docs/` and internal `docs-local/`.
18
+
19
+ ## 1.0.0
20
+
21
+ ### Stable local tracing
22
+
23
+ - Stable manual tracing entry points: `inspectRun`, `step`, `step.llm`, `step.tool`, `observe`
24
+ - v0.1 JSONL trace compatibility retained (schemaVersion `"0.1"`)
25
+
26
+ ### Local inspection CLI
27
+
28
+ - Stable CLI workflows: `list`, `view`, `clean`
29
+ - Safety-critical cleanup verifies traces before deletion
30
+
31
+ ### Structured logs and live tail
32
+
33
+ - Local log-to-tree parsing and live tail workflows (`logs`, `tail`) with confidence labeling
34
+ - Best-effort log4js parsing; JSON logs first-class; no unsafe object parsing
35
+
36
+ ### Optional LangChain adapter
37
+
38
+ - `@agent-inspect/langchain` optional adapter package (experimental surface)
39
+
40
+ ### Optional TUI
41
+
42
+ - `@agent-inspect/tui` optional Ink/React viewer (experimental programmatic surface)
43
+
44
+ ### Standards-aligned local export
45
+
46
+ - Markdown/HTML exports for sharing traces locally
47
+ - OpenInference-compatible JSON export (experimental; verify against backends)
48
+ - OTLP JSON export (experimental; JSON mapping only, no OTLP gRPC)
49
+
50
+ ### Diff and compare
51
+
52
+ - Local, read-only diff of two manual traces (`diff`)
53
+
54
+ ### Fixtures, recipes, and hardening (v0.9)
55
+
56
+ - Canonical fixtures under `fixtures/` plus validation scripts
57
+ - Runnable recipes under `examples/recipes/` with deterministic expected output markers
58
+ - Package smoke checks and adoption hardening tests
59
+
60
+ ### Documentation and stability
61
+
62
+ - Added/updated API/CLI/schema/getting-started docs for v1.0 stabilization
63
+ - Added stability and compatibility tests to prevent accidental surface breaks
64
+
65
+ ### Known limitations
66
+
67
+ - Local-first only; no SaaS/dashboard; no vendor sinks; no replay; no cost engine
68
+
69
+ ## Historical notes (v0.1–v0.9)
70
+
71
+ AgentInspect started as a minimal manual tracing MVP (v0.1) and evolved through:
72
+
73
+ - local inspection improvements (metadata, filtering, safety checks)
74
+ - structured log ingestion (JSON first-class, log4js best-effort)
75
+ - conservative tree building rules with confidence labels
76
+ - incremental live tail rendering
77
+ - standards-aligned local exports (experimental)
78
+ - run diff and compare
79
+ - fixtures, recipes, and hardening focused on adoption
80
+
81
+ For detailed intent and sequencing (planning docs), see:
82
+
83
+ - `docs-local/roadmap/VERSION-ROADMAP.md`
84
+ - `docs-local/strategy/PRODUCT-PRINCIPLES.md`
85
+
86
+ # agent-inspect
87
+
88
+ ## 0.1.2
89
+
90
+ ### Patch Changes
91
+
92
+ - 62afb94: fix CI/publish smoke + vitest config
93
+
94
+ ## 0.1.1
95
+
96
+ ### Patch Changes
97
+
98
+ - bd719ef: Prepare npm publishing (Trusted Publishing via GitHub Actions OIDC) and polish documentation.
99
+ - 76791b8: Improve README, release docs, and npm publishing guidance.
package/README.md CHANGED
@@ -1,24 +1,10 @@
1
1
  # agent-inspect
2
2
 
3
- agent-inspect is a local-first execution-tree debugger for TypeScript AI agents.
3
+ Local execution trees for TypeScript AI agents.
4
4
 
5
- ## Why
5
+ AgentInspect helps you debug multi-step AI workflows locally by turning manual steps, structured logs, and agent callbacks into readable execution trees.
6
6
 
7
- AI agents are multi-step. Console logs are flat.
8
-
9
- agent-inspect turns runs into structured execution trees with JSONL traces and CLI inspection.
10
-
11
- agent-inspect is designed for inner-loop debugging, not as a replacement for production observability platforms.
12
-
13
- ## What you get
14
-
15
- - Execution-tree tracing for TypeScript agent workflows
16
- - Nested `step()` support with parent-child relationships
17
- - `step.llm()` and `step.tool()` helpers for agent-aware traces
18
- - Local JSONL trace files
19
- - Real-time terminal output while the agent runs
20
- - CLI commands to inspect previous runs
21
- - No accounts, API keys, dashboards, or cloud ingestion
7
+ No account. No cloud upload. No dashboard required.
22
8
 
23
9
  ## Install
24
10
 
@@ -26,25 +12,140 @@ agent-inspect is designed for inner-loop debugging, not as a replacement for pro
26
12
  npm install agent-inspect
27
13
  ```
28
14
 
29
- ## See your first trace
15
+ ```bash
16
+ pnpm add agent-inspect
17
+ ```
18
+
19
+ ## 60-second quickstart
30
20
 
31
- Run a traced workflow, then inspect it with the CLI.
21
+ Create `demo.mjs`:
32
22
 
33
- ```ts
23
+ ```js
34
24
  import { inspectRun, step } from "agent-inspect";
35
25
 
36
- await inspectRun("hello-agent", async () => {
37
- const plan = await step("plan", async () => "search hotels");
38
- return step("finalize", async () => ({ plan, status: "done" }));
39
- });
26
+ const delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
27
+
28
+ await inspectRun(
29
+ "support-agent",
30
+ async () => {
31
+ const plan = await step("plan", async () => {
32
+ await delay(50);
33
+ return { query: "refund policy", intent: "support" };
34
+ });
35
+
36
+ const docs = await step.tool("search-docs", async () => {
37
+ await delay(75);
38
+ return ["Refunds are available within 30 days."];
39
+ });
40
+
41
+ return step.llm("answer", async () => {
42
+ await delay(100);
43
+ return `Based on ${docs.length} document(s), refunds are available within 30 days.`;
44
+ });
45
+ },
46
+ { traceDir: "./.agent-inspect" }
47
+ );
40
48
  ```
41
49
 
50
+ Run it, then inspect it:
51
+
42
52
  ```bash
43
- npx agent-inspect list
44
- npx agent-inspect view run_abc123
53
+ node demo.mjs
54
+ npx agent-inspect list --dir ./.agent-inspect
55
+ npx agent-inspect view <run-id> --dir ./.agent-inspect
56
+ npx agent-inspect view <run-id> --dir ./.agent-inspect --summary
57
+ ```
58
+
59
+ Simplified example output:
60
+
61
+ ```text
62
+ Run run_abc123 (support-agent)
63
+ ├─ ✔ plan (50ms)
64
+ ├─ ✔ tool:search-docs (75ms)
65
+ └─ ✔ llm:answer (100ms)
66
+
67
+ Summary:
68
+ Steps: 3 (0 error)
69
+ Duration: 225ms
70
+ ```
71
+
72
+ Want a runnable demo folder? See [examples/00-quickstart-demo](examples/00-quickstart-demo/README.md).
73
+
74
+ ## Why not just console.log?
75
+
76
+ Console logs are great for quick values, but they’re flat. AgentInspect gives you:
77
+
78
+ - run grouping and local trace files
79
+ - explicit step boundaries (including nesting)
80
+ - step types (`tool:*`, `llm:*`)
81
+ - status + duration summaries
82
+ - a CLI to list/view/export/diff runs
83
+ - log ingestion workflows (`logs`, `tail`) when you already have structured logs
84
+
85
+ ## Inspect existing structured logs
86
+
87
+ ```bash
88
+ npx agent-inspect logs ./agent.log \
89
+ --format json \
90
+ --run-id-key requestId \
91
+ --event-key event \
92
+ --timestamp-key timestamp
45
93
  ```
46
94
 
47
- Replace `run_abc123` with the run id printed by `agent-inspect list`.
95
+ See the log-to-tree guide: [docs/LOG-TO-TREE-QUICKSTART.md](docs/LOG-TO-TREE-QUICKSTART.md).
96
+
97
+ ## When to use AgentInspect
98
+
99
+ Use AgentInspect when:
100
+
101
+ - you are building TypeScript/Node.js AI agents
102
+ - you want local debugging before a hosted observability setup
103
+ - console logs are too flat for multi-step execution
104
+ - you want to inspect tool calls, LLM calls, failures, and durations locally
105
+ - you want a lightweight CLI workflow with no account and no cloud upload
106
+ - you want to compare two local runs
107
+ - you want to turn structured logs into readable execution trees
108
+
109
+ ## When not to use AgentInspect
110
+
111
+ Do not use AgentInspect as a replacement for:
112
+
113
+ - production monitoring or alerting
114
+ - hosted observability dashboards
115
+ - long-term trace storage
116
+ - eval dataset management
117
+ - prompt management
118
+ - cost analytics
119
+ - replay/fork execution
120
+ - vendor telemetry pipelines
121
+
122
+ AgentInspect can complement tools like LangSmith, Langfuse, Braintrust, Phoenix/OpenInference, OpenTelemetry, New Relic, Datadog, etc. It does not replace their production/eval/dashboard workflows.
123
+
124
+ ## Security and privacy posture
125
+
126
+ - local files only by default (no upload)
127
+ - no vendor sinks
128
+ - no API keys required
129
+ - small root dependency footprint
130
+ - traces can include **user-provided metadata**; review exports before sharing
131
+
132
+ See `SECURITY.md`.
133
+
134
+ ## Documentation
135
+
136
+ - **Getting started**: [docs/GETTING-STARTED.md](docs/GETTING-STARTED.md)
137
+ - **API**: [docs/API.md](docs/API.md)
138
+ - **CLI**: [docs/CLI.md](docs/CLI.md)
139
+ - **Schema**: [docs/SCHEMA.md](docs/SCHEMA.md)
140
+ - **Logs**: [docs/LOGS.md](docs/LOGS.md) and [docs/LOG-TO-TREE-QUICKSTART.md](docs/LOG-TO-TREE-QUICKSTART.md)
141
+ - **Exports**: [docs/EXPORTS.md](docs/EXPORTS.md)
142
+ - **Diff**: [docs/DIFF.md](docs/DIFF.md)
143
+ - **Adapters**: [docs/ADAPTERS.md](docs/ADAPTERS.md)
144
+ - **Compare with other tools**: [docs/COMPARE.md](docs/COMPARE.md)
145
+ - **Known issues**: [docs/KNOWN-ISSUES.md](docs/KNOWN-ISSUES.md)
146
+ - **Limitations**: [docs/LIMITATIONS.md](docs/LIMITATIONS.md)
147
+
148
+ Screenshots/GIFs are planned; see [docs/SCREENSHOTS.md](docs/SCREENSHOTS.md).
48
149
 
49
150
  ## Minimal API
50
151
 
@@ -217,6 +318,41 @@ await agent.run("How do I reset my password?");
217
318
 
218
319
  `observe()` wraps top-level `run`, `execute`, and `invoke` methods. For internal detail, add manual `step()` calls inside the agent.
219
320
 
321
+ ## LangChain adapter (experimental)
322
+
323
+ Install:
324
+
325
+ ```bash
326
+ pnpm add agent-inspect @agent-inspect/langchain @langchain/core
327
+ ```
328
+
329
+ `@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.
330
+
331
+ ```ts
332
+ import { AgentInspectCallback } from "@agent-inspect/langchain";
333
+
334
+ const callback = new AgentInspectCallback({
335
+ runName: "support-agent-eval",
336
+ capture: "metadata-only",
337
+ });
338
+
339
+ await agent.invoke(input, {
340
+ callbacks: [callback],
341
+ });
342
+
343
+ const events = callback.getEvents();
344
+ ```
345
+
346
+ Behavior:
347
+
348
+ - **Metadata-only** capture by default (model, tags, token usage when present, counts). **No** full prompt/output capture by default.
349
+ - **Preview** mode is opt-in (`capture: "preview"`) with truncation via `maxPreviewChars` (default `200`).
350
+ - **Parent** links use LangChain `parentRunId`, surfaced as `parentId` on `InspectEvent` with `confidence: "explicit"`.
351
+ - **No** cost calculation; token fields are informational only.
352
+ - Events are collected **in memory** only (`getEvents()` / `clear()`). **No trace-file persistence** for adapter events yet; they are **not** written into the manual JSONL trace format.
353
+
354
+ The LangChain adapter API remains **experimental** even though the core AgentInspect tracing API is stable in 1.0. See [examples/08-langchain-adapter](examples/08-langchain-adapter).
355
+
220
356
  ## CLI
221
357
 
222
358
  List recent runs:
@@ -225,12 +361,83 @@ List recent runs:
225
361
  npx agent-inspect list
226
362
  ```
227
363
 
364
+ Common filters:
365
+
366
+ ```bash
367
+ npx agent-inspect list --status success
368
+ npx agent-inspect list --status error
369
+ npx agent-inspect list --status running
370
+ npx agent-inspect list --status unknown
371
+ npx agent-inspect list --name hotel
372
+ npx agent-inspect list --since 24h
373
+ npx agent-inspect list --json
374
+ ```
375
+
228
376
  View a run:
229
377
 
230
378
  ```bash
231
379
  npx agent-inspect view run_abc123
232
380
  ```
233
381
 
382
+ Alternate view modes:
383
+
384
+ ```bash
385
+ npx agent-inspect view run_abc123 --summary
386
+ npx agent-inspect view run_abc123 --metadata
387
+ npx agent-inspect view run_abc123 --errors-only
388
+ npx agent-inspect view run_abc123 --json --summary
389
+ ```
390
+
391
+ Safely clean up old traces (recommended: start with `--dry-run`):
392
+
393
+ ```bash
394
+ npx agent-inspect clean --older-than 7d --dry-run
395
+ npx agent-inspect clean --older-than 7d
396
+ npx agent-inspect clean --keep 100 --dry-run
397
+ npx agent-inspect clean --keep 100 --yes
398
+ npx agent-inspect clean --dir ./traces --older-than 7d --dry-run
399
+ ```
400
+
401
+ Safety notes:
402
+
403
+ - `clean` **verifies each file** as an AgentInspect trace before deleting.
404
+ - Arbitrary JSONL files are **not deleted**.
405
+ - Malformed JSONL files are **not deleted**.
406
+ - Without `--dry-run`, `clean` requires confirmation unless `--yes` is provided.
407
+ - In non-interactive terminals, deletion requires `--yes`.
408
+
409
+ Inspect structured logs:
410
+
411
+ ```bash
412
+ npx agent-inspect logs ./agent.log --format json
413
+ npx agent-inspect logs ./agent.log --format log4js
414
+ npx agent-inspect logs ./agent.log --format auto
415
+ npx agent-inspect logs ./agent.log --config agent-inspect.logs.json
416
+ npx agent-inspect logs ./agent.log --json
417
+ npx agent-inspect logs ./agent.log --summary
418
+ npx agent-inspect logs ./agent.log --warnings all
419
+ ```
420
+
421
+ Log ingestion notes:
422
+
423
+ - JSON logs are first-class.
424
+ - log4js text logs are best-effort: only embedded **valid JSON payloads** are supported.
425
+ - JavaScript object-literal payloads are intentionally unsupported.
426
+ - No eval is used.
427
+ - Flat timeline is default (nesting only with explicit `parentId`).
428
+ - Confidence labels explain attribution.
429
+ - Redaction is applied to sensitive attributes (based on config).
430
+
431
+ Live tail structured logs:
432
+
433
+ ```bash
434
+ npx agent-inspect tail --file ./agent.log --format json
435
+ npx agent-inspect tail --file ./agent.log --format log4js --config agent-inspect.logs.json
436
+ npm run dev 2>&1 | npx agent-inspect tail --format log4js --config agent-inspect.logs.json
437
+ npx agent-inspect tail --file ./agent.log --format auto --once
438
+ npx agent-inspect tail --file ./agent.log --json --once
439
+ ```
440
+
234
441
  Use a custom trace directory:
235
442
 
236
443
  ```bash
@@ -240,6 +447,12 @@ npx agent-inspect view run_abc123 --dir ./traces
240
447
 
241
448
  By default, traces are stored under `~/.agent-inspect/runs`.
242
449
 
450
+ You can also set a default trace directory with:
451
+
452
+ ```bash
453
+ AGENT_INSPECT_TRACE_DIR=./traces npx agent-inspect list
454
+ ```
455
+
243
456
  For local repo development after `pnpm build`:
244
457
 
245
458
  ```bash
@@ -272,13 +485,16 @@ cat ~/.agent-inspect/runs/run_abc123.jsonl | jq
272
485
 
273
486
  ## Runnable examples
274
487
 
275
- The repo includes five runnable MVP examples:
488
+ The repo includes runnable examples for manual tracing, log-to-tree, and the optional LangChain adapter:
276
489
 
490
+ - `examples/00-quickstart-demo` — minimal install-and-try demo
277
491
  - `examples/01-basic` — `inspectRun()` + `step()`
278
492
  - `examples/02-nested-steps` — nested execution tree hierarchy
279
493
  - `examples/03-parallel-steps` — `Promise.all` sibling isolation
280
494
  - `examples/04-error-handling` — failed steps and error traces
281
495
  - `examples/05-observe-wrapper` — `observe()` wrapper with internal steps
496
+ - `examples/06-log-to-tree` — structured log-to-tree example (`agent-inspect logs`, `tail`)
497
+ - `examples/08-langchain-adapter` — optional LangChain callback adapter (`@agent-inspect/langchain`), provider-free simulated lifecycle (install from repo root; see example README)
282
498
 
283
499
  Run one locally:
284
500
 
@@ -302,26 +518,20 @@ Supporting material:
302
518
 
303
519
  - [examples/README.md](examples/README.md)
304
520
 
305
- ## MVP scope
306
-
307
- Included:
308
-
309
- - `inspectRun()`
310
- - `step()`
311
- - `step.llm()`
312
- - `step.tool()`
313
- - `observe()`
314
- - JSONL traces
315
- - CLI `list` and `view`
316
-
317
521
  Not included:
318
522
 
319
- - Framework adapters
320
- - Token or cost tracking
321
- - Replay
523
+ - Live TUI / streaming trace updates in the TUI
524
+ - Direct vendor sinks or uploads (Phoenix, Langfuse, Braintrust, New Relic, Datadog, …)
525
+ - Live OTLP streaming / OTLP gRPC
526
+ - Production monitoring platforms
527
+ - Additional framework adapters beyond LangChain
528
+ - Token cost calculation
529
+ - Replay / fork execution
322
530
  - SQLite
323
531
  - Dashboards
324
- - OpenTelemetry
532
+ - Multi-run statistical eval dashboards
533
+ - Semantic / LLM-powered trace comparison
534
+ - OpenTelemetry SDK instrumentation (exports are generated strings only)
325
535
 
326
536
  ## Development
327
537
 
package/SECURITY.md ADDED
@@ -0,0 +1,77 @@
1
+ # Security policy
2
+
3
+ AgentInspect is a **local-first** debugging tool. It does **not** upload your traces or logs anywhere, and it does not include vendor sink integrations in the core package.
4
+
5
+ This document describes how to report vulnerabilities and how to think about data safety when using AgentInspect.
6
+
7
+ ## Supported status
8
+
9
+ AgentInspect is in active development. Security fixes are accepted and prioritized based on impact and exploitability.
10
+
11
+ There is **no formal SLA**. If a fix is needed, it should land as a patch release once verified.
12
+
13
+ ## Reporting vulnerabilities
14
+
15
+ - If **GitHub Security Advisories** are enabled for this repository, please report via a private advisory.
16
+ - Otherwise, open a GitHub issue with **minimal sensitive detail** and request a private contact path for the full report.
17
+
18
+ ### What to include in a report
19
+
20
+ - A clear description of the issue and expected impact
21
+ - Steps to reproduce (prefer a small repro repo or minimized snippet)
22
+ - Affected package(s) and version(s)
23
+ - Platform info (Node version, OS)
24
+ - Any mitigations/workarounds you found
25
+
26
+ ### Please do not include
27
+
28
+ - real API keys or tokens
29
+ - production log files
30
+ - customer/user PII
31
+ - full unredacted traces
32
+
33
+ If you need to include sample data, use synthetic placeholders (for example, `example.test` emails and fake tokens).
34
+
35
+ ## Scope
36
+
37
+ In scope:
38
+
39
+ - vulnerabilities in trace/log parsing that could lead to code execution, path traversal, or data disclosure
40
+ - unsafe redaction defaults (obvious secrets displayed where the product promises safety)
41
+ - package supply-chain / dependency boundary issues that cause heavy or unsafe dependencies to be pulled into the main `agent-inspect` install
42
+
43
+ ## Out of scope
44
+
45
+ - production monitoring SLAs or uptime guarantees (AgentInspect is not a production observability platform)
46
+ - vendor sink behavior (not implemented in core)
47
+ - network upload security (AgentInspect does not upload)
48
+ - replay sandboxing (replay is not implemented)
49
+ - cost calculation correctness (cost engine is not implemented)
50
+
51
+ ## Data handling model (local-first)
52
+
53
+ - Manual tracing writes local JSONL files (see `docs/SCHEMA.md`).
54
+ - The CLI reads and renders local files.
55
+ - Exports generate local strings/files only (Markdown/HTML/OpenInference/OTLP JSON); they do not upload anywhere.
56
+
57
+ ## Redaction expectations
58
+
59
+ AgentInspect aims to be safe-by-default for **log-derived attributes** and **exported payloads**:
60
+
61
+ - Log ingestion applies redaction to parsed attributes using configured rules (with conservative defaults).
62
+ - Exporters default to redacted output and bounded attribute previews.
63
+
64
+ Important limitations:
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.
67
+ - Always **review exported files** before sharing them externally.
68
+ - Avoid committing trace directories (`.agent-inspect-runs/`) to source control.
69
+
70
+ For redaction design details, see `docs-local/architecture/REDACTION.md`.
71
+
72
+ ## Dependency and security review process
73
+
74
+ - Prefer Node.js built-ins over new dependencies.
75
+ - Do not add vendor SDKs, OpenTelemetry SDKs, or framework dependencies to the main `agent-inspect` package.
76
+ - Keep optional integrations (`@agent-inspect/langchain`, `@agent-inspect/tui`) separate so users do not pull them in by default.
77
+
@@ -0,0 +1,15 @@
1
+ ## Adapters
2
+
3
+ AgentInspect is framework-agnostic at its core, but can optionally integrate with frameworks via adapter packages.
4
+
5
+ - **LangChain.js adapter** (optional): `@agent-inspect/langchain`
6
+ - Documented as **experimental** in `docs/API.md`
7
+ - Requires `@langchain/core` as a peer dependency
8
+ - **Interactive TUI** (optional): `@agent-inspect/tui`
9
+ - Documented as **experimental** in `docs/API.md`
10
+ - Intended for CLI integration; programmatic TUI APIs may change
11
+
12
+ See also:
13
+ - `docs/MIGRATION.md` (what changed from early versions)
14
+ - `docs-local/RELEASE-CHECKLIST.md` (maintainer-only release steps)
15
+