@opengeni/worker-bundle 0.26.0-canary.5 → 0.26.0-canary.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/activities/goals.d.ts +0 -1
- package/dist/{activities-control-SHMDOQWS.js → activities-control-VMA3XMHE.js} +45 -8
- package/dist/{activities-control-SHMDOQWS.js.map → activities-control-VMA3XMHE.js.map} +1 -1
- package/dist/{activities-turn-GHSFZB64.js → activities-turn-57AOUNYN.js} +64 -13
- package/dist/activities-turn-57AOUNYN.js.map +1 -0
- package/dist/{chunk-O2LQWJIK.js → chunk-7LS42PHP.js} +4 -8
- package/dist/chunk-7LS42PHP.js.map +1 -0
- package/dist/index.js +1 -1
- package/package.json +17 -17
- package/src/activities/agent-turn/codex-capacity.ts +18 -3
- package/src/activities/agent-turn/run.ts +8 -0
- package/src/activities/agent-turn/tool-environment.ts +9 -0
- package/src/activities/agent-turn/xai-capacity.ts +17 -0
- package/src/activities/capabilities.ts +16 -3
- package/src/activities/goals.ts +5 -7
- package/src/activities/scheduled-tasks.ts +77 -8
- package/dist/activities-turn-GHSFZB64.js.map +0 -1
- package/dist/chunk-O2LQWJIK.js.map +0 -1
|
@@ -84,7 +84,7 @@ import {
|
|
|
84
84
|
withFirstPartyTools,
|
|
85
85
|
wrapLazyTurnBoxWithRouting,
|
|
86
86
|
wrapTurnBoxWithRouting
|
|
87
|
-
} from "./chunk-
|
|
87
|
+
} from "./chunk-7LS42PHP.js";
|
|
88
88
|
import {
|
|
89
89
|
StreamTimingMetrics,
|
|
90
90
|
makeMachineOpObserver,
|
|
@@ -116,6 +116,7 @@ import {
|
|
|
116
116
|
import { createProductionAgentRuntime, summarizeForCompaction as summarizeForCompaction2 } from "@opengeni/runtime";
|
|
117
117
|
|
|
118
118
|
// src/activities/agent-turn/run.ts
|
|
119
|
+
import { assertModelConnectionAllowsTurn } from "@opengeni/db";
|
|
119
120
|
import {
|
|
120
121
|
setSessionLastInputTokensForTurnAttempt,
|
|
121
122
|
getMaterializedSandboxFileResources as getMaterializedSandboxFileResources3,
|
|
@@ -9683,7 +9684,10 @@ function withXaiSubscriptionProvider(settings) {
|
|
|
9683
9684
|
return withXaiSubscriptionCatalogProvider(settings);
|
|
9684
9685
|
}
|
|
9685
9686
|
async function settingsWithWorkspaceGatewayCredential(db, accountId, workspaceId, settings, retainedProductModelId) {
|
|
9686
|
-
const activeCustomModels = await listWorkspaceGatewayCustomModels(db, {
|
|
9687
|
+
const activeCustomModels = await listWorkspaceGatewayCustomModels(db, {
|
|
9688
|
+
accountId,
|
|
9689
|
+
workspaceId
|
|
9690
|
+
});
|
|
9687
9691
|
const retainedUpstreamModelId = retainedProductModelId?.startsWith(
|
|
9688
9692
|
WORKSPACE_GATEWAY_MODEL_ID_PREFIX
|
|
9689
9693
|
) ? retainedProductModelId.slice(WORKSPACE_GATEWAY_MODEL_ID_PREFIX.length) : null;
|
|
@@ -9696,7 +9700,12 @@ async function settingsWithWorkspaceGatewayCredential(db, accountId, workspaceId
|
|
|
9696
9700
|
(model) => model.upstreamModelId === retainedCustomModel.upstreamModelId
|
|
9697
9701
|
) ? [...activeCustomModels, retainedCustomModel] : activeCustomModels;
|
|
9698
9702
|
const catalogSettings = withWorkspaceGatewayCatalogProvider(settings, customModels);
|
|
9699
|
-
const apiKey = await loadWorkspaceVercelAiGatewayApiKey(
|
|
9703
|
+
const apiKey = await loadWorkspaceVercelAiGatewayApiKey(
|
|
9704
|
+
db,
|
|
9705
|
+
settings,
|
|
9706
|
+
workspaceId,
|
|
9707
|
+
retainedProductModelId
|
|
9708
|
+
);
|
|
9700
9709
|
return apiKey ? withWorkspaceGatewayCredential(catalogSettings, apiKey, customModels) : catalogSettings;
|
|
9701
9710
|
}
|
|
9702
9711
|
async function settingsWithWorkspaceOpenRouterCredential(db, accountId, workspaceId, settings, retainedProductModelId) {
|
|
@@ -9716,7 +9725,12 @@ async function settingsWithWorkspaceOpenRouterCredential(db, accountId, workspac
|
|
|
9716
9725
|
(model) => model.upstreamModelId === retainedCustomModel.upstreamModelId
|
|
9717
9726
|
) ? [...activeCustomModels, retainedCustomModel] : activeCustomModels;
|
|
9718
9727
|
const catalogSettings = withWorkspaceOpenRouterCatalogProvider(settings, customModels);
|
|
9719
|
-
const apiKey = await loadWorkspaceOpenRouterApiKey(
|
|
9728
|
+
const apiKey = await loadWorkspaceOpenRouterApiKey(
|
|
9729
|
+
db,
|
|
9730
|
+
settings,
|
|
9731
|
+
workspaceId,
|
|
9732
|
+
retainedProductModelId
|
|
9733
|
+
);
|
|
9720
9734
|
return apiKey ? withWorkspaceOpenRouterCredential(catalogSettings, apiKey, customModels) : catalogSettings;
|
|
9721
9735
|
}
|
|
9722
9736
|
async function settingsWithOrganizationProviderCredentials(db, accountId, workspaceId, settings, retainedProductModelId) {
|
|
@@ -10159,6 +10173,7 @@ async function claimTurnAttempt(deps) {
|
|
|
10159
10173
|
|
|
10160
10174
|
// src/activities/agent-turn/codex-capacity.ts
|
|
10161
10175
|
import {
|
|
10176
|
+
connectionModelAllowed,
|
|
10162
10177
|
getSessionGoal as getSessionGoal2,
|
|
10163
10178
|
acquireCodexCredentialLease,
|
|
10164
10179
|
CodexCredentialLeaseAttemptFencedError,
|
|
@@ -10397,14 +10412,24 @@ async function selectCodexTurnCapacity(deps) {
|
|
|
10397
10412
|
const credentialSelectionStartedAt = performance.now();
|
|
10398
10413
|
let credentialSelectionOutcome = "completed";
|
|
10399
10414
|
try {
|
|
10400
|
-
const selectForTurn = (context, lockedSessionCodexState2) =>
|
|
10401
|
-
context
|
|
10402
|
-
|
|
10403
|
-
|
|
10404
|
-
|
|
10405
|
-
|
|
10406
|
-
|
|
10407
|
-
|
|
10415
|
+
const selectForTurn = (context, lockedSessionCodexState2) => {
|
|
10416
|
+
const allowed = context.accounts.filter(
|
|
10417
|
+
(account) => connectionModelAllowed(account.allowedModelIds, deps.turnExecutionPolicy.productModelId)
|
|
10418
|
+
);
|
|
10419
|
+
if (context.accounts.length > 0 && allowed.length === 0)
|
|
10420
|
+
throw new Error("This model is disabled for the connected Codex subscriptions");
|
|
10421
|
+
const sessionPin2 = lockedSessionCodexState2.pinnedCredentialId;
|
|
10422
|
+
if (sessionPin2 && lockedSessionCodexState2.pinSource !== "policy" && context.accounts.some((account) => account.id === sessionPin2) && !allowed.some((account) => account.id === sessionPin2))
|
|
10423
|
+
throw new Error("This model is disabled for the pinned Codex subscription");
|
|
10424
|
+
return selectCodexCredentialLeaseForTurn({
|
|
10425
|
+
context: { ...context, accounts: allowed },
|
|
10426
|
+
sessionId: input.sessionId,
|
|
10427
|
+
sessionPinnedCredentialId: lockedSessionCodexState2.pinnedCredentialId,
|
|
10428
|
+
sessionPinSource: lockedSessionCodexState2.pinSource,
|
|
10429
|
+
sessionLastCredentialId: lockedSessionCodexState2.lastCredentialId,
|
|
10430
|
+
now: /* @__PURE__ */ new Date()
|
|
10431
|
+
});
|
|
10432
|
+
};
|
|
10408
10433
|
let leaseAcquisitionStartedAtMs = performance.now();
|
|
10409
10434
|
let leased = await acquireCodexCredentialLease(
|
|
10410
10435
|
db,
|
|
@@ -13552,6 +13577,7 @@ async function bindLazySandboxProvisioner(deps) {
|
|
|
13552
13577
|
}
|
|
13553
13578
|
|
|
13554
13579
|
// src/activities/agent-turn/xai-capacity.ts
|
|
13580
|
+
import { connectionModelAllowed as connectionModelAllowed2 } from "@opengeni/db";
|
|
13555
13581
|
import {
|
|
13556
13582
|
getSessionGoal as getSessionGoal3,
|
|
13557
13583
|
acquireXaiCredentialLease,
|
|
@@ -13601,6 +13627,7 @@ async function selectXaiTurnCapacity(deps) {
|
|
|
13601
13627
|
authoritySnapshot
|
|
13602
13628
|
});
|
|
13603
13629
|
const leased = await acquireXaiCredentialLease(db, {
|
|
13630
|
+
modelId: deps.turnExecutionPolicy.productModelId,
|
|
13604
13631
|
accountId: input.accountId,
|
|
13605
13632
|
workspaceId: input.workspaceId,
|
|
13606
13633
|
subjectId,
|
|
@@ -13619,6 +13646,14 @@ async function selectXaiTurnCapacity(deps) {
|
|
|
13619
13646
|
leases.xai.confirmedUntilMs = leased.leasedUntil ? leaseStartedAtMs + XAI_CREDENTIAL_LEASE_TTL_MS2 : null;
|
|
13620
13647
|
leases.xai.held = providerTurn.effectiveXaiCredentialId !== null && leased.holderId !== null && leased.generation !== null && leases.xai.confirmedUntilMs !== null;
|
|
13621
13648
|
if (!providerTurn.effectiveXaiCredentialId) {
|
|
13649
|
+
const relevant = sessionPin?.pinnedCredentialId && sessionPin.pinSource !== "policy" ? leased.accounts.filter((account) => account.id === sessionPin.pinnedCredentialId) : leased.accounts;
|
|
13650
|
+
if (relevant.length > 0 && relevant.every(
|
|
13651
|
+
(account) => !connectionModelAllowed2(
|
|
13652
|
+
account.allowedModelIds,
|
|
13653
|
+
deps.turnExecutionPolicy.productModelId
|
|
13654
|
+
)
|
|
13655
|
+
))
|
|
13656
|
+
throw new Error("This model is disabled for the selected SuperGrok subscription");
|
|
13622
13657
|
const connected = leased.accounts.length;
|
|
13623
13658
|
const allocatorEnabled = leased.accounts.filter((account) => account.allocatorEnabled).length;
|
|
13624
13659
|
if (connected === 0) {
|
|
@@ -14672,6 +14707,7 @@ async function prepareRunCredentials(deps) {
|
|
|
14672
14707
|
}
|
|
14673
14708
|
|
|
14674
14709
|
// src/activities/agent-turn/tool-environment.ts
|
|
14710
|
+
import { getWorkspaceConnectionModelRestrictions } from "@opengeni/db";
|
|
14675
14711
|
import {
|
|
14676
14712
|
beginConnectorActionExecution,
|
|
14677
14713
|
completeConnectorActionExecution,
|
|
@@ -16879,6 +16915,7 @@ async function prepareTurnToolRuntime(deps) {
|
|
|
16879
16915
|
const currentSettings = currentCatalog.settings;
|
|
16880
16916
|
const xaiReadinessAuthority = xaiCatalogReadinessAuthority(turn, credentialSubjectId);
|
|
16881
16917
|
const [
|
|
16918
|
+
connectionModelRestrictions,
|
|
16882
16919
|
policy,
|
|
16883
16920
|
codexSubscriptionActive,
|
|
16884
16921
|
xaiSubscriptionActive,
|
|
@@ -16891,6 +16928,12 @@ async function prepareTurnToolRuntime(deps) {
|
|
|
16891
16928
|
organizationOpenRouterConnectionActive,
|
|
16892
16929
|
organizationOpenRouterCustomModels
|
|
16893
16930
|
] = await Promise.all([
|
|
16931
|
+
getWorkspaceConnectionModelRestrictions(
|
|
16932
|
+
db,
|
|
16933
|
+
input.workspaceId,
|
|
16934
|
+
xaiReadinessAuthority?.subjectId ?? credentialSubjectId ?? "worker:model-access",
|
|
16935
|
+
xaiReadinessAuthority?.authoritySnapshot
|
|
16936
|
+
),
|
|
16894
16937
|
getWorkspaceModelPolicy2(db, input.workspaceId),
|
|
16895
16938
|
workspaceCodexSubscriptionActive3(db, currentSettings, input.workspaceId),
|
|
16896
16939
|
xaiReadinessAuthority && currentSettings.supergrokSubscriptionEnabled ? workspaceXaiSubscriptionActiveForAuthority(db, currentSettings, {
|
|
@@ -16930,6 +16973,7 @@ async function prepareTurnToolRuntime(deps) {
|
|
|
16930
16973
|
]);
|
|
16931
16974
|
return {
|
|
16932
16975
|
selections: resolveWorkspaceModelSelection({
|
|
16976
|
+
connectionModelRestrictions,
|
|
16933
16977
|
settings: currentSettings,
|
|
16934
16978
|
policy,
|
|
16935
16979
|
codexSubscriptionActive,
|
|
@@ -19377,6 +19421,13 @@ function createRunAgentTurnActivity(services) {
|
|
|
19377
19421
|
requiredGeneratedVideoFiles
|
|
19378
19422
|
});
|
|
19379
19423
|
if ("exit" in governance) return governance.exit;
|
|
19424
|
+
await assertModelConnectionAllowsTurn(db, {
|
|
19425
|
+
workspaceId: input.workspaceId,
|
|
19426
|
+
subjectId: turn.initiatingHumanSubjectId ?? "worker:model-access",
|
|
19427
|
+
modelId: turnExecutionPolicy.productModelId,
|
|
19428
|
+
codexCredentialId: providerTurn.effectiveCodexCredentialId,
|
|
19429
|
+
xaiCredentialId: providerTurn.effectiveXaiCredentialId
|
|
19430
|
+
});
|
|
19380
19431
|
const {
|
|
19381
19432
|
runtimePreparationStartedAt,
|
|
19382
19433
|
packRuntime,
|
|
@@ -21506,4 +21557,4 @@ export {
|
|
|
21506
21557
|
createTurnActivities,
|
|
21507
21558
|
createTurnActivitiesFromServices
|
|
21508
21559
|
};
|
|
21509
|
-
//# sourceMappingURL=activities-turn-
|
|
21560
|
+
//# sourceMappingURL=activities-turn-57AOUNYN.js.map
|