@nodetool-ai/execution 0.8.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 (231) hide show
  1. package/README.md +129 -0
  2. package/dist/.nodetool-build-stamp +1 -0
  3. package/dist/app-debug/app-spec.d.ts +94 -0
  4. package/dist/app-debug/app-spec.d.ts.map +1 -0
  5. package/dist/app-debug/app-spec.js +710 -0
  6. package/dist/app-debug/app-spec.js.map +1 -0
  7. package/dist/app-debug/application-target.d.ts +53 -0
  8. package/dist/app-debug/application-target.d.ts.map +1 -0
  9. package/dist/app-debug/application-target.js +126 -0
  10. package/dist/app-debug/application-target.js.map +1 -0
  11. package/dist/app-debug/bundle-target.d.ts +21 -0
  12. package/dist/app-debug/bundle-target.d.ts.map +1 -0
  13. package/dist/app-debug/bundle-target.js +51 -0
  14. package/dist/app-debug/bundle-target.js.map +1 -0
  15. package/dist/app-debug/graph-shape.d.ts +14 -0
  16. package/dist/app-debug/graph-shape.d.ts.map +1 -0
  17. package/dist/app-debug/graph-shape.js +23 -0
  18. package/dist/app-debug/graph-shape.js.map +1 -0
  19. package/dist/app-debug/index.d.ts +26 -0
  20. package/dist/app-debug/index.d.ts.map +1 -0
  21. package/dist/app-debug/index.js +19 -0
  22. package/dist/app-debug/index.js.map +1 -0
  23. package/dist/app-debug/markdown.d.ts +6 -0
  24. package/dist/app-debug/markdown.d.ts.map +1 -0
  25. package/dist/app-debug/markdown.js +133 -0
  26. package/dist/app-debug/markdown.js.map +1 -0
  27. package/dist/app-debug/runtime.d.ts +267 -0
  28. package/dist/app-debug/runtime.d.ts.map +1 -0
  29. package/dist/app-debug/runtime.js +633 -0
  30. package/dist/app-debug/runtime.js.map +1 -0
  31. package/dist/app-debug/script-operation.d.ts +58 -0
  32. package/dist/app-debug/script-operation.d.ts.map +1 -0
  33. package/dist/app-debug/script-operation.js +44 -0
  34. package/dist/app-debug/script-operation.js.map +1 -0
  35. package/dist/app-debug/simulate.d.ts +85 -0
  36. package/dist/app-debug/simulate.d.ts.map +1 -0
  37. package/dist/app-debug/simulate.js +991 -0
  38. package/dist/app-debug/simulate.js.map +1 -0
  39. package/dist/app-debug/summarize.d.ts +64 -0
  40. package/dist/app-debug/summarize.d.ts.map +1 -0
  41. package/dist/app-debug/summarize.js +65 -0
  42. package/dist/app-debug/summarize.js.map +1 -0
  43. package/dist/app-debug/types.d.ts +343 -0
  44. package/dist/app-debug/types.d.ts.map +1 -0
  45. package/dist/app-debug/types.js +2 -0
  46. package/dist/app-debug/types.js.map +1 -0
  47. package/dist/cost-ledger.d.ts +147 -0
  48. package/dist/cost-ledger.d.ts.map +1 -0
  49. package/dist/cost-ledger.js +288 -0
  50. package/dist/cost-ledger.js.map +1 -0
  51. package/dist/debug/collector.d.ts +28 -0
  52. package/dist/debug/collector.d.ts.map +1 -0
  53. package/dist/debug/collector.js +284 -0
  54. package/dist/debug/collector.js.map +1 -0
  55. package/dist/debug/index.d.ts +15 -0
  56. package/dist/debug/index.d.ts.map +1 -0
  57. package/dist/debug/index.js +16 -0
  58. package/dist/debug/index.js.map +1 -0
  59. package/dist/debug/types.d.ts +179 -0
  60. package/dist/debug/types.d.ts.map +1 -0
  61. package/dist/debug/types.js +11 -0
  62. package/dist/debug/types.js.map +1 -0
  63. package/dist/debug/verdict.d.ts +27 -0
  64. package/dist/debug/verdict.d.ts.map +1 -0
  65. package/dist/debug/verdict.js +51 -0
  66. package/dist/debug/verdict.js.map +1 -0
  67. package/dist/executor-resolver.d.ts +13 -0
  68. package/dist/executor-resolver.d.ts.map +1 -0
  69. package/dist/executor-resolver.js +13 -0
  70. package/dist/executor-resolver.js.map +1 -0
  71. package/dist/fal-output-decoder.d.ts +36 -0
  72. package/dist/fal-output-decoder.d.ts.map +1 -0
  73. package/dist/fal-output-decoder.js +129 -0
  74. package/dist/fal-output-decoder.js.map +1 -0
  75. package/dist/generation-lifecycle.d.ts +54 -0
  76. package/dist/generation-lifecycle.d.ts.map +1 -0
  77. package/dist/generation-lifecycle.js +431 -0
  78. package/dist/generation-lifecycle.js.map +1 -0
  79. package/dist/generation-recovery-worker.d.ts +100 -0
  80. package/dist/generation-recovery-worker.d.ts.map +1 -0
  81. package/dist/generation-recovery-worker.js +995 -0
  82. package/dist/generation-recovery-worker.js.map +1 -0
  83. package/dist/generation-tracker.d.ts +83 -0
  84. package/dist/generation-tracker.d.ts.map +1 -0
  85. package/dist/generation-tracker.js +436 -0
  86. package/dist/generation-tracker.js.map +1 -0
  87. package/dist/index.d.ts +28 -0
  88. package/dist/index.d.ts.map +1 -0
  89. package/dist/index.js +21 -0
  90. package/dist/index.js.map +1 -0
  91. package/dist/js-script-debug/index.d.ts +13 -0
  92. package/dist/js-script-debug/index.d.ts.map +1 -0
  93. package/dist/js-script-debug/index.js +12 -0
  94. package/dist/js-script-debug/index.js.map +1 -0
  95. package/dist/js-script-debug/markdown.d.ts +6 -0
  96. package/dist/js-script-debug/markdown.d.ts.map +1 -0
  97. package/dist/js-script-debug/markdown.js +62 -0
  98. package/dist/js-script-debug/markdown.js.map +1 -0
  99. package/dist/js-script-debug/outputs.d.ts +20 -0
  100. package/dist/js-script-debug/outputs.d.ts.map +1 -0
  101. package/dist/js-script-debug/outputs.js +30 -0
  102. package/dist/js-script-debug/outputs.js.map +1 -0
  103. package/dist/js-script-debug/report.d.ts +15 -0
  104. package/dist/js-script-debug/report.d.ts.map +1 -0
  105. package/dist/js-script-debug/report.js +90 -0
  106. package/dist/js-script-debug/report.js.map +1 -0
  107. package/dist/js-script-debug/types.d.ts +63 -0
  108. package/dist/js-script-debug/types.d.ts.map +1 -0
  109. package/dist/js-script-debug/types.js +10 -0
  110. package/dist/js-script-debug/types.js.map +1 -0
  111. package/dist/js-script-debug/validate.d.ts +38 -0
  112. package/dist/js-script-debug/validate.d.ts.map +1 -0
  113. package/dist/js-script-debug/validate.js +137 -0
  114. package/dist/js-script-debug/validate.js.map +1 -0
  115. package/dist/message-stream.d.ts +33 -0
  116. package/dist/message-stream.d.ts.map +1 -0
  117. package/dist/message-stream.js +58 -0
  118. package/dist/message-stream.js.map +1 -0
  119. package/dist/normalize-graph.d.ts +13 -0
  120. package/dist/normalize-graph.d.ts.map +1 -0
  121. package/dist/normalize-graph.js +63 -0
  122. package/dist/normalize-graph.js.map +1 -0
  123. package/dist/output-names.d.ts +13 -0
  124. package/dist/output-names.d.ts.map +1 -0
  125. package/dist/output-names.js +13 -0
  126. package/dist/output-names.js.map +1 -0
  127. package/dist/predicates.d.ts +6 -0
  128. package/dist/predicates.d.ts.map +1 -0
  129. package/dist/predicates.js +6 -0
  130. package/dist/predicates.js.map +1 -0
  131. package/dist/preflight.d.ts +87 -0
  132. package/dist/preflight.d.ts.map +1 -0
  133. package/dist/preflight.js +139 -0
  134. package/dist/preflight.js.map +1 -0
  135. package/dist/provider-secret-key.d.ts +3 -0
  136. package/dist/provider-secret-key.d.ts.map +1 -0
  137. package/dist/provider-secret-key.js +7 -0
  138. package/dist/provider-secret-key.js.map +1 -0
  139. package/dist/service/app-debug-service.d.ts +78 -0
  140. package/dist/service/app-debug-service.d.ts.map +1 -0
  141. package/dist/service/app-debug-service.js +201 -0
  142. package/dist/service/app-debug-service.js.map +1 -0
  143. package/dist/service/app-run-server.d.ts +28 -0
  144. package/dist/service/app-run-server.d.ts.map +1 -0
  145. package/dist/service/app-run-server.js +104 -0
  146. package/dist/service/app-run-server.js.map +1 -0
  147. package/dist/service/debug-sessions.d.ts +158 -0
  148. package/dist/service/debug-sessions.d.ts.map +1 -0
  149. package/dist/service/debug-sessions.js +358 -0
  150. package/dist/service/debug-sessions.js.map +1 -0
  151. package/dist/service/index.d.ts +22 -0
  152. package/dist/service/index.d.ts.map +1 -0
  153. package/dist/service/index.js +17 -0
  154. package/dist/service/index.js.map +1 -0
  155. package/dist/service/job-progress.d.ts +40 -0
  156. package/dist/service/job-progress.d.ts.map +1 -0
  157. package/dist/service/job-progress.js +53 -0
  158. package/dist/service/job-progress.js.map +1 -0
  159. package/dist/service/workflow-run.d.ts +279 -0
  160. package/dist/service/workflow-run.d.ts.map +1 -0
  161. package/dist/service/workflow-run.js +598 -0
  162. package/dist/service/workflow-run.js.map +1 -0
  163. package/dist/service/workflow-workspace.d.ts +89 -0
  164. package/dist/service/workflow-workspace.d.ts.map +1 -0
  165. package/dist/service/workflow-workspace.js +160 -0
  166. package/dist/service/workflow-workspace.js.map +1 -0
  167. package/dist/session.d.ts +62 -0
  168. package/dist/session.d.ts.map +1 -0
  169. package/dist/session.js +353 -0
  170. package/dist/session.js.map +1 -0
  171. package/dist/sketch-debug/index.d.ts +11 -0
  172. package/dist/sketch-debug/index.d.ts.map +1 -0
  173. package/dist/sketch-debug/index.js +10 -0
  174. package/dist/sketch-debug/index.js.map +1 -0
  175. package/dist/sketch-debug/markdown.d.ts +6 -0
  176. package/dist/sketch-debug/markdown.d.ts.map +1 -0
  177. package/dist/sketch-debug/markdown.js +93 -0
  178. package/dist/sketch-debug/markdown.js.map +1 -0
  179. package/dist/sketch-debug/report.d.ts +15 -0
  180. package/dist/sketch-debug/report.d.ts.map +1 -0
  181. package/dist/sketch-debug/report.js +98 -0
  182. package/dist/sketch-debug/report.js.map +1 -0
  183. package/dist/sketch-debug/types.d.ts +62 -0
  184. package/dist/sketch-debug/types.d.ts.map +1 -0
  185. package/dist/sketch-debug/types.js +10 -0
  186. package/dist/sketch-debug/types.js.map +1 -0
  187. package/dist/sketch-debug/validate.d.ts +14 -0
  188. package/dist/sketch-debug/validate.d.ts.map +1 -0
  189. package/dist/sketch-debug/validate.js +478 -0
  190. package/dist/sketch-debug/validate.js.map +1 -0
  191. package/dist/supervisor.d.ts +45 -0
  192. package/dist/supervisor.d.ts.map +1 -0
  193. package/dist/supervisor.js +97 -0
  194. package/dist/supervisor.js.map +1 -0
  195. package/dist/timeline-debug/index.d.ts +11 -0
  196. package/dist/timeline-debug/index.d.ts.map +1 -0
  197. package/dist/timeline-debug/index.js +10 -0
  198. package/dist/timeline-debug/index.js.map +1 -0
  199. package/dist/timeline-debug/legibility.d.ts +23 -0
  200. package/dist/timeline-debug/legibility.d.ts.map +1 -0
  201. package/dist/timeline-debug/legibility.js +240 -0
  202. package/dist/timeline-debug/legibility.js.map +1 -0
  203. package/dist/timeline-debug/markdown.d.ts +6 -0
  204. package/dist/timeline-debug/markdown.d.ts.map +1 -0
  205. package/dist/timeline-debug/markdown.js +103 -0
  206. package/dist/timeline-debug/markdown.js.map +1 -0
  207. package/dist/timeline-debug/motion.d.ts +20 -0
  208. package/dist/timeline-debug/motion.d.ts.map +1 -0
  209. package/dist/timeline-debug/motion.js +362 -0
  210. package/dist/timeline-debug/motion.js.map +1 -0
  211. package/dist/timeline-debug/report.d.ts +16 -0
  212. package/dist/timeline-debug/report.d.ts.map +1 -0
  213. package/dist/timeline-debug/report.js +100 -0
  214. package/dist/timeline-debug/report.js.map +1 -0
  215. package/dist/timeline-debug/showcase.d.ts +7 -0
  216. package/dist/timeline-debug/showcase.d.ts.map +1 -0
  217. package/dist/timeline-debug/showcase.js +347 -0
  218. package/dist/timeline-debug/showcase.js.map +1 -0
  219. package/dist/timeline-debug/types.d.ts +64 -0
  220. package/dist/timeline-debug/types.d.ts.map +1 -0
  221. package/dist/timeline-debug/types.js +10 -0
  222. package/dist/timeline-debug/types.js.map +1 -0
  223. package/dist/timeline-debug/validate.d.ts +24 -0
  224. package/dist/timeline-debug/validate.d.ts.map +1 -0
  225. package/dist/timeline-debug/validate.js +1432 -0
  226. package/dist/timeline-debug/validate.js.map +1 -0
  227. package/dist/types.d.ts +211 -0
  228. package/dist/types.d.ts.map +1 -0
  229. package/dist/types.js +2 -0
  230. package/dist/types.js.map +1 -0
  231. package/package.json +103 -0
