@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
@@ -34,5 +34,6 @@ export function connectionTokenResolverForTurn(input: {
34
34
  initiator: input.turn.initiator,
35
35
  initiatorContext: input.turn.initiatorContext,
36
36
  surface: "model",
37
+ allowOfficialGmailRestDestination: input.settings.gmailRestAdapterEnabled,
37
38
  });
38
39
  }
@@ -1,55 +1,51 @@
1
- import type { Settings } from "@opengeni/config";
2
- import { CapabilityPack } from "@opengeni/contracts";
1
+ import { CapabilityPack, type PackInstallation } from "@opengeni/contracts";
3
2
  import {
4
3
  getWorkspace,
5
4
  getWorkspacePack,
6
- listCapabilityInstallations,
5
+ listInstalledPortableSkills,
7
6
  listPackInstallations,
8
7
  type Database,
9
8
  } from "@opengeni/db";
10
9
  import {
11
- isSkillLibraryEntryId,
12
- loadSkillLibrarySkill,
13
- type EffectiveSkillSelection,
14
- type PackSkill,
10
+ buildPortableSkillArtifact,
11
+ type InstalledSkillActivation,
12
+ type PackSkillActivation,
13
+ type RuntimeSkillArtifact,
15
14
  } from "@opengeni/runtime";
15
+ export {
16
+ resolveRigProviderImageSelection,
17
+ rigProviderImageSourceImage,
18
+ settingsWithPackSandboxImage,
19
+ settingsWithRigImage,
20
+ settingsWithRigProviderImage,
21
+ } from "./sandbox-images";
16
22
 
17
23
  /**
18
- * The pack-scoped runtime for a workspace: the sandbox image its sessions run
19
- * in (when an enabled pack declares one) and the pack skills that join the
20
- * sandbox skill index.
24
+ * Legacy pack-scoped runtime compatibility. V2 Pack installations own ordinary
25
+ * Skill components and select an explicit Rig; they contribute nothing here.
21
26
  */
22
27
  export type WorkspacePackRuntime = {
23
28
  sandboxImage: string | null;
24
29
  sandboxProviderImages: CapabilityPack["sandboxProviderImages"] | null;
25
- skills: PackSkill[];
30
+ skillActivations: PackSkillActivation[];
26
31
  };
27
32
 
28
33
  const emptyPackRuntime: WorkspacePackRuntime = {
29
34
  sandboxImage: null,
30
35
  sandboxProviderImages: null,
31
- skills: [],
36
+ skillActivations: [],
32
37
  };
33
38
 
