@voltro/plugin-ai-flows 0.38.0 → 0.39.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,91 +1,91 @@
1
- import { A as e, C as t, D as n, E as r, M as i, O as a, S as o, T as s, _ as c, a as l, b as u, c as d, d as f, f as p, g as m, h, i as g, j as _, k as ee, l as te, m as ne, n as re, o as ie, p as ae, r as oe, s as se, t as ce, u as le, v as ue, w as de, x as fe, y as pe } from "./ir-BOv5uwYI.js";
2
- import { FLOW_RUN_WORKFLOW as v, HUMAN_RESPONSE_SIGNAL_PREFIX as me, humanResponseSignalName as y } from "./workflow.js";
3
- import { FlowBriefIncomplete as he, FlowCapabilityMissing as b, FlowDependencyError as ge, FlowNotAwaitingResponse as _e, FlowNotFound as ve, FlowRunNotFound as x, FlowValidationError as ye } from "./errors.js";
4
- import { n as be, t as xe } from "./cadence-Bt6dPelT.js";
5
- import { Cause as Se, Effect as S, Schema as C } from "effect";
6
- import { definePlugin as Ce, pluginInstanceName as we } from "@voltro/protocol";
7
- import { boolean as Te, eq as w, id as Ee, inSet as De, integer as T, json as E, queryFor as D, registerRetention as Oe, table as ke, text as O, timestamp as k } from "@voltro/database";
8
- import { tenant as Ae } from "@voltro/plugin-multitenancy/mixin";
9
- import { audit as je } from "@voltro/plugin-audit/mixin";
10
- import { softDelete as Me } from "@voltro/plugin-soft-delete/mixin";
11
- import { awaitSignalSuspending as Ne, step as A } from "@voltro/workflow";
12
- import { defineTool as j, estimateCostUsd as Pe, gatewayCostUsd as Fe, generateImage as Ie, generateObject as Le, generateObjectWithTools as Re, generateSpeech as ze, generateText as M, generateVideo as Be } from "@voltro/ai";
1
+ import { A as e, C as t, D as n, E as r, M as i, O as a, S as o, T as s, _ as c, a as l, b as u, c as d, d as f, f as p, g as m, h, i as ee, j as g, k as te, l as ne, m as re, n as ie, o as ae, p as oe, r as se, s as ce, t as le, u as ue, v as de, w as fe, x as pe, y as me } from "./ir-BOv5uwYI.js";
2
+ import { FLOW_RUN_WORKFLOW as _, HUMAN_RESPONSE_SIGNAL_PREFIX as he, humanResponseSignalName as v } from "./workflow.js";
3
+ import { FlowBriefIncomplete as ge, FlowCapabilityMissing as y, FlowDependencyError as _e, FlowNotAwaitingResponse as ve, FlowNotFound as ye, FlowRunNotFound as b, FlowValidationError as be } from "./errors.js";
4
+ import { n as xe, t as Se } from "./cadence-_9Izk_fL.js";
5
+ import { Cause as Ce, Effect as x, Schema as S } from "effect";
6
+ import { definePlugin as we, pluginInstanceName as Te } from "@voltro/protocol";
7
+ import { boolean as Ee, eq as C, id as De, inSet as Oe, integer as w, json as T, queryFor as E, registerRetention as ke, table as Ae, text as D, timestamp as O } from "@voltro/database";
8
+ import { tenant as je } from "@voltro/plugin-multitenancy/mixin";
9
+ import { audit as Me } from "@voltro/plugin-audit/mixin";
10
+ import { softDelete as Ne } from "@voltro/plugin-soft-delete/mixin";
11
+ import { awaitSignalSuspending as Pe, step as k } from "@voltro/workflow";
12
+ import { defineTool as A, estimateCostUsd as Fe, gatewayCostUsd as Ie, generateImage as Le, generateObject as Re, generateObjectWithTools as ze, generateSpeech as Be, generateText as j, generateVideo as Ve } from "@voltro/ai";
13
13
  //#region src/table.ts
