@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,29 @@
1
+ /**
2
+ * Builds a NodeRegistry with installed TypeScript packs and catalog metadata
3
+ * for missing enabled packs. Shared by the debug, validate, and single-node-run harnesses so they
4
+ * all resolve node types against the same set.
5
+ *
6
+ * Python-only node packs (huggingface worker nodes, mlx, etc.) are not
7
+ * registered here — they have no TS class and are resolved lazily through the
8
+ * Python bridge at execution time. Static tools (validate) therefore treat
9
+ * unknown types as "not in the local TS registry".
10
+ */
11
+ import { NodeRegistry, type BuiltinPackPolicy } from "@nodetool-ai/node-sdk";
12
+ /** CLI harnesses expose optional packs independently of user toggles. */
13
+ export declare const CLI_BUILTIN_PACK_POLICY: BuiltinPackPolicy;
14
+ /** Workflow JSON runs and local MCP historically omit AtlasCloud too. */
15
+ export declare const CLI_LOCAL_BUILTIN_PACK_POLICY: {
16
+ includeOptionalPacks?: boolean;
17
+ enabledOverrides?: Readonly<Record<string, boolean>>;
18
+ production?: boolean;
19
+ cloudProfile?: boolean;
20
+ excludedPackIds: string[];
21
+ };
22
+ /** DSL files import provider nodes themselves, so only the required base pack is bootstrapped. */
23
+ export declare const CLI_DSL_BUILTIN_PACK_POLICY: {
24
+ enabledOverrides: {
25
+ [k: string]: boolean;
26
+ };
27
+ };
28
+ export declare function buildFullRegistry(): Promise<NodeRegistry>;
29
+ //# sourceMappingURL=node-registry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"node-registry.d.ts","sourceRoot":"","sources":["../src/node-registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,YAAY,EAAE,KAAK,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAM7E,yEAAyE;AACzE,eAAO,MAAM,uBAAuB,EAAE,iBAGrC,CAAC;AAEF,yEAAyE;AACzE,eAAO,MAAM,6BAA6B;;;;;;CAMzC,CAAC;AAEF,kGAAkG;AAClG,eAAO,MAAM,2BAA2B;IACtC,gBAAgB;;;CAGjB,CAAC;AAEF,wBAAsB,iBAAiB,IAAI,OAAO,CAAC,YAAY,CAAC,CAK/D"}
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Builds a NodeRegistry with installed TypeScript packs and catalog metadata
3
+ * for missing enabled packs. Shared by the debug, validate, and single-node-run harnesses so they
4
+ * all resolve node types against the same set.
5
+ *
6
+ * Python-only node packs (huggingface worker nodes, mlx, etc.) are not
7
+ * registered here — they have no TS class and are resolved lazily through the
8
+ * Python bridge at execution time. Static tools (validate) therefore treat
9
+ * unknown types as "not in the local TS registry".
10
+ */
11
+ import { NodeRegistry } from "@nodetool-ai/node-sdk";
12
+ import { registerCliPacks } from "./packs/host.js";
13
+ import { BUILTIN_NODE_PACKS } from "@nodetool-ai/protocol";
14
+ import { installSandboxCatalog } from "./sandbox-catalog.js";
15
+ /** CLI harnesses expose optional packs independently of user toggles. */
16
+ export const CLI_BUILTIN_PACK_POLICY = {
17
+ includeOptionalPacks: true,
18
+ excludedPackIds: ["kie", "topaz", "higgsfield", "together"]
19
+ };
20
+ /** Workflow JSON runs and local MCP historically omit AtlasCloud too. */
21
+ export const CLI_LOCAL_BUILTIN_PACK_POLICY = {
22
+ ...CLI_BUILTIN_PACK_POLICY,
23
+ excludedPackIds: [
24
+ ...(CLI_BUILTIN_PACK_POLICY.excludedPackIds ?? []),
25
+ "atlascloud"
26
+ ]
27
+ };
28
+ /** DSL files import provider nodes themselves, so only the required base pack is bootstrapped. */
29
+ export const CLI_DSL_BUILTIN_PACK_POLICY = {
30
+ enabledOverrides: Object.fromEntries(BUILTIN_NODE_PACKS.map((pack) => [pack.id, false]))
31
+ };
32
+ export async function buildFullRegistry() {
33
+ installSandboxCatalog();
34
+ const registry = new NodeRegistry();
35
+ await registerCliPacks(registry, CLI_BUILTIN_PACK_POLICY);
36
+ return registry;
37
+ }
38
+ //# sourceMappingURL=node-registry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"node-registry.js","sourceRoot":"","sources":["../src/node-registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,YAAY,EAA0B,MAAM,uBAAuB,CAAC;AAC7E,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAEnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAE7D,yEAAyE;AACzE,MAAM,CAAC,MAAM,uBAAuB,GAAsB;IACxD,oBAAoB,EAAE,IAAI;IAC1B,eAAe,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,UAAU,CAAC;CAC5D,CAAC;AAEF,yEAAyE;AACzE,MAAM,CAAC,MAAM,6BAA6B,GAAG;IAC3C,GAAG,uBAAuB;IAC1B,eAAe,EAAE;QACf,GAAG,CAAC,uBAAuB,CAAC,eAAe,IAAI,EAAE,CAAC;QAClD,YAAY;KACb;CACF,CAAC;AAEF,kGAAkG;AAClG,MAAM,CAAC,MAAM,2BAA2B,GAAG;IACzC,gBAAgB,EAAE,MAAM,CAAC,WAAW,CAClC,kBAAkB,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC,CACnD;CACF,CAAC;AAEF,MAAM,CAAC,KAAK,UAAU,iBAAiB;IACrC,qBAAqB,EAAE,CAAC;IACxB,MAAM,QAAQ,GAAG,IAAI,YAAY,EAAE,CAAC;IACpC,MAAM,gBAAgB,CAAC,QAAQ,EAAE,uBAAuB,CAAC,CAAC;IAC1D,OAAO,QAAQ,CAAC;AAClB,CAAC"}
@@ -0,0 +1,14 @@
1
+ import { type NodeCatalogIndex } from "@nodetool-ai/node-catalog";
2
+ import type { BuiltinPackPolicy, NodeRegistry } from "@nodetool-ai/node-sdk";
3
+ import type { PackSource } from "@nodetool-ai/pack-host";
4
+ export { loadCliPackSnapshot, loaderContextForSnapshot } from "@nodetool-ai/pack-manager/packs/host";
5
+ export declare function configureCliPackHost(url: string, options?: {
6
+ readonly catalog?: NodeCatalogIndex;
7
+ readonly stateFile?: string;
8
+ readonly configuredPackIds?: readonly string[];
9
+ }): void;
10
+ /** Serve and command registries share one source and admitted snapshot per process. */
11
+ export declare function getCliPackSource(): Promise<PackSource | undefined>;
12
+ /** Preserve library callers until a CLI entry explicitly configures its installed policy. */
13
+ export declare function registerCliPacks(registry: NodeRegistry, policy: BuiltinPackPolicy): Promise<void>;
14
+ //# sourceMappingURL=host.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"host.d.ts","sourceRoot":"","sources":["../../src/packs/host.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,KAAK,gBAAgB,EACtB,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAC7E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAKzD,OAAO,EACL,mBAAmB,EACnB,wBAAwB,EACzB,MAAM,sCAAsC,CAAC;AAI9C,wBAAgB,oBAAoB,CAClC,GAAG,EAAE,MAAM,EACX,OAAO,GAAE;IACP,QAAQ,CAAC,OAAO,CAAC,EAAE,gBAAgB,CAAC;IACpC,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,iBAAiB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CAC3C,GACL,IAAI,CAKN;AACD,uFAAuF;AACvF,wBAAsB,gBAAgB,IAAI,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CAUxE;AAED,6FAA6F;AAC7F,wBAAsB,gBAAgB,CACpC,QAAQ,EAAE,YAAY,EACtB,MAAM,EAAE,iBAAiB,GACxB,OAAO,CAAC,IAAI,CAAC,CAYf"}
@@ -0,0 +1,38 @@
1
+ import { initializeInstalledExecutionHost } from "@nodetool-ai/pack-manager";
2
+ import { registerAvailablePacks } from "@nodetool-ai/node-catalog";
3
+ import { configureCliPackHost as configureInventory, loadCliPackSnapshot } from "@nodetool-ai/pack-manager/packs/host";
4
+ export { loadCliPackSnapshot, loaderContextForSnapshot } from "@nodetool-ai/pack-manager/packs/host";
5
+ let entryUrl;
6
+ let configuredPackIds;
7
+ let sourcePromise;
8
+ export function configureCliPackHost(url, options = {}) {
9
+ entryUrl = url;
10
+ configuredPackIds = options.configuredPackIds;
11
+ sourcePromise = undefined;
12
+ configureInventory(url, options);
13
+ }
14
+ /** Serve and command registries share one source and admitted snapshot per process. */
15
+ export async function getCliPackSource() {
16
+ if (!entryUrl) {
17
+ return undefined;
18
+ }
19
+ await loadCliPackSnapshot();
20
+ sourcePromise ??= import("@nodetool-ai/pack-host").then(({ createCatalogPackSource }) => createCatalogPackSource({ configuredPackIds }));
21
+ return sourcePromise;
22
+ }
23
+ /** Preserve library callers until a CLI entry explicitly configures its installed policy. */
24
+ export async function registerCliPacks(registry, policy) {
25
+ if (entryUrl) {
26
+ await initializeInstalledExecutionHost(entryUrl, {
27
+ snapshot: await loadCliPackSnapshot()
28
+ });
29
+ }
30
+ const source = await getCliPackSource();
31
+ if (source) {
32
+ await source.register(registry, policy);
33
+ }
34
+ else {
35
+ await registerAvailablePacks(registry, policy);
36
+ }
37
+ }
38
+ //# sourceMappingURL=host.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"host.js","sourceRoot":"","sources":["../../src/packs/host.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gCAAgC,EAAE,MAAM,2BAA2B,CAAC;AAC7E,OAAO,EACL,sBAAsB,EAEvB,MAAM,2BAA2B,CAAC;AAGnC,OAAO,EACL,oBAAoB,IAAI,kBAAkB,EAC1C,mBAAmB,EACpB,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EACL,mBAAmB,EACnB,wBAAwB,EACzB,MAAM,sCAAsC,CAAC;AAC9C,IAAI,QAA4B,CAAC;AACjC,IAAI,iBAAgD,CAAC;AACrD,IAAI,aAA8C,CAAC;AACnD,MAAM,UAAU,oBAAoB,CAClC,GAAW,EACX,OAAO,GAIH,EAAE;IAEN,QAAQ,GAAG,GAAG,CAAC;IACf,iBAAiB,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAC9C,aAAa,GAAG,SAAS,CAAC;IAC1B,kBAAkB,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;AACnC,CAAC;AACD,uFAAuF;AACvF,MAAM,CAAC,KAAK,UAAU,gBAAgB;IACpC,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,MAAM,mBAAmB,EAAE,CAAC;IAC5B,aAAa,KAAK,MAAM,CAAC,wBAAwB,CAAC,CAAC,IAAI,CACrD,CAAC,EAAE,uBAAuB,EAAE,EAAE,EAAE,CAC9B,uBAAuB,CAAC,EAAE,iBAAiB,EAAE,CAAC,CACjD,CAAC;IACF,OAAO,aAAa,CAAC;AACvB,CAAC;AAED,6FAA6F;AAC7F,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,QAAsB,EACtB,MAAyB;IAEzB,IAAI,QAAQ,EAAE,CAAC;QACb,MAAM,gCAAgC,CAAC,QAAQ,EAAE;YAC/C,QAAQ,EAAE,MAAM,mBAAmB,EAAE;SACtC,CAAC,CAAC;IACL,CAAC;IACD,MAAM,MAAM,GAAG,MAAM,gBAAgB,EAAE,CAAC;IACxC,IAAI,MAAM,EAAE,CAAC;QACX,MAAM,MAAM,CAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;IAC1C,CAAC;SAAM,CAAC;QACN,MAAM,sBAAsB,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;IACjD,CAAC;AACH,CAAC"}
@@ -0,0 +1,40 @@
1
+ /**
2
+ * The bounds one CLI agent run shares downward.
3
+ *
4
+ * Same object, same five settings, same defaults as a chat turn on the server
5
+ * (`chat-turn.ts` → `createChatTurnBudget`): a run gets one {@link RunBudget}
6
+ * and every loop it starts — a sub-agent, an `execute_plan` DAG, an `AgentNode`
7
+ * reached through `run_node` — reserves against it instead of opening an
8
+ * allowance of its own (invariant I-2). `--cost-cap` and `--timeout` override
9
+ * the first two settings for one invocation; nothing else is per-run.
10
+ *
11
+ * The settings are read the way the server reads them — stored value first,
12
+ * then the environment variable of the same name — and the read is
13
+ * best-effort: an unreachable database falls back to the documented default
14
+ * rather than failing the run.
15
+ */
16
+ import { type RunBudget } from "@nodetool-ai/runtime";
17
+ /** The two flags every CLI agent surface accepts. */
18
+ export interface RunBudgetFlags {
19
+ /** `--cost-cap <usd>`; `0` lifts the cap. */
20
+ costCap?: string | number;
21
+ /** `--timeout <s>`; `0` leaves the run no time at all. */
22
+ timeout?: string | number;
23
+ }
24
+ /**
25
+ * Build the run's budget: the five settings, with the two flags overriding the
26
+ * cost cap and the deadline.
27
+ */
28
+ export declare function createCliRunBudget(flags?: RunBudgetFlags): Promise<RunBudget>;
29
+ /**
30
+ * The reason a ceiling ended the run, or null when none did.
31
+ *
32
+ * A budget stop is not the model finishing its answer, and the two are
33
+ * indistinguishable to a caller that only sees an empty transcript
34
+ * (invariant I-3), so every CLI surface reports this before it reports
35
+ * anything else about how the run ended.
36
+ */
37
+ export declare function budgetStopReason(budget: RunBudget): string | null;
38
+ /** `spent $0.0123` — what the whole run committed against the shared cap. */
39
+ export declare function budgetSummaryLine(budget: RunBudget): string;
40
+ //# sourceMappingURL=run-budget.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run-budget.d.ts","sourceRoot":"","sources":["../src/run-budget.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,EAAmB,KAAK,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAyDvE,qDAAqD;AACrD,MAAM,WAAW,cAAc;IAC7B,6CAA6C;IAC7C,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC1B,0DAA0D;IAC1D,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CAC3B;AAUD;;;GAGG;AACH,wBAAsB,kBAAkB,CACtC,KAAK,GAAE,cAAmB,GACzB,OAAO,CAAC,SAAS,CAAC,CAgCpB;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,SAAS,GAAG,MAAM,GAAG,IAAI,CAEjE;AAED,6EAA6E;AAC7E,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,SAAS,GAAG,MAAM,CAQ3D"}
@@ -0,0 +1,119 @@
1
+ /**
2
+ * The bounds one CLI agent run shares downward.
3
+ *
4
+ * Same object, same five settings, same defaults as a chat turn on the server
5
+ * (`chat-turn.ts` → `createChatTurnBudget`): a run gets one {@link RunBudget}
6
+ * and every loop it starts — a sub-agent, an `execute_plan` DAG, an `AgentNode`
7
+ * reached through `run_node` — reserves against it instead of opening an
8
+ * allowance of its own (invariant I-2). `--cost-cap` and `--timeout` override
9
+ * the first two settings for one invocation; nothing else is per-run.
10
+ *
11
+ * The settings are read the way the server reads them — stored value first,
12
+ * then the environment variable of the same name — and the read is
13
+ * best-effort: an unreachable database falls back to the documented default
14
+ * rather than failing the run.
15
+ */
16
+ import { Setting } from "@nodetool-ai/models";
17
+ import { createRunBudget } from "@nodetool-ai/runtime";
18
+ import { parseNumericOption } from "@nodetool-ai/cli-common/numeric-options";
19
+ /**
20
+ * Output-token worst case assumed when reserving a turn. No CLI loop sends a
21
+ * `maxTokens`, so nothing bounds the answer from this side; the reservation
22
+ * charges the same ceiling the chat turn does, which is what makes the dollar
23
+ * cap hold before the money is spent rather than after.
24
+ */
25
+ const CLI_TURN_MAX_OUTPUT_TOKENS = 16_384;
26
+ /** Documented defaults for the five `NODETOOL_AGENT_*` budget settings. */
27
+ const AGENT_BUDGET_DEFAULTS = {
28
+ costCapUsd: 5,
29
+ deadlineMs: 1_800_000,
30
+ maxConcurrency: 8,
31
+ maxTurns: 200,
32
+ unpricedTokenCeiling: 400_000
33
+ };
34
+ /** Stored value, then env var, then null — the server's own lookup order. */
35
+ async function readBudgetSetting(key) {
36
+ try {
37
+ const setting = await Setting.find("1", key);
38
+ if (setting && setting.value.length > 0)
39
+ return setting.value;
40
+ }
41
+ catch {
42
+ // Settings store unavailable — the environment and the defaults stand.
43
+ }
44
+ const fromEnv = process.env[key];
45
+ return fromEnv !== undefined && fromEnv.length > 0 ? fromEnv : null;
46
+ }
47
+ async function budgetSettingNumber(key, fallback) {
48
+ const raw = await readBudgetSetting(key);
49
+ if (raw === null)
50
+ return fallback;
51
+ const parsed = Number(raw);
52
+ return Number.isFinite(parsed) && parsed > 0 ? parsed : fallback;
53
+ }
54
+ /**
55
+ * The run's USD ceiling, or `null` for no ceiling at all.
56
+ *
57
+ * A non-positive number means *no cap*, not a cap nothing can pass — the same
58
+ * rule the setting documents, so `--cost-cap 0` and a stored `0` mean the same
59
+ * thing. An absent setting takes the documented $5 default.
60
+ */
61
+ async function budgetCostCapUsd() {
62
+ const raw = await readBudgetSetting("NODETOOL_AGENT_TURN_COST_CAP_USD");
63
+ if (raw === null)
64
+ return AGENT_BUDGET_DEFAULTS.costCapUsd;
65
+ const parsed = Number(raw.trim());
66
+ if (!Number.isFinite(parsed) || parsed <= 0)
67
+ return null;
68
+ return parsed;
69
+ }
70
+ function flagNumber(value, flag) {
71
+ if (value === undefined)
72
+ return undefined;
73
+ return parseNumericOption(String(value), flag, { min: 0 });
74
+ }
75
+ /**
76
+ * Build the run's budget: the five settings, with the two flags overriding the
77
+ * cost cap and the deadline.
78
+ */
79
+ export async function createCliRunBudget(flags = {}) {
80
+ const capFlag = flagNumber(flags.costCap, "--cost-cap");
81
+ const timeoutFlag = flagNumber(flags.timeout, "--timeout");
82
+ const [settingCap, settingDeadlineMs, maxConcurrency, maxTurns, unpricedTokenCeiling] = await Promise.all([
83
+ budgetCostCapUsd(),
84
+ budgetSettingNumber("NODETOOL_AGENT_TURN_DEADLINE_MS", AGENT_BUDGET_DEFAULTS.deadlineMs),
85
+ budgetSettingNumber("NODETOOL_AGENT_MAX_CONCURRENCY", AGENT_BUDGET_DEFAULTS.maxConcurrency),
86
+ budgetSettingNumber("NODETOOL_AGENT_MAX_TURNS", AGENT_BUDGET_DEFAULTS.maxTurns),
87
+ budgetSettingNumber("NODETOOL_AGENT_UNPRICED_TOKEN_CEILING", AGENT_BUDGET_DEFAULTS.unpricedTokenCeiling)
88
+ ]);
89
+ return createRunBudget({
90
+ capUsd: capFlag === undefined ? settingCap : capFlag > 0 ? capFlag : null,
91
+ maxOutputTokens: CLI_TURN_MAX_OUTPUT_TOKENS,
92
+ unpricedTokenCeiling,
93
+ deadlineMs: timeoutFlag === undefined ? settingDeadlineMs : timeoutFlag * 1000,
94
+ maxConcurrency,
95
+ maxTurns
96
+ });
97
+ }
98
+ /**
99
+ * The reason a ceiling ended the run, or null when none did.
100
+ *
101
+ * A budget stop is not the model finishing its answer, and the two are
102
+ * indistinguishable to a caller that only sees an empty transcript
103
+ * (invariant I-3), so every CLI surface reports this before it reports
104
+ * anything else about how the run ended.
105
+ */
106
+ export function budgetStopReason(budget) {
107
+ return budget.exhausted?.detail ?? null;
108
+ }
109
+ /** `spent $0.0123` — what the whole run committed against the shared cap. */
110
+ export function budgetSummaryLine(budget) {
111
+ const spent = `$${budget.turns.spentUsd.toFixed(4)}`;
112
+ const unpriced = budget.turns.unpricedTurns;
113
+ // A turn on a model with no catalog price adds nothing to the total, so
114
+ // the number is a lower bound and says so (invariant I-4).
115
+ return unpriced > 0
116
+ ? `spent at least ${spent} (${unpriced} turn(s) on a model with no catalog price)`
117
+ : `spent ${spent}`;
118
+ }
119
+ //# sourceMappingURL=run-budget.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run-budget.js","sourceRoot":"","sources":["../src/run-budget.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAkB,MAAM,sBAAsB,CAAC;AACvE,OAAO,EAAE,kBAAkB,EAAE,MAAM,yCAAyC,CAAC;AAE7E;;;;;GAKG;AACH,MAAM,0BAA0B,GAAG,MAAM,CAAC;AAE1C,2EAA2E;AAC3E,MAAM,qBAAqB,GAAG;IAC5B,UAAU,EAAE,CAAC;IACb,UAAU,EAAE,SAAS;IACrB,cAAc,EAAE,CAAC;IACjB,QAAQ,EAAE,GAAG;IACb,oBAAoB,EAAE,OAAO;CACrB,CAAC;AAEX,6EAA6E;AAC7E,KAAK,UAAU,iBAAiB,CAAC,GAAW;IAC1C,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;QAC7C,IAAI,OAAO,IAAI,OAAO,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC;YAAE,OAAO,OAAO,CAAC,KAAK,CAAC;IAChE,CAAC;IAAC,MAAM,CAAC;QACP,uEAAuE;IACzE,CAAC;IACD,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACjC,OAAO,OAAO,KAAK,SAAS,IAAI,OAAO,CAAC,M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GAAG,CAAC;QACjB,CAAC,CAAC,kBAAkB,KAAK,KAAK,QAAQ,4CAA4C;QAClF,CAAC,CAAC,SAAS,KAAK,EAAE,CAAC;AACvB,CAAC"}
@@ -0,0 +1,11 @@
1
+ import type { Intervention } from "@nodetool-ai/protocol";
2
+ import { type SupervisorRunConfig } from "./supervisor.js";
3
+ interface SupervisedDslRun {
4
+ /** Workflow outputs, keyed by export name — the unsupervised path's shape. */
5
+ results: Record<string, Record<string, unknown>>;
6
+ /** Every decision the supervisor made, across the file's workflows. */
7
+ interventions: Intervention[];
8
+ }
9
+ export declare function runDslFileSupervised(filePath: string, config: SupervisorRunConfig, jsonMode: boolean): Promise<SupervisedDslRun>;
10
+ export {};
11
+ //# sourceMappingURL=run-dsl-supervised.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run-dsl-supervised.d.ts","sourceRoot":"","sources":["../src/run-dsl-supervised.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAO1D,OAAO,EAKL,KAAK,mBAAmB,EACzB,MAAM,iBAAiB,CAAC;AAEzB,UAAU,gBAAgB;IACxB,8EAA8E;IAC9E,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACjD,uEAAuE;IACvE,aAAa,EAAE,YAAY,EAAE,CAAC;CAC/B;AAED,wBAAsB,oBAAoB,CACxC,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,mBAAmB,EAC3B,QAAQ,EAAE,OAAO,GAChB,OAAO,CAAC,gBAAgB,CAAC,CAwE3B"}
@@ -0,0 +1,89 @@
1
+ /**
2
+ * `nodetool run --supervise` — the DSL file path, executed under supervision.
3
+ *
4
+ * `@nodetool-ai/dsl`'s own `run()` constructs a `WorkflowRunner` directly: one
5
+ * of the grandfathered direct-construction sites that must not gain
6
+ * supervision ad hoc (docs/workflow-supervisor-implementation-plan.md, PR 4).
7
+ * So a supervised DSL run goes through `ExecutionSession` instead, and an
8
+ * unsupervised one keeps taking the untouched `runDslFile` path.
9
+ *
10
+ * Lives in its own module because it pulls the session facade, the node
11
+ * registries, and a provider — none of which an unsupervised `nodetool run`
12
+ * should load.
13
+ */
14
+ import { getDefaultAssetsPath } from "@nodetool-ai/config";
15
+ import { ExecutionSession } from "@nodetool-ai/execution";
16
+ import { resolveLocalSecret } from "@nodetool-ai/cli-local/local-secrets";
17
+ import { MissingRuntimePackageError, MissingPackError } from "@nodetool-ai/protocol";
18
+ import { createGraphNodeTypeResolver } from "@nodetool-ai/node-sdk";
19
+ import { ProcessingContext } from "@nodetool-ai/runtime";
20
+ import { FileStorageAdapter } from "@nodetool-ai/storage";
21
+ import { buildFullRegistry } from "./node-registry.js";
22
+ import { dslWorkflowToGraph, loadDslWorkflows } from "./run-dsl.js";
23
+ import { createSupervisorHandle, printSupervisedSummary, recordSupervisorCost, streamInterventionLines } from "./supervisor.js";
24
+ export async function runDslFileSupervised(filePath, config, jsonMode) {
25
+ const workflows = await loadDslWorkflows(filePath);
26
+ const registry = await buildFullRegistry();
27
+ const results = {};
28
+ const allInterventions = [];
29
+ for (const [name, workflow] of Object.entries(workflows)) {
30
+ const jobId = `dsl-${Date.now()}-${name}`;
31
+ const context = new ProcessingContext({
32
+ jobId,
33
+ workflowId: null,
34
+ userId: "1",
35
+ secretResolver: resolveLocalSecret,
36
+ storage: new FileStorageAdapter(getDefaultAssetsPath())
37
+ });
38
+ const supervisor = await createSupervisorHandle({ config, context });
39
+ console.error(`Running ${name} supervised by ${supervisor.providerId}/${supervisor.model}...`);
40
+ const session = await ExecutionSession.create({
41
+ graph: dslWorkflowToGraph(workflow),
42
+ registry,
43
+ resolveNodeType: createGraphNodeTypeResolver(registry).resolveNodeType,
44
+ jobId,
45
+ params: {},
46
+ context,
47
+ supervisor: supervisor.handle,
48
+ captureMessages: true
49
+ });
50
+ const lines = streamInterventionLines(session.messages);
51
+ const result = await session.result;
52
+ await lines;
53
+ supervisor.handle.close();
54
+ const interventions = result.interventions ?? [];
55
+ allInterventions.push(...interventions);
56
+ if (interventions.length > 0) {
57
+ await recordSupervisorCost({
58
+ interventions,
59
+ jobId,
60
+ workflowId: null,
61
+ userId: "1",
62
+ providerId: supervisor.providerId,
63
+ model: supervisor.model
64
+ });
65
+ if (!jsonMode)
66
+ printSupervisedSummary(interventions, console.error);
67
+ }
68
+ // A node error the supervisor resolved is not a run failure — unlike the
69
+ // unsupervised DSL path, which rethrows the first node error it finds.
70
+ // Only the run's own terminal status decides.
71
+ if (result.status === "failed") {
72
+ if (result.missingPack) {
73
+ throw new MissingPackError(result.missingPack);
74
+ }
75
+ if (result.missingRuntime) {
76
+ throw new MissingRuntimePackageError(result.error ?? `Workflow ${name} failed`, result.missingRuntime.runtimePackage, { details: result.missingRuntime });
77
+ }
78
+ throw new Error(result.error ?? `Workflow ${name} failed`);
79
+ }
80
+ const outputs = {};
81
+ for (const [outputName, values] of Object.entries(result.outputs)) {
82
+ if (values.length > 0)
83
+ outputs[outputName] = values[values.length - 1];
84
+ }
85
+ results[name] = outputs;
86
+ }
87
+ return { results, interventions: allInterventions };
88
+ }
89
+ //# sourceMappingURL=run-dsl-supervised.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run-dsl-supervised.js","sourceRoot":"","sources":["../src/run-dsl-supervised.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,sCAAsC,CAAC;AAE1E,OAAO,EAAE,0BAA0B,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACrF,OAAO,EAAE,2BAA2B,EAAE,MAAM,uBAAuB,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,E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EAAE,MAAM,CAAC,cAAc,EAAE,CAAC,CAAC;YAC5J,CAAC;YACD,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,IAAI,YAAY,IAAI,SAAS,CAAC,CAAC;QAC7D,CAAC;QAED,MAAM,OAAO,GAA4B,EAAE,CAAC;QAC5C,KAAK,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC;YAClE,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC;gBAAE,OAAO,CAAC,UAAU,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QACzE,CAAC;QACD,OAAO,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC;IAC1B,CAAC;IAED,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,CAAC;AACtD,CAAC"}
@@ -0,0 +1,40 @@
1
+ /**
2
+ * runDslFile — dynamically import a TypeScript/JavaScript DSL file,
3
+ * find all exported Workflow objects, and run each with run() from @nodetool-ai/dsl.
4
+ *
5
+ * Uses tsx/esm/api's tsImport() so TypeScript files can be loaded without
6
+ * pre-compilation and without registering a global module loader.
7
+ */
8
+ import type { Workflow } from "@nodetool-ai/dsl";
9
+ export declare function isWorkflow(value: unknown): value is Workflow;
10
+ /** Every exported `Workflow` in the file, keyed by export name. */
11
+ export declare function loadDslWorkflows(filePath: string): Promise<Record<string, Workflow>>;
12
+ export declare function runDslFile(filePath: string): Promise<Record<string, Record<string, unknown>>>;
13
+ /**
14
+ * The graph shape `ExecutionSession` takes, from a DSL workflow. `run()` in
15
+ * `@nodetool-ai/dsl` builds the same descriptors against its own
16
+ * `WorkflowRunner`; supervision goes through the session facade instead
17
+ * (docs/workflow-supervisor-design.md §7), so the mapping is needed here too.
18
+ */
19
+ export declare function dslWorkflowToGraph(wf: Workflow): {
20
+ nodes: {
21
+ id: string;
22
+ type: string;
23
+ properties: Record<string, unknown>;
24
+ dynamic_outputs: Record<string, {
25
+ type: string;
26
+ type_args: never[];
27
+ }> | undefined;
28
+ output_correlation: Record<string, import("@nodetool-ai/protocol").OutputCorrelation> | undefined;
29
+ input_mode: import("@nodetool-ai/protocol").InputMode | undefined;
30
+ is_streaming_output: boolean;
31
+ is_streaming_input: boolean;
32
+ }[];
33
+ edges: {
34
+ source: string;
35
+ sourceHandle: string;
36
+ target: string;
37
+ targetHandle: string;
38
+ }[];
39
+ };
40
+ //# sourceMappingURL=run-dsl.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run-dsl.d.ts","sourceRoot":"","sources":["../src/run-dsl.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAIjD,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,QAAQ,CAO5D;AAED,mEAAmE;AACnE,wBAAsB,gBAAgB,CACpC,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAgBnC;AAED,wBAAsB,UAAU,CAC9B,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,CAOlD;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,EAAE,EAAE,QAAQ;IAE3C,KAAK;;;;;;;;;;;;;IAUL,KAAK;;;;;;EAOR"}
@@ -0,0 +1,65 @@
1
+ /**
2
+ * runDslFile — dynamically import a TypeScript/JavaScript DSL file,
3
+ * find all exported Workflow objects, and run each with run() from @nodetool-ai/dsl.
4
+ *
5
+ * Uses tsx/esm/api's tsImport() so TypeScript files can be loaded without
6
+ * pre-compilation and without registering a global module loader.
7
+ */
8
+ import { run as runWorkflow } from "@nodetool-ai/dsl";
9
+ import { tsImport } from "tsx/esm/api";
10
+ import { pathToFileURL } from "node:url";
11
+ export function isWorkflow(value) {
12
+ return ((typeof value === "object" || typeof value === "function") &&
13
+ value !== null &&
14
+ Array.isArray(value.nodes) &&
15
+ Array.isArray(value.edges));
16
+ }
17
+ /** Every exported `Workflow` in the file, keyed by export name. */
18
+ export async function loadDslWorkflows(filePath) {
19
+ const moduleUrl = pathToFileURL(filePath).href;
20
+ const mod = (await tsImport(moduleUrl, import.meta.url));
21
+ const workflows = {};
22
+ for (const [name, value] of Object.entries(mod)) {
23
+ if (isWorkflow(value))
24
+ workflows[name] = value;
25
+ }
26
+ if (Object.keys(workflows).length === 0) {
27
+ throw new Error(`No Workflow exports found in ${filePath}`);
28
+ }
29
+ return workflows;
30
+ }
31
+ export async function runDslFile(filePath) {
32
+ const workflows = await loadDslWorkflows(filePath);
33
+ const results = {};
34
+ for (const [name, wf] of Object.entries(workflows)) {
35
+ results[name] = await runWorkflow(wf);
36
+ }
37
+ return results;
38
+ }
39
+ /**
40
+ * The graph shape `ExecutionSession` takes, from a DSL workflow. `run()` in
41
+ * `@nodetool-ai/dsl` builds the same descriptors against its own
42
+ * `WorkflowRunner`; supervision goes through the session facade instead
43
+ * (docs/workflow-supervisor-design.md §7), so the mapping is needed here too.
44
+ */
45
+ export function dslWorkflowToGraph(wf) {
46
+ return {
47
+ nodes: wf.nodes.map((n) => ({
48
+ id: n.id,
49
+ type: n.type,
50
+ properties: n.data,
51
+ dynamic_outputs: n.dynamic_outputs,
52
+ output_correlation: n.output_correlation,
53
+ input_mode: n.input_mode,
54
+ is_streaming_output: n.streaming,
55
+ is_streaming_input: n.streamingInput
56
+ })),
57
+ edges: wf.edges.map((e) => ({
58
+ source: e.source,
59
+ sourceHandle: e.sourceHandle,
60
+ target: e.target,
61
+ targetHandle: e.targetHandle
62
+ }))
63
+ };
64
+ }
65
+ //# sourceMappingURL=run-dsl.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run-dsl.js","sourceRoot":"","sources":["../src/run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AM,gBAAgB,CAAC,QAAQ,CAAC,CAAC;IACnD,MAAM,OAAO,GAA4C,EAAE,CAAC;IAC5D,KAAK,MAAM,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC;QACnD,OAAO,CAAC,IAAI,CAAC,GAAG,MAAM,WAAW,CAAC,EAAE,CAAC,CAAC;IACxC,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CAAC,EAAY;IAC7C,OAAO;QACL,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;YAC1B,EAAE,EAAE,CAAC,CAAC,EAAE;YACR,IAAI,EAAE,CAAC,CAAC,IAAI;YACZ,UAAU,EAAE,CAAC,CAAC,IAAI;YAClB,eAAe,EAAE,CAAC,CAAC,eAAe;YAClC,kBAAkB,EAAE,CAAC,CAAC,kBAAkB;YACxC,UAAU,EAAE,CAAC,CAAC,UAAU;YACxB,mBAAmB,EAAE,CAAC,CAAC,SAAS;YAChC,kBAAkB,EAAE,CAAC,CAAC,cAAc;SACrC,CAAC,CAAC;QACH,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;YAC1B,MAAM,EAAE,CAAC,CAAC,MAAM;YAChB,YAAY,EAAE,CAAC,CAAC,YAAY;YAC5B,MAAM,EAAE,CAAC,CAAC,MAAM;YAChB,YAAY,EAAE,CAAC,CAAC,YAAY;SAC7B,CAAC,CAAC;KACJ,CAAC;AACJ,CAAC"}
@@ -0,0 +1,24 @@
1
+ export interface RunJsonOptions {
2
+ /**
3
+ * Where oversized payloads are written, created on the first spill. Callers
4
+ * with a run id should scope this per run so a later run does not overwrite
5
+ * files the printed JSON still points at.
6
+ */
7
+ outputDir?: string;
8
+ /** Binary payloads of at least this many bytes go to disk instead. */
9
+ maxInlineBytes?: number;
10
+ }
11
+ /** The JSON text for a run result, plus every payload file it points at. */
12
+ export declare function formatRunJson(value: unknown, opts?: RunJsonOptions): Promise<{
13
+ json: string;
14
+ files: string[];
15
+ }>;
16
+ /** Print a run result as JSON, noting on stderr where any payloads landed. */
17
+ export declare function printRunJson(value: unknown, opts?: RunJsonOptions): Promise<void>;
18
+ /**
19
+ * One-line rendering of a value for the human-readable output. Byte arrays are
20
+ * described rather than expanded, so a 4 MB frame does not cost tens of
21
+ * megabytes of text on its way to being truncated to `maxChars`.
22
+ */
23
+ export declare function previewJson(value: unknown, maxChars?: number): string;
24
+ //# sourceMappingURL=run-json.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run-json.d.ts","sourceRoot":"","sources":["../src/run-json.ts"],"names":[],"mappings":"AAiCA,MAAM,WAAW,cAAc;IAC7B;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,sEAAsE;IACtE,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AA2FD,4EAA4E;AAC5E,wBAAsB,aAAa,CACjC,KAAK,EAAE,OAAO,EACd,IAAI,GAAE,cAAmB,GACxB,OAAO,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC,CAmB5C;AAED,8EAA8E;AAC9E,wBAAsB,YAAY,CAChC,KAAK,EAAE,OAAO,EACd,IAAI,GAAE,cAAmB,GACxB,OAAO,CAAC,IAAI,CAAC,CAOf;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CASrE"}