





















@@ -27,6 +27,8 @@ function managedCommandPath(root: string, platform: NodeJS.Platform): string {
2727return pathApi.join(root, "node_modules", ".bin", platform === "win32" ? "codex.cmd" : "codex");
2828}
292930+const MACOS_DESKTOP_CODEX_APP_SERVER_COMMAND = "/Applications/Codex.app/Contents/Resources/codex";
31+3032describe("managed Codex app-server binary", () => {
3133it("leaves explicit command overrides unchanged", async () => {
3234const explicitOptions = startOptions("config");
@@ -41,10 +43,35 @@ describe("managed Codex app-server binary", () => {
4143expect(pathExists).not.toHaveBeenCalled();
4244});
434544-it("resolves the plugin-local bundled Codex binary", async () => {
46+it("prefers the macOS desktop app bundle when it exists", async () => {
4547const pluginRoot = path.join("/tmp", "openclaw", "extensions", "codex");
4648const paths = resolveManagedCodexAppServerPaths({ platform: "darwin", pluginRoot });
47-const pathExists = vi.fn(async (filePath: string) => filePath === paths.commandPath);
49+const pluginLocalCommand = managedCommandPath(pluginRoot, "darwin");
50+const pathExists = vi.fn(
51+async (filePath: string) =>
52+filePath === MACOS_DESKTOP_CODEX_APP_SERVER_COMMAND || filePath === pluginLocalCommand,
53+);
54+55+await expect(
56+resolveManagedCodexAppServerStartOptions(startOptions("managed"), {
57+platform: "darwin",
58+ pluginRoot,
59+ pathExists,
60+}),
61+).resolves.toEqual({
62+ ...startOptions("managed"),
63+command: MACOS_DESKTOP_CODEX_APP_SERVER_COMMAND,
64+commandSource: "resolved-managed",
65+managedFallbackCommandPaths: [pluginLocalCommand],
66+});
67+expect(paths.commandPath).toBe(MACOS_DESKTOP_CODEX_APP_SERVER_COMMAND);
68+expect(paths.candidateCommandPaths).toContain(pluginLocalCommand);
69+});
70+71+it("falls back to the plugin-local bundled Codex binary on macOS", async () => {
72+const pluginRoot = path.join("/tmp", "openclaw", "extensions", "codex");
73+const pluginLocalCommand = managedCommandPath(pluginRoot, "darwin");
74+const pathExists = vi.fn(async (filePath: string) => filePath === pluginLocalCommand);
48754976await expect(
5077resolveManagedCodexAppServerStartOptions(startOptions("managed"), {
@@ -54,10 +81,10 @@ describe("managed Codex app-server binary", () => {
5481}),
5582).resolves.toEqual({
5683 ...startOptions("managed"),
57-command: paths.commandPath,
84+command: pluginLocalCommand,
5885commandSource: "resolved-managed",
5986});
60-expect(paths.commandPath).toBe(managedCommandPath(pluginRoot, "darwin"));
87+expect(pathExists).toHaveBeenCalledWith(MACOS_DESKTOP_CODEX_APP_SERVER_COMMAND, "darwin");
6188});
62896390it("resolves Windows Codex command shims", () => {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。