@opengeni/db 0.27.3 → 0.27.7
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/index.d.ts +12 -0
- package/dist/index.js +33 -1
- package/dist/index.js.map +1 -1
- package/dist/session-realtime-context.d.ts +1 -1
- package/package.json +4 -4
- package/src/index.ts +54 -0
- package/src/session-realtime-context.ts +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -276,6 +276,14 @@ export declare function getHostExportConsumerStatus(db: Database, input: {
|
|
|
276
276
|
}): Promise<HostExportConsumerStatus | null>;
|
|
277
277
|
export declare function setRlsContext(db: Database, context: RlsContext): Promise<void>;
|
|
278
278
|
export declare function withRlsContext<T>(db: Database, context: RlsContext, fn: (db: Database) => Promise<T>, transactionConfig?: PgTransactionConfig): Promise<T>;
|
|
279
|
+
/**
|
|
280
|
+
* Run one bounded database operation on a transaction-pinned backend.
|
|
281
|
+
*
|
|
282
|
+
* Callers that also have an application deadline should check their abort
|
|
283
|
+
* signal before returning from `fn`; throwing there rolls the transaction back
|
|
284
|
+
* even when the application deadline won a surrounding Promise race.
|
|
285
|
+
*/
|
|
286
|
+
export declare function withDatabaseStatementTimeout<T>(db: Database, timeoutMs: number, fn: (db: Database) => Promise<T>): Promise<T>;
|
|
279
287
|
export declare function rlsContextForWorkspace(db: Database, workspaceId: string): Promise<RlsContext>;
|
|
280
288
|
export declare function withWorkspaceRls<T>(db: Database, workspaceId: string, fn: (db: Database) => Promise<T>): Promise<T>;
|
|
281
289
|
/**
|
|
@@ -900,6 +908,9 @@ export type StoreIntegrationOAuthClientInput = {
|
|
|
900
908
|
metadata?: Record<string, unknown>;
|
|
901
909
|
};
|
|
902
910
|
export type ReplaceIntegrationOAuthClientInput = StoreIntegrationOAuthClientInput;
|
|
911
|
+
export type ReplaceIntegrationOAuthClientIfCurrentInput = ReplaceIntegrationOAuthClientInput & {
|
|
912
|
+
expectedClientId: string;
|
|
913
|
+
};
|
|
903
914
|
export type ConsumeOAuthStateNonceInput = {
|
|
904
915
|
accountId: string;
|
|
905
916
|
workspaceId: string;
|
|
@@ -1588,6 +1599,7 @@ export declare function recordConnectionUsed(db: Database, workspaceId: string,
|
|
|
1588
1599
|
export declare function loadIntegrationOAuthClient(db: Database, settings: Settings, issuer: string): Promise<IntegrationOAuthClientForUse | null>;
|
|
1589
1600
|
export declare function storeIntegrationOAuthClient(db: Database, input: StoreIntegrationOAuthClientInput): Promise<StoredIntegrationOAuthClient>;
|
|
1590
1601
|
export declare function replaceIntegrationOAuthClient(db: Database, input: ReplaceIntegrationOAuthClientInput): Promise<StoredIntegrationOAuthClient>;
|
|
1602
|
+
export declare function replaceIntegrationOAuthClientIfCurrent(db: Database, input: ReplaceIntegrationOAuthClientIfCurrentInput): Promise<StoredIntegrationOAuthClient | null>;
|
|
1591
1603
|
export declare function consumeIntegrationOAuthStateNonce(db: Database, input: ConsumeOAuthStateNonceInput): Promise<boolean>;
|
|
1592
1604
|
export declare function createKnowledgeMemory(db: Database, input: CreateKnowledgeMemoryInput): Promise<KnowledgeMemory>;
|
|
1593
1605
|
export declare function updateKnowledgeMemory(db: Database, workspaceId: string, memoryId: string, input: UpdateKnowledgeMemoryInput, embedder?: MemoryEmbedder): Promise<KnowledgeMemory>;
|
package/dist/index.js
CHANGED
|
@@ -5065,7 +5065,7 @@ async function steerAgentSessionInTransaction(db, input) {
|
|
|
5065
5065
|
// src/session-realtime-context.ts
|
|
5066
5066
|
var SESSION_REALTIME_CONTEXT_MAX_BYTES = 65536;
|
|
5067
5067
|
var SESSION_REALTIME_TAIL_SOURCE = "transcript_tail_flush";
|
|
5068
|
-
var SESSION_REALTIME_TAIL_INSTRUCTION = "The user just ended
|
|
5068
|
+
var SESSION_REALTIME_TAIL_INSTRUCTION = "The user just ended the realtime voice session but remains reachable by text. Ending voice changes only the communication mode; it does not stop, pause, or complete existing work. Treat the remaining transcript tail as additional context. If work was already underway, continue it from the current state. Change or stop that work only if the user explicitly requested it. If nothing was underway and the transcript contains no unhandled request, acknowledge briefly; otherwise handle any unhandled request.";
|
|
5069
5069
|
function deterministicUuid2(seed) {
|
|
5070
5070
|
const bytes = createHash3("sha256").update(seed, "utf8").digest().subarray(0, 16);
|
|
5071
5071
|
bytes[6] = (bytes[6] ?? 0) & 15 | 80;
|
|
@@ -14145,6 +14145,19 @@ async function withRlsContext(db, context, fn, transactionConfig) {
|
|
|
14145
14145
|
return await fn(scoped);
|
|
14146
14146
|
}, transactionConfig);
|
|
14147
14147
|
}
|
|
14148
|
+
async function withDatabaseStatementTimeout(db, timeoutMs, fn) {
|
|
14149
|
+
if (!Number.isFinite(timeoutMs) || timeoutMs <= 0) {
|
|
14150
|
+
throw new Error("withDatabaseStatementTimeout requires a positive timeout");
|
|
14151
|
+
}
|
|
14152
|
+
const boundedTimeoutMs = Math.max(1, Math.floor(timeoutMs));
|
|
14153
|
+
return await db.transaction(async (tx) => {
|
|
14154
|
+
const scoped = tx;
|
|
14155
|
+
await scoped.execute(
|
|
14156
|
+
sql14`select set_config('statement_timeout', ${`${boundedTimeoutMs}ms`}, true)`
|
|
14157
|
+
);
|
|
14158
|
+
return await fn(scoped);
|
|
14159
|
+
});
|
|
14160
|
+
}
|
|
14148
14161
|
async function rlsContextForWorkspace(db, workspaceId) {
|
|
14149
14162
|
const [row] = await db.select({ accountId: workspaces.accountId }).from(workspaces).where(eq17(workspaces.id, workspaceId)).limit(1);
|
|
14150
14163
|
if (!row) {
|
|
@@ -17998,6 +18011,22 @@ async function replaceIntegrationOAuthClient(db, input) {
|
|
|
17998
18011
|
}
|
|
17999
18012
|
return mapStoredIntegrationOAuthClient(row);
|
|
18000
18013
|
}
|
|
18014
|
+
async function replaceIntegrationOAuthClientIfCurrent(db, input) {
|
|
18015
|
+
const [row] = await db.update(integrationOauthClients).set({
|
|
18016
|
+
authorizationServer: input.authorizationServer,
|
|
18017
|
+
clientId: input.clientId,
|
|
18018
|
+
clientSecretEncrypted: input.clientSecretEncrypted ?? null,
|
|
18019
|
+
tokenEndpointAuthMethod: input.tokenEndpointAuthMethod ?? "none",
|
|
18020
|
+
metadata: input.metadata ?? {},
|
|
18021
|
+
updatedAt: /* @__PURE__ */ new Date()
|
|
18022
|
+
}).where(
|
|
18023
|
+
and17(
|
|
18024
|
+
eq17(integrationOauthClients.issuer, input.issuer),
|
|
18025
|
+
eq17(integrationOauthClients.clientId, input.expectedClientId)
|
|
18026
|
+
)
|
|
18027
|
+
).returning();
|
|
18028
|
+
return row ? mapStoredIntegrationOAuthClient(row) : null;
|
|
18029
|
+
}
|
|
18001
18030
|
function mapStoredIntegrationOAuthClient(row) {
|
|
18002
18031
|
return {
|
|
18003
18032
|
id: row.id,
|
|
@@ -40148,6 +40177,7 @@ function mapSession(row, effectiveControl, mcpServers = [], pin = mapSessionPin(
|
|
|
40148
40177
|
// the fence exact even if the column type ever drifts (the lease-epoch lesson).
|
|
40149
40178
|
activeSandboxId: row.activeSandboxId ?? null,
|
|
40150
40179
|
activeEpoch: Number(row.activeEpoch),
|
|
40180
|
+
workingDir: row.workingDir ?? null,
|
|
40151
40181
|
variableSetId: row.variableSetId,
|
|
40152
40182
|
environmentId: row.variableSetId,
|
|
40153
40183
|
// The rig + frozen rig version the session rides (M3). Both null for a
|
|
@@ -41528,6 +41558,7 @@ export {
|
|
|
41528
41558
|
reopenSlackInteractionDelivery,
|
|
41529
41559
|
replaceExpiredWorkspaceArchiveCapture,
|
|
41530
41560
|
replaceIntegrationOAuthClient,
|
|
41561
|
+
replaceIntegrationOAuthClientIfCurrent,
|
|
41531
41562
|
requestDueSandboxRotationsGlobal,
|
|
41532
41563
|
requestSessionCompaction,
|
|
41533
41564
|
requestSessionTurnRecovery,
|
|
@@ -41682,6 +41713,7 @@ export {
|
|
|
41682
41713
|
withCodexCapacityMutation,
|
|
41683
41714
|
withCodexCredentialRefreshLock,
|
|
41684
41715
|
withCodexTokenDeadline,
|
|
41716
|
+
withDatabaseStatementTimeout,
|
|
41685
41717
|
withRlsContext,
|
|
41686
41718
|
withWorkspaceRls,
|
|
41687
41719
|
withWorkspaceSubjectRls,
|