@nodetool-ai/cli-execution 0.0.0-stage → 0.8.9-beta.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.
Files changed (103) hide show
  1. package/dist/.nodetool-build-stamp +1 -0
  2. package/dist/debug/browser-runner.d.ts +21 -0
  3. package/dist/debug/browser-runner.d.ts.map +1 -0
  4. package/dist/debug/browser-runner.js +196 -0
  5. package/dist/debug/browser-runner.js.map +1 -0
  6. package/dist/debug/collector.d.ts +9 -0
  7. package/dist/debug/collector.d.ts.map +1 -0
  8. package/dist/debug/collector.js +9 -0
  9. package/dist/debug/collector.js.map +1 -0
  10. package/dist/debug/diff.d.ts +48 -0
  11. package/dist/debug/diff.d.ts.map +1 -0
  12. package/dist/debug/diff.js +68 -0
  13. package/dist/debug/diff.js.map +1 -0
  14. package/dist/debug/harness.d.ts +11 -0
  15. package/dist/debug/harness.d.ts.map +1 -0
  16. package/dist/debug/harness.js +102 -0
  17. package/dist/debug/harness.js.map +1 -0
  18. package/dist/debug/index.d.ts +17 -0
  19. package/dist/debug/index.d.ts.map +1 -0
  20. package/dist/debug/index.js +16 -0
  21. package/dist/debug/index.js.map +1 -0
  22. package/dist/debug/markdown.d.ts +3 -0
  23. package/dist/debug/markdown.d.ts.map +1 -0
  24. package/dist/debug/markdown.js +127 -0
  25. package/dist/debug/markdown.js.map +1 -0
  26. package/dist/debug/server-runner.d.ts +24 -0
  27. package/dist/debug/server-runner.d.ts.map +1 -0
  28. package/dist/debug/server-runner.js +211 -0
  29. package/dist/debug/server-runner.js.map +1 -0
  30. package/dist/debug/target.d.ts +34 -0
  31. package/dist/debug/target.d.ts.map +1 -0
  32. package/dist/debug/target.js +95 -0
  33. package/dist/debug/target.js.map +1 -0
  34. package/dist/debug/trace.d.ts +30 -0
  35. package/dist/debug/trace.d.ts.map +1 -0
  36. package/dist/debug/trace.js +87 -0
  37. package/dist/debug/trace.js.map +1 -0
  38. package/dist/debug/types.d.ts +82 -0
  39. package/dist/debug/types.d.ts.map +1 -0
  40. package/dist/debug/types.js +13 -0
  41. package/dist/debug/types.js.map +1 -0
  42. package/dist/debug/verdict.d.ts +3 -0
  43. package/dist/debug/verdict.d.ts.map +1 -0
  44. package/dist/debug/verdict.js +78 -0
  45. package/dist/debug/verdict.js.map +1 -0
  46. package/dist/debug/watch.d.ts +23 -0
  47. package/dist/debug/watch.d.ts.map +1 -0
  48. package/dist/debug/watch.js +68 -0
  49. package/dist/debug/watch.js.map +1 -0
  50. package/dist/index.d.ts +3 -0
  51. package/dist/index.d.ts.map +1 -0
  52. package/dist/index.js +3 -0
  53. package/dist/index.js.map +1 -0
  54. package/dist/local-model-interfaces.d.ts +20 -0
  55. package/dist/local-model-interfaces.d.ts.map +1 -0
  56. package/dist/local-model-interfaces.js +39 -0
  57. package/dist/local-model-interfaces.js.map +1 -0
  58. package/dist/node/run-node.d.ts +31 -0
  59. package/dist/node/run-node.d.ts.map +1 -0
  60. package/dist/node/run-node.js +92 -0
  61. package/dist/node/run-node.js.map +1 -0
  62. package/dist/node-registry.d.ts +29 -0
  63. package/dist/node-registry.d.ts.map +1 -0
  64. package/dist/node-registry.js +38 -0
  65. package/dist/node-registry.js.map +1 -0
  66. package/dist/packs/host.d.ts +14 -0
  67. package/dist/packs/host.d.ts.map +1 -0
  68. package/dist/packs/host.js +38 -0
  69. package/dist/packs/host.js.map +1 -0
  70. package/dist/run-budget.d.ts +40 -0
  71. package/dist/run-budget.d.ts.map +1 -0
  72. package/dist/run-budget.js +119 -0
  73. package/dist/run-budget.js.map +1 -0
  74. package/dist/run-dsl-supervised.d.ts +11 -0
  75. package/dist/run-dsl-supervised.d.ts.map +1 -0
  76. package/dist/run-dsl-supervised.js +89 -0
  77. package/dist/run-dsl-supervised.js.map +1 -0
  78. package/dist/run-dsl.d.ts +40 -0
  79. package/dist/run-dsl.d.ts.map +1 -0
  80. package/dist/run-dsl.js +65 -0
  81. package/dist/run-dsl.js.map +1 -0
  82. package/dist/run-json.d.ts +24 -0
  83. package/dist/run-json.d.ts.map +1 -0
  84. package/dist/run-json.js +132 -0
  85. package/dist/run-json.js.map +1 -0
  86. package/dist/sandbox-catalog.d.ts +26 -0
  87. package/dist/sandbox-catalog.d.ts.map +1 -0
  88. package/dist/sandbox-catalog.js +83 -0
  89. package/dist/sandbox-catalog.js.map +1 -0
  90. package/dist/supervisor.d.ts +97 -0
  91. package/dist/supervisor.d.ts.map +1 -0
  92. package/dist/supervisor.js +194 -0
  93. package/dist/supervisor.js.map +1 -0
  94. package/dist/validate/index.d.ts +29 -0
  95. package/dist/validate/index.d.ts.map +1 -0
  96. package/dist/validate/index.js +79 -0
  97. package/dist/validate/index.js.map +1 -0
  98. package/dist/workflow-file.d.ts +3 -0
  99. package/dist/workflow-file.d.ts.map +1 -0
  100. package/dist/workflow-file.js +176 -0
  101. package/dist/workflow-file.js.map +1 -0
  102. package/package.json +70 -4
  103. package/README.md +0 -3
