import { WorkflowGraph, WorkflowRun, AgentRule, WorkflowTool, AgentTool, Workflow, VariableValue, AgentModel } from './astrlabe/contracts.js';
import { A as AgentWithPrompts } from './index-CnCY-b5V.js';
import { AgentPrompt } from '@datatechsolutions/shared-domain/ports/workflow';
import { AgentConfigLike, DataSource } from '@datatechsolutions/shared-domain/common';
import * as react_jsx_runtime from 'react/jsx-runtime';

type DialectCategory = {
    id: string;
    labelKey: string;
    icon: React.ComponentType<{
        className?: string;
    }>;
    gradient: string;
    dialects: DialectOption[];
};
type DialectOption = {
    value: string;
    label: string;
    defaultPort?: number;
    /** 'standard' = host/port/db, 'connection-string' = single URL, 'cloud' = project/dataset/key */
    formType: 'standard' | 'connection-string' | 'cloud-bigquery' | 'cloud-snowflake' | 'cloud-key' | 'vector-key';
};
declare const DIALECT_CATEGORIES: DialectCategory[];
declare function findDialect(value: string): DialectOption | undefined;
declare function findCategory(dialectValue: string): DialectCategory | undefined;
type DatasourceFormData = {
    name: string;
    dialect: string;
    host?: string;
    port?: number;
    database?: string;
    username?: string;
    password?: string;
    schema?: string;
    ssl?: boolean;
    readOnly?: boolean;
    connectionString?: string;
    projectId?: string;
    dataset?: string;
    keyFile?: string;
    account?: string;
    warehouse?: string;
    region?: string;
    bucket?: string;
    token?: string;
    apiKey?: string;
    environment?: string;
    index?: string;
    url?: string;
    /** Whitelist of tables the engine is allowed to query. Empty/undef =
     *  allow every table the credential can see. */
    allowedTables?: string[];
    /** Columns the engine MUST NOT surface to workflows. Applied at the
     *  driver layer — trying to SELECT a blocked column still fails. */
    blockedColumns?: string[];
    /** Max concurrent connections in the org's cached pool (default 5). */
    maxPoolSize?: number;
    /** Query/connect timeout in ms (default 5000). */
    timeoutMs?: number;
};
type Labels = Record<string, string>;
type DatasourceFormModalProps = {
    open: boolean;
    onClose: () => void;
    labels: Labels;
    onSave: (data: DatasourceFormData) => void;
};
declare function DatasourceFormModal({ open, onClose, labels, onSave }: DatasourceFormModalProps): react_jsx_runtime.JSX.Element;
type DatasourceModalProps = {
    open: boolean;
    onClose: () => void;
    labels: Labels;
    onSave: (data: DatasourceFormData) => void;
};
declare function DatasourceModal({ open, onClose, labels, onSave }: DatasourceModalProps): react_jsx_runtime.JSX.Element;

/**
 * Register an authenticated fetch function (call once from a provider/layout).
 * After this, all workflow API calls automatically include the JWT token.
 */
declare function setAuthenticatedFetch(authFetch: typeof fetch): void;
declare function setAccessTokenProvider(provider: () => Promise<string | null>): void;
declare function getCurrentAccessToken(): Promise<string | null>;
/**
 * Build a full URL for a workflow API path, optionally appending the current
 * access token as a query parameter. Useful for APIs that require auth but
 * cannot set custom headers (EventSource, direct links).
 */
