@opengeni/worker-bundle 0.23.4 → 0.24.2-canary.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/activities/agent-turn/admission.d.ts +17 -2
- package/dist/activities/agent-turn/claim.d.ts +1 -0
- package/dist/activities/agent-turn/codex.d.ts +2 -2
- package/dist/activities/agent-turn/list-models.d.ts +16 -0
- package/dist/activities/agent-turn/model-usage.d.ts +15 -1
- package/dist/activities/agent-turn/quiescence.d.ts +2 -0
- package/dist/activities/agent-turn/run.d.ts +9 -0
- package/dist/activities/agent-turn/sandbox-runtime.d.ts +15 -0
- package/dist/activities/agent-turn/session-title.d.ts +21 -0
- package/dist/activities/agent-turn/stream-attempt.d.ts +4 -0
- package/dist/activities/agent-turn/tool-environment.d.ts +2 -0
- package/dist/activities/agent-turn/tool-policy.d.ts +36 -5
- package/dist/activities/agent-turn/turn-context.d.ts +4 -1
- package/dist/activities/agent-turn.d.ts +1 -1
- package/dist/activities/automations.d.ts +1 -0
- package/dist/activities/capabilities.d.ts +3 -1
- package/dist/activities/context-compaction.d.ts +2 -0
- package/dist/activities/goals.d.ts +11 -0
- package/dist/activities/image-generation-references.d.ts +2 -1
- package/dist/activities/scheduled-tasks.d.ts +1 -0
- package/dist/activities/types.d.ts +8 -0
- package/dist/{activities-control-52W5IDWM.js → activities-control-ZWH7J4KZ.js} +297 -180
- package/dist/activities-control-ZWH7J4KZ.js.map +1 -0
- package/dist/activities-control.d.ts +2 -0
- package/dist/{activities-turn-A2G2KLSY.js → activities-turn-I4OPLQLS.js} +898 -333
- package/dist/activities-turn-I4OPLQLS.js.map +1 -0
- package/dist/activities.d.ts +2 -0
- package/dist/{chunk-GFNXVZVQ.js → chunk-65JEWP2Q.js} +107 -7
- package/dist/chunk-65JEWP2Q.js.map +1 -0
- package/dist/{chunk-GRFQTTSQ.js → chunk-GDCLDKSH.js} +7 -3
- package/dist/{chunk-GRFQTTSQ.js.map → chunk-GDCLDKSH.js.map} +1 -1
- package/dist/{chunk-IPVMCAW5.js → chunk-RQNH6CGR.js} +111 -62
- package/dist/chunk-RQNH6CGR.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +43 -7
- package/dist/index.js.map +1 -1
- package/dist/observability-metrics.d.ts +34 -7
- package/dist/sandbox-reaper-timeout.d.ts +2 -2
- package/dist/sandbox-resume.d.ts +6 -1
- package/dist/workflow-bundle.js +26 -3
- package/dist/workflows/activities.d.ts +5 -0
- package/dist/workflows/automations.d.ts +5 -0
- package/package.json +17 -17
- package/src/activities/agent-run-admission.ts +7 -1
- package/src/activities/agent-turn/admission.ts +47 -6
- package/src/activities/agent-turn/claim.ts +33 -5
- package/src/activities/agent-turn/codex.ts +2 -2
- package/src/activities/agent-turn/compaction-prep.ts +8 -1
- package/src/activities/agent-turn/finalization.ts +31 -17
- package/src/activities/agent-turn/list-models.ts +101 -0
- package/src/activities/agent-turn/model-usage.ts +120 -45
- package/src/activities/agent-turn/quiescence.ts +11 -2
- package/src/activities/agent-turn/run.ts +80 -4
- package/src/activities/agent-turn/sandbox-runtime.ts +78 -81
- package/src/activities/agent-turn/session-title.ts +55 -2
- package/src/activities/agent-turn/stream-attempt.ts +266 -135
- package/src/activities/agent-turn/tool-environment.ts +102 -7
- package/src/activities/agent-turn/tool-policy.ts +58 -5
- package/src/activities/agent-turn/turn-context.ts +8 -2
- package/src/activities/agent-turn.ts +5 -1
- package/src/activities/api-integrations.ts +11 -1
- package/src/activities/automations.ts +122 -67
- package/src/activities/capabilities.ts +129 -2
- package/src/activities/context-compaction.ts +3 -0
- package/src/activities/goals.ts +108 -31
- package/src/activities/image-generation-references.ts +9 -9
- package/src/activities/mcp-credentials.ts +53 -0
- package/src/activities/rig-verification.ts +5 -3
- package/src/activities/scheduled-tasks.ts +217 -110
- package/src/activities/site-auth-maintenance.ts +12 -12
- package/src/activities/types.ts +6 -0
- package/src/activities.ts +1 -0
- package/src/activity-services.ts +4 -1
- package/src/github-rest-mcp.ts +2 -1
- package/src/index.ts +34 -4
- package/src/observability-metrics.ts +154 -14
- package/src/sandbox-reaper-timeout.ts +10 -4
- package/src/sandbox-resume.ts +58 -8
- package/src/workflows/activities.ts +15 -0
- package/src/workflows/automations.ts +21 -2
- package/dist/activities-control-52W5IDWM.js.map +0 -1
- package/dist/activities-turn-A2G2KLSY.js.map +0 -1
- package/dist/chunk-GFNXVZVQ.js.map +0 -1
- package/dist/chunk-IPVMCAW5.js.map +0 -1
|
@@ -41,7 +41,6 @@ import {
|
|
|
41
41
|
mergeResourceRefs,
|
|
42
42
|
nextStreamEvent,
|
|
43
43
|
persistOrSignalSessionAttemptQuiescence,
|
|
44
|
-
persistSandboxDeadlineRotationCheckpoint,
|
|
45
44
|
postClaimDatabaseRecoveryFailure,
|
|
46
45
|
preClaimAdmissionFailure,
|
|
47
46
|
providerRecoveryCountAfterModelRequestPhase,
|
|
@@ -81,7 +80,7 @@ import {
|
|
|
81
80
|
waitForTurnOperation,
|
|
82
81
|
waitForWarmSnapshot,
|
|
83
82
|
withFirstPartyTools
|
|
84
|
-
} from "./chunk-
|
|
83
|
+
} from "./chunk-RQNH6CGR.js";
|
|
85
84
|
import {
|
|
86
85
|
StreamTimingMetrics,
|
|
87
86
|
makeMachineOpObserver,
|
|
@@ -90,6 +89,7 @@ import {
|
|
|
90
89
|
recordBatchFlush,
|
|
91
90
|
recordCompanyBrainContributions,
|
|
92
91
|
recordContextCompaction,
|
|
92
|
+
recordContextCompactionStarted,
|
|
93
93
|
recordCreditMicros,
|
|
94
94
|
recordModelCacheTokens,
|
|
95
95
|
recordModelInputTokens,
|
|
@@ -106,7 +106,7 @@ import {
|
|
|
106
106
|
recordTurnWorkerPreparationTotal,
|
|
107
107
|
runtimeMetricsHooksForObservability,
|
|
108
108
|
turnLifecycleMetricsFor
|
|
109
|
-
} from "./chunk-
|
|
109
|
+
} from "./chunk-65JEWP2Q.js";
|
|
110
110
|
|
|
111
111
|
// src/activities-turn.ts
|
|
112
112
|
import { createProductionAgentRuntime, summarizeForCompaction as summarizeForCompaction2 } from "@opengeni/runtime";
|
|
@@ -136,7 +136,9 @@ import {
|
|
|
136
136
|
codexRequestStorage,
|
|
137
137
|
withCodexRequestOverrides
|
|
138
138
|
} from "@opengeni/codex";
|
|
139
|
-
import {
|
|
139
|
+
import {
|
|
140
|
+
xaiSubscriptionRequestStorage
|
|
141
|
+
} from "@opengeni/xai-subscription";
|
|
140
142
|
|
|
141
143
|
// src/activities/xai-auth.ts
|
|
142
144
|
import { environmentsEncryptionKeyBytes } from "@opengeni/config";
|
|
@@ -3466,7 +3468,9 @@ function createTurnContext(input) {
|
|
|
3466
3468
|
billingState: {
|
|
3467
3469
|
isCodexTurn: false,
|
|
3468
3470
|
isXaiTurn: false,
|
|
3469
|
-
isExternallyBilledTurn: false
|
|
3471
|
+
isExternallyBilledTurn: false,
|
|
3472
|
+
chargesOpenGeniCredits: true,
|
|
3473
|
+
countsTowardTokenCap: true
|
|
3470
3474
|
},
|
|
3471
3475
|
sandboxState: {
|
|
3472
3476
|
resolvedSandbox: null,
|
|
@@ -3484,7 +3488,8 @@ function createTurnContext(input) {
|
|
|
3484
3488
|
sandboxHolderId: null,
|
|
3485
3489
|
sandboxGroupId: null,
|
|
3486
3490
|
leaseHeartbeatTimer: void 0,
|
|
3487
|
-
|
|
3491
|
+
rotationPreemptionInFlight: null,
|
|
3492
|
+
deadlineRotationRequested: false,
|
|
3488
3493
|
snapshotInFlight: null,
|
|
3489
3494
|
firstProviderRequestStarted: false,
|
|
3490
3495
|
turnEndCaptureInProgress: false,
|
|
@@ -4430,6 +4435,19 @@ async function finalizeTurnAttempt(deps) {
|
|
|
4430
4435
|
cancellationSignal,
|
|
4431
4436
|
control.activityStatus
|
|
4432
4437
|
);
|
|
4438
|
+
const drainInFlightWarmSnapshot = async () => {
|
|
4439
|
+
const snapshot = sandboxState.snapshotInFlight;
|
|
4440
|
+
if (!snapshot) return;
|
|
4441
|
+
await snapshot.catch((error) => {
|
|
4442
|
+
console.error(
|
|
4443
|
+
"in-flight workspace snapshot settlement failed (turn outcome unaffected)",
|
|
4444
|
+
safeErrorDiagnostic(error)
|
|
4445
|
+
);
|
|
4446
|
+
});
|
|
4447
|
+
if (sandboxState.snapshotInFlight === snapshot) {
|
|
4448
|
+
sandboxState.snapshotInFlight = null;
|
|
4449
|
+
}
|
|
4450
|
+
};
|
|
4433
4451
|
try {
|
|
4434
4452
|
const toolCancellationFence = eventing.toolCancellationFenceRef.current;
|
|
4435
4453
|
renewals.gitCredentialRenewalClosed = true;
|
|
@@ -4666,7 +4684,8 @@ async function finalizeTurnAttempt(deps) {
|
|
|
4666
4684
|
}
|
|
4667
4685
|
const runTurnEndPersistence = shouldRunTurnEndWorkspacePersistence({
|
|
4668
4686
|
activityStatus: control.activityStatus,
|
|
4669
|
-
cancellationRequested: finalizerSignal?.aborted === true
|
|
4687
|
+
cancellationRequested: finalizerSignal?.aborted === true,
|
|
4688
|
+
deadlineRotationRequested: sandboxState.deadlineRotationRequested
|
|
4670
4689
|
});
|
|
4671
4690
|
if (runTurnEndPersistence && attempt.turnId && sandboxState.resolvedSandbox && sandboxState.setupBoxSession && sandboxState.sandboxGroupId) {
|
|
4672
4691
|
sandboxState.turnEndCaptureInProgress = true;
|
|
@@ -4745,22 +4764,14 @@ async function finalizeTurnAttempt(deps) {
|
|
|
4745
4764
|
if (sandboxState.leaseHeartbeatTimer) {
|
|
4746
4765
|
stopLeaseHeartbeat();
|
|
4747
4766
|
}
|
|
4748
|
-
if (sandboxState.
|
|
4749
|
-
await
|
|
4750
|
-
() => void 0
|
|
4751
|
-
);
|
|
4767
|
+
if (sandboxState.rotationPreemptionInFlight) {
|
|
4768
|
+
await sandboxState.rotationPreemptionInFlight.catch(() => void 0);
|
|
4752
4769
|
}
|
|
4770
|
+
await drainInFlightWarmSnapshot();
|
|
4753
4771
|
if (sandboxState.resolvedSandbox) {
|
|
4754
4772
|
const settledTurnId = attempt.turnId;
|
|
4755
4773
|
if (runTurnEndPersistence && sandboxState.setupBoxSession && sandboxState.sandboxGroupId && settledTurnId) {
|
|
4756
|
-
|
|
4757
|
-
await waitForWarmSnapshot(
|
|
4758
|
-
sandboxState.snapshotInFlight,
|
|
4759
|
-
settings.sandboxSnapshotTimeoutMs,
|
|
4760
|
-
finalizerSignal
|
|
4761
|
-
);
|
|
4762
|
-
}
|
|
4763
|
-
const persisted = await maybePersistWarmWorkspaceSnapshot(
|
|
4774
|
+
const snapshot = maybePersistWarmWorkspaceSnapshot(
|
|
4764
4775
|
{ db, settings, objectStorage },
|
|
4765
4776
|
{
|
|
4766
4777
|
accountId: input.accountId,
|
|
@@ -4774,6 +4785,8 @@ async function finalizeTurnAttempt(deps) {
|
|
|
4774
4785
|
sandboxState.resolvedSandbox.leaseEpoch,
|
|
4775
4786
|
finalizerSignal
|
|
4776
4787
|
);
|
|
4788
|
+
sandboxState.snapshotInFlight = snapshot.settled;
|
|
4789
|
+
const persisted = await snapshot;
|
|
4777
4790
|
if (persisted && eventing.publish) {
|
|
4778
4791
|
await eventing.publish([
|
|
4779
4792
|
{
|
|
@@ -4792,6 +4805,10 @@ async function finalizeTurnAttempt(deps) {
|
|
|
4792
4805
|
);
|
|
4793
4806
|
} finally {
|
|
4794
4807
|
stopLeaseHeartbeat();
|
|
4808
|
+
if (sandboxState.rotationPreemptionInFlight) {
|
|
4809
|
+
await sandboxState.rotationPreemptionInFlight.catch(() => void 0);
|
|
4810
|
+
}
|
|
4811
|
+
await drainInFlightWarmSnapshot();
|
|
4795
4812
|
const sandboxReleaseTargets = new Set(sandboxState.lateSandboxesAwaitingWriterDrain);
|
|
4796
4813
|
sandboxState.lateSandboxesAwaitingWriterDrain.clear();
|
|
4797
4814
|
if (sandboxState.resolvedSandbox) {
|
|
@@ -4946,11 +4963,13 @@ import {
|
|
|
4946
4963
|
} from "@opengeni/runtime";
|
|
4947
4964
|
import {
|
|
4948
4965
|
calculateGatewayReportedCostBreakdown,
|
|
4966
|
+
calculateGatewayReportedProviderCostMicros,
|
|
4949
4967
|
calculateModelUsageCostBreakdown,
|
|
4950
4968
|
configuredModelPricingSchedules,
|
|
4969
|
+
resolveModelProvider,
|
|
4951
4970
|
responseSatisfiesLatencyMode,
|
|
4952
|
-
|
|
4953
|
-
|
|
4971
|
+
OPENGENI_GATEWAY_PROVIDER_ID,
|
|
4972
|
+
WORKSPACE_GATEWAY_PROVIDER_ID
|
|
4954
4973
|
} from "@opengeni/config";
|
|
4955
4974
|
import { CODEX_PROVIDER_ID } from "@opengeni/codex";
|
|
4956
4975
|
function modelUsageSourceKey(input) {
|
|
@@ -4977,6 +4996,7 @@ function createModelResponseEventState(claimedSourceKeys = /* @__PURE__ */ new S
|
|
|
4977
4996
|
function createCompactionModelUsageEventState(claimedSourceKeys = /* @__PURE__ */ new Set()) {
|
|
4978
4997
|
return { usageCount: 0, claimedSourceKeys };
|
|
4979
4998
|
}
|
|
4999
|
+
var createSessionTitleModelUsageEventState = createCompactionModelUsageEventState;
|
|
4980
5000
|
function modelResponseContextSignal(state) {
|
|
4981
5001
|
return state.contextSignal;
|
|
4982
5002
|
}
|
|
@@ -5035,9 +5055,10 @@ async function processModelResponseTerminalEvent(input) {
|
|
|
5035
5055
|
turnAttemptId: input.turnAttemptId,
|
|
5036
5056
|
model: input.model,
|
|
5037
5057
|
externallyBilled: input.externallyBilled,
|
|
5058
|
+
...input.chargesOpenGeniCredits !== void 0 ? { chargesOpenGeniCredits: input.chargesOpenGeniCredits } : {},
|
|
5059
|
+
...input.countsTowardTokenCap !== void 0 ? { countsTowardTokenCap: input.countsTowardTokenCap } : {},
|
|
5038
5060
|
usage: responseUsage.usage,
|
|
5039
5061
|
normalizedUsage,
|
|
5040
|
-
gatewayManaged: input.provider === OPENGENI_GATEWAY_PROVIDER_ID,
|
|
5041
5062
|
gatewayBilling: responseUsage.gatewayBilling,
|
|
5042
5063
|
sourceKey,
|
|
5043
5064
|
...input.latencyMode ? { latencyMode: input.latencyMode } : {},
|
|
@@ -5056,6 +5077,8 @@ async function processModelResponseTerminalEvent(input) {
|
|
|
5056
5077
|
sourceKey,
|
|
5057
5078
|
usage: responseUsage,
|
|
5058
5079
|
normalizedUsage,
|
|
5080
|
+
...billing ? { billingPath: billing.billingPath } : {},
|
|
5081
|
+
...billing?.upstreamProvider ? { upstreamProvider: billing.upstreamProvider } : {},
|
|
5059
5082
|
servingAccountHash: accountContext.servingAccountHash,
|
|
5060
5083
|
accountChangedFromPrevCall: accountContext.accountChangedFromPrevCall,
|
|
5061
5084
|
emittedSourceKeys: input.emittedSourceKeys
|
|
@@ -5104,7 +5127,7 @@ async function processCompactionModelUsageEvent(input) {
|
|
|
5104
5127
|
const sourceKey = modelUsageSourceKey({
|
|
5105
5128
|
responseId: input.usage.responseId,
|
|
5106
5129
|
dispatchId: input.dispatchId,
|
|
5107
|
-
positionalKey:
|
|
5130
|
+
positionalKey: `${input.sourceKind ?? "compaction"}-${usageOrdinal}`
|
|
5108
5131
|
});
|
|
5109
5132
|
if (input.state.claimedSourceKeys.has(sourceKey)) {
|
|
5110
5133
|
return { status: "duplicate", sourceKey };
|
|
@@ -5131,9 +5154,10 @@ async function processCompactionModelUsageEvent(input) {
|
|
|
5131
5154
|
turnAttemptId: input.turnAttemptId,
|
|
5132
5155
|
model: input.model,
|
|
5133
5156
|
externallyBilled: input.externallyBilled,
|
|
5157
|
+
...input.chargesOpenGeniCredits !== void 0 ? { chargesOpenGeniCredits: input.chargesOpenGeniCredits } : {},
|
|
5158
|
+
...input.countsTowardTokenCap !== void 0 ? { countsTowardTokenCap: input.countsTowardTokenCap } : {},
|
|
5134
5159
|
usage: input.usage.usage,
|
|
5135
5160
|
normalizedUsage,
|
|
5136
|
-
gatewayManaged: input.provider === OPENGENI_GATEWAY_PROVIDER_ID,
|
|
5137
5161
|
gatewayBilling: input.usage.gatewayBilling,
|
|
5138
5162
|
sourceKey,
|
|
5139
5163
|
observability: input.observability
|
|
@@ -5151,6 +5175,8 @@ async function processCompactionModelUsageEvent(input) {
|
|
|
5151
5175
|
sourceKey,
|
|
5152
5176
|
usage: input.usage,
|
|
5153
5177
|
normalizedUsage,
|
|
5178
|
+
...billing ? { billingPath: billing.billingPath } : {},
|
|
5179
|
+
...billing?.upstreamProvider ? { upstreamProvider: billing.upstreamProvider } : {},
|
|
5154
5180
|
servingAccountHash: accountContext.servingAccountHash,
|
|
5155
5181
|
accountChangedFromPrevCall: accountContext.accountChangedFromPrevCall,
|
|
5156
5182
|
emittedSourceKeys: input.emittedSourceKeys
|
|
@@ -5176,6 +5202,12 @@ async function processCompactionModelUsageEvent(input) {
|
|
|
5176
5202
|
});
|
|
5177
5203
|
return { status: "processed", sourceKey, authoritative };
|
|
5178
5204
|
}
|
|
5205
|
+
async function processSessionTitleModelUsageEvent(input) {
|
|
5206
|
+
return await processCompactionModelUsageEvent({
|
|
5207
|
+
...input,
|
|
5208
|
+
sourceKind: "session-title"
|
|
5209
|
+
});
|
|
5210
|
+
}
|
|
5179
5211
|
async function emitModelCallUsage(input) {
|
|
5180
5212
|
const usage = input.usage && typeof input.usage === "object" && "usage" in input.usage ? input.usage.usage : null;
|
|
5181
5213
|
if (!usage || typeof usage !== "object") {
|
|
@@ -5197,6 +5229,8 @@ async function emitModelCallUsage(input) {
|
|
|
5197
5229
|
providerApi: input.providerApi,
|
|
5198
5230
|
model: input.model,
|
|
5199
5231
|
sourceKey: input.sourceKey,
|
|
5232
|
+
...input.billingPath ? { billingPath: input.billingPath } : {},
|
|
5233
|
+
...input.upstreamProvider ? { upstreamProvider: input.upstreamProvider } : {},
|
|
5200
5234
|
...telemetry
|
|
5201
5235
|
}
|
|
5202
5236
|
}
|
|
@@ -5253,22 +5287,35 @@ async function recordModelUsageAndDebitCredits(settings, db, input) {
|
|
|
5253
5287
|
const inputTokens = sanitizedUsage.inputTokens ?? 0;
|
|
5254
5288
|
const outputTokens = sanitizedUsage.outputTokens ?? 0;
|
|
5255
5289
|
const totalTokens = sanitizedUsage.totalTokens ?? 0;
|
|
5256
|
-
const
|
|
5290
|
+
const chargesOpenGeniCredits = input.chargesOpenGeniCredits ?? !input.externallyBilled;
|
|
5291
|
+
const countsTowardTokenCap = input.countsTowardTokenCap ?? !input.externallyBilled;
|
|
5292
|
+
const resolvedGatewayModel = input.gatewayBilling ? resolveModelProvider(settings, input.model) : void 0;
|
|
5293
|
+
const gatewayProviderId = resolvedGatewayModel?.provider.id;
|
|
5294
|
+
const gatewayBilling = gatewayProviderId === OPENGENI_GATEWAY_PROVIDER_ID || gatewayProviderId === WORKSPACE_GATEWAY_PROVIDER_ID ? input.gatewayBilling : void 0;
|
|
5295
|
+
const allowedProviders = resolvedGatewayModel?.model.requestPolicy?.gateway.only;
|
|
5296
|
+
const unpinnedWorkspaceGatewayModel = gatewayProviderId === WORKSPACE_GATEWAY_PROVIDER_ID && allowedProviders === void 0;
|
|
5257
5297
|
if (gatewayBilling) {
|
|
5258
|
-
|
|
5259
|
-
(candidate) => candidate.productId === input.model
|
|
5260
|
-
);
|
|
5261
|
-
if (!gatewayModel || !gatewayModel.providers.includes(gatewayBilling.finalProvider)) {
|
|
5298
|
+
if (!unpinnedWorkspaceGatewayModel && (!allowedProviders || !allowedProviders.includes(gatewayBilling.finalProvider))) {
|
|
5262
5299
|
throw new Error(
|
|
5263
5300
|
`AI Gateway reported unapproved provider ${gatewayBilling.finalProvider} for ${input.model}`
|
|
5264
5301
|
);
|
|
5265
5302
|
}
|
|
5303
|
+
if (unpinnedWorkspaceGatewayModel && chargesOpenGeniCredits) {
|
|
5304
|
+
throw new Error(
|
|
5305
|
+
`Workspace Gateway custom model ${input.model} cannot charge OpenGeni credits without pinned pricing`
|
|
5306
|
+
);
|
|
5307
|
+
}
|
|
5266
5308
|
}
|
|
5267
5309
|
const pricingSchedules = configuredModelPricingSchedules(settings);
|
|
5268
5310
|
const configuredPricingModel = pricingSchedules[input.model] ? input.model : input.model.startsWith("codex/") && pricingSchedules[input.model.slice("codex/".length)] ? input.model.slice("codex/".length) : null;
|
|
5269
|
-
const pricingBreakdown = gatewayBilling ?
|
|
5311
|
+
const pricingBreakdown = gatewayBilling ? unpinnedWorkspaceGatewayModel ? {
|
|
5312
|
+
providerCostMicros: calculateGatewayReportedProviderCostMicros(
|
|
5313
|
+
gatewayBilling.inferenceCostUsd
|
|
5314
|
+
),
|
|
5315
|
+
creditCostMicros: 0
|
|
5316
|
+
} : calculateGatewayReportedCostBreakdown(
|
|
5270
5317
|
settings,
|
|
5271
|
-
input.model,
|
|
5318
|
+
configuredPricingModel ?? input.model,
|
|
5272
5319
|
gatewayBilling.inferenceCostUsd,
|
|
5273
5320
|
{ inputTokens }
|
|
5274
5321
|
) : configuredPricingModel ? calculateModelUsageCostBreakdown(settings, configuredPricingModel, sanitizedUsage, {
|
|
@@ -5276,43 +5323,46 @@ async function recordModelUsageAndDebitCredits(settings, db, input) {
|
|
|
5276
5323
|
}) : null;
|
|
5277
5324
|
const hasCompleteCoreTokenTelemetry = normalizedUsage.telemetry.inputTokens !== null && normalizedUsage.telemetry.outputTokens !== null;
|
|
5278
5325
|
const estimatedProviderCostMicros = gatewayBilling ? pricingBreakdown?.providerCostMicros ?? null : hasCompleteCoreTokenTelemetry ? pricingBreakdown?.providerCostMicros ?? null : null;
|
|
5326
|
+
const equivalentCreditCostMicros = pricingBreakdown && !unpinnedWorkspaceGatewayModel ? gatewayBilling || hasCompleteCoreTokenTelemetry ? pricingBreakdown.creditCostMicros : null : null;
|
|
5279
5327
|
const pricingSource = gatewayBilling ? "gateway_reported" : estimatedProviderCostMicros !== null ? "configured_list_price" : null;
|
|
5280
|
-
if (
|
|
5328
|
+
if (countsTowardTokenCap && totalTokens > 0) {
|
|
5281
5329
|
await recordUsageEvent(db, {
|
|
5282
5330
|
accountId: input.accountId,
|
|
5283
5331
|
workspaceId: input.workspaceId,
|
|
5284
|
-
eventType: "model.
|
|
5285
|
-
quantity:
|
|
5286
|
-
unit: "
|
|
5332
|
+
eventType: "model.tokens",
|
|
5333
|
+
quantity: totalTokens,
|
|
5334
|
+
unit: "tokens",
|
|
5287
5335
|
sourceResourceType: "model_response",
|
|
5288
5336
|
sourceResourceId: `${input.turnId}:${input.sourceKey}`,
|
|
5289
5337
|
sessionId: input.sessionId,
|
|
5290
5338
|
turnId: input.turnId,
|
|
5291
5339
|
turnAttemptId: input.turnAttemptId,
|
|
5292
|
-
idempotencyKey: `usage:model.
|
|
5340
|
+
idempotencyKey: `usage:model.tokens:${input.turnId}:${input.sourceKey}`
|
|
5293
5341
|
});
|
|
5294
|
-
return {
|
|
5295
|
-
billingPath: "external",
|
|
5296
|
-
pricedCostMicros: 0,
|
|
5297
|
-
estimatedProviderCostMicros,
|
|
5298
|
-
pricingSource,
|
|
5299
|
-
normalizedUsage
|
|
5300
|
-
};
|
|
5301
5342
|
}
|
|
5302
|
-
if (
|
|
5343
|
+
if (!chargesOpenGeniCredits) {
|
|
5303
5344
|
await recordUsageEvent(db, {
|
|
5304
5345
|
accountId: input.accountId,
|
|
5305
5346
|
workspaceId: input.workspaceId,
|
|
5306
|
-
eventType: "model.
|
|
5307
|
-
quantity:
|
|
5308
|
-
unit: "
|
|
5347
|
+
eventType: "model.cost",
|
|
5348
|
+
quantity: 0,
|
|
5349
|
+
unit: "usd_micros",
|
|
5309
5350
|
sourceResourceType: "model_response",
|
|
5310
5351
|
sourceResourceId: `${input.turnId}:${input.sourceKey}`,
|
|
5311
5352
|
sessionId: input.sessionId,
|
|
5312
5353
|
turnId: input.turnId,
|
|
5313
5354
|
turnAttemptId: input.turnAttemptId,
|
|
5314
|
-
idempotencyKey: `usage:model.
|
|
5355
|
+
idempotencyKey: `usage:model.cost:${input.turnId}:${input.sourceKey}`
|
|
5315
5356
|
});
|
|
5357
|
+
return {
|
|
5358
|
+
billingPath: "external",
|
|
5359
|
+
pricedCostMicros: 0,
|
|
5360
|
+
estimatedProviderCostMicros,
|
|
5361
|
+
equivalentCreditCostMicros,
|
|
5362
|
+
pricingSource,
|
|
5363
|
+
normalizedUsage,
|
|
5364
|
+
...gatewayBilling ? { upstreamProvider: gatewayBilling.finalProvider } : {}
|
|
5365
|
+
};
|
|
5316
5366
|
}
|
|
5317
5367
|
const shouldDebit = settings.billingMode === "stripe" || settings.usageLimitsMode === "managed";
|
|
5318
5368
|
if (!shouldDebit || totalTokens === 0 && !gatewayBilling) {
|
|
@@ -5320,6 +5370,7 @@ async function recordModelUsageAndDebitCredits(settings, db, input) {
|
|
|
5320
5370
|
billingPath: "opengeni_credits",
|
|
5321
5371
|
pricedCostMicros: 0,
|
|
5322
5372
|
estimatedProviderCostMicros,
|
|
5373
|
+
equivalentCreditCostMicros,
|
|
5323
5374
|
pricingSource,
|
|
5324
5375
|
normalizedUsage,
|
|
5325
5376
|
...gatewayBilling ? { upstreamProvider: gatewayBilling.finalProvider } : {}
|
|
@@ -5373,6 +5424,7 @@ async function recordModelUsageAndDebitCredits(settings, db, input) {
|
|
|
5373
5424
|
billingPath: "opengeni_credits",
|
|
5374
5425
|
pricedCostMicros: costMicros,
|
|
5375
5426
|
estimatedProviderCostMicros,
|
|
5427
|
+
equivalentCreditCostMicros,
|
|
5376
5428
|
pricingSource,
|
|
5377
5429
|
normalizedUsage,
|
|
5378
5430
|
...gatewayBilling ? { upstreamProvider: gatewayBilling.finalProvider } : {}
|
|
@@ -5394,6 +5446,7 @@ async function recordAuthoritativeModelCallFact(input) {
|
|
|
5394
5446
|
billingPath: input.billing.billingPath,
|
|
5395
5447
|
pricedCostMicros: input.billing.pricedCostMicros,
|
|
5396
5448
|
estimatedProviderCostMicros: input.billing.estimatedProviderCostMicros,
|
|
5449
|
+
equivalentCreditCostMicros: input.billing.equivalentCreditCostMicros,
|
|
5397
5450
|
pricingSource: input.billing.pricingSource,
|
|
5398
5451
|
inputTokens: telemetry.inputTokens,
|
|
5399
5452
|
outputTokens: telemetry.outputTokens,
|
|
@@ -5414,9 +5467,10 @@ function sanitizedModelUsageInput(normalized) {
|
|
|
5414
5467
|
...normalized.telemetry.inputTokens !== null ? { inputTokens: normalized.telemetry.inputTokens } : {},
|
|
5415
5468
|
...normalized.telemetry.outputTokens !== null ? { outputTokens: normalized.telemetry.outputTokens } : {},
|
|
5416
5469
|
...normalized.totalTokens !== null ? { totalTokens: normalized.totalTokens } : {},
|
|
5417
|
-
...normalized.telemetry.cachedTokens !== null ? {
|
|
5470
|
+
...normalized.telemetry.cachedTokens !== null || normalized.telemetry.cacheWriteTokens !== null ? {
|
|
5418
5471
|
inputTokensDetails: {
|
|
5419
|
-
cached_tokens: normalized.telemetry.cachedTokens
|
|
5472
|
+
...normalized.telemetry.cachedTokens === null ? {} : { cached_tokens: normalized.telemetry.cachedTokens },
|
|
5473
|
+
...normalized.telemetry.cacheWriteTokens === null ? {} : { cache_write_tokens: normalized.telemetry.cacheWriteTokens }
|
|
5420
5474
|
}
|
|
5421
5475
|
} : {},
|
|
5422
5476
|
...normalized.requestUsageEntries ? { requestUsageEntries: normalized.requestUsageEntries } : {}
|
|
@@ -5440,6 +5494,10 @@ function assertWorkspaceHumanInputAllowed(enabled, kind, attempted) {
|
|
|
5440
5494
|
function credentialSubjectIdForTurnInitiator(turn) {
|
|
5441
5495
|
return directPersonalConnectionSubjectId(turn);
|
|
5442
5496
|
}
|
|
5497
|
+
function xaiCatalogReadinessAuthority(turn, directCredentialSubjectId) {
|
|
5498
|
+
const subjectId = turn.initiatingHumanSubjectId ?? directCredentialSubjectId;
|
|
5499
|
+
return subjectId ? { subjectId, authoritySnapshot: turn.xaiProviderAccountAuthoritySnapshot } : null;
|
|
5500
|
+
}
|
|
5443
5501
|
function isDirectHumanTurnInitiation(turn) {
|
|
5444
5502
|
if (turn.source !== "user" && turn.source !== "api" || turn.initiator.kind !== "subject") {
|
|
5445
5503
|
return false;
|
|
@@ -5463,9 +5521,20 @@ function shouldPublishToolAuthNeededForTurn(payload, trigger, turn) {
|
|
|
5463
5521
|
const text = trigger.payload.text;
|
|
5464
5522
|
return typeof text === "string" && /\bslack\b/i.test(text);
|
|
5465
5523
|
}
|
|
5524
|
+
function rollingSafeToolAuthNeededPayload(payload) {
|
|
5525
|
+
if (payload.authoritySource !== "host") {
|
|
5526
|
+
return payload;
|
|
5527
|
+
}
|
|
5528
|
+
return {
|
|
5529
|
+
...payload,
|
|
5530
|
+
reason: "unsupported_auth",
|
|
5531
|
+
hostReason: payload.hostReason ?? payload.reason
|
|
5532
|
+
};
|
|
5533
|
+
}
|
|
5466
5534
|
function turnExecutionPolicyBillingIdentity(policy) {
|
|
5467
5535
|
return {
|
|
5468
5536
|
externallyBilled: policy.billing.metering === "external",
|
|
5537
|
+
countsTowardTokenCap: policy.billing.upstreamPayer === "deployment",
|
|
5469
5538
|
codexSubscription: policy.providerId === "codex-subscription" && policy.credentialSource.kind === "connected_subscription" && policy.credentialSource.provider === "codex",
|
|
5470
5539
|
xaiSubscription: policy.providerId === "supergrok-subscription" && policy.credentialSource.kind === "connected_subscription" && policy.credentialSource.provider === "xai"
|
|
5471
5540
|
};
|
|
@@ -5519,8 +5588,8 @@ var BudgetExhaustedError = class extends Error {
|
|
|
5519
5588
|
this.name = "BudgetExhaustedError";
|
|
5520
5589
|
}
|
|
5521
5590
|
};
|
|
5522
|
-
async function ensureRunAllowed(settings, db, accountId, workspaceId, isExternallyBilledTurn, entitlements) {
|
|
5523
|
-
if (
|
|
5591
|
+
async function ensureRunAllowed(settings, db, accountId, workspaceId, isExternallyBilledTurn, entitlements, chargesOpenGeniCredits = !isExternallyBilledTurn, countsTowardTokenCap = !isExternallyBilledTurn) {
|
|
5592
|
+
if (chargesOpenGeniCredits && entitlements && (settings.billingMode === "stripe" || settings.usageLimitsMode === "managed")) {
|
|
5524
5593
|
const decision = await entitlements.admitRun({
|
|
5525
5594
|
accountId,
|
|
5526
5595
|
workspaceId,
|
|
@@ -5530,7 +5599,7 @@ async function ensureRunAllowed(settings, db, accountId, workspaceId, isExternal
|
|
|
5530
5599
|
if (!decision.allowed) {
|
|
5531
5600
|
throw new Error(decision.reason || "insufficient OpenGeni credits");
|
|
5532
5601
|
}
|
|
5533
|
-
} else if (
|
|
5602
|
+
} else if (chargesOpenGeniCredits && (settings.billingMode === "stripe" || settings.usageLimitsMode === "managed")) {
|
|
5534
5603
|
const balance = await getBillingBalance(db, accountId);
|
|
5535
5604
|
if (balance.balanceMicros <= 0) {
|
|
5536
5605
|
throw new Error("insufficient OpenGeni credits");
|
|
@@ -5550,7 +5619,7 @@ async function ensureRunAllowed(settings, db, accountId, workspaceId, isExternal
|
|
|
5550
5619
|
);
|
|
5551
5620
|
}
|
|
5552
5621
|
}
|
|
5553
|
-
if (
|
|
5622
|
+
if (countsTowardTokenCap && limits.maxMonthlyTokensPerWorkspace) {
|
|
5554
5623
|
const used = await sumUsageQuantity(db, {
|
|
5555
5624
|
workspaceId,
|
|
5556
5625
|
eventType: "model.tokens",
|
|
@@ -6620,8 +6689,10 @@ import {
|
|
|
6620
6689
|
attachOpenSuffixToPendingToolCalls,
|
|
6621
6690
|
clearDurablePendingSessionToolCalls,
|
|
6622
6691
|
isSessionCompactionRequested,
|
|
6623
|
-
nextSessionHistoryPosition as nextSessionHistoryPosition2
|
|
6692
|
+
nextSessionHistoryPosition as nextSessionHistoryPosition2,
|
|
6693
|
+
updateSessionTitleWithEvent
|
|
6624
6694
|
} from "@opengeni/db";
|
|
6695
|
+
import { publishDurableSessionEvents as publishDurableSessionEvents3 } from "@opengeni/events";
|
|
6625
6696
|
import {
|
|
6626
6697
|
normalizeModelCallUsage as normalizeModelCallUsage2,
|
|
6627
6698
|
normalizeSdkEvent,
|
|
@@ -6633,6 +6704,7 @@ import {
|
|
|
6633
6704
|
withRunCredentialsSession,
|
|
6634
6705
|
runOwnedSandboxSetup
|
|
6635
6706
|
} from "@opengeni/runtime";
|
|
6707
|
+
import { serviceTierForLatencyMode } from "@opengeni/config";
|
|
6636
6708
|
|
|
6637
6709
|
// src/activities/context-compaction.ts
|
|
6638
6710
|
import {
|
|
@@ -7211,6 +7283,7 @@ async function maybeCompactContext(db, settings, scope, lastInputTokens, summari
|
|
|
7211
7283
|
`turn attempt was fenced while recording context compaction start: ${started.reason}`
|
|
7212
7284
|
);
|
|
7213
7285
|
}
|
|
7286
|
+
options.onCompactionStarted?.(trigger);
|
|
7214
7287
|
await options.publishLiveEvents?.(started.events);
|
|
7215
7288
|
if (useRemoteV2) {
|
|
7216
7289
|
const outcome2 = await compactContextRemoteV2(
|
|
@@ -7752,6 +7825,111 @@ import {
|
|
|
7752
7825
|
resolveWorkspaceAgentHumanInputEnabled
|
|
7753
7826
|
} from "@opengeni/contracts";
|
|
7754
7827
|
|
|
7828
|
+
// src/activities/agent-turn/session-title.ts
|
|
7829
|
+
import { hasPermission } from "@opengeni/core";
|
|
7830
|
+
import {
|
|
7831
|
+
AUTOMATIC_SESSION_TITLE_FALLBACK,
|
|
7832
|
+
DEFAULT_FIRST_PARTY_MCP_PERMISSIONS
|
|
7833
|
+
} from "@opengeni/contracts";
|
|
7834
|
+
var SESSION_TITLE_MODEL_TOOL_NAME = "opengeni__set_session_title";
|
|
7835
|
+
var SESSION_TITLE_DESCRIPTION = "Set this session's display title to a concise 3-7 word topic label. Use a stable noun phrase about the actual task or subject, never a quote/prefix of a prompt, greeting, request boilerplate, URL, identifier, credential, token, or other sensitive value. Call once on a new session, then only when the topic materially changes. Never call it as routine setup after a continuation, resume, or interruption, or merely to reassert the same title. A human-set title cannot be replaced.";
|
|
7836
|
+
function shouldRequestMissingSessionTitle(input) {
|
|
7837
|
+
const title = input.title?.trim() ?? "";
|
|
7838
|
+
const needsSemanticTitle = input.titleSource !== "user" && (!title || title === AUTOMATIC_SESSION_TITLE_FALLBACK);
|
|
7839
|
+
if (!needsSemanticTitle) return false;
|
|
7840
|
+
if (!input.firstPartyMcpTools.includes("set_session_title")) return false;
|
|
7841
|
+
const permissions = input.firstPartyMcpPermissions ?? DEFAULT_FIRST_PARTY_MCP_PERMISSIONS;
|
|
7842
|
+
return hasPermission([...permissions], "sessions:control");
|
|
7843
|
+
}
|
|
7844
|
+
function sessionTitleToolPlan(input) {
|
|
7845
|
+
const titleToolAvailable = input.shouldRequestTitle && input.tools.some((tool) => tool.kind === "mcp" && tool.id === "opengeni");
|
|
7846
|
+
const generateTitleInParallel = titleToolAvailable && input.parallelGenerationAvailable;
|
|
7847
|
+
const promoteTitleTool = titleToolAvailable && !generateTitleInParallel;
|
|
7848
|
+
return {
|
|
7849
|
+
promoteTitleTool,
|
|
7850
|
+
generateTitleInParallel,
|
|
7851
|
+
remoteFirstPartyMcpTools: titleToolAvailable ? input.selectedFirstPartyMcpTools.filter((tool) => tool !== "set_session_title") : [...input.selectedFirstPartyMcpTools],
|
|
7852
|
+
preparationIndependentToolNames: promoteTitleTool ? [SESSION_TITLE_MODEL_TOOL_NAME] : []
|
|
7853
|
+
};
|
|
7854
|
+
}
|
|
7855
|
+
var PARALLEL_SESSION_TITLE_TIMEOUT_MS = 15e3;
|
|
7856
|
+
function startParallelSessionTitleGeneration(input) {
|
|
7857
|
+
const cancellationController = new AbortController();
|
|
7858
|
+
const timeoutSignal = AbortSignal.timeout(input.timeoutMs ?? PARALLEL_SESSION_TITLE_TIMEOUT_MS);
|
|
7859
|
+
const signals = [cancellationController.signal, timeoutSignal];
|
|
7860
|
+
if (input.signal) signals.push(input.signal);
|
|
7861
|
+
const signal = AbortSignal.any(signals);
|
|
7862
|
+
const generation = input.generate(signal).then((result) => signal.aborted ? null : result).catch((error) => {
|
|
7863
|
+
if (!signal.aborted) input.onError?.(error);
|
|
7864
|
+
return null;
|
|
7865
|
+
});
|
|
7866
|
+
let finished = null;
|
|
7867
|
+
return {
|
|
7868
|
+
finish: () => {
|
|
7869
|
+
if (finished) return finished;
|
|
7870
|
+
finished = generation;
|
|
7871
|
+
return finished;
|
|
7872
|
+
},
|
|
7873
|
+
cancel: async () => {
|
|
7874
|
+
cancellationController.abort();
|
|
7875
|
+
await generation;
|
|
7876
|
+
}
|
|
7877
|
+
};
|
|
7878
|
+
}
|
|
7879
|
+
function createSessionTitleAttemptToolDefinition(input) {
|
|
7880
|
+
return {
|
|
7881
|
+
identity: { serverId: "opengeni", toolName: "set_session_title" },
|
|
7882
|
+
modelName: SESSION_TITLE_MODEL_TOOL_NAME,
|
|
7883
|
+
codemodePath: ["opengeni", "set_session_title"],
|
|
7884
|
+
title: "Set session title",
|
|
7885
|
+
description: SESSION_TITLE_DESCRIPTION,
|
|
7886
|
+
inputSchema: {
|
|
7887
|
+
type: "object",
|
|
7888
|
+
properties: {
|
|
7889
|
+
title: { type: "string", minLength: 1, maxLength: 200 }
|
|
7890
|
+
},
|
|
7891
|
+
required: ["title"],
|
|
7892
|
+
additionalProperties: false
|
|
7893
|
+
},
|
|
7894
|
+
outputSchema: {
|
|
7895
|
+
type: "object",
|
|
7896
|
+
properties: {
|
|
7897
|
+
ok: { type: "boolean", const: true },
|
|
7898
|
+
updated: { type: "boolean" },
|
|
7899
|
+
title: { type: "string" }
|
|
7900
|
+
},
|
|
7901
|
+
required: ["ok", "updated", "title"],
|
|
7902
|
+
additionalProperties: false
|
|
7903
|
+
},
|
|
7904
|
+
annotations: {
|
|
7905
|
+
title: "Set session title",
|
|
7906
|
+
readOnlyHint: false,
|
|
7907
|
+
destructiveHint: false,
|
|
7908
|
+
idempotentHint: true,
|
|
7909
|
+
openWorldHint: false
|
|
7910
|
+
},
|
|
7911
|
+
source: "opengeni",
|
|
7912
|
+
approval: "none",
|
|
7913
|
+
execute: async (args) => {
|
|
7914
|
+
const title = args.title;
|
|
7915
|
+
if (typeof title !== "string") {
|
|
7916
|
+
throw new Error("set_session_title requires a title string");
|
|
7917
|
+
}
|
|
7918
|
+
const result = await input.updateTitle(title);
|
|
7919
|
+
const output = {
|
|
7920
|
+
ok: true,
|
|
7921
|
+
updated: result.updated,
|
|
7922
|
+
title: result.title ?? title
|
|
7923
|
+
};
|
|
7924
|
+
return {
|
|
7925
|
+
isError: false,
|
|
7926
|
+
content: [{ type: "text", text: JSON.stringify(output) }],
|
|
7927
|
+
structuredContent: output
|
|
7928
|
+
};
|
|
7929
|
+
}
|
|
7930
|
+
};
|
|
7931
|
+
}
|
|
7932
|
+
|
|
7755
7933
|
// src/activities/agent-turn/sandbox-shared-preparation.ts
|
|
7756
7934
|
import { randomUUID } from "crypto";
|
|
7757
7935
|
import {
|
|
@@ -7918,6 +8096,7 @@ async function runTurnStreamAttempt(deps) {
|
|
|
7918
8096
|
input,
|
|
7919
8097
|
settings,
|
|
7920
8098
|
db,
|
|
8099
|
+
bus,
|
|
7921
8100
|
runtime,
|
|
7922
8101
|
objectStorage,
|
|
7923
8102
|
observability,
|
|
@@ -7948,6 +8127,7 @@ async function runTurnStreamAttempt(deps) {
|
|
|
7948
8127
|
attachCodemodeTokenRenewal,
|
|
7949
8128
|
attachRunCredentialRenewal,
|
|
7950
8129
|
withProviderRequestContext,
|
|
8130
|
+
withSessionTitleProviderRequestContext,
|
|
7951
8131
|
publishCompactionLiveEvents,
|
|
7952
8132
|
publishCompactionOutcomeEvents,
|
|
7953
8133
|
recordCompanyBrainContributionReceiptOnce,
|
|
@@ -7973,6 +8153,8 @@ async function runTurnStreamAttempt(deps) {
|
|
|
7973
8153
|
providerApi,
|
|
7974
8154
|
runSettings,
|
|
7975
8155
|
turnTools,
|
|
8156
|
+
generateSessionTitleInParallel,
|
|
8157
|
+
sessionTitlePrompt,
|
|
7976
8158
|
compactSummarizer,
|
|
7977
8159
|
settleDeferredSteerAfterCompaction,
|
|
7978
8160
|
compactionModelHistoryProjector,
|
|
@@ -7992,6 +8174,69 @@ async function runTurnStreamAttempt(deps) {
|
|
|
7992
8174
|
if (!activeTurnId) {
|
|
7993
8175
|
throw new Error("Turn id was not initialized");
|
|
7994
8176
|
}
|
|
8177
|
+
const sessionTitleUsageState = createSessionTitleModelUsageEventState(
|
|
8178
|
+
claimedModelUsageSourceKeys
|
|
8179
|
+
);
|
|
8180
|
+
let parallelSessionTitle = null;
|
|
8181
|
+
let parallelSessionTitleFinished = false;
|
|
8182
|
+
const finishParallelSessionTitle = async () => {
|
|
8183
|
+
if (parallelSessionTitleFinished) return;
|
|
8184
|
+
parallelSessionTitleFinished = true;
|
|
8185
|
+
const generated = await parallelSessionTitle?.finish();
|
|
8186
|
+
if (!generated) return;
|
|
8187
|
+
if (generated.usage) {
|
|
8188
|
+
await processSessionTitleModelUsageEvent({
|
|
8189
|
+
usage: generated.usage,
|
|
8190
|
+
state: sessionTitleUsageState,
|
|
8191
|
+
dispatchId: modelUsageDispatchId,
|
|
8192
|
+
settings,
|
|
8193
|
+
db,
|
|
8194
|
+
observability,
|
|
8195
|
+
publish: eventing.publish,
|
|
8196
|
+
accountId: input.accountId,
|
|
8197
|
+
workspaceId: input.workspaceId,
|
|
8198
|
+
sessionId: input.sessionId,
|
|
8199
|
+
turnId: activeTurnId,
|
|
8200
|
+
turnAttemptId: input.attemptId,
|
|
8201
|
+
provider: resolvedModel?.provider.id ?? settings.openaiProvider,
|
|
8202
|
+
providerApi: resolvedModel?.provider.api ?? "responses",
|
|
8203
|
+
model: resolvedModel?.configured.id ?? turn.model,
|
|
8204
|
+
externallyBilled: billingState.isExternallyBilledTurn,
|
|
8205
|
+
chargesOpenGeniCredits: billingState.chargesOpenGeniCredits,
|
|
8206
|
+
countsTowardTokenCap: billingState.countsTowardTokenCap,
|
|
8207
|
+
servingCredentialId: providerTurn.effectiveCodexCredentialId,
|
|
8208
|
+
priorSessionCredentialId: providerTurn.priorSessionCodexCredentialId,
|
|
8209
|
+
emittedSourceKeys: emittedModelUsageSourceKeys,
|
|
8210
|
+
renewLease: () => leases.renewServing("model_usage"),
|
|
8211
|
+
leaseLost: leases.servingLost,
|
|
8212
|
+
leaseLostMessage: "Provider credential lease expired during session title generation"
|
|
8213
|
+
});
|
|
8214
|
+
}
|
|
8215
|
+
if (!generated.title) return;
|
|
8216
|
+
try {
|
|
8217
|
+
const result = await updateSessionTitleWithEvent(db, {
|
|
8218
|
+
workspaceId: input.workspaceId,
|
|
8219
|
+
sessionId: input.sessionId,
|
|
8220
|
+
title: generated.title,
|
|
8221
|
+
source: "agent"
|
|
8222
|
+
});
|
|
8223
|
+
if (result.events.length > 0) {
|
|
8224
|
+
await publishDurableSessionEvents3(bus, input.workspaceId, input.sessionId, result.events);
|
|
8225
|
+
}
|
|
8226
|
+
} catch (error) {
|
|
8227
|
+
observability.warn("parallel session title persistence failed", {
|
|
8228
|
+
...safeErrorDiagnostic(error),
|
|
8229
|
+
errorClass: "ParallelSessionTitlePersistenceError",
|
|
8230
|
+
errorCode: "parallel_session_title_persistence_failed",
|
|
8231
|
+
origin: "worker"
|
|
8232
|
+
});
|
|
8233
|
+
}
|
|
8234
|
+
};
|
|
8235
|
+
const cancelParallelSessionTitle = async () => {
|
|
8236
|
+
if (parallelSessionTitleFinished) return;
|
|
8237
|
+
parallelSessionTitleFinished = true;
|
|
8238
|
+
await parallelSessionTitle?.cancel();
|
|
8239
|
+
};
|
|
7995
8240
|
let runInput = null;
|
|
7996
8241
|
const prepareRunAttemptInput = async () => {
|
|
7997
8242
|
const historyPreparationStartedAt = performance.now();
|
|
@@ -8452,6 +8697,8 @@ async function runTurnStreamAttempt(deps) {
|
|
|
8452
8697
|
latencyMode: turnExecutionPolicy.latencyMode,
|
|
8453
8698
|
metricProvider: streamProvider,
|
|
8454
8699
|
externallyBilled: billingState.isExternallyBilledTurn,
|
|
8700
|
+
chargesOpenGeniCredits: billingState.chargesOpenGeniCredits,
|
|
8701
|
+
countsTowardTokenCap: billingState.countsTowardTokenCap,
|
|
8455
8702
|
servingCredentialId: providerTurn.effectiveCodexCredentialId,
|
|
8456
8703
|
priorSessionCredentialId: providerTurn.priorSessionCodexCredentialId,
|
|
8457
8704
|
emittedSourceKeys: emittedModelUsageSourceKeys,
|
|
@@ -8509,7 +8756,9 @@ async function runTurnStreamAttempt(deps) {
|
|
|
8509
8756
|
input.accountId,
|
|
8510
8757
|
input.workspaceId,
|
|
8511
8758
|
billingState.isExternallyBilledTurn,
|
|
8512
|
-
entitlements
|
|
8759
|
+
entitlements,
|
|
8760
|
+
billingState.chargesOpenGeniCredits,
|
|
8761
|
+
billingState.countsTowardTokenCap
|
|
8513
8762
|
);
|
|
8514
8763
|
} catch (limitError) {
|
|
8515
8764
|
let serializedRunState = null;
|
|
@@ -8802,6 +9051,8 @@ async function runTurnStreamAttempt(deps) {
|
|
|
8802
9051
|
turnAttemptId: input.attemptId,
|
|
8803
9052
|
model: turn.model,
|
|
8804
9053
|
externallyBilled: billingState.isExternallyBilledTurn,
|
|
9054
|
+
chargesOpenGeniCredits: billingState.chargesOpenGeniCredits,
|
|
9055
|
+
countsTowardTokenCap: billingState.countsTowardTokenCap,
|
|
8805
9056
|
usage: aggregateUsage,
|
|
8806
9057
|
normalizedUsage: normalizedAggregateUsage,
|
|
8807
9058
|
sourceKey: aggregateSourceKey,
|
|
@@ -8823,6 +9074,8 @@ async function runTurnStreamAttempt(deps) {
|
|
|
8823
9074
|
sourceKey: aggregateSourceKey,
|
|
8824
9075
|
usage: { usage: aggregateUsage },
|
|
8825
9076
|
normalizedUsage: normalizedAggregateUsage,
|
|
9077
|
+
...billing ? { billingPath: billing.billingPath } : {},
|
|
9078
|
+
...billing?.upstreamProvider ? { upstreamProvider: billing.upstreamProvider } : {},
|
|
8826
9079
|
servingAccountHash: aggregateAccountCtx.servingAccountHash,
|
|
8827
9080
|
accountChangedFromPrevCall: aggregateAccountCtx.accountChangedFromPrevCall,
|
|
8828
9081
|
emittedSourceKeys: emittedModelUsageSourceKeys
|
|
@@ -8955,6 +9208,7 @@ async function runTurnStreamAttempt(deps) {
|
|
|
8955
9208
|
if (!attached.accepted) {
|
|
8956
9209
|
return claimedResult({ status: "cancelled" });
|
|
8957
9210
|
}
|
|
9211
|
+
await finishParallelSessionTitle();
|
|
8958
9212
|
if (!await eventing.settle({
|
|
8959
9213
|
events: [
|
|
8960
9214
|
...requestEvents,
|
|
@@ -8988,6 +9242,7 @@ async function runTurnStreamAttempt(deps) {
|
|
|
8988
9242
|
const finalOutput = String(requireAgentStreamFinalOutput(eventing.stream.finalOutput));
|
|
8989
9243
|
await historySink.reconcileConversationTruth({ requireDurable: true });
|
|
8990
9244
|
await finalizeTurnOpStreamOps();
|
|
9245
|
+
await finishParallelSessionTitle();
|
|
8991
9246
|
if (!await eventing.settle({
|
|
8992
9247
|
events: [
|
|
8993
9248
|
{
|
|
@@ -9049,125 +9304,161 @@ async function runTurnStreamAttempt(deps) {
|
|
|
9049
9304
|
})) {
|
|
9050
9305
|
return claimedResult({ status: "cancelled" });
|
|
9051
9306
|
}
|
|
9052
|
-
|
|
9053
|
-
|
|
9054
|
-
|
|
9055
|
-
|
|
9056
|
-
|
|
9057
|
-
|
|
9058
|
-
|
|
9059
|
-
|
|
9060
|
-
|
|
9061
|
-
|
|
9307
|
+
if (generateSessionTitleInParallel && runtime.generateSessionTitle && !runtimeCancellationSignal.aborted) {
|
|
9308
|
+
const serviceTier = serviceTierForLatencyMode(
|
|
9309
|
+
turnExecutionPolicy.providerId,
|
|
9310
|
+
turnExecutionPolicy.latencyMode
|
|
9311
|
+
);
|
|
9312
|
+
parallelSessionTitle = startParallelSessionTitleGeneration({
|
|
9313
|
+
signal: runtimeCancellationSignal,
|
|
9314
|
+
generate: async (signal) => await withSessionTitleProviderRequestContext(
|
|
9315
|
+
() => runtime.generateSessionTitle(runSettings, sessionTitlePrompt, {
|
|
9316
|
+
...resolvedModel ? {
|
|
9317
|
+
client: resolvedModel.client,
|
|
9318
|
+
provider: resolvedModel.provider,
|
|
9319
|
+
model: resolvedModel.model
|
|
9320
|
+
} : {},
|
|
9321
|
+
modelName: turnExecutionPolicy.upstreamModelId,
|
|
9322
|
+
...serviceTier ? { serviceTier } : {},
|
|
9323
|
+
signal
|
|
9324
|
+
})
|
|
9325
|
+
),
|
|
9326
|
+
onError: (error) => {
|
|
9327
|
+
observability.warn("parallel session title generation failed", {
|
|
9328
|
+
...safeErrorDiagnostic(error),
|
|
9329
|
+
errorClass: "ParallelSessionTitleGenerationError",
|
|
9330
|
+
errorCode: "parallel_session_title_generation_failed",
|
|
9331
|
+
origin: "worker"
|
|
9062
9332
|
});
|
|
9063
9333
|
}
|
|
9064
|
-
|
|
9065
|
-
|
|
9066
|
-
|
|
9067
|
-
|
|
9068
|
-
|
|
9069
|
-
if (!recoveryKind || !eventing.publish || !eventing.turnStartedPublished) {
|
|
9070
|
-
throw attemptError;
|
|
9071
|
-
}
|
|
9072
|
-
await flushRuntimeBatcher();
|
|
9073
|
-
await historySink.reconcileConversationTruth({ skipInputOnlyRows: true });
|
|
9074
|
-
observability.warn("context compaction recovery attempted", {
|
|
9075
|
-
sessionId: input.sessionId,
|
|
9076
|
-
turnId: activeTurnId,
|
|
9077
|
-
reason: recoveryKind,
|
|
9078
|
-
...safeErrorDiagnostic(attemptError),
|
|
9079
|
-
signalTokens: compactionNeeded?.signalTokens,
|
|
9080
|
-
thresholdTokens: compactionNeeded?.thresholdTokens
|
|
9081
|
-
});
|
|
9082
|
-
let compacted = false;
|
|
9083
|
-
let compactionHandled = false;
|
|
9084
|
-
let compactionFailureMessage = null;
|
|
9085
|
-
let compactionRequestCleared = false;
|
|
9334
|
+
});
|
|
9335
|
+
}
|
|
9336
|
+
try {
|
|
9337
|
+
let retriedAfterCompaction = false;
|
|
9338
|
+
while (true) {
|
|
9086
9339
|
try {
|
|
9087
|
-
const
|
|
9088
|
-
|
|
9089
|
-
|
|
9090
|
-
)
|
|
9091
|
-
|
|
9092
|
-
if (outcome.compacted) {
|
|
9093
|
-
compactionHandled = true;
|
|
9094
|
-
} else {
|
|
9095
|
-
compactionHandled = recoveryKind === "operator" && outcome.requestConsumed;
|
|
9096
|
-
if (!compactionHandled) {
|
|
9097
|
-
compactionFailureMessage = compactionFailureReason(outcome.reason);
|
|
9098
|
-
}
|
|
9099
|
-
}
|
|
9100
|
-
} catch (compactError) {
|
|
9101
|
-
if (shouldRecoverCompactionProviderFailure(compactError)) throw compactError;
|
|
9102
|
-
if (compactError instanceof TurnAttemptFencedError) throw compactError;
|
|
9103
|
-
const landmark = await settleFailedContextCompactionLandmark(
|
|
9104
|
-
db,
|
|
9105
|
-
{
|
|
9106
|
-
accountId: input.accountId,
|
|
9107
|
-
workspaceId: input.workspaceId,
|
|
9340
|
+
const result = await runStreamAttempt({
|
|
9341
|
+
requireTerminalModelResponse: retriedAfterCompaction
|
|
9342
|
+
});
|
|
9343
|
+
if (retriedAfterCompaction) {
|
|
9344
|
+
observability.info("context compaction recovery succeeded after in-activity retry", {
|
|
9108
9345
|
sessionId: input.sessionId,
|
|
9109
|
-
turnId: activeTurnId
|
|
9110
|
-
|
|
9111
|
-
|
|
9112
|
-
|
|
9113
|
-
|
|
9114
|
-
|
|
9115
|
-
|
|
9116
|
-
|
|
9117
|
-
)
|
|
9118
|
-
|
|
9119
|
-
|
|
9120
|
-
|
|
9121
|
-
|
|
9122
|
-
|
|
9123
|
-
observability.warn("context compaction recovery compaction failed", {
|
|
9346
|
+
turnId: activeTurnId
|
|
9347
|
+
});
|
|
9348
|
+
}
|
|
9349
|
+
return result;
|
|
9350
|
+
} catch (attemptError) {
|
|
9351
|
+
const overflow = classifyContextWindowOverflowError(attemptError);
|
|
9352
|
+
const compactionNeeded = findCompactionNeededError(attemptError);
|
|
9353
|
+
const recoveryKind = compactionNeeded ? compactionNeeded.trigger === "operator" ? "operator" : "proactive" : overflow ? "overflow" : null;
|
|
9354
|
+
if (!recoveryKind || !eventing.publish || !eventing.turnStartedPublished) {
|
|
9355
|
+
throw attemptError;
|
|
9356
|
+
}
|
|
9357
|
+
await flushRuntimeBatcher();
|
|
9358
|
+
await historySink.reconcileConversationTruth({ skipInputOnlyRows: true });
|
|
9359
|
+
observability.warn("context compaction recovery attempted", {
|
|
9124
9360
|
sessionId: input.sessionId,
|
|
9125
9361
|
turnId: activeTurnId,
|
|
9126
|
-
|
|
9362
|
+
reason: recoveryKind,
|
|
9363
|
+
...safeErrorDiagnostic(attemptError),
|
|
9364
|
+
signalTokens: compactionNeeded?.signalTokens,
|
|
9365
|
+
thresholdTokens: compactionNeeded?.thresholdTokens
|
|
9127
9366
|
});
|
|
9128
|
-
|
|
9129
|
-
|
|
9130
|
-
|
|
9131
|
-
|
|
9132
|
-
|
|
9367
|
+
let compacted = false;
|
|
9368
|
+
let compactionHandled = false;
|
|
9369
|
+
let compactionFailureMessage = null;
|
|
9370
|
+
let compactionRequestCleared = false;
|
|
9371
|
+
try {
|
|
9372
|
+
const outcome = await forceContextCompaction(
|
|
9373
|
+
recoveryKind,
|
|
9374
|
+
compactionNeeded?.signalTokens ?? null
|
|
9375
|
+
);
|
|
9376
|
+
compacted = outcome.compacted;
|
|
9377
|
+
if (outcome.compacted) {
|
|
9378
|
+
compactionHandled = true;
|
|
9379
|
+
} else {
|
|
9380
|
+
compactionHandled = recoveryKind === "operator" && outcome.requestConsumed;
|
|
9381
|
+
if (!compactionHandled) {
|
|
9382
|
+
compactionFailureMessage = compactionFailureReason(outcome.reason);
|
|
9383
|
+
}
|
|
9384
|
+
}
|
|
9385
|
+
} catch (compactError) {
|
|
9386
|
+
if (shouldRecoverCompactionProviderFailure(compactError)) throw compactError;
|
|
9387
|
+
if (compactError instanceof TurnAttemptFencedError) throw compactError;
|
|
9388
|
+
const landmark = await settleFailedContextCompactionLandmark(
|
|
9389
|
+
db,
|
|
9133
9390
|
{
|
|
9134
|
-
|
|
9135
|
-
|
|
9136
|
-
|
|
9137
|
-
|
|
9138
|
-
|
|
9139
|
-
|
|
9140
|
-
compacted: false
|
|
9141
|
-
}
|
|
9391
|
+
accountId: input.accountId,
|
|
9392
|
+
workspaceId: input.workspaceId,
|
|
9393
|
+
sessionId: input.sessionId,
|
|
9394
|
+
turnId: activeTurnId,
|
|
9395
|
+
executionGeneration: attempt.executionGeneration,
|
|
9396
|
+
attemptId: input.attemptId
|
|
9142
9397
|
},
|
|
9143
9398
|
{
|
|
9144
|
-
|
|
9145
|
-
|
|
9399
|
+
clearRequestedCompaction: recoveryKind === "operator",
|
|
9400
|
+
publishLiveEvents: publishCompactionLiveEvents
|
|
9146
9401
|
}
|
|
9147
|
-
|
|
9148
|
-
|
|
9149
|
-
|
|
9150
|
-
|
|
9151
|
-
|
|
9152
|
-
|
|
9153
|
-
|
|
9402
|
+
);
|
|
9403
|
+
compactionRequestCleared = landmark.requestConsumed;
|
|
9404
|
+
if (!isCompactionSummaryFailure(compactError)) throw compactError;
|
|
9405
|
+
await finishParallelSessionTitle();
|
|
9406
|
+
const deferredSteer2 = await settleDeferredSteerAfterCompaction();
|
|
9407
|
+
if (deferredSteer2) return deferredSteer2;
|
|
9408
|
+
compactionFailureMessage = String(compactionFailureReasonFromError(compactError));
|
|
9409
|
+
observability.warn("context compaction recovery compaction failed", {
|
|
9410
|
+
sessionId: input.sessionId,
|
|
9411
|
+
turnId: activeTurnId,
|
|
9412
|
+
...safeErrorDiagnostic(compactError)
|
|
9413
|
+
});
|
|
9154
9414
|
}
|
|
9155
|
-
|
|
9156
|
-
|
|
9157
|
-
|
|
9158
|
-
|
|
9415
|
+
if (!compactionHandled) {
|
|
9416
|
+
const errorMessage = compactionFailureMessage ?? "compaction summarization failed: compaction produced no replacement history";
|
|
9417
|
+
await finishParallelSessionTitle();
|
|
9418
|
+
if (!await eventing.settle({
|
|
9419
|
+
events: [
|
|
9420
|
+
{
|
|
9421
|
+
type: "turn.failed",
|
|
9422
|
+
payload: {
|
|
9423
|
+
error: errorMessage,
|
|
9424
|
+
code: "context_compaction_failed",
|
|
9425
|
+
retryable: false,
|
|
9426
|
+
recovery: "user_message",
|
|
9427
|
+
compacted: false
|
|
9428
|
+
}
|
|
9429
|
+
},
|
|
9430
|
+
{
|
|
9431
|
+
type: "session.status.changed",
|
|
9432
|
+
payload: { status: "idle" }
|
|
9433
|
+
}
|
|
9434
|
+
],
|
|
9435
|
+
turnStatus: "failed",
|
|
9436
|
+
sessionStatus: "idle",
|
|
9437
|
+
activeTurnId: null,
|
|
9438
|
+
...recoveryKind === "operator" && !compactionRequestCleared ? { consumeRequestedCompactionFailure: true } : {}
|
|
9439
|
+
})) {
|
|
9440
|
+
return claimedResult({ status: "cancelled" });
|
|
9441
|
+
}
|
|
9442
|
+
control.turnMetricOutcome = "failed";
|
|
9443
|
+
control.activityStatus = "idle";
|
|
9444
|
+
control.activityError = attemptError;
|
|
9445
|
+
return claimedResult({ status: "idle", deferredUntilWake: true });
|
|
9446
|
+
}
|
|
9447
|
+
await finishParallelSessionTitle();
|
|
9448
|
+
const deferredSteer = await settleDeferredSteerAfterCompaction();
|
|
9449
|
+
if (deferredSteer) return deferredSteer;
|
|
9450
|
+
retriedAfterCompaction = true;
|
|
9451
|
+
observability.info("context compaction recovery retrying turn after compaction", {
|
|
9452
|
+
sessionId: input.sessionId,
|
|
9453
|
+
turnId: activeTurnId,
|
|
9454
|
+
reason: recoveryKind,
|
|
9455
|
+
compacted
|
|
9456
|
+
});
|
|
9457
|
+
await prepareRunAttemptInput();
|
|
9159
9458
|
}
|
|
9160
|
-
const deferredSteer = await settleDeferredSteerAfterCompaction();
|
|
9161
|
-
if (deferredSteer) return deferredSteer;
|
|
9162
|
-
retriedAfterCompaction = true;
|
|
9163
|
-
observability.info("context compaction recovery retrying turn after compaction", {
|
|
9164
|
-
sessionId: input.sessionId,
|
|
9165
|
-
turnId: activeTurnId,
|
|
9166
|
-
reason: recoveryKind,
|
|
9167
|
-
compacted
|
|
9168
|
-
});
|
|
9169
|
-
await prepareRunAttemptInput();
|
|
9170
9459
|
}
|
|
9460
|
+
} finally {
|
|
9461
|
+
await cancelParallelSessionTitle();
|
|
9171
9462
|
}
|
|
9172
9463
|
}
|
|
9173
9464
|
|
|
@@ -9182,7 +9473,7 @@ import {
|
|
|
9182
9473
|
workspaceCodexSubscriptionActive as workspaceCodexSubscriptionActive2,
|
|
9183
9474
|
requireSession
|
|
9184
9475
|
} from "@opengeni/db";
|
|
9185
|
-
import { appendAndPublishTurnEventsFenced as appendAndPublishTurnEventsFenced2, publishDurableSessionEvents as
|
|
9476
|
+
import { appendAndPublishTurnEventsFenced as appendAndPublishTurnEventsFenced2, publishDurableSessionEvents as publishDurableSessionEvents4 } from "@opengeni/events";
|
|
9186
9477
|
import {
|
|
9187
9478
|
assertTurnExecutionPolicyMatchesConfigV1,
|
|
9188
9479
|
resolveTurnExecutionPolicyV1 as resolveTurnExecutionPolicyV12
|
|
@@ -9191,17 +9482,35 @@ import {
|
|
|
9191
9482
|
// src/activities/capabilities.ts
|
|
9192
9483
|
import {
|
|
9193
9484
|
environmentsEncryptionKeyBytes as environmentsEncryptionKeyBytes2,
|
|
9485
|
+
WORKSPACE_GATEWAY_MODEL_ID_PREFIX,
|
|
9486
|
+
WORKSPACE_OPENROUTER_MODEL_ID_PREFIX,
|
|
9194
9487
|
withCodexCatalogProvider,
|
|
9195
9488
|
withWorkspaceGatewayCatalogProvider,
|
|
9196
9489
|
withWorkspaceGatewayCredential,
|
|
9490
|
+
withWorkspaceOpenRouterCatalogProvider,
|
|
9491
|
+
withWorkspaceOpenRouterCredential,
|
|
9492
|
+
withOrganizationGatewayCatalogProvider,
|
|
9493
|
+
withOrganizationGatewayCredential,
|
|
9494
|
+
withOrganizationOpenRouterCatalogProvider,
|
|
9495
|
+
withOrganizationOpenRouterCredential,
|
|
9496
|
+
ORGANIZATION_GATEWAY_MODEL_ID_PREFIX,
|
|
9497
|
+
ORGANIZATION_OPENROUTER_MODEL_ID_PREFIX,
|
|
9197
9498
|
withXaiSubscriptionCatalogProvider
|
|
9198
9499
|
} from "@opengeni/config";
|
|
9199
9500
|
import { settingsWithEnabledCapabilityMcpServers } from "@opengeni/core";
|
|
9200
9501
|
import {
|
|
9502
|
+
getWorkspaceGatewayCustomModelForExecution,
|
|
9503
|
+
getWorkspaceOpenRouterCustomModelForExecution,
|
|
9201
9504
|
listSessionMcpServerMetadata,
|
|
9202
9505
|
listSessionMcpServersForRun,
|
|
9506
|
+
listWorkspaceGatewayCustomModels,
|
|
9507
|
+
listWorkspaceOpenRouterCustomModels,
|
|
9203
9508
|
workspaceCodexSubscriptionActive,
|
|
9204
|
-
loadWorkspaceVercelAiGatewayApiKey
|
|
9509
|
+
loadWorkspaceVercelAiGatewayApiKey,
|
|
9510
|
+
loadWorkspaceOpenRouterApiKey,
|
|
9511
|
+
listOrganizationModelProviderCustomModelsForWorkspace,
|
|
9512
|
+
getOrganizationModelProviderCustomModelForExecution,
|
|
9513
|
+
loadOrganizationModelProviderApiKey
|
|
9205
9514
|
} from "@opengeni/db";
|
|
9206
9515
|
async function settingsWithSessionMcpServersForRun(db, workspaceId, sessionId, attemptId, settings, options) {
|
|
9207
9516
|
const encryptionKey = environmentsEncryptionKeyBytes2(settings);
|
|
@@ -9263,15 +9572,79 @@ function withCodexProvider(settings) {
|
|
|
9263
9572
|
function withXaiSubscriptionProvider(settings) {
|
|
9264
9573
|
return withXaiSubscriptionCatalogProvider(settings);
|
|
9265
9574
|
}
|
|
9266
|
-
async function settingsWithWorkspaceGatewayCredential(db, workspaceId, settings) {
|
|
9267
|
-
const
|
|
9575
|
+
async function settingsWithWorkspaceGatewayCredential(db, accountId, workspaceId, settings, retainedProductModelId) {
|
|
9576
|
+
const activeCustomModels = await listWorkspaceGatewayCustomModels(db, { accountId, workspaceId });
|
|
9577
|
+
const retainedUpstreamModelId = retainedProductModelId?.startsWith(
|
|
9578
|
+
WORKSPACE_GATEWAY_MODEL_ID_PREFIX
|
|
9579
|
+
) ? retainedProductModelId.slice(WORKSPACE_GATEWAY_MODEL_ID_PREFIX.length) : null;
|
|
9580
|
+
const retainedCustomModel = retainedUpstreamModelId ? await getWorkspaceGatewayCustomModelForExecution(db, {
|
|
9581
|
+
accountId,
|
|
9582
|
+
workspaceId,
|
|
9583
|
+
upstreamModelId: retainedUpstreamModelId
|
|
9584
|
+
}) : null;
|
|
9585
|
+
const customModels = retainedCustomModel && !activeCustomModels.some(
|
|
9586
|
+
(model) => model.upstreamModelId === retainedCustomModel.upstreamModelId
|
|
9587
|
+
) ? [...activeCustomModels, retainedCustomModel] : activeCustomModels;
|
|
9588
|
+
const catalogSettings = withWorkspaceGatewayCatalogProvider(settings, customModels);
|
|
9268
9589
|
const apiKey = await loadWorkspaceVercelAiGatewayApiKey(db, settings, workspaceId);
|
|
9269
|
-
return apiKey ? withWorkspaceGatewayCredential(catalogSettings, apiKey) : catalogSettings;
|
|
9590
|
+
return apiKey ? withWorkspaceGatewayCredential(catalogSettings, apiKey, customModels) : catalogSettings;
|
|
9591
|
+
}
|
|
9592
|
+
async function settingsWithWorkspaceOpenRouterCredential(db, accountId, workspaceId, settings, retainedProductModelId) {
|
|
9593
|
+
const activeCustomModels = await listWorkspaceOpenRouterCustomModels(db, {
|
|
9594
|
+
accountId,
|
|
9595
|
+
workspaceId
|
|
9596
|
+
});
|
|
9597
|
+
const retainedUpstreamModelId = retainedProductModelId?.startsWith(
|
|
9598
|
+
WORKSPACE_OPENROUTER_MODEL_ID_PREFIX
|
|
9599
|
+
) ? retainedProductModelId.slice(WORKSPACE_OPENROUTER_MODEL_ID_PREFIX.length) : null;
|
|
9600
|
+
const retainedCustomModel = retainedUpstreamModelId ? await getWorkspaceOpenRouterCustomModelForExecution(db, {
|
|
9601
|
+
accountId,
|
|
9602
|
+
workspaceId,
|
|
9603
|
+
upstreamModelId: retainedUpstreamModelId
|
|
9604
|
+
}) : null;
|
|
9605
|
+
const customModels = retainedCustomModel && !activeCustomModels.some(
|
|
9606
|
+
(model) => model.upstreamModelId === retainedCustomModel.upstreamModelId
|
|
9607
|
+
) ? [...activeCustomModels, retainedCustomModel] : activeCustomModels;
|
|
9608
|
+
const catalogSettings = withWorkspaceOpenRouterCatalogProvider(settings, customModels);
|
|
9609
|
+
const apiKey = await loadWorkspaceOpenRouterApiKey(db, settings, workspaceId);
|
|
9610
|
+
return apiKey ? withWorkspaceOpenRouterCredential(catalogSettings, apiKey, customModels) : catalogSettings;
|
|
9611
|
+
}
|
|
9612
|
+
async function settingsWithOrganizationProviderCredentials(db, accountId, workspaceId, settings, retainedProductModelId) {
|
|
9613
|
+
const buildModels = async (providerKind, prefix) => {
|
|
9614
|
+
const active = await listOrganizationModelProviderCustomModelsForWorkspace(db, {
|
|
9615
|
+
accountId,
|
|
9616
|
+
workspaceId,
|
|
9617
|
+
providerKind
|
|
9618
|
+
});
|
|
9619
|
+
const upstreamModelId = retainedProductModelId?.startsWith(prefix) ? retainedProductModelId.slice(prefix.length) : null;
|
|
9620
|
+
const retained = upstreamModelId ? await getOrganizationModelProviderCustomModelForExecution(db, {
|
|
9621
|
+
accountId,
|
|
9622
|
+
workspaceId,
|
|
9623
|
+
providerKind,
|
|
9624
|
+
upstreamModelId
|
|
9625
|
+
}) : null;
|
|
9626
|
+
return retained && !active.some((model) => model.id === retained.id) ? [...active, retained] : active;
|
|
9627
|
+
};
|
|
9628
|
+
const gatewayModels = await buildModels("vercel_gateway", ORGANIZATION_GATEWAY_MODEL_ID_PREFIX);
|
|
9629
|
+
const openRouterModels = await buildModels("openrouter", ORGANIZATION_OPENROUTER_MODEL_ID_PREFIX);
|
|
9630
|
+
const gatewayKey = await loadOrganizationModelProviderApiKey(db, settings, {
|
|
9631
|
+
accountId,
|
|
9632
|
+
workspaceId,
|
|
9633
|
+
providerKind: "vercel_gateway"
|
|
9634
|
+
});
|
|
9635
|
+
const gatewaySettings = gatewayKey ? withOrganizationGatewayCredential(settings, gatewayKey, gatewayModels) : withOrganizationGatewayCatalogProvider(settings, gatewayModels);
|
|
9636
|
+
const openRouterKey = await loadOrganizationModelProviderApiKey(db, settings, {
|
|
9637
|
+
accountId,
|
|
9638
|
+
workspaceId,
|
|
9639
|
+
providerKind: "openrouter"
|
|
9640
|
+
});
|
|
9641
|
+
return openRouterKey ? withOrganizationOpenRouterCredential(gatewaySettings, openRouterKey, openRouterModels) : withOrganizationOpenRouterCatalogProvider(gatewaySettings, openRouterModels);
|
|
9270
9642
|
}
|
|
9271
9643
|
|
|
9272
9644
|
// src/activities/agent-turn/claim.ts
|
|
9273
9645
|
import {
|
|
9274
9646
|
assertSessionAllowsProductModel,
|
|
9647
|
+
resolveCatalogSettings,
|
|
9275
9648
|
resolveCodexAppsCredentialIdForRun
|
|
9276
9649
|
} from "@opengeni/core";
|
|
9277
9650
|
|
|
@@ -9295,6 +9668,7 @@ async function claimTurnAttempt(deps) {
|
|
|
9295
9668
|
const {
|
|
9296
9669
|
input,
|
|
9297
9670
|
settings,
|
|
9671
|
+
catalogSourceSettings,
|
|
9298
9672
|
db,
|
|
9299
9673
|
bus,
|
|
9300
9674
|
runtime,
|
|
@@ -9315,9 +9689,10 @@ async function claimTurnAttempt(deps) {
|
|
|
9315
9689
|
claimedResult,
|
|
9316
9690
|
acknowledgeLostAttemptOwnership
|
|
9317
9691
|
} = deps;
|
|
9692
|
+
const deploymentCatalogSettings = (await resolveCatalogSettings(db, catalogSourceSettings)).settings;
|
|
9318
9693
|
const validatePendingSystemUpdateAuthority = async (tx, update) => await validateIncidentTelemetrySystemUpdateAuthority({
|
|
9319
9694
|
db: tx,
|
|
9320
|
-
settings,
|
|
9695
|
+
settings: deploymentCatalogSettings,
|
|
9321
9696
|
workspaceId: input.workspaceId,
|
|
9322
9697
|
sessionId: input.sessionId,
|
|
9323
9698
|
update
|
|
@@ -9343,6 +9718,7 @@ async function claimTurnAttempt(deps) {
|
|
|
9343
9718
|
attempt.redispatchesAtDispatch = Number(
|
|
9344
9719
|
turn.metadata?.workerDeathRedispatches ?? 0
|
|
9345
9720
|
);
|
|
9721
|
+
const claimedPolicy = readTurnExecutionPolicyV1(turn.metadata);
|
|
9346
9722
|
const session = await requireSession(db, input.workspaceId, input.sessionId);
|
|
9347
9723
|
let installedApiIntegrations = [];
|
|
9348
9724
|
const credentialSubjectId = credentialSubjectIdForTurnInitiator(turn);
|
|
@@ -9350,7 +9726,7 @@ async function claimTurnAttempt(deps) {
|
|
|
9350
9726
|
const mcpSettings = await settingsWithEnabledCapabilityMcpServers(
|
|
9351
9727
|
db,
|
|
9352
9728
|
input.workspaceId,
|
|
9353
|
-
|
|
9729
|
+
deploymentCatalogSettings,
|
|
9354
9730
|
{
|
|
9355
9731
|
...credentialSubjectId ? { subjectId: credentialSubjectId } : {
|
|
9356
9732
|
personalConnectionDelegations: turn.personalConnectionDelegations
|
|
@@ -9372,14 +9748,29 @@ async function claimTurnAttempt(deps) {
|
|
|
9372
9748
|
codexSubscriptionActive
|
|
9373
9749
|
);
|
|
9374
9750
|
const xaiSettings = codexSettings.supergrokSubscriptionEnabled ? withXaiSubscriptionProvider(codexSettings) : codexSettings;
|
|
9375
|
-
const
|
|
9751
|
+
const gatewaySettings = await settingsWithWorkspaceGatewayCredential(
|
|
9752
|
+
db,
|
|
9753
|
+
input.accountId,
|
|
9754
|
+
input.workspaceId,
|
|
9755
|
+
xaiSettings,
|
|
9756
|
+
claimedPolicy.kind === "valid" ? claimedPolicy.policy.productModelId : turn.model
|
|
9757
|
+
);
|
|
9758
|
+
const workspaceProviderSettings = await settingsWithWorkspaceOpenRouterCredential(
|
|
9759
|
+
db,
|
|
9760
|
+
input.accountId,
|
|
9761
|
+
input.workspaceId,
|
|
9762
|
+
gatewaySettings,
|
|
9763
|
+
claimedPolicy.kind === "valid" ? claimedPolicy.policy.productModelId : turn.model
|
|
9764
|
+
);
|
|
9765
|
+
const capabilitySettings = await settingsWithOrganizationProviderCredentials(
|
|
9376
9766
|
db,
|
|
9767
|
+
input.accountId,
|
|
9377
9768
|
input.workspaceId,
|
|
9378
|
-
|
|
9769
|
+
workspaceProviderSettings,
|
|
9770
|
+
claimedPolicy.kind === "valid" ? claimedPolicy.policy.productModelId : turn.model
|
|
9379
9771
|
);
|
|
9380
9772
|
const codexAppsCredentialId = capabilitySettings.codexConnectedAppsEnabled ? await resolveCodexAppsCredentialIdForRun(db, input.workspaceId) : null;
|
|
9381
9773
|
runtime.configure(capabilitySettings);
|
|
9382
|
-
const claimedPolicy = readTurnExecutionPolicyV1(turn.metadata);
|
|
9383
9774
|
const policyForAbsent = claimedPolicy.kind === "valid" ? claimedPolicy.policy : resolveTurnExecutionPolicyV12(capabilitySettings, legacyTurnExecutionPolicyInput(turn));
|
|
9384
9775
|
const installedPolicy = await installOrReadTurnExecutionPolicyForAttempt(db, {
|
|
9385
9776
|
accountId: input.accountId,
|
|
@@ -9406,6 +9797,8 @@ async function claimTurnAttempt(deps) {
|
|
|
9406
9797
|
assertSessionAllowsProductModel(session, turnExecutionPolicy.productModelId);
|
|
9407
9798
|
const billingIdentity = turnExecutionPolicyBillingIdentity(turnExecutionPolicy);
|
|
9408
9799
|
billingState.isExternallyBilledTurn = billingIdentity.externallyBilled;
|
|
9800
|
+
billingState.chargesOpenGeniCredits = verifiedExecutionPolicy.model.cost === "credits";
|
|
9801
|
+
billingState.countsTowardTokenCap = billingIdentity.countsTowardTokenCap;
|
|
9409
9802
|
billingState.isCodexTurn = billingIdentity.codexSubscription;
|
|
9410
9803
|
billingState.isXaiTurn = billingIdentity.xaiSubscription;
|
|
9411
9804
|
const trigger = await getSessionEvent3(db, input.workspaceId, attempt.triggerEventId);
|
|
@@ -9441,12 +9834,14 @@ async function claimTurnAttempt(deps) {
|
|
|
9441
9834
|
turnLifecycleMetricsFor(observability).start(attempt.turnId);
|
|
9442
9835
|
await waitForTurnOperation(
|
|
9443
9836
|
ensureRunAllowed(
|
|
9444
|
-
|
|
9837
|
+
capabilitySettings,
|
|
9445
9838
|
db,
|
|
9446
9839
|
input.accountId,
|
|
9447
9840
|
input.workspaceId,
|
|
9448
9841
|
billingState.isExternallyBilledTurn,
|
|
9449
|
-
entitlements
|
|
9842
|
+
entitlements,
|
|
9843
|
+
billingState.chargesOpenGeniCredits,
|
|
9844
|
+
billingState.countsTowardTokenCap
|
|
9450
9845
|
),
|
|
9451
9846
|
cancellationSignal,
|
|
9452
9847
|
void 0
|
|
@@ -9566,7 +9961,7 @@ async function claimTurnAttempt(deps) {
|
|
|
9566
9961
|
}
|
|
9567
9962
|
recordCanonicalStartupMilestones(result.canonicalStartupMilestones);
|
|
9568
9963
|
turnLifecycleMetricsFor(observability).progress(attempt.turnId);
|
|
9569
|
-
await
|
|
9964
|
+
await publishDurableSessionEvents4(bus, input.workspaceId, input.sessionId, result.events);
|
|
9570
9965
|
if (inputSettlement.turnStatus === "requires_action") {
|
|
9571
9966
|
await deliverChildRequiresActionToParent(
|
|
9572
9967
|
{ db, bus, settings, observability, wakeSessionWorkflow },
|
|
@@ -9657,7 +10052,7 @@ import {
|
|
|
9657
10052
|
setActiveCodexCredential,
|
|
9658
10053
|
withSessionCodexCapacityMutation as withSessionCodexCapacityMutation2
|
|
9659
10054
|
} from "@opengeni/db";
|
|
9660
|
-
import { publishDurableSessionEvents as
|
|
10055
|
+
import { publishDurableSessionEvents as publishDurableSessionEvents5 } from "@opengeni/events";
|
|
9661
10056
|
|
|
9662
10057
|
// src/activities/codex-fleet-shadow.ts
|
|
9663
10058
|
import {
|
|
@@ -10192,7 +10587,7 @@ async function selectCodexTurnCapacity(deps) {
|
|
|
10192
10587
|
}
|
|
10193
10588
|
});
|
|
10194
10589
|
if (armed.action === "waiting") {
|
|
10195
|
-
await
|
|
10590
|
+
await publishDurableSessionEvents5(bus, input.workspaceId, input.sessionId, armed.events);
|
|
10196
10591
|
control.turnMetricOutcome = "recovering";
|
|
10197
10592
|
control.activityStatus = "waiting_capacity";
|
|
10198
10593
|
return {
|
|
@@ -10287,7 +10682,7 @@ async function selectCodexTurnCapacity(deps) {
|
|
|
10287
10682
|
failurePayload
|
|
10288
10683
|
});
|
|
10289
10684
|
if (armed.action === "waiting") {
|
|
10290
|
-
await
|
|
10685
|
+
await publishDurableSessionEvents5(bus, input.workspaceId, input.sessionId, armed.events);
|
|
10291
10686
|
control.turnMetricOutcome = "recovering";
|
|
10292
10687
|
control.activityStatus = "waiting_capacity";
|
|
10293
10688
|
return {
|
|
@@ -10432,6 +10827,9 @@ import {
|
|
|
10432
10827
|
} from "@opengeni/contracts";
|
|
10433
10828
|
|
|
10434
10829
|
// src/activities/agent-turn/tool-policy.ts
|
|
10830
|
+
import {
|
|
10831
|
+
desktopCapableBackend
|
|
10832
|
+
} from "@opengeni/runtime";
|
|
10435
10833
|
import {
|
|
10436
10834
|
isDirectOpenAiApiBaseUrl
|
|
10437
10835
|
} from "@opengeni/config";
|
|
@@ -10966,7 +11364,7 @@ async function prepareGovernanceAndModel(deps) {
|
|
|
10966
11364
|
|
|
10967
11365
|
// src/activities/agent-turn/compaction-prep.ts
|
|
10968
11366
|
import { hasPendingSteerAfterContextCompaction, isSessionCompactionRequested as isSessionCompactionRequested2 } from "@opengeni/db";
|
|
10969
|
-
import { publishDurableSessionEvents as
|
|
11367
|
+
import { publishDurableSessionEvents as publishDurableSessionEvents6 } from "@opengeni/events";
|
|
10970
11368
|
import {
|
|
10971
11369
|
appendSessionInstructions,
|
|
10972
11370
|
appendWorkspaceGovernance,
|
|
@@ -11036,6 +11434,8 @@ async function prepareCompaction(deps) {
|
|
|
11036
11434
|
providerApi: resolvedModel?.provider.api ?? "responses",
|
|
11037
11435
|
model: resolvedModel?.configured.id ?? turn.model,
|
|
11038
11436
|
externallyBilled: billingState.isExternallyBilledTurn,
|
|
11437
|
+
chargesOpenGeniCredits: billingState.chargesOpenGeniCredits,
|
|
11438
|
+
countsTowardTokenCap: billingState.countsTowardTokenCap,
|
|
11039
11439
|
turnAttemptId: input.attemptId,
|
|
11040
11440
|
servingCredentialId: providerTurn.effectiveCodexCredentialId,
|
|
11041
11441
|
priorSessionCredentialId: providerTurn.priorSessionCodexCredentialId,
|
|
@@ -11100,10 +11500,10 @@ async function prepareCompaction(deps) {
|
|
|
11100
11500
|
});
|
|
11101
11501
|
}) : void 0;
|
|
11102
11502
|
const publishCompactionLiveEvents = async (events) => {
|
|
11103
|
-
await
|
|
11503
|
+
await publishDurableSessionEvents6(bus, input.workspaceId, input.sessionId, events);
|
|
11104
11504
|
};
|
|
11105
11505
|
const publishCompactionOutcomeEvents = async (events) => {
|
|
11106
|
-
await
|
|
11506
|
+
await publishDurableSessionEvents6(
|
|
11107
11507
|
bus,
|
|
11108
11508
|
input.workspaceId,
|
|
11109
11509
|
input.sessionId,
|
|
@@ -11113,6 +11513,7 @@ async function prepareCompaction(deps) {
|
|
|
11113
11513
|
const compactionModeOptions = {
|
|
11114
11514
|
codexCompactionMode: session.codexCompactionMode,
|
|
11115
11515
|
isCodexSubscriptionTurn: billingState.isCodexTurn,
|
|
11516
|
+
onCompactionStarted: (trigger) => recordContextCompactionStarted(observability, trigger),
|
|
11116
11517
|
publishLiveEvents: publishCompactionLiveEvents,
|
|
11117
11518
|
...remoteCompactionRequester ? { requestRemoteCompactionV2: remoteCompactionRequester } : {}
|
|
11118
11519
|
};
|
|
@@ -11549,6 +11950,12 @@ import {
|
|
|
11549
11950
|
sandboxWarmRateMicrosPerSecond
|
|
11550
11951
|
} from "@opengeni/config";
|
|
11551
11952
|
import { ChannelAPartialMutationError } from "@opengeni/runtime/sandbox";
|
|
11953
|
+
function preemptSandboxTurnForDeadlineRotation(input) {
|
|
11954
|
+
if (input.controller.signal.aborted || input.cancellationSignal?.aborted) return false;
|
|
11955
|
+
input.sandboxState.deadlineRotationRequested = true;
|
|
11956
|
+
input.controller.abort(new SandboxDeadlineRotationError(input.sandboxGroupId, input.leaseEpoch));
|
|
11957
|
+
return true;
|
|
11958
|
+
}
|
|
11552
11959
|
function createSandboxTurnRuntime(deps) {
|
|
11553
11960
|
const {
|
|
11554
11961
|
input,
|
|
@@ -11671,7 +12078,7 @@ function createSandboxTurnRuntime(deps) {
|
|
|
11671
12078
|
admissionOutcome = "completed";
|
|
11672
12079
|
} catch (admissionError) {
|
|
11673
12080
|
if (admissionError instanceof SandboxWorkspaceMutationFencedError && admissionError.code === "rotation_in_progress" && sandboxState.sandboxGroupId) {
|
|
11674
|
-
void
|
|
12081
|
+
void beginRotationPreemption(
|
|
11675
12082
|
sandbox,
|
|
11676
12083
|
sandbox.leaseEpoch,
|
|
11677
12084
|
sandboxState.sandboxGroupId
|
|
@@ -11782,51 +12189,30 @@ function createSandboxTurnRuntime(deps) {
|
|
|
11782
12189
|
console.error("sandbox box lost event publish failed", safeErrorDiagnostic(publishError));
|
|
11783
12190
|
});
|
|
11784
12191
|
};
|
|
11785
|
-
const
|
|
11786
|
-
if (sandboxState.
|
|
12192
|
+
const beginRotationPreemption = async (sandbox, rotationEpoch, rotationGroupId) => {
|
|
12193
|
+
if (sandboxState.rotationPreemptionInFlight || sandboxRotationController.signal.aborted || cancellationSignal?.aborted) {
|
|
11787
12194
|
return "busy";
|
|
11788
12195
|
}
|
|
11789
|
-
|
|
11790
|
-
|
|
11791
|
-
return "not_rotating";
|
|
12196
|
+
if (sandboxState.rotationPreemptionInFlight || sandboxRotationController.signal.aborted) {
|
|
12197
|
+
return "busy";
|
|
11792
12198
|
}
|
|
11793
|
-
|
|
11794
|
-
sandboxState.
|
|
11795
|
-
|
|
11796
|
-
|
|
11797
|
-
|
|
11798
|
-
settings.sandboxSnapshotTimeoutMs,
|
|
11799
|
-
cancellationSignal
|
|
11800
|
-
);
|
|
11801
|
-
}
|
|
11802
|
-
const snapshotSession = sandboxState.setupBoxSession;
|
|
11803
|
-
const snapshotTurnId = attempt.turnId;
|
|
11804
|
-
if (!snapshotSession || !snapshotTurnId) return;
|
|
11805
|
-
const checkpoint = await persistSandboxDeadlineRotationCheckpoint(
|
|
11806
|
-
{ db, settings, objectStorage, observability },
|
|
11807
|
-
{
|
|
11808
|
-
accountId: input.accountId,
|
|
11809
|
-
workspaceId: input.workspaceId,
|
|
11810
|
-
sessionId: input.sessionId,
|
|
11811
|
-
turnId: snapshotTurnId,
|
|
11812
|
-
attemptId: input.attemptId,
|
|
11813
|
-
sandboxGroupId: rotationGroupId
|
|
11814
|
-
},
|
|
11815
|
-
snapshotSession,
|
|
11816
|
-
{ leaseEpoch: rotationEpoch, instanceId: sandbox.established.instanceId },
|
|
11817
|
-
cancellationSignal
|
|
11818
|
-
);
|
|
11819
|
-
if (checkpoint.checkpointed) {
|
|
11820
|
-
sandboxRotationController.abort(
|
|
11821
|
-
new SandboxDeadlineRotationError(rotationGroupId, rotationEpoch)
|
|
11822
|
-
);
|
|
12199
|
+
let disposition = "started";
|
|
12200
|
+
sandboxState.rotationPreemptionInFlight = (async () => {
|
|
12201
|
+
const rotatingLease = await readLease2(db, input.workspaceId, rotationGroupId);
|
|
12202
|
+
if (rotatingLease?.leaseEpoch !== rotationEpoch || rotatingLease.instanceId !== sandbox.established.instanceId || rotatingLease.rotationRequestedAt === null) {
|
|
12203
|
+
disposition = "not_rotating";
|
|
11823
12204
|
return;
|
|
11824
12205
|
}
|
|
11825
|
-
|
|
11826
|
-
|
|
11827
|
-
|
|
12206
|
+
stopLeaseHeartbeat();
|
|
12207
|
+
preemptSandboxTurnForDeadlineRotation({
|
|
12208
|
+
controller: sandboxRotationController,
|
|
12209
|
+
sandboxState,
|
|
12210
|
+
sandboxGroupId: rotationGroupId,
|
|
12211
|
+
leaseEpoch: rotationEpoch,
|
|
12212
|
+
...cancellationSignal ? { cancellationSignal } : {}
|
|
12213
|
+
});
|
|
11828
12214
|
})().catch((error) => {
|
|
11829
|
-
observability.warn("sandbox deadline rotation
|
|
12215
|
+
observability.warn("sandbox deadline rotation preemption check failed; retrying", {
|
|
11830
12216
|
workspaceId: input.workspaceId,
|
|
11831
12217
|
sessionId: input.sessionId,
|
|
11832
12218
|
sandboxGroupId: rotationGroupId,
|
|
@@ -11834,10 +12220,10 @@ function createSandboxTurnRuntime(deps) {
|
|
|
11834
12220
|
...safeErrorDiagnostic(error)
|
|
11835
12221
|
});
|
|
11836
12222
|
}).finally(() => {
|
|
11837
|
-
sandboxState.
|
|
12223
|
+
sandboxState.rotationPreemptionInFlight = null;
|
|
11838
12224
|
});
|
|
11839
|
-
await sandboxState.
|
|
11840
|
-
return
|
|
12225
|
+
await sandboxState.rotationPreemptionInFlight;
|
|
12226
|
+
return disposition;
|
|
11841
12227
|
};
|
|
11842
12228
|
const startLeaseHeartbeat = (sandbox, warmBackend) => {
|
|
11843
12229
|
if (sandboxState.leaseHeartbeatTimer) return;
|
|
@@ -11862,7 +12248,7 @@ function createSandboxTurnRuntime(deps) {
|
|
|
11862
12248
|
expectedEpoch: heartbeatEpoch
|
|
11863
12249
|
}).then(async (alive) => {
|
|
11864
12250
|
if (alive) return;
|
|
11865
|
-
const rotation = await
|
|
12251
|
+
const rotation = await beginRotationPreemption(sandbox, heartbeatEpoch, heartbeatGroupId);
|
|
11866
12252
|
if (rotation === "not_rotating") {
|
|
11867
12253
|
stopLeaseHeartbeat();
|
|
11868
12254
|
}
|
|
@@ -11880,9 +12266,10 @@ function createSandboxTurnRuntime(deps) {
|
|
|
11880
12266
|
if (snapshotSession && snapshotTurnId && shouldStartPeriodicWorkspaceSnapshot({
|
|
11881
12267
|
firstProviderRequestStarted: sandboxState.firstProviderRequestStarted,
|
|
11882
12268
|
snapshotInFlight: Boolean(sandboxState.snapshotInFlight),
|
|
11883
|
-
turnEndCaptureInProgress: sandboxState.turnEndCaptureInProgress
|
|
12269
|
+
turnEndCaptureInProgress: sandboxState.turnEndCaptureInProgress,
|
|
12270
|
+
deadlineRotationRequested: sandboxState.deadlineRotationRequested
|
|
11884
12271
|
})) {
|
|
11885
|
-
|
|
12272
|
+
const snapshot = maybePersistWarmWorkspaceSnapshot(
|
|
11886
12273
|
{ db, settings, objectStorage },
|
|
11887
12274
|
{
|
|
11888
12275
|
accountId: input.accountId,
|
|
@@ -11895,7 +12282,9 @@ function createSandboxTurnRuntime(deps) {
|
|
|
11895
12282
|
snapshotSession,
|
|
11896
12283
|
heartbeatEpoch,
|
|
11897
12284
|
activityContext?.cancellationSignal
|
|
11898
|
-
)
|
|
12285
|
+
);
|
|
12286
|
+
sandboxState.snapshotInFlight = snapshot.settled;
|
|
12287
|
+
void snapshot.then(async (persisted) => {
|
|
11899
12288
|
if (persisted && eventing.publish) {
|
|
11900
12289
|
await eventing.publish([
|
|
11901
12290
|
{
|
|
@@ -11904,8 +12293,11 @@ function createSandboxTurnRuntime(deps) {
|
|
|
11904
12293
|
}
|
|
11905
12294
|
]);
|
|
11906
12295
|
}
|
|
11907
|
-
}).catch(() => void 0)
|
|
11908
|
-
|
|
12296
|
+
}).catch(() => void 0);
|
|
12297
|
+
void snapshot.settled.then(() => {
|
|
12298
|
+
if (sandboxState.snapshotInFlight === snapshot.settled) {
|
|
12299
|
+
sandboxState.snapshotInFlight = null;
|
|
12300
|
+
}
|
|
11909
12301
|
});
|
|
11910
12302
|
}
|
|
11911
12303
|
}, 1e4);
|
|
@@ -13860,7 +14252,7 @@ import {
|
|
|
13860
14252
|
XAI_CREDENTIAL_LEASE_TTL_MS as XAI_CREDENTIAL_LEASE_TTL_MS2,
|
|
13861
14253
|
armXaiCapacityWait as armXaiCapacityWait2
|
|
13862
14254
|
} from "@opengeni/db";
|
|
13863
|
-
import { publishDurableSessionEvents as
|
|
14255
|
+
import { publishDurableSessionEvents as publishDurableSessionEvents7 } from "@opengeni/events";
|
|
13864
14256
|
async function selectXaiTurnCapacity(deps) {
|
|
13865
14257
|
const {
|
|
13866
14258
|
input,
|
|
@@ -13967,7 +14359,7 @@ async function selectXaiTurnCapacity(deps) {
|
|
|
13967
14359
|
}
|
|
13968
14360
|
});
|
|
13969
14361
|
if (armed.action === "waiting") {
|
|
13970
|
-
await
|
|
14362
|
+
await publishDurableSessionEvents7(bus, input.workspaceId, input.sessionId, armed.events);
|
|
13971
14363
|
control.turnMetricOutcome = "recovering";
|
|
13972
14364
|
control.activityStatus = "waiting_capacity";
|
|
13973
14365
|
return {
|
|
@@ -14963,12 +15355,21 @@ async function prepareRunCredentials(deps) {
|
|
|
14963
15355
|
// src/activities/agent-turn/tool-environment.ts
|
|
14964
15356
|
import {
|
|
14965
15357
|
getScheduledVariableSetExpectedGenerationForAttempt,
|
|
15358
|
+
getWorkspaceModelPolicy as getWorkspaceModelPolicy2,
|
|
15359
|
+
listWorkspaceGatewayCustomModels as listWorkspaceGatewayCustomModels2,
|
|
15360
|
+
listWorkspaceOpenRouterCustomModels as listWorkspaceOpenRouterCustomModels2,
|
|
15361
|
+
listOrganizationModelProviderCustomModelsForWorkspace as listOrganizationModelProviderCustomModelsForWorkspace2,
|
|
15362
|
+
organizationModelProviderConnectionActiveForWorkspace,
|
|
14966
15363
|
persistAttemptToolCatalog,
|
|
14967
15364
|
namedSubjectHasLiveWorkspaceAuthority as namedSubjectHasLiveWorkspaceAuthority2,
|
|
14968
|
-
updateSessionTitleWithEvent,
|
|
14969
|
-
withCodexAppsRequestAuthorization
|
|
15365
|
+
updateSessionTitleWithEvent as updateSessionTitleWithEvent2,
|
|
15366
|
+
withCodexAppsRequestAuthorization,
|
|
15367
|
+
workspaceCodexSubscriptionActive as workspaceCodexSubscriptionActive3,
|
|
15368
|
+
workspaceVercelAiGatewayConnectionActive,
|
|
15369
|
+
workspaceOpenRouterConnectionActive,
|
|
15370
|
+
workspaceXaiSubscriptionActiveForAuthority
|
|
14970
15371
|
} from "@opengeni/db";
|
|
14971
|
-
import { publishDurableSessionEvents as
|
|
15372
|
+
import { publishDurableSessionEvents as publishDurableSessionEvents9 } from "@opengeni/events";
|
|
14972
15373
|
import {
|
|
14973
15374
|
createFirstPartyInteractionAttemptToolDefinitions
|
|
14974
15375
|
} from "@opengeni/runtime";
|
|
@@ -15643,6 +16044,7 @@ import {
|
|
|
15643
16044
|
sessionTenancyProductActivated
|
|
15644
16045
|
} from "@opengeni/db";
|
|
15645
16046
|
import { recordTenancyCompatibilityLaneUse } from "@opengeni/observability";
|
|
16047
|
+
var OPENGENI_CONNECTION_ID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/iu;
|
|
15646
16048
|
function connectionTokenResolverForTurn(input) {
|
|
15647
16049
|
const hostResolver = input.connectionCredentials?.mcpCredentials;
|
|
15648
16050
|
const baseResolver = hostResolver ? buildHostConnectionTokenResolver(hostResolver, {
|
|
@@ -15658,6 +16060,37 @@ function connectionTokenResolverForTurn(input) {
|
|
|
15658
16060
|
surface: "model"
|
|
15659
16061
|
}) : buildConnectionTokenResolver(input.db, input.settings);
|
|
15660
16062
|
return async (request) => {
|
|
16063
|
+
if (request.connectionRef.authoritySource === "host") {
|
|
16064
|
+
if (hostResolver) return await baseResolver(request);
|
|
16065
|
+
return {
|
|
16066
|
+
status: "auth_needed",
|
|
16067
|
+
reason: "unsupported_auth",
|
|
16068
|
+
providerDomain: request.connectionRef.providerDomain,
|
|
16069
|
+
authoritySource: "host",
|
|
16070
|
+
...request.connectionRef.provider ? { provider: request.connectionRef.provider } : {},
|
|
16071
|
+
...request.connectionRef.connectionId ? { connectionId: request.connectionRef.connectionId } : {},
|
|
16072
|
+
...request.connectionRef.scopes ? { scopes: request.connectionRef.scopes } : {},
|
|
16073
|
+
...request.connectionRef.resource ? { resource: request.connectionRef.resource } : {},
|
|
16074
|
+
...request.connectionRef.selectedResources ? { selectedResources: request.connectionRef.selectedResources } : {}
|
|
16075
|
+
};
|
|
16076
|
+
}
|
|
16077
|
+
if (hostResolver && request.connectionRef.connectionId && !OPENGENI_CONNECTION_ID_PATTERN.test(request.connectionRef.connectionId)) {
|
|
16078
|
+
try {
|
|
16079
|
+
return await baseResolver(request);
|
|
16080
|
+
} catch {
|
|
16081
|
+
return {
|
|
16082
|
+
status: "auth_needed",
|
|
16083
|
+
reason: "refresh_failed",
|
|
16084
|
+
providerDomain: request.connectionRef.providerDomain,
|
|
16085
|
+
authoritySource: "host",
|
|
16086
|
+
...request.connectionRef.provider ? { provider: request.connectionRef.provider } : {},
|
|
16087
|
+
connectionId: request.connectionRef.connectionId,
|
|
16088
|
+
...request.connectionRef.scopes ? { scopes: request.connectionRef.scopes } : {},
|
|
16089
|
+
...request.connectionRef.resource ? { resource: request.connectionRef.resource } : {},
|
|
16090
|
+
...request.connectionRef.selectedResources ? { selectedResources: request.connectionRef.selectedResources } : {}
|
|
16091
|
+
};
|
|
16092
|
+
}
|
|
16093
|
+
}
|
|
15661
16094
|
const acceptedDelegation = input.turn.personalConnectionDelegations.find(
|
|
15662
16095
|
(delegation) => (delegation.connectionType === void 0 || delegation.connectionType === "mcp" || delegation.connectionType === "github_personal" && delegation.serverId === "github:personal" && request.serverId === "github:personal" && request.connectionRef.provider === "github" && request.connectionRef.kind === "oauth2" && request.connectionRef.providerDomain === "github.com" && request.credentialTarget === "http_api" && isGitHubApiDestination(request.destinationUrl)) && delegation.serverId === request.serverId && delegation.connectionId === request.connectionRef.connectionId
|
|
15663
16096
|
);
|
|
@@ -15820,7 +16253,13 @@ function integrationCredentialResolver(input, integration) {
|
|
|
15820
16253
|
forceRefresh: request.forceRefresh === true
|
|
15821
16254
|
});
|
|
15822
16255
|
if (result.status === "auth_needed") {
|
|
15823
|
-
await publishAuthNeeded(
|
|
16256
|
+
await publishAuthNeeded(
|
|
16257
|
+
input,
|
|
16258
|
+
integration.serverId,
|
|
16259
|
+
request.operationKey,
|
|
16260
|
+
result,
|
|
16261
|
+
connectionRef
|
|
16262
|
+
);
|
|
15824
16263
|
return null;
|
|
15825
16264
|
}
|
|
15826
16265
|
const destination = new URL(request.destinationUrl);
|
|
@@ -15838,7 +16277,7 @@ function integrationCredentialResolver(input, integration) {
|
|
|
15838
16277
|
}
|
|
15839
16278
|
};
|
|
15840
16279
|
}
|
|
15841
|
-
async function publishAuthNeeded(input, serverId, toolName, result) {
|
|
16280
|
+
async function publishAuthNeeded(input, serverId, toolName, result, connectionRef) {
|
|
15842
16281
|
try {
|
|
15843
16282
|
await input.onAuthNeeded?.({
|
|
15844
16283
|
serverId,
|
|
@@ -15847,6 +16286,7 @@ async function publishAuthNeeded(input, serverId, toolName, result) {
|
|
|
15847
16286
|
...result.provider ? { provider: result.provider } : {},
|
|
15848
16287
|
reason: result.reason,
|
|
15849
16288
|
...result.connectionId ? { connectionId: result.connectionId } : {},
|
|
16289
|
+
...result.authoritySource === "host" || connectionRef.authoritySource === "host" ? { authoritySource: "host" } : {},
|
|
15850
16290
|
...result.scopes ? { scopes: result.scopes } : {},
|
|
15851
16291
|
...result.resource ? { resource: result.resource } : {},
|
|
15852
16292
|
...result.selectedResources ? { selectedResources: result.selectedResources } : {},
|
|
@@ -15880,6 +16320,7 @@ import {
|
|
|
15880
16320
|
} from "@opengeni/codemode";
|
|
15881
16321
|
import { createGitHubAppInstallationTokenWithExpiry as createGitHubAppInstallationTokenWithExpiry2, githubAppBotIdentity as githubAppBotIdentity2 } from "@opengeni/github";
|
|
15882
16322
|
import {
|
|
16323
|
+
ConnectorActionBindingRejectedError,
|
|
15883
16324
|
prefixedMcpToolName
|
|
15884
16325
|
} from "@opengeni/runtime";
|
|
15885
16326
|
import {
|
|
@@ -16314,7 +16755,7 @@ function githubConnectorBindings(serverId, repositories) {
|
|
|
16314
16755
|
const args = objectRecord(arguments_);
|
|
16315
16756
|
const repository = typeof args.repository === "string" ? byName.get(args.repository.toLowerCase()) : null;
|
|
16316
16757
|
if (!repository) {
|
|
16317
|
-
throw new
|
|
16758
|
+
throw new ConnectorActionBindingRejectedError(
|
|
16318
16759
|
"GitHub action repository does not match an accepted resource"
|
|
16319
16760
|
);
|
|
16320
16761
|
}
|
|
@@ -16523,7 +16964,7 @@ import {
|
|
|
16523
16964
|
} from "@opengeni/db";
|
|
16524
16965
|
import {
|
|
16525
16966
|
appendAndPublishTurnEventsFenced as appendAndPublishTurnEventsFenced3,
|
|
16526
|
-
publishDurableSessionEvents as
|
|
16967
|
+
publishDurableSessionEvents as publishDurableSessionEvents8
|
|
16527
16968
|
} from "@opengeni/events";
|
|
16528
16969
|
var CodemodeAttemptDispatcher = class {
|
|
16529
16970
|
constructor(db, bus, environment, scope, turnSignal, maxConcurrentCalls = CODEMODE_MAX_CONCURRENT_CALLS_PER_ATTEMPT) {
|
|
@@ -16732,7 +17173,7 @@ var CodemodeAttemptDispatcher = class {
|
|
|
16732
17173
|
settlement
|
|
16733
17174
|
});
|
|
16734
17175
|
if (!result.committed || result.events.length === 0) return;
|
|
16735
|
-
await
|
|
17176
|
+
await publishDurableSessionEvents8(
|
|
16736
17177
|
this.bus,
|
|
16737
17178
|
this.scope.workspaceId,
|
|
16738
17179
|
this.scope.sessionId,
|
|
@@ -16782,64 +17223,78 @@ import {
|
|
|
16782
17223
|
defaultSessionMcpServerIds,
|
|
16783
17224
|
loadRigDefaultVariableSetEnvironment,
|
|
16784
17225
|
mergeRigDefaultVariableSetEnvironment,
|
|
17226
|
+
resolveCatalogSettings as resolveCatalogSettings2,
|
|
17227
|
+
resolveWorkspaceModelSelection,
|
|
16785
17228
|
withFrozenPersonalConnectionDelegations,
|
|
16786
17229
|
resolveSessionToolPolicy
|
|
16787
17230
|
} from "@opengeni/core";
|
|
16788
17231
|
import { SandboxChannelAService as SandboxChannelAService3 } from "@opengeni/runtime/sandbox";
|
|
16789
17232
|
import { sandboxRunAs as sandboxRunAs4 } from "@opengeni/runtime";
|
|
16790
17233
|
|
|
16791
|
-
// src/activities/agent-turn/
|
|
16792
|
-
|
|
16793
|
-
|
|
16794
|
-
|
|
16795
|
-
|
|
16796
|
-
}
|
|
16797
|
-
|
|
16798
|
-
|
|
16799
|
-
function shouldRequestMissingSessionTitle(input) {
|
|
16800
|
-
const title = input.title?.trim() ?? "";
|
|
16801
|
-
const needsSemanticTitle = input.titleSource !== "user" && (!title || title === AUTOMATIC_SESSION_TITLE_FALLBACK);
|
|
16802
|
-
if (!needsSemanticTitle) return false;
|
|
16803
|
-
if (!input.firstPartyMcpTools.includes("set_session_title")) return false;
|
|
16804
|
-
const permissions = input.firstPartyMcpPermissions ?? DEFAULT_FIRST_PARTY_MCP_PERMISSIONS;
|
|
16805
|
-
return hasPermission([...permissions], "sessions:control");
|
|
16806
|
-
}
|
|
16807
|
-
function sessionTitleToolPlan(input) {
|
|
16808
|
-
const promoteTitleTool = input.shouldRequestTitle && input.tools.some((tool) => tool.kind === "mcp" && tool.id === "opengeni");
|
|
17234
|
+
// src/activities/agent-turn/turn-sandbox-access.ts
|
|
17235
|
+
async function resolveTurnSandboxAccess(sandboxState, sdkOwnedSandboxSession, unavailableMessage) {
|
|
17236
|
+
let sandbox = sandboxState.resolvedSandbox;
|
|
17237
|
+
if (!sandbox && sandboxState.turnSandboxProvisioner) {
|
|
17238
|
+
sandbox = await sandboxState.turnSandboxProvisioner.get();
|
|
17239
|
+
}
|
|
17240
|
+
const session = sandboxState.lazyOwnedSandbox?.session ?? sandbox?.established.session ?? sdkOwnedSandboxSession;
|
|
17241
|
+
if (!session) throw new Error(unavailableMessage);
|
|
16809
17242
|
return {
|
|
16810
|
-
|
|
16811
|
-
|
|
16812
|
-
|
|
17243
|
+
sandbox,
|
|
17244
|
+
session,
|
|
17245
|
+
leaseEpoch: sandbox?.leaseEpoch ?? 0
|
|
16813
17246
|
};
|
|
16814
17247
|
}
|
|
16815
|
-
|
|
17248
|
+
|
|
17249
|
+
// src/activities/agent-turn/list-models.ts
|
|
17250
|
+
import {
|
|
17251
|
+
compareModelPickerOrder,
|
|
17252
|
+
modelPickerBillingClassFor
|
|
17253
|
+
} from "@opengeni/contracts/model-picker-order";
|
|
17254
|
+
var LIST_MODELS_TOOL_NAME = "list_models";
|
|
17255
|
+
var LIST_MODELS_TOOL_DESCRIPTION = "List the models this workspace can select right now, in picker order, with deployment-defined cost and optional guidance. This does not switch the current session model; use an ID with session_create or the human model picker.";
|
|
17256
|
+
function safeLineField(value) {
|
|
17257
|
+
return value.replace(/[\r\n|]/gu, " ").replace(/\s+/gu, " ").trim();
|
|
17258
|
+
}
|
|
17259
|
+
function renderListModels(input) {
|
|
17260
|
+
const lines = [];
|
|
17261
|
+
if (input.currentModelId) {
|
|
17262
|
+
lines.push(`Current: ${safeLineField(input.currentModelId)}`);
|
|
17263
|
+
}
|
|
17264
|
+
const selectable = input.selections.filter((entry) => entry.availability.selectable).map((selection) => ({
|
|
17265
|
+
selection,
|
|
17266
|
+
billingClass: modelPickerBillingClassFor(selection.model),
|
|
17267
|
+
selectable: selection.availability.selectable,
|
|
17268
|
+
label: selection.model.label
|
|
17269
|
+
})).sort(compareModelPickerOrder);
|
|
17270
|
+
if (selectable.length === 0) {
|
|
17271
|
+
lines.push("No models are available in this workspace.");
|
|
17272
|
+
return lines.join("\n");
|
|
17273
|
+
}
|
|
17274
|
+
for (const { selection } of selectable) {
|
|
17275
|
+
const { model } = selection;
|
|
17276
|
+
const fields = [safeLineField(model.id), safeLineField(model.label), model.cost];
|
|
17277
|
+
const note = input.modelNotes[model.id];
|
|
17278
|
+
if (note) fields.push(safeLineField(note));
|
|
17279
|
+
lines.push(`- ${fields.join(" | ")}`);
|
|
17280
|
+
}
|
|
17281
|
+
return lines.join("\n");
|
|
17282
|
+
}
|
|
17283
|
+
function createListModelsAttemptToolDefinition(input) {
|
|
16816
17284
|
return {
|
|
16817
|
-
identity: { serverId: "opengeni", toolName:
|
|
16818
|
-
modelName:
|
|
16819
|
-
codemodePath: ["opengeni",
|
|
16820
|
-
title: "
|
|
16821
|
-
description:
|
|
17285
|
+
identity: { serverId: "opengeni", toolName: LIST_MODELS_TOOL_NAME },
|
|
17286
|
+
modelName: LIST_MODELS_TOOL_NAME,
|
|
17287
|
+
codemodePath: ["opengeni", LIST_MODELS_TOOL_NAME],
|
|
17288
|
+
title: "List selectable models",
|
|
17289
|
+
description: LIST_MODELS_TOOL_DESCRIPTION,
|
|
16822
17290
|
inputSchema: {
|
|
16823
17291
|
type: "object",
|
|
16824
|
-
properties: {
|
|
16825
|
-
title: { type: "string", minLength: 1, maxLength: 200 }
|
|
16826
|
-
},
|
|
16827
|
-
required: ["title"],
|
|
16828
|
-
additionalProperties: false
|
|
16829
|
-
},
|
|
16830
|
-
outputSchema: {
|
|
16831
|
-
type: "object",
|
|
16832
|
-
properties: {
|
|
16833
|
-
ok: { type: "boolean", const: true },
|
|
16834
|
-
updated: { type: "boolean" },
|
|
16835
|
-
title: { type: "string" }
|
|
16836
|
-
},
|
|
16837
|
-
required: ["ok", "updated", "title"],
|
|
17292
|
+
properties: {},
|
|
16838
17293
|
additionalProperties: false
|
|
16839
17294
|
},
|
|
16840
17295
|
annotations: {
|
|
16841
|
-
title: "
|
|
16842
|
-
readOnlyHint:
|
|
17296
|
+
title: "List selectable models",
|
|
17297
|
+
readOnlyHint: true,
|
|
16843
17298
|
destructiveHint: false,
|
|
16844
17299
|
idempotentHint: true,
|
|
16845
17300
|
openWorldHint: false
|
|
@@ -16847,40 +17302,27 @@ function createSessionTitleAttemptToolDefinition(input) {
|
|
|
16847
17302
|
source: "opengeni",
|
|
16848
17303
|
approval: "none",
|
|
16849
17304
|
execute: async (args) => {
|
|
16850
|
-
|
|
16851
|
-
|
|
16852
|
-
throw new Error("set_session_title requires a title string");
|
|
17305
|
+
if (Object.keys(args).length !== 0) {
|
|
17306
|
+
throw new Error("list_models accepts no arguments");
|
|
16853
17307
|
}
|
|
16854
|
-
const
|
|
16855
|
-
const output = {
|
|
16856
|
-
ok: true,
|
|
16857
|
-
updated: result.updated,
|
|
16858
|
-
title: result.title ?? title
|
|
16859
|
-
};
|
|
17308
|
+
const catalog = await input.load();
|
|
16860
17309
|
return {
|
|
16861
17310
|
isError: false,
|
|
16862
|
-
content: [
|
|
16863
|
-
|
|
17311
|
+
content: [
|
|
17312
|
+
{
|
|
17313
|
+
type: "text",
|
|
17314
|
+
text: renderListModels({
|
|
17315
|
+
currentModelId: input.currentModelId,
|
|
17316
|
+
selections: catalog.selections,
|
|
17317
|
+
modelNotes: catalog.modelNotes
|
|
17318
|
+
})
|
|
17319
|
+
}
|
|
17320
|
+
]
|
|
16864
17321
|
};
|
|
16865
17322
|
}
|
|
16866
17323
|
};
|
|
16867
17324
|
}
|
|
16868
17325
|
|
|
16869
|
-
// src/activities/agent-turn/turn-sandbox-access.ts
|
|
16870
|
-
async function resolveTurnSandboxAccess(sandboxState, sdkOwnedSandboxSession, unavailableMessage) {
|
|
16871
|
-
let sandbox = sandboxState.resolvedSandbox;
|
|
16872
|
-
if (!sandbox && sandboxState.turnSandboxProvisioner) {
|
|
16873
|
-
sandbox = await sandboxState.turnSandboxProvisioner.get();
|
|
16874
|
-
}
|
|
16875
|
-
const session = sandboxState.lazyOwnedSandbox?.session ?? sandbox?.established.session ?? sdkOwnedSandboxSession;
|
|
16876
|
-
if (!session) throw new Error(unavailableMessage);
|
|
16877
|
-
return {
|
|
16878
|
-
sandbox,
|
|
16879
|
-
session,
|
|
16880
|
-
leaseEpoch: sandbox?.leaseEpoch ?? 0
|
|
16881
|
-
};
|
|
16882
|
-
}
|
|
16883
|
-
|
|
16884
17326
|
// src/activities/agent-turn/tool-environment.ts
|
|
16885
17327
|
async function prepareTurnToolPolicy(deps) {
|
|
16886
17328
|
const {
|
|
@@ -17002,6 +17444,7 @@ async function prepareTurnToolPolicy(deps) {
|
|
|
17002
17444
|
async function prepareTurnToolRuntime(deps) {
|
|
17003
17445
|
const {
|
|
17004
17446
|
input,
|
|
17447
|
+
catalogSourceSettings,
|
|
17005
17448
|
db,
|
|
17006
17449
|
bus,
|
|
17007
17450
|
runtime,
|
|
@@ -17106,7 +17549,10 @@ async function prepareTurnToolRuntime(deps) {
|
|
|
17106
17549
|
if (!shouldPublishToolAuthNeededForTurn(payload, trigger, turn)) {
|
|
17107
17550
|
return;
|
|
17108
17551
|
}
|
|
17109
|
-
await eventing.publish(
|
|
17552
|
+
await eventing.publish(
|
|
17553
|
+
[{ type: "tool.auth_needed", payload: rollingSafeToolAuthNeededPayload(payload) }],
|
|
17554
|
+
true
|
|
17555
|
+
);
|
|
17110
17556
|
};
|
|
17111
17557
|
const selectedApiIntegrationServerIds = new Set(turnTools.map((tool) => tool.id));
|
|
17112
17558
|
const apiIntegrationMcpServers = buildApiIntegrationServersForTurn({
|
|
@@ -17173,7 +17619,8 @@ async function prepareTurnToolRuntime(deps) {
|
|
|
17173
17619
|
titleSource: session.titleSource,
|
|
17174
17620
|
firstPartyMcpTools: selectedFirstPartyMcpTools,
|
|
17175
17621
|
firstPartyMcpPermissions: session.firstPartyMcpPermissions
|
|
17176
|
-
})
|
|
17622
|
+
}),
|
|
17623
|
+
parallelGenerationAvailable: typeof runtime.generateSessionTitle === "function"
|
|
17177
17624
|
});
|
|
17178
17625
|
const googleDrivePublicationAllowed = selectedFirstPartyMcpTools.includes("editable_artifact_export") && selectedFirstPartyMcpTools.includes("editable_artifact_export_status") && (!session.firstPartyMcpPermissions?.length || session.firstPartyMcpPermissions.includes("artifacts:read") && session.firstPartyMcpPermissions.includes("artifacts:publish"));
|
|
17179
17626
|
const googleDriveConnectorBindings = googleDrivePublicationTool && googleDrivePublicationTarget && googleDrivePublicationAllowed ? [
|
|
@@ -17187,16 +17634,91 @@ async function prepareTurnToolRuntime(deps) {
|
|
|
17187
17634
|
}
|
|
17188
17635
|
] : [];
|
|
17189
17636
|
const attemptToolDefinitions = [
|
|
17637
|
+
createListModelsAttemptToolDefinition({
|
|
17638
|
+
currentModelId: turnExecutionPolicy.productModelId,
|
|
17639
|
+
load: async () => {
|
|
17640
|
+
const currentCatalog = await resolveCatalogSettings2(db, catalogSourceSettings);
|
|
17641
|
+
const currentSettings = currentCatalog.settings;
|
|
17642
|
+
const xaiReadinessAuthority = xaiCatalogReadinessAuthority(turn, credentialSubjectId);
|
|
17643
|
+
const [
|
|
17644
|
+
policy,
|
|
17645
|
+
codexSubscriptionActive,
|
|
17646
|
+
xaiSubscriptionActive,
|
|
17647
|
+
workspaceGatewayConnectionActive,
|
|
17648
|
+
workspaceGatewayCustomModels,
|
|
17649
|
+
openRouterConnectionActive,
|
|
17650
|
+
workspaceOpenRouterCustomModels,
|
|
17651
|
+
organizationGatewayConnectionActive,
|
|
17652
|
+
organizationGatewayCustomModels,
|
|
17653
|
+
organizationOpenRouterConnectionActive,
|
|
17654
|
+
organizationOpenRouterCustomModels
|
|
17655
|
+
] = await Promise.all([
|
|
17656
|
+
getWorkspaceModelPolicy2(db, input.workspaceId),
|
|
17657
|
+
workspaceCodexSubscriptionActive3(db, currentSettings, input.workspaceId),
|
|
17658
|
+
xaiReadinessAuthority && currentSettings.supergrokSubscriptionEnabled ? workspaceXaiSubscriptionActiveForAuthority(db, currentSettings, {
|
|
17659
|
+
workspaceId: input.workspaceId,
|
|
17660
|
+
...xaiReadinessAuthority
|
|
17661
|
+
}) : false,
|
|
17662
|
+
workspaceVercelAiGatewayConnectionActive(db, input.workspaceId),
|
|
17663
|
+
listWorkspaceGatewayCustomModels2(db, {
|
|
17664
|
+
accountId: input.accountId,
|
|
17665
|
+
workspaceId: input.workspaceId
|
|
17666
|
+
}),
|
|
17667
|
+
workspaceOpenRouterConnectionActive(db, input.workspaceId),
|
|
17668
|
+
listWorkspaceOpenRouterCustomModels2(db, {
|
|
17669
|
+
accountId: input.accountId,
|
|
17670
|
+
workspaceId: input.workspaceId
|
|
17671
|
+
}),
|
|
17672
|
+
organizationModelProviderConnectionActiveForWorkspace(db, {
|
|
17673
|
+
accountId: input.accountId,
|
|
17674
|
+
workspaceId: input.workspaceId,
|
|
17675
|
+
providerKind: "vercel_gateway"
|
|
17676
|
+
}),
|
|
17677
|
+
listOrganizationModelProviderCustomModelsForWorkspace2(db, {
|
|
17678
|
+
accountId: input.accountId,
|
|
17679
|
+
workspaceId: input.workspaceId,
|
|
17680
|
+
providerKind: "vercel_gateway"
|
|
17681
|
+
}),
|
|
17682
|
+
organizationModelProviderConnectionActiveForWorkspace(db, {
|
|
17683
|
+
accountId: input.accountId,
|
|
17684
|
+
workspaceId: input.workspaceId,
|
|
17685
|
+
providerKind: "openrouter"
|
|
17686
|
+
}),
|
|
17687
|
+
listOrganizationModelProviderCustomModelsForWorkspace2(db, {
|
|
17688
|
+
accountId: input.accountId,
|
|
17689
|
+
workspaceId: input.workspaceId,
|
|
17690
|
+
providerKind: "openrouter"
|
|
17691
|
+
})
|
|
17692
|
+
]);
|
|
17693
|
+
return {
|
|
17694
|
+
selections: resolveWorkspaceModelSelection({
|
|
17695
|
+
settings: currentSettings,
|
|
17696
|
+
policy,
|
|
17697
|
+
codexSubscriptionActive,
|
|
17698
|
+
xaiSubscriptionActive,
|
|
17699
|
+
workspaceGatewayConnectionActive,
|
|
17700
|
+
workspaceGatewayCustomModels,
|
|
17701
|
+
workspaceOpenRouterConnectionActive: openRouterConnectionActive,
|
|
17702
|
+
workspaceOpenRouterCustomModels,
|
|
17703
|
+
organizationGatewayConnectionActive,
|
|
17704
|
+
organizationGatewayCustomModels,
|
|
17705
|
+
organizationOpenRouterConnectionActive,
|
|
17706
|
+
organizationOpenRouterCustomModels
|
|
17707
|
+
}),
|
|
17708
|
+
modelNotes: currentCatalog.modelNotes
|
|
17709
|
+
};
|
|
17710
|
+
}
|
|
17711
|
+
}),
|
|
17190
17712
|
...titleToolPlan.promoteTitleTool ? [
|
|
17191
17713
|
createSessionTitleAttemptToolDefinition({
|
|
17192
17714
|
updateTitle: async (title) => {
|
|
17193
|
-
const result = await
|
|
17715
|
+
const result = await updateSessionTitleWithEvent2(db, {
|
|
17194
17716
|
workspaceId: input.workspaceId,
|
|
17195
17717
|
sessionId: input.sessionId,
|
|
17196
17718
|
title,
|
|
17197
17719
|
source: "agent"
|
|
17198
17720
|
});
|
|
17199
|
-
await
|
|
17721
|
+
await publishDurableSessionEvents9(
|
|
17200
17722
|
bus,
|
|
17201
17723
|
input.workspaceId,
|
|
17202
17724
|
input.sessionId,
|
|
@@ -17400,6 +17922,7 @@ async function prepareTurnToolRuntime(deps) {
|
|
|
17400
17922
|
...githubRestMcp.connectorBindings
|
|
17401
17923
|
],
|
|
17402
17924
|
connectorActionIdentity,
|
|
17925
|
+
generateSessionTitleInParallel: titleToolPlan.generateTitleInParallel,
|
|
17403
17926
|
postToolPreparationStartedAt,
|
|
17404
17927
|
preparationIndependentToolNames: titleToolPlan.preparationIndependentToolNames
|
|
17405
17928
|
};
|
|
@@ -17602,10 +18125,10 @@ import {
|
|
|
17602
18125
|
prepareConnectorActionApproval as prepareConnectorActionApproval3
|
|
17603
18126
|
} from "@opengeni/db";
|
|
17604
18127
|
import {
|
|
17605
|
-
serviceTierForLatencyMode,
|
|
18128
|
+
serviceTierForLatencyMode as serviceTierForLatencyMode2,
|
|
17606
18129
|
environmentsEncryptionKeyBytes as environmentsEncryptionKeyBytes4,
|
|
17607
|
-
WORKSPACE_GATEWAY_PROVIDER_ID,
|
|
17608
|
-
resolveModelProvider
|
|
18130
|
+
WORKSPACE_GATEWAY_PROVIDER_ID as WORKSPACE_GATEWAY_PROVIDER_ID2,
|
|
18131
|
+
resolveModelProvider as resolveModelProvider2
|
|
17609
18132
|
} from "@opengeni/config";
|
|
17610
18133
|
|
|
17611
18134
|
// src/activities/xai-image-generation.ts
|
|
@@ -18679,19 +19202,16 @@ async function referenceBytes(input, reference2) {
|
|
|
18679
19202
|
);
|
|
18680
19203
|
}
|
|
18681
19204
|
return {
|
|
18682
|
-
bytes: await
|
|
19205
|
+
bytes: await readStoredImageReferenceFile(input.objectStorage, file),
|
|
18683
19206
|
file
|
|
18684
19207
|
};
|
|
18685
19208
|
}
|
|
18686
|
-
async function
|
|
18687
|
-
const bytes = await objectStorage.
|
|
18688
|
-
|
|
18689
|
-
end: file.sizeBytes - 1
|
|
18690
|
-
});
|
|
18691
|
-
if (!bytes) {
|
|
19209
|
+
async function readStoredImageReferenceFile(objectStorage, file) {
|
|
19210
|
+
const bytes = await objectStorage.getFileBytes(file);
|
|
19211
|
+
if (bytes.byteLength !== file.sizeBytes) {
|
|
18692
19212
|
throw new ImageGenerationReferenceError(
|
|
18693
|
-
"
|
|
18694
|
-
"The durable image reference bytes
|
|
19213
|
+
"reference_integrity_mismatch",
|
|
19214
|
+
"The durable image reference bytes do not match their file metadata."
|
|
18695
19215
|
);
|
|
18696
19216
|
}
|
|
18697
19217
|
return bytes;
|
|
@@ -18940,9 +19460,9 @@ async function buildTurnAgent(deps) {
|
|
|
18940
19460
|
}
|
|
18941
19461
|
};
|
|
18942
19462
|
}
|
|
18943
|
-
const gatewayResolution =
|
|
19463
|
+
const gatewayResolution = resolveModelProvider2(
|
|
18944
19464
|
capabilitySettings,
|
|
18945
|
-
|
|
19465
|
+
WORKSPACE_GATEWAY_PROVIDER_ID2
|
|
18946
19466
|
);
|
|
18947
19467
|
const gateway = gatewayResolution?.provider;
|
|
18948
19468
|
if (gateway?.kind !== "vercel-gateway-workspace" || !gateway.apiKey) return {};
|
|
@@ -19121,7 +19641,7 @@ async function buildTurnAgent(deps) {
|
|
|
19121
19641
|
}
|
|
19122
19642
|
};
|
|
19123
19643
|
})();
|
|
19124
|
-
const serviceTier =
|
|
19644
|
+
const serviceTier = serviceTierForLatencyMode2(
|
|
19125
19645
|
turnExecutionPolicy.providerId,
|
|
19126
19646
|
turnExecutionPolicy.latencyMode
|
|
19127
19647
|
);
|
|
@@ -19320,12 +19840,39 @@ async function buildTurnAgent(deps) {
|
|
|
19320
19840
|
}
|
|
19321
19841
|
|
|
19322
19842
|
// src/activities/agent-turn/run.ts
|
|
19843
|
+
function sessionTitleCodexRequestContext(context, nextRequestId) {
|
|
19844
|
+
return {
|
|
19845
|
+
clientVersion: context.clientVersion,
|
|
19846
|
+
...context.sessionId !== void 0 ? { sessionId: context.sessionId } : {},
|
|
19847
|
+
getToken: context.getToken,
|
|
19848
|
+
refresh: context.refresh,
|
|
19849
|
+
resolveModel: context.resolveModel,
|
|
19850
|
+
...context.onUsageHeaders ? { onUsageHeaders: context.onUsageHeaders } : {},
|
|
19851
|
+
...context.responseTimeoutPolicy ? { responseTimeoutPolicy: context.responseTimeoutPolicy } : {},
|
|
19852
|
+
nextRequestId,
|
|
19853
|
+
turnMetadata: { request_kind: "session_title" }
|
|
19854
|
+
};
|
|
19855
|
+
}
|
|
19856
|
+
function sessionTitleXaiRequestContext(context, nextRequestId) {
|
|
19857
|
+
return {
|
|
19858
|
+
clientVersion: context.clientVersion,
|
|
19859
|
+
sessionId: context.sessionId,
|
|
19860
|
+
turnId: context.turnId,
|
|
19861
|
+
getToken: context.getToken,
|
|
19862
|
+
refresh: context.refresh,
|
|
19863
|
+
resolveModel: context.resolveModel,
|
|
19864
|
+
...context.streamIdleTimeoutMs !== void 0 ? { streamIdleTimeoutMs: context.streamIdleTimeoutMs } : {},
|
|
19865
|
+
...context.hostedToolContinuationTimeoutMs !== void 0 ? { hostedToolContinuationTimeoutMs: context.hostedToolContinuationTimeoutMs } : {},
|
|
19866
|
+
nextRequestId
|
|
19867
|
+
};
|
|
19868
|
+
}
|
|
19323
19869
|
function createRunAgentTurnActivity(services) {
|
|
19324
19870
|
const modelCheckpointMemoryCollector = createModelCheckpointMemoryCollector();
|
|
19325
19871
|
const turnCompletionMemoryCollector = createModelCheckpointMemoryCollector();
|
|
19326
19872
|
return async function runAgentTurn(input) {
|
|
19327
19873
|
const {
|
|
19328
19874
|
settings,
|
|
19875
|
+
catalogSourceSettings = settings,
|
|
19329
19876
|
db,
|
|
19330
19877
|
bus,
|
|
19331
19878
|
runtime,
|
|
@@ -19493,6 +20040,7 @@ function createRunAgentTurnActivity(services) {
|
|
|
19493
20040
|
const claimed = await claimTurnAttempt({
|
|
19494
20041
|
input,
|
|
19495
20042
|
settings,
|
|
20043
|
+
catalogSourceSettings,
|
|
19496
20044
|
db,
|
|
19497
20045
|
bus,
|
|
19498
20046
|
runtime,
|
|
@@ -19880,6 +20428,17 @@ function createRunAgentTurnActivity(services) {
|
|
|
19880
20428
|
}
|
|
19881
20429
|
const withCodex = (fn) => codexContext ? codexRequestStorage.run(codexContext, fn) : fn();
|
|
19882
20430
|
const withProviderRequestContext = (fn) => providerTurn.xaiRequestContext ? xaiSubscriptionRequestStorage.run(providerTurn.xaiRequestContext, fn) : withCodex(fn);
|
|
20431
|
+
let codexSessionTitleRequestSequence = 0;
|
|
20432
|
+
let xaiSessionTitleRequestSequence = 0;
|
|
20433
|
+
const codexSessionTitleContext = codexContext ? sessionTitleCodexRequestContext(
|
|
20434
|
+
codexContext,
|
|
20435
|
+
() => `${dispatchId}:title:${++codexSessionTitleRequestSequence}`
|
|
20436
|
+
) : null;
|
|
20437
|
+
const xaiSessionTitleContext = providerTurn.xaiRequestContext ? sessionTitleXaiRequestContext(
|
|
20438
|
+
providerTurn.xaiRequestContext,
|
|
20439
|
+
() => `${dispatchId}:xai:title:${++xaiSessionTitleRequestSequence}`
|
|
20440
|
+
) : null;
|
|
20441
|
+
const withSessionTitleProviderRequestContext = (fn) => xaiSessionTitleContext ? xaiSubscriptionRequestStorage.run(xaiSessionTitleContext, fn) : codexSessionTitleContext ? codexRequestStorage.run(codexSessionTitleContext, fn) : fn();
|
|
19883
20442
|
const withCodexRemoteCompaction = (fn) => withCodex(
|
|
19884
20443
|
() => withCodexRequestOverrides(
|
|
19885
20444
|
{
|
|
@@ -19897,7 +20456,7 @@ function createRunAgentTurnActivity(services) {
|
|
|
19897
20456
|
);
|
|
19898
20457
|
const compactionPrep = await prepareCompaction({
|
|
19899
20458
|
input,
|
|
19900
|
-
settings,
|
|
20459
|
+
settings: capabilitySettings,
|
|
19901
20460
|
db,
|
|
19902
20461
|
bus,
|
|
19903
20462
|
observability,
|
|
@@ -20150,6 +20709,7 @@ function createRunAgentTurnActivity(services) {
|
|
|
20150
20709
|
];
|
|
20151
20710
|
const toolRuntime = await prepareTurnToolRuntime({
|
|
20152
20711
|
input,
|
|
20712
|
+
catalogSourceSettings,
|
|
20153
20713
|
db,
|
|
20154
20714
|
bus,
|
|
20155
20715
|
runtime,
|
|
@@ -20189,6 +20749,7 @@ function createRunAgentTurnActivity(services) {
|
|
|
20189
20749
|
const {
|
|
20190
20750
|
attemptConnectorActionBindings,
|
|
20191
20751
|
connectorActionIdentity,
|
|
20752
|
+
generateSessionTitleInParallel,
|
|
20192
20753
|
postToolPreparationStartedAt,
|
|
20193
20754
|
preparationIndependentToolNames
|
|
20194
20755
|
} = toolRuntime;
|
|
@@ -20325,7 +20886,7 @@ function createRunAgentTurnActivity(services) {
|
|
|
20325
20886
|
};
|
|
20326
20887
|
const postAgentCompaction = await runPostAgentCompaction({
|
|
20327
20888
|
input,
|
|
20328
|
-
settings,
|
|
20889
|
+
settings: capabilitySettings,
|
|
20329
20890
|
db,
|
|
20330
20891
|
bus,
|
|
20331
20892
|
observability,
|
|
@@ -20473,8 +21034,9 @@ function createRunAgentTurnActivity(services) {
|
|
|
20473
21034
|
);
|
|
20474
21035
|
return await runTurnStreamAttempt({
|
|
20475
21036
|
input,
|
|
20476
|
-
settings,
|
|
21037
|
+
settings: capabilitySettings,
|
|
20477
21038
|
db,
|
|
21039
|
+
bus,
|
|
20478
21040
|
runtime,
|
|
20479
21041
|
objectStorage,
|
|
20480
21042
|
observability,
|
|
@@ -20505,6 +21067,7 @@ function createRunAgentTurnActivity(services) {
|
|
|
20505
21067
|
attachCodemodeTokenRenewal,
|
|
20506
21068
|
attachRunCredentialRenewal,
|
|
20507
21069
|
withProviderRequestContext,
|
|
21070
|
+
withSessionTitleProviderRequestContext,
|
|
20508
21071
|
publishCompactionLiveEvents,
|
|
20509
21072
|
publishCompactionOutcomeEvents,
|
|
20510
21073
|
recordCompanyBrainContributionReceiptOnce,
|
|
@@ -20530,6 +21093,8 @@ function createRunAgentTurnActivity(services) {
|
|
|
20530
21093
|
providerApi,
|
|
20531
21094
|
runSettings,
|
|
20532
21095
|
turnTools,
|
|
21096
|
+
generateSessionTitleInParallel,
|
|
21097
|
+
sessionTitlePrompt: session.initialMessage.trim() ? session.initialMessage : turn.prompt,
|
|
20533
21098
|
compactSummarizer,
|
|
20534
21099
|
settleDeferredSteerAfterCompaction,
|
|
20535
21100
|
compactionModelHistoryProjector,
|
|
@@ -20630,7 +21195,7 @@ import {
|
|
|
20630
21195
|
settleVideoGenerationFailure,
|
|
20631
21196
|
settleVideoGenerationReady
|
|
20632
21197
|
} from "@opengeni/db";
|
|
20633
|
-
import { publishDurableSessionEvents as
|
|
21198
|
+
import { publishDurableSessionEvents as publishDurableSessionEvents10 } from "@opengeni/events";
|
|
20634
21199
|
|
|
20635
21200
|
// src/activities/gateway-video-generation.ts
|
|
20636
21201
|
import { readResponseTextBounded as readResponseTextBounded2 } from "@opengeni/network";
|
|
@@ -21432,7 +21997,7 @@ async function deliverTerminalResult(service, operation) {
|
|
|
21432
21997
|
return;
|
|
21433
21998
|
}
|
|
21434
21999
|
if (result.added && result.events.length > 0) {
|
|
21435
|
-
await
|
|
22000
|
+
await publishDurableSessionEvents10(
|
|
21436
22001
|
service.bus,
|
|
21437
22002
|
operation.workspaceId,
|
|
21438
22003
|
operation.sessionId,
|
|
@@ -21697,4 +22262,4 @@ export {
|
|
|
21697
22262
|
createTurnActivities,
|
|
21698
22263
|
createTurnActivitiesFromServices
|
|
21699
22264
|
};
|
|
21700
|
-
//# sourceMappingURL=activities-turn-
|
|
22265
|
+
//# sourceMappingURL=activities-turn-I4OPLQLS.js.map
|