oda-engine 0.0.0-stage → 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 (204) hide show
  1. package/README.md +151 -2
  2. package/bin/nowhere.mjs +352 -0
  3. package/lib/account.mjs +57 -0
  4. package/lib/agentModules.mjs +57 -0
  5. package/lib/devServer.mjs +351 -0
  6. package/lib/headless.mjs +231 -0
  7. package/lib/headlessPreview.mjs +212 -0
  8. package/lib/keys.mjs +517 -0
  9. package/lib/make.mjs +855 -0
  10. package/lib/mcp.mjs +537 -0
  11. package/lib/open.mjs +22 -0
  12. package/lib/preview.mjs +87 -0
  13. package/lib/previewRpc.mjs +134 -0
  14. package/lib/project.mjs +359 -0
  15. package/lib/publishFlow.mjs +90 -0
  16. package/lib/resources.mjs +50 -0
  17. package/lib/rules.mjs +60 -0
  18. package/lib/scaffold.mjs +42 -0
  19. package/lib/setup.mjs +59 -0
  20. package/lib/tools.mjs +668 -0
  21. package/package.json +51 -4
  22. package/template/game.config.json +9 -0
  23. package/template/scene.json +4 -0
  24. package/template/src/main.ts +11 -0
  25. package/vendor/DOCS.md +447 -0
  26. package/vendor/agent/appRun.mjs +520 -0
  27. package/vendor/agent/assets/brief.mjs +242 -0
  28. package/vendor/agent/assets/collider.mjs +531 -0
  29. package/vendor/agent/assets/environments/index.mjs +12 -0
  30. package/vendor/agent/assets/environments/worldlabs.mjs +161 -0
  31. package/vendor/agent/assets/fetch.mjs +168 -0
  32. package/vendor/agent/assets/footprint.mjs +13 -0
  33. package/vendor/agent/assets/gltf.mjs +547 -0
  34. package/vendor/agent/assets/hdr.mjs +269 -0
  35. package/vendor/agent/assets/imageOps.mjs +171 -0
  36. package/vendor/agent/assets/images/codex.mjs +307 -0
  37. package/vendor/agent/assets/images/fal.mjs +75 -0
  38. package/vendor/agent/assets/images/gemini.mjs +84 -0
  39. package/vendor/agent/assets/images/index.mjs +25 -0
  40. package/vendor/agent/assets/images/openai.mjs +75 -0
  41. package/vendor/agent/assets/images/stability.mjs +71 -0
  42. package/vendor/agent/assets/images/views.mjs +31 -0
  43. package/vendor/agent/assets/import.mjs +1352 -0
  44. package/vendor/agent/assets/inspect.mjs +465 -0
  45. package/vendor/agent/assets/jobs.mjs +196 -0
  46. package/vendor/agent/assets/ktx2.mjs +290 -0
  47. package/vendor/agent/assets/ledger.mjs +466 -0
  48. package/vendor/agent/assets/net.mjs +254 -0
  49. package/vendor/agent/assets/prices.json +39 -0
  50. package/vendor/agent/assets/providers/fal.mjs +115 -0
  51. package/vendor/agent/assets/providers/index.mjs +22 -0
  52. package/vendor/agent/assets/providers/meshy.mjs +119 -0
  53. package/vendor/agent/assets/providers/tripo.mjs +188 -0
  54. package/vendor/agent/assets/sources/ambientcg.mjs +129 -0
  55. package/vendor/agent/assets/sources/index.mjs +23 -0
  56. package/vendor/agent/assets/sources/polyhaven.mjs +237 -0
  57. package/vendor/agent/assets/sources/polypizza.mjs +121 -0
  58. package/vendor/agent/assets/splat.mjs +631 -0
  59. package/vendor/agent/assets/targets.mjs +122 -0
  60. package/vendor/agent/assets/tile.mjs +261 -0
  61. package/vendor/agent/assets/unzip.mjs +180 -0
  62. package/vendor/agent/blender/cleanup.py +360 -0
  63. package/vendor/agent/blender/convert.py +167 -0
  64. package/vendor/agent/blender/find.mjs +192 -0
  65. package/vendor/agent/blender/nw_export.py +104 -0
  66. package/vendor/agent/blender/nw_rubric.py +426 -0
  67. package/vendor/agent/blender/run.mjs +193 -0
  68. package/vendor/agent/blender/runner.py +252 -0
  69. package/vendor/agent/blender/sheet.py +743 -0
  70. package/vendor/agent/depth.mjs +134 -0
  71. package/vendor/agent/director/board.mjs +451 -0
  72. package/vendor/agent/director/contracts.mjs +663 -0
  73. package/vendor/agent/director/director.mjs +2365 -0
  74. package/vendor/agent/director/estimate.mjs +200 -0
  75. package/vendor/agent/director/gate.mjs +802 -0
  76. package/vendor/agent/director/limits.json +16 -0
  77. package/vendor/agent/director/methods.mjs +457 -0
  78. package/vendor/agent/director/policy.json +33 -0
  79. package/vendor/agent/director/prompts.mjs +244 -0
  80. package/vendor/agent/director/reading.mjs +341 -0
  81. package/vendor/agent/director/router.mjs +184 -0
  82. package/vendor/agent/director/seams.mjs +243 -0
  83. package/vendor/agent/director/session.mjs +643 -0
  84. package/vendor/agent/director/store.mjs +119 -0
  85. package/vendor/agent/director/taskGate.mjs +110 -0
  86. package/vendor/agent/director/teamLedger.mjs +118 -0
  87. package/vendor/agent/director/triage.mjs +63 -0
  88. package/vendor/agent/downloads.cjs +363 -0
  89. package/vendor/agent/flow.mjs +78 -0
  90. package/vendor/agent/guard.mjs +613 -0
  91. package/vendor/agent/host.mjs +1736 -0
  92. package/vendor/agent/language.mjs +58 -0
  93. package/vendor/agent/ledger.mjs +360 -0
  94. package/vendor/agent/locale.cjs +186 -0
  95. package/vendor/agent/loop/capacity.mjs +74 -0
  96. package/vendor/agent/loop/compose.mjs +127 -0
  97. package/vendor/agent/loop/gate.mjs +205 -0
  98. package/vendor/agent/loop/judge.mjs +189 -0
  99. package/vendor/agent/loop/levels.mjs +273 -0
  100. package/vendor/agent/loop/state.mjs +358 -0
  101. package/vendor/agent/notes.cjs +278 -0
  102. package/vendor/agent/pace.mjs +258 -0
  103. package/vendor/agent/panels.mjs +431 -0
  104. package/vendor/agent/prompt.mjs +342 -0
  105. package/vendor/agent/reference/board.mjs +410 -0
  106. package/vendor/agent/reference/compose.mjs +364 -0
  107. package/vendor/agent/reference/decode.mjs +56 -0
  108. package/vendor/agent/reference/facts.mjs +1874 -0
  109. package/vendor/agent/reference/png.mjs +107 -0
  110. package/vendor/agent/reference/records.mjs +63 -0
  111. package/vendor/agent/reference/web.mjs +252 -0
  112. package/vendor/agent/roles/artist.mjs +69 -0
  113. package/vendor/agent/roles/builder.mjs +79 -0
  114. package/vendor/agent/roles/checks.mjs +223 -0
  115. package/vendor/agent/roles/common.mjs +188 -0
  116. package/vendor/agent/roles/critic.mjs +171 -0
  117. package/vendor/agent/roles/index.mjs +39 -0
  118. package/vendor/agent/roles/modeller.mjs +142 -0
  119. package/vendor/agent/roles/qa.mjs +58 -0
  120. package/vendor/agent/roles/rubrics.mjs +79 -0
  121. package/vendor/agent/roles/sound.mjs +69 -0
  122. package/vendor/agent/rounds.cjs +333 -0
  123. package/vendor/agent/shared.mjs +284 -0
  124. package/vendor/agent/stopGate.mjs +574 -0
  125. package/vendor/agent/subagents.mjs +129 -0
  126. package/vendor/agent/tools/assets.mjs +499 -0
  127. package/vendor/agent/tools/blender.mjs +754 -0
  128. package/vendor/agent/tools/cards.mjs +479 -0
  129. package/vendor/agent/tools/choices.mjs +479 -0
  130. package/vendor/agent/tools/compose.mjs +74 -0
  131. package/vendor/agent/tools/environment.mjs +488 -0
  132. package/vendor/agent/tools/eyes.mjs +733 -0
  133. package/vendor/agent/tools/generate.mjs +338 -0
  134. package/vendor/agent/tools/guide.mjs +46 -0
  135. package/vendor/agent/tools/harness.mjs +193 -0
  136. package/vendor/agent/tools/image.mjs +643 -0
  137. package/vendor/agent/tools/index.mjs +162 -0
  138. package/vendor/agent/tools/look.mjs +578 -0
  139. package/vendor/agent/tools/loop.mjs +858 -0
  140. package/vendor/agent/tools/others.mjs +123 -0
  141. package/vendor/agent/tools/pictures.mjs +535 -0
  142. package/vendor/agent/tools/reference.mjs +366 -0
  143. package/vendor/agent/transcripts.mjs +118 -0
  144. package/vendor/agent-loop.mjs +602 -0
  145. package/vendor/agent-plugin/.claude-plugin/plugin.json +5 -0
  146. package/vendor/agent-plugin/skills/art-direction/SKILL.md +82 -0
  147. package/vendor/agent-plugin/skills/asset-legality/SKILL.md +101 -0
  148. package/vendor/agent-plugin/skills/asset-sources/SKILL.md +111 -0
  149. package/vendor/agent-plugin/skills/blender-modeling/SKILL.md +97 -0
  150. package/vendor/agent-plugin/skills/look-dev/SKILL.md +104 -0
  151. package/vendor/agent-plugin/skills/playtesting/SKILL.md +74 -0
  152. package/vendor/agent-plugin/skills/reference-loop/SKILL.md +102 -0
  153. package/vendor/agent-plugin/skills/sound-design/SKILL.md +60 -0
  154. package/vendor/agent-plugin/skills/style/SKILL.md +35 -0
  155. package/vendor/agent-plugin/skills/tsl-r185/SKILL.md +107 -0
  156. package/vendor/auth.cjs +570 -0
  157. package/vendor/build.cjs +953 -0
  158. package/vendor/catalog.json +455 -0
  159. package/vendor/connectors.cjs +688 -0
  160. package/vendor/eyes.mjs +733 -0
  161. package/vendor/gameExports.json +1390 -0
  162. package/vendor/git.cjs +222 -0
  163. package/vendor/models.json +57 -0
  164. package/vendor/publish.cjs +1018 -0
  165. package/vendor/refBoard.cjs +301 -0
  166. package/vendor/schema/dist/assets.d.ts +335 -0
  167. package/vendor/schema/dist/assets.js +439 -0
  168. package/vendor/schema/dist/brief.d.ts +357 -0
  169. package/vendor/schema/dist/brief.js +302 -0
  170. package/vendor/schema/dist/common.d.ts +9 -0
  171. package/vendor/schema/dist/common.js +13 -0
  172. package/vendor/schema/dist/config.d.ts +406 -0
  173. package/vendor/schema/dist/config.js +355 -0
  174. package/vendor/schema/dist/contract.d.ts +599 -0
  175. package/vendor/schema/dist/contract.js +1146 -0
  176. package/vendor/schema/dist/index.d.ts +14 -0
  177. package/vendor/schema/dist/index.js +21 -0
  178. package/vendor/schema/dist/look.d.ts +463 -0
  179. package/vendor/schema/dist/look.js +681 -0
  180. package/vendor/schema/dist/lookStats.d.ts +230 -0
  181. package/vendor/schema/dist/lookStats.js +768 -0
  182. package/vendor/schema/dist/pilot.d.ts +32 -0
  183. package/vendor/schema/dist/pilot.js +44 -0
  184. package/vendor/schema/dist/publish.d.ts +214 -0
  185. package/vendor/schema/dist/publish.js +291 -0
  186. package/vendor/schema/dist/scene.d.ts +75 -0
  187. package/vendor/schema/dist/scene.js +120 -0
  188. package/vendor/schema/dist/skyLight.d.ts +141 -0
  189. package/vendor/schema/dist/skyLight.js +436 -0
  190. package/vendor/schema/dist/style.d.ts +131 -0
  191. package/vendor/schema/dist/style.js +155 -0
  192. package/vendor/schema/package.json +1 -0
  193. package/vendor/selectionPrompt.mjs +51 -0
  194. package/vendor/useTools.mjs +195 -0
  195. package/vendor/userMessage.mjs +26 -0
  196. package/web-dist/assets/GaussianSplatUtils-CB77cP9U.js +1 -0
  197. package/web-dist/assets/KTX2Loader-6OIWUF7s.js +2 -0
  198. package/web-dist/assets/SPZLoader-zYj0Alfv.js +1 -0
  199. package/web-dist/assets/gaussianSplat-CJTI1sEh.js +1 -0
  200. package/web-dist/assets/index-CcjyyQco.css +1 -0
  201. package/web-dist/assets/index-DMyJcoZJ.js +693 -0
  202. package/web-dist/assets/meshopt_decoder.module-BvwdjiD3.js +1 -0
  203. package/web-dist/assets/zstddec.module-CfFeQW7d.js +1 -0
  204. package/web-dist/index.html +34 -0
