@opengeni/db 3.7.4 → 4.0.0-canary.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (113) hide show
  1. package/dist/automations.d.ts +4 -0
  2. package/dist/canonical-human-identities.js +3 -3
  3. package/dist/capability-integrations.d.ts +2 -0
  4. package/dist/{chunk-6DPJA36C.js → chunk-2XEZK4LF.js} +7 -1
  5. package/dist/chunk-2XEZK4LF.js.map +1 -0
  6. package/dist/{chunk-4NAR7FBA.js → chunk-3RI33YQN.js} +67 -1
  7. package/dist/chunk-3RI33YQN.js.map +1 -0
  8. package/dist/{chunk-SZAWDXQC.js → chunk-CJROYHSC.js} +3 -3
  9. package/dist/{chunk-DZCYW2WT.js → chunk-MX6V5F65.js} +2 -2
  10. package/dist/{chunk-S3TDDCS2.js → chunk-N5VXJ4I2.js} +151 -78
  11. package/dist/chunk-N5VXJ4I2.js.map +1 -0
  12. package/dist/{chunk-U4WPPEBH.js → chunk-NLFHMPUB.js} +2 -2
  13. package/dist/{chunk-5NNCGFQY.js → chunk-P6NSEG2S.js} +2 -2
  14. package/dist/{chunk-O56DM5GZ.js → chunk-QM6YOWHZ.js} +624 -57
  15. package/dist/chunk-QM6YOWHZ.js.map +1 -0
  16. package/dist/{chunk-US4IS6IV.js → chunk-RZNOSEMC.js} +2 -2
  17. package/dist/{chunk-F6PBS6WE.js → chunk-UFAMOUWL.js} +2 -2
  18. package/dist/codemode-operations.d.ts +5 -0
  19. package/dist/codex-token-resolver.d.ts +6 -2
  20. package/dist/connection-token-resolver.d.ts +8 -0
  21. package/dist/editable-artifact-durable-export.js +2 -2
  22. package/dist/editable-artifacts.js +3 -3
  23. package/dist/generated-images.d.ts +15 -0
  24. package/dist/index.d.ts +393 -91
  25. package/dist/index.js +9992 -6069
  26. package/dist/index.js.map +1 -1
  27. package/dist/insights.d.ts +9 -0
  28. package/dist/managed-auth-session-sets.js +3 -3
  29. package/dist/managed-user-setup.d.ts +3 -0
  30. package/dist/mcp-oauth.d.ts +80 -0
  31. package/dist/migrate.d.ts +1 -0
  32. package/dist/migrate.js +3 -1
  33. package/dist/model-catalog.d.ts +153 -0
  34. package/dist/model-context-snapshots.d.ts +20 -0
  35. package/dist/new-session-drafts.d.ts +12 -0
  36. package/dist/organization-membership-lifecycle.d.ts +8 -1
  37. package/dist/organization-model-providers.d.ts +101 -0
  38. package/dist/pack-components.d.ts +1 -0
  39. package/dist/pr-review.d.ts +9 -0
  40. package/dist/provision-roles.js +1 -1
  41. package/dist/runtime-posture.d.ts +8 -8
  42. package/dist/schema.d.ts +7708 -5050
  43. package/dist/schema.js +25 -1
  44. package/dist/session-background-commands.d.ts +18 -6
  45. package/dist/session-background-commands.js +15 -9
  46. package/dist/session-control.d.ts +37 -2
  47. package/dist/session-goal-pacing.d.ts +3 -6
  48. package/dist/session-queue-commands.d.ts +17 -0
  49. package/dist/session-tenancy.js +3 -3
  50. package/dist/tool-gateway-approvals.d.ts +31 -0
  51. package/dist/video-generation.js +3 -3
  52. package/dist/workspace-artifacts.d.ts +17 -3
  53. package/dist/xai-subscription.d.ts +8 -0
  54. package/drizzle/0387_bound_host_export_session_payloads.sql +165 -0
  55. package/drizzle/0388_sandbox_provider_deadline_interactions.sql +491 -0
  56. package/drizzle/0389_model_catalog_and_gateway_custom_models.sql +241 -0
  57. package/drizzle/0390_organization_model_provider_connections.sql +197 -0
  58. package/drizzle/0391_sandbox_provider_deadline_interaction_followup.sql +295 -0
  59. package/drizzle/0392_context_compaction_pending_observability.sql +198 -0
  60. package/drizzle/0393_workspace_memory_and_learning_defaults.sql +102 -0
  61. package/drizzle/0394_session_selected_skill_activation.sql +20 -0
  62. package/drizzle/0395_scheduled_task_unclaimed_occurrence_invalidation.sql +154 -0
  63. package/drizzle/0396_model_call_equivalent_credit_cost.sql +28 -0
  64. package/drizzle/0397_sandbox_deadline_rotation_preemption.sql +113 -0
  65. package/drizzle/0398_organization_workspace_management_entry.sql +206 -0
  66. package/drizzle/0399_additional_managed_organization_creation.sql +691 -0
  67. package/drizzle/0400_session_attempt_model_context_snapshots.sql +65 -0
  68. package/drizzle/0401_organization_user_setup_token_transport.sql +178 -0
  69. package/drizzle/0402_session_input_wait_and_background_command_results.sql +1023 -0
  70. package/drizzle/0403_codex_unconditional_credential_leasing.sql +181 -0
  71. package/drizzle/0404_mcp_oauth_authorization_server.sql +471 -0
  72. package/drizzle/0405_tool_gateway_approval_capabilities.sql +184 -0
  73. package/drizzle/0406_workspace_html_site_sources.sql +71 -0
  74. package/package.json +6 -6
  75. package/src/automations.ts +9 -1
  76. package/src/capability-integrations.ts +8 -0
  77. package/src/codemode-operations.ts +31 -21
  78. package/src/codex-token-resolver.ts +16 -6
  79. package/src/connection-token-resolver.ts +52 -3
  80. package/src/generated-images.ts +70 -6
  81. package/src/index.ts +3894 -994
  82. package/src/insights-model-bundle.ts +54 -5
  83. package/src/insights.ts +53 -7
  84. package/src/managed-user-setup.ts +14 -3
  85. package/src/mcp-oauth.ts +488 -0
  86. package/src/migrate.ts +9 -1
  87. package/src/model-catalog.ts +682 -0
  88. package/src/model-context-snapshots.ts +151 -0
  89. package/src/new-session-drafts.ts +66 -21
  90. package/src/organization-membership-lifecycle.ts +47 -5
  91. package/src/organization-model-providers.ts +614 -0
  92. package/src/pack-components.ts +15 -2
  93. package/src/pr-review.ts +19 -0
  94. package/src/provision-roles.ts +4 -0
  95. package/src/runtime-posture.ts +64 -0
  96. package/src/schema.ts +666 -61
  97. package/src/session-background-commands.ts +180 -78
  98. package/src/session-control.ts +181 -12
  99. package/src/session-goal-pacing.ts +4 -8
  100. package/src/session-queue-commands.ts +157 -82
  101. package/src/tool-gateway-approvals.ts +168 -0
  102. package/src/workspace-artifacts.ts +633 -178
  103. package/src/xai-subscription.ts +66 -14
  104. package/dist/chunk-4NAR7FBA.js.map +0 -1
  105. package/dist/chunk-6DPJA36C.js.map +0 -1
  106. package/dist/chunk-O56DM5GZ.js.map +0 -1
  107. package/dist/chunk-S3TDDCS2.js.map +0 -1
  108. /package/dist/{chunk-SZAWDXQC.js.map → chunk-CJROYHSC.js.map} +0 -0
  109. /package/dist/{chunk-DZCYW2WT.js.map → chunk-MX6V5F65.js.map} +0 -0
  110. /package/dist/{chunk-U4WPPEBH.js.map → chunk-NLFHMPUB.js.map} +0 -0
  111. /package/dist/{chunk-5NNCGFQY.js.map → chunk-P6NSEG2S.js.map} +0 -0
  112. /package/dist/{chunk-US4IS6IV.js.map → chunk-RZNOSEMC.js.map} +0 -0
  113. /package/dist/{chunk-F6PBS6WE.js.map → chunk-UFAMOUWL.js.map} +0 -0
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { type ChildLifecycleSystemUpdateKind, type ChildRequiresActionRespondedByKind, SessionGoalSnapshot } from "@opengeni/contracts";
2
- import type { AccessContext, AccessGrant, AccessPrincipalKind, ApiKey, AttemptToolResult, BillingBalance, CapabilityCatalogItem, CapabilityInstallation, CapabilityPack, CapabilitySource, ConnectionKind, ConnectionMetadata, ConnectionStatus, DocumentAuthorityKind, McpServerConnectionRef, FileAsset, FileUploadStatus, FirstPartyMcpToolName, HumanInputQuestion, HumanInputResponse, KnowledgeMemory, KnowledgeMemoryKind, KnowledgeMemoryStatus, KnowledgeSourceRef, GitHubInstallationAuthorityKind, GitHubRepositoryScope, HostEventExportBatch, HostUsageExportBatch, ManagedAccount, ManagedOrganizationMembershipProjection, WorkspaceMemberCandidate, McpPersonalConnectionDelegation, ModelContextContributionSummary, Permission, PersonalResourceAttachmentIntent, PackInstallation, PackInstallationStatus, ResourceRef, SandboxBackend, SandboxOs, ScheduledTask, ScheduledTaskAction, ScheduledTaskActionKind, KnowledgeSourceSyncAction, ScheduledTaskAgentConfig, ScheduledTaskOverlapPolicy, ScheduledTaskRun, ScheduledTaskRunAcceptedExecution as ScheduledTaskRunAcceptedExecutionType, ScheduledTaskRunMode, ScheduledTaskRunStatus, ScheduledTaskScheduleSpec, ScheduledTaskStatus, ScheduledTaskTriggerType, SlackInstallationBinding, Session, SessionAuthorizationListScope, SessionListResponse, SessionEvent, SessionEventPayloadMode, SessionEventReadDirection, SessionEventSemanticClass, SessionEventType, SessionGoal, SessionGoalChangeKind, SessionGoalCreatedBy, SessionGoalMutationPolicy, SessionGoalRevision, SessionGoalStatus, SessionHumanInputRequest, LineageNode, SessionMcpApprovalPolicy, SessionSkill, SessionMcpServerMetadata, SessionStatus, SessionToolPolicy, SessionTurn, SessionQueueSnapshot, SessionSystemUpdate, SessionSystemUpdateKind, SystemUpdateClassification, SessionTurnSource, SessionTurnStatus, TurnInitiator, TurnInitiatorContext, SocialConnection, SocialConnectionStatus, SocialPost, SocialProvider, ToolRef, ReasoningEffort, UsageEvent, Workspace, WorkspaceControlEvent, VariableSet, VariableSetSecret, VariableSetVariableMetadata, WorkspaceMember, WorkspaceMemoryPromptMode, WorkspaceRegisteredPack, Channel, Rig, RigProviderImage, RigProviderImages, RigVersion, RigVerificationHealth, RigChange, RigChangeKind, RigChangeStatus, RigCheck, NativeSnapshotDescriptor, TarWorkspaceArchiveDescriptor, WorkspaceArchiveDescriptor, ModalCheckpointProviderBinding, SandboxProviderContinuityRecovery, WorkClaimSubjectFilter, WorkDiscoveryProjection } from "@opengeni/contracts";
2
+ import type { AccessContext, AccessGrant, AccessPrincipalKind, ApiKey, AttemptToolResult, BillingBalance, CapabilityCatalogItem, CapabilityInstallation, CapabilityPack, CapabilitySource, ConnectionKind, ConnectionMetadata, ConnectionStatus, DocumentAuthorityKind, McpServerConnectionRef, FileAsset, FileUploadStatus, FirstPartyMcpToolName, HumanInputQuestion, HumanInputResponse, KnowledgeMemory, KnowledgeMemoryKind, KnowledgeMemoryStatus, KnowledgeSourceRef, GitHubInstallationAuthorityKind, GitHubRepositoryScope, HostEventExportBatch, HostUsageExportBatch, ManagedAccount, ManagedOrganizationMembershipProjection, WorkspaceMemberCandidate, McpPersonalConnectionDelegation, ModelContextContributionSummary, Permission, PersonalResourceAttachmentIntent, PackInstallation, PackInstallationStatus, ResourceRef, SandboxBackend, SandboxOs, ScheduledTask, ScheduledTaskAction, ScheduledTaskActionKind, KnowledgeSourceSyncAction, ScheduledTaskAgentConfig, ScheduledTaskOverlapPolicy, ScheduledTaskRun, ScheduledTaskRunAcceptedExecution as ScheduledTaskRunAcceptedExecutionType, ScheduledTaskRunMode, ScheduledTaskRunStatus, ScheduledTaskScheduleSpec, ScheduledTaskStatus, ScheduledTaskTriggerType, SlackInstallationBinding, Session, SessionAuthorizationListScope, SessionListResponse, SessionEvent, SessionEventPayloadMode, SessionEventReadDirection, SessionEventSemanticClass, SessionEventType, SessionGoal, SessionGoalChangeKind, SessionGoalCreatedBy, SessionGoalMutationPolicy, SessionGoalRevision, SessionGoalStatus, SessionHumanInputRequest, LineageNode, SessionMcpApprovalPolicy, SessionBackgroundCommand, SessionSkill, SessionMcpServerMetadata, SessionStatus, SessionToolPolicy, SessionTurn, SessionQueueSnapshot, SessionSystemUpdate, SessionSystemUpdateKind, SystemUpdateClassification, SessionTurnSource, SessionTurnStatus, TurnInitiator, TurnInitiatorContext, SocialConnection, SocialConnectionStatus, SocialPost, SocialProvider, ToolRef, ReasoningEffort, UsageEvent, Workspace, WorkspaceControlEvent, VariableSet, VariableSetSecret, VariableSetVariableMetadata, WorkspaceMember, WorkspaceMemoryPromptMode, WorkspaceRegisteredPack, Channel, Rig, RigProviderImage, RigProviderImages, RigVersion, RigVerificationHealth, RigChange, RigChangeKind, RigChangeStatus, RigCheck, NativeSnapshotDescriptor, TarWorkspaceArchiveDescriptor, WorkspaceArchiveDescriptor, ModalCheckpointProviderBinding, SandboxProviderContinuityRecovery, WorkClaimSubjectFilter, WorkDiscoveryProjection } from "@opengeni/contracts";
3
3
  import { type WorkspaceArchiveObjectRef, RequestHumanInteractionToolInput, XaiProviderAccountAuthoritySnapshotV1, type TimelineAnnotation } from "@opengeni/contracts";
