import type { Database } from "./database.js"; import * as schema from "./schema.js"; type Turn = typeof schema.sessionTurns.$inferSelect; type Update = typeof schema.sessionSystemUpdates.$inferSelect; export declare function inboxOrigin(update: Pick, sessionId: string): { turnId: string; sessionId: string; } | null; export declare function turnHuman(turn: Pick): string | null; export declare function informationalAgentUpdate(update: Pick): boolean; /** Accepted rows are the only authority source. No creator/default-account fallback. */ export declare function loadInboxExecutionContext(tx: Database, input: { accountId: string; workspaceId: string; sessionId: string; contextTurnId: string | null; updates: readonly Update[]; }): Promise<{ context: { id: string; accountId: string; workspaceId: string; sessionId: string; triggerEventId: string; temporalWorkflowId: string; status: string; source: string; surface: string | null; billingOrigin: string | null; promptRouting: string | null; position: number; prompt: string; promptCodecVersion: number | null; annotations: { id: string; source: { kind: "assistant_message" | "tool_output" | "user_message"; eventId: string; eventType: "agent.message.completed" | "agent.toolCall.output" | "user.message"; sequence: number; turnId: string | null; startOffset: number; endOffset: number; contextBefore: string; contextAfter: string; label?: string | undefined; }; quote: string; note: string; ordinal: number; }[]; modelContext: string | null; resources: unknown[]; tools: unknown[]; toolsProvided: boolean; model: string; reasoningEffort: string; latencyMode: string; sandboxBackend: string; sandboxOs: string | null; metadata: Record; version: number; executionGeneration: number; activeAttemptId: string | null; lineage: Record; initiatorKind: string; initiatorSubjectId: string; initiatorContext: Record; initiatingHumanSubjectId: string | null; executionContextTurnId: string | null; goalSnapshot: { state: "none"; capturedAt: string; } | { state: "active" | "completed" | "paused"; goalId: string; objectiveRevision: number; text: string; successCriteria: string | null; rootConstraints: string[]; reportRequirements?: { id: string; title: string; }[] | undefined; mutationPolicy: "autonomous_adaptation" | "preserve_intent" | "review_changes"; capturedAt: string; } | null; personalConnectionDelegations: { serverId: string; canonicalServerId?: string | undefined; connectionId: string; originWorkspaceId?: string | undefined; ownerSubjectId: string; providerDomain: string; kind?: "api_key" | "app_install" | "delegated" | "oauth2" | undefined; connectionType?: "atlassian" | "github_personal" | "mcp" | "social" | undefined; userDelegation?: { authorityId: string; grantId: string; organizationId: string; workspaceId: string; sessionId: string | null; action: string; mode: "always" | "once" | "session"; context: "user_private" | "workspace_shared"; authorityEpoch: number | null; authorityGeneration: number; grantGeneration: number; resourceVersionId?: string | null | undefined; } | undefined; personalGitHubRepositorySelection?: { credentialBindingId: string; connectionAuthorityGeneration: number; selectionGeneration: number; allRepositoriesAccess?: "read" | "write" | undefined; repositories: { repositoryId: string; fullName: string; canonicalUrl: string; ref: string; access: "read" | "write"; selectionGeneration: number; }[]; } | undefined; outputDestination?: { folderId: string; folderName: string; driveId: string | null; location: "my_drive" | "shared_drive"; selectedAt: string; } | undefined; }[]; mcpAccountBindings: { serverId: string; canonicalServerId: string; connectionId: string; originWorkspaceId: string; subjectScope: "subject" | "workspace"; ownerSubjectId: string | null; accountLabel: string; providerDomain: string; kind: "api_key" | "app_install" | "delegated" | "oauth2"; connectionRef: { connectionId?: string | undefined; accountSelection?: "all_eligible" | undefined; authoritySource?: "host" | undefined; hostBinding?: { bindingId: string; generation: number; } | { selection: "accepted_turn"; } | undefined; provider?: string | undefined; providerDomain: string; kind?: "api_key" | "app_install" | "delegated" | "oauth2" | undefined; scopes?: string[] | undefined; resource?: string | undefined; selectedResources?: { id: string; kind: "repository"; }[] | undefined; subjectScope?: "subject" | "workspace" | undefined; }; connectionAuthorityGeneration?: number | undefined; }[] | null; connectionAccountIntent: { version: 1; principal: { kind: "subject"; subjectId: string; } | { kind: "none"; }; selections: { serverId: string; connectionId: string; }[]; } | null; personalResourceAttachmentSummary: { mode: "always" | "once" | "session"; context: "user_private" | "workspace_shared"; resourceCount: number; resourceKinds: ("connected_machine" | "rig" | "variable_set")[]; sharedOutputWarningVersion: 1; } | null; personalResourceProtocolVersion: number; scheduledTaskRunId: string | null; xaiProviderAccountAuthoritySnapshot: { version: 1; scope: "organization"; } | { version: 1; scope: "workspace"; } | { version: 1; scope: "user"; authorityGeneration: number; }; claudeProviderAccountAuthoritySnapshot: { version: 1; scope: "organization"; } | { version: 1; scope: "workspace"; } | { version: 1; scope: "user"; authorityGeneration: number; }; subscriptionAuthority: { version: 2; personal: { provider: "claude" | "codex" | "xai"; ownerMembershipId: string; authorityGeneration: number; sharedSessionChoice?: { sessionId: string; connectionId: string; } | undefined; }[]; } | null; cancelledBy: string | null; cancelReason: string | null; codemodeCallCount: number; startedAt: Date | null; finishedAt: Date | null; createdAt: Date; updatedAt: Date; externalLink: unknown; sessionMetadata: Record; sessionTools: unknown[]; sessionToolPolicy: { mode: "explicit" | "inherited" | "workspace_default"; inheritedFromSessionId: string | null; excludedMcpServerIds?: string[] | undefined; firstPartyMode?: "explicit" | "workspace_default" | undefined; firstPartyAdditions?: ("admin_action_call" | "admin_action_describe" | "admin_actions_search" | "app_data_define_collection" | "app_data_describe" | "app_data_export" | "app_data_import" | "app_data_query" | "app_data_reset" | "app_data_write" | "app_export" | "app_files_delete" | "app_files_list" | "app_files_upload" | "app_hostname_check" | "app_install" | "app_publication_apply_fix" | "app_publication_get" | "app_publication_update" | "app_server_run" | "app_server_runs" | "app_sql_define_query" | "app_sql_enable" | "app_sql_execute" | "app_sql_export" | "app_sql_import" | "app_sql_inspect" | "app_sql_migrate" | "app_sql_query" | "app_sql_reset" | "app_sql_run" | "app_sync_delete" | "app_sync_list" | "app_sync_opt_in" | "app_sync_run" | "app_sync_save" | "app_upgrade" | "app_webhook_delete" | "app_webhook_list" | "app_webhook_save" | "artifacts_archive" | "artifacts_create" | "artifacts_get_source" | "artifacts_list" | "artifacts_prepare_upload" | "artifacts_publish" | "artifacts_restore" | "artifacts_rollback" | "atlassian_get" | "atlassian_search" | "atlassian_sources_list" | "bot_template_save" | "browser_act" | "browser_auth" | "browser_clipboard" | "browser_debug" | "browser_download_save" | "browser_downloads" | "browser_identity" | "browser_lifecycle" | "browser_observe" | "browser_open" | "browser_publish" | "browser_read" | "browser_record" | "browser_screenshot" | "browser_tabs" | "call_user" | "capability_authorization_request" | "capability_catalog_search" | "command_read" | "command_wait" | "company_profile_confirm" | "company_profile_propose" | "computer_act" | "computer_clipboard" | "computer_lifecycle" | "computer_observe" | "computer_open" | "computer_targets" | "connected_machine_enable_screen_control" | "connected_machine_enroll_token" | "connected_machine_remove" | "custom_mcp_setup_request" | "editable_artifact_apply" | "editable_artifact_create" | "editable_artifact_export" | "editable_artifact_export_status" | "editable_artifact_get" | "editable_artifact_import" | "editable_artifact_inspect" | "editable_artifact_list" | "environment_list" | "environment_set_variable" | "event_sources_create_webhook" | "event_sources_delete" | "event_sources_list" | "event_sources_update" | "events_get" | "excel_run" | "fiken_bank_accounts_list" | "fiken_companies_list" | "fiken_contact_create" | "fiken_contacts_list" | "fiken_invoice_draft_create" | "fiken_invoice_get" | "fiken_invoices_list" | "fiken_products_list" | "fiken_purchases_list" | "fiken_sales_list" | "github_connect_link" | "github_repositories_list" | "github_repository_attach" | "goal_complete" | "goal_pause" | "goal_progress" | "goal_resume" | "goal_set" | "goal_update" | "inbox_tidy" | "instruction_policy_get" | "instruction_policy_propose" | "instruction_policy_save" | "interaction_discover" | "interaction_request_human" | "knowledge_archive" | "knowledge_browse" | "knowledge_correct" | "knowledge_get" | "knowledge_prepare_save" | "knowledge_propose" | "knowledge_retain_file" | "knowledge_retain_message" | "knowledge_save" | "knowledge_search" | "meeting_notes_save" | "meeting_read" | "meetings_search" | "memory_correct" | "memory_save" | "memory_search" | "notification_withdraw" | "notify_user" | "preference_propose" | "preference_registry_get" | "preference_registry_summary" | "project_create" | "project_delete" | "project_get" | "project_list" | "project_reorder" | "project_update" | "reddit_accounts_list" | "reddit_mentions_live" | "reddit_post_reply" | "reddit_posts_sync" | "reddit_search_live" | "reddit_thread_fetch" | "remember" | "remember_confirm" | "rig_get" | "rig_list" | "rig_promote" | "rig_propose_change" | "rig_verify" | "run_on" | "sandbox_attach" | "sandbox_file_publish" | "sandbox_provision" | "sandbox_swap" | "sandboxes_list" | "scheduled_task_runs_list" | "scheduled_tasks_create" | "scheduled_tasks_delete" | "scheduled_tasks_get" | "scheduled_tasks_list" | "scheduled_tasks_pause" | "scheduled_tasks_resume" | "scheduled_tasks_trigger" | "scheduled_tasks_update" | "secret_delete" | "secret_get" | "secret_move" | "secret_profile_get" | "secret_profile_set" | "secret_save" | "secret_search" | "session_create" | "session_events" | "session_get" | "session_human_input_respond" | "session_links_add" | "session_links_remove" | "session_message_status" | "session_pause" | "session_queue_message" | "session_resume" | "session_send_message" | "session_set_model" | "session_set_project" | "session_steer" | "session_target_get" | "session_target_set" | "session_wait" | "sessions_list" | "set_other_session_title" | "set_session_title" | "set_waiting_on" | "sidebar_layout_get" | "sidebar_layout_update" | "site_data_define_collection" | "site_data_describe" | "site_data_export" | "site_data_import" | "site_data_query" | "site_data_reset" | "site_data_write" | "site_files_delete" | "site_files_list" | "site_files_upload" | "site_hostname_check" | "site_publication_apply_fix" | "site_publication_get" | "site_publication_update" | "site_sql_define_query" | "site_sql_enable" | "site_sql_execute" | "site_sql_export" | "site_sql_import" | "site_sql_inspect" | "site_sql_migrate" | "site_sql_query" | "site_sql_reset" | "site_sql_run" | "slack_agent_chats" | "slack_agent_handoff" | "slack_agent_propose" | "slack_agent_suggest" | "slack_bot_channel_history" | "slack_bot_delete_message" | "slack_bot_file_content" | "slack_bot_file_info" | "slack_bot_list_channels" | "slack_bot_list_files" | "slack_bot_list_users" | "slack_bot_post_message" | "slack_bot_prepare_message" | "slack_bot_search" | "slack_bot_send_prepared_message" | "slack_bot_thread_replies" | "slack_bot_upload_file" | "social_connections_list" | "social_daily_analysis_context" | "social_mentions_live" | "social_post_reply" | "social_posts_recent" | "social_posts_sync" | "social_search_live" | "social_thread_fetch" | "task_note_archive" | "task_note_promote_instruction_policy" | "task_note_promote_knowledge" | "task_note_promote_preference" | "task_note_replace" | "task_note_save" | "task_notes_list" | "variable_set_get_variable" | "variable_set_list" | "variable_set_set_variable" | "wait_for_input" | "work_claim_release" | "work_claim_upsert" | "x_accounts_list" | "x_mentions_live" | "x_post_reply" | "x_posts_sync" | "x_search_live" | "x_thread_fetch")[] | undefined; }; } | null; eligibleIds: Set; causalKeys: Map; origins: Map; version: number; executionGeneration: number; activeAttemptId: string | null; lineage: Record; initiatorKind: string; initiatorSubjectId: string; initiatorContext: Record; initiatingHumanSubjectId: string | null; executionContextTurnId: string | null; goalSnapshot: { state: "none"; capturedAt: string; } | { state: "active" | "completed" | "paused"; goalId: string; objectiveRevision: number; text: string; successCriteria: string | null; rootConstraints: string[]; reportRequirements?: { id: string; title: string; }[] | undefined; mutationPolicy: "autonomous_adaptation" | "preserve_intent" | "review_changes"; capturedAt: string; } | null; personalConnectionDelegations: { serverId: string; canonicalServerId?: string | undefined; connectionId: string; originWorkspaceId?: string | undefined; ownerSubjectId: string; providerDomain: string; kind?: "api_key" | "app_install" | "delegated" | "oauth2" | undefined; connectionType?: "atlassian" | "github_personal" | "mcp" | "social" | undefined; userDelegation?: { authorityId: string; grantId: string; organizationId: string; workspaceId: string; sessionId: string | null; action: string; mode: "always" | "once" | "session"; context: "user_private" | "workspace_shared"; authorityEpoch: number | null; authorityGeneration: number; grantGeneration: number; resourceVersionId?: string | null | undefined; } | undefined; personalGitHubRepositorySelection?: { credentialBindingId: string; connectionAuthorityGeneration: number; selectionGeneration: number; allRepositoriesAccess?: "read" | "write" | undefined; repositories: { repositoryId: string; fullName: string; canonicalUrl: string; ref: string; access: "read" | "write"; selectionGeneration: number; }[]; } | undefined; outputDestination?: { folderId: string; folderName: string; driveId: string | null; location: "my_drive" | "shared_drive"; selectedAt: string; } | undefined; }[]; mcpAccountBindings: { serverId: string; canonicalServerId: string; connectionId: string; originWorkspaceId: string; subjectScope: "subject" | "workspace"; ownerSubjectId: string | null; accountLabel: string; providerDomain: string; kind: "api_key" | "app_install" | "delegated" | "oauth2"; connectionRef: { connectionId?: string | undefined; accountSelection?: "all_eligible" | undefined; authoritySource?: "host" | undefined; hostBinding?: { bindingId: string; generation: number; } | { selection: "accepted_turn"; } | undefined; provider?: string | undefined; providerDomain: string; kind?: "api_key" | "app_install" | "delegated" | "oauth2" | undefined; scopes?: string[] | undefined; resource?: string | undefined; selectedResources?: { id: string; kind: "repository"; }[] | undefined; subjectScope?: "subject" | "workspace" | undefined; }; connectionAuthorityGeneration?: number | undefined; }[] | null; connectionAccountIntent: { version: 1; principal: { kind: "subject"; subjectId: string; } | { kind: "none"; }; selections: { serverId: string; connectionId: string; }[]; } | null; personalResourceAttachmentSummary: { mode: "always" | "once" | "session"; context: "user_private" | "workspace_shared"; resourceCount: number; resourceKinds: ("connected_machine" | "rig" | "variable_set")[]; sharedOutputWarningVersion: 1; } | null; personalResourceProtocolVersion: number; scheduledTaskRunId: string | null; xaiProviderAccountAuthoritySnapshot: { version: 1; scope: "organization"; } | { version: 1; scope: "workspace"; } | { version: 1; scope: "user"; authorityGeneration: number; }; claudeProviderAccountAuthoritySnapshot: { version: 1; scope: "organization"; } | { version: 1; scope: "workspace"; } | { version: 1; scope: "user"; authorityGeneration: number; }; subscriptionAuthority: { version: 2; personal: { provider: "claude" | "codex" | "xai"; ownerMembershipId: string; authorityGeneration: number; sharedSessionChoice?: { sessionId: string; connectionId: string; } | undefined; }[]; } | null; cancelledBy: string | null; cancelReason: string | null; codemodeCallCount: number; startedAt: Date | null; finishedAt: Date | null; createdAt: Date; updatedAt: Date; externalLink: unknown; sessionMetadata: Record; sessionTools: unknown[]; sessionToolPolicy: { mode: "explicit" | "inherited" | "workspace_default"; inheritedFromSessionId: string | null; excludedMcpServerIds?: string[] | undefined; firstPartyMode?: "explicit" | "workspace_default" | undefined; firstPartyAdditions?: ("admin_action_call" | "admin_action_describe" | "admin_actions_search" | "app_data_define_collection" | "app_data_describe" | "app_data_export" | "app_data_import" | "app_data_query" | "app_data_reset" | "app_data_write" | "app_export" | "app_files_delete" | "app_files_list" | "app_files_upload" | "app_hostname_check" | "app_install" | "app_publication_apply_fix" | "app_publication_get" | "app_publication_update" | "app_server_run" | "app_server_runs" | "app_sql_define_query" | "app_sql_enable" | "app_sql_execute" | "app_sql_export" | "app_sql_import" | "app_sql_inspect" | "app_sql_migrate" | "app_sql_query" | "app_sql_reset" | "app_sql_run" | "app_sync_delete" | "app_sync_list" | "app_sync_opt_in" | "app_sync_run" | "app_sync_save" | "app_upgrade" | "app_webhook_delete" | "app_webhook_list" | "app_webhook_save" | "artifacts_archive" | "artifacts_create" | "artifacts_get_source" | "artifacts_list" | "artifacts_prepare_upload" | "artifacts_publish" | "artifacts_restore" | "artifacts_rollback" | "atlassian_get" | "atlassian_search" | "atlassian_sources_list" | "bot_template_save" | "browser_act" | "browser_auth" | "browser_clipboard" | "browser_debug" | "browser_download_save" | "browser_downloads" | "browser_identity" | "browser_lifecycle" | "browser_observe" | "browser_open" | "browser_publish" | "browser_read" | "browser_record" | "browser_screenshot" | "browser_tabs" | "call_user" | "capability_authorization_request" | "capability_catalog_search" | "command_read" | "command_wait" | "company_profile_confirm" | "company_profile_propose" | "computer_act" | "computer_clipboard" | "computer_lifecycle" | "computer_observe" | "computer_open" | "computer_targets" | "connected_machine_enable_screen_control" | "connected_machine_enroll_token" | "connected_machine_remove" | "custom_mcp_setup_request" | "editable_artifact_apply" | "editable_artifact_create" | "editable_artifact_export" | "editable_artifact_export_status" | "editable_artifact_get" | "editable_artifact_import" | "editable_artifact_inspect" | "editable_artifact_list" | "environment_list" | "environment_set_variable" | "event_sources_create_webhook" | "event_sources_delete" | "event_sources_list" | "event_sources_update" | "events_get" | "excel_run" | "fiken_bank_accounts_list" | "fiken_companies_list" | "fiken_contact_create" | "fiken_contacts_list" | "fiken_invoice_draft_create" | "fiken_invoice_get" | "fiken_invoices_list" | "fiken_products_list" | "fiken_purchases_list" | "fiken_sales_list" | "github_connect_link" | "github_repositories_list" | "github_repository_attach" | "goal_complete" | "goal_pause" | "goal_progress" | "goal_resume" | "goal_set" | "goal_update" | "inbox_tidy" | "instruction_policy_get" | "instruction_policy_propose" | "instruction_policy_save" | "interaction_discover" | "interaction_request_human" | "knowledge_archive" | "knowledge_browse" | "knowledge_correct" | "knowledge_get" | "knowledge_prepare_save" | "knowledge_propose" | "knowledge_retain_file" | "knowledge_retain_message" | "knowledge_save" | "knowledge_search" | "meeting_notes_save" | "meeting_read" | "meetings_search" | "memory_correct" | "memory_save" | "memory_search" | "notification_withdraw" | "notify_user" | "preference_propose" | "preference_registry_get" | "preference_registry_summary" | "project_create" | "project_delete" | "project_get" | "project_list" | "project_reorder" | "project_update" | "reddit_accounts_list" | "reddit_mentions_live" | "reddit_post_reply" | "reddit_posts_sync" | "reddit_search_live" | "reddit_thread_fetch" | "remember" | "remember_confirm" | "rig_get" | "rig_list" | "rig_promote" | "rig_propose_change" | "rig_verify" | "run_on" | "sandbox_attach" | "sandbox_file_publish" | "sandbox_provision" | "sandbox_swap" | "sandboxes_list" | "scheduled_task_runs_list" | "scheduled_tasks_create" | "scheduled_tasks_delete" | "scheduled_tasks_get" | "scheduled_tasks_list" | "scheduled_tasks_pause" | "scheduled_tasks_resume" | "scheduled_tasks_trigger" | "scheduled_tasks_update" | "secret_delete" | "secret_get" | "secret_move" | "secret_profile_get" | "secret_profile_set" | "secret_save" | "secret_search" | "session_create" | "session_events" | "session_get" | "session_human_input_respond" | "session_links_add" | "session_links_remove" | "session_message_status" | "session_pause" | "session_queue_message" | "session_resume" | "session_send_message" | "session_set_model" | "session_set_project" | "session_steer" | "session_target_get" | "session_target_set" | "session_wait" | "sessions_list" | "set_other_session_title" | "set_session_title" | "set_waiting_on" | "sidebar_layout_get" | "sidebar_layout_update" | "site_data_define_collection" | "site_data_describe" | "site_data_export" | "site_data_import" | "site_data_query" | "site_data_reset" | "site_data_write" | "site_files_delete" | "site_files_list" | "site_files_upload" | "site_hostname_check" | "site_publication_apply_fix" | "site_publication_get" | "site_publication_update" | "site_sql_define_query" | "site_sql_enable" | "site_sql_execute" | "site_sql_export" | "site_sql_import" | "site_sql_inspect" | "site_sql_migrate" | "site_sql_query" | "site_sql_reset" | "site_sql_run" | "slack_agent_chats" | "slack_agent_handoff" | "slack_agent_propose" | "slack_agent_suggest" | "slack_bot_channel_history" | "slack_bot_delete_message" | "slack_bot_file_content" | "slack_bot_file_info" | "slack_bot_list_channels" | "slack_bot_list_files" | "slack_bot_list_users" | "slack_bot_post_message" | "slack_bot_prepare_message" | "slack_bot_search" | "slack_bot_send_prepared_message" | "slack_bot_thread_replies" | "slack_bot_upload_file" | "social_connections_list" | "social_daily_analysis_context" | "social_mentions_live" | "social_post_reply" | "social_posts_recent" | "social_posts_sync" | "social_search_live" | "social_thread_fetch" | "task_note_archive" | "task_note_promote_instruction_policy" | "task_note_promote_knowledge" | "task_note_promote_preference" | "task_note_replace" | "task_note_save" | "task_notes_list" | "variable_set_get_variable" | "variable_set_list" | "variable_set_set_variable" | "wait_for_input" | "work_claim_release" | "work_claim_upsert" | "x_accounts_list" | "x_mentions_live" | "x_post_reply" | "x_posts_sync" | "x_search_live" | "x_thread_fetch")[] | undefined; }; }>; }>; /** Factual model context only; no credential identifiers, instructions or UI event changes. */ export declare function agentSelectionNotes(updates: readonly Update[], receiver: NonNullable>["context"]>, origins: Awaited>["origins"]): Record; export {};