@sweny-ai/core 0.1.95 → 0.1.96
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/dist/cli/verbose-observer.d.ts +13 -13
- package/dist/cli/verbose-observer.js +28 -19
- package/package.json +1 -1
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import type { Observer } from "../types.js";
|
|
2
2
|
/**
|
|
3
|
-
* Create an observer that prints
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
3
|
+
* Create an observer that prints, on `node:exit`:
|
|
4
|
+
* 1. Every tool call's input and output (truncated).
|
|
5
|
+
* 2. The node's structured output (`result.data`) — the payload that
|
|
6
|
+
* conditional edges route on. Without this, "validate → notify_halt"
|
|
7
|
+
* with no failing checks looks like a paradox; with it, you can see
|
|
8
|
+
* that the node emitted `{ status: "fail" }` and root-cause the wrong
|
|
9
|
+
* decision.
|
|
7
10
|
*
|
|
8
|
-
*
|
|
9
|
-
* `
|
|
10
|
-
*
|
|
11
|
-
* Claude Code subprocess's built-in tools (Bash, Read, Edit, etc.). Those
|
|
12
|
-
* built-in tools — the ones agents actually use most — land in
|
|
13
|
-
* `result.toolCalls` only after the node completes. Walking result.toolCalls
|
|
14
|
-
* on node:exit covers both kinds and avoids partial visibility.
|
|
11
|
+
* Both kinds of tools are covered (skill-registered AND Claude Code's
|
|
12
|
+
* built-in Bash/Read/Edit/Write), because `result.toolCalls` is populated
|
|
13
|
+
* after the node completes regardless of how the call was dispatched.
|
|
15
14
|
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
15
|
+
* Truncation defaults to 4000 chars per side. Override with the
|
|
16
|
+
* `SWENY_VERBOSE_TRUNCATE` env var for ad-hoc debugging. Use `--stream` for
|
|
17
|
+
* the full untruncated NDJSON.
|
|
18
18
|
*/
|
|
19
19
|
export declare function createVerboseToolObserver(): Observer;
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import chalk from "chalk";
|
|
2
|
-
|
|
2
|
+
// Default truncation, large enough to fit a 14-item validation checklist JSON
|
|
3
|
+
// without losing the bottom (passed/failed totals). Overridable via env var
|
|
4
|
+
// for ad-hoc debugging when even this isn't enough.
|
|
5
|
+
const TRUNCATE = Number.parseInt(process.env.SWENY_VERBOSE_TRUNCATE ?? "4000", 10) || 4000;
|
|
3
6
|
function truncate(s) {
|
|
4
7
|
return s.length > TRUNCATE
|
|
5
8
|
? `${s.slice(0, TRUNCATE)}\n ${chalk.dim(`… [${s.length - TRUNCATE} more chars]`)}`
|
|
@@ -29,33 +32,39 @@ function printCall(call) {
|
|
|
29
32
|
process.stderr.write(` ${chalk.dim("←")} ${chalk.cyan(call.tool)} ${status}\n`);
|
|
30
33
|
process.stderr.write(` ${chalk.dim(indent(truncate(fmt(call.output))))}\n`);
|
|
31
34
|
}
|
|
35
|
+
function printData(node, data) {
|
|
36
|
+
if (!data || Object.keys(data).length === 0)
|
|
37
|
+
return;
|
|
38
|
+
process.stderr.write(` ${chalk.bold.dim(`${node}: output`)}\n`);
|
|
39
|
+
process.stderr.write(` ${chalk.dim(indent(truncate(fmt(data))))}\n`);
|
|
40
|
+
}
|
|
32
41
|
/**
|
|
33
|
-
* Create an observer that prints
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
42
|
+
* Create an observer that prints, on `node:exit`:
|
|
43
|
+
* 1. Every tool call's input and output (truncated).
|
|
44
|
+
* 2. The node's structured output (`result.data`) — the payload that
|
|
45
|
+
* conditional edges route on. Without this, "validate → notify_halt"
|
|
46
|
+
* with no failing checks looks like a paradox; with it, you can see
|
|
47
|
+
* that the node emitted `{ status: "fail" }` and root-cause the wrong
|
|
48
|
+
* decision.
|
|
37
49
|
*
|
|
38
|
-
*
|
|
39
|
-
* `
|
|
40
|
-
*
|
|
41
|
-
* Claude Code subprocess's built-in tools (Bash, Read, Edit, etc.). Those
|
|
42
|
-
* built-in tools — the ones agents actually use most — land in
|
|
43
|
-
* `result.toolCalls` only after the node completes. Walking result.toolCalls
|
|
44
|
-
* on node:exit covers both kinds and avoids partial visibility.
|
|
50
|
+
* Both kinds of tools are covered (skill-registered AND Claude Code's
|
|
51
|
+
* built-in Bash/Read/Edit/Write), because `result.toolCalls` is populated
|
|
52
|
+
* after the node completes regardless of how the call was dispatched.
|
|
45
53
|
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
54
|
+
* Truncation defaults to 4000 chars per side. Override with the
|
|
55
|
+
* `SWENY_VERBOSE_TRUNCATE` env var for ad-hoc debugging. Use `--stream` for
|
|
56
|
+
* the full untruncated NDJSON.
|
|
48
57
|
*/
|
|
49
58
|
export function createVerboseToolObserver() {
|
|
50
59
|
return (event) => {
|
|
51
60
|
if (event.type !== "node:exit")
|
|
52
61
|
return;
|
|
53
62
|
const calls = event.result.toolCalls;
|
|
54
|
-
if (calls.length
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
printCall(call);
|
|
63
|
+
if (calls.length > 0) {
|
|
64
|
+
process.stderr.write(` ${chalk.bold.dim(`${event.node}: ${calls.length} tool call${calls.length === 1 ? "" : "s"}`)}\n`);
|
|
65
|
+
for (const call of calls)
|
|
66
|
+
printCall(call);
|
|
59
67
|
}
|
|
68
|
+
printData(event.node, event.result.data);
|
|
60
69
|
};
|
|
61
70
|
}
|