Skip to content

Commit 38d53e3

Browse files
fix(codex): preserve user home default for session catalog (#116131)
* fix-codex-preserve-user-home-session-catalog-default * fix-codex-cover-catalog-reload-proof * fix-codex-harden-catalog-home-proof * fix-codex-enforce-proof-cleanup * test(codex): require proof process shutdown * fix(codex): honor supervised Unix control connections --------- Co-authored-by: IWhatsskill <[email protected]> Co-authored-by: Peter Steinberger <[email protected]>
1 parent db63387 commit 38d53e3

4 files changed

Lines changed: 66 additions & 4 deletions

File tree

‎extensions/codex/openclaw.plugin.json‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,8 +236,7 @@
236236
},
237237
"homeScope": {
238238
"type": "string",
239-
"enum": ["agent", "user"],
240-
"default": "agent"
239+
"enum": ["agent", "user"]
241240
},
242241
"command": { "type": "string" },
243242
"args": {

‎extensions/codex/src/command-rpc.test.ts‎

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,39 @@ describe("Codex command RPC helpers", () => {
3535
);
3636
});
3737

38+
it("keeps omitted Unix scope on the explicit user-scoped supervision connection", async () => {
39+
requestCodexAppServerJsonMock.mockResolvedValue({ data: [] });
40+
const pluginConfig = {
41+
appServer: {
42+
transport: "unix" as const,
43+
url: "unix:///tmp/codex.sock",
44+
requestTimeoutMs: 321,
45+
},
46+
};
47+
const startOptions = {
48+
transport: "unix" as const,
49+
homeScope: "user" as const,
50+
command: "codex",
51+
args: ["app-server", "--listen", "stdio://"],
52+
url: "unix:///tmp/codex.sock",
53+
headers: {},
54+
};
55+
56+
await codexControlRequest(
57+
pluginConfig,
58+
"thread/list",
59+
{ archived: false },
60+
{
61+
startOptions,
62+
authProfileId: null,
63+
},
64+
);
65+
66+
expect(requestCodexAppServerJsonMock).toHaveBeenCalledWith(
67+
expect.objectContaining({ startOptions, timeoutMs: 321, authProfileId: null }),
68+
);
69+
});
70+
3871
it("forwards explicit native auth for supervised control connections", async () => {
3972
requestCodexAppServerJsonMock.mockResolvedValue({});
4073

‎extensions/codex/src/command-rpc.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
} from "./app-server/capabilities.js";
88
import {
99
resolveCodexAppServerRuntimeOptions,
10+
resolveCodexSupervisionAppServerRuntimeOptions,
1011
type CodexAppServerStartOptions,
1112
} from "./app-server/config.js";
1213
import { listCodexAppServerModels } from "./app-server/models.js";
@@ -71,7 +72,10 @@ export async function codexControlRequest(
7172
requestParams?: unknown,
7273
options: CodexControlRequestOptions = {},
7374
): Promise<unknown> {
74-
const runtime = resolveCodexAppServerRuntimeOptions({ pluginConfig });
75+
// Explicit control options own the connection; harness defaults would reject user-home Unix.
76+
const runtime = options.startOptions
77+
? resolveCodexSupervisionAppServerRuntimeOptions({ pluginConfig })
78+
: resolveCodexAppServerRuntimeOptions({ pluginConfig });
7579
return await requestCodexAppServerJson({
7680
method,
7781
requestParams,

‎extensions/codex/src/session-catalog.test.ts‎

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ import fs from "node:fs/promises";
55
import os from "node:os";
66
import path from "node:path";
77
import type { OpenClawConfig } from "openclaw/plugin-sdk/config-contracts";
8+
import {
9+
validateJsonSchemaValue,
10+
type JsonSchemaObject,
11+
} from "openclaw/plugin-sdk/json-schema-runtime";
812
import type { OpenClawPluginApi } from "openclaw/plugin-sdk/plugin-entry";
913
import type { PluginRuntime } from "openclaw/plugin-sdk/plugin-runtime";
1014
import type { SessionCatalogProvider } from "openclaw/plugin-sdk/session-catalog";
@@ -120,6 +124,24 @@ type SessionEntrySummary = ReturnType<
120124

121125
const config = {} as OpenClawConfig;
122126

127+
async function normalizeCodexManifestConfig(value: unknown): Promise<Record<string, unknown>> {
128+
const manifest = JSON.parse(
129+
await fs.readFile(new URL("../openclaw.plugin.json", import.meta.url), "utf8"),
130+
) as { configSchema: JsonSchemaObject };
131+
const result = validateJsonSchemaValue({
132+
cacheKey: "codex.session-catalog.manifest-config",
133+
schema: manifest.configSchema,
134+
value,
135+
applyDefaults: true,
136+
});
137+
if (!result.ok) {
138+
throw new Error(
139+
`Expected valid Codex manifest config: ${result.errors.map((error) => error.text).join(", ")}`,
140+
);
141+
}
142+
return result.value as Record<string, unknown>;
143+
}
144+
123145
function idleThread(overrides: Partial<CodexThread> = {}): CodexThread {
124146
return {
125147
id: "thread-1",
@@ -429,7 +451,11 @@ describe("Codex session catalog errors", () => {
429451

430452
describe("Codex supervision catalog", () => {
431453
it("lists non-archived interactive threads without probing transcript previews", async () => {
432-
const pluginConfig = { supervision: { enabled: true } };
454+
const pluginConfig = await normalizeCodexManifestConfig({
455+
supervision: { enabled: true },
456+
appServer: { command: "codex-catalog" },
457+
});
458+
expect((pluginConfig.appServer as Record<string, unknown>).homeScope).toBeUndefined();
433459
commandRpcMocks.codexControlRequest.mockResolvedValue({
434460
data: [
435461
{

0 commit comments

Comments
 (0)