@opengeni/db 0.36.1 → 1.0.1
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/canonical-human-identities.js +3 -3
- package/dist/{chunk-HSOWSYOX.js → chunk-4SR4HKKA.js} +2 -2
- package/dist/{chunk-5KTIEDX7.js → chunk-6ZYKCRFO.js} +124 -16
- package/dist/chunk-6ZYKCRFO.js.map +1 -0
- package/dist/{chunk-VTPRIXKG.js → chunk-CUPM3FGB.js} +3 -3
- package/dist/{chunk-GYO7ED2Q.js → chunk-LTG3S6ZY.js} +2 -2
- package/dist/{chunk-VKLB2ZGI.js → chunk-NXAFLCQX.js} +81 -2
- package/dist/chunk-NXAFLCQX.js.map +1 -0
- package/dist/{chunk-FPVAD4CO.js → chunk-WD5ROSLL.js} +2 -2
- package/dist/{chunk-Z7VYMNPZ.js → chunk-ZWREYEWA.js} +2 -2
- package/dist/editable-artifact-durable-export.d.ts +10 -0
- package/dist/editable-artifact-durable-export.js +18 -3
- package/dist/editable-artifact-durable-export.js.map +1 -1
- package/dist/editable-artifacts.js +3 -3
- package/dist/index.d.ts +40 -8
- package/dist/index.js +509 -59
- package/dist/index.js.map +1 -1
- package/dist/knowledge-source-sync-schema.d.ts +730 -0
- package/dist/knowledge-source-sync.d.ts +60 -0
- package/dist/provision-roles.js +1 -1
- package/dist/runtime-posture.d.ts +3 -3
- package/dist/schema.d.ts +21 -4
- package/dist/schema.js +5 -1
- package/dist/session-queue-commands.d.ts +1 -1
- package/dist/session-realtime-ledger.d.ts +1 -0
- package/dist/session-tenancy.js +3 -3
- package/dist/video-generation.js +3 -3
- package/drizzle/0240_model_context_user_messages.sql +204 -0
- package/drizzle/0243_google_drive_object_acl_authority.sql +554 -0
- package/package.json +4 -4
- package/src/editable-artifact-durable-export.ts +27 -0
- package/src/index.ts +212 -13
- package/src/knowledge-source-sync-schema.ts +83 -0
- package/src/knowledge-source-sync.ts +530 -0
- package/src/provision-roles.ts +36 -0
- package/src/runtime-posture.ts +49 -1
- package/src/schema.ts +30 -7
- package/src/session-queue-commands.ts +13 -14
- package/src/session-realtime-context.ts +16 -0
- package/src/session-realtime-ledger.ts +53 -1
- package/dist/chunk-5KTIEDX7.js.map +0 -1
- package/dist/chunk-VKLB2ZGI.js.map +0 -1
- /package/dist/{chunk-HSOWSYOX.js.map → chunk-4SR4HKKA.js.map} +0 -0
- /package/dist/{chunk-VTPRIXKG.js.map → chunk-CUPM3FGB.js.map} +0 -0
- /package/dist/{chunk-GYO7ED2Q.js.map → chunk-LTG3S6ZY.js.map} +0 -0
- /package/dist/{chunk-FPVAD4CO.js.map → chunk-WD5ROSLL.js.map} +0 -0
- /package/dist/{chunk-Z7VYMNPZ.js.map → chunk-ZWREYEWA.js.map} +0 -0
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
canonicalSessionVisibilityTransitionHash,
|
|
4
4
|
forkSessionContent,
|
|
5
5
|
transitionSessionVisibility
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-WD5ROSLL.js";
|
|
7
7
|
import {
|
|
8
8
|
migrate,
|
|
9
9
|
runMigrations
|
|
@@ -27,7 +27,7 @@ import {
|
|
|
27
27
|
inspectRuntimeDatabasePosture,
|
|
28
28
|
provisionRoles,
|
|
29
29
|
runtimeDatabaseReadyCheck
|
|
30
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-NXAFLCQX.js";
|
|
31
31
|
import {
|
|
32
32
|
CanonicalHumanIdentityAuthorityError,
|
|
33
33
|
CanonicalHumanIdentityConflictError,
|
|
@@ -39,7 +39,7 @@ import {
|
|
|
39
39
|
getCanonicalHumanIdentityProjection,
|
|
40
40
|
synchronizeCanonicalHumanLoginBindings,
|
|
41
41
|
validateCanonicalHumanSession
|
|
42
|
-
} from "./chunk-
|
|
42
|
+
} from "./chunk-LTG3S6ZY.js";
|
|
43
43
|
import {
|
|
44
44
|
EDITABLE_ARTIFACT_INTENT_MAX_BYTES,
|
|
45
45
|
EDITABLE_ARTIFACT_KERNEL_TAIL_MAX_BYTES,
|
|
@@ -50,7 +50,7 @@ import {
|
|
|
50
50
|
PostgresEditableArtifactStore,
|
|
51
51
|
listEditableArtifactIdsForSession,
|
|
52
52
|
touchEditableArtifactSessionLink
|
|
53
|
-
} from "./chunk-
|
|
53
|
+
} from "./chunk-4SR4HKKA.js";
|
|
54
54
|
import {
|
|
55
55
|
ACTIVE_VIDEO_GENERATION_STATUSES,
|
|
56
56
|
VideoGenerationCapacityError,
|
|
@@ -82,7 +82,7 @@ import {
|
|
|
82
82
|
settleVideoGenerationFailure,
|
|
83
83
|
settleVideoGenerationReady,
|
|
84
84
|
updateWorkspaceVideoGenerationPolicy
|
|
85
|
-
} from "./chunk-
|
|
85
|
+
} from "./chunk-CUPM3FGB.js";
|
|
86
86
|
import {
|
|
87
87
|
SandboxProviderReadLockUnavailableError,
|
|
88
88
|
SessionEventPersistenceError,
|
|
@@ -117,7 +117,7 @@ import {
|
|
|
117
117
|
withWorkspaceSubjectRls,
|
|
118
118
|
withWorkspaceSubjectSessionActivityRls,
|
|
119
119
|
withWorkspaceUsageLock
|
|
120
|
-
} from "./chunk-
|
|
120
|
+
} from "./chunk-ZWREYEWA.js";
|
|
121
121
|
import {
|
|
122
122
|
LOSSLESS_CONTENT_CODEC_VERSION,
|
|
123
123
|
LOSSLESS_TEXT_PREFIX,
|
|
@@ -178,6 +178,8 @@ import {
|
|
|
178
178
|
generatedImageArtifacts,
|
|
179
179
|
githubInstallationRepositories,
|
|
180
180
|
githubInstallations,
|
|
181
|
+
googleDriveObjectAclEvidence,
|
|
182
|
+
googleDriveObjectAclPrincipals,
|
|
181
183
|
imageGenerationOperations,
|
|
182
184
|
importBatches,
|
|
183
185
|
integrationFacetBindingOwners,
|
|
@@ -323,11 +325,11 @@ import {
|
|
|
323
325
|
xaiRotationSettings,
|
|
324
326
|
xaiSessionAccountPins,
|
|
325
327
|
xaiSubscriptionCredentials
|
|
326
|
-
} from "./chunk-
|
|
328
|
+
} from "./chunk-6ZYKCRFO.js";
|
|
327
329
|
import "./chunk-PZ5AY32C.js";
|
|
328
330
|
|
|
329
331
|
// src/index.ts
|
|
330
|
-
import { createHash as
|
|
332
|
+
import { createHash as createHash29, randomUUID as randomUUID10 } from "crypto";
|
|
331
333
|
import {
|
|
332
334
|
SESSION_GOAL_PROGRESS_MAX_BYTES,
|
|
333
335
|
SESSION_GOAL_RATIONALE_MAX_BYTES,
|
|
@@ -3915,7 +3917,7 @@ import {
|
|
|
3915
3917
|
MODEL_ATTACHMENT_REFS_FIELD,
|
|
3916
3918
|
MODEL_TIMELINE_ANNOTATIONS_FIELD,
|
|
3917
3919
|
TimelineAnnotations as TimelineAnnotations2,
|
|
3918
|
-
|
|
3920
|
+
renderUserMessageContentForModel,
|
|
3919
3921
|
SessionMcpApprovalPolicy as SessionMcpApprovalPolicySchema,
|
|
3920
3922
|
RequestHumanInteractionToolInput as RequestHumanInteractionToolInput2,
|
|
3921
3923
|
WORKSPACE_XAI_PROVIDER_ACCOUNT_AUTHORITY_SNAPSHOT_V1 as WORKSPACE_XAI_PROVIDER_ACCOUNT_AUTHORITY_SNAPSHOT_V13,
|
|
@@ -9057,7 +9059,7 @@ async function submitHumanPromptInTransaction(db, input) {
|
|
|
9057
9059
|
expectedDraftRevision: input.expectedDraftRevision ?? null,
|
|
9058
9060
|
text: input.text,
|
|
9059
9061
|
annotations,
|
|
9060
|
-
|
|
9062
|
+
modelContext: input.modelContext ?? null,
|
|
9061
9063
|
resources: withCanonicalResourceMountPaths(input.resources),
|
|
9062
9064
|
model: input.model ?? null,
|
|
9063
9065
|
reasoningEffort: input.reasoningEffort ?? null,
|
|
@@ -9189,7 +9191,7 @@ async function submitHumanPromptInTransaction(db, input) {
|
|
|
9189
9191
|
}
|
|
9190
9192
|
}
|
|
9191
9193
|
let editedSourceTurn;
|
|
9192
|
-
let
|
|
9194
|
+
let editedSourceModelContext;
|
|
9193
9195
|
if (draft?.sourceTurnId) {
|
|
9194
9196
|
const sourceLocks = await lockSessionEventWriteRows(db, {
|
|
9195
9197
|
workspaceId: input.workspaceId,
|
|
@@ -9213,7 +9215,7 @@ async function submitHumanPromptInTransaction(db, input) {
|
|
|
9213
9215
|
);
|
|
9214
9216
|
}
|
|
9215
9217
|
editedSourceTurn = sourceTurn;
|
|
9216
|
-
|
|
9218
|
+
editedSourceModelContext = sourceTurn.modelContext ?? null;
|
|
9217
9219
|
}
|
|
9218
9220
|
for (const update of input.mcpCredentialUpdates ?? []) {
|
|
9219
9221
|
const [server] = await db.update(sessionMcpServers).set({
|
|
@@ -9260,6 +9262,7 @@ async function submitHumanPromptInTransaction(db, input) {
|
|
|
9260
9262
|
const acceptedEventId = crypto.randomUUID();
|
|
9261
9263
|
const turnId = crypto.randomUUID();
|
|
9262
9264
|
const workflowId = session.temporalWorkflowId ?? `session-${session.id}`;
|
|
9265
|
+
const effectiveModelContext = editedSourceModelContext !== void 0 ? editedSourceModelContext : input.modelContext ?? null;
|
|
9263
9266
|
let sequence = session.lastSequence;
|
|
9264
9267
|
const eventValues = [
|
|
9265
9268
|
{
|
|
@@ -9280,6 +9283,7 @@ async function submitHumanPromptInTransaction(db, input) {
|
|
|
9280
9283
|
}
|
|
9281
9284
|
} : {},
|
|
9282
9285
|
...input.resources.length ? { resources: input.resources } : {},
|
|
9286
|
+
...effectiveModelContext ? { modelContext: effectiveModelContext } : {},
|
|
9283
9287
|
...input.model ? { model: input.model } : {},
|
|
9284
9288
|
...input.reasoningEffort ? { reasoningEffort: input.reasoningEffort } : {},
|
|
9285
9289
|
...input.latencyMode ? { latencyMode: input.latencyMode } : {},
|
|
@@ -9304,7 +9308,7 @@ async function submitHumanPromptInTransaction(db, input) {
|
|
|
9304
9308
|
position: input.delivery === "steer" ? 0 : existingQueued.length + 1,
|
|
9305
9309
|
prompt: input.text,
|
|
9306
9310
|
annotations,
|
|
9307
|
-
|
|
9311
|
+
modelContext: effectiveModelContext,
|
|
9308
9312
|
resources: input.resources,
|
|
9309
9313
|
tools: [],
|
|
9310
9314
|
toolsProvided: false,
|
|
@@ -10145,7 +10149,8 @@ async function flushSessionRealtimeTranscriptTailInTransaction(db, input) {
|
|
|
10145
10149
|
text: sessionRealtimeEntries.text,
|
|
10146
10150
|
textCodecVersion: sessionRealtimeEntries.textCodecVersion,
|
|
10147
10151
|
payload: sessionRealtimeEntries.payload,
|
|
10148
|
-
payloadCodecVersion: sessionRealtimeEntries.payloadCodecVersion
|
|
10152
|
+
payloadCodecVersion: sessionRealtimeEntries.payloadCodecVersion,
|
|
10153
|
+
modelContext: sessionRealtimeEntries.modelContext
|
|
10149
10154
|
}).from(sessionRealtimeEntries).where(
|
|
10150
10155
|
and12(
|
|
10151
10156
|
eq13(sessionRealtimeEntries.realtimeId, mode.id),
|
|
@@ -10162,6 +10167,20 @@ async function flushSessionRealtimeTranscriptTailInTransaction(db, input) {
|
|
|
10162
10167
|
}));
|
|
10163
10168
|
const rendered = renderSessionRealtimeTail(decodedRows);
|
|
10164
10169
|
if (!rendered.context) return null;
|
|
10170
|
+
const renderedRows = decodedRows.slice(decodedRows.length - rendered.includedEntryCount);
|
|
10171
|
+
let foundUserTranscript = false;
|
|
10172
|
+
let modelContext = null;
|
|
10173
|
+
for (let index = renderedRows.length - 1; index >= 0; index -= 1) {
|
|
10174
|
+
const entry = renderedRows[index];
|
|
10175
|
+
if (entry.role === "user") {
|
|
10176
|
+
foundUserTranscript = true;
|
|
10177
|
+
modelContext = entry.modelContext;
|
|
10178
|
+
break;
|
|
10179
|
+
}
|
|
10180
|
+
}
|
|
10181
|
+
if (!foundUserTranscript) {
|
|
10182
|
+
modelContext = renderedRows.at(-1)?.modelContext ?? null;
|
|
10183
|
+
}
|
|
10165
10184
|
const [session] = await db.select({ metadata: sessions.metadata }).from(sessions).where(
|
|
10166
10185
|
and12(
|
|
10167
10186
|
eq13(sessions.workspaceId, input.workspaceId),
|
|
@@ -10185,6 +10204,7 @@ async function flushSessionRealtimeTranscriptTailInTransaction(db, input) {
|
|
|
10185
10204
|
operationKey: deterministicUuid2(`opengeni:session-realtime-tail-flush:${mode.id}`),
|
|
10186
10205
|
delivery: "steer",
|
|
10187
10206
|
text: rendered.context,
|
|
10207
|
+
modelContext,
|
|
10188
10208
|
messagePresentation: {
|
|
10189
10209
|
kind: "realtime_voice_handoff",
|
|
10190
10210
|
text: "Voice session ended. Remaining conversation context was sent to the agent.",
|
|
@@ -11556,10 +11576,37 @@ function canonicalJsonValue2(value) {
|
|
|
11556
11576
|
}
|
|
11557
11577
|
return value;
|
|
11558
11578
|
}
|
|
11559
|
-
function
|
|
11579
|
+
function normalizedModelContext(input) {
|
|
11580
|
+
const value = input.modelContext?.trim();
|
|
11581
|
+
if (!value) {
|
|
11582
|
+
if (input.modelContext !== void 0) {
|
|
11583
|
+
throw new Error("Realtime modelContext must not be empty");
|
|
11584
|
+
}
|
|
11585
|
+
return null;
|
|
11586
|
+
}
|
|
11587
|
+
if (value.length > 32768) {
|
|
11588
|
+
throw new Error("Realtime modelContext exceeds the server limit");
|
|
11589
|
+
}
|
|
11590
|
+
if (input.kind !== "delegation_call" && input.kind !== "user_transcript" && input.kind !== "assistant_transcript") {
|
|
11591
|
+
throw new Error("Realtime modelContext requires a delegation or finalized transcript");
|
|
11592
|
+
}
|
|
11593
|
+
return value;
|
|
11594
|
+
}
|
|
11595
|
+
function inboundReplayMatches(row, input, role, text, payload, modelContext) {
|
|
11560
11596
|
const storedText = row.text === null ? null : fromPostgresLosslessText(row.text, row.textCodecVersion);
|
|
11561
11597
|
const storedPayload = fromPostgresLosslessJson(row.payload, row.payloadCodecVersion);
|
|
11562
|
-
return row.direction === "provider_in" && row.kind === input.kind && row.role === role && row.providerEventId === (input.providerEventId ?? null) && row.delegationItemId === (input.delegationItemId ?? null) && row.sourceUpdateId === null && storedText === text && JSON.stringify(canonicalJsonValue2(storedPayload)) === JSON.stringify(canonicalJsonValue2(payload));
|
|
11598
|
+
return row.direction === "provider_in" && row.kind === input.kind && row.role === role && row.providerEventId === (input.providerEventId ?? null) && row.delegationItemId === (input.delegationItemId ?? null) && row.sourceUpdateId === null && storedText === text && row.modelContext === modelContext && JSON.stringify(canonicalJsonValue2(storedPayload)) === JSON.stringify(canonicalJsonValue2(payload));
|
|
11599
|
+
}
|
|
11600
|
+
async function delegationModelContextMatches(db, row, modelContext) {
|
|
11601
|
+
if (row.kind !== "delegation_call" || row.turnId === null) return true;
|
|
11602
|
+
const [turn] = await db.select({ modelContext: sessionTurns.modelContext }).from(sessionTurns).where(
|
|
11603
|
+
and15(
|
|
11604
|
+
eq16(sessionTurns.workspaceId, row.workspaceId),
|
|
11605
|
+
eq16(sessionTurns.sessionId, row.sessionId),
|
|
11606
|
+
eq16(sessionTurns.id, row.turnId)
|
|
11607
|
+
)
|
|
11608
|
+
).limit(1);
|
|
11609
|
+
return turn?.modelContext === modelContext;
|
|
11563
11610
|
}
|
|
11564
11611
|
async function appendInvalidDelegationFailure(db, input, accountId, incoming, failure, sequence, now) {
|
|
11565
11612
|
await db.insert(sessionRealtimeEntries).values({
|
|
@@ -11584,7 +11631,7 @@ async function appendInvalidDelegationFailure(db, input, accountId, incoming, fa
|
|
|
11584
11631
|
updatedAt: now
|
|
11585
11632
|
});
|
|
11586
11633
|
}
|
|
11587
|
-
async function admitRealtimeDelegationInTransaction(db, input, accountId, incoming, entryId) {
|
|
11634
|
+
async function admitRealtimeDelegationInTransaction(db, input, accountId, incoming, entryId, modelContext) {
|
|
11588
11635
|
const [session] = await db.select().from(sessions).where(
|
|
11589
11636
|
and15(
|
|
11590
11637
|
eq16(sessions.workspaceId, input.workspaceId),
|
|
@@ -11634,6 +11681,7 @@ async function admitRealtimeDelegationInTransaction(db, input, accountId, incomi
|
|
|
11634
11681
|
operationKey: incoming.operationId,
|
|
11635
11682
|
delivery: "steer",
|
|
11636
11683
|
text: incoming.text,
|
|
11684
|
+
modelContext,
|
|
11637
11685
|
messagePresentation: {
|
|
11638
11686
|
kind: "realtime_voice",
|
|
11639
11687
|
text: inputTranscript,
|
|
@@ -11806,6 +11854,7 @@ async function syncSessionRealtimeLedgerInTransaction(db, input, hooks = {}) {
|
|
|
11806
11854
|
const payload = boundedPayload3(incoming.payload);
|
|
11807
11855
|
const role = expectedRole(incoming);
|
|
11808
11856
|
const text = incoming.text ?? null;
|
|
11857
|
+
const modelContext = normalizedModelContext(incoming);
|
|
11809
11858
|
assertBoundedString(text, SESSION_REALTIME_LEDGER_MAX_TEXT_BYTES, "Realtime text");
|
|
11810
11859
|
if ((incoming.kind === "user_transcript" || incoming.kind === "assistant_transcript") && !text) {
|
|
11811
11860
|
throw new Error("Finalized realtime transcript text is required");
|
|
@@ -11830,7 +11879,7 @@ async function syncSessionRealtimeLedgerInTransaction(db, input, hooks = {}) {
|
|
|
11830
11879
|
)
|
|
11831
11880
|
).limit(1);
|
|
11832
11881
|
if (existing) {
|
|
11833
|
-
if (!inboundReplayMatches(existing, incoming, role, text, payload)) {
|
|
11882
|
+
if (!inboundReplayMatches(existing, incoming, role, text, payload, modelContext) || !await delegationModelContextMatches(db, existing, modelContext)) {
|
|
11834
11883
|
throw new SessionRealtimeConflictError(
|
|
11835
11884
|
incoming.kind === "delegation_call" ? "REALTIME_DELEGATION_CHANGED" : "REALTIME_ENTRY_CHANGED",
|
|
11836
11885
|
"Realtime ledger operation was already used with different input"
|
|
@@ -11857,6 +11906,7 @@ async function syncSessionRealtimeLedgerInTransaction(db, input, hooks = {}) {
|
|
|
11857
11906
|
textCodecVersion: LOSSLESS_CONTENT_CODEC_VERSION,
|
|
11858
11907
|
payload,
|
|
11859
11908
|
payloadCodecVersion: LOSSLESS_CONTENT_CODEC_VERSION,
|
|
11909
|
+
modelContext,
|
|
11860
11910
|
createdAt: now,
|
|
11861
11911
|
updatedAt: now
|
|
11862
11912
|
}).returning();
|
|
@@ -11879,7 +11929,8 @@ async function syncSessionRealtimeLedgerInTransaction(db, input, hooks = {}) {
|
|
|
11879
11929
|
input,
|
|
11880
11930
|
modeRow.accountId,
|
|
11881
11931
|
incoming,
|
|
11882
|
-
entry.id
|
|
11932
|
+
entry.id,
|
|
11933
|
+
modelContext
|
|
11883
11934
|
);
|
|
11884
11935
|
const [linked] = await db.update(sessionRealtimeEntries).set({ turnId: admission.turnId, updatedAt: now }).where(eq16(sessionRealtimeEntries.id, entry.id)).returning();
|
|
11885
11936
|
if (!linked) throw new Error("Failed to link realtime delegation turn");
|
|
@@ -18976,6 +19027,7 @@ import {
|
|
|
18976
19027
|
KnowledgeSourceSyncAction,
|
|
18977
19028
|
KnowledgeSourceSyncRunSummary
|
|
18978
19029
|
} from "@opengeni/contracts";
|
|
19030
|
+
import { createHash as createHash16 } from "crypto";
|
|
18979
19031
|
import { and as and23, eq as eq24, inArray as inArray13, sql as sql21 } from "drizzle-orm";
|
|
18980
19032
|
function compareCanonicalDecimalProviderRevisions(candidate, floor) {
|
|
18981
19033
|
if (candidate === floor) return 0;
|
|
@@ -19818,6 +19870,260 @@ async function recordKnowledgeSourceSyncAclEvidence(db, input) {
|
|
|
19818
19870
|
}
|
|
19819
19871
|
);
|
|
19820
19872
|
}
|
|
19873
|
+
async function recordGoogleDriveObjectAclEvidence(db, input) {
|
|
19874
|
+
const observedAt = exactDate(input.observedAt, "Google Drive ACL observedAt");
|
|
19875
|
+
const expiresAt = exactDate(input.expiresAt, "Google Drive ACL expiresAt");
|
|
19876
|
+
if (expiresAt.getTime() <= observedAt.getTime()) {
|
|
19877
|
+
throw new Error("Google Drive ACL evidence must expire after it was observed");
|
|
19878
|
+
}
|
|
19879
|
+
if (input.principals.length > 1e3) {
|
|
19880
|
+
throw new Error("Google Drive ACL evidence exceeds 1000 principals");
|
|
19881
|
+
}
|
|
19882
|
+
const principals = input.principals.map(normalizeGoogleDriveAclPrincipal);
|
|
19883
|
+
const canonicalAcl = principals.map((principal) => JSON.stringify(principal)).sort((left, right) => left.localeCompare(right));
|
|
19884
|
+
const aclHash = sha256Hex(JSON.stringify(canonicalAcl));
|
|
19885
|
+
const sourcePrincipalHash = principalHash("permission", input.sourceGooglePermissionId);
|
|
19886
|
+
const inputHash = sha256Hex(
|
|
19887
|
+
JSON.stringify({
|
|
19888
|
+
version: 1,
|
|
19889
|
+
obligationId: input.obligationId,
|
|
19890
|
+
connectionId: input.connectionId,
|
|
19891
|
+
connectionVersion: input.connectionVersion,
|
|
19892
|
+
sourcePrincipalHash,
|
|
19893
|
+
sourceSyncGeneration: input.sourceSyncGeneration,
|
|
19894
|
+
sourceConfigGeneration: input.sourceConfigGeneration,
|
|
19895
|
+
sourceLifecycleGeneration: input.sourceLifecycleGeneration,
|
|
19896
|
+
objectLifecycleGeneration: input.objectLifecycleGeneration,
|
|
19897
|
+
objectVersionGeneration: input.objectVersionGeneration,
|
|
19898
|
+
providerRevision: input.providerRevision,
|
|
19899
|
+
driveId: input.driveId,
|
|
19900
|
+
aclRevision: input.aclRevision,
|
|
19901
|
+
aclHash,
|
|
19902
|
+
eligibility: input.eligibility,
|
|
19903
|
+
observedAt: observedAt.toISOString(),
|
|
19904
|
+
expiresAt: expiresAt.toISOString(),
|
|
19905
|
+
citationLocator: input.citationLocator
|
|
19906
|
+
})
|
|
19907
|
+
);
|
|
19908
|
+
return await withRlsContext(
|
|
19909
|
+
db,
|
|
19910
|
+
{ accountId: input.accountId, workspaceId: input.workspaceId },
|
|
19911
|
+
async (scopedDb) => await scopedDb.transaction(async (tx) => {
|
|
19912
|
+
const [observedObligation] = await tx.select().from(knowledgeSourceSyncIndexObligations).where(eq24(knowledgeSourceSyncIndexObligations.id, input.obligationId)).limit(1);
|
|
19913
|
+
if (!observedObligation) {
|
|
19914
|
+
throw new Error("Google Drive ACL evidence obligation was not found");
|
|
19915
|
+
}
|
|
19916
|
+
await setSubjectRlsContext(tx, observedObligation.initiatingSubjectId);
|
|
19917
|
+
const [state] = await tx.select().from(knowledgeSourceSyncStates).where(eq24(knowledgeSourceSyncStates.sourceId, observedObligation.sourceId)).for("update").limit(1);
|
|
19918
|
+
if (!state) throw new Error("Google Drive sync authorization is no longer active");
|
|
19919
|
+
await tx.execute(sql21`
|
|
19920
|
+
SELECT knowledge_source_sync_lock_authority(
|
|
19921
|
+
${input.accountId}::uuid,
|
|
19922
|
+
${observedObligation.sourceId}::uuid,
|
|
19923
|
+
${observedObligation.knowledgeSourceObjectId}::uuid
|
|
19924
|
+
)
|
|
19925
|
+
`);
|
|
19926
|
+
const [[source], [object], [version], [obligation], [connection]] = await Promise.all([
|
|
19927
|
+
tx.select().from(knowledgeSources).where(eq24(knowledgeSources.id, observedObligation.sourceId)).limit(1),
|
|
19928
|
+
tx.select().from(knowledgeSourceObjects).where(eq24(knowledgeSourceObjects.id, observedObligation.knowledgeSourceObjectId)).limit(1),
|
|
19929
|
+
tx.select().from(knowledgeDocumentVersions).where(
|
|
19930
|
+
eq24(
|
|
19931
|
+
knowledgeDocumentVersions.id,
|
|
19932
|
+
observedObligation.knowledgeDocumentVersionId
|
|
19933
|
+
)
|
|
19934
|
+
).limit(1),
|
|
19935
|
+
tx.select().from(knowledgeSourceSyncIndexObligations).where(eq24(knowledgeSourceSyncIndexObligations.id, input.obligationId)).for("update").limit(1),
|
|
19936
|
+
tx.select().from(connections).where(eq24(connections.id, input.connectionId)).limit(1)
|
|
19937
|
+
]);
|
|
19938
|
+
const [provider] = source ? await tx.select().from(knowledgeProviders).where(eq24(knowledgeProviders.id, source.providerId)).limit(1) : [];
|
|
19939
|
+
const [document] = obligation ? await tx.select().from(documents).where(eq24(documents.id, obligation.documentId)).for("update").limit(1) : [];
|
|
19940
|
+
const metadata = connection?.metadata ?? {};
|
|
19941
|
+
const connectionPermissionId = cleanBoundedString(metadata.googlePermissionId, 256);
|
|
19942
|
+
const connectionLifecycle = metadata.lifecycle && typeof metadata.lifecycle === "object" ? cleanBoundedString(metadata.lifecycle.state, 64) : null;
|
|
19943
|
+
const hasDriveReadScope = Array.isArray(connection?.grantedScopes) && connection.grantedScopes.some(
|
|
19944
|
+
(scope) => scope === "https://www.googleapis.com/auth/drive" || scope === "https://www.googleapis.com/auth/drive.readonly"
|
|
19945
|
+
);
|
|
19946
|
+
if (!obligation || !source || !object || !version || !provider || !document || !connection || provider.providerKey !== "google-drive" || provider.lifecycleState !== "active" || state.connectionId !== input.connectionId || state.connectionProviderDomain !== "googleapis.com" || state.connectionKind !== "oauth2" || state.connectionOwnerSubjectId !== connection.subjectId || state.reconnectRequired || connection.accountId !== input.accountId || connection.subjectId !== observedObligation.initiatingSubjectId || connection.providerDomain !== "googleapis.com" || connection.kind !== "oauth2" || connection.status !== "active" || connection.version !== input.connectionVersion || connection.version < state.connectionVersion || metadata.accessMode !== "readonly" || connectionLifecycle !== null && connectionLifecycle !== "active" || !hasDriveReadScope || !connectionPermissionId || principalHash("permission", connectionPermissionId) !== sourcePrincipalHash || input.sourceSyncGeneration !== obligation.sourceSyncGeneration || state.sourceSyncGeneration < obligation.sourceSyncGeneration || state.sourceConfigGeneration !== input.sourceConfigGeneration || state.sourceConfigGeneration !== obligation.sourceConfigGeneration || state.sourceLifecycleGeneration !== input.sourceLifecycleGeneration || state.sourceLifecycleGeneration !== obligation.sourceLifecycleGeneration || source.lifecycleState !== "active" || source.syncGeneration < obligation.sourceSyncGeneration || source.lifecycleGeneration !== obligation.sourceLifecycleGeneration || source.currentAclGeneration !== version.aclGeneration || object.sourceId !== obligation.sourceId || object.externalObjectId !== obligation.externalObjectId || object.lifecycleState !== "active" || object.lifecycleGeneration !== obligation.objectLifecycleGeneration || object.versionGeneration !== obligation.objectVersionGeneration || object.currentVersionId !== obligation.knowledgeDocumentVersionId || version.sourceId !== obligation.sourceId || version.objectId !== obligation.knowledgeSourceObjectId || version.versionGeneration !== obligation.objectVersionGeneration || version.documentId !== obligation.documentId || version.fileId !== document.fileId || document.accountId !== input.accountId || document.workspaceId !== input.workspaceId || document.sourceExternalId !== obligation.externalObjectId || !document.knowledgeSourceIdentity || obligation.sourceLifecycleGeneration !== input.sourceLifecycleGeneration || obligation.objectLifecycleGeneration !== input.objectLifecycleGeneration || obligation.objectVersionGeneration !== input.objectVersionGeneration) {
|
|
19947
|
+
throw new Error("Google Drive ACL evidence authority changed");
|
|
19948
|
+
}
|
|
19949
|
+
if (input.eligibility === "eligible" && obligation.status !== "indexed") {
|
|
19950
|
+
throw new Error("Google Drive ACL eligibility requires a completed index obligation");
|
|
19951
|
+
}
|
|
19952
|
+
const evidenceValues = {
|
|
19953
|
+
accountId: input.accountId,
|
|
19954
|
+
workspaceId: input.workspaceId,
|
|
19955
|
+
sourceId: obligation.sourceId,
|
|
19956
|
+
knowledgeSourceObjectId: obligation.knowledgeSourceObjectId,
|
|
19957
|
+
knowledgeDocumentVersionId: obligation.knowledgeDocumentVersionId,
|
|
19958
|
+
documentId: obligation.documentId,
|
|
19959
|
+
fileId: document.fileId,
|
|
19960
|
+
indexObligationId: obligation.id,
|
|
19961
|
+
connectionId: input.connectionId,
|
|
19962
|
+
connectionVersion: input.connectionVersion,
|
|
19963
|
+
sourcePrincipalHash,
|
|
19964
|
+
sourceSyncGeneration: input.sourceSyncGeneration,
|
|
19965
|
+
sourceConfigGeneration: input.sourceConfigGeneration,
|
|
19966
|
+
sourceLifecycleGeneration: input.sourceLifecycleGeneration,
|
|
19967
|
+
objectLifecycleGeneration: input.objectLifecycleGeneration,
|
|
19968
|
+
objectVersionGeneration: input.objectVersionGeneration,
|
|
19969
|
+
providerRevision: input.providerRevision,
|
|
19970
|
+
driveId: cleanBoundedString(input.driveId, 1024),
|
|
19971
|
+
aclRevision: exactBoundedString(input.aclRevision, 1024, "Google Drive ACL revision"),
|
|
19972
|
+
aclHash,
|
|
19973
|
+
eligibility: input.eligibility,
|
|
19974
|
+
observedAt,
|
|
19975
|
+
expiresAt,
|
|
19976
|
+
citationLocator: input.citationLocator,
|
|
19977
|
+
operationId: exactBoundedString(input.operationId, 256, "Google Drive ACL operation id"),
|
|
19978
|
+
inputHash
|
|
19979
|
+
};
|
|
19980
|
+
const [inserted] = await tx.insert(googleDriveObjectAclEvidence).values(evidenceValues).onConflictDoNothing({
|
|
19981
|
+
target: [
|
|
19982
|
+
googleDriveObjectAclEvidence.indexObligationId,
|
|
19983
|
+
googleDriveObjectAclEvidence.operationId
|
|
19984
|
+
]
|
|
19985
|
+
}).returning();
|
|
19986
|
+
const [evidence] = inserted ? [inserted] : await tx.select().from(googleDriveObjectAclEvidence).where(
|
|
19987
|
+
and23(
|
|
19988
|
+
eq24(googleDriveObjectAclEvidence.indexObligationId, obligation.id),
|
|
19989
|
+
eq24(googleDriveObjectAclEvidence.operationId, evidenceValues.operationId)
|
|
19990
|
+
)
|
|
19991
|
+
).limit(1);
|
|
19992
|
+
if (!evidence || evidence.inputHash !== inputHash) {
|
|
19993
|
+
throw new Error("Google Drive ACL evidence operation conflicted");
|
|
19994
|
+
}
|
|
19995
|
+
if (inserted && principals.length > 0) {
|
|
19996
|
+
await tx.insert(googleDriveObjectAclPrincipals).values(
|
|
19997
|
+
principals.map((principal, ordinal) => ({
|
|
19998
|
+
evidenceId: evidence.id,
|
|
19999
|
+
ordinal,
|
|
20000
|
+
accountId: input.accountId,
|
|
20001
|
+
workspaceId: input.workspaceId,
|
|
20002
|
+
...principal
|
|
20003
|
+
}))
|
|
20004
|
+
);
|
|
20005
|
+
}
|
|
20006
|
+
const now = /* @__PURE__ */ new Date();
|
|
20007
|
+
await tx.update(knowledgeSourceSyncIndexObligations).set({
|
|
20008
|
+
googleDriveAclEvidenceId: evidence.id,
|
|
20009
|
+
aclEligibility: input.eligibility,
|
|
20010
|
+
updatedAt: now
|
|
20011
|
+
}).where(eq24(knowledgeSourceSyncIndexObligations.id, obligation.id));
|
|
20012
|
+
await tx.update(knowledgeSourceSyncItemOutcomes).set({
|
|
20013
|
+
aclEligibility: input.eligibility,
|
|
20014
|
+
aclEvidence: {
|
|
20015
|
+
version: 1,
|
|
20016
|
+
provider: "google_drive",
|
|
20017
|
+
evidenceId: evidence.id,
|
|
20018
|
+
aclRevision: evidence.aclRevision,
|
|
20019
|
+
observedAt: evidence.observedAt.toISOString(),
|
|
20020
|
+
expiresAt: evidence.expiresAt.toISOString()
|
|
20021
|
+
}
|
|
20022
|
+
}).where(eq24(knowledgeSourceSyncItemOutcomes.indexObligationId, obligation.id));
|
|
20023
|
+
const [updatedDocument] = await tx.update(documents).set({
|
|
20024
|
+
agentAccess: input.eligibility === "eligible",
|
|
20025
|
+
...input.eligibility === "denied" ? { chunkCount: 0 } : {},
|
|
20026
|
+
updatedAt: now
|
|
20027
|
+
}).where(eq24(documents.id, obligation.documentId)).returning({ id: documents.id });
|
|
20028
|
+
if (!updatedDocument) {
|
|
20029
|
+
throw new Error("Google Drive ACL evidence document authority changed");
|
|
20030
|
+
}
|
|
20031
|
+
if (input.eligibility === "denied") {
|
|
20032
|
+
await tx.delete(documentChunks).where(eq24(documentChunks.documentId, obligation.documentId));
|
|
20033
|
+
}
|
|
20034
|
+
return { evidenceId: evidence.id, aclHash };
|
|
20035
|
+
})
|
|
20036
|
+
);
|
|
20037
|
+
}
|
|
20038
|
+
async function beginGoogleDriveObjectAclRefresh(db, input) {
|
|
20039
|
+
await withRlsContext(
|
|
20040
|
+
db,
|
|
20041
|
+
{ accountId: input.accountId, workspaceId: input.workspaceId },
|
|
20042
|
+
async (scopedDb) => await scopedDb.transaction(async (tx) => {
|
|
20043
|
+
const [observed] = await tx.select().from(knowledgeSourceSyncIndexObligations).where(eq24(knowledgeSourceSyncIndexObligations.id, input.obligationId)).limit(1);
|
|
20044
|
+
if (!observed) throw new Error("Google Drive ACL refresh obligation was not found");
|
|
20045
|
+
await setSubjectRlsContext(tx, observed.initiatingSubjectId);
|
|
20046
|
+
const [state] = await tx.select().from(knowledgeSourceSyncStates).where(eq24(knowledgeSourceSyncStates.sourceId, observed.sourceId)).for("update").limit(1);
|
|
20047
|
+
if (!state) throw new Error("Google Drive sync authorization is no longer active");
|
|
20048
|
+
await tx.execute(sql21`
|
|
20049
|
+
SELECT knowledge_source_sync_lock_authority(
|
|
20050
|
+
${input.accountId}::uuid,
|
|
20051
|
+
${observed.sourceId}::uuid,
|
|
20052
|
+
${observed.knowledgeSourceObjectId}::uuid
|
|
20053
|
+
)
|
|
20054
|
+
`);
|
|
20055
|
+
const [[source], [object], [version], [obligation]] = await Promise.all([
|
|
20056
|
+
tx.select().from(knowledgeSources).where(eq24(knowledgeSources.id, observed.sourceId)).limit(1),
|
|
20057
|
+
tx.select().from(knowledgeSourceObjects).where(eq24(knowledgeSourceObjects.id, observed.knowledgeSourceObjectId)).limit(1),
|
|
20058
|
+
tx.select().from(knowledgeDocumentVersions).where(eq24(knowledgeDocumentVersions.id, observed.knowledgeDocumentVersionId)).limit(1),
|
|
20059
|
+
tx.select().from(knowledgeSourceSyncIndexObligations).where(eq24(knowledgeSourceSyncIndexObligations.id, input.obligationId)).for("update").limit(1)
|
|
20060
|
+
]);
|
|
20061
|
+
const [document] = obligation ? await tx.select().from(documents).where(eq24(documents.id, obligation.documentId)).for("update").limit(1) : [];
|
|
20062
|
+
if (!source || !object || !version || !obligation || !document || state.reconnectRequired || state.sourceSyncGeneration < input.sourceSyncGeneration || state.sourceConfigGeneration !== input.sourceConfigGeneration || state.sourceLifecycleGeneration !== input.sourceLifecycleGeneration || source.lifecycleState !== "active" || source.syncGeneration < obligation.sourceSyncGeneration || source.lifecycleGeneration !== input.sourceLifecycleGeneration || source.currentAclGeneration !== version.aclGeneration || object.lifecycleState !== "active" || object.lifecycleGeneration !== input.objectLifecycleGeneration || object.versionGeneration !== input.objectVersionGeneration || object.currentVersionId !== version.id || version.documentId !== document.id || version.fileId !== document.fileId || obligation.sourceSyncGeneration !== input.sourceSyncGeneration || obligation.sourceConfigGeneration !== input.sourceConfigGeneration || obligation.sourceLifecycleGeneration !== input.sourceLifecycleGeneration || obligation.objectLifecycleGeneration !== input.objectLifecycleGeneration || obligation.objectVersionGeneration !== input.objectVersionGeneration || obligation.status !== "indexed") {
|
|
20063
|
+
throw new Error("Google Drive ACL refresh authority changed");
|
|
20064
|
+
}
|
|
20065
|
+
const now = /* @__PURE__ */ new Date();
|
|
20066
|
+
await tx.update(knowledgeSourceSyncIndexObligations).set({
|
|
20067
|
+
googleDriveAclEvidenceId: null,
|
|
20068
|
+
aclEligibility: "denied",
|
|
20069
|
+
updatedAt: now
|
|
20070
|
+
}).where(eq24(knowledgeSourceSyncIndexObligations.id, obligation.id));
|
|
20071
|
+
await tx.update(knowledgeSourceSyncItemOutcomes).set({
|
|
20072
|
+
aclEligibility: "denied",
|
|
20073
|
+
aclEvidence: { version: 1, provider: "google_drive", state: "refresh_pending" }
|
|
20074
|
+
}).where(eq24(knowledgeSourceSyncItemOutcomes.indexObligationId, obligation.id));
|
|
20075
|
+
await tx.update(documents).set({ agentAccess: false, updatedAt: now }).where(eq24(documents.id, obligation.documentId));
|
|
20076
|
+
})
|
|
20077
|
+
);
|
|
20078
|
+
}
|
|
20079
|
+
function normalizeGoogleDriveAclPrincipal(principal) {
|
|
20080
|
+
const permissionId = cleanBoundedString(principal.permissionId, 1024);
|
|
20081
|
+
const emailAddress = cleanBoundedString(principal.emailAddress, 320)?.toLowerCase() ?? null;
|
|
20082
|
+
const domain = cleanBoundedString(principal.domain, 320)?.toLowerCase() ?? null;
|
|
20083
|
+
if (principal.type === "user" || principal.type === "group") {
|
|
20084
|
+
if (!permissionId && !emailAddress) {
|
|
20085
|
+
throw new Error(`Google Drive ${principal.type} principal is missing identity`);
|
|
20086
|
+
}
|
|
20087
|
+
} else if (principal.type === "domain") {
|
|
20088
|
+
if (!domain) throw new Error("Google Drive domain principal is missing its domain");
|
|
20089
|
+
} else if (principal.type !== "anyone") {
|
|
20090
|
+
throw new Error("Google Drive ACL principal type is invalid");
|
|
20091
|
+
}
|
|
20092
|
+
const expirationTime = principal.expirationTime ? exactDate(principal.expirationTime, "Google Drive ACL principal expiration") : null;
|
|
20093
|
+
return {
|
|
20094
|
+
principalType: principal.type,
|
|
20095
|
+
permissionIdHash: permissionId ? principalHash("permission", permissionId) : null,
|
|
20096
|
+
emailHash: emailAddress ? principalHash("email", emailAddress) : null,
|
|
20097
|
+
domainHash: domain ? principalHash("domain", domain) : null,
|
|
20098
|
+
role: principal.role,
|
|
20099
|
+
inherited: principal.inherited === true,
|
|
20100
|
+
allowFileDiscovery: principal.allowFileDiscovery === void 0 ? null : principal.allowFileDiscovery,
|
|
20101
|
+
expirationTime
|
|
20102
|
+
};
|
|
20103
|
+
}
|
|
20104
|
+
function principalHash(kind, value) {
|
|
20105
|
+
return sha256Hex(`${kind}:${value.trim().toLowerCase()}`);
|
|
20106
|
+
}
|
|
20107
|
+
function sha256Hex(value) {
|
|
20108
|
+
return createHash16("sha256").update(value).digest("hex");
|
|
20109
|
+
}
|
|
20110
|
+
function exactDate(value, label) {
|
|
20111
|
+
const parsed = new Date(value);
|
|
20112
|
+
if (!value || !Number.isFinite(parsed.getTime()) || parsed.toISOString() !== value) {
|
|
20113
|
+
throw new Error(`${label} must be an exact UTC timestamp`);
|
|
20114
|
+
}
|
|
20115
|
+
return parsed;
|
|
20116
|
+
}
|
|
20117
|
+
function exactBoundedString(value, max, label) {
|
|
20118
|
+
const normalized = cleanBoundedString(value, max);
|
|
20119
|
+
if (!normalized || normalized !== value) throw new Error(`${label} is invalid`);
|
|
20120
|
+
return normalized;
|
|
20121
|
+
}
|
|
20122
|
+
function cleanBoundedString(value, max) {
|
|
20123
|
+
if (typeof value !== "string") return null;
|
|
20124
|
+
const normalized = value.trim();
|
|
20125
|
+
return normalized && normalized.length <= max ? normalized : null;
|
|
20126
|
+
}
|
|
19821
20127
|
async function pruneKnowledgeSourceSyncEvidence(db, input) {
|
|
19822
20128
|
const limit = Math.max(1, Math.min(input.limit ?? 500, 5e3));
|
|
19823
20129
|
return await withRlsContext(
|
|
@@ -20497,7 +20803,7 @@ function assertImageGenerationOperationMatches(operation, input) {
|
|
|
20497
20803
|
}
|
|
20498
20804
|
|
|
20499
20805
|
// src/slack-user-link-access.ts
|
|
20500
|
-
import { createHash as
|
|
20806
|
+
import { createHash as createHash17 } from "crypto";
|
|
20501
20807
|
import {
|
|
20502
20808
|
SlackUserLinkAccessRequest as SlackUserLinkAccessRequestSchema
|
|
20503
20809
|
} from "@opengeni/contracts";
|
|
@@ -20952,7 +21258,7 @@ function assertExactClaims(row, input) {
|
|
|
20952
21258
|
}
|
|
20953
21259
|
}
|
|
20954
21260
|
function digestOperation(value) {
|
|
20955
|
-
return
|
|
21261
|
+
return createHash17("sha256").update(JSON.stringify(value)).digest("hex");
|
|
20956
21262
|
}
|
|
20957
21263
|
function mapRequest(row) {
|
|
20958
21264
|
return {
|
|
@@ -20972,12 +21278,12 @@ function mapRequest(row) {
|
|
|
20972
21278
|
}
|
|
20973
21279
|
|
|
20974
21280
|
// src/capability-integrations.ts
|
|
20975
|
-
import { createHash as
|
|
21281
|
+
import { createHash as createHash19 } from "crypto";
|
|
20976
21282
|
import { stableJson as stableJson5 } from "@opengeni/contracts";
|
|
20977
21283
|
import { and as and27, asc as asc14, eq as eq28, inArray as inArray15, ne as ne2, or as or6, sql as sql25 } from "drizzle-orm";
|
|
20978
21284
|
|
|
20979
21285
|
// src/integration-bindings.ts
|
|
20980
|
-
import { createHash as
|
|
21286
|
+
import { createHash as createHash18 } from "crypto";
|
|
20981
21287
|
import { stableJson as stableJson4 } from "@opengeni/contracts";
|
|
20982
21288
|
import { and as and26, asc as asc13, eq as eq27, or as or5, sql as sql24 } from "drizzle-orm";
|
|
20983
21289
|
var IntegrationFacetBindingVersionConflictError = class extends Error {
|
|
@@ -21261,7 +21567,7 @@ function assertBindingKey(value) {
|
|
|
21261
21567
|
}
|
|
21262
21568
|
}
|
|
21263
21569
|
function sha2563(value) {
|
|
21264
|
-
return
|
|
21570
|
+
return createHash18("sha256").update(value).digest("hex");
|
|
21265
21571
|
}
|
|
21266
21572
|
|
|
21267
21573
|
// src/capability-integrations.ts
|
|
@@ -22276,11 +22582,11 @@ function stringValue(value) {
|
|
|
22276
22582
|
return typeof value === "string" && value.length > 0 ? value : void 0;
|
|
22277
22583
|
}
|
|
22278
22584
|
function sha2564(value) {
|
|
22279
|
-
return
|
|
22585
|
+
return createHash19("sha256").update(value).digest("hex");
|
|
22280
22586
|
}
|
|
22281
22587
|
|
|
22282
22588
|
// src/integration-facets.ts
|
|
22283
|
-
import { createHash as
|
|
22589
|
+
import { createHash as createHash20 } from "crypto";
|
|
22284
22590
|
import { stableJson as stableJson6 } from "@opengeni/contracts";
|
|
22285
22591
|
import { and as and28, asc as asc15, eq as eq29, ne as ne3, sql as sql26 } from "drizzle-orm";
|
|
22286
22592
|
var IntegrationFacetNotFoundError = class extends Error {
|
|
@@ -22845,7 +23151,7 @@ function objectValue2(value) {
|
|
|
22845
23151
|
return value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
22846
23152
|
}
|
|
22847
23153
|
function sha2565(value) {
|
|
22848
|
-
return
|
|
23154
|
+
return createHash20("sha256").update(value).digest("hex");
|
|
22849
23155
|
}
|
|
22850
23156
|
|
|
22851
23157
|
// src/insights.ts
|
|
@@ -24461,7 +24767,7 @@ async function cancelResponseBody(response) {
|
|
|
24461
24767
|
}
|
|
24462
24768
|
|
|
24463
24769
|
// src/pack-components.ts
|
|
24464
|
-
import { createHash as
|
|
24770
|
+
import { createHash as createHash21 } from "crypto";
|
|
24465
24771
|
import {
|
|
24466
24772
|
stableJson as stableJson7
|
|
24467
24773
|
} from "@opengeni/contracts";
|
|
@@ -25099,11 +25405,11 @@ function stringArray2(value) {
|
|
|
25099
25405
|
return Array.isArray(value) ? value.filter((entry) => typeof entry === "string") : [];
|
|
25100
25406
|
}
|
|
25101
25407
|
function sha2566(value) {
|
|
25102
|
-
return
|
|
25408
|
+
return createHash21("sha256").update(value).digest("hex");
|
|
25103
25409
|
}
|
|
25104
25410
|
|
|
25105
25411
|
// src/pack-installations.ts
|
|
25106
|
-
import { createHash as
|
|
25412
|
+
import { createHash as createHash22 } from "crypto";
|
|
25107
25413
|
import {
|
|
25108
25414
|
CapabilityPack as CapabilityPackSchema,
|
|
25109
25415
|
stableJson as stableJson8
|
|
@@ -25667,7 +25973,7 @@ async function assertRegisteredPackManifestCurrent(db, input) {
|
|
|
25667
25973
|
)
|
|
25668
25974
|
).for("update").limit(1);
|
|
25669
25975
|
const parsed = registration ? CapabilityPackSchema.safeParse(registration.manifest) : null;
|
|
25670
|
-
const currentDigest = parsed?.success === true ?
|
|
25976
|
+
const currentDigest = parsed?.success === true ? createHash22("sha256").update(stableJson8(parsed.data)).digest("hex") : null;
|
|
25671
25977
|
if (input.expectedDigest !== input.admittedDigest || currentDigest !== input.expectedDigest) {
|
|
25672
25978
|
throw new PackManifestChangedError(
|
|
25673
25979
|
"Pack manifest changed after preview; review the current installation plan"
|
|
@@ -25712,7 +26018,7 @@ function mapPackInstallation(row) {
|
|
|
25712
26018
|
}
|
|
25713
26019
|
|
|
25714
26020
|
// src/plugin-packages.ts
|
|
25715
|
-
import { createHash as
|
|
26021
|
+
import { createHash as createHash23 } from "crypto";
|
|
25716
26022
|
import { stableJson as stableJson9 } from "@opengeni/contracts";
|
|
25717
26023
|
import { and as and32, asc as asc17, eq as eq33, inArray as inArray19, ne as ne6, or as or8, sql as sql30 } from "drizzle-orm";
|
|
25718
26024
|
var PluginOperationIdempotencyError = class extends Error {
|
|
@@ -26502,7 +26808,7 @@ function safeHttpUrl(value) {
|
|
|
26502
26808
|
}
|
|
26503
26809
|
}
|
|
26504
26810
|
function sha2567(value) {
|
|
26505
|
-
return
|
|
26811
|
+
return createHash23("sha256").update(value).digest("hex");
|
|
26506
26812
|
}
|
|
26507
26813
|
|
|
26508
26814
|
// src/workspace-artifacts.ts
|
|
@@ -28012,7 +28318,7 @@ async function purgeExpiredTranscriptionRecordings(db, input) {
|
|
|
28012
28318
|
}
|
|
28013
28319
|
|
|
28014
28320
|
// src/editable-artifact-materialization.ts
|
|
28015
|
-
import { createHash as
|
|
28321
|
+
import { createHash as createHash24 } from "crypto";
|
|
28016
28322
|
import { EDITABLE_ARTIFACT_KERNEL_VERSION_MAX_BYTES } from "@opengeni/contracts/editable-artifacts";
|
|
28017
28323
|
import { sql as sql33 } from "drizzle-orm";
|
|
28018
28324
|
var EDITABLE_ARTIFACT_MATERIALIZATION_MAX_CLAIM = 1e3;
|
|
@@ -28488,7 +28794,7 @@ function validateDatabaseNormalizedOptions(value, expectedHash) {
|
|
|
28488
28794
|
} catch (error) {
|
|
28489
28795
|
throw contractViolation("Materialization row contains invalid normalized options", error);
|
|
28490
28796
|
}
|
|
28491
|
-
const actualHash = `sha256:${
|
|
28797
|
+
const actualHash = `sha256:${createHash24("sha256").update(normalized, "utf8").digest("hex")}`;
|
|
28492
28798
|
if (actualHash !== expectedHash) {
|
|
28493
28799
|
throw contractViolation("Materialization options hash does not bind its exact canonical bytes");
|
|
28494
28800
|
}
|
|
@@ -28645,7 +28951,7 @@ async function attemptToolCatalogByAttemptTx(tx, workspaceId, attemptId) {
|
|
|
28645
28951
|
}
|
|
28646
28952
|
|
|
28647
28953
|
// src/browser-sessions.ts
|
|
28648
|
-
import { createHash as
|
|
28954
|
+
import { createHash as createHash25, randomUUID as randomUUID7 } from "crypto";
|
|
28649
28955
|
import {
|
|
28650
28956
|
BrowserSession,
|
|
28651
28957
|
BrowserSessionCapabilities,
|
|
@@ -29117,7 +29423,7 @@ async function loadOperation2(db, workspaceId, operationId) {
|
|
|
29117
29423
|
return row ?? null;
|
|
29118
29424
|
}
|
|
29119
29425
|
function requestDigest(value) {
|
|
29120
|
-
return
|
|
29426
|
+
return createHash25("sha256").update(JSON.stringify(value)).digest("hex");
|
|
29121
29427
|
}
|
|
29122
29428
|
function browserSessionCreateRequestDigest(input) {
|
|
29123
29429
|
const revisionSelection = input.identityId ? input.resolveDefaultRevision ? { kind: "identity_default" } : input.baseRevisionId ? { kind: "exact", revisionId: input.baseRevisionId } : { kind: "blank_identity" } : { kind: "none" };
|
|
@@ -30469,7 +30775,7 @@ function postgresConstraint2(error) {
|
|
|
30469
30775
|
}
|
|
30470
30776
|
|
|
30471
30777
|
// src/computer-sessions.ts
|
|
30472
|
-
import { createHash as
|
|
30778
|
+
import { createHash as createHash26, randomUUID as randomUUID8 } from "crypto";
|
|
30473
30779
|
import {
|
|
30474
30780
|
ComputerSession,
|
|
30475
30781
|
ComputerSessionCapabilities,
|
|
@@ -30614,7 +30920,7 @@ async function loadOperation3(db, workspaceId, operationId) {
|
|
|
30614
30920
|
return row ?? null;
|
|
30615
30921
|
}
|
|
30616
30922
|
function requestDigest2(value) {
|
|
30617
|
-
return
|
|
30923
|
+
return createHash26("sha256").update(JSON.stringify(value)).digest("hex");
|
|
30618
30924
|
}
|
|
30619
30925
|
function computerSessionCreateRequestDigest(input) {
|
|
30620
30926
|
return requestDigest2({
|
|
@@ -31275,7 +31581,7 @@ function assertOperationResource2(operation, computerSessionId, kind) {
|
|
|
31275
31581
|
}
|
|
31276
31582
|
|
|
31277
31583
|
// src/browser-identities.ts
|
|
31278
|
-
import { createHash as
|
|
31584
|
+
import { createHash as createHash27, randomUUID as randomUUID9 } from "crypto";
|
|
31279
31585
|
import {
|
|
31280
31586
|
BrowserIdentity,
|
|
31281
31587
|
BrowserIdentityListResponse,
|
|
@@ -31512,7 +31818,7 @@ async function updateBrowserIdentity(db, input) {
|
|
|
31512
31818
|
...input.defaultRevisionId !== void 0 ? { defaultRevisionId: input.defaultRevisionId } : {}
|
|
31513
31819
|
});
|
|
31514
31820
|
const { operationId: _operationId, ...digestRequest } = request;
|
|
31515
|
-
const requestDigest4 =
|
|
31821
|
+
const requestDigest4 = createHash27("sha256").update(
|
|
31516
31822
|
JSON.stringify({
|
|
31517
31823
|
version: 1,
|
|
31518
31824
|
identityId: input.identityId,
|
|
@@ -31623,7 +31929,7 @@ async function updateBrowserIdentity(db, input) {
|
|
|
31623
31929
|
}
|
|
31624
31930
|
}
|
|
31625
31931
|
function browserRevisionPublicationRequestDigest(input) {
|
|
31626
|
-
return
|
|
31932
|
+
return createHash27("sha256").update(
|
|
31627
31933
|
JSON.stringify({
|
|
31628
31934
|
version: 1,
|
|
31629
31935
|
browserSessionId: input.browserSessionId,
|
|
@@ -32226,7 +32532,7 @@ function postgresConstraint3(error) {
|
|
|
32226
32532
|
}
|
|
32227
32533
|
|
|
32228
32534
|
// src/browser-downloads.ts
|
|
32229
|
-
import { createHash as
|
|
32535
|
+
import { createHash as createHash28 } from "crypto";
|
|
32230
32536
|
import {
|
|
32231
32537
|
BrowserDownload,
|
|
32232
32538
|
BrowserDownloadSaveRequest,
|
|
@@ -32464,7 +32770,7 @@ function parseIdentity(input) {
|
|
|
32464
32770
|
};
|
|
32465
32771
|
}
|
|
32466
32772
|
function requestDigest3(input) {
|
|
32467
|
-
return
|
|
32773
|
+
return createHash28("sha256").update(
|
|
32468
32774
|
JSON.stringify({
|
|
32469
32775
|
browserSessionId: input.browserSessionId,
|
|
32470
32776
|
destinationPath: input.request.destinationPath,
|
|
@@ -34835,6 +35141,57 @@ async function requireFile(db, workspaceId, fileId) {
|
|
|
34835
35141
|
}
|
|
34836
35142
|
return file;
|
|
34837
35143
|
}
|
|
35144
|
+
async function requireFileForSubject(db, input) {
|
|
35145
|
+
return await withRlsContext(
|
|
35146
|
+
db,
|
|
35147
|
+
{ accountId: input.accountId, workspaceId: input.workspaceId },
|
|
35148
|
+
async (scopedDb) => {
|
|
35149
|
+
if (input.subjectId) await setSubjectRlsContext(scopedDb, input.subjectId);
|
|
35150
|
+
const subjectIdSql = input.subjectId === null ? sql39`NULL::text` : sql39`${input.subjectId}`;
|
|
35151
|
+
const [row] = await scopedDb.select().from(files).where(
|
|
35152
|
+
and42(
|
|
35153
|
+
eq43(files.accountId, input.accountId),
|
|
35154
|
+
eq43(files.workspaceId, input.workspaceId),
|
|
35155
|
+
eq43(files.id, input.fileId),
|
|
35156
|
+
sql39`google_drive_file_authorized(
|
|
35157
|
+
${input.accountId}::uuid,
|
|
35158
|
+
${input.workspaceId}::uuid,
|
|
35159
|
+
${subjectIdSql},
|
|
35160
|
+
${input.fileId}::uuid
|
|
35161
|
+
)`
|
|
35162
|
+
)
|
|
35163
|
+
).limit(1);
|
|
35164
|
+
if (!row) throw new Error(`File not found: ${input.fileId}`);
|
|
35165
|
+
return mapFile2(row);
|
|
35166
|
+
}
|
|
35167
|
+
);
|
|
35168
|
+
}
|
|
35169
|
+
async function getFilesForSubject(db, input) {
|
|
35170
|
+
const ids = [...new Set(input.fileIds)];
|
|
35171
|
+
if (ids.length === 0) return [];
|
|
35172
|
+
return await withRlsContext(
|
|
35173
|
+
db,
|
|
35174
|
+
{ accountId: input.accountId, workspaceId: input.workspaceId },
|
|
35175
|
+
async (scopedDb) => {
|
|
35176
|
+
if (input.subjectId) await setSubjectRlsContext(scopedDb, input.subjectId);
|
|
35177
|
+
const subjectIdSql = input.subjectId === null ? sql39`NULL::text` : sql39`${input.subjectId}`;
|
|
35178
|
+
const rows = await scopedDb.select().from(files).where(
|
|
35179
|
+
and42(
|
|
35180
|
+
eq43(files.accountId, input.accountId),
|
|
35181
|
+
eq43(files.workspaceId, input.workspaceId),
|
|
35182
|
+
inArray25(files.id, ids),
|
|
35183
|
+
sql39`google_drive_file_authorized(
|
|
35184
|
+
${input.accountId}::uuid,
|
|
35185
|
+
${input.workspaceId}::uuid,
|
|
35186
|
+
${subjectIdSql},
|
|
35187
|
+
${files.id}
|
|
35188
|
+
)`
|
|
35189
|
+
)
|
|
35190
|
+
);
|
|
35191
|
+
return rows.map(mapFile2);
|
|
35192
|
+
}
|
|
35193
|
+
);
|
|
35194
|
+
}
|
|
34838
35195
|
async function getFiles(db, workspaceId, fileIds) {
|
|
34839
35196
|
const ids = [...new Set(fileIds)];
|
|
34840
35197
|
if (ids.length === 0) return [];
|
|
@@ -34843,14 +35200,14 @@ async function getFiles(db, workspaceId, fileIds) {
|
|
|
34843
35200
|
return rows.map(mapFile2);
|
|
34844
35201
|
});
|
|
34845
35202
|
}
|
|
34846
|
-
function durableUserHistoryItem(prompt, resources, annotations = []) {
|
|
35203
|
+
function durableUserHistoryItem(prompt, resources, annotations = [], modelContext) {
|
|
34847
35204
|
const attachmentRefs = resources.filter(
|
|
34848
35205
|
(resource) => resource.kind === "file"
|
|
34849
35206
|
);
|
|
34850
35207
|
return {
|
|
34851
35208
|
type: "message",
|
|
34852
35209
|
role: "user",
|
|
34853
|
-
content:
|
|
35210
|
+
content: renderUserMessageContentForModel(prompt, annotations, modelContext),
|
|
34854
35211
|
...attachmentRefs.length > 0 ? { [MODEL_ATTACHMENT_REFS_FIELD]: attachmentRefs } : {},
|
|
34855
35212
|
...annotations.length > 0 ? {
|
|
34856
35213
|
[MODEL_TIMELINE_ANNOTATIONS_FIELD]: TimelineAnnotations2.parse(annotations)
|
|
@@ -35946,7 +36303,7 @@ async function installPortableSkill(db, input) {
|
|
|
35946
36303
|
fileCount: input.files.length,
|
|
35947
36304
|
totalBytes: input.totalBytes
|
|
35948
36305
|
};
|
|
35949
|
-
const manifestDigest =
|
|
36306
|
+
const manifestDigest = createHash29("sha256").update(stableJson10(manifest)).digest("hex");
|
|
35950
36307
|
const [versionByName] = await tx.select().from(capabilityPluginVersions).where(
|
|
35951
36308
|
and42(
|
|
35952
36309
|
eq43(capabilityPluginVersions.pluginId, plugin.id),
|
|
@@ -41436,7 +41793,7 @@ async function retainRigProviderImageArtifacts(db, workspaceId, images) {
|
|
|
41436
41793
|
inArray25(sandboxCheckpointArtifacts.state, ["candidate", "current"])
|
|
41437
41794
|
)
|
|
41438
41795
|
).for("update").limit(1);
|
|
41439
|
-
const bindingHash = artifact ? `sha256:${
|
|
41796
|
+
const bindingHash = artifact ? `sha256:${createHash29("sha256").update(artifact.providerBindingKey, "utf8").digest("hex")}` : null;
|
|
41440
41797
|
if (!artifact || bindingHash !== image.providerBindingKeyHash) continue;
|
|
41441
41798
|
retained[backend] = image;
|
|
41442
41799
|
}
|
|
@@ -45591,7 +45948,7 @@ function connectorActionPolicyDecision(resolved) {
|
|
|
45591
45948
|
return resolved.decision;
|
|
45592
45949
|
}
|
|
45593
45950
|
function connectorActionFingerprint(input) {
|
|
45594
|
-
return
|
|
45951
|
+
return createHash29("sha256").update(
|
|
45595
45952
|
stableJson10({
|
|
45596
45953
|
workspaceId: input.workspaceId,
|
|
45597
45954
|
connectionId: input.connectionId,
|
|
@@ -45900,6 +46257,93 @@ async function upsertConnectorActionPolicy(db, input) {
|
|
|
45900
46257
|
})
|
|
45901
46258
|
);
|
|
45902
46259
|
}
|
|
46260
|
+
async function ensureConnectorActionPolicyDefault(db, input) {
|
|
46261
|
+
const scope = {
|
|
46262
|
+
connectionId: boundedConnectorActionText(
|
|
46263
|
+
input.connectionId,
|
|
46264
|
+
"connector connection id",
|
|
46265
|
+
CONNECTOR_ACTION_CONNECTION_ID_MAX
|
|
46266
|
+
),
|
|
46267
|
+
serverId: boundedConnectorActionText(
|
|
46268
|
+
input.serverId,
|
|
46269
|
+
"connector server id",
|
|
46270
|
+
CONNECTOR_ACTION_SERVER_ID_MAX
|
|
46271
|
+
),
|
|
46272
|
+
toolName: boundedConnectorActionText(
|
|
46273
|
+
input.toolName,
|
|
46274
|
+
"connector tool name",
|
|
46275
|
+
CONNECTOR_ACTION_NAME_MAX
|
|
46276
|
+
),
|
|
46277
|
+
actionName: boundedConnectorActionText(
|
|
46278
|
+
input.actionName,
|
|
46279
|
+
"connector action name",
|
|
46280
|
+
CONNECTOR_ACTION_NAME_MAX
|
|
46281
|
+
)
|
|
46282
|
+
};
|
|
46283
|
+
const subjectId = boundedConnectorActionText(input.subjectId, "policy actor", 1024);
|
|
46284
|
+
return await withRlsContext(
|
|
46285
|
+
db,
|
|
46286
|
+
{ accountId: input.accountId, workspaceId: input.workspaceId },
|
|
46287
|
+
async (scopedDb) => await scopedDb.transaction(async (tx) => {
|
|
46288
|
+
await assertWorkspaceAccountPairInScope(tx, input.accountId, input.workspaceId);
|
|
46289
|
+
const [inserted] = await tx.insert(connectorActionPolicies).values({
|
|
46290
|
+
accountId: input.accountId,
|
|
46291
|
+
workspaceId: input.workspaceId,
|
|
46292
|
+
...scope,
|
|
46293
|
+
policy: input.policy,
|
|
46294
|
+
createdBySubjectId: subjectId,
|
|
46295
|
+
updatedBySubjectId: subjectId
|
|
46296
|
+
}).onConflictDoNothing({
|
|
46297
|
+
target: [
|
|
46298
|
+
connectorActionPolicies.workspaceId,
|
|
46299
|
+
connectorActionPolicies.connectionId,
|
|
46300
|
+
connectorActionPolicies.serverId,
|
|
46301
|
+
connectorActionPolicies.toolName,
|
|
46302
|
+
connectorActionPolicies.actionName
|
|
46303
|
+
]
|
|
46304
|
+
}).returning();
|
|
46305
|
+
if (!inserted) {
|
|
46306
|
+
const [existing] = await tx.select().from(connectorActionPolicies).where(
|
|
46307
|
+
and42(
|
|
46308
|
+
eq43(connectorActionPolicies.workspaceId, input.workspaceId),
|
|
46309
|
+
eq43(connectorActionPolicies.connectionId, scope.connectionId),
|
|
46310
|
+
eq43(connectorActionPolicies.serverId, scope.serverId),
|
|
46311
|
+
eq43(connectorActionPolicies.toolName, scope.toolName),
|
|
46312
|
+
eq43(connectorActionPolicies.actionName, scope.actionName)
|
|
46313
|
+
)
|
|
46314
|
+
).limit(1);
|
|
46315
|
+
if (!existing) throw new Error("Failed to reconcile connector action policy default");
|
|
46316
|
+
return { policy: existing, changed: false };
|
|
46317
|
+
}
|
|
46318
|
+
await tx.insert(auditEvents).values(
|
|
46319
|
+
withLosslessContentWriteVersion(
|
|
46320
|
+
{
|
|
46321
|
+
accountId: input.accountId,
|
|
46322
|
+
workspaceId: input.workspaceId,
|
|
46323
|
+
subjectId,
|
|
46324
|
+
action: "connector.action.policy_changed",
|
|
46325
|
+
targetType: "connector_action_policy",
|
|
46326
|
+
targetId: inserted.id,
|
|
46327
|
+
metadata: {
|
|
46328
|
+
connectionId: inserted.connectionId,
|
|
46329
|
+
serverId: inserted.serverId,
|
|
46330
|
+
toolName: inserted.toolName,
|
|
46331
|
+
actionName: inserted.actionName,
|
|
46332
|
+
policy: inserted.policy,
|
|
46333
|
+
version: inserted.version,
|
|
46334
|
+
previousPolicy: null,
|
|
46335
|
+
previousVersion: null,
|
|
46336
|
+
source: "connector_default"
|
|
46337
|
+
}
|
|
46338
|
+
},
|
|
46339
|
+
"metadata",
|
|
46340
|
+
"metadataCodecVersion"
|
|
46341
|
+
)
|
|
46342
|
+
);
|
|
46343
|
+
return { policy: inserted, changed: true };
|
|
46344
|
+
})
|
|
46345
|
+
);
|
|
46346
|
+
}
|
|
45903
46347
|
async function prepareConnectorActionApproval(db, identity, invocation) {
|
|
45904
46348
|
const normalized = normalizedConnectorActionInvocation(identity, invocation);
|
|
45905
46349
|
if (!normalized.connectionId) {
|
|
@@ -46399,7 +46843,7 @@ async function createSessionInTransaction(tx, input, id) {
|
|
|
46399
46843
|
accountId: input.accountId,
|
|
46400
46844
|
workspaceId: input.workspaceId,
|
|
46401
46845
|
initialMessage: input.initialMessage,
|
|
46402
|
-
|
|
46846
|
+
initialModelContext: input.initialModelContext ?? null,
|
|
46403
46847
|
resources: input.resources,
|
|
46404
46848
|
skills: input.skills ?? [],
|
|
46405
46849
|
tools: input.tools ?? [],
|
|
@@ -51082,7 +51526,7 @@ function validatedLegacyNativeSnapshotAdoption(value) {
|
|
|
51082
51526
|
if (Buffer.from(bytes).toString("base64") !== value.archiveBase64) return null;
|
|
51083
51527
|
const descriptor = parseArchiveRevision(value.descriptor);
|
|
51084
51528
|
const native = decodeNativeSnapshotRef(bytes);
|
|
51085
|
-
if (descriptor?.version !== 2 || !native || descriptor.archiveBytes !== bytes.length || descriptor.archiveSha256 !==
|
|
51529
|
+
if (descriptor?.version !== 2 || !native || descriptor.archiveBytes !== bytes.length || descriptor.archiveSha256 !== createHash29("sha256").update(bytes).digest("hex") || descriptor.provider !== native.provider || descriptor.snapshotId !== native.snapshotId || descriptor.workspacePersistence !== native.workspacePersistence) {
|
|
51086
51530
|
return null;
|
|
51087
51531
|
}
|
|
51088
51532
|
return { archiveBase64: value.archiveBase64, descriptor };
|
|
@@ -51731,7 +52175,7 @@ var MODAL_ARCHIVE_PREFIXES = [
|
|
|
51731
52175
|
var COLD_LOST_PROVIDER_OBSERVATION_MAX_AGE_MS = 5 * 60 * 1e3;
|
|
51732
52176
|
var COLD_LOST_PROVIDER_OBSERVATION_MAX_FUTURE_MS = 60 * 1e3;
|
|
51733
52177
|
function sha256String(value) {
|
|
51734
|
-
return
|
|
52178
|
+
return createHash29("sha256").update(value).digest("hex");
|
|
51735
52179
|
}
|
|
51736
52180
|
function decodeCanonicalBase64(value) {
|
|
51737
52181
|
if (typeof value !== "string" || value.length === 0 || value.length % 4 !== 0 || !/^[A-Za-z0-9+/]+={0,2}$/.test(value)) {
|
|
@@ -55677,7 +56121,7 @@ function validatedModalCheckpoint(input) {
|
|
|
55677
56121
|
throw new Error("Checkpoint artifact archive is not canonical base64");
|
|
55678
56122
|
}
|
|
55679
56123
|
const native = decodeNativeSnapshotRef(bytes);
|
|
55680
|
-
const sha2568 =
|
|
56124
|
+
const sha2568 = createHash29("sha256").update(bytes).digest("hex");
|
|
55681
56125
|
if (!native || native.provider !== descriptor.provider || native.snapshotId !== descriptor.snapshotId || native.workspacePersistence !== descriptor.workspacePersistence || descriptor.archiveBytes !== bytes.length || descriptor.archiveSha256 !== sha2568) {
|
|
55682
56126
|
throw new Error("Checkpoint artifact receipt does not match its verified descriptor");
|
|
55683
56127
|
}
|
|
@@ -57060,7 +57504,7 @@ var MachineRemovalRevisionConflictError = class extends Error {
|
|
|
57060
57504
|
name = "MachineRemovalRevisionConflictError";
|
|
57061
57505
|
};
|
|
57062
57506
|
function machineRemovalFingerprint(enrollmentId, expectedUpdatedAt) {
|
|
57063
|
-
return
|
|
57507
|
+
return createHash29("sha256").update(
|
|
57064
57508
|
JSON.stringify({
|
|
57065
57509
|
enrollmentId,
|
|
57066
57510
|
expectedUpdatedAt: expectedUpdatedAt ?? null
|
|
@@ -60454,6 +60898,7 @@ async function initializeSessionStartAtomically(db, input) {
|
|
|
60454
60898
|
type: "user.message",
|
|
60455
60899
|
payload: {
|
|
60456
60900
|
...initialPayload,
|
|
60901
|
+
...session.initialModelContext ? { modelContext: session.initialModelContext } : {},
|
|
60457
60902
|
initiator: creator.initiator
|
|
60458
60903
|
},
|
|
60459
60904
|
clientEventId: input.clientEventId ?? `session-initial:${session.id}`
|
|
@@ -60500,7 +60945,7 @@ async function initializeSessionStartAtomically(db, input) {
|
|
|
60500
60945
|
source: "user",
|
|
60501
60946
|
position: queueTailPosition,
|
|
60502
60947
|
prompt: canonicalInitialMessage,
|
|
60503
|
-
|
|
60948
|
+
modelContext: session.initialModelContext ?? null,
|
|
60504
60949
|
resources: session.resources,
|
|
60505
60950
|
tools: session.tools,
|
|
60506
60951
|
toolsProvided: session.toolPolicy?.mode === "explicit",
|
|
@@ -60655,7 +61100,7 @@ async function enqueueSessionTurn(db, input) {
|
|
|
60655
61100
|
source: input.source,
|
|
60656
61101
|
position,
|
|
60657
61102
|
prompt: input.prompt,
|
|
60658
|
-
|
|
61103
|
+
modelContext: input.modelContext ?? null,
|
|
60659
61104
|
resources: input.resources,
|
|
60660
61105
|
tools: input.tools,
|
|
60661
61106
|
toolsProvided: input.toolsProvided ?? false,
|
|
@@ -61935,7 +62380,8 @@ async function claimSessionWorkForAttempt(db, workspaceId, input) {
|
|
|
61935
62380
|
item: durableUserHistoryItem(
|
|
61936
62381
|
fromPostgresLosslessText(row.prompt, row.promptCodecVersion),
|
|
61937
62382
|
Array.isArray(row.resources) ? row.resources : [],
|
|
61938
|
-
TimelineAnnotations2.parse(row.annotations)
|
|
62383
|
+
TimelineAnnotations2.parse(row.annotations),
|
|
62384
|
+
row.modelContext
|
|
61939
62385
|
)
|
|
61940
62386
|
},
|
|
61941
62387
|
"item",
|
|
@@ -66322,7 +66768,7 @@ async function acceptSessionApprovalDecision(db, input) {
|
|
|
66322
66768
|
);
|
|
66323
66769
|
}
|
|
66324
66770
|
function deterministicSystemUuid(seed) {
|
|
66325
|
-
const bytes =
|
|
66771
|
+
const bytes = createHash29("sha256").update(seed, "utf8").digest().subarray(0, 16);
|
|
66326
66772
|
bytes[6] = (bytes[6] ?? 0) & 15 | 80;
|
|
66327
66773
|
bytes[8] = (bytes[8] ?? 0) & 63 | 128;
|
|
66328
66774
|
const hex = bytes.toString("hex");
|
|
@@ -67048,7 +67494,6 @@ function mapSessionTurn(row) {
|
|
|
67048
67494
|
function mapSessionTurnForExecution(row) {
|
|
67049
67495
|
return {
|
|
67050
67496
|
...mapSessionTurn(row),
|
|
67051
|
-
turnInstructions: row.turnInstructions ?? null,
|
|
67052
67497
|
initiatingHumanSubjectId: row.initiatingHumanSubjectId ?? null,
|
|
67053
67498
|
personalConnectionDelegations: parsedPersonalConnectionDelegations(
|
|
67054
67499
|
row.personalConnectionDelegations,
|
|
@@ -68077,6 +68522,7 @@ export {
|
|
|
68077
68522
|
autoResumeSessionBranchInTransaction,
|
|
68078
68523
|
backfillModelCallFactsFromSessionEvents,
|
|
68079
68524
|
beginConnectorActionExecution,
|
|
68525
|
+
beginGoogleDriveObjectAclRefresh,
|
|
68080
68526
|
beginImageGenerationOperation,
|
|
68081
68527
|
beginKnowledgeSyncRun,
|
|
68082
68528
|
beginRigChangeVerificationAttempt,
|
|
@@ -68333,6 +68779,7 @@ export {
|
|
|
68333
68779
|
ensureCanonicalHumanIdentity,
|
|
68334
68780
|
ensureCanonicalHumanIdentityForAuthUser,
|
|
68335
68781
|
ensureCodexRotationSettings,
|
|
68782
|
+
ensureConnectorActionPolicyDefault,
|
|
68336
68783
|
ensureIntegrationFacetDefinition,
|
|
68337
68784
|
ensureKnowledgeSourceBlobFile,
|
|
68338
68785
|
ensureKnowledgeSourceSyncState,
|
|
@@ -68425,6 +68872,7 @@ export {
|
|
|
68425
68872
|
getFile,
|
|
68426
68873
|
getFileUpload,
|
|
68427
68874
|
getFiles,
|
|
68875
|
+
getFilesForSubject,
|
|
68428
68876
|
getGeneratedImageArtifact,
|
|
68429
68877
|
getGeneratedVideoArtifact,
|
|
68430
68878
|
getHostExportConsumerStatus,
|
|
@@ -68841,6 +69289,7 @@ export {
|
|
|
68841
69289
|
recordConnectionTokenRefresh,
|
|
68842
69290
|
recordConnectionUsed,
|
|
68843
69291
|
recordGeneratedImageArtifactError,
|
|
69292
|
+
recordGoogleDriveObjectAclEvidence,
|
|
68844
69293
|
recordKnowledgeLifecycleEvent,
|
|
68845
69294
|
recordKnowledgeSourceSyncAclEvidence,
|
|
68846
69295
|
recordKnowledgeSourceSyncItemOutcomes,
|
|
@@ -68912,6 +69361,7 @@ export {
|
|
|
68912
69361
|
requestSessionTurnRecovery,
|
|
68913
69362
|
requestSlackUserLinkWorkspaceAccess,
|
|
68914
69363
|
requireFile,
|
|
69364
|
+
requireFileForSubject,
|
|
68915
69365
|
requireScheduledTask,
|
|
68916
69366
|
requireScheduledTaskTargetInTransaction,
|
|
68917
69367
|
requireSession,
|