import type { Db } from "@rudderhq/db";
import type { AgentSkillAnalytics } from "@rudderhq/shared";
import { type BudgetEnforcementScope } from "../budgets.js";
export { prioritizeProjectWorkspaceCandidatesForRun, type ResolvedWorkspaceForRun } from "../agent-run-context.js";
export declare function heartbeatService(db: Db): {
    list: (orgId: string, agentId?: string, limit?: number, filters?: {
        startDate?: Date;
        endDate?: Date;
    }) => Promise<{
        resultJson: Record<string, unknown> | null;
        id: string;
        orgId: string;
        agentId: string;
        invocationSource: string;
        triggerDetail: string | null;
        status: string;
        startedAt: Date | null;
        finishedAt: Date | null;
        error: string | null;
        wakeupRequestId: string | null;
        exitCode: number | null;
        signal: string | null;
        usageJson: Record<string, unknown> | null;
        sessionIdBefore: string | null;
        sessionIdAfter: string | null;
        logStore: string | null;
        logRef: string | null;
        logBytes: number | null;
        logSha256: string | null;
        logCompressed: boolean;
        stdoutExcerpt: string | null;
        stderrExcerpt: string | null;
        errorCode: string | null;
        externalRunId: string | null;
        chatConversationId: string | null;
        processPid: number | null;
        processStartedAt: Date | null;
        retryOfRunId: string | null;
        processLossRetryCount: number;
        contextSnapshot: Record<string, unknown> | null;
        createdAt: Date;
        updatedAt: Date;
    }[]>;
    getAgentSkillAnalytics: (agentId: string, opts?: {
        windowDays?: number;
        now?: Date;
        startDate?: string;
        endDate?: string;
    }) => Promise<AgentSkillAnalytics>;
    getOrganizationSkillAnalytics: (orgId: string, opts?: {
        windowDays?: number;
        now?: Date;
        startDate?: string;
        endDate?: string;
    }) => Promise<AgentSkillAnalytics>;
    getRun: (runId: string) => Promise<{
        error: string | null;
        wakeupRequestId: string | null;
        id: string;
        orgId: string;
        status: string;
        createdAt: Date;
        updatedAt: Date;
        agentId: string;
        startedAt: Date | null;
        triggerDetail: string | null;
        chatConversationId: string | null;
        finishedAt: Date | null;
        invocationSource: string;
        exitCode: number | null;
        signal: string | null;
        usageJson: Record<string, unknown> | null;
        resultJson: Record<string, unknown> | null;
        sessionIdBefore: string | null;
        sessionIdAfter: string | null;
        logStore: string | null;
        logRef: string | null;
        logBytes: number | null;
        logSha256: string | null;
        logCompressed: boolean;
        stdoutExcerpt: string | null;
        stderrExcerpt: string | null;
        errorCode: string | null;
        externalRunId: string | null;
        processPid: number | null;
        processStartedAt: Date | null;
        retryOfRunId: string | null;
        processLossRetryCount: number;
        contextSnapshot: Record<string, unknown> | null;
    }>;
    getRuntimeState: (agentId: string) => Promise<{
        sessionDisplayId: string | null;
        sessionParamsJson: Record<string, unknown> | null;
        orgId: string;
        createdAt: Date;
        updatedAt: Date;
        agentId: string;
        agentRuntimeType: string;
        lastError: string | null;
        sessionId: string | null;
        stateJson: Record<string, unknown>;
        lastRunId: string | null;
        lastRunStatus: string | null;
        totalInputTokens: number;
        totalOutputTokens: number;
        totalCachedInputTokens: number;
        totalCostCents: number;
    } | null>;
    listTaskSessions: (agentId: string) => Promise<{
        id: string;
        orgId: string;
        createdAt: Date;
        updatedAt: Date;
        agentId: string;
        agentRuntimeType: string;
        taskKey: string;
        lastError: string | null;
        lastRunId: string | null;
        sessionParamsJson: Record<string, unknown> | null;
        sessionDisplayId: string | null;
    }[]>;
    resetRuntimeSession: (agentId: string, opts?: {
        taskKey?: string | null;
    }) => Promise<{
        sessionDisplayId: null;
        sessionParamsJson: null;
        clearedTaskSessions: number;
        agentId: string;
        orgId: string;
        agentRuntimeType: string;
        sessionId: string | null;
        stateJson: Record<string, unknown>;
        lastRunId: string | null;
        lastRunStatus: string | null;
        totalInputTokens: number;
        totalOutputTokens: number;
        totalCachedInputTokens: number;
        totalCostCents: number;
        lastError: string | null;
        createdAt: Date;
        updatedAt: Date;
    } | null>;
    listEvents: (runId: string, afterSeq?: number, limit?: number) => Omit<import("drizzle-orm/pg-core").PgSelectBase<"heartbeat_run_events", {
        id: import("drizzle-orm/pg-core").PgColumn<{
            name: "id";
            tableName: "heartbeat_run_events";
            dataType: "number";
            columnType: "PgBigSerial53";
            data: number;
            driverParam: number;
            notNull: true;
            hasDefault: true;
            isPrimaryKey: true;
            isAutoincrement: false;
            hasRuntimeDefault: false;
            enumValues: undefined;
            baseColumn: never;
            identity: undefined;
            generated: undefined;
        }, {}, {}>;
        orgId: import("drizzle-orm/pg-core").PgColumn<{
            name: "org_id";
            tableName: "heartbeat_run_events";
            dataType: "string";
            columnType: "PgUUID";
            data: string;
            driverParam: string;
            notNull: true;
            hasDefault: false;
            isPrimaryKey: false;
            isAutoincrement: false;
            hasRuntimeDefault: false;
            enumValues: undefined;
            baseColumn: never;
            identity: undefined;
            generated: undefined;
        }, {}, {}>;
        runId: import("drizzle-orm/pg-core").PgColumn<{
            name: "run_id";
            tableName: "heartbeat_run_events";
            dataType: "string";
            columnType: "PgUUID";
            data: string;
            driverParam: string;
            notNull: true;
            hasDefault: false;
            isPrimaryKey: false;
            isAutoincrement: false;
            hasRuntimeDefault: false;
            enumValues: undefined;
            baseColumn: never;
            identity: undefined;
            generated: undefined;
        }, {}, {}>;
        agentId: import("drizzle-orm/pg-core").PgColumn<{
            name: "agent_id";
            tableName: "heartbeat_run_events";
            dataType: "string";
            columnType: "PgUUID";
            data: string;
            driverParam: string;
            notNull: true;
            hasDefault: false;
            isPrimaryKey: false;
            isAutoincrement: false;
            hasRuntimeDefault: false;
            enumValues: undefined;
            baseColumn: never;
            identity: undefined;
            generated: undefined;
        }, {}, {}>;
        seq: import("drizzle-orm/pg-core").PgColumn<{
            name: "seq";
            tableName: "heartbeat_run_events";
            dataType: "number";
            columnType: "PgInteger";
            data: number;
            driverParam: string | number;
            notNull: true;
            hasDefault: false;
            isPrimaryKey: false;
            isAutoincrement: false;
            hasRuntimeDefault: false;
            enumValues: undefined;
            baseColumn: never;
            identity: undefined;
            generated: undefined;
        }, {}, {}>;
        eventType: import("drizzle-orm/pg-core").PgColumn<{
            name: "event_type";
            tableName: "heartbeat_run_events";
            dataType: "string";
            columnType: "PgText";
            data: string;
            driverParam: string;
            notNull: true;
            hasDefault: false;
            isPrimaryKey: false;
            isAutoincrement: false;
            hasRuntimeDefault: false;
            enumValues: [string, ...string[]];
            baseColumn: never;
            identity: undefined;
            generated: undefined;
        }, {}, {}>;
        stream: import("drizzle-orm/pg-core").PgColumn<{
            name: "stream";
            tableName: "heartbeat_run_events";
            dataType: "string";
            columnType: "PgText";
            data: string;
            driverParam: string;
            notNull: false;
            hasDefault: false;
            isPrimaryKey: false;
            isAutoincrement: false;
            hasRuntimeDefault: false;
            enumValues: [string, ...string[]];
            baseColumn: never;
            identity: undefined;
            generated: undefined;
        }, {}, {}>;
        level: import("drizzle-orm/pg-core").PgColumn<{
            name: "level";
            tableName: "heartbeat_run_events";
            dataType: "string";
            columnType: "PgText";
            data: string;
            driverParam: string;
            notNull: false;
            hasDefault: false;
            isPrimaryKey: false;
            isAutoincrement: false;
            hasRuntimeDefault: false;
            enumValues: [string, ...string[]];
            baseColumn: never;
            identity: undefined;
            generated: undefined;
        }, {}, {}>;
        color: import("drizzle-orm/pg-core").PgColumn<{
            name: "color";
            tableName: "heartbeat_run_events";
            dataType: "string";
            columnType: "PgText";
            data: string;
            driverParam: string;
            notNull: false;
            hasDefault: false;
            isPrimaryKey: false;
            isAutoincrement: false;
            hasRuntimeDefault: false;
            enumValues: [string, ...string[]];
            baseColumn: never;
            identity: undefined;
            generated: undefined;
        }, {}, {}>;
        message: import("drizzle-orm/pg-core").PgColumn<{
            name: "message";
            tableName: "heartbeat_run_events";
            dataType: "string";
            columnType: "PgText";
            data: string;
            driverParam: string;
            notNull: false;
            hasDefault: false;
            isPrimaryKey: false;
            isAutoincrement: false;
            hasRuntimeDefault: false;
            enumValues: [string, ...string[]];
            baseColumn: never;
            identity: undefined;
            generated: undefined;
        }, {}, {}>;
        payload: import("drizzle-orm/pg-core").PgColumn<{
            name: "payload";
            tableName: "heartbeat_run_events";
            dataType: "json";
            columnType: "PgJsonb";
            data: Record<string, unknown>;
            driverParam: unknown;
            notNull: false;
            hasDefault: false;
            isPrimaryKey: false;
            isAutoincrement: false;
            hasRuntimeDefault: false;
            enumValues: undefined;
            baseColumn: never;
            identity: undefined;
            generated: undefined;
        }, {}, {
            $type: Record<string, unknown>;
        }>;
        createdAt: import("drizzle-orm/pg-core").PgColumn<{
            name: "created_at";
            tableName: "heartbeat_run_events";
            dataType: "date";
            columnType: "PgTimestamp";
            data: Date;
            driverParam: string;
            notNull: true;
            hasDefault: true;
            isPrimaryKey: false;
            isAutoincrement: false;
            hasRuntimeDefault: false;
            enumValues: undefined;
            baseColumn: never;
            identity: undefined;
            generated: undefined;
        }, {}, {}>;
    }, "single", Record<"heartbeat_run_events", "not-null">, false, "where" | "orderBy" | "limit", {
        message: string | null;
        id: number;
        orgId: string;
        createdAt: Date;
        runId: string;
        agentId: string;
        payload: Record<string, unknown> | null;
        color: string | null;
        level: string | null;
        seq: number;
        eventType: string;
        stream: string | null;
    }[], {
        id: import("drizzle-orm/pg-core").PgColumn<{
            name: "id";
            tableName: "heartbeat_run_events";
            dataType: "number";
            columnType: "PgBigSerial53";
            data: number;
            driverParam: number;
            notNull: true;
            hasDefault: true;
            isPrimaryKey: true;
            isAutoincrement: false;
            hasRuntimeDefault: false;
            enumValues: undefined;
            baseColumn: never;
            identity: undefined;
            generated: undefined;
        }, {}, {}>;
        orgId: import("drizzle-orm/pg-core").PgColumn<{
            name: "org_id";
            tableName: "heartbeat_run_events";
            dataType: "string";
            columnType: "PgUUID";
            data: string;
            driverParam: string;
            notNull: true;
            hasDefault: false;
            isPrimaryKey: false;
            isAutoincrement: false;
            hasRuntimeDefault: false;
            enumValues: undefined;
            baseColumn: never;
            identity: undefined;
            generated: undefined;
        }, {}, {}>;
        runId: import("drizzle-orm/pg-core").PgColumn<{
            name: "run_id";
            tableName: "heartbeat_run_events";
            dataType: "string";
            columnType: "PgUUID";
            data: string;
            driverParam: string;
            notNull: true;
            hasDefault: false;
            isPrimaryKey: false;
            isAutoincrement: false;
            hasRuntimeDefault: false;
            enumValues: undefined;
            baseColumn: never;
            identity: undefined;
            generated: undefined;
        }, {}, {}>;
        agentId: import("drizzle-orm/pg-core").PgColumn<{
            name: "agent_id";
            tableName: "heartbeat_run_events";
            dataType: "string";
            columnType: "PgUUID";
            data: string;
            driverParam: string;
            notNull: true;
            hasDefault: false;
            isPrimaryKey: false;
            isAutoincrement: false;
            hasRuntimeDefault: false;
            enumValues: undefined;
            baseColumn: never;
            identity: undefined;
            generated: undefined;
        }, {}, {}>;
        seq: import("drizzle-orm/pg-core").PgColumn<{
            name: "seq";
            tableName: "heartbeat_run_events";
            dataType: "number";
            columnType: "PgInteger";
            data: number;
            driverParam: string | number;
            notNull: true;
            hasDefault: false;
            isPrimaryKey: false;
            isAutoincrement: false;
            hasRuntimeDefault: false;
            enumValues: undefined;
            baseColumn: never;
            identity: undefined;
            generated: undefined;
        }, {}, {}>;
        eventType: import("drizzle-orm/pg-core").PgColumn<{
            name: "event_type";
            tableName: "heartbeat_run_events";
            dataType: "string";
            columnType: "PgText";
            data: string;
            driverParam: string;
            notNull: true;
            hasDefault: false;
            isPrimaryKey: false;
            isAutoincrement: false;
            hasRuntimeDefault: false;
            enumValues: [string, ...string[]];
            baseColumn: never;
            identity: undefined;
            generated: undefined;
        }, {}, {}>;
        stream: import("drizzle-orm/pg-core").PgColumn<{
            name: "stream";
            tableName: "heartbeat_run_events";
            dataType: "string";
            columnType: "PgText";
            data: string;
            driverParam: string;
            notNull: false;
            hasDefault: false;
            isPrimaryKey: false;
            isAutoincrement: false;
            hasRuntimeDefault: false;
            enumValues: [string, ...string[]];
            baseColumn: never;
            identity: undefined;
            generated: undefined;
        }, {}, {}>;
        level: import("drizzle-orm/pg-core").PgColumn<{
            name: "level";
            tableName: "heartbeat_run_events";
            dataType: "string";
            columnType: "PgText";
            data: string;
            driverParam: string;
            notNull: false;
            hasDefault: false;
            isPrimaryKey: false;
            isAutoincrement: false;
            hasRuntimeDefault: false;
            enumValues: [string, ...string[]];
            baseColumn: never;
            identity: undefined;
            generated: undefined;
        }, {}, {}>;
        color: import("drizzle-orm/pg-core").PgColumn<{
            name: "color";
            tableName: "heartbeat_run_events";
            dataType: "string";
            columnType: "PgText";
            data: string;
            driverParam: string;
            notNull: false;
            hasDefault: false;
            isPrimaryKey: false;
            isAutoincrement: false;
            hasRuntimeDefault: false;
            enumValues: [string, ...string[]];
            baseColumn: never;
            identity: undefined;
            generated: undefined;
        }, {}, {}>;
        message: import("drizzle-orm/pg-core").PgColumn<{
            name: "message";
            tableName: "heartbeat_run_events";
            dataType: "string";
            columnType: "PgText";
            data: string;
            driverParam: string;
            notNull: false;
            hasDefault: false;
            isPrimaryKey: false;
            isAutoincrement: false;
            hasRuntimeDefault: false;
            enumValues: [string, ...string[]];
            baseColumn: never;
            identity: undefined;
            generated: undefined;
        }, {}, {}>;
        payload: import("drizzle-orm/pg-core").PgColumn<{
            name: "payload";
            tableName: "heartbeat_run_events";
            dataType: "json";
            columnType: "PgJsonb";
            data: Record<string, unknown>;
            driverParam: unknown;
            notNull: false;
            hasDefault: false;
            isPrimaryKey: false;
            isAutoincrement: false;
            hasRuntimeDefault: false;
            enumValues: undefined;
            baseColumn: never;
            identity: undefined;
            generated: undefined;
        }, {}, {
            $type: Record<string, unknown>;
        }>;
        createdAt: import("drizzle-orm/pg-core").PgColumn<{
            name: "created_at";
            tableName: "heartbeat_run_events";
            dataType: "date";
            columnType: "PgTimestamp";
            data: Date;
            driverParam: string;
            notNull: true;
            hasDefault: true;
            isPrimaryKey: false;
            isAutoincrement: false;
            hasRuntimeDefault: false;
            enumValues: undefined;
            baseColumn: never;
            identity: undefined;
            generated: undefined;
        }, {}, {}>;
    }>, "where" | "orderBy" | "limit">;
    readLog: (runId: string, opts?: {
        offset?: number;
        limitBytes?: number;
    }) => Promise<{
        content: string;
        endOffset: number;
        eof: boolean;
        nextOffset?: number;
        runId: string;
        store: string;
        logRef: string;
    }>;
    invoke: (agentId: string, source?: "timer" | "assignment" | "review" | "on_demand" | "automation", contextSnapshot?: Record<string, unknown>, triggerDetail?: "manual" | "ping" | "callback" | "system", actor?: {
        actorType?: "user" | "agent" | "system";
        actorId?: string | null;
    }) => Promise<any>;
    wakeup: (agentId: string, opts?: WakeupOptions) => any;
    resumeDeferredWakeupsForAgent: (agentId: string) => Promise<{
        replayed: number;
        wakeupRequestIds: string[];
    }>;
    retryRun: (runId: string, opts?: {
        requestedByActorType?: WakeupOptions["requestedByActorType"];
        requestedByActorId?: string | null;
        now?: Date;
    }) => Promise<any>;
    reportRunActivity: (runId: string) => Promise<{
        id: string;
        orgId: string;
        agentId: string;
        invocationSource: string;
        triggerDetail: string | null;
        status: string;
        startedAt: Date | null;
        finishedAt: Date | null;
        error: string | null;
        wakeupRequestId: string | null;
        exitCode: number | null;
        signal: string | null;
        usageJson: Record<string, unknown> | null;
        resultJson: Record<string, unknown> | null;
        sessionIdBefore: string | null;
        sessionIdAfter: string | null;
        logStore: string | null;
        logRef: string | null;
        logBytes: number | null;
        logSha256: string | null;
        logCompressed: boolean;
        stdoutExcerpt: string | null;
        stderrExcerpt: string | null;
        errorCode: string | null;
        externalRunId: string | null;
        chatConversationId: string | null;
        processPid: number | null;
        processStartedAt: Date | null;
        retryOfRunId: string | null;
        processLossRetryCount: number;
        contextSnapshot: Record<string, unknown> | null;
        createdAt: Date;
        updatedAt: Date;
    } | null>;
    reapOrphanedRuns: (opts?: {
        staleThresholdMs?: number;
    }) => Promise<{
        reaped: number;
        runIds: string[];
    }>;
    reapInactiveRuns: (opts?: {
        maxInactivityMs?: number;
        now?: Date;
    }) => Promise<{
        timedOut: number;
        runIds: string[];
    }>;
    reapTimedOutRuns: (opts?: {
        maxRuntimeMs?: number;
        now?: Date;
    }) => Promise<{
        timedOut: number;
        runIds: string[];
    }>;
    resumeQueuedRuns: () => Promise<void>;
    tickTimers: (now?: Date) => Promise<{
        checked: number;
        enqueued: number;
        skipped: number;
    }>;
    cancelRun: (runId: string) => Promise<any>;
    cancelActiveForAgent: (agentId: string) => Promise<any>;
    cancelBudgetScopeWork: (scope: BudgetEnforcementScope) => Promise<void>;
    getActiveRunForAgent: (agentId: string) => Promise<{
        error: string | null;
        wakeupRequestId: string | null;
        id: string;
        orgId: string;
        status: string;
        createdAt: Date;
        updatedAt: Date;
        agentId: string;
        startedAt: Date | null;
        triggerDetail: string | null;
        chatConversationId: string | null;
        finishedAt: Date | null;
        invocationSource: string;
        exitCode: number | null;
        signal: string | null;
        usageJson: Record<string, unknown> | null;
        resultJson: Record<string, unknown> | null;
        sessionIdBefore: string | null;
        sessionIdAfter: string | null;
        logStore: string | null;
        logRef: string | null;
        logBytes: number | null;
        logSha256: string | null;
        logCompressed: boolean;
        stdoutExcerpt: string | null;
        stderrExcerpt: string | null;
        errorCode: string | null;
        externalRunId: string | null;
        processPid: number | null;
        processStartedAt: Date | null;
        retryOfRunId: string | null;
        processLossRetryCount: number;
        contextSnapshot: Record<string, unknown> | null;
    }>;
};
//# sourceMappingURL=heartbeat.d.ts.map