@squeed/flow-sdk 2.0.16 → 2.0.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -261,6 +261,70 @@ menu. The [small-step walkthrough](examples/configuration-basics/README.md) show
261
261
  two consumers sharing values, editing them, and exporting plain data, before
262
262
  introducing field-level mapping and returning values inline.
263
263
 
264
+ ## Connect Your Execution Backend
265
+
266
+ Property schemas and bindings edit data; they do not execute it. Use
267
+ `createWorkflowExecution(adapter, onChange)` to submit that data through your
268
+ own API and receive normalized step progress and output:
269
+
270
+ ```ts
271
+ import { createWorkflowExecution } from "@squeed/flow-sdk";
272
+ import type { WorkflowExecutionAdapter } from "@squeed/flow-sdk";
273
+
274
+ const adapter: WorkflowExecutionAdapter<MyWorkflow> = {
275
+ execute: async ({ input, executionId, signal }) => {
276
+ const response = await fetch("/api/workflows/run", {
277
+ method: "POST",
278
+ headers: { "Content-Type": "application/json" },
279
+ body: JSON.stringify({ workflow: input, executionId }),
280
+ signal,
281
+ });
282
+ if (!response.ok) throw new Error(`Execution failed: ${response.status}`);
283
+ return await response.json();
284
+ },
285
+ subscribe: ({ executionId, signal }, receive) =>
286
+ feedback.subscribe(executionId, receive, signal),
287
+ };
288
+
289
+ const execution = createWorkflowExecution(adapter, setRun);
290
+ await execution.run(workflowState);
291
+ ```
292
+
293
+ `MyWorkflow`, `feedback.subscribe`, and `setRun` above are supplied by your
294
+ application. Map your API response and feedback to `WorkflowExecutionUpdate`:
295
+
296
+ ```ts
297
+ receive({
298
+ executionId,
299
+ step: { id: "fetch", status: "completed", output: { count: 3 } },
300
+ });
301
+ receive({ executionId, status: "completed", output: { result: "ready" } });
302
+ ```
303
+
304
+ - `subscribe` must resolve with an unsubscribe function only after feedback is
305
+ ready. Execution starts afterwards, so early events are not lost. SSE,
306
+ WebSockets, and polling can all implement this adapter.
307
+ - Your backend must use or correlate the supplied execution ID. Responses may
308
+ return an update, or nothing for an acknowledgement. Completion comes from
309
+ an explicit terminal status, not merely a successful HTTP response.
310
+ - `onChange` receives run status, per-step status/output, and final output.
311
+ Use your bindings to map step IDs to node IDs and update your diagram or
312
+ output panel; the controller does not mutate the workflow or canvas.
313
+ - A second run is rejected while one is active. Terminal updates release the
314
+ listener. Errors before terminal feedback reject `run()` and emit a failed
315
+ state; handle the rejection. Terminal feedback takes precedence over late
316
+ HTTP responses or errors. Each `run()` resolves with its own execution state.
317
+ - Step updates merge with the previous step: omitted output/error fields are
318
+ preserved; explicitly passing `undefined` clears them.
319
+ - Supply `adapter.cancel` to support `execution.cancel()`. Call
320
+ `execution.dispose()` on unmount to abort local requests and unsubscribe;
321
+ disposal does not cancel the remote job.
322
+ - Keep service credentials in your backend. The SDK does not select a server,
323
+ forward Squeed credentials, or translate workflows into another tool's format.
324
+
325
+ This API is for SDK hosts. It does not automatically wire the Squeed editor's
326
+ Execution panel or its Backflow-specific execution mapping.
327
+
264
328
  ## Maintainer Guide
265
329
 
266
330
  The SDK Test **Form Connection** dataset loads
@@ -317,9 +381,9 @@ const resourceMappings = {
317
381
  version: 1 as const,
318
382
  templates: true,
319
383
  fields: [
320
- { type: "CastLlmConfig", field: "prompt" },
321
- { type: "CastLlmConfig", field: "model", createEmpty: true },
322
- { type: "CastDatabaseConfig", field: "data" },
384
+ { type: "LlmConfig", field: "prompt" },
385
+ { type: "LlmConfig", field: "model", createEmpty: true },
386
+ { type: "DatabaseConfig", field: "data" },
323
387
  ],
324
388
  },
325
389
  };