import type { H3Event } from "h3"; export type AutomationResponseMode = "synchronous" | "asynchronous"; export type AutomationInvocationStatus = "completed" | "accepted"; export type JsonSchema = Readonly>; export interface AutomationRetryPolicy { readonly maxAttempts?: number; readonly retryDelayMs?: number; } export interface AutomationWorkflowCapabilities { readonly invokesExternalWorkflow: boolean; readonly receivesCallback: boolean; readonly supportsIdempotency: boolean; readonly supportsSynchronousResponse: boolean; readonly supportsAsynchronousResponse: boolean; readonly mayCauseExternalSideEffects: boolean; } export interface AutomationOutboundDefinition { readonly baseUrl: string; readonly allowedOrigins?: readonly string[]; readonly path: string; readonly method?: "POST" | "PUT" | "PATCH"; readonly headers?: Readonly>; readonly credentialRequirements?: readonly string[]; readonly timeoutMs?: number; readonly retry?: AutomationRetryPolicy; readonly maxRequestBytes?: number; readonly maxResponseBytes?: number; readonly idempotencyHeader?: string; } export type AutomationCallbackAuthentication = { readonly kind: "shared-secret"; readonly secretRef: string; readonly header: string; readonly prefix?: string; } | { readonly kind: "hmac-sha256"; readonly secretRef: string; readonly header: string; readonly prefix?: string; } | { readonly kind: "provider-auth"; readonly verify: (input: { readonly rawBody: string; readonly headers: Headers; }) => Promise; }; export interface AutomationInboundDefinition { readonly authentication: AutomationCallbackAuthentication; readonly eventIdHeader?: string; readonly maxRequestBytes?: number; readonly triggersAgentExecution?: boolean; } export interface AutomationWorkflowDefinition { readonly id: string; readonly connectorId: string; readonly name: string; readonly inputSchema: JsonSchema; readonly outputSchema?: JsonSchema; readonly response: { readonly mode: AutomationResponseMode; }; readonly capabilities: AutomationWorkflowCapabilities; readonly outbound?: AutomationOutboundDefinition; readonly inbound?: AutomationInboundDefinition; } export interface AutomationInvocation { readonly workflowId: string; readonly input: Record; readonly idempotencyKey?: string; readonly userEmail: string; } export interface AutomationInvocationResult { readonly workflowId: string; readonly connectorId: string; readonly status: AutomationInvocationStatus; readonly responseMode: AutomationResponseMode; readonly attempts: number; readonly httpStatus: number; readonly output?: unknown; readonly responseTruncated: boolean; } export interface AutomationCallbackInput { readonly workflowId: string; readonly rawBody: string; readonly headers: Headers; } export interface AutomationCallbackResult { readonly accepted: boolean; readonly duplicate: boolean; readonly eventId: string; } export declare class AutomationConnectorError extends Error { readonly code: "unknown_workflow" | "unsupported_direction" | "invalid_configuration" | "blocked_target" | "payload_too_large" | "authentication_failed" | "missing_idempotency" | "timeout" | "request_failed"; constructor(code: "unknown_workflow" | "unsupported_direction" | "invalid_configuration" | "blocked_target" | "payload_too_large" | "authentication_failed" | "missing_idempotency" | "timeout" | "request_failed", message: string); } export interface AutomationRuntimeOptions { readonly workflows: readonly AutomationWorkflowDefinition[]; readonly fetch?: typeof fetch; /** * The caller receives the raw secret only inside this server-side callback. * Return a value for a configured secret reference; never log or return it. */ readonly resolveSecret?: (secretRef: string, context: { readonly userEmail?: string; }) => Promise; readonly claimInboundEvent?: (input: { readonly workflow: AutomationWorkflowDefinition; readonly eventId: string; }) => Promise; readonly releaseInboundEvent?: (input: { readonly workflow: AutomationWorkflowDefinition; readonly eventId: string; }) => Promise; readonly enqueueInboundEvent?: (input: { readonly workflow: AutomationWorkflowDefinition; readonly eventId: string; readonly payload: unknown; }) => Promise; } export interface AutomationRuntime { readonly listWorkflows: () => readonly AutomationWorkflowDefinition[]; readonly getWorkflow: (workflowId: string) => AutomationWorkflowDefinition | undefined; readonly invoke: (input: AutomationInvocation) => Promise; readonly receiveCallback: (input: AutomationCallbackInput) => Promise; } export declare function readBoundedRequestBody(event: H3Event, maxBytes: number): Promise; export declare function createAutomationRuntime(options: AutomationRuntimeOptions): AutomationRuntime; export declare function createInvokeAutomationWorkflowAction(runtime: AutomationRuntime, options?: { readonly description?: string; readonly requireApproval?: boolean; }): import("../action.js").ActionDefinition<{ workflowId: string; input: Record; idempotencyKey?: string | undefined; }, AutomationInvocationResult>; export declare function createAutomationCallbackHandler(runtime: AutomationRuntime): (event: H3Event) => Promise<{ error: string; accepted?: undefined; duplicate?: undefined; eventId?: undefined; } | { error?: undefined; accepted: boolean; duplicate: boolean; eventId: string; }>;