declare function buildAuthenticatedApiUrl(path: string, options?: {
    includeAccessToken?: boolean;
}): Promise<string>;
type NodeValidationIssue = {
    nodeId: string;
    nodeType: string;
    field?: string;
    code: string;
    message: string;
};
type AiValidateResponse = {
    ok: boolean;
    structuralIssues: string[];
    nodeIssues: NodeValidationIssue[];
    rationale?: string | null;
};
declare function aiValidateWorkflow(body: {
    graph: WorkflowGraph;
    connectionId?: string;
}): Promise<AiValidateResponse>;
type AiGenerateResponse = {
    graph: WorkflowGraph;
    ok: boolean;
    structuralIssues: string[];
    nodeIssues: NodeValidationIssue[];
    rationale?: string | null;
};
declare function aiGenerateWorkflow(body: {
    prompt: string;
    connectionId: string;
    context?: string;
}): Promise<AiGenerateResponse>;
declare function getWorkflows(): Promise<Workflow[]>;
declare function getWorkflowById(workflowId: string): Promise<Workflow>;
declare function createWorkflow(data: {
    name: string;
    description?: string;
}): Promise<Workflow>;
declare function deleteWorkflow(workflowId: string): Promise<{
    deleted: boolean;
}>;
declare function saveWorkflowDraft(workflowId: string, graph: WorkflowGraph, metadata?: {
    name?: string;
    description?: string;
    slug?: string | null;
    isDraft?: boolean;
    isActive?: boolean;
}): Promise<Workflow>;
/**
 * Settings modal PATCH — updates the workflow's identity + lifecycle
 * fields in one call. Pass `isDraft: true` to move a published workflow
 * back to draft, `isActive: false` to archive, etc. Anything omitted is
 * left untouched.
 */
declare function updateWorkflowSettings(workflowId: string, changes: {
    name?: string;
    description?: string;
    slug?: string | null;
    isDraft?: boolean;
    isActive?: boolean;
}): Promise<Workflow>;
declare function publishWorkflow(workflowId: string): Promise<Workflow>;
declare function executeWorkflow(workflowId: string, inputVariables?: Record<string, VariableValue>): Promise<WorkflowRun>;
declare function getWorkflowRuns(workflowId: string): Promise<WorkflowRun[]>;
interface WorkflowTemplateSummary {
    id: string;
    name: string;
    description: string;
    tags: string[];
}
declare function listWorkflowTemplates(): Promise<WorkflowTemplateSummary[]>;
/**
 * Instantiate a workflow from a template. `connectionId` is required when
 * the template references a `{{connectionId}}` placeholder (all LLM-backed
 * templates do).
 */
declare function createWorkflowFromTemplate(templateId: string, body: {
    connectionId?: string;
    name?: string;
}): Promise<Workflow>;
interface ModelProviderConnection {
    id: string;
    organizationId: string;
    providerId: string;
    providerSlug?: string;
    name: string;
    region?: string;
    endpoint?: string;
    credentialRef?: string;
    apiKeyRef?: string;
    modelFilter?: string[];
    config?: Record<string, unknown>;
    enabled: boolean;
    createdAt?: string;
    updatedAt?: string;
}
declare function listModelProviderConnections(): Promise<ModelProviderConnection[]>;
/**
 * One model family record joined onto a provider in the catalog.
 * Mirrors the `FamilyView` shape returned by `agents_providers.rs`.
 */
type ModelFamilyCatalogEntry = {
    id: string;
    slug: string;
    name: string;
    modelIds: string[];
    maxTokens?: number | null;
    contextWindow?: string | null;
    supportsTools?: boolean | null;
    supportsVision?: boolean | null;
    costTier?: string | null;
};
/**
 * Catalog of supported LLM providers. Previously hard-coded in the
 * connections modal; now backed by `astrlabe.model_providers` +
 * `astrlabe.model_families` so new providers can be added server-side
 * without a frontend release.
 */
