@opengeni/db 5.0.1 → 6.0.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 (212) hide show
  1. package/dist/automations.d.ts +0 -2
  2. package/dist/canonical-human-identities.d.ts +4 -0
  3. package/dist/canonical-human-identities.js +3 -3
  4. package/dist/capability-components.d.ts +5 -13
  5. package/dist/capability-integrations.d.ts +23 -8
  6. package/dist/capability-reconciliation.d.ts +5 -0
  7. package/dist/capability-reconciliation.js +21 -0
  8. package/dist/capability-reconciliation.js.map +1 -0
  9. package/dist/{chunk-6T2GGYWE.js → chunk-4UJCXBR2.js} +4 -5800
  10. package/dist/chunk-4UJCXBR2.js.map +1 -0
  11. package/dist/{chunk-MWMXWHJD.js → chunk-7JCDSMX2.js} +2 -2
  12. package/dist/chunk-AJA2ZIUW.js +219 -0
  13. package/dist/chunk-AJA2ZIUW.js.map +1 -0
  14. package/dist/chunk-CDAT6EKW.js +247 -0
  15. package/dist/chunk-CDAT6EKW.js.map +1 -0
  16. package/dist/{chunk-DPONPYJD.js → chunk-CJI6G254.js} +70 -18
  17. package/dist/chunk-CJI6G254.js.map +1 -0
  18. package/dist/chunk-G32NVMRJ.js +276 -0
  19. package/dist/chunk-G32NVMRJ.js.map +1 -0
  20. package/dist/chunk-GABXCG3N.js +5811 -0
  21. package/dist/chunk-GABXCG3N.js.map +1 -0
  22. package/dist/{chunk-ERKVSPDX.js → chunk-LVY33EWL.js} +3 -3
  23. package/dist/{chunk-45CP2YKY.js → chunk-MAMBI2HR.js} +9 -3
  24. package/dist/{chunk-45CP2YKY.js.map → chunk-MAMBI2HR.js.map} +1 -1
  25. package/dist/{chunk-F73UKJY6.js → chunk-MN5PZMEK.js} +91 -108
  26. package/dist/chunk-MN5PZMEK.js.map +1 -0
  27. package/dist/chunk-PJI4MUZ7.js +131 -0
  28. package/dist/chunk-PJI4MUZ7.js.map +1 -0
  29. package/dist/{chunk-T6BWIGWJ.js → chunk-RIYHP2WU.js} +2 -2
  30. package/dist/{chunk-7HMK3B45.js → chunk-RL2MUXM3.js} +16 -7
  31. package/dist/chunk-RL2MUXM3.js.map +1 -0
  32. package/dist/{chunk-HQDVI2DB.js → chunk-SYKHLPTK.js} +4 -3
  33. package/dist/{chunk-HQDVI2DB.js.map → chunk-SYKHLPTK.js.map} +1 -1
  34. package/dist/{chunk-T6YLHJLS.js → chunk-XIXVVBW2.js} +198 -51
  35. package/dist/chunk-XIXVVBW2.js.map +1 -0
  36. package/dist/chunk-ZPJ6V2VG.js +156 -0
  37. package/dist/chunk-ZPJ6V2VG.js.map +1 -0
  38. package/dist/codex-capacity-recovery.d.ts +12 -0
  39. package/dist/codex-failure-eligibility.d.ts +9 -0
  40. package/dist/company-profile-schema.d.ts +4 -2
  41. package/dist/connect-attempts.d.ts +15 -0
  42. package/dist/connect-attempts.js +25 -0
  43. package/dist/connect-attempts.js.map +1 -0
  44. package/dist/connection-authority.d.ts +7 -63
  45. package/dist/connection-refresh-lock.d.ts +4 -0
  46. package/dist/connection-token-resolver.d.ts +8 -43
  47. package/dist/database-timing.d.ts +10 -0
  48. package/dist/database.d.ts +4 -0
  49. package/dist/editable-artifact-durable-export.js +2 -2
  50. package/dist/editable-artifacts.d.ts +9 -0
  51. package/dist/editable-artifacts.js +7 -5
  52. package/dist/index.d.ts +447 -78
  53. package/dist/index.js +12705 -12872
  54. package/dist/index.js.map +1 -1
  55. package/dist/insights-usage-bundle.d.ts +3 -0
  56. package/dist/integration-bindings.d.ts +1 -1
  57. package/dist/integration-facets.d.ts +18 -1
  58. package/dist/knowledge-entries-schema.d.ts +2 -0
  59. package/dist/knowledge-entries.d.ts +1 -0
  60. package/dist/knowledge-indexing.d.ts +1 -0
  61. package/dist/live-session-attempt.d.ts +35 -137
  62. package/dist/managed-auth-session-sets.js +3 -3
  63. package/dist/mcp-account-bindings.d.ts +4 -0
  64. package/dist/mcp-oauth.d.ts +11 -0
  65. package/dist/mcp-operations.js +2 -2
  66. package/dist/migrate.js +1 -1
  67. package/dist/organization-integration-policy.d.ts +51 -0
  68. package/dist/organization-integration-policy.js +18 -0
  69. package/dist/organization-integration-policy.js.map +1 -0
  70. package/dist/organization-usage.d.ts +20 -0
  71. package/dist/plugin-packages.d.ts +9 -12
  72. package/dist/pr-review.d.ts +0 -11
  73. package/dist/preference-registry-schema.d.ts +17 -0
  74. package/dist/provision-roles.js +1 -1
  75. package/dist/retained-provider-commands.d.ts +124 -6
  76. package/dist/retained-provider-commands.js +29 -97
  77. package/dist/retained-provider-commands.js.map +1 -1
  78. package/dist/retired-session-create-metadata.d.ts +4 -0
  79. package/dist/runtime-posture.d.ts +7 -5
  80. package/dist/schema.d.ts +876 -656
  81. package/dist/schema.js +5 -7
  82. package/dist/session-admission-block.d.ts +32 -0
  83. package/dist/session-attempt-writers.d.ts +4 -0
  84. package/dist/session-background-commands.js +5 -4
  85. package/dist/session-command-output.js +8 -126
  86. package/dist/session-command-output.js.map +1 -1
  87. package/dist/session-control.d.ts +5 -1
  88. package/dist/session-event-slices.d.ts +10 -0
  89. package/dist/session-event-slices.js +8 -222
  90. package/dist/session-event-slices.js.map +1 -1
  91. package/dist/session-file-attachments.d.ts +28 -0
  92. package/dist/session-goal-reports.d.ts +43 -0
  93. package/dist/session-mcp-approval.d.ts +4 -0
  94. package/dist/session-mcp-credential-rotation.js +5 -4
  95. package/dist/session-mcp-credential-rotation.js.map +1 -1
  96. package/dist/session-message-search.d.ts +22 -0
  97. package/dist/session-queue-commands.d.ts +2 -6
  98. package/dist/session-retry.d.ts +36 -0
  99. package/dist/session-tenancy.js +3 -3
  100. package/dist/skill-source-release-impact.d.ts +18 -0
  101. package/dist/skill-source-release.d.ts +9 -0
  102. package/dist/skills.d.ts +7 -1
  103. package/dist/user-resource-authority.d.ts +0 -8
  104. package/dist/video-generation.js +3 -3
  105. package/dist/workspace-tool-defaults.js +5 -4
  106. package/dist/workspace-tool-defaults.js.map +1 -1
  107. package/drizzle/0468_knowledge_relationship_projection.sql +30 -0
  108. package/drizzle/0469_knowledge_source_discovery.sql +85 -0
  109. package/drizzle/0470_organization_integration_policy.sql +151 -0
  110. package/drizzle/0471_usage_events_account_recent_index.sql +4 -0
  111. package/drizzle/0472_usage_events_workspace_recent_index.sql +4 -0
  112. package/drizzle/0473_organization_usage_analytical_capability.sql +237 -0
  113. package/drizzle/0474_goal_report_requirements.sql +156 -0
  114. package/drizzle/0475_session_event_history_statistics.sql +15 -0
  115. package/drizzle/0476_session_event_history_policy_planning.sql +29 -0
  116. package/drizzle/0477_managed_sign_in_methods.sql +303 -0
  117. package/drizzle/0478_sender_owned_connections.sql +2772 -0
  118. package/drizzle/0479_connection_create_idempotency.sql +16 -0
  119. package/drizzle/0480_private_session_organization_key_administration.sql +154 -0
  120. package/drizzle/0481_personal_connection_visibility_cleanup.sql +45 -0
  121. package/drizzle/0482_remove_packs.sql +417 -0
  122. package/drizzle/0483_preclaim_admission_block.sql +85 -0
  123. package/drizzle/0484_insights_usage_projection.sql +211 -0
  124. package/drizzle/0485_inherited_mcp_approval_policies.sql +6 -0
  125. package/drizzle/0486_reasoning_configuration_message_forks.sql +35 -0
  126. package/drizzle/0487_skill_catalog_message_forks.sql +26 -0
  127. package/drizzle/0488_permanent_skill_removal.sql +207 -0
  128. package/drizzle/0489_modal_command_byte_offsets.sql +17 -0
  129. package/drizzle/0490_periodic_capture_attempt_cadence.sql +6 -0
  130. package/drizzle/0491_warm_capture_holder_reclamation.sql +57 -0
  131. package/drizzle/0492_codex_accepted_source_authority.sql +249 -0
  132. package/drizzle/0493_stopping_command_error_containment.sql +58 -0
  133. package/drizzle/0494_mcp_account_bindings.sql +334 -0
  134. package/drizzle/0495_consented_sandbox_recovery.sql +220 -0
  135. package/drizzle/0496_supervised_command_settlement.sql +386 -0
  136. package/drizzle/0497_modal_inventory_owner_read_capability.sql +112 -0
  137. package/drizzle/0498_enrollment_membership_fence.sql +87 -0
  138. package/drizzle/0499_session_attachment_access.sql +224 -0
  139. package/drizzle/0500_session_execution_epoch.sql +37 -0
  140. package/drizzle/0501_session_sharing_execution.sql +591 -0
  141. package/drizzle/0502_active_message_boundary_forks.sql +30 -0
  142. package/package.json +17 -5
  143. package/src/automations.ts +17 -73
  144. package/src/canonical-human-identities.ts +17 -5
  145. package/src/capability-components.ts +7 -24
  146. package/src/capability-integrations.ts +301 -21
  147. package/src/capability-reconciliation.ts +19 -0
  148. package/src/codex-capacity-recovery.ts +47 -0
  149. package/src/codex-failure-eligibility.ts +93 -0
  150. package/src/connect-attempts.ts +49 -18
  151. package/src/connection-authority.ts +12 -158
  152. package/src/connection-refresh-lock.ts +22 -0
  153. package/src/connection-token-resolver.ts +58 -530
  154. package/src/database-timing.ts +43 -0
  155. package/src/database.ts +61 -26
  156. package/src/editable-artifacts.ts +1 -1
  157. package/src/index.ts +3578 -1273
  158. package/src/insights-model-bundle.ts +19 -7
  159. package/src/insights-usage-bundle.ts +16 -19
  160. package/src/integration-bindings.ts +2 -7
  161. package/src/integration-facets.ts +73 -6
  162. package/src/knowledge-entries.ts +8 -1
  163. package/src/live-session-attempt.ts +0 -22
  164. package/src/mcp-account-bindings.ts +12 -0
  165. package/src/mcp-oauth.ts +26 -0
  166. package/src/organization-integration-policy.ts +235 -0
  167. package/src/organization-usage.ts +83 -0
  168. package/src/plugin-packages.ts +226 -42
  169. package/src/pr-review.ts +7 -69
  170. package/src/preference-registry-schema.ts +1 -0
  171. package/src/provision-roles.ts +50 -37
  172. package/src/retained-provider-commands.ts +286 -9
  173. package/src/retired-session-create-metadata.ts +16 -0
  174. package/src/runtime-posture.ts +217 -13
  175. package/src/schema.ts +104 -120
  176. package/src/session-admission-block.ts +29 -0
  177. package/src/session-attempt-writers.ts +48 -0
  178. package/src/session-control.ts +21 -5
  179. package/src/session-event-slices.ts +76 -26
  180. package/src/session-file-attachments.ts +66 -0
  181. package/src/session-goal-reports.ts +255 -0
  182. package/src/session-mcp-approval.ts +30 -0
  183. package/src/session-message-search.ts +348 -0
  184. package/src/session-queue-commands.ts +60 -36
  185. package/src/session-retry.ts +319 -0
  186. package/src/skill-config-migration.ts +11 -2
  187. package/src/skill-source-release-impact.ts +33 -0
  188. package/src/skill-source-release.ts +67 -26
  189. package/src/skills.ts +44 -6
  190. package/src/user-resource-authority.ts +0 -56
  191. package/dist/chunk-6T2GGYWE.js.map +0 -1
  192. package/dist/chunk-7HMK3B45.js.map +0 -1
  193. package/dist/chunk-DPONPYJD.js.map +0 -1
  194. package/dist/chunk-F73UKJY6.js.map +0 -1
  195. package/dist/chunk-T6YLHJLS.js.map +0 -1
  196. package/dist/host-mcp-binding-match.d.ts +0 -5
  197. package/dist/host-mcp-bindings.d.ts +0 -79
  198. package/dist/host-mcp-resolvers.d.ts +0 -47
  199. package/dist/host-mcp-task-authority.d.ts +0 -43
  200. package/dist/host-selection-identity.d.ts +0 -6
  201. package/dist/pack-components.d.ts +0 -83
  202. package/dist/pack-installations.d.ts +0 -86
  203. package/src/host-mcp-binding-match.ts +0 -34
  204. package/src/host-mcp-bindings.ts +0 -777
  205. package/src/host-mcp-resolvers.ts +0 -266
  206. package/src/host-mcp-task-authority.ts +0 -384
  207. package/src/host-selection-identity.ts +0 -29
  208. package/src/pack-components.ts +0 -980
  209. package/src/pack-installations.ts +0 -950
  210. /package/dist/{chunk-MWMXWHJD.js.map → chunk-7JCDSMX2.js.map} +0 -0
  211. /package/dist/{chunk-ERKVSPDX.js.map → chunk-LVY33EWL.js.map} +0 -0
  212. /package/dist/{chunk-T6BWIGWJ.js.map → chunk-RIYHP2WU.js.map} +0 -0