@@ -0,0 +1 @@
1
+ 2026-10-31T09:12:00.510Z
@@ -0,0 +1,21 @@
1
+ import type { BrowserRunReport, DebugGraph } from "./types.js";
2
+ export interface BrowserRunInput {
3
+ graph: DebugGraph;
4
+ params: Record<string, unknown>;
5
+ /** Bundle dir for the browser surface; record/screenshot/console land here. */
6
+ outDir: string;
7
+ /** Capture a screenshot at every run stage (expensive) vs. only the final frame. */
8
+ captureStages?: boolean;
9
+ timeoutMs?: number;
10
+ /** Stream the Playwright child's stdout/stderr through. */
11
+ onLog?: (line: string) => void;
12
+ }
13
+ export declare function runInBrowser(input: BrowserRunInput): Promise<BrowserRunReport>;
14
+ /**
15
+ * Fold the artifacts a Playwright debug run leaves in `outDir`
16
+ * (record.json, console-errors.log, screenshot.png) into a `BrowserRunReport`.
17
+ * Pure file IO — separated from the spawn so it's directly testable against a
18
+ * real captured bundle.
19
+ */
20
+ export declare function buildBrowserReport(outDir: string, exitCode?: number): Promise<BrowserRunReport>;
21
+ //# sourceMappingURL=browser-runner.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"browser-runner.d.ts","sourceRoot":"","sources":["../../src/debug/browser-runner.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAkB/D,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,UAAU,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,+EAA+E;IAC/E,MAAM,EAAE,MAAM,CAAC;IACf,oFAAoF;IACpF,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,2DAA2D;IAC3D,KAAK,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CAChC;AAgED,wBAAsB,YAAY,CAChC,KAAK,EAAE,eAAe,GACrB,OAAO,CAAC,gBAAgB,CAAC,CAmE3B;AAED;;;;;GAKG;AACH,wBAAsB,kBAAkB,CACtC,MAAM,EAAE,MAAM,EACd,QAAQ,SAAI,GACX,OAAO,CAAC,gBAAgB,CAAC,CAsD3B"}
@@ -0,0 +1,196 @@
1
+ /**
2
+ * Real-browser ("browser") debug surface: drives the `e2e_runner` harness page
3
+ * in headless Chromium via Playwright to execute the workflow end-to-end through
4
+ * the actual web stack, capturing browser console errors, a canvas screenshot,
5
+ * and the same logs / node IO / outputs the server surface reports.
6
+ *
7
+ * The heavy lifting (Vite + hermetic backend + the harness page) already exists
8
+ * in `web/`; this module just resolves the web workspace, shells out to the
9
+ * Playwright spec, and folds the resulting RunRecord into a `BrowserRunReport`.
10
+ * It degrades gracefully (an `unavailableReason`) when the web deps or browser
11
+ * binaries aren't installed.
12
+ */
13
+ import { spawn } from "node:child_process";
14
+ import { existsSync } from "node:fs";
15
+ import { mkdir, readFile, writeFile } from "node:fs/promises";
16
+ import { dirname, join } from "node:path";
17
+ import { fileURLToPath } from "node:url";
18
+ import { collectExecutionSummary } from "./collector.js";
19
+ const CONFIG_REL = "playwright.debug-harness.config.ts";
20
+ const DEFAULT_TIMEOUT_MS = 6 * 60_000;
21
+ /** Walk up from this module to the repo root (the dir whose `web/` has our config). */
22
+ function findWebDir() {
23
+ let dir = dirname(fileURLToPath(import.meta.url));
24
+ for (let i = 0; i < 8; i++) {
25
+ const candidate = join(dir, "web");
26
+ if (existsSync(join(candidate, CONFIG_REL)))
27
+ return candidate;
28
+ const parent = dirname(dir);
29
+ if (parent === dir)
30
+ break;
31
+ dir = parent;
32
+ }
33
+ return null;
34
+ }
35
+ /** Grace period between SIGTERM and SIGKILL when tearing down the child's process group. */
36
+ const GROUP_KILL_GRACE_MS = 5_000;
37
+ /**
38
+ * Kill the Playwright child on timeout. Playwright's webServer (Vite) and the
39
+ * tsx e2e backend spawned by globalSetup are children of this process, not of
40
+ * `child` itself, so a plain `child.kill()` orphans them holding ports
41
+ * 3000/7777. On POSIX, `child` is spawned detached (its own process group), so
42
+ * we can kill the whole group via the negative pid; on win32 (no process
43
+ * groups, and no `shell: true` here) fall back to killing just the child.
44
+ */
45
+ function killChild(child) {
46
+ if (process.platform !== "win32" && child.pid !== undefined) {
47
+ const pgid = child.pid;
48
+ try {
49
+ process.kill(-pgid, "SIGTERM");
50
+ }
51
+ catch {
52
+ // Process group may already be gone.
53
+ }
54
+ setTimeout(() => {
55
+ try {
56
+ process.kill(-pgid, "SIGKILL");
57
+ }
58
+ catch {
59
+ // Process group may already be gone.
60
+ }
61
+ }, GROUP_KILL_GRACE_MS).unref();
62
+ return;
63
+ }
64
+ try {
65
+ child.kill("SIGKILL");
66
+ }
67
+ catch {
68
+ // Already exited.
69
+ }
70
+ }
71
+ function unavailable(reason) {
72
+ return {
73
+ surface: "browser",
74
+ ok: false,
75
+ status: "unavailable",
76
+ error: null,
77
+ durationMs: null,
78
+ summary: collectExecutionSummary([]),
79
+ consoleErrors: [],
80
+ unavailableReason: reason
81
+ };
82
+ }
83
+ export async function runInBrowser(input) {
84
+ const webDir = findWebDir();
85
+ if (!webDir)
86
+ return unavailable("could not locate the web workspace");
87
+ const playwrightBin = join(webDir, "node_modules", ".bin", "playwright");
88
+ if (!existsSync(playwrightBin)) {
89
+ return unavailable("web dependencies not installed (run `npm install` and `npx playwright install chromium`)");
90
+ }
91
+ await mkdir(input.outDir, { recursive: true });
92
+ const graphPath = join(input.outDir, "_graph.json");
93
+ await writeFile(graphPath, JSON.stringify({ graph: input.graph }), "utf8");
94
+ const env = {
95
+ ...process.env,
96
+ NODETOOL_DEBUG_GRAPH: graphPath,
97
+ NODETOOL_DEBUG_OUT: input.outDir,
98
+ NODETOOL_DEBUG_PARAMS: JSON.stringify(input.params ?? {})
99
+ };
100
+ if (input.captureStages) {
101
+ env.NODETOOL_DEBUG_STAGES = "1";
102
+ }
103
+ // Read by debug.spec.ts to arm the in-page run's own timeout, so the
104
+ // Playwright spec doesn't fall back to its internal RUN_TIMEOUT_MS cap.
105
+ if (input.timeoutMs) {
106
+ env.NODETOOL_DEBUG_TIMEOUT = String(input.timeoutMs);
107
+ }
108
+ // The child-kill timer below is the outer backstop; it must stay comfortably
109
+ // above the in-page timeout the spec applies, or the child gets killed
110
+ // before the harness can settle and write record.json.
111
+ const killTimeoutMs = input.timeoutMs !== undefined
112
+ ? Math.max(input.timeoutMs + 60_000, DEFAULT_TIMEOUT_MS)
113
+ : DEFAULT_TIMEOUT_MS;
114
+ const isWindows = process.platform === "win32";
115
+ const exitCode = await new Promise((resolvePromise) => {
116
+ const child = spawn(playwrightBin, ["test", "-c", CONFIG_REL], {
117
+ cwd: webDir,
118
+ env,
119
+ stdio: ["ignore", "pipe", "pipe"],
120
+ // .bin/playwright is a shell shim on win32 (no .exe), so it needs a
121
+ // shell to resolve; shell mode has no process groups, so detach only
122
+ // on POSIX where killChild can use them for whole-tree teardown.
123
+ ...(isWindows ? { shell: true } : { detached: true })
124
+ });
125
+ const onChunk = (buf) => input.onLog?.(buf.toString());
126
+ child.stdout?.on("data", onChunk);
127
+ child.stderr?.on("data", onChunk);
128
+ const timer = setTimeout(() => {
129
+ killChild(child);
130
+ resolvePromise(124);
131
+ }, killTimeoutMs);
132
+ child.on("error", () => {
133
+ clearTimeout(timer);
134
+ resolvePromise(127);
135
+ });
136
+ child.on("exit", (code) => {
137
+ clearTimeout(timer);
138
+ resolvePromise(code ?? 1);
139
+ });
140
+ });
141
+ return buildBrowserReport(input.outDir, exitCode);
142
+ }
143
+ /**
144
+ * Fold the artifacts a Playwright debug run leaves in `outDir`
145
+ * (record.json, console-errors.log, screenshot.png) into a `BrowserRunReport`.
146
+ * Pure file IO — separated from the spawn so it's directly testable against a
147
+ * real captured bundle.
148
+ */
149
+ export async function buildBrowserReport(outDir, exitCode = 0) {
150
+ const recordPath = join(outDir, "record.json");
151
+ if (!existsSync(recordPath)) {
152
+ return unavailable(`Playwright run produced no record (exit ${exitCode}); check that the web app builds and chromium is installed`);
153
+ }
154
+ let record;
155
+ try {
156
+ record = JSON.parse(await readFile(recordPath, "utf8"));
157
+ }
158
+ catch (err) {
159
+ return unavailable(`could not parse browser record: ${String(err)}`);
160
+ }
161
+ const consoleErrors = existsSync(join(outDir, "console-errors.log"))
162
+ ? (await readFile(join(outDir, "console-errors.log"), "utf8"))
163
+ .split("\n")
164
+ .filter(Boolean)
165
+ : [];
166
+ const summary = collectExecutionSummary(record.events ?? []);
167
+ const status = record.status ?? summary.status;
168
+ const report = {
169
+ surface: "browser",
170
+ ok: status === "completed",
171
+ status,
172
+ error: record.error ?? summary.error,
173
+ durationMs: record.durationMs ?? null,
174
+ summary,
175
+ consoleErrors,
176
+ recordFile: "browser/record.json"
177
+ };
178
+ if (existsSync(join(outDir, "screenshot.png"))) {
179
+ report.screenshotFile = "browser/screenshot.png";
180
+ }
181
+ if (existsSync(join(outDir, "stages.json"))) {
182
+ try {
183
+ const stages = JSON.parse(await readFile(join(outDir, "stages.json"), "utf8"));
184
+ report.stages = stages.map((s) => ({
185
+ index: s.index,
186
+ status: s.status,
187
+ file: `browser/${s.file}`
188
+ }));
189
+ }
190
+ catch {
191
+ // A malformed stages manifest just means no staged screenshots.
192
+ }
193
+ }
194
+ return report;
195
+ }
196
+ //# sourceMappingURL=browser-runner.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"browser-runner.js","sourceRoot":"","sources":["../../src/debug/browser-runner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,KAAK,EAAqB,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC9D,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAGzD,MAAM,UAAU,GAAG,oCAAoC,CAAC;AACxD,MAAM,kBAAkB,GAAG,CAAC,GAAG,MAAM,CAAC;AAEtC,uFAAuF;AACvF,SAAS,UAAU;IACjB,IAAI,GAAG,GAAG,OAAO,CAAC,aAAa,CAAC,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;IAClD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QAC3B,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QACnC,IAAI,UAAU,CAAC,IAAI,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;YAAE,OAAO,SAAS,CAAC;QAC9D,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;QAC5B,IAAI,MAAM,KAAK,GAAG;YAAE,MAAM;QAC1B,GAAG,GAAG,MAAM,CAAC;IACf,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AA4BD,4FAA4F;AAC5F,MAAM,mBAAmB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ACrC,OAAO;QACP,aAAa;QACb,UAAU,EAAE,qBAAqB;KAClC,CAAC;IACF,IAAI,UAAU,CAAC,IAAI,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC,EAAE,CAAC;QAC/C,MAAM,CAAC,cAAc,GAAG,wBAAwB,CAAC;IACnD,CAAC;IAED,IAAI,UAAU,CAAC,IAAI,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC,EAAE,CAAC;QAC5C,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CACvB,MAAM,QAAQ,CAAC,IAAI,CAAC,MAAM,EAAE,aAAa,CAAC,EAAE,MAAM,CAAC,CACpC,CAAC;YAClB,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;gBACjC,KAAK,EAAE,CAAC,CAAC,KAAK;gBACd,MAAM,EAAE,CAAC,CAAC,MAAM;gBAChB,IAAI,EAAE,WAAW,CAAC,CAAC,IAAI,EAAE;aAC1B,CAAC,CAAC,CAAC;QACN,CAAC;QAAC,MAAM,CAAC;YACP,gEAAgE;QAClE,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Re-export of the shared execution-summary collector.
3
+ *
4
+ * The reducer lives in `@nodetool-ai/execution` so the CLI harness, the HTTP
5
+ * debug endpoint and the agent-facing `debug_workflow` tool all distill a run
6
+ * the same way. This module keeps the CLI's original import path.
7
+ */
8
+ export { collectExecutionSummary, previewValue } from "@nodetool-ai/execution/debug";
9
+ //# sourceMappingURL=collector.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"collector.d.ts","sourceRoot":"","sources":["../../src/debug/collector.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EACL,uBAAuB,EACvB,YAAY,EACb,MAAM,8BAA8B,CAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Re-export of the shared execution-summary collector.
3
+ *
4
+ * The reducer lives in `@nodetool-ai/execution` so the CLI harness, the HTTP
5
+ * debug endpoint and the agent-facing `debug_workflow` tool all distill a run
6
+ * the same way. This module keeps the CLI's original import path.
7
+ */
8
+ export { collectExecutionSummary, previewValue } from "@nodetool-ai/execution/debug";
9
+ //# sourceMappingURL=collector.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"collector.js","sourceRoot":"","sources":["../../src/debug/collector.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EACL,uBAAuB,EACvB,YAAY,EACb,MAAM,8BAA8B,CAAC"}
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Diffs two harness runs so watch mode can show only what changed between
3
+ * edits: status transitions, newly-appeared and resolved issues, and token/cost
4
+ * movement.
5
+ *
6
+ * The diff works on a {@link RunSnapshot} — ok, issues, one status word, and
7
+ * the run's totals — so every watchable harness shares one differ. `debug`
8
+ * projects a {@link DebugReport} into it; `app build` projects a `BuildReport`.
9
+ * Pure (types only), so it is unit-tested directly.
10
+ */
11
+ import type { DebugReport } from "./types.js";
12
+ /** What a differ needs from a run, whatever harness produced it. */
13
+ export interface RunSnapshot {
14
+ ok: boolean;
15
+ /** Everything wrong right now, not a delta. */
16
+ issues: string[];
17
+ /** One word for the run's main surface, e.g. `completed` or `run/failed`. */
18
+ status: string | null;
19
+ tokens: number | null;
20
+ costUsd: number | null;
21
+ }
22
+ export interface DebugDiff {
23
+ /** Verdict ok transition, when it changed. */
24
+ okChanged: {
25
+ from: boolean;
26
+ to: boolean;
27
+ } | null;
28
+ /** Status transition, when it changed. */
29
+ serverStatusChanged: {
30
+ from: string | null;
31
+ to: string | null;
32
+ } | null;
33
+ /** Issues present now but not before. */
34
+ newIssues: string[];
35
+ /** Issues present before but not now. */
36
+ resolvedIssues: string[];
37
+ /** Token/cost deltas, when both runs reported them. */
38
+ tokenDelta: number | null;
39
+ costDelta: number | null;
40
+ }
41
+ /** Project a workflow debug report into the shape the differ reads. */
42
+ export declare function snapshotDebugReport(report: DebugReport): RunSnapshot;
43
+ export declare function diffRuns(prev: RunSnapshot, next: RunSnapshot): DebugDiff;
44
+ export declare function diffReports(prev: DebugReport, next: DebugReport): DebugDiff;
45
+ /** True when nothing an agent would act on changed between two runs. */
46
+ export declare function diffIsEmpty(diff: DebugDiff): boolean;
47
+ export declare function formatDiff(diff: DebugDiff, statusLabel?: string): string;
48
+ //# sourceMappingURL=diff.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"diff.d.ts","sourceRoot":"","sources":["../../src/debug/diff.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C,oEAAoE;AACpE,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,OAAO,CAAC;IACZ,+CAA+C;IAC/C,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,6EAA6E;IAC7E,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;CACxB;AAED,MAAM,WAAW,SAAS;IACxB,8CAA8C;IAC9C,SAAS,EAAE;QAAE,IAAI,EAAE,OAAO,CAAC;QAAC,EAAE,EAAE,OAAO,CAAA;KAAE,GAAG,IAAI,CAAC;IACjD,0CAA0C;IAC1C,mBAAmB,EAAE;QAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;QAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,GAAG,IAAI,CAAC;IACvE,yCAAyC;IACzC,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,yCAAyC;IACzC,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,uDAAuD;IACvD,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B;AAED,uEAAuE;AACvE,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,WAAW,GAAG,WAAW,CASpE;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,WAAW,GAAG,SAAS,CAwBxE;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,WAAW,GAAG,SAAS,CAE3E;AAED,wEAAwE;AACxE,wBAAgB,WAAW,CAAC,IAAI,EAAE,SAAS,GAAG,OAAO,CAOpD;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,SAAS,EAAE,WAAW,SAAW,GAAG,MAAM,CA0B1E"}
@@ -0,0 +1,68 @@
1
+ /** Project a workflow debug report into the shape the differ reads. */
2
+ export function snapshotDebugReport(report) {
3
+ const trace = report.server?.trace;
4
+ return {
5
+ ok: report.verdict.ok,
6
+ issues: report.verdict.issues,
7
+ status: report.server ? report.server.status : null,
8
+ tokens: trace ? trace.tokens.total : null,
9
+ costUsd: trace ? trace.costUsd : null
10
+ };
11
+ }
12
+ export function diffRuns(prev, next) {
13
+ const prevIssues = new Set(prev.issues);
14
+ const nextIssues = new Set(next.issues);
15
+ // Tokens and cost move independently: a build reports what it spent without
16
+ // counting tokens, so one being absent must not suppress the other.
17
+ const tokenDelta = prev.tokens != null && next.tokens != null ? next.tokens - prev.tokens : null;
18
+ const costDelta = prev.costUsd != null && next.costUsd != null
19
+ ? next.costUsd - prev.costUsd
20
+ : null;
21
+ return {
22
+ okChanged: prev.ok !== next.ok ? { from: prev.ok, to: next.ok } : null,
23
+ serverStatusChanged: prev.status !== next.status
24
+ ? { from: prev.status, to: next.status }
25
+ : null,
26
+ newIssues: next.issues.filter((i) => !prevIssues.has(i)),
27
+ resolvedIssues: prev.issues.filter((i) => !nextIssues.has(i)),
28
+ tokenDelta,
29
+ costDelta
30
+ };
31
+ }
32
+ export function diffReports(prev, next) {
33
+ return diffRuns(snapshotDebugReport(prev), snapshotDebugReport(next));
34
+ }
35
+ /** True when nothing an agent would act on changed between two runs. */
36
+ export function diffIsEmpty(diff) {
37
+ return (diff.okChanged === null &&
38
+ diff.serverStatusChanged === null &&
39
+ diff.newIssues.length === 0 &&
40
+ diff.resolvedIssues.length === 0);
41
+ }
42
+ export function formatDiff(diff, statusLabel = "server") {
43
+ if (diffIsEmpty(diff))
44
+ return "No change since last run.";
45
+ const lines = [];
46
+ if (diff.okChanged) {
47
+ lines.push(diff.okChanged.to
48
+ ? "✅ Now passing (was failing)"
49
+ : "❌ Now failing (was passing)");
50
+ }
51
+ if (diff.serverStatusChanged) {
52
+ lines.push(`${statusLabel}: ${diff.serverStatusChanged.from ?? "—"} → ${diff.serverStatusChanged.to ?? "—"}`);
53
+ }
54
+ for (const issue of diff.resolvedIssues)
55
+ lines.push(` - resolved: ${issue}`);
56
+ for (const issue of diff.newIssues)
57
+ lines.push(` + new: ${issue}`);
58
+ if (diff.tokenDelta != null && diff.tokenDelta !== 0) {
59
+ const sign = diff.tokenDelta > 0 ? "+" : "";
60
+ lines.push(`tokens: ${sign}${diff.tokenDelta}`);
61
+ }
62
+ if (diff.costDelta != null && Math.abs(diff.costDelta) > 1e-9) {
63
+ const sign = diff.costDelta > 0 ? "+" : "";
64
+ lines.push(`cost: ${sign}$${diff.costDelta.toFixed(4)}`);
65
+ }
66
+ return lines.join("\n");
67
+ }
68
+ //# sourceMappingURL=diff.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"diff.js","sourceRoot":"","sources":["../../src/debug/diff.ts"],"names":[],"mappings":"AAqCA,uEAAuE;AACvE,MAAM,UAAU,mBAAmB,CAAC,MAAmB;IACrD,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC;IACnC,OAAO;QACL,EAAE,EAAE,MAAM,CAAC,OAAO,CAAC,EAAE;QACrB,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC,MAAM;QAC7B,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,M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CAClG,CAAC;IACJ,CAAC;IACD,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,cAAc;QAAE,KAAK,CAAC,IAAI,CAAC,iBAAiB,KAAK,EAAE,CAAC,CAAC;IAC9E,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,SAAS;QAAE,KAAK,CAAC,IAAI,CAAC,YAAY,KAAK,EAAE,CAAC,CAAC;IACpE,IAAI,IAAI,CAAC,UAAU,IAAI,IAAI,IAAI,IAAI,CAAC,UAAU,KAAK,CAAC,EAAE,CAAC;QACrD,MAAM,IAAI,GAAG,IAAI,CAAC,UAAU,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;QAC5C,KAAK,CAAC,IAAI,CAAC,WAAW,IAAI,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC;IAClD,CAAC;IACD,IAAI,IAAI,CAAC,SAAS,IAAI,IAAI,IAAI,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,CAAC;QAC9D,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;QAC3C,KAAK,CAAC,IAAI,CAAC,SAAS,IAAI,IAAI,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IAC3D,CAAC;IACD,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC"}
@@ -0,0 +1,11 @@
1
+ import type { DebugGraph, DebugOptions, DebugReport } from "./types.js";
2
+ export interface DebugHarnessDeps {
3
+ /** Load a workflow graph by DB id (injected to keep models out of light paths). */
4
+ loadFromDb: (id: string) => Promise<{
5
+ graph: DebugGraph;
6
+ } | null>;
7
+ /** Progress/log sink for surfacing child-process output. */
8
+ onLog?: (line: string) => void;
9
+ }
10
+ export declare function runDebug(ref: string, options: DebugOptions, deps: DebugHarnessDeps): Promise<DebugReport>;
11
+ //# sourceMappingURL=harness.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"harness.d.ts","sourceRoot":"","sources":["../../src/debug/harness.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAExE,MAAM,WAAW,gBAAgB;IAC/B,mFAAmF;IACnF,UAAU,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC;QAAE,KAAK,EAAE,UAAU,CAAA;KAAE,GAAG,IAAI,CAAC,CAAC;IAClE,4DAA4D;IAC5D,KAAK,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CAChC;AAUD,wBAAsB,QAAQ,CAC5B,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,YAAY,EACrB,IAAI,EAAE,gBAAgB,GACrB,OAAO,CAAC,WAAW,CAAC,CA8GtB"}
@@ -0,0 +1,102 @@
1
+ import { trimHyphens } from "@nodetool-ai/cli-common/trimHyphens";
2
+ /**
3
+ * The workflow debug harness orchestrator.
4
+ *
5
+ * Resolves a target workflow, runs it on the requested surfaces (headless server
6
+ * and/or real browser), folds everything into a `DebugReport`, and writes a
7
+ * self-contained debug bundle to disk. Returns the report so an agent can act on
8
+ * it directly and iterate (edit → re-run) without re-reading files.
9
+ */
10
+ import { mkdir, writeFile } from "node:fs/promises";
11
+ import { join, resolve } from "node:path";
12
+ import { initTelemetry } from "@nodetool-ai/runtime";
13
+ import { runOnServer } from "./server-runner.js";
14
+ import { runInBrowser } from "./browser-runner.js";
15
+ import { buildVerdict } from "./verdict.js";
16
+ import { renderReportMarkdown } from "./markdown.js";
17
+ import { resolveTarget } from "./target.js";
18
+ function defaultOutDir(ref) {
19
+ const slug = trimHyphens(ref.replace(/[^a-zA-Z0-9_-]+/g, "-")).slice(0, 40) ||
20
+ "workflow";
21
+ const stamp = new Date().toISOString().replace(/[:.]/g, "-");
22
+ return resolve(`nodetool-debug/${slug}-${stamp}`);
23
+ }
24
+ export async function runDebug(ref, options, deps) {
25
+ const runServer = options.server ?? true;
26
+ // `--stages` is a browser-surface modifier, so opting into it implies the
27
+ // browser surface.
28
+ const runBrowser = (options.browser ?? false) || (options.stages ?? false);
29
+ const captureTrace = options.trace ?? false;
30
+ const log = deps.onLog ?? (() => { });
31
+ // A run with no surface exercises nothing, and the verdict builder scored it
32
+ // "ran clean on no surface" — a green report for a workflow that never ran.
33
+ if (!runServer && !runBrowser) {
34
+ throw new Error("Nothing to debug: --no-server was passed without --browser. Enable at least one surface.");
35
+ }
36
+ const resolved = await resolveTarget(ref, deps.loadFromDb);
37
+ const params = { ...resolved.fileParams, ...(options.params ?? {}) };
38
+ const outDir = options.outDir ? resolve(options.outDir) : defaultOutDir(ref);
39
+ await mkdir(outDir, { recursive: true });
40
+ await writeFile(join(outDir, "workflow.json"), JSON.stringify(resolved.graph, null, 2), "utf8");
41
+ const report = {
42
+ generatedAt: new Date().toISOString(),
43
+ target: resolved.info,
44
+ workflow: resolved.graph,
45
+ server: null,
46
+ browser: null,
47
+ verdict: { ok: false, headline: "", issues: [] },
48
+ bundleDir: outDir
49
+ };
50
+ if (runServer) {
51
+ log("Running workflow on the server surface…");
52
+ const serverDir = join(outDir, "server");
53
+ await mkdir(serverDir, { recursive: true });
54
+ // Tracing is opt-in (`--trace`): loading the OTel SDK and processing spans
55
+ // is real overhead. When enabled, route span output into the bundle — this
56
+ // wins because the `debug` command skips the global telemetry init.
57
+ let tracePath = null;
58
+ if (captureTrace) {
59
+ tracePath = join(serverDir, "trace.jsonl");
60
+ await initTelemetry({ traceFile: tracePath, silent: true });
61
+ }
62
+ const runInput = {
63
+ graph: resolved.graph,
64
+ workflowId: resolved.info.workflowId,
65
+ params,
66
+ tracePath,
67
+ timeoutMs: options.timeoutMs,
68
+ onInterventionLine: log
69
+ };
70
+ if (options.supervisor) {
71
+ runInput.supervisor = options.supervisor;
72
+ }
73
+ const outcome = await runOnServer(runInput);
74
+ const messagesPath = join(serverDir, "messages.jsonl");
75
+ await writeFile(messagesPath, outcome.rawMessages.map((m) => JSON.stringify(m)).join("\n") + "\n", "utf8");
76
+ outcome.report.messagesFile = "server/messages.jsonl";
77
+ if (outcome.report.trace)
78
+ outcome.report.traceFile = "server/trace.jsonl";
79
+ report.server = outcome.report;
80
+ log(`Server run: ${outcome.report.status} · ${outcome.report.summary.counts.errored} node error(s)`);
81
+ }
82
+ if (runBrowser) {
83
+ log("Running workflow on the browser surface (Playwright)…");
84
+ const browserDir = join(outDir, "browser");
85
+ report.browser = await runInBrowser({
86
+ graph: resolved.graph,
87
+ params,
88
+ outDir: browserDir,
89
+ captureStages: options.stages ?? false,
90
+ timeoutMs: options.timeoutMs,
91
+ onLog: log
92
+ });
93
+ log(report.browser.unavailableReason
94
+ ? `Browser run skipped: ${report.browser.unavailableReason}`
95
+ : `Browser run: ${report.browser.status} · ${report.browser.consoleErrors.length} console error(s)`);
96
+ }
97
+ report.verdict = buildVerdict(report.server, report.browser);
98
+ await writeFile(join(outDir, "report.json"), JSON.stringify(report, null, 2), "utf8");
99
+ await writeFile(join(outDir, "report.md"), renderReportMarkdown(report), "utf8");
100
+ return report;
101
+ }
102
+ //# sourceMappingURL=harness.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"harness.js","sourceRoot":"","sources":["../../src/debug/harness.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,qCAAqC,CAAC;AAClE;;;;;;;GAOG;AACH,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,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M,CAAC,OAAO,GAAG,MAAM,YAAY,CAAC;YAClC,KAAK,EAAE,QAAQ,CAAC,KAAK;YACrB,MAAM;YACN,MAAM,EAAE,UAAU;YAClB,aAAa,EAAE,OAAO,CAAC,MAAM,IAAI,KAAK;YACtC,SAAS,EAAE,OAAO,CAAC,SAAS;YAC5B,KAAK,EAAE,GAAG;SACX,CAAC,CAAC;QACH,GAAG,CACD,MAAM,CAAC,OAAO,CAAC,iBAAiB;YAC9B,CAAC,CAAC,wBAAwB,MAAM,CAAC,OAAO,CAAC,iBAAiB,EAAE;YAC5D,CAAC,CAAC,gBAAgB,MAAM,CAAC,OAAO,CAAC,MAAM,MAAM,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,mBAAmB,CACtG,CAAC;IACJ,CAAC;IAED,MAAM,CAAC,OAAO,GAAG,YAAY,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC;IAE7D,MAAM,SAAS,CACb,IAAI,CAAC,MAAM,EAAE,aAAa,CAAC,EAC3B,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,EAC/B,MAAM,CACP,CAAC;IACF,MAAM,SAAS,CACb,IAAI,CAAC,MAAM,EAAE,WAAW,CAAC,EACzB,oBAAoB,CAAC,MAAM,CAAC,EAC5B,MAAM,CACP,CAAC;IAEF,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Workflow debug harness — runs a workflow end-to-end on the server and/or in a
3
+ * real browser and collects the workflow JSON, every log/output/error, and an
4
+ * OpenTelemetry trace summary into a single `DebugReport` + on-disk bundle.
5
+ */
6
+ export { runDebug, type DebugHarnessDeps } from "./harness.js";
7
+ export { runOnServer, type ServerRunInput, type ServerRunOutcome } from "./server-runner.js";
8
+ export { runInBrowser, buildBrowserReport, type BrowserRunInput } from "./browser-runner.js";
9
+ export { resolveTarget, type ResolvedTarget } from "./target.js";
10
+ export { collectExecutionSummary, previewValue } from "./collector.js";
11
+ export { parseTraceJsonl, summarizeSpans, readTraceSummary, type TraceSpan } from "./trace.js";
12
+ export { buildVerdict } from "./verdict.js";
13
+ export { renderReportMarkdown } from "./markdown.js";
14
+ export { diffReports, diffRuns, diffIsEmpty, formatDiff, snapshotDebugReport, type DebugDiff, type RunSnapshot } from "./diff.js";
15
+ export { runWatchLoop, type FileWatcher, type WatchLoopInit } from "./watch.js";
16
+ export type * from "./types.js";
17
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/debug/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,QAAQ,EAAE,KAAK,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,KAAK,cAAc,EAAE,KAAK,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC7F,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,KAAK,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC7F,OAAO,EAAE,aAAa,EAAE,KAAK,cAAc,EAAE,MAAM,aAAa,CAAC;AACjE,OAAO,EAAE,uBAAuB,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACvE,OAAO,EACL,eAAe,EACf,cAAc,EACd,gBAAgB,EAChB,KAAK,SAAS,EACf,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EACL,WAAW,EACX,QAAQ,EACR,WAAW,EACX,UAAU,EACV,mBAAmB,EACnB,KAAK,SAAS,EACd,KAAK,WAAW,EACjB,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,YAAY,EAAE,KAAK,WAAW,EAAE,KAAK,aAAa,EAAE,MAAM,YAAY,CAAC;AAChF,mBAAmB,YAAY,CAAC"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Workflow debug harness — runs a workflow end-to-end on the server and/or in a
3
+ * real browser and collects the workflow JSON, every log/output/error, and an
4
+ * OpenTelemetry trace summary into a single `DebugReport` + on-disk bundle.
5
+ */
6
+ export { runDebug } from "./harness.js";
7
+ export { runOnServer } from "./server-runner.js";
8
+ export { runInBrowser, buildBrowserReport } from "./browser-runner.js";
9
+ export { resolveTarget } from "./target.js";
10
+ export { collectExecutionSummary, previewValue } from "./collector.js";
11
+ export { parseTraceJsonl, summarizeSpans, readTraceSummary } from "./trace.js";
12
+ export { buildVerdict } from "./verdict.js";
13
+ export { renderReportMarkdown } from "./markdown.js";
14
+ export { diffReports, diffRuns, diffIsEmpty, formatDiff, snapshotDebugReport } from "./diff.js";
15
+ export { runWatchLoop } from "./watch.js";
16
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/debug/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,QAAQ,EAAyB,MAAM,cAAc,CAAC;AAC/D,OAAO,EAAE,WAAW,EAA8C,MAAM,oBAAoB,CAAC;AAC7F,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAwB,MAAM,qBAAqB,CAAC;AAC7F,OAAO,EAAE,aAAa,EAAuB,MAAM,aAAa,CAAC;AACjE,OAAO,EAAE,uBAAuB,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACvE,OAAO,EACL,eAAe,EACf,cAAc,EACd,gBAAgB,EAEjB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EACL,WAAW,EACX,QAAQ,EACR,WAAW,EACX,UAAU,EACV,mBAAmB,EAGpB,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,YAAY,EAAwC,MAAM,YAAY,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { DebugReport } from "./types.js";
2
+ export declare function renderReportMarkdown(report: DebugReport): string;
3
+ //# sourceMappingURL=markdown.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"markdown.d.ts","sourceRoot":"","sources":["../../src/debug/markdown.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAEV,WAAW,EAIZ,MAAM,YAAY,CAAC;AAwHpB,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,WAAW,GAAG,MAAM,CAsBhE"}