@opengeni/db 4.2.2 → 4.3.2-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 (103) hide show
  1. package/dist/canonical-human-identities.js +3 -3
  2. package/dist/{chunk-S4Y42VSX.js → chunk-AI4NC6XW.js} +212 -7
  3. package/dist/chunk-AI4NC6XW.js.map +1 -0
  4. package/dist/{chunk-SNLIKELL.js → chunk-DVSLOUEI.js} +2 -2
  5. package/dist/{chunk-6GAPAYZR.js → chunk-F4BIHJ7J.js} +562 -86
  6. package/dist/chunk-F4BIHJ7J.js.map +1 -0
  7. package/dist/{chunk-B2KR3TEM.js → chunk-I4ITNMX2.js} +2 -2
  8. package/dist/{chunk-MGVOYVPS.js → chunk-PFBUHOI5.js} +3 -3
  9. package/dist/{chunk-6Y7ZDVJ5.js → chunk-UUPY6IGP.js} +2 -2
  10. package/dist/{chunk-FPTI4NP4.js → chunk-UVBPOGA7.js} +2 -2
  11. package/dist/{chunk-7WX3R3YL.js → chunk-XBXANJQS.js} +7 -2
  12. package/dist/chunk-XBXANJQS.js.map +1 -0
  13. package/dist/{chunk-6IQ4X35Y.js → chunk-YVYBAWBU.js} +46 -1
  14. package/dist/chunk-YVYBAWBU.js.map +1 -0
  15. package/dist/connect-attempts.d.ts +60 -0
  16. package/dist/connection-setup-authority.d.ts +10 -0
  17. package/dist/connection-token-resolver.d.ts +11 -2
  18. package/dist/editable-artifact-durable-export.js +2 -2
  19. package/dist/editable-artifacts.js +3 -3
  20. package/dist/external-identities.d.ts +16 -0
  21. package/dist/external-identity-links.d.ts +74 -0
  22. package/dist/external-link-work.d.ts +51 -0
  23. package/dist/host-mcp-binding-match.d.ts +5 -0
  24. package/dist/host-mcp-bindings.d.ts +73 -0
  25. package/dist/host-mcp-task-authority.d.ts +47 -0
  26. package/dist/host-selection-identity.d.ts +6 -0
  27. package/dist/index.d.ts +60 -35
  28. package/dist/index.js +15247 -13793
  29. package/dist/index.js.map +1 -1
  30. package/dist/live-session-attempt.d.ts +275 -0
  31. package/dist/managed-auth-session-sets.js +3 -3
  32. package/dist/memory-domain.d.ts +3 -3
  33. package/dist/provision-roles.js +1 -1
  34. package/dist/retained-provider-commands.js +2 -2
  35. package/dist/runtime-posture.d.ts +6 -6
  36. package/dist/scheduled-task-revision-authority.d.ts +11 -0
  37. package/dist/schema.d.ts +1279 -9
  38. package/dist/schema.js +11 -1
  39. package/dist/session-background-commands.js +4 -4
  40. package/dist/session-command-output.js +4 -4
  41. package/dist/session-event-slices.js +2 -2
  42. package/dist/session-queue-commands.d.ts +7 -0
  43. package/dist/session-tenancy.d.ts +2 -0
  44. package/dist/session-tenancy.js +3 -3
  45. package/dist/video-generation.js +3 -3
  46. package/dist/workspace-authority.d.ts +4 -4
  47. package/dist/workspace-tool-defaults.js +4 -4
  48. package/drizzle/0437_organization_scoped_external_workspaces.sql +71 -0
  49. package/drizzle/0438_durable_connect_attempts.sql +95 -0
  50. package/drizzle/0439_external_identity_provisioning.sql +128 -0
  51. package/drizzle/0440_external_workspace_member_removal.sql +59 -0
  52. package/drizzle/0441_external_identity_membership_lifecycle.sql +163 -0
  53. package/drizzle/0442_external_owning_user_authority.sql +81 -0
  54. package/drizzle/0443_host_mcp_binding_registry.sql +93 -0
  55. package/drizzle/0444_host_mcp_delegations.sql +129 -0
  56. package/drizzle/0445_host_mcp_turn_authorities.sql +145 -0
  57. package/drizzle/0446_host_mcp_causal_continuation.sql +126 -0
  58. package/drizzle/0447_host_mcp_task_authorities.sql +264 -0
  59. package/drizzle/0448_host_mcp_child_authority.sql +115 -0
  60. package/drizzle/0449_external_identity_link_lifecycle.sql +107 -0
  61. package/drizzle/0450_external_identity_link_work.sql +179 -0
  62. package/drizzle/0451_external_link_preview_and_permission_ceiling.sql +82 -0
  63. package/drizzle/0452_external_link_scheduled_origin.sql +34 -0
  64. package/drizzle/0453_host_mcp_native_owner.sql +35 -0
  65. package/drizzle/0454_connect_origin_authority.sql +42 -0
  66. package/drizzle/0455_external_link_inventory_labels.sql +44 -0
  67. package/drizzle/0456_social_connection_versions.sql +14 -0
  68. package/drizzle/0457_canonical_session_scope_subject.sql +46 -0
  69. package/drizzle/0458_skill_review_wire_compatibility.sql +36 -0
  70. package/package.json +6 -6
  71. package/src/connect-attempts.ts +317 -0
  72. package/src/connection-authority.ts +9 -0
  73. package/src/connection-setup-authority.ts +35 -0
  74. package/src/connection-token-resolver.ts +177 -48
  75. package/src/external-identities.ts +70 -0
  76. package/src/external-identity-links.ts +364 -0
  77. package/src/external-link-work.ts +228 -0
  78. package/src/host-mcp-binding-match.ts +33 -0
  79. package/src/host-mcp-bindings.ts +741 -0
  80. package/src/host-mcp-task-authority.ts +383 -0
  81. package/src/host-selection-identity.ts +29 -0
  82. package/src/index.ts +481 -151
  83. package/src/live-session-attempt.ts +85 -0
  84. package/src/managed-human-provisioning.ts +6 -1
  85. package/src/memory-domain.ts +6 -11
  86. package/src/provision-roles.ts +3 -0
  87. package/src/runtime-posture.ts +47 -0
  88. package/src/scheduled-task-revision-authority.ts +30 -0
  89. package/src/schema.ts +233 -7
  90. package/src/session-control.ts +14 -0
  91. package/src/session-queue-commands.ts +11 -0
  92. package/src/session-tenancy.ts +7 -0
  93. package/src/workspace-artifacts.ts +10 -4
  94. package/src/workspace-authority.ts +5 -5
  95. package/dist/chunk-6GAPAYZR.js.map +0 -1
  96. package/dist/chunk-6IQ4X35Y.js.map +0 -1
  97. package/dist/chunk-7WX3R3YL.js.map +0 -1
  98. package/dist/chunk-S4Y42VSX.js.map +0 -1
  99. /package/dist/{chunk-SNLIKELL.js.map → chunk-DVSLOUEI.js.map} +0 -0
  100. /package/dist/{chunk-B2KR3TEM.js.map → chunk-I4ITNMX2.js.map} +0 -0
  101. /package/dist/{chunk-MGVOYVPS.js.map → chunk-PFBUHOI5.js.map} +0 -0
  102. /package/dist/{chunk-6Y7ZDVJ5.js.map → chunk-UUPY6IGP.js.map} +0 -0
  103. /package/dist/{chunk-FPTI4NP4.js.map → chunk-UVBPOGA7.js.map} +0 -0
