@opengeni/db 3.7.4 → 3.8.2-canary.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. package/dist/automations.d.ts +4 -0
  2. package/dist/canonical-human-identities.js +3 -3
  3. package/dist/{chunk-O56DM5GZ.js → chunk-53A2PEHT.js} +328 -31
  4. package/dist/chunk-53A2PEHT.js.map +1 -0
  5. package/dist/{chunk-SZAWDXQC.js → chunk-5S4BQAHX.js} +3 -3
  6. package/dist/{chunk-S3TDDCS2.js → chunk-CITYUGMW.js} +3 -3
  7. package/dist/{chunk-4NAR7FBA.js → chunk-F5YOZEYQ.js} +49 -1
  8. package/dist/chunk-F5YOZEYQ.js.map +1 -0
  9. package/dist/{chunk-F6PBS6WE.js → chunk-HZV7O6JR.js} +2 -2
  10. package/dist/{chunk-5NNCGFQY.js → chunk-RLQVPOVR.js} +2 -2
  11. package/dist/{chunk-DZCYW2WT.js → chunk-UKOGHUGC.js} +2 -2
  12. package/dist/{chunk-US4IS6IV.js → chunk-X6TO5HII.js} +2 -2
  13. package/dist/{chunk-U4WPPEBH.js → chunk-Y53WEFYB.js} +2 -2
  14. package/dist/connection-token-resolver.d.ts +4 -0
  15. package/dist/editable-artifact-durable-export.js +2 -2
  16. package/dist/editable-artifacts.js +3 -3
  17. package/dist/index.d.ts +164 -14
  18. package/dist/index.js +7327 -5442
  19. package/dist/index.js.map +1 -1
  20. package/dist/insights.d.ts +9 -0
  21. package/dist/managed-auth-session-sets.js +3 -3
  22. package/dist/model-catalog.d.ts +153 -0
  23. package/dist/new-session-drafts.d.ts +12 -0
  24. package/dist/organization-membership-lifecycle.d.ts +8 -1
  25. package/dist/organization-model-providers.d.ts +101 -0
  26. package/dist/pack-components.d.ts +1 -0
  27. package/dist/pr-review.d.ts +9 -0
  28. package/dist/provision-roles.js +1 -1
  29. package/dist/runtime-posture.d.ts +7 -7
  30. package/dist/schema.d.ts +989 -2
  31. package/dist/schema.js +11 -1
  32. package/dist/session-background-commands.js +3 -3
  33. package/dist/session-control.d.ts +35 -0
  34. package/dist/session-queue-commands.d.ts +17 -0
  35. package/dist/session-tenancy.js +3 -3
  36. package/dist/video-generation.js +3 -3
  37. package/dist/xai-subscription.d.ts +8 -0
  38. package/drizzle/0387_bound_host_export_session_payloads.sql +165 -0
  39. package/drizzle/0388_sandbox_provider_deadline_interactions.sql +491 -0
  40. package/drizzle/0389_model_catalog_and_gateway_custom_models.sql +241 -0
  41. package/drizzle/0390_organization_model_provider_connections.sql +197 -0
  42. package/drizzle/0391_sandbox_provider_deadline_interaction_followup.sql +295 -0
  43. package/drizzle/0392_context_compaction_pending_observability.sql +198 -0
  44. package/drizzle/0393_workspace_memory_and_learning_defaults.sql +102 -0
  45. package/drizzle/0394_session_selected_skill_activation.sql +20 -0
  46. package/drizzle/0395_scheduled_task_unclaimed_occurrence_invalidation.sql +154 -0
  47. package/drizzle/0396_model_call_equivalent_credit_cost.sql +28 -0
  48. package/drizzle/0397_sandbox_deadline_rotation_preemption.sql +113 -0
  49. package/drizzle/0398_organization_workspace_management_entry.sql +206 -0
  50. package/drizzle/0399_additional_managed_organization_creation.sql +691 -0
  51. package/package.json +6 -6
  52. package/src/automations.ts +9 -1
  53. package/src/connection-token-resolver.ts +12 -0
  54. package/src/index.ts +1551 -272
  55. package/src/insights-model-bundle.ts +54 -5
  56. package/src/insights.ts +53 -7
  57. package/src/model-catalog.ts +682 -0
  58. package/src/new-session-drafts.ts +66 -21
  59. package/src/organization-membership-lifecycle.ts +47 -5
  60. package/src/organization-model-providers.ts +614 -0
  61. package/src/pack-components.ts +15 -2
  62. package/src/pr-review.ts +19 -0
  63. package/src/provision-roles.ts +2 -0
  64. package/src/runtime-posture.ts +48 -0
  65. package/src/schema.ts +348 -32
  66. package/src/session-control.ts +170 -0
  67. package/src/session-queue-commands.ts +157 -82
  68. package/src/xai-subscription.ts +66 -14
  69. package/dist/chunk-4NAR7FBA.js.map +0 -1
  70. package/dist/chunk-O56DM5GZ.js.map +0 -1
  71. /package/dist/{chunk-SZAWDXQC.js.map → chunk-5S4BQAHX.js.map} +0 -0
  72. /package/dist/{chunk-S3TDDCS2.js.map → chunk-CITYUGMW.js.map} +0 -0
  73. /package/dist/{chunk-F6PBS6WE.js.map → chunk-HZV7O6JR.js.map} +0 -0
  74. /package/dist/{chunk-5NNCGFQY.js.map → chunk-RLQVPOVR.js.map} +0 -0
  75. /package/dist/{chunk-DZCYW2WT.js.map → chunk-UKOGHUGC.js.map} +0 -0
  76. /package/dist/{chunk-US4IS6IV.js.map → chunk-X6TO5HII.js.map} +0 -0
  77. /package/dist/{chunk-U4WPPEBH.js.map → chunk-Y53WEFYB.js.map} +0 -0
