@webywz/agent-trace 0.1.0 → 0.1.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/README.md +54 -18
- package/dist/args.d.ts +7 -0
- package/dist/args.d.ts.map +1 -1
- package/dist/args.js +115 -19
- package/dist/args.js.map +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +57 -19
- package/dist/cli.js.map +1 -1
- package/dist/parse/index.d.ts.map +1 -1
- package/dist/parse/index.js +3 -3
- package/dist/parse/index.js.map +1 -1
- package/dist/read-input.d.ts +1 -0
- package/dist/read-input.d.ts.map +1 -1
- package/dist/read-input.js +19 -3
- package/dist/read-input.js.map +1 -1
- package/examples/README.md +44 -0
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -4,19 +4,26 @@ Turn messy agent run logs into a readable timeline.
|
|
|
4
4
|
|
|
5
5
|
OpenAI tool-call dumps, LangChain / LangSmith trees, JSONL event streams, Cursor-ish traces — all of them are painful to skim. `agent-trace` is an offline CLI that normalizes those shapes into a numbered timeline: thoughts, tools, results, errors, durations, and a one-line autopsy.
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
No API key. No network. Pipe a dump, get a story.
|
|
8
|
+
|
|
9
|
+
## 30-second demo
|
|
10
|
+
|
|
11
|
+
Copy-paste. `--demo` is bundled with the package, so this works without cloning the repo.
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npx @webywz/agent-trace --demo --no-color
|
|
9
15
|
```
|
|
10
16
|
|
|
11
17
|
```text
|
|
18
|
+
$ npx @webywz/agent-trace --demo --stats --no-color
|
|
19
|
+
19 steps · 7 tool calls · 1 failure · ~1,840 in / 96 out · 15.3s
|
|
20
|
+
|
|
21
|
+
$ npx @webywz/agent-trace --demo --no-color
|
|
12
22
|
agent-trace · examples/run.jsonl
|
|
13
23
|
jsonl · 19 steps · 7 tool calls · 1 failure · 15.3s
|
|
14
24
|
────────────────────────────────────────────────────────────────────────
|
|
15
25
|
1 user +0ms 770ms
|
|
16
|
-
│ The login test is flaky on CI. Fix it. Do not sleep() your way
|
|
17
|
-
│
|
|
18
|
-
2 thought +770ms 120ms
|
|
19
|
-
│ I'll read the spec and the auth module, then look for a race — not a …
|
|
26
|
+
│ The login test is flaky on CI. Fix it. Do not sleep() your way …
|
|
20
27
|
│
|
|
21
28
|
3 tool +890ms 170ms read_file
|
|
22
29
|
│ {"path":"test/login.spec.ts"}
|
|
@@ -25,49 +32,77 @@ jsonl · 19 steps · 7 tool calls · 1 failure · 15.3s
|
|
|
25
32
|
│ {"cmd":"npx playwright test test/login.spec.ts --repeat-each=8"}
|
|
26
33
|
│
|
|
27
34
|
13 error +9.29s 470ms run_tests
|
|
28
|
-
│ 1 failed · login.spec.ts:12: cookie sid missing on first
|
|
35
|
+
│ 1 failed · login.spec.ts:12: cookie sid missing on first naviga…
|
|
29
36
|
│
|
|
30
37
|
19 assistant +15.3s
|
|
31
|
-
│ The flake was a cookie/redirect race, not a slow page. Cookie
|
|
38
|
+
│ The flake was a cookie/redirect race, not a slow page. Cookie i…
|
|
32
39
|
────────────────────────────────────────────────────────────────────────
|
|
33
40
|
19 steps · 7 tool calls · 1 failure · ~1,840 in / 96 out · 15.3s
|
|
34
41
|
```
|
|
35
42
|
|
|
43
|
+
The sample above is abbreviated; the real command prints all 19 steps. `--demo` is the bundled `examples/run.jsonl` (a coding agent that fails `run_tests` once, then recovers).
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
npx @webywz/agent-trace --demo --spicy --no-color
|
|
47
|
+
# spicy The brief was “The login test is flaky…”. Then `run_tests` blew up: …
|
|
48
|
+
```
|
|
49
|
+
|
|
36
50
|
## Install
|
|
37
51
|
|
|
38
52
|
```bash
|
|
39
53
|
npm i -g @webywz/agent-trace
|
|
40
|
-
agent-trace
|
|
54
|
+
agent-trace --demo
|
|
41
55
|
```
|
|
42
56
|
|
|
43
57
|
Node 18+. No API key required.
|
|
44
58
|
|
|
45
59
|
```bash
|
|
46
|
-
npx @webywz/agent-trace
|
|
60
|
+
npx @webywz/agent-trace --demo
|
|
61
|
+
cat run.jsonl | npx @webywz/agent-trace
|
|
47
62
|
```
|
|
48
63
|
|
|
49
64
|
## Usage
|
|
50
65
|
|
|
51
66
|
```bash
|
|
67
|
+
agent-trace --demo
|
|
52
68
|
agent-trace run.jsonl
|
|
53
|
-
agent-trace --format auto|openai|langchain|jsonl run.jsonl
|
|
54
|
-
agent-trace --json run.jsonl
|
|
69
|
+
agent-trace --format auto|openai|langchain|jsonl|generic run.jsonl
|
|
70
|
+
agent-trace --json run.jsonl | jq .stats
|
|
71
|
+
agent-trace --stats run.jsonl
|
|
72
|
+
agent-trace --fail-on-error --stats traces/ci.jsonl
|
|
55
73
|
agent-trace --spicy run.jsonl
|
|
56
74
|
cat run.jsonl | agent-trace
|
|
57
75
|
```
|
|
58
76
|
|
|
59
77
|
| Flag | What it does |
|
|
60
78
|
| --- | --- |
|
|
61
|
-
| `-f, --format` | `auto` (default), `openai`, `langchain`, `jsonl` |
|
|
62
|
-
|
|
|
79
|
+
| `-f, --format` | `auto` (default), `openai`, `langchain`, `jsonl`, `generic` |
|
|
80
|
+
| `-j, --json` | Normalized trace as JSON (steps, stats, warnings) |
|
|
81
|
+
| `--stats` | One-line summary only (good for CI logs) |
|
|
63
82
|
| `--spicy` | A short narrative recap. Offline by default; uses `OPENAI_API_KEY` or `ANTHROPIC_API_KEY` when set |
|
|
83
|
+
| `--fail-on-error` | Exit `1` if the run had tool/step failures |
|
|
84
|
+
| `--demo` | Render the bundled sample (`examples/run.jsonl`) |
|
|
64
85
|
| `--ascii` | ASCII-only timeline (no box drawing) |
|
|
65
|
-
| `--no-color` |
|
|
86
|
+
| `--color` / `--no-color` | Force or disable ANSI colors (`NO_COLOR` also disables) |
|
|
66
87
|
| `--width <n>` | Wrap width (defaults to the terminal) |
|
|
67
88
|
| `--max-content <n>` | Truncate args / results (default 160) |
|
|
68
89
|
|
|
69
90
|
`--spicy` never blocks the timeline. If the key is missing, the recap is local. If the LLM call fails, you still get the local recap.
|
|
70
91
|
|
|
92
|
+
### Exit codes
|
|
93
|
+
|
|
94
|
+
| Code | When |
|
|
95
|
+
| --- | --- |
|
|
96
|
+
| `0` | Timeline (or JSON / stats) printed |
|
|
97
|
+
| `1` | I/O or parse error, **or** `--fail-on-error` when the trace has failures |
|
|
98
|
+
| `2` | Usage error (unknown flag, missing file). stderr ends with `try 'agent-trace --help'` |
|
|
99
|
+
|
|
100
|
+
CI one-liner — fail the job if the agent run had failures:
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
agent-trace --fail-on-error --stats traces/last-run.jsonl
|
|
104
|
+
```
|
|
105
|
+
|
|
71
106
|
## What it parses
|
|
72
107
|
|
|
73
108
|
**OpenAI** — `chat.completion` objects, `messages[]` with `tool_calls` / `role: tool`, Responses API `output[]`, and streamed JSONL chunks with `delta`.
|
|
@@ -95,14 +130,15 @@ process.stdout.write(renderTimeline(trace, { color: false }));
|
|
|
95
130
|
|
|
96
131
|
## Examples
|
|
97
132
|
|
|
98
|
-
Same repo, ready to paste
|
|
133
|
+
Same repo, ready to paste. Walkthrough: [`examples/README.md`](examples/README.md).
|
|
99
134
|
|
|
100
135
|
```bash
|
|
136
|
+
agent-trace --demo
|
|
101
137
|
agent-trace examples/run.jsonl
|
|
102
138
|
agent-trace examples/openai.json
|
|
103
139
|
agent-trace examples/langchain.json
|
|
104
140
|
agent-trace --json examples/generic.json
|
|
105
|
-
agent-trace --
|
|
141
|
+
agent-trace --fail-on-error --stats examples/run.jsonl; echo $?
|
|
106
142
|
```
|
|
107
143
|
|
|
108
144
|
## Develop
|
|
@@ -111,7 +147,7 @@ agent-trace --spicy examples/run.jsonl
|
|
|
111
147
|
npm install
|
|
112
148
|
npm test
|
|
113
149
|
npm run build
|
|
114
|
-
node dist/cli.js
|
|
150
|
+
node dist/cli.js --demo --no-color
|
|
115
151
|
```
|
|
116
152
|
|
|
117
153
|
MIT © webywz
|
package/dist/args.d.ts
CHANGED
|
@@ -10,6 +10,13 @@ export interface CliArgs {
|
|
|
10
10
|
maxContent?: number;
|
|
11
11
|
help: boolean;
|
|
12
12
|
version: boolean;
|
|
13
|
+
demo: boolean;
|
|
14
|
+
failOnError: boolean;
|
|
15
|
+
stats: boolean;
|
|
16
|
+
}
|
|
17
|
+
export declare class UsageError extends Error {
|
|
18
|
+
readonly exitCode = 2;
|
|
19
|
+
constructor(message: string);
|
|
13
20
|
}
|
|
14
21
|
export declare function parseArgs(argv: string[]): CliArgs;
|
|
15
22
|
export declare function helpText(version: string): string;
|
package/dist/args.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"args.d.ts","sourceRoot":"","sources":["../src/args.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C,MAAM,WAAW,OAAO;IACtB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,WAAW,CAAC;IACpB,IAAI,EAAE,OAAO,CAAC;IACd,KAAK,EAAE,OAAO,CAAC;IACf,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,KAAK,EAAE,OAAO,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,EAAE,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"args.d.ts","sourceRoot":"","sources":["../src/args.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C,MAAM,WAAW,OAAO;IACtB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,WAAW,CAAC;IACpB,IAAI,EAAE,OAAO,CAAC;IACd,KAAK,EAAE,OAAO,CAAC;IACf,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,KAAK,EAAE,OAAO,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,EAAE,OAAO,CAAC;IACd,WAAW,EAAE,OAAO,CAAC;IACrB,KAAK,EAAE,OAAO,CAAC;CAChB;AAED,qBAAa,UAAW,SAAQ,KAAK;IACnC,QAAQ,CAAC,QAAQ,KAAK;gBACV,OAAO,EAAE,MAAM;CAI5B;AAyBD,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAyGjD;AA8CD,wBAAgB,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CA6ChD"}
|
package/dist/args.js
CHANGED
|
@@ -1,4 +1,31 @@
|
|
|
1
|
+
export class UsageError extends Error {
|
|
2
|
+
exitCode = 2;
|
|
3
|
+
constructor(message) {
|
|
4
|
+
super(message);
|
|
5
|
+
this.name = "UsageError";
|
|
6
|
+
}
|
|
7
|
+
}
|
|
1
8
|
const FORMATS = new Set(["auto", "openai", "langchain", "jsonl", "generic"]);
|
|
9
|
+
const FORMAT_LIST = "auto|openai|langchain|jsonl|generic";
|
|
10
|
+
const FLAGS = [
|
|
11
|
+
"-h",
|
|
12
|
+
"--help",
|
|
13
|
+
"-v",
|
|
14
|
+
"--version",
|
|
15
|
+
"--json",
|
|
16
|
+
"-j",
|
|
17
|
+
"--spicy",
|
|
18
|
+
"--ascii",
|
|
19
|
+
"--no-color",
|
|
20
|
+
"--color",
|
|
21
|
+
"-f",
|
|
22
|
+
"--format",
|
|
23
|
+
"--width",
|
|
24
|
+
"--max-content",
|
|
25
|
+
"--demo",
|
|
26
|
+
"--fail-on-error",
|
|
27
|
+
"--stats",
|
|
28
|
+
];
|
|
2
29
|
export function parseArgs(argv) {
|
|
3
30
|
const args = {
|
|
4
31
|
format: "auto",
|
|
@@ -7,6 +34,9 @@ export function parseArgs(argv) {
|
|
|
7
34
|
ascii: false,
|
|
8
35
|
help: false,
|
|
9
36
|
version: false,
|
|
37
|
+
demo: false,
|
|
38
|
+
failOnError: false,
|
|
39
|
+
stats: false,
|
|
10
40
|
};
|
|
11
41
|
const rest = argv.slice(2);
|
|
12
42
|
for (let i = 0; i < rest.length; i += 1) {
|
|
@@ -21,7 +51,7 @@ export function parseArgs(argv) {
|
|
|
21
51
|
}
|
|
22
52
|
if (token === "-") {
|
|
23
53
|
if (args.file)
|
|
24
|
-
throw new
|
|
54
|
+
throw new UsageError("unexpected extra argument '-'");
|
|
25
55
|
args.file = "-";
|
|
26
56
|
continue;
|
|
27
57
|
}
|
|
@@ -53,12 +83,24 @@ export function parseArgs(argv) {
|
|
|
53
83
|
args.color = true;
|
|
54
84
|
continue;
|
|
55
85
|
}
|
|
86
|
+
if (token === "--demo") {
|
|
87
|
+
args.demo = true;
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
if (token === "--fail-on-error") {
|
|
91
|
+
args.failOnError = true;
|
|
92
|
+
continue;
|
|
93
|
+
}
|
|
94
|
+
if (token === "--stats") {
|
|
95
|
+
args.stats = true;
|
|
96
|
+
continue;
|
|
97
|
+
}
|
|
56
98
|
const eq = token.indexOf("=");
|
|
57
99
|
const [flag, inline] = eq === -1 ? [token, undefined] : [token.slice(0, eq), token.slice(eq + 1)];
|
|
58
100
|
if (flag === "-f" || flag === "--format") {
|
|
59
101
|
const value = inline ?? rest[++i];
|
|
60
|
-
if (!value || !FORMATS.has(value)) {
|
|
61
|
-
throw new
|
|
102
|
+
if (!value || value.startsWith("-") || !FORMATS.has(value)) {
|
|
103
|
+
throw new UsageError(`unknown format '${value ?? ""}' (expected ${FORMAT_LIST})`);
|
|
62
104
|
}
|
|
63
105
|
args.format = value;
|
|
64
106
|
continue;
|
|
@@ -72,49 +114,103 @@ export function parseArgs(argv) {
|
|
|
72
114
|
continue;
|
|
73
115
|
}
|
|
74
116
|
if (token.startsWith("-")) {
|
|
75
|
-
|
|
117
|
+
const hint = suggestFlag(token);
|
|
118
|
+
throw new UsageError(hint ? `unknown option '${token}' (did you mean ${hint}?)` : `unknown option '${token}'`);
|
|
76
119
|
}
|
|
77
120
|
if (args.file) {
|
|
78
|
-
throw new
|
|
121
|
+
throw new UsageError(`unexpected extra argument '${token}'`);
|
|
79
122
|
}
|
|
80
123
|
args.file = token;
|
|
81
124
|
}
|
|
125
|
+
if (args.demo && args.file) {
|
|
126
|
+
throw new UsageError("do not pass a file with --demo (the bundled sample is used)");
|
|
127
|
+
}
|
|
82
128
|
return args;
|
|
83
129
|
}
|
|
84
130
|
function toInt(value, flag) {
|
|
85
131
|
const n = Number(value);
|
|
86
|
-
if (!value || !Number.isInteger(n) || n <= 0) {
|
|
87
|
-
throw new
|
|
132
|
+
if (!value || value.startsWith("-") || !Number.isInteger(n) || n <= 0) {
|
|
133
|
+
throw new UsageError(`${flag} expects a positive integer`);
|
|
88
134
|
}
|
|
89
135
|
return n;
|
|
90
136
|
}
|
|
137
|
+
function suggestFlag(token) {
|
|
138
|
+
if (token.startsWith("--") && token.length >= 4) {
|
|
139
|
+
const prefixes = FLAGS.filter((flag) => flag.startsWith(token));
|
|
140
|
+
if (prefixes.length === 1)
|
|
141
|
+
return prefixes[0];
|
|
142
|
+
}
|
|
143
|
+
let best;
|
|
144
|
+
let bestDist = 3;
|
|
145
|
+
for (const flag of FLAGS) {
|
|
146
|
+
const dist = levenshtein(token, flag);
|
|
147
|
+
if (dist < bestDist) {
|
|
148
|
+
bestDist = dist;
|
|
149
|
+
best = flag;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
return best;
|
|
153
|
+
}
|
|
154
|
+
function levenshtein(a, b) {
|
|
155
|
+
const rows = a.length + 1;
|
|
156
|
+
const cols = b.length + 1;
|
|
157
|
+
const dp = new Array(rows * cols);
|
|
158
|
+
for (let i = 0; i < rows; i += 1)
|
|
159
|
+
dp[i * cols] = i;
|
|
160
|
+
for (let j = 0; j < cols; j += 1)
|
|
161
|
+
dp[j] = j;
|
|
162
|
+
for (let i = 1; i < rows; i += 1) {
|
|
163
|
+
for (let j = 1; j < cols; j += 1) {
|
|
164
|
+
const cost = a[i - 1] === b[j - 1] ? 0 : 1;
|
|
165
|
+
dp[i * cols + j] = Math.min((dp[(i - 1) * cols + j] ?? 0) + 1, (dp[i * cols + j - 1] ?? 0) + 1, (dp[(i - 1) * cols + j - 1] ?? 0) + cost);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
return dp[a.length * cols + b.length] ?? 0;
|
|
169
|
+
}
|
|
91
170
|
export function helpText(version) {
|
|
92
171
|
return `\
|
|
93
172
|
agent-trace v${version}
|
|
94
173
|
Turn messy agent run logs into a readable timeline.
|
|
95
174
|
|
|
96
175
|
Usage:
|
|
97
|
-
agent-trace <file>
|
|
98
|
-
agent-trace -
|
|
176
|
+
agent-trace [options] <file>
|
|
177
|
+
agent-trace [options] - Read from stdin
|
|
99
178
|
cat run.jsonl | agent-trace
|
|
179
|
+
agent-trace --demo Bundled sample (no file needed)
|
|
100
180
|
|
|
101
181
|
Options:
|
|
102
|
-
-f, --format
|
|
103
|
-
|
|
104
|
-
--
|
|
105
|
-
|
|
106
|
-
--
|
|
107
|
-
--
|
|
108
|
-
--
|
|
109
|
-
--
|
|
110
|
-
|
|
111
|
-
|
|
182
|
+
-f, --format <fmt> ${FORMAT_LIST} (default: auto)
|
|
183
|
+
-j, --json Normalized trace as JSON
|
|
184
|
+
--stats One-line summary only
|
|
185
|
+
--spicy Narrative recap (offline, or LLM if API key set)
|
|
186
|
+
--fail-on-error Exit 1 if the run had failures
|
|
187
|
+
--demo Render bundled examples/run.jsonl
|
|
188
|
+
--ascii ASCII-only timeline
|
|
189
|
+
--color Force ANSI colors
|
|
190
|
+
--no-color Disable ANSI colors (or set NO_COLOR)
|
|
191
|
+
--width <n> Wrap width (default: terminal)
|
|
192
|
+
--max-content <n> Truncate args/results (default: 160)
|
|
193
|
+
-h, --help Show this help
|
|
194
|
+
-v, --version Print version
|
|
112
195
|
|
|
113
196
|
Formats:
|
|
114
197
|
openai Chat Completions, messages[], Responses API, streaming deltas
|
|
115
198
|
langchain LangSmith run trees, callback events, AgentAction dumps
|
|
116
199
|
jsonl Role/tool/content events, Cursor-ish traces, generic objects
|
|
200
|
+
generic JSON array (or { events: [...] }) of { type, name, content, ts }
|
|
117
201
|
auto Sniff the file, then fall through the parsers above
|
|
202
|
+
|
|
203
|
+
Exit codes:
|
|
204
|
+
0 ok
|
|
205
|
+
1 I/O or parse error; or --fail-on-error when the trace has failures
|
|
206
|
+
2 usage error (bad flag, missing file)
|
|
207
|
+
|
|
208
|
+
Examples:
|
|
209
|
+
agent-trace --demo
|
|
210
|
+
agent-trace run.jsonl
|
|
211
|
+
agent-trace --format openai dump.json
|
|
212
|
+
agent-trace --json run.jsonl | jq .stats
|
|
213
|
+
agent-trace --fail-on-error --stats traces/ci.jsonl
|
|
118
214
|
`;
|
|
119
215
|
}
|
|
120
216
|
//# sourceMappingURL=args.js.map
|
package/dist/args.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"args.js","sourceRoot":"","sources":["../src/args.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"args.js","sourceRoot":"","sources":["../src/args.ts"],"names":[],"mappings":"AAkBA,MAAM,OAAO,UAAW,SAAQ,KAAK;IAC1B,QAAQ,GAAG,CAAC,CAAC;IACtB,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,YAAY,CAAC;IAC3B,CAAC;CACF;AAED,MAAM,OAAO,GAAG,IAAI,GAAG,CAAc,CAAC,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC,CAAC;AAC1F,MAAM,WAAW,GAAG,qCAAqC,CAAC;AAE1D,MAAM,KAAK,GAAG;IACZ,IAAI;IACJ,QAAQ;IACR,IAAI;IACJ,WAAW;IACX,QAAQ;IACR,IAAI;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CAAC,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,IAAI,CACzC,CAAC;QACJ,CAAC;IACH,CAAC;IACD,OAAO,EAAE,CAAC,CAAC,CAAC,MAAM,GAAG,IAAI,GAAG,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;AAC7C,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,OAAe;IACtC,OAAO;gBACO,OAAO;;;;;;;;;;2BAUI,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgCrC,CAAC;AACF,CAAC"}
|
package/dist/cli.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAcA,iBAAe,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAsEnD;AAuED,OAAO,EAAE,IAAI,EAAE,CAAC"}
|
package/dist/cli.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { readFileSync, realpathSync } from "node:fs";
|
|
3
|
+
import { readFile } from "node:fs/promises";
|
|
3
4
|
import { dirname, join } from "node:path";
|
|
4
5
|
import { fileURLToPath } from "node:url";
|
|
5
|
-
import { helpText, parseArgs } from "./args.js";
|
|
6
|
+
import { helpText, parseArgs, UsageError } from "./args.js";
|
|
6
7
|
import { createPalette, shouldColor } from "./color.js";
|
|
7
8
|
import { parseTrace } from "./parse/index.js";
|
|
8
|
-
import { readInput } from "./read-input.js";
|
|
9
|
+
import { readInput, wrapIoError } from "./read-input.js";
|
|
9
10
|
import { spicyNarrative } from "./render/spicy.js";
|
|
10
|
-
import { renderTimeline } from "./render/timeline.js";
|
|
11
|
+
import { renderTimeline, summaryLine } from "./render/timeline.js";
|
|
11
12
|
const VERSION = readVersion();
|
|
12
13
|
async function main(argv) {
|
|
13
14
|
let args;
|
|
@@ -16,7 +17,7 @@ async function main(argv) {
|
|
|
16
17
|
}
|
|
17
18
|
catch (error) {
|
|
18
19
|
printErr(error);
|
|
19
|
-
return
|
|
20
|
+
return exitCodeFor(error);
|
|
20
21
|
}
|
|
21
22
|
if (args.help) {
|
|
22
23
|
process.stdout.write(helpText(VERSION));
|
|
@@ -29,11 +30,11 @@ async function main(argv) {
|
|
|
29
30
|
let text;
|
|
30
31
|
let source;
|
|
31
32
|
try {
|
|
32
|
-
({ text, source } = await readInput(args.file));
|
|
33
|
+
({ text, source } = args.demo ? await readDemo() : await readInput(args.file));
|
|
33
34
|
}
|
|
34
35
|
catch (error) {
|
|
35
36
|
printErr(error);
|
|
36
|
-
return
|
|
37
|
+
return exitCodeFor(error);
|
|
37
38
|
}
|
|
38
39
|
let trace;
|
|
39
40
|
try {
|
|
@@ -53,25 +54,63 @@ async function main(argv) {
|
|
|
53
54
|
...(args.spicy ? { spicy: await spicyNarrative(trace) } : {}),
|
|
54
55
|
};
|
|
55
56
|
process.stdout.write(`${JSON.stringify(payload, null, 2)}\n`);
|
|
56
|
-
return
|
|
57
|
+
return failOnErrorCode(args.failOnError, trace.stats.failures);
|
|
58
|
+
}
|
|
59
|
+
if (args.stats) {
|
|
60
|
+
process.stdout.write(`${summaryLine(trace)}\n`);
|
|
61
|
+
for (const warning of trace.warnings) {
|
|
62
|
+
process.stderr.write(`agent-trace: warn: ${warning}\n`);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
const timeline = renderTimeline(trace, {
|
|
67
|
+
color: args.color,
|
|
68
|
+
ascii: args.ascii,
|
|
69
|
+
width: args.width,
|
|
70
|
+
maxContent: args.maxContent,
|
|
71
|
+
});
|
|
72
|
+
process.stdout.write(timeline);
|
|
57
73
|
}
|
|
58
|
-
const timeline = renderTimeline(trace, {
|
|
59
|
-
color: args.color,
|
|
60
|
-
ascii: args.ascii,
|
|
61
|
-
width: args.width,
|
|
62
|
-
maxContent: args.maxContent,
|
|
63
|
-
});
|
|
64
|
-
process.stdout.write(timeline);
|
|
65
74
|
if (args.spicy) {
|
|
66
75
|
const color = createPalette(shouldColor(args.color));
|
|
67
76
|
const narrative = await spicyNarrative(trace);
|
|
68
77
|
process.stdout.write(`\n${color.bold("spicy")} ${narrative}\n`);
|
|
69
78
|
}
|
|
70
|
-
return
|
|
79
|
+
return failOnErrorCode(args.failOnError, trace.stats.failures);
|
|
80
|
+
}
|
|
81
|
+
function failOnErrorCode(enabled, failures) {
|
|
82
|
+
if (!enabled || failures <= 0)
|
|
83
|
+
return 0;
|
|
84
|
+
const noun = failures === 1 ? "failure" : "failures";
|
|
85
|
+
process.stderr.write(`agent-trace: ${failures} ${noun} (--fail-on-error)\n`);
|
|
86
|
+
return 1;
|
|
71
87
|
}
|
|
72
88
|
function printErr(error) {
|
|
73
89
|
const message = error instanceof Error ? error.message : String(error);
|
|
74
90
|
process.stderr.write(`agent-trace: ${message}\n`);
|
|
91
|
+
if (error instanceof UsageError) {
|
|
92
|
+
process.stderr.write("try 'agent-trace --help'\n");
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
function exitCodeFor(error) {
|
|
96
|
+
return error instanceof UsageError ? 2 : 1;
|
|
97
|
+
}
|
|
98
|
+
async function readDemo() {
|
|
99
|
+
const file = join(packageRoot(), "examples", "run.jsonl");
|
|
100
|
+
try {
|
|
101
|
+
const text = await readFile(file, "utf8");
|
|
102
|
+
return { text, source: "examples/run.jsonl" };
|
|
103
|
+
}
|
|
104
|
+
catch (error) {
|
|
105
|
+
const wrapped = wrapIoError(error, file);
|
|
106
|
+
if (wrapped.message.startsWith("file not found")) {
|
|
107
|
+
throw new Error("bundled demo missing (expected examples/run.jsonl in the package)");
|
|
108
|
+
}
|
|
109
|
+
throw wrapped;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
function packageRoot() {
|
|
113
|
+
return join(dirname(fileURLToPath(import.meta.url)), "..");
|
|
75
114
|
}
|
|
76
115
|
function isCliEntry(argvPath) {
|
|
77
116
|
if (!argvPath)
|
|
@@ -86,13 +125,12 @@ function isCliEntry(argvPath) {
|
|
|
86
125
|
}
|
|
87
126
|
function readVersion() {
|
|
88
127
|
try {
|
|
89
|
-
const
|
|
90
|
-
const raw = readFileSync(join(here, "..", "package.json"), "utf8");
|
|
128
|
+
const raw = readFileSync(join(packageRoot(), "package.json"), "utf8");
|
|
91
129
|
const parsed = JSON.parse(raw);
|
|
92
|
-
return parsed.version ?? "0.1.
|
|
130
|
+
return parsed.version ?? "0.1.1";
|
|
93
131
|
}
|
|
94
132
|
catch {
|
|
95
|
-
return "0.1.
|
|
133
|
+
return "0.1.1";
|
|
96
134
|
}
|
|
97
135
|
}
|
|
98
136
|
if (isCliEntry(process.argv[1])) {
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,SAAS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C;AACpE,OAAO,EAAmB,WAAW,EAAE,MAAM,aAAa,CAAC;AAE3D,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,GAAE,YAAiB,GAAG,KAAK,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/parse/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,KAAK,EAAe,MAAM,aAAa,CAAC;AAEpE,OAAO,EAAoB,YAAY,EAAE,MAAM,cAAc,CAAC;AAC9D,OAAO,EAAkB,UAAU,EAAc,MAAM,YAAY,CAAC;AACpE,OAAO,EAAsB,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACpE,OAAO,EAAmB,WAAW,EAAE,MAAM,aAAa,CAAC;AAE3D,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,GAAE,YAAiB,GAAG,KAAK,CAkC3E;AAkCD,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,cAAc,EAAE,WAAW,EAAE,CAAC"}
|
package/dist/parse/index.js
CHANGED
|
@@ -7,7 +7,7 @@ export function parseTrace(input, options = {}) {
|
|
|
7
7
|
const source = options.source;
|
|
8
8
|
const trimmed = input.replace(/^\uFEFF/, "").trim();
|
|
9
9
|
if (!trimmed) {
|
|
10
|
-
throw new Error("empty trace");
|
|
10
|
+
throw new Error("empty trace — pass a JSON/JSONL file, pipe stdin, or use --demo");
|
|
11
11
|
}
|
|
12
12
|
const format = options.format ?? "auto";
|
|
13
13
|
if (format !== "auto") {
|
|
@@ -31,7 +31,7 @@ export function parseTrace(input, options = {}) {
|
|
|
31
31
|
const jsonl = parseJsonl(trimmed, source);
|
|
32
32
|
if (jsonl.steps.length)
|
|
33
33
|
return jsonl;
|
|
34
|
-
throw new Error("could not detect trace format (tried openai, langchain, jsonl, generic)");
|
|
34
|
+
throw new Error("could not detect trace format (tried openai, langchain, jsonl, generic); pass --format to force a parser");
|
|
35
35
|
}
|
|
36
36
|
function parseAs(format, text, source, json) {
|
|
37
37
|
switch (format) {
|
|
@@ -56,7 +56,7 @@ function decode(text, format) {
|
|
|
56
56
|
const { rows } = splitJsonl(text);
|
|
57
57
|
if (rows.length)
|
|
58
58
|
return rows;
|
|
59
|
-
throw new Error(`could not parse input as ${format}`);
|
|
59
|
+
throw new Error(`could not parse input as ${format} (not valid JSON/JSONL for that parser)`);
|
|
60
60
|
}
|
|
61
61
|
function detectJson(value) {
|
|
62
62
|
if (looksLikeOpenAI(value))
|
package/dist/parse/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/parse/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACpE,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACpE,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE3D,MAAM,UAAU,UAAU,CAAC,KAAa,EAAE,UAAwB,EAAE;IAClE,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAC9B,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;IACpD,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/parse/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,UAAU,E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yCAAyC,CAAC,CAAC;AAC/F,CAAC;AAED,SAAS,UAAU,CAAC,KAAc;IAChC,IAAI,eAAe,CAAC,KAAK,CAAC;QAAE,OAAO,QAAQ,CAAC;IAC5C,IAAI,kBAAkB,CAAC,KAAK,CAAC;QAAE,OAAO,WAAW,CAAC;IAClD,IAAI,gBAAgB,CAAC,KAAK,CAAC;QAAE,OAAO,SAAS,CAAC;IAC9C,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,cAAc,EAAE,WAAW,EAAE,CAAC"}
|
package/dist/read-input.d.ts
CHANGED
package/dist/read-input.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"read-input.d.ts","sourceRoot":"","sources":["../src/read-input.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"read-input.d.ts","sourceRoot":"","sources":["../src/read-input.ts"],"names":[],"mappings":"AAGA,wBAAsB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC,CAcnG;AAUD,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,KAAK,CAM/D"}
|
package/dist/read-input.js
CHANGED
|
@@ -1,14 +1,20 @@
|
|
|
1
1
|
import { readFile } from "node:fs/promises";
|
|
2
|
+
import { UsageError } from "./args.js";
|
|
2
3
|
export async function readInput(file) {
|
|
3
4
|
if (!file || file === "-") {
|
|
4
5
|
if (process.stdin.isTTY && file !== "-") {
|
|
5
|
-
throw new
|
|
6
|
+
throw new UsageError("missing file (pass a path, '-' for stdin, or --demo for the bundled sample)");
|
|
6
7
|
}
|
|
7
8
|
const text = await readStdin();
|
|
8
9
|
return { text, source: "stdin" };
|
|
9
10
|
}
|
|
10
|
-
|
|
11
|
-
|
|
11
|
+
try {
|
|
12
|
+
const text = await readFile(file, "utf8");
|
|
13
|
+
return { text, source: file };
|
|
14
|
+
}
|
|
15
|
+
catch (error) {
|
|
16
|
+
throw wrapIoError(error, file);
|
|
17
|
+
}
|
|
12
18
|
}
|
|
13
19
|
async function readStdin() {
|
|
14
20
|
const chunks = [];
|
|
@@ -17,4 +23,14 @@ async function readStdin() {
|
|
|
17
23
|
}
|
|
18
24
|
return Buffer.concat(chunks).toString("utf8");
|
|
19
25
|
}
|
|
26
|
+
export function wrapIoError(error, file) {
|
|
27
|
+
const code = error && typeof error === "object" && "code" in error ? String(error.code) : "";
|
|
28
|
+
if (code === "ENOENT")
|
|
29
|
+
return new Error(`file not found: ${file}`);
|
|
30
|
+
if (code === "EISDIR")
|
|
31
|
+
return new Error(`expected a file, got a directory: ${file}`);
|
|
32
|
+
if (code === "EACCES")
|
|
33
|
+
return new Error(`permission denied: ${file}`);
|
|
34
|
+
return error instanceof Error ? error : new Error(String(error));
|
|
35
|
+
}
|
|
20
36
|
//# sourceMappingURL=read-input.js.map
|
package/dist/read-input.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"read-input.js","sourceRoot":"","sources":["../src/read-input.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"read-input.js","sourceRoot":"","sources":["../src/read-input.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAEvC,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,IAAwB;IACtD,IAAI,CAAC,IAAI,IAAI,IAAI,KAAK,GAAG,EAAE,CAAC;QAC1B,IAAI,OAAO,CAAC,KAAK,CAAC,KAAK,IAAI,IAAI,KAAK,GAAG,EAAE,CAAC;YACxC,MAAM,IAAI,UAAU,CAAC,6EAA6E,CAAC,CAAC;QACtG,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AI,KAAK,CAAC,sBAAsB,IAAI,EAAE,CAAC,CAAC;IACtE,OAAO,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;AACnE,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# Examples
|
|
2
|
+
|
|
3
|
+
These files ship in the npm package. After a git clone they live in `examples/`; after `npm i -g` use `--demo` or point at the files in the cloned repo.
|
|
4
|
+
|
|
5
|
+
## 30-second walkthrough: `run.jsonl`
|
|
6
|
+
|
|
7
|
+
A coding agent is told the login test is flaky. It reads the spec and auth module, patches both, fails `run_tests` once (cookie set after redirect), then recovers.
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
agent-trace examples/run.jsonl
|
|
11
|
+
agent-trace --stats examples/run.jsonl
|
|
12
|
+
agent-trace --fail-on-error examples/run.jsonl; echo $? # 1 — the run had a failure
|
|
13
|
+
agent-trace --spicy examples/run.jsonl
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
What to look for:
|
|
17
|
+
|
|
18
|
+
- Step 13 is `error run_tests` — the flake still reproduced.
|
|
19
|
+
- The footer is the autopsy: 19 steps, 7 tool calls, 1 failure, ~15s.
|
|
20
|
+
- `--spicy` names the failed tool without sending the log anywhere unless an API key is set.
|
|
21
|
+
|
|
22
|
+
This is the fixture `--demo` renders.
|
|
23
|
+
|
|
24
|
+
## Other shapes
|
|
25
|
+
|
|
26
|
+
| File | Shape | Why it's here |
|
|
27
|
+
| --- | --- | --- |
|
|
28
|
+
| `run.jsonl` | JSONL events (`role` / `type` / `tool`) | Realistic coding-agent debug loop |
|
|
29
|
+
| `openai.json` | Chat Completions `tool_calls` | Dump a `chat.completion` object as-is |
|
|
30
|
+
| `langchain.json` | LangSmith run tree (`child_runs`) | Flatten a nested executor trace |
|
|
31
|
+
| `generic.json` | `{ type, name, content, ts }[]` | Lowest-common-denominator if you emit your own log |
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
agent-trace examples/openai.json
|
|
35
|
+
agent-trace examples/langchain.json
|
|
36
|
+
agent-trace --json examples/generic.json
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Pipe your own dump:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
cat /tmp/agent.jsonl | agent-trace --stats
|
|
43
|
+
agent-trace --fail-on-error --stats traces/ci.jsonl
|
|
44
|
+
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webywz/agent-trace",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Turn messy agent run logs into a readable timeline.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -21,10 +21,10 @@
|
|
|
21
21
|
"README.md"
|
|
22
22
|
],
|
|
23
23
|
"scripts": {
|
|
24
|
-
"build": "tsc",
|
|
24
|
+
"build": "tsc && node scripts/chmod-cli.mjs",
|
|
25
25
|
"test": "tsx --test test/*.test.ts",
|
|
26
26
|
"dev": "tsx src/cli.ts",
|
|
27
|
-
"prepublishOnly": "npm test && npm run build
|
|
27
|
+
"prepublishOnly": "npm test && npm run build"
|
|
28
28
|
},
|
|
29
29
|
"engines": {
|
|
30
30
|
"node": ">=18"
|