package/dist/index.d.ts CHANGED
@@ -4,8 +4,16 @@ export * from "./model-connection-access.js";
4
4
  import { type BundledSkillId } from "@opengeni/contracts";
5
5
  import { type SkillSourceReleaseReceipt } from "./skill-source-release.js";
6
6
  import type { SkillActor, SkillWriteReceipt } from "@opengeni/contracts";
7
+ import { type HostMcpCreateSelection } from "./host-selection-identity.js";
8
+ export * from "./connect-attempts.js";
9
+ export * from "./external-identities.js";
10
+ export * from "./external-identity-links.js";
11
+ export * from "./connection-setup-authority.js";
12
+ export * from "./external-link-work.js";
13
+ export * from "./host-mcp-bindings.js";
14
+ export * from "./host-mcp-task-authority.js";
7
15
  import { type ChildLifecycleSystemUpdateKind, type ChildRequiresActionRespondedByKind, SessionGoalSnapshot } from "@opengeni/contracts";
8
- 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, SessionAgentAccess, SessionAgentAccessViewer, SessionAuthorizationListScope, SessionEndUser, 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, 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";
16
+ 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, 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, 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";
9
17
  import { type WorkspaceArchiveObjectRef, RequestHumanInteractionToolInput, XaiProviderAccountAuthoritySnapshotV1, type TimelineAnnotation } from "@opengeni/contracts";
