@opengeni/db 6.0.1 → 6.0.3
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/browser-sessions.d.ts +26 -0
- package/dist/canonical-human-identities.js +3 -3
- package/dist/capability-reconciliation.js +2 -2
- package/dist/{chunk-4RDUZ5UV.js → chunk-4ZQFT5II.js} +2 -2
- package/dist/{chunk-6ORJPCYW.js → chunk-5UOWNKPP.js} +2 -2
- package/dist/{chunk-4CCFFLDZ.js → chunk-BG46J5HF.js} +13 -2
- package/dist/chunk-BG46J5HF.js.map +1 -0
- package/dist/{chunk-CSVHCF3R.js → chunk-IB3SW3JW.js} +11 -4
- package/dist/{chunk-CSVHCF3R.js.map → chunk-IB3SW3JW.js.map} +1 -1
- package/dist/{chunk-GSB4ISHE.js → chunk-IIPWNNVR.js} +4 -1
- package/dist/chunk-IIPWNNVR.js.map +1 -0
- package/dist/{chunk-MAMBI2HR.js → chunk-JPYN5XKV.js} +39 -3
- package/dist/chunk-JPYN5XKV.js.map +1 -0
- package/dist/{chunk-LSLNMENV.js → chunk-KZXWUXWV.js} +4 -4
- package/dist/{chunk-LO6BVXXH.js → chunk-LD52IFS3.js} +2 -2
- package/dist/{chunk-JILAWE26.js → chunk-M5Z6II2P.js} +2 -2
- package/dist/{chunk-PGIFHEBA.js → chunk-RVEOGRMF.js} +2 -2
- package/dist/{chunk-H7BC444C.js → chunk-SRAMNVHT.js} +17 -1
- package/dist/chunk-SRAMNVHT.js.map +1 -0
- package/dist/{chunk-XK6HXON2.js → chunk-UXFBXCHM.js} +2 -2
- package/dist/{chunk-RXH5CFG3.js → chunk-VE2XK2KD.js} +12 -8
- package/dist/{chunk-RXH5CFG3.js.map → chunk-VE2XK2KD.js.map} +1 -1
- package/dist/{chunk-FULLE5CF.js → chunk-WT7HG43Y.js} +3 -3
- package/dist/{chunk-I7HQL6FK.js → chunk-ZM5BA3TD.js} +3 -3
- package/dist/connect-attempts.js +3 -3
- package/dist/database.d.ts +8 -0
- package/dist/editable-artifact-durable-export.js +2 -2
- package/dist/editable-artifacts.js +3 -3
- package/dist/index.d.ts +69 -20
- package/dist/index.js +633 -202
- package/dist/index.js.map +1 -1
- package/dist/knowledge-entries.d.ts +2 -0
- package/dist/knowledge-indexing.d.ts +17 -0
- package/dist/managed-auth-session-sets.js +3 -3
- package/dist/managed-user-setup.d.ts +1 -0
- package/dist/mcp-operations.js +2 -2
- package/dist/migrate.d.ts +10 -1
- package/dist/migrate.js +3 -1
- package/dist/organization-integration-policy.js +3 -3
- package/dist/organization-membership-lifecycle.d.ts +1 -0
- package/dist/provision-roles.js +1 -1
- package/dist/retained-provider-commands.d.ts +4 -2
- package/dist/retained-provider-commands.js +6 -6
- package/dist/runtime-posture.d.ts +1 -1
- package/dist/schema.d.ts +25 -8
- package/dist/schema.js +1 -1
- package/dist/session-background-commands.js +4 -4
- package/dist/session-command-output.js +5 -5
- package/dist/session-event-slices.js +3 -3
- package/dist/session-mcp-credential-rotation.js +4 -4
- package/dist/session-tenancy.js +3 -3
- package/dist/video-generation.js +3 -3
- package/dist/workspace-tool-defaults.js +4 -4
- package/drizzle/0508_deadline_command_workspace_capture.sql +75 -0
- package/drizzle/0509_verified_signup_trial_credits.sql +76 -0
- package/drizzle/0510_knowledge_index_funding_wait.sql +174 -0
- package/drizzle/0511_knowledge_visible_index_status.sql +56 -0
- package/drizzle/0512_insights_fact_reads_hash_join.sql +31 -0
- package/drizzle/0513_message_fork_prefix_compaction.sql +85 -0
- package/drizzle/0514_failed_session_variable_set_attach.sql +25 -0
- package/package.json +5 -5
- package/src/browser-sessions.ts +71 -1
- package/src/database.ts +18 -0
- package/src/index.ts +706 -252
- package/src/insights.ts +44 -36
- package/src/knowledge-entries.ts +43 -2
- package/src/knowledge-indexing.ts +79 -1
- package/src/managed-user-setup.ts +18 -1
- package/src/migrate.ts +58 -1
- package/src/organization-membership-lifecycle.ts +11 -0
- package/src/provision-roles.ts +12 -0
- package/src/retained-provider-commands.ts +16 -6
- package/src/runtime-posture.ts +4 -0
- package/src/schema.ts +3 -0
- package/dist/chunk-4CCFFLDZ.js.map +0 -1
- package/dist/chunk-GSB4ISHE.js.map +0 -1
- package/dist/chunk-H7BC444C.js.map +0 -1
- package/dist/chunk-MAMBI2HR.js.map +0 -1
- /package/dist/{chunk-4RDUZ5UV.js.map → chunk-4ZQFT5II.js.map} +0 -0
- /package/dist/{chunk-6ORJPCYW.js.map → chunk-5UOWNKPP.js.map} +0 -0
- /package/dist/{chunk-LSLNMENV.js.map → chunk-KZXWUXWV.js.map} +0 -0
- /package/dist/{chunk-LO6BVXXH.js.map → chunk-LD52IFS3.js.map} +0 -0
- /package/dist/{chunk-JILAWE26.js.map → chunk-M5Z6II2P.js.map} +0 -0
- /package/dist/{chunk-PGIFHEBA.js.map → chunk-RVEOGRMF.js.map} +0 -0
- /package/dist/{chunk-XK6HXON2.js.map → chunk-UXFBXCHM.js.map} +0 -0
- /package/dist/{chunk-FULLE5CF.js.map → chunk-WT7HG43Y.js.map} +0 -0
- /package/dist/{chunk-I7HQL6FK.js.map → chunk-ZM5BA3TD.js.map} +0 -0
package/src/browser-sessions.ts
CHANGED
|
@@ -266,6 +266,11 @@ function associationFromRow(row: BrowserAssociationRow) {
|
|
|
266
266
|
} as const;
|
|
267
267
|
}
|
|
268
268
|
|
|
269
|
+
/** Legacy resources predate permission control; absence must never advertise support. */
|
|
270
|
+
export function readStoredBrowserCapabilities(value: Record<string, unknown>) {
|
|
271
|
+
return BrowserSessionCapabilities.parse({ permissions: false, ...value });
|
|
272
|
+
}
|
|
273
|
+
|
|
269
274
|
function browserSessionFromRows(
|
|
270
275
|
row: BrowserSessionRow,
|
|
271
276
|
associations: readonly BrowserAssociationRow[],
|
|
@@ -286,7 +291,7 @@ function browserSessionFromRows(
|
|
|
286
291
|
baseRevisionId: row.baseRevisionId,
|
|
287
292
|
networkRouteId: row.networkRouteId,
|
|
288
293
|
linkedComputerSessionId: row.linkedComputerSessionId,
|
|
289
|
-
capabilities: row.capabilities,
|
|
294
|
+
capabilities: readStoredBrowserCapabilities(row.capabilities),
|
|
290
295
|
associations: associations.map(associationFromRow),
|
|
291
296
|
createdBySubjectId: row.createdBySubjectId,
|
|
292
297
|
createdAt: iso(row.createdAt),
|
|
@@ -1463,6 +1468,71 @@ export async function prepareBrowserSessionSuspend(
|
|
|
1463
1468
|
});
|
|
1464
1469
|
}
|
|
1465
1470
|
|
|
1471
|
+
/** Restore the active controller when placement fails before a suspend was dispatched. */
|
|
1472
|
+
export async function failPreparedBrowserSessionSuspend(
|
|
1473
|
+
db: Database,
|
|
1474
|
+
input: {
|
|
1475
|
+
accountId: string;
|
|
1476
|
+
workspaceId: string;
|
|
1477
|
+
operationId: string;
|
|
1478
|
+
browserSessionId: string;
|
|
1479
|
+
error: InteractionErrorValue;
|
|
1480
|
+
},
|
|
1481
|
+
): Promise<BrowserSessionMutationResponseValue | null> {
|
|
1482
|
+
const error = InteractionError.parse(input.error);
|
|
1483
|
+
return await withRlsContext(
|
|
1484
|
+
db,
|
|
1485
|
+
input,
|
|
1486
|
+
async (scopedDb) =>
|
|
1487
|
+
await scopedDb.transaction(async (txRaw) => {
|
|
1488
|
+
const tx = txRaw as unknown as Database;
|
|
1489
|
+
await lockOperation(tx, input.workspaceId, input.operationId);
|
|
1490
|
+
const operation = await loadOperation(tx, input.workspaceId, input.operationId);
|
|
1491
|
+
assertOperationResource(operation, input.browserSessionId, "suspend");
|
|
1492
|
+
if (operation.state !== "prepared" || operation.dispatchedAt) return null;
|
|
1493
|
+
|
|
1494
|
+
await lockBrowserSession(tx, input.workspaceId, input.browserSessionId);
|
|
1495
|
+
const now = new Date();
|
|
1496
|
+
const [sessionRow] = await tx
|
|
1497
|
+
.update(schema.browserSessions)
|
|
1498
|
+
.set({ lifecycle: "active", failureCode: null, updatedAt: now })
|
|
1499
|
+
.where(
|
|
1500
|
+
and(
|
|
1501
|
+
eq(schema.browserSessions.workspaceId, input.workspaceId),
|
|
1502
|
+
eq(schema.browserSessions.id, input.browserSessionId),
|
|
1503
|
+
eq(schema.browserSessions.lifecycle, "suspending"),
|
|
1504
|
+
),
|
|
1505
|
+
)
|
|
1506
|
+
.returning();
|
|
1507
|
+
if (!sessionRow) {
|
|
1508
|
+
throw new BrowserSessionStateError("Prepared BrowserSession suspension changed state");
|
|
1509
|
+
}
|
|
1510
|
+
const [operationRow] = await tx
|
|
1511
|
+
.update(schema.interactionOperations)
|
|
1512
|
+
.set({
|
|
1513
|
+
state: "failed",
|
|
1514
|
+
errorCode: error.code,
|
|
1515
|
+
errorMessage: error.message,
|
|
1516
|
+
errorRetryable: error.retryable,
|
|
1517
|
+
errorDetails: error.details ?? null,
|
|
1518
|
+
settledAt: now,
|
|
1519
|
+
updatedAt: now,
|
|
1520
|
+
})
|
|
1521
|
+
.where(eq(schema.interactionOperations.operationId, input.operationId))
|
|
1522
|
+
.returning();
|
|
1523
|
+
if (!operationRow) throw new Error("BrowserSession failure receipt was lost");
|
|
1524
|
+
const associations = await loadAssociations(tx, input.workspaceId, [
|
|
1525
|
+
input.browserSessionId,
|
|
1526
|
+
]);
|
|
1527
|
+
await advanceWorkspaceInteractionRevision(tx, input.accountId, input.workspaceId);
|
|
1528
|
+
return BrowserSessionMutationResponse.parse({
|
|
1529
|
+
session: browserSessionFromRows(sessionRow, associations),
|
|
1530
|
+
operation: operationReceipt(operationRow, false),
|
|
1531
|
+
});
|
|
1532
|
+
}),
|
|
1533
|
+
);
|
|
1534
|
+
}
|
|
1535
|
+
|
|
1466
1536
|
export async function prepareBrowserSessionResume(
|
|
1467
1537
|
db: Database,
|
|
1468
1538
|
input: PrepareBrowserSessionLifecycleInput,
|
package/src/database.ts
CHANGED
|
@@ -67,6 +67,24 @@ export function currentSessionAttachmentReadAccess(): SessionAttachmentReadAcces
|
|
|
67
67
|
return sessionRlsActorContext.getStore()?.sessionAttachmentReadAccess;
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
+
/**
|
|
71
|
+
* Stable identity of the ambient session RLS actor: every field that
|
|
72
|
+
* `setRlsContext` turns into database-visible GUCs or that scoped reads
|
|
73
|
+
* consult. Two callers with equal keys see exactly the same rows, so the key
|
|
74
|
+
* is safe for sharing a read result between them; `null` means no actor, in
|
|
75
|
+
* which case the subject GUC stays empty for every such caller.
|
|
76
|
+
*/
|
|
77
|
+
export function currentSessionRlsActorIdentityKey(): string | null {
|
|
78
|
+
const actor = sessionRlsActorContext.getStore();
|
|
79
|
+
if (!actor) return null;
|
|
80
|
+
return JSON.stringify([
|
|
81
|
+
actor.subjectId,
|
|
82
|
+
actor.initiatingHumanSubjectId ?? null,
|
|
83
|
+
actor.privateFileOwnerSubjectId ?? null,
|
|
84
|
+
actor.sessionAttachmentReadAccess ?? null,
|
|
85
|
+
]);
|
|
86
|
+
}
|
|
87
|
+
|
|
70
88
|
export async function withSessionRlsActorContext<T>(
|
|
71
89
|
actor: SessionRlsActorContext,
|
|
72
90
|
fn: () => Promise<T>,
|