type ModelProviderCatalogEntry = {
    id: string;
    slug: string;
    /** Slug normalized into the `ModelProviderType` enum the runtime uses. */
    normalizedSlug: string;
    name: string;
    category?: string | null;
    logoUrl?: string | null;
    docsUrl?: string | null;
    authType?: string | null;
    /**
     * Full family records joined from `model_families`. Empty array if no
     * families are seeded for this provider (`custom`, where the operator
     * supplies the model id at node-config time).
     */
    families: ModelFamilyCatalogEntry[];
    /** @deprecated — array of family slugs only. New callers read `families`. */
    supportedModelFamilies?: unknown;
    regions?: string[] | null;
    enabled: boolean;
};
declare function listModelProviderCatalog(): Promise<ModelProviderCatalogEntry[]>;
declare function createModelProviderConnection(body: {
    providerSlug?: string;
    providerId?: string;
    name: string;
    region?: string;
    endpoint?: string;
    credentialRef?: string;
    apiKeyRef?: string;
    modelFilter?: string[];
    config?: Record<string, unknown>;
}): Promise<ModelProviderConnection>;
declare function updateModelProviderConnection(id: string, body: {
    name?: string;
    region?: string;
    endpoint?: string;
    credentialRef?: string;
    apiKeyRef?: string;
    modelFilter?: string[];
    config?: Record<string, unknown>;
    enabled?: boolean;
}): Promise<ModelProviderConnection>;
declare function deleteModelProviderConnection(id: string): Promise<{
    deleted: boolean;
}>;
declare function getAgentPrompts(agentId: string): Promise<AgentPrompt[]>;
declare function getAgentModels(): Promise<AgentModel[]>;
declare function getAgentTools(agentId: string): Promise<WorkflowTool[]>;
declare function updateAgentTool(toolId: string, updates: Partial<WorkflowTool>): Promise<WorkflowTool>;
declare function createAgentTool(tool: Omit<WorkflowTool, 'organizationId' | 'createdAt' | 'updatedAt'>): Promise<WorkflowTool>;
declare function deleteAgentTool(toolId: string): Promise<{
    deleted: boolean;
}>;
declare function getAgentToolDefinitions(): Promise<AgentTool[]>;
/**
 * Create a custom agent tool definition. The backend (`POST
 * /agents/tool-definitions`) requires:
 *   { name, description, toolType, inputSchema, handlerConfig }
 * where `inputSchema` is a JSON-Schema object with `type` + `properties`.
 */
declare function createAgentToolDefinition(toolDef: {
    name: string;
    description?: string;
    toolType: string;
    inputSchema: Record<string, unknown>;
    handlerConfig: Record<string, unknown>;
}): Promise<AgentTool>;
declare function getAgentRules(): Promise<AgentRule[]>;
declare function updateAgentRule(ruleId: string, updates: Partial<AgentRule> & Record<string, unknown>): Promise<AgentRule>;
declare function createAgentRule(rule: Partial<AgentRule> & Record<string, unknown>): Promise<AgentRule>;
declare function deleteAgentRule(ruleId: string): Promise<{
    deleted: boolean;
}>;
declare function executeAgentRule(ruleId: string, input: Record<string, unknown>): Promise<unknown>;
declare function createAgentConfig(input: Partial<AgentConfigLike>): Promise<AgentConfigLike>;
declare function updateAgentConfig(agentId: string, updates: Partial<AgentConfigLike>): Promise<AgentConfigLike>;
declare function deleteAgentConfig(agentId: string): Promise<{
    deleted: boolean;
}>;
declare function createAgentPrompt(input: Omit<AgentPrompt, 'promptId' | 'version' | 'createdAt'>): Promise<AgentPrompt>;
declare function updateAgentPrompt(promptId: string, updates: Partial<AgentPrompt>): Promise<AgentPrompt>;
declare function deleteAgentPrompt(promptId: string): Promise<{
    deleted: boolean;
}>;
/**
 * Patch an existing tool definition. The Rust handler takes the id in
 * the BODY (`toolId`) rather than the URL, and accepts a narrower set
 * of fields than create: `{toolId, name?, description?, parameters?,
 * implementationKey?}`. `implementationKey` is a JSON string that wraps
 * `handlerConfig` — the page wrapper produces that shape before calling.
 */
