deepline 0.3.537 → 0.3.539
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/bundling-sources/sdk/src/client-core.ts +22 -5
- package/dist/bundling-sources/sdk/src/index.ts +2 -0
- package/dist/bundling-sources/sdk/src/plays/client-core.ts +18 -1
- package/dist/bundling-sources/sdk/src/release.ts +1 -1
- package/dist/bundling-sources/sdk/src/runs/watch-polling.ts +33 -4
- package/dist/bundling-sources/shared_libs/integration-contracts/billing-entitlements.ts +1 -1
- package/dist/bundling-sources/shared_libs/observability/scheduled-jobs.json +18 -0
- package/dist/bundling-sources/shared_libs/play-runtime/app-runtime-api.ts +9 -1
- package/dist/bundling-sources/shared_libs/play-runtime/baked-runner-image.ts +392 -0
- package/dist/bundling-sources/shared_libs/play-runtime/context.ts +717 -133
- package/dist/bundling-sources/shared_libs/play-runtime/coordinator-headers.ts +7 -0
- package/dist/bundling-sources/shared_libs/play-runtime/daytona-payload-contract.ts +22 -1
- package/dist/bundling-sources/shared_libs/play-runtime/durable-runs-rollout.ts +123 -0
- package/dist/bundling-sources/shared_libs/play-runtime/experiment-switches.ts +480 -0
- package/dist/bundling-sources/shared_libs/play-runtime/fixture-egress-fetch.ts +24 -16
- package/dist/bundling-sources/shared_libs/play-runtime/freshness-receipt-execution.ts +293 -53
- package/dist/bundling-sources/shared_libs/play-runtime/governor/block-reserving-budget-state-backend.ts +57 -2
- package/dist/bundling-sources/shared_libs/play-runtime/governor/budget-state-backend.ts +43 -0
- package/dist/bundling-sources/shared_libs/play-runtime/governor/governor.ts +141 -9
- package/dist/bundling-sources/shared_libs/play-runtime/launch-identity.ts +4 -0
- package/dist/bundling-sources/shared_libs/play-runtime/modal-runtime-config.ts +6 -0
- package/dist/bundling-sources/shared_libs/play-runtime/modal-supervisor-sidecar.ts +556 -0
- package/dist/bundling-sources/shared_libs/play-runtime/protocol.ts +27 -0
- package/dist/bundling-sources/shared_libs/play-runtime/resource-governor.ts +19 -0
- package/dist/bundling-sources/shared_libs/play-runtime/run-ledger.ts +54 -0
- package/dist/bundling-sources/shared_libs/play-runtime/run-snapshot-stream.ts +5 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runner-app/index.ts +155 -7
- package/dist/bundling-sources/shared_libs/play-runtime/runner-app/relay-connection-counter.ts +103 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runner-app/runtime-heartbeat.ts +75 -6
- package/dist/bundling-sources/shared_libs/play-runtime/runner-app/runtime-terminal-push.ts +59 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-payload-transport.ts +544 -73
- package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-runtime-watchdog.ts +8 -1
- package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/detached-runner-readiness-pacing.ts +19 -1
- package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/modal.ts +2399 -110
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-flow.ts +42 -8
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-read-through.ts +287 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-receipt-finish.ts +606 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-receipt-writer.ts +274 -119
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-speed-profile.ts +136 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-traffic-policy.ts +54 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-work-counters.ts +10 -1
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backend.ts +22 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-play-run-task.ts +18 -1
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-pool.ts +18 -4
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-runtime-worker.ts +219 -7
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-shared.ts +3 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/early-sandbox-claim-affinity.ts +340 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/play-run-recovery.ts +1 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres-progress.ts +10 -1
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres-rate-state.ts +623 -7
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres.ts +340 -5
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runner-push.ts +61 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-event-search.ts +2 -1
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-sandbox-ledger-reconciliation.ts +269 -2
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-worker-wake.ts +238 -5
- package/dist/bundling-sources/shared_libs/play-runtime/startup-read-tool-ids.ts +47 -0
- package/dist/bundling-sources/shared_libs/play-runtime/tool-call/runtime-step-receipts-adapter.ts +5 -4
- package/dist/bundling-sources/shared_libs/play-runtime/tool-result.ts +6 -0
- package/dist/bundling-sources/shared_libs/play-runtime/transient-service-error.ts +11 -0
- package/dist/cli/auth-O5Y2VYXK.js +43 -0
- package/dist/cli/{auth-4SUPGDIM.mjs → auth-QD7QGD3B.mjs} +5 -5
- package/dist/cli/{billing-5JUA3ZM3.mjs → billing-FIZXMHBW.mjs} +31 -7
- package/dist/cli/{billing-SQU726P7.js → billing-KOQAF6WS.js} +114 -90
- package/dist/cli/{chunk-R7JYG6XO.mjs → chunk-2XMFT44N.mjs} +1 -1
- package/dist/cli/{chunk-XDS26J7Z.js → chunk-3YDI2PTN.js} +10 -10
- package/dist/cli/{chunk-KH27B2HJ.mjs → chunk-55ITVU2V.mjs} +2 -2
- package/dist/cli/{chunk-2Q7VXTMS.js → chunk-5QL4GJB2.js} +2 -2
- package/dist/cli/{chunk-D77W6Q67.js → chunk-5RUB53KG.js} +26 -26
- package/dist/cli/{chunk-JS2SBCWD.js → chunk-5YF35HAV.js} +6 -6
- package/dist/cli/{chunk-C37VELBR.mjs → chunk-6KG4KVTH.mjs} +5 -5
- package/dist/cli/{chunk-AX2OAXDL.mjs → chunk-6NZBLFL4.mjs} +1 -1
- package/dist/cli/{chunk-C3XD2WHM.mjs → chunk-6V3LNYK5.mjs} +2 -2
- package/dist/cli/{chunk-GPMS6OPX.mjs → chunk-ADV2IB2C.mjs} +5 -5
- package/dist/cli/{chunk-ZUAMXZXC.mjs → chunk-APKZGUTU.mjs} +4 -4
- package/dist/cli/{chunk-IQOIT6E3.js → chunk-CQJCLHBE.js} +41 -41
- package/dist/cli/{chunk-W3J3LT22.mjs → chunk-DZFVVP3S.mjs} +5 -5
- package/dist/cli/{chunk-V5IIBG2E.mjs → chunk-E4QHTDPF.mjs} +1 -1
- package/dist/cli/{chunk-CXTW7SRW.mjs → chunk-E7D37PLM.mjs} +8 -0
- package/dist/cli/{chunk-KULT6O5K.js → chunk-EAZS52DL.js} +15 -15
- package/dist/cli/{chunk-L3JVGNAT.mjs → chunk-F43MXIN3.mjs} +2 -2
- package/dist/cli/{chunk-WBTYWJLN.js → chunk-FH3P3E4S.js} +2 -2
- package/dist/cli/{chunk-K4WJ4BYO.mjs → chunk-FIRV7BXJ.mjs} +1 -1
- package/dist/cli/{chunk-NXGLJGPB.js → chunk-FSQCB5SJ.js} +2 -2
- package/dist/cli/{chunk-AVQET3NR.js → chunk-FTBWFDF3.js} +7 -7
- package/dist/cli/{chunk-QDBGPRR2.mjs → chunk-G3UFDUYU.mjs} +3 -1
- package/dist/cli/{chunk-ZHPSJ3LJ.mjs → chunk-GEO2EMM7.mjs} +29 -16
- package/dist/cli/{chunk-CGDW2CRR.mjs → chunk-GLEGINSP.mjs} +2 -2
- package/dist/cli/{chunk-EEFSUCYP.mjs → chunk-GLKUC5PO.mjs} +2 -2
- package/dist/cli/{chunk-BFHR7IC2.mjs → chunk-GNCIMHO2.mjs} +10 -10
- package/dist/cli/{chunk-PU42VOBI.js → chunk-ISXX5DUD.js} +3 -3
- package/dist/cli/{chunk-Y6AMMXWS.mjs → chunk-JBCQFG7G.mjs} +3 -3
- package/dist/cli/{chunk-Z2PPB3IO.mjs → chunk-JHEZQMOM.mjs} +1 -1
- package/dist/cli/{chunk-WBFOV5HT.js → chunk-K22EKW6L.js} +5 -5
- package/dist/cli/{chunk-CHIGEDAE.js → chunk-K5MZHTK7.js} +3 -3
- package/dist/cli/{chunk-L6QAIZNZ.js → chunk-KAEVL62Q.js} +44 -44
- package/dist/cli/{chunk-PJ4ZGZAN.js → chunk-KQTX545E.js} +13 -13
- package/dist/cli/{chunk-VP2K5B3R.mjs → chunk-LE5KN7CZ.mjs} +3 -3
- package/dist/cli/{chunk-BGXEMTIG.js → chunk-LEREPTAE.js} +19 -19
- package/dist/cli/{chunk-QPDLG7DQ.js → chunk-MI53W4DN.js} +53 -53
- package/dist/cli/{chunk-RMVZTBI5.mjs → chunk-MKESK3SW.mjs} +4 -4
- package/dist/cli/{chunk-NU7B5X6J.mjs → chunk-N3LPGGWD.mjs} +1 -1
- package/dist/cli/{chunk-VRYX2BR4.js → chunk-NR5PLMNG.js} +107 -107
- package/dist/cli/{chunk-JMHYDDBQ.js → chunk-Q4HNK7JX.js} +292 -279
- package/dist/cli/{chunk-37AZHCTP.mjs → chunk-RULRGMMM.mjs} +5 -5
- package/dist/cli/{chunk-GI3V4D7K.mjs → chunk-SDAP5MCO.mjs} +2 -2
- package/dist/cli/{chunk-5EOEJKSV.js → chunk-TZBCJHV6.js} +1 -1
- package/dist/cli/{chunk-3PMCQ3LK.js → chunk-V7DEGIYO.js} +7 -5
- package/dist/cli/{chunk-ALHKB3AE.js → chunk-VK5UTS5B.js} +9 -9
- package/dist/cli/{chunk-ZFSB7GXF.js → chunk-W32KT6LM.js} +5 -5
- package/dist/cli/{chunk-6BBGUQJJ.js → chunk-XTYHZEJ2.js} +8 -0
- package/dist/cli/{chunk-UGA5KI4A.js → chunk-XZBXQCRJ.js} +22 -22
- package/dist/cli/{chunk-BRRCWUOW.mjs → chunk-Y66ZMOJI.mjs} +1 -1
- package/dist/cli/{chunk-CFND2ACL.js → chunk-YMQFQO3K.js} +16 -16
- package/dist/cli/command-docs.js +2 -2
- package/dist/cli/command-docs.mjs +1 -1
- package/dist/cli/{csv-JITYN27L.js → csv-BWWJYV2C.js} +13 -13
- package/dist/cli/{csv-HZP6QMG7.mjs → csv-G5RQQ74W.mjs} +4 -4
- package/dist/cli/{db-FYSRB7O4.js → db-5KNDLADE.js} +27 -27
- package/dist/cli/{db-QRIRTOMM.mjs → db-AJZHWB3V.mjs} +6 -6
- package/dist/cli/describe-B6CN6CFJ.js +49 -0
- package/dist/cli/{describe-REXJVJC3.mjs → describe-QY5TKWVD.mjs} +17 -17
- package/dist/cli/describe-core.d.mts +3 -3
- package/dist/cli/describe-core.d.ts +3 -3
- package/dist/cli/{executions-BSTF4DDS.js → executions-BCCW76BI.js} +8 -8
- package/dist/cli/{executions-53KJAFOW.mjs → executions-SJPH3MZT.mjs} +6 -6
- package/dist/cli/{feedback-6MW3QOXX.js → feedback-GF65JKK6.js} +14 -14
- package/dist/cli/{feedback-CWUJJF3J.mjs → feedback-S6SZOFGK.mjs} +6 -6
- package/dist/cli/git-DX6NB7VF.js +25 -0
- package/dist/cli/{git-CKVZTJFS.mjs → git-F5FT5YVB.mjs} +5 -5
- package/dist/cli/index.js +143 -143
- package/dist/cli/index.mjs +42 -42
- package/dist/cli/{legacy-noops-QBL4PNGB.js → legacy-noops-ECR6FS6U.js} +9 -9
- package/dist/cli/{legacy-noops-USTBRFRX.mjs → legacy-noops-NOA4P5NE.mjs} +6 -6
- package/dist/cli/{monitors-6UCG5D7W.mjs → monitors-CTYSAGP4.mjs} +7 -7
- package/dist/cli/{monitors-VCR6SUZD.js → monitors-DEWBSURN.js} +100 -100
- package/dist/cli/{org-GSRBOJVO.mjs → org-EKSKKT7H.mjs} +6 -6
- package/dist/cli/{org-HPILTEG4.js → org-ZM2UUMZZ.js} +86 -86
- package/dist/cli/{play-TK7WOP5H.js → play-6JQOM6DE.js} +317 -317
- package/dist/cli/{play-QRTYQNG4.mjs → play-R2BH374J.mjs} +17 -17
- package/dist/cli/{providers-HEXNJ5QC.js → providers-CMIYHEMN.js} +9 -9
- package/dist/cli/{providers-OAQJWVBS.mjs → providers-X7WMIWO4.mjs} +6 -6
- package/dist/cli/{quickstart-PYZTFXZX.js → quickstart-6HVPAMSW.js} +6 -6
- package/dist/cli/{quickstart-FFVHTPSP.mjs → quickstart-ZZ7L6VZJ.mjs} +4 -4
- package/dist/cli/{run-HLN6YYZH.mjs → run-FP32RKBU.mjs} +22 -22
- package/dist/cli/{run-4DWJXJRO.js → run-OOHYH3GI.js} +42 -42
- package/dist/cli/search-34C6LFOJ.js +32 -0
- package/dist/cli/{search-ZHRCXGEL.mjs → search-BDDNC23Z.mjs} +7 -7
- package/dist/cli/{search-output-2KY6PFDH.js → search-output-5VZIQQAM.js} +6 -6
- package/dist/cli/{search-output-N7QXACVK.mjs → search-output-QXJ6CV5G.mjs} +4 -4
- package/dist/cli/{secrets-WXQ7XO5C.js → secrets-EN2HQCO3.js} +15 -15
- package/dist/cli/{secrets-FKMWBLHU.mjs → secrets-Z7CQSQGC.mjs} +6 -6
- package/dist/cli/{sessions-3YDTEDA5.mjs → sessions-I2H37OTJ.mjs} +6 -6
- package/dist/cli/sessions-RYQX3NDD.js +22 -0
- package/dist/cli/{settings-67TWLQ6E.js → settings-CTRAPFNZ.js} +85 -85
- package/dist/cli/{settings-JTPASUZN.mjs → settings-IYSC5PPQ.mjs} +12 -12
- package/dist/cli/{setup-VYNGXUJ6.mjs → setup-PU3HOVI3.mjs} +9 -9
- package/dist/cli/{setup-KUERQJUX.js → setup-XIN53GEW.js} +49 -49
- package/dist/cli/skills-576CX7DK.js +36 -0
- package/dist/cli/{skills-KI4KYHH6.mjs → skills-TYBML2ZO.mjs} +7 -7
- package/dist/cli/tools-EXMUWA3Z.js +56 -0
- package/dist/cli/{tools-UQDJS2RS.mjs → tools-ZVNE6M6J.mjs} +16 -16
- package/dist/cli/{update-7FQQUBOD.mjs → update-54WENBNT.mjs} +9 -9
- package/dist/cli/update-RAHETNL2.js +34 -0
- package/dist/cli/{views-MJK7JGZG.js → views-7L75EZOJ.js} +21 -21
- package/dist/cli/{views-JAM4MNNV.mjs → views-EUBB4ONT.mjs} +6 -6
- package/dist/cli/{workflow-AQPRIWQX.js → workflow-EZVYCR6Y.js} +17 -17
- package/dist/cli/{workflow-TQRV5FGO.mjs → workflow-GUKGFJ72.mjs} +7 -7
- package/dist/{client-BlLYQDNo.d.mts → client-D0uDBybG.d.mts} +1 -1
- package/dist/{client-DSQlkIDO.d.ts → client-DZTnAv4B.d.ts} +1 -1
- package/dist/{client-core-rX7n2H8U.d.mts → client-core-BhWf8Y1b.d.mts} +15 -2
- package/dist/{client-core-CDwapXy5.d.ts → client-core-og3AP1LL.d.ts} +15 -2
- package/dist/{compiler-manifest-BHNC4RL-.d.ts → compiler-manifest-Bes3OVA3.d.mts} +1 -1
- package/dist/{compiler-manifest-BHNC4RL-.d.mts → compiler-manifest-Bes3OVA3.d.ts} +1 -1
- package/dist/{errors-lhtIWG5Z.d.ts → errors-BJm4lLWc.d.ts} +1 -1
- package/dist/{errors-D7sPXrvB.d.mts → errors-Dc5r42ks.d.mts} +1 -1
- package/dist/{index-CQTBHXHr.d.ts → index-BfV7mRPF.d.ts} +1 -1
- package/dist/{index-NaDZq2xf.d.mts → index-DTkiz_Ur.d.mts} +1 -1
- package/dist/index.d.mts +7 -7
- package/dist/index.d.ts +7 -7
- package/dist/index.js +9 -9
- package/dist/index.mjs +6 -6
- package/dist/install-integrity.json +121 -112
- package/dist/plays/bundle-play-file.d.mts +3 -3
- package/dist/plays/bundle-play-file.d.ts +3 -3
- package/dist/plays/play-description.d.mts +2 -2
- package/dist/plays/play-description.d.ts +2 -2
- package/dist/plays/run-request.d.mts +2 -2
- package/dist/plays/run-request.d.ts +2 -2
- package/dist/release.d.mts +1 -1
- package/dist/release.d.ts +1 -1
- package/dist/release.js +2 -2
- package/dist/release.mjs +1 -1
- package/dist/server.d.mts +4 -4
- package/dist/server.d.ts +4 -4
- package/dist/server.js +5 -5
- package/dist/server.mjs +3 -3
- package/package.json +1 -1
- package/dist/cli/auth-Y2K2ZYYA.js +0 -43
- package/dist/cli/describe-LSOHOLFI.js +0 -49
- package/dist/cli/git-S7SWUZ3T.js +0 -25
- package/dist/cli/search-WERQBC6V.js +0 -32
- package/dist/cli/sessions-LXQ4Q6BS.js +0 -22
- package/dist/cli/skills-EFRLHY3F.js +0 -36
- package/dist/cli/tools-C3EIGFFP.js +0 -56
- package/dist/cli/update-KCY72RXH.js +0 -34
|
@@ -18,6 +18,7 @@ import {
|
|
|
18
18
|
import {
|
|
19
19
|
STANDARD_PLAY_SANDBOX_RUNTIME_LIMITS,
|
|
20
20
|
validatePlaySandboxRuntimeLimits,
|
|
21
|
+
type PlaySandboxRuntimeLimits,
|
|
21
22
|
} from '../../../plays/sandbox-runtime-limits';
|
|
22
23
|
import {
|
|
23
24
|
RUNNER_POST_TERMINAL_DIAGNOSTIC_MAX_BYTES,
|
|
@@ -31,10 +32,13 @@ import {
|
|
|
31
32
|
} from '../../run-failure';
|
|
32
33
|
import {
|
|
33
34
|
buildDaytonaPayloadMaterializerSource,
|
|
35
|
+
buildPrebootDeliveryMaterializerSource,
|
|
34
36
|
type DaytonaPayloadEnvelope,
|
|
35
37
|
} from '../../daytona-payload-contract';
|
|
36
38
|
export { buildDaytonaPayloadMaterializerSource } from '../../daytona-payload-contract';
|
|
37
39
|
import { compactPlayArtifactForRuntimeTransport } from '../../../plays/artifact-transport';
|
|
40
|
+
import { buildBakedRunnerVerifySource } from '../../baked-runner-image';
|
|
41
|
+
import { DURABLE_RUNS_ROLLOUT } from '../../durable-runs-rollout';
|
|
38
42
|
import type {
|
|
39
43
|
DaytonaExecutionContext,
|
|
40
44
|
DaytonaSandbox,
|
|
@@ -81,8 +85,52 @@ export type StagedDaytonaPayload = {
|
|
|
81
85
|
terminationDiagnosticPath: string;
|
|
82
86
|
progressEventPath: string;
|
|
83
87
|
startupDiagnosticPath: string;
|
|
88
|
+
/**
|
|
89
|
+
* Present only when the caller asked for stdin delivery: the gzipped
|
|
90
|
+
* envelope (base64) that `inlineCommand` reads from its own stdin before
|
|
91
|
+
* running exactly `command`. The envelope was NOT uploaded. If stdin
|
|
92
|
+
* delivery fails, upload `envelope` to `envelopePath` and run `command`.
|
|
93
|
+
*/
|
|
94
|
+
inlineEnvelope?: {
|
|
95
|
+
envelopePath: string;
|
|
96
|
+
envelope: Buffer;
|
|
97
|
+
base64: string;
|
|
98
|
+
inlineCommand: string;
|
|
99
|
+
/** The inline command prints the baked verdict line before reading stdin. */
|
|
100
|
+
verifiesBakedRunner?: boolean;
|
|
101
|
+
};
|
|
84
102
|
};
|
|
85
103
|
|
|
104
|
+
/** Exit code of the inline prefix when stdin did not carry the whole envelope. */
|
|
105
|
+
export const INLINE_ENVELOPE_INCOMPLETE_EXIT_CODE = 97;
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Shell prefix that reads exactly the base64 envelope from stdin, decodes it
|
|
109
|
+
* to `envelopePath`, and refuses (exit 97, before anything else runs) unless
|
|
110
|
+
* the decoded file has exactly the expected byte count. The secret-bearing
|
|
111
|
+
* envelope travels only on stdin, never in argv or the environment.
|
|
112
|
+
*/
|
|
113
|
+
export function inlineEnvelopeCommandPrefix(input: {
|
|
114
|
+
envelopePath: string;
|
|
115
|
+
base64Length: number;
|
|
116
|
+
bytes: number;
|
|
117
|
+
/** Verify the baked runner first and print its verdict line on stdout. */
|
|
118
|
+
verifyBakedRunner?: { nodeCommand: string; path: string; hash: string };
|
|
119
|
+
}): string {
|
|
120
|
+
const path = shellQuote(input.envelopePath);
|
|
121
|
+
return `${bakedRunnerGuardPrefix(input.verifyBakedRunner)}head -c ${input.base64Length} | base64 -d > ${path} && [ "$(wc -c < ${path} | tr -d ' ')" = "${input.bytes}" ] || exit ${INLINE_ENVELOPE_INCOMPLETE_EXIT_CODE}; `;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
function bakedRunnerGuardPrefix(verify?: {
|
|
125
|
+
nodeCommand: string;
|
|
126
|
+
path: string;
|
|
127
|
+
hash: string;
|
|
128
|
+
}): string {
|
|
129
|
+
return verify
|
|
130
|
+
? `v=$(${verify.nodeCommand} -e ${shellQuote(buildBakedRunnerVerifySource())} ${shellQuote(verify.path)} ${shellQuote(verify.hash)}); printf '%s\\n' "$v"; [ "$v" = 'baked-runner:ok' ] || exit ${INLINE_BAKED_RUNNER_UNVERIFIED_EXIT_CODE}; `
|
|
131
|
+
: '';
|
|
132
|
+
}
|
|
133
|
+
|
|
86
134
|
/** No payload or customer command has been sent when this is raised. */
|
|
87
135
|
export class DaytonaNodeUnavailableError extends Error {
|
|
88
136
|
constructor(
|
|
@@ -100,6 +148,28 @@ export class DaytonaNodeUnavailableError extends Error {
|
|
|
100
148
|
}
|
|
101
149
|
}
|
|
102
150
|
|
|
151
|
+
/**
|
|
152
|
+
* A prebaked runner the launcher expects in the sandbox image. `verified`
|
|
153
|
+
* settles with whether the sandbox itself proved the file exists and hashes to
|
|
154
|
+
* `hash`; a rejection or `false` keeps the full-upload path. The runner is
|
|
155
|
+
* never executed from `path` before that verdict is `true`.
|
|
156
|
+
*/
|
|
157
|
+
export type BakedRunnerExpectation = {
|
|
158
|
+
hash: string;
|
|
159
|
+
path: string;
|
|
160
|
+
verified: Promise<boolean>;
|
|
161
|
+
/**
|
|
162
|
+
* Inline (stdin) delivery only: the launch command itself verifies the
|
|
163
|
+
* baked file before reading stdin, printing the verdict line first, so no
|
|
164
|
+
* separate verify call is made. `verified` must then resolve true; a
|
|
165
|
+
* non-`ok` verdict makes the command exit 98 before reading the envelope.
|
|
166
|
+
*/
|
|
167
|
+
verifyInCommand?: boolean;
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
/** Exit code of the inline prefix when the baked runner did not verify. */
|
|
171
|
+
export const INLINE_BAKED_RUNNER_UNVERIFIED_EXIT_CODE = 98;
|
|
172
|
+
|
|
103
173
|
export type RemoteRunnerPayloadSandbox = {
|
|
104
174
|
id: string;
|
|
105
175
|
/** Daytona target (region) the sandbox runs in, when the provider reports it. */
|
|
@@ -162,6 +232,20 @@ function nodeMaterializePayloadCommand(input: {
|
|
|
162
232
|
].join(' ');
|
|
163
233
|
}
|
|
164
234
|
|
|
235
|
+
/**
|
|
236
|
+
* One Node process materializes the payload and then becomes the runtime
|
|
237
|
+
* watchdog (`DURABLE_RUNS_ROLLOUT.singleNodeMaterializeWatchdog`). The materializer runs in its own block scope (so its constants
|
|
238
|
+
* cannot collide with the watchdog's), consumes its six leading arguments, and
|
|
239
|
+
* removes them from `process.argv` so the watchdog reads exactly the argument
|
|
240
|
+
* positions it always had. A materializer failure throws before the watchdog
|
|
241
|
+
* is evaluated, which is what the former `materialize && watchdog` chain did.
|
|
242
|
+
*/
|
|
243
|
+
export function buildCombinedMaterializeAndWatchdogSource(
|
|
244
|
+
watchdogSource: string,
|
|
245
|
+
): string {
|
|
246
|
+
return `{${buildDaytonaPayloadMaterializerSource()}}process.argv.splice(1,6);${watchdogSource}`;
|
|
247
|
+
}
|
|
248
|
+
|
|
165
249
|
/**
|
|
166
250
|
* Crash-containment epilogue (push execution). The parked worker no longer
|
|
167
251
|
* holds anything that returns when the runner process dies, so a runner that
|
|
@@ -598,6 +682,262 @@ export function withRunnerSandboxProvider(
|
|
|
598
682
|
};
|
|
599
683
|
}
|
|
600
684
|
|
|
685
|
+
type DetachedRunnerPaths = Pick<
|
|
686
|
+
StagedDaytonaPayload,
|
|
687
|
+
| 'outputPath'
|
|
688
|
+
| 'exitCodePath'
|
|
689
|
+
| 'oomKillBaselinePath'
|
|
690
|
+
| 'runnerPidPath'
|
|
691
|
+
| 'runtimeStartedPath'
|
|
692
|
+
| 'runtimeCompletedPath'
|
|
693
|
+
| 'terminationDiagnosticPath'
|
|
694
|
+
| 'progressEventPath'
|
|
695
|
+
| 'startupDiagnosticPath'
|
|
696
|
+
>;
|
|
697
|
+
|
|
698
|
+
/**
|
|
699
|
+
* The detached shell command: the watched runner (its output captured), then
|
|
700
|
+
* the crash-terminal epilogue. With `materialize`, the envelope is
|
|
701
|
+
* materialized in the same chain first (today's launch). Without it (PB), the
|
|
702
|
+
* runner is started with `--wait-config` and the files arrive later, config
|
|
703
|
+
* last; every watchdog limit and marker is otherwise the same.
|
|
704
|
+
*/
|
|
705
|
+
function buildDetachedRunnerCommand(input: {
|
|
706
|
+
workDir: string;
|
|
707
|
+
nodeBinaryPath?: string;
|
|
708
|
+
sandboxTarget?: string;
|
|
709
|
+
sandboxRuntimeLimits: PlaySandboxRuntimeLimits;
|
|
710
|
+
memoryLimitMiB?: number;
|
|
711
|
+
/** The runner file the watchdog starts. */
|
|
712
|
+
runnerPath: string;
|
|
713
|
+
configPath: string;
|
|
714
|
+
crashPusherPath: string;
|
|
715
|
+
materialize: {
|
|
716
|
+
envelopePath: string;
|
|
717
|
+
/** Where the materializer writes runner bytes the envelope carries. */
|
|
718
|
+
uploadedRunnerPath: string;
|
|
719
|
+
artifactCodePath: string;
|
|
720
|
+
artifactSourceMapPath: string;
|
|
721
|
+
} | null;
|
|
722
|
+
}): DetachedRunnerPaths & { command: string } {
|
|
723
|
+
const { workDir, configPath, crashPusherPath, materialize } = input;
|
|
724
|
+
const runtimeLimitSeconds = input.sandboxRuntimeLimits.timeoutSeconds;
|
|
725
|
+
const outputPath = `${workDir}/deepline-play-output-${randomUUID()}.log`;
|
|
726
|
+
const crashPusherLogPath = `${workDir}/deepline-play-crash-terminal-${randomUUID()}.log`;
|
|
727
|
+
const exitCodePath = `${workDir}/deepline-play-exit-${randomUUID()}.txt`;
|
|
728
|
+
const oomKillBaselinePath = `${workDir}/deepline-play-oom-kill-${randomUUID()}.txt`;
|
|
729
|
+
const runnerPidPath = `${workDir}/deepline-play-runner-pid-${randomUUID()}.txt`;
|
|
730
|
+
const runtimeStartedPath = `${workDir}/deepline-play-runtime-started-${randomUUID()}.json`;
|
|
731
|
+
const runtimeCompletedPath = `${workDir}/deepline-play-runtime-completed-${randomUUID()}.json`;
|
|
732
|
+
const runtimeLimitMarkerPath = `${workDir}/deepline-play-runtime-limit-${randomUUID()}.txt`;
|
|
733
|
+
const terminationDiagnosticPath = `${workDir}/deepline-play-termination-${randomUUID()}.json`;
|
|
734
|
+
const memoryLedgerPath = `${workDir}/deepline-play-memory-ledger-${randomUUID()}.json`;
|
|
735
|
+
const memoryPressurePath = `${workDir}/deepline-play-memory-pressure-${randomUUID()}.json`;
|
|
736
|
+
const progressEventPath = `${workDir}/deepline-play-progress-${randomUUID()}.jsonl`;
|
|
737
|
+
const startupDiagnosticPath = `${workDir}/deepline-play-startup-${randomUUID()}.json`;
|
|
738
|
+
const runnerTraceEnv =
|
|
739
|
+
process.env.DEEPLINE_RUNTIME_RECEIPT_TRACE === '1'
|
|
740
|
+
? 'DEEPLINE_RUNTIME_RECEIPT_TRACE=1 '
|
|
741
|
+
: '';
|
|
742
|
+
const runtimeReliabilityEnv = runtimeReliabilityEnvironmentPrefix();
|
|
743
|
+
// The runner's egress probe prints this next to its round-trip timings so
|
|
744
|
+
// a slow sandbox-to-estate path can be read against the region it crosses.
|
|
745
|
+
const sandboxTarget = input.sandboxTarget;
|
|
746
|
+
const sandboxTargetEnv =
|
|
747
|
+
typeof sandboxTarget === 'string' && sandboxTarget.trim()
|
|
748
|
+
? `DEEPLINE_SANDBOX_TARGET=${shellQuote(sandboxTarget.trim())} `
|
|
749
|
+
: '';
|
|
750
|
+
const nodeCommand = input.nodeBinaryPath
|
|
751
|
+
? shellQuote(input.nodeBinaryPath)
|
|
752
|
+
: 'node';
|
|
753
|
+
const singleNodeStart =
|
|
754
|
+
materialize !== null && DURABLE_RUNS_ROLLOUT.singleNodeMaterializeWatchdog;
|
|
755
|
+
const watchdogSource = buildDaytonaRuntimeWatchdogSource(
|
|
756
|
+
input.sandboxRuntimeLimits,
|
|
757
|
+
input.memoryLimitMiB,
|
|
758
|
+
materialize === null,
|
|
759
|
+
);
|
|
760
|
+
const watchedRunnerCommand = [
|
|
761
|
+
nodeCommand,
|
|
762
|
+
'-e',
|
|
763
|
+
shellQuote(
|
|
764
|
+
singleNodeStart
|
|
765
|
+
? buildCombinedMaterializeAndWatchdogSource(watchdogSource)
|
|
766
|
+
: watchdogSource,
|
|
767
|
+
),
|
|
768
|
+
// Materializer arguments, consumed (and removed from argv) before the
|
|
769
|
+
// watchdog reads its own.
|
|
770
|
+
...(singleNodeStart && materialize
|
|
771
|
+
? [
|
|
772
|
+
shellQuote(materialize.envelopePath),
|
|
773
|
+
shellQuote(materialize.uploadedRunnerPath),
|
|
774
|
+
shellQuote(configPath),
|
|
775
|
+
shellQuote(materialize.artifactCodePath),
|
|
776
|
+
shellQuote(materialize.artifactSourceMapPath),
|
|
777
|
+
shellQuote(crashPusherPath),
|
|
778
|
+
]
|
|
779
|
+
: []),
|
|
780
|
+
// Watchdog arguments.
|
|
781
|
+
shellQuote(input.runnerPath),
|
|
782
|
+
shellQuote(configPath),
|
|
783
|
+
shellQuote(runtimeStartedPath),
|
|
784
|
+
shellQuote(runtimeCompletedPath),
|
|
785
|
+
String(runtimeLimitSeconds * 1_000),
|
|
786
|
+
String(PLAY_RUNNER_STARTUP_GRACE_SECONDS * 1_000),
|
|
787
|
+
String(PLAY_RUNNER_TERMINAL_GRACE_SECONDS * 1_000),
|
|
788
|
+
shellQuote(runtimeLimitMarkerPath),
|
|
789
|
+
shellQuote(terminationDiagnosticPath),
|
|
790
|
+
shellQuote(memoryLedgerPath),
|
|
791
|
+
shellQuote(memoryPressurePath),
|
|
792
|
+
shellQuote(RUNNER_MEMORY_CGROUP_ROOT),
|
|
793
|
+
shellQuote(runnerPidPath),
|
|
794
|
+
].join(' ');
|
|
795
|
+
const materializeFirst =
|
|
796
|
+
singleNodeStart || !materialize
|
|
797
|
+
? ''
|
|
798
|
+
: `${nodeMaterializePayloadCommand({
|
|
799
|
+
envelopePath: materialize.envelopePath,
|
|
800
|
+
runnerPath: materialize.uploadedRunnerPath,
|
|
801
|
+
configPath,
|
|
802
|
+
artifactCodePath: materialize.artifactCodePath,
|
|
803
|
+
artifactSourceMapPath: materialize.artifactSourceMapPath,
|
|
804
|
+
crashPusherPath,
|
|
805
|
+
nodeBinaryPath: input.nodeBinaryPath,
|
|
806
|
+
})} && `;
|
|
807
|
+
const runnerCommand = `${materializeFirst}DEEPLINE_PLAY_RUNNER_RUNTIME_STARTED_PATH=${shellQuote(runtimeStartedPath)} DEEPLINE_PLAY_RUNNER_RUNTIME_COMPLETED_PATH=${shellQuote(runtimeCompletedPath)} DEEPLINE_PLAY_RUNNER_PROGRESS_EVENT_PATH=${shellQuote(progressEventPath)} DEEPLINE_PLAY_RUNNER_STARTUP_DIAGNOSTIC_PATH=${shellQuote(startupDiagnosticPath)} DEEPLINE_PLAY_RUNNER_STDOUT_EVENT_MODE=compact UV_THREADPOOL_SIZE=${PLAY_RUNNER_UV_THREADPOOL_SIZE} ${runtimeReliabilityEnv}${runnerTraceEnv}${sandboxTargetEnv}${watchedRunnerCommand}`;
|
|
808
|
+
// Crash-containment epilogue: runs UNCONDITIONALLY after the runner exits and
|
|
809
|
+
// pushes an unacknowledged parsed (or synthesized) terminal so the parked
|
|
810
|
+
// worker wakes within seconds of ANY runner death — process.exit abuse, OOM
|
|
811
|
+
// SIGKILL, or a crash before the in-process push. Idempotent against a
|
|
812
|
+
// successful in-runner push when its local acknowledgement was lost.
|
|
813
|
+
// Its own retry diagnostics are kept in a separate log: appending them to
|
|
814
|
+
// `outputPath` after a near-gateway-sized result could hide that result from
|
|
815
|
+
// a later bounded-tail recovery read.
|
|
816
|
+
const command = `rm -f ${shellQuote(outputPath)} ${shellQuote(crashPusherLogPath)} ${shellQuote(exitCodePath)} ${shellQuote(oomKillBaselinePath)} ${shellQuote(runnerPidPath)} ${shellQuote(runtimeStartedPath)} ${shellQuote(runtimeCompletedPath)} ${shellQuote(runtimeLimitMarkerPath)} ${shellQuote(terminationDiagnosticPath)} ${shellQuote(memoryLedgerPath)} ${shellQuote(`${memoryLedgerPath}.tmp`)} ${shellQuote(memoryPressurePath)} ${shellQuote(progressEventPath)} ${shellQuote(`${progressEventPath}.*`)} ${shellQuote(startupDiagnosticPath)}; ( awk '$1 == "oom_kill" { print $2 }' /sys/fs/cgroup/memory.events 2>/dev/null || true ) > ${shellQuote(oomKillBaselinePath)}; ( ${runnerCommand} ) > ${shellQuote(outputPath)} 2>&1; code=$?; printf '%s' "$code" > ${shellQuote(exitCodePath)}; ${runtimeReliabilityEnv}${nodeCommand} ${shellQuote(crashPusherPath)} ${shellQuote(configPath)} "$code" ${shellQuote(outputPath)} ${shellQuote(runtimeLimitMarkerPath)} ${shellQuote(oomKillBaselinePath)} /sys/fs/cgroup/memory.events ${shellQuote(terminationDiagnosticPath)} ${shellQuote(runtimeCompletedPath)} > ${shellQuote(crashPusherLogPath)} 2>&1 || true; printf 'deepline runner output captured: %s\\n' ${shellQuote(outputPath)}; exit "$code"`;
|
|
817
|
+
|
|
818
|
+
return {
|
|
819
|
+
command,
|
|
820
|
+
outputPath,
|
|
821
|
+
exitCodePath,
|
|
822
|
+
oomKillBaselinePath,
|
|
823
|
+
runnerPidPath,
|
|
824
|
+
runtimeStartedPath,
|
|
825
|
+
runtimeCompletedPath,
|
|
826
|
+
terminationDiagnosticPath,
|
|
827
|
+
progressEventPath,
|
|
828
|
+
startupDiagnosticPath,
|
|
829
|
+
};
|
|
830
|
+
}
|
|
831
|
+
|
|
832
|
+
/**
|
|
833
|
+
* PB (pre-booted runner): what the early sandbox runs before its run is
|
|
834
|
+
* adopted, and the fixed paths the run's delivery and suspension must use.
|
|
835
|
+
*/
|
|
836
|
+
export type PrebootedRunnerLaunch = DetachedRunnerPaths & {
|
|
837
|
+
/**
|
|
838
|
+
* The long-lived pre-boot command: the baked-runner verify guard (verdict
|
|
839
|
+
* line first; exit 98 before anything else on a non-ok verdict), then the
|
|
840
|
+
* watched runner started with `--wait-config`, then the crash-terminal
|
|
841
|
+
* epilogue. It names only public paths and the public baked runner: no
|
|
842
|
+
* envelope, config, token or customer data.
|
|
843
|
+
*/
|
|
844
|
+
command: string;
|
|
845
|
+
/** The verified baked runner the watchdog starts. */
|
|
846
|
+
runnerPath: string;
|
|
847
|
+
configPath: string;
|
|
848
|
+
artifactCodePath: string;
|
|
849
|
+
artifactSourceMapPath: string;
|
|
850
|
+
crashPusherPath: string;
|
|
851
|
+
/** The limits the watchdog and V8 flags were fixed with at pre-boot. */
|
|
852
|
+
sandboxRuntimeLimits: PlaySandboxRuntimeLimits;
|
|
853
|
+
memoryLimitMiB?: number;
|
|
854
|
+
};
|
|
855
|
+
|
|
856
|
+
export function buildPrebootedRunnerLaunch(input: {
|
|
857
|
+
workDir: string;
|
|
858
|
+
bakedRunner: { hash: string; path: string };
|
|
859
|
+
sandboxRuntimeLimits: PlaySandboxRuntimeLimits;
|
|
860
|
+
memoryLimitMiB?: number;
|
|
861
|
+
nodeBinaryPath?: string;
|
|
862
|
+
}): PrebootedRunnerLaunch {
|
|
863
|
+
const workDir = input.workDir.replace(/\/$/, '');
|
|
864
|
+
const sandboxRuntimeLimits = validatePlaySandboxRuntimeLimits(
|
|
865
|
+
input.sandboxRuntimeLimits,
|
|
866
|
+
);
|
|
867
|
+
const configPath = `${workDir}/deepline-play-config-${randomUUID()}.json`;
|
|
868
|
+
const artifactCodePath = `${workDir}/deepline-play-artifact-${randomUUID()}.cjs`;
|
|
869
|
+
const crashPusherPath = `${workDir}/deepline-play-crash-terminal-${randomUUID()}.cjs`;
|
|
870
|
+
const nodeCommand = input.nodeBinaryPath
|
|
871
|
+
? shellQuote(input.nodeBinaryPath)
|
|
872
|
+
: 'node';
|
|
873
|
+
const { command, ...paths } = buildDetachedRunnerCommand({
|
|
874
|
+
workDir,
|
|
875
|
+
nodeBinaryPath: input.nodeBinaryPath,
|
|
876
|
+
sandboxRuntimeLimits,
|
|
877
|
+
memoryLimitMiB: input.memoryLimitMiB,
|
|
878
|
+
runnerPath: input.bakedRunner.path,
|
|
879
|
+
configPath,
|
|
880
|
+
crashPusherPath,
|
|
881
|
+
materialize: null,
|
|
882
|
+
});
|
|
883
|
+
return {
|
|
884
|
+
...paths,
|
|
885
|
+
command: `${bakedRunnerGuardPrefix({
|
|
886
|
+
nodeCommand,
|
|
887
|
+
path: input.bakedRunner.path,
|
|
888
|
+
hash: input.bakedRunner.hash,
|
|
889
|
+
})}${command}`,
|
|
890
|
+
runnerPath: input.bakedRunner.path,
|
|
891
|
+
configPath,
|
|
892
|
+
artifactCodePath,
|
|
893
|
+
artifactSourceMapPath: `${artifactCodePath}.map`,
|
|
894
|
+
crashPusherPath,
|
|
895
|
+
sandboxRuntimeLimits,
|
|
896
|
+
...(input.memoryLimitMiB === undefined
|
|
897
|
+
? {}
|
|
898
|
+
: { memoryLimitMiB: input.memoryLimitMiB }),
|
|
899
|
+
};
|
|
900
|
+
}
|
|
901
|
+
|
|
902
|
+
/** The run's limits differ from those the pre-booted runner was started with. */
|
|
903
|
+
export class PrebootedRunnerLimitsMismatchError extends Error {
|
|
904
|
+
constructor() {
|
|
905
|
+
super(
|
|
906
|
+
'The pre-booted runner was started with different sandbox limits than this run; nothing was delivered to it.',
|
|
907
|
+
);
|
|
908
|
+
this.name = 'PrebootedRunnerLimitsMismatchError';
|
|
909
|
+
}
|
|
910
|
+
}
|
|
911
|
+
|
|
912
|
+
export function samePlaySandboxRuntimeLimits(
|
|
913
|
+
a: PlaySandboxRuntimeLimits,
|
|
914
|
+
b: PlaySandboxRuntimeLimits,
|
|
915
|
+
): boolean {
|
|
916
|
+
return (
|
|
917
|
+
a.timeoutSeconds === b.timeoutSeconds &&
|
|
918
|
+
a.memoryGiB === b.memoryGiB &&
|
|
919
|
+
a.cpu === b.cpu &&
|
|
920
|
+
a.diskGiB === b.diskGiB
|
|
921
|
+
);
|
|
922
|
+
}
|
|
923
|
+
|
|
924
|
+
function prebootDeliveryMaterializeCommand(input: {
|
|
925
|
+
nodeCommand: string;
|
|
926
|
+
envelopePath: string;
|
|
927
|
+
preboot: PrebootedRunnerLaunch;
|
|
928
|
+
}): string {
|
|
929
|
+
return [
|
|
930
|
+
input.nodeCommand,
|
|
931
|
+
'-e',
|
|
932
|
+
shellQuote(buildPrebootDeliveryMaterializerSource()),
|
|
933
|
+
shellQuote(input.envelopePath),
|
|
934
|
+
shellQuote(input.preboot.configPath),
|
|
935
|
+
shellQuote(input.preboot.artifactCodePath),
|
|
936
|
+
shellQuote(input.preboot.artifactSourceMapPath),
|
|
937
|
+
shellQuote(input.preboot.crashPusherPath),
|
|
938
|
+
].join(' ');
|
|
939
|
+
}
|
|
940
|
+
|
|
601
941
|
export async function stageRunnerPayload(input: {
|
|
602
942
|
sandbox: RemoteRunnerPayloadSandbox;
|
|
603
943
|
bundlePromise: Promise<string>;
|
|
@@ -609,14 +949,42 @@ export async function stageRunnerPayload(input: {
|
|
|
609
949
|
workDir: string;
|
|
610
950
|
startedAt: number;
|
|
611
951
|
emitStage: DaytonaStageEmitter;
|
|
952
|
+
/** Set only when the image is expected to carry this deploy's runner. */
|
|
953
|
+
bakedRunner?: BakedRunnerExpectation;
|
|
954
|
+
/**
|
|
955
|
+
* `stdin`: do not upload the envelope; return it for the caller to deliver
|
|
956
|
+
* on the launch command's stdin (one provider call fewer). Default upload.
|
|
957
|
+
*/
|
|
958
|
+
envelopeDelivery?: 'upload' | 'stdin';
|
|
959
|
+
/**
|
|
960
|
+
* PB: a runner already started in this sandbox by
|
|
961
|
+
* `buildPrebootedRunnerLaunch` and polling for its config. The envelope is
|
|
962
|
+
* staged for that runner's fixed paths (stdin delivery only, no runner
|
|
963
|
+
* bytes), and the returned command only materializes it, config last.
|
|
964
|
+
* Mutually exclusive with `bakedRunner`.
|
|
965
|
+
*/
|
|
966
|
+
preboot?: PrebootedRunnerLaunch;
|
|
612
967
|
}): Promise<StagedDaytonaPayload> {
|
|
968
|
+
const preboot = input.preboot;
|
|
969
|
+
if (preboot && (input.bakedRunner || input.envelopeDelivery !== 'stdin')) {
|
|
970
|
+
throw new Error(
|
|
971
|
+
'A pre-booted runner takes its envelope on stdin and has no separate baked-runner placement.',
|
|
972
|
+
);
|
|
973
|
+
}
|
|
613
974
|
const workDir = input.workDir.replace(/\/$/, '');
|
|
614
975
|
const runnerPath = `${workDir}/deepline-play-runner-${randomUUID()}.cjs`;
|
|
615
976
|
const envelopePath = `${workDir}/deepline-play-payload-${randomUUID()}.json.gz`;
|
|
616
|
-
const configPath =
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
const
|
|
977
|
+
const configPath =
|
|
978
|
+
preboot?.configPath ??
|
|
979
|
+
`${workDir}/deepline-play-config-${randomUUID()}.json`;
|
|
980
|
+
const artifactCodePath =
|
|
981
|
+
preboot?.artifactCodePath ??
|
|
982
|
+
`${workDir}/deepline-play-artifact-${randomUUID()}.cjs`;
|
|
983
|
+
const artifactSourceMapPath =
|
|
984
|
+
preboot?.artifactSourceMapPath ?? `${artifactCodePath}.map`;
|
|
985
|
+
const crashPusherPath =
|
|
986
|
+
preboot?.crashPusherPath ??
|
|
987
|
+
`${workDir}/deepline-play-crash-terminal-${randomUUID()}.cjs`;
|
|
620
988
|
|
|
621
989
|
const remoteMaterializedFiles: Record<string, string> = {};
|
|
622
990
|
const hasInlineCsv = Boolean(input.config.csvSourceContentBase64);
|
|
@@ -712,16 +1080,30 @@ export async function stageRunnerPayload(input: {
|
|
|
712
1080
|
},
|
|
713
1081
|
);
|
|
714
1082
|
const runtimeLimitSeconds = sandboxRuntimeLimits.timeoutSeconds;
|
|
1083
|
+
if (
|
|
1084
|
+
preboot &&
|
|
1085
|
+
(!samePlaySandboxRuntimeLimits(
|
|
1086
|
+
preboot.sandboxRuntimeLimits,
|
|
1087
|
+
sandboxRuntimeLimits,
|
|
1088
|
+
) ||
|
|
1089
|
+
preboot.memoryLimitMiB !== input.memoryLimitMiB)
|
|
1090
|
+
) {
|
|
1091
|
+
// Nothing was delivered: the pre-booted runner still holds no config.
|
|
1092
|
+
throw new PrebootedRunnerLimitsMismatchError();
|
|
1093
|
+
}
|
|
715
1094
|
|
|
1095
|
+
const inlineDelivery = input.envelopeDelivery === 'stdin';
|
|
1096
|
+
let inlineEnvelopeBytes: Buffer | null = null;
|
|
716
1097
|
const envelopeUpload = input.bundlePromise.then((bundle) =>
|
|
717
|
-
|
|
1098
|
+
deliverEnvelope({
|
|
718
1099
|
sandbox: input.sandbox,
|
|
719
1100
|
emitStage: input.emitStage,
|
|
720
1101
|
label: 'payload',
|
|
721
1102
|
path: envelopePath,
|
|
722
1103
|
content: gzipJson({
|
|
723
1104
|
schemaVersion: 1,
|
|
724
|
-
|
|
1105
|
+
// Empty means "already on disk"; see the runner placement below.
|
|
1106
|
+
runnerCode: input.bakedRunner || preboot ? '' : bundle,
|
|
725
1107
|
artifactBundledCode: compactedArtifact.bundledCode,
|
|
726
1108
|
artifactSourceMap: input.config.artifact.sourceMap,
|
|
727
1109
|
config: preparePlayRunnerConfigForTransport(remoteConfig),
|
|
@@ -730,84 +1112,173 @@ export async function stageRunnerPayload(input: {
|
|
|
730
1112
|
}),
|
|
731
1113
|
}),
|
|
732
1114
|
);
|
|
733
|
-
|
|
1115
|
+
function deliverEnvelope(
|
|
1116
|
+
upload: Parameters<typeof timedRunnerPayloadUpload>[0],
|
|
1117
|
+
) {
|
|
1118
|
+
if (!inlineDelivery) return timedRunnerPayloadUpload(upload);
|
|
1119
|
+
inlineEnvelopeBytes = upload.content;
|
|
1120
|
+
return Promise.resolve();
|
|
1121
|
+
}
|
|
1122
|
+
// The baked runner is used only after the sandbox proved the file. Any other
|
|
1123
|
+
// verdict uploads the bundle exactly where the full-upload path always did,
|
|
1124
|
+
// so the command below never names a runner file that was not confirmed.
|
|
1125
|
+
const runnerPlacement = (async (): Promise<{
|
|
1126
|
+
path: string;
|
|
1127
|
+
source: 'envelope' | 'baked' | 'uploaded_fallback' | 'prebooted';
|
|
1128
|
+
}> => {
|
|
1129
|
+
const baked = input.bakedRunner;
|
|
1130
|
+
if (preboot) return { path: preboot.runnerPath, source: 'prebooted' };
|
|
1131
|
+
if (!baked) return { path: runnerPath, source: 'envelope' };
|
|
1132
|
+
const verified = await baked.verified.then(
|
|
1133
|
+
(value) => value === true,
|
|
1134
|
+
() => false,
|
|
1135
|
+
);
|
|
1136
|
+
if (verified) return { path: baked.path, source: 'baked' };
|
|
1137
|
+
await timedRunnerPayloadUpload({
|
|
1138
|
+
sandbox: input.sandbox,
|
|
1139
|
+
emitStage: input.emitStage,
|
|
1140
|
+
label: 'runner_fallback',
|
|
1141
|
+
path: runnerPath,
|
|
1142
|
+
content: Buffer.from(await input.bundlePromise, 'utf-8'),
|
|
1143
|
+
});
|
|
1144
|
+
return { path: runnerPath, source: 'uploaded_fallback' };
|
|
1145
|
+
})();
|
|
1146
|
+
// Awaited below; this only keeps an earlier upload failure from orphaning it.
|
|
1147
|
+
runnerPlacement.catch(() => undefined);
|
|
1148
|
+
const [, , placedRunner] = await Promise.all([
|
|
1149
|
+
filesUpload,
|
|
1150
|
+
envelopeUpload,
|
|
1151
|
+
runnerPlacement,
|
|
1152
|
+
]);
|
|
1153
|
+
if (input.bakedRunner) {
|
|
1154
|
+
input.emitStage('runner:placement', {
|
|
1155
|
+
sandboxId: input.sandbox.id,
|
|
1156
|
+
source: placedRunner.source,
|
|
1157
|
+
bakedHashPrefix: input.bakedRunner.hash.slice(0, 12),
|
|
1158
|
+
});
|
|
1159
|
+
}
|
|
1160
|
+
if (preboot) {
|
|
1161
|
+
input.emitStage('runner:placement', {
|
|
1162
|
+
sandboxId: input.sandbox.id,
|
|
1163
|
+
source: placedRunner.source,
|
|
1164
|
+
});
|
|
1165
|
+
}
|
|
734
1166
|
input.emitStage('upload:done', {
|
|
735
1167
|
sandboxId: input.sandbox.id,
|
|
736
1168
|
uploadedFileCount: uniqueLocalPaths.size + 1,
|
|
737
1169
|
elapsedMs: Date.now() - input.startedAt,
|
|
738
1170
|
});
|
|
739
1171
|
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
:
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
1172
|
+
if (preboot) {
|
|
1173
|
+
const inlineEnvelope = inlineEnvelopeBytes as Buffer | null;
|
|
1174
|
+
if (!inlineEnvelope) {
|
|
1175
|
+
throw new Error('Inline envelope delivery produced no envelope.');
|
|
1176
|
+
}
|
|
1177
|
+
const base64 = inlineEnvelope.toString('base64');
|
|
1178
|
+
// Materialize only: the watched runner, its limits and the crash-pusher
|
|
1179
|
+
// epilogue are already running in the pre-boot exec.
|
|
1180
|
+
const command = prebootDeliveryMaterializeCommand({
|
|
1181
|
+
nodeCommand: input.nodeBinaryPath
|
|
1182
|
+
? shellQuote(input.nodeBinaryPath)
|
|
1183
|
+
: 'node',
|
|
1184
|
+
envelopePath,
|
|
1185
|
+
preboot,
|
|
1186
|
+
});
|
|
1187
|
+
input.emitStage('upload:payload:inline', {
|
|
1188
|
+
bytes: inlineEnvelope.byteLength,
|
|
1189
|
+
base64Bytes: base64.length,
|
|
1190
|
+
});
|
|
1191
|
+
return {
|
|
1192
|
+
inlineEnvelope: {
|
|
1193
|
+
envelopePath,
|
|
1194
|
+
envelope: inlineEnvelope,
|
|
1195
|
+
base64,
|
|
1196
|
+
inlineCommand: `${inlineEnvelopeCommandPrefix({
|
|
1197
|
+
envelopePath,
|
|
1198
|
+
base64Length: base64.length,
|
|
1199
|
+
bytes: inlineEnvelope.byteLength,
|
|
1200
|
+
})}${command}`,
|
|
1201
|
+
},
|
|
1202
|
+
workDir: input.workDir,
|
|
1203
|
+
command,
|
|
1204
|
+
outputPath: preboot.outputPath,
|
|
1205
|
+
exitCodePath: preboot.exitCodePath,
|
|
1206
|
+
oomKillBaselinePath: preboot.oomKillBaselinePath,
|
|
1207
|
+
runnerPidPath: preboot.runnerPidPath,
|
|
1208
|
+
runtimeStartedPath: preboot.runtimeStartedPath,
|
|
1209
|
+
runtimeCompletedPath: preboot.runtimeCompletedPath,
|
|
1210
|
+
terminationDiagnosticPath: preboot.terminationDiagnosticPath,
|
|
1211
|
+
progressEventPath: preboot.progressEventPath,
|
|
1212
|
+
startupDiagnosticPath: preboot.startupDiagnosticPath,
|
|
1213
|
+
};
|
|
1214
|
+
}
|
|
1215
|
+
|
|
1216
|
+
const {
|
|
1217
|
+
command,
|
|
1218
|
+
outputPath,
|
|
1219
|
+
exitCodePath,
|
|
1220
|
+
oomKillBaselinePath,
|
|
1221
|
+
runnerPidPath,
|
|
1222
|
+
runtimeStartedPath,
|
|
1223
|
+
runtimeCompletedPath,
|
|
1224
|
+
terminationDiagnosticPath,
|
|
1225
|
+
progressEventPath,
|
|
1226
|
+
startupDiagnosticPath,
|
|
1227
|
+
} = buildDetachedRunnerCommand({
|
|
1228
|
+
workDir,
|
|
1229
|
+
nodeBinaryPath: input.nodeBinaryPath,
|
|
1230
|
+
sandboxTarget: input.sandbox.target,
|
|
1231
|
+
sandboxRuntimeLimits,
|
|
1232
|
+
memoryLimitMiB: input.memoryLimitMiB,
|
|
1233
|
+
runnerPath: placedRunner.path,
|
|
1234
|
+
configPath,
|
|
1235
|
+
crashPusherPath,
|
|
1236
|
+
materialize: {
|
|
1237
|
+
envelopePath,
|
|
1238
|
+
uploadedRunnerPath: runnerPath,
|
|
1239
|
+
artifactCodePath,
|
|
1240
|
+
artifactSourceMapPath,
|
|
1241
|
+
},
|
|
1242
|
+
});
|
|
765
1243
|
const nodeCommand = input.nodeBinaryPath
|
|
766
1244
|
? shellQuote(input.nodeBinaryPath)
|
|
767
1245
|
: 'node';
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
// pushes an unacknowledged parsed (or synthesized) terminal so the parked
|
|
802
|
-
// worker wakes within seconds of ANY runner death — process.exit abuse, OOM
|
|
803
|
-
// SIGKILL, or a crash before the in-process push. Idempotent against a
|
|
804
|
-
// successful in-runner push when its local acknowledgement was lost.
|
|
805
|
-
// Its own retry diagnostics are kept in a separate log: appending them to
|
|
806
|
-
// `outputPath` after a near-gateway-sized result could hide that result from
|
|
807
|
-
// a later bounded-tail recovery read.
|
|
808
|
-
const command = `rm -f ${shellQuote(outputPath)} ${shellQuote(crashPusherLogPath)} ${shellQuote(exitCodePath)} ${shellQuote(oomKillBaselinePath)} ${shellQuote(runnerPidPath)} ${shellQuote(runtimeStartedPath)} ${shellQuote(runtimeCompletedPath)} ${shellQuote(runtimeLimitMarkerPath)} ${shellQuote(terminationDiagnosticPath)} ${shellQuote(memoryLedgerPath)} ${shellQuote(`${memoryLedgerPath}.tmp`)} ${shellQuote(memoryPressurePath)} ${shellQuote(progressEventPath)} ${shellQuote(`${progressEventPath}.*`)} ${shellQuote(startupDiagnosticPath)}; ( awk '$1 == "oom_kill" { print $2 }' /sys/fs/cgroup/memory.events 2>/dev/null || true ) > ${shellQuote(oomKillBaselinePath)}; ( ${runnerCommand} ) > ${shellQuote(outputPath)} 2>&1; code=$?; printf '%s' "$code" > ${shellQuote(exitCodePath)}; ${runtimeReliabilityEnv}${nodeCommand} ${shellQuote(crashPusherPath)} ${shellQuote(configPath)} "$code" ${shellQuote(outputPath)} ${shellQuote(runtimeLimitMarkerPath)} ${shellQuote(oomKillBaselinePath)} /sys/fs/cgroup/memory.events ${shellQuote(terminationDiagnosticPath)} ${shellQuote(runtimeCompletedPath)} > ${shellQuote(crashPusherLogPath)} 2>&1 || true; printf 'deepline runner output captured: %s\\n' ${shellQuote(outputPath)}; exit "$code"`;
|
|
1246
|
+
|
|
1247
|
+
const inlineEnvelope = inlineEnvelopeBytes as Buffer | null;
|
|
1248
|
+
let inline: StagedDaytonaPayload['inlineEnvelope'];
|
|
1249
|
+
if (inlineDelivery) {
|
|
1250
|
+
if (!inlineEnvelope) {
|
|
1251
|
+
throw new Error('Inline envelope delivery produced no envelope.');
|
|
1252
|
+
}
|
|
1253
|
+
const base64 = inlineEnvelope.toString('base64');
|
|
1254
|
+
inline = {
|
|
1255
|
+
envelopePath,
|
|
1256
|
+
envelope: inlineEnvelope,
|
|
1257
|
+
base64,
|
|
1258
|
+
inlineCommand: `${inlineEnvelopeCommandPrefix({
|
|
1259
|
+
envelopePath,
|
|
1260
|
+
base64Length: base64.length,
|
|
1261
|
+
bytes: inlineEnvelope.byteLength,
|
|
1262
|
+
...(input.bakedRunner?.verifyInCommand
|
|
1263
|
+
? {
|
|
1264
|
+
verifyBakedRunner: {
|
|
1265
|
+
nodeCommand,
|
|
1266
|
+
path: input.bakedRunner.path,
|
|
1267
|
+
hash: input.bakedRunner.hash,
|
|
1268
|
+
},
|
|
1269
|
+
}
|
|
1270
|
+
: {}),
|
|
1271
|
+
})}${command}`,
|
|
1272
|
+
verifiesBakedRunner: input.bakedRunner?.verifyInCommand === true,
|
|
1273
|
+
};
|
|
1274
|
+
input.emitStage('upload:payload:inline', {
|
|
1275
|
+
bytes: inlineEnvelope.byteLength,
|
|
1276
|
+
base64Bytes: base64.length,
|
|
1277
|
+
});
|
|
1278
|
+
}
|
|
809
1279
|
|
|
810
1280
|
return {
|
|
1281
|
+
...(inline ? { inlineEnvelope: inline } : {}),
|
|
811
1282
|
workDir: input.workDir,
|
|
812
1283
|
command,
|
|
813
1284
|
outputPath,
|