File size: 1,181 Bytes
3d700dd | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | import type { CloudRequestOptions } from "@openhands/typescript-client/clients";
import type { Backend } from "../backend-registry/types";
import { createCloudClientForRuntime, createCloudClient } from "./client";
export interface CloudProxyRequest {
backend: Backend;
method: CloudRequestOptions["method"];
path: string;
body?: unknown;
headers?: Record<string, string>;
timeoutSeconds?: number;
hostOverride?: string;
authMode?: "bearer" | "session-api-key" | "none";
sessionApiKey?: string | null;
responseType?: "blob";
}
export async function callCloudProxy<TResponse = unknown>(
req: CloudProxyRequest,
): Promise<TResponse> {
const client = req.hostOverride
? createCloudClientForRuntime(req.backend)
: createCloudClient(req.backend);
return client.request<TResponse>({
method: req.method,
path: req.path,
body: req.body,
headers: req.headers,
timeoutSeconds: req.timeoutSeconds,
hostOverride: req.hostOverride,
authMode:
req.authMode === undefined || req.authMode === "bearer"
? "bearer"
: req.authMode,
sessionApiKey: req.sessionApiKey,
responseType: req.responseType,
});
}
|