@oomol-lab/open-flow 0.1.0-beta.5 → 0.1.0-beta.7

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.
@@ -1,5 +1,5 @@
1
1
  import { $ as e, A as t, At as n, Bn as r, Dt as i, Et as a, Fn as o, G as s, I as c, Jn as l, Jt as u, K as d, Kn as f, Mn as p, Mt as m, N as h, Nn as ee, Nt as g, On as _, P as v, Pn as y, Qn as b, Rn as x, Sn as S, St as C, Tt as w, Un as T, Vt as E, Xt as D, Yt as te, Z as O, Zn as k, Zt as A, _t as j, a as M, bt as N, c as P, en as F, et as I, f as L, ft as R, gt as z, i as ne, j as re, kt as ie, l as ae, lr as oe, lt as B, m as se, n as V, nr as H, nt as U, or as ce, p as le, qn as ue, qt as de, r as fe, rn as pe, rr as W, s as me, sr as he, t as G, tn as ge, tr as K, tt as _e, u as ve, vn as ye, vt as be, x as q, xt as xe, zn as Se, zt as J } from "./getPseudoElementBounds-5LArT6Xc.js";
2
- import { s as Ce } from "./icons-CRxvozBE.js";
2
+ import { s as Ce } from "./icons-KIOgjHpD.js";
3
3
  import * as Y from "react";
4
4
  import { jsx as X, jsxs as we } from "react/jsx-runtime";
5
5
  //#region ../../node_modules/.bun/lucide-react@0.468.0+f4eacebf2041cd4f/node_modules/lucide-react/dist/esm/icons/chevron-up.js
