@opengeni/worker-bundle 1.4.0 → 1.4.4
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 +6 -0
- package/dist/activities/agent-turn/sandbox-provision.d.ts +22 -0
- package/dist/activities/agent-turn/turn-context.d.ts +6 -0
- package/dist/activities/agent-turn/web-search.d.ts +5 -1
- package/dist/activities/codemode-dispatcher.d.ts +8 -0
- package/dist/activities/programmatic-approvals.d.ts +0 -17
- package/dist/activities/sandbox-lease.d.ts +9 -0
- package/dist/{activities-control-D5KVEPHI.js → activities-control-VRFS65FT.js} +59 -13
- package/dist/activities-control-VRFS65FT.js.map +1 -0
- package/dist/{activities-turn-4Z3M7Z3F.js → activities-turn-P2YAW2QW.js} +6038 -5890
- package/dist/activities-turn-P2YAW2QW.js.map +1 -0
- package/dist/{chunk-BMTWULF7.js → chunk-BICGFGO7.js} +92 -17
- package/dist/chunk-BICGFGO7.js.map +1 -0
- package/dist/{chunk-FF4HPY7L.js → chunk-HVNNCWEU.js} +108 -3
- package/dist/chunk-HVNNCWEU.js.map +1 -0
- package/dist/index.js +2 -2
- package/dist/observability-metrics.d.ts +52 -14
- package/dist/sandbox-resume.d.ts +3 -0
- package/package.json +21 -21
- package/src/activities/agent-turn/errors.ts +61 -7
- package/src/activities/agent-turn/finalization.ts +16 -0
- package/src/activities/agent-turn/run.ts +12 -0
- package/src/activities/agent-turn/sandbox-establish.ts +87 -80
- package/src/activities/agent-turn/sandbox-provision.ts +51 -0
- package/src/activities/agent-turn/stream-attempt.ts +37 -50
- package/src/activities/agent-turn/turn-context.ts +8 -0
- package/src/activities/agent-turn/web-search.ts +135 -6
- package/src/activities/codemode-dispatcher.ts +57 -8
- package/src/activities/programmatic-approvals.ts +0 -26
- package/src/activities/sandbox-lease.ts +77 -10
- package/src/observability-metrics.ts +130 -18
- package/src/sandbox-resume.ts +24 -5
- package/src/sandbox-routing.ts +12 -0
- package/dist/activities-control-D5KVEPHI.js.map +0 -1
- package/dist/activities-turn-4Z3M7Z3F.js.map +0 -1
- package/dist/chunk-BMTWULF7.js.map +0 -1
- package/dist/chunk-FF4HPY7L.js.map +0 -1
|
@@ -246,6 +246,12 @@ export declare function collectErrorStrings(value: unknown, seen?: WeakSet<objec
|
|
|
246
246
|
*/
|
|
247
247
|
export declare const STATUSLESS_UPSTREAM_CONNECTIVITY_MESSAGE = "unable to connect. is the computer able to access the url?";
|
|
248
248
|
export declare function isExactStatuslessUpstreamConnectivityMessage(message: string): boolean;
|
|
249
|
+
/**
|
|
250
|
+
* A fetch-layer timeout: the runtime's DOMException `TimeoutError` (message
|
|
251
|
+
* "The operation timed out."), possibly wrapped by SDK/runner `cause` chains.
|
|
252
|
+
* Explicit cancellation (`AbortError`) is deliberately not matched.
|
|
253
|
+
*/
|
|
254
|
+
export declare function isTransportTimeoutError(error: unknown): boolean;
|
|
249
255
|
export declare function isTransientProviderError(error: unknown): boolean;
|
|
250
256
|
/**
|
|
251
257
|
* Recognize an exhausted API-key provider quota (a daily or monthly allowance,
|
|
@@ -48,6 +48,28 @@ export declare class SandboxDeadlineRotationError extends Error {
|
|
|
48
48
|
export declare function turnOperationCancellationFailure(error: unknown): CancelledFailure | null;
|
|
49
49
|
export declare function throwIfTurnOperationCancelled(signal: AbortSignal | undefined): void;
|
|
50
50
|
export declare function waitForTurnOperation<T>(operation: Promise<T>, signal: AbortSignal | undefined, disposeLateResult: ((result: T) => Promise<void> | void) | undefined): Promise<T>;
|
|
51
|
+
/**
|
|
52
|
+
* Upper bound for joining a cancelled attempt's in-flight provider establish.
|
|
53
|
+
* Worker shutdown cancels activities 5s after SIGTERM and force-stops 100s
|
|
54
|
+
* after it; this leaves room for the remaining finalization steps.
|
|
55
|
+
*/
|
|
56
|
+
export declare const PHYSICAL_SANDBOX_RESUME_DRAIN_TIMEOUT_MS = 60000;
|
|
57
|
+
/** Register the PHYSICAL lease acquire/provider establish promise, not the
|
|
58
|
+
* cancellable wrapper awaiting it. */
|
|
59
|
+
export declare function trackPhysicalSandboxResume<T>(inFlight: Set<Promise<unknown>>, operation: Promise<T>): Promise<T>;
|
|
60
|
+
/**
|
|
61
|
+
* Join every lease acquire/provider establish this attempt started, even after
|
|
62
|
+
* the turn-facing wrapper rejected on cancellation. An establish has no
|
|
63
|
+
* portable abort: after cancellation it still finishes its own exact cleanup
|
|
64
|
+
* (terminate an unpublished box and roll warming back to cold, or keep a
|
|
65
|
+
* published box and drop its holder). If the activity returned first, a
|
|
66
|
+
* shutting-down worker exited mid-cleanup and stranded a warming lease naming a
|
|
67
|
+
* terminated box; the replacement attempt then waited out the warming TTL and
|
|
68
|
+
* inherited a lost-workspace verdict. This wait is deliberately independent of
|
|
69
|
+
* the finalizer cancellation signal (cancellation is what started it) and is
|
|
70
|
+
* bounded so an uncooperative provider call cannot pin the activity.
|
|
71
|
+
*/
|
|
72
|
+
export declare function drainPhysicalSandboxResumes(inFlight: Set<Promise<unknown>>, timeoutMs?: number): Promise<"none" | "settled" | "timed_out">;
|
|
51
73
|
export declare function sleep(ms: number): Promise<void>;
|
|
52
74
|
export declare function sandboxProvisionErrorChain(error: unknown): unknown[];
|
|
53
75
|
export declare function firstProvisionError<T>(chain: readonly unknown[], constructor: abstract new (...args: never[]) => T): T | null;
|
|
@@ -78,6 +78,9 @@ export type SandboxRuntimeState = {
|
|
|
78
78
|
}>;
|
|
79
79
|
turnSandboxProvisioner: TurnSandboxProvisioner<ResumedTurnSandbox> | null;
|
|
80
80
|
resumeManagedGroupBox: (() => Promise<ResumedTurnSandbox>) | null;
|
|
81
|
+
/** Physical resumeBoxForTurn promises still running for this attempt; the
|
|
82
|
+
* finalizer joins them so a cancelled establish completes its own cleanup. */
|
|
83
|
+
inFlightSandboxResumes: Set<Promise<unknown>>;
|
|
81
84
|
prefetchedManagedBox: Promise<ResumedTurnSandbox> | null;
|
|
82
85
|
prefetchedManagedBoxResult: ResumedTurnSandbox | null;
|
|
83
86
|
setupBoxSession: unknown;
|
|
@@ -127,6 +130,9 @@ export type EventingState = {
|
|
|
127
130
|
firstModelRequestPreparationRecorded: boolean;
|
|
128
131
|
firstModelRequestCheckpointAt: number | null;
|
|
129
132
|
initialModelWireDispatch: InitialModelWireDispatchClock;
|
|
133
|
+
/** Diagnostic only: the current stream's timing hook for a native transport's
|
|
134
|
+
* literal provider dispatch. Never joins, fences or fails the request. */
|
|
135
|
+
providerDispatchObserver: (() => void) | null;
|
|
130
136
|
companyBrainContextContributions: readonly ModelContextContributionSummary[] | null;
|
|
131
137
|
/** Skill ids in this turn's frozen, model-visible Skill index; telemetry only. */
|
|
132
138
|
modelVisibleSkillIds: ReadonlySet<string> | null;
|
|
@@ -18,6 +18,9 @@ export declare function turnWebSearchPlan(resolvedModel: {
|
|
|
18
18
|
hostedWebSearch: boolean;
|
|
19
19
|
providerTools: WebSearchProviderToolName[];
|
|
20
20
|
};
|
|
21
|
+
/** Closed outcome set for `opengeni_web_search_calls_total`. */
|
|
22
|
+
export type WebSearchCallOutcome = "ok" | "provider_error" | "provider_retryable" | "billing_refused" | "error";
|
|
23
|
+
type WebSearchObservability = Pick<Observability, "warn" | "incrementCounter" | "observeHistogram">;
|
|
21
24
|
/**
|
|
22
25
|
* The `web_search` and `web_fetch` attempt tools for one turn. The caller
|
|
23
26
|
* decides which names the turn gets ({@link webSearchToolPlan}); this only
|
|
@@ -28,6 +31,7 @@ export declare function webSearchToolDefinitions(input: {
|
|
|
28
31
|
tools: readonly WebSearchProviderToolName[];
|
|
29
32
|
scope: WebSearchCallScope;
|
|
30
33
|
billing: WebSearchBilling;
|
|
31
|
-
observability:
|
|
34
|
+
observability: WebSearchObservability;
|
|
32
35
|
fetch?: typeof fetch;
|
|
33
36
|
}): AttemptToolDefinition[];
|
|
37
|
+
export {};
|
|
@@ -43,7 +43,15 @@ export declare class CodemodeAttemptDispatcher {
|
|
|
43
43
|
beginWait(): (accepted: boolean) => void;
|
|
44
44
|
} | undefined);
|
|
45
45
|
start(): void;
|
|
46
|
+
/**
|
|
47
|
+
* Join-on-use recovery before the first model request. The journal read needs
|
|
48
|
+
* no tool environment, so a turn with nothing unfinished returns at once and
|
|
49
|
+
* never waits on lazy MCP preparation. Only a stored waiting/queued/running
|
|
50
|
+
* operation awaits the prepared dispatcher to adopt and execute it.
|
|
51
|
+
*/
|
|
52
|
+
static resumeApproved(db: Database, scope: CodemodeDispatcherScope, callerSubjectId: string, decisionOperationId: string | undefined, prepared: () => Promise<CodemodeAttemptDispatcher | null>): Promise<CodemodeOperation[]>;
|
|
46
53
|
resumeApproved(callerSubjectId: string, decisionOperationId?: string): Promise<CodemodeOperation[]>;
|
|
54
|
+
private resumeOperations;
|
|
47
55
|
close(reason?: string): Promise<void>;
|
|
48
56
|
private execute;
|
|
49
57
|
private executeClaimed;
|
|
@@ -8,20 +8,3 @@ export declare function programmaticApproval(operation: CodemodeOperation): {
|
|
|
8
8
|
requestId: string | undefined;
|
|
9
9
|
};
|
|
10
10
|
export declare function programmaticContinuationNote(operations: readonly CodemodeOperation[]): string | undefined;
|
|
11
|
-
/**
|
|
12
|
-
* Recover committed programmatic approval waits/results before the first model
|
|
13
|
-
* request without turning lazy MCP preparation into a first-request barrier.
|
|
14
|
-
*
|
|
15
|
-
* Only eager servers may gate the first request. Resuming a stored operation
|
|
16
|
-
* needs the prepared attempt tool environment, so this waits for full tool
|
|
17
|
-
* preparation only when there is something to resume: an approval decision
|
|
18
|
-
* trigger, or a cheap durable read showing unfinished operations for this
|
|
19
|
-
* logical turn (which covers every recovery that has stored work). Every other
|
|
20
|
-
* turn sends its first request without waiting on any lazy server.
|
|
21
|
-
*/
|
|
22
|
-
export declare function recoverProgrammaticOperationsBeforeFirstRequest(input: {
|
|
23
|
-
approvalDecisionId: string | undefined;
|
|
24
|
-
hasUnfinishedOperations: () => Promise<boolean>;
|
|
25
|
-
toolPreparationReady: Promise<void> | null;
|
|
26
|
-
resumeApproved: (decisionOperationId: string | undefined) => Promise<CodemodeOperation[]> | undefined;
|
|
27
|
-
}): Promise<CodemodeOperation[]>;
|
|
@@ -209,6 +209,15 @@ export declare function probeRetainedProcessAtProvider(settings: ActivityService
|
|
|
209
209
|
export declare function classifyRetainedProcessPollResult(result: unknown, providerSessionId: number, source?: object): RetainedProcessProbeResult;
|
|
210
210
|
export declare function reconcileModalProviderCreates(db: ActivityServices["db"], settings: ActivityServices["settings"], observability: ActivityServices["observability"], discover?: typeof findModalProviderCreateReceipt): Promise<void>;
|
|
211
211
|
export declare function modalOrphanTerminationStillEligible(latest: Awaited<ReturnType<typeof listLiveModalSandboxLeaseAttributions>>, candidate: ModalOrphanSweepTermination): boolean;
|
|
212
|
+
/** Live leases still WARM on an instance the complete listing did not show.
|
|
213
|
+
* A draining lease legitimately loses its box mid-drain (capture, terminate,
|
|
214
|
+
* then cold), and warming has not published a box yet, so only a warm lease
|
|
215
|
+
* whose exact box is gone is a zombie. */
|
|
216
|
+
export declare function countWarmModalLeasesMissingInstance(latest: Awaited<ReturnType<typeof listLiveModalSandboxLeaseAttributions>>, missingInstanceIds: string[]): number;
|
|
217
|
+
/** Whether no live lease owns the candidate box by exact instance or by its
|
|
218
|
+
* attribution tags. Unlike termination eligibility this ignores the pending
|
|
219
|
+
* create postponement: a postponed orphan is still running without a lease. */
|
|
220
|
+
export declare function modalOrphanCandidateStillUnowned(latest: Awaited<ReturnType<typeof listLiveModalSandboxLeaseAttributions>>, candidate: ModalOrphanSweepTermination): boolean;
|
|
212
221
|
export type SandboxDrainReason = "idle" | "provider_deadline" | "operator" | "teardown_claim" | "rotation_requested";
|
|
213
222
|
/** The bounded drain reason carried on `sandbox.box.terminated`: the lease's
|
|
214
223
|
* rotation reason when a rotation was requested, otherwise the ordinary idle
|
|
@@ -34,7 +34,7 @@ import {
|
|
|
34
34
|
warnDrainSnapshotFailure,
|
|
35
35
|
withFirstPartyTools,
|
|
36
36
|
workflowIdForSession
|
|
37
|
-
} from "./chunk-
|
|
37
|
+
} from "./chunk-BICGFGO7.js";
|
|
38
38
|
import {
|
|
39
39
|
inspectOpenSandboxKubernetesInventory,
|
|
40
40
|
recordActiveUserGauges,
|
|
@@ -42,7 +42,9 @@ import {
|
|
|
42
42
|
recordCreditGrantGauges,
|
|
43
43
|
recordCreditMicros,
|
|
44
44
|
recordExpiredDrainingSandboxLeaseGauges,
|
|
45
|
+
recordInteractionOnlyLeaseGauges,
|
|
45
46
|
recordManagedAuthNewSignupsSwitchGauge,
|
|
47
|
+
recordModalSandboxInventoryGauges,
|
|
46
48
|
recordOpenSandboxKubernetesInventoryGauges,
|
|
47
49
|
recordRetainedProcessInventoryGauges,
|
|
48
50
|
recordRetainedProcessReconciliation,
|
|
@@ -62,7 +64,7 @@ import {
|
|
|
62
64
|
recordVerifiedSignupTrialSwitchGauge,
|
|
63
65
|
recordWorkerDeathRecoveryMetrics,
|
|
64
66
|
runtimeMetricsHooksForObservability
|
|
65
|
-
} from "./chunk-
|
|
67
|
+
} from "./chunk-HVNNCWEU.js";
|
|
66
68
|
import "./chunk-PZ5AY32C.js";
|
|
67
69
|
|
|
68
70
|
// src/activities/knowledge-indexing.ts
|
|
@@ -2790,6 +2792,7 @@ import {
|
|
|
2790
2792
|
recordRecoveredModalProviderCreate,
|
|
2791
2793
|
markWarmBillingStopCutoff,
|
|
2792
2794
|
listMeterableWarmLeases,
|
|
2795
|
+
countInteractionOnlyWarmLeasesByIdle,
|
|
2793
2796
|
listSandboxViewerForceDrainWorkspaceIds,
|
|
2794
2797
|
markSandboxCheckpointArtifactDeletePending as markSandboxCheckpointArtifactDeletePending2,
|
|
2795
2798
|
persistDrainSnapshot,
|
|
@@ -4599,6 +4602,17 @@ async function refreshQueueLeaseAndCreditGauges(db, settings, observability, ins
|
|
|
4599
4602
|
);
|
|
4600
4603
|
}
|
|
4601
4604
|
),
|
|
4605
|
+
refreshSandboxInventoryGauge(
|
|
4606
|
+
observability,
|
|
4607
|
+
"interaction_idle",
|
|
4608
|
+
"interaction-only-lease",
|
|
4609
|
+
async () => {
|
|
4610
|
+
recordInteractionOnlyLeaseGauges(
|
|
4611
|
+
observability,
|
|
4612
|
+
await countInteractionOnlyWarmLeasesByIdle(db, await listMeterableWarmLeases(db))
|
|
4613
|
+
);
|
|
4614
|
+
}
|
|
4615
|
+
),
|
|
4602
4616
|
refreshSandboxInventoryGauge(observability, "expired_drains", "expired-draining", async () => {
|
|
4603
4617
|
recordExpiredDrainingSandboxLeaseGauges(
|
|
4604
4618
|
observability,
|
|
@@ -4751,6 +4765,14 @@ function modalOrphanTerminationStillEligible(latest, candidate) {
|
|
|
4751
4765
|
if (latest.some((lease) => lease.liveness === "warming" && lease.instanceId === null)) {
|
|
4752
4766
|
return false;
|
|
4753
4767
|
}
|
|
4768
|
+
return modalOrphanCandidateStillUnowned(latest, candidate);
|
|
4769
|
+
}
|
|
4770
|
+
function countWarmModalLeasesMissingInstance(latest, missingInstanceIds) {
|
|
4771
|
+
return missingInstanceIds.filter(
|
|
4772
|
+
(instanceId) => latest.some((lease) => lease.liveness === "warm" && lease.instanceId === instanceId)
|
|
4773
|
+
).length;
|
|
4774
|
+
}
|
|
4775
|
+
function modalOrphanCandidateStillUnowned(latest, candidate) {
|
|
4754
4776
|
if (latest.some((lease) => lease.instanceId === candidate.sandboxId)) {
|
|
4755
4777
|
return false;
|
|
4756
4778
|
}
|
|
@@ -4786,6 +4808,27 @@ async function sweepModalOrphansForConfiguredBackend(settings, db, observability
|
|
|
4786
4808
|
return modalOrphanTerminationStillEligible(latest, candidate);
|
|
4787
4809
|
}
|
|
4788
4810
|
});
|
|
4811
|
+
if (result.inventory.complete) {
|
|
4812
|
+
try {
|
|
4813
|
+
const latest = await listLiveModalSandboxLeaseAttributions(db);
|
|
4814
|
+
recordModalSandboxInventoryGauges(observability, {
|
|
4815
|
+
running: result.inventory.running,
|
|
4816
|
+
unleased: result.inventory.unterminated.filter(
|
|
4817
|
+
(candidate) => modalOrphanCandidateStillUnowned(latest, candidate)
|
|
4818
|
+
).length,
|
|
4819
|
+
liveLeaseInstancesMissing: countWarmModalLeasesMissingInstance(
|
|
4820
|
+
latest,
|
|
4821
|
+
result.inventory.missingLiveLeaseInstanceIds
|
|
4822
|
+
)
|
|
4823
|
+
});
|
|
4824
|
+
recordSandboxInventoryProjectionSuccess(observability, "modal_provider");
|
|
4825
|
+
} catch (error) {
|
|
4826
|
+
recordSandboxInventoryProjectionFailure(observability, "modal_provider");
|
|
4827
|
+
observability.warn("sandbox reaper: Modal inventory ownership re-read failed", {
|
|
4828
|
+
error: error instanceof Error ? error.message : String(error)
|
|
4829
|
+
});
|
|
4830
|
+
}
|
|
4831
|
+
}
|
|
4789
4832
|
for (const terminated of result.terminated) {
|
|
4790
4833
|
observability.warn("sandbox reaper: terminated Modal orphan sandbox", {
|
|
4791
4834
|
sandboxId: terminated.sandboxId,
|
|
@@ -5174,15 +5217,18 @@ async function terminateDrainableBox(db, settings, row, observability, terminate
|
|
|
5174
5217
|
}
|
|
5175
5218
|
}
|
|
5176
5219
|
const providerMissing = providerMissingBeforeCapture || (typeof termination === "boolean" ? false : termination.providerMissingBeforeCapture);
|
|
5177
|
-
const { wentCold, backgroundCommandEvents } = await confirmDrainCold(
|
|
5178
|
-
|
|
5179
|
-
|
|
5180
|
-
|
|
5181
|
-
|
|
5182
|
-
|
|
5183
|
-
|
|
5184
|
-
|
|
5185
|
-
|
|
5220
|
+
const { wentCold, unpublishedProviderLost, backgroundCommandEvents } = await confirmDrainCold(
|
|
5221
|
+
db,
|
|
5222
|
+
{
|
|
5223
|
+
accountId,
|
|
5224
|
+
workspaceId: row.workspaceId,
|
|
5225
|
+
sandboxGroupId: row.sandboxGroupId,
|
|
5226
|
+
expectedEpoch: row.leaseEpoch,
|
|
5227
|
+
...captureClaim ? { expectedCaptureId: captureClaim.id } : {},
|
|
5228
|
+
providerMissingBeforeCapture: providerMissing,
|
|
5229
|
+
idleCommandContainmentMs: settings.sandboxIdleCommandContainmentMs
|
|
5230
|
+
}
|
|
5231
|
+
);
|
|
5186
5232
|
await publishDurableSessionEvents(bus, row.workspaceId, backgroundCommandEvents, (error) => {
|
|
5187
5233
|
observability.warn("sandbox reaper: contained command event fanout failed", {
|
|
5188
5234
|
sandboxGroupId: row.sandboxGroupId,
|
|
@@ -5190,7 +5236,7 @@ async function terminateDrainableBox(db, settings, row, observability, terminate
|
|
|
5190
5236
|
});
|
|
5191
5237
|
});
|
|
5192
5238
|
if (wentCold) {
|
|
5193
|
-
if (providerMissing) {
|
|
5239
|
+
if (providerMissing && !unpublishedProviderLost) {
|
|
5194
5240
|
recordSandboxProviderMissingBeforeCapture(observability, backend);
|
|
5195
5241
|
}
|
|
5196
5242
|
if (lease.unobservableCommandDrainIds?.length) {
|
|
@@ -8813,4 +8859,4 @@ export {
|
|
|
8813
8859
|
createControlActivities,
|
|
8814
8860
|
createControlActivitiesFromServices
|
|
8815
8861
|
};
|
|
8816
|
-
//# sourceMappingURL=activities-control-
|
|
8862
|
+
//# sourceMappingURL=activities-control-VRFS65FT.js.map
|