diff options
Diffstat (limited to 'makima/frontend/src/lib/api.ts')
| -rw-r--r-- | makima/frontend/src/lib/api.ts | 176 |
1 files changed, 0 insertions, 176 deletions
diff --git a/makima/frontend/src/lib/api.ts b/makima/frontend/src/lib/api.ts index 9d9cb1c..480041c 100644 --- a/makima/frontend/src/lib/api.ts +++ b/makima/frontend/src/lib/api.ts @@ -3246,179 +3246,3 @@ export async function cleanupDirectiveTasks(id: string): Promise<{ deleted: numb return res.json(); } -// ============================================================================= -// Directive Memory Types & API -// ============================================================================= - -/** Category of a directive memory entry */ -export type MemoryCategory = - | "decision" - | "learning" - | "context" - | "preference" - | "issue" - | "progress" - | "other"; - -/** A single memory entry associated with a directive */ -export interface DirectiveMemory { - id: string; - directiveId: string; - /** The memory content text */ - content: string; - /** Category for organizing memories */ - category: MemoryCategory; - /** Which step created this memory (null if directive-level) */ - stepId: string | null; - /** Which task created this memory (null if manually added) */ - taskId: string | null; - /** Importance score (1-10, higher = more important) */ - importance: number; - createdAt: string; - updatedAt: string; -} - -/** Response from listing directive memories */ -export interface DirectiveMemoryListResponse { - memories: DirectiveMemory[]; - total: number; -} - -/** Request to create a new directive memory */ -export interface CreateDirectiveMemoryRequest { - content: string; - category?: MemoryCategory; - stepId?: string; - taskId?: string; - importance?: number; -} - -/** Request to update a directive memory */ -export interface UpdateDirectiveMemoryRequest { - content?: string; - category?: MemoryCategory; - importance?: number; -} - -// Directive Memory API functions - -/** - * List all memories for a directive. - * Optionally filter by category or step. - */ -export async function listDirectiveMemories( - directiveId: string, - params?: { category?: MemoryCategory; stepId?: string } -): Promise<DirectiveMemoryListResponse> { - const searchParams = new URLSearchParams(); - if (params?.category) searchParams.set("category", params.category); - if (params?.stepId) searchParams.set("stepId", params.stepId); - const query = searchParams.toString(); - const url = `${API_BASE}/api/v1/directives/${directiveId}/memories${query ? `?${query}` : ""}`; - const res = await authFetch(url); - if (!res.ok) throw new Error(`Failed to list directive memories: ${res.statusText}`); - return res.json(); -} - -/** - * Get a single memory entry by ID. - */ -export async function getDirectiveMemory( - directiveId: string, - memoryId: string -): Promise<DirectiveMemory> { - const res = await authFetch( - `${API_BASE}/api/v1/directives/${directiveId}/memories/${memoryId}` - ); - if (!res.ok) throw new Error(`Failed to get directive memory: ${res.statusText}`); - return res.json(); -} - -/** - * Create a new memory entry for a directive. - */ -export async function createDirectiveMemory( - directiveId: string, - req: CreateDirectiveMemoryRequest -): Promise<DirectiveMemory> { - const res = await authFetch(`${API_BASE}/api/v1/directives/${directiveId}/memories`, { - method: "POST", - headers: { "Content-Type": "application/json" }, - body: JSON.stringify(req), - }); - if (!res.ok) throw new Error(`Failed to create directive memory: ${res.statusText}`); - return res.json(); -} - -/** - * Update an existing memory entry. - */ -export async function updateDirectiveMemory( - directiveId: string, - memoryId: string, - req: UpdateDirectiveMemoryRequest -): Promise<DirectiveMemory> { - const res = await authFetch( - `${API_BASE}/api/v1/directives/${directiveId}/memories/${memoryId}`, - { - method: "PUT", - headers: { "Content-Type": "application/json" }, - body: JSON.stringify(req), - } - ); - if (!res.ok) throw new Error(`Failed to update directive memory: ${res.statusText}`); - return res.json(); -} - -/** - * Delete a memory entry. - */ -export async function deleteDirectiveMemory( - directiveId: string, - memoryId: string -): Promise<void> { - const res = await authFetch( - `${API_BASE}/api/v1/directives/${directiveId}/memories/${memoryId}`, - { method: "DELETE" } - ); - if (!res.ok) throw new Error(`Failed to delete directive memory: ${res.statusText}`); -} - -/** - * Batch create multiple memory entries for a directive. - * Useful when a task completes and wants to store multiple learnings at once. - */ -export async function batchCreateDirectiveMemories( - directiveId: string, - memories: CreateDirectiveMemoryRequest[] -): Promise<DirectiveMemory[]> { - const res = await authFetch( - `${API_BASE}/api/v1/directives/${directiveId}/memories/batch`, - { - method: "POST", - headers: { "Content-Type": "application/json" }, - body: JSON.stringify(memories), - } - ); - if (!res.ok) throw new Error(`Failed to batch create directive memories: ${res.statusText}`); - return res.json(); -} - -/** - * Get a formatted memory context string for a directive. - * This returns memories formatted for injection into task prompts. - * Optionally filter by category or limit the number of memories returned. - */ -export async function getDirectiveMemoryContext( - directiveId: string, - params?: { category?: MemoryCategory; limit?: number } -): Promise<{ context: string; memoryCount: number }> { - const searchParams = new URLSearchParams(); - if (params?.category) searchParams.set("category", params.category); - if (params?.limit) searchParams.set("limit", params.limit.toString()); - const query = searchParams.toString(); - const url = `${API_BASE}/api/v1/directives/${directiveId}/memories/context${query ? `?${query}` : ""}`; - const res = await authFetch(url); - if (!res.ok) throw new Error(`Failed to get directive memory context: ${res.statusText}`); - return res.json(); -} |
