import type { RunStatus } from './run-lifecycle.js'; import type { ChangeOperation, InputPortDefinition, JsonValue, PortDefinition, RevisionContent, TriggerKeySnapshot } from '../browser/project-change.js'; export type { JsonValue, TriggerKeySnapshot } from '../browser/project-change.js'; export type { RunStatus } from './run-lifecycle.js'; export { controlErrorCode, controlErrorMetadata, type ControlErrorCode } from './control-api-errors.js'; export type { ProjectChangeEvent } from './project-notifications.js'; export type ControlRequest = (path: string, init?: RequestInit) => Promise; export interface Project { readonly createdAt: string; readonly draftRevisionId: string; readonly name: string; readonly projectId: string; readonly status: 'active' | 'retiring'; readonly updatedAt: string; readonly version: 1; } export interface ProjectPage { readonly nextCursor?: string; readonly projects: readonly Project[]; readonly total?: number; readonly version: 1; } export interface TriggerKeySummary { readonly description: string; readonly displayName: string; readonly key: string; readonly name: string; readonly provider: string; readonly type: TriggerKeySnapshot['type']; } export interface TriggerBinding { readonly currentPublicationId?: string; readonly currentRevisionId?: string; readonly endpointUrl?: string; readonly flowId: string; readonly health: 'failed' | 'healthy' | 'initializing' | 'needs_reauth' | 'suspended'; readonly kind: 'cron' | 'integration' | 'poll' | 'webhook'; readonly lastErrorCode?: string; readonly operatorState: 'active' | 'paused'; readonly projectId: string; readonly runtimeVersion: number; readonly triggerNodeId: string; readonly updatedAt: string; readonly version: 1; } export interface TriggerBindingDetail { readonly binding: TriggerBinding; readonly version: 1; } export type TriggerActivityKind = 'delivery.failed' | 'health.failed' | 'health.needs_reauth' | 'health.recovered' | 'health.suspended' | 'operator.paused' | 'operator.resumed'; export interface TriggerActivity { readonly activityId: string; readonly createdAt: string; readonly errorCode?: string; readonly errorMessage?: string; readonly kind: TriggerActivityKind; } export interface TriggerActivityPage { readonly activities: readonly TriggerActivity[]; readonly nextCursor?: string; readonly version: 1; } export interface PollTriggerTestResult { readonly events: readonly Readonly>[]; readonly filtered: number; readonly hasMore: boolean; readonly version: 1; } export interface ConnectorConnection { readonly connectionId: string; readonly displayName: string; readonly isDefault: boolean; readonly serviceId: string; readonly status: 'active' | 'disconnected' | 'error' | 'reauth_required'; } export interface ConnectorAction { readonly actionId: string; readonly defaultConnection?: ConnectorConnection; readonly description: string; readonly icon?: string; readonly inputs: Readonly>; readonly name: string; readonly outputs: Readonly>; readonly serviceId: string; readonly serviceName: string; } export interface ConnectorProvider { readonly icon?: string; readonly serviceId: string; readonly serviceName: string; } export interface RevisionMetadata { readonly actorId: string; readonly createdAt: string; readonly digest: string; readonly modelVersion: number; readonly parentRevisionId: string | null; readonly projectId: string; readonly revisionId: string; readonly version: 1; } export interface Draft extends RevisionMetadata { readonly content: RevisionContent; } export interface DraftFlow { readonly closureDigest: string; readonly flowId: string; readonly name: string; } export interface DraftChange { readonly draftFlows: readonly DraftFlow[]; readonly revision: RevisionMetadata; readonly version: 1; } export type DraftSync = { readonly draftFlows: readonly DraftFlow[]; readonly kind: 'changes'; readonly revisions: readonly { readonly operations: readonly ChangeOperation[]; readonly revision: RevisionMetadata; }[]; readonly version: 1; } | { readonly draft: Draft; readonly draftFlows: readonly DraftFlow[]; readonly kind: 'snapshot'; readonly version: 1; }; export interface Publication { readonly actorId: string; readonly closureDigest: string; readonly createdAt: string; readonly engineContract: string; readonly flowId: string; readonly modelVersion: number; readonly operation: 'publish' | 'rollback'; readonly projectId: string; readonly publicationId: string; readonly revisionDigest: string; readonly revisionId: string; readonly sourcePublicationId?: string; readonly version: 1; } export interface Flow { readonly draft: { readonly closureDigest: string; readonly name: string; readonly revisionDigest: string; readonly revisionId: string; } | null; readonly flowId: string; readonly hasUnpublishedChanges: boolean; readonly live: { readonly publication: Publication; readonly revision: number; readonly status: 'runnable' | 'suspended'; } | null; } export interface Diagnostic { readonly code: string; readonly column: number; readonly line: number; readonly message: string; readonly path: string; } export interface FlowCheck { readonly closureDigest: string; readonly diagnostics: readonly Diagnostic[]; readonly engineContract: string; readonly flowId: string; readonly modelVersion: number; readonly projectId: string; readonly revisionDigest: string; readonly revisionId: string; readonly valid: boolean; readonly version: 1; } export interface Live { readonly flowId: string; readonly hasUnpublishedChanges: boolean; readonly projectId: string; readonly publication: Publication | null; readonly revision: number; readonly status: 'not-published' | 'runnable' | 'suspended'; readonly version: 1; } export interface PublicationPage { readonly nextCursor?: string; readonly publications: readonly Publication[]; readonly total?: number; readonly version: 1; } export interface Run { readonly createdAt: string; readonly finishedAt?: string; readonly flowId: string; readonly projectId: string; readonly revisionId: string; readonly runId: string; readonly source: 'draft' | 'live' | 'trigger'; readonly startedAt?: string; readonly status: RunStatus; readonly version: 1; } interface RunDetailsBase extends Run { readonly closureDigest: string; readonly engineContract: string; readonly engineDigest: string; readonly eventsExpiresAt?: string; readonly modelVersion: number; readonly revisionDigest: string; } export type DraftRun = RunDetailsBase & { readonly source: 'draft'; }; export type LiveRun = RunDetailsBase & { readonly publicationId: string; readonly source: 'live'; }; export type TriggerRun = RunDetailsBase & { readonly occurrenceId: string; readonly publicationId: string; readonly source: 'trigger'; readonly triggerNodeId: string; }; export type RunDetails = DraftRun | LiveRun | TriggerRun; export interface RunPage { readonly nextCursor?: string; readonly projectId: string; readonly runs: readonly Run[]; readonly version: 1; } export type RunEventKind = 'node.artifact' | 'node.completed' | 'node.failed' | 'node.log' | 'node.output' | 'node.progress' | 'node.started' | 'run.canceled' | 'run.completed' | 'run.events-truncated' | 'run.failed' | 'run.indeterminate' | 'run.progress' | 'run.queued' | 'run.started'; export interface RunEvent { readonly createdAt: string; readonly kind: RunEventKind; readonly payload: Readonly>; readonly sequence: number; readonly sourceSequence?: number; } export interface RunEvents { readonly done: boolean; readonly events: readonly RunEvent[]; readonly eventsExpiresAt?: string; readonly historyComplete: boolean; readonly nextAfter: number; readonly runId: string; readonly version: 1; } export interface RunCancellation { readonly cancelAccepted: boolean; readonly runId: string; readonly status: Extract; readonly version: 1; } export type RunResult = { readonly finishedAt: string; readonly result: JsonValue; readonly runId: string; readonly status: 'completed'; readonly version: 1; } | { readonly error: { readonly code: string; readonly message: string; }; readonly finishedAt: string; readonly runId: string; readonly status: 'failed' | 'indeterminate'; readonly version: 1; } | { readonly finishedAt: string; readonly runId: string; readonly status: 'canceled'; readonly version: 1; }; interface RunOptions { readonly idempotencyKey?: string; readonly inputs?: Readonly>>>; } interface PublicationOptions { readonly idempotencyKey?: string; } export declare class ApiError extends Error { readonly status: number; readonly code: string; constructor(status: number, code: string, message: string); } export declare class ControlClient { private readonly requestControl; constructor(requestControl: ControlRequest); listProjects(options?: { readonly cursor?: string; readonly includeTotal?: boolean; readonly limit?: number; }): Promise; createProject(name: string, idempotencyKey?: string): Promise; getProject(projectId: string): Promise; deleteProject(projectId: string): Promise; listTriggerKeys(signal?: AbortSignal): Promise; listTriggerDefinitions(signal?: AbortSignal): Promise; getTriggerKey(key: string, signal?: AbortSignal): Promise; listFlowTriggerBindings(projectId: string, flowId: string): Promise; getFlowTriggerBinding(projectId: string, flowId: string, triggerNodeId: string): Promise; listFlowTriggerActivities(projectId: string, flowId: string, triggerNodeId: string, options?: { readonly cursor?: string; readonly limit?: number; }): Promise; pauseFlowTrigger(projectId: string, flowId: string, triggerNodeId: string): Promise; resumeFlowTrigger(projectId: string, flowId: string, triggerNodeId: string): Promise; testFlowPollTrigger(projectId: string, flowId: string, triggerNodeId: string): Promise; getDraft(projectId: string): Promise; syncDraft(projectId: string, fromRevisionId?: string): Promise; getRevision(projectId: string, revisionId: string): Promise; listFlows(projectId: string): Promise; listConnectorProviders(projectId: string, signal?: AbortSignal): Promise; listConnectorActions(projectId: string, serviceId?: string, signal?: AbortSignal): Promise; searchConnectorActions(projectId: string, query: string, signal?: AbortSignal): Promise; getConnectorAction(projectId: string, actionId: string, signal?: AbortSignal): Promise; listConnectorConnections(projectId: string, serviceId: string, signal?: AbortSignal): Promise; createConnectorConnectionPage(projectId: string, serviceId: string, returnUrl: string): Promise; changeDraft(projectId: string, expectedRevisionId: string, operations: readonly ChangeOperation[]): Promise; checkFlow(projectId: string, revisionId: string, flowId: string): Promise; getLive(projectId: string, flowId: string): Promise; listPublications(projectId: string, flowId: string, options?: { readonly cursor?: string; readonly includeTotal?: boolean; readonly limit?: number; }): Promise; createDraftRun(projectId: string, revisionId: string, flowId: string, options?: RunOptions): Promise; createLiveRun(projectId: string, flowId: string, options?: RunOptions): Promise; publishFlow(projectId: string, revisionId: string, flowId: string, expectedLivePublicationId: string | null, options?: PublicationOptions): Promise; rollbackFlow(projectId: string, flowId: string, publicationId: string, expectedLivePublicationId: string, options?: PublicationOptions): Promise; getRun(projectId: string, runId: string): Promise; listRuns(projectId: string, options?: { readonly cursor?: string; readonly flowId?: string; readonly limit?: number; readonly status?: RunStatus; }): Promise; getRunEvents(projectId: string, runId: string, options?: { readonly after?: number; readonly limit?: number; }): Promise; getRunResult(projectId: string, runId: string): Promise; cancelRun(projectId: string, runId: string): Promise; private connectorActions; protected request(path: string, init?: RequestInit): Promise; }