@opengeni/worker-bundle 0.20.3 → 0.22.0-canary.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.
Files changed (184) hide show
  1. package/dist/activities/agent-turn/admission.d.ts +52 -0
  2. package/dist/activities/agent-turn/agent-build.d.ts +89 -0
  3. package/dist/activities/agent-turn/claim.d.ts +67 -0
  4. package/dist/activities/agent-turn/codex-capacity.d.ts +40 -0
  5. package/dist/activities/agent-turn/codex.d.ts +32 -0
  6. package/dist/activities/agent-turn/compaction-prep.d.ts +88 -0
  7. package/dist/activities/agent-turn/credential-leases.d.ts +56 -0
  8. package/dist/activities/agent-turn/errors.d.ts +253 -0
  9. package/dist/activities/agent-turn/failure-settlement.d.ts +33 -0
  10. package/dist/activities/agent-turn/file-resources.d.ts +37 -0
  11. package/dist/activities/agent-turn/finalization.d.ts +42 -0
  12. package/dist/activities/agent-turn/github-repository-bindings.d.ts +105 -0
  13. package/dist/activities/agent-turn/governance-model.d.ts +66 -0
  14. package/dist/activities/agent-turn/history-sink.d.ts +52 -0
  15. package/dist/activities/agent-turn/history.d.ts +63 -0
  16. package/dist/activities/agent-turn/media-artifacts.d.ts +145 -0
  17. package/dist/activities/agent-turn/model-usage.d.ts +218 -0
  18. package/dist/activities/agent-turn/quiescence.d.ts +135 -0
  19. package/dist/activities/agent-turn/run-credentials.d.ts +84 -0
  20. package/dist/activities/agent-turn/run.d.ts +3 -0
  21. package/dist/activities/agent-turn/sandbox-establish.d.ts +93 -0
  22. package/dist/activities/agent-turn/sandbox-provision.d.ts +89 -0
  23. package/dist/activities/agent-turn/sandbox-route.d.ts +151 -0
  24. package/dist/activities/agent-turn/sandbox-runtime.d.ts +44 -0
  25. package/dist/activities/agent-turn/stream-attempt.d.ts +107 -0
  26. package/dist/activities/agent-turn/tool-environment.d.ts +142 -0
  27. package/dist/activities/agent-turn/tool-policy.d.ts +127 -0
  28. package/dist/activities/agent-turn/tool-result-spill.d.ts +59 -0
  29. package/dist/activities/agent-turn/turn-context.d.ts +144 -0
  30. package/dist/activities/agent-turn/xai-capacity.d.ts +2 -0
  31. package/dist/activities/agent-turn.d.ts +12 -954
  32. package/dist/activities/automations.d.ts +16 -0
  33. package/dist/activities/common.d.ts +1 -1
  34. package/dist/activities/connector-attachments.d.ts +13 -0
  35. package/dist/activities/documents.d.ts +1 -0
  36. package/dist/activities/environment.d.ts +26 -15
  37. package/dist/activities/generated-images.d.ts +1 -1
  38. package/dist/activities/git-credential-renewal.d.ts +3 -1
  39. package/dist/activities/goals.d.ts +4 -1
  40. package/dist/activities/google-drive-provider.d.ts +29 -0
  41. package/dist/activities/google-drive-publication.d.ts +17 -4
  42. package/dist/activities/incident-telemetry-authority.d.ts +52 -0
  43. package/dist/activities/incident-telemetry-preflight.d.ts +71 -0
  44. package/dist/activities/knowledge-source-sync.d.ts +4 -0
  45. package/dist/activities/mcp-credentials.d.ts +9 -3
  46. package/dist/activities/open-suffix-resume.d.ts +77 -0
  47. package/dist/activities/packs.d.ts +3 -11
  48. package/dist/activities/parent-wake.d.ts +19 -0
  49. package/dist/activities/retained-screenshot-reaper.d.ts +1 -1
  50. package/dist/activities/retained-screenshots.d.ts +1 -1
  51. package/dist/activities/rig-verification.d.ts +1 -1
  52. package/dist/activities/run-input.d.ts +9 -10
  53. package/dist/activities/sandbox-images.d.ts +1 -14
  54. package/dist/activities/sandbox-lease.d.ts +21 -3
  55. package/dist/activities/scheduled-tasks.d.ts +47 -0
  56. package/dist/activities/types.d.ts +23 -2
  57. package/dist/activities/video-media-validation.d.ts +1 -1
  58. package/dist/activities/video-output-retention.d.ts +1 -2
  59. package/dist/activities/xai-auth.d.ts +3 -0
  60. package/dist/{activities-control-BJSDRSIP.js → activities-control-DKG22ONJ.js} +2646 -551
  61. package/dist/activities-control-DKG22ONJ.js.map +1 -0
  62. package/dist/activities-control.d.ts +6 -2
  63. package/dist/activities-turn-4IMC3MAA.js +21326 -0
  64. package/dist/activities-turn-4IMC3MAA.js.map +1 -0
  65. package/dist/activities.d.ts +7 -3
  66. package/dist/artifact-materializer-entry.js +41 -22
  67. package/dist/artifact-materializer-entry.js.map +1 -1
  68. package/dist/{chunk-N5TJIFCE.js → chunk-CE7TPKBS.js} +468 -1
  69. package/dist/chunk-CE7TPKBS.js.map +1 -0
  70. package/dist/chunk-CNYGVRKF.js +4698 -0
  71. package/dist/chunk-CNYGVRKF.js.map +1 -0
  72. package/dist/connection-provider-use.d.ts +18 -0
  73. package/dist/editable-artifact-materializer.d.ts +4 -3
  74. package/dist/github-rest-mcp.d.ts +26 -0
  75. package/dist/index.d.ts +10 -2
  76. package/dist/index.js +58 -14
  77. package/dist/index.js.map +1 -1
  78. package/dist/knowledge-source-sync-activity-policy.d.ts +2 -0
  79. package/dist/model-context-contributions.d.ts +8 -4
  80. package/dist/observability-metrics.d.ts +63 -4
  81. package/dist/opensandbox-kubernetes-inventory.d.ts +21 -0
  82. package/dist/personal-github-git-credentials.d.ts +9 -0
  83. package/dist/pr-review-credentials.d.ts +6 -0
  84. package/dist/sandbox-archive-storage.d.ts +45 -0
  85. package/dist/sandbox-resume.d.ts +65 -6
  86. package/dist/sandbox-routing.d.ts +38 -2
  87. package/dist/scheduled-alert-occurrence.d.ts +33 -0
  88. package/dist/workflow-bundle.js +87 -28
  89. package/dist/workflows/activities.d.ts +1 -0
  90. package/dist/workflows/automations.d.ts +6 -0
  91. package/dist/workflows/document-index.d.ts +1 -0
  92. package/dist/workflows.d.ts +1 -0
  93. package/package.json +17 -17
  94. package/src/activities/agent-turn/admission.ts +292 -0
  95. package/src/activities/agent-turn/agent-build.ts +802 -0
  96. package/src/activities/agent-turn/claim.ts +590 -0
  97. package/src/activities/agent-turn/codex-capacity.ts +720 -0
  98. package/src/activities/agent-turn/codex.ts +94 -0
  99. package/src/activities/agent-turn/compaction-prep.ts +722 -0
  100. package/src/activities/agent-turn/credential-leases.ts +240 -0
  101. package/src/activities/agent-turn/errors.ts +1068 -0
  102. package/src/activities/agent-turn/failure-settlement.ts +1436 -0
  103. package/src/activities/agent-turn/file-resources.ts +227 -0
  104. package/src/activities/agent-turn/finalization.ts +754 -0
  105. package/src/activities/agent-turn/github-repository-bindings.ts +300 -0
  106. package/src/activities/agent-turn/governance-model.ts +465 -0
  107. package/src/activities/agent-turn/history-sink.ts +139 -0
  108. package/src/activities/agent-turn/history.ts +200 -0
  109. package/src/activities/agent-turn/media-artifacts.ts +359 -0
  110. package/src/activities/agent-turn/model-usage.ts +823 -0
  111. package/src/activities/agent-turn/quiescence.ts +353 -0
  112. package/src/activities/agent-turn/run-credentials.ts +761 -0
  113. package/src/activities/agent-turn/run.ts +1530 -0
  114. package/src/activities/agent-turn/sandbox-establish.ts +1207 -0
  115. package/src/activities/agent-turn/sandbox-provision.ts +569 -0
  116. package/src/activities/agent-turn/sandbox-route.ts +358 -0
  117. package/src/activities/agent-turn/sandbox-runtime.ts +731 -0
  118. package/src/activities/agent-turn/stream-attempt.ts +1670 -0
  119. package/src/activities/agent-turn/tool-environment.ts +729 -0
  120. package/src/activities/agent-turn/tool-policy.ts +216 -0
  121. package/src/activities/agent-turn/tool-result-spill.ts +265 -0
  122. package/src/activities/agent-turn/turn-context.ts +281 -0
  123. package/src/activities/agent-turn/xai-capacity.ts +229 -0
  124. package/src/activities/agent-turn.ts +12 -12701
  125. package/src/activities/api-integrations.ts +3 -0
  126. package/src/activities/automations.ts +214 -0
  127. package/src/activities/codemode-dispatcher.ts +12 -1
  128. package/src/activities/common.ts +1 -5
  129. package/src/activities/connector-attachments.ts +168 -0
  130. package/src/activities/context-compaction.ts +18 -0
  131. package/src/activities/environment.ts +151 -55
  132. package/src/activities/generated-images.ts +26 -11
  133. package/src/activities/git-credential-renewal.ts +13 -3
  134. package/src/activities/goals.ts +85 -19
  135. package/src/activities/google-drive-provider.ts +178 -0
  136. package/src/activities/google-drive-publication.ts +147 -49
  137. package/src/activities/incident-telemetry-authority.ts +327 -0
  138. package/src/activities/incident-telemetry-preflight.ts +317 -0
  139. package/src/activities/knowledge-source-sync.ts +178 -37
  140. package/src/activities/mcp-credentials.ts +191 -17
  141. package/src/activities/open-suffix-resume.ts +422 -0
  142. package/src/activities/packs.ts +12 -60
  143. package/src/activities/parent-wake.ts +64 -14
  144. package/src/activities/retained-screenshot-reaper.ts +6 -3
  145. package/src/activities/retained-screenshots.ts +15 -47
  146. package/src/activities/rig-verification.ts +1 -1
  147. package/src/activities/run-input.ts +102 -142
  148. package/src/activities/sandbox-images.ts +7 -166
  149. package/src/activities/sandbox-lease.ts +406 -15
  150. package/src/activities/scheduled-tasks.ts +2103 -411
  151. package/src/activities/session-state.ts +10 -2
  152. package/src/activities/types.ts +32 -2
  153. package/src/activities/video-media-validation.ts +3 -3
  154. package/src/activities/video-output-retention.ts +2 -57
  155. package/src/activities/xai-auth.ts +8 -0
  156. package/src/activities-control.ts +2 -0
  157. package/src/activities.ts +3 -0
  158. package/src/activity-services.ts +13 -4
  159. package/src/connection-provider-use.ts +36 -0
  160. package/src/editable-artifact-materializer-subprocess.ts +25 -14
  161. package/src/editable-artifact-materializer.ts +29 -18
  162. package/src/github-rest-mcp.ts +713 -0
  163. package/src/http.ts +16 -6
  164. package/src/index.ts +40 -5
  165. package/src/knowledge-source-sync-activity-policy.ts +2 -0
  166. package/src/model-context-contributions.ts +33 -10
  167. package/src/observability-metrics.ts +357 -0
  168. package/src/opensandbox-kubernetes-inventory.ts +292 -0
  169. package/src/personal-github-git-credentials.ts +331 -0
  170. package/src/pr-review-credentials.ts +163 -0
  171. package/src/sandbox-archive-storage.ts +159 -0
  172. package/src/sandbox-resume.ts +449 -63
  173. package/src/sandbox-routing.ts +314 -16
  174. package/src/scheduled-alert-occurrence.ts +176 -0
  175. package/src/workflows/activities.ts +18 -2
  176. package/src/workflows/automations.ts +11 -0
  177. package/src/workflows/session.ts +13 -3
  178. package/src/workflows.ts +1 -0
  179. package/dist/activities-control-BJSDRSIP.js.map +0 -1
  180. package/dist/activities-turn-J5YO7XXX.js +0 -17243
  181. package/dist/activities-turn-J5YO7XXX.js.map +0 -1
  182. package/dist/chunk-N5TJIFCE.js.map +0 -1
  183. package/dist/chunk-P6Z2SLAA.js +0 -3092
  184. package/dist/chunk-P6Z2SLAA.js.map +0 -1
