@framers/agentos-ext-image-generation 1.0.1 → 1.0.2

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/LICENSE CHANGED
@@ -1,23 +1,98 @@
1
- MIT License
2
-
3
- Copyright (c) 2025 Framers
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
10
+
11
+ "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
12
+
13
+ "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
14
+
15
+ "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
16
+
17
+ "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
18
+
19
+ "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
20
+
21
+ "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
22
+
23
+ "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
24
+
25
+ "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
26
+
27
+ "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
28
+
29
+ 2. Grant of Copyright License.
30
+
31
+ Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
32
+
33
+ 3. Grant of Patent License.
34
+
35
+ Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
36
+
37
+ 4. Redistribution.
38
+
39
+ You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
40
+
41
+ (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and
42
+
43
+ (b) You must cause any modified files to carry prominent notices stating that You changed the files; and
44
+
45
+ (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
46
+
47
+ (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
48
+
49
+ You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
50
+
51
+ 5. Submission of Contributions.
52
+
53
+ Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
54
+
55
+ 6. Trademarks.
56
+
57
+ This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
58
+
59
+ 7. Disclaimer of Warranty.
60
+
61
+ Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
62
+
63
+ 8. Limitation of Liability.
64
+
65
+ In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
66
+
67
+ 9. Accepting Warranty or Additional Liability.
68
+
69
+ While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
70
+
71
+ END OF TERMS AND CONDITIONS
72
+
73
+ APPENDIX: How to apply the Apache License to your work.
74
+
75
+ To apply the Apache License to your work, attach the following
76
+ boilerplate notice, with the fields enclosed by brackets "[]"
77
+ replaced with your own identifying information. (Don't include
78
+ the brackets!) The text should be enclosed in the appropriate
79
+ comment syntax for the file format. We also recommend that a
80
+ file or class name and description of purpose be included on the
81
+ same "printed page" as the copyright notice for easier
82
+ identification within third-party archives.
83
+
84
+ Copyright (c) 2025 Framers
85
+
86
+ Licensed under the Apache License, Version 2.0 (the "License");
87
+ you may not use this file except in compliance with the License.
88
+ You may obtain a copy of the License at
89
+
90
+ http://www.apache.org/licenses/LICENSE-2.0
91
+
92
+ Unless required by applicable law or agreed to in writing, software
93
+ distributed under the License is distributed on an "AS IS" BASIS,
94
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
95
+ See the License for the specific language governing permissions and
96
+ limitations under the License.
22
97
 
23
98
 
@@ -0,0 +1,55 @@
1
+ /**
2
+ * @fileoverview Image generation service backed by AgentOS's shared
3
+ * provider-agnostic image API.
4
+ */
5
+ import { type ImageProviderOptionBag } from '@framers/agentos';
6
+ export type ImageGenerationProvider = 'openai' | 'openrouter' | 'stability' | 'replicate';
7
+ export interface ImageGenerationConfig {
8
+ openaiApiKey?: string;
9
+ openrouterApiKey?: string;
10
+ stabilityApiKey?: string;
11
+ replicateApiToken?: string;
12
+ defaultProvider?: ImageGenerationProvider;
13
+ defaultModel?: string;
14
+ defaultSize?: string;
15
+ defaultQuality?: 'standard' | 'hd';
16
+ }
17
+ export interface GenerateImageOptions {
18
+ prompt: string;
19
+ size?: '1024x1024' | '1792x1024' | '1024x1792' | '512x512' | '256x256';
20
+ aspectRatio?: string;
21
+ quality?: 'standard' | 'hd';
22
+ style?: 'vivid' | 'natural';
23
+ n?: number;
24
+ provider?: ImageGenerationProvider;
25
+ model?: string;
26
+ seed?: number;
27
+ negativePrompt?: string;
28
+ providerOptions?: ImageProviderOptionBag | Record<string, unknown>;
29
+ }
30
+ export interface GeneratedImage {
31
+ url: string;
32
+ revisedPrompt?: string;
33
+ provider: string;
34
+ model: string;
35
+ size: string;
36
+ }
37
+ export declare class ImageGenerationService {
38
+ private readonly config;
39
+ private initialized;
40
+ constructor(config: ImageGenerationConfig);
41
+ get hasOpenAI(): boolean;
42
+ get hasOpenRouter(): boolean;
43
+ get hasStability(): boolean;
44
+ get hasReplicate(): boolean;
45
+ get hasAnyProvider(): boolean;
46
+ initialize(): Promise<void>;
47
+ generateImage(options: GenerateImageOptions): Promise<GeneratedImage>;
48
+ shutdown(): Promise<void>;
49
+ private resolveProvider;
50
+ private getApiKey;
51
+ private defaultModelForProvider;
52
+ private displayNameForProvider;
53
+ private normalizeProviderOptions;
54
+ }
55
+ //# sourceMappingURL=ImageGenerationService.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ImageGenerationService.d.ts","sourceRoot":"","sources":["../src/ImageGenerationService.ts"],"names":[],"mappings":"AACA;;;GAGG;AAEH,OAAO,EAAiB,KAAK,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAE9E,MAAM,MAAM,uBAAuB,GAAG,QAAQ,GAAG,YAAY,GAAG,WAAW,GAAG,WAAW,CAAC;AAE1F,MAAM,WAAW,qBAAqB;IACpC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,eAAe,CAAC,EAAE,uBAAuB,CAAC;IAC1C,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,UAAU,GAAG,IAAI,CAAC;CACpC;AAED,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,WAAW,GAAG,WAAW,GAAG,WAAW,GAAG,SAAS,GAAG,SAAS,CAAC;IACvE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,UAAU,GAAG,IAAI,CAAC;IAC5B,KAAK,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAC5B,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,QAAQ,CAAC,EAAE,uBAAuB,CAAC;IACnC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,eAAe,CAAC,EAAE,sBAAsB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpE;AAED,MAAM,WAAW,cAAc;IAC7B,GAAG,EAAE,MAAM,CAAC;IACZ,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;CACd;AASD,qBAAa,sBAAsB;IACjC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAwB;IAC/C,OAAO,CAAC,WAAW,CAAS;gBAEhB,MAAM,EAAE,qBAAqB;IAIzC,IAAI,SAAS,IAAI,OAAO,CAEvB;IAED,IAAI,aAAa,IAAI,OAAO,CAE3B;IAED,IAAI,YAAY,IAAI,OAAO,CAE1B;IAED,IAAI,YAAY,IAAI,OAAO,CAE1B;IAED,IAAI,cAAc,IAAI,OAAO,CAE5B;IAEK,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAI3B,aAAa,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,cAAc,CAAC;IA+CrE,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAI/B,OAAO,CAAC,eAAe;IAcvB,OAAO,CAAC,SAAS;IAejB,OAAO,CAAC,uBAAuB;IAe/B,OAAO,CAAC,sBAAsB;IAe9B,OAAO,CAAC,wBAAwB;CAoCjC"}
@@ -0,0 +1,171 @@
1
+ "use strict";
2
+ // @ts-nocheck
3
+ /**
4
+ * @fileoverview Image generation service backed by AgentOS's shared
5
+ * provider-agnostic image API.
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.ImageGenerationService = void 0;
9
+ const agentos_1 = require("@framers/agentos");
10
+ const PROVIDER_DOCS_URL = {
11
+ openai: 'https://platform.openai.com/api-keys',
12
+ openrouter: 'https://openrouter.ai/settings/keys',
13
+ stability: 'https://platform.stability.ai/account/keys',
14
+ replicate: 'https://replicate.com/account/api-tokens',
15
+ };
16
+ class ImageGenerationService {
17
+ constructor(config) {
18
+ this.initialized = false;
19
+ this.config = config;
20
+ }
21
+ get hasOpenAI() {
22
+ return !!this.config.openaiApiKey;
23
+ }
24
+ get hasOpenRouter() {
25
+ return !!this.config.openrouterApiKey;
26
+ }
27
+ get hasStability() {
28
+ return !!this.config.stabilityApiKey;
29
+ }
30
+ get hasReplicate() {
31
+ return !!this.config.replicateApiToken;
32
+ }
33
+ get hasAnyProvider() {
34
+ return this.hasOpenAI || this.hasOpenRouter || this.hasStability || this.hasReplicate;
35
+ }
36
+ async initialize() {
37
+ this.initialized = true;
38
+ }
39
+ async generateImage(options) {
40
+ const provider = this.resolveProvider(options.provider);
41
+ const apiKey = this.getApiKey(provider);
42
+ if (!apiKey) {
43
+ const envVar = provider === 'replicate' ? 'REPLICATE_API_TOKEN' : `${provider.toUpperCase()}_API_KEY`;
44
+ throw new Error(`${envVar} is required for ${this.displayNameForProvider(provider)} image generation. `
45
+ + `Set it in your environment or .env file. Get one at ${PROVIDER_DOCS_URL[provider]}`);
46
+ }
47
+ const providerOptions = this.normalizeProviderOptions(provider, options);
48
+ const model = options.model || this.config.defaultModel || this.defaultModelForProvider(provider);
49
+ const result = await (0, agentos_1.generateImage)({
50
+ model: `${provider}:${model}`,
51
+ prompt: options.prompt,
52
+ apiKey,
53
+ size: options.size || this.config.defaultSize || '1024x1024',
54
+ aspectRatio: options.aspectRatio,
55
+ quality: options.quality || this.config.defaultQuality || 'standard',
56
+ n: options.n,
57
+ seed: options.seed,
58
+ negativePrompt: options.negativePrompt,
59
+ providerOptions,
60
+ });
61
+ const first = result.images[0];
62
+ if (!first) {
63
+ throw new Error('Image generation returned no images.');
64
+ }
65
+ const url = first.url || first.dataUrl || (first.base64
66
+ ? `data:${first.mimeType || 'image/png'};base64,${first.base64}`
67
+ : undefined);
68
+ if (!url) {
69
+ throw new Error('Image generation returned no image URL or image data.');
70
+ }
71
+ return {
72
+ url,
73
+ revisedPrompt: first.revisedPrompt,
74
+ provider: result.provider,
75
+ model: result.model,
76
+ size: options.size || this.config.defaultSize || '1024x1024',
77
+ };
78
+ }
79
+ async shutdown() {
80
+ this.initialized = false;
81
+ }
82
+ resolveProvider(provider) {
83
+ if (provider) {
84
+ return provider;
85
+ }
86
+ if (this.config.defaultProvider) {
87
+ return this.config.defaultProvider;
88
+ }
89
+ if (this.hasOpenAI)
90
+ return 'openai';
91
+ if (this.hasOpenRouter)
92
+ return 'openrouter';
93
+ if (this.hasStability)
94
+ return 'stability';
95
+ if (this.hasReplicate)
96
+ return 'replicate';
97
+ return 'openai';
98
+ }
99
+ getApiKey(provider) {
100
+ switch (provider) {
101
+ case 'openai':
102
+ return this.config.openaiApiKey;
103
+ case 'openrouter':
104
+ return this.config.openrouterApiKey;
105
+ case 'stability':
106
+ return this.config.stabilityApiKey;
107
+ case 'replicate':
108
+ return this.config.replicateApiToken;
109
+ default:
110
+ return undefined;
111
+ }
112
+ }
113
+ defaultModelForProvider(provider) {
114
+ switch (provider) {
115
+ case 'openai':
116
+ return 'dall-e-3';
117
+ case 'openrouter':
118
+ return 'google/gemini-2.5-flash-image';
119
+ case 'stability':
120
+ return 'stable-image-core';
121
+ case 'replicate':
122
+ return 'black-forest-labs/flux-schnell';
123
+ default:
124
+ return 'gpt-image-1';
125
+ }
126
+ }
127
+ displayNameForProvider(provider) {
128
+ switch (provider) {
129
+ case 'openai':
130
+ return 'OpenAI';
131
+ case 'openrouter':
132
+ return 'OpenRouter';
133
+ case 'stability':
134
+ return 'Stability AI';
135
+ case 'replicate':
136
+ return 'Replicate';
137
+ default:
138
+ return provider;
139
+ }
140
+ }
141
+ normalizeProviderOptions(provider, options) {
142
+ if (!options.providerOptions && !options.style && provider !== 'openai') {
143
+ return undefined;
144
+ }
145
+ const providerOptions = options.providerOptions && typeof options.providerOptions === 'object' && !Array.isArray(options.providerOptions)
146
+ ? { ...options.providerOptions }
147
+ : undefined;
148
+ if (provider === 'openai' && options.style) {
149
+ const openAIOptions = {
150
+ ...(providerOptions?.openai ?? {}),
151
+ style: options.style,
152
+ };
153
+ return {
154
+ ...(providerOptions ?? {}),
155
+ openai: openAIOptions,
156
+ };
157
+ }
158
+ if (provider === 'openai') {
159
+ return {
160
+ ...(providerOptions ?? {}),
161
+ openai: {
162
+ ...(providerOptions?.openai ?? {}),
163
+ style: options.style ?? providerOptions?.openai?.style ?? 'vivid',
164
+ },
165
+ };
166
+ }
167
+ return providerOptions;
168
+ }
169
+ }
170
+ exports.ImageGenerationService = ImageGenerationService;
171
+ //# sourceMappingURL=ImageGenerationService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ImageGenerationService.js","sourceRoot":"","sources":["../src/ImageGenerationService.ts"],"names":[],"mappings":";AAAA,cAAc;AACd;;;GAGG;;;AAEH,8CAA8E;AAqC9E,MAAM,iBAAiB,GAA4C;IACjE,MAAM,EAAE,sCAAsC;IAC9C,UAAU,EAAE,qCAAqC;IACjD,SAAS,EAAE,4CAA4C;IACvD,SAAS,EAAE,0CAA0C;CACtD,CAAC;AAEF,MAAa,sBAAsB;IAIjC,YAAY,MAA6B;QAFjC,gBAAW,GAAG,KAAK,CAAC;QAG1B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED,IAAI,SAAS;QACX,OAAO,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC;IACpC,CAAC;IAED,IAAI,aAAa;QACf,OAAO,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC;IACxC,CAAC;IAED,IAAI,YAAY;QACd,OAAO,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC;IACvC,CAAC;IAED,IAAI,YAAY;QACd,OAAO,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC;IACzC,CAAC;IAED,IAAI,cAAc;QAChB,OAAO,IAAI,CAAC,SAAS,IAAI,IAAI,CAAC,aAAa,IAAI,IAAI,CAAC,YAAY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AK,QAAQ,EAAE,CAAC;YACxE,OAAO,SAAS,CAAC;QACnB,CAAC;QAED,MAAM,eAAe,GACnB,OAAO,CAAC,eAAe,IAAI,OAAO,OAAO,CAAC,eAAe,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,eAAe,CAAC;YAC/G,CAAC,CAAC,EAAE,GAAG,OAAO,CAAC,eAAe,EAAE;YAChC,CAAC,CAAC,SAAS,CAAC;QAEhB,IAAI,QAAQ,KAAK,QAAQ,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;YAC3C,MAAM,aAAa,GAAG;gBACpB,GAAG,CAAC,eAAe,EAAE,MAAM,IAAI,EAAE,CAAC;gBAClC,KAAK,EAAE,OAAO,CAAC,KAAK;aACrB,CAAC;YACF,OAAO;gBACL,GAAG,CAAC,eAAe,IAAI,EAAE,CAAC;gBAC1B,MAAM,EAAE,aAAa;aACtB,CAAC;QACJ,CAAC;QAED,IAAI,QAAQ,KAAK,QAAQ,EAAE,CAAC;YAC1B,OAAO;gBACL,GAAG,CAAC,eAAe,IAAI,EAAE,CAAC;gBAC1B,MAAM,EAAE;oBACN,GAAG,CAAC,eAAe,EAAE,MAAM,IAAI,EAAE,CAAC;oBAClC,KAAK,EAAE,OAAO,CAAC,KAAK,IAAI,eAAe,EAAE,MAAM,EAAE,KAAK,IAAI,OAAO;iBAClE;aACF,CAAC;QACJ,CAAC;QAED,OAAO,eAAe,CAAC;IACzB,CAAC;CACF;AAlLD,wDAkLC"}
@@ -0,0 +1,17 @@
1
+ import type { ExtensionPackContext, ExtensionPack } from '@framers/agentos';
2
+ export interface ImageGenerationOptions {
3
+ openaiApiKey?: string;
4
+ openrouterApiKey?: string;
5
+ stabilityApiKey?: string;
6
+ replicateApiToken?: string;
7
+ defaultProvider?: 'openai' | 'openrouter' | 'stability' | 'replicate';
8
+ defaultModel?: string;
9
+ defaultSize?: string;
10
+ defaultQuality?: 'standard' | 'hd';
11
+ priority?: number;
12
+ }
13
+ export declare function createExtensionPack(context: ExtensionPackContext): ExtensionPack;
14
+ export { ImageGenerationService } from './ImageGenerationService.js';
15
+ export { GenerateImageTool } from './tools/generateImage.js';
16
+ export default createExtensionPack;
17
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,oBAAoB,EACpB,aAAa,EAEd,MAAM,kBAAkB,CAAC;AAK1B,MAAM,WAAW,sBAAsB;IACrC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,eAAe,CAAC,EAAE,QAAQ,GAAG,YAAY,GAAG,WAAW,GAAG,WAAW,CAAC;IACtE,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,UAAU,GAAG,IAAI,CAAC;IACnC,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,oBAAoB,GAAG,aAAa,CAsEhF;AAED,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,eAAe,mBAAmB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,76 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GenerateImageTool = exports.ImageGenerationService = void 0;
4
+ exports.createExtensionPack = createExtensionPack;
5
+ const ImageGenerationService_js_1 = require("./ImageGenerationService.js");
6
+ const generateImage_js_1 = require("./tools/generateImage.js");
7
+ function createExtensionPack(context) {
8
+ const options = (context.options ?? {});
9
+ const openaiApiKey = options.openaiApiKey ||
10
+ context.getSecret?.('openai.apiKey') ||
11
+ process.env.OPENAI_API_KEY;
12
+ const openrouterApiKey = options.openrouterApiKey ||
13
+ context.getSecret?.('openrouter.apiKey') ||
14
+ process.env.OPENROUTER_API_KEY;
15
+ const stabilityApiKey = options.stabilityApiKey ||
16
+ context.getSecret?.('stability.apiKey') ||
17
+ process.env.STABILITY_API_KEY;
18
+ const replicateApiToken = options.replicateApiToken ||
19
+ context.getSecret?.('replicate.apiToken') ||
20
+ process.env.REPLICATE_API_TOKEN;
21
+ const service = new ImageGenerationService_js_1.ImageGenerationService({
22
+ openaiApiKey,
23
+ openrouterApiKey,
24
+ stabilityApiKey,
25
+ replicateApiToken,
26
+ defaultProvider: options.defaultProvider,
27
+ defaultModel: options.defaultModel,
28
+ defaultSize: options.defaultSize,
29
+ defaultQuality: options.defaultQuality,
30
+ });
31
+ const tool = new generateImage_js_1.GenerateImageTool(service);
32
+ return {
33
+ name: '@framers/agentos-ext-image-generation',
34
+ version: '1.0.0',
35
+ descriptors: [
36
+ {
37
+ id: tool.name,
38
+ kind: 'tool',
39
+ priority: options.priority ?? 50,
40
+ payload: tool,
41
+ requiredSecrets: [
42
+ { id: 'openai.apiKey', optional: true },
43
+ { id: 'openrouter.apiKey', optional: true },
44
+ { id: 'stability.apiKey', optional: true },
45
+ { id: 'replicate.apiToken', optional: true },
46
+ ],
47
+ },
48
+ ],
49
+ onActivate: async (lc) => {
50
+ await service.initialize();
51
+ const providers = [];
52
+ if (service.hasOpenAI)
53
+ providers.push('OpenAI');
54
+ if (service.hasOpenRouter)
55
+ providers.push('OpenRouter');
56
+ if (service.hasStability)
57
+ providers.push('Stability AI');
58
+ if (service.hasReplicate)
59
+ providers.push('Replicate');
60
+ const status = providers.length > 0
61
+ ? providers.join(' + ')
62
+ : 'no API keys configured (set OPENAI_API_KEY, OPENROUTER_API_KEY, STABILITY_API_KEY, or REPLICATE_API_TOKEN)';
63
+ lc?.logger?.info(`Image Generation Extension activated — ${status}`);
64
+ },
65
+ onDeactivate: async (lc) => {
66
+ await service.shutdown();
67
+ lc?.logger?.info('Image Generation Extension deactivated');
68
+ },
69
+ };
70
+ }
71
+ var ImageGenerationService_js_2 = require("./ImageGenerationService.js");
72
+ Object.defineProperty(exports, "ImageGenerationService", { enumerable: true, get: function () { return ImageGenerationService_js_2.ImageGenerationService; } });
73
+ var generateImage_js_2 = require("./tools/generateImage.js");
74
+ Object.defineProperty(exports, "GenerateImageTool", { enumerable: true, get: function () { return generateImage_js_2.GenerateImageTool; } });
75
+ exports.default = createExtensionPack;
76
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAsBA,kDAsEC;AArFD,2EAAqE;AACrE,+DAA6D;AAc7D,SAAgB,mBAAmB,CAAC,OAA6B;IAC/D,MAAM,OAAO,GAAG,CAAC,OAAO,CAAC,OAAO,IAAI,EAAE,CAA2B,CAAC;IAElE,MAAM,YAAY,GAChB,OAAO,CAAC,YAAY;QACpB,OAAO,CAAC,SAAS,EAAE,CAAC,eAAe,CAAC;QACpC,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC;IAE7B,MAAM,gBAAgB,GACpB,OAAO,CAAC,gBAAgB;QACxB,OAAO,CAAC,SAAS,EAAE,CAAC,mBAAmB,CAAC;QACxC,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC;IAEjC,MAAM,eAAe,GACnB,OAAO,CAAC,eAAe;QACvB,OAAO,CAAC,SAAS,EAAE,CAAC,kBAAkB,CAAC;QACvC,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC;IAEhC,MAAM,iBAAiB,GACrB,OAAO,CAAC,iBAAiB;QACzB,OAAO,CAAC,SAAS,EAAE,CAAC,oBAAoB,CAAC;QACzC,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC;IAElC,MAAM,OAAO,GAAG,IAAI,kDAAsB,CAAC;QACzC,YAAY;QACZ,gBAAgB;QAChB,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G,SAAS,CAAC,MAAM,GAAG,CAAC;gBACjC,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC;gBACvB,CAAC,CAAC,4GAA4G,CAAC;YACjH,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,0CAA0C,MAAM,EAAE,CAAC,CAAC;QACvE,CAAC;QACD,YAAY,EAAE,KAAK,EAAE,EAA8B,EAAE,EAAE;YACrD,MAAM,OAAO,CAAC,QAAQ,EAAE,CAAC;YACzB,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,wCAAwC,CAAC,CAAC;QAC7D,CAAC;KACF,CAAC;AACJ,CAAC;AAED,yEAAqE;AAA5D,mIAAA,sBAAsB,OAAA;AAC/B,6DAA6D;AAApD,qHAAA,iBAAiB,OAAA;AAC1B,kBAAe,mBAAmB,CAAC"}
@@ -0,0 +1,37 @@
1
+ /**
2
+ * @fileoverview Image generation tool — generates images from text prompts
3
+ * using the configured image provider stack.
4
+ */
5
+ import type { ITool, JSONSchemaObject, ToolExecutionContext, ToolExecutionResult } from '@framers/agentos';
6
+ import type { ImageGenerationService } from '../ImageGenerationService.js';
7
+ export interface GenerateImageInput {
8
+ prompt: string;
9
+ size?: '1024x1024' | '1792x1024' | '1024x1792';
10
+ aspectRatio?: string;
11
+ quality?: 'standard' | 'hd';
12
+ style?: 'vivid' | 'natural';
13
+ provider?: 'openai' | 'openrouter' | 'stability' | 'replicate';
14
+ model?: string;
15
+ seed?: number;
16
+ negativePrompt?: string;
17
+ }
18
+ export interface GenerateImageOutput {
19
+ url: string;
20
+ revisedPrompt?: string;
21
+ provider: string;
22
+ model: string;
23
+ size: string;
24
+ }
25
+ export declare class GenerateImageTool implements ITool<GenerateImageInput, GenerateImageOutput> {
26
+ readonly id = "tool.generate_image";
27
+ readonly name = "generate_image";
28
+ readonly displayName = "Generate Image";
29
+ readonly description = "Generate an image from a text prompt using the configured image providers. Returns a URL or data URL to the generated image.";
30
+ readonly category = "media";
31
+ readonly hasSideEffects = false;
32
+ readonly inputSchema: JSONSchemaObject;
33
+ private service;
34
+ constructor(service: ImageGenerationService);
35
+ execute(args: GenerateImageInput, _context?: ToolExecutionContext): Promise<ToolExecutionResult<GenerateImageOutput>>;
36
+ }
37
+ //# sourceMappingURL=generateImage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generateImage.d.ts","sourceRoot":"","sources":["../../src/tools/generateImage.ts"],"names":[],"mappings":"AACA;;;GAGG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAC3G,OAAO,KAAK,EAAE,sBAAsB,EAAwB,MAAM,8BAA8B,CAAC;AAEjG,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,WAAW,GAAG,WAAW,GAAG,WAAW,CAAC;IAC/C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,UAAU,GAAG,IAAI,CAAC;IAC5B,KAAK,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAC5B,QAAQ,CAAC,EAAE,QAAQ,GAAG,YAAY,GAAG,WAAW,GAAG,WAAW,CAAC;IAC/D,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,mBAAmB;IAClC,GAAG,EAAE,MAAM,CAAC;IACZ,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;CACd;AAED,qBAAa,iBAAkB,YAAW,KAAK,CAAC,kBAAkB,EAAE,mBAAmB,CAAC;IACtF,QAAQ,CAAC,EAAE,yBAAyB;IACpC,QAAQ,CAAC,IAAI,oBAAoB;IACjC,QAAQ,CAAC,WAAW,oBAAoB;IACxC,QAAQ,CAAC,WAAW,kIAAkI;IACtJ,QAAQ,CAAC,QAAQ,WAAW;IAC5B,QAAQ,CAAC,cAAc,SAAS;IAEhC,QAAQ,CAAC,WAAW,EAAE,gBAAgB,CA6CpC;IAEF,OAAO,CAAC,OAAO,CAAyB;gBAE5B,OAAO,EAAE,sBAAsB;IAIrC,OAAO,CACX,IAAI,EAAE,kBAAkB,EACxB,QAAQ,CAAC,EAAE,oBAAoB,GAC9B,OAAO,CAAC,mBAAmB,CAAC,mBAAmB,CAAC,CAAC;CA8BrD"}
@@ -0,0 +1,97 @@
1
+ "use strict";
2
+ // @ts-nocheck
3
+ /**
4
+ * @fileoverview Image generation tool — generates images from text prompts
5
+ * using the configured image provider stack.
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.GenerateImageTool = void 0;
9
+ class GenerateImageTool {
10
+ constructor(service) {
11
+ this.id = 'tool.generate_image';
12
+ this.name = 'generate_image';
13
+ this.displayName = 'Generate Image';
14
+ this.description = 'Generate an image from a text prompt using the configured image providers. Returns a URL or data URL to the generated image.';
15
+ this.category = 'media';
16
+ this.hasSideEffects = false;
17
+ this.inputSchema = {
18
+ type: 'object',
19
+ properties: {
20
+ prompt: {
21
+ type: 'string',
22
+ description: 'Detailed text description of the image to generate. Be specific about style, subject, composition, lighting, and mood.',
23
+ },
24
+ size: {
25
+ type: 'string',
26
+ enum: ['1024x1024', '1792x1024', '1024x1792'],
27
+ description: 'Image dimensions. 1024x1024 (square, default), 1792x1024 (landscape), 1024x1792 (portrait).',
28
+ },
29
+ aspectRatio: {
30
+ type: 'string',
31
+ description: 'Optional aspect ratio hint for providers that support it, such as 1:1, 16:9, or 9:16.',
32
+ },
33
+ quality: {
34
+ type: 'string',
35
+ enum: ['standard', 'hd'],
36
+ description: 'Image quality. "hd" produces higher detail but costs more.',
37
+ },
38
+ style: {
39
+ type: 'string',
40
+ enum: ['vivid', 'natural'],
41
+ description: 'Style preset. "vivid" (default) for hyper-real/dramatic, "natural" for more realistic.',
42
+ },
43
+ provider: {
44
+ type: 'string',
45
+ enum: ['openai', 'openrouter', 'stability', 'replicate'],
46
+ description: 'Which AI provider to use. If omitted, the extension uses its configured default provider.',
47
+ },
48
+ model: {
49
+ type: 'string',
50
+ description: 'Optional provider-native model id, for example gpt-image-1, stable-image-core, or black-forest-labs/flux-schnell.',
51
+ },
52
+ seed: {
53
+ type: 'number',
54
+ description: 'Optional seed for providers that support reproducible image generation.',
55
+ },
56
+ negativePrompt: {
57
+ type: 'string',
58
+ description: 'Optional negative prompt for providers that support excluding specific traits or artifacts.',
59
+ },
60
+ },
61
+ required: ['prompt'],
62
+ };
63
+ this.service = service;
64
+ }
65
+ async execute(args, _context) {
66
+ try {
67
+ const result = await this.service.generateImage(args);
68
+ return {
69
+ success: true,
70
+ output: {
71
+ url: result.url,
72
+ revisedPrompt: result.revisedPrompt,
73
+ provider: result.provider,
74
+ model: result.model,
75
+ size: result.size,
76
+ },
77
+ details: {
78
+ displayText: result.revisedPrompt
79
+ ? `Image generated (${result.model}): ${result.url}\nRevised prompt: ${result.revisedPrompt}`
80
+ : `Image generated (${result.model}): ${result.url}`,
81
+ },
82
+ };
83
+ }
84
+ catch (error) {
85
+ const message = error instanceof Error ? error.message : String(error);
86
+ return {
87
+ success: false,
88
+ error: message,
89
+ details: message.includes('API_KEY')
90
+ ? { apiKeyGuidance: message }
91
+ : undefined,
92
+ };
93
+ }
94
+ }
95
+ }
96
+ exports.GenerateImageTool = GenerateImageTool;
97
+ //# sourceMappingURL=generateImage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generateImage.js","sourceRoot":"","sources":["../../src/tools/generateImage.ts"],"names":[],"mappings":";AAAA,cAAc;AACd;;;GAGG;;;AAyBH,MAAa,iBAAiB;IAyD5B,YAAY,OAA+B;QAxDlC,OAAE,GAAG,qBAAqB,CAAC;QAC3B,SAAI,GAAG,gBAAgB,CAAC;QACxB,gBAAW,GAAG,gBAAgB,CAAC;Q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X,IAAwB,EACxB,QAA+B;QAE/B,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,IAA4B,CAAC,CAAC;YAE9E,OAAO;gBACL,OAAO,EAAE,IAAI;gBACb,MAAM,EAAE;oBACN,GAAG,EAAE,MAAM,CAAC,GAAG;oBACf,aAAa,EAAE,MAAM,CAAC,aAAa;oBACnC,QAAQ,EAAE,MAAM,CAAC,QAAQ;oBACzB,KAAK,EAAE,MAAM,CAAC,KAAK;oBACnB,IAAI,EAAE,MAAM,CAAC,IAAI;iBAClB;gBACD,OAAO,EAAE;oBACP,WAAW,EAAE,MAAM,CAAC,aAAa;wBAC/B,CAAC,CAAC,oBAAoB,MAAM,CAAC,KAAK,MAAM,MAAM,CAAC,GAAG,qBAAqB,MAAM,CAAC,aAAa,EAAE;wBAC7F,CAAC,CAAC,oBAAoB,MAAM,CAAC,KAAK,MAAM,MAAM,CAAC,GAAG,EAAE;iBACvD;aACF,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YACvE,OAAO;gBACL,OAAO,EAAE,KAAK;gBACd,KAAK,EAAE,OAAO;gBACd,OAAO,EAAE,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC;oBAClC,CAAC,CAAC,EAAE,cAAc,EAAE,OAAO,EAAE;oBAC7B,CAAC,CAAC,SAAS;aACd,CAAC;QACJ,CAAC;IACH,CAAC;CACF;AA9FD,8CA8FC"}
package/manifest.json CHANGED
@@ -2,8 +2,8 @@
2
2
  "id": "com.framers.tools.image-generation",
3
3
  "name": "@framers/agentos-ext-image-generation",
4
4
  "displayName": "Image Generation",
5
- "version": "1.0.0",
6
- "description": "Generate images from text prompts using DALL-E 3 or Stability AI.",
5
+ "version": "1.0.2",
6
+ "description": "Generate images from text prompts using OpenAI, OpenRouter, Stability AI, or Replicate.",
7
7
  "category": "tool",
8
8
  "author": "Framers AI",
9
9
  "license": "MIT",
@@ -13,17 +13,31 @@
13
13
  {
14
14
  "id": "openai.apiKey",
15
15
  "envVar": "OPENAI_API_KEY",
16
- "description": "OpenAI API key for DALL-E 3 image generation",
16
+ "description": "OpenAI API key for image generation",
17
17
  "optional": true,
18
18
  "docsUrl": "https://platform.openai.com/api-keys"
19
19
  },
20
+ {
21
+ "id": "openrouter.apiKey",
22
+ "envVar": "OPENROUTER_API_KEY",
23
+ "description": "OpenRouter API key for routed image generation models",
24
+ "optional": true,
25
+ "docsUrl": "https://openrouter.ai/settings/keys"
26
+ },
20
27
  {
21
28
  "id": "stability.apiKey",
22
29
  "envVar": "STABILITY_API_KEY",
23
- "description": "Stability AI API key for Stable Diffusion image generation",
30
+ "description": "Stability AI API key for Stable Image and Stable Diffusion generation",
24
31
  "optional": true,
25
32
  "docsUrl": "https://platform.stability.ai/account/keys"
33
+ },
34
+ {
35
+ "id": "replicate.apiToken",
36
+ "envVar": "REPLICATE_API_TOKEN",
37
+ "description": "Replicate API token for Flux and community image models",
38
+ "optional": true,
39
+ "docsUrl": "https://replicate.com/account/api-tokens"
26
40
  }
27
41
  ],
28
- "keywords": ["image", "generation", "dall-e", "stable-diffusion", "ai-art", "text-to-image"]
42
+ "keywords": ["image", "generation", "openai", "openrouter", "stable-diffusion", "replicate", "ai-art", "text-to-image"]
29
43
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@framers/agentos-ext-image-generation",
3
- "version": "1.0.1",
4
- "description": "Image generation extension for AgentOS — DALL-E 3 and Stability AI",
3
+ "version": "1.0.2",
4
+ "description": "Image generation extension for AgentOS — OpenAI, OpenRouter, Stability AI, and Replicate",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "files": [
@@ -13,7 +13,9 @@
13
13
  "extension",
14
14
  "image-generation",
15
15
  "openai",
16
- "stability"
16
+ "openrouter",
17
+ "stability",
18
+ "replicate"
17
19
  ],
18
20
  "author": {
19
21
  "name": "Framers AI",
@@ -21,10 +23,10 @@
21
23
  },
22
24
  "license": "MIT",
23
25
  "peerDependencies": {
24
- "@framers/agentos": "^0.1.0"
26
+ "@framers/agentos": "^0.10.28"
25
27
  },
26
28
  "dependencies": {
27
- "@framers/agentos": "0.1.47"
29
+ "@framers/agentos": "^0.10.28"
28
30
  },
29
31
  "devDependencies": {
30
32
  "@types/node": "^20.0.0",
@@ -36,13 +38,17 @@
36
38
  },
37
39
  "repository": {
38
40
  "type": "git",
39
- "url": "https://github.com/framersai/agentos-extensions",
41
+ "url": "git+https://github.com/framerslab/agentos-extensions.git",
40
42
  "directory": "registry/curated/tools/image-generation"
41
43
  },
44
+ "homepage": "https://github.com/framerslab/agentos-extensions/tree/master/registry/curated/tools/image-generation#readme",
45
+ "bugs": {
46
+ "url": "https://github.com/framerslab/agentos-extensions/issues"
47
+ },
42
48
  "scripts": {
43
49
  "build": "tsc",
44
50
  "dev": "tsc --watch",
45
- "test": "vitest run",
51
+ "test": "vitest run --passWithNoTests",
46
52
  "test:watch": "vitest watch",
47
53
  "clean": "rm -rf dist"
48
54
  }