@opengeni/worker-bundle 4.4.1 → 4.5.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.
@@ -0,0 +1,38 @@
1
+ import { type PreparedAgentInput } from "@opengeni/runtime";
2
+ import type { TurnStreamAttemptDeps } from "./stream-attempt.js";
3
+ export type EagerOwnedSandboxSetupDeps = Pick<TurnStreamAttemptDeps, "input" | "db" | "observability" | "runtimeCancellationSignal" | "sandboxState" | "eventing" | "leases" | "runWorkspaceMutationForSandbox" | "attachGitCredentialRenewal" | "attachRunCredentialRenewal" | "activeSandboxBackend" | "groupBoxBackend" | "turnExecutionPolicy" | "agent" | "runSettings" | "initialRunCredentialMaterial" | "initialGitCredentials" | "sandboxEnvironment" | "fileResourceDownloads">;
4
+ export type EagerOwnedSandboxSetupOptions = {
5
+ /** The worker delivers this turn's file resources itself. */
6
+ fileDownloadsMaterialized: boolean;
7
+ /** Receives the runtime's file-failure note when the runtime delivers files. */
8
+ preparedInput?: PreparedAgentInput;
9
+ };
10
+ /**
11
+ * Whether this turn's platform setup runs eagerly against an owned box the
12
+ * worker already holds. Lazy boxes run the same setup in their first-operation
13
+ * provisioner, and connected machines receive no platform setup.
14
+ */
15
+ export declare function hasEagerOwnedSandboxSetup(sandboxState: EagerOwnedSandboxSetupDeps["sandboxState"]): boolean;
16
+ /**
17
+ * Run the turn's platform setup (rig setup, credential hooks, repository
18
+ * clones) against the eager owned box. The setup settles its workspace
19
+ * admission before returning, so no admission stays open into the model stream.
20
+ */
21
+ export declare function runEagerOwnedSandboxSetup(deps: EagerOwnedSandboxSetupDeps, options: EagerOwnedSandboxSetupOptions): Promise<void>;
22
+ /**
23
+ * The eager platform setup for each model stream of one turn attempt.
24
+ *
25
+ * The first stream's setup may already be running: it needs nothing from the
26
+ * model input, so the worker starts it with file delivery and input
27
+ * preparation instead of after them. Each later stream of the attempt runs the
28
+ * idempotent setup again, as before.
29
+ */
30
+ export type EagerOwnedSandboxSetup = {
31
+ /** Run, or join the already started, setup for the next model stream. */
32
+ beforeModelStream(options: EagerOwnedSandboxSetupOptions): Promise<void>;
33
+ /** Resolves once a started setup has finished, whatever its outcome. */
34
+ settled(): Promise<void>;
35
+ };
36
+ export declare function createEagerOwnedSandboxSetup(deps: EagerOwnedSandboxSetupDeps, start?: {
37
+ fileDownloadsMaterialized: boolean;
38
+ }, runSetup?: typeof runEagerOwnedSandboxSetup): EagerOwnedSandboxSetup;
@@ -14,6 +14,7 @@ import { createTurnHistorySink } from "./history-sink.js";
14
14
  import { type SessionEvent, type SessionTurn } from "@opengeni/contracts";
15
15
  import { createModelCheckpointMemoryCollector } from "../../model-checkpoint-memory-collector.js";
16
16
  import { TurnEventPublisher } from "./model-usage.js";
17
+ import { type EagerOwnedSandboxSetup } from "./owned-sandbox-setup.js";
17
18
  import type { CompactionSummarizer } from "../context-compaction.js";
18
19
  import type { TurnExecutionPolicyV1 } from "@opengeni/contracts";
19
20
  import type { BoundRunCredentialResolver } from "../run-credentials.js";
@@ -77,6 +78,8 @@ export type TurnStreamAttemptDeps = {
77
78
  modelUsageDispatchId: string;
78
79
  workerPreparationStartedAt: number;
79
80
  fileDownloadsMaterializedForRun: boolean;
81
+ /** Eager owned-box platform setup, possibly already started by the worker. */
82
+ eagerOwnedSandboxSetup?: EagerOwnedSandboxSetup;
80
83
  unavailableSandboxFilesNote: string | undefined;
81
84
  runCredentialsNote: string | undefined;
82
85
  mcpAvailabilityNote: string | undefined;