import type { Db } from "@rudderhq/db";
import { approvals, chatConversations, chatGenerations } from "@rudderhq/db";
import { type ChatQueuedMessagePayload, type ChatStreamTranscriptEntry } from "@rudderhq/shared";
type ChatGenerationRow = typeof chatGenerations.$inferSelect;
type ConversationSummaryCursor = {
    activityAt: Date;
    title: string;
    threadKey: string;
};
type ConversationSourceMetadata = {
    source: "agent_integration";
    provider: string;
    integrationId: string;
    externalChatId: string;
    externalChatType: string;
};
type ApprovalRow = typeof approvals.$inferSelect;
export declare function chatService(db: Db): {
    list: (orgId: string, options?: {
        status?: "active" | "resolved" | "archived" | "all";
        q?: string;
        limit?: number;
    }, userId?: string | null) => Promise<{
        primaryIssue: {
            id: string;
            identifier: string | null;
            title: string;
            status: string;
            priority: string;
        } | null;
        latestReplyPreview: string | null;
        latestUserMessagePreview: string | null;
        userMessageCount: number;
        contextLinks: {
            entity: {
                type: "issue" | "project" | "agent";
                id: string;
                label: string;
                subtitle: string | null;
                identifier: string | null;
                status: string | null;
                description?: string | null;
                priority?: string | null;
                href: string;
            } | null;
            conversationId: string;
            id: string;
            orgId: string;
            createdAt: Date;
            updatedAt: Date;
            entityType: string;
            entityId: string;
            metadata: Record<string, unknown> | null;
        }[];
        sourceMetadata: ConversationSourceMetadata | null;
        mutability: "native_chat" | "external_bound_chat" | "native_fork_from_external";
        lastReadAt: Date | null;
        isPinned: boolean;
        unreadCount: number;
        isUnread: boolean;
        needsAttention: boolean;
        id: string;
        orgId: string;
        status: string;
        createdAt: Date;
        updatedAt: Date;
        createdByUserId: string | null;
        title: string;
        summary: string | null;
        preferredAgentId: string | null;
        issueCreationMode: string;
        planMode: boolean;
        routedAgentId: string | null;
        primaryIssueId: string | null;
        resolvedAt: Date | null;
        forkedFromConversationId: string | null;
        forkedFromMessageId: string | null;
        forkRootConversationId: string | null;
        lastMessageAt: Date | null;
    }[]>;
    listSummaries: (orgId: string, options?: {
        status?: "active" | "resolved" | "archived" | "all";
        limit?: number;
        after?: ConversationSummaryCursor | null;
        excludePinned?: boolean;
    }, userId?: string | null) => Promise<{
        latestReplyPreview: string | null;
        latestUserMessagePreview: string | null;
        userMessageCount: number;
        sourceMetadata: ConversationSourceMetadata | null;
        mutability: "native_chat" | "external_bound_chat" | "native_fork_from_external";
        lastReadAt: Date | null;
        isPinned: boolean;
        unreadCount: number;
        isUnread: boolean;
        needsAttention: boolean;
        id: string;
        orgId: string;
        status: string;
        createdAt: Date;
        updatedAt: Date;
        createdByUserId: string | null;
        title: string;
        summary: string | null;
        preferredAgentId: string | null;
        issueCreationMode: string;
        planMode: boolean;
        routedAgentId: string | null;
        primaryIssueId: string | null;
        resolvedAt: Date | null;
        forkedFromConversationId: string | null;
        forkedFromMessageId: string | null;
        forkRootConversationId: string | null;
        lastMessageAt: Date | null;
    }[]>;
    listPinnedSummaries: (orgId: string, userId: string) => Promise<{
        latestReplyPreview: string | null;
        latestUserMessagePreview: string | null;
        userMessageCount: number;
        sourceMetadata: ConversationSourceMetadata | null;
        mutability: "native_chat" | "external_bound_chat" | "native_fork_from_external";
        lastReadAt: Date | null;
        isPinned: boolean;
        unreadCount: number;
        isUnread: boolean;
        needsAttention: boolean;
        id: string;
        orgId: string;
        status: string;
        createdAt: Date;
        updatedAt: Date;
        createdByUserId: string | null;
        title: string;
        summary: string | null;
        preferredAgentId: string | null;
        issueCreationMode: string;
        planMode: boolean;
        routedAgentId: string | null;
        primaryIssueId: string | null;
        resolvedAt: Date | null;
        forkedFromConversationId: string | null;
        forkedFromMessageId: string | null;
        forkRootConversationId: string | null;
        lastMessageAt: Date | null;
    }[]>;
    listSummariesByIds: (orgId: string, conversationIds: string[], userId?: string | null) => Promise<{
        latestReplyPreview: string | null;
        latestUserMessagePreview: string | null;
        userMessageCount: number;
        sourceMetadata: ConversationSourceMetadata | null;
        mutability: "native_chat" | "external_bound_chat" | "native_fork_from_external";
        lastReadAt: Date | null;
        isPinned: boolean;
        unreadCount: number;
        isUnread: boolean;
        needsAttention: boolean;
        id: string;
        orgId: string;
        status: string;
        createdAt: Date;
        updatedAt: Date;
        createdByUserId: string | null;
        title: string;
        summary: string | null;
        preferredAgentId: string | null;
        issueCreationMode: string;
        planMode: boolean;
        routedAgentId: string | null;
        primaryIssueId: string | null;
        resolvedAt: Date | null;
        forkedFromConversationId: string | null;
        forkedFromMessageId: string | null;
        forkRootConversationId: string | null;
        lastMessageAt: Date | null;
    }[]>;
    getById: (id: string, userId?: string | null) => Promise<{
        primaryIssue: {
            id: string;
            identifier: string | null;
            title: string;
            status: string;
            priority: string;
        } | null;
        latestReplyPreview: string | null;
        latestUserMessagePreview: string | null;
        userMessageCount: number;
        contextLinks: {
            entity: {
                type: "issue" | "project" | "agent";
                id: string;
                label: string;
                subtitle: string | null;
                identifier: string | null;
                status: string | null;
                description?: string | null;
                priority?: string | null;
                href: string;
            } | null;
            conversationId: string;
            id: string;
            orgId: string;
            createdAt: Date;
            updatedAt: Date;
            entityType: string;
            entityId: string;
            metadata: Record<string, unknown> | null;
        }[];
        sourceMetadata: ConversationSourceMetadata | null;
        mutability: "native_chat" | "external_bound_chat" | "native_fork_from_external";
        lastReadAt: Date | null;
        isPinned: boolean;
        unreadCount: number;
        isUnread: boolean;
        needsAttention: boolean;
        id: string;
        orgId: string;
        status: string;
        createdAt: Date;
        updatedAt: Date;
        createdByUserId: string | null;
        title: string;
        summary: string | null;
        preferredAgentId: string | null;
        issueCreationMode: string;
        planMode: boolean;
        routedAgentId: string | null;
        primaryIssueId: string | null;
        resolvedAt: Date | null;
        forkedFromConversationId: string | null;
        forkedFromMessageId: string | null;
        forkRootConversationId: string | null;
        lastMessageAt: Date | null;
    } | null>;
    create: (orgId: string, data: {
        title?: string;
        summary?: string | null;
        preferredAgentId?: string | null;
        issueCreationMode: "manual_approval" | "auto_create";
        planMode: boolean;
        createdByUserId: string | null;
        contextLinks?: Array<{
            entityType: "issue" | "project" | "agent";
            entityId: string;
            metadata?: Record<string, unknown> | null;
        }>;
    }) => Promise<{
        primaryIssue: {
            id: string;
            identifier: string | null;
            title: string;
            status: string;
            priority: string;
        } | null;
        latestReplyPreview: string | null;
        latestUserMessagePreview: string | null;
        userMessageCount: number;
        contextLinks: {
            entity: {
                type: "issue" | "project" | "agent";
                id: string;
                label: string;
                subtitle: string | null;
                identifier: string | null;
                status: string | null;
                description?: string | null;
                priority?: string | null;
                href: string;
            } | null;
            conversationId: string;
            id: string;
            orgId: string;
            createdAt: Date;
            updatedAt: Date;
            entityType: string;
            entityId: string;
            metadata: Record<string, unknown> | null;
        }[];
        sourceMetadata: ConversationSourceMetadata | null;
        mutability: "native_chat" | "external_bound_chat" | "native_fork_from_external";
        lastReadAt: Date | null;
        isPinned: boolean;
        unreadCount: number;
        isUnread: boolean;
        needsAttention: boolean;
        id: string;
        orgId: string;
        status: string;
        createdAt: Date;
        updatedAt: Date;
        createdByUserId: string | null;
        title: string;
        summary: string | null;
        preferredAgentId: string | null;
        issueCreationMode: string;
        planMode: boolean;
        routedAgentId: string | null;
        primaryIssueId: string | null;
        resolvedAt: Date | null;
        forkedFromConversationId: string | null;
        forkedFromMessageId: string | null;
        forkRootConversationId: string | null;
        lastMessageAt: Date | null;
    } | null>;
    update: (id: string, patch: Partial<typeof chatConversations.$inferInsert>) => Promise<{
        primaryIssue: {
            id: string;
            identifier: string | null;
            title: string;
            status: string;
            priority: string;
        } | null;
        latestReplyPreview: string | null;
        latestUserMessagePreview: string | null;
        userMessageCount: number;
        contextLinks: {
            entity: {
                type: "issue" | "project" | "agent";
                id: string;
                label: string;
                subtitle: string | null;
                identifier: string | null;
                status: string | null;
                description?: string | null;
                priority?: string | null;
                href: string;
            } | null;
            conversationId: string;
            id: string;
            orgId: string;
            createdAt: Date;
            updatedAt: Date;
            entityType: string;
            entityId: string;
            metadata: Record<string, unknown> | null;
        }[];
        sourceMetadata: ConversationSourceMetadata | null;
        mutability: "native_chat" | "external_bound_chat" | "native_fork_from_external";
        lastReadAt: Date | null;
        isPinned: boolean;
        unreadCount: number;
        isUnread: boolean;
        needsAttention: boolean;
        id: string;
        orgId: string;
        status: string;
        createdAt: Date;
        updatedAt: Date;
        createdByUserId: string | null;
        title: string;
        summary: string | null;
        preferredAgentId: string | null;
        issueCreationMode: string;
        planMode: boolean;
        routedAgentId: string | null;
        primaryIssueId: string | null;
        resolvedAt: Date | null;
        forkedFromConversationId: string | null;
        forkedFromMessageId: string | null;
        forkRootConversationId: string | null;
        lastMessageAt: Date | null;
    } | null>;
    updateDefaultTitle: (id: string, title: string, expectedCurrentTitle?: string) => Promise<{
        primaryIssue: {
            id: string;
            identifier: string | null;
            title: string;
            status: string;
            priority: string;
        } | null;
        latestReplyPreview: string | null;
        latestUserMessagePreview: string | null;
        userMessageCount: number;
        contextLinks: {
            entity: {
                type: "issue" | "project" | "agent";
                id: string;
                label: string;
                subtitle: string | null;
                identifier: string | null;
                status: string | null;
                description?: string | null;
                priority?: string | null;
                href: string;
            } | null;
            conversationId: string;
            id: string;
            orgId: string;
            createdAt: Date;
            updatedAt: Date;
            entityType: string;
            entityId: string;
            metadata: Record<string, unknown> | null;
        }[];
        sourceMetadata: ConversationSourceMetadata | null;
        mutability: "native_chat" | "external_bound_chat" | "native_fork_from_external";
        lastReadAt: Date | null;
        isPinned: boolean;
        unreadCount: number;
        isUnread: boolean;
        needsAttention: boolean;
        id: string;
        orgId: string;
        status: string;
        createdAt: Date;
        updatedAt: Date;
        createdByUserId: string | null;
        title: string;
        summary: string | null;
        preferredAgentId: string | null;
        issueCreationMode: string;
        planMode: boolean;
        routedAgentId: string | null;
        primaryIssueId: string | null;
        resolvedAt: Date | null;
        forkedFromConversationId: string | null;
        forkedFromMessageId: string | null;
        forkRootConversationId: string | null;
        lastMessageAt: Date | null;
    } | null>;
    replaceSystemGeneratedTitle: (id: string, expectedTitle: string, title: string) => Promise<{
        primaryIssue: {
            id: string;
            identifier: string | null;
            title: string;
            status: string;
            priority: string;
        } | null;
        latestReplyPreview: string | null;
        latestUserMessagePreview: string | null;
        userMessageCount: number;
        contextLinks: {
            entity: {
                type: "issue" | "project" | "agent";
                id: string;
                label: string;
                subtitle: string | null;
                identifier: string | null;
                status: string | null;
                description?: string | null;
                priority?: string | null;
                href: string;
            } | null;
            conversationId: string;
            id: string;
            orgId: string;
            createdAt: Date;
            updatedAt: Date;
            entityType: string;
            entityId: string;
            metadata: Record<string, unknown> | null;
        }[];
        sourceMetadata: ConversationSourceMetadata | null;
        mutability: "native_chat" | "external_bound_chat" | "native_fork_from_external";
        lastReadAt: Date | null;
        isPinned: boolean;
        unreadCount: number;
        isUnread: boolean;
        needsAttention: boolean;
        id: string;
        orgId: string;
        status: string;
        createdAt: Date;
        updatedAt: Date;
        createdByUserId: string | null;
        title: string;
        summary: string | null;
        preferredAgentId: string | null;
        issueCreationMode: string;
        planMode: boolean;
        routedAgentId: string | null;
        primaryIssueId: string | null;
        resolvedAt: Date | null;
        forkedFromConversationId: string | null;
        forkedFromMessageId: string | null;
        forkRootConversationId: string | null;
        lastMessageAt: Date | null;
    } | null>;
    listAttachmentsForConversation: (conversationId: string) => Promise<{
        id: string;
        orgId: string;
        assetId: string;
        objectKey: string;
    }[]>;
    remove: (id: string) => Promise<{
        id: string;
        orgId: string;
        status: string;
        createdAt: Date;
        updatedAt: Date;
        createdByUserId: string | null;
        title: string;
        summary: string | null;
        preferredAgentId: string | null;
        issueCreationMode: string;
        planMode: boolean;
        routedAgentId: string | null;
        primaryIssueId: string | null;
        resolvedAt: Date | null;
        forkedFromConversationId: string | null;
        forkedFromMessageId: string | null;
        forkRootConversationId: string | null;
        lastMessageAt: Date | null;
    } | null>;
    forkConversation: (input: {
        sourceConversationId: string;
        orgId: string;
        userId: string;
        sourceMessageId?: string | null;
        title?: string | null;
        createdByUserId: string | null;
    }) => Promise<{
        primaryIssue: {
            id: string;
            identifier: string | null;
            title: string;
            status: string;
            priority: string;
        } | null;
        latestReplyPreview: string | null;
        latestUserMessagePreview: string | null;
        userMessageCount: number;
        contextLinks: {
            entity: {
                type: "issue" | "project" | "agent";
                id: string;
                label: string;
                subtitle: string | null;
                identifier: string | null;
                status: string | null;
                description?: string | null;
                priority?: string | null;
                href: string;
            } | null;
            conversationId: string;
            id: string;
            orgId: string;
            createdAt: Date;
            updatedAt: Date;
            entityType: string;
            entityId: string;
            metadata: Record<string, unknown> | null;
        }[];
        sourceMetadata: ConversationSourceMetadata | null;
        mutability: "native_chat" | "external_bound_chat" | "native_fork_from_external";
        lastReadAt: Date | null;
        isPinned: boolean;
        unreadCount: number;
        isUnread: boolean;
        needsAttention: boolean;
        id: string;
        orgId: string;
        status: string;
        createdAt: Date;
        updatedAt: Date;
        createdByUserId: string | null;
        title: string;
        summary: string | null;
        preferredAgentId: string | null;
        issueCreationMode: string;
        planMode: boolean;
        routedAgentId: string | null;
        primaryIssueId: string | null;
        resolvedAt: Date | null;
        forkedFromConversationId: string | null;
        forkedFromMessageId: string | null;
        forkRootConversationId: string | null;
        lastMessageAt: Date | null;
    } | null>;
    resolve: (id: string) => Promise<{
        primaryIssue: {
            id: string;
            identifier: string | null;
            title: string;
            status: string;
            priority: string;
        } | null;
        latestReplyPreview: string | null;
        latestUserMessagePreview: string | null;
        userMessageCount: number;
        contextLinks: {
            entity: {
                type: "issue" | "project" | "agent";
                id: string;
                label: string;
                subtitle: string | null;
                identifier: string | null;
                status: string | null;
                description?: string | null;
                priority?: string | null;
                href: string;
            } | null;
            conversationId: string;
            id: string;
            orgId: string;
            createdAt: Date;
            updatedAt: Date;
            entityType: string;
            entityId: string;
            metadata: Record<string, unknown> | null;
        }[];
        sourceMetadata: ConversationSourceMetadata | null;
        mutability: "native_chat" | "external_bound_chat" | "native_fork_from_external";
        lastReadAt: Date | null;
        isPinned: boolean;
        unreadCount: number;
        isUnread: boolean;
        needsAttention: boolean;
        id: string;
        orgId: string;
        status: string;
        createdAt: Date;
        updatedAt: Date;
        createdByUserId: string | null;
        title: string;
        summary: string | null;
        preferredAgentId: string | null;
        issueCreationMode: string;
        planMode: boolean;
        routedAgentId: string | null;
        primaryIssueId: string | null;
        resolvedAt: Date | null;
        forkedFromConversationId: string | null;
        forkedFromMessageId: string | null;
        forkRootConversationId: string | null;
        lastMessageAt: Date | null;
    } | null>;
    markRead: (conversationId: string, orgId: string, userId: string, readAt?: Date) => Promise<{
        conversationId: string;
        id: string;
        orgId: string;
        createdAt: Date;
        updatedAt: Date;
        userId: string;
        lastReadAt: Date;
        pinnedAt: Date | null;
    }>;
    markUnread: (conversationId: string, orgId: string, userId: string) => Promise<{
        conversationId: string;
        id: string;
        orgId: string;
        createdAt: Date;
        updatedAt: Date;
        userId: string;
        lastReadAt: Date;
        pinnedAt: Date | null;
    }>;
    setPinned: (conversationId: string, orgId: string, userId: string, pinned: boolean) => Promise<{
        conversationId: string;
        id: string;
        orgId: string;
        createdAt: Date;
        updatedAt: Date;
        userId: string;
        lastReadAt: Date;
        pinnedAt: Date | null;
    }>;
    createGeneration: (orgId: string, conversationId: string) => Promise<ChatGenerationRow>;
    markGenerationTerminal: (generationId: string | null | undefined, status: "completed" | "failed" | "stopped" | "aborted") => Promise<{
        id: string;
        orgId: string;
        conversationId: string;
        status: string;
        terminalReason: string | null;
        startedAt: Date;
        completedAt: Date | null;
        createdAt: Date;
        updatedAt: Date;
    } | null>;
    getLatestActiveGeneration: (conversationId: string) => Promise<{
        conversationId: string;
        id: string;
        orgId: string;
        status: string;
        createdAt: Date;
        updatedAt: Date;
        startedAt: Date;
        completedAt: Date | null;
        terminalReason: string | null;
    }>;
    getLatestGeneration: (conversationId: string) => Promise<{
        conversationId: string;
        id: string;
        orgId: string;
        status: string;
        createdAt: Date;
        updatedAt: Date;
        startedAt: Date;
        completedAt: Date | null;
        terminalReason: string | null;
    }>;
    getQueueSnapshot: (conversationId: string, activeGenerationId?: string | null) => Promise<{
        activeGenerationId: string;
        items: {
            payload: ChatQueuedMessagePayload;
            conversationId: string;
            id: string;
            orgId: string;
            status: string;
            createdAt: Date;
            updatedAt: Date;
            cancelledAt: Date | null;
            sourceMessageId: string | null;
            clientMutationId: string;
            expectedGenerationId: string | null;
            version: number;
            position: number;
            activeGenerationId: string | null;
            deliveryAttempts: number;
            lastAttemptAt: Date | null;
            lastDeliveryReason: string | null;
            deliveredMessageId: string | null;
            steeredAt: Date | null;
            dequeuedAt: Date | null;
        }[];
    }>;
    listQueuedMessages: (conversationId: string) => Promise<{
        payload: ChatQueuedMessagePayload;
        conversationId: string;
        id: string;
        orgId: string;
        status: string;
        createdAt: Date;
        updatedAt: Date;
        cancelledAt: Date | null;
        sourceMessageId: string | null;
        clientMutationId: string;
        expectedGenerationId: string | null;
        version: number;
        position: number;
        activeGenerationId: string | null;
        deliveryAttempts: number;
        lastAttemptAt: Date | null;
        lastDeliveryReason: string | null;
        deliveredMessageId: string | null;
        steeredAt: Date | null;
        dequeuedAt: Date | null;
    }[]>;
    createQueuedMessage: (input: {
        orgId: string;
        conversationId: string;
        clientMutationId: string;
        payload: ChatQueuedMessagePayload;
        expectedGenerationId?: string | null;
    }) => Promise<{
        payload: ChatQueuedMessagePayload;
        conversationId: string;
        id: string;
        orgId: string;
        status: string;
        createdAt: Date;
        updatedAt: Date;
        cancelledAt: Date | null;
        sourceMessageId: string | null;
        clientMutationId: string;
        expectedGenerationId: string | null;
        version: number;
        position: number;
        activeGenerationId: string | null;
        deliveryAttempts: number;
        lastAttemptAt: Date | null;
        lastDeliveryReason: string | null;
        deliveredMessageId: string | null;
        steeredAt: Date | null;
        dequeuedAt: Date | null;
    }>;
    updateQueuedMessage: (input: {
        conversationId: string;
        itemId: string;
        version: number;
        payload: ChatQueuedMessagePayload;
    }) => Promise<{
        payload: ChatQueuedMessagePayload;
        conversationId: string;
        id: string;
        orgId: string;
        status: string;
        createdAt: Date;
        updatedAt: Date;
        cancelledAt: Date | null;
        sourceMessageId: string | null;
        clientMutationId: string;
        expectedGenerationId: string | null;
        version: number;
        position: number;
        activeGenerationId: string | null;
        deliveryAttempts: number;
        lastAttemptAt: Date | null;
        lastDeliveryReason: string | null;
        deliveredMessageId: string | null;
        steeredAt: Date | null;
        dequeuedAt: Date | null;
    }>;
    cancelQueuedMessage: (input: {
        conversationId: string;
        itemId: string;
        version?: number | null;
    }) => Promise<{
        payload: ChatQueuedMessagePayload;
        conversationId: string;
        id: string;
        orgId: string;
        status: string;
        createdAt: Date;
        updatedAt: Date;
        cancelledAt: Date | null;
        sourceMessageId: string | null;
        clientMutationId: string;
        expectedGenerationId: string | null;
        version: number;
        position: number;
        activeGenerationId: string | null;
        deliveryAttempts: number;
        lastAttemptAt: Date | null;
        lastDeliveryReason: string | null;
        deliveredMessageId: string | null;
        steeredAt: Date | null;
        dequeuedAt: Date | null;
    }>;
    markQueuedMessageSteerFallback: (input: {
        conversationId: string;
        itemId: string;
        reason: "unsupported" | "stale_generation" | "closing";
        activeGenerationId?: string | null;
    }) => Promise<{
        payload: ChatQueuedMessagePayload;
        conversationId: string;
        id: string;
        orgId: string;
        status: string;
        createdAt: Date;
        updatedAt: Date;
        cancelledAt: Date | null;
        sourceMessageId: string | null;
        clientMutationId: string;
        expectedGenerationId: string | null;
        version: number;
        position: number;
        activeGenerationId: string | null;
        deliveryAttempts: number;
        lastAttemptAt: Date | null;
        lastDeliveryReason: string | null;
        deliveredMessageId: string | null;
        steeredAt: Date | null;
        dequeuedAt: Date | null;
    }>;
    claimNextQueuedMessage: (conversationId: string) => Promise<{
        payload: ChatQueuedMessagePayload;
        conversationId: string;
        id: string;
        orgId: string;
        status: string;
        createdAt: Date;
        updatedAt: Date;
        cancelledAt: Date | null;
        sourceMessageId: string | null;
        clientMutationId: string;
        expectedGenerationId: string | null;
        version: number;
        position: number;
        activeGenerationId: string | null;
        deliveryAttempts: number;
        lastAttemptAt: Date | null;
        lastDeliveryReason: string | null;
        deliveredMessageId: string | null;
        steeredAt: Date | null;
        dequeuedAt: Date | null;
    } | null>;
    releaseQueuedMessageClaim: (input: {
        conversationId: string;
        itemId: string;
        reason: "delivery_failed" | "delivery_aborted" | "claim_expired";
    }) => Promise<{
        payload: ChatQueuedMessagePayload;
        conversationId: string;
        id: string;
        orgId: string;
        status: string;
        createdAt: Date;
        updatedAt: Date;
        cancelledAt: Date | null;
        sourceMessageId: string | null;
        clientMutationId: string;
        expectedGenerationId: string | null;
        version: number;
        position: number;
        activeGenerationId: string | null;
        deliveryAttempts: number;
        lastAttemptAt: Date | null;
        lastDeliveryReason: string | null;
        deliveredMessageId: string | null;
        steeredAt: Date | null;
        dequeuedAt: Date | null;
    } | null>;
    assertQueuedMessageClaimedForDelivery: (input: {
        conversationId: string;
        itemId: string;
        body: string;
    }) => Promise<{
        payload: ChatQueuedMessagePayload;
        conversationId: string;
        id: string;
        orgId: string;
        status: string;
        createdAt: Date;
        updatedAt: Date;
        cancelledAt: Date | null;
        sourceMessageId: string | null;
        clientMutationId: string;
        expectedGenerationId: string | null;
        version: number;
        position: number;
        activeGenerationId: string | null;
        deliveryAttempts: number;
        lastAttemptAt: Date | null;
        lastDeliveryReason: string | null;
        deliveredMessageId: string | null;
        steeredAt: Date | null;
        dequeuedAt: Date | null;
    }>;
    markQueuedMessageRunning: (input: {
        conversationId: string;
        itemId: string;
        sourceMessageId: string;
    }) => Promise<{
        payload: ChatQueuedMessagePayload;
        conversationId: string;
        id: string;
        orgId: string;
        status: string;
        createdAt: Date;
        updatedAt: Date;
        cancelledAt: Date | null;
        sourceMessageId: string | null;
        clientMutationId: string;
        expectedGenerationId: string | null;
        version: number;
        position: number;
        activeGenerationId: string | null;
        deliveryAttempts: number;
        lastAttemptAt: Date | null;
        lastDeliveryReason: string | null;
        deliveredMessageId: string | null;
        steeredAt: Date | null;
        dequeuedAt: Date | null;
    }>;
    markQueuedMessageDeliveryTerminal: (input: {
        conversationId: string;
        itemId: string;
        status: "completed" | "failed" | "stopped" | "aborted";
    }) => Promise<{
        payload: ChatQueuedMessagePayload;
        conversationId: string;
        id: string;
        orgId: string;
        status: string;
        createdAt: Date;
        updatedAt: Date;
        cancelledAt: Date | null;
        sourceMessageId: string | null;
        clientMutationId: string;
        expectedGenerationId: string | null;
        version: number;
        position: number;
        activeGenerationId: string | null;
        deliveryAttempts: number;
        lastAttemptAt: Date | null;
        lastDeliveryReason: string | null;
        deliveredMessageId: string | null;
        steeredAt: Date | null;
        dequeuedAt: Date | null;
    } | null>;
    listMessages: (conversationId: string, options?: {
        includeTranscript?: boolean;
    }) => Promise<{
        structuredPayload: Record<string, unknown> | null;
        transcript: ChatStreamTranscriptEntry[] | undefined;
        transcriptSummary: import("@rudderhq/shared").ChatTranscriptSummary | null;
        approval: {
            id: string;
            orgId: string;
            status: string;
            createdAt: Date;
            updatedAt: Date;
            type: string;
            decisionNote: string | null;
            payload: Record<string, unknown>;
            requestedByAgentId: string | null;
            decidedByUserId: string | null;
            requestedByUserId: string | null;
            decidedAt: Date | null;
        } | null;
        attachments: any[];
        conversationId: string;
        id: string;
        orgId: string;
        kind: string;
        status: string;
        createdAt: Date;
        updatedAt: Date;
        runId: string | null;
        body: string;
        role: string;
        approvalId: string | null;
        replyingAgentId: string | null;
        chatTurnId: string | null;
        turnVariant: number;
        supersededAt: Date | null;
    }[]>;
    getMessageTranscript: (conversationId: string, messageId: string) => Promise<{
        messageId: string;
        transcript: ChatStreamTranscriptEntry[];
    } | null>;
    addMessage: (conversationId: string, input: {
        orgId: string;
        role: "user" | "assistant" | "system";
        kind: "message" | "ask_user" | "issue_proposal" | "operation_proposal" | "system_event";
        status?: "streaming" | "completed" | "stopped" | "failed" | "interrupted";
        body: string;
        structuredPayload?: Record<string, unknown> | null;
        transcript?: ChatStreamTranscriptEntry[];
        approvalId?: string | null;
        runId?: string | null;
        replyingAgentId?: string | null;
        chatTurnId?: string | null;
        turnVariant?: number;
    }) => Promise<{
        structuredPayload: Record<string, unknown> | null;
        transcript: ChatStreamTranscriptEntry[] | undefined;
        transcriptSummary: import("@rudderhq/shared").ChatTranscriptSummary | null;
        approval: {
            id: string;
            orgId: string;
            status: string;
            createdAt: Date;
            updatedAt: Date;
            type: string;
            decisionNote: string | null;
            payload: Record<string, unknown>;
            requestedByAgentId: string | null;
            decidedByUserId: string | null;
            requestedByUserId: string | null;
            decidedAt: Date | null;
        } | null;
        attachments: any[];
        conversationId: string;
        id: string;
        orgId: string;
        kind: string;
        status: string;
        createdAt: Date;
        updatedAt: Date;
        runId: string | null;
        body: string;
        role: string;
        approvalId: string | null;
        replyingAgentId: string | null;
        chatTurnId: string | null;
        turnVariant: number;
        supersededAt: Date | null;
    }>;
    updateMessage: (conversationId: string, messageId: string, input: {
        kind?: "message" | "ask_user" | "issue_proposal" | "operation_proposal" | "system_event";
        status?: "streaming" | "completed" | "stopped" | "failed" | "interrupted";
        body?: string;
        structuredPayload?: Record<string, unknown> | null;
        transcript?: ChatStreamTranscriptEntry[];
        approvalId?: string | null;
        runId?: string | null;
        replyingAgentId?: string | null;
    }) => Promise<{
        structuredPayload: Record<string, unknown> | null;
        transcript: ChatStreamTranscriptEntry[] | undefined;
        transcriptSummary: import("@rudderhq/shared").ChatTranscriptSummary | null;
        approval: {
            id: string;
            orgId: string;
            status: string;
            createdAt: Date;
            updatedAt: Date;
            type: string;
            decisionNote: string | null;
            payload: Record<string, unknown>;
            requestedByAgentId: string | null;
            decidedByUserId: string | null;
            requestedByUserId: string | null;
            decidedAt: Date | null;
        } | null;
        attachments: any[];
        conversationId: string;
        id: string;
        orgId: string;
        kind: string;
        status: string;
        createdAt: Date;
        updatedAt: Date;
        runId: string | null;
        body: string;
        role: string;
        approvalId: string | null;
        replyingAgentId: string | null;
        chatTurnId: string | null;
        turnVariant: number;
        supersededAt: Date | null;
    } | null>;
    markInterruptedStreamingMessages: (conversationId: string) => Promise<{
        structuredPayload: Record<string, unknown> | null;
        transcript: ChatStreamTranscriptEntry[] | undefined;
        transcriptSummary: import("@rudderhq/shared").ChatTranscriptSummary | null;
        approval: {
            id: string;
            orgId: string;
            status: string;
            createdAt: Date;
            updatedAt: Date;
            type: string;
            decisionNote: string | null;
            payload: Record<string, unknown>;
            requestedByAgentId: string | null;
            decidedByUserId: string | null;
            requestedByUserId: string | null;
            decidedAt: Date | null;
        } | null;
        attachments: any[];
        conversationId: string;
        id: string;
        orgId: string;
        kind: string;
        status: string;
        createdAt: Date;
        updatedAt: Date;
        runId: string | null;
        body: string;
        role: string;
        approvalId: string | null;
        replyingAgentId: string | null;
        chatTurnId: string | null;
        turnVariant: number;
        supersededAt: Date | null;
    }[]>;
    addUserChatMessage: (conversationId: string, orgId: string, body: string, editUserMessageId?: string | null, options?: {
        structuredPayload?: Record<string, unknown> | null;
    }) => Promise<{
        structuredPayload: Record<string, unknown> | null;
        transcript: ChatStreamTranscriptEntry[] | undefined;
        transcriptSummary: import("@rudderhq/shared").ChatTranscriptSummary | null;
        approval: {
            id: string;
            orgId: string;
            status: string;
            createdAt: Date;
            updatedAt: Date;
            type: string;
            decisionNote: string | null;
            payload: Record<string, unknown>;
            requestedByAgentId: string | null;
            decidedByUserId: string | null;
            requestedByUserId: string | null;
            decidedAt: Date | null;
        } | null;
        attachments: any[];
        conversationId: string;
        id: string;
        orgId: string;
        kind: string;
        status: string;
        createdAt: Date;
        updatedAt: Date;
        runId: string | null;
        body: string;
        role: string;
        approvalId: string | null;
        replyingAgentId: string | null;
        chatTurnId: string | null;
        turnVariant: number;
        supersededAt: Date | null;
    }>;
    addContextLink: (conversationId: string, orgId: string, input: {
        entityType: "issue" | "project" | "agent";
        entityId: string;
        metadata?: Record<string, unknown> | null;
    }) => Promise<{
        entity: {
            type: "issue" | "project" | "agent";
            id: string;
            label: string;
            subtitle: string | null;
            identifier: string | null;
            status: string | null;
            description?: string | null;
            priority?: string | null;
            href: string;
        } | null;
        conversationId: string;
        id: string;
        orgId: string;
        createdAt: Date;
        updatedAt: Date;
        entityType: string;
        entityId: string;
        metadata: Record<string, unknown> | null;
    } | null>;
    setProjectContextLink: (conversationId: string, orgId: string, projectId: string | null) => Promise<{
        primaryIssue: {
            id: string;
            identifier: string | null;
            title: string;
            status: string;
            priority: string;
        } | null;
        latestReplyPreview: string | null;
        latestUserMessagePreview: string | null;
        userMessageCount: number;
        contextLinks: {
            entity: {
                type: "issue" | "project" | "agent";
                id: string;
                label: string;
                subtitle: string | null;
                identifier: string | null;
                status: string | null;
                description?: string | null;
                priority?: string | null;
                href: string;
            } | null;
            conversationId: string;
            id: string;
            orgId: string;
            createdAt: Date;
            updatedAt: Date;
            entityType: string;
            entityId: string;
            metadata: Record<string, unknown> | null;
        }[];
        sourceMetadata: ConversationSourceMetadata | null;
        mutability: "native_chat" | "external_bound_chat" | "native_fork_from_external";
        lastReadAt: Date | null;
        isPinned: boolean;
        unreadCount: number;
        isUnread: boolean;
        needsAttention: boolean;
        id: string;
        orgId: string;
        status: string;
        createdAt: Date;
        updatedAt: Date;
        createdByUserId: string | null;
        title: string;
        summary: string | null;
        preferredAgentId: string | null;
        issueCreationMode: string;
        planMode: boolean;
        routedAgentId: string | null;
        primaryIssueId: string | null;
        resolvedAt: Date | null;
        forkedFromConversationId: string | null;
        forkedFromMessageId: string | null;
        forkRootConversationId: string | null;
        lastMessageAt: Date | null;
    } | null>;
    createAttachment: (input: {
        orgId: string;
        conversationId: string;
        messageId: string;
        provider: string;
        objectKey: string;
        contentType: string;
        byteSize: number;
        sha256: string;
        originalFilename: string | null;
        createdByAgentId: string | null;
        createdByUserId: string | null;
    }) => Promise<{
        provider: string;
        objectKey: string;
        contentType: string;
        byteSize: number;
        sha256: string;
        originalFilename: string | null;
        createdByAgentId: string | null;
        createdByUserId: string | null;
        contentPath: string;
        conversationId: string;
        messageId: string;
        id: string;
        orgId: string;
        createdAt: Date;
        updatedAt: Date;
        assetId: string;
    }>;
    convertToIssue: (conversationId: string, input: {
        actorUserId: string | null;
        createdByAgentId?: string | null;
        messageId?: string | null;
        proposal?: Record<string, unknown> | null;
    }) => Promise<import("./issues.helpers.js").IssueWithLabels>;
    getMessage: (conversationId: string, messageId: string) => Promise<{
        structuredPayload: Record<string, unknown> | null;
        transcript: ChatStreamTranscriptEntry[] | undefined;
        transcriptSummary: import("@rudderhq/shared").ChatTranscriptSummary | null;
        approval: {
            id: string;
            orgId: string;
            status: string;
            createdAt: Date;
            updatedAt: Date;
            type: string;
            decisionNote: string | null;
            payload: Record<string, unknown>;
            requestedByAgentId: string | null;
            decidedByUserId: string | null;
            requestedByUserId: string | null;
            decidedAt: Date | null;
        } | null;
        attachments: any[];
        conversationId: string;
        id: string;
        orgId: string;
        kind: string;
        status: string;
        createdAt: Date;
        updatedAt: Date;
        runId: string | null;
        body: string;
        role: string;
        approvalId: string | null;
        replyingAgentId: string | null;
        chatTurnId: string | null;
        turnVariant: number;
        supersededAt: Date | null;
    } | null>;
    applyApprovedApproval: (approval: ApprovalRow, actorUserId: string | null) => Promise<Omit<{
        permissions: import("./agent-permissions.js").NormalizedAgentPermissions;
        id: string;
        orgId: string;
        status: string;
        createdAt: Date;
        updatedAt: Date;
        name: string;
        title: string | null;
        agentRuntimeType: string;
        metadata: Record<string, unknown> | null;
        icon: string | null;
        agentRuntimeConfig: Record<string, unknown>;
        role: string;
        capabilities: string | null;
        runtimeConfig: Record<string, unknown>;
        budgetMonthlyCents: number;
        spentMonthlyCents: number;
        reportsTo: string | null;
        pauseReason: string | null;
        pausedAt: Date | null;
        workspaceKey: string | null;
        lastHeartbeatAt: Date | null;
    } & {
        shortRef: string;
        urlKey: string;
    }, "workspaceKey"> | import("./issues.helpers.js").IssueWithLabels | ({
        logoAssetId: string | null;
        id: string;
        urlKey: string;
        name: string;
        description: string | null;
        status: string;
        pauseReason: string | null;
        pausedAt: Date | null;
        issuePrefix: string;
        issueCounter: number;
        budgetMonthlyCents: number;
        spentMonthlyCents: number;
        requireBoardApprovalForNewAgents: boolean;
        defaultChatIssueCreationMode: string;
        workspaceConfig: Record<string, unknown> | null;
        brandColor: string | null;
        createdAt: Date;
        updatedAt: Date;
    } & {
        spentMonthlyCents: number;
    } & {
        workspace: null;
        logoUrl: string | null;
    }) | null>;
    createProposalApproval: (orgId: string, input: {
        type: "chat_issue_creation" | "chat_operation";
        requestedByUserId: string | null;
        payload: Record<string, unknown>;
    }) => Promise<{
        id: string;
        orgId: string;
        status: string;
        createdAt: Date;
        updatedAt: Date;
        type: string;
        decisionNote: string | null;
        payload: Record<string, unknown>;
        requestedByAgentId: string | null;
        decidedByUserId: string | null;
        requestedByUserId: string | null;
        decidedAt: Date | null;
    }>;
    resolveOperationProposal: (conversationId: string, messageId: string, input: {
        action: "approve" | "reject" | "requestRevision";
        actorUserId: string | null;
        decisionNote?: string | null;
    }) => Promise<{
        message: {
            structuredPayload: Record<string, unknown> | null;
            transcript: ChatStreamTranscriptEntry[] | undefined;
            transcriptSummary: import("@rudderhq/shared").ChatTranscriptSummary | null;
            approval: {
                id: string;
                orgId: string;
                status: string;
                createdAt: Date;
                updatedAt: Date;
                type: string;
                decisionNote: string | null;
                payload: Record<string, unknown>;
                requestedByAgentId: string | null;
                decidedByUserId: string | null;
                requestedByUserId: string | null;
                decidedAt: Date | null;
            } | null;
            attachments: any[];
            conversationId: string;
            id: string;
            orgId: string;
            kind: string;
            status: string;
            createdAt: Date;
            updatedAt: Date;
            runId: string | null;
            body: string;
            role: string;
            approvalId: string | null;
            replyingAgentId: string | null;
            chatTurnId: string | null;
            turnVariant: number;
            supersededAt: Date | null;
        };
        systemMessage: {
            structuredPayload: Record<string, unknown> | null;
            transcript: ChatStreamTranscriptEntry[] | undefined;
            transcriptSummary: import("@rudderhq/shared").ChatTranscriptSummary | null;
            approval: {
                id: string;
                orgId: string;
                status: string;
                createdAt: Date;
                updatedAt: Date;
                type: string;
                decisionNote: string | null;
                payload: Record<string, unknown>;
                requestedByAgentId: string | null;
                decidedByUserId: string | null;
                requestedByUserId: string | null;
                decidedAt: Date | null;
            } | null;
            attachments: any[];
            conversationId: string;
            id: string;
            orgId: string;
            kind: string;
            status: string;
            createdAt: Date;
            updatedAt: Date;
            runId: string | null;
            body: string;
            role: string;
            approvalId: string | null;
            replyingAgentId: string | null;
            chatTurnId: string | null;
            turnVariant: number;
            supersededAt: Date | null;
        };
    }>;
};
export {};
//# sourceMappingURL=chats.d.ts.map