@opengeni/db 4.2.2 → 4.3.0-canary.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (102) hide show
  1. package/dist/canonical-human-identities.js +3 -3
  2. package/dist/{chunk-6GAPAYZR.js → chunk-7JPLGBSA.js} +562 -86
  3. package/dist/chunk-7JPLGBSA.js.map +1 -0
  4. package/dist/{chunk-SNLIKELL.js → chunk-IHADTE7C.js} +2 -2
  5. package/dist/{chunk-7WX3R3YL.js → chunk-ILKJKDII.js} +7 -2
  6. package/dist/chunk-ILKJKDII.js.map +1 -0
  7. package/dist/{chunk-MGVOYVPS.js → chunk-NCSPNCQK.js} +3 -3
  8. package/dist/{chunk-B2KR3TEM.js → chunk-SGJDIF2D.js} +2 -2
  9. package/dist/{chunk-S4Y42VSX.js → chunk-Y5XFVJJM.js} +207 -3
  10. package/dist/chunk-Y5XFVJJM.js.map +1 -0
  11. package/dist/{chunk-FPTI4NP4.js → chunk-YGBOVXC7.js} +2 -2
  12. package/dist/{chunk-6Y7ZDVJ5.js → chunk-YGRT6VZO.js} +2 -2
  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 +51 -35
  28. package/dist/index.js +15171 -13775
  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 +398 -147
  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 +228 -3
  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-authority.ts +5 -5
  94. package/dist/chunk-6GAPAYZR.js.map +0 -1
  95. package/dist/chunk-6IQ4X35Y.js.map +0 -1
  96. package/dist/chunk-7WX3R3YL.js.map +0 -1
  97. package/dist/chunk-S4Y42VSX.js.map +0 -1
  98. /package/dist/{chunk-SNLIKELL.js.map → chunk-IHADTE7C.js.map} +0 -0
  99. /package/dist/{chunk-MGVOYVPS.js.map → chunk-NCSPNCQK.js.map} +0 -0
  100. /package/dist/{chunk-B2KR3TEM.js.map → chunk-SGJDIF2D.js.map} +0 -0
  101. /package/dist/{chunk-FPTI4NP4.js.map → chunk-YGBOVXC7.js.map} +0 -0
  102. /package/dist/{chunk-6Y7ZDVJ5.js.map → chunk-YGRT6VZO.js.map} +0 -0
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  nestedPostgresSqlState,
3
3
  rawRows
4
- } from "./chunk-B2KR3TEM.js";
4
+ } from "./chunk-SGJDIF2D.js";
5
5
 
6
6
  // src/canonical-human-identities.ts
7
7
  import { createHash } from "crypto";
@@ -309,4 +309,4 @@ export {
309
309
  getCanonicalHumanIdentityProjection,
310
310
  applyCanonicalHumanIdentityOperation
311
311
  };
312
- //# sourceMappingURL=chunk-SNLIKELL.js.map
312
+ //# sourceMappingURL=chunk-IHADTE7C.js.map
@@ -5,7 +5,7 @@ import {
5
5
  withWorkspaceRls,
6
6
  withWorkspaceSubjectRls,
7
7
  withWorkspaceSubjectSessionActivityRls
8
- } from "./chunk-B2KR3TEM.js";
8
+ } from "./chunk-SGJDIF2D.js";
9
9
 
10
10
  // src/session-tenancy.ts
11
11
  import { createHash } from "crypto";
@@ -288,6 +288,7 @@ async function transitionSessionVisibility(db, input) {
288
288
  );
289
289
  const result = rows[0];
290
290
  if (!result) throw new Error("Session visibility transition returned no result");
291
+ await input.beforeCommit?.(scopedDb);
291
292
  return result;
292
293
  },
293
294
  void 0,
@@ -355,6 +356,7 @@ async function forkSessionContent(db, input) {
355
356
  );
356
357
  const result2 = rows2[0];
357
358
  if (!result2) throw new Error("Session fork returned no result");
359
+ await input.beforeCommit?.(scopedDb);
358
360
  return result2;
359
361
  }
360
362
  const rows = await rawRows(
@@ -387,6 +389,7 @@ async function forkSessionContent(db, input) {
387
389
  );
388
390
  const result = rows[0];
389
391
  if (!result) throw new Error("Session fork returned no result");
392
+ await input.beforeCommit?.(scopedDb);
390
393
  return result;
391
394
  },
392
395
  void 0,
@@ -443,6 +446,7 @@ async function replayAppliedSessionFork(db, input) {
443
446
  ${runtimeDigest}
444
447
  )`
445
448
  );
449
+ await input.beforeCommit?.(scopedDb);
446
450
  return rows2[0] ?? null;
447
451
  }
448
452
  const rows = await rawRows(
@@ -472,6 +476,7 @@ async function replayAppliedSessionFork(db, input) {
472
476
  ${SESSION_TENANCY_ACTIVATION_VERSION}
473
477
  )`
474
478
  );
479
+ await input.beforeCommit?.(scopedDb);
475
480
  return rows[0] ?? null;
476
481
  }
477
482
  );
@@ -497,4 +502,4 @@ export {
497
502
  forkSessionContent,
498
503
  replayAppliedSessionFork
499
504
  };
