agent-inspect 1.8.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.
- package/CHANGELOG.md +8 -0
- package/README.md +137 -18
- package/docs/ADAPTERS.md +41 -6
- package/docs/API.md +98 -12
- package/docs/CLI.md +35 -1
- package/docs/GETTING-STARTED.md +71 -16
- package/docs/LOG-TO-TREE-QUICKSTART.md +1 -2
- package/docs/MIGRATION.md +67 -0
- package/package.json +2 -2
- package/packages/cli/dist/index.cjs +338 -48
- package/packages/cli/dist/index.cjs.map +1 -1
- package/packages/cli/dist/index.mjs +338 -48
- package/packages/cli/dist/index.mjs.map +1 -1
- package/packages/core/dist/index.cjs +146 -0
- package/packages/core/dist/index.cjs.map +1 -1
- package/packages/core/dist/index.d.cts +39 -2
- package/packages/core/dist/index.d.ts +39 -2
- package/packages/core/dist/index.mjs +148 -1
- package/packages/core/dist/index.mjs.map +1 -1
package/docs/GETTING-STARTED.md
CHANGED
|
@@ -25,7 +25,36 @@ pnpm build
|
|
|
25
25
|
node packages/cli/dist/index.cjs --help
|
|
26
26
|
```
|
|
27
27
|
|
|
28
|
-
## 2.
|
|
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
|
-
|
|
69
|
+
Use the root import for stable beginner APIs:
|
|
41
70
|
|
|
42
|
-
|
|
43
|
-
|
|
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
|
-
##
|
|
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
|
-
##
|
|
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
|
-
##
|
|
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
|
-
##
|
|
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
|
-
##
|
|
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
|
-
##
|
|
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
|
-
##
|
|
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
|
-
##
|
|
212
|
+
## 11. Try recipes
|
|
164
213
|
|
|
165
214
|
See `examples/recipes/README.md`.
|
|
166
215
|
|
|
167
|
-
##
|
|
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
|
-
##
|
|
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
|
-
##
|
|
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
|
-
##
|
|
247
|
+
## 15. Next docs
|
|
193
248
|
|
|
194
249
|
- [docs/API.md](./API.md)
|
|
195
250
|
- [docs/CLI.md](./CLI.md)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
## Log-to-tree quickstart
|
|
2
2
|
|
|
3
|
-
AgentInspect can inspect
|
|
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agent-inspect",
|
|
3
|
-
"version": "1.
|
|
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",
|
|
@@ -168,7 +168,7 @@
|
|
|
168
168
|
},
|
|
169
169
|
"scripts": {
|
|
170
170
|
"clean": "pnpm -r exec -- rm -rf dist",
|
|
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",
|
|
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",
|
|
172
172
|
"typecheck": "tsc --noEmit",
|
|
173
173
|
"test": "vitest run",
|
|
174
174
|
"test:watch": "vitest",
|