@voltro/plugin-ai-flows 0.75.0 → 0.76.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.
@@ -1,11 +1,11 @@
1
1
  import { Schema as e } from "effect";
2
- import { WorkflowRunHandleSchema as t } from "@voltro/protocol";
2
+ import { WorkflowControlResultSchema as t, WorkflowRunHandleSchema as n } from "@voltro/protocol";
3
3
  //#region src/condition.ts
4
- var n = e.Literal("truthy", "falsy", "eq", "neq", "contains"), r = e.Struct({
4
+ var r = e.Literal("truthy", "falsy", "eq", "neq", "contains"), i = e.Struct({
5
5
  ref: e.String,
6
- op: n,
6
+ op: r,
7
7
  value: e.optional(e.Unknown)
8
- }), i = (e) => e == null ? !1 : typeof e == "boolean" ? e : !Array.isArray(e) || e.length > 0, a = (e, t) => {
8
+ }), a = (e) => e == null ? !1 : typeof e == "boolean" ? e : !Array.isArray(e) || e.length > 0, o = (e, t) => {
9
9
  if (e === t) return !0;
10
10
  if (e === null || t === null || e === void 0 || t === void 0) return !1;
11
11
  if (typeof e == "object" || typeof t == "object") try {
@@ -14,21 +14,21 @@ var n = e.Literal("truthy", "falsy", "eq", "neq", "contains"), r = e.Struct({
14
14
  return !1;
15
15
  }
16
16
  return String(e) === String(t);
17
- }, o = (e, t) => {
17
+ }, s = (e, t) => {
18
18
  let n = t[e.ref];
19
19
  switch (e.op) {
20
- case "truthy": return i(n);
21
- case "falsy": return !i(n);
22
- case "eq": return a(n, e.value);
23
- case "neq": return !a(n, e.value);
20
+ case "truthy": return a(n);
21
+ case "falsy": return !a(n);
22
+ case "eq": return o(n, e.value);
23
+ case "neq": return !o(n, e.value);
24
24
  case "contains": {
25
25
  if (n == null) return !1;
26
- if (Array.isArray(n)) return n.some((t) => a(t, e.value));
26
+ if (Array.isArray(n)) return n.some((t) => o(t, e.value));
27
27
  let t = e.value;
28
28
  return typeof t != "string" && typeof t != "number" ? !1 : String(n).includes(String(t));
29
29
  }
30
30
  }
31
- }, s = (e) => {
31
+ }, c = (e) => {
32
32
  switch (e.op) {
33
33
  case "truthy": return `{{${e.ref}}} is set`;
34
34
  case "falsy": return `{{${e.ref}}} is not set`;
@@ -36,14 +36,30 @@ var n = e.Literal("truthy", "falsy", "eq", "neq", "contains"), r = e.Struct({
36
36
  case "neq": return `{{${e.ref}}} does not equal ${JSON.stringify(e.value)}`;
37
37
  case "contains": return `{{${e.ref}}} contains ${JSON.stringify(e.value)}`;
38
38
  }
39
- }, c = e.Struct({
39
+ }, l = e.Struct({
40
40
  runId: e.NonEmptyString,
41
41
  requestId: e.NonEmptyString,
42
- admission: t
43
- }), l = e.Literal("deterministic", "agentic"), u = e.Literal("draft", "active", "archived"), d = e.Literal("private", "organization", "shared"), f = e.Literal("pending", "running", "waiting", "succeeded", "failed", "cancelled"), p = e.Literal("manual", "cron"), m = e.Literal("agent", "generate", "structured", "note", "human"), h = e.Literal("text", "image", "video", "audio"), g = e.Literal("approve", "choice", "text"), _ = e.Struct({
42
+ admission: n
43
+ }), u = e.Literal("deterministic", "agentic"), d = e.Literal("draft", "active", "archived"), f = e.Literal("private", "organization", "shared"), p = e.Literal("pending", "running", "waiting", "succeeded", "failed", "cancelled"), m = e.Struct({
44
+ runId: e.NonEmptyString,
45
+ status: p,
46
+ engine: e.Literal("cancelled", "accepted", "unknown", "already-terminal", "unreachable", "not-requested"),
47
+ control: e.NullOr(t)
48
+ }).pipe(e.filter((e) => {
49
+ let t = e.control;
50
+ if (t !== null && t.operation !== "cancel") return !1;
51
+ switch (e.engine) {
52
+ case "cancelled": return t !== null && t.snapshot.status === "cancelled" && (t.kind === "confirmed" || t.kind === "already-terminal");
53
+ case "accepted": return t?.kind === "accepted";
54
+ case "already-terminal": return t?.kind === "already-terminal" && t.snapshot.status !== "cancelled";
55
+ case "unknown": return t === null || t.kind === "unknown";
56
+ case "unreachable":
57
+ case "not-requested": return t === null;
58
+ }
59
+ }, { message: () => "Flow cancellation acknowledgement contradicts its workflow control receipt" })), h = e.Literal("manual", "cron"), g = e.Literal("agent", "generate", "structured", "note", "human"), _ = e.Literal("text", "image", "video", "audio"), v = e.Literal("approve", "choice", "text"), y = e.Struct({
44
60
  value: e.String,
45
61
  label: e.String
46
- }), v = e.Union(e.Struct({
62
+ }), b = e.Union(e.Struct({
47
63
  from: e.Literal("upload"),
48
64
  url: e.String,
49
65
  mediaType: e.optional(e.NonEmptyString)
@@ -51,50 +67,50 @@ var n = e.Literal("truthy", "falsy", "eq", "neq", "contains"), r = e.Struct({
51
67
  from: e.Literal("step"),
52
68
  ref: e.String,
53
69
  artifact: e.optional(e.Int.pipe(e.nonNegative()))
54
- })), y = e.Record({
70
+ })), x = e.Record({
55
71
  key: e.String,
56
- value: v
57
- }), b = e.Record({
72
+ value: b
73
+ }), S = e.Record({
58
74
  key: e.String,
59
75
  value: e.Unknown
60
- }), x = e.Struct({
76
+ }), C = e.Struct({
61
77
  url: e.NonEmptyString,
62
78
  mediaType: e.NonEmptyString,
63
79
  role: e.NonEmptyString,
64
80
  storageRefId: e.optional(e.NonEmptyString),
65
81
  providerMetadata: e.optional(e.Unknown)
66
- }), S = e.Array(x).pipe(e.filter((e) => e.filter((e) => e.role === "primary").length === 1)), C = e.Struct({
82
+ }), w = e.Array(C).pipe(e.filter((e) => e.filter((e) => e.role === "primary").length === 1)), T = e.Struct({
67
83
  id: e.String,
68
84
  title: e.optional(e.String),
69
85
  description: e.optional(e.String),
70
- type: m,
86
+ type: g,
71
87
  outputKey: e.optional(e.String),
72
88
  prompt: e.optional(e.String),
73
- modality: e.optional(h),
89
+ modality: e.optional(_),
74
90
  model: e.optional(e.String),
75
- params: e.optional(b),
76
- mediaInputs: e.optional(y),
91
+ params: e.optional(S),
92
+ mediaInputs: e.optional(x),
77
93
  agentRef: e.optional(e.String),
78
- schema: e.optional(b),
79
- reviewMode: e.optional(g),
80
- options: e.optional(e.Array(_)),
81
- when: e.optional(r),
94
+ schema: e.optional(S),
95
+ reviewMode: e.optional(v),
96
+ options: e.optional(e.Array(y)),
97
+ when: e.optional(i),
82
98
  group: e.optional(e.String),
83
99
  timeoutMs: e.optional(e.Number)
84
- }), w = e.Struct({
100
+ }), E = e.Struct({
85
101
  key: e.String,
86
102
  label: e.String,
87
103
  type: e.Literal("text", "textarea", "number", "boolean"),
88
104
  required: e.optional(e.Boolean),
89
105
  placeholder: e.optional(e.String)
90
- }), T = e.Struct({
106
+ }), D = e.Struct({
91
107
  flowRef: e.String,
92
108
  mappings: e.Array(e.Struct({
93
109
  targetKey: e.String,
94
110
  sourceKey: e.String
95
111
  })),
96
112
  requireConfirmation: e.optional(e.Boolean)
97
- }), E = e.Struct({
113
+ }), O = e.Struct({
98
114
  frequency: e.optional(e.Literal("weekly", "monthly")),
99
115
  repeats: e.Array(e.Number),
100
116
  intervalWeeks: e.optional(e.Number),
@@ -102,62 +118,62 @@ var n = e.Literal("truthy", "falsy", "eq", "neq", "contains"), r = e.Struct({
102
118
  weekOfMonth: e.optional(e.Union(e.Literal(1, 2, 3, 4), e.Literal("last"))),
103
119
  hour: e.optional(e.Number),
104
120
  minute: e.optional(e.Literal(0, 15, 30, 45)),
105
- defaultInput: e.optional(b)
106
- }), D = e.Literal("pending", "running", "waiting", "succeeded", "failed", "skipped"), O = e.Struct({
107
- mode: g,
108
- options: e.optional(e.Array(_)),
121
+ defaultInput: e.optional(S)
122
+ }), k = e.Literal("pending", "running", "waiting", "succeeded", "failed", "skipped"), A = e.Struct({
123
+ mode: v,
124
+ options: e.optional(e.Array(y)),
109
125
  prompt: e.String
110
- }), k = e.Literal("gateway", "estimated", "unpriced"), A = e.Literal("actual", "estimated", "incomplete", "unknown"), j = e.Struct({
126
+ }), j = e.Literal("gateway", "estimated", "unpriced"), M = e.Literal("actual", "estimated", "incomplete", "unknown"), N = e.Struct({
111
127
  status: e.Literal("reported", "unreported"),
112
128
  unit: e.optional(e.Literal("tokens", "characters", "seconds")),
113
129
  input: e.optional(e.Finite.pipe(e.nonNegative())),
114
130
  output: e.optional(e.Finite.pipe(e.nonNegative()))
115
- }), M = e.Struct({
131
+ }), P = e.Struct({
116
132
  costMicroUsd: e.optional(e.Finite.pipe(e.nonNegative())),
117
- costSource: e.optional(k),
133
+ costSource: e.optional(j),
118
134
  requestId: e.optional(e.NonEmptyString),
119
- usage: e.optional(j)
120
- }), N = e.Struct({
135
+ usage: e.optional(N)
136
+ }), F = e.Struct({
121
137
  id: e.Number,
122
138
  title: e.String,
123
139
  description: e.optional(e.String),
124
- type: m,
125
- status: D,
140
+ type: g,
141
+ status: k,
126
142
  startedAt: e.optional(e.String),
127
143
  completedAt: e.optional(e.String),
128
144
  costMicroUsd: e.optional(e.Number),
129
- costSource: e.optional(k),
145
+ costSource: e.optional(j),
130
146
  requestId: e.optional(e.String),
131
- usage: e.optional(j),
147
+ usage: e.optional(N),
132
148
  url: e.optional(e.String),
133
- artifacts: e.optional(S),
149
+ artifacts: e.optional(w),
134
150
  output: e.optional(e.Struct({ text: e.String })),
135
151
  errorMessage: e.optional(e.String),
136
152
  skipReason: e.optional(e.String),
137
- review: e.optional(O)
138
- }), P = e.Struct({
153
+ review: e.optional(A)
154
+ }), I = e.Struct({
139
155
  decision: e.optional(e.Literal("approve", "reject")),
140
156
  value: e.optional(e.String),
141
157
  text: e.optional(e.String),
142
158
  respondedAt: e.optional(e.String)
143
- }), F = e.Struct({
159
+ }), L = e.Struct({
144
160
  runId: e.NonEmptyString,
145
161
  stepIndex: e.Int.pipe(e.nonNegative()),
146
- response: P
147
- }), I = e.Struct({
162
+ response: I
163
+ }), R = e.Struct({
148
164
  runId: e.NonEmptyString,
149
165
  stepIndex: e.Int.pipe(e.nonNegative()),
150
166
  executionId: e.NonEmptyString,
151
167
  eventId: e.NonEmptyString,
152
168
  status: e.Literal("accepted")
153
- }), L = e.Struct({
169
+ }), z = e.Struct({
154
170
  flowRef: e.String,
155
- input: b,
171
+ input: S,
156
172
  status: e.Literal("pending", "confirmed", "dismissed")
157
- }), R = 30, z = 1, B = 100, V = (e) => e == null || !Number.isFinite(e) ? 30 : Math.min(100, Math.max(1, Math.trunc(e))), H = (e) => e.replace(/[^\w.-]/g, "_"), U = (e) => {
173
+ }), B = 30, V = 1, H = 100, U = (e) => e == null || !Number.isFinite(e) ? 30 : Math.min(100, Math.max(1, Math.trunc(e))), W = (e) => e.replace(/[^\w.-]/g, "_"), G = (e) => {
158
174
  let t = (e.steps ?? []).map((e) => e.outputKey ? {
159
175
  ...e,
160
- outputKey: H(e.outputKey)
176
+ outputKey: W(e.outputKey)
161
177
  } : e), n = e.orchestratorModel || e.orchestratorInstructions ? {
162
178
  ...e.orchestratorModel ? { model: e.orchestratorModel } : {},
163
179
  ...e.orchestratorInstructions ? { instructions: e.orchestratorInstructions } : {}
@@ -166,7 +182,7 @@ var n = e.Literal("truthy", "falsy", "eq", "neq", "contains"), r = e.Struct({
166
182
  name: e.name,
167
183
  mode: e.mode ?? "deterministic",
168
184
  steps: t,
169
- maxSteps: V(e.maxSteps),
185
+ maxSteps: U(e.maxSteps),
170
186
  brief: e.brief ?? [],
171
187
  ...n ? { orchestrator: n } : {},
172
188
  ...e.chain ? { chain: e.chain } : {},
@@ -175,4 +191,4 @@ var n = e.Literal("truthy", "falsy", "eq", "neq", "contains"), r = e.Struct({
175
191
  };
176
192
  };
177
193
  //#endregion
178
- export { D as A, o as B, h as C, p as D, O as E, U as F, H as I, n as L, j as M, d as N, f as O, V as P, r as R, M as S, _ as T, i as V, z as _, E as a, v as b, F as c, u as d, C as f, B as g, R as h, k as i, m as j, N as k, I as l, b as m, L as n, T as o, P as p, A as r, l as s, w as t, c as u, x as v, g as w, y as x, S as y, s as z };
194
+ export { F as A, c as B, P as C, A as D, y as E, U as F, a as H, G as I, W as L, g as M, N, h as O, f as P, r as R, x as S, v as T, s as V, H as _, O as a, w as b, u as c, l as d, d as f, B as g, S as h, j as i, k as j, p as k, L as l, I as m, z as n, m as o, T as p, M as r, D as s, E as t, R as u, V as v, _ as w, b as x, C as y, i as z };
package/dist/ir.d.ts CHANGED
@@ -105,6 +105,32 @@ export declare interface FlowCadence {
105
105
  readonly defaultInput?: Json | undefined;
106
106
  }
107
107
 
108
+ /** Row state and engine acknowledgement are separate observations. Retain the
109
+ * control request identity so an accepted/unknown request can be observed. */
110
+ export declare const FlowCancelReceipt: Schema.filter<Schema.Struct<{
111
+ runId: typeof Schema.NonEmptyString;
112
+ status: Schema.Literal<["pending", "running", "waiting", "succeeded", "failed", "cancelled"]>;
113
+ engine: Schema.Literal<["cancelled", "accepted", "unknown", "already-terminal", "unreachable", "not-requested"]>;
114
+ control: Schema.NullOr<Schema.filter<Schema.Struct<{
115
+ operation: Schema.Literal<["cancel", "resume"]>;
116
+ kind: Schema.Literal<["accepted", "confirmed", "unknown", "already-terminal"]>;
117
+ requestId: Schema.NullOr<typeof Schema.NonEmptyString>;
118
+ snapshot: Schema.Struct<{
119
+ id: typeof Schema.String;
120
+ workflowName: typeof Schema.String;
121
+ executionId: typeof Schema.String;
122
+ status: Schema.Union<[Schema.Literal<["running", "succeeded", "failed", "cancelled", "suspended"]>, Schema.Literal<["unknown"]>]>;
123
+ output: Schema.optional<typeof Schema.Unknown>;
124
+ error: Schema.optional<Schema.Struct<{
125
+ tag: Schema.NullOr<typeof Schema.String>;
126
+ message: typeof Schema.String;
127
+ }>>;
128
+ }>;
129
+ }>>>;
130
+ }>>;
131
+
132
+ export declare type FlowCancelReceipt = typeof FlowCancelReceipt.Type;
133
+
108
134
  /** Follow-up flow spec. On success, map source → the child's brief. */
109
135
  export declare const FlowChain: Schema.Struct<{
110
136
  /** Child flow id (data) or name (code). */
package/dist/ir.js CHANGED
@@ -1,2 +1,2 @@
1
- import { A as e, B as t, C as n, D as r, E as i, F as a, I as o, L as s, M as c, N as l, O as u, P as d, R as f, S as p, T as m, V as h, _ as g, a as _, b as v, c as y, d as b, f as x, g as S, h as C, i as w, j as T, k as E, l as D, m as O, n as k, o as A, p as j, r as M, s as N, t as P, u as F, v as I, w as L, x as R, y as z, z as B } from "./ir-C2ewescS.js";
2
- export { P as BriefField, k as ChainPending, s as ConditionOp, M as CostCompleteness, w as CostSource, _ as FlowCadence, A as FlowChain, N as FlowMode, y as FlowReviewInput, D as FlowReviewReceipt, F as FlowStartReceipt, b as FlowStatus, x as FlowStep, j as HumanResponse, O as Json, C as MAX_STEPS_DEFAULT, S as MAX_STEPS_MAX, g as MAX_STEPS_MIN, I as MediaArtifact, z as MediaArtifacts, v as MediaInputSlot, R as MediaInputs, p as MediaReceipt, n as Modality, L as ReviewMode, m as ReviewOption, i as RunReview, r as RunSource, u as RunStatus, E as RunStep, e as RunStepStatus, f as StepCondition, T as StepType, c as StepUsage, l as Visibility, d as clampMaxSteps, B as describeCondition, t as evaluateCondition, h as isTruthy, a as normalizeFlow, o as sanitizeOutputKey };
1
+ import { A as e, B as t, C as n, D as r, E as i, F as a, H as o, I as s, L as c, M as l, N as u, O as d, P as f, R as p, S as m, T as h, V as g, _, a as v, b as y, c as b, d as x, f as S, g as C, h as w, i as T, j as E, k as D, l as O, m as k, n as A, o as j, p as M, r as N, s as P, t as F, u as I, v as L, w as R, x as z, y as B, z as V } from "./ir-BW5JRUiH.js";
2
+ export { F as BriefField, A as ChainPending, p as ConditionOp, N as CostCompleteness, T as CostSource, v as FlowCadence, j as FlowCancelReceipt, P as FlowChain, b as FlowMode, O as FlowReviewInput, I as FlowReviewReceipt, x as FlowStartReceipt, S as FlowStatus, M as FlowStep, k as HumanResponse, w as Json, C as MAX_STEPS_DEFAULT, _ as MAX_STEPS_MAX, L as MAX_STEPS_MIN, B as MediaArtifact, y as MediaArtifacts, z as MediaInputSlot, m as MediaInputs, n as MediaReceipt, R as Modality, h as ReviewMode, i as ReviewOption, r as RunReview, d as RunSource, D as RunStatus, e as RunStep, E as RunStepStatus, V as StepCondition, l as StepType, u as StepUsage, f as Visibility, a as clampMaxSteps, t as describeCondition, g as evaluateCondition, o as isTruthy, s as normalizeFlow, c as sanitizeOutputKey };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@voltro/plugin-ai-flows",
3
- "version": "0.75.0",
3
+ "version": "0.76.0",
4
4
  "description": "AI Flows — durable multi-step AI pipelines (deterministic + agentic) with human-in-the-loop, chaining, and cadence. Author flows in code (defineFlow) or as data (visual editor rows); one engine runs both on @voltro/workflow durability, @voltro/ai generation, storage artifacts, and notifications.",
5
5
  "keywords": [
6
6
  "voltro",
@@ -58,19 +58,19 @@
58
58
  "node": ">=24.0.0"
59
59
  },
60
60
  "dependencies": {
61
- "@voltro/ai": "0.75.0",
62
- "@voltro/client": "0.75.0",
63
- "@voltro/database": "0.75.0",
64
- "@voltro/env": "0.75.0",
65
- "@voltro/plugin-audit": "0.75.0",
66
- "@voltro/plugin-multitenancy": "0.75.0",
67
- "@voltro/plugin-soft-delete": "0.75.0",
68
- "@voltro/protocol": "0.75.0",
69
- "@voltro/runtime": "0.75.0",
70
- "@voltro/workflow": "0.75.0"
61
+ "@voltro/ai": "0.76.0",
62
+ "@voltro/client": "0.76.0",
63
+ "@voltro/database": "0.76.0",
64
+ "@voltro/env": "0.76.0",
65
+ "@voltro/plugin-audit": "0.76.0",
66
+ "@voltro/plugin-multitenancy": "0.76.0",
67
+ "@voltro/plugin-soft-delete": "0.76.0",
68
+ "@voltro/protocol": "0.76.0",
69
+ "@voltro/runtime": "0.76.0",
70
+ "@voltro/workflow": "0.76.0"
71
71
  },
72
72
  "peerDependencies": {
73
- "effect": "^3.22.1"
73
+ "effect": "^3.22.2"
74
74
  },
75
75
  "publishConfig": {
76
76
  "access": "public"