@opengeni/worker-bundle 1.3.0 → 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/programmatic-approvals.d.ts +17 -0
- package/dist/{activities-control-PEXBWKQJ.js → activities-control-D5KVEPHI.js} +3 -3
- package/dist/{activities-turn-W27A2SBO.js → activities-turn-4Z3M7Z3F.js} +288 -23
- package/dist/activities-turn-4Z3M7Z3F.js.map +1 -0
- package/dist/{chunk-QUX5LT2B.js → chunk-BMTWULF7.js} +113 -30
- 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 +4 -2
- 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 +40 -6
- package/src/activities/agent-turn/subscription-lease.ts +10 -1
- package/src/activities/agent-turn/tool-environment.ts +19 -0
- package/src/activities/agent-turn/tool-policy.ts +25 -0
- package/src/activities/agent-turn/web-search.ts +252 -0
- package/src/activities/connector-attachments.ts +3 -1
- package/src/activities/programmatic-approvals.ts +26 -0
- 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-W27A2SBO.js.map +0 -1
- package/dist/chunk-QUX5LT2B.js.map +0 -1
- package/dist/chunk-XONQEVAD.js.map +0 -1
- /package/dist/{activities-control-PEXBWKQJ.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,
|
|
@@ -9900,7 +9939,7 @@ function preClaimAdmissionFailure(error) {
|
|
|
9900
9939
|
details: [detail]
|
|
9901
9940
|
});
|
|
9902
9941
|
}
|
|
9903
|
-
function
|
|
9942
|
+
function structuredRecoveryCauseGraph(error) {
|
|
9904
9943
|
const graph = /* @__PURE__ */ new Map();
|
|
9905
9944
|
const queue = [];
|
|
9906
9945
|
let links = 0;
|
|
@@ -9928,7 +9967,7 @@ function databaseRecoveryCauseGraph(error) {
|
|
|
9928
9967
|
}
|
|
9929
9968
|
function retryableDatabaseFailureCode(error, requireDatabaseProvenance = false) {
|
|
9930
9969
|
try {
|
|
9931
|
-
const graph =
|
|
9970
|
+
const graph = structuredRecoveryCauseGraph(error);
|
|
9932
9971
|
if (!graph) return null;
|
|
9933
9972
|
const transports = /* @__PURE__ */ new Set();
|
|
9934
9973
|
const boundaries = /* @__PURE__ */ new Set();
|
|
@@ -9940,7 +9979,8 @@ function retryableDatabaseFailureCode(error, requireDatabaseProvenance = false)
|
|
|
9940
9979
|
[...graph.get(node)].filter((child) => child === node.cause)
|
|
9941
9980
|
) : [...graph.get(node)];
|
|
9942
9981
|
for (const node of graph.keys()) {
|
|
9943
|
-
if (isRoutingMutationOutcomeUnknownError(node)
|
|
9982
|
+
if (isRoutingMutationOutcomeUnknownError(node) || isRoutingMutationOutputRejectedError(node))
|
|
9983
|
+
return null;
|
|
9944
9984
|
const record = node;
|
|
9945
9985
|
if (requireDatabaseProvenance ? isRunningTurnDatabaseTransportFailure(record) : isRetryableDatabaseTransportFailure({ code: record.code, errno: record.errno }))
|
|
9946
9986
|
transports.add(node);
|
|
@@ -10095,7 +10135,29 @@ function modelPreparationFailureEventPayload(error, durationMs) {
|
|
|
10095
10135
|
} : {}
|
|
10096
10136
|
};
|
|
10097
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
|
+
}
|
|
10098
10157
|
function sandboxRouteTransitionCode(error) {
|
|
10158
|
+
if (isPreDispatchHomeBackendRecoveryRequired(error)) {
|
|
10159
|
+
return "home_backend_recovery_pending";
|
|
10160
|
+
}
|
|
10099
10161
|
const pending = [error];
|
|
10100
10162
|
const seen = /* @__PURE__ */ new WeakSet();
|
|
10101
10163
|
let inspected = 0;
|
|
@@ -10385,7 +10447,28 @@ function anthropicRequestDiagnostic(error) {
|
|
|
10385
10447
|
if (error instanceof AnthropicRequestError) return error;
|
|
10386
10448
|
return error instanceof Error && error.cause instanceof AnthropicRequestError ? error.cause : void 0;
|
|
10387
10449
|
}
|
|
10450
|
+
function isRawProviderCommandOutcomeUnknown(error) {
|
|
10451
|
+
try {
|
|
10452
|
+
return error instanceof ProviderCommandInputOutcomeUnknownError || error instanceof ProviderCommandStartOutcomeUnknownError;
|
|
10453
|
+
} catch {
|
|
10454
|
+
return false;
|
|
10455
|
+
}
|
|
10456
|
+
}
|
|
10388
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
|
+
}
|
|
10389
10472
|
const failure = baseAgentRunFailurePayload(error, options);
|
|
10390
10473
|
const diagnostic = materializationVerificationDiagnostic(error);
|
|
10391
10474
|
const anthropic = anthropicRequestDiagnostic(error);
|
|
@@ -10926,4 +11009,4 @@ export {
|
|
|
10926
11009
|
CODEX_USAGE_LIMIT_MAX_RESUME_MS,
|
|
10927
11010
|
classifyClaudeCredentialFailure
|
|
10928
11011
|
};
|
|
10929
|
-
//# sourceMappingURL=chunk-
|
|
11012
|
+
//# sourceMappingURL=chunk-BMTWULF7.js.map
|