10
18
  import { type LatencyMode, SessionSystemUpdatePayload, TurnExecutionPolicyV1, CodexCredentialPolicySnapshotV1 } from "@opengeni/contracts";
11
19
  import { type Settings } from "@opengeni/config";
@@ -84,6 +92,7 @@ export * from "./model-catalog.js";
84
92
  import { type Database, type SessionActivityDatabase } from "./database.js";
85
93
  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";
86
94
  export { withSessionRlsActorContext } from "./database.js";
95
+ export { normalizedHostCredentialHeaders } from "./connection-token-resolver.js";
87
96
  import { buildCodexTokenResolver as buildCodexTokenResolverCore, fetchCodexRateLimitResetCreditsForAccount as fetchCodexRateLimitResetCreditsForAccountCore, fetchCodexUsageForAccount as fetchCodexUsageForAccountCore, type CodexAccountUsageSnapshot, type CodexAuthDeps, type CodexCredentialCooldownKind, type CodexCredentialForRun } from "./codex-token-resolver.js";
88
97
  import { buildConnectionTokenResolver as buildConnectionTokenResolverCore, type ConnectionBrokerDeps, type ConnectionCredentialForBroker, type ConnectionTokenResolverOptions } from "./connection-token-resolver.js";
89
98
  /** Raised when a durable session tool-policy write lost its version fence. */
@@ -348,6 +357,7 @@ export declare class WorkspaceExternalIdentityConflictError extends Error {
348
357
  constructor();
349
358
  }
350
359
  export declare function findWorkspaceByExternalIdentity(db: Database, input: {
360
+ accountId: string;
351
361
  externalSource: string;
352
362
  externalId: string;
353
363
  }): Promise<Workspace | null>;
@@ -357,7 +367,7 @@ export declare class WorkspaceLimitExceededError extends Error {
357
367
  }
358
368
  /**
359
369
  * Create an organization workspace exactly once for a stable external tenant
360
- * identity. The global unique index is the concurrency arbiter. A replay never
370
+ * identity. The organization-scoped unique index is the concurrency arbiter. A replay never
361
371
  * mutates presentation fields supplied by the original create.
362
372
  */
