huskies: merge 950

This commit is contained in:
dave
2026-05-13 08:41:57 +00:00
parent 7491eec257
commit 4a8ed4348b
38 changed files with 354 additions and 4329 deletions
+12 -57
View File
@@ -40,60 +40,19 @@ export interface AgentConfigInfo {
max_budget_usd: number | null;
}
const DEFAULT_API_BASE = "/api";
function buildApiUrl(path: string, baseUrl = DEFAULT_API_BASE): string {
return `${baseUrl}${path}`;
}
async function requestJson<T>(
path: string,
options: RequestInit = {},
baseUrl = DEFAULT_API_BASE,
): Promise<T> {
const res = await fetch(buildApiUrl(path, baseUrl), {
headers: {
"Content-Type": "application/json",
...(options.headers ?? {}),
},
...options,
});
if (!res.ok) {
const text = await res.text();
throw new Error(text || `Request failed (${res.status})`);
}
return res.json() as Promise<T>;
}
export const agentsApi = {
startAgent(storyId: string, agentName?: string, baseUrl?: string) {
return requestJson<AgentInfo>(
"/agents/start",
{
method: "POST",
body: JSON.stringify({
story_id: storyId,
agent_name: agentName,
}),
},
baseUrl,
);
startAgent(storyId: string, agentName?: string) {
return rpcCall<AgentInfo>("agents.start", {
story_id: storyId,
agent_name: agentName,
});
},
stopAgent(storyId: string, agentName: string, baseUrl?: string) {
return requestJson<boolean>(
"/agents/stop",
{
method: "POST",
body: JSON.stringify({
story_id: storyId,
agent_name: agentName,
}),
},
baseUrl,
);
stopAgent(storyId: string, agentName: string) {
return rpcCall<boolean>("agents.stop", {
story_id: storyId,
agent_name: agentName,
});
},
listAgents(_baseUrl?: string) {
@@ -104,12 +63,8 @@ export const agentsApi = {
return rpcCall<AgentConfigInfo[]>("agent_config.list");
},
reloadConfig(baseUrl?: string) {
return requestJson<AgentConfigInfo[]>(
"/agents/config/reload",
{ method: "POST" },
baseUrl,
);
reloadConfig() {
return rpcCall<AgentConfigInfo[]>("agent_config.list");
},
getAgentOutput(storyId: string, agentName: string, _baseUrl?: string) {