feat(frontend): migrate API calls to /api/v1 (Stage 1 PR5)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
1445043649
2026-06-28 20:07:20 +08:00
parent e6a12b9a7c
commit 190c1dc3c8
12 changed files with 47 additions and 35 deletions
+6 -6
View File
@@ -27,20 +27,20 @@ function isAgentsApiDisabledDetail(detail: string | undefined): boolean {
}
export async function listAgents(): Promise<Agent[]> {
const res = await fetch(`${getBackendBaseURL()}/api/agents`);
const res = await fetch(`${getBackendBaseURL()}/api/v1/agents`);
if (!res.ok) throw new Error(`Failed to load agents: ${res.statusText}`);
const data = (await res.json()) as { agents: Agent[] };
return data.agents;
}
export async function getAgent(name: string): Promise<Agent> {
const res = await fetch(`${getBackendBaseURL()}/api/agents/${name}`);
const res = await fetch(`${getBackendBaseURL()}/api/v1/agents/${name}`);
if (!res.ok) throw new Error(`Agent '${name}' not found`);
return res.json() as Promise<Agent>;
}
export async function createAgent(request: CreateAgentRequest): Promise<Agent> {
const res = await fetch(`${getBackendBaseURL()}/api/agents`, {
const res = await fetch(`${getBackendBaseURL()}/api/v1/agents`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(request),
@@ -59,7 +59,7 @@ export async function updateAgent(
name: string,
request: UpdateAgentRequest,
): Promise<Agent> {
const res = await fetch(`${getBackendBaseURL()}/api/agents/${name}`, {
const res = await fetch(`${getBackendBaseURL()}/api/v1/agents/${name}`, {
method: "PUT",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(request),
@@ -72,7 +72,7 @@ export async function updateAgent(
}
export async function deleteAgent(name: string): Promise<void> {
const res = await fetch(`${getBackendBaseURL()}/api/agents/${name}`, {
const res = await fetch(`${getBackendBaseURL()}/api/v1/agents/${name}`, {
method: "DELETE",
});
if (!res.ok) throw new Error(`Failed to delete agent: ${res.statusText}`);
@@ -84,7 +84,7 @@ export async function checkAgentName(
let res: Response;
try {
res = await fetch(
`${getBackendBaseURL()}/api/agents/check?name=${encodeURIComponent(name)}`,
`${getBackendBaseURL()}/api/v1/agents/check?name=${encodeURIComponent(name)}`,
);
} catch {
throw new AgentNameCheckError(