@opengeni/worker-bundle 0.20.1 → 0.22.0-canary.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/activities/agent-turn/admission.d.ts +52 -0
- package/dist/activities/agent-turn/agent-build.d.ts +89 -0
- package/dist/activities/agent-turn/claim.d.ts +67 -0
- package/dist/activities/agent-turn/codex-capacity.d.ts +40 -0
- package/dist/activities/agent-turn/codex.d.ts +32 -0
- package/dist/activities/agent-turn/compaction-prep.d.ts +88 -0
- package/dist/activities/agent-turn/credential-leases.d.ts +56 -0
- package/dist/activities/agent-turn/errors.d.ts +253 -0
- package/dist/activities/agent-turn/failure-settlement.d.ts +33 -0
- package/dist/activities/agent-turn/file-resources.d.ts +37 -0
- package/dist/activities/agent-turn/finalization.d.ts +42 -0
- package/dist/activities/agent-turn/github-repository-bindings.d.ts +105 -0
- package/dist/activities/agent-turn/governance-model.d.ts +66 -0
- package/dist/activities/agent-turn/history-sink.d.ts +52 -0
- package/dist/activities/agent-turn/history.d.ts +63 -0
- package/dist/activities/agent-turn/media-artifacts.d.ts +145 -0
- package/dist/activities/agent-turn/model-usage.d.ts +218 -0
- package/dist/activities/agent-turn/quiescence.d.ts +135 -0
- package/dist/activities/agent-turn/run-credentials.d.ts +84 -0
- package/dist/activities/agent-turn/run.d.ts +3 -0
- package/dist/activities/agent-turn/sandbox-establish.d.ts +93 -0
- package/dist/activities/agent-turn/sandbox-provision.d.ts +89 -0
- package/dist/activities/agent-turn/sandbox-route.d.ts +151 -0
- package/dist/activities/agent-turn/sandbox-runtime.d.ts +44 -0
- package/dist/activities/agent-turn/stream-attempt.d.ts +107 -0
- package/dist/activities/agent-turn/tool-environment.d.ts +142 -0
- package/dist/activities/agent-turn/tool-policy.d.ts +127 -0
- package/dist/activities/agent-turn/tool-result-spill.d.ts +59 -0
- package/dist/activities/agent-turn/turn-context.d.ts +144 -0
- package/dist/activities/agent-turn/xai-capacity.d.ts +2 -0
- package/dist/activities/agent-turn.d.ts +12 -954
- package/dist/activities/automations.d.ts +16 -0
- package/dist/activities/common.d.ts +1 -1
- package/dist/activities/connector-attachments.d.ts +13 -0
- package/dist/activities/documents.d.ts +1 -0
- package/dist/activities/environment.d.ts +26 -15
- package/dist/activities/generated-images.d.ts +1 -1
- package/dist/activities/git-credential-renewal.d.ts +3 -1
- package/dist/activities/goals.d.ts +4 -1
- package/dist/activities/google-drive-provider.d.ts +29 -0
- package/dist/activities/google-drive-publication.d.ts +66 -0
- package/dist/activities/image-generation-references.d.ts +2 -0
- package/dist/activities/incident-telemetry-authority.d.ts +52 -0
- package/dist/activities/incident-telemetry-preflight.d.ts +71 -0
- package/dist/activities/knowledge-source-sync-driver.d.ts +21 -0
- package/dist/activities/knowledge-source-sync.d.ts +33 -1
- package/dist/activities/mcp-credentials.d.ts +9 -3
- package/dist/activities/open-suffix-resume.d.ts +77 -0
- package/dist/activities/packs.d.ts +3 -11
- package/dist/activities/parent-wake.d.ts +19 -0
- package/dist/activities/retained-screenshot-reaper.d.ts +1 -1
- package/dist/activities/retained-screenshots.d.ts +1 -1
- package/dist/activities/rig-verification.d.ts +1 -1
- package/dist/activities/run-input.d.ts +16 -7
- package/dist/activities/sandbox-images.d.ts +1 -14
- package/dist/activities/sandbox-lease.d.ts +21 -3
- package/dist/activities/scheduled-tasks.d.ts +47 -0
- package/dist/activities/types.d.ts +23 -2
- package/dist/activities/video-media-validation.d.ts +1 -1
- package/dist/activities/video-output-retention.d.ts +1 -2
- package/dist/activities/xai-auth.d.ts +3 -0
- package/dist/{activities-control-SMKF2OBE.js → activities-control-DKG22ONJ.js} +2946 -549
- package/dist/activities-control-DKG22ONJ.js.map +1 -0
- package/dist/activities-control.d.ts +6 -2
- package/dist/activities-turn-4IMC3MAA.js +21326 -0
- package/dist/activities-turn-4IMC3MAA.js.map +1 -0
- package/dist/activities.d.ts +7 -3
- package/dist/artifact-materializer-entry.js +41 -22
- package/dist/artifact-materializer-entry.js.map +1 -1
- package/dist/{chunk-N5TJIFCE.js → chunk-CE7TPKBS.js} +468 -1
- package/dist/chunk-CE7TPKBS.js.map +1 -0
- package/dist/chunk-CNYGVRKF.js +4698 -0
- package/dist/chunk-CNYGVRKF.js.map +1 -0
- package/dist/connection-provider-use.d.ts +18 -0
- package/dist/editable-artifact-materializer.d.ts +4 -3
- package/dist/github-rest-mcp.d.ts +26 -0
- package/dist/index.d.ts +10 -2
- package/dist/index.js +58 -14
- package/dist/index.js.map +1 -1
- package/dist/knowledge-source-sync-activity-policy.d.ts +2 -0
- package/dist/model-context-contributions.d.ts +8 -4
- package/dist/observability-metrics.d.ts +63 -4
- package/dist/opensandbox-kubernetes-inventory.d.ts +21 -0
- package/dist/personal-github-git-credentials.d.ts +9 -0
- package/dist/pr-review-credentials.d.ts +6 -0
- package/dist/sandbox-archive-storage.d.ts +45 -0
- package/dist/sandbox-resume.d.ts +65 -6
- package/dist/sandbox-routing.d.ts +38 -2
- package/dist/scheduled-alert-occurrence.d.ts +33 -0
- package/dist/workflow-bundle.js +87 -28
- package/dist/workflows/activities.d.ts +1 -0
- package/dist/workflows/automations.d.ts +6 -0
- package/dist/workflows/document-index.d.ts +1 -0
- package/dist/workflows.d.ts +1 -0
- package/package.json +17 -17
- package/src/activities/agent-turn/admission.ts +292 -0
- package/src/activities/agent-turn/agent-build.ts +802 -0
- package/src/activities/agent-turn/claim.ts +590 -0
- package/src/activities/agent-turn/codex-capacity.ts +720 -0
- package/src/activities/agent-turn/codex.ts +94 -0
- package/src/activities/agent-turn/compaction-prep.ts +722 -0
- package/src/activities/agent-turn/credential-leases.ts +240 -0
- package/src/activities/agent-turn/errors.ts +1068 -0
- package/src/activities/agent-turn/failure-settlement.ts +1436 -0
- package/src/activities/agent-turn/file-resources.ts +227 -0
- package/src/activities/agent-turn/finalization.ts +754 -0
- package/src/activities/agent-turn/github-repository-bindings.ts +300 -0
- package/src/activities/agent-turn/governance-model.ts +465 -0
- package/src/activities/agent-turn/history-sink.ts +139 -0
- package/src/activities/agent-turn/history.ts +200 -0
- package/src/activities/agent-turn/media-artifacts.ts +359 -0
- package/src/activities/agent-turn/model-usage.ts +823 -0
- package/src/activities/agent-turn/quiescence.ts +353 -0
- package/src/activities/agent-turn/run-credentials.ts +761 -0
- package/src/activities/agent-turn/run.ts +1530 -0
- package/src/activities/agent-turn/sandbox-establish.ts +1207 -0
- package/src/activities/agent-turn/sandbox-provision.ts +569 -0
- package/src/activities/agent-turn/sandbox-route.ts +358 -0
- package/src/activities/agent-turn/sandbox-runtime.ts +731 -0
- package/src/activities/agent-turn/stream-attempt.ts +1670 -0
- package/src/activities/agent-turn/tool-environment.ts +729 -0
- package/src/activities/agent-turn/tool-policy.ts +216 -0
- package/src/activities/agent-turn/tool-result-spill.ts +265 -0
- package/src/activities/agent-turn/turn-context.ts +281 -0
- package/src/activities/agent-turn/xai-capacity.ts +229 -0
- package/src/activities/agent-turn.ts +12 -12575
- package/src/activities/api-integrations.ts +3 -0
- package/src/activities/automations.ts +214 -0
- package/src/activities/codemode-dispatcher.ts +12 -1
- package/src/activities/common.ts +1 -5
- package/src/activities/connector-attachments.ts +168 -0
- package/src/activities/context-compaction.ts +18 -0
- package/src/activities/documents.ts +6 -4
- package/src/activities/environment.ts +151 -55
- package/src/activities/generated-images.ts +26 -11
- package/src/activities/git-credential-renewal.ts +13 -3
- package/src/activities/goals.ts +85 -19
- package/src/activities/google-drive-provider.ts +178 -0
- package/src/activities/google-drive-publication.ts +938 -0
- package/src/activities/image-generation-references.ts +11 -2
- package/src/activities/incident-telemetry-authority.ts +327 -0
- package/src/activities/incident-telemetry-preflight.ts +317 -0
- package/src/activities/knowledge-source-sync-driver.ts +23 -0
- package/src/activities/knowledge-source-sync.ts +556 -40
- package/src/activities/mcp-credentials.ts +191 -17
- package/src/activities/open-suffix-resume.ts +422 -0
- package/src/activities/packs.ts +12 -60
- package/src/activities/parent-wake.ts +64 -14
- package/src/activities/retained-screenshot-reaper.ts +6 -3
- package/src/activities/retained-screenshots.ts +15 -47
- package/src/activities/rig-verification.ts +1 -1
- package/src/activities/run-input.ts +128 -136
- package/src/activities/sandbox-images.ts +7 -166
- package/src/activities/sandbox-lease.ts +406 -15
- package/src/activities/scheduled-tasks.ts +2103 -411
- package/src/activities/session-state.ts +10 -2
- package/src/activities/types.ts +32 -2
- package/src/activities/video-media-validation.ts +3 -3
- package/src/activities/video-output-retention.ts +2 -57
- package/src/activities/xai-auth.ts +8 -0
- package/src/activities-control.ts +2 -0
- package/src/activities.ts +3 -0
- package/src/activity-services.ts +13 -4
- package/src/connection-provider-use.ts +36 -0
- package/src/editable-artifact-materializer-subprocess.ts +25 -14
- package/src/editable-artifact-materializer.ts +29 -18
- package/src/github-rest-mcp.ts +713 -0
- package/src/http.ts +16 -6
- package/src/index.ts +40 -5
- package/src/knowledge-source-sync-activity-policy.ts +2 -0
- package/src/model-context-contributions.ts +33 -10
- package/src/observability-metrics.ts +357 -0
- package/src/opensandbox-kubernetes-inventory.ts +292 -0
- package/src/personal-github-git-credentials.ts +331 -0
- package/src/pr-review-credentials.ts +163 -0
- package/src/sandbox-archive-storage.ts +159 -0
- package/src/sandbox-resume.ts +449 -63
- package/src/sandbox-routing.ts +314 -16
- package/src/scheduled-alert-occurrence.ts +176 -0
- package/src/workflows/activities.ts +18 -2
- package/src/workflows/automations.ts +11 -0
- package/src/workflows/session.ts +13 -3
- package/src/workflows.ts +1 -0
- package/dist/activities-control-SMKF2OBE.js.map +0 -1
- package/dist/activities-turn-IDS3WEHA.js +0 -16532
- package/dist/activities-turn-IDS3WEHA.js.map +0 -1
- package/dist/chunk-N5TJIFCE.js.map +0 -1
- package/dist/chunk-P6Z2SLAA.js +0 -3092
- package/dist/chunk-P6Z2SLAA.js.map +0 -1
package/src/activities/packs.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { CapabilityPack
|
|
1
|
+
import { CapabilityPack } from "@opengeni/contracts";
|
|
2
|
+
import { getWorkspace, listInstalledPortableSkills, type Database } from "@opengeni/db";
|
|
2
3
|
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
type Database,
|
|
8
|
-
} from "@opengeni/db";
|
|
4
|
+
legacySandboxRuntimeFromPacks,
|
|
5
|
+
packInstallationUsesLegacyRuntime,
|
|
6
|
+
resolveWorkspaceLegacyRuntimePacks,
|
|
7
|
+
} from "@opengeni/core";
|
|
9
8
|
import {
|
|
10
9
|
buildPortableSkillArtifact,
|
|
11
10
|
type InstalledSkillActivation,
|
|
@@ -19,6 +18,7 @@ export {
|
|
|
19
18
|
settingsWithRigImage,
|
|
20
19
|
settingsWithRigProviderImage,
|
|
21
20
|
} from "./sandbox-images";
|
|
21
|
+
export { packInstallationUsesLegacyRuntime };
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
24
|
* Legacy pack-scoped runtime compatibility. V2 Pack installations own ordinary
|
|
@@ -51,34 +51,11 @@ export async function resolveWorkspacePackRuntime(
|
|
|
51
51
|
db: Database,
|
|
52
52
|
workspaceId: string,
|
|
53
53
|
): Promise<WorkspacePackRuntime> {
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
if (active.length === 0) {
|
|
57
|
-
return emptyPackRuntime;
|
|
58
|
-
}
|
|
59
|
-
const packs: CapabilityPack[] = [];
|
|
60
|
-
for (const installation of active) {
|
|
61
|
-
if (!packInstallationUsesLegacyRuntime(installation)) {
|
|
62
|
-
continue;
|
|
63
|
-
}
|
|
64
|
-
const registration = await getWorkspacePack(db, workspaceId, installation.packId);
|
|
65
|
-
if (!registration) {
|
|
66
|
-
continue;
|
|
67
|
-
}
|
|
68
|
-
const parsed = CapabilityPack.safeParse(registration.pack);
|
|
69
|
-
if (parsed.success) {
|
|
70
|
-
packs.push(parsed.data);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
54
|
+
const packs = await resolveWorkspaceLegacyRuntimePacks(db, workspaceId);
|
|
55
|
+
if (packs.length === 0) return emptyPackRuntime;
|
|
73
56
|
return workspacePackRuntimeFromPacks(packs);
|
|
74
57
|
}
|
|
75
58
|
|
|
76
|
-
export function packInstallationUsesLegacyRuntime(
|
|
77
|
-
installation: Pick<PackInstallation, "manifestSnapshot" | "manifestDigest">,
|
|
78
|
-
): boolean {
|
|
79
|
-
return installation.manifestSnapshot === null && installation.manifestDigest === null;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
59
|
/**
|
|
83
60
|
* Resolves every active immutable Skill through the normalized Plugin/Skill-
|
|
84
61
|
* Facet ledger. The data layer has already filtered ineffective owner edges;
|
|
@@ -128,18 +105,7 @@ export async function resolveWorkspaceInstalledSkillRuntime(
|
|
|
128
105
|
* unique. V2 rows never reach this function through runtime resolution.
|
|
129
106
|
*/
|
|
130
107
|
export function workspacePackRuntimeFromPacks(packs: CapabilityPack[]): WorkspacePackRuntime {
|
|
131
|
-
const
|
|
132
|
-
(pack) => typeof pack.sandboxImage === "string" && pack.sandboxImage.trim().length > 0,
|
|
133
|
-
);
|
|
134
|
-
if (imagePacks.length > 1) {
|
|
135
|
-
const ids = imagePacks
|
|
136
|
-
.map((pack) => pack.id)
|
|
137
|
-
.sort()
|
|
138
|
-
.join(", ");
|
|
139
|
-
throw new Error(
|
|
140
|
-
`Multiple enabled packs declare a sandbox image (${ids}). Only one enabled pack per workspace may declare sandboxImage; disable the others and retry.`,
|
|
141
|
-
);
|
|
142
|
-
}
|
|
108
|
+
const sandboxRuntime = legacySandboxRuntimeFromPacks(packs);
|
|
143
109
|
const skillActivations: PackSkillActivation[] = [];
|
|
144
110
|
// Keyed case-insensitively to match the per-pack uniqueness rule in the
|
|
145
111
|
// CapabilityPack contract (and case-insensitive filesystems).
|
|
@@ -168,8 +134,8 @@ export function workspacePackRuntimeFromPacks(packs: CapabilityPack[]): Workspac
|
|
|
168
134
|
}
|
|
169
135
|
}
|
|
170
136
|
return {
|
|
171
|
-
sandboxImage:
|
|
172
|
-
sandboxProviderImages:
|
|
137
|
+
sandboxImage: sandboxRuntime.sandboxImage,
|
|
138
|
+
sandboxProviderImages: sandboxRuntime.sandboxProviderImages,
|
|
173
139
|
skillActivations,
|
|
174
140
|
};
|
|
175
141
|
}
|
|
@@ -198,17 +164,3 @@ export async function resolveWorkspaceAgentInstructions(
|
|
|
198
164
|
* the settings pass through untouched, so deployments without packs keep the
|
|
199
165
|
* global OPENGENI_DOCKER_IMAGE / OPENGENI_MODAL_IMAGE_REF behavior exactly.
|
|
200
166
|
*/
|
|
201
|
-
/**
|
|
202
|
-
* Layers the rig version's default variable sets BELOW the session's own set:
|
|
203
|
-
* the session's values WIN on any key collision (explicit precedence). Both maps
|
|
204
|
-
* are already the decrypted-and-merged values (rig defaults merged in listed
|
|
205
|
-
* order upstream). Pure and deterministic — given the same inputs it returns the
|
|
206
|
-
* same env, which is what keeps a session's box-manifest env stable across turns
|
|
207
|
-
* (the rig version is frozen per session, so its default-set list is fixed).
|
|
208
|
-
*/
|
|
209
|
-
export function mergeRigDefaultVariableSetEnvironment(
|
|
210
|
-
rigDefaultValues: Record<string, string>,
|
|
211
|
-
sessionValues: Record<string, string>,
|
|
212
|
-
): Record<string, string> {
|
|
213
|
-
return { ...rigDefaultValues, ...sessionValues };
|
|
214
|
-
}
|
|
@@ -8,11 +8,13 @@ import {
|
|
|
8
8
|
addSessionSystemUpdateWithSourceMutation,
|
|
9
9
|
claimPendingSessionSystemUpdateOutbox,
|
|
10
10
|
claimPendingSessionWorkflowWakes,
|
|
11
|
+
childRequiresActionDedupeKey,
|
|
11
12
|
getSessionSystemUpdateOutboxByDedupeKey,
|
|
12
13
|
getOrCreateSessionSystemUpdateOutbox,
|
|
13
14
|
markSessionWorkflowWakeFailed,
|
|
14
15
|
markSessionSystemUpdateOutboxDeliveredInTransaction,
|
|
15
16
|
markSessionSystemUpdateOutboxFailed,
|
|
17
|
+
sessionSystemUpdateOutboxKindPayload,
|
|
16
18
|
type Database,
|
|
17
19
|
type SessionSystemUpdateOutboxDelivery,
|
|
18
20
|
} from "@opengeni/db";
|
|
@@ -103,41 +105,88 @@ export async function notifyParentOfChildIdle(
|
|
|
103
105
|
}
|
|
104
106
|
|
|
105
107
|
/**
|
|
106
|
-
* Deliver
|
|
107
|
-
*
|
|
108
|
-
*
|
|
108
|
+
* Deliver one exact child-lifecycle outbox row already committed by the
|
|
109
|
+
* child's own lifecycle transaction (turn failure, requires_action freeze,
|
|
110
|
+
* ...). This layer deliberately cannot create or rewrite the row: the
|
|
111
|
+
* producing transaction is the sole owner of its payload and lineage, and the
|
|
112
|
+
* global reconciler remains the recovery path if immediate delivery fails.
|
|
109
113
|
*/
|
|
110
|
-
export async function
|
|
114
|
+
export async function deliverChildLifecycleOutboxToParent(
|
|
111
115
|
svc: NotifyServices,
|
|
112
116
|
workspaceId: string,
|
|
113
117
|
childSessionId: string,
|
|
114
|
-
|
|
118
|
+
dedupeKey: string,
|
|
119
|
+
options: { requireRow?: boolean } = {},
|
|
115
120
|
): Promise<void> {
|
|
116
121
|
try {
|
|
117
122
|
const child = await getSession(svc.db, workspaceId, childSessionId);
|
|
118
123
|
if (!child || !child.parentSessionId) return;
|
|
119
|
-
const dedupeKey = `child-completion:${childSessionId}:turn:${turnId}`;
|
|
120
124
|
const outbox = await getSessionSystemUpdateOutboxByDedupeKey(svc.db, {
|
|
121
125
|
accountId: child.accountId,
|
|
122
126
|
workspaceId,
|
|
123
127
|
dedupeKey,
|
|
124
128
|
});
|
|
125
129
|
if (!outbox) {
|
|
126
|
-
|
|
130
|
+
if (options.requireRow === false) return;
|
|
131
|
+
throw new Error(`Committed child-lifecycle outbox disappeared: ${dedupeKey}`);
|
|
127
132
|
}
|
|
128
133
|
if (outbox.status === "delivered") return;
|
|
129
134
|
await deliverParentSystemUpdateOutbox(svc, outbox);
|
|
130
135
|
} catch (error) {
|
|
131
|
-
|
|
132
|
-
// reconciler remains the recovery path if immediate delivery fails.
|
|
133
|
-
svc.observability.error("Failed to deliver committed child-turn failure", {
|
|
136
|
+
svc.observability.error("Failed to deliver committed child-lifecycle notice", {
|
|
134
137
|
childSessionId,
|
|
135
|
-
|
|
138
|
+
dedupeKey,
|
|
136
139
|
error: error instanceof Error ? error.message : String(error),
|
|
137
140
|
});
|
|
138
141
|
}
|
|
139
142
|
}
|
|
140
143
|
|
|
144
|
+
/**
|
|
145
|
+
* Deliver the exact failure row already committed by turn settlement. This
|
|
146
|
+
* layer deliberately cannot create or rewrite the row: the settlement
|
|
147
|
+
* transaction is the sole owner of the failed turn id, payload, and lineage.
|
|
148
|
+
*/
|
|
149
|
+
export async function deliverFailedChildTurnToParent(
|
|
150
|
+
svc: NotifyServices,
|
|
151
|
+
workspaceId: string,
|
|
152
|
+
childSessionId: string,
|
|
153
|
+
turnId: string,
|
|
154
|
+
): Promise<void> {
|
|
155
|
+
await deliverChildLifecycleOutboxToParent(
|
|
156
|
+
svc,
|
|
157
|
+
workspaceId,
|
|
158
|
+
childSessionId,
|
|
159
|
+
`child-completion:${childSessionId}:turn:${turnId}`,
|
|
160
|
+
);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Deliver the child_requires_action notice a requires_action settlement
|
|
165
|
+
* committed for this exact (child, turn, generation). When the rollout flag is
|
|
166
|
+
* off no row exists and this is a no-op; the reaper covers crashes after commit.
|
|
167
|
+
*/
|
|
168
|
+
export async function deliverChildRequiresActionToParent(
|
|
169
|
+
svc: NotifyServices,
|
|
170
|
+
workspaceId: string,
|
|
171
|
+
childSessionId: string,
|
|
172
|
+
input: { turnId: string; turnGeneration: number },
|
|
173
|
+
): Promise<void> {
|
|
174
|
+
if (!svc.settings.childLifecycleNoticesEnabled) return;
|
|
175
|
+
await deliverChildLifecycleOutboxToParent(
|
|
176
|
+
svc,
|
|
177
|
+
workspaceId,
|
|
178
|
+
childSessionId,
|
|
179
|
+
childRequiresActionDedupeKey({
|
|
180
|
+
childSessionId,
|
|
181
|
+
turnId: input.turnId,
|
|
182
|
+
turnGeneration: input.turnGeneration,
|
|
183
|
+
}),
|
|
184
|
+
// A requires_action freeze without any human-input/approval request (or a
|
|
185
|
+
// child without a parent) commits no row; that is not an error.
|
|
186
|
+
{ requireRow: false },
|
|
187
|
+
);
|
|
188
|
+
}
|
|
189
|
+
|
|
141
190
|
async function deliverParentSystemUpdateOutbox(
|
|
142
191
|
svc: NotifyServices,
|
|
143
192
|
outbox: SessionSystemUpdateOutboxDelivery,
|
|
@@ -149,12 +198,11 @@ async function deliverParentSystemUpdateOutbox(
|
|
|
149
198
|
accountId: outbox.accountId,
|
|
150
199
|
workspaceId: outbox.workspaceId,
|
|
151
200
|
sessionId: outbox.targetSessionId,
|
|
152
|
-
|
|
201
|
+
...sessionSystemUpdateOutboxKindPayload(outbox),
|
|
153
202
|
classification: outbox.classification,
|
|
154
203
|
sourceId: outbox.sourceId,
|
|
155
204
|
dedupeKey: outbox.dedupeKey,
|
|
156
205
|
summary: outbox.summary,
|
|
157
|
-
payload: outbox.payload,
|
|
158
206
|
lineage: outbox.lineage,
|
|
159
207
|
personalConnectionDelegations: outbox.personalConnectionDelegations,
|
|
160
208
|
xaiProviderAccountAuthoritySnapshot: outbox.xaiProviderAccountAuthoritySnapshot,
|
|
@@ -181,10 +229,12 @@ async function deliverParentSystemUpdateOutbox(
|
|
|
181
229
|
wakeRevision: result.workflowWakeRevision,
|
|
182
230
|
});
|
|
183
231
|
}
|
|
184
|
-
svc.observability.info("
|
|
232
|
+
svc.observability.info("Delivered child lifecycle notice to parent session", {
|
|
185
233
|
childSessionId: outbox.sourceSessionId,
|
|
186
234
|
parentSessionId: outbox.targetSessionId,
|
|
235
|
+
kind: outbox.kind,
|
|
187
236
|
dedupeKey: outbox.dedupeKey,
|
|
237
|
+
woke: result.shouldWake,
|
|
188
238
|
});
|
|
189
239
|
} catch (error) {
|
|
190
240
|
await markSessionSystemUpdateOutboxFailed(
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
promoteRetainedScreenshotMaintenanceCleanup,
|
|
6
6
|
type RetainedScreenshotMaintenanceClaim,
|
|
7
7
|
} from "@opengeni/db";
|
|
8
|
-
import type
|
|
8
|
+
import { retryWhileMissing, type ObjectHead, type ObjectStorage } from "@opengeni/storage";
|
|
9
9
|
import type { ControlActivityServices } from "./types";
|
|
10
10
|
|
|
11
11
|
export const RETAINED_SCREENSHOT_PENDING_GRACE_MS = 15 * 60 * 1_000;
|
|
@@ -168,8 +168,11 @@ async function observeClaimObject(
|
|
|
168
168
|
provider: Required<Pick<RetainedScreenshotMaintenanceActivityOptions, "fileExists" | "headFile">>,
|
|
169
169
|
): Promise<"matches" | "mismatch" | "missing"> {
|
|
170
170
|
const file = claimFile(storage, claim);
|
|
171
|
-
|
|
172
|
-
|
|
171
|
+
const head = await retryWhileMissing(async () => {
|
|
172
|
+
if (!(await provider.fileExists(storage, file))) return null;
|
|
173
|
+
return await provider.headFile(storage, file);
|
|
174
|
+
});
|
|
175
|
+
if (!head) return "missing";
|
|
173
176
|
return head.ContentLength === claim.sizeBytes &&
|
|
174
177
|
head.ContentType === claim.mediaType &&
|
|
175
178
|
head.Metadata?.sha256 === claim.sha256
|
|
@@ -13,13 +13,15 @@ import {
|
|
|
13
13
|
import {
|
|
14
14
|
RetainedScreenshotQuotaExceededError,
|
|
15
15
|
getRetainedScreenshotArtifact,
|
|
16
|
+
isDatabasePersistenceFailure,
|
|
17
|
+
isSessionEventPersistenceError,
|
|
16
18
|
prepareRetainedScreenshotArtifact,
|
|
17
19
|
recordRetainedScreenshotArtifactError,
|
|
18
20
|
settleRetainedScreenshotArtifactReady,
|
|
19
21
|
type Database,
|
|
20
22
|
type RetainedScreenshotArtifact,
|
|
21
23
|
} from "@opengeni/db";
|
|
22
|
-
import
|
|
24
|
+
import { retryWhileMissing, type ObjectStorage } from "@opengeni/storage";
|
|
23
25
|
import { createHash } from "node:crypto";
|
|
24
26
|
|
|
25
27
|
const PNG_SIGNATURE = Uint8Array.of(0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a);
|
|
@@ -588,13 +590,14 @@ export async function retainComputerScreenshot(input: {
|
|
|
588
590
|
if (error instanceof RetainedScreenshotQuotaExceededError) {
|
|
589
591
|
return unavailable(identity.artifactId, "quota_exceeded");
|
|
590
592
|
}
|
|
593
|
+
if (isSessionEventPersistenceError(error) || isDatabasePersistenceFailure(error)) {
|
|
594
|
+
return unavailable(identity.artifactId, "pending");
|
|
595
|
+
}
|
|
591
596
|
throw error;
|
|
592
597
|
}
|
|
593
598
|
|
|
594
599
|
if (prepared.status === "ready") {
|
|
595
|
-
return (
|
|
596
|
-
? reference(prepared)
|
|
597
|
-
: unavailable(identity.artifactId, "missing_storage");
|
|
600
|
+
return reference(prepared);
|
|
598
601
|
}
|
|
599
602
|
if (prepared.status !== "pending" && prepared.status !== "reconciling") {
|
|
600
603
|
return unavailable(identity.artifactId, unavailableReasonForStatus(prepared.status));
|
|
@@ -607,8 +610,6 @@ export async function retainComputerScreenshot(input: {
|
|
|
607
610
|
body: screenshot.bytes,
|
|
608
611
|
sha256: screenshot.sha256,
|
|
609
612
|
});
|
|
610
|
-
const head = await input.objectStorage.headFile(prepared.file);
|
|
611
|
-
assertStoredScreenshotHead(head, screenshot);
|
|
612
613
|
} catch (error) {
|
|
613
614
|
await recordRetainedScreenshotArtifactError(input.db, {
|
|
614
615
|
accountId: input.accountId,
|
|
@@ -639,9 +640,7 @@ export async function retainComputerScreenshot(input: {
|
|
|
639
640
|
identity.artifactId,
|
|
640
641
|
).catch(() => undefined);
|
|
641
642
|
if (stillReferenced?.status === "ready") {
|
|
642
|
-
return (
|
|
643
|
-
? reference(stillReferenced)
|
|
644
|
-
: unavailable(identity.artifactId, "missing_storage");
|
|
643
|
+
return reference(stillReferenced);
|
|
645
644
|
}
|
|
646
645
|
if (
|
|
647
646
|
stillReferenced === null ||
|
|
@@ -810,9 +809,6 @@ async function materializeRetainedScreenshotHistoryWithCache(
|
|
|
810
809
|
): Promise<Array<Record<string, unknown>>> {
|
|
811
810
|
const now = input.now ?? new Date();
|
|
812
811
|
const dataUrlForReceipt = async (receipt: RetainedArtifactMetadata): Promise<string> => {
|
|
813
|
-
if (!receipt.available) {
|
|
814
|
-
throw new RetainedScreenshotUnavailableError(receipt.artifactId, receipt.reason);
|
|
815
|
-
}
|
|
816
812
|
let dataUrl = cache.get(receipt.artifactId);
|
|
817
813
|
if (!dataUrl) {
|
|
818
814
|
if (!input.objectStorage) {
|
|
@@ -834,9 +830,12 @@ async function materializeRetainedScreenshotHistoryWithCache(
|
|
|
834
830
|
if (artifact.retentionExpiresAt.getTime() <= now.getTime()) {
|
|
835
831
|
throw new RetainedScreenshotUnavailableError(receipt.artifactId, "expired");
|
|
836
832
|
}
|
|
837
|
-
const
|
|
838
|
-
|
|
833
|
+
const object = await retryWhileMissing(async () =>
|
|
834
|
+
input.objectStorage!.getObjectBytes(artifact.file.objectKey),
|
|
835
|
+
);
|
|
836
|
+
if (!object)
|
|
839
837
|
throw new RetainedScreenshotUnavailableError(receipt.artifactId, "missing_storage");
|
|
838
|
+
const bytes = object.bytes;
|
|
840
839
|
const validated = validateRetainableSessionImage({
|
|
841
840
|
bytes,
|
|
842
841
|
declaredMediaType: artifact.mediaType,
|
|
@@ -846,8 +845,8 @@ async function materializeRetainedScreenshotHistoryWithCache(
|
|
|
846
845
|
validated.sha256 !== artifact.sha256 ||
|
|
847
846
|
validated.width !== artifact.width ||
|
|
848
847
|
validated.height !== artifact.height ||
|
|
849
|
-
receipt.
|
|
850
|
-
|
|
848
|
+
(receipt.available &&
|
|
849
|
+
(receipt.sha256 !== artifact.sha256 || receipt.originalBytes !== artifact.sizeBytes))
|
|
851
850
|
) {
|
|
852
851
|
throw new RetainedScreenshotUnavailableError(receipt.artifactId, "invalid_content");
|
|
853
852
|
}
|
|
@@ -1020,37 +1019,6 @@ function unavailableReasonForStatus(
|
|
|
1020
1019
|
}
|
|
1021
1020
|
}
|
|
1022
1021
|
|
|
1023
|
-
async function verifyReadyArtifact(
|
|
1024
|
-
storage: ObjectStorage,
|
|
1025
|
-
artifact: RetainedScreenshotArtifact,
|
|
1026
|
-
): Promise<boolean> {
|
|
1027
|
-
try {
|
|
1028
|
-
assertStoredScreenshotHead(await storage.headFile(artifact.file), {
|
|
1029
|
-
sizeBytes: artifact.sizeBytes,
|
|
1030
|
-
mediaType: artifact.mediaType as RetainableSessionImageMediaType,
|
|
1031
|
-
sha256: artifact.sha256,
|
|
1032
|
-
});
|
|
1033
|
-
return true;
|
|
1034
|
-
} catch {
|
|
1035
|
-
return false;
|
|
1036
|
-
}
|
|
1037
|
-
}
|
|
1038
|
-
|
|
1039
|
-
function assertStoredScreenshotHead(
|
|
1040
|
-
head: ObjectHead,
|
|
1041
|
-
expected: Pick<ValidatedSessionImage, "sizeBytes" | "mediaType" | "sha256">,
|
|
1042
|
-
): void {
|
|
1043
|
-
if (head.ContentLength !== expected.sizeBytes) {
|
|
1044
|
-
throw new Error("retained screenshot object size mismatch");
|
|
1045
|
-
}
|
|
1046
|
-
if (head.ContentType !== expected.mediaType) {
|
|
1047
|
-
throw new Error("retained screenshot object MIME mismatch");
|
|
1048
|
-
}
|
|
1049
|
-
if (head.Metadata?.sha256 !== expected.sha256) {
|
|
1050
|
-
throw new Error("retained screenshot object SHA-256 metadata mismatch");
|
|
1051
|
-
}
|
|
1052
|
-
}
|
|
1053
|
-
|
|
1054
1022
|
function retainedReceiptFromImageContent(entry: unknown): RetainedArtifactMetadata | null {
|
|
1055
1023
|
if (!entry || typeof entry !== "object" || Array.isArray(entry)) return null;
|
|
1056
1024
|
const image = (entry as Record<string, unknown>).image;
|
|
@@ -501,7 +501,7 @@ export async function runWithOwnedRigVerificationSandbox<T>(
|
|
|
501
501
|
holderId,
|
|
502
502
|
subjectId: null,
|
|
503
503
|
backend: input.settings.sandboxBackend,
|
|
504
|
-
image: input.settings
|
|
504
|
+
image: rigProviderImageSourceImage(input.settings, input.settings.sandboxBackend),
|
|
505
505
|
rigVersionId: input.rigVersionId,
|
|
506
506
|
leaseTtlMs: RIG_VERIFICATION_OWNER_TTL_MS,
|
|
507
507
|
warmingLeaseTtlMs: RIG_VERIFICATION_OWNER_TTL_MS,
|