| import type { |
| AgentProfileSaveInput, |
| AgentProfileListResponse, |
| AgentProfileDetailResponse, |
| AgentProfileMutationResponse, |
| ActivateAgentProfileResponse, |
| } from "@openhands/typescript-client"; |
| import { getActiveBackend } from "../backend-registry/active-store"; |
| import type { Backend } from "../backend-registry/types"; |
| import { callCloudProxy } from "./proxy"; |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
| const BASE = "/api/agent-profiles"; |
|
|
| function activeCloudBackend(): Backend { |
| const active = getActiveBackend().backend; |
| if (active.kind !== "cloud") { |
| throw new Error("Cloud agent-profile call requires a cloud backend."); |
| } |
| return active; |
| } |
|
|
| export async function listCloudAgentProfiles(): Promise<AgentProfileListResponse> { |
| return callCloudProxy<AgentProfileListResponse>({ |
| backend: activeCloudBackend(), |
| method: "GET", |
| path: BASE, |
| }); |
| } |
|
|
| export async function getCloudAgentProfile( |
| name: string, |
| ): Promise<AgentProfileDetailResponse> { |
| return callCloudProxy<AgentProfileDetailResponse>({ |
| backend: activeCloudBackend(), |
| method: "GET", |
| path: `${BASE}/${encodeURIComponent(name)}`, |
| }); |
| } |
|
|
| export async function saveCloudAgentProfile( |
| name: string, |
| profile: AgentProfileSaveInput, |
| ): Promise<AgentProfileMutationResponse> { |
| return callCloudProxy<AgentProfileMutationResponse>({ |
| backend: activeCloudBackend(), |
| method: "POST", |
| path: `${BASE}/${encodeURIComponent(name)}`, |
| body: profile, |
| }); |
| } |
|
|
| export async function deleteCloudAgentProfile( |
| name: string, |
| ): Promise<AgentProfileMutationResponse> { |
| return callCloudProxy<AgentProfileMutationResponse>({ |
| backend: activeCloudBackend(), |
| method: "DELETE", |
| path: `${BASE}/${encodeURIComponent(name)}`, |
| }); |
| } |
|
|
| export async function renameCloudAgentProfile( |
| name: string, |
| newName: string, |
| ): Promise<AgentProfileMutationResponse> { |
| return callCloudProxy<AgentProfileMutationResponse>({ |
| backend: activeCloudBackend(), |
| method: "POST", |
| path: `${BASE}/${encodeURIComponent(name)}/rename`, |
| body: { new_name: newName }, |
| }); |
| } |
|
|
| export async function activateCloudAgentProfile( |
| profileId: string, |
| ): Promise<ActivateAgentProfileResponse> { |
| return callCloudProxy<ActivateAgentProfileResponse>({ |
| backend: activeCloudBackend(), |
| method: "POST", |
| path: `${BASE}/${encodeURIComponent(profileId)}/activate`, |
| body: {}, |
| }); |
| } |
|
|