@opengeni/worker-bundle 0.27.3 → 0.28.3-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/model-usage.d.ts +1 -1
- package/dist/activities/mcp-credentials.d.ts +3 -1
- package/dist/activities/sandbox-lease.d.ts +4 -4
- package/dist/activities/workspace-capture.d.ts +12 -1
- package/dist/{activities-control-WZRFEIJH.js → activities-control-JUBMDBDZ.js} +58 -73
- package/dist/activities-control-JUBMDBDZ.js.map +1 -0
- package/dist/{activities-turn-V7J34ZOF.js → activities-turn-I2ZKGZE6.js} +268 -187
- package/dist/activities-turn-I2ZKGZE6.js.map +1 -0
- package/dist/{chunk-BARTLVBK.js → chunk-A4XQWVZK.js} +25 -25
- package/dist/chunk-A4XQWVZK.js.map +1 -0
- package/dist/{chunk-C54VDT6I.js → chunk-ZNIKZQMN.js} +148 -111
- package/dist/chunk-ZNIKZQMN.js.map +1 -0
- package/dist/index.js +2 -2
- package/dist/observability-metrics.d.ts +12 -4
- package/dist/sandbox-archive-storage.d.ts +15 -3
- package/dist/sandbox-resume.d.ts +1 -1
- package/package.json +17 -17
- package/src/activities/agent-turn/agent-build.ts +30 -1
- package/src/activities/agent-turn/claim.ts +3 -3
- package/src/activities/agent-turn/finalization.ts +62 -41
- package/src/activities/agent-turn/model-usage.ts +10 -1
- package/src/activities/agent-turn/skill-read.ts +2 -21
- package/src/activities/agent-turn/stream-attempt.ts +3 -2
- package/src/activities/agent-turn/tool-environment.ts +52 -10
- package/src/activities/goals.ts +2 -0
- package/src/activities/mcp-credentials.ts +42 -2
- package/src/activities/sandbox-lease.ts +64 -71
- package/src/activities/scheduled-tasks.ts +8 -6
- package/src/activities/workspace-capture.ts +148 -126
- package/src/observability-metrics.ts +28 -24
- package/src/pr-review-credentials.ts +2 -0
- package/src/sandbox-archive-storage.ts +82 -18
- package/src/sandbox-resume.ts +79 -63
- package/dist/activities-control-WZRFEIJH.js.map +0 -1
- package/dist/activities-turn-V7J34ZOF.js.map +0 -1
- package/dist/chunk-BARTLVBK.js.map +0 -1
- package/dist/chunk-C54VDT6I.js.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
observabilityEventLogger
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-A4XQWVZK.js";
|
|
4
4
|
|
|
5
5
|
// src/activity-services.ts
|
|
6
6
|
import { dbSearchPath, getSettings, resolveNatsControlPlaneAuth } from "@opengeni/config";
|
|
@@ -246,6 +246,7 @@ function exactRequestedRepositories(refs, credentialBindingId, snapshots) {
|
|
|
246
246
|
// src/pr-review-credentials.ts
|
|
247
247
|
import { environmentsEncryptionKeyBytes } from "@opengeni/config";
|
|
248
248
|
import { prReviewRegistrationIdFromCredentialBinding } from "@opengeni/core";
|
|
249
|
+
import { createRemoteMcpCredentialsPort } from "@opengeni/core/remote-mcp-credentials";
|
|
249
250
|
import { decryptVariableSetValue, resolvePrReviewGitCredential } from "@opengeni/db";
|
|
250
251
|
import {
|
|
251
252
|
createGitHubAppInstallationTokenWithExpiry,
|
|
@@ -253,6 +254,7 @@ import {
|
|
|
253
254
|
} from "@opengeni/github";
|
|
254
255
|
function createStandaloneConnectionCredentialsPort(settings, db) {
|
|
255
256
|
return {
|
|
257
|
+
...createRemoteMcpCredentialsPort(settings),
|
|
256
258
|
gitCredentials: async (request) => await resolveStandaloneGitCredentials(settings, db, request)
|
|
257
259
|
};
|
|
258
260
|
}
|
|
@@ -1327,6 +1329,8 @@ function goalContinuationPrompt(_goal, _autoContinuation, _cap, options = {}) {
|
|
|
1327
1329
|
"Continuation behavior:",
|
|
1328
1330
|
"- This goal persists across turns. A runtime boundary can end one turn without shrinking the objective; the next continuation resumes the same full objective.",
|
|
1329
1331
|
"- Keep working until the requested end state is true and verified. Do not end the turn merely because one useful action completed, and do not redefine success around a smaller or easier task.",
|
|
1332
|
+
"- An incomplete-status report is not a substitute for continuing the work. If the remaining problem can be investigated or addressed within your current authority, continue that work in this turn rather than returning another equivalent status-only final.",
|
|
1333
|
+
"- Distinguish unfinished work from a blocker that actually requires human input or external change; use the existing waiting and blocked audits only when their conditions hold.",
|
|
1330
1334
|
"- Temporary rough edges are acceptable while the work is moving in the right direction. Completion still requires the requested end state to be true and verified.",
|
|
1331
1335
|
"",
|
|
1332
1336
|
"Work from evidence:",
|
|
@@ -1642,6 +1646,8 @@ async function nextStreamEvent(iterator, context) {
|
|
|
1642
1646
|
}
|
|
1643
1647
|
|
|
1644
1648
|
// src/sandbox-archive-storage.ts
|
|
1649
|
+
import { uploadWorkspaceArchiveSpool } from "@opengeni/storage";
|
|
1650
|
+
import { randomUUID as randomUUID2 } from "crypto";
|
|
1645
1651
|
import {
|
|
1646
1652
|
parseWorkspaceArchiveObjectRef,
|
|
1647
1653
|
workspaceArchiveObjectKey
|
|
@@ -1653,47 +1659,74 @@ var WorkspaceArchiveObjectStorageRequiredError = class extends Error {
|
|
|
1653
1659
|
this.name = "WorkspaceArchiveObjectStorageRequiredError";
|
|
1654
1660
|
}
|
|
1655
1661
|
};
|
|
1656
|
-
function collectWorkspaceArchiveObjectKeys(resumeState) {
|
|
1657
|
-
const sessionState = resumeState?.sessionState && typeof resumeState.sessionState === "object" ? resumeState.sessionState : null;
|
|
1658
|
-
const keys = /* @__PURE__ */ new Set();
|
|
1659
|
-
for (const value of [sessionState?.workspaceArchiveRef, sessionState?.workspaceArchivePrevRef]) {
|
|
1660
|
-
const ref = parseWorkspaceArchiveObjectRef(value);
|
|
1661
|
-
if (ref) keys.add(ref.key);
|
|
1662
|
-
}
|
|
1663
|
-
return keys;
|
|
1664
|
-
}
|
|
1665
1662
|
async function putTarWorkspaceArchiveObject(input) {
|
|
1666
|
-
|
|
1663
|
+
const descriptor = structuredClone(input.archive.descriptor);
|
|
1664
|
+
if (descriptor.version !== 1) {
|
|
1667
1665
|
throw new Error("Object-storage workspace archives are portable tar only");
|
|
1668
1666
|
}
|
|
1669
1667
|
const key = workspaceArchiveObjectKey({
|
|
1670
1668
|
accountId: input.accountId,
|
|
1671
1669
|
workspaceId: input.workspaceId,
|
|
1672
1670
|
sandboxGroupId: input.sandboxGroupId,
|
|
1673
|
-
revision:
|
|
1674
|
-
|
|
1675
|
-
await input.objectStorage.putObject({
|
|
1676
|
-
key,
|
|
1677
|
-
contentType: "application/x-tar",
|
|
1678
|
-
body: input.archive.bytes,
|
|
1679
|
-
sha256: input.archive.descriptor.archiveSha256
|
|
1671
|
+
revision: descriptor.revision,
|
|
1672
|
+
uploadId: randomUUID2()
|
|
1680
1673
|
});
|
|
1674
|
+
const archive = input.archive;
|
|
1675
|
+
if ("spool" in archive) {
|
|
1676
|
+
if (archive.spool.byteSize !== descriptor.archiveBytes || archive.spool.sha256 !== descriptor.archiveSha256) {
|
|
1677
|
+
throw new Error("Workspace archive spool does not match its verified descriptor");
|
|
1678
|
+
}
|
|
1679
|
+
}
|
|
1680
|
+
const source = "spool" in archive ? archive.spool : {
|
|
1681
|
+
path: "",
|
|
1682
|
+
byteSize: archive.bytes.byteLength,
|
|
1683
|
+
sha256: descriptor.archiveSha256,
|
|
1684
|
+
async *open() {
|
|
1685
|
+
for (let offset = 0; offset < archive.bytes.length; offset += 1024 * 1024)
|
|
1686
|
+
yield archive.bytes.subarray(offset, offset + 1024 * 1024);
|
|
1687
|
+
},
|
|
1688
|
+
async dispose() {
|
|
1689
|
+
}
|
|
1690
|
+
};
|
|
1691
|
+
try {
|
|
1692
|
+
await uploadWorkspaceArchiveSpool(input.objectStorage, key, {
|
|
1693
|
+
...source,
|
|
1694
|
+
byteSize: descriptor.archiveBytes,
|
|
1695
|
+
sha256: descriptor.archiveSha256,
|
|
1696
|
+
open: source.open.bind(source)
|
|
1697
|
+
});
|
|
1698
|
+
} catch (error) {
|
|
1699
|
+
await input.objectStorage.deleteObject(key).catch(() => void 0);
|
|
1700
|
+
throw error;
|
|
1701
|
+
}
|
|
1681
1702
|
return {
|
|
1682
1703
|
schema: "sandbox_archive_object_v1",
|
|
1683
1704
|
key,
|
|
1684
|
-
sha256:
|
|
1685
|
-
bytes:
|
|
1705
|
+
sha256: descriptor.archiveSha256,
|
|
1706
|
+
bytes: descriptor.archiveBytes,
|
|
1686
1707
|
backend: input.objectStorage.backend
|
|
1687
1708
|
};
|
|
1688
1709
|
}
|
|
1710
|
+
async function persistWorkspaceArchiveCandidate(input) {
|
|
1711
|
+
const objectStorage = input.objectStorage;
|
|
1712
|
+
const ref = input.ref ? { ...input.ref } : void 0;
|
|
1713
|
+
const result = await input.persist();
|
|
1714
|
+
if (objectStorage && ref && result.candidateDisposition === "unused") {
|
|
1715
|
+
await deleteUnpublishedWorkspaceArchiveObject(objectStorage, ref);
|
|
1716
|
+
}
|
|
1717
|
+
return result;
|
|
1718
|
+
}
|
|
1689
1719
|
async function putVersion1TarArchiveOrInline(input) {
|
|
1690
1720
|
if (input.archive.descriptor.version !== 1) {
|
|
1721
|
+
if ("spool" in input.archive) throw new Error("Native snapshots cannot use a portable spool");
|
|
1691
1722
|
return { workspaceArchive: input.archive.base64 };
|
|
1692
1723
|
}
|
|
1693
1724
|
if (input.backend === "opensandbox" && !input.objectStorage) {
|
|
1694
1725
|
throw new WorkspaceArchiveObjectStorageRequiredError("opensandbox");
|
|
1695
1726
|
}
|
|
1696
1727
|
if (!input.objectStorage) {
|
|
1728
|
+
if ("spool" in input.archive)
|
|
1729
|
+
throw new WorkspaceArchiveObjectStorageRequiredError(input.backend);
|
|
1697
1730
|
return { workspaceArchive: input.archive.base64 };
|
|
1698
1731
|
}
|
|
1699
1732
|
try {
|
|
@@ -1702,7 +1735,7 @@ async function putVersion1TarArchiveOrInline(input) {
|
|
|
1702
1735
|
accountId: input.accountId,
|
|
1703
1736
|
workspaceId: input.workspaceId,
|
|
1704
1737
|
sandboxGroupId: input.sandboxGroupId,
|
|
1705
|
-
archive:
|
|
1738
|
+
archive: input.archive
|
|
1706
1739
|
});
|
|
1707
1740
|
try {
|
|
1708
1741
|
input.metrics?.onWorkspaceArchiveObject?.({
|
|
@@ -1743,11 +1776,6 @@ async function deleteUnpublishedWorkspaceArchiveObject(objectStorage, ref, metri
|
|
|
1743
1776
|
console.error("unpublished workspace archive object delete failed", { key: ref.key });
|
|
1744
1777
|
}
|
|
1745
1778
|
}
|
|
1746
|
-
async function deleteWorkspaceArchiveObjectKeys(objectStorage, keys) {
|
|
1747
|
-
for (const key of keys) {
|
|
1748
|
-
await objectStorage.deleteObject(key);
|
|
1749
|
-
}
|
|
1750
|
-
}
|
|
1751
1779
|
|
|
1752
1780
|
// src/sandbox-routing.ts
|
|
1753
1781
|
import { sandboxLifecycleTransitionWaitMs as sandboxLifecycleTransitionWaitMs2 } from "@opengeni/config";
|
|
@@ -1802,7 +1830,7 @@ import {
|
|
|
1802
1830
|
sandboxArchiveCaptureTimeoutMs,
|
|
1803
1831
|
sandboxLifecycleTransitionWaitMs
|
|
1804
1832
|
} from "@opengeni/config";
|
|
1805
|
-
import { randomUUID as
|
|
1833
|
+
import { randomUUID as randomUUID3 } from "crypto";
|
|
1806
1834
|
import {
|
|
1807
1835
|
acquireLease,
|
|
1808
1836
|
adoptLegacyModalCheckpointArtifact,
|
|
@@ -1829,7 +1857,8 @@ import {
|
|
|
1829
1857
|
SandboxLeaseTransitionError
|
|
1830
1858
|
} from "@opengeni/db";
|
|
1831
1859
|
import {
|
|
1832
|
-
|
|
1860
|
+
captureWorkspaceArchiveForStorage,
|
|
1861
|
+
disposeWorkspaceArchive,
|
|
1833
1862
|
describeLegacyNativeSnapshotArchive,
|
|
1834
1863
|
inlineWorkspaceArchiveForRestore,
|
|
1835
1864
|
MODAL_EXEC_READINESS_TIMEOUT_MS,
|
|
@@ -1850,6 +1879,10 @@ import {
|
|
|
1850
1879
|
verifySandboxExecReadiness,
|
|
1851
1880
|
withoutSandboxProviderIdentity
|
|
1852
1881
|
} from "@opengeni/runtime";
|
|
1882
|
+
import {
|
|
1883
|
+
downloadWorkspaceArchiveSpool,
|
|
1884
|
+
WorkspaceArchiveStorageError
|
|
1885
|
+
} from "@opengeni/storage";
|
|
1853
1886
|
import { parseWorkspaceArchiveObjectRef as parseWorkspaceArchiveObjectRef2 } from "@opengeni/contracts";
|
|
1854
1887
|
function sandboxLeaseHolderIdForAttempt(attemptId) {
|
|
1855
1888
|
const normalized = attemptId.trim();
|
|
@@ -2105,6 +2138,10 @@ async function materializeSpawnEnvelopeArchive(envelope, objectStorage) {
|
|
|
2105
2138
|
"workspace archive object storage is not configured"
|
|
2106
2139
|
);
|
|
2107
2140
|
}
|
|
2141
|
+
const descriptor = parseWorkspaceArchiveDescriptor(sessionState.workspaceArchiveMeta);
|
|
2142
|
+
if (process.platform === "linux" && descriptor?.version === 1 && descriptor.workspace.projection === "sdk_local_archive_v1") {
|
|
2143
|
+
return envelope;
|
|
2144
|
+
}
|
|
2108
2145
|
return {
|
|
2109
2146
|
...record,
|
|
2110
2147
|
sessionState: await inlineWorkspaceArchiveForRestore(
|
|
@@ -2202,7 +2239,7 @@ async function persistWarmWorkspaceSnapshot(services, ids, session, leaseEpoch,
|
|
|
2202
2239
|
const nativeModalPersistence = workspacePersistence === "snapshot_filesystem" || workspacePersistence === "snapshot_directory";
|
|
2203
2240
|
const checkpointBinding = nativeModalPersistence ? await resolveModalCheckpointBindingBeforeCapture(settings, persistable, signal) : null;
|
|
2204
2241
|
if (signal?.aborted) return false;
|
|
2205
|
-
const captureId =
|
|
2242
|
+
const captureId = randomUUID3();
|
|
2206
2243
|
const captureTimeoutMs = sandboxArchiveCaptureTimeoutMs(settings);
|
|
2207
2244
|
const claimed = await claimWorkspaceArchiveCapture(db, {
|
|
2208
2245
|
accountId: ids.accountId,
|
|
@@ -2235,7 +2272,7 @@ async function persistWarmWorkspaceSnapshot(services, ids, session, leaseEpoch,
|
|
|
2235
2272
|
let timeout;
|
|
2236
2273
|
const capturedAtMs = Date.now();
|
|
2237
2274
|
const registerCandidate = async (archive) => {
|
|
2238
|
-
if (archive.descriptor.version !== 2 || archive.descriptor.provider !== "modal_snapshot_filesystem" && archive.descriptor.provider !== "modal_snapshot_directory") {
|
|
2275
|
+
if (archive.kind === "host_spool" || archive.descriptor.version !== 2 || archive.descriptor.provider !== "modal_snapshot_filesystem" && archive.descriptor.provider !== "modal_snapshot_directory") {
|
|
2239
2276
|
return null;
|
|
2240
2277
|
}
|
|
2241
2278
|
if (!checkpointBinding) {
|
|
@@ -2264,80 +2301,64 @@ async function persistWarmWorkspaceSnapshot(services, ids, session, leaseEpoch,
|
|
|
2264
2301
|
}).catch(() => void 0);
|
|
2265
2302
|
};
|
|
2266
2303
|
const captureAndPublish = (async () => {
|
|
2304
|
+
let archive;
|
|
2267
2305
|
let candidate = null;
|
|
2268
|
-
let
|
|
2306
|
+
let publicationAttempted = false;
|
|
2269
2307
|
try {
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2308
|
+
archive = await captureWorkspaceArchiveForStorage(
|
|
2309
|
+
session,
|
|
2310
|
+
capturedAtMs,
|
|
2311
|
+
{
|
|
2312
|
+
requestId: claimed.claim.providerRequestId,
|
|
2313
|
+
strategy: capturePolicy.strategy
|
|
2314
|
+
},
|
|
2315
|
+
Boolean(services.objectStorage)
|
|
2278
2316
|
);
|
|
2317
|
+
candidate = await registerCandidate(archive);
|
|
2318
|
+
const archiveDescriptor = archive.descriptor;
|
|
2279
2319
|
const published = await putVersion1TarArchiveOrInline({
|
|
2280
2320
|
backend: lease.backend,
|
|
2281
2321
|
objectStorage: services.objectStorage,
|
|
2282
2322
|
accountId: ids.accountId,
|
|
2283
2323
|
workspaceId: ids.workspaceId,
|
|
2284
2324
|
sandboxGroupId: ids.sandboxGroupId,
|
|
2285
|
-
archive
|
|
2286
|
-
bytes: archive.bytes,
|
|
2287
|
-
descriptor: archive.descriptor,
|
|
2288
|
-
base64: archive.base64
|
|
2289
|
-
},
|
|
2325
|
+
archive,
|
|
2290
2326
|
...services.sandboxMetrics ? { metrics: services.sandboxMetrics } : {}
|
|
2291
2327
|
});
|
|
2292
|
-
|
|
2293
|
-
const { wrote } = await
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2328
|
+
publicationAttempted = true;
|
|
2329
|
+
const { wrote } = await persistWorkspaceArchiveCandidate({
|
|
2330
|
+
...services.objectStorage ? { objectStorage: services.objectStorage } : {},
|
|
2331
|
+
...published.workspaceArchiveRef ? { ref: published.workspaceArchiveRef } : {},
|
|
2332
|
+
persist: () => persistWarmSnapshot(db, {
|
|
2333
|
+
accountId: ids.accountId,
|
|
2334
|
+
workspaceId: ids.workspaceId,
|
|
2335
|
+
sessionId: ids.sessionId,
|
|
2336
|
+
turnId: ids.turnId,
|
|
2337
|
+
attemptId: ids.attemptId,
|
|
2338
|
+
sandboxGroupId: ids.sandboxGroupId,
|
|
2339
|
+
expectedEpoch: leaseEpoch,
|
|
2340
|
+
expectedInstanceId: instanceId,
|
|
2341
|
+
expectedWorkspaceGeneration: claimed.claim.workspaceGeneration,
|
|
2342
|
+
captureId,
|
|
2343
|
+
workspaceArchiveMeta: archiveDescriptor,
|
|
2344
|
+
...published,
|
|
2345
|
+
checkpointArtifactId: candidate?.id ?? null,
|
|
2346
|
+
minIntervalMs: force ? 0 : intervalMs,
|
|
2347
|
+
capturedAtMs
|
|
2348
|
+
})
|
|
2309
2349
|
});
|
|
2310
|
-
if (published.workspaceArchiveRef && services.objectStorage) {
|
|
2311
|
-
if (!wrote) {
|
|
2312
|
-
await deleteUnpublishedWorkspaceArchiveObject(
|
|
2313
|
-
services.objectStorage,
|
|
2314
|
-
published.workspaceArchiveRef,
|
|
2315
|
-
services.sandboxMetrics
|
|
2316
|
-
);
|
|
2317
|
-
} else {
|
|
2318
|
-
const afterLease = await readLease(db, ids.workspaceId, ids.sandboxGroupId);
|
|
2319
|
-
const afterKeys = collectWorkspaceArchiveObjectKeys(
|
|
2320
|
-
afterLease?.resumeState ?? null
|
|
2321
|
-
);
|
|
2322
|
-
await deleteWorkspaceArchiveObjectKeys(
|
|
2323
|
-
services.objectStorage,
|
|
2324
|
-
[...priorKeys].filter((key) => !afterKeys.has(key))
|
|
2325
|
-
).catch(() => void 0);
|
|
2326
|
-
}
|
|
2327
|
-
}
|
|
2328
2350
|
if (!wrote && candidate) {
|
|
2329
2351
|
await abandonCandidate(candidate.id, "snapshot_publication_fenced");
|
|
2330
2352
|
}
|
|
2331
2353
|
return wrote;
|
|
2332
2354
|
} catch (error) {
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
workspaceArchiveRef,
|
|
2336
|
-
services.sandboxMetrics
|
|
2337
|
-
);
|
|
2338
|
-
if (candidate) await abandonCandidate(candidate.id, "snapshot_capture_failed");
|
|
2355
|
+
if (candidate && !publicationAttempted)
|
|
2356
|
+
await abandonCandidate(candidate.id, "snapshot_capture_failed");
|
|
2339
2357
|
throw error;
|
|
2340
2358
|
} finally {
|
|
2359
|
+
await disposeWorkspaceArchive(archive).catch(() => {
|
|
2360
|
+
console.warn("workspace archive spool cleanup failed");
|
|
2361
|
+
});
|
|
2341
2362
|
await releaseWorkspaceArchiveCapture(db, {
|
|
2342
2363
|
accountId: ids.accountId,
|
|
2343
2364
|
workspaceId: ids.workspaceId,
|
|
@@ -2677,6 +2698,24 @@ async function resumeBoxForTurn(services, ids, kind, holderId) {
|
|
|
2677
2698
|
const established = await establishSandboxSessionFromEnvelope(settings, hydrateEnvelope, {
|
|
2678
2699
|
sessionId: ids.sessionId,
|
|
2679
2700
|
recovery: "create-or-restore",
|
|
2701
|
+
...services.objectStorage ? {
|
|
2702
|
+
loadHostWorkspaceArchive: async (ref) => {
|
|
2703
|
+
try {
|
|
2704
|
+
return await downloadWorkspaceArchiveSpool(services.objectStorage, ref.key, {
|
|
2705
|
+
bytes: ref.bytes,
|
|
2706
|
+
sha256: ref.sha256
|
|
2707
|
+
});
|
|
2708
|
+
} catch (error) {
|
|
2709
|
+
if (error instanceof WorkspaceArchiveStorageError) {
|
|
2710
|
+
throw new WorkspaceArchiveIntegrityError(error.code, error.message, {
|
|
2711
|
+
retryable: error.retryable,
|
|
2712
|
+
cause: error
|
|
2713
|
+
});
|
|
2714
|
+
}
|
|
2715
|
+
throw error;
|
|
2716
|
+
}
|
|
2717
|
+
}
|
|
2718
|
+
} : {},
|
|
2680
2719
|
backendOverride: ids.backend,
|
|
2681
2720
|
...ids.environment ? { environment: ids.environment } : {},
|
|
2682
2721
|
...services.sandboxMetrics ? { metrics: services.sandboxMetrics } : {},
|
|
@@ -3255,11 +3294,11 @@ function afterPersistableHomeMutation(services, ids, home) {
|
|
|
3255
3294
|
function beforeRetainedProcessMutation(services, ids) {
|
|
3256
3295
|
const fence = ids.workspaceMutationFence;
|
|
3257
3296
|
if (!fence) return void 0;
|
|
3258
|
-
return async ({ op, process }) => await advanceWorkspaceGenerationForRetainedProcess(services.db, {
|
|
3297
|
+
return async ({ op, process: process2 }) => await advanceWorkspaceGenerationForRetainedProcess(services.db, {
|
|
3259
3298
|
accountId: fence.accountId,
|
|
3260
3299
|
workspaceId: ids.workspaceId,
|
|
3261
3300
|
sessionId: ids.sessionId,
|
|
3262
|
-
processId:
|
|
3301
|
+
processId: process2.id,
|
|
3263
3302
|
operation: op,
|
|
3264
3303
|
captureWaitMs: sandboxLifecycleTransitionWaitMs2(services.settings),
|
|
3265
3304
|
...services.waitSignal ? { waitSignal: services.waitSignal } : {}
|
|
@@ -3268,7 +3307,7 @@ function beforeRetainedProcessMutation(services, ids) {
|
|
|
3268
3307
|
function afterRetainedProcessMutation(services, ids) {
|
|
3269
3308
|
const fence = ids.workspaceMutationFence;
|
|
3270
3309
|
if (!fence) return void 0;
|
|
3271
|
-
return async ({ op, process, admission, outcome }) => {
|
|
3310
|
+
return async ({ op, process: process2, admission, outcome }) => {
|
|
3272
3311
|
if (!admission || typeof admission !== "object" || typeof admission.id !== "string" || typeof admission.workspaceGeneration !== "number") {
|
|
3273
3312
|
throw new Error("Retained-process mutation settlement lacked its exact admission");
|
|
3274
3313
|
}
|
|
@@ -3276,7 +3315,7 @@ function afterRetainedProcessMutation(services, ids) {
|
|
|
3276
3315
|
accountId: fence.accountId,
|
|
3277
3316
|
workspaceId: ids.workspaceId,
|
|
3278
3317
|
sessionId: ids.sessionId,
|
|
3279
|
-
processId:
|
|
3318
|
+
processId: process2.id,
|
|
3280
3319
|
admission,
|
|
3281
3320
|
operation: op,
|
|
3282
3321
|
outcome
|
|
@@ -3302,7 +3341,7 @@ function captureRetainedProcessOutputForTurn(services, ids) {
|
|
|
3302
3341
|
const accountId = ids.workspaceMutationFence?.accountId;
|
|
3303
3342
|
if (!accountId) return void 0;
|
|
3304
3343
|
return async ({
|
|
3305
|
-
process,
|
|
3344
|
+
process: process2,
|
|
3306
3345
|
chunkId,
|
|
3307
3346
|
chunk,
|
|
3308
3347
|
stream,
|
|
@@ -3312,7 +3351,7 @@ function captureRetainedProcessOutputForTurn(services, ids) {
|
|
|
3312
3351
|
accountId,
|
|
3313
3352
|
workspaceId: ids.workspaceId,
|
|
3314
3353
|
sessionId: ids.sessionId,
|
|
3315
|
-
commandId:
|
|
3354
|
+
commandId: process2.id,
|
|
3316
3355
|
chunkId,
|
|
3317
3356
|
chunk,
|
|
3318
3357
|
stream,
|
|
@@ -3325,32 +3364,32 @@ function captureRetainedProcessOutputForTurn(services, ids) {
|
|
|
3325
3364
|
function observeRetainedProcessTerminalForTurn(services, ids) {
|
|
3326
3365
|
const fence = ids.workspaceMutationFence;
|
|
3327
3366
|
if (!fence) return void 0;
|
|
3328
|
-
return async ({ process }) => {
|
|
3367
|
+
return async ({ process: process2 }) => {
|
|
3329
3368
|
await observeSessionBackgroundCommandCompletion(services.db, {
|
|
3330
3369
|
accountId: fence.accountId,
|
|
3331
3370
|
workspaceId: ids.workspaceId,
|
|
3332
3371
|
sessionId: ids.sessionId,
|
|
3333
|
-
commandId:
|
|
3372
|
+
commandId: process2.id
|
|
3334
3373
|
});
|
|
3335
3374
|
};
|
|
3336
3375
|
}
|
|
3337
3376
|
function settleRetainedProcessForTurn(services, ids) {
|
|
3338
3377
|
const fence = ids.workspaceMutationFence;
|
|
3339
3378
|
if (!fence) return void 0;
|
|
3340
|
-
return async ({ backend, process, proof }) => {
|
|
3379
|
+
return async ({ backend, process: process2, proof }) => {
|
|
3341
3380
|
const durable = await getRetainedProcess(services.db, {
|
|
3342
3381
|
workspaceId: ids.workspaceId,
|
|
3343
3382
|
sessionId: ids.sessionId,
|
|
3344
|
-
processId:
|
|
3383
|
+
processId: process2.id
|
|
3345
3384
|
});
|
|
3346
|
-
if (!durable || durable.providerSessionId !==
|
|
3385
|
+
if (!durable || durable.providerSessionId !== process2.providerSessionId || durable.providerBackend !== backend.kind || durable.providerInstanceId !== backend.providerInstanceId || durable.leaseEpoch !== backend.leaseEpoch || durable.routeKind !== (backend.sandboxId === null ? "home" : "active") || durable.routeTargetId !== backend.sandboxId || durable.routeEpoch !== backend.activeEpoch) {
|
|
3347
3386
|
throw new Error("Retained-process settlement lost its exact durable backend identity");
|
|
3348
3387
|
}
|
|
3349
3388
|
const settlement = await settleRetainedProcess(services.db, {
|
|
3350
3389
|
accountId: fence.accountId,
|
|
3351
3390
|
workspaceId: ids.workspaceId,
|
|
3352
3391
|
sessionId: ids.sessionId,
|
|
3353
|
-
processId:
|
|
3392
|
+
processId: process2.id,
|
|
3354
3393
|
expected: retainedProcessSettlementIdentity(durable),
|
|
3355
3394
|
outcome: proof.outcome,
|
|
3356
3395
|
exitCode: proof.exitCode,
|
|
@@ -3368,13 +3407,13 @@ function settleRetainedProcessForTurn(services, ids) {
|
|
|
3368
3407
|
function adoptRetainedProcessAsBackgroundCommandForTurn(services, ids) {
|
|
3369
3408
|
const fence = ids.workspaceMutationFence;
|
|
3370
3409
|
if (!fence) return void 0;
|
|
3371
|
-
return async ({ backend, process }) => {
|
|
3410
|
+
return async ({ backend, process: process2 }) => {
|
|
3372
3411
|
const durable = await getRetainedProcess(services.db, {
|
|
3373
3412
|
workspaceId: ids.workspaceId,
|
|
3374
3413
|
sessionId: ids.sessionId,
|
|
3375
|
-
processId:
|
|
3414
|
+
processId: process2.id
|
|
3376
3415
|
});
|
|
3377
|
-
if (!durable || durable.providerSessionId !==
|
|
3416
|
+
if (!durable || durable.providerSessionId !== process2.providerSessionId || durable.providerBackend !== backend.kind || durable.providerInstanceId !== backend.providerInstanceId || durable.leaseEpoch !== backend.leaseEpoch || durable.routeKind !== (backend.sandboxId === null ? "home" : "active") || durable.routeTargetId !== backend.sandboxId || durable.routeEpoch !== backend.activeEpoch) {
|
|
3378
3417
|
throw new Error("Background command adoption lost its exact retained-process identity");
|
|
3379
3418
|
}
|
|
3380
3419
|
await adoptManagedSessionBackgroundCommand(services.db, {
|
|
@@ -3384,7 +3423,7 @@ function adoptRetainedProcessAsBackgroundCommandForTurn(services, ids) {
|
|
|
3384
3423
|
turnId: fence.turnId,
|
|
3385
3424
|
executionGeneration: fence.executionGeneration,
|
|
3386
3425
|
attemptId: fence.attemptId,
|
|
3387
|
-
processId:
|
|
3426
|
+
processId: process2.id,
|
|
3388
3427
|
expected: retainedProcessSettlementIdentity(durable),
|
|
3389
3428
|
command: "execCommand"
|
|
3390
3429
|
});
|
|
@@ -3561,11 +3600,11 @@ function wrapTurnBoxWithRouting(services, ids, established) {
|
|
|
3561
3600
|
...services.onSandboxOperation ? { onOperation: services.onSandboxOperation } : {},
|
|
3562
3601
|
providerCommandHandle: admittedCommandHandle,
|
|
3563
3602
|
...ids.workspaceMutationFence ? {
|
|
3564
|
-
providerCommandPersistence: (
|
|
3603
|
+
providerCommandPersistence: (process2) => retainedProviderCommandPersistence(db, {
|
|
3565
3604
|
accountId: ids.workspaceMutationFence.accountId,
|
|
3566
3605
|
workspaceId: ids.workspaceId,
|
|
3567
3606
|
sessionId: ids.sessionId,
|
|
3568
|
-
processId:
|
|
3607
|
+
processId: process2.id
|
|
3569
3608
|
})
|
|
3570
3609
|
} : {},
|
|
3571
3610
|
...beforeMutation ? { beforeMutation } : {},
|
|
@@ -3758,11 +3797,11 @@ function wrapLazyTurnBoxWithRouting(services, ids, args) {
|
|
|
3758
3797
|
...args.onFirstOperation ? { onFirstOperation: args.onFirstOperation } : {},
|
|
3759
3798
|
providerCommandHandle: admittedCommandHandle,
|
|
3760
3799
|
...ids.workspaceMutationFence ? {
|
|
3761
|
-
providerCommandPersistence: (
|
|
3800
|
+
providerCommandPersistence: (process2) => retainedProviderCommandPersistence(db, {
|
|
3762
3801
|
accountId: ids.workspaceMutationFence.accountId,
|
|
3763
3802
|
workspaceId: ids.workspaceId,
|
|
3764
3803
|
sessionId: ids.sessionId,
|
|
3765
|
-
processId:
|
|
3804
|
+
processId: process2.id
|
|
3766
3805
|
})
|
|
3767
3806
|
} : {},
|
|
3768
3807
|
...beforeMutation ? { beforeMutation } : {},
|
|
@@ -4781,7 +4820,7 @@ import {
|
|
|
4781
4820
|
classifyProviderSandboxFailure
|
|
4782
4821
|
} from "@opengeni/runtime";
|
|
4783
4822
|
import { CancelledFailure } from "@temporalio/activity";
|
|
4784
|
-
import { randomUUID as
|
|
4823
|
+
import { randomUUID as randomUUID4 } from "crypto";
|
|
4785
4824
|
var TurnOperationCancelledError = class extends Error {
|
|
4786
4825
|
constructor(reason) {
|
|
4787
4826
|
super("Turn operation was cancelled with its owning turn", {
|
|
@@ -5072,7 +5111,7 @@ function createTurnSandboxProvisioner(establish, options = {}) {
|
|
|
5072
5111
|
return {
|
|
5073
5112
|
get() {
|
|
5074
5113
|
if (!memo) {
|
|
5075
|
-
const provisionId = options.provisionIdFactory?.() ??
|
|
5114
|
+
const provisionId = options.provisionIdFactory?.() ?? randomUUID4();
|
|
5076
5115
|
memo = (async () => {
|
|
5077
5116
|
const startedAt = performance.now();
|
|
5078
5117
|
throwIfTurnOperationCancelled(options.signal);
|
|
@@ -6637,10 +6676,8 @@ export {
|
|
|
6637
6676
|
currentActivityContext,
|
|
6638
6677
|
startActivityHeartbeat,
|
|
6639
6678
|
nextStreamEvent,
|
|
6640
|
-
|
|
6679
|
+
persistWorkspaceArchiveCandidate,
|
|
6641
6680
|
putVersion1TarArchiveOrInline,
|
|
6642
|
-
deleteUnpublishedWorkspaceArchiveObject,
|
|
6643
|
-
deleteWorkspaceArchiveObjectKeys,
|
|
6644
6681
|
sandboxLeaseHolderIdForAttempt,
|
|
6645
6682
|
waitForWarmSnapshot,
|
|
6646
6683
|
maybePersistWarmWorkspaceSnapshot,
|
|
@@ -6722,4 +6759,4 @@ export {
|
|
|
6722
6759
|
codexUsageLimitFailurePayload,
|
|
6723
6760
|
CODEX_USAGE_LIMIT_MAX_RESUME_MS
|
|
6724
6761
|
};
|
|
6725
|
-
//# sourceMappingURL=chunk-
|
|
6762
|
+
//# sourceMappingURL=chunk-ZNIKZQMN.js.map
|