@opengeni/db 3.6.0 → 3.7.4-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 (92) hide show
  1. package/dist/automations.d.ts +4 -0
  2. package/dist/canonical-human-identities.js +3 -3
  3. package/dist/{chunk-UGDVSQ6U.js → chunk-3ZMN4EXC.js} +2 -2
  4. package/dist/{chunk-744DFC65.js → chunk-6FIVOJ3V.js} +96 -6
  5. package/dist/chunk-6FIVOJ3V.js.map +1 -0
  6. package/dist/{chunk-UJ2EW3QI.js → chunk-DXJ2WY6W.js} +427 -85
  7. package/dist/chunk-DXJ2WY6W.js.map +1 -0
  8. package/dist/{chunk-CDMMSUWJ.js → chunk-JP6IYGYI.js} +3 -3
  9. package/dist/{chunk-Q5YUGQVK.js → chunk-JS3AWDKZ.js} +3 -3
  10. package/dist/{chunk-G3732M3T.js → chunk-LHKB62GC.js} +2 -2
  11. package/dist/{chunk-2NT476HD.js → chunk-QL4AHBYD.js} +2 -2
  12. package/dist/{chunk-IW6O6G7R.js → chunk-VDXHLVDE.js} +2 -2
  13. package/dist/{chunk-WW7AJ5IC.js → chunk-ZTSJPFDH.js} +5 -7
  14. package/dist/chunk-ZTSJPFDH.js.map +1 -0
  15. package/dist/codex-token-resolver.d.ts +12 -1
  16. package/dist/company-profile-agent-admin.d.ts +4 -2
  17. package/dist/company-profile-agent-policy.d.ts +20 -0
  18. package/dist/company-profile-schema.d.ts +573 -0
  19. package/dist/editable-artifact-durable-export.js +2 -2
  20. package/dist/editable-artifacts.js +3 -3
  21. package/dist/index.d.ts +487 -20
  22. package/dist/index.js +9489 -6041
  23. package/dist/index.js.map +1 -1
  24. package/dist/managed-auth-session-sets.js +3 -3
  25. package/dist/managed-human-provisioning.d.ts +3 -3
  26. package/dist/memory-domain.d.ts +5 -3
  27. package/dist/model-catalog.d.ts +153 -0
  28. package/dist/pr-review.d.ts +9 -0
  29. package/dist/provision-roles.js +1 -1
  30. package/dist/runtime-posture.d.ts +7 -7
  31. package/dist/schema.d.ts +1069 -6
  32. package/dist/schema.js +17 -1
  33. package/dist/session-background-commands.js +3 -3
  34. package/dist/session-control.d.ts +75 -5
  35. package/dist/session-queue-commands.d.ts +19 -0
  36. package/dist/session-tenancy.js +3 -3
  37. package/dist/user-resource-authority.d.ts +8 -0
  38. package/dist/video-generation.js +3 -3
  39. package/dist/xai-subscription.d.ts +8 -0
  40. package/drizzle/0369_local_human_personal_authority.sql +350 -0
  41. package/drizzle/0370_workspace_member_management_scope.sql +98 -0
  42. package/drizzle/0371_workspace_member_candidate_inventory.sql +128 -0
  43. package/drizzle/0372_ordered_variable_set_runtime_authority.sql +287 -0
  44. package/drizzle/0373_sandbox_shared_preparation.sql +59 -0
  45. package/drizzle/0374_session_event_cursors.sql +315 -0
  46. package/drizzle/0375_session_recovery_observability.sql +73 -0
  47. package/drizzle/0376_organization_workspace_inventory.sql +88 -0
  48. package/drizzle/0377_scoped_rig_health_projection.sql +80 -0
  49. package/drizzle/0378_scoped_rig_health_audit_timestamp.sql +77 -0
  50. package/drizzle/0379_session_event_raw_lane_activation.sql +518 -0
  51. package/drizzle/0380_autonomous_company_profile_agent_policy.sql +829 -0
  52. package/drizzle/0381_organization_codex_subscription_inheritance.sql +720 -0
  53. package/drizzle/0382_organization_api_key_provenance.sql +91 -0
  54. package/drizzle/0383_codex_cooldown_reconciliation.sql +51 -0
  55. package/drizzle/0384_codex_cooldown_revision_guard_privileges.sql +6 -0
  56. package/drizzle/0385_connected_machine_legacy_tilde_workdirs.sql +25 -0
  57. package/drizzle/0386_local_organization_administration.sql +157 -0
  58. package/drizzle/0387_bound_host_export_session_payloads.sql +165 -0
  59. package/drizzle/0388_sandbox_provider_deadline_interactions.sql +491 -0
  60. package/drizzle/0389_model_catalog_and_gateway_custom_models.sql +241 -0
  61. package/package.json +6 -6
  62. package/src/automations.ts +9 -1
  63. package/src/codex-token-resolver.ts +26 -1
  64. package/src/company-brain-governed-writes.ts +30 -1
  65. package/src/company-profile-agent-admin.ts +68 -1
  66. package/src/company-profile-agent-policy.ts +126 -0
  67. package/src/company-profile-schema.ts +115 -1
  68. package/src/database.ts +3 -5
  69. package/src/index.ts +4473 -570
  70. package/src/insights.ts +21 -7
  71. package/src/managed-human-provisioning.ts +3 -3
  72. package/src/memory-domain.ts +9 -4
  73. package/src/model-catalog.ts +682 -0
  74. package/src/organization-membership-lifecycle.ts +0 -1
  75. package/src/pr-review.ts +19 -0
  76. package/src/provision-roles.ts +83 -4
  77. package/src/runtime-posture.ts +26 -0
  78. package/src/schema.ts +259 -10
  79. package/src/session-control.ts +347 -59
  80. package/src/session-queue-commands.ts +303 -122
  81. package/src/session-tool-call-settlement.ts +34 -7
  82. package/src/user-resource-authority.ts +56 -0
  83. package/src/xai-subscription.ts +66 -14
  84. package/dist/chunk-744DFC65.js.map +0 -1
  85. package/dist/chunk-UJ2EW3QI.js.map +0 -1
  86. package/dist/chunk-WW7AJ5IC.js.map +0 -1
  87. /package/dist/{chunk-UGDVSQ6U.js.map → chunk-3ZMN4EXC.js.map} +0 -0
  88. /package/dist/{chunk-CDMMSUWJ.js.map → chunk-JP6IYGYI.js.map} +0 -0
  89. /package/dist/{chunk-Q5YUGQVK.js.map → chunk-JS3AWDKZ.js.map} +0 -0
  90. /package/dist/{chunk-G3732M3T.js.map → chunk-LHKB62GC.js.map} +0 -0
  91. /package/dist/{chunk-2NT476HD.js.map → chunk-QL4AHBYD.js.map} +0 -0
  92. /package/dist/{chunk-IW6O6G7R.js.map → chunk-VDXHLVDE.js.map} +0 -0
