mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-01 06:50:23 +00:00
refactor: split Codex app-server modules
This commit is contained in:
21
extensions/codex/src/app-server/request.ts
Normal file
21
extensions/codex/src/app-server/request.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import type { CodexAppServerStartOptions } from "./config.js";
|
||||
import type { JsonValue } from "./protocol.js";
|
||||
import { getSharedCodexAppServerClient } from "./shared-client.js";
|
||||
import { withTimeout } from "./timeout.js";
|
||||
|
||||
export async function requestCodexAppServerJson<T = JsonValue | undefined>(params: {
|
||||
method: string;
|
||||
requestParams?: JsonValue;
|
||||
timeoutMs?: number;
|
||||
startOptions?: CodexAppServerStartOptions;
|
||||
}): Promise<T> {
|
||||
const timeoutMs = params.timeoutMs ?? 60_000;
|
||||
return await withTimeout(
|
||||
(async () => {
|
||||
const client = await getSharedCodexAppServerClient({ startOptions: params.startOptions });
|
||||
return await client.request<T>(params.method, params.requestParams);
|
||||
})(),
|
||||
timeoutMs,
|
||||
`codex app-server ${params.method} timed out`,
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user