@opengeni/worker-bundle 1.2.1-canary.37222965366001 → 1.4.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/errors.d.ts +1 -13
- package/dist/activities/agent-turn/subscription-lease.d.ts +1 -0
- package/dist/activities/agent-turn/tool-policy.d.ts +10 -1
- package/dist/activities/agent-turn/web-search.d.ts +33 -0
- package/dist/activities/codemode-dispatcher.d.ts +6 -2
- package/dist/activities/open-suffix-resume.d.ts +2 -0
- package/dist/activities/programmatic-approvals.d.ts +27 -0
- package/dist/activities/run-input.d.ts +2 -0
- package/dist/{activities-control-QSDPXLLD.js → activities-control-D5KVEPHI.js} +3 -3
- package/dist/{activities-turn-BMY3CDKL.js → activities-turn-4Z3M7Z3F.js} +554 -113
- package/dist/activities-turn-4Z3M7Z3F.js.map +1 -0
- package/dist/{chunk-JKMG5ZHH.js → chunk-BMTWULF7.js} +115 -31
- package/dist/chunk-BMTWULF7.js.map +1 -0
- package/dist/{chunk-XONQEVAD.js → chunk-FF4HPY7L.js} +1 -1
- package/dist/chunk-FF4HPY7L.js.map +1 -0
- package/dist/index.js +2 -2
- package/dist/observability-metrics.d.ts +1 -1
- package/package.json +21 -21
- package/src/activities/agent-turn/agent-build.ts +6 -4
- package/src/activities/agent-turn/errors.ts +82 -3
- package/src/activities/agent-turn/governance-model.ts +8 -8
- package/src/activities/agent-turn/sandbox-runtime.ts +16 -0
- package/src/activities/agent-turn/stream-attempt.ts +100 -21
- package/src/activities/agent-turn/subscription-lease.ts +10 -1
- package/src/activities/agent-turn/tool-environment.ts +20 -0
- package/src/activities/agent-turn/tool-policy.ts +26 -5
- package/src/activities/agent-turn/web-search.ts +252 -0
- package/src/activities/codemode-dispatcher.ts +145 -7
- package/src/activities/connector-attachments.ts +3 -1
- package/src/activities/open-suffix-resume.ts +107 -86
- package/src/activities/programmatic-approvals.ts +52 -0
- package/src/activities/run-input.ts +4 -1
- package/src/activity-services.ts +8 -0
- package/src/observability-metrics.ts +1 -0
- package/src/sandbox-routing.ts +58 -24
- package/dist/activities-turn-BMY3CDKL.js.map +0 -1
- package/dist/chunk-JKMG5ZHH.js.map +0 -1
- package/dist/chunk-XONQEVAD.js.map +0 -1
- /package/dist/{activities-control-QSDPXLLD.js.map → activities-control-D5KVEPHI.js.map} +0 -0
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
observabilityEventBusOptions
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-FF4HPY7L.js";
|
|
4
4
|
|
|
5
5
|
// src/activity-services.ts
|
|
6
6
|
import {
|
|
7
7
|
codeSearchDeploymentPolicy,
|
|
8
|
+
resolveWebSearchProvider,
|
|
8
9
|
dbSearchPath,
|
|
9
10
|
getSettings,
|
|
10
11
|
resolveNatsControlPlaneAuth
|
|
@@ -413,6 +414,12 @@ function createSharedActivityServices(dependencies) {
|
|
|
413
414
|
const resolvedSettings = (await resolveCatalogSettings(db, settings)).settings;
|
|
414
415
|
configureChildLifecycleNotices({ enabled: settings.childLifecycleNoticesEnabled });
|
|
415
416
|
configureCodeSearchDeploymentPolicy(codeSearchDeploymentPolicy(settings));
|
|
417
|
+
const webSearchProvider = resolveWebSearchProvider(settings);
|
|
418
|
+
if (webSearchProvider.status === "invalid") {
|
|
419
|
+
observability.warn("web search provider is misconfigured; web_search stays off", {
|
|
420
|
+
reason: webSearchProvider.reason
|
|
421
|
+
});
|
|
422
|
+
}
|
|
416
423
|
return {
|
|
417
424
|
settings: resolvedSettings,
|
|
418
425
|
catalogSourceSettings: settings,
|
|
@@ -4990,7 +4997,8 @@ import {
|
|
|
4990
4997
|
readLease as readLease2,
|
|
4991
4998
|
readActiveSandbox,
|
|
4992
4999
|
resolvePersonalMachineConnectionForAttempt,
|
|
4993
|
-
SandboxRetainedProcessPromotionFencedError
|
|
5000
|
+
SandboxRetainedProcessPromotionFencedError,
|
|
5001
|
+
SandboxWorkspaceMutationOutputRejectedError
|
|
4994
5002
|
} from "@opengeni/db";
|
|
4995
5003
|
import {
|
|
4996
5004
|
observeSessionBackgroundCommandCompletion,
|
|
@@ -5008,6 +5016,7 @@ import {
|
|
|
5008
5016
|
NatsOpStreamTransport,
|
|
5009
5017
|
RoutingBackendRecoveryRequiredError,
|
|
5010
5018
|
RoutingSandboxSession,
|
|
5019
|
+
RoutingMutationOutputRejectedError,
|
|
5011
5020
|
resolveModalCheckpointProviderBindingForSession as resolveModalCheckpointProviderBindingForSession2,
|
|
5012
5021
|
resolveConnectedMachineWorkspaceRoot,
|
|
5013
5022
|
sandboxProviderInstanceIdFromEnvelope,
|
|
@@ -6655,21 +6664,34 @@ function afterPersistableHomeMutation(services, ids, home) {
|
|
|
6655
6664
|
}
|
|
6656
6665
|
if (outcome === "outcome_unknown")
|
|
6657
6666
|
throw new Error("Outcome-unknown command settlement requires its exact retained invocation");
|
|
6658
|
-
|
|
6659
|
-
|
|
6660
|
-
|
|
6661
|
-
|
|
6662
|
-
|
|
6663
|
-
|
|
6664
|
-
|
|
6665
|
-
|
|
6666
|
-
|
|
6667
|
-
|
|
6668
|
-
|
|
6669
|
-
|
|
6670
|
-
|
|
6671
|
-
|
|
6672
|
-
|
|
6667
|
+
try {
|
|
6668
|
+
await verifyWorkspaceMutationSettlement(services.db, {
|
|
6669
|
+
accountId: fence.accountId,
|
|
6670
|
+
workspaceId: ids.workspaceId,
|
|
6671
|
+
sessionId: ids.sessionId,
|
|
6672
|
+
turnId: fence.turnId,
|
|
6673
|
+
executionGeneration: fence.executionGeneration,
|
|
6674
|
+
attemptId: fence.attemptId,
|
|
6675
|
+
holderId: sandboxLeaseHolderIdForAttempt(fence.attemptId),
|
|
6676
|
+
sandboxGroupId: home.sandboxGroupId,
|
|
6677
|
+
expectedEpoch: backend.leaseEpoch,
|
|
6678
|
+
expectedInstanceId: backend.providerInstanceId,
|
|
6679
|
+
admission: exactAdmission,
|
|
6680
|
+
operation: op,
|
|
6681
|
+
outcome
|
|
6682
|
+
});
|
|
6683
|
+
} catch (error) {
|
|
6684
|
+
if (error instanceof SandboxWorkspaceMutationOutputRejectedError && error.matchesPhysicalSettlement({
|
|
6685
|
+
accountId: fence.accountId,
|
|
6686
|
+
workspaceId: ids.workspaceId,
|
|
6687
|
+
admission: exactAdmission,
|
|
6688
|
+
operation: op,
|
|
6689
|
+
outcome
|
|
6690
|
+
})) {
|
|
6691
|
+
throw new RoutingMutationOutputRejectedError(op, error.code, { cause: error });
|
|
6692
|
+
}
|
|
6693
|
+
throw error;
|
|
6694
|
+
}
|
|
6673
6695
|
};
|
|
6674
6696
|
}
|
|
6675
6697
|
function beforeRetainedProcessMutation(services, ids) {
|
|
@@ -6692,15 +6714,28 @@ function afterRetainedProcessMutation(services, ids) {
|
|
|
6692
6714
|
if (!admission || typeof admission !== "object" || typeof admission.id !== "string" || typeof admission.workspaceGeneration !== "number") {
|
|
6693
6715
|
throw new Error("Retained-process mutation settlement lacked its exact admission");
|
|
6694
6716
|
}
|
|
6695
|
-
|
|
6696
|
-
|
|
6697
|
-
|
|
6698
|
-
|
|
6699
|
-
|
|
6700
|
-
|
|
6701
|
-
|
|
6702
|
-
|
|
6703
|
-
|
|
6717
|
+
try {
|
|
6718
|
+
await verifyRetainedProcessMutationSettlement(services.db, {
|
|
6719
|
+
accountId: fence.accountId,
|
|
6720
|
+
workspaceId: ids.workspaceId,
|
|
6721
|
+
sessionId: ids.sessionId,
|
|
6722
|
+
processId: process2.id,
|
|
6723
|
+
admission,
|
|
6724
|
+
operation: op,
|
|
6725
|
+
outcome
|
|
6726
|
+
});
|
|
6727
|
+
} catch (error) {
|
|
6728
|
+
if (error instanceof SandboxWorkspaceMutationOutputRejectedError && error.matchesPhysicalSettlement({
|
|
6729
|
+
accountId: fence.accountId,
|
|
6730
|
+
workspaceId: ids.workspaceId,
|
|
6731
|
+
admission,
|
|
6732
|
+
operation: op,
|
|
6733
|
+
outcome
|
|
6734
|
+
})) {
|
|
6735
|
+
throw new RoutingMutationOutputRejectedError(op, error.code, { cause: error });
|
|
6736
|
+
}
|
|
6737
|
+
throw error;
|
|
6738
|
+
}
|
|
6704
6739
|
};
|
|
6705
6740
|
}
|
|
6706
6741
|
function captureConnectedCommandOutput(db, ids, bus) {
|
|
@@ -9101,8 +9136,12 @@ import {
|
|
|
9101
9136
|
isModalTaskExecStartPreDispatchUnavailableError,
|
|
9102
9137
|
isModalCommandStartOutcomeUnknownError,
|
|
9103
9138
|
isProviderCommandObservationUnavailableError,
|
|
9139
|
+
ProviderCommandInputOutcomeUnknownError,
|
|
9140
|
+
ProviderCommandStartOutcomeUnknownError,
|
|
9104
9141
|
isRoutingMutationOutcomeUnknownError,
|
|
9142
|
+
isRoutingMutationOutputRejectedError,
|
|
9105
9143
|
RoutingWorkspaceRootChangedError,
|
|
9144
|
+
RoutingBackendRecoveryRequiredError as RoutingBackendRecoveryRequiredError2,
|
|
9106
9145
|
ResponsesStreamingTerminalError,
|
|
9107
9146
|
SandboxMaterializationVerificationError,
|
|
9108
9147
|
materializationVerificationDiagnostic,
|
|
@@ -9424,6 +9463,7 @@ async function turnInput(db, runtime, agent, trigger, options) {
|
|
|
9424
9463
|
options.unavailableSandboxFilesNote,
|
|
9425
9464
|
options.runCredentialsNote,
|
|
9426
9465
|
options.mcpAvailabilityNote,
|
|
9466
|
+
options.codemodeContinuationNote,
|
|
9427
9467
|
options.knowledgeSourcePreparationNote
|
|
9428
9468
|
);
|
|
9429
9469
|
if (trigger.type === "user.message") {
|
|
@@ -9497,7 +9537,7 @@ async function openSuffixMessageInput(db, runtime, agent, trigger, internalConte
|
|
|
9497
9537
|
trigger.sessionId,
|
|
9498
9538
|
options.turnId
|
|
9499
9539
|
);
|
|
9500
|
-
if (suffixRows.length === 0) {
|
|
9540
|
+
if (suffixRows.length === 0 && !options.programmaticApprovalAcknowledged) {
|
|
9501
9541
|
throw new Error("Open suffix resume has no interruption rows");
|
|
9502
9542
|
}
|
|
9503
9543
|
if (suffixRows.some((row) => row.resultItem == null)) {
|
|
@@ -9899,7 +9939,7 @@ function preClaimAdmissionFailure(error) {
|
|
|
9899
9939
|
details: [detail]
|
|
9900
9940
|
});
|
|
9901
9941
|
}
|
|
9902
|
-
function
|
|
9942
|
+
function structuredRecoveryCauseGraph(error) {
|
|
9903
9943
|
const graph = /* @__PURE__ */ new Map();
|
|
9904
9944
|
const queue = [];
|
|
9905
9945
|
let links = 0;
|
|
@@ -9927,7 +9967,7 @@ function databaseRecoveryCauseGraph(error) {
|
|
|
9927
9967
|
}
|
|
9928
9968
|
function retryableDatabaseFailureCode(error, requireDatabaseProvenance = false) {
|
|
9929
9969
|
try {
|
|
9930
|
-
const graph =
|
|
9970
|
+
const graph = structuredRecoveryCauseGraph(error);
|
|
9931
9971
|
if (!graph) return null;
|
|
9932
9972
|
const transports = /* @__PURE__ */ new Set();
|
|
9933
9973
|
const boundaries = /* @__PURE__ */ new Set();
|
|
@@ -9939,7 +9979,8 @@ function retryableDatabaseFailureCode(error, requireDatabaseProvenance = false)
|
|
|
9939
9979
|
[...graph.get(node)].filter((child) => child === node.cause)
|
|
9940
9980
|
) : [...graph.get(node)];
|
|
9941
9981
|
for (const node of graph.keys()) {
|
|
9942
|
-
if (isRoutingMutationOutcomeUnknownError(node)
|
|
9982
|
+
if (isRoutingMutationOutcomeUnknownError(node) || isRoutingMutationOutputRejectedError(node))
|
|
9983
|
+
return null;
|
|
9943
9984
|
const record = node;
|
|
9944
9985
|
if (requireDatabaseProvenance ? isRunningTurnDatabaseTransportFailure(record) : isRetryableDatabaseTransportFailure({ code: record.code, errno: record.errno }))
|
|
9945
9986
|
transports.add(node);
|
|
@@ -10094,7 +10135,29 @@ function modelPreparationFailureEventPayload(error, durationMs) {
|
|
|
10094
10135
|
} : {}
|
|
10095
10136
|
};
|
|
10096
10137
|
}
|
|
10138
|
+
function isPreDispatchHomeBackendRecoveryRequired(error) {
|
|
10139
|
+
const graph = structuredRecoveryCauseGraph(error);
|
|
10140
|
+
if (!graph) return false;
|
|
10141
|
+
let found = false;
|
|
10142
|
+
try {
|
|
10143
|
+
for (const node of graph.keys()) {
|
|
10144
|
+
if (isRoutingMutationOutcomeUnknownError(node) || isRoutingMutationOutputRejectedError(node) || isRawProviderCommandOutcomeUnknown(node) || isModalCommandStartOutcomeUnknownError(node) || isProviderCommandObservationUnavailableError(node))
|
|
10145
|
+
return false;
|
|
10146
|
+
if (node instanceof RoutingBackendRecoveryRequiredError2) {
|
|
10147
|
+
if (node.op !== "resolve_home_backend" || !Number.isSafeInteger(node.leaseEpoch) || node.leaseEpoch < 0 || !node.retryable || node.recovery !== "pending" && node.recovery !== "superseded")
|
|
10148
|
+
return false;
|
|
10149
|
+
found = true;
|
|
10150
|
+
}
|
|
10151
|
+
}
|
|
10152
|
+
} catch {
|
|
10153
|
+
return false;
|
|
10154
|
+
}
|
|
10155
|
+
return found;
|
|
10156
|
+
}
|
|
10097
10157
|
function sandboxRouteTransitionCode(error) {
|
|
10158
|
+
if (isPreDispatchHomeBackendRecoveryRequired(error)) {
|
|
10159
|
+
return "home_backend_recovery_pending";
|
|
10160
|
+
}
|
|
10098
10161
|
const pending = [error];
|
|
10099
10162
|
const seen = /* @__PURE__ */ new WeakSet();
|
|
10100
10163
|
let inspected = 0;
|
|
@@ -10384,7 +10447,28 @@ function anthropicRequestDiagnostic(error) {
|
|
|
10384
10447
|
if (error instanceof AnthropicRequestError) return error;
|
|
10385
10448
|
return error instanceof Error && error.cause instanceof AnthropicRequestError ? error.cause : void 0;
|
|
10386
10449
|
}
|
|
10450
|
+
function isRawProviderCommandOutcomeUnknown(error) {
|
|
10451
|
+
try {
|
|
10452
|
+
return error instanceof ProviderCommandInputOutcomeUnknownError || error instanceof ProviderCommandStartOutcomeUnknownError;
|
|
10453
|
+
} catch {
|
|
10454
|
+
return false;
|
|
10455
|
+
}
|
|
10456
|
+
}
|
|
10387
10457
|
function agentRunFailurePayload(error, options = {}) {
|
|
10458
|
+
const graph = structuredRecoveryCauseGraph(error);
|
|
10459
|
+
const nodes = graph ? [...graph.keys()] : [];
|
|
10460
|
+
const outputRejected = nodes.find(isRoutingMutationOutputRejectedError);
|
|
10461
|
+
if (outputRejected) {
|
|
10462
|
+
const unknown = nodes.find(
|
|
10463
|
+
(node) => isRoutingMutationOutcomeUnknownError(node) || isModalCommandStartOutcomeUnknownError(node) || isProviderCommandObservationUnavailableError(node) || isRawProviderCommandOutcomeUnknown(node)
|
|
10464
|
+
);
|
|
10465
|
+
if (unknown) return { ...baseAgentRunFailurePayload(unknown, options), retryable: false };
|
|
10466
|
+
return {
|
|
10467
|
+
error: outputRejected.message,
|
|
10468
|
+
code: outputRejected.code,
|
|
10469
|
+
retryable: false
|
|
10470
|
+
};
|
|
10471
|
+
}
|
|
10388
10472
|
const failure = baseAgentRunFailurePayload(error, options);
|
|
10389
10473
|
const diagnostic = materializationVerificationDiagnostic(error);
|
|
10390
10474
|
const anthropic = anthropicRequestDiagnostic(error);
|
|
@@ -10925,4 +11009,4 @@ export {
|
|
|
10925
11009
|
CODEX_USAGE_LIMIT_MAX_RESUME_MS,
|
|
10926
11010
|
classifyClaudeCredentialFailure
|
|
10927
11011
|
};
|
|
10928
|
-
//# sourceMappingURL=chunk-
|
|
11012
|
+
//# sourceMappingURL=chunk-BMTWULF7.js.map
|