14
- var N = ke("_voltro_ai_flows", {
15
- id: Ee({ prefix: "aifl" }),
16
- name: O(),
17
- description: O().nullable(),
18
- mode: O().default("deterministic"),
19
- status: O().default("draft"),
20
- visibility: O().default("private"),
21
- orchestratorModel: O().nullable(),
22
- orchestratorInstructions: O().nullable(),
23
- maxSteps: T().default(30),
24
- steps: E().nullable(),
25
- inputSchema: E().nullable(),
26
- chainTo: E().nullable(),
27
- cadence: E().nullable(),
28
- humanTimeoutMs: T().nullable(),
29
- isEnabled: Te().default(!0),
30
- metadata: E().nullable(),
31
- icon: O().nullable(),
32
- color: O().nullable(),
33
- avatarUrl: O().nullable(),
34
- usageCount: T().default(0),
35
- ownerId: O().nullable()
36
- }).renamedFrom("ai_flows").with(Ae(), je(), Me()).index(["status"]).index(["visibility"]), P = ke("_voltro_ai_flow_runs", {
37
- id: Ee({ prefix: "aifr" }),
38
- flowRef: O(),
39
- flowName: O().nullable(),
40
- mode: O().default("deterministic"),
41
- status: O().default("pending"),
42
- source: O().nullable(),
43
- requestId: O(),
44
- input: E().nullable(),
45
- output: E().nullable(),
46
- steps: E().nullable(),
47
- currentStep: T().default(0),
48
- totalSteps: T().default(0),
49
- humanResponse: E().nullable(),
50
- chainPending: E().nullable(),
51
- chainRefusal: O().nullable(),
52
- costMicroUsd: T().default(0),
53
- durationMs: T().nullable(),
54
- error: O().nullable(),
55
- errorMessage: O().nullable(),
56
- startedAt: k().nullable(),
57
- completedAt: k().nullable(),
58
- cancelledAt: k().nullable(),
59
- sessionId: O().nullable(),
60
- sessionName: O().nullable(),
61
- ownerId: O().nullable(),
62
- metadata: E().nullable()
63
- }).renamedFrom("ai_flow_runs").with(Ae(), je()).index(["flowRef"]).index(["status"]).index(["requestId"]), Ve = [N, P], He = 168, Ue = "VOLTRO_AI_FLOW_HUMAN_REVIEW_TIMEOUT_HOURS", We = 2160, Ge = "VOLTRO_AI_FLOW_RUNS_TTL_HOURS", Ke = 5, qe = "VOLTRO_AI_FLOW_MAX_CHAIN_DEPTH", F = { current: {} }, Je = (e) => {
64
- F.current = e;
65
- }, I = () => F.current, Ye = () => {
66
- F.current = {};
67
- }, Xe = (e, t) => {
14
+ var M = Ae("_voltro_ai_flows", {
15
+ id: De({ prefix: "aifl" }),
16
+ name: D(),
17
+ description: D().nullable(),
18
+ mode: D().default("deterministic"),
19
+ status: D().default("draft"),
20
+ visibility: D().default("private"),
21
+ orchestratorModel: D().nullable(),
22
+ orchestratorInstructions: D().nullable(),
23
+ maxSteps: w().default(30),
24
+ steps: T().nullable(),
25
+ inputSchema: T().nullable(),
26
+ chainTo: T().nullable(),
27
+ cadence: T().nullable(),
28
+ humanTimeoutMs: w().nullable(),
29
+ isEnabled: Ee().default(!0),
30
+ metadata: T().nullable(),
31
+ icon: D().nullable(),
32
+ color: D().nullable(),
33
+ avatarUrl: D().nullable(),
34
+ usageCount: w().default(0),
35
+ ownerId: D().nullable()
36
+ }).renamedFrom("ai_flows").with(je(), Me(), Ne()).index(["status"]).index(["visibility"]), N = Ae("_voltro_ai_flow_runs", {
37
+ id: De({ prefix: "aifr" }),
38
+ flowRef: D(),
39
+ flowName: D().nullable(),
40
+ mode: D().default("deterministic"),
41
+ status: D().default("pending"),
42
+ source: D().nullable(),
43
+ requestId: D(),
44
+ input: T().nullable(),
45
+ output: T().nullable(),
46
+ steps: T().nullable(),
47
+ currentStep: w().default(0),
48
+ totalSteps: w().default(0),
49
+ humanResponse: T().nullable(),
50
+ chainPending: T().nullable(),
51
+ chainRefusal: D().nullable(),
52
+ costMicroUsd: w().default(0),
53
+ durationMs: w().nullable(),
54
+ error: D().nullable(),
55
+ errorMessage: D().nullable(),
56
+ startedAt: O().nullable(),
57
+ completedAt: O().nullable(),
58
+ cancelledAt: O().nullable(),
59
+ sessionId: D().nullable(),
60
+ sessionName: D().nullable(),
61
+ ownerId: D().nullable(),
62
+ metadata: T().nullable()
63
+ }).renamedFrom("ai_flow_runs").with(je(), Me()).index(["flowRef"]).index(["status"]).index(["requestId"]), He = [M, N], Ue = 168, We = "VOLTRO_AI_FLOW_HUMAN_REVIEW_TIMEOUT_HOURS", Ge = 2160, Ke = "VOLTRO_AI_FLOW_RUNS_TTL_HOURS", qe = 5, Je = "VOLTRO_AI_FLOW_MAX_CHAIN_DEPTH", P = { current: {} }, Ye = (e) => {
64
+ P.current = e;
65
+ }, F = () => P.current, Xe = () => {
66
+ P.current = {};
67
+ }, Ze = (e, t) => {
68
68
  if (e === void 0 || e.trim() === "") return t * 36e5;
69
69
  let n = Number(e);
70
70
  return !Number.isFinite(n) || n < 0 ? t * 36e5 : n * 36e5;
71
- }, Ze = (e) => Number.isFinite(e) && e > 0 ? e : Infinity, Qe = (e) => {
71
+ }, Qe = (e) => Number.isFinite(e) && e > 0 ? e : Infinity, $e = (e) => {
72
72
  let t = e.env ?? process.env;
73
- return Ze(e.step?.timeoutMs ?? e.flow?.humanTimeoutMs ?? e.deps?.humanReviewTimeoutMs ?? I().humanReviewTimeoutMs ?? Xe(t.VOLTRO_AI_FLOW_HUMAN_REVIEW_TIMEOUT_HOURS, 168));
74
- }, $e = (e) => {
75
- let t = e?.env ?? process.env, n = Number(t[qe]), r = e?.maxChainDepth ?? I().maxChainDepth ?? (Number.isFinite(n) && n >= 1 ? n : 5);
73
+ return Qe(e.step?.timeoutMs ?? e.flow?.humanTimeoutMs ?? e.deps?.humanReviewTimeoutMs ?? F().humanReviewTimeoutMs ?? Ze(t.VOLTRO_AI_FLOW_HUMAN_REVIEW_TIMEOUT_HOURS, 168));
74
+ }, et = (e) => {
75
+ let t = e?.env ?? process.env, n = Number(t[Je]), r = e?.maxChainDepth ?? F().maxChainDepth ?? (Number.isFinite(n) && n >= 1 ? n : 5);
76
76
  return Number.isFinite(r) && r >= 1 ? r : 5;
77
- }, et = /\{\{\s*([\w.-]+)\s*\}\}/g, L = (e) => {
77
+ }, tt = /\{\{\s*([\w.-]+)\s*\}\}/g, I = (e) => {
78
78
  let t = [];
79
- for (let n of e.matchAll(et)) t.push(n[1]);
79
+ for (let n of e.matchAll(tt)) t.push(n[1]);
80
80
  return t;
81
- }, R = (e, t) => e.replace(et, (e, n) => {
81
+ }, L = (e, t) => e.replace(tt, (e, n) => {
82
82
  let r = t[n];
83
83
  return r == null ? "" : typeof r == "string" ? r : JSON.stringify(r);
84
- }), tt = (e, t) => {
84
+ }), nt = (e, t) => {
85
85
  let n = /* @__PURE__ */ new Set();
86
- for (let r of L(e)) t[r] == null && !n.has(r) && n.add(r);
86
+ for (let r of I(e)) t[r] == null && !n.has(r) && n.add(r);
87
87
  return [...n];
88
- }, z = (e) => {
88
+ }, R = (e) => {
89
89
  let t = [], n;
90
90
  if (e.forEach((e, r) => {
91
91
  let i = e.group;
@@ -114,66 +114,66 @@ var N = ke("_voltro_ai_flows", {
114
114
  });
115
115
  }
116
116
  return t;
117
- }, nt = (e) => {
117
+ }, rt = (e) => {
118
118
  let t = /* @__PURE__ */ new Map();
119
119
  for (let n of e) n.group !== void 0 && t.set(n.group, (t.get(n.group) ?? 0) + 1);
120
120
  return [...t.entries()].filter(([, e]) => e > 1).map(([e]) => e).sort();
121
- }, B = /* @__PURE__ */ new Map(), rt = (e) => {
122
- B.set(e.name, e);
123
- }, it = (e) => B.get(e), at = () => [...B.values()], ot = () => B.clear(), V = (e) => typeof e == "object" && e && !Array.isArray(e) ? e : void 0, H = (e) => Array.isArray(e) ? e : void 0, st = (e) => {
121
+ }, z = /* @__PURE__ */ new Map(), it = (e) => {
122
+ z.set(e.name, e);
123
+ }, at = (e) => z.get(e), ot = () => [...z.values()], st = () => z.clear(), B = (e) => typeof e == "object" && e && !Array.isArray(e) ? e : void 0, V = (e) => Array.isArray(e) ? e : void 0, ct = (e) => {
124
124
  switch (e) {
125
- case "string": return C.String;
126
- case "number": return C.Number;
127
- case "integer": return C.Int;
128
- case "boolean": return C.Boolean;
129
- case "null": return C.Null;
130
- default: return C.Unknown;
125
+ case "string": return S.String;
126
+ case "number": return S.Number;
127
+ case "integer": return S.Int;
128
+ case "boolean": return S.Boolean;
129
+ case "null": return S.Null;
130
+ default: return S.Unknown;
131
131
  }
132
- }, U = (e, t) => {
132
+ }, H = (e, t) => {
133
133
  let n = typeof t.description == "string" ? t.description : void 0, r = typeof t.title == "string" ? t.title : void 0;
134
134
  return n === void 0 && r === void 0 ? e : e.annotations({
135
135
  ...n === void 0 ? {} : { description: n },
136
136
  ...r === void 0 ? {} : { title: r }
137
137
  });
138
- }, ct = (e) => e.length === 0 ? C.Unknown : e.length === 1 ? e[0] : C.Union(...e), lt = () => C.Record({
139
- key: C.String,
140
- value: C.Unknown
141
- }), W = (e) => {
142
- let t = V(e);
143
- if (t === void 0) return C.Unknown;
144
- if ("const" in t) return U(C.Literal(t.const), t);
145
- let n = H(t.enum);
146
- if (n !== void 0 && n.length > 0) return U(C.Literal(...n), t);
147
- let r = H(t.anyOf) ?? H(t.oneOf);
148
- if (r !== void 0) return U(ct(r.map(W)), t);
149
- let i = t.type, a = typeof i == "string" ? [i] : H(i)?.filter((e) => typeof e == "string") ?? [], o = t.nullable === !0 || a.includes("null"), s = a.find((e) => e !== "null"), c = s === "object" || s === void 0 && t.properties !== void 0 ? ut(t) : s === "array" || s === void 0 && t.items !== void 0 ? C.Array(W(t.items)) : s === void 0 ? C.Unknown : st(s);
150
- return U(o ? C.NullOr(c) : c, t);
151
- }, ut = (e) => {
152
- let t = V(e.properties);
153
- if (t === void 0) return lt();
154
- let n = new Set((H(e.required) ?? []).filter((e) => typeof e == "string")), r = {};
138
+ }, lt = (e) => e.length === 0 ? S.Unknown : e.length === 1 ? e[0] : S.Union(...e), ut = () => S.Record({
139
+ key: S.String,
140
+ value: S.Unknown
141
+ }), U = (e) => {
142
+ let t = B(e);
143
+ if (t === void 0) return S.Unknown;
144
+ if ("const" in t) return H(S.Literal(t.const), t);
145
+ let n = V(t.enum);
146
+ if (n !== void 0 && n.length > 0) return H(S.Literal(...n), t);
147
+ let r = V(t.anyOf) ?? V(t.oneOf);
148
+ if (r !== void 0) return H(lt(r.map(U)), t);
149
+ let i = t.type, a = typeof i == "string" ? [i] : V(i)?.filter((e) => typeof e == "string") ?? [], o = t.nullable === !0 || a.includes("null"), s = a.find((e) => e !== "null"), c = s === "object" || s === void 0 && t.properties !== void 0 ? dt(t) : s === "array" || s === void 0 && t.items !== void 0 ? S.Array(U(t.items)) : s === void 0 ? S.Unknown : ct(s);
150
+ return H(o ? S.NullOr(c) : c, t);
151
+ }, dt = (e) => {
152
+ let t = B(e.properties);
153
+ if (t === void 0) return ut();
154
+ let n = new Set((V(e.required) ?? []).filter((e) => typeof e == "string")), r = {};
155
155
  for (let [e, i] of Object.entries(t)) {
156
- let t = W(i);
157
- r[e] = n.has(e) ? t : C.optional(t);
156
+ let t = U(i);
157
+ r[e] = n.has(e) ? t : S.optional(t);
158
158
  }
159
- return C.Struct(r);
160
- }, dt = (e) => {
161
- let t = V(e);
162
- return t === void 0 || Object.keys(t).length === 0 ? lt() : W(t);
163
- }, G = (e) => e, ft = C.Struct({
164
- value: C.optional(C.Unknown),
165
- text: C.optional(C.String),
166
- url: C.optional(C.String),
167
- costMicroUsd: C.optional(C.Number),
168
- requestId: C.optional(C.String),
169
- error: C.optional(C.String)
170
- }), K = () => (/* @__PURE__ */ new Date()).toISOString(), pt = (e) => Math.round(e * 1e6), q = (e, t) => e.resolveModel?.(t) ?? q(e, t), J = (e, t, n) => {
171
- let r = Fe(t);
172
- return typeof r == "number" ? pt(r) : Pe(e, { model: n ?? "unknown" }).costMicroUsd ?? 0;
173
- }, Y = (e, t, n) => S.promise(() => e.store.update(P.tableName, t, n).then(() => void 0)).pipe(S.catchAllCause(() => S.void)), mt = (e, t) => S.promise(async () => (await e.store.query(D(P).where(w("id", t)).descriptor))[0]?.status === "cancelled").pipe(S.catchAllCause(() => S.succeed(!1))), X = (e, t) => S.gen(function* () {
174
- let n = it(t);
159
+ return S.Struct(r);
160
+ }, ft = (e) => {
161
+ let t = B(e);
162
+ return t === void 0 || Object.keys(t).length === 0 ? ut() : U(t);
163
+ }, W = (e) => e, pt = S.Struct({
164
+ value: S.optional(S.Unknown),
165
+ text: S.optional(S.String),
166
+ url: S.optional(S.String),
167
+ costMicroUsd: S.optional(S.Number),
168
+ requestId: S.optional(S.String),
169
+ error: S.optional(S.String)
170
+ }), G = () => (/* @__PURE__ */ new Date()).toISOString(), mt = (e) => Math.round(e * 1e6), K = (e, t) => e.resolveModel?.(t) ?? K(e, t), q = (e, t, n) => {
171
+ let r = Ie(t);
172
+ return typeof r == "number" ? mt(r) : Fe(e, { model: n ?? "unknown" }).costMicroUsd ?? 0;
173
+ }, J = (e, t, n) => x.promise(() => e.store.update(N.tableName, t, n).then(() => void 0)).pipe(x.catchAllCause(() => x.void)), ht = (e, t) => x.promise(async () => (await e.store.query(E(N).where(C("id", t)).descriptor))[0]?.status === "cancelled").pipe(x.catchAllCause(() => x.succeed(!1))), Y = (e, t) => x.gen(function* () {
174
+ let n = at(t);
175
175
  if (n) return n;
176
- let i = (yield* S.promise(() => e.store.query(D(N).where(w("id", t)).descriptor)))[0];
176
+ let i = (yield* x.promise(() => e.store.query(E(M).where(C("id", t)).descriptor)))[0];
177
177
  return i ? r({
178
178
  name: i.name ?? t,
179
179
  mode: i.mode,
@@ -185,13 +185,13 @@ var N = ke("_voltro_ai_flows", {
185
185
  chain: i.chainTo ?? null,
186
186
  cadence: i.cadence ?? null,
187
187
  humanTimeoutMs: i.humanTimeoutMs ?? null
188
- }) : yield* S.fail(new ve({
188
+ }) : yield* x.fail(new ye({
189
189
  flowRef: t,
190
190
  message: `no flow registered or stored for "${t}"`
191
191
  }));
192
- }), ht = (e, t, n, r, i) => S.gen(function* () {
193
- let e = R(n.prompt ?? "", r), a = tt(n.prompt ?? "", r);
194
- if (a.length > 0) return { error: new ge({
192
+ }), gt = (e, t, n, r, i) => x.gen(function* () {
193
+ let e = L(n.prompt ?? "", r), a = nt(n.prompt ?? "", r);
194
+ if (a.length > 0) return { error: new _e({
195
195
  stepId: n.id,
196
196
  unresolvedRef: a[0],
197
197
  message: `step "${n.id}" references unresolved {{${a[0]}}}`
@@ -204,86 +204,86 @@ var N = ke("_voltro_ai_flows", {
204
204
  };
205
205
  case "agent": {
206
206
  if (!n.agentRef) return { error: "agent step missing agentRef" };
207
- if (!t.resolveAgent) return { error: new b({
207
+ if (!t.resolveAgent) return { error: new y({
208
208
  capability: "resolveAgent",
209
209
  message: "no agent resolver configured"
210
210
  }).message };
211
- let r = yield* G(t.resolveAgent(n.agentRef)).pipe(S.map((e) => ({
211
+ let r = yield* W(t.resolveAgent(n.agentRef)).pipe(x.map((e) => ({
212
212
  ok: !0,
213
213
  a: e
214
- })), S.catchAll((e) => S.succeed({
214
+ })), x.catchAll((e) => x.succeed({
215
215
  ok: !1,
216
216
  e
217
217
  })));
218
218
  if (!r.ok) return { error: r.e.message };
219
- let i = yield* M({
219
+ let i = yield* j({
220
220
  system: r.a.system,
221
221
  prompt: e,
222
- provider: q(t, r.a.model)
223
- }).pipe(S.map((e) => ({
222
+ provider: K(t, r.a.model)
223
+ }).pipe(x.map((e) => ({
224
224
  ok: !0,
225
225
  r: e
226
- })), S.catchAll((e) => S.succeed({
226
+ })), x.catchAll((e) => x.succeed({
227
227
  ok: !1,
228
228
  e
229
229
  })));
230
230
  return i.ok ? {
231
231
  value: i.r.text,
232
232
  text: i.r.text,
233
- costMicroUsd: J(i.r.usage, i.r.providerMetadata, r.a.model)
233
+ costMicroUsd: q(i.r.usage, i.r.providerMetadata, r.a.model)
234
234
  } : { error: String(i.e.message ?? i.e) };
235
235
  }
236
236
  case "structured": {
237
- let r = n.model ?? t.defaultModels?.text, i = yield* Le({
237
+ let r = n.model ?? t.defaultModels?.text, i = yield* Re({
238
238
  prompt: e,
239
- schema: dt(n.schema),
240
- ...r ? { provider: q(t, r) } : {}
241
- }).pipe(S.map((e) => ({
239
+ schema: ft(n.schema),
240
+ ...r ? { provider: K(t, r) } : {}
241
+ }).pipe(x.map((e) => ({
242
242
  ok: !0,
243
243
  r: e
244
- })), S.catchAll((e) => S.succeed({
244
+ })), x.catchAll((e) => x.succeed({
245
245
  ok: !1,
246
246
  e
247
247
  })));
248
248
  return i.ok ? {
249
249
  value: i.r.object,
250
250
  text: JSON.stringify(i.r.object, null, 2),
251
- costMicroUsd: J(i.r.usage, i.r.providerMetadata, r)
251
+ costMicroUsd: q(i.r.usage, i.r.providerMetadata, r)
252
252
  } : { error: String(i.e.message ?? i.e) };
253
253
  }
254
254
  case "generate": {
255
255
  let r = n.modality ?? "text";
256
256
  if (r === "text") {
257
- let r = n.model ?? t.defaultModels?.text, i = yield* M({
257
+ let r = n.model ?? t.defaultModels?.text, i = yield* j({
258
258
  prompt: e,
259
- ...r ? { provider: q(t, r) } : {}
260
- }).pipe(S.map((e) => ({
259
+ ...r ? { provider: K(t, r) } : {}
260
+ }).pipe(x.map((e) => ({
261
261
  ok: !0,
262
262
  r: e
263
- })), S.catchAll((e) => S.succeed({
263
+ })), x.catchAll((e) => x.succeed({
264
264
  ok: !1,
265
265
  e
266
266
  })));
267
267
  return i.ok ? {
268
268
  value: i.r.text,
269
269
  text: i.r.text,
270
- costMicroUsd: J(i.r.usage, i.r.providerMetadata, r)
270
+ costMicroUsd: q(i.r.usage, i.r.providerMetadata, r)
271
271
  } : { error: String(i.e.message ?? i.e) };
272
272
  }
273
- if (!t.generateMedia) return { error: new b({
273
+ if (!t.generateMedia) return { error: new y({
274
274
  capability: `media:${r}`,
275
275
  message: `no media generator configured for ${r}`
276
276
  }).message };
277
- let a = n.model ?? t.defaultModels?.[r], o = yield* G(t.generateMedia({
277
+ let a = n.model ?? t.defaultModels?.[r], o = yield* W(t.generateMedia({
278
278
  modality: r,
279
279
  ...a ? { model: a } : {},
280
280
  prompt: e,
281
281
  ...n.params ? { params: n.params } : {},
282
282
  run: i
283
- })).pipe(S.map((e) => ({
283
+ })).pipe(x.map((e) => ({
284
284
  ok: !0,
285
285
  m: e
286
- })), S.catchAll((e) => S.succeed({
286
+ })), x.catchAll((e) => x.succeed({
287
287
  ok: !1,
288
288
  e
289
289
  })));
@@ -294,13 +294,13 @@ var N = ke("_voltro_ai_flows", {
294
294
  costMicroUsd: o.m.costMicroUsd ?? 0
295
295
  } : { error: o.e.message };
296
296
  }
297
- case "human": return { error: new b({
297
+ case "human": return { error: new y({
298
298
  capability: "human",
299
299
  message: "human step reached the step interpreter — it should have been parked by the deterministic executor (routing bug)"
300
300
  }).message };
301
301
  default: return { error: `unknown step type: ${String(n.type)}` };
302
302
  }
303
- }), gt = (t, n, r, i, a, o) => S.gen(function* () {
303
+ }), _t = (t, n, r, i, a, o) => x.gen(function* () {
304
304
  let s = { ...a }, c = i.steps.map((e, t) => ({
305
305
  id: t,
306
306
  title: e.title ?? `Step ${t + 1}`,
@@ -308,26 +308,26 @@ var N = ke("_voltro_ai_flows", {
308
308
  status: "pending",
309
309
  ...e.description ? { description: e.description } : {}
310
310
  })), l = 0;
311
- yield* Y(t, r, {
311
+ yield* J(t, r, {
312
312
  status: "running",
313
313
  steps: c,
314
314
  totalSteps: i.steps.length,
315
315
  currentStep: 0,
316
- startedAt: K()
316
+ startedAt: G()
317
317
  });
318
- for (let a of z(i.steps)) {
319
- if (yield* mt(t, r)) return {
318
+ for (let a of R(i.steps)) {
319
+ if (yield* ht(t, r)) return {
320
320
  runId: r,
321
321
  status: "cancelled"
322
322
  };
323
323
  if (a.steps.length > 1) {
324
324
  let i = [];
325
325
  for (let { index: t, step: n } of a.steps) {
326
- if (n.when !== void 0 && !_(n.when, s)) {
326
+ if (n.when !== void 0 && !g(n.when, s)) {
327
327
  c[t] = {
328
328
  ...c[t],
329
329
  status: "skipped",
330
- completedAt: K(),
330
+ completedAt: G(),
331
331
  skipReason: e(n.when)
332
332
  };
333
333
  continue;
@@ -338,22 +338,22 @@ var N = ke("_voltro_ai_flows", {
338
338
  }), c[t] = {
339
339
  ...c[t],
340
340
  status: "running",
341
- startedAt: K()
341
+ startedAt: G()
342
342
  };
343
343
  }
344
- yield* Y(t, r, {
344
+ yield* J(t, r, {
345
345
  steps: c,
346
346
  currentStep: a.steps[0].index
347
347
  });
348
- let u = yield* S.all(i.map(({ index: e, step: i }) => A({
348
+ let u = yield* x.all(i.map(({ index: e, step: i }) => k({
349
349
  name: `flow-${e}-${i.id}`,
350
350
  input: { index: e },
351
- success: ft,
352
- execute: ht(t, n, i, s, {
351
+ success: pt,
352
+ execute: gt(t, n, i, s, {
353
353
  runId: r,
354
354
  tenantId: o.tenantId
355
355
  })
356
- }).pipe(S.map((t) => ({
356
+ }).pipe(x.map((t) => ({
357
357
  index: e,
358
358
  step: i,
359
359
  result: t
@@ -363,7 +363,7 @@ var N = ke("_voltro_ai_flows", {
363
363
  c[e] = {
364
364
  ...c[e],
365
365
  status: "failed",
366
- completedAt: K(),
366
+ completedAt: G(),
367
367
  errorMessage: n.error
368
368
  };
369
369
  continue;
@@ -371,24 +371,24 @@ var N = ke("_voltro_ai_flows", {
371
371
  t.outputKey && n.value !== void 0 && (s[t.outputKey] = n.value), l += n.costMicroUsd ?? 0, c[e] = {
372
372
  ...c[e],
373
373
  status: "succeeded",
374
- completedAt: K(),
374
+ completedAt: G(),
375
375
  ...n.text ? { output: { text: n.text } } : {},
376
376
  ...n.url ? { url: n.url } : {},
377
377
  ...n.requestId ? { requestId: n.requestId } : {},
378
378
  ...n.costMicroUsd ? { costMicroUsd: n.costMicroUsd } : {}
379
379
  };
380
380
  }
381
- if (d !== void 0) return yield* Y(t, r, {
381
+ if (d !== void 0) return yield* J(t, r, {
382
382
  steps: c,
383
383
  status: "failed",
384
384
  errorMessage: d.result.error,
385
- completedAt: K(),
385
+ completedAt: G(),
386
386
  costMicroUsd: l
387
387
  }), {
388
388
  runId: r,
389
389
  status: "failed"
390
390
  };
391
- yield* Y(t, r, {
391
+ yield* J(t, r, {
392
392
  steps: c,
393
393
  currentStep: a.steps[a.steps.length - 1].index + 1,
394
394
  costMicroUsd: l
@@ -396,13 +396,13 @@ var N = ke("_voltro_ai_flows", {
396
396
  continue;
397
397
  }
398
398
  let { index: u, step: f } = a.steps[0];
399
- if (f.when !== void 0 && !_(f.when, s)) {
399
+ if (f.when !== void 0 && !g(f.when, s)) {
400
400
  c[u] = {
401
401
  ...c[u],
402
402
  status: "skipped",
403
- completedAt: K(),
403
+ completedAt: G(),
404
404
  skipReason: e(f.when)
405
- }, yield* Y(t, r, {
405
+ }, yield* J(t, r, {
406
406
  steps: c,
407
407
  currentStep: u + 1
408
408
  });
@@ -412,36 +412,36 @@ var N = ke("_voltro_ai_flows", {
412
412
  let e = {
413
413
  mode: f.reviewMode ?? "approve",
414
414
  ...f.options ? { options: f.options } : {},
415
- prompt: R(f.prompt ?? "", s)
415
+ prompt: L(f.prompt ?? "", s)
416
416
  };
417
417
  c[u] = {
418
418
  ...c[u],
419
419
  status: "waiting",
420
- startedAt: K(),
420
+ startedAt: G(),
421
421
  review: e
422
- }, yield* Y(t, r, {
422
+ }, yield* J(t, r, {
423
423
  steps: c,
424
424
  status: "waiting",
425
425
  currentStep: u
426
- }), n.onEvent && (yield* G(n.onEvent({
426
+ }), n.onEvent && (yield* W(n.onEvent({
427
427
  kind: "review-needed",
428
428
  runId: r,
429
429
  flowName: i.name,
430
430
  ownerId: o.ownerId,
431
431
  source: o.source
432
- })).pipe(S.catchAllCause(() => S.void)));
433
- let a = Qe({
432
+ })).pipe(x.catchAllCause(() => x.void)));
433
+ let a = $e({
434
434
  step: f,
435
435
  flow: i,
436
436
  deps: n
437
- }), p = yield* Ne(t, {
438
- name: y(u),
437
+ }), p = yield* Pe(t, {
438
+ name: v(u),
439
439
  schema: d,
440
440
  timeoutMs: a
441
- }).pipe(S.map((e) => ({
441
+ }).pipe(x.map((e) => ({
442
442
  ok: !0,
443
443
  a: e
444
- })), S.catchAllCause((e) => Se.isInterruptedOnly(e) ? S.failCause(e) : S.succeed({
444
+ })), x.catchAllCause((e) => Ce.isInterruptedOnly(e) ? x.failCause(e) : x.succeed({
445
445
  ok: !1,
446
446
  cause: e
447
447
  })));
@@ -450,13 +450,13 @@ var N = ke("_voltro_ai_flows", {
450
450
  return c[u] = {
451
451
  ...c[u],
452
452
  status: "failed",
453
- completedAt: K(),
453
+ completedAt: G(),
454
454
  errorMessage: e
455
- }, yield* Y(t, r, {
455
+ }, yield* J(t, r, {
456
456
  steps: c,
457
457
  status: "failed",
458
458
  errorMessage: e,
459
- completedAt: K(),
459
+ completedAt: G(),
460
460
  costMicroUsd: l
461
461
  }), {
462
462
  runId: r,
@@ -467,12 +467,12 @@ var N = ke("_voltro_ai_flows", {
467
467
  if (m.decision === "reject") return c[u] = {
468
468
  ...c[u],
469
469
  status: "failed",
470
- completedAt: K(),
470
+ completedAt: G(),
471
471
  errorMessage: "rejected by reviewer"
472
- }, yield* Y(t, r, {
472
+ }, yield* J(t, r, {
473
473
  steps: c,
474
474
  status: "cancelled",
475
- completedAt: K(),
475
+ completedAt: G(),
476
476
  costMicroUsd: l
477
477
  }), {
478
478
  runId: r,
@@ -481,9 +481,9 @@ var N = ke("_voltro_ai_flows", {
481
481
  f.outputKey && (s[f.outputKey] = m.value ?? m.text ?? m.decision ?? !0), c[u] = {
482
482
  ...c[u],
483
483
  status: "succeeded",
484
- completedAt: K(),
484
+ completedAt: G(),
485
485
  output: { text: String(m.text ?? m.value ?? m.decision ?? "approved") }
486
- }, yield* Y(t, r, {
486
+ }, yield* J(t, r, {
487
487
  steps: c,
488
488
  status: "running",
489
489
  currentStep: u + 1
@@ -493,16 +493,16 @@ var N = ke("_voltro_ai_flows", {
493
493
  c[u] = {
494
494
  ...c[u],
495
495
  status: "running",
496
- startedAt: K()
497
- }, yield* Y(t, r, {
496
+ startedAt: G()
497
+ }, yield* J(t, r, {
498
498
  steps: c,
499
499
  currentStep: u
500
500
  });
501
- let p = yield* A({
501
+ let p = yield* k({
502
502
  name: `flow-${u}-${f.id}`,
503
503
  input: { index: u },
504
- success: ft,
505
- execute: ht(t, n, f, s, {
504
+ success: pt,
505
+ execute: gt(t, n, f, s, {
506
506
  runId: r,
507
507
  tenantId: o.tenantId
508
508
  })
@@ -510,13 +510,13 @@ var N = ke("_voltro_ai_flows", {
510
510
  if (p.error) return c[u] = {
511
511
  ...c[u],
512
512
  status: "failed",
513
- completedAt: K(),
513
+ completedAt: G(),
514
514
  errorMessage: p.error
515
- }, yield* Y(t, r, {
515
+ }, yield* J(t, r, {
516
516
  steps: c,
517
517
  status: "failed",
518
518
  errorMessage: p.error,
519
- completedAt: K(),
519
+ completedAt: G(),
520
520
  costMicroUsd: l
521
521
  }), {
522
522
  runId: r,
@@ -525,12 +525,12 @@ var N = ke("_voltro_ai_flows", {
525
525
  f.outputKey && p.value !== void 0 && (s[f.outputKey] = p.value), l += p.costMicroUsd ?? 0, c[u] = {
526
526
  ...c[u],
527
527
  status: "succeeded",
528
- completedAt: K(),
528
+ completedAt: G(),
529
529
  ...p.text ? { output: { text: p.text } } : {},
530
530
  ...p.url ? { url: p.url } : {},
531
531
  ...p.requestId ? { requestId: p.requestId } : {},
532
532
  ...p.costMicroUsd ? { costMicroUsd: p.costMicroUsd } : {}
533
- }, yield* Y(t, r, {
533
+ }, yield* J(t, r, {
534
534
  steps: c,
535
535
  currentStep: u + 1,
536
536
  costMicroUsd: l
@@ -538,28 +538,28 @@ var N = ke("_voltro_ai_flows", {
538
538
  }
539
539
  let u = {};
540
540
  for (let e of i.steps) e.outputKey && s[e.outputKey] !== void 0 && (u[e.outputKey] = s[e.outputKey]);
541
- return yield* Y(t, r, {
541
+ return yield* J(t, r, {
542
542
  status: "succeeded",
543
543
  output: u,
544
- completedAt: K(),
544
+ completedAt: G(),
545
545
  costMicroUsd: l
546
546
  }), {
547
547
  runId: r,
548
548
  status: "succeeded",
549
549
  output: u
550
550
  };
551
- }), _t = (e, t, n, r, i, a, o) => S.gen(function* () {
551
+ }), vt = (e, t, n, r, i, a, o) => x.gen(function* () {
552
552
  let s = n.chain;
553
553
  if (!s) return;
554
554
  let c = [...a.chainPath ?? [], a.flowRef];
555
555
  if (s.flowRef === n.name || s.flowRef === a.flowRef) return;
556
556
  if (c.includes(s.flowRef)) {
557
- yield* Y(e, t, { chainRefusal: `chain to "${s.flowRef}" refused — it is already in this run's chain (${c.join(" → ")}), which would loop` });
557
+ yield* J(e, t, { chainRefusal: `chain to "${s.flowRef}" refused — it is already in this run's chain (${c.join(" → ")}), which would loop` });
558
558
  return;
559
559
  }
560
- let l = $e(o);
560
+ let l = et(o);
561
561
  if (c.length >= l) {
562
- yield* Y(e, t, { chainRefusal: `chain to "${s.flowRef}" refused — depth ${c.length} reached the limit of ${l} (${c.join(" → ")})` });
562
+ yield* J(e, t, { chainRefusal: `chain to "${s.flowRef}" refused — depth ${c.length} reached the limit of ${l} (${c.join(" → ")})` });
563
563
  return;
564
564
  }
565
565
  let u = {
@@ -568,7 +568,7 @@ var N = ke("_voltro_ai_flows", {
568
568
  }, d = {};
569
569
  for (let e of s.mappings) e.sourceKey in u && (d[e.targetKey] = u[e.sourceKey]);
570
570
  if (s.requireConfirmation) {
571
- yield* Y(e, t, { chainPending: {
571
+ yield* J(e, t, { chainPending: {
572
572
  flowRef: s.flowRef,
573
573
  input: d,
574
574
  status: "pending"
@@ -578,9 +578,9 @@ var N = ke("_voltro_ai_flows", {
578
578
  let f = e.workflows;
579
579
  if (!f) return;
580
580
  let p = `${t}--chain`, m = `${a.requestId}--chain`;
581
- yield* S.promise(async () => {
581
+ yield* x.promise(async () => {
582
582
  try {
583
- await e.store.insert(P.tableName, {
583
+ await e.store.insert(N.tableName, {
584
584
  id: p,
585
585
  flowRef: s.flowRef,
586
586
  flowName: s.flowRef,
@@ -598,60 +598,60 @@ var N = ke("_voltro_ai_flows", {
598
598
  requestId: m,
599
599
  chainPath: c
600
600
  });
601
- }).pipe(S.catchAllCause(() => S.void));
602
- }), vt = (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"), yt = (e) => {
601
+ }).pipe(x.catchAllCause(() => x.void));
602
+ }), yt = (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"), bt = (e) => {
603
603
  let t = Object.entries(e);
604
604
  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");
605
- }, bt = (e) => [
605
+ }, xt = (e) => [
606
606
  e.orchestrator?.instructions ?? "You are an orchestrator that uses the available tools to produce a bundled result.",
607
- vt(e),
607
+ yt(e),
608
608
  "When finished, emit a JSON object mapping each deliverable name (outputKey) to its value."
609
- ].filter(Boolean).join("\n\n"), xt = C.Struct({
610
- object: C.Record({
611
- key: C.String,
612
- value: C.Unknown
609
+ ].filter(Boolean).join("\n\n"), St = S.Struct({
610
+ object: S.Record({
611
+ key: S.String,
612
+ value: S.Unknown
613
613
  }),
614
- planCostMicroUsd: C.Number,
615
- toolCostMicroUsd: C.Number,
616
- steps: C.Array(fe),
617
- error: C.optional(C.String)
618
- }), St = (e, t, n, r, i, a, o) => S.gen(function* () {
619
- yield* Y(e, n, {
614
+ planCostMicroUsd: S.Number,
615
+ toolCostMicroUsd: S.Number,
616
+ steps: S.Array(pe),
617
+ error: S.optional(S.String)
618
+ }), Ct = (e, t, n, r, i, a, o) => x.gen(function* () {
619
+ yield* J(e, n, {
620
620
  status: "running",
621
- startedAt: K(),
621
+ startedAt: G(),
622
622
  totalSteps: r.steps.length
623
623
  });
624
- let s = yield* A({
624
+ let s = yield* k({
625
625
  name: "flow-agentic",
626
626
  input: { flowRef: r.name },
627
- success: xt,
628
- execute: S.gen(function* () {
627
+ success: St,
628
+ execute: x.gen(function* () {
629
629
  let s = [], c = 0, l = (e) => {
630
630
  let t = s.length;
631
631
  return s.push({
632
632
  id: t,
633
633
  status: "running",
634
- startedAt: K(),
634
+ startedAt: G(),
635
635
  ...e
636
636
  }), t;
637
637
  }, u = (e, t) => {
638
638
  s[e] = {
639
639
  ...s[e],
640
- completedAt: K(),
640
+ completedAt: G(),
641
641
  ...t
642
642
  };
643
- }, d = () => Y(e, n, {
643
+ }, d = () => J(e, n, {
644
644
  steps: s,
645
645
  currentStep: s.length,
646
646
  costMicroUsd: c
647
- }), f = j({
647
+ }), f = A({
648
648
  name: "run_agent",
649
649
  description: "Delegate a text task to an allowed sub-agent. Returns the agent's text.",
650
- input: C.Struct({
651
- agentRef: C.String,
652
- prompt: C.String
650
+ input: S.Struct({
651
+ agentRef: S.String,
652
+ prompt: S.String
653
653
  }),
654
- execute: ({ agentRef: e, prompt: n }) => S.gen(function* () {
654
+ execute: ({ agentRef: e, prompt: n }) => x.gen(function* () {
655
655
  let r = l({
656
656
  title: `agent:${e}`,
657
657
  type: "agent"
@@ -660,10 +660,10 @@ var N = ke("_voltro_ai_flows", {
660
660
  status: "failed",
661
661
  errorMessage: "no agent resolver configured"
662
662
  }), yield* d(), "ERROR: no agent resolver configured";
663
- let i = yield* G(t.resolveAgent(e)).pipe(S.map((e) => ({
663
+ let i = yield* W(t.resolveAgent(e)).pipe(x.map((e) => ({
664
664
  ok: !0,
665
665
  a: e
666
- })), S.catchAll((e) => S.succeed({
666
+ })), x.catchAll((e) => x.succeed({
667
667
  ok: !1,
668
668
  e
669
669
  })));
@@ -671,14 +671,14 @@ var N = ke("_voltro_ai_flows", {
671
671
  status: "failed",
672
672
  errorMessage: i.e.message
673
673
  }), yield* d(), `ERROR: ${i.e.message}`;
674
- let a = yield* M({
674
+ let a = yield* j({
675
675
  system: i.a.system,
676
676
  prompt: n,
677
- provider: q(t, i.a.model)
678
- }).pipe(S.map((e) => ({
677
+ provider: K(t, i.a.model)
678
+ }).pipe(x.map((e) => ({
679
679
  ok: !0,
680
680
  r: e
681
- })), S.catchAll((e) => S.succeed({
681
+ })), x.catchAll((e) => x.succeed({
682
682
  ok: !1,
683
683
  e
684
684
  })));
@@ -689,22 +689,22 @@ var N = ke("_voltro_ai_flows", {
689
689
  errorMessage: e
690
690
  }), yield* d(), `ERROR: ${e}`;
691
691
  }
692
- let o = J(a.r.usage, a.r.providerMetadata, i.a.model);
692
+ let o = q(a.r.usage, a.r.providerMetadata, i.a.model);
693
693
  return c += o, u(r, {
694
694
  status: "succeeded",
695
695
  output: { text: a.r.text },
696
696
  costMicroUsd: o
697
697
  }), yield* d(), a.r.text;
698
698
  })
699
- }), p = j({
699
+ }), p = A({
700
700
  name: "generate_media",
701
701
  description: "Generate an image, video, or audio artifact. Returns the hosted URL.",
702
- input: C.Struct({
703
- modality: C.Literal("image", "video", "audio"),
704
- prompt: C.String,
705
- model: C.optional(C.String)
702
+ input: S.Struct({
703
+ modality: S.Literal("image", "video", "audio"),
704
+ prompt: S.String,
705
+ model: S.optional(S.String)
706
706
  }),
707
- execute: ({ modality: e, prompt: r, model: i }) => S.gen(function* () {
707
+ execute: ({ modality: e, prompt: r, model: i }) => x.gen(function* () {
708
708
  let a = l({
709
709
  title: `media:${e}`,
710
710
  type: "generate"
@@ -713,7 +713,7 @@ var N = ke("_voltro_ai_flows", {
713
713
  status: "failed",
714
714
  errorMessage: `no media generator for ${e}`
715
715
  }), yield* d(), `ERROR: no media generator configured for ${e}`;
716
- let s = yield* G(t.generateMedia({
716
+ let s = yield* W(t.generateMedia({
717
717
  modality: e,
718
718
  prompt: r,
719
719
  ...i ? { model: i } : {},
@@ -721,10 +721,10 @@ var N = ke("_voltro_ai_flows", {
721
721
  runId: n,
722
722
  tenantId: o
723
723
  }
724
- })).pipe(S.map((e) => ({
724
+ })).pipe(x.map((e) => ({
725
725
  ok: !0,
726
726
  r: e
727
- })), S.catchAll((e) => S.succeed({
727
+ })), x.catchAll((e) => x.succeed({
728
728
  ok: !1,
729
729
  e
730
730
  })));
@@ -738,30 +738,30 @@ var N = ke("_voltro_ai_flows", {
738
738
  errorMessage: s.e.message
739
739
  }), yield* d(), `ERROR: ${s.e.message}`);
740
740
  })
741
- }), m = j({
741
+ }), m = A({
742
742
  name: "pick_structured",
743
743
  description: "Produce a JSON object for a task. Returns the object.",
744
- input: C.Struct({
745
- prompt: C.String,
746
- model: C.optional(C.String)
744
+ input: S.Struct({
745
+ prompt: S.String,
746
+ model: S.optional(S.String)
747
747
  }),
748
- execute: ({ prompt: e, model: n }) => S.gen(function* () {
748
+ execute: ({ prompt: e, model: n }) => x.gen(function* () {
749
749
  let r = l({
750
750
  title: "structured",
751
751
  type: "structured"
752
752
  });
753
753
  yield* d();
754
- let i = yield* Le({
754
+ let i = yield* Re({
755
755
  prompt: e,
756
- schema: C.Record({
757
- key: C.String,
758
- value: C.Unknown
756
+ schema: S.Record({
757
+ key: S.String,
758
+ value: S.Unknown
759
759
  }),
760
- ...n ? { provider: q(t, n) } : {}
761
- }).pipe(S.map((e) => ({
760
+ ...n ? { provider: K(t, n) } : {}
761
+ }).pipe(x.map((e) => ({
762
762
  ok: !0,
763
763
  r: e
764
- })), S.catchAll((e) => S.succeed({
764
+ })), x.catchAll((e) => x.succeed({
765
765
  ok: !1,
766
766
  e
767
767
  })));
@@ -772,19 +772,19 @@ var N = ke("_voltro_ai_flows", {
772
772
  errorMessage: e
773
773
  }), yield* d(), { error: e };
774
774
  }
775
- let a = J(i.r.usage, i.r.providerMetadata, n);
775
+ let a = q(i.r.usage, i.r.providerMetadata, n);
776
776
  return c += a, u(r, {
777
777
  status: "succeeded",
778
778
  output: { text: JSON.stringify(i.r.object) },
779
779
  costMicroUsd: a
780
780
  }), yield* d(), i.r.object;
781
781
  })
782
- }), h = t.memoryPrefix ? yield* G(t.memoryPrefix(a)).pipe(S.catchAll(() => S.succeed(""))) : "", g = yield* Re({
783
- system: h ? `${h}\n\n${bt(r)}` : bt(r),
784
- prompt: yt(i),
785
- schema: C.Record({
786
- key: C.String,
787
- value: C.Unknown
782
+ }), h = t.memoryPrefix ? yield* W(t.memoryPrefix(a)).pipe(x.catchAll(() => x.succeed(""))) : "", ee = h ? `${h}\n\n${xt(r)}` : xt(r), g = yield* ze({
783
+ system: ee,
784
+ prompt: bt(i),
785
+ schema: S.Record({
786
+ key: S.String,
787
+ value: S.Unknown
788
788
  }),
789
789
  tools: {
790
790
  run_agent: f,
@@ -792,17 +792,17 @@ var N = ke("_voltro_ai_flows", {
792
792
  pick_structured: m
793
793
  },
794
794
  maxSteps: r.maxSteps,
795
- ...r.orchestrator?.model ? { provider: q(t, r.orchestrator.model) } : {}
796
- }).pipe(S.map((e) => ({
795
+ ...r.orchestrator?.model ? { provider: K(t, r.orchestrator.model) } : {}
796
+ }).pipe(x.map((e) => ({
797
797
  ok: !0,
798
798
  r: e
799
- })), S.catchAll((e) => S.succeed({
799
+ })), x.catchAll((e) => x.succeed({
800
800
  ok: !1,
801
801
  e
802
802
  })));
803
803
  return g.ok ? {
804
804
  object: g.r.object,
805
- planCostMicroUsd: J(g.r.usage, g.r.providerMetadata, r.orchestrator?.model),
805
+ planCostMicroUsd: q(g.r.usage, g.r.providerMetadata, r.orchestrator?.model),
806
806
  toolCostMicroUsd: c,
807
807
  steps: s
808
808
  } : {
@@ -814,60 +814,60 @@ var N = ke("_voltro_ai_flows", {
814
814
  };
815
815
  })
816
816
  }), c = s.planCostMicroUsd + s.toolCostMicroUsd;
817
- return s.error ? (yield* Y(e, n, {
817
+ return s.error ? (yield* J(e, n, {
818
818
  status: "failed",
819
819
  steps: s.steps,
820
820
  errorMessage: s.error,
821
- completedAt: K(),
821
+ completedAt: G(),
822
822
  costMicroUsd: c
823
823
  }), {
824
824
  runId: n,
825
825
  status: "failed"
826
- }) : (yield* Y(e, n, {
826
+ }) : (yield* J(e, n, {
827
827
  status: "succeeded",
828
828
  steps: s.steps,
829
829
  output: s.object,
830
- completedAt: K(),
830
+ completedAt: G(),
831
831
  costMicroUsd: c
832
832
  }), {
833
833
  runId: n,
834
834
  status: "succeeded",
835
835
  output: s.object
836
836
  });
837
- }), Ct = (e, t = {}) => (n, r) => S.gen(function* () {
838
- let { runId: r, flowRef: i, input: a } = n, o = yield* A({
837
+ }), wt = (e, t = {}) => (n, r) => x.gen(function* () {
838
+ let { runId: r, flowRef: i, input: a } = n, o = yield* k({
839
839
  name: "flow-0-resolve",
840
840
  input: { flowRef: i },
841
- success: C.Struct({
842
- ir: C.Unknown,
843
- error: C.optional(C.String)
841
+ success: S.Struct({
842
+ ir: S.Unknown,
843
+ error: S.optional(S.String)
844
844
  }),
845
- execute: X(e, i).pipe(S.map((e) => ({ ir: e })), S.catchAll((e) => S.succeed({
845
+ execute: Y(e, i).pipe(x.map((e) => ({ ir: e })), x.catchAll((e) => x.succeed({
846
846
  ir: void 0,
847
847
  error: e.message
848
848
  })))
849
849
  });
850
- if (o.error || !o.ir) return yield* Y(e, r, {
850
+ if (o.error || !o.ir) return yield* J(e, r, {
851
851
  status: "failed",
852
852
  errorMessage: o.error ?? "flow not found",
853
- completedAt: K()
853
+ completedAt: G()
854
854
  }), {
855
855
  runId: r,
856
856
  status: "failed"
857
857
  };
858
- let s = o.ir, c = (yield* S.promise(() => e.store.query(D(P).where(w("id", r)).descriptor)).pipe(S.catchAllCause(() => S.succeed([]))))[0], l = c?.ownerId ?? null, u = c?.tenantId ?? null, d = s.mode === "agentic" ? yield* St(e, t, r, s, a, l, u) : yield* gt(e, t, r, s, a, {
858
+ let s = o.ir, c = (yield* x.promise(() => e.store.query(E(N).where(C("id", r)).descriptor)).pipe(x.catchAllCause(() => x.succeed([]))))[0], l = c?.ownerId ?? null, u = c?.tenantId ?? null, d = s.mode === "agentic" ? yield* Ct(e, t, r, s, a, l, u) : yield* _t(e, t, r, s, a, {
859
859
  ownerId: l,
860
860
  tenantId: u,
861
861
  source: n.source
862
862
  });
863
- return d.status === "succeeded" && s.chain && (yield* _t(e, r, s, a, d.output ?? {}, n, t)), t.onEvent && (d.status === "succeeded" || d.status === "failed") && (yield* G(t.onEvent({
863
+ return d.status === "succeeded" && s.chain && (yield* vt(e, r, s, a, d.output ?? {}, n, t)), t.onEvent && (d.status === "succeeded" || d.status === "failed") && (yield* W(t.onEvent({
864
864
  kind: d.status,
865
865
  runId: r,
866
866
  flowName: s.name,
867
867
  ownerId: l,
868
868
  source: n.source
869
- })).pipe(S.catchAllCause(() => S.void))), d;
870
- }), wt = {
869
+ })).pipe(x.catchAllCause(() => x.void))), d;
870
+ }), Tt = {
871
871
  text: (e) => ({
872
872
  type: "generate",
873
873
  modality: "text",
@@ -894,31 +894,31 @@ var N = ke("_voltro_ai_flows", {
894
894
  type: "human",
895
895
  ...e
896
896
  })
897
- }, Tt = (e) => e.map((e, t) => "id" in e && e.id ? e : {
897
+ }, Et = (e) => e.map((e, t) => "id" in e && e.id ? e : {
898
898
  id: `step-${t}`,
899
899
  ...e
900
- }), Et = (e) => {
901
- let t = [], r = z(e.steps);
902
- for (let e of nt(r)) t.push(`group "${e}" is not contiguous — only CONSECUTIVE steps sharing a group run concurrently, so this would execute as two separate fan-outs`);
900
+ }), Dt = (e) => {
901
+ let t = [], r = R(e.steps);
902
+ for (let e of rt(r)) t.push(`group "${e}" is not contiguous — only CONSECUTIVE steps sharing a group run concurrently, so this would execute as two separate fan-outs`);
903
903
  let i = new Set(e.brief.map((e) => e.key));
904
904
  for (let e of r) {
905
905
  for (let { step: n } of e.steps) {
906
906
  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`);
907
- for (let r of L(n.prompt ?? "")) i.has(r) || t.push(e.steps.length > 1 ? `step "${n.id}" references {{${r}}} 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 {{${r}}} which is not a brief field or a prior step outputKey`);
907
+ for (let r of I(n.prompt ?? "")) i.has(r) || t.push(e.steps.length > 1 ? `step "${n.id}" references {{${r}}} 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 {{${r}}} which is not a brief field or a prior step outputKey`);
908
908
  n.when !== void 0 && !i.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`);
909
909
  }
910
910
  for (let { step: t } of e.steps) t.outputKey && i.add(n(t.outputKey));
911
911
  }
912
- if (t.length > 0) throw new ye({
912
+ if (t.length > 0) throw new be({
913
913
  flowRef: e.name,
914
914
  message: `flow "${e.name}" has ${t.length} problem(s)`,
915
915
  issues: t
916
916
  });
917
- }, Dt = (e) => {
917
+ }, Ot = (e) => {
918
918
  let t = r({
919
919
  name: e.name,
920
920
  mode: e.mode,
921
- steps: Tt(e.steps),
921
+ steps: Et(e.steps),
922
922
  maxSteps: e.maxSteps,
923
923
  brief: e.brief,
924
924
  orchestratorModel: e.orchestrator?.model,
@@ -927,10 +927,10 @@ var N = ke("_voltro_ai_flows", {
927
927
  cadence: e.cadence,
928
928
  humanTimeoutMs: e.humanTimeoutMs
929
929
  });
930
- return Et(t), rt(t), t;
931
- }, Z = (e) => String(e).padStart(2, "0"), Ot = (e, t) => `cron-${e}-${t.getFullYear()}${Z(t.getMonth() + 1)}${Z(t.getDate())}-${Z(t.getHours())}${Z(t.getMinutes())}`, kt = async (e) => {
930
+ return Dt(t), it(t), t;
931
+ }, X = (e) => String(e).padStart(2, "0"), kt = (e, t) => `cron-${e}-${t.getFullYear()}${X(t.getMonth() + 1)}${X(t.getDate())}-${X(t.getHours())}${X(t.getMinutes())}`, At = async (e) => {
932
932
  let t = [];
933
- for (let e of at()) e.cadence && (e.cadence.repeats?.length ?? 0) > 0 && t.push({
933
+ for (let e of ot()) e.cadence && (e.cadence.repeats?.length ?? 0) > 0 && t.push({
934
934
  flowRef: e.name,
935
935
  cadence: e.cadence,
936
936
  defaultInput: e.cadence.defaultInput ?? {}
@@ -942,11 +942,11 @@ var N = ke("_voltro_ai_flows", {
942
942
  defaultInput: e.cadence.defaultInput ?? {}
943
943
  });
944
944
  return t;
945
- }, At = async (e, t = /* @__PURE__ */ new Date()) => {
946
- let n = e.workflows, r = [], i = 0, a = await kt(e).catch(() => []);
945
+ }, jt = async (e, t = /* @__PURE__ */ new Date()) => {
946
+ let n = e.workflows, r = [], i = 0, a = await At(e).catch(() => []);
947
947
  for (let o of a) {
948
- if (!xe(o.cadence, t) || (i += 1, !n)) continue;
949
- let a = Ot(o.flowRef, t), s = `run-${a}`;
948
+ if (!Se(o.cadence, t) || (i += 1, !n)) continue;
949
+ let a = kt(o.flowRef, t), s = `run-${a}`;
950
950
  try {
951
951
  try {
952
952
  await e.store.insert("_voltro_ai_flow_runs", {
@@ -972,25 +972,25 @@ var N = ke("_voltro_ai_flows", {
972
972
  matched: i,
973
973
  started: r
974
974
  };
975
- }, jt = (e) => ({
975
+ }, Mt = (e) => ({
976
976
  name: "gateway",
977
977
  model: e
978
- }), Mt = (e) => Math.round(e * 1e6), Nt = (e, t, n) => {
979
- let r = Fe(t);
980
- return typeof r == "number" ? Mt(r) : e ? Pe(e, { model: n ?? "unknown" }).costMicroUsd ?? 0 : 0;
978
+ }), Nt = (e) => Math.round(e * 1e6), Z = (e, t, n) => {
979
+ let r = Ie(t);
980
+ return typeof r == "number" ? Nt(r) : e ? Fe(e, { model: n ?? "unknown" }).costMicroUsd ?? 0 : 0;
981
981
  }, Pt = (e, t) => (n) => {
982
- let r = n.model, i = (e) => t?.resolveModel?.(e) ?? jt(e);
983
- return S.gen(function* () {
982
+ let r = n.model, i = (e) => t?.resolveModel?.(e) ?? Mt(e);
983
+ return x.gen(function* () {
984
984
  if (n.modality === "image") {
985
- let t = yield* Ie({
985
+ let t = yield* Le({
986
986
  prompt: n.prompt,
987
987
  ...r ? { provider: i(r) } : {}
988
988
  }), a = t.images[0];
989
- if (!a) return yield* S.fail(new b({
989
+ if (!a) return yield* x.fail(new y({
990
990
  capability: "media:image",
991
991
  message: "no image produced"
992
992
  }));
993
- let o = yield* S.promise(() => e.put({
993
+ let o = yield* x.promise(() => e.put({
994
994
  data: a.data,
995
995
  mediaType: a.mediaType,
996
996
  run: n.run
@@ -998,14 +998,14 @@ var N = ke("_voltro_ai_flows", {
998
998
  return {
999
999
  url: o.url,
1000
1000
  ...o.refId ? { requestId: o.refId } : {},
1001
- costMicroUsd: Nt(t.usage, t.providerMetadata, r)
1001
+ costMicroUsd: Z(t.usage, t.providerMetadata, r)
1002
1002
  };
1003
1003
  }
1004
1004
  if (n.modality === "audio") {
1005
- let t = yield* ze({
1005
+ let t = yield* Be({
1006
1006
  text: n.prompt,
1007
1007
  ...r ? { provider: i(r) } : {}
1008
- }), a = yield* S.promise(() => e.put({
1008
+ }), a = yield* x.promise(() => e.put({
1009
1009
  data: t.audio.data,
1010
1010
  mediaType: t.audio.mediaType,
1011
1011
  run: n.run
@@ -1013,41 +1013,41 @@ var N = ke("_voltro_ai_flows", {
1013
1013
  return {
1014
1014
  url: a.url,
1015
1015
  ...a.refId ? { requestId: a.refId } : {},
1016
- costMicroUsd: Nt(t.usage, t.providerMetadata, r)
1016
+ costMicroUsd: Z(t.usage, t.providerMetadata, r)
1017
1017
  };
1018
1018
  }
1019
- let t = yield* Be({
1019
+ let t = yield* Ve({
1020
1020
  prompt: n.prompt,
1021
1021
  ...r ? { provider: i(r) } : {},
1022
1022
  ...n.params ? { params: n.params } : {}
1023
1023
  }), a;
1024
- if (t.video.url) a = e.ingestUrl ? yield* S.promise(() => e.ingestUrl(t.video.url, n.run)) : { url: t.video.url };
1025
- else if (t.video.data) a = yield* S.promise(() => e.put({
1024
+ if (t.video.url) a = e.ingestUrl ? yield* x.promise(() => e.ingestUrl(t.video.url, n.run)) : { url: t.video.url };
1025
+ else if (t.video.data) a = yield* x.promise(() => e.put({
1026
1026
  data: t.video.data,
1027
1027
  mediaType: t.video.mediaType,
1028
1028
  run: n.run
1029
1029
  }));
1030
- else return yield* S.fail(new b({
1030
+ else return yield* x.fail(new y({
1031
1031
  capability: "media:video",
1032
1032
  message: "no video produced"
1033
1033
  }));
1034
1034
  return {
1035
1035
  url: a.url,
1036
1036
  ...a.refId ? { requestId: a.refId } : {},
1037
- costMicroUsd: Nt(t.usage, t.providerMetadata, r)
1037
+ costMicroUsd: Z(t.usage, t.providerMetadata, r)
1038
1038
  };
1039
- }).pipe(S.catchAll((e) => e instanceof b ? S.fail(e) : S.fail(new b({
1039
+ }).pipe(x.catchAll((e) => e instanceof y ? x.fail(e) : x.fail(new y({
1040
1040
  capability: `media:${n.modality}`,
1041
1041
  message: String(e.message ?? e)
1042
1042
  }))));
1043
- }, Q = () => globalThis.crypto?.randomUUID?.() ?? `req-${Date.now().toString(36)}`, Ft = (e) => e.request?.subject?.id ?? null, $ = (e, t) => S.promise(() => e.store.query(D(P).where(w("id", t)).descriptor)).pipe(S.map((e) => e[0])), It = (e, t) => S.gen(function* () {
1044
- let n = yield* X(e, t.flowRef), r = t.input ?? {}, i = n.brief.filter((e) => e.required && e.type !== "boolean" && (r[e.key] === void 0 || r[e.key] === null || r[e.key] === "")).map((e) => e.key);
1045
- if (i.length > 0) return yield* S.fail(new he({
1043
+ }, Q = () => globalThis.crypto?.randomUUID?.() ?? `req-${Date.now().toString(36)}`, Ft = (e) => e.request?.subject?.id ?? null, $ = (e, t) => x.promise(() => e.store.query(E(N).where(C("id", t)).descriptor)).pipe(x.map((e) => e[0])), It = (e, t) => x.gen(function* () {
1044
+ let n = yield* Y(e, t.flowRef), r = t.input ?? {}, i = n.brief.filter((e) => e.required && e.type !== "boolean" && (r[e.key] === void 0 || r[e.key] === null || r[e.key] === "")).map((e) => e.key);
1045
+ if (i.length > 0) return yield* x.fail(new ge({
1046
1046
  missing: i,
1047
1047
  message: `missing required brief field(s): ${i.join(", ")}`
1048
1048
  }));
1049
1049
  let a = Q(), o = `run-${a}`, s = t.source ?? "manual";
1050
- yield* S.promise(() => e.store.insert(P.tableName, {
1050
+ yield* x.promise(() => e.store.insert(N.tableName, {
1051
1051
  id: o,
1052
1052
  flowRef: t.flowRef,
1053
1053
  flowName: n.name,
@@ -1059,7 +1059,7 @@ var N = ke("_voltro_ai_flows", {
1059
1059
  ownerId: Ft(e)
1060
1060
  }));
1061
1061
  let c = e.workflows;
1062
- return c && (yield* S.promise(() => c.start(v, {
1062
+ return c && (yield* x.promise(() => c.start(_, {
1063
1063
  runId: o,
1064
1064
  flowRef: t.flowRef,
1065
1065
  input: r,
@@ -1070,20 +1070,20 @@ var N = ke("_voltro_ai_flows", {
1070
1070
  requestId: a,
1071
1071
  status: "pending"
1072
1072
  };
1073
- }), Lt = (e, t) => S.gen(function* () {
1073
+ }), Lt = (e, t) => x.gen(function* () {
1074
1074
  let n = yield* $(e, t.runId);
1075
- if (!n) return yield* S.fail(new x({
1075
+ if (!n) return yield* x.fail(new b({
1076
1076
  runId: t.runId,
1077
1077
  message: "run not found"
1078
1078
  }));
1079
1079
  let r = n.requestId ?? Q(), i = n.flowRef, a = n.input ?? {}, o = n.source ?? "manual";
1080
- yield* S.promise(() => e.store.update(P.tableName, t.runId, {
1080
+ yield* x.promise(() => e.store.update(N.tableName, t.runId, {
1081
1081
  status: "pending",
1082
1082
  error: null,
1083
1083
  errorMessage: null
1084
1084
  }));
1085
1085
  let s = e.workflows;
1086
- return s && (yield* S.promise(() => s.start(v, {
1086
+ return s && (yield* x.promise(() => s.start(_, {
1087
1087
  runId: t.runId,
1088
1088
  flowRef: i,
1089
1089
  input: a,
@@ -1094,14 +1094,14 @@ var N = ke("_voltro_ai_flows", {
1094
1094
  requestId: r,
1095
1095
  status: "pending"
1096
1096
  };
1097
- }), Rt = (e, t) => S.gen(function* () {
1098
- return (yield* $(e, t.runId)) ? (yield* S.promise(() => e.store.update(P.tableName, t.runId, {
1097
+ }), Rt = (e, t) => x.gen(function* () {
1098
+ return (yield* $(e, t.runId)) ? (yield* x.promise(() => e.store.update(N.tableName, t.runId, {
1099
1099
  status: "cancelled",
1100
1100
  cancelledAt: (/* @__PURE__ */ new Date()).toISOString()
1101
1101
  })), {
1102
1102
  runId: t.runId,
1103
1103
  status: "cancelled"
1104
- }) : yield* S.fail(new x({
1104
+ }) : yield* x.fail(new b({
1105
1105
  runId: t.runId,
1106
1106
  message: "run not found"
1107
1107
  }));
@@ -1110,14 +1110,14 @@ var N = ke("_voltro_ai_flows", {
1110
1110
  if (t !== void 0) return t.id;
1111
1111
  let n = e.currentStep;
1112
1112
  return typeof n == "number" ? n : 0;
1113
- }, Bt = (e, t) => S.gen(function* () {
1113
+ }, Bt = (e, t) => x.gen(function* () {
1114
1114
  let n = yield* $(e, t.runId);
1115
- if (!n) return yield* S.fail(new x({
1115
+ if (!n) return yield* x.fail(new b({
1116
1116
  runId: t.runId,
1117
1117
  message: "run not found"
1118
1118
  }));
1119
1119
  let r = n.status;
1120
- if (r !== "waiting") return yield* S.fail(new _e({
1120
+ if (r !== "waiting") return yield* x.fail(new ve({
1121
1121
  runId: t.runId,
1122
1122
  status: r ?? "unknown",
1123
1123
  message: `run is "${r}", not awaiting a response`
@@ -1126,31 +1126,31 @@ var N = ke("_voltro_ai_flows", {
1126
1126
  ...t.response,
1127
1127
  respondedAt: (/* @__PURE__ */ new Date()).toISOString()
1128
1128
  };
1129
- yield* S.promise(() => e.store.update(P.tableName, t.runId, { humanResponse: i }));
1129
+ yield* x.promise(() => e.store.update(N.tableName, t.runId, { humanResponse: i }));
1130
1130
  let a = e.workflows, o = n.requestId, s = zt(n);
1131
- return a && o && (yield* S.promise(() => a.signal({
1132
- workflowName: v,
1131
+ return a && o && (yield* x.promise(() => a.signal({
1132
+ workflowName: _,
1133
1133
  executionId: `flow-run:${o}`
1134
- }, y(s), i)).pipe(S.catchAllCause(() => S.void))), {
1134
+ }, v(s), i)).pipe(x.catchAllCause(() => x.void))), {
1135
1135
  runId: t.runId,
1136
1136
  stepIndex: s
1137
1137
  };
1138
- }), Vt = (e, t) => S.promise(() => e.store.query(D(N).where(w("id", t.id)).descriptor)).pipe(S.map((e) => e[0])), Ht = (e) => S.promise(() => e.store.query(D(N).descriptor)), Ut = (e, t) => S.promise(() => e.store.insert(N.tableName, {
1138
+ }), Vt = (e, t) => x.promise(() => e.store.query(E(M).where(C("id", t.id)).descriptor)).pipe(x.map((e) => e[0])), Ht = (e) => x.promise(() => e.store.query(E(M).descriptor)), Ut = (e, t) => x.promise(() => e.store.insert(M.tableName, {
1139
1139
  id: t.id ?? `flow-${Q()}`,
1140
1140
  ...t
1141
- })), Wt = (e, t) => S.promise(() => e.store.update(N.tableName, t.id, t.patch)), Gt = (e, t) => S.promise(() => e.store.delete(N.tableName, t.id)), Kt = "aiFlows", qt = (e = {}) => {
1142
- let t = we({
1141
+ })), Wt = (e, t) => x.promise(() => e.store.update(M.tableName, t.id, t.patch)), Gt = (e, t) => x.promise(() => e.store.delete(M.tableName, t.id)), Kt = "aiFlows", qt = (e = {}) => {
1142
+ let t = Te({
1143
1143
  base: Kt,
1144
1144
  alias: e.alias
1145
1145
  });
1146
- Je(e.humanReviewTimeoutMs === void 0 ? {} : { humanReviewTimeoutMs: e.humanReviewTimeoutMs }), Oe({
1146
+ Ye(e.humanReviewTimeoutMs === void 0 ? {} : { humanReviewTimeoutMs: e.humanReviewTimeoutMs }), ke({
1147
1147
  source: "plugin",
1148
- table: P.tableName,
1148
+ table: N.tableName,
1149
1149
  timeColumn: "createdAt",
1150
- ttlMs: e.runsTtlMs ?? Xe(process.env.VOLTRO_AI_FLOW_RUNS_TTL_HOURS, 2160),
1151
- envVar: Ge,
1150
+ ttlMs: e.runsTtlMs ?? Ze(process.env.VOLTRO_AI_FLOW_RUNS_TTL_HOURS, 2160),
1151
+ envVar: Ke,
1152
1152
  label: "ai flow runs",
1153
- where: De("status", [
1153
+ where: Oe("status", [
1154
1154
  "succeeded",
1155
1155
  "failed",
1156
1156
  "cancelled"
@@ -1163,7 +1163,7 @@ var N = ke("_voltro_ai_flows", {
1163
1163
  kind: "json",
1164
1164
  status: e,
1165
1165
  data: { error: t }
1166
- }), o = (e, t) => S.promise(async () => {
1166
+ }), o = (e, t) => x.promise(async () => {
1167
1167
  let n = r.current;
1168
1168
  if (!n) return a(503, "store not bound yet");
1169
1169
  let o = await n.query({
@@ -1179,7 +1179,7 @@ var N = ke("_voltro_ai_flows", {
1179
1179
  rows: o,
1180
1180
  take: t
1181
1181
  });
1182
- }).pipe(S.catchAllCause(() => S.succeed(a(500, "query failed")))), s = (e, t) => {
1182
+ }).pipe(x.catchAllCause(() => x.succeed(a(500, "query failed")))), s = (e, t) => {
1183
1183
  let r = /[?&]take=(\d+)/.exec(e)?.[1], i = r === void 0 ? t : Number(r);
1184
1184
  return Math.min(n, Math.max(1, Number.isFinite(i) ? i : t));
1185
1185
  }, c = [{
@@ -1193,12 +1193,12 @@ var N = ke("_voltro_ai_flows", {
1193
1193
  description: "List recent flow runs (`?take=` up to the configured max).",
1194
1194
  handler: (e) => o("_voltro_ai_flow_runs", s(e.url, Math.min(100, n)))
1195
1195
  }];
1196
- return Ce({
1196
+ return we({
1197
1197
  name: t,
1198
1198
  baseName: Kt,
1199
1199
  description: "AI Flows — durable multi-step AI pipelines (deterministic + agentic) with human-in-the-loop, chaining, and cadence. Code-first (defineFlow) or data-driven.",
1200
1200
  permissions: ["store:write", "inspect:read"],
1201
- ...e.tables === !1 ? {} : { extendSchema: { tables: Ve } },
1201
+ ...e.tables === !1 ? {} : { extendSchema: { tables: He } },
1202
1202
  inspectEndpoints: c,
1203
1203
  bindDataStore: (e) => {
1204
1204
  r.current = e;
@@ -1206,4 +1206,4 @@ var N = ke("_voltro_ai_flows", {
1206
1206
  });
1207
1207
  };
1208
1208
  //#endregion
1209
- export { ce as BriefField, re as ChainPending, a as ConditionOp, Ge as FLOW_RUNS_TTL_ENV, We as FLOW_RUNS_TTL_HOURS_DEFAULT, v as FLOW_RUN_WORKFLOW, oe as FlowCadence, g as FlowChain, l as FlowMode, ie as FlowStatus, se as FlowStep, me as HUMAN_RESPONSE_SIGNAL_PREFIX, Ue as HUMAN_REVIEW_TIMEOUT_ENV, He as HUMAN_REVIEW_TIMEOUT_HOURS_DEFAULT, d as HumanResponse, te as Json, Ke as MAX_CHAIN_DEPTH_DEFAULT, qe as MAX_CHAIN_DEPTH_ENV, le as MAX_STEPS_DEFAULT, f as MAX_STEPS_MAX, p as MAX_STEPS_MIN, ae as MediaInputSlot, ne as MediaInputs, h as Modality, m as ReviewMode, c as ReviewOption, ue as RunReview, pe as RunSource, u as RunStatus, fe as RunStep, o as RunStepStatus, ee as StepCondition, t as StepType, de as Visibility, P as aiFlowRunsTable, qt as aiFlowsPlugin, N as aiFlowsTable, Ve as aiFlowsTables, Ct as buildFlowRunExecute, xe as cadenceMatches, Rt as cancelFlow, s as clampMaxSteps, ot as clearRegistry, L as collectRefs, Ut as createFlow, Ot as cronRequestId, Dt as defineFlow, Gt as deleteFlow, e as describeCondition, _ as evaluateCondition, z as flowSegments, wt as flowStep, I as getAiFlowsDefaults, Vt as getFlow, it as getRegisteredFlow, y as humanResponseSignalName, R as interpolate, i as isTruthy, dt as jsonSchemaToEffectSchema, It as launchFlow, Ht as listFlows, at as listRegisteredFlows, Pt as makeMediaGenerator, be as nextRuns, nt as nonContiguousGroups, r as normalizeFlow, rt as registerFlow, Ye as resetAiFlowsDefaults, Qe as resolveHumanReviewTimeoutMs, X as resolveIr, $e as resolveMaxChainDepth, Bt as respondToFlow, Lt as retryFlow, At as runCadenceTick, n as sanitizeOutputKey, Je as setAiFlowsDefaults, tt as unresolvedRefs, Wt as updateFlow, Et as validateFlow, zt as waitingStepIndex };
1209
+ export { le as BriefField, ie as ChainPending, a as ConditionOp, Ke as FLOW_RUNS_TTL_ENV, Ge as FLOW_RUNS_TTL_HOURS_DEFAULT, _ as FLOW_RUN_WORKFLOW, se as FlowCadence, ee as FlowChain, l as FlowMode, ae as FlowStatus, ce as FlowStep, he as HUMAN_RESPONSE_SIGNAL_PREFIX, We as HUMAN_REVIEW_TIMEOUT_ENV, Ue as HUMAN_REVIEW_TIMEOUT_HOURS_DEFAULT, d as HumanResponse, ne as Json, qe as MAX_CHAIN_DEPTH_DEFAULT, Je as MAX_CHAIN_DEPTH_ENV, ue as MAX_STEPS_DEFAULT, f as MAX_STEPS_MAX, p as MAX_STEPS_MIN, oe as MediaInputSlot, re as MediaInputs, h as Modality, m as ReviewMode, c as ReviewOption, de as RunReview, me as RunSource, u as RunStatus, pe as RunStep, o as RunStepStatus, te as StepCondition, t as StepType, fe as Visibility, N as aiFlowRunsTable, qt as aiFlowsPlugin, M as aiFlowsTable, He as aiFlowsTables, wt as buildFlowRunExecute, Se as cadenceMatches, Rt as cancelFlow, s as clampMaxSteps, st as clearRegistry, I as collectRefs, Ut as createFlow, kt as cronRequestId, Ot as defineFlow, Gt as deleteFlow, e as describeCondition, g as evaluateCondition, R as flowSegments, Tt as flowStep, F as getAiFlowsDefaults, Vt as getFlow, at as getRegisteredFlow, v as humanResponseSignalName, L as interpolate, i as isTruthy, ft as jsonSchemaToEffectSchema, It as launchFlow, Ht as listFlows, ot as listRegisteredFlows, Pt as makeMediaGenerator, xe as nextRuns, rt as nonContiguousGroups, r as normalizeFlow, it as registerFlow, Xe as resetAiFlowsDefaults, $e as resolveHumanReviewTimeoutMs, Y as resolveIr, et as resolveMaxChainDepth, Bt as respondToFlow, Lt as retryFlow, jt as runCadenceTick, n as sanitizeOutputKey, Ye as setAiFlowsDefaults, nt as unresolvedRefs, Wt as updateFlow, Dt as validateFlow, zt as waitingStepIndex };