@voltro/ai 0.82.0 → 0.83.1

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.
@@ -87,7 +87,33 @@ var u = [], d = (...e) => {
87
87
  return r.doStart(n);
88
88
  };
89
89
  return new Proxy(n, { get: (e, t) => t === "doGenerate" ? r : t === "doStart" ? a : _(e, t) });
90
- }, b = {
90
+ }, b = 134217728, x = (e, t = process.env) => {
91
+ if (e !== void 0) return e;
92
+ let n = Number(t.VOLTRO_AI_MEDIA_MAX_RESPONSE_BYTES);
93
+ return Number.isFinite(n) && n > 0 ? Math.floor(n) : b;
94
+ }, S = (e) => `gateway media response exceeded maxResponseBytes (${e}); it was not read further. Raise \`maxResponseBytes\` on the gateway provider config, or VOLTRO_AI_MEDIA_MAX_RESPONSE_BYTES.`, C = (e) => Response.json({ error: {
95
+ message: S(e),
96
+ type: "response_too_large"
97
+ } }, { status: 413 }), w = async (e, t) => {
98
+ let n = Number(e.headers.get("content-length"));
99
+ if (Number.isFinite(n) && n > t) return e.body?.cancel(), C(t);
100
+ if (e.body === null) return e;
101
+ let r = e.body.getReader(), i = [], a = 0;
102
+ for (;;) {
103
+ let { done: e, value: n } = await r.read();
104
+ if (e) break;
105
+ if (a += n.byteLength, a > t) return r.cancel(), C(t);
106
+ i.push(new Uint8Array(n));
107
+ }
108
+ return new Response(new Blob(i), {
109
+ status: e.status,
110
+ statusText: e.statusText,
111
+ headers: e.headers
112
+ });
113
+ }, T = (e, t) => ({
114
+ ...e,
115
+ fetch: async (n, r) => w(await (e.fetch ?? globalThis.fetch)(n, r), t)
116
+ }), E = {
91
117
  inputTokens: {
92
118
  total: 0,
93
119
  noCache: 0,
@@ -99,10 +125,10 @@ var u = [], d = (...e) => {
99
125
  text: 0,
100
126
  reasoning: 0
101
127
  }
102
- }, x = (e) => ({
128
+ }, D = (e) => ({
103
129
  unified: e,
104
130
  raw: void 0
105
- }), S = class {
131
+ }), O = class {
106
132
  turns;
107
133
  cursor = 0;
108
134
  calls = [];
@@ -122,12 +148,12 @@ var u = [], d = (...e) => {
122
148
  reset() {
123
149
  this.cursor = 0, this.calls.length = 0;
124
150
  }
125
- }, C = (e) => (e.toolCalls ?? []).map((e, t) => ({
151
+ }, k = (e) => (e.toolCalls ?? []).map((e, t) => ({
126
152
  type: "tool-call",
127
153
  toolCallId: `mock_tool_${t}`,
128
154
  toolName: e.name,
129
155
  input: JSON.stringify(e.input ?? {})
130
- })), w = (e) => (e.sources ?? []).map((e, t) => e.sourceType === "document" ? {
156
+ })), A = (e) => (e.sources ?? []).map((e, t) => e.sourceType === "document" ? {
131
157
  type: "source",
132
158
  sourceType: "document",
133
159
  id: e.id ?? `mock_src_${t}`,
@@ -140,14 +166,14 @@ var u = [], d = (...e) => {
140
166
  id: e.id ?? `mock_src_${t}`,
141
167
  url: e.url ?? "https://example.com",
142
168
  ...e.title === void 0 ? {} : { title: e.title }
143
- }), T = (e) => (e.files ?? []).map((e) => ({
169
+ }), j = (e) => (e.files ?? []).map((e) => ({
144
170
  type: "file",
145
171
  mediaType: e.mediaType,
146
172
  data: {
147
173
  type: "data",
148
174
  data: e.data
149
175
  }
150
- })), E = (e) => [
176
+ })), M = (e) => [
151
177
  {
152
178
  type: "text-start",
153
179
  id: "0"
@@ -161,7 +187,7 @@ var u = [], d = (...e) => {
161
187
  type: "text-end",
162
188
  id: "0"
163
189
  }
164
- ], D = (e) => e.length === 0 ? [] : [
190
+ ], N = (e) => e.length === 0 ? [] : [
165
191
  {
166
192
  type: "reasoning-start",
167
193
  id: "r0"
@@ -175,7 +201,7 @@ var u = [], d = (...e) => {
175
201
  type: "reasoning-end",
176
202
  id: "r0"
177
203
  }
178
- ], O = (e, t, n, r) => ({
204
+ ], P = (e, t, n, r) => ({
179
205
  specificationVersion: "v4",
180
206
  provider: "mock",
181
207
  modelId: e,
@@ -192,16 +218,16 @@ var u = [], d = (...e) => {
192
218
  toolName: e.name,
193
219
  input: JSON.stringify(e.input ?? {})
194
220
  })),
195
- finishReason: x("tool-calls"),
196
- usage: b,
221
+ finishReason: D("tool-calls"),
222
+ usage: E,
197
223
  warnings: []
198
224
  } : {
199
225
  content: [{
200
226
  type: "text",
201
227
  text: o?.text ?? t ?? `[mock(${e})] ${s}`
202
228
  }],
203
- finishReason: x("stop"),
204
- usage: b,
229
+ finishReason: D("stop"),
230
+ usage: E,
205
231
  warnings: [],
206
232
  ...r === void 0 ? {} : { providerMetadata: r }
207
233
  };
@@ -217,18 +243,18 @@ var u = [], d = (...e) => {
217
243
  error: Error(i.error.message)
218
244
  }), s.push({
219
245
  type: "finish",
220
- finishReason: x("error"),
221
- usage: b
222
- })) : (s.push(...D(i?.reasoning ?? "")), o.length > 0 && s.push(...E(o)), s.push(...w(i ?? {})), s.push(...T(i ?? {})), s.push(...C(i ?? {})), s.push({
246
+ finishReason: D("error"),
247
+ usage: E
248
+ })) : (s.push(...N(i?.reasoning ?? "")), o.length > 0 && s.push(...M(o)), s.push(...A(i ?? {})), s.push(...j(i ?? {})), s.push(...k(i ?? {})), s.push({
223
249
  type: "finish",
224
- finishReason: x(a ? "tool-calls" : "stop"),
225
- usage: b
250
+ finishReason: D(a ? "tool-calls" : "stop"),
251
+ usage: E
226
252
  })), { stream: new ReadableStream({ start(e) {
227
253
  for (let t of s) e.enqueue(t);
228
254
  e.close();
229
255
  } }) };
230
256
  }
231
- }), k = "iVBORw0KGgo=", A = "SUQzBAAAAAAAAA==", j = "video/mp4", M = "mock transcript", N = (e, t) => ({
257
+ }), F = "iVBORw0KGgo=", I = "SUQzBAAAAAAAAA==", L = "video/mp4", R = "mock transcript", z = (e, t) => ({
232
258
  specificationVersion: "v4",
233
259
  provider: "mock",
234
260
  modelId: e,
@@ -247,7 +273,7 @@ var u = [], d = (...e) => {
247
273
  totalTokens: 0
248
274
  }
249
275
  })
