From 2ee09745c12f0762ab99fadb00cdc0c363cb027b Mon Sep 17 00:00:00 2001 From: soryu Date: Mon, 26 Jan 2026 19:15:03 +0000 Subject: [WIP] Heartbeat checkpoint - 2026-01-26 19:15:03 UTC --- makima/frontend/src/lib/api.ts | 142 ++++++++++++++++++++++++++++++----------- 1 file changed, 106 insertions(+), 36 deletions(-) (limited to 'makima/frontend/src/lib/api.ts') diff --git a/makima/frontend/src/lib/api.ts b/makima/frontend/src/lib/api.ts index 64ce591..4a7486f 100644 --- a/makima/frontend/src/lib/api.ts +++ b/makima/frontend/src/lib/api.ts @@ -811,6 +811,112 @@ export async function retryCompletionAction( return res.json(); } +// ============================================================================= +// Git Actions for Tasks (Manual) +// ============================================================================= + +/** Response from export patch */ +export interface ExportPatchResponse { + success: boolean; + taskId: string; + fileName: string; + filePath?: string; + patchSize?: number; + message: string; +} + +/** + * Export a task's changes as a patch file. + * The patch will be saved to the contract's patch directory. + */ +export async function exportTaskPatch( + taskId: string, + fileName?: string +): Promise { + const body: Record = {}; + if (fileName) { + body.fileName = fileName; + } + const res = await authFetch(`${API_BASE}/api/v1/mesh/tasks/${taskId}/export-patch`, { + method: "POST", + body: JSON.stringify(body), + }); + if (!res.ok) { + const errorText = await res.text(); + throw new Error(`Failed to export patch: ${errorText || res.statusText}`); + } + return res.json(); +} + +/** Response from push branch */ +export interface PushBranchResponse { + success: boolean; + taskId: string; + branchName: string; + remote?: string; + message: string; +} + +/** + * Push a task's changes to a remote branch. + * Creates a branch if it doesn't exist and pushes the commits. + */ +export async function pushTaskBranch( + taskId: string, + branchName?: string +): Promise { + const body: Record = {}; + if (branchName) { + body.branchName = branchName; + } + const res = await authFetch(`${API_BASE}/api/v1/mesh/tasks/${taskId}/push-branch`, { + method: "POST", + body: JSON.stringify(body), + }); + if (!res.ok) { + const errorText = await res.text(); + throw new Error(`Failed to push branch: ${errorText || res.statusText}`); + } + return res.json(); +} + +/** Response from create PR */ +export interface CreatePRResponse { + success: boolean; + taskId: string; + prUrl?: string; + prNumber?: number; + branchName?: string; + message: string; +} + +/** + * Create a pull request for a task's changes. + * First pushes the branch if needed, then creates the PR. + */ +export async function createTaskPR( + taskId: string, + title?: string, + body?: string +): Promise { + const reqBody: Record = {}; + if (title) { + reqBody.title = title; + } + if (body) { + reqBody.body = body; + } + const res = await authFetch(`${API_BASE}/api/v1/mesh/tasks/${taskId}/create-pr`, { + method: "POST", + body: JSON.stringify(reqBody), + }); + if (!res.ok) { + const errorText = await res.text(); + throw new Error(`Failed to create PR: ${errorText || res.statusText}`); + } + return res.json(); +} + /** A suggested directory from a connected daemon */ export interface DaemonDirectory { /** Path to the directory */ @@ -2044,42 +2150,6 @@ export async function getTemplate(id: string): Promise { return res.json(); } -// ============================================================================= -// Contract Type Templates (Workflow Definitions) -// ============================================================================= - -/** A contract type template defining a workflow */ -export interface ContractTypeTemplate { - /** Unique identifier (e.g., 'simple', 'specification', 'feature-development') */ - id: string; - /** Display name */ - name: string; - /** What this contract type is for */ - description: string; - /** Ordered list of phases in the workflow */ - phases: string[]; - /** Starting phase */ - defaultPhase: string; - /** True for built-in types ('simple', 'specification') */ - isBuiltin: boolean; -} - -export interface ListContractTypesResponse { - contractTypes: ContractTypeTemplate[]; -} - -/** - * List all available contract type templates. - * Returns built-in types (simple, specification) and any custom types. - */ -export async function listContractTypes(): Promise { - 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(); -} - // ============================================================================= // Supervisor Question Types and Functions // ============================================================================= -- cgit v1.2.3