summaryrefslogtreecommitdiff
path: root/makima/frontend/src/lib
diff options
context:
space:
mode:
Diffstat (limited to 'makima/frontend/src/lib')
-rw-r--r--makima/frontend/src/lib/api.ts59
1 files changed, 59 insertions, 0 deletions
diff --git a/makima/frontend/src/lib/api.ts b/makima/frontend/src/lib/api.ts
index 3fcd728..4d664cf 100644
--- a/makima/frontend/src/lib/api.ts
+++ b/makima/frontend/src/lib/api.ts
@@ -3509,6 +3509,65 @@ export async function newDirectiveDraft(
return res.json();
}
+/**
+ * Request body for spawning an ephemeral task under a directive. The task is
+ * not part of the DAG — it lives alongside the directive's planned steps but
+ * the orchestrator ignores it.
+ */
+export interface CreateDirectiveTaskRequest {
+ name: string;
+ plan: string;
+ /** Override the directive's repository_url; defaults to the directive's. */
+ repositoryUrl?: string;
+ /** Override the directive's base_branch; defaults to the directive's. */
+ baseBranch?: string;
+}
+
+/**
+ * List ephemeral tasks (directive_id set, directive_step_id NULL) attached
+ * to a directive. Backs the "spinoff" group inside each directive folder
+ * in the document-mode sidebar.
+ */
+export async function listDirectiveEphemeralTasks(
+ directiveId: string,
+): Promise<TaskListResponse> {
+ const res = await authFetch(`${API_BASE}/api/v1/directives/${directiveId}/tasks`);
+ if (!res.ok) {
+ throw new Error(`Failed to list directive tasks: ${res.statusText}`);
+ }
+ return res.json();
+}
+
+export async function createDirectiveTask(
+ directiveId: string,
+ req: CreateDirectiveTaskRequest,
+): Promise<Task> {
+ const res = await authFetch(
+ `${API_BASE}/api/v1/directives/${directiveId}/tasks`,
+ {
+ method: "POST",
+ headers: { "Content-Type": "application/json" },
+ body: JSON.stringify(req),
+ },
+ );
+ if (!res.ok) {
+ throw new Error(`Failed to create directive task: ${res.statusText}`);
+ }
+ return res.json();
+}
+
+/**
+ * List tasks not attached to any directive (and not subtasks). Backs the
+ * `tmp/` pseudo-folder in the document-mode sidebar.
+ */
+export async function listOrphanTasks(): Promise<TaskListResponse> {
+ const res = await authFetch(`${API_BASE}/api/v1/mesh/tasks?orphan=true`);
+ if (!res.ok) {
+ throw new Error(`Failed to list orphan tasks: ${res.statusText}`);
+ }
+ return res.json();
+}
+
export async function createDirectivePR(id: string): Promise<DirectiveWithSteps> {
const res = await authFetch(`${API_BASE}/api/v1/directives/${id}/create-pr`, { method: "POST" });
if (!res.ok) throw new Error(`Failed to create PR: ${res.statusText}`);