@pixerate/editor 0.134.0 → 0.136.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/animation-editor/index.cjs +58 -55
- package/dist/animation-editor/index.cjs.map +1 -1
- package/dist/animation-editor/index.d.cts +8 -5
- package/dist/animation-editor/index.d.ts +8 -5
- package/dist/animation-editor/index.js +5 -2
- package/dist/animation-editor/index.js.map +1 -1
- package/dist/{bezier-J8i4uqSH.d.cts → bezier-CdccFsF8.d.cts} +1 -1
- package/dist/{bezier-lNEOp0Jx.d.ts → bezier-DG9qNZQV.d.ts} +1 -1
- package/dist/canvas/index.d.cts +10 -7
- package/dist/canvas/index.d.ts +10 -7
- package/dist/{chunk-Z2H7KECK.cjs → chunk-2R3UW57U.cjs} +13 -2
- package/dist/chunk-2R3UW57U.cjs.map +1 -0
- package/dist/{chunk-ESIWZMMK.js → chunk-6QQR4LKE.js} +2 -2
- package/dist/chunk-A3BVTI3G.js +150 -0
- package/dist/chunk-A3BVTI3G.js.map +1 -0
- package/dist/{chunk-T6TV6HY6.cjs → chunk-B2CUCM7Y.cjs} +36 -36
- package/dist/{chunk-T6TV6HY6.cjs.map → chunk-B2CUCM7Y.cjs.map} +1 -1
- package/dist/chunk-ECCXGELC.cjs +727 -0
- package/dist/chunk-ECCXGELC.cjs.map +1 -0
- package/dist/{chunk-OXSV64JX.js → chunk-G6IKY6PL.js} +4 -4
- package/dist/chunk-I52DRGGJ.js +727 -0
- package/dist/chunk-I52DRGGJ.js.map +1 -0
- package/dist/{chunk-6CTZAGZ2.js → chunk-ILYFOJUN.js} +56 -1
- package/dist/chunk-ILYFOJUN.js.map +1 -0
- package/dist/{chunk-YAFS2QFZ.cjs → chunk-JLGNZMUV.cjs} +82 -82
- package/dist/{chunk-YAFS2QFZ.cjs.map → chunk-JLGNZMUV.cjs.map} +1 -1
- package/dist/{chunk-7RJ6P7MI.js → chunk-KZXLZCQ7.js} +2 -2
- package/dist/{chunk-HHTCDFZC.js → chunk-MAHQC3SK.js} +13 -2
- package/dist/chunk-MAHQC3SK.js.map +1 -0
- package/dist/{chunk-FWEO3HSL.js → chunk-PQQF5KOW.js} +8 -8
- package/dist/chunk-Q6OUXEK3.cjs +150 -0
- package/dist/chunk-Q6OUXEK3.cjs.map +1 -0
- package/dist/{chunk-P3RQ5UJE.cjs → chunk-UTQKC66X.cjs} +4 -4
- package/dist/{chunk-P3RQ5UJE.cjs.map → chunk-UTQKC66X.cjs.map} +1 -1
- package/dist/{chunk-J3B45HTA.cjs → chunk-XB25WOC2.cjs} +6 -6
- package/dist/{chunk-J3B45HTA.cjs.map → chunk-XB25WOC2.cjs.map} +1 -1
- package/dist/{chunk-NVTHUPJ6.cjs → chunk-YT3JL7YM.cjs} +71 -16
- package/dist/chunk-YT3JL7YM.cjs.map +1 -0
- package/dist/effects/index.d.cts +7 -4
- package/dist/effects/index.d.ts +7 -4
- package/dist/{export-BGdT02aL.d.cts → export-BOheWw2R.d.cts} +13 -5
- package/dist/{export-Dng22YB8.d.ts → export-ByKKIA2S.d.ts} +13 -5
- package/dist/{export-KzubBKo7.d.cts → export-CEYeRQXH.d.cts} +1 -1
- package/dist/{export-DMeG6E06.d.ts → export-Ds7zgGD8.d.ts} +1 -1
- package/dist/extensions/index.cjs +3 -3
- package/dist/extensions/index.cjs.map +1 -1
- package/dist/extensions/index.js +2 -2
- package/dist/generation/index.cjs +150 -945
- package/dist/generation/index.cjs.map +1 -1
- package/dist/generation/index.d.cts +3 -423
- package/dist/generation/index.d.ts +3 -423
- package/dist/generation/index.js +59 -854
- package/dist/generation/index.js.map +1 -1
- package/dist/grammar/index.cjs +3 -3
- package/dist/grammar/index.cjs.map +1 -1
- package/dist/grammar/index.js +2 -2
- package/dist/{helpers-Coa4e2j_.d.ts → helpers--ns3W2D7.d.ts} +7 -1
- package/dist/{helpers-DHl28yLO.d.cts → helpers-BVkU4oUi.d.cts} +7 -1
- package/dist/image-editor/index.cjs +742 -647
- package/dist/image-editor/index.cjs.map +1 -1
- package/dist/image-editor/index.d.cts +29 -11
- package/dist/image-editor/index.d.ts +29 -11
- package/dist/image-editor/index.js +107 -12
- package/dist/image-editor/index.js.map +1 -1
- package/dist/index.cjs +28 -28
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +36 -36
- package/dist/{opentype-Dfcx6wFx.d.ts → opentype-DfoVYgmG.d.ts} +1 -1
- package/dist/{opentype-BWR7Qv8W.d.cts → opentype-yi-Kz4ND.d.cts} +1 -1
- package/dist/paint/index.cjs +10 -2
- package/dist/paint/index.cjs.map +1 -1
- package/dist/paint/index.d.cts +2 -2
- package/dist/paint/index.d.ts +2 -2
- package/dist/paint/index.js +9 -1
- package/dist/paint-editor/index.cjs +10 -7
- package/dist/paint-editor/index.cjs.map +1 -1
- package/dist/paint-editor/index.d.cts +10 -7
- package/dist/paint-editor/index.d.ts +10 -7
- package/dist/paint-editor/index.js +5 -2
- package/dist/paint-editor/index.js.map +1 -1
- package/dist/{pathfinder-D8KQ6blQ.d.cts → pathfinder-7JkMwYvC.d.cts} +1 -1
- package/dist/{pathfinder-Celbi3e6.d.ts → pathfinder-GM3UWdBZ.d.ts} +1 -1
- package/dist/{pool-BfuxBKTd.d.cts → pool-04qp8iW4.d.cts} +1 -1
- package/dist/{pool-8JZGWHvR.d.ts → pool-CkTxlLMC.d.ts} +1 -1
- package/dist/provenance-DmlcgdzT.d.cts +426 -0
- package/dist/provenance-uh5r2TQ8.d.ts +426 -0
- package/dist/{rand-BaqEOs1Y.d.ts → rand-BszBST4s.d.ts} +31 -1
- package/dist/{rand-DdpFzCo6.d.cts → rand-DOH_aMvm.d.cts} +31 -1
- package/dist/{svg-pwXWq6s2.d.cts → svg-BDDKvWWY.d.cts} +2 -2
- package/dist/{svg-CxxqG3_W.d.ts → svg-rV6_HPmn.d.ts} +2 -2
- package/dist/{tools-3EBjR91b.d.cts → tools-BAjSbTdY.d.cts} +1 -1
- package/dist/{tools-y1M6O3UT.d.ts → tools-DPYerqeR.d.ts} +1 -1
- package/dist/vector/index.cjs +2684 -1860
- package/dist/vector/index.cjs.map +1 -1
- package/dist/vector/index.d.cts +313 -71
- package/dist/vector/index.d.ts +313 -71
- package/dist/vector/index.js +4700 -3876
- package/dist/vector/index.js.map +1 -1
- package/dist/video-editor/index.d.cts +7 -4
- package/dist/video-editor/index.d.ts +7 -4
- package/dist/{warp-Ceqdz7kj.d.cts → warp-DQh9R7Ie.d.cts} +1 -1
- package/dist/{warp-C1gwu2G_.d.ts → warp-XVL6SpSh.d.ts} +1 -1
- package/package.json +1 -1
- package/skills/pixerate-image-editor/SKILL.md +4 -4
- package/skills/pixerate-vector/SKILL.md +20 -1
- package/dist/chunk-6CTZAGZ2.js.map +0 -1
- package/dist/chunk-HHTCDFZC.js.map +0 -1
- package/dist/chunk-NVTHUPJ6.cjs.map +0 -1
- package/dist/chunk-Z2H7KECK.cjs.map +0 -1
- /package/dist/{chunk-ESIWZMMK.js.map → chunk-6QQR4LKE.js.map} +0 -0
- /package/dist/{chunk-OXSV64JX.js.map → chunk-G6IKY6PL.js.map} +0 -0
- /package/dist/{chunk-7RJ6P7MI.js.map → chunk-KZXLZCQ7.js.map} +0 -0
- /package/dist/{chunk-FWEO3HSL.js.map → chunk-PQQF5KOW.js.map} +0 -0
|
@@ -1,10 +1,30 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
2
14
|
|
|
3
15
|
|
|
4
16
|
|
|
5
17
|
|
|
6
|
-
|
|
7
|
-
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
var _chunkECCXGELCcjs = require('../chunk-ECCXGELC.cjs');
|
|
8
28
|
|
|
9
29
|
|
|
10
30
|
|
|
@@ -12,664 +32,23 @@ require('../chunk-MKA3AHLV.cjs');
|
|
|
12
32
|
var _chunkBVP3TSLHcjs = require('../chunk-BVP3TSLH.cjs');
|
|
13
33
|
|
|
14
34
|
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
var _chunkQ6OUXEK3cjs = require('../chunk-Q6OUXEK3.cjs');
|
|
43
|
+
|
|
44
|
+
|
|
15
45
|
var _chunkRIWPYSKUcjs = require('../chunk-RIWPYSKU.cjs');
|
|
16
46
|
|
|
17
|
-
// src/generation/capabilities.ts
|
|
18
|
-
var REFERENCE_ROLE_NAME_REGEX = /^[A-Za-z](?:[A-Za-z0-9_-]*[A-Za-z0-9])?$/;
|
|
19
|
-
function isReferenceRoleName(value) {
|
|
20
|
-
return typeof value === "string" && value.length <= 64 && REFERENCE_ROLE_NAME_REGEX.test(value);
|
|
21
|
-
}
|
|
22
|
-
var REFERENCE_ROLES = [
|
|
23
|
-
"start_frame",
|
|
24
|
-
"end_frame",
|
|
25
|
-
"style_ref",
|
|
26
|
-
"character_ref",
|
|
27
|
-
"background_ref",
|
|
28
|
-
"mask",
|
|
29
|
-
"image_ref",
|
|
30
|
-
"video_ref",
|
|
31
|
-
"audio_ref"
|
|
32
|
-
];
|
|
33
|
-
var REFERENCE_ROLE_LABELS = {
|
|
34
|
-
start_frame: "Start frame",
|
|
35
|
-
end_frame: "End frame",
|
|
36
|
-
style_ref: "Style reference",
|
|
37
|
-
character_ref: "Character reference",
|
|
38
|
-
background_ref: "Background reference",
|
|
39
|
-
mask: "Mask",
|
|
40
|
-
image_ref: "Image reference",
|
|
41
|
-
video_ref: "Video reference",
|
|
42
|
-
audio_ref: "Audio reference"
|
|
43
|
-
};
|
|
44
|
-
var REFERENCE_ROLE_ALIASES = {
|
|
45
|
-
reference: "image_ref",
|
|
46
|
-
image: "image_ref",
|
|
47
|
-
style: "style_ref",
|
|
48
|
-
character: "character_ref",
|
|
49
|
-
background: "background_ref",
|
|
50
|
-
"start-frame": "start_frame",
|
|
51
|
-
"first-frame": "start_frame",
|
|
52
|
-
first_frame: "start_frame",
|
|
53
|
-
"end-frame": "end_frame",
|
|
54
|
-
"last-frame": "end_frame",
|
|
55
|
-
last_frame: "end_frame",
|
|
56
|
-
"style-ref": "style_ref",
|
|
57
|
-
"character-ref": "character_ref",
|
|
58
|
-
"background-ref": "background_ref",
|
|
59
|
-
"image-ref": "image_ref",
|
|
60
|
-
"video-ref": "video_ref",
|
|
61
|
-
"audio-ref": "audio_ref",
|
|
62
|
-
video: "video_ref",
|
|
63
|
-
audio: "audio_ref"
|
|
64
|
-
};
|
|
65
|
-
var isBuiltinRole = (role) => REFERENCE_ROLES.includes(role);
|
|
66
|
-
function referenceRoleLabel(role, caps) {
|
|
67
|
-
const declared = _optionalChain([caps, 'optionalAccess', _ => _.references, 'optionalAccess', _2 => _2.roles, 'access', _3 => _3[role], 'optionalAccess', _4 => _4.label]);
|
|
68
|
-
if (declared) return declared;
|
|
69
|
-
if (isBuiltinRole(role)) return REFERENCE_ROLE_LABELS[role];
|
|
70
|
-
const words = String(role).replace(/[_-]+/g, " ").trim();
|
|
71
|
-
return words.charAt(0).toUpperCase() + words.slice(1);
|
|
72
|
-
}
|
|
73
|
-
function normalizeReferenceRole(role, caps) {
|
|
74
|
-
const name = String(role).trim();
|
|
75
|
-
if (caps ? !!_optionalChain([caps, 'access', _5 => _5.references, 'optionalAccess', _6 => _6.roles, 'access', _7 => _7[name]]) : isBuiltinRole(name)) return name;
|
|
76
|
-
const lower = name.toLowerCase();
|
|
77
|
-
if (_optionalChain([caps, 'optionalAccess', _8 => _8.references, 'optionalAccess', _9 => _9.roles, 'access', _10 => _10[lower]])) return lower;
|
|
78
|
-
if (!caps && isBuiltinRole(lower)) return lower;
|
|
79
|
-
return _nullishCoalesce(REFERENCE_ROLE_ALIASES[lower], () => ( (isBuiltinRole(lower) ? lower : name)));
|
|
80
|
-
}
|
|
81
|
-
function mediaTypeMatches(mediaType, accepts) {
|
|
82
|
-
if (!accepts || accepts.length === 0) return true;
|
|
83
|
-
if (!mediaType) return false;
|
|
84
|
-
const type = mediaType.split(";")[0].trim().toLowerCase();
|
|
85
|
-
const kind = type.split("/")[0];
|
|
86
|
-
return accepts.some((entry) => {
|
|
87
|
-
const pattern = entry.trim().toLowerCase();
|
|
88
|
-
if (pattern === "*" || pattern === "*/*" || pattern === type) return true;
|
|
89
|
-
if (!pattern.includes("/")) return pattern === kind;
|
|
90
|
-
if (pattern.endsWith("/*")) return pattern.slice(0, -2) === kind;
|
|
91
|
-
return false;
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
var GENERATION_REQUEST_FIELDS = [
|
|
95
|
-
"model",
|
|
96
|
-
"prompt",
|
|
97
|
-
"negativePrompt",
|
|
98
|
-
"systemPrompt",
|
|
99
|
-
"aspectRatio",
|
|
100
|
-
"resolution",
|
|
101
|
-
"quality",
|
|
102
|
-
"count",
|
|
103
|
-
"duration",
|
|
104
|
-
"seed",
|
|
105
|
-
"mode",
|
|
106
|
-
"references",
|
|
107
|
-
"params"
|
|
108
|
-
];
|
|
109
|
-
function textFieldCapability(value) {
|
|
110
|
-
if (!value) return null;
|
|
111
|
-
return value === true ? {} : value;
|
|
112
|
-
}
|
|
113
|
-
function seedCapability(value) {
|
|
114
|
-
if (!value) return null;
|
|
115
|
-
return value === true ? {} : value;
|
|
116
|
-
}
|
|
117
|
-
function supportedReferenceRoles(caps) {
|
|
118
|
-
const roles = _nullishCoalesce(_optionalChain([caps, 'access', _11 => _11.references, 'optionalAccess', _12 => _12.roles]), () => ( {}));
|
|
119
|
-
const builtin = REFERENCE_ROLES.filter((role) => (_nullishCoalesce(_optionalChain([roles, 'access', _13 => _13[role], 'optionalAccess', _14 => _14.max]), () => ( 0))) > 0);
|
|
120
|
-
const custom = Object.keys(roles).filter(
|
|
121
|
-
(role) => !isBuiltinRole(role) && isReferenceRoleName(role) && (_nullishCoalesce(_optionalChain([roles, 'access', _15 => _15[role], 'optionalAccess', _16 => _16.max]), () => ( 0))) > 0
|
|
122
|
-
);
|
|
123
|
-
return [...builtin, ...custom];
|
|
124
|
-
}
|
|
125
|
-
function supportedModes(caps) {
|
|
126
|
-
const modes = ["generate"];
|
|
127
|
-
if (caps.editing) modes.push("edit");
|
|
128
|
-
if (caps.inpainting) modes.push("inpaint");
|
|
129
|
-
return modes;
|
|
130
|
-
}
|
|
131
|
-
var PRESENTATION_KEYS = ["name", "description", "badges", "icon", "group"];
|
|
132
|
-
function mergeCapabilities(remote, overlay = []) {
|
|
133
|
-
const overlayById = new Map(overlay.map((entry) => [entry.id, entry]));
|
|
134
|
-
const remoteIds = new Set(remote.map((model) => model.id));
|
|
135
|
-
const merged = remote.map((model) => {
|
|
136
|
-
const extra = overlayById.get(model.id);
|
|
137
|
-
if (!extra) return { ...model };
|
|
138
|
-
const next = { ...model };
|
|
139
|
-
for (const key of PRESENTATION_KEYS) {
|
|
140
|
-
if (extra[key] !== void 0) next[key] = extra[key];
|
|
141
|
-
}
|
|
142
|
-
return next;
|
|
143
|
-
});
|
|
144
|
-
for (const entry of overlay) {
|
|
145
|
-
if (remoteIds.has(entry.id) || !entry.media) continue;
|
|
146
|
-
remoteIds.add(entry.id);
|
|
147
|
-
merged.push({ ...entry });
|
|
148
|
-
}
|
|
149
|
-
return merged;
|
|
150
|
-
}
|
|
151
47
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
if (!match) return void 0;
|
|
157
|
-
const w = Number(match[1]);
|
|
158
|
-
const h = Number(match[2]);
|
|
159
|
-
if (!(w > 0) || !(h > 0)) return void 0;
|
|
160
|
-
return Math.log(w / h);
|
|
161
|
-
}
|
|
162
|
-
function resolutionRank(value) {
|
|
163
|
-
const text = String(value).trim().toLowerCase();
|
|
164
|
-
let pixels;
|
|
165
|
-
let match = /^(\d+(?:\.\d+)?)\s*[x×*]\s*(\d+(?:\.\d+)?)$/.exec(text);
|
|
166
|
-
if (match) pixels = Number(match[1]) * Number(match[2]);
|
|
167
|
-
else if (match = /^(\d+(?:\.\d+)?)p$/.exec(text)) pixels = Number(match[1]) ** 2 * 16 / 9;
|
|
168
|
-
else if (match = /^(\d+(?:\.\d+)?)k$/.exec(text)) pixels = (Number(match[1]) * 1024) ** 2;
|
|
169
|
-
return pixels && pixels > 0 ? Math.log(pixels) : void 0;
|
|
170
|
-
}
|
|
171
|
-
function resolutionMegapixels(value) {
|
|
172
|
-
const rank = resolutionRank(value);
|
|
173
|
-
return rank === void 0 ? void 0 : Math.exp(rank) / 1e6;
|
|
174
|
-
}
|
|
175
|
-
var QUALITY_LADDER = {
|
|
176
|
-
draft: 0,
|
|
177
|
-
preview: 0,
|
|
178
|
-
low: 1,
|
|
179
|
-
fast: 1,
|
|
180
|
-
turbo: 1,
|
|
181
|
-
standard: 2,
|
|
182
|
-
normal: 2,
|
|
183
|
-
medium: 2,
|
|
184
|
-
balanced: 2,
|
|
185
|
-
high: 3,
|
|
186
|
-
hd: 3,
|
|
187
|
-
quality: 3,
|
|
188
|
-
ultra: 4,
|
|
189
|
-
max: 5,
|
|
190
|
-
best: 5
|
|
191
|
-
};
|
|
192
|
-
function qualityRank(value) {
|
|
193
|
-
return QUALITY_LADDER[String(value).trim().toLowerCase()];
|
|
194
|
-
}
|
|
195
|
-
var numberRank = (value) => typeof value === "number" && Number.isFinite(value) ? value : void 0;
|
|
196
|
-
function snapToOption(value, options, rank, tie) {
|
|
197
|
-
const target = rank(value);
|
|
198
|
-
if (target === void 0) return void 0;
|
|
199
|
-
let best;
|
|
200
|
-
for (const option of options) {
|
|
201
|
-
const r = rank(option);
|
|
202
|
-
if (r === void 0) continue;
|
|
203
|
-
const distance = Math.abs(r - target);
|
|
204
|
-
if (!best || distance < best.distance - EPSILON || Math.abs(distance - best.distance) <= EPSILON && (tie === "lower" ? r < best.rank : r > best.rank)) {
|
|
205
|
-
best = { option, distance, rank: r };
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
return _optionalChain([best, 'optionalAccess', _17 => _17.option]);
|
|
209
|
-
}
|
|
210
|
-
function truncateText(text, max) {
|
|
211
|
-
if (text.length <= max) return text;
|
|
212
|
-
let end = max;
|
|
213
|
-
const code = text.charCodeAt(end - 1);
|
|
214
|
-
if (end > 0 && code >= 55296 && code <= 56319) end -= 1;
|
|
215
|
-
return text.slice(0, end);
|
|
216
|
-
}
|
|
217
|
-
function cloneRequest(request) {
|
|
218
|
-
const copy = { ...request };
|
|
219
|
-
if (request.references) copy.references = request.references.map((ref) => ({ ...ref }));
|
|
220
|
-
if (request.params) copy.params = { ...request.params };
|
|
221
|
-
return copy;
|
|
222
|
-
}
|
|
223
|
-
var describe = (value) => typeof value === "string" ? `"${value}"` : JSON.stringify(value);
|
|
224
|
-
var list = (options) => options.map(describe).join(", ");
|
|
225
|
-
var Planner = (_class = class {
|
|
226
|
-
constructor(caps, request, options, strategy) {;_class.prototype.__init.call(this);_class.prototype.__init2.call(this);
|
|
227
|
-
this.caps = caps;
|
|
228
|
-
this.request = request;
|
|
229
|
-
this.options = options;
|
|
230
|
-
this.strategy = strategy;
|
|
231
|
-
this.tie = strategy === "downgrade" ? "lower" : "higher";
|
|
232
|
-
this.strict = strategy === "error";
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
__init() {this.adjustments = []}
|
|
239
|
-
__init2() {this.errors = []}
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
adjust(field, from, to, kind, reason) {
|
|
243
|
-
this.adjustments.push({ field, from, to, kind, reason });
|
|
244
|
-
}
|
|
245
|
-
error(field, value, message) {
|
|
246
|
-
this.errors.push({ field, value, message });
|
|
247
|
-
}
|
|
248
|
-
/** Removes an unsupported field (or reports it under `error`). */
|
|
249
|
-
unsupported(field, message) {
|
|
250
|
-
const value = this.request[field];
|
|
251
|
-
if (this.strict) {
|
|
252
|
-
this.error(field, value, message);
|
|
253
|
-
return;
|
|
254
|
-
}
|
|
255
|
-
delete this.request[field];
|
|
256
|
-
this.adjust(field, value, void 0, "dropped", message);
|
|
257
|
-
}
|
|
258
|
-
defaulted(field, value, set) {
|
|
259
|
-
if (!this.options.fillDefaults || value === void 0) return;
|
|
260
|
-
set();
|
|
261
|
-
this.adjust(field, void 0, value, "defaulted", "Filled with the model default.");
|
|
262
|
-
}
|
|
263
|
-
planText(field, maxLength, measured) {
|
|
264
|
-
const value = this.request[field];
|
|
265
|
-
if (value === void 0 || maxLength === void 0) return;
|
|
266
|
-
if (typeof value !== "string") {
|
|
267
|
-
this.error(field, value, `Expected text.`);
|
|
268
|
-
return;
|
|
269
|
-
}
|
|
270
|
-
const text = _nullishCoalesce(measured, () => ( value));
|
|
271
|
-
if (text.length <= maxLength) return;
|
|
272
|
-
if (this.strict || measured !== void 0) {
|
|
273
|
-
this.error(
|
|
274
|
-
field,
|
|
275
|
-
text.length,
|
|
276
|
-
`${measured !== void 0 ? "Resolved text" : "Text"} is ${text.length} characters; the model accepts at most ${maxLength}.`
|
|
277
|
-
);
|
|
278
|
-
return;
|
|
279
|
-
}
|
|
280
|
-
const next = truncateText(value, maxLength);
|
|
281
|
-
this.request[field] = next;
|
|
282
|
-
this.adjust(field, value.length, next.length, "truncated", `Truncated to the model's ${maxLength}-character limit.`);
|
|
283
|
-
}
|
|
284
|
-
planEnum(field, cap, rank, label) {
|
|
285
|
-
const value = this.request[field];
|
|
286
|
-
if (value === void 0) {
|
|
287
|
-
if (cap) this.defaulted(field, cap.default, () => this.request[field] = cap.default);
|
|
288
|
-
return;
|
|
289
|
-
}
|
|
290
|
-
if (!cap || cap.options.length === 0) {
|
|
291
|
-
this.unsupported(field, `The model does not take a ${label}.`);
|
|
292
|
-
return;
|
|
293
|
-
}
|
|
294
|
-
if (cap.options.includes(value)) return;
|
|
295
|
-
if (this.strict) {
|
|
296
|
-
this.error(field, value, `${describe(value)} is not a supported ${label}; supported: ${list(cap.options)}.`);
|
|
297
|
-
return;
|
|
298
|
-
}
|
|
299
|
-
const snapped = snapToOption(value, cap.options, rank, this.tie);
|
|
300
|
-
const next = _nullishCoalesce(_nullishCoalesce(snapped, () => ( cap.default)), () => ( cap.options[0]));
|
|
301
|
-
this.request[field] = next;
|
|
302
|
-
this.adjust(
|
|
303
|
-
field,
|
|
304
|
-
value,
|
|
305
|
-
next,
|
|
306
|
-
"snapped",
|
|
307
|
-
snapped !== void 0 ? `${describe(value)} is not supported; using the nearest ${label}.` : `${describe(value)} is not supported; using ${cap.default !== void 0 ? "the default" : "the first option"}.`
|
|
308
|
-
);
|
|
309
|
-
}
|
|
310
|
-
/** Clamps/rounds/snaps a number. Returns the next value or `undefined` after an error. */
|
|
311
|
-
planNumber(field, value, spec, label) {
|
|
312
|
-
if (typeof value !== "number" || !Number.isFinite(value)) {
|
|
313
|
-
this.error(field, value, `Expected a number for ${label}.`);
|
|
314
|
-
return void 0;
|
|
315
|
-
}
|
|
316
|
-
const options = _optionalChain([spec, 'access', _18 => _18.options, 'optionalAccess', _19 => _19.filter, 'call', _20 => _20(
|
|
317
|
-
(o) => (spec.min === void 0 || o >= spec.min) && (spec.max === void 0 || o <= spec.max)
|
|
318
|
-
)]);
|
|
319
|
-
if (options && options.length > 0) {
|
|
320
|
-
if (options.includes(value)) return { value, changed: false };
|
|
321
|
-
if (this.strict) {
|
|
322
|
-
this.error(field, value, `${value} is not a supported ${label}; supported: ${list(options)}.`);
|
|
323
|
-
return void 0;
|
|
324
|
-
}
|
|
325
|
-
const next2 = snapToOption(value, options, numberRank, this.tie);
|
|
326
|
-
this.adjust(field, value, next2, "snapped", `${value} is not supported; using the nearest ${label}.`);
|
|
327
|
-
return { value: next2, changed: true };
|
|
328
|
-
}
|
|
329
|
-
let next = value;
|
|
330
|
-
if (spec.step !== void 0 && spec.step > 0) {
|
|
331
|
-
const base = _nullishCoalesce(spec.min, () => ( 0));
|
|
332
|
-
const steps = (next - base) / spec.step;
|
|
333
|
-
const rounded = Math.abs(steps - Math.trunc(steps) - 0.5) < EPSILON ? this.tie === "lower" ? Math.floor(steps) : Math.ceil(steps) : Math.round(steps);
|
|
334
|
-
next = Number((base + rounded * spec.step).toPrecision(12));
|
|
335
|
-
}
|
|
336
|
-
if (spec.integer && !Number.isInteger(next)) {
|
|
337
|
-
const frac = next - Math.floor(next);
|
|
338
|
-
next = Math.abs(frac - 0.5) < EPSILON ? this.tie === "lower" ? Math.floor(next) : Math.ceil(next) : Math.round(next);
|
|
339
|
-
}
|
|
340
|
-
let kind = "snapped";
|
|
341
|
-
if (spec.min !== void 0 && next < spec.min) {
|
|
342
|
-
next = spec.min;
|
|
343
|
-
kind = "clamped";
|
|
344
|
-
}
|
|
345
|
-
if (spec.max !== void 0 && next > spec.max) {
|
|
346
|
-
next = spec.max;
|
|
347
|
-
kind = "clamped";
|
|
348
|
-
}
|
|
349
|
-
if (next === value) return { value, changed: false };
|
|
350
|
-
const range = `${_nullishCoalesce(spec.min, () => ( "-\u221E"))}\u2013${_nullishCoalesce(spec.max, () => ( "\u221E"))}`;
|
|
351
|
-
if (this.strict) {
|
|
352
|
-
this.error(
|
|
353
|
-
field,
|
|
354
|
-
value,
|
|
355
|
-
kind === "clamped" ? `${label} must be within ${range}.` : `${value} is not a valid ${label} (try ${next}).`
|
|
356
|
-
);
|
|
357
|
-
return void 0;
|
|
358
|
-
}
|
|
359
|
-
this.adjust(
|
|
360
|
-
field,
|
|
361
|
-
value,
|
|
362
|
-
next,
|
|
363
|
-
kind,
|
|
364
|
-
kind === "clamped" ? `Clamped to the supported range ${range}.` : `Rounded to a supported ${label}.`
|
|
365
|
-
);
|
|
366
|
-
return { value: next, changed: true };
|
|
367
|
-
}
|
|
368
|
-
planCount() {
|
|
369
|
-
const value = this.request.count;
|
|
370
|
-
const cap = this.caps.count;
|
|
371
|
-
if (value === void 0) {
|
|
372
|
-
if (cap) this.defaulted("count", cap.default, () => this.request.count = cap.default);
|
|
373
|
-
return;
|
|
374
|
-
}
|
|
375
|
-
if (!cap) {
|
|
376
|
-
if (value === 1) return;
|
|
377
|
-
this.unsupported("count", "The model produces one output per request.");
|
|
378
|
-
return;
|
|
379
|
-
}
|
|
380
|
-
const result = this.planNumber("count", value, { min: 1, max: cap.max, integer: true, options: cap.options }, "output count");
|
|
381
|
-
if (result) this.request.count = result.value;
|
|
382
|
-
}
|
|
383
|
-
planDuration() {
|
|
384
|
-
const value = this.request.duration;
|
|
385
|
-
const cap = this.caps.duration;
|
|
386
|
-
if (value === void 0) {
|
|
387
|
-
if (cap) this.defaulted("duration", cap.default, () => this.request.duration = cap.default);
|
|
388
|
-
return;
|
|
389
|
-
}
|
|
390
|
-
if (!cap) {
|
|
391
|
-
this.unsupported("duration", "The model does not take a duration.");
|
|
392
|
-
return;
|
|
393
|
-
}
|
|
394
|
-
const result = this.planNumber("duration", value, cap, "duration");
|
|
395
|
-
if (result) this.request.duration = result.value;
|
|
396
|
-
}
|
|
397
|
-
planSeed() {
|
|
398
|
-
const value = this.request.seed;
|
|
399
|
-
if (value === void 0) return;
|
|
400
|
-
const cap = seedCapability(this.caps.seed);
|
|
401
|
-
if (!cap) {
|
|
402
|
-
this.unsupported("seed", "The model does not take a seed.");
|
|
403
|
-
return;
|
|
404
|
-
}
|
|
405
|
-
const result = this.planNumber("seed", value, { ...cap, integer: true }, "seed");
|
|
406
|
-
if (result) this.request.seed = result.value;
|
|
407
|
-
}
|
|
408
|
-
planMode() {
|
|
409
|
-
const mode = this.request.mode;
|
|
410
|
-
if (mode === void 0) return;
|
|
411
|
-
const modes = supportedModes(this.caps);
|
|
412
|
-
if (!modes.includes(mode)) {
|
|
413
|
-
this.error("mode", mode, `The model does not support ${describe(mode)}; supported: ${list(modes)}.`);
|
|
414
|
-
}
|
|
415
|
-
}
|
|
416
|
-
roleCapability(role) {
|
|
417
|
-
const cap = _optionalChain([this, 'access', _21 => _21.caps, 'access', _22 => _22.references, 'optionalAccess', _23 => _23.roles, 'access', _24 => _24[role]]);
|
|
418
|
-
if (cap && cap.max > 0) return cap;
|
|
419
|
-
if (role === "mask" && this.caps.inpainting) return { max: 1 };
|
|
420
|
-
return void 0;
|
|
421
|
-
}
|
|
422
|
-
/** Turns `options.mentions` into references (appended after the request's own). */
|
|
423
|
-
addMentions() {
|
|
424
|
-
const mentions = this.options.mentions;
|
|
425
|
-
if (!_optionalChain([mentions, 'optionalAccess', _25 => _25.length])) return;
|
|
426
|
-
const refs = [..._nullishCoalesce(this.request.references, () => ( []))];
|
|
427
|
-
for (const mention of mentions) {
|
|
428
|
-
if (!mention || typeof mention.id !== "string" || mention.id === "") continue;
|
|
429
|
-
let role = _nullishCoalesce(mention.role, () => ( void 0));
|
|
430
|
-
if (!role) {
|
|
431
|
-
role = _nullishCoalesce(this.options.defaultMentionRole, () => ( this.inferRole(mention.mediaType)));
|
|
432
|
-
this.adjust(
|
|
433
|
-
`references.${role}`,
|
|
434
|
-
void 0,
|
|
435
|
-
role,
|
|
436
|
-
"defaulted",
|
|
437
|
-
`@${_nullishCoalesce(mention.label, () => ( mention.id))} has no role; using ${role}.`
|
|
438
|
-
);
|
|
439
|
-
}
|
|
440
|
-
refs.push({
|
|
441
|
-
id: mention.id,
|
|
442
|
-
role,
|
|
443
|
-
...mention.url !== void 0 ? { url: mention.url } : {},
|
|
444
|
-
...mention.mediaType !== void 0 ? { mediaType: mention.mediaType } : {},
|
|
445
|
-
...mention.contentHash !== void 0 ? { contentHash: mention.contentHash } : {}
|
|
446
|
-
});
|
|
447
|
-
}
|
|
448
|
-
this.request.references = refs;
|
|
449
|
-
}
|
|
450
|
-
/** First role of the model (other than `mask`) whose `accepts` matches `mediaType`. */
|
|
451
|
-
inferRole(mediaType) {
|
|
452
|
-
for (const role of supportedReferenceRoles(this.caps)) {
|
|
453
|
-
if (role === "mask") continue;
|
|
454
|
-
const cap = this.roleCapability(role);
|
|
455
|
-
if (cap && (mediaType === void 0 || mediaTypeMatches(mediaType, cap.accepts))) return role;
|
|
456
|
-
}
|
|
457
|
-
return "image_ref";
|
|
458
|
-
}
|
|
459
|
-
planReferences() {
|
|
460
|
-
const refs = this.request.references;
|
|
461
|
-
const allowDrop = !this.strict && (_nullishCoalesce(this.options.dropUnsupportedReferences, () => ( (this.strategy === "nearest" || this.strategy === "downgrade"))));
|
|
462
|
-
const byRole = /* @__PURE__ */ new Map();
|
|
463
|
-
const kept = [];
|
|
464
|
-
const unsupported = /* @__PURE__ */ new Map();
|
|
465
|
-
for (const [index, original] of (_nullishCoalesce(refs, () => ( []))).entries()) {
|
|
466
|
-
let ref = original;
|
|
467
|
-
if (!ref || typeof ref.id !== "string" || ref.id === "" || !isReferenceRoleName(ref.role)) {
|
|
468
|
-
this.error(`references.${index}`, ref, "Each reference needs an `id` and a valid `role`.");
|
|
469
|
-
continue;
|
|
470
|
-
}
|
|
471
|
-
if (!this.roleCapability(ref.role)) {
|
|
472
|
-
const alias = normalizeReferenceRole(ref.role, this.caps);
|
|
473
|
-
if (alias !== ref.role && this.roleCapability(alias)) {
|
|
474
|
-
if (this.strict) {
|
|
475
|
-
this.error(`references.${ref.role}`, ref.role, `The model calls this role ${describe(alias)}.`);
|
|
476
|
-
continue;
|
|
477
|
-
}
|
|
478
|
-
this.adjust(
|
|
479
|
-
`references.${ref.role}`,
|
|
480
|
-
ref.role,
|
|
481
|
-
alias,
|
|
482
|
-
"snapped",
|
|
483
|
-
`Using the model's ${alias} role for ${describe(ref.role)}.`
|
|
484
|
-
);
|
|
485
|
-
ref = { ...ref, role: alias };
|
|
486
|
-
} else {
|
|
487
|
-
unsupported.set(ref.role, (_nullishCoalesce(unsupported.get(ref.role), () => ( 0))) + 1);
|
|
488
|
-
continue;
|
|
489
|
-
}
|
|
490
|
-
}
|
|
491
|
-
const cap = this.roleCapability(ref.role);
|
|
492
|
-
if (ref.mediaType !== void 0 && !mediaTypeMatches(ref.mediaType, cap.accepts)) {
|
|
493
|
-
const message = `${describe(ref.id)} is ${describe(ref.mediaType)}; ${ref.role} accepts ${list(_nullishCoalesce(cap.accepts, () => ( [])))}.`;
|
|
494
|
-
if (allowDrop) this.adjust(`references.${ref.role}`, ref.id, void 0, "dropped", message);
|
|
495
|
-
else this.error(`references.${ref.role}`, ref.id, message);
|
|
496
|
-
continue;
|
|
497
|
-
}
|
|
498
|
-
const group = _nullishCoalesce(byRole.get(ref.role), () => ( []));
|
|
499
|
-
if (group.some((other) => other.id === ref.id)) {
|
|
500
|
-
this.adjust(`references.${ref.role}`, ref.id, void 0, "dropped", `Duplicate reference "${ref.id}" removed.`);
|
|
501
|
-
continue;
|
|
502
|
-
}
|
|
503
|
-
group.push(ref);
|
|
504
|
-
byRole.set(ref.role, group);
|
|
505
|
-
kept.push(ref);
|
|
506
|
-
}
|
|
507
|
-
for (const [role, count] of unsupported) {
|
|
508
|
-
const message = this.caps.media === "text" || !this.caps.references ? `The ${this.caps.media} model "${this.caps.id}" does not accept reference inputs (${role}).` : `The model does not accept ${role} references.`;
|
|
509
|
-
if (allowDrop) this.adjust(`references.${role}`, count, 0, "dropped", message);
|
|
510
|
-
else this.error(`references.${role}`, count, message);
|
|
511
|
-
}
|
|
512
|
-
const removed = /* @__PURE__ */ new Set();
|
|
513
|
-
const custom = supportedReferenceRoles(this.caps).filter(
|
|
514
|
-
(role) => !REFERENCE_ROLES.includes(role)
|
|
515
|
-
);
|
|
516
|
-
for (const role of [...REFERENCE_ROLES, ...custom]) {
|
|
517
|
-
const cap = this.roleCapability(role);
|
|
518
|
-
const group = _nullishCoalesce(byRole.get(role), () => ( []));
|
|
519
|
-
if (!cap) continue;
|
|
520
|
-
if (group.length > cap.max) {
|
|
521
|
-
if (this.strict) {
|
|
522
|
-
this.error(`references.${role}`, group.length, `At most ${cap.max} ${role} reference(s) are supported.`);
|
|
523
|
-
} else {
|
|
524
|
-
group.slice(cap.max).forEach((ref) => removed.add(ref));
|
|
525
|
-
this.adjust(
|
|
526
|
-
`references.${role}`,
|
|
527
|
-
group.length,
|
|
528
|
-
cap.max,
|
|
529
|
-
"truncated",
|
|
530
|
-
`Kept the first ${cap.max} ${role} reference(s); the model accepts no more.`
|
|
531
|
-
);
|
|
532
|
-
}
|
|
533
|
-
}
|
|
534
|
-
if (cap.min !== void 0 && group.length < cap.min) {
|
|
535
|
-
this.error(`references.${role}`, group.length, `At least ${cap.min} ${role} reference(s) are required.`);
|
|
536
|
-
}
|
|
537
|
-
}
|
|
538
|
-
let next = kept.filter((ref) => !removed.has(ref));
|
|
539
|
-
const maxTotal = _optionalChain([this, 'access', _26 => _26.caps, 'access', _27 => _27.references, 'optionalAccess', _28 => _28.maxTotal]);
|
|
540
|
-
if (maxTotal !== void 0 && next.length > maxTotal) {
|
|
541
|
-
if (this.strict) {
|
|
542
|
-
this.error("references", next.length, `At most ${maxTotal} references are supported in total.`);
|
|
543
|
-
} else {
|
|
544
|
-
this.adjust(
|
|
545
|
-
"references",
|
|
546
|
-
next.length,
|
|
547
|
-
maxTotal,
|
|
548
|
-
"truncated",
|
|
549
|
-
`Kept the first ${maxTotal} references; the model accepts no more in total.`
|
|
550
|
-
);
|
|
551
|
-
next = next.slice(0, maxTotal);
|
|
552
|
-
}
|
|
553
|
-
}
|
|
554
|
-
if (this.request.mode === "inpaint" && !next.some((ref) => ref.role === "mask")) {
|
|
555
|
-
this.error("references.mask", 0, "Inpainting needs a `mask` reference.");
|
|
556
|
-
}
|
|
557
|
-
if (refs === void 0) return;
|
|
558
|
-
if (!this.strict) {
|
|
559
|
-
if (next.length > 0) this.request.references = next;
|
|
560
|
-
else delete this.request.references;
|
|
561
|
-
}
|
|
562
|
-
}
|
|
563
|
-
planParam(name, spec, value) {
|
|
564
|
-
const field = `params.${name}`;
|
|
565
|
-
if (!spec) {
|
|
566
|
-
if (this.strict) this.error(field, value, `Unknown parameter "${name}".`);
|
|
567
|
-
else this.adjust(field, value, void 0, "dropped", `The model has no "${name}" parameter.`);
|
|
568
|
-
return void 0;
|
|
569
|
-
}
|
|
570
|
-
const label = _nullishCoalesce(spec.label, () => ( name));
|
|
571
|
-
if (spec.type === "boolean") {
|
|
572
|
-
if (typeof value !== "boolean") this.error(field, value, `Expected true or false for ${label}.`);
|
|
573
|
-
return value;
|
|
574
|
-
}
|
|
575
|
-
if (spec.type === "enum") {
|
|
576
|
-
if (spec.options.includes(value)) return value;
|
|
577
|
-
if (this.strict) {
|
|
578
|
-
this.error(field, value, `${describe(value)} is not a supported ${label}; supported: ${list(spec.options)}.`);
|
|
579
|
-
return value;
|
|
580
|
-
}
|
|
581
|
-
const numeric = spec.options.every((o) => typeof o === "number");
|
|
582
|
-
const snapped = numeric ? snapToOption(value, spec.options, numberRank, this.tie) : void 0;
|
|
583
|
-
const next = _nullishCoalesce(_nullishCoalesce(snapped, () => ( spec.default)), () => ( spec.options[0]));
|
|
584
|
-
this.adjust(
|
|
585
|
-
field,
|
|
586
|
-
value,
|
|
587
|
-
next,
|
|
588
|
-
"snapped",
|
|
589
|
-
snapped !== void 0 ? `Using the nearest supported ${label}.` : `${describe(value)} is not supported; using ${spec.default !== void 0 ? "the default" : "the first option"}.`
|
|
590
|
-
);
|
|
591
|
-
return next;
|
|
592
|
-
}
|
|
593
|
-
const result = this.planNumber(field, value, { ...spec, integer: spec.type === "integer" }, label);
|
|
594
|
-
return result ? result.value : value;
|
|
595
|
-
}
|
|
596
|
-
planParams() {
|
|
597
|
-
const params = this.request.params;
|
|
598
|
-
const specs = _nullishCoalesce(this.caps.params, () => ( {}));
|
|
599
|
-
const next = {};
|
|
600
|
-
for (const [name, value] of Object.entries(_nullishCoalesce(params, () => ( {})))) {
|
|
601
|
-
if (value === void 0) continue;
|
|
602
|
-
const planned = this.planParam(name, specs[name], value);
|
|
603
|
-
if (planned !== void 0) next[name] = planned;
|
|
604
|
-
else if (this.strict) next[name] = value;
|
|
605
|
-
}
|
|
606
|
-
if (this.options.fillDefaults) {
|
|
607
|
-
for (const [name, spec] of Object.entries(specs)) {
|
|
608
|
-
if (next[name] === void 0 && spec.default !== void 0) {
|
|
609
|
-
next[name] = spec.default;
|
|
610
|
-
this.adjust(`params.${name}`, void 0, spec.default, "defaulted", "Filled with the model default.");
|
|
611
|
-
}
|
|
612
|
-
}
|
|
613
|
-
}
|
|
614
|
-
if (Object.keys(next).length > 0) this.request.params = next;
|
|
615
|
-
else delete this.request.params;
|
|
616
|
-
}
|
|
617
|
-
run() {
|
|
618
|
-
const { caps, request } = this;
|
|
619
|
-
for (const key of Object.keys(request)) {
|
|
620
|
-
if (GENERATION_REQUEST_FIELDS.includes(key)) continue;
|
|
621
|
-
const value = request[key];
|
|
622
|
-
if (this.strict) this.error(key, value, `Unknown request field "${key}".`);
|
|
623
|
-
else {
|
|
624
|
-
delete request[key];
|
|
625
|
-
this.adjust(key, value, void 0, "dropped", `Unknown request field "${key}".`);
|
|
626
|
-
}
|
|
627
|
-
}
|
|
628
|
-
if (request.model !== void 0 && request.model !== caps.id) {
|
|
629
|
-
this.error("model", request.model, `The request targets "${request.model}" but the plan is for "${caps.id}".`);
|
|
630
|
-
}
|
|
631
|
-
request.model = caps.id;
|
|
632
|
-
const promptCap = _nullishCoalesce(caps.prompt, () => ( {}));
|
|
633
|
-
if (promptCap.required && !(_nullishCoalesce(request.prompt, () => ( ""))).trim()) {
|
|
634
|
-
this.error("prompt", request.prompt, "A prompt is required.");
|
|
635
|
-
}
|
|
636
|
-
const countResolved = _nullishCoalesce(promptCap.countResolved, () => ( true));
|
|
637
|
-
const measured = countResolved && this.options.resolvedPrompt !== void 0 && this.options.resolvedPrompt !== request.prompt ? this.options.resolvedPrompt : void 0;
|
|
638
|
-
this.planText("prompt", promptCap.maxLength, measured);
|
|
639
|
-
for (const field of ["negativePrompt", "systemPrompt"]) {
|
|
640
|
-
if (request[field] === void 0) continue;
|
|
641
|
-
const cap = textFieldCapability(caps[field]);
|
|
642
|
-
if (!cap) {
|
|
643
|
-
this.unsupported(field, `The model does not take a ${field === "negativePrompt" ? "negative" : "system"} prompt.`);
|
|
644
|
-
continue;
|
|
645
|
-
}
|
|
646
|
-
this.planText(field, cap.maxLength);
|
|
647
|
-
}
|
|
648
|
-
this.planEnum("aspectRatio", caps.aspectRatios, aspectRatioRank, "aspect ratio");
|
|
649
|
-
this.planEnum("resolution", caps.resolutions, resolutionRank, "resolution");
|
|
650
|
-
this.planEnum("quality", caps.quality, qualityRank, "quality");
|
|
651
|
-
this.planCount();
|
|
652
|
-
this.planDuration();
|
|
653
|
-
this.planSeed();
|
|
654
|
-
this.planMode();
|
|
655
|
-
this.addMentions();
|
|
656
|
-
this.planReferences();
|
|
657
|
-
this.planParams();
|
|
658
|
-
}
|
|
659
|
-
}, _class);
|
|
660
|
-
function planGenerationRequest(request, caps, options = {}) {
|
|
661
|
-
const strategy = _nullishCoalesce(options.strategy, () => ( "nearest"));
|
|
662
|
-
const planner = new Planner(caps, cloneRequest(_nullishCoalesce(request, () => ( {}))), options, strategy);
|
|
663
|
-
planner.run();
|
|
664
|
-
return {
|
|
665
|
-
ok: planner.errors.length === 0,
|
|
666
|
-
request: planner.request,
|
|
667
|
-
adjustments: planner.adjustments,
|
|
668
|
-
errors: planner.errors,
|
|
669
|
-
model: caps.id,
|
|
670
|
-
strategy
|
|
671
|
-
};
|
|
672
|
-
}
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
var _chunkFD4LPFAEcjs = require('../chunk-FD4LPFAE.cjs');
|
|
51
|
+
require('../chunk-MKA3AHLV.cjs');
|
|
673
52
|
|
|
674
53
|
// src/generation/schema.ts
|
|
675
54
|
function enumSchema(cap, description) {
|
|
@@ -716,7 +95,7 @@ function capabilitiesToJsonSchema(caps) {
|
|
|
716
95
|
...prompt.required ? { minLength: 1 } : {}
|
|
717
96
|
};
|
|
718
97
|
if (prompt.required) required.push("prompt");
|
|
719
|
-
const negative = textFieldCapability(caps.negativePrompt);
|
|
98
|
+
const negative = _chunkECCXGELCcjs.textFieldCapability.call(void 0, caps.negativePrompt);
|
|
720
99
|
if (negative) {
|
|
721
100
|
properties.negativePrompt = {
|
|
722
101
|
type: "string",
|
|
@@ -724,7 +103,7 @@ function capabilitiesToJsonSchema(caps) {
|
|
|
724
103
|
...negative.maxLength !== void 0 ? { maxLength: negative.maxLength } : {}
|
|
725
104
|
};
|
|
726
105
|
}
|
|
727
|
-
const system = textFieldCapability(caps.systemPrompt);
|
|
106
|
+
const system = _chunkECCXGELCcjs.textFieldCapability.call(void 0, caps.systemPrompt);
|
|
728
107
|
if (system) {
|
|
729
108
|
properties.systemPrompt = {
|
|
730
109
|
type: "string",
|
|
@@ -732,18 +111,18 @@ function capabilitiesToJsonSchema(caps) {
|
|
|
732
111
|
...system.maxLength !== void 0 ? { maxLength: system.maxLength } : {}
|
|
733
112
|
};
|
|
734
113
|
}
|
|
735
|
-
if (_optionalChain([caps, 'access',
|
|
736
|
-
if (_optionalChain([caps, 'access',
|
|
737
|
-
if (_optionalChain([caps, 'access',
|
|
114
|
+
if (_optionalChain([caps, 'access', _ => _.aspectRatios, 'optionalAccess', _2 => _2.options, 'access', _3 => _3.length])) properties.aspectRatio = enumSchema(caps.aspectRatios, "Aspect ratio (width:height).");
|
|
115
|
+
if (_optionalChain([caps, 'access', _4 => _4.resolutions, 'optionalAccess', _5 => _5.options, 'access', _6 => _6.length])) properties.resolution = enumSchema(caps.resolutions, "Output resolution, low to high.");
|
|
116
|
+
if (_optionalChain([caps, 'access', _7 => _7.quality, 'optionalAccess', _8 => _8.options, 'access', _9 => _9.length])) properties.quality = enumSchema(caps.quality, "Quality level, low to high.");
|
|
738
117
|
if (caps.count) {
|
|
739
|
-
const options = _optionalChain([caps, 'access',
|
|
740
|
-
properties.count = _optionalChain([options, 'optionalAccess',
|
|
118
|
+
const options = _optionalChain([caps, 'access', _10 => _10.count, 'access', _11 => _11.options, 'optionalAccess', _12 => _12.filter, 'call', _13 => _13((o) => o >= 1 && o <= caps.count.max)]);
|
|
119
|
+
properties.count = _optionalChain([options, 'optionalAccess', _14 => _14.length]) ? { type: "integer", enum: options, description: "Number of outputs." } : { type: "integer", minimum: 1, maximum: caps.count.max, description: "Number of outputs." };
|
|
741
120
|
if (caps.count.default !== void 0) properties.count.default = caps.count.default;
|
|
742
121
|
}
|
|
743
122
|
if (caps.duration) {
|
|
744
123
|
const d = caps.duration;
|
|
745
|
-
const options = _optionalChain([d, 'access',
|
|
746
|
-
properties.duration = _optionalChain([options, 'optionalAccess',
|
|
124
|
+
const options = _optionalChain([d, 'access', _15 => _15.options, 'optionalAccess', _16 => _16.filter, 'call', _17 => _17((o) => (d.min === void 0 || o >= d.min) && (d.max === void 0 || o <= d.max))]);
|
|
125
|
+
properties.duration = _optionalChain([options, 'optionalAccess', _18 => _18.length]) ? { type: "number", enum: options, description: "Duration in seconds." } : {
|
|
747
126
|
type: "number",
|
|
748
127
|
description: d.step !== void 0 ? `Duration in seconds (step ${d.step}).` : "Duration in seconds.",
|
|
749
128
|
...d.min !== void 0 ? { minimum: d.min } : {},
|
|
@@ -751,7 +130,7 @@ function capabilitiesToJsonSchema(caps) {
|
|
|
751
130
|
};
|
|
752
131
|
if (d.default !== void 0) properties.duration.default = d.default;
|
|
753
132
|
}
|
|
754
|
-
const seed = seedCapability(caps.seed);
|
|
133
|
+
const seed = _chunkECCXGELCcjs.seedCapability.call(void 0, caps.seed);
|
|
755
134
|
if (seed) {
|
|
756
135
|
properties.seed = {
|
|
757
136
|
type: "integer",
|
|
@@ -760,24 +139,24 @@ function capabilitiesToJsonSchema(caps) {
|
|
|
760
139
|
...seed.max !== void 0 ? { maximum: seed.max } : {}
|
|
761
140
|
};
|
|
762
141
|
}
|
|
763
|
-
const modes = supportedModes(caps);
|
|
142
|
+
const modes = _chunkECCXGELCcjs.supportedModes.call(void 0, caps);
|
|
764
143
|
if (modes.length > 1) {
|
|
765
144
|
properties.mode = { type: "string", enum: modes, default: "generate", description: "Generate, edit a source, or inpaint with a mask." };
|
|
766
145
|
}
|
|
767
|
-
const roles = supportedReferenceRoles(caps);
|
|
146
|
+
const roles = _chunkECCXGELCcjs.supportedReferenceRoles.call(void 0, caps);
|
|
768
147
|
if (caps.inpainting && !roles.includes("mask")) roles.push("mask");
|
|
769
148
|
if (roles.length > 0) {
|
|
770
149
|
const limits = roles.map((role) => {
|
|
771
|
-
const cap = _nullishCoalesce(_optionalChain([caps, 'access',
|
|
150
|
+
const cap = _nullishCoalesce(_optionalChain([caps, 'access', _19 => _19.references, 'optionalAccess', _20 => _20.roles, 'access', _21 => _21[role]]), () => ( { max: 1 }));
|
|
772
151
|
const min = cap.min ? `${cap.min}\u2013` : "up to ";
|
|
773
|
-
const accepts = "accepts" in cap && _optionalChain([cap, 'access',
|
|
774
|
-
return `${role} (${referenceRoleLabel(role, caps)}): ${min}${cap.max}${accepts}`;
|
|
152
|
+
const accepts = "accepts" in cap && _optionalChain([cap, 'access', _22 => _22.accepts, 'optionalAccess', _23 => _23.length]) ? `, ${cap.accepts.join("/")} only` : "";
|
|
153
|
+
return `${role} (${_chunkECCXGELCcjs.referenceRoleLabel.call(void 0, role, caps)}): ${min}${cap.max}${accepts}`;
|
|
775
154
|
});
|
|
776
|
-
const perRoleTotal = roles.reduce((sum, role) => sum + (_nullishCoalesce(_optionalChain([caps, 'access',
|
|
777
|
-
const maxItems = Math.min(_nullishCoalesce(_optionalChain([caps, 'access',
|
|
155
|
+
const perRoleTotal = roles.reduce((sum, role) => sum + (_nullishCoalesce(_optionalChain([caps, 'access', _24 => _24.references, 'optionalAccess', _25 => _25.roles, 'access', _26 => _26[role], 'optionalAccess', _27 => _27.max]), () => ( 1))), 0);
|
|
156
|
+
const maxItems = Math.min(_nullishCoalesce(_optionalChain([caps, 'access', _28 => _28.references, 'optionalAccess', _29 => _29.maxTotal]), () => ( Infinity)), perRoleTotal);
|
|
778
157
|
properties.references = {
|
|
779
158
|
type: "array",
|
|
780
|
-
description: `Reference inputs by role. Limits: ${limits.join("; ")}${_optionalChain([caps, 'access',
|
|
159
|
+
description: `Reference inputs by role. Limits: ${limits.join("; ")}${_optionalChain([caps, 'access', _30 => _30.references, 'optionalAccess', _31 => _31.maxTotal]) !== void 0 ? `; at most ${caps.references.maxTotal} in total` : ""}.`,
|
|
781
160
|
maxItems,
|
|
782
161
|
items: {
|
|
783
162
|
type: "object",
|
|
@@ -792,7 +171,7 @@ function capabilitiesToJsonSchema(caps) {
|
|
|
792
171
|
additionalProperties: false
|
|
793
172
|
}
|
|
794
173
|
};
|
|
795
|
-
if (roles.some((role) => (_nullishCoalesce(_optionalChain([caps, 'access',
|
|
174
|
+
if (roles.some((role) => (_nullishCoalesce(_optionalChain([caps, 'access', _32 => _32.references, 'optionalAccess', _33 => _33.roles, 'access', _34 => _34[role], 'optionalAccess', _35 => _35.min]), () => ( 0))) > 0)) required.push("references");
|
|
796
175
|
}
|
|
797
176
|
const params = Object.entries(_nullishCoalesce(caps.params, () => ( {})));
|
|
798
177
|
if (params.length > 0) {
|
|
@@ -813,54 +192,12 @@ function capabilitiesToJsonSchema(caps) {
|
|
|
813
192
|
};
|
|
814
193
|
}
|
|
815
194
|
|
|
816
|
-
// src/generation/hash.ts
|
|
817
|
-
function stableStringify(value) {
|
|
818
|
-
if (Array.isArray(value)) return `[${value.map((item) => item === void 0 ? "null" : stableStringify(item)).join(",")}]`;
|
|
819
|
-
if (value && typeof value === "object") {
|
|
820
|
-
const entries = Object.keys(value).filter((key) => value[key] !== void 0).sort().map((key) => `${JSON.stringify(key)}:${stableStringify(value[key])}`);
|
|
821
|
-
return `{${entries.join(",")}}`;
|
|
822
|
-
}
|
|
823
|
-
return _nullishCoalesce(JSON.stringify(value), () => ( "null"));
|
|
824
|
-
}
|
|
825
|
-
var FNV_PRIME = 16777619;
|
|
826
|
-
function hashText(text) {
|
|
827
|
-
let a = 2166136261;
|
|
828
|
-
let b = 789454171;
|
|
829
|
-
for (let i = 0; i < text.length; i++) {
|
|
830
|
-
const unit = text.charCodeAt(i);
|
|
831
|
-
a = Math.imul(a ^ unit & 255, FNV_PRIME);
|
|
832
|
-
a = Math.imul(a ^ unit >>> 8, FNV_PRIME);
|
|
833
|
-
b = Math.imul(b ^ unit >>> 8, FNV_PRIME);
|
|
834
|
-
b = Math.imul(b ^ unit & 255, FNV_PRIME);
|
|
835
|
-
b ^= b >>> 15;
|
|
836
|
-
}
|
|
837
|
-
a ^= a >>> 16;
|
|
838
|
-
a = Math.imul(a, 2246822507);
|
|
839
|
-
a ^= a >>> 13;
|
|
840
|
-
b ^= b >>> 16;
|
|
841
|
-
b = Math.imul(b, 3266489909);
|
|
842
|
-
b ^= b >>> 13;
|
|
843
|
-
const hex = (n) => (n >>> 0).toString(16).padStart(8, "0");
|
|
844
|
-
return `h1-${hex(a)}${hex(b)}`;
|
|
845
|
-
}
|
|
846
|
-
function hashValue(value) {
|
|
847
|
-
return hashText(stableStringify(value));
|
|
848
|
-
}
|
|
849
|
-
var PRESENTATION_ONLY = /* @__PURE__ */ new Set(["name", "description", "badges", "icon", "group", "timing"]);
|
|
850
|
-
function hashCapabilities(caps) {
|
|
851
|
-
const relevant = {};
|
|
852
|
-
for (const key of Object.keys(caps)) {
|
|
853
|
-
if (!PRESENTATION_ONLY.has(key)) relevant[key] = caps[key];
|
|
854
|
-
}
|
|
855
|
-
return hashValue(relevant);
|
|
856
|
-
}
|
|
857
|
-
|
|
858
195
|
// src/generation/tools.ts
|
|
859
196
|
var STRATEGIES = ["nearest", "upgrade", "downgrade", "error"];
|
|
860
197
|
function knownRoles(models) {
|
|
861
|
-
const roles = [...REFERENCE_ROLES];
|
|
198
|
+
const roles = [..._chunkECCXGELCcjs.REFERENCE_ROLES];
|
|
862
199
|
for (const model of models) {
|
|
863
|
-
for (const role of supportedReferenceRoles(model)) if (!roles.includes(role)) roles.push(role);
|
|
200
|
+
for (const role of _chunkECCXGELCcjs.supportedReferenceRoles.call(void 0, model)) if (!roles.includes(role)) roles.push(role);
|
|
864
201
|
}
|
|
865
202
|
return roles;
|
|
866
203
|
}
|
|
@@ -934,7 +271,7 @@ function createGenerationToolProvider(options) {
|
|
|
934
271
|
const request = { ..._nullishCoalesce(args.request, () => ( {})), model: model.id };
|
|
935
272
|
return {
|
|
936
273
|
model,
|
|
937
|
-
plan: planGenerationRequest(request, model, {
|
|
274
|
+
plan: _chunkECCXGELCcjs.planGenerationRequest.call(void 0, request, model, {
|
|
938
275
|
strategy: _nullishCoalesce(args.strategy, () => ( defaultStrategy)),
|
|
939
276
|
resolvedPrompt: args.resolvedPrompt
|
|
940
277
|
})
|
|
@@ -959,7 +296,7 @@ function createGenerationToolProvider(options) {
|
|
|
959
296
|
};
|
|
960
297
|
};
|
|
961
298
|
const tools = () => {
|
|
962
|
-
const
|
|
299
|
+
const list = [
|
|
963
300
|
{
|
|
964
301
|
name: "list_models",
|
|
965
302
|
title: "List generation models",
|
|
@@ -984,7 +321,7 @@ function createGenerationToolProvider(options) {
|
|
|
984
321
|
media: m.media,
|
|
985
322
|
...m.name ? { name: m.name } : {},
|
|
986
323
|
...m.description ? { description: m.description } : {},
|
|
987
|
-
..._optionalChain([m, 'access',
|
|
324
|
+
..._optionalChain([m, 'access', _36 => _36.badges, 'optionalAccess', _37 => _37.length]) ? { badges: [...m.badges] } : {},
|
|
988
325
|
requestSchema: capabilitiesToJsonSchema(m)
|
|
989
326
|
}))
|
|
990
327
|
})
|
|
@@ -1006,7 +343,7 @@ function createGenerationToolProvider(options) {
|
|
|
1006
343
|
];
|
|
1007
344
|
if (options.estimate) {
|
|
1008
345
|
const estimate = options.estimate;
|
|
1009
|
-
|
|
346
|
+
list.push({
|
|
1010
347
|
name: "estimate_generation",
|
|
1011
348
|
title: "Estimate a generation",
|
|
1012
349
|
description: "Estimates cost and/or time of a request after planning it. Does not generate anything.",
|
|
@@ -1027,7 +364,7 @@ function createGenerationToolProvider(options) {
|
|
|
1027
364
|
});
|
|
1028
365
|
}
|
|
1029
366
|
const generateInput = planInput();
|
|
1030
|
-
|
|
367
|
+
list.push({
|
|
1031
368
|
name: "generate",
|
|
1032
369
|
title: "Generate media",
|
|
1033
370
|
description: "Plans the request and starts a generation. Pass a fresh `idempotencyKey` per intended generation and reuse it when retrying, so a retry never generates twice.",
|
|
@@ -1054,7 +391,7 @@ function createGenerationToolProvider(options) {
|
|
|
1054
391
|
handler: async (args, context) => {
|
|
1055
392
|
const key = String(args.idempotencyKey);
|
|
1056
393
|
const { idempotencyKey: _key, ...rest } = args;
|
|
1057
|
-
const signature = stableStringify(rest);
|
|
394
|
+
const signature = _chunkECCXGELCcjs.stableStringify.call(void 0, rest);
|
|
1058
395
|
const existing = calls.get(key);
|
|
1059
396
|
if (existing) {
|
|
1060
397
|
if (existing.signature !== signature) {
|
|
@@ -1082,12 +419,12 @@ function createGenerationToolProvider(options) {
|
|
|
1082
419
|
try {
|
|
1083
420
|
return await result;
|
|
1084
421
|
} catch (error) {
|
|
1085
|
-
if (_optionalChain([calls, 'access',
|
|
422
|
+
if (_optionalChain([calls, 'access', _38 => _38.get, 'call', _39 => _39(key), 'optionalAccess', _40 => _40.result]) === result) calls.delete(key);
|
|
1086
423
|
throw error;
|
|
1087
424
|
}
|
|
1088
425
|
}
|
|
1089
426
|
});
|
|
1090
|
-
return
|
|
427
|
+
return list;
|
|
1091
428
|
};
|
|
1092
429
|
return {
|
|
1093
430
|
id: _nullishCoalesce(options.id, () => ( "generation")),
|
|
@@ -1110,23 +447,23 @@ function toAssetResolver(lookup) {
|
|
|
1110
447
|
return (id) => byId.get(id);
|
|
1111
448
|
}
|
|
1112
449
|
function roleCap(caps, role) {
|
|
1113
|
-
const cap = _optionalChain([caps, 'access',
|
|
450
|
+
const cap = _optionalChain([caps, 'access', _41 => _41.references, 'optionalAccess', _42 => _42.roles, 'access', _43 => _43[role]]);
|
|
1114
451
|
if (cap && cap.max > 0) return cap;
|
|
1115
452
|
if (role === "mask" && caps.inpainting) return { max: 1 };
|
|
1116
453
|
return void 0;
|
|
1117
454
|
}
|
|
1118
455
|
function getAssetRoleOptions(caps) {
|
|
1119
|
-
const roles = supportedReferenceRoles(caps);
|
|
456
|
+
const roles = _chunkECCXGELCcjs.supportedReferenceRoles.call(void 0, caps);
|
|
1120
457
|
if (caps.inpainting && !roles.includes("mask")) roles.push("mask");
|
|
1121
458
|
return roles.map((role) => {
|
|
1122
459
|
const cap = _nullishCoalesce(roleCap(caps, role), () => ( { max: 1 }));
|
|
1123
460
|
return {
|
|
1124
461
|
role,
|
|
1125
|
-
label: referenceRoleLabel(role, caps),
|
|
462
|
+
label: _chunkECCXGELCcjs.referenceRoleLabel.call(void 0, role, caps),
|
|
1126
463
|
...cap.description ? { description: cap.description } : {},
|
|
1127
464
|
min: _nullishCoalesce(cap.min, () => ( 0)),
|
|
1128
465
|
max: cap.max,
|
|
1129
|
-
..._optionalChain([cap, 'access',
|
|
466
|
+
..._optionalChain([cap, 'access', _44 => _44.accepts, 'optionalAccess', _45 => _45.length]) ? { accepts: [...cap.accepts] } : {}
|
|
1130
467
|
};
|
|
1131
468
|
});
|
|
1132
469
|
}
|
|
@@ -1143,7 +480,7 @@ function validateAssetMentions(mentions, caps, options = {}) {
|
|
|
1143
480
|
}
|
|
1144
481
|
let role = mention.role;
|
|
1145
482
|
if (!roleCap(caps, role)) {
|
|
1146
|
-
const alias = normalizeReferenceRole(role, caps);
|
|
483
|
+
const alias = _chunkECCXGELCcjs.normalizeReferenceRole.call(void 0, role, caps);
|
|
1147
484
|
if (alias !== role && roleCap(caps, alias)) {
|
|
1148
485
|
issues.push({
|
|
1149
486
|
index,
|
|
@@ -1152,7 +489,7 @@ function validateAssetMentions(mentions, caps, options = {}) {
|
|
|
1152
489
|
code: "renamed-role",
|
|
1153
490
|
severity: "warning",
|
|
1154
491
|
suggestion: alias,
|
|
1155
|
-
message: `${label}: this model calls "${role}" ${referenceRoleLabel(alias, caps)} (${alias}).`
|
|
492
|
+
message: `${label}: this model calls "${role}" ${_chunkECCXGELCcjs.referenceRoleLabel.call(void 0, alias, caps)} (${alias}).`
|
|
1156
493
|
});
|
|
1157
494
|
role = alias;
|
|
1158
495
|
} else {
|
|
@@ -1162,21 +499,21 @@ function validateAssetMentions(mentions, caps, options = {}) {
|
|
|
1162
499
|
role,
|
|
1163
500
|
code: "unsupported-role",
|
|
1164
501
|
severity: "error",
|
|
1165
|
-
message: `${label}: ${_nullishCoalesce(caps.name, () => ( caps.id))} does not accept ${referenceRoleLabel(role, caps).toLowerCase()} assets.`
|
|
502
|
+
message: `${label}: ${_nullishCoalesce(caps.name, () => ( caps.id))} does not accept ${_chunkECCXGELCcjs.referenceRoleLabel.call(void 0, role, caps).toLowerCase()} assets.`
|
|
1166
503
|
});
|
|
1167
504
|
return;
|
|
1168
505
|
}
|
|
1169
506
|
}
|
|
1170
507
|
const cap = roleCap(caps, role);
|
|
1171
|
-
const mediaType = _nullishCoalesce(mention.mediaType, () => ( _optionalChain([resolve, 'optionalCall',
|
|
1172
|
-
if (mediaType !== void 0 && !mediaTypeMatches(mediaType, cap.accepts)) {
|
|
508
|
+
const mediaType = _nullishCoalesce(mention.mediaType, () => ( _optionalChain([resolve, 'optionalCall', _46 => _46(id), 'optionalAccess', _47 => _47.mediaType])));
|
|
509
|
+
if (mediaType !== void 0 && !_chunkECCXGELCcjs.mediaTypeMatches.call(void 0, mediaType, cap.accepts)) {
|
|
1173
510
|
issues.push({
|
|
1174
511
|
index,
|
|
1175
512
|
id,
|
|
1176
513
|
role,
|
|
1177
514
|
code: "media-mismatch",
|
|
1178
515
|
severity: "error",
|
|
1179
|
-
message: `${label} is ${mediaType}; ${referenceRoleLabel(role, caps)} accepts ${(_nullishCoalesce(cap.accepts, () => ( []))).join(", ")}.`
|
|
516
|
+
message: `${label} is ${mediaType}; ${_chunkECCXGELCcjs.referenceRoleLabel.call(void 0, role, caps)} accepts ${(_nullishCoalesce(cap.accepts, () => ( []))).join(", ")}.`
|
|
1180
517
|
});
|
|
1181
518
|
return;
|
|
1182
519
|
}
|
|
@@ -1188,7 +525,7 @@ function validateAssetMentions(mentions, caps, options = {}) {
|
|
|
1188
525
|
role,
|
|
1189
526
|
code: "too-many",
|
|
1190
527
|
severity: "warning",
|
|
1191
|
-
message: `${label}: at most ${cap.max} ${referenceRoleLabel(role, caps).toLowerCase()} asset(s); extra ones are left out.`
|
|
528
|
+
message: `${label}: at most ${cap.max} ${_chunkECCXGELCcjs.referenceRoleLabel.call(void 0, role, caps).toLowerCase()} asset(s); extra ones are left out.`
|
|
1192
529
|
});
|
|
1193
530
|
}
|
|
1194
531
|
});
|
|
@@ -1214,7 +551,7 @@ function resolveAssetMentions(mentions, assets) {
|
|
|
1214
551
|
return result;
|
|
1215
552
|
}
|
|
1216
553
|
function defaultAssetRoleOptions() {
|
|
1217
|
-
return REFERENCE_ROLES.map((role) => ({ role, label: referenceRoleLabel(role), min: 0, max: 1 }));
|
|
554
|
+
return _chunkECCXGELCcjs.REFERENCE_ROLES.map((role) => ({ role, label: _chunkECCXGELCcjs.referenceRoleLabel.call(void 0, role), min: 0, max: 1 }));
|
|
1218
555
|
}
|
|
1219
556
|
function describeAssetMentions(mentions, assets, caps) {
|
|
1220
557
|
const byId = new Map(assets.map((asset) => [asset.id, asset]));
|
|
@@ -1229,7 +566,7 @@ function describeAssetMentions(mentions, assets, caps) {
|
|
|
1229
566
|
...mention.start !== void 0 ? { start: mention.start } : {},
|
|
1230
567
|
handle: mention.handle,
|
|
1231
568
|
asset,
|
|
1232
|
-
...role ? { role, roleLabel: referenceRoleLabel(caps ? normalizeReferenceRole(role, caps) : role, caps) } : {},
|
|
569
|
+
...role ? { role, roleLabel: _chunkECCXGELCcjs.referenceRoleLabel.call(void 0, caps ? _chunkECCXGELCcjs.normalizeReferenceRole.call(void 0, role, caps) : role, caps) } : {},
|
|
1233
570
|
issues: []
|
|
1234
571
|
});
|
|
1235
572
|
}
|
|
@@ -1248,165 +585,33 @@ function describeAssetMentions(mentions, assets, caps) {
|
|
|
1248
585
|
return chips;
|
|
1249
586
|
}
|
|
1250
587
|
|
|
1251
|
-
// src/generation/provenance.ts
|
|
1252
|
-
var PROVENANCE_FORMAT = "pixerate.generation-provenance";
|
|
1253
|
-
var PROVENANCE_VERSION = 1;
|
|
1254
|
-
var ProvenanceParseError = class extends Error {
|
|
1255
|
-
constructor(message) {
|
|
1256
|
-
super(message);
|
|
1257
|
-
this.name = "ProvenanceParseError";
|
|
1258
|
-
}
|
|
1259
|
-
};
|
|
1260
|
-
var toIso = (value) => new Date(value).toISOString();
|
|
1261
|
-
var clone = (value) => value === void 0 ? value : JSON.parse(JSON.stringify(value));
|
|
1262
|
-
function pinTemplates(rawPrompt, templates, bindings, maxDepth) {
|
|
1263
|
-
const byName = new Map(templates.map((t) => [t.name, t]));
|
|
1264
|
-
const pinned = /* @__PURE__ */ new Map();
|
|
1265
|
-
const visit = (text, depth) => {
|
|
1266
|
-
if (depth > maxDepth) return;
|
|
1267
|
-
for (const token of _chunkFD4LPFAEcjs.tokenizePrompt.call(void 0, text)) {
|
|
1268
|
-
if (token.type !== "template" || pinned.has(token.value)) continue;
|
|
1269
|
-
const template = byName.get(token.value);
|
|
1270
|
-
if (!template) continue;
|
|
1271
|
-
const body = _chunkFD4LPFAEcjs.getTemplateBody.call(void 0, template, bindings);
|
|
1272
|
-
if (body === void 0) continue;
|
|
1273
|
-
const bound = bindings[template.name];
|
|
1274
|
-
const version = bound && template.versions ? template.versions.find((v) => v.id === bound || v.version === bound) : _chunkFD4LPFAEcjs.getLatestVersion.call(void 0, template);
|
|
1275
|
-
const isVersioned = !!_optionalChain([template, 'access', _76 => _76.versions, 'optionalAccess', _77 => _77.length]) && !!version;
|
|
1276
|
-
pinned.set(template.name, {
|
|
1277
|
-
name: template.name,
|
|
1278
|
-
...template.id !== void 0 ? { templateId: template.id } : {},
|
|
1279
|
-
...isVersioned ? { versionId: version.id, version: version.version } : {},
|
|
1280
|
-
body
|
|
1281
|
-
});
|
|
1282
|
-
visit(body, depth + 1);
|
|
1283
|
-
}
|
|
1284
|
-
};
|
|
1285
|
-
visit(rawPrompt, 0);
|
|
1286
|
-
return [...pinned.values()];
|
|
1287
|
-
}
|
|
1288
|
-
function pinnedTemplatesToTemplates(pinned) {
|
|
1289
|
-
return pinned.map(
|
|
1290
|
-
(p) => p.versionId !== void 0 ? {
|
|
1291
|
-
...p.templateId !== void 0 ? { id: p.templateId } : {},
|
|
1292
|
-
name: p.name,
|
|
1293
|
-
latestVersion: p.version,
|
|
1294
|
-
versions: [{ id: p.versionId, version: _nullishCoalesce(p.version, () => ( p.versionId)), body: p.body }]
|
|
1295
|
-
} : { ...p.templateId !== void 0 ? { id: p.templateId } : {}, name: p.name, body: p.body }
|
|
1296
|
-
);
|
|
1297
|
-
}
|
|
1298
|
-
function createProvenance(options) {
|
|
1299
|
-
const templates = _nullishCoalesce(options.templates, () => ( []));
|
|
1300
|
-
const maxDepth = _nullishCoalesce(options.maxDepth, () => ( 10));
|
|
1301
|
-
const resolved = _chunkFD4LPFAEcjs.resolvePrompt.call(void 0, options.rawPrompt, templates, {
|
|
1302
|
-
bindings: options.bindings,
|
|
1303
|
-
values: options.values,
|
|
1304
|
-
maxDepth
|
|
1305
|
-
});
|
|
1306
|
-
const pinned = pinTemplates(options.rawPrompt, templates, _nullishCoalesce(options.bindings, () => ( {})), maxDepth);
|
|
1307
|
-
const bindings = {};
|
|
1308
|
-
for (const p of pinned) if (p.versionId !== void 0) bindings[p.name] = p.versionId;
|
|
1309
|
-
const modelId = typeof options.model === "string" ? options.model : options.model.id;
|
|
1310
|
-
const request = clone(_nullishCoalesce(_nullishCoalesce(_optionalChain([options, 'access', _78 => _78.plan, 'optionalAccess', _79 => _79.request]), () => ( options.request)), () => ( {})));
|
|
1311
|
-
request.model = modelId;
|
|
1312
|
-
if (request.prompt === void 0) request.prompt = resolved.text;
|
|
1313
|
-
const adjustments = clone(_nullishCoalesce(_nullishCoalesce(options.adjustments, () => ( _optionalChain([options, 'access', _80 => _80.plan, 'optionalAccess', _81 => _81.adjustments]))), () => ( [])));
|
|
1314
|
-
return {
|
|
1315
|
-
format: PROVENANCE_FORMAT,
|
|
1316
|
-
version: PROVENANCE_VERSION,
|
|
1317
|
-
rawPrompt: options.rawPrompt,
|
|
1318
|
-
templates: pinned,
|
|
1319
|
-
bindings,
|
|
1320
|
-
values: options.values ? clone(options.values) : null,
|
|
1321
|
-
resolvedPrompt: resolved.text,
|
|
1322
|
-
sourceMap: resolved.map.map((segment) => {
|
|
1323
|
-
const { locked: _locked, ...rest } = segment;
|
|
1324
|
-
return rest;
|
|
1325
|
-
}),
|
|
1326
|
-
modelId,
|
|
1327
|
-
request,
|
|
1328
|
-
adjustments,
|
|
1329
|
-
references: (_nullishCoalesce(request.references, () => ( []))).map(({ id, role }) => ({ id, role })),
|
|
1330
|
-
createdAt: toIso(_nullishCoalesce(options.createdAt, () => ( Date.now()))),
|
|
1331
|
-
...options.startedAt !== void 0 ? { startedAt: toIso(options.startedAt) } : {},
|
|
1332
|
-
...options.completedAt !== void 0 ? { completedAt: toIso(options.completedAt) } : {},
|
|
1333
|
-
...options.outputIds ? { outputIds: [...options.outputIds] } : {},
|
|
1334
|
-
...options.meta ? { meta: clone(options.meta) } : {}
|
|
1335
|
-
};
|
|
1336
|
-
}
|
|
1337
|
-
function serializeProvenance(provenance) {
|
|
1338
|
-
return JSON.stringify(provenance);
|
|
1339
|
-
}
|
|
1340
|
-
var isRecord = (value) => !!value && typeof value === "object" && !Array.isArray(value);
|
|
1341
|
-
function parseProvenance(input) {
|
|
1342
|
-
let data = input;
|
|
1343
|
-
if (typeof input === "string") {
|
|
1344
|
-
try {
|
|
1345
|
-
data = JSON.parse(input);
|
|
1346
|
-
} catch (e2) {
|
|
1347
|
-
throw new ProvenanceParseError("Provenance is not valid JSON.");
|
|
1348
|
-
}
|
|
1349
|
-
}
|
|
1350
|
-
if (!isRecord(data) || data.format !== PROVENANCE_FORMAT) {
|
|
1351
|
-
throw new ProvenanceParseError("Not a generation provenance record.");
|
|
1352
|
-
}
|
|
1353
|
-
if (typeof data.version !== "number" || data.version > PROVENANCE_VERSION) {
|
|
1354
|
-
throw new ProvenanceParseError(`Unsupported provenance version ${JSON.stringify(data.version)}.`);
|
|
1355
|
-
}
|
|
1356
|
-
const checks = [
|
|
1357
|
-
["rawPrompt", typeof data.rawPrompt === "string"],
|
|
1358
|
-
["resolvedPrompt", typeof data.resolvedPrompt === "string"],
|
|
1359
|
-
["modelId", typeof data.modelId === "string"],
|
|
1360
|
-
["createdAt", typeof data.createdAt === "string"],
|
|
1361
|
-
["request", isRecord(data.request)],
|
|
1362
|
-
["templates", Array.isArray(data.templates) && data.templates.every((t) => isRecord(t) && typeof t.name === "string" && typeof t.body === "string")],
|
|
1363
|
-
["sourceMap", Array.isArray(data.sourceMap)],
|
|
1364
|
-
["adjustments", Array.isArray(data.adjustments)],
|
|
1365
|
-
["references", Array.isArray(data.references)]
|
|
1366
|
-
];
|
|
1367
|
-
const bad = checks.find(([, ok]) => !ok);
|
|
1368
|
-
if (bad) throw new ProvenanceParseError(`Invalid provenance field "${bad[0]}".`);
|
|
1369
|
-
return {
|
|
1370
|
-
...data,
|
|
1371
|
-
bindings: isRecord(data.bindings) ? data.bindings : {},
|
|
1372
|
-
values: isRecord(data.values) ? data.values : null
|
|
1373
|
-
};
|
|
1374
|
-
}
|
|
1375
|
-
function replayProvenancePrompt(provenance) {
|
|
1376
|
-
const result = _chunkFD4LPFAEcjs.resolvePrompt.call(void 0, provenance.rawPrompt, pinnedTemplatesToTemplates(provenance.templates), {
|
|
1377
|
-
bindings: provenance.bindings,
|
|
1378
|
-
...provenance.values ? { values: provenance.values } : {}
|
|
1379
|
-
});
|
|
1380
|
-
return { text: result.text, map: result.map, matches: result.text === provenance.resolvedPrompt };
|
|
1381
|
-
}
|
|
1382
|
-
|
|
1383
588
|
// src/generation/record.ts
|
|
1384
589
|
var GENERATION_RECORD_FORMAT = "pixerate.generation-record";
|
|
1385
590
|
var GENERATION_RECORD_VERSION = 1;
|
|
1386
591
|
var idCounter = 0;
|
|
1387
592
|
function createGenerationRecordId() {
|
|
1388
|
-
const uuid = _optionalChain([globalThis, 'access',
|
|
593
|
+
const uuid = _optionalChain([globalThis, 'access', _48 => _48.crypto, 'optionalAccess', _49 => _49.randomUUID, 'optionalCall', _50 => _50()]);
|
|
1389
594
|
if (typeof uuid === "string") return `gen_${uuid}`;
|
|
1390
595
|
idCounter = (idCounter + 1) % 1679616;
|
|
1391
596
|
const random = Math.floor(Math.random() * 2 ** 48).toString(36).padStart(10, "0");
|
|
1392
597
|
return `gen_${Date.now().toString(36)}${idCounter.toString(36).padStart(4, "0")}${random}`;
|
|
1393
598
|
}
|
|
1394
|
-
var
|
|
599
|
+
var clone = (value) => value === void 0 ? value : JSON.parse(JSON.stringify(value));
|
|
1395
600
|
function recordTemplates(pinned) {
|
|
1396
601
|
return pinned.map((p) => ({
|
|
1397
602
|
name: p.name,
|
|
1398
603
|
...p.templateId !== void 0 ? { templateId: p.templateId } : {},
|
|
1399
604
|
...p.versionId !== void 0 ? { versionId: p.versionId, version: p.version } : {},
|
|
1400
|
-
hash: hashText(p.body)
|
|
605
|
+
hash: _chunkECCXGELCcjs.hashText.call(void 0, p.body)
|
|
1401
606
|
}));
|
|
1402
607
|
}
|
|
1403
608
|
function recordAssets(references, lookup) {
|
|
1404
609
|
const resolve = toAssetResolver(lookup);
|
|
1405
610
|
return (_nullishCoalesce(references, () => ( []))).map((ref) => {
|
|
1406
|
-
const info = _optionalChain([resolve, 'optionalCall',
|
|
1407
|
-
const contentHash = _nullishCoalesce(ref.contentHash, () => ( _optionalChain([info, 'optionalAccess',
|
|
1408
|
-
const mediaType = _nullishCoalesce(ref.mediaType, () => ( _optionalChain([info, 'optionalAccess',
|
|
1409
|
-
const url = _nullishCoalesce(ref.url, () => ( _optionalChain([info, 'optionalAccess',
|
|
611
|
+
const info = _optionalChain([resolve, 'optionalCall', _51 => _51(ref.id)]);
|
|
612
|
+
const contentHash = _nullishCoalesce(ref.contentHash, () => ( _optionalChain([info, 'optionalAccess', _52 => _52.contentHash])));
|
|
613
|
+
const mediaType = _nullishCoalesce(ref.mediaType, () => ( _optionalChain([info, 'optionalAccess', _53 => _53.mediaType])));
|
|
614
|
+
const url = _nullishCoalesce(ref.url, () => ( _optionalChain([info, 'optionalAccess', _54 => _54.url])));
|
|
1410
615
|
return {
|
|
1411
616
|
id: ref.id,
|
|
1412
617
|
role: ref.role,
|
|
@@ -1431,7 +636,7 @@ function createGenerationRecord(options) {
|
|
|
1431
636
|
...provenanceOptions
|
|
1432
637
|
} = options;
|
|
1433
638
|
const caps = typeof model === "string" ? void 0 : model;
|
|
1434
|
-
const settings =
|
|
639
|
+
const settings = clone(_nullishCoalesce(_nullishCoalesce(settingsInput, () => ( _optionalChain([planInput, 'optionalAccess', _55 => _55.request]))), () => ( {})));
|
|
1435
640
|
let plan = planInput;
|
|
1436
641
|
if (!plan && caps) {
|
|
1437
642
|
const resolved = _chunkFD4LPFAEcjs.resolvePrompt.call(void 0, options.rawPrompt, _nullishCoalesce(options.templates, () => ( [])), {
|
|
@@ -1439,13 +644,13 @@ function createGenerationRecord(options) {
|
|
|
1439
644
|
values: options.values,
|
|
1440
645
|
maxDepth: options.maxDepth
|
|
1441
646
|
});
|
|
1442
|
-
plan = planGenerationRequest(settings, caps, {
|
|
647
|
+
plan = _chunkECCXGELCcjs.planGenerationRequest.call(void 0, settings, caps, {
|
|
1443
648
|
strategy: _nullishCoalesce(strategyInput, () => ( "nearest")),
|
|
1444
649
|
resolvedPrompt: resolved.text,
|
|
1445
650
|
...mentions ? { mentions } : {}
|
|
1446
651
|
});
|
|
1447
652
|
}
|
|
1448
|
-
const provenance = createProvenance({
|
|
653
|
+
const provenance = _chunkQ6OUXEK3cjs.createProvenance.call(void 0, {
|
|
1449
654
|
...provenanceOptions,
|
|
1450
655
|
model,
|
|
1451
656
|
...plan ? { plan } : { request: settings }
|
|
@@ -1459,22 +664,22 @@ function createGenerationRecord(options) {
|
|
|
1459
664
|
kind: _nullishCoalesce(kind, () => ( (parentId !== void 0 ? "recreate" : "generate"))),
|
|
1460
665
|
provenance,
|
|
1461
666
|
templates: recordTemplates(provenance.templates),
|
|
1462
|
-
promptHash: hashText(provenance.resolvedPrompt),
|
|
1463
|
-
...caps ? { capabilityHash: hashCapabilities(caps) } : {},
|
|
667
|
+
promptHash: _chunkECCXGELCcjs.hashText.call(void 0, provenance.resolvedPrompt),
|
|
668
|
+
...caps ? { capabilityHash: _chunkECCXGELCcjs.hashCapabilities.call(void 0, caps) } : {},
|
|
1464
669
|
settings,
|
|
1465
|
-
strategy: _nullishCoalesce(_nullishCoalesce(strategyInput, () => ( _optionalChain([plan, 'optionalAccess',
|
|
670
|
+
strategy: _nullishCoalesce(_nullishCoalesce(strategyInput, () => ( _optionalChain([plan, 'optionalAccess', _56 => _56.strategy]))), () => ( "nearest")),
|
|
1466
671
|
...seed !== void 0 ? { seed } : {},
|
|
1467
672
|
assets: recordAssets(provenance.request.references, assets),
|
|
1468
|
-
..._optionalChain([mentions, 'optionalAccess',
|
|
673
|
+
..._optionalChain([mentions, 'optionalAccess', _57 => _57.length]) ? { mentions: clone([...mentions]) } : {},
|
|
1469
674
|
createdAt: provenance.createdAt
|
|
1470
675
|
};
|
|
1471
676
|
}
|
|
1472
677
|
function completeGenerationRecord(record, update) {
|
|
1473
|
-
const next =
|
|
678
|
+
const next = clone(record);
|
|
1474
679
|
const now = new Date(_nullishCoalesce(update.completedAt, () => ( Date.now()))).toISOString();
|
|
1475
680
|
if (update.outputIds) next.provenance.outputIds = [...update.outputIds];
|
|
1476
681
|
next.provenance.completedAt = now;
|
|
1477
|
-
if (update.meta) next.provenance.meta = { ..._nullishCoalesce(next.provenance.meta, () => ( {})), ...
|
|
682
|
+
if (update.meta) next.provenance.meta = { ..._nullishCoalesce(next.provenance.meta, () => ( {})), ...clone(update.meta) };
|
|
1478
683
|
if (update.seed !== void 0) next.seed = update.seed;
|
|
1479
684
|
next.updatedAt = now;
|
|
1480
685
|
return next;
|
|
@@ -1488,15 +693,15 @@ function parseGenerationRecord(input) {
|
|
|
1488
693
|
if (typeof input === "string") {
|
|
1489
694
|
try {
|
|
1490
695
|
data = JSON.parse(input);
|
|
1491
|
-
} catch (
|
|
1492
|
-
throw new ProvenanceParseError("Generation record is not valid JSON.");
|
|
696
|
+
} catch (e2) {
|
|
697
|
+
throw new (0, _chunkQ6OUXEK3cjs.ProvenanceParseError)("Generation record is not valid JSON.");
|
|
1493
698
|
}
|
|
1494
699
|
}
|
|
1495
700
|
if (!isObject(data) || data.format !== GENERATION_RECORD_FORMAT) {
|
|
1496
|
-
throw new ProvenanceParseError("Not a generation record.");
|
|
701
|
+
throw new (0, _chunkQ6OUXEK3cjs.ProvenanceParseError)("Not a generation record.");
|
|
1497
702
|
}
|
|
1498
703
|
if (typeof data.version !== "number" || data.version > GENERATION_RECORD_VERSION) {
|
|
1499
|
-
throw new ProvenanceParseError(`Unsupported generation record version ${JSON.stringify(data.version)}.`);
|
|
704
|
+
throw new (0, _chunkQ6OUXEK3cjs.ProvenanceParseError)(`Unsupported generation record version ${JSON.stringify(data.version)}.`);
|
|
1500
705
|
}
|
|
1501
706
|
const checks = [
|
|
1502
707
|
["id", typeof data.id === "string" && data.id !== ""],
|
|
@@ -1507,8 +712,8 @@ function parseGenerationRecord(input) {
|
|
|
1507
712
|
["createdAt", typeof data.createdAt === "string"]
|
|
1508
713
|
];
|
|
1509
714
|
const bad = checks.find(([, ok]) => !ok);
|
|
1510
|
-
if (bad) throw new ProvenanceParseError(`Invalid generation record field "${bad[0]}".`);
|
|
1511
|
-
const provenance = parseProvenance(data.provenance);
|
|
715
|
+
if (bad) throw new (0, _chunkQ6OUXEK3cjs.ProvenanceParseError)(`Invalid generation record field "${bad[0]}".`);
|
|
716
|
+
const provenance = _chunkQ6OUXEK3cjs.parseProvenance.call(void 0, data.provenance);
|
|
1512
717
|
return {
|
|
1513
718
|
...data,
|
|
1514
719
|
kind: data.kind === "recreate" || data.kind === "variation" ? data.kind : "generate",
|
|
@@ -1522,10 +727,10 @@ function isGenerationRecord(value) {
|
|
|
1522
727
|
var SKIPPED_SETTING_FIELDS = /* @__PURE__ */ new Set(["model", "prompt", "references", "params", "seed"]);
|
|
1523
728
|
function findModel(capabilities, modelId) {
|
|
1524
729
|
if (!capabilities) return { given: false };
|
|
1525
|
-
const
|
|
1526
|
-
return { given: true, caps:
|
|
730
|
+
const list = Array.isArray(capabilities) ? capabilities : [capabilities];
|
|
731
|
+
return { given: true, caps: list.find((m) => m.id === modelId) };
|
|
1527
732
|
}
|
|
1528
|
-
var sameValue = (a, b) => stableStringify(a) === stableStringify(b);
|
|
733
|
+
var sameValue = (a, b) => _chunkECCXGELCcjs.stableStringify.call(void 0, a) === _chunkECCXGELCcjs.stableStringify.call(void 0, b);
|
|
1529
734
|
var show = (value) => value === void 0 ? "unset" : typeof value === "string" ? `"${value}"` : JSON.stringify(value);
|
|
1530
735
|
var refKey = (ref) => `${ref.role}:${ref.id}`;
|
|
1531
736
|
function templateDrift(record, current, mode) {
|
|
@@ -1547,10 +752,10 @@ function templateDrift(record, current, mode) {
|
|
|
1547
752
|
continue;
|
|
1548
753
|
}
|
|
1549
754
|
const body = _chunkFD4LPFAEcjs.getTemplateBody.call(void 0, template, {});
|
|
1550
|
-
const hash = body === void 0 ? void 0 : hashText(body);
|
|
755
|
+
const hash = body === void 0 ? void 0 : _chunkECCXGELCcjs.hashText.call(void 0, body);
|
|
1551
756
|
if (hash === recorded.hash) continue;
|
|
1552
757
|
const latest = _chunkFD4LPFAEcjs.getLatestVersion.call(void 0, template);
|
|
1553
|
-
const toVersion = _optionalChain([template, 'access',
|
|
758
|
+
const toVersion = _optionalChain([template, 'access', _58 => _58.versions, 'optionalAccess', _59 => _59.length]) ? _nullishCoalesce(_optionalChain([latest, 'optionalAccess', _60 => _60.version]), () => ( _optionalChain([latest, 'optionalAccess', _61 => _61.id]))) : void 0;
|
|
1554
759
|
const versions = fromVersion !== void 0 || toVersion !== void 0 ? ` (${_nullishCoalesce(fromVersion, () => ( "unversioned"))} \u2192 ${_nullishCoalesce(toVersion, () => ( "unversioned"))})` : "";
|
|
1555
760
|
drift.push({
|
|
1556
761
|
type: "template-changed",
|
|
@@ -1565,7 +770,7 @@ function templateDrift(record, current, mode) {
|
|
|
1565
770
|
return drift;
|
|
1566
771
|
}
|
|
1567
772
|
function randomSeed(caps, previous, random) {
|
|
1568
|
-
const cap = caps ? seedCapability(caps.seed) : {};
|
|
773
|
+
const cap = caps ? _chunkECCXGELCcjs.seedCapability.call(void 0, caps.seed) : {};
|
|
1569
774
|
if (!cap) return void 0;
|
|
1570
775
|
const min = Math.ceil(_nullishCoalesce(cap.min, () => ( 0)));
|
|
1571
776
|
const max = Math.floor(_nullishCoalesce(cap.max, () => ( 2 ** 31 - 1)));
|
|
@@ -1581,9 +786,9 @@ function rebuild(record, options, kind, overrides) {
|
|
|
1581
786
|
const mode = _nullishCoalesce(options.mode, () => ( "exact"));
|
|
1582
787
|
const provenance = record.provenance;
|
|
1583
788
|
const drift = templateDrift(record, options.templates, mode);
|
|
1584
|
-
const rawPrompt = _nullishCoalesce(_optionalChain([overrides, 'optionalAccess',
|
|
1585
|
-
const values = _optionalChain([overrides, 'optionalAccess',
|
|
1586
|
-
const pinned = pinnedTemplatesToTemplates(provenance.templates);
|
|
789
|
+
const rawPrompt = _nullishCoalesce(_optionalChain([overrides, 'optionalAccess', _62 => _62.rawPrompt]), () => ( provenance.rawPrompt));
|
|
790
|
+
const values = _optionalChain([overrides, 'optionalAccess', _63 => _63.values]) !== void 0 ? { ..._nullishCoalesce(provenance.values, () => ( {})), ...overrides.values } : provenance.values ? clone(provenance.values) : null;
|
|
791
|
+
const pinned = _chunkQ6OUXEK3cjs.pinnedTemplatesToTemplates.call(void 0, provenance.templates);
|
|
1587
792
|
let templates;
|
|
1588
793
|
let bindings;
|
|
1589
794
|
if (mode === "latest" && options.templates) {
|
|
@@ -1613,11 +818,11 @@ function rebuild(record, options, kind, overrides) {
|
|
|
1613
818
|
message: "The resolved prompt differs from the recorded one."
|
|
1614
819
|
});
|
|
1615
820
|
}
|
|
1616
|
-
const base =
|
|
821
|
+
const base = clone(mode === "exact" ? provenance.request : record.settings);
|
|
1617
822
|
const recordedPlanned = provenance.request;
|
|
1618
823
|
if (base.prompt === void 0 || base.prompt === provenance.resolvedPrompt) base.prompt = resolved.text;
|
|
1619
824
|
else if (base.prompt === provenance.rawPrompt) base.prompt = rawPrompt;
|
|
1620
|
-
if (mode === "latest" && _optionalChain([record, 'access',
|
|
825
|
+
if (mode === "latest" && _optionalChain([record, 'access', _64 => _64.mentions, 'optionalAccess', _65 => _65.length])) {
|
|
1621
826
|
const plannedRole = new Map((_nullishCoalesce(recordedPlanned.references, () => ( []))).map((ref) => [ref.id, ref.role]));
|
|
1622
827
|
base.references = [
|
|
1623
828
|
..._nullishCoalesce(base.references, () => ( [])),
|
|
@@ -1630,7 +835,7 @@ function rebuild(record, options, kind, overrides) {
|
|
|
1630
835
|
}))
|
|
1631
836
|
];
|
|
1632
837
|
} else if (mode === "latest" && base.references === void 0 && recordedPlanned.references) {
|
|
1633
|
-
base.references =
|
|
838
|
+
base.references = clone(recordedPlanned.references);
|
|
1634
839
|
}
|
|
1635
840
|
if (record.seed !== void 0) base.seed = record.seed;
|
|
1636
841
|
base.model = provenance.modelId;
|
|
@@ -1638,8 +843,8 @@ function rebuild(record, options, kind, overrides) {
|
|
|
1638
843
|
if (overrides) {
|
|
1639
844
|
if (overrides.settings) {
|
|
1640
845
|
const { params, ...rest } = overrides.settings;
|
|
1641
|
-
Object.assign(base,
|
|
1642
|
-
if (params) base.params = { ..._nullishCoalesce(base.params, () => ( {})), ...
|
|
846
|
+
Object.assign(base, clone(rest));
|
|
847
|
+
if (params) base.params = { ..._nullishCoalesce(base.params, () => ( {})), ...clone(params) };
|
|
1643
848
|
}
|
|
1644
849
|
if (overrides.seed === null) delete base.seed;
|
|
1645
850
|
else base.seed = _nullishCoalesce(overrides.seed, () => ( randomSeed(caps, record.seed, _nullishCoalesce(overrides.random, () => ( Math.random)))));
|
|
@@ -1661,7 +866,7 @@ function rebuild(record, options, kind, overrides) {
|
|
|
1661
866
|
});
|
|
1662
867
|
continue;
|
|
1663
868
|
}
|
|
1664
|
-
const recordedHash = _nullishCoalesce(_optionalChain([recordedById, 'access',
|
|
869
|
+
const recordedHash = _nullishCoalesce(_optionalChain([recordedById, 'access', _66 => _66.get, 'call', _67 => _67(refKey(ref)), 'optionalAccess', _68 => _68.contentHash]), () => ( ref.contentHash));
|
|
1665
870
|
if (recordedHash !== void 0 && info.contentHash !== void 0 && recordedHash !== info.contentHash) {
|
|
1666
871
|
drift.push({
|
|
1667
872
|
type: "asset-changed",
|
|
@@ -1692,7 +897,7 @@ function rebuild(record, options, kind, overrides) {
|
|
|
1692
897
|
message: `Model "${provenance.modelId}" is no longer available.`
|
|
1693
898
|
});
|
|
1694
899
|
} else if (caps) {
|
|
1695
|
-
const capabilityHash = hashCapabilities(caps);
|
|
900
|
+
const capabilityHash = _chunkECCXGELCcjs.hashCapabilities.call(void 0, caps);
|
|
1696
901
|
if (record.capabilityHash !== void 0 && record.capabilityHash !== capabilityHash) {
|
|
1697
902
|
drift.push({
|
|
1698
903
|
type: "model-changed",
|
|
@@ -1703,7 +908,7 @@ function rebuild(record, options, kind, overrides) {
|
|
|
1703
908
|
message: `The capabilities of "${_nullishCoalesce(caps.name, () => ( caps.id))}" changed since this generation.`
|
|
1704
909
|
});
|
|
1705
910
|
}
|
|
1706
|
-
plan = planGenerationRequest(base, caps, {
|
|
911
|
+
plan = _chunkECCXGELCcjs.planGenerationRequest.call(void 0, base, caps, {
|
|
1707
912
|
strategy: _nullishCoalesce(options.strategy, () => ( record.strategy)),
|
|
1708
913
|
resolvedPrompt: resolved.text
|
|
1709
914
|
});
|
|
@@ -1723,7 +928,7 @@ function rebuild(record, options, kind, overrides) {
|
|
|
1723
928
|
});
|
|
1724
929
|
};
|
|
1725
930
|
if (!overrides) {
|
|
1726
|
-
for (const field of GENERATION_REQUEST_FIELDS) {
|
|
931
|
+
for (const field of _chunkECCXGELCcjs.GENERATION_REQUEST_FIELDS) {
|
|
1727
932
|
if (SKIPPED_SETTING_FIELDS.has(field)) continue;
|
|
1728
933
|
const from = recordedPlanned[field];
|
|
1729
934
|
const to = request[field];
|
|
@@ -1731,8 +936,8 @@ function rebuild(record, options, kind, overrides) {
|
|
|
1731
936
|
}
|
|
1732
937
|
const paramNames = /* @__PURE__ */ new Set([...Object.keys(_nullishCoalesce(recordedPlanned.params, () => ( {}))), ...Object.keys(_nullishCoalesce(request.params, () => ( {})))]);
|
|
1733
938
|
for (const name of [...paramNames].sort()) {
|
|
1734
|
-
const from = _optionalChain([recordedPlanned, 'access',
|
|
1735
|
-
const to = _optionalChain([request, 'access',
|
|
939
|
+
const from = _optionalChain([recordedPlanned, 'access', _69 => _69.params, 'optionalAccess', _70 => _70[name]]);
|
|
940
|
+
const to = _optionalChain([request, 'access', _71 => _71.params, 'optionalAccess', _72 => _72[name]]);
|
|
1736
941
|
if (!sameValue(from, to)) describeChange(`params.${name}`, from, to);
|
|
1737
942
|
}
|
|
1738
943
|
if (!sameValue(_nullishCoalesce(record.seed, () => ( recordedPlanned.seed)), request.seed)) describeChange("seed", _nullishCoalesce(record.seed, () => ( recordedPlanned.seed)), request.seed);
|
|
@@ -1784,7 +989,7 @@ function rebuild(record, options, kind, overrides) {
|
|
|
1784
989
|
function recreateRequest(input, options) {
|
|
1785
990
|
if (isGenerationRecord(input)) return rebuild(input, _nullishCoalesce(options, () => ( {})), "recreate");
|
|
1786
991
|
const provenance = input;
|
|
1787
|
-
const request =
|
|
992
|
+
const request = clone(provenance.request);
|
|
1788
993
|
request.model = provenance.modelId;
|
|
1789
994
|
if (request.prompt === void 0) request.prompt = provenance.resolvedPrompt;
|
|
1790
995
|
return request;
|
|
@@ -1959,16 +1164,16 @@ function createBatchResolver(options) {
|
|
|
1959
1164
|
const run = (keys) => {
|
|
1960
1165
|
const pendings = keys.map((key) => inFlight.get(key));
|
|
1961
1166
|
const finish = (values, error) => {
|
|
1962
|
-
if (values === null) _optionalChain([options, 'access',
|
|
1167
|
+
if (values === null) _optionalChain([options, 'access', _73 => _73.onError, 'optionalCall', _74 => _74(error, keys)]);
|
|
1963
1168
|
keys.forEach((key, index) => {
|
|
1964
1169
|
const pending = pendings[index];
|
|
1965
|
-
const value = _optionalChain([values, 'optionalAccess',
|
|
1170
|
+
const value = _optionalChain([values, 'optionalAccess', _75 => _75.get, 'call', _76 => _76(key)]);
|
|
1966
1171
|
if (pending && inFlight.get(key) === pending) {
|
|
1967
1172
|
inFlight.delete(key);
|
|
1968
1173
|
settled.set(key, value);
|
|
1969
1174
|
if (values === null) failures.add(key);
|
|
1970
1175
|
}
|
|
1971
|
-
_optionalChain([pending, 'optionalAccess',
|
|
1176
|
+
_optionalChain([pending, 'optionalAccess', _77 => _77.resolve, 'call', _78 => _78(value)]);
|
|
1972
1177
|
});
|
|
1973
1178
|
};
|
|
1974
1179
|
let promise;
|
|
@@ -2066,10 +1271,10 @@ function estimateJobProgress(input) {
|
|
|
2066
1271
|
function expectedDurationFor(caps, request = {}) {
|
|
2067
1272
|
const timing = caps.timing;
|
|
2068
1273
|
if (!timing) return void 0;
|
|
2069
|
-
const count = _nullishCoalesce(_nullishCoalesce(request.count, () => ( _optionalChain([caps, 'access',
|
|
2070
|
-
const duration = _nullishCoalesce(_nullishCoalesce(request.duration, () => ( _optionalChain([caps, 'access',
|
|
2071
|
-
const resolution = _nullishCoalesce(request.resolution, () => ( _optionalChain([caps, 'access',
|
|
2072
|
-
const megapixels = resolution ? _nullishCoalesce(resolutionMegapixels(resolution), () => ( 0)) : 0;
|
|
1274
|
+
const count = _nullishCoalesce(_nullishCoalesce(request.count, () => ( _optionalChain([caps, 'access', _79 => _79.count, 'optionalAccess', _80 => _80.default]))), () => ( 1));
|
|
1275
|
+
const duration = _nullishCoalesce(_nullishCoalesce(request.duration, () => ( _optionalChain([caps, 'access', _81 => _81.duration, 'optionalAccess', _82 => _82.default]))), () => ( 0));
|
|
1276
|
+
const resolution = _nullishCoalesce(request.resolution, () => ( _optionalChain([caps, 'access', _83 => _83.resolutions, 'optionalAccess', _84 => _84.default])));
|
|
1277
|
+
const megapixels = resolution ? _nullishCoalesce(_chunkECCXGELCcjs.resolutionMegapixels.call(void 0, resolution), () => ( 0)) : 0;
|
|
2073
1278
|
return Math.round(
|
|
2074
1279
|
timing.baseMs + (_nullishCoalesce(timing.perItemMs, () => ( 0))) * Math.max(0, count - 1) + (_nullishCoalesce(timing.perSecondMs, () => ( 0))) * duration + (_nullishCoalesce(timing.perMegapixelMs, () => ( 0))) * megapixels
|
|
2075
1280
|
);
|
|
@@ -2077,19 +1282,19 @@ function expectedDurationFor(caps, request = {}) {
|
|
|
2077
1282
|
|
|
2078
1283
|
// src/generation/controls.ts
|
|
2079
1284
|
function enumControl(key, label, cap) {
|
|
2080
|
-
if (!_optionalChain([cap, 'optionalAccess',
|
|
1285
|
+
if (!_optionalChain([cap, 'optionalAccess', _85 => _85.options, 'access', _86 => _86.length])) return null;
|
|
2081
1286
|
return {
|
|
2082
1287
|
key,
|
|
2083
1288
|
label,
|
|
2084
1289
|
kind: "select",
|
|
2085
1290
|
valueType: "string",
|
|
2086
|
-
options: cap.options.map((value) => ({ value, label: _nullishCoalesce(_optionalChain([cap, 'access',
|
|
1291
|
+
options: cap.options.map((value) => ({ value, label: _nullishCoalesce(_optionalChain([cap, 'access', _87 => _87.labels, 'optionalAccess', _88 => _88[value]]), () => ( value)) })),
|
|
2087
1292
|
...cap.default !== void 0 ? { defaultValue: cap.default } : {}
|
|
2088
1293
|
};
|
|
2089
1294
|
}
|
|
2090
1295
|
function getGenerationControls(caps) {
|
|
2091
1296
|
const controls = [];
|
|
2092
|
-
const modes = supportedModes(caps);
|
|
1297
|
+
const modes = _chunkECCXGELCcjs.supportedModes.call(void 0, caps);
|
|
2093
1298
|
if (modes.length > 1) {
|
|
2094
1299
|
controls.push({
|
|
2095
1300
|
key: "mode",
|
|
@@ -2100,24 +1305,24 @@ function getGenerationControls(caps) {
|
|
|
2100
1305
|
defaultValue: "generate"
|
|
2101
1306
|
});
|
|
2102
1307
|
}
|
|
2103
|
-
const negative = textFieldCapability(caps.negativePrompt);
|
|
1308
|
+
const negative = _chunkECCXGELCcjs.textFieldCapability.call(void 0, caps.negativePrompt);
|
|
2104
1309
|
if (negative) controls.push({ key: "negativePrompt", label: "Negative prompt", kind: "textarea", valueType: "string", maxLength: negative.maxLength });
|
|
2105
|
-
const system = textFieldCapability(caps.systemPrompt);
|
|
1310
|
+
const system = _chunkECCXGELCcjs.textFieldCapability.call(void 0, caps.systemPrompt);
|
|
2106
1311
|
if (system) controls.push({ key: "systemPrompt", label: "System prompt", kind: "textarea", valueType: "string", maxLength: system.maxLength });
|
|
2107
1312
|
controls.push(enumControl("aspectRatio", "Aspect ratio", caps.aspectRatios));
|
|
2108
1313
|
controls.push(enumControl("resolution", "Resolution", caps.resolutions));
|
|
2109
1314
|
controls.push(enumControl("quality", "Quality", caps.quality));
|
|
2110
1315
|
if (caps.count) {
|
|
2111
|
-
const options = _optionalChain([caps, 'access',
|
|
1316
|
+
const options = _optionalChain([caps, 'access', _89 => _89.count, 'access', _90 => _90.options, 'optionalAccess', _91 => _91.filter, 'call', _92 => _92((o) => o >= 1 && o <= caps.count.max)]);
|
|
2112
1317
|
controls.push(
|
|
2113
|
-
_optionalChain([options, 'optionalAccess',
|
|
1318
|
+
_optionalChain([options, 'optionalAccess', _93 => _93.length]) ? { key: "count", label: "Outputs", kind: "select", valueType: "number", options: options.map((o) => ({ value: o, label: String(o) })), defaultValue: caps.count.default } : { key: "count", label: "Outputs", kind: "range", valueType: "number", min: 1, max: caps.count.max, step: 1, defaultValue: _nullishCoalesce(caps.count.default, () => ( 1)) }
|
|
2114
1319
|
);
|
|
2115
1320
|
}
|
|
2116
1321
|
if (caps.duration) {
|
|
2117
1322
|
const d = caps.duration;
|
|
2118
|
-
const options = _optionalChain([d, 'access',
|
|
1323
|
+
const options = _optionalChain([d, 'access', _94 => _94.options, 'optionalAccess', _95 => _95.filter, 'call', _96 => _96((o) => (d.min === void 0 || o >= d.min) && (d.max === void 0 || o <= d.max))]);
|
|
2119
1324
|
controls.push(
|
|
2120
|
-
_optionalChain([options, 'optionalAccess',
|
|
1325
|
+
_optionalChain([options, 'optionalAccess', _97 => _97.length]) ? { key: "duration", label: "Duration (s)", kind: "select", valueType: "number", options: options.map((o) => ({ value: o, label: `${o}s` })), defaultValue: d.default } : {
|
|
2121
1326
|
key: "duration",
|
|
2122
1327
|
label: "Duration (s)",
|
|
2123
1328
|
kind: d.min !== void 0 && d.max !== void 0 ? "range" : "number",
|
|
@@ -2129,7 +1334,7 @@ function getGenerationControls(caps) {
|
|
|
2129
1334
|
}
|
|
2130
1335
|
);
|
|
2131
1336
|
}
|
|
2132
|
-
const seed = seedCapability(caps.seed);
|
|
1337
|
+
const seed = _chunkECCXGELCcjs.seedCapability.call(void 0, caps.seed);
|
|
2133
1338
|
if (seed) controls.push({ key: "seed", label: "Seed", kind: "number", valueType: "number", min: seed.min, max: seed.max, step: 1 });
|
|
2134
1339
|
for (const [name, spec] of Object.entries(_nullishCoalesce(caps.params, () => ( {})))) {
|
|
2135
1340
|
const base = { key: `params.${name}`, label: _nullishCoalesce(spec.label, () => ( name)), ...spec.description ? { description: spec.description } : {} };
|
|
@@ -2159,7 +1364,7 @@ function getGenerationControls(caps) {
|
|
|
2159
1364
|
return controls.filter((c) => c !== null);
|
|
2160
1365
|
}
|
|
2161
1366
|
function getRequestValue(request, key) {
|
|
2162
|
-
if (key.startsWith("params.")) return _optionalChain([request, 'access',
|
|
1367
|
+
if (key.startsWith("params.")) return _optionalChain([request, 'access', _98 => _98.params, 'optionalAccess', _99 => _99[key.slice(7)]]);
|
|
2163
1368
|
return request[key];
|
|
2164
1369
|
}
|
|
2165
1370
|
function setRequestValue(request, key, value) {
|
|
@@ -2188,19 +1393,19 @@ function parseControlValue(control, raw) {
|
|
|
2188
1393
|
return String(raw);
|
|
2189
1394
|
}
|
|
2190
1395
|
function getReferenceSlots(caps, request = {}) {
|
|
2191
|
-
const roles = supportedReferenceRoles(caps);
|
|
1396
|
+
const roles = _chunkECCXGELCcjs.supportedReferenceRoles.call(void 0, caps);
|
|
2192
1397
|
if (caps.inpainting && !roles.includes("mask")) roles.push("mask");
|
|
2193
1398
|
const refs = _nullishCoalesce(request.references, () => ( []));
|
|
2194
1399
|
const total = refs.length;
|
|
2195
|
-
const maxTotal = _nullishCoalesce(_optionalChain([caps, 'access',
|
|
1400
|
+
const maxTotal = _nullishCoalesce(_optionalChain([caps, 'access', _100 => _100.references, 'optionalAccess', _101 => _101.maxTotal]), () => ( Infinity));
|
|
2196
1401
|
return roles.map((role) => {
|
|
2197
|
-
const cap = _nullishCoalesce(_optionalChain([caps, 'access',
|
|
1402
|
+
const cap = _nullishCoalesce(_optionalChain([caps, 'access', _102 => _102.references, 'optionalAccess', _103 => _103.roles, 'access', _104 => _104[role]]), () => ( { max: 1 }));
|
|
2198
1403
|
const references = refs.filter((ref) => ref.role === role);
|
|
2199
1404
|
return {
|
|
2200
1405
|
role,
|
|
2201
|
-
label: referenceRoleLabel(role, caps),
|
|
1406
|
+
label: _chunkECCXGELCcjs.referenceRoleLabel.call(void 0, role, caps),
|
|
2202
1407
|
...cap.description ? { description: cap.description } : {},
|
|
2203
|
-
..."accepts" in cap && _optionalChain([cap, 'access',
|
|
1408
|
+
..."accepts" in cap && _optionalChain([cap, 'access', _105 => _105.accepts, 'optionalAccess', _106 => _106.length]) ? { accepts: [...cap.accepts] } : {},
|
|
2204
1409
|
min: _nullishCoalesce(cap.min, () => ( 0)),
|
|
2205
1410
|
max: cap.max,
|
|
2206
1411
|
references,
|
|
@@ -2279,7 +1484,7 @@ function createGenerationRecordStore(options) {
|
|
|
2279
1484
|
if (data && Array.isArray(data.items)) {
|
|
2280
1485
|
items = data.items.filter((item) => item && typeof item.id === "string" && typeof item.createdAt === "string");
|
|
2281
1486
|
}
|
|
2282
|
-
} catch (
|
|
1487
|
+
} catch (e3) {
|
|
2283
1488
|
items = [];
|
|
2284
1489
|
}
|
|
2285
1490
|
}
|
|
@@ -2302,7 +1507,7 @@ function createGenerationRecordStore(options) {
|
|
|
2302
1507
|
let candidates = 0;
|
|
2303
1508
|
const cutoff = prune.olderThan !== void 0 ? time(prune.olderThan) : void 0;
|
|
2304
1509
|
for (const item of items) {
|
|
2305
|
-
if (_optionalChain([prune, 'access',
|
|
1510
|
+
if (_optionalChain([prune, 'access', _107 => _107.keep, 'optionalCall', _108 => _108(item)])) {
|
|
2306
1511
|
kept.push(item);
|
|
2307
1512
|
candidates++;
|
|
2308
1513
|
continue;
|
|
@@ -2335,7 +1540,7 @@ function createGenerationRecordStore(options) {
|
|
|
2335
1540
|
if (!raw) return null;
|
|
2336
1541
|
try {
|
|
2337
1542
|
return parseGenerationRecord(raw);
|
|
2338
|
-
} catch (
|
|
1543
|
+
} catch (e4) {
|
|
2339
1544
|
return null;
|
|
2340
1545
|
}
|
|
2341
1546
|
}),
|
|
@@ -2347,7 +1552,7 @@ function createGenerationRecordStore(options) {
|
|
|
2347
1552
|
if (!raw) continue;
|
|
2348
1553
|
try {
|
|
2349
1554
|
records.push(parseGenerationRecord(raw));
|
|
2350
|
-
} catch (
|
|
1555
|
+
} catch (e5) {
|
|
2351
1556
|
}
|
|
2352
1557
|
}
|
|
2353
1558
|
return records;
|
|
@@ -2454,5 +1659,5 @@ function createGenerationRecordStore(options) {
|
|
|
2454
1659
|
|
|
2455
1660
|
|
|
2456
1661
|
|
|
2457
|
-
exports.DRIFT_TYPE_LABELS = DRIFT_TYPE_LABELS; exports.GENERATION_RECORD_FORMAT = GENERATION_RECORD_FORMAT; exports.GENERATION_RECORD_VERSION = GENERATION_RECORD_VERSION; exports.GENERATION_REQUEST_FIELDS = GENERATION_REQUEST_FIELDS; exports.MAX_PENDING_PERCENT = MAX_PENDING_PERCENT; exports.PROVENANCE_FORMAT = PROVENANCE_FORMAT; exports.PROVENANCE_VERSION = PROVENANCE_VERSION; exports.ProvenanceParseError = ProvenanceParseError; exports.QUALITY_LADDER = QUALITY_LADDER; exports.REFERENCE_ROLES = REFERENCE_ROLES; exports.REFERENCE_ROLE_ALIASES = REFERENCE_ROLE_ALIASES; exports.REFERENCE_ROLE_LABELS = REFERENCE_ROLE_LABELS; exports.REFERENCE_ROLE_NAME_REGEX = REFERENCE_ROLE_NAME_REGEX; exports.addReference = addReference; exports.aspectRatioRank = aspectRatioRank; exports.blockingDrift = blockingDrift; exports.capabilitiesToJsonSchema = capabilitiesToJsonSchema; exports.completeGenerationRecord = completeGenerationRecord; exports.createBatchResolver = createBatchResolver; exports.createGenerationHistoryToolProvider = createGenerationHistoryToolProvider; exports.createGenerationRecord = createGenerationRecord; exports.createGenerationRecordId = createGenerationRecordId; exports.createGenerationRecordStore = createGenerationRecordStore; exports.createGenerationToolProvider = createGenerationToolProvider; exports.createProvenance = createProvenance; exports.defaultAssetRoleOptions = defaultAssetRoleOptions; exports.describeAssetMentions = describeAssetMentions; exports.estimateJobProgress = estimateJobProgress; exports.expectedDurationFor = expectedDurationFor; exports.findTextMentions = _chunkBVP3TSLHcjs.findTextMentions; exports.formatMentionText = _chunkBVP3TSLHcjs.formatMentionText; exports.formatRemaining = formatRemaining; exports.getAssetRoleOptions = getAssetRoleOptions; exports.getGenerationControls = getGenerationControls; exports.getReferenceSlots = getReferenceSlots; exports.getRequestValue = getRequestValue; exports.hashCapabilities = hashCapabilities; exports.hashText = hashText; exports.hashValue = hashValue; exports.isGenerationRecord = isGenerationRecord; exports.isReferenceRoleName = isReferenceRoleName; exports.matchesRecordFilter = matchesRecordFilter; exports.mediaTypeMatches = mediaTypeMatches; exports.mergeCapabilities = mergeCapabilities; exports.normalizeReferenceRole = normalizeReferenceRole; exports.parseControlValue = parseControlValue; exports.parseGenerationRecord = parseGenerationRecord; exports.parseProvenance = parseProvenance; exports.pinnedTemplatesToTemplates = pinnedTemplatesToTemplates; exports.planGenerationRequest = planGenerationRequest; exports.qualityRank = qualityRank; exports.recreateRequest = recreateRequest; exports.referenceRoleLabel = referenceRoleLabel; exports.removeReference = removeReference; exports.replayProvenancePrompt = replayProvenancePrompt; exports.resolutionMegapixels = resolutionMegapixels; exports.resolutionRank = resolutionRank; exports.resolveAssetMentions = resolveAssetMentions; exports.seedCapability = seedCapability; exports.serializeGenerationRecord = serializeGenerationRecord; exports.serializeProvenance = serializeProvenance; exports.setMentionRoleInText = _chunkBVP3TSLHcjs.setMentionRoleInText; exports.setRequestValue = setRequestValue; exports.snapToOption = snapToOption; exports.stableStringify = stableStringify; exports.summarizeGenerationRecord = summarizeGenerationRecord; exports.supportedModes = supportedModes; exports.supportedReferenceRoles = supportedReferenceRoles; exports.textFieldCapability = textFieldCapability; exports.toAssetResolver = toAssetResolver; exports.validateAssetMentions = validateAssetMentions; exports.validateJsonSchema = _chunkRIWPYSKUcjs.validateJsonSchema; exports.variationRequest = variationRequest;
|
|
1662
|
+
exports.DRIFT_TYPE_LABELS = DRIFT_TYPE_LABELS; exports.GENERATION_RECORD_FORMAT = GENERATION_RECORD_FORMAT; exports.GENERATION_RECORD_VERSION = GENERATION_RECORD_VERSION; exports.GENERATION_REQUEST_FIELDS = _chunkECCXGELCcjs.GENERATION_REQUEST_FIELDS; exports.MAX_PENDING_PERCENT = MAX_PENDING_PERCENT; exports.PROVENANCE_FORMAT = _chunkQ6OUXEK3cjs.PROVENANCE_FORMAT; exports.PROVENANCE_VERSION = _chunkQ6OUXEK3cjs.PROVENANCE_VERSION; exports.ProvenanceParseError = _chunkQ6OUXEK3cjs.ProvenanceParseError; exports.QUALITY_LADDER = _chunkECCXGELCcjs.QUALITY_LADDER; exports.REFERENCE_ROLES = _chunkECCXGELCcjs.REFERENCE_ROLES; exports.REFERENCE_ROLE_ALIASES = _chunkECCXGELCcjs.REFERENCE_ROLE_ALIASES; exports.REFERENCE_ROLE_LABELS = _chunkECCXGELCcjs.REFERENCE_ROLE_LABELS; exports.REFERENCE_ROLE_NAME_REGEX = _chunkECCXGELCcjs.REFERENCE_ROLE_NAME_REGEX; exports.addReference = addReference; exports.aspectRatioRank = _chunkECCXGELCcjs.aspectRatioRank; exports.blockingDrift = blockingDrift; exports.capabilitiesToJsonSchema = capabilitiesToJsonSchema; exports.completeGenerationRecord = completeGenerationRecord; exports.createBatchResolver = createBatchResolver; exports.createGenerationHistoryToolProvider = createGenerationHistoryToolProvider; exports.createGenerationRecord = createGenerationRecord; exports.createGenerationRecordId = createGenerationRecordId; exports.createGenerationRecordStore = createGenerationRecordStore; exports.createGenerationToolProvider = createGenerationToolProvider; exports.createProvenance = _chunkQ6OUXEK3cjs.createProvenance; exports.defaultAssetRoleOptions = defaultAssetRoleOptions; exports.describeAssetMentions = describeAssetMentions; exports.estimateJobProgress = estimateJobProgress; exports.expectedDurationFor = expectedDurationFor; exports.findTextMentions = _chunkBVP3TSLHcjs.findTextMentions; exports.formatMentionText = _chunkBVP3TSLHcjs.formatMentionText; exports.formatRemaining = formatRemaining; exports.getAssetRoleOptions = getAssetRoleOptions; exports.getGenerationControls = getGenerationControls; exports.getReferenceSlots = getReferenceSlots; exports.getRequestValue = getRequestValue; exports.hashCapabilities = _chunkECCXGELCcjs.hashCapabilities; exports.hashText = _chunkECCXGELCcjs.hashText; exports.hashValue = _chunkECCXGELCcjs.hashValue; exports.isGenerationRecord = isGenerationRecord; exports.isReferenceRoleName = _chunkECCXGELCcjs.isReferenceRoleName; exports.matchesRecordFilter = matchesRecordFilter; exports.mediaTypeMatches = _chunkECCXGELCcjs.mediaTypeMatches; exports.mergeCapabilities = _chunkECCXGELCcjs.mergeCapabilities; exports.normalizeReferenceRole = _chunkECCXGELCcjs.normalizeReferenceRole; exports.parseControlValue = parseControlValue; exports.parseGenerationRecord = parseGenerationRecord; exports.parseProvenance = _chunkQ6OUXEK3cjs.parseProvenance; exports.pinnedTemplatesToTemplates = _chunkQ6OUXEK3cjs.pinnedTemplatesToTemplates; exports.planGenerationRequest = _chunkECCXGELCcjs.planGenerationRequest; exports.qualityRank = _chunkECCXGELCcjs.qualityRank; exports.recreateRequest = recreateRequest; exports.referenceRoleLabel = _chunkECCXGELCcjs.referenceRoleLabel; exports.removeReference = removeReference; exports.replayProvenancePrompt = _chunkQ6OUXEK3cjs.replayProvenancePrompt; exports.resolutionMegapixels = _chunkECCXGELCcjs.resolutionMegapixels; exports.resolutionRank = _chunkECCXGELCcjs.resolutionRank; exports.resolveAssetMentions = resolveAssetMentions; exports.seedCapability = _chunkECCXGELCcjs.seedCapability; exports.serializeGenerationRecord = serializeGenerationRecord; exports.serializeProvenance = _chunkQ6OUXEK3cjs.serializeProvenance; exports.setMentionRoleInText = _chunkBVP3TSLHcjs.setMentionRoleInText; exports.setRequestValue = setRequestValue; exports.snapToOption = _chunkECCXGELCcjs.snapToOption; exports.stableStringify = _chunkECCXGELCcjs.stableStringify; exports.summarizeGenerationRecord = summarizeGenerationRecord; exports.supportedModes = _chunkECCXGELCcjs.supportedModes; exports.supportedReferenceRoles = _chunkECCXGELCcjs.supportedReferenceRoles; exports.textFieldCapability = _chunkECCXGELCcjs.textFieldCapability; exports.toAssetResolver = toAssetResolver; exports.validateAssetMentions = validateAssetMentions; exports.validateJsonSchema = _chunkRIWPYSKUcjs.validateJsonSchema; exports.variationRequest = variationRequest;
|
|
2458
1663
|
//# sourceMappingURL=index.cjs.map
|