@@ -0,0 +1,307 @@
1
+ // The Codex app's image generation, through the creator's own Codex CLI and
2
+ // the ChatGPT account it is logged in with: no key of the studio's, and
3
+ // nothing on the cost card, since it is the creator's plan that is spent,
4
+ // which is why it needs their consent (a host consent card, topic codex,
5
+ // asked once and saved) before the first picture.
6
+ //
7
+ // What one real run taught (2026-10-22, codex-cli 0.163.0-alpha.11 from the
8
+ // ChatGPT app, a plain mug on grey, no picture attached):
9
+ //
10
+ // codex exec --json --color never --skip-git-repo-check --ignore-user-config
11
+ // -s read-only -C <scratch> - (the prompt on stdin)
12
+ //
13
+ // took 28 s, exited 0 and printed JSONL: thread.started { thread_id },
14
+ // turn.started, item.completed (agent_message), turn.completed { usage }.
15
+ // No event names the picture: it lands as a PNG (that run: 1536 x 1024,
16
+ // RGB, 1.6 MB) at $CODEX_HOME/generated_images/<thread_id>/exec-<uuid>.png
17
+ // ($CODEX_HOME is ~/.codex unless set). So a picture is read from that
18
+ // folder after the run; none there, a non-zero exit, a turn.failed or an
19
+ // error event, or no end within the time is a failure, said as Codex said it.
20
+ //
21
+ // The binary is found the way it is installed: the creator's own
22
+ // NOWHERE_CODEX, then each codex on PATH, then the ChatGPT app's own copy
23
+ // and the usual install folders. Each is run for its version first: an npm
24
+ // shim on PATH can be there and not start (its platform binary missing), and
25
+ // is passed over. `codex login status` says whether it is logged in, and
26
+ // how; only a ChatGPT login is the creator's plan. Codex runs with an
27
+ // environment built from scratch (its own home, the path, the language), so
28
+ // no key the studio holds reaches it and it never bills an API key instead
29
+ // of the plan. Everything outside comes in through `deps`, so a check runs a
30
+ // fake binary on a fake machine.
31
+
32
+ import { execFile, spawn as spawnChild } from 'node:child_process'
33
+ import fs from 'node:fs'
34
+ import fsp from 'node:fs/promises'
35
+ import os from 'node:os'
36
+ import path from 'node:path'
37
+
38
+ export const realDeps = {
39
+ platform: process.platform,
40
+ env: process.env,
41
+ home: os.homedir(),
42
+ exists: (p) => fs.existsSync(p),
43
+ run: (cmd, args, timeoutMs, env) =>
44
+ new Promise((resolve) => {
45
+ execFile(cmd, args, { timeout: timeoutMs, windowsHide: true, maxBuffer: 1 << 20, ...(env ? { env } : {}) }, (err, stdout, stderr) => {
46
+ resolve({ code: err ? (typeof err.code === 'number' ? err.code : 1) : 0, stdout: String(stdout ?? ''), stderr: String(stderr ?? '') })
47
+ })
48
+ }),
49
+ spawn: spawnChild,
50
+ now: () => Date.now(),
51
+ }
52
+
53
+ /** How long one picture may take, and each picture after it. */
54
+ export const CODEX_MINUTES = { first: 4, more: 2 }
55
+ const PROBE_MS = 15_000
56
+ const MISS_MS = 60_000
57
+ const cache = new WeakMap()
58
+ const IMAGE = /\.(png|jpe?g|webp)$/i
59
+ /** The Codex runs going now, so a Stop ends them (stopAll). */
60
+ const running = new Set()
61
+
62
+ const envVar = (env, name) => {
63
+ if (env?.[name] !== undefined) return env[name]
64
+ const key = Object.keys(env ?? {}).find((k) => k.toLowerCase() === name.toLowerCase())
65
+ return key ? env[key] : undefined
66
+ }
67
+
68
+ /** Where Codex keeps its home (its login and the pictures it makes). */
69
+ export const codexHome = (deps = realDeps) => envVar(deps.env, 'CODEX_HOME') || path.join(deps.home, '.codex')
70
+
71
+ /** The only variables Codex sees. */
72
+ export function codexEnv(deps = realDeps) {
73
+ const out = { PATH: envVar(deps.env, 'PATH') ?? '', HOME: envVar(deps.env, 'HOME') ?? deps.home, LANG: envVar(deps.env, 'LANG') ?? 'en_US.UTF-8' }
74
+ for (const name of ['CODEX_HOME', 'TMPDIR', 'USER', 'LOGNAME', 'SystemRoot', 'USERPROFILE', 'LOCALAPPDATA', 'APPDATA', 'TEMP', 'TMP']) {
75
+ const v = envVar(deps.env, name)
76
+ if (v !== undefined) out[name] = v
77
+ }
78
+ return out
79
+ }
80
+
81
+ /** Every place a codex may be, in the order they are tried. */
82
+ export function codexPlaces(deps = realDeps) {
83
+ const P = deps.platform === 'win32' ? path.win32 : path.posix
84
+ const names = deps.platform === 'win32' ? ['codex.exe', 'codex.cmd'] : ['codex']
85
+ const own = envVar(deps.env, 'NOWHERE_CODEX')
86
+ const onPath = String(envVar(deps.env, 'PATH') ?? '')
87
+ .split(deps.platform === 'win32' ? ';' : ':')
88
+ .filter(Boolean)
89
+ .flatMap((dir) => names.map((n) => P.join(dir, n)))
90
+ const home = deps.home
91
+ const known =
92
+ deps.platform === 'darwin'
93
+ ? ['/Applications/ChatGPT.app/Contents/Resources/codex-cli/bin/codex', P.join(home, 'Applications', 'ChatGPT.app', 'Contents', 'Resources', 'codex-cli', 'bin', 'codex'), '/opt/homebrew/bin/codex', '/usr/local/bin/codex', P.join(home, '.local', 'bin', 'codex'), P.join(home, '.npm-global', 'bin', 'codex')]
94
+ : deps.platform === 'win32'
95
+ ? [P.join(envVar(deps.env, 'LOCALAPPDATA') ?? P.join(home, 'AppData', 'Local'), 'Programs', 'codex', 'codex.exe'), P.join(envVar(deps.env, 'APPDATA') ?? P.join(home, 'AppData', 'Roaming'), 'npm', 'codex.cmd')]
96
+ : [P.join(home, '.local', 'bin', 'codex'), '/usr/local/bin/codex', '/usr/bin/codex', P.join(home, '.npm-global', 'bin', 'codex')]
97
+ return [...new Set([...(own ? [own] : []), ...onPath, ...known])]
98
+ }
99
+
100
+ /** What `codex login status` said: chatgpt, api-key, or null (not logged in). */
101
+ export function loginOf(text) {
102
+ const t = String(text ?? '')
103
+ if (/not logged in/i.test(t)) return null
104
+ if (/logged in using chatgpt/i.test(t)) return 'chatgpt'
105
+ if (/logged in using an api key/i.test(t)) return 'api-key'
106
+ return /logged in/i.test(t) ? 'other' : null
107
+ }
108
+
109
+ /**
110
+ * The creator's Codex: { path, version, login, places } where one starts
111
+ * (login chatgpt, api-key, other or null), or { error, searched, broken }.
112
+ * Found once per deps; a miss is kept a minute, so a Codex installed or
113
+ * logged into after being told is found on the next request.
114
+ */
115
+ export async function findCodex(deps = realDeps) {
116
+ const hit = cache.get(deps)
117
+ if (hit && ((hit.found && hit.login && deps.exists(hit.found)) || deps.now() - hit.at < MISS_MS)) return hit.promise
118
+ const promise = search(deps)
119
+ cache.set(deps, { promise, at: deps.now(), found: null })
120
+ const result = await promise
121
+ cache.set(deps, { promise, at: deps.now(), found: result.path ?? null, login: result.login ?? null })
122
+ return result
123
+ }
124
+
125
+ async function search(deps) {
126
+ const searched = []
127
+ const broken = []
128
+ const env = codexEnv(deps)
129
+ for (const exe of codexPlaces(deps)) {
130
+ searched.push(exe)
131
+ if (!deps.exists(exe)) continue
132
+ const v = await deps.run(exe, ['--version'], PROBE_MS, env)
133
+ const version = /codex[\w-]*\s+([\w.+-]+)/i.exec(v.stdout)?.[1] ?? null
134
+ if (v.code !== 0 || !version) {
135
+ broken.push(exe)
136
+ continue
137
+ }
138
+ const s = await deps.run(exe, ['login', 'status'], PROBE_MS, env)
139
+ return { path: exe, version, login: loginOf(`${s.stdout}\n${s.stderr}`), searched, broken }
140
+ }
141
+ return { error: broken.length ? `Codex is on this computer but does not start (${broken.join(', ')}); reinstall it, or install the ChatGPT app.` : 'Codex is not installed on this computer (the ChatGPT app ships it).', searched, broken }
142
+ }
143
+
144
+ /** The one message Codex is sent: the pictures to make, each with its own
145
+ * words, made with its image tool and nothing else. */
146
+ export function codexPrompt(prompts, inputs = 0) {
147
+ const each = prompts.length === 1 ? prompts[0] : prompts.map((p, i) => `Picture ${i + 1}:\n${p}`).join('\n\n')
148
+ return [
149
+ `Use your image generation tool to make ${prompts.length === 1 ? 'one picture' : `${prompts.length} pictures, one call of the tool each`}, and do nothing else: run no shell command and write no file.`,
150
+ inputs ? `The attached picture${inputs === 1 ? ' is' : 's are'} what to start from, as the words below say.` : '',
151
+ each,
152
+ `When ${prompts.length === 1 ? 'the picture is' : 'the pictures are'} made, answer with the one word DONE.`,
153
+ ]
154
+ .filter(Boolean)
155
+ .join('\n\n')
156
+ }
157
+
158
+ /** The pictures a Codex thread made since `since`, oldest first. */
159
+ async function picturesOf(home, threadId, since) {
160
+ const dirs = []
161
+ const root = path.join(home, 'generated_images')
162
+ if (threadId) dirs.push(path.join(root, threadId))
163
+ else {
164
+ // No thread id came back: the folders written since the run began.
165
+ for (const name of await fsp.readdir(root).catch(() => [])) {
166
+ const st = await fsp.stat(path.join(root, name)).catch(() => null)
167
+ if (st?.isDirectory() && st.mtimeMs >= since) dirs.push(path.join(root, name))
168
+ }
169
+ }
170
+ const found = []
171
+ for (const dir of dirs) {
172
+ for (const name of await fsp.readdir(dir).catch(() => [])) {
173
+ if (!IMAGE.test(name)) continue
174
+ const st = await fsp.stat(path.join(dir, name)).catch(() => null)
175
+ if (st?.isFile() && st.mtimeMs >= since) found.push({ file: path.join(dir, name), at: st.mtimeMs })
176
+ }
177
+ }
178
+ return found.sort((a, b) => a.at - b.at).map((f) => f.file)
179
+ }
180
+
181
+ /** What Codex said went wrong, from its events and its error output. */
182
+ function failureOf(events, stderr) {
183
+ for (const e of [...events].reverse()) {
184
+ if (e?.type === 'turn.failed') return String(e.error?.message ?? e.message ?? 'the turn failed')
185
+ if (e?.type === 'error') return String(e.message ?? e.error?.message ?? 'an error')
186
+ }
187
+ const last = String(stderr ?? '').trim().split('\n').filter(Boolean).at(-1)
188
+ return last ? last.slice(0, 300) : null
189
+ }
190
+
191
+ /**
192
+ * One run of Codex for `prompts` (one picture each), starting from the
193
+ * picture files `inputs` (absolute paths). Answers [{ mime, data, file }]
194
+ * or throws with what went wrong. `signal` stops it.
195
+ */
196
+ export async function runCodex({ bin, prompts, inputs = [], workDir, deps = realDeps, signal = null, timeoutMs = null }) {
197
+ const home = codexHome(deps)
198
+ const since = deps.now() - 2000
199
+ await fsp.mkdir(workDir, { recursive: true })
200
+ const args = ['exec', '--json', '--color', 'never', '--skip-git-repo-check', '--ignore-user-config', '-s', 'read-only', '-C', workDir, ...inputs.map((f) => `--image=${f}`), '-']
201
+ const limit = timeoutMs ?? (CODEX_MINUTES.first + CODEX_MINUTES.more * Math.max(0, prompts.length - 1)) * 60_000
202
+ const out = await new Promise((resolve) => {
203
+ let stdout = ''
204
+ let stderr = ''
205
+ let settled = false
206
+ const child = deps.spawn(bin, args, { cwd: workDir, env: codexEnv(deps), stdio: ['pipe', 'pipe', 'pipe'], windowsHide: true })
207
+ running.add(child)
208
+ const finish = (r) => {
209
+ if (settled) return
210
+ settled = true
211
+ running.delete(child)
212
+ clearTimeout(timer)
213
+ signal?.removeEventListener?.('abort', abort)
214
+ resolve({ stdout, stderr, ...r, ...(child.nwStopped ? { stopped: true } : {}) })
215
+ }
216
+ const abort = () => {
217
+ child.kill('SIGTERM')
218
+ finish({ code: null, stopped: true })
219
+ }
220
+ const timer = setTimeout(() => {
221
+ child.kill('SIGTERM')
222
+ finish({ code: null, timedOut: true })
223
+ }, limit)
224
+ timer.unref?.()
225
+ signal?.addEventListener?.('abort', abort)
226
+ child.stdout.on('data', (d) => {
227
+ if (stdout.length < 1 << 20) stdout += d
228
+ })
229
+ child.stderr.on('data', (d) => {
230
+ if (stderr.length < 64 << 10) stderr += d
231
+ })
232
+ child.on('error', (err) => finish({ code: null, error: err.message }))
233
+ child.on('close', (code) => finish({ code }))
234
+ child.stdin.on('error', () => {})
235
+ child.stdin.end(codexPrompt(prompts, inputs.length))
236
+ })
237
+ if (out.stopped) throw new Error('The request was stopped, so Codex was stopped too.')
238
+ if (out.error) throw new Error(`Codex could not be started (${out.error}).`)
239
+ if (out.timedOut) throw new Error(`Codex did not finish within ${Math.round(limit / 60_000)} minutes, so it was stopped.`)
240
+ const events = out.stdout
241
+ .split('\n')
242
+ .map((l) => {
243
+ try {
244
+ return JSON.parse(l)
245
+ } catch {
246
+ return null
247
+ }
248
+ })
249
+ .filter(Boolean)
250
+ const threadId = events.find((e) => e.type === 'thread.started')?.thread_id ?? null
251
+ const why = failureOf(events, out.stderr)?.replace(/\.+$/, '') ?? null
252
+ if (out.code !== 0) throw new Error(`Codex stopped with exit code ${out.code}${why ? `: ${why}` : ''}.`)
253
+ if (events.some((e) => e.type === 'turn.failed' || e.type === 'error')) throw new Error(`Codex could not make it: ${why}.`)
254
+ const files = (await picturesOf(home, threadId, since)).slice(-prompts.length)
255
+ if (!files.length) {
256
+ const said = events.filter((e) => e.type === 'item.completed' && e.item?.type === 'agent_message').map((e) => e.item.text).at(-1)
257
+ throw new Error(`Codex finished but made no picture${said ? ` (it said: ${String(said).trim().slice(0, 200).replace(/\.+$/, '')})` : ''}.`)
258
+ }
259
+ const pictures = []
260
+ for (const file of files) {
261
+ const data = await fsp.readFile(file)
262
+ pictures.push({ mime: /\.jpe?g$/i.test(file) ? 'image/jpeg' : /\.webp$/i.test(file) ? 'image/webp' : 'image/png', data: data.toString('base64'), file })
263
+ }
264
+ return pictures
265
+ }
266
+
267
+ /** Every Codex run going now is stopped (the creator's Stop). */
268
+ export function stopAll() {
269
+ for (const child of running) {
270
+ child.nwStopped = true
271
+ try {
272
+ child.kill('SIGTERM')
273
+ } catch {
274
+ // already gone
275
+ }
276
+ }
277
+ }
278
+
279
+ export const codex = {
280
+ id: 'codex',
281
+ label: 'Codex',
282
+ connector: null,
283
+ envVar: null,
284
+ hosts: [],
285
+ paid: false,
286
+
287
+ /** Codex picks its own image model; the studio names none. */
288
+ defaultModel() {
289
+ return 'codex'
290
+ },
291
+
292
+ licenseOf() {
293
+ return { spdx: 'LicenseRef-Generated-Owned', url: 'https://openai.com/policies/terms-of-use' }
294
+ },
295
+
296
+ refuse(model, { inputs = 0 } = {}) {
297
+ if (model !== 'codex') return 'Codex chooses its own image model: leave model out.'
298
+ if (inputs > 4) return 'Codex here takes at most four pictures to start from.'
299
+ return null
300
+ },
301
+
302
+ price(_model, _options, prices) {
303
+ const p = prices?.images?.codex
304
+ if (!p) return null
305
+ return { low: Number(p.usd) || 0, high: Number(p.usd) || 0, unit: `the creator's ${p.plan ?? 'ChatGPT'} plan` }
306
+ },
307
+ }
@@ -0,0 +1,75 @@
1
+ // fal's hosted FLUX.2 [pro], text to picture and picture plus text to
2
+ // picture, with the creator's key (connector fal, env FAL_KEY, Authorization:
3
+ // Key ...), through fal.run, the synchronous form of the queue the 3D side
4
+ // uses (assets/providers/fal.mjs). The models' pages (read 2026-10-22) give
5
+ // their inputs, outputs and prices and mark them for commercial use; NOT
6
+ // exercised against the live API from here: the checks use a fake. Verify
7
+ // one real picture before release.
8
+ //
9
+ // POST https://fal.run/fal-ai/flux-2-pro { prompt, image_size, output_format, num_images }
10
+ // POST https://fal.run/fal-ai/flux-2-pro/edit the same and image_urls (data URIs, at most 9)
11
+ // both answer { images: [{ url, content_type }] }, files on fal.media
12
+ //
13
+ // The key goes only to fal.run; the files are fetched without it.
14
+
15
+ import { fetchJson, safeFetch } from '../net.mjs'
16
+ import { eachView } from './views.mjs'
17
+
18
+ const RUN = 'https://fal.run'
19
+
20
+ /** The models image_generate may run on fal: one makes a picture from
21
+ * words, the other from pictures and words. */
22
+ export const MODELS = {
23
+ 'fal-ai/flux-2-pro': { inputs: false, license: { spdx: 'LicenseRef-Generated-Owned', url: 'https://fal.ai/terms' } },
24
+ 'fal-ai/flux-2-pro/edit': { inputs: true, license: { spdx: 'LicenseRef-Generated-Owned', url: 'https://fal.ai/terms' } },
25
+ }
26
+
27
+ const SIZES = { square: 'square_hd', tall: 'portrait_4_3', wide: 'landscape_4_3' }
28
+ const MAX_PICTURE = 20 * 1024 * 1024
29
+
30
+ export const fal = {
31
+ id: 'fal',
32
+ label: 'fal',
33
+ connector: 'fal',
34
+ envVar: 'FAL_KEY',
35
+ hosts: ['fal.run', 'fal.media', '*.fal.media'],
36
+ paid: true,
37
+
38
+ /** The model for a request: the edit model when it starts from pictures. */
39
+ defaultModel({ inputs = 0 } = {}) {
40
+ return inputs > 0 ? 'fal-ai/flux-2-pro/edit' : 'fal-ai/flux-2-pro'
41
+ },
42
+
43
+ licenseOf(model) {
44
+ return MODELS[model]?.license ?? { spdx: 'LicenseRef-Unknown' }
45
+ },
46
+
47
+ refuse(model, { inputs = 0 } = {}) {
48
+ const m = MODELS[model]
49
+ if (!m) return `fal model ${model} is not in the studio's table, so what it costs and whose its pictures are is unknown. Use one of: ${Object.keys(MODELS).join(', ')}.`
50
+ if (inputs > 0 && !m.inputs) return `${model} makes a picture from words only; start from pictures with fal-ai/flux-2-pro/edit.`
51
+ if (inputs === 0 && m.inputs) return `${model} starts from pictures; with none, use fal-ai/flux-2-pro.`
52
+ if (inputs > 2) return 'fal here takes at most two pictures to start from.'
53
+ return null
54
+ },
55
+
56
+ price(model, _options, prices) {
57
+ const p = prices?.images?.fal?.[model]
58
+ if (!Array.isArray(p) || !p.every(Number.isFinite)) return null
59
+ return { low: p[0], high: p[1], unit: 'per picture' }
60
+ },
61
+
62
+ generate({ model, prompts, inputs = [], size = 'square', key, fetch, ua }) {
63
+ return eachView(prompts, async (prompt) => {
64
+ const body = { prompt, image_size: SIZES[size] ?? SIZES.square, output_format: 'png', num_images: 1, ...(inputs.length ? { image_urls: inputs.map((p) => `data:${p.mime};base64,${p.data}`) } : {}) }
65
+ const r = await fetchJson(`${RUN}/${model}`, { fetch, hosts: ['fal.run'], ua, method: 'POST', headers: { authorization: `Key ${key}`, 'content-type': 'application/json' }, body: JSON.stringify(body) })
66
+ const url = r?.images?.[0]?.url
67
+ if (typeof url !== 'string') throw new Error(`fal answered without a picture${r?.detail ? `: ${String(typeof r.detail === 'string' ? r.detail : JSON.stringify(r.detail)).slice(0, 200)}` : ''}.`)
68
+ const { res } = await safeFetch(url, { fetch, hosts: fal.hosts, ua })
69
+ if (!res.ok) throw new Error(`fal's picture could not be fetched (${res.status}).`)
70
+ const buf = Buffer.from(await res.arrayBuffer())
71
+ if (buf.length > MAX_PICTURE) throw new Error('fal\'s picture is over 20 MB.')
72
+ return { mime: r.images[0].content_type === 'image/jpeg' ? 'image/jpeg' : 'image/png', data: buf.toString('base64') }
73
+ })
74
+ },
75
+ }
@@ -0,0 +1,84 @@
1
+ // Google's Gemini image models, through the Interactions API with the
2
+ // creator's key (connector gemini, env GEMINI_API_KEY, x-goog-api-key). The
3
+ // shape is Google's documented one (ai.google.dev image generation guide and
4
+ // Interactions API reference, read 2026-10-22), NOT exercised against the
5
+ // live API from here: the checks use a fake. Verify one real picture before
6
+ // release.
7
+ //
8
+ // POST https://generativelanguage.googleapis.com/v1beta/interactions
9
+ // { model, input: [{ type: 'text', text }, { type: 'image', mime_type, data }...],
10
+ // response_format: { type: 'image', mime_type, aspect_ratio, image_size } }
11
+ // answers { status, steps: [{ type: 'model_output', content: [{ type: 'image', data, mime_type }] }], errors? }
12
+ //
13
+ // The Gemini API's terms leave what it makes to the caller, so a picture is
14
+ // the creator's (LicenseRef-Generated-Owned).
15
+
16
+ import { fetchJson } from '../net.mjs'
17
+ import { eachView } from './views.mjs'
18
+
19
+ const API = 'https://generativelanguage.googleapis.com/v1beta/interactions'
20
+
21
+ /** The models image_generate may run on Gemini. */
22
+ export const MODELS = {
23
+ 'gemini-nano-banana-2.1': { license: { spdx: 'LicenseRef-Generated-Owned', url: 'https://ai.google.dev/gemini-api/terms' } },
24
+ 'gemini-3-pro-image': { license: { spdx: 'LicenseRef-Generated-Owned', url: 'https://ai.google.dev/gemini-api/terms' } },
25
+ }
26
+
27
+ const RATIOS = { square: '1:1', tall: '2:3', wide: '3:2' }
28
+
29
+ /** The last picture an interaction made, or null. */
30
+ function pictureOf(r) {
31
+ let found = null
32
+ for (const step of Array.isArray(r?.steps) ? r.steps : []) {
33
+ if (step?.type !== 'model_output') continue
34
+ for (const block of Array.isArray(step.content) ? step.content : []) {
35
+ if (block?.type === 'image' && typeof block.data === 'string' && block.data) found = { mime: block.mime_type === 'image/jpeg' ? 'image/jpeg' : 'image/png', data: block.data }
36
+ }
37
+ }
38
+ return found ?? (typeof r?.output_image?.data === 'string' ? { mime: r.output_image.mime_type === 'image/jpeg' ? 'image/jpeg' : 'image/png', data: r.output_image.data } : null)
39
+ }
40
+
41
+ export const gemini = {
42
+ id: 'gemini',
43
+ label: 'Gemini',
44
+ connector: 'gemini',
45
+ envVar: 'GEMINI_API_KEY',
46
+ hosts: ['generativelanguage.googleapis.com'],
47
+ paid: true,
48
+
49
+ defaultModel() {
50
+ return 'gemini-nano-banana-2.1'
51
+ },
52
+
53
+ licenseOf(model) {
54
+ return MODELS[model]?.license ?? { spdx: 'LicenseRef-Unknown' }
55
+ },
56
+
57
+ refuse(model) {
58
+ return MODELS[model] ? null : `Gemini model ${model} is not in the studio's table, so what it costs and whose its pictures are is unknown. Use one of: ${Object.keys(MODELS).join(', ')}.`
59
+ },
60
+
61
+ /** One 1K picture, with its inputs, from prices.json. */
62
+ price(model, { inputs = 0 } = {}, prices) {
63
+ const p = prices?.images?.gemini?.[model]
64
+ const one = Number(p?.['1K'])
65
+ if (!Number.isFinite(one)) return null
66
+ const usd = one + (Number(p.input) || 0) * inputs
67
+ return { low: usd, high: usd, unit: '1K picture' }
68
+ },
69
+
70
+ generate({ model, prompts, inputs = [], size = 'square', key, fetch, ua }) {
71
+ return eachView(prompts, async (prompt) => {
72
+ const body = {
73
+ model,
74
+ input: [{ type: 'text', text: prompt }, ...inputs.map((p) => ({ type: 'image', mime_type: p.mime, data: p.data }))],
75
+ response_format: { type: 'image', mime_type: 'image/png', aspect_ratio: RATIOS[size] ?? RATIOS.square, image_size: '1K' },
76
+ }
77
+ const r = await fetchJson(API, { fetch, hosts: gemini.hosts, ua, method: 'POST', headers: { 'x-goog-api-key': key, 'content-type': 'application/json' }, body: JSON.stringify(body) })
78
+ if (r?.status === 'failed' || (Array.isArray(r?.errors) && r.errors.length)) throw new Error(`Gemini could not make it: ${String(r.errors?.[0]?.message ?? r.status).slice(0, 200)}`)
79
+ const pic = pictureOf(r)
80
+ if (!pic) throw new Error('Gemini answered without a picture.')
81
+ return pic
82
+ })
83
+ },
84
+ }
@@ -0,0 +1,25 @@
1
+ // The image generators image_generate can run, behind one shape:
2
+ // { id, label, connector, envVar, hosts, paid, defaultModel({ inputs }),
3
+ // licenseOf(model), refuse(model, { inputs }), price(model, options, prices),
4
+ // generate({ model, prompts, inputs, size, quality, key, fetch, ua }) }
5
+ // where generate makes one picture a prompt (views.mjs eachView), and one
6
+ // that fails after some throws with those it made (err.made).
7
+ // Codex has no generate of its own here: it runs the creator's CLI
8
+ // (codex.mjs runCodex), on their ChatGPT plan, after their consent. The paid
9
+ // ones run only after the creator approved a cost card that covers them, and
10
+ // every check drives them with a fake fetch or a fake binary.
11
+ //
12
+ // A picture made for image-to-3D is one object, whole: what a reconstruction
13
+ // needs is in the words of the prompt, written for each asset. Several views
14
+ // of it are made one picture each (views.mjs).
15
+
16
+ import { codex } from './codex.mjs'
17
+ import { fal } from './fal.mjs'
18
+ import { gemini } from './gemini.mjs'
19
+ import { openai } from './openai.mjs'
20
+ import { stability } from './stability.mjs'
21
+
22
+ export { VIEW_WORDS, viewPrompts } from './views.mjs'
23
+
24
+ export const IMAGE_PROVIDERS = { codex, openai, gemini, fal, stability }
25
+ export const IMAGE_PROVIDER_IDS = Object.keys(IMAGE_PROVIDERS)
@@ -0,0 +1,75 @@
1
+ // OpenAI's GPT Image models, through the Image API with the creator's key
2
+ // (connector openai, env OPENAI_API_KEY, Authorization: Bearer). The shapes
3
+ // are OpenAI's documented ones (developers.openai.com image generation
4
+ // guide, read 2026-10-22), NOT exercised against the live API from here:
5
+ // the checks use a fake. Verify one real picture before release.
6
+ //
7
+ // POST https://api.openai.com/v1/images/generations JSON { model, prompt, n, size, quality, output_format }
8
+ // POST https://api.openai.com/v1/images/edits multipart, the same fields and image[] (the pictures to start from)
9
+ // both answer { data: [{ b64_json }] }
10
+ //
11
+ // OpenAI's terms give what the models make to the caller, so a picture is
12
+ // the creator's (LicenseRef-Generated-Owned).
13
+
14
+ import { fetchJson } from '../net.mjs'
15
+ import { eachView } from './views.mjs'
16
+
17
+ const API = 'https://api.openai.com/v1/images'
18
+
19
+ /** The models image_generate may run on OpenAI. */
20
+ export const MODELS = {
21
+ 'gpt-image-2.5-flare': { license: { spdx: 'LicenseRef-Generated-Owned', url: 'https://openai.com/policies/terms-of-use' } },
22
+ 'gpt-image-2.5-sunburst': { license: { spdx: 'LicenseRef-Generated-Owned', url: 'https://openai.com/policies/terms-of-use' } },
23
+ }
24
+
25
+ /** The picture shapes as the API names them. */
26
+ const SIZES = { square: '1024x1024', tall: '1024x1536', wide: '1536x1024' }
27
+
28
+ export const openai = {
29
+ id: 'openai',
30
+ label: 'OpenAI',
31
+ connector: 'openai',
32
+ envVar: 'OPENAI_API_KEY',
33
+ hosts: ['api.openai.com'],
34
+ paid: true,
35
+
36
+ defaultModel() {
37
+ return 'gpt-image-2.5-flare'
38
+ },
39
+
40
+ licenseOf(model) {
41
+ return MODELS[model]?.license ?? { spdx: 'LicenseRef-Unknown' }
42
+ },
43
+
44
+ refuse(model) {
45
+ return MODELS[model] ? null : `OpenAI model ${model} is not in the studio's table, so what it costs and whose its pictures are is unknown. Use one of: ${Object.keys(MODELS).join(', ')}.`
46
+ },
47
+
48
+ /** One picture, lower and upper, with its inputs, from prices.json. */
49
+ price(model, { quality = 'medium', inputs = 0 } = {}, prices) {
50
+ const p = prices?.images?.openai?.[model]
51
+ const one = Number(p?.[quality])
52
+ if (!Number.isFinite(one)) return null
53
+ const extra = (Number(p.input) || 0) * inputs
54
+ return { low: Number(p.low) + extra, high: one + extra, unit: `${quality} quality, per picture` }
55
+ },
56
+
57
+ /** `views` pictures, one request each. */
58
+ generate({ model, prompts, inputs = [], size = 'square', quality = 'medium', key, fetch, ua }) {
59
+ return eachView(prompts, async (prompt) => {
60
+ const fields = { model, prompt, n: 1, size: SIZES[size] ?? SIZES.square, quality, output_format: 'png' }
61
+ let r
62
+ if (inputs.length) {
63
+ const form = new FormData()
64
+ for (const [k, v] of Object.entries(fields)) form.append(k, String(v))
65
+ inputs.forEach((pic, i) => form.append('image[]', new Blob([Buffer.from(pic.data, 'base64')], { type: pic.mime }), `input-${i + 1}.${pic.mime === 'image/jpeg' ? 'jpg' : 'png'}`))
66
+ r = await fetchJson(`${API}/edits`, { fetch, hosts: openai.hosts, ua, method: 'POST', headers: { authorization: `Bearer ${key}` }, body: form })
67
+ } else {
68
+ r = await fetchJson(`${API}/generations`, { fetch, hosts: openai.hosts, ua, method: 'POST', headers: { authorization: `Bearer ${key}`, 'content-type': 'application/json' }, body: JSON.stringify(fields) })
69
+ }
70
+ const b64 = r?.data?.[0]?.b64_json
71
+ if (typeof b64 !== 'string' || !b64) throw new Error('OpenAI answered without a picture.')
72
+ return { mime: 'image/png', data: b64 }
73
+ })
74
+ },
75
+ }
@@ -0,0 +1,71 @@
1
+ // Stability AI's Stable Image Ultra, with the creator's key (connector
2
+ // stability, env STABILITY_API_KEY, Authorization: Bearer). The shape is the
3
+ // documented v2beta one (docs.stability.ai API reference and pricing, read
4
+ // 2026-10-22), NOT exercised against the live API from here: the checks use
5
+ // a fake. Verify one real picture before release.
6
+ //
7
+ // POST https://api.stability.ai/v2beta/stable-image/generate/ultra
8
+ // multipart: prompt, output_format, aspect_ratio (from words) or
9
+ // image and strength (from a picture); Accept: application/json
10
+ // answers { image (base64), finish_reason, seed }; finish_reason
11
+ // CONTENT_FILTERED is a refusal
12
+ //
13
+ // Stability's terms give a paying caller what it makes, so a picture is the
14
+ // creator's (LicenseRef-Generated-Owned).
15
+
16
+ import { fetchJson } from '../net.mjs'
17
+ import { eachView } from './views.mjs'
18
+
19
+ const API = 'https://api.stability.ai/v2beta/stable-image/generate'
20
+
21
+ export const MODELS = { ultra: { license: { spdx: 'LicenseRef-Generated-Owned' } } }
22
+
23
+ const RATIOS = { square: '1:1', tall: '2:3', wide: '3:2' }
24
+
25
+ export const stability = {
26
+ id: 'stability',
27
+ label: 'Stability AI',
28
+ connector: 'stability',
29
+ envVar: 'STABILITY_API_KEY',
30
+ hosts: ['api.stability.ai'],
31
+ paid: true,
32
+
33
+ defaultModel() {
34
+ return 'ultra'
35
+ },
36
+
37
+ licenseOf(model) {
38
+ return MODELS[model]?.license ?? { spdx: 'LicenseRef-Unknown' }
39
+ },
40
+
41
+ refuse(model, { inputs = 0 } = {}) {
42
+ if (!MODELS[model]) return `Stability model ${model} is not in the studio's table. Use one of: ${Object.keys(MODELS).join(', ')}.`
43
+ if (inputs > 1) return 'Stable Image Ultra starts from one picture at most.'
44
+ return null
45
+ },
46
+
47
+ price(model, _options, prices) {
48
+ const credits = Number(prices?.images?.stability?.[model])
49
+ const credit = Number(prices?.images?.stability?.creditUsd)
50
+ if (!Number.isFinite(credits) || !Number.isFinite(credit)) return null
51
+ return { low: credits * credit, high: credits * credit, unit: `${credits} credits` }
52
+ },
53
+
54
+ generate({ model, prompts, inputs = [], size = 'square', key, fetch, ua }) {
55
+ return eachView(prompts, async (prompt) => {
56
+ const form = new FormData()
57
+ form.append('prompt', prompt)
58
+ form.append('output_format', 'png')
59
+ if (inputs.length) {
60
+ form.append('image', new Blob([Buffer.from(inputs[0].data, 'base64')], { type: inputs[0].mime }), inputs[0].mime === 'image/jpeg' ? 'input.jpg' : 'input.png')
61
+ // How far the picture may move from the one it starts from (0 to 1):
62
+ // a clean view of the same object, not a copy of the crop.
63
+ form.append('strength', '0.6')
64
+ } else form.append('aspect_ratio', RATIOS[size] ?? RATIOS.square)
65
+ const r = await fetchJson(`${API}/${model}`, { fetch, hosts: stability.hosts, ua, method: 'POST', headers: { authorization: `Bearer ${key}`, accept: 'application/json' }, body: form })
66
+ if (r?.finish_reason && r.finish_reason !== 'SUCCESS') throw new Error(`Stability did not make it (${r.finish_reason}).`)
67
+ if (typeof r?.image !== 'string' || !r.image) throw new Error('Stability answered without a picture.')
68
+ return { mime: 'image/png', data: r.image }
69
+ })
70
+ },
71
+ }