agent-inspect 1.0.2 → 1.0.3
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 +15 -1
- package/docs/API.md +4 -2
- package/docs/CLI.md +1 -0
- package/docs/GETTING-STARTED.md +22 -0
- package/package.json +9 -4
- package/packages/cli/dist/index.cjs.map +1 -1
- package/packages/cli/dist/index.mjs.map +1 -1
- package/packages/core/dist/index.cjs +24 -0
- package/packages/core/dist/index.cjs.map +1 -1
- package/packages/core/dist/index.d.cts +20 -2
- package/packages/core/dist/index.d.ts +20 -2
- package/packages/core/dist/index.mjs +23 -1
- package/packages/core/dist/index.mjs.map +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.0.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Add `enabled` option and `maybeInspectRun` helper for env-gated tracing (`AGENT_INSPECT`).
|
|
8
|
+
- Fix CJS/ESM conditional type exports for TypeScript consumers.
|
|
9
|
+
- Add community contributor scaffold and issue drafts.
|
|
10
|
+
|
|
3
11
|
## 1.0.2
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -93,6 +93,18 @@ support-agent
|
|
|
93
93
|
|
|
94
94
|
A runnable copy lives in [examples/00-quickstart-demo](examples/00-quickstart-demo/README.md).
|
|
95
95
|
|
|
96
|
+
**Env-gated tracing** (eval harnesses, CI): use `maybeInspectRun` and set `AGENT_INSPECT=1` when you want a trace — otherwise no files are written.
|
|
97
|
+
|
|
98
|
+
```ts
|
|
99
|
+
import { maybeInspectRun } from "agent-inspect";
|
|
100
|
+
|
|
101
|
+
await maybeInspectRun("eval-case-42", async () => runAgent());
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
AGENT_INSPECT=1 node eval-runner.mjs
|
|
106
|
+
```
|
|
107
|
+
|
|
96
108
|
## What the trace shows
|
|
97
109
|
|
|
98
110
|
Each run produces a **JSONL** trace: `run_started` / `run_completed`, `step_started` / `step_completed`, with **nested steps**, **tool/LLM** types where you use `step.tool` / `step.llm`, and **durations** on completed steps. Failures are recorded on `step_completed` with `status: "error"` (there is no separate `step_failed` event). See [docs/SCHEMA.md](docs/SCHEMA.md).
|
|
@@ -155,7 +167,9 @@ Full flags and behavior: [docs/CLI.md](docs/CLI.md).
|
|
|
155
167
|
- Inspect runs with **`list`** and **`view`**
|
|
156
168
|
- Safely remove old trace files with **`clean`**
|
|
157
169
|
|
|
158
|
-
**Stable APIs:** `inspectRun()`, `step()`, `step.llm()`, `step.tool()`, `observe()`.
|
|
170
|
+
**Stable APIs:** `inspectRun()`, `maybeInspectRun()`, `step()`, `step.llm()`, `step.tool()`, `observe()`.
|
|
171
|
+
|
|
172
|
+
Pass `enabled: false` to `inspectRun` for a no-trace passthrough. Use `maybeInspectRun` with `AGENT_INSPECT=1` (or `true` / `yes` / `on` / `enabled`) to toggle tracing in eval or CI jobs — see [docs/API.md](docs/API.md).
|
|
159
173
|
|
|
160
174
|
**Stable CLI workflows:** `agent-inspect list`, `agent-inspect view`, `agent-inspect clean`.
|
|
161
175
|
|
package/docs/API.md
CHANGED
|
@@ -22,10 +22,12 @@ These are the recommended entry points for manual instrumentation. They are desi
|
|
|
22
22
|
Import from `agent-inspect`:
|
|
23
23
|
|
|
24
24
|
```ts
|
|
25
|
-
import { inspectRun, step, observe } from "agent-inspect";
|
|
25
|
+
import { inspectRun, maybeInspectRun, step, observe } from "agent-inspect";
|
|
26
26
|
```
|
|
27
27
|
|
|
28
|
-
- **`inspectRun(name, fn, options?)`**: wraps a workflow in a local JSONL trace (`run_started` / `run_completed`), prints terminal progress, and swallows instrumentation failures (user errors are re-thrown).
|
|
28
|
+
- **`inspectRun(name, fn, options?)`**: wraps a workflow in a local JSONL trace (`run_started` / `run_completed`), prints terminal progress, and swallows instrumentation failures (user errors are re-thrown). **Traces by default** when `enabled` is omitted or `true`. Pass **`enabled: false`** to run `fn` with no trace file, no execution context, and no terminal output.
|
|
29
|
+
- **`maybeInspectRun(name, fn, options?)`**: same as `inspectRun` when tracing is enabled; otherwise passthrough. Enablement: explicit **`options.enabled`** wins; when omitted, reads **`AGENT_INSPECT`** (`1`, `true`, `yes`, `on`, `enabled` — case-insensitive). Unset or other values disable tracing. Use in eval harnesses, CI, or jobs where tracing should be toggled by environment.
|
|
30
|
+
- **`isAgentInspectEnabled(value?)`**: returns whether a string (or `process.env.AGENT_INSPECT`) matches an enable token.
|
|
29
31
|
- **`step(name, fn, options?)`**: traces a named unit of work inside `inspectRun` (`step_started` / `step_completed`).
|
|
30
32
|
- **`step.llm(model, fn)`**: convenience wrapper (`type: "llm"`, `metadata.model`).
|
|
31
33
|
- **`step.tool(toolName, fn)`**: convenience wrapper (`type: "tool"`, `metadata.toolName`).
|
package/docs/CLI.md
CHANGED
|
@@ -31,6 +31,7 @@ Core commands:
|
|
|
31
31
|
|
|
32
32
|
- **`AGENT_INSPECT_TRACE_DIR`**: default directory for manual trace files (`.jsonl`) when not passed via `--dir` (or API options).
|
|
33
33
|
- **`AGENT_INSPECT_SILENT`**: when `true`, suppresses live terminal tree output during manual tracing (`inspectRun` / `step`). Trace files are still written.
|
|
34
|
+
- **`AGENT_INSPECT`**: enables manual tracing for **`maybeInspectRun`** when set to `1`, `true`, `yes`, `on`, or `enabled` (case-insensitive). Unset or any other value disables tracing. Does **not** change default **`inspectRun`** behavior (which always traces unless `enabled: false` is passed in code). No network upload — local JSONL only.
|
|
34
35
|
|
|
35
36
|
## 3. Exit code policy
|
|
36
37
|
|
package/docs/GETTING-STARTED.md
CHANGED
|
@@ -38,6 +38,28 @@ This writes a local JSONL trace with stable v1.0 event names:
|
|
|
38
38
|
- `run_started`, `run_completed`
|
|
39
39
|
- `step_started`, `step_completed`
|
|
40
40
|
|
|
41
|
+
### Always trace vs env-gated tracing
|
|
42
|
+
|
|
43
|
+
Use **`inspectRun`** when you always want a local trace (default behavior).
|
|
44
|
+
|
|
45
|
+
Use **`maybeInspectRun`** in eval harnesses, CI, or production-shaped jobs where tracing should be toggled by environment:
|
|
46
|
+
|
|
47
|
+
```ts
|
|
48
|
+
import { maybeInspectRun } from "agent-inspect";
|
|
49
|
+
|
|
50
|
+
await maybeInspectRun("eval-case-42", async () => {
|
|
51
|
+
return runAgent();
|
|
52
|
+
});
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
AGENT_INSPECT=1 node eval-runner.mjs
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Enable tokens: `1`, `true`, `yes`, `on`, `enabled` (case-insensitive). Explicit `enabled: true | false` in options overrides the env var.
|
|
60
|
+
|
|
61
|
+
To skip tracing in code without env vars: `inspectRun(name, fn, { enabled: false })`.
|
|
62
|
+
|
|
41
63
|
## 3. View runs
|
|
42
64
|
|
|
43
65
|
```bash
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agent-inspect",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "Local-first execution-tree debugger for TypeScript AI agents",
|
|
@@ -18,9 +18,14 @@
|
|
|
18
18
|
"types": "./packages/core/dist/index.d.ts",
|
|
19
19
|
"exports": {
|
|
20
20
|
".": {
|
|
21
|
-
"
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
"import": {
|
|
22
|
+
"types": "./packages/core/dist/index.d.ts",
|
|
23
|
+
"default": "./packages/core/dist/index.mjs"
|
|
24
|
+
},
|
|
25
|
+
"require": {
|
|
26
|
+
"types": "./packages/core/dist/index.d.cts",
|
|
27
|
+
"default": "./packages/core/dist/index.cjs"
|
|
28
|
+
}
|
|
24
29
|
}
|
|
25
30
|
},
|
|
26
31
|
"bin": {
|