@opengeni/worker-bundle 0.16.29 → 0.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (188) hide show
  1. package/dist/activities/agent-run-admission.d.ts +12 -0
  2. package/dist/activities/agent-turn.d.ts +110 -19
  3. package/dist/activities/api-integrations.d.ts +21 -0
  4. package/dist/activities/browser-state-artifact-reaper.d.ts +29 -0
  5. package/dist/activities/capabilities.d.ts +6 -0
  6. package/dist/activities/codemode-dispatcher.d.ts +35 -0
  7. package/dist/activities/codemode-token-renewal.d.ts +23 -0
  8. package/dist/activities/codex-capacity.d.ts +6 -5
  9. package/dist/activities/codex-image-generation.d.ts +21 -0
  10. package/dist/activities/context-compaction.d.ts +1 -0
  11. package/dist/activities/documents.d.ts +3 -2
  12. package/dist/activities/environment.d.ts +17 -8
  13. package/dist/activities/expiring-material-renewal.d.ts +1 -1
  14. package/dist/activities/file-upload-reaper.d.ts +7 -2
  15. package/dist/activities/gateway-image-generation.d.ts +39 -0
  16. package/dist/activities/gateway-video-generation.d.ts +53 -0
  17. package/dist/activities/generated-images.d.ts +112 -0
  18. package/dist/activities/git-credential-renewal.d.ts +1 -1
  19. package/dist/activities/goals.d.ts +2 -2
  20. package/dist/activities/google-drive-changes.d.ts +99 -0
  21. package/dist/activities/image-generation-operation.d.ts +74 -0
  22. package/dist/activities/image-generation-references.d.ts +25 -0
  23. package/dist/activities/knowledge-source-sync-driver.d.ts +23 -0
  24. package/dist/activities/knowledge-source-sync.d.ts +75 -0
  25. package/dist/activities/packs.d.ts +21 -36
  26. package/dist/activities/parent-wake.d.ts +1 -1
  27. package/dist/activities/retained-screenshot-reaper.d.ts +2 -2
  28. package/dist/activities/retained-screenshots.d.ts +36 -0
  29. package/dist/activities/rig-verification.d.ts +82 -5
  30. package/dist/activities/run-credential-renewal.d.ts +1 -1
  31. package/dist/activities/run-input.d.ts +3 -1
  32. package/dist/activities/sandbox-images.d.ts +14 -0
  33. package/dist/activities/sandbox-lease.d.ts +47 -9
  34. package/dist/activities/scheduled-tasks.d.ts +2 -2
  35. package/dist/activities/session-state.d.ts +7 -5
  36. package/dist/activities/site-auth-maintenance.d.ts +27 -0
  37. package/dist/activities/streaming.d.ts +1 -1
  38. package/dist/activities/types.d.ts +87 -5
  39. package/dist/activities/video-generation-admission.d.ts +43 -0
  40. package/dist/activities/video-generation-credential.d.ts +24 -0
  41. package/dist/activities/video-generation-reconciliation.d.ts +13 -0
  42. package/dist/activities/video-media-validation.d.ts +34 -0
  43. package/dist/activities/video-output-retention.d.ts +36 -0
  44. package/dist/activities/video-reference-staging.d.ts +55 -0
  45. package/dist/activities/workflow-wake.d.ts +2 -2
  46. package/dist/activities/workspace-capture.d.ts +10 -1
  47. package/dist/activities/xai-auth.d.ts +23 -0
  48. package/dist/activities/xai-image-generation.d.ts +26 -0
  49. package/dist/activities/xai-video-generation.d.ts +18 -0
  50. package/dist/activities-control-XURE4VKN.js +7221 -0
  51. package/dist/activities-control-XURE4VKN.js.map +1 -0
  52. package/dist/activities-control.d.ts +297 -0
  53. package/dist/activities-turn-6EBXGGLS.js +16036 -0
  54. package/dist/activities-turn-6EBXGGLS.js.map +1 -0
  55. package/dist/activities-turn.d.ts +17 -0
  56. package/dist/activities.d.ts +138 -150
  57. package/dist/activity-services.d.ts +10 -0
  58. package/dist/artifact-materializer-entry.d.ts +6 -0
  59. package/dist/artifact-materializer-entry.js +2662 -0
  60. package/dist/artifact-materializer-entry.js.map +1 -0
  61. package/dist/artifact-outbox-entry.d.ts +2 -0
  62. package/dist/artifact-outbox-entry.js +681 -0
  63. package/dist/artifact-outbox-entry.js.map +1 -0
  64. package/dist/chunk-5GRJIP5H.js +3092 -0
  65. package/dist/chunk-5GRJIP5H.js.map +1 -0
  66. package/dist/chunk-GRFQTTSQ.js +448 -0
  67. package/dist/chunk-GRFQTTSQ.js.map +1 -0
  68. package/dist/chunk-TYNPCG4U.js +906 -0
  69. package/dist/chunk-TYNPCG4U.js.map +1 -0
  70. package/dist/concurrency.d.ts +108 -5
  71. package/dist/editable-artifact-hint-broker.d.ts +49 -0
  72. package/dist/editable-artifact-materializer-launcher.d.ts +49 -0
  73. package/dist/editable-artifact-materializer-service.d.ts +108 -0
  74. package/dist/editable-artifact-materializer-storage.d.ts +12 -0
  75. package/dist/editable-artifact-materializer-subprocess.d.ts +50 -0
  76. package/dist/editable-artifact-materializer.d.ts +262 -0
  77. package/dist/editable-artifact-outbox-dispatcher.d.ts +44 -0
  78. package/dist/editable-artifact-outbox-service.d.ts +70 -0
  79. package/dist/host-export.d.ts +1 -1
  80. package/dist/index.d.ts +189 -10
  81. package/dist/index.js +715 -17380
  82. package/dist/index.js.map +1 -1
  83. package/dist/memory-pressure-guard.d.ts +57 -0
  84. package/dist/model-checkpoint-memory-collector.d.ts +23 -0
  85. package/dist/model-context-contributions.d.ts +40 -0
  86. package/dist/observability-metrics.d.ts +53 -1
  87. package/dist/sandbox-reaper-contract.d.ts +40 -0
  88. package/dist/sandbox-reaper-timeout.d.ts +14 -0
  89. package/dist/sandbox-resume.d.ts +34 -7
  90. package/dist/sandbox-routing.d.ts +6 -0
  91. package/dist/worker-service-lifecycle.d.ts +6 -2
  92. package/dist/workflow-bundle.js +1094 -370
  93. package/dist/workflows/activities.d.ts +8 -2
  94. package/dist/workflows/document-index.d.ts +1 -1
  95. package/dist/workflows/knowledge-source-sync.d.ts +13 -0
  96. package/dist/workflows/rig-verification.d.ts +1 -1
  97. package/dist/workflows/sandbox-reaper.d.ts +8 -0
  98. package/dist/workflows/scheduled-tasks.d.ts +1 -1
  99. package/dist/workflows/session.d.ts +2 -2
  100. package/dist/workflows/site-auth-maintenance.d.ts +2 -0
  101. package/dist/workflows/video-generation.d.ts +10 -0
  102. package/dist/workflows/workflow-wake.d.ts +1 -1
  103. package/dist/workflows.d.ts +10 -7
  104. package/package.json +35 -15
  105. package/src/activities/agent-run-admission.ts +76 -0
  106. package/src/activities/agent-turn.ts +2600 -340
  107. package/src/activities/api-integrations.ts +138 -0
  108. package/src/activities/browser-state-artifact-reaper.ts +120 -0
  109. package/src/activities/capabilities.ts +10 -0
  110. package/src/activities/codemode-dispatcher.ts +335 -0
  111. package/src/activities/codemode-token-renewal.ts +64 -0
  112. package/src/activities/codex-capacity.ts +54 -7
  113. package/src/activities/codex-image-generation.ts +56 -0
  114. package/src/activities/context-compaction.ts +38 -3
  115. package/src/activities/documents.ts +14 -4
  116. package/src/activities/environment.ts +54 -45
  117. package/src/activities/expiring-material-renewal.ts +1 -1
  118. package/src/activities/file-upload-reaper.ts +34 -3
  119. package/src/activities/gateway-image-generation.ts +146 -0
  120. package/src/activities/gateway-video-generation.ts +298 -0
  121. package/src/activities/generated-images.ts +860 -0
  122. package/src/activities/goals.ts +8 -3
  123. package/src/activities/google-drive-changes.ts +454 -0
  124. package/src/activities/image-generation-operation.ts +333 -0
  125. package/src/activities/image-generation-references.ts +118 -0
  126. package/src/activities/knowledge-source-sync-driver.ts +27 -0
  127. package/src/activities/knowledge-source-sync.ts +2840 -0
  128. package/src/activities/mcp-credentials.ts +1 -0
  129. package/src/activities/packs.ts +75 -152
  130. package/src/activities/parent-wake.ts +13 -1
  131. package/src/activities/retained-screenshot-reaper.ts +2 -2
  132. package/src/activities/retained-screenshots.ts +453 -28
  133. package/src/activities/rig-verification.ts +554 -43
  134. package/src/activities/run-input.ts +22 -6
  135. package/src/activities/sandbox-images.ts +167 -0
  136. package/src/activities/sandbox-lease.ts +1065 -483
  137. package/src/activities/scheduled-tasks.ts +104 -74
  138. package/src/activities/session-state.ts +22 -4
  139. package/src/activities/site-auth-maintenance.ts +269 -0
  140. package/src/activities/streaming.ts +42 -3
  141. package/src/activities/types.ts +104 -5
  142. package/src/activities/video-generation-admission.ts +303 -0
  143. package/src/activities/video-generation-credential.ts +112 -0
  144. package/src/activities/video-generation-reconciliation.ts +771 -0
  145. package/src/activities/video-media-validation.ts +332 -0
  146. package/src/activities/video-output-retention.ts +314 -0
  147. package/src/activities/video-reference-staging.ts +350 -0
  148. package/src/activities/workflow-wake.ts +2 -2
  149. package/src/activities/workspace-capture.ts +44 -10
  150. package/src/activities/xai-auth.ts +122 -0
  151. package/src/activities/xai-image-generation.ts +86 -0
  152. package/src/activities/xai-video-generation.ts +69 -0
  153. package/src/activities-control.ts +58 -0
  154. package/src/activities-turn.ts +40 -0
  155. package/src/activities.ts +53 -124
  156. package/src/activity-services.ts +62 -0
  157. package/src/artifact-materializer-entry.ts +35 -0
  158. package/src/artifact-outbox-entry.ts +29 -0
  159. package/src/concurrency.ts +484 -6
  160. package/src/editable-artifact-hint-broker.ts +235 -0
  161. package/src/editable-artifact-materializer-launcher.ts +515 -0
  162. package/src/editable-artifact-materializer-service.ts +787 -0
  163. package/src/editable-artifact-materializer-storage.ts +413 -0
  164. package/src/editable-artifact-materializer-subprocess.ts +956 -0
  165. package/src/editable-artifact-materializer.ts +1289 -0
  166. package/src/editable-artifact-outbox-dispatcher.ts +244 -0
  167. package/src/editable-artifact-outbox-service.ts +438 -0
  168. package/src/index.ts +328 -72
  169. package/src/memory-pressure-guard.ts +489 -0
  170. package/src/model-checkpoint-memory-collector.ts +123 -0
  171. package/src/model-context-contributions.ts +159 -0
  172. package/src/observability-metrics.ts +297 -13
  173. package/src/sandbox-reaper-contract.ts +73 -0
  174. package/src/sandbox-reaper-timeout.ts +79 -0
  175. package/src/sandbox-resume.ts +294 -153
  176. package/src/sandbox-routing.ts +32 -24
  177. package/src/worker-service-lifecycle.ts +80 -14
  178. package/src/workflows/activities.ts +31 -0
  179. package/src/workflows/file-upload-reaper.ts +9 -1
  180. package/src/workflows/knowledge-source-sync.ts +83 -0
  181. package/src/workflows/sandbox-reaper.ts +183 -21
  182. package/src/workflows/scheduled-tasks.ts +42 -6
  183. package/src/workflows/session.ts +20 -6
  184. package/src/workflows/site-auth-maintenance.ts +14 -0
  185. package/src/workflows/video-generation.ts +36 -0
  186. package/src/workflows.ts +18 -1
  187. package/dist/activities/toolspace-token-renewal.d.ts +0 -23
  188. package/src/activities/toolspace-token-renewal.ts +0 -64