500
- //# sourceMappingURL=chunk-7WX3R3YL.js.map
505
+ //# sourceMappingURL=chunk-ILKJKDII.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/session-tenancy.ts"],"sourcesContent":["import { createHash } from \"node:crypto\";\nimport { sql } from \"drizzle-orm\";\nimport {\n SessionTenancyBlocker as SessionTenancyBlockerSchema,\n type SessionTenancyBlocker,\n} from \"@opengeni/contracts\";\nimport {\n rawRows,\n type Database,\n rlsContextForWorkspace,\n withWorkspaceRls,\n withWorkspaceSubjectRls,\n withWorkspaceSubjectSessionActivityRls,\n} from \"./database\";\nimport { nestedPostgresSqlState } from \"./persistence-errors\";\n\nconst SESSION_TENANCY_ACTIVATION_VERSION = 1;\n\nexport class SessionTenancyConflictError extends Error {\n readonly name = \"SessionTenancyConflictError\";\n constructor(\n readonly reason: \"not_quiescent\" | \"authority_epoch\" | \"operation_reuse\",\n readonly blocker: SessionTenancyBlocker | null = null,\n options?: ErrorOptions,\n ) {\n super(\n reason === \"not_quiescent\"\n ? \"Session must be fully quiescent before its tenancy can change\"\n : reason === \"authority_epoch\"\n ? \"Session authority changed before the operation committed\"\n : \"Session tenancy operation key was reused with different input\",\n options,\n );\n }\n}\n\nexport class SessionTenancyNotActivatedError extends Error {\n readonly name = \"SessionTenancyNotActivatedError\";\n constructor(options?: ErrorOptions) {\n super(\"Session tenancy product surface is not activated for this organization\", options);\n }\n}\n\nexport class SessionTenancyAccessError extends Error {\n readonly name = \"SessionTenancyAccessError\";\n constructor(options?: ErrorOptions) {\n super(\"Session tenancy target is unavailable\", options);\n }\n}\n\nexport class SessionTenancyInvalidRequestError extends Error {\n readonly name = \"SessionTenancyInvalidRequestError\";\n constructor(options?: ErrorOptions) {\n super(\"Session tenancy request is invalid\", options);\n }\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return Boolean(value && typeof value === \"object\");\n}\n\n/** Extract only the fixed quiescence DETAIL vocabulary, never arbitrary driver detail. */\nexport function nestedSessionTenancyBlocker(error: unknown): SessionTenancyBlocker | null {\n const queue: unknown[] = [error];\n const seen = new Set<unknown>();\n while (queue.length > 0 && seen.size < 64) {\n const current = queue.shift();\n if (!isRecord(current) || seen.has(current)) continue;\n seen.add(current);\n for (const key of [\"detail\", \"detailMessage\"] as const) {\n const parsed = SessionTenancyBlockerSchema.safeParse(current[key]);\n if (parsed.success) return parsed.data;\n }\n for (const key of [\"cause\", \"original\", \"driverError\", \"error\", \"errors\"] as const) {\n const nested = current[key];\n if (Array.isArray(nested)) queue.push(...nested);\n else if (nested !== undefined) queue.push(nested);\n }\n }\n return null;\n}\n\nexport type SessionTenancyVisibility = \"user_private\" | \"workspace_shared\";\n\nexport type PrivateSessionCreatePolicy = {\n personalWorkspace: boolean;\n platformAvailable: boolean;\n organizationEnabled: boolean;\n};\n\nexport type TransitionSessionVisibilityInput = {\n workspaceId: string;\n sessionId: string;\n actorSubjectId: string;\n targetVisibility: SessionTenancyVisibility;\n expectedAuthorityEpoch: number;\n operationKey: string;\n beforeCommit?: (tx: Database) => Promise<void>;\n};\n\nexport type TransitionSessionVisibilityResult = {\n operationId: string;\n eventId: string | null;\n eventSequence: number | null;\n visibility: SessionTenancyVisibility;\n authorityEpoch: number;\n ownerOrganizationMembershipId: string | null;\n changed: boolean;\n replay: boolean;\n interruptedAttemptCount: number;\n cancelledTurnCount: number;\n cancelledUpdateCount: number;\n pausedGoalCount: number;\n revokedGrantCount: number;\n};\n\nexport type ForkSessionContentInput = {\n sourceEventId?: string;\n sourceWorkspaceId: string;\n sourceSessionId: string;\n actorSubjectId: string;\n destinationWorkspaceId: string;\n destinationVisibility: SessionTenancyVisibility;\n workspaceSharedAcknowledged: boolean;\n operationKey: string;\n runtimeRequest?: ForkSessionRuntimeRequest;\n runtimeConfiguration?: ForkSessionRuntimeConfiguration;\n beforeCommit?: (tx: Database) => Promise<void>;\n};\n\nexport type ForkSessionRuntimeRequest = {\n variableSetIds: string[];\n rigId: string | null;\n};\n\nexport type ForkSessionRuntimeConfiguration = ForkSessionRuntimeRequest & {\n rigVersionId: string | null;\n};\n\nexport type ForkSessionContentResult = {\n operationId: string;\n eventId: string;\n eventSequence: number;\n sessionId: string;\n workspaceId: string;\n visibility: SessionTenancyVisibility;\n authorityEpoch: number;\n copiedHistoryItemCount: number;\n replay: boolean;\n runtimeEventId: string | null;\n runtimeEventSequence: number | null;\n};\n\nexport async function sessionTenancyProductActivated(\n db: Database,\n workspaceId: string,\n): Promise<boolean> {\n const { accountId } = await rlsContextForWorkspace(db, workspaceId);\n return await withWorkspaceRls(db, workspaceId, async (scopedDb) => {\n const rows = await rawRows<{ activated: boolean }>(\n scopedDb,\n sql`select session_tenancy_product_activated(\n ${accountId}::uuid,\n ${SESSION_TENANCY_ACTIVATION_VERSION}\n ) as activated`,\n );\n return rows[0]?.activated === true;\n });\n}\n\nexport async function getPrivateSessionCreatePolicy(\n db: Database,\n input: { workspaceId: string; actorSubjectId: string },\n): Promise<PrivateSessionCreatePolicy> {\n const { accountId } = await rlsContextForWorkspace(db, input.workspaceId);\n return await withWorkspaceSubjectRls(\n db,\n input.workspaceId,\n input.actorSubjectId,\n async (scopedDb) => {\n const rows = await rawRows<{\n personalWorkspace: boolean;\n platformAvailable: boolean;\n organizationEnabled: boolean;\n }>(\n scopedDb,\n sql`select\n personal_workspace as \"personalWorkspace\",\n platform_available as \"platformAvailable\",\n organization_enabled as \"organizationEnabled\"\n from get_private_session_create_policy(\n ${accountId}::uuid,\n ${input.workspaceId}::uuid,\n ${input.actorSubjectId}\n )`,\n );\n const policy = rows[0];\n if (!policy) throw new SessionTenancyAccessError();\n return policy;\n },\n );\n}\n\n/** Open the exact transaction-local trigger capability used by atomic private create. */\nexport async function openPrivateSessionCreateCapability(\n db: Database,\n input: { accountId: string; workspaceId: string; sessionId: string; actorSubjectId: string },\n): Promise<{ capabilityId: string; ownerMembershipId: string }> {\n let rows: Array<{ capabilityId: string; ownerMembershipId: string }>;\n try {\n rows = await rawRows<{ capabilityId: string; ownerMembershipId: string }>(\n db,\n sql`select\n capability_id as \"capabilityId\",\n owner_membership_id as \"ownerMembershipId\"\n from open_private_session_create_capability(\n ${input.accountId}::uuid,\n ${input.workspaceId}::uuid,\n ${input.sessionId}::uuid,\n ${input.actorSubjectId}\n )`,\n );\n } catch (error) {\n // The definer raises 55000 only when the organization owner/admin setting\n // does not permit a new private session in this shared workspace; every\n // authority failure remains 42501 and propagates unchanged.\n if (nestedPostgresSqlState(error) === \"55000\") {\n throw new SessionTenancyNotActivatedError({ cause: error });\n }\n throw error;\n }\n const capabilityId = rows[0]?.capabilityId;\n const ownerMembershipId = rows[0]?.ownerMembershipId;\n if (!capabilityId || !ownerMembershipId) {\n throw new Error(\"Private session create capability was not returned\");\n }\n return { capabilityId, ownerMembershipId };\n}\n\n/** Open the exact transaction-local capability for one private child insert. */\nexport async function openPrivateChildSessionCreateCapability(\n db: Database,\n input: {\n accountId: string;\n workspaceId: string;\n sessionId: string;\n parentSessionId: string;\n actorTurnId: string;\n actorAttemptId: string;\n actorExecutionGeneration: number;\n },\n): Promise<{ capabilityId: string; ownerMembershipId: string; ownerSubjectId: string }> {\n const rows = await rawRows<{\n capabilityId: string;\n ownerMembershipId: string;\n ownerSubjectId: string;\n }>(\n db,\n sql`select\n capability_id as \"capabilityId\",\n owner_membership_id as \"ownerMembershipId\",\n owner_subject_id as \"ownerSubjectId\"\n from open_private_child_session_create_capability(\n ${input.accountId}::uuid,\n ${input.workspaceId}::uuid,\n ${input.sessionId}::uuid,\n ${input.parentSessionId}::uuid,\n ${input.actorTurnId}::uuid,\n ${input.actorAttemptId}::uuid,\n ${input.actorExecutionGeneration}::integer\n )`,\n );\n const capabilityId = rows[0]?.capabilityId;\n const ownerMembershipId = rows[0]?.ownerMembershipId;\n const ownerSubjectId = rows[0]?.ownerSubjectId;\n if (!capabilityId || !ownerMembershipId || !ownerSubjectId) {\n throw new Error(\"Private child session create capability was not returned\");\n }\n return { capabilityId, ownerMembershipId, ownerSubjectId };\n}\n\nexport async function closePrivateSessionCreateCapability(\n db: Database,\n capabilityId: string,\n): Promise<void> {\n await db.execute(sql`select close_private_session_create_capability(${capabilityId}::uuid)`);\n}\n\nasync function assertSessionTenancyProductActivated(\n db: Database,\n workspaceId: string,\n): Promise<void> {\n if (!(await sessionTenancyProductActivated(db, workspaceId))) {\n throw new SessionTenancyNotActivatedError();\n }\n}\n\nfunction mapSessionTenancyPersistenceError(\n error: unknown,\n options: { authorityEpochConflict: boolean },\n): never {\n const state = nestedPostgresSqlState(error);\n if (state === \"55P03\") {\n throw new SessionTenancyConflictError(\"not_quiescent\", nestedSessionTenancyBlocker(error), {\n cause: error,\n });\n }\n if (state === \"40001\" && options.authorityEpochConflict) {\n throw new SessionTenancyConflictError(\"authority_epoch\", null, { cause: error });\n }\n if (state === \"23505\") {\n throw new SessionTenancyConflictError(\"operation_reuse\", null, { cause: error });\n }\n if (state === \"55000\") {\n throw new SessionTenancyNotActivatedError({ cause: error });\n }\n if (state === \"42501\" || state === \"P0002\") {\n throw new SessionTenancyAccessError({ cause: error });\n }\n if (state === \"22023\") {\n throw new SessionTenancyInvalidRequestError({ cause: error });\n }\n throw error;\n}\n\nexport function canonicalSessionVisibilityTransitionHash(\n input: Pick<\n TransitionSessionVisibilityInput,\n \"sessionId\" | \"targetVisibility\" | \"expectedAuthorityEpoch\"\n >,\n): string {\n return createHash(\"sha256\")\n .update(\n JSON.stringify({\n version: 1,\n sessionId: input.sessionId,\n targetVisibility: input.targetVisibility,\n expectedAuthorityEpoch: input.expectedAuthorityEpoch,\n }),\n )\n .digest(\"hex\");\n}\n\nexport function canonicalSessionForkHash(\n input: Pick<\n ForkSessionContentInput,\n | \"sourceSessionId\"\n | \"destinationWorkspaceId\"\n | \"destinationVisibility\"\n | \"workspaceSharedAcknowledged\"\n | \"runtimeRequest\"\n | \"sourceEventId\"\n >,\n): string {\n if (input.sourceEventId) {\n return createHash(\"sha256\")\n .update(\n JSON.stringify({\n version: 4,\n sourceSessionId: input.sourceSessionId,\n destinationWorkspaceId: input.destinationWorkspaceId,\n destinationVisibility: input.destinationVisibility,\n workspaceSharedAcknowledged: input.workspaceSharedAcknowledged,\n sourceEventId: input.sourceEventId,\n }),\n )\n .digest(\"hex\");\n }\n if (input.runtimeRequest) {\n return createHash(\"sha256\")\n .update(\n JSON.stringify({\n version: 3,\n sourceSessionId: input.sourceSessionId,\n destinationWorkspaceId: input.destinationWorkspaceId,\n destinationVisibility: input.destinationVisibility,\n workspaceSharedAcknowledged: input.workspaceSharedAcknowledged,\n runtime: input.runtimeRequest,\n }),\n )\n .digest(\"hex\");\n }\n const legacyCompatiblePrivateRequest =\n input.destinationVisibility === \"user_private\" && !input.workspaceSharedAcknowledged;\n return createHash(\"sha256\")\n .update(\n JSON.stringify(\n legacyCompatiblePrivateRequest\n ? {\n version: 1,\n sourceSessionId: input.sourceSessionId,\n destinationWorkspaceId: input.destinationWorkspaceId,\n destinationVisibility: input.destinationVisibility,\n }\n : {\n version: 2,\n sourceSessionId: input.sourceSessionId,\n destinationWorkspaceId: input.destinationWorkspaceId,\n destinationVisibility: input.destinationVisibility,\n workspaceSharedAcknowledged: input.workspaceSharedAcknowledged,\n },\n ),\n )\n .digest(\"hex\");\n}\n\nfunction canonicalForkRuntimeConfigurationDigest(input: ForkSessionRuntimeRequest): string {\n return createHash(\"sha256\")\n .update(JSON.stringify({ version: 1, ...input }))\n .digest(\"hex\");\n}\n\nexport async function transitionSessionVisibility(\n db: Database,\n input: TransitionSessionVisibilityInput,\n): Promise<TransitionSessionVisibilityResult> {\n if (!Number.isSafeInteger(input.expectedAuthorityEpoch) || input.expectedAuthorityEpoch < 1) {\n throw new Error(\"expectedAuthorityEpoch must be a positive safe integer\");\n }\n if (!input.operationKey.trim()) throw new Error(\"operationKey must not be empty\");\n const requestHash = canonicalSessionVisibilityTransitionHash(input);\n const { accountId } = await rlsContextForWorkspace(db, input.workspaceId);\n await assertSessionTenancyProductActivated(db, input.workspaceId);\n try {\n return await withWorkspaceSubjectSessionActivityRls(\n db,\n input.workspaceId,\n input.actorSubjectId,\n async (scopedDb) => {\n const rows = await rawRows<{\n operationId: string;\n eventId: string | null;\n eventSequence: number | null;\n visibility: SessionTenancyVisibility;\n authorityEpoch: number;\n ownerOrganizationMembershipId: string | null;\n changed: boolean;\n replay: boolean;\n interruptedAttemptCount: number;\n cancelledTurnCount: number;\n cancelledUpdateCount: number;\n pausedGoalCount: number;\n revokedGrantCount: number;\n }>(\n scopedDb,\n sql`select\n operation_id as \"operationId\",\n event_id as \"eventId\",\n event_sequence as \"eventSequence\",\n visibility,\n authority_epoch as \"authorityEpoch\",\n owner_organization_membership_id as \"ownerOrganizationMembershipId\",\n changed,\n replay,\n interrupted_attempt_count as \"interruptedAttemptCount\",\n cancelled_turn_count as \"cancelledTurnCount\",\n cancelled_update_count as \"cancelledUpdateCount\",\n paused_goal_count as \"pausedGoalCount\",\n revoked_grant_count as \"revokedGrantCount\"\n from transition_session_visibility(\n ${accountId}::uuid,\n ${input.workspaceId}::uuid,\n ${input.sessionId}::uuid,\n ${input.actorSubjectId},\n ${input.targetVisibility},\n ${input.expectedAuthorityEpoch},\n ${input.operationKey},\n ${requestHash},\n ${SESSION_TENANCY_ACTIVATION_VERSION}\n )`,\n );\n const result = rows[0];\n if (!result) throw new Error(\"Session visibility transition returned no result\");\n await input.beforeCommit?.(scopedDb);\n return result;\n },\n undefined,\n \"none\",\n );\n } catch (error) {\n mapSessionTenancyPersistenceError(error, { authorityEpochConflict: true });\n }\n}\n\nexport async function forkSessionContent(\n db: Database,\n input: ForkSessionContentInput,\n): Promise<ForkSessionContentResult> {\n if (!input.operationKey.trim()) throw new Error(\"operationKey must not be empty\");\n if (input.destinationWorkspaceId !== input.sourceWorkspaceId) {\n throw new Error(\"The first session fork contract is same-workspace only\");\n }\n if (input.sourceEventId && input.runtimeRequest) {\n throw new Error(\"Message forks cannot replace runtime setup\");\n }\n if (Boolean(input.runtimeRequest) !== Boolean(input.runtimeConfiguration)) {\n throw new Error(\"A fresh session fork runtime request requires its resolved configuration\");\n }\n if (\n input.runtimeRequest &&\n (input.runtimeRequest.rigId !== input.runtimeConfiguration?.rigId ||\n JSON.stringify(input.runtimeRequest.variableSetIds) !==\n JSON.stringify(input.runtimeConfiguration?.variableSetIds))\n ) {\n throw new Error(\"Resolved session fork runtime configuration does not match its request\");\n }\n const { accountId } = await rlsContextForWorkspace(db, input.sourceWorkspaceId);\n await assertSessionTenancyProductActivated(db, input.sourceWorkspaceId);\n const requestHash = canonicalSessionForkHash(input);\n try {\n return await withWorkspaceSubjectRls(\n db,\n input.sourceWorkspaceId,\n input.actorSubjectId,\n async (scopedDb) => {\n if (input.runtimeRequest && input.runtimeConfiguration) {\n const runtimeDigest = canonicalForkRuntimeConfigurationDigest(input.runtimeRequest);\n const rows = await rawRows<ForkSessionContentResult>(\n scopedDb,\n sql`select\n operation_id as \"operationId\",\n event_id as \"eventId\",\n event_sequence as \"eventSequence\",\n session_id as \"sessionId\",\n workspace_id as \"workspaceId\",\n visibility,\n authority_epoch as \"authorityEpoch\",\n copied_history_item_count as \"copiedHistoryItemCount\",\n replay,\n runtime_event_id as \"runtimeEventId\",\n runtime_event_sequence as \"runtimeEventSequence\"\n from fork_session_content_with_runtime(\n ${accountId}::uuid,\n ${input.sourceWorkspaceId}::uuid,\n ${input.sourceSessionId}::uuid,\n ${input.actorSubjectId},\n ${input.destinationWorkspaceId}::uuid,\n ${input.destinationVisibility},\n ${input.workspaceSharedAcknowledged},\n ${input.operationKey},\n ${requestHash},\n ${SESSION_TENANCY_ACTIVATION_VERSION},\n ${JSON.stringify(input.runtimeConfiguration.variableSetIds)}::jsonb,\n ${input.runtimeConfiguration.rigId}::uuid,\n ${input.runtimeConfiguration.rigVersionId}::uuid,\n ${runtimeDigest}\n )`,\n );\n const result = rows[0];\n if (!result) throw new Error(\"Session fork returned no result\");\n await input.beforeCommit?.(scopedDb);\n return result;\n }\n const rows = await rawRows<ForkSessionContentResult>(\n scopedDb,\n sql`select\n operation_id as \"operationId\",\n event_id as \"eventId\",\n event_sequence as \"eventSequence\",\n session_id as \"sessionId\",\n workspace_id as \"workspaceId\",\n visibility,\n authority_epoch as \"authorityEpoch\",\n copied_history_item_count as \"copiedHistoryItemCount\",\n replay,\n null::uuid as \"runtimeEventId\",\n null::integer as \"runtimeEventSequence\"\n from fork_session_content(\n ${accountId}::uuid,\n ${input.sourceWorkspaceId}::uuid,\n ${input.sourceSessionId}::uuid,\n ${input.actorSubjectId},\n ${input.destinationWorkspaceId}::uuid,\n ${input.destinationVisibility},\n ${input.workspaceSharedAcknowledged},\n ${input.operationKey},\n ${requestHash},\n ${SESSION_TENANCY_ACTIVATION_VERSION}\n ${input.sourceEventId ? sql`, ${input.sourceEventId}::uuid` : sql``}\n )`,\n );\n const result = rows[0];\n if (!result) throw new Error(\"Session fork returned no result\");\n await input.beforeCommit?.(scopedDb);\n return result;\n },\n undefined,\n \"none\",\n );\n } catch (error) {\n // A private destination inside a shared workspace carries the same\n // organization owner/admin product decision the create path enforces\n // (migration 0323), and the fork routine raises the same 55000. Surface it\n // as the not-activated product state rather than an opaque database error.\n if (nestedPostgresSqlState(error) === \"55000\") {\n throw new SessionTenancyNotActivatedError({ cause: error });\n }\n mapSessionTenancyPersistenceError(error, { authorityEpochConflict: false });\n }\n}\n\n/**\n * Recover one exact committed fork before mutable source-session authorization.\n *\n * The database capability requires the authenticated actor's active workspace\n * authority and matches the complete actor/workspace/source/key/request-hash\n * tuple. A fresh key returns null; changed intent raises the ordinary tenancy\n * idempotency conflict. This is receipt recovery, not session discovery.\n */\nexport async function replayAppliedSessionFork(\n db: Database,\n input: ForkSessionContentInput,\n): Promise<ForkSessionContentResult | null> {\n if (!input.operationKey.trim()) throw new Error(\"operationKey must not be empty\");\n if (input.destinationWorkspaceId !== input.sourceWorkspaceId) {\n throw new Error(\"The first session fork contract is same-workspace only\");\n }\n const { accountId } = await rlsContextForWorkspace(db, input.sourceWorkspaceId);\n await assertSessionTenancyProductActivated(db, input.sourceWorkspaceId);\n const requestHash = canonicalSessionForkHash(input);\n try {\n return await withWorkspaceSubjectRls(\n db,\n input.sourceWorkspaceId,\n input.actorSubjectId,\n async (scopedDb) => {\n if (input.runtimeRequest) {\n const runtimeDigest = canonicalForkRuntimeConfigurationDigest(input.runtimeRequest);\n const rows = await rawRows<ForkSessionContentResult>(\n scopedDb,\n sql`select\n operation_id as \"operationId\",\n event_id as \"eventId\",\n event_sequence as \"eventSequence\",\n session_id as \"sessionId\",\n workspace_id as \"workspaceId\",\n visibility,\n authority_epoch as \"authorityEpoch\",\n copied_history_item_count as \"copiedHistoryItemCount\",\n replay,\n runtime_event_id as \"runtimeEventId\",\n runtime_event_sequence as \"runtimeEventSequence\"\n from replay_applied_session_fork_with_runtime(\n ${accountId}::uuid,\n ${input.sourceWorkspaceId}::uuid,\n ${input.sourceSessionId}::uuid,\n ${input.actorSubjectId},\n ${input.destinationWorkspaceId}::uuid,\n ${input.destinationVisibility},\n ${input.workspaceSharedAcknowledged},\n ${input.operationKey},\n ${requestHash},\n ${SESSION_TENANCY_ACTIVATION_VERSION},\n ${runtimeDigest}\n )`,\n );\n await input.beforeCommit?.(scopedDb);\n return rows[0] ?? null;\n }\n const rows = await rawRows<ForkSessionContentResult>(\n scopedDb,\n sql`select\n operation_id as \"operationId\",\n event_id as \"eventId\",\n event_sequence as \"eventSequence\",\n session_id as \"sessionId\",\n workspace_id as \"workspaceId\",\n visibility,\n authority_epoch as \"authorityEpoch\",\n copied_history_item_count as \"copiedHistoryItemCount\",\n replay,\n null::uuid as \"runtimeEventId\",\n null::integer as \"runtimeEventSequence\"\n from replay_applied_session_fork(\n ${accountId}::uuid,\n ${input.sourceWorkspaceId}::uuid,\n ${input.sourceSessionId}::uuid,\n ${input.actorSubjectId},\n ${input.destinationWorkspaceId}::uuid,\n ${input.destinationVisibility},\n ${input.workspaceSharedAcknowledged},\n ${input.operationKey},\n ${requestHash},\n ${SESSION_TENANCY_ACTIVATION_VERSION}\n )`,\n );\n await input.beforeCommit?.(scopedDb);\n return rows[0] ?? null;\n },\n );\n } catch (error) {\n mapSessionTenancyPersistenceError(error, { authorityEpochConflict: false });\n }\n}\n"],"mappings":";;;;;;;;;;AAAA,SAAS,kBAAkB;AAC3B,SAAS,WAAW;AACpB;AAAA,EACE,yBAAyB;AAAA,OAEpB;AAWP,IAAM,qCAAqC;AAEpC,IAAM,8BAAN,cAA0C,MAAM;AAAA,EAErD,YACW,QACA,UAAwC,MACjD,SACA;AACA;AAAA,MACE,WAAW,kBACP,kEACA,WAAW,oBACT,6DACA;AAAA,MACN;AAAA,IACF;AAXS;AACA;AAAA,EAWX;AAAA,EAdS,OAAO;AAelB;AAEO,IAAM,kCAAN,cAA8C,MAAM;AAAA,EAChD,OAAO;AAAA,EAChB,YAAY,SAAwB;AAClC,UAAM,0EAA0E,OAAO;AAAA,EACzF;AACF;AAEO,IAAM,4BAAN,cAAwC,MAAM;AAAA,EAC1C,OAAO;AAAA,EAChB,YAAY,SAAwB;AAClC,UAAM,yCAAyC,OAAO;AAAA,EACxD;AACF;AAEO,IAAM,oCAAN,cAAgD,MAAM;AAAA,EAClD,OAAO;AAAA,EAChB,YAAY,SAAwB;AAClC,UAAM,sCAAsC,OAAO;AAAA,EACrD;AACF;AAEA,SAAS,SAAS,OAAkD;AAClE,SAAO,QAAQ,SAAS,OAAO,UAAU,QAAQ;AACnD;AAGO,SAAS,4BAA4B,OAA8C;AACxF,QAAM,QAAmB,CAAC,KAAK;AAC/B,QAAM,OAAO,oBAAI,IAAa;AAC9B,SAAO,MAAM,SAAS,KAAK,KAAK,OAAO,IAAI;AACzC,UAAM,UAAU,MAAM,MAAM;AAC5B,QAAI,CAAC,SAAS,OAAO,KAAK,KAAK,IAAI,OAAO,E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Ac;AAAA,cACpB,MAAM,sBAAsB;AAAA,cAC5B,MAAM,qBAAqB;AAAA,cAC3B,MAAM,2BAA2B;AAAA,cACjC,MAAM,YAAY;AAAA,cAClB,WAAW;AAAA,cACX,kCAAkC;AAAA,cAClC,aAAa;AAAA;AAAA,UAEjB;AACA,gBAAM,MAAM,eAAe,QAAQ;AACnC,iBAAOA,MAAK,CAAC,KAAK;AAAA,QACpB;AACA,cAAM,OAAO,MAAM;AAAA,UACjB;AAAA,UACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,YAaE,SAAS;AAAA,YACT,MAAM,iBAAiB;AAAA,YACvB,MAAM,eAAe;AAAA,YACrB,MAAM,cAAc;AAAA,YACpB,MAAM,sBAAsB;AAAA,YAC5B,MAAM,qBAAqB;AAAA,YAC3B,MAAM,2BAA2B;AAAA,YACjC,MAAM,YAAY;AAAA,YAClB,WAAW;AAAA,YACX,kCAAkC;AAAA;AAAA,QAEtC;AACA,cAAM,MAAM,eAAe,QAAQ;AACnC,eAAO,KAAK,CAAC,KAAK;AAAA,MACpB;AAAA,IACF;AAAA,EACF,SAAS,OAAO;AACd,sCAAkC,OAAO,EAAE,wBAAwB,MAAM,CAAC;AAAA,EAC5E;AACF;","names":["rows","result"]}
@@ -2,7 +2,7 @@ import {
2
2
  rawRows,
3
3
  withRlsContext,
4
4
  withWorkspaceRls
5
- } from "./chunk-B2KR3TEM.js";
5
+ } from "./chunk-SGJDIF2D.js";
6
6
  import {
7
7
  connections,
8
8
  creditLedgerEntries,
@@ -14,7 +14,7 @@ import {
14
14
  workspaceVideoGenerationPolicies,
15
15
  workspaceVideoGenerationQuotas,
16
16
  workspaces
17
- } from "./chunk-S4Y42VSX.js";
17
+ } from "./chunk-Y5XFVJJM.js";
18
18
 
