summaryrefslogtreecommitdiff
path: root/makima/frontend/src/lib/api.ts
diff options
context:
space:
mode:
Diffstat (limited to 'makima/frontend/src/lib/api.ts')
-rw-r--r--makima/frontend/src/lib/api.ts183
1 files changed, 183 insertions, 0 deletions
diff --git a/makima/frontend/src/lib/api.ts b/makima/frontend/src/lib/api.ts
index 40e160e..552829a 100644
--- a/makima/frontend/src/lib/api.ts
+++ b/makima/frontend/src/lib/api.ts
@@ -3023,6 +3023,8 @@ export interface Directive {
prUrl: string | null;
prBranch: string | null;
completionTaskId: string | null;
+ /** Whether the memory system is enabled for this directive */
+ memoryEnabled: boolean;
goalUpdatedAt: string;
startedAt: string | null;
version: number;
@@ -3060,6 +3062,8 @@ export interface DirectiveSummary {
orchestratorTaskId: string | null;
prUrl: string | null;
completionTaskId: string | null;
+ /** Whether the memory system is enabled for this directive */
+ memoryEnabled: boolean;
version: number;
createdAt: string;
updatedAt: string;
@@ -3080,6 +3084,8 @@ export interface CreateDirectiveRequest {
repositoryUrl?: string;
localPath?: string;
baseBranch?: string;
+ /** Enable the memory system for this directive (default: false) */
+ memoryEnabled?: boolean;
}
export interface UpdateDirectiveRequest {
@@ -3090,6 +3096,8 @@ export interface UpdateDirectiveRequest {
localPath?: string;
baseBranch?: string;
orchestratorTaskId?: string;
+ /** Enable or disable the memory system for this directive */
+ memoryEnabled?: boolean;
version?: number;
}
@@ -3230,4 +3238,179 @@ export async function updateDirectiveGoal(id: string, goal: string): Promise<Dir
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();
+}