declare function updateAgentToolDefinition(agentToolId: string, updates: {
    name?: string;
    description?: string;
    parameters?: Record<string, unknown>;
    implementationKey?: string;
}): Promise<AgentTool>;
declare function deleteAgentToolDefinition(agentToolId: string): Promise<{
    deleted: boolean;
}>;
type WorkflowRunListParams = {
    workflowId?: string;
    status?: string;
    limit?: number;
    offset?: number;
};
declare function listWorkflowRuns(params?: WorkflowRunListParams): Promise<{
    items: WorkflowRun[];
    total: number;
}>;
declare function getWorkflowRunById(runId: string): Promise<WorkflowRun>;
declare function cancelWorkflowRun(runId: string): Promise<WorkflowRun>;
declare function replayWorkflowRun(workflowId: string, runId: string, overrides?: Record<string, VariableValue>): Promise<WorkflowRun>;
type NodeMetrics = {
    tokensIn?: number;
    tokensOut?: number;
    costUsd?: number;
    provider?: string;
    model?: string;
};
type RunTimelineEntry = {
    nodeId: string;
    nodeType: string;
    status: 'pending' | 'running' | 'completed' | 'failed' | 'skipped';
    startedAt: string | null;
    completedAt: string | null;
    durationMs: number | null;
    inputs?: Record<string, unknown>;
    outputs?: Record<string, unknown>;
    error?: string;
    metrics?: NodeMetrics;
};
declare function getRunTimeline(workflowId: string, runId: string): Promise<RunTimelineEntry[]>;
type AnalyticsSummary = {
    totalRuns: number;
    runsByStatus: Record<string, number>;
    avgDurationMs: number;
    successRate: number;
    perWorkflow: Array<{
        workflowId: string;
        name: string;
        runs: number;
        successRate: number;
    }>;
    series?: Array<{
        date: string;
        runs: number;
        successes: number;
        failures: number;
    }>;
};
declare function getAnalyticsSummary(params?: {
    from?: string;
    to?: string;
}): Promise<AnalyticsSummary>;
type PresignUploadInput = {
    fileName: string;
    contentType: string;
    fileSize?: number;
    folder?: string;
};
type PresignedUpload = {
    uploadUrl: string;
    downloadUrl: string;
    objectKey: string;
    expiresAt: string;
};
declare function presignUpload(input: PresignUploadInput): Promise<PresignedUpload>;
declare function getUploadDownloadUrl(objectKey: string): Promise<{
    downloadUrl: string;
}>;
declare function deleteUpload(objectKey: string): Promise<{
    deleted: boolean;
}>;
type RunEvent = {
    /**
     * Discriminator for the event payload. The set is open-ended on purpose
     * — Phase 2/3 of the generative-UI work adds `ui-render` (per-section
     * progressive rendering) and `run-paused` (operator-input pause) without
     * a breaking change.
     */
    type: 'run-started' | 'node-started' | 'node-completed' | 'node-failed' | 'run-completed' | 'run-failed' | 'run-paused' | 'ui-render' | 'log';
    runId: string;
    nodeId?: string;
    data?: Record<string, unknown>;
    timestamp: string;
};
type PublicSampleWorkflow = {
    slug: string;
    name: string | null;
    description: string | null;
    graph: WorkflowGraph;
    version: number | null;
    publishedAt: string | null;
};
declare function getPublicSampleWorkflow(slug: string): Promise<PublicSampleWorkflow>;
type ApprovalDecision = {
    /** True approves and resumes the run; false fails it with `reason`. */
    approved: boolean;
    /** Operator-supplied rationale, surfaced on the audit row. */
    reason?: string;
    /**
     * Captured payload — for `input_request` sections this carries the
     * form field values. The downstream workflow nodes read it from
     * `inputs.approvals.<nodeId>.payload`.
     */
    payload?: Record<string, unknown>;
};
type ApprovalResponse = {
    approvalId: string;
    sourceRunId: string;
    resumedRunId: string;
    nodeId: string;
    approved: boolean;
    status: string;
};
/**
 * Resolve a paused workflow run by recording an operator decision.
 * The backend writes an audit row, merges the decision into the run's
 * inputs, and re-executes — see #457.
 */
declare function submitApproval(runId: string, nodeId: string, decision: ApprovalDecision): Promise<ApprovalResponse>;
/**
 * Connection state for {@link subscribeToRunEvents}. UI consumers can
 * surface this — e.g. show "reconnecting…" badge — by passing an
 * `onState` callback.
 */
