@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.
- package/dist/automations.d.ts +4 -0
- package/dist/canonical-human-identities.js +3 -3
- package/dist/{chunk-O56DM5GZ.js → chunk-53A2PEHT.js} +328 -31
- package/dist/chunk-53A2PEHT.js.map +1 -0
- package/dist/{chunk-SZAWDXQC.js → chunk-5S4BQAHX.js} +3 -3
- package/dist/{chunk-S3TDDCS2.js → chunk-CITYUGMW.js} +3 -3
- package/dist/{chunk-4NAR7FBA.js → chunk-F5YOZEYQ.js} +49 -1
- package/dist/chunk-F5YOZEYQ.js.map +1 -0
- package/dist/{chunk-F6PBS6WE.js → chunk-HZV7O6JR.js} +2 -2
- package/dist/{chunk-5NNCGFQY.js → chunk-RLQVPOVR.js} +2 -2
- package/dist/{chunk-DZCYW2WT.js → chunk-UKOGHUGC.js} +2 -2
- package/dist/{chunk-US4IS6IV.js → chunk-X6TO5HII.js} +2 -2
- package/dist/{chunk-U4WPPEBH.js → chunk-Y53WEFYB.js} +2 -2
- package/dist/connection-token-resolver.d.ts +4 -0
- package/dist/editable-artifact-durable-export.js +2 -2
- package/dist/editable-artifacts.js +3 -3
- package/dist/index.d.ts +164 -14
- package/dist/index.js +7327 -5442
- package/dist/index.js.map +1 -1
- package/dist/insights.d.ts +9 -0
- package/dist/managed-auth-session-sets.js +3 -3
- package/dist/model-catalog.d.ts +153 -0
- package/dist/new-session-drafts.d.ts +12 -0
- package/dist/organization-membership-lifecycle.d.ts +8 -1
- package/dist/organization-model-providers.d.ts +101 -0
- package/dist/pack-components.d.ts +1 -0
- package/dist/pr-review.d.ts +9 -0
- package/dist/provision-roles.js +1 -1
- package/dist/runtime-posture.d.ts +7 -7
- package/dist/schema.d.ts +989 -2
- package/dist/schema.js +11 -1
- package/dist/session-background-commands.js +3 -3
- package/dist/session-control.d.ts +35 -0
- package/dist/session-queue-commands.d.ts +17 -0
- package/dist/session-tenancy.js +3 -3
- package/dist/video-generation.js +3 -3
- package/dist/xai-subscription.d.ts +8 -0
- package/drizzle/0387_bound_host_export_session_payloads.sql +165 -0
- package/drizzle/0388_sandbox_provider_deadline_interactions.sql +491 -0
- package/drizzle/0389_model_catalog_and_gateway_custom_models.sql +241 -0
- package/drizzle/0390_organization_model_provider_connections.sql +197 -0
- package/drizzle/0391_sandbox_provider_deadline_interaction_followup.sql +295 -0
- package/drizzle/0392_context_compaction_pending_observability.sql +198 -0
- package/drizzle/0393_workspace_memory_and_learning_defaults.sql +102 -0
- package/drizzle/0394_session_selected_skill_activation.sql +20 -0
- package/drizzle/0395_scheduled_task_unclaimed_occurrence_invalidation.sql +154 -0
- package/drizzle/0396_model_call_equivalent_credit_cost.sql +28 -0
- package/drizzle/0397_sandbox_deadline_rotation_preemption.sql +113 -0
- package/drizzle/0398_organization_workspace_management_entry.sql +206 -0
- package/drizzle/0399_additional_managed_organization_creation.sql +691 -0
- package/package.json +6 -6
- package/src/automations.ts +9 -1
- package/src/connection-token-resolver.ts +12 -0
- package/src/index.ts +1551 -272
- package/src/insights-model-bundle.ts +54 -5
- package/src/insights.ts +53 -7
- package/src/model-catalog.ts +682 -0
- package/src/new-session-drafts.ts +66 -21
- package/src/organization-membership-lifecycle.ts +47 -5
- package/src/organization-model-providers.ts +614 -0
- package/src/pack-components.ts +15 -2
- package/src/pr-review.ts +19 -0
- package/src/provision-roles.ts +2 -0
- package/src/runtime-posture.ts +48 -0
- package/src/schema.ts +348 -32
- package/src/session-control.ts +170 -0
- package/src/session-queue-commands.ts +157 -82
- package/src/xai-subscription.ts +66 -14
- package/dist/chunk-4NAR7FBA.js.map +0 -1
- package/dist/chunk-O56DM5GZ.js.map +0 -1
- /package/dist/{chunk-SZAWDXQC.js.map → chunk-5S4BQAHX.js.map} +0 -0
- /package/dist/{chunk-S3TDDCS2.js.map → chunk-CITYUGMW.js.map} +0 -0
- /package/dist/{chunk-F6PBS6WE.js.map → chunk-HZV7O6JR.js.map} +0 -0
- /package/dist/{chunk-5NNCGFQY.js.map → chunk-RLQVPOVR.js.map} +0 -0
- /package/dist/{chunk-DZCYW2WT.js.map → chunk-UKOGHUGC.js.map} +0 -0
- /package/dist/{chunk-US4IS6IV.js.map → chunk-X6TO5HII.js.map} +0 -0
- /package/dist/{chunk-U4WPPEBH.js.map → chunk-Y53WEFYB.js.map} +0 -0
package/src/schema.ts
CHANGED
|
@@ -110,9 +110,12 @@ export const workspaces = pgTable(
|
|
|
110
110
|
// White-label agent persona template override. NULL means the deployment
|
|
111
111
|
// default (OPENGENI_AGENT_INSTRUCTIONS_TEMPLATE / DEFAULT_AGENT_INSTRUCTIONS).
|
|
112
112
|
agentInstructions: text("agent_instructions"),
|
|
113
|
-
// Growth-ready per-workspace settings bag (migration 0045).
|
|
114
|
-
//
|
|
115
|
-
settings: jsonb("settings")
|
|
113
|
+
// Growth-ready per-workspace settings bag (migration 0045). Migration 0393
|
|
114
|
+
// makes Memory enabled by default; explicit false remains authoritative.
|
|
115
|
+
settings: jsonb("settings")
|
|
116
|
+
.$type<Record<string, unknown>>()
|
|
117
|
+
.notNull()
|
|
118
|
+
.default({ memoryEnabled: true }),
|
|
116
119
|
// The workspace's default rig (migration 0047). NULL ⇒ no default; sessions
|
|
117
120
|
// created without an explicit rig ride no rig (today's behavior exactly). FK
|
|
118
121
|
// (-> rigs(id) ON DELETE SET NULL) lives in migration 0047, not a Drizzle
|
|
@@ -524,8 +527,12 @@ export const organizationProfileEvents = pgTable(
|
|
|
524
527
|
actorMembershipId: uuid("actor_membership_id").notNull(),
|
|
525
528
|
previousName: text("previous_name").notNull(),
|
|
526
529
|
requestedName: text("requested_name").notNull(),
|
|
527
|
-
expectedUpdatedAt: timestamp("expected_updated_at", {
|
|
528
|
-
|
|
530
|
+
expectedUpdatedAt: timestamp("expected_updated_at", {
|
|
531
|
+
withTimezone: true,
|
|
532
|
+
}).notNull(),
|
|
533
|
+
resultUpdatedAt: timestamp("result_updated_at", {
|
|
534
|
+
withTimezone: true,
|
|
535
|
+
}).notNull(),
|
|
529
536
|
createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
530
537
|
},
|
|
531
538
|
(table) => ({
|
|
@@ -613,7 +620,9 @@ export const organizationPrivateSessionSettingEvents = pgTable(
|
|
|
613
620
|
expectedVersion: bigint("expected_version", { mode: "number" }).notNull(),
|
|
614
621
|
resultEnabled: boolean("result_enabled").notNull(),
|
|
615
622
|
resultVersion: bigint("result_version", { mode: "number" }).notNull(),
|
|
616
|
-
resultUpdatedAt: timestamp("result_updated_at", {
|
|
623
|
+
resultUpdatedAt: timestamp("result_updated_at", {
|
|
624
|
+
withTimezone: true,
|
|
625
|
+
}).notNull(),
|
|
617
626
|
changed: boolean("changed").notNull(),
|
|
618
627
|
createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
619
628
|
},
|
|
@@ -751,7 +760,9 @@ export const organizationInvitationBindingEvents = pgTable(
|
|
|
751
760
|
.references(() => managedAccounts.id, { onDelete: "cascade" }),
|
|
752
761
|
invitationId: uuid("invitation_id").notNull(),
|
|
753
762
|
targetSubjectId: text("target_subject_id").notNull(),
|
|
754
|
-
resultingRevision: bigint("resulting_revision", {
|
|
763
|
+
resultingRevision: bigint("resulting_revision", {
|
|
764
|
+
mode: "number",
|
|
765
|
+
}).notNull(),
|
|
755
766
|
boundAt: timestamp("bound_at", { withTimezone: true }).notNull().defaultNow(),
|
|
756
767
|
},
|
|
757
768
|
(table) => ({
|
|
@@ -854,13 +865,19 @@ export const organizationUserRetentionDeletions = pgTable(
|
|
|
854
865
|
.notNull()
|
|
855
866
|
.references(() => managedAccounts.id, { onDelete: "cascade" }),
|
|
856
867
|
membershipId: uuid("membership_id").notNull(),
|
|
857
|
-
retentionUntil: timestamp("retention_until", {
|
|
868
|
+
retentionUntil: timestamp("retention_until", {
|
|
869
|
+
withTimezone: true,
|
|
870
|
+
}).notNull(),
|
|
858
871
|
state: text("state").notNull().default("claimed"),
|
|
859
872
|
claimOperationId: uuid("claim_operation_id").notNull(),
|
|
860
|
-
claimExpiresAt: timestamp("claim_expires_at", {
|
|
873
|
+
claimExpiresAt: timestamp("claim_expires_at", {
|
|
874
|
+
withTimezone: true,
|
|
875
|
+
}).notNull(),
|
|
861
876
|
attemptCount: integer("attempt_count").notNull().default(1),
|
|
862
877
|
databaseResult: jsonb("database_result").$type<Record<string, unknown>>(),
|
|
863
|
-
databaseFinalizedAt: timestamp("database_finalized_at", {
|
|
878
|
+
databaseFinalizedAt: timestamp("database_finalized_at", {
|
|
879
|
+
withTimezone: true,
|
|
880
|
+
}),
|
|
864
881
|
result: jsonb("result").$type<Record<string, unknown>>(),
|
|
865
882
|
completedAt: timestamp("completed_at", { withTimezone: true }),
|
|
866
883
|
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow(),
|
|
@@ -1262,7 +1279,9 @@ export const codexSubscriptionCredentials = pgTable(
|
|
|
1262
1279
|
accountId: uuid("account_id")
|
|
1263
1280
|
.notNull()
|
|
1264
1281
|
.references(() => managedAccounts.id, { onDelete: "cascade" }),
|
|
1265
|
-
workspaceId: uuid("workspace_id").references(() => workspaces.id, {
|
|
1282
|
+
workspaceId: uuid("workspace_id").references(() => workspaces.id, {
|
|
1283
|
+
onDelete: "cascade",
|
|
1284
|
+
}),
|
|
1266
1285
|
organizationId: uuid("organization_id").references(() => managedAccounts.id, {
|
|
1267
1286
|
onDelete: "cascade",
|
|
1268
1287
|
}),
|
|
@@ -1836,7 +1855,9 @@ export const connectionUseOnceConsumptionReceipts = pgTable(
|
|
|
1836
1855
|
.notNull()
|
|
1837
1856
|
.references(() => managedAccounts.id, { onDelete: "cascade" }),
|
|
1838
1857
|
authorityId: uuid("authority_id").notNull(),
|
|
1839
|
-
authorityGeneration: bigint("authority_generation", {
|
|
1858
|
+
authorityGeneration: bigint("authority_generation", {
|
|
1859
|
+
mode: "number",
|
|
1860
|
+
}).notNull(),
|
|
1840
1861
|
grantGeneration: bigint("grant_generation", { mode: "number" }).notNull(),
|
|
1841
1862
|
acceptedWorkKind: text("accepted_work_kind").notNull(),
|
|
1842
1863
|
acceptedWorkId: uuid("accepted_work_id").notNull(),
|
|
@@ -2621,7 +2642,9 @@ export const slackInteractionInbox = pgTable(
|
|
|
2621
2642
|
targetAccountId: uuid("target_account_id"),
|
|
2622
2643
|
targetWorkspaceId: uuid("target_workspace_id"),
|
|
2623
2644
|
routePromptId: uuid("route_prompt_id"),
|
|
2624
|
-
routePromptExpiresAt: timestamp("route_prompt_expires_at", {
|
|
2645
|
+
routePromptExpiresAt: timestamp("route_prompt_expires_at", {
|
|
2646
|
+
withTimezone: true,
|
|
2647
|
+
}),
|
|
2625
2648
|
processedAt: timestamp("processed_at", { withTimezone: true }),
|
|
2626
2649
|
createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
2627
2650
|
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow(),
|
|
@@ -6185,7 +6208,9 @@ export const turnPersonalResourceSnapshots = pgTable(
|
|
|
6185
6208
|
mode: "number",
|
|
6186
6209
|
}).notNull(),
|
|
6187
6210
|
authorityId: uuid("authority_id").notNull(),
|
|
6188
|
-
authorityGeneration: bigint("authority_generation", {
|
|
6211
|
+
authorityGeneration: bigint("authority_generation", {
|
|
6212
|
+
mode: "number",
|
|
6213
|
+
}).notNull(),
|
|
6189
6214
|
grantId: uuid("grant_id").notNull(),
|
|
6190
6215
|
grantGeneration: bigint("grant_generation", { mode: "number" }).notNull(),
|
|
6191
6216
|
grantMode: text("grant_mode").notNull(),
|
|
@@ -6197,7 +6222,9 @@ export const turnPersonalResourceSnapshots = pgTable(
|
|
|
6197
6222
|
createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
6198
6223
|
},
|
|
6199
6224
|
(table) => ({
|
|
6200
|
-
pk: primaryKey({
|
|
6225
|
+
pk: primaryKey({
|
|
6226
|
+
columns: [table.turnId, table.resourceKind, table.resourceId],
|
|
6227
|
+
}),
|
|
6201
6228
|
receipt: foreignKey({
|
|
6202
6229
|
name: "turn_personal_resource_snapshots_receipt_fk",
|
|
6203
6230
|
columns: [table.turnId],
|
|
@@ -6246,7 +6273,9 @@ export const turnPersonalResourceOnceReceipts = pgTable(
|
|
|
6246
6273
|
turnId: uuid("turn_id").notNull(),
|
|
6247
6274
|
accountId: uuid("account_id").notNull(),
|
|
6248
6275
|
authorityId: uuid("authority_id").notNull(),
|
|
6249
|
-
authorityGeneration: bigint("authority_generation", {
|
|
6276
|
+
authorityGeneration: bigint("authority_generation", {
|
|
6277
|
+
mode: "number",
|
|
6278
|
+
}).notNull(),
|
|
6250
6279
|
grantGeneration: bigint("grant_generation", { mode: "number" }).notNull(),
|
|
6251
6280
|
consumedAt: timestamp("consumed_at", { withTimezone: true }).notNull().defaultNow(),
|
|
6252
6281
|
},
|
|
@@ -6541,7 +6570,9 @@ export const turnConnectionAuthoritySnapshots = pgTable(
|
|
|
6541
6570
|
turnId: uuid("turn_id").notNull(),
|
|
6542
6571
|
serverId: text("server_id").notNull(),
|
|
6543
6572
|
connectionId: uuid("connection_id").notNull(),
|
|
6544
|
-
connectionGeneration: bigint("connection_generation", {
|
|
6573
|
+
connectionGeneration: bigint("connection_generation", {
|
|
6574
|
+
mode: "number",
|
|
6575
|
+
}).notNull(),
|
|
6545
6576
|
originWorkspaceId: uuid("origin_workspace_id").notNull(),
|
|
6546
6577
|
providerDomain: text("provider_domain").notNull(),
|
|
6547
6578
|
connectionKind: text("connection_kind").notNull(),
|
|
@@ -7080,6 +7111,15 @@ export const sessionCommandReceipts = pgTable(
|
|
|
7080
7111
|
table.targetSessionId,
|
|
7081
7112
|
table.createdAt,
|
|
7082
7113
|
),
|
|
7114
|
+
promptActorOperation: index("session_command_receipts_prompt_actor_operation_idx")
|
|
7115
|
+
.on(
|
|
7116
|
+
table.workspaceId,
|
|
7117
|
+
table.actorType,
|
|
7118
|
+
table.actorSubjectId,
|
|
7119
|
+
table.actorAttemptId,
|
|
7120
|
+
table.operationKey,
|
|
7121
|
+
)
|
|
7122
|
+
.where(sql`${table.action} in ('prompt.send', 'prompt.steer')`),
|
|
7083
7123
|
goalUpdateOperation: uniqueIndex("session_command_receipts_goal_update_operation_uq")
|
|
7084
7124
|
.on(table.workspaceId, table.action, table.targetSessionId, table.operationKey)
|
|
7085
7125
|
.where(sql`${table.action} = 'goal.update'`),
|
|
@@ -7575,9 +7615,13 @@ export const sessionGoals = pgTable(
|
|
|
7575
7615
|
// Any newer finished turn, a passed deadline, or a goal mutation clears all
|
|
7576
7616
|
// four columns together.
|
|
7577
7617
|
continuationHoldTurnId: uuid("continuation_hold_turn_id"),
|
|
7578
|
-
continuationHoldUntil: timestamp("continuation_hold_until", {
|
|
7618
|
+
continuationHoldUntil: timestamp("continuation_hold_until", {
|
|
7619
|
+
withTimezone: true,
|
|
7620
|
+
}),
|
|
7579
7621
|
continuationHoldReason: text("continuation_hold_reason"),
|
|
7580
|
-
continuationHoldSetAt: timestamp("continuation_hold_set_at", {
|
|
7622
|
+
continuationHoldSetAt: timestamp("continuation_hold_set_at", {
|
|
7623
|
+
withTimezone: true,
|
|
7624
|
+
}),
|
|
7581
7625
|
metadata: jsonb("metadata").$type<Record<string, unknown>>().notNull().default({}),
|
|
7582
7626
|
createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
7583
7627
|
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow(),
|
|
@@ -8852,7 +8896,9 @@ export const sandboxWorkspaceMutationAdmissions = pgTable(
|
|
|
8852
8896
|
// authorization revision observed at admission. The revision is audit
|
|
8853
8897
|
// evidence: a role change is not a revocation and must not fence a writer.
|
|
8854
8898
|
initiatorOrganizationMembershipId: uuid("initiator_organization_membership_id"),
|
|
8855
|
-
initiatorAuthorizationRevision: bigint("initiator_authorization_revision", {
|
|
8899
|
+
initiatorAuthorizationRevision: bigint("initiator_authorization_revision", {
|
|
8900
|
+
mode: "number",
|
|
8901
|
+
}),
|
|
8856
8902
|
// Session tenancy authority observed when the operation was admitted; the
|
|
8857
8903
|
// same triple `session_turn_attempts` freezes for a turn.
|
|
8858
8904
|
authorityEpoch: integer("authority_epoch"),
|
|
@@ -9074,7 +9120,9 @@ export const sandboxRetainedProcesses = pgTable(
|
|
|
9074
9120
|
initiatorSubjectId: text("initiator_subject_id").notNull().default("unattributed-legacy"),
|
|
9075
9121
|
initiatingHumanSubjectId: text("initiating_human_subject_id"),
|
|
9076
9122
|
initiatorOrganizationMembershipId: uuid("initiator_organization_membership_id"),
|
|
9077
|
-
initiatorAuthorizationRevision: bigint("initiator_authorization_revision", {
|
|
9123
|
+
initiatorAuthorizationRevision: bigint("initiator_authorization_revision", {
|
|
9124
|
+
mode: "number",
|
|
9125
|
+
}),
|
|
9078
9126
|
authorityEpoch: integer("authority_epoch"),
|
|
9079
9127
|
authorityVisibility: text("authority_visibility", {
|
|
9080
9128
|
enum: ["user_private", "workspace_shared"],
|
|
@@ -9333,7 +9381,9 @@ export const sessionBackgroundCommands = pgTable(
|
|
|
9333
9381
|
accountId: uuid("account_id").notNull(),
|
|
9334
9382
|
workspaceId: uuid("workspace_id").notNull(),
|
|
9335
9383
|
sessionId: uuid("session_id").notNull(),
|
|
9336
|
-
provider: text("provider", {
|
|
9384
|
+
provider: text("provider", {
|
|
9385
|
+
enum: ["managed", "connected_machine"],
|
|
9386
|
+
}).notNull(),
|
|
9337
9387
|
state: text("state", { enum: ["running", "stopping", "exited", "lost"] })
|
|
9338
9388
|
.notNull()
|
|
9339
9389
|
.default("running"),
|
|
@@ -9351,13 +9401,19 @@ export const sessionBackgroundCommands = pgTable(
|
|
|
9351
9401
|
settledAt: timestamp("settled_at", { withTimezone: true }),
|
|
9352
9402
|
reconcileAfter: timestamp("reconcile_after", { withTimezone: true }).notNull().defaultNow(),
|
|
9353
9403
|
reconcileClaimId: uuid("reconcile_claim_id"),
|
|
9354
|
-
reconcileClaimedAt: timestamp("reconcile_claimed_at", {
|
|
9404
|
+
reconcileClaimedAt: timestamp("reconcile_claimed_at", {
|
|
9405
|
+
withTimezone: true,
|
|
9406
|
+
}),
|
|
9355
9407
|
reconcileAttempts: integer("reconcile_attempts").notNull().default(0),
|
|
9356
9408
|
lastReconcileOutcome: text("last_reconcile_outcome"),
|
|
9357
|
-
reconcileProofOutcome: text("reconcile_proof_outcome", {
|
|
9409
|
+
reconcileProofOutcome: text("reconcile_proof_outcome", {
|
|
9410
|
+
enum: ["exited", "lost"],
|
|
9411
|
+
}),
|
|
9358
9412
|
reconcileProofExitCode: integer("reconcile_proof_exit_code"),
|
|
9359
9413
|
reconcileProofReason: text("reconcile_proof_reason"),
|
|
9360
|
-
reconcileProofObservedAt: timestamp("reconcile_proof_observed_at", {
|
|
9414
|
+
reconcileProofObservedAt: timestamp("reconcile_proof_observed_at", {
|
|
9415
|
+
withTimezone: true,
|
|
9416
|
+
}),
|
|
9361
9417
|
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow(),
|
|
9362
9418
|
},
|
|
9363
9419
|
(table) => ({
|
|
@@ -10597,12 +10653,18 @@ export const prReviewAppRegistrations = pgTable(
|
|
|
10597
10653
|
providerAccountType: text("provider_account_type"),
|
|
10598
10654
|
githubActorId: text("github_actor_id"),
|
|
10599
10655
|
authorityKind: text("authority_kind"),
|
|
10600
|
-
authorityCheckedAt: timestamp("authority_checked_at", {
|
|
10601
|
-
|
|
10656
|
+
authorityCheckedAt: timestamp("authority_checked_at", {
|
|
10657
|
+
withTimezone: true,
|
|
10658
|
+
}),
|
|
10659
|
+
authorityExpiresAt: timestamp("authority_expires_at", {
|
|
10660
|
+
withTimezone: true,
|
|
10661
|
+
}),
|
|
10602
10662
|
authorityNonce: text("authority_nonce"),
|
|
10603
10663
|
credentialKind: text("credential_kind").notNull(),
|
|
10604
10664
|
credentialEncrypted: text("credential_encrypted"),
|
|
10605
|
-
accessTokenExpiresAt: timestamp("access_token_expires_at", {
|
|
10665
|
+
accessTokenExpiresAt: timestamp("access_token_expires_at", {
|
|
10666
|
+
withTimezone: true,
|
|
10667
|
+
}),
|
|
10606
10668
|
webhookAuthKind: text("webhook_auth_kind").notNull(),
|
|
10607
10669
|
webhookUsername: text("webhook_username"),
|
|
10608
10670
|
status: text("status").notNull().default("active"),
|
|
@@ -10748,7 +10810,9 @@ export const prReviewManagedGithubAuthorityNonces = pgTable(
|
|
|
10748
10810
|
.notNull()
|
|
10749
10811
|
.references(() => workspaces.id, { onDelete: "cascade" }),
|
|
10750
10812
|
installationId: text("installation_id").notNull(),
|
|
10751
|
-
authorityExpiresAt: timestamp("authority_expires_at", {
|
|
10813
|
+
authorityExpiresAt: timestamp("authority_expires_at", {
|
|
10814
|
+
withTimezone: true,
|
|
10815
|
+
}).notNull(),
|
|
10752
10816
|
consumedAt: timestamp("consumed_at", { withTimezone: true }).notNull().defaultNow(),
|
|
10753
10817
|
},
|
|
10754
10818
|
(table) => ({
|
|
@@ -10930,6 +10994,9 @@ export const modelCallFacts = pgTable(
|
|
|
10930
10994
|
estimatedProviderCostMicros: bigint("estimated_provider_cost_micros", {
|
|
10931
10995
|
mode: "number",
|
|
10932
10996
|
}),
|
|
10997
|
+
equivalentCreditCostMicros: bigint("equivalent_credit_cost_micros", {
|
|
10998
|
+
mode: "number",
|
|
10999
|
+
}),
|
|
10933
11000
|
pricingSource: text("pricing_source"),
|
|
10934
11001
|
contextContributions:
|
|
10935
11002
|
jsonb("context_contributions").$type<readonly ModelContextContributionSummary[]>(),
|
|
@@ -10974,6 +11041,10 @@ export const modelCallFacts = pgTable(
|
|
|
10974
11041
|
"model_call_facts_estimated_provider_cost_check",
|
|
10975
11042
|
sql`${table.estimatedProviderCostMicros} is null or ${table.estimatedProviderCostMicros} >= 0`,
|
|
10976
11043
|
),
|
|
11044
|
+
equivalentCreditCostValid: check(
|
|
11045
|
+
"model_call_facts_equivalent_credit_cost_check",
|
|
11046
|
+
sql`${table.equivalentCreditCostMicros} is null or (${table.equivalentCreditCostMicros} >= 0 and ${table.estimatedProviderCostMicros} is not null)`,
|
|
11047
|
+
),
|
|
10977
11048
|
pricingSourceValid: check(
|
|
10978
11049
|
"model_call_facts_pricing_source_check",
|
|
10979
11050
|
sql`(${table.estimatedProviderCostMicros} is null and ${table.pricingSource} is null)
|
|
@@ -11027,8 +11098,9 @@ export const hostExportConfig = pgTable(
|
|
|
11027
11098
|
/**
|
|
11028
11099
|
* Transactional delivery buffer. It intentionally has no tenant/source FKs:
|
|
11029
11100
|
* a workspace deletion must not erase an already-committed, unacknowledged
|
|
11030
|
-
* host fact. Session-event
|
|
11031
|
-
*
|
|
11101
|
+
* host fact. Session-event rows retain exact storage bytes while they fit the
|
|
11102
|
+
* bounded host wire; larger canonical events carry an explicit content-free
|
|
11103
|
+
* projection plus literal-JSON codec truth. Usage payloads remain ordinary JSON.
|
|
11032
11104
|
*/
|
|
11033
11105
|
export const hostExportOutbox = pgTable(
|
|
11034
11106
|
"host_export_outbox",
|
|
@@ -11624,7 +11696,9 @@ export const automationRuns = pgTable(
|
|
|
11624
11696
|
occurrenceKey: text("occurrence_key").notNull(),
|
|
11625
11697
|
acceptedExecution: jsonb("accepted_execution").$type<AutomationAcceptedExecution>().notNull(),
|
|
11626
11698
|
status: text("status").notNull().default("queued"),
|
|
11627
|
-
sessionId: uuid("session_id").references(() => sessions.id, {
|
|
11699
|
+
sessionId: uuid("session_id").references(() => sessions.id, {
|
|
11700
|
+
onDelete: "set null",
|
|
11701
|
+
}),
|
|
11628
11702
|
errorCode: text("error_code"),
|
|
11629
11703
|
createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
11630
11704
|
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow(),
|
|
@@ -12628,6 +12702,248 @@ export const rigChanges = pgTable(
|
|
|
12628
12702
|
}),
|
|
12629
12703
|
);
|
|
12630
12704
|
|
|
12705
|
+
export const deploymentModelCatalog = pgTable(
|
|
12706
|
+
"deployment_model_catalog",
|
|
12707
|
+
{
|
|
12708
|
+
singleton: boolean("singleton").primaryKey().notNull().default(true),
|
|
12709
|
+
document: jsonb("document").$type<unknown>().notNull(),
|
|
12710
|
+
version: bigint("version", { mode: "number" }).notNull().default(1),
|
|
12711
|
+
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow(),
|
|
12712
|
+
},
|
|
12713
|
+
(table) => ({
|
|
12714
|
+
singletonCheck: check("deployment_model_catalog_singleton_chk", sql`${table.singleton}`),
|
|
12715
|
+
documentCheck: check(
|
|
12716
|
+
"deployment_model_catalog_document_chk",
|
|
12717
|
+
sql`jsonb_typeof(${table.document}) = 'object'`,
|
|
12718
|
+
),
|
|
12719
|
+
versionCheck: check("deployment_model_catalog_version_chk", sql`${table.version} > 0`),
|
|
12720
|
+
}),
|
|
12721
|
+
);
|
|
12722
|
+
|
|
12723
|
+
export const workspaceGatewayCustomModels = pgTable(
|
|
12724
|
+
"workspace_gateway_custom_models",
|
|
12725
|
+
{
|
|
12726
|
+
id: uuid("id").primaryKey().defaultRandom(),
|
|
12727
|
+
accountId: uuid("account_id")
|
|
12728
|
+
.notNull()
|
|
12729
|
+
.references(() => managedAccounts.id, { onDelete: "cascade" }),
|
|
12730
|
+
workspaceId: uuid("workspace_id")
|
|
12731
|
+
.notNull()
|
|
12732
|
+
.references(() => workspaces.id, { onDelete: "cascade" }),
|
|
12733
|
+
providerKind: text("provider_kind").$type<"vercel_gateway" | "openrouter">().notNull(),
|
|
12734
|
+
upstreamModelId: text("upstream_model_id").notNull(),
|
|
12735
|
+
label: text("label"),
|
|
12736
|
+
version: integer("version").notNull().default(1),
|
|
12737
|
+
createOperationId: uuid("create_operation_id").notNull(),
|
|
12738
|
+
createRequestHash: text("create_request_hash").notNull(),
|
|
12739
|
+
deleteOperationId: uuid("delete_operation_id"),
|
|
12740
|
+
deleteRequestHash: text("delete_request_hash"),
|
|
12741
|
+
createdBySubjectId: text("created_by_subject_id").notNull(),
|
|
12742
|
+
retiredAt: timestamp("retired_at", { withTimezone: true }),
|
|
12743
|
+
createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
12744
|
+
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow(),
|
|
12745
|
+
},
|
|
12746
|
+
(table) => ({
|
|
12747
|
+
workspaceAccountFk: foreignKey({
|
|
12748
|
+
name: "workspace_gateway_custom_models_workspace_account_fk",
|
|
12749
|
+
columns: [table.workspaceId, table.accountId],
|
|
12750
|
+
foreignColumns: [workspaces.id, workspaces.accountId],
|
|
12751
|
+
}).onDelete("cascade"),
|
|
12752
|
+
workspaceUpstream: uniqueIndex("workspace_gateway_custom_models_workspace_upstream_uq")
|
|
12753
|
+
.on(table.workspaceId, table.providerKind, table.upstreamModelId)
|
|
12754
|
+
.where(sql`${table.retiredAt} is null`),
|
|
12755
|
+
createOperation: uniqueIndex("workspace_gateway_custom_models_create_operation_uq").on(
|
|
12756
|
+
table.workspaceId,
|
|
12757
|
+
table.providerKind,
|
|
12758
|
+
table.createOperationId,
|
|
12759
|
+
),
|
|
12760
|
+
deleteOperation: uniqueIndex("workspace_gateway_custom_models_delete_operation_uq")
|
|
12761
|
+
.on(table.workspaceId, table.providerKind, table.deleteOperationId)
|
|
12762
|
+
.where(sql`${table.deleteOperationId} is not null`),
|
|
12763
|
+
providerKindCheck: check(
|
|
12764
|
+
"workspace_gateway_custom_models_provider_kind_chk",
|
|
12765
|
+
sql`${table.providerKind} in ('vercel_gateway', 'openrouter')`,
|
|
12766
|
+
),
|
|
12767
|
+
upstreamCheck: check(
|
|
12768
|
+
"workspace_gateway_custom_models_upstream_chk",
|
|
12769
|
+
sql`octet_length(${table.upstreamModelId}) between 1 and 238 and ${table.upstreamModelId} ~ '^[!-~]+$' and ${table.upstreamModelId} !~ '[|]'`,
|
|
12770
|
+
),
|
|
12771
|
+
labelCheck: check(
|
|
12772
|
+
"workspace_gateway_custom_models_label_chk",
|
|
12773
|
+
sql`${table.label} is null or (octet_length(${table.label}) between 1 and 128 and ${table.label} !~ '[\r\n|]')`,
|
|
12774
|
+
),
|
|
12775
|
+
actorCheck: check(
|
|
12776
|
+
"workspace_gateway_custom_models_actor_chk",
|
|
12777
|
+
sql`octet_length(${table.createdBySubjectId}) between 1 and 1024`,
|
|
12778
|
+
),
|
|
12779
|
+
versionCheck: check("workspace_gateway_custom_models_version_chk", sql`${table.version} > 0`),
|
|
12780
|
+
createHashCheck: check(
|
|
12781
|
+
"workspace_gateway_custom_models_create_hash_chk",
|
|
12782
|
+
sql`${table.createRequestHash} ~ '^[a-f0-9]{64}$'`,
|
|
12783
|
+
),
|
|
12784
|
+
deleteReceiptCheck: check(
|
|
12785
|
+
"workspace_gateway_custom_models_delete_receipt_chk",
|
|
12786
|
+
sql`(${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)`,
|
|
12787
|
+
),
|
|
12788
|
+
}),
|
|
12789
|
+
);
|
|
12790
|
+
|
|
12791
|
+
export const organizationModelProviderConnections = pgTable(
|
|
12792
|
+
"organization_model_provider_connections",
|
|
12793
|
+
{
|
|
12794
|
+
id: uuid("id").primaryKey().defaultRandom(),
|
|
12795
|
+
accountId: uuid("account_id")
|
|
12796
|
+
.notNull()
|
|
12797
|
+
.references(() => managedAccounts.id, { onDelete: "cascade" }),
|
|
12798
|
+
providerKind: text("provider_kind").$type<"vercel_gateway" | "openrouter">().notNull(),
|
|
12799
|
+
status: text("status").$type<"active" | "revoked">().notNull().default("active"),
|
|
12800
|
+
credentialEncrypted: text("credential_encrypted").notNull(),
|
|
12801
|
+
version: integer("version").notNull().default(1),
|
|
12802
|
+
operationId: uuid("operation_id").notNull(),
|
|
12803
|
+
requestHash: text("request_hash").notNull(),
|
|
12804
|
+
updatedBySubjectId: text("updated_by_subject_id").notNull(),
|
|
12805
|
+
createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
12806
|
+
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow(),
|
|
12807
|
+
},
|
|
12808
|
+
(table) => ({
|
|
12809
|
+
accountProvider: uniqueIndex("organization_model_provider_connections_account_provider_uq").on(
|
|
12810
|
+
table.accountId,
|
|
12811
|
+
table.providerKind,
|
|
12812
|
+
),
|
|
12813
|
+
operation: uniqueIndex("organization_model_provider_connections_operation_uq").on(
|
|
12814
|
+
table.accountId,
|
|
12815
|
+
table.providerKind,
|
|
12816
|
+
table.operationId,
|
|
12817
|
+
),
|
|
12818
|
+
providerKindCheck: check(
|
|
12819
|
+
"organization_model_provider_connections_provider_kind_chk",
|
|
12820
|
+
sql`${table.providerKind} in ('vercel_gateway', 'openrouter')`,
|
|
12821
|
+
),
|
|
12822
|
+
statusCheck: check(
|
|
12823
|
+
"organization_model_provider_connections_status_chk",
|
|
12824
|
+
sql`${table.status} in ('active', 'revoked')`,
|
|
12825
|
+
),
|
|
12826
|
+
versionCheck: check(
|
|
12827
|
+
"organization_model_provider_connections_version_chk",
|
|
12828
|
+
sql`${table.version} > 0`,
|
|
12829
|
+
),
|
|
12830
|
+
requestHashCheck: check(
|
|
12831
|
+
"organization_model_provider_connections_request_hash_chk",
|
|
12832
|
+
sql`${table.requestHash} ~ '^[a-f0-9]{64}$'`,
|
|
12833
|
+
),
|
|
12834
|
+
actorCheck: check(
|
|
12835
|
+
"organization_model_provider_connections_actor_chk",
|
|
12836
|
+
sql`octet_length(${table.updatedBySubjectId}) between 1 and 1024`,
|
|
12837
|
+
),
|
|
12838
|
+
}),
|
|
12839
|
+
);
|
|
12840
|
+
|
|
12841
|
+
export const organizationModelProviderConnectionOperations = pgTable(
|
|
12842
|
+
"organization_model_provider_connection_operations",
|
|
12843
|
+
{
|
|
12844
|
+
id: uuid("id").primaryKey().defaultRandom(),
|
|
12845
|
+
accountId: uuid("account_id")
|
|
12846
|
+
.notNull()
|
|
12847
|
+
.references(() => managedAccounts.id, { onDelete: "cascade" }),
|
|
12848
|
+
providerKind: text("provider_kind").$type<"vercel_gateway" | "openrouter">().notNull(),
|
|
12849
|
+
operationId: uuid("operation_id").notNull(),
|
|
12850
|
+
requestHash: text("request_hash").notNull(),
|
|
12851
|
+
resultStatus: text("result_status").$type<"active" | "revoked">().notNull(),
|
|
12852
|
+
resultVersion: integer("result_version").notNull(),
|
|
12853
|
+
resultCreatedAt: timestamp("result_created_at", {
|
|
12854
|
+
withTimezone: true,
|
|
12855
|
+
}).notNull(),
|
|
12856
|
+
resultUpdatedAt: timestamp("result_updated_at", {
|
|
12857
|
+
withTimezone: true,
|
|
12858
|
+
}).notNull(),
|
|
12859
|
+
createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
12860
|
+
},
|
|
12861
|
+
(table) => ({
|
|
12862
|
+
operation: uniqueIndex("organization_model_provider_connection_operations_operation_uq").on(
|
|
12863
|
+
table.accountId,
|
|
12864
|
+
table.providerKind,
|
|
12865
|
+
table.operationId,
|
|
12866
|
+
),
|
|
12867
|
+
providerKindCheck: check(
|
|
12868
|
+
"organization_model_provider_connection_operations_provider_kind_chk",
|
|
12869
|
+
sql`${table.providerKind} in ('vercel_gateway', 'openrouter')`,
|
|
12870
|
+
),
|
|
12871
|
+
resultStatusCheck: check(
|
|
12872
|
+
"organization_model_provider_connection_operations_result_status_chk",
|
|
12873
|
+
sql`${table.resultStatus} in ('active', 'revoked')`,
|
|
12874
|
+
),
|
|
12875
|
+
resultVersionCheck: check(
|
|
12876
|
+
"organization_model_provider_connection_operations_result_version_chk",
|
|
12877
|
+
sql`${table.resultVersion} > 0`,
|
|
12878
|
+
),
|
|
12879
|
+
requestHashCheck: check(
|
|
12880
|
+
"organization_model_provider_connection_operations_request_hash_chk",
|
|
12881
|
+
sql`${table.requestHash} ~ '^[a-f0-9]{64}$'`,
|
|
12882
|
+
),
|
|
12883
|
+
}),
|
|
12884
|
+
);
|
|
12885
|
+
|
|
12886
|
+
export const organizationModelProviderCustomModels = pgTable(
|
|
12887
|
+
"organization_model_provider_custom_models",
|
|
12888
|
+
{
|
|
12889
|
+
id: uuid("id").primaryKey().defaultRandom(),
|
|
12890
|
+
accountId: uuid("account_id")
|
|
12891
|
+
.notNull()
|
|
12892
|
+
.references(() => managedAccounts.id, { onDelete: "cascade" }),
|
|
12893
|
+
providerKind: text("provider_kind").$type<"vercel_gateway" | "openrouter">().notNull(),
|
|
12894
|
+
upstreamModelId: text("upstream_model_id").notNull(),
|
|
12895
|
+
label: text("label"),
|
|
12896
|
+
version: integer("version").notNull().default(1),
|
|
12897
|
+
createOperationId: uuid("create_operation_id").notNull(),
|
|
12898
|
+
createRequestHash: text("create_request_hash").notNull(),
|
|
12899
|
+
deleteOperationId: uuid("delete_operation_id"),
|
|
12900
|
+
deleteRequestHash: text("delete_request_hash"),
|
|
12901
|
+
createdBySubjectId: text("created_by_subject_id").notNull(),
|
|
12902
|
+
retiredAt: timestamp("retired_at", { withTimezone: true }),
|
|
12903
|
+
createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
12904
|
+
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow(),
|
|
12905
|
+
},
|
|
12906
|
+
(table) => ({
|
|
12907
|
+
accountUpstream: uniqueIndex("organization_model_provider_custom_models_active_uq")
|
|
12908
|
+
.on(table.accountId, table.providerKind, table.upstreamModelId)
|
|
12909
|
+
.where(sql`${table.retiredAt} is null`),
|
|
12910
|
+
createOperation: uniqueIndex(
|
|
12911
|
+
"organization_model_provider_custom_models_create_operation_uq",
|
|
12912
|
+
).on(table.accountId, table.providerKind, table.createOperationId),
|
|
12913
|
+
deleteOperation: uniqueIndex("organization_model_provider_custom_models_delete_operation_uq")
|
|
12914
|
+
.on(table.accountId, table.providerKind, table.deleteOperationId)
|
|
12915
|
+
.where(sql`${table.deleteOperationId} is not null`),
|
|
12916
|
+
providerKindCheck: check(
|
|
12917
|
+
"organization_model_provider_custom_models_provider_kind_chk",
|
|
12918
|
+
sql`${table.providerKind} in ('vercel_gateway', 'openrouter')`,
|
|
12919
|
+
),
|
|
12920
|
+
upstreamCheck: check(
|
|
12921
|
+
"organization_model_provider_custom_models_upstream_chk",
|
|
12922
|
+
sql`octet_length(${table.upstreamModelId}) between 1 and 238 and ${table.upstreamModelId} ~ '^[!-~]+$' and ${table.upstreamModelId} !~ '[|]'`,
|
|
12923
|
+
),
|
|
12924
|
+
labelCheck: check(
|
|
12925
|
+
"organization_model_provider_custom_models_label_chk",
|
|
12926
|
+
sql`${table.label} is null or (octet_length(${table.label}) between 1 and 128 and ${table.label} !~ '[\r\n|]')`,
|
|
12927
|
+
),
|
|
12928
|
+
versionCheck: check(
|
|
12929
|
+
"organization_model_provider_custom_models_version_chk",
|
|
12930
|
+
sql`${table.version} > 0`,
|
|
12931
|
+
),
|
|
12932
|
+
actorCheck: check(
|
|
12933
|
+
"organization_model_provider_custom_models_actor_chk",
|
|
12934
|
+
sql`octet_length(${table.createdBySubjectId}) between 1 and 1024`,
|
|
12935
|
+
),
|
|
12936
|
+
createHashCheck: check(
|
|
12937
|
+
"organization_model_provider_custom_models_create_hash_chk",
|
|
12938
|
+
sql`${table.createRequestHash} ~ '^[a-f0-9]{64}$'`,
|
|
12939
|
+
),
|
|
12940
|
+
deleteReceiptCheck: check(
|
|
12941
|
+
"organization_model_provider_custom_models_delete_receipt_chk",
|
|
12942
|
+
sql`(${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)`,
|
|
12943
|
+
),
|
|
12944
|
+
}),
|
|
12945
|
+
);
|
|
12946
|
+
|
|
12631
12947
|
export * from "./workspace-instruction-policies-schema";
|
|
12632
12948
|
export * from "./company-profile-schema";
|
|
12633
12949
|
export * from "./workspace-learning-policy-schema";
|