mirror of
https://github.com/Ark0N/Codeman.git
synced 2026-11-16 03:09:33 +01:00
Merge #753 feat(codex): let Codex sessions drive other sessions through the codeman skill
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
commit
44349395d0
30 files changed
+380
-47
No files matched your search
@@ -490,7 +490,11 @@ const capabilitiesSchema = z
|
||||
launchDefaults: z
|
||||
.record(
|
||||
z.string(),
|
||||
z.enum(['codexModel', 'codexReasoningEffort'] as const satisfies readonly LaunchDefaultSettingKey[])
|
||||
z.enum([
|
||||
'codexModel',
|
||||
'codexReasoningEffort',
|
||||
'codexNetworkAccess',
|
||||
] as const satisfies readonly LaunchDefaultSettingKey[])
|
||||
)
|
||||
.refine((v) => Object.keys(v).length >= 1 && Object.keys(v).length <= 8, 'launchDefaults takes 1 to 8 params')
|
||||
.optional(),
|
||||
|
||||
@@ -640,6 +640,7 @@ const CODEX: CliEntry = {
|
||||
launch: {
|
||||
params: {
|
||||
bypassApprovals: { type: 'bool' },
|
||||
networkAccess: { type: 'bool' },
|
||||
animations: { type: 'bool' },
|
||||
// `model-plain-colon`, not `model`: the custom-model feature forces the selected id
|
||||
// onto this param (`launchModel: '{modelId}'` below), and Ollama-style ids carry a
|
||||
@@ -653,7 +654,38 @@ const CODEX: CliEntry = {
|
||||
id: 'default',
|
||||
args: [
|
||||
{ lit: 'codex' },
|
||||
// Codex 0.162 hands every client's tool commands to ONE shared background
|
||||
// app-server (`codex app-server --managed-daemon`), started by whichever client
|
||||
// came first. Two things break inside a Codeman pane, both measured 2026-11-01 on
|
||||
// 0.162.0: the commands run with the STARTER's environment, so
|
||||
// `$CODEMAN_SESSION_ID`/`$CODEMAN_API_URL` belong to another session (the codeman
|
||||
// skill's self-check 404s and its delete guard protects the wrong id), and a daemon
|
||||
// of another version (a 0.166 one left by a later install) stops every launch on an
|
||||
// "incompatible feature settings" dialog before the composer appears. `--no-daemon`
|
||||
// runs this session's own in-process server, which is what a pane per session
|
||||
// means anyway. Gated at the version it was measured on; an older or unknown
|
||||
// codex gets nothing (fail-closed), since an unknown flag makes codex exit.
|
||||
{ flag: '--no-daemon', when: { capabilityGate: 'noDaemonFlag' } },
|
||||
{ flag: '--dangerously-bypass-approvals-and-sandbox', when: { param: 'bypassApprovals', is: true } },
|
||||
// Lets commands in codex's workspace-write sandbox open network connections,
|
||||
// Codeman's own API on loopback included (the codeman skill's curl calls fail
|
||||
// with "couldn't connect" without it). Measured on 0.162.0 (`codex sandbox` and
|
||||
// a live pane): loopback stays blocked under workspace-write until this is set.
|
||||
// ⚠️ Not a safe middle ground below the bypass above: that API can start a session
|
||||
// outside the sandbox with no approval prompt, so codex's sandbox no longer contains
|
||||
// a command once this is on. Measured 2026-11-06: a `touch` the sandbox refused
|
||||
// landed through POST /api/sessions, and with a password set too from inside a
|
||||
// Codeman pane, which inherits CODEMAN_PASSWORD by design.
|
||||
// ⚠️ Workspace-write ONLY: a folder codex runs read-only (one it does not trust,
|
||||
// such as a fresh non-git case) keeps the network closed and asks per command.
|
||||
// Deliberately not paired with `--sandbox workspace-write` (owner decision,
|
||||
// 2026-11-06), which would also grant write access to a folder codex itself chose
|
||||
// not to trust, under a label that only says "network".
|
||||
{
|
||||
flag: '--config',
|
||||
value: 'sandbox_workspace_write.network_access=true',
|
||||
when: { param: 'networkAccess', is: true },
|
||||
},
|
||||
{ flag: '--config', value: 'tui.animations=true', when: { param: 'animations', is: true } },
|
||||
{ flag: '--config', value: 'tui.animations=false', when: { param: 'animations', is: false } },
|
||||
{ flag: '--model', valueFrom: 'model', when: { param: 'model', state: 'set' } },
|
||||
@@ -819,7 +851,14 @@ const CODEX: CliEntry = {
|
||||
// App Settings → Codex model / reasoning effort (synced), filled into a LOCAL launch's
|
||||
// codexConfig wherever the caller left the field unset. Launch-only: nothing writes
|
||||
// codex's own config.toml. Read by applyLaunchDefaults() in src/web/launch-defaults.ts.
|
||||
launchDefaults: { model: 'codexModel', reasoningEffort: 'codexReasoningEffort' },
|
||||
// `networkAccess` (App Settings → Codex → Allow network access) rides the same path, so
|
||||
// a codex session started by the codeman skill, `codeman agent spawn` or the MCP server
|
||||
// gets it as well as one started from the browser. Off (the default) fills nothing.
|
||||
launchDefaults: {
|
||||
model: 'codexModel',
|
||||
reasoningEffort: 'codexReasoningEffort',
|
||||
networkAccess: 'codexNetworkAccess',
|
||||
},
|
||||
// Two columns, like claude's, measured on a live 0.154.0 answer: the `•`/`›`/`⚠`
|
||||
// markers sit in the gutter, prose continuations sit at 2, and a nested YAML block
|
||||
// the model wrote rendered at 2/4/6/8 for its own 0/2/4/6. Replayed at 100, 120,
|
||||
@@ -844,7 +883,19 @@ const CODEX: CliEntry = {
|
||||
// does. codex is the entry where the two names differ (`bypassApprovals` here,
|
||||
// `dangerouslyBypassApprovals` on the wire), so it is the one that would have caught a
|
||||
// regression; `schema.ts` now rejects a name that is not a declared param.
|
||||
privilegedParams: [{ param: 'bypassApprovals', clampTo: false }],
|
||||
//
|
||||
// `networkAccess` widens the sandbox too (any host, not just Codeman's loopback API), so
|
||||
// a non-granted owner gets it forced off like the bypass. Only-if-sent is enough here as
|
||||
// well: an absent value leaves codex's own no-network default, and the launch default
|
||||
// above is filled BEFORE the clamp runs, so a filled `true` is still clamped.
|
||||
privilegedParams: [
|
||||
{ param: 'bypassApprovals', clampTo: false },
|
||||
{ param: 'networkAccess', clampTo: false },
|
||||
],
|
||||
// `--no-daemon` above. Evaluated against codex's OWN version (resolveSessionCliVersion).
|
||||
gates: {
|
||||
noDaemonFlag: { minVersion: '0.162.0', failClosed: true },
|
||||
},
|
||||
mcpConfig: {
|
||||
path: '.codex/config.toml',
|
||||
format: 'codex-toml',
|
||||
|
||||
@@ -112,7 +112,7 @@ export type ModelConfigResolverName = 'deepseek-route';
|
||||
* arbitrary setting onto a command line; each name must also be a `SettingsUpdateSchema`
|
||||
* key, which the resolver's typing enforces.
|
||||
*/
|
||||
export type LaunchDefaultSettingKey = 'codexModel' | 'codexReasoningEffort';
|
||||
export type LaunchDefaultSettingKey = 'codexModel' | 'codexReasoningEffort' | 'codexNetworkAccess';
|
||||
|
||||
/** The MCP config dialects `src/mcp-sync.ts` has an adapter for. */
|
||||
export type McpConfigFormat =
|
||||
|
||||
+3
-3
@@ -1682,9 +1682,9 @@ export async function probeDockerCliVersion(
|
||||
if (IS_TEST_MODE) return undefined;
|
||||
// ⚠️ The MODE NAME IS NOT ALWAYS THE BINARY NAME — `antigravity` runs `agy`. This used
|
||||
// to pass the mode straight through as the command, which would have probed a binary that
|
||||
// does not exist. Only claude reaches this today (it is the one CLI with a version gate),
|
||||
// so nothing was actually broken, but the registry is what makes it correct for the next
|
||||
// CLI that needs a version.
|
||||
// does not exist. Claude and codex reach this today (the CLIs with a version gate), and
|
||||
// both binaries match their mode, so nothing was actually broken, but the registry is what
|
||||
// makes it correct for the next CLI that needs a version.
|
||||
const bin = getCli(mode)?.discovery.binaries[0];
|
||||
if (!bin) return undefined; // `shell` has no binary of its own
|
||||
const argv = dockerEngineArgv(docker);
|
||||
|
||||
+2
-1
@@ -1433,7 +1433,8 @@ export async function installAgentSkillInto(skillDir: string): Promise<AgentSkil
|
||||
* the skill (`agentSkillDir()` non-null, any CLI: the preamble is bash + curl + jq, nothing
|
||||
* claude-specific; a remote or in-container HOME is not this filesystem) and treat it as
|
||||
* best-effort: the skill's §0 fallback block self-heals a missing or stale file. Codex
|
||||
* caveat: codex 0.162 runs tool commands in a shared app-server daemon whose
|
||||
* caveat: a local codex started without `--no-daemon` (older than 0.162, or its version
|
||||
* probe failed) can run tool commands in a shared app-server daemon whose
|
||||
* `CODEMAN_SESSION_ID` is the starting session's, so its loader looks for that session's
|
||||
* file and its self id is wrong; the skill tells the agent how to notice.
|
||||
*/
|
||||
|
||||
@@ -23,7 +23,7 @@ import { renderLaunch, type EngineValues, type ParamValues } from './config/cli-
|
||||
import { matchesPattern } from './config/cli-registry/patterns.js';
|
||||
import { buildAdvisorSettings, buildEffortCliArgs, sanitizeCliSessionName } from './session-cli-builder.js';
|
||||
import { compareVersions } from './utils/dependency-checker.js';
|
||||
import { getClaudeCliVersion } from './utils/claude-cli-resolver.js';
|
||||
import { resolveSessionCliVersion } from './utils/cli-resolver.js';
|
||||
import { launcherDefaultTarget } from './utils/cli-launcher.js';
|
||||
import { getCli } from './config/cli-registry/registry.js';
|
||||
import type {
|
||||
@@ -184,9 +184,19 @@ function resolveGatesPassed(entry: CliEntry, resolveVersion: () => string | null
|
||||
export function launchGatePasses(mode: string, gate: string, claudeCliVersion?: string | null): boolean {
|
||||
const entry = getCli(mode);
|
||||
if (!entry?.capabilities.gates[gate]) return false;
|
||||
return resolveGatesPassed(entry, () =>
|
||||
claudeCliVersion !== undefined ? claudeCliVersion : getClaudeCliVersion()
|
||||
).has(gate);
|
||||
return resolveGatesPassed(entry, () => gateVersion(entry, claudeCliVersion)).has(gate);
|
||||
}
|
||||
|
||||
/**
|
||||
* The version a gate of `entry` is measured against: the caller's explicit value (tests, or
|
||||
* null for "known unknown"), else THIS entry's own local CLI via resolveSessionCliVersion.
|
||||
* ⚠️ Never `getClaudeCliVersion()` for every entry, which is what this used to do: codex's
|
||||
* `noDaemonFlag` gate (0.162.0) would then have passed on any claude 2.x and handed an older
|
||||
* codex a flag it exits on. resolveSessionCliVersion still routes claude to its own probe
|
||||
* policy (`retryOnTransientFailure`), so a claude launch is unchanged.
|
||||
*/
|
||||
function gateVersion(entry: CliEntry, explicit: string | null | undefined): string | null {
|
||||
return explicit !== undefined ? explicit : resolveSessionCliVersion(entry.id);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -253,14 +263,12 @@ export function buildSpawnCommandFromRegistry(entry: CliEntry, options: SpawnBri
|
||||
// `startupHint` setting are on. Claude-only in practice, like the settings object above.
|
||||
engineValues.appendSystemPrompt = getDiscordStartupHint();
|
||||
|
||||
// Preserves buildSpawnCommand's original fallback exactly: an EXPLICIT `undefined` probes
|
||||
// the local claude CLI (getClaudeCliVersion, null under vitest); an explicit `null` means
|
||||
// "known to be unresolvable" and must not probe. The probe only ever runs from
|
||||
// resolveGatesPassed, and only for an entry that actually declares a gate, so this stays
|
||||
// generic without spawning a stray `claude --version` for every other CLI's launch.
|
||||
const gatesPassed = resolveGatesPassed(entry, () =>
|
||||
options.claudeCliVersion !== undefined ? options.claudeCliVersion : getClaudeCliVersion()
|
||||
);
|
||||
// Preserves buildSpawnCommand's original fallback: an EXPLICIT `undefined` probes the
|
||||
// entry's own local CLI (gateVersion: claude's probe for claude, the registry resolver for
|
||||
// the rest, both null under vitest); an explicit `null` means "known to be unresolvable"
|
||||
// and must not probe. The probe only ever runs from resolveGatesPassed, and only for an
|
||||
// entry that actually declares a gate, so a CLI with none never spawns a `--version`.
|
||||
const gatesPassed = resolveGatesPassed(entry, () => gateVersion(entry, options.claudeCliVersion));
|
||||
|
||||
return renderLaunch(entry.launch, params, engineValues, gatesPassed);
|
||||
}
|
||||
+2
-2
@@ -278,8 +278,8 @@ function getModeLabel(mode: SessionMode): string {
|
||||
*
|
||||
* Only such a CLI needs its version probed at session start — probing one with no gates
|
||||
* would spawn a `--version` subprocess whose answer nothing reads. Today that is claude
|
||||
* (the `--name` flag, gated at 2.1.224), which is why the probe used to be written as
|
||||
* `mode === 'claude'`.
|
||||
* (the `--name` flag, gated at 2.1.224) and codex (`--no-daemon`, gated at 0.162.0). The
|
||||
* probe used to be written as `mode === 'claude'`, when claude was the only one.
|
||||
*/
|
||||
function cliNeedsVersionProbe(mode: SessionMode): boolean {
|
||||
return Object.keys(getCli(mode)?.capabilities.gates ?? {}).length > 0;
|
||||
|
||||
+3
-2
@@ -1203,8 +1203,9 @@ export function buildSpawnCommand(options: {
|
||||
/** Name pinned on claude as `--name` (version-gated, sanitized; local spawns only). By default only a user-chosen name; `pinCliSessionName` pins every tab name: see `Session.cliPinnedName`. */
|
||||
sessionName?: string;
|
||||
/**
|
||||
* Claude CLI version for the `--name` gate. Omitted = probe the local CLI
|
||||
* (getClaudeCliVersion; null under vitest). Tests inject a value here; the
|
||||
* CLI version for the launch template's version gates (claude's `--name`, codex's
|
||||
* `--no-daemon`). Omitted = probe the mode's own local CLI (resolveSessionCliVersion;
|
||||
* null under vitest). The name predates the second gated CLI. Tests inject a value here; the
|
||||
* docker/remote paths never see this builder's output, which is what keeps the
|
||||
* gate measuring the RIGHT binary, the local one.
|
||||
*/
|
||||
|
||||
@@ -438,6 +438,14 @@ export interface CodexConfig {
|
||||
resumeSessionId?: string;
|
||||
/** Bypass approval prompts (passes --dangerously-bypass-approvals-and-sandbox) */
|
||||
dangerouslyBypassApprovals?: boolean;
|
||||
/**
|
||||
* Let commands in codex's workspace-write sandbox use the network, Codeman's loopback API
|
||||
* included (passes --config sandbox_workspace_write.network_access=true). Never changes the
|
||||
* sandbox mode: a folder codex runs read-only keeps the network closed and asks per command.
|
||||
* Filled from the synced `codexNetworkAccess` setting when unset; clamped off for a
|
||||
* non-granted owner.
|
||||
*/
|
||||
networkAccess?: boolean;
|
||||
/** Enable Codex's decorative TUI animations. Disable to reduce remote terminal redraws. */
|
||||
animations?: boolean;
|
||||
/** Browser rendering strategy for Codex sessions. Hybrid TUI is the only supported mode. */
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* @fileoverview Launch-time defaults from synced App Settings, driven by registry data.
|
||||
*
|
||||
* A CLI entry declares `capabilities.launchDefaults` (launch param -> settings key; today
|
||||
* only codex, `{ model: 'codexModel', reasoningEffort: 'codexReasoningEffort' }`), and
|
||||
* only codex: `model`, `reasoningEffort` and `networkAccess`), and
|
||||
* `applyLaunchDefaults()` fills those settings into the entry's `launch.legacyConfigField`
|
||||
* object, setting ONLY the fields the caller left unset. Persisted values are re-validated
|
||||
* with `SettingsUpdateSchema`, so a hand-edited settings.json can never smuggle an
|
||||
@@ -39,7 +39,7 @@ export async function applyLaunchDefaults<T extends object>(
|
||||
const defaults: Record<string, unknown> = {};
|
||||
for (const [param, settingKey] of Object.entries(declared)) {
|
||||
const parsed = SettingsUpdateSchema.shape[settingKey].safeParse(settings[settingKey]);
|
||||
// '' is the settings' "leave it to the CLI" value, the same as unset.
|
||||
// '' and an off switch are the settings' "leave it to the CLI" value, the same as unset.
|
||||
const value = parsed.success ? parsed.data || undefined : undefined;
|
||||
const wireKey = aliases[param] ?? param;
|
||||
if (value !== undefined && (current?.[wireKey] ?? undefined) === undefined) defaults[wireKey] = value;
|
||||
|
||||
@@ -3050,6 +3050,13 @@
|
||||
</div>
|
||||
<label class="switch switch-sm"><input type="checkbox" id="appSettingsCodexDangerouslyBypassApprovals"><span class="slider"></span></label>
|
||||
</div>
|
||||
<div class="set-row" data-search="codex network access sandbox loopback codeman skill orchestrate spawn">
|
||||
<div class="set-row-text">
|
||||
<span class="set-row-label">Allow network access</span>
|
||||
<span class="set-row-desc">Lets commands in Codex's workspace-write sandbox use the network, which the Codeman skill needs to reach this server. Those commands can then call Codeman's API, which can start a session outside the sandbox with no approval prompt, even when a password is set. So with this on, Codex's sandbox does not contain a prompt-injected command: treat it as close to Bypass. Applies to every new local Codex session, not scheduled jobs. It does not change Codex's sandbox mode: a folder Codex runs read-only (one it does not trust) keeps the network closed and asks per command.</span>
|
||||
</div>
|
||||
<label class="switch switch-sm"><input type="checkbox" id="appSettingsCodexNetworkAccess"><span class="slider"></span></label>
|
||||
</div>
|
||||
<div class="set-row" data-search="codex animations status effects">
|
||||
<div class="set-row-text">
|
||||
<span class="set-row-label">Animated status effects</span>
|
||||
|
||||
@@ -699,6 +699,7 @@ Object.assign(CodemanApp.prototype, {
|
||||
// that does have it.
|
||||
document.getElementById('appSettingsCodexDangerouslyBypassApprovals').checked =
|
||||
settings.codexDangerouslyBypassApprovals ?? false;
|
||||
document.getElementById('appSettingsCodexNetworkAccess').checked = settings.codexNetworkAccess ?? false;
|
||||
document.getElementById('appSettingsCodexAnimations').checked =
|
||||
settings.codexAnimationsEnabled ?? false;
|
||||
document.getElementById('appSettingsCodexModel').value = settings.codexModel ?? '';
|
||||
@@ -3209,6 +3210,7 @@ Object.assign(CodemanApp.prototype, {
|
||||
codexModel: document.getElementById('appSettingsCodexModel').value.trim(),
|
||||
codexReasoningEffort: document.getElementById('appSettingsCodexReasoningEffort').value,
|
||||
codexDangerouslyBypassApprovals: document.getElementById('appSettingsCodexDangerouslyBypassApprovals').checked,
|
||||
codexNetworkAccess: document.getElementById('appSettingsCodexNetworkAccess').checked,
|
||||
codexAnimationsEnabled: document.getElementById('appSettingsCodexAnimations').checked,
|
||||
// Claude Permissions settings
|
||||
agentTeamsEnabled: document.getElementById('appSettingsAgentTeams').checked,
|
||||
|
||||
@@ -1379,8 +1379,9 @@ export function registerSessionRoutes(
|
||||
const globalNice = await ctx.getGlobalNiceConfig();
|
||||
const modelConfig = await ctx.getModelConfig();
|
||||
const mode = body.mode || 'claude';
|
||||
// Synced App Settings launch defaults (capabilities.launchDefaults, codex's model and
|
||||
// effort today) fill the CLI's own config object where the caller left it unset.
|
||||
// Synced App Settings launch defaults (capabilities.launchDefaults, codex's model,
|
||||
// effort and network access today) fill the CLI's own config object where the caller
|
||||
// left it unset.
|
||||
// Local launches only: a remote attach runs whatever the remote pane already runs.
|
||||
const launchBody = remote ? body : await applyLaunchDefaults(mode, body);
|
||||
// Where a model override comes from is a capability, and the three answers are
|
||||
|
||||
@@ -371,6 +371,7 @@ const CodexConfigSchema = z
|
||||
.regex(/^[a-zA-Z0-9_-]+$/)
|
||||
.optional(),
|
||||
dangerouslyBypassApprovals: z.boolean().optional(),
|
||||
networkAccess: z.boolean().optional(),
|
||||
animations: z.boolean().optional(),
|
||||
renderMode: z
|
||||
.enum(['scrollback', 'hybrid'])
|
||||
@@ -1723,6 +1724,7 @@ export const SettingsUpdateSchema = z
|
||||
.optional(),
|
||||
codexReasoningEffort: z.enum(['', ...CODEX_REASONING_EFFORTS]).optional(),
|
||||
codexDangerouslyBypassApprovals: z.boolean().optional(),
|
||||
codexNetworkAccess: z.boolean().optional(),
|
||||
codexAnimationsEnabled: z.boolean().optional(),
|
||||
// Terminal history and retention
|
||||
terminalScrollbackLines: z
|
||||
|
||||
Reference in new issue
Block a user