diff options
| -rw-r--r-- | makima/frontend/src/lib/api.ts | 47 |
1 files changed, 45 insertions, 2 deletions
diff --git a/makima/frontend/src/lib/api.ts b/makima/frontend/src/lib/api.ts index 78e52cd..f34ba57 100644 --- a/makima/frontend/src/lib/api.ts +++ b/makima/frontend/src/lib/api.ts @@ -607,8 +607,8 @@ export interface TaskListResponse { } export interface CreateTaskRequest { - /** Contract this task belongs to (required) */ - contractId: string; + /** Contract this task belongs to (optional - can be standalone) */ + contractId?: string; name: string; description?: string; plan: string; @@ -974,6 +974,49 @@ export async function listSubtasks(taskId: string): Promise<TaskListResponse> { return res.json(); } +// ============================================================================= +// Task Branching +// ============================================================================= + +/** Request to branch a task */ +export interface BranchTaskRequest { + /** Message to send to the new branched task */ + message: string; + /** Optional name for the new task (defaults to "Branch of {original task name}") */ + name?: string; + /** Whether to include conversation history from the source task */ + includeConversation?: boolean; +} + +/** Response from branching a task */ +export interface BranchTaskResponse { + /** The newly created task */ + task: Task; + /** Number of conversation messages copied to the new task */ + messageCount: number; + /** ID of the daemon assigned to the new task (null if not yet assigned) */ + daemonId: string | null; +} + +/** + * Branch a task to create a new task with the same state. + * Copies the worktree and optionally the conversation history. + */ +export async function branchTask( + taskId: string, + request: BranchTaskRequest +): Promise<BranchTaskResponse> { + const res = await authFetch(`${API_BASE}/api/v1/mesh/tasks/${taskId}/branch`, { + method: "POST", + body: JSON.stringify(request), + }); + if (!res.ok) { + const errorText = await res.text(); + throw new Error(`Failed to branch task: ${errorText || res.statusText}`); + } + return res.json(); +} + export async function listTaskEvents( taskId: string ): Promise<TaskEventListResponse> { |
