Skip to content

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

parse the `<id>\t<Label>` rows agy models prints now, not just bare ids

[._.]/ Adam Eivydd130d92e9df
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index be133e665e..d9138b70f4 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -257,3 +257,5 @@
- **[issue-3736] The per-runtime video mode gates now resolve through one contract.** `wan22` and `minimax_h3` each carried a near-copy of the same five-step mode gate — resolve the requested mode, check it against the model's `supportedModes`, forbid a conditioning image in text mode, require a source in image mode — restated at *both* the route boundary (`prepareParams.js`) and the render boundary (`local.js`), four copies in all. They had already drifted: wan22 had no first/last-frame rules at all, and identical request shapes returned differently-worded errors depending on which copy caught them. Every one of those gates now calls `videoModeContractError` in `server/services/videoGen/modeContract.js`, a single `supportedModes`-driven rule table with a per-runtime row supplying only its error-code prefix and its wording; adding a runtime is now a row, not another forty lines across two files, and the module records that as a hard rule. No API change — `WAN22_*`, `MINIMAX_H3_*` and `VIDEO_CHAIN_REQUIRES_IMAGE_MODE` all keep their codes and messages, and the existing route and service suites pass unmodified. One drift closes as a side effect: an H3 request naming a gallery image that no longer resolves is now rejected at the route with `MINIMAX_H3_I2V_REQUIRES_IMAGE`, the way the wan22 lane always was, instead of being enqueued and failing later in the worker.
- **[issue-3737] Every video model now carries a resolved `supportedModes`, so capability is a registry fact instead of a hardcoded runtime list.** "Which modes does this model actually support?" had no single answer: `wan22` and `minimax_h3` entries declared `supportedModes`, `mlx_video` and `ltx2` declared nothing, and `hunyuan` carried a legacy `mode: 't2v'` field no reader ever consulted. The client's model picker read "declares nothing" as "supports everything" — so it offered FFLF on runtimes whose helper takes a single `--image` and silently drops the other keyframe, a UI claiming a capability the render path doesn't honor. `server/lib/videoModeProfiles.js` now states each runtime's modes once, as facts about its helper's argv (`mlx_video`/`ltx2` text+image+fflf+extend, `wan22` text+image, `minimax_h3` text+image+fflf — also the mode ceiling `modeContract.js` enforces, so the two can't drift — `hunyuan` text only, replacing the retired `mode: 't2v'`), and `getVideoModels()` resolves it on read — the way `listVideoModels()` already decorates `lastFrameAnchored` — so it covers the load path, the user-model mutators that bypass the load-time normalizer, and peer-synced entries in one place. Deriving on read rather than backfilling into the file (as the sibling `disclosure` / `finishModelId` facts do) is deliberate: a persisted copy reads back as a *declared* list, which is exactly what no later correction to the table could reach. An entry that declares its own list always wins, and there is no migration. `isModelAllowedForMode` lost its "no `supportedModes` ⇒ allow everything" fallback as a result. mlx_video's FFLF is declared *honestly rather than absent* — the mode does run, and the caveat rides on the existing `lastFrameAnchored: false` the client renders as "last frame is advisory". The server-side gate reads the same resolver, so `videoChainUnsupportedError` no longer waves an unresolved entry through as unconstrained while the picker hides it, and the client's two hand-rolled "can this model chain?" copies now ask `isModelAllowedForMode` instead of re-reading the field. An unknown runtime — a user-added model, or one synced from a newer peer — keeps the full base mode set rather than vanishing from every picker.
+
+- **Image Gen's agy model picker lists models again, instead of reporting an empty catalog against a healthy one.** Choosing `agy` as the Image Gen provider showed "agy models returned no model ids — renders will use the model saved in Settings → Image Gen", with `agy models` printing a full eleven-model catalog on stdout the whole time. The parser dated from a build that printed one bare model id per line; agy now prints `<id>\t<Label>` rows (`gemini-3.6-flash-high⇥Gemini 3.6 Flash (High)`), so every row failed the bare-id test and the list came back empty — which the picker correctly refuses to present as a real fetch. Both the id-only and the tab-labelled shapes are now accepted, since other installs run older builds and every previously-persisted catalog was parsed under the old rule. The label is anchored on the tab rather than split on first whitespace on purpose: agy's own banner prose ("Fetching available models…") leads with a word that passes the id pattern, and a whitespace split would have persisted "Fetching" as a model. The same stale parse sat in the provider-catalog refresh behind Settings → Providers → Refresh models, whose failure was louder (it throws rather than falling back to the shipped seed) but has the identical cause; both now share one definition — `parseAntigravityModelList` in `server/lib/antigravity.js`, mirrored into the vendored toolkit copy — with a test that fails if the two ever disagree on any output shape.
diff --git a/server/lib/README.md b/server/lib/README.md
index 6cdd6f11e5..d1e14dd382 100644
--- a/server/lib/README.md
+++ b/server/lib/README.md
@@ -96,7 +96,7 @@ The barrel `server/lib/index.js` is a machine-checkable enumeration of every pub
|---|---|
| `aiToolkit/` | Vendored toolkit (providers + runner + prompts + status). See `aiToolkit/index.js`. |
| `aiToolkitState.js` | Module-level singleton for the toolkit instance shared by the `providers`/`runner`/`promptService` shims — `setAIToolkitInstance` / `requireToolkit` (throws `AI_TOOLKIT_NOT_INITIALIZED`) / `getAIToolkitInstance` (no-throw for cleanup paths). |
-| `antigravity.js` | Antigravity (`agy`) CLI provider helpers — id/sentinel constants (`ANTIGRAVITY_CLI_ID`, `ANTIGRAVITY_CONFIGURED_DEFAULT`, `LEGACY_GEMINI_*`), `isAntigravityCommand`/`isAntigravityCliProvider` predicates, and `ensureAntigravityPrintArgs(args, {model, effort})`/`ensureAntigravityTuiArgs(args, {model, effort})`/`stripAntigravityUnsupportedArgs` argv normalizers. The strip drops legacy Gemini `--yolo`/`-m`/`--output-format` but PRESERVES the long `--model` (agy accepts it as a per-session flag, so a user-baked pin is a real selection and suppresses the injected one); the two builders inject `--model`/`--effort` from the per-run overrides, always ahead of the trailing `--print` marker whose value is the prompt. |
+| `antigravity.js` | Antigravity (`agy`) CLI provider helpers — id/sentinel constants (`ANTIGRAVITY_CLI_ID`, `ANTIGRAVITY_CONFIGURED_DEFAULT`, `LEGACY_GEMINI_*`), `isAntigravityCommand`/`isAntigravityCliProvider` predicates, and `ensureAntigravityPrintArgs(args, {model, effort})`/`ensureAntigravityTuiArgs(args, {model, effort})`/`stripAntigravityUnsupportedArgs` argv normalizers. `parseAntigravityModelList(stdout)` parses `agy models` rows — accepts both the modern `<id>\t<Label>` shape and the older bare-id-per-line one, deduped, sentinel dropped (mirrored in the vendored toolkit's `internal/antigravity.js`; used by both the provider-catalog refresh and Image Gen's agy model picker). `isAntigravityModelId(id)` is the same id shape as a bare predicate, for spawn sites building an `agy --model` argv from a value no route schema bounded. The strip drops legacy Gemini `--yolo`/`-m`/`--output-format` but PRESERVES the long `--model` (agy accepts it as a per-session flag, so a user-baked pin is a real selection and suppresses the injected one); the two builders inject `--model`/`--effort` from the per-run overrides, always ahead of the trailing `--print` marker whose value is the prompt. |
| `aiProvider.js` | Shared AI provider utilities for LLM calls. |
| `promptRunner.js` | Shared LLM runner wrapper. |
| `providerCooldown.js` | Provider bench policy — `resolveProviderBench(analysis)` → `null` (don't bench) / a `usage-limit` marker / an `unavailable` marker with the per-category cooldown from `COOLDOWN_MS_BY_CATEGORY`. Declines to bench request/response-specific categories (`isRequestSpecificCategory` / `isSchemaTypeCategory`) so one bad model id or off-shape response can't take a healthy provider offline. Shared by `promptRunner.js` (prompt cascade) and `services/agentFinalization.js` (finished CoS agent run) so both bench a category for the same window. Pure. |
diff --git a/server/lib/aiToolkit/internal/antigravity.js b/server/lib/aiToolkit/internal/antigravity.js
index 127aa0bc09..7f11b736af 100644
--- a/server/lib/aiToolkit/internal/antigravity.js
+++ b/server/lib/aiToolkit/internal/antigravity.js
@@ -23,23 +23,40 @@ export function isAntigravityCommand(command) {
return base === 'agy' || base === 'antigravity';
}
-// `agy models` prints one bare model id per line. Toolkit-native (there is no
-// upstream counterpart to keep in sync) — it lives here so it sits next to
-// ./cursor.js#parseCursorModelList and gets direct unit coverage, rather than
-// being reachable only by spawning a fake binary through the provider service.
-const ANTIGRAVITY_MODEL_LINE = /^[A-Za-z0-9][A-Za-z0-9._:/-]*$/;
+// `agy models` prints one row per model on stdout (its "Fetching available
+// models…" banner goes to stderr, so it never reaches this parser). Older
+// builds printed a bare id per line; agy 2026-08 prints `<id>\t<Label>`:
+//
+// gemini-3.6-flash-high\tGemini 3.6 Flash (High)
+// claude-sonnet-4-6\tClaude Sonnet 4.6 (Thinking)
+//
+// Both shapes are accepted — other installs run older agy builds, and a
+// whole-line id match is what every previously-persisted catalog was parsed
+// with. The label is anchored on a TAB rather than "first whitespace token" on
+// purpose: a prose line ("Available models") would otherwise surrender a
+// regex-valid first word and get persisted as a model id.
+//
+// Lives here so it sits next to ./cursor.js#parseCursorModelList and gets
+// direct unit coverage, rather than being reachable only by spawning a fake
+// binary through the provider service. Mirrored upstream at
+// server/lib/antigravity.js#parseAntigravityModelList (PortOS's image-gen agy
+// provider needs the same parse and cannot import into this directory's
+// `internal/`) — keep the two in sync.
+const ANTIGRAVITY_MODEL_LINE = /^([A-Za-z0-9][A-Za-z0-9._:/-]*)(?:\t.*)?$/;
/**
* Parse the ids out of `agy models` output, dropping blanks, banner/status
* prose, and the configured-default sentinel (which the caller re-prepends).
* @param {string} stdout - raw stdout from `agy models`
- * @returns {string[]} ids in the order the binary listed them (not deduped)
+ * @returns {string[]} deduped ids, in the order the binary listed them
*/
export function parseAntigravityModelList(stdout) {
- return String(stdout || '')
- .split(/\r?\n/)
- .map(line => line.trim())
- .filter(line => ANTIGRAVITY_MODEL_LINE.test(line) && line !== ANTIGRAVITY_CONFIGURED_DEFAULT);
+ const ids = [];
+ for (const line of String(stdout || '').split(/\r?\n/)) {
+ const match = ANTIGRAVITY_MODEL_LINE.exec(line.trim());
+ if (match && match[1] !== ANTIGRAVITY_CONFIGURED_DEFAULT) ids.push(match[1]);
+ }
+ return [...new Set(ids)];
}
export function isAntigravityCliProvider(provider) {
diff --git a/server/lib/aiToolkit/internal/antigravity.test.js b/server/lib/aiToolkit/internal/antigravity.test.js
index c1d0ee6507..74755fe4ce 100644
--- a/server/lib/aiToolkit/internal/antigravity.test.js
+++ b/server/lib/aiToolkit/internal/antigravity.test.js
@@ -2,9 +2,12 @@ import { describe, it, expect } from 'vitest';
import { ANTIGRAVITY_CONFIGURED_DEFAULT, isAntigravityCommand, parseAntigravityModelList } from './antigravity.js';
// The toolkit SOURCE may not import out to server/lib (see ../CLAUDE.md); a test
// may, and this is the only way to actually pin the duplication it documents.
-import { isAntigravityCommand as upstreamIsAntigravityCommand } from '../../antigravity.js';
+import {
+ isAntigravityCommand as upstreamIsAntigravityCommand,
+ parseAntigravityModelList as upstreamParseAntigravityModelList,
+} from '../../antigravity.js';
-// `agy models` prints one bare id per line. Shape reproduced from the real
+// Older agy builds print one bare id per line. Shape reproduced from the real
// binary: a blank line, the ids, and (on some builds) a status/banner line the
// filter has to reject.
const REAL_OUTPUT = `
@@ -15,6 +18,19 @@ gpt-5.2-codex
`;
+// agy 2026-08 prints `<id>\t<Label>` instead. Transcribed verbatim from
+// `agy models` stdout (the "Fetching available models…" banner goes to stderr,
+// so it never reaches the parser). Parsing this shape as bare ids yields ZERO
+// models, which is what broke the Image Gen agy model picker.
+const TAB_LABELLED_OUTPUT = [
+ 'gemini-3.6-flash-high\tGemini 3.6 Flash (High)',
+ 'gemini-3.6-flash-medium\tGemini 3.6 Flash (Medium)',
+ 'gemini-3.1-pro-high\tGemini 3.1 Pro (High)',
+ 'claude-sonnet-4-6\tClaude Sonnet 4.6 (Thinking)',
+ 'gpt-oss-120b-medium\tGPT-OSS 120B (Medium)',
+ '',
+].join('\n');
+
describe('parseAntigravityModelList', () => {
// Success-path coverage for the parser extracted out of providers.js. Without
// it, `agy models` had no test that ever fed the filter real output — only a
@@ -29,6 +45,28 @@ describe('parseAntigravityModelList', () => {
]);
});
+ it('extracts the id column from the tab-labelled shape agy prints today', () => {
+ expect(parseAntigravityModelList(TAB_LABELLED_OUTPUT)).toEqual([
+ 'gemini-3.6-flash-high',
+ 'gemini-3.6-flash-medium',
+ 'gemini-3.1-pro-high',
+ 'claude-sonnet-4-6',
+ 'gpt-oss-120b-medium',
+ ]);
+ });
+
+ it('rejects prose rather than surrendering its first word as an id', () => {
+ // The reason the label is anchored on a TAB and not "first whitespace
+ // token": every one of these lines leads with a regex-valid word, and a
+ // whitespace split would persist "Fetching"/"Available"/"Tip" as models.
+ expect(parseAntigravityModelList([
+ 'Fetching available models...',
+ 'Available models',
+ 'Tip: use --model <id> to switch',
+ 'gemini-3.6-flash-high\tGemini 3.6 Flash (High)',
+ ].join('\n'))).toEqual(['gemini-3.6-flash-high']);
+ });
+
it('drops banner/status prose — anything that is not a bare id', () => {
const out = parseAntigravityModelList('Available models:\ngemini-3.1-pro\nTip: use --model <id>\n');
expect(out).toEqual(['gemini-3.1-pro']);
@@ -72,4 +110,23 @@ describe('vendored copy stays in sync with server/lib/antigravity.js', () => {
.toBe(upstreamIsAntigravityCommand(c));
}
});
+
+ it('agrees with upstream on every `agy models` output shape', () => {
+ // Image Gen parses `agy models` through the upstream copy and the provider
+ // catalog refresh through this one. A fix applied to only one of them is
+ // exactly how the picker went empty while the catalog still worked.
+ const cases = [
+ REAL_OUTPUT,
+ TAB_LABELLED_OUTPUT,
+ 'Available models:\ngemini-3.1-pro\nTip: use --model <id>\n',
+ `${ANTIGRAVITY_CONFIGURED_DEFAULT}\ngemini-3.1-pro\n`,
+ 'gemini-3.1-pro\r\nclaude-sonnet-4-6\r\n',
+ 'gpt-5.2-codex\nqwen2.5:7b\nvendor/model\nnot an id\n',
+ '',
+ ];
+ for (const c of cases) {
+ expect(parseAntigravityModelList(c), `disagreement on ${JSON.stringify(c)}`)
+ .toEqual(upstreamParseAntigravityModelList(c));
+ }
+ });
});
diff --git a/server/lib/antigravity.js b/server/lib/antigravity.js
index b168c8bcec..6f4b1a5991 100644
--- a/server/lib/antigravity.js
+++ b/server/lib/antigravity.js
@@ -25,6 +25,56 @@ export function isAntigravityCliProvider(provider) {
return provider?.id === ANTIGRAVITY_CLI_ID || isAntigravityCommand(provider?.command);
}
+// `agy models` prints one row per model on stdout (its "Fetching available
+// models…" banner goes to stderr, so it never reaches this parser). Older
+// builds printed a bare id per line; agy 2026-08 prints `<id>\t<Label>`:
+//
+// gemini-3.6-flash-high\tGemini 3.6 Flash (High)
+// claude-sonnet-4-6\tClaude Sonnet 4.6 (Thinking)
+//
+// Both shapes are accepted — other installs run older agy builds, and a
+// whole-line id match is what every previously-persisted catalog was parsed
+// with. The label is anchored on a TAB rather than "first whitespace token" on
+// purpose: a prose line ("Available models") would otherwise surrender a
+// regex-valid first word and get persisted as a model id.
+//
+// The id shape itself is the charset `validation.js#cloudModelIdString` bounds
+// its Zod schemas with; it is restated here rather than imported because
+// `validation.js` pulls in the whole route-schema graph, which several mocked
+// suites cannot absorb.
+const ANTIGRAVITY_MODEL_ID = /^[A-Za-z0-9][A-Za-z0-9._:/-]*$/;
+const ANTIGRAVITY_MODEL_LINE = /^([A-Za-z0-9][A-Za-z0-9._:/-]*)(?:\t.*)?$/;
+
+/**
+ * Is this a syntactically valid agy model id? The defense-in-depth check
+ * behind `agyImageModelSchema`, for spawn sites that build an `agy --model`
+ * argv from a value the route schema didn't already bound.
+ * @param {unknown} id
+ */
+export function isAntigravityModelId(id) {
+ return typeof id === 'string' && ANTIGRAVITY_MODEL_ID.test(id);
+}
+
+/**
+ * Parse the ids out of `agy models` output, dropping blanks, banner/status
+ * prose, and the configured-default sentinel (which callers re-prepend).
+ *
+ * Mirrored in the vendored toolkit at
+ * `server/lib/aiToolkit/internal/antigravity.js` (which must not import out of
+ * its own directory) — keep the two in sync.
+ *
+ * @param {string} stdout - raw stdout from `agy models`
+ * @returns {string[]} deduped ids, in the order the binary listed them
+ */
+export function parseAntigravityModelList(stdout) {
+ const ids = [];
+ for (const line of String(stdout || '').split(/\r?\n/)) {
+ const match = ANTIGRAVITY_MODEL_LINE.exec(line.trim());
+ if (match && match[1] !== ANTIGRAVITY_CONFIGURED_DEFAULT) ids.push(match[1]);
+ }
+ return [...new Set(ids)];
+}
+
// agy print flags. Unlike the old Gemini CLI (which read the prompt from stdin),
// `agy --print`/`-p`/`--prompt` takes the prompt as the flag's VALUE and does
// NOT read stdin at all. So the print flag must be the FINAL token, with the
diff --git a/server/services/imageGen/agy.js b/server/services/imageGen/agy.js
index 3968bf6d76..da22ed1267 100644
--- a/server/services/imageGen/agy.js
+++ b/server/services/imageGen/agy.js
@@ -19,6 +19,8 @@ import { tmpdir } from 'os';
import sharp from 'sharp';
import {
ensureAntigravityPrintArgs,
+ isAntigravityModelId,
+ parseAntigravityModelList,
prepareAntigravityPrompt,
} from '../../lib/antigravity.js';
import { bufferedSpawn, killProcessTree, prepareCliSpawn } from '../../lib/bufferedSpawn.js';
@@ -44,7 +46,6 @@ const AGY_TIMEOUT_MS = (() => {
})();
const DEFAULT_BIN = 'agy';
const DEFAULT_HARVEST_TIMEOUT_MS = 5000;
-const MODEL_ID_RE = /^[A-Za-z0-9][A-Za-z0-9._:/-]*$/;
let harvestTimeoutMs = DEFAULT_HARVEST_TIMEOUT_MS;
const jobs = new Map();
@@ -132,9 +133,9 @@ export function listModels({ agyPath } = {}) {
finish({ models: [], error: stderr.trim() || `agy models exited ${code}` });
return;
}
- const models = [...new Set(stdout.split(/\r?\n/)
- .map((line) => line.trim())
- .filter((line) => MODEL_ID_RE.test(line)))];
+ // Shared with the provider-catalog refresh so the two never disagree
+ // about what a `models` row looks like — see parseAntigravityModelList.
+ const models = parseAntigravityModelList(stdout);
finish(models.length ? { models, error: null } : { models: [], error: 'agy models returned no model ids' });
});
});
@@ -226,7 +227,7 @@ export async function generateImage({
if (cloudPromptRequired(IMAGE_GEN_MODE.AGY, inputImages.paths.length > 0) && !prompt.trim()) {
throw new ServerError('Prompt is required', { status: 400, code: 'VALIDATION_ERROR' });
}
- if (model && !MODEL_ID_RE.test(model)) {
+ if (model && !isAntigravityModelId(model)) {
throw new ServerError('Invalid Agy model id', { status: 400, code: 'VALIDATION_ERROR' });
}
diff --git a/server/services/imageGen/agy.test.js b/server/services/imageGen/agy.test.js
index 03d8a78f86..1c17cc300c 100644
--- a/server/services/imageGen/agy.test.js
+++ b/server/services/imageGen/agy.test.js
@@ -79,6 +79,25 @@ describe('agy image provider', () => {
});
});
+ // agy 2026-08 prints `<id>\t<Label>` rows, not the bare ids this parser was
+ // originally written against — so every row failed the id test and the picker
+ // reported "agy models returned no model ids" with a full, healthy catalog on
+ // stdout. Transcribed verbatim from the real binary.
+ it('lists models from the tab-labelled output agy prints today', async () => {
+ const pending = agy.listModels({ agyPath: '/opt/agy' });
+ spawnCalls[0].child.stdout.emit('data', [
+ 'gemini-3.6-flash-high\tGemini 3.6 Flash (High)',
+ 'gemini-3.1-pro-high\tGemini 3.1 Pro (High)',
+ 'claude-sonnet-4-6\tClaude Sonnet 4.6 (Thinking)',
+ '',
+ ].join('\n'));
+ spawnCalls[0].child.emit('close', 0, null);
+ await expect(pending).resolves.toEqual({
+ models: ['gemini-3.6-flash-high', 'gemini-3.1-pro-high', 'claude-sonnet-4-6'],
+ error: null,
+ });
+ });
+
it('spawns headlessly with the selected model and a directed one-image prompt', async () => {
const job = await agy.generateImage({
prompt: 'a fox beneath the stars',