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
address review (claude): trust/approval split, refresh mirror, dead imports
Adam Eivyadc9ce6176bb
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex 6dbce45723..960402831e 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -14,6 +14,8 @@- **Updated documentation index and feature references.** Added missing feature deep dive links for Quota-burn automation (`QUOTA-BURN.md`), Three.js procedural 3D models (`THREEJS_MODELS.md`), Stacker News stewardship (`stacker-news.md`), and the PortDeck native companion app API contract (`COMPANION_APP_API.md`) across `README.md` and `docs/README.md`. Improved inline JSDoc comments for client and server utility modules.## Fixed+- **A `--model` you baked into a TUI provider's own arguments is now honored instead of silently overridden.** The CoS-agent TUI spawn path respected a hand-pinned `--model` for OpenCode providers only; for every other TUI it appended the UI's model choice as a *second* `--model` flag, and last-flag-wins meant your pin was quietly discarded (or the CLI rejected the duplicate outright). It now honors the pin for every provider, matching what the one-shot TUI path and the CLI path already did, and what the rest of the app documents. This only affects providers whose saved arguments hand-pin a model — no shipped provider does.+- **The AI Providers page no longer offers "Refresh Models" on providers the server can't refresh.** The button's visibility was decided by a deny-list of command names that had drifted from the server's actual dispatch, so Codex and Kimi Code — both shipped providers — showed the button and produced an error toast on every click. It also compared the exact command string, so pointing a provider at an absolute binary path (`/opt/homebrew/bin/gemini`) hid the button on a provider that refreshes fine. The check now mirrors the server's own name-or-command test and tolerates a path-configured binary.- **On a Bedrock box, a TUI provider that isn't Claude Code no longer has its model id rewritten.** Claude Code on AWS Bedrock needs region-prefixed model ids (`global.anthropic.claude-opus-5`), so PortOS rewrites bare Claude ids just-in-time when `CLAUDE_CODE_USE_BEDROCK` is set. That rewrite keyed only on the *model id* containing "claude" and was applied by default to every TUI provider — so any vendor that labels Anthropic models under its own ids got captured by it. Cursor is exactly that case: `claude-opus-5-thinking-high` would have been sent to Cursor's router as `global.anthropic.claude-opus-5-thinking-high`, an id it has never heard of. The rewrite now keys on the launch command actually being Claude Code, which is what it always meant. Two independent copies of that model-injection step (the one-shot TUI prompt path and the CoS-agent TUI spawn path) had already drifted apart on this; both now share one implementation, so the next provider can't be fixed in one and missed in the other. No shipped provider's behavior changes; a *custom* TUI provider running a non-`claude` binary against a claude-ish model id will stop being rewritten, which is the correct result for a non-Claude-Code binary.- **The Antigravity card on the Usage page loads quota again after `agy` 1.1.x renamed its limit rows.** The `/usage` panel still groups Gemini / Claude+GPT windows the same way, but each window header grew a trailing "Remaining" (`Weekly Limit Remaining`, `Five Hour Limit Remaining`). The parser required the line to end on bare `Limit`, so it found the groups and returned zero meters — the card looked broken with "No quota data found." Both the new labels and the older bare-`Limit` form parse to the same keys.- **Grok and Kimi agents now actually start, and an agent that fails to spawn says why.** Picking the Grok or Kimi provider for a CoS agent produced a task that never opened a shell: the durable agent runner keeps an allowlist of CLI commands it is permitted to spawn, and `grok` and `kimi` were never added to it even though both ship as selectable providers. Both are allowlisted now, and a test keeps that list in step with the shipped provider catalog so the next provider added without an entry fails in CI rather than in a silent agent. The reporting around it was the worse half of the bug: a rejected spawn was logged and dropped, never reaching the agent record. A TUI agent sat in "initializing" for a minute until the zombie sweeper finalized it as "Agent process terminated unexpectedly" — a message that named no cause — and the CLI equivalent was worse still, staying "working" indefinitely because the stale in-memory entry made every cleanup sweep skip it. Both paths now finalize immediately with the runner's actual error, the runner names the offending command instead of returning one opaque "missing or invalid fields", and an agent reaped without ever having recorded a process id is reported as never having started rather than as a crash.diff --git a/client/src/pages/AIProviders.jsx b/client/src/pages/AIProviders.jsxindex 743ad3bf71..f3245bddb8 100644--- a/client/src/pages/AIProviders.jsx+++ b/client/src/pages/AIProviders.jsx@@ -2,7 +2,7 @@ import { useState, useEffect, useCallback } from 'react';import toast from '../components/ui/Toast';import * as api from '../services/api';import socket from '../services/socket';-import { filterSelectableModels, filterGenerationModels, isEmbeddingModel, mergeModelLists, configuredDefaultIn, localBackendForProvider, modelOptionLabel, providerTypeClass, isTuiProvider, isApiProvider, isProcessProvider, isOllamaBackedProvider, isAntigravityProvider, supportsModelRefresh, isGrokBuildCli, isLocalEndpoint, effectiveModelContextWindow } from '../utils/providers';+import { filterSelectableModels, filterGenerationModels, isEmbeddingModel, mergeModelLists, configuredDefaultIn, localBackendForProvider, modelOptionLabel, providerTypeClass, isTuiProvider, isApiProvider, isProcessProvider, supportsModelRefresh, isGrokBuildCli, isLocalEndpoint, effectiveModelContextWindow } from '../utils/providers';import useLocalModels from '../hooks/useLocalModels';import BrailleSpinner from '../components/BrailleSpinner';import EmptyState from '../components/EmptyState';diff --git a/client/src/utils/providers.js b/client/src/utils/providers.jsindex ebf493f7b3..e3e9a3f400 100644--- a/client/src/utils/providers.js+++ b/client/src/utils/providers.js@@ -150,18 +150,24 @@ export const supportsModelRefresh = (provider) => {// server has a type==='tui' branch for it) — checked before the generic// TUI gate, same as Claude Ollama above.if (isAntigravityProvider(provider)) return true;+ // Every other TUI's model is fixed by the CLI/config — no branch server-side.if (isTuiProvider(provider)) return false;- // 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 === 'gemini' || provider.command === 'grok')) return false;- // Cursor is hidden for the OPPOSITE reason, so it gets its own clause rather- // than joining the two above: `cursor-agent models` does print an- // authoritative per-account catalog, there just isn't a server-side fetcher- // for it yet, so the button could only ever produce an error toast. This- // clause is temporary where theirs are permanent.- if (provider?.type === 'cli' && isCursorCommand(provider.command)) return false;- // All other providers support refresh (API and CLI)- return true;+ // API providers all route to _refreshAPIProviderModels.+ if (isApiProvider(provider)) return true;+ // CLI: the server's `_refreshCLIProviderModels` has exactly two remaining+ // fetchers past the ollama/antigravity branches above — Anthropic and Gemini —+ // and THROWS for everything else. So this is an allowlist, not a deny-list.+ //+ // It used to be written as a deny-list (`command === 'gemini' || 'grok'`,+ // plus cursor), which reported true for `codex` and `kimi-cli` — two providers+ // that ship in the seed and whose Refresh button therefore 404'd on every+ // click. It also matched on the exact command string, so a path-configured+ // `/opt/homebrew/bin/gemini` fell through to true and 404'd too. Matching the+ // server's own name-or-command test (basename-tolerant) fixes both.+ const name = String(provider?.name || '').toLowerCase();+ const command = commandBasename(provider?.command);+ return name.includes('claude') || command === 'claude'+ || name.includes('gemini') || command === 'gemini';};export const knownProviderContextWindow = (provider) => {diff --git a/client/src/utils/providers.test.js b/client/src/utils/providers.test.jsindex 544e3e7857..db64b94132 100644--- a/client/src/utils/providers.test.js+++ b/client/src/utils/providers.test.js@@ -736,28 +736,42 @@ describe('isKimiProvider (mirror of server providerModels)', () => {describe('supportsModelRefresh', () => {// Guards the AI Providers page's "Refresh Models" button. Lived as a// module-local in AIProviders.jsx with zero coverage until it moved here.+ // The contract is a MIRROR of the server's `_refreshCLIProviderModels`+ // dispatch: anything the server throws for must be false here, or the button+ // 404s on every click.it('hides the button for cursor — no server-side fetcher exists yet', () => {- expect(supportsModelRefresh({ id: 'cursor-cli', type: 'cli', command: 'cursor-agent' })).toBe(false);- // Path-configured cursor must be hidden too, or the button 404s.- expect(supportsModelRefresh({ id: 'custom', type: 'cli', command: '/Users/x/.local/bin/cursor-agent' })).toBe(false);+ expect(supportsModelRefresh({ id: 'cursor-cli', type: 'cli', command: 'cursor-agent', name: 'Cursor Agent CLI' })).toBe(false);+ expect(supportsModelRefresh({ id: 'custom', type: 'cli', command: '/Users/x/.local/bin/cursor-agent', name: 'Cursor' })).toBe(false);});it('hides the button for the TUI variant via the generic TUI gate', () => {- expect(supportsModelRefresh({ id: 'cursor-tui', type: 'tui', command: 'cursor-agent' })).toBe(false);+ expect(supportsModelRefresh({ id: 'cursor-tui', type: 'tui', command: 'cursor-agent', name: 'Cursor Agent TUI' })).toBe(false);});- it('keeps hiding it for gemini/grok, whose model config is CLI-local', () => {- expect(supportsModelRefresh({ id: 'grok-cli', type: 'cli', command: 'grok' })).toBe(false);- expect(supportsModelRefresh({ id: 'gemini-cli', type: 'cli', command: 'gemini' })).toBe(false);+ // Regression: these two SHIP in data.reference/providers.json and the old+ // deny-list reported true for both, so the button 404'd on every click.+ it('hides the button for shipped CLIs the server has no fetcher for', () => {+ expect(supportsModelRefresh({ id: 'codex', type: 'cli', command: 'codex', name: 'Codex CLI' })).toBe(false);+ expect(supportsModelRefresh({ id: 'kimi-cli', type: 'cli', command: 'kimi', name: 'Kimi Code CLI' })).toBe(false);+ expect(supportsModelRefresh({ id: 'grok-cli', type: 'cli', command: 'grok', name: 'Grok Build CLI' })).toBe(false);+ });++ // Regression: the old clause compared the exact command string, so a+ // path-configured binary fell through to true and 404'd.+ it('is basename-tolerant, matching the server test', () => {+ expect(supportsModelRefresh({ id: 'g', type: 'cli', command: '/opt/homebrew/bin/gemini', name: 'g' })).toBe(true);+ expect(supportsModelRefresh({ id: 'c', type: 'cli', command: '/opt/homebrew/bin/claude', name: 'c' })).toBe(true);+ expect(supportsModelRefresh({ id: 'k', type: 'cli', command: '/opt/homebrew/bin/kimi', name: 'k' })).toBe(false);});it('still offers it for the providers the server CAN fetch for', () => {// Ollama-backed and antigravity are checked BEFORE the TUI gate, so their// TUI variants must still refresh — the ordering is the load-bearing part.- expect(supportsModelRefresh({ id: 'claude-ollama-tui', type: 'tui', ollamaBacked: true })).toBe(true);- expect(supportsModelRefresh({ id: 'antigravity-tui', type: 'tui', command: 'agy' })).toBe(true);- expect(supportsModelRefresh({ id: 'claude-code', type: 'cli', command: 'claude' })).toBe(true);- expect(supportsModelRefresh({ id: 'lmstudio', type: 'api', endpoint: 'http://localhost:1234/v1' })).toBe(true);+ expect(supportsModelRefresh({ id: 'claude-ollama-tui', type: 'tui', ollamaBacked: true, name: 'Claude Ollama TUI' })).toBe(true);+ expect(supportsModelRefresh({ id: 'antigravity-tui', type: 'tui', command: 'agy', name: 'Antigravity TUI' })).toBe(true);+ expect(supportsModelRefresh({ id: 'claude-code', type: 'cli', command: 'claude', name: 'Claude Code CLI' })).toBe(true);+ expect(supportsModelRefresh({ id: 'lmstudio', type: 'api', endpoint: 'http://localhost:1234/v1', name: 'LM Studio' })).toBe(true);+ expect(supportsModelRefresh({ id: 'cerebras', type: 'api', name: 'Cerebras' })).toBe(true);});it('does not throw on a nullish provider', () => {diff --git a/server/lib/cliProviderArgs.test.js b/server/lib/cliProviderArgs.test.jsindex 737cb6a691..aabf432a08 100644--- a/server/lib/cliProviderArgs.test.js+++ b/server/lib/cliProviderArgs.test.js@@ -216,9 +216,11 @@ describe('cliProviderArgs', () => {expect(args).not.toContain('auto');});- it('respects a user-pinned trust/approval posture instead of adding --force', () => {+ it('preserves a pinned --auto-review but still clears the trust gate', () => {+ // --auto-review grants approval but NOT trust; without a trust flag cursor+ // exits on "Workspace Trust Required" before doing any work.const args = buildCliArgs({ id: 'cursor-cli', command: 'cursor-agent', args: ['--print', '--auto-review'], defaultModel: null });- expect(args).toEqual(['--print', '--auto-review']);+ expect(args).toEqual(['--print', '--auto-review', '--trust']);});it('delivers the prompt over stdin (useStdin true) — cursor reads raw stdin in print mode', () => {diff --git a/server/lib/cursor.js b/server/lib/cursor.jsindex 4a3f7c6c16..d67522a868 100644--- a/server/lib/cursor.js+++ b/server/lib/cursor.js@@ -64,25 +64,48 @@ export function isCursorCommand(command) {// `--print` (`-p`) puts cursor-agent in non-interactive print mode.const PRINT_FLAGS = ['--print', '-p'];-// APPROVAL postures — flags that decide what happens when a tool call needs-// permission. `--force`/`-f`/`--yolo` run everything unprompted; `--auto-review`-// is the server-classifier middle ground. Any one present means the user pinned-// their own posture, so don't add another.-//-// `--trust` is deliberately NOT in this list. It clears the workspace-trust gate-// and nothing else, so treating it as an approval posture would suppress-// `--force` and leave an unattended run to stall on the first tool prompt with-// nobody to answer it — burning the full provider timeout to produce nothing.-// A user who pins `--trust` still gets `--force` added, which is a superset of it.+// cursor-agent gates an unattended run on TWO orthogonal postures, and a headless+// run needs BOTH satisfied or it produces nothing:+// - TRUST — without it, cursor prints "Workspace Trust Required" and EXITS+// immediately, before any work.+// - APPROVAL — without it, the run reaches the first tool call and then stalls+// on a permission prompt with nobody to answer, burning the whole+// provider timeout.+// They overlap but are not the same set, so collapsing them into one list breaks+// in both directions: `--trust` clears trust but grants no approval, while+// `--auto-review` is an approval posture that does NOT clear trust. Treating+// either as "the user pinned a posture, we're done" suppresses the flag that+// covers the OTHER gate. Keep them separate and check each independently.+const TRUST_FLAGS = ['--force', '-f', '--yolo', '--trust'];const APPROVAL_FLAGS = ['--force', '-f', '--yolo', '--auto-review'];+/**+ * Add whatever posture flag the argv is still missing, honoring anything the+ * user already pinned. `--force` satisfies both gates at once, so it is the+ * default; when the user pinned an approval posture we only owe them trust+ * (`--trust`), and vice-versa. No-op when both gates are already covered.+ * @param {string[]} out - argv, mutated in place+ * @returns {string[]} the same array, for chaining+ */+function ensureCursorPosture(out) {+ const hasTrust = argvHasFlag(out, TRUST_FLAGS);+ const hasApproval = argvHasFlag(out, APPROVAL_FLAGS);+ if (hasTrust && hasApproval) return out;+ // `--force` covers trust AND approval; only fall back to the narrow `--trust`+ // when the user has already chosen an approval posture we must not override.+ out.push(hasApproval ? '--trust' : '--force');+ return out;+}+/*** Build the headless (one-shot) argv for the Cursor Agent CLI. Ensures, when not* already pinned by the user's saved `args`:* - `--print` — non-interactive print mode (prompt read from stdin).- * - `--force` — clears the workspace-trust gate AND auto-approves tool- * calls, so an unattended run neither exits on the trust- * block nor stalls on an approval prompt.+ * - a posture flag — `--force` by default, which clears the workspace-trust+ * gate AND auto-approves tool calls, so an unattended run+ * neither exits on the trust block nor stalls on a prompt.+ * See `ensureCursorPosture` for how a user-pinned posture+ * narrows this to just the gate they left uncovered.* - `--model <id>` — gated on `model` being set AND no user-baked model flag.* The prompt itself is NOT added here — it rides on stdin at spawn time.* @param {string[]} baseArgs - user/legacy args (already model-flag-sanitized)@@ -94,9 +117,7 @@ export function ensureCursorHeadlessArgs(baseArgs = [], model) {if (!argvHasFlag(out, PRINT_FLAGS)) {out.push('--print');}- if (!argvHasFlag(out, APPROVAL_FLAGS)) {- out.push('--force');- }+ ensureCursorPosture(out);if (model && !hasModelFlag(out)) {out.push('--model', model);}@@ -114,9 +135,5 @@ export function ensureCursorHeadlessArgs(baseArgs = [], model) {* @returns {string[]}*/export function ensureCursorTuiArgs(args = []) {- const out = [...args];- if (!argvHasFlag(out, APPROVAL_FLAGS)) {- out.push('--force');- }- return out;+ return ensureCursorPosture([...args]);}diff --git a/server/lib/cursor.test.js b/server/lib/cursor.test.jsindex 519372e6e2..c0d41a311c 100644--- a/server/lib/cursor.test.js+++ b/server/lib/cursor.test.js@@ -42,19 +42,27 @@ describe('ensureCursorHeadlessArgs', () => {expect(ensureCursorHeadlessArgs(['-p'], null)).toEqual(['-p', '--force']);});- it('respects any user-pinned APPROVAL posture instead of adding --force', () => {- for (const flag of ['--force', '-f', '--yolo', '--auto-review']) {+ // Only a flag covering BOTH gates (trust + approval) means we owe nothing.+ it('adds nothing when the pinned flag already covers both gates', () => {+ for (const flag of ['--force', '-f', '--yolo']) {expect(ensureCursorHeadlessArgs(['--print', flag], null)).toEqual(['--print', flag]);}});- // `--trust` only clears the workspace-trust gate — it is NOT an approval- // posture. Treating it as one would suppress `--force` and leave an unattended- // run stalled on the first tool prompt until the provider timeout expires.- it('still adds --force when the user pinned only --trust', () => {+ // `--trust` clears trust but grants NO approval — the run would reach the first+ // tool call and stall there until the provider timeout expires.+ it('adds --force for approval when the user pinned only --trust', () => {expect(ensureCursorHeadlessArgs(['--print', '--trust'], null)).toEqual(['--print', '--trust', '--force']);});+ // `--auto-review` is an approval posture that does NOT clear trust — without a+ // trust flag cursor prints "Workspace Trust Required" and exits doing no work.+ // The pinned posture must be preserved, so we add the narrow `--trust`, not `--force`.+ it('adds --trust (not --force) when the user pinned only --auto-review', () => {+ expect(ensureCursorHeadlessArgs(['--print', '--auto-review'], null))+ .toEqual(['--print', '--auto-review', '--trust']);+ });+it('respects a joined posture flag (--force=true style)', () => {expect(ensureCursorHeadlessArgs(['--print', '--force=true'], null)).toEqual(['--print', '--force=true']);});@@ -83,16 +91,20 @@ describe('ensureCursorTuiArgs', () => {expect(ensureCursorTuiArgs([])).toEqual(['--force']);});- it('leaves a user-pinned approval posture alone', () => {- for (const flag of ['--force', '-f', '--yolo', '--auto-review']) {+ it('adds nothing when the pinned flag already covers both gates', () => {+ for (const flag of ['--force', '-f', '--yolo']) {expect(ensureCursorTuiArgs([flag])).toEqual([flag]);}});- it('still adds --force when the user pinned only --trust (trust is not approval)', () => {+ it('adds --force for approval when the user pinned only --trust', () => {expect(ensureCursorTuiArgs(['--trust'])).toEqual(['--trust', '--force']);});+ it('adds --trust for the trust gate when the user pinned only --auto-review', () => {+ expect(ensureCursorTuiArgs(['--auto-review'])).toEqual(['--auto-review', '--trust']);+ });+it('does not mutate the caller-supplied args array and is idempotent', () => {const base = [];const once = ensureCursorTuiArgs(base);diff --git a/server/services/agentTuiSpawning.js b/server/services/agentTuiSpawning.jsindex d3fd1ca3f0..862cb6bf63 100644--- a/server/services/agentTuiSpawning.js+++ b/server/services/agentTuiSpawning.js@@ -27,7 +27,7 @@ import * as git from './git.js';import { resolveReviewLoopOptions } from './codeReview.js';import { spawnTuiSessionViaRunner } from './cosRunnerClient.js';import { shellQuote } from '../lib/shellQuote.js';-import { resolveCliModel, buildEffortArgs, resolveInjectedTuiModel, hasModelFlag, isOpencodeCommand, isClaudeCommand, applyLeanClaudeArgs, providerSuppliesGithubToken } from '../lib/providerModels.js';+import { resolveCliModel, buildEffortArgs, resolveInjectedTuiModel, hasModelFlag, isClaudeCommand, applyLeanClaudeArgs, providerSuppliesGithubToken } from '../lib/providerModels.js';import { createStreamingAnsiStripper, stripAnsi } from '../lib/ansiStrip.js';import { createImmediateFallbackSignalDetector } from '../lib/aiToolkit/errorDetection.js';import { isMachineOnline } from '../lib/connectivity.js';diff --git a/server/services/agentTuiSpawning.test.js b/server/services/agentTuiSpawning.test.jsindex c8d37b4b79..a56aa6ad53 100644--- a/server/services/agentTuiSpawning.test.js+++ b/server/services/agentTuiSpawning.test.js@@ -152,9 +152,6 @@ vi.mock('../lib/providerModels.js', async (importOriginal) => ({// one input the real mapper keys on (`CLAUDE_CODE_USE_BEDROCK`, cleared in// beforeEach below), so these assertions are deterministic regardless of the// ambient env on a developer's Bedrock box or a CI runner.- // Mirror the real opencode-command basename match (fully unit-tested in- // providerModels.test.js).- isOpencodeCommand: vi.fn((c) => typeof c === 'string' && c.split(/[\\/]/).pop().toLowerCase().replace(/\.exe$/, '') === 'opencode'),// Mirror hasModelFlag (real impl unit-tested in providerModels.test.js).hasModelFlag: vi.fn((a) => Array.isArray(a) && a.some((x) => x === '--model' || x === '-m' || (typeof x === 'string' && (x.startsWith('--model=') || x.startsWith('-m=')))))}));