@@ -0,0 +1,93 @@
1
+ import { readActiveSandbox, type SandboxRecord } from "@opengeni/db";
2
+ import { sandboxOperationMetricObserver } from "@opengeni/observability";
3
+ import { type GitCredentialTokenWriterSession, type NormalizedRunCredentialMaterial, type RunCredentialCommandSession, type CodemodeTokenWriterSession } from "@opengeni/runtime";
4
+ import { type Settings } from "@opengeni/config";
5
+ import { mergeResourceRefs } from "../common.js";
6
+ import { type MintedRunGitCredentials, type SandboxCodemodeAuthority } from "../environment.js";
7
+ import { rigProviderImageSourceImage } from "../packs.js";
8
+ import type { TurnActivityServices as ActivityServices, RunAgentTurnInput } from "../types.js";
9
+ import type { currentActivityContext } from "../streaming.js";
10
+ import { type ResumedTurnSandbox } from "../../sandbox-resume.js";
11
+ import { makeMachineOpObserver } from "../../observability-metrics.js";
12
+ import { ToolResultSpill } from "./tool-result-spill.js";
13
+ import type { createTurnMediaArtifacts } from "./media-artifacts.js";
14
+ import { sandboxEstablishPolicyDecision } from "./sandbox-route.js";
15
+ import type { ClaimTurnOk } from "./claim.js";
16
+ import type { GovernanceModelOk } from "./governance-model.js";
17
+ import type { SandboxTurnRuntime } from "./sandbox-runtime.js";
18
+ import type { AttemptIdentityState, EventingState, SandboxRuntimeState } from "./turn-context.js";
19
+ export type SandboxRouteDeps = {
20
+ input: RunAgentTurnInput;
21
+ settings: Settings;
22
+ db: ActivityServices["db"];
23
+ eventing: EventingState;
24
+ sandboxState: SandboxRuntimeState;
25
+ media: ReturnType<typeof createTurnMediaArtifacts>;
26
+ fileAuthoritySubjectId: ClaimTurnOk["fileAuthoritySubjectId"];
27
+ runSettings: GovernanceModelOk["runSettings"];
28
+ };
29
+ export type SandboxRouteOk = {
30
+ routingOn: boolean;
31
+ activeSandboxPointer: Awaited<ReturnType<typeof readActiveSandbox>>;
32
+ activeSandboxRecord: SandboxRecord | null;
33
+ activeSandboxBackend: Settings["sandboxBackend"] | undefined;
34
+ machinePrimary: boolean;
35
+ groupBoxBackend: Settings["sandboxBackend"];
36
+ groupBoxImage: ReturnType<typeof rigProviderImageSourceImage>;
37
+ sandboxCreationBackend: Settings["sandboxBackend"];
38
+ effectiveRunCredentialBackend: Settings["sandboxBackend"];
39
+ };
40
+ export type EstablishTurnSandboxDeps = SandboxRouteOk & {
41
+ input: RunAgentTurnInput;
42
+ settings: Settings;
43
+ db: ActivityServices["db"];
44
+ bus: ActivityServices["bus"];
45
+ objectStorage: ActivityServices["objectStorage"];
46
+ observability: ActivityServices["observability"];
47
+ cancellationSignal: AbortSignal | undefined;
48
+ runtimeCancellationSignal: AbortSignal | undefined;
49
+ sandboxResumeSignal: AbortSignal;
50
+ activityContext: ReturnType<typeof currentActivityContext>;
51
+ opJournal: ClaimTurnOk["opJournal"];
52
+ sandboxState: SandboxRuntimeState;
53
+ eventing: EventingState;
54
+ attempt: AttemptIdentityState;
55
+ turn: ClaimTurnOk["turn"];
56
+ session: ClaimTurnOk["session"];
57
+ fileAuthoritySubjectId: ClaimTurnOk["fileAuthoritySubjectId"];
58
+ capabilitySettings: ClaimTurnOk["capabilitySettings"];
59
+ turnExecutionPolicy: ClaimTurnOk["turnExecutionPolicy"];
60
+ runSettings: GovernanceModelOk["runSettings"];
61
+ logicalSandboxSettings: GovernanceModelOk["logicalSandboxSettings"];
62
+ verifiedRigProviderImageId: GovernanceModelOk["verifiedRigProviderImageId"];
63
+ runtimePreparationStartedAt: number;
64
+ establishPolicy: ReturnType<typeof sandboxEstablishPolicyDecision>["policy"];
65
+ sandboxEnvironment: Record<string, string>;
66
+ startRunGitCredentialsMint: () => Promise<MintedRunGitCredentials | undefined>;
67
+ machineOpObserver: ReturnType<typeof makeMachineOpObserver>;
68
+ sandboxOperationObserver: ReturnType<typeof sandboxOperationMetricObserver>;
69
+ sandboxRuntime: SandboxTurnRuntime;
70
+ transientCodemodeEnvironment: (() => Readonly<Record<string, string>>) | undefined;
71
+ rigVersion: GovernanceModelOk["rigVersion"];
72
+ turnResources: ReturnType<typeof mergeResourceRefs>;
73
+ };
74
+ export type BindLazySandboxProvisionerDeps = EstablishTurnSandboxDeps & {
75
+ agent: ReturnType<ActivityServices["runtime"]["buildAgent"]>;
76
+ attachRunCredentialRenewal: (credentialSession: RunCredentialCommandSession, initialMaterial: NormalizedRunCredentialMaterial | null, initialSandbox?: ResumedTurnSandbox) => Promise<void>;
77
+ attachGitCredentialRenewal: (tokenSession: GitCredentialTokenWriterSession, initial: MintedRunGitCredentials | undefined, initialSandbox?: ResumedTurnSandbox) => Promise<void>;
78
+ attachCodemodeTokenRenewal: (tokenSession?: CodemodeTokenWriterSession, initialExpiresAt?: Date, initialSandbox?: ResumedTurnSandbox) => Promise<void>;
79
+ throwIfWorkerShuttingDown: () => void;
80
+ throwIfTurnCancelled: () => void;
81
+ initialRunCredentialMaterial: NormalizedRunCredentialMaterial | null;
82
+ sandboxCodemodeToken: string | undefined;
83
+ media: ReturnType<typeof createTurnMediaArtifacts>;
84
+ toolResultSpill: ToolResultSpill;
85
+ connectionScope: {
86
+ accountId: string;
87
+ workspaceId: string;
88
+ };
89
+ codemodeAuthority: SandboxCodemodeAuthority;
90
+ };
91
+ export declare function resolveSandboxRoute(deps: SandboxRouteDeps): Promise<SandboxRouteOk>;
92
+ export declare function establishTurnSandbox(deps: EstablishTurnSandboxDeps): Promise<void>;
93
+ export declare function bindLazySandboxProvisioner(deps: BindLazySandboxProvisionerDeps): Promise<void>;
@@ -0,0 +1,89 @@
1
+ import { type Settings } from "@opengeni/config";
2
+ import { CancelledFailure } from "@temporalio/activity";
3
+ import { type SandboxLogicalProvisionCategory, type SandboxLogicalProvisionStage } from "../../observability-metrics.js";
4
+ export type TurnSandboxProvisioner<T> = {
5
+ get(): Promise<T>;
6
+ hasStarted(): boolean;
7
+ waitForSettled(timeoutMs: number): Promise<T | null>;
8
+ };
9
+ export type SandboxLogicalProvisionFailure = {
10
+ category: SandboxLogicalProvisionCategory;
11
+ stage: SandboxLogicalProvisionStage;
12
+ code: string;
13
+ expected: boolean;
14
+ retryable: boolean;
15
+ };
16
+ export type TurnSandboxProvisionAttempt<T = unknown> = {
17
+ provisionId: string;
18
+ attempt: number;
19
+ outcome: "completed" | "retrying" | "failed";
20
+ durationMs: number;
21
+ result?: T;
22
+ error?: unknown;
23
+ };
24
+ export type TurnSandboxProvisionSettlement = {
25
+ provisionId: string;
26
+ internalAttempts: number;
27
+ durationMs: number;
28
+ };
29
+ export declare class TurnOperationCancelledError extends Error {
30
+ readonly reason: unknown;
31
+ readonly name = "TurnOperationCancelledError";
32
+ constructor(reason: unknown);
33
+ }
34
+ export declare class SandboxDeadlineRotationError extends Error {
35
+ readonly sandboxGroupId: string;
36
+ readonly leaseEpoch: number;
37
+ readonly name = "SandboxDeadlineRotationError";
38
+ constructor(sandboxGroupId: string, leaseEpoch: number);
39
+ }
40
+ /**
41
+ * Normalize a preparation/provisioning cancellation race back to the Temporal
42
+ * cancellation that owns the activity. Several provider APIs expose no portable
43
+ * abort primitive, so the worker stops awaiting them and disposes any late
44
+ * resource. The wrapper error must never fall through as an ordinary turn
45
+ * failure: doing so would omit the quiescence receipt and strand a committed
46
+ * Steer/Pause behind `control-pending`.
47
+ */
48
+ export declare function turnOperationCancellationFailure(error: unknown): CancelledFailure | null;
49
+ export declare function throwIfTurnOperationCancelled(signal: AbortSignal | undefined): void;
50
+ export declare function waitForTurnOperation<T>(operation: Promise<T>, signal: AbortSignal | undefined, disposeLateResult: ((result: T) => Promise<void> | void) | undefined): Promise<T>;
51
+ export declare function sleep(ms: number): Promise<void>;
52
+ export declare function sandboxProvisionErrorChain(error: unknown): unknown[];
53
+ export declare function firstProvisionError<T>(chain: readonly unknown[], constructor: abstract new (...args: never[]) => T): T | null;
54
+ /**
55
+ * Closed, structural taxonomy for one logical provision failure. The classifier
56
+ * follows only typed wrapper/cause links and provider status/code fields; it
57
+ * never infers lifecycle truth from an arbitrary error message.
58
+ */
59
+ export declare function classifySandboxLogicalProvisionFailure(backend: string, error: unknown): SandboxLogicalProvisionFailure;
60
+ export declare function isLazySandboxProvisionRetryable(error: unknown): boolean;
61
+ /** Short workflow-visible anti-churn pacing after a lifecycle transition. The
62
+ * next acquire waits on the exact durable claim itself, so this is deliberately
63
+ * not a guessed snapshot-plus-schedules completion time. */
64
+ export declare function sandboxDeadlineRotationRecoveryDelayMs(settings: Pick<Settings, "sandboxLeaseReaperPeriodMs">): number;
65
+ export declare function createTurnSandboxProvisioner<T>(establish: () => Promise<T>, options?: {
66
+ maxRetries?: number;
67
+ backoffMs?: number;
68
+ signal?: AbortSignal;
69
+ provisionIdFactory?: () => string;
70
+ onStarted?: (settlement: Pick<TurnSandboxProvisionSettlement, "provisionId">) => Promise<void> | void;
71
+ onAttemptSettled?: (attempt: TurnSandboxProvisionAttempt<T>) => Promise<void> | void;
72
+ beforeCompleted?: (result: T, settlement: TurnSandboxProvisionSettlement) => Promise<void> | void;
73
+ onCompleted?: (result: T, settlement: TurnSandboxProvisionSettlement) => Promise<void> | void;
74
+ onFailed?: (error: unknown, settlement: TurnSandboxProvisionSettlement) => Promise<void> | void;
75
+ disposeResult?: (result: T) => Promise<void> | void;
76
+ }): TurnSandboxProvisioner<T>;
77
+ /**
78
+ * Decide whether THIS turn may send OpenAI's `prompt_cache_key` request field.
79
+ *
80
+ * Accepted transports:
81
+ * - legacy/built-in OpenAI or Azure Responses fallback (resolvedModel null);
82
+ * - resolved built-in OpenAI/Azure providers;
83
+ * - ChatGPT/Codex subscription backend (its strict allowlist permits the field).
84
+ *
85
+ * Registry API-key providers are intentionally excluded. Fireworks' prompt-cache
86
+ * docs prescribe `user` or `x-session-affinity`, not `prompt_cache_key`; Z.AI/GLM
87
+ * documents automatic context caching plus `user_id`. Sending OpenAI-only fields
88
+ * to unknown OpenAI-compatible providers risks unsupported-parameter 400s.
89
+ */
@@ -0,0 +1,151 @@
1
+ import { type ActiveSandboxPointer, type SandboxRecord } from "@opengeni/db";
2
+ import { type BackendUnresolvableCode } from "@opengeni/runtime";
3
+ import { type Settings } from "@opengeni/config";
4
+ import type { TurnActivityServices as ActivityServices } from "../types.js";
5
+ import { type TurnSandboxLeaseHolderId } from "../../sandbox-resume.js";
6
+ import { type TurnSandboxEstablishReason } from "../../observability-metrics.js";
7
+ import { type SessionEventType } from "@opengeni/contracts";
8
+ export declare function resolveActiveSandboxBackend(routingOn: boolean, loadPointer: () => Promise<{
9
+ activeSandboxId: string | null;
10
+ } | null>, loadSandboxKind: (sandboxId: string) => Promise<string | null>): Promise<Settings["sandboxBackend"] | undefined>;
11
+ /**
12
+ * Managed-sandbox ownership exists only when this turn actually uses the
13
+ * managed home. A Connected Machine is fenced by its active-route epoch and
14
+ * must remain independent from cloud recovery state for the same session.
15
+ */
16
+ export declare function managedSandboxOwnershipForTurn(machinePrimary: boolean, attemptId: string, sandboxGroupId: string): {
17
+ holderId: TurnSandboxLeaseHolderId;
18
+ sandboxGroupId: string;
19
+ } | null;
20
+ /** A sandboxless home still establishes an explicitly attached Connected Machine. */
21
+ export declare function shouldEstablishSandboxForTurn(sandboxOwnershipEnabled: boolean, homeBackend: Settings["sandboxBackend"], machinePrimary: boolean): boolean;
22
+ export declare function sandboxEstablishPolicyDecision(input: {
23
+ lazyEnabled: boolean;
24
+ machinePrimary: boolean;
25
+ sandboxBackend: Settings["sandboxBackend"];
26
+ hasRunCredentialResolver: boolean;
27
+ generatedVideoFileCount: number;
28
+ hasSignedFileResources: boolean;
29
+ }): {
30
+ policy: "eager" | "on-demand";
31
+ reason: TurnSandboxEstablishReason;
32
+ };
33
+ /**
34
+ * Repo-backed workspace skills bind into the first-request prompt-cache prefix
35
+ * (`WorkspaceSkillsCapability.instructions()` listDirs the live box). Starting
36
+ * the managed-box establish as soon as its inputs exist lets Modal create overlap
37
+ * tools/history/agent; `get()` still owns clone/setup after `buildAgent`.
38
+ *
39
+ * Do not flip those turns to eager: that serializes create BEFORE tools and
40
+ * increases first-token latency. Chat-only turns without a repository still
41
+ * never create a box. Portable `/compact` returns before this path. Connected
42
+ * Machines and `backend: none` have no managed Modal/docker create to overlap.
43
+ */
44
+ export declare function shouldPrefetchManagedSandbox(input: {
45
+ establishPolicy: "eager" | "on-demand";
46
+ machinePrimary: boolean;
47
+ groupBoxBackend: Settings["sandboxBackend"];
48
+ hasRepositoryResources: boolean;
49
+ }): boolean;
50
+ /**
51
+ * Classify a persisted active-sandbox pointer for TURN-START RECONCILE (issue #341
52
+ * invariant B). Returns the typed reason to RESET the pointer to the session HOME,
53
+ * or null to leave it in place. STRUCTURAL unestablishability only:
54
+ * - no record → the pointed-at sandbox row is gone (`stale_pointer`);
55
+ * - an unestablishable kind (a non-group Modal sibling, or an unknown backend) per
56
+ * the SHARED `swapTargetEstablishability` predicate (`unsupported_backend_context`);
57
+ * - a selfhosted sandbox with no enrollment id to address (`offline_enrollment`).
58
+ * A selfhosted sandbox WITH an enrollment is deliberately left in place even when it
59
+ * is momentarily offline: the machine may recover mid-turn and its ops surface
60
+ * agent_offline lazily, so the user's explicit machine target is never abandoned for
61
+ * a transient control-plane blip (that is #339's concern, not this one).
62
+ */
63
+ export declare function pointerReconcileReason(record: {
64
+ kind: string;
65
+ enrollmentId: string | null;
66
+ } | null): BackendUnresolvableCode | null;
67
+ /** The active pointer + its sandbox row, loaded once at turn start and threaded
68
+ * through the reconcile so the establish branch reads the SAME (possibly reset)
69
+ * values with no second query. */
70
+ export type LoadedActivePointer = {
71
+ pointer: ActiveSandboxPointer | null;
72
+ record: SandboxRecord | null;
73
+ };
74
+ /**
75
+ * TURN-START RECONCILE (issue #341 invariant B / Shapes 1+2). If the persisted pointer's
76
+ * target is STRUCTURALLY unestablishable ({@link pointerReconcileReason}) reset the pointer
77
+ * to the session HOME (null) under the epoch fence, emit a VISIBLE `session.route.reconciled`
78
+ * event, and return the reconciled pointer/record so the rest of the turn runs on home. NEVER
79
+ * a silent downgrade. Bounded to ONE attempt: a lost CAS means a concurrent user swap won a
80
+ * higher epoch, so re-read + honor it rather than clobber a newer, user-directed pointer. The
81
+ * event publish is best-effort — a publish failure never fails the turn.
82
+ *
83
+ * FAIL-OPEN on a lookup failure (issue #341 review): the sandbox row is fetched HERE via the
84
+ * caller's NON-swallowing `loadRecord`, so a null decision means the row is genuinely absent,
85
+ * never a suppressed transient DB error. If `loadRecord` THROWS, reconciliation is skipped
86
+ * entirely this turn — the pointer is left UNTOUCHED (record null → the turn runs
87
+ * machinePrimary:false on the group box exactly as before reconcile existed), no CAS, no
88
+ * event — and the next turn retries. A TRANSIENT LOOKUP FAILURE MUST NEVER MUTATE THE POINTER.
89
+ */
90
+ export declare function reconcileActiveSandboxPointer(db: ActivityServices["db"], ids: {
91
+ accountId: string;
92
+ workspaceId: string;
93
+ sessionId: string;
94
+ }, pointer: ActiveSandboxPointer | null, loadRecord: (sandboxId: string) => Promise<SandboxRecord | null>, publish?: (events: Array<{
95
+ type: SessionEventType;
96
+ payload: unknown;
97
+ }>) => Promise<void> | void): Promise<LoadedActivePointer>;
98
+ /**
99
+ * Warm the Modal private-registry image for the image ref this turn actually
100
+ * resolved, not only the deployment-global OPENGENI_MODAL_IMAGE_REF warmed at
101
+ * worker boot. A provider-native modalImageId bypasses registry import and is
102
+ * resolved by ModalImageSelector.fromId during create. Otherwise packs can
103
+ * override `modalImageRef` per workspace/turn, so a private pack image must be
104
+ * resolved before sandbox creation or Modal falls back to the unauthenticated
105
+ * `fromTag` path.
106
+ */
107
+ export declare function ensureTurnModalRegistryImage(runSettings: Settings, sandboxCreationBackend: Settings["sandboxBackend"] | undefined, ensureRegistryImage?: (settings: Settings) => Promise<void>): Promise<void>;
108
+ export declare const SANDBOX_ARTIFACT_RUNTIME_MANIFEST = "/opt/opengeni/artifact-runtime/installation.json";
109
+ export declare const SANDBOX_ARTIFACT_TOOL_ENTRY = "/opt/opengeni/artifact-runtime/skill-facade-entry.mjs";
110
+ export type SandboxArtifactRuntimeAdmission = Readonly<{
111
+ available: boolean;
112
+ environment: Readonly<Record<string, string>>;
113
+ }>;
114
+ /**
115
+ * Admit the optional native standalone-file runtime only for the deployment's
116
+ * exact base sandbox image contract. A pack/rig image override is an
117
+ * independent filesystem and therefore fails closed even when the deployment
118
+ * base image is capable. Collaborative artifact skills are admitted separately
119
+ * from the frozen canonical tool catalog.
120
+ *
121
+ * This keeps lazy provisioning intact: CI/release proves the image closure,
122
+ * while a before-agent-start doctor verifies the actual box before any model
123
+ * call. No speculative sandbox is created merely to populate the skill index.
124
+ */
125
+ export declare function sandboxArtifactRuntimeAdmission(deploymentSettings: Settings, runSettings: Settings, backend: Settings["sandboxBackend"] | undefined, options?: Readonly<{
126
+ production?: boolean;
127
+ }>): SandboxArtifactRuntimeAdmission;
128
+ /**
129
+ * Decide whether the first actual computer action may start a proof recording.
130
+ *
131
+ * On-turn recording runs ffmpeg/x11grab INSIDE the box and reads the .mp4 back
132
+ * out of the box's /tmp — plumbing that exists only for OpenGeni-operated cloud
133
+ * boxes (the Modal desktop backend). A turn whose EFFECTIVE backend is a connected
134
+ * machine ("selfhosted") runs on the user's REAL computer, which has none of that
135
+ * capture plumbing (and the platform must never shell ffmpeg onto a user's machine
136
+ * — the same reason the runtime skips its setup hooks for selfhosted). Left ungated
137
+ * it films nothing, finds no /tmp file, and emits recording.started followed by
138
+ * recording.failed{box-death} on EVERY machine-primary turn — misleading timeline
139
+ * noise + wasted work. So gate it off, exactly like a recording-disabled deployment:
140
+ * skip silently, emit nothing (no new event shape).
141
+ *
142
+ * `effectiveBackend` is the resolved ACTIVE backend for the turn
143
+ * (resolveActiveSandboxBackend) — NOT the session's home backend. A modal-home
144
+ * session actively swapped onto a machine resolves to "selfhosted" here and
145
+ * correctly skips; a machine-home turn that degraded back to its cloud group box
146
+ * (swap-away / flag-off) resolves to undefined and records as before.
147
+ *
148
+ * EDGE — mid-turn swap: this is evaluated once when computer-use first runs. A swap
149
+ * after recording starts is deliberately ignored; the partial recording already has
150
+ * defined failure semantics, so there is no stop/restart machinery.
151
+ */
@@ -0,0 +1,44 @@
1
+ import { type EstablishedSandboxSession } from "@opengeni/runtime";
2
+ import { type Settings } from "@opengeni/config";
3
+ import { currentActivityContext } from "../streaming.js";
4
+ import type { TurnActivityServices as ActivityServices, RunAgentTurnInput } from "../types.js";
5
+ import { type ResumedTurnSandbox } from "../../sandbox-resume.js";
6
+ import type { AttemptIdentityState, EventingState, RecordingState, SandboxRuntimeState } from "./turn-context.js";
7
+ export type SandboxTurnRuntimeDeps = {
8
+ input: RunAgentTurnInput;
9
+ settings: Settings;
10
+ db: ActivityServices["db"];
11
+ objectStorage: ActivityServices["objectStorage"];
12
+ observability: ActivityServices["observability"];
13
+ cancellationSignal: AbortSignal | undefined;
14
+ activityContext: ReturnType<typeof currentActivityContext>;
15
+ sandboxRotationController: AbortController;
16
+ sandboxState: SandboxRuntimeState;
17
+ recordingState: RecordingState;
18
+ eventing: EventingState;
19
+ attempt: AttemptIdentityState;
20
+ };
21
+ export type SandboxTurnRuntime = ReturnType<typeof createSandboxTurnRuntime>;
22
+ export declare function createSandboxTurnRuntime(deps: SandboxTurnRuntimeDeps): {
23
+ releaseLateSandbox: (sandbox: ResumedTurnSandbox) => Promise<void>;
24
+ requireResolvedSandboxForMutation: (message: string) => ResumedTurnSandbox;
25
+ finalizeTurnOpStreamOps: () => Promise<void>;
26
+ onHomeSandboxRebound: (rebound: {
27
+ established: EstablishedSandboxSession;
28
+ leaseEpoch: number;
29
+ }) => void;
30
+ runWorkspaceMutationForSandbox: <T>(sandbox: ResumedTurnSandbox, operation: string, mutation: () => Promise<T>, observePhase?: (measurement: {
31
+ phase: "admission" | "provider" | "settlement" | "snapshot_wait";
32
+ outcome: "completed" | "failed";
33
+ durationSeconds: number;
34
+ }) => void) => Promise<T>;
35
+ stopLeaseHeartbeat: () => void;
36
+ abandonActiveRecording: (reason: string, disposition?: "failed" | "discard") => Promise<void>;
37
+ flushRuntimeBatcher: () => Promise<void>;
38
+ publishSandboxLifecycleEvents: (sandbox: ResumedTurnSandbox) => Promise<void>;
39
+ publishSandboxLost: (lostSandbox: {
40
+ instanceId: string;
41
+ }) => Promise<void>;
42
+ startLeaseHeartbeat: (sandbox: ResumedTurnSandbox, warmBackend: Settings["sandboxBackend"] | undefined) => void;
43
+ maybeStartOnTurnRecording: (sandbox: ResumedTurnSandbox, effectiveBackend: Settings["sandboxBackend"] | undefined) => Promise<void>;
44
+ };
@@ -0,0 +1,107 @@
1
+ import { getSessionEvent, getHumanInputResumeForEvent } from "@opengeni/db";
2
+ import { type SandboxFileDownload, type HistoryProviderApi, type GitCredentialTokenWriterSession, type NormalizedRunCredentialMaterial, type RunCredentialCommandSession, type CodemodeTokenWriterSession } from "@opengeni/runtime";
3
+ import { type Settings } from "@opengeni/config";
4
+ import { maybeCompactContext } from "../context-compaction.js";
5
+ import { type MintedRunGitCredentials } from "../environment.js";
6
+ import { withFirstPartyTools } from "../goals.js";
7
+ import { currentActivityContext } from "../streaming.js";
8
+ import type { TurnActivityServices as ActivityServices, RunAgentTurnInput, RunAgentTurnResult } from "../types.js";
9
+ import { type ResumedTurnSandbox } from "../../sandbox-resume.js";
10
+ import { ToolResultSpill } from "./tool-result-spill.js";
11
+ import { createTurnCredentialLeases } from "./credential-leases.js";
12
+ import { createTurnMediaArtifacts } from "./media-artifacts.js";
13
+ import { createTurnHistorySink } from "./history-sink.js";
14
+ import { type SessionEvent } from "@opengeni/contracts";
15
+ import { createModelCheckpointMemoryCollector } from "../../model-checkpoint-memory-collector.js";
16
+ import { TurnEventPublisher } from "./model-usage.js";
17
+ import type { CompactionSummarizer } from "../context-compaction.js";
18
+ import type { TurnExecutionPolicyV1 } from "@opengeni/contracts";
19
+ import type { BoundRunCredentialResolver } from "../run-credentials.js";
20
+ import type { ModelHistoryAttachmentProjector } from "../run-input.js";
21
+ import type { AttemptIdentityState, BillingState, ClaimedResult, EventingState, ProviderTurnState, SandboxRuntimeState, TurnControlState } from "./turn-context.js";
22
+ export type TurnStreamAttemptDeps = {
23
+ input: RunAgentTurnInput;
24
+ settings: Settings;
25
+ db: ActivityServices["db"];
26
+ runtime: ActivityServices["runtime"];
27
+ objectStorage: ActivityServices["objectStorage"];
28
+ observability: ActivityServices["observability"];
29
+ entitlements: ActivityServices["entitlements"];
30
+ startVideoGenerationWorkflow: ActivityServices["startVideoGenerationWorkflow"];
31
+ cancellationSignal: AbortSignal | undefined;
32
+ runtimeCancellationSignal: AbortSignal;
33
+ activityContext: ReturnType<typeof currentActivityContext>;
34
+ dispatchId: string;
35
+ control: TurnControlState;
36
+ attempt: AttemptIdentityState;
37
+ billingState: BillingState;
38
+ sandboxState: SandboxRuntimeState;
39
+ eventing: EventingState & {
40
+ publish: TurnEventPublisher;
41
+ settle: NonNullable<EventingState["settle"]>;
42
+ };
43
+ providerTurn: ProviderTurnState;
44
+ leases: ReturnType<typeof createTurnCredentialLeases>;
45
+ historySink: ReturnType<typeof createTurnHistorySink>;
46
+ media: ReturnType<typeof createTurnMediaArtifacts>;
47
+ toolResultSpill: ToolResultSpill;
48
+ claimedResult: ClaimedResult;
49
+ flushRuntimeBatcher: () => Promise<void>;
50
+ finalizeTurnOpStreamOps: () => Promise<void>;
51
+ runWorkspaceMutationForSandbox: <T>(sandbox: ResumedTurnSandbox, operation: string, mutation: () => Promise<T>, observePhase?: (measurement: {
52
+ phase: "admission" | "provider" | "settlement" | "snapshot_wait";
53
+ outcome: "completed" | "failed";
54
+ durationSeconds: number;
55
+ }) => void) => Promise<T>;
56
+ throwIfWorkerShuttingDown: () => void;
57
+ throwIfTurnCancelled: () => void;
58
+ setLastInputTokensFenced: (lastInputTokens: number | null) => Promise<void>;
59
+ attachGitCredentialRenewal: (tokenSession: GitCredentialTokenWriterSession, initial: MintedRunGitCredentials | undefined, initialSandbox?: ResumedTurnSandbox) => Promise<void>;
60
+ attachCodemodeTokenRenewal: (tokenSession?: CodemodeTokenWriterSession, initialExpiresAt?: Date, initialSandbox?: ResumedTurnSandbox) => Promise<void>;
61
+ attachRunCredentialRenewal: (credentialSession: RunCredentialCommandSession, initialMaterial: NormalizedRunCredentialMaterial | null, initialSandbox?: ResumedTurnSandbox) => Promise<void>;
62
+ withProviderRequestContext: <T>(fn: () => Promise<T>) => Promise<T>;
63
+ publishCompactionLiveEvents: (events: SessionEvent[]) => Promise<void>;
64
+ publishCompactionOutcomeEvents: (events: SessionEvent[]) => Promise<void>;
65
+ recordCompanyBrainContributionReceiptOnce: () => void;
66
+ modelCheckpointMemoryCollector: ReturnType<typeof createModelCheckpointMemoryCollector>;
67
+ claimedModelUsageSourceKeys: Set<string>;
68
+ emittedModelUsageSourceKeys: Set<string>;
69
+ modelUsageDispatchId: string;
70
+ workerPreparationStartedAt: number;
71
+ fileDownloadsMaterializedForRun: boolean;
72
+ unavailableSandboxFilesNote: string | undefined;
73
+ runCredentialsNote: string | undefined;
74
+ mcpAvailabilityNote: string | undefined;
75
+ fileAuthoritySubjectId: string | null;
76
+ activeSandboxBackend: Settings["sandboxBackend"] | undefined;
77
+ groupBoxBackend: Settings["sandboxBackend"];
78
+ turnExecutionPolicy: TurnExecutionPolicyV1;
79
+ turn: {
80
+ executionGeneration: number;
81
+ model: string;
82
+ };
83
+ trigger: NonNullable<Awaited<ReturnType<typeof getSessionEvent>>>;
84
+ humanInputResume: Awaited<ReturnType<typeof getHumanInputResumeForEvent>>;
85
+ agent: ReturnType<ActivityServices["runtime"]["buildAgent"]>;
86
+ resolvedModel: ReturnType<ActivityServices["runtime"]["resolveTurnModel"]>;
87
+ providerApi: HistoryProviderApi;
88
+ runSettings: Settings;
89
+ turnTools: ReturnType<typeof withFirstPartyTools>;
90
+ compactSummarizer: CompactionSummarizer;
91
+ compactionModelHistoryProjector: (items: Array<Record<string, unknown>>) => Promise<Array<Record<string, unknown>>>;
92
+ generatedImageHistoryProjector: (items: Array<Record<string, unknown>>) => Promise<Array<Record<string, unknown>>>;
93
+ modelHistoryProjector: ModelHistoryAttachmentProjector;
94
+ compactionModeOptions: NonNullable<Parameters<typeof maybeCompactContext>[5]>;
95
+ initialRunCredentialMaterial: NormalizedRunCredentialMaterial | null;
96
+ initialGitCredentials: MintedRunGitCredentials | undefined;
97
+ sandboxEnvironment: Record<string, string>;
98
+ sandboxCodemodeToken: string | undefined;
99
+ sandboxCodemodeTokenExpiresAt: Date | string | number | null | undefined;
100
+ fileResourceDownloads: SandboxFileDownload[];
101
+ runCredentialResolver: BoundRunCredentialResolver | null;
102
+ videoGenerationAcceptancesByCallId: Map<string, {
103
+ operationId: string;
104
+ requestDigest: string;
105
+ }>;
106
+ };
107
+ export declare function runTurnStreamAttempt(deps: TurnStreamAttemptDeps): Promise<RunAgentTurnResult>;
@@ -0,0 +1,142 @@
1
+ import { type AttemptConnectorActionBinding } from "@opengeni/runtime";
2
+ import { type Settings } from "@opengeni/config";
3
+ import { withFirstPartyTools } from "../goals.js";
4
+ import type { TurnActivityServices as ActivityServices, RunAgentTurnInput } from "../types.js";
5
+ import { ToolResultSpill } from "./tool-result-spill.js";
6
+ import { createTurnMediaArtifacts } from "./media-artifacts.js";
7
+ import type { ClaimTurnOk } from "./claim.js";
8
+ import type { GovernanceModelOk } from "./governance-model.js";
9
+ import type { SandboxTurnRuntime } from "./sandbox-runtime.js";
10
+ import type { sandboxArtifactRuntimeAdmission } from "./sandbox-route.js";
11
+ import type { AttemptIdentityState, EventingState, SandboxRuntimeState, WorkspaceRefState } from "./turn-context.js";
12
+ export type PrepareTurnToolPolicyDeps = {
13
+ input: RunAgentTurnInput;
14
+ db: ActivityServices["db"];
15
+ cancellationSignal: AbortSignal | undefined;
16
+ connectionCredentials: ActivityServices["connectionCredentials"];
17
+ turn: ClaimTurnOk["turn"];
18
+ session: ClaimTurnOk["session"];
19
+ fileAuthoritySubjectId: ClaimTurnOk["fileAuthoritySubjectId"];
20
+ capabilitySettings: ClaimTurnOk["capabilitySettings"];
21
+ runSettings: GovernanceModelOk["runSettings"];
22
+ rigVersion: GovernanceModelOk["rigVersion"];
23
+ workspaceRefs: WorkspaceRefState;
24
+ };
25
+ export type PrepareTurnToolRuntimeDeps = {
26
+ input: RunAgentTurnInput;
27
+ db: ActivityServices["db"];
28
+ bus: ActivityServices["bus"];
29
+ runtime: ActivityServices["runtime"];
30
+ objectStorage: ActivityServices["objectStorage"];
31
+ observability: ActivityServices["observability"];
32
+ cancellationSignal: AbortSignal | undefined;
33
+ connectionCredentials: ActivityServices["connectionCredentials"];
34
+ eventing: EventingState;
35
+ attempt: AttemptIdentityState;
36
+ sandboxState: SandboxRuntimeState;
37
+ media: ReturnType<typeof createTurnMediaArtifacts>;
38
+ toolResultSpill: ToolResultSpill;
39
+ turn: ClaimTurnOk["turn"];
40
+ session: ClaimTurnOk["session"];
41
+ fileAuthoritySubjectId: ClaimTurnOk["fileAuthoritySubjectId"];
42
+ capabilitySettings: ClaimTurnOk["capabilitySettings"];
43
+ installedApiIntegrations: ClaimTurnOk["installedApiIntegrations"];
44
+ codexAppsCredentialId: ClaimTurnOk["codexAppsCredentialId"];
45
+ turnExecutionPolicy: ClaimTurnOk["turnExecutionPolicy"];
46
+ trigger: ClaimTurnOk["trigger"];
47
+ runSettings: GovernanceModelOk["runSettings"];
48
+ lazyToolTransport: GovernanceModelOk["lazyToolTransport"];
49
+ turnTools: ReturnType<typeof withFirstPartyTools>;
50
+ connectionScope: {
51
+ accountId: string;
52
+ workspaceId: string;
53
+ };
54
+ hostCredentialRootSessionId: string | null;
55
+ sandboxArtifactRuntime: ReturnType<typeof sandboxArtifactRuntimeAdmission>;
56
+ activeSandboxBackend: Settings["sandboxBackend"] | undefined;
57
+ groupBoxBackend: Settings["sandboxBackend"];
58
+ routingOn: boolean;
59
+ runtimeCancellationSignal: AbortSignal | undefined;
60
+ credentialSubjectId: ClaimTurnOk["credentialSubjectId"];
61
+ interactionInterventionResume: ClaimTurnOk["interactionInterventionResume"];
62
+ runWorkspaceMutationForSandbox: SandboxTurnRuntime["runWorkspaceMutationForSandbox"];
63
+ throwIfWorkerShuttingDown: () => void;
64
+ throwIfTurnCancelled: () => void;
65
+ };
66
+ export declare function prepareTurnToolPolicy(deps: PrepareTurnToolPolicyDeps): Promise<{
67
+ turnResources: ({
68
+ kind: "repository";
69
+ uri: string;
70
+ ref: string;
71
+ expectedCommitSha?: string | undefined;
72
+ mountPath?: string | undefined;
73
+ subpath?: string | undefined;
74
+ provider?: "azure_devops" | "github" | "gitlab" | undefined;
75
+ connectionType?: "github_personal" | undefined;
76
+ credentialBindingId?: string | undefined;
77
+ access?: "read" | "write" | undefined;
78
+ repositoryId?: string | number | undefined;
79
+ installationId?: string | number | undefined;
80
+ projectId?: string | number | undefined;
81
+ connectionId?: string | undefined;
82
+ githubInstallationId?: number | undefined;
83
+ githubRepositoryId?: number | undefined;
84
+ } | {
85
+ kind: "file";
86
+ fileId: string;
87
+ mountPath?: string | undefined;
88
+ })[];
89
+ runtimeResources: ({
90
+ kind: "repository";
91
+ uri: string;
92
+ ref: string;
93
+ expectedCommitSha?: string | undefined;
94
+ mountPath?: string | undefined;
95
+ subpath?: string | undefined;
96
+ provider?: "azure_devops" | "github" | "gitlab" | undefined;
97
+ connectionType?: "github_personal" | undefined;
98
+ credentialBindingId?: string | undefined;
99
+ access?: "read" | "write" | undefined;
100
+ repositoryId?: string | number | undefined;
101
+ installationId?: string | number | undefined;
102
+ projectId?: string | number | undefined;
103
+ connectionId?: string | undefined;
104
+ githubInstallationId?: number | undefined;
105
+ githubRepositoryId?: number | undefined;
106
+ } | {
107
+ kind: "file";
108
+ fileId: string;
109
+ mountPath?: string | undefined;
110
+ })[];
111
+ mcpAvailabilityNote: string | undefined;
112
+ turnTools: {
113
+ kind: "mcp";
114
+ id: string;
115
+ eager?: boolean | undefined;
116
+ optional?: boolean | undefined;
117
+ }[];
118
+ connectionScope: {
119
+ accountId: string;
120
+ workspaceId: string;
121
+ };
122
+ workspaceVariableSet: import("@opengeni/db").VariableSetForRun | null;
123
+ sandboxWorkspaceEnvironmentValues: Record<string, string>;
124
+ }>;
125
+ export declare function prepareTurnToolRuntime(deps: PrepareTurnToolRuntimeDeps): Promise<{
126
+ attemptConnectorActionBindings: AttemptConnectorActionBinding[];
127
+ connectorActionIdentity: {
128
+ readonly accountId: string;
129
+ readonly workspaceId: string;
130
+ readonly sessionId: string;
131
+ readonly turnId: string;
132
+ readonly attemptId: string;
133
+ readonly executionGeneration: number;
134
+ readonly initiator: {
135
+ readonly kind: "service" | "subject";
136
+ readonly subjectId: string;
137
+ };
138
+ };
139
+ postToolPreparationStartedAt: number;
140
+ }>;
141
+ export type PrepareTurnToolPolicyOk = Awaited<ReturnType<typeof prepareTurnToolPolicy>>;
142
+ export type PrepareTurnToolRuntimeOk = Awaited<ReturnType<typeof prepareTurnToolRuntime>>;