@opengeni/worker-bundle 0.16.29 → 0.20.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 (188) hide show
  1. package/dist/activities/agent-run-admission.d.ts +12 -0
  2. package/dist/activities/agent-turn.d.ts +110 -19
  3. package/dist/activities/api-integrations.d.ts +21 -0
  4. package/dist/activities/browser-state-artifact-reaper.d.ts +29 -0
  5. package/dist/activities/capabilities.d.ts +6 -0
  6. package/dist/activities/codemode-dispatcher.d.ts +35 -0
  7. package/dist/activities/codemode-token-renewal.d.ts +23 -0
  8. package/dist/activities/codex-capacity.d.ts +6 -5
  9. package/dist/activities/codex-image-generation.d.ts +21 -0
  10. package/dist/activities/context-compaction.d.ts +1 -0
  11. package/dist/activities/documents.d.ts +3 -2
  12. package/dist/activities/environment.d.ts +17 -8
  13. package/dist/activities/expiring-material-renewal.d.ts +1 -1
  14. package/dist/activities/file-upload-reaper.d.ts +7 -2
  15. package/dist/activities/gateway-image-generation.d.ts +39 -0
  16. package/dist/activities/gateway-video-generation.d.ts +53 -0
  17. package/dist/activities/generated-images.d.ts +112 -0
  18. package/dist/activities/git-credential-renewal.d.ts +1 -1
  19. package/dist/activities/goals.d.ts +2 -2
  20. package/dist/activities/google-drive-changes.d.ts +99 -0
  21. package/dist/activities/image-generation-operation.d.ts +74 -0
  22. package/dist/activities/image-generation-references.d.ts +25 -0
  23. package/dist/activities/knowledge-source-sync-driver.d.ts +23 -0
  24. package/dist/activities/knowledge-source-sync.d.ts +75 -0
  25. package/dist/activities/packs.d.ts +21 -36
  26. package/dist/activities/parent-wake.d.ts +1 -1
  27. package/dist/activities/retained-screenshot-reaper.d.ts +2 -2
  28. package/dist/activities/retained-screenshots.d.ts +36 -0
  29. package/dist/activities/rig-verification.d.ts +82 -5
  30. package/dist/activities/run-credential-renewal.d.ts +1 -1
  31. package/dist/activities/run-input.d.ts +3 -1
  32. package/dist/activities/sandbox-images.d.ts +14 -0
  33. package/dist/activities/sandbox-lease.d.ts +47 -9
  34. package/dist/activities/scheduled-tasks.d.ts +2 -2
  35. package/dist/activities/session-state.d.ts +7 -5
  36. package/dist/activities/site-auth-maintenance.d.ts +27 -0
  37. package/dist/activities/streaming.d.ts +1 -1
  38. package/dist/activities/types.d.ts +87 -5
  39. package/dist/activities/video-generation-admission.d.ts +43 -0
  40. package/dist/activities/video-generation-credential.d.ts +24 -0
  41. package/dist/activities/video-generation-reconciliation.d.ts +13 -0
  42. package/dist/activities/video-media-validation.d.ts +34 -0
  43. package/dist/activities/video-output-retention.d.ts +36 -0
  44. package/dist/activities/video-reference-staging.d.ts +55 -0
  45. package/dist/activities/workflow-wake.d.ts +2 -2
  46. package/dist/activities/workspace-capture.d.ts +10 -1
  47. package/dist/activities/xai-auth.d.ts +23 -0
  48. package/dist/activities/xai-image-generation.d.ts +26 -0
  49. package/dist/activities/xai-video-generation.d.ts +18 -0
  50. package/dist/activities-control-XURE4VKN.js +7221 -0
  51. package/dist/activities-control-XURE4VKN.js.map +1 -0
  52. package/dist/activities-control.d.ts +297 -0
  53. package/dist/activities-turn-6EBXGGLS.js +16036 -0
  54. package/dist/activities-turn-6EBXGGLS.js.map +1 -0
  55. package/dist/activities-turn.d.ts +17 -0
  56. package/dist/activities.d.ts +138 -150
  57. package/dist/activity-services.d.ts +10 -0
  58. package/dist/artifact-materializer-entry.d.ts +6 -0
  59. package/dist/artifact-materializer-entry.js +2662 -0
  60. package/dist/artifact-materializer-entry.js.map +1 -0
  61. package/dist/artifact-outbox-entry.d.ts +2 -0
  62. package/dist/artifact-outbox-entry.js +681 -0
  63. package/dist/artifact-outbox-entry.js.map +1 -0
  64. package/dist/chunk-5GRJIP5H.js +3092 -0
  65. package/dist/chunk-5GRJIP5H.js.map +1 -0
  66. package/dist/chunk-GRFQTTSQ.js +448 -0
  67. package/dist/chunk-GRFQTTSQ.js.map +1 -0
  68. package/dist/chunk-TYNPCG4U.js +906 -0
  69. package/dist/chunk-TYNPCG4U.js.map +1 -0
  70. package/dist/concurrency.d.ts +108 -5
  71. package/dist/editable-artifact-hint-broker.d.ts +49 -0
  72. package/dist/editable-artifact-materializer-launcher.d.ts +49 -0
  73. package/dist/editable-artifact-materializer-service.d.ts +108 -0
  74. package/dist/editable-artifact-materializer-storage.d.ts +12 -0
  75. package/dist/editable-artifact-materializer-subprocess.d.ts +50 -0
  76. package/dist/editable-artifact-materializer.d.ts +262 -0
  77. package/dist/editable-artifact-outbox-dispatcher.d.ts +44 -0
  78. package/dist/editable-artifact-outbox-service.d.ts +70 -0
  79. package/dist/host-export.d.ts +1 -1
  80. package/dist/index.d.ts +189 -10
  81. package/dist/index.js +715 -17380
  82. package/dist/index.js.map +1 -1
  83. package/dist/memory-pressure-guard.d.ts +57 -0
  84. package/dist/model-checkpoint-memory-collector.d.ts +23 -0
  85. package/dist/model-context-contributions.d.ts +40 -0
  86. package/dist/observability-metrics.d.ts +53 -1
  87. package/dist/sandbox-reaper-contract.d.ts +40 -0
  88. package/dist/sandbox-reaper-timeout.d.ts +14 -0
  89. package/dist/sandbox-resume.d.ts +34 -7
  90. package/dist/sandbox-routing.d.ts +6 -0
  91. package/dist/worker-service-lifecycle.d.ts +6 -2
  92. package/dist/workflow-bundle.js +1094 -370
  93. package/dist/workflows/activities.d.ts +8 -2
  94. package/dist/workflows/document-index.d.ts +1 -1
  95. package/dist/workflows/knowledge-source-sync.d.ts +13 -0
  96. package/dist/workflows/rig-verification.d.ts +1 -1
  97. package/dist/workflows/sandbox-reaper.d.ts +8 -0
  98. package/dist/workflows/scheduled-tasks.d.ts +1 -1
  99. package/dist/workflows/session.d.ts +2 -2
  100. package/dist/workflows/site-auth-maintenance.d.ts +2 -0
  101. package/dist/workflows/video-generation.d.ts +10 -0
  102. package/dist/workflows/workflow-wake.d.ts +1 -1
  103. package/dist/workflows.d.ts +10 -7
  104. package/package.json +35 -15
  105. package/src/activities/agent-run-admission.ts +76 -0
  106. package/src/activities/agent-turn.ts +2600 -340
  107. package/src/activities/api-integrations.ts +138 -0
  108. package/src/activities/browser-state-artifact-reaper.ts +120 -0
  109. package/src/activities/capabilities.ts +10 -0
  110. package/src/activities/codemode-dispatcher.ts +335 -0
  111. package/src/activities/codemode-token-renewal.ts +64 -0
  112. package/src/activities/codex-capacity.ts +54 -7
  113. package/src/activities/codex-image-generation.ts +56 -0
  114. package/src/activities/context-compaction.ts +38 -3
  115. package/src/activities/documents.ts +14 -4
  116. package/src/activities/environment.ts +54 -45
  117. package/src/activities/expiring-material-renewal.ts +1 -1
  118. package/src/activities/file-upload-reaper.ts +34 -3
  119. package/src/activities/gateway-image-generation.ts +146 -0
  120. package/src/activities/gateway-video-generation.ts +298 -0
  121. package/src/activities/generated-images.ts +860 -0
  122. package/src/activities/goals.ts +8 -3
  123. package/src/activities/google-drive-changes.ts +454 -0
  124. package/src/activities/image-generation-operation.ts +333 -0
  125. package/src/activities/image-generation-references.ts +118 -0
  126. package/src/activities/knowledge-source-sync-driver.ts +27 -0
  127. package/src/activities/knowledge-source-sync.ts +2840 -0
  128. package/src/activities/mcp-credentials.ts +1 -0
  129. package/src/activities/packs.ts +75 -152
  130. package/src/activities/parent-wake.ts +13 -1
  131. package/src/activities/retained-screenshot-reaper.ts +2 -2
  132. package/src/activities/retained-screenshots.ts +453 -28
  133. package/src/activities/rig-verification.ts +554 -43
  134. package/src/activities/run-input.ts +22 -6
  135. package/src/activities/sandbox-images.ts +167 -0
  136. package/src/activities/sandbox-lease.ts +1065 -483
  137. package/src/activities/scheduled-tasks.ts +104 -74
  138. package/src/activities/session-state.ts +22 -4
  139. package/src/activities/site-auth-maintenance.ts +269 -0
  140. package/src/activities/streaming.ts +42 -3
  141. package/src/activities/types.ts +104 -5
  142. package/src/activities/video-generation-admission.ts +303 -0
  143. package/src/activities/video-generation-credential.ts +112 -0
  144. package/src/activities/video-generation-reconciliation.ts +771 -0
  145. package/src/activities/video-media-validation.ts +332 -0
  146. package/src/activities/video-output-retention.ts +314 -0
  147. package/src/activities/video-reference-staging.ts +350 -0
  148. package/src/activities/workflow-wake.ts +2 -2
  149. package/src/activities/workspace-capture.ts +44 -10
  150. package/src/activities/xai-auth.ts +122 -0
  151. package/src/activities/xai-image-generation.ts +86 -0
  152. package/src/activities/xai-video-generation.ts +69 -0
  153. package/src/activities-control.ts +58 -0
  154. package/src/activities-turn.ts +40 -0
  155. package/src/activities.ts +53 -124
  156. package/src/activity-services.ts +62 -0
  157. package/src/artifact-materializer-entry.ts +35 -0
  158. package/src/artifact-outbox-entry.ts +29 -0
  159. package/src/concurrency.ts +484 -6
  160. package/src/editable-artifact-hint-broker.ts +235 -0
  161. package/src/editable-artifact-materializer-launcher.ts +515 -0
  162. package/src/editable-artifact-materializer-service.ts +787 -0
  163. package/src/editable-artifact-materializer-storage.ts +413 -0
  164. package/src/editable-artifact-materializer-subprocess.ts +956 -0
  165. package/src/editable-artifact-materializer.ts +1289 -0
  166. package/src/editable-artifact-outbox-dispatcher.ts +244 -0
  167. package/src/editable-artifact-outbox-service.ts +438 -0
  168. package/src/index.ts +328 -72
  169. package/src/memory-pressure-guard.ts +489 -0
  170. package/src/model-checkpoint-memory-collector.ts +123 -0
  171. package/src/model-context-contributions.ts +159 -0
  172. package/src/observability-metrics.ts +297 -13
  173. package/src/sandbox-reaper-contract.ts +73 -0
  174. package/src/sandbox-reaper-timeout.ts +79 -0
  175. package/src/sandbox-resume.ts +294 -153
  176. package/src/sandbox-routing.ts +32 -24
  177. package/src/worker-service-lifecycle.ts +80 -14
  178. package/src/workflows/activities.ts +31 -0
  179. package/src/workflows/file-upload-reaper.ts +9 -1
  180. package/src/workflows/knowledge-source-sync.ts +83 -0
  181. package/src/workflows/sandbox-reaper.ts +183 -21
  182. package/src/workflows/scheduled-tasks.ts +42 -6
  183. package/src/workflows/session.ts +20 -6
  184. package/src/workflows/site-auth-maintenance.ts +14 -0
  185. package/src/workflows/video-generation.ts +36 -0
  186. package/src/workflows.ts +18 -1
  187. package/dist/activities/toolspace-token-renewal.d.ts +0 -23
  188. package/src/activities/toolspace-token-renewal.ts +0 -64
