diff options
Diffstat (limited to 'makima/frontend/src/lib/api.ts')
| -rw-r--r-- | makima/frontend/src/lib/api.ts | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/makima/frontend/src/lib/api.ts b/makima/frontend/src/lib/api.ts index 56491fd..bdaedf9 100644 --- a/makima/frontend/src/lib/api.ts +++ b/makima/frontend/src/lib/api.ts @@ -2137,6 +2137,60 @@ export async function clearContractChatHistory( } // ============================================================================= +// 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(); +} + +// ============================================================================= // Template Types and API // ============================================================================= |
