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.
@@ -0,0 +1,54 @@
1
+ ## Log-to-tree quickstart
2
+
3
+ AgentInspect can inspect **structured logs** and render a local execution tree without requiring you to wrap every function in manual tracing.
4
+
5
+ ## Example JSON log lines
6
+
7
+ `agent.log` (JSONL):
8
+
9
+ ```json
10
+ {"timestamp":"2026-05-08T10:00:00.000Z","requestId":"req_123","event":"agent.started","message":"Agent started"}
11
+ {"timestamp":"2026-05-08T10:00:00.150Z","requestId":"req_123","event":"tool.search.started","tool":"searchDocs"}
12
+ {"timestamp":"2026-05-08T10:00:00.420Z","requestId":"req_123","event":"tool.search.completed","tool":"searchDocs","durationMs":270}
13
+ {"timestamp":"2026-05-08T10:00:00.500Z","requestId":"req_123","event":"llm.answer.started","model":"gpt-example"}
14
+ {"timestamp":"2026-05-08T10:00:01.100Z","requestId":"req_123","event":"llm.answer.completed","model":"gpt-example","durationMs":600}
15
+ {"timestamp":"2026-05-08T10:00:01.150Z","requestId":"req_123","event":"agent.completed","status":"ok"}
16
+ ```
17
+
18
+ ## Parse logs into trees
19
+
20
+ ```bash
21
+ npx agent-inspect logs ./agent.log \
22
+ --format json \
23
+ --run-id-key requestId \
24
+ --event-key event \
25
+ --timestamp-key timestamp
26
+ ```
27
+
28
+ Example output:
29
+
30
+ ```text
31
+ Run req_123
32
+ ├─ agent.started
33
+ ├─ tool.search.started
34
+ ├─ tool.search.completed (270ms)
35
+ ├─ llm.answer.started
36
+ ├─ llm.answer.completed (600ms)
37
+ └─ agent.completed (ok)
38
+ ```
39
+
40
+ ## Important notes
41
+
42
+ - **JSON logs are first-class**. (Line-delimited JSON is the recommended input.)
43
+ - **log4js text logs with embedded JSON are best-effort**.
44
+ - AgentInspect does **not** evaluate JavaScript object strings (`eval` is not used).
45
+ - **Flat timeline is the default** for log-derived events.
46
+ - Nesting is conservative: **explicit parent/config wins**, and inferred relationships are labeled.
47
+ - **Confidence labels** explain how relationships were inferred (`explicit`, `correlated`, `heuristic`, `unknown`).
48
+ - **Redaction** is applied where configured/defaulted for log-derived attributes and exports.
49
+
50
+ See also:
51
+ - `docs/CLI.md` (`logs`, `tail`)
52
+ - `docs/LOGS.md`
53
+ - `docs/SCHEMA.md` (log ingest config types + confidence)
54
+
package/docs/LOGS.md ADDED
@@ -0,0 +1,13 @@
1
+ ## Logs (structured log → tree)
2
+
3
+ AgentInspect can parse **existing logs** (line-delimited JSON, and best-effort log4js-style text with embedded JSON) into a local execution tree / grouped timeline.
4
+
5
+ - **CLI usage**: `docs/CLI.md` (`logs`, `tail`)
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`
9
+
10
+ Notes:
11
+ - Log parsing APIs are documented as **experimental** in `docs/API.md`.
12
+ - Log-derived events include **confidence labels**; AgentInspect is conservative about inferring parent/child structure.
13
+
@@ -0,0 +1,109 @@
1
+ # Migration guide (to AgentInspect 1.0)
2
+
3
+ This guide summarizes how to move from early AgentInspect MVP usage to **AgentInspect 1.0**.
4
+
5
+ AgentInspect remains local-first: it does not introduce any network upload or vendor sink workflows.
6
+
7
+ ## Scope
8
+
9
+ Covered:
10
+
11
+ - manual tracing (`inspectRun`, `step`, `observe`)
12
+ - trace directory behavior
13
+ - CLI commands (`list`, `view`, `clean`, `logs`, `tail`, `export`, `diff`)
14
+ - optional packages (`@agent-inspect/langchain`, `@agent-inspect/tui`)
15
+ - schema compatibility guarantees
16
+
17
+ Not covered:
18
+
19
+ - publish/version bump workflows (see `docs-local/RELEASE-CHECKLIST.md`)
20
+ - vendor sinks (not implemented)
21
+ - replay (not implemented)
22
+ - cost engine (not implemented)
23
+
24
+ ## Manual tracing API
25
+
26
+ If you were using:
27
+
28
+ ```ts
29
+ import { inspectRun, step } from "agent-inspect";
30
+ ```
31
+
32
+ that remains the recommended stable path. AgentInspect 1.0 is specifically about keeping these entry points compatible.
33
+
34
+ ### Event names and failure representation
35
+
36
+ Manual JSONL event names remain stable:
37
+
38
+ - `run_started`
39
+ - `run_completed`
40
+ - `step_started`
41
+ - `step_completed`
42
+
43
+ There is **no `step_failed` event**. Step failures are represented as:
44
+
45
+ - `step_completed` with `status: "error"`
46
+
47
+ Existing `schemaVersion: "0.1"` traces remain readable. No migration command is required.
48
+
49
+ ## Trace directory behavior
50
+
51
+ - `AGENT_INSPECT_TRACE_DIR` is supported.
52
+ - When unset, AgentInspect uses its default local directory (see `docs/CLI.md` and `docs/API.md`).
53
+ - Trace files are JSONL and are not automatically rewritten.
54
+
55
+ ## CLI changes and additive commands
56
+
57
+ Manual inspection commands (`list`, `view`) are stable and local-only.
58
+
59
+ The following commands are additive workflows that remain local-only:
60
+
61
+ - `logs`: parse structured logs into normalized trees
62
+ - `tail`: live-tail structured logs in the terminal
63
+ - `export`: export a manual trace as Markdown/HTML/OpenInference-compatible JSON/OTLP JSON (local-only)
64
+ - `diff`: compare two manual traces (local, read-only)
65
+
66
+ ### `clean` is safety-critical
67
+
68
+ `clean` verifies traces before deletion using conservative heuristics. If a file cannot be verified as an AgentInspect trace, it is skipped.
69
+
70
+ ## Logs and tail
71
+
72
+ - JSON logs are first-class.
73
+ - log4js parsing is best-effort.
74
+ - No JS object literal parsing or `eval`.
75
+ - Redaction is applied to log-derived attributes based on config/default rules.
76
+
77
+ ## Export and share safety
78
+
79
+ - Exports are **generated locally** and do not upload anywhere.
80
+ - Exporters default to **redacted** and **bounded** attribute previews.
81
+ - Always review exports before sharing.
82
+
83
+ ## Diff and compare
84
+
85
+ - Diff compares two existing local traces.
86
+ - Diff does not rerun agents, mutate trace files, or call an LLM.
87
+
88
+ ## Optional LangChain adapter
89
+
90
+ `@agent-inspect/langchain` is optional and separate from core. It uses `@langchain/core` as a **peer dependency**.
91
+
92
+ ## Optional TUI
93
+
94
+ `@agent-inspect/tui` is optional and separate from core. It contains `ink`/`react` dependencies so the main `agent-inspect` install remains lean.
95
+
96
+ ## Breaking changes
97
+
98
+ This stabilization effort aims to avoid breaking changes. If a breaking change is ever required:
99
+
100
+ - it requires a major version
101
+ - it must preserve trace readability where possible
102
+ - it must be explicitly documented
103
+
104
+ ## Known non-migrations
105
+
106
+ - No vendor sink migration exists because there are **no vendor sinks** in core.
107
+ - No replay migration exists because replay is **not implemented**.
108
+ - No cost engine migration exists because cost calculation is **not implemented**.
109
+
package/docs/SCHEMA.md ADDED
@@ -0,0 +1,199 @@
1
+ # Schema (AgentInspect 1.0)
2
+
3
+ This document describes the **persisted manual trace JSONL schema** and the **log-derived normalized model** used by AgentInspect.
4
+
5
+ ## 1. Overview
6
+
7
+ AgentInspect has two related (but distinct) data models:
8
+
9
+ 1. **Manual trace JSONL** (persisted): lines of `TraceEvent` written by `inspectRun()` / `step()`.
10
+ 2. **Log-derived normalized model** (in-memory): `InspectEvent` / `InspectRunTree` built from structured logs or adapters.
11
+
12
+ Important: log-derived trees are **normalized views**, not the same persisted JSONL schema.
13
+
14
+ ## 2. Manual trace JSONL schema
15
+
16
+ ### 2.1 File format
17
+
18
+ - One JSON object per line (JSONL)
19
+ - Lines may be skipped if invalid JSON or invalid event shape
20
+ - AgentInspect does **not** automatically rewrite old trace files
21
+
22
+ ### 2.2 Current schemaVersion
23
+
24
+ Manual trace events use:
25
+
26
+ - **`schemaVersion: "0.1"`**
27
+
28
+ Existing `0.1` traces remain readable in v1.0.
29
+
30
+ ### 2.3 TraceEvent union
31
+
32
+ The stable event names are:
33
+
34
+ - `run_started`
35
+ - `run_completed`
36
+ - `step_started`
37
+ - `step_completed`
38
+
39
+ There is **no** `step_failed` event. Failures are represented by `step_completed` with `status: "error"`.
40
+
41
+ ### 2.4 Common fields
42
+
43
+ Every trace line contains:
44
+
45
+ - `schemaVersion: "0.1"`
46
+ - `event: string`
47
+ - `timestamp: number` (ms since epoch)
48
+
49
+ ## 3. Event definitions
50
+
51
+ ### 3.1 `run_started`
52
+
53
+ ```ts
54
+ {
55
+ schemaVersion: "0.1",
56
+ event: "run_started",
57
+ timestamp: number,
58
+ runId: string,
59
+ name: string,
60
+ startTime: number,
61
+ metadata?: Record<string, unknown>
62
+ }
63
+ ```
64
+
65
+ ### 3.2 `run_completed`
66
+
67
+ ```ts
68
+ {
69
+ schemaVersion: "0.1",
70
+ event: "run_completed",
71
+ timestamp: number,
72
+ runId: string,
73
+ status: "success" | "error",
74
+ endTime: number,
75
+ durationMs: number,
76
+ error?: { message: string, stack?: string }
77
+ }
78
+ ```
79
+
80
+ ### 3.3 `step_started`
81
+
82
+ ```ts
83
+ {
84
+ schemaVersion: "0.1",
85
+ event: "step_started",
86
+ timestamp: number,
87
+ runId: string,
88
+ stepId: string,
89
+ parentId?: string,
90
+ name: string,
91
+ type: "run" | "llm" | "tool" | "decision" | "logic" | "state" | "custom",
92
+ startTime: number,
93
+ metadata?: Record<string, unknown>
94
+ }
95
+ ```
96
+
97
+ ### 3.4 `step_completed`
98
+
99
+ ```ts
100
+ {
101
+ schemaVersion: "0.1",
102
+ event: "step_completed",
103
+ timestamp: number,
104
+ runId: string,
105
+ stepId: string,
106
+ status: "success" | "error",
107
+ endTime: number,
108
+ durationMs: number,
109
+ error?: { message: string, stack?: string }
110
+ }
111
+ ```
112
+
113
+ ## 4. Error representation
114
+
115
+ - Errors are structured as `{ message, stack? }`.
116
+ - AgentInspect prints short human errors by default; verbose modes may include stack strings.
117
+
118
+ ## 5. Status representation
119
+
120
+ Manual trace statuses:
121
+
122
+ - Run: `status: "success" | "error"` on `run_completed`
123
+ - Step: `status: "success" | "error"` on `step_completed`
124
+
125
+ There is no `"unknown"` status in the persisted manual trace event itself; `"unknown"` can appear in **derived metadata** when status cannot be determined safely.
126
+
127
+ Unknown status must **not** be treated as success.
128
+
129
+ ## 6. Metadata policy
130
+
131
+ - Runs may include `metadata` on `run_started`.
132
+ - Steps may include `metadata` on `step_started`.
133
+ - Manual traces intentionally avoid full prompt/output capture by default.
134
+
135
+ ## 7. Additive fields and unknown fields
136
+
137
+ - Additive changes are allowed in minor versions.
138
+ - Readers should ignore unknown fields where safe.
139
+ - Breaking schema changes require a major version.
140
+
141
+ ## 8. Malformed lines
142
+
143
+ Manual trace reading:
144
+
145
+ - invalid JSON lines are skipped
146
+ - JSON objects that fail strict `TraceEvent` validation are skipped
147
+
148
+ ## 9. Backward compatibility
149
+
150
+ - v0.1 JSONL traces remain readable in v1.0.
151
+ - No automatic migrations or rewriting of old files.
152
+
153
+ ## 10. Breaking change policy
154
+
155
+ - Breaking changes require a major version.
156
+ - Stable v1.x policy: avoid removing stable fields/events; prefer additive extensions.
157
+
158
+ ## 11. Log-derived InspectEvent model
159
+
160
+ Log-derived events normalize into:
161
+
162
+ ```ts
163
+ interface InspectEvent {
164
+ eventId: string;
165
+ runId: string;
166
+ parentId?: string;
167
+ name: string;
168
+ kind: "RUN" | "AGENT" | "LLM" | "TOOL" | "CHAIN" | "RETRIEVER" | "DECISION" | "RESULT" | "ERROR" | "LOGIC" | "LOG";
169
+ timestamp: number;
170
+ status?: "running" | "ok" | "error";
171
+ durationMs?: number;
172
+ attributes?: Record<string, unknown>;
173
+ confidence: "explicit" | "correlated" | "heuristic" | "unknown";
174
+ source: { type: "manual" | "json-log" | "log4js" | "pino" | "winston" | "adapter"; file?: string; line?: number };
175
+ }
176
+ ```
177
+
178
+ ## 12. Confidence labels (required)
179
+
180
+ Log-derived trees must remain honest:
181
+
182
+ - `explicit`: parent relationship is directly known (parentId, adapter parent, etc.)
183
+ - `correlated`: grouped by run id / request id keys
184
+ - `heuristic`: inferred from patterns (used sparingly)
185
+ - `unknown`: missing key evidence (e.g. missing timestamp)
186
+
187
+ ## 13. Redaction considerations
188
+
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.
190
+
191
+ Always review any exported content (Markdown/HTML/OpenInference/OTLP JSON) before sharing, especially if you enable richer attribute inclusion.
192
+
193
+ See: `docs-local/architecture/REDACTION.md`.
194
+
195
+ ## 14. Migration notes
196
+
197
+ - Minor releases may add optional fields/events, but must keep existing v0.1 traces readable.
198
+ - Migration guides (v0.1 → v1.0) are out of scope for this pass, but this document is the canonical schema reference for that future guide.
199
+
@@ -0,0 +1,14 @@
1
+ ## Screenshots / GIFs (planned)
2
+
3
+ This repo does not currently include screenshots or recorded GIFs in the npm package.
4
+
5
+ Recommended captures to add (when convenient):
6
+
7
+ - [ ] Basic trace tree (`inspectRun` + `step`)
8
+ - [ ] Failed tool call / failed step rendering
9
+ - [ ] `agent-inspect logs` output (JSON logs)
10
+ - [ ] `agent-inspect diff` output
11
+ - [ ] Optional TUI (`agent-inspect view <run-id> --tui`)
12
+
13
+ <!-- Add screenshots after running `examples/00-quickstart-demo` locally. -->
14
+
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-inspect",
3
- "version": "0.1.2",
3
+ "version": "1.0.1",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "description": "Local-first execution-tree debugger for TypeScript AI agents",
@@ -12,6 +12,7 @@
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",
15
16
  "main": "./packages/core/dist/index.cjs",
16
17
  "module": "./packages/core/dist/index.mjs",
17
18
  "types": "./packages/core/dist/index.d.ts",
@@ -29,7 +30,24 @@
29
30
  "packages/core/dist",
30
31
  "packages/cli/dist",
31
32
  "README.md",
32
- "LICENSE"
33
+ "LICENSE",
34
+ "SECURITY.md",
35
+ "CHANGELOG.md",
36
+ "docs/GETTING-STARTED.md",
37
+ "docs/API.md",
38
+ "docs/CLI.md",
39
+ "docs/SCHEMA.md",
40
+ "docs/LIMITATIONS.md",
41
+ "docs/KNOWN-ISSUES.md",
42
+ "docs/MIGRATION.md",
43
+ "docs/ARCHITECTURE.md",
44
+ "docs/LOGS.md",
45
+ "docs/EXPORTS.md",
46
+ "docs/DIFF.md",
47
+ "docs/ADAPTERS.md",
48
+ "docs/COMPARE.md",
49
+ "docs/LOG-TO-TREE-QUICKSTART.md",
50
+ "docs/SCREENSHOTS.md"
33
51
  ],
34
52
  "sideEffects": false,
35
53
  "keywords": [
@@ -45,35 +63,43 @@
45
63
  "publishConfig": {
46
64
  "access": "public"
47
65
  },
66
+ "engines": {
67
+ "node": ">=20"
68
+ },
48
69
  "dependencies": {
49
70
  "chalk": "^5.3.0",
50
71
  "nanoid": "^5.0.9",
51
72
  "commander": "^12.1.0"
52
73
  },
53
- "devDependencies": {
54
- "@changesets/cli": "^2.27.10",
55
- "@size-limit/preset-small-lib": "^11.1.6",
56
- "@types/node": "^22.10.2",
57
- "@vitest/coverage-v8": "^2.1.8",
58
- "size-limit": "^11.1.6",
59
- "tsup": "^8.3.5",
60
- "typescript": "^5.7.2",
61
- "vitest": "^2.1.8"
62
- },
63
74
  "scripts": {
64
75
  "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",
76
+ "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
77
  "typecheck": "tsc --noEmit",
67
78
  "test": "vitest run",
68
79
  "test:watch": "vitest",
69
80
  "test:coverage": "vitest run --coverage",
70
81
  "size": "size-limit --config size-limit.config.mjs",
71
82
  "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",
83
+ "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",
73
86
  "pack:dry-run": "pnpm run build && npm pack --dry-run",
74
87
  "pack:smoke": "pnpm run build && node scripts/package-smoke.mjs",
88
+ "fixtures:check": "node scripts/validate-fixtures.mjs",
89
+ "recipes:check": "node scripts/validate-recipes.mjs",
90
+ "perf:baseline": "node scripts/performance-baseline.mjs",
75
91
  "examples:check": "pnpm install && pnpm --filter agent-inspect-example-01-basic run start",
76
92
  "changeset": "changeset",
77
93
  "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"
78
104
  }
79
- }
105
+ }