@@ -0,0 +1,12 @@
1
+ import { type Settings } from "@opengeni/config";
2
+ import type { ControlActivityServices } from "./types.js";
3
+ export type AgentRunAdmissionDenial = "insufficient_credits" | "monthly_model_cost_limit" | "monthly_agent_run_limit";
4
+ /** One worker-side admission boundary for service-authored agent runs. */
5
+ export declare function agentRunAdmissionDenial(services: Pick<ControlActivityServices, "db" | "entitlements"> & {
6
+ settings: Settings;
7
+ }, input: {
8
+ accountId: string;
9
+ workspaceId: string;
10
+ model: string;
11
+ requestedAgentRuns: number;
12
+ }): Promise<AgentRunAdmissionDenial | null>;
@@ -1,14 +1,14 @@
1
- import { type AppendEventInput, type ActiveSandboxPointer, type SandboxRecord } from "@opengeni/db";
2
- import { modelResponseServiceTierFromSdkEvent, modelTerminalResponseFromSdkEvent, type SandboxFileDownload, type ComputerToolMode, type ModelResponseUsage, type ModelCallUsageInput, type ModelCallUsageNormalization, type TurnToolCancellationFence, type BackendUnresolvableCode } from "@opengeni/runtime";
1
+ import { type AppendEventInput, type ActiveSandboxPointer, type SandboxRecord, type SessionAttemptQuiescenceCommit } from "@opengeni/db";
2
+ import { modelResponseServiceTierFromSdkEvent, modelTerminalResponseFromSdkEvent, type SandboxFileDownload, type ComputerToolMode, type ModelResponseUsage, type ModelCallUsageInput, type ModelCallUsageNormalization, type TurnToolCancellationFence, type BackendUnresolvableCode, type LazyToolTransport } from "@opengeni/runtime";
3
3
  import { resolveTurnExecutionPolicyV1, type ModelUsageInput, type ModelProviderApi, type RegistryProviderKind, type Settings } from "@opengeni/config";
