@opengeni/worker-bundle 4.3.3-canary.39786771332001 → 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;
@@ -0,0 +1,30 @@
1
+ import { appendTurnCapabilityCardOnce } from "@opengeni/db";
2
+ import { publishDurableSessionEvents } from "@opengeni/events";
3
+ import type { UserSetupCardPoster } from "@opengeni/runtime";
4
+ type AppendCardOnce = typeof appendTurnCapabilityCardOnce;
5
+ type PublishEvents = typeof publishDurableSessionEvents;
6
+ export type UserSetupCardInput = {
7
+ db: Parameters<AppendCardOnce>[0];
8
+ bus: Parameters<PublishEvents>[0];
9
+ /** Connected Machines are enabled on this deployment; their cards can't help otherwise. */
10
+ connectedMachinesEnabled: boolean;
11
+ /** The web app's base URL, for the chat link the agent can hand out. */
12
+ webBaseUrl: string | null | undefined;
13
+ workspaceId: string;
14
+ sessionId: string;
15
+ turnId: string;
16
+ executionGeneration: number;
17
+ attemptId: string;
18
+ append?: AppendCardOnce;
19
+ publish?: PublishEvents;
20
+ };
21
+ /**
22
+ * Posts the setup card for a tool refusal the person can fix (see
23
+ * USER_SETUP_BLOCKERS) in the calling turn, at most once per turn and card: a
24
+ * later refusal in the same turn reuses the card already shown. The append
25
+ * runs under the attempt fence, so a replaced turn posts nothing. Resolves
26
+ * "unavailable" when the card can't help on this deployment, and null when it
27
+ * was not posted.
28
+ */
29
+ export declare function userSetupCardPoster(input: UserSetupCardInput): UserSetupCardPoster;
30
+ export {};