@voltro/plugin-ai-flows 0.85.0 → 0.86.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.
@@ -0,0 +1,15 @@
1
+ //#region src/interpolate.ts
2
+ var e = /\{\{\s*([\w.-]+)\s*\}\}/g, t = (t) => {
3
+ let n = [];
4
+ for (let r of t.matchAll(e)) n.push(r[1]);
5
+ return n;
6
+ }, n = (t, n) => t.replace(e, (e, t) => {
7
+ let r = n[t];
8
+ return r == null ? "" : typeof r == "string" ? r : JSON.stringify(r);
9
+ }), r = (e, n) => {
10
+ let r = /* @__PURE__ */ new Set();
11
+ for (let i of t(e)) n[i] == null && !r.has(i) && r.add(i);
12
+ return [...r];
13
+ };
14
+ //#endregion
15
+ export { t as collectRefs, n as interpolate, r as unresolvedRefs };
package/dist/ir.js CHANGED
@@ -1,2 +1,233 @@
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-Cjk1kQl9.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 };
1
+ import { ConditionOp as e, StepCondition as t, describeCondition as n, evaluateCondition as r, isTruthy as i } from "./condition.js";
2
+ import { Schema as a } from "effect";
3
+ import { WorkflowControlResultSchema as o, WorkflowRunHandleSchema as s } from "@voltro/protocol";
4
+ //#region src/ir.ts
5
+ var c = a.Struct({
6
+ runId: a.NonEmptyString,
7
+ requestId: a.NonEmptyString,
8
+ admission: s
9
+ }), l = a.Literals(["deterministic", "agentic"]), u = a.Literals([
10
+ "draft",
11
+ "active",
12
+ "archived"
13
+ ]), d = a.Literals([
14
+ "private",
15
+ "organization",
16
+ "shared"
17
+ ]), f = a.Literals([
18
+ "pending",
19
+ "running",
20
+ "waiting",
21
+ "cancelling",
22
+ "succeeded",
23
+ "failed",
24
+ "cancelled"
25
+ ]), p = a.Struct({
26
+ runId: a.NonEmptyString,
27
+ status: f,
28
+ engine: a.Literals([
29
+ "cancelled",
30
+ "accepted",
31
+ "unknown",
32
+ "already-terminal",
33
+ "unreachable",
34
+ "not-requested"
35
+ ]),
36
+ control: a.NullOr(o)
37
+ }).pipe(a.check(a.makeFilter((e) => {
38
+ let t = e.control;
39
+ if (t !== null && t.operation !== "cancel") return !1;
40
+ switch (e.engine) {
41
+ case "cancelled": return e.status === "cancelled" && t !== null && t.snapshot.status === "cancelled" && (t.kind === "confirmed" || t.kind === "already-terminal");
42
+ case "accepted": return t?.kind === "accepted";
43
+ case "already-terminal": return t?.kind === "already-terminal" && t.snapshot.status !== "cancelled";
44
+ case "unknown": return t === null || t.kind === "unknown";
45
+ case "unreachable":
46
+ case "not-requested": return t === null;
47
+ }
48
+ }, { message: "Flow cancellation acknowledgement contradicts its workflow control receipt" }))), m = a.Literals(["manual", "cron"]), h = a.Literals([
49
+ "agent",
50
+ "generate",
51
+ "structured",
52
+ "note",
53
+ "human"
54
+ ]), g = a.Literals([
55
+ "text",
56
+ "image",
57
+ "video",
58
+ "audio"
59
+ ]), _ = a.Literals([
60
+ "approve",
61
+ "choice",
62
+ "text"
63
+ ]), v = a.Struct({
64
+ value: a.String,
65
+ label: a.String
66
+ }), y = a.Union([a.Struct({
67
+ from: a.Literal("upload"),
68
+ url: a.String,
69
+ mediaType: a.optional(a.NonEmptyString)
70
+ }), a.Struct({
71
+ from: a.Literal("step"),
72
+ ref: a.String,
73
+ artifact: a.optional(a.Int.pipe(a.check(a.isGreaterThanOrEqualTo(0))))
74
+ })]), b = a.Record(a.String, y), x = a.Record(a.String, a.Unknown), S = a.Struct({
75
+ url: a.NonEmptyString,
76
+ mediaType: a.NonEmptyString,
77
+ role: a.NonEmptyString,
78
+ storageRefId: a.optional(a.NonEmptyString),
79
+ providerMetadata: a.optional(a.Unknown)
80
+ }), C = a.Array(S).pipe(a.check(a.makeFilter((e) => e.filter((e) => e.role === "primary").length === 1))), w = a.Struct({
81
+ id: a.String,
82
+ title: a.optional(a.String),
83
+ description: a.optional(a.String),
84
+ type: h,
85
+ outputKey: a.optional(a.String),
86
+ prompt: a.optional(a.String),
87
+ modality: a.optional(g),
88
+ model: a.optional(a.String),
89
+ params: a.optional(x),
90
+ mediaInputs: a.optional(b),
91
+ agentRef: a.optional(a.String),
92
+ schema: a.optional(x),
93
+ reviewMode: a.optional(_),
94
+ options: a.optional(a.Array(v)),
95
+ when: a.optional(t),
96
+ group: a.optional(a.String),
97
+ timeoutMs: a.optional(a.Number)
98
+ }), T = a.Struct({
99
+ key: a.String,
100
+ label: a.String,
101
+ type: a.Literals([
102
+ "text",
103
+ "textarea",
104
+ "number",
105
+ "boolean"
106
+ ]),
107
+ required: a.optional(a.Boolean),
108
+ placeholder: a.optional(a.String)
109
+ }), E = a.Struct({
110
+ flowRef: a.String,
111
+ mappings: a.Array(a.Struct({
112
+ targetKey: a.String,
113
+ sourceKey: a.String
114
+ })),
115
+ requireConfirmation: a.optional(a.Boolean)
116
+ }), D = a.Struct({
117
+ frequency: a.optional(a.Literals(["weekly", "monthly"])),
118
+ repeats: a.Array(a.Number),
119
+ intervalWeeks: a.optional(a.Number),
120
+ anchorDate: a.optional(a.String),
121
+ weekOfMonth: a.optional(a.Union([a.Literals([
122
+ 1,
123
+ 2,
124
+ 3,
125
+ 4
126
+ ]), a.Literal("last")])),
127
+ hour: a.optional(a.Number),
128
+ minute: a.optional(a.Literals([
129
+ 0,
130
+ 15,
131
+ 30,
132
+ 45
133
+ ])),
134
+ defaultInput: a.optional(x)
135
+ }), O = a.Literals([
136
+ "pending",
137
+ "running",
138
+ "waiting",
139
+ "succeeded",
140
+ "failed",
141
+ "skipped"
142
+ ]), k = a.Struct({
143
+ mode: _,
144
+ options: a.optional(a.Array(v)),
145
+ prompt: a.String
146
+ }), A = a.Literals([
147
+ "gateway",
148
+ "estimated",
149
+ "unpriced"
150
+ ]), j = a.Literals([
151
+ "actual",
152
+ "estimated",
153
+ "incomplete",
154
+ "unknown"
155
+ ]), M = a.Struct({
156
+ status: a.Literals(["reported", "unreported"]),
157
+ unit: a.optional(a.Literals([
158
+ "tokens",
159
+ "characters",
160
+ "seconds"
161
+ ])),
162
+ input: a.optional(a.Finite.pipe(a.check(a.isGreaterThanOrEqualTo(0)))),
163
+ output: a.optional(a.Finite.pipe(a.check(a.isGreaterThanOrEqualTo(0))))
164
+ }), N = a.Struct({
165
+ costMicroUsd: a.optional(a.Finite.pipe(a.check(a.isGreaterThanOrEqualTo(0)))),
166
+ costSource: a.optional(A),
167
+ requestId: a.optional(a.NonEmptyString),
168
+ usage: a.optional(M)
169
+ }), P = a.Struct({
170
+ id: a.Number,
171
+ title: a.String,
172
+ description: a.optional(a.String),
173
+ type: h,
174
+ status: O,
175
+ agentRef: a.optional(a.String),
176
+ modality: a.optional(g),
177
+ startedAt: a.optional(a.String),
178
+ completedAt: a.optional(a.String),
179
+ costMicroUsd: a.optional(a.Number),
180
+ costSource: a.optional(A),
181
+ requestId: a.optional(a.String),
182
+ usage: a.optional(M),
183
+ url: a.optional(a.String),
184
+ artifacts: a.optional(C),
185
+ output: a.optional(a.Struct({ text: a.String })),
186
+ errorMessage: a.optional(a.String),
187
+ skipReason: a.optional(a.String),
188
+ review: a.optional(k)
189
+ }), F = a.Struct({
190
+ decision: a.optional(a.Literals(["approve", "reject"])),
191
+ value: a.optional(a.String),
192
+ text: a.optional(a.String),
193
+ respondedAt: a.optional(a.String)
194
+ }), I = a.Struct({
195
+ runId: a.NonEmptyString,
196
+ stepIndex: a.Int.pipe(a.check(a.isGreaterThanOrEqualTo(0))),
197
+ response: F
198
+ }), L = a.Struct({
199
+ runId: a.NonEmptyString,
200
+ stepIndex: a.Int.pipe(a.check(a.isGreaterThanOrEqualTo(0))),
201
+ executionId: a.NonEmptyString,
202
+ eventId: a.NonEmptyString,
203
+ status: a.Literal("accepted")
204
+ }), R = a.Struct({
205
+ flowRef: a.String,
206
+ input: x,
207
+ status: a.Literals([
208
+ "pending",
209
+ "confirmed",
210
+ "dismissed"
211
+ ])
212
+ }), z = 30, B = 1, V = 100, H = (e) => e == null || !Number.isFinite(e) ? 30 : Math.min(100, Math.max(1, Math.trunc(e))), U = (e) => e.replace(/[^\w.-]/g, "_"), W = (e) => {
213
+ let t = (e.steps ?? []).map((e) => e.outputKey ? {
214
+ ...e,
215
+ outputKey: U(e.outputKey)
216
+ } : e), n = e.orchestratorModel || e.orchestratorInstructions ? {
217
+ ...e.orchestratorModel ? { model: e.orchestratorModel } : {},
218
+ ...e.orchestratorInstructions ? { instructions: e.orchestratorInstructions } : {}
219
+ } : void 0;
220
+ return {
221
+ name: e.name,
222
+ mode: e.mode ?? "deterministic",
223
+ steps: t,
224
+ maxSteps: H(e.maxSteps),
225
+ brief: e.brief ?? [],
226
+ ...n ? { orchestrator: n } : {},
227
+ ...e.chain ? { chain: e.chain } : {},
228
+ ...e.cadence ? { cadence: e.cadence } : {},
229
+ ...e.humanTimeoutMs != null && Number.isFinite(e.humanTimeoutMs) ? { humanTimeoutMs: e.humanTimeoutMs } : {}
230
+ };
231
+ };
232
+ //#endregion
233
+ export { T as BriefField, R as ChainPending, e as ConditionOp, j as CostCompleteness, A as CostSource, D as FlowCadence, p as FlowCancelReceipt, E as FlowChain, l as FlowMode, I as FlowReviewInput, L as FlowReviewReceipt, c as FlowStartReceipt, u as FlowStatus, w as FlowStep, F as HumanResponse, x as Json, z as MAX_STEPS_DEFAULT, V as MAX_STEPS_MAX, B as MAX_STEPS_MIN, S as MediaArtifact, C as MediaArtifacts, y as MediaInputSlot, b as MediaInputs, N as MediaReceipt, g as Modality, _ as ReviewMode, v as ReviewOption, k as RunReview, m as RunSource, f as RunStatus, P as RunStep, O as RunStepStatus, t as StepCondition, h as StepType, M as StepUsage, d as Visibility, H as clampMaxSteps, n as describeCondition, r as evaluateCondition, i as isTruthy, W as normalizeFlow, U as sanitizeOutputKey };
@@ -0,0 +1,12 @@
1
+ import { Schema as e } from "effect";
2
+ //#region src/jsonParams.ts
3
+ var t = e.suspend(() => e.Union([
4
+ e.Null,
5
+ e.Boolean,
6
+ e.Finite,
7
+ e.String,
8
+ e.Array(t).pipe(e.mutable),
9
+ e.Record(e.String, t)
10
+ ])), n = e.Record(e.String, e.Record(e.String, t));
11
+ //#endregion
12
+ export { n as ProviderOptions };
@@ -0,0 +1,179 @@
1
+ import { nativeMediaInputs as e } from "./mediaInputs.js";
2
+ import { FlowCapabilityMissing as t } from "./errors.js";
3
+ import { audioParams as n, imageParams as r, videoParams as i } from "./mediaParams.js";
4
+ import { Effect as a } from "effect";
5
+ import { estimateCostUsd as o, gatewayCostUsd as s, generateImage as c, generateSpeech as l, generateVideo as u, isMeteredUsage as d } from "@voltro/ai";
6
+ //#region src/mediaAdapter.ts
7
+ var f = (e) => ({
8
+ name: "gateway",
9
+ model: e
10
+ }), p = (e) => Math.round(e * 1e6), m = (e, t, n) => {
11
+ let r = s(t);
12
+ if (typeof r == "number") return {
13
+ costMicroUsd: p(r),
14
+ costSource: "gateway"
15
+ };
16
+ if (e) {
17
+ let t = o(e, { model: n ?? "unknown" });
18
+ return {
19
+ costMicroUsd: t.costMicroUsd ?? 0,
20
+ costSource: t.costSource ?? "unpriced"
21
+ };
22
+ }
23
+ return {
24
+ costMicroUsd: 0,
25
+ costSource: "unpriced"
26
+ };
27
+ }, h = (e) => {
28
+ if (e === void 0) return { status: "unreported" };
29
+ let [t, n, r] = d(e) ? [
30
+ e.unit,
31
+ e.input,
32
+ e.output
33
+ ] : [
34
+ "tokens",
35
+ e.inputTokens,
36
+ e.outputTokens
37
+ ];
38
+ return n === void 0 && r === void 0 ? { status: "unreported" } : {
39
+ status: "reported",
40
+ unit: t,
41
+ ...n === void 0 ? {} : { input: n },
42
+ ...r === void 0 ? {} : { output: r }
43
+ };
44
+ }, g = (e, t, n) => ({
45
+ ...m(e, t, n),
46
+ usage: h(e)
47
+ }), _ = (o, s) => (d) => {
48
+ let p = d.model, _ = (e) => s?.resolveModel?.(e) ?? f(e);
49
+ return a.gen(function* () {
50
+ let s = yield* e(d.modality, d.inputs).pipe(a.mapError((e) => new t({
51
+ capability: `media:${d.modality}`,
52
+ message: e
53
+ })));
54
+ if (d.modality === "image") {
55
+ let e = yield* r(d.params).pipe(a.mapError((e) => new t({
56
+ capability: "media:image",
57
+ message: e
58
+ }))), n = s.referenceImageUrl, i = s.maskImageUrl, l = yield* c({
59
+ ...e,
60
+ prompt: d.prompt,
61
+ ...n === void 0 ? {} : { inputs: {
62
+ images: [n],
63
+ ...i === void 0 ? {} : { mask: i }
64
+ } },
65
+ ...p ? { provider: _(p) } : {}
66
+ });
67
+ if (l.images.length === 0) return yield* a.fail(new t({
68
+ capability: "media:image",
69
+ message: "no image produced"
70
+ }));
71
+ let u = [];
72
+ for (let [e, n] of l.images.entries()) {
73
+ let r = yield* o.put({
74
+ data: n.data,
75
+ mediaType: n.mediaType,
76
+ run: d.run
77
+ }).pipe(a.mapError(() => new t({
78
+ capability: "media:image",
79
+ message: "media persistence failed",
80
+ receipt: g(l.usage, l.providerMetadata, p)
81
+ })));
82
+ u.push({
83
+ url: r.url,
84
+ mediaType: n.mediaType,
85
+ role: e === 0 ? "primary" : "variant",
86
+ ...r.refId === void 0 ? {} : { storageRefId: r.refId },
87
+ ...n.providerMetadata === void 0 ? {} : { providerMetadata: n.providerMetadata }
88
+ });
89
+ }
90
+ return {
91
+ artifacts: u,
92
+ ...m(l.usage, l.providerMetadata, p),
93
+ usage: h(l.usage)
94
+ };
95
+ }
96
+ if (d.modality === "audio") {
97
+ let e = yield* n(d.params).pipe(a.mapError((e) => new t({
98
+ capability: "media:audio",
99
+ message: e
100
+ }))), r = yield* l({
101
+ ...e,
102
+ text: d.prompt,
103
+ ...p ? { provider: _(p) } : {}
104
+ }), i = yield* o.put({
105
+ data: r.audio.data,
106
+ mediaType: r.audio.mediaType,
107
+ run: d.run
108
+ }).pipe(a.mapError(() => new t({
109
+ capability: "media:audio",
110
+ message: "media persistence failed",
111
+ receipt: g(r.usage, r.providerMetadata, p)
112
+ })));
113
+ return {
114
+ artifacts: [{
115
+ url: i.url,
116
+ mediaType: r.audio.mediaType,
117
+ role: "primary",
118
+ ...i.refId === void 0 ? {} : { storageRefId: i.refId }
119
+ }],
120
+ ...m(r.usage, r.providerMetadata, p),
121
+ usage: h(r.usage)
122
+ };
123
+ }
124
+ let { maxInlineBytes: f, providerOptions: v, ...y } = yield* i(d.params).pipe(a.mapError((e) => new t({
125
+ capability: "media:video",
126
+ message: e
127
+ }))), b = yield* u({
128
+ prompt: d.prompt,
129
+ inputs: {
130
+ ...s.referenceImageUrl === void 0 ? {} : { image: s.referenceImageUrl },
131
+ ...s.referenceVideoUrl === void 0 ? {} : { references: [s.referenceVideoUrl] },
132
+ frameImages: [...s.firstFrameImageUrl === void 0 ? [] : [{
133
+ frameType: "first_frame",
134
+ image: s.firstFrameImageUrl
135
+ }], ...s.lastFrameImageUrl === void 0 ? [] : [{
136
+ frameType: "last_frame",
137
+ image: s.lastFrameImageUrl
138
+ }]]
139
+ },
140
+ ...p ? { provider: _(p) } : {},
141
+ params: y,
142
+ ...v === void 0 ? {} : { providerOptions: v },
143
+ ...f === void 0 ? {} : { maxInlineBytes: f }
144
+ }), x;
145
+ if (b.video.url) x = o.ingestUrl ? yield* o.ingestUrl(b.video.url, d.run).pipe(a.mapError(() => new t({
146
+ capability: "media:video",
147
+ message: "media persistence failed",
148
+ receipt: g(b.usage, b.providerMetadata, p)
149
+ }))) : { url: b.video.url };
150
+ else if (b.video.data) x = yield* o.put({
151
+ data: b.video.data,
152
+ mediaType: b.video.mediaType,
153
+ run: d.run
154
+ }).pipe(a.mapError(() => new t({
155
+ capability: "media:video",
156
+ message: "media persistence failed",
157
+ receipt: g(b.usage, b.providerMetadata, p)
158
+ })));
159
+ else return yield* a.fail(new t({
160
+ capability: "media:video",
161
+ message: "no video produced"
162
+ }));
163
+ return {
164
+ artifacts: [{
165
+ url: x.url,
166
+ mediaType: b.video.mediaType,
167
+ role: "primary",
168
+ ...x.refId === void 0 ? {} : { storageRefId: x.refId }
169
+ }],
170
+ ...m(b.usage, b.providerMetadata, p),
171
+ usage: h(b.usage)
172
+ };
173
+ }).pipe(a.catch((e) => e instanceof t ? a.fail(e) : a.fail(new t({
174
+ capability: `media:${d.modality}`,
175
+ message: String(e.message ?? e)
176
+ }))));
177
+ };
178
+ //#endregion
179
+ export { _ as makeMediaGenerator };
@@ -0,0 +1,57 @@
1
+ import { MediaInputs as e } from "./ir.js";
2
+ import { Effect as t, Schema as n } from "effect";
3
+ //#region src/mediaInputs.ts
4
+ var r = n.String.pipe(n.check(n.makeFilter((e) => {
5
+ try {
6
+ let t = new URL(e);
7
+ return (t.protocol === "https:" || t.protocol === "http:") && t.username === "" && t.password === "";
8
+ } catch {
9
+ return !1;
10
+ }
11
+ }))), i = n.Record(n.String, r), a = (r, a, o = {}) => t.try({
12
+ try: () => {
13
+ let t = n.decodeUnknownSync(e, { onExcessProperty: "error" })(r === void 0 ? {} : r), s = Object.fromEntries(Object.entries(t).map(([e, t]) => [e, t.from === "upload" ? t.url : t.artifact === void 0 ? Object.hasOwn(a, t.ref) ? a[t.ref] : void 0 : Object.hasOwn(o, t.ref) ? o[t.ref]?.[t.artifact]?.url : void 0]));
14
+ return n.decodeUnknownSync(i)(s);
15
+ },
16
+ catch: () => "invalid or unresolved media input: each slot must resolve to an absolute HTTP(S) URL without embedded credentials"
17
+ }), o = n.Struct({
18
+ url: r,
19
+ mediaType: n.NonEmptyString
20
+ });
21
+ n.Record(n.String, o);
22
+ var s = (t, i = {}) => {
23
+ let a = n.decodeUnknownOption(e)(t === void 0 ? {} : t);
24
+ if (a._tag === "None") return {};
25
+ let o = {};
26
+ for (let [e, t] of Object.entries(a.value)) {
27
+ if (t.from === "upload") {
28
+ t.mediaType !== void 0 && n.is(r)(t.url) && (o[e] = {
29
+ url: t.url,
30
+ mediaType: t.mediaType
31
+ });
32
+ continue;
33
+ }
34
+ if (t.artifact === void 0 || !Object.hasOwn(i, t.ref)) continue;
35
+ let a = i[t.ref]?.[t.artifact];
36
+ a !== void 0 && n.is(r)(a.url) && (o[e] = {
37
+ url: a.url,
38
+ mediaType: a.mediaType
39
+ });
40
+ }
41
+ return o;
42
+ }, c = (e, r) => t.try({
43
+ try: () => {
44
+ let t = n.decodeUnknownSync(i)(r === void 0 ? {} : r), a = e === "image" ? ["referenceImageUrl", "maskImageUrl"] : e === "video" ? [
45
+ "referenceImageUrl",
46
+ "firstFrameImageUrl",
47
+ "lastFrameImageUrl",
48
+ "referenceVideoUrl"
49
+ ] : [];
50
+ if (Object.keys(t).some((e) => !a.includes(e))) throw Error("unsupported slot");
51
+ if (e === "image" && t.maskImageUrl !== void 0 && t.referenceImageUrl === void 0) throw Error("mask requires reference");
52
+ return t;
53
+ },
54
+ catch: () => `invalid or unsupported media input for ${e}; check the built-in adapter's slot contract`
55
+ });
56
+ //#endregion
57
+ export { r as MediaInputUrl, o as ResolvedMediaInputRef, i as ResolvedMediaInputs, c as nativeMediaInputs, s as resolveMediaInputRefs, a as resolveMediaInputs };
@@ -0,0 +1,42 @@
1
+ import { ProviderOptions as e } from "./jsonParams.js";
2
+ import { Effect as t, Schema as n } from "effect";
3
+ //#region src/mediaParams.ts
4
+ var r = (e) => n.optionalKey(e), i = n.Int.pipe(n.check(n.isGreaterThan(0)), n.check(n.isLessThanOrEqualTo(2 ** 53 - 1))), a = n.Int.pipe(n.check(n.isBetween({
5
+ minimum: -(2 ** 53 - 1),
6
+ maximum: 2 ** 53 - 1
7
+ }))), o = n.TemplateLiteral([
8
+ n.Number,
9
+ "x",
10
+ n.Number
11
+ ]).pipe(n.check(n.isPattern(/^[1-9]\d*x[1-9]\d*$/))), s = n.TemplateLiteral([
12
+ n.Number,
13
+ ":",
14
+ n.Number
15
+ ]).pipe(n.check(n.isPattern(/^[1-9]\d*:[1-9]\d*$/))), c = n.Struct({
16
+ n: r(i),
17
+ seed: r(a),
18
+ size: r(o),
19
+ aspectRatio: r(s),
20
+ providerOptions: r(e)
21
+ }), l = n.Struct({
22
+ voice: r(n.NonEmptyString),
23
+ outputFormat: r(n.NonEmptyString),
24
+ instructions: r(n.String),
25
+ speed: r(n.Finite.pipe(n.check(n.isGreaterThan(0)))),
26
+ language: r(n.NonEmptyString),
27
+ providerOptions: r(e)
28
+ }), u = n.Struct({
29
+ aspectRatio: r(s),
30
+ durationSeconds: r(n.Finite.pipe(n.check(n.isGreaterThan(0)))),
31
+ resolution: r(o),
32
+ fps: r(n.Finite.pipe(n.check(n.isGreaterThan(0)))),
33
+ seed: r(a),
34
+ generateAudio: r(n.Boolean),
35
+ maxInlineBytes: r(i),
36
+ providerOptions: r(e)
37
+ }), d = (e, r, i) => t.try({
38
+ try: () => n.decodeUnknownSync(e, { onExcessProperty: "error" })(r === void 0 ? {} : r),
39
+ catch: () => `invalid ${i} media params: check the built-in adapter's supported options and value ranges`
40
+ }), f = (e) => d(c, e, "image"), p = (e) => d(l, e, "audio"), m = (e) => d(u, e, "video");
41
+ //#endregion
42
+ export { p as audioParams, f as imageParams, m as videoParams };
@@ -0,0 +1,15 @@
1
+ import { CostSource as e, MediaArtifacts as t, StepUsage as n } from "./ir.js";
2
+ import { Effect as r, Schema as i } from "effect";
3
+ //#region src/mediaResult.ts
4
+ var a = i.Struct({
5
+ artifacts: t,
6
+ costMicroUsd: i.optional(i.Finite.pipe(i.check(i.isGreaterThanOrEqualTo(0)))),
7
+ costSource: i.optional(e),
8
+ requestId: i.optional(i.NonEmptyString),
9
+ usage: i.optional(n)
10
+ }), o = (e) => r.try({
11
+ try: () => i.decodeUnknownSync(a, { onExcessProperty: "error" })(e),
12
+ catch: () => "invalid media result: expected artifacts with URL, mediaType and role, exactly one primary artifact, and optional storage references"
13
+ });
14
+ //#endregion
15
+ export { a as MediaResult, o as decodeMediaResult };