Skip to content

Commit 2c4ca02

Browse files
author
Benjamin Badejo
committed
fix(codex): provision Computer Use service app
1 parent 9fc1f0b commit 2c4ca02

10 files changed

Lines changed: 947 additions & 12 deletions

‎docs/plugins/codex-computer-use.md‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,16 @@ also tries to register the bundled Codex marketplace from
115115
as a fallback for legacy standalone installs. If setup still cannot make the
116116
MCP server available, the turn fails before the thread starts.
117117

118+
Current desktop bundles ship the Computer Use plugin separately from its
119+
signed macOS service app. For isolated agent Codex homes, `autoInstall: true`
120+
and explicit `/codex computer-use install` therefore also copy the
121+
desktop-bundled `Codex Computer Use.app` into the canonical
122+
`$CODEX_HOME/computer-use/` location before app-server startup. OpenClaw uses
123+
the same quarantine-free `ditto` copy strategy as ChatGPT desktop and leaves an
124+
existing matching service app unchanged. When the desktop-bundled app changes,
125+
OpenClaw atomically refreshes the isolated copy so the plugin and service do not
126+
drift across upgrades.
127+
118128
After changing Computer Use config, use `/new` or `/reset` in the affected
119129
chat before testing if an existing Codex thread has already started.
120130

@@ -354,6 +364,13 @@ installed through the current app-server API.
354364
servers reload. If it remains unavailable, fix the Codex Computer Use app,
355365
Codex app-server MCP status, or macOS permissions.
356366

367+
**A readiness `thread/start` times out and Codex logs say the Computer Use
368+
client was not found.** Newer thin plugin bundles expect the signed service app
369+
under the active `$CODEX_HOME`, while older bundles carried it inside the
370+
plugin. Enable `autoInstall` or run `/codex computer-use install` so OpenClaw
371+
can provision the desktop-bundled app into an isolated agent home. This repair
372+
requires ChatGPT.app or the legacy Codex.app to be installed locally.
373+
357374
**Status or a probe times out on `computer-use.list_apps`.** The plugin and
358375
MCP server are present, but the local Computer Use bridge did not answer.
359376
Quit or restart Codex Computer Use, relaunch Codex Desktop if needed, then

‎extensions/codex/src/app-server/attempt-startup.test.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -674,7 +674,9 @@ describe("startCodexAttemptThread", () => {
674674
});
675675

