@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.
- package/dist/activities/agent-run-admission.d.ts +12 -0
- package/dist/activities/agent-turn.d.ts +110 -19
- package/dist/activities/api-integrations.d.ts +21 -0
- package/dist/activities/browser-state-artifact-reaper.d.ts +29 -0
- package/dist/activities/capabilities.d.ts +6 -0
- package/dist/activities/codemode-dispatcher.d.ts +35 -0
- package/dist/activities/codemode-token-renewal.d.ts +23 -0
- package/dist/activities/codex-capacity.d.ts +6 -5
- package/dist/activities/codex-image-generation.d.ts +21 -0
- package/dist/activities/context-compaction.d.ts +1 -0
- package/dist/activities/documents.d.ts +3 -2
- package/dist/activities/environment.d.ts +17 -8
- package/dist/activities/expiring-material-renewal.d.ts +1 -1
- package/dist/activities/file-upload-reaper.d.ts +7 -2
- package/dist/activities/gateway-image-generation.d.ts +39 -0
- package/dist/activities/gateway-video-generation.d.ts +53 -0
- package/dist/activities/generated-images.d.ts +112 -0
- package/dist/activities/git-credential-renewal.d.ts +1 -1
- package/dist/activities/goals.d.ts +2 -2
- package/dist/activities/google-drive-changes.d.ts +99 -0
- package/dist/activities/image-generation-operation.d.ts +74 -0
- package/dist/activities/image-generation-references.d.ts +25 -0
- package/dist/activities/knowledge-source-sync-driver.d.ts +23 -0
- package/dist/activities/knowledge-source-sync.d.ts +75 -0
- package/dist/activities/packs.d.ts +21 -36
- package/dist/activities/parent-wake.d.ts +1 -1
- package/dist/activities/retained-screenshot-reaper.d.ts +2 -2
- package/dist/activities/retained-screenshots.d.ts +36 -0
- package/dist/activities/rig-verification.d.ts +82 -5
- package/dist/activities/run-credential-renewal.d.ts +1 -1
- package/dist/activities/run-input.d.ts +3 -1
- package/dist/activities/sandbox-images.d.ts +14 -0
- package/dist/activities/sandbox-lease.d.ts +47 -9
- package/dist/activities/scheduled-tasks.d.ts +2 -2
- package/dist/activities/session-state.d.ts +7 -5
- package/dist/activities/site-auth-maintenance.d.ts +27 -0
- package/dist/activities/streaming.d.ts +1 -1
- package/dist/activities/types.d.ts +87 -5
- package/dist/activities/video-generation-admission.d.ts +43 -0
- package/dist/activities/video-generation-credential.d.ts +24 -0
- package/dist/activities/video-generation-reconciliation.d.ts +13 -0
- package/dist/activities/video-media-validation.d.ts +34 -0
- package/dist/activities/video-output-retention.d.ts +36 -0
- package/dist/activities/video-reference-staging.d.ts +55 -0
- package/dist/activities/workflow-wake.d.ts +2 -2
- package/dist/activities/workspace-capture.d.ts +10 -1
- package/dist/activities/xai-auth.d.ts +23 -0
- package/dist/activities/xai-image-generation.d.ts +26 -0
- package/dist/activities/xai-video-generation.d.ts +18 -0
- package/dist/activities-control-XURE4VKN.js +7221 -0
- package/dist/activities-control-XURE4VKN.js.map +1 -0
- package/dist/activities-control.d.ts +297 -0
- package/dist/activities-turn-6EBXGGLS.js +16036 -0
- package/dist/activities-turn-6EBXGGLS.js.map +1 -0
- package/dist/activities-turn.d.ts +17 -0
- package/dist/activities.d.ts +138 -150
- package/dist/activity-services.d.ts +10 -0
- package/dist/artifact-materializer-entry.d.ts +6 -0
- package/dist/artifact-materializer-entry.js +2662 -0
- package/dist/artifact-materializer-entry.js.map +1 -0
- package/dist/artifact-outbox-entry.d.ts +2 -0
- package/dist/artifact-outbox-entry.js +681 -0
- package/dist/artifact-outbox-entry.js.map +1 -0
- package/dist/chunk-5GRJIP5H.js +3092 -0
- package/dist/chunk-5GRJIP5H.js.map +1 -0
- package/dist/chunk-GRFQTTSQ.js +448 -0
- package/dist/chunk-GRFQTTSQ.js.map +1 -0
- package/dist/chunk-TYNPCG4U.js +906 -0
- package/dist/chunk-TYNPCG4U.js.map +1 -0
- package/dist/concurrency.d.ts +108 -5
- package/dist/editable-artifact-hint-broker.d.ts +49 -0
- package/dist/editable-artifact-materializer-launcher.d.ts +49 -0
- package/dist/editable-artifact-materializer-service.d.ts +108 -0
- package/dist/editable-artifact-materializer-storage.d.ts +12 -0
- package/dist/editable-artifact-materializer-subprocess.d.ts +50 -0
- package/dist/editable-artifact-materializer.d.ts +262 -0
- package/dist/editable-artifact-outbox-dispatcher.d.ts +44 -0
- package/dist/editable-artifact-outbox-service.d.ts +70 -0
- package/dist/host-export.d.ts +1 -1
- package/dist/index.d.ts +189 -10
- package/dist/index.js +715 -17380
- package/dist/index.js.map +1 -1
- package/dist/memory-pressure-guard.d.ts +57 -0
- package/dist/model-checkpoint-memory-collector.d.ts +23 -0
- package/dist/model-context-contributions.d.ts +40 -0
- package/dist/observability-metrics.d.ts +53 -1
- package/dist/sandbox-reaper-contract.d.ts +40 -0
- package/dist/sandbox-reaper-timeout.d.ts +14 -0
- package/dist/sandbox-resume.d.ts +34 -7
- package/dist/sandbox-routing.d.ts +6 -0
- package/dist/worker-service-lifecycle.d.ts +6 -2
- package/dist/workflow-bundle.js +1094 -370
- package/dist/workflows/activities.d.ts +8 -2
- package/dist/workflows/document-index.d.ts +1 -1
- package/dist/workflows/knowledge-source-sync.d.ts +13 -0
- package/dist/workflows/rig-verification.d.ts +1 -1
- package/dist/workflows/sandbox-reaper.d.ts +8 -0
- package/dist/workflows/scheduled-tasks.d.ts +1 -1
- package/dist/workflows/session.d.ts +2 -2
- package/dist/workflows/site-auth-maintenance.d.ts +2 -0
- package/dist/workflows/video-generation.d.ts +10 -0
- package/dist/workflows/workflow-wake.d.ts +1 -1
- package/dist/workflows.d.ts +10 -7
- package/package.json +35 -15
- package/src/activities/agent-run-admission.ts +76 -0
- package/src/activities/agent-turn.ts +2600 -340
- package/src/activities/api-integrations.ts +138 -0
- package/src/activities/browser-state-artifact-reaper.ts +120 -0
- package/src/activities/capabilities.ts +10 -0
- package/src/activities/codemode-dispatcher.ts +335 -0
- package/src/activities/codemode-token-renewal.ts +64 -0
- package/src/activities/codex-capacity.ts +54 -7
- package/src/activities/codex-image-generation.ts +56 -0
- package/src/activities/context-compaction.ts +38 -3
- package/src/activities/documents.ts +14 -4
- package/src/activities/environment.ts +54 -45
- package/src/activities/expiring-material-renewal.ts +1 -1
- package/src/activities/file-upload-reaper.ts +34 -3
- package/src/activities/gateway-image-generation.ts +146 -0
- package/src/activities/gateway-video-generation.ts +298 -0
- package/src/activities/generated-images.ts +860 -0
- package/src/activities/goals.ts +8 -3
- package/src/activities/google-drive-changes.ts +454 -0
- package/src/activities/image-generation-operation.ts +333 -0
- package/src/activities/image-generation-references.ts +118 -0
- package/src/activities/knowledge-source-sync-driver.ts +27 -0
- package/src/activities/knowledge-source-sync.ts +2840 -0
- package/src/activities/mcp-credentials.ts +1 -0
- package/src/activities/packs.ts +75 -152
- package/src/activities/parent-wake.ts +13 -1
- package/src/activities/retained-screenshot-reaper.ts +2 -2
- package/src/activities/retained-screenshots.ts +453 -28
- package/src/activities/rig-verification.ts +554 -43
- package/src/activities/run-input.ts +22 -6
- package/src/activities/sandbox-images.ts +167 -0
- package/src/activities/sandbox-lease.ts +1065 -483
- package/src/activities/scheduled-tasks.ts +104 -74
- package/src/activities/session-state.ts +22 -4
- package/src/activities/site-auth-maintenance.ts +269 -0
- package/src/activities/streaming.ts +42 -3
- package/src/activities/types.ts +104 -5
- package/src/activities/video-generation-admission.ts +303 -0
- package/src/activities/video-generation-credential.ts +112 -0
- package/src/activities/video-generation-reconciliation.ts +771 -0
- package/src/activities/video-media-validation.ts +332 -0
- package/src/activities/video-output-retention.ts +314 -0
- package/src/activities/video-reference-staging.ts +350 -0
- package/src/activities/workflow-wake.ts +2 -2
- package/src/activities/workspace-capture.ts +44 -10
- package/src/activities/xai-auth.ts +122 -0
- package/src/activities/xai-image-generation.ts +86 -0
- package/src/activities/xai-video-generation.ts +69 -0
- package/src/activities-control.ts +58 -0
- package/src/activities-turn.ts +40 -0
- package/src/activities.ts +53 -124
- package/src/activity-services.ts +62 -0
- package/src/artifact-materializer-entry.ts +35 -0
- package/src/artifact-outbox-entry.ts +29 -0
- package/src/concurrency.ts +484 -6
- package/src/editable-artifact-hint-broker.ts +235 -0
- package/src/editable-artifact-materializer-launcher.ts +515 -0
- package/src/editable-artifact-materializer-service.ts +787 -0
- package/src/editable-artifact-materializer-storage.ts +413 -0
- package/src/editable-artifact-materializer-subprocess.ts +956 -0
- package/src/editable-artifact-materializer.ts +1289 -0
- package/src/editable-artifact-outbox-dispatcher.ts +244 -0
- package/src/editable-artifact-outbox-service.ts +438 -0
- package/src/index.ts +328 -72
- package/src/memory-pressure-guard.ts +489 -0
- package/src/model-checkpoint-memory-collector.ts +123 -0
- package/src/model-context-contributions.ts +159 -0
- package/src/observability-metrics.ts +297 -13
- package/src/sandbox-reaper-contract.ts +73 -0
- package/src/sandbox-reaper-timeout.ts +79 -0
- package/src/sandbox-resume.ts +294 -153
- package/src/sandbox-routing.ts +32 -24
- package/src/worker-service-lifecycle.ts +80 -14
- package/src/workflows/activities.ts +31 -0
- package/src/workflows/file-upload-reaper.ts +9 -1
- package/src/workflows/knowledge-source-sync.ts +83 -0
- package/src/workflows/sandbox-reaper.ts +183 -21
- package/src/workflows/scheduled-tasks.ts +42 -6
- package/src/workflows/session.ts +20 -6
- package/src/workflows/site-auth-maintenance.ts +14 -0
- package/src/workflows/video-generation.ts +36 -0
- package/src/workflows.ts +18 -1
- package/dist/activities/toolspace-token-renewal.d.ts +0 -23
- package/src/activities/toolspace-token-renewal.ts +0 -64
|
@@ -1,7 +1,11 @@
|
|
|
1
|
+
import type { RigProviderImage } from "@opengeni/contracts";
|
|
2
|
+
import { type RigProviderImageDefinition } from "@opengeni/core";
|
|
1
3
|
import { acquireLease, commitWarmingToWarm, failWarmingToCold, markWarmLeaseInstanceLost, recordWarmingSandboxCreated, releaseLeaseHolder, touchLeaseHolder, type Database } from "@opengeni/db";
|
|
2
|
-
import { createTurnToolCancellationController, establishSandboxSessionFromEnvelope, serializeEstablishedSandboxEnvelope, tagModalSandbox, type EstablishedSandboxSession, type
|
|
4
|
+
import { createTurnToolCancellationController, establishSandboxSessionFromEnvelope, serializeEstablishedSandboxEnvelope, tagModalSandbox, type EstablishedSandboxSession, type TurnSandboxCommandArgs, type TurnSandboxCommandSession } from "@opengeni/runtime/sandbox";
|
|
3
5
|
import type { Context } from "@temporalio/activity";
|
|
4
|
-
import type {
|
|
6
|
+
import type { ControlActivityServices } from "./types.js";
|
|
7
|
+
import { type WorkspacePackRuntime } from "./packs.js";
|
|
8
|
+
type SandboxLifecycleCommandRunner = (session: TurnSandboxCommandSession, args: TurnSandboxCommandArgs) => Promise<unknown>;
|
|
5
9
|
export type RigVerificationWorkflowInput = {
|
|
6
10
|
workspaceId: string;
|
|
7
11
|
changeId: string;
|
|
@@ -54,6 +58,12 @@ export type RigVerificationOwnershipDependencies = {
|
|
|
54
58
|
export type RigVerificationSandboxRunContext = {
|
|
55
59
|
signal: AbortSignal;
|
|
56
60
|
commandRunner: SandboxLifecycleCommandRunner;
|
|
61
|
+
ownership: {
|
|
62
|
+
leaseId: string;
|
|
63
|
+
leaseEpoch: number;
|
|
64
|
+
workspaceGeneration: number;
|
|
65
|
+
instanceId: string;
|
|
66
|
+
};
|
|
57
67
|
};
|
|
58
68
|
export declare class RigVerificationLeaseUnavailableError extends Error {
|
|
59
69
|
readonly sandboxGroupId: string;
|
|
@@ -76,9 +86,9 @@ export declare class RigVerificationLeaseUnavailableError extends Error {
|
|
|
76
86
|
* lease expiry and the provider reaper remain the hard-worker-loss backstops.
|
|
77
87
|
*/
|
|
78
88
|
export declare function runWithOwnedRigVerificationSandbox<T>(input: {
|
|
79
|
-
settings:
|
|
89
|
+
settings: ControlActivityServices["settings"];
|
|
80
90
|
db: Database;
|
|
81
|
-
observability:
|
|
91
|
+
observability: ControlActivityServices["observability"];
|
|
82
92
|
accountId: string;
|
|
83
93
|
workspaceId: string;
|
|
84
94
|
sandboxGroupId: string;
|
|
@@ -86,7 +96,45 @@ export declare function runWithOwnedRigVerificationSandbox<T>(input: {
|
|
|
86
96
|
sessionIdPrefix: string;
|
|
87
97
|
lifecycle?: RigVerificationActivityLifecycle;
|
|
88
98
|
}, run: (established: EstablishedSandboxSession, context: RigVerificationSandboxRunContext) => Promise<T>, dependencies?: RigVerificationOwnershipDependencies): Promise<T>;
|
|
89
|
-
export declare function
|
|
99
|
+
export declare function rigProviderImageContentMarkerCommand(contentHash: string, markerRoot?: string): string;
|
|
100
|
+
export type RigProviderImageColdBootDependencies = {
|
|
101
|
+
runOwnedSandbox: typeof runWithOwnedRigVerificationSandbox;
|
|
102
|
+
now: () => Date;
|
|
103
|
+
};
|
|
104
|
+
/** Prove a provider image from a second clean sandbox before runtime selection. */
|
|
105
|
+
export declare function verifyRigProviderImageColdBoot(input: {
|
|
106
|
+
settings: ControlActivityServices["settings"];
|
|
107
|
+
db: Database;
|
|
108
|
+
observability: ControlActivityServices["observability"];
|
|
109
|
+
accountId: string;
|
|
110
|
+
workspaceId: string;
|
|
111
|
+
buildRequestId: string;
|
|
112
|
+
rigVersionId: string;
|
|
113
|
+
sessionIdPrefix: string;
|
|
114
|
+
imageId: string;
|
|
115
|
+
contentHash: string;
|
|
116
|
+
checks: RigProviderImageDefinition["checks"];
|
|
117
|
+
lifecycle: RigVerificationActivityLifecycle;
|
|
118
|
+
}, dependencies?: RigProviderImageColdBootDependencies): Promise<string>;
|
|
119
|
+
export declare function buildVerifiedRigProviderImage(input: {
|
|
120
|
+
settings: ControlActivityServices["settings"];
|
|
121
|
+
db: Database;
|
|
122
|
+
observability: ControlActivityServices["observability"];
|
|
123
|
+
accountId: string;
|
|
124
|
+
workspaceId: string;
|
|
125
|
+
existingVersionId?: string;
|
|
126
|
+
definition: RigProviderImageDefinition;
|
|
127
|
+
target: {
|
|
128
|
+
kind: "change" | "version";
|
|
129
|
+
id: string;
|
|
130
|
+
};
|
|
131
|
+
established: EstablishedSandboxSession;
|
|
132
|
+
ownership: RigVerificationSandboxRunContext["ownership"];
|
|
133
|
+
lifecycle: RigVerificationActivityLifecycle;
|
|
134
|
+
signal: AbortSignal;
|
|
135
|
+
}): Promise<RigProviderImage>;
|
|
136
|
+
export declare function settingsForRigVerification(settings: ControlActivityServices["settings"], packRuntime: WorkspacePackRuntime, rigImage: string | null): ControlActivityServices["settings"];
|
|
137
|
+
export declare function createRigVerificationActivities(services: () => Promise<ControlActivityServices>): {
|
|
90
138
|
verifyRigChange: (input: {
|
|
91
139
|
workspaceId: string;
|
|
92
140
|
changeId: string;
|
|
@@ -126,6 +174,35 @@ export declare function createRigVerificationActivities(services: () => Promise<
|
|
|
126
174
|
name: string;
|
|
127
175
|
command: string;
|
|
128
176
|
}[];
|
|
177
|
+
providerImage: {
|
|
178
|
+
backend: "blaxel" | "cloudflare" | "daytona" | "docker" | "e2b" | "local" | "modal" | "none" | "runloop" | "selfhosted" | "vercel";
|
|
179
|
+
provider: string;
|
|
180
|
+
status: "building" | "failed" | "ready" | "unsupported";
|
|
181
|
+
contentHash: string;
|
|
182
|
+
setupHash: string;
|
|
183
|
+
sourceImage: string | null;
|
|
184
|
+
buildRequestId: string;
|
|
185
|
+
imageId: string | null;
|
|
186
|
+
imageDigest: string | null;
|
|
187
|
+
artifactId: string | null;
|
|
188
|
+
providerBindingKeyHash: string | null;
|
|
189
|
+
coldBootValidation?: {
|
|
190
|
+
version: 1;
|
|
191
|
+
checkedAt: string;
|
|
192
|
+
} | undefined;
|
|
193
|
+
provenance: {
|
|
194
|
+
kind: "rig_verification";
|
|
195
|
+
targetKind: "change" | "version";
|
|
196
|
+
targetId: string;
|
|
197
|
+
};
|
|
198
|
+
startedAt: string;
|
|
199
|
+
finishedAt: string | null;
|
|
200
|
+
error: {
|
|
201
|
+
code: string;
|
|
202
|
+
message: string;
|
|
203
|
+
retryable: boolean;
|
|
204
|
+
} | null;
|
|
205
|
+
} | null;
|
|
129
206
|
}>;
|
|
130
207
|
};
|
|
131
208
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { NormalizedRunCredentialMaterial } from "@opengeni/runtime";
|
|
2
|
-
import { type ExpiringMaterialRenewalController } from "./expiring-material-renewal";
|
|
2
|
+
import { type ExpiringMaterialRenewalController } from "./expiring-material-renewal.js";
|
|
3
3
|
export declare const RUN_CREDENTIAL_DEFAULT_REFRESH_MS: number;
|
|
4
4
|
export declare const RUN_CREDENTIAL_EXPIRY_LEAD_MS: number;
|
|
5
5
|
export declare const RUN_CREDENTIAL_MIN_REFRESH_MS = 5000;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { FileResourceRef, type FileAsset, type ResourceRef } from "@opengeni/contracts";
|
|
2
|
-
import { getSessionEvent, type Database } from "@opengeni/db";
|
|
2
|
+
import { getActiveSessionHistoryItemsPaged, getSessionEvent, type Database } from "@opengeni/db";
|
|
3
3
|
import { type HistoryProviderApi, type OpenGeniRuntime } from "@opengeni/runtime";
|
|
4
4
|
/** Project only artifacts explicitly rejected by the provider out of its next view. */
|
|
5
5
|
export declare function projectRejectedProviderArtifacts(rows: ReadonlyArray<{
|
|
@@ -27,9 +27,11 @@ export type TurnInputOptions = {
|
|
|
27
27
|
unavailableSandboxFilesNote?: string;
|
|
28
28
|
runCredentialsNote?: string;
|
|
29
29
|
providerApi: HistoryProviderApi;
|
|
30
|
+
projectCanonicalHistory?: ModelHistoryAttachmentProjector;
|
|
30
31
|
materializeModelHistory?: ModelHistoryAttachmentProjector;
|
|
31
32
|
materializeSerializedRunState?: (serialized: string) => Promise<string>;
|
|
32
33
|
projectModelHistory?: ModelHistoryAttachmentProjector;
|
|
34
|
+
loadActiveHistory?: typeof getActiveSessionHistoryItemsPaged;
|
|
33
35
|
};
|
|
34
36
|
export declare const MAX_INLINE_MODEL_ATTACHMENT_BYTES: number;
|
|
35
37
|
export type ModelAttachmentContent = {
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Settings } from "@opengeni/config";
|
|
2
|
+
import type { CapabilityPack, RigVersion, SandboxBackend } from "@opengeni/contracts";
|
|
3
|
+
import { resolveModalCheckpointProviderBinding } from "@opengeni/runtime/sandbox";
|
|
4
|
+
export declare function settingsWithPackSandboxImage(settings: Settings, sandboxImage: string | null, sandboxProviderImages?: CapabilityPack["sandboxProviderImages"] | null): Settings;
|
|
5
|
+
export declare function settingsWithRigImage(settings: Settings, rigImage: string | null): Settings;
|
|
6
|
+
export declare function rigProviderImageSourceImage(settings: Settings, backend: SandboxBackend): string | null;
|
|
7
|
+
export type RigProviderImageSelectionReason = "selected" | "missing" | "provider_unsupported" | "not_ready" | "not_cold_boot_validated" | "content_mismatch" | "provider_binding_unavailable" | "provider_binding_mismatch";
|
|
8
|
+
export declare function resolveRigProviderImageSelection(settings: Settings, version: RigVersion | null, backend: SandboxBackend, currentProviderBindingKeyHash: string | null): {
|
|
9
|
+
settings: Settings;
|
|
10
|
+
reason: RigProviderImageSelectionReason;
|
|
11
|
+
contentHash: string | null;
|
|
12
|
+
imageId: string | null;
|
|
13
|
+
};
|
|
14
|
+
export declare function settingsWithRigProviderImage(settings: Settings, version: RigVersion | null, backend: SandboxBackend, resolveBinding?: typeof resolveModalCheckpointProviderBinding): Promise<Settings>;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import { listLiveModalSandboxLeaseAttributions, readLease, type RetainedProcessProviderProof, type SandboxRetainedProcess, type LeaseSnapshot } from "@opengeni/db";
|
|
2
|
-
import { createSandboxClientForBackend, inspectModalSandboxLifecycle, resolveModalCheckpointProviderBindingForSession, type ModalOrphanSweepTermination, type ModalCheckpointProviderBinding, type WorkspaceArchiveDescriptor } from "@opengeni/runtime";
|
|
3
|
-
import type
|
|
1
|
+
import { listLiveModalSandboxLeaseAttributions, readLease, type ReapDrainable, type RetainedProcessProviderProof, type SandboxRetainedProcess, type LeaseSnapshot } from "@opengeni/db";
|
|
2
|
+
import { createSandboxClientForBackend, inspectModalSandboxLifecycle, resolveModalCheckpointProviderBindingForSession, terminateModalSandboxById, type ModalOrphanSweepTermination, type ModalCheckpointProviderBinding, type ProviderWorkspaceCapturePolicy, type WorkspaceArchiveDescriptor } from "@opengeni/runtime/sandbox";
|
|
3
|
+
import { type SandboxDrainActivityInput, type SandboxLeaseSweepMaintenanceInput } from "../sandbox-reaper-contract.js";
|
|
4
|
+
import type { ControlActivityServices as ActivityServices } from "./types.js";
|
|
5
|
+
export { sandboxLeaseTelemetryKey } from "@opengeni/observability";
|
|
4
6
|
export type ReapSandboxLeasesResult = {
|
|
5
7
|
/** Stale viewer holders + warming-death rows the sweep touched is folded into
|
|
6
8
|
* the DB pass; here we report the terminate outcomes. */
|
|
@@ -45,6 +47,7 @@ export type ProviderTerminationOutcome = {
|
|
|
45
47
|
* already vanished before this drain could capture its workspace. */
|
|
46
48
|
providerMissingBeforeCapture: boolean;
|
|
47
49
|
};
|
|
50
|
+
export type DrainCaptureDisposition = "capture_required" | "archive_published";
|
|
48
51
|
/** The provider-terminate seam. Production wires the real resume-by-id ->
|
|
49
52
|
* persistWorkspace -> persist-onto-lease (epoch-fenced) -> snapshot-GC ->
|
|
50
53
|
* provider stop() (`terminateProviderBox`); a unit test injects a spy so the
|
|
@@ -52,7 +55,7 @@ export type ProviderTerminationOutcome = {
|
|
|
52
55
|
* Test seams may return the legacy boolean shorthand. Production returns the
|
|
53
56
|
* typed outcome so the cold commit can distinguish a clean stop from definitive
|
|
54
57
|
* provider disappearance before capture. */
|
|
55
|
-
export type TerminateBoxFn = (settings: ActivityServices["settings"], lease: NonNullable<Awaited<ReturnType<typeof readLease>>>, observability: ActivityServices["observability"], persistArchive: PersistArchiveFn) => Promise<boolean | ProviderTerminationOutcome>;
|
|
58
|
+
export type TerminateBoxFn = (settings: ActivityServices["settings"], lease: NonNullable<Awaited<ReturnType<typeof readLease>>>, observability: ActivityServices["observability"], persistArchive: PersistArchiveFn, providerCaptureRequestId?: string, captureDisposition?: DrainCaptureDisposition, capturePolicy?: ProviderWorkspaceCapturePolicy | null) => Promise<boolean | ProviderTerminationOutcome>;
|
|
56
59
|
export type SweepModalOrphansFn = (settings: ActivityServices["settings"], db: ActivityServices["db"], observability: ActivityServices["observability"]) => Promise<number>;
|
|
57
60
|
export type SandboxLeaseActivityOptions = {
|
|
58
61
|
/** Override the provider terminate (tests spy this; defaults to the real
|
|
@@ -88,7 +91,41 @@ export type DrainableProviderProbeFn = (settings: ActivityServices["settings"],
|
|
|
88
91
|
export declare const RETAINED_PROCESS_RECONCILIATION_LIMIT = 20;
|
|
89
92
|
export declare const RETAINED_PROCESS_RECONCILIATION_CLAIM_TTL_MS: number;
|
|
90
93
|
export declare const RETAINED_PROCESS_PROVIDER_PROBE_TIMEOUT_MS = 5000;
|
|
94
|
+
export declare class SandboxProviderCaptureTimeoutError extends Error {
|
|
95
|
+
readonly sandboxGroupId: string;
|
|
96
|
+
readonly backend: string;
|
|
97
|
+
readonly timeoutMs: number;
|
|
98
|
+
readonly leaseEpoch: number;
|
|
99
|
+
readonly instanceId: string;
|
|
100
|
+
readonly name = "SandboxProviderCaptureTimeoutError";
|
|
101
|
+
constructor(sandboxGroupId: string, backend: string, timeoutMs: number, leaseEpoch: number, instanceId: string);
|
|
102
|
+
}
|
|
103
|
+
export type SandboxLeaseSweepPlan = {
|
|
104
|
+
drainable: ReapDrainable[];
|
|
105
|
+
timeoutClass: SandboxDrainActivityInput["timeoutClass"];
|
|
106
|
+
snapshotTimeoutMs: number;
|
|
107
|
+
captureTimeoutMs: number;
|
|
108
|
+
/** Deadline rotations admitted immediately before inventory, so zero-holder
|
|
109
|
+
* boxes enter the same sweep instead of paying another schedule period. */
|
|
110
|
+
rotationsRequested: number;
|
|
111
|
+
};
|
|
112
|
+
export type SandboxLeaseSweepMaintenanceResult = {
|
|
113
|
+
metered: number;
|
|
114
|
+
forceDrained: number;
|
|
115
|
+
rotationsRequested: number;
|
|
116
|
+
modalOrphansTerminated: number;
|
|
117
|
+
};
|
|
118
|
+
export type SandboxDrainActivityResult = {
|
|
119
|
+
status: "terminated" | "skipped";
|
|
120
|
+
};
|
|
121
|
+
/** Stable UUID per logical operation + Temporal attempt. Attempt one uses the
|
|
122
|
+
* operation id itself; later attempts are SHA-256-derived UUIDv5-shaped values.
|
|
123
|
+
* This makes the DB receipt idempotent even if an activity delivery is replayed. */
|
|
124
|
+
export declare function sandboxDrainCaptureId(operationId: string, attempt: number): string;
|
|
91
125
|
export declare function createSandboxLeaseActivities(services: () => Promise<ActivityServices>, options?: SandboxLeaseActivityOptions): {
|
|
126
|
+
prepareSandboxLeaseSweep: () => Promise<SandboxLeaseSweepPlan>;
|
|
127
|
+
drainSandboxLease: (input: SandboxDrainActivityInput) => Promise<SandboxDrainActivityResult>;
|
|
128
|
+
maintainSandboxLeaseSweep: (input: SandboxLeaseSweepMaintenanceInput) => Promise<SandboxLeaseSweepMaintenanceResult>;
|
|
92
129
|
reapSandboxLeases: () => Promise<ReapSandboxLeasesResult>;
|
|
93
130
|
};
|
|
94
131
|
export declare function probeRetainedProcessAtProvider(settings: ActivityServices["settings"], lease: LeaseSnapshot, process: SandboxRetainedProcess): Promise<RetainedProcessProbeResult>;
|
|
@@ -107,7 +144,7 @@ export declare function modalOrphanTerminationStillEligible(latest: Awaited<Retu
|
|
|
107
144
|
* - persistArchive(base64) -> CAS-fold it onto the lease and atomically mark
|
|
108
145
|
* the displaced artifact delete-pending;
|
|
109
146
|
* - the provider-bound global GC deletes that object asynchronously;
|
|
110
|
-
* - terminate the live handle
|
|
147
|
+
* - terminate the live handle through the standard Agents SDK lifecycle.
|
|
111
148
|
*
|
|
112
149
|
* Returns true when the box was terminated (or was already gone), false when the
|
|
113
150
|
* persist CAS found the lease re-armed and the box was deliberately LEFT RUNNING.
|
|
@@ -121,8 +158,9 @@ export declare function modalOrphanTerminationStillEligible(latest: Awaited<Retu
|
|
|
121
158
|
* BEFORE any terminate, so the box is NOT torn down with un-captured files;
|
|
122
159
|
* the next sweep retries, and the provider idle-timeout is the ultimate
|
|
123
160
|
* backstop. We never terminate a box whose snapshot we could not capture.
|
|
124
|
-
*
|
|
125
|
-
*
|
|
161
|
+
* A provider-backed row with instance_id but no envelope is never guessed away:
|
|
162
|
+
* Modal has an explicit by-id rescue adapter above; every other backend stays
|
|
163
|
+
* draining until its adapter can prove termination. A truly instance-less or
|
|
164
|
+
* `none`-backed row is a no-op.
|
|
126
165
|
*/
|
|
127
|
-
export declare function terminateProviderBox(settings: ActivityServices["settings"], lease: NonNullable<Awaited<ReturnType<typeof readLease>>>, observability: ActivityServices["observability"], persistArchive: PersistArchiveFn, createClientForBackend?: CreateSandboxClientForBackendFn): Promise<ProviderTerminationOutcome>;
|
|
128
|
-
export {};
|
|
166
|
+
export declare function terminateProviderBox(settings: ActivityServices["settings"], lease: NonNullable<Awaited<ReturnType<typeof readLease>>>, observability: ActivityServices["observability"], persistArchive: PersistArchiveFn, createClientForBackend?: CreateSandboxClientForBackendFn, terminateModalById?: typeof terminateModalSandboxById, providerCaptureRequestId?: string, captureDisposition?: DrainCaptureDisposition, claimedCapturePolicy?: ProviderWorkspaceCapturePolicy | null): Promise<ProviderTerminationOutcome>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare function createScheduledTaskActivities(services: () => Promise<
|
|
1
|
+
import type { ControlActivityServices, DispatchScheduledTaskRunInput, DispatchScheduledTaskRunResult } from "./types.js";
|
|
2
|
+
export declare function createScheduledTaskActivities(services: () => Promise<ControlActivityServices>): {
|
|
3
3
|
dispatchScheduledTaskRun: (input: DispatchScheduledTaskRunInput) => Promise<DispatchScheduledTaskRunResult>;
|
|
4
4
|
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { settleSessionAttemptInterruptions, applySessionTurnSettlement, requestSessionTurnRecovery, recoverSessionDispatch, reconcileSessionAttemptQuiescence, peekSessionWork as peekSessionWorkDb, countQueuedTurns, getSessionAttemptActivityRef, getSessionEvent, getSessionTurnForAttempt, expireSessionHumanInputRequest, markSessionAttemptQuiesced, requireSession, settleSessionIdleWithParentOutbox } from "@opengeni/db";
|
|
1
|
+
import { settleSessionAttemptInterruptions, applySessionTurnSettlement, requestSessionTurnRecovery, recoverSessionDispatch, reconcileSessionAttemptQuiescence, peekSessionWork as peekSessionWorkDb, countQueuedTurns, getSessionAttemptActivityRef, getSessionEvent, getSessionTurnForAttempt, expireSessionInteractionIntervention as expireSessionInteractionInterventionDb, expireSessionHumanInputRequest, markSessionAttemptQuiesced, requireSession, settleSessionIdleWithParentOutbox } from "@opengeni/db";
|
|
2
2
|
import { publishDurableSessionEvents } from "@opengeni/events";
|
|
3
|
-
import { deliverFailedChildTurnToParent, notifyParentOfChildIdle } from "./parent-wake";
|
|
4
|
-
import { recordTurnsQueuedGauge } from "../observability-metrics";
|
|
5
|
-
import type {
|
|
3
|
+
import { deliverFailedChildTurnToParent, notifyParentOfChildIdle } from "./parent-wake.js";
|
|
4
|
+
import { recordTurnsQueuedGauge } from "../observability-metrics.js";
|
|
5
|
+
import type { ControlActivityServices, ExpireSessionHumanInputInput, ExpireSessionHumanInputResult, ExpireSessionInteractionInterventionInput, ExpireSessionInteractionInterventionResult, PeekSessionWorkInput, FailSessionAttemptInput, SettleSessionInterruptionsInput, MarkSessionIdleInput, PersistSessionAttemptQuiescenceInput, ReconcileSessionAttemptQuiescenceInput, ReconcileSessionAttemptQuiescenceResult, RecoverDispatchInput, RecoverDispatchResult, RecoverEscapedMcpTimeoutInput, RecoverEscapedMcpTimeoutResult } from "./types.js";
|
|
6
6
|
export type SessionStateActivityOverrides = Partial<{
|
|
7
7
|
settleSessionAttemptInterruptions: typeof settleSessionAttemptInterruptions;
|
|
8
8
|
applySessionTurnSettlement: typeof applySessionTurnSettlement;
|
|
@@ -15,6 +15,7 @@ export type SessionStateActivityOverrides = Partial<{
|
|
|
15
15
|
getSessionEvent: typeof getSessionEvent;
|
|
16
16
|
getSessionTurnForAttempt: typeof getSessionTurnForAttempt;
|
|
17
17
|
expireSessionHumanInputRequest: typeof expireSessionHumanInputRequest;
|
|
18
|
+
expireSessionInteractionIntervention: typeof expireSessionInteractionInterventionDb;
|
|
18
19
|
requireSession: typeof requireSession;
|
|
19
20
|
settleSessionIdleWithParentOutbox: typeof settleSessionIdleWithParentOutbox;
|
|
20
21
|
markSessionAttemptQuiesced: typeof markSessionAttemptQuiesced;
|
|
@@ -24,7 +25,7 @@ export type SessionStateActivityOverrides = Partial<{
|
|
|
24
25
|
recordTurnsQueuedGauge: typeof recordTurnsQueuedGauge;
|
|
25
26
|
}>;
|
|
26
27
|
export declare const WORKER_DEATH_MAX_REDISPATCHES = 3;
|
|
27
|
-
export declare function createSessionStateActivities(services: () => Promise<
|
|
28
|
+
export declare function createSessionStateActivities(services: () => Promise<ControlActivityServices>, overrides?: SessionStateActivityOverrides): {
|
|
28
29
|
failSessionAttempt: (input: FailSessionAttemptInput) => Promise<void>;
|
|
29
30
|
settleSessionInterruptions: (input: SettleSessionInterruptionsInput) => Promise<{
|
|
30
31
|
action: "paused" | "continue" | "stale";
|
|
@@ -35,5 +36,6 @@ export declare function createSessionStateActivities(services: () => Promise<Act
|
|
|
35
36
|
recoverEscapedMcpTimeout: (input: RecoverEscapedMcpTimeoutInput) => Promise<RecoverEscapedMcpTimeoutResult>;
|
|
36
37
|
peekSessionWork: (input: PeekSessionWorkInput) => Promise<import("@opengeni/db").SessionWorkPeek>;
|
|
37
38
|
expireSessionHumanInput: (input: ExpireSessionHumanInputInput) => Promise<ExpireSessionHumanInputResult>;
|
|
39
|
+
expireSessionInteractionIntervention: (input: ExpireSessionInteractionInterventionInput) => Promise<ExpireSessionInteractionInterventionResult>;
|
|
38
40
|
markSessionIdle: (input: MarkSessionIdleInput) => Promise<void>;
|
|
39
41
|
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { assertWorkspaceModelPolicyAllows, createAndStartSessionWithOutcome, recordWorkspaceUsage } from "@opengeni/core";
|
|
2
|
+
import { claimSiteAuthMaintenance, confirmSiteAuthMaintenanceSessionInTransaction, deferSiteAuthMaintenance } from "@opengeni/db";
|
|
3
|
+
import { agentRunAdmissionDenial } from "./agent-run-admission.js";
|
|
4
|
+
import type { ControlActivityServices } from "./types.js";
|
|
5
|
+
export declare const SITE_AUTH_MAINTENANCE_CLAIM_TIMEOUT_MS: number;
|
|
6
|
+
export declare const SITE_AUTH_MAINTENANCE_BATCH_SIZE = 16;
|
|
7
|
+
export type MaintainSiteAuthConnectionsResult = {
|
|
8
|
+
claimed: number;
|
|
9
|
+
started: number;
|
|
10
|
+
deferred: number;
|
|
11
|
+
};
|
|
12
|
+
export type SiteAuthMaintenanceOptions = {
|
|
13
|
+
claimTimeoutMs?: number;
|
|
14
|
+
batchSize?: number;
|
|
15
|
+
claim?: typeof claimSiteAuthMaintenance;
|
|
16
|
+
confirm?: typeof confirmSiteAuthMaintenanceSessionInTransaction;
|
|
17
|
+
defer?: typeof deferSiteAuthMaintenance;
|
|
18
|
+
createSession?: typeof createAndStartSessionWithOutcome;
|
|
19
|
+
admit?: typeof agentRunAdmissionDenial;
|
|
20
|
+
recordUsage?: typeof recordWorkspaceUsage;
|
|
21
|
+
assertModelPolicy?: typeof assertWorkspaceModelPolicyAllows;
|
|
22
|
+
};
|
|
23
|
+
/** Dispatch bounded, auditable agent sessions for due authentication checks.
|
|
24
|
+
* A hidden claim id/session id pair makes every crash point replayable. */
|
|
25
|
+
export declare function createSiteAuthMaintenanceActivities(services: () => Promise<ControlActivityServices>, options?: SiteAuthMaintenanceOptions): {
|
|
26
|
+
maintainSiteAuthConnections: () => Promise<MaintainSiteAuthConnectionsResult>;
|
|
27
|
+
};
|
|
@@ -20,5 +20,5 @@ export declare function createRuntimeBatcher(flushEvents: (events: AppendEventIn
|
|
|
20
20
|
flush: () => Promise<void>;
|
|
21
21
|
};
|
|
22
22
|
export declare function currentActivityContext(): Context | null;
|
|
23
|
-
export declare function startActivityHeartbeat(context: Context | null, details: Record<string, unknown
|
|
23
|
+
export declare function startActivityHeartbeat(context: Context | null, details: Record<string, unknown>, schedule?: typeof setInterval): ReturnType<typeof setInterval> | null;
|
|
24
24
|
export declare function nextStreamEvent<T>(iterator: AsyncIterator<T>, context: Context | null): Promise<IteratorResult<T>>;
|
|
@@ -21,6 +21,16 @@ export type SignalCodexCapacityWorkflow = (input: {
|
|
|
21
21
|
workflowId: string;
|
|
22
22
|
wakeRevision: number;
|
|
23
23
|
}) => Promise<void>;
|
|
24
|
+
/** Start the versioned, per-box sandbox reaper from the history-stable legacy
|
|
25
|
+
* activity. The legacy Schedule workflow must keep its exact historical
|
|
26
|
+
* ScheduleActivity command across mixed-version worker pools. */
|
|
27
|
+
export type StartSandboxReaperWorkflow = () => Promise<"started" | "already_running">;
|
|
28
|
+
/** Start-or-observe the one durable reconciler for a paid video operation. */
|
|
29
|
+
export type StartVideoGenerationWorkflow = (input: {
|
|
30
|
+
accountId: string;
|
|
31
|
+
workspaceId: string;
|
|
32
|
+
operationId: string;
|
|
33
|
+
}) => Promise<"started" | "already_running">;
|
|
24
34
|
/** Exact activity-owned proof that the hard sandbox/tool fence physically
|
|
25
35
|
* drained. This is delivery evidence only: the workflow still validates the
|
|
26
36
|
* persisted attempt dispatch and commits the authoritative Postgres receipt. */
|
|
@@ -39,13 +49,13 @@ export type InspectSessionAttemptActivity = (input: {
|
|
|
39
49
|
workflowRunId: string;
|
|
40
50
|
activityId: string;
|
|
41
51
|
}) => Promise<"pending" | "settled">;
|
|
42
|
-
|
|
52
|
+
/** Services shared by both Temporal worker roles. Keep this graph free of the
|
|
53
|
+
* agent runtime and document parser so each process can load only its role. */
|
|
54
|
+
export type SharedActivityServices = {
|
|
43
55
|
settings: Settings;
|
|
44
56
|
db: Database;
|
|
45
57
|
bus: EventBus;
|
|
46
|
-
runtime: OpenGeniRuntime;
|
|
47
58
|
objectStorage: ObjectStorage | null;
|
|
48
|
-
documentServices: DocumentServices;
|
|
49
59
|
observability: Observability;
|
|
50
60
|
wakeSessionWorkflow: WakeSessionWorkflowSignal | null;
|
|
51
61
|
/** Durable signalWithStart fallback used only after the activity's direct
|
|
@@ -56,15 +66,37 @@ export type ActivityServices = {
|
|
|
56
66
|
inspectSessionAttemptActivity: InspectSessionAttemptActivity | null;
|
|
57
67
|
/** Revision-carrying capacity nudge; generic outbox repair is also sufficient. */
|
|
58
68
|
signalCodexCapacityWorkflow?: SignalCodexCapacityWorkflow | null;
|
|
69
|
+
/** Production control workers inject this Temporal client edge. A null edge
|
|
70
|
+
* deliberately retains the composite implementation for embedded/test hosts. */
|
|
71
|
+
startSandboxReaperWorkflow?: StartSandboxReaperWorkflow | null;
|
|
72
|
+
startVideoGenerationWorkflow?: StartVideoGenerationWorkflow | null;
|
|
59
73
|
entitlements?: EntitlementsPort | null;
|
|
60
74
|
connectionCredentials?: ConnectionCredentialsPort | null;
|
|
61
75
|
};
|
|
76
|
+
/** Control workers own short database and maintenance activities. Document
|
|
77
|
+
* parsing is resolved lazily by the indexing activity itself. */
|
|
78
|
+
export type ControlActivityServices = SharedActivityServices;
|
|
79
|
+
/** Turn workers own the model loop and never construct document parsers. */
|
|
80
|
+
export type TurnActivityServices = SharedActivityServices & {
|
|
81
|
+
runtime: OpenGeniRuntime;
|
|
82
|
+
/** Provider-free test/profiling seam; production injects the real runtime summarizer. */
|
|
83
|
+
summarizeContextForCompaction: typeof import("@opengeni/runtime").summarizeForCompaction;
|
|
84
|
+
};
|
|
85
|
+
/** Full test/embedded harness retained as a source-compatible superset. */
|
|
86
|
+
export type ActivityServices = ControlActivityServices & TurnActivityServices & {
|
|
87
|
+
documentServices: DocumentServices;
|
|
88
|
+
};
|
|
62
89
|
export type CodexCapacityWaitRef = {
|
|
90
|
+
/** Absent only for Temporal histories written before provider-tagged waits. */
|
|
91
|
+
provider?: "codex" | "xai";
|
|
63
92
|
waiterId: string;
|
|
64
93
|
generation: number;
|
|
65
94
|
nextCheckAt: string;
|
|
66
95
|
wakeRevision: number;
|
|
67
96
|
};
|
|
97
|
+
export type XaiCapacityWaitRef = CodexCapacityWaitRef & {
|
|
98
|
+
provider: "xai";
|
|
99
|
+
};
|
|
68
100
|
export type GetCodexCapacityWaitInput = {
|
|
69
101
|
workspaceId: string;
|
|
70
102
|
sessionId: string;
|
|
@@ -76,6 +108,8 @@ export type ReconcileCodexCapacityWaitInput = {
|
|
|
76
108
|
waiterId: string;
|
|
77
109
|
generation: number;
|
|
78
110
|
cause: "timer" | "signal" | "queue" | "recovery";
|
|
111
|
+
/** Absent only for Codex waits and pre-provider-tagged workflow histories. */
|
|
112
|
+
provider?: "codex" | "xai";
|
|
79
113
|
};
|
|
80
114
|
export type ReconcileCodexCapacityWaitResult = ({
|
|
81
115
|
action: "waiting";
|
|
@@ -83,6 +117,8 @@ export type ReconcileCodexCapacityWaitResult = ({
|
|
|
83
117
|
action: "resumed" | "paused" | "superseded" | "stale";
|
|
84
118
|
};
|
|
85
119
|
export type ActivityDependencies = Partial<ActivityServices>;
|
|
120
|
+
export type ControlActivityDependencies = Partial<ControlActivityServices>;
|
|
121
|
+
export type TurnActivityDependencies = Partial<TurnActivityServices>;
|
|
86
122
|
export type RunAgentTurnInput = {
|
|
87
123
|
accountId: string;
|
|
88
124
|
workspaceId: string;
|
|
@@ -97,6 +133,14 @@ export type RunAgentTurnInput = {
|
|
|
97
133
|
triggerEventId: string;
|
|
98
134
|
};
|
|
99
135
|
};
|
|
136
|
+
export type VideoGenerationTerminalStatus = "completed" | "provider_failed" | "cancelled_before_submit" | "outcome_unknown" | "retention_failed";
|
|
137
|
+
export type VideoGenerationReconcileResult = {
|
|
138
|
+
action: "waiting";
|
|
139
|
+
delayMs: number;
|
|
140
|
+
} | {
|
|
141
|
+
action: "terminal";
|
|
142
|
+
status: VideoGenerationTerminalStatus;
|
|
143
|
+
};
|
|
100
144
|
export type SettleSessionInterruptionsInput = {
|
|
101
145
|
accountId: string;
|
|
102
146
|
workspaceId: string;
|
|
@@ -177,6 +221,15 @@ export type ExpireSessionHumanInputInput = {
|
|
|
177
221
|
export type ExpireSessionHumanInputResult = {
|
|
178
222
|
action: "expired" | "stale" | "not_found";
|
|
179
223
|
};
|
|
224
|
+
export type ExpireSessionInteractionInterventionInput = {
|
|
225
|
+
accountId: string;
|
|
226
|
+
workspaceId: string;
|
|
227
|
+
sessionId: string;
|
|
228
|
+
interventionId: string;
|
|
229
|
+
};
|
|
230
|
+
export type ExpireSessionInteractionInterventionResult = {
|
|
231
|
+
action: "expired" | "stale" | "not_found";
|
|
232
|
+
};
|
|
180
233
|
export type MarkSessionIdleInput = {
|
|
181
234
|
workspaceId: string;
|
|
182
235
|
sessionId: string;
|
|
@@ -200,7 +253,7 @@ export type DispatchScheduledTaskRunInput = {
|
|
|
200
253
|
agentRunUsageIdempotencyKey?: never;
|
|
201
254
|
initiator?: never;
|
|
202
255
|
} | {
|
|
203
|
-
triggerType: Extract<ScheduledTaskTriggerType, "manual">;
|
|
256
|
+
triggerType: Extract<ScheduledTaskTriggerType, "manual" | "initial" | "provider_event" | "retry" | "repair">;
|
|
204
257
|
agentRunUsageIdempotencyKey: string;
|
|
205
258
|
/** Exact identity used by the API-side charge for this same trigger. */
|
|
206
259
|
initiator: TurnInitiator;
|
|
@@ -209,7 +262,7 @@ export type DispatchScheduledTaskRunResult = {
|
|
|
209
262
|
action: "deleted";
|
|
210
263
|
} | {
|
|
211
264
|
action: "blocked";
|
|
212
|
-
reason: "insufficient_credits" | "monthly_model_cost_limit" | "monthly_agent_run_limit" | "malformed_manual_trigger";
|
|
265
|
+
reason: "insufficient_credits" | "monthly_model_cost_limit" | "monthly_agent_run_limit" | "malformed_manual_trigger" | "knowledge_source_paused";
|
|
213
266
|
} | {
|
|
214
267
|
action: "start" | "signal";
|
|
215
268
|
accountId: string;
|
|
@@ -218,6 +271,35 @@ export type DispatchScheduledTaskRunResult = {
|
|
|
218
271
|
triggerEventId: string;
|
|
219
272
|
workflowId: string;
|
|
220
273
|
workflowWakeRevision: number | null;
|
|
274
|
+
} | {
|
|
275
|
+
action: "knowledge_source_sync";
|
|
276
|
+
accountId: string;
|
|
277
|
+
workspaceId: string;
|
|
278
|
+
taskId: string;
|
|
279
|
+
scheduledTaskRunId: string;
|
|
280
|
+
sourceId: string;
|
|
281
|
+
overlapPolicy: "skip" | "buffer_one";
|
|
282
|
+
};
|
|
283
|
+
export type RunKnowledgeSourceSyncBatchInput = {
|
|
284
|
+
accountId: string;
|
|
285
|
+
workspaceId: string;
|
|
286
|
+
taskId: string;
|
|
287
|
+
scheduledTaskRunId: string;
|
|
288
|
+
sourceId: string;
|
|
289
|
+
overlapPolicy: "skip" | "buffer_one";
|
|
290
|
+
};
|
|
291
|
+
export type RunKnowledgeSourceSyncBatchResult = {
|
|
292
|
+
action: "continue";
|
|
293
|
+
} | {
|
|
294
|
+
action: "complete";
|
|
295
|
+
bufferedWake: boolean;
|
|
296
|
+
bufferedScheduledTaskRunId?: string | null;
|
|
297
|
+
} | {
|
|
298
|
+
action: "skipped" | "buffered";
|
|
299
|
+
} | {
|
|
300
|
+
action: "failed";
|
|
301
|
+
bufferedWake: boolean;
|
|
302
|
+
bufferedScheduledTaskRunId?: string | null;
|
|
221
303
|
};
|
|
222
304
|
type DocumentIndexIdentity = {
|
|
223
305
|
accountId: string;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { VideoGenerationAcceptedReceipt, type GenerateVideoToolInput, type VideoGenerationCapabilities, type VideoGenerationPolicy, type XaiProviderAccountAuthoritySnapshotV1 } from "@opengeni/contracts";
|
|
2
|
+
import { type Database, type XaiCredentialForRun } from "@opengeni/db";
|
|
3
|
+
import { type Settings } from "@opengeni/config";
|
|
4
|
+
import type { ObjectStorage } from "@opengeni/storage";
|
|
5
|
+
import { type SandboxCommandRunner } from "./video-reference-staging.js";
|
|
6
|
+
export type VideoGenerationCredentialLease = Readonly<{
|
|
7
|
+
fundingSource: "opengeni_credits" | "workspace_gateway" | "supergrok_subscription";
|
|
8
|
+
connectionId: string | null;
|
|
9
|
+
version: number;
|
|
10
|
+
credentialEncrypted: string;
|
|
11
|
+
}>;
|
|
12
|
+
export type AcceptedVideoGeneration = Readonly<{
|
|
13
|
+
receipt: ReturnType<typeof VideoGenerationAcceptedReceipt.parse>;
|
|
14
|
+
operationId: string;
|
|
15
|
+
requestDigest: string;
|
|
16
|
+
}>;
|
|
17
|
+
export declare function videoCapabilitiesForTurn(input: {
|
|
18
|
+
policy: VideoGenerationPolicy;
|
|
19
|
+
credential: VideoGenerationCredentialLease;
|
|
20
|
+
}): VideoGenerationCapabilities;
|
|
21
|
+
export declare function managedVideoGenerationCredentialLease(settings: Settings): VideoGenerationCredentialLease | null;
|
|
22
|
+
export declare function xaiVideoGenerationCredentialLease(input: {
|
|
23
|
+
settings: Settings;
|
|
24
|
+
credential: XaiCredentialForRun;
|
|
25
|
+
subjectId: string;
|
|
26
|
+
authoritySnapshot: XaiProviderAccountAuthoritySnapshotV1;
|
|
27
|
+
}): VideoGenerationCredentialLease;
|
|
28
|
+
export declare function admitVideoGenerationRequest(input: {
|
|
29
|
+
db: Database;
|
|
30
|
+
storage: ObjectStorage;
|
|
31
|
+
settings: Settings;
|
|
32
|
+
accountId: string;
|
|
33
|
+
workspaceId: string;
|
|
34
|
+
sessionId: string;
|
|
35
|
+
turnId: string;
|
|
36
|
+
attemptId: string;
|
|
37
|
+
toolCallId: string;
|
|
38
|
+
toolInput: GenerateVideoToolInput;
|
|
39
|
+
policy: VideoGenerationPolicy;
|
|
40
|
+
credential: VideoGenerationCredentialLease;
|
|
41
|
+
runCommand?: SandboxCommandRunner;
|
|
42
|
+
signal?: AbortSignal;
|
|
43
|
+
}): Promise<AcceptedVideoGeneration>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { XaiProviderAccountAuthoritySnapshotV1 } from "@opengeni/contracts";
|
|
2
|
+
export type VideoGenerationProviderCredential = Readonly<{
|
|
3
|
+
kind: "api-key";
|
|
4
|
+
apiKey: string;
|
|
5
|
+
}> | Readonly<{
|
|
6
|
+
kind: "xai-subscription";
|
|
7
|
+
accessToken: string;
|
|
8
|
+
refreshToken: string;
|
|
9
|
+
userId: string;
|
|
10
|
+
credentialId: string;
|
|
11
|
+
subjectId: string;
|
|
12
|
+
authoritySnapshot: XaiProviderAccountAuthoritySnapshotV1;
|
|
13
|
+
}>;
|
|
14
|
+
/** One frozen, provider-neutral credential envelope for every video funding route. */
|
|
15
|
+
export declare function encryptVideoGenerationApiKey(key: Uint8Array, apiKey: string): string;
|
|
16
|
+
export declare function encryptVideoGenerationXaiCredential(key: Uint8Array, credential: Omit<Extract<VideoGenerationProviderCredential, {
|
|
17
|
+
kind: "xai-subscription";
|
|
18
|
+
}>, "kind">): string;
|
|
19
|
+
/**
|
|
20
|
+
* Decrypt without ever attaching parser/decryption errors: JSON parser errors
|
|
21
|
+
* may quote plaintext and must not enter Temporal failure payloads or logs.
|
|
22
|
+
*/
|
|
23
|
+
export declare function decryptVideoGenerationCredential(key: Uint8Array, stored: string): VideoGenerationProviderCredential;
|
|
24
|
+
export declare function decryptVideoGenerationApiKey(key: Uint8Array, stored: string): string;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { TurnActivityServices, VideoGenerationReconcileResult } from "./types.js";
|
|
2
|
+
export declare function createVideoGenerationActivities(services: () => Promise<TurnActivityServices>): {
|
|
3
|
+
reconcileVideoGenerationOperation: (input: {
|
|
4
|
+
accountId: string;
|
|
5
|
+
workspaceId: string;
|
|
6
|
+
operationId: string;
|
|
7
|
+
}) => Promise<VideoGenerationReconcileResult>;
|
|
8
|
+
};
|
|
9
|
+
export declare function reconcileVideoGenerationOperation(service: TurnActivityServices, input: {
|
|
10
|
+
accountId: string;
|
|
11
|
+
workspaceId: string;
|
|
12
|
+
operationId: string;
|
|
13
|
+
}): Promise<VideoGenerationReconcileResult>;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { GeneratedVideoFacts } from "@opengeni/contracts";
|
|
2
|
+
import type { ObjectStorage } from "@opengeni/storage";
|
|
3
|
+
export type VerifiedTempFile = Readonly<{
|
|
4
|
+
directory: string;
|
|
5
|
+
path: string;
|
|
6
|
+
sizeBytes: number;
|
|
7
|
+
sha256: string;
|
|
8
|
+
contentType: string;
|
|
9
|
+
cleanup: () => Promise<void>;
|
|
10
|
+
}>;
|
|
11
|
+
export declare function copyVersionedObjectToVerifiedTemp(input: {
|
|
12
|
+
storage: ObjectStorage;
|
|
13
|
+
key: string;
|
|
14
|
+
expectedSizeBytes: number;
|
|
15
|
+
expectedSha256: string;
|
|
16
|
+
expectedContentType: string;
|
|
17
|
+
maxBytes: number;
|
|
18
|
+
tempRoot: string;
|
|
19
|
+
signal?: AbortSignal;
|
|
20
|
+
}): Promise<VerifiedTempFile>;
|
|
21
|
+
export declare function validateImageReference(path: string): Promise<{
|
|
22
|
+
contentType: "image/jpeg" | "image/png" | "image/webp";
|
|
23
|
+
width: number;
|
|
24
|
+
height: number;
|
|
25
|
+
}>;
|
|
26
|
+
export declare function validateGeneratedVideo(input: {
|
|
27
|
+
path: string;
|
|
28
|
+
ffprobePath: string;
|
|
29
|
+
expectedDurationSeconds?: number;
|
|
30
|
+
}): Promise<GeneratedVideoFacts>;
|
|
31
|
+
export declare function validateVideoReference(input: {
|
|
32
|
+
path: string;
|
|
33
|
+
ffprobePath: string;
|
|
34
|
+
}): Promise<GeneratedVideoFacts>;
|