feat: add one pull plug and play feature

This commit is contained in:
2026-05-18 11:28:38 +02:00
parent ad64766cd6
commit fc498379f6
11 changed files with 290 additions and 42 deletions

View File

@ -58,6 +58,21 @@ async function apiFetch(input: string, init: RequestInit = {}): Promise<Response
return r;
}
export async function createAgentToken(hostname: string): Promise<{ agent_id: string; token: string }> {
const r = await apiFetch(`${BASE}/agents/token`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ hostname }),
});
if (!r.ok) throw new Error(`create token: ${r.status}`);
return r.json();
}
export async function deleteAgent(id: string): Promise<void> {
const r = await apiFetch(`${BASE}/agents/${id}`, { method: "DELETE" });
if (!r.ok) throw new Error(`delete agent: ${r.status}`);
}
export async function fetchAgents(): Promise<Agent[]> {
const r = await apiFetch(`${BASE}/agents`);
if (!r.ok) throw new Error(`agents: ${r.status}`);