package/dist/index.d.ts CHANGED
@@ -1,3 +1,29 @@
1
+ export { acceptSessionFileAttachments, readSessionFileAttachments, type SessionAttachmentReadAccess, } from "./session-file-attachments.js";
2
+ import { SandboxRecoveryResponse, type SandboxRecoveryProjection, type SandboxRecoveryRequest, ModalRouterProviderCommand } from "@opengeni/contracts";
3
+ import { type ConfigurationEffort } from "@opengeni/codex";
4
+ export { getSessionAttemptMcpApprovalPolicies } from "./session-mcp-approval.js";
5
+ export { SessionRetryConflictError, getSessionRetryReceiptInTransaction } from "./session-retry.js";
6
+ import { retainedProviderCommandPersistence as retainedProviderCommandState } from "./retained-provider-commands.js";
7
+ export declare const retryFailedSessionInTransaction: (db: SessionActivityDatabase, input: Parameters<(db: SessionActivityDatabase, input: {
8
+ accountId: string;
9
+ workspaceId: string;
10
+ sessionId: string;
11
+ subjectId: string;
12
+ request: import("@opengeni/contracts").SessionRetryRequest;
13
+ executionPolicy: TurnExecutionPolicyV1;
14
+ }, sessionEffectiveSandboxRecoveryBlocked: (db: Database, session: typeof schema.sessions.$inferSelect) => Promise<boolean>) => Promise<import("@opengeni/contracts").SessionRetryResponse & {
15
+ eventIds: string[];
16
+ }>>[1]) => Promise<{
17
+ outcome: "accepted" | "replayed";
18
+ turnId: string;
19
+ failureEventId: string;
20
+ } & {
21
+ eventIds: string[];
22
+ }>;
23
+ import { type SessionAdmissionFence, StoredSessionAdmissionBlock } from "./session-admission-block.js";
24
+ export type { SessionAdmissionFence, StoredSessionAdmissionBlock } from "./session-admission-block.js";
25
+ import { SessionMessageSearchRequest, type SessionMessageSearchResponse } from "@opengeni/contracts";
26
+ export { SessionMessageSearchCursorError } from "./session-message-search.js";
1
27
  export * from "./artifact-catalog.js";
2
28
  export { grantWorkspaceAccess, listWorkspaceMembers } from "./workspace-membership-access.js";
3
29
  import { codexSelectionDiagnostics } from "./codex-selection-diagnostics.js";
@@ -5,20 +31,19 @@ export { codexSelectionDiagnostics } from "./codex-selection-diagnostics.js";
5
31
  import { type ModelConnectionAccess, type ModelConnectionTarget } from "./model-connection-access.js";
6
32
  export { assertModelConnectionAllowsTurn, modelAllowedByConnections, type ConnectionModelRestrictions, } from "./workspace-model-connection-access.js";
7
33
  export * from "./model-connection-access.js";
34
+ import { type ReportArtifactActor } from "./session-goal-reports.js";
35
+ export { recordNativeDocumentInspection } from "./session-goal-reports.js";
36
+ import { type SessionGoalReportRequirement, type SessionGoalReportDelivery } from "@opengeni/contracts";
8
37
  import { type BundledSkillId } from "@opengeni/contracts";
9
38
  import { type SkillSourceReleaseReceipt } from "./skill-source-release.js";
10
39
  import type { SkillActor, SkillWriteReceipt } from "@opengeni/contracts";
11
- import { type HostMcpCreateSelection } from "./host-selection-identity.js";
12
40
  export * from "./connect-attempts.js";
13
41
  export * from "./external-identities.js";
14
42
  export * from "./external-identity-links.js";
15
43
  export * from "./connection-setup-authority.js";
16
44
  export * from "./external-link-work.js";
17
- export * from "./host-mcp-bindings.js";
18
- export * from "./host-mcp-resolvers.js";
19
- export * from "./host-mcp-task-authority.js";
20
45
  import { type ChildLifecycleSystemUpdateKind, type ChildRequiresActionRespondedByKind, SessionGoalSnapshot } from "@opengeni/contracts";
21
- 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, ScheduledTaskAgentConfig, ScheduledTaskOverlapPolicy, ScheduledTaskRun, ScheduledTaskRunAcceptedExecution as ScheduledTaskRunAcceptedExecutionType, ScheduledTaskRunMode, ScheduledTaskRunStatus, ScheduledTaskScheduleSpec, ScheduledTaskStatus, ScheduledTaskTriggerType, SlackInstallationBinding, Session, SessionAgentAccess, SessionAgentAccessViewer, SessionAuthorizationListScope, SessionScopeSubjectId, SessionMemoryScope, 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, WorkspaceMember, WorkspaceControlEvent, VariableSet, VariableSetSecret, VariableSetVariableMetadata, WorkspaceMemoryPromptMode, WorkspaceRegisteredPack, Channel, Rig, RigProviderImage, RigProviderImages, RigVersion, RigVerificationHealth, RigChange, RigChangeKind, RigChangeStatus, RigCheck, NativeSnapshotDescriptor, TarWorkspaceArchiveDescriptor, WorkspaceArchiveDescriptor, ModalCheckpointProviderBinding, SandboxProviderContinuityRecovery, WorkClaimSubjectFilter, WorkDiscoveryProjection } from "@opengeni/contracts";
46
+ import type { AccessContext, AccessGrant, AccessPrincipalKind, ApiKey, AttemptToolResult, BillingBalance, CapabilityCatalogItem, CapabilityInstallation, CapabilitySource, ConnectionKind, ConnectionMetadata, ConnectionStatus, DocumentAuthorityKind, McpServerConnectionRef, FileAsset, FileUploadStatus, FirstPartyMcpToolName, HumanInputQuestion, HumanInputResponse, KnowledgeMemory, KnowledgeMemoryKind, KnowledgeMemoryStatus, KnowledgeSourceRef, GitHubInstallationAuthorityKind, GitHubRepositoryScope, HostEventExportBatch, HostUsageExportBatch, ManagedAccount, ManagedOrganizationMembershipProjection, WorkspaceMemberCandidate, McpPersonalConnectionDelegation, McpConnectionAccountBinding, ModelContextContributionSummary, Permission, PersonalResourceAttachmentIntent, ResourceRef, SandboxBackend, SandboxOs, ScheduledTask, ScheduledTaskAction, ScheduledTaskActionKind, ScheduledTaskAgentConfig, ScheduledTaskOverlapPolicy, ScheduledTaskRun, ScheduledTaskRunAcceptedExecution as ScheduledTaskRunAcceptedExecutionType, ScheduledTaskRunMode, ScheduledTaskRunStatus, ScheduledTaskScheduleSpec, ScheduledTaskStatus, ScheduledTaskTriggerType, SlackInstallationBinding, Session, SessionAgentAccess, SessionAgentAccessViewer, SessionAuthorizationListScope, SessionScopeSubjectId, SessionMemoryScope, SessionListResponse, SessionEvent, SessionEventPayloadMode, SessionEventReadDirection, SessionEventSemanticClass, SessionEventType, SessionGoal, SessionGoalChangeKind, SessionGoalCreatedBy, SessionGoalMutationPolicy, SessionGoalRevision, SessionGoalStatus, SessionHumanInputRequest, LineageNode, SessionMcpApprovalPolicy, SessionMcpApprovalPolicyTarget, SessionBackgroundCommand, SessionSkill, SessionMcpServerMetadata, SessionStatus, SessionToolPolicy, SessionTurn, SessionQueueSnapshot, SessionSystemUpdate, SessionSystemUpdateKind, SystemUpdateClassification, SessionTurnSource, SessionTurnStatus, TurnInitiator, TurnInitiatorContext, SocialConnection, SocialConnectionStatus, SocialPost, SocialProvider, ToolRef, ReasoningEffort, UsageEvent, Workspace, WorkspaceMember, WorkspaceControlEvent, VariableSet, VariableSetSecret, VariableSetVariableMetadata, WorkspaceMemoryPromptMode, Channel, Rig, RigProviderImage, RigProviderImages, RigVersion, RigVerificationHealth, RigChange, RigChangeKind, RigChangeStatus, RigCheck, NativeSnapshotDescriptor, TarWorkspaceArchiveDescriptor, WorkspaceArchiveDescriptor, ModalCheckpointProviderBinding, SandboxProviderContinuityRecovery, WorkClaimSubjectFilter, WorkDiscoveryProjection } from "@opengeni/contracts";
22
47
  import { type WorkspaceArchiveObjectRef, RequestHumanInteractionToolInput, XaiProviderAccountAuthoritySnapshotV1, type TimelineAnnotation } from "@opengeni/contracts";