4
- import { type LatencyMode, SessionSystemUpdatePayload, TurnExecutionPolicyV1 } from "@opengeni/contracts";
4
+ import { type LatencyMode, SessionSystemUpdatePayload, TurnExecutionPolicyV1, CodexCredentialPolicySnapshotV1 } from "@opengeni/contracts";
5
5
  import { type Settings } from "@opengeni/config";
6
6
  import { type CodexFetch } from "@opengeni/codex";
7
7
  export { isCodexBilledModel } from "@opengeni/codex";
@@ -11,6 +11,7 @@ export { frozenInitiatorForCommandActor, type FrozenTurnInitiator } from "./turn
11
11
  export { LOSSLESS_TEXT_PREFIX } from "./lossless-json.js";
12
12
  import { type NewSessionDraftSnapshot } from "./new-session-drafts.js";
13
13
  import { type SessionDiscoveryControl, type SessionCommandActor, type SessionTurnAttemptOutcome } from "./session-control.js";
14
+ import { type ConnectedMachineBackgroundCommandClaim } from "./session-background-commands.js";
14
15
  import { type SessionRealtimeContinuityEntry } from "./session-realtime-context.js";
15
16
  import * as schema from "./schema.js";
16
17
  export { sql as dbSql } from "drizzle-orm";
@@ -68,6 +69,7 @@ export { memoryTextForStorage } from "./memory-domain.js";
68
69
  export { migrate, runMigrations } from "./migrate.js";
69
70
  export { provisionRoles, type ProvisionResult, type ProvisionRolesOptions, } from "./provision-roles.js";
70
71
  export * from "./memory-domain.js";
72
+ export * from "./model-catalog.js";
71
73
  import { type Database, type SessionActivityDatabase } from "./database.js";
72
74
  export { createDb, registerDbBinding, retrySessionActivityRls, rlsContextForWorkspace, rlsStrategyFor, setRlsContext, setSubjectRlsContext, withAccountRls, withDatabaseStatementTimeout, withRlsContext, withSessionActivityRlsContext, withSessionActivitySavepoint, withWorkspaceRls, withWorkspaceSessionActivityRls, withWorkspaceSubjectRls, withWorkspaceSubjectSessionActivityRls, withWorkspaceUsageLock, withSandboxProviderReadLock, SandboxProviderReadLockUnavailableError, type CreateDbOptions, type Database, type DbClient, type SessionActivityDatabase, type RlsContext, type SessionRlsActorContext, type RlsStrategy, type SandboxProviderReadLockIdentity, type ManagedUserProfile, type UserLookup, type UserProfileLookup, } from "./database.js";
73
75
  export { withSessionRlsActorContext } from "./database.js";
@@ -536,6 +538,7 @@ export declare function deleteWorkspaceIfQuiescent(db: Database, input: {
536
538
  accountId: string;
537
539
  workspaceId: string;
538
540
  observer?: WorkspaceDeleteObserver;
541
+ organizationAdministratorSubjectId?: string;
539
542
  }): Promise<DeleteWorkspaceIfQuiescentResult>;
540
543
  /** Claim a bounded cross-workspace batch after abandoned claims expire. */
