Skip to content

Commit 8d72aaf

Browse files
committed
refactor: split Codex app-server modules
1 parent e9684c2 commit 8d72aaf

19 files changed

Lines changed: 981 additions & 657 deletions

extensions/codex/harness.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import type { AgentHarness } from "openclaw/plugin-sdk/agent-harness";
2-
import { listCodexAppServerModels } from "./src/app-server/client.js";
2+
import { maybeCompactCodexAppServerSession } from "./src/app-server/compact.js";
3+
import { listCodexAppServerModels } from "./src/app-server/models.js";
34
import type {
45
CodexAppServerListModelsOptions,
56
CodexAppServerModel,
67
CodexAppServerModelListResult,
7-
} from "./src/app-server/client.js";
8-
import { maybeCompactCodexAppServerSession } from "./src/app-server/compact.js";
8+
} from "./src/app-server/models.js";
99
import { runCodexAppServerAttempt } from "./src/app-server/run-attempt.js";
1010
import { clearCodexAppServerBinding } from "./src/app-server/session-binding.js";
1111

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
export const CODEX_CONTROL_METHODS = {
2+
account: "account/read",
3+
compact: "thread/compact/start",
4+
listMcpServers: "mcpServerStatus/list",
5+
listSkills: "skills/list",
6+
listThreads: "thread/list",
7+
rateLimits: "account/rateLimits/read",
8+
resumeThread: "thread/resume",
9+
review: "review/start",
10+
} as const;
11+
12+
export type CodexControlName = keyof typeof CODEX_CONTROL_METHODS;
13+
export type CodexControlMethod = (typeof CODEX_CONTROL_METHODS)[CodexControlName];
14+
15+
export function describeControlFailure(error: string): string {
16+
return isUnsupportedControlError(error) ? "unsupported by this Codex app-server" : error;
17+
}
18+
19+
function isUnsupportedControlError(error: string): boolean {
20+
return /method not found|unknown method|unsupported method|-32601/i.test(error);
21+
}

extensions/codex/src/app-server/client.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ import { afterEach, describe, expect, it, vi } from "vitest";
44
import { WebSocketServer, type RawData } from "ws";
55
import {
66
CodexAppServerClient,
7-
listCodexAppServerModels,
87
MIN_CODEX_APP_SERVER_VERSION,
98
readCodexVersionFromUserAgent,
10-
resetSharedCodexAppServerClientForTests,
119
} from "./client.js";
10+
import { listCodexAppServerModels } from "./models.js";
11+
import { resetSharedCodexAppServerClientForTests } from "./shared-client.js";
1212

1313
function createClientHarness() {
1414
const stdout = new PassThrough();

0 commit comments

Comments
 (0)