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
stop restating the form's reference-slot ceiling as a codex/grok provider capability
[._.]/ Adam Eivyc433522792e1
diff --git a/client/src/components/imageGen/ReferenceImagePicker.jsx b/client/src/components/imageGen/ReferenceImagePicker.jsxindex a6e941bb15..6e9ea4d1fd 100644--- a/client/src/components/imageGen/ReferenceImagePicker.jsx+++ b/client/src/components/imageGen/ReferenceImagePicker.jsx@@ -33,12 +33,16 @@ export default function ReferenceImagePicker({onBrowse,disabled = false,showStrength = true,- caption = 'up to 4 images for FLUX.2 multi-reference edit',+ // Required: the slot count and the wording both vary per backend now, so+ // there is no default that stays true (the old one named FLUX.2, which is+ // wrong on all three cloud CLIs).+ caption,}) {return (<div><label className="block text-xs font-medium text-gray-400 mb-1">- Reference images <span className="text-gray-500 font-normal">({caption})</span>+ Reference images+ {caption ? <span className="text-gray-500 font-normal"> ({caption})</span> : null}</label><div className="grid grid-cols-2 sm:grid-cols-4 gap-2">{referenceImages.map((slot, i) => {diff --git a/client/src/lib/imageGenBackends.test.js b/client/src/lib/imageGenBackends.test.jsindex c60fce46ca..5a6c066512 100644--- a/client/src/lib/imageGenBackends.test.js+++ b/client/src/lib/imageGenBackends.test.js@@ -28,10 +28,11 @@ 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 PortOS's own ceiling applies:- // 1 init image + 4 reference slots.- expect(MAX_INPUT_IMAGES[IMAGE_GEN_MODE.CODEX]).toBe(5);- expect(MAX_INPUT_IMAGES[IMAGE_GEN_MODE.GROK]).toBe(5);+ // 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+ // "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();});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 6437f35411..173d19d7d8 100644--- a/client/src/lib/imageGenModes.js+++ b/client/src/lib/imageGenModes.js@@ -146,21 +146,28 @@ export function pickI2iMode(backends) {// 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. Local isn't listed:-// FLUX.2 takes the init image plus all 4 reference slots.+// 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,- [IMAGE_GEN_MODE.CODEX]: 5,- [IMAGE_GEN_MODE.GROK]: 5,});+// 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).-// Codex and grok can render from an input image alone; agy's generate_image-// lists `Prompt` in its required parameters, so it always needs one. Bound to-// the server predicate by server/lib/renderTargets.parity.test.js.-export const cloudPromptRequired = (mode, hasInputImage) =>- isCloudCliMode(mode) && (!hasInputImage || mode === IMAGE_GEN_MODE.AGY);+// 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`.@@ -168,14 +175,16 @@ export const cloudPromptRequired = (mode, hasInputImage) =>* The client half of the server's input-image cap: a cloud CLI's tool caps the* COMBINED count, so an init image eats one of its slots — the same "init image* leads" rule `resolveInputImages` applies server-side, predicted here so the- * form never offers a slot the backend would drop. Local FLUX.2 takes all of- * them (its references ride a separate runner flag from the init image); a- * non-FLUX.2 local model and external take none.+ * form never offers a slot the backend would drop. A backend that declares no+ * cap gets the form's full slot count. Local FLUX.2 takes all of them (its+ * references ride a separate runner flag from the init image); a non-FLUX.2+ * local model and external take none.*/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;- return Math.min(maxSlots, MAX_INPUT_IMAGES[mode] - (hasInitImage ? 1 : 0));+ const cap = MAX_INPUT_IMAGES[mode] ?? Infinity;+ return Math.min(maxSlots, cap - (hasInitImage ? 1 : 0));}// Backends that honor a NUMERIC per-reference strength. Only the local FLUX.2diff --git a/server/lib/renderTargets.parity.test.js b/server/lib/renderTargets.parity.test.jsindex 1614778bc5..f74b3c5c2a 100644--- a/server/lib/renderTargets.parity.test.js+++ b/server/lib/renderTargets.parity.test.js@@ -90,7 +90,10 @@ describe('edit-capability client mirror parity (#3331)', () => {describe('cloud input-image capability client mirror parity', () => {it('every cloud CLI mirrors its server maxInputImages', () => {for (const mode of CLOUD_IMAGE_GEN_MODES) {- expect(CLIENT_MAX_INPUT_IMAGES[mode],+ // 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));}diff --git a/server/services/imageGen/agy.js b/server/services/imageGen/agy.jsindex 0982244d28..3968bf6d76 100644--- a/server/services/imageGen/agy.js+++ b/server/services/imageGen/agy.js@@ -157,25 +157,26 @@ export const noImageReason = (stdoutTail = '') => buildNoImageReason(stdoutTail,* to use in generation. You can pass in images here if you would like to edit,* combine, or use as references… you cannot pass in more than 3 images" (schema* probed 2026-08-09). The 3-image ceiling is enforced upstream by- * resolveInputImages, which also fixes the order — hence `inputImagePaths` +- * `hasInit` here rather than re-deriving "init leads" a second time.+ * resolveInputImages, which also fixes the order and splits out the init image+ * — so this takes that resolver's `{ paths, initPath, referencePaths }` shape+ * directly rather than re-deriving "init leads" a second time.** Naming the paths on their own line keeps them out of the tool's `Prompt`, for* the same reason the AspectRatio directive is separated: anything that lands* inside `Prompt` becomes part of what gets drawn.*/-const agyImagePathsDirective = ({ inputImagePaths, hasInit, initImageStrength }) => {- if (!inputImagePaths.length) return '';- const refCount = hasInit ? inputImagePaths.length - 1 : inputImagePaths.length;- const role = hasInit+const agyImagePathsDirective = ({ paths, initPath, referencePaths, initImageStrength }) => {+ if (!paths.length) return '';+ const refCount = referencePaths.length;+ const role = initPath? `The first is the source image to edit — ${describeFidelity(initImageStrength)}.${refCount ? ` The rest are ${visualReferenceRole(refCount)}.` : ''}`: `Use ${refCount === 1 ? 'it' : 'them'} as ${visualReferenceRole(refCount)}.`;- return `\nPass these absolute paths to the tool's ImagePaths parameter, in this order: ${inputImagePaths.join(', ')}\n${role}`;+ return `\nPass these absolute paths to the tool's ImagePaths parameter, in this order: ${paths.join(', ')}\n${role}`;};export function buildAgyPrompt({prompt, negativePrompt, width, height, stagingPath,- inputImagePaths = [], hasInit = false, initImageStrength,+ inputImages = { paths: [], initPath: null, referencePaths: [] }, initImageStrength,}) {const avoid = negativePrompt?.trim() ? `\nAvoid: ${negativePrompt.trim()}` : '';// `AspectRatio` is a real generate_image parameter and it defaults to '1:1'.@@ -192,7 +193,7 @@ export function buildAgyPrompt({// exposed this failure mode captioned itself "DIMENSIONS: 832 x 1216 (2:3)".const ratio = nearestAgyAspectRatio(width, height);const aspect = ratio ? `\nPass AspectRatio "${ratio}" to the tool.` : '';- const images = agyImagePathsDirective({ inputImagePaths, hasInit, initImageStrength });+ const images = agyImagePathsDirective({ ...inputImages, initImageStrength });return `Use your built-in ${AGY_TOOL} tool to generate exactly one image.Image prompt: ${prompt.trim()}${avoid}${aspect}${images}Save the generated image as a PNG file at exactly this path: ${stagingPath}@@ -238,8 +239,7 @@ export async function generateImage({await mkdir(scratchDir, { recursive: true });const fullPrompt = buildAgyPrompt({- prompt, negativePrompt, width, height, stagingPath,- inputImagePaths: inputImages.paths, hasInit: Boolean(inputImages.initPath), initImageStrength,+ prompt, negativePrompt, width, height, stagingPath, inputImages, initImageStrength,});const baseArgs = ensureAntigravityPrintArgs([], { model });const { args } = prepareAntigravityPrompt(baseArgs, fullPrompt);diff --git a/server/services/imageGen/cloudProviderConfig.js b/server/services/imageGen/cloudProviderConfig.jsindex 7ce470d103..4798407e69 100644--- a/server/services/imageGen/cloudProviderConfig.js+++ b/server/services/imageGen/cloudProviderConfig.js@@ -40,8 +40,12 @@ import {* `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. Probed from- * the live tool schemas on 2026-08-09 — do NOT raise one on a+ * 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@@ -59,9 +63,8 @@ export const CLOUD_PROVIDER_SPECS = Object.freeze({label: 'Codex Imagegen',errorCode: 'CODEX_IMAGEGEN_DISABLED',supportsModelOverride: true,- // `image_gen.referenced_image_paths` is a string[] with no declared- // maximum, so PortOS's own ceiling applies: 1 init image + 4 ref slots.- maxInputImages: 5,+ // `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) => ({@@ -75,9 +78,8 @@ export const CLOUD_PROVIDER_SPECS = Object.freeze({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 — same PortOS- // ceiling as codex.- maxInputImages: 5,+ // `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 }),diff --git a/server/services/imageGen/cloudProviderConfig.test.js b/server/services/imageGen/cloudProviderConfig.test.jsindex 2795712751..3ddfc92668 100644--- a/server/services/imageGen/cloudProviderConfig.test.js+++ b/server/services/imageGen/cloudProviderConfig.test.js@@ -171,16 +171,15 @@ describe('isModeUsable', () => {it('allows every queueable backend for an edit render — all take input images', () => {// Each backend feeds an input image to its own tool: local `--image-path`,// codex `referenced_image_paths`, grok `image_edit.image`, agy- // `ImagePaths`. The `edit` flag stays the single gate a future- // input-image-less backend would need, so it is asserted as a no-op rather- // than dropped.+ // `ImagePaths`. So an i2i render walks this exact ladder with no edit+ // variant — the sole edit-incapable backend (external) isn't queueable.const s = settingsWith({ agy: { enabled: true }, codex: { enabled: true }, grok: { enabled: true } });for (const mode of [IMAGE_GEN_MODE.AGY, IMAGE_GEN_MODE.CODEX, IMAGE_GEN_MODE.GROK, IMAGE_GEN_MODE.LOCAL]) {- expect(isModeUsable(s, mode, { edit: true })).toBe(isModeUsable(s, mode));+ expect(isModeUsable(s, mode), `${mode} should be usable for an edit render`).toBe(true);}- // Disabled-ness still gates, independently of the edit flag.+ // Disabled-ness still gates.const off = settingsWith({ agy: { enabled: false }, codex: { enabled: true } });- expect(isModeUsable(off, IMAGE_GEN_MODE.AGY, { edit: true })).toBe(false);+ expect(isModeUsable(off, IMAGE_GEN_MODE.AGY)).toBe(false);});});@@ -217,14 +216,13 @@ describe('pickUsableMode', () => {// edit render lands where the user asked for it.const s = settingsWith({ agy: { enabled: true }, codex: { enabled: true } });expect(pickUsableMode(s, [IMAGE_GEN_MODE.AGY])).toBe(IMAGE_GEN_MODE.AGY);- expect(pickUsableMode(s, [IMAGE_GEN_MODE.AGY], { edit: true })).toBe(IMAGE_GEN_MODE.AGY);});it('lands on local for an edit render when every cloud backend is off', () => {// LOCAL is edit-capable, so the auto tail always resolves — an edit render// can never fall off the end of the ladder.const allOff = settingsWith({ codex: { enabled: false }, grok: { enabled: false }, agy: { enabled: false } });- expect(pickUsableMode(allOff, [IMAGE_GEN_MODE.AGY], { edit: true })).toBe(IMAGE_GEN_MODE.LOCAL);+ expect(pickUsableMode(allOff, [IMAGE_GEN_MODE.AGY])).toBe(IMAGE_GEN_MODE.LOCAL);});it('falls back to local when nothing else is usable', () => {diff --git a/server/services/imageGen/modes.js b/server/services/imageGen/modes.jsindex 07ff369514..54f9e541a0 100644--- a/server/services/imageGen/modes.js+++ b/server/services/imageGen/modes.js@@ -97,13 +97,28 @@ 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+ * mode id, so a backend whose id isn't a single lowercase word ('lm-studio')+ * still gets a real name instead of 'Lm-studio'.+ */+const MODE_LABELS = Object.freeze({+ [IMAGE_GEN_MODE.LOCAL]: 'Local',+ [IMAGE_GEN_MODE.CODEX]: 'Codex',+ [IMAGE_GEN_MODE.GROK]: 'Grok',+ [IMAGE_GEN_MODE.AGY]: 'Agy',+ [IMAGE_GEN_MODE.EXTERNAL]: 'External',+});+/*** Sentence-case backend name for user-facing messages ('Codex', 'Agy', …).- * The client mirror is `modeLabel` in client/src/lib/imageGenModes.js; this is- * the server half, shared so error messages don't grow a per-backend ternary- * ladder each time a backend is added.+ * Shared so error messages don't grow a per-backend ternary ladder each time a+ * backend is added, and so one backend never appears under two names across+ * the UI. Falls back to 'This' for an absent mode, which reads correctly in+ * `editIncapableModeError`'s sentence.*/-export const modeLabel = (mode) => (mode ? mode[0].toUpperCase() + mode.slice(1) : 'This');+export const modeLabel = (mode) => MODE_LABELS[mode] || mode || 'This';/*** The one 400 for "this backend was handed an input image and cannot take one".diff --git a/server/services/imageGen/prepareParams.js b/server/services/imageGen/prepareParams.jsindex 45ee686787..5f4e6afaea 100644--- a/server/services/imageGen/prepareParams.js+++ b/server/services/imageGen/prepareParams.js@@ -119,7 +119,13 @@ export async function prepareGenerateParams({ data, files, referenceImageFieldsmode = resolved.mode;if (!data.cloudModel && resolved.cloud?.modelId) data.cloudModel = resolved.cloud.modelId;}- if (!isEditCapableMode(mode) && (initUpload || data.initImageFile)) {+ // The render's input images, counted once: the init image (uploaded this+ // request or named by an earlier one) plus every reference slot. Every gate+ // below keys off these two, rather than respelling "carries input images"+ // per gate and having to keep the spellings in sync.+ const inputImageCount = (initUpload || data.initImageFile ? 1 : 0) + referenceUploads.length;++ if (!isEditCapableMode(mode) && inputImageCount) {cleanupReqFilesTemp();throw editIncapableModeError(mode);}@@ -131,7 +137,7 @@ export async function prepareGenerateParams({ data, files, referenceImageFields// 400 forever. Same "reject up-front rather than copy-then-fail" rule the// reference gates below follow.const cloudConfig = resolveCloudProviderConfig(settings, mode);- if (cloudConfig && !cloudConfig.enabled && (initUpload || data.initImageFile || referenceUploads.length)) {+ if (cloudConfig && !cloudConfig.enabled && inputImageCount) {cleanupReqFilesTemp();throw cloudConfig.disabledError;}@@ -153,22 +159,16 @@ export async function prepareGenerateParams({ data, files, referenceImageFields// copying the uploads to PATHS.imageRefs and silently dropping them// downstream — that would orphan files on disk and produce metadata sidecars// that lie about how the render was conditioned.- if (referenceUploads.length) {- if (!isEditCapableMode(mode)) {+ if (referenceUploads.length && mode === IMAGE_GEN_MODE.LOCAL) {+ const candidate = getImageModels().find((m) => m.id === data.modelId)+ ?? getImageModels().find((m) => m.id === 'dev')+ ?? getImageModels()[0];+ if (!isFlux2(candidate)) {cleanupReqFilesTemp();- throw editIncapableModeError(mode);- }- if (mode === IMAGE_GEN_MODE.LOCAL) {- const candidate = getImageModels().find((m) => m.id === data.modelId)- ?? getImageModels().find((m) => m.id === 'dev')- ?? getImageModels()[0];- if (!isFlux2(candidate)) {- cleanupReqFilesTemp();- throw new ServerError(- 'Reference images are only supported for FLUX.2 models on the local backend',- { status: 400, code: 'REFERENCE_IMAGES_FLUX2_ONLY' },- );- }+ throw new ServerError(+ 'Reference images are only supported for FLUX.2 models on the local backend',+ { status: 400, code: 'REFERENCE_IMAGES_FLUX2_ONLY' },+ );}}@@ -180,7 +180,6 @@ export async function prepareGenerateParams({ data, files, referenceImageFields// so this only fires for direct API callers — but a silent drop is exactly// the failure the sidecar-honesty rule exists to prevent. `resolveInputImages`// keeps its own cap as the backstop for in-process callers that skip the route.- const inputImageCount = (initUpload || data.initImageFile ? 1 : 0) + referenceUploads.length;const inputImageCap = maxInputImages(mode);if (inputImageCap != null && inputImageCount > inputImageCap) {cleanupReqFilesTemp();diff --git a/server/services/imageGenQuota.js b/server/services/imageGenQuota.jsindex 34daf95cf4..869145d3d0 100644--- a/server/services/imageGenQuota.js+++ b/server/services/imageGenQuota.js@@ -32,7 +32,7 @@*/import { join } from 'path';-import { IMAGE_GEN_MODE, CLOUD_IMAGE_GEN_MODES, IMAGE_TOOL_NAMES } from './imageGen/modes.js';+import { CLOUD_IMAGE_GEN_MODES, IMAGE_TOOL_NAMES, modeLabel } from './imageGen/modes.js';import { imageGenEvents } from './imageGenEvents.js';import { atomicWrite, PATHS, readJSONFileStrict } from '../lib/fileUtils.js';import { createFileWriteQueue } from '../lib/fileWriteQueue.js';@@ -54,14 +54,8 @@ const UNKNOWN_BLOCK_TTL_MS = 60 * 60 * 1000;// user's own GPU and external hits their own SD endpoint, so neither has// anything to report. Keyed off CLOUD_IMAGE_GEN_MODES rather than a second// hand-maintained list, so a 4th cloud backend is tracked the moment it is-// added there. Labels mirror the client's MODE_LABELS so one backend doesn't-// appear under two names across the UI.-const MODE_LABELS = Object.freeze({- [IMAGE_GEN_MODE.AGY]: 'Agy',- [IMAGE_GEN_MODE.GROK]: 'Grok',- [IMAGE_GEN_MODE.CODEX]: 'Codex',-});-+// added there. Display names come from `modeLabel` for the same reason — one+// backend must not appear under two names across the UI.export const isQuotaTrackedImageMode = (mode) => CLOUD_IMAGE_GEN_MODES.includes(mode);/** Card id for the image-gen quota card, in the same namespace as the provider@@ -69,7 +63,7 @@ export const isQuotaTrackedImageMode = (mode) => CLOUD_IMAGE_GEN_MODES.includes(export const IMAGE_GEN_FAMILY = 'imagegen';const rowLabel = (mode) =>- `${MODE_LABELS[mode] || mode} · ${IMAGE_TOOL_NAMES[mode] || 'image tool'}`;+ `${modeLabel(mode)} · ${IMAGE_TOOL_NAMES[mode] || 'image tool'}`;// Single tail: two renders finishing together must not interleave their// read-modify-write on the shared ledger file.@@ -249,7 +243,7 @@ export async function getImageGenQuota({ enabledModes = [], now = Date.now() } =key,label,scope: 'image',- model: MODE_LABELS[mode] || mode,+ model: modeLabel(mode),percentUsed: 100,percentRemaining: 0,// Null when the provider didn't state one — the meter renders without a