@opengeni/worker-bundle 0.13.11 → 0.14.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.
|
@@ -10,10 +10,10 @@ import { type SecretForRedaction } from "./redaction";
|
|
|
10
10
|
import { type TurnCodexAccount } from "./run-input";
|
|
11
11
|
import type { ActivityServices, EscapedMcpTimeoutRecoveryDetail, RunAgentTurnInput, RunAgentTurnResult, SessionAttemptQuiescenceProof } from "./types";
|
|
12
12
|
import { type TurnSandboxLeaseHolderId } from "../sandbox-resume";
|
|
13
|
-
import { type LatencyMode, type SessionEvent, type SessionEventType, type SessionTurn, type ToolAuthNeededPayload, type TurnExecutionPolicyV1
|
|
13
|
+
import { type LatencyMode, type SessionEvent, type SessionEventType, type SessionTurn, type ToolAuthNeededPayload, type TurnExecutionPolicyV1 } from "@opengeni/contracts";
|
|
14
14
|
export declare const PROVIDER_BACKPRESSURE_DELAY_MS = 60000;
|
|
15
|
-
/**
|
|
16
|
-
export declare function credentialSubjectIdForTurnInitiator(
|
|
15
|
+
/** Broad personal lookup is allowed only for a direct human/API command. */
|
|
16
|
+
export declare function credentialSubjectIdForTurnInitiator(turn: Pick<SessionTurn, "source" | "initiator" | "initiatorContext">): string | undefined;
|
|
17
17
|
/**
|
|
18
18
|
* Direct authenticated-human work is the persisted human source with subject
|
|
19
19
|
* authority and no inherited agent or legacy provenance. Use this complete
|
package/dist/index.js
CHANGED
|
@@ -71,6 +71,7 @@ import {
|
|
|
71
71
|
CODEX_CREDENTIAL_LEASE_TTL_MS,
|
|
72
72
|
getCodexRotationSettings,
|
|
73
73
|
getWorkspaceModelPolicy as getWorkspaceModelPolicy2,
|
|
74
|
+
getWorkspaceGrant,
|
|
74
75
|
listCodexAccountStatuses as listCodexAccountStatuses2,
|
|
75
76
|
fetchCodexUsageForAccount as fetchCodexUsageForAccount2,
|
|
76
77
|
getSessionCodexState,
|
|
@@ -1027,6 +1028,8 @@ function workflowIdForSession(sessionId) {
|
|
|
1027
1028
|
import {
|
|
1028
1029
|
assertSessionAllowsProductModel,
|
|
1029
1030
|
defaultSessionMcpServerIds,
|
|
1031
|
+
directPersonalConnectionSubjectId,
|
|
1032
|
+
withFrozenPersonalConnectionDelegations,
|
|
1030
1033
|
resolveSessionToolPolicy
|
|
1031
1034
|
} from "@opengeni/core";
|
|
1032
1035
|
|
|
@@ -2803,6 +2806,7 @@ function mergeRigDefaultVariableSetEnvironment(rigDefaultValues, sessionValues)
|
|
|
2803
2806
|
import {
|
|
2804
2807
|
getSession,
|
|
2805
2808
|
getSessionGoal as getSessionGoal2,
|
|
2809
|
+
getSessionParentPersonalConnectionDelegations,
|
|
2806
2810
|
addSessionSystemUpdateWithSourceMutation,
|
|
2807
2811
|
claimPendingSessionSystemUpdateOutbox,
|
|
2808
2812
|
claimPendingSessionWorkflowWakes,
|
|
@@ -2821,6 +2825,11 @@ async function notifyParentOfChildIdle(svc, workspaceId, childSessionId, episode
|
|
|
2821
2825
|
const goal = await getSessionGoal2(svc.db, workspaceId, childSessionId);
|
|
2822
2826
|
const clientEventId = `child-completion:${childSessionId}:${episodeKey}`;
|
|
2823
2827
|
const payload = childCompletionPayload(child, goal);
|
|
2828
|
+
const personalConnectionDelegations = await getSessionParentPersonalConnectionDelegations(
|
|
2829
|
+
svc.db,
|
|
2830
|
+
workspaceId,
|
|
2831
|
+
childSessionId
|
|
2832
|
+
);
|
|
2824
2833
|
const outbox = await getOrCreateSessionSystemUpdateOutbox(svc.db, {
|
|
2825
2834
|
accountId: child.accountId,
|
|
2826
2835
|
workspaceId,
|
|
@@ -2832,7 +2841,8 @@ async function notifyParentOfChildIdle(svc, workspaceId, childSessionId, episode
|
|
|
2832
2841
|
dedupeKey: clientEventId,
|
|
2833
2842
|
summary: childCompletionSummary(child, goal, "idle"),
|
|
2834
2843
|
payload,
|
|
2835
|
-
lineage: { childSessionId: child.id, parentSessionId: child.parentSessionId }
|
|
2844
|
+
lineage: { childSessionId: child.id, parentSessionId: child.parentSessionId },
|
|
2845
|
+
personalConnectionDelegations
|
|
2836
2846
|
});
|
|
2837
2847
|
if (outbox.status === "delivered") {
|
|
2838
2848
|
return;
|
|
@@ -2882,7 +2892,8 @@ async function deliverParentSystemUpdateOutbox(svc, outbox) {
|
|
|
2882
2892
|
dedupeKey: outbox.dedupeKey,
|
|
2883
2893
|
summary: outbox.summary,
|
|
2884
2894
|
payload: outbox.payload,
|
|
2885
|
-
lineage: outbox.lineage
|
|
2895
|
+
lineage: outbox.lineage,
|
|
2896
|
+
personalConnectionDelegations: outbox.personalConnectionDelegations
|
|
2886
2897
|
},
|
|
2887
2898
|
async (tx) => {
|
|
2888
2899
|
await markSessionSystemUpdateOutboxDeliveredInTransaction(tx, outbox);
|
|
@@ -6284,11 +6295,11 @@ import {
|
|
|
6284
6295
|
} from "@opengeni/contracts";
|
|
6285
6296
|
import { createHash as createHash4, randomUUID as randomUUID2 } from "crypto";
|
|
6286
6297
|
var PROVIDER_BACKPRESSURE_DELAY_MS = 6e4;
|
|
6287
|
-
function credentialSubjectIdForTurnInitiator(
|
|
6288
|
-
return
|
|
6298
|
+
function credentialSubjectIdForTurnInitiator(turn) {
|
|
6299
|
+
return directPersonalConnectionSubjectId(turn);
|
|
6289
6300
|
}
|
|
6290
6301
|
function isDirectHumanTurnInitiation(turn) {
|
|
6291
|
-
if (turn.source !== "user" || turn.initiator.kind !== "subject") {
|
|
6302
|
+
if (turn.source !== "user" && turn.source !== "api" || turn.initiator.kind !== "subject") {
|
|
6292
6303
|
return false;
|
|
6293
6304
|
}
|
|
6294
6305
|
return !["via", "viaTruncated", "provenanceError", "backfill"].some(
|
|
@@ -9630,8 +9641,23 @@ function createRunAgentTurnActivity(services) {
|
|
|
9630
9641
|
attemptId: input.attemptId,
|
|
9631
9642
|
turn
|
|
9632
9643
|
});
|
|
9644
|
+
const personalConnectionDelegations = turn.personalConnectionDelegations;
|
|
9645
|
+
const delegatedMembershipChecks = /* @__PURE__ */ new Map();
|
|
9646
|
+
const delegatedOwnerHasMembership = async (subjectId) => {
|
|
9647
|
+
const existing = delegatedMembershipChecks.get(subjectId);
|
|
9648
|
+
if (existing) return await existing;
|
|
9649
|
+
const check = getWorkspaceGrant(db, subjectId, input.workspaceId).then(Boolean);
|
|
9650
|
+
delegatedMembershipChecks.set(subjectId, check);
|
|
9651
|
+
return await check;
|
|
9652
|
+
};
|
|
9653
|
+
const resolveFrozenCredential = withFrozenPersonalConnectionDelegations({
|
|
9654
|
+
resolveCredential: rawResolveCredential,
|
|
9655
|
+
settings: runSettings,
|
|
9656
|
+
personalConnectionDelegations,
|
|
9657
|
+
ownerHasWorkspaceMembership: delegatedOwnerHasMembership
|
|
9658
|
+
});
|
|
9633
9659
|
const resolveCredential = async (request) => {
|
|
9634
|
-
const result = await
|
|
9660
|
+
const result = await resolveFrozenCredential(request);
|
|
9635
9661
|
if (result.status === "ok") {
|
|
9636
9662
|
registerSecretRedactions(
|
|
9637
9663
|
headerSecretRedactions("MCP", result.headers, Object.keys(result.headers))
|
|
@@ -9639,7 +9665,7 @@ function createRunAgentTurnActivity(services) {
|
|
|
9639
9665
|
}
|
|
9640
9666
|
return result;
|
|
9641
9667
|
};
|
|
9642
|
-
const credentialSubjectId = credentialSubjectIdForTurnInitiator(turn
|
|
9668
|
+
const credentialSubjectId = credentialSubjectIdForTurnInitiator(turn);
|
|
9643
9669
|
preparedTools = await waitForTurnOperation(
|
|
9644
9670
|
withCodex(
|
|
9645
9671
|
() => runtime.prepareTools(runSettings, turnTools, {
|
|
@@ -14009,6 +14035,7 @@ import {
|
|
|
14009
14035
|
enqueueSessionWorkflowWakeIfRunnable as enqueueSessionWorkflowWakeIfRunnable2,
|
|
14010
14036
|
getBillingBalance as getBillingBalance5,
|
|
14011
14037
|
getScheduledTask,
|
|
14038
|
+
getScheduledTaskPersonalConnectionDelegations,
|
|
14012
14039
|
getRig,
|
|
14013
14040
|
getVariableSet,
|
|
14014
14041
|
isCodexBilledTurn as isCodexBilledTurn2,
|
|
@@ -14035,6 +14062,11 @@ function createScheduledTaskActivities(services) {
|
|
|
14035
14062
|
if (!task) {
|
|
14036
14063
|
return { action: "deleted" };
|
|
14037
14064
|
}
|
|
14065
|
+
const taskPersonalConnectionDelegations = await getScheduledTaskPersonalConnectionDelegations(
|
|
14066
|
+
db,
|
|
14067
|
+
task.workspaceId,
|
|
14068
|
+
task.id
|
|
14069
|
+
);
|
|
14038
14070
|
const slackBotConnection = task.agentConfig.slackBotConnectionId ? await requireOpenGeniSlackBotConnection(
|
|
14039
14071
|
db,
|
|
14040
14072
|
task.workspaceId,
|
|
@@ -14180,6 +14212,7 @@ function createScheduledTaskActivities(services) {
|
|
|
14180
14212
|
variableSetId: task.variableSetId ?? null,
|
|
14181
14213
|
rigId: frozenRigId,
|
|
14182
14214
|
rigVersionId: frozenRigVersionId,
|
|
14215
|
+
personalConnectionDelegations: taskPersonalConnectionDelegations,
|
|
14183
14216
|
maxNestedAgentDepthOverride: task.agentConfig.maxNestedAgentDepth ?? null,
|
|
14184
14217
|
// The durable agent config was privilege-checked when the task
|
|
14185
14218
|
// was created/updated. Preserve that explicit policy if a broader
|
|
@@ -14262,7 +14295,8 @@ function createScheduledTaskActivities(services) {
|
|
|
14262
14295
|
task.id,
|
|
14263
14296
|
run.id
|
|
14264
14297
|
),
|
|
14265
|
-
lineage: { scheduledTaskId: task.id, scheduledTaskRunId: run.id }
|
|
14298
|
+
lineage: { scheduledTaskId: task.id, scheduledTaskRunId: run.id },
|
|
14299
|
+
personalConnectionDelegations: taskPersonalConnectionDelegations
|
|
14266
14300
|
},
|
|
14267
14301
|
async (tx, wakeEventId) => {
|
|
14268
14302
|
if (!wakeEventId) throw new Error("Scheduled delivery has no wake event");
|
|
@@ -14361,7 +14395,8 @@ function createScheduledTaskActivities(services) {
|
|
|
14361
14395
|
task.id,
|
|
14362
14396
|
run.id
|
|
14363
14397
|
),
|
|
14364
|
-
lineage: { scheduledTaskId: task.id, scheduledTaskRunId: run.id }
|
|
14398
|
+
lineage: { scheduledTaskId: task.id, scheduledTaskRunId: run.id },
|
|
14399
|
+
personalConnectionDelegations: taskPersonalConnectionDelegations
|
|
14365
14400
|
},
|
|
14366
14401
|
async (tx, wakeEventId) => {
|
|
14367
14402
|
if (!wakeEventId) throw new Error("Scheduled delivery has no wake event");
|