type RunSubscriptionState = 'live' | 'reconnecting' | 'polling' | 'closed';
/**
 * Subscribe to a run's event stream with auto-reconnect + polling fallback.
 *
 * The default `EventSource` drops silently on idle proxies / cold-restarts
 * (CloudFront + Lambda Function URL combo at customer scale will close
 * an idle connection after ~30–60s). When that happens the run viewer
 * looks frozen with no signal to the user.
 *
 * Lifecycle:
 *  1. Open SSE. On `open`, state = `live`.
 *  2. On `error`, close the source and exponential-backoff (1s → 2s → 4s
 *     → 8s → 16s, with jitter). State = `reconnecting`.
 *  3. After {@link SSE_MAX_RECONNECT_ATTEMPTS} failures, fall back to
 *     polling `GET /workflow-runs/{runId}` every 5s. State = `polling`.
 *  4. On terminal event (`run-completed` / `run-failed`) or terminal
 *     polled status (completed/failed/cancelled), close + state = `closed`.
 *  5. Returned disposer also flips to `closed`; idempotent.
 *
 * Backwards-compatible with the previous 3-arg signature; pass `onState`
 * as a 4th arg if you want to render connection-state UI.
 */
declare function subscribeToRunEvents(runId: string, onEvent: (event: RunEvent) => void, onError?: (error: Event) => void, onState?: (state: RunSubscriptionState) => void): () => void;
declare function getAgentConfigsWithPrompts(): Promise<AgentWithPrompts[]>;
declare function getDatasources(): Promise<DataSource[]>;
declare function createDatasource(data: DatasourceFormData): Promise<DataSource>;
declare function getDatasourceTables(datasourceId: string): Promise<string[]>;
declare function getDatasourceSchema(datasourceId: string, table: string): Promise<Array<{
    name: string;
    type: string;
    nullable?: boolean;
}>>;

export { getAgentToolDefinitions as $, type AnalyticsSummary as A, createAgentTool as B, createAgentToolDefinition as C, type DatasourceFormData as D, createDatasource as E, createModelProviderConnection as F, createWorkflow as G, createWorkflowFromTemplate as H, deleteAgentConfig as I, deleteAgentPrompt as J, deleteAgentRule as K, deleteAgentTool as L, type ModelProviderConnection as M, type NodeMetrics as N, deleteAgentToolDefinition as O, type PresignUploadInput as P, deleteModelProviderConnection as Q, type RunTimelineEntry as R, deleteUpload as S, deleteWorkflow as T, executeAgentRule as U, executeWorkflow as V, type WorkflowRunListParams as W, getAgentConfigsWithPrompts as X, getAgentModels as Y, getAgentPrompts as Z, getAgentRules as _, DIALECT_CATEGORIES as a, getAgentTools as a0, getAnalyticsSummary as a1, getCurrentAccessToken as a2, getDatasourceSchema as a3, getDatasourceTables as a4, getDatasources as a5, getPublicSampleWorkflow as a6, getRunTimeline as a7, getUploadDownloadUrl as a8, getWorkflowById as a9, getWorkflowRunById as aa, getWorkflowRuns as ab, getWorkflows as ac, listModelProviderCatalog as ad, listModelProviderConnections as ae, listWorkflowRuns as af, listWorkflowTemplates as ag, presignUpload as ah, publishWorkflow as ai, replayWorkflowRun as aj, saveWorkflowDraft as ak, setAccessTokenProvider as al, setAuthenticatedFetch as am, submitApproval as an, subscribeToRunEvents as ao, updateAgentConfig as ap, updateAgentPrompt as aq, updateAgentRule as ar, updateAgentTool as as, updateAgentToolDefinition as at, updateModelProviderConnection as au, updateWorkflowSettings as av, DatasourceFormModal as b, type DatasourceFormModalProps as c, DatasourceModal as d, type DatasourceModalProps as e, findCategory as f, findDialect as g, type AiGenerateResponse as h, type AiValidateResponse as i, type ApprovalDecision as j, type ApprovalResponse as k, type ModelFamilyCatalogEntry as l, type ModelProviderCatalogEntry as m, type NodeValidationIssue as n, type PresignedUpload as o, type PublicSampleWorkflow as p, type RunEvent as q, type RunSubscriptionState as r, type WorkflowTemplateSummary as s, aiGenerateWorkflow as t, aiValidateWorkflow as u, buildAuthenticatedApiUrl as v, cancelWorkflowRun as w, createAgentConfig as x, createAgentPrompt as y, createAgentRule as z };
