openrouter-genimage-kote-opencode 0.1.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.
Files changed (163) hide show
  1. package/.opencode/skills/openrouter-image-generation/SKILL.md +379 -0
  2. package/CHANGELOG.md +10 -0
  3. package/LICENSE +21 -0
  4. package/README.md +229 -0
  5. package/README.ru.md +229 -0
  6. package/SECURITY.md +31 -0
  7. package/THIRD_PARTY_NOTICES.md +16 -0
  8. package/dist/cli.d.ts +20 -0
  9. package/dist/cli.d.ts.map +1 -0
  10. package/dist/cli.js +277 -0
  11. package/dist/cli.js.map +1 -0
  12. package/dist/commands/balance-command.d.ts +5 -0
  13. package/dist/commands/balance-command.d.ts.map +1 -0
  14. package/dist/commands/balance-command.js +20 -0
  15. package/dist/commands/balance-command.js.map +1 -0
  16. package/dist/config/resolve.d.ts +5 -0
  17. package/dist/config/resolve.d.ts.map +1 -0
  18. package/dist/config/resolve.js +113 -0
  19. package/dist/config/resolve.js.map +1 -0
  20. package/dist/config/schema.d.ts +188 -0
  21. package/dist/config/schema.d.ts.map +1 -0
  22. package/dist/config/schema.js +144 -0
  23. package/dist/config/schema.js.map +1 -0
  24. package/dist/config/types.d.ts +75 -0
  25. package/dist/config/types.d.ts.map +1 -0
  26. package/dist/config/types.js +30 -0
  27. package/dist/config/types.js.map +1 -0
  28. package/dist/logging.d.ts +46 -0
  29. package/dist/logging.d.ts.map +1 -0
  30. package/dist/logging.js +58 -0
  31. package/dist/logging.js.map +1 -0
  32. package/dist/openrouter/capabilities.d.ts +22 -0
  33. package/dist/openrouter/capabilities.d.ts.map +1 -0
  34. package/dist/openrouter/capabilities.js +137 -0
  35. package/dist/openrouter/capabilities.js.map +1 -0
  36. package/dist/openrouter/client.d.ts +54 -0
  37. package/dist/openrouter/client.d.ts.map +1 -0
  38. package/dist/openrouter/client.js +440 -0
  39. package/dist/openrouter/client.js.map +1 -0
  40. package/dist/openrouter/errors.d.ts +22 -0
  41. package/dist/openrouter/errors.d.ts.map +1 -0
  42. package/dist/openrouter/errors.js +75 -0
  43. package/dist/openrouter/errors.js.map +1 -0
  44. package/dist/openrouter/models.d.ts +37 -0
  45. package/dist/openrouter/models.d.ts.map +1 -0
  46. package/dist/openrouter/models.js +113 -0
  47. package/dist/openrouter/models.js.map +1 -0
  48. package/dist/openrouter/requests.d.ts +6 -0
  49. package/dist/openrouter/requests.d.ts.map +1 -0
  50. package/dist/openrouter/requests.js +74 -0
  51. package/dist/openrouter/requests.js.map +1 -0
  52. package/dist/openrouter/schemas.d.ts +37 -0
  53. package/dist/openrouter/schemas.d.ts.map +1 -0
  54. package/dist/openrouter/schemas.js +2 -0
  55. package/dist/openrouter/schemas.js.map +1 -0
  56. package/dist/output/attachments.d.ts +10 -0
  57. package/dist/output/attachments.d.ts.map +1 -0
  58. package/dist/output/attachments.js +13 -0
  59. package/dist/output/attachments.js.map +1 -0
  60. package/dist/output/formats.d.ts +42 -0
  61. package/dist/output/formats.d.ts.map +1 -0
  62. package/dist/output/formats.js +126 -0
  63. package/dist/output/formats.js.map +1 -0
  64. package/dist/output/index.d.ts +5 -0
  65. package/dist/output/index.d.ts.map +1 -0
  66. package/dist/output/index.js +5 -0
  67. package/dist/output/index.js.map +1 -0
  68. package/dist/output/paths.d.ts +38 -0
  69. package/dist/output/paths.d.ts.map +1 -0
  70. package/dist/output/paths.js +296 -0
  71. package/dist/output/paths.js.map +1 -0
  72. package/dist/output/writer.d.ts +33 -0
  73. package/dist/output/writer.d.ts.map +1 -0
  74. package/dist/output/writer.js +176 -0
  75. package/dist/output/writer.js.map +1 -0
  76. package/dist/references/attachments.d.ts +82 -0
  77. package/dist/references/attachments.d.ts.map +1 -0
  78. package/dist/references/attachments.js +238 -0
  79. package/dist/references/attachments.js.map +1 -0
  80. package/dist/references/data-url.d.ts +12 -0
  81. package/dist/references/data-url.d.ts.map +1 -0
  82. package/dist/references/data-url.js +75 -0
  83. package/dist/references/data-url.js.map +1 -0
  84. package/dist/references/formats.d.ts +13 -0
  85. package/dist/references/formats.d.ts.map +1 -0
  86. package/dist/references/formats.js +50 -0
  87. package/dist/references/formats.js.map +1 -0
  88. package/dist/references/index.d.ts +7 -0
  89. package/dist/references/index.d.ts.map +1 -0
  90. package/dist/references/index.js +7 -0
  91. package/dist/references/index.js.map +1 -0
  92. package/dist/references/limits.d.ts +15 -0
  93. package/dist/references/limits.d.ts.map +1 -0
  94. package/dist/references/limits.js +62 -0
  95. package/dist/references/limits.js.map +1 -0
  96. package/dist/references/project-files.d.ts +13 -0
  97. package/dist/references/project-files.d.ts.map +1 -0
  98. package/dist/references/project-files.js +148 -0
  99. package/dist/references/project-files.js.map +1 -0
  100. package/dist/references/remote-urls.d.ts +3 -0
  101. package/dist/references/remote-urls.d.ts.map +1 -0
  102. package/dist/references/remote-urls.js +22 -0
  103. package/dist/references/remote-urls.js.map +1 -0
  104. package/dist/server.d.ts +8 -0
  105. package/dist/server.d.ts.map +1 -0
  106. package/dist/server.js +97 -0
  107. package/dist/server.js.map +1 -0
  108. package/dist/tools/balance.d.ts +8 -0
  109. package/dist/tools/balance.d.ts.map +1 -0
  110. package/dist/tools/balance.js +133 -0
  111. package/dist/tools/balance.js.map +1 -0
  112. package/dist/tools/common.d.ts +3 -0
  113. package/dist/tools/common.d.ts.map +1 -0
  114. package/dist/tools/common.js +18 -0
  115. package/dist/tools/common.js.map +1 -0
  116. package/dist/tools/edit-image.d.ts +90 -0
  117. package/dist/tools/edit-image.d.ts.map +1 -0
  118. package/dist/tools/edit-image.js +47 -0
  119. package/dist/tools/edit-image.js.map +1 -0
  120. package/dist/tools/generate-image.d.ts +70 -0
  121. package/dist/tools/generate-image.d.ts.map +1 -0
  122. package/dist/tools/generate-image.js +36 -0
  123. package/dist/tools/generate-image.js.map +1 -0
  124. package/dist/tools/generation.d.ts +19 -0
  125. package/dist/tools/generation.d.ts.map +1 -0
  126. package/dist/tools/generation.js +154 -0
  127. package/dist/tools/generation.js.map +1 -0
  128. package/dist/tools/schema.d.ts +127 -0
  129. package/dist/tools/schema.d.ts.map +1 -0
  130. package/dist/tools/schema.js +47 -0
  131. package/dist/tools/schema.js.map +1 -0
  132. package/dist/tools/types.d.ts +18 -0
  133. package/dist/tools/types.d.ts.map +1 -0
  134. package/dist/tools/types.js +2 -0
  135. package/dist/tools/types.js.map +1 -0
  136. package/dist/transport/direct.d.ts +10 -0
  137. package/dist/transport/direct.d.ts.map +1 -0
  138. package/dist/transport/direct.js +15 -0
  139. package/dist/transport/direct.js.map +1 -0
  140. package/dist/transport/index.d.ts +4 -0
  141. package/dist/transport/index.d.ts.map +1 -0
  142. package/dist/transport/index.js +4 -0
  143. package/dist/transport/index.js.map +1 -0
  144. package/dist/transport/kote-gateway.d.ts +19 -0
  145. package/dist/transport/kote-gateway.d.ts.map +1 -0
  146. package/dist/transport/kote-gateway.js +224 -0
  147. package/dist/transport/kote-gateway.js.map +1 -0
  148. package/dist/transport/types.d.ts +10 -0
  149. package/dist/transport/types.d.ts.map +1 -0
  150. package/dist/transport/types.js +9 -0
  151. package/dist/transport/types.js.map +1 -0
  152. package/dist/utils/abort.d.ts +19 -0
  153. package/dist/utils/abort.d.ts.map +1 -0
  154. package/dist/utils/abort.js +121 -0
  155. package/dist/utils/abort.js.map +1 -0
  156. package/docs/architecture.md +75 -0
  157. package/docs/configuration.md +110 -0
  158. package/docs/image-to-image.md +101 -0
  159. package/docs/security.md +49 -0
  160. package/docs/testing.md +81 -0
  161. package/docs/troubleshooting.md +73 -0
  162. package/package.json +88 -0
  163. package/schema/plugin-options.schema.json +182 -0