23
48
  import { type LatencyMode, SessionSystemUpdatePayload, TurnExecutionPolicyV1, CodexCredentialPolicySnapshotV1 } from "@opengeni/contracts";
24
49
  import { type Settings } from "@opengeni/config";
@@ -97,7 +122,8 @@ export * from "./model-catalog.js";
97
122
  import { type Database, type SessionActivityDatabase } from "./database.js";
98
123
  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";
99
124
  export { withSessionRlsActorContext } from "./database.js";
100
- export { normalizedHostCredentialHeaders } from "./connection-token-resolver.js";
125
+ export { withDatabaseTimingObserver, type DatabaseTimingObservation } from "./database-timing.js";
126
+ export { normalizedCredentialHeaders } from "./connection-token-resolver.js";
101
127
  import { buildCodexTokenResolver as buildCodexTokenResolverCore, fetchCodexRateLimitResetCreditsForAccount as fetchCodexRateLimitResetCreditsForAccountCore, fetchCodexUsageForAccount as fetchCodexUsageForAccountCore, type CodexAccountUsageSnapshot, type CodexAuthDeps, type CodexCredentialCooldownKind, type CodexCredentialForRun } from "./codex-token-resolver.js";
102
128
  import { buildConnectionTokenResolver as buildConnectionTokenResolverCore, type ConnectionBrokerDeps, type ConnectionCredentialForBroker, type ConnectionTokenResolverOptions } from "./connection-token-resolver.js";
103
129
  /** Raised when a durable session tool-policy write lost its version fence. */
@@ -779,6 +805,7 @@ export declare function recordModelCallFact(db: Database, input: {
779
805
  totalTokens?: number | null;
780
806
  occurredAt?: Date;
781
807
  }): Promise<ModelCallFact>;