250
- }), P = (e, t, n) => ({
276
+ }), B = (e, t, n) => ({
251
277
  specificationVersion: "v4",
252
278
  provider: "mock",
253
279
  modelId: e,
@@ -260,7 +286,7 @@ var u = [], d = (...e) => {
260
286
  },
261
287
  ...n === void 0 ? {} : { providerMetadata: n }
262
288
  })
263
- }), F = (e, t, n) => ({
289
+ }), V = (e, t, n) => ({
264
290
  specificationVersion: "v4",
265
291
  provider: "mock",
266
292
  modelId: e,
@@ -278,7 +304,7 @@ var u = [], d = (...e) => {
278
304
  },
279
305
  ...n === void 0 ? {} : { providerMetadata: n }
280
306
  })
281
- }), I = (e, t, n) => ({
307
+ }), H = (e, t, n) => ({
282
308
  specificationVersion: "v4",
283
309
  provider: "mock",
284
310
  modelId: e,
@@ -293,67 +319,67 @@ var u = [], d = (...e) => {
293
319
  },
294
320
  ...n === void 0 ? {} : { providerMetadata: n }
295
321
  })
296
- }), L = (e) => e.apiKey !== void 0 || e.baseURL !== void 0, R = (e) => ({
322
+ }), U = (e) => e.apiKey !== void 0 || e.baseURL !== void 0, W = (e) => ({
297
323
  ...e.apiKey === void 0 ? {} : { apiKey: e.apiKey },
298
324
  ...e.baseURL === void 0 ? {} : { baseURL: e.baseURL }
299
- }), z = (o, s) => m((() => {
325
+ }), G = (o, s) => m((() => {
300
326
  switch (o.name) {
301
- case "mock": return O(o.model ?? "mock", o.mockText, o.script, o.providerMetadata);
302
- case "anthropic": return L(o) ? t(R(o))(o.model) : e(o.model);
303
- case "openai": return L(o) ? n(R(o))(o.model) : r(o.model);
304
- case "gateway": return L(o) ? i(R(o))(o.model) : a(o.model);
327
+ case "mock": return P(o.model ?? "mock", o.mockText, o.script, o.providerMetadata);
328
+ case "anthropic": return U(o) ? t(W(o))(o.model) : e(o.model);
329
+ case "openai": return U(o) ? n(W(o))(o.model) : r(o.model);
330
+ case "gateway": return U(o) ? i(W(o))(o.model) : a(o.model);
305
331
  }
306
- })(), s), B = (e) => {
332
+ })(), s), K = (e) => {
307
333
  switch (e.name) {
308
- case "mock": return N(e.model ?? "mock", e.mockMedia?.imageBase64 ?? k);
309
- case "openai": return L(e) ? n(R(e)).image(e.model) : r.image(e.model);
310
- case "gateway": return v(R(e), e.model);
334
+ case "mock": return z(e.model ?? "mock", e.mockMedia?.imageBase64 ?? F);
335
+ case "openai": return U(e) ? n(W(e)).image(e.model) : r.image(e.model);
336
+ case "gateway": return v(T(W(e), x(e.maxResponseBytes)), e.model);
311
337
  case "anthropic": throw Error("Provider 'anthropic' does not support image generation. Use 'openai' or 'gateway'.");
312
338
  }
313
- }, V = (e) => {
339
+ }, q = (e) => {
314
340
  switch (e.name) {
315
- case "mock": return P(e.model ?? "mock", e.mockMedia?.audioBase64 ?? A, e.providerMetadata);
316
- case "openai": return L(e) ? n(R(e)).speech(e.model) : r.speech(e.model);
317
- case "gateway": return L(e) ? i(R(e)).speech(e.model) : a.speech(e.model);
341
+ case "mock": return B(e.model ?? "mock", e.mockMedia?.audioBase64 ?? I, e.providerMetadata);
342
+ case "openai": return U(e) ? n(W(e)).speech(e.model) : r.speech(e.model);
343
+ case "gateway": return i(T(W(e), x(e.maxResponseBytes))).speech(e.model);
318
344
  case "anthropic": throw Error("Provider 'anthropic' does not support speech generation. Use 'openai' or 'gateway'.");
319
345
  }
320
- }, H = (e) => {
346
+ }, J = (e) => {
321
347
  switch (e.name) {
322
- case "mock": return F(e.model ?? "mock", e.mockMedia?.transcript ?? M, e.providerMetadata);
323
- case "openai": return L(e) ? n(R(e)).transcription(e.model) : r.transcription(e.model);
324
- case "gateway": return L(e) ? i(R(e)).transcription(e.model) : a.transcription(e.model);
348
+ case "mock": return V(e.model ?? "mock", e.mockMedia?.transcript ?? R, e.providerMetadata);
349
+ case "openai": return U(e) ? n(W(e)).transcription(e.model) : r.transcription(e.model);
350
+ case "gateway": return i(T(W(e), x(e.maxResponseBytes))).transcription(e.model);
325
351
  case "anthropic": throw Error("Provider 'anthropic' does not support transcription. Use 'openai' or 'gateway'.");
326
352
  }
327
- }, U = (e) => {
353
+ }, Y = (e) => {
328
354
  switch (e.name) {
329
355
  case "mock": {
330
356
  let t = e.mockMedia, n = t?.videoBase64 === void 0 ? {
331
357
  type: "url",
332
358
  url: t?.videoUrl ?? `https://mock.local/${e.model ?? "mock"}.mp4`,
333
- mediaType: j
359
+ mediaType: L
334
360
  } : {
335
361
  type: "base64",
336
362
  data: t.videoBase64,
337
- mediaType: j
363
+ mediaType: L
338
364
  };
339
- return I(e.model ?? "mock", n, e.providerMetadata);
365
+ return H(e.model ?? "mock", n, e.providerMetadata);
340
366
  }
341
- case "gateway": return y(R(e), e.model);
367
+ case "gateway": return y(T(W(e), x(e.maxResponseBytes)), e.model);
342
368
  case "openai": throw Error("Provider 'openai' does not support video generation. Use 'gateway'.");
343
369
  case "anthropic": throw Error("Provider 'anthropic' does not support video generation. Use 'gateway'.");
344
370
  }
345
- }, W = null, G = (e) => {
346
- let t = W;
347
- return W = e, t;
348
- }, K = () => W, q = (e) => {
371
+ }, X = null, Z = (e) => {
372
+ let t = X;
373
+ return X = e, t;
374
+ }, Q = () => X, $ = (e) => {
349
375
  switch (e.toLowerCase()) {
350
376
  case "anthropic": return "ANTHROPIC_API_KEY";
351
377
  case "openai": return "OPENAI_API_KEY";
352
378
  case "gateway": return "AI_GATEWAY_API_KEY";
353
379
  default: return;
354
380
  }
355
- }, J = (e = process.env) => {
356
- if (W) return W;
381
+ }, ee = (e = process.env) => {
382
+ if (X) return X;
357
383
  let t = (e.AI_PROVIDER ?? "mock").toLowerCase(), n = e.AI_MODEL;
358
384
  switch (t) {
359
385
  case "mock": return {
@@ -380,4 +406,4 @@ var u = [], d = (...e) => {
380
406
  }
381
407
  };
382
408
  //#endregion
383
- export { d as _, B as a, H as c, m as d, p as f, h as g, f as h, q as i, U as l, s as m, K as n, z as o, o as p, J as r, V as s, S as t, G as u, c as v };
409
+ export { d as _, K as a, J as c, m as d, p as f, h as g, f as h, $ as i, Y as l, s as m, Q as n, G as o, o as p, ee as r, q as s, O as t, Z as u, c as v };
package/dist/test.js CHANGED
@@ -1,4 +1,4 @@
1
- import { t as e, u as t } from "./provider-BsyDya-H.js";
1
+ import { t as e, u as t } from "./provider-BnemgE4D.js";
2
2
  //#region src/test/index.ts
3
3
  var n = (e) => e.turns && e.turns.length > 0 ? e.turns : e.stream && e.stream.length > 0 ? [{ text: e.stream.join("") }] : e.generate ? [{ text: e.generate.text }] : [{ text: "" }], r = (t) => {
4
4
  let r = new e(n(t));
@@ -486,6 +486,11 @@ declare type ProviderConfig = {
486
486
  readonly model: GatewayModel;
487
487
  readonly apiKey?: string;
488
488
  readonly baseURL?: string;
489
+ /** Media calls only (image, video, speech, transcription): the largest
490
+ * response read, in bytes — refused before reading when declared, cut
491
+ * off while streaming otherwise. Default `VOLTRO_AI_MEDIA_MAX_RESPONSE_BYTES`,
492
+ * else 128 MiB. */
493
+ readonly maxResponseBytes?: number;
489
494
  };
490
495
 
491
496
  /**
package/dist/workflow.js CHANGED
@@ -1,17 +1,17 @@
1
- import { r as e } from "./provider-BsyDya-H.js";
2
- import { D as t, O as n, T as r, V as i, b as a, k as o, m as s, o as c, p as l, q as u, rt as d, s as f, t as p, y as m } from "./inferenceQueue-ita1Kn2m.js";
1
+ import { r as e } from "./provider-BnemgE4D.js";
2
+ import { D as t, O as n, T as r, V as i, b as a, k as o, m as s, o as c, p as l, q as u, rt as d, s as f, t as p, y as m } from "./inferenceQueue-BKq11Jrt.js";
3
3
  import { Effect as h, Schema as g } from "effect";
4
4
  import { eq as _ } from "@voltro/database";
5
- import { BudgetHoldExpired as v, CurrentWorkflowExecutionId as y, awaitSignalSuspending as b, step as x, suspendForBudget as S } from "@voltro/workflow";
5
+ import { BudgetHoldExpired as v, CurrentWorkflowExecutionId as y, SuspensionUnavailable as b, WorkflowCannotPark as x, awaitSignalSuspending as S, step as C, suspendForBudget as w } from "@voltro/workflow";
6
6
  //#region src/inferStep.ts
7
- var C = {
7
+ var T = {
8
8
  maxAttempts: 4,
9
9
  strategy: "exponential",
10
10
  baseDelay: "1 second",
11
11
  maxDelay: "30 seconds",
12
12
  jitter: !0,
13
13
  respectRetryAfter: !0
14
- }, w = 36e5, T = "ai-usd", E = (e, t, n, r) => {
14
+ }, E = 36e5, D = "ai-usd", O = (e, t, n, r) => {
15
15
  let i = r === void 0 ? {} : {
16
16
  promptId: r.promptId,
17
17
  promptVersion: r.digest,
@@ -31,7 +31,7 @@ var C = {
31
31
  systemChars: t.length
32
32
  }
33
33
  };
34
- }, D = (e) => l(e.prompt) ? {
34
+ }, k = (e) => l(e.prompt) ? {
35
35
  text: e.prompt.prompt,
36
36
  system: e.system ?? e.prompt.system,
37
37
  rendered: e.prompt
@@ -39,13 +39,13 @@ var C = {
39
39
  text: e.prompt,
40
40
  system: e.system,
41
41
  rendered: void 0
42
- }, O = (e) => ({
42
+ }, A = (e) => ({
43
43
  provider: String(e.name),
44
44
  model: String(e.model ?? "unknown")
45
- }), k = (e, t, n, r, a) => {
45
+ }), j = (e, t, n, r, a) => {
46
46
  let o = e.store;
47
47
  if (o === void 0) return h.void;
48
- let { provider: s, model: c } = O(t), l = i(r.providerMetadata);
48
+ let { provider: s, model: c } = A(t), l = i(r.providerMetadata);
49
49
  return u(o, {
50
50
  provider: s,
51
51
  model: c,
@@ -56,33 +56,33 @@ var C = {
56
56
  ...l === void 0 ? {} : { actualCostUsd: l },
57
57
  ...a === void 0 ? {} : { prompt: a }
58
58
  });
59
- }, A = (e, t) => {
59
+ }, M = (e, t) => {
60
60
  let n = e.store;
61
61
  return n === void 0 || t === void 0 ? h.void : m(n, {
62
62
  ...t.definition,
63
63
  digest: t.digest
64
64
  }).pipe(h.asVoid, h.catchAllCause(() => h.void));
65
- }, j = g.Struct({
65
+ }, N = g.Struct({
66
66
  text: g.String,
67
67
  inputTokens: g.NullOr(g.Number),
68
68
  outputTokens: g.NullOr(g.Number),
69
69
  totalTokens: g.NullOr(g.Number)
70
- }), M = (e) => typeof e == "object" && !!e && e.__voltro_ai_error === !0, N = class extends Error {
70
+ }), P = (e) => typeof e == "object" && !!e && e.__voltro_ai_error === !0, F = class extends Error {
71
71
  attempts;
72
72
  outcome;
73
73
  constructor(e, t, n, r = "failed") {
74
74
  super(`aiStep('${e}'): the offloaded model call gave up after ${n} attempt(s): ${t}. The queued call is in _voltro_ai_inferences with status 'failed' — the Flow tab shows it with the provider's own message.`), this.name = "AiOffloadError", this.attempts = n, this.outcome = r;
75
75
  }
76
- }, P = class extends Error {
76
+ }, I = class extends Error {
77
77
  constructor(e) {
78
78
  super(`aiStep('${e}'): offload: true needs \`store\` — the queued call lives in a table and the dispatcher reads it from there. Pass ctx.store.`), this.name = "AiOffloadMisuseError";
79
79
  }
80
- }, F = (e, t, n, r, i, a, o) => h.gen(function* () {
80
+ }, L = (e, t, n, r, i, a, o) => h.gen(function* () {
81
81
  let s = e.store;
82
- if (s === void 0) return yield* h.die(new P(e.name));
82
+ if (s === void 0) return yield* h.die(new I(e.name));
83
83
  let l = yield* y;
84
84
  if (l === void 0) return yield* h.die(/* @__PURE__ */ Error(`aiStep('${e.name}'): offload: true is only valid inside a workflow body — there is no execution to suspend here.`));
85
- let { provider: u, model: d } = O(t), m = f(l, e.name), g = yield* h.promise(() => s.query({
85
+ let { provider: u, model: d } = A(t), m = f(l, e.name), g = yield* h.promise(() => s.query({
86
86
  table: "_voltro_workflow_runs",
87
87
  predicate: _("executionId", l),
88
88
  order: [],
@@ -117,29 +117,31 @@ var C = {
117
117
  queuedAt: x,
118
118
  enqueuedAt: x
119
119
  }, { conflictColumns: ["id"] })), m;
120
- }), I = (e, t, n, r, i, a, o, s) => h.gen(function* () {
121
- let l = yield* x({
120
+ }), R = (e, t, n, r, i, a, o, s) => h.gen(function* () {
121
+ let l = yield* b;
122
+ if (l !== void 0) return yield* h.die(new x(`the offloaded call '${e.name}'`, l));
123
+ let u = yield* C({
122
124
  name: `${e.name}:enqueue`,
123
125
  success: g.String,
124
126
  input: i,
125
- execute: F(e, t, n, r, a, o, s)
127
+ execute: L(e, t, n, r, a, o, s)
126
128
  });
127
- yield* A(e, a.rendered);
128
- let u = yield* b({ store: e.store }, {
129
- name: c(l),
129
+ yield* M(e, a.rendered);
130
+ let d = yield* S({ store: e.store }, {
131
+ name: c(u),
130
132
  schema: g.Unknown,
131
133
  timeoutMs: e.offloadTimeoutMs ?? 36e5
132
134
  });
133
- return M(u) ? yield* h.die(new N(e.name, u.message, u.attempts, u.outcome === "unknown" ? "unknown" : "failed")) : u;
134
- }), L = class extends Error {
135
+ return P(d) ? yield* h.die(new F(e.name, d.message, d.attempts, d.outcome === "unknown" ? "unknown" : "failed")) : d;
136
+ }), z = class extends Error {
135
137
  constructor(e) {
136
138
  super(`aiStep('${e}'): budget needs \`store\` — the reservation counter and the hold both live in tables. Pass ctx.store.`), this.name = "AiBudgetMisuseError";
137
139
  }
138
- }, R = (e) => h.gen(function* () {
140
+ }, B = (e) => h.gen(function* () {
139
141
  let t = e.budget;
140
142
  if (t === void 0) return;
141
143
  let n = e.store;
142
- if (n === void 0) return yield* h.die(new L(e.name));
144
+ if (n === void 0) return yield* h.die(new z(e.name));
143
145
  let r = e.tenantId ?? null, i = t.name ?? "ai-usd", a = yield* y, o = () => d(n, {
144
146
  tenantId: r,
145
147
  limitUsd: t.limitUsd,
@@ -156,12 +158,12 @@ var C = {
156
158
  ])) },
157
159
  ...t.since === void 0 ? {} : { since: t.since }
158
160
  }).pipe(h.asVoid), c = yield* t.estimateUsd !== void 0 && t.estimateUsd !== 0 ? s().pipe(h.as(null), h.catchTag("AiBudgetExceeded", (e) => h.succeed(e))) : o();
159
- if (c !== null) return (t.onExceeded ?? "fail") !== "suspend" || a === void 0 ? yield* h.fail(c) : (yield* S({
161
+ if (c !== null) return (t.onExceeded ?? "fail") !== "suspend" || a === void 0 ? yield* h.fail(c) : (yield* w({
160
162
  store: n,
161
163
  budget: i,
162
164
  tenantId: r,
163
165
  executionId: a,
164
- workflowName: yield* z(n, a),
166
+ workflowName: yield* V(n, a),
165
167
  stepName: e.name,
166
168
  spentMicroUsd: Math.round(c.spentUsd * 1e6),
167
169
  limitMicroUsd: Math.round(t.limitUsd * 1e6),
@@ -169,7 +171,7 @@ var C = {
169
171
  ...t.holdTimeoutMs === void 0 ? {} : { timeoutMs: t.holdTimeoutMs },
170
172
  ...t.recheckEveryMs === void 0 ? {} : { recheckEveryMs: t.recheckEveryMs }
171
173
  }).pipe(h.catchAll((e) => e instanceof v ? h.die(e) : h.fail(e))), yield* s());
172
- }), z = (e, t) => h.promise(async () => {
174
+ }), V = (e, t) => h.promise(async () => {
173
175
  let n = await e.query({
174
176
  table: "_voltro_workflow_runs",
175
177
  predicate: _("executionId", t),
@@ -179,18 +181,18 @@ var C = {
179
181
  projection: void 0
180
182
  });
181
183
  return String(n[0]?.tag ?? "");
182
- }), B = (t) => {
183
- let r = t.provider ?? e(), i = D(t), a = {
184
- ...O(r),
184
+ }), H = (t) => {
185
+ let r = t.provider ?? e(), i = k(t), a = {
186
+ ...A(r),
185
187
  operation: "generateText",
186
188
  offloaded: t.offload === !0,
187
- ...E(i.text, i.system, t.recordPrompt ?? "digest", i.rendered)
188
- }, o = (e) => t.budget === void 0 ? e : h.zipRight(R(t), e);
189
- return t.offload === !0 ? o(I(t, r, "text", null, a, i)) : o(x({
189
+ ...O(i.text, i.system, t.recordPrompt ?? "digest", i.rendered)
190
+ }, o = (e) => t.budget === void 0 ? e : h.zipRight(B(t), e);
191
+ return t.offload === !0 ? o(R(t, r, "text", null, a, i)) : o(C({
190
192
  name: t.name,
191
- success: j,
193
+ success: N,
192
194
  input: a,
193
- retry: t.retry ?? C,
195
+ retry: t.retry ?? T,
194
196
  execute: n({
195
197
  prompt: i.text,
196
198
  provider: r,
@@ -201,18 +203,18 @@ var C = {
201
203
  ...t.tools === void 0 ? {} : { tools: t.tools },
202
204
  ...t.maxSteps === void 0 ? {} : { maxSteps: t.maxSteps },
203
205
  ...t.toolContext === void 0 ? {} : { toolContext: t.toolContext }
204
- }).pipe(h.tap((e) => k(t, r, "generateText", e, i.rendered)), h.tap(() => A(t, i.rendered)), h.map((e) => ({
206
+ }).pipe(h.tap((e) => j(t, r, "generateText", e, i.rendered)), h.tap(() => M(t, i.rendered)), h.map((e) => ({
205
207
  text: e.text,
206
208
  inputTokens: e.usage.inputTokens ?? null,
207
209
  outputTokens: e.usage.outputTokens ?? null,
208
210
  totalTokens: e.usage.totalTokens ?? null
209
211
  })))
210
212
  }));
211
- }, V = g.Struct({
213
+ }, U = g.Struct({
212
214
  text: g.String,
213
215
  language: g.optional(g.String),
214
216
  durationSec: g.optional(g.Number)
215
- }), H = (t) => {
217
+ }), W = (t) => {
216
218
  let n = t.provider ?? e(), r = {
217
219
  source: t.source,
218
220
  ...t.language === void 0 ? {} : { language: t.language },
@@ -220,19 +222,19 @@ var C = {
220
222
  ...t.diarize === void 0 ? {} : { diarize: t.diarize },
221
223
  ...t.translateToEnglish === void 0 ? {} : { translateToEnglish: t.translateToEnglish }
222
224
  }, i = {
223
- ...O(n),
225
+ ...A(n),
224
226
  operation: "transcribe",
225
227
  offloaded: t.offload === !0
226
- }, o = (e) => t.budget === void 0 ? e : h.zipRight(R(t), e);
227
- return t.offload === !0 ? o(I(t, n, "transcription", null, i, {
228
+ }, o = (e) => t.budget === void 0 ? e : h.zipRight(B(t), e);
229
+ return t.offload === !0 ? o(R(t, n, "transcription", null, i, {
228
230
  text: "",
229
231
  system: void 0,
230
232
  rendered: void 0
231
- }, r)) : o(x({
233
+ }, r)) : o(C({
232
234
  name: t.name,
233
- success: V,
235
+ success: U,
234
236
  input: i,
235
- retry: t.retry ?? C,
237
+ retry: t.retry ?? T,
236
238
  execute: a({
237
239
  ...r,
238
240
  provider: n,
@@ -243,8 +245,8 @@ var C = {
243
245
  ...e.durationSec === void 0 ? {} : { durationSec: e.durationSec }
244
246
  })))
245
247
  }));
246
- }, U = (t) => {
247
- let n = t.provider ?? e(), r = D({
248
+ }, G = (t) => {
249
+ let n = t.provider ?? e(), r = k({
248
250
  ...t,
249
251
  prompt: t.prompt
250
252
  }), i = {
@@ -253,31 +255,31 @@ var C = {
253
255
  inputs: t.inputs ?? {},
254
256
  ...t.persist === void 0 ? {} : { persist: t.persist }
255
257
  }, a = {
256
- ...O(n),
258
+ ...A(n),
257
259
  operation: `generate${t.modality[0].toUpperCase()}${t.modality.slice(1)}`,
258
260
  offloaded: !0,
259
261
  modality: t.modality,
260
- ...E(r.text, void 0, t.recordPrompt ?? "digest", r.rendered)
262
+ ...O(r.text, void 0, t.recordPrompt ?? "digest", r.rendered)
261
263
  };
262
- return ((e) => t.budget === void 0 ? e : h.zipRight(R(t), e))(I({
264
+ return ((e) => t.budget === void 0 ? e : h.zipRight(B(t), e))(R({
263
265
  ...t,
264
266
  offload: !0
265
267
  }, n, "media", null, a, r, void 0, i));
266
- }, W = (n) => {
267
- let i = n.provider ?? e(), a = D(n), s = {
268
- ...O(i),
268
+ }, K = (n) => {
269
+ let i = n.provider ?? e(), a = k(n), s = {
270
+ ...A(i),
269
271
  operation: "generateObject",
270
272
  offloaded: n.offload === !0,
271
- ...E(a.text, a.system, n.recordPrompt ?? "digest", a.rendered)
272
- }, c = (e) => n.budget === void 0 ? e : h.zipRight(R(n), e);
273
+ ...O(a.text, a.system, n.recordPrompt ?? "digest", a.rendered)
274
+ }, c = (e) => n.budget === void 0 ? e : h.zipRight(B(n), e);
273
275
  return n.offload === !0 ? c(h.gen(function* () {
274
- let e = yield* o(n.schema, "aiObjectStep"), t = yield* I(n, i, "object", e, s, a);
276
+ let e = yield* o(n.schema, "aiObjectStep"), t = yield* R(n, i, "object", e, s, a);
275
277
  return yield* g.decodeUnknown(n.schema)(t);
276
- })) : c(x({
278
+ })) : c(C({
277
279
  name: n.name,
278
280
  success: n.schema,
279
281
  input: s,
280
- retry: n.retry ?? C,
282
+ retry: n.retry ?? T,
281
283
  execute: (n.tools === void 0 ? r({
282
284
  prompt: a.text,
283
285
  schema: n.schema,
@@ -297,8 +299,8 @@ var C = {
297
299
  ...n.fallbacks === void 0 ? {} : { fallbacks: n.fallbacks },
298
300
  ...n.maxTokens === void 0 ? {} : { maxTokens: n.maxTokens },
299
301
  ...n.providerOptions === void 0 ? {} : { providerOptions: n.providerOptions }
300
- })).pipe(h.tap((e) => k(n, i, "generateObject", e, a.rendered)), h.tap(() => A(n, a.rendered)), h.map((e) => e.object))
302
+ })).pipe(h.tap((e) => j(n, i, "generateObject", e, a.rendered)), h.tap(() => M(n, a.rendered)), h.map((e) => e.object))
301
303
  }));
302
304
  };
303
305
  //#endregion
304
- export { C as AI_STEP_RETRY, L as AiBudgetMisuseError, N as AiOffloadError, P as AiOffloadMisuseError, T as DEFAULT_AI_BUDGET_NAME, w as DEFAULT_OFFLOAD_TIMEOUT_MS, V as TranscriptionStepResult, W as aiObjectStep, B as aiStep, U as mediaStep, s as promptDigest, E as promptRecordFor, D as resolveStepPrompt, H as transcribeStep };
306
+ export { T as AI_STEP_RETRY, z as AiBudgetMisuseError, F as AiOffloadError, I as AiOffloadMisuseError, D as DEFAULT_AI_BUDGET_NAME, E as DEFAULT_OFFLOAD_TIMEOUT_MS, U as TranscriptionStepResult, K as aiObjectStep, H as aiStep, G as mediaStep, s as promptDigest, O as promptRecordFor, k as resolveStepPrompt, W as transcribeStep };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@voltro/ai",
3
- "version": "0.82.0",
3
+ "version": "0.83.1",
4
4
  "description": "Effect-native AI primitives — generateText / generateObject / streamText, tools, agents, media generation, cost tracking + budgets, and provider fallback.",
5
5
  "keywords": [
6
6
  "voltro",
@@ -55,10 +55,10 @@
55
55
  "dependencies": {
56
56
  "@ai-sdk/anthropic": "^4.0.56",
57
57
  "@ai-sdk/openai": "^4.0.69",
58
- "@voltro/cache": "0.82.0",
59
- "@voltro/database": "0.82.0",
60
- "@voltro/protocol": "0.82.0",
61
- "@voltro/workflow": "0.82.0",
58
+ "@voltro/cache": "0.83.1",
59
+ "@voltro/database": "0.83.1",
60
+ "@voltro/protocol": "0.83.1",
61
+ "@voltro/workflow": "0.83.1",
62
62
  "ajv": "^8.20.0",
63
63
  "ajv-formats": "^3.0.1",
64
64
  "ws": "^8.21.3"