@oomol-lab/open-flow 0.1.0-beta.1 → 0.1.0-beta.11

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 (69) hide show
  1. package/dist/browser/DesignerIcon-ckcKnxxJ.js +2267 -0
  2. package/dist/browser/createResourceDialog-DhIU-HYW.js +111 -0
  3. package/dist/browser/{dist-CPuF50D9.js → dist-BZ5PTFAs.js} +1 -1
  4. package/dist/browser/dist-Bmb2mZvW.js +795 -0
  5. package/dist/browser/{dist-DWADUsVB.js → dist-By46o5UV.js} +47 -47
  6. package/dist/browser/dist-CP0883sY.js +4 -0
  7. package/dist/browser/{dist-CJpzJrLM.js → dist-Ce71Szg7.js} +894 -895
  8. package/dist/browser/dist-DSe6KRsr.js +1224 -0
  9. package/dist/browser/{dist-DUzA0Ukh.js → dist-DY4qlXTK.js} +140 -141
  10. package/dist/browser/{dist-3Mj8q8Pr.js → dist-DmuE3M0R.js} +53 -54
  11. package/dist/browser/{dist-BN4ZCyOB.js → dist-DpDLsYtO.js} +14 -15
  12. package/dist/browser/dist-DxahK_I8.js +2688 -0
  13. package/dist/browser/{esm-DGQbgYoJ.js → esm-C64_h7HF.js} +58 -59
  14. package/dist/browser/flow-authoring-module.d.ts +2 -2
  15. package/dist/browser/flow-authoring-node.d.ts +17 -7
  16. package/dist/browser/flow-authoring.d.ts +1 -1
  17. package/dist/browser/flow-authoring.js +5329 -286
  18. package/dist/browser/flow-change-schema.d.ts +3 -0
  19. package/dist/browser/flow-change.d.ts +131 -14
  20. package/dist/browser/flow-change.js +5216 -114
  21. package/dist/browser/flow-notifications.d.ts +5 -0
  22. package/dist/browser/flowChanges-BINNGoug.js +12896 -0
  23. package/dist/browser/{flowRunInputEditorStore-BeyUSWpO.js → flowRunInputEditorStore-NPGePkvP.js} +775 -776
  24. package/dist/browser/flowWorkspace-Dp_b8KXF.js +158409 -0
  25. package/dist/browser/{getPseudoElementBounds-ESJExRFX.js → getPseudoElementBounds-Dfqo78k7.js} +2051 -2542
  26. package/dist/browser/{languages-DgJehE1g.js → languages-i3Xmpt6S.js} +6 -15
  27. package/dist/browser/licenses.md +82 -0
  28. package/dist/browser/{markdownContent-DdlIRN3_.js → markdownContent-BawLYUjh.js} +24 -24
  29. package/dist/browser/select-CbQHq-GM.js +6851 -0
  30. package/dist/browser/theme.css +34 -34
  31. package/dist/browser/{typeScriptSession-mPCiA9sV.js → typeScriptSession-BoV-FDl3.js} +68 -69
  32. package/dist/browser/waitNotificationInputs-fzyKN6mk.js +29 -0
  33. package/dist/browser/workbench-contract.d.ts +8 -2
  34. package/dist/browser/workbench.css +1 -1
  35. package/dist/browser/workbench.d.ts +3 -1
  36. package/dist/browser/workbench.js +1647 -1299
  37. package/dist/browser/workbenchSelect-BjbJjlNd.js +435 -0
  38. package/dist/common/control-api-conformance.d.ts +1 -0
  39. package/dist/common/control-api-conformance.js +309 -81
  40. package/dist/common/control-api-errors.d.ts +12 -0
  41. package/dist/common/control-api.d.ts +95 -23
  42. package/dist/common/control-api.js +567 -364
  43. package/dist/common/engine-contract.d.ts +1 -1
  44. package/dist/common/flow-encoding.js +33 -15
  45. package/dist/common/flow-graph.d.ts +6 -0
  46. package/dist/common/flow-modules.d.ts +20 -0
  47. package/dist/common/flow-notifications.d.ts +5 -0
  48. package/dist/common/flow-schema.d.ts +8 -0
  49. package/dist/common/flow-semantics.d.ts +7 -5
  50. package/dist/common/flow-semantics.js +8880 -1702
  51. package/dist/common/integration-trigger.d.ts +2 -0
  52. package/dist/common/provider-triggers.js +4 -1
  53. package/dist/common/run-events.d.ts +2 -2
  54. package/dist/common/run-events.js +10 -16
  55. package/dist/common/run-lifecycle.d.ts +17 -2
  56. package/dist/common/run-lifecycle.js +53 -2
  57. package/dist/common/runtime-contract.d.ts +10 -2
  58. package/dist/common/runtime-contract.js +143 -6
  59. package/dist/common/scheduler.d.ts +52 -13
  60. package/dist/common/scheduler.js +7315 -242
  61. package/dist/index.d.ts +6 -5
  62. package/package.json +1 -1
  63. package/dist/browser/createResourceDialog-DXQz0thK.js +0 -504
  64. package/dist/browser/diagnostics-BGoGFvHA.js +0 -9237
  65. package/dist/browser/dist-BMqL-qR5.js +0 -1894
  66. package/dist/browser/dist-BpopSHwP.js +0 -1543
  67. package/dist/browser/dist-CUSrALSX.js +0 -1620
  68. package/dist/browser/flowWorkspace-DwyxAOBH.js +0 -47615
  69. package/dist/browser/workbenchSelect-B2s1HV-Y.js +0 -1374
