export interface PublicValidationDetails { "code": string; "reason": "not_array" | "invalid_array" | "invalid_item" | "option_not_allowed"; "path": string; "index"?: number; "option"?: string; } export interface ValidationFailureResponse { "ok": boolean; "error": string; "details"?: PublicValidationDetails; } export interface InvalidLoopStatusResponse { "ok": boolean; "error": string; } export interface AmbiguousNameResponse { "ok": boolean; "error": string; } export interface InvalidJsonResponse { "ok": boolean; "error": string; } export interface UnsupportedMediaTypeResponse { "ok": boolean; "error": string; } export interface InvalidWorkflowRecoveryBodyResponse { "ok": boolean; "error": string; } export interface WorkflowRecoveryConflictResponse { "ok": boolean; "error": "workflow_run_has_live_steps" | "workflow_run_step_ownership_unverifiable" | "workflow_run_not_running"; } export interface RunFinalizeConflictResponse { "ok": boolean; "error": "stale_claim" | "run_not_running" | "loop_advancement_conflict"; } export interface RunFinalizeValidationResponse { "ok": boolean; "error": "status_required" | "skip_status_requires_overlap_skip_exit_75"; } export interface StuckRunCandidate { "runId": string; "loopId": string; "snapshotId": string; } export interface StuckRunReportResponse { "ok": boolean; "report": { "state": "clear" | "stuck"; "expiredBefore": string; "candidates": Array; "truncated": boolean; }; } export interface StuckRunReconciliationInput { "candidates": Array; } export interface StuckRunReconciliationOutcome { "runId": string; "outcome": "recovered" | "already_recovered" | "conflict" | "operation_reconciliation_required"; "reason"?: string; } export interface StuckRunReconciliationResponse { "ok": boolean; "reconciliation": { "outcomes": Array; }; } export interface Foundation { "status": string; "version": string; "storage": "sqlite" | "postgresql"; "connection": "file" | "api"; "service"?: string; "detail"?: string; } export interface Loop { "id": string; "name": string; "description"?: string | null; "labels": Array; "status": "active" | "paused" | "stopped" | "expired"; "schedule"?: Record; "target"?: Record; "nextRunAt"?: string | null; "expiresAfterRuns"?: number | null; "createdAt"?: string; "updatedAt"?: string; "machine"?: LoopMachineRef; } export interface CreateLoopInput { "name": string; "description"?: string; "labels"?: Array; "schedule": Record; "target": Record; "expiresAfterRuns"?: number | null; "machine"?: LoopMachineRef; } export interface UpdateLoopInput { "status"?: "active" | "paused" | "stopped" | "expired"; "nextRunAt"?: string | null; "retryScheduledFor"?: string | null; "expiresAt"?: string | null; "expiresAfterRuns"?: number | null; "maxAttempts"?: number; "labels"?: Array; } export interface LoopMutationEnvelope { "schema": string; "operationId": string; "stepId": string; "targetId": string; "action": "pause" | "resume" | "stop"; "expectedRevision": string; "approvedPlanDigest": string; "manifestDigest": string; "descriptorRef": string; "descriptorDigest": string; "dryRun"?: boolean; } export interface LoopMutationBinding { "schema": string; "operationId": string; "stepId": string; "targetId": string; "action": "pause" | "resume" | "stop"; "expectedRevision": string; "approvedPlanDigest": string; "manifestDigest": string; "descriptorCommitment": string; "descriptorDigest": string; "dryRun"?: boolean; "authority": { "authorityId": string; "tenantId": string; }; "bindingDigest": string; "leaseId": string; } export interface LoopMutationAdmissionReceipt { "schema": string; "receiptId": string; "receiptKind": string; "state": string; "bindingDigest": string; "operationId": string; "stepId": string; "targetId": string; "action": "pause" | "resume" | "stop"; "expectedRevision": string; "authority": { "authorityId": string; "tenantId": string; }; "descriptorCommitment": string; "descriptorDigest": string; "createdAt": string; } export interface LoopMutationTerminalReceipt { "schema": string; "receiptId": string; "receiptKind": string; "state": "succeeded" | "dry_run"; "bindingDigest": string; "resultRevision": string; "resultStatus": "active" | "paused" | "stopped" | "expired"; } export interface LoopMutationResponse { "ok": boolean; "mutation": { "binding": LoopMutationBinding; "admission": LoopMutationAdmissionReceipt; "terminal": LoopMutationTerminalReceipt; "loop": Loop; "replayed": boolean; }; } export interface Run { "id": string; "loopId": string; "status": string; "attempt"?: number; "scheduledFor"?: string; "startedAt"?: string | null; "finishedAt"?: string | null; } export interface LoopResponse { "ok": boolean; "loop": Loop; } export interface LoopListResponse { "ok": boolean; "loops": Array; } export interface RunResponse { "ok": boolean; "run": Run; } export interface RunListResponse { "ok": boolean; "runs": Array; } export interface DeleteResponse { "ok": boolean; "deleted": boolean; } export type RunReceiptMachine = string | Record; export interface RunReceiptSummary { "text"?: string; "stdout_bytes": number; "stderr_bytes": number; "stdout_excerpt"?: string; "stderr_excerpt"?: string; "error"?: string; "duration_ms"?: number; } export interface RunReceipt { "loop_id": string; "run_id": string; "machine": RunReceiptMachine; "repo": string; "task_ids": Array; "knowledge_ids": Array; "digest_id": string; "started_at": string | null; "finished_at": string | null; "status": string; "exit_code": number | null; "summary": RunReceiptSummary; "evidence_paths": Array; "created_at": string; "updated_at": string; } export interface WriteRunReceiptInput { "loop_id"?: string; "run_id": string; "machine"?: RunReceiptMachine; "repo"?: string; "task_ids"?: Array; "knowledge_ids"?: Array; "digest_id"?: string; "started_at"?: string | null; "finished_at"?: string | null; "status"?: string; "exit_code"?: number | null; "summary"?: string | RunReceiptSummary | null; "evidence_paths"?: Array; "stdout"?: string; "stderr"?: string; "error"?: string; "duration_ms"?: number; } export interface RunReceiptResponse { "ok": boolean; "receipt": RunReceipt; } export interface RunReceiptListResponse { "ok": boolean; "receipts": Array; } export interface Workflow { "id": string; "name": string; "description"?: string | null; "version": number; "status": string; "steps": Array>; "goal"?: Record; "createdAt"?: string; "updatedAt"?: string; } export interface CreateWorkflowInput { "name": string; "description"?: string; "steps": Array>; "goal"?: Record; } export interface WorkflowResponse { "ok": boolean; "workflow": Workflow; } export interface WorkflowListResponse { "ok": boolean; "workflows": Array; } export interface CreateWorkflowInvocationInput { "id"?: string; "workflowId"?: string; "templateId"?: string; "sourceRef": Record; "subjectRef": Record; "intent": string; "scope"?: Record; "outputPolicy"?: Record; } export type WorkflowInvocation = CreateWorkflowInvocationInput & { "id": string; "createdAt": string; "updatedAt": string; }; export interface WorkflowInvocationResponse { "ok": boolean; "invocation": WorkflowInvocation; } export interface WorkflowInvocationListResponse { "ok": boolean; "invocations": Array; } export interface WorkflowWorkItem { "id": string; "routeKey": string; "idempotencyKey": string; "invocationId": string; "sourceType": string; "sourceRef": string; "subjectRef": string; "status": string; "priority": number; "createdAt"?: string; "updatedAt"?: string; } export interface UpsertWorkflowWorkItemInput { "id"?: string; "routeKey": string; "idempotencyKey": string; "invocationId": string; "sourceType": string; "sourceRef": string; "subjectRef": string; "projectKey"?: string; "projectGroup"?: string; "machineId"?: string; "routeScope"?: string; "priority"?: number; "status"?: "queued" | "deferred"; "nextAttemptAt"?: string; "lastReason"?: string; } export interface WorkflowWorkItemResponse { "ok": boolean; "workItem": WorkflowWorkItem; } export interface WorkflowWorkItemListResponse { "ok": boolean; "workItems": Array; } export interface ImportInput { "workflows"?: Array>; "loops"?: Array>; "runs"?: Array>; "replace"?: boolean; "preserveLoopScheduling"?: boolean; "preserveWorkflowActivation"?: boolean; } export interface ImportResponse { "ok": boolean; "imported": { "workflows": number; "loops": number; "runs": number; }; "skippedRunning": number; } export interface AgentSessionContract { "version": 1; "provider": "claude" | "cursor" | "codewith" | "codex" | "aicopilot" | "opencode"; "model"?: string; "cwd"?: string; "permissionMode": "default" | "plan" | "auto" | "bypass"; "sandbox": "read-only" | "workspace-write" | "danger-full-access" | "enabled" | "disabled" | "provider-default"; "manualBreakGlass": boolean; "routing"?: { "projectPath"?: string; "projectGroup"?: string; "taskId"?: string; "eventId"?: string; "eventType"?: string; "eventSource"?: string; "role"?: "triage" | "planner" | "worker" | "verifier"; }; "timeoutMs": number | null; "restrictions": { "tools"?: Array; "commands"?: Array; "enforcement": "metadata_only"; "providerEnforced": false; }; "safetyReason"?: string; } export interface AgentSessionContractEventInput { "claimToken": string; "eventType": "agent_session_contract"; "stepId": string; "payload": AgentSessionContract; } export interface GenericWorkflowEvent { "id": string; "workflowRunId": string; "sequence": number; "eventType": "created" | "workflow_archived" | "todos_workflow_pointers_synced" | "todos_workflow_pointers_sync_failed" | "step_started" | "step_progress" | "recovered" | "step_pending" | "step_running" | "step_succeeded" | "step_failed" | "step_timed_out" | "step_skipped" | "step_cancelled" | "succeeded" | "failed" | "timed_out" | "cancelled"; "stepId"?: string; "payload"?: Record; "createdAt": string; } export interface AgentSessionContractWorkflowEvent { "id": string; "workflowRunId": string; "sequence": number; "eventType": "agent_session_contract"; "stepId": string; "payload": AgentSessionContract; "createdAt": string; } export interface CustomWorkflowEvent { "id": string; "workflowRunId": string; "sequence": number; "eventKind": "custom"; "eventType": string; "stepId"?: string; "payload"?: Record; "createdAt": string; } export type WorkflowEvent = AgentSessionContractWorkflowEvent | GenericWorkflowEvent | CustomWorkflowEvent; export interface WorkflowEventResponse { "ok": boolean; "event": WorkflowEvent; } export interface WorkflowEventListResponse { "ok": boolean; "events": Array; } export interface CountResponse { "ok": boolean; "count": number; } export interface LoopMachineRef { "id": string; "route"?: string; "local"?: boolean; "confidence"?: "exact" | "high" | "medium" | "low" | "none"; "packageVersion"?: string; "warnings"?: Array; } export interface LoopsClientOptions { /** Base URL, e.g. process.env.APP_API_URL. */ baseUrl: string; /** API key, e.g. process.env.APP_API_KEY. Sent as the 'x-api-key' header. */ apiKey?: string; /** Custom fetch (defaults to global fetch). */ fetch?: typeof fetch; /** Extra headers merged into every request. */ headers?: Record; } export declare class ApiError extends Error { readonly status: number; readonly body: unknown; constructor(status: number, message: string, body: unknown); } export declare class LoopsClient { private readonly baseUrl; private readonly apiKey; private readonly fetchImpl; private readonly baseHeaders; constructor(options: LoopsClientOptions); private request; /** Liveness probe */ healthCheck(init?: RequestInit): Promise; healthzProbe(init?: RequestInit): Promise>; openapiJsonProbe(init?: RequestInit): Promise>; /** Readiness probe (storage reachable + migrated) */ readyCheck(init?: RequestInit): Promise; readyzProbe(init?: RequestInit): Promise>; /** status.read */ statusRead(init?: RequestInit): Promise>; /** api.read */ apiRead(init?: RequestInit): Promise>; /** goalRuns.list */ goalRunsList(init?: RequestInit): Promise>; /** goals.list */ goalsList(init?: RequestInit): Promise>; /** goals.get */ goalsGet(id: string, init?: RequestInit): Promise>; /** goals.planNodes */ goalsPlanNodes(id: string, init?: RequestInit): Promise>; /** history.prune */ historyPrune(init?: RequestInit): Promise>; /** Bulk id-preserving import (control-plane backfill) */ importRows(body: ImportInput, init?: RequestInit): Promise; /** List workflow route invocations */ listWorkflowInvocations(query?: { "limit"?: number; }, init?: RequestInit): Promise; /** Create an id-preserving workflow route invocation */ createWorkflowInvocation(body: CreateWorkflowInvocationInput, init?: RequestInit): Promise; /** invocations.get */ invocationsGet(id: string, init?: RequestInit): Promise>; /** Reconcile exact hosted stuck-run snapshots without blind effect replay */ leasesReconcile(body: StuckRunReconciliationInput, init?: RequestInit): Promise; /** Legacy server-selected lease recovery */ leasesRecover(init?: RequestInit): Promise>; /** Detect hosted runs whose leases are safely past the recovery grace period */ leasesStuck(query?: { "expiredBefore"?: string; "limit"?: number; }, init?: RequestInit): Promise; /** Reconcile one exact tenant-bound loop mutation result under explicit lookup caps */ getLoopMutation(operationId: string, stepId: string, query?: { "maxCalls"?: number; "maxRecords"?: number; "maxBytes"?: number; "maxWallMs"?: number; }, init?: RequestInit): Promise; /** List loops */ listLoops(query?: { "status"?: "active" | "paused" | "stopped" | "expired"; "limit"?: number; "offset"?: number; "includeArchived"?: boolean; "archived"?: boolean; "labels"?: Array; }, init?: RequestInit): Promise; /** Create a loop */ createLoop(body: CreateLoopInput, init?: RequestInit): Promise; /** Count loops (total-row verification) */ countLoops(query?: { "status"?: string; "includeArchived"?: boolean; "archived"?: boolean; }, init?: RequestInit): Promise; /** Get a loop by id */ getLoop(id: string, init?: RequestInit): Promise; /** Delete a loop */ deleteLoop(id: string, init?: RequestInit): Promise; /** Update a loop (status / schedule fields) */ updateLoop(id: string, body: UpdateLoopInput, init?: RequestInit): Promise; /** Archive a loop by id or name */ archiveLoop(id: string, init?: RequestInit): Promise; /** Apply a full-id, tenant-bound loop mutation with CAS and exactly-once receipts */ mutateLoop(id: string, body: LoopMutationEnvelope, init?: RequestInit): Promise; /** loops.rename */ loopsRename(id: string, init?: RequestInit): Promise>; /** Unarchive a loop by id or name */ unarchiveLoop(id: string, init?: RequestInit): Promise; /** List run receipts */ listRunReceipts(query?: { "loopId"?: string; "repo"?: string; "taskId"?: string; "knowledgeId"?: string; "status"?: string; "limit"?: number; }, init?: RequestInit): Promise; /** Write a run receipt */ writeRunReceipt(body: WriteRunReceiptInput, init?: RequestInit): Promise; /** Get a run receipt by run id */ getRunReceipt(runId: string, init?: RequestInit): Promise; /** runners.claim */ runnersClaim(body: Record, init?: RequestInit): Promise>; /** runners.poll */ runnersPoll(body: Record, init?: RequestInit): Promise>; /** List runs */ listRuns(query?: { "loopId"?: string; "status"?: string; "labels"?: Array; "limit"?: number; "offset"?: number; "showOutput"?: boolean; }, init?: RequestInit): Promise; /** Count runs (total-row verification; accepts the same filters as listRuns) */ countRuns(query?: { "loopId"?: string; "status"?: string; "labels"?: Array; }, init?: RequestInit): Promise; /** Get a run by id */ getRun(id: string, query?: { "showOutput"?: boolean; }, init?: RequestInit): Promise; /** runs.evidence */ runsEvidence(id: string, body: Record, init?: RequestInit): Promise>; /** runs.finalize */ runsFinalize(id: string, body: { "claimToken": string; "status": "succeeded" | "failed" | "timed_out" | "skipped"; "finishedAt"?: string; "durationMs"?: number; "stdout"?: string; "stderr"?: string; "error"?: string; "exitCode"?: number; "pid"?: number; }, init?: RequestInit): Promise>; /** runs.Goals.Create */ runsGoalsCreate(id: string, body: Record, init?: RequestInit): Promise>; /** runs.Goals.Find */ runsGoalsFind(id: string, body: Record, init?: RequestInit): Promise>; /** runs.Goals.Events */ runsGoalsEvents(id: string, goalId: string, body: Record, init?: RequestInit): Promise>; /** runs.Goals.Get */ runsGoalsGet(id: string, goalId: string, body: Record, init?: RequestInit): Promise>; /** runs.Goals.Plan.Nodes.Create */ runsGoalsPlanNodesCreate(id: string, goalId: string, body: Record, init?: RequestInit): Promise>; /** runs.Goals.Plan.Nodes.List */ runsGoalsPlanNodesList(id: string, goalId: string, body: Record, init?: RequestInit): Promise>; /** runs.Goals.Plan.Nodes.Update */ runsGoalsPlanNodesUpdate(id: string, goalId: string, key: string, body: Record, init?: RequestInit): Promise>; /** runs.Goals.Status */ runsGoalsStatus(id: string, goalId: string, body: Record, init?: RequestInit): Promise>; /** runs.heartbeat */ runsHeartbeat(id: string, body: Record, init?: RequestInit): Promise>; /** runs.recover */ runsRecover(id: string, init?: RequestInit): Promise>; /** runs.workflowRuns.create */ runsWorkflowRunsCreate(id: string, body: Record, init?: RequestInit): Promise>; /** Validate a legacy runner-authored agent session contract */ runsWorkflowRunsEvents(id: string, workflowRunId: string, body: AgentSessionContractEventInput, init?: RequestInit): Promise; /** runs.workflowRuns.finalize */ runsWorkflowRunsFinalize(id: string, workflowRunId: string, body: Record, init?: RequestInit): Promise>; /** runs.workflowRuns.get */ runsWorkflowRunsGet(id: string, workflowRunId: string, body: Record, init?: RequestInit): Promise>; /** runs.workflowRuns.recover */ runsWorkflowRunsRecover(id: string, workflowRunId: string, body: Record, init?: RequestInit): Promise>; /** runs.workflowRuns.steps */ runsWorkflowRunsSteps(id: string, workflowRunId: string, body: Record, init?: RequestInit): Promise>; /** runs.workflowRuns.stepAction */ runsWorkflowRunsStepAction(id: string, workflowRunId: string, stepId: string, action: "get" | "start" | "pid" | "progress" | "skip" | "finalize", body: Record, init?: RequestInit): Promise>; /** api.status */ apiStatus(init?: RequestInit): Promise>; v1VersionProbe(init?: RequestInit): Promise>; /** List workflow route work items */ listWorkflowWorkItems(query?: { "status"?: string; "routeKey"?: string; "limit"?: number; }, init?: RequestInit): Promise; /** Upsert an id-preserving workflow route work item */ upsertWorkflowWorkItem(body: UpsertWorkflowWorkItemInput, init?: RequestInit): Promise; /** workItems.get */ workItemsGet(id: string, init?: RequestInit): Promise>; /** workflowRuns.list */ workflowRunsList(init?: RequestInit): Promise>; /** workflowRuns.get */ workflowRunsGet(id: string, init?: RequestInit): Promise>; /** workflowRuns.events */ workflowRunsEvents(id: string, init?: RequestInit): Promise; /** workflowRuns.recover */ workflowRunsRecover(id: string, body?: { "reason"?: string; }, init?: RequestInit): Promise>; /** workflowRuns.steps */ workflowRunsSteps(id: string, init?: RequestInit): Promise>; /** List workflow specs */ listWorkflows(query?: { "status"?: "active" | "archived"; "limit"?: number; "offset"?: number; }, init?: RequestInit): Promise; /** Create a workflow spec */ createWorkflow(body: CreateWorkflowInput, init?: RequestInit): Promise; /** Count workflow specs */ countWorkflows(query?: { "status"?: string; }, init?: RequestInit): Promise; /** Get a workflow spec by id */ getWorkflow(id: string, init?: RequestInit): Promise; /** workflows.archive */ workflowsArchive(id: string, init?: RequestInit): Promise>; /** Service version */ getVersion(init?: RequestInit): Promise; }