summaryrefslogtreecommitdiff
path: root/makima/frontend/src/lib/api.ts
diff options
context:
space:
mode:
Diffstat (limited to 'makima/frontend/src/lib/api.ts')
-rw-r--r--makima/frontend/src/lib/api.ts74
1 files changed, 74 insertions, 0 deletions
diff --git a/makima/frontend/src/lib/api.ts b/makima/frontend/src/lib/api.ts
index 458b69d..155c716 100644
--- a/makima/frontend/src/lib/api.ts
+++ b/makima/frontend/src/lib/api.ts
@@ -1258,6 +1258,76 @@ export function getDaemonDownloadUrl(platform: string): string {
}
// =============================================================================
+// Daemon Reauthorization
+// =============================================================================
+
+/** Response from the trigger daemon reauth endpoint */
+export interface TriggerReauthResponse {
+ success: boolean;
+ daemonId: string;
+ requestId: string;
+}
+
+/** Response from the reauth status polling endpoint */
+export interface ReauthStatusResponse {
+ status: string; // "pending" | "url_ready" | "completed" | "failed"
+ loginUrl?: string;
+ error?: string;
+}
+
+/**
+ * Trigger OAuth re-authentication on a daemon.
+ * Sends a reauth command to the daemon, which will spawn `claude setup-token`
+ * and return the OAuth login URL.
+ */
+export async function triggerDaemonReauth(daemonId: string): Promise<TriggerReauthResponse> {
+ const res = await authFetch(`${API_BASE}/api/v1/mesh/daemons/${daemonId}/reauth`, {
+ method: "POST",
+ });
+ if (!res.ok) {
+ const errorData = await res.json().catch(() => ({}));
+ throw new Error(errorData.message || `Failed to trigger reauth: ${res.statusText}`);
+ }
+ return res.json();
+}
+
+/**
+ * Submit an OAuth auth code to a daemon's pending reauth flow.
+ */
+export async function submitDaemonAuthCode(
+ daemonId: string,
+ code: string,
+ requestId: string,
+): Promise<void> {
+ const res = await authFetch(`${API_BASE}/api/v1/mesh/daemons/${daemonId}/reauth/code`, {
+ method: "POST",
+ body: JSON.stringify({ code, requestId }),
+ });
+ if (!res.ok) {
+ const errorData = await res.json().catch(() => ({}));
+ throw new Error(errorData.message || `Failed to submit auth code: ${res.statusText}`);
+ }
+}
+
+/**
+ * Get the status of a daemon reauth request.
+ * Used for polling to track reauth flow progress.
+ */
+export async function getDaemonReauthStatus(
+ daemonId: string,
+ requestId: string,
+): Promise<ReauthStatusResponse> {
+ const res = await authFetch(
+ `${API_BASE}/api/v1/mesh/daemons/${daemonId}/reauth/${requestId}/status`,
+ );
+ if (!res.ok) {
+ const errorData = await res.json().catch(() => ({}));
+ throw new Error(errorData.message || `Failed to get reauth status: ${res.statusText}`);
+ }
+ return res.json();
+}
+
+// =============================================================================
// Mesh Chat Types for Task Orchestration
// =============================================================================
@@ -3081,6 +3151,10 @@ export interface DirectiveStep {
dependsOn: string[];
status: StepStatus;
taskId: string | null;
+ /** Contract ID for contract-backed steps */
+ contractId?: string | null;
+ /** Contract type (e.g. "simple", "specification", "execute") for contract-backed steps */
+ contractType?: string | null;
orderIndex: number;
generation: number;
startedAt: string | null;