import type { LateInput } from "./late-input.js"; export type RunStatus = "queued" | "running" | "waiting_for_input" | "completed" | "failed" | "cancelled" | "needs_developer_attention"; export interface TapiClientOptions { baseUrl: string; authToken: string; tappId: string; projectId?: string; dev?: boolean; fetch?: typeof fetch; localControlUrl?: string; webSocket?: LocalWebSocketConstructor; } export interface ServiceRunRequest { queueId: string; inputs?: Record>; runtime?: RuntimeRunOptions; priority?: number; idempotencyKey?: string; site?: string; } export interface CloudRunOptions { windows?: boolean; maxVms?: number; chromePerVm?: number; maxCostUsd?: number; [key: string]: unknown; } export interface CloudRunUser { externalUserId: string; email?: string; } export interface CloudRunPaymentOptions { successUrl?: string; cancelUrl?: string; } export interface ServiceCloudQuoteRequest { inputs?: Array>; cloud?: CloudRunOptions; user?: CloudRunUser; runtime?: RuntimeRunOptions; site?: string; } export interface ServiceCloudBatchRequest { inputs: Array>; queueId: string; cloud?: CloudRunOptions; user?: CloudRunUser; runtime?: RuntimeRunOptions; payment?: CloudRunPaymentOptions; site?: string; idempotencyKey?: string; } export interface CloudRunQuote { inputCount: number; windows: boolean; maxVms: number; chromePerVm: number; estimatedVms: number; estimatedVmSeconds: number; estimatedCostCents: number; requiredBalanceCents: number; currency: string; maxCostUsd?: number | null; withinMaxCost?: boolean; billingEnabled?: boolean; availableBalanceCents?: number | null; minimumBalanceCents?: number; user?: CloudRunUser; [key: string]: unknown; } export interface CloudBatchRun { id: string; status: RunStatus | "payment_required" | "provisioning"; serviceName: string; serviceKey: string; serviceRun?: string; site?: string; inputCount?: number; completedCount?: number; failedCount?: number; cancelledCount?: number; cloud?: CloudRunOptions | Record; quote?: CloudRunQuote | Record; user?: CloudRunUser; paymentRequired?: boolean; checkoutUrl?: string | null; checkoutSessionId?: string | null; paymentProvider?: string; paymentProviderEnabled?: boolean; availableBalanceCents?: number; requiredBalanceCents?: number; reservationCents?: number; actualCostCents?: number; error?: Record | null; traceId?: string; createdAt?: string; updatedAt?: string; [key: string]: unknown; } export interface CloudRunEvent { runId: string; type: string; status?: string; itemIndex?: number; traceId?: string; createdAt?: string; updatedAt?: string; [key: string]: unknown; } export interface CloudRunResultItem { index: number; status: string; traceId?: string; result?: Record | null; error?: Record | null; [key: string]: unknown; } export interface CloudRunResults { runId: string; status: string; results: CloudRunResultItem[]; } export interface CloudBalance { balanceCents: number; currency: string; billingEnabled: boolean; minimumBalanceCents: number; user?: CloudRunUser; } export interface CloudCreditCheckoutRequest { amountCents: number; user?: CloudRunUser; successUrl?: string; cancelUrl?: string; } export interface CloudCreditCheckout { checkoutUrl: string | null; checkoutSessionId: string | null; paymentProvider: "stripe" | string; paymentProviderEnabled: boolean; } export interface ServiceInputContract { key: string; label?: string; type?: string; valueType?: string; control?: string; options?: unknown[]; requiredWhen?: Record; default?: unknown; [key: string]: unknown; } export interface ServiceOutputContract { key: string; type?: string; [key: string]: unknown; } export interface ServiceOperation { name: string; serviceName: string; serviceKey: string; serviceRun?: string; site?: string; version?: string; status?: string; deviceMode?: "desktop" | "mobile" | string; runtime?: RuntimeRunOptions | Record; inputs: ServiceInputContract[]; outputs?: ServiceOutputContract[]; inputSchema?: Record; outputSchema?: Record; [key: string]: unknown; } export interface ServiceTriggerSchedule { intervalSeconds?: number; cron?: string; [key: string]: unknown; } export interface ServiceTriggerCreateRequest { name: string; serviceRun: string; enabled?: boolean; schedule?: ServiceTriggerSchedule; inputs?: Record; runtime?: RuntimeRunOptions; queueId: string; priority?: number; site?: string; } export interface ServiceTriggerUpdateRequest { enabled: boolean; } export interface ServiceTrigger { id: string; name: string; serviceRun: string; serviceName: string; serviceKey: string; site?: string; enabled: boolean; schedule?: ServiceTriggerSchedule | Record; inputs?: Record; runtime?: RuntimeRunOptions | Record; queueId?: string; priority?: number; lastRun?: TapiRun | Record | null; lastError?: string; lastFiredAt?: string | null; nextFireAt?: string | null; createdAt?: string; updatedAt?: string; [key: string]: unknown; } export interface ServiceTriggerList { triggers: ServiceTrigger[]; } export interface ServiceTriggerRunResult { success: boolean; trigger: ServiceTrigger; run: TapiRun | Record; } export interface TapiRun { id: string; status: RunStatus; serviceName: string; serviceKey: string; serviceRun?: string; tappId?: string; queueId?: string; runnerId?: string; slotIndex?: number; deviceId?: string; result?: Record | null; error?: Record | null; runtime?: RuntimeRunOptions | Record | null; waitingInput?: ServiceWaitingInput | null; pendingInputs?: ServiceWaitingInput[]; createdAt?: string; updatedAt?: string; [key: string]: unknown; } export type TapiDevSessionStatus = "queued" | "running" | "waiting_for_input" | "awaiting_takeover" | "needs_developer_attention" | "completed" | "failed" | "cancelled" | string; export interface TapiDevSession { id: string; projectId: string; sitemap: string; site?: string; serviceName: string; serviceKey: string; serviceRun?: string; status: TapiDevSessionStatus; stateId?: number | null; stateLabel?: string; currentUrl?: string; profileRef?: string; runtimeSessionId?: string; deviceId?: string; live: boolean; openable: boolean; dev: boolean; updatedAt?: string; createdAt?: string; [key: string]: unknown; } export interface TapiDevSessionGroup { sitemap: string; sessions: TapiDevSession[]; } export interface TapiDevSessionsList { projectId: string; groups: TapiDevSessionGroup[]; } export interface ServiceWaitingInput { key: string; label?: string; stateId?: number; actionId?: string; control?: string; timeoutMs?: number; [key: string]: unknown; } export interface TapiRunner { id: string; status: string; name?: string; online?: boolean; [key: string]: unknown; } export interface RuntimeRequirements { daemonRequired: boolean; serviceRequired?: boolean; localControlUrl?: string; serviceName?: string; serviceVersion?: string; windowsServiceName?: string; [key: string]: unknown; } export type RuntimeProfileKind = "perm" | "temp" | "runtime_clone"; export type OriginPolicyType = "home" | "direct" | "fixed_proxy"; export interface OriginPolicy { type: OriginPolicyType; proxy?: string; [key: string]: unknown; } export interface RuntimeProfile { profileRef: string; kind: RuntimeProfileKind; displayName: string; userDataDir?: string; originPolicy: OriginPolicy; templateRef?: string; parentProfileRef?: string; destroyOnRelease?: boolean; ttlSeconds?: number | null; state?: string; createdAt?: string; updatedAt?: string; metadata?: Record; [key: string]: unknown; } export interface RuntimeRunOptions { owner?: "service_run"; profileRef?: string; destroyOnRelease?: boolean; [key: string]: unknown; } export interface CreatePermProfileRequest { displayName: string; originPolicy?: OriginPolicy | OriginPolicyType | string; profileRef?: string; } export interface ProvisionTempProfilesRequest { count?: number; proxies?: string[]; templateRef?: string; displayNamePrefix?: string; destroyOnRelease?: boolean; ttlSeconds?: number; } export interface PromoteTempProfileRequest { profileRef: string; displayName?: string; originPolicy?: OriginPolicy | OriginPolicyType | string; } export interface CreateRuntimeCloneRequest { profileRef: string; site?: string; } export interface LaunchPermProfileSetupRequest { profileRef: string; windowBounds?: Record; } export interface RuntimeProfileListResponse { success: boolean; profiles: RuntimeProfile[]; } export interface RuntimeProfileResponse { success: boolean; profile: RuntimeProfile; } export interface RuntimeProfilesDestroyedResponse { success: boolean; destroyed: boolean; profileRef: string; } export interface LocalWebSocketMessageEvent { data: unknown; } export interface LocalWebSocketLike { onopen: (() => void) | null; onmessage: ((event: LocalWebSocketMessageEvent) => void) | null; onerror: ((event: unknown) => void) | null; onclose: ((event: unknown) => void) | null; send(data: string): void; close(): void; } export type LocalWebSocketConstructor = new (url: string) => LocalWebSocketLike; export interface SdkCatalogRequest { key: string; status: string; operation?: string; sdkName?: string; deviceMode?: "desktop" | "mobile" | string; runtime?: RuntimeRunOptions | Record; inputs?: ServiceInputContract[]; inputSchema?: Record; outputSchema?: Record; responseSchema?: Record; [key: string]: unknown; } export interface SdkCatalogService { name: string; serviceName: string; version?: string; site?: string; requests: SdkCatalogRequest[]; [key: string]: unknown; } export interface SdkCatalog { services: SdkCatalogService[]; [key: string]: unknown; }