@@ -27,6 +27,7 @@ export interface IntegrationStateContext {
27
27
  readonly saveSubscription: (subscription: Readonly<Record<string, JsonValue>>, reconcileAt: Date) => Promise<void>;
28
28
  }
29
29
  export interface IntegrationReceiveContext {
30
+ readonly signal?: AbortSignal;
30
31
  readonly admit: boolean;
31
32
  readonly allow?: () => Promise<boolean>;
32
33
  readonly bindingId: string;
@@ -48,6 +49,7 @@ export interface IntegrationReconcileContext {
48
49
  readonly config: Readonly<Record<string, JsonValue>>;
49
50
  readonly connector: ConnectorProxy;
50
51
  readonly endpointUrl: string;
52
+ readonly idempotencyKey: string;
51
53
  readonly now: Date;
52
54
  readonly signal?: AbortSignal;
53
55
  readonly state?: IntegrationStateContext;
@@ -3923,7 +3923,10 @@ var ci = 300, H = "/v1/webhook_endpoints", li = { "Content-Type": "application/x
3923
3923
  let t = await U(e, "endpoint create", {
3924
3924
  body: fi(e.endpointUrl, n),
3925
3925
  endpoint: H,
3926
- headers: li,
3926
+ headers: {
3927
+ ...li,
3928
+ "Idempotency-Key": e.idempotencyKey
3929
+ },
3927
3930
  method: "POST"
3928
3931
  });
3929
3932
  W(t, "endpoint create");
@@ -1,9 +1,9 @@
1
1
  export type ProjectedRunEvent = {
2
- readonly kind: 'node.output';
2
+ readonly kind: 'node.completed';
3
3
  readonly payload: Readonly<Record<string, unknown>>;
4
4
  readonly value: unknown;
5
5
  } | {
6
- readonly kind: 'node.artifact' | 'node.completed' | 'node.failed' | 'node.log' | 'node.progress' | 'node.started' | 'run.progress' | 'run.started';
6
+ readonly kind: 'node.artifact' | 'node.failed' | 'node.log' | 'node.progress' | 'node.started' | 'run.progress' | 'run.started';
7
7
  readonly payload: Readonly<Record<string, unknown>>;
8
8
  };
9
9
  export declare function createEventProjector(platformRunId: string, nodeFailureCodes: ReadonlySet<string>): (event: unknown) => Promise<ProjectedRunEvent | undefined>;
@@ -5,7 +5,8 @@ var e = new TextEncoder(), t = /* @__PURE__ */ new Set([
5
5
  "javascript",
6
6
  "llm",
7
7
  "subflow",
8
- "value"
8
+ "value",
9
+ "wait"
9
10
  ]);
10
11
  function n(e, t) {
11
12
  if (typeof e != "object" || !e || Array.isArray(e)) throw TypeError(`${t} must be an object.`);
@@ -109,21 +110,18 @@ function f(e, t) {
109
110
  o(g);
110
111
  return;
111
112
  }
112
- if (_ == "node.started" || _ == "node.output" || _ == "node.progress" || _ == "node.artifact" || _ == "node.log" || _ == "node.completed" || _ == "node.failed") {
113
- let n = s(g, f, e), o = await n.executionId, m = {
113
+ if (_ == "node.started" || _ == "node.progress" || _ == "node.artifact" || _ == "node.log" || _ == "node.completed" || _ == "node.failed") {
114
+ let r = s(g, f, e), o = await r.executionId, m = {
114
115
  executionId: o,
115
- flowId: n.flowId,
116
- nodeId: n.nodeId,
117
- scopeId: await c("scope", e, n.rawRunId)
116
+ flowId: r.flowId,
117
+ nodeId: r.nodeId,
118
+ scopeId: await c("scope", e, r.rawRunId)
118
119
  };
119
120
  switch (_) {
120
- case "node.output": return {
121
+ case "node.completed": return {
121
122
  kind: _,
122
- payload: {
123
- ...m,
124
- handle: r(g.handle, "Runtime node.output handle")
125
- },
126
- value: g.value
123
+ payload: m,
124
+ value: n(g.outputs, "Runtime node.completed outputs")
127
125
  };
128
126
  case "node.started": {
129
127
  let e = a(g.nodeKind), t = i(g.nodeTitle, "Runtime node.started nodeTitle"), n = i(g.operation, "Runtime node.started operation");
@@ -169,10 +167,6 @@ function f(e, t) {
169
167
  message: l(g.message)
170
168
  }
171
169
  };
172
- case "node.completed": return {
173
- kind: _,
174
- payload: m
175
- };
176
170
  case "node.failed": return {
177
171
  kind: _,
178
172
  payload: {
@@ -1,11 +1,15 @@
1
1
  export declare const runTerminalStatuses: readonly ['canceled', 'completed', 'failed', 'indeterminate'];
2
- export declare const runStatuses: readonly ["canceled", "completed", "failed", "indeterminate", "queued", "running", "starting"];
2
+ export declare const runStatuses: readonly ["canceled", "completed", "failed", "indeterminate", "queued", "running", "starting", "waiting"];
3
3
  export type RunStatus = (typeof runStatuses)[number];
4
4
  export type RunTerminalStatus = (typeof runTerminalStatuses)[number];
5
5
  export type RunOperation = {
6
6
  readonly kind: 'claim';
7
7
  } | {
8
8
  readonly kind: 'start';
9
+ } | {
10
+ readonly kind: 'wait';
11
+ } | {
12
+ readonly kind: 'resolve';
9
13
  } | {
10
14
  readonly kind: 'commit';
11
15
  readonly status: RunTerminalStatus;
@@ -16,6 +20,9 @@ export type RunTransition = {
16
20
  } | {
17
21
  readonly kind: 'running';
18
22
  readonly status: 'running';
23
+ } | {
24
+ readonly kind: 'waiting';
25
+ readonly status: 'waiting';
19
26
  } | {
20
27
  readonly kind: 'terminal';
21
28
  readonly status: RunTerminalStatus;
@@ -28,12 +35,18 @@ export type RunTransition = {
28
35
  } | {
29
36
  readonly kind: 'committed';
30
37
  readonly status: RunTerminalStatus;
38
+ } | {
39
+ readonly kind: 'waited';
40
+ readonly status: 'waiting';
41
+ } | {
42
+ readonly kind: 'resolved';
43
+ readonly status: 'queued';
31
44
  } | {
32
45
  readonly kind: 'stale';
33
46
  readonly status: RunStatus;
34
47
  };
35
48
  export type RunClaim = Extract<RunTransition, {
36
- readonly kind: 'ready' | 'running' | 'terminal';
49
+ readonly kind: 'ready' | 'running' | 'terminal' | 'waiting';
37
50
  }>;
38
51
  export type RunStart = Extract<RunTransition, {
39
52
  readonly kind: 'already-started' | 'started' | 'stale';
@@ -60,7 +73,9 @@ export interface RunLifecycleHarness {
60
73
  claim(runId: string): Promise<RunClaim>;
61
74
  commit(runId: string, status: RunTerminalStatus): Promise<boolean>;
62
75
  observe(runId: string): Promise<RunObservation>;
76
+ resolve(runId: string): Promise<boolean>;
63
77
  start(runId: string): Promise<RunStart>;
78
+ wait(runId: string): Promise<boolean>;
64
79
  }
65
80
  export interface RunLifecycleConformanceCase {
66
81
  readonly name: string;
@@ -28,7 +28,8 @@ var n = [
28
28
  ...n,
29
29
  "queued",
30
30
  "running",
31
- "starting"
31
+ "starting",
32
+ "waiting"
32
33
  ];
33
34
  function i(e) {
34
35
  return e == "canceled" || e == "completed" || e == "failed" || e == "indeterminate";
@@ -45,6 +46,10 @@ function a(e, t) {
45
46
  kind: "running",
46
47
  status: e
47
48
  };
49
+ case "waiting": return {
50
+ kind: "waiting",
51
+ status: e
52
+ };
48
53
  case "canceled":
49
54
  case "completed":
50
55
  case "failed":
@@ -63,6 +68,7 @@ function a(e, t) {
63
68
  status: e
64
69
  };
65
70
  case "queued":
71
+ case "waiting":
66
72
  case "canceled":
67
73
  case "completed":
68
74
  case "failed":
@@ -71,10 +77,24 @@ function a(e, t) {
71
77
  status: e
72
78
  };
73
79
  }
80
+ case "wait": return e == "running" ? {
81
+ kind: "waited",
82
+ status: "waiting"
83
+ } : {
84
+ kind: "stale",
85
+ status: e
86
+ };
87
+ case "resolve": return e == "waiting" ? {
88
+ kind: "resolved",
89
+ status: "queued"
90
+ } : {
91
+ kind: "stale",
92
+ status: e
93
+ };
74
94
  case "commit": return i(e) ? {
75
95
  kind: "stale",
76
96
  status: e
77
- } : t.status == "canceled" || e == "running" ? {
97
+ } : t.status == "canceled" || e == "running" || t.status == "failed" && e == "waiting" ? {
78
98
  kind: "committed",
79
99
  status: t.status
80
100
  } : {
@@ -95,6 +115,37 @@ async function s(e, t = "request", n = "request-a") {
95
115
  return r.runId;
96
116
  }
97
117
  var c = [
118
+ {
119
+ name: "pauses and resumes the same Run through the ordinary start barrier",
120
+ async verify(e) {
121
+ let t = await s(e), n = await e.claim(t);
122
+ if (n.kind != "ready") throw Error("Initial Run claim was not ready.");
123
+ o(await e.start(t), a(n.status, { kind: "start" }), "Initial start"), o(await e.wait(t), !0, "Wait commit"), o(await e.observe(t), {
124
+ status: "waiting",
125
+ terminalEvents: []
126
+ }, "Waiting Run observation"), o(await e.claim(t), a("waiting", { kind: "claim" }), "Claim while waiting"), o(await e.resolve(t), !0, "Wait resolution"), o(await e.resolve(t), !1, "Repeated Wait resolution");
127
+ let r = await e.claim(t);
128
+ if (r.kind != "ready") throw Error("Resolved Run claim was not ready.");
129
+ o(await e.start(t), a(r.status, { kind: "start" }), "Resume start"), o(await e.commit(t, "completed"), !0, "Completion after resume"), o(await e.observe(t), {
130
+ status: "completed",
131
+ terminalEvents: ["completed"]
132
+ }, "Resumed Run observation");
133
+ }
134
+ },
135
+ {
136
+ name: "allows cancellation and expiry failure while waiting",
137
+ async verify(e) {
138
+ let t = await s(e, "cancel-wait");
139
+ if ((await e.claim(t)).kind != "ready") throw Error("Canceled Run claim was not ready.");
140
+ await e.start(t), o(await e.wait(t), !0, "Canceled Run Wait commit"), o(await e.commit(t, "canceled"), !0, "Waiting cancellation"), o(await e.resolve(t), !1, "Resolution after cancellation");
141
+ let n = await s(e, "expire-wait");
142
+ if ((await e.claim(n)).kind != "ready") throw Error("Expired Run claim was not ready.");
143
+ await e.start(n), o(await e.wait(n), !0, "Expired Run Wait commit"), o(await e.commit(n, "failed"), !0, "Waiting expiry failure"), o(await e.observe(n), {
144
+ status: "failed",
145
+ terminalEvents: ["failed"]
146
+ }, "Expired Run observation");
147
+ }
148
+ },
98
149
  {
99
150
  name: "replays idempotent acceptance and rejects a conflicting request",
100
151
  async verify(e) {
@@ -1,4 +1,4 @@
1
- import type { CodeModule, JsonValue } from '../browser/flow-change.js';
1
+ import type { CodeModule, ConnectorCapability, JsonValue } from '../browser/flow-change.js';
2
2
  export { currentEngineContract, findEngineContract, type EngineContract } from './engine-contract.js';
3
3
  export type RuntimeModule = Pick<CodeModule, 'imports' | 'source'>;
4
4
  export interface RuntimeProgram {
@@ -8,6 +8,7 @@ export interface RuntimeProgram {
8
8
  readonly modules: Readonly<Record<string, RuntimeModule>>;
9
9
  }
10
10
  export interface RuntimeCapabilityCall {
11
+ readonly callId: string;
11
12
  readonly invocationId: string;
12
13
  readonly kind: string;
13
14
  readonly payload: JsonValue;
@@ -36,6 +37,7 @@ export type LlmTaskResult = {
36
37
  };
37
38
  export type InvokeLlmTask = (invocation: LlmTaskInvocation) => Promise<LlmTaskResult>;
38
39
  export interface RuntimeInvocation {
40
+ readonly capabilities?: readonly ConnectorCapability[];
39
41
  readonly capability: (call: RuntimeCapabilityCall) => Promise<RuntimeCapabilityResponse>;
40
42
  readonly input: JsonValue;
41
43
  readonly invocationId: string;
@@ -44,10 +46,16 @@ export interface RuntimeInvocation {
44
46
  }
45
47
  export interface RuntimeHarness {
46
48
  readonly engineDigest: string;
47
- invoke(invocation: RuntimeInvocation): Promise<JsonValue>;
49
+ invoke(invocation: RuntimeInvocation): Promise<JsonValue | undefined>;
48
50
  }
49
51
  export interface RuntimeConformanceCase {
50
52
  readonly name: string;
51
53
  verify(harness: RuntimeHarness): Promise<void>;
52
54
  }
53
55
  export declare const runtimeConformanceCases: readonly RuntimeConformanceCase[];
56
+ export declare function createActions(declarations: readonly ConnectorCapability[], invoke: (payload: JsonValue) => Promise<RuntimeCapabilityResponse>): Readonly<Record<string, unknown>>;
57
+ export declare function resolveAction(declarations: readonly ConnectorCapability[], payload: unknown): {
58
+ readonly action: string;
59
+ readonly connectionId?: string;
60
+ readonly input: Readonly<Record<string, JsonValue>>;
61
+ };
@@ -19,7 +19,7 @@ function t(n, r) {
19
19
  }
20
20
  //#endregion
21
21
  //#region src/execution/common/engineContract.ts
22
- var n = "open-flow-engine/v1", r = {
22
+ var n = "open-flow-engine/v2", r = {
23
23
  platformExports: /* @__PURE__ */ new Set(["engineContract", "identity"]),
24
24
  platformModule: "open-flow:platform",
25
25
  platformSource: `export const engineContract = ${JSON.stringify(n)}
@@ -27,7 +27,7 @@ export function identity(value) { return value }
27
27
  `
28
28
  };
29
29
  function i(e) {
30
- return e == "open-flow-engine/v1" ? r : void 0;
30
+ return e == "open-flow-engine/v2" ? r : void 0;
31
31
  }
32
32
  //#endregion
33
33
  //#region src/execution/common/runtime.ts
@@ -58,6 +58,71 @@ async function s(e, t, n) {
58
58
  throw Error(`${n}: operation unexpectedly succeeded.`);
59
59
  }
60
60
  var c = [
61
+ {
62
+ name: "preserves Action error codes and fixed per-call Connection selection",
63
+ async verify(e) {
64
+ let t = [{
65
+ kind: "connector",
66
+ action: "example.echo",
67
+ connections: [{
68
+ connectionId: "work",
69
+ alias: "office"
70
+ }, { connectionId: "home" }]
71
+ }];
72
+ o(await e.invoke({
73
+ capabilities: t,
74
+ capability: async ({ payload: e }) => {
75
+ let n = u(t, e);
76
+ if (n.input.fail) throw Object.assign(/* @__PURE__ */ Error("Provider unavailable."), { code: "connector.unavailable" });
77
+ return {
78
+ body: n.connectionId ?? null,
79
+ status: 200
80
+ };
81
+ },
82
+ input: null,
83
+ invocationId: "action-accounts",
84
+ program: a(e, "export default async (_, context) => {\n const values = await Promise.all([\n context.actions.example.echo({}, { connectionAlias: 'office' }),\n context.actions['example.echo']({}, { connectionId: 'home' }),\n ])\n try { await context.actions.example.echo({ fail: true }, { connectionId: 'work' }) }\n catch (error) { values.push(error.code) }\n return values\n }")
85
+ }), [
86
+ "work",
87
+ "home",
88
+ "connector.unavailable"
89
+ ], "Action selection and recovery");
90
+ }
91
+ },
92
+ {
93
+ name: "shares Action entries and assigns independent concurrent call identities",
94
+ async verify(e) {
95
+ let t = [];
96
+ o(await e.invoke({
97
+ capabilities: [{
98
+ kind: "connector",
99
+ action: "example.echo",
100
+ connections: []
101
+ }],
102
+ capability: async (e) => (t.push(e), {
103
+ body: e.payload,
104
+ status: 200
105
+ }),
106
+ input: null,
107
+ invocationId: "action-calls",
108
+ program: a(e, "export default async (_input, context) => {\n const call = context.actions.example.echo\n return { same: call === context.actions['example.echo'], values: await Promise.all([call({ value: 1 }), call({ value: 2 }), call({ value: 3 })]) }\n }")
109
+ }), {
110
+ same: !0,
111
+ values: [
112
+ 1,
113
+ 2,
114
+ 3
115
+ ].map((e) => ({
116
+ action: "example.echo",
117
+ input: { value: e }
118
+ }))
119
+ }, "Action results"), o(new Set(t.map((e) => e.callId)).size, 3, "Independent Action identities"), o(t.map((e) => e.invocationId), [
120
+ "action-calls",
121
+ "action-calls",
122
+ "action-calls"
123
+ ], "Task identity");
124
+ }
125
+ },
61
126
  {
62
127
  name: "loads the fixed ESM closure and platform module",
63
128
  async verify(e) {
@@ -105,7 +170,7 @@ var c = [
105
170
  }),
106
171
  input: { issue: 42 },
107
172
  invocationId: "async-capability",
108
- program: a(e, "export default async (input, capability) => capability.connector({ action: 'read', input })")
173
+ program: a(e, "export default async (input, capability) => capability.artifact.put({ action: 'read', input })")
109
174
  }), {
110
175
  body: {
111
176
  accepted: !0,
@@ -121,7 +186,7 @@ var c = [
121
186
  payload: n
122
187
  })), [{
123
188
  invocationId: "async-capability",
124
- kind: "connector",
189
+ kind: "artifact.put",
125
190
  payload: {
126
191
  action: "read",
127
192
  input: { issue: 42 }
@@ -129,23 +194,95 @@ var c = [
129
194
  }], "Capability request");
130
195
  }
131
196
  },
197
+ {
198
+ name: "returns final outputs without exposing intermediate output capability",
199
+ async verify(e) {
200
+ o(await e.invoke({
201
+ capability: async () => {
202
+ throw Error("Capability must not be called.");
203
+ },
204
+ input: null,
205
+ invocationId: "final-outputs",
206
+ program: a(e, "export default (_input, context) => ({ available: typeof context.outputs, value: 1 })")
207
+ }), {
208
+ available: "undefined",
209
+ value: 1
210
+ }, "Final Task outputs");
211
+ }
212
+ },
132
213
  {
133
214
  name: "cancels a pending Capability and the user invocation",
134
215
  async verify(e) {
135
216
  let t = new AbortController(), n = !1, r, i = new Promise((e) => {
136
217
  r = e;
137
218
  }), c = e.invoke({
219
+ capabilities: [{
220
+ kind: "connector",
221
+ action: "example.wait",
222
+ connections: []
223
+ }],
138
224
  capability: async ({ signal: e }) => (r(), await new Promise((t, r) => e.addEventListener("abort", () => {
139
225
  n = !0, r(e.reason);
140
226
  }, { once: !0 }))),
141
227
  input: null,
142
228
  invocationId: "canceled-capability",
143
- program: a(e, "export default async (_input, capability) => capability.connector({ action: 'wait' })"),
229
+ program: a(e, "export default async (_input, context) => context.actions.example.wait({})"),
144
230
  signal: t.signal
145
231
  });
146
232
  await i, t.abort(/* @__PURE__ */ Error("Invocation canceled.")), await s(c, /cancel|abort|disposed/i, "Canceled invocation"), o(n, !0, "Capability cancellation");
147
233
  }
148
234
  }
149
235
  ];
236
+ function l(e, t) {
237
+ let n = (e, t) => {
238
+ if (!(e === null || typeof e == "string" || typeof e == "boolean" || typeof e == "number" && Number.isFinite(e))) {
239
+ if (typeof e != "object" || t.has(e) || !Array.isArray(e) && Object.getPrototypeOf(e) !== Object.prototype && Object.getPrototypeOf(e) !== null || Object.getOwnPropertySymbols(e).length > 0) throw Object.assign(/* @__PURE__ */ Error("Action parameters must contain only JSON values."), { code: "capability.invalid" });
240
+ t.add(e);
241
+ for (let r of Array.isArray(e) ? e : Object.values(e)) n(r, t);
242
+ t.delete(e);
243
+ }
244
+ }, r = Object.create(null), i = /* @__PURE__ */ new Map();
245
+ for (let a of e) {
246
+ let e = a.action.indexOf("."), o = a.action.slice(0, e), s = a.action.slice(e + 1), c = i.get(o);
247
+ c ?? (c = Object.create(null), i.set(o, c), r[o] = c);
248
+ let l = async (e = {}, r) => (n(e, /* @__PURE__ */ new Set()), r !== void 0 && n(r, /* @__PURE__ */ new Set()), (await t({
249
+ action: a.action,
250
+ input: e,
251
+ ...r === void 0 ? {} : { options: r }
252
+ })).body);
253
+ r[a.action] = l, c[s] = l;
254
+ }
255
+ for (let e of i.values()) Object.freeze(e);
256
+ return Object.freeze(r);
257
+ }
258
+ function u(e, t) {
259
+ let n = Object.assign(/* @__PURE__ */ Error("The Action request is invalid."), { code: "capability.invalid" }), r = Object.assign(/* @__PURE__ */ Error("The Action or Connection is not declared for this Task."), { code: "capability.denied" });
260
+ if (typeof t != "object" || !t || Array.isArray(t)) throw n;
261
+ let i = t;
262
+ if (Object.keys(i).some((e) => ![
263
+ "action",
264
+ "input",
265
+ "options"
266
+ ].includes(e)) || typeof i.action != "string" || i.input == null || typeof i.input != "object" || Array.isArray(i.input)) throw n;
267
+ let a = e.find((e) => e.action == i.action);
268
+ if (a == null) throw r;
269
+ let o = a.connectionId;
270
+ if (Object.hasOwn(i, "options")) {
271
+ if (i.options == null || typeof i.options != "object" || Array.isArray(i.options)) throw n;
272
+ let e = i.options, t = Object.keys(e);
273
+ if (t.length != 1) throw n;
274
+ if (typeof e.connectionId == "string" && e.connectionId.length > 0 && t[0] == "connectionId") o = e.connectionId;
275
+ else if (typeof e.connectionAlias == "string" && e.connectionAlias.length > 0 && t[0] == "connectionAlias") {
276
+ if (o = a.connections.find((t) => t.alias == e.connectionAlias)?.connectionId, o == null) throw r;
277
+ } else throw n;
278
+ }
279
+ if (o != null && !a.connections.some((e) => e.connectionId == o)) throw r;
280
+ if (o == null && a.connections.length > 0) throw Object.assign(/* @__PURE__ */ Error("Choose a Connector Connection for this Action."), { code: "connector.connection-required" });
281
+ return {
282
+ action: i.action,
283
+ input: i.input,
284
+ ...o == null ? {} : { connectionId: o }
285
+ };
286
+ }
150
287
  //#endregion
151
- export { n as currentEngineContract, i as findEngineContract, c as runtimeConformanceCases };
288
+ export { l as createActions, n as currentEngineContract, i as findEngineContract, u as resolveAction, c as runtimeConformanceCases };
@@ -1,4 +1,4 @@
1
- import type { ConnectorCapability, JsonValue } from '../browser/flow-change.js';
1
+ import type { ConnectorCapability, JsonValue, WaitAction } from '../browser/flow-change.js';
2
2
  import type { PreparedFlow } from './flow-semantics.js';
3
3
  import * as Effect from 'effect/Effect';
4
4
  export type SchedulerEvent = {
@@ -17,29 +17,30 @@ export type SchedulerEvent = {
17
17
  readonly inputs: Readonly<Record<string, JsonValue>>;
18
18
  readonly jobId: string;
19
19
  readonly nodeId: string;
20
- readonly nodeKind: 'condition' | 'connector' | 'javascript' | 'llm' | 'subflow' | 'value';
20
+ readonly nodeKind: 'condition' | 'connector' | 'javascript' | 'llm' | 'subflow' | 'value' | 'wait';
21
21
  readonly nodeTitle?: string;
22
22
  readonly runId: string;
23
23
  readonly type: 'node.started';
24
24
  } | {
25
- readonly handle: string;
26
25
  readonly jobId: string;
27
26
  readonly nodeId: string;
27
+ readonly outputs: Readonly<Record<string, JsonValue>>;
28
28
  readonly runId: string;
29
- readonly type: 'node.output';
30
- readonly value: JsonValue;
29
+ readonly type: 'node.completed';
31
30
  } | {
31
+ readonly code: string;
32
32
  readonly jobId: string;
33
+ readonly message: string;
33
34
  readonly nodeId: string;
34
35
  readonly runId: string;
35
- readonly type: 'node.completed';
36
+ readonly type: 'node.failed';
36
37
  } | {
37
- readonly code: string;
38
38
  readonly jobId: string;
39
+ readonly level: 'debug' | 'error' | 'info' | 'warn';
39
40
  readonly message: string;
40
41
  readonly nodeId: string;
41
42
  readonly runId: string;
42
- readonly type: 'node.failed';
43
+ readonly type: 'node.log';
43
44
  } | {
44
45
  readonly result: FlowRunResult | SubflowRunResult;
45
46
  readonly runId: string;
@@ -52,19 +53,52 @@ export type SchedulerEvent = {
52
53
  export interface FlowRunResult {
53
54
  readonly kind: 'node-results';
54
55
  readonly nodes: readonly {
55
- readonly jobs: readonly {
56
- readonly jobId: string;
57
- readonly outputs: Readonly<Record<string, JsonValue>>;
58
- }[];
59
56
  readonly nodeId: string;
57
+ readonly status: 'completed';
58
+ readonly jobId: string;
59
+ readonly outputs: Readonly<Record<string, JsonValue>>;
60
60
  }[];
61
61
  }
62
+ export interface FlowRunCheckpoint {
63
+ readonly bindingValues: Readonly<Record<string, string>>;
64
+ readonly inputs: Readonly<Record<string, Readonly<Record<string, JsonValue>>>>;
65
+ readonly results: Readonly<Record<string, {
66
+ readonly jobId: string;
67
+ readonly outputs: Readonly<Record<string, JsonValue>>;
68
+ }>>;
69
+ readonly skipped: readonly string[];
70
+ readonly version: 1;
71
+ readonly wait: {
72
+ readonly jobId: string;
73
+ readonly nodeId: string;
74
+ readonly value: JsonValue;
75
+ readonly waitId: string;
76
+ };
77
+ }
78
+ export type FlowRunOutcome = FlowRunResult | {
79
+ readonly checkpoint: FlowRunCheckpoint;
80
+ readonly kind: 'waiting';
81
+ readonly notification?: {
82
+ readonly input: Readonly<Record<string, JsonValue>>;
83
+ readonly messageHandle: string;
84
+ readonly taskId: string;
85
+ };
86
+ readonly wait: {
87
+ readonly actions: readonly ['continue'] | readonly ['approve', 'reject'];
88
+ readonly jobId: string;
89
+ readonly nodeId: string;
90
+ readonly waitId: string;
91
+ };
92
+ };
62
93
  export interface SubflowRunResult {
63
94
  readonly kind: 'function-outputs';
64
95
  readonly outputs: Readonly<Record<string, JsonValue>>;
65
96
  readonly target: 'subflow';
66
97
  }
67
98
  interface TaskInvocationBase {
99
+ readonly additionalInputs: Readonly<Record<string, JsonValue>>;
100
+ readonly blockId: string;
101
+ readonly flowId: string;
68
102
  readonly input: Readonly<Record<string, JsonValue>>;
69
103
  readonly invocationId: string;
70
104
  readonly jobId: string;
@@ -93,8 +127,13 @@ export interface FlowRunOptions {
93
127
  readonly inputs?: Readonly<Record<string, Readonly<Record<string, JsonValue>>>>;
94
128
  readonly invokeTask: (invocation: TaskInvocation) => Effect.Effect<unknown, Error>;
95
129
  readonly projectFailure?: (error: unknown) => SchedulerFailure;
130
+ readonly resume?: {
131
+ readonly action: WaitAction;
132
+ readonly checkpoint: unknown;
133
+ };
96
134
  readonly runId: string;
97
135
  readonly trigger?: TriggerSeed;
98
136
  }
99
- export declare function runFlow(prepared: PreparedFlow, options: FlowRunOptions): Effect.Effect<FlowRunResult, Error>;
137
+ export declare function decodeFlowRunCheckpoint(input: unknown): FlowRunCheckpoint;
138
+ export declare function runFlow(prepared: PreparedFlow, options: FlowRunOptions): Effect.Effect<FlowRunOutcome, Error>;
100
139
  export {};