363
373
  export declare function ensureWorkspaceByExternalIdentity(db: Database, input: {
@@ -858,10 +868,7 @@ export type AppendEventInput = {
858
868
  */
859
869
  export type ScheduledTaskCreatorSessionPolicy = {
860
870
  agentAccess: string | null;
861
- endUser: {
862
- source: string;
863
- id: string;
864
- } | null;
871
+ scopeSubjectId: string | null;
865
872
  memoryScope: string | null;
866
873
  };
867
874
  /**
@@ -901,6 +908,8 @@ export type CreateScheduledTaskInput = {
901
908
  metadata: Record<string, unknown>;
902
909
  /** Trusted database-only admission seam. Throwing rolls the task creation back. */
903
910
  beforeCreateCommit?: (tx: Database) => Promise<void>;
911
+ captureHostAuthority?: (tx: Database, task: ScheduledTask) => Promise<void>;
912
+ captureLinkAuthority?: (tx: Database, task: ScheduledTask) => Promise<void>;
904
913
  };
905
914
  export type UpdateScheduledTaskInput = Partial<{
906
915
  name: string;
@@ -924,6 +933,8 @@ export type UpdateScheduledTaskInput = Partial<{
924
933
  authorityUpdatedByActor: AgentSessionCreationActor | null;
925
934
  /** Trusted database-only admission seam. Throwing rolls the task update back. */
926
935
  beforeUpdateCommit: (tx: Database) => Promise<void>;
936
+ captureHostAuthority: (tx: Database, task: ScheduledTask) => Promise<void>;
937
+ captureLinkAuthority: (tx: Database, task: ScheduledTask) => Promise<void>;
927
938
  }>;
928
939
  export type CreatePackInstallationInput = {
929
940
  accountId: string;
@@ -1000,6 +1011,10 @@ export type CreateSocialConnectionInput = {
1000
1011
  metadata?: Record<string, unknown>;
1001
1012
  };
1002
1013
  export type UpsertSocialOAuthConnectionInput = {
1014
+ expectedConnection?: {
1015
+ id: string;
1016
+ version: number;
1017
+ };
1003
1018
  accountId: string;
1004
1019
  workspaceId: string;
1005
1020
  subjectId?: string | null;
@@ -1103,6 +1118,8 @@ export type UpdateConnectionInput = {
1103
1118
  updatedBySubjectId?: string | null;
1104
1119
  };
1105
1120
  export type PersistProviderOAuthConnectionInput = CreateConnectionInput & {
1121
+ /** Server continuation reauthorization; runs inside the credential transaction. */
1122
+ authorize?: (tx: Database) => Promise<void>;
1106
1123
  visibleToSubjectId: string;
1107
1124
  credentialRole: string;
1108
1125
  providerFamily: string;
@@ -2977,16 +2994,7 @@ export declare function getScheduledTaskRevisionAuthoritySubject(db: Database, i
2977
2994
  taskId: string;
2978
2995
  taskAuthorityRevision: number;
2979
2996
  }): Promise<string | null>;
2980
- export declare function getScheduledTaskRevisionAuthority(db: Database, input: {
2981
- accountId: string;
2982
- workspaceId: string;
2983
- taskId: string;
2984
- taskAuthorityRevision: number;
2985
- }): Promise<{
2986
- subjectId: string;
2987
- organizationMembershipId: string;
2988
- membershipAuthorizationRevision: number;
2989
- } | null>;
2997
+ export { getScheduledTaskRevisionAuthority } from "./scheduled-task-revision-authority.js";
2990
2998
  /** Failure settlement must not rewrite a source already committed as dispatched. */
2991
2999
  export declare function markScheduledTaskRunFailedIfQueued(db: Database, workspaceId: string, runId: string, error: string): Promise<void>;
2992
3000
  export type FailScheduledGeneratedSessionRouteResult = {
@@ -5097,13 +5105,15 @@ export type SessionCreateInput = {
5097
5105
  /** Agent-to-agent reach (migration 0427); omitted means the workspace default. */
5098
5106
  agentAccess?: SessionAgentAccess;
5099
5107
  /** Opaque end-user label; omitted or null means none. */
5100
- endUser?: SessionEndUser | null;
5108
+ scopeSubjectId?: SessionScopeSubjectId | null;
5101
5109
  /** Typed Memory selector (migration 0427); omitted means the workspace layer. */
5102
5110
  memoryScope?: SessionMemoryScope;
5103
5111
  parentSessionId?: string | null;
5104
5112
  createIdempotencyKey?: string | null;
5105
5113
  /** Exact explicit installed-Skill selection used for keyed-create replay. */
5106
5114
  selectedInstalledSkillIds?: string[];
5115
+ /** Backend-only replay identity; does not admit host credential authority. */
5116
+ selectedHostMcpDelegations?: HostMcpCreateSelection[];
5107
5117
  sandboxGroupId?: string | null;
5108
5118
  sandboxOs?: SandboxOs;
5109
5119
  /** Exact accepted generated-session compaction policy; internal lifecycle callers only. */
@@ -5185,6 +5195,7 @@ export declare function getInitializedSessionCreateReplay(db: Database, input: {
5185
5195
  visibility?: "user_private" | "workspace_shared";
5186
5196
  variableSetIds: string[];
5187
5197
  selectedInstalledSkillIds: string[];
5198
+ selectedHostMcpDelegations?: HostMcpCreateSelection[];
5188
5199
  initialPersonalResourceAttachmentIntent?: PersonalResourceAttachmentIntent | null;
5189
5200
  deferInitialTurn?: boolean;
5190
5201
  }): Promise<InitializedSessionCreateReplay | null>;
@@ -5225,7 +5236,7 @@ export type SessionAccessProjection = {
5225
5236
  sessionId: string;
5226
5237
  rootSessionId: string;
5227
5238
  agentAccess: SessionAgentAccess;
5228
- endUser: SessionEndUser | null;
5239
+ scopeSubjectId: SessionScopeSubjectId | null;
5229
5240
  memoryScope: SessionMemoryScope;
5230
5241
  };
5231
5242
  export type SessionAuthorityProjection = SessionAccessProjection & {
@@ -5237,12 +5248,16 @@ export declare function getSessionAuthorityProjection(db: Database, workspaceId:
5237
5248
  export declare function getSessionAccessProjection(db: Database, workspaceId: string, sessionId: string): Promise<SessionAccessProjection | null>;
5238
5249
  /**
5239
5250
  * The typed Memory selector an agent on this session reads and writes. The
5240
- * end-user subject is the opaque `end_user:v1:<tuple hash>` label and the
5241
- * session selector is the lineage root, so one tree shares one private layer.
5251
+ * user subject comes from the verified active execution, not a conversation
5252
+ * label or its original creator. Task notes own temporary tree-local data.
5242
5253
  * Null when the session does not exist in the workspace.
5243
5254
  */
5244
- export declare function resolveSessionMemoryAgentScope(db: Database, workspaceId: string, sessionId: string): Promise<MemoryAgentScope | null>;
5245
- export declare function memoryAgentScopeForSessionAccess(access: Pick<SessionAccessProjection, "rootSessionId" | "endUser" | "memoryScope">): MemoryAgentScope;
5255
+ export declare function resolveSessionMemoryAgentScope(db: Database, workspaceId: string, sessionId: string, caller?: {
5256
+ turnId?: unknown;
5257
+ attemptId?: unknown;
5258
+ executionGeneration?: unknown;
5259
+ }): Promise<MemoryAgentScope | null>;
5260
+ export declare function memoryAgentScopeForSessionAccess(access: Pick<SessionAccessProjection, "rootSessionId" | "scopeSubjectId" | "memoryScope">): MemoryAgentScope;
5246
5261
  export declare function getSessionTurnXaiProviderAccountAuthoritySnapshot(db: Database, workspaceId: string, sessionId: string, turnId: string): Promise<XaiProviderAccountAuthoritySnapshotV1>;
5247
5262
  export declare function getSessionTurnPersonalConnectionDelegations(db: Database, workspaceId: string, sessionId: string, turnId: string): Promise<McpPersonalConnectionDelegation[]>;
5248
5263
  export declare function getSessionParentPersonalConnectionDelegations(db: Database, workspaceId: string, childSessionId: string): Promise<McpPersonalConnectionDelegation[]>;
@@ -5327,7 +5342,7 @@ export type SessionListFilterOptions = {
5327
5342
  /** Exclusive creation upper bound. */
5328
5343
  createdBefore?: Date;
5329
5344
  /** Exact opaque end-user label pair (both parts). */
5330
- endUser?: SessionEndUser;
5345
+ scopeSubjectId?: SessionScopeSubjectId;
5331
5346
  };
5332
5347
  export type ListSessionsForSubjectOptions = ListSessionsOptions & SessionListFilterOptions & {
5333
5348
  subjectId: string;
@@ -5355,13 +5370,13 @@ export type ListSessionsForSubjectOptions = ListSessionsOptions & SessionListFil
5355
5370
  *
5356
5371
  * **This flag is the authorization.** The resolver it gates is not: it answers
5357
5372
  * "does subject X hold authority here" and establishes nothing about who the
5358
- * caller is. The exception is for "the canonical managed-cookie (Better Auth)
5359
- * session" only "Bearer/delegated principals, API keys, and account or
5360
- * organization administrators receive no personal-workspace access through that
5361
- * exception" — and a host-signed delegated bearer chooses its own `subjectId`,
5373
+ * caller is. The exception requires verified native-cookie or dedicated
5374
+ * external owning-user provenance. Unscoped service keys and account or
5375
+ * organization administrators receive no Personal access through it.
5376
+ * A host-signed delegated bearer chooses its own `subjectId`,
5362
5377
  * `principalKind`, `metadata.delegated`, and `serviceInitiator` claims, so no
5363
5378
  * inspection of the grant can carry that distinction. Set this ONLY from
5364
- * `AccessGrantAuthorization.canonicalManagedHumanSession` (`@opengeni/core`),
5379
+ * `hasVerifiedOwningUserAuthorization` (`@opengeni/core`),
5365
5380
  * which reflects HOW the request authenticated. Omitted/false keeps the
5366
5381
  * historical bare-membership fence exactly.
5367
5382
  */
@@ -5419,12 +5434,9 @@ export declare function sessionTreeStatsForSessions(db: Database, workspaceId: s
5419
5434
  export declare function sessionRequiresActionSinceForSessions(db: Database, workspaceId: string, sessionIds: readonly string[]): Promise<Map<string, string>>;
5420
5435
  /**
5421
5436
  * The agent-access predicate for one calling attempt (migration 0427). It
5422
- * mirrors the pairwise rule in the core seam exactly: a caller always keeps
5423
- * its own root tree; a `session` caller sees nothing else; a `user` caller
5424
- * additionally sees non-`session` sessions carrying its own end-user label; a
5425
- * `workspace` caller additionally sees every `workspace` session and the
5426
- * `user` sessions carrying its own label. A caller without a label can never
5427
- * match a labelled `user` session.
5437
+ * mirrors outgoing reach in the core seam: own tree, same canonical user, or
5438
+ * workspace. Target task scope never hides the conversation. This predicate
5439
+ * remains intersected with host scope and ordinary private-session visibility.
5428
5440
  */
5429
5441
  export declare function sessionAgentAccessViewerFilter(viewer: SessionAgentAccessViewer): SQL;
5430
5442
  /**
@@ -8100,6 +8112,13 @@ export type LegacyModalCheckpointAdoptionTarget = Omit<LegacyModalCheckpointSlot
8100
8112
  * an unreferenced candidate that GC might delete while the legacy slot still
8101
8113
  * depends on that provider object. */
8102
8114
  export declare function adoptLegacyModalCheckpointArtifact(db: Database, input: LegacyModalCheckpointAdoptionTarget): Promise<boolean>;
8115
+ /** Object-candidate outcome from the publication transaction, independent of
8116
+ * lifecycle `wrote`. Absent for inline/provider receipts and pure CAS checks.
8117
+ * `unused` is NOT a retirement receipt: only the owner of a fresh candidate with
8118
+ * no other publication in flight may use it for immediate cleanup. Exceptions
8119
+ * give no disposition (commit may have happened). Legacy/shared keys and evicted
8120
+ * refs need durable no-reattachment evidence before deletion. */
8121
+ export type WorkspaceArchiveCandidateDisposition = "adopted" | "already_referenced" | "unused";
8103
8122
  export declare function persistDrainSnapshot(db: Database, input: {
8104
8123
  accountId: string;
8105
8124
  workspaceId: string;
@@ -8130,6 +8149,7 @@ export declare function persistDrainSnapshot(db: Database, input: {
8130
8149
  })): Promise<{
8131
8150
  wrote: boolean;
8132
8151
  archiveRevision: string | null;
8152
+ candidateDisposition?: WorkspaceArchiveCandidateDisposition;
8133
8153
  }>;
8134
8154
  /**
8135
8155
  * The ONE archive-fold write, shared by the drain seam (persistDrainSnapshot)
@@ -8201,6 +8221,7 @@ export declare function persistWarmSnapshot(db: Database, input: {
8201
8221
  throttled: boolean;
8202
8222
  superseded: boolean;
8203
8223
  archiveRevision: string | null;
8224
+ candidateDisposition?: WorkspaceArchiveCandidateDisposition;
8204
8225
  }>;
8205
8226
  export declare function getMaterializedSandboxFileResources(db: Database, input: {
8206
8227
  accountId: string;
@@ -9429,6 +9450,10 @@ export type InitializeSessionStartInput = {
9429
9450
  /** Trusted create-session policy. Omitted only by legacy low-level callers. */
9430
9451
  turnExecutionPolicy?: TurnExecutionPolicyV1;
9431
9452
  createdEventPayload: Record<string, unknown>;
9453
+ /** Trusted backend-only capture for a newly inserted initial turn. Runs under
9454
+ * the canonical activity transaction; failure rolls back events and turn.
9455
+ * Never invoked on replay or deferred starts; not caller JSON authority. */
9456
+ captureInitialTurnAuthority?: (tx: Database, turnId: string) => Promise<void>;
9432
9457
  /** Sensitive-safe semantic title supplied by the trusted agent-child create
9433
9458
  * path. It is committed with the initial timeline, never as a bare row edit. */
9434
9459
  initialAutomaticTitle?: string | null;
@@ -10461,7 +10486,7 @@ export declare function fetchCodexUsageForAccount(db: Database, settings: Settin
10461
10486
  export declare function fetchCodexRateLimitResetCreditsForAccount(db: Database, settings: Settings, workspaceId: string, credentialId: string, fetchImpl?: CodexFetch): ReturnType<typeof fetchCodexRateLimitResetCreditsForAccountCore>;
10462
10487
  export declare function buildConnectionTokenResolver(db: Database, settings: Settings, deps?: ConnectionBrokerDeps, options?: ConnectionTokenResolverOptions): ReturnType<typeof buildConnectionTokenResolverCore>;
10463
10488
  export { withCodexTokenDeadline, type CodexAccountUsageSnapshot, type CodexAuthDeps, type CodexCredentialCooldownKind, type CodexCredentialForRun, type CodexCredentialTokens, type CodexRateLimitResetCreditsAccountResult, type CodexTokenDeadlineClock, type CodexTokenDeadlineOptions, } from "./codex-token-resolver.js";
10464
- export { buildHostConnectionTokenResolver, 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";
10489
+ 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";
10465
10490
  export { CapabilityComponentVersionConflictError, cleanupOrphanedCapabilityComponents, effectiveCapabilityOwnerSql, type CapabilityComponentOwnerIdentity, } from "./capability-components.js";
10466
10491
  export { adoptPackComponentReferences, finalizePackComponentOwnership, listPackInstallationComponents, PackComponentResolutionError, previewPackComponentRelease, recordPackInlineSkillComponent, releasePackComponents, resolvePackComponentReferences, resolvePackInlineSkillReferences, type PackInlineSkillRequirement, type StoredPackInstallationComponent, } from "./pack-components.js";
10467
10492
  export { deferPackInstallationOperation, finalizePackInstallationOperation, finalizePackUninstallOperation, PackManifestChangedError, PackOperationClaimLostError, PackOperationInProgressError, PackInstallationVersionConflictError, PackInstallationVersionRequiredError, PackOperationIdempotencyError, preparePackInstallationOperation, preparePackUninstallOperation, touchPackInstallationOperation, type PreparedPackInstallation, } from "./pack-installations.js";