summaryrefslogtreecommitdiff
path: root/makima/frontend/src/lib/api.ts
diff options
context:
space:
mode:
authorsoryu <soryu@soryu.co>2026-02-07 01:11:26 +0000
committersoryu <soryu@soryu.co>2026-02-07 01:11:26 +0000
commit9e9f18884c78c21f5785908fb7ccd00e2fa5436b (patch)
treef2ca7c2a3db5350186282ae0be0e539aa77c0320 /makima/frontend/src/lib/api.ts
parentb8d563d45f14a2b1db1f684aa0a8dcd7e5b6ad56 (diff)
downloadsoryu-9e9f18884c78c21f5785908fb7ccd00e2fa5436b.tar.gz
soryu-9e9f18884c78c21f5785908fb7ccd00e2fa5436b.zip
Add new directive initial implementation
Diffstat (limited to 'makima/frontend/src/lib/api.ts')
-rw-r--r--makima/frontend/src/lib/api.ts158
1 files changed, 158 insertions, 0 deletions
diff --git a/makima/frontend/src/lib/api.ts b/makima/frontend/src/lib/api.ts
index 9f5ff88..6c450eb 100644
--- a/makima/frontend/src/lib/api.ts
+++ b/makima/frontend/src/lib/api.ts
@@ -3003,3 +3003,161 @@ export async function listTaskPatches(taskId: string, contractId: string): Promi
return res.json();
}
+// =============================================================================
+// Directive Types & API
+// =============================================================================
+
+export type DirectiveStatus = "draft" | "planning" | "active" | "paused" | "completed" | "archived" | "failed";
+export type AutonomyLevel = "full_auto" | "guardrails" | "manual";
+
+export interface DirectiveSummary {
+ id: string;
+ title: string;
+ goal: string;
+ status: DirectiveStatus;
+ autonomyLevel: AutonomyLevel;
+ chainCount: number;
+ stepCount: number;
+ totalCostUsd: number;
+ version: number;
+ createdAt: string;
+ updatedAt: string;
+}
+
+export interface Directive {
+ id: string;
+ ownerId: string;
+ title: string;
+ goal: string;
+ requirements: unknown[];
+ acceptanceCriteria: unknown[];
+ constraints: unknown[];
+ externalDependencies: unknown[];
+ status: DirectiveStatus;
+ autonomyLevel: AutonomyLevel;
+ confidenceThresholdGreen: number;
+ confidenceThresholdYellow: number;
+ maxTotalCostUsd: number | null;
+ maxWallTimeMinutes: number | null;
+ maxReworkCycles: number | null;
+ maxChainRegenerations: number | null;
+ repositoryUrl: string | null;
+ localPath: string | null;
+ baseBranch: string | null;
+ orchestratorContractId: string | null;
+ currentChainId: string | null;
+ chainGenerationCount: number;
+ totalCostUsd: number;
+ startedAt: string | null;
+ completedAt: string | null;
+ version: number;
+ createdAt: string;
+ updatedAt: string;
+}
+
+export interface DirectiveChain {
+ id: string;
+ directiveId: string;
+ generation: number;
+ name: string;
+ description: string | null;
+ rationale: string | null;
+ planningModel: string | null;
+ status: string;
+ totalSteps: number;
+ completedSteps: number;
+ failedSteps: number;
+ currentConfidence: number | null;
+ startedAt: string | null;
+ completedAt: string | null;
+ version: number;
+ createdAt: string;
+ updatedAt: string;
+}
+
+export interface DirectiveWithChains extends Directive {
+ chains: DirectiveChain[];
+}
+
+export interface DirectiveListResponse {
+ directives: DirectiveSummary[];
+ total: number;
+}
+
+export interface CreateDirectiveRequest {
+ title: string;
+ goal: string;
+ requirements?: unknown[];
+ acceptanceCriteria?: unknown[];
+ constraints?: unknown[];
+ externalDependencies?: unknown[];
+ autonomyLevel?: AutonomyLevel;
+ repositoryUrl?: string;
+ localPath?: string;
+ baseBranch?: string;
+}
+
+export interface UpdateDirectiveRequest {
+ title?: string;
+ goal?: string;
+ status?: DirectiveStatus;
+ autonomyLevel?: AutonomyLevel;
+ version?: number;
+}
+
+export async function listDirectives(): Promise<DirectiveListResponse> {
+ const res = await authFetch(`${API_BASE}/api/v1/directives`);
+ if (!res.ok) {
+ throw new Error(`Failed to list directives: ${res.statusText}`);
+ }
+ return res.json();
+}
+
+export async function getDirective(id: string): Promise<DirectiveWithChains> {
+ const res = await authFetch(`${API_BASE}/api/v1/directives/${id}`);
+ if (!res.ok) {
+ throw new Error(`Failed to get directive: ${res.statusText}`);
+ }
+ return res.json();
+}
+
+export async function createDirective(
+ data: CreateDirectiveRequest
+): Promise<Directive> {
+ const res = await authFetch(`${API_BASE}/api/v1/directives`, {
+ method: "POST",
+ body: JSON.stringify(data),
+ });
+ if (!res.ok) {
+ throw new Error(`Failed to create directive: ${res.statusText}`);
+ }
+ return res.json();
+}
+
+export async function updateDirective(
+ id: string,
+ data: UpdateDirectiveRequest
+): Promise<Directive> {
+ const res = await authFetch(`${API_BASE}/api/v1/directives/${id}`, {
+ method: "PUT",
+ body: JSON.stringify(data),
+ });
+ if (res.status === 409) {
+ const conflict = (await res.json()) as ConflictErrorResponse;
+ throw new VersionConflictError(conflict);
+ }
+ if (!res.ok) {
+ throw new Error(`Failed to update directive: ${res.statusText}`);
+ }
+ return res.json();
+}
+
+export async function deleteDirective(id: string): Promise<void> {
+ const res = await authFetch(`${API_BASE}/api/v1/directives/${id}`, {
+ method: "DELETE",
+ });
+ if (!res.ok) {
+ throw new Error(`Failed to delete directive: ${res.statusText}`);
+ }
+}
+