feat(#37-41): Add domains, ideas, relationships, agents, widgets schema

Schema additions for issues #37-41:

New models:
- Domain (#37): Life domains (work, marriage, homelab, etc.)
- Idea (#38): Brain dumps with pgvector embeddings
- Relationship (#39): Generic entity linking (blocks, depends_on)
- Agent (#40): ClawdBot agent tracking with metrics
- AgentSession (#40): Conversation session tracking
- WidgetDefinition (#41): HUD widget registry
- UserLayout (#41): Per-user dashboard configuration

Updated models:
- Task, Event, Project: Added domainId foreign key
- User, Workspace: Added new relations

New enums:
- IdeaStatus: CAPTURED, PROCESSING, ACTIONABLE, ARCHIVED, DISCARDED
- RelationshipType: BLOCKS, BLOCKED_BY, DEPENDS_ON, etc.
- AgentStatus: IDLE, WORKING, WAITING, ERROR, TERMINATED
- EntityType: Added IDEA, DOMAIN

Migration: 20260129182803_add_domains_ideas_agents_widgets
This commit is contained in:
Jason Woltje
2026-01-29 12:29:21 -06:00
parent a220c2dc0a
commit 973502f26e
308 changed files with 18374 additions and 113 deletions

View File

@@ -0,0 +1,90 @@
/**
* API Client for Mosaic Stack
* Handles authenticated requests to the backend API
*/
const API_BASE_URL = process.env.NEXT_PUBLIC_API_URL || "http://localhost:3001";
export interface ApiError {
code: string;
message: string;
details?: unknown;
}
export interface ApiResponse<T> {
data: T;
meta?: {
total?: number;
page?: number;
limit?: number;
};
}
/**
* Make an authenticated API request
*/
export async function apiRequest<T>(
endpoint: string,
options: RequestInit = {}
): Promise<T> {
const url = `${API_BASE_URL}${endpoint}`;
const response = await fetch(url, {
...options,
headers: {
"Content-Type": "application/json",
...options.headers,
},
credentials: "include", // Include cookies for session
});
if (!response.ok) {
const error: ApiError = await response.json().catch(() => ({
code: "UNKNOWN_ERROR",
message: response.statusText || "An unknown error occurred",
}));
throw new Error(error.message);
}
return response.json();
}
/**
* GET request helper
*/
export async function apiGet<T>(endpoint: string): Promise<T> {
return apiRequest<T>(endpoint, { method: "GET" });
}
/**
* POST request helper
*/
export async function apiPost<T>(endpoint: string, data?: unknown): Promise<T> {
const options: RequestInit = {
method: "POST",
};
if (data !== undefined) {
options.body = JSON.stringify(data);
}
return apiRequest<T>(endpoint, options);
}
/**
* PATCH request helper
*/
export async function apiPatch<T>(endpoint: string, data: unknown): Promise<T> {
return apiRequest<T>(endpoint, {
method: "PATCH",
body: JSON.stringify(data),
});
}
/**
* DELETE request helper
*/
export async function apiDelete<T>(endpoint: string): Promise<T> {
return apiRequest<T>(endpoint, { method: "DELETE" });
}