export type CreateApiApiAgentRuntimesArgs = {body: {action?: ('install' | 'job-status' | 'docker-compose' | 'detect') | undefined, runtime?: ('openclaw' | 'hermes' | 'claude' | 'codex' | 'opencode') | undefined, mode?: ('local' | 'docker') | undefined, jobId?: string | undefined}}; export type CreateApiApiAgentRuntimesOptions = {baseUrl: string, sessionCookie?: string | undefined, fetch?: typeof fetch | undefined}; /** * Manage agent runtime actions * * POST /api/agent-runtimes * * Also accepts auth: apiKey */ export const createApiApiAgentRuntimes = async (args: CreateApiApiAgentRuntimesArgs, options: CreateApiApiAgentRuntimesOptions) => { const {baseUrl, fetch: fetchFn = fetch, sessionCookie} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (sessionCookie !== undefined) cookies.push("__Host-mc-session=" + encodeURIComponent(sessionCookie)) const url = `${baseUrl.replace(/\/+$/, '')}/api/agent-runtimes${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };