@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
|
@@ -24,3 +24,29 @@ export function programmaticContinuationNote(
|
|
|
24
24
|
"Approval resumes the stored operation, not the earlier program's JavaScript stack. Read results with the current Codemode client's status/resume handle. Do not resubmit arguments for completed, running, waiting, or uncertain operations.",
|
|
25
25
|
].join("\n");
|
|
26
26
|
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Recover committed programmatic approval waits/results before the first model
|
|
30
|
+
* request without turning lazy MCP preparation into a first-request barrier.
|
|
31
|
+
*
|
|
32
|
+
* Only eager servers may gate the first request. Resuming a stored operation
|
|
33
|
+
* needs the prepared attempt tool environment, so this waits for full tool
|
|
34
|
+
* preparation only when there is something to resume: an approval decision
|
|
35
|
+
* trigger, or a cheap durable read showing unfinished operations for this
|
|
36
|
+
* logical turn (which covers every recovery that has stored work). Every other
|
|
37
|
+
* turn sends its first request without waiting on any lazy server.
|
|
38
|
+
*/
|
|
39
|
+
export async function recoverProgrammaticOperationsBeforeFirstRequest(input: {
|
|
40
|
+
approvalDecisionId: string | undefined;
|
|
41
|
+
hasUnfinishedOperations: () => Promise<boolean>;
|
|
42
|
+
toolPreparationReady: Promise<void> | null;
|
|
43
|
+
resumeApproved: (
|
|
44
|
+
decisionOperationId: string | undefined,
|
|
45
|
+
) => Promise<CodemodeOperation[]> | undefined;
|
|
46
|
+
}): Promise<CodemodeOperation[]> {
|
|
47
|
+
if (input.approvalDecisionId === undefined && !(await input.hasUnfinishedOperations())) {
|
|
48
|
+
return [];
|
|
49
|
+
}
|
|
50
|
+
await input.toolPreparationReady;
|
|
51
|
+
return (await input.resumeApproved(input.approvalDecisionId)) ?? [];
|
|
52
|
+
}
|
package/src/activity-services.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
codeSearchDeploymentPolicy,
|
|
3
|
+
resolveWebSearchProvider,
|
|
3
4
|
dbSearchPath,
|
|
4
5
|
getSettings,
|
|
5
6
|
resolveNatsControlPlaneAuth,
|
|
@@ -52,6 +53,13 @@ export function createSharedActivityServices(
|
|
|
52
53
|
// Child, scheduled and automation sessions created here freeze their
|
|
53
54
|
// code_search decision from the same deployment policy as the API.
|
|
54
55
|
configureCodeSearchDeploymentPolicy(codeSearchDeploymentPolicy(settings));
|
|
56
|
+
// A named but unusable web search provider withholds the tools; say why.
|
|
57
|
+
const webSearchProvider = resolveWebSearchProvider(settings);
|
|
58
|
+
if (webSearchProvider.status === "invalid") {
|
|
59
|
+
observability.warn("web search provider is misconfigured; web_search stays off", {
|
|
60
|
+
reason: webSearchProvider.reason,
|
|
61
|
+
});
|
|
62
|
+
}
|
|
55
63
|
return {
|
|
56
64
|
settings: resolvedSettings,
|
|
57
65
|
catalogSourceSettings: settings,
|
|
@@ -1629,6 +1629,7 @@ export type TurnStartupPhase =
|
|
|
1629
1629
|
| "post_tool_preparation"
|
|
1630
1630
|
| "agent_construction"
|
|
1631
1631
|
| "post_agent_preparation"
|
|
1632
|
+
| "programmatic_operation_recovery"
|
|
1632
1633
|
| "file_materialization"
|
|
1633
1634
|
| "history_preparation"
|
|
1634
1635
|
| "history_system_update_load"
|
package/src/sandbox-routing.ts
CHANGED
|
@@ -40,6 +40,7 @@ import {
|
|
|
40
40
|
readActiveSandbox,
|
|
41
41
|
resolvePersonalMachineConnectionForAttempt,
|
|
42
42
|
SandboxRetainedProcessPromotionFencedError,
|
|
43
|
+
SandboxWorkspaceMutationOutputRejectedError,
|
|
43
44
|
type Database,
|
|
44
45
|
type EnrollmentRecord,
|
|
45
46
|
type SandboxWorkspaceMutationAdmission,
|
|
@@ -63,6 +64,7 @@ import {
|
|
|
63
64
|
NatsOpStreamTransport,
|
|
64
65
|
RoutingBackendRecoveryRequiredError,
|
|
65
66
|
RoutingSandboxSession,
|
|
67
|
+
RoutingMutationOutputRejectedError,
|
|
66
68
|
resolveModalCheckpointProviderBindingForSession,
|
|
67
69
|
resolveConnectedMachineWorkspaceRoot,
|
|
68
70
|
sandboxProviderInstanceIdFromEnvelope,
|
|
@@ -594,21 +596,37 @@ function afterPersistableHomeMutation(
|
|
|
594
596
|
}
|
|
595
597
|
if (outcome === "outcome_unknown")
|
|
596
598
|
throw new Error("Outcome-unknown command settlement requires its exact retained invocation");
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
599
|
+
try {
|
|
600
|
+
await verifyWorkspaceMutationSettlement(services.db, {
|
|
601
|
+
accountId: fence.accountId,
|
|
602
|
+
workspaceId: ids.workspaceId,
|
|
603
|
+
sessionId: ids.sessionId,
|
|
604
|
+
turnId: fence.turnId,
|
|
605
|
+
executionGeneration: fence.executionGeneration,
|
|
606
|
+
attemptId: fence.attemptId,
|
|
607
|
+
holderId: sandboxLeaseHolderIdForAttempt(fence.attemptId),
|
|
608
|
+
sandboxGroupId: home.sandboxGroupId,
|
|
609
|
+
expectedEpoch: backend.leaseEpoch,
|
|
610
|
+
expectedInstanceId: backend.providerInstanceId,
|
|
611
|
+
admission: exactAdmission,
|
|
612
|
+
operation: op,
|
|
613
|
+
outcome,
|
|
614
|
+
});
|
|
615
|
+
} catch (error) {
|
|
616
|
+
if (
|
|
617
|
+
error instanceof SandboxWorkspaceMutationOutputRejectedError &&
|
|
618
|
+
error.matchesPhysicalSettlement({
|
|
619
|
+
accountId: fence.accountId,
|
|
620
|
+
workspaceId: ids.workspaceId,
|
|
621
|
+
admission: exactAdmission,
|
|
622
|
+
operation: op,
|
|
623
|
+
outcome,
|
|
624
|
+
})
|
|
625
|
+
) {
|
|
626
|
+
throw new RoutingMutationOutputRejectedError(op, error.code, { cause: error });
|
|
627
|
+
}
|
|
628
|
+
throw error;
|
|
629
|
+
}
|
|
612
630
|
};
|
|
613
631
|
}
|
|
614
632
|
|
|
@@ -661,15 +679,31 @@ function afterRetainedProcessMutation(
|
|
|
661
679
|
) {
|
|
662
680
|
throw new Error("Retained-process mutation settlement lacked its exact admission");
|
|
663
681
|
}
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
682
|
+
try {
|
|
683
|
+
await verifyRetainedProcessMutationSettlement(services.db, {
|
|
684
|
+
accountId: fence.accountId,
|
|
685
|
+
workspaceId: ids.workspaceId,
|
|
686
|
+
sessionId: ids.sessionId,
|
|
687
|
+
processId: process.id,
|
|
688
|
+
admission: admission as SandboxWorkspaceMutationAdmission,
|
|
689
|
+
operation: op,
|
|
690
|
+
outcome,
|
|
691
|
+
});
|
|
692
|
+
} catch (error) {
|
|
693
|
+
if (
|
|
694
|
+
error instanceof SandboxWorkspaceMutationOutputRejectedError &&
|
|
695
|
+
error.matchesPhysicalSettlement({
|
|
696
|
+
accountId: fence.accountId,
|
|
697
|
+
workspaceId: ids.workspaceId,
|
|
698
|
+
admission: admission as SandboxWorkspaceMutationAdmission,
|
|
699
|
+
operation: op,
|
|
700
|
+
outcome,
|
|
701
|
+
})
|
|
702
|
+
) {
|
|
703
|
+
throw new RoutingMutationOutputRejectedError(op, error.code, { cause: error });
|
|
704
|
+
}
|
|
705
|
+
throw error;
|
|
706
|
+
}
|
|
673
707
|
};
|
|
674
708
|
}
|
|
675
709
|
|