@opengeni/db 3.8.2-canary.0 → 4.0.0-canary.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. package/dist/canonical-human-identities.js +3 -3
  2. package/dist/capability-integrations.d.ts +2 -0
  3. package/dist/{chunk-6DPJA36C.js → chunk-2XEZK4LF.js} +7 -1
  4. package/dist/chunk-2XEZK4LF.js.map +1 -0
  5. package/dist/{chunk-F5YOZEYQ.js → chunk-3RI33YQN.js} +19 -1
  6. package/dist/chunk-3RI33YQN.js.map +1 -0
  7. package/dist/{chunk-5S4BQAHX.js → chunk-CJROYHSC.js} +3 -3
  8. package/dist/{chunk-UKOGHUGC.js → chunk-MX6V5F65.js} +2 -2
  9. package/dist/{chunk-CITYUGMW.js → chunk-N5VXJ4I2.js} +151 -78
  10. package/dist/chunk-N5VXJ4I2.js.map +1 -0
  11. package/dist/{chunk-Y53WEFYB.js → chunk-NLFHMPUB.js} +2 -2
  12. package/dist/{chunk-RLQVPOVR.js → chunk-P6NSEG2S.js} +2 -2
  13. package/dist/{chunk-53A2PEHT.js → chunk-QM6YOWHZ.js} +303 -33
  14. package/dist/chunk-QM6YOWHZ.js.map +1 -0
  15. package/dist/{chunk-X6TO5HII.js → chunk-RZNOSEMC.js} +2 -2
  16. package/dist/{chunk-HZV7O6JR.js → chunk-UFAMOUWL.js} +2 -2
  17. package/dist/codemode-operations.d.ts +5 -0
  18. package/dist/codex-token-resolver.d.ts +6 -2
  19. package/dist/connection-token-resolver.d.ts +4 -0
  20. package/dist/editable-artifact-durable-export.js +2 -2
  21. package/dist/editable-artifacts.js +3 -3
  22. package/dist/generated-images.d.ts +15 -0
  23. package/dist/index.d.ts +229 -77
  24. package/dist/index.js +7663 -5625
  25. package/dist/index.js.map +1 -1
  26. package/dist/managed-auth-session-sets.js +3 -3
  27. package/dist/managed-user-setup.d.ts +3 -0
  28. package/dist/mcp-oauth.d.ts +80 -0
  29. package/dist/migrate.d.ts +1 -0
  30. package/dist/migrate.js +3 -1
  31. package/dist/model-context-snapshots.d.ts +20 -0
  32. package/dist/provision-roles.js +1 -1
  33. package/dist/runtime-posture.d.ts +5 -5
  34. package/dist/schema.d.ts +2046 -375
  35. package/dist/schema.js +15 -1
  36. package/dist/session-background-commands.d.ts +18 -6
  37. package/dist/session-background-commands.js +15 -9
  38. package/dist/session-control.d.ts +2 -2
  39. package/dist/session-goal-pacing.d.ts +3 -6
  40. package/dist/session-tenancy.js +3 -3
  41. package/dist/tool-gateway-approvals.d.ts +31 -0
  42. package/dist/video-generation.js +3 -3
  43. package/dist/workspace-artifacts.d.ts +17 -3
  44. package/drizzle/0400_session_attempt_model_context_snapshots.sql +65 -0
  45. package/drizzle/0401_organization_user_setup_token_transport.sql +178 -0
  46. package/drizzle/0402_session_input_wait_and_background_command_results.sql +1023 -0
  47. package/drizzle/0403_codex_unconditional_credential_leasing.sql +181 -0
  48. package/drizzle/0404_mcp_oauth_authorization_server.sql +471 -0
  49. package/drizzle/0405_tool_gateway_approval_capabilities.sql +184 -0
  50. package/drizzle/0406_workspace_html_site_sources.sql +71 -0
  51. package/package.json +6 -6
  52. package/src/capability-integrations.ts +8 -0
  53. package/src/codemode-operations.ts +31 -21
  54. package/src/codex-token-resolver.ts +16 -6
  55. package/src/connection-token-resolver.ts +40 -3
  56. package/src/generated-images.ts +70 -6
  57. package/src/index.ts +2444 -823
  58. package/src/managed-user-setup.ts +14 -3
  59. package/src/mcp-oauth.ts +488 -0
  60. package/src/migrate.ts +9 -1
  61. package/src/model-context-snapshots.ts +151 -0
  62. package/src/provision-roles.ts +2 -0
  63. package/src/runtime-posture.ts +16 -0
  64. package/src/schema.ts +324 -35
  65. package/src/session-background-commands.ts +180 -78
  66. package/src/session-control.ts +11 -12
  67. package/src/session-goal-pacing.ts +4 -8
  68. package/src/tool-gateway-approvals.ts +168 -0
  69. package/src/workspace-artifacts.ts +633 -178
  70. package/dist/chunk-53A2PEHT.js.map +0 -1
  71. package/dist/chunk-6DPJA36C.js.map +0 -1
  72. package/dist/chunk-CITYUGMW.js.map +0 -1
  73. package/dist/chunk-F5YOZEYQ.js.map +0 -1
  74. /package/dist/{chunk-5S4BQAHX.js.map → chunk-CJROYHSC.js.map} +0 -0
  75. /package/dist/{chunk-UKOGHUGC.js.map → chunk-MX6V5F65.js.map} +0 -0
  76. /package/dist/{chunk-Y53WEFYB.js.map → chunk-NLFHMPUB.js.map} +0 -0
  77. /package/dist/{chunk-RLQVPOVR.js.map → chunk-P6NSEG2S.js.map} +0 -0
  78. /package/dist/{chunk-X6TO5HII.js.map → chunk-RZNOSEMC.js.map} +0 -0
  79. /package/dist/{chunk-HZV7O6JR.js.map → chunk-UFAMOUWL.js.map} +0 -0