34
- export type WorkspaceSkillLibraryRuntime = {
35
- skillLibrarySkills: PackSkill[];
36
- skillLibrarySelections: EffectiveSkillSelection[];
37
- };
38
-
39
- type SkillLibraryInstallationMetadata = {
40
- libraryId: string;
41
- libraryVersion: string;
42
- contentSha256: string;
43
- sourceCommit: string;
44
- provenance: string;
39
+ export type WorkspaceInstalledSkillRuntime = {
40
+ activations: InstalledSkillActivation[];
45
41
  };
46
42
 
47
43
  /**
48
- * Resolves the pack-scoped runtime from the workspace's active pack
49
- * installations. Only registered (manifest-backed) packs can contribute a
50
- * sandbox image or skills; built-in packs never declare either (enforced by a
51
- * test on the built-in catalog), so their installations are skipped here
52
- * without consulting the API's built-in pack list.
44
+ * Resolves only pre-V2 active Pack installations. A frozen manifest/digest is
45
+ * the protocol marker for V2: inline Skills were migrated into the ordinary
46
+ * Skill ledger and sandboxImage was resolved to selectedRigId during install,
47
+ * so reading either field directly here would duplicate ownership and silently
48
+ * override session compute.
53
49
  */
54
50
  export async function resolveWorkspacePackRuntime(
55
51
  db: Database,
@@ -62,6 +58,9 @@ export async function resolveWorkspacePackRuntime(
62
58
  }
63
59
  const packs: CapabilityPack[] = [];
64
60
  for (const installation of active) {
61
+ if (!packInstallationUsesLegacyRuntime(installation)) {
62
+ continue;
63
+ }
65
64
  const registration = await getWorkspacePack(db, workspaceId, installation.packId);
66
65
  if (!registration) {
67
66
  continue;
@@ -74,100 +73,59 @@ export async function resolveWorkspacePackRuntime(
74
73
  return workspacePackRuntimeFromPacks(packs);
75
74
  }
76
75
 
76
+ export function packInstallationUsesLegacyRuntime(
77
+ installation: Pick<PackInstallation, "manifestSnapshot" | "manifestDigest">,
78
+ ): boolean {
79
+ return installation.manifestSnapshot === null && installation.manifestDigest === null;
80
+ }
81
+
77
82
  /**
78
- * Resolves active immutable curated skills separately from pack skills. The
79
- * capability installation is the workspace selection boundary; it carries
80
- * only secret-free exact identity metadata, and the runtime loader verifies
81
- * the pinned artifact hash before any content is materialized.
83
+ * Resolves every active immutable Skill through the normalized Plugin/Skill-
84
+ * Facet ledger. The data layer has already filtered ineffective owner edges;
85
+ * this boundary independently verifies exact files before runtime activation.
82
86
  */
83
- export async function resolveWorkspaceSkillLibraryRuntime(
87
+ export async function resolveWorkspaceInstalledSkillRuntime(
84
88
  db: Database,
85
89
  workspaceId: string,
86
- ): Promise<WorkspaceSkillLibraryRuntime> {
87
- const installations = await listCapabilityInstallations(db, workspaceId);
88
- const activeSkills = installations
89
- .filter(
90
- (installation) =>
91
- installation.status === "active" &&
92
- installation.kind === "skill" &&
93
- installation.capabilityId.startsWith("skill:") &&
94
- isSkillLibraryEntryId(installation.capabilityId.slice("skill:".length)),
95
- )
96
- .sort((a, b) => a.capabilityId.localeCompare(b.capabilityId));
97
- const skillLibrarySkills: PackSkill[] = [];
98
- const skillLibrarySelections: EffectiveSkillSelection[] = [];
99
- for (const installation of activeSkills) {
100
- const metadata = parseSkillLibraryInstallationMetadata(
101
- installation.metadata,
102
- installation.capabilityId,
103
- );
104
- if (installation.capabilityId !== `skill:${metadata.libraryId}`) {
105
- throw new Error(
106
- `Skill installation id does not match its library entry: ${installation.capabilityId} -> ${metadata.libraryId}`,
107
- );
108
- }
109
- const loaded = loadSkillLibrarySkill(metadata.libraryId, metadata.libraryVersion);
110
- if (installation.config.version !== metadata.libraryVersion) {
111
- throw new Error(
112
- `Skill installation version mismatch for ${metadata.libraryId}@${metadata.libraryVersion}: config has ${String(installation.config.version)}`,
113
- );
114
- }
115
- if (loaded.entry.contentSha256 !== metadata.contentSha256) {
116
- throw new Error(
117
- `Skill installation hash mismatch for ${metadata.libraryId}@${metadata.libraryVersion}: expected ${metadata.contentSha256}, catalog has ${loaded.entry.contentSha256}`,
118
- );
119
- }
90
+ ): Promise<WorkspaceInstalledSkillRuntime> {
91
+ const installedSkills = await listInstalledPortableSkills(db, workspaceId);
92
+ const activations: InstalledSkillActivation[] = [];
93
+ for (const installed of installedSkills) {
94
+ const artifact = buildPortableSkillArtifact(installed.files);
120
95
  if (
121
- loaded.entry.sourceCommit !== metadata.sourceCommit ||
122
- loaded.entry.provenance !== metadata.provenance
96
+ artifact.name !== installed.name ||
97
+ artifact.description !== installed.description ||
98
+ artifact.contentSha256 !== installed.contentSha256
123
99
  ) {
124
100
  throw new Error(
125
- `Skill installation provenance mismatch for ${metadata.libraryId}@${metadata.libraryVersion}; re-enable the skill from the current catalog`,
101
+ `Installed Skill artifact verification failed for ${installed.capabilityId}; reinstall it from the pinned source`,
126
102
  );
127
103
  }
128
- skillLibrarySkills.push({
129
- name: loaded.skill.name,
130
- description: loaded.skill.description,
131
- files: loaded.skill.files.map((file) => ({ path: file.path, content: file.content })),
104
+ activations.push({
105
+ source: "installation",
106
+ id: installed.capabilityId,
107
+ artifact: {
108
+ name: artifact.name,
109
+ description: artifact.description,
110
+ files: artifact.files.map((file) => ({ path: file.path, content: file.content })),
111
+ },
112
+ version: installed.version,
113
+ contentSha256: artifact.contentSha256,
114
+ reason:
115
+ installed.source === "library"
116
+ ? "installed from the curated Skill library"
117
+ : installed.source === "pack"
118
+ ? "installed as a Pack-owned Skill"
119
+ : `installed from ${installed.sourceUrl}`,
132
120
  });
133
- skillLibrarySelections.push({
134
- id: loaded.entry.id,
135
- name: loaded.entry.name,
136
- source: "library",
137
- version: loaded.entry.version,
138
- contentSha256: loaded.entry.contentSha256,
139
- reason: "enabled workspace capability installation",
140
- });
141
- }
142
- return { skillLibrarySkills, skillLibrarySelections };
143
- }
144
-
145
- function parseSkillLibraryInstallationMetadata(
146
- metadata: Record<string, unknown>,
147
- capabilityId: string,
148
- ): SkillLibraryInstallationMetadata {
149
- const libraryId = stringMetadata(metadata.libraryId);
150
- const libraryVersion = stringMetadata(metadata.libraryVersion);
151
- const contentSha256 = stringMetadata(metadata.contentSha256);
152
- const sourceCommit = stringMetadata(metadata.sourceCommit);
153
- const provenance = stringMetadata(metadata.provenance);
154
- if (!libraryId || !libraryVersion || !contentSha256 || !sourceCommit || !provenance) {
155
- throw new Error(
156
- `Skill installation ${capabilityId} is missing immutable library metadata; re-enable the skill from the current catalog`,
157
- );
158
121
  }
159
- return { libraryId, libraryVersion, contentSha256, sourceCommit, provenance };
160
- }
161
-
162
- function stringMetadata(value: unknown): string | null {
163
- return typeof value === "string" && value.trim().length > 0 ? value.trim() : null;
122
+ return { activations };
164
123
  }
165
124
 
166
125
  /**
167
- * Pure composition rule for enabled pack manifests. v1 keeps this small by
168
- * design: at most one enabled pack may declare a sandbox image (no image
169
- * layering or composition), and skill names must be unique across enabled
170
- * packs. Violations fail the turn with a plain error instead of guessing.
126
+ * Pure pre-V2 compatibility rule for enabled Pack manifests. At most one
127
+ * legacy Pack may declare a sandbox image, and legacy Skill names must be
128
+ * unique. V2 rows never reach this function through runtime resolution.
171
129
  */
172
130
  export function workspacePackRuntimeFromPacks(packs: CapabilityPack[]): WorkspacePackRuntime {
173
131
  const imagePacks = packs.filter(
@@ -182,7 +140,7 @@ export function workspacePackRuntimeFromPacks(packs: CapabilityPack[]): Workspac
182
140
  `Multiple enabled packs declare a sandbox image (${ids}). Only one enabled pack per workspace may declare sandboxImage; disable the others and retry.`,
183
141
  );
184
142
  }
185
- const skills: PackSkill[] = [];
143
+ const skillActivations: PackSkillActivation[] = [];
186
144
  // Keyed case-insensitively to match the per-pack uniqueness rule in the
187
145
  // CapabilityPack contract (and case-insensitive filesystems).
188
146
  const skillOwners = new Map<string, string>();
@@ -196,17 +154,23 @@ export function workspacePackRuntimeFromPacks(packs: CapabilityPack[]): Workspac
196
154
  );
197
155
  }
198
156
  skillOwners.set(key, pack.id);
199
- skills.push({
157
+ const artifact: RuntimeSkillArtifact = {
200
158
  name: skill.name,
201
159
  description: skill.description ?? null,
202
160
  files: skill.files.map((file) => ({ path: file.path, content: file.content })),
161
+ };
162
+ skillActivations.push({
163
+ source: "pack",
164
+ id: `pack:${pack.id}:${skill.name}`,
165
+ artifact,
166
+ reason: `active legacy Pack ${pack.id}`,
203
167
  });
204
168
  }
205
169
  }
206
170
  return {
207
171
  sandboxImage: imagePacks[0]?.sandboxImage?.trim() ?? null,
208
172
  sandboxProviderImages: imagePacks[0]?.sandboxProviderImages ?? null,
209
- skills,
173
+ skillActivations,
210
174
  };
211
175
  }
212
176
 
@@ -234,47 +198,6 @@ export async function resolveWorkspaceAgentInstructions(
234
198
  * the settings pass through untouched, so deployments without packs keep the
235
199
  * global OPENGENI_DOCKER_IMAGE / OPENGENI_MODAL_IMAGE_REF behavior exactly.
236
200
  */
237
- export function settingsWithPackSandboxImage(
238
- settings: Settings,
239
- sandboxImage: string | null,
240
- sandboxProviderImages: CapabilityPack["sandboxProviderImages"] | null = null,
241
- ): Settings {
242
- if (!sandboxImage) {
243
- return settings;
244
- }
245
- return {
246
- ...settings,
247
- dockerImage: sandboxImage,
248
- modalImageRef: sandboxImage,
249
- modalImageId: sandboxProviderImages?.modal?.imageId,
250
- };
251
- }
252
-
253
- /**
254
- * Applies the session's frozen rig-version image to run settings. Rig image is
255
- * the TOP of the image precedence chain (rig > pack > deployment default): when
256
- * the rig version pins an image it OVERRIDES both the deployment
257
- * dockerImage/modalImageRef AND any pack-declared sandboxImage. When the rig
258
- * pins no image (`null`), the settings pass through untouched so the pack /
259
- * deployment chain below still resolves exactly as today. Applied AFTER
260
- * settingsWithPackSandboxImage so it wins the collision; identical mechanics to
261
- * the pack equivalent (write both image fields so docker and modal agree).
262
- */
263
- export function settingsWithRigImage(settings: Settings, rigImage: string | null): Settings {
264
- if (!rigImage) {
265
- return settings;
266
- }
267
- return {
268
- ...settings,
269
- dockerImage: rigImage,
270
- modalImageRef: rigImage,
271
- // A rig image has no provider-native identity in the current rig contract.
272
- // Clear a lower-precedence pack/deployment ID so the rig cannot silently
273
- // run the wrong Modal image.
274
- modalImageId: undefined,
275
- };
276
- }
277
-
278
201
  /**
279
202
  * Layers the rig version's default variable sets BELOW the session's own set:
280
203
  * the session's values WIN on any key collision (explicit precedence). Both maps
@@ -4,6 +4,7 @@ import {
4
4
  getSession,
5
5
  getSessionGoal,
6
6
  getSessionParentPersonalConnectionDelegations,
7
+ getSessionParentXaiProviderAccountAuthority,
7
8
  addSessionSystemUpdateWithSourceMutation,
8
9
  claimPendingSessionSystemUpdateOutbox,
9
10
  claimPendingSessionWorkflowWakes,
@@ -63,6 +64,11 @@ export async function notifyParentOfChildIdle(
63
64
  workspaceId,
64
65
  childSessionId,
65
66
  );
67
+ const xaiAuthority = await getSessionParentXaiProviderAccountAuthority(
68
+ svc.db,
69
+ workspaceId,
70
+ childSessionId,
71
+ );
66
72
  const outbox = await getOrCreateSessionSystemUpdateOutbox(svc.db, {
67
73
  accountId: child.accountId,
68
74
  workspaceId,
@@ -74,8 +80,13 @@ export async function notifyParentOfChildIdle(
74
80
  dedupeKey: clientEventId,
75
81
  summary: childCompletionSummary(child, goal, "idle"),
76
82
  payload,
77
- lineage: { childSessionId: child.id, parentSessionId: child.parentSessionId },
83
+ lineage: {
84
+ childSessionId: child.id,
85
+ parentSessionId: child.parentSessionId,
86
+ ...(xaiAuthority.subjectId ? { xaiAuthoritySubjectId: xaiAuthority.subjectId } : {}),
87
+ },
78
88
  personalConnectionDelegations,
89
+ xaiProviderAccountAuthoritySnapshot: xaiAuthority.snapshot,
79
90
  });
80
91
  if (outbox.status === "delivered") {
81
92
  return;
@@ -146,6 +157,7 @@ async function deliverParentSystemUpdateOutbox(
146
157
  payload: outbox.payload,
147
158
  lineage: outbox.lineage,
148
159
  personalConnectionDelegations: outbox.personalConnectionDelegations,
160
+ xaiProviderAccountAuthoritySnapshot: outbox.xaiProviderAccountAuthoritySnapshot,
149
161
  },
150
162
  async (tx) => {
151
163
  await markSessionSystemUpdateOutboxDeliveredInTransaction(tx, outbox);
@@ -6,7 +6,7 @@ import {
6
6
  type RetainedScreenshotMaintenanceClaim,
7
7
  } from "@opengeni/db";
8
8
  import type { ObjectHead, ObjectStorage } from "@opengeni/storage";
9
- import type { ActivityServices } from "./types";
9
+ import type { ControlActivityServices } from "./types";
10
10
 
11
11
  export const RETAINED_SCREENSHOT_PENDING_GRACE_MS = 15 * 60 * 1_000;
12
12
  export const RETAINED_SCREENSHOT_CLAIM_TIMEOUT_MS = 10 * 60 * 1_000;
@@ -38,7 +38,7 @@ export type RetainedScreenshotMaintenanceActivityOptions = {
38
38
  * object delete.
39
39
  */
40
40
  export function createRetainedScreenshotMaintenanceActivities(
41
- services: () => Promise<ActivityServices>,
41
+ services: () => Promise<ControlActivityServices>,
42
42
  options: RetainedScreenshotMaintenanceActivityOptions = {},
43
43
  ) {
44
44
  const pendingGraceMs = options.pendingGraceMs ?? RETAINED_SCREENSHOT_PENDING_GRACE_MS;