@@ -52,6 +52,7 @@ __export(schema_exports, {
52
52
  companyBrainContextSelectionReceipts: () => companyBrainContextSelectionReceipts,
53
53
  companyBrainTurnContextSnapshots: () => companyBrainTurnContextSnapshots,
54
54
  companyProfileActivationEvents: () => companyProfileActivationEvents,
55
+ companyProfileAgentAutomaticActivationReceipts: () => companyProfileAgentAutomaticActivationReceipts,
55
56
  companyProfileAgentConfirmationReceipts: () => companyProfileAgentConfirmationReceipts,
56
57
  companyProfileAgentProposalReceipts: () => companyProfileAgentProposalReceipts,
57
58
  companyProfileHeads: () => companyProfileHeads,
@@ -67,6 +68,7 @@ __export(schema_exports, {
67
68
  connectorActionPolicies: () => connectorActionPolicies,
68
69
  connectorActionRequests: () => connectorActionRequests,
69
70
  creditLedgerEntries: () => creditLedgerEntries,
71
+ deploymentModelCatalog: () => deploymentModelCatalog,
70
72
  deviceEnrollmentRequests: () => deviceEnrollmentRequests,
71
73
  deviceEnrollmentStatusValues: () => deviceEnrollmentStatusValues,
72
74
  documentBases: () => documentBases,
@@ -166,6 +168,9 @@ __export(schema_exports, {
166
168
  nestedAgentDepthConfiguration: () => nestedAgentDepthConfiguration,
167
169
  networkRoutes: () => networkRoutes,
168
170
  newSessionDrafts: () => newSessionDrafts,
171
+ organizationCodexRotationSettings: () => organizationCodexRotationSettings,
172
+ organizationCompanyProfileAgentPolicies: () => organizationCompanyProfileAgentPolicies,
173
+ organizationCompanyProfileAgentPolicyEvents: () => organizationCompanyProfileAgentPolicyEvents,
169
174
  organizationInvitationBindingEvents: () => organizationInvitationBindingEvents,
170
175
  organizationMembershipInvitations: () => organizationMembershipInvitations,
171
176
  organizationMembershipLifecycleEvents: () => organizationMembershipLifecycleEvents,
@@ -230,6 +235,7 @@ __export(schema_exports, {
230
235
  sessionAttemptToolCatalogs: () => sessionAttemptToolCatalogs,
231
236
  sessionBackgroundCommands: () => sessionBackgroundCommands,
232
237
  sessionCommandReceipts: () => sessionCommandReceipts,
238
+ sessionEventCursors: () => sessionEventCursors,
233
239
  sessionEvents: () => sessionEvents,
234
240
  sessionGoalRevisions: () => sessionGoalRevisions,
235
241
  sessionGoals: () => sessionGoals,
@@ -309,7 +315,9 @@ __export(schema_exports, {
309
315
  workspaceArtifactVersions: () => workspaceArtifactVersions,
310
316
  workspaceArtifacts: () => workspaceArtifacts,
311
317
  workspaceCaptures: () => workspaceCaptures,
318
+ workspaceCodexSubscriptionPreferences: () => workspaceCodexSubscriptionPreferences,
312
319
  workspaceControlEvents: () => workspaceControlEvents,
320
+ workspaceGatewayCustomModels: () => workspaceGatewayCustomModels,
313
321
  workspaceInferenceControls: () => workspaceInferenceControls,
314
322
  workspaceInstructionPolicyActivationEvents: () => workspaceInstructionPolicyActivationEvents,
315
323
  workspaceInstructionPolicyDeactivationEvents: () => workspaceInstructionPolicyDeactivationEvents,
@@ -342,7 +350,7 @@ import { WORKSPACE_XAI_PROVIDER_ACCOUNT_AUTHORITY_SNAPSHOT_V1 } from "@opengeni/
342
350
  import { sql as sql16 } from "drizzle-orm";
343
351
  import {
344
352
  bigint as bigint14,
345
- boolean as boolean10,
353
+ boolean as boolean11,
346
354
  check as check11,
347
355
  customType as customType5,
348
356
  foreignKey,
@@ -2198,6 +2206,7 @@ var workspaceInstructionPolicySnapshots = pgTable4(
2198
2206
  import { sql as sql5 } from "drizzle-orm";
2199
2207
  import {
2200
2208
  bigint as bigint5,
2209
+ boolean as boolean3,
2201
2210
  check as check3,
2202
2211
  index as index5,
2203
2212
  integer as integer6,
@@ -2298,6 +2307,55 @@ var companyProfileActivationEvents = pgTable5(
2298
2307
  type: check3("company_profile_events_type_chk", sql5`${table.type} in ('activate', 'rollback')`)
2299
2308
  })
2300
2309
  );
2310
+ var organizationCompanyProfileAgentPolicies = pgTable5(
2311
+ "organization_company_profile_agent_policies",
2312
+ {
2313
+ accountId: uuid5("account_id").primaryKey(),
2314
+ mode: text5("mode").$type().notNull().default("suggest"),
2315
+ version: bigint5("version", { mode: "number" }).notNull().default(0),
2316
+ updatedByMembershipId: uuid5("updated_by_membership_id"),
2317
+ updatedAt: timestamp5("updated_at", { withTimezone: true }).notNull().defaultNow()
2318
+ },
2319
+ (table) => ({
2320
+ mode: check3(
2321
+ "organization_company_profile_agent_policies_mode_check",
2322
+ sql5`${table.mode} in ('off', 'suggest', 'automatic')`
2323
+ ),
2324
+ version: check3(
2325
+ "organization_company_profile_agent_policies_version_check",
2326
+ sql5`${table.version} >= 0`
2327
+ )
2328
+ })
2329
+ );
2330
+ var organizationCompanyProfileAgentPolicyEvents = pgTable5(
2331
+ "organization_company_profile_agent_policy_events",
2332
+ {
2333
+ id: uuid5("id").primaryKey(),
2334
+ accountId: uuid5("account_id").notNull(),
2335
+ actorMembershipId: uuid5("actor_membership_id").notNull(),
2336
+ requestedMode: text5("requested_mode").$type().notNull(),
2337
+ expectedVersion: bigint5("expected_version", { mode: "number" }).notNull(),
2338
+ resultMode: text5("result_mode").$type().notNull(),
2339
+ resultVersion: bigint5("result_version", { mode: "number" }).notNull(),
2340
+ resultUpdatedAt: timestamp5("result_updated_at", { withTimezone: true }).notNull(),
2341
+ changed: boolean3("changed").notNull()
2342
+ },
2343
+ (table) => ({
2344
+ accountTimeline: index5("organization_company_profile_agent_policy_events_account_idx").on(
2345
+ table.accountId,
2346
+ table.resultVersion
2347
+ ),
2348
+ modes: check3(
2349
+ "organization_company_profile_agent_policy_events_mode_check",
2350
+ sql5`${table.requestedMode} in ('off', 'suggest', 'automatic')
2351
+ and ${table.resultMode} in ('off', 'suggest', 'automatic')`
2352
+ ),
2353
+ versions: check3(
2354
+ "organization_company_profile_agent_policy_events_version_check",
2355
+ sql5`${table.expectedVersion} >= 0 and ${table.resultVersion} > 0`
2356
+ )
2357
+ })
2358
+ );
2301
2359
  var companyProfileSnapshots = pgTable5(
2302
2360
  "company_profile_snapshots",
2303
2361
  {
@@ -2350,6 +2408,8 @@ var companyProfileAgentProposalReceipts = pgTable5(
2350
2408
  revisionId: uuid5("revision_id").notNull(),
2351
2409
  expectedCurrentRevisionId: uuid5("expected_current_revision_id"),
2352
2410
  expectedActivationVersion: bigint5("expected_activation_version", { mode: "number" }).notNull(),
2411
+ policyMode: text5("policy_mode").$type().notNull(),
2412
+ policyVersion: bigint5("policy_version", { mode: "number" }).notNull(),
2353
2413
  reason: text5("reason").notNull(),
2354
2414
  humanInput: jsonb5("human_input").$type().notNull(),
2355
2415
  createdAt: timestamp5("created_at", { withTimezone: true }).notNull().defaultNow()
@@ -2379,7 +2439,9 @@ var companyProfileAgentProposalReceipts = pgTable5(
2379
2439
  ),
2380
2440
  generation: check3(
2381
2441
  "company_profile_agent_proposals_generation_check",
2382
- sql5`${table.executionGeneration} > 0 and ${table.expectedActivationVersion} >= 0`
2442
+ sql5`${table.executionGeneration} > 0
2443
+ and ${table.expectedActivationVersion} >= 0
2444
+ and ${table.policyVersion} >= 0`
2383
2445
  ),
2384
2446
  subject: check3(
2385
2447
  "company_profile_agent_proposals_subject_check",
@@ -2390,6 +2452,10 @@ var companyProfileAgentProposalReceipts = pgTable5(
2390
2452
  sql5`char_length(btrim(${table.reason})) between 1 and 4096
2391
2453
  and octet_length(convert_to(btrim(${table.reason}), 'UTF8')) <= 16384`
2392
2454
  ),
2455
+ policyMode: check3(
2456
+ "company_profile_agent_proposals_policy_mode_check",
2457
+ sql5`${table.policyMode} in ('suggest', 'automatic')`
2458
+ ),
2393
2459
  humanInputShape: check3(
2394
2460
  "company_profile_agent_proposals_human_input_check",
2395
2461
  sql5`jsonb_typeof(${table.humanInput}) = 'object'
@@ -2446,6 +2512,58 @@ var companyProfileAgentConfirmationReceipts = pgTable5(
2446
2512
  )
2447
2513
  })
2448
2514
  );
2515
+ var companyProfileAgentAutomaticActivationReceipts = pgTable5(
2516
+ "company_profile_agent_automatic_activation_receipts",
2517
+ {
2518
+ id: uuid5("id").primaryKey().defaultRandom(),
2519
+ operationId: uuid5("operation_id").notNull(),
2520
+ inputHash: text5("input_hash").notNull(),
2521
+ accountId: uuid5("account_id").notNull(),
2522
+ workspaceId: uuid5("workspace_id").notNull(),
2523
+ sessionId: uuid5("session_id").notNull(),
2524
+ turnId: uuid5("turn_id").notNull(),
2525
+ activationAttemptId: uuid5("activation_attempt_id").notNull(),
2526
+ executionGeneration: integer6("execution_generation").notNull(),
2527
+ proposalReceiptId: uuid5("proposal_receipt_id").notNull(),
2528
+ proposalRevisionId: uuid5("proposal_revision_id").notNull(),
2529
+ initiatingHumanSubjectId: text5("initiating_human_subject_id").notNull(),
2530
+ initiatingMembershipId: uuid5("initiating_membership_id").notNull(),
2531
+ policyVersion: bigint5("policy_version", { mode: "number" }).notNull(),
2532
+ activationEventId: uuid5("activation_event_id").notNull(),
2533
+ createdAt: timestamp5("created_at", { withTimezone: true }).notNull().defaultNow()
2534
+ },
2535
+ (table) => ({
2536
+ accountOperation: uniqueIndex5(
2537
+ "company_profile_agent_automatic_activations_account_operation_uq"
2538
+ ).on(table.accountId, table.operationId),
2539
+ proposal: uniqueIndex5("company_profile_agent_automatic_activations_proposal_uq").on(
2540
+ table.accountId,
2541
+ table.proposalReceiptId
2542
+ ),
2543
+ activationEvent: uniqueIndex5("company_profile_agent_automatic_activations_event_uq").on(
2544
+ table.accountId,
2545
+ table.activationEventId
2546
+ ),
2547
+ turn: index5("company_profile_agent_automatic_activations_turn_idx").on(
2548
+ table.workspaceId,
2549
+ table.sessionId,
2550
+ table.turnId,
2551
+ table.executionGeneration
2552
+ ),
2553
+ hash: check3(
2554
+ "company_profile_agent_automatic_activations_input_hash_check",
2555
+ sql5`${table.inputHash} ~ '^[0-9a-f]{64}$'`
2556
+ ),
2557
+ generation: check3(
2558
+ "company_profile_agent_automatic_activations_generation_check",
2559
+ sql5`${table.executionGeneration} > 0 and ${table.policyVersion} >= 0`
2560
+ ),
2561
+ subject: check3(
2562
+ "company_profile_agent_automatic_activations_subject_check",
2563
+ sql5`octet_length(btrim(${table.initiatingHumanSubjectId})) between 1 and 1024`
2564
+ )
2565
+ })
2566
+ );
2449
2567
 
2450
2568
  // src/workspace-learning-policy-schema.ts
2451
2569
  import { sql as sql6 } from "drizzle-orm";
@@ -2713,7 +2831,7 @@ var slackSharedTaskOrigins = pgTable7(
2713
2831
  import { sql as sql8 } from "drizzle-orm";
2714
2832
  import {
2715
2833
  bigint as bigint8,
2716
- boolean as boolean3,
2834
+ boolean as boolean4,
2717
2835
  check as check6,
2718
2836
  index as index8,
2719
2837
  integer as integer8,
@@ -2845,7 +2963,7 @@ var preferenceRegistrySnapshots = pgTable8(
2845
2963
  initiatingHumanSubjectId: text8("initiating_human_subject_id").notNull(),
2846
2964
  descriptors: jsonb8("descriptors").$type().notNull(),
2847
2965
  descriptorHash: text8("descriptor_hash").notNull(),
2848
- truncated: boolean3("truncated").notNull().default(false),
2966
+ truncated: boolean4("truncated").notNull().default(false),
2849
2967
  createdAt: timestamp8("created_at", { withTimezone: true }).notNull().defaultNow()
2850
2968
  },
2851
2969
  (table) => ({
@@ -3023,7 +3141,7 @@ var knowledgeMemoryLifecycleEvents = pgTable9(
3023
3141
  import { sql as sql10 } from "drizzle-orm";
3024
3142
  import {
3025
3143
  bigint as bigint9,
3026
- boolean as boolean4,
3144
+ boolean as boolean5,
3027
3145
  index as index10,
3028
3146
  integer as integer10,
3029
3147
  jsonb as jsonb10,
@@ -3161,7 +3279,7 @@ var knowledgeSourceAclVersions = pgTable10(
3161
3279
  generation: bigint9("generation", { mode: "number" }).notNull(),
3162
3280
  aclVersion: text10("acl_version"),
3163
3281
  aclHash: text10("acl_hash").notNull(),
3164
- agentAccess: boolean4("agent_access").notNull().default(true),
3282
+ agentAccess: boolean5("agent_access").notNull().default(true),
3165
3283
  operationId: text10("operation_id").notNull(),
3166
3284
  inputHash: text10("input_hash").notNull(),
3167
3285
  ...actorColumns(),
@@ -3935,7 +4053,7 @@ var sessionWorkClaimWriteCapabilities = pgTable12(
3935
4053
 
3936
4054
  // src/company-brain-context-selection-schema.ts
3937
4055
  import {
3938
- boolean as boolean5,
4056
+ boolean as boolean6,
3939
4057
  index as index13,
3940
4058
  integer as integer13,
3941
4059
  jsonb as jsonb11,
@@ -3958,9 +4076,9 @@ var companyBrainContextSelectionReceipts = pgTable13(
3958
4076
  createdByExecutionGeneration: integer13("created_by_execution_generation").notNull(),
3959
4077
  acceptedAt: timestamp13("accepted_at", { withTimezone: true }).notNull(),
3960
4078
  sessionRole: text13("session_role").notNull(),
3961
- memoryEnabled: boolean5("memory_enabled").notNull(),
4079
+ memoryEnabled: boolean6("memory_enabled").notNull(),
3962
4080
  memoryPromptMode: text13("memory_prompt_mode").notNull(),
3963
- companyProfileIncluded: boolean5("company_profile_included").notNull(),
4081
+ companyProfileIncluded: boolean6("company_profile_included").notNull(),
3964
4082
  instructionPolicyEntryHash: text13("instruction_policy_entry_hash").notNull(),
3965
4083
  preferenceDescriptorHash: text13("preference_descriptor_hash"),
3966
4084
  companyProfileSnapshotHash: text13("company_profile_snapshot_hash").notNull(),
@@ -3994,13 +4112,13 @@ var companyBrainTurnContextSnapshots = pgTable13(
3994
4112
  rootSessionId: uuid13("root_session_id").notNull(),
3995
4113
  turnId: uuid13("turn_id").notNull(),
3996
4114
  acceptedAt: timestamp13("accepted_at", { withTimezone: true }).notNull(),
3997
- memoryEnabled: boolean5("memory_enabled").notNull(),
4115
+ memoryEnabled: boolean6("memory_enabled").notNull(),
3998
4116
  memoryPromptMode: text13("memory_prompt_mode").notNull(),
3999
4117
  legacyWorkspaceInstructions: text13("legacy_workspace_instructions"),
4000
4118
  legacyWorkspaceInstructionsOriginalUtf8Bytes: integer13(
4001
4119
  "legacy_workspace_instructions_original_utf8_bytes"
4002
4120
  ),
4003
- legacyWorkspaceInstructionsTruncated: boolean5(
4121
+ legacyWorkspaceInstructionsTruncated: boolean6(
4004
4122
  "legacy_workspace_instructions_truncated"
4005
4123
  ).notNull(),
4006
4124
  snapshotSource: text13("snapshot_source").notNull(),
@@ -4022,7 +4140,7 @@ var companyBrainTurnContextSnapshots = pgTable13(
4022
4140
  // src/governed-learning-evaluator-schema.ts
4023
4141
  import {
4024
4142
  bigint as bigint10,
4025
- boolean as boolean6,
4143
+ boolean as boolean7,
4026
4144
  index as index14,
4027
4145
  integer as integer14,
4028
4146
  pgTable as pgTable14,
@@ -4066,7 +4184,7 @@ var governedLearningDecisionReceipts = pgTable14(
4066
4184
  conflictCount: integer14("conflict_count").notNull(),
4067
4185
  outcome: text14("outcome").notNull(),
4068
4186
  reasonCodes: text14("reason_codes").array().$type().notNull(),
4069
- automaticEligible: boolean6("automatic_eligible").notNull(),
4187
+ automaticEligible: boolean7("automatic_eligible").notNull(),
4070
4188
  confidenceFloorBps: integer14("confidence_floor_bps").notNull(),
4071
4189
  createdAt: timestamp14("created_at", { withTimezone: true }).notNull().defaultNow()
4072
4190
  },
@@ -4210,7 +4328,7 @@ var governedLearningActivationUndoReceipts = pgTable15(
4210
4328
  // src/knowledge-source-sync-schema.ts
4211
4329
  import {
4212
4330
  bigint as bigint12,
4213
- boolean as boolean7,
4331
+ boolean as boolean8,
4214
4332
  index as index16,
4215
4333
  integer as integer15,
4216
4334
  jsonb as jsonb12,
@@ -4250,9 +4368,9 @@ var knowledgeSourceSyncStates = pgTable16(
4250
4368
  pendingWakeCount: integer15("pending_wake_count").notNull().default(0),
4251
4369
  leaseId: uuid16("lease_id"),
4252
4370
  leaseUntil: timestamp16("lease_until", { withTimezone: true }),
4253
- bufferedWake: boolean7("buffered_wake").notNull().default(false),
4371
+ bufferedWake: boolean8("buffered_wake").notNull().default(false),
4254
4372
  bufferedScheduledTaskRunId: uuid16("buffered_scheduled_task_run_id"),
4255
- reconnectRequired: boolean7("reconnect_required").notNull().default(false),
4373
+ reconnectRequired: boolean8("reconnect_required").notNull().default(false),
4256
4374
  lastSuccessAt: timestamp16("last_success_at", { withTimezone: true }),
4257
4375
  lastCompletedAt: timestamp16("last_completed_at", { withTimezone: true }),
4258
4376
  lastSummary: jsonb12("last_summary").$type(),
@@ -4343,7 +4461,7 @@ var knowledgeSourceSyncWakes = pgTable16(
4343
4461
  producerKey: text16("producer_key").notNull(),
4344
4462
  sourceConfigGeneration: bigint12("source_config_generation", { mode: "number" }).notNull(),
4345
4463
  sourceLifecycleGeneration: bigint12("source_lifecycle_generation", { mode: "number" }).notNull(),
4346
- coalesced: boolean7("coalesced").notNull().default(false),
4464
+ coalesced: boolean8("coalesced").notNull().default(false),
4347
4465
  claimedAt: timestamp16("claimed_at", { withTimezone: true }),
4348
4466
  completedAt: timestamp16("completed_at", { withTimezone: true }),
4349
4467
  createdAt: timestamp16("created_at", { withTimezone: true }).notNull().defaultNow()
@@ -4458,8 +4576,8 @@ var googleDriveObjectAclPrincipals = pgTable16(
4458
4576
  emailHash: text16("email_hash"),
4459
4577
  domainHash: text16("domain_hash"),
4460
4578
  role: text16("role").notNull(),
4461
- inherited: boolean7("inherited").notNull().default(false),
4462
- allowFileDiscovery: boolean7("allow_file_discovery"),
4579
+ inherited: boolean8("inherited").notNull().default(false),
4580
+ allowFileDiscovery: boolean8("allow_file_discovery"),
4463
4581
  expirationTime: timestamp16("expiration_time", { withTimezone: true }),
4464
4582
  createdAt: timestamp16("created_at", { withTimezone: true }).notNull().defaultNow()
4465
4583
  },
@@ -4478,7 +4596,7 @@ var googleDriveObjectAclPrincipals = pgTable16(
4478
4596
  // src/transcription-recordings-schema.ts
4479
4597
  import { sql as sql14 } from "drizzle-orm";
4480
4598
  import {
4481
- boolean as boolean8,
4599
+ boolean as boolean9,
4482
4600
  check as check9,
4483
4601
  index as index17,
4484
4602
  integer as integer16,
@@ -4527,7 +4645,7 @@ var transcriptionRecordings = pgTable17(
4527
4645
  transcriptTextCodecVersion: losslessCodecVersion("transcript_text_codec_version"),
4528
4646
  languages: jsonb13("languages").$type().notNull().default([]),
4529
4647
  errorCode: text17("error_code"),
4530
- retryable: boolean8("retryable").notNull().default(false),
4648
+ retryable: boolean9("retryable").notNull().default(false),
4531
4649
  providerId: text17("provider_id"),
4532
4650
  processingGeneration: integer16("processing_generation").notNull().default(0),
4533
4651
  processingOwner: uuid17("processing_owner"),
@@ -4676,7 +4794,7 @@ var transcriptionRecordingSegments = pgTable17(
4676
4794
  languages: jsonb13("languages").$type().notNull().default([]),
4677
4795
  providerId: text17("provider_id"),
4678
4796
  errorCode: text17("error_code"),
4679
- retryable: boolean8("retryable").notNull().default(false),
4797
+ retryable: boolean9("retryable").notNull().default(false),
4680
4798
  createdAt: timestamp17("created_at", { withTimezone: true }).notNull().defaultNow(),
4681
4799
  updatedAt: timestamp17("updated_at", { withTimezone: true }).notNull().defaultNow()
4682
4800
  },
@@ -4716,7 +4834,7 @@ var transcriptionRecordingSegments = pgTable17(
4716
4834
  import { sql as sql15 } from "drizzle-orm";
4717
4835
  import {
4718
4836
  bigint as bigint13,
4719
- boolean as boolean9,
4837
+ boolean as boolean10,
4720
4838
  check as check10,
4721
4839
  index as index18,
4722
4840
  integer as integer17,
@@ -4831,8 +4949,8 @@ var browserRevisions = pgTable18(
4831
4949
  expectedHeadGeneration: bigint13("expected_head_generation", {
4832
4950
  mode: "number"
4833
4951
  }).notNull(),
4834
- advanceDefaultRequested: boolean9("advance_default_requested").notNull(),
4835
- defaultAdvanced: boolean9("default_advanced").notNull(),
4952
+ advanceDefaultRequested: boolean10("advance_default_requested").notNull(),
4953
+ defaultAdvanced: boolean10("default_advanced").notNull(),
4836
4954
  resultHeadGeneration: bigint13("result_head_generation", {
4837
4955
  mode: "number"
4838
4956
  }).notNull(),
@@ -5247,7 +5365,7 @@ var browserSessions = pgTable18(
5247
5365
  enum: ["chromium", "chrome", "firefox", "webkit", "lightpanda", "external"]
5248
5366
  }).notNull(),
5249
5367
  engineVersion: text18("engine_version"),
5250
- headless: boolean9("headless").notNull(),
5368
+ headless: boolean10("headless").notNull(),
5251
5369
  identityId: uuid18("identity_id"),
5252
5370
  baseRevisionId: uuid18("base_revision_id"),
5253
5371
  linkedComputerSessionId: uuid18("linked_computer_session_id"),
@@ -6161,7 +6279,7 @@ var interactionOperations = pgTable18(
6161
6279
  controllerGeneration: text18("controller_generation"),
6162
6280
  errorCode: text18("error_code"),
6163
6281
  errorMessage: text18("error_message"),
6164
- errorRetryable: boolean9("error_retryable"),
6282
+ errorRetryable: boolean10("error_retryable"),
6165
6283
  errorDetails: jsonb14("error_details").$type(),
6166
6284
  actorSubjectId: text18("actor_subject_id").notNull(),
6167
6285
  createdAt: timestamp18("created_at", { withTimezone: true }).notNull().defaultNow(),
@@ -6460,7 +6578,7 @@ var workspaceArtifactEvents = pgTable19(
6460
6578
  var nestedAgentDepthConfiguration = pgTable19(
6461
6579
  "nested_agent_depth_configuration",
6462
6580
  {
6463
- singleton: boolean10("singleton").primaryKey().notNull().default(true),
6581
+ singleton: boolean11("singleton").primaryKey().notNull().default(true),
6464
6582
  maxNestedAgentDepth: integer18("max_nested_agent_depth").notNull(),
6465
6583
  policySource: text19("policy_source").$type().notNull(),
6466
6584
  updatedAt: timestamp19("updated_at", { withTimezone: true }).notNull().defaultNow()
@@ -6677,7 +6795,7 @@ var organizationPrivateSessionSettings = pgTable19(
6677
6795
  "organization_private_session_settings",
6678
6796
  {
6679
6797
  accountId: uuid19("account_id").primaryKey().references(() => managedAccounts.id, { onDelete: "cascade" }),
6680
- enabled: boolean10("enabled").notNull().default(false),
6798
+ enabled: boolean11("enabled").notNull().default(false),
6681
6799
  version: bigint14("version", { mode: "number" }).notNull().default(1),
6682
6800
  updatedByMembershipId: uuid19("updated_by_membership_id"),
6683
6801
  updatedAt: timestamp19("updated_at", { withTimezone: true }).notNull().defaultNow()
@@ -6700,12 +6818,12 @@ var organizationPrivateSessionSettingEvents = pgTable19(
6700
6818
  id: uuid19("id").primaryKey(),
6701
6819
  accountId: uuid19("account_id").notNull().references(() => managedAccounts.id, { onDelete: "cascade" }),
6702
6820
  actorMembershipId: uuid19("actor_membership_id").notNull(),
6703
- requestedEnabled: boolean10("requested_enabled").notNull(),
6821
+ requestedEnabled: boolean11("requested_enabled").notNull(),
6704
6822
  expectedVersion: bigint14("expected_version", { mode: "number" }).notNull(),
6705
- resultEnabled: boolean10("result_enabled").notNull(),
6823
+ resultEnabled: boolean11("result_enabled").notNull(),
6706
6824
  resultVersion: bigint14("result_version", { mode: "number" }).notNull(),
6707
6825
  resultUpdatedAt: timestamp19("result_updated_at", { withTimezone: true }).notNull(),
6708
- changed: boolean10("changed").notNull(),
6826
+ changed: boolean11("changed").notNull(),
6709
6827
  createdAt: timestamp19("created_at", { withTimezone: true }).notNull().defaultNow()
6710
6828
  },
6711
6829
  (table) => ({
@@ -7159,6 +7277,7 @@ var apiKeys = pgTable19(
7159
7277
  }),
7160
7278
  name: text19("name").notNull(),
7161
7279
  description: text19("description"),
7280
+ credentialKind: text19("credential_kind").$type().notNull(),
7162
7281
  prefix: text19("prefix").notNull(),
7163
7282
  keyHash: text19("key_hash").notNull(),
7164
7283
  permissions: jsonb15("permissions").$type().notNull().default([]),
@@ -7176,6 +7295,20 @@ var apiKeys = pgTable19(
7176
7295
  descriptionValid: check11(
7177
7296
  "api_keys_description_check",
7178
7297
  sql16`${table.description} is null or length(${table.description}) between 1 and 500`
7298
+ ),
7299
+ credentialKindValid: check11(
7300
+ "api_keys_credential_kind_check",
7301
+ sql16`(
7302
+ ${table.workspaceId} is not null
7303
+ and ${table.credentialKind} = 'workspace'
7304
+ ) or (
7305
+ ${table.workspaceId} is null
7306
+ and ${table.credentialKind} = 'organization'
7307
+ ) or (
7308
+ ${table.workspaceId} is null
7309
+ and ${table.credentialKind} = 'legacy_account'
7310
+ and ${table.revokedAt} is not null
7311
+ )`
7179
7312
  )
7180
7313
  })
7181
7314
  );
@@ -7279,7 +7412,18 @@ var codexSubscriptionCredentials = pgTable19(
7279
7412
  {
7280
7413
  id: uuid19("id").primaryKey().defaultRandom(),
7281
7414
  accountId: uuid19("account_id").notNull().references(() => managedAccounts.id, { onDelete: "cascade" }),
7282
- workspaceId: uuid19("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
7415
+ workspaceId: uuid19("workspace_id").references(() => workspaces.id, { onDelete: "cascade" }),
7416
+ organizationId: uuid19("organization_id").references(() => managedAccounts.id, {
7417
+ onDelete: "cascade"
7418
+ }),
7419
+ authorityScope: text19("authority_scope").notNull().default("workspace"),
7420
+ ownerOrganizationMembershipId: uuid19("owner_organization_membership_id"),
7421
+ organizationUserResourceAuthorityId: uuid19("organization_user_resource_authority_id"),
7422
+ organizationUserResourceKind: text19("organization_user_resource_kind"),
7423
+ organizationUserResourceAuthorityGeneration: bigint14(
7424
+ "organization_user_resource_authority_generation",
7425
+ { mode: "number" }
7426
+ ),
7283
7427
  // Format: v1:<base64 iv>:<base64 ciphertext||gcm-tag>. JSON {access_token, refresh_token, id_token}. Never returned by any API.
7284
7428
  credentialEncrypted: text19("credential_encrypted").notNull(),
7285
7429
  chatgptAccountId: text19("chatgpt_account_id"),
@@ -7287,7 +7431,7 @@ var codexSubscriptionCredentials = pgTable19(
7287
7431
  scopes: text19("scopes"),
7288
7432
  // space-delimited, as granted
7289
7433
  planType: text19("plan_type"),
7290
- isFedramp: boolean10("is_fedramp").notNull().default(false),
7434
+ isFedramp: boolean11("is_fedramp").notNull().default(false),
7291
7435
  expiresAt: timestamp19("expires_at", { withTimezone: true }),
7292
7436
  // derived from access-token JWT exp
7293
7437
  lastRefreshAt: timestamp19("last_refresh_at", { withTimezone: true }),
@@ -7308,17 +7452,21 @@ var codexSubscriptionCredentials = pgTable19(
7308
7452
  secondaryResetAt: timestamp19("secondary_reset_at", { withTimezone: true }),
7309
7453
  usageCheckedAt: timestamp19("usage_checked_at", { withTimezone: true }),
7310
7454
  // snapshot freshness → cache TTL clock
7311
- // P3 rotation cooldown (plaintext metadata; NEVER a token). Set when this account hit its
7312
- // usage cap on a rotation turn; the rotation engine treats `exhausted_until > now()` as
7313
- // capped/skip so it isn't immediately re-picked. Self-clears via the now() comparison.
7455
+ // P3 rotation cooldown (plaintext metadata; NEVER a token). The kind keeps
7456
+ // quota refusals distinct from generic provider backpressure. The independent
7457
+ // revision fences a live usage response against a concurrently newer refusal;
7458
+ // neither field participates in token-refresh OCC.
7314
7459
  exhaustedUntil: timestamp19("exhausted_until", { withTimezone: true }),
7460
+ exhaustedKind: text19("exhausted_kind"),
7461
+ // quota | rate_limit | null (legacy/cleared)
7462
+ exhaustedRevision: bigint14("exhausted_revision", { mode: "number" }).notNull().default(0),
7315
7463
  // Workspace-local, server-held fairness cursor. Provider usage headers are
7316
7464
  // capacity hints, never the sole allocator: live lease count is ranked first
7317
7465
  // and this cursor deterministically breaks equal-load/equal-capacity ties.
7318
7466
  // This flag controls NEW automatic allocations only. Credential health,
7319
7467
  // refresh, encrypted material, and an already-leased in-flight turn are
7320
7468
  // intentionally independent. account eligibility policy owns toggle OCC/audit and product UI.
7321
- allocatorEnabled: boolean10("allocator_enabled").notNull().default(true),
7469
+ allocatorEnabled: boolean11("allocator_enabled").notNull().default(true),
7322
7470
  // Independent OCC/audit sequence for the allocator toggle. Token refresh
7323
7471
  // continues to own `version`; quota/cache writes own neither counter.
7324
7472
  allocatorVersion: integer18("allocator_version").notNull().default(1),
@@ -7356,7 +7504,58 @@ var codexSubscriptionCredentials = pgTable19(
7356
7504
  ),
7357
7505
  workspaceAccountIdentity: uniqueIndex19(
7358
7506
  "codex_subscription_credentials_workspace_account_id_idx"
7359
- ).on(table.workspaceId, table.accountId, table.id)
7507
+ ).on(table.workspaceId, table.accountId, table.id),
7508
+ accountIdentity: uniqueIndex19("codex_subscription_credentials_account_id_idx").on(
7509
+ table.accountId,
7510
+ table.id
7511
+ ),
7512
+ organizationAccount: uniqueIndex19("codex_subscription_credentials_organization_account_idx").on(table.organizationId, table.chatgptAccountId).where(
7513
+ sql16`${table.authorityScope} = 'organization' and ${table.chatgptAccountId} is not null`
7514
+ ),
7515
+ organizationLookup: index19("codex_subscription_credentials_organization_lookup_idx").on(table.organizationId, table.createdAt, table.id).where(sql16`${table.authorityScope} = 'organization'`)
7516
+ })
7517
+ );
7518
+ var workspaceCodexSubscriptionPreferences = pgTable19(
7519
+ "workspace_codex_subscription_preferences",
7520
+ {
7521
+ workspaceId: uuid19("workspace_id").primaryKey().references(() => workspaces.id, { onDelete: "cascade" }),
7522
+ accountId: uuid19("account_id").notNull().references(() => managedAccounts.id, { onDelete: "cascade" }),
7523
+ mode: text19("mode").notNull().default("automatic"),
7524
+ updatedBySubjectId: text19("updated_by_subject_id"),
7525
+ createdAt: timestamp19("created_at", { withTimezone: true }).notNull().defaultNow(),
7526
+ updatedAt: timestamp19("updated_at", { withTimezone: true }).notNull().defaultNow()
7527
+ },
7528
+ (table) => ({
7529
+ workspaceAccount: foreignKey({
7530
+ name: "workspace_codex_subscription_preferences_workspace_account_fk",
7531
+ columns: [table.workspaceId, table.accountId],
7532
+ foreignColumns: [workspaces.id, workspaces.accountId]
7533
+ }).onDelete("cascade"),
7534
+ modeValid: check11(
7535
+ "workspace_codex_subscription_preferences_mode_chk",
7536
+ sql16`${table.mode} in ('automatic', 'workspace', 'organization', 'disabled')`
7537
+ )
7538
+ })
7539
+ );
7540
+ var organizationCodexRotationSettings = pgTable19(
7541
+ "organization_codex_rotation_settings",
7542
+ {
7543
+ id: uuid19("id").primaryKey().defaultRandom(),
7544
+ accountId: uuid19("account_id").notNull().references(() => managedAccounts.id, { onDelete: "cascade" }),
7545
+ activeCredentialId: uuid19("active_credential_id"),
7546
+ rotationEnabled: boolean11("rotation_enabled").notNull().default(false),
7547
+ leaseRotationEnabled: boolean11("lease_rotation_enabled").notNull().default(false),
7548
+ rotationStrategy: text19("rotation_strategy").notNull().default("sharded"),
7549
+ createdAt: timestamp19("created_at", { withTimezone: true }).notNull().defaultNow(),
7550
+ updatedAt: timestamp19("updated_at", { withTimezone: true }).notNull().defaultNow()
7551
+ },
7552
+ (table) => ({
7553
+ account: uniqueIndex19("organization_codex_rotation_settings_account_idx").on(table.accountId),
7554
+ activeCredential: foreignKey({
7555
+ name: "organization_codex_rotation_settings_active_fk",
7556
+ columns: [table.activeCredentialId],
7557
+ foreignColumns: [codexSubscriptionCredentials.id]
7558
+ }).onDelete("set null")
7360
7559
  })
7361
7560
  );
7362
7561
  var codexAppsSettings = pgTable19(
@@ -7619,9 +7818,9 @@ var personalGitHubRepositorySelections = pgTable19(
7619
7818
  canonicalHttpsUri: text19("canonical_https_uri").notNull(),
7620
7819
  defaultBranch: text19("default_branch").notNull(),
7621
7820
  visibility: text19("visibility").notNull(),
7622
- private: boolean10("private").notNull(),
7623
- archived: boolean10("archived").notNull(),
7624
- disabled: boolean10("disabled").notNull(),
7821
+ private: boolean11("private").notNull(),
7822
+ archived: boolean11("archived").notNull(),
7823
+ disabled: boolean11("disabled").notNull(),
7625
7824
  permissions: jsonb15("permissions").$type().notNull(),
7626
7825
  selectedAccess: text19("selected_access").notNull(),
7627
7826
  selectionGeneration: bigint14("selection_generation", {
@@ -7915,7 +8114,7 @@ var slackRoutePrompts = pgTable19(
7915
8114
  providerEventId: text19("provider_event_id").notNull(),
7916
8115
  triggerKind: text19("trigger_kind").$type().notNull(),
7917
8116
  requestText: text19("request_text").notNull(),
7918
- hasFiles: boolean10("has_files").notNull().default(false),
8117
+ hasFiles: boolean11("has_files").notNull().default(false),
7919
8118
  slackThreadTs: text19("slack_thread_ts"),
7920
8119
  messageOperationId: uuid19("message_operation_id").notNull(),
7921
8120
  status: text19("status").$type().notNull().default("pending"),
@@ -8312,7 +8511,7 @@ var slackInteractionInbox = pgTable19(
8312
8511
  slackThreadTs: text19("slack_thread_ts"),
8313
8512
  triggerKind: text19("trigger_kind").$type().notNull(),
8314
8513
  text: text19("text").notNull(),
8315
- hasFiles: boolean10("has_files").notNull().default(false),
8514
+ hasFiles: boolean11("has_files").notNull().default(false),
8316
8515
  status: text19("status").$type().notNull().default("pending"),
8317
8516
  claimHolderId: uuid19("claim_holder_id"),
8318
8517
  claimExpiresAt: timestamp19("claim_expires_at", { withTimezone: true }),
@@ -8441,7 +8640,7 @@ var slackInteractions = pgTable19(
8441
8640
  ackSlackMessageTs: text19("ack_slack_message_ts"),
8442
8641
  // Frozen once: whether this interaction's acknowledgement renders the
8443
8642
  // one-time onboarding hint. NULL means the decision has not been resolved.
8444
- firstTaskHint: boolean10("first_task_hint"),
8643
+ firstTaskHint: boolean11("first_task_hint"),
8445
8644
  // The routed workspace's display name, frozen when the interaction binds.
8446
8645
  // A live lookup at post time would be wrong: a workspace rename between the
8447
8646
  // original post and a reconciliation makes `reconcilePostMessage`'s
@@ -8679,7 +8878,7 @@ var memorySlackPublicationConfigurations = pgTable19(
8679
8878
  accountId: uuid19("account_id").notNull().references(() => managedAccounts.id, { onDelete: "cascade" }),
8680
8879
  workspaceId: uuid19("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
8681
8880
  revision: integer18("revision").notNull(),
8682
- enabled: boolean10("enabled").notNull(),
8881
+ enabled: boolean11("enabled").notNull(),
8683
8882
  connectionId: uuid19("connection_id"),
8684
8883
  slackTeamId: text19("slack_team_id"),
8685
8884
  slackChannelId: text19("slack_channel_id"),
@@ -9033,11 +9232,11 @@ var codexRotationSettings = pgTable19(
9033
9232
  // Legacy selector bit. Keep false as the DB default forever: an old worker
9034
9233
  // only understands this column, so a schema-first rollout or binary
9035
9234
  // rollback must never make it enter the non-atomic rotation path.
9036
- rotationEnabled: boolean10("rotation_enabled").notNull().default(false),
9235
+ rotationEnabled: boolean11("rotation_enabled").notNull().default(false),
9037
9236
  // Revision-aware allocator cutover. Only migration-compatible API/worker
9038
9237
  // code reads this bit; old binaries safely ignore it and keep the legacy
9039
9238
  // pin/rotation policy.
9040
- leaseRotationEnabled: boolean10("lease_rotation_enabled").notNull().default(false),
9239
+ leaseRotationEnabled: boolean11("lease_rotation_enabled").notNull().default(false),
9041
9240
  rotationStrategy: text19("rotation_strategy").notNull().default("sharded"),
9042
9241
  // sharded-rotation policy: legacy residue; behavior is always sharded
9043
9242
  createdAt: timestamp19("created_at", { withTimezone: true }).notNull().defaultNow(),
@@ -9108,7 +9307,7 @@ var xaiSubscriptionCredentials = pgTable19(
9108
9307
  lastRefreshAt: timestamp19("last_refresh_at", { withTimezone: true }),
9109
9308
  lastError: text19("last_error"),
9110
9309
  version: integer18("version").notNull().default(1),
9111
- allocatorEnabled: boolean10("allocator_enabled").notNull().default(true),
9310
+ allocatorEnabled: boolean11("allocator_enabled").notNull().default(true),
9112
9311
  allocatorVersion: integer18("allocator_version").notNull().default(1),
9113
9312
  allocatorUpdatedAt: timestamp19("allocator_updated_at", {
9114
9313
  withTimezone: true
@@ -9195,7 +9394,7 @@ var xaiRotationSettings = pgTable19(
9195
9394
  authorityScope: text19("authority_scope").notNull().default("workspace"),
9196
9395
  ownerOrganizationMembershipId: uuid19("owner_organization_membership_id"),
9197
9396
  activeCredentialId: uuid19("active_credential_id"),
9198
- rotationEnabled: boolean10("rotation_enabled").notNull().default(true),
9397
+ rotationEnabled: boolean11("rotation_enabled").notNull().default(true),
9199
9398
  fairnessCursor: bigint14("fairness_cursor", { mode: "number" }).notNull().default(0),
9200
9399
  version: integer18("version").notNull().default(1),
9201
9400
  createdAt: timestamp19("created_at", { withTimezone: true }).notNull().defaultNow(),
@@ -9261,7 +9460,7 @@ var channels = pgTable19(
9261
9460
  workspaceId: uuid19("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
9262
9461
  name: text19("name").notNull(),
9263
9462
  description: text19("description"),
9264
- pinned: boolean10("pinned").notNull().default(false),
9463
+ pinned: boolean11("pinned").notNull().default(false),
9265
9464
  // Explicit user order within the pinned and unpinned project groups.
9266
9465
  sortOrder: integer18("sort_order").notNull().default(0),
9267
9466
  // Attribution string: 'user:<subject>' | 'session:<id>' | 'system'.
@@ -9448,7 +9647,7 @@ var sessions = pgTable19(
9448
9647
  // it true; the worker honors it BEFORE the next turn's model call by forcing
9449
9648
  // a compaction, then clears it. A durable flag (not a transient signal) so
9450
9649
  // the trigger survives a worker restart and converges before the next turn.
9451
- compactRequested: boolean10("compact_requested").notNull().default(false),
9650
+ compactRequested: boolean11("compact_requested").notNull().default(false),
9452
9651
  queueVersion: integer18("queue_version").notNull().default(0),
9453
9652
  queueHeadPosition: bigint14("queue_head_position", { mode: "number" }).notNull().default(0),
9454
9653
  queueTailPosition: bigint14("queue_tail_position", { mode: "number" }).notNull().default(0),
@@ -10120,16 +10319,16 @@ var sessionPins = pgTable19(
10120
10319
  // deleting it. That preserves a monotonic version and prevents an ABA race:
10121
10320
  // a stale client that saw pin version 1 cannot silently overwrite a later
10122
10321
  // unpin+re-pin that would otherwise recreate version 1.
10123
- pinned: boolean10("pinned").notNull().default(true),
10322
+ pinned: boolean11("pinned").notNull().default(true),
10124
10323
  pinnedAt: timestamp19("pinned_at", { withTimezone: true }).defaultNow(),
10125
10324
  version: integer18("version").notNull().default(1),
10126
10325
  // A session is unread for this subject whenever its durable event sequence
10127
10326
  // has advanced beyond this explicit acknowledgment fence. Merely opening a
10128
10327
  // route never changes the fence.
10129
10328
  acknowledgedSequence: integer18("acknowledged_sequence").notNull().default(0),
10130
- activelyWorking: boolean10("actively_working").notNull().default(false),
10329
+ activelyWorking: boolean11("actively_working").notNull().default(false),
10131
10330
  attentionVersion: integer18("attention_version").notNull().default(0),
10132
- archived: boolean10("archived").notNull().default(false),
10331
+ archived: boolean11("archived").notNull().default(false),
10133
10332
  archivedAt: timestamp19("archived_at", { withTimezone: true }),
10134
10333
  archiveVersion: integer18("archive_version").notNull().default(0)
10135
10334
  },
@@ -10246,7 +10445,7 @@ var sessionMcpServers = pgTable19(
10246
10445
  url: text19("url").notNull(),
10247
10446
  allowedTools: jsonb15("allowed_tools").$type(),
10248
10447
  timeoutMs: integer18("timeout_ms"),
10249
- cacheToolsList: boolean10("cache_tools_list").notNull().default(false),
10448
+ cacheToolsList: boolean11("cache_tools_list").notNull().default(false),
10250
10449
  // Human-approval policy: `true` = every tool requires approval, a string[] of
10251
10450
  // UNPREFIXED tool names = only those require it, null/absent = auto-run.
10252
10451
  requireApproval: jsonb15("require_approval").$type(),
@@ -10757,7 +10956,7 @@ var generatedVideoArtifacts = pgTable19(
10757
10956
  fpsMilli: integer18("fps_milli").notNull(),
10758
10957
  videoCodec: text19("video_codec").notNull(),
10759
10958
  audioCodec: text19("audio_codec"),
10760
- hasAudio: boolean10("has_audio").notNull(),
10959
+ hasAudio: boolean11("has_audio").notNull(),
10761
10960
  sandboxFilename: text19("sandbox_filename").notNull(),
10762
10961
  deletedAt: timestamp19("deleted_at", { withTimezone: true }),
10763
10962
  readyAt: timestamp19("ready_at", { withTimezone: true }).notNull().defaultNow(),
@@ -10983,7 +11182,7 @@ var documents = pgTable19(
10983
11182
  // document from agent retrieval surfaces (docs MCP) while humans keep REST.
10984
11183
  visibility: text19("visibility").notNull().default("workspace"),
10985
11184
  createdBy: text19("created_by"),
10986
- agentAccess: boolean10("agent_access").notNull().default(true),
11185
+ agentAccess: boolean11("agent_access").notNull().default(true),
10987
11186
  // Auto-curation output (knowledge drops).
10988
11187
  summary: text19("summary"),
10989
11188
  topics: jsonb15("topics").$type().notNull().default([]),
@@ -11160,7 +11359,7 @@ var knowledgeMemories = pgTable19(
11160
11359
  // (embedder unavailable) persist keyword-searchable rows without a vector.
11161
11360
  embedding: vector("embedding"),
11162
11361
  embeddingModel: text19("embedding_model"),
11163
- pinned: boolean10("pinned").notNull().default(false),
11362
+ pinned: boolean11("pinned").notNull().default(false),
11164
11363
  usageCount: integer18("usage_count").notNull().default(0),
11165
11364
  lastUsedAt: timestamp19("last_used_at", { withTimezone: true }),
11166
11365
  // Self-referential supersession chain. FKs live in migration 0045 (ON DELETE SET
@@ -11261,7 +11460,7 @@ var sessionTurns = pgTable19(
11261
11460
  tools: jsonb15("tools").$type().notNull().default([]),
11262
11461
  // false = inherit the durable session policy; true = this turn explicitly
11263
11462
  // replaces it with `tools` after the core subset fence.
11264
- toolsProvided: boolean10("tools_provided").notNull().default(false),
11463
+ toolsProvided: boolean11("tools_provided").notNull().default(false),
11265
11464
  model: text19("model").notNull(),
11266
11465
  reasoningEffort: text19("reasoning_effort").notNull(),
11267
11466
  // Peer of model + reasoning_effort for Fast/priority inheritance.
@@ -11362,7 +11561,7 @@ var turnPersonalResourceAttachmentReceipts = pgTable19(
11362
11561
  sessionAuthorityEpoch: integer18("session_authority_epoch").notNull(),
11363
11562
  grantMode: text19("grant_mode").notNull(),
11364
11563
  sharedOutputWarningVersion: integer18("shared_output_warning_version").notNull(),
11365
- sharedOutputAcknowledged: boolean10("shared_output_acknowledged").notNull(),
11564
+ sharedOutputAcknowledged: boolean11("shared_output_acknowledged").notNull(),
11366
11565
  requestDigest: bytea2("request_digest").notNull(),
11367
11566
  resourceCount: integer18("resource_count").notNull(),
11368
11567
  createdAt: timestamp19("created_at", { withTimezone: true }).notNull().defaultNow()
@@ -12232,6 +12431,13 @@ var sessionCommandReceipts = pgTable19(
12232
12431
  table.targetSessionId,
12233
12432
  table.createdAt
12234
12433
  ),
12434
+ promptActorOperation: index19("session_command_receipts_prompt_actor_operation_idx").on(
12435
+ table.workspaceId,
12436
+ table.actorType,
12437
+ table.actorSubjectId,
12438
+ table.actorAttemptId,
12439
+ table.operationKey
12440
+ ).where(sql16`${table.action} in ('prompt.send', 'prompt.steer')`),
12235
12441
  goalUpdateOperation: uniqueIndex19("session_command_receipts_goal_update_operation_uq").on(table.workspaceId, table.action, table.targetSessionId, table.operationKey).where(sql16`${table.action} = 'goal.update'`),
12236
12442
  actorValid: check11(
12237
12443
  "session_command_receipts_actor_check",
@@ -12257,7 +12463,7 @@ var workspaceControlEvents = pgTable19(
12257
12463
  scope: text19("scope").notNull(),
12258
12464
  rootSessionId: uuid19("root_session_id"),
12259
12465
  action: text19("action").notNull(),
12260
- automatic: boolean10("automatic").notNull().default(false),
12466
+ automatic: boolean11("automatic").notNull().default(false),
12261
12467
  reason: text19("reason"),
12262
12468
  reasonOriginalBytes: integer18("reason_original_bytes"),
12263
12469
  actor: text19("actor").notNull(),
@@ -12359,7 +12565,7 @@ var composerDrafts = pgTable19(
12359
12565
  annotations: jsonb15("annotations").$type().notNull().default([]),
12360
12566
  resources: jsonb15("resources").$type().notNull().default([]),
12361
12567
  tools: jsonb15("tools").$type().notNull().default([]),
12362
- toolsProvided: boolean10("tools_provided").notNull().default(false),
12568
+ toolsProvided: boolean11("tools_provided").notNull().default(false),
12363
12569
  model: text19("model").notNull(),
12364
12570
  reasoningEffort: text19("reasoning_effort").notNull(),
12365
12571
  latencyMode: text19("latency_mode").notNull().default("standard"),
@@ -12929,6 +13135,36 @@ var xaiCapacityWaiters = pgTable19(
12929
13135
  )
12930
13136
  })
12931
13137
  );
13138
+ var sessionEventCursors = pgTable19(
13139
+ "session_event_cursors",
13140
+ {
13141
+ sessionId: uuid19("session_id").primaryKey().references(() => sessions.id, { onDelete: "cascade" }),
13142
+ accountId: uuid19("account_id").notNull().references(() => managedAccounts.id, { onDelete: "cascade" }),
13143
+ workspaceId: uuid19("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
13144
+ lastSequence: integer18("last_sequence").notNull().default(0),
13145
+ revision: bigint14("revision", { mode: "number" }).notNull().default(0),
13146
+ createdAt: timestamp19("created_at", { withTimezone: true }).notNull().defaultNow(),
13147
+ updatedAt: timestamp19("updated_at", { withTimezone: true }).notNull().defaultNow()
13148
+ },
13149
+ (table) => ({
13150
+ workspaceAccount: foreignKey({
13151
+ name: "session_event_cursors_workspace_account_fk",
13152
+ columns: [table.workspaceId, table.accountId],
13153
+ foreignColumns: [workspaces.id, workspaces.accountId]
13154
+ }).onDelete("cascade"),
13155
+ workspaceSession: foreignKey({
13156
+ name: "session_event_cursors_workspace_session_fk",
13157
+ columns: [table.workspaceId, table.sessionId],
13158
+ foreignColumns: [sessions.workspaceId, sessions.id]
13159
+ }).onDelete("cascade"),
13160
+ workspaceIdentity: uniqueIndex19("session_event_cursors_workspace_session_idx").on(
13161
+ table.workspaceId,
13162
+ table.sessionId
13163
+ ),
13164
+ sequenceValid: check11("session_event_cursors_sequence_check", sql16`${table.lastSequence} >= 0`),
13165
+ revisionValid: check11("session_event_cursors_revision_check", sql16`${table.revision} >= 0`)
13166
+ })
13167
+ );
12932
13168
  var sessionEvents = pgTable19(
12933
13169
  "session_events",
12934
13170
  {
@@ -13074,7 +13310,7 @@ var sessionHumanInputRequests = pgTable19(
13074
13310
  toolCallId: text19("tool_call_id").notNull(),
13075
13311
  status: text19("status").notNull().default("pending"),
13076
13312
  questions: jsonb15("questions").$type().notNull(),
13077
- allowSkip: boolean10("allow_skip").notNull().default(false),
13313
+ allowSkip: boolean11("allow_skip").notNull().default(false),
13078
13314
  response: jsonb15("response").$type(),
13079
13315
  respondedBy: text19("responded_by"),
13080
13316
  respondedAt: timestamp19("responded_at", { withTimezone: true }),
@@ -13158,7 +13394,7 @@ var sessionHistoryItems = pgTable19(
13158
13394
  // false — never deletes, so the full transcript stays as an audit trail) and
13159
13395
  // inserts ONE synthetic active summary row at the boundary. Defaults true so
13160
13396
  // every existing and normally-appended row is live.
13161
- active: boolean10("active").notNull().default(true),
13397
+ active: boolean11("active").notNull().default(true),
13162
13398
  // An exact provider 400 can prove that the request's active opaque artifact
13163
13399
  // set is no longer usable. Keep each canonical item immutable, but record the
13164
13400
  // attempt-fenced rejection on the exact candidate row IDs so later model
@@ -13432,12 +13668,12 @@ var sandboxLeases = pgTable19(
13432
13668
  // archiveCaptureProviderRequestId resumes the same physical capture. This is
13433
13669
  // deliberately explicit rather than inferred from backend/id equality so a
13434
13670
  // rolling old worker can never be mistaken for an idempotent caller.
13435
- archiveCaptureProviderReplaySafe: boolean10("archive_capture_provider_replay_safe").notNull().default(false),
13671
+ archiveCaptureProviderReplaySafe: boolean11("archive_capture_provider_replay_safe").notNull().default(false),
13436
13672
  // Provider-neutral takeover proof. True means the registered adapter has
13437
13673
  // proven either same-request idempotency or an independently repeatable,
13438
13674
  // read-only capture. It is distinct from providerReplaySafe so portable tar
13439
13675
  // can recover immediately without pretending it resumes one provider RPC.
13440
- archiveCaptureTakeoverSafe: boolean10("archive_capture_takeover_safe").notNull().default(false),
13676
+ archiveCaptureTakeoverSafe: boolean11("archive_capture_takeover_safe").notNull().default(false),
13441
13677
  archiveCaptureAttempt: integer18("archive_capture_attempt"),
13442
13678
  archiveCaptureGeneration: integer18("archive_capture_generation"),
13443
13679
  archiveCaptureStartedAt: timestamp19("archive_capture_started_at", {
@@ -13483,6 +13719,28 @@ var sandboxLeases = pgTable19(
13483
13719
  // these remain bare UUIDs here rather than generating a stricter wrong FK.
13484
13720
  currentCheckpointArtifactId: uuid19("current_checkpoint_artifact_id"),
13485
13721
  previousCheckpointArtifactId: uuid19("previous_checkpoint_artifact_id"),
13722
+ // Durable single-flight for immutable machine setup (currently exact rig
13723
+ // setup only). Per-turn credentials, repositories, files, and cloud login
13724
+ // deliberately remain outside this lease-scoped receipt.
13725
+ sharedPreparationLeaseEpoch: integer18("shared_preparation_lease_epoch"),
13726
+ sharedPreparationInstanceId: text19("shared_preparation_instance_id"),
13727
+ sharedPreparationSpecHash: text19("shared_preparation_spec_hash"),
13728
+ sharedPreparationStatus: text19("shared_preparation_status", {
13729
+ enum: ["running", "completed", "failed"]
13730
+ }),
13731
+ sharedPreparationClaimId: uuid19("shared_preparation_claim_id"),
13732
+ sharedPreparationOwnerAttemptId: uuid19("shared_preparation_owner_attempt_id"),
13733
+ sharedPreparationAttempt: integer18("shared_preparation_attempt"),
13734
+ sharedPreparationRevision: integer18("shared_preparation_revision").notNull().default(0),
13735
+ sharedPreparationStartedAt: timestamp19("shared_preparation_started_at", {
13736
+ withTimezone: true
13737
+ }),
13738
+ sharedPreparationDeadlineAt: timestamp19("shared_preparation_deadline_at", {
13739
+ withTimezone: true
13740
+ }),
13741
+ sharedPreparationSettledAt: timestamp19("shared_preparation_settled_at", {
13742
+ withTimezone: true
13743
+ }),
13486
13744
  expiresAt: timestamp19("expires_at", { withTimezone: true }).notNull(),
13487
13745
  createdAt: timestamp19("created_at", { withTimezone: true }).notNull().defaultNow(),
13488
13746
  updatedAt: timestamp19("updated_at", { withTimezone: true }).notNull().defaultNow()
@@ -14451,10 +14709,10 @@ var enrollments = pgTable19(
14451
14709
  // The agent's ed25519 public key (the machine identity).
14452
14710
  pubkey: text19("pubkey").notNull(),
14453
14711
  exposure: text19("exposure", { enum: enrollmentExposureValues }).notNull().default("whole-machine"),
14454
- hasDisplay: boolean10("has_display").notNull().default(false),
14712
+ hasDisplay: boolean11("has_display").notNull().default(false),
14455
14713
  // Refreshed from every connect Hello (Capabilities.op_stream); false for
14456
14714
  // agents predating the op-stream engine.
14457
- opStream: boolean10("op_stream").notNull().default(false),
14715
+ opStream: boolean11("op_stream").notNull().default(false),
14458
14716
  // When the machine has a display it CANNOT capture (macOS Screen Recording / TCC
14459
14717
  // not granted), the agent reports has_display=false AND a human, actionable reason
14460
14718
  // here (e.g. "grant Screen Recording in System Settings"). NULL means capture is
@@ -14463,7 +14721,7 @@ var enrollments = pgTable19(
14463
14721
  // so the Machines dashboard / VM picker can surface the specific hint. Refreshed
14464
14722
  // from every connect Hello alongside has_display.
14465
14723
  desktopUnavailableReason: text19("desktop_unavailable_reason"),
14466
- allowScreenControl: boolean10("allow_screen_control").notNull().default(false),
14724
+ allowScreenControl: boolean11("allow_screen_control").notNull().default(false),
14467
14725
  // Optional per-connection command policy. NULL is the unrestricted default.
14468
14726
  // Values remain within JavaScript's exact-integer wire range; local runner and
14469
14727
  // ancestor host policy may only tighten them at execution.
@@ -14532,8 +14790,8 @@ var enrollments = pgTable19(
14532
14790
  agentUpdateTargetVersion: text19("agent_update_target_version"),
14533
14791
  agentUpdateExpectedBinarySha256: text19("agent_update_expected_binary_sha256"),
14534
14792
  agentUpdateErrorCode: text19("agent_update_error_code"),
14535
- agentUpdateRetryable: boolean10("agent_update_retryable").notNull().default(false),
14536
- agentUpdateRolledBack: boolean10("agent_update_rolled_back").notNull().default(false),
14793
+ agentUpdateRetryable: boolean11("agent_update_retryable").notNull().default(false),
14794
+ agentUpdateRolledBack: boolean11("agent_update_rolled_back").notNull().default(false),
14537
14795
  agentUpdateConnectionInstanceId: text19("agent_update_connection_instance_id"),
14538
14796
  agentUpdateConnectionGeneration: integer18("agent_update_connection_generation"),
14539
14797
  agentUpdateRequestedAt: timestamp19("agent_update_requested_at", {
@@ -14736,17 +14994,17 @@ var deviceEnrollmentRequests = pgTable19(
14736
14994
  // The agent CAN offer a display (a real screen / Xvfb is available) — gates
14737
14995
  // whether screen-control consent is even meaningful. has_display on the
14738
14996
  // resulting enrollment is derived from this.
14739
- canOfferDisplay: boolean10("can_offer_display").notNull().default(false),
14997
+ canOfferDisplay: boolean11("can_offer_display").notNull().default(false),
14740
14998
  // The agent REQUESTS screen control (computer-use). The user's allow_screen_control
14741
14999
  // at approve is the AUTHORITATIVE consent; this is only the agent's request.
14742
- requestsScreenControl: boolean10("requests_screen_control").notNull().default(false),
15000
+ requestsScreenControl: boolean11("requests_screen_control").notNull().default(false),
14743
15001
  status: text19("status", { enum: deviceEnrollmentStatusValues }).notNull().default("pending"),
14744
15002
  // ── LOUD CONSENT capture (who/when/what), stamped at approve ──────────────
14745
15003
  approvedBySubjectId: text19("approved_by_subject_id"),
14746
15004
  approvedBySubjectLabel: text19("approved_by_subject_label"),
14747
15005
  // The user's screen-control consent decision (whole-machine is mandatory at
14748
15006
  // approve; screen-control is opt-in per this flag).
14749
- allowScreenControl: boolean10("allow_screen_control").notNull().default(false),
15007
+ allowScreenControl: boolean11("allow_screen_control").notNull().default(false),
14750
15008
  approvedAt: timestamp19("approved_at", { withTimezone: true }),
14751
15009
  // The enrollment + sandbox the approve produced (acceptance #2: an enrollment
14752
15010
  // row AND a sandbox row appear). Null until approved.
@@ -15541,8 +15799,8 @@ var hostExportConfig = pgTable19(
15541
15799
  "host_export_config",
15542
15800
  {
15543
15801
  id: integer18("id").primaryKey().default(1),
15544
- sessionEventsEnabled: boolean10("session_events_enabled").notNull().default(false),
15545
- usageEventsEnabled: boolean10("usage_events_enabled").notNull().default(false),
15802
+ sessionEventsEnabled: boolean11("session_events_enabled").notNull().default(false),
15803
+ usageEventsEnabled: boolean11("usage_events_enabled").notNull().default(false),
15546
15804
  updatedAt: timestamp19("updated_at", { withTimezone: true }).notNull().defaultNow()
15547
15805
  },
15548
15806
  (table) => ({
@@ -15634,7 +15892,7 @@ var hostExportConsumers = pgTable19(
15634
15892
  consumerId: text19("consumer_id").notNull(),
15635
15893
  exportKind: text19("export_kind").notNull(),
15636
15894
  checkpoint: bigint14("checkpoint", { mode: "bigint" }).notNull().default(0n),
15637
- enabled: boolean10("enabled").notNull().default(true),
15895
+ enabled: boolean11("enabled").notNull().default(true),
15638
15896
  leaseToken: uuid19("lease_token"),
15639
15897
  leaseHolderId: text19("lease_holder_id"),
15640
15898
  leaseExpiresAt: timestamp19("lease_expires_at", { withTimezone: true }),
@@ -16257,7 +16515,7 @@ var capabilityCatalogItems = pgTable19(
16257
16515
  importBatchId: uuid19("import_batch_id").references(() => importBatches.id, {
16258
16516
  onDelete: "set null"
16259
16517
  }),
16260
- stale: boolean10("stale").notNull().default(false),
16518
+ stale: boolean11("stale").notNull().default(false),
16261
16519
  staleAt: timestamp19("stale_at", { withTimezone: true }),
16262
16520
  metadata: jsonb15("metadata").$type().notNull().default({}),
16263
16521
  createdAt: timestamp19("created_at", { withTimezone: true }).notNull().defaultNow(),
@@ -16381,7 +16639,7 @@ var capabilityFacets = pgTable19(
16381
16639
  facetKey: text19("facet_key").notNull(),
16382
16640
  kind: text19("kind").notNull(),
16383
16641
  activationMode: text19("activation_mode").notNull(),
16384
- required: boolean10("required").notNull().default(true),
16642
+ required: boolean11("required").notNull().default(true),
16385
16643
  createdAt: timestamp19("created_at", { withTimezone: true }).notNull().defaultNow()
16386
16644
  },
16387
16645
  (table) => ({
@@ -16537,7 +16795,7 @@ var capabilityComponentOwners = pgTable19(
16537
16795
  }),
16538
16796
  ownerKind: text19("owner_kind").notNull(),
16539
16797
  ownerId: text19("owner_id").notNull(),
16540
- removable: boolean10("removable").notNull().default(true),
16798
+ removable: boolean11("removable").notNull().default(true),
16541
16799
  createdAt: timestamp19("created_at", { withTimezone: true }).notNull().defaultNow()
16542
16800
  },
16543
16801
  (table) => ({
@@ -16588,7 +16846,7 @@ var integrationTools = pgTable19(
16588
16846
  inputSchema: jsonb15("input_schema").$type().notNull().default({}),
16589
16847
  outputSchema: jsonb15("output_schema").$type(),
16590
16848
  effect: text19("effect").notNull().default("read"),
16591
- active: boolean10("active").notNull().default(true),
16849
+ active: boolean11("active").notNull().default(true),
16592
16850
  createdAt: timestamp19("created_at", { withTimezone: true }).notNull().defaultNow(),
16593
16851
  updatedAt: timestamp19("updated_at", { withTimezone: true }).notNull().defaultNow()
16594
16852
  },
@@ -16671,7 +16929,7 @@ var integrationFacetBindingOwners = pgTable19(
16671
16929
  bindingId: uuid19("binding_id").notNull().references(() => integrationFacetBindings.id, { onDelete: "cascade" }),
16672
16930
  ownerKind: text19("owner_kind").notNull(),
16673
16931
  ownerId: text19("owner_id").notNull(),
16674
- removable: boolean10("removable").notNull().default(true),
16932
+ removable: boolean11("removable").notNull().default(true),
16675
16933
  createdAt: timestamp19("created_at", { withTimezone: true }).notNull().defaultNow()
16676
16934
  },
16677
16935
  (table) => ({
@@ -16879,7 +17137,7 @@ var rigVersions = pgTable19(
16879
17137
  // session state, or process state.
16880
17138
  providerImages: jsonb15("provider_images").$type().notNull().default({}),
16881
17139
  createdBy: text19("created_by"),
16882
- active: boolean10("active").notNull().default(false),
17140
+ active: boolean11("active").notNull().default(false),
16883
17141
  createdAt: timestamp19("created_at", { withTimezone: true }).notNull().defaultNow()
16884
17142
  },
16885
17143
  (table) => ({
@@ -16927,6 +17185,82 @@ var rigChanges = pgTable19(
16927
17185
  workspaceStatus: index19("rig_changes_workspace_status_idx").on(table.workspaceId, table.status)
16928
17186
  })
16929
17187
  );
17188
+ var deploymentModelCatalog = pgTable19(
17189
+ "deployment_model_catalog",
17190
+ {
17191
+ singleton: boolean11("singleton").primaryKey().notNull().default(true),
17192
+ document: jsonb15("document").$type().notNull(),
17193
+ version: bigint14("version", { mode: "number" }).notNull().default(1),
17194
+ updatedAt: timestamp19("updated_at", { withTimezone: true }).notNull().defaultNow()
17195
+ },
17196
+ (table) => ({
17197
+ singletonCheck: check11("deployment_model_catalog_singleton_chk", sql16`${table.singleton}`),
17198
+ documentCheck: check11(
17199
+ "deployment_model_catalog_document_chk",
17200
+ sql16`jsonb_typeof(${table.document}) = 'object'`
17201
+ ),
17202
+ versionCheck: check11("deployment_model_catalog_version_chk", sql16`${table.version} > 0`)
17203
+ })
17204
+ );
17205
+ var workspaceGatewayCustomModels = pgTable19(
17206
+ "workspace_gateway_custom_models",
17207
+ {
17208
+ id: uuid19("id").primaryKey().defaultRandom(),
17209
+ accountId: uuid19("account_id").notNull().references(() => managedAccounts.id, { onDelete: "cascade" }),
17210
+ workspaceId: uuid19("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
17211
+ providerKind: text19("provider_kind").$type().notNull(),
17212
+ upstreamModelId: text19("upstream_model_id").notNull(),
17213
+ label: text19("label"),
17214
+ version: integer18("version").notNull().default(1),
17215
+ createOperationId: uuid19("create_operation_id").notNull(),
17216
+ createRequestHash: text19("create_request_hash").notNull(),
17217
+ deleteOperationId: uuid19("delete_operation_id"),
17218
+ deleteRequestHash: text19("delete_request_hash"),
17219
+ createdBySubjectId: text19("created_by_subject_id").notNull(),
17220
+ retiredAt: timestamp19("retired_at", { withTimezone: true }),
17221
+ createdAt: timestamp19("created_at", { withTimezone: true }).notNull().defaultNow(),
17222
+ updatedAt: timestamp19("updated_at", { withTimezone: true }).notNull().defaultNow()
17223
+ },
17224
+ (table) => ({
17225
+ workspaceAccountFk: foreignKey({
17226
+ name: "workspace_gateway_custom_models_workspace_account_fk",
17227
+ columns: [table.workspaceId, table.accountId],
17228
+ foreignColumns: [workspaces.id, workspaces.accountId]
17229
+ }).onDelete("cascade"),
17230
+ workspaceUpstream: uniqueIndex19("workspace_gateway_custom_models_workspace_upstream_uq").on(table.workspaceId, table.providerKind, table.upstreamModelId).where(sql16`${table.retiredAt} is null`),
17231
+ createOperation: uniqueIndex19("workspace_gateway_custom_models_create_operation_uq").on(
17232
+ table.workspaceId,
17233
+ table.providerKind,
17234
+ table.createOperationId
17235
+ ),
17236
+ deleteOperation: uniqueIndex19("workspace_gateway_custom_models_delete_operation_uq").on(table.workspaceId, table.providerKind, table.deleteOperationId).where(sql16`${table.deleteOperationId} is not null`),
17237
+ providerKindCheck: check11(
17238
+ "workspace_gateway_custom_models_provider_kind_chk",
17239
+ sql16`${table.providerKind} in ('vercel_gateway', 'openrouter')`
17240
+ ),
17241
+ upstreamCheck: check11(
17242
+ "workspace_gateway_custom_models_upstream_chk",
17243
+ sql16`octet_length(${table.upstreamModelId}) between 1 and 238 and ${table.upstreamModelId} ~ '^[!-~]+$' and ${table.upstreamModelId} !~ '[|]'`
17244
+ ),
17245
+ labelCheck: check11(
17246
+ "workspace_gateway_custom_models_label_chk",
17247
+ sql16`${table.label} is null or (octet_length(${table.label}) between 1 and 128 and ${table.label} !~ '[\r\n|]')`
17248
+ ),
17249
+ actorCheck: check11(
17250
+ "workspace_gateway_custom_models_actor_chk",
17251
+ sql16`octet_length(${table.createdBySubjectId}) between 1 and 1024`
17252
+ ),
17253
+ versionCheck: check11("workspace_gateway_custom_models_version_chk", sql16`${table.version} > 0`),
17254
+ createHashCheck: check11(
17255
+ "workspace_gateway_custom_models_create_hash_chk",
17256
+ sql16`${table.createRequestHash} ~ '^[a-f0-9]{64}$'`
17257
+ ),
17258
+ deleteReceiptCheck: check11(
17259
+ "workspace_gateway_custom_models_delete_receipt_chk",
17260
+ sql16`(${table.deleteOperationId} is null and ${table.deleteRequestHash} is null) or (${table.deleteOperationId} is not null and ${table.deleteRequestHash} ~ '^[a-f0-9]{64}$' and ${table.retiredAt} is not null)`
17261
+ )
17262
+ })
17263
+ );
16930
17264
 
16931
17265
  export {
16932
17266
  LOSSLESS_CONTENT_CODEC_VERSION,
@@ -16978,9 +17312,12 @@ export {
16978
17312
  companyProfileRevisions,
16979
17313
  companyProfileHeads,
16980
17314
  companyProfileActivationEvents,
17315
+ organizationCompanyProfileAgentPolicies,
17316
+ organizationCompanyProfileAgentPolicyEvents,
16981
17317
  companyProfileSnapshots,
16982
17318
  companyProfileAgentProposalReceipts,
16983
17319
  companyProfileAgentConfirmationReceipts,
17320
+ companyProfileAgentAutomaticActivationReceipts,
16984
17321
  workspaceLearningPolicyRevisions,
16985
17322
  workspaceLearningPolicyHeads,
16986
17323
  workspaceLearningPolicyActivationEvents,
@@ -17088,6 +17425,8 @@ export {
17088
17425
  workspaceVariableSets,
17089
17426
  workspaceVariableSetVariables,
17090
17427
  codexSubscriptionCredentials,
17428
+ workspaceCodexSubscriptionPreferences,
17429
+ organizationCodexRotationSettings,
17091
17430
  codexAppsSettings,
17092
17431
  codexResetRedemptionAttempts,
17093
17432
  connections,
@@ -17175,6 +17514,7 @@ export {
17175
17514
  codexCapacityWaiters,
17176
17515
  xaiSessionAccountPins,
17177
17516
  xaiCapacityWaiters,
17517
+ sessionEventCursors,
17178
17518
  sessionEvents,
17179
17519
  automaticSessionTitleFanoutOutboxV1,
17180
17520
  agentRunStates,
@@ -17268,6 +17608,8 @@ export {
17268
17608
  rigs,
17269
17609
  rigVersions,
17270
17610
  rigChanges,
17611
+ deploymentModelCatalog,
17612
+ workspaceGatewayCustomModels,
17271
17613
  schema_exports
17272
17614
  };
17273
- //# sourceMappingURL=chunk-UJ2EW3QI.js.map
17615
+ //# sourceMappingURL=chunk-DXJ2WY6W.js.map