@@ -161,6 +161,11 @@ __export(schema_exports, {
161
161
  managedAuthLoginTransactions: () => managedAuthLoginTransactions,
162
162
  managedAuthSessionSetOperations: () => managedAuthSessionSetOperations,
163
163
  managedAuthSessionSets: () => managedAuthSessionSets,
164
+ mcpOauthAccessTokens: () => mcpOauthAccessTokens,
165
+ mcpOauthAuthorizationCodes: () => mcpOauthAuthorizationCodes,
166
+ mcpOauthAuthorizationRequests: () => mcpOauthAuthorizationRequests,
167
+ mcpOauthClients: () => mcpOauthClients,
168
+ mcpOauthRefreshTokens: () => mcpOauthRefreshTokens,
164
169
  memorySlackPublicationConfigurations: () => memorySlackPublicationConfigurations,
165
170
  memorySlackPublicationReceipts: () => memorySlackPublicationReceipts,
166
171
  memorySlackPublications: () => memorySlackPublications,
@@ -235,6 +240,7 @@ __export(schema_exports, {
235
240
  scheduledTasks: () => scheduledTasks,
236
241
  sessionAttemptCodemodeCalls: () => sessionAttemptCodemodeCalls,
237
242
  sessionAttemptInterruptions: () => sessionAttemptInterruptions,
243
+ sessionAttemptModelContextSnapshots: () => sessionAttemptModelContextSnapshots,
238
244
  sessionAttemptToolCatalogs: () => sessionAttemptToolCatalogs,
239
245
  sessionBackgroundCommands: () => sessionBackgroundCommands,
240
246
  sessionCommandReceipts: () => sessionCommandReceipts,
@@ -299,6 +305,7 @@ __export(schema_exports, {
299
305
  taskNoteWriteCapabilities: () => taskNoteWriteCapabilities,
300
306
  taskNotes: () => taskNotes,
301
307
  temporalScheduleCleanupOutbox: () => temporalScheduleCleanupOutbox,
308
+ toolGatewayApprovalCapabilities: () => toolGatewayApprovalCapabilities,
302
309
  transcriptionRecordingChunkStateValues: () => transcriptionRecordingChunkStateValues,
303
310
  transcriptionRecordingChunks: () => transcriptionRecordingChunks,
304
311
  transcriptionRecordingObjectKindValues: () => transcriptionRecordingObjectKindValues,
@@ -6460,7 +6467,12 @@ var workspaceArtifacts = pgTable19(
6460
6467
  table.slug
6461
6468
  ),
6462
6469
  workspaceId: uniqueIndex19("workspace_artifacts_workspace_id_uq").on(table.workspaceId, table.id),
6463
- list: index19("workspace_artifacts_list_idx").on(table.workspaceId, table.updatedAt)
6470
+ list: index19("workspace_artifacts_list_idx").on(table.workspaceId, table.updatedAt),
6471
+ statusList: index19("workspace_artifacts_status_list_idx").on(
6472
+ table.workspaceId,
6473
+ table.status,
6474
+ table.updatedAt
6475
+ )
6464
6476
  })
6465
6477
  );
6466
6478
  var workspaceArtifactVersions = pgTable19(
@@ -6475,6 +6487,10 @@ var workspaceArtifactVersions = pgTable19(
6475
6487
  contentType: text19("content_type").$type().notNull().default("text/html"),
6476
6488
  contentSha256: text19("content_sha256").notNull(),
6477
6489
  sizeBytes: integer18("size_bytes").notNull(),
6490
+ sourceKey: text19("source_key"),
6491
+ sourceSha256: text19("source_sha256"),
6492
+ sourceSizeBytes: integer18("source_size_bytes"),
6493
+ requestedTools: jsonb15("requested_tools").$type().notNull().default([]),
6478
6494
  operationKey: text19("operation_key").notNull(),
6479
6495
  sourceSessionId: uuid19("source_session_id"),
6480
6496
  sourceTurnId: uuid19("source_turn_id"),
@@ -6534,6 +6550,7 @@ var workspaceArtifactEvents = pgTable19(
6534
6550
  fromVersionId: uuid19("from_version_id"),
6535
6551
  toVersionId: uuid19("to_version_id").notNull(),
6536
6552
  operationKey: text19("operation_key").notNull(),
6553
+ requestDigest: text19("request_digest"),
6537
6554
  sourceSessionId: uuid19("source_session_id"),
6538
6555
  sourceTurnId: uuid19("source_turn_id"),
6539
6556
  sourceAttemptId: uuid19("source_attempt_id"),
@@ -7563,7 +7580,6 @@ var organizationCodexRotationSettings = pgTable19(
7563
7580
  accountId: uuid19("account_id").notNull().references(() => managedAccounts.id, { onDelete: "cascade" }),
7564
7581
  activeCredentialId: uuid19("active_credential_id"),
7565
7582
  rotationEnabled: boolean11("rotation_enabled").notNull().default(false),
7566
- leaseRotationEnabled: boolean11("lease_rotation_enabled").notNull().default(false),
7567
7583
  rotationStrategy: text19("rotation_strategy").notNull().default("sharded"),
7568
7584
  createdAt: timestamp19("created_at", { withTimezone: true }).notNull().defaultNow(),
7569
7585
  updatedAt: timestamp19("updated_at", { withTimezone: true }).notNull().defaultNow()
@@ -9245,6 +9261,192 @@ var integrationOauthStateNonces = pgTable19(
9245
9261
  expires: index19("integration_oauth_state_nonces_expires_idx").on(table.expiresAt)
9246
9262
  })
9247
9263
  );
9264
+ var mcpOauthClients = pgTable19(
9265
+ "mcp_oauth_clients",
9266
+ {
9267
+ clientId: text19("client_id").primaryKey(),
9268
+ redirectUris: jsonb15("redirect_uris").$type().notNull(),
9269
+ clientName: text19("client_name"),
9270
+ tokenEndpointAuthMethod: text19("token_endpoint_auth_method").notNull().default("none"),
9271
+ grantTypes: jsonb15("grant_types").$type().notNull(),
9272
+ responseTypes: jsonb15("response_types").$type().notNull(),
9273
+ registrationScopeHash: text19("registration_scope_hash").notNull(),
9274
+ createdAt: timestamp19("created_at", { withTimezone: true }).notNull().defaultNow(),
9275
+ expiresAt: timestamp19("expires_at", { withTimezone: true }).notNull()
9276
+ },
9277
+ (table) => ({
9278
+ created: index19("mcp_oauth_clients_created_idx").on(table.createdAt),
9279
+ scopeCreated: index19("mcp_oauth_clients_scope_created_idx").on(
9280
+ table.registrationScopeHash,
9281
+ table.createdAt
9282
+ ),
9283
+ expires: index19("mcp_oauth_clients_expires_idx").on(table.expiresAt, table.clientId)
9284
+ })
9285
+ );
9286
+ var mcpOauthGrantColumns = () => ({
9287
+ accountId: uuid19("account_id").notNull().references(() => managedAccounts.id, { onDelete: "cascade" }),
9288
+ workspaceId: uuid19("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
9289
+ subjectId: text19("subject_id").notNull(),
9290
+ resource: text19("resource").notNull(),
9291
+ permissions: jsonb15("permissions").$type().notNull(),
9292
+ toolIdentities: jsonb15("tool_identities").$type().notNull()
9293
+ });
9294
+ var mcpOauthAuthorizationRequests = pgTable19(
9295
+ "mcp_oauth_authorization_requests",
9296
+ {
9297
+ requestHash: text19("request_hash").primaryKey(),
9298
+ clientId: text19("client_id").notNull().references(() => mcpOauthClients.clientId, { onDelete: "cascade" }),
9299
+ ...mcpOauthGrantColumns(),
9300
+ redirectUri: text19("redirect_uri").notNull(),
9301
+ codeChallenge: text19("code_challenge").notNull(),
9302
+ state: text19("state"),
9303
+ expiresAt: timestamp19("expires_at", { withTimezone: true }).notNull(),
9304
+ createdAt: timestamp19("created_at", { withTimezone: true }).notNull().defaultNow()
9305
+ },
9306
+ (table) => ({
9307
+ workspaceAccount: foreignKey({
9308
+ name: "mcp_oauth_authorization_requests_workspace_account_fk",
9309
+ columns: [table.workspaceId, table.accountId],
9310
+ foreignColumns: [workspaces.id, workspaces.accountId]
9311
+ }).onDelete("cascade"),
9312
+ expires: index19("mcp_oauth_authorization_requests_expires_idx").on(table.expiresAt)
9313
+ })
9314
+ );
9315
+ var mcpOauthAuthorizationCodes = pgTable19(
9316
+ "mcp_oauth_authorization_codes",
9317
+ {
9318
+ codeHash: text19("code_hash").primaryKey(),
9319
+ clientId: text19("client_id").notNull().references(() => mcpOauthClients.clientId, { onDelete: "cascade" }),
9320
+ ...mcpOauthGrantColumns(),
9321
+ redirectUri: text19("redirect_uri").notNull(),
9322
+ codeChallenge: text19("code_challenge").notNull(),
9323
+ expiresAt: timestamp19("expires_at", { withTimezone: true }).notNull(),
9324
+ createdAt: timestamp19("created_at", { withTimezone: true }).notNull().defaultNow()
9325
+ },
9326
+ (table) => ({
9327
+ workspaceAccount: foreignKey({
9328
+ name: "mcp_oauth_authorization_codes_workspace_account_fk",
9329
+ columns: [table.workspaceId, table.accountId],
9330
+ foreignColumns: [workspaces.id, workspaces.accountId]
9331
+ }).onDelete("cascade"),
9332
+ expires: index19("mcp_oauth_authorization_codes_expires_idx").on(table.expiresAt)
9333
+ })
9334
+ );
9335
+ var mcpOauthRefreshTokens = pgTable19(
9336
+ "mcp_oauth_refresh_tokens",
9337
+ {
9338
+ tokenHash: text19("token_hash").primaryKey(),
9339
+ familyId: uuid19("family_id").notNull(),
9340
+ generation: integer18("generation").notNull(),
9341
+ clientId: text19("client_id").notNull().references(() => mcpOauthClients.clientId, { onDelete: "cascade" }),
9342
+ ...mcpOauthGrantColumns(),
9343
+ expiresAt: timestamp19("expires_at", { withTimezone: true }).notNull(),
9344
+ revokedAt: timestamp19("revoked_at", { withTimezone: true }),
9345
+ createdAt: timestamp19("created_at", { withTimezone: true }).notNull().defaultNow()
9346
+ },
9347
+ (table) => ({
9348
+ workspaceAccount: foreignKey({
9349
+ name: "mcp_oauth_refresh_tokens_workspace_account_fk",
9350
+ columns: [table.workspaceId, table.accountId],
9351
+ foreignColumns: [workspaces.id, workspaces.accountId]
9352
+ }).onDelete("cascade"),
9353
+ familyGeneration: uniqueIndex19("mcp_oauth_refresh_tokens_family_generation_uq").on(
9354
+ table.familyId,
9355
+ table.generation
9356
+ ),
9357
+ expires: index19("mcp_oauth_refresh_tokens_expires_idx").on(table.expiresAt)
9358
+ })
9359
+ );
9360
+ var mcpOauthAccessTokens = pgTable19(
9361
+ "mcp_oauth_access_tokens",
9362
+ {
9363
+ tokenHash: text19("token_hash").primaryKey(),
9364
+ refreshFamilyId: uuid19("refresh_family_id").notNull(),
9365
+ refreshGeneration: integer18("refresh_generation").notNull(),
9366
+ clientId: text19("client_id").notNull().references(() => mcpOauthClients.clientId, { onDelete: "cascade" }),
9367
+ ...mcpOauthGrantColumns(),
9368
+ expiresAt: timestamp19("expires_at", { withTimezone: true }).notNull(),
9369
+ revokedAt: timestamp19("revoked_at", { withTimezone: true }),
9370
+ createdAt: timestamp19("created_at", { withTimezone: true }).notNull().defaultNow()
9371
+ },
9372
+ (table) => ({
9373
+ workspaceAccount: foreignKey({
9374
+ name: "mcp_oauth_access_tokens_workspace_account_fk",
9375
+ columns: [table.workspaceId, table.accountId],
9376
+ foreignColumns: [workspaces.id, workspaces.accountId]
9377
+ }).onDelete("cascade"),
9378
+ family: index19("mcp_oauth_access_tokens_family_idx").on(
9379
+ table.refreshFamilyId,
9380
+ table.refreshGeneration
9381
+ ),
9382
+ expires: index19("mcp_oauth_access_tokens_expires_idx").on(table.expiresAt)
9383
+ })
9384
+ );
9385
+ var toolGatewayApprovalCapabilities = pgTable19(
9386
+ "tool_gateway_approval_capabilities",
9387
+ {
9388
+ tokenHash: text19("token_hash").primaryKey(),
9389
+ accountId: uuid19("account_id").notNull().references(() => managedAccounts.id, { onDelete: "cascade" }),
9390
+ workspaceId: uuid19("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
9391
+ subjectId: text19("subject_id").notNull(),
9392
+ operationId: uuid19("operation_id").notNull(),
9393
+ catalogDigest: text19("catalog_digest").notNull(),
9394
+ serverId: text19("server_id").notNull(),
9395
+ toolName: text19("tool_name").notNull(),
9396
+ argumentsDigest: text19("arguments_digest").notNull(),
9397
+ authorityDigest: text19("authority_digest").notNull(),
9398
+ expiresAt: timestamp19("expires_at", { withTimezone: true }).notNull(),
9399
+ consumedAt: timestamp19("consumed_at", { withTimezone: true }),
9400
+ createdAt: timestamp19("created_at", { withTimezone: true }).notNull().defaultNow()
9401
+ },
9402
+ (table) => ({
9403
+ workspaceAccount: foreignKey({
9404
+ name: "tool_gateway_approval_capabilities_workspace_account_fk",
9405
+ columns: [table.workspaceId, table.accountId],
9406
+ foreignColumns: [workspaces.id, workspaces.accountId]
9407
+ }).onDelete("cascade"),
9408
+ operation: uniqueIndex19("tool_gateway_approval_capabilities_operation_uq").on(
9409
+ table.workspaceId,
9410
+ table.subjectId,
9411
+ table.operationId
9412
+ ),
9413
+ expires: index19("tool_gateway_approval_capabilities_expires_idx").on(
9414
+ table.expiresAt,
9415
+ table.tokenHash
9416
+ ),
9417
+ liveSubjectExpiry: index19("tool_gateway_approval_capabilities_live_subject_expiry_idx").on(table.workspaceId, table.subjectId, table.expiresAt, table.tokenHash).where(sql16`${table.consumedAt} is null`),
9418
+ tokenHashValid: check11(
9419
+ "tool_gateway_approval_capabilities_token_hash_chk",
9420
+ sql16`${table.tokenHash} ~ '^[0-9a-f]{64}$'`
9421
+ ),
9422
+ catalogDigestValid: check11(
9423
+ "tool_gateway_approval_capabilities_catalog_digest_chk",
9424
+ sql16`${table.catalogDigest} ~ '^[0-9a-f]{64}$'`
9425
+ ),
9426
+ argumentsDigestValid: check11(
9427
+ "tool_gateway_approval_capabilities_arguments_digest_chk",
9428
+ sql16`${table.argumentsDigest} ~ '^[0-9a-f]{64}$'`
9429
+ ),
9430
+ authorityDigestValid: check11(
9431
+ "tool_gateway_approval_capabilities_authority_digest_chk",
9432
+ sql16`${table.authorityDigest} ~ '^[0-9a-f]{64}$'`
9433
+ ),
9434
+ subjectValid: check11(
9435
+ "tool_gateway_approval_capabilities_subject_chk",
9436
+ sql16`length(btrim(${table.subjectId})) between 1 and 1024`
9437
+ ),
9438
+ identityValid: check11(
9439
+ "tool_gateway_approval_capabilities_identity_chk",
9440
+ sql16`length(${table.serverId}) between 1 and 256
9441
+ and length(${table.toolName}) between 1 and 512`
9442
+ ),
9443
+ expiryValid: check11(
9444
+ "tool_gateway_approval_capabilities_expiry_chk",
9445
+ sql16`${table.expiresAt} > ${table.createdAt}
9446
+ and ${table.expiresAt} <= ${table.createdAt} + interval '10 minutes'`
9447
+ )
9448
+ })
9449
+ );
9248
9450
  var codexRotationSettings = pgTable19(
9249
9451
  "codex_rotation_settings",
9250
9452
  {
@@ -9252,14 +9454,10 @@ var codexRotationSettings = pgTable19(
9252
9454
  accountId: uuid19("account_id").notNull().references(() => managedAccounts.id, { onDelete: "cascade" }),
9253
9455
  workspaceId: uuid19("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
9254
9456
  activeCredentialId: uuid19("active_credential_id"),
9255
- // Legacy selector bit. Keep false as the DB default forever: an old worker
9256
- // only understands this column, so a schema-first rollout or binary
9257
- // rollback must never make it enter the non-atomic rotation path.
9457
+ // User-owned account-selection policy. When false, every new turn may lease
9458
+ // only the active credential and waits if that credential is unavailable.
9459
+ // When true, the allocator may choose another eligible account.
9258
9460
  rotationEnabled: boolean11("rotation_enabled").notNull().default(false),
9259
- // Revision-aware allocator cutover. Only migration-compatible API/worker
9260
- // code reads this bit; old binaries safely ignore it and keep the legacy
9261
- // pin/rotation policy.
9262
- leaseRotationEnabled: boolean11("lease_rotation_enabled").notNull().default(false),
9263
9461
  rotationStrategy: text19("rotation_strategy").notNull().default("sharded"),
9264
9462
  // sharded-rotation policy: legacy residue; behavior is always sharded
9265
9463
  createdAt: timestamp19("created_at", { withTimezone: true }).notNull().defaultNow(),
@@ -9292,9 +9490,12 @@ var codexCredentialLeases = pgTable19(
9292
9490
  workspaceId: uuid19("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
9293
9491
  credentialId: uuid19("credential_id").notNull(),
9294
9492
  turnId: uuid19("turn_id").notNull(),
9295
- // Temporal activity execution fence. A successor dispatch for the same
9296
- // durable turn replaces holderId and increments generation atomically;
9297
- // stale/zombie heartbeats and releases must match both values.
9493
+ // Durable turn-attempt fence. The worker holder includes the
9494
+ // durable workflow turn-attempt identity; dispatchId remains a separate
9495
+ // attempt/audit identity. A successor dispatch for the same durable turn
9496
+ // replaces holderId and increments generation atomically; stale/zombie
9497
+ // heartbeats and releases must match both values. Generation may restart
9498
+ // at 1 after an expired row is reaped, so holder identity cannot be reused.
9298
9499
  holderId: text19("holder_id").notNull(),
9299
9500
  generation: integer18("generation").notNull().default(1),
9300
9501
  leasedUntil: timestamp19("leased_until", { withTimezone: true }).notNull(),
@@ -9307,7 +9508,6 @@ var codexCredentialLeases = pgTable19(
9307
9508
  table.turnId
9308
9509
  ),
9309
9510
  activeCredential: index19("codex_credential_leases_active_credential_idx").on(
9310
- table.workspaceId,
9311
9511
  table.credentialId,
9312
9512
  table.leasedUntil
9313
9513
  ),
@@ -9662,6 +9862,14 @@ var sessions = pgTable19(
9662
9862
  nestedAgentDepthPolicySessionId: uuid19("nested_agent_depth_policy_session_id"),
9663
9863
  temporalWorkflowId: text19("temporal_workflow_id"),
9664
9864
  activeTurnId: uuid19("active_turn_id"),
9865
+ // Session-scoped out-of-turn wait (`wait_for_input`). The exact declaring
9866
+ // turn and absolute deadline are durable PostgreSQL authority; workflow
9867
+ // signals and timers only nudge reevaluation. A newer finished turn or a
9868
+ // terminal timeout input retires all four fields together.
9869
+ inputWaitTurnId: uuid19("input_wait_turn_id"),
9870
+ inputWaitUntil: timestamp19("input_wait_until", { withTimezone: true }),
9871
+ inputWaitReason: text19("input_wait_reason"),
9872
+ inputWaitSetAt: timestamp19("input_wait_set_at", { withTimezone: true }),
9665
9873
  // Actual input tokens reported for the latest authoritative ordinary model
9666
9874
  // call. Compaction/context clearing invalidates it to null; local history
9667
9875
  // estimates must never be stored here.
@@ -9814,6 +10022,21 @@ var sessions = pgTable19(
9814
10022
  "sessions_initial_model_context_check",
9815
10023
  sql16`${table.initialModelContext} is null
9816
10024
  or opengeni_private.model_context_value_valid(${table.initialModelContext})`
10025
+ ),
10026
+ inputWaitValid: check11(
10027
+ "sessions_input_wait_check",
10028
+ sql16`(
10029
+ ${table.inputWaitTurnId} is null
10030
+ and ${table.inputWaitUntil} is null
10031
+ and ${table.inputWaitReason} is null
10032
+ and ${table.inputWaitSetAt} is null
10033
+ ) or (
10034
+ ${table.inputWaitTurnId} is not null
10035
+ and ${table.inputWaitUntil} is not null
10036
+ and ${table.inputWaitReason} is not null
10037
+ and octet_length(btrim(${table.inputWaitReason})) between 1 and 2048
10038
+ and ${table.inputWaitSetAt} is not null
10039
+ )`
9817
10040
  )
9818
10041
  })
9819
10042
  );
@@ -12151,6 +12374,58 @@ var sessionAttemptToolCatalogs = pgTable19(
12151
12374
  )
12152
12375
  })
12153
12376
  );
12377
+ var sessionAttemptModelContextSnapshots = pgTable19(
12378
+ "session_attempt_model_context_snapshots",
12379
+ {
12380
+ attemptId: uuid19("attempt_id").primaryKey(),
12381
+ accountId: uuid19("account_id").notNull(),
12382
+ workspaceId: uuid19("workspace_id").notNull(),
12383
+ sessionId: uuid19("session_id").notNull(),
12384
+ turnId: uuid19("turn_id").notNull(),
12385
+ executionGeneration: integer18("execution_generation").notNull(),
12386
+ requestIndex: integer18("request_index").notNull(),
12387
+ capturedAt: timestamp19("captured_at", { withTimezone: true }).notNull(),
12388
+ snapshot: jsonb15("snapshot").$type().notNull(),
12389
+ createdAt: timestamp19("created_at", { withTimezone: true }).notNull(),
12390
+ updatedAt: timestamp19("updated_at", { withTimezone: true }).notNull()
12391
+ },
12392
+ (table) => ({
12393
+ attemptOwner: foreignKey({
12394
+ name: "session_attempt_model_context_snapshots_attempt_owner_fk",
12395
+ columns: [table.accountId, table.workspaceId, table.sessionId, table.turnId, table.attemptId],
12396
+ foreignColumns: [
12397
+ sessionTurnAttempts.accountId,
12398
+ sessionTurnAttempts.workspaceId,
12399
+ sessionTurnAttempts.sessionId,
12400
+ sessionTurnAttempts.turnId,
12401
+ sessionTurnAttempts.id
12402
+ ]
12403
+ }).onDelete("cascade"),
12404
+ sessionLatest: index19("session_attempt_model_context_snapshots_session_idx").on(
12405
+ table.workspaceId,
12406
+ table.sessionId,
12407
+ table.capturedAt.desc()
12408
+ ),
12409
+ requestIndexValid: check11(
12410
+ "session_attempt_model_context_snapshots_request_index_check",
12411
+ sql16`${table.requestIndex} > 0 and ${table.executionGeneration} > 0`
12412
+ ),
12413
+ snapshotSize: check11(
12414
+ "session_attempt_model_context_snapshots_size_check",
12415
+ sql16`octet_length(${table.snapshot}::text) between 2 and 16777216`
12416
+ ),
12417
+ snapshotIdentity: check11(
12418
+ "session_attempt_model_context_snapshots_identity_check",
12419
+ sql16`jsonb_typeof(${table.snapshot}) = 'object'
12420
+ and ${table.snapshot} ?& array['version', 'capturedAt', 'source', 'requestIndex', 'instructions', 'layers', 'tools', 'skills', 'tokens']::text[]
12421
+ and (${table.snapshot}->>'version')::integer = 1
12422
+ and ${table.snapshot}->>'source' = 'model_request'
12423
+ and jsonb_typeof(${table.snapshot}->'layers') = 'array'
12424
+ and jsonb_typeof(${table.snapshot}->'tools') = 'array'
12425
+ and jsonb_typeof(${table.snapshot}->'skills') = 'array'`
12426
+ )
12427
+ })
12428
+ );
12154
12429
  var sessionAttemptCodemodeCalls = pgTable19(
12155
12430
  "session_attempt_codemode_calls",
12156
12431
  {
@@ -12470,6 +12745,7 @@ var sessionCommandReceipts = pgTable19(
12470
12745
  table.operationKey
12471
12746
  ).where(sql16`${table.action} in ('prompt.send', 'prompt.steer')`),
12472
12747
  goalUpdateOperation: uniqueIndex19("session_command_receipts_goal_update_operation_uq").on(table.workspaceId, table.action, table.targetSessionId, table.operationKey).where(sql16`${table.action} = 'goal.update'`),
12748
+ waitForInputOperation: uniqueIndex19("session_command_receipts_wait_for_input_operation_uq").on(table.workspaceId, table.action, table.targetSessionId, table.operationKey).where(sql16`${table.action} = 'session.wait_for_input'`),
12473
12749
  actorValid: check11(
12474
12750
  "session_command_receipts_actor_check",
12475
12751
  sql16`(
@@ -12714,7 +12990,7 @@ var sessionSystemUpdates = pgTable19(
12714
12990
  (table) => ({
12715
12991
  kindValid: check11(
12716
12992
  "system_updates_kind_check",
12717
- sql16`${table.kind} in ('scheduled_occurrence', 'goal_continuation', 'agent_message', 'agent_steer_instruction', 'child_terminal_result', 'media_generation_result', 'child_requires_action', 'child_requires_action_resolved', 'child_paused', 'child_waiting_capacity', 'child_progress')`
12993
+ sql16`${table.kind} in ('scheduled_occurrence', 'goal_continuation', 'agent_message', 'agent_steer_instruction', 'session_wait_timeout', 'background_command_result', 'child_terminal_result', 'media_generation_result', 'child_requires_action', 'child_requires_action_resolved', 'child_paused', 'child_waiting_capacity', 'child_progress')`
12718
12994
  ),
12719
12995
  payloadKindValid: check11(
12720
12996
  "system_updates_payload_kind_check",
@@ -12885,19 +13161,10 @@ var sessionGoals = pgTable19(
12885
13161
  continuationObservedRevision: bigint14("continuation_observed_revision", {
12886
13162
  mode: "number"
12887
13163
  }).notNull().default(0),
12888
- // Agent-declared continuation hold (`goal_wait`, migration 0317). Honored
12889
- // only while `continuationHoldTurnId` is still the latest finished turn and
12890
- // the deadline has not passed; it never consumes the wake/observed ledger.
12891
- // Any newer finished turn, a passed deadline, or a goal mutation clears all
12892
- // four columns together.
12893
- continuationHoldTurnId: uuid19("continuation_hold_turn_id"),
12894
- continuationHoldUntil: timestamp19("continuation_hold_until", {
12895
- withTimezone: true
12896
- }),
12897
- continuationHoldReason: text19("continuation_hold_reason"),
12898
- continuationHoldSetAt: timestamp19("continuation_hold_set_at", {
12899
- withTimezone: true
12900
- }),
13164
+ // A terminal condition can keep the goal active while making unchanged
13165
+ // autonomous input unsafe. The fence is honored only while this remains
13166
+ // the newest finished turn; newer work or a goal mutation clears it.
13167
+ continuationSuppressedTurnId: uuid19("continuation_suppressed_turn_id"),
12901
13168
  metadata: jsonb15("metadata").$type().notNull().default({}),
12902
13169
  createdAt: timestamp19("created_at", { withTimezone: true }).notNull().defaultNow(),
12903
13170
  updatedAt: timestamp19("updated_at", { withTimezone: true }).notNull().defaultNow()
@@ -12915,10 +13182,6 @@ var sessionGoals = pgTable19(
12915
13182
  continuationRevisionValid: check11(
12916
13183
  "session_goals_continuation_revision_check",
12917
13184
  sql16`${table.continuationWakeRevision} >= 0 and ${table.continuationObservedRevision} >= 0 and ${table.continuationObservedRevision} <= ${table.continuationWakeRevision} and ${table.continuationWakeRevision} <= 9007199254740991 and ${table.continuationObservedRevision} <= 9007199254740991`
12918
- ),
12919
- continuationHoldValid: check11(
12920
- "session_goals_continuation_hold_check",
12921
- sql16`(${table.continuationHoldTurnId} is null and ${table.continuationHoldUntil} is null and ${table.continuationHoldReason} is null and ${table.continuationHoldSetAt} is null) or (${table.continuationHoldTurnId} is not null and ${table.continuationHoldUntil} is not null and ${table.continuationHoldSetAt} is not null and (${table.continuationHoldReason} is null or octet_length(${table.continuationHoldReason}) <= 2048))`
12922
13185
  )
12923
13186
  })
12924
13187
  );
@@ -13032,7 +13295,7 @@ var codexCapacityWaiters = pgTable19(
13032
13295
  earliestResetAt: timestamp19("earliest_reset_at", { withTimezone: true }),
13033
13296
  nextCheckAt: timestamp19("next_check_at", { withTimezone: true }).notNull(),
13034
13297
  resetKind: text19("reset_kind").notNull(),
13035
- // authoritative | bounded_refresh
13298
+ // authoritative | bounded_refresh | mutation_only
13036
13299
  refreshAttempt: integer18("refresh_attempt").notNull().default(0),
13037
13300
  // Coalescing outbox generation. Every eligibility-affecting mutation bumps
13038
13301
  // wakeRevision. Duplicate/lost Temporal signals are harmless because only
@@ -17664,6 +17927,12 @@ export {
17664
17927
  slackBotDeleteOperations,
17665
17928
  integrationOauthClients,
17666
17929
  integrationOauthStateNonces,
17930
+ mcpOauthClients,
17931
+ mcpOauthAuthorizationRequests,
17932
+ mcpOauthAuthorizationCodes,
17933
+ mcpOauthRefreshTokens,
17934
+ mcpOauthAccessTokens,
17935
+ toolGatewayApprovalCapabilities,
17667
17936
  codexRotationSettings,
17668
17937
  workspaceModelPolicies,
17669
17938
  codexCredentialLeases,
@@ -17706,6 +17975,7 @@ export {
17706
17975
  turnConnectionAuthoritySnapshots,
17707
17976
  connectionUseAuditFacts,
17708
17977
  sessionAttemptToolCatalogs,
17978
+ sessionAttemptModelContextSnapshots,
17709
17979
  sessionAttemptCodemodeCalls,
17710
17980
  connectorActionRequests,
17711
17981
  sessionCommandReceipts,
@@ -17822,4 +18092,4 @@ export {
17822
18092
  organizationModelProviderCustomModels,
17823
18093
  schema_exports
17824
18094
  };
17825
- //# sourceMappingURL=chunk-53A2PEHT.js.map
18095
+ //# sourceMappingURL=chunk-QM6YOWHZ.js.map