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
Hide Grok Build model selection like Antigravity
[._.]/ Adam Eivydd2a924daee0
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex b64cd91d15..d6643de7e6 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -8,6 +8,8 @@- **[issue-2336] xAI Grok is now a built-in AI provider — API, Grok Build CLI, and Grok Build TUI.** Three new providers ship ready to enable under AI Providers: **xAI Grok** (the OpenAI-compatible chat API at `https://api.x.ai/v1` — paste your xAI key and pick a model), **Grok Build CLI** (headless, for one-shot generations and file-writing CoS agents), and **Grok Build TUI** (the interactive `grok` coding agent driven over a PTY like Claude Code / Codex). All three arrive disabled by default (nothing calls Grok until you turn one on) and reach existing installs on upgrade. The CLI/TUI use the local `grok` binary; run `grok login` (or set your xAI credentials) to authenticate it.+- **Grok Build CLI/TUI no longer show a model picker — they use the binary's latest default, like Antigravity.** The CLI and TUI now store a `grok-configured-default` sentinel (same pattern as Codex / Antigravity), so provider/model dropdowns hide model selection and spawn paths omit `--model`, letting the local `grok` binary pick its current default. The xAI Grok **API** provider is unchanged and still lets you choose among chat models.+## Layered Intelligence- **Layered Intelligence now runs as a visible agent you can watch — and talk to in a TUI — instead of an invisible in-process handler.** It used to be a "handler-backed" task: on each fire it made one inline reasoning call and filed a tracker issue with no agent record, so it never appeared in the CoS queue or the Active Agents page and couldn't be interacted with mid-run. It's now a normal agent-backed scheduled task with two programmatic slots around the agent — a pre-agent step that gathers the app's goals/telemetry/open issues and builds the reasoning prompt, and a post-agent step that validates the agent's structured output and files exactly one deduplicated tracker issue. The reasoning run shows up as an agent like any other automation, and when you select a TUI provider/model you can attach to its terminal and message it while it thinks (`btw`). The "reasoner never writes code" guarantee is preserved by isolation: the agent runs in a throwaway git worktree that is discarded without a commit, push, or merge, so its only durable output is the structured result the filing step consumes. This generalizes into a reusable "programmatic-I/O task" mechanism (pre-agent input hook + post-agent output hook) for future task types that need deterministic data collection or output processing around an agent. Existing installs inherit the throwaway-worktree posture automatically on upgrade (schedule defaults are backfilled) — no migration needed. Per-app enable/interval/provider/model and behavior config (sources, scopes, rules, hand-off) are unchanged, and the Edit App → Intelligence "Last run" status still reflects filed/parked/skipped/no-op outcomes.diff --git a/client/src/pages/AIProviders.jsx b/client/src/pages/AIProviders.jsxindex d0f3a0434c..498d546329 100644--- a/client/src/pages/AIProviders.jsx+++ b/client/src/pages/AIProviders.jsx@@ -148,8 +148,9 @@ export default function AIProviders() {if (isTuiProvider(provider)) {return false;}- // Antigravity/Gemini CLIs use their own local model configuration.- if (provider.type === 'cli' && (provider.command === 'agy' || provider.command === 'gemini')) {+ // Antigravity/Gemini/Grok Build CLIs use their own local model configuration+ // (no PortOS model list to refresh — same as the configured-default sentinel).+ if (provider.type === 'cli' && (provider.command === 'agy' || provider.command === 'gemini' || provider.command === 'grok')) {return false;}// All other providers support refresh (API and CLI)diff --git a/client/src/utils/providers.js b/client/src/utils/providers.jsindex e297036690..ae658757d2 100644--- a/client/src/utils/providers.js+++ b/client/src/utils/providers.js@@ -7,6 +7,16 @@ import { formatContextLength } from './formatters.js';*/export const CODEX_CONFIGURED_DEFAULT = 'codex-configured-default';export const ANTIGRAVITY_CONFIGURED_DEFAULT = 'antigravity-configured-default';+export const GROK_CONFIGURED_DEFAULT = 'grok-configured-default';++const CONFIGURED_DEFAULT_SENTINELS = new Set([+ CODEX_CONFIGURED_DEFAULT,+ ANTIGRAVITY_CONFIGURED_DEFAULT,+ GROK_CONFIGURED_DEFAULT,+]);++/** True for any provider "use CLI's own default" sentinel. Mirror of server `isConfiguredDefaultModel`. */+export const isConfiguredDefaultModel = (model) => CONFIGURED_DEFAULT_SENTINELS.has(model);export const DEFAULT_LARGE_CONTEXT_WINDOW = 128_000;export const CODEX_CONTEXT_WINDOW = 1_000_000;@@ -74,7 +84,7 @@ export const PROVIDER_TYPES = Object.freeze({* @returns {string[]}*/export const filterSelectableModels = (models) =>- (models || []).filter(m => m !== CODEX_CONFIGURED_DEFAULT && m !== ANTIGRAVITY_CONFIGURED_DEFAULT);+ (models || []).filter(m => !isConfiguredDefaultModel(m));/*** Embedding-only model detector — mirror of `isEmbeddingModel` indiff --git a/client/src/utils/providers.test.js b/client/src/utils/providers.test.jsindex 4dc5d2d9fc..d3a4c9517e 100644--- a/client/src/utils/providers.test.js+++ b/client/src/utils/providers.test.js@@ -2,6 +2,7 @@ import { describe, it, expect } from 'vitest';import {ANTIGRAVITY_CONFIGURED_DEFAULT,CODEX_CONFIGURED_DEFAULT,+ GROK_CONFIGURED_DEFAULT,providerDisplayName,assignmentProviderOptions,assignmentModelOptions,@@ -53,7 +54,13 @@ describe('PROVIDER_TYPES', () => {describe('filterSelectableModels', () => {it('drops configured-default sentinels', () => {- expect(filterSelectableModels(['gpt-4', CODEX_CONFIGURED_DEFAULT, ANTIGRAVITY_CONFIGURED_DEFAULT, 'gpt-5'])).toEqual(['gpt-4', 'gpt-5']);+ expect(filterSelectableModels([+ 'gpt-4',+ CODEX_CONFIGURED_DEFAULT,+ ANTIGRAVITY_CONFIGURED_DEFAULT,+ GROK_CONFIGURED_DEFAULT,+ 'gpt-5',+ ])).toEqual(['gpt-4', 'gpt-5']);});it('returns an empty array for null/undefined input', () => {@@ -339,8 +346,8 @@ describe('effectiveModelContextWindow', () => {it('uses canonical provider windows for configured-default process providers', () => {expect(effectiveModelContextWindow({ id: 'codex-tui', type: 'tui', command: 'codex' }, CODEX_CONFIGURED_DEFAULT)).toBe(1_000_000);expect(effectiveModelContextWindow({ id: 'antigravity-cli', type: 'cli', command: 'agy' }, ANTIGRAVITY_CONFIGURED_DEFAULT)).toBe(1_048_576);- expect(effectiveModelContextWindow({ id: 'grok-cli', type: 'cli', command: 'grok' }, 'grok-build')).toBe(256_000);- expect(effectiveModelContextWindow({ id: 'grok-tui', type: 'tui', command: 'grok' }, 'grok-build')).toBe(256_000);+ expect(effectiveModelContextWindow({ id: 'grok-cli', type: 'cli', command: 'grok' }, GROK_CONFIGURED_DEFAULT)).toBe(256_000);+ expect(effectiveModelContextWindow({ id: 'grok-tui', type: 'tui', command: 'grok' }, GROK_CONFIGURED_DEFAULT)).toBe(256_000);});it('matches the server planner for local and cloud api defaults', () => {diff --git a/data.reference/providers.json b/data.reference/providers.jsonindex 6b8766255e..ad77ecd7db 100644--- a/data.reference/providers.json+++ b/data.reference/providers.json@@ -271,11 +271,11 @@"type": "cli","command": "grok","args": [],- "models": ["grok-build"],- "defaultModel": "grok-build",- "lightModel": "grok-build",- "mediumModel": "grok-build",- "heavyModel": "grok-build",+ "models": ["grok-configured-default"],+ "defaultModel": "grok-configured-default",+ "lightModel": "grok-configured-default",+ "mediumModel": "grok-configured-default",+ "heavyModel": "grok-configured-default","contextWindow": 256000,"timeout": 300000,"enabled": false,@@ -288,11 +288,11 @@"type": "tui","command": "grok","args": [],- "models": ["grok-build"],- "defaultModel": "grok-build",- "lightModel": "grok-build",- "mediumModel": "grok-build",- "heavyModel": "grok-build",+ "models": ["grok-configured-default"],+ "defaultModel": "grok-configured-default",+ "lightModel": "grok-configured-default",+ "mediumModel": "grok-configured-default",+ "heavyModel": "grok-configured-default","contextWindow": 256000,"timeout": 600000,"enabled": false,diff --git a/scripts/migrations/186-grok-configured-default.js b/scripts/migrations/186-grok-configured-default.jsnew file mode 100644index 0000000000..ca42b8f2ac--- /dev/null+++ b/scripts/migrations/186-grok-configured-default.js@@ -0,0 +1,97 @@+/**+ * Rewrite Grok Build CLI/TUI model fields from the short-lived `grok-build`+ * pseudo-model to the `grok-configured-default` sentinel (Antigravity/Codex+ * pattern). PortOS never selects a Grok Build model — the local `grok` binary+ * uses its own latest default, so the model picker should stay hidden.+ *+ * Migration 185 shipped the CLI/TUI with `models: ['grok-build']` (a real-looking+ * id that still appeared in model dropdowns). This migration rewrites only the+ * shipped `grok-build` value on model fields; any other custom model id is left+ * alone so a user who intentionally pinned a concrete model keeps it.+ *+ * Kept in lockstep with data.reference/providers.json and+ * server/lib/aiToolkit/defaults/providers.sample.json.+ */++import { readFile, writeFile } from 'fs/promises';+import { join } from 'path';++const PROVIDERS_REL_PATH = 'data/providers.json';+const TARGET_IDS = ['grok-cli', 'grok-tui'];+const OLD = 'grok-build';+const NEW = 'grok-configured-default';+const MODEL_FIELDS = ['defaultModel', 'lightModel', 'mediumModel', 'heavyModel', 'fallbackModel'];++const rewriteModelsList = (models) => {+ if (!Array.isArray(models)) return { models, changed: false };+ let changed = false;+ const next = models.map((m) => {+ if (m === OLD) {+ changed = true;+ return NEW;+ }+ return m;+ });+ return { models: next, changed };+};++const rewriteProvider = (provider) => {+ if (!provider || typeof provider !== 'object') return false;+ let changed = false;++ const list = rewriteModelsList(provider.models);+ if (list.changed) {+ provider.models = list.models;+ changed = true;+ }++ for (const field of MODEL_FIELDS) {+ if (provider[field] === OLD) {+ provider[field] = NEW;+ changed = true;+ }+ }++ return changed;+};++export default {+ async up({ rootDir }) {+ const providersPath = join(rootDir, PROVIDERS_REL_PATH);+ const raw = await readFile(providersPath, 'utf-8').catch((err) => {+ if (err.code === 'ENOENT') return null;+ throw err;+ });+ if (raw == null) {+ console.log(`📄 ${PROVIDERS_REL_PATH} not present — skipping (fresh install seeds Grok Build from data.reference)`);+ return;+ }++ let config;+ try {+ config = JSON.parse(raw);+ } catch (err) {+ console.log(`⚠️ ${PROVIDERS_REL_PATH}: invalid JSON, skipping (${err.message})`);+ return;+ }++ if (!config || typeof config !== 'object' || !config.providers || typeof config.providers !== 'object') {+ console.log(`⚠️ ${PROVIDERS_REL_PATH}: unexpected shape, skipping`);+ return;+ }++ let changed = false;+ for (const id of TARGET_IDS) {+ if (rewriteProvider(config.providers[id])) {+ changed = true;+ console.log(`📝 ${PROVIDERS_REL_PATH}: ${id} model fields ${OLD} → ${NEW}`);+ }+ }++ if (changed) {+ await writeFile(providersPath, `${JSON.stringify(config, null, 2)}\n`);+ } else {+ console.log(`✅ ${PROVIDERS_REL_PATH}: Grok Build CLI/TUI already on configured-default sentinel — no change`);+ }+ },+};diff --git a/scripts/migrations/186-grok-configured-default.test.js b/scripts/migrations/186-grok-configured-default.test.jsnew file mode 100644index 0000000000..b9172edb0b--- /dev/null+++ b/scripts/migrations/186-grok-configured-default.test.js@@ -0,0 +1,150 @@+/**+ * Test for migration 186 — rewrite Grok Build CLI/TUI from `grok-build` to+ * the `grok-configured-default` sentinel. Picked up by server/vitest.config.js's+ * `../scripts/**\/*.test.js` glob.+ */+import { describe, it, expect, beforeEach, afterEach } from 'vitest';+import { mkdtempSync, rmSync, writeFileSync, readFileSync, mkdirSync, existsSync } from 'fs';+import { tmpdir } from 'os';+import { join } from 'path';++import migration from './186-grok-configured-default.js';++const writeJson = (path, value) => writeFileSync(path, JSON.stringify(value, null, 2) + '\n');+const readJson = (path) => JSON.parse(readFileSync(path, 'utf-8'));++describe('migration 186 — Grok Build configured-default sentinel', () => {+ let rootDir;+ let providersPath;++ beforeEach(() => {+ rootDir = mkdtempSync(join(tmpdir(), 'migration-186-'));+ mkdirSync(join(rootDir, 'data'), { recursive: true });+ providersPath = join(rootDir, 'data/providers.json');+ });++ afterEach(() => {+ rmSync(rootDir, { recursive: true, force: true });+ });++ it('rewrites grok-build model fields on grok-cli and grok-tui', async () => {+ writeJson(providersPath, {+ providers: {+ 'grok-cli': {+ id: 'grok-cli',+ models: ['grok-build'],+ defaultModel: 'grok-build',+ lightModel: 'grok-build',+ mediumModel: 'grok-build',+ heavyModel: 'grok-build',+ },+ 'grok-tui': {+ id: 'grok-tui',+ models: ['grok-build'],+ defaultModel: 'grok-build',+ lightModel: 'grok-build',+ mediumModel: 'grok-build',+ heavyModel: 'grok-build',+ },+ },+ });++ await migration.up({ rootDir });++ const out = readJson(providersPath);+ for (const id of ['grok-cli', 'grok-tui']) {+ const p = out.providers[id];+ expect(p.models).toEqual(['grok-configured-default']);+ expect(p.defaultModel).toBe('grok-configured-default');+ expect(p.lightModel).toBe('grok-configured-default');+ expect(p.mediumModel).toBe('grok-configured-default');+ expect(p.heavyModel).toBe('grok-configured-default');+ }+ });++ it('leaves a custom pinned model alone', async () => {+ writeJson(providersPath, {+ providers: {+ 'grok-cli': {+ id: 'grok-cli',+ models: ['grok-code-fast-1'],+ defaultModel: 'grok-code-fast-1',+ lightModel: 'grok-code-fast-1',+ },+ },+ });++ await migration.up({ rootDir });++ const cli = readJson(providersPath).providers['grok-cli'];+ expect(cli.models).toEqual(['grok-code-fast-1']);+ expect(cli.defaultModel).toBe('grok-code-fast-1');+ });++ it('only rewrites grok-build entries in a mixed models list', async () => {+ writeJson(providersPath, {+ providers: {+ 'grok-cli': {+ id: 'grok-cli',+ models: ['grok-build', 'grok-code-fast-1'],+ defaultModel: 'grok-build',+ },+ },+ });++ await migration.up({ rootDir });++ const cli = readJson(providersPath).providers['grok-cli'];+ expect(cli.models).toEqual(['grok-configured-default', 'grok-code-fast-1']);+ expect(cli.defaultModel).toBe('grok-configured-default');+ });++ it('does not touch the xAI Grok API provider', async () => {+ writeJson(providersPath, {+ providers: {+ grok: {+ id: 'grok',+ models: ['grok-4', 'grok-3'],+ defaultModel: 'grok-4',+ },+ 'grok-cli': {+ id: 'grok-cli',+ models: ['grok-build'],+ defaultModel: 'grok-build',+ },+ },+ });++ await migration.up({ rootDir });++ const out = readJson(providersPath);+ expect(out.providers.grok.defaultModel).toBe('grok-4');+ expect(out.providers.grok.models).toEqual(['grok-4', 'grok-3']);+ expect(out.providers['grok-cli'].defaultModel).toBe('grok-configured-default');+ });++ it('is idempotent', async () => {+ writeJson(providersPath, {+ providers: {+ 'grok-cli': { id: 'grok-cli', models: ['grok-build'], defaultModel: 'grok-build' },+ },+ });++ await migration.up({ rootDir });+ const afterFirst = readFileSync(providersPath, 'utf-8');+ await migration.up({ rootDir });+ expect(readFileSync(providersPath, 'utf-8')).toBe(afterFirst);+ });++ it('is a no-op when data/providers.json does not exist', async () => {+ await migration.up({ rootDir });+ expect(existsSync(providersPath)).toBe(false);+ });++ it('does not modify the file on invalid JSON', async () => {+ writeFileSync(providersPath, '{ not valid json');+ const before = readFileSync(providersPath, 'utf-8');+ await migration.up({ rootDir });+ expect(readFileSync(providersPath, 'utf-8')).toBe(before);+ });+});diff --git a/server/lib/README.md b/server/lib/README.mdindex 458cca56ae..d740cdd1d3 100644--- a/server/lib/README.md+++ b/server/lib/README.md@@ -94,11 +94,11 @@ The barrel `server/lib/index.js` is a machine-checkable enumeration of every pub| `promptTemplate.js` | Mustache-flavored, dot-notation-aware prompt template engine. || `promptPartials.js` | Mustache-style partial expansion. || `mediaModels.js` | Single source of truth for image/video model metadata. |-| `providerModels.js` | Provider model resolution sentinel + helpers. |+| `providerModels.js` | Provider model resolution sentinels + helpers (`CODEX_CONFIGURED_DEFAULT` / `ANTIGRAVITY_CONFIGURED_DEFAULT` / `GROK_CONFIGURED_DEFAULT`, `resolveCliModel`, `filterSelectableModels`, Bedrock/OpenCode model mappers, model-flag scan helpers). || `opencodeConfig.js` | OpenCode config builder — `buildOpencodeEnvVars(provider, model)` builds dynamic `OPENCODE_CONFIG_CONTENT` declaring the models map under `provider.ollama.models` (bare ids) for Ollama-backed OpenCode providers. Fixes --model rejection. || `cliProviderArgs.js` | Per-CLI argv conventions (`buildCliArgs`) for stdin prompt delivery — dependency-light extraction from runner.js so out-of-process callers (autofixer) can import it. || `cliProviderRun.js` | One-shot CLI provider invocation (`pickCliProvider` + `runCliProviderPrompt`) — lightweight path for the autofixer + calendar MCP sync to honor the configured provider/model. |-| `grok.js` | xAI Grok Build (`grok`) provider helpers — id/endpoint/default-model constants (`GROK_API_ID`/`GROK_CLI_ID`/`GROK_TUI_ID`/`GROK_API_ENDPOINT`/`GROK_DEFAULT_MODEL`), `isGrokCommand`/`isGrokCliProvider`/`isGrokTuiProvider` predicates, `ensureGrokHeadlessArgs`/`ensureGrokTuiArgs` argv builders (grok reads its prompt from `--prompt-file /dev/stdin`, not raw stdin), and `prepareGrokPromptFile` (Windows temp-file delivery fallback). |+| `grok.js` | xAI Grok Build (`grok`) provider helpers — id/endpoint constants (`GROK_API_ID`/`GROK_CLI_ID`/`GROK_TUI_ID`/`GROK_API_ENDPOINT`), `isGrokCommand`/`isGrokCliProvider`/`isGrokTuiProvider` predicates, `ensureGrokHeadlessArgs`/`ensureGrokTuiArgs` argv builders (grok reads its prompt from `--prompt-file /dev/stdin`, not raw stdin; model selection uses the `GROK_CONFIGURED_DEFAULT` sentinel in `providerModels.js` so PortOS omits `--model` like Antigravity), and `prepareGrokPromptFile` (Windows temp-file delivery fallback). || `runners.js` | Image-runner family constants. || `codexAssistantExtract.js` | Strip Codex CLI banner + echoed metadata from session transcript. || `codexCliOutput.js` | Network/system error patterns for `agentErrorAnalysis.js`. |diff --git a/server/lib/aiToolkit/defaults/providers.sample.json b/server/lib/aiToolkit/defaults/providers.sample.jsonindex 0ccc37804b..a3100879b9 100644--- a/server/lib/aiToolkit/defaults/providers.sample.json+++ b/server/lib/aiToolkit/defaults/providers.sample.json@@ -286,11 +286,11 @@"type": "cli","command": "grok","args": [],- "models": ["grok-build"],- "defaultModel": "grok-build",- "lightModel": "grok-build",- "mediumModel": "grok-build",- "heavyModel": "grok-build",+ "models": ["grok-configured-default"],+ "defaultModel": "grok-configured-default",+ "lightModel": "grok-configured-default",+ "mediumModel": "grok-configured-default",+ "heavyModel": "grok-configured-default","contextWindow": 256000,"timeout": 300000,"enabled": false,@@ -303,11 +303,11 @@"type": "tui","command": "grok","args": [],- "models": ["grok-build"],- "defaultModel": "grok-build",- "lightModel": "grok-build",- "mediumModel": "grok-build",- "heavyModel": "grok-build",+ "models": ["grok-configured-default"],+ "defaultModel": "grok-configured-default",+ "lightModel": "grok-configured-default",+ "mediumModel": "grok-configured-default",+ "heavyModel": "grok-configured-default","contextWindow": 256000,"timeout": 600000,"enabled": false,diff --git a/server/lib/cliProviderArgs.js b/server/lib/cliProviderArgs.jsindex a0bcd42ac6..dfc00de033 100644--- a/server/lib/cliProviderArgs.js+++ b/server/lib/cliProviderArgs.js@@ -39,9 +39,9 @@ export function buildCliArgs(provider) {// injection path fires — but if we kept the bogus token in baseArgs the// CLI would still see two `--model` occurrences and reject the argv.const baseArgs = stripBrokenModelFlags(Array.isArray(provider?.args) ? provider.args : []);- const effectiveDefaultModel = providerId === 'codex'- ? resolveCliModel(provider.defaultModel)- : provider.defaultModel;+ // Configured-default sentinels (Codex / Antigravity / Grok Build) resolve to+ // null so the CLI uses its own latest/default model without a --model flag.+ const effectiveDefaultModel = resolveCliModel(provider.defaultModel);// Codex CLI: `codex exec -` reads prompt from stdin, --model for model.// Detect an existing leading `exec` in user/legacy args so we don't end updiff --git a/server/lib/cliProviderArgs.test.js b/server/lib/cliProviderArgs.test.jsindex deb130e780..52638ab54e 100644--- a/server/lib/cliProviderArgs.test.js+++ b/server/lib/cliProviderArgs.test.js@@ -106,14 +106,15 @@ describe('cliProviderArgs', () => {});describe('buildCliArgs — Grok Build CLI', () => {- it('builds a headless one-shot invocation with plain output, bypassed permissions, model, and stdin prompt file', () => {- const args = buildCliArgs({ id: 'grok-cli', command: 'grok', defaultModel: 'grok-build' });+ it('builds a headless one-shot invocation without --model when using the configured-default sentinel', () => {+ const args = buildCliArgs({ id: 'grok-cli', command: 'grok', defaultModel: 'grok-configured-default' });expect(args).toEqual(['--output-format', 'plain','--permission-mode', 'bypassPermissions',- '--model', 'grok-build','--prompt-file', '/dev/stdin',]);+ expect(args).not.toContain('--model');+ expect(args).not.toContain('grok-configured-default');});it('omits the model flag when no defaultModel is set (grok uses its own default)', () => {@@ -125,29 +126,29 @@ describe('cliProviderArgs', () => {]);});- it('resolves grok by command even when the id is custom', () => {- const args = buildCliArgs({ id: 'my-grok', command: '/opt/homebrew/bin/grok', defaultModel: 'grok-build' });+ it('injects --model when a concrete model id is set', () => {+ const args = buildCliArgs({ id: 'my-grok', command: '/opt/homebrew/bin/grok', defaultModel: 'grok-code-fast-1' });expect(args).toContain('--prompt-file');expect(args).toContain('/dev/stdin');- expect(args).toEqual(expect.arrayContaining(['--model', 'grok-build']));+ expect(args).toEqual(expect.arrayContaining(['--model', 'grok-code-fast-1']));});it('respects a user-baked --output-format and does not inject plain', () => {- const args = buildCliArgs({ id: 'grok-cli', command: 'grok', args: ['--output-format', 'json'], defaultModel: 'grok-build' });+ const args = buildCliArgs({ id: 'grok-cli', command: 'grok', args: ['--output-format', 'json'], defaultModel: 'grok-configured-default' });expect(args.filter((a) => a === '--output-format')).toHaveLength(1);expect(args).toContain('json');expect(args).not.toContain('plain');});it('respects a user-baked --model and does not duplicate it', () => {- const args = buildCliArgs({ id: 'grok-cli', command: 'grok', args: ['--model', 'grok-code-fast-1'], defaultModel: 'grok-build' });+ const args = buildCliArgs({ id: 'grok-cli', command: 'grok', args: ['--model', 'grok-code-fast-1'], defaultModel: 'grok-configured-default' });expect(args.filter((a) => a === '--model')).toHaveLength(1);expect(args).toContain('grok-code-fast-1');- expect(args).not.toContain('grok-build');+ expect(args).not.toContain('grok-configured-default');});it('respects a user-baked prompt source and does not append --prompt-file', () => {- const args = buildCliArgs({ id: 'grok-cli', command: 'grok', args: ['-p', 'hello'], defaultModel: 'grok-build' });+ const args = buildCliArgs({ id: 'grok-cli', command: 'grok', args: ['-p', 'hello'], defaultModel: 'grok-configured-default' });expect(args).not.toContain('--prompt-file');expect(args).not.toContain('/dev/stdin');});diff --git a/server/lib/grok.js b/server/lib/grok.jsindex 08543cf11f..623acd6568 100644--- a/server/lib/grok.js+++ b/server/lib/grok.js@@ -38,10 +38,10 @@ export const GROK_API_ID = 'grok';export const GROK_CLI_ID = 'grok-cli';export const GROK_TUI_ID = 'grok-tui';export const GROK_API_ENDPOINT = 'https://api.x.ai/v1';-// Grok Build's built-in default coding model (256K context). A valid `--model`-// value, so we ship it as the CLI/TUI default rather than a "configured-default"-// sentinel — grok accepts the id directly.-export const GROK_DEFAULT_MODEL = 'grok-build';+// Model selection for Grok Build CLI/TUI mirrors Antigravity: PortOS does not+// pick a model. The stored sentinel lives in providerModels.js+// (`GROK_CONFIGURED_DEFAULT`); spawn paths omit `--model` so the local `grok`+// binary uses its own latest default.// grok reads a single-turn prompt from a file path. On POSIX we hand it// /dev/stdin so the existing stdin write feeds it unchanged at every spawn site.diff --git a/server/lib/grok.test.js b/server/lib/grok.test.jsindex c7d214051b..29cfa6eaa4 100644--- a/server/lib/grok.test.js+++ b/server/lib/grok.test.js@@ -6,7 +6,6 @@ import {GROK_CLI_ID,GROK_TUI_ID,GROK_API_ENDPOINT,- GROK_DEFAULT_MODEL,GROK_STDIN_PROMPT_PATH,isGrokCommand,isGrokCliProvider,@@ -17,12 +16,11 @@ import {} from './grok.js';describe('grok — constants', () => {- it('exposes the expected ids, endpoint, and default model', () => {+ it('exposes the expected ids, endpoint, and stdin prompt path', () => {expect(GROK_API_ID).toBe('grok');expect(GROK_CLI_ID).toBe('grok-cli');expect(GROK_TUI_ID).toBe('grok-tui');expect(GROK_API_ENDPOINT).toBe('https://api.x.ai/v1');- expect(GROK_DEFAULT_MODEL).toBe('grok-build');expect(GROK_STDIN_PROMPT_PATH).toBe('/dev/stdin');});});@@ -57,16 +55,16 @@ describe('grok — provider predicates', () => {});describe('grok — ensureGrokHeadlessArgs', () => {- it('injects plain output, permission bypass, model, and the stdin prompt file', () => {- expect(ensureGrokHeadlessArgs([], 'grok-build')).toEqual([+ it('injects plain output, permission bypass, model, and the stdin prompt file when a concrete model is given', () => {+ expect(ensureGrokHeadlessArgs([], 'grok-code-fast-1')).toEqual(['--output-format', 'plain','--permission-mode', 'bypassPermissions',- '--model', 'grok-build',+ '--model', 'grok-code-fast-1','--prompt-file', '/dev/stdin',]);});- it('omits --model when no model is given', () => {+ it('omits --model when no model is given (configured-default / latest)', () => {expect(ensureGrokHeadlessArgs([], null)).toEqual(['--output-format', 'plain','--permission-mode', 'bypassPermissions',@@ -77,19 +75,19 @@ describe('grok — ensureGrokHeadlessArgs', () => {it('does not override a user-pinned output format, permission mode, model, or prompt source', () => {const out = ensureGrokHeadlessArgs(['--output-format', 'json', '--permission-mode', 'default', '--model', 'grok-4', '--prompt-file', '/my/prompt.txt'],- 'grok-build',+ 'grok-code-fast-1',);expect(out.filter((a) => a === '--output-format')).toHaveLength(1);expect(out.filter((a) => a === '--permission-mode')).toHaveLength(1);expect(out.filter((a) => a === '--model')).toHaveLength(1);expect(out.filter((a) => a === '--prompt-file')).toHaveLength(1);expect(out).toContain('grok-4');- expect(out).not.toContain('grok-build');+ expect(out).not.toContain('grok-code-fast-1');expect(out).not.toContain('/dev/stdin');});it('treats --always-approve as an existing permission posture', () => {- const out = ensureGrokHeadlessArgs(['--always-approve'], 'grok-build');+ const out = ensureGrokHeadlessArgs(['--always-approve'], null);expect(out).not.toContain('--permission-mode');expect(out).toContain('--always-approve');});diff --git a/server/lib/providerModels.js b/server/lib/providerModels.jsindex 85ec908f2a..4d5f344072 100644--- a/server/lib/providerModels.js+++ b/server/lib/providerModels.js@@ -5,9 +5,22 @@export const CODEX_CONFIGURED_DEFAULT = 'codex-configured-default';export const ANTIGRAVITY_CONFIGURED_DEFAULT = 'antigravity-configured-default';+// Grok Build CLI/TUI: PortOS does not select a model — the local `grok` binary+// uses its own latest default. Stored as a sentinel so pickers hide the model+// dropdown (same UX as Codex / Antigravity).+export const GROK_CONFIGURED_DEFAULT = 'grok-configured-default';++const CONFIGURED_DEFAULT_SENTINELS = new Set([+ CODEX_CONFIGURED_DEFAULT,+ ANTIGRAVITY_CONFIGURED_DEFAULT,+ GROK_CONFIGURED_DEFAULT,+]);export const isCodexConfiguredDefault = (model) => model === CODEX_CONFIGURED_DEFAULT;+/** True for any provider "use CLI's own default" sentinel (Codex / Antigravity / Grok Build). */+export const isConfiguredDefaultModel = (model) => CONFIGURED_DEFAULT_SENTINELS.has(model);+/*** Normalize a provider `command` to its lowercase binary basename, stripping any* directory prefix and a Windows `.exe` suffix — e.g. `/opt/homebrew/bin/Grok.exe`@@ -25,12 +38,13 @@ export function commandBasename(command) {/*** Returns the model string to pass to a CLI's --model flag, or null if the- * caller should omit --model entirely (Codex sentinel case — the CLI will use- * whatever model is configured in ~/.codex/config.toml).+ * caller should omit --model entirely (configured-default sentinels — the CLI+ * uses its own default: Codex via ~/.codex/config.toml, Antigravity/Grok Build+ * via the binary's built-in latest model).* @param {string|null|undefined} model* @returns {string|null}*/-export const resolveCliModel = (model) => isCodexConfiguredDefault(model) ? null : (model || null);+export const resolveCliModel = (model) => isConfiguredDefaultModel(model) ? null : (model || null);/*** True when a provider command points at the OpenCode binary — matching the bare@@ -181,12 +195,12 @@ export function resolveBedrockCliModel(id, { env = process.env, providerId } = {}/**- * Strip the sentinel from a model list — the user-selectable view.+ * Strip configured-default sentinels from a model list — the user-selectable view.* @param {string[]} models* @returns {string[]}*/export const filterSelectableModels = (models) =>- (models || []).filter(m => m !== CODEX_CONFIGURED_DEFAULT && m !== ANTIGRAVITY_CONFIGURED_DEFAULT);+ (models || []).filter(m => !isConfiguredDefaultModel(m));/*** Detects whether the provider's stored argv already pins a model with adiff --git a/server/lib/providerModels.test.js b/server/lib/providerModels.test.jsindex b27e23f72e..d3d54d5790 100644--- a/server/lib/providerModels.test.js+++ b/server/lib/providerModels.test.js@@ -2,7 +2,9 @@ import { describe, it, expect, vi } from 'vitest';import {ANTIGRAVITY_CONFIGURED_DEFAULT,CODEX_CONFIGURED_DEFAULT,+ GROK_CONFIGURED_DEFAULT,isCodexConfiguredDefault,+ isConfiguredDefaultModel,resolveCliModel,filterSelectableModels,hasModelFlag,@@ -111,8 +113,10 @@ describe('providerModels', () => {});describe('resolveCliModel', () => {- it('returns null for the codex sentinel so --model is omitted', () => {+ it('returns null for configured-default sentinels so --model is omitted', () => {expect(resolveCliModel(CODEX_CONFIGURED_DEFAULT)).toBeNull();+ expect(resolveCliModel(ANTIGRAVITY_CONFIGURED_DEFAULT)).toBeNull();+ expect(resolveCliModel(GROK_CONFIGURED_DEFAULT)).toBeNull();});it('returns null for empty / nullish values', () => {@@ -127,9 +131,24 @@ describe('providerModels', () => {});});+ describe('isConfiguredDefaultModel', () => {+ it('matches every configured-default sentinel', () => {+ expect(isConfiguredDefaultModel(CODEX_CONFIGURED_DEFAULT)).toBe(true);+ expect(isConfiguredDefaultModel(ANTIGRAVITY_CONFIGURED_DEFAULT)).toBe(true);+ expect(isConfiguredDefaultModel(GROK_CONFIGURED_DEFAULT)).toBe(true);+ expect(isConfiguredDefaultModel('gpt-5')).toBe(false);+ });+ });+describe('filterSelectableModels', () => {it('strips configured-default sentinels from the list', () => {- expect(filterSelectableModels(['a', CODEX_CONFIGURED_DEFAULT, ANTIGRAVITY_CONFIGURED_DEFAULT, 'b'])).toEqual(['a', 'b']);+ expect(filterSelectableModels([+ 'a',+ CODEX_CONFIGURED_DEFAULT,+ ANTIGRAVITY_CONFIGURED_DEFAULT,+ GROK_CONFIGURED_DEFAULT,+ 'b',+ ])).toEqual(['a', 'b']);});it('returns an empty list for nullish input', () => {diff --git a/server/lib/tuiHandshake.test.js b/server/lib/tuiHandshake.test.jsindex 7f84220bb2..fd5df5f938 100644--- a/server/lib/tuiHandshake.test.js+++ b/server/lib/tuiHandshake.test.js@@ -508,11 +508,18 @@ describe('tuiHandshake.buildTuiInvocation', () => {expect(buildTuiInvocation(provider, '').args).toEqual(['-p', '-']);});- it('injects Grok TUI permission bypass and appends --model', () => {+ it('injects Grok TUI permission bypass and omits --model for the configured-default sentinel', () => {const provider = { id: 'grok-tui', command: 'grok', args: [] };- const out = buildTuiInvocation(provider, 'grok-build');+ const out = buildTuiInvocation(provider, 'grok-configured-default');expect(out.command).toBe('grok');- expect(out.args).toEqual(['--permission-mode', 'bypassPermissions', '--model', 'grok-build']);+ expect(out.args).toEqual(['--permission-mode', 'bypassPermissions']);+ expect(out.args).not.toContain('--model');+ });++ it('appends --model for Grok TUI when a concrete model is requested', () => {+ const provider = { id: 'grok-tui', command: 'grok', args: [] };+ const out = buildTuiInvocation(provider, 'grok-code-fast-1');+ expect(out.args).toEqual(['--permission-mode', 'bypassPermissions', '--model', 'grok-code-fast-1']);});it('namespaces the Ollama model under ollama/ for an OpenCode TUI', () => {diff --git a/server/services/agentCliSpawning.js b/server/services/agentCliSpawning.jsindex d4d573fbd3..7fa6f78e01 100644--- a/server/services/agentCliSpawning.js+++ b/server/services/agentCliSpawning.js@@ -27,7 +27,7 @@ import { PROVIDER_TYPES } from '../lib/aiToolkit/constants.js';import { createImmediateFallbackSignalDetector } from '../lib/aiToolkit/errorDetection.js';import { ensureAntigravityPrintArgs, isAntigravityCliProvider } from '../lib/antigravity.js';import { isGrokCommand, ensureGrokHeadlessArgs, prepareGrokPromptFile } from '../lib/grok.js';-import { resolveBedrockCliModel, prefixOpencodeModel, hasModelFlag, isOpencodeCommand, applyLeanClaudeArgs } from '../lib/providerModels.js';+import { resolveCliModel, resolveBedrockCliModel, prefixOpencodeModel, hasModelFlag, isOpencodeCommand, applyLeanClaudeArgs } from '../lib/providerModels.js';import { agentGuardEnv } from '../lib/agentGuard/index.js';import { buildOpencodeEnvVars } from '../lib/opencodeConfig.js';import { prepareCliSpawn, killProcessTree } from '../lib/bufferedSpawn.js';@@ -246,7 +246,9 @@ export function createStreamJsonParser() {*/export function buildCliSpawnConfig(provider, model, settingsEnv = {}, { systemPromptFile = null } = {}) {const providerId = provider?.id || 'claude-code';- const effectiveModel = providerId === 'codex' && model === 'codex-configured-default' ? null : model;+ // Configured-default sentinels (Codex / Antigravity / Grok Build) → null so+ // the CLI uses its own default without a --model flag.+ const effectiveModel = resolveCliModel(model);// Codex CLI uses different invocation pattern.// `--dangerously-bypass-approvals-and-sandbox` is the Codex equivalent ofdiff --git a/server/services/agentCliSpawning.test.js b/server/services/agentCliSpawning.test.jsindex a97574404e..cd4d7050dc 100644--- a/server/services/agentCliSpawning.test.js+++ b/server/services/agentCliSpawning.test.js@@ -224,16 +224,16 @@ describe('buildCliSpawnConfig', () => {expect(config.args).toEqual(['run', '-m', 'ollama/custom']);});- it('runs `grok` headless with plain output, permission bypass, model, and stdin prompt file', () => {- const config = buildCliSpawnConfig({ id: 'grok-cli', command: 'grok', args: [] }, 'grok-build');+ it('runs `grok` headless with plain output, permission bypass, and stdin prompt file (no --model for configured-default)', () => {+ const config = buildCliSpawnConfig({ id: 'grok-cli', command: 'grok', args: [] }, 'grok-configured-default');expect(config.command).toBe('grok');expect(config.stdinMode).toBe('prompt');expect(config.args).toEqual(['--output-format', 'plain','--permission-mode', 'bypassPermissions',- '--model', 'grok-build','--prompt-file', '/dev/stdin',]);+ expect(config.args).not.toContain('--model');// Grok is non-Claude, so no claude-only flags leak in.expect(config.args).not.toContain('--dangerously-skip-permissions');expect(config.args).not.toContain('--print');diff --git a/server/services/askService.test.js b/server/services/askService.test.jsindex 89e3772500..55b059130f 100644--- a/server/services/askService.test.js+++ b/server/services/askService.test.js@@ -352,14 +352,14 @@ describe('runAsk', () => {expect(args[modelIdx + 1]).toBe('o4-mini');});- it('runs `grok` headless with plain output, permission bypass, model, and stdin prompt file', async () => {+ it('runs `grok` headless with plain output, permission bypass, and stdin prompt file (no --model for configured-default)', async () => {providers.getActiveProvider.mockResolvedValue({id: 'grok-cli',type: 'cli',enabled: true,command: 'grok',args: [],- defaultModel: 'grok-build',+ defaultModel: 'grok-configured-default',timeout: 5000,});@@ -383,9 +383,9 @@ describe('runAsk', () => {expect(args).toEqual(['--output-format', 'plain','--permission-mode', 'bypassPermissions',- '--model', 'grok-build','--prompt-file', '/dev/stdin',]);+ expect(args).not.toContain('--model');// POSIX delivery: the prompt is piped in via stdin.expect(child.stdin.end).toHaveBeenCalled();});