676676
await expect(run).rejects.toThrow("stop after option capture");
677-
expect(clientFactory).toHaveBeenCalledWith(expect.objectContaining({ preparedAuth }));
677+
expect(clientFactory).toHaveBeenCalledWith(
678+
expect.objectContaining({ preparedAuth, pluginConfig }),
679+
);
678680
expect(clientFactory.mock.calls[0]?.[0]?.preparedAuth).toBe(preparedAuth);
679681
expect(clientFactory).not.toHaveBeenCalledWith(
680682
expect.objectContaining({ authProfileId: expect.anything() }),

‎extensions/codex/src/app-server/attempt-startup.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,7 @@ export async function startCodexAttemptThread(params: {
226226
const attemptParams = params.buildAttemptParams();
227227
startupClient = await params.attemptClientFactory({
228228
startOptions: params.appServer.start,
229+
pluginConfig: params.pluginConfig,
229230
...(params.startupPreparedAuth
230231
? { preparedAuth: params.startupPreparedAuth }
231232
: { authProfileId: params.startupAuthProfileId }),

‎extensions/codex/src/app-server/auth-bridge.test.ts‎

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,14 @@ const oauthMocks = vi.hoisted(() => ({
3030
refreshOpenAICodexToken: vi.fn(),
3131
}));
3232

33+
const computerUseServiceMocks = vi.hoisted(() => ({
34+
ensureCodexComputerUseServiceApp: vi.fn(async () => ({
35+
status: "already_installed" as const,
36+
changed: false,
37+
message: "Computer Use service app is installed.",
38+
})),
39+
}));
40+
3341
const providerRuntimeMocks = vi.hoisted(() => ({
3442
formatProviderAuthProfileApiKeyWithPlugin: vi.fn(),
3543
refreshProviderOAuthCredentialWithPlugin: vi.fn(
@@ -117,12 +125,17 @@ vi.mock("openclaw/plugin-sdk/agent-runtime", async (importOriginal) => {
117125
};
118126
});
119127

128+
vi.mock("./computer-use-service.js", () => ({
129+
ensureCodexComputerUseServiceApp: computerUseServiceMocks.ensureCodexComputerUseServiceApp,
130+
}));
131+
120132
afterEach(() => {
121133
vi.unstubAllEnvs();
122134
clearRuntimeAuthProfileStoreSnapshots();
123135
oauthMocks.refreshOpenAICodexToken.mockReset();
124136
providerRuntimeMocks.formatProviderAuthProfileApiKeyWithPlugin.mockReset();
125137
providerRuntimeMocks.refreshProviderOAuthCredentialWithPlugin.mockClear();
138+
computerUseServiceMocks.ensureCodexComputerUseServiceApp.mockClear();
126139
});
127140

128141
function createStartOptions(
@@ -241,6 +254,36 @@ describe("bridgeCodexAppServerStartOptions", () => {
241254
}
242255
});
243256

257+
it("provisions the Computer Use service app before auto-install startup", async () => {
258+
await withTempDir("openclaw-codex-computer-use-service-", async (agentDir) => {
259+
const startOptions = createStartOptions();
260+
const codexHome = resolveCodexAppServerHomeDir(agentDir);
261+
262+
await bridgeCodexAppServerStartOptions({
263+
startOptions,
264+
agentDir,
265+
pluginConfig: { computerUse: { enabled: true, autoInstall: true } },
266+
});
267+
268+
expect(computerUseServiceMocks.ensureCodexComputerUseServiceApp).toHaveBeenCalledWith({
269+
codexHome,
270+
appServerCommand: startOptions.command,
271+
});
272+
});
273+
});
274+
275+
it("does not provision the Computer Use service app without auto-install authorization", async () => {
276+
await withTempDir("openclaw-codex-computer-use-service-", async (agentDir) => {
277+
await bridgeCodexAppServerStartOptions({
278+
startOptions: createStartOptions(),
279+
agentDir,
280+
pluginConfig: { computerUse: { enabled: true, autoInstall: false } },
281+
});
282+
283+
expect(computerUseServiceMocks.ensureCodexComputerUseServiceApp).not.toHaveBeenCalled();
284+
});
285+
});
286+
244287
it("uses the native user Codex home for coexistence mode", async () => {
245288
await withTempDir("openclaw-codex-user-home-", async (root) => {
246289
const agentDir = path.join(root, "agent");

‎extensions/codex/src/app-server/auth-bridge.ts‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import { hasUsableOAuthCredential } from "openclaw/plugin-sdk/provider-auth";
2424
import { resolveCodexAppServerHomeDir, withEphemeralCodexAuthStore } from "./auth-start-options.js";
2525
import type { CodexAppServerClient } from "./client.js";
2626
import { ensureCodexComputerUseSharedPluginCache } from "./computer-use-cache.js";
27+
import { ensureCodexComputerUseServiceApp } from "./computer-use-service.js";
2728
import {
2829
resolveCodexAppServerUserHomeDir,
2930
resolveCodexComputerUseConfig,
@@ -437,10 +438,17 @@ async function withCodexHomeEnvironment(
437438
? startOptions.env[HOME_ENV_VAR]
438439
: undefined;
439440
await fs.mkdir(codexHome, { recursive: true });
441+
const computerUseConfig = resolveCodexComputerUseConfig({ pluginConfig });
440442
await ensureCodexComputerUseSharedPluginCache({
441443
codexHome,
442-
config: resolveCodexComputerUseConfig({ pluginConfig }),
444+
config: computerUseConfig,
443445
});
446+
if (computerUseConfig.enabled && computerUseConfig.autoInstall) {
447+
await ensureCodexComputerUseServiceApp({
448+
codexHome,
449+
appServerCommand: startOptions.command,
450+
});
451+
}
444452
if (nativeHome) {
445453
await fs.mkdir(nativeHome, { recursive: true });
446454
}

0 commit comments

Comments
 (0)