@@ -38,9 +38,11 @@ function s(e, t) {
38
38
  async function c(e, t, n) {
39
39
  return i(e.status, t, `${n} status`), a(await e.json().catch(() => r(`${n} body: expected JSON.`)), `${n} body`);
40
40
  }
41
- async function l(e, t, n, r) {
42
- let o = await c(e, t, r);
43
- i(a(o.error, `${r} error`).code, n, `${r} error code`), i(o.version, 1, `${r} version`);
41
+ async function l(e, t, n, o, l) {
42
+ let u = await c(e, t, o), d = a(u.error, `${o} error`);
43
+ i(d.code, n, `${o} error code`);
44
+ let f = s(d.message, `${o} error message`);
45
+ l != null && !f.includes(l) && r(`${o} error message: expected ${JSON.stringify(l)} in ${JSON.stringify(f)}.`), i(u.version, 1, `${o} version`);
44
46
  }
45
47
  function u(e, t, n = {}) {
46
48
  let r = new Headers(n.headers);
@@ -199,7 +201,7 @@ var b = [
199
201
  name: "commits immutable Draft Revisions for one Flow",
200
202
  async verify(e) {
201
203
  let t = await f(e, "Draft flow", "draft-flow"), n = s(t.flowId, "Draft Flow flowId"), r = s(t.draftRevisionId, "Draft Flow revisionId"), o = await c(await m(e, n, r, "marker", "draft-change"), 200, "Change Draft"), d = h(o, "Changed Draft");
202
- i(a(o.revision, "Changed Draft revision").parentRevisionId, r, "Changed Draft parent"), i(await c(await m(e, n, r, "marker", "draft-change"), 200, "Replay Draft change"), o, "Replayed Draft change"), await l(await m(e, n, r, "another-marker", "draft-change"), 409, "flow.conflict", "Conflicting Draft change replay"), await l(await p(e, n, d, [{
204
+ i(a(o.revision, "Changed Draft revision").parentRevisionId, r, "Changed Draft parent"), i(await c(await m(e, n, r, "marker", "draft-change"), 200, "Replay Draft change"), o, "Replayed Draft change"), await l(await m(e, n, r, "another-marker", "draft-change"), 409, "flow.conflict", "Conflicting Draft change replay"), await l(await m(e, n, d, "marker"), 400, "flow.invalid", "Duplicate Draft Node", "A Node with this ID already exists"), await l(await p(e, n, d, [{
203
205
  before: [{
204
206
  handle: "ready",
205
207
  jsonSchema: { type: "boolean" },
@@ -301,6 +303,12 @@ var b = [
301
303
  node: {
302
304
  actions: ["approve", "reject"],
303
305
  concurrency: 1,
306
+ input: {
307
+ handle: "value",
308
+ jsonSchema: {},
309
+ nullable: !0,
310
+ value: null
311
+ },
304
312
  inputs: { value: {
305
313
  kind: "value",
306
314
  value: { request: 1 }
@@ -107,6 +107,10 @@ function d(e) {
107
107
  case "wait": return {
108
108
  ...t,
109
109
  actions: e.actions,
110
+ input: {
111
+ handle: e.input.handle,
112
+ ...o(e.input)
113
+ },
110
114
  kind: e.kind,
111
115
  ...e.notification == null ? {} : { notification: {
112
116
  inputs: l(e.notification.inputs),
@@ -10249,6 +10249,10 @@ function vo(e) {
10249
10249
  case "wait": return {
10250
10250
  ...t,
10251
10251
  actions: e.actions,
10252
+ input: {
10253
+ handle: e.input.handle,
10254
+ ...po(e.input)
10255
+ },
10252
10256
  kind: e.kind,
10253
10257
  ...e.notification == null ? {} : { notification: {
10254
10258
  inputs: go(e.notification.inputs),
@@ -10713,11 +10717,7 @@ function Jo(e, t) {
10713
10717
  case "value": return {};
10714
10718
  case "subflow": return oo(e.subflows[t.subflowId]?.inputs ?? []);
10715
10719
  case "task": return oo([...t.task == null ? e.tasks[t.taskId]?.inputs ?? [] : t.task.inputs, ...t.additionalInputs ?? []]);
10716
- case "wait": return { value: {
10717
- jsonSchema: {},
10718
- nullable: !0,
10719
- value: null
10720
- } };
10720
+ case "wait": return { [t.input.handle]: t.input };
10721
10721
  case "cron":
10722
10722
  case "integration":
10723
10723
  case "poll":
@@ -10733,10 +10733,7 @@ function Yo(e, t) {
10733
10733
  case "value": return oo(t.values);
10734
10734
  case "subflow": return oo(e.subflows[t.subflowId]?.outputs ?? []);
10735
10735
  case "task": return oo(t.task == null ? e.tasks[t.taskId]?.outputs ?? [] : t.task.outputs);
10736
- case "wait": return Object.fromEntries(t.actions.map((e) => [e, {
10737
- jsonSchema: {},
10738
- nullable: !0
10739
- }]));
10736
+ case "wait": return Object.fromEntries(t.actions.map((e) => [e, t.input]));
10740
10737
  case "cron":
10741
10738
  case "integration":
10742
10739
  case "poll":
@@ -10792,6 +10789,7 @@ function Qo(e, t, n, r, i, a, o, s) {
10792
10789
  "concurrency",
10793
10790
  "description",
10794
10791
  "icon",
10792
+ "input",
10795
10793
  "inputs",
10796
10794
  "kind",
10797
10795
  "name",
@@ -10801,7 +10799,7 @@ function Qo(e, t, n, r, i, a, o, s) {
10801
10799
  if (l.length > 0 && s.push(Q("wait.field-unsupported", `Wait node "${e}" contains unsupported fields: ${l.join(", ")}.`, o, {
10802
10800
  fields: l.join(", "),
10803
10801
  nodeId: e
10804
- })), a || s.push(Q("wait.not-allowed", "Wait nodes are only allowed in Flows.", o)), t.concurrency != 1 && s.push(Q("wait.concurrency-invalid", "Wait concurrency must be 1.", `${o}/concurrency`)), (typeof t.prompt != "string" || t.prompt.trim().length == 0 || [...t.prompt].length > 1e3) && s.push(Q("wait.prompt-invalid", "Wait prompt must contain between 1 and 1,000 Unicode code points.", `${o}/prompt`)), (!Array.isArray(t.actions) || !(t.actions.length == 1 && t.actions[0] == "continue" || t.actions.length == 2 && t.actions[0] == "approve" && t.actions[1] == "reject")) && s.push(Q("wait.actions-invalid", "Wait actions must be [\"continue\"] or [\"approve\", \"reject\"].", `${o}/actions`)), t.notification == null) return;
10802
+ })), a || s.push(Q("wait.not-allowed", "Wait nodes are only allowed in Flows.", o)), t.concurrency != 1 && s.push(Q("wait.concurrency-invalid", "Wait concurrency must be 1.", `${o}/concurrency`)), t.input.handle != "value" && s.push(Q("wait.input-invalid", "Wait input handle must be \"value\".", `${o}/input/handle`)), (typeof t.prompt != "string" || t.prompt.trim().length == 0 || [...t.prompt].length > 1e3) && s.push(Q("wait.prompt-invalid", "Wait prompt must contain between 1 and 1,000 Unicode code points.", `${o}/prompt`)), (!Array.isArray(t.actions) || !(t.actions.length == 1 && t.actions[0] == "continue" || t.actions.length == 2 && t.actions[0] == "approve" && t.actions[1] == "reject")) && s.push(Q("wait.actions-invalid", "Wait actions must be [\"continue\"] or [\"approve\", \"reject\"].", `${o}/actions`)), t.notification == null) return;
10805
10803
  let u = t.notification;
10806
10804
  if (typeof u != "object" || Array.isArray(u)) {
10807
10805
  s.push(Q("wait.notification-invalid", "Wait notification must be an object.", `${o}/notification`));
@@ -44,7 +44,7 @@ export interface RuntimeInvocation {
44
44
  }
45
45
  export interface RuntimeHarness {
46
46
  readonly engineDigest: string;
47
- invoke(invocation: RuntimeInvocation): Promise<JsonValue>;
47
+ invoke(invocation: RuntimeInvocation): Promise<JsonValue | undefined>;
48
48
  }
49
49
  export interface RuntimeConformanceCase {
50
50
  readonly name: string;
@@ -129,6 +129,33 @@ var c = [
129
129
  }], "Capability request");
130
130
  }
131
131
  },
132
+ {
133
+ name: "submits Task outputs and accepts a void result",
134
+ async verify(e) {
135
+ let t = [];
136
+ o(await e.invoke({
137
+ capability: async (e) => (t.push(e), {
138
+ body: null,
139
+ status: 200
140
+ }),
141
+ input: null,
142
+ invocationId: "task-outputs",
143
+ program: a(e, "export default async (_input, context) => {\n await context.outputs({ first: 1 })\n await context.outputs({ second: 2 })\n}")
144
+ }), void 0, "Void Task result"), o(t.map(({ invocationId: e, kind: t, payload: n }) => ({
145
+ invocationId: e,
146
+ kind: t,
147
+ payload: n
148
+ })), [{
149
+ invocationId: "task-outputs",
150
+ kind: "outputs",
151
+ payload: { first: 1 }
152
+ }, {
153
+ invocationId: "task-outputs",
154
+ kind: "outputs",
155
+ payload: { second: 2 }
156
+ }], "Task outputs request");
157
+ }
158
+ },
132
159
  {
133
160
  name: "cancels a pending Capability and the user invocation",
134
161
  async verify(e) {
@@ -147,7 +147,7 @@ export interface FlowRunOptions {
147
147
  readonly emit?: (event: SchedulerEvent) => Effect.Effect<void, Error>;
148
148
  readonly flowId: string;
149
149
  readonly inputs?: Readonly<Record<string, Readonly<Record<string, JsonValue>>>>;
150
- readonly invokeTask: (invocation: TaskInvocation) => Effect.Effect<unknown, Error>;
150
+ readonly invokeTask: (invocation: TaskInvocation, outputs: (value: unknown) => Effect.Effect<void, Error>) => Effect.Effect<unknown, Error>;
151
151
  readonly projectFailure?: (error: unknown) => SchedulerFailure;
152
152
  readonly resume?: {
153
153
  readonly action: WaitAction;
@@ -122,14 +122,10 @@ function p(e, t) {
122
122
  case "subflow": return a(e.subflows[t.subflowId].inputs);
123
123
  case "task": return a([...t.task == null ? e.tasks[t.taskId].inputs : t.task.inputs, ...t.additionalInputs ?? []]);
124
124
  case "wait": {
125
- let n = t.notification == null ? void 0 : e.tasks[t.notification.taskId];
125
+ let n = t.notification, r = n == null ? void 0 : e.tasks[n.taskId];
126
126
  return {
127
- value: {
128
- jsonSchema: {},
129
- nullable: !0,
130
- value: null
131
- },
132
- ...t.notification == null || n == null ? {} : Object.fromEntries(n.inputs.flatMap((e) => "handle" in e && e.handle != t.notification.messageHandle ? [[d(e.handle), e]] : []))
127
+ [t.input.handle]: t.input,
128
+ ...n == null || r == null ? {} : Object.fromEntries(r.inputs.flatMap((e) => "handle" in e && e.handle != n.messageHandle ? [[d(e.handle), e]] : []))
133
129
  };
134
130
  }
135
131
  }
@@ -317,6 +313,7 @@ function D(e, t, n) {
317
313
  }
318
314
  }
319
315
  function O(e, t) {
316
+ if (e === void 0) return {};
320
317
  if (typeof e != "object" || !e || Array.isArray(e)) throw Error(`Node "${t}" must return an object.`);
321
318
  return e;
322
319
  }
@@ -374,7 +371,7 @@ function k(r, s, c, d, b, x = {}, S, C, w) {
374
371
  }), ee = (t, n, i, o) => {
375
372
  let l = e.gen(function* () {
376
373
  let l = h(r.prepared, n), u = m(r.prepared, n), d = Object.fromEntries(Object.entries(o).filter(([e]) => {
377
- if (n.kind == "wait") return e == "value";
374
+ if (n.kind == "wait") return e == n.input.handle;
378
375
  let t = n.inputs[e];
379
376
  return t?.kind != "sources" || t.sources.every((e) => e.kind != "binding");
380
377
  }));
@@ -417,7 +414,14 @@ function k(r, s, c, d, b, x = {}, S, C, w) {
417
414
  break;
418
415
  }
419
416
  case "task": {
420
- let a = new Set((n.additionalInputs ?? []).map((e) => e.handle)), l = yield* r.invokeTask({
417
+ let a = new Set((n.additionalInputs ?? []).map((e) => e.handle)), l = /* @__PURE__ */ new Map(), u = (n) => e.gen(function* () {
418
+ let r = yield* e.try({
419
+ try: () => O(n, t),
420
+ catch: (e) => e instanceof Error ? e : Error(String(e))
421
+ });
422
+ for (let [e, n] of Object.entries(r)) yield* Z(t, i, e, n), l.set(e, n);
423
+ });
424
+ yield* u(yield* r.invokeTask({
421
425
  additionalInputs: Object.fromEntries(Object.entries(o).filter(([e]) => a.has(e))),
422
426
  blockId: n.task == null ? n.taskId : n.task.moduleId,
423
427
  flowId: s.flowId,
@@ -430,12 +434,7 @@ function k(r, s, c, d, b, x = {}, S, C, w) {
430
434
  capabilities: n.task.capabilities ?? [],
431
435
  moduleId: n.task.moduleId
432
436
  }
433
- });
434
- f = yield* e.try({
435
- try: () => O(l, t),
436
- catch: (e) => e instanceof Error ? e : Error(String(e))
437
- });
438
- for (let [e, n] of Object.entries(f)) yield* Z(t, i, e, n);
437
+ }, u)), f = Object.fromEntries(l);
439
438
  break;
440
439
  }
441
440
  case "wait": return yield* e.fail(/* @__PURE__ */ Error("Wait jobs are handled by the Scheduler suspension boundary."));
@@ -464,10 +463,10 @@ function k(r, s, c, d, b, x = {}, S, C, w) {
464
463
  taskId: n.notification.taskId
465
464
  } },
466
465
  order: d,
467
- value: a.value ?? null,
466
+ value: a[n.input.handle] ?? null,
468
467
  waitId: i()
469
468
  };
470
- let e = n.inputs.value, o = e?.kind == "sources" && e.sources.some((e) => e.kind == "binding") ? {} : { value: a.value ?? null };
469
+ let e = n.inputs[n.input.handle], o = e?.kind == "sources" && e.sources.some((e) => e.kind == "binding") ? {} : { [n.input.handle]: a[n.input.handle] ?? null };
471
470
  B(r.emit({
472
471
  inputs: o,
473
472
  jobId: l,
@@ -513,7 +512,7 @@ function k(r, s, c, d, b, x = {}, S, C, w) {
513
512
  if (Y = (e) => {
514
513
  if (G != null || q) return;
515
514
  let t = s.graph.nodes[e], n = N.get(e);
516
- for (; n.ready && (R.get(e) ?? 0) < t.concurrency;) te(e);
515
+ for (; n.ready && (R.get(e) ?? 0) < t.concurrency;) if (te(e), q) return;
517
516
  }, w == null) {
518
517
  for (let [e, t] of Object.entries(x)) {
519
518
  let n = N.get(e);
package/dist/index.d.ts CHANGED
@@ -57,7 +57,7 @@ export interface TaskContext<Outputs extends object = Record<string, unknown>> {
57
57
  readonly artifact: ArtifactCapability;
58
58
  readonly fetch: typeof fetch;
59
59
  readonly logger: TaskLogger;
60
- output<Handle extends keyof Outputs & string>(handle: Handle, value: Outputs[Handle]): Promise<void>;
60
+ outputs(value: Partial<Outputs>): Promise<void>;
61
61
  preview(payload: PreviewPayload, id?: string): Promise<void>;
62
62
  reportProgress(progress: number): Promise<void>;
63
63
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oomol-lab/open-flow",
3
- "version": "0.1.0-beta.5",
3
+ "version": "0.1.0-beta.7",
4
4
  "description": "TypeScript contracts and Browser runtime for Open Flow.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {