mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-22 22:52:03 +00:00
refactor(codex): split app-server lifecycle seams
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import { CodexAppServerRpcError } from "./client.js";
|
||||
|
||||
export const CODEX_CONTROL_METHODS = {
|
||||
account: "account/read",
|
||||
compact: "thread/compact/start",
|
||||
@@ -12,10 +14,13 @@ export const CODEX_CONTROL_METHODS = {
|
||||
export type CodexControlName = keyof typeof CODEX_CONTROL_METHODS;
|
||||
export type CodexControlMethod = (typeof CODEX_CONTROL_METHODS)[CodexControlName];
|
||||
|
||||
export function describeControlFailure(error: string): string {
|
||||
return isUnsupportedControlError(error) ? "unsupported by this Codex app-server" : error;
|
||||
export function describeControlFailure(error: unknown): string {
|
||||
if (isUnsupportedControlError(error)) {
|
||||
return "unsupported by this Codex app-server";
|
||||
}
|
||||
return error instanceof Error ? error.message : String(error);
|
||||
}
|
||||
|
||||
function isUnsupportedControlError(error: string): boolean {
|
||||
return /method not found|unknown method|unsupported method|-32601/i.test(error);
|
||||
function isUnsupportedControlError(error: unknown): error is CodexAppServerRpcError {
|
||||
return error instanceof CodexAppServerRpcError && error.code === -32601;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user