@opengeni/core 3.3.0 → 3.4.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/goal-admission.d.ts +2 -0
- package/dist/index.js +110 -93
- package/dist/index.js.map +1 -1
- package/package.json +13 -13
- package/src/domain/capabilities.ts +44 -16
- package/src/domain/session-tool-policy.ts +3 -0
- package/src/session-authorization.ts +94 -83
package/dist/goal-admission.d.ts
CHANGED
|
@@ -36,6 +36,7 @@ export declare function resolveGoalModelAdmission(db: Database, settings: Settin
|
|
|
36
36
|
serverVersion?: string | undefined;
|
|
37
37
|
databaseUrl: string;
|
|
38
38
|
apiDatabasePoolMax: number;
|
|
39
|
+
databasePreparedStatements?: boolean | undefined;
|
|
39
40
|
dbSchema: string;
|
|
40
41
|
rlsStrategy: "force" | "scoped";
|
|
41
42
|
runtimeDatabaseRole: string;
|
|
@@ -568,6 +569,7 @@ export declare function resolveGoalModelAdmission(db: Database, settings: Settin
|
|
|
568
569
|
stripePublishableKey?: string | undefined;
|
|
569
570
|
stripeWebhookSecret?: string | undefined;
|
|
570
571
|
stripeCreditsProductId?: string | undefined;
|
|
572
|
+
subscriptionPlansEnabled: boolean;
|
|
571
573
|
mcpServers: {
|
|
572
574
|
id: string;
|
|
573
575
|
name?: string | undefined;
|
package/dist/index.js
CHANGED
|
@@ -140,7 +140,7 @@ import {
|
|
|
140
140
|
|
|
141
141
|
// src/domain/session-file-access.ts
|
|
142
142
|
import {
|
|
143
|
-
getSessionAuthorityProjection
|
|
143
|
+
getSessionAuthorityProjection,
|
|
144
144
|
getFilesForSubject,
|
|
145
145
|
readSessionFileAttachments,
|
|
146
146
|
withSessionRlsActorContext as withSessionRlsActorContext2
|
|
@@ -157,11 +157,8 @@ import { AsyncLocalStorage as AsyncLocalStorage2 } from "async_hooks";
|
|
|
157
157
|
import {
|
|
158
158
|
currentSessionRlsActorIdentityKey,
|
|
159
159
|
currentSiteViewerRlsContext,
|
|
160
|
-
getSessionAuthorityProjection,
|
|
161
|
-
getSessionAuthorizationTargetProjection,
|
|
162
160
|
getSession as getSession2,
|
|
163
|
-
|
|
164
|
-
getSlackInteractionSessionAccessForSession,
|
|
161
|
+
getSessionAuthorizationFacts,
|
|
165
162
|
withSessionRlsActorContext
|
|
166
163
|
} from "@opengeni/db";
|
|
167
164
|
|
|
@@ -405,7 +402,9 @@ async function withResolvedSessionAuthorization(authorization, fn) {
|
|
|
405
402
|
}
|
|
406
403
|
async function requireLiveAgentAttemptAuthorization(db, grant, callerSessionId) {
|
|
407
404
|
const reads = claimSessionAuthorizationReads();
|
|
408
|
-
const
|
|
405
|
+
const claims = agentAttemptClaims(grant);
|
|
406
|
+
const facts = claims ? await readSessionAuthorizationFacts(db, grant, claims.callerSessionId, claims, reads) : null;
|
|
407
|
+
const { actor } = resolveSessionAuthorizationActor(grant, claims, facts);
|
|
409
408
|
if (actor.kind !== "agent_attempt" || actor.callerSessionId !== callerSessionId) {
|
|
410
409
|
throw new SessionAuthorizationDeniedError("caller_stale");
|
|
411
410
|
}
|
|
@@ -415,23 +414,16 @@ async function requireSessionAuthorization(deps, grant, input) {
|
|
|
415
414
|
const reads = claimSessionAuthorizationReads();
|
|
416
415
|
const port = deps.sessionAuthorization;
|
|
417
416
|
const isAgentAttempt = grantHasAgentAttemptAuthority(grant);
|
|
418
|
-
const
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
});
|
|
423
|
-
const authority = await getSessionAuthorityProjection(
|
|
424
|
-
deps.db,
|
|
425
|
-
grant.workspaceId,
|
|
426
|
-
input.sessionId
|
|
427
|
-
);
|
|
417
|
+
const claims = agentAttemptClaims(grant);
|
|
418
|
+
const facts = await readSessionAuthorizationFacts(deps.db, grant, input.sessionId, claims, reads);
|
|
419
|
+
const authority = facts.target;
|
|
420
|
+
const slackAccess = authority?.slackAccess ?? null;
|
|
428
421
|
if (!authority && input.surface !== "core") {
|
|
429
422
|
throw new SessionAuthorizationDeniedError("not_found");
|
|
430
423
|
}
|
|
431
424
|
if (authority?.siteAccessRootId) {
|
|
432
425
|
const viewer = currentSiteViewerRlsContext();
|
|
433
|
-
const
|
|
434
|
-
const actor2 = resolved.actor;
|
|
426
|
+
const actor2 = resolveSessionAuthorizationActor(grant, claims, facts).actor;
|
|
435
427
|
const allowed = actor2.kind === "agent_attempt" ? authority.siteOwnerSubjectId !== null && authority.siteOwnerSubjectId === actor2.initiatingHumanSubjectId || actor2.callerRootSessionId === authority.rootSessionId && authority.siteAccessRootId === authority.rootSessionId : authority.siteOwnerSubjectId === actor2.subjectId || actor2.subjectId === `site:${authority.siteId}` && viewer?.siteId === authority.siteId && viewer.principal === authority.siteViewerPrincipal;
|
|
436
428
|
if (!allowed) throw new SessionAuthorizationDeniedError("not_found");
|
|
437
429
|
}
|
|
@@ -445,15 +437,15 @@ async function requireSessionAuthorization(deps, grant, input) {
|
|
|
445
437
|
return null;
|
|
446
438
|
}
|
|
447
439
|
if (!authority) throw new SessionAuthorizationDeniedError("not_found");
|
|
448
|
-
const resolvedActor =
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
input.sessionId,
|
|
453
|
-
reads
|
|
454
|
-
);
|
|
440
|
+
const resolvedActor = resolveSessionAuthorizationActor(grant, claims, facts);
|
|
441
|
+
if (authority.accountId !== grant.accountId) {
|
|
442
|
+
throw new SessionAuthorizationDeniedError("not_found");
|
|
443
|
+
}
|
|
455
444
|
const actor = resolvedActor.actor;
|
|
456
|
-
const target =
|
|
445
|
+
const target = {
|
|
446
|
+
sessionId: authority.sessionId,
|
|
447
|
+
rootSessionId: authority.rootSessionId
|
|
448
|
+
};
|
|
457
449
|
const agentRelatedSessionAccess = actor.kind === "agent_attempt" ? relatedSessionAccessForAgentAttempt(actor, target.sessionId) : null;
|
|
458
450
|
if (actor.kind === "agent_attempt" && input.operation === "session.approval.write") {
|
|
459
451
|
throw new SessionAuthorizationDeniedError("forbidden");
|
|
@@ -524,7 +516,9 @@ async function requireSessionAuthorizationListScope(deps, grant, surface) {
|
|
|
524
516
|
const port = deps.sessionAuthorization;
|
|
525
517
|
const isAgentAttempt = grantHasAgentAttemptAuthority(grant);
|
|
526
518
|
if (!port && !isAgentAttempt) return null;
|
|
527
|
-
const
|
|
519
|
+
const claims = agentAttemptClaims(grant);
|
|
520
|
+
const facts = claims ? await readSessionAuthorizationFacts(deps.db, grant, claims.callerSessionId, claims, reads) : null;
|
|
521
|
+
const { actor, callerAccess } = resolveSessionAuthorizationActor(grant, claims, facts);
|
|
528
522
|
const viewer = actor.kind === "agent_attempt" && callerAccess ? {
|
|
529
523
|
callerRootSessionId: actor.callerRootSessionId,
|
|
530
524
|
agentAccess: callerAccess.agentAccess,
|
|
@@ -553,27 +547,39 @@ async function requireSessionAuthorizationListScope(deps, grant, surface) {
|
|
|
553
547
|
};
|
|
554
548
|
return viewer ? agentAccessListScopeForViewer(viewer, hostScope) : hostScope;
|
|
555
549
|
}
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
reads,
|
|
559
|
-
db,
|
|
560
|
-
["target-identity", grant.workspaceId, sessionId],
|
|
561
|
-
() => getSessionAuthorizationTargetProjection(db, grant.workspaceId, sessionId)
|
|
562
|
-
);
|
|
563
|
-
if (!session || session.accountId !== grant.accountId) {
|
|
564
|
-
throw new SessionAuthorizationDeniedError("not_found");
|
|
565
|
-
}
|
|
566
|
-
return {
|
|
567
|
-
target: { sessionId: session.id, rootSessionId: session.rootSessionId }
|
|
568
|
-
};
|
|
569
|
-
}
|
|
570
|
-
async function resolveSessionAuthorizationActor(db, grant, reads) {
|
|
550
|
+
function agentAttemptClaims(grant) {
|
|
551
|
+
if (!grantHasAgentAttemptAuthority(grant)) return null;
|
|
571
552
|
const callerSessionId = grant.metadata?.["sessionId"];
|
|
572
553
|
const turnId = grant.metadata?.["turnId"];
|
|
573
554
|
const attemptId = grant.metadata?.["attemptId"];
|
|
574
555
|
const executionGeneration = grant.metadata?.["executionGeneration"];
|
|
575
|
-
|
|
576
|
-
|
|
556
|
+
if (typeof callerSessionId !== "string" || typeof turnId !== "string" || typeof attemptId !== "string" || typeof executionGeneration !== "number" || !Number.isSafeInteger(executionGeneration) || executionGeneration < 1) {
|
|
557
|
+
return null;
|
|
558
|
+
}
|
|
559
|
+
return { callerSessionId, turnId, attemptId, executionGeneration };
|
|
560
|
+
}
|
|
561
|
+
async function readSessionAuthorizationFacts(db, grant, sessionId, claims, reads) {
|
|
562
|
+
return await reusableAuthorizationRead(
|
|
563
|
+
reads,
|
|
564
|
+
db,
|
|
565
|
+
[
|
|
566
|
+
"authorization-facts",
|
|
567
|
+
grant.accountId,
|
|
568
|
+
grant.workspaceId,
|
|
569
|
+
sessionId,
|
|
570
|
+
claims?.callerSessionId ?? "",
|
|
571
|
+
claims?.attemptId ?? ""
|
|
572
|
+
],
|
|
573
|
+
() => getSessionAuthorizationFacts(db, {
|
|
574
|
+
accountId: grant.accountId,
|
|
575
|
+
workspaceId: grant.workspaceId,
|
|
576
|
+
sessionId,
|
|
577
|
+
caller: claims ? { sessionId: claims.callerSessionId, attemptId: claims.attemptId } : void 0
|
|
578
|
+
})
|
|
579
|
+
);
|
|
580
|
+
}
|
|
581
|
+
function resolveSessionAuthorizationActor(grant, claims, facts) {
|
|
582
|
+
if (!grantHasAgentAttemptAuthority(grant)) {
|
|
577
583
|
return {
|
|
578
584
|
actor: SessionAuthorizationActor.parse({
|
|
579
585
|
kind: "subject",
|
|
@@ -584,33 +590,20 @@ async function resolveSessionAuthorizationActor(db, grant, reads) {
|
|
|
584
590
|
callerAccess: null
|
|
585
591
|
};
|
|
586
592
|
}
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
const callerSession = await reusableAuthorizationRead(
|
|
591
|
-
reads,
|
|
592
|
-
db,
|
|
593
|
-
["session", grant.workspaceId, callerSessionId],
|
|
594
|
-
() => getSession2(db, grant.workspaceId, callerSessionId)
|
|
595
|
-
);
|
|
596
|
-
const turn = await reusableAuthorizationRead(
|
|
597
|
-
reads,
|
|
598
|
-
db,
|
|
599
|
-
["turn", grant.workspaceId, callerSessionId, attemptId],
|
|
600
|
-
() => getSessionTurnForAttempt(db, grant.workspaceId, callerSessionId, attemptId)
|
|
601
|
-
);
|
|
602
|
-
if (!callerSession || callerSession.accountId !== grant.accountId || !turn || turn.id !== turnId || turn.executionGeneration !== executionGeneration || callerSession.activeTurnId !== turn.id) {
|
|
593
|
+
const callerSession = facts?.caller?.session ?? null;
|
|
594
|
+
const turn = facts?.caller?.turn ?? null;
|
|
595
|
+
if (!claims || !callerSession || callerSession.accountId !== grant.accountId || !turn || turn.id !== claims.turnId || turn.executionGeneration !== claims.executionGeneration) {
|
|
603
596
|
throw new SessionAuthorizationDeniedError("caller_stale");
|
|
604
597
|
}
|
|
605
598
|
return {
|
|
606
599
|
actor: SessionAuthorizationActor.parse({
|
|
607
600
|
kind: "agent_attempt",
|
|
608
601
|
subjectId: grant.subjectId,
|
|
609
|
-
callerSessionId,
|
|
602
|
+
callerSessionId: claims.callerSessionId,
|
|
610
603
|
callerRootSessionId: callerSession.rootSessionId,
|
|
611
|
-
turnId,
|
|
612
|
-
attemptId,
|
|
613
|
-
executionGeneration,
|
|
604
|
+
turnId: claims.turnId,
|
|
605
|
+
attemptId: claims.attemptId,
|
|
606
|
+
executionGeneration: claims.executionGeneration,
|
|
614
607
|
initiator: turn.initiator,
|
|
615
608
|
initiatorContext: turn.initiatorContext,
|
|
616
609
|
initiatingHumanSubjectId: turn.initiatingHumanSubjectId ?? (turn.initiator.kind === "subject" ? turn.initiator.subjectId : null)
|
|
@@ -625,7 +618,7 @@ async function resolveSessionAuthorizationActor(db, grant, reads) {
|
|
|
625
618
|
|
|
626
619
|
// src/domain/session-file-access.ts
|
|
627
620
|
async function readSessionAttachmentFiles(deps, grant, sessionId, fileIds) {
|
|
628
|
-
const authority = await
|
|
621
|
+
const authority = await getSessionAuthorityProjection(deps.db, grant.workspaceId, sessionId);
|
|
629
622
|
if (!authority) return [];
|
|
630
623
|
const authorization = await requireSessionAuthorization(deps, grant, {
|
|
631
624
|
sessionId,
|
|
@@ -1051,6 +1044,7 @@ import {
|
|
|
1051
1044
|
getCapabilityCatalogItem,
|
|
1052
1045
|
getCapabilityInstallation,
|
|
1053
1046
|
getConnectionMetadata as getConnectionMetadata3,
|
|
1047
|
+
isTransactionHandle,
|
|
1054
1048
|
readCodexCutoverDisposition,
|
|
1055
1049
|
resolveSubscriptionCoreCodexAppsDesignation,
|
|
1056
1050
|
rlsContextForWorkspace,
|
|
@@ -1516,6 +1510,21 @@ var maxMcpCredentialHeaders = 16;
|
|
|
1516
1510
|
var maxMcpCredentialHeaderValueLength = 4096;
|
|
1517
1511
|
var mcpCredentialHeaderName = /^[A-Za-z0-9!#$%&'*+.^_`|~-]+$/;
|
|
1518
1512
|
async function buildCapabilityCatalog(input) {
|
|
1513
|
+
const serial = isTransactionHandle(input.db);
|
|
1514
|
+
const reads = [
|
|
1515
|
+
() => listCapabilityCatalogItems(input.db, input.workspaceId),
|
|
1516
|
+
() => listCapabilityInstallations(input.db, input.workspaceId),
|
|
1517
|
+
() => listSocialConnections(input.db, input.workspaceId, 500, input.subjectId),
|
|
1518
|
+
() => listConnectionsMetadata(input.db, input.workspaceId, null),
|
|
1519
|
+
() => discoverCuratedSkillLibraryItems(),
|
|
1520
|
+
() => listInstalledSkills(input.db, input.workspaceId),
|
|
1521
|
+
() => input.settings.codexConnectedAppsEnabled ? resolveCodexAppsDesignationForRun(
|
|
1522
|
+
input.db,
|
|
1523
|
+
input.workspaceId,
|
|
1524
|
+
input.accountId ? { accountId: input.accountId } : {}
|
|
1525
|
+
) : Promise.resolve(null),
|
|
1526
|
+
() => listEnabledMcpCapabilityServers(input.db, input.workspaceId)
|
|
1527
|
+
];
|
|
1519
1528
|
const [
|
|
1520
1529
|
persistedItems,
|
|
1521
1530
|
capabilityInstallations,
|
|
@@ -1525,19 +1534,24 @@ async function buildCapabilityCatalog(input) {
|
|
|
1525
1534
|
installedSkills,
|
|
1526
1535
|
codexAppsDesignation,
|
|
1527
1536
|
runnableMcpServers
|
|
1528
|
-
] =
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1537
|
+
] = serial ? [
|
|
1538
|
+
await reads[0](),
|
|
1539
|
+
await reads[1](),
|
|
1540
|
+
await reads[2](),
|
|
1541
|
+
await reads[3](),
|
|
1542
|
+
await reads[4](),
|
|
1543
|
+
await reads[5](),
|
|
1544
|
+
await reads[6](),
|
|
1545
|
+
await reads[7]()
|
|
1546
|
+
] : await Promise.all([
|
|
1547
|
+
reads[0](),
|
|
1548
|
+
reads[1](),
|
|
1549
|
+
reads[2](),
|
|
1550
|
+
reads[3](),
|
|
1551
|
+
reads[4](),
|
|
1552
|
+
reads[5](),
|
|
1553
|
+
reads[6](),
|
|
1554
|
+
reads[7]()
|
|
1541
1555
|
]);
|
|
1542
1556
|
const runnableCapabilityIds = new Set(runnableMcpServers.map((server) => server.capabilityId));
|
|
1543
1557
|
const operatorOAuthClientConfigured = operatorOAuthClientResolver(input.settings);
|
|
@@ -5833,7 +5847,7 @@ import { withSessionRlsActorContext as withSessionRlsActorContext4 } from "@open
|
|
|
5833
5847
|
// src/domain/file-owner.ts
|
|
5834
5848
|
import {
|
|
5835
5849
|
freezeAgentLearningPolicy,
|
|
5836
|
-
getSessionAuthorityProjection as
|
|
5850
|
+
getSessionAuthorityProjection as getSessionAuthorityProjection2
|
|
5837
5851
|
} from "@opengeni/db";
|
|
5838
5852
|
async function fileOwnerContextForAccess(deps, access, permission) {
|
|
5839
5853
|
if (access.grant.principalKind === "agent_attempt")
|
|
@@ -5863,7 +5877,7 @@ async function fileOwnerContextForAgent(deps, grant, permission) {
|
|
|
5863
5877
|
executionGeneration: attempt.executionGeneration
|
|
5864
5878
|
}
|
|
5865
5879
|
});
|
|
5866
|
-
const sessionAuthority = await
|
|
5880
|
+
const sessionAuthority = await getSessionAuthorityProjection2(
|
|
5867
5881
|
deps.db,
|
|
5868
5882
|
grant.workspaceId,
|
|
5869
5883
|
sessionId
|
|
@@ -6037,14 +6051,14 @@ import {
|
|
|
6037
6051
|
getSession as getSession5,
|
|
6038
6052
|
getInitializedSessionCreateReplay,
|
|
6039
6053
|
getSessionGoal,
|
|
6040
|
-
getSessionAuthorityProjection as
|
|
6054
|
+
getSessionAuthorityProjection as getSessionAuthorityProjection3,
|
|
6041
6055
|
SessionIdConflictError,
|
|
6042
6056
|
NewSessionDraftConflictError,
|
|
6043
6057
|
getWorkspaceControlEvent,
|
|
6044
6058
|
getSessionLineage,
|
|
6045
6059
|
getSessionTurn,
|
|
6046
6060
|
getSessionTurnInitiatingHumanSubjectId,
|
|
6047
|
-
getSessionTurnForAttempt as
|
|
6061
|
+
getSessionTurnForAttempt as getSessionTurnForAttempt2,
|
|
6048
6062
|
getSessionTurnPersonalConnectionDelegations as getSessionTurnPersonalConnectionDelegations2,
|
|
6049
6063
|
getSessionTurnXaiProviderAccountAuthoritySnapshot,
|
|
6050
6064
|
getSessionTurnClaudeProviderAccountAuthoritySnapshot,
|
|
@@ -6100,7 +6114,7 @@ import {
|
|
|
6100
6114
|
captureExternalLinkTurnAuthority,
|
|
6101
6115
|
captureExternalLinkTaskAuthority,
|
|
6102
6116
|
getExternalLinkTurnSnapshot,
|
|
6103
|
-
getSessionTurnForAttempt
|
|
6117
|
+
getSessionTurnForAttempt
|
|
6104
6118
|
} from "@opengeni/db";
|
|
6105
6119
|
|
|
6106
6120
|
// src/application/external-continuation.ts
|
|
@@ -6220,7 +6234,7 @@ function prepareExternalLinkTaskAdmission(authorization, actor) {
|
|
|
6220
6234
|
} : void 0;
|
|
6221
6235
|
}
|
|
6222
6236
|
return async (tx, task) => {
|
|
6223
|
-
const turn = await
|
|
6237
|
+
const turn = await getSessionTurnForAttempt(
|
|
6224
6238
|
tx,
|
|
6225
6239
|
task.workspaceId,
|
|
6226
6240
|
actor.sessionId,
|
|
@@ -11014,6 +11028,9 @@ function sessionEffectiveToolProjectionInput(session, toolRefs, context) {
|
|
|
11014
11028
|
"request_human_input",
|
|
11015
11029
|
"list_models",
|
|
11016
11030
|
...webSearchPlan.providerTools,
|
|
11031
|
+
// Interaction entry tools stay visible even with progressive disclosure;
|
|
11032
|
+
// the remaining authorized family tools are disclosed after opening.
|
|
11033
|
+
...firstPartyMcpTools.filter((name) => name === "browser_open" || name === "computer_open"),
|
|
11017
11034
|
...toolRefs.some((ref) => ref.id === "opengeni" && ref.eager === true) || !progressiveDisclosure ? firstPartyMcpTools.filter((name) => !interactionNames.has(name) || !progressiveDisclosure) : [],
|
|
11018
11035
|
...!progressiveDisclosure ? runtimeToolNames : [],
|
|
11019
11036
|
...nativeComputerTools && !progressiveDisclosure ? CUA_DESKTOP_TOOLS.map((tool) => `interaction__cua_${tool.name}`) : []
|
|
@@ -13350,7 +13367,7 @@ async function createSessionForRequestInFileScope(unresolvedDeps, grant, workspa
|
|
|
13350
13367
|
() => requireWorkspace5(db, workspaceId)
|
|
13351
13368
|
);
|
|
13352
13369
|
const workspaceSessionToolDefaults = resolveWorkspaceSessionToolDefaults2(workspace.settings);
|
|
13353
|
-
const parentAuthority = parentSession ? await
|
|
13370
|
+
const parentAuthority = parentSession ? await getSessionAuthorityProjection3(db, workspaceId, parentSession.id) : null;
|
|
13354
13371
|
if (parentSession && !parentAuthority) {
|
|
13355
13372
|
throw new HTTPException21(403, {
|
|
13356
13373
|
message: "parent session authority is unavailable"
|
|
@@ -13411,7 +13428,7 @@ async function createSessionForRequestInFileScope(unresolvedDeps, grant, workspa
|
|
|
13411
13428
|
payload.instructions = agentResolution.instructions;
|
|
13412
13429
|
}
|
|
13413
13430
|
bundledSkillIds = bundledSkillSelectionForAgentConfig2(bundledSkillIds, agentConfig);
|
|
13414
|
-
const parentCallingTurn = parentSession && creationInitiator.actor ? await
|
|
13431
|
+
const parentCallingTurn = parentSession && creationInitiator.actor ? await getSessionTurnForAttempt2(
|
|
13415
13432
|
db,
|
|
13416
13433
|
workspaceId,
|
|
13417
13434
|
parentSession.id,
|
|
@@ -21149,7 +21166,7 @@ import {
|
|
|
21149
21166
|
SignedJsonAutomationEnvelope,
|
|
21150
21167
|
readTurnExecutionPolicyV1 as readTurnExecutionPolicyV13
|
|
21151
21168
|
} from "@opengeni/contracts";
|
|
21152
|
-
import { getSession as getSession7, getSessionTurnForAttempt as
|
|
21169
|
+
import { getSession as getSession7, getSessionTurnForAttempt as getSessionTurnForAttempt3 } from "@opengeni/db";
|
|
21153
21170
|
import { HTTPException as HTTPException30 } from "hono/http-exception";
|
|
21154
21171
|
|
|
21155
21172
|
// src/domain/pr-review.ts
|
|
@@ -21673,7 +21690,7 @@ async function automationCredentialRestrictionForGrant(db, grant) {
|
|
|
21673
21690
|
if (isDeveloperSetupGrant(grant)) return "developer_setup";
|
|
21674
21691
|
const actor = creationInitiatorForGrant(grant).actor;
|
|
21675
21692
|
if (!actor) return void 0;
|
|
21676
|
-
const turn = await
|
|
21693
|
+
const turn = await getSessionTurnForAttempt3(
|
|
21677
21694
|
db,
|
|
21678
21695
|
grant.workspaceId,
|
|
21679
21696
|
actor.sessionId,
|
|
@@ -22175,8 +22192,8 @@ import {
|
|
|
22175
22192
|
getSandbox as getSandbox5,
|
|
22176
22193
|
getSessionTurnXaiProviderAccountAuthoritySnapshot as getSessionTurnXaiProviderAccountAuthoritySnapshot2,
|
|
22177
22194
|
getSession as getSession8,
|
|
22178
|
-
getSessionTurnForAttempt as
|
|
22179
|
-
getSessionAuthorityProjection as
|
|
22195
|
+
getSessionTurnForAttempt as getSessionTurnForAttempt4,
|
|
22196
|
+
getSessionAuthorityProjection as getSessionAuthorityProjection4,
|
|
22180
22197
|
getWorkspaceDefaultRigId as getWorkspaceDefaultRigId2,
|
|
22181
22198
|
withSessionRlsActorContext as withSessionRlsActorContext5,
|
|
22182
22199
|
nestedPostgresSqlState as nestedPostgresSqlState8,
|
|
@@ -22758,7 +22775,7 @@ async function frozenScheduledTaskCreatorPolicy(input) {
|
|
|
22758
22775
|
message: "the calling agent session is not available in this workspace"
|
|
22759
22776
|
});
|
|
22760
22777
|
}
|
|
22761
|
-
const turn = await
|
|
22778
|
+
const turn = await getSessionTurnForAttempt4(
|
|
22762
22779
|
input.db,
|
|
22763
22780
|
input.grant.workspaceId,
|
|
22764
22781
|
input.actor.sessionId,
|
|
@@ -22962,7 +22979,7 @@ async function scheduledTaskCredentialRestrictionForGrant(db, grant, actor) {
|
|
|
22962
22979
|
if (isDeveloperSetupGrant(grant)) return "developer_setup";
|
|
22963
22980
|
if (!actor) return void 0;
|
|
22964
22981
|
const session = await getSession8(db, grant.workspaceId, actor.sessionId);
|
|
22965
|
-
const turn = await
|
|
22982
|
+
const turn = await getSessionTurnForAttempt4(
|
|
22966
22983
|
db,
|
|
22967
22984
|
grant.workspaceId,
|
|
22968
22985
|
actor.sessionId,
|
|
@@ -23922,7 +23939,7 @@ async function validateScheduledTaskAgentConfig(input) {
|
|
|
23922
23939
|
}
|
|
23923
23940
|
const fileActor = resources.some((resource) => resource.kind === "file") && hasPermission(input.grant.permissions, "files:read") ? input.authorization ? await fileOwnerContextForAccess({ db: input.db }, input.authorization, "files:read") : input.grant.principalKind === "agent_attempt" ? await fileOwnerContextForAgent({ db: input.db }, input.grant, "files:read") : { subjectId: input.grant.subjectId, privateFileOwnerSubjectId: null } : { subjectId: input.grant.subjectId, privateFileOwnerSubjectId: null };
|
|
23924
23941
|
await withSessionRlsActorContext5(fileActor, async () => {
|
|
23925
|
-
const target = input.payload.targetSessionId && input.payload.runMode !== "new_session_per_run" ? await
|
|
23942
|
+
const target = input.payload.targetSessionId && input.payload.runMode !== "new_session_per_run" ? await getSessionAuthorityProjection4(
|
|
23926
23943
|
input.db,
|
|
23927
23944
|
input.workspaceId,
|
|
23928
23945
|
input.payload.targetSessionId
|