@opengeni/worker-bundle 1.0.2 → 1.1.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-run-admission.d.ts +1 -14
- package/dist/activities/agent-turn/errors.d.ts +3 -0
- package/dist/activities/agent-turn/provider-recovery-metrics.d.ts +18 -0
- package/dist/activities/agent-turn/turn-context.d.ts +5 -0
- package/dist/activities/goals.d.ts +1 -17
- package/dist/activities/types.d.ts +1 -1
- package/dist/{activities-control-BNPTRTOE.js → activities-control-XZAIMFQJ.js} +23 -7
- package/dist/activities-control-XZAIMFQJ.js.map +1 -0
- package/dist/{activities-turn-5LGZOSVU.js → activities-turn-4EEVNZCC.js} +97 -5
- package/dist/activities-turn-4EEVNZCC.js.map +1 -0
- package/dist/{chunk-LJX7Z2KP.js → chunk-OT64XARC.js} +38 -162
- package/dist/chunk-OT64XARC.js.map +1 -0
- package/dist/index.js +2 -3
- package/dist/index.js.map +1 -1
- package/dist/workflow-bundle.js +1 -1
- package/package.json +21 -21
- package/src/activities/agent-run-admission.ts +1 -98
- package/src/activities/agent-turn/claim.ts +11 -0
- package/src/activities/agent-turn/compaction-prep.ts +15 -0
- package/src/activities/agent-turn/errors.ts +30 -15
- package/src/activities/agent-turn/failure-settlement.ts +22 -0
- package/src/activities/agent-turn/provider-recovery-metrics.ts +64 -0
- package/src/activities/agent-turn/stream-attempt.ts +10 -0
- package/src/activities/agent-turn/tool-environment.ts +9 -2
- package/src/activities/agent-turn/turn-context.ts +4 -0
- package/src/activities/goals.ts +17 -113
- package/src/activities/scheduled-tasks.ts +18 -3
- package/src/activities/types.ts +1 -0
- package/src/index.ts +0 -2
- package/dist/activities-control-BNPTRTOE.js.map +0 -1
- package/dist/activities-turn-5LGZOSVU.js.map +0 -1
- package/dist/chunk-LJX7Z2KP.js.map +0 -1
|
@@ -99,7 +99,7 @@ import {
|
|
|
99
99
|
withFirstPartyTools,
|
|
100
100
|
wrapLazyTurnBoxWithRouting,
|
|
101
101
|
wrapTurnBoxWithRouting
|
|
102
|
-
} from "./chunk-
|
|
102
|
+
} from "./chunk-OT64XARC.js";
|
|
103
103
|
import {
|
|
104
104
|
StreamTimingMetrics,
|
|
105
105
|
makeMachineOpObserver,
|
|
@@ -6022,6 +6022,47 @@ async function ensureRunAllowed(settings, db, accountId, workspaceId, isExternal
|
|
|
6022
6022
|
}
|
|
6023
6023
|
}
|
|
6024
6024
|
|
|
6025
|
+
// src/activities/agent-turn/provider-recovery-metrics.ts
|
|
6026
|
+
function providerRecoveryCause(code) {
|
|
6027
|
+
if (code === "provider_rate_limited") return "rate_limited";
|
|
6028
|
+
if (code === "provider_unavailable") return "unavailable";
|
|
6029
|
+
if (code === "upstream_connectivity_unavailable") return "connectivity";
|
|
6030
|
+
return null;
|
|
6031
|
+
}
|
|
6032
|
+
function readProviderRecoveryObservation(metadata) {
|
|
6033
|
+
const cause = providerRecoveryCause(metadata.providerRecoveryReason);
|
|
6034
|
+
const startedAt = typeof metadata.providerRecoveryStartedAt === "string" ? Date.parse(metadata.providerRecoveryStartedAt) : Number.NaN;
|
|
6035
|
+
return cause && Number.isFinite(startedAt) ? { cause, startedAt } : void 0;
|
|
6036
|
+
}
|
|
6037
|
+
function recordProviderRecoveryOutcome(observability, input) {
|
|
6038
|
+
if (!input.route) return;
|
|
6039
|
+
const labels = { ...input.route, cause: input.cause, outcome: input.outcome };
|
|
6040
|
+
try {
|
|
6041
|
+
observability.incrementCounter({
|
|
6042
|
+
name: "opengeni_model_recovery_total",
|
|
6043
|
+
help: "Observed model recovery decisions and successful resumptions.",
|
|
6044
|
+
labels
|
|
6045
|
+
});
|
|
6046
|
+
if (input.delayMs !== void 0) {
|
|
6047
|
+
observability.observeHistogram({
|
|
6048
|
+
name: "opengeni_model_recovery_delay_seconds",
|
|
6049
|
+
help: "Scheduled model recovery delay, including provider hints and jitter.",
|
|
6050
|
+
labels: { ...input.route, cause: input.cause },
|
|
6051
|
+
value: Math.max(0, input.delayMs) / 1e3
|
|
6052
|
+
});
|
|
6053
|
+
}
|
|
6054
|
+
if (input.elapsedMs !== void 0) {
|
|
6055
|
+
observability.observeHistogram({
|
|
6056
|
+
name: "opengeni_model_recovery_duration_seconds",
|
|
6057
|
+
help: "Elapsed recovery episode including backoff, preparation and model requests.",
|
|
6058
|
+
labels,
|
|
6059
|
+
value: Math.max(0, input.elapsedMs) / 1e3
|
|
6060
|
+
});
|
|
6061
|
+
}
|
|
6062
|
+
} catch {
|
|
6063
|
+
}
|
|
6064
|
+
}
|
|
6065
|
+
|
|
6025
6066
|
// src/activities/agent-turn/failure-settlement.ts
|
|
6026
6067
|
function codexDefinitiveFailureDisposition(input) {
|
|
6027
6068
|
const alternateAvailable = input.rotationEnabled && input.pinDisposition !== "manual" && input.decisionKind === "active" && input.decisionCredentialId !== null && input.decisionCredentialId !== input.servingCredentialId;
|
|
@@ -7395,7 +7436,8 @@ async function settleTurnFailureInAttempt(deps) {
|
|
|
7395
7436
|
const recoveryResult = providerRecoveryResult({
|
|
7396
7437
|
failureCode: failure2.code,
|
|
7397
7438
|
attemptNumber: nextProviderRecoveryCount,
|
|
7398
|
-
retryAfterMs: providerRetryAfterMs(error51)
|
|
7439
|
+
retryAfterMs: providerRetryAfterMs(error51),
|
|
7440
|
+
jitterSample: Math.random()
|
|
7399
7441
|
});
|
|
7400
7442
|
const setupRecoveryExhausted = earlyCommandStartUnavailable && recoveryResult.status === "exhausted" && attempt.providerRecoveryCount === SANDBOX_SETUP_RECOVERY_LIMIT;
|
|
7401
7443
|
try {
|
|
@@ -7459,9 +7501,27 @@ async function settleTurnFailureInAttempt(deps) {
|
|
|
7459
7501
|
control.turnMetricOutcome = "recovering";
|
|
7460
7502
|
control.activityStatus = "recovering";
|
|
7461
7503
|
control.activityError = error51;
|
|
7504
|
+
const recoveryCause2 = providerRecoveryCause(failure2.code);
|
|
7505
|
+
if (recoveryCause2) {
|
|
7506
|
+
recordProviderRecoveryOutcome(observability, {
|
|
7507
|
+
route: attempt.modelMetricRoute,
|
|
7508
|
+
cause: recoveryCause2,
|
|
7509
|
+
outcome: "scheduled",
|
|
7510
|
+
delayMs: recoveryResult.continueDelayMs
|
|
7511
|
+
});
|
|
7512
|
+
}
|
|
7462
7513
|
return claimedResult(recoveryResult);
|
|
7463
7514
|
}
|
|
7464
7515
|
failure2 = providerRecoveryExhaustedFailure(failure2, recoveryResult);
|
|
7516
|
+
const recoveryCause = providerRecoveryCause(failure2.code);
|
|
7517
|
+
if (recoveryCause) {
|
|
7518
|
+
recordProviderRecoveryOutcome(observability, {
|
|
7519
|
+
route: attempt.modelMetricRoute,
|
|
7520
|
+
cause: recoveryCause,
|
|
7521
|
+
outcome: "exhausted",
|
|
7522
|
+
...attempt.providerRecoveryObservation ? { elapsedMs: Date.now() - attempt.providerRecoveryObservation.startedAt } : {}
|
|
7523
|
+
});
|
|
7524
|
+
}
|
|
7465
7525
|
if (earlyRecoverableSetup) {
|
|
7466
7526
|
control.activityStatus = "failed";
|
|
7467
7527
|
control.turnMetricOutcome = "failed";
|
|
@@ -9452,6 +9512,15 @@ async function runTurnStreamAttempt(deps) {
|
|
|
9452
9512
|
]);
|
|
9453
9513
|
attempt.providerRecoveryCount = 0;
|
|
9454
9514
|
}
|
|
9515
|
+
if (attempt.providerRecoveryObservation) {
|
|
9516
|
+
recordProviderRecoveryOutcome(observability, {
|
|
9517
|
+
route: attempt.modelMetricRoute,
|
|
9518
|
+
cause: attempt.providerRecoveryObservation.cause,
|
|
9519
|
+
outcome: "recovered",
|
|
9520
|
+
elapsedMs: Date.now() - attempt.providerRecoveryObservation.startedAt
|
|
9521
|
+
});
|
|
9522
|
+
attempt.providerRecoveryObservation = void 0;
|
|
9523
|
+
}
|
|
9455
9524
|
const rawStreamHistory = eventing.stream.state.history;
|
|
9456
9525
|
if (Array.isArray(rawStreamHistory)) {
|
|
9457
9526
|
await media.retainNativeGeneratedImagesFromHistory(
|
|
@@ -10684,6 +10753,7 @@ async function claimTurnAttempt(deps) {
|
|
|
10684
10753
|
attempt.dispatchId = dispatchId;
|
|
10685
10754
|
attempt.executionGeneration = turn.executionGeneration;
|
|
10686
10755
|
attempt.providerRecoveryCount = providerRecoveryCountFromMetadata(turn.metadata);
|
|
10756
|
+
attempt.providerRecoveryObservation = readProviderRecoveryObservation(turn.metadata ?? {});
|
|
10687
10757
|
const authRecovery = turn.metadata?.claudeAuthRecovery;
|
|
10688
10758
|
attempt.claudeAuthRecovery = authRecovery && typeof authRecovery === "object" && "credentialId" in authRecovery && typeof authRecovery.credentialId === "string" && "credentialVersion" in authRecovery && typeof authRecovery.credentialVersion === "number" && Number.isSafeInteger(authRecovery.credentialVersion) && authRecovery.credentialVersion > 0 ? {
|
|
10689
10759
|
credentialId: authRecovery.credentialId,
|
|
@@ -10793,6 +10863,7 @@ async function claimTurnAttempt(deps) {
|
|
|
10793
10863
|
latencyMode: turn.latencyMode
|
|
10794
10864
|
}
|
|
10795
10865
|
);
|
|
10866
|
+
capabilitySettings = { ...capabilitySettings, openaiMaxRetries: 0 };
|
|
10796
10867
|
runtime.configure(capabilitySettings);
|
|
10797
10868
|
const verifiedExecutionPolicy = assertTurnExecutionPolicyMatchesConfigV1(
|
|
10798
10869
|
capabilitySettings,
|
|
@@ -10804,6 +10875,10 @@ async function claimTurnAttempt(deps) {
|
|
|
10804
10875
|
}
|
|
10805
10876
|
);
|
|
10806
10877
|
const turnExecutionPolicy = verifiedExecutionPolicy.policy;
|
|
10878
|
+
attempt.modelMetricRoute = {
|
|
10879
|
+
provider: turnExecutionPolicy.providerId,
|
|
10880
|
+
model: turnExecutionPolicy.productModelId
|
|
10881
|
+
};
|
|
10807
10882
|
assertSessionAllowsProductModel(session, turnExecutionPolicy.productModelId);
|
|
10808
10883
|
const billingIdentity = turnExecutionPolicyBillingIdentity(turnExecutionPolicy);
|
|
10809
10884
|
billingState.isExternallyBilledTurn = billingIdentity.externallyBilled;
|
|
@@ -12822,6 +12897,18 @@ async function prepareCompaction(deps) {
|
|
|
12822
12897
|
await publishDurableSessionEvents6(bus, input.workspaceId, input.sessionId, events);
|
|
12823
12898
|
};
|
|
12824
12899
|
const publishCompactionOutcomeEvents = async (events) => {
|
|
12900
|
+
if (events.some((event) => event.type === "session.context.compacted")) {
|
|
12901
|
+
attempt.providerRecoveryCount = 0;
|
|
12902
|
+
if (attempt.providerRecoveryObservation) {
|
|
12903
|
+
recordProviderRecoveryOutcome(observability, {
|
|
12904
|
+
route: attempt.modelMetricRoute,
|
|
12905
|
+
cause: attempt.providerRecoveryObservation.cause,
|
|
12906
|
+
outcome: "recovered",
|
|
12907
|
+
elapsedMs: Date.now() - attempt.providerRecoveryObservation.startedAt
|
|
12908
|
+
});
|
|
12909
|
+
attempt.providerRecoveryObservation = void 0;
|
|
12910
|
+
}
|
|
12911
|
+
}
|
|
12825
12912
|
await publishDurableSessionEvents6(
|
|
12826
12913
|
bus,
|
|
12827
12914
|
input.workspaceId,
|
|
@@ -33172,6 +33259,7 @@ import {
|
|
|
33172
33259
|
import { SandboxChannelAService as SandboxChannelAService3 } from "@opengeni/runtime/sandbox";
|
|
33173
33260
|
import { sandboxRunAs as sandboxRunAs4 } from "@opengeni/runtime";
|
|
33174
33261
|
import {
|
|
33262
|
+
bundledSkillSelectionForAgentConfig,
|
|
33175
33263
|
DEFAULT_FIRST_PARTY_MCP_PERMISSIONS as DEFAULT_FIRST_PARTY_MCP_PERMISSIONS2,
|
|
33176
33264
|
resolveAgentToolFamilies
|
|
33177
33265
|
} from "@opengeni/contracts";
|
|
@@ -34928,7 +35016,9 @@ async function prepareTurnToolRuntime(deps) {
|
|
|
34928
35016
|
session.firstPartyMcpPermissions,
|
|
34929
35017
|
linkedAuthority
|
|
34930
35018
|
);
|
|
34931
|
-
const toolFamilies = resolveAgentToolFamilies(session.agent
|
|
35019
|
+
const toolFamilies = resolveAgentToolFamilies(session.agent, {
|
|
35020
|
+
sandboxAttached: (activeSandboxBackend ?? groupBoxBackend) !== "none"
|
|
35021
|
+
});
|
|
34932
35022
|
const selectedFirstPartyMcpTools = toolFamilies.firstPartyTools(
|
|
34933
35023
|
allowedFirstPartyMcpToolsForSession(runSettings, session.firstPartyMcpTools)
|
|
34934
35024
|
);
|
|
@@ -34988,7 +35078,9 @@ async function prepareTurnToolRuntime(deps) {
|
|
|
34988
35078
|
})
|
|
34989
35079
|
]);
|
|
34990
35080
|
const bundledSkills = loadConfiguredBundledSkills({
|
|
34991
|
-
|
|
35081
|
+
// Rows that could not freeze the "none" default at create (scheduled
|
|
35082
|
+
// generated sessions, pre-existing rows) get the same rule here.
|
|
35083
|
+
bundledSkillIds: bundledSkillSelectionForAgentConfig(session.bundledSkillIds, session.agent),
|
|
34992
35084
|
firstPartyTools: selectedFirstPartyMcpTools,
|
|
34993
35085
|
videoGenerationEnabled: skillConfiguration.defaultModelId !== null && skillConfiguration.enabledModelIds.length > 0
|
|
34994
35086
|
});
|
|
@@ -40351,4 +40443,4 @@ export {
|
|
|
40351
40443
|
createTurnActivities,
|
|
40352
40444
|
createTurnActivitiesFromServices
|
|
40353
40445
|
};
|
|
40354
|
-
//# sourceMappingURL=activities-turn-
|
|
40446
|
+
//# sourceMappingURL=activities-turn-4EEVNZCC.js.map
|