@ai-sdk/luma 3.0.0-beta.19 → 3.0.0-beta.20
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/CHANGELOG.md +12 -0
- package/dist/index.js +71 -82
- package/dist/index.js.map +1 -1
- package/package.json +7 -7
- package/dist/index.d.mts +0 -76
- package/dist/index.mjs +0 -398
- package/dist/index.mjs.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @ai-sdk/luma
|
|
2
2
|
|
|
3
|
+
## 3.0.0-beta.20
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- ef992f8: Remove CommonJS exports from all packages. All packages are now ESM-only (`"type": "module"`). Consumers using `require()` must switch to ESM `import` syntax.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [ef992f8]
|
|
12
|
+
- @ai-sdk/provider@4.0.0-beta.11
|
|
13
|
+
- @ai-sdk/provider-utils@5.0.0-beta.19
|
|
14
|
+
|
|
3
15
|
## 3.0.0-beta.19
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/dist/index.js
CHANGED
|
@@ -1,39 +1,29 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// src/index.ts
|
|
21
|
-
var index_exports = {};
|
|
22
|
-
__export(index_exports, {
|
|
23
|
-
VERSION: () => VERSION,
|
|
24
|
-
createLuma: () => createLuma,
|
|
25
|
-
luma: () => luma
|
|
26
|
-
});
|
|
27
|
-
module.exports = __toCommonJS(index_exports);
|
|
28
|
-
|
|
29
1
|
// src/luma-provider.ts
|
|
30
|
-
|
|
31
|
-
|
|
2
|
+
import { NoSuchModelError } from "@ai-sdk/provider";
|
|
3
|
+
import {
|
|
4
|
+
loadApiKey,
|
|
5
|
+
withoutTrailingSlash,
|
|
6
|
+
withUserAgentSuffix
|
|
7
|
+
} from "@ai-sdk/provider-utils";
|
|
32
8
|
|
|
33
9
|
// src/luma-image-model.ts
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
10
|
+
import {
|
|
11
|
+
InvalidResponseDataError
|
|
12
|
+
} from "@ai-sdk/provider";
|
|
13
|
+
import {
|
|
14
|
+
combineHeaders,
|
|
15
|
+
createBinaryResponseHandler,
|
|
16
|
+
createJsonResponseHandler,
|
|
17
|
+
createJsonErrorResponseHandler,
|
|
18
|
+
createStatusCodeErrorResponseHandler,
|
|
19
|
+
delay,
|
|
20
|
+
getFromApi,
|
|
21
|
+
postJsonToApi,
|
|
22
|
+
lazySchema,
|
|
23
|
+
parseProviderOptions,
|
|
24
|
+
zodSchema
|
|
25
|
+
} from "@ai-sdk/provider-utils";
|
|
26
|
+
import { z } from "zod/v4";
|
|
37
27
|
var DEFAULT_POLL_INTERVAL_MILLIS = 500;
|
|
38
28
|
var DEFAULT_MAX_POLL_ATTEMPTS = 6e4 / DEFAULT_POLL_INTERVAL_MILLIS;
|
|
39
29
|
var LumaImageModel = class {
|
|
@@ -75,7 +65,7 @@ var LumaImageModel = class {
|
|
|
75
65
|
details: "This model does not support the `size` option. Use `aspectRatio` instead."
|
|
76
66
|
});
|
|
77
67
|
}
|
|
78
|
-
const lumaOptions = await
|
|
68
|
+
const lumaOptions = await parseProviderOptions({
|
|
79
69
|
provider: "luma",
|
|
80
70
|
providerOptions,
|
|
81
71
|
schema: lumaImageModelOptionsSchema
|
|
@@ -94,8 +84,8 @@ var LumaImageModel = class {
|
|
|
94
84
|
imageConfigs != null ? imageConfigs : []
|
|
95
85
|
);
|
|
96
86
|
const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
|
|
97
|
-
const fullHeaders =
|
|
98
|
-
const { value: generationResponse, responseHeaders } = await
|
|
87
|
+
const fullHeaders = combineHeaders(this.config.headers(), headers);
|
|
88
|
+
const { value: generationResponse, responseHeaders } = await postJsonToApi({
|
|
99
89
|
url: this.getLumaGenerationsUrl(),
|
|
100
90
|
headers: fullHeaders,
|
|
101
91
|
body: {
|
|
@@ -108,7 +98,7 @@ var LumaImageModel = class {
|
|
|
108
98
|
abortSignal,
|
|
109
99
|
fetch: this.config.fetch,
|
|
110
100
|
failedResponseHandler: this.createLumaErrorHandler(),
|
|
111
|
-
successfulResponseHandler:
|
|
101
|
+
successfulResponseHandler: createJsonResponseHandler(
|
|
112
102
|
lumaGenerationResponseSchema
|
|
113
103
|
)
|
|
114
104
|
});
|
|
@@ -138,39 +128,39 @@ var LumaImageModel = class {
|
|
|
138
128
|
const maxPollAttempts = (_a = pollSettings == null ? void 0 : pollSettings.maxPollAttempts) != null ? _a : this.maxPollAttempts;
|
|
139
129
|
const pollIntervalMillis = (_b = pollSettings == null ? void 0 : pollSettings.pollIntervalMillis) != null ? _b : this.pollIntervalMillis;
|
|
140
130
|
for (let i = 0; i < maxPollAttempts; i++) {
|
|
141
|
-
const { value: statusResponse } = await
|
|
131
|
+
const { value: statusResponse } = await getFromApi({
|
|
142
132
|
url,
|
|
143
133
|
headers,
|
|
144
134
|
abortSignal,
|
|
145
135
|
fetch: this.config.fetch,
|
|
146
136
|
failedResponseHandler: this.createLumaErrorHandler(),
|
|
147
|
-
successfulResponseHandler:
|
|
137
|
+
successfulResponseHandler: createJsonResponseHandler(
|
|
148
138
|
lumaGenerationResponseSchema
|
|
149
139
|
)
|
|
150
140
|
});
|
|
151
141
|
switch (statusResponse.state) {
|
|
152
142
|
case "completed":
|
|
153
143
|
if (!((_c = statusResponse.assets) == null ? void 0 : _c.image)) {
|
|
154
|
-
throw new
|
|
144
|
+
throw new InvalidResponseDataError({
|
|
155
145
|
data: statusResponse,
|
|
156
146
|
message: `Image generation completed but no image was found.`
|
|
157
147
|
});
|
|
158
148
|
}
|
|
159
149
|
return statusResponse.assets.image;
|
|
160
150
|
case "failed":
|
|
161
|
-
throw new
|
|
151
|
+
throw new InvalidResponseDataError({
|
|
162
152
|
data: statusResponse,
|
|
163
153
|
message: `Image generation failed.`
|
|
164
154
|
});
|
|
165
155
|
}
|
|
166
|
-
await
|
|
156
|
+
await delay(pollIntervalMillis);
|
|
167
157
|
}
|
|
168
158
|
throw new Error(
|
|
169
159
|
`Image generation timed out after ${this.maxPollAttempts} attempts.`
|
|
170
160
|
);
|
|
171
161
|
}
|
|
172
162
|
createLumaErrorHandler() {
|
|
173
|
-
return
|
|
163
|
+
return createJsonErrorResponseHandler({
|
|
174
164
|
errorSchema: lumaErrorSchema,
|
|
175
165
|
errorToMessage: (error) => {
|
|
176
166
|
var _a;
|
|
@@ -270,47 +260,47 @@ var LumaImageModel = class {
|
|
|
270
260
|
return `${this.config.baseURL}/dream-machine/v1/generations/${generationId != null ? generationId : "image"}`;
|
|
271
261
|
}
|
|
272
262
|
async downloadImage(url, abortSignal) {
|
|
273
|
-
const { value: response } = await
|
|
263
|
+
const { value: response } = await getFromApi({
|
|
274
264
|
url,
|
|
275
265
|
// No specific headers should be needed for this request as it's a
|
|
276
266
|
// generated image provided by Luma.
|
|
277
267
|
abortSignal,
|
|
278
|
-
failedResponseHandler:
|
|
279
|
-
successfulResponseHandler:
|
|
268
|
+
failedResponseHandler: createStatusCodeErrorResponseHandler(),
|
|
269
|
+
successfulResponseHandler: createBinaryResponseHandler(),
|
|
280
270
|
fetch: this.config.fetch
|
|
281
271
|
});
|
|
282
272
|
return response;
|
|
283
273
|
}
|
|
284
274
|
};
|
|
285
|
-
var lumaGenerationResponseSchema =
|
|
286
|
-
() =>
|
|
287
|
-
|
|
288
|
-
id:
|
|
289
|
-
state:
|
|
290
|
-
failure_reason:
|
|
291
|
-
assets:
|
|
292
|
-
image:
|
|
275
|
+
var lumaGenerationResponseSchema = lazySchema(
|
|
276
|
+
() => zodSchema(
|
|
277
|
+
z.object({
|
|
278
|
+
id: z.string(),
|
|
279
|
+
state: z.enum(["queued", "dreaming", "completed", "failed"]),
|
|
280
|
+
failure_reason: z.string().nullish(),
|
|
281
|
+
assets: z.object({
|
|
282
|
+
image: z.string()
|
|
293
283
|
// URL of the generated image
|
|
294
284
|
}).nullish()
|
|
295
285
|
})
|
|
296
286
|
)
|
|
297
287
|
);
|
|
298
|
-
var lumaErrorSchema =
|
|
299
|
-
detail:
|
|
300
|
-
|
|
301
|
-
type:
|
|
302
|
-
loc:
|
|
303
|
-
msg:
|
|
304
|
-
input:
|
|
305
|
-
ctx:
|
|
306
|
-
expected:
|
|
288
|
+
var lumaErrorSchema = z.object({
|
|
289
|
+
detail: z.array(
|
|
290
|
+
z.object({
|
|
291
|
+
type: z.string(),
|
|
292
|
+
loc: z.array(z.string()),
|
|
293
|
+
msg: z.string(),
|
|
294
|
+
input: z.string(),
|
|
295
|
+
ctx: z.object({
|
|
296
|
+
expected: z.string()
|
|
307
297
|
}).nullish()
|
|
308
298
|
})
|
|
309
299
|
)
|
|
310
300
|
});
|
|
311
|
-
var lumaImageModelOptionsSchema =
|
|
312
|
-
() =>
|
|
313
|
-
|
|
301
|
+
var lumaImageModelOptionsSchema = lazySchema(
|
|
302
|
+
() => zodSchema(
|
|
303
|
+
z.object({
|
|
314
304
|
/**
|
|
315
305
|
* The type of image reference to use when providing input images.
|
|
316
306
|
* - `image`: Guide generation using reference images (up to 4). Default.
|
|
@@ -318,20 +308,20 @@ var lumaImageModelOptionsSchema = (0, import_provider_utils.lazySchema)(
|
|
|
318
308
|
* - `character`: Create consistent characters from reference images (up to 4).
|
|
319
309
|
* - `modify_image`: Transform a single input image with prompt guidance.
|
|
320
310
|
*/
|
|
321
|
-
referenceType:
|
|
311
|
+
referenceType: z.enum(["image", "style", "character", "modify_image"]).nullish(),
|
|
322
312
|
/**
|
|
323
313
|
* Per-image configuration array. Each entry corresponds to an image in `prompt.images`.
|
|
324
314
|
* Allows setting individual weights for each reference image.
|
|
325
315
|
*/
|
|
326
|
-
images:
|
|
327
|
-
|
|
316
|
+
images: z.array(
|
|
317
|
+
z.object({
|
|
328
318
|
/**
|
|
329
319
|
* The weight of this image's influence on the generation.
|
|
330
320
|
* - For `image`: Higher weight = closer to reference (default: 0.85)
|
|
331
321
|
* - For `style`: Higher weight = stronger style influence (default: 0.8)
|
|
332
322
|
* - For `modify_image`: Higher weight = closer to input, lower = more creative (default: 1.0)
|
|
333
323
|
*/
|
|
334
|
-
weight:
|
|
324
|
+
weight: z.number().min(0).max(1).nullish(),
|
|
335
325
|
/**
|
|
336
326
|
* The identity name for character references.
|
|
337
327
|
* Used with `character` to specify which identity group the image belongs to.
|
|
@@ -339,32 +329,32 @@ var lumaImageModelOptionsSchema = (0, import_provider_utils.lazySchema)(
|
|
|
339
329
|
* images with multiple consistent characters.
|
|
340
330
|
* Default: 'identity0'
|
|
341
331
|
*/
|
|
342
|
-
id:
|
|
332
|
+
id: z.string().nullish()
|
|
343
333
|
})
|
|
344
334
|
).nullish(),
|
|
345
335
|
/**
|
|
346
336
|
* Override the polling interval in milliseconds (default 500).
|
|
347
337
|
*/
|
|
348
|
-
pollIntervalMillis:
|
|
338
|
+
pollIntervalMillis: z.number().nullish(),
|
|
349
339
|
/**
|
|
350
340
|
* Override the maximum number of polling attempts (default 120).
|
|
351
341
|
*/
|
|
352
|
-
maxPollAttempts:
|
|
342
|
+
maxPollAttempts: z.number().nullish()
|
|
353
343
|
}).passthrough()
|
|
354
344
|
)
|
|
355
345
|
);
|
|
356
346
|
|
|
357
347
|
// src/version.ts
|
|
358
|
-
var VERSION = true ? "3.0.0-beta.
|
|
348
|
+
var VERSION = true ? "3.0.0-beta.20" : "0.0.0-test";
|
|
359
349
|
|
|
360
350
|
// src/luma-provider.ts
|
|
361
351
|
var defaultBaseURL = "https://api.lumalabs.ai";
|
|
362
352
|
function createLuma(options = {}) {
|
|
363
353
|
var _a;
|
|
364
|
-
const baseURL =
|
|
365
|
-
const getHeaders = () =>
|
|
354
|
+
const baseURL = withoutTrailingSlash((_a = options.baseURL) != null ? _a : defaultBaseURL);
|
|
355
|
+
const getHeaders = () => withUserAgentSuffix(
|
|
366
356
|
{
|
|
367
|
-
Authorization: `Bearer ${
|
|
357
|
+
Authorization: `Bearer ${loadApiKey({
|
|
368
358
|
apiKey: options.apiKey,
|
|
369
359
|
environmentVariableName: "LUMA_API_KEY",
|
|
370
360
|
description: "Luma"
|
|
@@ -380,7 +370,7 @@ function createLuma(options = {}) {
|
|
|
380
370
|
fetch: options.fetch
|
|
381
371
|
});
|
|
382
372
|
const embeddingModel = (modelId) => {
|
|
383
|
-
throw new
|
|
373
|
+
throw new NoSuchModelError({
|
|
384
374
|
modelId,
|
|
385
375
|
modelType: "embeddingModel"
|
|
386
376
|
});
|
|
@@ -390,7 +380,7 @@ function createLuma(options = {}) {
|
|
|
390
380
|
image: createImageModel,
|
|
391
381
|
imageModel: createImageModel,
|
|
392
382
|
languageModel: (modelId) => {
|
|
393
|
-
throw new
|
|
383
|
+
throw new NoSuchModelError({
|
|
394
384
|
modelId,
|
|
395
385
|
modelType: "languageModel"
|
|
396
386
|
});
|
|
@@ -400,10 +390,9 @@ function createLuma(options = {}) {
|
|
|
400
390
|
};
|
|
401
391
|
}
|
|
402
392
|
var luma = createLuma();
|
|
403
|
-
|
|
404
|
-
0 && (module.exports = {
|
|
393
|
+
export {
|
|
405
394
|
VERSION,
|
|
406
395
|
createLuma,
|
|
407
396
|
luma
|
|
408
|
-
}
|
|
397
|
+
};
|
|
409
398
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/luma-provider.ts","../src/luma-image-model.ts","../src/version.ts"],"sourcesContent":["export { createLuma, luma } from './luma-provider';\nexport type { LumaProvider, LumaProviderSettings } from './luma-provider';\nexport type {\n LumaErrorData,\n LumaImageModelOptions,\n /** @deprecated Use `LumaImageModelOptions` instead. */\n LumaImageModelOptions as LumaImageProviderOptions,\n} from './luma-image-model';\nexport { VERSION } from './version';\n","import { ImageModelV4, NoSuchModelError, ProviderV4 } from '@ai-sdk/provider';\nimport {\n FetchFunction,\n loadApiKey,\n withoutTrailingSlash,\n withUserAgentSuffix,\n} from '@ai-sdk/provider-utils';\nimport { LumaImageModel } from './luma-image-model';\nimport { LumaImageModelId } from './luma-image-settings';\nimport { VERSION } from './version';\n\nexport interface LumaProviderSettings {\n /**\n * Luma API key. Default value is taken from the `LUMA_API_KEY` environment\n * variable.\n */\n apiKey?: string;\n /**\n * Base URL for the API calls.\n */\n baseURL?: string;\n /**\n * Custom headers to include in the requests.\n */\n headers?: Record<string, string>;\n /**\n * Custom fetch implementation. You can use it as a middleware to intercept requests,\n * or to provide a custom fetch implementation for e.g. testing.\n */\n fetch?: FetchFunction;\n}\n\nexport interface LumaProvider extends ProviderV4 {\n /**\n * Creates a model for image generation.\n */\n image(modelId: LumaImageModelId): ImageModelV4;\n\n /**\n * Creates a model for image generation.\n */\n imageModel(modelId: LumaImageModelId): ImageModelV4;\n\n /**\n * @deprecated Use `embeddingModel` instead.\n */\n textEmbeddingModel(modelId: string): never;\n}\n\nconst defaultBaseURL = 'https://api.lumalabs.ai';\n\nexport function createLuma(options: LumaProviderSettings = {}): LumaProvider {\n const baseURL = withoutTrailingSlash(options.baseURL ?? defaultBaseURL);\n const getHeaders = () =>\n withUserAgentSuffix(\n {\n Authorization: `Bearer ${loadApiKey({\n apiKey: options.apiKey,\n environmentVariableName: 'LUMA_API_KEY',\n description: 'Luma',\n })}`,\n ...options.headers,\n },\n `ai-sdk/luma/${VERSION}`,\n );\n\n const createImageModel = (modelId: LumaImageModelId) =>\n new LumaImageModel(modelId, {\n provider: 'luma.image',\n baseURL: baseURL ?? defaultBaseURL,\n headers: getHeaders,\n fetch: options.fetch,\n });\n\n const embeddingModel = (modelId: string) => {\n throw new NoSuchModelError({\n modelId,\n modelType: 'embeddingModel',\n });\n };\n\n return {\n specificationVersion: 'v4' as const,\n image: createImageModel,\n imageModel: createImageModel,\n languageModel: (modelId: string) => {\n throw new NoSuchModelError({\n modelId,\n modelType: 'languageModel',\n });\n },\n embeddingModel,\n textEmbeddingModel: embeddingModel,\n };\n}\n\nexport const luma = createLuma();\n","import {\n ImageModelV4,\n ImageModelV4File,\n SharedV4Warning,\n InvalidResponseDataError,\n} from '@ai-sdk/provider';\nimport {\n FetchFunction,\n combineHeaders,\n createBinaryResponseHandler,\n createJsonResponseHandler,\n createJsonErrorResponseHandler,\n createStatusCodeErrorResponseHandler,\n delay,\n getFromApi,\n postJsonToApi,\n InferSchema,\n lazySchema,\n parseProviderOptions,\n zodSchema,\n} from '@ai-sdk/provider-utils';\nimport { LumaReferenceType } from './luma-image-settings';\nimport { z } from 'zod/v4';\n\nconst DEFAULT_POLL_INTERVAL_MILLIS = 500;\nconst DEFAULT_MAX_POLL_ATTEMPTS = 60000 / DEFAULT_POLL_INTERVAL_MILLIS;\n\ninterface LumaImageModelConfig {\n provider: string;\n baseURL: string;\n headers: () => Record<string, string>;\n fetch?: FetchFunction;\n _internal?: {\n currentDate?: () => Date;\n };\n}\n\nexport class LumaImageModel implements ImageModelV4 {\n readonly specificationVersion = 'v4';\n readonly maxImagesPerCall = 1;\n readonly pollIntervalMillis = DEFAULT_POLL_INTERVAL_MILLIS;\n readonly maxPollAttempts = DEFAULT_MAX_POLL_ATTEMPTS;\n\n get provider(): string {\n return this.config.provider;\n }\n\n constructor(\n readonly modelId: string,\n private readonly config: LumaImageModelConfig,\n ) {}\n\n async doGenerate({\n prompt,\n size,\n aspectRatio,\n seed,\n providerOptions,\n headers,\n abortSignal,\n files,\n mask,\n }: Parameters<ImageModelV4['doGenerate']>[0]): Promise<\n Awaited<ReturnType<ImageModelV4['doGenerate']>>\n > {\n const warnings: Array<SharedV4Warning> = [];\n\n if (seed != null) {\n warnings.push({\n type: 'unsupported',\n feature: 'seed',\n details: 'This model does not support the `seed` option.',\n });\n }\n\n if (size != null) {\n warnings.push({\n type: 'unsupported',\n feature: 'size',\n details:\n 'This model does not support the `size` option. Use `aspectRatio` instead.',\n });\n }\n\n // Parse and validate provider options\n const lumaOptions = await parseProviderOptions({\n provider: 'luma',\n providerOptions,\n schema: lumaImageModelOptionsSchema,\n });\n\n // Extract non-request options\n const {\n pollIntervalMillis,\n maxPollAttempts,\n referenceType,\n images: imageConfigs,\n ...providerRequestOptions\n } = lumaOptions ?? {};\n\n // Handle image editing via files with reference type support\n const editingOptions = this.getEditingOptions(\n files,\n mask,\n referenceType ?? undefined,\n imageConfigs ?? [],\n );\n\n const currentDate = this.config._internal?.currentDate?.() ?? new Date();\n const fullHeaders = combineHeaders(this.config.headers(), headers);\n const { value: generationResponse, responseHeaders } = await postJsonToApi({\n url: this.getLumaGenerationsUrl(),\n headers: fullHeaders,\n body: {\n prompt,\n ...(aspectRatio ? { aspect_ratio: aspectRatio } : {}),\n model: this.modelId,\n ...editingOptions,\n ...providerRequestOptions,\n },\n abortSignal,\n fetch: this.config.fetch,\n failedResponseHandler: this.createLumaErrorHandler(),\n successfulResponseHandler: createJsonResponseHandler(\n lumaGenerationResponseSchema,\n ),\n });\n\n const imageUrl = await this.pollForImageUrl(\n generationResponse.id,\n fullHeaders,\n abortSignal,\n {\n pollIntervalMillis: pollIntervalMillis ?? undefined,\n maxPollAttempts: maxPollAttempts ?? undefined,\n },\n );\n\n const downloadedImage = await this.downloadImage(imageUrl, abortSignal);\n\n return {\n images: [downloadedImage],\n warnings,\n response: {\n modelId: this.modelId,\n timestamp: currentDate,\n headers: responseHeaders,\n },\n };\n }\n\n private async pollForImageUrl(\n generationId: string,\n headers: Record<string, string | undefined>,\n abortSignal: AbortSignal | undefined,\n pollSettings?: { pollIntervalMillis?: number; maxPollAttempts?: number },\n ): Promise<string> {\n const url = this.getLumaGenerationsUrl(generationId);\n const maxPollAttempts =\n pollSettings?.maxPollAttempts ?? this.maxPollAttempts;\n const pollIntervalMillis =\n pollSettings?.pollIntervalMillis ?? this.pollIntervalMillis;\n\n for (let i = 0; i < maxPollAttempts; i++) {\n const { value: statusResponse } = await getFromApi({\n url,\n headers,\n abortSignal,\n fetch: this.config.fetch,\n failedResponseHandler: this.createLumaErrorHandler(),\n successfulResponseHandler: createJsonResponseHandler(\n lumaGenerationResponseSchema,\n ),\n });\n\n switch (statusResponse.state) {\n case 'completed':\n if (!statusResponse.assets?.image) {\n throw new InvalidResponseDataError({\n data: statusResponse,\n message: `Image generation completed but no image was found.`,\n });\n }\n return statusResponse.assets.image;\n case 'failed':\n throw new InvalidResponseDataError({\n data: statusResponse,\n message: `Image generation failed.`,\n });\n }\n await delay(pollIntervalMillis);\n }\n\n throw new Error(\n `Image generation timed out after ${this.maxPollAttempts} attempts.`,\n );\n }\n\n private createLumaErrorHandler() {\n return createJsonErrorResponseHandler({\n errorSchema: lumaErrorSchema,\n errorToMessage: (error: LumaErrorData) =>\n error.detail[0].msg ?? 'Unknown error',\n });\n }\n\n private getEditingOptions(\n files: ImageModelV4File[] | undefined,\n mask: ImageModelV4File | undefined,\n referenceType: LumaReferenceType = 'image',\n imageConfigs: Array<{ weight?: number | null; id?: string | null }> = [],\n ): Record<string, unknown> {\n const options: Record<string, unknown> = {};\n\n // Luma does not support mask-based inpainting\n if (mask != null) {\n throw new Error(\n 'Luma AI does not support mask-based image editing. ' +\n 'Use the prompt to describe the changes you want to make, along with ' +\n '`prompt.images` containing the source image URL.',\n );\n }\n\n if (files == null || files.length === 0) {\n return options;\n }\n\n // Validate all files are URL-based\n for (const file of files) {\n if (file.type !== 'url') {\n throw new Error(\n 'Luma AI only supports URL-based images. ' +\n 'Please provide image URLs using `prompt.images` with publicly accessible URLs. ' +\n 'Base64 and Uint8Array data are not supported.',\n );\n }\n }\n\n // Default weights per reference type\n const defaultWeights: Record<LumaReferenceType, number> = {\n image: 0.85,\n style: 0.8,\n character: 1.0, // Not used, but defined for completeness\n modify_image: 1.0,\n };\n\n switch (referenceType) {\n case 'image': {\n // Supports up to 4 images\n if (files.length > 4) {\n throw new Error(\n 'Luma AI image supports up to 4 reference images. ' +\n `You provided ${files.length} images.`,\n );\n }\n options.image = files.map((file, index) => ({\n url: (file as { type: 'url'; url: string }).url,\n weight: imageConfigs[index]?.weight ?? defaultWeights.image,\n }));\n break;\n }\n\n case 'style': {\n // Style ref accepts an array but typically uses one style image\n options.style = files.map((file, index) => ({\n url: (file as { type: 'url'; url: string }).url,\n weight: imageConfigs[index]?.weight ?? defaultWeights.style,\n }));\n break;\n }\n\n case 'character': {\n // Group images by identity id\n const identities: Record<string, string[]> = {};\n for (let i = 0; i < files.length; i++) {\n const file = files[i] as { type: 'url'; url: string };\n const identityId = imageConfigs[i]?.id ?? 'identity0';\n if (!identities[identityId]) {\n identities[identityId] = [];\n }\n identities[identityId].push(file.url);\n }\n\n // Validate each identity has at most 4 images\n for (const [identityId, images] of Object.entries(identities)) {\n if (images.length > 4) {\n throw new Error(\n `Luma AI character supports up to 4 images per identity. ` +\n `Identity '${identityId}' has ${images.length} images.`,\n );\n }\n }\n\n options.character = Object.fromEntries(\n Object.entries(identities).map(([id, images]) => [id, { images }]),\n );\n break;\n }\n\n case 'modify_image': {\n // Only supports a single image\n if (files.length > 1) {\n throw new Error(\n 'Luma AI modify_image only supports a single input image. ' +\n `You provided ${files.length} images.`,\n );\n }\n options.modify_image = {\n url: (files[0] as { type: 'url'; url: string }).url,\n weight: imageConfigs[0]?.weight ?? defaultWeights.modify_image,\n };\n break;\n }\n }\n\n return options;\n }\n\n private getLumaGenerationsUrl(generationId?: string) {\n return `${this.config.baseURL}/dream-machine/v1/generations/${\n generationId ?? 'image'\n }`;\n }\n\n private async downloadImage(\n url: string,\n abortSignal: AbortSignal | undefined,\n ): Promise<Uint8Array> {\n const { value: response } = await getFromApi({\n url,\n // No specific headers should be needed for this request as it's a\n // generated image provided by Luma.\n abortSignal,\n failedResponseHandler: createStatusCodeErrorResponseHandler(),\n successfulResponseHandler: createBinaryResponseHandler(),\n fetch: this.config.fetch,\n });\n return response;\n }\n}\n\n// limited version of the schema, focussed on what is needed for the implementation\n// this approach limits breakages when the API changes and increases efficiency\nconst lumaGenerationResponseSchema = lazySchema(() =>\n zodSchema(\n z.object({\n id: z.string(),\n state: z.enum(['queued', 'dreaming', 'completed', 'failed']),\n failure_reason: z.string().nullish(),\n assets: z\n .object({\n image: z.string(), // URL of the generated image\n })\n .nullish(),\n }),\n ),\n);\n\nconst lumaErrorSchema = z.object({\n detail: z.array(\n z.object({\n type: z.string(),\n loc: z.array(z.string()),\n msg: z.string(),\n input: z.string(),\n ctx: z\n .object({\n expected: z.string(),\n })\n .nullish(),\n }),\n ),\n});\n\nexport type LumaErrorData = z.infer<typeof lumaErrorSchema>;\n\n/**\n * Provider options schema for Luma image generation.\n *\n * @see https://docs.lumalabs.ai/docs/image-generation\n */\nexport const lumaImageModelOptionsSchema = lazySchema(() =>\n zodSchema(\n z\n .object({\n /**\n * The type of image reference to use when providing input images.\n * - `image`: Guide generation using reference images (up to 4). Default.\n * - `style`: Apply a specific style from reference image(s).\n * - `character`: Create consistent characters from reference images (up to 4).\n * - `modify_image`: Transform a single input image with prompt guidance.\n */\n referenceType: z\n .enum(['image', 'style', 'character', 'modify_image'])\n .nullish(),\n\n /**\n * Per-image configuration array. Each entry corresponds to an image in `prompt.images`.\n * Allows setting individual weights for each reference image.\n */\n images: z\n .array(\n z.object({\n /**\n * The weight of this image's influence on the generation.\n * - For `image`: Higher weight = closer to reference (default: 0.85)\n * - For `style`: Higher weight = stronger style influence (default: 0.8)\n * - For `modify_image`: Higher weight = closer to input, lower = more creative (default: 1.0)\n */\n weight: z.number().min(0).max(1).nullish(),\n\n /**\n * The identity name for character references.\n * Used with `character` to specify which identity group the image belongs to.\n * Luma supports multiple identities (e.g., 'identity0', 'identity1') for generating\n * images with multiple consistent characters.\n * Default: 'identity0'\n */\n id: z.string().nullish(),\n }),\n )\n .nullish(),\n\n /**\n * Override the polling interval in milliseconds (default 500).\n */\n pollIntervalMillis: z.number().nullish(),\n\n /**\n * Override the maximum number of polling attempts (default 120).\n */\n maxPollAttempts: z.number().nullish(),\n })\n .passthrough(),\n ),\n);\n\nexport type LumaImageModelOptions = InferSchema<\n typeof lumaImageModelOptionsSchema\n>;\n","// Version string of this package injected at build time.\ndeclare const __PACKAGE_VERSION__: string | undefined;\nexport const VERSION: string =\n typeof __PACKAGE_VERSION__ !== 'undefined'\n ? __PACKAGE_VERSION__\n : '0.0.0-test';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAA,mBAA2D;AAC3D,IAAAC,yBAKO;;;ACNP,sBAKO;AACP,4BAcO;AAEP,gBAAkB;AAElB,IAAM,+BAA+B;AACrC,IAAM,4BAA4B,MAAQ;AAYnC,IAAM,iBAAN,MAA6C;AAAA,EAUlD,YACW,SACQ,QACjB;AAFS;AACQ;AAXnB,SAAS,uBAAuB;AAChC,SAAS,mBAAmB;AAC5B,SAAS,qBAAqB;AAC9B,SAAS,kBAAkB;AAAA,EASxB;AAAA,EAPH,IAAI,WAAmB;AACrB,WAAO,KAAK,OAAO;AAAA,EACrB;AAAA,EAOA,MAAM,WAAW;AAAA,IACf;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import_provider","import_provider_utils","_a","_b"]}
|
|
1
|
+
{"version":3,"sources":["../src/luma-provider.ts","../src/luma-image-model.ts","../src/version.ts"],"sourcesContent":["import { ImageModelV4, NoSuchModelError, ProviderV4 } from '@ai-sdk/provider';\nimport {\n FetchFunction,\n loadApiKey,\n withoutTrailingSlash,\n withUserAgentSuffix,\n} from '@ai-sdk/provider-utils';\nimport { LumaImageModel } from './luma-image-model';\nimport { LumaImageModelId } from './luma-image-settings';\nimport { VERSION } from './version';\n\nexport interface LumaProviderSettings {\n /**\n * Luma API key. Default value is taken from the `LUMA_API_KEY` environment\n * variable.\n */\n apiKey?: string;\n /**\n * Base URL for the API calls.\n */\n baseURL?: string;\n /**\n * Custom headers to include in the requests.\n */\n headers?: Record<string, string>;\n /**\n * Custom fetch implementation. You can use it as a middleware to intercept requests,\n * or to provide a custom fetch implementation for e.g. testing.\n */\n fetch?: FetchFunction;\n}\n\nexport interface LumaProvider extends ProviderV4 {\n /**\n * Creates a model for image generation.\n */\n image(modelId: LumaImageModelId): ImageModelV4;\n\n /**\n * Creates a model for image generation.\n */\n imageModel(modelId: LumaImageModelId): ImageModelV4;\n\n /**\n * @deprecated Use `embeddingModel` instead.\n */\n textEmbeddingModel(modelId: string): never;\n}\n\nconst defaultBaseURL = 'https://api.lumalabs.ai';\n\nexport function createLuma(options: LumaProviderSettings = {}): LumaProvider {\n const baseURL = withoutTrailingSlash(options.baseURL ?? defaultBaseURL);\n const getHeaders = () =>\n withUserAgentSuffix(\n {\n Authorization: `Bearer ${loadApiKey({\n apiKey: options.apiKey,\n environmentVariableName: 'LUMA_API_KEY',\n description: 'Luma',\n })}`,\n ...options.headers,\n },\n `ai-sdk/luma/${VERSION}`,\n );\n\n const createImageModel = (modelId: LumaImageModelId) =>\n new LumaImageModel(modelId, {\n provider: 'luma.image',\n baseURL: baseURL ?? defaultBaseURL,\n headers: getHeaders,\n fetch: options.fetch,\n });\n\n const embeddingModel = (modelId: string) => {\n throw new NoSuchModelError({\n modelId,\n modelType: 'embeddingModel',\n });\n };\n\n return {\n specificationVersion: 'v4' as const,\n image: createImageModel,\n imageModel: createImageModel,\n languageModel: (modelId: string) => {\n throw new NoSuchModelError({\n modelId,\n modelType: 'languageModel',\n });\n },\n embeddingModel,\n textEmbeddingModel: embeddingModel,\n };\n}\n\nexport const luma = createLuma();\n","import {\n ImageModelV4,\n ImageModelV4File,\n SharedV4Warning,\n InvalidResponseDataError,\n} from '@ai-sdk/provider';\nimport {\n FetchFunction,\n combineHeaders,\n createBinaryResponseHandler,\n createJsonResponseHandler,\n createJsonErrorResponseHandler,\n createStatusCodeErrorResponseHandler,\n delay,\n getFromApi,\n postJsonToApi,\n InferSchema,\n lazySchema,\n parseProviderOptions,\n zodSchema,\n} from '@ai-sdk/provider-utils';\nimport { LumaReferenceType } from './luma-image-settings';\nimport { z } from 'zod/v4';\n\nconst DEFAULT_POLL_INTERVAL_MILLIS = 500;\nconst DEFAULT_MAX_POLL_ATTEMPTS = 60000 / DEFAULT_POLL_INTERVAL_MILLIS;\n\ninterface LumaImageModelConfig {\n provider: string;\n baseURL: string;\n headers: () => Record<string, string>;\n fetch?: FetchFunction;\n _internal?: {\n currentDate?: () => Date;\n };\n}\n\nexport class LumaImageModel implements ImageModelV4 {\n readonly specificationVersion = 'v4';\n readonly maxImagesPerCall = 1;\n readonly pollIntervalMillis = DEFAULT_POLL_INTERVAL_MILLIS;\n readonly maxPollAttempts = DEFAULT_MAX_POLL_ATTEMPTS;\n\n get provider(): string {\n return this.config.provider;\n }\n\n constructor(\n readonly modelId: string,\n private readonly config: LumaImageModelConfig,\n ) {}\n\n async doGenerate({\n prompt,\n size,\n aspectRatio,\n seed,\n providerOptions,\n headers,\n abortSignal,\n files,\n mask,\n }: Parameters<ImageModelV4['doGenerate']>[0]): Promise<\n Awaited<ReturnType<ImageModelV4['doGenerate']>>\n > {\n const warnings: Array<SharedV4Warning> = [];\n\n if (seed != null) {\n warnings.push({\n type: 'unsupported',\n feature: 'seed',\n details: 'This model does not support the `seed` option.',\n });\n }\n\n if (size != null) {\n warnings.push({\n type: 'unsupported',\n feature: 'size',\n details:\n 'This model does not support the `size` option. Use `aspectRatio` instead.',\n });\n }\n\n // Parse and validate provider options\n const lumaOptions = await parseProviderOptions({\n provider: 'luma',\n providerOptions,\n schema: lumaImageModelOptionsSchema,\n });\n\n // Extract non-request options\n const {\n pollIntervalMillis,\n maxPollAttempts,\n referenceType,\n images: imageConfigs,\n ...providerRequestOptions\n } = lumaOptions ?? {};\n\n // Handle image editing via files with reference type support\n const editingOptions = this.getEditingOptions(\n files,\n mask,\n referenceType ?? undefined,\n imageConfigs ?? [],\n );\n\n const currentDate = this.config._internal?.currentDate?.() ?? new Date();\n const fullHeaders = combineHeaders(this.config.headers(), headers);\n const { value: generationResponse, responseHeaders } = await postJsonToApi({\n url: this.getLumaGenerationsUrl(),\n headers: fullHeaders,\n body: {\n prompt,\n ...(aspectRatio ? { aspect_ratio: aspectRatio } : {}),\n model: this.modelId,\n ...editingOptions,\n ...providerRequestOptions,\n },\n abortSignal,\n fetch: this.config.fetch,\n failedResponseHandler: this.createLumaErrorHandler(),\n successfulResponseHandler: createJsonResponseHandler(\n lumaGenerationResponseSchema,\n ),\n });\n\n const imageUrl = await this.pollForImageUrl(\n generationResponse.id,\n fullHeaders,\n abortSignal,\n {\n pollIntervalMillis: pollIntervalMillis ?? undefined,\n maxPollAttempts: maxPollAttempts ?? undefined,\n },\n );\n\n const downloadedImage = await this.downloadImage(imageUrl, abortSignal);\n\n return {\n images: [downloadedImage],\n warnings,\n response: {\n modelId: this.modelId,\n timestamp: currentDate,\n headers: responseHeaders,\n },\n };\n }\n\n private async pollForImageUrl(\n generationId: string,\n headers: Record<string, string | undefined>,\n abortSignal: AbortSignal | undefined,\n pollSettings?: { pollIntervalMillis?: number; maxPollAttempts?: number },\n ): Promise<string> {\n const url = this.getLumaGenerationsUrl(generationId);\n const maxPollAttempts =\n pollSettings?.maxPollAttempts ?? this.maxPollAttempts;\n const pollIntervalMillis =\n pollSettings?.pollIntervalMillis ?? this.pollIntervalMillis;\n\n for (let i = 0; i < maxPollAttempts; i++) {\n const { value: statusResponse } = await getFromApi({\n url,\n headers,\n abortSignal,\n fetch: this.config.fetch,\n failedResponseHandler: this.createLumaErrorHandler(),\n successfulResponseHandler: createJsonResponseHandler(\n lumaGenerationResponseSchema,\n ),\n });\n\n switch (statusResponse.state) {\n case 'completed':\n if (!statusResponse.assets?.image) {\n throw new InvalidResponseDataError({\n data: statusResponse,\n message: `Image generation completed but no image was found.`,\n });\n }\n return statusResponse.assets.image;\n case 'failed':\n throw new InvalidResponseDataError({\n data: statusResponse,\n message: `Image generation failed.`,\n });\n }\n await delay(pollIntervalMillis);\n }\n\n throw new Error(\n `Image generation timed out after ${this.maxPollAttempts} attempts.`,\n );\n }\n\n private createLumaErrorHandler() {\n return createJsonErrorResponseHandler({\n errorSchema: lumaErrorSchema,\n errorToMessage: (error: LumaErrorData) =>\n error.detail[0].msg ?? 'Unknown error',\n });\n }\n\n private getEditingOptions(\n files: ImageModelV4File[] | undefined,\n mask: ImageModelV4File | undefined,\n referenceType: LumaReferenceType = 'image',\n imageConfigs: Array<{ weight?: number | null; id?: string | null }> = [],\n ): Record<string, unknown> {\n const options: Record<string, unknown> = {};\n\n // Luma does not support mask-based inpainting\n if (mask != null) {\n throw new Error(\n 'Luma AI does not support mask-based image editing. ' +\n 'Use the prompt to describe the changes you want to make, along with ' +\n '`prompt.images` containing the source image URL.',\n );\n }\n\n if (files == null || files.length === 0) {\n return options;\n }\n\n // Validate all files are URL-based\n for (const file of files) {\n if (file.type !== 'url') {\n throw new Error(\n 'Luma AI only supports URL-based images. ' +\n 'Please provide image URLs using `prompt.images` with publicly accessible URLs. ' +\n 'Base64 and Uint8Array data are not supported.',\n );\n }\n }\n\n // Default weights per reference type\n const defaultWeights: Record<LumaReferenceType, number> = {\n image: 0.85,\n style: 0.8,\n character: 1.0, // Not used, but defined for completeness\n modify_image: 1.0,\n };\n\n switch (referenceType) {\n case 'image': {\n // Supports up to 4 images\n if (files.length > 4) {\n throw new Error(\n 'Luma AI image supports up to 4 reference images. ' +\n `You provided ${files.length} images.`,\n );\n }\n options.image = files.map((file, index) => ({\n url: (file as { type: 'url'; url: string }).url,\n weight: imageConfigs[index]?.weight ?? defaultWeights.image,\n }));\n break;\n }\n\n case 'style': {\n // Style ref accepts an array but typically uses one style image\n options.style = files.map((file, index) => ({\n url: (file as { type: 'url'; url: string }).url,\n weight: imageConfigs[index]?.weight ?? defaultWeights.style,\n }));\n break;\n }\n\n case 'character': {\n // Group images by identity id\n const identities: Record<string, string[]> = {};\n for (let i = 0; i < files.length; i++) {\n const file = files[i] as { type: 'url'; url: string };\n const identityId = imageConfigs[i]?.id ?? 'identity0';\n if (!identities[identityId]) {\n identities[identityId] = [];\n }\n identities[identityId].push(file.url);\n }\n\n // Validate each identity has at most 4 images\n for (const [identityId, images] of Object.entries(identities)) {\n if (images.length > 4) {\n throw new Error(\n `Luma AI character supports up to 4 images per identity. ` +\n `Identity '${identityId}' has ${images.length} images.`,\n );\n }\n }\n\n options.character = Object.fromEntries(\n Object.entries(identities).map(([id, images]) => [id, { images }]),\n );\n break;\n }\n\n case 'modify_image': {\n // Only supports a single image\n if (files.length > 1) {\n throw new Error(\n 'Luma AI modify_image only supports a single input image. ' +\n `You provided ${files.length} images.`,\n );\n }\n options.modify_image = {\n url: (files[0] as { type: 'url'; url: string }).url,\n weight: imageConfigs[0]?.weight ?? defaultWeights.modify_image,\n };\n break;\n }\n }\n\n return options;\n }\n\n private getLumaGenerationsUrl(generationId?: string) {\n return `${this.config.baseURL}/dream-machine/v1/generations/${\n generationId ?? 'image'\n }`;\n }\n\n private async downloadImage(\n url: string,\n abortSignal: AbortSignal | undefined,\n ): Promise<Uint8Array> {\n const { value: response } = await getFromApi({\n url,\n // No specific headers should be needed for this request as it's a\n // generated image provided by Luma.\n abortSignal,\n failedResponseHandler: createStatusCodeErrorResponseHandler(),\n successfulResponseHandler: createBinaryResponseHandler(),\n fetch: this.config.fetch,\n });\n return response;\n }\n}\n\n// limited version of the schema, focussed on what is needed for the implementation\n// this approach limits breakages when the API changes and increases efficiency\nconst lumaGenerationResponseSchema = lazySchema(() =>\n zodSchema(\n z.object({\n id: z.string(),\n state: z.enum(['queued', 'dreaming', 'completed', 'failed']),\n failure_reason: z.string().nullish(),\n assets: z\n .object({\n image: z.string(), // URL of the generated image\n })\n .nullish(),\n }),\n ),\n);\n\nconst lumaErrorSchema = z.object({\n detail: z.array(\n z.object({\n type: z.string(),\n loc: z.array(z.string()),\n msg: z.string(),\n input: z.string(),\n ctx: z\n .object({\n expected: z.string(),\n })\n .nullish(),\n }),\n ),\n});\n\nexport type LumaErrorData = z.infer<typeof lumaErrorSchema>;\n\n/**\n * Provider options schema for Luma image generation.\n *\n * @see https://docs.lumalabs.ai/docs/image-generation\n */\nexport const lumaImageModelOptionsSchema = lazySchema(() =>\n zodSchema(\n z\n .object({\n /**\n * The type of image reference to use when providing input images.\n * - `image`: Guide generation using reference images (up to 4). Default.\n * - `style`: Apply a specific style from reference image(s).\n * - `character`: Create consistent characters from reference images (up to 4).\n * - `modify_image`: Transform a single input image with prompt guidance.\n */\n referenceType: z\n .enum(['image', 'style', 'character', 'modify_image'])\n .nullish(),\n\n /**\n * Per-image configuration array. Each entry corresponds to an image in `prompt.images`.\n * Allows setting individual weights for each reference image.\n */\n images: z\n .array(\n z.object({\n /**\n * The weight of this image's influence on the generation.\n * - For `image`: Higher weight = closer to reference (default: 0.85)\n * - For `style`: Higher weight = stronger style influence (default: 0.8)\n * - For `modify_image`: Higher weight = closer to input, lower = more creative (default: 1.0)\n */\n weight: z.number().min(0).max(1).nullish(),\n\n /**\n * The identity name for character references.\n * Used with `character` to specify which identity group the image belongs to.\n * Luma supports multiple identities (e.g., 'identity0', 'identity1') for generating\n * images with multiple consistent characters.\n * Default: 'identity0'\n */\n id: z.string().nullish(),\n }),\n )\n .nullish(),\n\n /**\n * Override the polling interval in milliseconds (default 500).\n */\n pollIntervalMillis: z.number().nullish(),\n\n /**\n * Override the maximum number of polling attempts (default 120).\n */\n maxPollAttempts: z.number().nullish(),\n })\n .passthrough(),\n ),\n);\n\nexport type LumaImageModelOptions = InferSchema<\n typeof lumaImageModelOptionsSchema\n>;\n","// Version string of this package injected at build time.\ndeclare const __PACKAGE_VERSION__: string | undefined;\nexport const VERSION: string =\n typeof __PACKAGE_VERSION__ !== 'undefined'\n ? __PACKAGE_VERSION__\n : '0.0.0-test';\n"],"mappings":";AAAA,SAAuB,wBAAoC;AAC3D;AAAA,EAEE;AAAA,EACA;AAAA,EACA;AAAA,OACK;;;ACNP;AAAA,EAIE;AAAA,OACK;AACP;AAAA,EAEE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAAS,SAAS;AAElB,IAAM,+BAA+B;AACrC,IAAM,4BAA4B,MAAQ;AAYnC,IAAM,iBAAN,MAA6C;AAAA,EAUlD,YACW,SACQ,QACjB;AAFS;AACQ;AAXnB,SAAS,uBAAuB;AAChC,SAAS,mBAAmB;AAC5B,SAAS,qBAAqB;AAC9B,SAAS,kBAAkB;AAAA,EASxB;AAAA,EAPH,IAAI,WAAmB;AACrB,WAAO,KAAK,OAAO;AAAA,EACrB;AAAA,EAOA,MAAM,WAAW;AAAA,IACf;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,GAEE;AAhEJ;AAiEI,UAAM,WAAmC,CAAC;AAE1C,QAAI,QAAQ,MAAM;AAChB,eAAS,KAAK;AAAA,QACZ,MAAM;AAAA,QACN,SAAS;AAAA,QACT,SAAS;AAAA,MACX,CAAC;AAAA,IACH;AAEA,QAAI,QAAQ,MAAM;AAChB,eAAS,KAAK;AAAA,QACZ,MAAM;AAAA,QACN,SAAS;AAAA,QACT,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4CN,IAAM,iBAAiB;AAEhB,SAAS,WAAW,UAAgC,CAAC,GAAiB;AAnD7E;AAoDE,QAAM,UAAU,sBAAqB,aAAQ,YAAR,YAAmB,cAAc;AACtE,QAAM,aAAa,MACjB;AAAA,IACE;AAAA,MACE,eAAe,UAAU,WAAW;AAAA,QAClC,QAAQ,QAAQ;AAAA,QAChB,yBAAyB;AAAA,QACzB,aAAa;AAAA,MACf,CAAC,CAAC;AAAA,MACF,GAAG,QAAQ;AAAA,IACb;AAAA,IACA,eAAe,OAAO;AAAA,EACxB;AAEF,QAAM,mBAAmB,CAAC,YACxB,IAAI,eAAe,SAAS;AAAA,IAC1B,UAAU;AAAA,IACV,SAAS,4BAAW;AAAA,IACpB,SAAS;AAAA,IACT,OAAO,QAAQ;AAAA,EACjB,CAAC;AAEH,QAAM,iBAAiB,CAAC,YAAoB;AAC1C,UAAM,IAAI,iBAAiB;AAAA,MACzB;AAAA,MACA,WAAW;AAAA,IACb,CAAC;AAAA,EACH;AAEA,SAAO;AAAA,IACL,sBAAsB;AAAA,IACtB,OAAO;AAAA,IACP,YAAY;AAAA,IACZ,eAAe,CAAC,YAAoB;AAClC,YAAM,IAAI,iBAAiB;AAAA,QACzB;AAAA,QACA,WAAW;AAAA,MACb,CAAC;AAAA,IACH;AAAA,IACA;AAAA,IACA,oBAAoB;AAAA,EACtB;AACF;AAEO,IAAM,OAAO,WAAW;","names":["_a","_b"]}
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-sdk/luma",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.20",
|
|
4
|
+
"type": "module",
|
|
4
5
|
"license": "Apache-2.0",
|
|
5
6
|
"sideEffects": false,
|
|
6
7
|
"main": "./dist/index.js",
|
|
7
|
-
"module": "./dist/index.mjs",
|
|
8
8
|
"types": "./dist/index.d.ts",
|
|
9
9
|
"files": [
|
|
10
10
|
"dist/**/*",
|
|
@@ -24,20 +24,20 @@
|
|
|
24
24
|
"./package.json": "./package.json",
|
|
25
25
|
".": {
|
|
26
26
|
"types": "./dist/index.d.ts",
|
|
27
|
-
"import": "./dist/index.
|
|
28
|
-
"
|
|
27
|
+
"import": "./dist/index.js",
|
|
28
|
+
"default": "./dist/index.js"
|
|
29
29
|
}
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@ai-sdk/provider": "4.0.0-beta.
|
|
33
|
-
"@ai-sdk/provider-utils": "5.0.0-beta.
|
|
32
|
+
"@ai-sdk/provider": "4.0.0-beta.11",
|
|
33
|
+
"@ai-sdk/provider-utils": "5.0.0-beta.19"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@types/node": "20.17.24",
|
|
37
37
|
"tsup": "^8",
|
|
38
38
|
"typescript": "5.8.3",
|
|
39
39
|
"zod": "3.25.76",
|
|
40
|
-
"@ai-sdk/test-server": "2.0.0-beta.
|
|
40
|
+
"@ai-sdk/test-server": "2.0.0-beta.1",
|
|
41
41
|
"@vercel/ai-tsconfig": "0.0.0"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
package/dist/index.d.mts
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import { ProviderV4, ImageModelV4 } from '@ai-sdk/provider';
|
|
2
|
-
import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
|
|
3
|
-
import { FetchFunction, InferSchema } from '@ai-sdk/provider-utils';
|
|
4
|
-
import { z } from 'zod/v4';
|
|
5
|
-
|
|
6
|
-
type LumaImageModelId = 'photon-1' | 'photon-flash-1' | (string & {});
|
|
7
|
-
|
|
8
|
-
interface LumaProviderSettings {
|
|
9
|
-
/**
|
|
10
|
-
* Luma API key. Default value is taken from the `LUMA_API_KEY` environment
|
|
11
|
-
* variable.
|
|
12
|
-
*/
|
|
13
|
-
apiKey?: string;
|
|
14
|
-
/**
|
|
15
|
-
* Base URL for the API calls.
|
|
16
|
-
*/
|
|
17
|
-
baseURL?: string;
|
|
18
|
-
/**
|
|
19
|
-
* Custom headers to include in the requests.
|
|
20
|
-
*/
|
|
21
|
-
headers?: Record<string, string>;
|
|
22
|
-
/**
|
|
23
|
-
* Custom fetch implementation. You can use it as a middleware to intercept requests,
|
|
24
|
-
* or to provide a custom fetch implementation for e.g. testing.
|
|
25
|
-
*/
|
|
26
|
-
fetch?: FetchFunction;
|
|
27
|
-
}
|
|
28
|
-
interface LumaProvider extends ProviderV4 {
|
|
29
|
-
/**
|
|
30
|
-
* Creates a model for image generation.
|
|
31
|
-
*/
|
|
32
|
-
image(modelId: LumaImageModelId): ImageModelV4;
|
|
33
|
-
/**
|
|
34
|
-
* Creates a model for image generation.
|
|
35
|
-
*/
|
|
36
|
-
imageModel(modelId: LumaImageModelId): ImageModelV4;
|
|
37
|
-
/**
|
|
38
|
-
* @deprecated Use `embeddingModel` instead.
|
|
39
|
-
*/
|
|
40
|
-
textEmbeddingModel(modelId: string): never;
|
|
41
|
-
}
|
|
42
|
-
declare function createLuma(options?: LumaProviderSettings): LumaProvider;
|
|
43
|
-
declare const luma: LumaProvider;
|
|
44
|
-
|
|
45
|
-
declare const lumaErrorSchema: z.ZodObject<{
|
|
46
|
-
detail: z.ZodArray<z.ZodObject<{
|
|
47
|
-
type: z.ZodString;
|
|
48
|
-
loc: z.ZodArray<z.ZodString>;
|
|
49
|
-
msg: z.ZodString;
|
|
50
|
-
input: z.ZodString;
|
|
51
|
-
ctx: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
52
|
-
expected: z.ZodString;
|
|
53
|
-
}, z.core.$strip>>>;
|
|
54
|
-
}, z.core.$strip>>;
|
|
55
|
-
}, z.core.$strip>;
|
|
56
|
-
type LumaErrorData = z.infer<typeof lumaErrorSchema>;
|
|
57
|
-
/**
|
|
58
|
-
* Provider options schema for Luma image generation.
|
|
59
|
-
*
|
|
60
|
-
* @see https://docs.lumalabs.ai/docs/image-generation
|
|
61
|
-
*/
|
|
62
|
-
declare const lumaImageModelOptionsSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
63
|
-
[x: string]: unknown;
|
|
64
|
-
referenceType?: "image" | "style" | "character" | "modify_image" | null | undefined;
|
|
65
|
-
images?: {
|
|
66
|
-
weight?: number | null | undefined;
|
|
67
|
-
id?: string | null | undefined;
|
|
68
|
-
}[] | null | undefined;
|
|
69
|
-
pollIntervalMillis?: number | null | undefined;
|
|
70
|
-
maxPollAttempts?: number | null | undefined;
|
|
71
|
-
}>;
|
|
72
|
-
type LumaImageModelOptions = InferSchema<typeof lumaImageModelOptionsSchema>;
|
|
73
|
-
|
|
74
|
-
declare const VERSION: string;
|
|
75
|
-
|
|
76
|
-
export { type LumaErrorData, type LumaImageModelOptions, type LumaImageModelOptions as LumaImageProviderOptions, type LumaProvider, type LumaProviderSettings, VERSION, createLuma, luma };
|
package/dist/index.mjs
DELETED
|
@@ -1,398 +0,0 @@
|
|
|
1
|
-
// src/luma-provider.ts
|
|
2
|
-
import { NoSuchModelError } from "@ai-sdk/provider";
|
|
3
|
-
import {
|
|
4
|
-
loadApiKey,
|
|
5
|
-
withoutTrailingSlash,
|
|
6
|
-
withUserAgentSuffix
|
|
7
|
-
} from "@ai-sdk/provider-utils";
|
|
8
|
-
|
|
9
|
-
// src/luma-image-model.ts
|
|
10
|
-
import {
|
|
11
|
-
InvalidResponseDataError
|
|
12
|
-
} from "@ai-sdk/provider";
|
|
13
|
-
import {
|
|
14
|
-
combineHeaders,
|
|
15
|
-
createBinaryResponseHandler,
|
|
16
|
-
createJsonResponseHandler,
|
|
17
|
-
createJsonErrorResponseHandler,
|
|
18
|
-
createStatusCodeErrorResponseHandler,
|
|
19
|
-
delay,
|
|
20
|
-
getFromApi,
|
|
21
|
-
postJsonToApi,
|
|
22
|
-
lazySchema,
|
|
23
|
-
parseProviderOptions,
|
|
24
|
-
zodSchema
|
|
25
|
-
} from "@ai-sdk/provider-utils";
|
|
26
|
-
import { z } from "zod/v4";
|
|
27
|
-
var DEFAULT_POLL_INTERVAL_MILLIS = 500;
|
|
28
|
-
var DEFAULT_MAX_POLL_ATTEMPTS = 6e4 / DEFAULT_POLL_INTERVAL_MILLIS;
|
|
29
|
-
var LumaImageModel = class {
|
|
30
|
-
constructor(modelId, config) {
|
|
31
|
-
this.modelId = modelId;
|
|
32
|
-
this.config = config;
|
|
33
|
-
this.specificationVersion = "v4";
|
|
34
|
-
this.maxImagesPerCall = 1;
|
|
35
|
-
this.pollIntervalMillis = DEFAULT_POLL_INTERVAL_MILLIS;
|
|
36
|
-
this.maxPollAttempts = DEFAULT_MAX_POLL_ATTEMPTS;
|
|
37
|
-
}
|
|
38
|
-
get provider() {
|
|
39
|
-
return this.config.provider;
|
|
40
|
-
}
|
|
41
|
-
async doGenerate({
|
|
42
|
-
prompt,
|
|
43
|
-
size,
|
|
44
|
-
aspectRatio,
|
|
45
|
-
seed,
|
|
46
|
-
providerOptions,
|
|
47
|
-
headers,
|
|
48
|
-
abortSignal,
|
|
49
|
-
files,
|
|
50
|
-
mask
|
|
51
|
-
}) {
|
|
52
|
-
var _a, _b, _c;
|
|
53
|
-
const warnings = [];
|
|
54
|
-
if (seed != null) {
|
|
55
|
-
warnings.push({
|
|
56
|
-
type: "unsupported",
|
|
57
|
-
feature: "seed",
|
|
58
|
-
details: "This model does not support the `seed` option."
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
if (size != null) {
|
|
62
|
-
warnings.push({
|
|
63
|
-
type: "unsupported",
|
|
64
|
-
feature: "size",
|
|
65
|
-
details: "This model does not support the `size` option. Use `aspectRatio` instead."
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
const lumaOptions = await parseProviderOptions({
|
|
69
|
-
provider: "luma",
|
|
70
|
-
providerOptions,
|
|
71
|
-
schema: lumaImageModelOptionsSchema
|
|
72
|
-
});
|
|
73
|
-
const {
|
|
74
|
-
pollIntervalMillis,
|
|
75
|
-
maxPollAttempts,
|
|
76
|
-
referenceType,
|
|
77
|
-
images: imageConfigs,
|
|
78
|
-
...providerRequestOptions
|
|
79
|
-
} = lumaOptions != null ? lumaOptions : {};
|
|
80
|
-
const editingOptions = this.getEditingOptions(
|
|
81
|
-
files,
|
|
82
|
-
mask,
|
|
83
|
-
referenceType != null ? referenceType : void 0,
|
|
84
|
-
imageConfigs != null ? imageConfigs : []
|
|
85
|
-
);
|
|
86
|
-
const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
|
|
87
|
-
const fullHeaders = combineHeaders(this.config.headers(), headers);
|
|
88
|
-
const { value: generationResponse, responseHeaders } = await postJsonToApi({
|
|
89
|
-
url: this.getLumaGenerationsUrl(),
|
|
90
|
-
headers: fullHeaders,
|
|
91
|
-
body: {
|
|
92
|
-
prompt,
|
|
93
|
-
...aspectRatio ? { aspect_ratio: aspectRatio } : {},
|
|
94
|
-
model: this.modelId,
|
|
95
|
-
...editingOptions,
|
|
96
|
-
...providerRequestOptions
|
|
97
|
-
},
|
|
98
|
-
abortSignal,
|
|
99
|
-
fetch: this.config.fetch,
|
|
100
|
-
failedResponseHandler: this.createLumaErrorHandler(),
|
|
101
|
-
successfulResponseHandler: createJsonResponseHandler(
|
|
102
|
-
lumaGenerationResponseSchema
|
|
103
|
-
)
|
|
104
|
-
});
|
|
105
|
-
const imageUrl = await this.pollForImageUrl(
|
|
106
|
-
generationResponse.id,
|
|
107
|
-
fullHeaders,
|
|
108
|
-
abortSignal,
|
|
109
|
-
{
|
|
110
|
-
pollIntervalMillis: pollIntervalMillis != null ? pollIntervalMillis : void 0,
|
|
111
|
-
maxPollAttempts: maxPollAttempts != null ? maxPollAttempts : void 0
|
|
112
|
-
}
|
|
113
|
-
);
|
|
114
|
-
const downloadedImage = await this.downloadImage(imageUrl, abortSignal);
|
|
115
|
-
return {
|
|
116
|
-
images: [downloadedImage],
|
|
117
|
-
warnings,
|
|
118
|
-
response: {
|
|
119
|
-
modelId: this.modelId,
|
|
120
|
-
timestamp: currentDate,
|
|
121
|
-
headers: responseHeaders
|
|
122
|
-
}
|
|
123
|
-
};
|
|
124
|
-
}
|
|
125
|
-
async pollForImageUrl(generationId, headers, abortSignal, pollSettings) {
|
|
126
|
-
var _a, _b, _c;
|
|
127
|
-
const url = this.getLumaGenerationsUrl(generationId);
|
|
128
|
-
const maxPollAttempts = (_a = pollSettings == null ? void 0 : pollSettings.maxPollAttempts) != null ? _a : this.maxPollAttempts;
|
|
129
|
-
const pollIntervalMillis = (_b = pollSettings == null ? void 0 : pollSettings.pollIntervalMillis) != null ? _b : this.pollIntervalMillis;
|
|
130
|
-
for (let i = 0; i < maxPollAttempts; i++) {
|
|
131
|
-
const { value: statusResponse } = await getFromApi({
|
|
132
|
-
url,
|
|
133
|
-
headers,
|
|
134
|
-
abortSignal,
|
|
135
|
-
fetch: this.config.fetch,
|
|
136
|
-
failedResponseHandler: this.createLumaErrorHandler(),
|
|
137
|
-
successfulResponseHandler: createJsonResponseHandler(
|
|
138
|
-
lumaGenerationResponseSchema
|
|
139
|
-
)
|
|
140
|
-
});
|
|
141
|
-
switch (statusResponse.state) {
|
|
142
|
-
case "completed":
|
|
143
|
-
if (!((_c = statusResponse.assets) == null ? void 0 : _c.image)) {
|
|
144
|
-
throw new InvalidResponseDataError({
|
|
145
|
-
data: statusResponse,
|
|
146
|
-
message: `Image generation completed but no image was found.`
|
|
147
|
-
});
|
|
148
|
-
}
|
|
149
|
-
return statusResponse.assets.image;
|
|
150
|
-
case "failed":
|
|
151
|
-
throw new InvalidResponseDataError({
|
|
152
|
-
data: statusResponse,
|
|
153
|
-
message: `Image generation failed.`
|
|
154
|
-
});
|
|
155
|
-
}
|
|
156
|
-
await delay(pollIntervalMillis);
|
|
157
|
-
}
|
|
158
|
-
throw new Error(
|
|
159
|
-
`Image generation timed out after ${this.maxPollAttempts} attempts.`
|
|
160
|
-
);
|
|
161
|
-
}
|
|
162
|
-
createLumaErrorHandler() {
|
|
163
|
-
return createJsonErrorResponseHandler({
|
|
164
|
-
errorSchema: lumaErrorSchema,
|
|
165
|
-
errorToMessage: (error) => {
|
|
166
|
-
var _a;
|
|
167
|
-
return (_a = error.detail[0].msg) != null ? _a : "Unknown error";
|
|
168
|
-
}
|
|
169
|
-
});
|
|
170
|
-
}
|
|
171
|
-
getEditingOptions(files, mask, referenceType = "image", imageConfigs = []) {
|
|
172
|
-
var _a, _b, _c, _d;
|
|
173
|
-
const options = {};
|
|
174
|
-
if (mask != null) {
|
|
175
|
-
throw new Error(
|
|
176
|
-
"Luma AI does not support mask-based image editing. Use the prompt to describe the changes you want to make, along with `prompt.images` containing the source image URL."
|
|
177
|
-
);
|
|
178
|
-
}
|
|
179
|
-
if (files == null || files.length === 0) {
|
|
180
|
-
return options;
|
|
181
|
-
}
|
|
182
|
-
for (const file of files) {
|
|
183
|
-
if (file.type !== "url") {
|
|
184
|
-
throw new Error(
|
|
185
|
-
"Luma AI only supports URL-based images. Please provide image URLs using `prompt.images` with publicly accessible URLs. Base64 and Uint8Array data are not supported."
|
|
186
|
-
);
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
const defaultWeights = {
|
|
190
|
-
image: 0.85,
|
|
191
|
-
style: 0.8,
|
|
192
|
-
character: 1,
|
|
193
|
-
// Not used, but defined for completeness
|
|
194
|
-
modify_image: 1
|
|
195
|
-
};
|
|
196
|
-
switch (referenceType) {
|
|
197
|
-
case "image": {
|
|
198
|
-
if (files.length > 4) {
|
|
199
|
-
throw new Error(
|
|
200
|
-
`Luma AI image supports up to 4 reference images. You provided ${files.length} images.`
|
|
201
|
-
);
|
|
202
|
-
}
|
|
203
|
-
options.image = files.map((file, index) => {
|
|
204
|
-
var _a2, _b2;
|
|
205
|
-
return {
|
|
206
|
-
url: file.url,
|
|
207
|
-
weight: (_b2 = (_a2 = imageConfigs[index]) == null ? void 0 : _a2.weight) != null ? _b2 : defaultWeights.image
|
|
208
|
-
};
|
|
209
|
-
});
|
|
210
|
-
break;
|
|
211
|
-
}
|
|
212
|
-
case "style": {
|
|
213
|
-
options.style = files.map((file, index) => {
|
|
214
|
-
var _a2, _b2;
|
|
215
|
-
return {
|
|
216
|
-
url: file.url,
|
|
217
|
-
weight: (_b2 = (_a2 = imageConfigs[index]) == null ? void 0 : _a2.weight) != null ? _b2 : defaultWeights.style
|
|
218
|
-
};
|
|
219
|
-
});
|
|
220
|
-
break;
|
|
221
|
-
}
|
|
222
|
-
case "character": {
|
|
223
|
-
const identities = {};
|
|
224
|
-
for (let i = 0; i < files.length; i++) {
|
|
225
|
-
const file = files[i];
|
|
226
|
-
const identityId = (_b = (_a = imageConfigs[i]) == null ? void 0 : _a.id) != null ? _b : "identity0";
|
|
227
|
-
if (!identities[identityId]) {
|
|
228
|
-
identities[identityId] = [];
|
|
229
|
-
}
|
|
230
|
-
identities[identityId].push(file.url);
|
|
231
|
-
}
|
|
232
|
-
for (const [identityId, images] of Object.entries(identities)) {
|
|
233
|
-
if (images.length > 4) {
|
|
234
|
-
throw new Error(
|
|
235
|
-
`Luma AI character supports up to 4 images per identity. Identity '${identityId}' has ${images.length} images.`
|
|
236
|
-
);
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
options.character = Object.fromEntries(
|
|
240
|
-
Object.entries(identities).map(([id, images]) => [id, { images }])
|
|
241
|
-
);
|
|
242
|
-
break;
|
|
243
|
-
}
|
|
244
|
-
case "modify_image": {
|
|
245
|
-
if (files.length > 1) {
|
|
246
|
-
throw new Error(
|
|
247
|
-
`Luma AI modify_image only supports a single input image. You provided ${files.length} images.`
|
|
248
|
-
);
|
|
249
|
-
}
|
|
250
|
-
options.modify_image = {
|
|
251
|
-
url: files[0].url,
|
|
252
|
-
weight: (_d = (_c = imageConfigs[0]) == null ? void 0 : _c.weight) != null ? _d : defaultWeights.modify_image
|
|
253
|
-
};
|
|
254
|
-
break;
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
return options;
|
|
258
|
-
}
|
|
259
|
-
getLumaGenerationsUrl(generationId) {
|
|
260
|
-
return `${this.config.baseURL}/dream-machine/v1/generations/${generationId != null ? generationId : "image"}`;
|
|
261
|
-
}
|
|
262
|
-
async downloadImage(url, abortSignal) {
|
|
263
|
-
const { value: response } = await getFromApi({
|
|
264
|
-
url,
|
|
265
|
-
// No specific headers should be needed for this request as it's a
|
|
266
|
-
// generated image provided by Luma.
|
|
267
|
-
abortSignal,
|
|
268
|
-
failedResponseHandler: createStatusCodeErrorResponseHandler(),
|
|
269
|
-
successfulResponseHandler: createBinaryResponseHandler(),
|
|
270
|
-
fetch: this.config.fetch
|
|
271
|
-
});
|
|
272
|
-
return response;
|
|
273
|
-
}
|
|
274
|
-
};
|
|
275
|
-
var lumaGenerationResponseSchema = lazySchema(
|
|
276
|
-
() => zodSchema(
|
|
277
|
-
z.object({
|
|
278
|
-
id: z.string(),
|
|
279
|
-
state: z.enum(["queued", "dreaming", "completed", "failed"]),
|
|
280
|
-
failure_reason: z.string().nullish(),
|
|
281
|
-
assets: z.object({
|
|
282
|
-
image: z.string()
|
|
283
|
-
// URL of the generated image
|
|
284
|
-
}).nullish()
|
|
285
|
-
})
|
|
286
|
-
)
|
|
287
|
-
);
|
|
288
|
-
var lumaErrorSchema = z.object({
|
|
289
|
-
detail: z.array(
|
|
290
|
-
z.object({
|
|
291
|
-
type: z.string(),
|
|
292
|
-
loc: z.array(z.string()),
|
|
293
|
-
msg: z.string(),
|
|
294
|
-
input: z.string(),
|
|
295
|
-
ctx: z.object({
|
|
296
|
-
expected: z.string()
|
|
297
|
-
}).nullish()
|
|
298
|
-
})
|
|
299
|
-
)
|
|
300
|
-
});
|
|
301
|
-
var lumaImageModelOptionsSchema = lazySchema(
|
|
302
|
-
() => zodSchema(
|
|
303
|
-
z.object({
|
|
304
|
-
/**
|
|
305
|
-
* The type of image reference to use when providing input images.
|
|
306
|
-
* - `image`: Guide generation using reference images (up to 4). Default.
|
|
307
|
-
* - `style`: Apply a specific style from reference image(s).
|
|
308
|
-
* - `character`: Create consistent characters from reference images (up to 4).
|
|
309
|
-
* - `modify_image`: Transform a single input image with prompt guidance.
|
|
310
|
-
*/
|
|
311
|
-
referenceType: z.enum(["image", "style", "character", "modify_image"]).nullish(),
|
|
312
|
-
/**
|
|
313
|
-
* Per-image configuration array. Each entry corresponds to an image in `prompt.images`.
|
|
314
|
-
* Allows setting individual weights for each reference image.
|
|
315
|
-
*/
|
|
316
|
-
images: z.array(
|
|
317
|
-
z.object({
|
|
318
|
-
/**
|
|
319
|
-
* The weight of this image's influence on the generation.
|
|
320
|
-
* - For `image`: Higher weight = closer to reference (default: 0.85)
|
|
321
|
-
* - For `style`: Higher weight = stronger style influence (default: 0.8)
|
|
322
|
-
* - For `modify_image`: Higher weight = closer to input, lower = more creative (default: 1.0)
|
|
323
|
-
*/
|
|
324
|
-
weight: z.number().min(0).max(1).nullish(),
|
|
325
|
-
/**
|
|
326
|
-
* The identity name for character references.
|
|
327
|
-
* Used with `character` to specify which identity group the image belongs to.
|
|
328
|
-
* Luma supports multiple identities (e.g., 'identity0', 'identity1') for generating
|
|
329
|
-
* images with multiple consistent characters.
|
|
330
|
-
* Default: 'identity0'
|
|
331
|
-
*/
|
|
332
|
-
id: z.string().nullish()
|
|
333
|
-
})
|
|
334
|
-
).nullish(),
|
|
335
|
-
/**
|
|
336
|
-
* Override the polling interval in milliseconds (default 500).
|
|
337
|
-
*/
|
|
338
|
-
pollIntervalMillis: z.number().nullish(),
|
|
339
|
-
/**
|
|
340
|
-
* Override the maximum number of polling attempts (default 120).
|
|
341
|
-
*/
|
|
342
|
-
maxPollAttempts: z.number().nullish()
|
|
343
|
-
}).passthrough()
|
|
344
|
-
)
|
|
345
|
-
);
|
|
346
|
-
|
|
347
|
-
// src/version.ts
|
|
348
|
-
var VERSION = true ? "3.0.0-beta.19" : "0.0.0-test";
|
|
349
|
-
|
|
350
|
-
// src/luma-provider.ts
|
|
351
|
-
var defaultBaseURL = "https://api.lumalabs.ai";
|
|
352
|
-
function createLuma(options = {}) {
|
|
353
|
-
var _a;
|
|
354
|
-
const baseURL = withoutTrailingSlash((_a = options.baseURL) != null ? _a : defaultBaseURL);
|
|
355
|
-
const getHeaders = () => withUserAgentSuffix(
|
|
356
|
-
{
|
|
357
|
-
Authorization: `Bearer ${loadApiKey({
|
|
358
|
-
apiKey: options.apiKey,
|
|
359
|
-
environmentVariableName: "LUMA_API_KEY",
|
|
360
|
-
description: "Luma"
|
|
361
|
-
})}`,
|
|
362
|
-
...options.headers
|
|
363
|
-
},
|
|
364
|
-
`ai-sdk/luma/${VERSION}`
|
|
365
|
-
);
|
|
366
|
-
const createImageModel = (modelId) => new LumaImageModel(modelId, {
|
|
367
|
-
provider: "luma.image",
|
|
368
|
-
baseURL: baseURL != null ? baseURL : defaultBaseURL,
|
|
369
|
-
headers: getHeaders,
|
|
370
|
-
fetch: options.fetch
|
|
371
|
-
});
|
|
372
|
-
const embeddingModel = (modelId) => {
|
|
373
|
-
throw new NoSuchModelError({
|
|
374
|
-
modelId,
|
|
375
|
-
modelType: "embeddingModel"
|
|
376
|
-
});
|
|
377
|
-
};
|
|
378
|
-
return {
|
|
379
|
-
specificationVersion: "v4",
|
|
380
|
-
image: createImageModel,
|
|
381
|
-
imageModel: createImageModel,
|
|
382
|
-
languageModel: (modelId) => {
|
|
383
|
-
throw new NoSuchModelError({
|
|
384
|
-
modelId,
|
|
385
|
-
modelType: "languageModel"
|
|
386
|
-
});
|
|
387
|
-
},
|
|
388
|
-
embeddingModel,
|
|
389
|
-
textEmbeddingModel: embeddingModel
|
|
390
|
-
};
|
|
391
|
-
}
|
|
392
|
-
var luma = createLuma();
|
|
393
|
-
export {
|
|
394
|
-
VERSION,
|
|
395
|
-
createLuma,
|
|
396
|
-
luma
|
|
397
|
-
};
|
|
398
|
-
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/luma-provider.ts","../src/luma-image-model.ts","../src/version.ts"],"sourcesContent":["import { ImageModelV4, NoSuchModelError, ProviderV4 } from '@ai-sdk/provider';\nimport {\n FetchFunction,\n loadApiKey,\n withoutTrailingSlash,\n withUserAgentSuffix,\n} from '@ai-sdk/provider-utils';\nimport { LumaImageModel } from './luma-image-model';\nimport { LumaImageModelId } from './luma-image-settings';\nimport { VERSION } from './version';\n\nexport interface LumaProviderSettings {\n /**\n * Luma API key. Default value is taken from the `LUMA_API_KEY` environment\n * variable.\n */\n apiKey?: string;\n /**\n * Base URL for the API calls.\n */\n baseURL?: string;\n /**\n * Custom headers to include in the requests.\n */\n headers?: Record<string, string>;\n /**\n * Custom fetch implementation. You can use it as a middleware to intercept requests,\n * or to provide a custom fetch implementation for e.g. testing.\n */\n fetch?: FetchFunction;\n}\n\nexport interface LumaProvider extends ProviderV4 {\n /**\n * Creates a model for image generation.\n */\n image(modelId: LumaImageModelId): ImageModelV4;\n\n /**\n * Creates a model for image generation.\n */\n imageModel(modelId: LumaImageModelId): ImageModelV4;\n\n /**\n * @deprecated Use `embeddingModel` instead.\n */\n textEmbeddingModel(modelId: string): never;\n}\n\nconst defaultBaseURL = 'https://api.lumalabs.ai';\n\nexport function createLuma(options: LumaProviderSettings = {}): LumaProvider {\n const baseURL = withoutTrailingSlash(options.baseURL ?? defaultBaseURL);\n const getHeaders = () =>\n withUserAgentSuffix(\n {\n Authorization: `Bearer ${loadApiKey({\n apiKey: options.apiKey,\n environmentVariableName: 'LUMA_API_KEY',\n description: 'Luma',\n })}`,\n ...options.headers,\n },\n `ai-sdk/luma/${VERSION}`,\n );\n\n const createImageModel = (modelId: LumaImageModelId) =>\n new LumaImageModel(modelId, {\n provider: 'luma.image',\n baseURL: baseURL ?? defaultBaseURL,\n headers: getHeaders,\n fetch: options.fetch,\n });\n\n const embeddingModel = (modelId: string) => {\n throw new NoSuchModelError({\n modelId,\n modelType: 'embeddingModel',\n });\n };\n\n return {\n specificationVersion: 'v4' as const,\n image: createImageModel,\n imageModel: createImageModel,\n languageModel: (modelId: string) => {\n throw new NoSuchModelError({\n modelId,\n modelType: 'languageModel',\n });\n },\n embeddingModel,\n textEmbeddingModel: embeddingModel,\n };\n}\n\nexport const luma = createLuma();\n","import {\n ImageModelV4,\n ImageModelV4File,\n SharedV4Warning,\n InvalidResponseDataError,\n} from '@ai-sdk/provider';\nimport {\n FetchFunction,\n combineHeaders,\n createBinaryResponseHandler,\n createJsonResponseHandler,\n createJsonErrorResponseHandler,\n createStatusCodeErrorResponseHandler,\n delay,\n getFromApi,\n postJsonToApi,\n InferSchema,\n lazySchema,\n parseProviderOptions,\n zodSchema,\n} from '@ai-sdk/provider-utils';\nimport { LumaReferenceType } from './luma-image-settings';\nimport { z } from 'zod/v4';\n\nconst DEFAULT_POLL_INTERVAL_MILLIS = 500;\nconst DEFAULT_MAX_POLL_ATTEMPTS = 60000 / DEFAULT_POLL_INTERVAL_MILLIS;\n\ninterface LumaImageModelConfig {\n provider: string;\n baseURL: string;\n headers: () => Record<string, string>;\n fetch?: FetchFunction;\n _internal?: {\n currentDate?: () => Date;\n };\n}\n\nexport class LumaImageModel implements ImageModelV4 {\n readonly specificationVersion = 'v4';\n readonly maxImagesPerCall = 1;\n readonly pollIntervalMillis = DEFAULT_POLL_INTERVAL_MILLIS;\n readonly maxPollAttempts = DEFAULT_MAX_POLL_ATTEMPTS;\n\n get provider(): string {\n return this.config.provider;\n }\n\n constructor(\n readonly modelId: string,\n private readonly config: LumaImageModelConfig,\n ) {}\n\n async doGenerate({\n prompt,\n size,\n aspectRatio,\n seed,\n providerOptions,\n headers,\n abortSignal,\n files,\n mask,\n }: Parameters<ImageModelV4['doGenerate']>[0]): Promise<\n Awaited<ReturnType<ImageModelV4['doGenerate']>>\n > {\n const warnings: Array<SharedV4Warning> = [];\n\n if (seed != null) {\n warnings.push({\n type: 'unsupported',\n feature: 'seed',\n details: 'This model does not support the `seed` option.',\n });\n }\n\n if (size != null) {\n warnings.push({\n type: 'unsupported',\n feature: 'size',\n details:\n 'This model does not support the `size` option. Use `aspectRatio` instead.',\n });\n }\n\n // Parse and validate provider options\n const lumaOptions = await parseProviderOptions({\n provider: 'luma',\n providerOptions,\n schema: lumaImageModelOptionsSchema,\n });\n\n // Extract non-request options\n const {\n pollIntervalMillis,\n maxPollAttempts,\n referenceType,\n images: imageConfigs,\n ...providerRequestOptions\n } = lumaOptions ?? {};\n\n // Handle image editing via files with reference type support\n const editingOptions = this.getEditingOptions(\n files,\n mask,\n referenceType ?? undefined,\n imageConfigs ?? [],\n );\n\n const currentDate = this.config._internal?.currentDate?.() ?? new Date();\n const fullHeaders = combineHeaders(this.config.headers(), headers);\n const { value: generationResponse, responseHeaders } = await postJsonToApi({\n url: this.getLumaGenerationsUrl(),\n headers: fullHeaders,\n body: {\n prompt,\n ...(aspectRatio ? { aspect_ratio: aspectRatio } : {}),\n model: this.modelId,\n ...editingOptions,\n ...providerRequestOptions,\n },\n abortSignal,\n fetch: this.config.fetch,\n failedResponseHandler: this.createLumaErrorHandler(),\n successfulResponseHandler: createJsonResponseHandler(\n lumaGenerationResponseSchema,\n ),\n });\n\n const imageUrl = await this.pollForImageUrl(\n generationResponse.id,\n fullHeaders,\n abortSignal,\n {\n pollIntervalMillis: pollIntervalMillis ?? undefined,\n maxPollAttempts: maxPollAttempts ?? undefined,\n },\n );\n\n const downloadedImage = await this.downloadImage(imageUrl, abortSignal);\n\n return {\n images: [downloadedImage],\n warnings,\n response: {\n modelId: this.modelId,\n timestamp: currentDate,\n headers: responseHeaders,\n },\n };\n }\n\n private async pollForImageUrl(\n generationId: string,\n headers: Record<string, string | undefined>,\n abortSignal: AbortSignal | undefined,\n pollSettings?: { pollIntervalMillis?: number; maxPollAttempts?: number },\n ): Promise<string> {\n const url = this.getLumaGenerationsUrl(generationId);\n const maxPollAttempts =\n pollSettings?.maxPollAttempts ?? this.maxPollAttempts;\n const pollIntervalMillis =\n pollSettings?.pollIntervalMillis ?? this.pollIntervalMillis;\n\n for (let i = 0; i < maxPollAttempts; i++) {\n const { value: statusResponse } = await getFromApi({\n url,\n headers,\n abortSignal,\n fetch: this.config.fetch,\n failedResponseHandler: this.createLumaErrorHandler(),\n successfulResponseHandler: createJsonResponseHandler(\n lumaGenerationResponseSchema,\n ),\n });\n\n switch (statusResponse.state) {\n case 'completed':\n if (!statusResponse.assets?.image) {\n throw new InvalidResponseDataError({\n data: statusResponse,\n message: `Image generation completed but no image was found.`,\n });\n }\n return statusResponse.assets.image;\n case 'failed':\n throw new InvalidResponseDataError({\n data: statusResponse,\n message: `Image generation failed.`,\n });\n }\n await delay(pollIntervalMillis);\n }\n\n throw new Error(\n `Image generation timed out after ${this.maxPollAttempts} attempts.`,\n );\n }\n\n private createLumaErrorHandler() {\n return createJsonErrorResponseHandler({\n errorSchema: lumaErrorSchema,\n errorToMessage: (error: LumaErrorData) =>\n error.detail[0].msg ?? 'Unknown error',\n });\n }\n\n private getEditingOptions(\n files: ImageModelV4File[] | undefined,\n mask: ImageModelV4File | undefined,\n referenceType: LumaReferenceType = 'image',\n imageConfigs: Array<{ weight?: number | null; id?: string | null }> = [],\n ): Record<string, unknown> {\n const options: Record<string, unknown> = {};\n\n // Luma does not support mask-based inpainting\n if (mask != null) {\n throw new Error(\n 'Luma AI does not support mask-based image editing. ' +\n 'Use the prompt to describe the changes you want to make, along with ' +\n '`prompt.images` containing the source image URL.',\n );\n }\n\n if (files == null || files.length === 0) {\n return options;\n }\n\n // Validate all files are URL-based\n for (const file of files) {\n if (file.type !== 'url') {\n throw new Error(\n 'Luma AI only supports URL-based images. ' +\n 'Please provide image URLs using `prompt.images` with publicly accessible URLs. ' +\n 'Base64 and Uint8Array data are not supported.',\n );\n }\n }\n\n // Default weights per reference type\n const defaultWeights: Record<LumaReferenceType, number> = {\n image: 0.85,\n style: 0.8,\n character: 1.0, // Not used, but defined for completeness\n modify_image: 1.0,\n };\n\n switch (referenceType) {\n case 'image': {\n // Supports up to 4 images\n if (files.length > 4) {\n throw new Error(\n 'Luma AI image supports up to 4 reference images. ' +\n `You provided ${files.length} images.`,\n );\n }\n options.image = files.map((file, index) => ({\n url: (file as { type: 'url'; url: string }).url,\n weight: imageConfigs[index]?.weight ?? defaultWeights.image,\n }));\n break;\n }\n\n case 'style': {\n // Style ref accepts an array but typically uses one style image\n options.style = files.map((file, index) => ({\n url: (file as { type: 'url'; url: string }).url,\n weight: imageConfigs[index]?.weight ?? defaultWeights.style,\n }));\n break;\n }\n\n case 'character': {\n // Group images by identity id\n const identities: Record<string, string[]> = {};\n for (let i = 0; i < files.length; i++) {\n const file = files[i] as { type: 'url'; url: string };\n const identityId = imageConfigs[i]?.id ?? 'identity0';\n if (!identities[identityId]) {\n identities[identityId] = [];\n }\n identities[identityId].push(file.url);\n }\n\n // Validate each identity has at most 4 images\n for (const [identityId, images] of Object.entries(identities)) {\n if (images.length > 4) {\n throw new Error(\n `Luma AI character supports up to 4 images per identity. ` +\n `Identity '${identityId}' has ${images.length} images.`,\n );\n }\n }\n\n options.character = Object.fromEntries(\n Object.entries(identities).map(([id, images]) => [id, { images }]),\n );\n break;\n }\n\n case 'modify_image': {\n // Only supports a single image\n if (files.length > 1) {\n throw new Error(\n 'Luma AI modify_image only supports a single input image. ' +\n `You provided ${files.length} images.`,\n );\n }\n options.modify_image = {\n url: (files[0] as { type: 'url'; url: string }).url,\n weight: imageConfigs[0]?.weight ?? defaultWeights.modify_image,\n };\n break;\n }\n }\n\n return options;\n }\n\n private getLumaGenerationsUrl(generationId?: string) {\n return `${this.config.baseURL}/dream-machine/v1/generations/${\n generationId ?? 'image'\n }`;\n }\n\n private async downloadImage(\n url: string,\n abortSignal: AbortSignal | undefined,\n ): Promise<Uint8Array> {\n const { value: response } = await getFromApi({\n url,\n // No specific headers should be needed for this request as it's a\n // generated image provided by Luma.\n abortSignal,\n failedResponseHandler: createStatusCodeErrorResponseHandler(),\n successfulResponseHandler: createBinaryResponseHandler(),\n fetch: this.config.fetch,\n });\n return response;\n }\n}\n\n// limited version of the schema, focussed on what is needed for the implementation\n// this approach limits breakages when the API changes and increases efficiency\nconst lumaGenerationResponseSchema = lazySchema(() =>\n zodSchema(\n z.object({\n id: z.string(),\n state: z.enum(['queued', 'dreaming', 'completed', 'failed']),\n failure_reason: z.string().nullish(),\n assets: z\n .object({\n image: z.string(), // URL of the generated image\n })\n .nullish(),\n }),\n ),\n);\n\nconst lumaErrorSchema = z.object({\n detail: z.array(\n z.object({\n type: z.string(),\n loc: z.array(z.string()),\n msg: z.string(),\n input: z.string(),\n ctx: z\n .object({\n expected: z.string(),\n })\n .nullish(),\n }),\n ),\n});\n\nexport type LumaErrorData = z.infer<typeof lumaErrorSchema>;\n\n/**\n * Provider options schema for Luma image generation.\n *\n * @see https://docs.lumalabs.ai/docs/image-generation\n */\nexport const lumaImageModelOptionsSchema = lazySchema(() =>\n zodSchema(\n z\n .object({\n /**\n * The type of image reference to use when providing input images.\n * - `image`: Guide generation using reference images (up to 4). Default.\n * - `style`: Apply a specific style from reference image(s).\n * - `character`: Create consistent characters from reference images (up to 4).\n * - `modify_image`: Transform a single input image with prompt guidance.\n */\n referenceType: z\n .enum(['image', 'style', 'character', 'modify_image'])\n .nullish(),\n\n /**\n * Per-image configuration array. Each entry corresponds to an image in `prompt.images`.\n * Allows setting individual weights for each reference image.\n */\n images: z\n .array(\n z.object({\n /**\n * The weight of this image's influence on the generation.\n * - For `image`: Higher weight = closer to reference (default: 0.85)\n * - For `style`: Higher weight = stronger style influence (default: 0.8)\n * - For `modify_image`: Higher weight = closer to input, lower = more creative (default: 1.0)\n */\n weight: z.number().min(0).max(1).nullish(),\n\n /**\n * The identity name for character references.\n * Used with `character` to specify which identity group the image belongs to.\n * Luma supports multiple identities (e.g., 'identity0', 'identity1') for generating\n * images with multiple consistent characters.\n * Default: 'identity0'\n */\n id: z.string().nullish(),\n }),\n )\n .nullish(),\n\n /**\n * Override the polling interval in milliseconds (default 500).\n */\n pollIntervalMillis: z.number().nullish(),\n\n /**\n * Override the maximum number of polling attempts (default 120).\n */\n maxPollAttempts: z.number().nullish(),\n })\n .passthrough(),\n ),\n);\n\nexport type LumaImageModelOptions = InferSchema<\n typeof lumaImageModelOptionsSchema\n>;\n","// Version string of this package injected at build time.\ndeclare const __PACKAGE_VERSION__: string | undefined;\nexport const VERSION: string =\n typeof __PACKAGE_VERSION__ !== 'undefined'\n ? __PACKAGE_VERSION__\n : '0.0.0-test';\n"],"mappings":";AAAA,SAAuB,wBAAoC;AAC3D;AAAA,EAEE;AAAA,EACA;AAAA,EACA;AAAA,OACK;;;ACNP;AAAA,EAIE;AAAA,OACK;AACP;AAAA,EAEE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAAS,SAAS;AAElB,IAAM,+BAA+B;AACrC,IAAM,4BAA4B,MAAQ;AAYnC,IAAM,iBAAN,MAA6C;AAAA,EAUlD,YACW,SACQ,QACjB;AAFS;AACQ;AAXnB,SAAS,uBAAuB;AAChC,SAAS,mBAAmB;AAC5B,SAAS,qBAAqB;AAC9B,SAAS,kBAAkB;AAAA,EASxB;AAAA,EAPH,IAAI,WAAmB;AACrB,WAAO,KAAK,OAAO;AAAA,EACrB;AAAA,EAOA,MAAM,WAAW;AAAA,IACf;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,GAEE;AAhEJ;AAiEI,UAAM,WAAmC,CAAC;AAE1C,QAAI,QAAQ,MAAM;AAChB,eAAS,KAAK;AAAA,QACZ,MAAM;AAAA,QACN,SAAS;AAAA,QACT,SAAS;AAAA,MACX,CAAC;AAAA,IACH;AAEA,QAAI,QAAQ,MAAM;AAChB,eAAS,KAAK;AAAA,QACZ,MAAM;AAAA,QACN,SAAS;AAAA,QACT,SACE;AAAA,MACJ,CAAC;AAAA,IACH;AAGA,UAAM,cAAc,MAAM,qBAAqB;AAAA,MAC7C,UAAU;AAAA,MACV;AAA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