@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.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opengeni/worker-bundle",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.1",
|
|
4
4
|
"description": "OpenGeni worker entry and reusable embedded lifecycle, shipped with a release-coherent pre-bundled Temporal workflow artifact.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -41,16 +41,16 @@
|
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"@opengeni/agent-proto": "^0.3.0",
|
|
43
43
|
"@opengeni/codex": "^0.2.9",
|
|
44
|
-
"@opengeni/config": "^0.9.
|
|
45
|
-
"@opengeni/contracts": "^0.
|
|
46
|
-
"@opengeni/core": "^0.
|
|
47
|
-
"@opengeni/db": "^0.
|
|
48
|
-
"@opengeni/documents": "^0.2.
|
|
49
|
-
"@opengeni/events": "^0.3.
|
|
50
|
-
"@opengeni/github": "^0.4.
|
|
51
|
-
"@opengeni/observability": "^0.4.
|
|
52
|
-
"@opengeni/runtime": "^0.16.
|
|
53
|
-
"@opengeni/storage": "^0.2.
|
|
44
|
+
"@opengeni/config": "^0.9.3",
|
|
45
|
+
"@opengeni/contracts": "^0.30.0",
|
|
46
|
+
"@opengeni/core": "^0.17.1",
|
|
47
|
+
"@opengeni/db": "^0.21.0",
|
|
48
|
+
"@opengeni/documents": "^0.2.66",
|
|
49
|
+
"@opengeni/events": "^0.3.57",
|
|
50
|
+
"@opengeni/github": "^0.4.15",
|
|
51
|
+
"@opengeni/observability": "^0.4.2",
|
|
52
|
+
"@opengeni/runtime": "^0.16.2",
|
|
53
|
+
"@opengeni/storage": "^0.2.52",
|
|
54
54
|
"@temporalio/activity": "^1.17.0",
|
|
55
55
|
"@temporalio/client": "^1.17.0",
|
|
56
56
|
"@temporalio/worker": "^1.17.0",
|
|
@@ -27,6 +27,7 @@ import {
|
|
|
27
27
|
CODEX_CREDENTIAL_LEASE_TTL_MS,
|
|
28
28
|
getCodexRotationSettings,
|
|
29
29
|
getWorkspaceModelPolicy,
|
|
30
|
+
getWorkspaceGrant,
|
|
30
31
|
listCodexAccountStatuses,
|
|
31
32
|
fetchCodexUsageForAccount,
|
|
32
33
|
getSessionCodexState,
|
|
@@ -201,6 +202,8 @@ import { mergeResourceRefs } from "./common";
|
|
|
201
202
|
import {
|
|
202
203
|
assertSessionAllowsProductModel,
|
|
203
204
|
defaultSessionMcpServerIds,
|
|
205
|
+
directPersonalConnectionSubjectId,
|
|
206
|
+
withFrozenPersonalConnectionDelegations,
|
|
204
207
|
resolveSessionToolPolicy,
|
|
205
208
|
} from "@opengeni/core";
|
|
206
209
|
import { maybeCompactContext, settleFailedContextCompactionLandmark } from "./context-compaction";
|
|
@@ -327,7 +330,6 @@ import {
|
|
|
327
330
|
type SessionTurn,
|
|
328
331
|
type ToolAuthNeededPayload,
|
|
329
332
|
type TurnExecutionPolicyV1,
|
|
330
|
-
type TurnInitiator,
|
|
331
333
|
} from "@opengeni/contracts";
|
|
332
334
|
import { createHash, randomUUID } from "node:crypto";
|
|
333
335
|
|
|
@@ -337,11 +339,11 @@ import { createHash, randomUUID } from "node:crypto";
|
|
|
337
339
|
// budget against the same window.
|
|
338
340
|
export const PROVIDER_BACKPRESSURE_DELAY_MS = 60_000;
|
|
339
341
|
|
|
340
|
-
/**
|
|
342
|
+
/** Broad personal lookup is allowed only for a direct human/API command. */
|
|
341
343
|
export function credentialSubjectIdForTurnInitiator(
|
|
342
|
-
|
|
344
|
+
turn: Pick<SessionTurn, "source" | "initiator" | "initiatorContext">,
|
|
343
345
|
): string | undefined {
|
|
344
|
-
return
|
|
346
|
+
return directPersonalConnectionSubjectId(turn);
|
|
345
347
|
}
|
|
346
348
|
|
|
347
349
|
/**
|
|
@@ -353,7 +355,7 @@ export function credentialSubjectIdForTurnInitiator(
|
|
|
353
355
|
export function isDirectHumanTurnInitiation(
|
|
354
356
|
turn: Pick<SessionTurn, "source" | "initiator" | "initiatorContext">,
|
|
355
357
|
): boolean {
|
|
356
|
-
if (turn.source !== "user" || turn.initiator.kind !== "subject") {
|
|
358
|
+
if ((turn.source !== "user" && turn.source !== "api") || turn.initiator.kind !== "subject") {
|
|
357
359
|
return false;
|
|
358
360
|
}
|
|
359
361
|
return !["via", "viaTruncated", "provenanceError", "backfill"].some((key) =>
|
|
@@ -5368,8 +5370,23 @@ export function createRunAgentTurnActivity(services: () => Promise<ActivityServi
|
|
|
5368
5370
|
attemptId: input.attemptId,
|
|
5369
5371
|
turn,
|
|
5370
5372
|
});
|
|
5373
|
+
const personalConnectionDelegations = turn.personalConnectionDelegations;
|
|
5374
|
+
const delegatedMembershipChecks = new Map<string, Promise<boolean>>();
|
|
5375
|
+
const delegatedOwnerHasMembership = async (subjectId: string): Promise<boolean> => {
|
|
5376
|
+
const existing = delegatedMembershipChecks.get(subjectId);
|
|
5377
|
+
if (existing) return await existing;
|
|
5378
|
+
const check = getWorkspaceGrant(db, subjectId, input.workspaceId).then(Boolean);
|
|
5379
|
+
delegatedMembershipChecks.set(subjectId, check);
|
|
5380
|
+
return await check;
|
|
5381
|
+
};
|
|
5382
|
+
const resolveFrozenCredential = withFrozenPersonalConnectionDelegations({
|
|
5383
|
+
resolveCredential: rawResolveCredential,
|
|
5384
|
+
settings: runSettings,
|
|
5385
|
+
personalConnectionDelegations,
|
|
5386
|
+
ownerHasWorkspaceMembership: delegatedOwnerHasMembership,
|
|
5387
|
+
});
|
|
5371
5388
|
const resolveCredential: typeof rawResolveCredential = async (request) => {
|
|
5372
|
-
const result = await
|
|
5389
|
+
const result = await resolveFrozenCredential(request);
|
|
5373
5390
|
if (result.status === "ok") {
|
|
5374
5391
|
registerSecretRedactions(
|
|
5375
5392
|
headerSecretRedactions("MCP", result.headers, Object.keys(result.headers)),
|
|
@@ -5377,7 +5394,7 @@ export function createRunAgentTurnActivity(services: () => Promise<ActivityServi
|
|
|
5377
5394
|
}
|
|
5378
5395
|
return result;
|
|
5379
5396
|
};
|
|
5380
|
-
const credentialSubjectId = credentialSubjectIdForTurnInitiator(turn
|
|
5397
|
+
const credentialSubjectId = credentialSubjectIdForTurnInitiator(turn);
|
|
5381
5398
|
preparedTools = await waitForTurnOperation(
|
|
5382
5399
|
withCodex(() =>
|
|
5383
5400
|
runtime.prepareTools(runSettings, turnTools, {
|
|
@@ -3,6 +3,7 @@ import type { Session, SessionGoal, SessionSystemUpdatePayload } from "@opengeni
|
|
|
3
3
|
import {
|
|
4
4
|
getSession,
|
|
5
5
|
getSessionGoal,
|
|
6
|
+
getSessionParentPersonalConnectionDelegations,
|
|
6
7
|
addSessionSystemUpdateWithSourceMutation,
|
|
7
8
|
claimPendingSessionSystemUpdateOutbox,
|
|
8
9
|
claimPendingSessionWorkflowWakes,
|
|
@@ -57,6 +58,11 @@ export async function notifyParentOfChildIdle(
|
|
|
57
58
|
// guard so a nudge that slips through still cannot revive the goal.
|
|
58
59
|
const clientEventId = `child-completion:${childSessionId}:${episodeKey}`;
|
|
59
60
|
const payload = childCompletionPayload(child, goal);
|
|
61
|
+
const personalConnectionDelegations = await getSessionParentPersonalConnectionDelegations(
|
|
62
|
+
svc.db,
|
|
63
|
+
workspaceId,
|
|
64
|
+
childSessionId,
|
|
65
|
+
);
|
|
60
66
|
const outbox = await getOrCreateSessionSystemUpdateOutbox(svc.db, {
|
|
61
67
|
accountId: child.accountId,
|
|
62
68
|
workspaceId,
|
|
@@ -69,6 +75,7 @@ export async function notifyParentOfChildIdle(
|
|
|
69
75
|
summary: childCompletionSummary(child, goal, "idle"),
|
|
70
76
|
payload,
|
|
71
77
|
lineage: { childSessionId: child.id, parentSessionId: child.parentSessionId },
|
|
78
|
+
personalConnectionDelegations,
|
|
72
79
|
});
|
|
73
80
|
if (outbox.status === "delivered") {
|
|
74
81
|
return;
|
|
@@ -138,6 +145,7 @@ async function deliverParentSystemUpdateOutbox(
|
|
|
138
145
|
summary: outbox.summary,
|
|
139
146
|
payload: outbox.payload,
|
|
140
147
|
lineage: outbox.lineage,
|
|
148
|
+
personalConnectionDelegations: outbox.personalConnectionDelegations,
|
|
141
149
|
},
|
|
142
150
|
async (tx) => {
|
|
143
151
|
await markSessionSystemUpdateOutboxDeliveredInTransaction(tx, outbox);
|
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
enqueueSessionWorkflowWakeIfRunnable,
|
|
18
18
|
getBillingBalance,
|
|
19
19
|
getScheduledTask,
|
|
20
|
+
getScheduledTaskPersonalConnectionDelegations,
|
|
20
21
|
getRig,
|
|
21
22
|
getVariableSet,
|
|
22
23
|
isCodexBilledTurn,
|
|
@@ -63,6 +64,11 @@ export function createScheduledTaskActivities(services: () => Promise<ActivitySe
|
|
|
63
64
|
if (!task) {
|
|
64
65
|
return { action: "deleted" };
|
|
65
66
|
}
|
|
67
|
+
const taskPersonalConnectionDelegations = await getScheduledTaskPersonalConnectionDelegations(
|
|
68
|
+
db,
|
|
69
|
+
task.workspaceId,
|
|
70
|
+
task.id,
|
|
71
|
+
);
|
|
66
72
|
// A scheduled bot selection was authorized when the task was written,
|
|
67
73
|
// but connection status and tenant/role binding are mutable. Revalidate
|
|
68
74
|
// before any session/model cost and never fall back to a personal Slack
|
|
@@ -237,6 +243,7 @@ export function createScheduledTaskActivities(services: () => Promise<ActivitySe
|
|
|
237
243
|
variableSetId: task.variableSetId ?? null,
|
|
238
244
|
rigId: frozenRigId,
|
|
239
245
|
rigVersionId: frozenRigVersionId,
|
|
246
|
+
personalConnectionDelegations: taskPersonalConnectionDelegations,
|
|
240
247
|
maxNestedAgentDepthOverride: task.agentConfig.maxNestedAgentDepth ?? null,
|
|
241
248
|
// The durable agent config was privilege-checked when the task
|
|
242
249
|
// was created/updated. Preserve that explicit policy if a broader
|
|
@@ -328,6 +335,7 @@ export function createScheduledTaskActivities(services: () => Promise<ActivitySe
|
|
|
328
335
|
run.id,
|
|
329
336
|
),
|
|
330
337
|
lineage: { scheduledTaskId: task.id, scheduledTaskRunId: run.id },
|
|
338
|
+
personalConnectionDelegations: taskPersonalConnectionDelegations,
|
|
331
339
|
},
|
|
332
340
|
async (tx, wakeEventId) => {
|
|
333
341
|
if (!wakeEventId) throw new Error("Scheduled delivery has no wake event");
|
|
@@ -444,6 +452,7 @@ export function createScheduledTaskActivities(services: () => Promise<ActivitySe
|
|
|
444
452
|
run.id,
|
|
445
453
|
),
|
|
446
454
|
lineage: { scheduledTaskId: task.id, scheduledTaskRunId: run.id },
|
|
455
|
+
personalConnectionDelegations: taskPersonalConnectionDelegations,
|
|
447
456
|
},
|
|
448
457
|
async (tx, wakeEventId) => {
|
|
449
458
|
if (!wakeEventId) throw new Error("Scheduled delivery has no wake event");
|