Spaces:
Paused
Paused
File size: 4,310 Bytes
4e7644b | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 | import { request } from "../request";
import type {
AgentListResponse,
AgentModelSettingsPatch,
AgentProfileConfig,
CreateAgentRequest,
CopyAgentRequest,
AgentProfileRef,
MemoryGraphSnapshot,
ReorderAgentsResponse,
} from "../types/agents";
export interface ReMeComponentMemoryUsage {
bytes: number;
human: string;
}
export interface MemoryCaptureTaskStatus {
task_id: string;
status: "pending" | "running" | "completed" | "failed" | "cancelled";
queued_at: string | null;
finished_at: string | null;
message_count: number;
result: string | null;
error: string | null;
}
export interface ReMeMemoryStatusResponse {
components: Record<string, Record<string, ReMeComponentMemoryUsage>>;
components_total: string;
process_rss: string;
runtime: {
worker: {
status: "idle" | "busy" | "stopping" | "error";
queue_pending: number;
tasks_running: number;
};
auto_memory: {
enabled: boolean;
interval: number;
};
tasks: MemoryCaptureTaskStatus[];
recent: {
last_error: string | null;
};
reindexing: boolean;
};
}
export type ReMeMemoryRuntimeStatus = ReMeMemoryStatusResponse["runtime"];
// Multi-agent management API
export const agentsApi = {
// List all agents
listAgents: () => request<AgentListResponse>("/agents"),
// Get agent details
getAgent: (agentId: string) =>
request<AgentProfileConfig>(`/agents/${agentId}`),
// Create new agent
createAgent: (agent: CreateAgentRequest) =>
request<AgentProfileRef>("/agents", {
method: "POST",
body: JSON.stringify(agent),
}),
// Copy selected agent configuration files into a new agent
copyAgent: (agentId: string, body: CopyAgentRequest) =>
request<AgentProfileRef>(`/agents/${agentId}/copy`, {
method: "POST",
body: JSON.stringify(body),
}),
// Update agent configuration
updateAgent: (agentId: string, agent: AgentProfileConfig) =>
request<AgentProfileConfig>(`/agents/${agentId}`, {
method: "PUT",
body: JSON.stringify(agent),
}),
updateModelSettings: (agentId: string, settings: AgentModelSettingsPatch) =>
request<AgentProfileConfig>(`/agents/${agentId}/model-settings`, {
method: "PATCH",
body: JSON.stringify(settings),
}),
updateBackendSettings: (
agentId: string,
settings: {
model?: string | null;
reasoning_effort?: string | null;
},
) =>
request<AgentProfileConfig>(`/agents/${agentId}/backend-settings`, {
method: "PATCH",
body: JSON.stringify(settings),
}),
rebuildMemoryIndex: (agentId: string) =>
request<{ status: "completed" }>(`/agents/${agentId}/memory/reindex`, {
method: "POST",
timeout: 10 * 60 * 1000,
}),
getMemoryStatus: (agentId: string, signal?: AbortSignal) => {
const path = `/agents/${agentId}/memory/status`;
return signal
? request<ReMeMemoryStatusResponse>(path, { signal })
: request<ReMeMemoryStatusResponse>(path);
},
getMemoryRuntimeStatus: (agentId: string, signal?: AbortSignal) => {
const path = `/agents/${agentId}/memory/runtime-status`;
return signal
? request<ReMeMemoryRuntimeStatus>(path, { signal })
: request<ReMeMemoryRuntimeStatus>(path);
},
getMemoryGraph: (agentId: string) =>
request<MemoryGraphSnapshot>(`/agents/${agentId}/memory/graph`),
// Delete agent
deleteAgent: (agentId: string) =>
request<{ success: boolean; agent_id: string }>(`/agents/${agentId}`, {
method: "DELETE",
}),
// Persist ordered agent ids
reorderAgents: (agentIds: string[]) =>
request<ReorderAgentsResponse>("/agents/order", {
method: "PUT",
body: JSON.stringify({ agent_ids: agentIds }),
}),
// Toggle agent enabled state
toggleAgentEnabled: (agentId: string, enabled: boolean) =>
request<{ success: boolean; agent_id: string; enabled: boolean }>(
`/agents/${agentId}/toggle`,
{
method: "PATCH",
body: JSON.stringify({ enabled }),
},
),
setAgentPinned: (agentId: string, pinned: boolean) =>
request<{ success: boolean; agent_id: string; pinned: boolean }>(
`/agents/${agentId}/pin`,
{
method: "PATCH",
body: JSON.stringify({ pinned }),
},
),
};
|