@agent-media/providers 0.6.0 → 0.7.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/ai-gateway/index.d.ts +14 -0
- package/dist/ai-gateway/index.d.ts.map +1 -0
- package/dist/ai-gateway/index.js +230 -0
- package/dist/ai-gateway/index.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/package.json +6 -2
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { MediaProvider } from '@agent-media/core';
|
|
2
|
+
/**
|
|
3
|
+
* AI Gateway provider for image generation and editing
|
|
4
|
+
* Requires AI_GATEWAY_API_KEY environment variable
|
|
5
|
+
*
|
|
6
|
+
* Supported actions:
|
|
7
|
+
* - generate: Text-to-image using BFL Flux, Google Imagen, Recraft models
|
|
8
|
+
* Default model: bfl/flux-2-pro
|
|
9
|
+
* - edit: Image editing using Google Nano Banana Pro
|
|
10
|
+
* Default model: google/gemini-3-pro-image
|
|
11
|
+
*/
|
|
12
|
+
export declare const aiGatewayProvider: MediaProvider;
|
|
13
|
+
export default aiGatewayProvider;
|
|
14
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ai-gateway/index.ts"],"names":[],"mappings":"AAkDA,OAAO,KAAK,EACV,aAAa,EAMd,MAAM,mBAAmB,CAAC;AAe3B;;;;;;;;;GASG;AACH,eAAO,MAAM,iBAAiB,EAAE,aAuC/B,CAAC;AA0KF,eAAe,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
import { generateImage, generateText } from 'ai';
|
|
2
|
+
import { writeFile, readFile, stat } from 'node:fs/promises';
|
|
3
|
+
/**
|
|
4
|
+
* Unwrap Promise-wrapped errors from the AI SDK gateway
|
|
5
|
+
* The gateway sometimes throws errors that are themselves Promises
|
|
6
|
+
*/
|
|
7
|
+
async function unwrapError(error) {
|
|
8
|
+
let current = error;
|
|
9
|
+
// Recursively unwrap if it's a Promise (up to 3 levels deep)
|
|
10
|
+
for (let i = 0; i < 3; i++) {
|
|
11
|
+
if (current && typeof current.then === 'function') {
|
|
12
|
+
try {
|
|
13
|
+
await current;
|
|
14
|
+
// If we get here, the Promise resolved successfully which is unexpected
|
|
15
|
+
return 'Unknown error (Promise resolved unexpectedly)';
|
|
16
|
+
}
|
|
17
|
+
catch (e) {
|
|
18
|
+
current = e;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
break;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
// Now extract the message
|
|
26
|
+
if (current instanceof Error) {
|
|
27
|
+
return current.message;
|
|
28
|
+
}
|
|
29
|
+
// Check for error-like objects
|
|
30
|
+
if (current && typeof current === 'object') {
|
|
31
|
+
const errObj = current;
|
|
32
|
+
if (typeof errObj.message === 'string') {
|
|
33
|
+
return errObj.message;
|
|
34
|
+
}
|
|
35
|
+
if (typeof errObj.error === 'string') {
|
|
36
|
+
return errObj.error;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
const str = String(current);
|
|
40
|
+
// Avoid returning "[object Promise]" or "[object Object]"
|
|
41
|
+
if (str.startsWith('[object ')) {
|
|
42
|
+
return 'Unknown error';
|
|
43
|
+
}
|
|
44
|
+
return str;
|
|
45
|
+
}
|
|
46
|
+
import { createSuccess, createError, ensureOutputDir, resolveOutputFilename, getOutputPath, ErrorCodes, } from '@agent-media/core';
|
|
47
|
+
/**
|
|
48
|
+
* Actions supported by the ai-gateway provider
|
|
49
|
+
*/
|
|
50
|
+
const SUPPORTED_ACTIONS = ['generate', 'edit'];
|
|
51
|
+
/**
|
|
52
|
+
* AI Gateway provider for image generation and editing
|
|
53
|
+
* Requires AI_GATEWAY_API_KEY environment variable
|
|
54
|
+
*
|
|
55
|
+
* Supported actions:
|
|
56
|
+
* - generate: Text-to-image using BFL Flux, Google Imagen, Recraft models
|
|
57
|
+
* Default model: bfl/flux-2-pro
|
|
58
|
+
* - edit: Image editing using Google Nano Banana Pro
|
|
59
|
+
* Default model: google/gemini-3-pro-image
|
|
60
|
+
*/
|
|
61
|
+
export const aiGatewayProvider = {
|
|
62
|
+
name: 'ai-gateway',
|
|
63
|
+
supports(action) {
|
|
64
|
+
return SUPPORTED_ACTIONS.includes(action);
|
|
65
|
+
},
|
|
66
|
+
async execute(actionConfig, context) {
|
|
67
|
+
const apiKey = process.env['AI_GATEWAY_API_KEY'];
|
|
68
|
+
if (!apiKey) {
|
|
69
|
+
return createError(ErrorCodes.API_ERROR, 'AI_GATEWAY_API_KEY environment variable is not set');
|
|
70
|
+
}
|
|
71
|
+
try {
|
|
72
|
+
await ensureOutputDir(context.outputDir);
|
|
73
|
+
switch (actionConfig.action) {
|
|
74
|
+
case 'generate':
|
|
75
|
+
return await executeGenerate(actionConfig.options, context, apiKey);
|
|
76
|
+
case 'edit':
|
|
77
|
+
return await executeEdit(actionConfig.options, context, apiKey);
|
|
78
|
+
default:
|
|
79
|
+
return createError(ErrorCodes.INVALID_INPUT, `Action '${actionConfig.action}' not supported by ai-gateway provider`);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
catch (error) {
|
|
83
|
+
const message = await unwrapError(error);
|
|
84
|
+
return createError(ErrorCodes.PROVIDER_ERROR, message);
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
};
|
|
88
|
+
/**
|
|
89
|
+
* Execute generate action using AI Gateway
|
|
90
|
+
* Default model: bfl/flux-2-pro
|
|
91
|
+
*
|
|
92
|
+
* Supported models:
|
|
93
|
+
* - BFL Flux: bfl/flux-2-pro, bfl/flux-2-flex, bfl/flux-kontext-max, bfl/flux-kontext-pro, bfl/flux-pro-1.1
|
|
94
|
+
* - Google Imagen: google/imagen-4.0-ultra-generate-001, google/imagen-4.0-generate-001
|
|
95
|
+
*
|
|
96
|
+
* Note: AI Gateway uses model ID strings directly, not a provider client.
|
|
97
|
+
* The API key is passed via environment variable AI_GATEWAY_API_KEY which is
|
|
98
|
+
* automatically read by the AI SDK when using gateway model IDs.
|
|
99
|
+
*/
|
|
100
|
+
async function executeGenerate(options, context, _apiKey) {
|
|
101
|
+
const { prompt, width = 1024, height = 1024, model, seed } = options;
|
|
102
|
+
if (!prompt) {
|
|
103
|
+
return createError(ErrorCodes.INVALID_INPUT, 'Prompt is required for image generation');
|
|
104
|
+
}
|
|
105
|
+
const modelId = model || 'bfl/flux-2-pro';
|
|
106
|
+
// AI Gateway image-only models use experimental_generateImage with model ID as string
|
|
107
|
+
// The API key is read from AI_GATEWAY_API_KEY environment variable automatically
|
|
108
|
+
let result;
|
|
109
|
+
try {
|
|
110
|
+
result = await generateImage({
|
|
111
|
+
model: modelId,
|
|
112
|
+
prompt,
|
|
113
|
+
aspectRatio: width === height ? '1:1' : `${width}:${height}`,
|
|
114
|
+
seed,
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
catch (err) {
|
|
118
|
+
const errMsg = await unwrapError(err);
|
|
119
|
+
return createError(ErrorCodes.PROVIDER_ERROR, errMsg);
|
|
120
|
+
}
|
|
121
|
+
// Image-only models return images in result.images as base64
|
|
122
|
+
if (!result.images || result.images.length === 0) {
|
|
123
|
+
return createError(ErrorCodes.PROVIDER_ERROR, 'No image was generated');
|
|
124
|
+
}
|
|
125
|
+
const generatedImage = result.images[0];
|
|
126
|
+
if (!generatedImage || !generatedImage.base64) {
|
|
127
|
+
return createError(ErrorCodes.PROVIDER_ERROR, 'Generated image has no data');
|
|
128
|
+
}
|
|
129
|
+
const outputFilename = resolveOutputFilename('png', 'generated', context.outputName);
|
|
130
|
+
const outputPath = getOutputPath(context.outputDir, outputFilename);
|
|
131
|
+
// Decode base64 and write to file
|
|
132
|
+
const buffer = Buffer.from(generatedImage.base64, 'base64');
|
|
133
|
+
await writeFile(outputPath, buffer);
|
|
134
|
+
const stats = await stat(outputPath);
|
|
135
|
+
return createSuccess({
|
|
136
|
+
mediaType: 'image',
|
|
137
|
+
action: 'generate',
|
|
138
|
+
provider: 'ai-gateway',
|
|
139
|
+
outputPath: outputPath,
|
|
140
|
+
mime: 'image/png',
|
|
141
|
+
bytes: stats.size,
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Execute edit action using AI Gateway with Google Nano Banana Pro
|
|
146
|
+
* Default model: google/gemini-3-pro-image
|
|
147
|
+
*
|
|
148
|
+
* Uses generateText() with multimodal input and extracts generated images from result.files
|
|
149
|
+
* Note: AI Gateway uses model ID strings directly, not a provider client.
|
|
150
|
+
*/
|
|
151
|
+
async function executeEdit(options, context, _apiKey) {
|
|
152
|
+
const { input, prompt, model } = options;
|
|
153
|
+
if (!input?.source) {
|
|
154
|
+
return createError(ErrorCodes.INVALID_INPUT, 'Input source is required for image editing');
|
|
155
|
+
}
|
|
156
|
+
if (!prompt) {
|
|
157
|
+
return createError(ErrorCodes.INVALID_INPUT, 'Prompt is required for image editing');
|
|
158
|
+
}
|
|
159
|
+
// Prepare the image as base64 data URL
|
|
160
|
+
let imageDataUrl;
|
|
161
|
+
if (input.isUrl) {
|
|
162
|
+
const response = await fetch(input.source);
|
|
163
|
+
if (!response.ok) {
|
|
164
|
+
return createError(ErrorCodes.NETWORK_ERROR, `Failed to fetch input image: ${response.statusText}`);
|
|
165
|
+
}
|
|
166
|
+
const arrayBuffer = await response.arrayBuffer();
|
|
167
|
+
const buffer = Buffer.from(arrayBuffer);
|
|
168
|
+
const base64 = buffer.toString('base64');
|
|
169
|
+
const contentType = response.headers.get('content-type') || 'image/png';
|
|
170
|
+
imageDataUrl = `data:${contentType};base64,${base64}`;
|
|
171
|
+
}
|
|
172
|
+
else {
|
|
173
|
+
const buffer = await readFile(input.source);
|
|
174
|
+
const base64 = buffer.toString('base64');
|
|
175
|
+
const ext = input.source.toLowerCase().split('.').pop();
|
|
176
|
+
const mimeType = ext === 'png' ? 'image/png' : ext === 'webp' ? 'image/webp' : 'image/jpeg';
|
|
177
|
+
imageDataUrl = `data:${mimeType};base64,${base64}`;
|
|
178
|
+
}
|
|
179
|
+
const modelId = model || 'google/gemini-3-pro-image';
|
|
180
|
+
// Use generateText with multimodal content for image editing
|
|
181
|
+
// Nano Banana Pro models can generate images as output files
|
|
182
|
+
// The API key is read from AI_GATEWAY_API_KEY environment variable automatically
|
|
183
|
+
let result;
|
|
184
|
+
try {
|
|
185
|
+
result = await generateText({
|
|
186
|
+
model: modelId,
|
|
187
|
+
messages: [
|
|
188
|
+
{
|
|
189
|
+
role: 'user',
|
|
190
|
+
content: [
|
|
191
|
+
{
|
|
192
|
+
type: 'image',
|
|
193
|
+
image: imageDataUrl,
|
|
194
|
+
},
|
|
195
|
+
{
|
|
196
|
+
type: 'text',
|
|
197
|
+
text: prompt,
|
|
198
|
+
},
|
|
199
|
+
],
|
|
200
|
+
},
|
|
201
|
+
],
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
catch (err) {
|
|
205
|
+
const errMsg = await unwrapError(err);
|
|
206
|
+
return createError(ErrorCodes.PROVIDER_ERROR, errMsg);
|
|
207
|
+
}
|
|
208
|
+
// Extract generated image from result.files
|
|
209
|
+
if (!result.files || result.files.length === 0) {
|
|
210
|
+
return createError(ErrorCodes.PROVIDER_ERROR, 'No image was generated by the model');
|
|
211
|
+
}
|
|
212
|
+
const generatedImage = result.files[0];
|
|
213
|
+
if (!generatedImage || !generatedImage.uint8Array) {
|
|
214
|
+
return createError(ErrorCodes.PROVIDER_ERROR, 'Generated image has no data');
|
|
215
|
+
}
|
|
216
|
+
const outputFilename = resolveOutputFilename('png', 'edited', context.outputName, context.inputSource);
|
|
217
|
+
const outputPath = getOutputPath(context.outputDir, outputFilename);
|
|
218
|
+
await writeFile(outputPath, generatedImage.uint8Array);
|
|
219
|
+
const stats = await stat(outputPath);
|
|
220
|
+
return createSuccess({
|
|
221
|
+
mediaType: 'image',
|
|
222
|
+
action: 'edit',
|
|
223
|
+
provider: 'ai-gateway',
|
|
224
|
+
outputPath: outputPath,
|
|
225
|
+
mime: 'image/png',
|
|
226
|
+
bytes: stats.size,
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
export default aiGatewayProvider;
|
|
230
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/ai-gateway/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAE7D;;;GAGG;AACH,KAAK,UAAU,WAAW,CAAC,KAAc;IACvC,IAAI,OAAO,GAAG,KAAK,CAAC;IAEpB,6DAA6D;IAC7D,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QAC3B,IAAI,OAAO,IAAI,OAAQ,OAA8B,CAAC,IAAI,KAAK,UAAU,EAAE,CAAC;YAC1E,IAAI,CAAC;gBACH,MAAO,OAA4B,CAAC;gBACpC,wEAAwE;gBACxE,OAAO,+CAA+C,CAAC;YACzD,CAAC;YAAC,OAAO,CAAC,EAAE,CAAC;gBACX,OAAO,GAAG,CAAC,CAAC;YACd,CAAC;QACH,CAAC;aAAM,CAAC;YACN,MAAM;QACR,CAAC;IACH,CAAC;IAED,0BAA0B;IAC1B,IAAI,OAAO,YAAY,KAAK,EAAE,CAAC;QAC7B,OAAO,OAAO,CAAC,OAAO,CAAC;IACzB,CAAC;IAED,+BAA+B;IAC/B,IAAI,OAAO,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;QAC3C,MAAM,MAAM,GAAG,OAAiD,CAAC;QACjE,IAAI,OAAO,MAAM,CAAC,OAAO,KAAK,QAAQ,EAAE,CAAC;YACvC,OAAO,MAAM,CA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cAAc,CAAC,CAAC;IAEpE,MAAM,SAAS,CAAC,UAAU,EAAE,cAAc,CAAC,UAAU,CAAC,CAAC;IAEvD,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,CAAC;IAErC,OAAO,aAAa,CAAC;QACnB,SAAS,EAAE,OAAO;QAClB,MAAM,EAAE,MAAM;QACd,QAAQ,EAAE,YAAY;QACtB,UAAU,EAAE,UAAU;QACtB,IAAI,EAAE,WAAW;QACjB,KAAK,EAAE,KAAK,CAAC,IAAI;KAClB,CAAC,CAAC;AACL,CAAC;AAED,eAAe,iBAAiB,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export { transformersProvider } from './transformers/index.js';
|
|
|
3
3
|
export { falProvider } from './fal/index.js';
|
|
4
4
|
export { replicateProvider } from './replicate/index.js';
|
|
5
5
|
export { runpodProvider } from './runpod/index.js';
|
|
6
|
+
export { aiGatewayProvider } from './ai-gateway/index.js';
|
|
6
7
|
/**
|
|
7
8
|
* All available providers
|
|
8
9
|
*/
|
|
@@ -12,6 +13,7 @@ export declare const providers: {
|
|
|
12
13
|
fal: import("@agent-media/core").MediaProvider;
|
|
13
14
|
replicate: import("@agent-media/core").MediaProvider;
|
|
14
15
|
runpod: import("@agent-media/core").MediaProvider;
|
|
16
|
+
'ai-gateway': import("@agent-media/core").MediaProvider;
|
|
15
17
|
};
|
|
16
18
|
/**
|
|
17
19
|
* Register all providers with the global registry
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE1D;;GAEG;AACH,eAAO,MAAM,SAAS;;;;;;;CAOrB,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,oBAAoB,IAAI,IAAI,CAO3C;AAED;;GAEG;AACH,wBAAgB,qBAAqB,IAAI,IAAI,CAE5C"}
|
package/dist/index.js
CHANGED
|
@@ -4,12 +4,14 @@ import { transformersProvider } from './transformers/index.js';
|
|
|
4
4
|
import { falProvider } from './fal/index.js';
|
|
5
5
|
import { replicateProvider } from './replicate/index.js';
|
|
6
6
|
import { runpodProvider } from './runpod/index.js';
|
|
7
|
+
import { aiGatewayProvider } from './ai-gateway/index.js';
|
|
7
8
|
// Export individual providers
|
|
8
9
|
export { localProvider } from './local/index.js';
|
|
9
10
|
export { transformersProvider } from './transformers/index.js';
|
|
10
11
|
export { falProvider } from './fal/index.js';
|
|
11
12
|
export { replicateProvider } from './replicate/index.js';
|
|
12
13
|
export { runpodProvider } from './runpod/index.js';
|
|
14
|
+
export { aiGatewayProvider } from './ai-gateway/index.js';
|
|
13
15
|
/**
|
|
14
16
|
* All available providers
|
|
15
17
|
*/
|
|
@@ -19,6 +21,7 @@ export const providers = {
|
|
|
19
21
|
fal: falProvider,
|
|
20
22
|
replicate: replicateProvider,
|
|
21
23
|
runpod: runpodProvider,
|
|
24
|
+
'ai-gateway': aiGatewayProvider,
|
|
22
25
|
};
|
|
23
26
|
/**
|
|
24
27
|
* Register all providers with the global registry
|
|
@@ -31,6 +34,7 @@ export function registerAllProviders() {
|
|
|
31
34
|
globalRegistry.register(falProvider);
|
|
32
35
|
globalRegistry.register(replicateProvider);
|
|
33
36
|
globalRegistry.register(runpodProvider);
|
|
37
|
+
globalRegistry.register(aiGatewayProvider);
|
|
34
38
|
}
|
|
35
39
|
/**
|
|
36
40
|
* Register only the local provider (for minimal setup)
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE1D,8BAA8B;AAC9B,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE1D;;GAEG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,KAAK,EAAE,aAAa;IACpB,YAAY,EAAE,oBAAoB;IAClC,GAAG,EAAE,WAAW;IAChB,SAAS,EAAE,iBAAiB;IAC5B,MAAM,EAAE,cAAc;IACtB,YAAY,EAAE,iBAAiB;CAChC,CAAC;AAEF;;;;GAIG;AACH,MAAM,UAAU,oBAAoB;IAClC,cAAc,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC;IACvC,cAAc,CAAC,QAAQ,CAAC,oBAAoB,CAAC,CAAC;IAC9C,cAAc,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;IACrC,cAAc,CAAC,QAAQ,CAAC,iBAAiB,CAAC,CAAC;IAC3C,cAAc,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC;IACxC,cAAc,CAAC,QAAQ,CAAC,iBAAiB,CAAC,CAAC;AAC7C,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,qBAAqB;IACnC,cAAc,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC;AACzC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agent-media/providers",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "Media providers for agent-media toolkit",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -35,6 +35,10 @@
|
|
|
35
35
|
"./transformers": {
|
|
36
36
|
"types": "./dist/transformers/index.d.ts",
|
|
37
37
|
"import": "./dist/transformers/index.js"
|
|
38
|
+
},
|
|
39
|
+
"./ai-gateway": {
|
|
40
|
+
"types": "./dist/ai-gateway/index.d.ts",
|
|
41
|
+
"import": "./dist/ai-gateway/index.js"
|
|
38
42
|
}
|
|
39
43
|
},
|
|
40
44
|
"files": [
|
|
@@ -49,7 +53,7 @@
|
|
|
49
53
|
"ai": "^6.0.33",
|
|
50
54
|
"replicate": "^1.1.1",
|
|
51
55
|
"sharp": "^0.34.1",
|
|
52
|
-
"@agent-media/core": "0.
|
|
56
|
+
"@agent-media/core": "0.7.0"
|
|
53
57
|
},
|
|
54
58
|
"devDependencies": {
|
|
55
59
|
"@types/node": "^22.0.0",
|