Skip to content

Open-source AI teammates in Slack, Teams, Discord, Telegram and Mattermost. Self-host it, with any agent harness and any model.

feat(codex): bundle the Switch MCP server in the Codex plugin; fix bypass, tool auto-approval & runtime status (CHOO-1935)

Christian McDermottdb1426cb74ea
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 254a4c0b3..e880a24a1 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -182,6 +182,34 @@ below:
### [Unreleased]
+#### Added
+- The Codex connector plugin now ships the Switch MCP server itself
+ (`mcpServers` + `env_vars` name-forwarding), so Codex can be used with Switch
+ **outside switchdash** — previously the server was registered only by a
+ switchdash-written profile, and a hand-run Codex session had the room-workflow
+ skill but none of the tools it describes. The plugin also auto-approves the
+ Switch tools, which no `approval_policy` setting could do: measured against
+ codex-cli 0.146.0, that setting does not govern MCP tool calls at all
+ (CHOO-1935).
+
+ ⚠️ Codex upgrades a plugin only when a user clicks Update in Settings and
+ caches each version separately, so an install still on an older connector has
+ no Switch tools until it is upgraded.
+
+#### Fixed
+- Bypass permissions is applied to sessions again: the toggle is stored on the
+ agent but every launch read a copy frozen into the session at creation, so
+ changing it never affected an existing session — on restart or resume — while
+ the settings copy promised the opposite (CHOO-1935).
+- Codex runtime status reports tool calls ("Running tool …") instead of sitting
+ on "Working on it…" for a whole turn; no tool hook was registered for Codex,
+ so nothing could ever produce an activity update (CHOO-1935).
+
+#### Changed
+- The per-agent Codex profile carries only model, reasoning effort and
+ instructions. An agent that sets none of them no longer gets a profile at all
+ (CHOO-1935).
+
### [0.18.2] - 2026-08-05
#### Fixed
@@ -211,8 +239,7 @@ below:
approval (validated — an unknown value fails rather than silently widening the
sandbox); a Codex agent defaults to a `codex.<repo>.<user>` identity; and
switchdash registers the Switch MCP runtime for Codex itself via a per-agent
- Codex profile, since Codex can't expand `${VAR}` in a bundled `.mcp.json`
- (CHOO-1436, #91, #79).
+ Codex profile (CHOO-1436, #91, #79).
#### Fixed
- Codex session correctness: per-agent Switch credentials are written to disk for
diff --git a/CLAUDE.md b/CLAUDE.md
index 4a45f310c..20e6e6772 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -86,13 +86,33 @@ each ships its own copy of the Switch room-workflow skill at
fetched with `npx` and built from `dash/packages/switch-agent-runtime/`.
switchdash imports the same package for its protocol client, so there is one
implementation of the agent protocol rather than a copy per consumer.
-- `connectors/codex-plugin/` — manifest `.codex-plugin/plugin.json`. Ships
- **only** the skill. Codex does not expand `${VAR}` in a plugin-bundled
- `.mcp.json` and has no `${CLAUDE_PLUGIN_ROOT}` equivalent, so switchdash
- registers the same local `switch-agent-runtime` MCP server itself when it
- launches the session — through a per-agent Codex profile
- (`$CODEX_HOME/<slug>.config.toml`, launched with `--profile <slug>`), since a
- stdio server cannot be expressed on argv the way an HTTP one can.
+- `connectors/codex-plugin/` — manifest `.codex-plugin/plugin.json`. Ships the
+ skill plus its own MCP config, declared as `"mcpServers": "./.mcp.json"`, so a
+ Codex session gets the Switch tools from the plugin alone. Codex does not
+ expand `${VAR}` in a bundled config, so the server names its variables under
+ `env_vars` and Codex forwards them **by name** from its own environment — no
+ expansion, and no secret in the file. An unset name is simply not forwarded,
+ which is why the list can include the switchdash-only variables without
+ breaking a standalone session (the Claude connector cannot do this: `${VAR}`
+ expansion makes every declared variable mandatory).
+
+ The plugin's `.mcp.json` also carries `default_tools_approval_mode =
+ "approve"`, so the Switch tools never prompt. It has to live there rather than
+ in anything switchdash writes: **no per-server setting can be layered onto a
+ plugin-provided MCP server.** An `mcp_servers.switch.*` entry with no
+ transport of its own — from the base config, a profile, or `-c` on argv —
+ makes Codex reject the whole config as "invalid transport" and the session
+ dies with it.
+
+ switchdash writes a per-agent Codex profile
+ (`$CODEX_HOME/<slug>.config.toml`, launched with `--profile <slug>`) carrying
+ **only** model, reasoning effort and instructions. It registers no MCP server.
+ An agent that specializes none of those gets no profile and no `--profile`
+ argv at all.
+
+ Note a connector plugin is only upgraded when a user clicks Update in
+ settings, and Codex caches an install per version, so an install on an older
+ plugin has no Switch tools until it is upgraded.
When you change how agents interact with Switch — new/changed MCP tools, in-room
commands, room workflow, or anything an agent-facing client needs to know:
diff --git a/connectors/codex-plugin/.codex-plugin/plugin.json b/connectors/codex-plugin/.codex-plugin/plugin.json
index fe579c5d9..e9e09eb16 100644
--- a/connectors/codex-plugin/.codex-plugin/plugin.json
+++ b/connectors/codex-plugin/.codex-plugin/plugin.json
@@ -1,6 +1,7 @@
{
"name": "switch-connector-codex",
- "version": "0.1.5",
+ "version": "0.2.0",
"description": "Connect Codex to a Switch platform instance as a participating agent",
- "skills": "./skills/"
+ "skills": "./skills/",
+ "mcpServers": "./.mcp.json"
}
diff --git a/connectors/codex-plugin/.mcp.json b/connectors/codex-plugin/.mcp.json
new file mode 100644
index 000000000..fea380cd8
--- /dev/null
+++ b/connectors/codex-plugin/.mcp.json
@@ -0,0 +1,19 @@
+{
+ "mcpServers": {
+ "switch": {
+ "command": "npx",
+ "args": ["-y", "@sandbox-quantum/[email protected]"],
+ "env_vars": [
+ "SWITCH_API_ENDPOINT",
+ "SWITCH_API_TOKEN",
+ "SWITCH_AGENT_ID",
+ "SWITCH_CONNECTION_ID",
+ "SWITCH_CHANNEL_DISABLE_POLL",
+ "npm_config_userconfig",
+ "SWITCHDASH_GITHUB_TOKEN"
+ ],
+ "startup_timeout_sec": 60,
+ "default_tools_approval_mode": "approve"
+ }
+ }
+}
diff --git a/connectors/codex-plugin/README.md b/connectors/codex-plugin/README.md
index 888e2bb47..1a9207549 100644
--- a/connectors/codex-plugin/README.md
+++ b/connectors/codex-plugin/README.md
@@ -4,51 +4,107 @@ The Codex build of the Switch connector plugin. It ships the **Switch
room-workflow skill** (`skills/switch/SKILL.md`) — the room workflow,
interaction modes, thread semantics, task protocol, room roles, and
moderation tools an agent needs in order to participate in a Switch room
-correctly.
+correctly — and the **Switch MCP server** that provides the tools the skill
+describes.
Manifest: `.codex-plugin/plugin.json`. Registered in the repo marketplace
(`.claude-plugin/marketplace.json`) as `switch-connector-codex`.
-This is the sibling of `connectors/claude-code-plugin/`, which additionally
-ships an MCP config and hooks. Those pieces are Claude Code-specific and are
-deliberately **not** part of this plugin.
-
-## The Switch MCP server is not registered by this plugin
-
-Codex does **not** expand `${VAR}` inside a plugin-bundled `.mcp.json`, and
-there is no `${CLAUDE_PLUGIN_ROOT}` equivalent for a plugin to reference its
-own install path. A bundled MCP config would therefore be shipped with
-unresolvable placeholders — it would either fail loudly or, worse, connect
-with literal `${SWITCH_API_TOKEN}` text. So this plugin ships no `.mcp.json`
-and never references its own path.
-
-Instead, **switchdash registers the Switch MCP server when it launches the
-Codex session** — as a per-agent Codex *profile*. It writes
-`$CODEX_HOME/<agent-slug>.config.toml` (under `~/.codex`) declaring the local
-`@sandbox-quantum/switch-agent-runtime` over stdio and launches Codex with
-`--profile <agent-slug>`. The profile is static and holds no secret: it lists
-the variables the runtime needs — `SWITCH_API_ENDPOINT` / `SWITCH_API_TOKEN` /
-`SWITCH_AGENT_ID` (and `SWITCH_CONNECTION_ID`) — under `env_vars`, and Codex
-forwards those by name from its own environment, which switchdash populates
-from the agent's `.switch/agents/<slug>.json`. Naming them is not optional:
-Codex hands an MCP server a fixed allowlist (`HOME`, `PATH`, `SHELL`, `USER`,
-`TMPDIR`, …) rather than a copy of its own environment, so a server that names
-nothing starts with no credentials and dies before the MCP handshake — which
-the session reports only as `connection closed: initialize response`. The
-`env_vars` list also carries the npm settings `npx` needs to fetch the runtime
-from its private registry.
+This is the sibling of `connectors/claude-code-plugin/`. Both ship the skill
+and an MCP config; the Claude plugin additionally ships hooks, which are
+Claude Code-specific and deliberately not part of this one.
+
+## The Switch MCP server
+
+The manifest declares `"mcpServers": "./.mcp.json"`, and that file registers
+`@sandbox-quantum/switch-agent-runtime` over stdio under the server name
+`switch` — the name the skill assumes. A Codex session with this plugin
+installed has the Switch tools, whether or not switchdash launched it.
+
+The config holds **no secret**. It names the variables the runtime needs under
+`env_vars`, and Codex forwards those **by name** from its own environment:
+
+```json
+{
+ "mcpServers": {
+ "switch": {
+ "command": "npx",
+ "args": ["-y", "@sandbox-quantum/[email protected]"],
+ "env_vars": ["SWITCH_API_ENDPOINT", "SWITCH_API_TOKEN", "SWITCH_AGENT_ID", "…"],
+ "startup_timeout_sec": 60
+ }
+ }
+}
+```
+
+Naming them is not optional. Codex hands an MCP server a fixed allowlist
+(`HOME`, `PATH`, `SHELL`, `USER`, `TMPDIR`, …) rather than a copy of its own
+environment, so a server that names nothing starts with no credentials and dies
+before the MCP handshake — which the session reports only as
+`connection closed: initialize response`.
+
+Two properties of `env_vars` are worth stating, because the plugin's shape
+depends on them:
+
+- **It forwards by name, so no `${VAR}` expansion is required.** Codex does not
+ expand `${VAR}` inside a bundled config — it stores the literal string — but
+ that only rules out an `env` map of placeholders, not a bundled config as
+ such. (This was previously documented the other way round, as a reason the
+ server could not ship here at all.)
+- **An unset name is simply not forwarded.** So the list can name
+ switchdash-only variables (`SWITCH_CONNECTION_ID`, the npm registry settings)
+ without breaking a session that has none of them. The Claude connector cannot
+ do this: `${VAR}` expansion makes every declared variable mandatory.
+
+`startup_timeout_sec` is raised from Codex's 10s default because a host that has
+never run the runtime can exceed it on the `npx` fetch alone, and a timeout
+there is indistinguishable from a broken server.
+
+## What switchdash adds on top
+
+switchdash writes a per-agent Codex *profile*
+(`$CODEX_HOME/<agent-slug>.config.toml`, launched with `--profile <agent-slug>`)
+carrying what is genuinely per-agent: model, reasoning effort, and
+instructions. It registers **no** MCP server — this plugin does that — and an
+agent that specializes none of those three gets no profile at all.
+
+switchdash's remaining job for the server is to put the credentials this config
+names into the session's environment, read from the agent's
+`.switch/agents/<slug>.json`.
+
+Because a plugin is only upgraded when a user clicks Update in switchdash's
+settings, and Codex caches each version in its own directory, an install on a
+plugin older than this one has no Switch tools until it is upgraded.
+
+## Auto-approving the Switch tools
+
+`.mcp.json` sets `default_tools_approval_mode: "approve"`. An agent answering a
+room is unattended by definition, so a permission prompt on `post_message`
+stops the turn with nobody watching to release it, and the tools reach Switch
+over the session's own credentials without touching the host.
+
+Two things are worth knowing before changing it:
+
+- **`approval_policy` does not govern MCP tool calls at all.** Measured against
+ codex-cli 0.146.0, a write-annotated MCP tool is denied under `untrusted`,
+ `on-request` *and* `never` alike. `default_tools_approval_mode` is the only
+ lever that moves them, and `approve` is the only one of its four values
+ (`auto`, `prompt`, `writes`, `approve`) that admits a tool annotated as
+ writing.
+- **A value outside that enum fails silently.** Codex does not reject it — it
+ drops the entire server and reports no MCP servers at all, so the session
+ simply has no Switch tools.
+
+It lives here rather than in anything switchdash writes because no per-server
+setting can be layered onto a plugin-provided server: an `mcp_servers.switch.*`
+entry with no transport of its own, whether from the base config, a profile or
+`-c` on argv, makes Codex reject the whole config as "invalid transport".
A profile does *not* replace a same-named server in the user's base
`~/.codex/config.toml` — the two tables are merged. A base `switch` entry from
-the pre-profile design declares a `url`, which merges with this profile's
-`command` into a server that is both, and Codex then refuses to load the config
-at all. switchdash removes such an entry when it writes the profile. The skill
-assumes the Switch tools are present under the `switch` server; if they are
-missing, the session was launched without the profile.
-
-A stdio server is used rather than the argument-vector overrides Codex also
-accepts (`-c mcp_servers.switch.*`) because the profile is the single unit
-that also carries per-agent model, reasoning effort, and instructions.
+the pre-profile design declares a `url`, which merges with a `command` entry
+into a server that is both, and Codex then refuses to load the config at all.
+switchdash removes such an entry.
## What the registered runtime gives a Codex session
@@ -72,6 +128,6 @@ is in — no tool-response scraping, and no per-session room-tracking hook.
One caveat on remote hosts: room tracking depends on that connection, which
switchdash opens only for a session it can keep attached — i.e. a tmux session.
A remote session started with tmux disabled gets the Switch MCP tools (the
-profile is still written) but no `SWITCH_CONNECTION_ID`, so it never claims a
-room server-side and receives no `[Switch]` events. Run remote Codex agents
-with tmux (the default) for room participation.
+plugin registers them regardless) but no `SWITCH_CONNECTION_ID`, so it never
+claims a room server-side and receives no `[Switch]` events. Run remote Codex
+agents with tmux (the default) for room participation.
diff --git a/dash/apps/switchdash-desktop/src/main/core/agent-hooks/event-enricher.ts b/dash/apps/switchdash-desktop/src/main/core/agent-hooks/event-enricher.ts
index ee5d4b28d..fbddf5e40 100644
--- a/dash/apps/switchdash-desktop/src/main/core/agent-hooks/event-enricher.ts
+++ b/dash/apps/switchdash-desktop/src/main/core/agent-hooks/event-enricher.ts
@@ -48,10 +48,12 @@ export interface HookEventLogger {
* instead: it carries a `SWITCH_CONNECTION_ID` and its `connect_to_room` claims
* the room on that connection. The hook covers what that path misses — a Claude
* session started outside switchdash and adopted afterwards, which joined a room
- * on a connection of its own. Codex has no equivalent case, so
- * `buildCodexHookConfig` registers no room hook: its Switch MCP server exists
- * only in the per-agent profile switchdash writes and launches it with, so a
- * Codex session switchdash did not start has no `connect_to_room` to call.
+ * on a connection of its own.
+ *
+ * `buildCodexHookConfig` registers no room hook. Note the case is no longer
+ * impossible: the Codex connector plugin now ships the Switch MCP server, so a
+ * Codex session started outside switchdash does have `connect_to_room`. An
+ * adopted Codex session is therefore untracked rather than inconceivable.
*/
const SWITCH_ROOM_CONNECT_EVENT = 'switch_room_connect';
diff --git a/dash/apps/switchdash-desktop/src/main/core/agent-runtime/switch-mcp-launch-args.test.ts b/dash/apps/switchdash-desktop/src/main/core/agent-runtime/agent-launch-profile.test.ts
similarity index 55%
rename from dash/apps/switchdash-desktop/src/main/core/agent-runtime/switch-mcp-launch-args.test.ts
rename to dash/apps/switchdash-desktop/src/main/core/agent-runtime/agent-launch-profile.test.ts
index aa4d75656..7758894de 100644
--- a/dash/apps/switchdash-desktop/src/main/core/agent-runtime/switch-mcp-launch-args.test.ts
+++ b/dash/apps/switchdash-desktop/src/main/core/agent-runtime/agent-launch-profile.test.ts
@@ -1,17 +1,15 @@
import type { PluginFs } from '@switchdash/core/agents/plugins';
import { pluginRegistry } from '@switchdash/plugins/agents';
-import { parse as parseTOML } from 'smol-toml';
import { describe, expect, it } from 'vitest';
import type { getPlugin } from '@main/core/providers/plugin-registry';
-import { switchAgentRuntimeCommand } from '@shared/core/switch-rooms/switch-agent-runtime';
-import { prepareSwitchMcpLaunch, resolveSwitchLaunchProfile } from './switch-mcp-launch-args';
+import { prepareAgentLaunchProfile, resolveAgentLaunchProfile } from './agent-launch-profile';
type Plugin = ReturnType<typeof getPlugin>;
-/** The real Codex plugin — it registers the Switch server via a profile. */
+/** The real Codex plugin — the only one that takes specialization from a file. */
const codexPlugin = pluginRegistry.get('codex')! as unknown as Plugin;
-/** A provider whose connector resolves MCP servers itself, as Claude's does. */
+/** A provider that takes its specialization on argv, as Claude's does. */
const claudeLikePlugin = { behavior: { mcp: {} } } as unknown as Plugin;
/** An agent working directory; folded into the profile name for uniqueness. */
@@ -20,6 +18,8 @@ const WD = '/home/agent/repo';
/** The profile filename stem is the `--profile` value; assert they agree. */
const PROFILE_STEM = /^codex-hoot-[a-z0-9]+$/;
+const SPECIALIZED = { model: 'gpt-5.6-terra' };
+
function memoryFs(): PluginFs & { files: Map<string, string> } {
const files = new Map<string, string>();
return {
@@ -42,43 +42,53 @@ function memoryFs(): PluginFs & { files: Map<string, string> } {
};
}
-describe('resolveSwitchLaunchProfile', () => {
- it('returns a Codex profile registering the local stdio runtime, keyed on the (dir, slug)', () => {
- const profile = resolveSwitchLaunchProfile(codexPlugin, {
+describe('resolveAgentLaunchProfile', () => {
+ it('returns a Codex profile keyed on the (dir, slug)', () => {
+ const profile = resolveAgentLaunchProfile(codexPlugin, {
slug: 'codex-hoot',
workingDir: WD,
- hasSwitchIdentity: true,
+ specialization: SPECIALIZED,
});
expect(profile).not.toBeNull();
// The --profile value and the file stem are the same digest-suffixed name.
expect(profile!.args[0]).toBe('--profile');
expect(profile!.args[1]).toMatch(PROFILE_STEM);
expect(profile!.files[0].relativePath).toBe(`.codex/${profile!.args[1]}.config.toml`);
- expect(profile!.files[0].content).toContain('[mcp_servers.switch]');
- expect(profile!.files[0].content).toContain('command = "npx"');
- expect(profile!.files[0].content).toContain('@sandbox-quantum/switch-agent-runtime@');
+ });
+
+ it('registers no MCP server — the connector plugin ships that', () => {
+ // The Switch server lives in the plugin's bundled `.mcp.json`, so a session
+ // has it whether or not switchdash launched it. Writing it here as well
+ // would restrict nothing and duplicate the declaration.
+ const profile = resolveAgentLaunchProfile(codexPlugin, {
+ slug: 'codex-hoot',
+ workingDir: WD,
+ specialization: SPECIALIZED,
+ })!;
+
+ expect(profile.files[0].content).not.toContain('mcp_servers');
+ expect(profile.files[0].content).not.toContain('switch-agent-runtime');
});
it('gives two agents that share a name in different dirs distinct profiles', () => {
- const a = resolveSwitchLaunchProfile(codexPlugin, {
+ const a = resolveAgentLaunchProfile(codexPlugin, {
slug: 'codex-hoot',
workingDir: '/dir/one',
- hasSwitchIdentity: true,
+ specialization: SPECIALIZED,
})!;
- const b = resolveSwitchLaunchProfile(codexPlugin, {
+ const b = resolveAgentLaunchProfile(codexPlugin, {
slug: 'codex-hoot',
workingDir: '/dir/two',
- hasSwitchIdentity: true,
+ specialization: SPECIALIZED,
})!;
expect(a.args).not.toEqual(b.args);
expect(a.files[0].relativePath).not.toBe(b.files[0].relativePath);
});
it('folds per-agent specialization into the one profile file', () => {
- const profile = resolveSwitchLaunchProfile(codexPlugin, {
+ const profile = resolveAgentLaunchProfile(codexPlugin, {
slug: 'codex-hoot',
workingDir: WD,
- hasSwitchIdentity: true,
specialization: { model: 'gpt-5.6-terra', reasoningEffort: 'high', instructions: 'be terse' },
})!;
expect(profile.files).toHaveLength(1);
@@ -91,10 +101,9 @@ describe('resolveSwitchLaunchProfile', () => {
});
it('keeps the system prompt out of the argv the SSH and tmux paths re-quote', () => {
- const profile = resolveSwitchLaunchProfile(codexPlugin, {
+ const profile = resolveAgentLaunchProfile(codexPlugin, {
slug: 'codex-hoot',
workingDir: WD,
- hasSwitchIdentity: true,
specialization: { instructions: 'be terse\n$(whoami) "quoted"' },
})!;
@@ -103,85 +112,53 @@ describe('resolveSwitchLaunchProfile', () => {
expect(profile.args.join(' ')).not.toContain('whoami');
});
- it('tells Codex which variables to route into the server it spawns', () => {
- // Codex gives an MCP child a fixed allowlist and nothing else, so a profile
- // that names none of these produces a runtime with no credentials — which
- // surfaces only as a closed connection during the handshake.
- const profile = resolveSwitchLaunchProfile(codexPlugin, {
- slug: 'codex-hoot',
- workingDir: WD,
- hasSwitchIdentity: true,
- })!;
- const server = (
- parseTOML(profile.files[0].content) as {
- mcp_servers: Record<string, { env_vars?: string[] }>;
- }
- ).mcp_servers.switch;
-
- expect(server.env_vars).toEqual(switchAgentRuntimeCommand().envVars);
- });
-
- it('names the credentials without carrying them, so the profile is safe to bake and ship', () => {
- const profile = resolveSwitchLaunchProfile(codexPlugin, {
+ it('carries no credential, so the profile is safe to bake and ship to a VM', () => {
+ const profile = resolveAgentLaunchProfile(codexPlugin, {
slug: 'a',
workingDir: WD,
- hasSwitchIdentity: true,
+ specialization: SPECIALIZED,
})!;
- const server = (
- parseTOML(profile.files[0].content) as {
- mcp_servers: Record<string, { env?: unknown; bearer_token?: unknown; env_vars?: string[] }>;
- }
- ).mcp_servers.switch;
-
- expect(server.env).toBeUndefined();
- expect(server.bearer_token).toBeUndefined();
- for (const name of server.env_vars ?? []) {
- expect(name).toMatch(/^[A-Za-z_][A-Za-z0-9_]*$/);
- }
+
expect(profile.files[0].content).not.toMatch(/Bearer /);
+ expect(profile.files[0].content).not.toContain('SWITCH_API_TOKEN');
});
- it('returns null when the provider resolves MCP servers some other way', () => {
+ it('returns null when the provider takes its specialization another way', () => {
expect(
- resolveSwitchLaunchProfile(claudeLikePlugin, {
+ resolveAgentLaunchProfile(claudeLikePlugin, {
slug: 'x',
workingDir: WD,
- hasSwitchIdentity: true,
+ specialization: SPECIALIZED,
})
).toBeNull();
});
- it('returns null when the session has no Switch identity', () => {
- expect(
- resolveSwitchLaunchProfile(codexPlugin, {
- slug: 'x',
- workingDir: WD,
- hasSwitchIdentity: false,
- })
- ).toBeNull();
+ it('returns null when there is nothing to specialize', () => {
+ // Previously a profile was written for the MCP registration alone. With that
+ // gone, an agent on the defaults needs no file and no `--profile` argv.
+ expect(resolveAgentLaunchProfile(codexPlugin, { slug: 'x', workingDir: WD })).toBeNull();
});
});
-describe('prepareSwitchMcpLaunch', () => {
+describe('prepareAgentLaunchProfile', () => {
it('writes the profile under ~/.codex and returns the --profile argv', async () => {
const fs = memoryFs();
- const args = await prepareSwitchMcpLaunch(codexPlugin, {
+ const args = await prepareAgentLaunchProfile(codexPlugin, {
homeFs: fs,
slug: 'codex-hoot',
workingDir: WD,
- hasSwitchIdentity: true,
+ specialization: SPECIALIZED,
});
expect(args[1]).toMatch(PROFILE_STEM);
- expect(fs.files.get(`.codex/${args[1]}.config.toml`)).toContain('[mcp_servers.switch]');
+ expect(fs.files.get(`.codex/${args[1]}.config.toml`)).toContain('model = "gpt-5.6-terra"');
});
it('writes the system prompt into the profile and no companion file', async () => {
const fs = memoryFs();
- const args = await prepareSwitchMcpLaunch(codexPlugin, {
+ const args = await prepareAgentLaunchProfile(codexPlugin, {
homeFs: fs,
slug: 'codex-hoot',
workingDir: WD,
- hasSwitchIdentity: true,
specialization: { instructions: 'be terse' },
});
@@ -191,26 +168,25 @@ describe('prepareSwitchMcpLaunch', () => {
);
});
- it('writes nothing and returns [] when the session has no Switch identity', async () => {
+ it('writes nothing and returns [] for an agent that specializes nothing', async () => {
const fs = memoryFs();
- const args = await prepareSwitchMcpLaunch(codexPlugin, {
+ const args = await prepareAgentLaunchProfile(codexPlugin, {
homeFs: fs,
slug: 'x',
workingDir: WD,
- hasSwitchIdentity: false,
});
expect(args).toEqual([]);
expect(fs.files.size).toBe(0);
});
- it('emits nothing for a provider that resolves MCP servers itself', async () => {
+ it('emits nothing for a provider that needs no launch file', async () => {
const fs = memoryFs();
expect(
- await prepareSwitchMcpLaunch(claudeLikePlugin, {
+ await prepareAgentLaunchProfile(claudeLikePlugin, {
homeFs: fs,
slug: 'x',
workingDir: WD,
- hasSwitchIdentity: true,
+ specialization: SPECIALIZED,
})
).toEqual([]);
expect(fs.files.size).toBe(0);
diff --git a/dash/apps/switchdash-desktop/src/main/core/agent-runtime/switch-mcp-launch-args.ts b/dash/apps/switchdash-desktop/src/main/core/agent-runtime/agent-launch-profile.ts
similarity index 57%
rename from dash/apps/switchdash-desktop/src/main/core/agent-runtime/switch-mcp-launch-args.ts
rename to dash/apps/switchdash-desktop/src/main/core/agent-runtime/agent-launch-profile.ts
index 3a6f6182f..75e615776 100644
--- a/dash/apps/switchdash-desktop/src/main/core/agent-runtime/switch-mcp-launch-args.ts
+++ b/dash/apps/switchdash-desktop/src/main/core/agent-runtime/agent-launch-profile.ts
@@ -4,26 +4,26 @@ import type {
SwitchLaunchSpecialization,
} from '@switchdash/core/agents/plugins';
import type { getPlugin } from '@main/core/providers/plugin-registry';
-import { switchAgentRuntimeCommand } from '@shared/core/switch-rooms/switch-agent-runtime';
/**
- * The launch profile that registers the Switch MCP server for a session and
- * folds in any per-agent specialization (model / effort / instructions), or null
- * when the provider resolves the server another way (Claude's bundled `.mcp.json`)
- * and there is nothing to specialize.
+ * The launch profile carrying a session's per-agent specialization (model /
+ * effort / instructions), or null for a provider that takes those another way
+ * (Claude, on argv) and for an agent that specializes nothing.
+ *
+ * It does not register the Switch MCP server — the connector plugins ship that
+ * in their own bundled `.mcp.json`, so it is present for every session of that
+ * host rather than only the ones switchdash launches.
*
* Pure — no write — so the caller decides where the files land: a direct write
* for local/SSH sessions, or a baked launch spec the VM sidecar writes for remote
- * auto-sessions. The runtime it registers is static and secret-free: the profile
- * names the variables the provider must route into the server's process rather
- * than carrying their values, so the same profile is safe to bake and ship.
+ * auto-sessions. Nothing it produces is secret, so the same profile is safe to
+ * bake and ship.
*/
-export function resolveSwitchLaunchProfile(
+export function resolveAgentLaunchProfile(
plugin: ReturnType<typeof getPlugin>,
params: {
slug: string;
workingDir: string;
- hasSwitchIdentity: boolean;
specialization?: SwitchLaunchSpecialization;
}
): SwitchLaunchProfile | null {
@@ -33,31 +33,29 @@ export function resolveSwitchLaunchProfile(
return launchProfile({
slug: params.slug,
workingDir: params.workingDir,
- switchServer: params.hasSwitchIdentity ? switchAgentRuntimeCommand() : null,
...params.specialization,
});
}
/**
- * Register the Switch MCP server for a launching session by writing its launch
+ * Apply a launching session's per-agent specialization by writing its launch
* profile files into `homeFs` (rooted at the agent's home dir) and returning the
* argv that loads them. Returns `[]` when there is nothing to write.
*
* Used by the local and SSH runtimes, which write at launch. Remote auto-sessions
* instead bake the files into their launch spec (see {@link
- * resolveSwitchLaunchProfile}) and the sidecar writes them.
+ * resolveAgentLaunchProfile}) and the sidecar writes them.
*/
-export async function prepareSwitchMcpLaunch(
+export async function prepareAgentLaunchProfile(
plugin: ReturnType<typeof getPlugin>,
params: {
homeFs: PluginFs;
slug: string;
workingDir: string;
- hasSwitchIdentity: boolean;
specialization?: SwitchLaunchSpecialization;
}
): Promise<string[]> {
- const profile = resolveSwitchLaunchProfile(plugin, params);
+ const profile = resolveAgentLaunchProfile(plugin, params);
if (!profile) return [];
for (const file of profile.files) {
diff --git a/dash/apps/switchdash-desktop/src/main/core/agent-runtime/impl/local-agent-runtime.test.ts b/dash/apps/switchdash-desktop/src/main/core/agent-runtime/impl/local-agent-runtime.test.ts
index f1cddb9b6..bb2a44bcb 100644
--- a/dash/apps/switchdash-desktop/src/main/core/agent-runtime/impl/local-agent-runtime.test.ts
+++ b/dash/apps/switchdash-desktop/src/main/core/agent-runtime/impl/local-agent-runtime.test.ts
@@ -1,13 +1,14 @@
import { pluginRegistry } from '@switchdash/plugins/agents';
-import { parse as parseTOML } from 'smol-toml';
import { beforeEach, describe, expect, it, vi } from 'vitest';
import { AGENT_FRESH_RECOVERY_GRACE_MS } from '@main/core/agent-runtime/agent-runtime-supervisor';
+import { getAgentById } from '@main/core/agents/getAgentById';
import type { Pty, PtyExitInfo } from '@main/core/pty/pty';
import { ptySessionRegistry } from '@main/core/pty/pty-session-registry';
import { agentSessionExitedChannel } from '@shared/core/providers/agentEvents';
import { ptyExitChannel } from '@shared/core/pty/ptyEvents';
import { makeAgentPtySessionId } from '@shared/core/pty/ptySessionId';
import type { Session } from '@shared/core/sessions/sessions';
+import { SWITCH_RUNTIME_REQUIRED_ENV } from '@shared/core/switch-rooms/switch-agent-runtime';
import { LocalAgentRuntime } from './local-agent-runtime';
const spawnLocalPty = vi.hoisted(() => vi.fn());
@@ -303,6 +304,9 @@ describe('local agent runtime respawn state', () => {
it('writes the Codex profile to the home dir and loads it on argv', async () => {
const exitHandlers: Array<(info: PtyExitInfo) => void> = [];
spawnLocalPty.mockReturnValue(fakePty(exitHandlers));
+ vi.mocked(getAgentById).mockResolvedValueOnce({
+ providerConfig: { model: 'gpt-5.6-terra' },
+ } as unknown as Awaited<ReturnType<typeof getAgentById>>);
vi.mocked(readAgentSwitchEnvFromFs).mockResolvedValueOnce({
SWITCH_API_ENDPOINT: 'https://switch.example.com',
SWITCH_API_TOKEN: 'tok-123',
@@ -311,7 +315,10 @@ describe('local agent runtime respawn state', () => {
await localProvider().start(session());
- expect(writtenCodexProfile()).toContain('[mcp_servers.switch]');
+ expect(writtenCodexProfile()).toContain('model = "gpt-5.6-terra"');
+ // The Switch server comes from the connector plugin's own `.mcp.json`; the
+ // profile carries only what is per-agent.
+ expect(writtenCodexProfile()).not.toContain('mcp_servers');
// Profile name is digest-suffixed on (dir, slug) so same-named agents in
// different dirs don't collide.
expect(buildCommandMock).toHaveBeenLastCalledWith(
@@ -321,10 +328,25 @@ describe('local agent runtime respawn state', () => {
);
});
- it('puts every variable the profile forwards onto the session it spawns', async () => {
- // Codex forwards these by name out of its own environment, so a name the
- // profile lists but the session lacks reaches the runtime as nothing at
- // all — and a missing credential kills the handshake, not just one tool.
+ it('writes no profile at all for a Codex agent that specializes nothing', async () => {
+ // The profile used to exist for the MCP registration, so every Codex agent
+ // got one. Now an agent on the defaults has nothing to put in it, and an
+ // empty file would still add a `--profile` pointing at nothing.
+ const exitHandlers: Array<(info: PtyExitInfo) => void> = [];
+ spawnLocalPty.mockReturnValue(fakePty(exitHandlers));
+
+ await localProvider().start(session());
+
+ expect(() => writtenCodexProfile()).toThrow(/no Codex profile/);
+ expect(buildCommandMock).toHaveBeenLastCalledWith(expect.objectContaining({ agentArgs: [] }));
+ });
+
+ it('puts the runtime credentials onto the session it spawns', async () => {
+ // Codex forwards these by name out of its own environment into the MCP
+ // server, so a name the connector's `.mcp.json` lists but the session lacks
+ // reaches the runtime as nothing at all — and a missing credential kills the
+ // handshake, not just one tool. Asserted against the runtime's own contract
+ // rather than the profile, which no longer declares the server.
const exitHandlers: Array<(info: PtyExitInfo) => void> = [];
spawnLocalPty.mockReturnValue(fakePty(exitHandlers));
vi.mocked(readAgentSwitchEnvFromFs).mockResolvedValueOnce({
@@ -335,18 +357,11 @@ describe('local agent runtime respawn state', () => {
await localProvider().start(session());
- const server = (
- parseTOML(writtenCodexProfile()) as {
- mcp_servers: Record<string, { env_vars?: string[] }>;
- }
- ).mcp_servers.switch;
const spawned = (spawnLocalPty.mock.calls[0][0] as { env: Record<string, string> }).env;
- expect(server.env_vars?.length).toBeGreaterThan(0);
- for (const name of server.env_vars ?? []) {
- // SWITCH_CONNECTION_ID and the npm settings come from services stubbed
- // out here; the credentials are the ones this path is responsible for.
- if (!name.startsWith('SWITCH_API') && name !== 'SWITCH_AGENT_ID') continue;
+ // SWITCH_CONNECTION_ID and the npm settings come from services stubbed out
+ // here; the credentials are the ones this path is responsible for.
+ for (const name of SWITCH_RUNTIME_REQUIRED_ENV) {
expect(spawned).toHaveProperty(name);
}
});
diff --git a/dash/apps/switchdash-desktop/src/main/core/agent-runtime/impl/local-agent-runtime.ts b/dash/apps/switchdash-desktop/src/main/core/agent-runtime/impl/local-agent-runtime.ts
index f7efbbc15..64d8be896 100644
--- a/dash/apps/switchdash-desktop/src/main/core/agent-runtime/impl/local-agent-runtime.ts
+++ b/dash/apps/switchdash-desktop/src/main/core/agent-runtime/impl/local-agent-runtime.ts
@@ -2,9 +2,9 @@ import { homedir } from 'node:os';
import { agentHookService } from '@main/core/agent-hooks/agent-hook-service';
import { dirTrustService } from '@main/core/agent-hooks/dir-trust-service';
import { ensureHooksInstalled } from '@main/core/agent-hooks/hook-config-service';
+import { prepareAgentLaunchProfile } from '@main/core/agent-runtime/agent-launch-profile';
import { AgentRuntimeSupervisor } from '@main/core/agent-runtime/agent-runtime-supervisor';
import { resolveAgentSessionCommandArgs } from '@main/core/agent-runtime/resolve-agent-session-command';
-import { prepareSwitchMcpLaunch } from '@main/core/agent-runtime/switch-mcp-launch-args';
import type { AgentRuntimeProvider } from '@main/core/agent-runtime/types';
import { agentCredsSlug } from '@main/core/agents/agent-creds-slug';
import { getAgentById } from '@main/core/agents/getAgentById';
@@ -133,11 +133,19 @@ export class LocalAgentRuntime implements AgentRuntimeProvider {
if (!spawnToken) return;
try {
+ // The toggle lives on the agent, so read it from the agent: the value on
+ // the session is a copy taken at creation and never refreshed, which left
+ // an existing session launching without the flag no matter how often the
+ // user set it. It stays as the fallback for a session whose agent row is
+ // gone.
+ const agentRecord = await getAgentById(session.agentId);
+ const autoApprove = agentRecord?.autoApprove ?? session.autoApprove ?? false;
+
await dirTrustService.maybeAutoTrustLocal({
providerId: session.providerId,
cwd: this.sessionPath,
homedir: homedir(),
- force: session.autoApprove === true,
+ force: autoApprove,
});
await ensureHooksInstalled({
providerId: session.providerId,
@@ -174,17 +182,14 @@ export class LocalAgentRuntime implements AgentRuntimeProvider {
? await repoAgents.readLaunchEnv(workspaceFs, session.agentName)
: await readAgentSwitchEnvFromFs(workspaceFs, agentCredsSlug(session), log);
- // Register the Switch MCP server for providers that cannot resolve it from
- // a bundled config (Codex): writes a per-agent profile under `~/.codex` and
- // returns `--profile <slug>`, folding in the agent's per-agent model /
- // effort / instructions. A no-op for Claude, whose plugin expands its own
- // `.mcp.json`.
- const agentRecord = await getAgentById(session.agentId);
- const switchMcpArgs = await prepareSwitchMcpLaunch(plugin, {
+ // Apply the provider's per-agent specialization: for Codex, a profile
+ // under `~/.codex` carrying model / effort / instructions, loaded with
+ // `--profile <slug>`. The Switch MCP server is not written here — the
+ // connector plugin registers it from its own bundled `.mcp.json`.
+ const launchProfileArgs = await prepareAgentLaunchProfile(plugin, {
homeFs: createPluginFs(homedir()),
slug: agentCredsSlug(session),
workingDir: this.sessionPath,
- hasSwitchIdentity: !!identityVars.SWITCH_API_ENDPOINT,
specialization: toSwitchSpecialization(agentRecord?.providerConfig),
});
@@ -192,15 +197,14 @@ export class LocalAgentRuntime implements AgentRuntimeProvider {
cli: executableCli,
extraArgs: parseExtraArgs(providerConfig?.extraArgs),
// The provider owns how to run as the named agent (CHOO-1440), and how to
- // receive a per-session Switch MCP server when it cannot read one from a
- // config file.
+ // load its per-agent specialization when that needs a config file.
agentArgs: [
...(session.agentName && repoAgents
? repoAgents.launchArgs(this.sessionPath, session.agentName)
: []),
- ...switchMcpArgs,
+ ...launchProfileArgs,
],
- autoApprove: session.autoApprove ?? false,
+ autoApprove,
initialPrompt: agentSession.isResuming ? undefined : initialPrompt,
sessionId: agentSession.sessionId,
providerSessionId: session.providerSessionId ?? undefined,
diff --git a/dash/apps/switchdash-desktop/src/main/core/agent-runtime/impl/ssh-agent-runtime.test.ts b/dash/apps/switchdash-desktop/src/main/core/agent-runtime/impl/ssh-agent-runtime.test.ts
index 4b97c72a0..72f0d084d 100644
--- a/dash/apps/switchdash-desktop/src/main/core/agent-runtime/impl/ssh-agent-runtime.test.ts
+++ b/dash/apps/switchdash-desktop/src/main/core/agent-runtime/impl/ssh-agent-runtime.test.ts
@@ -1,5 +1,4 @@
import { pluginRegistry } from '@switchdash/plugins/agents';
-import { parse as parseTOML } from 'smol-toml';
import { beforeEach, describe, expect, it, vi } from 'vitest';
import { FileSystemError, FileSystemErrorCodes } from '@main/core/fs/types';
import type { Pty, PtyExitInfo } from '@main/core/pty/pty';
@@ -8,6 +7,7 @@ import type { SshClientProxy } from '@main/core/ssh/lifecycle/ssh-client-proxy';
import { agentSessionExitedChannel } from '@shared/core/providers/agentEvents';
import { makeAgentPtySessionId } from '@shared/core/pty/ptySessionId';
import type { Session } from '@shared/core/sessions/sessions';
+import { SWITCH_RUNTIME_REQUIRED_ENV } from '@shared/core/switch-rooms/switch-agent-runtime';
import { SidecarHttpStatusError } from './sidecar-http';
import { SshAgentRuntime } from './ssh-agent-runtime';
@@ -311,10 +311,11 @@ describe('SshAgentRuntime', () => {
);
});
- it('registers the Switch MCP server via a profile written to the VM home', async () => {
- // The endpoint and token reach the session as env vars, but Codex only learns
- // the server exists from a profile loaded with `--profile`. Without this a
- // remote Codex session comes up authenticated and with no `switch` tools.
+ it('writes the per-agent Codex profile to the VM home and loads it on argv', async () => {
+ // The profile carries model / effort / instructions. The Switch server is no
+ // longer among them — the connector plugin registers it — but the
+ // credentials it names must still reach the remote session, or the runtime
+ // starts blind and never answers the handshake.
const ctx = makeCtx();
vi.mocked(getPlugin).mockImplementation(
(id: string) =>
@@ -332,6 +333,7 @@ describe('SshAgentRuntime', () => {
vi.mocked(getAgentById).mockResolvedValueOnce({
autoApprove: false,
name: 'codex-hoot',
+ providerConfig: { model: 'gpt-5.6-terra' },
} as never);
mockSpawn([]);
@@ -364,8 +366,6 @@ describe('SshAgentRuntime', () => {
])
);
- // Every credential the profile tells Codex to forward must be on the remote
- // session, or the runtime starts blind and never answers the handshake.
const written = (vi.mocked(ctx.exec).mock.calls as unknown[][])
.flatMap((call) => (call[1] as string[]) ?? [])
.map((arg) => {
@@ -375,17 +375,16 @@ describe('SshAgentRuntime', () => {
return '';
}
})
- .find((decoded) => decoded.includes('[mcp_servers.switch]'));
- const server = (parseTOML(written!) as { mcp_servers: Record<string, { env_vars?: string[] }> })
- .mcp_servers.switch;
- const env = (resolveSshCommand.mock.calls[0] as unknown[])[2] as Record<string, string>;
+ .find((decoded) => decoded.includes('model = "gpt-5.6-terra"'));
+ expect(written).toBeDefined();
+ // The connector plugin declares the server on the VM as it does locally.
+ expect(written).not.toContain('mcp_servers');
- expect(server.env_vars?.length).toBeGreaterThan(0);
- for (const name of server.env_vars ?? []) {
- // Only the identity tier here: this session runs without tmux, so it has
- // no sidecar and therefore no connection id or registry config. The tmux
- // path below covers the rest of what the profile forwards.
- if (!name.startsWith('SWITCH_API') && name !== 'SWITCH_AGENT_ID') continue;
+ // Every credential the runtime needs must be on the remote session. Only the
+ // identity tier here: this session runs without tmux, so it has no sidecar
+ // and therefore no connection id or registry config.
+ const env = (resolveSshCommand.mock.calls[0] as unknown[])[2] as Record<string, string>;
+ for (const name of SWITCH_RUNTIME_REQUIRED_ENV) {
expect(env).toHaveProperty(name);
}
});
@@ -422,7 +421,13 @@ describe('SshAgentRuntime', () => {
const config = JSON.parse(Buffer.from(written!.at(-1)!, 'base64').toString('utf8')) as {
hooks: Record<string, unknown[]>;
};
- expect(Object.keys(config.hooks).sort()).toEqual(['PermissionRequest', 'SessionStart', 'Stop']);
+ expect(Object.keys(config.hooks).sort()).toEqual([
+ 'PermissionRequest',
+ 'PostToolUse',
+ 'PreToolUse',
+ 'SessionStart',
+ 'Stop',
+ ]);
});
// Neither root fits a scope nobody has taught the remote path about, and the
diff --git a/dash/apps/switchdash-desktop/src/main/core/agent-runtime/impl/ssh-agent-runtime.ts b/dash/apps/switchdash-desktop/src/main/core/agent-runtime/impl/ssh-agent-runtime.ts
index d9b06ad9f..de9a97f12 100644
--- a/dash/apps/switchdash-desktop/src/main/core/agent-runtime/impl/ssh-agent-runtime.ts
+++ b/dash/apps/switchdash-desktop/src/main/core/agent-runtime/impl/ssh-agent-runtime.ts
@@ -1,9 +1,9 @@
import type { PluginFs, SwitchLaunchSpecialization } from '@switchdash/core/agents/plugins';
import { DEEPLINK_SCHEME } from '@main/app/deeplinks';
import { agentHookService } from '@main/core/agent-hooks/agent-hook-service';
+import { resolveAgentLaunchProfile } from '@main/core/agent-runtime/agent-launch-profile';
import { AgentRuntimeSupervisor } from '@main/core/agent-runtime/agent-runtime-supervisor';
import { resolveAgentSessionCommandArgs } from '@main/core/agent-runtime/resolve-agent-session-command';
-import { resolveSwitchLaunchProfile } from '@main/core/agent-runtime/switch-mcp-launch-args';
import type { AgentRuntimeProvider } from '@main/core/agent-runtime/types';
import { agentCredsSlug } from '@main/core/agents/agent-creds-slug';
import { getAgentById } from '@main/core/agents/getAgentById';
@@ -236,20 +236,18 @@ export class SshAgentRuntime implements AgentRuntimeProvider {
}
/**
- * Register the Switch MCP server for a provider that writes per-agent launch
- * files under the VM's home (Codex: a profile). Returns the argv that loads
- * the profile, or `[]` when there is nothing to write.
+ * Write the per-agent launch files of a provider that needs them under the
+ * VM's home (Codex: a profile carrying model / effort / instructions).
+ * Returns the argv that loads them, or `[]` when there is nothing to write.
*/
- private async registerRemoteSwitchMcp(
+ private async writeRemoteLaunchProfile(
plugin: ReturnType<typeof getPlugin>,
slug: string,
- hasSwitchIdentity: boolean,
specialization: SwitchLaunchSpecialization | undefined
): Promise<string[]> {
- const profile = resolveSwitchLaunchProfile(plugin, {
+ const profile = resolveAgentLaunchProfile(plugin, {
slug,
workingDir: this.sessionPath,
- hasSwitchIdentity,
specialization,
});
if (!profile) return [];
@@ -557,13 +555,17 @@ export class SshAgentRuntime implements AgentRuntimeProvider {
? await repoAgents.readLaunchEnv(remoteFs, session.agentName)
: await readAgentSwitchEnvFromFs(remoteFs, agentCredsSlug(session), log);
- // Register the Switch MCP server (Codex writes a profile under the VM's
- // ~/.codex), folding in the agent's per-agent model / effort / instructions.
const agentRecord = await getAgentById(session.agentId);
- const switchMcpArgs = await this.registerRemoteSwitchMcp(
+ // Read from the agent, not the session: the session's copy is frozen at
+ // creation, so an existing session never picked up the toggle. See the
+ // matching comment in local-agent-runtime.
+ const autoApprove = agentRecord?.autoApprove ?? session.autoApprove ?? false;
+ // Codex writes a profile under the VM's ~/.codex for model / effort /
+ // instructions. The Switch MCP server comes from the connector plugin's
+ // own `.mcp.json`, on the VM as locally.
+ const launchProfileArgs = await this.writeRemoteLaunchProfile(
plugin,
agentCredsSlug(session),
- !!identityVars.SWITCH_API_ENDPOINT,
toSwitchSpecialization(agentRecord?.providerConfig)
);
@@ -573,15 +575,15 @@ export class SshAgentRuntime implements AgentRuntimeProvider {
// A remote agent runs as its own definition: the provider produces the
// run-as-name args (Claude → `--agent <name> --settings <neutral creds>`),
// resolved on the VM (sessionPath is remote). Distinct from user extra
- // args (CHOO-1440). The provider also owns how it receives a per-session
- // Switch MCP server when it cannot read one from a config file.
+ // args (CHOO-1440). The provider also owns how it loads its per-agent
+ // specialization when that needs a config file.
agentArgs: [
...(session.agentName && repoAgents
? repoAgents.launchArgs(this.sessionPath, session.agentName)
: []),
- ...switchMcpArgs,
+ ...launchProfileArgs,
],
- autoApprove: session.autoApprove ?? false,
+ autoApprove,
initialPrompt: agentSession.isResuming ? undefined : initialPrompt,
sessionId: agentSession.sessionId,
providerSessionId: session.providerSessionId ?? undefined,
@@ -602,7 +604,7 @@ export class SshAgentRuntime implements AgentRuntimeProvider {
cwd: this.sessionPath,
shellSetup: this.shellSetup,
tmuxSessionName,
- autoApprove: session.autoApprove ?? false,
+ autoApprove,
resume: agentSession.isResuming,
};
diff --git a/dash/apps/switchdash-desktop/src/main/core/agents/generate-agent-launch-spec.test.ts b/dash/apps/switchdash-desktop/src/main/core/agents/generate-agent-launch-spec.test.ts
index 2137b6a1c..e5550ad6e 100644
--- a/dash/apps/switchdash-desktop/src/main/core/agents/generate-agent-launch-spec.test.ts
+++ b/dash/apps/switchdash-desktop/src/main/core/agents/generate-agent-launch-spec.test.ts
@@ -1,7 +1,6 @@
import { pluginRegistry } from '@switchdash/plugins/agents';
import { parse as parseTOML } from 'smol-toml';
import { beforeEach, describe, expect, it, vi } from 'vitest';
-import { switchAgentRuntimeCommand } from '@shared/core/switch-rooms/switch-agent-runtime';
const buildCommand = vi.fn(() => ({ command: 'claude', args: ['--x'], env: { E: '1' } }));
const launchArgs = vi.fn((dir: string, name: string) => [
@@ -11,15 +10,15 @@ const launchArgs = vi.fn((dir: string, name: string) => [
`${dir}/.switch/agents/${name}.json`,
]);
-const launchProfile = vi.fn((params: { slug: string; switchServer: unknown | null }) =>
- params.switchServer
+const launchProfile = vi.fn((params: { slug: string; model?: string; instructions?: string }) =>
+ params.model || params.instructions
? {
files: [{ relativePath: `.codex/${params.slug}.config.toml`, content: 'PROFILE' }],
args: ['--profile', params.slug],
}
: null
);
-/** Set per test: whether the mocked provider registers the Switch server itself. */
+/** Set per test: whether the mocked provider takes specialization from a file. */
let mcpBehavior: { launchProfile?: typeof launchProfile } | undefined;
vi.mock('@main/core/providers/plugin-registry', () => ({
@@ -95,13 +94,17 @@ describe('generateAgentLaunchSpec', () => {
expect(buildCommand).toHaveBeenCalledWith(expect.objectContaining({ agentArgs: [] }));
});
- it('bakes the profile args and launch file for a provider that registers the server itself', async () => {
- // The endpoint and credentials reach the runtime through the env, so the spec
- // carries the profile file the sidecar writes on the VM plus `--profile <slug>`
- // to load it — no argv endpoint token any more.
+ it('bakes the profile args and launch file for a provider that specializes from a file', async () => {
+ // The endpoint and credentials reach the runtime through the env, and the
+ // Switch server through the connector plugin, so the spec carries only the
+ // per-agent profile the sidecar writes on the VM plus `--profile <slug>`.
mcpBehavior = { launchProfile };
- const spec = await generateAgentLaunchSpec({ ...baseParams, autoApprove: false });
+ const spec = await generateAgentLaunchSpec({
+ ...baseParams,
+ autoApprove: false,
+ specialization: { model: 'gpt-5.6-terra' },
+ });
expect(launchProfile).toHaveBeenCalledWith(expect.objectContaining({ slug: 'hoot' }));
expect(buildCommand).toHaveBeenCalledWith(
@@ -112,19 +115,23 @@ describe('generateAgentLaunchSpec', () => {
]);
});
- it('bakes a profile that names the credentials and carries none of them', async () => {
+ it('bakes a profile that carries no credential and registers no server', async () => {
// The sidecar writes this file verbatim on the VM, so whatever is baked here
// is what a remote session runs with — and a value baked in would be a secret
- // shipped to the box and re-read on every poll.
+ // shipped to the box and re-read on every poll. The Switch server is not
+ // baked either: the connector plugin declares it on the VM as it does locally.
mcpBehavior = (pluginRegistry.get('codex')!.behavior as { mcp?: typeof mcpBehavior }).mcp;
- const spec = await generateAgentLaunchSpec({ ...baseParams, autoApprove: false });
+ const spec = await generateAgentLaunchSpec({
+ ...baseParams,
+ autoApprove: false,
+ specialization: { model: 'gpt-5.6-terra' },
+ });
const content = spec.launchFiles![0].content;
- const server = (parseTOML(content) as { mcp_servers: Record<string, { env_vars?: string[] }> })
- .mcp_servers.switch;
- expect(server.env_vars).toEqual(switchAgentRuntimeCommand().envVars);
+ expect(content).toContain('model = "gpt-5.6-terra"');
+ expect(content).not.toContain('mcp_servers');
expect(content).not.toMatch(/Bearer |tok-/);
});
diff --git a/dash/apps/switchdash-desktop/src/main/core/agents/generate-agent-launch-spec.ts b/dash/apps/switchdash-desktop/src/main/core/agents/generate-agent-launch-spec.ts
index 2b41ea2b1..1c50ade4a 100644
--- a/dash/apps/switchdash-desktop/src/main/core/agents/generate-agent-launch-spec.ts
+++ b/dash/apps/switchdash-desktop/src/main/core/agents/generate-agent-launch-spec.ts
@@ -1,6 +1,6 @@
import type { SwitchLaunchSpecialization } from '@switchdash/core/agents/plugins';
+import { resolveAgentLaunchProfile } from '@main/core/agent-runtime/agent-launch-profile';
import { resolveAgentExecutable } from '@main/core/agent-runtime/impl/resolve-agent-executable';
-import { resolveSwitchLaunchProfile } from '@main/core/agent-runtime/switch-mcp-launch-args';
import { hostDependencyStore } from '@main/core/dependencies/host-dependency-store';
import type { IExecutionContext } from '@main/core/execution-context/types';
import { getPlugin } from '@main/core/providers/plugin-registry';
@@ -75,15 +75,13 @@ export async function generateAgentLaunchSpec(params: {
connectionId,
});
- // Auto-started sessions always run as the agent, so they have a Switch
- // identity. A provider that registers the server itself (Codex) returns the
- // profile file to bake into the spec and the `--profile <slug>` argv; the
- // sidecar writes the file on the VM. Null for providers whose plugin resolves
- // the server from a bundled config (Claude).
- const switchProfile = resolveSwitchLaunchProfile(plugin, {
+ // A provider that takes its per-agent specialization from a file (Codex)
+ // returns the profile to bake into the spec and the `--profile <slug>` argv;
+ // the sidecar writes the file on the VM. Null for a provider that takes it on
+ // argv (Claude), and for an agent that specializes nothing.
+ const switchProfile = resolveAgentLaunchProfile(plugin, {
slug: credsSlug,
workingDir: remoteRepoDir,
- hasSwitchIdentity: true,
specialization,
});
diff --git a/dash/apps/switchdash-desktop/src/shared/core/switch-rooms/switch-agent-runtime.test.ts b/dash/apps/switchdash-desktop/src/shared/core/switch-rooms/switch-agent-runtime.test.ts
index 9fbd41d13..16181a086 100644
--- a/dash/apps/switchdash-desktop/src/shared/core/switch-rooms/switch-agent-runtime.test.ts
+++ b/dash/apps/switchdash-desktop/src/shared/core/switch-rooms/switch-agent-runtime.test.ts
@@ -9,32 +9,42 @@ import {
SWITCH_RUNTIME_ENV_VARS,
SWITCH_RUNTIME_OPTIONAL_ENV,
SWITCH_RUNTIME_REQUIRED_ENV,
- switchAgentRuntimeCommand,
} from './switch-agent-runtime';
-const MCP_JSON_RELATIVE = 'connectors/claude-code-plugin/.mcp.json';
+const CLAUDE_MCP_JSON = 'connectors/claude-code-plugin/.mcp.json';
+const CODEX_MCP_JSON = 'connectors/codex-plugin/.mcp.json';
-/** Walk up from this file until the connector plugin's .mcp.json is found. */
-function findClaudeMcpJson(): string {
+type SwitchServerEntry = {
+ args?: string[];
+ env?: Record<string, string>;
+ env_vars?: string[];
+ default_tools_approval_mode?: string;
+};
+
+/** Walk up from this file until the given repo-relative path is found. */
+function findRepoFile(relative: string): string {
let dir = dirname(fileURLToPath(import.meta.url));
for (let i = 0; i < 12; i++) {
- const candidate = join(dir, MCP_JSON_RELATIVE);
+ const candidate = join(dir, relative);
if (existsSync(candidate)) return candidate;
const parent = dirname(dir);
if (parent === dir) break;
dir = parent;
}
- throw new Error(`could not locate ${MCP_JSON_RELATIVE} above ${fileURLToPath(import.meta.url)}`);
+ throw new Error(`could not locate ${relative} above ${fileURLToPath(import.meta.url)}`);
}
-/** The `switch` server entry from the Claude connector's bundled .mcp.json. */
-function claudeSwitchServer(): { args?: string[]; env?: Record<string, string> } {
- const mcp = JSON.parse(readFileSync(findClaudeMcpJson(), 'utf8')) as {
- mcpServers: Record<string, { args?: string[]; env?: Record<string, string> }>;
+/** The `switch` server entry from a connector plugin's bundled .mcp.json. */
+function switchServerIn(relative: string): SwitchServerEntry {
+ const mcp = JSON.parse(readFileSync(findRepoFile(relative), 'utf8')) as {
+ mcpServers: Record<string, SwitchServerEntry>;
};
return mcp.mcpServers.switch ?? {};
}
+const claudeSwitchServer = (): SwitchServerEntry => switchServerIn(CLAUDE_MCP_JSON);
+const codexSwitchServer = (): SwitchServerEntry => switchServerIn(CODEX_MCP_JSON);
+
/** The runtime package's own version, the third pin nothing else checks. */
function runtimePackageVersion(): string {
let dir = dirname(fileURLToPath(import.meta.url));
@@ -50,26 +60,23 @@ function runtimePackageVersion(): string {
throw new Error('could not locate packages/switch-agent-runtime/package.json');
}
-describe('switchAgentRuntimeCommand', () => {
- it('resolves npx against the pinned package version', () => {
- const { command, args } = switchAgentRuntimeCommand();
- expect(command).toBe('npx');
- expect(args).toEqual(['-y', `${SWITCH_AGENT_RUNTIME_PACKAGE}@${SWITCH_AGENT_RUNTIME_VERSION}`]);
- });
-
+describe('the pinned runtime version', () => {
it('forwards what npx itself needs to reach the private registry', () => {
// Without these the child cannot fetch the package at all on a cold cache,
// and the failure reads as a 404 for something that does not exist.
- expect(switchAgentRuntimeCommand().envVars).toEqual(
+ expect(SWITCH_RUNTIME_ENV_VARS).toEqual(
expect.arrayContaining(['npm_config_userconfig', NPM_TOKEN_VAR])
);
});
- it('stays pinned to the same runtime version the Claude connector .mcp.json registers', () => {
- // Codex registers this runtime via a profile and Claude via its bundled
- // .mcp.json. Both must run the same published version; this guards the two
- // pins from drifting when only one is bumped.
- const args = claudeSwitchServer().args ?? [];
+ it.each([
+ ['Claude', CLAUDE_MCP_JSON],
+ ['Codex', CODEX_MCP_JSON],
+ ])('is the version the %s connector .mcp.json registers', (_host, relative) => {
+ // Both connectors register this runtime from their own bundled .mcp.json,
+ // and both must run the same published version; this guards the pins from
+ // drifting when only one is bumped.
+ const args = switchServerIn(relative).args ?? [];
expect(args).toContain(`${SWITCH_AGENT_RUNTIME_PACKAGE}@${SWITCH_AGENT_RUNTIME_VERSION}`);
});
@@ -116,7 +123,40 @@ describe('the credentials the runtime needs', () => {
}
});
- it('are all routed by the Codex launch command', () => {
- expect(switchAgentRuntimeCommand().envVars).toEqual([...SWITCH_RUNTIME_ENV_VARS]);
+ it('are all named by the Codex connector, which forwards by name', () => {
+ // Codex passes an MCP child a fixed allowlist and nothing else, so a name
+ // missing here reaches the runtime as nothing at all — and a missing
+ // credential kills the handshake rather than one tool. Safe to list the
+ // optional tier too: an unset name is simply not forwarded.
+ expect(codexSwitchServer().env_vars).toEqual([...SWITCH_RUNTIME_ENV_VARS]);
+ });
+
+ it('are named by the Codex connector without any value channel', () => {
+ const server = codexSwitchServer();
+ expect(server.env).toBeUndefined();
+ for (const name of server.env_vars ?? []) {
+ expect(name).toMatch(/^[A-Za-z_][A-Za-z0-9_]*$/);
+ }
+ });
+});
+
+describe('the Codex connector tool approval', () => {
+ it('auto-approves the Switch tools, which no approval_policy would have done', () => {
+ // An agent answering a room is unattended: a prompt on `post_message` stops
+ // the turn with nobody to release it. Measured against codex-cli 0.146.0,
+ // `approval_policy` does not govern MCP tool calls at all — a write-annotated
+ // tool is denied under `never` just as under `untrusted` — so the bypass
+ // toggle cannot cover this and only this field can.
+ expect(codexSwitchServer().default_tools_approval_mode).toBe('approve');
+ });
+
+ it('stays inside the enum Codex accepts, which it does not police', () => {
+ // An unrecognised value does not fail loudly: Codex drops the whole server
+ // and reports no MCP servers at all, so the session simply has no Switch
+ // tools. `approve` is also the only one of the four that admits a tool
+ // annotated as writing, which most Switch tools are.
+ expect(['auto', 'prompt', 'writes', 'approve']).toContain(
+ codexSwitchServer().default_tools_approval_mode
+ );
});
});
diff --git a/dash/apps/switchdash-desktop/src/shared/core/switch-rooms/switch-agent-runtime.ts b/dash/apps/switchdash-desktop/src/shared/core/switch-rooms/switch-agent-runtime.ts
index 90788c6a0..08664e298 100644
--- a/dash/apps/switchdash-desktop/src/shared/core/switch-rooms/switch-agent-runtime.ts
+++ b/dash/apps/switchdash-desktop/src/shared/core/switch-rooms/switch-agent-runtime.ts
@@ -1,9 +1,9 @@
/**
* The published Switch agent-runtime package that serves the Switch MCP tools
* over local stdio (transport to switch-core is HTTP+SSE, held inside the
- * runtime). The Claude Code connector plugin registers it from its bundled
- * `.mcp.json`; providers whose plugin cannot expand variables in a bundled
- * config — Codex — have switchdash register the same package itself at launch.
+ * runtime). Both connector plugins register it from a bundled `.mcp.json`: the
+ * Claude Code one expands `${VAR}`, the Codex one forwards the same names via
+ * `env_vars`. switchdash routes the values into the session's environment.
*
* Lives in `shared` so both halves of the remote path can reach it: the main
* process bakes the launch recipe, and the on-VM sidecar (bundled free of
@@ -42,10 +42,12 @@ export const SWITCH_RUNTIME_REQUIRED_ENV = [
* `npx` needs to resolve the package from the private registry.
*
* Kept apart from the required tier because the two hosts cannot treat them
- * alike. Codex forwards names, so an unset one is simply not passed. Claude
+ * alike. Codex forwards names, so an unset one is simply not passed, and the
+ * Codex connector's `.mcp.json` lists this tier under `env_vars`. Claude
* expands `${VAR}`, which makes a declared variable mandatory — declaring
* `SWITCH_CONNECTION_ID` there once cost every standalone session its tools.
- * These must therefore never be added to the connector's `.mcp.json`.
+ * This tier must therefore never be added to the *Claude* connector's
+ * `.mcp.json`.
*/
export const SWITCH_RUNTIME_OPTIONAL_ENV = [
'SWITCH_CONNECTION_ID',
@@ -60,29 +62,12 @@ export const SWITCH_RUNTIME_ENV_VARS: readonly string[] = [
...SWITCH_RUNTIME_OPTIONAL_ENV,
];
-/** stdio command that launches the runtime with `npx`, resolving the pinned version. */
-export type SwitchAgentRuntimeCommand = {
- command: string;
- args: string[];
- /** Names the host must route into the server's process. See {@link SWITCH_RUNTIME_ENV_VARS}. */
- envVars: string[];
-};
-
/**
- * The stdio command that runs the pinned Switch MCP runtime, and the names of
- * the variables it needs.
- *
- * A host does not hand its own environment to an MCP server it spawns. Codex
- * gives the child a fixed allowlist — `HOME`, `PATH`, `SHELL`, `USER`, `TMPDIR`
- * and a few more — and forwards nothing else unless the server's config names
- * it; Claude Code declares its own `env` block. So the command stays static and
- * secret-free, while `envVars` says what has to travel with it: without them
- * `npx` cannot reach the private registry and the runtime cannot authenticate.
+ * The stdio command that runs the pinned runtime is no longer built here: both
+ * connector plugins declare it in their own bundled `.mcp.json`. What switchdash
+ * still owns is putting the values behind {@link SWITCH_RUNTIME_ENV_VARS} into
+ * the session's environment — a host does not hand an MCP server a copy of its
+ * own environment, so Codex forwards only the names its config lists and Claude
+ * only what its `env` block expands. `switch-agent-runtime.test.ts` holds both
+ * plugin files to the constants above so a rename cannot land on one side only.
*/
-export function switchAgentRuntimeCommand(): SwitchAgentRuntimeCommand {
- return {
- command: 'npx',
- args: ['-y', `${SWITCH_AGENT_RUNTIME_PACKAGE}@${SWITCH_AGENT_RUNTIME_VERSION}`],
- envVars: [...SWITCH_RUNTIME_ENV_VARS],
- };
-}
diff --git a/dash/apps/switchdash-desktop/src/sidecar/session-spawner.test.ts b/dash/apps/switchdash-desktop/src/sidecar/session-spawner.test.ts
index c83116fa3..c8cbbadd3 100644
--- a/dash/apps/switchdash-desktop/src/sidecar/session-spawner.test.ts
+++ b/dash/apps/switchdash-desktop/src/sidecar/session-spawner.test.ts
@@ -137,7 +137,13 @@ describe('InProcessSessionSpawner.launch', () => {
const config = JSON.parse(await readFile(join(HOME, '.codex/hooks.json'), 'utf8')) as {
hooks: Record<string, unknown[]>;
};
- expect(Object.keys(config.hooks).sort()).toEqual(['PermissionRequest', 'SessionStart', 'Stop']);
+ expect(Object.keys(config.hooks).sort()).toEqual([
+ 'PermissionRequest',
+ 'PostToolUse',
+ 'PreToolUse',
+ 'SessionStart',
+ 'Stop',
+ ]);
expect(calls.find((c) => c.args[0] === 'new-session')).toBeDefined();
});
diff --git a/dash/packages/core/src/agents/plugins/capabilities/mcp.ts b/dash/packages/core/src/agents/plugins/capabilities/mcp.ts
index 9d628c873..47ddfbc82 100644
--- a/dash/packages/core/src/agents/plugins/capabilities/mcp.ts
+++ b/dash/packages/core/src/agents/plugins/capabilities/mcp.ts
@@ -4,28 +4,6 @@ import type { PluginFs } from '../../runtime/fs';
export type McpTransport = 'stdio' | 'http';
-/**
- * The Switch MCP runtime as a stdio command, handed to {@link
- * IMcpBehavior.launchProfile}.
- *
- * Static and secret-free — but not self-sufficient. An agent host spawns an MCP
- * server with an environment of its own choosing, not a copy of its own: Codex
- * passes a fixed allowlist (`HOME`, `PATH`, `SHELL`, `USER`, `TMPDIR`, …) and
- * drops everything else. `envVars` names what the host must route through for
- * the runtime to authenticate and to resolve its package, carrying names only
- * so no credential is written anywhere.
- */
-export type SwitchMcpLaunchServer = {
- command: string;
- args: string[];
- /**
- * Environment variable names the host must forward from its own environment.
- * Required rather than optional: a launch server that omits them produces a
- * session whose Switch tools silently never start.
- */
- envVars: string[];
-};
-
/** A single per-agent launch config file, path relative to the agent's home. */
export type SwitchLaunchProfileFile = {
relativePath: string;
@@ -63,23 +41,22 @@ export type IMcpBehavior = {
writeServers(fs: PluginFs, servers: McpServerRegistration[]): Promise<void>;
removeServer(fs: PluginFs, name: string): Promise<void>;
/**
- * Compute the launch config that registers the Switch MCP server for a
- * session (and folds in any per-agent specialization), for agents whose
- * connector plugin cannot resolve a per-session server from a bundled config.
- * Pure: it returns the files to write and the argv to load them, leaving the
- * write to the caller so the same result serves a direct write (local/SSH) and
- * a baked launch spec the sidecar writes.
+ * Compute the launch config that applies a session's per-agent specialization
+ * — model, reasoning effort, instructions — for a provider that can only take
+ * them from a config file. Pure: it returns the files to write and the argv to
+ * load them, leaving the write to the caller so the same result serves a
+ * direct write (local/SSH) and a baked launch spec the sidecar writes.
+ *
+ * This does NOT register the Switch MCP server. Both connector plugins ship
+ * that in their own bundled `.mcp.json`, so it is already present for every
+ * session of that host, switchdash-launched or not.
*
- * Claude Code leaves this undefined: its plugin expands environment variables
- * in a bundled `.mcp.json`, so the config is already per-session. Codex
- * performs no such expansion and a stdio server cannot ride argv across the
- * `resume` subcommand cleanly, so it returns a per-agent profile
- * (`~/.codex/<name>.config.toml`) and `--profile <name>`. That profile must
- * also name the environment it needs;
- * see {@link SwitchMcpLaunchServer.envVars}.
+ * Claude Code leaves this undefined: it takes its specialization on argv.
+ * Codex returns a per-agent profile (`~/.codex/<name>.config.toml`) and
+ * `--profile <name>`, because free-form instructions cannot ride a command
+ * line that the SSH and tmux paths re-render as a shell string.
*
- * Returns `null` when there is nothing to write (no Switch identity and no
- * specialization).
+ * Returns `null` when there is nothing to specialize.
*/
launchProfile?(
params: {
@@ -87,7 +64,6 @@ export type IMcpBehavior = {
/** The agent's working directory, mixed into the profile name so two agents
* that share a name in different directories get distinct profiles. */
workingDir: string;
- switchServer: SwitchMcpLaunchServer | null;
} & SwitchLaunchSpecialization
): SwitchLaunchProfile | null;
/**
diff --git a/dash/packages/core/src/agents/plugins/helpers/index.ts b/dash/packages/core/src/agents/plugins/helpers/index.ts
index ff48d0e5c..8a6d62495 100644
--- a/dash/packages/core/src/agents/plugins/helpers/index.ts
+++ b/dash/packages/core/src/agents/plugins/helpers/index.ts
@@ -9,3 +9,4 @@ export * from './mcp';
export * from './merge';
export * from './parse-hook-event';
export * from './standard-command';
+export * from './tool-activity';
diff --git a/dash/packages/core/src/agents/plugins/helpers/tool-activity.ts b/dash/packages/core/src/agents/plugins/helpers/tool-activity.ts
new file mode 100644
index 000000000..739faf4c3
--- /dev/null
+++ b/dash/packages/core/src/agents/plugins/helpers/tool-activity.ts
@@ -0,0 +1,67 @@
+/**
+ * Shared pieces for turning a tool hook body into a runtime-activity line.
+ *
+ * The wire format is Claude Code's hook payload — `tool_name` plus a
+ * `tool_input` object — which Codex also emits, so the parts that only read
+ * those two fields live here rather than in either provider. What a tool acts
+ * *on* does not generalise: the tool names differ per provider and so do the
+ * `tool_input` keys, so each provider supplies its own object extractor and
+ * composes it with {@link formatToolActivityLine}.
+ */
+
+/** The base name of a file path, for compact activity lines. */
+export function baseName(path: string): string {
+ const parts = path.split(/[/\\]/).filter(Boolean);
+ return parts.length ? parts[parts.length - 1] : path;
+}
+
+/** Read a tool name off a hook body (pre/post tool use, or a failure). */
+export function toolNameOf(body: Record<string, unknown>): string {
+ return typeof body.tool_name === 'string' ? body.tool_name : '';
+}
+
+/** A tool's bare leaf label — MCP tools arrive as mcp__<server>__<tool>. */
+export function toolLabel(toolName: string): string {
+ return toolName.startsWith('mcp__')
+ ? (toolName.split('__').filter(Boolean).pop() ?? toolName)
+ : toolName;
+}
+
+/** A tool body's `tool_input` as a plain object; empty when absent or scalar. */
+export function toolInputOf(body: Record<string, unknown>): Record<string, unknown> {
+ return body.tool_input && typeof body.tool_input === 'object' && !Array.isArray(body.tool_input)
+ ? (body.tool_input as Record<string, unknown>)
+ : {};
+}
+
+/** Whitespace-collapsed and truncated, for a value shown inline in a status. */
+export function collapseText(value: string, limit = 60): string {
+ const oneLine = value.replace(/\s+/g, ' ').trim();
+ return oneLine.length > limit ? `${oneLine.slice(0, limit - 3)}…` : oneLine;
+}
+
+/**
+ * A command off a tool input, whether the provider sends it as a string
+ * (Claude's `Bash`) or as an argv array (Codex's `shell`).
+ */
+export function commandText(value: unknown): string | undefined {
+ if (typeof value === 'string') return collapseText(value) || undefined;
+ if (Array.isArray(value)) {
+ const joined = value.filter((part) => typeof part === 'string').join(' ');
+ return collapseText(joined) || undefined;
+ }
+ return undefined;
+}
+
+/**
+ * A tool activity line, e.g. "_Running tool_ `Edit` — foo.py". `verb` is the
+ * italicised lead; the tool name is code-formatted and `object` trails after an
+ * em dash when present.
+ */
+export function formatToolActivityLine(
+ toolName: string,
+ verb: string,
+ object: string | undefined
+): string {
+ return `_${verb}_ \`${toolLabel(toolName)}\`` + (object ? ` — ${object}` : '');
+}
diff --git a/dash/packages/core/src/agents/plugins/index.ts b/dash/packages/core/src/agents/plugins/index.ts
index e6569f02a..10ffc5db0 100644
--- a/dash/packages/core/src/agents/plugins/index.ts
+++ b/dash/packages/core/src/agents/plugins/index.ts
@@ -74,7 +74,6 @@ export type {
SwitchLaunchProfile,
SwitchLaunchProfileFile,
SwitchLaunchSpecialization,
- SwitchMcpLaunchServer,
} from './capabilities/mcp';
export type { IPlugins } from './capabilities/plugins';
export type { ISessionsBehavior } from './capabilities/sessions';
diff --git a/dash/packages/plugins/src/agents/impl/claude/hooks.ts b/dash/packages/plugins/src/agents/impl/claude/hooks.ts
index 1362ef8bf..823fb8122 100644
--- a/dash/packages/plugins/src/agents/impl/claude/hooks.ts
+++ b/dash/packages/plugins/src/agents/impl/claude/hooks.ts
@@ -1,40 +1,21 @@
import type { CanonicalHookEvent, NotificationType } from '@switchdash/core/agents/plugins';
import {
+ baseName,
buildNestedJsonHookConfig,
+ commandText,
defaultHookEventParser,
+ formatToolActivityLine,
makeStdinHookCommand,
+ toolInputOf,
+ toolLabel,
+ toolNameOf,
} from '@switchdash/core/agents/plugins/helpers';
export const CLAUDE_SETTINGS_PATH = '.claude/settings.local.json';
-/** The base name of a file path, for compact activity lines. */
-function baseName(path: string): string {
- const parts = path.split(/[/\\]/).filter(Boolean);
- return parts.length ? parts[parts.length - 1] : path;
-}
-
-/** Read a tool name off a hook body (PreToolUse / PostToolUse / failure). */
-function toolNameOf(body: Record<string, unknown>): string {
- return typeof body.tool_name === 'string' ? body.tool_name : '';
-}
-
-/** A tool's bare leaf label — MCP tools arrive as mcp__<server>__<tool>. */
-function toolLabel(toolName: string): string {
- return toolName.startsWith('mcp__')
- ? (toolName.split('__').filter(Boolean).pop() ?? toolName)
- : toolName;
-}
-
/** The Bash command off a tool body, whitespace-collapsed and truncated. */
function shortCommand(body: Record<string, unknown>): string | undefined {
- const input =
- body.tool_input && typeof body.tool_input === 'object'
- ? (body.tool_input as Record<string, unknown>)
- : {};
- const command = typeof input.command === 'string' ? input.command : undefined;
- if (!command) return undefined;
- const oneLine = command.replace(/\s+/g, ' ').trim();
- return oneLine.length > 60 ? `${oneLine.slice(0, 57)}…` : oneLine;
+ return commandText(toolInputOf(body).command);
}
/**
@@ -44,10 +25,7 @@ function shortCommand(body: Record<string, unknown>): string | undefined {
*/
function toolObject(body: Record<string, unknown>): string | undefined {
const toolName = toolNameOf(body);
- const input =
- body.tool_input && typeof body.tool_input === 'object'
- ? (body.tool_input as Record<string, unknown>)
- : {};
+ const input = toolInputOf(body);
const filePath = typeof input.file_path === 'string' ? input.file_path : undefined;
const pattern = typeof input.pattern === 'string' ? input.pattern : undefined;
const query = typeof input.query === 'string' ? input.query : undefined;
@@ -85,8 +63,7 @@ function toolObject(body: Record<string, unknown>): string | undefined {
function toolActivityLine(body: Record<string, unknown>, verb: string): string | undefined {
const toolName = toolNameOf(body);
if (!toolName || toolName === 'Task') return undefined;
- const object = toolObject(body);
- return `_${verb}_ \`${toolLabel(toolName)}\`` + (object ? ` — ${object}` : '');
+ return formatToolActivityLine(toolName, verb, toolObject(body));
}
/**
diff --git a/dash/packages/plugins/src/agents/impl/codex/hooks.test.ts b/dash/packages/plugins/src/agents/impl/codex/hooks.test.ts
index f5eb93f46..099af58d3 100644
--- a/dash/packages/plugins/src/agents/impl/codex/hooks.test.ts
+++ b/dash/packages/plugins/src/agents/impl/codex/hooks.test.ts
@@ -159,6 +159,52 @@ describe('buildCodexHookConfig.parseHookEvent', () => {
type: 'notification',
});
});
+
+ it('turns tool events into activity, so the status is not stuck on the opener', () => {
+ // Without these the runtime status has nothing to report for a whole turn
+ // and renders "Working on it…" from first tool call to last.
+ expect(parseHookEvent('tool-use', { tool_name: 'shell' })).toEqual({
+ kind: 'activity',
+ detail: '_Running tool_ `shell`',
+ });
+ expect(parseHookEvent('tool-done', { tool_name: 'shell' })).toEqual({
+ kind: 'activity',
+ detail: '_Ran tool_ `shell`',
+ });
+ });
+
+ it('names the Switch MCP tool by its leaf, so a room action reads as what it did', () => {
+ expect(parseHookEvent('tool-use', { tool_name: 'mcp__switch__post_message' })).toEqual({
+ kind: 'activity',
+ detail: '_Running tool_ `post_message`',
+ });
+ });
+
+ it("renders Codex's argv-array shell command as text", () => {
+ // Codex sends `command` as an argv array where Claude sends a string.
+ expect(
+ parseHookEvent('tool-use', {
+ tool_name: 'shell',
+ tool_input: { command: ['bash', '-lc', 'pytest -q'] },
+ })
+ ).toEqual({ kind: 'activity', detail: '_Running tool_ `shell` — bash -lc pytest -q' });
+ });
+
+ it('drops the object suffix rather than the line when the input is unexpected', () => {
+ // The tool name is the point; an unrecognised tool or a shape we did not
+ // predict must not cost the status update entirely.
+ expect(parseHookEvent('tool-use', { tool_name: 'some_future_tool' })).toEqual({
+ kind: 'activity',
+ detail: '_Running tool_ `some_future_tool`',
+ });
+ expect(parseHookEvent('tool-use', { tool_name: 'shell', tool_input: { command: 42 } })).toEqual(
+ { kind: 'activity', detail: '_Running tool_ `shell`' }
+ );
+ });
+
+ it('ignores a tool event with no tool name', () => {
+ expect(parseHookEvent('tool-use', {})).toEqual({ kind: 'ignore' });
+ });
});
describe('buildCodexHookConfig install/read/delete', () => {
@@ -176,19 +222,27 @@ describe('buildCodexHookConfig install/read/delete', () => {
}
});
- it('installs no PostToolUse room-tracking hook — the room is connection-driven', async () => {
- // Since the agent-bridge push transport (CHOO-1857), a session's room is
- // claimed on the connection switchdash opens and hands it as
- // SWITCH_CONNECTION_ID, so the server reports the room back. The old
- // PostToolUse `connect_to_room` scrape is gone; only lifecycle hooks remain.
+ it('installs tool hooks unscoped, with no room-tracking matcher', async () => {
+ // The tool hooks exist for the runtime status line and so cover every tool.
+ // Room tracking is not among their jobs: since the agent-bridge push
+ // transport (CHOO-1857), a session's room is claimed on the connection
+ // switchdash opens and hands it as SWITCH_CONNECTION_ID, so the server
+ // reports the room back and the old `connect_to_room` scrape is gone.
const fs = createMemoryFs();
await buildCodexHookConfig().writeHooks(fs, []);
const config = JSON.parse((await fs.read(CODEX_HOOKS_PATH))!) as {
- hooks: Record<string, unknown>;
+ hooks: Record<string, { matcher?: string }[]>;
};
- expect(config.hooks.PostToolUse).toBeUndefined();
- expect(Object.keys(config.hooks).sort()).toEqual(['PermissionRequest', 'SessionStart', 'Stop']);
+ expect(Object.keys(config.hooks).sort()).toEqual([
+ 'PermissionRequest',
+ 'PostToolUse',
+ 'PreToolUse',
+ 'SessionStart',
+ 'Stop',
+ ]);
+ expect(config.hooks.PostToolUse[0].matcher).toBeUndefined();
+ expect(config.hooks.PreToolUse[0].matcher).toBeUndefined();
expect(JSON.stringify(config.hooks)).not.toContain('switch_room_connect');
});
@@ -199,6 +253,8 @@ describe('buildCodexHookConfig install/read/delete', () => {
Stop: 'stop',
PermissionRequest: 'notification',
SessionStart: 'session',
+ PreToolUse: 'tool-use',
+ PostToolUse: 'tool-done',
};
const fs = createMemoryFs();
diff --git a/dash/packages/plugins/src/agents/impl/codex/hooks.ts b/dash/packages/plugins/src/agents/impl/codex/hooks.ts
index d0ec200e0..9d7891614 100644
--- a/dash/packages/plugins/src/agents/impl/codex/hooks.ts
+++ b/dash/packages/plugins/src/agents/impl/codex/hooks.ts
@@ -1,10 +1,15 @@
import type { PluginFs } from '@switchdash/core/agents/plugins';
import type { CanonicalHookEvent, HookRegistration } from '@switchdash/core/agents/plugins';
import {
+ baseName,
buildNestedJsonHookConfig,
+ commandText,
defaultHookEventParser,
+ formatToolActivityLine,
makeNotificationHookCommand,
makeStdinHookCommand,
+ toolInputOf,
+ toolNameOf,
} from '@switchdash/core/agents/plugins/helpers';
import * as toml from 'smol-toml';
@@ -75,6 +80,41 @@ async function removeLegacyCodexNotify(fs: PluginFs): Promise<void> {
await fs.write(CODEX_CONFIG_PATH, toml.stringify(config));
}
+/**
+ * The concrete thing a Codex tool acts on, for the " — <object>" suffix.
+ *
+ * Codex's built-in tool names are its own (`shell`, `unified_exec`,
+ * `write_stdin`, `apply_patch`, `web_search`), so Claude's mapping does not
+ * transfer. `shell` sends its command as an argv array rather than a string,
+ * which {@link commandText} normalises.
+ *
+ * Deliberately best-effort: the tool *name* is what the status line is for, and
+ * an unrecognised tool or an unexpected input shape drops the suffix rather
+ * than the line. MCP tools (the Switch ones included) take no suffix — the tool
+ * name already says what happened.
+ */
+function codexToolObject(body: Record<string, unknown>): string | undefined {
+ const toolName = toolNameOf(body);
+ const input = toolInputOf(body);
+ const path = typeof input.path === 'string' ? input.path : undefined;
+ const filePath = typeof input.file_path === 'string' ? input.file_path : undefined;
+
+ switch (toolName) {
+ case 'shell':
+ case 'unified_exec':
+ case 'write_stdin':
+ return commandText(input.command ?? input.input);
+ case 'apply_patch':
+ return (filePath ?? path) ? baseName((filePath ?? path) as string) : undefined;
+ case 'web_search':
+ return typeof input.query === 'string' ? input.query : undefined;
+ case 'view_image':
+ return (filePath ?? path) ? baseName((filePath ?? path) as string) : undefined;
+ default:
+ return undefined;
+ }
+}
+
/**
* Codex sends `{ type: 'agent-turn-complete' }` as its stop signal instead
* of a plain 'stop' event type, and uses fixed `notification_type` values
@@ -101,19 +141,36 @@ function parseCodexHookEvent(eventType: string, body: Record<string, unknown>):
}
}
+ if (eventType === 'tool-use' || eventType === 'tool-done') {
+ const toolName = toolNameOf(body);
+ if (!toolName) return { kind: 'ignore' };
+ const verb = eventType === 'tool-use' ? 'Running tool' : 'Ran tool';
+ return {
+ kind: 'activity',
+ detail: formatToolActivityLine(toolName, verb, codexToolObject(body)),
+ };
+ }
+
return defaultHookEventParser(eventType, body);
}
export function buildCodexHookConfig() {
- // No PostToolUse room-tracking hook: since the agent-bridge push transport
+ // The tool hooks drive the runtime status line: without them a Codex session
+ // reports only its opening "Working on it…" for the whole turn, because
+ // nothing else can produce an `activity` event. Codex's own hook payload
+ // carries `tool_name` / `tool_input`, the same shape Claude sends.
+ //
+ // No PostToolUse room-tracking matcher: since the agent-bridge push transport
// (CHOO-1857), a session's room is driven by the connection switchdash opens
// and hands it as SWITCH_CONNECTION_ID, so `connect_to_room` claims the room
- // on that connection and the server reports it back. Only lifecycle events
- // remain, none matcher-scoped.
+ // on that connection and the server reports it back. These two are unscoped
+ // — every tool, no matcher.
const base = buildNestedJsonHookConfig(CODEX_HOOKS_PATH, [
{ hookKey: 'Stop', command: makeNotificationHookCommand('idle_prompt') },
{ hookKey: 'PermissionRequest', command: makeNotificationHookCommand('permission_prompt') },
{ hookKey: 'SessionStart', command: makeStdinHookCommand('session-start') },
+ { hookKey: 'PreToolUse', command: makeStdinHookCommand('tool-use') },
+ { hookKey: 'PostToolUse', command: makeStdinHookCommand('tool-done') },
]);
return {
diff --git a/dash/packages/plugins/src/agents/impl/codex/index.ts b/dash/packages/plugins/src/agents/impl/codex/index.ts
index 86f3eabb2..3f88ba333 100644
--- a/dash/packages/plugins/src/agents/impl/codex/index.ts
+++ b/dash/packages/plugins/src/agents/impl/codex/index.ts
@@ -28,7 +28,7 @@ export const plugin = definePlugin(
hooks: {
kind: 'config',
scope: 'global',
- supportedEvents: ['notification', 'stop', 'session'],
+ supportedEvents: ['notification', 'stop', 'session', 'tool-use', 'tool-done'],
},
hostDependency: npmDependency({
id: 'codex',
@@ -102,9 +102,10 @@ export const provider = registerPluginBehavior(plugin, {
hooks: buildCodexHookConfig(),
mcp: {
...codexMcpAdapter(),
- // Codex cannot expand ${VAR} in a bundled .mcp.json, so switchdash registers
- // the local Switch runtime itself: a per-agent profile in CODEX_HOME loaded
- // with `--profile <slug>`.
+ // The profile carries per-agent model / effort / instructions in CODEX_HOME,
+ // loaded with `--profile <slug>`. It registers no MCP server: the connector
+ // plugin's own .mcp.json does that, for every Codex session rather than only
+ // switchdash's.
launchProfile: codexLaunchProfile,
launchProfilePaths: codexProfilePaths,
},
diff --git a/dash/packages/plugins/src/agents/impl/codex/profile.test.ts b/dash/packages/plugins/src/agents/impl/codex/profile.test.ts
index 6030dcb67..fb9b1b5a3 100644
--- a/dash/packages/plugins/src/agents/impl/codex/profile.test.ts
+++ b/dash/packages/plugins/src/agents/impl/codex/profile.test.ts
@@ -2,82 +2,45 @@ import { parse as parseTOML } from 'smol-toml';
import { describe, expect, it } from 'vitest';
import {
buildCodexProfileToml,
- CODEX_MCP_STARTUP_TIMEOUT_SEC,
- CODEX_PROFILE_SWITCH_SERVER_NAME,
CODEX_REASONING_EFFORTS,
codexLaunchProfile,
codexProfileName,
codexProfileRelativePath,
} from './profile';
-const runtime = {
- command: 'npx',
- args: ['-y', '@sandbox-quantum/[email protected]'],
- envVars: ['SWITCH_API_ENDPOINT', 'SWITCH_API_TOKEN', 'SWITCH_AGENT_ID', 'npm_config_userconfig'],
-};
-
-type ServerEntry = {
- command: string;
- args: string[];
- env_vars?: string[];
- env?: Record<string, string>;
- bearer_token?: string;
- startup_timeout_sec?: number;
-};
-
-function switchServerOf(toml: string): ServerEntry {
- const parsed = parseTOML(toml) as { mcp_servers: Record<string, ServerEntry> };
- return parsed.mcp_servers[CODEX_PROFILE_SWITCH_SERVER_NAME];
-}
-
describe('buildCodexProfileToml', () => {
- it('registers the Switch runtime as a stdio server', () => {
- const server = switchServerOf(buildCodexProfileToml({ switchServer: runtime }));
-
- expect(server.command).toBe('npx');
- expect(server.args).toEqual(['-y', '@sandbox-quantum/[email protected]']);
- });
-
- it('forwards the env-var names the runtime needs, since Codex passes it none of its own', () => {
- const server = switchServerOf(buildCodexProfileToml({ switchServer: runtime }));
+ it('registers no MCP server — the connector plugin owns that now', () => {
+ // The plugin's bundled `.mcp.json` declares the Switch server, so writing it
+ // here too would duplicate it for switchdash sessions only. Nothing may be
+ // layered onto a plugin-provided server either: any `mcp_servers.switch.*`
+ // without a transport of its own makes Codex reject the whole config
+ // ("invalid transport"), taking the session with it.
+ const toml = buildCodexProfileToml({
+ model: 'gpt-5.6-terra',
+ reasoningEffort: 'high',
+ instructions: 'be terse',
+ });
- expect(server.env_vars).toEqual(runtime.envVars);
+ expect(toml).not.toContain('mcp_servers');
+ expect(toml).not.toContain('switch-agent-runtime');
});
- it('names credential env vars without carrying one — the profile has no value channel', () => {
- const toml = buildCodexProfileToml({ switchServer: runtime });
- const server = switchServerOf(toml);
+ it('carries no credential, and no channel that could hold one', () => {
+ const toml = buildCodexProfileToml({
+ model: 'gpt-5.6-terra',
+ instructions: 'be terse',
+ });
- // A name list is the whole mechanism; any of these would be a value channel.
- expect(server.env).toBeUndefined();
- expect(server.bearer_token).toBeUndefined();
- for (const name of server.env_vars ?? []) {
- expect(name).toMatch(/^[A-Za-z_][A-Za-z0-9_]*$/);
- }
+ // The file is baked into launch specs and shipped to VMs, so it must stay
+ // safe to write anywhere.
expect(toml).not.toMatch(/Bearer /);
- });
-
- it('declares a startup budget a cold npx fetch can finish inside', () => {
- const server = switchServerOf(buildCodexProfileToml({ switchServer: runtime }));
-
- expect(server.startup_timeout_sec).toBe(CODEX_MCP_STARTUP_TIMEOUT_SEC);
- // Codex defaults to 10s. Fetching the runtime from the private registry on a
- // host that has never run it can exceed that before the server does any work.
- expect(server.startup_timeout_sec).toBeGreaterThanOrEqual(60);
- });
-
- it('omits env_vars for a launch server that needs nothing forwarded', () => {
- const server = switchServerOf(
- buildCodexProfileToml({ switchServer: { ...runtime, envVars: [] } })
- );
-
- expect(server.env_vars).toBeUndefined();
+ expect(toml).not.toContain('SWITCH_API_TOKEN');
+ expect(toml).not.toContain('env_vars');
});
it('emits model / effort scalars and the system prompt as developer_instructions', () => {
const parsed = parseTOML(
buildCodexProfileToml({
- switchServer: runtime,
model: 'gpt-5.6-terra',
reasoningEffort: 'high',
instructions: 'be terse',
@@ -95,17 +58,14 @@ describe('buildCodexProfileToml', () => {
// operating manual (exec/apply_patch protocol, sandbox escalation, planning
// tool, final-answer formatting) is gone. `developer_instructions` leaves it
// intact and adds a developer message, which is what the UI promises.
- const toml = buildCodexProfileToml({ switchServer: runtime, instructions: 'be terse' });
+ const toml = buildCodexProfileToml({ instructions: 'be terse' });
expect(toml).not.toContain('model_instructions_file');
expect(toml).not.toContain('instructions.md');
});
it('omits unset specialization keys so the base config default is inherited', () => {
- const parsed = parseTOML(buildCodexProfileToml({ switchServer: runtime })) as Record<
- string,
- unknown
- >;
+ const parsed = parseTOML(buildCodexProfileToml({})) as Record<string, unknown>;
expect(parsed.model).toBeUndefined();
expect(parsed.model_reasoning_effort).toBeUndefined();
expect(parsed.developer_instructions).toBeUndefined();
@@ -125,9 +85,10 @@ describe('buildCodexProfileToml', () => {
'',
].join('\n');
- const parsed = parseTOML(
- buildCodexProfileToml({ switchServer: runtime, instructions: body })
- ) as Record<string, unknown>;
+ const parsed = parseTOML(buildCodexProfileToml({ instructions: body })) as Record<
+ string,
+ unknown
+ >;
expect(parsed.developer_instructions).toBe(body);
});
@@ -140,14 +101,14 @@ describe('codexLaunchProfile', () => {
const profile = codexLaunchProfile({
slug: 'codex-hoot',
workingDir: WD,
- switchServer: runtime,
+ model: 'gpt-5.6-terra',
});
expect(profile).not.toBeNull();
expect(profile!.args).toEqual(['--profile', codexProfileName('codex-hoot', WD)]);
expect(profile!.files).toEqual([
{
relativePath: codexProfileRelativePath('codex-hoot', WD),
- content: expect.stringContaining('[mcp_servers.switch]'),
+ content: expect.stringContaining('model = "gpt-5.6-terra"'),
},
]);
expect(codexProfileRelativePath('codex-hoot', WD)).toBe(
@@ -163,7 +124,6 @@ describe('codexLaunchProfile', () => {
const profile = codexLaunchProfile({
slug: 'codex-hoot',
workingDir: WD,
- switchServer: runtime,
instructions,
})!;
@@ -175,20 +135,17 @@ describe('codexLaunchProfile', () => {
expect(profile.args.join(' ')).not.toContain('whoami');
});
- it('returns a profile for specialization even without a Switch identity', () => {
- const profile = codexLaunchProfile({
- slug: 'a',
- workingDir: WD,
- switchServer: null,
- model: 'gpt-5.6-terra',
- });
+ it('returns a profile for specialization alone', () => {
+ const profile = codexLaunchProfile({ slug: 'a', workingDir: WD, model: 'gpt-5.6-terra' });
expect(profile).not.toBeNull();
expect(profile!.files[0].content).toContain('model = "gpt-5.6-terra"');
expect(profile!.files[0].content).not.toContain('mcp_servers');
});
- it('returns null when there is nothing to register or specialize', () => {
- expect(codexLaunchProfile({ slug: 'a', workingDir: WD, switchServer: null })).toBeNull();
+ it('returns null when there is nothing to specialize, rather than an empty profile', () => {
+ // An agent on the defaults needs no file. Writing an empty one would still
+ // put `--profile <name>` on the command line, pointing at nothing.
+ expect(codexLaunchProfile({ slug: 'a', workingDir: WD })).toBeNull();
});
it('exposes the stable reasoning-effort levels', () => {
@@ -222,7 +179,6 @@ describe('codexProfileName', () => {
const profile = codexLaunchProfile({
slug,
workingDir: WD,
- switchServer: runtime,
instructions: 'be terse',
})!;
const name = codexProfileName(slug, WD);
diff --git a/dash/packages/plugins/src/agents/impl/codex/profile.ts b/dash/packages/plugins/src/agents/impl/codex/profile.ts
index efae8a718..52d361d77 100644
Binary files a/dash/packages/plugins/src/agents/impl/codex/profile.ts and b/dash/packages/plugins/src/agents/impl/codex/profile.ts differ
diff --git a/docs/api/AGENT_PROTOCOL.md b/docs/api/AGENT_PROTOCOL.md
index aea7ddd83..7d0eaf60f 100644
--- a/docs/api/AGENT_PROTOCOL.md
+++ b/docs/api/AGENT_PROTOCOL.md
@@ -670,9 +670,9 @@ session `SWITCH_CONNECTION_ID`, so a switchdash-launched session claims its room
on a connection switchdash already holds — for Claude Code and for Codex alike.
The `PostToolUse` hook survives only as the fallback for a **Claude** session
switchdash did not start and adopted afterwards, which holds a connection of its
-own. Codex registers no such hook: its Switch MCP server exists only in the
-per-agent profile switchdash writes, so a Codex session switchdash did not start
-has no `connect_to_room` to observe in the first place.
+own. Codex registers no such hook. Since the Codex connector plugin now ships
+the Switch MCP server, a Codex session switchdash did not start *can* call
+`connect_to_room`; such a session is currently untracked rather than impossible.
Cross-checking a room against incoming events becomes unnecessary: a
connection only receives events for rooms it is subscribed to, and any change