@@ -0,0 +1,112 @@
1
+ import { type GeneratedImageReceipt } from "@opengeni/contracts";
2
+ import { type Database, type GeneratedImageArtifact, type GeneratedImageSourceStrategy } from "@opengeni/db";
3
+ import type { ObjectStorage } from "@opengeni/storage";
4
+ export type GeneratedImageMediaType = "image/png" | "image/jpeg" | "image/webp";
5
+ export type ValidatedGeneratedImage = {
6
+ bytes: Uint8Array;
7
+ mediaType: GeneratedImageMediaType;
8
+ extension: "png" | "jpg" | "webp";
9
+ sizeBytes: number;
10
+ sha256: string;
11
+ width: number;
12
+ height: number;
13
+ };
14
+ export type GeneratedImageOutput = {
15
+ toolCallId: string;
16
+ providerItemId: string | null;
17
+ bytes: Uint8Array;
18
+ declaredMediaType?: string;
19
+ };
20
+ export type { GeneratedImageReceipt };
21
+ export type RetainedGeneratedImage = {
22
+ receipt: GeneratedImageReceipt;
23
+ artifact: GeneratedImageArtifact;
24
+ };
25
+ export declare class GeneratedImageValidationError extends Error {
26
+ constructor(message: string);
27
+ }
28
+ /** Extract the completed Responses hosted-tool payload before JSON serialization. */
29
+ export declare function generatedImageFromSdkEvent(event: unknown): GeneratedImageOutput | null;
30
+ /** Classify the native terminal item independently from its current payload shape. */
31
+ export declare function isCompletedGeneratedImageSdkEvent(event: unknown): boolean;
32
+ export declare function generatedImagesFromHistory(history: ReadonlyArray<Record<string, unknown>>, retainedProviderItems?: Pick<ReadonlyMap<string, unknown>, "has">): GeneratedImageOutput[];
33
+ /** Refuse to serialize a completed native item unless its bytes have a receipt. */
34
+ export declare function assertGeneratedImageHistoryRetained(history: ReadonlyArray<Record<string, unknown>>, receiptsByProviderItemId: Pick<ReadonlyMap<string, unknown>, "has">): void;
35
+ export declare function decodeGeneratedImageBase64(value: string): Uint8Array;
36
+ /** Validate signatures and dimensions; never trust provider-declared MIME metadata. */
37
+ export declare function validateGeneratedImage(input: {
38
+ bytes: Uint8Array;
39
+ declaredMediaType?: string;
40
+ }): ValidatedGeneratedImage;
41
+ type GeneratedImageIdentityInput = {
42
+ workspaceId: string;
43
+ sessionId: string;
44
+ turnId: string;
45
+ providerId: string;
46
+ providerBindingHash: string;
47
+ toolCallId: string;
48
+ } & ({
49
+ sourceStrategy: "native_hosted";
50
+ providerItemId: string;
51
+ } | {
52
+ sourceStrategy: "provider_adapter";
53
+ providerItemId: null;
54
+ });
55
+ export declare function generatedImageIdentity(input: GeneratedImageIdentityInput): {
56
+ artifactId: string;
57
+ uploadId: string;
58
+ settlementKey: string;
59
+ };
60
+ export declare function retainGeneratedImage(input: {
61
+ db: Database;
62
+ objectStorage: ObjectStorage | null;
63
+ accountId: string;
64
+ workspaceId: string;
65
+ sessionId: string;
66
+ turnId: string;
67
+ attemptId: string;
68
+ sourceStrategy: GeneratedImageSourceStrategy;
69
+ providerId: string;
70
+ providerBindingHash: string;
71
+ output: GeneratedImageOutput;
72
+ now?: Date;
73
+ }): Promise<RetainedGeneratedImage>;
74
+ /** Replace provider bytes before they can enter event/history serialization. */
75
+ export declare function compactGeneratedImageHistory(history: Array<Record<string, unknown>>, receiptsByProviderItemId: ReadonlyMap<string, GeneratedImageReceipt>): Array<Record<string, unknown>>;
76
+ export declare function compactGeneratedImageSdkEvent(event: unknown, receipt: GeneratedImageReceipt): unknown;
77
+ export declare function collectGeneratedImageReceipts(history: ReadonlyArray<Record<string, unknown>>, target?: Map<string, GeneratedImageReceipt>): Map<string, GeneratedImageReceipt>;
78
+ export declare function collectGeneratedImageArtifactReceipts(history: ReadonlyArray<Record<string, unknown>>, target?: Map<string, GeneratedImageReceipt>): Map<string, GeneratedImageReceipt>;
79
+ /**
80
+ * Project native image calls to one provider-neutral, cache-stable model fact.
81
+ * The canonical hosted-tool item remains available to the UI, but its provider
82
+ * id and compact receipt are never replayed as a counterfeit native result.
83
+ */
84
+ export declare function projectGeneratedImageHistoryForModel(history: Array<Record<string, unknown>>): Array<Record<string, unknown>>;
85
+ /**
86
+ * Build the attempt-local RunState view consumed by the Agents SDK on resume.
87
+ *
88
+ * OpenAI serializes a hosted image call from `providerData.result`, not from
89
+ * the SDK item's generic `output`. Our durable state deliberately replaces
90
+ * those bytes with a compact receipt, so replaying the hosted item would send
91
+ * a counterfeit `result: null`. Convert it to the same provider-neutral fact
92
+ * used for ordinary history instead. Durable state is never modified.
93
+ */
94
+ export declare function projectGeneratedImageRunStateForModel(serialized: string): string;
95
+ export declare function compactGeneratedImageRunState(serialized: string, receiptsByProviderItemId: ReadonlyMap<string, GeneratedImageReceipt>): string;
96
+ export declare function collectGeneratedImageRunStateArtifactReceipts(serialized: string, target?: Map<string, GeneratedImageReceipt>): Map<string, GeneratedImageReceipt>;
97
+ export declare function generatedImageReceiptFromUnknown(value: unknown): GeneratedImageReceipt | null;
98
+ export declare function retainedGeneratedImageFromArtifact(artifact: GeneratedImageArtifact): RetainedGeneratedImage;
99
+ /** Verify a recovered ready correlation against the immutable object metadata. */
100
+ export declare function verifyReadyGeneratedImageArtifact(storage: ObjectStorage, artifact: GeneratedImageArtifact): Promise<void>;
101
+ /**
102
+ * Finish a crash-interrupted upload from immutable DB/object metadata without
103
+ * provider replay. A missing object is not proof that generation failed: the
104
+ * paid outcome remains unknown and the caller may check again later.
105
+ */
106
+ export declare function recoverGeneratedImageArtifact(input: {
107
+ db: Database;
108
+ storage: ObjectStorage;
109
+ accountId: string;
110
+ workspaceId: string;
111
+ artifact: GeneratedImageArtifact;
112
+ }): Promise<GeneratedImageArtifact | null>;
@@ -1,5 +1,5 @@
1
1
  import type { GitCredentialProvider } from "@opengeni/contracts";
