@opengeni/worker-bundle 0.16.21 → 0.17.2
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-turn.d.ts +145 -32
- package/dist/activities/api-integrations.d.ts +21 -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 +5 -5
- package/dist/activities/codex-image-generation.d.ts +21 -0
- package/dist/activities/context-compaction.d.ts +3 -0
- package/dist/activities/documents.d.ts +3 -2
- package/dist/activities/environment.d.ts +11 -7
- package/dist/activities/expiring-material-renewal.d.ts +5 -3
- 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 +2 -2
- 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 +13 -26
- package/dist/activities/parent-wake.d.ts +1 -1
- package/dist/activities/retained-screenshot-reaper.d.ts +32 -0
- package/dist/activities/retained-screenshots.d.ts +129 -0
- package/dist/activities/rig-verification.d.ts +82 -5
- package/dist/activities/run-credential-renewal.d.ts +2 -2
- package/dist/activities/run-input.d.ts +5 -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 +4 -4
- package/dist/activities/streaming.d.ts +1 -1
- package/dist/activities/types.d.ts +71 -5
- package/dist/activities/video-generation-admission.d.ts +38 -0
- package/dist/activities/video-generation-credential.d.ts +7 -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 +49 -0
- package/dist/activities/workflow-wake.d.ts +2 -2
- package/dist/activities/workspace-capture.d.ts +11 -1
- package/dist/activities-control-44KBWLSM.js +6885 -0
- package/dist/activities-control-44KBWLSM.js.map +1 -0
- package/dist/activities-control.d.ts +289 -0
- package/dist/activities-turn-K4CEDEGJ.js +14675 -0
- package/dist/activities-turn-K4CEDEGJ.js.map +1 -0
- package/dist/activities-turn.d.ts +17 -0
- package/dist/activities.d.ts +130 -147
- 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-E3RI3I33.js +828 -0
- package/dist/chunk-E3RI3I33.js.map +1 -0
- package/dist/chunk-GRFQTTSQ.js +448 -0
- package/dist/chunk-GRFQTTSQ.js.map +1 -0
- package/dist/chunk-KKCRGAGZ.js +3091 -0
- package/dist/chunk-KKCRGAGZ.js.map +1 -0
- package/dist/{chunk-BJUW5LCM.js → chunk-RAMNYSAW.js} +15 -12
- package/dist/chunk-RAMNYSAW.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/host-export.js +1 -1
- package/dist/index.d.ts +176 -10
- package/dist/index.js +675 -16460
- package/dist/index.js.map +1 -1
- package/dist/memory-pressure-guard.d.ts +57 -0
- package/dist/model-checkpoint-memory-collector.d.ts +22 -0
- package/dist/observability-metrics.d.ts +33 -0
- package/dist/sandbox-reaper-contract.d.ts +40 -0
- package/dist/sandbox-reaper-timeout.d.ts +14 -0
- package/dist/sandbox-resume.d.ts +40 -7
- package/dist/sandbox-routing.d.ts +13 -6
- package/dist/worker-service-lifecycle.d.ts +6 -2
- package/dist/workflow-bundle.js +1044 -363
- package/dist/workflows/activities.d.ts +7 -1
- 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/video-generation.d.ts +10 -0
- package/dist/workflows/workflow-wake.d.ts +1 -1
- package/dist/workflows.d.ts +9 -7
- package/package.json +34 -15
- package/src/activities/agent-turn.ts +1905 -559
- package/src/activities/api-integrations.ts +138 -0
- package/src/activities/codemode-dispatcher.ts +335 -0
- package/src/activities/codemode-token-renewal.ts +64 -0
- package/src/activities/codex-capacity.ts +16 -7
- package/src/activities/codex-image-generation.ts +56 -0
- package/src/activities/codex-rotation.ts +19 -5
- package/src/activities/context-compaction.ts +47 -6
- package/src/activities/documents.ts +14 -4
- package/src/activities/environment.ts +52 -60
- package/src/activities/expiring-material-renewal.ts +16 -7
- 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/git-credential-renewal.ts +3 -3
- package/src/activities/goals.ts +6 -2
- 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 +55 -55
- package/src/activities/recording.ts +4 -5
- package/src/activities/retained-screenshot-reaper.ts +202 -0
- package/src/activities/retained-screenshots.ts +1317 -0
- package/src/activities/rig-verification.ts +567 -77
- package/src/activities/run-credential-renewal.ts +9 -2
- package/src/activities/run-input.ts +40 -10
- package/src/activities/sandbox-images.ts +167 -0
- package/src/activities/sandbox-lease.ts +1065 -483
- package/src/activities/scheduled-tasks.ts +96 -7
- package/src/activities/session-state.ts +4 -4
- package/src/activities/streaming.ts +42 -3
- package/src/activities/types.ts +87 -5
- package/src/activities/video-generation-admission.ts +270 -0
- package/src/activities/video-generation-credential.ts +34 -0
- package/src/activities/video-generation-reconciliation.ts +578 -0
- package/src/activities/video-media-validation.ts +326 -0
- package/src/activities/video-output-retention.ts +314 -0
- package/src/activities/video-reference-staging.ts +263 -0
- package/src/activities/workflow-wake.ts +2 -2
- package/src/activities/workspace-capture.ts +77 -13
- package/src/activities-control.ts +54 -0
- package/src/activities-turn.ts +40 -0
- package/src/activities.ts +50 -118
- 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/host-export-pump.ts +28 -11
- package/src/http.ts +3 -6
- package/src/index.ts +277 -72
- package/src/memory-pressure-guard.ts +489 -0
- package/src/model-checkpoint-memory-collector.ts +116 -0
- package/src/observability-metrics.ts +202 -7
- package/src/sandbox-reaper-contract.ts +73 -0
- package/src/sandbox-reaper-timeout.ts +79 -0
- package/src/sandbox-resume.ts +331 -157
- package/src/sandbox-routing.ts +49 -39
- package/src/worker-service-lifecycle.ts +82 -12
- package/src/workflows/activities.ts +30 -0
- package/src/workflows/file-upload-reaper.ts +6 -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/video-generation.ts +36 -0
- package/src/workflows.ts +17 -1
- package/dist/activities/redaction.d.ts +0 -1
- package/dist/activities/toolspace-token-renewal.d.ts +0 -23
- package/dist/chunk-BJUW5LCM.js.map +0 -1
- package/src/activities/redaction.ts +0 -9
- package/src/activities/toolspace-token-renewal.ts +0 -57
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { type RetainedArtifactMetadata, type RetainedOutputUnavailableReason } from "@opengeni/contracts";
|
|
2
|
+
import { type Database } from "@opengeni/db";
|
|
3
|
+
import type { ObjectStorage } from "@opengeni/storage";
|
|
4
|
+
export type TypedScreenshotToolOutput = {
|
|
5
|
+
callId: string;
|
|
6
|
+
toolOutputId: string;
|
|
7
|
+
bytes: Uint8Array;
|
|
8
|
+
mediaType: string;
|
|
9
|
+
};
|
|
10
|
+
export type ValidatedScreenshot = {
|
|
11
|
+
bytes: Uint8Array;
|
|
12
|
+
mediaType: "image/png";
|
|
13
|
+
sizeBytes: number;
|
|
14
|
+
sha256: string;
|
|
15
|
+
width: number;
|
|
16
|
+
height: number;
|
|
17
|
+
};
|
|
18
|
+
export type RetainableSessionImageMediaType = "image/png" | "image/jpeg" | "image/webp";
|
|
19
|
+
export type ValidatedSessionImage = {
|
|
20
|
+
bytes: Uint8Array;
|
|
21
|
+
mediaType: RetainableSessionImageMediaType;
|
|
22
|
+
extension: "png" | "jpg" | "webp";
|
|
23
|
+
sizeBytes: number;
|
|
24
|
+
sha256: string;
|
|
25
|
+
width: number;
|
|
26
|
+
height: number;
|
|
27
|
+
};
|
|
28
|
+
export declare class ScreenshotValidationError extends Error {
|
|
29
|
+
readonly reason: "invalid_content" | "oversized" | "unsupported";
|
|
30
|
+
constructor(reason: "invalid_content" | "oversized" | "unsupported", message: string);
|
|
31
|
+
}
|
|
32
|
+
export declare class RetainedScreenshotUnavailableError extends Error {
|
|
33
|
+
readonly artifactId: string;
|
|
34
|
+
readonly reason: RetainedOutputUnavailableReason;
|
|
35
|
+
constructor(artifactId: string, reason: RetainedOutputUnavailableReason);
|
|
36
|
+
}
|
|
37
|
+
/** Read an intentional image directly at the tool execution boundary. */
|
|
38
|
+
export declare function typedScreenshotFromToolOutput(input: {
|
|
39
|
+
callId: string;
|
|
40
|
+
output: unknown;
|
|
41
|
+
}): TypedScreenshotToolOutput | null;
|
|
42
|
+
/** Read the SDK's trusted typed image before event/history serialization. */
|
|
43
|
+
export declare function typedScreenshotFromSdkEvent(event: unknown): TypedScreenshotToolOutput | null;
|
|
44
|
+
/** Does this SDK result still contain inline bytes that persistence must replace? */
|
|
45
|
+
export declare function sdkEventContainsInlineImage(event: unknown): boolean;
|
|
46
|
+
export declare function toolOutputContainsInlineImage(output: unknown): boolean;
|
|
47
|
+
/** Validate the complete canonical PNG and derive exact integrity metadata. */
|
|
48
|
+
export declare function validateComputerScreenshot(input: {
|
|
49
|
+
bytes: Uint8Array;
|
|
50
|
+
mediaType: string;
|
|
51
|
+
}, limits?: {
|
|
52
|
+
maxBytes?: number;
|
|
53
|
+
maxDimension?: number;
|
|
54
|
+
maxPixels?: number;
|
|
55
|
+
}): ValidatedScreenshot;
|
|
56
|
+
/** Validate a durable view_image/computer image from bytes, never from its claimed MIME alone. */
|
|
57
|
+
export declare function validateRetainableSessionImage(input: {
|
|
58
|
+
bytes: Uint8Array;
|
|
59
|
+
declaredMediaType?: string;
|
|
60
|
+
}, limits?: {
|
|
61
|
+
maxBytes?: number;
|
|
62
|
+
maxDimension?: number;
|
|
63
|
+
maxPixels?: number;
|
|
64
|
+
}): ValidatedSessionImage;
|
|
65
|
+
export declare function retainedScreenshotIdentity(input: {
|
|
66
|
+
sessionId: string;
|
|
67
|
+
turnId: string;
|
|
68
|
+
attemptId: string;
|
|
69
|
+
toolCallId: string;
|
|
70
|
+
toolOutputId: string;
|
|
71
|
+
}): {
|
|
72
|
+
artifactId: string;
|
|
73
|
+
settlementKey: string;
|
|
74
|
+
};
|
|
75
|
+
/** Deterministic fail-closed receipt installed before retention can perform I/O. */
|
|
76
|
+
export declare function unavailableRetainedSessionImage(input: {
|
|
77
|
+
sessionId: string;
|
|
78
|
+
turnId: string;
|
|
79
|
+
attemptId: string;
|
|
80
|
+
toolCallId: string;
|
|
81
|
+
toolOutputId: string;
|
|
82
|
+
reason: RetainedOutputUnavailableReason;
|
|
83
|
+
}): RetainedArtifactMetadata;
|
|
84
|
+
export declare function retainComputerScreenshot(input: {
|
|
85
|
+
db: Database;
|
|
86
|
+
objectStorage: ObjectStorage | null;
|
|
87
|
+
accountId: string;
|
|
88
|
+
workspaceId: string;
|
|
89
|
+
sessionId: string;
|
|
90
|
+
turnId: string;
|
|
91
|
+
attemptId: string;
|
|
92
|
+
output: TypedScreenshotToolOutput;
|
|
93
|
+
now?: Date;
|
|
94
|
+
retentionMs?: number;
|
|
95
|
+
workspaceQuotaBytes?: number;
|
|
96
|
+
}): Promise<RetainedArtifactMetadata>;
|
|
97
|
+
/** Replace only new screenshot bytes with a compact receipt before first persistence. */
|
|
98
|
+
export declare function compactRetainedScreenshotHistory(history: Array<Record<string, unknown>>, receiptsByCallId: ReadonlyMap<string, RetainedArtifactMetadata>): Array<Record<string, unknown>>;
|
|
99
|
+
/** Collect durable screenshot receipts before their provider-only expansion. */
|
|
100
|
+
export declare function collectRetainedScreenshotReceipts(history: ReadonlyArray<Record<string, unknown>>, target?: Map<string, RetainedArtifactMetadata>): Map<string, RetainedArtifactMetadata>;
|
|
101
|
+
/**
|
|
102
|
+
* Compact every protocol-item copy inside an SDK RunState before persistence.
|
|
103
|
+
* The traversal intentionally mirrors the repository's existing serialized
|
|
104
|
+
* RunState sanitizers. A parse failure or no-op returns the original string.
|
|
105
|
+
*/
|
|
106
|
+
export declare function compactRetainedScreenshotRunState(serialized: string, receiptsByCallId: ReadonlyMap<string, RetainedArtifactMetadata>): string;
|
|
107
|
+
export declare function collectRetainedScreenshotRunStateReceipts(serialized: string, target?: Map<string, RetainedArtifactMetadata>): Map<string, RetainedArtifactMetadata>;
|
|
108
|
+
/**
|
|
109
|
+
* Materialize canonical receipts to the exact SDK input_image data URL shape.
|
|
110
|
+
* Missing/deleted/expired/corrupt bytes fail closed; no item is omitted,
|
|
111
|
+
* reordered, rewritten in storage, or converted to text.
|
|
112
|
+
*/
|
|
113
|
+
export declare function materializeRetainedScreenshotHistory(input: {
|
|
114
|
+
db: Database;
|
|
115
|
+
objectStorage: ObjectStorage | null;
|
|
116
|
+
workspaceId: string;
|
|
117
|
+
sessionId: string;
|
|
118
|
+
history: Array<Record<string, unknown>>;
|
|
119
|
+
now?: Date;
|
|
120
|
+
}): Promise<Array<Record<string, unknown>>>;
|
|
121
|
+
/** Expand durable markers in an SDK RunState immediately before resume. */
|
|
122
|
+
export declare function materializeRetainedScreenshotRunState(input: {
|
|
123
|
+
db: Database;
|
|
124
|
+
objectStorage: ObjectStorage | null;
|
|
125
|
+
workspaceId: string;
|
|
126
|
+
sessionId: string;
|
|
127
|
+
serialized: string;
|
|
128
|
+
now?: Date;
|
|
129
|
+
}): Promise<string>;
|
|
@@ -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;
|
|
@@ -19,7 +19,7 @@ export type RunCredentialRenewalOptions = {
|
|
|
19
19
|
}) => void;
|
|
20
20
|
onFailure?: (failure: {
|
|
21
21
|
retryDelayMs: number;
|
|
22
|
-
errorClass:
|
|
22
|
+
errorClass: "RunCredentialRenewalOperationError";
|
|
23
23
|
}) => void;
|
|
24
24
|
};
|
|
25
25
|
export declare function nextRunCredentialRenewalDelay(expiresAt: Date | null, nowMs?: number): number;
|
|
@@ -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,7 +27,11 @@ export type TurnInputOptions = {
|
|
|
27
27
|
unavailableSandboxFilesNote?: string;
|
|
28
28
|
runCredentialsNote?: string;
|
|
29
29
|
providerApi: HistoryProviderApi;
|
|
30
|
+
projectCanonicalHistory?: ModelHistoryAttachmentProjector;
|
|
31
|
+
materializeModelHistory?: ModelHistoryAttachmentProjector;
|
|
32
|
+
materializeSerializedRunState?: (serialized: string) => Promise<string>;
|
|
30
33
|
projectModelHistory?: ModelHistoryAttachmentProjector;
|
|
34
|
+
loadActiveHistory?: typeof getActiveSessionHistoryItemsPaged;
|
|
31
35
|
};
|
|
32
36
|
export declare const MAX_INLINE_MODEL_ATTACHMENT_BYTES: number;
|
|
33
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
1
|
import { settleSessionAttemptInterruptions, applySessionTurnSettlement, requestSessionTurnRecovery, recoverSessionDispatch, reconcileSessionAttemptQuiescence, peekSessionWork as peekSessionWorkDb, countQueuedTurns, getSessionAttemptActivityRef, getSessionEvent, getSessionTurnForAttempt, 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, 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;
|
|
@@ -24,7 +24,7 @@ export type SessionStateActivityOverrides = Partial<{
|
|
|
24
24
|
recordTurnsQueuedGauge: typeof recordTurnsQueuedGauge;
|
|
25
25
|
}>;
|
|
26
26
|
export declare const WORKER_DEATH_MAX_REDISPATCHES = 3;
|
|
27
|
-
export declare function createSessionStateActivities(services: () => Promise<
|
|
27
|
+
export declare function createSessionStateActivities(services: () => Promise<ControlActivityServices>, overrides?: SessionStateActivityOverrides): {
|
|
28
28
|
failSessionAttempt: (input: FailSessionAttemptInput) => Promise<void>;
|
|
29
29
|
settleSessionInterruptions: (input: SettleSessionInterruptionsInput) => Promise<{
|
|
30
30
|
action: "paused" | "continue" | "stale";
|
|
@@ -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,9 +66,26 @@ 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 = {
|
|
63
90
|
waiterId: string;
|
|
64
91
|
generation: number;
|
|
@@ -83,6 +110,8 @@ export type ReconcileCodexCapacityWaitResult = ({
|
|
|
83
110
|
action: "resumed" | "paused" | "superseded" | "stale";
|
|
84
111
|
};
|
|
85
112
|
export type ActivityDependencies = Partial<ActivityServices>;
|
|
113
|
+
export type ControlActivityDependencies = Partial<ControlActivityServices>;
|
|
114
|
+
export type TurnActivityDependencies = Partial<TurnActivityServices>;
|
|
86
115
|
export type RunAgentTurnInput = {
|
|
87
116
|
accountId: string;
|
|
88
117
|
workspaceId: string;
|
|
@@ -97,6 +126,14 @@ export type RunAgentTurnInput = {
|
|
|
97
126
|
triggerEventId: string;
|
|
98
127
|
};
|
|
99
128
|
};
|
|
129
|
+
export type VideoGenerationTerminalStatus = "completed" | "provider_failed" | "cancelled_before_submit" | "outcome_unknown" | "retention_failed";
|
|
130
|
+
export type VideoGenerationReconcileResult = {
|
|
131
|
+
action: "waiting";
|
|
132
|
+
delayMs: number;
|
|
133
|
+
} | {
|
|
134
|
+
action: "terminal";
|
|
135
|
+
status: VideoGenerationTerminalStatus;
|
|
136
|
+
};
|
|
100
137
|
export type SettleSessionInterruptionsInput = {
|
|
101
138
|
accountId: string;
|
|
102
139
|
workspaceId: string;
|
|
@@ -200,7 +237,7 @@ export type DispatchScheduledTaskRunInput = {
|
|
|
200
237
|
agentRunUsageIdempotencyKey?: never;
|
|
201
238
|
initiator?: never;
|
|
202
239
|
} | {
|
|
203
|
-
triggerType: Extract<ScheduledTaskTriggerType, "manual">;
|
|
240
|
+
triggerType: Extract<ScheduledTaskTriggerType, "manual" | "initial" | "provider_event" | "retry" | "repair">;
|
|
204
241
|
agentRunUsageIdempotencyKey: string;
|
|
205
242
|
/** Exact identity used by the API-side charge for this same trigger. */
|
|
206
243
|
initiator: TurnInitiator;
|
|
@@ -209,7 +246,7 @@ export type DispatchScheduledTaskRunResult = {
|
|
|
209
246
|
action: "deleted";
|
|
210
247
|
} | {
|
|
211
248
|
action: "blocked";
|
|
212
|
-
reason: "insufficient_credits" | "monthly_model_cost_limit" | "monthly_agent_run_limit" | "malformed_manual_trigger";
|
|
249
|
+
reason: "insufficient_credits" | "monthly_model_cost_limit" | "monthly_agent_run_limit" | "malformed_manual_trigger" | "knowledge_source_paused";
|
|
213
250
|
} | {
|
|
214
251
|
action: "start" | "signal";
|
|
215
252
|
accountId: string;
|
|
@@ -218,6 +255,35 @@ export type DispatchScheduledTaskRunResult = {
|
|
|
218
255
|
triggerEventId: string;
|
|
219
256
|
workflowId: string;
|
|
220
257
|
workflowWakeRevision: number | null;
|
|
258
|
+
} | {
|
|
259
|
+
action: "knowledge_source_sync";
|
|
260
|
+
accountId: string;
|
|
261
|
+
workspaceId: string;
|
|
262
|
+
taskId: string;
|
|
263
|
+
scheduledTaskRunId: string;
|
|
264
|
+
sourceId: string;
|
|
265
|
+
overlapPolicy: "skip" | "buffer_one";
|
|
266
|
+
};
|
|
267
|
+
export type RunKnowledgeSourceSyncBatchInput = {
|
|
268
|
+
accountId: string;
|
|
269
|
+
workspaceId: string;
|
|
270
|
+
taskId: string;
|
|
271
|
+
scheduledTaskRunId: string;
|
|
272
|
+
sourceId: string;
|
|
273
|
+
overlapPolicy: "skip" | "buffer_one";
|
|
274
|
+
};
|
|
275
|
+
export type RunKnowledgeSourceSyncBatchResult = {
|
|
276
|
+
action: "continue";
|
|
277
|
+
} | {
|
|
278
|
+
action: "complete";
|
|
279
|
+
bufferedWake: boolean;
|
|
280
|
+
bufferedScheduledTaskRunId?: string | null;
|
|
281
|
+
} | {
|
|
282
|
+
action: "skipped" | "buffered";
|
|
283
|
+
} | {
|
|
284
|
+
action: "failed";
|
|
285
|
+
bufferedWake: boolean;
|
|
286
|
+
bufferedScheduledTaskRunId?: string | null;
|
|
221
287
|
};
|
|
222
288
|
type DocumentIndexIdentity = {
|
|
223
289
|
accountId: string;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { VideoGenerationAcceptedReceipt, type GenerateVideoToolInput, type VideoGenerationCapabilities, type VideoGenerationPolicy } from "@opengeni/contracts";
|
|
2
|
+
import { type Database } 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";
|
|
8
|
+
connectionId: string | null;
|
|
9
|
+
version: number;
|
|
10
|
+
credentialEncrypted: string;
|
|
11
|
+
apiKey: string;
|
|
12
|
+
}>;
|
|
13
|
+
export type AcceptedVideoGeneration = Readonly<{
|
|
14
|
+
receipt: ReturnType<typeof VideoGenerationAcceptedReceipt.parse>;
|
|
15
|
+
operationId: string;
|
|
16
|
+
requestDigest: string;
|
|
17
|
+
}>;
|
|
18
|
+
export declare function videoCapabilitiesForTurn(input: {
|
|
19
|
+
policy: VideoGenerationPolicy;
|
|
20
|
+
credential: VideoGenerationCredentialLease;
|
|
21
|
+
}): VideoGenerationCapabilities;
|
|
22
|
+
export declare function managedVideoGenerationCredentialLease(settings: Settings): VideoGenerationCredentialLease | null;
|
|
23
|
+
export declare function admitVideoGenerationRequest(input: {
|
|
24
|
+
db: Database;
|
|
25
|
+
storage: ObjectStorage;
|
|
26
|
+
settings: Settings;
|
|
27
|
+
accountId: string;
|
|
28
|
+
workspaceId: string;
|
|
29
|
+
sessionId: string;
|
|
30
|
+
turnId: string;
|
|
31
|
+
attemptId: string;
|
|
32
|
+
toolCallId: string;
|
|
33
|
+
toolInput: GenerateVideoToolInput;
|
|
34
|
+
policy: VideoGenerationPolicy;
|
|
35
|
+
credential: VideoGenerationCredentialLease;
|
|
36
|
+
runCommand?: SandboxCommandRunner;
|
|
37
|
+
signal?: AbortSignal;
|
|
38
|
+
}): Promise<AcceptedVideoGeneration>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** One frozen, provider-neutral credential envelope for every video funding route. */
|
|
2
|
+
export declare function encryptVideoGenerationApiKey(key: Uint8Array, apiKey: string): string;
|
|
3
|
+
/**
|
|
4
|
+
* Decrypt without ever attaching parser/decryption errors: JSON parser errors
|
|
5
|
+
* may quote plaintext and must not enter Temporal failure payloads or logs.
|
|
6
|
+
*/
|
|
7
|
+
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>;
|