@opengeni/worker-bundle 0.23.4 → 0.26.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 +17 -2
- package/dist/activities/agent-turn/agent-build.d.ts +3 -10
- package/dist/activities/agent-turn/claim.d.ts +8 -0
- package/dist/activities/agent-turn/codex.d.ts +2 -2
- package/dist/activities/agent-turn/credential-leases.d.ts +8 -0
- package/dist/activities/agent-turn/errors.d.ts +1 -1
- package/dist/activities/agent-turn/failure-settlement.d.ts +43 -1
- package/dist/activities/agent-turn/list-models.d.ts +16 -0
- package/dist/activities/agent-turn/model-usage.d.ts +15 -1
- package/dist/activities/agent-turn/quiescence.d.ts +11 -6
- package/dist/activities/agent-turn/run.d.ts +9 -0
- package/dist/activities/agent-turn/sandbox-runtime.d.ts +15 -0
- package/dist/activities/agent-turn/session-title.d.ts +21 -0
- package/dist/activities/agent-turn/stream-attempt.d.ts +4 -0
- package/dist/activities/agent-turn/tool-environment.d.ts +4 -13
- package/dist/activities/agent-turn/tool-policy.d.ts +40 -5
- package/dist/activities/agent-turn/turn-context.d.ts +13 -2
- package/dist/activities/agent-turn.d.ts +1 -1
- package/dist/activities/automations.d.ts +1 -0
- package/dist/activities/capabilities.d.ts +3 -1
- package/dist/activities/codemode-dispatcher.d.ts +10 -1
- package/dist/activities/codex-capacity.d.ts +32 -3
- package/dist/activities/codex-fleet-shadow.d.ts +1 -1
- package/dist/activities/codex-image-generation.d.ts +1 -1
- package/dist/activities/codex-rotation.d.ts +8 -67
- package/dist/activities/context-compaction.d.ts +2 -0
- package/dist/activities/goals.d.ts +12 -1
- package/dist/activities/google-drive-publication.d.ts +2 -13
- package/dist/activities/image-generation-operation.d.ts +13 -4
- package/dist/activities/image-generation-references.d.ts +2 -1
- package/dist/activities/scheduled-tasks.d.ts +1 -0
- package/dist/activities/session-state.d.ts +4 -2
- package/dist/activities/types.d.ts +19 -1
- package/dist/{activities-control-52W5IDWM.js → activities-control-CTEMLTHG.js} +339 -195
- package/dist/activities-control-CTEMLTHG.js.map +1 -0
- package/dist/activities-control.d.ts +4 -0
- package/dist/{activities-turn-A2G2KLSY.js → activities-turn-S5IU347A.js} +1846 -1136
- package/dist/activities-turn-S5IU347A.js.map +1 -0
- package/dist/activities.d.ts +4 -0
- package/dist/{chunk-GFNXVZVQ.js → chunk-D4ZEFOYH.js} +107 -7
- package/dist/chunk-D4ZEFOYH.js.map +1 -0
- package/dist/{chunk-GRFQTTSQ.js → chunk-GDCLDKSH.js} +7 -3
- package/dist/{chunk-GRFQTTSQ.js.map → chunk-GDCLDKSH.js.map} +1 -1
- package/dist/{chunk-IPVMCAW5.js → chunk-TAUE3GYT.js} +225 -154
- package/dist/chunk-TAUE3GYT.js.map +1 -0
- package/dist/github-rest-mcp.d.ts +0 -2
- package/dist/index.d.ts +2 -0
- package/dist/index.js +43 -7
- package/dist/index.js.map +1 -1
- package/dist/observability-metrics.d.ts +35 -8
- package/dist/sandbox-reaper-timeout.d.ts +2 -2
- package/dist/sandbox-resume.d.ts +6 -1
- package/dist/workflow-bundle.js +96 -10
- package/dist/workflows/activities.d.ts +6 -1
- package/dist/workflows/automations.d.ts +5 -0
- package/dist/workflows/session.d.ts +3 -0
- package/package.json +17 -17
- package/src/activities/agent-run-admission.ts +7 -1
- package/src/activities/agent-turn/admission.ts +47 -6
- package/src/activities/agent-turn/agent-build.ts +20 -26
- package/src/activities/agent-turn/claim.ts +59 -6
- package/src/activities/agent-turn/codex-capacity.ts +311 -234
- package/src/activities/agent-turn/codex.ts +2 -2
- package/src/activities/agent-turn/compaction-prep.ts +8 -1
- package/src/activities/agent-turn/credential-leases.ts +36 -0
- package/src/activities/agent-turn/errors.ts +29 -1
- package/src/activities/agent-turn/failure-settlement.ts +451 -323
- package/src/activities/agent-turn/finalization.ts +31 -17
- package/src/activities/agent-turn/list-models.ts +101 -0
- package/src/activities/agent-turn/model-usage.ts +120 -45
- package/src/activities/agent-turn/quiescence.ts +32 -17
- package/src/activities/agent-turn/run.ts +98 -9
- package/src/activities/agent-turn/sandbox-runtime.ts +78 -81
- package/src/activities/agent-turn/session-title.ts +55 -2
- package/src/activities/agent-turn/stream-attempt.ts +281 -136
- package/src/activities/agent-turn/tool-environment.ts +132 -39
- package/src/activities/agent-turn/tool-policy.ts +71 -12
- package/src/activities/agent-turn/turn-context.ts +21 -2
- package/src/activities/agent-turn.ts +5 -1
- package/src/activities/automations.ts +122 -67
- package/src/activities/capabilities.ts +129 -2
- package/src/activities/codemode-dispatcher.ts +235 -59
- package/src/activities/codex-capacity.ts +89 -10
- package/src/activities/codex-fleet-shadow.ts +8 -1
- package/src/activities/codex-image-generation.ts +19 -2
- package/src/activities/codex-rotation.ts +45 -142
- package/src/activities/context-compaction.ts +3 -0
- package/src/activities/goals.ts +116 -39
- package/src/activities/google-drive-publication.ts +4 -81
- package/src/activities/image-generation-operation.ts +28 -3
- package/src/activities/image-generation-references.ts +9 -9
- package/src/activities/mcp-credentials.ts +53 -0
- package/src/activities/rig-verification.ts +5 -3
- package/src/activities/sandbox-lease.ts +29 -12
- package/src/activities/scheduled-tasks.ts +217 -110
- package/src/activities/session-state.ts +17 -0
- package/src/activities/site-auth-maintenance.ts +12 -12
- package/src/activities/types.ts +22 -8
- package/src/activities.ts +2 -0
- package/src/activity-services.ts +4 -1
- package/src/github-rest-mcp.ts +2 -83
- package/src/index.ts +34 -4
- package/src/observability-metrics.ts +158 -14
- package/src/sandbox-reaper-timeout.ts +10 -4
- package/src/sandbox-resume.ts +58 -8
- package/src/sandbox-routing.ts +71 -16
- package/src/workflows/activities.ts +16 -0
- package/src/workflows/automations.ts +21 -2
- package/src/workflows/session.ts +85 -7
- package/dist/activities/api-integrations.d.ts +0 -21
- package/dist/activities-control-52W5IDWM.js.map +0 -1
- package/dist/activities-turn-A2G2KLSY.js.map +0 -1
- package/dist/chunk-GFNXVZVQ.js.map +0 -1
- package/dist/chunk-IPVMCAW5.js.map +0 -1
- package/src/activities/api-integrations.ts +0 -141
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createHash } from "node:crypto";
|
|
2
|
-
import {
|
|
2
|
+
import type { AttemptToolDefinition } from "@opengeni/codemode";
|
|
3
3
|
import type { McpPersonalConnectionDelegation } from "@opengeni/contracts";
|
|
4
4
|
import {
|
|
5
5
|
GOOGLE_DRIVE_FILE_SCOPE,
|
|
@@ -17,10 +17,7 @@ import {
|
|
|
17
17
|
type GoogleDrivePublicationToolInput as GoogleDrivePublicationToolInputValue,
|
|
18
18
|
} from "@opengeni/contracts/google-drive";
|
|
19
19
|
import {
|
|
20
|
-
beginConnectorActionExecution,
|
|
21
|
-
completeConnectorActionExecution,
|
|
22
20
|
getConnectionMetadata,
|
|
23
|
-
prepareConnectorActionApproval,
|
|
24
21
|
requireFile,
|
|
25
22
|
namedSubjectHasLiveWorkspaceAuthority,
|
|
26
23
|
type ConnectorActionAttemptIdentity,
|
|
@@ -34,6 +31,7 @@ import {
|
|
|
34
31
|
type PersistedEditableArtifactMaterializationJob,
|
|
35
32
|
} from "@opengeni/db/editable-artifact-durable-export";
|
|
36
33
|
import { readResponseJsonBounded, undiciFetch, type FetchLike } from "@opengeni/network";
|
|
34
|
+
import { ConnectorActionExecutionError } from "@opengeni/runtime";
|
|
37
35
|
import { retryWhileMissing, type ObjectStorage } from "@opengeni/storage";
|
|
38
36
|
|
|
39
37
|
const DRIVE_API = "https://www.googleapis.com/drive/v3";
|
|
@@ -66,9 +64,6 @@ export type GoogleDrivePublicationPorts = {
|
|
|
66
64
|
getMembership: typeof namedSubjectHasLiveWorkspaceAuthority;
|
|
67
65
|
readMaterialization: typeof readAuthorizedEditableArtifactMaterialization;
|
|
68
66
|
requireFile: typeof requireFile;
|
|
69
|
-
prepare: typeof prepareConnectorActionApproval;
|
|
70
|
-
begin: typeof beginConnectorActionExecution;
|
|
71
|
-
complete: typeof completeConnectorActionExecution;
|
|
72
67
|
fetch: FetchLike;
|
|
73
68
|
};
|
|
74
69
|
|
|
@@ -77,9 +72,6 @@ const defaultPorts: GoogleDrivePublicationPorts = {
|
|
|
77
72
|
getMembership: namedSubjectHasLiveWorkspaceAuthority,
|
|
78
73
|
readMaterialization: readAuthorizedEditableArtifactMaterialization,
|
|
79
74
|
requireFile,
|
|
80
|
-
prepare: prepareConnectorActionApproval,
|
|
81
|
-
begin: beginConnectorActionExecution,
|
|
82
|
-
complete: completeConnectorActionExecution,
|
|
83
75
|
fetch: undiciFetch,
|
|
84
76
|
};
|
|
85
77
|
|
|
@@ -303,35 +295,6 @@ export function createGoogleDrivePublicationAttemptTool(input: {
|
|
|
303
295
|
approval: "policy",
|
|
304
296
|
execute: async (raw, context) => {
|
|
305
297
|
const request = GoogleDrivePublicationToolInput.parse(raw);
|
|
306
|
-
const connectorCall = googleDrivePublicationConnectorCall(
|
|
307
|
-
input.target,
|
|
308
|
-
request,
|
|
309
|
-
context.operationId,
|
|
310
|
-
);
|
|
311
|
-
// Every caller is behind exactly one durable execute-once fence. Model
|
|
312
|
-
// callers arrive through the attempt connector-action wrapper, which has
|
|
313
|
-
// already registered this call under its durable SDK call id and moved
|
|
314
|
-
// the approved row to executing - a second inner begin here would mint a
|
|
315
|
-
// second row under an unrelated operation id and deadlock the default
|
|
316
|
-
// ask policy. Codemode callers bypass that wrapper, so the tool
|
|
317
|
-
// registers the fence itself with the shared Codemode operation id.
|
|
318
|
-
let requestId: string | null = null;
|
|
319
|
-
if (context.caller.kind === "codemode") {
|
|
320
|
-
const admission = await ports.begin(input.db, input.identity, connectorCall);
|
|
321
|
-
if (!admission.allowed) {
|
|
322
|
-
throw new Error(
|
|
323
|
-
admission.reason === "uncertain_retry" || admission.reason === "already_executed"
|
|
324
|
-
? "Google Drive publication outcome is unknown: a previous attempt may have already sent this publication to Google Drive. Verify in Drive before retrying with a new idempotency key."
|
|
325
|
-
: admission.reason === "not_executed"
|
|
326
|
-
? "Google Drive publication was not executed: the previous attempt failed before any request reached Google Drive. Retrying with a new call is safe."
|
|
327
|
-
: `Google Drive publication was not executed: ${admission.reason}. No request reached Google Drive.`,
|
|
328
|
-
);
|
|
329
|
-
}
|
|
330
|
-
if (!admission.managed) {
|
|
331
|
-
throw new Error("Google Drive publication has no explicit connector action policy");
|
|
332
|
-
}
|
|
333
|
-
requestId = admission.requestId;
|
|
334
|
-
}
|
|
335
298
|
let providerRequestStarted = false;
|
|
336
299
|
try {
|
|
337
300
|
const receipt = await executeGoogleDrivePublication(
|
|
@@ -350,34 +313,17 @@ export function createGoogleDrivePublicationAttemptTool(input: {
|
|
|
350
313
|
},
|
|
351
314
|
ports,
|
|
352
315
|
);
|
|
353
|
-
if (requestId) {
|
|
354
|
-
await ports.complete(input.db, {
|
|
355
|
-
accountId: input.identity.accountId,
|
|
356
|
-
workspaceId: input.identity.workspaceId,
|
|
357
|
-
requestId,
|
|
358
|
-
attemptId: input.identity.attemptId,
|
|
359
|
-
outcome: "completed",
|
|
360
|
-
});
|
|
361
|
-
}
|
|
362
316
|
return {
|
|
363
317
|
content: [{ type: "text", text: JSON.stringify(receipt) }],
|
|
364
318
|
structuredContent: receipt,
|
|
365
319
|
};
|
|
366
320
|
} catch (error) {
|
|
367
|
-
if (requestId) {
|
|
368
|
-
await ports.complete(input.db, {
|
|
369
|
-
accountId: input.identity.accountId,
|
|
370
|
-
workspaceId: input.identity.workspaceId,
|
|
371
|
-
requestId,
|
|
372
|
-
attemptId: input.identity.attemptId,
|
|
373
|
-
outcome: providerRequestStarted ? "uncertain" : "not_executed",
|
|
374
|
-
});
|
|
375
|
-
}
|
|
376
321
|
const detail = error instanceof Error ? error.message : String(error);
|
|
377
|
-
throw new
|
|
322
|
+
throw new ConnectorActionExecutionError(
|
|
378
323
|
providerRequestStarted
|
|
379
324
|
? `Google Drive publication outcome is unknown: a provider request may have been sent before the failure. Verify in Drive before retrying. Cause: ${detail}`
|
|
380
325
|
: `Google Drive publication was not executed: no request reached Google Drive. Cause: ${detail}`,
|
|
326
|
+
providerRequestStarted ? "uncertain" : "not_executed",
|
|
381
327
|
{ cause: error },
|
|
382
328
|
);
|
|
383
329
|
}
|
|
@@ -385,29 +331,6 @@ export function createGoogleDrivePublicationAttemptTool(input: {
|
|
|
385
331
|
};
|
|
386
332
|
}
|
|
387
333
|
|
|
388
|
-
export async function authorizeGoogleDrivePublicationAttempt(input: {
|
|
389
|
-
db: Database;
|
|
390
|
-
identity: ConnectorActionAttemptIdentity;
|
|
391
|
-
target: GoogleDrivePublicationTarget;
|
|
392
|
-
approvalId: string;
|
|
393
|
-
arguments: unknown;
|
|
394
|
-
ports?: Pick<GoogleDrivePublicationPorts, "prepare">;
|
|
395
|
-
}): Promise<void> {
|
|
396
|
-
const request = GoogleDrivePublicationToolInput.parse(input.arguments);
|
|
397
|
-
const preparation = await (input.ports ?? defaultPorts).prepare(
|
|
398
|
-
input.db,
|
|
399
|
-
input.identity,
|
|
400
|
-
googleDrivePublicationConnectorCall(input.target, request, input.approvalId),
|
|
401
|
-
);
|
|
402
|
-
if (!preparation.managed) {
|
|
403
|
-
throw new Error("Google Drive publication has no explicit connector action policy");
|
|
404
|
-
}
|
|
405
|
-
if (preparation.decision === "ask") throw new AttemptToolApprovalRequiredError();
|
|
406
|
-
if (preparation.decision === "block") {
|
|
407
|
-
throw new Error("Google Drive publication is blocked by connector action policy");
|
|
408
|
-
}
|
|
409
|
-
}
|
|
410
|
-
|
|
411
334
|
export async function executeGoogleDrivePublication(
|
|
412
335
|
input: {
|
|
413
336
|
db: Database;
|
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
markImageGenerationOperationOutcomeUnknown,
|
|
6
6
|
markImageGenerationOperationRetentionFailed,
|
|
7
7
|
prepareImageGenerationOperation,
|
|
8
|
+
resetImageGenerationOperationBeforeProviderDispatch,
|
|
8
9
|
type Database,
|
|
9
10
|
type ImageGenerationOperationStatus,
|
|
10
11
|
} from "@opengeni/db";
|
|
@@ -45,6 +46,7 @@ export class ImageGenerationRetentionFailedError extends Error {
|
|
|
45
46
|
export type ImageGenerationOperationPorts = {
|
|
46
47
|
prepare: typeof prepareImageGenerationOperation;
|
|
47
48
|
begin: typeof beginImageGenerationOperation;
|
|
49
|
+
resetBeforeProviderDispatch: typeof resetImageGenerationOperationBeforeProviderDispatch;
|
|
48
50
|
retain: typeof retainGeneratedImage;
|
|
49
51
|
complete: typeof completeImageGenerationOperation;
|
|
50
52
|
markOutcomeUnknown: typeof markImageGenerationOperationOutcomeUnknown;
|
|
@@ -55,6 +57,7 @@ export type ImageGenerationOperationPorts = {
|
|
|
55
57
|
const imageGenerationOperationPorts: ImageGenerationOperationPorts = {
|
|
56
58
|
prepare: prepareImageGenerationOperation,
|
|
57
59
|
begin: beginImageGenerationOperation,
|
|
60
|
+
resetBeforeProviderDispatch: resetImageGenerationOperationBeforeProviderDispatch,
|
|
58
61
|
retain: retainGeneratedImage,
|
|
59
62
|
complete: completeImageGenerationOperation,
|
|
60
63
|
markOutcomeUnknown: markImageGenerationOperationOutcomeUnknown,
|
|
@@ -65,9 +68,10 @@ const imageGenerationOperationPorts: ImageGenerationOperationPorts = {
|
|
|
65
68
|
/**
|
|
66
69
|
* Durable admission fence shared by every client-executed image provider.
|
|
67
70
|
* Provider execution is permitted at most once after the prepared ->
|
|
68
|
-
* provider_started transition. A
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
+
* provider_started transition. A verified pre-dispatch fence rejection returns
|
|
72
|
+
* the row to `prepared`; a crash or any error after dispatch admission may
|
|
73
|
+
* conservatively leave the outcome unknown. A retry may recover a ready
|
|
74
|
+
* artifact, but never blindly replays an admitted paid operation.
|
|
71
75
|
*/
|
|
72
76
|
export type ExecuteImageGenerationOperationInput = {
|
|
73
77
|
db: Database;
|
|
@@ -83,6 +87,13 @@ export type ExecuteImageGenerationOperationInput = {
|
|
|
83
87
|
modelId: string;
|
|
84
88
|
prompt: string;
|
|
85
89
|
referenceDigests?: readonly Readonly<{ mediaType: string; sha256: string }>[];
|
|
90
|
+
/**
|
|
91
|
+
* Provider-specific proof that a thrown error occurred before the paid
|
|
92
|
+
* provider boundary was crossed. Such a failure may return the operation to
|
|
93
|
+
* `prepared`; every other generation error remains outcome-ambiguous after
|
|
94
|
+
* `provider_started` and is never blindly replayed.
|
|
95
|
+
*/
|
|
96
|
+
isProviderDispatchRejected?: (error: unknown) => boolean;
|
|
86
97
|
generate: () => Promise<GeneratedImageOutput>;
|
|
87
98
|
};
|
|
88
99
|
|
|
@@ -132,6 +143,8 @@ export async function executeImageGenerationOperation(
|
|
|
132
143
|
workspaceId: input.workspaceId,
|
|
133
144
|
operationId: identity.operationId,
|
|
134
145
|
operationKey: identity.operationKey,
|
|
146
|
+
providerBindingHash: input.providerBindingHash,
|
|
147
|
+
expectedArtifactId: identity.artifactId,
|
|
135
148
|
});
|
|
136
149
|
if (!begun.started || begun.operation.status !== "provider_started") {
|
|
137
150
|
const recovered = await ports.recover(input, {
|
|
@@ -147,6 +160,18 @@ export async function executeImageGenerationOperation(
|
|
|
147
160
|
try {
|
|
148
161
|
output = await input.generate();
|
|
149
162
|
} catch (error) {
|
|
163
|
+
if (input.isProviderDispatchRejected?.(error) === true) {
|
|
164
|
+
await ports
|
|
165
|
+
.resetBeforeProviderDispatch(input.db, {
|
|
166
|
+
accountId: input.accountId,
|
|
167
|
+
workspaceId: input.workspaceId,
|
|
168
|
+
operationId: identity.operationId,
|
|
169
|
+
operationKey: identity.operationKey,
|
|
170
|
+
error: error instanceof Error ? error.message : String(error),
|
|
171
|
+
})
|
|
172
|
+
.catch(() => undefined);
|
|
173
|
+
throw error;
|
|
174
|
+
}
|
|
150
175
|
await ports
|
|
151
176
|
.markOutcomeUnknown(input.db, {
|
|
152
177
|
accountId: input.accountId,
|
|
@@ -200,20 +200,20 @@ async function referenceBytes(
|
|
|
200
200
|
);
|
|
201
201
|
}
|
|
202
202
|
return {
|
|
203
|
-
bytes: await
|
|
203
|
+
bytes: await readStoredImageReferenceFile(input.objectStorage, file),
|
|
204
204
|
file,
|
|
205
205
|
};
|
|
206
206
|
}
|
|
207
207
|
|
|
208
|
-
async function
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
if (
|
|
208
|
+
export async function readStoredImageReferenceFile(
|
|
209
|
+
objectStorage: Pick<ObjectStorage, "getFileBytes">,
|
|
210
|
+
file: FileAsset,
|
|
211
|
+
): Promise<Uint8Array> {
|
|
212
|
+
const bytes = await objectStorage.getFileBytes(file);
|
|
213
|
+
if (bytes.byteLength !== file.sizeBytes) {
|
|
214
214
|
throw new ImageGenerationReferenceError(
|
|
215
|
-
"
|
|
216
|
-
"The durable image reference bytes
|
|
215
|
+
"reference_integrity_mismatch",
|
|
216
|
+
"The durable image reference bytes do not match their file metadata.",
|
|
217
217
|
);
|
|
218
218
|
}
|
|
219
219
|
return bytes;
|
|
@@ -12,6 +12,9 @@ import {
|
|
|
12
12
|
} from "@opengeni/db";
|
|
13
13
|
import { recordTenancyCompatibilityLaneUse, type Observability } from "@opengeni/observability";
|
|
14
14
|
|
|
15
|
+
const OPENGENI_CONNECTION_ID_PATTERN =
|
|
16
|
+
/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/iu;
|
|
17
|
+
|
|
15
18
|
export function connectionTokenResolverForTurn(input: {
|
|
16
19
|
db: Database;
|
|
17
20
|
settings: Settings;
|
|
@@ -44,6 +47,56 @@ export function connectionTokenResolverForTurn(input: {
|
|
|
44
47
|
})
|
|
45
48
|
: buildConnectionTokenResolver(input.db, input.settings);
|
|
46
49
|
return async (request) => {
|
|
50
|
+
// Host-owned refs carry explicit provenance because their opaque ids may
|
|
51
|
+
// themselves be valid UUIDs. They never enter OpenGeni's native connection
|
|
52
|
+
// authority or PostgreSQL UUID lookup; the bound host authorizes the exact
|
|
53
|
+
// immutable turn context on every credential request.
|
|
54
|
+
if (request.connectionRef.authoritySource === "host") {
|
|
55
|
+
if (hostResolver) return await baseResolver(request);
|
|
56
|
+
return {
|
|
57
|
+
status: "auth_needed",
|
|
58
|
+
reason: "unsupported_auth",
|
|
59
|
+
providerDomain: request.connectionRef.providerDomain,
|
|
60
|
+
authoritySource: "host",
|
|
61
|
+
...(request.connectionRef.provider ? { provider: request.connectionRef.provider } : {}),
|
|
62
|
+
...(request.connectionRef.connectionId
|
|
63
|
+
? { connectionId: request.connectionRef.connectionId }
|
|
64
|
+
: {}),
|
|
65
|
+
...(request.connectionRef.scopes ? { scopes: request.connectionRef.scopes } : {}),
|
|
66
|
+
...(request.connectionRef.resource ? { resource: request.connectionRef.resource } : {}),
|
|
67
|
+
...(request.connectionRef.selectedResources
|
|
68
|
+
? { selectedResources: request.connectionRef.selectedResources }
|
|
69
|
+
: {}),
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
// Before explicit provenance existed, the public embedding contract let a
|
|
73
|
+
// bound host use any non-UUID opaque id. Preserve those frozen/stored refs
|
|
74
|
+
// during upgrades while keeping every UUID-shaped omission on OpenGeni's
|
|
75
|
+
// native accepted-use authority. New host refs must carry authoritySource
|
|
76
|
+
// so UUID-shaped host ids are unambiguous.
|
|
77
|
+
if (
|
|
78
|
+
hostResolver &&
|
|
79
|
+
request.connectionRef.connectionId &&
|
|
80
|
+
!OPENGENI_CONNECTION_ID_PATTERN.test(request.connectionRef.connectionId)
|
|
81
|
+
) {
|
|
82
|
+
try {
|
|
83
|
+
return await baseResolver(request);
|
|
84
|
+
} catch {
|
|
85
|
+
return {
|
|
86
|
+
status: "auth_needed",
|
|
87
|
+
reason: "refresh_failed",
|
|
88
|
+
providerDomain: request.connectionRef.providerDomain,
|
|
89
|
+
authoritySource: "host",
|
|
90
|
+
...(request.connectionRef.provider ? { provider: request.connectionRef.provider } : {}),
|
|
91
|
+
connectionId: request.connectionRef.connectionId,
|
|
92
|
+
...(request.connectionRef.scopes ? { scopes: request.connectionRef.scopes } : {}),
|
|
93
|
+
...(request.connectionRef.resource ? { resource: request.connectionRef.resource } : {}),
|
|
94
|
+
...(request.connectionRef.selectedResources
|
|
95
|
+
? { selectedResources: request.connectionRef.selectedResources }
|
|
96
|
+
: {}),
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
}
|
|
47
100
|
const acceptedDelegation = input.turn.personalConnectionDelegations.find(
|
|
48
101
|
(delegation) =>
|
|
49
102
|
(delegation.connectionType === undefined ||
|
|
@@ -115,11 +115,13 @@ export function rigPlatformChecksForSettings(
|
|
|
115
115
|
'test -x "$__og_browser_engine"',
|
|
116
116
|
'__og_browser_token="$(mktemp)"',
|
|
117
117
|
"trap 'opengeni-browserd-down >/dev/null 2>&1 || true; rm -f \"$__og_browser_token\"' EXIT",
|
|
118
|
-
"
|
|
118
|
+
"__og_browser_token_value=\"$(od -An -N32 -tx1 /dev/urandom | tr -d '[:space:]')\"",
|
|
119
|
+
'test "${#__og_browser_token_value}" -eq 64',
|
|
120
|
+
'printf \'%s\\n\' "$__og_browser_token_value" > "$__og_browser_token"',
|
|
119
121
|
'chmod 0600 "$__og_browser_token"',
|
|
120
122
|
'OPENGENI_BROWSERD_ADMIN_TOKEN_FILE="$__og_browser_token" OPENGENI_BROWSERD_PORT=7682 OPENGENI_BROWSERD_ALLOWED_ORIGINS= opengeni-browserd-up',
|
|
121
123
|
"curl --noproxy '*' -fsS http://127.0.0.1:7682/healthz >/dev/null",
|
|
122
|
-
"curl --noproxy '*' -fsS -H
|
|
124
|
+
"curl --noproxy '*' -fsS -H \"Authorization: Bearer $__og_browser_token_value\" http://127.0.0.1:7682/v1/browser-sessions >/dev/null",
|
|
123
125
|
].join("\n"),
|
|
124
126
|
},
|
|
125
127
|
];
|
|
@@ -148,7 +150,7 @@ export function rigPlatformChecksForSettings(
|
|
|
148
150
|
"test -x /usr/local/bin/opengeni-desktop-down",
|
|
149
151
|
"command -v Xvfb >/dev/null",
|
|
150
152
|
"command -v x11vnc >/dev/null",
|
|
151
|
-
"
|
|
153
|
+
"test -x /opt/noVNC/utils/novnc_proxy",
|
|
152
154
|
"command -v scrot >/dev/null",
|
|
153
155
|
"command -v xdotool >/dev/null",
|
|
154
156
|
'__og_desktop_home="$(mktemp -d)"',
|
|
@@ -53,6 +53,7 @@ import {
|
|
|
53
53
|
workspaceArchiveCaptureDeadlineElapsed,
|
|
54
54
|
retainedProcessReconciliationProof,
|
|
55
55
|
retainedProcessSettlementIdentity,
|
|
56
|
+
settleClaimedConnectedMachineBackgroundCommand,
|
|
56
57
|
settleSandboxCheckpointArtifactGc,
|
|
57
58
|
rlsContextForWorkspace,
|
|
58
59
|
settleRetainedProcess,
|
|
@@ -66,8 +67,6 @@ import {
|
|
|
66
67
|
claimConnectedMachineSessionBackgroundCommands,
|
|
67
68
|
deferConnectedMachineBackgroundCommandReconciliation,
|
|
68
69
|
recordConnectedMachineBackgroundCommandProof,
|
|
69
|
-
settleClaimedConnectedMachineBackgroundCommand,
|
|
70
|
-
settleSessionBackgroundCommandForRetainedProcess,
|
|
71
70
|
type ConnectedMachineBackgroundCommandClaim,
|
|
72
71
|
type ConnectedMachineBackgroundCommandProof,
|
|
73
72
|
} from "@opengeni/db/session-background-commands";
|
|
@@ -727,6 +726,7 @@ export function createSandboxLeaseActivities(
|
|
|
727
726
|
observability,
|
|
728
727
|
probeRetainedProcess,
|
|
729
728
|
options.inspectHistoricalModalSandbox ?? inspectModalSandboxLifecycle,
|
|
729
|
+
service.bus,
|
|
730
730
|
);
|
|
731
731
|
|
|
732
732
|
try {
|
|
@@ -1107,9 +1107,20 @@ async function reconcileConnectedMachineBackgroundCommands(
|
|
|
1107
1107
|
}
|
|
1108
1108
|
|
|
1109
1109
|
try {
|
|
1110
|
-
|
|
1110
|
+
const settlement = await settleClaimedConnectedMachineBackgroundCommand(db, { claim });
|
|
1111
|
+
if (!settlement.settled) {
|
|
1111
1112
|
throw new Error("Connected command settlement lost its exact claim or proof");
|
|
1112
1113
|
}
|
|
1114
|
+
if (settlement.events.length > 0) {
|
|
1115
|
+
try {
|
|
1116
|
+
await bus.publish(claim.workspaceId, claim.sessionId, settlement.events);
|
|
1117
|
+
} catch (error) {
|
|
1118
|
+
observability.warn("sandbox reaper: connected-command event fanout failed", {
|
|
1119
|
+
commandId: claim.commandId,
|
|
1120
|
+
error: error instanceof Error ? error.message : String(error),
|
|
1121
|
+
});
|
|
1122
|
+
}
|
|
1123
|
+
}
|
|
1113
1124
|
recordConnectedCommandReconciliation(observability, `settled_${proof.outcome}`);
|
|
1114
1125
|
} catch (error) {
|
|
1115
1126
|
recordConnectedCommandReconciliation(observability, "settlement_failed");
|
|
@@ -1226,6 +1237,7 @@ async function reconcileTerminalRetainedProcesses(
|
|
|
1226
1237
|
observability: ActivityServices["observability"],
|
|
1227
1238
|
probe: RetainedProcessProbeFn,
|
|
1228
1239
|
inspectHistoricalModalSandbox: HistoricalModalSandboxLifecycleProbeFn,
|
|
1240
|
+
bus: ActivityServices["bus"],
|
|
1229
1241
|
): Promise<void> {
|
|
1230
1242
|
const claimId = crypto.randomUUID();
|
|
1231
1243
|
let claims: Awaited<ReturnType<typeof claimTerminalRetainedProcesses>>;
|
|
@@ -1444,15 +1456,20 @@ async function reconcileTerminalRetainedProcesses(
|
|
|
1444
1456
|
if (settlement.process.state === "active") {
|
|
1445
1457
|
throw new Error("Retained-process reconciliation returned an active durable process");
|
|
1446
1458
|
}
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1459
|
+
if (settlement.backgroundCommandEvents.length > 0) {
|
|
1460
|
+
try {
|
|
1461
|
+
await bus.publish(
|
|
1462
|
+
process.workspaceId,
|
|
1463
|
+
process.sessionId,
|
|
1464
|
+
settlement.backgroundCommandEvents,
|
|
1465
|
+
);
|
|
1466
|
+
} catch (error) {
|
|
1467
|
+
observability.warn("sandbox reaper: retained-command event fanout failed", {
|
|
1468
|
+
processId: process.id,
|
|
1469
|
+
error: error instanceof Error ? error.message : String(error),
|
|
1470
|
+
});
|
|
1471
|
+
}
|
|
1472
|
+
}
|
|
1456
1473
|
recordRetainedProcessReconciliation(observability, `settled_${proof.outcome}`);
|
|
1457
1474
|
} catch (error) {
|
|
1458
1475
|
recordRetainedProcessReconciliation(observability, "settlement_failed");
|