@@ -0,0 +1,113 @@
1
+ import { PluginError, isPluginError } from "../openrouter/errors.js";
2
+ import { DEFAULT_OPTIONS, pluginOptionsSchema } from "./schema.js";
3
+ function validationDetails(error) {
4
+ return {
5
+ issues: error.issues.map((issue) => ({
6
+ code: issue.code,
7
+ path: issue.path.map(String).join("."),
8
+ message: issue.message,
9
+ })),
10
+ };
11
+ }
12
+ function normalizeEnvironmentKey(value) {
13
+ if (value === undefined) {
14
+ return undefined;
15
+ }
16
+ const normalized = value.trim();
17
+ if (normalized.length === 0)
18
+ return undefined;
19
+ if (normalized.length > 4_096 ||
20
+ /[\u0000-\u001f\u007f]/u.test(normalized)) {
21
+ throw new PluginError("GENIMAGE_CONFIG_INVALID", "An OpenRouter credential from the environment is invalid.", {
22
+ suggestion: "Set a single-line OPENROUTER_API_KEY or OPENROUTER_MANAGEMENT_API_KEY value.",
23
+ });
24
+ }
25
+ return normalized;
26
+ }
27
+ export function resolvePluginOptions(rawOptions, environment = {
28
+ OPENROUTER_API_KEY: process.env.OPENROUTER_API_KEY,
29
+ OPENROUTER_MANAGEMENT_API_KEY: process.env.OPENROUTER_MANAGEMENT_API_KEY,
30
+ }) {
31
+ const parsed = pluginOptionsSchema.safeParse(rawOptions);
32
+ if (!parsed.success) {
33
+ throw new PluginError("GENIMAGE_CONFIG_INVALID", "OpenRouter image plugin configuration is invalid.", {
34
+ details: validationDetails(parsed.error),
35
+ suggestion: "Check the plugin tuple options in opencode.jsonc.",
36
+ });
37
+ }
38
+ const apiKey = parsed.data.apiKey ??
39
+ normalizeEnvironmentKey(environment.OPENROUTER_API_KEY);
40
+ if (apiKey === undefined) {
41
+ throw new PluginError("GENIMAGE_OPENROUTER_KEY_MISSING", "An OpenRouter API key is required.", {
42
+ suggestion: "Set apiKey in plugin options or OPENROUTER_API_KEY in the environment.",
43
+ });
44
+ }
45
+ const managementApiKey = parsed.data.managementApiKey ??
46
+ normalizeEnvironmentKey(environment.OPENROUTER_MANAGEMENT_API_KEY);
47
+ return {
48
+ routing: parsed.data.routing,
49
+ model: parsed.data.model,
50
+ apiKey,
51
+ ...(managementApiKey === undefined ? {} : { managementApiKey }),
52
+ outputDirectory: parsed.data.outputDirectory ?? DEFAULT_OPTIONS.outputDirectory,
53
+ defaults: {
54
+ ...(parsed.data.defaults?.aspect_ratio === undefined
55
+ ? {}
56
+ : { aspect_ratio: parsed.data.defaults.aspect_ratio }),
57
+ ...(parsed.data.defaults?.background === undefined
58
+ ? {}
59
+ : { background: parsed.data.defaults.background }),
60
+ n: parsed.data.defaults?.n ?? DEFAULT_OPTIONS.defaults.n,
61
+ ...(parsed.data.defaults?.output_format === undefined
62
+ ? {}
63
+ : { output_format: parsed.data.defaults.output_format }),
64
+ ...(parsed.data.defaults?.output_compression === undefined
65
+ ? {}
66
+ : { output_compression: parsed.data.defaults.output_compression }),
67
+ ...(parsed.data.defaults?.quality === undefined
68
+ ? {}
69
+ : { quality: parsed.data.defaults.quality }),
70
+ ...(parsed.data.defaults?.resolution === undefined
71
+ ? {}
72
+ : { resolution: parsed.data.defaults.resolution }),
73
+ ...(parsed.data.defaults?.seed === undefined
74
+ ? {}
75
+ : { seed: parsed.data.defaults.seed }),
76
+ },
77
+ input: {
78
+ maxReferences: parsed.data.input?.maxReferences ??
79
+ DEFAULT_OPTIONS.input.maxReferences,
80
+ maxFileBytes: parsed.data.input?.maxFileBytes ?? DEFAULT_OPTIONS.input.maxFileBytes,
81
+ maxTotalBytes: parsed.data.input?.maxTotalBytes ??
82
+ DEFAULT_OPTIONS.input.maxTotalBytes,
83
+ },
84
+ requestTimeoutMs: parsed.data.requestTimeoutMs ?? DEFAULT_OPTIONS.requestTimeoutMs,
85
+ modelCacheTtlMs: parsed.data.modelCacheTtlMs ?? DEFAULT_OPTIONS.modelCacheTtlMs,
86
+ maxResponseBytes: parsed.data.maxResponseBytes ?? DEFAULT_OPTIONS.maxResponseBytes,
87
+ maxDecodedBytes: parsed.data.maxDecodedBytes ?? DEFAULT_OPTIONS.maxDecodedBytes,
88
+ };
89
+ }
90
+ export function resolvePluginConfig(rawOptions, environment = {
91
+ OPENROUTER_API_KEY: process.env.OPENROUTER_API_KEY,
92
+ OPENROUTER_MANAGEMENT_API_KEY: process.env.OPENROUTER_MANAGEMENT_API_KEY,
93
+ }) {
94
+ try {
95
+ return {
96
+ blocked: false,
97
+ options: resolvePluginOptions(rawOptions, environment),
98
+ };
99
+ }
100
+ catch (error) {
101
+ if (isPluginError(error)) {
102
+ return { blocked: true, error };
103
+ }
104
+ throw error;
105
+ }
106
+ }
107
+ export function requireResolvedPluginOptions(state) {
108
+ if (state.blocked) {
109
+ throw state.error;
110
+ }
111
+ return state.options;
112
+ }
113
+ //# sourceMappingURL=resolve.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolve.js","sourceRoot":"","sources":["../../src/config/resolve.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAA;AACpE,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA;AAOlE,SAAS,iBAAiB,CAAC,KAAiB;IAC1C,OAAO;QACL,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;YACnC,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;YACtC,OAAO,EAAE,KAAK,CAAC,OAAO;SACvB,CAAC,CAAC;KACJ,CAAA;AACH,CAAC;AAED,SAAS,uBAAuB,CAAC,KAAyB;IACxD,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACxB,OAAO,SAAS,CAAA;IAClB,CAAC;IAED,MAAM,UAAU,GAAG,KAAK,CAAC,IAAI,EAAE,CAAA;IAC/B,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,SAAS,CAAA;IAC7C,IACE,UAAU,CAAC,MAAM,GAAG,KAAK;QACzB,wBAAwB,CAAC,IAAI,CAAC,UAAU,CAAC,EACzC,CAAC;QACD,MAAM,IAAI,WAAW,CACnB,yBAAyB,EACzB,2DAA2D,EAC3D;YACE,UAAU,EACR,8EAA8E;SACjF,CACF,CAAA;IACH,CAAC;IACD,OAAO,UAAU,CAAA;AACnB,CAAC;AAED,MAAM,UAAU,oB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AED,MAAM,UAAU,4BAA4B,CAC1C,KAAwB;IAExB,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC;QAClB,MAAM,KAAK,CAAC,KAAK,CAAA;IACnB,CAAC;IAED,OAAO,KAAK,CAAC,OAAO,CAAA;AACtB,CAAC"}
@@ -0,0 +1,188 @@
1
+ import { z } from "zod";
2
+ import type { ResolvedPluginInputOptions } from "./types.js";
3
+ export declare const generationParametersSchema: z.ZodObject<{
4
+ aspect_ratio: z.ZodOptional<z.ZodEnum<{
5
+ auto: "auto";
6
+ "1:1": "1:1";
7
+ "1:2": "1:2";
8
+ "1:4": "1:4";
9
+ "1:8": "1:8";
10
+ "2:1": "2:1";
11
+ "2:3": "2:3";
12
+ "3:2": "3:2";
13
+ "3:4": "3:4";
14
+ "4:1": "4:1";
15
+ "4:3": "4:3";
16
+ "4:5": "4:5";
17
+ "5:4": "5:4";
18
+ "8:1": "8:1";
19
+ "9:16": "9:16";
20
+ "16:9": "16:9";
21
+ "9:19.5": "9:19.5";
22
+ "19.5:9": "19.5:9";
23
+ "9:20": "9:20";
24
+ "20:9": "20:9";
25
+ "9:21": "9:21";
26
+ "21:9": "21:9";
27
+ }>>;
28
+ background: z.ZodOptional<z.ZodEnum<{
29
+ transparent: "transparent";
30
+ auto: "auto";
31
+ opaque: "opaque";
32
+ }>>;
33
+ n: z.ZodOptional<z.ZodNumber>;
34
+ output_format: z.ZodOptional<z.ZodEnum<{
35
+ png: "png";
36
+ jpeg: "jpeg";
37
+ webp: "webp";
38
+ }>>;
39
+ output_compression: z.ZodOptional<z.ZodNumber>;
40
+ quality: z.ZodOptional<z.ZodEnum<{
41
+ auto: "auto";
42
+ high: "high";
43
+ low: "low";
44
+ medium: "medium";
45
+ }>>;
46
+ resolution: z.ZodOptional<z.ZodEnum<{
47
+ 512: "512";
48
+ "1K": "1K";
49
+ "2K": "2K";
50
+ "4K": "4K";
51
+ }>>;
52
+ seed: z.ZodOptional<z.ZodNumber>;
53
+ }, z.core.$strict>;
54
+ export declare const generateImageArgsSchema: z.ZodObject<{
55
+ prompt: z.ZodString;
56
+ output_path: z.ZodOptional<z.ZodString>;
57
+ aspect_ratio: z.ZodOptional<z.ZodEnum<{
58
+ auto: "auto";
59
+ "1:1": "1:1";
60
+ "1:2": "1:2";
61
+ "1:4": "1:4";
62
+ "1:8": "1:8";
63
+ "2:1": "2:1";
64
+ "2:3": "2:3";
65
+ "3:2": "3:2";
66
+ "3:4": "3:4";
67
+ "4:1": "4:1";
68
+ "4:3": "4:3";
69
+ "4:5": "4:5";
70
+ "5:4": "5:4";
71
+ "8:1": "8:1";
72
+ "9:16": "9:16";
73
+ "16:9": "16:9";
74
+ "9:19.5": "9:19.5";
75
+ "19.5:9": "19.5:9";
76
+ "9:20": "9:20";
77
+ "20:9": "20:9";
78
+ "9:21": "9:21";
79
+ "21:9": "21:9";
80
+ }>>;
81
+ background: z.ZodOptional<z.ZodEnum<{
82
+ transparent: "transparent";
83
+ auto: "auto";
84
+ opaque: "opaque";
85
+ }>>;
86
+ n: z.ZodOptional<z.ZodNumber>;
87
+ output_format: z.ZodOptional<z.ZodEnum<{
88
+ png: "png";
89
+ jpeg: "jpeg";
90
+ webp: "webp";
91
+ }>>;
92
+ output_compression: z.ZodOptional<z.ZodNumber>;
93
+ quality: z.ZodOptional<z.ZodEnum<{
94
+ auto: "auto";
95
+ high: "high";
96
+ low: "low";
97
+ medium: "medium";
98
+ }>>;
99
+ resolution: z.ZodOptional<z.ZodEnum<{
100
+ 512: "512";
101
+ "1K": "1K";
102
+ "2K": "2K";
103
+ "4K": "4K";
104
+ }>>;
105
+ seed: z.ZodOptional<z.ZodNumber>;
106
+ }, z.core.$strict>;
107
+ export declare const pluginOptionsSchema: z.ZodObject<{
108
+ routing: z.ZodEnum<{
109
+ direct: "direct";
110
+ proxy: "proxy";
111
+ }>;
112
+ model: z.ZodString;
113
+ apiKey: z.ZodOptional<z.ZodString>;
114
+ managementApiKey: z.ZodOptional<z.ZodString>;
115
+ outputDirectory: z.ZodOptional<z.ZodString>;
116
+ defaults: z.ZodOptional<z.ZodObject<{
117
+ aspect_ratio: z.ZodOptional<z.ZodEnum<{
118
+ auto: "auto";
119
+ "1:1": "1:1";
120
+ "1:2": "1:2";
121
+ "1:4": "1:4";
122
+ "1:8": "1:8";
123
+ "2:1": "2:1";
124
+ "2:3": "2:3";
125
+ "3:2": "3:2";
126
+ "3:4": "3:4";
127
+ "4:1": "4:1";
128
+ "4:3": "4:3";
129
+ "4:5": "4:5";
130
+ "5:4": "5:4";
131
+ "8:1": "8:1";
132
+ "9:16": "9:16";
133
+ "16:9": "16:9";
134
+ "9:19.5": "9:19.5";
135
+ "19.5:9": "19.5:9";
136
+ "9:20": "9:20";
137
+ "20:9": "20:9";
138
+ "9:21": "9:21";
139
+ "21:9": "21:9";
140
+ }>>;
141
+ background: z.ZodOptional<z.ZodEnum<{
142
+ transparent: "transparent";
143
+ auto: "auto";
144
+ opaque: "opaque";
145
+ }>>;
146
+ n: z.ZodOptional<z.ZodNumber>;
147
+ output_format: z.ZodOptional<z.ZodEnum<{
148
+ png: "png";
149
+ jpeg: "jpeg";
150
+ webp: "webp";
151
+ }>>;
152
+ output_compression: z.ZodOptional<z.ZodNumber>;
153
+ quality: z.ZodOptional<z.ZodEnum<{
154
+ auto: "auto";
155
+ high: "high";
156
+ low: "low";
157
+ medium: "medium";
158
+ }>>;
159
+ resolution: z.ZodOptional<z.ZodEnum<{
160
+ 512: "512";
161
+ "1K": "1K";
162
+ "2K": "2K";
163
+ "4K": "4K";
164
+ }>>;
165
+ seed: z.ZodOptional<z.ZodNumber>;
166
+ }, z.core.$strict>>;
167
+ input: z.ZodOptional<z.ZodObject<{
168
+ maxReferences: z.ZodOptional<z.ZodNumber>;
169
+ maxFileBytes: z.ZodOptional<z.ZodNumber>;
170
+ maxTotalBytes: z.ZodOptional<z.ZodNumber>;
171
+ }, z.core.$strict>>;
172
+ requestTimeoutMs: z.ZodOptional<z.ZodNumber>;
173
+ modelCacheTtlMs: z.ZodOptional<z.ZodNumber>;
174
+ maxResponseBytes: z.ZodOptional<z.ZodNumber>;
175
+ maxDecodedBytes: z.ZodOptional<z.ZodNumber>;
176
+ }, z.core.$strict>;
177
+ export declare const DEFAULT_OPTIONS: {
178
+ readonly outputDirectory: string;
179
+ readonly defaults: Readonly<{
180
+ n: number;
181
+ }>;
182
+ readonly input: Readonly<ResolvedPluginInputOptions>;
183
+ readonly requestTimeoutMs: number;
184
+ readonly modelCacheTtlMs: number;
185
+ readonly maxResponseBytes: number;
186
+ readonly maxDecodedBytes: number;
187
+ };
188
+ //# sourceMappingURL=schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/config/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAUvB,OAAO,KAAK,EACV,0BAA0B,EAC3B,MAAM,YAAY,CAAA;AAoDnB,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAWQ,CAAA;AAgB/C,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAehC,CAAA;AA+BJ,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAiC5B,CAAA;AAEJ,eAAO,MAAM,eAAe,EAAE;IAC5B,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAA;IAChC,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;QAAE,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;IAC1C,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC,0BAA0B,CAAC,CAAA;IACpD,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAA;IACjC,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAA;IAChC,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAA;IACjC,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAA;CAahC,CAAA"}
@@ -0,0 +1,144 @@
1
+ import { z } from "zod";
2
+ import { IMAGE_ASPECT_RATIOS, IMAGE_BACKGROUNDS, IMAGE_OUTPUT_FORMATS, IMAGE_QUALITIES, IMAGE_RESOLUTIONS, ROUTING_MODES, } from "./types.js";
3
+ const positiveInteger = z.number().int().positive();
4
+ function addParameterCompatibilityChecks(parameters, context, requireCompressionFormat = true) {
5
+ if (parameters.background === "transparent" &&
6
+ ((requireCompressionFormat && parameters.output_format === undefined) ||
7
+ parameters.output_format === "jpeg")) {
8
+ context.addIssue({
9
+ code: "custom",
10
+ path: ["background"],
11
+ message: "Transparent backgrounds are not supported for JPEG output.",
12
+ });
13
+ }
14
+ if (parameters.output_compression !== undefined &&
15
+ (requireCompressionFormat || parameters.output_format !== undefined) &&
16
+ parameters.output_format !== "jpeg" &&
17
+ parameters.output_format !== "webp") {
18
+ context.addIssue({
19
+ code: "custom",
20
+ path: ["output_compression"],
21
+ message: "Output compression requires JPEG or WebP output.",
22
+ });
23
+ }
24
+ }
25
+ function isSafeRelativeDirectory(value) {
26
+ if (value.length > 4_096 ||
27
+ /^[A-Za-z]:/u.test(value) ||
28
+ /^(?:[\\/]|\\\\)/u.test(value) ||
29
+ /[\u0000-\u001f\u007f]/u.test(value)) {
30
+ return false;
31
+ }
32
+ return !value.split(/[\\/]/u).includes("..");
33
+ }
34
+ export const generationParametersSchema = z
35
+ .strictObject({
36
+ aspect_ratio: z.enum(IMAGE_ASPECT_RATIOS).optional(),
37
+ background: z.enum(IMAGE_BACKGROUNDS).optional(),
38
+ n: z.number().int().min(1).max(10).optional(),
39
+ output_format: z.enum(IMAGE_OUTPUT_FORMATS).optional(),
40
+ output_compression: z.number().int().min(0).max(100).optional(),
41
+ quality: z.enum(IMAGE_QUALITIES).optional(),
42
+ resolution: z.enum(IMAGE_RESOLUTIONS).optional(),
43
+ seed: z.number().int().nonnegative().optional(),
44
+ })
45
+ .superRefine(addParameterCompatibilityChecks);
46
+ const promptSchema = z
47
+ .string()
48
+ .max(32_000)
49
+ .refine((prompt) => prompt.trim().length > 0, {
50
+ message: "Prompt must not be empty.",
51
+ });
52
+ const outputPathSchema = z
53
+ .string()
54
+ .max(4_096)
55
+ .refine((outputPath) => outputPath.trim().length > 0, {
56
+ message: "Output path must not be empty.",
57
+ });
58
+ export const generateImageArgsSchema = z
59
+ .strictObject({
60
+ prompt: promptSchema,
61
+ output_path: outputPathSchema.optional(),
62
+ aspect_ratio: z.enum(IMAGE_ASPECT_RATIOS).optional(),
63
+ background: z.enum(IMAGE_BACKGROUNDS).optional(),
64
+ n: z.number().int().min(1).max(10).optional(),
65
+ output_format: z.enum(IMAGE_OUTPUT_FORMATS).optional(),
66
+ output_compression: z.number().int().min(0).max(100).optional(),
67
+ quality: z.enum(IMAGE_QUALITIES).optional(),
68
+ resolution: z.enum(IMAGE_RESOLUTIONS).optional(),
69
+ seed: z.number().int().nonnegative().optional(),
70
+ })
71
+ .superRefine((args, context) => {
72
+ addParameterCompatibilityChecks(args, context, false);
73
+ });
74
+ const pluginInputSchema = z
75
+ .strictObject({
76
+ maxReferences: positiveInteger.max(16).optional(),
77
+ maxFileBytes: positiveInteger.optional(),
78
+ maxTotalBytes: positiveInteger.optional(),
79
+ })
80
+ .superRefine((input, context) => {
81
+ if (input.maxFileBytes !== undefined &&
82
+ input.maxTotalBytes !== undefined &&
83
+ input.maxTotalBytes < input.maxFileBytes) {
84
+ context.addIssue({
85
+ code: "custom",
86
+ path: ["maxTotalBytes"],
87
+ message: "Total input size cannot be smaller than per-file size.",
88
+ });
89
+ }
90
+ });
91
+ const credentialSchema = z
92
+ .string()
93
+ .trim()
94
+ .min(1)
95
+ .max(4_096)
96
+ .refine((value) => !/[\u0000-\u001f\u007f]/u.test(value), {
97
+ message: "Credentials cannot contain control characters.",
98
+ });
99
+ export const pluginOptionsSchema = z
100
+ .strictObject({
101
+ routing: z.enum(ROUTING_MODES),
102
+ model: z.string().trim().min(1),
103
+ apiKey: credentialSchema.optional(),
104
+ managementApiKey: credentialSchema.optional(),
105
+ outputDirectory: z
106
+ .string()
107
+ .trim()
108
+ .min(1)
109
+ .refine(isSafeRelativeDirectory, {
110
+ message: "Output directory must be a safe worktree-relative path.",
111
+ })
112
+ .optional(),
113
+ defaults: generationParametersSchema.optional(),
114
+ input: pluginInputSchema.optional(),
115
+ requestTimeoutMs: positiveInteger.optional(),
116
+ modelCacheTtlMs: positiveInteger.optional(),
117
+ maxResponseBytes: positiveInteger.optional(),
118
+ maxDecodedBytes: positiveInteger.optional(),
119
+ })
120
+ .superRefine((options, context) => {
121
+ const maxFileBytes = options.input?.maxFileBytes ?? DEFAULT_OPTIONS.input.maxFileBytes;
122
+ const maxTotalBytes = options.input?.maxTotalBytes ?? DEFAULT_OPTIONS.input.maxTotalBytes;
123
+ if (maxTotalBytes < maxFileBytes) {
124
+ context.addIssue({
125
+ code: "custom",
126
+ path: ["input", "maxTotalBytes"],
127
+ message: "Total input size cannot be smaller than per-file size.",
128
+ });
129
+ }
130
+ });
131
+ export const DEFAULT_OPTIONS = Object.freeze({
132
+ outputDirectory: "assets/generated",
133
+ defaults: Object.freeze({ n: 1 }),
134
+ input: Object.freeze({
135
+ maxReferences: 16,
136
+ maxFileBytes: 20 * 1024 * 1024,
137
+ maxTotalBytes: 50 * 1024 * 1024,
138
+ }),
139
+ requestTimeoutMs: 300_000,
140
+ modelCacheTtlMs: 3_600_000,
141
+ maxResponseBytes: 128 * 1024 * 1024,
142
+ maxDecodedBytes: 128 * 1024 * 1024,
143
+ });
144
+ //# sourceMappingURL=schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/config/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,OAAO,EACL,mBAAmB,EACnB,iBAAi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AAI;IACnC,eAAe,EAAE,GAAG,GAAG,IAAI,GAAG,IAAI;CACnC,CAAC,CAAA"}
@@ -0,0 +1,75 @@
1
+ import type { PluginError } from "../openrouter/errors.js";
2
+ export declare const IMAGE_ASPECT_RATIOS: readonly ["1:1", "1:2", "1:4", "1:8", "2:1", "2:3", "3:2", "3:4", "4:1", "4:3", "4:5", "5:4", "8:1", "9:16", "16:9", "9:19.5", "19.5:9", "9:20", "20:9", "9:21", "21:9", "auto"];
3
+ export declare const IMAGE_BACKGROUNDS: readonly ["auto", "transparent", "opaque"];
4
+ export declare const IMAGE_OUTPUT_FORMATS: readonly ["png", "jpeg", "webp"];
5
+ export declare const IMAGE_QUALITIES: readonly ["auto", "low", "medium", "high"];
6
+ export declare const IMAGE_RESOLUTIONS: readonly ["512", "1K", "2K", "4K"];
7
+ export declare const ROUTING_MODES: readonly ["direct", "proxy"];
8
+ export type ImageAspectRatio = (typeof IMAGE_ASPECT_RATIOS)[number];
9
+ export type ImageBackground = (typeof IMAGE_BACKGROUNDS)[number];
10
+ export type ImageOutputFormat = (typeof IMAGE_OUTPUT_FORMATS)[number];
11
+ export type ImageQuality = (typeof IMAGE_QUALITIES)[number];
12
+ export type ImageResolution = (typeof IMAGE_RESOLUTIONS)[number];
13
+ export type RoutingMode = (typeof ROUTING_MODES)[number];
14
+ export interface ImageGenerationParameters {
15
+ aspect_ratio?: ImageAspectRatio | undefined;
16
+ background?: ImageBackground | undefined;
17
+ n?: number | undefined;
18
+ output_format?: ImageOutputFormat | undefined;
19
+ output_compression?: number | undefined;
20
+ quality?: ImageQuality | undefined;
21
+ resolution?: ImageResolution | undefined;
22
+ seed?: number | undefined;
23
+ }
24
+ export type ImageGenerationDefaults = ImageGenerationParameters;
25
+ export interface PluginInputOptions {
26
+ maxReferences?: number | undefined;
27
+ maxFileBytes?: number | undefined;
28
+ maxTotalBytes?: number | undefined;
29
+ }
30
+ export interface PluginOptions {
31
+ routing: RoutingMode;
32
+ model: string;
33
+ apiKey?: string | undefined;
34
+ managementApiKey?: string | undefined;
35
+ outputDirectory?: string | undefined;
36
+ defaults?: ImageGenerationDefaults | undefined;
37
+ input?: PluginInputOptions | undefined;
38
+ requestTimeoutMs?: number | undefined;
39
+ modelCacheTtlMs?: number | undefined;
40
+ maxResponseBytes?: number | undefined;
41
+ maxDecodedBytes?: number | undefined;
42
+ }
43
+ export interface ResolvedImageGenerationDefaults extends ImageGenerationParameters {
44
+ n: number;
45
+ }
46
+ export interface ResolvedPluginInputOptions {
47
+ maxReferences: number;
48
+ maxFileBytes: number;
49
+ maxTotalBytes: number;
50
+ }
51
+ export interface ResolvedPluginOptions {
52
+ routing: RoutingMode;
53
+ model: string;
54
+ apiKey: string;
55
+ managementApiKey?: string;
56
+ outputDirectory: string;
57
+ defaults: ResolvedImageGenerationDefaults;
58
+ input: ResolvedPluginInputOptions;
59
+ requestTimeoutMs: number;
60
+ modelCacheTtlMs: number;
61
+ maxResponseBytes: number;
62
+ maxDecodedBytes: number;
63
+ }
64
+ export interface ConfigEnvironment {
65
+ OPENROUTER_API_KEY?: string | undefined;
66
+ OPENROUTER_MANAGEMENT_API_KEY?: string | undefined;
67
+ }
68
+ export type PluginConfigState = {
69
+ blocked: false;
70
+ options: ResolvedPluginOptions;
71
+ } | {
72
+ blocked: true;
73
+ error: PluginError;
74
+ };
75
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/config/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AAE1D,eAAO,MAAM,mBAAmB,kLAuBtB,CAAA;AAEV,eAAO,MAAM,iBAAiB,4CAA6C,CAAA;AAC3E,eAAO,MAAM,oBAAoB,kCAAmC,CAAA;AACpE,eAAO,MAAM,eAAe,4CAA6C,CAAA;AACzE,eAAO,MAAM,iBAAiB,oCAAqC,CAAA;AACnE,eAAO,MAAM,aAAa,8BAA+B,C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qBAAqB,CAAA;CAC/B,GACD;IACE,OAAO,EAAE,IAAI,CAAA;IACb,KAAK,EAAE,WAAW,CAAA;CACnB,CAAA"}
@@ -0,0 +1,30 @@
1
+ export const IMAGE_ASPECT_RATIOS = [
2
+ "1:1",
3
+ "1:2",
4
+ "1:4",
5
+ "1:8",
6
+ "2:1",
7
+ "2:3",
8
+ "3:2",
9
+ "3:4",
10
+ "4:1",
11
+ "4:3",
12
+ "4:5",
13
+ "5:4",
14
+ "8:1",
15
+ "9:16",
16
+ "16:9",
17
+ "9:19.5",
18
+ "19.5:9",
19
+ "9:20",
20
+ "20:9",
21
+ "9:21",
22
+ "21:9",
23
+ "auto",
24
+ ];
25
+ export const IMAGE_BACKGROUNDS = ["auto", "transparent", "opaque"];
26
+ export const IMAGE_OUTPUT_FORMATS = ["png", "jpeg", "webp"];
27
+ export const IMAGE_QUALITIES = ["auto", "low", "medium", "high"];
28
+ export const IMAGE_RESOLUTIONS = ["512", "1K", "2K", "4K"];
29
+ export const ROUTING_MODES = ["direct", "proxy"];
30
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/config/types.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,KAAK;IACL,KAAK;IACL,KAAK;IACL,KAAK;IACL,KAAK;IACL,KAAK;IACL,KAAK;IACL,KAAK;IACL,KAAK;IACL,KAAK;IACL,KAAK;IACL,KAAK;IACL,KAAK;IACL,MAAM;IACN,MAAM;IACN,QAAQ;IACR,QAAQ;IACR,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;CACE,CAAA;AAEV,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,MAAM,EAAE,aAAa,EAAE,QAAQ,CAAU,CAAA;AAC3E,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAU,CAAA;AACpE,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,CAAU,CAAA;AACzE,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAU,CAAA;AACnE,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,QAAQ,EAAE,OAAO,CAAU,CAAA"}
@@ -0,0 +1,46 @@
1
+ export type LogLevel = "debug" | "info" | "warn" | "error";
2
+ export type SafeLogFields = Partial<{
3
+ routing: "direct" | "proxy";
4
+ model: string;
5
+ requestId: string;
6
+ errorCode: string;
7
+ httpStatus: number;
8
+ referenceCount: number;
9
+ inputBytes: number;
10
+ outputBytes: number;
11
+ outputPath: string;
12
+ requestedCount: number;
13
+ returnedCount: number;
14
+ cacheStatus: "hit" | "miss" | "expired";
15
+ gatewayOrigin: string;
16
+ promptLength: number;
17
+ promptSha256Prefix: string;
18
+ }>;
19
+ export interface SafeLogger {
20
+ log(level: LogLevel, message: string, fields?: SafeLogFields): void;
21
+ }
22
+ export declare const noopLogger: SafeLogger;
23
+ type OpenCodeLogClient = {
24
+ app: {
25
+ log(options: {
26
+ body: {
27
+ service: string;
28
+ level: LogLevel;
29
+ message: string;
30
+ extra?: Record<string, unknown>;
31
+ };
32
+ query?: {
33
+ directory?: string;
34
+ };
35
+ }): Promise<unknown>;
36
+ };
37
+ };
38
+ export declare function redactSecrets(value: string): string;
39
+ export declare function safeUrlOrigin(value: string | URL): string | undefined;
40
+ export declare function promptFingerprint(prompt: string): {
41
+ promptLength: number;
42
+ promptSha256Prefix: string;
43
+ };
44
+ export declare function createOpenCodeLogger(client: OpenCodeLogClient, directory: string): SafeLogger;
45
+ export {};
46
+ //# sourceMappingURL=logging.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logging.d.ts","sourceRoot":"","sources":["../src/logging.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,QAAQ,GAAG,OAAO,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