2
- import type { GitTokenExpiries, GitTokenSeeds, MintedRunGitCredentials } from "./environment";
2
+ import type { GitTokenExpiries, GitTokenSeeds, MintedRunGitCredentials } from "./environment.js";
3
3
  export declare const GIT_CREDENTIAL_DEFAULT_REFRESH_MS: number;
4
4
  export declare const GIT_CREDENTIAL_EXPIRY_LEAD_MS: number;
5
5
  export declare const GIT_CREDENTIAL_MIN_REFRESH_MS = 5000;
@@ -1,7 +1,7 @@
1
1
  import { type Settings } from "@opengeni/config";
2
2
  import { type SessionGoal, type ToolRef } from "@opengeni/contracts";
3
- import type { ActivityServices, MaybeContinueGoalInput, MaybeContinueGoalResult } from "./types";
4
- export declare function createGoalActivities(services: () => Promise<ActivityServices>): {
3
+ import type { ControlActivityServices, MaybeContinueGoalInput, MaybeContinueGoalResult } from "./types.js";
4
+ export declare function createGoalActivities(services: () => Promise<ControlActivityServices>): {
5
5
  enqueueGoalRetryWake: (input: MaybeContinueGoalInput) => Promise<void>;
6
6
  maybeContinueGoal: (input: MaybeContinueGoalInput) => Promise<MaybeContinueGoalResult>;
7
7
  };
@@ -0,0 +1,99 @@
1
+ import type { GoogleDriveSelectedSource } from "@opengeni/contracts/google-drive";
2
+ import { type GoogleDriveInventoryEntry, type GoogleDriveInventoryProviderItem } from "@opengeni/documents/google-drive";
3
+ export type GoogleDriveSyncBudget = {
4
+ examinedItems: number;
5
+ providerRequests: number;
6
+ elapsedMs: number;
7
+ };
8
+ export type GoogleDriveChangesCursor = {
9
+ version: 1;
10
+ kind: "google_drive_changes";
11
+ connectionId: string;
12
+ googlePermissionId: string;
13
+ sourceId: string;
14
+ driveId: string | null;
15
+ boundaryId: string;
16
+ pageToken: string;
17
+ cursorGeneration: number;
18
+ lastFullReconciliationAt: string;
19
+ nextFullReconciliationAt: string;
20
+ };
21
+ export type GoogleDriveChangesCheckpoint = {
22
+ version: 2;
23
+ pageToken: string;
24
+ requiresFullReconciliation: boolean;
25
+ seenPageTokenHashes: string[];
26
+ budget: GoogleDriveSyncBudget;
27
+ };
28
+ export type GoogleDriveChange = {
29
+ fileId: string;
30
+ removed: boolean;
31
+ file: GoogleDriveInventoryProviderItem | null;
32
+ };
33
+ export type GoogleDriveChangesPage = {
34
+ changes: GoogleDriveChange[];
35
+ nextPageToken: string | null;
36
+ newStartPageToken: string | null;
37
+ };
38
+ export type GoogleDriveChangesStopReason = "item_limit" | "api_request_limit" | "elapsed_time_limit";
39
+ export type GoogleDriveChangesDrainResult = {
40
+ status: "complete" | "paused";
41
+ stopReason: GoogleDriveChangesStopReason | null;
42
+ entries: GoogleDriveInventoryEntry[];
43
+ checkpoint: GoogleDriveChangesCheckpoint | null;
44
+ newStartPageToken: string | null;
45
+ requiresFullReconciliation: boolean;
46
+ providerRequests: number;
47
+ elapsedMs: number;
48
+ budget: GoogleDriveSyncBudget;
49
+ hardLimitReached: boolean;
50
+ };
51
+ export declare function parseGoogleDriveChangesCursor(value: Record<string, unknown> | null, expected: {
52
+ connectionId: string;
53
+ googlePermissionId: string;
54
+ sourceId: string;
55
+ driveId: string | null;
56
+ }): GoogleDriveChangesCursor | null;
57
+ export declare function buildGoogleDriveChangesCursor(input: {
58
+ connectionId: string;
59
+ googlePermissionId: string;
60
+ sourceId: string;
61
+ driveId: string | null;
62
+ boundaryId: string;
63
+ pageToken: string;
64
+ previousGeneration: number;
65
+ reconciledAt: Date;
66
+ fullReconciliationIntervalMs: number;
67
+ }): GoogleDriveChangesCursor;
68
+ export declare function advanceGoogleDriveChangesCursor(cursor: GoogleDriveChangesCursor, pageToken: string): GoogleDriveChangesCursor;
69
+ export declare function googleDriveFullReconciliationDue(cursor: GoogleDriveChangesCursor, now: Date): boolean;
70
+ export declare function resolveGoogleDriveChangesBoundaryId(input: {
71
+ source: GoogleDriveSelectedSource;
72
+ getFile: (fileId: string) => Promise<GoogleDriveInventoryProviderItem | null>;
73
+ }): Promise<string>;
74
+ export declare function parseGoogleDriveChangesCheckpoint(value: unknown, limits: {
75
+ maxItems: number;
76
+ maxProviderRequests: number;
77
+ maxElapsedMs: number;
78
+ }): GoogleDriveChangesCheckpoint | null;
79
+ export declare function drainGoogleDriveChanges(input: {
80
+ source: GoogleDriveSelectedSource;
81
+ cursor: GoogleDriveChangesCursor;
82
+ checkpoint: GoogleDriveChangesCheckpoint | null;
83
+ maxItems: number;
84
+ maxProviderRequests: number;
85
+ maxElapsedMs: number;
86
+ maxInvocationElapsedMs: number;
87
+ maxFileBytes: number;
88
+ listChanges: (pageToken: string, pageSize: number) => Promise<GoogleDriveChangesPage>;
89
+ getFile: (fileId: string) => Promise<GoogleDriveInventoryProviderItem | null>;
90
+ observedExternalObjectIds: (ids: string[]) => Promise<Set<string>>;
91
+ now?: () => number;
92
+ }): Promise<GoogleDriveChangesDrainResult>;
93
+ export declare class GoogleDriveCursorInvalidError extends Error {
94
+ budget: GoogleDriveSyncBudget | null;
95
+ constructor();
96
+ }
97
+ export declare class GoogleDriveChangesProtocolError extends Error {
98
+ constructor(message: string);
99
+ }
@@ -0,0 +1,74 @@
1
+ import { beginImageGenerationOperation, completeImageGenerationOperation, markImageGenerationOperationOutcomeUnknown, markImageGenerationOperationRetentionFailed, prepareImageGenerationOperation, type Database } from "@opengeni/db";
2
+ import type { ObjectStorage } from "@opengeni/storage";
3
+ import { retainGeneratedImage, type GeneratedImageOutput, type GeneratedImageReceipt } from "./generated-images.js";
4
+ export declare class ImageGenerationOutcomeUnknownError extends Error {
5
+ readonly operationId: string;
6
+ constructor(operationId: string);
7
+ }
8
+ export declare class ImageGenerationRetentionFailedError extends Error {
9
+ readonly operationId: string;
10
+ constructor(operationId: string, cause?: unknown);
11
+ }
12
+ export type ImageGenerationOperationPorts = {
13
+ prepare: typeof prepareImageGenerationOperation;
14
+ begin: typeof beginImageGenerationOperation;
15
+ retain: typeof retainGeneratedImage;
16
+ complete: typeof completeImageGenerationOperation;
17
+ markOutcomeUnknown: typeof markImageGenerationOperationOutcomeUnknown;
18
+ markRetentionFailed: typeof markImageGenerationOperationRetentionFailed;
19
+ recover: typeof recoverCompletedImage;
20
+ };
21
+ /**
22
+ * Durable admission fence shared by every client-executed image provider.
23
+ * Provider execution is permitted at most once after the prepared ->
24
+ * provider_started transition. A crash at that boundary may conservatively
25
+ * leave the outcome unknown; a retry may recover a ready artifact, but never
26
+ * blindly replays the paid operation.
27
+ */
28
+ export type ExecuteImageGenerationOperationInput = {
29
+ db: Database;
30
+ objectStorage: ObjectStorage | null;
31
+ accountId: string;
32
+ workspaceId: string;
33
+ sessionId: string;
34
+ turnId: string;
35
+ attemptId: string;
36
+ toolCallId: string;
37
+ providerId: string;
38
+ providerBindingHash: string;
39
+ modelId: string;
40
+ prompt: string;
41
+ referenceDigests?: readonly Readonly<{
42
+ mediaType: string;
43
+ sha256: string;
44
+ }>[];
45
+ generate: () => Promise<GeneratedImageOutput>;
46
+ };
47
+ export declare function executeImageGenerationOperation(input: ExecuteImageGenerationOperationInput, ports?: ImageGenerationOperationPorts): Promise<GeneratedImageReceipt>;
48
+ export declare function imageProviderBindingHash(providerId: string, credentialIdentity: string): string;
49
+ /** Stable across worker/Temporal attempt retries; the attempt id is provenance, not identity. */
50
+ export declare function imageGenerationOperationIdentity(input: {
51
+ workspaceId: string;
52
+ sessionId: string;
53
+ turnId: string;
54
+ toolCallId: string;
55
+ providerId: string;
56
+ providerBindingHash: string;
57
+ modelId: string;
58
+ prompt: string;
59
+ referenceDigests?: readonly Readonly<{
60
+ mediaType: string;
61
+ sha256: string;
62
+ }>[];
63
+ }): {
64
+ operationId: string;
65
+ operationKey: string;
66
+ requestDigest: string;
67
+ artifactId: string;
68
+ };
69
+ declare function recoverCompletedImage(input: Pick<Parameters<typeof executeImageGenerationOperation>[0], "db" | "objectStorage" | "accountId" | "workspaceId" | "sessionId" | "turnId" | "toolCallId" | "providerId" | "providerBindingHash">, identity: {
70
+ artifactId: string;
71
+ operationId: string;
72
+ operationKey: string;
73
+ }): Promise<GeneratedImageReceipt | null>;
74
+ export {};
@@ -0,0 +1,25 @@
1
+ import { type ImageGenerationReference } from "@opengeni/contracts";
2
+ import { type Database } from "@opengeni/db";
3
+ import type { ObjectStorage } from "@opengeni/storage";
4
+ import { type GeneratedImageMediaType } from "./generated-images.js";
5
+ export declare const IMAGE_GENERATION_REFERENCE_MAX_BYTES: number;
6
+ export declare const IMAGE_GENERATION_REFERENCES_MAX_TOTAL_BYTES: number;
7
+ export type ResolvedImageGenerationReference = Readonly<{
8
+ mediaType: GeneratedImageMediaType;
9
+ bytes: Uint8Array;
10
+ sizeBytes: number;
11
+ sha256: string;
12
+ }>;
13
+ export type SandboxImageReferenceReader = (path: string, maxBytes: number) => Promise<Uint8Array>;
14
+ /**
15
+ * Resolve ordered model-facing references without accepting arbitrary URLs.
16
+ * Stored files remain workspace-RLS scoped; sandbox reads stay rooted beneath
17
+ * /workspace. Provider adapters receive only validated immutable bytes.
18
+ */
19
+ export declare function resolveImageGenerationReferences(input: {
20
+ db: Database;
21
+ objectStorage: ObjectStorage;
22
+ workspaceId: string;
23
+ references: readonly ImageGenerationReference[];
24
+ readSandboxFile?: SandboxImageReferenceReader;
25
+ }): Promise<ResolvedImageGenerationReference[]>;
@@ -0,0 +1,23 @@
1
+ export type KnowledgeSourceSyncDriverInventory<Entry, StopReason extends string> = {
2
+ status: "complete" | "paused";
3
+ stopReason: StopReason | null;
4
+ entries: Entry[];
5
+ checkpoint: Record<string, unknown> | null;
6
+ providerCursor: Record<string, unknown> | null;
7
+ authoritativeFullScan: boolean;
8
+ cursorInvalidated: boolean;
9
+ providerRequests: number;
10
+ elapsedMs: number;
11
+ hardLimitReached: boolean;
12
+ };
13
+ /** Provider port for deterministic knowledge ingestion. Implementations own
14
+ * provider JSON and byte transfer; the shared activity owns authority,
15
+ * persistence, indexing obligations, telemetry, and checkpoint settlement. */
16
+ export type KnowledgeSourceSyncDriver<Entry, StopReason extends string> = {
17
+ providerKey: string;
18
+ providerDomain: string;
19
+ providerCoordinationKey: string;
20
+ inventory: (executionCheckpoint: Record<string, unknown> | null, providerCursor: Record<string, unknown> | null) => Promise<KnowledgeSourceSyncDriverInventory<Entry, StopReason>>;
21
+ fetchContent: (entry: Entry, maxBytes: number) => Promise<Uint8Array>;
22
+ citationLocator: (entry: Entry) => Record<string, unknown>;
23
+ };
@@ -0,0 +1,75 @@
1
+ import { GoogleDriveConnectionMetadata, type GoogleDriveSelectedSource } from "@opengeni/contracts/google-drive";
2
+ import { type GoogleDriveInventoryEntry, type GoogleDriveInventoryPage, type GoogleDriveInventoryProviderItem, type GoogleDriveInventoryStopReason } from "@opengeni/documents/google-drive";
3
+ import { deauthorizeKnowledgeSourceRetrieval, settleKnowledgeSourceSyncLease, type Database, type KnowledgeSourceSyncObjectObservationResult, type KnowledgeSourceSyncObservationFloor } from "@opengeni/db";
4
+ import type { ControlActivityServices, RunKnowledgeSourceSyncBatchInput, RunKnowledgeSourceSyncBatchResult } from "./types.js";
5
+ import type { KnowledgeSourceSyncDriver } from "./knowledge-source-sync-driver.js";
6
+ import { type GoogleDriveChangesPage } from "./google-drive-changes.js";
7
+ export declare function knowledgeSyncObservationPolicy(kind: "google_drive" | "atlassian"): {
8
+ revisionOrdering: "canonical_decimal";
9
+ filterWithDriveDurability: boolean;
10
+ } | {
11
+ revisionOrdering: "first_observation";
12
+ filterWithDriveDurability: boolean;
13
+ };
14
+ export declare function createKnowledgeSourceSyncActivities(services: () => Promise<ControlActivityServices>, resolveDocumentServices?: () => Promise<import("@opengeni/documents").DocumentServices>): {
15
+ runKnowledgeSourceSyncBatch: (input: RunKnowledgeSourceSyncBatchInput) => Promise<RunKnowledgeSourceSyncBatchResult>;
16
+ };
17
+ /**
18
+ * Permission loss must fail closed, while the exact source lease must never be
19
+ * stranded by a deauthorization error. If deauthorization fails, release the
20
+ * lease without settling the wake/run and surface the error so Temporal retries
21
+ * this DB-only safety obligation. Terminal settlement is allowed only after
22
+ * deauthorization succeeds.
23
+ */
24
+ export declare function deauthorizeAndSettleKnowledgeSourceSyncFailure(db: Database, input: {
25
+ deauthorization: Parameters<typeof deauthorizeKnowledgeSourceRetrieval>[1];
26
+ settlement: Parameters<typeof settleKnowledgeSourceSyncLease>[1];
27
+ }): Promise<Awaited<ReturnType<typeof settleKnowledgeSourceSyncLease>>>;
28
+ export type GoogleDriveSyncProviderPort = {
29
+ now?: () => number;
30
+ getStartPageToken: (driveId: string | null) => Promise<string>;
31
+ listChanges: (pageToken: string, driveId: string | null, pageSize: number) => Promise<GoogleDriveChangesPage>;
32
+ getFile: (fileId: string) => Promise<GoogleDriveInventoryProviderItem | null>;
33
+ listChildren: (input: {
34
+ folderId: string;
35
+ driveId: string | null;
36
+ pageToken: string | null;
37
+ pageSize: number;
38
+ }) => Promise<GoogleDriveInventoryPage>;
39
+ };
40
+ export declare function googleDriveSyncDriver(input: {
41
+ actionProviderCoordinationKey: string;
42
+ metadata: ReturnType<typeof GoogleDriveConnectionMetadata.parse>;
43
+ selectedSource: GoogleDriveSelectedSource;
44
+ connectionId: string;
45
+ accountId: string;
46
+ workspaceId: string;
47
+ initiatingSubjectId: string;
48
+ authorization: string | undefined;
49
+ fullReconciliationIntervalMs: number;
50
+ observedExternalObjectIds: (ids: string[]) => Promise<Set<string>>;
51
+ provider?: GoogleDriveSyncProviderPort;
52
+ limits: {
53
+ maxItems: number;
54
+ maxBytes: number;
55
+ maxFileBytes: number;
56
+ maxProviderRequests: number;
57
+ maxElapsedSeconds: number;
58
+ };
59
+ }): KnowledgeSourceSyncDriver<GoogleDriveInventoryEntry, GoogleDriveInventoryStopReason>;
60
+ export declare function shouldProcessGoogleDriveDurableObservation(input: {
61
+ entry: Pick<GoogleDriveInventoryEntry, "externalObjectId">;
62
+ observation: KnowledgeSourceSyncObjectObservationResult;
63
+ sourceLifecycleGeneration: number;
64
+ aclGeneration: number;
65
+ }): boolean;
66
+ export declare function mergeGoogleDriveDurableObservationFloors(checkpoint: Record<string, unknown> | null, observations: KnowledgeSourceSyncObservationFloor[], maxItems: number): Record<string, unknown> | null;
67
+ export declare function googleDriveSyncProviderAccessAllowed(input: {
68
+ connectionVersion: number;
69
+ resolvedConnectionVersion: number | undefined;
70
+ connectionStatus: string;
71
+ lifecycleState: string | undefined;
72
+ grantedScopes: string[];
73
+ }): boolean;
74
+ export declare function confluenceCursor(value: unknown): string | null;
75
+ export declare function adfToMarkdown(value: unknown): string;
@@ -1,41 +1,38 @@
1
- import type { Settings } from "@opengeni/config";
2
- import { CapabilityPack } from "@opengeni/contracts";
1
+ import { CapabilityPack, type PackInstallation } from "@opengeni/contracts";
3
2
  import { type Database } from "@opengeni/db";
4
- import { type EffectiveSkillSelection, type PackSkill } from "@opengeni/runtime";
3
+ import { type InstalledSkillActivation, type PackSkillActivation } from "@opengeni/runtime";
4
+ export { resolveRigProviderImageSelection, rigProviderImageSourceImage, settingsWithPackSandboxImage, settingsWithRigImage, settingsWithRigProviderImage, } from "./sandbox-images.js";
5
5
  /**
6
- * The pack-scoped runtime for a workspace: the sandbox image its sessions run
7
- * in (when an enabled pack declares one) and the pack skills that join the
8
- * sandbox skill index.
6
+ * Legacy pack-scoped runtime compatibility. V2 Pack installations own ordinary
7
+ * Skill components and select an explicit Rig; they contribute nothing here.
9
8
  */
10
9
  export type WorkspacePackRuntime = {
11
10
  sandboxImage: string | null;
12
11
  sandboxProviderImages: CapabilityPack["sandboxProviderImages"] | null;
13
- skills: PackSkill[];
12
+ skillActivations: PackSkillActivation[];
14
13
  };
15
- export type WorkspaceSkillLibraryRuntime = {
16
- skillLibrarySkills: PackSkill[];
17
- skillLibrarySelections: EffectiveSkillSelection[];
14
+ export type WorkspaceInstalledSkillRuntime = {
15
+ activations: InstalledSkillActivation[];
18
16
  };
19
17
  /**
20
- * Resolves the pack-scoped runtime from the workspace's active pack
21
- * installations. Only registered (manifest-backed) packs can contribute a
22
- * sandbox image or skills; built-in packs never declare either (enforced by a
23
- * test on the built-in catalog), so their installations are skipped here
24
- * without consulting the API's built-in pack list.
18
+ * Resolves only pre-V2 active Pack installations. A frozen manifest/digest is
19
+ * the protocol marker for V2: inline Skills were migrated into the ordinary
20
+ * Skill ledger and sandboxImage was resolved to selectedRigId during install,
21
+ * so reading either field directly here would duplicate ownership and silently
22
+ * override session compute.
25
23
  */
26
24
  export declare function resolveWorkspacePackRuntime(db: Database, workspaceId: string): Promise<WorkspacePackRuntime>;
25
+ export declare function packInstallationUsesLegacyRuntime(installation: Pick<PackInstallation, "manifestSnapshot" | "manifestDigest">): boolean;
27
26
  /**
28
- * Resolves active immutable curated skills separately from pack skills. The
29
- * capability installation is the workspace selection boundary; it carries
30
- * only secret-free exact identity metadata, and the runtime loader verifies
31
- * the pinned artifact hash before any content is materialized.
27
+ * Resolves every active immutable Skill through the normalized Plugin/Skill-
28
+ * Facet ledger. The data layer has already filtered ineffective owner edges;
29
+ * this boundary independently verifies exact files before runtime activation.
32
30
  */
33
- export declare function resolveWorkspaceSkillLibraryRuntime(db: Database, workspaceId: string): Promise<WorkspaceSkillLibraryRuntime>;
31
+ export declare function resolveWorkspaceInstalledSkillRuntime(db: Database, workspaceId: string): Promise<WorkspaceInstalledSkillRuntime>;
34
32
  /**
35
- * Pure composition rule for enabled pack manifests. v1 keeps this small by
36
- * design: at most one enabled pack may declare a sandbox image (no image
37
- * layering or composition), and skill names must be unique across enabled
38
- * packs. Violations fail the turn with a plain error instead of guessing.
33
+ * Pure pre-V2 compatibility rule for enabled Pack manifests. At most one
34
+ * legacy Pack may declare a sandbox image, and legacy Skill names must be
35
+ * unique. V2 rows never reach this function through runtime resolution.
39
36
  */
40
37
  export declare function workspacePackRuntimeFromPacks(packs: CapabilityPack[]): WorkspacePackRuntime;
41
38
  /**
@@ -55,18 +52,6 @@ export declare function resolveWorkspaceAgentInstructions(db: Database, workspac
55
52
  * the settings pass through untouched, so deployments without packs keep the
56
53
  * global OPENGENI_DOCKER_IMAGE / OPENGENI_MODAL_IMAGE_REF behavior exactly.
57
54
  */
58
- export declare function settingsWithPackSandboxImage(settings: Settings, sandboxImage: string | null, sandboxProviderImages?: CapabilityPack["sandboxProviderImages"] | null): Settings;
59
- /**
60
- * Applies the session's frozen rig-version image to run settings. Rig image is
61
- * the TOP of the image precedence chain (rig > pack > deployment default): when
62
- * the rig version pins an image it OVERRIDES both the deployment
63
- * dockerImage/modalImageRef AND any pack-declared sandboxImage. When the rig
64
- * pins no image (`null`), the settings pass through untouched so the pack /
65
- * deployment chain below still resolves exactly as today. Applied AFTER
66
- * settingsWithPackSandboxImage so it wins the collision; identical mechanics to
67
- * the pack equivalent (write both image fields so docker and modal agree).
68
- */
69
- export declare function settingsWithRigImage(settings: Settings, rigImage: string | null): Settings;
70
55
  /**
71
56
  * Layers the rig version's default variable sets BELOW the session's own set:
72
57
  * the session's values WIN on any key collision (explicit precedence). Both maps
@@ -2,7 +2,7 @@ import type { Settings } from "@opengeni/config";
2
2
  import type { Session, SessionGoal } from "@opengeni/contracts";
3
3
  import { claimPendingSessionSystemUpdateOutbox, claimPendingSessionWorkflowWakes, type Database } from "@opengeni/db";
4
4
  import type { EventBus } from "@opengeni/events";
5
- import type { ActivityServices, WakeSessionWorkflowSignal } from "./types";
5
+ import type { ActivityServices, WakeSessionWorkflowSignal } from "./types.js";
6
6
  export type NotifyServices = {
7
7
  db: Database;
8
8
  bus: EventBus;
@@ -1,6 +1,6 @@
1
1
  import type { FileAsset } from "@opengeni/contracts";
2
2
  import type { ObjectHead, ObjectStorage } from "@opengeni/storage";
3
- import type { ActivityServices } from "./types";
3
+ import type { ControlActivityServices } from "./types.js";
4
4
  export declare const RETAINED_SCREENSHOT_PENDING_GRACE_MS: number;
5
5
  export declare const RETAINED_SCREENSHOT_CLAIM_TIMEOUT_MS: number;
6
6
  export declare const RETAINED_SCREENSHOT_MAINTENANCE_BATCH_SIZE = 100;
@@ -27,6 +27,6 @@ export type RetainedScreenshotMaintenanceActivityOptions = {
27
27
  * completion happens only after exact metadata verification or an idempotent
28
28
  * object delete.
29
29
  */
30
- export declare function createRetainedScreenshotMaintenanceActivities(services: () => Promise<ActivityServices>, options?: RetainedScreenshotMaintenanceActivityOptions): {
30
+ export declare function createRetainedScreenshotMaintenanceActivities(services: () => Promise<ControlActivityServices>, options?: RetainedScreenshotMaintenanceActivityOptions): {
31
31
  maintainRetainedScreenshots: () => Promise<MaintainRetainedScreenshotsResult>;
32
32
  };
@@ -15,6 +15,16 @@ export type ValidatedScreenshot = {
15
15
  width: number;
16
16
  height: number;
17
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
+ };
18
28
  export declare class ScreenshotValidationError extends Error {
19
29
  readonly reason: "invalid_content" | "oversized" | "unsupported";
20
30
  constructor(reason: "invalid_content" | "oversized" | "unsupported", message: string);
@@ -24,8 +34,16 @@ export declare class RetainedScreenshotUnavailableError extends Error {
24
34
  readonly reason: RetainedOutputUnavailableReason;
25
35
  constructor(artifactId: string, reason: RetainedOutputUnavailableReason);
26
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;
27
42
  /** Read the SDK's trusted typed image before event/history serialization. */
28
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;
29
47
  /** Validate the complete canonical PNG and derive exact integrity metadata. */
30
48
  export declare function validateComputerScreenshot(input: {
31
49
  bytes: Uint8Array;
@@ -35,6 +53,15 @@ export declare function validateComputerScreenshot(input: {
35
53
  maxDimension?: number;
36
54
  maxPixels?: number;
37
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;
38
65
  export declare function retainedScreenshotIdentity(input: {
39
66
  sessionId: string;
40
67
  turnId: string;
@@ -45,6 +72,15 @@ export declare function retainedScreenshotIdentity(input: {
45
72
  artifactId: string;
46
73
  settlementKey: string;
47
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;
48
84
  export declare function retainComputerScreenshot(input: {
49
85
  db: Database;
50
86
  objectStorage: ObjectStorage | null;