541
544
  export declare function claimTemporalScheduleCleanups(db: Database, input: {
@@ -718,6 +721,7 @@ export type ModelCallFact = {
718
721
  totalTokens: number | null;
719
722
  pricedCostMicros: number;
720
723
  estimatedProviderCostMicros: number | null;
724
+ equivalentCreditCostMicros: number | null;
721
725
  pricingSource: "configured_list_price" | "gateway_reported" | null;
722
726
  contextContributions: readonly ModelContextContributionSummary[] | null;
723
727
  occurredAt: Date;
@@ -740,6 +744,7 @@ export declare function recordModelCallFact(db: Database, input: {
740
744
  billingPath: ModelCallBillingPath;
741
745
  pricedCostMicros: number;
742
746
  estimatedProviderCostMicros?: number | null;
747
+ equivalentCreditCostMicros?: number | null;
743
748
  pricingSource?: "configured_list_price" | "gateway_reported" | null;
744
749
  contextContributions?: readonly ModelContextContributionSummary[] | null;
745
750
  inputTokens?: number | null;
@@ -849,6 +854,8 @@ export type CreateScheduledTaskInput = {
849
854
  variableSetId?: string | null;
850
855
  rigId?: string | null;
851
856
  metadata: Record<string, unknown>;
857
+ /** Trusted database-only admission seam. Throwing rolls the task creation back. */
858
+ beforeCreateCommit?: (tx: Database) => Promise<void>;
852
859
  };
853
860
  export type UpdateScheduledTaskInput = Partial<{
854
861
  name: string;
@@ -870,6 +877,8 @@ export type UpdateScheduledTaskInput = Partial<{
870
877
  authorityUpdatedBy: TurnInitiator;
871
878
  authorityUpdatedByContext: TurnInitiatorContext;
872
879
  authorityUpdatedByActor: AgentSessionCreationActor | null;
880
+ /** Trusted database-only admission seam. Throwing rolls the task update back. */
881
+ beforeUpdateCommit: (tx: Database) => Promise<void>;
873
882
  }>;
874
883
  export type CreatePackInstallationInput = {
875
884
  accountId: string;
@@ -992,6 +1001,43 @@ export type CreateConnectionInput = {
992
1001
  createdBySubjectId?: string | null;
993
1002
  updatedBySubjectId?: string | null;
994
1003
  };
1004
+ type UpsertWorkspaceProviderApiKeyConnectionInput = {
1005
+ accountId: string;
1006
+ workspaceId: string;
1007
+ operationId: string;
1008
+ requestDigest: string;
1009
+ credentialEncrypted: string;
1010
+ grantedScopes?: string[];
1011
+ expiresAt?: Date | null;
1012
+ metadata?: Record<string, unknown>;
1013
+ updatedBySubjectId: string;
1014
+ };
1015
+ type RotateWorkspaceProviderApiKeyConnectionInput = {
1016
+ accountId: string;
1017
+ workspaceId: string;
1018
+ connectionId: string;
1019
+ expectedVersion: number;
1020
+ operationId: string;
1021
+ requestDigest: string;
1022
+ credentialEncrypted: string;
1023
+ grantedScopes?: string[];
1024
+ expiresAt?: Date | null;
1025
+ metadata?: Record<string, unknown>;
1026
+ updatedBySubjectId: string;
1027
+ };
1028
+ type RevokeWorkspaceProviderApiKeyConnectionsInput = {
1029
+ accountId: string;
1030
+ workspaceId: string;
1031
+ connectionId: string;
1032
+ expectedVersion: number;
1033
+ updatedBySubjectId: string;
1034
+ };
1035
+ export type UpsertWorkspaceVercelAiGatewayConnectionInput = UpsertWorkspaceProviderApiKeyConnectionInput;
1036
+ export type RotateWorkspaceVercelAiGatewayConnectionInput = RotateWorkspaceProviderApiKeyConnectionInput;
1037
+ export type RevokeWorkspaceVercelAiGatewayConnectionsInput = RevokeWorkspaceProviderApiKeyConnectionsInput;
1038
+ export type UpsertWorkspaceOpenRouterConnectionInput = UpsertWorkspaceProviderApiKeyConnectionInput;
1039
+ export type RotateWorkspaceOpenRouterConnectionInput = RotateWorkspaceProviderApiKeyConnectionInput;
1040
+ export type RevokeWorkspaceOpenRouterConnectionsInput = RevokeWorkspaceProviderApiKeyConnectionsInput;
995
1041
  export type UpdateConnectionInput = {
996
1042
  workspaceId: string;
997
1043
  connectionId: string;
@@ -1335,6 +1381,7 @@ export type InstallPortableSkillInput = {
1335
1381
  sourcePath: string;
1336
1382
  name: string;
1337
1383
  description: string;
1384
+ activationMode?: "workspace_managed" | "session_selected";
1338
1385
  category?: string;
1339
1386
  tags?: string[];
1340
1387
  provenance?: "platform" | "deployment" | "registry" | "workspace";
@@ -1373,6 +1420,7 @@ export type PortableSkillRuntime = {
1373
1420
  version: string;
1374
1421
  name: string;
1375
1422
  description: string;
1423
+ activationMode: "workspace_managed" | "session_selected";
1376
1424
  sourceUrl: string;
1377
1425
  sourceCommit: string;
1378
1426
  sourcePath: string;
@@ -1848,8 +1896,14 @@ export declare function getCapabilityCatalogItem(db: Database, workspaceId: stri
1848
1896
  * immutable history.
1849
1897
  */
1850
1898
  export declare function installPortableSkill(db: Database, input: InstallPortableSkillInput): Promise<InstalledPortableSkill>;
1851
- /** Return exact text artifacts for active authoritative Skill installations. */
1852
- export declare function listInstalledPortableSkills(db: Database, workspaceId: string): Promise<PortableSkillRuntime[]>;
1899
+ /**
1900
+ * Return exact text artifacts for active authoritative Skill installations.
1901
+ * Session-selected Skills are excluded from ambient runtime resolution unless
1902
+ * the caller is explicitly materializing one during session admission.
1903
+ */
1904
+ export declare function listInstalledPortableSkills(db: Database, workspaceId: string, options?: {
1905
+ includeSessionSelected?: boolean;
1906
+ }): Promise<PortableSkillRuntime[]>;
1853
1907
  /** Return secret-free lifecycle summaries from the authoritative Skill ledger. */
1854
1908
  export declare function listInstalledSkills(db: Database, workspaceId: string): Promise<InstalledSkillSummary[]>;
1855
1909
  export declare function getPortableSkillUninstallPreview(db: Database, workspaceId: string, capabilityId: string): Promise<PortableSkillUninstallPreview>;
@@ -1886,6 +1940,15 @@ export declare function decryptedCapabilityHeaders(server: EnabledMcpCapabilityS
1886
1940
  export declare function getStoredCapabilityHeaderCiphertext(db: Database, workspaceId: string, capabilityId: string): Promise<Record<string, string> | null>;
1887
1941
  export declare function mcpServerIdForCapability(capabilityId: string, metadata?: Record<string, unknown>): string;
1888
1942
  export declare function createConnection(db: Database, input: CreateConnectionInput): Promise<ConnectionMetadataWithVerification>;
1943
+ /** Compatibility wrapper for the existing Vercel AI Gateway create/replay contract. */
1944
+ export declare function upsertWorkspaceVercelAiGatewayConnection(db: Database, input: UpsertWorkspaceVercelAiGatewayConnectionInput): Promise<ConnectionMetadataWithVerification | null>;
1945
+ export declare function upsertWorkspaceOpenRouterConnection(db: Database, input: UpsertWorkspaceOpenRouterConnectionInput): Promise<ConnectionMetadataWithVerification | null>;
1946
+ /** Compatibility wrapper for the existing Vercel AI Gateway rotation contract. */
1947
+ export declare function rotateWorkspaceVercelAiGatewayConnection(db: Database, input: RotateWorkspaceVercelAiGatewayConnectionInput): Promise<ConnectionMetadataWithVerification | null>;
1948
+ export declare function rotateWorkspaceOpenRouterConnection(db: Database, input: RotateWorkspaceOpenRouterConnectionInput): Promise<ConnectionMetadataWithVerification | null>;
1949
+ /** Compatibility wrapper for the existing Vercel AI Gateway revoke contract. */
1950
+ export declare function revokeWorkspaceVercelAiGatewayConnections(db: Database, input: RevokeWorkspaceVercelAiGatewayConnectionsInput): Promise<ConnectionMetadataWithVerification | null>;
1951
+ export declare function revokeWorkspaceOpenRouterConnections(db: Database, input: RevokeWorkspaceOpenRouterConnectionsInput): Promise<ConnectionMetadataWithVerification | null>;
1889
1952
  /**
1890
1953
  * Serialize one provider-principal/owner connection generation. Distinct OAuth
1891
1954
  * starts for the same principal converge on one row, while an explicit
@@ -2517,14 +2580,21 @@ export declare function loadConnectionCredentialForBroker(db: Database, settings
2517
2580
  allowSubjectOwned?: boolean;
2518
2581
  expectedAuthorityGeneration?: number;
2519
2582
  }): Promise<ConnectionCredentialForBroker | null>;
2520
- export declare function workspaceVercelAiGatewayConnectionActive(db: Database, workspaceId: string): Promise<boolean>;
2521
2583
  /** Metadata-only capability revision input; never selects/decrypts the API key. */
2522
2584
  export declare function getWorkspaceVercelAiGatewayConnectionMetadata(db: Database, workspaceId: string): Promise<{
2523
2585
  connectionId: string;
2524
2586
  version: number;
2525
2587
  } | null>;
2588
+ export declare function getWorkspaceOpenRouterConnectionMetadata(db: Database, workspaceId: string): Promise<{
2589
+ connectionId: string;
2590
+ version: number;
2591
+ } | null>;
2592
+ export declare function workspaceVercelAiGatewayConnectionActive(db: Database, workspaceId: string): Promise<boolean>;
2593
+ export declare function workspaceOpenRouterConnectionActive(db: Database, workspaceId: string): Promise<boolean>;
2526
2594
  /** Resolve only the reviewed workspace-shared AI Gateway credential shape. */
2527
2595
  export declare function loadWorkspaceVercelAiGatewayApiKey(db: Database, settings: Settings, workspaceId: string): Promise<string | null>;
2596
+ /** Resolve only the reviewed workspace-shared OpenRouter credential shape. */
2597
+ export declare function loadWorkspaceOpenRouterApiKey(db: Database, settings: Settings, workspaceId: string): Promise<string | null>;
2528
2598
  /**
2529
2599
  * Worker-only immutable credential lease for an asynchronous video operation.
2530
2600
  * The operation copies the already-encrypted credential envelope before its
@@ -2753,6 +2823,11 @@ export declare function createScheduledTaskRun(db: Database, input: {
2753
2823
  scheduledAt?: Date | null;
2754
2824
  firedAt?: Date;
2755
2825
  acceptedExecutionSnapshot?: ScheduledTaskRunAcceptedExecutionType | null;
2826
+ /**
2827
+ * Trusted database-only admission seam for a fresh agent occurrence.
2828
+ * Throwing rolls back the run insert; exact producer replay skips it.
2829
+ */
2830
+ beforeFreshAgentRunCommit?: (tx: Database) => Promise<void>;
2756
2831
  }): Promise<ScheduledTaskRun>;
2757
2832
  export declare function getScheduledTaskRunAcceptedExecution(db: Database, input: {
2758
2833
  workspaceId: string;
@@ -3609,11 +3684,17 @@ export type WorkspaceCodexSubscriptionSource = {
3609
3684
  organizationAvailable: boolean;
3610
3685
  };
3611
3686
  export declare function getWorkspaceCodexSubscriptionSource(db: Database, workspaceId: string): Promise<WorkspaceCodexSubscriptionSource>;
3687
+ export declare class CodexSubscriptionSourceChangeBlockedError extends Error {
3688
+ readonly code = "codex_subscription_source_change_blocked";
3689
+ constructor();
3690
+ }
3612
3691
  export declare function setWorkspaceCodexSubscriptionModeInTransaction(scopedDb: Database, input: {
3613
3692
  accountId: string;
3614
3693
  workspaceId: string;
3615
3694
  subjectId: string | null;
3616
3695
  mode: WorkspaceCodexSubscriptionMode;
3696
+ /** Effective source captured under the source lock before caller-owned credential writes. */
3697
+ effectiveSourceBeforeMutation?: EffectiveCodexSubscriptionSource;
3617
3698
  }): Promise<WorkspaceCodexSubscriptionSource>;
3618
3699
  export declare function setWorkspaceCodexSubscriptionMode(db: Database, input: {
3619
3700
  accountId: string;
@@ -3859,7 +3940,7 @@ export declare function getCodexCredentialStatus(db: Database, workspaceId: stri
3859
3940
  * decide whether to inject the synthetic codex-subscription provider, so billing
3860
3941
  * and provider-injection cannot drift. Metadata-only read (never the secret).
3861
3942
  */
3862
- export declare function workspaceCodexSubscriptionActive(db: Database, settings: Pick<Settings, "codexSubscriptionEnabled" | "codexCredentialLeasingEnabled">, workspaceId: string): Promise<boolean>;
3943
+ export declare function workspaceCodexSubscriptionActive(db: Database, settings: Pick<Settings, "codexSubscriptionEnabled">, workspaceId: string): Promise<boolean>;
3863
3944
  /**
3864
3945
  * CANONICAL "is this a Codex-billed turn?" predicate.
3865
3946
  *
@@ -3875,7 +3956,7 @@ export declare function workspaceCodexSubscriptionActive(db: Database, settings:
3875
3956
  */
3876
3957
  export declare function isCodexBilledTurn(input: {
3877
3958
  db: Database;
3878
- settings: Pick<Settings, "codexSubscriptionEnabled" | "codexCredentialLeasingEnabled">;
3959
+ settings: Pick<Settings, "codexSubscriptionEnabled">;
3879
3960
  workspaceId: string;
3880
3961
  model: string | null | undefined;
3881
3962
  /**
@@ -3947,15 +4028,25 @@ export type CodexCredentialLeaseCandidateFilter<TPolicyScope, TUnavailableDiagno
3947
4028
  accounts: readonly CodexLeaseAccountStatus[];
3948
4029
  policyScope: TPolicyScope | null;
3949
4030
  }) => readonly CodexLeaseAccountStatus[] | CodexCredentialLeaseCandidateFilterResult<TUnavailableDiagnostic>;
4031
+ /**
4032
+ * Codex session state read from the exact session row locked by credential
4033
+ * acquisition. Selection and pointer movement must use this snapshot rather
4034
+ * than an unlocked read taken before the allocator transaction.
4035
+ */
4036
+ export type CodexCredentialLeaseSessionState = {
4037
+ pinnedCredentialId: string | null;
4038
+ pinSource: "manual" | "policy" | null;
4039
+ lastCredentialId: string | null;
4040
+ };
3950
4041
  export type CodexCredentialLeaseSelectionContext<TPolicyScope = never, TUnavailableDiagnostic = never> = {
3951
4042
  accounts: CodexLeaseAccountStatus[];
3952
4043
  activeCredentialId: string | null;
3953
4044
  rotationEnabled: boolean;
3954
- /** Workspace cutover fence. False means the additive lease table stays inert. */
3955
- leaseRotationEnabled: boolean;
3956
4045
  rotationStrategy: string;
3957
4046
  /** A still-live idempotent lease for this SAME turn, if one exists. */
3958
4047
  existingCredentialId: string | null;
4048
+ /** Credentials already consumed by a definitive refusal on this accepted turn. */
4049
+ failedCredentialIds?: readonly string[];
3959
4050
  /** Downstream-owned accepted-turn policy; absent until a resolver is supplied. */
3960
4051
  policyScope: TPolicyScope | null;
3961
4052
  /** Diagnostics produced while choosing one policy scope for this NEW allocation. */
@@ -3973,6 +4064,14 @@ export type CodexCredentialLeaseResult<T, TUnavailableDiagnostic = never> = {
3973
4064
  activeCredentialId: string | null;
3974
4065
  rotationEnabled: boolean;
3975
4066
  rotationStrategy: string;
4067
+ /** Session state from the row locked during this acquisition. */
4068
+ sessionCodexState: CodexCredentialLeaseSessionState;
4069
+ /** Number of effective-pool rows before any downstream policy filter. */
4070
+ poolAccountCount: number;
4071
+ /** Accepted allocator policy captured with the first durable lease. */
4072
+ codexPolicySnapshot: CodexCredentialPolicySnapshotV1 | null;
4073
+ /** True when this acquisition reused a snapshot already present on the turn. */
4074
+ codexPolicySnapshotReused: boolean;
3976
4075
  credentialId: string | null;
3977
4076
  reused: boolean;
3978
4077
  holderId: string | null;
@@ -3981,7 +4080,19 @@ export type CodexCredentialLeaseResult<T, TUnavailableDiagnostic = never> = {
3981
4080
  unavailableDiagnostics: readonly TUnavailableDiagnostic[];
3982
4081
  /** Final selector decision after input policy and manual/policy pin handling. */
3983
4082
  advanceActivePointer: boolean;
4083
+ /** Frozen alternate-account budget observed before the first provider request. */
4084
+ failoverLimit: number;
3984
4085
  };
4086
+ export declare class CodexCredentialLeaseAttemptFencedError extends Error {
4087
+ readonly code = "codex_credential_lease_attempt_fenced";
4088
+ constructor();
4089
+ }
4090
+ export declare class CodexCredentialFailoverExhaustedError extends Error {
4091
+ readonly failoverCount: number;
4092
+ readonly maxFailovers: number;
4093
+ readonly code = "codex_credential_failover_exhausted";
4094
+ constructor(failoverCount: number, maxFailovers: number);
4095
+ }
3985
4096
  /**
3986
4097
  * Five minutes is deliberately much longer than the one-minute heartbeat and
3987
4098
  * much shorter than a five-hour allowance window. A killed worker therefore
@@ -4006,7 +4117,14 @@ export declare const CODEX_CREDENTIAL_LEASE_TTL_MS: number;
4006
4117
  export declare function acquireCodexCredentialLease<T, TPolicyScope = never, TUnavailableDiagnostic = never>(db: Database, input: {
4007
4118
  accountId: string;
4008
4119
  workspaceId: string;
4120
+ sessionId: string;
4009
4121
  turnId: string;
4122
+ attemptId: string;
4123
+ executionGeneration: number;
4124
+ workflowId: string;
4125
+ workflowRunId: string;
4126
+ dispatchId: string;
4127
+ expectedRedispatches: number;
4010
4128
  /** Unique Temporal/local activity execution id used as the zombie fence. */
4011
4129
  holderId: string;
4012
4130
  /** Pins must not move the workspace-global cursor. */
@@ -4024,9 +4142,9 @@ export declare function acquireCodexCredentialLease<T, TPolicyScope = never, TUn
4024
4142
  */
4025
4143
  filterNewAllocationCandidates?: CodexCredentialLeaseCandidateFilter<TPolicyScope, TUnavailableDiagnostic>;
4026
4144
  leaseTtlMs?: number;
4027
- }, select: (context: CodexCredentialLeaseSelectionContext<TPolicyScope, TUnavailableDiagnostic>) => CodexCredentialLeaseSelection<T>): Promise<CodexCredentialLeaseResult<T, TUnavailableDiagnostic>>;
4145
+ }, select: (context: CodexCredentialLeaseSelectionContext<TPolicyScope, TUnavailableDiagnostic>, sessionCodexState: CodexCredentialLeaseSessionState) => CodexCredentialLeaseSelection<T>): Promise<CodexCredentialLeaseResult<T, TUnavailableDiagnostic>>;
4028
4146
  export type CodexCapacityWaitStatus = "waiting" | "resumed" | "superseded";
4029
- export type CodexCapacityResetKind = "authoritative" | "bounded_refresh";
4147
+ export type CodexCapacityResetKind = "authoritative" | "bounded_refresh" | "mutation_only";
4030
4148
  export type CodexCapacityWait = {
4031
4149
  id: string;
4032
4150
  accountId: string;
@@ -4122,7 +4240,8 @@ export declare const CODEX_CAPACITY_REFRESH_MAX_MS: number;
4122
4240
  export declare function codexCapacityRefreshBackoffMs(attempt: number): number;
4123
4241
  /**
4124
4242
  * Atomically close one all-unavailable attempt and arm exactly one durable wait
4125
- * for the same logical turn. Lock order is allocator rotation row -> workspace
4243
+ * for the same logical turn. Lock order is workspace source advisory -> allocator
4244
+ * rotation row -> workspace
4126
4245
  * control -> actual workspace -> session -> exact turn -> exact attempt ->
4127
4246
  * optional goal -> live lease (when a reactive failure owns one) -> waiter.
4128
4247
  * The waiting turn/session pointer, durable events, exact lease release, and
@@ -4189,6 +4308,8 @@ export declare function reconcileCodexCapacityWait<TPolicyScope = never, TUnavai
4189
4308
  waiterId: string;
4190
4309
  generation: number;
4191
4310
  now?: Date;
4311
+ /** True only after the caller performed the due bounded metadata refresh. */
4312
+ boundedRefreshAttempted?: boolean;
4192
4313
  }, decide: (context: CodexCapacitySelectionContext<TPolicyScope, TUnavailableDiagnostic>) => CodexCapacityAvailabilityDecision, policy?: {
4193
4314
  resolvePolicyScope?: CodexCredentialLeasePolicyScopeResolver<TPolicyScope>;
4194
4315
  filterNewAllocationCandidates?: CodexCredentialLeaseCandidateFilter<TPolicyScope, TUnavailableDiagnostic>;
@@ -4292,7 +4413,8 @@ export declare function reconcileXaiCapacityWait(db: Database, input: {
4292
4413
  * Extend a live holder and return the database-confirmed expiry. A
4293
4414
  * missing/expired/released row returns null. A successful result lets the worker
4294
4415
  * derive a conservative monotonic deadline from the request start and configured
4295
- * TTL, without comparing the Postgres and worker wall clocks.
4416
+ * TTL, without comparing the Postgres and worker wall clocks; the worker still
4417
+ * rejects a response that returns after its prior confirmed deadline.
4296
4418
  */
4297
4419
  export declare function heartbeatCodexCredentialLeaseUntil(db: Database, accountId: string, workspaceId: string, turnId: string, holderId: string, generation: number, leaseTtlMs?: number): Promise<Date | null>;
4298
4420
  /** Extend a live holder. Compatibility wrapper for boolean-only callers. */
@@ -4308,20 +4430,46 @@ export type CodexCredentialLeaseQuarantine = {
4308
4430
  until: Date;
4309
4431
  cooldownKind: CodexCredentialCooldownKind;
4310
4432
  };
4433
+ export type CodexCredentialLeaseQuarantineResult = {
4434
+ action: "recorded";
4435
+ failoverCount: number;
4436
+ maxFailovers: number;
4437
+ exhausted: boolean;
4438
+ } | {
4439
+ action: "credential_changed";
4440
+ failoverCount: number;
4441
+ maxFailovers: number;
4442
+ currentCredentialVersion: number;
4443
+ } | {
4444
+ action: "stale";
4445
+ failoverCount: number;
4446
+ maxFailovers: number;
4447
+ };
4311
4448
  /**
4312
- * Quarantine the credential served by one exact live holder. The lease row is
4313
- * locked and checked before the credential write, so a superseded/expired
4314
- * activity cannot poison status or cooldown after a successor owns the turn.
4449
+ * Quarantine the credential served by one exact live attempt and token family.
4450
+ * The attempt, dispatch, lease, and credential version are checked before the
4451
+ * write. The same transaction freezes the accepted turn's alternate budget and
4452
+ * records the attempted credential, so waiter/database recovery cannot reset
4453
+ * accounting or return to an already-consumed account under rotation policy.
4315
4454
  */
4316
4455
  export declare function quarantineCodexCredentialForLease(db: Database, input: {
4317
4456
  accountId: string;
4318
4457
  workspaceId: string;
4458
+ sessionId: string;
4319
4459
  turnId: string;
4460
+ attemptId: string;
4461
+ executionGeneration: number;
4462
+ workflowId: string;
4463
+ workflowRunId: string;
4464
+ dispatchId: string;
4465
+ expectedRedispatches: number;
4320
4466
  credentialId: string;
4467
+ credentialVersion: number;
4321
4468
  holderId: string;
4322
4469
  generation: number;
4470
+ maxFailovers: number;
4323
4471
  quarantine: CodexCredentialLeaseQuarantine;
4324
- }): Promise<boolean>;
4472
+ }): Promise<CodexCredentialLeaseQuarantineResult>;
4325
4473
  /**
4326
4474
  * Metadata-only list of every connected Codex account in the workspace, for the
4327
4475
  * accounts UI + the worker's selection resolver. NEVER decrypts. `isActive` marks
@@ -4524,10 +4672,8 @@ export declare function recordCodexAccountUsage(db: Database, workspaceId: strin
4524
4672
  export declare function recordCodexAccountUsageWithWakeTargets(db: Database, workspaceId: string, credentialId: string, snapshot: CodexAccountUsageSnapshot): Promise<CodexCapacityMutationResult<boolean>>;
4525
4673
  export type CodexRotationSettings = {
4526
4674
  activeCredentialId: string | null;
4527
- /** Legacy selector bit; old binaries only understand this field. */
4675
+ /** False keeps new allocations on the active account; true permits pool failover. */
4528
4676
  rotationEnabled: boolean;
4529
- /** New allocator cutover bit; ignored safely by old binaries. */
4530
- leaseRotationEnabled: boolean;
4531
4677
  rotationStrategy: string;
4532
4678
  };
4533
4679
  /**
@@ -4579,20 +4725,6 @@ export declare function setInitialActiveCodexCredential(db: Database, workspaceI
4579
4725
  export declare function setCodexCredentialExhausted(db: Database, workspaceId: string, credentialId: string, until: Date | null, cooldownKind: CodexCredentialCooldownKind | null): Promise<boolean>;
4580
4726
  /** Cooldown mutation plus its committed durable capacity-wake outbox. */
4581
4727
  export declare function setCodexCredentialExhaustedWithWakeTargets(db: Database, workspaceId: string, credentialId: string, until: Date | null, cooldownKind: CodexCredentialCooldownKind | null): Promise<CodexCapacityMutationResult<boolean>>;
4582
- /**
4583
- * P3 reactive-rotation boundedness (Finding 1b): the number of CONSECUTIVE rotated
4584
- * 429-failover turns since the session last had a SUCCESSFUL turn. Counts
4585
- * `turn.failed` events carrying the `rotated` marker that occurred AFTER the most
4586
- * recent `turn.completed` event (the natural reset anchor — any successful turn
4587
- * moves the anchor past every prior failover, so the streak resets to 0). The
4588
- * reactive 429 catch consults this to bound its otherwise-0-delay re-dispatch:
4589
- * once the streak exceeds ~(connected accounts + margin) the path degrades to a
4590
- * fixed positive idle instead of another hot re-dispatch (invariant 4: NO THRASH),
4591
- * covering the double-fault where a cooldown write did not persist AND the 429
4592
- * carried no usage headers. Derived from persisted events so it is correct across
4593
- * the Temporal re-dispatch (each failover is a NEW turn, but its event survives).
4594
- */
4595
- export declare function countConsecutiveReactiveRotations(db: Database, workspaceId: string, sessionId: string): Promise<number>;
4596
4728
  /** The supported rotation strategies (P3). */
4597
4729
  export declare const CODEX_ROTATION_STRATEGIES: readonly ["most_remaining", "round_robin", "drain_then_next", "sharded"];
4598
4730
  export type CodexRotationStrategy = (typeof CODEX_ROTATION_STRATEGIES)[number];
@@ -4788,6 +4920,8 @@ export declare function ensureConnectorActionPolicyDefault(db: Database, input:
4788
4920
  changed: boolean;
4789
4921
  }>;
4790
4922
  export declare function prepareConnectorActionApproval(db: Database, identity: ConnectorActionAttemptIdentity, invocation: ConnectorActionInvocation): Promise<PrepareConnectorActionApprovalResult>;
4923
+ /** Resolve the frozen connector policy without creating approval or audit state. */
4924
+ export declare function previewConnectorActionApproval(db: Database, identity: ConnectorActionAttemptIdentity, invocation: ConnectorActionInvocation): Promise<PrepareConnectorActionApprovalResult>;
4791
4925
  export declare function beginConnectorActionExecution(db: Database, identity: ConnectorActionAttemptIdentity, invocation: ConnectorActionInvocation): Promise<BeginConnectorActionExecutionResult>;
4792
4926
  export declare function completeConnectorActionExecution(db: Database, input: {
4793
4927
  accountId: string;
@@ -4839,6 +4973,8 @@ export type SessionCreateInput = {
4839
4973
  policyRole?: string | null;
4840
4974
  parentSessionId?: string | null;
4841
4975
  createIdempotencyKey?: string | null;
4976
+ /** Exact explicit installed-Skill selection used for keyed-create replay. */
4977
+ selectedInstalledSkillIds?: string[];
4842
4978
  sandboxGroupId?: string | null;
4843
4979
  sandboxOs?: SandboxOs;
4844
4980
  /** Exact accepted generated-session compaction policy; internal lifecycle callers only. */
@@ -4858,7 +4994,9 @@ export type SessionCreateInput = {
4858
4994
  /** Trusted, transaction-local linkage run after the exact session row and
4859
4995
  * MCP metadata exist but before either can commit. It must perform database
4860
4996
  * work only; throwing rolls the complete create/replay transaction back. */
4861
- beforeCreateCommit?: (tx: Database, sessionId: string) => Promise<void>;
4997
+ beforeCreateCommit?: (tx: Database, sessionId: string, context?: {
4998
+ created: boolean;
4999
+ }) => Promise<void>;
4862
5000
  };
4863
5001
  export declare function createSession(db: Database, input: SessionCreateInput): Promise<DbSession>;
4864
5002
  /**
@@ -4883,6 +5021,43 @@ export declare function createSessionWithIdempotencyKey(db: Database, input: Ses
4883
5021
  createIdempotencyKey: string;
4884
5022
  }): Promise<SessionCreateSuccessResult>;
4885
5023
  export declare function getSessionByCreateIdempotencyKey(db: Database, workspaceId: string, createIdempotencyKey: string): Promise<Session | null>;
5024
+ /**
5025
+ * Recover a keyed create before mutable create dependencies (notably the
5026
+ * current model catalog) are consulted. A fully initialized queued turn gets a
5027
+ * fresh durable wake revision from persisted state only; an uninitialized shell
5028
+ * returns its persisted model so the caller can reopen it strictly as retained
5029
+ * while the canonical keyed transaction repairs initialization. The same
5030
+ * request-identity checks as transactional create replay run before any session
5031
+ * or committed denial is returned.
5032
+ */
5033
+ export type InitializedSessionCreateReplay = {
5034
+ outcome: "session";
5035
+ session: Session & {
5036
+ initialTurnId: string | null;
5037
+ };
5038
+ temporalWorkflowId: string;
5039
+ workflowWakeRevision: number | null;
5040
+ changed: boolean;
5041
+ } | {
5042
+ outcome: "pending";
5043
+ session: Session;
5044
+ } | {
5045
+ outcome: "denied";
5046
+ denial: SessionSpawnDenial;
5047
+ };
5048
+ export declare function getInitializedSessionCreateReplay(db: Database, input: {
5049
+ accountId: string;
5050
+ workspaceId: string;
5051
+ subjectId: string;
5052
+ activeManagedHumanSubjectId?: string;
5053
+ createIdempotencyKey: string;
5054
+ requestedSessionId?: string;
5055
+ visibility?: "user_private" | "workspace_shared";
5056
+ variableSetIds: string[];
5057
+ selectedInstalledSkillIds: string[];
5058
+ initialPersonalResourceAttachmentIntent?: PersonalResourceAttachmentIntent | null;
5059
+ deferInitialTurn?: boolean;
5060
+ }): Promise<InitializedSessionCreateReplay | null>;
4886
5061
  export declare function getSession(db: Database, workspaceId: string, sessionId: string): Promise<Session | null>;
4887
5062
  export type DeleteSessionTreeIfQuiescentResult = {
4888
5063
  status: "deleted";
@@ -5047,7 +5222,7 @@ type SessionTreeStats = NonNullable<Session["treeStats"]>;
5047
5222
  export declare function projectEffectiveControlForRelatedAccess(control: Session["effectiveControl"], sessionId: string, access: "target" | "root"): Session["effectiveControl"];
5048
5223
  /**
5049
5224
  * Remove metadata derived from sessions other than the exact authorized
5050
- * target, including parent identity and descendant counts.
5225
+ * target, including parent identity, policy provenance, and descendant counts.
5051
5226
  */
5052
5227
  export declare function projectSessionForRelatedAccess(session: Session, access: "target" | "root"): Session;
5053
5228
  /**
@@ -5228,7 +5403,8 @@ export declare function listSessionDiscoverySummaries(db: Database, workspaceId:
5228
5403
  recentHours?: number;
5229
5404
  subject?: WorkClaimSubjectFilter;
5230
5405
  claimLimit?: number;
5231
- /** Skip advisory claim reads for an operator-disabled discovery rollout. */
5406
+ /** Skip advisory claim reads on plain MCP browse or an operator-disabled rollout.
5407
+ * Omitted retains the REST/UI legacy evidence default. */
5232
5408
  includeWorkDiscovery?: boolean;
5233
5409
  subjectId?: string;
5234
5410
  authorizationScope?: SessionAuthorizationListScope;
@@ -5324,6 +5500,8 @@ export type SessionEventPage = {
5324
5500
  events: SessionEvent[];
5325
5501
  hasMore: boolean;
5326
5502
  bytes: number;
5503
+ /** True only when every full-mode event is the exact retained database row. */
5504
+ fullPayloadsExact: boolean;
5327
5505
  direction: SessionEventReadDirection;
5328
5506
  coveredSequence: {
5329
5507
  first: number;
@@ -5336,10 +5514,12 @@ export type SessionEventPage = {
5336
5514
  export declare const SESSION_EVENT_DB_PAGE_MAX_BYTES: number;
5337
5515
  /**
5338
5516
  * Read one direction-aware session-event page. Full mode selects the canonical
5339
- * row exactly; summary/none modes derive bounded monitoring projections in SQL
5340
- * without rewriting the retained source. `bytes` is the exact UTF-8 size of
5341
- * `JSON.stringify(events)`; `hasMore` is true whenever count or byte selection
5342
- * stopped before the durable range ended.
5517
+ * row exactly when it fits the page; an oversized historical row that predates
5518
+ * the durable write guard is projected at the bounded database-read boundary
5519
+ * when it would otherwise strand its cursor forever. Summary/none modes derive
5520
+ * bounded monitoring projections in SQL without rewriting the retained source.
5521
+ * `bytes` is the exact UTF-8 size of `JSON.stringify(events)`; `hasMore` is true
5522
+ * whenever count or byte selection stopped before the durable range ended.
5343
5523
  */
5344
5524
  export declare function listSessionEventPage(db: Database, workspaceId: string, sessionId: string, options?: ListSessionEventPageOptions): Promise<SessionEventPage>;
5345
5525
  export declare function listSessionEvents(db: Database, workspaceId: string, sessionId: string): Promise<SessionEvent[]>;
@@ -5356,6 +5536,18 @@ export declare function getWorkspaceControlEvent(db: Database, workspaceId: stri
5356
5536
  * a session, while the workspace predicate remains the tenancy boundary.
5357
5537
  */
5358
5538
  export declare function getSessionEventByClientEventId(db: Database, workspaceId: string, sessionId: string, clientEventId: string): Promise<SessionEvent | null>;
5539
+ /**
5540
+ * Resolve the visible creation event for one exact tool operation. This is a
5541
+ * rolling-upgrade compatibility lookup for producers that predate deterministic
5542
+ * client event ids; the operation id remains bound to the same turn attempt.
5543
+ */
5544
+ export declare function getSessionToolCallCreatedEventByOperationId(db: Database, input: {
5545
+ workspaceId: string;
5546
+ sessionId: string;
5547
+ turnId: string;
5548
+ attemptId: string;
5549
+ operationId: string;
5550
+ }): Promise<SessionEvent | null>;
5359
5551
  export declare const APPROVAL_RUN_STATE_MAX_JSON_BYTES: number;
5360
5552
  export declare const APPROVAL_RUN_STATE_MAX_JSON_NODES = 65536;
5361
5553
  export declare const APPROVAL_RUN_STATE_MAX_JSON_PROPERTIES = 32768;
@@ -5487,6 +5679,34 @@ export declare function adoptConnectedMachineSessionBackgroundCommand(db: Databa
5487
5679
  settledAt: string | null;
5488
5680
  updatedAt: string;
5489
5681
  }>;
5682
+ /** Transfer one exact managed retained process from a live turn attempt to its
5683
+ * session. Retaining the provider process and backgrounding it are deliberately
5684
+ * separate: a provider yield only preserves physical ownership; this adoption
5685
+ * occurs immediately before the running receipt becomes model-visible. */
5686
+ export declare function adoptManagedSessionBackgroundCommand(db: Database, input: {
5687
+ accountId: string;
5688
+ workspaceId: string;
5689
+ sessionId: string;
5690
+ turnId: string;
5691
+ executionGeneration: number;
5692
+ attemptId: string;
5693
+ processId: string;
5694
+ expected: SandboxRetainedProcessIdentity;
5695
+ command: string;
5696
+ }): Promise<{
5697
+ id: string;
5698
+ workspaceId: string;
5699
+ sessionId: string;
5700
+ provider: "connected_machine" | "managed";
5701
+ state: "exited" | "lost" | "running" | "stopping";
5702
+ commandPreview: string;
5703
+ cancelRequestedAt: string | null;
5704
+ exitCode: number | null;
5705
+ settlementReason: string | null;
5706
+ startedAt: string;
5707
+ settledAt: string | null;
5708
+ updatedAt: string;
5709
+ }>;
5490
5710
  export type InstallOrReadTurnExecutionPolicyForAttemptResult = {
5491
5711
  accepted: true;
5492
5712
  installed: boolean;
@@ -6208,6 +6428,9 @@ export type AcquireLeaseResult = {
6208
6428
  role: "fenced";
6209
6429
  reason: "superseded" | "capture_in_progress" | "rotation_in_progress" | "provider_recovery_in_progress";
6210
6430
  lease: LeaseSnapshot;
6431
+ /** Remaining durable capture budget from PostgreSQL's clock. Present only
6432
+ * for an exact active capture; callers cap it at the lifecycle ceiling. */
6433
+ captureRemainingMs?: number;
6211
6434
  };
6212
6435
  export type SandboxSharedPreparationSnapshot = {
6213
6436
  status: "running" | "completed" | "failed";
@@ -6965,6 +7188,16 @@ export declare function listSandboxViewerForceDrainWorkspaceIds(db: Database): P
6965
7188
  export declare function countQueuedTurns(db: Database): Promise<number>;
6966
7189
  export type SessionRecoveryBacklogState = "quiescence_missing" | "projection_stale";
6967
7190
  export declare function countSessionRecoveryBacklog(db: Database): Promise<Record<SessionRecoveryBacklogState, number>>;
7191
+ export type ContextCompactionPendingSummary = {
7192
+ pendingCount: number;
7193
+ oldestStartedAt: Date | null;
7194
+ };
7195
+ /**
7196
+ * Content-free cross-workspace projection of exact active attempts whose latest
7197
+ * automatic compaction landmark is still `started`. The trigger-maintained
7198
+ * private ledger survives turn-worker loss without exposing tenant identities.
7199
+ */
7200
+ export declare function getContextCompactionPendingSummary(db: Database): Promise<ContextCompactionPendingSummary>;
6968
7201
  export declare function countSandboxLeasesByLiveness(db: Database): Promise<Record<SandboxLeaseLiveness, number>>;
6969
7202
  export type CreditBalanceByAccount = {
6970
7203
  accountId: string;
@@ -6997,8 +7230,14 @@ export declare function confirmDrainCold(db: Database, input: {
6997
7230
  }>;
6998
7231
  export declare class SandboxWorkspaceMutationFencedError extends Error {
6999
7232
  readonly code: "attempt_fenced" | "holder_fenced" | "lease_fenced" | "rotation_in_progress" | "route_fenced" | "process_fenced" | "capture_in_progress" | "admission_fenced" | "operation_invalid" | "generation_exhausted" | "authority_unattributed" | "authority_revoked";
7233
+ /** Remaining exact archive-capture budget projected by PostgreSQL. This is
7234
+ * observational wait input only; it never licenses capture takeover. */
7235
+ readonly captureRemainingMs: number | null;
7000
7236
  readonly name: string;
7001
- constructor(code: "attempt_fenced" | "holder_fenced" | "lease_fenced" | "rotation_in_progress" | "route_fenced" | "process_fenced" | "capture_in_progress" | "admission_fenced" | "operation_invalid" | "generation_exhausted" | "authority_unattributed" | "authority_revoked", message: string);
7237
+ constructor(code: "attempt_fenced" | "holder_fenced" | "lease_fenced" | "rotation_in_progress" | "route_fenced" | "process_fenced" | "capture_in_progress" | "admission_fenced" | "operation_invalid" | "generation_exhausted" | "authority_unattributed" | "authority_revoked", message: string,
7238
+ /** Remaining exact archive-capture budget projected by PostgreSQL. This is
7239
+ * observational wait input only; it never licenses capture takeover. */
7240
+ captureRemainingMs?: number | null);
7002
7241
  }
7003
7242
  /** An operation named a durable retained process that has already reached a
7004
7243
  * terminal state. This remains a fence—the provider must not be called again
@@ -7332,8 +7571,9 @@ export declare function deferRetainedProcessReconciliation(db: Database, input:
7332
7571
  export declare function countActiveRetainedProcessesByOwnerState(db: Database): Promise<ActiveRetainedProcessOwnerCount[]>;
7333
7572
  export declare function countExpiredDrainingSandboxLeases(db: Database): Promise<ExpiredDrainingSandboxLeaseCount[]>;
7334
7573
  /** Settle an exact retained process only after exit or definitive loss proof.
7335
- * The process row, parent admission, non-TTL holder, and lease count transition
7336
- * commit atomically. A duplicate terminal state + exit code is idempotent and
7574
+ * The process row, parent admission, non-TTL holder, lease count, and any
7575
+ * linked background-command terminal input commit atomically. A duplicate
7576
+ * terminal state + exit code is idempotent and
7337
7577
  * preserves the first durable evidence reason; contradictory physical truth
7338
7578
  * fails closed. */
7339
7579
  export declare function settleRetainedProcess(db: Database, input: {
@@ -7350,6 +7590,7 @@ export declare function settleRetainedProcess(db: Database, input: {
7350
7590
  }): Promise<{
7351
7591
  settled: boolean;
7352
7592
  process: SandboxRetainedProcess;
7593
+ backgroundCommandEvents: SessionEvent[];
7353
7594
  }>;
7354
7595
  /** Read the exact generation a verified capture must later fold. This is a
7355
7596
  * preflight only: persistWarmSnapshot/persistDrainSnapshot repeat the full
@@ -7586,6 +7827,7 @@ export type SandboxRotationBacklog = {
7586
7827
  turnBlocked: number;
7587
7828
  directBlocked: number;
7588
7829
  processBlocked: number;
7830
+ interactionBlocked: number;
7589
7831
  };
7590
7832
  export declare function readSandboxRotationBacklog(db: Database): Promise<SandboxRotationBacklog>;
7591
7833
  export type LegacyModalCheckpointSlot = {
@@ -8573,6 +8815,9 @@ export type CreateSessionGoalInput = {
8573
8815
  };
8574
8816
  export declare function createSessionGoal(db: Database, input: CreateSessionGoalInput): Promise<SessionGoal>;
8575
8817
  export declare function getSessionGoal(db: Database, workspaceId: string, sessionId: string): Promise<SessionGoal | null>;
8818
+ /** Bounded MCP management facts. No config, goal metadata, or event payload is materialized.
8819
+ * The caller must authorize session.read first, just as for getSession/queue reads. */
8820
+ export declare function getSessionMcpMonitoringSummary(db: Database, workspaceId: string, sessionId: string): Promise<import("@opengeni/contracts").SessionMcpMonitoringSource>;
8576
8821
  export type SessionGoalContinuationProjection = {
8577
8822
  state: "inactive" | "scheduled" | "running" | "blocked" | "invariant_broken";
8578
8823
  reason: "goal_inactive" | "wake_pending" | "continuation_pending" | "human_work_pending" | "goal_turn_running" | "human_turn_running" | "workstream_paused" | "approval_required" | "provider_backpressure" | "session_cancelled" | "system_work_pending" | "held_for_input" | "backoff_pending" | "missing_obligation";
@@ -8580,7 +8825,7 @@ export type SessionGoalContinuationProjection = {
8580
8825
  observedRevision: number;
8581
8826
  nextAttemptAt: string | null;
8582
8827
  lastError: string | null;
8583
- /** The agent's stated `goal_wait` reason while `held_for_input`; null otherwise. */
8828
+ /** The agent's stated `wait_for_input` reason while held; null otherwise. */
8584
8829
  holdReason: string | null;
8585
8830
  };
8586
8831
  /**
@@ -8700,34 +8945,19 @@ export declare function updateSessionGoalWithEvent(db: Database, workspaceId: st
8700
8945
  outcome: "applied" | "proposed";
8701
8946
  proposalId: string | null;
8702
8947
  }>;
8948
+ /** Maximum relative duration accepted by the session-level out-of-turn wait. */
8949
+ export declare const SESSION_INPUT_WAIT_MIN_SECONDS = 30;
8950
+ export declare const SESSION_INPUT_WAIT_MAX_SECONDS: number;
8951
+ export declare const SESSION_INPUT_WAIT_REASON_MAX_BYTES: number;
8703
8952
  /**
8704
- * Record execution progress without changing goal semantics or either goal
8705
- * revision. The attempt-fenced operation receipt makes a recovered tool call
8706
- * converge on the original event instead of manufacturing progress twice.
8707
- */
8708
- /**
8709
- * Column set that retires an agent-declared `goal_wait` hold. Spread into every
8710
- * goal head mutation (status transition, applied semantic revision, replace) so
8711
- * newer truth never sits behind an older wait.
8953
+ * Agent `wait_for_input`: persist one session-owned, self-only out-of-turn
8954
+ * wait. The exact declaring turn and absolute deadline are causal authority;
8955
+ * Temporal/NATS are replaceable wake hints. A replacement attempt replaying
8956
+ * the same target-scoped operation key receives the committed result.
8712
8957
  */
8713
- export declare const SESSION_GOAL_HOLD_MIN_SECONDS = 30;
8714
- export declare const SESSION_GOAL_HOLD_MAX_SECONDS: number;
8715
- /**
8716
- * Agent `goal_wait`: record that the active goal's next continuation should
8717
- * wait for child results, a message, a human prompt, or the deadline instead of
8718
- * materializing immediately after the declaring turn ends.
8719
- *
8720
- * The hold is bound to the exact caller turn. The materializer honors it only
8721
- * while that turn is still the latest finished turn and `now < until`; it
8722
- * never consumes the wake/observed revision ledger. The receipt, goal
8723
- * mutation, and `goal.held` timeline fact commit under the canonical goal
8724
- * event-write prefix (control FOR SHARE -> workspace FOR KEY SHARE -> session
8725
- * FOR NO KEY UPDATE), never a workspace FOR UPDATE. A replacement attempt
8726
- * replaying the same target-scoped operation key receives the stored result.
8727
- */
8728
- export declare function holdSessionGoalContinuationWithEvent(db: Database, workspaceId: string, sessionId: string, input: {
8958
+ export declare function waitForSessionInputWithEvent(db: Database, workspaceId: string, sessionId: string, input: {
8729
8959
  reason: string;
8730
- untilSeconds: number;
8960
+ timeoutSeconds: number;
8731
8961
  command: {
8732
8962
  accountId: string;
8733
8963
  actor: Extract<SessionCommandActor, {
@@ -8736,13 +8966,17 @@ export declare function holdSessionGoalContinuationWithEvent(db: Database, works
8736
8966
  operationKey: string;
8737
8967
  };
8738
8968
  }): Promise<{
8739
- goal: SessionGoal;
8740
8969
  events: SessionEvent[];
8741
8970
  operationId: string;
8742
8971
  replay: boolean;
8743
- holdTurnId: string;
8744
- untilAt: string;
8972
+ waitTurnId: string;
8973
+ deadlineAt: string;
8745
8974
  }>;
8975
+ /**
8976
+ * Record execution progress without changing goal semantics or either goal
8977
+ * revision. The attempt-fenced operation receipt makes a recovered tool call
8978
+ * converge on the original event instead of manufacturing progress twice.
8979
+ */
8746
8980
  export declare function recordSessionGoalProgressWithEvent(db: Database, workspaceId: string, sessionId: string, input: {
8747
8981
  progressNote: string;
8748
8982
  command: {
@@ -8903,11 +9137,6 @@ export type GoalIdleBackoffPolicy = {
8903
9137
  export type MaterializeGoalContinuationResult = {
8904
9138
  action: "none" | "queue";
8905
9139
  events: [];
8906
- } | {
8907
- action: "held";
8908
- events: [];
8909
- holdTurnId: string;
8910
- holdUntil: Date;
8911
9140
  } | {
8912
9141
  action: "deferred";
8913
9142
  events: [];
@@ -8944,6 +9173,7 @@ export declare function materializeGoalContinuation(db: Database, input: {
8944
9173
  model: string;
8945
9174
  reasoningEffort: ReasoningEffort;
8946
9175
  latencyMode: LatencyMode;
9176
+ turnExecutionPolicy?: TurnExecutionPolicyV1;
8947
9177
  tools: ToolRef[];
8948
9178
  sandboxBackend: SandboxBackend;
8949
9179
  };
@@ -9189,10 +9419,37 @@ export type SessionWorkPeek = {
9189
9419
  } | {
9190
9420
  kind: "cancellation-wait";
9191
9421
  attemptId: string;
9422
+ } | {
9423
+ kind: "input-wait";
9424
+ disposition: "held" | "timeout" | "superseded";
9425
+ waitTurnId: string;
9426
+ deadlineAt: string;
9192
9427
  } | {
9193
9428
  kind: "idle";
9194
9429
  };
9195
9430
  export declare function peekSessionWork(db: Database, workspaceId: string, sessionId: string): Promise<SessionWorkPeek>;
9431
+ export type SettleSessionInputWaitResult = {
9432
+ action: "held";
9433
+ events: [];
9434
+ workflowWakeRevision: number;
9435
+ } | {
9436
+ action: "timeout";
9437
+ events: SessionEvent[];
9438
+ workflowWakeRevision: number | null;
9439
+ } | {
9440
+ action: "superseded";
9441
+ events: SessionEvent[];
9442
+ } | {
9443
+ action: "stale";
9444
+ events: [];
9445
+ };
9446
+ export declare function settleSessionInputWait(db: Database, input: {
9447
+ accountId: string;
9448
+ workspaceId: string;
9449
+ sessionId: string;
9450
+ waitTurnId: string;
9451
+ disposition: "held" | "timeout" | "superseded";
9452
+ }): Promise<SettleSessionInputWaitResult>;
9196
9453
  export type FailSessionWorkBeforeAttemptClaimInput = {
9197
9454
  accountId: string;
9198
9455
  sessionId: string;
@@ -9267,6 +9524,13 @@ export type ApplySessionTurnSettlementInput = {
9267
9524
  turnStatus: SessionTurnStatus;
9268
9525
  sessionStatus: SessionStatus;
9269
9526
  activeTurnId: string | null;
9527
+ /**
9528
+ * Finish this terminal turn without arming the active goal's autonomous
9529
+ * continuation. The goal remains active so explicit later work can proceed,
9530
+ * but this exact settlement cannot synthesize another turn from unchanged
9531
+ * input after a bounded terminal condition.
9532
+ */
9533
+ suppressGoalContinuation?: boolean;
9270
9534
  events: AppendEventInput[];
9271
9535
  /**
9272
9536
  * A mid-turn requires_action freeze. Human-input rows and interaction
@@ -9349,7 +9613,8 @@ export type SettleCodexCredentialFailoverResult = {
9349
9613
  } | {
9350
9614
  action: "limit_exceeded";
9351
9615
  failoverCount: number;
9352
- events: [];
9616
+ maxFailovers: number;
9617
+ events: SessionEvent[];
9353
9618
  };
9354
9619
  export type SettleCodexCredentialLeaseLossResult = {
9355
9620
  action: "recovering";
@@ -9387,11 +9652,13 @@ export declare function settleCodexCredentialLeaseLoss(db: Database, input: {
9387
9652
  /**
9388
9653
  * Atomically settle a definitive Codex credential failover. Conversation
9389
9654
  * history/RunState is persisted by the caller first; this transaction then
9390
- * fences the exact activity lease, increments the bounded same-turn counter,
9391
- * appends both durable events, marks the same turn recoverable, updates the
9392
- * session, and releases the lease together. The exact holder remains provable
9393
- * if its row just expired or was reaped; a successor, redispatch, or closed
9394
- * inference gate makes the caller stale without a second settlement path.
9655
+ * fences the exact activity lease, consumes the quarantine transaction's
9656
+ * bounded same-turn receipt, appends durable recovery or terminal events,
9657
+ * updates the turn/session, and releases the lease together. Exhaustion also
9658
+ * suppresses autonomous goal continuation and enqueues a failed-child notice in
9659
+ * this transaction. The exact holder remains provable if its row just expired
9660
+ * or was reaped; a successor, redispatch, or closed inference gate makes the
9661
+ * caller stale without a second settlement path.
9395
9662
  */
9396
9663
  export declare function settleCodexCredentialFailover(db: Database, input: {
9397
9664
  accountId: string;
@@ -9399,11 +9666,12 @@ export declare function settleCodexCredentialFailover(db: Database, input: {
9399
9666
  sessionId: string;
9400
9667
  turnId: string;
9401
9668
  attemptId: string;
9402
- holderId: string;
9403
- generation: number;
9669
+ holderId?: string | null;
9670
+ generation?: number | null;
9404
9671
  expectedRedispatches: number;
9405
9672
  maxFailovers: number;
9406
9673
  recoveryPayload: Record<string, unknown>;
9674
+ failedPayload?: Record<string, unknown>;
9407
9675
  }): Promise<SettleCodexCredentialFailoverResult>;
9408
9676
  export type RequestSessionTurnRecoveryInput = {
9409
9677
  sessionId: string;
@@ -9654,10 +9922,13 @@ export type AddSessionSystemUpdateInput = {
9654
9922
  xaiProviderAccountAuthoritySnapshot?: XaiProviderAccountAuthoritySnapshotV1;
9655
9923
  scheduledTaskRunId?: string | null;
9656
9924
  } & SessionSystemUpdateInputVariant;
9657
- export type AddSessionSystemUpdateResult = {
9925
+ export type AddSessionSystemUpdateResult<RequireIdleSession extends boolean = boolean> = {
9658
9926
  added: false;
9659
9927
  reason: "session_cancelled";
9660
- } | {
9928
+ } | (RequireIdleSession extends true ? {
9929
+ added: false;
9930
+ reason: "session_not_idle";
9931
+ } : never) | {
9661
9932
  added: boolean;
9662
9933
  reason: "added" | "duplicate";
9663
9934
  update: SessionSystemUpdate;
@@ -9670,16 +9941,43 @@ export type AddSessionSystemUpdateResult = {
9670
9941
  export type PrepareSessionSystemUpdateSourceResult = {
9671
9942
  /** Private, bounded, content-free source authority appended before insert. */
9672
9943
  lineage?: Record<string, unknown>;
9944
+ /** Source-owned events appended before the pending-update event. */
9945
+ events?: SessionEvent[];
9673
9946
  };
9674
- export declare function addSessionSystemUpdate(db: Database, input: AddSessionSystemUpdateInput): Promise<AddSessionSystemUpdateResult>;
9947
+ export declare function addSessionSystemUpdate(db: Database, input: AddSessionSystemUpdateInput): Promise<AddSessionSystemUpdateResult<false>>;
9675
9948
  /**
9676
9949
  * Persist one internal update without fabricating a user prompt or queue row.
9677
9950
  * Dedupe and any producer/outbox mutation commit in the same transaction.
9678
9951
  */
9679
- export declare function addSessionSystemUpdateWithSourceMutation(db: Database, input: AddSessionSystemUpdateInput, mutateSource: (tx: Database, wakeEventId: string | null, updateId: string | null) => Promise<void>, options?: {
9952
+ export declare function addSessionSystemUpdateWithSourceMutation<RequireIdleSession extends boolean = false>(db: Database, input: AddSessionSystemUpdateInput, mutateSource: (tx: Database, wakeEventId: string | null, updateId: string | null, rejectionReason: "session_cancelled" | "session_not_idle" | null) => Promise<void>, options?: {
9953
+ /** Admit only when the already-locked session is at its idle boundary. */
9954
+ requireIdleSession?: RequireIdleSession;
9680
9955
  /** Runs under the locked session/source transaction before any update/event insert. */
9681
9956
  prepareSource?: (tx: Database, sessionId: string) => Promise<PrepareSessionSystemUpdateSourceResult | void>;
9682
- }): Promise<AddSessionSystemUpdateResult>;
9957
+ }): Promise<AddSessionSystemUpdateResult<RequireIdleSession>>;
9958
+ export type SessionBackgroundCommandTerminalSettlement = {
9959
+ command: SessionBackgroundCommand;
9960
+ events: SessionEvent[];
9961
+ };
9962
+ export declare function settleConnectedMachineSessionBackgroundCommand(db: Database, input: {
9963
+ accountId: string;
9964
+ workspaceId: string;
9965
+ sessionId: string;
9966
+ commandId: string;
9967
+ controlWorkspaceId: string;
9968
+ enrollmentId: string;
9969
+ connectionInstanceId: string;
9970
+ opId: string;
9971
+ outcome: "exited" | "lost";
9972
+ exitCode: number | null;
9973
+ reason: string;
9974
+ }): Promise<SessionBackgroundCommandTerminalSettlement | null>;
9975
+ export declare function settleClaimedConnectedMachineBackgroundCommand(db: Database, input: {
9976
+ claim: ConnectedMachineBackgroundCommandClaim;
9977
+ }): Promise<{
9978
+ settled: boolean;
9979
+ events: SessionEvent[];
9980
+ }>;
9683
9981
  /**
9684
9982
  * One durable machine input by id, under the ordinary workspace RLS scope.
9685
9983
  * The row outlives delivery, so a late bounded projection of an already
@@ -9879,10 +10177,13 @@ export { adoptPackComponentReferences, finalizePackComponentOwnership, listPackI
9879
10177
  export { deferPackInstallationOperation, finalizePackInstallationOperation, finalizePackUninstallOperation, PackManifestChangedError, PackOperationClaimLostError, PackOperationInProgressError, PackInstallationVersionConflictError, PackInstallationVersionRequiredError, PackOperationIdempotencyError, preparePackInstallationOperation, preparePackUninstallOperation, touchPackInstallationOperation, type PreparedPackInstallation, } from "./pack-installations.js";
9880
10178
  export { checkpointPluginPackageOperation, deferPluginPackageOperation, finalizePluginPackageInstall, getInstalledPluginPackage, getPluginPackageUninstallPreview, installPluginMcpReference, listInstalledPluginPackages, PluginInstallationVersionConflictError, PluginInstallationVersionRequiredError, PluginOperationIdempotencyError, preparePluginPackageInstall, uninstallPluginPackage, type InstalledPluginPackage, type InstalledPluginPackageSummary, type PluginBomComponent, type PreparedPluginPackage, } from "./plugin-packages.js";
9881
10179
  export * from "./workspace-artifacts.js";
10180
+ export * from "./mcp-oauth.js";
10181
+ export * from "./tool-gateway-approvals.js";
9882
10182
  export * from "./transcription-recordings.js";
9883
10183
  export * from "./editable-artifacts.js";
9884
10184
  export * from "./editable-artifact-materialization.js";
9885
10185
  export * from "./attempt-tool-catalogs.js";
10186
+ export * from "./model-context-snapshots.js";
9886
10187
  export * from "./codemode-operations.js";
9887
10188
  export * from "./browser-sessions.js";
9888
10189
  export * from "./computer-sessions.js";
@@ -9899,3 +10200,4 @@ export * from "./organization-recovery.js";
9899
10200
  export * from "./session-tenancy.js";
9900
10201
  export * from "./governed-learning-activation.js";
9901
10202
  export * from "./automations.js";
10203
+ export * from "./organization-model-providers.js";