@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
|
@@ -357,23 +357,10 @@ export async function rememberNewSessionSelectionInTransaction(
|
|
|
357
357
|
return Boolean(updated);
|
|
358
358
|
}
|
|
359
359
|
|
|
360
|
-
|
|
361
|
-
* Replace one exact accepted draft with the next-create safe seed. The row is
|
|
362
|
-
* identity-serialized before the revision check so even the absent-row
|
|
363
|
-
* revision-zero case cannot race a first save. Exact create callers receive a
|
|
364
|
-
* typed conflict; legacy revision-only callers retain the old false/no-op
|
|
365
|
-
* result. A missing row is an idempotent no-op.
|
|
366
|
-
*/
|
|
367
|
-
export async function seedNewSessionDraftInTransaction(
|
|
360
|
+
async function lockCurrentNewSessionDraft(
|
|
368
361
|
db: Database,
|
|
369
|
-
input: {
|
|
370
|
-
|
|
371
|
-
subjectId: string;
|
|
372
|
-
expectedRevision: number;
|
|
373
|
-
expectedSnapshot?: NewSessionDraftSnapshot;
|
|
374
|
-
acceptedSelection?: AcceptedNewSessionSelection;
|
|
375
|
-
},
|
|
376
|
-
): Promise<boolean> {
|
|
362
|
+
input: { workspaceId: string; subjectId: string },
|
|
363
|
+
): Promise<NewSessionDraftRow | undefined> {
|
|
377
364
|
await lockNewSessionDraftIdentity(db, input.workspaceId, input.subjectId);
|
|
378
365
|
const [current] = await db
|
|
379
366
|
.select()
|
|
@@ -386,14 +373,23 @@ export async function seedNewSessionDraftInTransaction(
|
|
|
386
373
|
)
|
|
387
374
|
.for("update")
|
|
388
375
|
.limit(1);
|
|
376
|
+
return current;
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
async function lockExactNewSessionDraft(
|
|
380
|
+
db: Database,
|
|
381
|
+
input: {
|
|
382
|
+
workspaceId: string;
|
|
383
|
+
subjectId: string;
|
|
384
|
+
expectedRevision: number;
|
|
385
|
+
expectedSnapshot: NewSessionDraftSnapshot;
|
|
386
|
+
},
|
|
387
|
+
): Promise<NewSessionDraftRow> {
|
|
388
|
+
const current = await lockCurrentNewSessionDraft(db, input);
|
|
389
389
|
if (!current || current.revision !== input.expectedRevision) {
|
|
390
|
-
|
|
391
|
-
throw new NewSessionDraftConflictError(current?.revision ?? 0);
|
|
392
|
-
}
|
|
393
|
-
return false;
|
|
390
|
+
throw new NewSessionDraftConflictError(current?.revision ?? 0);
|
|
394
391
|
}
|
|
395
392
|
if (
|
|
396
|
-
input.expectedSnapshot &&
|
|
397
393
|
stableJson({
|
|
398
394
|
text: current.text,
|
|
399
395
|
resources: current.resources,
|
|
@@ -407,6 +403,55 @@ export async function seedNewSessionDraftInTransaction(
|
|
|
407
403
|
) {
|
|
408
404
|
throw new NewSessionDraftConflictError(current.revision);
|
|
409
405
|
}
|
|
406
|
+
return current;
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
/**
|
|
410
|
+
* Fence a fresh session shell on the exact actor-private draft it represents.
|
|
411
|
+
* The caller keeps this row lock through its create transaction, so a draft
|
|
412
|
+
* that was already stale cannot leave a committed, uninitialized session.
|
|
413
|
+
* The later atomic initializer still performs the authoritative consume.
|
|
414
|
+
*/
|
|
415
|
+
export async function assertExactNewSessionDraftInTransaction(
|
|
416
|
+
db: Database,
|
|
417
|
+
input: {
|
|
418
|
+
workspaceId: string;
|
|
419
|
+
subjectId: string;
|
|
420
|
+
expectedRevision: number;
|
|
421
|
+
expectedSnapshot: NewSessionDraftSnapshot;
|
|
422
|
+
},
|
|
423
|
+
): Promise<void> {
|
|
424
|
+
await lockExactNewSessionDraft(db, input);
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
/**
|
|
428
|
+
* Replace one exact accepted draft with the next-create safe seed. The row is
|
|
429
|
+
* identity-serialized before the revision check so even the absent-row
|
|
430
|
+
* revision-zero case cannot race a first save. Exact create callers receive a
|
|
431
|
+
* typed conflict; legacy revision-only callers retain the old false/no-op
|
|
432
|
+
* result. A missing row is an idempotent no-op.
|
|
433
|
+
*/
|
|
434
|
+
export async function seedNewSessionDraftInTransaction(
|
|
435
|
+
db: Database,
|
|
436
|
+
input: {
|
|
437
|
+
workspaceId: string;
|
|
438
|
+
subjectId: string;
|
|
439
|
+
expectedRevision: number;
|
|
440
|
+
expectedSnapshot?: NewSessionDraftSnapshot;
|
|
441
|
+
acceptedSelection?: AcceptedNewSessionSelection;
|
|
442
|
+
},
|
|
443
|
+
): Promise<boolean> {
|
|
444
|
+
const current = input.expectedSnapshot
|
|
445
|
+
? await lockExactNewSessionDraft(db, {
|
|
446
|
+
workspaceId: input.workspaceId,
|
|
447
|
+
subjectId: input.subjectId,
|
|
448
|
+
expectedRevision: input.expectedRevision,
|
|
449
|
+
expectedSnapshot: input.expectedSnapshot,
|
|
450
|
+
})
|
|
451
|
+
: await lockCurrentNewSessionDraft(db, input);
|
|
452
|
+
if (!current || current.revision !== input.expectedRevision) {
|
|
453
|
+
return false;
|
|
454
|
+
}
|
|
410
455
|
|
|
411
456
|
const parsedOptions = NewSessionDraftOptions.safeParse(publicNewSessionDraftOptions(current));
|
|
412
457
|
const options = parsedOptions.success ? parsedOptions.data : {};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
+
CreateAdditionalOrganizationResponse,
|
|
2
3
|
CreateOrganizationResponse,
|
|
3
4
|
ListOrganizationAdministrationMembersResponse,
|
|
4
5
|
ListOrganizationInvitationsResponse,
|
|
@@ -18,6 +19,7 @@ import {
|
|
|
18
19
|
OrganizationRetentionPolicy,
|
|
19
20
|
OrganizationSummary,
|
|
20
21
|
RevokeOrganizationWorkspaceMemberResponse,
|
|
22
|
+
type CreateAdditionalOrganizationResponse as CreateAdditionalOrganizationResponseType,
|
|
21
23
|
type CreateOrganizationResponse as CreateOrganizationResponseType,
|
|
22
24
|
type OrganizationAdministrationMember as OrganizationAdministrationMemberType,
|
|
23
25
|
type OrganizationAdministrationOverview as OrganizationAdministrationOverviewType,
|
|
@@ -74,6 +76,32 @@ export async function createManagedOrganization(
|
|
|
74
76
|
});
|
|
75
77
|
}
|
|
76
78
|
|
|
79
|
+
export async function createAdditionalManagedOrganization(
|
|
80
|
+
db: Database,
|
|
81
|
+
input: {
|
|
82
|
+
subjectId: string;
|
|
83
|
+
subjectLabel: string;
|
|
84
|
+
name: string;
|
|
85
|
+
workspaceName: string;
|
|
86
|
+
operationId: string;
|
|
87
|
+
},
|
|
88
|
+
): Promise<CreateAdditionalOrganizationResponseType> {
|
|
89
|
+
return await db.transaction(async (tx) => {
|
|
90
|
+
await setSubjectRlsContext(tx as unknown as Database, input.subjectId);
|
|
91
|
+
const [row] = await rawRows<{ result: unknown }>(
|
|
92
|
+
tx,
|
|
93
|
+
sql`select create_additional_managed_organization(
|
|
94
|
+
${input.subjectId},
|
|
95
|
+
${input.subjectLabel},
|
|
96
|
+
${input.name},
|
|
97
|
+
${input.workspaceName},
|
|
98
|
+
${input.operationId}::uuid
|
|
99
|
+
) as result`,
|
|
100
|
+
);
|
|
101
|
+
return CreateAdditionalOrganizationResponse.parse(row?.result);
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
|
|
77
105
|
/**
|
|
78
106
|
* Bounded replay of one exact organization-lifecycle transaction after a
|
|
79
107
|
* PostgreSQL deadlock abort.
|
|
@@ -208,7 +236,10 @@ async function settleOrganizationMembershipProtocols(
|
|
|
208
236
|
db: Database,
|
|
209
237
|
settlements: OrganizationMembershipProtocolSettlement[],
|
|
210
238
|
): Promise<void> {
|
|
211
|
-
const [prior] = await rawRows<{
|
|
239
|
+
const [prior] = await rawRows<{
|
|
240
|
+
subject_id: string;
|
|
241
|
+
initiating_human_subject_id: string;
|
|
242
|
+
}>(
|
|
212
243
|
db,
|
|
213
244
|
sql`select
|
|
214
245
|
coalesce(current_setting('opengeni.subject_id', true), '') as subject_id,
|
|
@@ -436,7 +467,9 @@ async function runOrganizationWorkspaceCommand(
|
|
|
436
467
|
{ accountId: command.organizationId, workspaceId: null },
|
|
437
468
|
async (scopedDb) => {
|
|
438
469
|
await setSubjectRlsContext(scopedDb, command.actorSubjectId);
|
|
439
|
-
const [row] = await rawRows<{
|
|
470
|
+
const [row] = await rawRows<{
|
|
471
|
+
result: OrganizationWorkspaceCommandResult;
|
|
472
|
+
}>(
|
|
440
473
|
scopedDb,
|
|
441
474
|
sql`select organization_workspace_command(${JSON.stringify(command)}::jsonb) as result`,
|
|
442
475
|
);
|
|
@@ -455,7 +488,10 @@ export async function createOrganizationWorkspace(
|
|
|
455
488
|
operationId: string;
|
|
456
489
|
},
|
|
457
490
|
): Promise<OrganizationWorkspaceAccessType> {
|
|
458
|
-
const command = await runOrganizationWorkspaceCommand(db, {
|
|
491
|
+
const command = await runOrganizationWorkspaceCommand(db, {
|
|
492
|
+
action: "create",
|
|
493
|
+
...input,
|
|
494
|
+
});
|
|
459
495
|
const overview = await getOrganizationAdministrationOverview(db, input);
|
|
460
496
|
const workspace = overview.workspaces.find((candidate) => candidate.id === command.workspaceId);
|
|
461
497
|
if (!workspace) throw new Error("Created organization workspace is missing from its overview");
|
|
@@ -615,7 +651,9 @@ export async function assertActiveManagedHumanOrganizationMembership(
|
|
|
615
651
|
db: Database,
|
|
616
652
|
input: { accountId: string; subjectId: string },
|
|
617
653
|
): Promise<number | null> {
|
|
618
|
-
const [row] = await rawRows<{
|
|
654
|
+
const [row] = await rawRows<{
|
|
655
|
+
authorization_revision: number | string | null;
|
|
656
|
+
}>(
|
|
619
657
|
db,
|
|
620
658
|
sql`select assert_active_managed_human_organization_membership(
|
|
621
659
|
${input.accountId}::uuid,
|
|
@@ -1098,7 +1136,11 @@ export async function previewOrganizationRetentionDeletions(
|
|
|
1098
1136
|
|
|
1099
1137
|
export async function claimOrganizationRetentionDeletion(
|
|
1100
1138
|
db: Database,
|
|
1101
|
-
input: {
|
|
1139
|
+
input: {
|
|
1140
|
+
organizationId: string;
|
|
1141
|
+
operationId: string;
|
|
1142
|
+
excludedMembershipIds?: string[];
|
|
1143
|
+
},
|
|
1102
1144
|
): Promise<OrganizationRetentionDeletionClaimType | null> {
|
|
1103
1145
|
return await runRetentionCapability(db, input.organizationId, async (scopedDb) => {
|
|
1104
1146
|
const excludedMembershipIds = input.excludedMembershipIds ?? [];
|