@@ -75,6 +75,8 @@ export declare function createAutomationTrigger(db: Database, input: {
75
75
  createdBySubjectId: string;
76
76
  request: CreateAutomationTriggerRequest;
77
77
  adapterId: string;
78
+ /** Trusted database-only admission seam. Throwing rolls creation back. */
79
+ beforeCreateCommit?: (tx: Database) => Promise<void>;
78
80
  }): Promise<AutomationTrigger>;
79
81
  export declare function listAutomationTriggers(db: Database, workspaceId: string): Promise<AutomationTrigger[]>;
80
82
  export declare function listActiveAutomationTriggersForSource(db: Database, input: {
@@ -94,6 +96,8 @@ export declare function updateAutomationTrigger(db: Database, input: {
94
96
  triggerId: string;
95
97
  subjectId: string;
96
98
  request: UpdateAutomationTriggerRequest;
99
+ /** Trusted database-only admission seam. Throwing rolls the revision back. */
100
+ beforeUpdateCommit?: (tx: Database) => Promise<void>;
97
101
  }): Promise<AutomationTrigger | null>;
98
102
  export declare function recordAutomationEvent(db: Database, input: {
99
103
  accountId: string;
@@ -11,9 +11,9 @@ import {
11
11
  getCanonicalHumanIdentityProjection,
12
12
  synchronizeCanonicalHumanLoginBindings,
13
13
  validateCanonicalHumanSession
14
- } from "./chunk-U4WPPEBH.js";
15
- import "./chunk-F6PBS6WE.js";
16
- import "./chunk-O56DM5GZ.js";
14
+ } from "./chunk-Y53WEFYB.js";
15
+ import "./chunk-HZV7O6JR.js";
16
+ import "./chunk-53A2PEHT.js";
17
17
  import "./chunk-PZ5AY32C.js";
18
18
  export {
19
19
  CanonicalHumanIdentityAuthorityError,
@@ -68,6 +68,7 @@ __export(schema_exports, {
68
68
  connectorActionPolicies: () => connectorActionPolicies,
69
69
  connectorActionRequests: () => connectorActionRequests,
70
70
  creditLedgerEntries: () => creditLedgerEntries,
71
+ deploymentModelCatalog: () => deploymentModelCatalog,
71
72
  deviceEnrollmentRequests: () => deviceEnrollmentRequests,
72
73
  deviceEnrollmentStatusValues: () => deviceEnrollmentStatusValues,
73
74
  documentBases: () => documentBases,
@@ -175,6 +176,9 @@ __export(schema_exports, {
175
176
  organizationMembershipLifecycleEvents: () => organizationMembershipLifecycleEvents,
176
177
  organizationMembershipOperationReceipts: () => organizationMembershipOperationReceipts,
177
178
  organizationMemberships: () => organizationMemberships,
179
+ organizationModelProviderConnectionOperations: () => organizationModelProviderConnectionOperations,
180
+ organizationModelProviderConnections: () => organizationModelProviderConnections,
181
+ organizationModelProviderCustomModels: () => organizationModelProviderCustomModels,
178
182
  organizationPrivateSessionSettingEvents: () => organizationPrivateSessionSettingEvents,
179
183
  organizationPrivateSessionSettings: () => organizationPrivateSessionSettings,
180
184
  organizationProfileEvents: () => organizationProfileEvents,
@@ -316,6 +320,7 @@ __export(schema_exports, {
316
320
  workspaceCaptures: () => workspaceCaptures,
317
321
  workspaceCodexSubscriptionPreferences: () => workspaceCodexSubscriptionPreferences,
318
322
  workspaceControlEvents: () => workspaceControlEvents,
323
+ workspaceGatewayCustomModels: () => workspaceGatewayCustomModels,
319
324
  workspaceInferenceControls: () => workspaceInferenceControls,
320
325
  workspaceInstructionPolicyActivationEvents: () => workspaceInstructionPolicyActivationEvents,
321
326
  workspaceInstructionPolicyDeactivationEvents: () => workspaceInstructionPolicyDeactivationEvents,
@@ -6387,9 +6392,9 @@ var workspaces = pgTable19(
6387
6392
  // White-label agent persona template override. NULL means the deployment
6388
6393
  // default (OPENGENI_AGENT_INSTRUCTIONS_TEMPLATE / DEFAULT_AGENT_INSTRUCTIONS).
6389
6394
  agentInstructions: text19("agent_instructions"),
6390
- // Growth-ready per-workspace settings bag (migration 0045). Holds memoryEnabled
6391
- // and future workspace-level toggles; validated/merged via WorkspaceSettingsSchema.
6392
- settings: jsonb15("settings").$type().notNull().default({}),
6395
+ // Growth-ready per-workspace settings bag (migration 0045). Migration 0393
6396
+ // makes Memory enabled by default; explicit false remains authoritative.
6397
+ settings: jsonb15("settings").$type().notNull().default({ memoryEnabled: true }),
6393
6398
  // The workspace's default rig (migration 0047). NULL ⇒ no default; sessions
6394
6399
  // created without an explicit rig ride no rig (today's behavior exactly). FK
6395
6400
  // (-> rigs(id) ON DELETE SET NULL) lives in migration 0047, not a Drizzle
@@ -6746,8 +6751,12 @@ var organizationProfileEvents = pgTable19(
6746
6751
  actorMembershipId: uuid19("actor_membership_id").notNull(),
6747
6752
  previousName: text19("previous_name").notNull(),
6748
6753
  requestedName: text19("requested_name").notNull(),
6749
- expectedUpdatedAt: timestamp19("expected_updated_at", { withTimezone: true }).notNull(),
6750
- resultUpdatedAt: timestamp19("result_updated_at", { withTimezone: true }).notNull(),
6754
+ expectedUpdatedAt: timestamp19("expected_updated_at", {
6755
+ withTimezone: true
6756
+ }).notNull(),
6757
+ resultUpdatedAt: timestamp19("result_updated_at", {
6758
+ withTimezone: true
6759
+ }).notNull(),
6751
6760
  createdAt: timestamp19("created_at", { withTimezone: true }).notNull().defaultNow()
6752
6761
  },
6753
6762
  (table) => ({
@@ -6820,7 +6829,9 @@ var organizationPrivateSessionSettingEvents = pgTable19(
6820
6829
  expectedVersion: bigint14("expected_version", { mode: "number" }).notNull(),
6821
6830
  resultEnabled: boolean11("result_enabled").notNull(),
6822
6831
  resultVersion: bigint14("result_version", { mode: "number" }).notNull(),
6823
- resultUpdatedAt: timestamp19("result_updated_at", { withTimezone: true }).notNull(),
6832
+ resultUpdatedAt: timestamp19("result_updated_at", {
6833
+ withTimezone: true
6834
+ }).notNull(),
6824
6835
  changed: boolean11("changed").notNull(),
6825
6836
  createdAt: timestamp19("created_at", { withTimezone: true }).notNull().defaultNow()
6826
6837
  },
@@ -6942,7 +6953,9 @@ var organizationInvitationBindingEvents = pgTable19(
6942
6953
  accountId: uuid19("account_id").notNull().references(() => managedAccounts.id, { onDelete: "cascade" }),
6943
6954
  invitationId: uuid19("invitation_id").notNull(),
6944
6955
  targetSubjectId: text19("target_subject_id").notNull(),
6945
- resultingRevision: bigint14("resulting_revision", { mode: "number" }).notNull(),
6956
+ resultingRevision: bigint14("resulting_revision", {
6957
+ mode: "number"
6958
+ }).notNull(),
6946
6959
  boundAt: timestamp19("bound_at", { withTimezone: true }).notNull().defaultNow()
6947
6960
  },
6948
6961
  (table) => ({
@@ -7036,13 +7049,19 @@ var organizationUserRetentionDeletions = pgTable19(
7036
7049
  {
7037
7050
  accountId: uuid19("account_id").notNull().references(() => managedAccounts.id, { onDelete: "cascade" }),
7038
7051
  membershipId: uuid19("membership_id").notNull(),
7039
- retentionUntil: timestamp19("retention_until", { withTimezone: true }).notNull(),
7052
+ retentionUntil: timestamp19("retention_until", {
7053
+ withTimezone: true
7054
+ }).notNull(),
7040
7055
  state: text19("state").notNull().default("claimed"),
7041
7056
  claimOperationId: uuid19("claim_operation_id").notNull(),
7042
- claimExpiresAt: timestamp19("claim_expires_at", { withTimezone: true }).notNull(),
7057
+ claimExpiresAt: timestamp19("claim_expires_at", {
7058
+ withTimezone: true
7059
+ }).notNull(),
7043
7060
  attemptCount: integer18("attempt_count").notNull().default(1),
7044
7061
  databaseResult: jsonb15("database_result").$type(),
7045
- databaseFinalizedAt: timestamp19("database_finalized_at", { withTimezone: true }),
7062
+ databaseFinalizedAt: timestamp19("database_finalized_at", {
7063
+ withTimezone: true
7064
+ }),
7046
7065
  result: jsonb15("result").$type(),
7047
7066
  completedAt: timestamp19("completed_at", { withTimezone: true }),
7048
7067
  updatedAt: timestamp19("updated_at", { withTimezone: true }).notNull().defaultNow()
@@ -7410,7 +7429,9 @@ var codexSubscriptionCredentials = pgTable19(
7410
7429
  {
7411
7430
  id: uuid19("id").primaryKey().defaultRandom(),
7412
7431
  accountId: uuid19("account_id").notNull().references(() => managedAccounts.id, { onDelete: "cascade" }),
7413
- workspaceId: uuid19("workspace_id").references(() => workspaces.id, { onDelete: "cascade" }),
7432
+ workspaceId: uuid19("workspace_id").references(() => workspaces.id, {
7433
+ onDelete: "cascade"
7434
+ }),
7414
7435
  organizationId: uuid19("organization_id").references(() => managedAccounts.id, {
7415
7436
  onDelete: "cascade"
7416
7437
  }),
@@ -7922,7 +7943,9 @@ var connectionUseOnceConsumptionReceipts = pgTable19(
7922
7943
  grantId: uuid19("grant_id").primaryKey(),
7923
7944
  accountId: uuid19("account_id").notNull().references(() => managedAccounts.id, { onDelete: "cascade" }),
7924
7945
  authorityId: uuid19("authority_id").notNull(),
7925
- authorityGeneration: bigint14("authority_generation", { mode: "number" }).notNull(),
7946
+ authorityGeneration: bigint14("authority_generation", {
7947
+ mode: "number"
7948
+ }).notNull(),
7926
7949
  grantGeneration: bigint14("grant_generation", { mode: "number" }).notNull(),
7927
7950
  acceptedWorkKind: text19("accepted_work_kind").notNull(),
7928
7951
  acceptedWorkId: uuid19("accepted_work_id").notNull(),
@@ -8531,7 +8554,9 @@ var slackInteractionInbox = pgTable19(
8531
8554
  targetAccountId: uuid19("target_account_id"),
8532
8555
  targetWorkspaceId: uuid19("target_workspace_id"),
8533
8556
  routePromptId: uuid19("route_prompt_id"),
8534
- routePromptExpiresAt: timestamp19("route_prompt_expires_at", { withTimezone: true }),
8557
+ routePromptExpiresAt: timestamp19("route_prompt_expires_at", {
8558
+ withTimezone: true
8559
+ }),
8535
8560
  processedAt: timestamp19("processed_at", { withTimezone: true }),
8536
8561
  createdAt: timestamp19("created_at", { withTimezone: true }).notNull().defaultNow(),
8537
8562
  updatedAt: timestamp19("updated_at", { withTimezone: true }).notNull().defaultNow()
@@ -11602,7 +11627,9 @@ var turnPersonalResourceSnapshots = pgTable19(
11602
11627
  mode: "number"
11603
11628
  }).notNull(),
11604
11629
  authorityId: uuid19("authority_id").notNull(),
11605
- authorityGeneration: bigint14("authority_generation", { mode: "number" }).notNull(),
11630
+ authorityGeneration: bigint14("authority_generation", {
11631
+ mode: "number"
11632
+ }).notNull(),
11606
11633
  grantId: uuid19("grant_id").notNull(),
11607
11634
  grantGeneration: bigint14("grant_generation", { mode: "number" }).notNull(),
11608
11635
  grantMode: text19("grant_mode").notNull(),
@@ -11614,7 +11641,9 @@ var turnPersonalResourceSnapshots = pgTable19(
11614
11641
  createdAt: timestamp19("created_at", { withTimezone: true }).notNull().defaultNow()
11615
11642
  },
11616
11643
  (table) => ({
11617
- pk: primaryKey8({ columns: [table.turnId, table.resourceKind, table.resourceId] }),
11644
+ pk: primaryKey8({
11645
+ columns: [table.turnId, table.resourceKind, table.resourceId]
11646
+ }),
11618
11647
  receipt: foreignKey({
11619
11648
  name: "turn_personal_resource_snapshots_receipt_fk",
11620
11649
  columns: [table.turnId],
@@ -11661,7 +11690,9 @@ var turnPersonalResourceOnceReceipts = pgTable19(
11661
11690
  turnId: uuid19("turn_id").notNull(),
11662
11691
  accountId: uuid19("account_id").notNull(),
11663
11692
  authorityId: uuid19("authority_id").notNull(),
11664
- authorityGeneration: bigint14("authority_generation", { mode: "number" }).notNull(),
11693
+ authorityGeneration: bigint14("authority_generation", {
11694
+ mode: "number"
11695
+ }).notNull(),
11665
11696
  grantGeneration: bigint14("grant_generation", { mode: "number" }).notNull(),
11666
11697
  consumedAt: timestamp19("consumed_at", { withTimezone: true }).notNull().defaultNow()
11667
11698
  },
@@ -11925,7 +11956,9 @@ var turnConnectionAuthoritySnapshots = pgTable19(
11925
11956
  turnId: uuid19("turn_id").notNull(),
11926
11957
  serverId: text19("server_id").notNull(),
11927
11958
  connectionId: uuid19("connection_id").notNull(),
11928
- connectionGeneration: bigint14("connection_generation", { mode: "number" }).notNull(),
11959
+ connectionGeneration: bigint14("connection_generation", {
11960
+ mode: "number"
11961
+ }).notNull(),
11929
11962
  originWorkspaceId: uuid19("origin_workspace_id").notNull(),
11930
11963
  providerDomain: text19("provider_domain").notNull(),
11931
11964
  connectionKind: text19("connection_kind").notNull(),
@@ -12429,6 +12462,13 @@ var sessionCommandReceipts = pgTable19(
12429
12462
  table.targetSessionId,
12430
12463
  table.createdAt
12431
12464
  ),
12465
+ promptActorOperation: index19("session_command_receipts_prompt_actor_operation_idx").on(
12466
+ table.workspaceId,
12467
+ table.actorType,
12468
+ table.actorSubjectId,
12469
+ table.actorAttemptId,
12470
+ table.operationKey
12471
+ ).where(sql16`${table.action} in ('prompt.send', 'prompt.steer')`),
12432
12472
  goalUpdateOperation: uniqueIndex19("session_command_receipts_goal_update_operation_uq").on(table.workspaceId, table.action, table.targetSessionId, table.operationKey).where(sql16`${table.action} = 'goal.update'`),
12433
12473
  actorValid: check11(
12434
12474
  "session_command_receipts_actor_check",
@@ -12851,9 +12891,13 @@ var sessionGoals = pgTable19(
12851
12891
  // Any newer finished turn, a passed deadline, or a goal mutation clears all
12852
12892
  // four columns together.
12853
12893
  continuationHoldTurnId: uuid19("continuation_hold_turn_id"),
12854
- continuationHoldUntil: timestamp19("continuation_hold_until", { withTimezone: true }),
12894
+ continuationHoldUntil: timestamp19("continuation_hold_until", {
12895
+ withTimezone: true
12896
+ }),
12855
12897
  continuationHoldReason: text19("continuation_hold_reason"),
12856
- continuationHoldSetAt: timestamp19("continuation_hold_set_at", { withTimezone: true }),
12898
+ continuationHoldSetAt: timestamp19("continuation_hold_set_at", {
12899
+ withTimezone: true
12900
+ }),
12857
12901
  metadata: jsonb15("metadata").$type().notNull().default({}),
12858
12902
  createdAt: timestamp19("created_at", { withTimezone: true }).notNull().defaultNow(),
12859
12903
  updatedAt: timestamp19("updated_at", { withTimezone: true }).notNull().defaultNow()
@@ -13925,7 +13969,9 @@ var sandboxWorkspaceMutationAdmissions = pgTable19(
13925
13969
  // authorization revision observed at admission. The revision is audit
13926
13970
  // evidence: a role change is not a revocation and must not fence a writer.
13927
13971
  initiatorOrganizationMembershipId: uuid19("initiator_organization_membership_id"),
13928
- initiatorAuthorizationRevision: bigint14("initiator_authorization_revision", { mode: "number" }),
13972
+ initiatorAuthorizationRevision: bigint14("initiator_authorization_revision", {
13973
+ mode: "number"
13974
+ }),
13929
13975
  // Session tenancy authority observed when the operation was admitted; the
13930
13976
  // same triple `session_turn_attempts` freezes for a turn.
13931
13977
  authorityEpoch: integer18("authority_epoch"),
@@ -14134,7 +14180,9 @@ var sandboxRetainedProcesses = pgTable19(
14134
14180
  initiatorSubjectId: text19("initiator_subject_id").notNull().default("unattributed-legacy"),
14135
14181
  initiatingHumanSubjectId: text19("initiating_human_subject_id"),
14136
14182
  initiatorOrganizationMembershipId: uuid19("initiator_organization_membership_id"),
14137
- initiatorAuthorizationRevision: bigint14("initiator_authorization_revision", { mode: "number" }),
14183
+ initiatorAuthorizationRevision: bigint14("initiator_authorization_revision", {
14184
+ mode: "number"
14185
+ }),
14138
14186
  authorityEpoch: integer18("authority_epoch"),
14139
14187
  authorityVisibility: text19("authority_visibility", {
14140
14188
  enum: ["user_private", "workspace_shared"]
@@ -14380,7 +14428,9 @@ var sessionBackgroundCommands = pgTable19(
14380
14428
  accountId: uuid19("account_id").notNull(),
14381
14429
  workspaceId: uuid19("workspace_id").notNull(),
14382
14430
  sessionId: uuid19("session_id").notNull(),
14383
- provider: text19("provider", { enum: ["managed", "connected_machine"] }).notNull(),
14431
+ provider: text19("provider", {
14432
+ enum: ["managed", "connected_machine"]
14433
+ }).notNull(),
14384
14434
  state: text19("state", { enum: ["running", "stopping", "exited", "lost"] }).notNull().default("running"),
14385
14435
  retainedProcessId: uuid19("retained_process_id"),
14386
14436
  controlWorkspaceId: uuid19("control_workspace_id"),
@@ -14396,13 +14446,19 @@ var sessionBackgroundCommands = pgTable19(
14396
14446
  settledAt: timestamp19("settled_at", { withTimezone: true }),
14397
14447
  reconcileAfter: timestamp19("reconcile_after", { withTimezone: true }).notNull().defaultNow(),
14398
14448
  reconcileClaimId: uuid19("reconcile_claim_id"),
14399
- reconcileClaimedAt: timestamp19("reconcile_claimed_at", { withTimezone: true }),
14449
+ reconcileClaimedAt: timestamp19("reconcile_claimed_at", {
14450
+ withTimezone: true
14451
+ }),
14400
14452
  reconcileAttempts: integer18("reconcile_attempts").notNull().default(0),
14401
14453
  lastReconcileOutcome: text19("last_reconcile_outcome"),
14402
- reconcileProofOutcome: text19("reconcile_proof_outcome", { enum: ["exited", "lost"] }),
14454
+ reconcileProofOutcome: text19("reconcile_proof_outcome", {
14455
+ enum: ["exited", "lost"]
14456
+ }),
14403
14457
  reconcileProofExitCode: integer18("reconcile_proof_exit_code"),
14404
14458
  reconcileProofReason: text19("reconcile_proof_reason"),
14405
- reconcileProofObservedAt: timestamp19("reconcile_proof_observed_at", { withTimezone: true }),
14459
+ reconcileProofObservedAt: timestamp19("reconcile_proof_observed_at", {
14460
+ withTimezone: true
14461
+ }),
14406
14462
  updatedAt: timestamp19("updated_at", { withTimezone: true }).notNull().defaultNow()
14407
14463
  },
14408
14464
  (table) => ({
@@ -15420,12 +15476,18 @@ var prReviewAppRegistrations = pgTable19(
15420
15476
  providerAccountType: text19("provider_account_type"),
15421
15477
  githubActorId: text19("github_actor_id"),
15422
15478
  authorityKind: text19("authority_kind"),
15423
- authorityCheckedAt: timestamp19("authority_checked_at", { withTimezone: true }),
15424
- authorityExpiresAt: timestamp19("authority_expires_at", { withTimezone: true }),
15479
+ authorityCheckedAt: timestamp19("authority_checked_at", {
15480
+ withTimezone: true
15481
+ }),
15482
+ authorityExpiresAt: timestamp19("authority_expires_at", {
15483
+ withTimezone: true
15484
+ }),
15425
15485
  authorityNonce: text19("authority_nonce"),
15426
15486
  credentialKind: text19("credential_kind").notNull(),
15427
15487
  credentialEncrypted: text19("credential_encrypted"),
15428
- accessTokenExpiresAt: timestamp19("access_token_expires_at", { withTimezone: true }),
15488
+ accessTokenExpiresAt: timestamp19("access_token_expires_at", {
15489
+ withTimezone: true
15490
+ }),
15429
15491
  webhookAuthKind: text19("webhook_auth_kind").notNull(),
15430
15492
  webhookUsername: text19("webhook_username"),
15431
15493
  status: text19("status").notNull().default("active"),
@@ -15554,7 +15616,9 @@ var prReviewManagedGithubAuthorityNonces = pgTable19(
15554
15616
  accountId: uuid19("account_id").notNull().references(() => managedAccounts.id, { onDelete: "cascade" }),
15555
15617
  workspaceId: uuid19("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
15556
15618
  installationId: text19("installation_id").notNull(),
15557
- authorityExpiresAt: timestamp19("authority_expires_at", { withTimezone: true }).notNull(),
15619
+ authorityExpiresAt: timestamp19("authority_expires_at", {
15620
+ withTimezone: true
15621
+ }).notNull(),
15558
15622
  consumedAt: timestamp19("consumed_at", { withTimezone: true }).notNull().defaultNow()
15559
15623
  },
15560
15624
  (table) => ({
@@ -15710,6 +15774,9 @@ var modelCallFacts = pgTable19(
15710
15774
  estimatedProviderCostMicros: bigint14("estimated_provider_cost_micros", {
15711
15775
  mode: "number"
15712
15776
  }),
15777
+ equivalentCreditCostMicros: bigint14("equivalent_credit_cost_micros", {
15778
+ mode: "number"
15779
+ }),
15713
15780
  pricingSource: text19("pricing_source"),
15714
15781
  contextContributions: jsonb15("context_contributions").$type(),
15715
15782
  occurredAt: timestamp19("occurred_at", { withTimezone: true }).notNull(),
@@ -15751,6 +15818,10 @@ var modelCallFacts = pgTable19(
15751
15818
  "model_call_facts_estimated_provider_cost_check",
15752
15819
  sql16`${table.estimatedProviderCostMicros} is null or ${table.estimatedProviderCostMicros} >= 0`
15753
15820
  ),
15821
+ equivalentCreditCostValid: check11(
15822
+ "model_call_facts_equivalent_credit_cost_check",
15823
+ sql16`${table.equivalentCreditCostMicros} is null or (${table.equivalentCreditCostMicros} >= 0 and ${table.estimatedProviderCostMicros} is not null)`
15824
+ ),
15754
15825
  pricingSourceValid: check11(
15755
15826
  "model_call_facts_pricing_source_check",
15756
15827
  sql16`(${table.estimatedProviderCostMicros} is null and ${table.pricingSource} is null)
@@ -16331,7 +16402,9 @@ var automationRuns = pgTable19(
16331
16402
  occurrenceKey: text19("occurrence_key").notNull(),
16332
16403
  acceptedExecution: jsonb15("accepted_execution").$type().notNull(),
16333
16404
  status: text19("status").notNull().default("queued"),
16334
- sessionId: uuid19("session_id").references(() => sessions.id, { onDelete: "set null" }),
16405
+ sessionId: uuid19("session_id").references(() => sessions.id, {
16406
+ onDelete: "set null"
16407
+ }),
16335
16408
  errorCode: text19("error_code"),
16336
16409
  createdAt: timestamp19("created_at", { withTimezone: true }).notNull().defaultNow(),
16337
16410
  updatedAt: timestamp19("updated_at", { withTimezone: true }).notNull().defaultNow()
@@ -17176,6 +17249,225 @@ var rigChanges = pgTable19(
17176
17249
  workspaceStatus: index19("rig_changes_workspace_status_idx").on(table.workspaceId, table.status)
17177
17250
  })
17178
17251
  );
17252
+ var deploymentModelCatalog = pgTable19(
17253
+ "deployment_model_catalog",
17254
+ {
17255
+ singleton: boolean11("singleton").primaryKey().notNull().default(true),
17256
+ document: jsonb15("document").$type().notNull(),
17257
+ version: bigint14("version", { mode: "number" }).notNull().default(1),
17258
+ updatedAt: timestamp19("updated_at", { withTimezone: true }).notNull().defaultNow()
17259
+ },
17260
+ (table) => ({
17261
+ singletonCheck: check11("deployment_model_catalog_singleton_chk", sql16`${table.singleton}`),
17262
+ documentCheck: check11(
17263
+ "deployment_model_catalog_document_chk",
17264
+ sql16`jsonb_typeof(${table.document}) = 'object'`
17265
+ ),
17266
+ versionCheck: check11("deployment_model_catalog_version_chk", sql16`${table.version} > 0`)
17267
+ })
17268
+ );
17269
+ var workspaceGatewayCustomModels = pgTable19(
17270
+ "workspace_gateway_custom_models",
17271
+ {
17272
+ id: uuid19("id").primaryKey().defaultRandom(),
17273
+ accountId: uuid19("account_id").notNull().references(() => managedAccounts.id, { onDelete: "cascade" }),
17274
+ workspaceId: uuid19("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
17275
+ providerKind: text19("provider_kind").$type().notNull(),
17276
+ upstreamModelId: text19("upstream_model_id").notNull(),
17277
+ label: text19("label"),
17278
+ version: integer18("version").notNull().default(1),
17279
+ createOperationId: uuid19("create_operation_id").notNull(),
17280
+ createRequestHash: text19("create_request_hash").notNull(),
17281
+ deleteOperationId: uuid19("delete_operation_id"),
17282
+ deleteRequestHash: text19("delete_request_hash"),
17283
+ createdBySubjectId: text19("created_by_subject_id").notNull(),
17284
+ retiredAt: timestamp19("retired_at", { withTimezone: true }),
17285
+ createdAt: timestamp19("created_at", { withTimezone: true }).notNull().defaultNow(),
17286
+ updatedAt: timestamp19("updated_at", { withTimezone: true }).notNull().defaultNow()
17287
+ },
17288
+ (table) => ({
17289
+ workspaceAccountFk: foreignKey({
17290
+ name: "workspace_gateway_custom_models_workspace_account_fk",
17291
+ columns: [table.workspaceId, table.accountId],
17292
+ foreignColumns: [workspaces.id, workspaces.accountId]
17293
+ }).onDelete("cascade"),
17294
+ workspaceUpstream: uniqueIndex19("workspace_gateway_custom_models_workspace_upstream_uq").on(table.workspaceId, table.providerKind, table.upstreamModelId).where(sql16`${table.retiredAt} is null`),
17295
+ createOperation: uniqueIndex19("workspace_gateway_custom_models_create_operation_uq").on(
17296
+ table.workspaceId,
17297
+ table.providerKind,
17298
+ table.createOperationId
17299
+ ),
17300
+ deleteOperation: uniqueIndex19("workspace_gateway_custom_models_delete_operation_uq").on(table.workspaceId, table.providerKind, table.deleteOperationId).where(sql16`${table.deleteOperationId} is not null`),
17301
+ providerKindCheck: check11(
17302
+ "workspace_gateway_custom_models_provider_kind_chk",
17303
+ sql16`${table.providerKind} in ('vercel_gateway', 'openrouter')`
17304
+ ),
17305
+ upstreamCheck: check11(
17306
+ "workspace_gateway_custom_models_upstream_chk",
17307
+ sql16`octet_length(${table.upstreamModelId}) between 1 and 238 and ${table.upstreamModelId} ~ '^[!-~]+$' and ${table.upstreamModelId} !~ '[|]'`
17308
+ ),
17309
+ labelCheck: check11(
17310
+ "workspace_gateway_custom_models_label_chk",
17311
+ sql16`${table.label} is null or (octet_length(${table.label}) between 1 and 128 and ${table.label} !~ '[\r\n|]')`
17312
+ ),
17313
+ actorCheck: check11(
17314
+ "workspace_gateway_custom_models_actor_chk",
17315
+ sql16`octet_length(${table.createdBySubjectId}) between 1 and 1024`
17316
+ ),
17317
+ versionCheck: check11("workspace_gateway_custom_models_version_chk", sql16`${table.version} > 0`),
17318
+ createHashCheck: check11(
17319
+ "workspace_gateway_custom_models_create_hash_chk",
17320
+ sql16`${table.createRequestHash} ~ '^[a-f0-9]{64}$'`
17321
+ ),
17322
+ deleteReceiptCheck: check11(
17323
+ "workspace_gateway_custom_models_delete_receipt_chk",
17324
+ 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)`
17325
+ )
17326
+ })
17327
+ );
17328
+ var organizationModelProviderConnections = pgTable19(
17329
+ "organization_model_provider_connections",
17330
+ {
17331
+ id: uuid19("id").primaryKey().defaultRandom(),
17332
+ accountId: uuid19("account_id").notNull().references(() => managedAccounts.id, { onDelete: "cascade" }),
17333
+ providerKind: text19("provider_kind").$type().notNull(),
17334
+ status: text19("status").$type().notNull().default("active"),
17335
+ credentialEncrypted: text19("credential_encrypted").notNull(),
17336
+ version: integer18("version").notNull().default(1),
17337
+ operationId: uuid19("operation_id").notNull(),
17338
+ requestHash: text19("request_hash").notNull(),
17339
+ updatedBySubjectId: text19("updated_by_subject_id").notNull(),
17340
+ createdAt: timestamp19("created_at", { withTimezone: true }).notNull().defaultNow(),
17341
+ updatedAt: timestamp19("updated_at", { withTimezone: true }).notNull().defaultNow()
17342
+ },
17343
+ (table) => ({
17344
+ accountProvider: uniqueIndex19("organization_model_provider_connections_account_provider_uq").on(
17345
+ table.accountId,
17346
+ table.providerKind
17347
+ ),
17348
+ operation: uniqueIndex19("organization_model_provider_connections_operation_uq").on(
17349
+ table.accountId,
17350
+ table.providerKind,
17351
+ table.operationId
17352
+ ),
17353
+ providerKindCheck: check11(
17354
+ "organization_model_provider_connections_provider_kind_chk",
17355
+ sql16`${table.providerKind} in ('vercel_gateway', 'openrouter')`
17356
+ ),
17357
+ statusCheck: check11(
17358
+ "organization_model_provider_connections_status_chk",
17359
+ sql16`${table.status} in ('active', 'revoked')`
17360
+ ),
17361
+ versionCheck: check11(
17362
+ "organization_model_provider_connections_version_chk",
17363
+ sql16`${table.version} > 0`
17364
+ ),
17365
+ requestHashCheck: check11(
17366
+ "organization_model_provider_connections_request_hash_chk",
17367
+ sql16`${table.requestHash} ~ '^[a-f0-9]{64}$'`
17368
+ ),
17369
+ actorCheck: check11(
17370
+ "organization_model_provider_connections_actor_chk",
17371
+ sql16`octet_length(${table.updatedBySubjectId}) between 1 and 1024`
17372
+ )
17373
+ })
17374
+ );
17375
+ var organizationModelProviderConnectionOperations = pgTable19(
17376
+ "organization_model_provider_connection_operations",
17377
+ {
17378
+ id: uuid19("id").primaryKey().defaultRandom(),
17379
+ accountId: uuid19("account_id").notNull().references(() => managedAccounts.id, { onDelete: "cascade" }),
17380
+ providerKind: text19("provider_kind").$type().notNull(),
17381
+ operationId: uuid19("operation_id").notNull(),
17382
+ requestHash: text19("request_hash").notNull(),
17383
+ resultStatus: text19("result_status").$type().notNull(),
17384
+ resultVersion: integer18("result_version").notNull(),
17385
+ resultCreatedAt: timestamp19("result_created_at", {
17386
+ withTimezone: true
17387
+ }).notNull(),
17388
+ resultUpdatedAt: timestamp19("result_updated_at", {
17389
+ withTimezone: true
17390
+ }).notNull(),
17391
+ createdAt: timestamp19("created_at", { withTimezone: true }).notNull().defaultNow()
17392
+ },
17393
+ (table) => ({
17394
+ operation: uniqueIndex19("organization_model_provider_connection_operations_operation_uq").on(
17395
+ table.accountId,
17396
+ table.providerKind,
17397
+ table.operationId
17398
+ ),
17399
+ providerKindCheck: check11(
17400
+ "organization_model_provider_connection_operations_provider_kind_chk",
17401
+ sql16`${table.providerKind} in ('vercel_gateway', 'openrouter')`
17402
+ ),
17403
+ resultStatusCheck: check11(
17404
+ "organization_model_provider_connection_operations_result_status_chk",
17405
+ sql16`${table.resultStatus} in ('active', 'revoked')`
17406
+ ),
17407
+ resultVersionCheck: check11(
17408
+ "organization_model_provider_connection_operations_result_version_chk",
17409
+ sql16`${table.resultVersion} > 0`
17410
+ ),
17411
+ requestHashCheck: check11(
17412
+ "organization_model_provider_connection_operations_request_hash_chk",
17413
+ sql16`${table.requestHash} ~ '^[a-f0-9]{64}$'`
17414
+ )
17415
+ })
17416
+ );
17417
+ var organizationModelProviderCustomModels = pgTable19(
17418
+ "organization_model_provider_custom_models",
17419
+ {
17420
+ id: uuid19("id").primaryKey().defaultRandom(),
17421
+ accountId: uuid19("account_id").notNull().references(() => managedAccounts.id, { onDelete: "cascade" }),
17422
+ providerKind: text19("provider_kind").$type().notNull(),
17423
+ upstreamModelId: text19("upstream_model_id").notNull(),
17424
+ label: text19("label"),
17425
+ version: integer18("version").notNull().default(1),
17426
+ createOperationId: uuid19("create_operation_id").notNull(),
17427
+ createRequestHash: text19("create_request_hash").notNull(),
17428
+ deleteOperationId: uuid19("delete_operation_id"),
17429
+ deleteRequestHash: text19("delete_request_hash"),
17430
+ createdBySubjectId: text19("created_by_subject_id").notNull(),
17431
+ retiredAt: timestamp19("retired_at", { withTimezone: true }),
17432
+ createdAt: timestamp19("created_at", { withTimezone: true }).notNull().defaultNow(),
17433
+ updatedAt: timestamp19("updated_at", { withTimezone: true }).notNull().defaultNow()
17434
+ },
17435
+ (table) => ({
17436
+ accountUpstream: uniqueIndex19("organization_model_provider_custom_models_active_uq").on(table.accountId, table.providerKind, table.upstreamModelId).where(sql16`${table.retiredAt} is null`),
17437
+ createOperation: uniqueIndex19(
17438
+ "organization_model_provider_custom_models_create_operation_uq"
17439
+ ).on(table.accountId, table.providerKind, table.createOperationId),
17440
+ deleteOperation: uniqueIndex19("organization_model_provider_custom_models_delete_operation_uq").on(table.accountId, table.providerKind, table.deleteOperationId).where(sql16`${table.deleteOperationId} is not null`),
17441
+ providerKindCheck: check11(
17442
+ "organization_model_provider_custom_models_provider_kind_chk",
17443
+ sql16`${table.providerKind} in ('vercel_gateway', 'openrouter')`
17444
+ ),
17445
+ upstreamCheck: check11(
17446
+ "organization_model_provider_custom_models_upstream_chk",
17447
+ sql16`octet_length(${table.upstreamModelId}) between 1 and 238 and ${table.upstreamModelId} ~ '^[!-~]+$' and ${table.upstreamModelId} !~ '[|]'`
17448
+ ),
17449
+ labelCheck: check11(
17450
+ "organization_model_provider_custom_models_label_chk",
17451
+ sql16`${table.label} is null or (octet_length(${table.label}) between 1 and 128 and ${table.label} !~ '[\r\n|]')`
17452
+ ),
17453
+ versionCheck: check11(
17454
+ "organization_model_provider_custom_models_version_chk",
17455
+ sql16`${table.version} > 0`
17456
+ ),
17457
+ actorCheck: check11(
17458
+ "organization_model_provider_custom_models_actor_chk",
17459
+ sql16`octet_length(${table.createdBySubjectId}) between 1 and 1024`
17460
+ ),
17461
+ createHashCheck: check11(
17462
+ "organization_model_provider_custom_models_create_hash_chk",
17463
+ sql16`${table.createRequestHash} ~ '^[a-f0-9]{64}$'`
17464
+ ),
17465
+ deleteReceiptCheck: check11(
17466
+ "organization_model_provider_custom_models_delete_receipt_chk",
17467
+ 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)`
17468
+ )
17469
+ })
17470
+ );
17179
17471
 
17180
17472
  export {
17181
17473
  LOSSLESS_CONTENT_CODEC_VERSION,
@@ -17523,6 +17815,11 @@ export {
17523
17815
  rigs,
17524
17816
  rigVersions,
17525
17817
  rigChanges,
17818
+ deploymentModelCatalog,
17819
+ workspaceGatewayCustomModels,
17820
+ organizationModelProviderConnections,
17821
+ organizationModelProviderConnectionOperations,
17822
+ organizationModelProviderCustomModels,
17526
17823
  schema_exports
17527
17824
  };
17528
- //# sourceMappingURL=chunk-O56DM5GZ.js.map
17825
+ //# sourceMappingURL=chunk-53A2PEHT.js.map