4
4
  import { ApplicationFailure, CancelledFailure } from "@temporalio/activity";
5
5
  import type { CodexAccountStatus } from "@opengeni/db";
6
- import { type GitCredentialRenewalController } from "./git-credential-renewal";
7
- import { type RunCredentialRenewalController } from "./run-credential-renewal";
8
- import { type ToolspaceTokenRenewalController } from "./toolspace-token-renewal";
9
- import { type ModelAttachmentInputPolicy } from "./run-input";
10
- import type { ActivityServices, EscapedMcpTimeoutRecoveryDetail, RunAgentTurnInput, RunAgentTurnResult, SessionAttemptQuiescenceProof } from "./types";
11
- import { type TurnSandboxLeaseHolderId } from "../sandbox-resume";
6
+ import { type GitCredentialRenewalController } from "./git-credential-renewal.js";
7
+ import { type RunCredentialRenewalController } from "./run-credential-renewal.js";
8
+ import { type CodemodeTokenRenewalController } from "./codemode-token-renewal.js";
9
+ import { type ModelAttachmentInputPolicy } from "./run-input.js";
10
+ import type { TurnActivityServices as ActivityServices, EscapedMcpTimeoutRecoveryDetail, RunAgentTurnInput, RunAgentTurnResult, SessionAttemptQuiescenceProof } from "./types.js";
11
+ import { type ResumedTurnSandbox, type TurnSandboxLeaseHolderId } from "../sandbox-resume.js";
12
12
  import { type LatencyMode, type SessionEvent, type SessionEventType, type SessionTurn, type ToolAuthNeededPayload, type TurnExecutionPolicyV1 } from "@opengeni/contracts";
13
13
  export declare const PROVIDER_BACKPRESSURE_DELAY_MS = 60000;
