import type { RudderSkillEntry } from "@rudderhq/agent-runtime-utils/server-utils";
import type { Db } from "@rudderhq/db";
import { type ProjectResourceAttachment } from "@rudderhq/shared";
export type AgentRunScene = "issue" | "chat" | "automation" | "review" | "heartbeat";
export type AgentRunContextAgent = {
    id: string;
    orgId: string;
    name: string;
    role?: string | null;
    workspaceKey?: string | null;
    status?: string | null;
    agentRuntimeType: string;
    agentRuntimeConfig: unknown;
    metadata?: Record<string, unknown> | null;
};
export type ResolvedWorkspaceForRun = {
    cwd: string;
    source: "project_primary" | "task_session" | "agent_home";
    projectId: string | null;
    workspaceId: string | null;
    repoUrl: string | null;
    repoRef: string | null;
    workspaceHints: Array<{
        workspaceId: string;
        cwd: string | null;
        repoUrl: string | null;
        repoRef: string | null;
    }>;
    warnings: string[];
};
type ProjectWorkspaceCandidate = {
    id: string;
};
type BuildSceneContextInput = {
    scene: AgentRunScene;
    agent: AgentRunContextAgent;
    resolvedWorkspace: ResolvedWorkspaceForRun;
    runtimeConfig: Record<string, unknown>;
    issueId?: string | null;
    chatConversationId?: string | null;
    executionWorkspace?: {
        cwd: string;
        source: string | null;
        strategy: string | null;
        projectId: string | null;
        workspaceId: string | null;
        repoUrl: string | null;
        repoRef: string | null;
        branchName: string | null;
        worktreePath: string | null;
    } | null;
    executionWorkspaceMode?: string | null;
};
type PreparedAgentRunConfig = {
    resolvedConfig: Record<string, unknown>;
    runtimeConfig: Record<string, unknown>;
    runtimeSkillEntries: RudderSkillEntry[];
    secretKeys: Set<string>;
};
export declare function prioritizeProjectWorkspaceCandidatesForRun<T extends ProjectWorkspaceCandidate>(rows: T[], preferredWorkspaceId: string | null | undefined): T[];
export declare function isHiddenSystemAgentMetadata(metadata: unknown): boolean;
export declare function agentRunContextService(db: Db): {
    buildSceneContext: (input: BuildSceneContextInput) => Promise<{
        rudderScene: AgentRunScene;
        rudderWorkspace: {
            cwd: string;
            source: string;
            mode: string;
            strategy: string | null;
            projectId: string | null;
            workspaceId: string | null;
            repoUrl: string | null;
            repoRef: string | null;
            branchName: string | null;
            worktreePath: string | null;
            executionWorkspaceCwd: string;
            executionWorkspaceSource: string;
            agentHome: string;
            agentRoot: string;
            instructionsDir: string;
            memoryDir: string;
            lifeDir: string;
            agentSkillsDir: string;
            orgWorkspaceRoot: string;
            orgAgentsDir: string;
            orgSkillsDir: string;
            projectLibraryRoot: string | null;
            projectLibraryRelativePath: string | null;
            resourcesPrompt: string;
            orgResourcesPrompt: string;
        };
        rudderResourcesPrompt: string;
        rudderResources: ProjectResourceAttachment[];
        rudderOrganizationResources: never[];
        rudderProjectResources: ProjectResourceAttachment[];
        rudderOrgNotes: string;
        rudderWorkspaces: {
            workspaceId: string;
            cwd: string | null;
            repoUrl: string | null;
            repoRef: string | null;
        }[];
        rudderRuntimeServiceIntents: Record<string, unknown>[] | undefined;
        rudderStartupContext: import("./agent-startup-context.js").AgentStartupContextBundle;
        rudderStartupContextMetrics: {
            version: typeof import("./agent-startup-context.js").AGENT_STARTUP_CONTEXT_VERSION;
            totalChars: number;
            limitChars: number;
            recentIssuesCount: number;
            recentChatsCount: number;
            omittedIssues: number;
            omittedChats: number;
        };
    }>;
    isHiddenSystemAgentMetadata: typeof isHiddenSystemAgentMetadata;
    materializeManagedInstructionsForRun: (agent: AgentRunContextAgent) => Promise<Record<string, unknown>>;
    prepareRuntimeConfig: (input: {
        scene: AgentRunScene;
        agent: AgentRunContextAgent;
        baseConfig?: Record<string, unknown> | null;
    }) => Promise<PreparedAgentRunConfig>;
    resolveWorkspaceForRun: (agent: AgentRunContextAgent, context: Record<string, unknown>, previousSessionParams: Record<string, unknown> | null, opts?: {
        useProjectWorkspace?: boolean | null;
    }) => Promise<ResolvedWorkspaceForRun>;
};
export {};
//# sourceMappingURL=agent-run-context.d.ts.map