diff options
| author | soryu <soryu@soryu.co> | 2026-05-17 21:23:20 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-05-17 21:23:20 +0100 |
| commit | 0d996cf7590e3e52f424859c7d6f0e68640f119e (patch) | |
| tree | 0f3898d9e2e2a3c312358dbf70c44f4ab1cf3648 /makima/frontend/src/lib/api.ts | |
| parent | ce29ae801bcc5a0ba76d5a8d1565242ab267a47d (diff) | |
| download | soryu-0d996cf7590e3e52f424859c7d6f0e68640f119e.tar.gz soryu-0d996cf7590e3e52f424859c7d6f0e68640f119e.zip | |
chore: remove LLM module + all dependent surfaces (#135)
Wholesale removal of the LLM integration layer. ~14,200 LOC deleted
across backend and frontend. All chat-driven UIs go with it.
## Backend
- Delete `src/llm/` (7,400 LOC): claude/groq clients, contract_tools,
contract_evaluator, discuss_tools, mesh_tools, phase_guidance,
task_output, templates, markdown round-trip, tools, transcript_analyzer.
- Delete handlers wholly dependent on LLM:
- `chat.rs` (file-level LLM chat at /files/{id}/chat)
- `mesh_chat.rs` (mesh & task LLM chat + history)
- `templates.rs` (/contract-types listing)
- Strip LLM uses from `mesh_daemon.rs`:
- `compute_action_directive` (used phase_guidance::check_deliverables_met
to nudge supervisors with "all tasks done" messages). The auto-PR
path below still fires when all tasks finish, so no behaviour lost.
- `crate::llm::markdown_to_body` → inline 1-line replacement that
wraps markdown content in a single BodyElement::Markdown. The
editor re-parses on display, so round-trip is preserved.
- Drop routes: /files/{id}/chat, /mesh/chat, /mesh/chat/history,
/mesh/tasks/{id}/chat, /contract-types.
- Drop the matching openapi registrations.
## Frontend
- Delete components that were LLM-only:
- `mesh/UnifiedMeshChatInput.tsx`
- `listen/DiscussContractModal.tsx`
- `listen/TranscriptAnalysisPanel.tsx`
- `listen/ContractPickerModal.tsx`
- `files/CliInput.tsx`
- Delete the entire /listen page (its primary value-add was
voice → LLM analysis → contract creation; without LLM the page is
just a transcript display with no obvious user purpose).
- Delete `hooks/useMeshChatHistory.ts` and `lib/listenApi.ts`
(transcript-analysis API client to the already-Phase-5-removed
listen handlers).
- Strip api.ts of LLM exports: LlmModel, ChatMessage/Request/Response,
UserQuestion/Answer, chatWithFile, MeshChat* types & functions,
getMeshChatHistory, clearMeshChatHistory, chatWithMeshContext,
ContractTypeTemplate, listContractTypes, chatWithContract,
getContractChatHistory, clearContractChatHistory, discussContract,
PhaseDefinition, DeliverableDefinition.
- mesh.tsx: drop UnifiedMeshChatInput render + the chatContext memo +
handleTaskUpdatedFromCli (only consumer was the input).
- files.tsx: drop CliInput render + handleGenerateFromElement +
handleBodyUpdate + handleClearFocus + suggestedPrompt state (all
CliInput-only).
- NavStrip: drop the /listen link.
- main.tsx: drop the /listen route.
## Net diff: 37 files changed, 58 insertions, 14,281 deletions.
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'makima/frontend/src/lib/api.ts')
| -rw-r--r-- | makima/frontend/src/lib/api.ts | 466 |
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 |