14
14
  export declare class WorkspaceHumanInputDisabledError extends Error {
@@ -35,6 +35,7 @@ export declare function shouldPublishToolAuthNeededForTurn(payload: Pick<ToolAut
35
35
  export declare function turnExecutionPolicyBillingIdentity(policy: TurnExecutionPolicyV1): {
36
36
  externallyBilled: boolean;
37
37
  codexSubscription: boolean;
38
+ xaiSubscription: boolean;
38
39
  };
39
40
  export declare function legacyTurnExecutionPolicyInput(turn: Pick<SessionTurn, "source" | "model" | "reasoningEffort" | "latencyMode">): Parameters<typeof resolveTurnExecutionPolicyV1>[1];
40
41
  /** A retryable provider fault recovers the accepted turn itself. Goal state is
@@ -91,6 +92,8 @@ export declare function filterUnmaterializedSandboxFileDownloads(downloads: Sand
91
92
  export declare function codexWorkspaceMetricKey(workspaceId: string): string;
92
93
  /** Stable public request identity across partial resumes and activity retries. */
93
94
  export declare function stableHumanInputRequestId(sessionId: string, turnId: string, toolCallId: string): string;
95
+ export declare function stableInteractionInterventionId(sessionId: string, turnId: string, toolCallId: string): string;
96
+ export declare function stableInteractionInterventionOperationId(sessionId: string, turnId: string, toolCallId: string): string;
94
97
  /**
95
98
  * True when this activity attempt was cancelled because its hosting worker is
96
99
  * shutting down gracefully (SIGTERM during a deploy), as opposed to a
@@ -133,12 +136,14 @@ export declare function assertSessionAttemptQuiescenceRecoveryDurable(input: {
133
136
  * state. The proof object never changes between attempts. */
134
137
  export declare function persistOrSignalSessionAttemptQuiescence(input: {
135
138
  proof: SessionAttemptQuiescenceProof;
136
- persistReceipt: () => Promise<SessionEvent[]>;
139
+ persistReceipt: () => Promise<SessionAttemptQuiescenceCommit>;
140
+ deliverWorkflowWake?: (wake: NonNullable<SessionAttemptQuiescenceCommit["workflowWake"]>) => Promise<unknown>;
137
141
  publishEvents: (events: SessionEvent[]) => Promise<unknown>;
138
142
  signalProof: ActivityServices["signalSessionAttemptQuiesced"];
139
143
  sleep?: (ms: number) => Promise<void>;
140
144
  heartbeat?: (attempt: number, delayMs: number) => void;
141
145
  onReceiptFailure?: (error: unknown) => void;
146
+ onWakeFailure?: (error: unknown) => void;
142
147
  onPublishFailure?: (error: unknown) => void;
143
148
  onSignalFailure?: (error: unknown, attempt: number, delayMs: number) => void;
144
149
  }): Promise<"receipt" | "signal">;
@@ -153,9 +158,19 @@ export declare function drainAttemptOwnedSandboxWriters(input: {
153
158
  toolCancellationFence: Pick<TurnToolCancellationFence, "cancel" | "waitForQuiescence"> | null;
154
159
  cancellationReason?: unknown;
155
160
  gitCredentialRenewals: readonly Pick<GitCredentialRenewalController, "stop">[];
156
- toolspaceTokenRenewal: Pick<ToolspaceTokenRenewalController, "stop"> | null;
161
+ codemodeTokenRenewal: Pick<CodemodeTokenRenewalController, "stop"> | null;
157
162
  runCredentialRenewal: Pick<RunCredentialRenewalController, "stop"> | null;
158
163
  }): Promise<void>;
164
+ /** Persist the exact turn's second-stage release only after the caller has
165
+ * crossed the physical writer boundary. This wait is intentionally independent
166
+ * of Temporal cancellation: it is a short idempotent DB transaction that closes
167
+ * the durable archive-capture fence. Bounded retries cover a rollout connection
168
+ * reset without turning ordinary finalizer housekeeping into lifecycle state. */
169
+ export declare function releaseTurnSandboxAfterWriterDrain(sandbox: Pick<ResumedTurnSandbox, "release">, options?: {
170
+ maxAttempts?: number;
171
+ retryDelayMs?: number;
172
+ wait?: (delayMs: number) => Promise<void>;
173
+ }): Promise<void>;
159
174
  /**
160
175
  * Await a finalizer operation only while this Temporal activity still owns its
161
176
  * execution window. Once Pause/Steer cancellation arrives, the operation keeps
@@ -494,6 +509,8 @@ export declare function managedSandboxOwnershipForTurn(machinePrimary: boolean,
494
509
  holderId: TurnSandboxLeaseHolderId;
495
510
  sandboxGroupId: string;
496
511
  } | null;
512
+ /** A sandboxless home still establishes an explicitly attached Connected Machine. */
513
+ export declare function shouldEstablishSandboxForTurn(sandboxOwnershipEnabled: boolean, homeBackend: Settings["sandboxBackend"], machinePrimary: boolean): boolean;
497
514
  /**
498
515
  * Classify a persisted active-sandbox pointer for TURN-START RECONCILE (issue #341
499
516
  * invariant B). Returns the typed reason to RESET the pointer to the session HOME,
@@ -552,6 +569,24 @@ export declare function reconcileActiveSandboxPointer(db: ActivityServices["db"]
552
569
  * `fromTag` path.
553
570
  */
554
571
  export declare function ensureTurnModalRegistryImage(runSettings: Settings, sandboxCreationBackend: Settings["sandboxBackend"] | undefined, ensureRegistryImage?: (settings: Settings) => Promise<void>): Promise<void>;
572
+ export type SandboxArtifactRuntimeAdmission = Readonly<{
573
+ available: boolean;
574
+ environment: Readonly<Record<string, string>>;
575
+ }>;
576
+ /**
577
+ * Admit the optional native standalone-file runtime only for the deployment's
578
+ * exact base sandbox image contract. A pack/rig image override is an
579
+ * independent filesystem and therefore fails closed even when the deployment
580
+ * base image is capable. Collaborative artifact skills are admitted separately
581
+ * from the frozen canonical tool catalog.
582
+ *
583
+ * This keeps lazy provisioning intact: CI/release proves the image closure,
584
+ * while a before-agent-start doctor verifies the actual box before any model
585
+ * call. No speculative sandbox is created merely to populate the skill index.
586
+ */
587
+ export declare function sandboxArtifactRuntimeAdmission(deploymentSettings: Settings, runSettings: Settings, backend: Settings["sandboxBackend"] | undefined, options?: Readonly<{
588
+ production?: boolean;
589
+ }>): SandboxArtifactRuntimeAdmission;
555
590
  /**
556
591
  * Decide whether the first actual computer action may start a proof recording.
557
592
  *
@@ -623,6 +658,21 @@ export declare function structuredToolTransportForTurn(resolvedModel: {
623
658
  kind: RegistryProviderKind;
624
659
  };
625
660
  } | null): boolean;
661
+ /**
662
+ * Progressive tool disclosure is universal for supported OpenGeni turns; only
663
+ * its contained transport differs. Codex keeps its native path, built-in direct
664
+ * OpenAI/Azure Responses use native client tool search, and every other ordinary
665
+ * function-calling provider uses OpenGeni's stable search/invoke dispatcher.
666
+ */
667
+ export declare function lazyToolTransportForTurn(resolvedModel: {
668
+ provider: {
669
+ id: string;
670
+ kind: RegistryProviderKind;
671
+ api: ModelProviderApi;
672
+ builtin: boolean;
673
+ baseUrl?: string | undefined;
674
+ };
675
+ } | null): LazyToolTransport;
626
676
  /**
627
677
  * Native web search is a runtime capability, not part of the session's MCP
628
678
  * allow-list. Attach it whenever the resolved provider advertises runnable
@@ -635,6 +685,37 @@ export declare function hostedWebSearchForTurn(resolvedModel: {
635
685
  hostedWebSearch: boolean;
636
686
  };
637
687
  } | null, deploymentWebSearchEnabled: boolean): boolean;
688
+ /**
689
+ * Image generation is an optional connected-account capability. A delegated
690
+ * subscription may still authorize the text model without carrying the local
691
+ * credential identity required for paid image operations; that must narrow the
692
+ * tool catalog, not reject an otherwise valid turn.
693
+ */
694
+ export declare function connectedSubscriptionImageGenerationAuthority<T>(credentialContext: T | null | undefined, credentialId: string | null | undefined): {
695
+ credentialContext: T;
696
+ credentialId: string;
697
+ } | null;
698
+ /** Direct OpenAI hosted image IDs are reusable only by the exact API credential. */
699
+ export declare function openAiHostedImageProviderBindingForTurn(settings: Pick<Settings, "openaiProvider" | "openaiApiKey" | "openaiBaseUrl">, resolvedModel: {
700
+ provider: {
701
+ id: string;
702
+ kind: RegistryProviderKind;
703
+ builtin: boolean;
704
+ baseUrl?: string | undefined;
705
+ };
706
+ configured: {
707
+ capabilities: {
708
+ hostedTools: {
709
+ imageGeneration: {
710
+ runnable: boolean;
711
+ };
712
+ };
713
+ };
714
+ };
715
+ } | null): {
716
+ providerId: string;
717
+ providerBindingHash: string;
718
+ } | null;
638
719
  /** Exact model-catalog modality gate; null preserves the legacy built-in path. */
639
720
  export declare function modelSupportsImageInputForTurn(resolvedModel: {
640
721
  configured: {
@@ -682,15 +763,10 @@ export declare class SandboxDeadlineRotationError extends Error {
682
763
  export declare function turnOperationCancellationFailure(error: unknown): CancelledFailure | null;
683
764
  export declare function waitForTurnOperation<T>(operation: Promise<T>, signal: AbortSignal | undefined, disposeLateResult: ((result: T) => Promise<void> | void) | undefined): Promise<T>;
684
765
  export declare function isLazySandboxProvisionRetryable(error: unknown): boolean;
685
- /**
686
- * Deadline recovery cannot re-admit the same turn until the global reaper has
687
- * observed the released holder, captured the final archive, terminated the old
688
- * provider box, and committed the lease cold. Give that full sequence one
689
- * snapshot budget plus two schedule periods. This is workflow-visible pacing,
690
- * not an in-memory sleep, so Pause/Steer/new user intent can still wake the
691
- * durable session immediately.
692
- */
693
- export declare function sandboxDeadlineRotationRecoveryDelayMs(settings: Pick<Settings, "sandboxLeaseReaperPeriodMs" | "sandboxSnapshotTimeoutMs">): number;
766
+ /** Short workflow-visible anti-churn pacing after a lifecycle transition. The
767
+ * next acquire waits on the exact durable claim itself, so this is deliberately
768
+ * not a guessed snapshot-plus-schedules completion time. */
769
+ export declare function sandboxDeadlineRotationRecoveryDelayMs(settings: Pick<Settings, "sandboxLeaseReaperPeriodMs">): number;
694
770
  export declare function createTurnSandboxProvisioner<T>(establish: () => Promise<T>, options?: {
695
771
  maxRetries?: number;
696
772
  backoffMs?: number;
@@ -732,6 +808,16 @@ type OpStreamFinalizer = {
732
808
  export declare function finalizeDurableTurnOpStreams(sessions: readonly unknown[], fallback: OpStreamFinalizer | null): Promise<void>;
733
809
  export declare function createRunAgentTurnActivity(services: () => Promise<ActivityServices>): (input: RunAgentTurnInput) => Promise<RunAgentTurnResult>;
734
810
  export declare function isTransientProviderError(error: unknown): boolean;
811
+ export type XaiCredentialFailure = {
812
+ kind: "auth" | "forbidden" | "rate_limit";
813
+ cooldownMs: number | null;
814
+ };
815
+ /**
816
+ * Only definitive SuperGrok account refusals may move the same logical turn to
817
+ * another credential. The marked transport response proves inference was
818
+ * rejected before a stream began; refresh relogin is equally definitive.
819
+ */
820
+ export declare function classifyXaiCredentialFailure(error: unknown): XaiCredentialFailure | null;
735
821
  export declare function agentRunFailurePayload(error: unknown, options?: {
736
822
  isCodexTurn?: boolean;
737
823
  }): {
@@ -793,6 +879,8 @@ export declare function pendingToolCallFromSdkEvent(event: unknown): {
793
879
  callName: string | null;
794
880
  callItem: Record<string, unknown>;
795
881
  } | null;
882
+ /** Tools whose intentional visual result must survive inline-media sanitization. */
883
+ export declare function toolCallProducesRetainableSessionImage(name: string | null): boolean;
796
884
  export declare function completedToolCallFromSdkEvent(event: unknown): {
797
885
  callId: string;
798
886
  resultItem: Record<string, unknown>;
@@ -802,6 +890,9 @@ export type ModelUsageBillingRecord = {
802
890
  billingPath: "opengeni_credits" | "external";
803
891
  /** Same quantity written to usage_events.model.cost when present; else 0. */
804
892
  pricedCostMicros: number;
893
+ /** Hypothetical provider-rate USD micros; never an OpenGeni charge. */
894
+ estimatedProviderCostMicros: number | null;
895
+ pricingSource: "configured_list_price" | "gateway_reported" | null;
805
896
  normalizedUsage: ModelCallUsageNormalization;
806
897
  upstreamProvider?: string;
807
898
  };
@@ -0,0 +1,21 @@
1
+ import { type IntegrationInvocationAuthority } from "@opengeni/capabilities";
2
+ import type { Settings } from "@opengeni/config";
3
+ import type { ToolAuthNeededPayload } from "@opengeni/contracts";
4
+ import type { ApiIntegrationRuntime, ResolveConnectionCredentialInput, ResolveConnectionCredentialResult } from "@opengeni/db";
5
+ import type { LocalMcpServerRegistration } from "@opengeni/runtime";
6
+ import type { FetchLike } from "@opengeni/network";
7
+ export type BuildApiIntegrationServersInput = {
8
+ settings: Settings;
9
+ integrations: readonly ApiIntegrationRuntime[];
10
+ authority: Omit<IntegrationInvocationAuthority, "connectionRef">;
11
+ resolveCredential: (input: ResolveConnectionCredentialInput) => Promise<ResolveConnectionCredentialResult>;
12
+ onAuthNeeded?: (payload: ToolAuthNeededPayload) => Promise<void> | void;
13
+ fetchImpl?: FetchLike;
14
+ };
15
+ /**
16
+ * Compile active persisted API facets into ordinary in-process MCP servers for
17
+ * one exact attempt. Connection resolution remains request-time, destination-
18
+ * bound, personal-delegation-fenced, and refreshable through the same worker
19
+ * resolver used by remote MCP servers.
20
+ */
21
+ export declare function buildApiIntegrationServersForTurn(input: BuildApiIntegrationServersInput): LocalMcpServerRegistration[];
@@ -0,0 +1,29 @@
1
+ import { claimBrowserStateArtifactCleanup, claimBrowserStateUploadCleanup, completeBrowserStateArtifactCleanup, completeBrowserStateUploadCleanup, type BrowserStateArtifactCleanupClaim, type BrowserStateUploadCleanupClaim } from "@opengeni/db";
2
+ import type { ObjectStorage } from "@opengeni/storage";
3
+ import type { ControlActivityServices } from "./types.js";
4
+ export declare const BROWSER_STATE_ARTIFACT_CLAIM_TIMEOUT_MS: number;
5
+ export declare const BROWSER_STATE_ARTIFACT_CLEANUP_BATCH_SIZE = 100;
6
+ export type MaintainBrowserStateArtifactsResult = {
7
+ claimed: number;
8
+ deleted: number;
9
+ retryable: number;
10
+ };
11
+ export type BrowserStateArtifactMaintenanceOptions = {
12
+ claimTimeoutMs?: number;
13
+ batchSize?: number;
14
+ claimArtifacts?: typeof claimBrowserStateArtifactCleanup;
15
+ completeArtifact?: typeof completeBrowserStateArtifactCleanup;
16
+ claimUploads?: typeof claimBrowserStateUploadCleanup;
17
+ completeUpload?: typeof completeBrowserStateUploadCleanup;
18
+ /** Failure-injection seam; production uses the configured provider delete. */
19
+ deleteObject?: (storage: ObjectStorage, key: string) => Promise<void>;
20
+ };
21
+ /**
22
+ * Reap retired encrypted private browser checkpoints. Provider deletion happens
23
+ * before terminal settlement; a crash or provider failure leaves the durable
24
+ * claim reclaimable and an already-deleted provider key is safe to retry.
25
+ */
26
+ export declare function createBrowserStateArtifactMaintenanceActivities(services: () => Promise<ControlActivityServices>, options?: BrowserStateArtifactMaintenanceOptions): {
27
+ maintainBrowserStateArtifacts: () => Promise<MaintainBrowserStateArtifactsResult>;
28
+ };
29
+ export type { BrowserStateArtifactCleanupClaim, BrowserStateUploadCleanupClaim };
@@ -16,4 +16,10 @@ export declare function settingsWithSessionMcpServers(settings: Settings, server
16
16
  export declare function settingsWithCodexCredential(db: Database, workspaceId: string, settings: Settings, activeOverride?: boolean): Promise<Settings>;
17
17
  /** Pure: append the synthetic codex-subscription provider, idempotently. */
18
18
  export declare function withCodexProvider(settings: Settings): Settings;
19
+ /**
20
+ * Pure: append the synthetic SuperGrok/xAI subscription provider,
21
+ * idempotently. The overlay is catalogue metadata only; the exact account,
22
+ * authority snapshot, and bearer remain frozen later at turn admission.
23
+ */
24
+ export declare function withXaiSubscriptionProvider(settings: Settings): Settings;
19
25
  export declare function settingsWithWorkspaceGatewayCredential(db: Database, workspaceId: string, settings: Settings): Promise<Settings>;
@@ -0,0 +1,35 @@
1
+ import { type AttemptToolEnvironment } from "@opengeni/codemode";
2
+ import { type Database } from "@opengeni/db";
3
+ import { type EventBus } from "@opengeni/events";
4
+ export type CodemodeDispatcherScope = {
5
+ accountId: string;
6
+ workspaceId: string;
7
+ sessionId: string;
8
+ turnId: string;
9
+ attemptId: string;
10
+ executionGeneration: number;
11
+ };
12
+ /**
13
+ * Owns the only Codemode execution edge for one exact attempt. NATS carries a
14
+ * wake-up only; the durable row is claimed before any side effect and the call
15
+ * is executed by the same AttemptToolEnvironment already bound to model MCP.
16
+ */
17
+ export declare class CodemodeAttemptDispatcher {
18
+ private readonly db;
19
+ private readonly bus;
20
+ private readonly environment;
21
+ private readonly scope;
22
+ private readonly turnSignal?;
23
+ private readonly maxConcurrentCalls;
24
+ private readonly stopController;
25
+ private readonly inFlight;
26
+ private pendingClaims;
27
+ private unsubscribe;
28
+ private closing;
29
+ constructor(db: Database, bus: EventBus, environment: AttemptToolEnvironment, scope: CodemodeDispatcherScope, turnSignal?: AbortSignal | undefined, maxConcurrentCalls?: number);
30
+ start(): void;
31
+ close(reason?: string): Promise<void>;
32
+ private execute;
33
+ private settleWithOutput;
34
+ private failBeforeExecution;
35
+ }
@@ -0,0 +1,23 @@
1
+ import { type ExpiringMaterialRenewalController } from "./expiring-material-renewal.js";
2
+ import type { MintedSandboxCodemodeToken } from "./environment.js";
3
+ export declare const CODEMODE_TOKEN_DEFAULT_REFRESH_MS: number;
4
+ export declare const CODEMODE_TOKEN_EXPIRY_LEAD_MS: number;
5
+ export declare const CODEMODE_TOKEN_MIN_REFRESH_MS = 5000;
6
+ export declare const CODEMODE_TOKEN_MAX_RETRY_MS: number;
7
+ export type CodemodeTokenRenewalController = ExpiringMaterialRenewalController;
8
+ export type CodemodeTokenRenewalOptions = {
9
+ initialExpiresAt: Date;
10
+ mint: () => Promise<MintedSandboxCodemodeToken | undefined>;
11
+ write: (material: MintedSandboxCodemodeToken) => Promise<void>;
12
+ now?: () => number;
13
+ schedule?: (callback: () => void, delayMs: number) => unknown;
14
+ clearSchedule?: (timer: unknown) => void;
15
+ onSuccess?: (result: {
16
+ nextDelayMs: number;
17
+ }) => void;
18
+ onFailure?: (failure: {
19
+ retryDelayMs: number;
20
+ errorClass: "CodemodeTokenRenewalOperationError";
21
+ }) => void;
22
+ };
23
+ export declare function startCodemodeTokenRenewalLoop(options: CodemodeTokenRenewalOptions): CodemodeTokenRenewalController;
@@ -1,9 +1,9 @@
1
1
  import { reconcileCodexCapacityWait as reconcileCodexCapacityWaitDb, type CodexCapacityWakeTarget, type CodexCapacitySelectionContext } from "@opengeni/db";
2
2
  import type { Settings } from "@opengeni/config";
3
- import type { ActivityServices, GetCodexCapacityWaitInput, ReconcileCodexCapacityWaitInput, ReconcileCodexCapacityWaitResult } from "./types";
3
+ import type { ControlActivityServices, GetCodexCapacityWaitInput, ReconcileCodexCapacityWaitInput, ReconcileCodexCapacityWaitResult } from "./types.js";
4
4
  type CodexCapacitySignalServices = {
5
- signalCodexCapacityWorkflow?: NonNullable<ActivityServices["signalCodexCapacityWorkflow"]> | null | undefined;
6
- wakeSessionWorkflow: ActivityServices["wakeSessionWorkflow"];
5
+ signalCodexCapacityWorkflow?: NonNullable<ControlActivityServices["signalCodexCapacityWorkflow"]> | null | undefined;
6
+ wakeSessionWorkflow: ControlActivityServices["wakeSessionWorkflow"];
7
7
  };
8
8
  /**
9
9
  * Run a bounded set of usage refreshes, then repair every committed waiter
@@ -16,11 +16,12 @@ export declare function refreshCodexUsageAndRepairCapacityWaiters(refreshes: rea
16
16
  export declare function signalCodexCapacityWakeTargets(services: CodexCapacitySignalServices, targets: readonly CodexCapacityWakeTarget[]): Promise<void>;
17
17
  /** Repair a commit/signal crash edge by redelivering every pending revision. */
18
18
  export declare function signalPendingCodexCapacityWakeTargets(services: CodexCapacitySignalServices & {
19
- db: ActivityServices["db"];
19
+ db: ControlActivityServices["db"];
20
20
  }, workspaceId: string): Promise<void>;
21
21
  export declare function codexCapacityDecision(context: CodexCapacitySelectionContext, settings: Settings): ReturnType<Parameters<typeof reconcileCodexCapacityWaitDb>[2]>;
22
- export declare function createCodexCapacityActivities(services: () => Promise<ActivityServices>): {
22
+ export declare function createCodexCapacityActivities(services: () => Promise<ControlActivityServices>): {
23
23
  getCodexCapacityWait: (input: GetCodexCapacityWaitInput) => Promise<{
24
+ provider?: "xai";
24
25
  waiterId: string;
25
26
  generation: number;
26
27
  nextCheckAt: string;
@@ -0,0 +1,21 @@
1
+ import { type CodexRequestContext } from "@opengeni/codex";
2
+ import type { Database } from "@opengeni/db";
3
+ import type { ObjectStorage } from "@opengeni/storage";
4
+ import type { GeneratedImageReceipt } from "./generated-images.js";
5
+ import type { ResolvedImageGenerationReference } from "./image-generation-references.js";
6
+ /** Execute the same standalone subscription image path used by Codex clients. */
7
+ export declare function executeCodexImageGeneration(input: {
8
+ db: Database;
9
+ objectStorage: ObjectStorage | null;
10
+ accountId: string;
11
+ workspaceId: string;
12
+ sessionId: string;
13
+ turnId: string;
14
+ attemptId: string;
15
+ toolCallId: string;
16
+ prompt: string;
17
+ references?: readonly ResolvedImageGenerationReference[];
18
+ credentialId: string;
19
+ codexContext: Pick<CodexRequestContext, "clientVersion" | "getToken" | "refresh">;
20
+ abortSignal?: AbortSignal;
21
+ }): Promise<GeneratedImageReceipt>;
@@ -79,3 +79,4 @@ export declare function settleFailedContextCompactionLandmark(db: Database, scop
79
79
  compacted: false;
80
80
  }>>;
81
81
  export declare function isContextWindowExceeded(error: unknown, seen?: WeakSet<object>): boolean;
82
+ export declare function isExactContextLengthExceeded(error: unknown, seen?: WeakSet<object>): boolean;
@@ -1,5 +1,6 @@
1
- import type { ActivityServices, IndexDocumentInput } from "./types";
2
- export declare function createDocumentActivities(services: () => Promise<ActivityServices>): {
1
+ import type { DocumentServices } from "@opengeni/documents";
2
+ import type { ControlActivityServices, IndexDocumentInput } from "./types.js";
3
+ export declare function createDocumentActivities(services: () => Promise<ControlActivityServices>, resolveDocumentServices?: () => Promise<DocumentServices>): {
3
4
  indexDocument: (input: IndexDocumentInput) => Promise<{
4
5
  id: string;
5
6
  workspaceId: string;
@@ -25,15 +25,18 @@ export type GitHubTokenMintAuthorization = (selection: {
25
25
  installationId: number;
26
26
  repositoryIds: number[];
27
27
  }) => Promise<void>;
28
- export declare const TOOLSPACE_TOKEN_TTL_SECONDS: number;
29
- export type MintedSandboxToolspaceToken = {
28
+ export declare const CODEMODE_TOKEN_TTL_SECONDS: number;
29
+ export type MintedSandboxCodemodeToken = {
30
30
  token: string;
31
31
  expiresAt: Date;
32
32
  };
33
- export type SandboxToolspaceAuthority = {
33
+ export type SandboxCodemodeAuthority = {
34
34
  sessionId: string;
35
+ turnId: string;
36
+ attemptId: string;
37
+ executionGeneration: number;
35
38
  };
36
- export declare function mintSandboxToolspaceToken(settings: Settings, scope: ConnectionScope, authority: SandboxToolspaceAuthority, nowMs?: number): Promise<MintedSandboxToolspaceToken | undefined>;
39
+ export declare function mintSandboxCodemodeToken(settings: Settings, scope: ConnectionScope, authority: SandboxCodemodeAuthority, nowMs?: number): Promise<MintedSandboxCodemodeToken | undefined>;
37
40
  export type GitCredentialAuthority = {
38
41
  sessionId: string;
39
42
  rootSessionId: string;
@@ -58,17 +61,23 @@ type RunGitCredentialOptions = {
58
61
  export declare function loadWorkspaceEnvironmentForRunWithCredentials(db: Database, settings: Settings, scope: ConnectionScope, environmentId: string | null, sandboxSecrets?: ConnectionCredentialsPort["sandboxSecrets"]): Promise<WorkspaceEnvironmentForRun | null>;
59
62
  export declare function sandboxEnvironmentForRun(settings: Settings, resources: ResourceRef[], workspaceEnvironment?: Record<string, string>, options?: RunGitCredentialOptions & {
60
63
  skipGitHubToken?: boolean;
61
- skipToolspace?: boolean;
64
+ /**
65
+ * Codemode credential delivery for this attempt. Managed sandboxes receive
66
+ * stable URL/file pointers in their manifest and the bearer through the
67
+ * lifecycle file writer. Connected Machines receive no manifest pointers;
68
+ * the worker injects the minted bearer only into exact exec requests.
69
+ */
70
+ codemodeDelivery?: "managed_file" | "transient_exec" | "none";
62
71
  deferGitHubToken?: boolean;
63
- toolspaceAuthority?: SandboxToolspaceAuthority;
72
+ codemodeAuthority?: SandboxCodemodeAuthority;
64
73
  }): Promise<{
65
74
  environment: Record<string, string>;
66
75
  gitToken?: string;
67
76
  gitTokens?: GitTokenSeeds;
68
77
  gitTokenExpiresAt?: GitTokenExpiries;
69
78
  gitCredentialBindings?: GitCredentialBindingSeed[];
70
- toolspaceToken?: string;
71
- toolspaceTokenExpiresAt?: Date;
79
+ codemodeToken?: string;
80
+ codemodeTokenExpiresAt?: Date;
72
81
  }>;
73
82
  export declare function mintRunGitCredentials(settings: Settings, resources: ResourceRef[], options?: RunGitCredentialOptions): Promise<MintedRunGitCredentials | undefined>;
74
83
  export declare function mintRunGitCredentialBinding(settings: Settings, resources: ResourceRef[], provider: GitCredentialProvider, credentialBindingId: string, options?: RunGitCredentialOptions): Promise<GitCredentialBindingSeed | undefined>;
@@ -9,7 +9,7 @@ export type ExpiringMaterialRenewalController = {
9
9
  refreshNow(): Promise<void>;
10
10
  stop(): Promise<void>;
11
11
  };
12
- export type ExpiringMaterialRenewalPublicErrorClass = "RunCredentialRenewalOperationError" | "ToolspaceTokenRenewalOperationError";
12
+ export type ExpiringMaterialRenewalPublicErrorClass = "RunCredentialRenewalOperationError" | "CodemodeTokenRenewalOperationError";
13
13
  export type ExpiringMaterialRenewalOptions<T, ErrorClass extends ExpiringMaterialRenewalPublicErrorClass> = {
14
14
  initialExpiresAt: Date | null;
15
15
  resolve: () => Promise<T>;
@@ -1,6 +1,6 @@
1
1
  import { claimDueTranscriptionRecordingObjectCleanup, claimExpiredFileUploadCleanup, completeDueTranscriptionRecordingObjectCleanup, completeExpiredFileUploadCleanup, purgeExpiredTranscriptionRecordings } from "@opengeni/db";
2
2
  import type { ObjectStorage } from "@opengeni/storage";
3
- import type { ActivityServices } from "./types";
3
+ import type { ControlActivityServices } from "./types.js";
4
4
  export declare const FILE_UPLOAD_CLEANUP_GRACE_MS: number;
5
5
  export declare const FILE_UPLOAD_CLEANUP_CLAIM_TIMEOUT_MS: number;
6
6
  export declare const FILE_UPLOAD_CLEANUP_BATCH_SIZE = 100;
@@ -26,6 +26,11 @@ export type FileUploadReaperActivityOptions = {
26
26
  * and reclaimable; object deletion is idempotent; only a successful delete is
27
27
  * settled terminally. One provider failure never aborts the rest of the batch.
28
28
  */
29
- export declare function createFileUploadReaperActivities(services: () => Promise<ActivityServices>, options?: FileUploadReaperActivityOptions): {
29
+ export declare function createFileUploadReaperActivities(services: () => Promise<ControlActivityServices>, options?: FileUploadReaperActivityOptions): {
30
30
  reapExpiredFileUploads: () => Promise<ReapExpiredFileUploadsResult>;
31
+ recoverVideoGenerationWorkflows: () => Promise<{
32
+ claimed: number;
33
+ started: number;
34
+ failed: number;
35
+ }>;
31
36
  };
@@ -0,0 +1,39 @@
1
+ import type { Database } from "@opengeni/db";
2
+ import { type FetchLike } from "@opengeni/network";
3
+ import type { ObjectStorage } from "@opengeni/storage";
4
+ import { type GeneratedImageOutput, type GeneratedImageReceipt } from "./generated-images.js";
5
+ import type { ResolvedImageGenerationReference } from "./image-generation-references.js";
6
+ export declare class GatewayImageApiError extends Error {
7
+ readonly status: number;
8
+ constructor(status: number, message: string);
9
+ }
10
+ export declare function executeGatewayImageGeneration(input: {
11
+ db: Database;
12
+ objectStorage: ObjectStorage | null;
13
+ accountId: string;
14
+ workspaceId: string;
15
+ sessionId: string;
16
+ turnId: string;
17
+ attemptId: string;
18
+ apiKey: string;
19
+ modelId: string;
20
+ prompt: string;
21
+ references?: readonly ResolvedImageGenerationReference[];
22
+ toolCallId: string;
23
+ abortSignal?: AbortSignal;
24
+ }): Promise<GeneratedImageReceipt>;
25
+ /**
26
+ * One explicit Vercel AI Gateway image-protocol adapter. The caller owns durable
27
+ * operation admission; this function never retries an outcome-ambiguous paid
28
+ * request. The response is decoded directly from its JSON stream so neither
29
+ * the complete envelope nor its multi-megabyte base64 string enters memory.
30
+ */
31
+ export declare function generateGatewayImage(input: {
32
+ apiKey: string;
33
+ modelId: string;
34
+ prompt: string;
35
+ references?: readonly ResolvedImageGenerationReference[];
36
+ toolCallId: string;
37
+ abortSignal?: AbortSignal;
38
+ fetch?: FetchLike;
39
+ }): Promise<GeneratedImageOutput>;
@@ -0,0 +1,53 @@
1
+ import type { CanonicalVideoGenerationRequest } from "@opengeni/core";
2
+ import { type FetchLike } from "@opengeni/network";
3
+ export declare const GATEWAY_VIDEO_PROVIDER_ID: "vercel-ai-gateway";
4
+ export declare const GATEWAY_VIDEO_START_URL: "https://ai-gateway.vercel.sh/v4/ai/video-model/start";
5
+ export declare const GATEWAY_VIDEO_STATUS_URL: "https://ai-gateway.vercel.sh/v4/ai/video-model/status";
6
+ export type GatewayVideoReferenceGrant = Readonly<{
7
+ role: "first_frame" | "last_frame" | "image_reference" | "video_reference";
8
+ url: string;
9
+ mediaType: string;
10
+ }>;
11
+ export type GatewayVideoStartResult = Readonly<{
12
+ providerJobId: string;
13
+ }>;
14
+ export type GatewayVideoStatusResult = Readonly<{
15
+ status: "pending";
16
+ }> | Readonly<{
17
+ status: "completed";
18
+ outputUrl: string;
19
+ mediaType: string;
20
+ }> | Readonly<{
21
+ status: "error";
22
+ publicReason: string;
23
+ }>;
24
+ export declare class GatewayVideoApiError extends Error {
25
+ readonly status: number | null;
26
+ readonly retryable: boolean;
27
+ constructor(status: number | null, retryable: boolean, message: string);
28
+ }
29
+ export declare function startGatewayVideoGeneration(input: {
30
+ apiKey: string;
31
+ request: CanonicalVideoGenerationRequest;
32
+ idempotencyKey: string;
33
+ referenceGrants: readonly GatewayVideoReferenceGrant[];
34
+ signal?: AbortSignal;
35
+ fetch?: FetchLike;
36
+ }): Promise<GatewayVideoStartResult>;
37
+ /** Replay entrypoint for the encrypted, byte-stable provider request. */
38
+ export declare function startGatewayVideoGenerationWithBody(input: {
39
+ apiKey: string;
40
+ modelId: string;
41
+ body: Record<string, unknown>;
42
+ idempotencyKey: string;
43
+ signal?: AbortSignal;
44
+ fetch?: FetchLike;
45
+ }): Promise<GatewayVideoStartResult>;
46
+ export declare function getGatewayVideoGenerationStatus(input: {
47
+ apiKey: string;
48
+ modelId: string;
49
+ providerJobId: string;
50
+ signal?: AbortSignal;
51
+ fetch?: FetchLike;
52
+ }): Promise<GatewayVideoStatusResult>;
53
+ export declare function buildGatewayVideoStartBody(request: CanonicalVideoGenerationRequest, referenceGrants: readonly GatewayVideoReferenceGrant[]): Record<string, unknown>;