@@ -0,0 +1,598 @@
1
+ /**
2
+ * Running a saved workflow, as a service every host can call in-process.
3
+ *
4
+ * This is what `POST /api/workflows/:id/run|debug` does minus Request/Response
5
+ * parsing: find the workflow, refuse a graph whose model selections cannot be
6
+ * honoured, create the job row, run it, finalize the row, and shape the payload
7
+ * — plain `/run` or the debug report. The interactive path parks escalations in
8
+ * the {@link debugSessions} registry and hands back the session event.
9
+ *
10
+ * The websocket package keeps the Fastify routes and calls this; the agent
11
+ * tools call it directly, so `run_workflow` no longer needs a server listening
12
+ * on localhost to run a workflow.
13
+ */
14
+ import { createLogger } from "@nodetool-ai/config";
15
+ import { BoundedHandle, WorkflowRunner } from "@nodetool-ai/kernel";
16
+ import { Job, Project, Workflow, getSecret } from "@nodetool-ai/models";
17
+ import { hydrateGraphNodeFlags, propertyTypesForMetadata } from "@nodetool-ai/node-sdk";
18
+ import { attachRunCostLedger, nodeTypeLookup } from "../cost-ledger.js";
19
+ import { normalizeGraph } from "../normalize-graph.js";
20
+ import { collectPreflightIssues, formatPreflightDetail } from "../preflight.js";
21
+ import { collectExecutionSummary } from "../debug/collector.js";
22
+ import { createJobProgressRecorder } from "./job-progress.js";
23
+ import { buildRunVerdict, collectInterventionWarnings } from "../debug/verdict.js";
24
+ import { rewriteOutputNames } from "../output-names.js";
25
+ import { debugSessions, InteractiveEscalationHandle, INTERACTIVE_DECISION_TIMEOUT_MS, TooManyDebugSessionsError } from "./debug-sessions.js";
26
+ import { buildWorkspaceExecutionContext, resolveWorkflowWorkspace } from "./workflow-workspace.js";
27
+ import { isFunctionValue, isNumber, isRecord, isString } from "../predicates.js";
28
+ // The preflight moved to `../preflight.ts` so `ExecutionSession` can run the
29
+ // same checks without importing the models database. Re-exported here because
30
+ // this module is where every host already reaches for them.
31
+ export { modelSelectionErrors, unconfiguredProviderErrors, formatPreflightDetail, ExecutionPreflightError } from "../preflight.js";
32
+ const log = createLogger("nodetool.execution.workflow-run");
33
+ /**
34
+ * Hydrate a saved graph for the kernel: registry-resolved execution flags,
35
+ * plus each node's declared input types under `propertyTypes`.
36
+ *
37
+ * Flags-only hydration leaves `propertyTypes` unset, and the kernel reads
38
+ * list-ness only from that map — so a genuine `list[...]` fan-in (several
39
+ * upstreams wired into one input, exactly what the editor and the graph DSL
40
+ * produce) was rejected by correlation analysis as "receives N edges but is
41
+ * not a list type". The full-fat alternative (`Graph.loadFromDict` with a
42
+ * resolver, the websocket runner's path) drops every node type this registry
43
+ * cannot resolve, which a service run over a saved workflow must not do — an
44
+ * unknown type has to fail loudly at executor resolution, not vanish. So:
45
+ * flags hydration keeps every node, and the property-type map is stamped from
46
+ * metadata per node where the registry can speak.
47
+ */
48
+ function hydrateRunGraph(graph, registry) {
49
+ const hydrated = hydrateGraphNodeFlags(graph, registry);
50
+ for (const node of hydrated.nodes) {
51
+ const metadata = registry.resolveMetadata(node.type);
52
+ if (!metadata)
53
+ continue;
54
+ node.propertyTypes = {
55
+ ...propertyTypesForMetadata(metadata),
56
+ ...(node.propertyTypes ?? {})
57
+ };
58
+ }
59
+ // Resolver-style hydration stamps each node's `name` with the registry
60
+ // title, which would outrank an Output node's public `name` *property* in
61
+ // the kernel's collection key. Flags hydration does not stamp one, but the
62
+ // rewrite makes the two paths agree and is what ExecutionSession applies.
63
+ rewriteOutputNames(hydrated);
64
+ return hydrated;
65
+ }
66
+ /**
67
+ * Server-side ceilings for the interactive bounds a caller may ask for. A
68
+ * number nobody would type by hand — a decision timeout of a day, ten thousand
69
+ * decisions — is clamped rather than honored.
70
+ */
71
+ export const MAX_INTERACTIVE_DECISIONS = 100;
72
+ export const MAX_INTERACTIVE_RETRIES_PER_NODE = 20;
73
+ export const MAX_INTERACTIVE_DECISION_TIMEOUT_MS = 30 * 60_000;
74
+ /**
75
+ * An interactive-run bound: an integer in `[min, max]`, or undefined.
76
+ * Out-of-range highs clamp to `max`; anything that is not a sane integer (NaN,
77
+ * Infinity, negatives, fractions) is undefined so the caller gets the default
78
+ * instead of a bound that fails every decision instantly.
79
+ */
80
+ export function boundedRunOption(value, min, max) {
81
+ if (!isNumber(value) || !Number.isInteger(value) || value < min) {
82
+ return undefined;
83
+ }
84
+ return Math.min(value, max);
85
+ }
86
+ /** Mark a job failed and persist it, best effort. */
87
+ async function markJobFailed(job, message) {
88
+ try {
89
+ job.markFailed(message);
90
+ await job.save();
91
+ }
92
+ catch (saveError) {
93
+ log.warn("failed to persist failed job status", {
94
+ jobId: job.id,
95
+ error: String(saveError)
96
+ });
97
+ }
98
+ }
99
+ /**
100
+ * How much serialized output a job row will carry. Outputs are normally
101
+ * asset refs and short strings; a run that emits a megabyte of text should
102
+ * not turn every `get_job` into that megabyte, so past this the row records
103
+ * the handle names instead and the caller reads the values from the assets.
104
+ */
105
+ export const MAX_PERSISTED_OUTPUT_BYTES = 256_000;
106
+ /**
107
+ * Drop inline bytes from an asset ref that already says where its bytes live.
108
+ *
109
+ * A media output travels as `{type, data: "<base64>", asset_id, uri}` — the
110
+ * bytes and the handle, both. The job row wants only the handle: it is read
111
+ * back by `get_job`, which hands it to an agent. Carrying the base64 pushed
112
+ * every real media run past {@link MAX_PERSISTED_OUTPUT_BYTES}, so the row
113
+ * recorded the omission marker instead of the asset the run produced, and a
114
+ * caller that ran a render in the background could not find its video.
115
+ *
116
+ * A ref with no `asset_id` and no `uri` keeps its `data`: dropping that loses
117
+ * the only copy.
118
+ */
119
+ export function withoutInlineAssetBytes(outputs) {
120
+ return Object.fromEntries(Object.entries(outputs).map(([key, value]) => [
121
+ key,
122
+ stripInlineBytes(value)
123
+ ]));
124
+ }
125
+ /** {@link withoutInlineAssetBytes}, one output value deep. */
126
+ function stripInlineBytes(value) {
127
+ if (Array.isArray(value)) {
128
+ const items = [];
129
+ for (const item of value) {
130
+ items.push(stripInlineBytes(item));
131
+ }
132
+ return items;
133
+ }
134
+ if (!isRecord(value))
135
+ return value;
136
+ const record = { ...value };
137
+ for (const [key, item] of Object.entries(record)) {
138
+ record[key] = stripInlineBytes(item);
139
+ }
140
+ const hasHandle = (isString(record["asset_id"]) && record["asset_id"] !== "") ||
141
+ (isString(record["uri"]) && record["uri"] !== "");
142
+ if (hasHandle && isString(record["data"]))
143
+ record["data"] = null;
144
+ return record;
145
+ }
146
+ /**
147
+ * The outputs to store on the job row, or a marker naming the handles when
148
+ * they are too big to keep. Pure so the size rule is pinned by a test.
149
+ */
150
+ export function persistableOutputs(outputs) {
151
+ let size;
152
+ try {
153
+ size = JSON.stringify(outputs).length;
154
+ }
155
+ catch {
156
+ // Circular or otherwise unserializable — the row cannot hold it either.
157
+ size = Number.POSITIVE_INFINITY;
158
+ }
159
+ if (size <= MAX_PERSISTED_OUTPUT_BYTES)
160
+ return outputs;
161
+ const omitted = {
162
+ omitted: true,
163
+ reason: `Outputs were ${Number.isFinite(size) ? `${size} bytes` : "not serializable"}, ` +
164
+ `over the ${MAX_PERSISTED_OUTPUT_BYTES}-byte limit for a job row. ` +
165
+ "Re-run the workflow with run_workflow to read them, or read the " +
166
+ "assets the run produced.",
167
+ handles: Object.keys(outputs)
168
+ };
169
+ return omitted;
170
+ }
171
+ /** How many log entries a job row keeps — the tail, which explains a failure. */
172
+ export const MAX_PERSISTED_LOG_ENTRIES = 200;
173
+ /** Per-entry ceiling, so one runaway line cannot fill the row. */
174
+ const MAX_LOG_CONTENT_CHARS = 2000;
175
+ /**
176
+ * The run's log tail plus one line per node that failed.
177
+ *
178
+ * `job.logs` had no writer at all: every `get_job_logs` call answered
179
+ * `total_logs: 0`, and `debug_workflow` reported an empty `logs` array, so the
180
+ * one tool an agent reaches for after a background run went wrong could not
181
+ * tell it anything. The messages are already folded for the debug payload;
182
+ * this keeps the part that survives the run.
183
+ */
184
+ export function persistableLogs(summary) {
185
+ const entries = summary.logs.map((log) => ({
186
+ severity: log.severity,
187
+ node_id: log.nodeId,
188
+ node_name: log.nodeName ?? null,
189
+ content: log.content.slice(0, MAX_LOG_CONTENT_CHARS)
190
+ }));
191
+ for (const node of summary.nodes) {
192
+ if (!node.error)
193
+ continue;
194
+ entries.push({
195
+ severity: "error",
196
+ node_id: node.nodeId,
197
+ node_name: node.nodeName ?? null,
198
+ content: `${node.nodeType ?? "node"} failed: ${node.error}`.slice(0, MAX_LOG_CONTENT_CHARS)
199
+ });
200
+ }
201
+ return entries.slice(-MAX_PERSISTED_LOG_ENTRIES);
202
+ }
203
+ async function finalizeWorkflowRunJob(job, result) {
204
+ if (result.status === "completed") {
205
+ job.markCompleted();
206
+ }
207
+ else if (result.status === "cancelled") {
208
+ job.markCancelled();
209
+ }
210
+ else {
211
+ job.markFailed(result.error ?? "Workflow run failed");
212
+ }
213
+ // Without this a detached run had nowhere to leave its results: the job row
214
+ // carried a status and nothing else, so `get_job` on a completed background
215
+ // job answered "completed" and the caller could never read what it produced.
216
+ job.metadata_json = {
217
+ ...(job.metadata_json ?? {}),
218
+ outputs: persistableOutputs(withoutInlineAssetBytes(result.outputs ?? {}))
219
+ };
220
+ job.logs = persistableLogs(collectExecutionSummary(result.messages));
221
+ await job.save();
222
+ }
223
+ export function buildWorkflowRunPayload(jobId, workflowId, result, debug, extras) {
224
+ if (debug) {
225
+ // The debug surface reports what actually happened — per-node status and
226
+ // errors, logs, edges, LLM calls, outputs — plus the same verdict the CLI
227
+ // harness computes.
228
+ const summary = collectExecutionSummary(result.messages);
229
+ const verdict = buildRunVerdict(summary, {
230
+ ok: result.status === "completed",
231
+ status: result.status,
232
+ error: result.error ?? null
233
+ });
234
+ // Supervisor decisions are warnings, never issues — a rescued run still
235
+ // completed — but without them a supervised run reads as "ran clean".
236
+ const warnings = collectInterventionWarnings("Server", summary);
237
+ return {
238
+ job_id: jobId,
239
+ workflow_id: workflowId,
240
+ status: result.status,
241
+ outputs: result.outputs,
242
+ error: result.error ?? null,
243
+ summary,
244
+ verdict: warnings.length > 0
245
+ ? {
246
+ ...verdict,
247
+ headline: verdict.ok
248
+ ? `${verdict.headline} (supervised)`
249
+ : verdict.headline,
250
+ warnings
251
+ }
252
+ : verdict
253
+ };
254
+ }
255
+ return {
256
+ job_id: jobId,
257
+ workflow_id: workflowId,
258
+ status: result.status,
259
+ outputs: result.outputs,
260
+ error: result.error ?? null,
261
+ message_count: result.messages.length,
262
+ background: extras.background
263
+ };
264
+ }
265
+ /** One escalated/running/done payload shape for every interactive response. */
266
+ export function debugSessionEventPayload(session, event) {
267
+ switch (event.kind) {
268
+ case "done":
269
+ return { ...event.report, session_id: session.id };
270
+ case "escalated":
271
+ return {
272
+ status: "escalated",
273
+ session_id: session.id,
274
+ job_id: session.jobId,
275
+ workflow_id: session.workflowId,
276
+ escalation_id: event.escalationId,
277
+ escalation: event.escalation,
278
+ resolve: `POST /api/debug/sessions/${session.id}/verdict with ` +
279
+ `{"escalation_id": "${event.escalationId}", "verdict": {"action": ...}} — ` +
280
+ `allowed actions: ${event.escalation.allowedActions.join(", ")}. ` +
281
+ "The run is parked on this node until a verdict arrives; an " +
282
+ "unanswered escalation fails closed on the decision timeout."
283
+ };
284
+ case "running":
285
+ return {
286
+ status: "running",
287
+ session_id: session.id,
288
+ job_id: session.jobId,
289
+ workflow_id: session.workflowId
290
+ };
291
+ }
292
+ }
293
+ /**
294
+ * Run a saved workflow end to end. Everything the HTTP route did except read
295
+ * the request and write the response.
296
+ */
297
+ export async function runWorkflow(options) {
298
+ const { workflowId, userId } = options;
299
+ const params = options.params ?? {};
300
+ const debug = options.debug === true;
301
+ const interactive = options.interactive === true;
302
+ // One normalization for every host: `data` → `properties`, editor-only nodes
303
+ // (Comment/Group/Reroute) pruned, and edges typed from `edge_type` or the
304
+ // legacy `type`.
305
+ let runnableGraph;
306
+ let workflowProjectId = options.projectId ?? null;
307
+ if (options.graph) {
308
+ runnableGraph = normalizeGraph(options.graph);
309
+ if (workflowProjectId && workflowProjectId !== "default") {
310
+ await Project.requireOwned(userId, workflowProjectId);
311
+ }
312
+ }
313
+ else {
314
+ const workflow = await Workflow.find(userId, workflowId);
315
+ if (!workflow) {
316
+ return { kind: "error", status: 404, detail: "Workflow not found" };
317
+ }
318
+ const runMode = workflow.run_mode ?? "workflow";
319
+ if (runMode !== "workflow") {
320
+ return {
321
+ kind: "error",
322
+ status: 400,
323
+ detail: `Workflow run mode "${runMode}" is not supported by the standalone backend`
324
+ };
325
+ }
326
+ workflowProjectId = workflow.project_id;
327
+ if (options.projectId !== undefined &&
328
+ options.projectId !== null &&
329
+ options.projectId !== workflow.project_id) {
330
+ return {
331
+ kind: "error",
332
+ status: 400,
333
+ detail: "Workflow is owned by another project"
334
+ };
335
+ }
336
+ runnableGraph = normalizeGraph(workflow.getGraph());
337
+ }
338
+ // The same refusal `ExecutionSession` raises, one layer up: a provider that
339
+ // would construct without its key fails mid-run today, after the upstream
340
+ // half of the graph is paid for. Refuse here, before the job row exists,
341
+ // and name the secret.
342
+ const preflightIssues = await collectPreflightIssues(runnableGraph, {
343
+ catalogs: options.catalogs,
344
+ resolveSecret: (key) => getSecret(key, userId)
345
+ });
346
+ if (preflightIssues.length > 0) {
347
+ return {
348
+ kind: "error",
349
+ status: 400,
350
+ detail: formatPreflightDetail(preflightIssues)
351
+ };
352
+ }
353
+ // Resolve the environment only after the cheap checks: a 404 on a missing
354
+ // workflow or a 400 on a bad model selection must not depend on (or be
355
+ // masked by) a cold runtime bootstrap.
356
+ const environment = isFunctionValue(options.environment)
357
+ ? await options.environment()
358
+ : options.environment;
359
+ const registry = environment.registry;
360
+ const hasPythonNode = runnableGraph.nodes.some((node) => {
361
+ const nodeType = isString(node.type) ? node.type : "";
362
+ return (nodeType !== "" &&
363
+ Boolean(registry.getMetadata(nodeType)) &&
364
+ !registry.has(nodeType));
365
+ });
366
+ if (hasPythonNode && environment.ensurePythonBridge) {
367
+ await environment.ensurePythonBridge();
368
+ }
369
+ const job = (await Job.create({
370
+ workflow_id: workflowId,
371
+ user_id: userId,
372
+ status: "running",
373
+ name: options.jobName ?? "",
374
+ params,
375
+ graph: runnableGraph,
376
+ project_id: workflowProjectId ?? "default"
377
+ }));
378
+ // Everything after the row exists must finalize it. Workspace resolution,
379
+ // node-flag hydration and the run itself can all throw (fs, registry) — a
380
+ // bare throw here stranded the row at "running" forever.
381
+ let runner;
382
+ let hydratedGraph;
383
+ let interactiveHandle = null;
384
+ let supervisorHandle = null;
385
+ try {
386
+ const workspace = await (options.resolveWorkspace ?? resolveWorkflowWorkspace)(workflowId || null, userId);
387
+ if (interactive) {
388
+ // `BoundedHandle` keeps the same guarantees an LLM supervisor gets —
389
+ // decision/retry caps, a per-decision timeout that fails closed, sticky
390
+ // verdicts — just with a timeout sized for an agent's tool round trip.
391
+ const maxDecisions = boundedRunOption(options.maxDecisions, 1, MAX_INTERACTIVE_DECISIONS);
392
+ const maxRetriesPerNode = boundedRunOption(options.maxRetriesPerNode, 0, MAX_INTERACTIVE_RETRIES_PER_NODE);
393
+ interactiveHandle = new InteractiveEscalationHandle();
394
+ const bounds = {
395
+ decisionTimeoutMs: boundedRunOption(options.decisionTimeoutMs, 1, MAX_INTERACTIVE_DECISION_TIMEOUT_MS) ?? INTERACTIVE_DECISION_TIMEOUT_MS
396
+ };
397
+ if (maxDecisions !== undefined) {
398
+ bounds.maxDecisions = maxDecisions;
399
+ }
400
+ if (maxRetriesPerNode !== undefined) {
401
+ bounds.maxRetriesPerNode = maxRetriesPerNode;
402
+ }
403
+ supervisorHandle = new BoundedHandle(interactiveHandle, bounds);
404
+ }
405
+ const resolveExecutor = environment.resolveExecutor ??
406
+ ((node) => registry.resolve(node));
407
+ const runnerOptions = {
408
+ resolveExecutor: (node) => resolveExecutor(node),
409
+ executionContext: (() => {
410
+ const executionContext = buildWorkspaceExecutionContext({
411
+ jobId: job.id,
412
+ workflowId,
413
+ projectId: workflowProjectId,
414
+ userId,
415
+ workspace,
416
+ storage: environment.storage ?? null,
417
+ assetStorage: environment.assetStorage ?? null,
418
+ durableFalGenerations: true
419
+ });
420
+ // The host attaches its model interfaces (asset persistence, …) —
421
+ // without them an Output node that stores an image fails the run.
422
+ environment.configureContext?.(executionContext);
423
+ // This path builds its own runner instead of going through
424
+ // `ExecutionSession`, so it has to attach the spend ledger itself.
425
+ // No detach: the listener lives on this context and dies with it.
426
+ // No `projectId`/`documentId` either — a run request names a workflow
427
+ // and a user, and nothing on this path carries project attribution.
428
+ // Progress on the row, so `get_job` during a long background render
429
+ // answers with a frame count instead of only "running".
430
+ executionContext.addMessageListener(createJobProgressRecorder({
431
+ write: async (progress) => {
432
+ await Job.recordProgressIfActive(job.id, { ...progress });
433
+ }
434
+ }));
435
+ attachRunCostLedger(executionContext, {
436
+ userId,
437
+ workflowId,
438
+ projectId: workflowProjectId,
439
+ documentId: options.documentId ?? null,
440
+ nodeType: nodeTypeLookup(runnableGraph.nodes),
441
+ resolveSecret: (key) => executionContext.getSecret(key)
442
+ });
443
+ return executionContext;
444
+ })()
445
+ };
446
+ if (supervisorHandle) {
447
+ runnerOptions.supervisor = supervisorHandle;
448
+ }
449
+ runner = new WorkflowRunner(job.id, runnerOptions);
450
+ hydratedGraph = hydrateRunGraph(runnableGraph, registry);
451
+ }
452
+ catch (error) {
453
+ const message = error instanceof Error ? error.message : String(error);
454
+ await markJobFailed(job, message);
455
+ throw error instanceof Error ? error : new Error(message);
456
+ }
457
+ if (!interactive && (options.background ?? false)) {
458
+ // Detached: the payload is the receipt, not the result. Awaiting the run
459
+ // here made `background: true` a label on a blocking call — an agent that
460
+ // started a two-minute render still had to sit through it, and its turn
461
+ // was cancelled before the job it started could be reported.
462
+ void (async () => {
463
+ try {
464
+ const result = await runner.run({ job_id: job.id, workflow_id: workflowId, params }, hydratedGraph);
465
+ await finalizeWorkflowRunJob(job, result);
466
+ }
467
+ catch (error) {
468
+ await markJobFailed(job, error instanceof Error ? error.message : String(error));
469
+ }
470
+ })();
471
+ return {
472
+ kind: "payload",
473
+ payload: {
474
+ job_id: job.id,
475
+ // The jobs API keys every other answer on `id`; a receipt that spells
476
+ // it only `job_id` sent callers to `get_job(undefined)`.
477
+ id: job.id,
478
+ workflow_id: workflowId,
479
+ status: "running",
480
+ background: true,
481
+ poll: `Poll get_job with job_id "${job.id}" until it settles; its outputs are on the settled job.`
482
+ }
483
+ };
484
+ }
485
+ if (!interactive) {
486
+ let result;
487
+ try {
488
+ result = await runner.run({ job_id: job.id, workflow_id: workflowId, params }, hydratedGraph);
489
+ }
490
+ catch (error) {
491
+ const message = error instanceof Error ? error.message : String(error);
492
+ await markJobFailed(job, message);
493
+ throw error instanceof Error ? error : new Error(message);
494
+ }
495
+ await finalizeWorkflowRunJob(job, result);
496
+ return {
497
+ kind: "payload",
498
+ payload: buildWorkflowRunPayload(job.id, workflowId, result, debug, {
499
+ background: options.background ?? false
500
+ })
501
+ };
502
+ }
503
+ // Interactive: the run keeps going between round trips, so a failure
504
+ // finalizes the job inside the run promise and becomes the final report.
505
+ // The promise never rejects; the session depends on that.
506
+ const runPromise = (async () => {
507
+ try {
508
+ const result = await runner.run({ job_id: job.id, workflow_id: workflowId, params }, hydratedGraph);
509
+ await finalizeWorkflowRunJob(job, result);
510
+ return buildWorkflowRunPayload(job.id, workflowId, result, debug, {
511
+ background: false
512
+ });
513
+ }
514
+ catch (error) {
515
+ const message = error instanceof Error ? error.message : String(error);
516
+ await markJobFailed(job, message);
517
+ // Keep the payload shape of a failed run — the debug surface still gets
518
+ // a summary and verdict — instead of a bare {status, error} object.
519
+ const failed = {
520
+ status: "failed",
521
+ error: message,
522
+ messages: [],
523
+ outputs: {}
524
+ };
525
+ return buildWorkflowRunPayload(job.id, workflowId, failed, debug, {
526
+ background: false
527
+ });
528
+ }
529
+ finally {
530
+ supervisorHandle?.close();
531
+ }
532
+ })();
533
+ let session;
534
+ try {
535
+ session = debugSessions.create({
536
+ userId,
537
+ workflowId,
538
+ jobId: job.id,
539
+ handle: interactiveHandle,
540
+ done: runPromise,
541
+ cancel: () => runner.cancel()
542
+ });
543
+ }
544
+ catch (error) {
545
+ // The run is already going; without a session nobody can answer it, so
546
+ // cancel it rather than leave an unreachable run behind.
547
+ runner.cancel();
548
+ if (error instanceof TooManyDebugSessionsError) {
549
+ return { kind: "error", status: 429, detail: error.message };
550
+ }
551
+ throw error instanceof Error ? error : new Error(String(error));
552
+ }
553
+ const event = await session.waitForEvent();
554
+ return {
555
+ kind: "payload",
556
+ payload: debugSessionEventPayload(session, event)
557
+ };
558
+ }
559
+ /** Read a session's current state without waiting. */
560
+ export function peekDebugSession(sessionId, userId) {
561
+ const session = debugSessions.get(sessionId, userId);
562
+ if (!session) {
563
+ return { kind: "error", status: 404, detail: "Debug session not found" };
564
+ }
565
+ return {
566
+ kind: "payload",
567
+ payload: debugSessionEventPayload(session, session.peek())
568
+ };
569
+ }
570
+ /**
571
+ * Answer the escalation a run is parked on, then wait for whatever comes next
572
+ * — the following escalation, or the run's final report.
573
+ */
574
+ export async function submitEscalationVerdict(sessionId, userId, escalationId, verdict) {
575
+ const session = debugSessions.get(sessionId, userId);
576
+ if (!session) {
577
+ return { kind: "error", status: 404, detail: "Debug session not found" };
578
+ }
579
+ const rejected = await session.submitVerdict(escalationId, verdict);
580
+ if (rejected) {
581
+ return { kind: "error", status: 400, detail: rejected.error };
582
+ }
583
+ const event = await session.waitForEvent();
584
+ return {
585
+ kind: "payload",
586
+ payload: debugSessionEventPayload(session, event)
587
+ };
588
+ }
589
+ /** Cancel a session's run and return its final report. */
590
+ export async function cancelDebugSession(sessionId, userId) {
591
+ const session = debugSessions.get(sessionId, userId);
592
+ if (!session) {
593
+ return { kind: "error", status: 404, detail: "Debug session not found" };
594
+ }
595
+ const report = await session.cancel();
596
+ return { kind: "payload", payload: { ...report, session_id: session.id } };
597
+ }
598
+ //# sourceMappingURL=workflow-run.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workflow-run.js","sourceRoot":"","sources":["../../src/service/workflow-run.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACpE,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACxE,OAAO,EACL,qBAAqB,EACrB,wBAAwB,EAEzB,MAAM,uBAAuB,CAAC;AAO/B,OAAO,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACxE,OAAO,EAAE,cAAc,EAAE,MAAM,uBA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