@voltro/plugin-ai-flows 0.76.0 → 0.77.0

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/dist/index.js CHANGED
@@ -1,81 +1,81 @@
1
1
  import { FLOW_RUN_WORKFLOW as e, HUMAN_RESPONSE_SIGNAL_PREFIX as t, flowRunWorkflow as n, humanResponseSignalName as r } from "./workflow.js";
2
- import { A as i, B as a, C as o, D as s, E as c, F as l, H as u, I as d, L as f, M as p, N as m, O as h, P as ee, R as g, S as te, T as ne, V as re, _ as ie, a as ae, b as oe, c as se, d as ce, f as le, g as ue, h as de, i as _, j as fe, k as pe, l as me, m as he, n as ge, o as v, p as _e, r as ve, s as ye, t as be, u as xe, v as Se, w as Ce, x as we, y as Te, z as Ee } from "./ir-BW5JRUiH.js";
2
+ import { A as i, B as a, C as o, D as s, E as c, F as l, H as u, I as d, L as f, M as p, N as m, O as h, P as ee, R as g, S as te, T as ne, V as re, _ as ie, a as ae, b as oe, c as se, d as ce, f as le, g as ue, h as de, i as _, j as fe, k as pe, l as me, m as he, n as ge, o as v, p as _e, r as ve, s as ye, t as be, u as xe, v as Se, w as Ce, x as we, y as Te, z as Ee } from "./ir-DcPJp738.js";
3
3
  import { FlowBriefIncomplete as De, FlowCapabilityMissing as y, FlowDependencyError as Oe, FlowNotAwaitingResponse as ke, FlowNotFound as Ae, FlowReviewDeliveryError as je, FlowRunNotFound as b, FlowValidationError as Me } from "./errors.js";
4
4
  import { n as Ne, t as Pe } from "./cadence-_9Izk_fL.js";
5
5
  import { Cause as Fe, Effect as x, Schema as S } from "effect";
6
6
  import { WorkflowControlResultSchema as Ie, WorkflowRunHandleSchema as Le, definePlugin as Re, pluginInstanceName as ze } from "@voltro/protocol";
7
- import { and as Be, boolean as Ve, eq as C, id as He, inSet as Ue, integer as w, json as T, queryFor as E, registerRetention as We, table as Ge, text as D, timestamp as Ke } from "@voltro/database";
8
- import { tenant as qe } from "@voltro/plugin-multitenancy/mixin";
9
- import { audit as Je } from "@voltro/plugin-audit/mixin";
10
- import { softDelete as Ye } from "@voltro/plugin-soft-delete/mixin";
11
- import { awaitSignalSuspending as Xe, step as O } from "@voltro/workflow";
12
- import { defineTool as Ze, estimateCostUsd as Qe, gatewayCostUsd as $e, generateImage as et, generateObject as tt, generateObjectJson as nt, generateObjectWithTools as rt, generateSpeech as it, generateText as at, generateVideo as ot, isMeteredUsage as st } from "@voltro/ai";
13
- import { createHash as ct } from "node:crypto";
7
+ import { and as C, boolean as Be, eq as w, id as Ve, inSet as He, integer as T, json as E, queryFor as D, registerRetention as Ue, table as We, text as O, timestamp as Ge } from "@voltro/database";
8
+ import { tenant as Ke } from "@voltro/plugin-multitenancy/mixin";
9
+ import { audit as qe } from "@voltro/plugin-audit/mixin";
10
+ import { softDelete as Je } from "@voltro/plugin-soft-delete/mixin";
11
+ import { awaitSignalSuspending as Ye, step as k } from "@voltro/workflow";
12
+ import { defineTool as Xe, estimateCostUsd as Ze, gatewayCostUsd as Qe, generateImage as $e, generateObject as et, generateObjectJson as tt, generateObjectWithTools as nt, generateSpeech as rt, generateText as it, generateVideo as at, isMeteredUsage as ot } from "@voltro/ai";
13
+ import { createHash as st } from "node:crypto";
14
14
  //#region src/table.ts
