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

feat: allow codex CLI as a music-video code authoring provider under a read-only sandbox

Adam Eivy3da537f3f50f
diff --git a/client/src/utils/providerSelection.js b/client/src/utils/providerSelection.js
index 9232e2999c..a54d793434 100644
--- a/client/src/utils/providerSelection.js
+++ b/client/src/utils/providerSelection.js
@@ -88,7 +88,7 @@ export const toolFreeLocalSelectionPolicy = (
* Never infer CLI support from a command name, and never admit a TUI session.
*/
export const supportsToolFreeOneShot = (provider) => provider?.enabled !== false
- && (provider?.type === 'api' || provider?.type === 'cli' && provider.toolFreeOneShot === true);
+ && (provider?.type === 'api' || provider?.type === 'cli' && (provider.toolFreeOneShot === true || provider.authoringOneShot === true));
// No compose modes: an unmaterialized CLI combination has no server capability
// annotation yet. Existing pins still render through the selector's saved-value
diff --git a/server/lib/providerVendors.js b/server/lib/providerVendors.js
index f793c8460e..dde73b19b7 100644
--- a/server/lib/providerVendors.js
+++ b/server/lib/providerVendors.js
@@ -267,6 +267,20 @@ function piToolFreeArgs(args) {
// ─── codex ──────────────────────────────────────────────────────────────────
+// Codex has no tool-disable switch, so a one-shot is never `toolFree`. It can
+// still be confined: OS-level read-only sandbox (no writes, no mutating
+// commands), no session persisted, no user config re-routing the run. Callers
+// that only need that bound (music-video code authoring over the user's own
+// brief) accept it through `isReadOnlySandboxOneShotProvider`; the Ask/app-detect
+// host-control guard keeps treating codex as non-tool-free.
+const CODEX_READ_ONLY_ONE_SHOT_ARGS = ['--sandbox', 'read-only', '--skip-git-repo-check', '--ephemeral', '--ignore-user-config'];
+function codexReadOnlyOneShotArgs(args) {
+ const cleared = dropOptions(args, ['--sandbox', '-s']).filter((arg) => !CODEX_READ_ONLY_ONE_SHOT_ARGS.includes(arg));
+ // Options precede the stdin-prompt marker, which stays last.
+ const tail = cleared.at(-1) === '-' ? ['-'] : [];
+ return [...cleared.slice(0, cleared.length - tail.length), ...CODEX_READ_ONLY_ONE_SHOT_ARGS, ...tail];
+}
+
// The opt-in that pins a Codex run to the account PortOS believes it is using.
// A third-party bridge re-points Codex by writing top-level routing keys into
// `~/.codex/config.toml`, and codex honors that file on every invocation — so
@@ -434,6 +448,7 @@ const CODEX = {
tuiArgs: ensureCodexTuiArgs,
cliArgs: codexCliArgs,
spawnArgs: codexSpawnArgs,
+ toolFreeOneShot: { matchCommand: isCodexCommand, sandboxArgs: codexReadOnlyOneShotArgs },
publicReview: {
// The CLI id and the TUI id share one binary, so both reach the same
// enforced recipe when a stage selects them.
@@ -1115,6 +1130,7 @@ export function toolFreeOneShotArgs(provider, args = []) {
const spec = PROVIDER_VENDORS.find((v) => v.toolFreeOneShot?.matchCommand(provider?.command))?.toolFreeOneShot;
const { args: stripped, removed } = stripApprovalBypassArgs(args, spec?.bypassAliases);
if (spec?.toolFreeArgs) return { args: spec.toolFreeArgs(stripped), toolFree: true };
+ if (spec?.sandboxArgs) return { args: spec.sandboxArgs(stripped), toolFree: false, readOnlySandbox: true };
return { args: removed && spec?.afterStrip ? spec.afterStrip(stripped) : stripped, toolFree: false };
}
@@ -1129,6 +1145,19 @@ export function isToolFreeOneShotProvider(provider) {
return provider?.type === PROVIDER_TYPES.CLI && toolFreeOneShotArgs(provider).toolFree;
}
+/**
+ * Whether a headless CLI one-shot is held to an OS read-only sandbox (codex)
+ * though it cannot disable its tools. Weaker than tool-free: read tools remain.
+ */
+export function isReadOnlySandboxOneShotProvider(provider) {
+ return provider?.type === PROVIDER_TYPES.CLI && toolFreeOneShotArgs(provider).readOnlySandbox === true;
+}
+
+/** Providers music-video code authoring may use: tool-free, or read-only sandboxed. */
+export function isAuthoringOneShotProvider(provider) {
+ return isToolFreeOneShotProvider(provider) || isReadOnlySandboxOneShotProvider(provider);
+}
+
/**
* The refusal for a one-shot over caller text whose provider cannot be made
* tool-free and whose caller lacks host control, or null when it may run.
diff --git a/server/lib/providerVendors.toolFree.test.js b/server/lib/providerVendors.toolFree.test.js
index 20d34f2024..ab8cdb7055 100644
--- a/server/lib/providerVendors.toolFree.test.js
+++ b/server/lib/providerVendors.toolFree.test.js
@@ -5,7 +5,7 @@
import { readFileSync } from 'node:fs';
import { describe, expect, it } from 'vitest';
import { buildCliArgs } from './cliProviderArgs.js';
-import { isToolFreeOneShotProvider, toolFreeOneShotArgs, toolFreeOneShotRefusal } from './providerVendors.js';
+import { isAuthoringOneShotProvider, isToolFreeOneShotProvider, toolFreeOneShotArgs, toolFreeOneShotRefusal } from './providerVendors.js';
const SHIPPED_PROVIDERS = Object.values(
JSON.parse(readFileSync(new URL('../../data.reference/providers.json', import.meta.url), 'utf8')).providers,
@@ -84,6 +84,24 @@ describe('toolFreeOneShotArgs', () => {
});
});
+describe('codex read-only sandbox one-shot', () => {
+ it('confines codex to a read-only sandbox without calling it tool-free', () => {
+ const result = toolFreeOneShotArgs(cli('codex'), ['exec', '--sandbox', 'danger-full-access', '--dangerously-bypass-approvals-and-sandbox', '-']);
+ expect(result).toEqual({
+ args: ['exec', '--sandbox', 'read-only', '--skip-git-repo-check', '--ephemeral', '--ignore-user-config', '-'],
+ toolFree: false,
+ readOnlySandbox: true,
+ });
+ });
+
+ it('admits codex for authoring only, not for the host-control guard', () => {
+ expect(isAuthoringOneShotProvider(cli('codex'))).toBe(true);
+ expect(isToolFreeOneShotProvider(cli('codex'))).toBe(false);
+ expect(isAuthoringOneShotProvider(cli('agy'))).toBe(false);
+ expect(isAuthoringOneShotProvider({ type: 'tui', command: 'codex' })).toBe(false);
+ });
+});
+
describe('isToolFreeOneShotProvider / toolFreeOneShotRefusal', () => {
it('treats API providers and claude/grok/pi CLIs as tool-free, TUI records and agent CLIs as host control', () => {
expect(isToolFreeOneShotProvider({ type: 'api' })).toBe(true);
diff --git a/server/routes/providers.js b/server/routes/providers.js
index c90c8afc23..6979ca53b4 100644
--- a/server/routes/providers.js
+++ b/server/routes/providers.js
@@ -80,6 +80,7 @@ import {
import { runLocalRuntimeSetup, SETUP_ACTIONS } from '../services/localRuntimeSetup.js';
import { localEndpointPort, localRuntimeForProvider } from '../lib/localProviderRuntime.js';
import {
+ isAuthoringOneShotProvider,
isToolFreeOneShotProvider,
enforcedPublicReviewPosturesForProvider,
publicReviewPosturesForProvider,
@@ -213,6 +214,7 @@ const presentProvider = (provider, capabilities = captureSystemCapabilities()) =
// a card offers a button the route refuses.
canRefreshModels: decorated.canRefreshModels || Boolean(harnessCatalogRuntime(provider)),
toolFreeOneShot: isToolFreeOneShotProvider(provider),
+ authoringOneShot: isAuthoringOneShotProvider(provider),
publicReviewPostures,
publicReviewEnforcedPostures: enforcedPublicReviewPosturesForProvider(provider),
publicReviewSupported: publicReviewPostures.includes(PUBLIC_REVIEW_NO_TOOL_POSTURE),
diff --git a/server/services/musicVideo/productionService.js b/server/services/musicVideo/productionService.js
index 39ae14576e..fc3c9c8f00 100644
--- a/server/services/musicVideo/productionService.js
+++ b/server/services/musicVideo/productionService.js
@@ -31,7 +31,7 @@ import { ServerError } from '../../lib/errorHandler.js';
import { getProject, mutateProjectRecord } from './projects.js';
import { musicVideoEvents } from './events.js';
import { isFreeProvider } from '../../lib/modelPricing.js';
-import { isToolFreeOneShotProvider } from '../../lib/providerVendors.js';
+import { isAuthoringOneShotProvider } from '../../lib/providerVendors.js';
import { codeFirstProductionAssets } from '../../lib/musicVideoMediumPlan.js';
import { beginNextAttempt } from './autoReview.js';
import { withAutopilotCutting } from './composition.js';
@@ -106,7 +106,7 @@ const defaults = {
const { resolveProviderAndModel } = await import('../promptRunner.js');
const { provider, selectedModel } = await resolveProviderAndModel(input);
if (!provider || provider.id !== input?.providerId || provider.enabled === false || !selectedModel || selectedModel !== input?.model) throw new ServerError('The selected code-authoring provider/model is unavailable', { status: 409, code: 'PRODUCTION_AUTHORING_UNAVAILABLE' });
- if (!isToolFreeOneShotProvider(provider)) throw new ServerError('Choose an API or a tool-free headless CLI for code authoring', { status: 422, code: 'PRODUCTION_AUTHORING_UNAVAILABLE' });
+ if (!isAuthoringOneShotProvider(provider)) throw new ServerError('Choose an API, a tool-free headless CLI, or a read-only-sandboxed codex CLI for code authoring', { status: 422, code: 'PRODUCTION_AUTHORING_UNAVAILABLE' });
return { providerId: provider.id, model: selectedModel, ...(input.effort ? { effort: input.effort } : {}), costUsd: isFreeProvider(provider) ? 0 : null };
},
releaseRevisionSection: async (...args) => (await import('./revisionService.js')).releaseRevisionSection(...args),
@@ -368,7 +368,7 @@ async function authorDocument(projectId, runId, action) {
verifyCurrent,
beforeSubmit: async ({ provider, model }) => {
if (provider.id !== run.authoring.providerId || model !== run.authoring.model) throw new ServerError('The authoring provider/model changed; no fallback is allowed', { status: 409, code: 'PRODUCTION_AUTHORING_UNAVAILABLE' });
- if (!isToolFreeOneShotProvider(provider)) throw new ServerError('This code authoring provider cannot run without tools', { status: 422, code: 'PRODUCTION_AUTHORING_UNAVAILABLE' });
+ if (!isAuthoringOneShotProvider(provider)) throw new ServerError('This code authoring provider cannot run without tools', { status: 422, code: 'PRODUCTION_AUTHORING_UNAVAILABLE' });
const costUsd = isFreeProvider(provider) ? 0 : null;
const reserved = await mutateProjectRecord(projectId, (current) => {
verifyCurrent(current);