@opengeni/worker-bundle 1.0.0-canary.0 → 1.0.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 +3 -1
- package/dist/activities/agent-turn/admission.d.ts +24 -3
- package/dist/activities/agent-turn/agent-build.d.ts +4 -0
- package/dist/activities/agent-turn/claude-usage-observer.d.ts +58 -0
- package/dist/activities/agent-turn/code-search.d.ts +60 -0
- package/dist/activities/agent-turn/codex-capacity.d.ts +13 -0
- package/dist/activities/agent-turn/codex-plan-entitlement.d.ts +105 -0
- package/dist/activities/agent-turn/codex.d.ts +3 -2
- package/dist/activities/agent-turn/compaction-prep.d.ts +21 -5
- package/dist/activities/agent-turn/credential-leases.d.ts +19 -33
- package/dist/activities/agent-turn/credential-restriction.d.ts +3 -0
- package/dist/activities/agent-turn/errors.d.ts +82 -11
- package/dist/activities/agent-turn/failure-settlement.d.ts +6 -3
- package/dist/activities/agent-turn/final-reply.d.ts +18 -0
- package/dist/activities/agent-turn/finalization-monitor.d.ts +17 -0
- package/dist/activities/agent-turn/finalization.d.ts +4 -2
- package/dist/activities/agent-turn/github-repository-bindings.d.ts +2 -0
- package/dist/activities/agent-turn/governance-model.d.ts +9 -2
- package/dist/activities/agent-turn/history-sink.d.ts +2 -0
- package/dist/activities/agent-turn/history.d.ts +2 -0
- package/dist/activities/agent-turn/input-wait-reply.d.ts +41 -0
- package/dist/activities/agent-turn/media-artifacts.d.ts +5 -3
- package/dist/activities/agent-turn/model-call-admission.d.ts +15 -0
- package/dist/activities/agent-turn/model-usage.d.ts +6 -0
- package/dist/activities/agent-turn/model-wire-dispatch.d.ts +15 -0
- package/dist/activities/agent-turn/optional-repositories.d.ts +59 -0
- package/dist/activities/agent-turn/provider-dispatch-barrier.d.ts +12 -1
- package/dist/activities/agent-turn/quiescence.d.ts +7 -7
- package/dist/activities/agent-turn/recovery-warning.d.ts +9 -0
- package/dist/activities/agent-turn/refresh-credentials.d.ts +6 -0
- package/dist/activities/agent-turn/run-credentials.d.ts +8 -3
- package/dist/activities/agent-turn/sandbox-establish.d.ts +2 -1
- package/dist/activities/agent-turn/sandbox-provision.d.ts +3 -1
- package/dist/activities/agent-turn/sandbox-route.d.ts +3 -20
- package/dist/activities/agent-turn/sandbox-runtime.d.ts +2 -2
- package/dist/activities/agent-turn/session-title.d.ts +34 -2
- package/dist/activities/agent-turn/skill-checkout.d.ts +25 -6
- package/dist/activities/agent-turn/skill-read.d.ts +70 -2
- package/dist/activities/agent-turn/skill-remove.d.ts +14 -0
- package/dist/activities/agent-turn/skill-search.d.ts +3 -1
- package/dist/activities/agent-turn/skill-tools.d.ts +15 -2
- package/dist/activities/agent-turn/skill-transfer.d.ts +18 -6
- package/dist/activities/agent-turn/stream-attempt.d.ts +7 -3
- package/dist/activities/agent-turn/subscription-lease.d.ts +38 -0
- package/dist/activities/agent-turn/tool-environment.d.ts +56 -6
- package/dist/activities/agent-turn/tool-policy.d.ts +43 -0
- package/dist/activities/agent-turn/turn-context.d.ts +29 -0
- package/dist/activities/agent-turn/turn-sandbox-access.d.ts +3 -0
- package/dist/activities/agent-turn/xai-capacity.d.ts +2 -1
- package/dist/activities/automations.d.ts +3 -1
- package/dist/activities/browser-deadline-checkpoint.d.ts +29 -0
- package/dist/activities/codemode-dispatcher.d.ts +9 -2
- package/dist/activities/codex-capacity.d.ts +18 -2
- package/dist/activities/codex-rotation.d.ts +7 -1
- package/dist/activities/context-compaction.d.ts +16 -2
- package/dist/activities/gmail-files.d.ts +32 -0
- package/dist/activities/goals.d.ts +8 -0
- package/dist/activities/knowledge-indexing.d.ts +19 -0
- package/dist/activities/mcp-account-routes.d.ts +3 -0
- package/dist/activities/mcp-credentials.d.ts +12 -13
- package/dist/activities/mcp-operation-authority.d.ts +0 -5
- package/dist/activities/model-call-fact-reconciler.d.ts +34 -0
- package/dist/activities/open-suffix-resume.d.ts +13 -0
- package/dist/activities/parent-wake.d.ts +6 -12
- package/dist/activities/retained-screenshots.d.ts +7 -2
- package/dist/activities/rig-verification.d.ts +2 -3
- package/dist/activities/run-credential-renewal.d.ts +1 -0
- package/dist/activities/run-credentials.d.ts +15 -3
- package/dist/activities/sandbox-images.d.ts +1 -1
- package/dist/activities/sandbox-lease.d.ts +47 -9
- package/dist/activities/scheduled-tasks.d.ts +4 -35
- package/dist/activities/session-state.d.ts +70 -3
- package/dist/activities/types.d.ts +55 -6
- package/dist/activities/workspace-capture.d.ts +2 -0
- package/dist/activities/workspace-credential-provider.d.ts +46 -0
- package/dist/{activities-control-HMFGSKC5.js → activities-control-BNPTRTOE.js} +1896 -418
- package/dist/activities-control-BNPTRTOE.js.map +1 -0
- package/dist/activities-control.d.ts +182 -4
- package/dist/{activities-turn-AP67JADS.js → activities-turn-5LGZOSVU.js} +4476 -1327
- package/dist/activities-turn-5LGZOSVU.js.map +1 -0
- package/dist/activities.d.ts +182 -4
- package/dist/artifact-materializer-entry.js +5 -2
- package/dist/artifact-materializer-entry.js.map +1 -1
- package/dist/artifact-outbox-entry.js +5 -2
- package/dist/artifact-outbox-entry.js.map +1 -1
- package/dist/browser-deadline-checkpoint-contract.d.ts +2 -0
- package/dist/{chunk-A4XQWVZK.js → chunk-3ZTRWDMN.js} +307 -4
- package/dist/chunk-3ZTRWDMN.js.map +1 -0
- package/dist/{chunk-RAMNYSAW.js → chunk-4ER3YXOT.js} +22 -4
- package/dist/chunk-4ER3YXOT.js.map +1 -0
- package/dist/{chunk-CYITU5UH.js → chunk-LJX7Z2KP.js} +1445 -343
- package/dist/chunk-LJX7Z2KP.js.map +1 -0
- package/dist/editable-artifact-materializer-service.d.ts +2 -2
- package/dist/editable-artifact-outbox-service.d.ts +2 -2
- package/dist/host-export-pump.d.ts +3 -1
- package/dist/host-export.d.ts +1 -1
- package/dist/host-export.js +1 -1
- package/dist/http.d.ts +1 -1
- package/dist/index.d.ts +95 -3
- package/dist/index.js +137 -43
- package/dist/index.js.map +1 -1
- package/dist/observability-metrics.d.ts +118 -8
- package/dist/retained-process-diagnostics.d.ts +4 -0
- package/dist/retained-process-retry.d.ts +7 -0
- package/dist/sandbox-resume.d.ts +55 -13
- package/dist/sandbox-routing.d.ts +5 -3
- package/dist/sandbox-snapshot-diagnostics.d.ts +20 -0
- package/dist/session-event-fanout.d.ts +6 -0
- package/dist/warm-capture-holder.d.ts +3 -0
- package/dist/worker-service-lifecycle.d.ts +12 -0
- package/dist/workflow-bundle.js +273 -41
- package/dist/workflows/activities.d.ts +1 -1
- package/dist/workflows/browser-deadline-checkpoint.d.ts +9 -0
- package/dist/workflows/scheduled-tasks.d.ts +4 -0
- package/dist/workflows/session.d.ts +36 -0
- package/dist/workflows.d.ts +1 -0
- package/package.json +21 -19
- package/src/activities/agent-run-admission.ts +17 -1
- package/src/activities/agent-turn/admission.ts +66 -3
- package/src/activities/agent-turn/agent-build.ts +84 -10
- package/src/activities/agent-turn/claim.ts +186 -43
- package/src/activities/agent-turn/claude-usage-observer.ts +221 -0
- package/src/activities/agent-turn/code-search.ts +275 -0
- package/src/activities/agent-turn/codex-capacity.ts +172 -8
- package/src/activities/agent-turn/codex-plan-entitlement.ts +254 -0
- package/src/activities/agent-turn/codex.ts +13 -5
- package/src/activities/agent-turn/compaction-prep.ts +170 -102
- package/src/activities/agent-turn/credential-leases.ts +122 -216
- package/src/activities/agent-turn/credential-restriction.ts +14 -0
- package/src/activities/agent-turn/errors.ts +647 -48
- package/src/activities/agent-turn/failure-settlement.ts +682 -130
- package/src/activities/agent-turn/final-reply.ts +46 -0
- package/src/activities/agent-turn/finalization-monitor.ts +120 -0
- package/src/activities/agent-turn/finalization.ts +146 -43
- package/src/activities/agent-turn/github-repository-bindings.ts +3 -1
- package/src/activities/agent-turn/governance-model.ts +69 -28
- package/src/activities/agent-turn/history-sink.ts +16 -2
- package/src/activities/agent-turn/history.ts +38 -11
- package/src/activities/agent-turn/input-wait-reply.ts +103 -0
- package/src/activities/agent-turn/knowledge-source-tools.ts +2 -0
- package/src/activities/agent-turn/media-artifacts.ts +2 -1
- package/src/activities/agent-turn/model-call-admission.ts +94 -0
- package/src/activities/agent-turn/model-usage.ts +64 -3
- package/src/activities/agent-turn/model-wire-dispatch.ts +27 -0
- package/src/activities/agent-turn/optional-repositories.ts +224 -0
- package/src/activities/agent-turn/provider-dispatch-barrier.ts +22 -0
- package/src/activities/agent-turn/quiescence.ts +10 -7
- package/src/activities/agent-turn/recovery-warning.ts +16 -0
- package/src/activities/agent-turn/refresh-credentials.ts +44 -0
- package/src/activities/agent-turn/run-credentials.ts +116 -55
- package/src/activities/agent-turn/run.ts +320 -93
- package/src/activities/agent-turn/sandbox-establish.ts +84 -8
- package/src/activities/agent-turn/sandbox-provision.ts +3 -1
- package/src/activities/agent-turn/sandbox-route.ts +4 -21
- package/src/activities/agent-turn/sandbox-runtime.ts +343 -18
- package/src/activities/agent-turn/session-title.ts +81 -5
- package/src/activities/agent-turn/skill-checkout.ts +111 -24
- package/src/activities/agent-turn/skill-install.ts +1 -1
- package/src/activities/agent-turn/skill-read.ts +374 -28
- package/src/activities/agent-turn/skill-remove.ts +46 -0
- package/src/activities/agent-turn/skill-save.ts +1 -1
- package/src/activities/agent-turn/skill-search.ts +10 -1
- package/src/activities/agent-turn/skill-selection.ts +4 -0
- package/src/activities/agent-turn/skill-tools.ts +112 -18
- package/src/activities/agent-turn/skill-transfer.ts +68 -23
- package/src/activities/agent-turn/stream-attempt.ts +313 -77
- package/src/activities/agent-turn/subscription-lease.ts +115 -0
- package/src/activities/agent-turn/tool-environment.ts +316 -167
- package/src/activities/agent-turn/tool-policy.ts +80 -1
- package/src/activities/agent-turn/turn-context.ts +35 -0
- package/src/activities/agent-turn/turn-sandbox-access.ts +7 -1
- package/src/activities/agent-turn/xai-capacity.ts +94 -51
- package/src/activities/automations.ts +76 -4
- package/src/activities/browser-deadline-checkpoint.ts +279 -0
- package/src/activities/capabilities.ts +108 -11
- package/src/activities/codemode-dispatcher.ts +36 -8
- package/src/activities/codex-capacity.ts +60 -25
- package/src/activities/codex-rotation.ts +39 -17
- package/src/activities/context-compaction.ts +75 -18
- package/src/activities/gmail-files.ts +88 -0
- package/src/activities/goals.ts +116 -121
- package/src/activities/google-drive-publication.ts +1 -3
- package/src/activities/image-generation-operation.ts +1 -1
- package/src/activities/knowledge-indexing.ts +269 -15
- package/src/activities/knowledge-source-sync.ts +10 -0
- package/src/activities/mcp-account-routes.ts +17 -0
- package/src/activities/mcp-credentials.ts +83 -194
- package/src/activities/mcp-operation-authority.ts +16 -41
- package/src/activities/model-call-fact-reconciler.ts +112 -0
- package/src/activities/open-suffix-resume.ts +15 -2
- package/src/activities/parent-wake.ts +46 -21
- package/src/activities/retained-screenshots.ts +82 -11
- package/src/activities/rig-verification.ts +38 -37
- package/src/activities/run-credential-renewal.ts +13 -1
- package/src/activities/run-credentials.ts +59 -17
- package/src/activities/run-input.ts +25 -16
- package/src/activities/sandbox-images.ts +0 -1
- package/src/activities/sandbox-lease.ts +798 -82
- package/src/activities/scheduled-tasks.ts +550 -178
- package/src/activities/session-state.ts +245 -6
- package/src/activities/site-auth-maintenance.ts +3 -0
- package/src/activities/types.ts +72 -5
- package/src/activities/workflow-wake.ts +2 -17
- package/src/activities/workspace-capture.ts +13 -2
- package/src/activities/workspace-credential-provider.ts +283 -0
- package/src/activities-control.ts +4 -0
- package/src/activities-turn.ts +5 -0
- package/src/activities.ts +13 -0
- package/src/activity-services.ts +16 -4
- package/src/browser-deadline-checkpoint-contract.ts +5 -0
- package/src/editable-artifact-hint-broker.ts +3 -0
- package/src/editable-artifact-materializer-service.ts +7 -3
- package/src/editable-artifact-outbox-service.ts +4 -4
- package/src/github-rest-mcp.ts +1 -2
- package/src/host-export-pump.ts +26 -4
- package/src/host-export.ts +3 -0
- package/src/http.ts +4 -2
- package/src/index.ts +99 -37
- package/src/observability-metrics.ts +510 -5
- package/src/personal-github-git-credentials.ts +2 -1
- package/src/pr-review-credentials.ts +1 -3
- package/src/retained-process-diagnostics.ts +50 -0
- package/src/retained-process-retry.ts +36 -0
- package/src/sandbox-resume.ts +388 -101
- package/src/sandbox-routing.ts +150 -25
- package/src/sandbox-snapshot-diagnostics.ts +112 -0
- package/src/session-event-fanout.ts +23 -0
- package/src/warm-capture-holder.ts +15 -0
- package/src/worker-service-lifecycle.ts +53 -0
- package/src/workflows/activities.ts +16 -1
- package/src/workflows/browser-deadline-checkpoint.ts +50 -0
- package/src/workflows/file-upload-reaper.ts +2 -0
- package/src/workflows/scheduled-tasks.ts +26 -13
- package/src/workflows/session.ts +242 -22
- package/src/workflows.ts +4 -0
- package/dist/activities/agent-turn/knowledge-sources.d.ts +0 -20
- package/dist/activities/packs.d.ts +0 -55
- package/dist/activities-control-HMFGSKC5.js.map +0 -1
- package/dist/activities-turn-AP67JADS.js.map +0 -1
- package/dist/chunk-A4XQWVZK.js.map +0 -1
- package/dist/chunk-CYITU5UH.js.map +0 -1
- package/dist/chunk-RAMNYSAW.js.map +0 -1
- package/src/activities/agent-turn/knowledge-sources.ts +0 -86
- package/src/activities/packs.ts +0 -166
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { type SessionEventType } from "@opengeni/contracts";
|
|
2
|
-
import type
|
|
3
|
-
import type
|
|
1
|
+
import { type SessionEventType, type SkillReadKind, type SkillUseSource } from "@opengeni/contracts";
|
|
2
|
+
import { type ActiveUserWindow, type CreditGrantTotals, type SessionEventAppendPhaseObservation } from "@opengeni/db";
|
|
3
|
+
import { type EventBusOptions, type EventLogger } from "@opengeni/events";
|
|
4
4
|
import type { Observability } from "@opengeni/observability";
|
|
5
5
|
import type { CompanyBrainContributionReceipt } from "./model-context-contributions.js";
|
|
6
6
|
import { type OpenSandboxKubernetesInventory } from "./opensandbox-kubernetes-inventory.js";
|
|
7
|
-
import { type RuntimeMetricsHooks, type SelfhostedOpObservation, type SelfhostedOpObserver } from "@opengeni/runtime";
|
|
7
|
+
import { type RuntimeMetricsHooks, type SelfhostedOpObservation, type SelfhostedOpObserver, type ToolPreparationPhaseMeasurement } from "@opengeni/runtime";
|
|
8
8
|
export type TurnOutcome = "completed" | "failed" | "cancelled" | "recovering";
|
|
9
9
|
export type WorkerDeathRecoveryOutcome = "recovering" | "exhausted";
|
|
10
10
|
export type CreditMicrosKind = "usage" | "grant" | "topup" | "refund";
|
|
@@ -39,6 +39,8 @@ export type TemporalTurnTaskQueueStats = {
|
|
|
39
39
|
} | null;
|
|
40
40
|
declare const CONTEXT_COMPACTION_TRIGGERS: readonly ["auto", "operator", "proactive", "overflow"];
|
|
41
41
|
export type ContextCompactionTrigger = (typeof CONTEXT_COMPACTION_TRIGGERS)[number];
|
|
42
|
+
/** Logger plus the closed-label subscription-termination counter for NATS connections. */
|
|
43
|
+
export declare function observabilityEventBusOptions(observability: Observability): Pick<EventBusOptions, "logger" | "onSubscriptionTerminated">;
|
|
42
44
|
export declare function observabilityEventLogger(observability: Observability): EventLogger;
|
|
43
45
|
export declare function runtimeMetricsHooksForObservability(observability: Observability): RuntimeMetricsHooks;
|
|
44
46
|
/**
|
|
@@ -174,17 +176,79 @@ export declare function startContextCompactionPendingMonitor(input: {
|
|
|
174
176
|
};
|
|
175
177
|
export declare function recordSandboxLeaseGauges(observability: Observability, counts: Partial<Record<SandboxLeaseLiveness, number>>): void;
|
|
176
178
|
export declare function recordOpenSandboxKubernetesInventoryGauges(observability: Observability, inventory: OpenSandboxKubernetesInventory): void;
|
|
177
|
-
export declare const SANDBOX_INVENTORY_PROJECTION_DOMAINS: readonly ["leases", "checkpoint_artifacts", "rotation_backlog", "retained_processes", "expired_drains", "opensandbox_kubernetes"];
|
|
179
|
+
export declare const SANDBOX_INVENTORY_PROJECTION_DOMAINS: readonly ["leases", "checkpoint_artifacts", "recovery_observations", "rotation_backlog", "retained_processes", "expired_drains", "opensandbox_kubernetes"];
|
|
178
180
|
export type SandboxInventoryProjectionDomain = (typeof SANDBOX_INVENTORY_PROJECTION_DOMAINS)[number];
|
|
179
181
|
export declare function recordSandboxInventoryProjectionSuccess(observability: Observability, domain: SandboxInventoryProjectionDomain, timestampSeconds?: number): void;
|
|
180
182
|
export declare function recordSandboxInventoryProjectionFailure(observability: Observability, domain: SandboxInventoryProjectionDomain): void;
|
|
181
183
|
export declare function recordCreditBalanceGauges(observability: Observability, balances: CreditBalanceGauge[]): void;
|
|
184
|
+
/**
|
|
185
|
+
* Distinct managed people with authenticated browser activity in each fixed
|
|
186
|
+
* window (migration 0565 presence). Every control worker publishes the same
|
|
187
|
+
* global value, so dashboards must aggregate with `max()` across pods, never
|
|
188
|
+
* `sum()`. API keys, services and embedded hosts are never counted.
|
|
189
|
+
*/
|
|
190
|
+
export declare function recordActiveUserGauges(observability: Observability, counts: Record<ActiveUserWindow, number>): void;
|
|
191
|
+
/**
|
|
192
|
+
* Positive credit grants observed by the ledger trigger since migration 0565,
|
|
193
|
+
* by closed class. These are cumulative database totals published as gauges by
|
|
194
|
+
* every control worker: aggregate with `max()` across pods, then `increase()`.
|
|
195
|
+
* Counting in the database covers the grants no application process writes:
|
|
196
|
+
* the verified-signup trial grant (a setup trigger) and operator grants.
|
|
197
|
+
*/
|
|
198
|
+
export declare function recordCreditGrantGauges(observability: Observability, totals: CreditGrantTotals): void;
|
|
199
|
+
/**
|
|
200
|
+
* The deployment-level runtime switch for the one-time verified signup trial
|
|
201
|
+
* credit (migration 0521): 1 while it allows grants, 0 when an operator has
|
|
202
|
+
* disabled it or no revision exists. A grant also needs the API's
|
|
203
|
+
* OPENGENI_VERIFIED_SIGNUP_TRIAL_CREDITS_ENABLED master opt-in, which
|
|
204
|
+
* {@link recordVerifiedSignupTrialDeploymentFlagGauge} reports separately.
|
|
205
|
+
*/
|
|
206
|
+
export declare function recordVerifiedSignupTrialSwitchGauge(observability: Observability, grantsEnabled: boolean): void;
|
|
207
|
+
/**
|
|
208
|
+
* The deployment-level runtime switch for new managed account sign-ups
|
|
209
|
+
* (migration 0585): 1 while it allows new accounts (also when no revision
|
|
210
|
+
* exists), 0 when an operator has paused them. The API additionally honours
|
|
211
|
+
* its OPENGENI_MANAGED_AUTH_NEW_SIGNUPS_ENABLED ceiling, which this gauge does
|
|
212
|
+
* not see; `GET /v1/config/client` reports the combined decision.
|
|
213
|
+
*/
|
|
214
|
+
export declare function recordManagedAuthNewSignupsSwitchGauge(observability: Observability, signupsEnabled: boolean): void;
|
|
215
|
+
/**
|
|
216
|
+
* The OPENGENI_VERIFIED_SIGNUP_TRIAL_CREDITS_ENABLED master opt-in as this
|
|
217
|
+
* worker's configuration sees it. The API reads the same shared setting; new
|
|
218
|
+
* grants happen only while this gauge and the runtime switch gauge are both 1.
|
|
219
|
+
*/
|
|
220
|
+
export declare function recordVerifiedSignupTrialDeploymentFlagGauge(observability: Observability, enabled: boolean): void;
|
|
182
221
|
export declare function recordSandboxOrphansTerminated(observability: Observability, count: number): void;
|
|
183
222
|
export type SandboxCheckpointArtifactMetricState = "candidate" | "current" | "previous" | "delete_pending" | "deleting" | "delete_failed" | "deleted";
|
|
184
223
|
export declare function recordSandboxCheckpointArtifactGauges(observability: Observability, counts: Record<SandboxCheckpointArtifactMetricState, number>): void;
|
|
185
224
|
export type SandboxCheckpointArtifactOutcome = "legacy_adopted" | "claimed" | "deleted" | "delete_failed" | "tombstone_pruned";
|
|
186
225
|
export declare function recordSandboxCheckpointArtifactOutcome(observability: Observability, outcome: SandboxCheckpointArtifactOutcome, count?: number): void;
|
|
187
226
|
export declare function recordSandboxDeadlineRotationsRequested(observability: Observability, count: number): void;
|
|
227
|
+
/** Fixed outcomes of legacy retained-command containment: per-candidate
|
|
228
|
+
* enrollment inspection, then the enrolled drain's exact cold commit. */
|
|
229
|
+
export declare const SANDBOX_COMMAND_CONTAINMENT_OUTCOMES: readonly ["idle_enrolled", "deadline_enrolled", "resumed_enrolled", "not_eligible", "inspection_failed", "contained", "provider_missing"];
|
|
230
|
+
export type SandboxCommandContainmentOutcome = (typeof SANDBOX_COMMAND_CONTAINMENT_OUTCOMES)[number];
|
|
231
|
+
export declare function recordSandboxCommandContainment(observability: Observability, outcome: SandboxCommandContainmentOutcome): void;
|
|
232
|
+
/** Only call after the exact draining->cold commit reports wentCold. The
|
|
233
|
+
* backend is validated against the closed contract so provider IDs and other
|
|
234
|
+
* per-sandbox values can never become metric labels. */
|
|
235
|
+
export declare function recordSandboxProviderMissingBeforeCapture(observability: Observability, backend: string): void;
|
|
236
|
+
export declare function recordSandboxRecoveryObservationGauges(observability: Observability, observations: {
|
|
237
|
+
providerLosses: number;
|
|
238
|
+
fallbackSelections: number;
|
|
239
|
+
freshWorkspaceSelections?: number;
|
|
240
|
+
}): void;
|
|
241
|
+
/** Fixed outcomes for a committed automatic continuity decision after
|
|
242
|
+
* definitive managed-provider loss: a singleton checkpoint (`selected`), a
|
|
243
|
+
* shared-group checkpoint (`selected_shared`), or a new empty workspace
|
|
244
|
+
* (`fresh_workspace`). Call only after the durable authorization committed. */
|
|
245
|
+
export declare const SANDBOX_AUTOMATIC_RECOVERY_OUTCOMES: readonly ["selected", "selected_shared", "fresh_workspace"];
|
|
246
|
+
export type SandboxAutomaticRecoveryOutcome = (typeof SANDBOX_AUTOMATIC_RECOVERY_OUTCOMES)[number];
|
|
247
|
+
export declare function sandboxAutomaticRecoveryOutcome(input: {
|
|
248
|
+
lane: "checkpoint" | "fresh_workspace";
|
|
249
|
+
groupSessionCount: number;
|
|
250
|
+
}): SandboxAutomaticRecoveryOutcome;
|
|
251
|
+
export declare function recordSandboxAutomaticRecoverySelected(observability: Observability, backend: string, outcome: SandboxAutomaticRecoveryOutcome): void;
|
|
188
252
|
export declare function recordSandboxRotationBacklogGauges(observability: Observability, backlog: {
|
|
189
253
|
requested: number;
|
|
190
254
|
overdue: number;
|
|
@@ -205,7 +269,7 @@ export declare function recordExpiredDrainingSandboxLeaseGauges(observability: O
|
|
|
205
269
|
ageBucket: string;
|
|
206
270
|
count: number;
|
|
207
271
|
}>): void;
|
|
208
|
-
export declare const RETAINED_PROCESS_RECONCILIATION_OUTCOMES: readonly ["claim_failed", "proof_exited", "proof_lost", "proof_checkpoint_failed", "settled_exited", "settled_lost", "settlement_failed", "identity_mismatch", "resume_state_missing", "backend_unsupported", "provider_running", "provider_unknown", "provider_timeout", "provider_error", "provider_binding_missing", "provider_binding_mismatch", "provider_binding_adopted", "process_observation_unavailable", "quarantined_process_observation_unavailable", "quarantined_binding_missing", "quarantined_binding_mismatch", "defer_failed"];
|
|
272
|
+
export declare const RETAINED_PROCESS_RECONCILIATION_OUTCOMES: readonly ["claim_failed", "background_recovered", "proof_exited", "proof_lost", "proof_checkpoint_failed", "settled_exited", "settled_lost", "settlement_failed", "identity_mismatch", "resume_state_missing", "backend_unsupported", "provider_running", "provider_unknown", "provider_timeout", "provider_error", "provider_binding_missing", "provider_binding_mismatch", "provider_binding_adopted", "process_observation_unavailable", "quarantined_process_observation_unavailable", "quarantined_binding_missing", "quarantined_binding_mismatch", "defer_failed"];
|
|
209
273
|
export type RetainedProcessReconciliationOutcome = (typeof RETAINED_PROCESS_RECONCILIATION_OUTCOMES)[number];
|
|
210
274
|
export declare function recordRetainedProcessReconciliation(observability: Observability, outcome: RetainedProcessReconciliationOutcome): void;
|
|
211
275
|
export declare function recordCreditMicros(observability: Observability | undefined, kind: CreditMicrosKind, amountMicros: number): void;
|
|
@@ -220,7 +284,7 @@ export declare function recordModelRequestPhase(observability: Observability, in
|
|
|
220
284
|
outcome?: "completed" | "failed" | "timed_out";
|
|
221
285
|
durationSeconds: number;
|
|
222
286
|
}): void;
|
|
223
|
-
export type TurnStartupPhase = "claim_and_policy" | "turn_start_settlement" | "credential_selection" | "runtime_preparation" | "sandbox_establish" | "file_resolution" | "tool_context_preparation" | "tool_preparation" | "tool_server_construction" | "tool_required_connect" | "tool_optional_connect" | "tool_attempt_catalog_build" | "tool_attempt_catalog_persist" | "tool_workspace_gateway_catalog_build" | "post_tool_preparation" | "agent_construction" | "post_agent_preparation" | "file_materialization" | "history_preparation" | "history_system_update_load" | "history_current_attachment_resolution" | "history_durable_history_load" | "history_sandbox_envelope_load" | "history_canonical_projection" | "history_provider_projection" | "history_attachment_ref_projection" | "history_screenshot_materialization" | "history_model_attachment_projection" | "history_runtime_input_assembly" | "history_artifact_candidate_scan" | "history_generated_image_materialization" | "history_position_load" | "owned_sandbox_setup" | "
|
|
287
|
+
export type TurnStartupPhase = "services_initialization" | "claim_catalog_read" | "claim_atomic" | "claim_session_read" | "claim_capability_settings" | "learning_policy_freeze" | "attachment_authority_projection" | "claim_and_policy" | "turn_start_settlement" | "credential_selection" | "runtime_preparation" | "session_mcp_settings" | "sandbox_establish" | "file_resolution" | "tool_context_preparation" | "tool_preparation" | "tool_server_construction" | "tool_required_connect" | "tool_optional_connect" | "tool_attempt_catalog_build" | "tool_attempt_catalog_persist" | "tool_workspace_gateway_catalog_build" | "post_tool_preparation" | "agent_construction" | "post_agent_preparation" | "file_materialization" | "history_preparation" | "history_system_update_load" | "history_current_attachment_resolution" | "history_durable_history_load" | "history_sandbox_envelope_load" | "history_canonical_projection" | "history_provider_projection" | "history_attachment_ref_projection" | "history_screenshot_materialization" | "history_model_attachment_projection" | "history_runtime_input_assembly" | "history_artifact_candidate_scan" | "history_generated_image_materialization" | "history_position_load" | "owned_sandbox_setup" | "runtime_stream_initialization" | "model_request_preparation" | "model_sdk_serialization" | "model_prepare_sandbox_agent_preparation" | "model_prepare_sandbox_agent_manifest_inventory" | "model_prepare_sandbox_session_manifest_inventory" | "model_prepare_sandbox_manifest_apply" | "model_prepare_sandbox_entry_materialization" | "model_prepare_sandbox_running_check" | "model_prepare_sandbox_start" | "model_prepare_sandbox_client_create" | "model_prepare_sandbox_client_resume" | "model_prepare_sandbox_client_delete" | "model_prepare_sandbox_client_state_serialize" | "model_prepare_sandbox_client_reuse_check" | "model_prepare_sandbox_workspace_mutation_admission" | "model_prepare_sandbox_workspace_mutation_provider" | "model_prepare_sandbox_workspace_mutation_settlement" | "model_prepare_sandbox_first_routed_resolution_other" | "model_prepare_sandbox_first_routed_mutation_admission" | "model_prepare_sandbox_first_routed_provider_operation" | "model_prepare_sandbox_first_routed_mutation_settlement" | "model_prepare_sandbox_first_routed_other" | "model_prepare_sandbox_snapshot_wait" | "model_prepare_runner_before_first_sandbox_operation" | "model_prepare_sdk_after_first_sandbox_operation" | "model_prepare_runner_before_mcp_tools" | "model_prepare_mcp_tools_snapshot" | "model_prepare_mcp_tools_before_input_filter" | "model_prepare_mcp_tools_before_repository_skill_discovery" | "model_prepare_repository_skill_discovery" | "model_prepare_repository_skill_discovery_before_input_filter" | "model_prepare_input_filter_base" | "model_prepare_input_filter_genesis" | "model_prepare_input_filter_host" | "model_prepare_input_filter_tool_output" | "model_prepare_input_filter_modality" | "model_prepare_input_filter_context" | "model_prepare_responses_input_conversion" | "model_prepare_responses_request_build" | "model_credential_resolution" | "model_wire_normalization" | "model_request_audit" | "stream_bootstrap";
|
|
224
288
|
export type TurnStartupOutcome = "completed" | "failed";
|
|
225
289
|
export type TurnStartupMilestone = "queue" | "provider_dispatch" | "first_byte";
|
|
226
290
|
export type TurnStartupCache = "hit" | "miss" | "disabled" | "none";
|
|
@@ -233,7 +297,8 @@ export type SandboxLogicalProvisionOutcome = "completed" | "expected_transition"
|
|
|
233
297
|
export type SandboxProvisionAttemptOutcome = "completed" | "retrying" | "failed";
|
|
234
298
|
export declare function turnStartupCountBucket(count: number | null): TurnStartupCountBucket;
|
|
235
299
|
/**
|
|
236
|
-
* Measure
|
|
300
|
+
* Measure startup operations, including nested and parallel work. These are
|
|
301
|
+
* not additive critical-path intervals; use milestones for elapsed latency.
|
|
237
302
|
* Every label is a closed or configuration-derived enum; high-cardinality turn,
|
|
238
303
|
* session, credential, connection, file, and model identifiers are forbidden.
|
|
239
304
|
*/
|
|
@@ -245,6 +310,16 @@ export declare function recordTurnStartupPhase(observability: Observability, inp
|
|
|
245
310
|
durationSeconds: number;
|
|
246
311
|
count?: number | null;
|
|
247
312
|
cache?: TurnStartupCache;
|
|
313
|
+
/** Trace-only lookup for the completed claim while its execution root is still open. */
|
|
314
|
+
executionCorrelationId?: string;
|
|
315
|
+
}): void;
|
|
316
|
+
/** Observe an existing dependency only. Child intervals can overlap and are
|
|
317
|
+
* not additive; observer failure must never change authority or error identity. */
|
|
318
|
+
export declare function measureTurnStartupPhase<T>(observability: Observability, input: Omit<Parameters<typeof recordTurnStartupPhase>[1], "durationSeconds" | "outcome">, work: () => Promise<T>): Promise<T>;
|
|
319
|
+
/** Background MCP preparation must not inflate startup phase distributions. */
|
|
320
|
+
export declare function recordToolPreparationPhase(observability: Observability, input: ToolPreparationPhaseMeasurement & {
|
|
321
|
+
provider: string;
|
|
322
|
+
backend: string;
|
|
248
323
|
}): void;
|
|
249
324
|
/**
|
|
250
325
|
* Explain why a turn did or did not keep provider sandbox work off the
|
|
@@ -414,4 +489,39 @@ export declare function modelCallAccountContext(input: {
|
|
|
414
489
|
servingAccountHash: string;
|
|
415
490
|
accountChangedFromPrevCall: boolean;
|
|
416
491
|
};
|
|
492
|
+
export type CodeSearchCallOutcome = "completed" | "jev_unavailable" | "jev_rejected" | "workspace_unavailable" | "invalid_arguments" | "breaker_open" | "cancelled" | "failed";
|
|
493
|
+
/** One `code_search` tool call: outcome, wall time and the Jev work it used. */
|
|
494
|
+
export declare function recordCodeSearchCall(observability: Observability, input: {
|
|
495
|
+
outcome: CodeSearchCallOutcome;
|
|
496
|
+
durationSeconds: number;
|
|
497
|
+
jevRequests: number;
|
|
498
|
+
jevCostUsd: number;
|
|
499
|
+
}): void;
|
|
500
|
+
/**
|
|
501
|
+
* One skill_read call. Labels are closed sets: `skill` is a built-in id or
|
|
502
|
+
* `custom` for every other Skill, so tenant Skill ids, names, and requested
|
|
503
|
+
* identifiers never become labels. `source` is `unknown` when the read was
|
|
504
|
+
* refused before a Skill resolved.
|
|
505
|
+
*/
|
|
506
|
+
export declare function recordSkillRead(observability: Observability, read: {
|
|
507
|
+
caller: "model" | "codemode";
|
|
508
|
+
kind: SkillReadKind;
|
|
509
|
+
source: SkillUseSource | null;
|
|
510
|
+
/** The resolved Skill id, or the requested identifier when none resolved. */
|
|
511
|
+
skill: string;
|
|
512
|
+
}): void;
|
|
513
|
+
/**
|
|
514
|
+
* One skill_checkout call. Labels are closed sets and never carry Skill ids,
|
|
515
|
+
* names, or paths. Phases that did not run are not observed.
|
|
516
|
+
*/
|
|
517
|
+
export declare function recordSkillCheckout(observability: Observability, checkout: {
|
|
518
|
+
outcome: "written" | "unchanged" | "refused" | "failed";
|
|
519
|
+
selection: "all" | "paths";
|
|
520
|
+
written: number;
|
|
521
|
+
unchanged: number;
|
|
522
|
+
resolveSeconds: number | null;
|
|
523
|
+
sandboxSeconds: number | null;
|
|
524
|
+
writeSeconds: number | null;
|
|
525
|
+
totalSeconds: number;
|
|
526
|
+
}): void;
|
|
417
527
|
export {};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type SandboxRetainedProcess } from "@opengeni/db";
|
|
2
|
+
import type { Observability } from "@opengeni/observability";
|
|
3
|
+
/** Protected cause locations and schema facts; public logs receive only the diagnostic key. */
|
|
4
|
+
export declare function warnRetainedProcessProofFailure(observability: Pick<Observability, "recordFailureDiagnostic" | "warn">, error: unknown, process: Pick<SandboxRetainedProcess, "id" | "sessionId" | "ownerAttemptId" | "ownerTurnId" | "reconcileAttempts">): void;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { LeaseSnapshot, SandboxRetainedProcess } from "@opengeni/db";
|
|
2
|
+
/** Observation backoff must leave the exact provider's rotation window usable.
|
|
3
|
+
* This changes only the next probe time, never cancellation or settlement proof. */
|
|
4
|
+
export declare function retainedProcessDeadlineRetryMs(process: Pick<SandboxRetainedProcess, "leaseId" | "leaseEpoch" | "providerBackend" | "providerInstanceId" | "routeTargetId">, lease: Pick<LeaseSnapshot, "id" | "leaseEpoch" | "backend" | "instanceId" | "providerDeadlineAt"> | null, settings: {
|
|
5
|
+
sandboxRotationLeadMs: number;
|
|
6
|
+
sandboxLeaseReaperPeriodMs: number;
|
|
7
|
+
}, retryAfterMs: number, now?: number): number;
|
package/dist/sandbox-resume.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import type { EventBus } from "@opengeni/events";
|
|
1
2
|
import { type Settings } from "@opengeni/config";
|
|
2
3
|
import { readLease, reinstateTurnLeaseHolder, SandboxLeaseSupersededError, type Database, type LeaseHolderKind } from "@opengeni/db";
|
|
3
4
|
import { establishSandboxSessionFromEnvelope, type EstablishedSandboxSession, type RuntimeMetricsHooks } from "@opengeni/runtime";
|
|
4
5
|
import { type ObjectStorage } from "@opengeni/storage";
|
|
5
|
-
import type
|
|
6
|
+
import { type Observability } from "@opengeni/observability";
|
|
7
|
+
export { safeSnapshotError } from "./sandbox-snapshot-diagnostics.js";
|
|
6
8
|
export type ResumeHolderKind = LeaseHolderKind;
|
|
7
9
|
/**
|
|
8
10
|
* The durable identity of a turn holding a shared sandbox lease.
|
|
@@ -22,9 +24,6 @@ export type SandboxResumeServices = {
|
|
|
22
24
|
db: Database;
|
|
23
25
|
settings: Settings;
|
|
24
26
|
objectStorage?: ObjectStorage | null;
|
|
25
|
-
/** Exact settings before a verified rig provider image overlaid the logical
|
|
26
|
-
* pack/deployment image. Fresh-create NotFound fallback must preserve an
|
|
27
|
-
* ID-only logical base instead of selecting the provider default. */
|
|
28
27
|
logicalFallbackSettings?: Settings;
|
|
29
28
|
sandboxMetrics?: RuntimeMetricsHooks;
|
|
30
29
|
/** Structured logger for lifecycle decisions (holder release reasons). Falls
|
|
@@ -45,6 +44,25 @@ export type SandboxResumeServices = {
|
|
|
45
44
|
/** Test seam for the bounded command-readiness proof performed before an
|
|
46
45
|
* attached provider box is handed to the agent. */
|
|
47
46
|
verifyAttachedSandboxReadiness?: (established: EstablishedSandboxSession) => Promise<void>;
|
|
47
|
+
/** Test seam for the bounded command-readiness proof the elected spawner runs
|
|
48
|
+
* on its freshly created box before publishing the lease warm. Production
|
|
49
|
+
* uses {@link waitForSandboxExecReadiness} with the shared 60 s budget. */
|
|
50
|
+
verifySpawnedSandboxReadiness?: (established: EstablishedSandboxSession, identity: {
|
|
51
|
+
sandboxGroupId: string;
|
|
52
|
+
}) => Promise<void>;
|
|
53
|
+
/** Test seam for the jittered pause before the single fresh-box readiness
|
|
54
|
+
* replacement. Production uses {@link freshSandboxReadinessReplacementDelayMs}.
|
|
55
|
+
* It may be async so a test can observe the rolled-back lease in between. */
|
|
56
|
+
freshSandboxReadinessReplacementDelayMs?: () => number | Promise<number>;
|
|
57
|
+
/**
|
|
58
|
+
* The turn attempt's fresh-box readiness replacement budget. The lazy
|
|
59
|
+
* provisioner may call resumeBoxForTurn again after a typed lease
|
|
60
|
+
* supersession, so the turn creates the budget once and shares it with every
|
|
61
|
+
* call. Absent, the call gets its own single replacement.
|
|
62
|
+
*/
|
|
63
|
+
freshSandboxReadinessReplacementBudget?: FreshSandboxReadinessReplacementBudget;
|
|
64
|
+
/** Live fanout for background commands a provider loss settled. */
|
|
65
|
+
bus?: EventBus | null;
|
|
48
66
|
/** Called only by the observer that wins the exact warm->cold loss CAS. */
|
|
49
67
|
onSandboxLost?: (input: {
|
|
50
68
|
sandboxGroupId: string;
|
|
@@ -83,6 +101,9 @@ export type ResumeBoxIds = {
|
|
|
83
101
|
* never conflicts).
|
|
84
102
|
*/
|
|
85
103
|
image?: string;
|
|
104
|
+
/** Deployment/workspace image pins apply only to new creates; an existing
|
|
105
|
+
* group keeps its image. Omission preserves explicit image matching (B3). */
|
|
106
|
+
imagePolicy?: "require_match" | "new_creates_only";
|
|
86
107
|
/**
|
|
87
108
|
* RIG IS SHARED STATE (M3): the frozen rig version this run rides. Threaded to
|
|
88
109
|
* acquireLease, which stamps it on the cold-create and conflicts on a live box
|
|
@@ -147,6 +168,23 @@ export declare class SandboxSiblingWarmingTimeoutError extends SandboxWarmingTim
|
|
|
147
168
|
instanceId?: string | null;
|
|
148
169
|
});
|
|
149
170
|
}
|
|
171
|
+
/** True only for a spawner readiness timeout whose unready fresh box is proven gone. */
|
|
172
|
+
export declare function isReplaceableFreshSandboxReadinessTimeout(error: unknown): boolean;
|
|
173
|
+
/**
|
|
174
|
+
* A burst of simultaneous turn starts can leave many freshly created provider
|
|
175
|
+
* boxes command-unready at once. The single replacement re-enters admission
|
|
176
|
+
* after a jittered pause so the replacement creates do not re-synchronize into
|
|
177
|
+
* the same burst. Bounded to [2 s, 10 s).
|
|
178
|
+
*/
|
|
179
|
+
export declare const FRESH_SANDBOX_READINESS_REPLACEMENT_BASE_DELAY_MS = 2000;
|
|
180
|
+
export declare const FRESH_SANDBOX_READINESS_REPLACEMENT_JITTER_MS = 8000;
|
|
181
|
+
export declare function freshSandboxReadinessReplacementDelayMs(random?: () => number): number;
|
|
182
|
+
/** Replacements allowed per turn attempt, across every resumeBoxForTurn call. */
|
|
183
|
+
export declare const FRESH_SANDBOX_READINESS_REPLACEMENTS_PER_TURN_ATTEMPT = 1;
|
|
184
|
+
export type FreshSandboxReadinessReplacementBudget = {
|
|
185
|
+
remaining: number;
|
|
186
|
+
};
|
|
187
|
+
export declare function createFreshSandboxReadinessReplacementBudget(): FreshSandboxReadinessReplacementBudget;
|
|
150
188
|
/** The exact attached caller that won warm->cold after proving the provider
|
|
151
189
|
* instance gone. It is a lease supersession (the same logical turn recovers),
|
|
152
190
|
* plus the lost id needed for one durable observability event. */
|
|
@@ -162,15 +200,7 @@ export declare class SandboxLeaseInstanceLostError extends SandboxLeaseSupersede
|
|
|
162
200
|
*/
|
|
163
201
|
export declare function waitForSandboxExecReadiness(established: EstablishedSandboxSession, timeoutMs?: number, identity?: {
|
|
164
202
|
sandboxGroupId?: string | null;
|
|
165
|
-
}): Promise<void>;
|
|
166
|
-
export declare function safeSnapshotError(error: unknown): {
|
|
167
|
-
errorClass: "SnapshotOperationError";
|
|
168
|
-
errorCode: "snapshot_operation_failed";
|
|
169
|
-
status?: number;
|
|
170
|
-
origin: "sandbox-resume";
|
|
171
|
-
causeName?: string;
|
|
172
|
-
integrityCode?: string;
|
|
173
|
-
};
|
|
203
|
+
}, signal?: AbortSignal): Promise<void>;
|
|
174
204
|
export declare function waitForWarmSnapshot(snapshot: Promise<unknown>, timeoutMs: number, signal?: AbortSignal): Promise<boolean>;
|
|
175
205
|
export type SandboxDeadlineRotationCheckpointResult = {
|
|
176
206
|
/** The exact established epoch still carries a requested rotation and a
|
|
@@ -245,5 +275,17 @@ export declare function maybePersistWarmWorkspaceSnapshot(services: SandboxResum
|
|
|
245
275
|
* holderId is the globally unique durable turn-attempt id. It must not be a
|
|
246
276
|
* Temporal activity id, because activity ids are only workflow-local and
|
|
247
277
|
* collide when sibling sessions share one sandbox group.
|
|
278
|
+
*
|
|
279
|
+
* A freshly created box that misses its bounded command-readiness budget is
|
|
280
|
+
* replaced at most once per turn attempt (the budget is shared by every call
|
|
281
|
+
* the turn's provisioner makes). The first establish has already terminated that exact
|
|
282
|
+
* unpublished box, rolled its exact warming epoch back to cold (advancing the
|
|
283
|
+
* epoch), and released its holder, so the replacement is an ordinary new
|
|
284
|
+
* admission: it re-runs the cold->warming CAS, persists its own provider
|
|
285
|
+
* instance before readiness, and may instead attach to a sibling that won the
|
|
286
|
+
* CAS first. Nothing model- or tool-visible ran on the discarded box, so no
|
|
287
|
+
* side effect is replayed. A second readiness timeout fails the turn exactly
|
|
288
|
+
* as before; attached/resumed boxes and unconfirmed terminations never
|
|
289
|
+
* replace.
|
|
248
290
|
*/
|
|
249
291
|
export declare function resumeBoxForTurn(services: SandboxResumeServices, ids: ResumeBoxIds, kind: "turn", holderId: TurnSandboxLeaseHolderId): Promise<ResumedTurnSandbox>;
|
|
@@ -2,7 +2,7 @@ import { type Settings } from "@opengeni/config";
|
|
|
2
2
|
import { type Database, type EnrollmentRecord } from "@opengeni/db";
|
|
3
3
|
import type { OpStreamOutputFrame } from "@opengeni/runtime/sandbox";
|
|
4
4
|
import type { EventBus } from "@opengeni/events";
|
|
5
|
-
import { type EstablishedSandboxSession, type RoutingSandboxFirstOperationObserver, type RoutingSandboxOperationObserver, type SelfhostedOpObserver, type SelfhostedConnectionBinding, type SelfhostedRelayConfig, type OpStreamJournal } from "@opengeni/runtime";
|
|
5
|
+
import { type EstablishedSandboxSession, type RoutingSandboxFirstOperationObserver, type RoutingSandboxOperationObserver, type RoutingSandboxCaptureWaitObserver, type SelfhostedOpObserver, type SelfhostedConnectionBinding, type SelfhostedRelayConfig, type OpStreamJournal } from "@opengeni/runtime";
|
|
6
6
|
export type RoutingWiringServices = {
|
|
7
7
|
db: Database;
|
|
8
8
|
settings: Settings;
|
|
@@ -15,6 +15,7 @@ export type RoutingWiringServices = {
|
|
|
15
15
|
onOp?: SelfhostedOpObserver;
|
|
16
16
|
/** Every physical routed provider call, across cloud and selfhosted homes. */
|
|
17
17
|
onSandboxOperation?: RoutingSandboxOperationObserver;
|
|
18
|
+
onSandboxCaptureWait?: RoutingSandboxCaptureWaitObserver;
|
|
18
19
|
/** The op-stream durable-resume journal (the Temporal adaptation from
|
|
19
20
|
* op-journal.ts): attach generation + settled-frontier persistence. Absent ⇒
|
|
20
21
|
* the runtime defaults (generation "1", no persistence) — tests / non-turn
|
|
@@ -27,11 +28,12 @@ export type RoutingWiringServices = {
|
|
|
27
28
|
instanceId: string;
|
|
28
29
|
leaseEpoch: number;
|
|
29
30
|
}) => Promise<void>;
|
|
30
|
-
/**
|
|
31
|
+
/** Prepare and publish the worker's home handle. Rejection leaves the route
|
|
32
|
+
* unpublished; replacement preparation must settle before the first tool op. */
|
|
31
33
|
onHomeSandboxRebound?: (input: {
|
|
32
34
|
established: EstablishedSandboxSession;
|
|
33
35
|
leaseEpoch: number;
|
|
34
|
-
}) => void
|
|
36
|
+
}) => void | Promise<void>;
|
|
35
37
|
/** Cancel bounded capture waits with the owning turn activity. */
|
|
36
38
|
waitSignal?: AbortSignal;
|
|
37
39
|
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type Observability } from "@opengeni/observability";
|
|
2
|
+
type SafeSnapshotError = {
|
|
3
|
+
errorClass: "SnapshotOperationError";
|
|
4
|
+
errorCode: "snapshot_operation_failed";
|
|
5
|
+
status?: number;
|
|
6
|
+
origin: "sandbox-resume" | "worker-lifecycle";
|
|
7
|
+
causeName?: string;
|
|
8
|
+
integrityCode?: string;
|
|
9
|
+
providerErrorName?: string;
|
|
10
|
+
providerGrpcCode?: number;
|
|
11
|
+
providerHttpStatus?: number;
|
|
12
|
+
providerRetryable?: boolean;
|
|
13
|
+
};
|
|
14
|
+
export declare function safeSnapshotError(error: unknown, origin?: SafeSnapshotError["origin"]): SafeSnapshotError;
|
|
15
|
+
export declare function warnDrainSnapshotFailure(observability: Pick<Observability, "warn">, message: string, error: unknown, lease: {
|
|
16
|
+
workspaceId?: string;
|
|
17
|
+
sandboxGroupId: string;
|
|
18
|
+
leaseEpoch: number;
|
|
19
|
+
}): void;
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { SessionEvent } from "@opengeni/contracts";
|
|
2
|
+
import type { EventBus } from "@opengeni/events";
|
|
3
|
+
/** Best-effort live fanout of events that are already durable, grouped by
|
|
4
|
+
* session. Durable catch-up remains the source of truth, so failures are only
|
|
5
|
+
* reported. */
|
|
6
|
+
export declare function publishDurableSessionEvents(bus: EventBus | null | undefined, workspaceId: string, events: readonly SessionEvent[] | undefined, onError?: (error: unknown) => void): Promise<void>;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { LeaseSnapshot } from "@opengeni/db";
|
|
2
|
+
/** Physical capture retention is not permission to heartbeat or execute a closed turn. */
|
|
3
|
+
export declare function retainsHolderForWarmCapture(lease: Pick<LeaseSnapshot, "liveness" | "leaseEpoch" | "archiveCapture"> | null, expectedEpoch: number, now?: number): boolean;
|
|
@@ -22,3 +22,15 @@ export declare function createWorkerServiceLifecycle(input: {
|
|
|
22
22
|
closeOwnedResources: () => Promise<void>;
|
|
23
23
|
onReady?: () => void;
|
|
24
24
|
}): WorkerServiceLifecycle;
|
|
25
|
+
/** A cleanup stall first drains peers through WORKER_SHUTDOWN. The standalone
|
|
26
|
+
* process owns the final exit, because Temporal cannot kill JavaScript writers.
|
|
27
|
+
* Embedded hosts may supply their own termination policy at this same edge. */
|
|
28
|
+
export declare function createWorkerCleanupContainment(input: {
|
|
29
|
+
drain: () => boolean;
|
|
30
|
+
terminate?: () => void;
|
|
31
|
+
observability: Observability;
|
|
32
|
+
timeoutMs?: number;
|
|
33
|
+
}): {
|
|
34
|
+
request(): void;
|
|
35
|
+
finished(): void;
|
|
36
|
+
};
|