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.ts466
1 files changed, 14 insertions, 452 deletions
diff --git a/makima/frontend/src/lib/api.ts b/makima/frontend/src/lib/api.ts
index b34f786..b7b904e 100644
--- a/makima/frontend/src/lib/api.ts
+++ b/makima/frontend/src/lib/api.ts
@@ -220,51 +220,9 @@ export class VersionConflictError extends Error {
}
}
-// Available LLM models
-export type LlmModel = "claude-sonnet" | "claude-opus" | "groq";
-
-// Chat API types
-export interface ChatMessage {
- role: "user" | "assistant";
- content: string;
-}
-
-export interface ChatRequest {
- message: string;
- model?: LlmModel;
- history?: ChatMessage[];
- focusedElementIndex?: number;
-}
-
-export interface ToolCallInfo {
- name: string;
- result: {
- success: boolean;
- message: string;
- };
-}
-
-// User question types for interactive LLM tool
-export interface UserQuestion {
- id: string;
- question: string;
- options: string[];
- allowMultiple: boolean;
- allowCustom: boolean;
-}
-
-export interface UserAnswer {
- id: string;
- answers: string[];
-}
-
-export interface ChatResponse {
- response: string;
- toolCalls: ToolCallInfo[];
- updatedBody: BodyElement[];
- updatedSummary: string | null;
- pendingQuestions?: UserQuestion[];
-}
+// (LlmModel, ChatMessage, ChatRequest, UserQuestion, UserAnswer,
+// ChatResponse, ToolCallInfo removed alongside the LLM module —
+// see Chat API function block further down + the deleted /llm/ tree.)
// File API functions
export async function listFiles(): Promise<FileListResponse> {
@@ -323,34 +281,7 @@ export async function deleteFile(id: string): Promise<void> {
}
}
-// Chat API function
-export async function chatWithFile(
- id: string,
- message: string,
- model?: LlmModel,
- history?: ChatMessage[],
- focusedElementIndex?: number
-): Promise<ChatResponse> {
- const body: ChatRequest = { message };
- if (model) {
- body.model = model;
- }
- if (history && history.length > 0) {
- body.history = history;
- }
- if (focusedElementIndex !== undefined) {
- body.focusedElementIndex = focusedElementIndex;
- }
- const res = await authFetch(`${API_BASE}/api/v1/files/${id}/chat`, {
- method: "POST",
- body: JSON.stringify(body),
- });
- if (!res.ok) {
- const errorText = await res.text();
- throw new Error(`Chat failed: ${errorText || res.statusText}`);
- }
- return res.json();
-}
+// chatWithFile removed — handler `/api/v1/files/{id}/chat` is gone.
// Version history types
export type VersionSource = "user" | "llm" | "system";
@@ -1327,186 +1258,9 @@ export async function getDaemonReauthStatus(
return res.json();
}
-// =============================================================================
-// Mesh Chat Types for Task Orchestration
-// =============================================================================
-
-export interface MeshChatMessage {
- role: "user" | "assistant";
- content: string;
-}
-
-export interface MeshChatRequest {
- message: string;
- model?: LlmModel;
- history?: MeshChatMessage[];
-}
-
-export interface MeshToolCallInfo {
- name: string;
- result: {
- success: boolean;
- message: string;
- };
-}
-
-export interface MeshChatResponse {
- response: string;
- toolCalls: MeshToolCallInfo[];
- pendingQuestions?: UserQuestion[];
-}
-
-// Mesh Chat API functions
-
-// Top-level mesh chat (no specific task context)
-export async function chatWithMesh(
- message: string,
- model?: LlmModel,
- history?: MeshChatMessage[]
-): Promise<MeshChatResponse> {
- const body: MeshChatRequest = { message };
- if (model) {
- body.model = model;
- }
- if (history && history.length > 0) {
- body.history = history;
- }
- const res = await authFetch(`${API_BASE}/api/v1/mesh/chat`, {
- method: "POST",
- body: JSON.stringify(body),
- });
- if (!res.ok) {
- const errorText = await res.text();
- throw new Error(`Mesh chat failed: ${errorText || res.statusText}`);
- }
- return res.json();
-}
-
-// Task-scoped mesh chat
-export async function chatWithTask(
- taskId: string,
- message: string,
- model?: LlmModel,
- history?: MeshChatMessage[]
-): Promise<MeshChatResponse> {
- const body: MeshChatRequest = { message };
- if (model) {
- body.model = model;
- }
- if (history && history.length > 0) {
- body.history = history;
- }
- const res = await authFetch(`${API_BASE}/api/v1/mesh/tasks/${taskId}/chat`, {
- method: "POST",
- body: JSON.stringify(body),
- });
- if (!res.ok) {
- const errorText = await res.text();
- throw new Error(`Mesh chat failed: ${errorText || res.statusText}`);
- }
- return res.json();
-}
-
-// =============================================================================
-// Mesh Chat History Types
-// =============================================================================
-
-export type MeshChatContextType = "mesh" | "task" | "subtask";
-
-export interface MeshChatContext {
- type: MeshChatContextType;
- taskId?: string;
- parentTaskId?: string;
-}
-
-export interface MeshChatMessageRecord {
- id: string;
- conversationId: string;
- role: "user" | "assistant" | "error";
- content: string;
- contextType: MeshChatContextType;
- contextTaskId: string | null;
- toolCalls: MeshToolCallInfo[] | null;
- pendingQuestions: UserQuestion[] | null;
- createdAt: string;
-}
-
-export interface MeshChatHistoryResponse {
- conversationId: string;
- messages: MeshChatMessageRecord[];
-}
-
-export interface MeshChatWithContextRequest {
- message: string;
- model?: LlmModel;
- contextType?: MeshChatContextType;
- contextTaskId?: string;
-}
-
-// =============================================================================
-// Mesh Chat History API Functions
-// =============================================================================
-
-/**
- * Get the current chat history from the database
- */
-export async function getMeshChatHistory(): Promise<MeshChatHistoryResponse> {
- const res = await authFetch(`${API_BASE}/api/v1/mesh/chat/history`);
- if (!res.ok) {
- throw new Error(`Failed to get chat history: ${res.statusText}`);
- }
- return res.json();
-}
-
-/**
- * Clear chat history (archives current conversation, starts new one)
- */
-export async function clearMeshChatHistory(): Promise<{ success: boolean; conversationId: string }> {
- const res = await authFetch(`${API_BASE}/api/v1/mesh/chat/history`, {
- method: "DELETE",
- });
- if (!res.ok) {
- throw new Error(`Failed to clear chat history: ${res.statusText}`);
- }
- return res.json();
-}
-
-/**
- * Chat with mesh using context (new approach with DB history)
- */
-export async function chatWithMeshContext(
- message: string,
- context: MeshChatContext,
- model?: LlmModel
-): Promise<MeshChatResponse> {
- const body: MeshChatWithContextRequest = {
- message,
- contextType: context.type,
- };
-
- if (model) {
- body.model = model;
- }
-
- // Set contextTaskId based on context type
- if (context.type === "task" && context.taskId) {
- body.contextTaskId = context.taskId;
- } else if (context.type === "subtask" && context.taskId) {
- body.contextTaskId = context.taskId;
- }
-
- // Use top-level endpoint (it now loads history from DB)
- const res = await authFetch(`${API_BASE}/api/v1/mesh/chat`, {
- method: "POST",
- body: JSON.stringify(body),
- });
-
- if (!res.ok) {
- const errorText = await res.text();
- throw new Error(`Mesh chat failed: ${errorText || res.statusText}`);
- }
- return res.json();
-}
+// (Mesh chat types + chatWithMesh / chatWithTask / getMeshChatHistory /
+// clearMeshChatHistory / chatWithMeshContext / MeshChatContext etc.
+// removed alongside the LLM module — backend handlers gone.)
// =============================================================================
// API Key Management
@@ -1770,58 +1524,10 @@ export function getDefaultPhase(contractType: ContractType): ContractPhase {
return "research";
}
-// =============================================================================
-// Contract Type Templates
-// =============================================================================
-
-/** Contract type template returned by the API */
-export interface ContractTypeTemplate {
- /** Template identifier (e.g., "simple", "specification") */
- id: string;
- /** Display name */
- name: string;
- /** Description of the contract type workflow */
- description: string;
- /** Ordered list of phases for this contract type */
- phases: ContractPhase[];
- /** Default starting phase */
- defaultPhase: ContractPhase;
- /** Whether this is a built-in type (always available) */
- isBuiltin: boolean;
- /** Optional mapping from phase ID to display name */
- phaseNames?: Record<string, string>;
-}
-
-/** Response from list contract types endpoint */
-export interface ListContractTypesResponse {
- contractTypes: ContractTypeTemplate[];
-}
-
-/** Phase definition for custom templates */
-export interface PhaseDefinition {
- id: string;
- name: string;
- order: number;
-}
-
-/** Deliverable definition for custom templates */
-export interface DeliverableDefinition {
- id: string;
- name: string;
- priority: "required" | "recommended" | "optional";
-}
-
-/**
- * List available contract types.
- * Returns built-in types only (simple, specification, execute).
- */
-export async function listContractTypes(): Promise<ListContractTypesResponse> {
- const res = await authFetch(`${API_BASE}/api/v1/contract-types`);
- if (!res.ok) {
- throw new Error(`Failed to list contract types: ${res.statusText}`);
- }
- return res.json();
-}
+// (ContractTypeTemplate / ListContractTypesResponse / PhaseDefinition /
+// DeliverableDefinition / listContractTypes removed alongside the LLM
+// module — the templates handler was the only consumer and the
+// endpoint /api/v1/contract-types is gone.)
export interface ContractRepository {
id: string;
@@ -2194,153 +1900,9 @@ export async function removeTaskFromContract(
}
}
-// =============================================================================
-// Contract Chat Types and API
-// =============================================================================
-
-export interface ContractChatRequest {
- message: string;
- model?: LlmModel;
- history?: ChatMessage[];
-}
-
-export interface ContractToolCallInfo {
- name: string;
- result: {
- success: boolean;
- message: string;
- };
-}
-
-export interface ContractChatResponse {
- response: string;
- toolCalls: ContractToolCallInfo[];
- pendingQuestions?: UserQuestion[];
-}
-
-/**
- * Chat with a contract using LLM-powered management tools.
- */
-export async function chatWithContract(
- contractId: string,
- message: string,
- model?: LlmModel,
- history?: ChatMessage[]
-): Promise<ContractChatResponse> {
- const body: ContractChatRequest = { message };
- if (model) {
- body.model = model;
- }
- if (history && history.length > 0) {
- body.history = history;
- }
- const res = await authFetch(`${API_BASE}/api/v1/contracts/${contractId}/chat`, {
- method: "POST",
- body: JSON.stringify(body),
- });
- if (!res.ok) {
- const errorText = await res.text();
- throw new Error(`Contract chat failed: ${errorText || res.statusText}`);
- }
- return res.json();
-}
-
-// Contract chat history types
-export interface ContractChatMessage {
- id: string;
- conversationId: string;
- role: "user" | "assistant" | "error";
- content: string;
- toolCalls?: unknown;
- pendingQuestions?: unknown;
- createdAt: string;
-}
-
-export interface ContractChatHistoryResponse {
- contractId: string;
- conversationId: string;
- messages: ContractChatMessage[];
-}
-
-/** Get contract chat history */
-export async function getContractChatHistory(
- contractId: string
-): Promise<ContractChatHistoryResponse> {
- const res = await authFetch(
- `${API_BASE}/api/v1/contracts/${contractId}/chat/history`
- );
- if (!res.ok) {
- throw new Error(`Failed to fetch contract chat history: ${res.statusText}`);
- }
- return res.json();
-}
-
-/** Clear contract chat history (starts a new conversation) */
-export async function clearContractChatHistory(
- contractId: string
-): Promise<void> {
- const res = await authFetch(
- `${API_BASE}/api/v1/contracts/${contractId}/chat/history`,
- { method: "DELETE" }
- );
- if (!res.ok) {
- throw new Error(`Failed to clear contract chat history: ${res.statusText}`);
- }
-}
-
-// =============================================================================
-// Contract Discussion Types and API
-// =============================================================================
-
-export interface DiscussContractRequest {
- message: string;
- model?: LlmModel;
- history?: ChatMessage[];
- transcriptContext?: string;
-}
-
-export interface CreatedContractInfo {
- id: string;
- name: string;
- description: string | null;
- contractType: string;
- initialPhase: string;
-}
-
-export interface DiscussContractResponse {
- response: string;
- toolCalls: ContractToolCallInfo[];
- createdContract?: CreatedContractInfo;
- pendingQuestions?: UserQuestion[];
-}
-
-/**
- * Discuss a potential contract with Makima.
- * This is an ephemeral conversation that can result in contract creation.
- */
-export async function discussContract(
- message: string,
- model?: LlmModel,
- history?: ChatMessage[],
- transcriptContext?: string
-): Promise<DiscussContractResponse> {
- const body: DiscussContractRequest = { message };
- if (model) body.model = model;
- if (history && history.length > 0) body.history = history;
- if (transcriptContext) body.transcriptContext = transcriptContext;
-
- const res = await authFetch(`${API_BASE}/api/v1/contracts/discuss`, {
- method: "POST",
- body: JSON.stringify(body),
- });
-
- if (!res.ok) {
- const errorText = await res.text();
- throw new Error(`Discussion failed: ${errorText || res.statusText}`);
- }
-
- return res.json();
-}
+// (Contract Chat / Contract Discussion API removed alongside the LLM
+// module — legacy contracts chat handlers were already Phase-5
+// removed; these were the dead frontend half.)
// =============================================================================
// Template Types and API