Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
refactor: share the image-gen capability literals from a server/lib leaf (#6590)
[._.]/ Adam Eivyb9ce05587a46
diff --git a/client/src/components/settings/ImageGenTab.jsx b/client/src/components/settings/ImageGenTab.jsxindex cd59fc7eca..721ce8c37b 100644--- a/client/src/components/settings/ImageGenTab.jsx+++ b/client/src/components/settings/ImageGenTab.jsx@@ -24,7 +24,7 @@ import {registerTool, updateTool, getToolsList,saveHfToken, clearHfToken,} from '../../services/api';-import { deriveAvailableBackends, imageGenReadiness, isCloudCliMode, IMAGE_GEN_MODE, AGY_IMAGEGEN_DEFAULT_MODEL, AGY_IMAGEGEN_IMAGE_MODEL, CODEX_IMAGEGEN_DEFAULT_EFFORT, GROK_ASPECT_RATIOS, RENDER_TARGET_BACKEND_AUTO, RENDER_TARGET_OPTIONS, VIDEO_RENDER_MODES, modeLabel, normalizeRenderPinValue, supportsCloudModelOverride } from '../../lib/imageGenBackends';+import { deriveAvailableBackends, imageGenReadiness, isCloudCliMode, IMAGE_GEN_MODE, AGY_IMAGEGEN_DEFAULT_MODEL, AGY_IMAGEGEN_IMAGE_MODEL, CODEX_IMAGEGEN_DEFAULT_EFFORT, CODEX_IMAGEGEN_DEFAULT_MODEL, GROK_ASPECT_RATIOS, RENDER_TARGET_BACKEND_AUTO, RENDER_TARGET_OPTIONS, VIDEO_RENDER_MODES, modeLabel, normalizeRenderPinValue, supportsCloudModelOverride } from '../../lib/imageGenBackends';import { resolveCleanersFromConfig } from '../../lib/imageCleaners';import { useMediaJobSse } from '../../hooks/useMediaJobSse';import { useAgyModels } from '../../hooks/useAgyModels';@@ -37,11 +37,6 @@ const GROK_TOOL_ID = 'grok-imagegen';const AGY_TOOL_ID = 'agy-imagegen';// Mirror of server/services/imageGen/modes.js — shown as placeholder/default// hints so the user sees what a blank Model / Effort field will actually use.-// The server owns the real default; these are display-only. The effort default-// lives in the shared imageGenBackends lib (imported above) so the Render Queue-// and this settings form don't drift; the model default stays local (only used-// here as a placeholder string).-const CODEX_IMAGEGEN_DEFAULT_MODEL = 'gpt-5.6-luna';const DEFAULT_TEST_PROMPT = 'a small cyberpunk fox sitting on a neon-lit rooftop at night, cinematic, highly detailed';const normalizeUrl = (url) => (url || '').trim().replace(/\/+$/, '');diff --git a/client/src/lib/imageGenBackends.test.js b/client/src/lib/imageGenBackends.test.jsindex 42dd10b1a7..38071454b9 100644--- a/client/src/lib/imageGenBackends.test.js+++ b/client/src/lib/imageGenBackends.test.js@@ -2,8 +2,8 @@ import { describe, it, expect } from 'vitest';import {IMAGE_GEN_MODE,I2I_CAPABLE_MODES,- MAX_INPUT_IMAGES,cloudPromptRequired,+ maxInputImages,isI2iCapableMode,pickI2iMode,referenceSlotsFor,@@ -40,12 +40,12 @@ describe('I2I_CAPABLE_MODES / isI2iCapableMode', () => {describe('input-image capability helpers', () => {it('caps agy at the 3 images its generate_image tool accepts', () => {- expect(MAX_INPUT_IMAGES[IMAGE_GEN_MODE.AGY]).toBe(3);- // The other two declare no maximum, so they carry no entry at all — the- // form's own slot count is their only ceiling. Restating it here as a+ expect(maxInputImages(IMAGE_GEN_MODE.AGY)).toBe(3);+ // The other two declare no maximum, so they report null — the form's own+ // slot count is their only ceiling. Restating a number here as a// "capability" would make a form change look like a provider limit.- expect(MAX_INPUT_IMAGES[IMAGE_GEN_MODE.CODEX]).toBeUndefined();- expect(MAX_INPUT_IMAGES[IMAGE_GEN_MODE.GROK]).toBeUndefined();+ expect(maxInputImages(IMAGE_GEN_MODE.CODEX)).toBeNull();+ expect(maxInputImages(IMAGE_GEN_MODE.GROK)).toBeNull();});it('lets codex/grok render image-only but always demands a prompt for agy', () => {diff --git a/client/src/lib/imageGenModes.js b/client/src/lib/imageGenModes.jsindex 715f7dd433..65c503fdd8 100644--- a/client/src/lib/imageGenModes.js+++ b/client/src/lib/imageGenModes.js@@ -4,22 +4,23 @@* parity suite (`server/lib/renderTargets.parity.test.js`) and the server CI* job import this module directly, where client-only packages (lucide-react)* are not installed. Nothing here may import React, icons, or any package —- * the only imports allowed are the two dependency-free server leaves below,+ * the only imports allowed are the three dependency-free server leaves below,* the same way `Layout.jsx` reads `server/lib/navManifest.js`. Icon metadata* and settings-driven backend derivation stay in `imageGenBackends.js`, which* re-exports everything below so client consumers keep a single import site.*- * The backend / render-target / execution-lane ALPHABETS are not copied here:- * they are re-exported from `server/lib/generationModes.js` and- * `server/lib/renderTargets.js`, so a backend added server-side reaches every- * client picker and the Render Queue's lane grouping in the same commit. A- * hand-copied alphabet is how fal.ai and Reactor video renders came to be- * filed under "Local machine" (#6292). What remains a mirror is only what- * lives in server SERVICE modules the browser bundle cannot load (per-provider- * capability specs, shipped default models) — each is labeled below. The- * parity suite binds `I2I_CAPABLE_MODES`, `MAX_INPUT_IMAGES` and- * `cloudPromptRequired`; the shipped defaults and `GROK_ASPECT_RATIOS` are- * unbound copies.+ * NOTHING here is a hand-copied server fact. The backend / render-target /+ * execution-lane ALPHABETS re-export from `server/lib/generationModes.js` and+ * `server/lib/renderTargets.js`, and the per-backend CAPABILITY literals —+ * input-image caps, the prompt rule, model-override support, the shipped+ * default models/effort, the aspect-ratio alphabets — from+ * `server/lib/imageGenCapabilities.js` (#6590). So a backend added or re-probed+ * server-side reaches every client picker in the same commit. A hand-copied+ * alphabet is how fal.ai and Reactor video renders came to be filed under+ * "Local machine" (#6292), and the shipped defaults were free to drift+ * silently until the capability leaf existed. What stays local to this module+ * is only what the CLIENT owns: display labels, the Settings row list, and the+ * form's own slot/strength predicates.*/import {@@ -36,39 +37,59 @@ import {RENDER_TARGET_BACKEND_AUTO,normalizeRenderPinValue,} from '../../../server/lib/renderTargets.js';+import {+ AGY_IMAGEGEN_DEFAULT_MODEL,+ AGY_IMAGEGEN_IMAGE_MODEL,+ CODEX_IMAGEGEN_DEFAULT_EFFORT,+ CODEX_IMAGEGEN_DEFAULT_MODEL,+ GROK_ASPECT_RATIOS,+ I2I_CAPABLE_MODES,+ MODEL_OVERRIDE_CAPABLE_MODES,+ cloudPromptRequired,+ maxInputImages,+ supportsCloudModelOverride,+} from '../../../server/lib/imageGenCapabilities.js';export {+ // Shipped per-backend defaults, so a UI that displays "the model/effort a job+ // used" resolves an absent value to what actually renders rather than to a+ // blank or to the CLI's own default (which stopped being true when the pins+ // shipped).+ AGY_IMAGEGEN_DEFAULT_MODEL,+ // The image model behind agy's generate_image tool — fixed by Antigravity and+ // NOT selectable by PortOS, surfaced read-only in Settings so the+ // agent-model field can't be mistaken for an image-model picker.+ AGY_IMAGEGEN_IMAGE_MODEL,CLOUD_IMAGE_GEN_MODES,+ CODEX_IMAGEGEN_DEFAULT_EFFORT,+ CODEX_IMAGEGEN_DEFAULT_MODEL,+ // The ratios grok's image tools accept — the Settings default-ratio picker.+ GROK_ASPECT_RATIOS,+ // Backends that support image-to-image, ordered best-first: what the i2i-only+ // pickers filter through and what `pickI2iMode` walks.+ I2I_CAPABLE_MODES,IMAGE_GEN_MODE,+ // Cloud CLIs that accept a per-render model override. Use+ // `supportsCloudModelOverride` at branch sites rather than a hand-rolled+ // `mode === CODEX || mode === AGY` disjunction.+ MODEL_OVERRIDE_CAPABLE_MODES,RENDER_TARGET,RENDER_TARGET_BACKEND_AUTO,// The backend alphabet for the video pin controls and the install-wide// `settings.videoGen.mode` pin, under the name the pickers already use.VIDEO_GEN_MODES as VIDEO_RENDER_MODES,+ // Text-to-image always needs a prompt; with an input image it depends on+ // whether the backend's tool lists the prompt as required. Gating the+ // Generate button on the server's own predicate keeps the button from+ // enabling a render `prepareParams` then 400s.+ cloudPromptRequired,+ // How many input images (init image + reference slots, combined) a backend's+ // tool accepts — null when its schema declares no maximum.+ maxInputImages,normalizeRenderPinValue,+ supportsCloudModelOverride,};-// Shipped default Codex reasoning-effort level — the client mirror of the-// server's CODEX_IMAGEGEN_DEFAULT_EFFORT (server/services/imageGen/modes.js).-// A Codex job with no explicit effort renders at this level, so any UI that-// displays or pre-fills "the effort a job used" must resolve an absent value to-// this default rather than showing a blank.-export const CODEX_IMAGEGEN_DEFAULT_EFFORT = 'low';--// Client mirror of the server's AGY_IMAGEGEN_DEFAULT_MODEL-// (server/services/imageGen/modes.js, #3231) — the cheap-tier agent/session-// model an unpinned agy render runs on. Any UI naming "the model an agy job-// used" must resolve an absent value to this, not to "agy's own default"-// (which stopped being true when the pin shipped).-export const AGY_IMAGEGEN_DEFAULT_MODEL = 'gemini-3.5-flash-low';--// Client mirror of AGY_IMAGEGEN_IMAGE_MODEL — the image model behind agy's-// generate_image tool, fixed server-side by Antigravity and NOT selectable by-// PortOS (all three channels probed and closed — see the server constant's-// comment). Surfaced read-only in Settings so the agent-model field can't be-// mistaken for an image-model picker.-export const AGY_IMAGEGEN_IMAGE_MODEL = 'imagen-3.0-generate-002';-// The Settings → Image Gen → Defaults rows for the server's render-target// alphabet (`RENDER_TARGET`, #3231) — the surfaces whose default backend +// model are pinnable via settings.renderDefaults. Only targets whose resolver@@ -96,11 +117,6 @@ export const RENDER_TARGET_OPTIONS = Object.freeze([// local accelerator.export const isCloudVideoMode = (mode) => CLOUD_VIDEO_GEN_MODES.includes(mode);-// Client mirror of the server's GROK_ASPECT_RATIOS (imageGen/grok.js) — the-// aspect ratios grok's image_gen/image_edit tools accept, offered as the-// default-ratio picker in Settings → Image Gen → Grok.-export const GROK_ASPECT_RATIOS = Object.freeze(['1:1', '16:9', '9:16', '4:3', '3:4', '3:2', '2:3']);-// Human-facing backend names — the pure half of imageGenBackends' per-mode// metadata (its icon half stays there with the lucide import).export const MODE_LABELS = Object.freeze({@@ -119,25 +135,13 @@ export const MODE_LABELS = Object.freeze({// GROK` disjunctions.export const isCloudCliMode = (mode) => CLOUD_IMAGE_GEN_MODES.includes(mode);-// Client mirror of the server's `supportsModelOverride` spec flag-// (imageGen/cloudProviderConfig.js) — cloud CLIs that accept a per-render-// `cloudModel` replacing the saved `settings.imageGen.<mode>.model` for one-// queue item. Grok is absent because its image tools run on a fixed xAI backend-// with no model knob, so offering the control there would be a lie.-// Use `supportsCloudModelOverride` instead of hand-rolled-// `mode === CODEX || mode === AGY` disjunctions — the two must stay in lock-step-// with the server spec, and a new CLI backend should be one entry here.-export const MODEL_OVERRIDE_CAPABLE_MODES = Object.freeze([- IMAGE_GEN_MODE.CODEX,- IMAGE_GEN_MODE.AGY,-]);-export const supportsCloudModelOverride = (mode) => MODEL_OVERRIDE_CAPABLE_MODES.includes(mode);-/**- * Client mirror of the server's `renderTargetDefaults`+ * The client-side counterpart of the server's `renderTargetDefaults`* (imageGen/cloudProviderConfig.js) — one surface's saved `settings.renderDefaults`* pin, re-keyed to the flat `imageMode`/`imageModelId` shape `renderPinLadder`- * consumes so a target pin and a record pin are the same kind of thing.+ * consumes so a target pin and a record pin are the same kind of thing. Its+ * input is the settings payload the client already holds, so this reads that+ * object rather than importing a resolver from a service module.*/export const renderTargetPin = (settings, target) => ({imageMode: settings?.renderDefaults?.[target]?.imageMode ?? null,@@ -146,7 +150,7 @@ export const renderTargetPin = (settings, target) => ({/*** Resolve the effective render pin from an ordered ladder of pin sources — the- * client mirror of the server's `resolveRenderTargetConfig` (#3231), minus the+ * client-side counterpart of the server's `resolveRenderTargetConfig` (#3231), minus the* explicit-per-request rung the caller owns. Pass sources highest-priority* first, which for every surface is: the record's own pin (`recordRenderPin`'s* `imageMode`/`imageModelId`), then the target's `renderTargetPin(settings, target)`.@@ -211,15 +215,6 @@ export function applyRecordRenderPin(cfg, sources, availableBackends = null) {// MODE_LABELS already holds and grow a branch per backend.export const modeLabel = (mode) => MODE_LABELS[mode] || mode || '';-// Backends that support image-to-image (init image / reference conditioning).-// The external SD-API path does not. Client mirror of the server's-// EDIT_INCAPABLE_IMAGE_MODES complement (imageGen/modes.js), bound to it by-// server/lib/renderTargets.parity.test.js. Ordered best-first — pickI2iMode-// walks this list.-export const I2I_CAPABLE_MODES = Object.freeze([- IMAGE_GEN_MODE.LOCAL, IMAGE_GEN_MODE.CODEX, IMAGE_GEN_MODE.GROK, IMAGE_GEN_MODE.AGY,-]);-// True when a mode can run image-to-image.export const isI2iCapableMode = (mode) => I2I_CAPABLE_MODES.includes(mode);@@ -246,33 +241,6 @@ export function pickI2iMode(backends) {return null;}-// Client mirror of the `maxInputImages` field on the server's-// CLOUD_PROVIDER_SPECS (imageGen/cloudProviderConfig.js) — how many input-// images (init image + reference slots, combined) each cloud CLI's image tool-// accepts. The form uses this to cap the reference slots it offers, so a user-// never fills a slot the backend would silently drop. Only agy declares a-// maximum; codex and grok are absent because their tool schemas declare none,-// so the form's own slot count is their only bound. Local is absent for the-// same reason: FLUX.2 takes the init image plus all 4 reference slots.-// Bound to the server values by server/lib/renderTargets.parity.test.js.-export const MAX_INPUT_IMAGES = Object.freeze({- [IMAGE_GEN_MODE.AGY]: 3,-});--// Client mirror of the server's `promptRequiredWithInputImage` spec flag-// (imageGen/cloudProviderConfig.js) — cloud CLIs whose image tool lists the-// prompt in its `required` parameters, so an image-only render still needs one.-// Codex and grok are absent: their tools render from an input image alone.-// Kept as data (like MODEL_OVERRIDE_CAPABLE_MODES) rather than a hand-rolled-// `mode === AGY` comparison, so a new CLI backend is one entry here.-export const PROMPT_REQUIRED_WITH_INPUT_IMAGE_MODES = Object.freeze([IMAGE_GEN_MODE.AGY]);--// Client mirror of the server's cloudPromptRequired (imageGen/cloudProviderConfig.js).-// Text-to-image always needs a prompt; with an input image it depends on the-// backend. Bound to the server predicate by server/lib/renderTargets.parity.test.js.-export const cloudPromptRequired = (mode, hasInputImage) => isCloudCliMode(mode)- && (!hasInputImage || PROMPT_REQUIRED_WITH_INPUT_IMAGE_MODES.includes(mode));-/*** How many reference slots the form should offer for `mode`.*@@ -287,7 +255,7 @@ export const cloudPromptRequired = (mode, hasInputImage) => isCloudCliMode(mode)export function referenceSlotsFor(mode, { hasInitImage = false, maxSlots = 4, localSupportsReferences = false } = {}) {if (mode === IMAGE_GEN_MODE.LOCAL) return localSupportsReferences ? maxSlots : 0;if (!isCloudCliMode(mode)) return 0;- const cap = MAX_INPUT_IMAGES[mode] ?? Infinity;+ const cap = maxInputImages(mode) ?? Infinity;return Math.min(maxSlots, cap - (hasInitImage ? 1 : 0));}diff --git a/server/lib/README.md b/server/lib/README.mdindex becaedb98b..ecf5bcdf15 100644--- a/server/lib/README.md+++ b/server/lib/README.md@@ -32,6 +32,7 @@ The barrel `server/lib/index.js` is a machine-checkable enumeration of every pub| `taskDataInputCatalog.js` | Pure catalog and persisted ids for deterministic context sources that scheduled agent tasks can preload before dispatch. || `sharedSchemas.js` | Cross-domain Zod fragments that `validation.js` and the per-domain `*Validation.js` files both need, kept in a leaf module so the domain files never import back through `validation.js` (its hoisted `export * from` lines would TDZ). `grokVideoDurationSchema` (grok clip-length union), `cloudModelIdString(message)` (cloud-CLI model-id charset/bounds), `recordRenderPinFields` (the `imageMode`/`imageModelId` per-record render pin pair), and `isSafeSubdirFilter(v)` (relative path with no wildcard, `..` segment, or leading `/`), and `csvIdsParam({ max, maxIdLength, truncate })` (the `?ids=a,b,c` batch-by-id query param: trims, drops empties, reads all-blank as absent, and either 400s or silently slices an over-cap batch). || `generationModes.js` | Shared immutable image/video render-backend alphabets (`IMAGE_GEN_MODE[S]`, `QUEUEABLE_IMAGE_MODES`, `VIDEO_GEN_MODE[S]`, and cloud subsets) plus `mediaJobExecutionLane({ kind, mode, remote })` / `MEDIA_JOB_EXECUTION_LANES` — THE media-queue lane rule the scheduler and the public job projection share, kept below both validation and generation services so schemas never import orchestration modules. |+| `imageGenCapabilities.js` | Per-backend image-gen capability literals, a dependency-free leaf beside `generationModes.js`: `EDIT_INCAPABLE_IMAGE_MODES`/`isEditCapableMode` and the derived `I2I_CAPABLE_MODES`, the shipped defaults (`CODEX_IMAGEGEN_DEFAULT_MODEL`/`_EFFORT`, `AGY_IMAGEGEN_DEFAULT_MODEL`, `AGY_IMAGEGEN_IMAGE_MODEL`), the `AGY_`/`GROK_ASPECT_RATIOS` alphabets, and `IMAGE_GEN_PROVIDER_CAPABILITIES` (`supportsModelOverride`, `maxInputImages`, `promptRequiredWithInputImage`) with its `supportsCloudModelOverride`/`maxInputImages`/`cloudPromptRequired` readers. The `services/imageGen/*` modules re-export these, and `client/src/lib/imageGenModes.js` imports them instead of copying them (#6590). || `fableLoomLimits.js` | FableLoom record caps (`LOOM_LIMITS`) — the single source of truth shared by the route schemas and the record sanitizer. A leaf module, below both. || `fableLoomCameraMovements.js` | Shared FableLoom camera-movement registry for generated cut direction and the manual scene editor selector. || `fableLoomPlayback.js` | FableLoom node playback modes (`cut` auto-advances; `decision` loops while awaiting input), with the backward-compatible default. |diff --git a/server/lib/imageGenCapabilities.js b/server/lib/imageGenCapabilities.jsnew file mode 100644index 0000000000..6126bb4c27--- /dev/null+++ b/server/lib/imageGenCapabilities.js@@ -0,0 +1,191 @@+/**+ * Per-backend image-gen capability literals.+ *+ * A dependency-free leaf beside `generationModes.js`, for the same reason that+ * module exists: these are FACTS about each render backend (what its image tool+ * accepts, what PortOS ships as its default model/effort), and both the server+ * services and the browser bundle need them. They used to live in+ * `services/imageGen/{modes,cloudProviderConfig,grok}.js`, which the client+ * cannot import — those modules pull `lib/errorHandler.js`, and through it+ * Node's `events` — so `client/src/lib/imageGenModes.js` hand-copied them and+ * a server-side parity suite bound three of the copies. The shipped defaults+ * and the aspect-ratio alphabets were unbound and could drift silently.+ *+ * Nothing here may import anything but `generationModes.js`: the moment this+ * file reaches a service module, the client copies come back.+ *+ * The three service modules re-export their old bindings, so every existing+ * server import site is untouched — the same compatibility pattern `modes.js`+ * already uses for the backend alphabets.+ */++import { CLOUD_IMAGE_GEN_MODES, IMAGE_GEN_MODE, IMAGE_GEN_MODES } from './generationModes.js';++// Backends that cannot take an input image at all (#3243). Every *queueable*+// backend now can: local (mflux/diffusers `--image-path` + FLUX.2 references),+// codex (`image_gen.referenced_image_paths`), grok (`image_edit.image`) and agy+// (`generate_image.ImagePaths`) all accept an init image and/or reference+// images — see `maxInputImages` below for the probed per-backend limits. Agy+// was listed here until its tool schema was probed directly and turned out to+// document ImagePaths as "images to use in generation… edit, combine, or use as+// references".+//+// The external SD-API backend is the one that genuinely has no input-image+// wiring in this codebase, so it inherits the slot. This is the SINGLE source+// for the fact — a future edit-incapable backend belongs here and nowhere else.+export const EDIT_INCAPABLE_IMAGE_MODES = Object.freeze([IMAGE_GEN_MODE.EXTERNAL]);++/** Can `mode` accept an input image (i2i / edit / reference)? */+export const isEditCapableMode = (mode) => !EDIT_INCAPABLE_IMAGE_MODES.includes(mode);++// The complement of the list above, derived rather than restated — this is what+// the i2i-only pickers (the sprite fork modal, #3331) filter their backend+// options through, and what `pickI2iMode` walks in order. That walk wants the+// best backend first (local's form exposes strength + LoRAs, then the cloud+// CLIs), which is the order `IMAGE_GEN_MODES` already has once external — its+// one edit-incapable member — is filtered out.+export const I2I_CAPABLE_MODES = Object.freeze(IMAGE_GEN_MODES.filter(isEditCapableMode));++// Shipped defaults for the Codex imagegen backend. Codex's built-in image_gen+// tool otherwise runs whatever model its logged-in session defaults to — often+// the heaviest, most expensive tier — at default reasoning effort. Pin the cheap+// `gpt-5.6-luna` model at `low` reasoning effort so every media-pipeline render+// pays the light path by default. Applied as a code-level default (not a+// settings migration) so it reaches every install and federated peer with no+// per-install bookkeeping; an explicit `imageGen.codex.model` / `.effort` in+// Settings still wins. Effort is one of providerModels' CODEX_EFFORT_LEVELS.+export const CODEX_IMAGEGEN_DEFAULT_MODEL = 'gpt-5.6-luna';+export const CODEX_IMAGEGEN_DEFAULT_EFFORT = 'low';++// The Agy mirror of the Codex pin above (#3231). An unpinned agy render used to+// resolve to the ANTIGRAVITY_CONFIGURED_DEFAULT sentinel, which resolveCliModel+// maps to null — no `--model` flag at all — so agy ran the session on whatever+// its own config selected, potentially a reasoning-heavy tier+// (claude-opus-4-6-thinking) just to relay one generate_image tool call. The+// driving agent does no creative work on the image, so the cheapest flash tier+// that reliably issues the tool call is the correct shipped default+// (empirically verified to complete a render). Agy bakes the effort ladder into+// the model id (-low/-medium/-high), so there is no separate effort pin. Same+// code-level-default rationale as Codex: reaches every install and peer with no+// migration; an explicit `imageGen.agy.model` in Settings still wins. If this+// tier ever proves flaky at issuing generate_image, escalate exactly one rung+// (gemini-3.5-flash-medium) and record why here.+export const AGY_IMAGEGEN_DEFAULT_MODEL = 'gemini-3.5-flash-low';++// The image model behind agy's generate_image tool — fixed server-side by+// Antigravity and NOT selectable by PortOS. Re-probed 2026-07-30 against agy+// 1.1.8 and still closed; the decisive evidence is now the tool's own schema,+// dumped from a live session:+//+// { Prompt, ImageName, AspectRatio, ImagePaths, toolAction, toolSummary }+//+// There is no model parameter, so the driving agent has nothing to route a+// model choice through. `agy --model imagen-3-fast` selects the AGENT/session+// model and rejects image-model ids ("invalid model selection"). A prompt+// directive naming a model is worse than a no-op: three runs directing+// imagen-3-fast / gemini-3.5-flash / gemini-2.0-flash all produced identical+// 1376×768 output from the same backend, and the directive text got+// concatenated into the tool's `Prompt` ("…spider web (macro lens) using the+// imagen-3-fast model"), polluting the image prompt itself.+//+// Beware: agy CONFIDENTLY names whichever model you asked for when questioned+// afterward — it reported "gemini-2.0-flash" for a render that came out at+// Imagen's 16:9 geometry. Do not re-probe on its word; probe the pixels.+// Exported so sidecars can record the image model that actually rendered+// (distinct from the agent/session model above) without a second copy, and so+// Settings can surface it read-only next to the agent-model field.+export const AGY_IMAGEGEN_IMAGE_MODEL = 'imagen-3.0-generate-002';++// Aspect ratios agy's generate_image tool accepts via its `AspectRatio`+// parameter — verbatim from the tool schema above. This IS a real knob: a run+// that names no ratio renders at the tool's documented '1:1' default (measured+// 1024×1024) no matter what pixel dimensions the prompt asks for, so a PortOS+// render requesting a wide comic page silently came back square before the+// prompt builders started naming a ratio.+export const AGY_ASPECT_RATIOS = Object.freeze(['1:1', '2:3', '3:2', '3:4', '4:3', '9:16', '16:9']);++// Aspect ratios grok's image_gen/image_edit tools accept. Width/height from+// PortOS callers are mapped to the closest of these; a configured default+// (`imageGen.grok.aspectRatio`) applies when the caller sent no dimensions, and+// Settings → Image Gen → Grok offers this list as the default-ratio picker.+export const GROK_ASPECT_RATIOS = Object.freeze(['1:1', '16:9', '9:16', '4:3', '3:4', '3:2', '2:3']);++/**+ * The pure per-provider capability flags, keyed by `IMAGE_GEN_MODE`. Spread+ * into `CLOUD_PROVIDER_SPECS` (services/imageGen/cloudProviderConfig.js), which+ * adds the impure half — labels, error codes, and the settings-reading+ * `modelId`/`params` resolvers.+ *+ * - `supportsModelOverride` — whether a per-render `cloudModel` may replace the+ * saved default for one queue item. Grok is `false`: its `image_gen` tool+ * runs on a fixed xAI backend with no model knob at all, so accepting an+ * override there would be a lie.+ * - `maxInputImages` — how many input images (init image + reference images,+ * combined) the provider's image tool accepts, or `null` when its schema+ * declares no maximum (PortOS's own form ceiling — MAX_REFERENCE_IMAGES in+ * routes/imageGen.js — is then the only bound, expressed once where it is+ * defined rather than restated here as a fake capability). Probed from the+ * live tool schemas on 2026-08-09 — do NOT raise one on a provider's word,+ * re-probe the schema. Applied server-side in exactly one place,+ * `resolveInputImages` (inputImages.js), and predicted client-side by+ * `referenceSlotsFor` so the form never offers a slot the backend drops.+ * - `promptRequiredWithInputImage` — whether the provider still needs a text+ * prompt when the render already carries an input image. `false` for the+ * tools where the attached image is the whole instruction; `true` where the+ * tool schema lists the prompt as required.+ */+export const IMAGE_GEN_PROVIDER_CAPABILITIES = Object.freeze({+ [IMAGE_GEN_MODE.CODEX]: Object.freeze({+ supportsModelOverride: true,+ // `image_gen.referenced_image_paths` is a string[] with no declared maximum.+ maxInputImages: null,+ promptRequiredWithInputImage: false,+ }),+ [IMAGE_GEN_MODE.GROK]: Object.freeze({+ // Grok's image tools run on xAI's fixed image backend — no model knob.+ supportsModelOverride: false,+ // `image_edit.image` is a string[] with no declared maximum — like codex.+ maxInputImages: null,+ promptRequiredWithInputImage: false,+ }),+ [IMAGE_GEN_MODE.AGY]: Object.freeze({+ supportsModelOverride: true,+ // `generate_image.ImagePaths`: "you cannot pass in more than 3 images".+ maxInputImages: 3,+ // …and `Prompt` is in that tool's `required` list, so an image-only agy+ // render has nothing to send.+ promptRequiredWithInputImage: true,+ }),+});++// Cloud CLIs that accept a per-render `cloudModel` override. Kept as data so a+// new backend is one capability entry rather than a hand-rolled+// `mode === CODEX || mode === AGY` disjunction at every call site.+export const MODEL_OVERRIDE_CAPABLE_MODES = Object.freeze(+ CLOUD_IMAGE_GEN_MODES.filter((mode) => IMAGE_GEN_PROVIDER_CAPABILITIES[mode]?.supportsModelOverride === true),+);++/** Can a per-render `cloudModel` replace `mode`'s saved default model? */+export const supportsCloudModelOverride = (mode) => MODEL_OVERRIDE_CAPABLE_MODES.includes(mode);++/**+ * How many input images (init image + reference images, combined) `mode`'s+ * image tool accepts. `null` for a non-cloud mode: the local runner's ceiling+ * is the form's own slot count, and external takes none at all (it never+ * reaches the resolver — `isEditCapableMode` rejects it first).+ */+export const maxInputImages = (mode) => IMAGE_GEN_PROVIDER_CAPABILITIES[mode]?.maxInputImages ?? null;++/**+ * Does a cloud-CLI render need a text prompt, given whether it carries an input+ * image? Text-to-image always does; with an input image it depends on whether+ * the provider's tool lists the prompt as required+ * (`promptRequiredWithInputImage`). Non-cloud modes return `false` — local and+ * external both accept an empty prompt. Rejecting up front keeps the failure a+ * 400 instead of a queued job that dies asynchronously.+ */+export const cloudPromptRequired = (mode, hasInputImage) => {+ const caps = IMAGE_GEN_PROVIDER_CAPABILITIES[mode];+ if (!caps) return false;+ return !hasInputImage || caps.promptRequiredWithInputImage === true;+};diff --git a/server/lib/importScoping.test.js b/server/lib/importScoping.test.jsindex 49ea036038..0483e70045 100644--- a/server/lib/importScoping.test.js+++ b/server/lib/importScoping.test.js@@ -272,7 +272,18 @@ describe('deferred imports stay deferred (#6156)', () => {// `seriesCharacterArc.js`), the vocabulary leaf +24, less the five deleted// mirror suites — leaves with nothing behind them to defer, the tolerated shape,// not an eager edge. Restore the ~1.5k allowance.-const MAX_STATIC_INSTANTIATIONS = 96900;+//+// #6590 is the same shape again: the image-gen capability literals the client+// hand-copied (input-image caps, the prompt rule, the shipped default+// models/effort, the aspect-ratio alphabets) moved out of three+// `services/imageGen/*` modules — unreachable from the browser bundle because+// they import `errorHandler.js` — into one dependency-free leaf,+// `lib/imageGenCapabilities.js`. Measured 96,975 (+108 over main's 96,867): the+// leaf is +1 in each of the 108 closures that already reached `imageGen/modes.js`,+// and it pulls in nothing new (its only import, `generationModes.js`, was+// already in every one of them). A leaf with nothing behind it to defer is the+// tolerated shape. The allowance had drifted to ~30 again, so restore the ~1.5k.+const MAX_STATIC_INSTANTIATIONS = 98500;const SKIP_DIRS = new Set(['node_modules', 'coverage', 'dist', 'data']);const serverTestFiles = (dir = SERVER_DIR, out = []) => {diff --git a/server/lib/index.js b/server/lib/index.jsindex c5637bf6d1..5bc9d471c3 100644--- a/server/lib/index.js+++ b/server/lib/index.js@@ -463,6 +463,7 @@ export * from './renderSlot.js';export * from './renderTargets.js';export * from './renderTiming.js';export * from './generationModes.js';+export * from './imageGenCapabilities.js';export * from './spriteVocabulary.js';export * from './spriteChromaKey.js';export * from './spriteAnimationTracks.js';diff --git a/server/lib/renderTargets.parity.test.js b/server/lib/renderTargets.parity.test.jsindex 7fb411287a..05fb575f53 100644--- a/server/lib/renderTargets.parity.test.js+++ b/server/lib/renderTargets.parity.test.js@@ -1,19 +1,20 @@/**- * Cross-package parity for the image-gen capability mirrors (#3231).+ * Cross-package parity for the render-target Settings rows (#3231).*- * The backend, render-target, and execution-lane ALPHABETS are no longer- * mirrored: `client/src/lib/imageGenModes.js` re-exports them from the- * dependency-free server leaves (`lib/generationModes.js`,- * `lib/renderTargets.js`), so they cannot drift and nothing here asserts them.+ * Nothing else needs binding any more. The backend, render-target, and+ * execution-lane ALPHABETS re-export from the dependency-free server leaves+ * (`lib/generationModes.js`, `lib/renderTargets.js`), and #6590 moved the+ * per-backend CAPABILITY literals — the input-image caps, the prompt rule, the+ * i2i-capable complement of `EDIT_INCAPABLE_IMAGE_MODES`, the shipped default+ * models — into `lib/imageGenCapabilities.js`, which the client re-exports too.+ * Facts that are imported cannot drift, so asserting them here would only+ * restate an `export`.*- * What this suite still binds is the client's copy of facts that live in- * server SERVICE modules the browser bundle cannot load (they import- * `errorHandler.js`, and through it Node's `events`): the per-provider- * input-image capability specs on `CLOUD_PROVIDER_SPECS`, the i2i-capable- * complement of `EDIT_INCAPABLE_IMAGE_MODES`, and the one presentation- * decision the Settings tab owns — which render targets get a Defaults row.- * Drift there is invisible to either suite alone: the client tests assert the- * client's own literals, and the server never loads the client mirror.+ * What remains is the one thing the client genuinely owns: which render targets+ * get a Defaults row in Settings. That is a presentation decision with no+ * server counterpart to import, so it is the only place drift is still possible+ * — and it is invisible to either suite alone, because the client tests assert+ * the client's own list and the server never loads it.** Lives server-side because the server runner loads the pure client lib fine,* while the client (happy-dom) runner can't load service modules.@@ -21,18 +22,10 @@import { describe, it, expect } from 'vitest';import { RENDER_TARGET, RENDER_TARGETS } from './renderTargets.js';-import { CLOUD_IMAGE_GEN_MODES, IMAGE_GEN_MODES } from './generationModes.js';-import { EDIT_INCAPABLE_IMAGE_MODES } from '../services/imageGen/modes.js';-import { cloudPromptRequired, maxInputImages } from '../services/imageGen/cloudProviderConfig.js';// Import the node-safe leaf, NOT imageGenBackends.js — that module imports// lucide-react, which is not installed in the server CI job (this exact import// broke main's CI when Phase 2 landed pointing at imageGenBackends).-import {- RENDER_TARGET_OPTIONS as CLIENT_OPTIONS,- I2I_CAPABLE_MODES as CLIENT_I2I_CAPABLE,- MAX_INPUT_IMAGES as CLIENT_MAX_INPUT_IMAGES,- cloudPromptRequired as clientCloudPromptRequired,-} from '../../client/src/lib/imageGenModes.js';+import { RENDER_TARGET_OPTIONS as CLIENT_OPTIONS } from '../../client/src/lib/imageGenModes.js';// Targets the Settings UI deliberately does NOT list — a pin nobody's// resolver reads would be a control that silently does nothing. FableLoom@@ -60,56 +53,3 @@ describe('render-target Settings rows (#3231)', () => {}});});--/**- * The client's `I2I_CAPABLE_MODES` is what the i2i-only pickers (the sprite fork- * modal, #3331) filter their backend options through, and the server's- * `EDIT_INCAPABLE_IMAGE_MODES` is what rejects such a mode at request time. If a- * future edit-incapable backend were added server-side and not removed from the- * client list, every i2i picker would go back to offering a backend the server- * 400s — the exact bug #3331 fixed, re-introduced silently.- *- * Both directions are asserted: the two sets are exact complements over the mode- * alphabet, so a backend that gains or loses input-image support server-side has- * to be reflected in the client list.- */-describe('edit-capability client mirror parity (#3331)', () => {- it('the client i2i-capable list is the exact complement of the server incapable list', () => {- const expected = IMAGE_GEN_MODES.filter((m) => !EDIT_INCAPABLE_IMAGE_MODES.includes(m));- expect([...CLIENT_I2I_CAPABLE].sort()).toEqual([...expected].sort());- });-});--/**- * The per-provider input-image capabilities live on `CLOUD_PROVIDER_SPECS`- * (server/services/imageGen/cloudProviderConfig.js) and are mirrored into the- * client so the Image Gen form can offer exactly the reference slots the backend- * accepts and gate the Generate button on the same prompt rule the server- * enforces. Drift in either direction is invisible to both suites on its own:- * the client tests assert the client's own literals, and the server never loads- * the client mirror. A raised/lowered cap would make the form offer a slot the- * server silently drops; a changed prompt rule would enable a button on a render- * `prepareParams` then 400s.- */-describe('cloud input-image capability client mirror parity', () => {- it('every cloud CLI mirrors its server maxInputImages', () => {- for (const mode of CLOUD_IMAGE_GEN_MODES) {- // An absent client entry and a null server cap are the same fact ("this- // tool declares no maximum"), so normalize before comparing — otherwise- // the mirror could drop a real cap and still pass.- expect(CLIENT_MAX_INPUT_IMAGES[mode] ?? null,- `client MAX_INPUT_IMAGES["${mode}"] does not match the server spec's maxInputImages`)- .toBe(maxInputImages(mode));- }- });-- it('the client prompt-required predicate agrees with the server for every mode', () => {- for (const mode of IMAGE_GEN_MODES) {- for (const hasInputImage of [false, true]) {- expect(clientCloudPromptRequired(mode, hasInputImage),- `client cloudPromptRequired("${mode}", ${hasInputImage}) disagrees with the server`)- .toBe(cloudPromptRequired(mode, hasInputImage));- }- }- });-});diff --git a/server/services/imageGen/cloudProviderConfig.js b/server/services/imageGen/cloudProviderConfig.jsindex 4798407e69..26b2cb22ac 100644--- a/server/services/imageGen/cloudProviderConfig.js+++ b/server/services/imageGen/cloudProviderConfig.js@@ -18,6 +18,11 @@import { ServerError } from '../../lib/errorHandler.js';import { normalizeRenderPinValue } from '../../lib/renderTargets.js';+import {+ cloudPromptRequired,+ IMAGE_GEN_PROVIDER_CAPABILITIES,+ maxInputImages,+} from '../../lib/imageGenCapabilities.js';import {AGY_IMAGEGEN_DEFAULT_MODEL,CLOUD_IMAGE_GEN_MODES,@@ -26,6 +31,13 @@ import {QUEUEABLE_IMAGE_MODES,} from './modes.js';+// The pure capability half of the specs below, plus the two predicates that+// read it, live in the dependency-free `lib/imageGenCapabilities.js` leaf so+// the client shares them instead of re-typing them. Re-exported here because+// every existing caller (inputImages, prepareParams, the providers,+// fableLoom/production) imports them from this module.+export { cloudPromptRequired, maxInputImages };+/*** Per-provider knowledge, keyed by mode:* - `label` — user-facing provider name used in every disabled message.@@ -35,24 +47,10 @@ import {* Codex's `model` carries the effective (defaulted) id so the* queue row reports what actually renders; the provider* re-applies the same default, so rendering is unchanged.- * - `supportsModelOverride` — whether a per-render `cloudModel` may replace the- * saved default for one queue item. Grok is `false`: its- * `image_gen` tool runs on a fixed xAI backend with no model- * knob at all, so accepting an override there would be a lie.- * - `maxInputImages` — how many input images (init image + reference images,- * combined) the provider's image tool accepts, or `null` when- * its schema declares no maximum (PortOS's own form ceiling —- * MAX_REFERENCE_IMAGES in routes/imageGen.js — is then the- * only bound, expressed once where it is defined rather than- * restated here as a fake capability). Probed from the live- * tool schemas on 2026-08-09 — do NOT raise one on a- * provider's word, re-probe the schema. Applied in exactly one- * place: `resolveInputImages` (inputImages.js).- * - `promptRequiredWithInputImage` — whether the provider still needs a text- * prompt when the render already carries an input image.- * `false` for the tools where the attached image is the whole- * instruction; `true` where the tool schema lists the prompt- * as required.+ * - the pure capability flags — `supportsModelOverride`, `maxInputImages`,+ * `promptRequiredWithInputImage` — are spread in from+ * IMAGE_GEN_PROVIDER_CAPABILITIES (lib/imageGenCapabilities.js),+ * which documents what each one means and how it was probed.** `modelId`/`params` both take `(config, override)` where `override` is the* per-render model id (or a falsy value when the render inherits the saved@@ -60,12 +58,9 @@ import {*/export const CLOUD_PROVIDER_SPECS = Object.freeze({[IMAGE_GEN_MODE.CODEX]: Object.freeze({+ ...IMAGE_GEN_PROVIDER_CAPABILITIES[IMAGE_GEN_MODE.CODEX],label: 'Codex Imagegen',errorCode: 'CODEX_IMAGEGEN_DISABLED',- supportsModelOverride: true,- // `image_gen.referenced_image_paths` is a string[] with no declared maximum.- maxInputImages: null,- promptRequiredWithInputImage: false,modelId: (c, override) => override || c.model || CODEX_IMAGEGEN_DEFAULT_MODEL,params: (c, override) => ({codexPath: c.codexPath,@@ -74,25 +69,16 @@ export const CLOUD_PROVIDER_SPECS = Object.freeze({}),}),[IMAGE_GEN_MODE.GROK]: Object.freeze({+ ...IMAGE_GEN_PROVIDER_CAPABILITIES[IMAGE_GEN_MODE.GROK],label: 'Grok Imagegen',errorCode: 'GROK_IMAGEGEN_DISABLED',- // Grok's image tools run on xAI's fixed image backend — no model knob.- supportsModelOverride: false,- // `image_edit.image` is a string[] with no declared maximum — like codex.- maxInputImages: null,- promptRequiredWithInputImage: false,modelId: () => 'grok-imagegen',params: (g) => ({ grokPath: g.grokPath, aspectRatio: g.aspectRatio }),}),[IMAGE_GEN_MODE.AGY]: Object.freeze({+ ...IMAGE_GEN_PROVIDER_CAPABILITIES[IMAGE_GEN_MODE.AGY],label: 'Agy Imagegen',errorCode: 'AGY_IMAGEGEN_DISABLED',- supportsModelOverride: true,- // `generate_image.ImagePaths`: "you cannot pass in more than 3 images".- maxInputImages: 3,- // …and `Prompt` is in that tool's `required` list, so an image-only agy- // render has nothing to send.- promptRequiredWithInputImage: true,// The concrete cheap-tier pin (not the ANTIGRAVITY_CONFIGURED_DEFAULT// sentinel, which resolves to "no --model" and lets agy pick a possibly// reasoning-heavy session default) — see AGY_IMAGEGEN_DEFAULT_MODEL.@@ -154,28 +140,6 @@ export function resolveCloudProviderConfig(settings, mode, overrides = {}) {};}-/**- * How many input images (init image + reference images, combined) `mode`'s- * image tool accepts. `null` for a non-cloud mode: the local runner's ceiling- * is the form's own slot count, and external takes none at all (it never- * reaches here — `isEditCapableMode` rejects it first).- */-export const maxInputImages = (mode) => CLOUD_PROVIDER_SPECS[mode]?.maxInputImages ?? null;--/**- * Does a cloud-CLI render need a text prompt, given whether it carries an input- * image? Text-to-image always does; with an input image it depends on whether- * the provider's tool lists the prompt as required (`promptRequiredWithInputImage`).- * Non-cloud modes return `false` — local and external both accept an empty- * prompt. Rejecting up front keeps the failure a 400 instead of a queued job- * that dies asynchronously.- */-export const cloudPromptRequired = (mode, hasInputImage) => {- const spec = CLOUD_PROVIDER_SPECS[mode];- if (!spec) return false;- return !hasInputImage || spec.promptRequiredWithInputImage === true;-};-/*** Can the queue-backed surfaces render in `mode` right now? Cloud CLIs need* their opt-in toggle; local is always usable (its own pythonPath/modeldiff --git a/server/services/imageGen/grok.js b/server/services/imageGen/grok.jsindex 828d6d4fe4..88cca9f963 100644--- a/server/services/imageGen/grok.js+++ b/server/services/imageGen/grok.js@@ -53,6 +53,7 @@ import { ensureGrokHeadlessArgs, prepareGrokPromptFile } from '../../lib/grok.jsimport {IMAGE_GEN_MODE, describeFidelity, grokImageTool, nearestAspectRatio, visualReferenceRole,} from './modes.js';+import { GROK_ASPECT_RATIOS } from '../../lib/imageGenCapabilities.js';import { resolveInputImages } from './inputImages.js';import { cloudPromptRequired } from './cloudProviderConfig.js';import { withSpawnCwdEnv } from '../../lib/spawnCwd.js';@@ -73,10 +74,11 @@ const DEFAULT_BIN = 'grok';const DEFAULT_HARVEST_TIMEOUT_MS = 5000;let harvestTimeoutMs = DEFAULT_HARVEST_TIMEOUT_MS;-// Aspect ratios grok's image_gen/image_edit tools accept. Width/height from-// PortOS callers are mapped to the closest of these; a configured default-// (`imageGen.grok.aspectRatio`) applies when the caller sent no dimensions.-export const GROK_ASPECT_RATIOS = Object.freeze(['1:1', '16:9', '9:16', '4:3', '3:4', '3:2', '2:3']);+// The tool's aspect-ratio alphabet lives in the dependency-free+// `lib/imageGenCapabilities.js` leaf (Settings offers it as the default-ratio+// picker, and this module is unreachable from the browser bundle). Re-exported+// so `videoGen/grok.js` and the render paths keep importing it from here.+export { GROK_ASPECT_RATIOS };// Map a width/height pair to the closest supported grok aspect ratio, or null// when dimensions are absent/invalid (the tool then uses its own default).diff --git a/server/services/imageGen/modes.js b/server/services/imageGen/modes.jsindex be772a65f5..51e3ec59cc 100644--- a/server/services/imageGen/modes.js+++ b/server/services/imageGen/modes.js@@ -9,7 +9,8 @@* `IMAGE_GEN_MODES` is the alphabet for Zod / OpenAI tool-spec enums.* Single source of truth: derive the array from `Object.values(...)`.*- * The backend alphabets live in `lib/generationModes.js`, below both validation+ * The backend alphabets live in `lib/generationModes.js` and the per-backend+ * capability literals in `lib/imageGenCapabilities.js`, both below validation* and this service module. They are re-exported here so existing generation* callers keep the same service-local import path.*/@@ -18,11 +19,35 @@ import { ServerError } from '../../lib/errorHandler.js';import {CLOUD_IMAGE_GEN_MODES, IMAGE_GEN_MODE, IMAGE_GEN_MODES, QUEUEABLE_IMAGE_MODES,} from '../../lib/generationModes.js';+import {+ AGY_ASPECT_RATIOS,+ AGY_IMAGEGEN_DEFAULT_MODEL,+ AGY_IMAGEGEN_IMAGE_MODEL,+ CODEX_IMAGEGEN_DEFAULT_EFFORT,+ CODEX_IMAGEGEN_DEFAULT_MODEL,+ EDIT_INCAPABLE_IMAGE_MODES,+ isEditCapableMode,+} from '../../lib/imageGenCapabilities.js';export {CLOUD_IMAGE_GEN_MODES, IMAGE_GEN_MODE, IMAGE_GEN_MODES, QUEUEABLE_IMAGE_MODES,};+// The per-backend capability literals live in `lib/imageGenCapabilities.js`,+// a dependency-free leaf the browser bundle can import — this module cannot be,+// because `editIncapableModeError` below needs `ServerError` and through it+// Node's `events`. Re-exported here so every existing service-local import site+// keeps its path.+export {+ AGY_ASPECT_RATIOS,+ AGY_IMAGEGEN_DEFAULT_MODEL,+ AGY_IMAGEGEN_IMAGE_MODEL,+ CODEX_IMAGEGEN_DEFAULT_EFFORT,+ CODEX_IMAGEGEN_DEFAULT_MODEL,+ EDIT_INCAPABLE_IMAGE_MODES,+ isEditCapableMode,+};+// The provider-side image tool each cloud CLI is directed to call. Single// source: the prompt builders name it, the fabrication guard names it when it// rejects a code-drawn stand-in, and the usage card labels its quota row with@@ -60,24 +85,6 @@ export const visualReferenceRole = (count) => (count === 1export const enabledCloudImageModes = (settings) =>CLOUD_IMAGE_GEN_MODES.filter((mode) => settings?.imageGen?.[mode]?.enabled === true);-// Backends that cannot take an input image at all (#3243). Every *queueable*-// backend now can: local (mflux/diffusers `--image-path` + FLUX.2 references),-// codex (`image_gen.referenced_image_paths`), grok (`image_edit.image`) and agy-// (`generate_image.ImagePaths`) all accept an init image and/or reference-// images — see `maxInputImages` on CLOUD_PROVIDER_SPECS (cloudProviderConfig.js)-// for the probed per-backend limits. Agy-// was listed here until its tool schema was probed directly and turned out to-// document ImagePaths as "images to use in generation… edit, combine, or use as-// references".-//-// The external SD-API backend is the one that genuinely has no input-image-// wiring in this codebase, so it inherits the slot. This is the SINGLE source-// for the fact — a future edit-incapable backend belongs here and nowhere else.-export const EDIT_INCAPABLE_IMAGE_MODES = Object.freeze([IMAGE_GEN_MODE.EXTERNAL]);--/** Can `mode` accept an input image (i2i / edit / reference)? */-export const isEditCapableMode = (mode) => !EDIT_INCAPABLE_IMAGE_MODES.includes(mode);-/*** Human-facing backend names — the server half of the client's MODE_LABELS* (client/src/lib/imageGenModes.js). A map rather than a capitalization of the@@ -129,63 +136,6 @@ export const describeFidelity = (strength) => {return 'use the attached image as a loose reference; you may reinterpret freely';};-// Shipped defaults for the Codex imagegen backend. Codex's built-in image_gen-// tool otherwise runs whatever model its logged-in session defaults to — often-// the heaviest, most expensive tier — at default reasoning effort. Pin the cheap-// `gpt-5.6-luna` model at `low` reasoning effort so every media-pipeline render-// pays the light path by default. Applied as a code-level default (not a-// settings migration) so it reaches every install and federated peer with no-// per-install bookkeeping; an explicit `imageGen.codex.model` / `.effort` in-// Settings still wins. Effort is one of providerModels' CODEX_EFFORT_LEVELS.-export const CODEX_IMAGEGEN_DEFAULT_MODEL = 'gpt-5.6-luna';-export const CODEX_IMAGEGEN_DEFAULT_EFFORT = 'low';--// The Agy mirror of the Codex pin above (#3231). An unpinned agy render used to-// resolve to the ANTIGRAVITY_CONFIGURED_DEFAULT sentinel, which resolveCliModel-// maps to null — no `--model` flag at all — so agy ran the session on whatever-// its own config selected, potentially a reasoning-heavy tier-// (claude-opus-4-6-thinking) just to relay one generate_image tool call. The-// driving agent does no creative work on the image, so the cheapest flash tier-// that reliably issues the tool call is the correct shipped default-// (empirically verified to complete a render). Agy bakes the effort ladder into-// the model id (-low/-medium/-high), so there is no separate effort pin. Same-// code-level-default rationale as Codex: reaches every install and peer with no-// migration; an explicit `imageGen.agy.model` in Settings still wins. If this-// tier ever proves flaky at issuing generate_image, escalate exactly one rung-// (gemini-3.5-flash-medium) and record why here.-export const AGY_IMAGEGEN_DEFAULT_MODEL = 'gemini-3.5-flash-low';--// The image model behind agy's generate_image tool — fixed server-side by-// Antigravity and NOT selectable by PortOS. Re-probed 2026-07-30 against agy-// 1.1.8 and still closed; the decisive evidence is now the tool's own schema,-// dumped from a live session:-//-// { Prompt, ImageName, AspectRatio, ImagePaths, toolAction, toolSummary }-//-// There is no model parameter, so the driving agent has nothing to route a-// model choice through. `agy --model imagen-3-fast` selects the AGENT/session-// model and rejects image-model ids ("invalid model selection"). A prompt-// directive naming a model is worse than a no-op: three runs directing-// imagen-3-fast / gemini-3.5-flash / gemini-2.0-flash all produced identical-// 1376×768 output from the same backend, and the directive text got-// concatenated into the tool's `Prompt` ("…spider web (macro lens) using the-// imagen-3-fast model"), polluting the image prompt itself.-//-// Beware: agy CONFIDENTLY names whichever model you asked for when questioned-// afterward — it reported "gemini-2.0-flash" for a render that came out at-// Imagen's 16:9 geometry. Do not re-probe on its word; probe the pixels.-// Exported so sidecars can record the image model that actually rendered-// (distinct from the agent/session model above) without a second copy.-export const AGY_IMAGEGEN_IMAGE_MODEL = 'imagen-3.0-generate-002';--// Aspect ratios agy's generate_image tool accepts via its `AspectRatio`-// parameter — verbatim from the tool schema above. This IS a real knob: a run-// that names no ratio renders at the tool's documented '1:1' default (measured-// 1024×1024) no matter what pixel dimensions the prompt asks for, so a PortOS-// render requesting a wide comic page silently came back square before the-// directive below started naming a ratio.-export const AGY_ASPECT_RATIOS = Object.freeze(['1:1', '2:3', '3:2', '3:4', '4:3', '9:16', '16:9']);-/*** Map a pixel width/height onto the closest ratio in `ratios` ('W:H' strings).* Returns null when either dimension is missing or non-positive, so the caller