summaryrefslogtreecommitdiff
path: root/makima/frontend/src/lib/api.ts
diff options
context:
space:
mode:
authorsoryu <soryu@soryu.co>2026-01-21 17:31:46 +0000
committerGitHub <noreply@github.com>2026-01-21 17:31:46 +0000
commit94e5604e770d6589f786ea71e51738e21492f301 (patch)
tree6c9b0f32a8d77464bc1a5131ba0828d252851abc /makima/frontend/src/lib/api.ts
parentda246c4c4e23c9ad976705f9a3fa80e0d75b4425 (diff)
downloadsoryu-94e5604e770d6589f786ea71e51738e21492f301.tar.gz
soryu-94e5604e770d6589f786ea71e51738e21492f301.zip
Add task branching feature (#15)
Diffstat (limited to 'makima/frontend/src/lib/api.ts')
-rw-r--r--makima/frontend/src/lib/api.ts47
1 files changed, 45 insertions, 2 deletions
diff --git a/makima/frontend/src/lib/api.ts b/makima/frontend/src/lib/api.ts
index 14ec9f2..86ff06c 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> {