export type RdiAiScope = { type: 'workspace'; subscriptionId: number; workspaceId?: string; pipelineId?: string; } | { type: 'account'; accountId?: number; }; /** Runtime feature switches and UI limits for AI transformation tools. */ export interface RdiTransformationAiConfig { /** Enables the assistant/chat entry points. */ aiAssistantAvailable: boolean; /** Enables the standalone transformation playground page. */ playgroundAvailable: boolean; /** Enables dry-run execution for transformation YAML. */ dryRunAvailable: boolean; /** Max sample records the UI should allow in one request. */ maxSamples?: number; /** Max user prompt length the UI should allow. */ maxPromptChars?: number; } /** Host-provided config lookup for AI transformation tools. */ export interface RdiTransformationAiConfigCapability { getConfig: () => Promise; } export interface RdiAiSession { id: string; title?: string; createdAt?: string; updatedAt?: string; status?: 'idle' | 'running' | 'failed'; failureMessage?: string; } export type RdiAiMessageOutcome = 'proposal' | 'diagnosis' | 'unsupported' | 'no_change' | 'clarification'; export interface RdiAiMessage { id: string; role: 'user' | 'assistant' | 'system'; content: string; status?: 'queued' | 'running' | 'complete' | 'failed' | 'cancelled'; outcome?: RdiAiMessageOutcome; createdAt?: string; metadata?: Record; } export type RdiTransformationSourceType = 'postgresql' | 'mongodb'; export type RdiTransformationOperation = 'r' | 'c' | 'u' | 'd'; export type RdiTransformationFieldType = 'array' | 'bigint' | 'binary' | 'boolean' | 'date' | 'decimal' | 'document' | 'double' | 'int' | 'jsonb' | 'objectId' | 'string' | 'time' | 'timestamp' | 'timestamptz' | 'uuid' | 'varchar'; export interface RdiTransformationFieldSchema { id: string; name: string; path: string; dataType: RdiTransformationFieldType; nullable: boolean; primaryKey: boolean; } export interface RdiTransformationEntitySchema { id: string; name: string; namespace?: string; fields: RdiTransformationFieldSchema[]; } export interface RdiTransformationInputEvent { id: string; operation: RdiTransformationOperation; entityId: string; key?: Record; before?: Record; after?: Record; } export interface RdiTransformationDataSetup { sourceType: RdiTransformationSourceType; databaseName: string; entities: RdiTransformationEntitySchema[]; events: RdiTransformationInputEvent[]; } export interface RdiAiDataSetupProposal { id: string; sourceMessageId?: string; explanation: string; dataSetup: RdiTransformationDataSetup; } export interface RdiTransformationWorkbenchState { yaml: string; dataSetup: RdiTransformationDataSetup; /** Raw editor value retained so generated or manually edited sample input can be restored. */ sampleInput: string; /** Raw JSON editor value; semantic comparison normalizes valid JSON. */ mockLookupsInput: string; /** Raw JSON editor value; semantic comparison normalizes valid JSON. */ expectationsInput: string; } export type RdiAiSessionCheckpointKind = 'automatic' | 'manual'; export type RdiAiSessionCheckpointReason = 'manual' | 'before_ai_transformation_apply' | 'ai_transformation_applied' | 'before_ai_data_setup_apply' | 'ai_data_setup_applied' | 'before_ai_sample_input_apply' | 'ai_sample_input_applied'; export interface RdiAiSessionCheckpointInput { label: string; kind: RdiAiSessionCheckpointKind; reason: RdiAiSessionCheckpointReason; stateFingerprint: string; state: RdiTransformationWorkbenchState; } export interface RdiAiSessionCheckpoint extends RdiAiSessionCheckpointInput { id: string; sessionId: string; createdAt: string; } export interface RdiAiContextPayload { currentYaml?: string; sourceMetadata?: unknown; sampleRecords?: unknown[]; mockLookups?: Record; pipelineDraft?: unknown; selectedJobName?: string; dataSetup?: RdiTransformationDataSetup; transformationCapabilities?: unknown; /** Complete task-scoped evidence for an isolated dry-run outcome explanation. */ outcomeExplanation?: unknown; } export interface RdiTransformationAiAssistantCapability { createSession: (params: { scope?: RdiAiScope; context?: RdiAiContextPayload; /** Optional host-visible title for task-specific sessions. */ title?: string; }) => Promise; listSessions: (params?: { scope?: RdiAiScope; }) => Promise; getSession: (params: { scope?: RdiAiScope; sessionId: string; }) => Promise<{ session: RdiAiSession; messages: RdiAiMessage[]; dataSetupProposals?: RdiAiDataSetupProposal[]; }>; renameSession: (params: { scope?: RdiAiScope; sessionId: string; title: string; }) => Promise; deleteSession: (params: { scope?: RdiAiScope; sessionId: string; }) => Promise; sendMessage: (params: { scope?: RdiAiScope; sessionId: string; message: string; context?: RdiAiContextPayload; signal?: AbortSignal; }) => Promise<{ messageId: string; }>; /** Optional host persistence for session-scoped workbench checkpoints. */ listSessionCheckpoints?: (params: { scope?: RdiAiScope; sessionId: string; }) => Promise; /** Optional host persistence for one deduplicated workbench checkpoint. */ saveSessionCheckpoint?: (params: { scope?: RdiAiScope; sessionId: string; checkpoint: RdiAiSessionCheckpointInput; }) => Promise; } export interface ResolvedRdiTransformationAiConfigCapability extends RdiTransformationAiConfigCapability { isConfigured: boolean; } export interface ResolvedRdiTransformationAiAssistantCapability extends RdiTransformationAiAssistantCapability { isConfigured: boolean; isCheckpointingConfigured: boolean; listSessionCheckpoints: NonNullable; saveSessionCheckpoint: NonNullable; }