808
+ export { getOrganizationUsageSummary, getOrganizationUsageWorkspacePage, organizationUsageWindow, } from "./organization-usage.js";
782
809
  export declare function listUsageEvents(db: Database, input: {
783
810
  accountId: string;
784
811
  workspaceId?: string;
@@ -894,7 +921,6 @@ export type CreateScheduledTaskInput = {
894
921
  createdBy?: TurnInitiator;
895
922
  createdByContext?: TurnInitiatorContext;
896
923
  createdByActor?: AgentSessionCreationActor | null;
897
- personalConnectionDelegations?: McpPersonalConnectionDelegation[];
898
924
  xaiProviderAccountAuthoritySnapshot?: XaiProviderAccountAuthoritySnapshotV1;
899
925
  /** Frozen creator boundary; omit (or pass null fields) for human/API creates. */
900
926
  creatorPolicy?: ScheduledTaskCreatorPolicy | null;
@@ -904,7 +930,6 @@ export type CreateScheduledTaskInput = {
904
930
  metadata: Record<string, unknown>;
905
931
  /** Trusted database-only admission seam. Throwing rolls the task creation back. */
906
932
  beforeCreateCommit?: (tx: Database) => Promise<void>;
907
- captureHostAuthority?: (tx: Database, task: ScheduledTask) => Promise<void>;
908
933
  captureLinkAuthority?: (tx: Database, task: ScheduledTask) => Promise<void>;
909
934
  };
910
935
  export type UpdateScheduledTaskInput = Partial<{
@@ -915,39 +940,20 @@ export type UpdateScheduledTaskInput = Partial<{
915
940
  overlapPolicy: ScheduledTaskOverlapPolicy;
916
941
  action: ScheduledTaskAction;
917
942
  agentConfig: ScheduledTaskAgentConfig;
918
- personalConnectionDelegations: McpPersonalConnectionDelegation[];
919
943
  reusableSessionId: string | null;
920
944
  targetSessionId: string | null;
921
945
  variableSetId: string | null;
922
946
  rigId: string | null;
923
947
  metadata: Record<string, unknown>;
924
948
  refreshPersonalResourceAuthority: boolean;
925
- cloneConnectionAuthorityFromRevision: number;
926
949
  clonePersonalResourceAuthorityFromRevision: number;
927
950
  authorityUpdatedBy: TurnInitiator;
928
951
  authorityUpdatedByContext: TurnInitiatorContext;
929
952
  authorityUpdatedByActor: AgentSessionCreationActor | null;
930
953
  /** Trusted database-only admission seam. Throwing rolls the task update back. */
931
954
  beforeUpdateCommit: (tx: Database) => Promise<void>;
932
- captureHostAuthority: (tx: Database, task: ScheduledTask) => Promise<void>;
933
955
  captureLinkAuthority: (tx: Database, task: ScheduledTask) => Promise<void>;
934
956
  }>;
935
- export type CreatePackInstallationInput = {
936
- accountId: string;
937
- workspaceId: string;
938
- packId: string;
939
- status?: PackInstallationStatus;
940
- manifestSnapshot?: CapabilityPack | null;
941
- manifestDigest?: string | null;
942
- selectedRigId?: string | null;
943
- installedBySubjectId?: string | null;
944
- metadata?: Record<string, unknown>;
945
- };
946
- export type RegisterWorkspacePackInput = {
947
- accountId: string;
948
- workspaceId: string;
949
- pack: CapabilityPack;
950
- };
951
957
  export type CreateKnowledgeMemoryInput = {
952
958
  accountId: string;
953
959
  workspaceId: string;
@@ -1413,6 +1419,8 @@ export type EnableCapabilityInstallationInput = {
1413
1419
  workspaceId: string;
1414
1420
  capabilityId: string;
1415
1421
  kind: "mcp";
1422
+ /** Automatic setup must preserve every existing installation, including disabled ones. */
1423
+ onlyIfUninstalled?: boolean;
1416
1424
  config?: Record<string, unknown>;
1417
1425
  metadata?: Record<string, unknown>;
1418
1426
  };
@@ -1427,7 +1435,7 @@ export type InstallPortableSkillInput = {
1427
1435
  skillRequestIdentity?: Record<string, unknown>;
1428
1436
  capabilityId: string;
1429
1437
  pluginKey: string;
1430
- source: "library" | "github" | "skills_sh" | "pack";
1438
+ source: "library" | "github" | "skills_sh";
1431
1439
  sourceUrl: string;
1432
1440
  repositoryUrl: string;
1433
1441
  version?: string;
@@ -1462,7 +1470,7 @@ export type InstalledPortableSkill = {
1462
1470
  pluginInstallationId: string;
1463
1471
  facetInstallationId: string;
1464
1472
  installationVersion: number;
1465
- source: "library" | "github" | "skills_sh" | "pack";
1473
+ source: "library" | "github" | "skills_sh";
1466
1474
  version: string;
1467
1475
  sourceUrl: string;
1468
1476
  sourceCommit: string;
@@ -1471,7 +1479,7 @@ export type InstalledPortableSkill = {
1471
1479
  };
1472
1480
  export type PortableSkillRuntime = {
1473
1481
  capabilityId: string;
1474
- source: "library" | "github" | "skills_sh" | "pack";
1482
+ source: "library" | "github" | "skills_sh";
1475
1483
  version: string;
1476
1484
  name: string;
1477
1485
  description: string;
@@ -1494,7 +1502,7 @@ export type InstalledSkillSummary = {
1494
1502
  category: string;
1495
1503
  tags: string[];
1496
1504
  provenance: string;
1497
- source: "library" | "github" | "skills_sh" | "pack";
1505
+ source: "library" | "github" | "skills_sh";
1498
1506
  version: string;
1499
1507
  sourceUrl: string;
1500
1508
  repositoryUrl: string;
@@ -1509,7 +1517,7 @@ export type InstalledSkillSummary = {
1509
1517
  owners: PortableSkillOwner[];
1510
1518
  };
1511
1519
  export type PortableSkillOwner = {
1512
- kind: "direct" | "plugin" | "pack" | "migration";
1520
+ kind: "direct" | "plugin" | "migration";
1513
1521
  id: string;
1514
1522
  removable: boolean;
1515
1523
  };
@@ -1549,6 +1557,7 @@ export type EnabledMcpCapabilityServer = {
1549
1557
  timeoutMs?: number;
1550
1558
  cacheToolsList?: boolean;
1551
1559
  requireApproval?: SessionMcpApprovalPolicy;
1560
+ approvalFloor?: SessionMcpApprovalPolicy;
1552
1561
  /**
1553
1562
  * Credential request headers stored encrypted at enable time
1554
1563
  * (AES-256-GCM under the workspace-variableSets key). Decrypted only at
@@ -1578,7 +1587,7 @@ export type UpdateSessionMcpServerCredentialsResult = {
1578
1587
  missingIds: string[];
1579
1588
  };
1580
1589
  export type UpdateSessionMcpApprovalPolicyResult = {
1581
- server: SessionMcpServerMetadata | null;
1590
+ server: SessionMcpApprovalPolicyTarget | null;
1582
1591
  changed: boolean;
1583
1592
  };
1584
1593
  export type SessionMcpServerForRun = SessionMcpServerMetadata & {
@@ -1610,6 +1619,7 @@ export type EnqueueSessionTurnInput = {
1610
1619
  initiator: TurnInitiator;
1611
1620
  initiatorContext?: TurnInitiatorContext;
1612
1621
  personalConnectionDelegations?: McpPersonalConnectionDelegation[];
1622
+ mcpAccountBindings?: McpConnectionAccountBinding[] | null;
1613
1623
  xaiProviderAccountAuthoritySnapshot?: XaiProviderAccountAuthoritySnapshotV1;
1614
1624
  /** Steer inserts before all waiting prompts; Send appends after them. */
1615
1625
  placement?: "head" | "tail";
@@ -1617,6 +1627,7 @@ export type EnqueueSessionTurnInput = {
1617
1627
  /** Worker-only turn projection with causal authority omitted from public APIs. */
1618
1628
  export type SessionTurnForExecution = SessionTurn & {
1619
1629
  personalConnectionDelegations: McpPersonalConnectionDelegation[];
1630
+ mcpAccountBindings: McpConnectionAccountBinding[] | null;
1620
1631
  /** Worker-only causal authority; never inferred from the current worker. */
1621
1632
  initiatingHumanSubjectId: string | null;
1622
1633
  scheduledTaskRunId: string | null;
@@ -1919,17 +1930,6 @@ export declare function completeExpiredFileUploadCleanup(db: Database, input: {
1919
1930
  uploadId: string;
1920
1931
  fileId: string;
1921
1932
  }): Promise<boolean>;
1922
- export declare function enablePackInstallation(db: Database, input: CreatePackInstallationInput): Promise<PackInstallation>;
1923
- export declare function listPackInstallations(db: Database, workspaceId: string): Promise<PackInstallation[]>;
1924
- export declare function getPackInstallation(db: Database, workspaceId: string, packId: string): Promise<PackInstallation | null>;
1925
- export declare function updatePackInstallationStatus(db: Database, workspaceId: string, packId: string, status: PackInstallationStatus): Promise<PackInstallation>;
1926
- export declare function registerWorkspacePack(db: Database, input: RegisterWorkspacePackInput): Promise<{
1927
- pack: WorkspaceRegisteredPack;
1928
- created: boolean;
1929
- }>;
1930
- export declare function listWorkspacePacks(db: Database, workspaceId: string): Promise<WorkspaceRegisteredPack[]>;
1931
- export declare function getWorkspacePack(db: Database, workspaceId: string, packId: string): Promise<WorkspaceRegisteredPack | null>;
1932
- export declare function deleteWorkspacePack(db: Database, workspaceId: string, packId: string): Promise<boolean>;
1933
1933
  export declare function createImportBatch(db: Database, input: CreateImportBatchInput): Promise<ImportBatch>;
1934
1934
  export declare function findCompletedImportBatch(db: Database, input: {
1935
1935
  source: string;
@@ -2020,6 +2020,23 @@ export declare function decryptedCapabilityHeaders(server: EnabledMcpCapabilityS
2020
2020
  */
2021
2021
  export declare function getStoredCapabilityHeaderCiphertext(db: Database, workspaceId: string, capabilityId: string): Promise<Record<string, string> | null>;
2022
2022
  export declare function mcpServerIdForCapability(capabilityId: string, metadata?: Record<string, unknown>): string;
2023
+ export declare class ConnectionCreateIdempotencyError extends Error {
2024
+ constructor();
2025
+ }
2026
+ export declare function getConnectionCreationResult(db: Database, input: {
2027
+ accountId: string;
2028
+ workspaceId: string;
2029
+ subjectId: string;
2030
+ operationId: string;
2031
+ }): Promise<ConnectionMetadataWithVerification | null>;
2032
+ export declare function createConnectionIdempotently(db: Database, input: CreateConnectionInput & {
2033
+ operation?: {
2034
+ id: string;
2035
+ requestDigest: string;
2036
+ };
2037
+ /** Runs inside the first creation transaction, never on operation replay. */
2038
+ onCreated?: (tx: Database, connection: Awaited<ReturnType<typeof createConnection>>) => Promise<void>;
2039
+ }): Promise<ConnectionMetadataWithVerification>;
2023
2040
  export declare function createConnection(db: Database, input: CreateConnectionInput): Promise<ConnectionMetadataWithVerification>;
2024
2041
  /** Compatibility wrapper for the existing Vercel AI Gateway create/replay contract. */
2025
2042
  export declare function upsertWorkspaceVercelAiGatewayConnection(db: Database, input: UpsertWorkspaceVercelAiGatewayConnectionInput): Promise<ConnectionMetadataWithVerification | null>;
@@ -2840,6 +2857,14 @@ export declare function listSocialPosts(db: Database, options: {
2840
2857
  limit?: number;
2841
2858
  }): Promise<SocialPost[]>;
2842
2859
  export declare function createScheduledTask(db: Database, input: CreateScheduledTaskInput): Promise<ScheduledTask>;
2860
+ /** Trusted mutation seam: verify an exact agent attempt before deriving its human. */
2861
+ export declare function scheduledTaskMutationOwnerMatches(db: Database, input: {
2862
+ workspaceId: string;
2863
+ taskId: string;
2864
+ createdBy?: TurnInitiator;
2865
+ createdByContext?: TurnInitiatorContext;
2866
+ createdByActor?: AgentSessionCreationActor | null;
2867
+ }): Promise<boolean>;
2843
2868
  export declare function updateScheduledTask(db: Database, workspaceId: string, taskId: string, input: UpdateScheduledTaskInput): Promise<ScheduledTask>;
2844
2869
  export declare function getScheduledTask(db: Database, workspaceId: string, taskId: string): Promise<ScheduledTask | null>;
2845
2870
  /** Internal delete-recovery lookup; public list/get surfaces hide tombstones. */
@@ -2850,20 +2875,14 @@ export declare function getScheduledTaskIncludingDeleted(db: Database, workspace
2850
2875
  export declare function getScheduledTaskIncludingDeletedForUpdate(db: Database, workspaceId: string, taskId: string): Promise<(ScheduledTask & {
2851
2876
  deletedAt: string | null;
2852
2877
  }) | null>;
2853
- export declare function getScheduledTaskPersonalConnectionDelegations(db: Database, workspaceId: string, taskId: string): Promise<McpPersonalConnectionDelegation[]>;
2854
2878
  /**
2855
- * Lock and project the exact mutable incident-task authority inside a caller's
2856
- * dispatch/claim transaction. Returning the frozen personal delegation tuple
2857
- * from the same row prevents a later task edit from mixing with the task
2858
- * snapshot used for preflight.
2879
+ * Lock the incident task definition inside the dispatch transaction. Account
2880
+ * authority belongs to the accepted occurrence, never the mutable task head.
2859
2881
  */
2860
2882
  export declare function requireScheduledTaskIncidentAuthorityInTransaction(tx: Database, input: {
2861
2883
  workspaceId: string;
2862
2884
  taskId: string;
2863
- }): Promise<{
2864
- task: ScheduledTask;
2865
- personalConnectionDelegations: McpPersonalConnectionDelegation[];
2866
- }>;
2885
+ }): Promise<ScheduledTask>;
2867
2886
  export declare function getScheduledTaskXaiProviderAccountAuthoritySnapshot(db: Database, workspaceId: string, taskId: string): Promise<XaiProviderAccountAuthoritySnapshotV1>;
2868
2887
  /**
2869
2888
  * The frozen creator boundary of a scheduled task. Read at fire time (and by
@@ -3781,7 +3800,7 @@ export declare function setWorkspaceCodexSubscriptionModeInTransaction(scopedDb:
3781
3800
  workspaceId: string;
3782
3801
  subjectId: string | null;
3783
3802
  mode: WorkspaceCodexSubscriptionMode;
3784
- /** Effective source captured under the source lock before caller-owned credential writes. */
3803
+ /** Compatibility hint only; database capture derives authority before credential writes. */
3785
3804
  effectiveSourceBeforeMutation?: EffectiveCodexSubscriptionSource;
3786
3805
  }): Promise<WorkspaceCodexSubscriptionSource>;
3787
3806
  export declare function setWorkspaceCodexSubscriptionMode(db: Database, input: {
@@ -3947,7 +3966,16 @@ export declare function clearCodexAppsCredential(db: Database, input: {
3947
3966
  * workspace; an unknown/disconnected id returns null → the caller treats it as
3948
3967
  * "needs relogin / re-pick".
3949
3968
  */
3950
- export declare function loadCodexCredentialForRun(db: Database, settings: Settings, workspaceId: string, credentialId: string): Promise<CodexCredentialForRun | null>;
3969
+ export type CodexAcceptedLeaseAuthority = {
3970
+ turnId: string;
3971
+ holderId: string;
3972
+ generation: number;
3973
+ };
3974
+ type CodexAcceptedCredentialAuthority = CodexAcceptedLeaseAuthority | {
3975
+ turnId: string;
3976
+ purpose: "capacity_refresh";
3977
+ };
3978
+ export declare function loadCodexCredentialForRun(db: Database, settings: Settings, workspaceId: string, credentialId: string, authority?: CodexAcceptedCredentialAuthority): Promise<CodexCredentialForRun | null>;
3951
3979
  /**
3952
3980
  * Persist rotated tokens after a successful refresh. Caller pre-encrypts.
3953
3981
  *
@@ -3966,6 +3994,7 @@ export declare function recordCodexTokenRefresh(db: Database, input: {
3966
3994
  credentialEncrypted: string;
3967
3995
  expiresAt: Date | null;
3968
3996
  lastRefreshAt: Date;
3997
+ authority?: CodexAcceptedCredentialAuthority | undefined;
3969
3998
  }): Promise<boolean>;
3970
3999
  /**
3971
4000
  * Cross-process single-flight boundary for one workspace credential refresh.
@@ -3989,7 +4018,7 @@ export declare function withCodexCredentialRefreshLock<T>(db: Database, workspac
3989
4018
  export declare function setCodexCredentialStatus(db: Database, workspaceId: string, status: "active" | "needs_relogin" | "error", lastError: string | null, target: {
3990
4019
  id: string;
3991
4020
  version: number;
3992
- }): Promise<boolean>;
4021
+ }, authority?: CodexAcceptedCredentialAuthority): Promise<boolean>;
3993
4022
  /**
3994
4023
  * Metadata-only runtime quarantine for a credential selected by id. The version
3995
4024
  * is read and written in one RLS-scoped transaction, so a reconnect that rotates
@@ -4028,7 +4057,7 @@ export declare function getCodexCredentialStatus(db: Database, workspaceId: stri
4028
4057
  * decide whether to inject the synthetic codex-subscription provider, so billing
4029
4058
  * and provider-injection cannot drift. Metadata-only read (never the secret).
4030
4059
  */
4031
- export declare function workspaceCodexSubscriptionActive(db: Database, settings: Pick<Settings, "codexSubscriptionEnabled">, workspaceId: string): Promise<boolean>;
4060
+ export declare function workspaceCodexSubscriptionActive(db: Database, settings: Pick<Settings, "codexSubscriptionEnabled">, workspaceId: string, acceptedTurnId?: string): Promise<boolean>;
4032
4061
  /**
4033
4062
  * CANONICAL "is this a Codex-billed turn?" predicate.
4034
4063
  *
@@ -4094,6 +4123,9 @@ export type CodexAccountStatus = {
4094
4123
  */
4095
4124
  export type CodexLeaseAccountStatus = Omit<CodexAccountStatus, "allocatorVersion" | "allocatorUpdatedBySubjectId" | "allocatorUpdatedAt" | "resetCreditAvailableCount" | "resetCreditsCheckedAt" | "connectedBySubjectId" | "source"> & {
4096
4125
  activeLeaseCount: number;
4126
+ /** Absent only in pre-0383 compatibility schemas. */
4127
+ exhaustedRevision?: number;
4128
+ credentialVersion?: number;
4097
4129
  selectionCount: number;
4098
4130
  lastSelectedAt: Date | null;
4099
4131
  };
@@ -4136,6 +4168,8 @@ export type CodexCredentialLeaseSelectionContext<TPolicyScope = never, TUnavaila
4136
4168
  existingCredentialId: string | null;
4137
4169
  /** Credentials already consumed by a definitive refusal on this accepted turn. */
4138
4170
  failedCredentialIds?: readonly string[];
4171
+ failoverExhausted?: boolean;
4172
+ modelId?: string;
4139
4173
  /** Downstream-owned accepted-turn policy; absent until a resolver is supplied. */
4140
4174
  policyScope: TPolicyScope | null;
4141
4175
  /** Diagnostics produced while choosing one policy scope for this NEW allocation. */
@@ -4293,6 +4327,11 @@ export type ArmCodexCapacityWaitResult = {
4293
4327
  action: "waiting";
4294
4328
  waiter: CodexCapacityWait;
4295
4329
  events: SessionEvent[];
4330
+ } | {
4331
+ action: "stopped";
4332
+ sessionStatus: "failed" | "queued";
4333
+ waiter: CodexCapacityWait;
4334
+ events: SessionEvent[];
4296
4335
  } | {
4297
4336
  action: "stale";
4298
4337
  waiter: CodexCapacityWait | null;
@@ -4361,14 +4400,18 @@ export declare function armCodexCapacityWait(db: Database, input: {
4361
4400
  }): Promise<ArmCodexCapacityWaitResult>;
4362
4401
  export declare function getCodexCapacityWaitForSession(db: Database, workspaceId: string, sessionId: string): Promise<CodexCapacityWait | null>;
4363
4402
  type CodexCapacityMutationInput = {
4403
+ acceptedTurnId?: string | undefined;
4404
+ /** Local management writes do not follow the live source preference. */
4405
+ mutationSource?: "workspace" | "organization" | "effective";
4364
4406
  workspaceId: string;
4365
4407
  reason: string;
4366
4408
  policyHash?: string | null;
4367
4409
  };
4368
4410
  /**
4369
4411
  * Same-transaction capacity-mutation/outbox seam for eligibility and
4370
- * membership/default changes. The allocator rotation row is always the
4371
- * first lock. Mutations report whether capacity truth changed; only then are
4412
+ * membership/default changes. Local management writes target the workspace
4413
+ * pool; runtime writers opt into the effective/accepted pool. The source lock
4414
+ * precedes that pool's rotation row. Mutations report whether capacity truth changed; only then are
4372
4415
  * matching waiter wake revisions advanced and returned for best-effort signal.
4373
4416
  */
4374
4417
  export declare function withCodexCapacityMutation<T>(db: Database, input: CodexCapacityMutationInput, mutate: (tx: Database) => Promise<{
@@ -4573,7 +4616,22 @@ export declare function getWorkspaceConnectionModelRestrictions(db: Database, wo
4573
4616
  * accounts UI + the worker's selection resolver. NEVER decrypts. `isActive` marks
4574
4617
  * the workspace active pointer. Ordered by created_at ASC (stable list order).
4575
4618
  */
4576
- export declare function listCodexAccountStatuses(db: Database, workspaceId: string): Promise<CodexAccountStatus[]>;
4619
+ export declare function listCodexAccountStatuses(db: Database, workspaceId: string, acceptedTurnId?: string): Promise<CodexAccountStatus[]>;
4620
+ /** Session-authorized metadata projection. The caller authorizes the session;
4621
+ * its locked active pointer, never a client-supplied turn/source, selects the
4622
+ * accepted pool. Running turns retain their display account while choices for
4623
+ * new work follow current settings. No credential material or Apps grants. */
4624
+ export declare function getSessionCodexAccounts(db: Database, workspaceId: string, sessionId: string): Promise<{
4625
+ accounts: CodexAccountStatus[];
4626
+ rotation: CodexRotationSettings | null;
4627
+ currentSelection: {
4628
+ waiting: boolean;
4629
+ credentialId: string | null;
4630
+ } | null;
4631
+ currentAccount: CodexAccountStatus | null;
4632
+ pinnedAccountId: string | null;
4633
+ lastAccountId: string | null;
4634
+ } | null>;
4577
4635
  export type CodexAllocatorUpdateResult = {
4578
4636
  kind: "updated" | "unchanged";
4579
4637
  allocatorEnabled: boolean;
@@ -4767,7 +4825,15 @@ export declare function completeCodexResetRedemption(db: Database, input: {
4767
4825
  */
4768
4826
  export declare function recordCodexAccountUsage(db: Database, workspaceId: string, credentialId: string, snapshot: CodexAccountUsageSnapshot): Promise<boolean>;
4769
4827
  /** Usage-cache mutation plus its committed durable capacity-wake outbox. */
4770
- export declare function recordCodexAccountUsageWithWakeTargets(db: Database, workspaceId: string, credentialId: string, snapshot: CodexAccountUsageSnapshot): Promise<CodexCapacityMutationResult<boolean>>;
4828
+ export declare function recordCodexAccountUsageWithWakeTargets(db: Database, workspaceId: string, credentialId: string, snapshot: CodexAccountUsageSnapshot, authority?: CodexAcceptedCredentialAuthority): Promise<CodexCapacityMutationResult<boolean>>;
4829
+ export type CodexFinalizationUsageAuthority = CodexAcceptedLeaseAuthority & {
4830
+ sessionId: string;
4831
+ attemptId: string;
4832
+ executionGeneration: number;
4833
+ credentialVersion: number;
4834
+ };
4835
+ /** Write-only cleanup authority: never usable by a token/decrypt accessor. */
4836
+ export declare function recordCodexAccountUsageForFinalization(db: Database, workspaceId: string, credentialId: string, snapshot: CodexAccountUsageSnapshot, authority: CodexFinalizationUsageAuthority): Promise<CodexCapacityMutationResult<boolean>>;
4771
4837
  export type CodexRotationSettings = {
4772
4838
  activeCredentialId: string | null;
4773
4839
  /** False keeps new allocations on the active account; true permits pool failover. */
@@ -4801,7 +4867,7 @@ export declare function upsertWorkspaceModelPolicy(db: Database, input: {
4801
4867
  allowedModels: string[] | null;
4802
4868
  }): Promise<WorkspaceModelPolicy>;
4803
4869
  /** The per-workspace rotation/active-pointer row (null when none exists yet). */
4804
- export declare function getCodexRotationSettings(db: Database, workspaceId: string): Promise<CodexRotationSettings | null>;
4870
+ export declare function getCodexRotationSettings(db: Database, workspaceId: string, acceptedTurnId?: string): Promise<CodexRotationSettings | null>;
4805
4871
  /** Idempotently ensure the per-workspace rotation-settings row exists. */
4806
4872
  export declare function ensureCodexRotationSettings(db: Database, accountId: string, workspaceId: string): Promise<void>;
4807
4873
  /**
@@ -5100,6 +5166,7 @@ export type SessionCreateInput = {
5100
5166
  skills?: SessionSkill[];
5101
5167
  tools?: ToolRef[];
5102
5168
  toolPolicy?: SessionToolPolicy;
5169
+ mcpApprovalPolicies?: Record<string, SessionMcpApprovalPolicy>;
5103
5170
  metadata: Record<string, unknown>;
5104
5171
  createdBy?: TurnInitiator;
5105
5172
  createdByContext?: TurnInitiatorContext;
@@ -5127,8 +5194,6 @@ export type SessionCreateInput = {
5127
5194
  createIdempotencyKey?: string | null;
5128
5195
  /** Exact explicit installed-Skill selection used for keyed-create replay. */
5129
5196
  selectedInstalledSkillIds?: string[];
5130
- /** Backend-only replay identity; does not admit host credential authority. */
5131
- selectedHostMcpDelegations?: HostMcpCreateSelection[];
5132
5197
  sandboxGroupId?: string | null;
5133
5198
  sandboxOs?: SandboxOs;
5134
5199
  /** Exact accepted generated-session compaction policy; internal lifecycle callers only. */
@@ -5140,6 +5205,7 @@ export type SessionCreateInput = {
5140
5205
  };
5141
5206
  mcpServers?: CreateSessionMcpServerInput[];
5142
5207
  personalConnectionDelegations?: McpPersonalConnectionDelegation[];
5208
+ mcpAccountBindings?: McpConnectionAccountBinding[] | null;
5143
5209
  initialPersonalResourceAttachmentIntent?: PersonalResourceAttachmentIntent | null;
5144
5210
  initialXaiProviderAccountAuthoritySnapshot?: XaiProviderAccountAuthoritySnapshotV1;
5145
5211
  maxNestedAgentDepthOverride?: number | null;
@@ -5214,7 +5280,6 @@ export declare function getInitializedSessionCreateReplay(db: Database, input: {
5214
5280
  visibility?: "user_private" | "workspace_shared";
5215
5281
  variableSetIds: string[];
5216
5282
  selectedInstalledSkillIds: string[];
5217
- selectedHostMcpDelegations?: HostMcpCreateSelection[];
5218
5283
  initialPersonalResourceAttachmentIntent?: PersonalResourceAttachmentIntent | null;
5219
5284
  deferInitialTurn?: boolean;
5220
5285
  }): Promise<InitializedSessionCreateReplay | null>;
@@ -5259,6 +5324,7 @@ export type SessionAccessProjection = {
5259
5324
  memoryScope: SessionMemoryScope;
5260
5325
  };
5261
5326
  export type SessionAuthorityProjection = SessionAccessProjection & {
5327
+ authorityEpoch: number;
5262
5328
  visibility: "user_private" | "workspace_shared";
5263
5329
  ownerSubjectId: string | null;
5264
5330
  };
@@ -5277,6 +5343,8 @@ export declare function resolveSessionMemoryAgentScope(db: Database, workspaceId
5277
5343
  executionGeneration?: unknown;
5278
5344
  }): Promise<MemoryAgentScope | null>;
5279
5345
  export declare function memoryAgentScopeForSessionAccess(access: Pick<SessionAccessProjection, "rootSessionId" | "scopeSubjectId" | "memoryScope">): MemoryAgentScope;
5346
+ export declare function getSessionTurnMcpAccountBindings(db: Database, workspaceId: string, sessionId: string, turnId: string): Promise<McpConnectionAccountBinding[] | null>;
5347
+ export declare function getSessionParentMcpAccountBindings(db: Database, workspaceId: string, childSessionId: string): Promise<McpConnectionAccountBinding[] | null>;
5280
5348
  export declare function getSessionTurnXaiProviderAccountAuthoritySnapshot(db: Database, workspaceId: string, sessionId: string, turnId: string): Promise<XaiProviderAccountAuthoritySnapshotV1>;
5281
5349
  export declare function getSessionTurnPersonalConnectionDelegations(db: Database, workspaceId: string, sessionId: string, turnId: string): Promise<McpPersonalConnectionDelegation[]>;
5282
5350
  export declare function getSessionParentPersonalConnectionDelegations(db: Database, workspaceId: string, childSessionId: string): Promise<McpPersonalConnectionDelegation[]>;
@@ -5322,22 +5390,22 @@ export type SessionListSnapshotCursor = {
5322
5390
  offset: number;
5323
5391
  parentSessionFilter: string;
5324
5392
  search: string | null;
5325
- archiveMode: "active" | "archived";
5393
+ archiveMode: "active" | "archived" | "all";
5326
5394
  /** Additive filter identity; absent on legacy snapshot cursors. */
5327
5395
  filter?: string;
5328
5396
  };
5329
5397
  export type SessionListKeysetCursor = {
5330
5398
  kind: "keyset";
5331
5399
  /** Absent on v2 cursors, which always used session updatedAt. */
5332
- sortBy?: "updatedAt" | "archivedAt";
5400
+ sortBy?: "updatedAt" | "archivedAt" | "createdAt" | "name";
5333
5401
  /** Decimal committed workspace activity revision frozen on page one. */
5334
5402
  snapshotRevision: string;
5335
- /** Exact PostgreSQL timestamp text, including microseconds. */
5403
+ /** Exact PostgreSQL timestamp (including microseconds), or normalized name for name order. */
5336
5404
  sortAt: string;
5337
5405
  id: string;
5338
5406
  parentSessionFilter: string;
5339
5407
  search: string | null;
5340
- archiveMode: "active" | "archived";
5408
+ archiveMode: "active" | "archived" | "all";
5341
5409
  /** Canonical identity for channel, creator, and time-bound filters. */
5342
5410
  filter?: string;
5343
5411
  };
@@ -5371,6 +5439,8 @@ export type ListSessionsForSubjectOptions = ListSessionsOptions & SessionListFil
5371
5439
  pinsOnly?: boolean | undefined;
5372
5440
  /** List personally archived chats instead of active chats. */
5373
5441
  archivedOnly?: boolean | undefined;
5442
+ sortBy?: "updatedAt" | "createdAt" | "name" | undefined;
5443
+ archiveStatus?: "active" | "archived" | "all" | undefined;
5374
5444
  /** Return a continuation cursor. Disable for legacy one-page array reads. */
5375
5445
  materializeSnapshot?: boolean | undefined;
5376
5446
  authorizationScope?: SessionAuthorizationListScope | undefined;
@@ -5480,6 +5550,12 @@ export declare function encodeSessionListCursor(cursor: SessionListCursor): stri
5480
5550
  export declare function decodeSessionListCursor(value: string): SessionListCursor | null;
5481
5551
  /** Bounded global TTL cleanup, isolated from serializable member list reads. */
5482
5552
  export declare function reapExpiredSessionListSnapshots(db: Database, limit?: number): Promise<number>;
5553
+ /** Bounded full-history message search. The caller must authorize a live grant
5554
+ * and its complete host/agent list scope before entering this RLS projection.
5555
+ */
5556
+ export declare function searchSessionMessagesForSubject(db: Database, workspaceId: string, request: SessionMessageSearchRequest, authority: Pick<ListSessionsForSubjectOptions, "subjectId" | "authorizationScope" | "personalWorkspaceOwnerException">, options?: {
5557
+ signal?: AbortSignal | undefined;
5558
+ }): Promise<SessionMessageSearchResponse>;
5483
5559
  /**
5484
5560
  * Server-authoritative member-specific page. Pinned rows are returned separately
5485
5561
  * and omitted from ordinary pages, so list pagination cannot duplicate a
@@ -5975,6 +6051,26 @@ export declare function installOrReadTurnExecutionPolicyForAttempt(db: Database,
5975
6051
  attemptId: string;
5976
6052
  policyForAbsent: TurnExecutionPolicyV1;
5977
6053
  }): Promise<InstallOrReadTurnExecutionPolicyForAttemptResult>;
6054
+ /** Persist the current catalog once per logical turn; retries reuse its exact snapshot. */
6055
+ export declare function ensureSessionSkillCatalog(db: Database, input: {
6056
+ accountId: string;
6057
+ workspaceId: string;
6058
+ sessionId: string;
6059
+ turnId: string;
6060
+ expectedExecutionGeneration: number;
6061
+ expectedAttemptId: string;
6062
+ catalog: string;
6063
+ }): Promise<string>;
6064
+ /** Install an effort update before accepted input, or at the maintenance tail, under the attempt fence. */
6065
+ export declare function ensureSessionReasoningConfiguration(db: Database, input: {
6066
+ accountId: string;
6067
+ workspaceId: string;
6068
+ sessionId: string;
6069
+ turnId: string;
6070
+ expectedExecutionGeneration: number;
6071
+ expectedAttemptId: string;
6072
+ effort: ConfigurationEffort;
6073
+ }): Promise<ConfigurationEffort>;
5978
6074
  /**
5979
6075
  * Append conversation items (verbatim SDK AgentInputItems) to the session's
5980
6076
  * history. Idempotent on (workspace, session, position): concurrent or
@@ -6186,6 +6282,7 @@ export declare function applyContextCompaction(db: Database, input: {
6186
6282
  expectedAttemptId: string;
6187
6283
  replacementItems: Array<Record<string, unknown>>;
6188
6284
  summaryItem: Record<string, unknown>;
6285
+ trailingItems?: Array<Record<string, unknown>>;
6189
6286
  clearRequestedCompaction?: boolean;
6190
6287
  eventPayload?: Record<string, unknown>;
6191
6288
  }): Promise<ApplyContextCompactionResult>;
@@ -6233,6 +6330,18 @@ export declare function recordSkippedContextCompaction(db: Database, input: {
6233
6330
  requirePendingRequest?: boolean;
6234
6331
  /** When false, leave `compactRequested` untouched. Defaults to true. */
6235
6332
  clearRequestedCompaction?: boolean;
6333
+ /**
6334
+ * Closed, content-free identifiers of a definitive provider rejection
6335
+ * (`summarization_failed` only): HTTP status, error type/code, rejected
6336
+ * parameter path, provider request id. Never a provider message.
6337
+ */
6338
+ providerRejection?: {
6339
+ httpStatus: number;
6340
+ type: string | null;
6341
+ code: string | null;
6342
+ param: string | null;
6343
+ requestId: string | null;
6344
+ };
6236
6345
  }): Promise<{
6237
6346
  recorded: true;
6238
6347
  events: SessionEvent[];
@@ -6553,6 +6662,8 @@ export type SandboxRecoveryState = {
6553
6662
  };
6554
6663
  };
6555
6664
  export interface LeaseSnapshot {
6665
+ /** Consent is not archive completeness; begin/commit revalidate the receipt. */
6666
+ historicalRecoveryAuthorized?: boolean;
6556
6667
  /** Exact idle-only enrollment. Commands remain active until provider stop. */
6557
6668
  unobservableCommandDrainIds?: string[] | null;
6558
6669
  id: string;
@@ -6800,6 +6911,29 @@ export type BeginSandboxRematerializationResult = {
6800
6911
  code: "archive_unavailable" | "archive_unverified" | "archive_generation_mismatch" | "checkpoint_artifact_invalid" | "attempt_conflict" | "stale_epoch";
6801
6912
  lease: LeaseSnapshot | null;
6802
6913
  };
6914
+ export declare class SandboxRecoveryConflictError extends Error {
6915
+ readonly code = "SANDBOX_RECOVERY_CONFLICT";
6916
+ }
6917
+ /** Retry already owns workspace/session/turn locks. Fence the EFFECTIVE route,
6918
+ * not a degraded managed home behind an explicitly selected Connected Machine. */
6919
+ export declare function sessionEffectiveSandboxRecoveryBlocked(tx: Database, session: typeof schema.sessions.$inferSelect): Promise<boolean>;
6920
+ type PublicRecoveryScope = {
6921
+ accountId: string;
6922
+ workspaceId: string;
6923
+ sessionId: string;
6924
+ subjectId: string;
6925
+ };
6926
+ /** Authorized caller only; provider-free and mutation-free (transaction scope only). */
6927
+ export declare function readPublicSandboxRecovery(db: Database, input: PublicRecoveryScope): Promise<SandboxRecoveryProjection>;
6928
+ /** Core authenticates the canonical managed human before calling this seam.
6929
+ * Exclusive tenancy precedes the complete membership proof and is shared by
6930
+ * every attach/child writer. No provider operation or inference is dispatched. */
6931
+ export declare function consentPublicSandboxRecovery(db: Database, input: PublicRecoveryScope & {
6932
+ request: SandboxRecoveryRequest;
6933
+ }): Promise<SandboxRecoveryResponse>;
6934
+ /** These warnings are outside compactable history and survive ordinary context
6935
+ * reconstruction. Receipts describe consent, never unverified restore success. */
6936
+ export declare function getSandboxRecoveryDiscontinuity(db: Database, workspaceId: string, sessionId: string): Promise<string | null>;
6803
6937
  /** Operator-only authorization for an exact historical checkpoint. Direct
6804
6938
  * database access is the authority boundary; subjectId records attribution.
6805
6939
  * This never resumes a turn or changes the archive/workspace generations. */
@@ -7238,6 +7372,8 @@ export declare function markWarmLeaseInstanceLost(db: Database, input: {
7238
7372
  sandboxGroupId: string;
7239
7373
  expectedEpoch: number;
7240
7374
  expectedInstanceId: string;
7375
+ /** Optional for legacy callers; new provider observers should bind backend too. */
7376
+ expectedBackend?: string;
7241
7377
  /** Bounded classifier output only; never raw provider error text. */
7242
7378
  diagnostic?: string;
7243
7379
  }): Promise<MarkWarmLeaseInstanceLostResult>;
@@ -7863,6 +7999,150 @@ export declare function settleRetainedProcess(db: Database, input: {
7863
7999
  process: SandboxRetainedProcess;
7864
8000
  backgroundCommandEvents: SessionEvent[];
7865
8001
  }>;
8002
+ /** Only call for an authenticated, typed provider response proving this exact
8003
+ * retained launch was never started. Ambiguous dispatch is NOT rejection proof.
8004
+ * The command equality and empty launch checks repeat under the settlement lock. */
8005
+ export declare function rejectRetainedSupervisedLaunch(db: Database, scope: {
8006
+ accountId: string;
8007
+ workspaceId: string;
8008
+ sessionId: string;
8009
+ processId: string;
8010
+ }, command: ModalRouterProviderCommand): Promise<void>;
8011
+ /** Compose the leaf cursor/proof persistence with canonical settlement. The
8012
+ * leaf subpath cannot import this root without reversing the DB boundary. */
8013
+ export declare function retainedProviderCommandPersistence(...[db, scope, publish]: Parameters<typeof retainedProviderCommandState>): {
8014
+ recordSupervisionReceipt: (receipt: import("./retained-provider-commands.js").SupervisionReceipt) => Promise<void>;
8015
+ loadSupervisionReceipt: () => Promise<{
8016
+ protocol: "native-subreaper-v1";
8017
+ invocationId: string;
8018
+ receiptId: string;
8019
+ leaderExitCode: number;
8020
+ } | null>;
8021
+ requestCancellation: (reason: "provider_deadline" | "explicit_stop") => Promise<void>;
8022
+ cancellationRequested: () => Promise<boolean>;
8023
+ load: () => Promise<{
8024
+ kind: "modal-control-v1";
8025
+ sandboxId: string;
8026
+ taskId: string;
8027
+ execId: string;
8028
+ pty?: boolean | undefined;
8029
+ streams: {
8030
+ stdout: {
8031
+ batchIndex: number;
8032
+ utf8Remainder: string;
8033
+ exitCode: number | null;
8034
+ };
8035
+ stderr: {
8036
+ batchIndex: number;
8037
+ utf8Remainder: string;
8038
+ exitCode: number | null;
8039
+ };
8040
+ };
8041
+ } | {
8042
+ kind: "modal-router-v1";
8043
+ sandboxId: string;
8044
+ taskId: string;
8045
+ execId: string;
8046
+ pty?: boolean | undefined;
8047
+ supervision?: {
8048
+ protocol: "native-subreaper-v1";
8049
+ invocationId: string;
8050
+ nonce: string;
8051
+ controlPath: string;
8052
+ } | undefined;
8053
+ streams: {
8054
+ stdout: {
8055
+ byteOffset: number;
8056
+ utf8Remainder: string;
8057
+ eof: boolean;
8058
+ exitCode: number | null;
8059
+ };
8060
+ stderr: {
8061
+ byteOffset: number;
8062
+ utf8Remainder: string;
8063
+ eof: boolean;
8064
+ exitCode: number | null;
8065
+ };
8066
+ };
8067
+ } | null>;
8068
+ acknowledge: (command: import("@opengeni/contracts").SandboxProviderCommand) => Promise<{
8069
+ kind: "modal-control-v1";
8070
+ sandboxId: string;
8071
+ taskId: string;
8072
+ execId: string;
8073
+ pty?: boolean | undefined;
8074
+ streams: {
8075
+ stdout: {
8076
+ batchIndex: number;
8077
+ utf8Remainder: string;
8078
+ exitCode: number | null;
8079
+ };
8080
+ stderr: {
8081
+ batchIndex: number;
8082
+ utf8Remainder: string;
8083
+ exitCode: number | null;
8084
+ };
8085
+ };
8086
+ } | {
8087
+ kind: "modal-router-v1";
8088
+ sandboxId: string;
8089
+ taskId: string;
8090
+ execId: string;
8091
+ pty?: boolean | undefined;
8092
+ supervision?: {
8093
+ protocol: "native-subreaper-v1";
8094
+ invocationId: string;
8095
+ nonce: string;
8096
+ controlPath: string;
8097
+ } | undefined;
8098
+ streams: {
8099
+ stdout: {
8100
+ byteOffset: number;
8101
+ utf8Remainder: string;
8102
+ eof: boolean;
8103
+ exitCode: number | null;
8104
+ };
8105
+ stderr: {
8106
+ byteOffset: number;
8107
+ utf8Remainder: string;
8108
+ eof: boolean;
8109
+ exitCode: number | null;
8110
+ };
8111
+ };
8112
+ }>;
8113
+ reserveInput: (byteLength?: number) => Promise<number>;
8114
+ captureRouterPage: (page: import("./retained-provider-commands.js").RetainedRouterOutputPage) => Promise<{
8115
+ command: {
8116
+ kind: "modal-router-v1";
8117
+ sandboxId: string;
8118
+ taskId: string;
8119
+ execId: string;
8120
+ pty?: boolean | undefined;
8121
+ supervision?: {
8122
+ protocol: "native-subreaper-v1";
8123
+ invocationId: string;
8124
+ nonce: string;
8125
+ controlPath: string;
8126
+ } | undefined;
8127
+ streams: {
8128
+ stdout: {
8129
+ byteOffset: number;
8130
+ utf8Remainder: string;
8131
+ eof: boolean;
8132
+ exitCode: number | null;
8133
+ };
8134
+ stderr: {
8135
+ byteOffset: number;
8136
+ utf8Remainder: string;
8137
+ eof: boolean;
8138
+ exitCode: number | null;
8139
+ };
8140
+ };
8141
+ };
8142
+ captured: boolean;
8143
+ }>;
8144
+ rejectSupervisedLaunch: (command: ModalRouterProviderCommand) => Promise<void>;
8145
+ };
7866
8146
  /** Read the exact generation a verified capture must later fold. This is a
7867
8147
  * preflight only: persistWarmSnapshot/persistDrainSnapshot repeat the full
7868
8148
  * epoch, provider, liveness, and generation CAS under the archive-fold lock. */
@@ -9083,6 +9363,7 @@ export type CreateSessionGoalInput = {
9083
9363
  text: string;
9084
9364
  successCriteria?: string | null;
9085
9365
  rootConstraints?: string[];
9366
+ reportRequirements?: SessionGoalReportRequirement[];
9086
9367
  maxAutoContinuations?: number | null;
9087
9368
  mutationPolicy?: SessionGoalMutationPolicy;
9088
9369
  expectedObjectiveRevision?: number;
@@ -9117,7 +9398,9 @@ export type SessionGoalContinuationProjection = {
9117
9398
  export declare function getSessionGoalWithContinuation(db: Database, workspaceId: string, sessionId: string): Promise<(SessionGoal & {
9118
9399
  continuation: SessionGoalContinuationProjection;
9119
9400
  }) | null>;
9120
- export declare function clearSessionGoal(db: Database, workspaceId: string, sessionId: string): Promise<{
9401
+ export declare function clearSessionGoal(db: Database, workspaceId: string, sessionId: string, options?: {
9402
+ actor: "api" | "agent";
9403
+ }): Promise<{
9121
9404
  cleared: boolean;
9122
9405
  goal: SessionGoal | null;
9123
9406
  event: SessionEvent | null;
@@ -9155,6 +9438,9 @@ export declare function upsertScheduledSessionGoalForRun(db: Database, input: {
9155
9438
  */
9156
9439
  export declare function upsertSessionGoalWithEvent(db: Database, input: CreateSessionGoalInput & {
9157
9440
  actor: "agent" | "api";
9441
+ commandActor?: Extract<SessionCommandActor, {
9442
+ type: "agent_attempt";
9443
+ }>;
9158
9444
  }): Promise<{
9159
9445
  goal: SessionGoal;
9160
9446
  replaced: boolean;
@@ -9259,6 +9545,7 @@ export declare function waitForSessionInputWithEvent(db: Database, workspaceId:
9259
9545
  */
9260
9546
  export declare function recordSessionGoalProgressWithEvent(db: Database, workspaceId: string, sessionId: string, input: {
9261
9547
  progressNote: string;
9548
+ reportRequirements?: SessionGoalReportRequirement[];
9262
9549
  command: {
9263
9550
  accountId: string;
9264
9551
  actor: Extract<SessionCommandActor, {
@@ -9345,6 +9632,11 @@ export declare function setSessionGoalStatus(db: Database, workspaceId: string,
9345
9632
  evidence?: string;
9346
9633
  rationale?: string;
9347
9634
  pausedReason?: string;
9635
+ reportDeliveries?: SessionGoalReportDelivery[];
9636
+ reportArtifactActor?: ReportArtifactActor;
9637
+ commandActor?: Extract<SessionCommandActor, {
9638
+ type: "agent_attempt";
9639
+ }>;
9348
9640
  }): Promise<{
9349
9641
  goal: SessionGoal;
9350
9642
  changed: boolean;
@@ -9368,6 +9660,11 @@ export declare function setSessionGoalStatusWithEvent(db: Database, workspaceId:
9368
9660
  evidence?: string;
9369
9661
  rationale?: string;
9370
9662
  pausedReason?: string;
9663
+ reportDeliveries?: SessionGoalReportDelivery[];
9664
+ reportArtifactActor?: ReportArtifactActor;
9665
+ commandActor?: Extract<SessionCommandActor, {
9666
+ type: "agent_attempt";
9667
+ }>;
9371
9668
  event: SetSessionGoalStatusEvent;
9372
9669
  }): Promise<{
9373
9670
  goal: SessionGoal;
@@ -9479,6 +9776,7 @@ export type InitializeSessionStartInput = {
9479
9776
  text: string;
9480
9777
  successCriteria?: string | null;
9481
9778
  rootConstraints?: string[];
9779
+ reportRequirements?: SessionGoalReportRequirement[];
9482
9780
  maxAutoContinuations?: number | null;
9483
9781
  mutationPolicy?: SessionGoalMutationPolicy;
9484
9782
  createdBy?: SessionGoalCreatedBy;
@@ -9538,6 +9836,9 @@ export type FrozenXaiExecutionAuthority = {
9538
9836
  subjectId: string | null;
9539
9837
  };
9540
9838
  export type ClaimSessionWorkForAttemptInput = {
9839
+ /** Internal worker-build declaration, never request-derived or universally
9840
+ * stamped by createDb. Only builds that always reconstruct the warning opt in. */
9841
+ filesystemDiscontinuityProtocol?: 1;
9541
9842
  sessionId: string;
9542
9843
  workflowId: string;
9543
9844
  workflowRunId: string;
@@ -9680,13 +9981,25 @@ export declare function reconcileSessionAttemptQuiescence(db: Database, input: {
9680
9981
  */
9681
9982
  export declare function settleSessionAttemptInterruptions(db: Database, workspaceId: string, sessionId: string, attemptId: string): Promise<SessionAttemptInterruptionSettlement>;
9682
9983
  export type SessionWorkPeek = {
9984
+ kind: "unavailable";
9985
+ } | {
9986
+ kind: "attempt-owned";
9987
+ turnId: string;
9988
+ attemptId: string;
9989
+ executionGeneration: number;
9990
+ activityRef: SessionAttemptActivityRef;
9991
+ } | {
9683
9992
  kind: "runnable";
9993
+ admissionFence?: SessionAdmissionFence;
9994
+ } | {
9995
+ kind: "admission-blocked";
9684
9996
  } | {
9685
9997
  kind: "sandbox-lifecycle-wait";
9686
9998
  ref: SandboxLifecycleWait;
9687
9999
  } | {
9688
10000
  kind: "approval-pending";
9689
10001
  triggerEventId: string;
10002
+ admissionFence?: SessionAdmissionFence;
9690
10003
  } | {
9691
10004
  kind: "approval-wait";
9692
10005
  humanInputRequestId?: string;
@@ -9695,6 +10008,7 @@ export type SessionWorkPeek = {
9695
10008
  } | {
9696
10009
  kind: "capacity-wait";
9697
10010
  ref: {
10011
+ provider?: "codex" | "xai";
9698
10012
  waiterId: string;
9699
10013
  generation: number;
9700
10014
  nextCheckAt: string;
@@ -9714,7 +10028,7 @@ export type SessionWorkPeek = {
9714
10028
  } | {
9715
10029
  kind: "idle";
9716
10030
  };
9717
- export declare function peekSessionWork(db: Database, workspaceId: string, sessionId: string): Promise<SessionWorkPeek>;
10031
+ export declare function peekSessionWork(db: Database, workspaceId: string, sessionId: string, includeAdmissionFence?: boolean, observerAccountId?: string): Promise<SessionWorkPeek>;
9718
10032
  export type SettleSessionInputWaitResult = {
9719
10033
  action: "held";
9720
10034
  events: [];
@@ -9737,6 +10051,19 @@ export declare function settleSessionInputWait(db: Database, input: {
9737
10051
  waitTurnId: string;
9738
10052
  disposition: "held" | "timeout" | "superseded";
9739
10053
  }): Promise<SettleSessionInputWaitResult>;
10054
+ /** Park only the exact pre-dispatch snapshot; late failures cannot block new work. */
10055
+ export declare function blockSessionWorkBeforeAttemptClaim(db: Database, workspaceId: string, input: {
10056
+ accountId: string;
10057
+ sessionId: string;
10058
+ workflowId: string;
10059
+ attemptId: string;
10060
+ fence: SessionAdmissionFence;
10061
+ reason: StoredSessionAdmissionBlock["reason"];
10062
+ sqlState: string | null;
10063
+ }): Promise<{
10064
+ action: "blocked" | "stale" | "terminal";
10065
+ events: SessionEvent[];
10066
+ }>;
9740
10067
  export type FailSessionWorkBeforeAttemptClaimInput = {
9741
10068
  accountId: string;
9742
10069
  sessionId: string;
@@ -10126,6 +10453,7 @@ export type SessionSystemUpdateOutboxDelivery = {
10126
10453
  payload: ChildLifecycleOutboxPayload;
10127
10454
  lineage: Record<string, unknown>;
10128
10455
  personalConnectionDelegations: McpPersonalConnectionDelegation[];
10456
+ mcpAccountBindings: McpConnectionAccountBinding[] | null;
10129
10457
  xaiProviderAccountAuthoritySnapshot: XaiProviderAccountAuthoritySnapshotV1;
10130
10458
  };
10131
10459
  /** Narrow an outbox row back to its correlated typed kind/payload input variant. */
@@ -10224,7 +10552,7 @@ export type SessionWorkflowWakeDeliveryResult = {
10224
10552
  action: "acknowledged";
10225
10553
  } | {
10226
10554
  action: "pending_admission";
10227
- blocker: "pending_agent_steer" | "pending_prompt_turn" | "pending_quiescence" | "pending_machine_input" | "pending_input_wait";
10555
+ blocker: "pending_agent_steer" | "pending_prompt_turn" | "pending_quiescence" | "pending_machine_input" | "pending_input_wait" | "session_unavailable";
10228
10556
  };
10229
10557
  export declare function markSessionWorkflowWakeDelivered(db: Database, input: Omit<SessionWorkflowWake, "interruptionRequested">): Promise<SessionWorkflowWakeDeliveryResult>;
10230
10558
  /** Record delivery failure; the claim already scheduled the bounded retry. */
@@ -10251,6 +10579,7 @@ export type AddSessionSystemUpdateInput = {
10251
10579
  summary: string;
10252
10580
  lineage?: Record<string, unknown>;
10253
10581
  personalConnectionDelegations?: McpPersonalConnectionDelegation[];
10582
+ mcpAccountBindings?: McpConnectionAccountBinding[] | null;
10254
10583
  xaiProviderAccountAuthoritySnapshot?: XaiProviderAccountAuthoritySnapshotV1;
10255
10584
  scheduledTaskRunId?: string | null;
10256
10585
  } & SessionSystemUpdateInputVariant;
@@ -10499,16 +10828,26 @@ export declare function appendSessionEventsWithLockedSessionUpdate(db: Database,
10499
10828
  lockParentSession?: boolean;
10500
10829
  }): Promise<SessionEvent[]>;
10501
10830
  export declare function sessionSubject(workspaceId: string, sessionId: string): string;
10502
- export declare function buildCodexTokenResolver(db: Database, settings: Settings, workspaceId: string, credentialId: string, deps?: CodexAuthDeps): ReturnType<typeof buildCodexTokenResolverCore>;
10503
- export declare function fetchCodexUsageForAccount(db: Database, settings: Settings, workspaceId: string, credentialId: string, fetchImpl?: CodexFetch): ReturnType<typeof fetchCodexUsageForAccountCore>;
10831
+ /**
10832
+ * Unions a workspace's configured approval policy with a global catalog row's
10833
+ * mandated floor, so `enableCapability`'s ordinary config override can only
10834
+ * ADD approval requirements beyond a curated minimum, never remove one -
10835
+ * closing the gap where a bare `??` let a workspace-supplied `false` or a
10836
+ * narrower array silently erase a reviewed row's mandate (e.g. Gmail's
10837
+ * approval-gated send tools). `true` on either side is maximal. Applies only
10838
+ * to global rows (`workspaceId === null`): a workspace's own custom MCP
10839
+ * registration owns its policy outright, with no OpenGeni-reviewed floor to
10840
+ * protect.
10841
+ */
10842
+ export declare function requireApprovalWithFloor(rawConfigValue: unknown, rawMetadataValue: unknown, isGlobalRow: boolean): SessionMcpApprovalPolicy | undefined;
10843
+ export declare function buildCodexTokenResolver(db: Database, settings: Settings, workspaceId: string, credentialId: string, deps?: CodexAuthDeps, authority?: CodexAcceptedLeaseAuthority): ReturnType<typeof buildCodexTokenResolverCore>;
10844
+ export declare function fetchCodexUsageForAccount(db: Database, settings: Settings, workspaceId: string, credentialId: string, fetchImpl?: CodexFetch, acceptedTurnId?: string): ReturnType<typeof fetchCodexUsageForAccountCore>;
10504
10845
  export declare function fetchCodexRateLimitResetCreditsForAccount(db: Database, settings: Settings, workspaceId: string, credentialId: string, fetchImpl?: CodexFetch): ReturnType<typeof fetchCodexRateLimitResetCreditsForAccountCore>;
10505
10846
  export declare function buildConnectionTokenResolver(db: Database, settings: Settings, deps?: ConnectionBrokerDeps, options?: ConnectionTokenResolverOptions): ReturnType<typeof buildConnectionTokenResolverCore>;
10506
10847
  export { withCodexTokenDeadline, type CodexAccountUsageSnapshot, type CodexAuthDeps, type CodexCredentialCooldownKind, type CodexCredentialForRun, type CodexCredentialTokens, type CodexRateLimitResetCreditsAccountResult, type CodexTokenDeadlineClock, type CodexTokenDeadlineOptions, } from "./codex-token-resolver.js";
10507
- export { buildHostConnectionTokenResolver, buildHostGatewayConnectionTokenResolver, ConnectionRefreshHttpError, HostMcpCredentialBindingError, HostMcpCredentialScopeError, isPrivateAddress, normalizeBearerScheme, refreshOAuthConnectionCredential, type ConnectionBrokerDeps, type ConnectionCredentialForBroker, type ConnectionCredentialLookupInput, type ConnectionStatusGuard, type ConnectionTokenRefreshInput, type ConnectionTokenResolverOptions, type HostMcpCredentialResolverContext, type PermanentConnectionRefreshFailure, type RefreshTransportOptions, type ResolveConnectionCredentialInput, type ResolveConnectionCredentialResult, } from "./connection-token-resolver.js";
10848
+ export { ConnectionRefreshHttpError, isPrivateAddress, normalizeBearerScheme, refreshOAuthConnectionCredential, type ConnectionBrokerDeps, type ConnectionCredentialForBroker, type ConnectionCredentialLookupInput, type ConnectionStatusGuard, type ConnectionTokenRefreshInput, type ConnectionTokenResolverOptions, type PermanentConnectionRefreshFailure, type RefreshTransportOptions, type ResolveConnectionCredentialInput, type ResolveConnectionCredentialResult, } from "./connection-token-resolver.js";
10508
10849
  export { CapabilityComponentVersionConflictError, cleanupOrphanedCapabilityComponents, effectiveCapabilityOwnerSql, type CapabilityComponentOwnerIdentity, } from "./capability-components.js";
10509
- export { adoptPackComponentReferences, finalizePackComponentOwnership, listPackInstallationComponents, PackComponentResolutionError, previewPackComponentRelease, recordPackInlineSkillComponent, releasePackComponents, resolvePackComponentReferences, resolvePackInlineSkillReferences, type PackInlineSkillRequirement, type StoredPackInstallationComponent, } from "./pack-components.js";
10510
- export { deferPackInstallationOperation, finalizePackInstallationOperation, finalizePackUninstallOperation, PackManifestChangedError, PackOperationClaimLostError, PackOperationInProgressError, PackInstallationVersionConflictError, PackInstallationVersionRequiredError, PackOperationIdempotencyError, preparePackInstallationOperation, preparePackUninstallOperation, touchPackInstallationOperation, type PreparedPackInstallation, } from "./pack-installations.js";
10511
- 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";
10850
+ export { checkpointPluginPackageOperation, deferPluginPackageOperation, finalizePluginPackageInstall, getInstalledPluginPackage, getPluginPackageUninstallPreview, PluginUninstallPreviewChangedError, installPluginMcpReference, listInstalledPluginPackages, PluginInstallationVersionConflictError, PluginInstallationVersionRequiredError, PluginOperationIdempotencyError, preparePluginPackageInstall, uninstallPluginPackage, type InstalledPluginPackage, type InstalledPluginPackageSummary, type PluginBomComponent, type PreparedPluginPackage, } from "./plugin-packages.js";
10512
10851
  export * from "./workspace-artifacts.js";
10513
10852
  export * from "./mcp-oauth.js";
10514
10853
  export * from "./tool-gateway-approvals.js";
@@ -10542,4 +10881,34 @@ export declare function listDueWorkspacePauseTimers(db: Database, limit?: number
10542
10881
  export * from "./feedback.js";
10543
10882
  export * from "./knowledge-entries.js";
10544
10883
  export * from "./knowledge-indexing.js";
10884
+ import type { ConnectorToolPermission } from "@opengeni/contracts";
10545
10885
  export * from "./knowledge-document-preparation.js";
10886
+ export declare function listConnectorToolPermissionPolicies(db: Database, input: {
10887
+ accountId: string;
10888
+ workspaceId: string;
10889
+ connectionId: string;
10890
+ }): Promise<{
10891
+ id: string;
10892
+ accountId: string;
10893
+ workspaceId: string;
10894
+ connectionId: string;
10895
+ serverId: string;
10896
+ toolName: string;
10897
+ actionName: string;
10898
+ policy: schema.ConnectorActionPolicyDecision;
10899
+ version: number;
10900
+ createdBySubjectId: string;
10901
+ updatedBySubjectId: string;
10902
+ createdAt: Date;
10903
+ updatedAt: Date;
10904
+ }[]>;
10905
+ /** All tools in a group change together, and never exceed the attempt snapshot bound. */
10906
+ export declare function updateConnectorToolPermissionPolicies(db: Database, input: {
10907
+ accountId: string;
10908
+ workspaceId: string;
10909
+ subjectId: string;
10910
+ connectionId: string;
10911
+ serverId: string;
10912
+ toolNames: string[];
10913
+ policy: ConnectorToolPermission;
10914
+ }): Promise<void>;