19
19
  // src/video-generation.ts
20
20
  import {
@@ -992,4 +992,4 @@ export {
992
992
  mediaGenerationResultForStoredOperation,
993
993
  getVideoGenerationOperationSummary
994
994
  };
995
- //# sourceMappingURL=chunk-MGVOYVPS.js.map
995
+ //# sourceMappingURL=chunk-NCSPNCQK.js.map
@@ -4,7 +4,7 @@ import {
4
4
  sessions,
5
5
  workspaceSessionActivityRevisions,
6
6
  workspaces
7
- } from "./chunk-S4Y42VSX.js";
7
+ } from "./chunk-Y5XFVJJM.js";
8
8
 
9
9
  // src/persistence-errors.ts
10
10
  var SQLSTATE_KEYS = ["sqlState", "sqlstate", "code"];
@@ -755,4 +755,4 @@ export {
755
755
  withAccountRls,
756
756
  dbBindingFor
757
757
  };
758
- //# sourceMappingURL=chunk-B2KR3TEM.js.map
758
+ //# sourceMappingURL=chunk-SGJDIF2D.js.map
@@ -61,6 +61,7 @@ __export(schema_exports, {
61
61
  composerDrafts: () => composerDrafts,
62
62
  computerSessionAssociations: () => computerSessionAssociations,
63
63
  computerSessions: () => computerSessions,
64
+ connectAttempts: () => connectAttempts,
64
65
  connectionDisconnectOperations: () => connectionDisconnectOperations,
65
66
  connectionUseAuditFacts: () => connectionUseAuditFacts,
66
67
  connectionUseOnceConsumptionReceipts: () => connectionUseOnceConsumptionReceipts,
@@ -93,6 +94,7 @@ __export(schema_exports, {
93
94
  enrollmentOsValues: () => enrollmentOsValues,
94
95
  enrollmentStatusValues: () => enrollmentStatusValues,
95
96
  enrollments: () => enrollments,
97
+ externalIdentities: () => externalIdentities,
96
98
  feedbackSubmissions: () => feedbackSubmissions,
97
99
  fileUploads: () => fileUploads,
98
100
  files: () => files,
@@ -110,6 +112,9 @@ __export(schema_exports, {
110
112
  hostExportCursorState: () => hostExportCursorState,
111
113
  hostExportDeadLetters: () => hostExportDeadLetters,
112
114
  hostExportOutbox: () => hostExportOutbox,
115
+ hostMcpBindings: () => hostMcpBindings,
116
+ hostMcpDelegations: () => hostMcpDelegations,
117
+ hostMcpTurnAuthorities: () => hostMcpTurnAuthorities,
113
118
  imageGenerationOperations: () => imageGenerationOperations,
114
119
  importBatches: () => importBatches,
115
120
  integrationFacetBindingOwners: () => integrationFacetBindingOwners,
@@ -6504,7 +6509,11 @@ var workspaces = pgTable20(
6504
6509
  (table) => ({
6505
6510
  account: index19("workspaces_account_idx").on(table.accountId),
6506
6511
  accountSlug: uniqueIndex20("workspaces_account_slug_idx").on(table.accountId, table.slug).where(sql16`${table.slug} is not null`),
6507
- external: uniqueIndex20("workspaces_external_idx").on(table.externalSource, table.externalId),
6512
+ external: uniqueIndex20("workspaces_external_idx").on(
6513
+ table.accountId,
6514
+ table.externalSource,
6515
+ table.externalId
6516
+ ),
6508
6517
  sandboxViewerForceDrain: index19("workspaces_sandbox_viewer_force_drain_idx").on(table.id).where(sql16`${table.sandboxViewerForceDrainReason} is not null`),
6509
6518
  sandboxViewerForceDrainValid: check11(
6510
6519
  "workspaces_sandbox_viewer_force_drain_check",
@@ -6819,6 +6828,41 @@ var workspaceMemberships = pgTable20(
6819
6828
  account: index19("workspace_memberships_account_idx").on(table.accountId)
6820
6829
  })
6821
6830
  );
6831
+ var externalIdentities = pgTable20(
6832
+ "external_identities",
6833
+ {
6834
+ id: uuid20("id").primaryKey(),
6835
+ accountId: uuid20("account_id").notNull().references(() => managedAccounts.id, { onDelete: "cascade" }),
6836
+ source: text20("source").notNull(),
6837
+ externalId: text20("external_id").notNull(),
6838
+ subjectId: text20("subject_id").notNull(),
6839
+ organizationMembershipId: uuid20("organization_membership_id").notNull(),
6840
+ personalWorkspaceId: uuid20("personal_workspace_id").notNull(),
6841
+ status: text20("status").notNull().default("active"),
6842
+ authorizationRevision: bigint14("authorization_revision", { mode: "number" }).notNull().default(1),
6843
+ createdAt: timestamp20("created_at", { withTimezone: true }).notNull().defaultNow(),
6844
+ updatedAt: timestamp20("updated_at", { withTimezone: true }).notNull().defaultNow()
6845
+ },
6846
+ (table) => ({
6847
+ mapping: uniqueIndex20("external_identities_account_id_source_external_id_key").on(
6848
+ table.accountId,
6849
+ table.source,
6850
+ table.externalId
6851
+ ),
6852
+ subject: uniqueIndex20("external_identities_account_id_subject_id_key").on(
6853
+ table.accountId,
6854
+ table.subjectId
6855
+ ),
6856
+ membership: foreignKey({
6857
+ columns: [table.organizationMembershipId, table.accountId],
6858
+ foreignColumns: [organizationMemberships.id, organizationMemberships.accountId]
6859
+ }),
6860
+ personalWorkspace: foreignKey({
6861
+ columns: [table.personalWorkspaceId, table.accountId],
6862
+ foreignColumns: [workspaces.id, workspaces.accountId]
6863
+ })
6864
+ })
6865
+ );
6822
6866
  var organizationMemberships = pgTable20(
6823
6867
  "organization_memberships",
6824
6868
  {
@@ -7147,7 +7191,8 @@ var organizationMembershipLifecycleEvents = pgTable20(
7147
7191
  id: uuid20("id").primaryKey().defaultRandom(),
7148
7192
  accountId: uuid20("account_id").notNull().references(() => managedAccounts.id, { onDelete: "cascade" }),
7149
7193
  operationId: uuid20("operation_id").notNull(),
7150
- actorMembershipId: uuid20("actor_membership_id").notNull(),
7194
+ actorMembershipId: uuid20("actor_membership_id"),
7195
+ actorServiceSubject: text20("actor_service_subject"),
7151
7196
  targetMembershipId: uuid20("target_membership_id"),
7152
7197
  kind: text20("kind").notNull(),
7153
7198
  priorAuthorizationRevision: bigint14("prior_authorization_revision", {
@@ -7177,6 +7222,10 @@ var organizationMembershipLifecycleEvents = pgTable20(
7177
7222
  kindValid: check11(
7178
7223
  "organization_membership_lifecycle_events_kind_check",
7179
7224
  sql16`${table.kind} in ('invite', 'accept', 'revoke_invitation', 'change_role', 'suspend', 'reactivate', 'offboard', 'retention')`
7225
+ ),
7226
+ actorKindValid: check11(
7227
+ "organization_membership_lifecycle_events_actor_kind_check",
7228
+ sql16`(${table.actorMembershipId} is not null and ${table.actorServiceSubject} is null) or (${table.actorMembershipId} is null and ${table.actorServiceSubject} is not null and ${table.actorServiceSubject} ~ '^api_key:[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$')`
7180
7229
  )
7181
7230
  })
7182
7231
  );
@@ -9376,6 +9425,36 @@ var integrationOauthClients = pgTable20(
9376
9425
  authorizationServer: index19("integration_oauth_clients_as_idx").on(table.authorizationServer)
9377
9426
  })
9378
9427
  );
9428
+ var hostMcpTurnAuthorities = pgTable20(
9429
+ "host_mcp_turn_authorities",
9430
+ {
9431
+ turnId: uuid20("turn_id").notNull().references(() => sessionTurns.id, { onDelete: "cascade" }),
9432
+ serverId: text20("server_id").notNull(),
9433
+ accountId: uuid20("account_id").notNull().references(() => managedAccounts.id, { onDelete: "cascade" }),
9434
+ workspaceId: uuid20("workspace_id").notNull(),
9435
+ sessionId: uuid20("session_id").notNull().references(() => sessions.id, { onDelete: "cascade" }),
9436
+ ownerSubjectId: text20("owner_subject_id").notNull(),
9437
+ bindingId: uuid20("binding_id").notNull().references(() => hostMcpBindings.id),
9438
+ delegationId: uuid20("delegation_id").notNull().references(() => hostMcpDelegations.id),
9439
+ canonicalSnapshot: jsonb16("canonical_snapshot").$type().notNull(),
9440
+ createdAt: timestamp20("created_at", { withTimezone: true }).notNull().defaultNow()
9441
+ },
9442
+ (table) => ({
9443
+ pk: primaryKey9({ columns: [table.turnId, table.serverId] }),
9444
+ workspaceAccount: foreignKey({
9445
+ columns: [table.workspaceId, table.accountId],
9446
+ foreignColumns: [workspaces.id, workspaces.accountId]
9447
+ }).onDelete("cascade"),
9448
+ serverBounds: check11(
9449
+ "host_mcp_turn_authorities_server_id_check",
9450
+ sql16`octet_length(${table.serverId}) between 1 and 1024`
9451
+ ),
9452
+ snapshotBounds: check11(
9453
+ "host_mcp_turn_authorities_canonical_snapshot_check",
9454
+ sql16`jsonb_typeof(${table.canonicalSnapshot}) = 'object' and octet_length(${table.canonicalSnapshot}::text) <= 262144`
9455
+ )
9456
+ })
9457
+ );
9379
9458
  var integrationOauthStateNonces = pgTable20(
9380
9459
  "integration_oauth_state_nonces",
9381
9460
  {
@@ -9392,6 +9471,122 @@ var integrationOauthStateNonces = pgTable20(
9392
9471
  expires: index19("integration_oauth_state_nonces_expires_idx").on(table.expiresAt)
9393
9472
  })
9394
9473
  );
9474
+ var hostMcpBindings = pgTable20(
9475
+ "host_mcp_bindings",
9476
+ {
9477
+ id: uuid20("id").primaryKey(),
9478
+ accountId: uuid20("account_id").notNull().references(() => managedAccounts.id, { onDelete: "cascade" }),
9479
+ workspaceId: uuid20("workspace_id").notNull(),
9480
+ ownerSubjectId: text20("owner_subject_id").notNull(),
9481
+ authorizationRevision: bigint14("authorization_revision", { mode: "number" }).notNull(),
9482
+ operationId: uuid20("operation_id").notNull(),
9483
+ requestDigest: text20("request_digest").notNull(),
9484
+ definition: jsonb16("definition").notNull(),
9485
+ generation: bigint14("generation", { mode: "number" }).notNull().default(1),
9486
+ status: text20("status").notNull().default("active"),
9487
+ createdAt: timestamp20("created_at", { withTimezone: true }).notNull().defaultNow(),
9488
+ revokedAt: timestamp20("revoked_at", { withTimezone: true })
9489
+ },
9490
+ (table) => ({
9491
+ workspace: foreignKey({
9492
+ name: "host_mcp_bindings_workspace_account_fk",
9493
+ columns: [table.workspaceId, table.accountId],
9494
+ foreignColumns: [workspaces.id, workspaces.accountId]
9495
+ }).onDelete("cascade"),
9496
+ owner: foreignKey({
9497
+ name: "host_mcp_bindings_member_owner_fk",
9498
+ columns: [table.accountId, table.ownerSubjectId],
9499
+ foreignColumns: [organizationMemberships.accountId, organizationMemberships.subjectId]
9500
+ }),
9501
+ operation: uniqueIndex20("host_mcp_bindings_workspace_id_owner_subject_id_operation_id_key").on(
9502
+ table.workspaceId,
9503
+ table.ownerSubjectId,
9504
+ table.operationId
9505
+ ),
9506
+ inventory: index19("host_mcp_bindings_owner_idx").on(
9507
+ table.workspaceId,
9508
+ table.ownerSubjectId,
9509
+ table.createdAt,
9510
+ table.id
9511
+ )
9512
+ })
9513
+ );
9514
+ var hostMcpDelegations = pgTable20(
9515
+ "host_mcp_delegations",
9516
+ {
9517
+ id: uuid20("id").primaryKey(),
9518
+ accountId: uuid20("account_id").notNull().references(() => managedAccounts.id, { onDelete: "cascade" }),
9519
+ workspaceId: uuid20("workspace_id").notNull(),
9520
+ ownerSubjectId: text20("owner_subject_id").notNull(),
9521
+ ownerAuthorizationRevision: bigint14("owner_authorization_revision", {
9522
+ mode: "number"
9523
+ }).notNull(),
9524
+ bindingId: uuid20("binding_id").notNull().references(() => hostMcpBindings.id),
9525
+ bindingGeneration: bigint14("binding_generation", { mode: "number" }).notNull(),
9526
+ operationId: uuid20("operation_id").notNull(),
9527
+ requestDigest: text20("request_digest").notNull(),
9528
+ grantDefinition: jsonb16("grant_definition").notNull(),
9529
+ generation: bigint14("generation", { mode: "number" }).notNull().default(1),
9530
+ status: text20("status").notNull().default("active"),
9531
+ createdAt: timestamp20("created_at", { withTimezone: true }).notNull().defaultNow(),
9532
+ revokedAt: timestamp20("revoked_at", { withTimezone: true })
9533
+ },
9534
+ (table) => ({
9535
+ workspace: foreignKey({
9536
+ name: "host_mcp_delegations_workspace_account_fk",
9537
+ columns: [table.workspaceId, table.accountId],
9538
+ foreignColumns: [workspaces.id, workspaces.accountId]
9539
+ }).onDelete("cascade"),
9540
+ owner: foreignKey({
9541
+ name: "host_mcp_delegations_member_owner_fk",
9542
+ columns: [table.accountId, table.ownerSubjectId],
9543
+ foreignColumns: [organizationMemberships.accountId, organizationMemberships.subjectId]
9544
+ }),
9545
+ operation: uniqueIndex20(
9546
+ "host_mcp_delegations_workspace_id_owner_subject_id_operation_id_key"
9547
+ ).on(table.workspaceId, table.ownerSubjectId, table.operationId),
9548
+ inventory: index19("host_mcp_delegations_owner_idx").on(
9549
+ table.workspaceId,
9550
+ table.ownerSubjectId,
9551
+ table.bindingId,
9552
+ table.id
9553
+ )
9554
+ })
9555
+ );
9556
+ var connectAttempts = pgTable20(
9557
+ "connect_attempts",
9558
+ {
9559
+ id: uuid20("id").primaryKey(),
9560
+ accountId: uuid20("account_id").notNull().references(() => managedAccounts.id, { onDelete: "cascade" }),
9561
+ workspaceId: uuid20("workspace_id").notNull(),
9562
+ subjectId: text20("subject_id").notNull(),
9563
+ idempotencyKeyHash: text20("idempotency_key_hash").notNull(),
9564
+ requestDigest: text20("request_digest").notNull(),
9565
+ returnUrl: text20("return_url").notNull(),
9566
+ externalContinuation: jsonb16("external_continuation"),
9567
+ projection: jsonb16("projection").notNull(),
9568
+ operationId: text20("operation_id"),
9569
+ operationDigest: text20("operation_digest"),
9570
+ receipts: jsonb16("receipts").notNull().default({}),
9571
+ expiresAt: timestamp20("expires_at", { withTimezone: true }).notNull(),
9572
+ createdAt: timestamp20("created_at", { withTimezone: true }).notNull().defaultNow(),
9573
+ updatedAt: timestamp20("updated_at", { withTimezone: true }).notNull().defaultNow()
9574
+ },
9575
+ (table) => ({
9576
+ workspaceAccount: foreignKey({
9577
+ name: "connect_attempts_workspace_account_fk",
9578
+ columns: [table.workspaceId, table.accountId],
9579
+ foreignColumns: [workspaces.id, workspaces.accountId]
9580
+ }).onDelete("cascade"),
9581
+ idempotency: uniqueIndex20("connect_attempts_actor_idempotency_idx").on(
9582
+ table.workspaceId,
9583
+ table.subjectId,
9584
+ table.idempotencyKeyHash
9585
+ ),
9586
+ pending: index19("connect_attempts_actor_pending_idx").on(table.workspaceId, table.subjectId, table.createdAt.desc(), table.id.desc()).where(sql16`${table.projection}->>'state' not in ('complete','cancelled','expired')`),
9587
+ expiry: index19("connect_attempts_expiry_idx").on(table.expiresAt, table.id)
9588
+ })
9589
+ );
9395
9590
  var mcpOauthClients = pgTable20(
9396
9591
  "mcp_oauth_clients",
9397
9592
  {
@@ -9897,6 +10092,9 @@ var sessions = pgTable20(
9897
10092
  // sessions carrying the same end-user label; 'session' limits it to the
9898
10093
  // own root tree. Enforced only in the core session-authorization seam.
9899
10094
  agentAccess: text20("agent_access").notNull().default("workspace"),
10095
+ // Canonical authenticated user for the frozen cross-session agent scope.
10096
+ // Independent of per-turn initiating users and historical external labels.
10097
+ scopeSubjectId: text20("scope_subject_id"),
9900
10098
  // Opaque end-user label (both set or both null). This is a product label
9901
10099
  // used for scoping and filtering, never a subject and never authority.
9902
10100
  endUserSource: text20("end_user_source"),
@@ -17556,6 +17754,7 @@ var socialConnections = pgTable20(
17556
17754
  "social_connections",
17557
17755
  {
17558
17756
  id: uuid20("id").primaryKey().defaultRandom(),
17757
+ version: integer18("version").notNull().default(1),
17559
17758
  accountId: uuid20("account_id").notNull().references(() => managedAccounts.id, { onDelete: "cascade" }),
17560
17759
  workspaceId: uuid20("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
17561
17760
  subjectId: text20("subject_id"),
@@ -18182,6 +18381,7 @@ export {
18182
18381
  workspaceInferenceControls,
18183
18382
  workspaceSessionActivityRevisions,
18184
18383
  workspaceMemberships,
18384
+ externalIdentities,
18185
18385
  organizationMemberships,
18186
18386
  organizationProfileEvents,
18187
18387
  sessionTenancyActivations,
@@ -18232,7 +18432,11 @@ export {
18232
18432
  memorySlackPublicationReceipts,
18233
18433
  slackBotDeleteOperations,
18234
18434
  integrationOauthClients,
18435
+ hostMcpTurnAuthorities,
18235
18436
  integrationOauthStateNonces,
18437
+ hostMcpBindings,
18438
+ hostMcpDelegations,
18439
+ connectAttempts,
18236
18440
  mcpOauthClients,
18237
18441
  mcpOauthAuthorizationRequests,
18238
18442
  mcpOauthAuthorizationCodes,
@@ -18399,4 +18603,4 @@ export {
18399
18603
  feedbackSubmissions,
18400
18604
  schema_exports
18401
18605
  };
18402
- //# sourceMappingURL=chunk-S4Y42VSX.js.map
18606
+ //# sourceMappingURL=chunk-Y5XFVJJM.js.map