@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,633 @@
1
+ /**
2
+ * Headless driver for the shared app runtime core.
3
+ *
4
+ * The fold rules, the state namespaces, the run policy, and the action
5
+ * vocabulary all live in `@nodetool-ai/app-runtime` — the same code the web and
6
+ * mobile runtimes run. This file only supplies what a headless run needs: a
7
+ * workflow executor per operation and the bookkeeping that turns an awaited run
8
+ * into an invocation, plus the in-memory resource collections a run gets in
9
+ * place of the server-backed ones the web runtime reads.
10
+ *
11
+ * The web engine's reactive subgraph runs collapse to full workflow runs here
12
+ * (the headless kernel has no browser worker), which the report notes rather
13
+ * than simulates.
14
+ */
15
+ import { applyEvent, applyEvents, createInstanceState, decideRun, evaluateCondition, formatTemplate, initialVariableValues, isMissingRequiredMediaValue, isLiveInvocation, liveInvocations, messagesToEvents, operationError, outputVariableTargets, parseCondition, readRef, resolveOperationParams, stateKey } from "@nodetool-ai/app-runtime";
16
+ import { isString } from "../predicates.js";
17
+ /**
18
+ * A condition as a failure message names it: `draft notEmpty`, `count gt 3`.
19
+ * The stored props are what an author sees in the builder, so the message
20
+ * points at something they can find.
21
+ */
22
+ export const describeCondition = (props) => {
23
+ if (!props?.binding)
24
+ return null;
25
+ const op = props.op ?? "notEmpty";
26
+ const value = props.value === undefined || props.value === "" ? "" : ` ${props.value}`;
27
+ return `${props.binding} ${op}${value}`;
28
+ };
29
+ /**
30
+ * Why a ref cannot be written, or null when it can.
31
+ *
32
+ * Only a run fills an output slot or an operation's execution state, so a
33
+ * script that writes one has named the wrong thing — the value would land in
34
+ * the inputs namespace, where nothing reads it.
35
+ */
36
+ export const writeRefusal = (ref) => {
37
+ switch (ref.kind) {
38
+ case "output":
39
+ return "resolves to an output, which only a run can fill, and cannot be set";
40
+ case "execution":
41
+ return "resolves to execution state, which only a run can fill, and cannot be set";
42
+ default:
43
+ return null;
44
+ }
45
+ };
46
+ /** How to seed a collection, named in every message about an unseeded one. */
47
+ export const seedResourceHint = (resourceBindingId) => `seed it with an interaction step {"seedResource":{"id":"${resourceBindingId}","items":[{"id":"item-1"}]}} or a "resource:${resourceBindingId}" param`;
48
+ /**
49
+ * The collection behind one resource binding, held in memory for the length of
50
+ * one debug run.
51
+ *
52
+ * The web runtime reads collections over tRPC and hands widgets a `ResourceRef`
53
+ * to act on; a headless run has no server and no user, so it gets the same
54
+ * envelope from a seeded provider instead. Nothing here touches the database —
55
+ * a run only ever sees what the interaction script or `--params` put in.
56
+ *
57
+ * Selection follows `useBoundResource`: a pinned `fixedId` wins, else the item
58
+ * the last command or `select` chose, else the first member — so a picker that
59
+ * nobody touched still has something to send.
60
+ */
61
+ export class InMemoryResourceProvider {
62
+ kind;
63
+ items = [];
64
+ pinnedId;
65
+ chosenId = null;
66
+ seq = 0;
67
+ constructor(init) {
68
+ this.kind = init.kind;
69
+ this.pinnedId = init.pinnedId ?? null;
70
+ for (const seed of init.items ?? [])
71
+ this.items.push(this.toItem(seed));
72
+ }
73
+ /**
74
+ * Timestamps come from a counter, not the clock, so two runs of the same
75
+ * script produce identical reports.
76
+ */
77
+ toItem(seed) {
78
+ this.seq += 1;
79
+ return {
80
+ ref: { kind: this.kind, id: seed.id, revision: seed.revision ?? 1 },
81
+ name: seed.name ?? seed.id,
82
+ projectId: seed.projectId ?? null,
83
+ contentType: seed.contentType ?? null,
84
+ updatedAt: seed.updatedAt ?? new Date(this.seq * 1000).toISOString(),
85
+ document: seed.document
86
+ };
87
+ }
88
+ list() {
89
+ return [...this.items];
90
+ }
91
+ get(id) {
92
+ return this.items.find((item) => item.ref.id === id) ?? null;
93
+ }
94
+ /** The item a `from: "resource"` param sends and a command acts on. */
95
+ selected() {
96
+ const targetId = this.pinnedId ?? this.chosenId ?? this.items[0]?.ref.id ?? null;
97
+ if (!targetId)
98
+ return null;
99
+ // A pinned id can sit outside the collection; point at it anyway, the way
100
+ // the web runtime does.
101
+ return this.get(targetId)?.ref ?? { kind: this.kind, id: targetId };
102
+ }
103
+ select(ref) {
104
+ this.chosenId = ref?.id ?? null;
105
+ }
106
+ apply(op) {
107
+ const args = op.args ?? {};
108
+ const name = isString(args.name) ? args.name : undefined;
109
+ switch (op.command) {
110
+ case "read": {
111
+ const ref = op.ref ?? this.selected();
112
+ return ref ? this.get(ref.id) : null;
113
+ }
114
+ case "create":
115
+ case "upload": {
116
+ const seed = {
117
+ id: isString(args.id) ? args.id : this.nextId(),
118
+ document: args.document
119
+ };
120
+ if (name !== undefined) {
121
+ seed.name = name;
122
+ }
123
+ if (isString(args.contentType)) {
124
+ seed.contentType = args.contentType;
125
+ }
126
+ const item = this.toItem(seed);
127
+ this.items.push(item);
128
+ this.chosenId = item.ref.id;
129
+ return item;
130
+ }
131
+ case "update": {
132
+ const ref = op.ref ?? this.selected();
133
+ const index = ref
134
+ ? this.items.findIndex((i) => i.ref.id === ref.id)
135
+ : -1;
136
+ if (!ref || index < 0) {
137
+ throw new Error(`Resource command "update" has nothing to write: the collection holds no resource "${ref?.id ?? ""}".`);
138
+ }
139
+ const current = this.items[index];
140
+ // The web providers reject a write whose revision is behind the row;
141
+ // headless keeps the rule so a script cannot pretend a stale write works.
142
+ if (ref.revision !== undefined &&
143
+ current.ref.revision !== undefined &&
144
+ ref.revision < current.ref.revision) {
145
+ throw new Error(`Resource command "update" carries revision ${ref.revision} but resource "${ref.id}" is at ${current.ref.revision}.`);
146
+ }
147
+ this.seq += 1;
148
+ const next = {
149
+ ...current,
150
+ ref: { ...current.ref, revision: (current.ref.revision ?? 0) + 1 },
151
+ name: name ?? current.name,
152
+ document: "document" in args ? args.document : current.document,
153
+ updatedAt: new Date(this.seq * 1000).toISOString()
154
+ };
155
+ this.items[index] = next;
156
+ return next;
157
+ }
158
+ case "delete": {
159
+ const ref = op.ref ?? this.selected();
160
+ const index = ref
161
+ ? this.items.findIndex((i) => i.ref.id === ref.id)
162
+ : -1;
163
+ if (!ref || index < 0) {
164
+ throw new Error(`Resource command "delete" has nothing to remove: the collection holds no resource "${ref?.id ?? ""}".`);
165
+ }
166
+ const [removed] = this.items.splice(index, 1);
167
+ if (this.chosenId === removed.ref.id)
168
+ this.chosenId = null;
169
+ return removed;
170
+ }
171
+ }
172
+ }
173
+ /** An id no member holds, so `create` twice makes two resources. */
174
+ nextId() {
175
+ let n = this.items.length + 1;
176
+ while (this.get(`${this.kind}-${n}`))
177
+ n += 1;
178
+ return `${this.kind}-${n}`;
179
+ }
180
+ }
181
+ /**
182
+ * The timeout a run actually gets: the operation's own `timeoutMs` capped by
183
+ * the harness-wide ceiling, so `--timeout` always shortens and never extends.
184
+ */
185
+ export const effectiveTimeoutMs = (operationTimeoutMs, ceilingMs) => {
186
+ const candidates = [operationTimeoutMs, ceilingMs].filter((value) => value != null && value > 0);
187
+ return candidates.length > 0 ? Math.min(...candidates) : null;
188
+ };
189
+ const TIMED_OUT = Symbol("timed-out");
190
+ /** Resolve, or hand back {@link TIMED_OUT} once `ms` elapses. */
191
+ const withTimeout = async (promise, ms) => {
192
+ if (ms == null)
193
+ return promise;
194
+ let timer;
195
+ const expiry = new Promise((resolve) => {
196
+ timer = setTimeout(() => resolve(TIMED_OUT), ms);
197
+ });
198
+ try {
199
+ return await Promise.race([promise, expiry]);
200
+ }
201
+ finally {
202
+ if (timer)
203
+ clearTimeout(timer);
204
+ }
205
+ };
206
+ export class HeadlessAppRuntime {
207
+ _state = createInstanceState();
208
+ runCount = 0;
209
+ /**
210
+ * Every state write goes through here, so a widget's conditions are re-read
211
+ * after each fold — exactly where the web runtime re-renders.
212
+ */
213
+ get state() {
214
+ return this._state;
215
+ }
216
+ set state(next) {
217
+ this._state = next;
218
+ this.refreshWidgets();
219
+ }
220
+ /** Every invocation started, in order. */
221
+ invocations = [];
222
+ /** Every activity label reported, in order. */
223
+ activity = [];
224
+ init;
225
+ byId = new Map();
226
+ /** Runs the harness stopped waiting for, still settling in the background. */
227
+ inFlight = new Map();
228
+ invocationSeq = 0;
229
+ /** Widget conditions, parsed once, plus the state each evaluation writes. */
230
+ compiled = [];
231
+ widgetStates = new Map();
232
+ /** Declared resource bindings, keyed by id. */
233
+ resourceBindings = new Map();
234
+ /** Seeded collections, keyed by resource binding id. */
235
+ providers = new Map();
236
+ /** Every resource command dispatched, in order. */
237
+ resourceCommands = [];
238
+ constructor(init) {
239
+ this.init = init;
240
+ const scope = init.scope;
241
+ for (const binding of init.resources ?? []) {
242
+ this.resourceBindings.set(binding.id, binding);
243
+ }
244
+ for (const widget of init.widgets ?? []) {
245
+ const state = {
246
+ visible: true,
247
+ disabled: false,
248
+ everReachable: false,
249
+ visibleWhen: describeCondition(widget.visibleWhen),
250
+ disabledWhen: describeCondition(widget.disabledWhen)
251
+ };
252
+ this.compiled.push({
253
+ init: widget,
254
+ visible: scope ? parseCondition(widget.visibleWhen, scope) : null,
255
+ disabled: scope ? parseCondition(widget.disabledWhen, scope) : null,
256
+ state
257
+ });
258
+ this.widgetStates.set(widget.id, state);
259
+ }
260
+ for (const operation of init.operations) {
261
+ this.byId.set(operation.binding.id, operation);
262
+ this.state = applyEvent(this.state, {
263
+ type: "seedInputs",
264
+ values: operation.defaults
265
+ });
266
+ }
267
+ this.state = applyEvent(this.state, {
268
+ type: "seedVariables",
269
+ values: initialVariableValues(init.variables ?? [])
270
+ });
271
+ }
272
+ /**
273
+ * Re-evaluate every widget's `visibleWhen`/`disabledWhen` against the current
274
+ * state. An unset or unresolvable condition leaves the widget visible and
275
+ * enabled, the same fallback the web runtime uses.
276
+ */
277
+ refreshWidgets() {
278
+ for (const widget of this.compiled) {
279
+ const visible = widget.visible
280
+ ? evaluateCondition(this._state, widget.visible)
281
+ : true;
282
+ const disabled = widget.disabled
283
+ ? evaluateCondition(this._state, widget.disabled)
284
+ : false;
285
+ widget.state.visible = visible;
286
+ widget.state.disabled = disabled;
287
+ widget.state.everReachable ||= visible && !disabled;
288
+ }
289
+ }
290
+ /** A widget's current visibility, or null when the runtime has no such widget. */
291
+ widgetState(widgetId) {
292
+ return this.widgetStates.get(widgetId) ?? null;
293
+ }
294
+ /**
295
+ * What a widget displays: its `format` template rendered against the current
296
+ * state, or null when it has none and shows its bound value raw.
297
+ */
298
+ display(widgetId) {
299
+ const widget = this.compiled.find((w) => w.init.id === widgetId);
300
+ if (!widget?.init.format || !this.init.scope)
301
+ return null;
302
+ return formatTemplate(widget.init.format, this._state, this.init.scope);
303
+ }
304
+ /**
305
+ * Attach a collection to a declared resource binding, replacing whatever was
306
+ * seeded before. Seeding is the only way a headless run gets resources.
307
+ */
308
+ seedResource(resourceBindingId, items) {
309
+ const binding = this.resourceBindings.get(resourceBindingId);
310
+ if (!binding) {
311
+ const declared = [...this.resourceBindings.keys()];
312
+ throw new Error(`No resource binding "${resourceBindingId}" is declared by this app` +
313
+ (declared.length > 0 ? ` (declared: ${declared.join(", ")}).` : "."));
314
+ }
315
+ const providerOptions = { kind: binding.kind, items };
316
+ if (binding.scope.fixedId) {
317
+ providerOptions.pinnedId = binding.scope.fixedId;
318
+ }
319
+ const provider = new InMemoryResourceProvider(providerOptions);
320
+ this.providers.set(resourceBindingId, provider);
321
+ return provider;
322
+ }
323
+ /** The collection behind a resource binding, or null when nothing seeded it. */
324
+ resourceProvider(resourceBindingId) {
325
+ return this.providers.get(resourceBindingId) ?? null;
326
+ }
327
+ /** Resource bindings the document declares, in document order. */
328
+ get resourceBindingList() {
329
+ return [...this.resourceBindings.values()];
330
+ }
331
+ /** Last error reported against an operation's active invocation. */
332
+ errorFor(operationId) {
333
+ return operationError(this.state, operationId) ?? null;
334
+ }
335
+ get error() {
336
+ return this.errorFor(this.init.defaultOperationId);
337
+ }
338
+ /**
339
+ * Write a value through its resolved binding.
340
+ *
341
+ * A ref {@link writeRefusal} rejects throws instead of landing in the inputs
342
+ * namespace: an output slot only a run fills, written as an input, is a value
343
+ * no reader ever sees, and the step that wrote it must not report success.
344
+ */
345
+ write(ref, value) {
346
+ const refusal = writeRefusal(ref);
347
+ if (refusal)
348
+ throw new Error(refusal);
349
+ const key = stateKey(ref);
350
+ switch (ref.kind) {
351
+ case "variable":
352
+ this.state = applyEvent(this.state, {
353
+ type: "setVariable",
354
+ variableId: ref.variableId,
355
+ value
356
+ });
357
+ break;
358
+ case "view":
359
+ this.state = applyEvent(this.state, { type: "setView", key, value });
360
+ break;
361
+ default:
362
+ this.state = applyEvent(this.state, { type: "setInput", key, value });
363
+ }
364
+ }
365
+ /**
366
+ * HOLDOUT (anti-slop/no-unknown-returns): a slot holds a workflow value —
367
+ * the open domain `AppInstanceState` stores as `unknown`.
368
+ */
369
+ read(ref) {
370
+ if (!ref)
371
+ return undefined;
372
+ const key = stateKey(ref);
373
+ switch (ref.kind) {
374
+ case "output":
375
+ return this.state.outputs[key]?.value;
376
+ case "variable":
377
+ return this.state.variables[key];
378
+ case "view":
379
+ return this.state.view[key];
380
+ case "execution":
381
+ return readRef(this.state, {
382
+ source: "execution",
383
+ operationId: ref.operationId,
384
+ field: ref.field
385
+ });
386
+ default:
387
+ return this.state.inputs[key]?.value;
388
+ }
389
+ }
390
+ /**
391
+ * Params for one operation's run: every input resolved through its mapping
392
+ * (widget value, variable, constant, or resource), keyed by node name.
393
+ */
394
+ collectParams(operationId) {
395
+ const operation = this.byId.get(operationId);
396
+ if (!operation)
397
+ return {};
398
+ return resolveOperationParams({
399
+ operation: operation.binding,
400
+ state: this.state,
401
+ inputName: (nodeId) => operation.inputNameByNodeId.get(nodeId),
402
+ inputNodeIds: operation.inputNodeIds,
403
+ resourceRef: (resourceBindingId) => this.providers.get(resourceBindingId)?.selected() ?? undefined
404
+ });
405
+ }
406
+ /**
407
+ * Refuse to run an operation whose inputs read a collection nothing seeded.
408
+ * Sending no param for it would look like a passing run against an app that
409
+ * cannot work, which is the failure this harness exists to catch.
410
+ */
411
+ assertResourcesSeeded(binding) {
412
+ for (const [nodeId, mapping] of Object.entries(binding.inputs)) {
413
+ if (mapping.from !== "resource")
414
+ continue;
415
+ const id = mapping.resourceBindingId;
416
+ const provider = this.providers.get(id);
417
+ if (!provider) {
418
+ throw new Error(`Operation "${binding.id}" input "${nodeId}" comes from resource binding "${id}", which nothing seeded — ${seedResourceHint(id)}.`);
419
+ }
420
+ if (!provider.selected()) {
421
+ throw new Error(`Operation "${binding.id}" input "${nodeId}" comes from resource binding "${id}", which was seeded empty — the run has no resource to send. Seed at least one item.`);
422
+ }
423
+ }
424
+ }
425
+ assertRequiredInputs(operation) {
426
+ const params = this.collectParams(operation.binding.id);
427
+ for (const nodeId of operation.inputNodeIds) {
428
+ const nodeType = operation.inputNodeTypeByNodeId?.get(nodeId);
429
+ const name = operation.inputNameByNodeId.get(nodeId);
430
+ if (nodeType &&
431
+ name &&
432
+ isMissingRequiredMediaValue(nodeType, params[name])) {
433
+ throw new Error(`Input "${name}" requires a media value before operation "${operation.binding.name}" can run.`);
434
+ }
435
+ }
436
+ }
437
+ /** Dispatch one action; a `run` executes the workflow and folds its stream. */
438
+ async dispatch(action) {
439
+ switch (action.kind) {
440
+ case "run":
441
+ await this.run(action.operationId);
442
+ break;
443
+ case "cancel":
444
+ this.cancel(action.operationId ?? this.init.defaultOperationId, action.invocationId);
445
+ break;
446
+ case "setVariable":
447
+ this.state = applyEvent(this.state, {
448
+ type: "setVariable",
449
+ variableId: action.variableId,
450
+ value: action.value
451
+ });
452
+ break;
453
+ case "toggleVariable":
454
+ this.state = applyEvent(this.state, {
455
+ type: "toggleVariable",
456
+ variableId: action.variableId
457
+ });
458
+ break;
459
+ case "resourceCommand": {
460
+ const provider = this.providers.get(action.resourceBindingId);
461
+ if (!provider) {
462
+ throw new Error(`Resource command "${action.command}" targets resource binding "${action.resourceBindingId}", which nothing seeded — ${seedResourceHint(action.resourceBindingId)}.`);
463
+ }
464
+ const command = {
465
+ command: action.command,
466
+ ref: provider.selected()
467
+ };
468
+ if (action.args) {
469
+ command.args = action.args;
470
+ }
471
+ provider.apply(command);
472
+ this.resourceCommands.push({
473
+ resourceBindingId: action.resourceBindingId,
474
+ command: action.command
475
+ });
476
+ break;
477
+ }
478
+ case "openResource":
479
+ // Opening a resource in its own editor is the host app's job, and a
480
+ // headless run has no editor — record the request and move on.
481
+ this.resourceCommands.push({
482
+ resourceBindingId: action.resourceBindingId,
483
+ command: "open"
484
+ });
485
+ break;
486
+ }
487
+ }
488
+ /** Cancel an operation's live invocations (or one named invocation). */
489
+ cancel(operationId, invocationId) {
490
+ // A named invocation is filtered on liveness like the bare path: cancelling
491
+ // one that already completed or failed would overwrite what it reported.
492
+ const targets = invocationId
493
+ ? [invocationId].filter((id) => {
494
+ const invocation = this.state.invocations[id];
495
+ return invocation ? isLiveInvocation(invocation) : false;
496
+ })
497
+ : liveInvocations(this.state, operationId).map((i) => i.id);
498
+ for (const id of targets) {
499
+ this.state = applyEvent(this.state, {
500
+ type: "invocationStatus",
501
+ invocationId: id,
502
+ status: "cancelled"
503
+ });
504
+ }
505
+ return targets;
506
+ }
507
+ timeoutFor(operation) {
508
+ return effectiveTimeoutMs(operation.timeoutMs, this.init.timeoutMs);
509
+ }
510
+ /**
511
+ * Start one run, after `decideRun` says what the operation's policy makes of
512
+ * whatever is already in flight.
513
+ */
514
+ async run(operationId) {
515
+ const operation = this.byId.get(operationId);
516
+ if (!operation) {
517
+ throw new Error(`No operation "${operationId}" is declared by this app.`);
518
+ }
519
+ if (!operation.runWorkflow) {
520
+ throw new Error(`Operation "${operationId}" has no runnable workflow — its binding could not be resolved.`);
521
+ }
522
+ this.assertResourcesSeeded(operation.binding);
523
+ this.assertRequiredInputs(operation);
524
+ const decision = decideRun(this.state, operation.binding);
525
+ const targets = decision.kind === "replace"
526
+ ? decision.cancel
527
+ : decision.kind === "queue"
528
+ ? decision.after
529
+ : [];
530
+ const timeoutMs = this.timeoutFor(operation.binding);
531
+ if (decision.kind === "replace") {
532
+ for (const id of targets)
533
+ this.cancel(operationId, id);
534
+ }
535
+ else if (decision.kind === "queue") {
536
+ // Wait for what is ahead. A run the harness already gave up on is bounded
537
+ // by the same timeout, so queueing cannot hang the report.
538
+ for (const id of targets) {
539
+ const pending = this.inFlight.get(id);
540
+ if (pending)
541
+ await withTimeout(pending, timeoutMs);
542
+ this.cancel(operationId, id);
543
+ }
544
+ }
545
+ this.invocationSeq += 1;
546
+ const invocation = {
547
+ id: `headless-${this.invocationSeq}`,
548
+ operationId,
549
+ status: "running",
550
+ // Deterministic, so two harness runs produce identical reports.
551
+ startedAt: this.invocationSeq
552
+ };
553
+ const record = {
554
+ id: invocation.id,
555
+ operationId,
556
+ decision: decision.kind,
557
+ decisionTargets: targets,
558
+ runIndex: null,
559
+ timedOutMs: null,
560
+ activity: []
561
+ };
562
+ this.invocations.push(record);
563
+ this.state = applyEvent(this.state, {
564
+ type: "runStarted",
565
+ invocation,
566
+ outputKeys: [...operation.outputKeyByNodeId.values()],
567
+ variableKeys: Object.values(operation.binding.outputs)
568
+ .filter((mapping) => mapping.to === "variable")
569
+ .map((mapping) => mapping.variableId)
570
+ });
571
+ this.runCount += 1;
572
+ const pending = operation.runWorkflow(this.collectParams(operationId));
573
+ // A run the harness never sees the end of must not take the process with
574
+ // it: swallow its eventual settlement and keep it for a queued successor.
575
+ this.inFlight.set(invocation.id, pending.then(() => undefined, () => undefined));
576
+ const outcome = await withTimeout(pending, timeoutMs);
577
+ if (outcome === TIMED_OUT) {
578
+ // The invocation stays live: the job is still running on the server, the
579
+ // harness simply stopped waiting. A later run of the same operation
580
+ // collides with it, which is exactly what the policy is for.
581
+ record.timedOutMs = timeoutMs;
582
+ this.state = applyEvent(this.state, {
583
+ type: "invocationError",
584
+ invocationId: invocation.id,
585
+ error: `timed out after ${timeoutMs}ms`
586
+ });
587
+ return;
588
+ }
589
+ this.inFlight.delete(invocation.id);
590
+ record.runIndex = outcome.runIndex;
591
+ // The headless runner awaits the whole stream, so every message belongs to
592
+ // the invocation just started — including the `job_update` and `edge_update`
593
+ // the kernel stamps with the *server's* job id, which the fold would
594
+ // otherwise fail to resolve and drop, losing a job-level failure.
595
+ const stamped = outcome.messages.map((message) => ({
596
+ ...message,
597
+ job_id: invocation.id
598
+ }));
599
+ const outputVariables = new Map(outputVariableTargets(operation.binding).map((t) => [
600
+ t.nodeId,
601
+ t.variableId
602
+ ]));
603
+ const events = messagesToEvents(stamped, {
604
+ resolveInvocation: (jobId) => jobId ? (this.state.invocations[jobId] ?? null) : null,
605
+ outputKey: (_operationId, nodeId) => operation.outputKeyByNodeId.get(nodeId) ?? null,
606
+ outputVariable: (_operationId, nodeId) => outputVariables.get(nodeId) ?? null
607
+ });
608
+ this.recordActivity(record, events);
609
+ this.state = applyEvents(this.state, events);
610
+ this.state = applyEvent(this.state, {
611
+ type: "invocationStatus",
612
+ invocationId: invocation.id,
613
+ status: this.state.invocations[invocation.id]?.status === "failed"
614
+ ? "failed"
615
+ : "completed"
616
+ });
617
+ }
618
+ recordActivity(record, events) {
619
+ for (const event of events) {
620
+ if (event.type !== "invocationActivity")
621
+ continue;
622
+ if (record.activity.at(-1) === event.label)
623
+ continue;
624
+ record.activity.push(event.label);
625
+ this.activity.push({
626
+ invocationId: record.id,
627
+ operationId: record.operationId,
628
+ label: event.label
629
+ });
630
+ }
631
+ }
632
+ }
633
+ //# sourceMappingURL=runtime.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime.js","sourceRoot":"","sources":["../../src/app-debug/runtime.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,EACL,UAAU,EACV,WAAW,EACX,mBAAmB,EACnB,SAAS,EACT,iBAAiB,EACjB,cAAc,EACd,qBAAqB,EACrB,2BAA2B,EAC3B,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EAChB,cAAc,EACd,qBAAqB,EACrB,cAAc,EACd,OAAO,EACP,sBAAsB,EACtB,QAAQ,EAgBT,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAiE5C;;;;GAIG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAC/B,KAAwC,EACzB,EAAE;IACjB,IAAI,CAAC,KAAK,EAAE,OAAO;QAAE,OAAO,IAAI,CAAC;IACjC,MAAM,EAAE,GAAG,KAAK,CAAC,EAAE,IAAI,UAAU,CAAC;IAClC,MAAM,KAAK,GACT,KAAK,CAAC,KAAK,KAAK,SAAS,IAAI,KAAK,CAAC,KAAK,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC;IAC3E,OAAO,GAAG,KAAK,CAAC,OAA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