2026-03-29 05:11:43 +00:00
|
|
|
import { launcherFetch } from "@/api/http"
|
|
|
|
|
|
feat(web): add agent management UI and improve launcher integration (#1358)
* Improve the web launcher and gateway integration across backend and frontend.
- add runtime model availability checks for local and OAuth-backed models
- support launcher-driven gateway host overrides and websocket URL resolution
- add gateway log clearing and keep incremental log sync consistent after resets
- migrate session history APIs to JSONL metadata-backed storage with legacy fallback
- expose session titles and improve chat history loading and error handling
- move shared backend runtime helpers into the web utils package
- avoid blocking web startup when automatic onboard initialization fails
- add backend tests covering gateway readiness, host resolution, models, logs, and sessions
* feat(agent): add skills and tools management APIs and UI
- add backend APIs to list, view, import, and delete skills
- add tool status and toggle endpoints with dependency-aware config updates
- add agent skills/tools pages, routes, sidebar entries, and i18n strings
- add backend tests for the new skills and tools flows
* chore(frontend): upgrade shadcn to 4.0.5 and refresh lockfile
* chore(web): keep backend dist placeholder tracked
2026-03-11 10:37:00 +00:00
|
|
|
export interface ToolSupportItem {
|
|
|
|
|
name: string
|
|
|
|
|
description: string
|
|
|
|
|
category: string
|
|
|
|
|
config_key: string
|
|
|
|
|
status: "enabled" | "disabled" | "blocked"
|
|
|
|
|
reason_code?: string
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
interface ToolsResponse {
|
|
|
|
|
tools: ToolSupportItem[]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
interface ToolActionResponse {
|
|
|
|
|
status: string
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function request<T>(path: string, options?: RequestInit): Promise<T> {
|
2026-03-29 05:11:43 +00:00
|
|
|
const res = await launcherFetch(path, options)
|
feat(web): add agent management UI and improve launcher integration (#1358)
* Improve the web launcher and gateway integration across backend and frontend.
- add runtime model availability checks for local and OAuth-backed models
- support launcher-driven gateway host overrides and websocket URL resolution
- add gateway log clearing and keep incremental log sync consistent after resets
- migrate session history APIs to JSONL metadata-backed storage with legacy fallback
- expose session titles and improve chat history loading and error handling
- move shared backend runtime helpers into the web utils package
- avoid blocking web startup when automatic onboard initialization fails
- add backend tests covering gateway readiness, host resolution, models, logs, and sessions
* feat(agent): add skills and tools management APIs and UI
- add backend APIs to list, view, import, and delete skills
- add tool status and toggle endpoints with dependency-aware config updates
- add agent skills/tools pages, routes, sidebar entries, and i18n strings
- add backend tests for the new skills and tools flows
* chore(frontend): upgrade shadcn to 4.0.5 and refresh lockfile
* chore(web): keep backend dist placeholder tracked
2026-03-11 10:37:00 +00:00
|
|
|
if (!res.ok) {
|
|
|
|
|
let message = `API error: ${res.status} ${res.statusText}`
|
|
|
|
|
try {
|
|
|
|
|
const body = (await res.json()) as {
|
|
|
|
|
error?: string
|
|
|
|
|
errors?: string[]
|
|
|
|
|
}
|
|
|
|
|
if (Array.isArray(body.errors) && body.errors.length > 0) {
|
|
|
|
|
message = body.errors.join("; ")
|
|
|
|
|
} else if (typeof body.error === "string" && body.error.trim() !== "") {
|
|
|
|
|
message = body.error
|
|
|
|
|
}
|
|
|
|
|
} catch {
|
|
|
|
|
// ignore invalid body
|
|
|
|
|
}
|
|
|
|
|
throw new Error(message)
|
|
|
|
|
}
|
|
|
|
|
return res.json() as Promise<T>
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export async function getTools(): Promise<ToolsResponse> {
|
|
|
|
|
return request<ToolsResponse>("/api/tools")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export async function setToolEnabled(
|
|
|
|
|
name: string,
|
|
|
|
|
enabled: boolean,
|
|
|
|
|
): Promise<ToolActionResponse> {
|
|
|
|
|
return request<ToolActionResponse>(
|
|
|
|
|
`/api/tools/${encodeURIComponent(name)}/state`,
|
|
|
|
|
{
|
|
|
|
|
method: "PUT",
|
|
|
|
|
headers: { "Content-Type": "application/json" },
|
|
|
|
|
body: JSON.stringify({ enabled }),
|
|
|
|
|
},
|
|
|
|
|
)
|
|
|
|
|
}
|