@opengeni/api-router 2.12.3 → 2.12.4-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/app.js +1 -1
- package/dist/{chunk-552H26YK.js → chunk-4AQMKVQM.js} +53 -27
- package/dist/chunk-4AQMKVQM.js.map +1 -0
- package/dist/index.js +1 -1
- package/dist/sandbox/rematerialize.d.ts +1 -1
- package/package.json +19 -19
- package/src/sandbox/rematerialize.ts +33 -1
- package/dist/chunk-552H26YK.js.map +0 -1
package/dist/app.js
CHANGED
|
@@ -6536,6 +6536,10 @@ import {
|
|
|
6536
6536
|
withoutSandboxProviderIdentity,
|
|
6537
6537
|
WorkspaceArchiveIntegrityError
|
|
6538
6538
|
} from "@opengeni/runtime/sandbox";
|
|
6539
|
+
import {
|
|
6540
|
+
downloadWorkspaceArchiveSpool,
|
|
6541
|
+
WorkspaceArchiveStorageError
|
|
6542
|
+
} from "@opengeni/storage";
|
|
6539
6543
|
function hasWorkspaceArchive(envelope) {
|
|
6540
6544
|
const sessionState = envelope?.sessionState && typeof envelope.sessionState === "object" && !Array.isArray(envelope.sessionState) ? envelope.sessionState : null;
|
|
6541
6545
|
return typeof sessionState?.workspaceArchive === "string" && sessionState.workspaceArchive.length > 0 || parseWorkspaceArchiveObjectRef(sessionState?.workspaceArchiveRef) !== null;
|
|
@@ -6557,6 +6561,10 @@ async function materializeArchiveObjectRef(envelope, objectStorage) {
|
|
|
6557
6561
|
"workspace archive object storage is not configured"
|
|
6558
6562
|
);
|
|
6559
6563
|
}
|
|
6564
|
+
const descriptor = parseWorkspaceArchiveDescriptor(sessionState.workspaceArchiveMeta);
|
|
6565
|
+
if (process.platform === "linux" && descriptor?.version === 1 && descriptor.workspace.projection === "sdk_local_archive_v1") {
|
|
6566
|
+
return envelope;
|
|
6567
|
+
}
|
|
6560
6568
|
return {
|
|
6561
6569
|
...envelope,
|
|
6562
6570
|
sessionState: await inlineWorkspaceArchiveForRestore(
|
|
@@ -6647,6 +6655,24 @@ async function establishApiSandboxSpawner(input) {
|
|
|
6647
6655
|
established = await establishSandboxSessionFromEnvelope(input.settings, hydrateEnvelope, {
|
|
6648
6656
|
sessionId: input.sessionId,
|
|
6649
6657
|
recovery: "create-or-restore",
|
|
6658
|
+
...input.objectStorage ? {
|
|
6659
|
+
loadHostWorkspaceArchive: async (ref) => {
|
|
6660
|
+
try {
|
|
6661
|
+
return await downloadWorkspaceArchiveSpool(input.objectStorage, ref.key, {
|
|
6662
|
+
bytes: ref.bytes,
|
|
6663
|
+
sha256: ref.sha256
|
|
6664
|
+
});
|
|
6665
|
+
} catch (error) {
|
|
6666
|
+
if (error instanceof WorkspaceArchiveStorageError) {
|
|
6667
|
+
throw new WorkspaceArchiveIntegrityError(error.code, error.message, {
|
|
6668
|
+
retryable: error.retryable,
|
|
6669
|
+
cause: error
|
|
6670
|
+
});
|
|
6671
|
+
}
|
|
6672
|
+
throw error;
|
|
6673
|
+
}
|
|
6674
|
+
}
|
|
6675
|
+
} : {},
|
|
6650
6676
|
backendOverride: input.backend,
|
|
6651
6677
|
environment: input.environment,
|
|
6652
6678
|
onSandboxCreated: async (created) => {
|
|
@@ -57084,14 +57110,14 @@ function registerSessionRoutes(app, deps) {
|
|
|
57084
57110
|
message: "durable interactive terminals require a session-home provider lease"
|
|
57085
57111
|
});
|
|
57086
57112
|
}
|
|
57087
|
-
const
|
|
57113
|
+
const process2 = await getRetainedProcess(db, {
|
|
57088
57114
|
workspaceId: ctx.workspaceId,
|
|
57089
57115
|
sessionId: ctx.session.id,
|
|
57090
57116
|
processId: pty.retainedProcessId
|
|
57091
57117
|
});
|
|
57092
|
-
if (!
|
|
57118
|
+
if (!process2 || process2.state !== "active" || process2.ownerActorKind !== "direct" || process2.accountId !== ctx.accountId || process2.leaseId !== pty.leaseId || process2.sandboxGroupId !== pty.sandboxGroupId || process2.parentAdmissionId !== pty.openAdmissionId || process2.leaseEpoch !== pty.leaseEpoch || process2.providerBackend !== pty.providerBackend || process2.providerInstanceId !== pty.providerInstanceId || process2.routeKind !== pty.routeKind || process2.routeTargetId !== pty.routeTargetId || process2.routeEpoch !== pty.routeEpoch || process2.providerSessionId !== pty.execSessionId || // Only a persistable home backend can currently be reconstructed by an
|
|
57093
57119
|
// API request without consulting the mutable active pointer.
|
|
57094
|
-
|
|
57120
|
+
process2.routeTargetId !== null || handle.lease.id !== process2.leaseId || handle.lease.sandboxGroupId !== process2.sandboxGroupId || handle.lease.leaseEpoch !== process2.leaseEpoch || handle.lease.backend !== process2.providerBackend || handle.lease.instanceId !== process2.providerInstanceId) {
|
|
57095
57121
|
throw new HTTPException70(409, {
|
|
57096
57122
|
message: "pty retained-process identity is stale; reopen the terminal"
|
|
57097
57123
|
});
|
|
@@ -57100,28 +57126,28 @@ function registerSessionRoutes(app, deps) {
|
|
|
57100
57126
|
accountId: ctx.accountId,
|
|
57101
57127
|
workspaceId: ctx.workspaceId,
|
|
57102
57128
|
sessionId: ctx.session.id,
|
|
57103
|
-
processId:
|
|
57129
|
+
processId: process2.id
|
|
57104
57130
|
});
|
|
57105
57131
|
handle.routingSession.adoptRetainedProcess({
|
|
57106
57132
|
process: {
|
|
57107
|
-
id:
|
|
57108
|
-
providerSessionId:
|
|
57133
|
+
id: process2.id,
|
|
57134
|
+
providerSessionId: process2.providerSessionId,
|
|
57109
57135
|
...providerCommand ? { providerCommand } : {}
|
|
57110
57136
|
},
|
|
57111
57137
|
backend: {
|
|
57112
57138
|
sandboxId: null,
|
|
57113
|
-
leaseEpoch:
|
|
57114
|
-
providerInstanceId:
|
|
57115
|
-
activeEpoch:
|
|
57139
|
+
leaseEpoch: process2.leaseEpoch,
|
|
57140
|
+
providerInstanceId: process2.providerInstanceId,
|
|
57141
|
+
activeEpoch: process2.routeEpoch
|
|
57116
57142
|
}
|
|
57117
57143
|
});
|
|
57118
|
-
return
|
|
57144
|
+
return process2;
|
|
57119
57145
|
};
|
|
57120
|
-
const emitPtyExited = async (ctx, ptyId,
|
|
57146
|
+
const emitPtyExited = async (ctx, ptyId, process2) => {
|
|
57121
57147
|
const exited = {
|
|
57122
57148
|
ptyId,
|
|
57123
|
-
exitCode:
|
|
57124
|
-
reason:
|
|
57149
|
+
exitCode: process2.exitCode,
|
|
57150
|
+
reason: process2.state === "exited" ? "exit" : "lost"
|
|
57125
57151
|
};
|
|
57126
57152
|
await appendAndPublishEvents4(db, bus, ctx.workspaceId, ctx.session.id, [
|
|
57127
57153
|
{ type: "terminal.pty.exited", payload: exited }
|
|
@@ -60427,12 +60453,12 @@ function registerSessionRoutes(app, deps) {
|
|
|
60427
60453
|
const opened = await service.ptyOpen(req, ptyId);
|
|
60428
60454
|
const execSessionId = opened.execSessionId;
|
|
60429
60455
|
const retained = execSessionId === null ? null : handle.routingSession.retainedProcessIdentity(execSessionId);
|
|
60430
|
-
const
|
|
60456
|
+
const process2 = retained ? await getRetainedProcess(db, {
|
|
60431
60457
|
workspaceId: ctx.workspaceId,
|
|
60432
60458
|
sessionId: ctx.session.id,
|
|
60433
60459
|
processId: retained.id
|
|
60434
60460
|
}) : null;
|
|
60435
|
-
if (execSessionId === null || !retained || !
|
|
60461
|
+
if (execSessionId === null || !retained || !process2 || process2.state !== "active" || process2.ownerActorKind !== "direct" || process2.providerSessionId !== execSessionId || process2.routeTargetId !== null || process2.leaseId !== handle.lease.id || process2.sandboxGroupId !== handle.lease.sandboxGroupId || process2.leaseEpoch !== handle.lease.leaseEpoch || process2.providerBackend !== handle.lease.backend || process2.providerInstanceId !== handle.lease.instanceId) {
|
|
60436
60462
|
if (execSessionId !== null && handle.routingSession.hasRetainedProcess(execSessionId)) {
|
|
60437
60463
|
await drainOpenedPty(handle, execSessionId);
|
|
60438
60464
|
}
|
|
@@ -60441,17 +60467,17 @@ function registerSessionRoutes(app, deps) {
|
|
|
60441
60467
|
});
|
|
60442
60468
|
}
|
|
60443
60469
|
const identity = {
|
|
60444
|
-
leaseId:
|
|
60445
|
-
sandboxGroupId:
|
|
60446
|
-
retainedProcessId:
|
|
60447
|
-
openAdmissionId:
|
|
60448
|
-
execSessionId:
|
|
60449
|
-
leaseEpoch:
|
|
60450
|
-
providerBackend:
|
|
60451
|
-
providerInstanceId:
|
|
60452
|
-
routeKind:
|
|
60453
|
-
routeTargetId:
|
|
60454
|
-
routeEpoch:
|
|
60470
|
+
leaseId: process2.leaseId,
|
|
60471
|
+
sandboxGroupId: process2.sandboxGroupId,
|
|
60472
|
+
retainedProcessId: process2.id,
|
|
60473
|
+
openAdmissionId: process2.parentAdmissionId,
|
|
60474
|
+
execSessionId: process2.providerSessionId,
|
|
60475
|
+
leaseEpoch: process2.leaseEpoch,
|
|
60476
|
+
providerBackend: process2.providerBackend,
|
|
60477
|
+
providerInstanceId: process2.providerInstanceId,
|
|
60478
|
+
routeKind: process2.routeKind,
|
|
60479
|
+
routeTargetId: process2.routeTargetId,
|
|
60480
|
+
routeEpoch: process2.routeEpoch
|
|
60455
60481
|
};
|
|
60456
60482
|
try {
|
|
60457
60483
|
await insertPtySession(db, {
|
|
@@ -76554,4 +76580,4 @@ export {
|
|
|
76554
76580
|
withDefaultEnabledCapabilityMcpTools,
|
|
76555
76581
|
workflowIdForSession4 as workflowIdForSession
|
|
76556
76582
|
};
|
|
76557
|
-
//# sourceMappingURL=chunk-
|
|
76583
|
+
//# sourceMappingURL=chunk-4AQMKVQM.js.map
|