15
- var k = Ge("_voltro_ai_flows", {
16
- id: He({ prefix: "aifl" }),
17
- name: D(),
18
- description: D().nullable(),
19
- mode: D().default("deterministic"),
20
- status: D().default("draft"),
21
- visibility: D().default("private"),
22
- orchestratorModel: D().nullable(),
23
- orchestratorInstructions: D().nullable(),
24
- maxSteps: w().default(30),
25
- steps: T().nullable(),
26
- inputSchema: T().nullable(),
27
- chainTo: T().nullable(),
28
- cadence: T().nullable(),
29
- humanTimeoutMs: w().nullable(),
30
- isEnabled: Ve().default(!0),
31
- metadata: T().nullable(),
32
- icon: D().nullable(),
33
- color: D().nullable(),
34
- avatarUrl: D().nullable(),
35
- usageCount: w().default(0),
36
- ownerId: D().nullable()
37
- }).renamedFrom("ai_flows").with(qe(), Je(), Ye()).index(["status"]).index(["visibility"]), A = Ge("_voltro_ai_flow_runs", {
38
- id: He({ prefix: "aifr" }),
39
- flowRef: D(),
40
- flowName: D().nullable(),
41
- mode: D().default("deterministic"),
42
- status: D().default("pending"),
43
- source: D().nullable(),
44
- requestId: D(),
45
- workflowStart: T().nullable(),
46
- input: T().nullable(),
47
- output: T().nullable(),
48
- steps: T().nullable(),
49
- currentStep: w().default(0),
50
- totalSteps: w().default(0),
51
- humanResponse: T().nullable(),
52
- chainPending: T().nullable(),
53
- chainRefusal: D().nullable(),
54
- costMicroUsd: w().default(0),
55
- costCompleteness: D().default("unknown"),
56
- durationMs: w().nullable(),
57
- error: D().nullable(),
58
- errorMessage: D().nullable(),
59
- startedAt: Ke().nullable(),
60
- completedAt: Ke().nullable(),
61
- cancelledAt: Ke().nullable(),
62
- sessionId: D().nullable(),
63
- sessionName: D().nullable(),
64
- ownerId: D().nullable(),
65
- metadata: T().nullable()
66
- }).renamedFrom("ai_flow_runs").with(qe(), Je()).index(["flowRef"]).index(["status"]).index(["requestId"]), lt = [k, A], ut = S.Struct({
15
+ var A = We("_voltro_ai_flows", {
16
+ id: Ve({ prefix: "aifl" }),
17
+ name: O(),
18
+ description: O().nullable(),
19
+ mode: O().default("deterministic"),
20
+ status: O().default("draft"),
21
+ visibility: O().default("private"),
22
+ orchestratorModel: O().nullable(),
23
+ orchestratorInstructions: O().nullable(),
24
+ maxSteps: T().default(30),
25
+ steps: E().nullable(),
26
+ inputSchema: E().nullable(),
27
+ chainTo: E().nullable(),
28
+ cadence: E().nullable(),
29
+ humanTimeoutMs: T().nullable(),
30
+ isEnabled: Be().default(!0),
31
+ metadata: E().nullable(),
32
+ icon: O().nullable(),
33
+ color: O().nullable(),
34
+ avatarUrl: O().nullable(),
35
+ usageCount: T().default(0),
36
+ ownerId: O().nullable()
37
+ }).renamedFrom("ai_flows").with(Ke(), qe(), Je()).index(["status"]).index(["visibility"]), j = We("_voltro_ai_flow_runs", {
38
+ id: Ve({ prefix: "aifr" }),
39
+ flowRef: O(),
40
+ flowName: O().nullable(),
41
+ mode: O().default("deterministic"),
42
+ status: O().default("pending"),
43
+ source: O().nullable(),
44
+ requestId: O(),
45
+ workflowStart: E().nullable(),
46
+ input: E().nullable(),
47
+ output: E().nullable(),
48
+ steps: E().nullable(),
49
+ currentStep: T().default(0),
50
+ totalSteps: T().default(0),
51
+ humanResponse: E().nullable(),
52
+ chainPending: E().nullable(),
53
+ chainRefusal: O().nullable(),
54
+ costMicroUsd: T().default(0),
55
+ costCompleteness: O().default("unknown"),
56
+ durationMs: T().nullable(),
57
+ error: O().nullable(),
58
+ errorMessage: O().nullable(),
59
+ startedAt: Ge().nullable(),
60
+ completedAt: Ge().nullable(),
61
+ cancelledAt: Ge().nullable(),
62
+ sessionId: O().nullable(),
63
+ sessionName: O().nullable(),
64
+ ownerId: O().nullable(),
65
+ metadata: E().nullable()
66
+ }).renamedFrom("ai_flow_runs").with(Ke(), qe()).index(["flowRef"]).index(["status"]).index(["requestId"]), ct = [A, j], lt = S.Struct({
67
67
  id: S.NonEmptyString,
68
68
  workflowName: S.Literal(e),
69
69
  status: S.Literal("queued")
70
- }), j = (t) => ({
70
+ }), M = (t) => ({
71
71
  id: t,
72
72
  workflowName: e,
73
73
  executionId: t,
74
74
  status: "running"
75
- }), dt = (e) => {
75
+ }), ut = (e) => {
76
76
  let t = `flow start was not executed: ${e.reason}`;
77
77
  return e.incumbentExecutionId === null ? e.failureId === null ? t : `${t} (failure report ${e.failureId})` : `${t} (incumbent execution ${e.incumbentExecutionId})`;
78
- }, ft = async (e, t = {}) => {
78
+ }, dt = async (e, t = {}) => {
79
79
  let n = e.workflows;
80
80
  if (!n) throw Error("workflow runtime unavailable; flow starts cannot be reconciled");
81
81
  if (n.startsDeferredUntilCommit === !0) return {
@@ -86,8 +86,8 @@ var k = Ge("_voltro_ai_flows", {
86
86
  failures: []
87
87
  };
88
88
  let r = t.take ?? 200, i = await e.store.query({
89
- table: A.tableName,
90
- predicate: C("status", "pending"),
89
+ table: j.tableName,
90
+ predicate: w("status", "pending"),
91
91
  order: [],
92
92
  take: r,
93
93
  skip: void 0,
@@ -102,7 +102,7 @@ var k = Ge("_voltro_ai_flows", {
102
102
  for (let t of i) {
103
103
  let r = t.id;
104
104
  if (typeof r != "string") continue;
105
- let i = S.decodeUnknownOption(ut)(t.workflowStart);
105
+ let i = S.decodeUnknownOption(lt)(t.workflowStart);
106
106
  if (i._tag !== "None") {
107
107
  a.examined++;
108
108
  try {
@@ -116,14 +116,14 @@ var k = Ge("_voltro_ai_flows", {
116
116
  }
117
117
  let o = (/* @__PURE__ */ new Date()).toISOString();
118
118
  if (t.kind === "accepted") {
119
- if (await e.store.update(A.tableName, r, { workflowStart: j(t.executionId) }) === null) throw Error("flow run disappeared while recording its accepted start");
119
+ if (await e.store.update(j.tableName, r, { workflowStart: M(t.executionId) }) === null) throw Error("flow run disappeared while recording its accepted start");
120
120
  a.accepted++;
121
121
  continue;
122
122
  }
123
- if (await e.store.update(A.tableName, r, {
123
+ if (await e.store.update(j.tableName, r, {
124
124
  status: "failed",
125
125
  error: "FlowStartNotExecuted",
126
- errorMessage: dt(t),
126
+ errorMessage: ut(t),
127
127
  completedAt: o
128
128
  }) === null) throw Error("flow run disappeared while recording that its start will not execute");
129
129
  a.notExecuted++;
@@ -136,32 +136,32 @@ var k = Ge("_voltro_ai_flows", {
136
136
  }
137
137
  }
138
138
  return a;
139
- }, pt = 168, mt = "VOLTRO_AI_FLOW_HUMAN_REVIEW_TIMEOUT_HOURS", ht = 2160, gt = "VOLTRO_AI_FLOW_RUNS_TTL_HOURS", _t = 5, vt = "VOLTRO_AI_FLOW_MAX_CHAIN_DEPTH", M = { current: {} }, yt = (e) => {
140
- M.current = e;
141
- }, N = () => M.current, bt = () => {
142
- M.current = {};
143
- }, xt = (e, t) => {
139
+ }, ft = 168, pt = "VOLTRO_AI_FLOW_HUMAN_REVIEW_TIMEOUT_HOURS", mt = 2160, ht = "VOLTRO_AI_FLOW_RUNS_TTL_HOURS", gt = 5, _t = "VOLTRO_AI_FLOW_MAX_CHAIN_DEPTH", N = { current: {} }, vt = (e) => {
140
+ N.current = e;
141
+ }, P = () => N.current, yt = () => {
142
+ N.current = {};
143
+ }, bt = (e, t) => {
144
144
  if (e === void 0 || e.trim() === "") return t * 36e5;
145
145
  let n = Number(e);
146
146
  return !Number.isFinite(n) || n < 0 ? t * 36e5 : n * 36e5;
147
- }, St = (e) => Number.isFinite(e) && e > 0 ? e : Infinity, Ct = (e) => {
147
+ }, xt = (e) => Number.isFinite(e) && e > 0 ? e : Infinity, St = (e) => {
148
148
  let t = e.env ?? process.env;
149
- return St(e.step?.timeoutMs ?? e.flow?.humanTimeoutMs ?? e.deps?.humanReviewTimeoutMs ?? N().humanReviewTimeoutMs ?? xt(t.VOLTRO_AI_FLOW_HUMAN_REVIEW_TIMEOUT_HOURS, 168));
150
- }, wt = (e) => {
151
- let t = e?.env ?? process.env, n = Number(t[vt]), r = e?.maxChainDepth ?? N().maxChainDepth ?? (Number.isFinite(n) && n >= 1 ? n : 5);
149
+ return xt(e.step?.timeoutMs ?? e.flow?.humanTimeoutMs ?? e.deps?.humanReviewTimeoutMs ?? P().humanReviewTimeoutMs ?? bt(t.VOLTRO_AI_FLOW_HUMAN_REVIEW_TIMEOUT_HOURS, 168));
150
+ }, Ct = (e) => {
151
+ let t = e?.env ?? process.env, n = Number(t[_t]), r = e?.maxChainDepth ?? P().maxChainDepth ?? (Number.isFinite(n) && n >= 1 ? n : 5);
152
152
  return Number.isFinite(r) && r >= 1 ? r : 5;
153
- }, Tt = /\{\{\s*([\w.-]+)\s*\}\}/g, P = (e) => {
153
+ }, wt = /\{\{\s*([\w.-]+)\s*\}\}/g, F = (e) => {
154
154
  let t = [];
155
- for (let n of e.matchAll(Tt)) t.push(n[1]);
155
+ for (let n of e.matchAll(wt)) t.push(n[1]);
156
156
  return t;
157
- }, F = (e, t) => e.replace(Tt, (e, n) => {
157
+ }, I = (e, t) => e.replace(wt, (e, n) => {
158
158
  let r = t[n];
159
159
  return r == null ? "" : typeof r == "string" ? r : JSON.stringify(r);
160
- }), Et = (e, t) => {
160
+ }), Tt = (e, t) => {
161
161
  let n = /* @__PURE__ */ new Set();
162
- for (let r of P(e)) t[r] == null && !n.has(r) && n.add(r);
162
+ for (let r of F(e)) t[r] == null && !n.has(r) && n.add(r);
163
163
  return [...n];
164
- }, I = (e) => {
164
+ }, L = (e) => {
165
165
  let t = [], n;
166
166
  if (e.forEach((e, r) => {
167
167
  let i = e.group;
@@ -190,54 +190,54 @@ var k = Ge("_voltro_ai_flows", {
190
190
  });
191
191
  }
192
192
  return t;
193
- }, Dt = (e) => {
193
+ }, Et = (e) => {
194
194
  let t = /* @__PURE__ */ new Map();
195
195
  for (let n of e) n.group !== void 0 && t.set(n.group, (t.get(n.group) ?? 0) + 1);
196
196
  return [...t.entries()].filter(([, e]) => e > 1).map(([e]) => e).sort();
197
- }, L = /* @__PURE__ */ new Map(), Ot = (e) => {
198
- L.set(e.name, e);
199
- }, kt = (e) => L.get(e), At = () => [...L.values()], jt = () => L.clear(), R = S.suspend(() => S.Union(S.Null, S.Boolean, S.Finite, S.String, S.Array(R).pipe(S.mutable), S.Record({
197
+ }, R = /* @__PURE__ */ new Map(), Dt = (e) => {
198
+ R.set(e.name, e);
199
+ }, Ot = (e) => R.get(e), kt = () => [...R.values()], At = () => R.clear(), z = S.suspend(() => S.Union(S.Null, S.Boolean, S.Finite, S.String, S.Array(z).pipe(S.mutable), S.Record({
200
200
  key: S.String,
201
- value: R
202
- }))), z = S.Record({
201
+ value: z
202
+ }))), B = S.Record({
203
203
  key: S.String,
204
204
  value: S.Record({
205
205
  key: S.String,
206
- value: R
206
+ value: z
207
207
  })
208
- }), Mt = S.Struct({
208
+ }), jt = S.Struct({
209
209
  maxTokens: S.optionalWith(S.Int.pipe(S.positive(), S.lessThanOrEqualTo(2 ** 53 - 1)), { exact: !0 }),
210
210
  temperature: S.optionalWith(S.Finite.pipe(S.nonNegative()), { exact: !0 }),
211
- providerOptions: S.optionalWith(z, { exact: !0 })
212
- }), Nt = [
211
+ providerOptions: S.optionalWith(B, { exact: !0 })
212
+ }), Mt = [
213
213
  "maxTokens",
214
214
  "temperature",
215
215
  "providerOptions"
216
- ], Pt = (e) => {
216
+ ], Nt = (e) => {
217
217
  if (typeof e != "object" || !e || Array.isArray(e)) return "params must be an object";
218
- let t = Object.keys(e), n = t.filter((e) => !Nt.includes(e)).sort(), r = t.filter((t) => Nt.includes(t) && S.decodeUnknownOption(Mt)({ [t]: e[t] })._tag === "None").sort();
218
+ let t = Object.keys(e), n = t.filter((e) => !Mt.includes(e)).sort(), r = t.filter((t) => Mt.includes(t) && S.decodeUnknownOption(jt)({ [t]: e[t] })._tag === "None").sort();
219
219
  return [...n.length > 0 ? [`unsupported field${n.length === 1 ? "" : "s"}: ${n.join(", ")}`] : [], ...r.length > 0 ? [`invalid value for: ${r.join(", ")}`] : []].join("; ");
220
- }, Ft = (e) => x.try({
221
- try: () => S.decodeUnknownSync(Mt, { onExcessProperty: "error" })(e === void 0 ? {} : e),
222
- catch: () => `invalid text params (${Pt(e)}): expected maxTokens (positive safe integer), temperature (finite nonnegative number), and/or providerOptions (provider-keyed JSON object); other fields are not supported`
223
- }), B = S.String.pipe(S.filter((e) => {
220
+ }, Pt = (e) => x.try({
221
+ try: () => S.decodeUnknownSync(jt, { onExcessProperty: "error" })(e === void 0 ? {} : e),
222
+ catch: () => `invalid text params (${Nt(e)}): expected maxTokens (positive safe integer), temperature (finite nonnegative number), and/or providerOptions (provider-keyed JSON object); other fields are not supported`
223
+ }), V = S.String.pipe(S.filter((e) => {
224
224
  try {
225
225
  let t = new URL(e);
226
226
  return (t.protocol === "https:" || t.protocol === "http:") && t.username === "" && t.password === "";
227
227
  } catch {
228
228
  return !1;
229
229
  }
230
- })), V = S.Record({
230
+ })), Ft = S.Record({
231
231
  key: S.String,
232
- value: B
232
+ value: V
233
233
  }), It = (e, t, n = {}) => x.try({
234
234
  try: () => {
235
235
  let r = S.decodeUnknownSync(te, { onExcessProperty: "error" })(e === void 0 ? {} : e), i = Object.fromEntries(Object.entries(r).map(([e, r]) => [e, r.from === "upload" ? r.url : r.artifact === void 0 ? Object.hasOwn(t, r.ref) ? t[r.ref] : void 0 : Object.hasOwn(n, r.ref) ? n[r.ref]?.[r.artifact]?.url : void 0]));
236
- return S.decodeUnknownSync(V)(i);
236
+ return S.decodeUnknownSync(Ft)(i);
237
237
  },
238
238
  catch: () => "invalid or unresolved media input: each slot must resolve to an absolute HTTP(S) URL without embedded credentials"
239
239
  }), Lt = S.Struct({
240
- url: B,
240
+ url: V,
241
241
  mediaType: S.NonEmptyString
242
242
  });
243
243
  S.Record({
@@ -250,7 +250,7 @@ var Rt = (e, t = {}) => {
250
250
  let r = {};
251
251
  for (let [e, i] of Object.entries(n.value)) {
252
252
  if (i.from === "upload") {
253
- i.mediaType !== void 0 && S.is(B)(i.url) && (r[e] = {
253
+ i.mediaType !== void 0 && S.is(V)(i.url) && (r[e] = {
254
254
  url: i.url,
255
255
  mediaType: i.mediaType
256
256
  });
@@ -258,7 +258,7 @@ var Rt = (e, t = {}) => {
258
258
  }
259
259
  if (i.artifact === void 0 || !Object.hasOwn(t, i.ref)) continue;
260
260
  let n = t[i.ref]?.[i.artifact];
261
- n !== void 0 && S.is(B)(n.url) && (r[e] = {
261
+ n !== void 0 && S.is(V)(n.url) && (r[e] = {
262
262
  url: n.url,
263
263
  mediaType: n.mediaType
264
264
  });
@@ -266,7 +266,7 @@ var Rt = (e, t = {}) => {
266
266
  return r;
267
267
  }, zt = (e, t) => x.try({
268
268
  try: () => {
269
- let n = S.decodeUnknownSync(V)(t === void 0 ? {} : t), r = e === "image" ? ["referenceImageUrl", "maskImageUrl"] : e === "video" ? [
269
+ let n = S.decodeUnknownSync(Ft)(t === void 0 ? {} : t), r = e === "image" ? ["referenceImageUrl", "maskImageUrl"] : e === "video" ? [
270
270
  "referenceImageUrl",
271
271
  "firstFrameImageUrl",
272
272
  "lastFrameImageUrl",
@@ -319,7 +319,7 @@ var Rt = (e, t = {}) => {
319
319
  return t.maxSteps !== void 0 && (!Number.isSafeInteger(t.maxSteps) || t.maxSteps < 1) ? yield* x.fail(new y({
320
320
  capability: "resolveAgent",
321
321
  message: "agent maxSteps must be a positive safe integer"
322
- })) : yield* at({
322
+ })) : yield* it({
323
323
  ...r,
324
324
  system: t.system,
325
325
  prompt: n,
@@ -328,12 +328,12 @@ var Rt = (e, t = {}) => {
328
328
  ...t.maxSteps === void 0 ? {} : { maxSteps: t.maxSteps }
329
329
  });
330
330
  }), Jt = (e, t, n) => K(e, t, n).costMicroUsd, K = (e, t, n) => {
331
- let r = $e(t);
331
+ let r = Qe(t);
332
332
  if (typeof r == "number") return {
333
333
  costMicroUsd: Gt(r),
334
334
  costSource: "gateway"
335
335
  };
336
- let i = Qe(e, { model: n ?? "unknown" });
336
+ let i = Ze(e, { model: n ?? "unknown" });
337
337
  return {
338
338
  costMicroUsd: i.costMicroUsd ?? 0,
339
339
  costSource: i.costSource ?? "unpriced"
@@ -343,13 +343,19 @@ var Rt = (e, t = {}) => {
343
343
  if (t.length === 0) return "unknown";
344
344
  let n = t.map((e) => e.costSource ?? "unpriced");
345
345
  return n.every((e) => e === "gateway") ? "actual" : n.some((e) => e === "unpriced") ? "incomplete" : "estimated";
346
- }, J = (e, t, n) => x.promise(() => e.store.update(A.tableName, t, n).then(() => void 0)).pipe(x.catchAllCause(() => x.void)), Yt = (e, t, n, r) => x.promise(async () => {
347
- let i = await e.store.query(E(A).where(C("id", t)).descriptor), a = i[0]?.[r];
348
- i[0] !== void 0 && a == null && await e.store.update(A.tableName, t, n);
349
- }).pipe(x.catchAllCause(() => x.void)), Xt = (e, t) => x.promise(async () => (await e.store.query(E(A).where(C("id", t)).descriptor))[0]?.status === "cancelled").pipe(x.catchAllCause(() => x.succeed(!1))), Zt = (e, t) => x.gen(function* () {
350
- let n = kt(t);
346
+ }, J = (e, t, n) => x.promise(() => e.store.update(j.tableName, t, n).then(() => void 0)).pipe(x.catchAllCause(() => x.void)), Yt = (e, t, n, r) => x.promise(async () => {
347
+ let i = await e.store.query(D(j).where(w("id", t)).descriptor), a = i[0]?.[r];
348
+ i[0] !== void 0 && a == null && await e.store.update(j.tableName, t, n);
349
+ }).pipe(x.catchAllCause(() => x.void)), Xt = (e, t) => x.promise(async () => {
350
+ let n = (await e.store.query(D(j).where(w("id", t)).descriptor))[0]?.status;
351
+ return n === "cancelling" || n === "cancelled";
352
+ }).pipe(x.catchAllCause(() => x.succeed(!1))), Zt = (e, t) => x.promise(() => e.store.updateMany(j.tableName, {
353
+ status: "cancelled",
354
+ completedAt: W()
355
+ }, { where: C(w("id", t), w("status", "cancelling")) }).then(() => void 0)).pipe(x.catchAllCause(() => x.void)), Qt = (e, t) => x.gen(function* () {
356
+ let n = Ot(t);
351
357
  if (n) return n;
352
- let r = (yield* x.promise(() => e.store.query(E(k).where(C("id", t)).descriptor)))[0];
358
+ let r = (yield* x.promise(() => e.store.query(D(A).where(w("id", t)).descriptor)))[0];
353
359
  return r ? d({
354
360
  name: r.name ?? t,
355
361
  mode: r.mode,
@@ -365,11 +371,11 @@ var Rt = (e, t = {}) => {
365
371
  flowRef: t,
366
372
  message: `no flow registered or stored for "${t}"`
367
373
  }));
368
- }), Qt = (e, t, n, r, i, a) => x.gen(function* () {
369
- let e = F(n.prompt ?? "", r), o = yield* Ft(n.type === "agent" || n.type === "structured" || n.type === "generate" && (n.modality ?? "text") === "text" ? n.params : void 0).pipe(x.either);
374
+ }), $t = (e, t, n, r, i, a) => x.gen(function* () {
375
+ let e = I(n.prompt ?? "", r), o = yield* Pt(n.type === "agent" || n.type === "structured" || n.type === "generate" && (n.modality ?? "text") === "text" ? n.params : void 0).pipe(x.either);
370
376
  if (o._tag === "Left") return { error: `step "${n.id}": ${o.left}` };
371
377
  if (n.mediaInputs !== void 0 && (n.type !== "generate" || (n.modality ?? "text") === "text")) return { error: `step "${n.id}": media inputs require an image, video or audio generation step` };
372
- let s = Et(n.prompt ?? "", r);
378
+ let s = Tt(n.prompt ?? "", r);
373
379
  if (s.length > 0) return { error: new Oe({
374
380
  stepId: n.id,
375
381
  unresolvedRef: s[0],
@@ -411,7 +417,7 @@ var Rt = (e, t = {}) => {
411
417
  }
412
418
  case "structured": {
413
419
  if (n.schema === void 0) return { error: `step "${n.id}": structured step requires a JSON Schema` };
414
- let r = n.model ?? t.defaultModels?.text, i = yield* nt({
420
+ let r = n.model ?? t.defaultModels?.text, i = yield* tt({
415
421
  ...o.right,
416
422
  prompt: e,
417
423
  jsonSchema: n.schema,
@@ -432,7 +438,7 @@ var Rt = (e, t = {}) => {
432
438
  case "generate": {
433
439
  let s = n.modality ?? "text";
434
440
  if (s === "text") {
435
- let r = n.model ?? t.defaultModels?.text, i = yield* at({
441
+ let r = n.model ?? t.defaultModels?.text, i = yield* it({
436
442
  ...o.right,
437
443
  prompt: e,
438
444
  ...r ? { provider: G(t, r) } : {}
@@ -485,7 +491,7 @@ var Rt = (e, t = {}) => {
485
491
  }).message };
486
492
  default: return { error: `unknown step type: ${String(n.type)}` };
487
493
  }
488
- }), $t = (e, t, n, i, o, s) => x.gen(function* () {
494
+ }), en = (e, t, n, i, o, s) => x.gen(function* () {
489
495
  let c = Object.assign(Object.create(null), o), l = Object.create(null), u = i.steps.map((e, t) => ({
490
496
  id: t,
491
497
  title: e.title ?? `Step ${t + 1}`,
@@ -500,8 +506,8 @@ var Rt = (e, t = {}) => {
500
506
  currentStep: 0,
501
507
  startedAt: W()
502
508
  }, "startedAt");
503
- for (let o of I(i.steps)) {
504
- if (yield* Xt(e, n)) return {
509
+ for (let o of L(i.steps)) {
510
+ if (yield* Xt(e, n)) return yield* Zt(e, n), {
505
511
  runId: n,
506
512
  status: "cancelled"
507
513
  };
@@ -530,11 +536,11 @@ var Rt = (e, t = {}) => {
530
536
  steps: u,
531
537
  currentStep: o.steps[0].index
532
538
  });
533
- let i = yield* x.all(r.map(({ index: r, step: i }) => O({
539
+ let i = yield* x.all(r.map(({ index: r, step: i }) => k({
534
540
  name: `flow-${r}-${i.id}`,
535
541
  input: { index: r },
536
542
  success: Ut,
537
- execute: Qt(e, t, i, c, {
543
+ execute: $t(e, t, i, c, {
538
544
  runId: n,
539
545
  tenantId: s.tenantId,
540
546
  ownerId: s.ownerId
@@ -601,7 +607,7 @@ var Rt = (e, t = {}) => {
601
607
  let a = {
602
608
  mode: p.reviewMode ?? "approve",
603
609
  ...p.options ? { options: p.options } : {},
604
- prompt: F(p.prompt ?? "", c)
610
+ prompt: I(p.prompt ?? "", c)
605
611
  };
606
612
  u[f] = {
607
613
  ...u[f],
@@ -619,11 +625,11 @@ var Rt = (e, t = {}) => {
619
625
  ownerId: s.ownerId,
620
626
  source: s.source
621
627
  })).pipe(x.catchAllCause(() => x.void)));
622
- let o = Ct({
628
+ let o = St({
623
629
  step: p,
624
630
  flow: i,
625
631
  deps: t
626
- }), l = yield* Xe(e, {
632
+ }), l = yield* Ye(e, {
627
633
  name: r(f),
628
634
  schema: he,
629
635
  timeoutMs: o
@@ -691,11 +697,11 @@ var Rt = (e, t = {}) => {
691
697
  steps: u,
692
698
  currentStep: f
693
699
  });
694
- let m = yield* O({
700
+ let m = yield* k({
695
701
  name: `flow-${f}-${p.id}`,
696
702
  input: { index: f },
697
703
  success: Ut,
698
- execute: Qt(e, t, p, c, {
704
+ execute: $t(e, t, p, c, {
699
705
  runId: n,
700
706
  tenantId: s.tenantId,
701
707
  ownerId: s.ownerId
@@ -745,7 +751,7 @@ var Rt = (e, t = {}) => {
745
751
  status: "succeeded",
746
752
  output: f
747
753
  };
748
- }), en = (e, t, n, r, i, a, o) => x.gen(function* () {
754
+ }), tn = (e, t, n, r, i, a, o) => x.gen(function* () {
749
755
  let s = n.chain;
750
756
  if (!s) return;
751
757
  let c = [...a.chainPath ?? [], a.flowRef];
@@ -754,7 +760,7 @@ var Rt = (e, t = {}) => {
754
760
  yield* J(e, t, { chainRefusal: `chain to "${s.flowRef}" refused — it is already in this run's chain (${c.join(" → ")}), which would loop` });
755
761
  return;
756
762
  }
757
- let l = wt(o);
763
+ let l = Ct(o);
758
764
  if (c.length >= l) {
759
765
  yield* J(e, t, { chainRefusal: `chain to "${s.flowRef}" refused — depth ${c.length} reached the limit of ${l} (${c.join(" → ")})` });
760
766
  return;
@@ -777,7 +783,7 @@ var Rt = (e, t = {}) => {
777
783
  let p = `${t}--chain`, m = `${a.requestId}--chain`;
778
784
  yield* x.promise(async () => {
779
785
  try {
780
- await e.store.insert(A.tableName, {
786
+ await e.store.insert(j.tableName, {
781
787
  id: p,
782
788
  flowRef: s.flowRef,
783
789
  flowName: s.flowRef,
@@ -796,14 +802,14 @@ var Rt = (e, t = {}) => {
796
802
  chainPath: c
797
803
  });
798
804
  }).pipe(x.catchAllCause(() => x.void));
799
- }), tn = (e) => e.steps.length === 0 ? "" : "Suggested plan (you MAY reorder, insert, or skip steps):\n" + e.steps.map((e, t) => `${t + 1}. [${e.type}${e.modality ? `/${e.modality}` : ""}] ${e.title ?? e.id}${e.prompt ? `: ${e.prompt}` : ""}`).join("\n"), nn = (e) => {
805
+ }), nn = (e) => e.steps.length === 0 ? "" : "Suggested plan (you MAY reorder, insert, or skip steps):\n" + e.steps.map((e, t) => `${t + 1}. [${e.type}${e.modality ? `/${e.modality}` : ""}] ${e.title ?? e.id}${e.prompt ? `: ${e.prompt}` : ""}`).join("\n"), rn = (e) => {
800
806
  let t = Object.entries(e);
801
807
  return t.length === 0 ? "Execute the flow." : "Brief for this run:\n" + t.map(([e, t]) => `- ${e}: ${typeof t == "string" ? t : JSON.stringify(t)}`).join("\n");
802
- }, rn = (e) => [
808
+ }, an = (e) => [
803
809
  e.orchestrator?.instructions ?? "You are an orchestrator that uses the available tools to produce a bundled result.",
804
- tn(e),
810
+ nn(e),
805
811
  "When finished, emit a JSON object mapping each deliverable name (outputKey) to its value."
806
- ].filter(Boolean).join("\n\n"), an = S.Struct({
812
+ ].filter(Boolean).join("\n\n"), on = S.Struct({
807
813
  object: S.Record({
808
814
  key: S.String,
809
815
  value: S.Unknown
@@ -813,16 +819,16 @@ var Rt = (e, t = {}) => {
813
819
  toolCostMicroUsd: S.Number,
814
820
  steps: S.Array(i),
815
821
  error: S.optional(S.String)
816
- }), on = (e, t, n, r, i, a, o, s) => x.gen(function* () {
822
+ }), sn = (e, t, n, r, i, a, o, s) => x.gen(function* () {
817
823
  yield* Yt(e, n, {
818
824
  status: "running",
819
825
  startedAt: W(),
820
826
  totalSteps: r.steps.length
821
827
  }, "startedAt");
822
- let c = yield* O({
828
+ let c = yield* k({
823
829
  name: "flow-agentic",
824
830
  input: { flowRef: r.name },
825
- success: an,
831
+ success: on,
826
832
  execute: x.gen(function* () {
827
833
  let c = [], l = 0, u = (e) => {
828
834
  let t = c.length;
@@ -843,7 +849,7 @@ var Rt = (e, t = {}) => {
843
849
  currentStep: c.length,
844
850
  costMicroUsd: l
845
851
  }), p = {
846
- run_agent: Ze({
852
+ run_agent: Xe({
847
853
  name: "run_agent",
848
854
  description: "Delegate a text task to an allowed sub-agent. Returns the agent's text.",
849
855
  input: S.Struct({
@@ -896,14 +902,14 @@ var Rt = (e, t = {}) => {
896
902
  }), yield* f(), c.r.text;
897
903
  })
898
904
  }),
899
- generate_media: Ze({
905
+ generate_media: Xe({
900
906
  name: "generate_media",
901
907
  description: "Generate image, video, or audio artifacts. Returns every artifact with its URL, role, media type and optional storage reference.",
902
908
  input: S.Struct({
903
909
  modality: S.Literal("image", "video", "audio"),
904
910
  prompt: S.String,
905
911
  model: S.optional(S.String),
906
- inputs: S.optional(V),
912
+ inputs: S.optional(Ft),
907
913
  params: S.optional(S.Record({
908
914
  key: S.String,
909
915
  value: S.Unknown
@@ -954,7 +960,7 @@ var Rt = (e, t = {}) => {
954
960
  }), yield* f(), { artifacts: h.artifacts });
955
961
  })
956
962
  }),
957
- pick_structured: Ze({
963
+ pick_structured: Xe({
958
964
  name: "pick_structured",
959
965
  description: "Produce a JSON object for a task. Returns the object.",
960
966
  input: S.Struct({
@@ -967,7 +973,7 @@ var Rt = (e, t = {}) => {
967
973
  type: "structured"
968
974
  });
969
975
  yield* f();
970
- let i = yield* tt({
976
+ let i = yield* et({
971
977
  prompt: e,
972
978
  schema: S.Record({
973
979
  key: S.String,
@@ -1015,9 +1021,9 @@ var Rt = (e, t = {}) => {
1015
1021
  steps: c,
1016
1022
  error: "flow tools cannot replace reserved planner tools"
1017
1023
  };
1018
- let h = t.memoryPrefix ? yield* H(t.memoryPrefix(a)).pipe(x.catchAll(() => x.succeed(""))) : "", ee = h ? `${h}\n\n${rn(r)}` : rn(r), g = yield* rt({
1024
+ let h = t.memoryPrefix ? yield* H(t.memoryPrefix(a)).pipe(x.catchAll(() => x.succeed(""))) : "", ee = h ? `${h}\n\n${an(r)}` : an(r), g = yield* nt({
1019
1025
  system: ee,
1020
- prompt: nn(i),
1026
+ prompt: rn(i),
1021
1027
  schema: S.Record({
1022
1028
  key: S.String,
1023
1029
  value: S.Unknown
@@ -1076,8 +1082,8 @@ var Rt = (e, t = {}) => {
1076
1082
  status: "succeeded",
1077
1083
  output: c.object
1078
1084
  });
1079
- }), sn = (e, t = {}) => (n, r) => x.gen(function* () {
1080
- let { runId: r, flowRef: i, input: a } = n, o = yield* x.tryPromise(() => e.store.query(E(A).where(C("id", r)).descriptor)).pipe(x.flatMap(S.decodeUnknown(S.Tuple(S.Struct({
1085
+ }), cn = (e, t = {}) => (n, r) => x.gen(function* () {
1086
+ let { runId: r, flowRef: i, input: a } = n, o = yield* x.tryPromise(() => e.store.query(D(j).where(w("id", r)).descriptor)).pipe(x.flatMap(S.decodeUnknown(S.Tuple(S.Struct({
1081
1087
  id: S.Literal(r),
1082
1088
  tenantId: S.NullOr(S.NonEmptyString),
1083
1089
  ownerId: S.optional(S.NullOr(S.String))
@@ -1090,14 +1096,14 @@ var Rt = (e, t = {}) => {
1090
1096
  runId: r,
1091
1097
  status: "failed"
1092
1098
  };
1093
- let { tenantId: s, ownerId: c = null } = o.right[0], l = yield* O({
1099
+ let { tenantId: s, ownerId: c = null } = o.right[0], l = yield* k({
1094
1100
  name: "flow-0-resolve",
1095
1101
  input: { flowRef: i },
1096
1102
  success: S.Struct({
1097
1103
  ir: S.Unknown,
1098
1104
  error: S.optional(S.String)
1099
1105
  }),
1100
- execute: Zt(e, i).pipe(x.map((e) => ({ ir: e })), x.catchAll((e) => x.succeed({
1106
+ execute: Qt(e, i).pipe(x.map((e) => ({ ir: e })), x.catchAll((e) => x.succeed({
1101
1107
  ir: void 0,
1102
1108
  error: e.message
1103
1109
  })))
@@ -1110,19 +1116,19 @@ var Rt = (e, t = {}) => {
1110
1116
  runId: r,
1111
1117
  status: "failed"
1112
1118
  };
1113
- let u = l.ir, d = u.mode === "agentic" ? yield* on(e, t, r, u, a, c, s, i) : yield* $t(e, t, r, u, a, {
1119
+ let u = l.ir, d = u.mode === "agentic" ? yield* sn(e, t, r, u, a, c, s, i) : yield* en(e, t, r, u, a, {
1114
1120
  ownerId: c,
1115
1121
  tenantId: s,
1116
1122
  source: n.source
1117
1123
  });
1118
- return d.status === "succeeded" && u.chain && (yield* en(e, r, u, a, d.output ?? {}, n, t)), t.onEvent && (d.status === "succeeded" || d.status === "failed") && (yield* H(t.onEvent({
1124
+ return d.status === "succeeded" && u.chain && (yield* tn(e, r, u, a, d.output ?? {}, n, t)), t.onEvent && (d.status === "succeeded" || d.status === "failed") && (yield* H(t.onEvent({
1119
1125
  kind: d.status,
1120
1126
  runId: r,
1121
1127
  flowName: u.name,
1122
1128
  ownerId: c,
1123
1129
  source: n.source
1124
1130
  })).pipe(x.catchAllCause(() => x.void))), d;
1125
- }), cn = {
1131
+ }), ln = {
1126
1132
  text: (e) => ({
1127
1133
  type: "generate",
1128
1134
  modality: "text",
@@ -1149,17 +1155,17 @@ var Rt = (e, t = {}) => {
1149
1155
  type: "human",
1150
1156
  ...e
1151
1157
  })
1152
- }, ln = (e) => e.map((e, t) => "id" in e && e.id ? e : {
1158
+ }, un = (e) => e.map((e, t) => "id" in e && e.id ? e : {
1153
1159
  id: `step-${t}`,
1154
1160
  ...e
1155
- }), un = (e) => {
1156
- let t = [], n = I(e.steps);
1157
- for (let e of Dt(n)) t.push(`group "${e}" is not contiguous — only CONSECUTIVE steps sharing a group run concurrently, so this would execute as two separate fan-outs`);
1161
+ }), dn = (e) => {
1162
+ let t = [], n = L(e.steps);
1163
+ for (let e of Et(n)) t.push(`group "${e}" is not contiguous — only CONSECUTIVE steps sharing a group run concurrently, so this would execute as two separate fan-outs`);
1158
1164
  let r = new Set(e.brief.map((e) => e.key));
1159
1165
  for (let e of n) {
1160
1166
  for (let { step: n } of e.steps) {
1161
1167
  n.type === "human" && n.group !== void 0 && t.push(`step "${n.id}" is a human review inside group "${n.group}" — a review SUSPENDS the whole run, which one branch of a fan-out cannot do`);
1162
- for (let i of P(n.prompt ?? "")) r.has(i) || t.push(e.steps.length > 1 ? `step "${n.id}" references {{${i}}} which is produced inside its OWN group "${n.group}" or does not exist — grouped steps run concurrently, so they cannot read each other` : `step "${n.id}" references {{${i}}} which is not a brief field or a prior step outputKey`);
1168
+ for (let i of F(n.prompt ?? "")) r.has(i) || t.push(e.steps.length > 1 ? `step "${n.id}" references {{${i}}} which is produced inside its OWN group "${n.group}" or does not exist — grouped steps run concurrently, so they cannot read each other` : `step "${n.id}" references {{${i}}} which is not a brief field or a prior step outputKey`);
1163
1169
  for (let [e, i] of Object.entries(n.mediaInputs ?? {})) i.from === "step" && !r.has(i.ref) && t.push(`step "${n.id}" media input "${e}" references "${i.ref}" which is not a brief field or an earlier segment's outputKey`);
1164
1170
  n.when !== void 0 && !r.has(n.when.ref) && t.push(`step "${n.id}" has a when-condition on {{${n.when.ref}}} which is not a brief field or a prior step outputKey — it would never run`);
1165
1171
  }
@@ -1170,11 +1176,11 @@ var Rt = (e, t = {}) => {
1170
1176
  message: `flow "${e.name}" has ${t.length} problem(s)`,
1171
1177
  issues: t
1172
1178
  });
1173
- }, dn = (e) => {
1179
+ }, fn = (e) => {
1174
1180
  let t = d({
1175
1181
  name: e.name,
1176
1182
  mode: e.mode,
1177
- steps: ln(e.steps),
1183
+ steps: un(e.steps),
1178
1184
  maxSteps: e.maxSteps,
1179
1185
  brief: e.brief,
1180
1186
  orchestratorModel: e.orchestrator?.model,
@@ -1183,21 +1189,21 @@ var Rt = (e, t = {}) => {
1183
1189
  cadence: e.cadence,
1184
1190
  humanTimeoutMs: e.humanTimeoutMs
1185
1191
  });
1186
- return un(t), Ot(t), t;
1187
- }, fn = async (e, t, n) => {
1192
+ return dn(t), Dt(t), t;
1193
+ }, pn = async (e, t, n) => {
1188
1194
  let r = S.decodeUnknownSync(Le.pipe(S.filter((e) => e.workflowName === "flow.run" && e.id.length > 0)))(n);
1189
- if (await e.store.update(A.tableName, t, { workflowStart: r }) === null) throw Error("flow start receipt could not be recorded; workflow submission may have succeeded");
1195
+ if (await e.store.update(j.tableName, t, { workflowStart: r }) === null) throw Error("flow start receipt could not be recorded; workflow submission may have succeeded");
1190
1196
  return r;
1191
- }, pn = (e, t, n) => {
1197
+ }, mn = (e, t, n) => {
1192
1198
  if (!Number.isFinite(t.getTime())) throw Error("cadence timestamp must be valid");
1193
- return `cron-${ct("sha256").update(JSON.stringify([
1199
+ return `cron-${st("sha256").update(JSON.stringify([
1194
1200
  n,
1195
1201
  e,
1196
1202
  Math.floor(t.getTime() / 6e4)
1197
1203
  ])).digest("hex")}`;
1198
- }, mn = async (e) => {
1204
+ }, hn = async (e) => {
1199
1205
  let t = [];
1200
- for (let n of At()) n.cadence && (n.cadence.repeats?.length ?? 0) > 0 && t.push({
1206
+ for (let n of kt()) n.cadence && (n.cadence.repeats?.length ?? 0) > 0 && t.push({
1201
1207
  tenantId: e.request.subject.tenantId,
1202
1208
  flowRef: n.name,
1203
1209
  cadence: n.cadence,
@@ -1211,8 +1217,8 @@ var Rt = (e, t = {}) => {
1211
1217
  defaultInput: r.cadence.defaultInput ?? {}
1212
1218
  });
1213
1219
  return t;
1214
- }, hn = async (e, t = /* @__PURE__ */ new Date()) => {
1215
- let r = [], i = 0, a = [], o = e.workflows ? await ft(e) : {
1220
+ }, gn = async (e, t = /* @__PURE__ */ new Date()) => {
1221
+ let r = [], i = 0, a = [], o = e.workflows ? await dt(e) : {
1216
1222
  examined: 0,
1217
1223
  accepted: 0,
1218
1224
  notExecuted: 0,
@@ -1220,11 +1226,11 @@ var Rt = (e, t = {}) => {
1220
1226
  failures: []
1221
1227
  };
1222
1228
  a.push(...o.failures.map((e) => Error(`flow run ${e.runId}: start reconciliation failed`, { cause: e.cause })));
1223
- let s = await mn(e);
1229
+ let s = await hn(e);
1224
1230
  for (let o of s) {
1225
1231
  if (!Pe(o.cadence, t)) continue;
1226
1232
  i += 1;
1227
- let s = pn(o.flowRef, t, o.tenantId), c = `run-${s}`;
1233
+ let s = mn(o.flowRef, t, o.tenantId), c = `run-${s}`;
1228
1234
  try {
1229
1235
  if (!e.workflows) throw Error("workflow runtime unavailable; no cadence start was submitted");
1230
1236
  (await e.transaction(async (e) => {
@@ -1245,7 +1251,7 @@ var Rt = (e, t = {}) => {
1245
1251
  ...r,
1246
1252
  runId: r.id
1247
1253
  });
1248
- return fn(e, c, await t.start("flow.run", i));
1254
+ return pn(e, c, await t.start("flow.run", i));
1249
1255
  }, o.tenantId === null ? void 0 : { tenantId: o.tenantId })).status === "running" && r.push(s);
1250
1256
  } catch (e) {
1251
1257
  a.push(e);
@@ -1257,42 +1263,42 @@ var Rt = (e, t = {}) => {
1257
1263
  started: r,
1258
1264
  reconciled: o
1259
1265
  };
1260
- }, Y = (e) => S.optionalWith(e, { exact: !0 }), gn = S.Int.pipe(S.positive(), S.lessThanOrEqualTo(2 ** 53 - 1)), _n = S.Int.pipe(S.between(-(2 ** 53 - 1), 2 ** 53 - 1)), vn = S.TemplateLiteral(S.Number, "x", S.Number).pipe(S.pattern(/^[1-9]\d*x[1-9]\d*$/)), yn = S.TemplateLiteral(S.Number, ":", S.Number).pipe(S.pattern(/^[1-9]\d*:[1-9]\d*$/)), bn = S.Struct({
1261
- n: Y(gn),
1262
- seed: Y(_n),
1263
- size: Y(vn),
1264
- aspectRatio: Y(yn),
1265
- providerOptions: Y(z)
1266
- }), xn = S.Struct({
1266
+ }, Y = (e) => S.optionalWith(e, { exact: !0 }), _n = S.Int.pipe(S.positive(), S.lessThanOrEqualTo(2 ** 53 - 1)), vn = S.Int.pipe(S.between(-(2 ** 53 - 1), 2 ** 53 - 1)), yn = S.TemplateLiteral(S.Number, "x", S.Number).pipe(S.pattern(/^[1-9]\d*x[1-9]\d*$/)), bn = S.TemplateLiteral(S.Number, ":", S.Number).pipe(S.pattern(/^[1-9]\d*:[1-9]\d*$/)), xn = S.Struct({
1267
+ n: Y(_n),
1268
+ seed: Y(vn),
1269
+ size: Y(yn),
1270
+ aspectRatio: Y(bn),
1271
+ providerOptions: Y(B)
1272
+ }), Sn = S.Struct({
1267
1273
  voice: Y(S.NonEmptyString),
1268
1274
  outputFormat: Y(S.NonEmptyString),
1269
1275
  instructions: Y(S.String),
1270
1276
  speed: Y(S.Finite.pipe(S.positive())),
1271
1277
  language: Y(S.NonEmptyString),
1272
- providerOptions: Y(z)
1273
- }), Sn = S.Struct({
1274
- aspectRatio: Y(yn),
1278
+ providerOptions: Y(B)
1279
+ }), Cn = S.Struct({
1280
+ aspectRatio: Y(bn),
1275
1281
  durationSeconds: Y(S.Finite.pipe(S.positive())),
1276
- resolution: Y(vn),
1282
+ resolution: Y(yn),
1277
1283
  fps: Y(S.Finite.pipe(S.positive())),
1278
- seed: Y(_n),
1284
+ seed: Y(vn),
1279
1285
  generateAudio: Y(S.Boolean),
1280
- maxInlineBytes: Y(gn),
1281
- providerOptions: Y(z)
1282
- }), Cn = (e, t, n) => x.try({
1286
+ maxInlineBytes: Y(_n),
1287
+ providerOptions: Y(B)
1288
+ }), wn = (e, t, n) => x.try({
1283
1289
  try: () => S.decodeUnknownSync(e, { onExcessProperty: "error" })(t === void 0 ? {} : t),
1284
1290
  catch: () => `invalid ${n} media params: check the built-in adapter's supported options and value ranges`
1285
- }), wn = (e) => Cn(bn, e, "image"), Tn = (e) => Cn(xn, e, "audio"), En = (e) => Cn(Sn, e, "video"), Dn = (e) => ({
1291
+ }), Tn = (e) => wn(xn, e, "image"), En = (e) => wn(Sn, e, "audio"), Dn = (e) => wn(Cn, e, "video"), On = (e) => ({
1286
1292
  name: "gateway",
1287
1293
  model: e
1288
- }), On = (e) => Math.round(e * 1e6), X = (e, t, n) => {
1289
- let r = $e(t);
1294
+ }), kn = (e) => Math.round(e * 1e6), X = (e, t, n) => {
1295
+ let r = Qe(t);
1290
1296
  if (typeof r == "number") return {
1291
- costMicroUsd: On(r),
1297
+ costMicroUsd: kn(r),
1292
1298
  costSource: "gateway"
1293
1299
  };
1294
1300
  if (e) {
1295
- let t = Qe(e, { model: n ?? "unknown" });
1301
+ let t = Ze(e, { model: n ?? "unknown" });
1296
1302
  return {
1297
1303
  costMicroUsd: t.costMicroUsd ?? 0,
1298
1304
  costSource: t.costSource ?? "unpriced"
@@ -1304,7 +1310,7 @@ var Rt = (e, t = {}) => {
1304
1310
  };
1305
1311
  }, Z = (e) => {
1306
1312
  if (e === void 0) return { status: "unreported" };
1307
- let [t, n, r] = st(e) ? [
1313
+ let [t, n, r] = ot(e) ? [
1308
1314
  e.unit,
1309
1315
  e.input,
1310
1316
  e.output
@@ -1322,18 +1328,18 @@ var Rt = (e, t = {}) => {
1322
1328
  }, Q = (e, t, n) => ({
1323
1329
  ...X(e, t, n),
1324
1330
  usage: Z(e)
1325
- }), kn = (e, t) => (n) => {
1326
- let r = n.model, i = (e) => t?.resolveModel?.(e) ?? Dn(e);
1331
+ }), An = (e, t) => (n) => {
1332
+ let r = n.model, i = (e) => t?.resolveModel?.(e) ?? On(e);
1327
1333
  return x.gen(function* () {
1328
1334
  let t = yield* zt(n.modality, n.inputs).pipe(x.mapError((e) => new y({
1329
1335
  capability: `media:${n.modality}`,
1330
1336
  message: e
1331
1337
  })));
1332
1338
  if (n.modality === "image") {
1333
- let a = yield* wn(n.params).pipe(x.mapError((e) => new y({
1339
+ let a = yield* Tn(n.params).pipe(x.mapError((e) => new y({
1334
1340
  capability: "media:image",
1335
1341
  message: e
1336
- }))), o = t.referenceImageUrl, s = t.maskImageUrl, c = yield* et({
1342
+ }))), o = t.referenceImageUrl, s = t.maskImageUrl, c = yield* $e({
1337
1343
  ...a,
1338
1344
  prompt: n.prompt,
1339
1345
  ...o === void 0 ? {} : { inputs: {
@@ -1372,10 +1378,10 @@ var Rt = (e, t = {}) => {
1372
1378
  };
1373
1379
  }
1374
1380
  if (n.modality === "audio") {
1375
- let t = yield* Tn(n.params).pipe(x.mapError((e) => new y({
1381
+ let t = yield* En(n.params).pipe(x.mapError((e) => new y({
1376
1382
  capability: "media:audio",
1377
1383
  message: e
1378
- }))), a = yield* it({
1384
+ }))), a = yield* rt({
1379
1385
  ...t,
1380
1386
  text: n.prompt,
1381
1387
  ...r ? { provider: i(r) } : {}
@@ -1399,10 +1405,10 @@ var Rt = (e, t = {}) => {
1399
1405
  usage: Z(a.usage)
1400
1406
  };
1401
1407
  }
1402
- let { maxInlineBytes: a, providerOptions: o, ...s } = yield* En(n.params).pipe(x.mapError((e) => new y({
1408
+ let { maxInlineBytes: a, providerOptions: o, ...s } = yield* Dn(n.params).pipe(x.mapError((e) => new y({
1403
1409
  capability: "media:video",
1404
1410
  message: e
1405
- }))), c = yield* ot({
1411
+ }))), c = yield* at({
1406
1412
  prompt: n.prompt,
1407
1413
  inputs: {
1408
1414
  ...t.referenceImageUrl === void 0 ? {} : { image: t.referenceImageUrl },
@@ -1452,22 +1458,22 @@ var Rt = (e, t = {}) => {
1452
1458
  capability: `media:${n.modality}`,
1453
1459
  message: String(e.message ?? e)
1454
1460
  }))));
1455
- }, An = () => globalThis.crypto?.randomUUID?.() ?? `req-${Date.now().toString(36)}`, jn = (e) => e.request?.subject?.id ?? null, $ = (e, t) => x.promise(() => e.store.query(E(A).where(C("id", t)).descriptor)).pipe(x.map((e) => e[0])), Mn = (e) => x.sync(() => {
1461
+ }, jn = () => globalThis.crypto?.randomUUID?.() ?? `req-${Date.now().toString(36)}`, Mn = (e) => e.request?.subject?.id ?? null, $ = (e, t) => x.promise(() => e.store.query(D(j).where(w("id", t)).descriptor)).pipe(x.map((e) => e[0])), Nn = (e) => x.sync(() => {
1456
1462
  let t = e.workflows;
1457
1463
  if (!t) throw Error("workflow runtime unavailable; no flow start was submitted");
1458
1464
  return t;
1459
- }), Nn = (t, n) => x.gen(function* () {
1460
- yield* Mn(t);
1461
- let r = yield* Zt(t, n.flowRef), i = n.input ?? {}, a = r.brief.filter((e) => e.required && e.type !== "boolean" && (i[e.key] === void 0 || i[e.key] === null || i[e.key] === "")).map((e) => e.key);
1465
+ }), Pn = (t, n) => x.gen(function* () {
1466
+ yield* Nn(t);
1467
+ let r = yield* Qt(t, n.flowRef), i = n.input ?? {}, a = r.brief.filter((e) => e.required && e.type !== "boolean" && (i[e.key] === void 0 || i[e.key] === null || i[e.key] === "")).map((e) => e.key);
1462
1468
  if (a.length > 0) return yield* x.fail(new De({
1463
1469
  missing: a,
1464
1470
  message: `missing required brief field(s): ${a.join(", ")}`
1465
1471
  }));
1466
- let o = An(), s = `run-${o}`, c = n.source ?? "manual";
1472
+ let o = jn(), s = `run-${o}`, c = n.source ?? "manual";
1467
1473
  return yield* x.promise(() => t.transaction(async (t) => {
1468
1474
  let a = t.workflows;
1469
1475
  if (!a) throw Error("workflow runtime unavailable in transaction; no flow start was submitted");
1470
- await t.store.insert(A.tableName, {
1476
+ await t.store.insert(j.tableName, {
1471
1477
  id: s,
1472
1478
  flowRef: n.flowRef,
1473
1479
  flowName: r.name,
@@ -1476,9 +1482,9 @@ var Rt = (e, t = {}) => {
1476
1482
  source: c,
1477
1483
  requestId: o,
1478
1484
  input: i,
1479
- ownerId: jn(t)
1485
+ ownerId: Mn(t)
1480
1486
  });
1481
- let l = await fn(t, s, await a.start(e, {
1487
+ let l = await pn(t, s, await a.start(e, {
1482
1488
  runId: s,
1483
1489
  flowRef: n.flowRef,
1484
1490
  input: i,
@@ -1491,12 +1497,12 @@ var Rt = (e, t = {}) => {
1491
1497
  admission: l
1492
1498
  });
1493
1499
  }));
1494
- }), Pn = (t, r) => x.gen(function* () {
1495
- return yield* Mn(t), yield* x.tryPromise({
1500
+ }), Fn = (t, r) => x.gen(function* () {
1501
+ return yield* Nn(t), yield* x.tryPromise({
1496
1502
  try: () => t.transaction(async (t) => {
1497
1503
  let i = t.workflows;
1498
1504
  if (!i) throw Error("workflow runtime unavailable in transaction; no flow start was submitted");
1499
- let a = (await t.store.query(E(A).where(C("id", r.runId)).descriptor))[0];
1505
+ let a = (await t.store.query(D(j).where(w("id", r.runId)).descriptor))[0];
1500
1506
  if (!a) throw new b({
1501
1507
  runId: r.runId,
1502
1508
  message: "run not found"
@@ -1508,7 +1514,7 @@ var Rt = (e, t = {}) => {
1508
1514
  runId: a.id
1509
1515
  });
1510
1516
  if (s._tag === "Left") throw Error("stored workflow payload is incomplete or invalid; retry refused without changing the run");
1511
- let c = await fn(t, r.runId, await i.start(e, s.right));
1517
+ let c = await pn(t, r.runId, await i.start(e, s.right));
1512
1518
  return ce.make({
1513
1519
  runId: r.runId,
1514
1520
  requestId: o,
@@ -1517,24 +1523,23 @@ var Rt = (e, t = {}) => {
1517
1523
  }),
1518
1524
  catch: (e) => e
1519
1525
  }).pipe(x.catchAll((e) => e instanceof b ? x.fail(e) : x.die(e)));
1520
- }), Fn = (t, r) => x.gen(function* () {
1526
+ }), In = (t, r) => x.gen(function* () {
1521
1527
  let i = yield* $(t, r.runId);
1522
1528
  if (!i) return yield* x.fail(new b({
1523
1529
  runId: r.runId,
1524
1530
  message: "run not found"
1525
1531
  }));
1526
- if (i.status === "succeeded" || i.status === "failed") return v.make({
1532
+ if (Ln(i.status)) return v.make({
1527
1533
  runId: r.runId,
1528
1534
  status: i.status,
1529
1535
  engine: "not-requested",
1530
1536
  control: null
1531
1537
  });
1532
1538
  let a = (/* @__PURE__ */ new Date()).toISOString();
1533
- yield* x.promise(() => t.store.updateMany(A.tableName, {
1534
- status: "cancelled",
1535
- cancelledAt: a,
1536
- completedAt: a
1537
- }, { where: Be(C("id", r.runId), Ue("status", [
1539
+ yield* x.promise(() => t.store.updateMany(j.tableName, {
1540
+ status: "cancelling",
1541
+ cancelledAt: a
1542
+ }, { where: C(w("id", r.runId), He("status", [
1538
1543
  "pending",
1539
1544
  "running",
1540
1545
  "waiting"
@@ -1544,7 +1549,7 @@ var Rt = (e, t = {}) => {
1544
1549
  runId: r.runId,
1545
1550
  message: "run not found"
1546
1551
  }));
1547
- if (o.status === "succeeded" || o.status === "failed") return v.make({
1552
+ if (Ln(o.status)) return v.make({
1548
1553
  runId: r.runId,
1549
1554
  status: o.status,
1550
1555
  engine: "not-requested",
@@ -1566,29 +1571,34 @@ var Rt = (e, t = {}) => {
1566
1571
  let n = S.decodeUnknownSync(Ie)(await s.cancel(e, t));
1567
1572
  if (n.operation !== "cancel" || n.snapshot.workflowName !== "flow.run" || n.snapshot.executionId !== t) throw Error("workflow cancellation receipt does not match the flow execution");
1568
1573
  return n;
1569
- })).pipe(x.catchAll(() => x.succeed(null))), u = l === null ? s === void 0 || c._tag === "None" ? "unreachable" : "unknown" : l.snapshot.status === "cancelled" && (l.kind === "confirmed" || l.kind === "already-terminal") ? "cancelled" : l.kind === "accepted" ? "accepted" : l.kind === "already-terminal" ? "already-terminal" : "unknown";
1570
- if (l?.kind === "already-terminal" && l.snapshot.status !== "cancelled") {
1574
+ })).pipe(x.catchAll(() => x.succeed(null))), u = l === null ? s === void 0 || c._tag === "None" ? "unreachable" : "unknown" : l.snapshot.status === "cancelled" && (l.kind === "confirmed" || l.kind === "already-terminal") ? "cancelled" : l.kind === "accepted" ? "accepted" : l.kind === "already-terminal" ? "already-terminal" : "unknown", d = C(w("id", r.runId), w("status", "cancelling"), w("cancelledAt", o.cancelledAt));
1575
+ if (u === "cancelled") yield* x.promise(() => t.store.updateMany(j.tableName, {
1576
+ status: "cancelled",
1577
+ completedAt: o.completedAt ?? (/* @__PURE__ */ new Date()).toISOString()
1578
+ }, { where: d }));
1579
+ else if (l?.kind === "already-terminal") {
1571
1580
  let e = S.decodeUnknownOption(n.successSchema)(l.snapshot.output), i = l.snapshot.status === "failed" ? "failed" : e._tag === "Some" && e.value.runId === r.runId && e.value.status !== "waiting" ? e.value.status : void 0;
1572
- i !== void 0 && (yield* x.promise(() => t.store.updateMany(A.tableName, {
1581
+ i !== void 0 && (yield* x.promise(() => t.store.updateMany(j.tableName, {
1573
1582
  status: i,
1583
+ completedAt: o.completedAt ?? (/* @__PURE__ */ new Date()).toISOString(),
1574
1584
  ...i === "cancelled" ? {} : { cancelledAt: null }
1575
- }, { where: Be(C("id", r.runId), C("status", "cancelled"), C("cancelledAt", o.cancelledAt)) })));
1585
+ }, { where: d })));
1576
1586
  }
1577
- let d = yield* $(t, r.runId);
1578
- return d ? yield* S.decodeUnknown(v)({
1587
+ let f = yield* $(t, r.runId);
1588
+ return f ? yield* S.decodeUnknown(v)({
1579
1589
  runId: r.runId,
1580
- status: d.status,
1590
+ status: f.status,
1581
1591
  engine: u,
1582
1592
  control: l
1583
1593
  }).pipe(x.orDie) : yield* x.fail(new b({
1584
1594
  runId: r.runId,
1585
1595
  message: "run not found"
1586
1596
  }));
1587
- }), In = (e) => {
1597
+ }), Ln = (e) => e === "succeeded" || e === "failed" || e === "cancelled", Rn = (e) => {
1588
1598
  let t = e.steps?.filter((e) => e.status === "waiting"), n = t?.[0];
1589
1599
  if (t?.length !== 1 || n?.type !== "human" || !Number.isSafeInteger(n.id) || n.id < 0) throw Error("expected exactly one waiting human step with a nonnegative integer index");
1590
1600
  return n.id;
1591
- }, Ln = (t, i) => x.gen(function* () {
1601
+ }, zn = (t, i) => x.gen(function* () {
1592
1602
  let a = (e, t) => new je({
1593
1603
  runId: i.runId,
1594
1604
  reason: e,
@@ -1609,7 +1619,7 @@ var Rt = (e, t = {}) => {
1609
1619
  message: `run is "${l}", not awaiting a response`
1610
1620
  }));
1611
1621
  let u = yield* x.try({
1612
- try: () => In(c),
1622
+ try: () => Rn(c),
1613
1623
  catch: () => a("invalid-run", "stored run has no unambiguous waiting review")
1614
1624
  });
1615
1625
  if (u !== o.stepIndex) return yield* x.fail(new ke({
@@ -1646,22 +1656,22 @@ var Rt = (e, t = {}) => {
1646
1656
  eventId: h.eventId,
1647
1657
  status: "accepted"
1648
1658
  }).pipe(x.mapError(() => a("delivery-unknown", "workflow runtime returned no valid review delivery receipt")));
1649
- }), Rn = (e, t) => x.promise(() => e.store.query(E(k).where(C("id", t.id)).descriptor)).pipe(x.map((e) => e[0])), zn = (e) => x.promise(() => e.store.query(E(k).descriptor)), Bn = (e, t) => x.promise(() => e.store.insert(k.tableName, {
1650
- id: t.id ?? `flow-${An()}`,
1659
+ }), Bn = (e, t) => x.promise(() => e.store.query(D(A).where(w("id", t.id)).descriptor)).pipe(x.map((e) => e[0])), Vn = (e) => x.promise(() => e.store.query(D(A).descriptor)), Hn = (e, t) => x.promise(() => e.store.insert(A.tableName, {
1660
+ id: t.id ?? `flow-${jn()}`,
1651
1661
  ...t
1652
- })), Vn = (e, t) => x.promise(() => e.store.update(k.tableName, t.id, t.patch)), Hn = (e, t) => x.promise(() => e.store.delete(k.tableName, t.id)), Un = "aiFlows", Wn = (e = {}) => {
1662
+ })), Un = (e, t) => x.promise(() => e.store.update(A.tableName, t.id, t.patch)), Wn = (e, t) => x.promise(() => e.store.delete(A.tableName, t.id)), Gn = "aiFlows", Kn = (e = {}) => {
1653
1663
  let t = ze({
1654
- base: Un,
1664
+ base: Gn,
1655
1665
  alias: e.alias
1656
1666
  });
1657
- yt(e.humanReviewTimeoutMs === void 0 ? {} : { humanReviewTimeoutMs: e.humanReviewTimeoutMs }), We({
1667
+ vt(e.humanReviewTimeoutMs === void 0 ? {} : { humanReviewTimeoutMs: e.humanReviewTimeoutMs }), Ue({
1658
1668
  source: "plugin",
1659
- table: A.tableName,
1669
+ table: j.tableName,
1660
1670
  timeColumn: "createdAt",
1661
- ttlMs: e.runsTtlMs ?? xt(process.env.VOLTRO_AI_FLOW_RUNS_TTL_HOURS, 2160),
1662
- envVar: gt,
1671
+ ttlMs: e.runsTtlMs ?? bt(process.env.VOLTRO_AI_FLOW_RUNS_TTL_HOURS, 2160),
1672
+ envVar: ht,
1663
1673
  label: "ai flow runs",
1664
- where: Ue("status", [
1674
+ where: He("status", [
1665
1675
  "succeeded",
1666
1676
  "failed",
1667
1677
  "cancelled"
@@ -1679,7 +1689,7 @@ var Rt = (e, t = {}) => {
1679
1689
  if (!o) return a(503, "store not bound yet");
1680
1690
  let s = await o.query({
1681
1691
  table: e,
1682
- predicate: n === void 0 ? void 0 : C("id", n),
1692
+ predicate: n === void 0 ? void 0 : w("id", n),
1683
1693
  order: [{
1684
1694
  column: "createdAt",
1685
1695
  direction: "desc"
@@ -1727,14 +1737,14 @@ var Rt = (e, t = {}) => {
1727
1737
  }];
1728
1738
  return Re({
1729
1739
  name: t,
1730
- baseName: Un,
1740
+ baseName: Gn,
1731
1741
  description: "AI Flows — durable multi-step AI pipelines (deterministic + agentic) with human-in-the-loop, chaining, and cadence. Code-first (defineFlow) or data-driven.",
1732
1742
  permissions: [
1733
1743
  "store:write",
1734
1744
  "inspect:read",
1735
1745
  "store:changes:read"
1736
1746
  ],
1737
- ...e.tables === !1 ? {} : { extendSchema: { tables: lt } },
1747
+ ...e.tables === !1 ? {} : { extendSchema: { tables: ct } },
1738
1748
  inspectEndpoints: c,
1739
1749
  bindDataStore: (e) => {
1740
1750
  r.current = e;
@@ -1747,20 +1757,20 @@ var Rt = (e, t = {}) => {
1747
1757
  if (n === void 0) return;
1748
1758
  let i = t.payload, a = (typeof i == "string" ? JSON.parse(i) : i)?.runId;
1749
1759
  if (typeof a != "string") return;
1750
- let o = (yield* x.promise(() => n.query(E(A).where(C("id", a)).descriptor)))[0];
1760
+ let o = (yield* x.promise(() => n.query(D(j).where(w("id", a)).descriptor)))[0];
1751
1761
  if (o === void 0) return;
1752
1762
  let s = o.status, c = t.executionId, l = o.workflowStart;
1753
- s === "pending" && l?.status === "queued" && typeof c == "string" && c.length > 0 && (yield* x.promise(() => n.update(A.tableName, a, { workflowStart: j(c) })));
1763
+ s === "pending" && l?.status === "queued" && typeof c == "string" && c.length > 0 && (yield* x.promise(() => n.update(j.tableName, a, { workflowStart: M(c) })));
1754
1764
  let u = e.old?.status === "cancelled";
1755
1765
  if (e.op !== "update" || t.status !== "cancelled" || u || s === "cancelled" || s === "succeeded" || s === "failed") return;
1756
- let d = (/* @__PURE__ */ new Date()).toISOString();
1757
- yield* x.promise(() => n.update(A.tableName, a, {
1766
+ let d = (/* @__PURE__ */ new Date()).toISOString(), f = typeof o.cancelledAt == "string" ? o.cancelledAt : d;
1767
+ yield* x.promise(() => n.update(j.tableName, a, {
1758
1768
  status: "cancelled",
1759
- cancelledAt: d,
1769
+ cancelledAt: f,
1760
1770
  completedAt: d
1761
1771
  }));
1762
1772
  }).pipe(x.catchAllCause(() => x.void))
1763
1773
  });
1764
1774
  };
1765
1775
  //#endregion
1766
- export { be as BriefField, ge as ChainPending, g as ConditionOp, ve as CostCompleteness, _ as CostSource, gt as FLOW_RUNS_TTL_ENV, ht as FLOW_RUNS_TTL_HOURS_DEFAULT, e as FLOW_RUN_WORKFLOW, ae as FlowCadence, v as FlowCancelReceipt, ye as FlowChain, se as FlowMode, me as FlowReviewInput, xe as FlowReviewReceipt, ce as FlowStartReceipt, le as FlowStatus, _e as FlowStep, t as HUMAN_RESPONSE_SIGNAL_PREFIX, mt as HUMAN_REVIEW_TIMEOUT_ENV, pt as HUMAN_REVIEW_TIMEOUT_HOURS_DEFAULT, he as HumanResponse, de as Json, _t as MAX_CHAIN_DEPTH_DEFAULT, vt as MAX_CHAIN_DEPTH_ENV, ue as MAX_STEPS_DEFAULT, ie as MAX_STEPS_MAX, Se as MAX_STEPS_MIN, Te as MediaArtifact, oe as MediaArtifacts, we as MediaInputSlot, te as MediaInputs, o as MediaReceipt, Ce as Modality, ne as ReviewMode, c as ReviewOption, s as RunReview, h as RunSource, pe as RunStatus, i as RunStep, fe as RunStepStatus, Ee as StepCondition, p as StepType, m as StepUsage, ee as Visibility, j as admittedStartHandle, A as aiFlowRunsTable, Wn as aiFlowsPlugin, k as aiFlowsTable, lt as aiFlowsTables, sn as buildFlowRunExecute, Pe as cadenceMatches, Fn as cancelFlow, l as clampMaxSteps, jt as clearRegistry, P as collectRefs, Bn as createFlow, pn as cronRequestId, dn as defineFlow, Hn as deleteFlow, a as describeCondition, re as evaluateCondition, I as flowSegments, cn as flowStep, N as getAiFlowsDefaults, Rn as getFlow, kt as getRegisteredFlow, r as humanResponseSignalName, F as interpolate, u as isTruthy, Nn as launchFlow, zn as listFlows, At as listRegisteredFlows, kn as makeMediaGenerator, Ne as nextRuns, Dt as nonContiguousGroups, d as normalizeFlow, ft as reconcileFlowStarts, Ot as registerFlow, bt as resetAiFlowsDefaults, Ct as resolveHumanReviewTimeoutMs, Zt as resolveIr, wt as resolveMaxChainDepth, Ln as respondToFlow, Pn as retryFlow, hn as runCadenceTick, f as sanitizeOutputKey, yt as setAiFlowsDefaults, Et as unresolvedRefs, Vn as updateFlow, un as validateFlow, In as waitingStepIndex };
1776
+ export { be as BriefField, ge as ChainPending, g as ConditionOp, ve as CostCompleteness, _ as CostSource, ht as FLOW_RUNS_TTL_ENV, mt as FLOW_RUNS_TTL_HOURS_DEFAULT, e as FLOW_RUN_WORKFLOW, ae as FlowCadence, v as FlowCancelReceipt, ye as FlowChain, se as FlowMode, me as FlowReviewInput, xe as FlowReviewReceipt, ce as FlowStartReceipt, le as FlowStatus, _e as FlowStep, t as HUMAN_RESPONSE_SIGNAL_PREFIX, pt as HUMAN_REVIEW_TIMEOUT_ENV, ft as HUMAN_REVIEW_TIMEOUT_HOURS_DEFAULT, he as HumanResponse, de as Json, gt as MAX_CHAIN_DEPTH_DEFAULT, _t as MAX_CHAIN_DEPTH_ENV, ue as MAX_STEPS_DEFAULT, ie as MAX_STEPS_MAX, Se as MAX_STEPS_MIN, Te as MediaArtifact, oe as MediaArtifacts, we as MediaInputSlot, te as MediaInputs, o as MediaReceipt, Ce as Modality, ne as ReviewMode, c as ReviewOption, s as RunReview, h as RunSource, pe as RunStatus, i as RunStep, fe as RunStepStatus, Ee as StepCondition, p as StepType, m as StepUsage, ee as Visibility, M as admittedStartHandle, j as aiFlowRunsTable, Kn as aiFlowsPlugin, A as aiFlowsTable, ct as aiFlowsTables, cn as buildFlowRunExecute, Pe as cadenceMatches, In as cancelFlow, l as clampMaxSteps, At as clearRegistry, F as collectRefs, Hn as createFlow, mn as cronRequestId, fn as defineFlow, Wn as deleteFlow, a as describeCondition, re as evaluateCondition, L as flowSegments, ln as flowStep, P as getAiFlowsDefaults, Bn as getFlow, Ot as getRegisteredFlow, r as humanResponseSignalName, I as interpolate, u as isTruthy, Pn as launchFlow, Vn as listFlows, kt as listRegisteredFlows, An as makeMediaGenerator, Ne as nextRuns, Et as nonContiguousGroups, d as normalizeFlow, dt as reconcileFlowStarts, Dt as registerFlow, yt as resetAiFlowsDefaults, St as resolveHumanReviewTimeoutMs, Qt as resolveIr, Ct as resolveMaxChainDepth, zn as respondToFlow, Fn as retryFlow, gn as runCadenceTick, f as sanitizeOutputKey, vt as setAiFlowsDefaults, Tt as unresolvedRefs, Un as updateFlow, dn as validateFlow, Rn as waitingStepIndex };