deepline 0.3.545 → 0.3.547
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 +13 -0
- package/dist/bundling-sources/sdk/src/errors.ts +1 -1
- package/dist/bundling-sources/sdk/src/http-core.ts +41 -12
- package/dist/bundling-sources/sdk/src/index.ts +7 -1
- package/dist/bundling-sources/sdk/src/integrations.ts +17 -7
- package/dist/bundling-sources/sdk/src/play.ts +71 -0
- package/dist/bundling-sources/sdk/src/release.ts +1 -1
- package/dist/bundling-sources/sdk/src/runs/watch-polling.ts +13 -4
- package/dist/bundling-sources/sdk/src/types.ts +33 -0
- package/dist/bundling-sources/shared_libs/integration-contracts/calendar-delegation.ts +7 -0
- package/dist/bundling-sources/shared_libs/monitors/provider-monitor-batch-operation.ts +2 -0
- package/dist/bundling-sources/shared_libs/monitors/tracking-provider-guidance.ts +1 -0
- package/dist/bundling-sources/shared_libs/observability/scheduled-jobs.json +21 -3
- package/dist/bundling-sources/shared_libs/play-data-plane/contracts.ts +5 -0
- package/dist/bundling-sources/shared_libs/play-data-plane/r2.ts +17 -2
- package/dist/bundling-sources/shared_libs/play-data-plane/sheet-contract.ts +27 -0
- package/dist/bundling-sources/shared_libs/play-runtime/async-operation.ts +57 -5
- package/dist/bundling-sources/shared_libs/play-runtime/context.ts +299 -52
- package/dist/bundling-sources/shared_libs/play-runtime/ctx-types.ts +18 -1
- package/dist/bundling-sources/shared_libs/play-runtime/docflow-decision-tracker.ts +135 -0
- package/dist/bundling-sources/shared_libs/play-runtime/docflow-fail-open.ts +177 -0
- package/dist/bundling-sources/shared_libs/play-runtime/docflow-node-io.ts +99 -2
- package/dist/bundling-sources/shared_libs/play-runtime/durable-runs-rollout.ts +16 -10
- package/dist/bundling-sources/shared_libs/play-runtime/fenced-call-diagnostics.ts +211 -0
- package/dist/bundling-sources/shared_libs/play-runtime/fleet-sandbox-sweep.ts +40 -3
- package/dist/bundling-sources/shared_libs/play-runtime/modal-runtime-config.ts +19 -3
- package/dist/bundling-sources/shared_libs/play-runtime/runner-app/index.ts +18 -4
- package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/modal.ts +441 -103
- package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/early-sandbox-egress.ts +322 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/early-sandbox.ts +200 -64
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-capacity-policy.ts +52 -14
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-speed-profile.ts +65 -2
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backend.ts +5 -3
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-runtime-worker.ts +53 -2
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/early-sandbox-lane.ts +206 -12
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres-progress.ts +18 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres.ts +68 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-sandbox-capacity.ts +11 -3
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-worker-wake.ts +30 -2
- package/dist/bundling-sources/shared_libs/play-runtime/tool-cache-policy.ts +9 -1
- package/dist/bundling-sources/shared_libs/play-runtime/tool-result.ts +48 -0
- package/dist/bundling-sources/shared_libs/plays/authoring-contract.ts +36 -2
- package/dist/bundling-sources/shared_libs/plays/bundling/index.ts +716 -51
- package/dist/bundling-sources/shared_libs/plays/docflow-decision-arms.ts +146 -0
- package/dist/bundling-sources/shared_libs/plays/docflow-flow-order.ts +94 -0
- package/dist/bundling-sources/shared_libs/plays/docflow-unreached-reason.ts +10 -1
- package/dist/bundling-sources/shared_libs/plays/docflow.ts +787 -117
- package/dist/bundling-sources/shared_libs/plays/share/static-pipeline-summary.ts +8 -2
- package/dist/bundling-sources/shared_libs/plays/static-pipeline.ts +41 -2
- package/dist/bundling-sources/shared_libs/plays/trigger-config-contract.ts +13 -0
- package/dist/bundling-sources/shared_libs/product-notifications/billing-sales.ts +25 -0
- package/dist/bundling-sources/shared_libs/security/email-blacklist.ts +35 -1
- package/dist/bundling-sources/shared_libs/security/email-domain.ts +19 -0
- package/dist/bundling-sources/shared_libs/security/secret-redaction.ts +58 -0
- package/dist/cli/auth-AC5277PI.js +43 -0
- package/dist/cli/{auth-VZAMAMFW.mjs → auth-WJEY4IDX.mjs} +6 -6
- package/dist/cli/{billing-ASZJDFH2.js → billing-IJITDDRQ.js} +99 -99
- package/dist/cli/{billing-DADQUQEZ.mjs → billing-PHJUDYF3.mjs} +11 -11
- package/dist/cli/{chunk-FB7UPZ6M.js → chunk-2AHY47SI.js} +3 -3
- package/dist/cli/{chunk-CJ7DBYEQ.js → chunk-2HPTLBNB.js} +8 -8
- package/dist/cli/{chunk-TI6DTURF.js → chunk-4WAM6TLD.js} +7 -1
- package/dist/cli/{chunk-LTCEZWPZ.mjs → chunk-56MEAGWA.mjs} +2 -2
- package/dist/cli/{chunk-YWTRCKGD.mjs → chunk-5SFHPMBY.mjs} +11 -11
- package/dist/cli/{chunk-D3SXB2NX.js → chunk-ABLTVG3J.js} +41 -41
- package/dist/cli/{chunk-KRW727W6.mjs → chunk-AEQ5VWZ5.mjs} +4 -4
- package/dist/cli/{chunk-Z7QM244Q.mjs → chunk-CKIRKYW7.mjs} +3 -3
- package/dist/cli/{chunk-2JHYYB3F.js → chunk-CSPHSNBW.js} +3 -3
- package/dist/cli/{chunk-OGQYAJSO.js → chunk-D6OIEH47.js} +5 -5
- package/dist/cli/{chunk-2HFSYH7V.mjs → chunk-DIUNDLSX.mjs} +2 -2
- package/dist/cli/{chunk-3M2QH3KA.mjs → chunk-DJI5CLLW.mjs} +22 -12
- package/dist/cli/{chunk-N4LADLCO.js → chunk-DZC7LMYM.js} +6 -6
- package/dist/cli/{chunk-CXETRZ3G.js → chunk-E2OIYPB4.js} +10 -10
- package/dist/cli/{chunk-Z4Y4BLW7.mjs → chunk-ECUD4QPD.mjs} +3 -3
- package/dist/cli/{chunk-2GJZLIKW.js → chunk-EITMD3A5.js} +1 -1
- package/dist/cli/{chunk-NAN3A4IF.mjs → chunk-ESCVHDNY.mjs} +5 -5
- package/dist/cli/{chunk-C6XYSTBW.js → chunk-FFBXLFKV.js} +1 -1
- package/dist/cli/{chunk-HLUNTJBO.mjs → chunk-FMQXAOVE.mjs} +4 -4
- package/dist/cli/{chunk-HXIR3VQL.mjs → chunk-FZHMNK6F.mjs} +7 -1
- package/dist/cli/{chunk-4NZ3OZNO.mjs → chunk-G6KW764N.mjs} +1 -1
- package/dist/cli/{chunk-LWPFMYSO.mjs → chunk-G6XTCG3J.mjs} +2 -2
- package/dist/cli/{chunk-NCX2JH2F.js → chunk-GIGAYLY6.js} +12 -12
- package/dist/cli/{chunk-BLYW6FFB.js → chunk-GJA2PRHJ.js} +2 -2
- package/dist/cli/{chunk-G5TV6WLV.js → chunk-GJOGFWX3.js} +20 -20
- package/dist/cli/{chunk-7MFATEUC.mjs → chunk-GPAWLXW3.mjs} +2 -2
- package/dist/cli/{chunk-DZTVDL2X.js → chunk-GZFZZQL4.js} +289 -268
- package/dist/cli/{chunk-XBYQZEUE.mjs → chunk-HARZ4AAX.mjs} +1 -1
- package/dist/cli/{chunk-QI57XUGA.js → chunk-HFIFKP3A.js} +5 -5
- package/dist/cli/{chunk-WP36UBRY.mjs → chunk-IGAK22XO.mjs} +1 -1
- package/dist/cli/{chunk-XMUPZINS.mjs → chunk-IKYN6PLO.mjs} +5 -5
- package/dist/cli/{chunk-HPX7LLAM.mjs → chunk-ITLZBDSR.mjs} +3 -3
- package/dist/cli/{chunk-QM7PHHYZ.js → chunk-IVFFCAV2.js} +44 -44
- package/dist/cli/{chunk-IYJO3RWR.js → chunk-K3GMDSUX.js} +5 -5
- package/dist/cli/{chunk-EK5C2R7S.js → chunk-L5J6UJ2X.js} +15 -15
- package/dist/cli/{chunk-EWA3M54M.mjs → chunk-L6QE2XVM.mjs} +1 -1
- package/dist/cli/{chunk-3NG43NXB.js → chunk-LMLSOHTU.js} +53 -53
- package/dist/cli/{chunk-7MHBJU73.js → chunk-MBQELFL7.js} +22 -22
- package/dist/cli/{chunk-Z7SXGOIQ.mjs → chunk-MF7PCM6C.mjs} +1 -1
- package/dist/cli/{chunk-DGKDCZGC.js → chunk-MO7TGNXB.js} +13 -13
- package/dist/cli/{chunk-7P72EGLK.mjs → chunk-MOZEAGSR.mjs} +1 -1
- package/dist/cli/{chunk-34UKDHRL.js → chunk-N63U5CRG.js} +26 -26
- package/dist/cli/{chunk-5YYWZ43J.js → chunk-NBYFQZ6O.js} +2 -2
- package/dist/cli/{chunk-CQBIO6HW.mjs → chunk-NURW5XH4.mjs} +1 -1
- package/dist/cli/{chunk-TQKHXMV3.js → chunk-OVYXYTEP.js} +16 -16
- package/dist/cli/{chunk-XGEUPU3L.mjs → chunk-PBMO36BP.mjs} +2 -2
- package/dist/cli/{chunk-4JQEAYN3.js → chunk-PVQCX6KQ.js} +55 -8
- package/dist/cli/{chunk-KYO2FICL.mjs → chunk-QLE3QKJ2.mjs} +5 -5
- package/dist/cli/{chunk-2FF3O2Y2.js → chunk-QU3K3IY6.js} +12 -12
- package/dist/cli/{chunk-HR5BT42R.js → chunk-REAFIEV5.js} +99 -99
- package/dist/cli/{chunk-Y3T5GWYK.mjs → chunk-RMCCB3XY.mjs} +55 -8
- package/dist/cli/{chunk-3TCHX7YK.mjs → chunk-RXRC2COC.mjs} +2 -2
- package/dist/cli/{chunk-YRQKRQDU.js → chunk-SAJWYN4B.js} +36 -26
- package/dist/cli/{chunk-JL5JU3LD.mjs → chunk-TNJG4ZPN.mjs} +3 -3
- package/dist/cli/{chunk-NZDZGK35.js → chunk-VNOQEDVC.js} +7 -7
- package/dist/cli/{chunk-2CBX43LP.mjs → chunk-VPF54TXQ.mjs} +5 -5
- package/dist/cli/{chunk-2HSZCQMT.mjs → chunk-WYT3H6JD.mjs} +1 -1
- package/dist/cli/{chunk-GWDPNOA7.mjs → chunk-XMBVHJPR.mjs} +29 -8
- package/dist/cli/{chunk-52C6W7FG.mjs → chunk-XNTDTAKC.mjs} +1 -1
- package/dist/cli/{chunk-ERLW6RPA.js → chunk-YURGAKI3.js} +2 -2
- package/dist/cli/{chunk-GFRJU2KB.js → chunk-YVKLF7RW.js} +2 -2
- package/dist/cli/{chunk-7JZ27AFH.mjs → chunk-Z2YGQZWV.mjs} +2 -2
- package/dist/cli/command-docs.js +2 -2
- package/dist/cli/command-docs.mjs +1 -1
- package/dist/cli/{concurrent-runs-help-YP7ALTDB.mjs → concurrent-runs-help-ZNGP563R.mjs} +7 -7
- package/dist/cli/concurrent-runs-help-ZYISYOQA.js +21 -0
- package/dist/cli/{csv-D5ITFSYI.mjs → csv-VAHQHYYV.mjs} +5 -5
- package/dist/cli/{csv-67WT5EGR.js → csv-X6D4ZELE.js} +14 -14
- package/dist/cli/{db-SZYBRFYG.mjs → db-4G4S2VOV.mjs} +8 -8
- package/dist/cli/{db-GZS76X7R.js → db-YA5ZGVEX.js} +33 -33
- package/dist/cli/{describe-YJ7ZLLLI.mjs → describe-EVXEM2S6.mjs} +20 -20
- package/dist/cli/describe-GYYSLZLV.js +50 -0
- package/dist/cli/describe-core.d.mts +4 -4
- package/dist/cli/describe-core.d.ts +4 -4
- package/dist/cli/describe-core.js +1 -1
- package/dist/cli/describe-core.mjs +1 -1
- package/dist/cli/{executions-O5USTYGL.js → executions-5YC7ABF6.js} +10 -10
- package/dist/cli/{executions-HMYGR32E.mjs → executions-HR6CTN5M.mjs} +8 -8
- package/dist/cli/{feedback-Z3NXWYUO.mjs → feedback-GEU5SPLR.mjs} +7 -7
- package/dist/cli/{feedback-RHLFDCRS.js → feedback-MJHSYLFF.js} +15 -15
- package/dist/cli/git-FZIQZNI4.js +25 -0
- package/dist/cli/{git-CLFKXELB.mjs → git-NPFF6QUS.mjs} +6 -6
- package/dist/cli/index.js +150 -150
- package/dist/cli/index.mjs +46 -46
- package/dist/cli/{integrations-TZ4QEQGV.js → integrations-YPHFI77G.js} +20 -18
- package/dist/cli/{integrations-FOACOBQB.mjs → integrations-Z7EGVBHF.mjs} +12 -10
- package/dist/cli/{legacy-noops-QRDOS33V.js → legacy-noops-246E3KKG.js} +10 -10
- package/dist/cli/{legacy-noops-6F6Y3BV7.mjs → legacy-noops-5IYCFWWX.mjs} +7 -7
- package/dist/cli/{mcp-UXRCWOZU.mjs → mcp-WUYGZXPI.mjs} +5 -5
- package/dist/cli/{mcp-ETMMDDGB.js → mcp-YTYTW67G.js} +25 -25
- package/dist/cli/{monitors-6XEWR46R.mjs → monitors-73DQKCU7.mjs} +27 -9
- package/dist/cli/{monitors-DITT7QTV.js → monitors-SA6ILD6Z.js} +121 -103
- package/dist/cli/{org-CVSSH73G.mjs → org-WVQRB2KX.mjs} +8 -8
- package/dist/cli/{org-4DE37X3L.js → org-X7ELDV7B.js} +90 -90
- package/dist/cli/{play-Y5NCHOKK.mjs → play-QI6V2EUQ.mjs} +296 -68
- package/dist/cli/{play-RH6P45CI.js → play-QTYOAJPE.js} +898 -670
- package/dist/cli/{providers-VHUHC4IZ.mjs → providers-DPVMVDS4.mjs} +8 -8
- package/dist/cli/{providers-DU42DLOL.js → providers-XXFLVREV.js} +11 -11
- package/dist/cli/{quickstart-XJ43JLEC.js → quickstart-33ISXQJU.js} +7 -7
- package/dist/cli/{quickstart-HJY5YYE5.mjs → quickstart-YWGNHULM.mjs} +5 -5
- package/dist/cli/{run-JXUS7QFI.js → run-BWHZXLTD.js} +46 -46
- package/dist/cli/{run-JAIXHVH7.mjs → run-J6FCAKQC.mjs} +26 -26
- package/dist/cli/search-JCWJX2XD.js +32 -0
- package/dist/cli/{search-RDMNM2AX.mjs → search-Z3UU3WBB.mjs} +9 -9
- package/dist/cli/{search-output-ZKTR3WTJ.mjs → search-output-OJYY4J7E.mjs} +5 -5
- package/dist/cli/{search-output-RKAM2HBH.js → search-output-YIPV74ME.js} +7 -7
- package/dist/cli/{secrets-TKFVMAYX.js → secrets-UXRJCEN4.js} +17 -17
- package/dist/cli/{secrets-WSW3FTF6.mjs → secrets-YZZN2WST.mjs} +8 -8
- package/dist/cli/{sessions-724BK6VP.mjs → sessions-ITCGPD7Z.mjs} +7 -7
- package/dist/cli/sessions-NA4SJH6Q.js +22 -0
- package/dist/cli/{settings-5LJZDAZU.js → settings-LAFYMILP.js} +87 -87
- package/dist/cli/{settings-YRC7J75G.mjs → settings-ZP2LSVNM.mjs} +14 -14
- package/dist/cli/{setup-2F3DBSOS.js → setup-4AL3XYM5.js} +50 -50
- package/dist/cli/{setup-STNPX5MK.mjs → setup-WEQAQSYC.mjs} +10 -10
- package/dist/cli/{skills-D5PK56FO.mjs → skills-NQH4HFW2.mjs} +8 -8
- package/dist/cli/skills-XZ4Y6SZ7.js +36 -0
- package/dist/cli/{tools-WOGWMBA3.mjs → tools-CXK2GSI4.mjs} +19 -19
- package/dist/cli/tools-WJQ6Y7E4.js +57 -0
- package/dist/cli/{update-PC6XSWMI.mjs → update-3ROF3Z75.mjs} +10 -10
- package/dist/cli/update-ZLRLTBRD.js +34 -0
- package/dist/cli/{views-IIHT4RYQ.mjs → views-AOUHVGV2.mjs} +8 -8
- package/dist/cli/{views-HLCLAPWN.js → views-XJFO5CEH.js} +23 -23
- package/dist/cli/{workflow-CCZ2A7DI.js → workflow-GY3DBHXX.js} +19 -19
- package/dist/cli/{workflow-HK4MZ7LK.mjs → workflow-KBS2QJK6.mjs} +9 -9
- package/dist/{client-DfdUc_MY.d.mts → client-D1uWA2Vc.d.mts} +1 -1
- package/dist/{client-BQ6yuSjM.d.ts → client-Hz7SsBXs.d.ts} +1 -1
- package/dist/{client-core-3GQ8WMuk.d.ts → client-core-D3Ad7Flt.d.ts} +554 -504
- package/dist/{client-core-ClsNRytk.d.mts → client-core-Db_e63Hb.d.mts} +554 -504
- package/dist/{compiler-manifest-BWFtsQIC.d.mts → compiler-manifest-BqwVrOri.d.mts} +73 -18
- package/dist/{compiler-manifest-BWFtsQIC.d.ts → compiler-manifest-BqwVrOri.d.ts} +73 -18
- package/dist/{errors-Lm9_vJHZ.d.ts → errors-BU8FB99X.d.mts} +2 -2
- package/dist/{errors-CwKXXtuu.d.mts → errors-DfVN_FUG.d.ts} +2 -2
- package/dist/{index-3vJ-V9yw.d.ts → index-BGnvtYGc.d.ts} +6 -1
- package/dist/{index-DjwsAt82.d.mts → index-DjZgwpGw.d.mts} +6 -1
- package/dist/index.d.mts +28 -8
- package/dist/index.d.ts +28 -8
- package/dist/index.js +65 -40
- package/dist/index.mjs +33 -8
- package/dist/install-integrity.json +137 -130
- package/dist/plays/bundle-play-file.d.mts +3 -3
- package/dist/plays/bundle-play-file.d.ts +3 -3
- package/dist/plays/bundle-play-file.mjs +640 -125
- package/dist/plays/play-description.d.mts +3 -3
- package/dist/plays/play-description.d.ts +3 -3
- 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 +11 -11
- package/dist/server.mjs +5 -5
- package/package.json +1 -1
- package/dist/cli/auth-455MB4K6.js +0 -43
- package/dist/cli/concurrent-runs-help-GFWXOKF5.js +0 -21
- package/dist/cli/describe-ZRGYAEBT.js +0 -50
- package/dist/cli/git-RC4XDATD.js +0 -25
- package/dist/cli/search-O5VVMXII.js +0 -32
- package/dist/cli/sessions-3PWFWCHO.js +0 -22
- package/dist/cli/skills-RFOMVXIT.js +0 -36
- package/dist/cli/tools-CAO6EVUW.js +0 -57
- package/dist/cli/update-L4DQZY3G.js +0 -34
|
@@ -22,7 +22,10 @@ import {
|
|
|
22
22
|
loadModalClientConfig,
|
|
23
23
|
loadModalRequiredConfig,
|
|
24
24
|
resolveModalSandboxMemoryPolicy,
|
|
25
|
+
resolveModalSandboxNetworkPolicy,
|
|
26
|
+
ModalSandboxAllowlistRequiredError,
|
|
25
27
|
isModalPreviewEvaluation,
|
|
28
|
+
MODAL_SANDBOX_REGIONS,
|
|
26
29
|
withModalCallSignal,
|
|
27
30
|
} from '../../modal-runtime-config';
|
|
28
31
|
import type { PlaySandboxRuntimeLimits } from '../../../plays/sandbox-runtime-limits';
|
|
@@ -102,6 +105,17 @@ import {
|
|
|
102
105
|
type EarlySandboxStartRequest,
|
|
103
106
|
type EarlySandboxSweepOutcome,
|
|
104
107
|
} from '../early-sandbox';
|
|
108
|
+
import {
|
|
109
|
+
assertEarlySandboxEgress,
|
|
110
|
+
earlySandboxEgressKey,
|
|
111
|
+
earlySandboxEnvironment,
|
|
112
|
+
earlySandboxGatewayHosts,
|
|
113
|
+
EarlySandboxEnvironmentError,
|
|
114
|
+
EarlySandboxGatewayAddressWatch,
|
|
115
|
+
type EarlySandboxEgressRefusal,
|
|
116
|
+
type EarlySandboxEnvironment,
|
|
117
|
+
type EarlySandboxScope,
|
|
118
|
+
} from '../early-sandbox-egress';
|
|
105
119
|
|
|
106
120
|
const MODAL_RUNNER_READY_TIMEOUT_MS =
|
|
107
121
|
RUNTIME_RELIABILITY_POLICY.sandbox.runnerReadyTimeoutMs;
|
|
@@ -1021,6 +1035,137 @@ const MODAL_SUPERVISOR_READY_TIMEOUT_MS = 30_000;
|
|
|
1021
1035
|
/** The `modal_sidecar` profile's default sandbox region (us-east). */
|
|
1022
1036
|
const MODAL_SUPERVISOR_DEFAULT_REGIONS = ['us-east'];
|
|
1023
1037
|
|
|
1038
|
+
/**
|
|
1039
|
+
* A Modal sandbox's network placement. Under the modal_sidecar profile the
|
|
1040
|
+
* runner has no outbound network at all (the supervisor sidecar is its only
|
|
1041
|
+
* peer) and runs in the profile's regions. Otherwise it carries the
|
|
1042
|
+
* deployment's outbound allowlist (absent: OPEN egress, which Production
|
|
1043
|
+
* refuses at config load) and runs in `MODAL_SANDBOX_REGIONS` (us-east).
|
|
1044
|
+
*/
|
|
1045
|
+
export function modalSandboxNetworkParams(input: {
|
|
1046
|
+
supervisorSidecar: boolean;
|
|
1047
|
+
outboundCidrAllowlist: string[] | null;
|
|
1048
|
+
}): { outboundCidrAllowlist?: string[]; regions?: string[] } {
|
|
1049
|
+
if (input.supervisorSidecar)
|
|
1050
|
+
return {
|
|
1051
|
+
outboundCidrAllowlist: [],
|
|
1052
|
+
regions:
|
|
1053
|
+
modalSupervisorLaunch().regions ?? MODAL_SUPERVISOR_DEFAULT_REGIONS,
|
|
1054
|
+
};
|
|
1055
|
+
// Unpinned, Modal places a sandbox anywhere in the world; every Play
|
|
1056
|
+
// sandbox runs in us-east, beside the iad gateways and relay.
|
|
1057
|
+
return input.outboundCidrAllowlist
|
|
1058
|
+
? {
|
|
1059
|
+
outboundCidrAllowlist: input.outboundCidrAllowlist,
|
|
1060
|
+
regions: [...MODAL_SANDBOX_REGIONS],
|
|
1061
|
+
}
|
|
1062
|
+
: { regions: [...MODAL_SANDBOX_REGIONS] };
|
|
1063
|
+
}
|
|
1064
|
+
|
|
1065
|
+
export type ModalSandboxCreateParams = {
|
|
1066
|
+
cpu: number;
|
|
1067
|
+
cpuLimit: number;
|
|
1068
|
+
timeoutMs: number;
|
|
1069
|
+
idleTimeoutMs: number;
|
|
1070
|
+
workdir: string;
|
|
1071
|
+
memoryMiB: number;
|
|
1072
|
+
memoryLimitMiB: number;
|
|
1073
|
+
outboundCidrAllowlist?: string[];
|
|
1074
|
+
regions?: string[];
|
|
1075
|
+
};
|
|
1076
|
+
|
|
1077
|
+
/**
|
|
1078
|
+
* The one builder of a run sandbox's create parameters (all but its tags),
|
|
1079
|
+
* shared by the ordinary create and the early (E2) create so egress, CPU,
|
|
1080
|
+
* memory and regions cannot drift between a sandbox and the launch that
|
|
1081
|
+
* adopts it. CPU is the billed `physicalCpuCores` unless the modal_sidecar
|
|
1082
|
+
* profile overrides it.
|
|
1083
|
+
*/
|
|
1084
|
+
export function modalSandboxCreateParams(input: {
|
|
1085
|
+
limits: PlaySandboxRuntimeLimits;
|
|
1086
|
+
memoryPolicy: { reservationMemoryMiB: number; memoryLimitMiB: number };
|
|
1087
|
+
workdir: string;
|
|
1088
|
+
outboundCidrAllowlist: string[] | null;
|
|
1089
|
+
supervisorSidecar: boolean;
|
|
1090
|
+
}): ModalSandboxCreateParams {
|
|
1091
|
+
const resources = modalSandboxResourcesForPlay(input.limits);
|
|
1092
|
+
const cpu =
|
|
1093
|
+
(input.supervisorSidecar && modalSupervisorLaunch().cpu) ||
|
|
1094
|
+
resources.physicalCpuCores;
|
|
1095
|
+
const lifetimeMs = modalSandboxLifetimeMs(input.limits);
|
|
1096
|
+
return {
|
|
1097
|
+
cpu,
|
|
1098
|
+
cpuLimit: cpu,
|
|
1099
|
+
timeoutMs: lifetimeMs,
|
|
1100
|
+
idleTimeoutMs: lifetimeMs,
|
|
1101
|
+
workdir: input.workdir,
|
|
1102
|
+
memoryMiB: input.memoryPolicy.reservationMemoryMiB,
|
|
1103
|
+
memoryLimitMiB: input.memoryPolicy.memoryLimitMiB,
|
|
1104
|
+
...modalSandboxNetworkParams(input),
|
|
1105
|
+
};
|
|
1106
|
+
}
|
|
1107
|
+
|
|
1108
|
+
/**
|
|
1109
|
+
* The early create's parameters: the ordinary ones, with the orphan guard's
|
|
1110
|
+
* short idle timeout (an unadopted early sandbox runs no command and ends
|
|
1111
|
+
* after this window; PB runs one, and the exact-id reaper ends that sandbox).
|
|
1112
|
+
*/
|
|
1113
|
+
export function earlyModalSandboxCreateParams(
|
|
1114
|
+
input: Parameters<typeof modalSandboxCreateParams>[0],
|
|
1115
|
+
): ModalSandboxCreateParams {
|
|
1116
|
+
return {
|
|
1117
|
+
...modalSandboxCreateParams(input),
|
|
1118
|
+
idleTimeoutMs: EARLY_SANDBOX_IDLE_TIMEOUT_MS,
|
|
1119
|
+
};
|
|
1120
|
+
}
|
|
1121
|
+
|
|
1122
|
+
/**
|
|
1123
|
+
* The early-sandbox scope (environment, egress) of a create's parameters.
|
|
1124
|
+
* `environment`, when given, is one the caller already resolved (the ordinary
|
|
1125
|
+
* launch resolves it before its circuit probe); otherwise it is read from
|
|
1126
|
+
* `env` and an unknown value throws.
|
|
1127
|
+
*/
|
|
1128
|
+
export function modalSandboxCreateScope(
|
|
1129
|
+
params: Pick<ModalSandboxCreateParams, 'outboundCidrAllowlist'>,
|
|
1130
|
+
options: {
|
|
1131
|
+
environment?: EarlySandboxEnvironment;
|
|
1132
|
+
env?: Readonly<Record<string, string | undefined>>;
|
|
1133
|
+
} = {},
|
|
1134
|
+
): EarlySandboxScope {
|
|
1135
|
+
return {
|
|
1136
|
+
environment:
|
|
1137
|
+
options.environment ??
|
|
1138
|
+
earlySandboxEnvironment(options.env ?? process.env),
|
|
1139
|
+
egressKey: earlySandboxEgressKey(params.outboundCidrAllowlist),
|
|
1140
|
+
};
|
|
1141
|
+
}
|
|
1142
|
+
|
|
1143
|
+
/**
|
|
1144
|
+
* The ordinary launch's deployment environment, for its cleanup and resource
|
|
1145
|
+
* records: exactly `preview` is Preview, anything else (unset, `native`, a
|
|
1146
|
+
* typo) is Production, as before early sandboxes existed. It never throws;
|
|
1147
|
+
* only the early-sandbox paths refuse an unknown value.
|
|
1148
|
+
*/
|
|
1149
|
+
export function modalLaunchRuntimeEnvironment(
|
|
1150
|
+
env: Readonly<Record<string, string | undefined>> = process.env,
|
|
1151
|
+
): EarlySandboxEnvironment {
|
|
1152
|
+
return env.DEEPLINE_RUNTIME_ENVIRONMENT === 'preview'
|
|
1153
|
+
? 'preview'
|
|
1154
|
+
: 'production';
|
|
1155
|
+
}
|
|
1156
|
+
|
|
1157
|
+
/** The limits an early sandbox's create fixed, which adoption must match. */
|
|
1158
|
+
export function modalSandboxLimitsKey(
|
|
1159
|
+
params: ModalSandboxCreateParams,
|
|
1160
|
+
): string {
|
|
1161
|
+
return earlySandboxLimitsKey({
|
|
1162
|
+
cpu: params.cpu,
|
|
1163
|
+
memoryMiB: params.memoryMiB,
|
|
1164
|
+
memoryLimitMiB: params.memoryLimitMiB,
|
|
1165
|
+
timeoutMs: params.timeoutMs,
|
|
1166
|
+
});
|
|
1167
|
+
}
|
|
1168
|
+
|
|
1024
1169
|
type ModalSupervisorPlan = {
|
|
1025
1170
|
image: Awaited<ReturnType<ModalClient['images']['fromName']>>;
|
|
1026
1171
|
secret: Awaited<ReturnType<ModalClient['secrets']['fromObject']>>;
|
|
@@ -1460,7 +1605,7 @@ export async function startEarlyModalPreboot(input: {
|
|
|
1460
1605
|
}
|
|
1461
1606
|
|
|
1462
1607
|
/**
|
|
1463
|
-
* Reap one early
|
|
1608
|
+
* Reap one early Modal sandbox by exact id if it is still
|
|
1464
1609
|
* unadopted (see reapEarlySandboxById).
|
|
1465
1610
|
*/
|
|
1466
1611
|
export async function reapEarlyModalSandboxById(input: {
|
|
@@ -1483,47 +1628,106 @@ export async function reapEarlyModalSandboxById(input: {
|
|
|
1483
1628
|
export async function sweepOrphanEarlyModalSandboxes(input: {
|
|
1484
1629
|
client: Pick<ModalClient, 'sandboxes'>;
|
|
1485
1630
|
modalAppId: string;
|
|
1631
|
+
environment: EarlySandboxScope['environment'];
|
|
1632
|
+
/** This process's early sandboxes; the module registry unless injected. */
|
|
1633
|
+
registry?: Pick<EarlyModalSandboxRegistry, 'settle'>;
|
|
1486
1634
|
nowMs?: () => number;
|
|
1487
1635
|
sleep?: (ms: number) => Promise<void>;
|
|
1488
1636
|
limit?: number;
|
|
1489
1637
|
}): Promise<EarlySandboxSweepOutcome> {
|
|
1490
1638
|
return await sweepOrphanEarlySandboxes({
|
|
1491
1639
|
calls: earlyModalSandboxCalls(input),
|
|
1640
|
+
environment: input.environment,
|
|
1641
|
+
registry: input.registry ?? earlyModalSandboxes,
|
|
1492
1642
|
...(input.nowMs === undefined ? {} : { nowMs: input.nowMs }),
|
|
1493
1643
|
...(input.sleep === undefined ? {} : { sleep: input.sleep }),
|
|
1494
1644
|
...(input.limit === undefined ? {} : { limit: input.limit }),
|
|
1495
1645
|
});
|
|
1496
1646
|
}
|
|
1497
1647
|
|
|
1648
|
+
function isModalNotFoundError(error: unknown): boolean {
|
|
1649
|
+
return error instanceof Error && error.name === 'NotFoundError';
|
|
1650
|
+
}
|
|
1651
|
+
|
|
1498
1652
|
/**
|
|
1499
|
-
* The
|
|
1500
|
-
*
|
|
1501
|
-
*
|
|
1653
|
+
* The sweep's Modal app id, per client and app name, for this process: each
|
|
1654
|
+
* pass within the TTL is one listing, not an app lookup plus a listing. The
|
|
1655
|
+
* id is re-resolved after the TTL (an app deleted and recreated under the
|
|
1656
|
+
* same name gets a new id, which a stale listing would never see), and a
|
|
1657
|
+
* NotFound (the app was deleted) drops it at once.
|
|
1502
1658
|
*/
|
|
1503
|
-
export
|
|
1659
|
+
export const EARLY_MODAL_SWEEP_APP_ID_TTL_MS = 10 * 60_000;
|
|
1660
|
+
const earlyModalSweepAppIds = new WeakMap<
|
|
1661
|
+
object,
|
|
1662
|
+
Map<string, { appId: string; resolvedAtMs: number }>
|
|
1663
|
+
>();
|
|
1664
|
+
|
|
1665
|
+
/**
|
|
1666
|
+
* The worker's sweep pass over this deployment environment's unadopted early
|
|
1667
|
+
* sandboxes. It runs whether or not the modal_sidecar profile is on: early
|
|
1668
|
+
* sandboxes start without it (behind the egress gate), and a sandbox another
|
|
1669
|
+
* process created must still be reaped after that process is gone. With none
|
|
1670
|
+
* in this environment, the pass is one tag-filtered listing. An unknown
|
|
1671
|
+
* DEEPLINE_RUNTIME_ENVIRONMENT sweeps nothing, loudly.
|
|
1672
|
+
*/
|
|
1673
|
+
export async function sweepOrphanEarlyModalSandboxesForWorker(_input: {
|
|
1504
1674
|
runtimeSchedulerSchema: string | null;
|
|
1505
1675
|
}): Promise<
|
|
1506
|
-
EarlySandboxSweepOutcome | { skipped: '
|
|
1676
|
+
EarlySandboxSweepOutcome | { skipped: 'app_missing' | 'environment_unknown' }
|
|
1507
1677
|
> {
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1678
|
+
let environment: EarlySandboxScope['environment'];
|
|
1679
|
+
try {
|
|
1680
|
+
environment = earlySandboxEnvironment();
|
|
1681
|
+
} catch (error) {
|
|
1682
|
+
if (!(error instanceof EarlySandboxEnvironmentError)) throw error;
|
|
1683
|
+
console.error(
|
|
1684
|
+
JSON.stringify({
|
|
1685
|
+
event: `${EARLY_MODAL_LOG_SCOPE}.sweep_refused`,
|
|
1686
|
+
reason: 'environment_unknown',
|
|
1687
|
+
error: error.message,
|
|
1688
|
+
}),
|
|
1689
|
+
);
|
|
1690
|
+
return { skipped: 'environment_unknown' };
|
|
1691
|
+
}
|
|
1692
|
+
// Client config only: the sweep creates nothing, so it needs no network
|
|
1693
|
+
// policy (whose Production check would otherwise fail every pass).
|
|
1694
|
+
const modalConfig = await loadModalClientConfig();
|
|
1695
|
+
let appIds = earlyModalSweepAppIds.get(modalConfig.client);
|
|
1696
|
+
if (!appIds) {
|
|
1697
|
+
appIds = new Map();
|
|
1698
|
+
earlyModalSweepAppIds.set(modalConfig.client, appIds);
|
|
1699
|
+
}
|
|
1700
|
+
const cached = appIds.get(modalConfig.appName);
|
|
1514
1701
|
let modalAppId: string;
|
|
1702
|
+
if (
|
|
1703
|
+
cached &&
|
|
1704
|
+
Date.now() - cached.resolvedAtMs < EARLY_MODAL_SWEEP_APP_ID_TTL_MS
|
|
1705
|
+
) {
|
|
1706
|
+
modalAppId = cached.appId;
|
|
1707
|
+
} else {
|
|
1708
|
+
appIds.delete(modalConfig.appName);
|
|
1709
|
+
const resolvedAtMs = Date.now();
|
|
1710
|
+
try {
|
|
1711
|
+
modalAppId = (await modalConfig.client.apps.fromName(modalConfig.appName))
|
|
1712
|
+
.appId;
|
|
1713
|
+
} catch (error) {
|
|
1714
|
+
if (isModalNotFoundError(error)) return { skipped: 'app_missing' };
|
|
1715
|
+
throw error;
|
|
1716
|
+
}
|
|
1717
|
+
appIds.set(modalConfig.appName, { appId: modalAppId, resolvedAtMs });
|
|
1718
|
+
}
|
|
1515
1719
|
try {
|
|
1516
|
-
|
|
1517
|
-
.
|
|
1720
|
+
return await sweepOrphanEarlyModalSandboxes({
|
|
1721
|
+
client: modalConfig.client,
|
|
1722
|
+
modalAppId,
|
|
1723
|
+
environment,
|
|
1724
|
+
});
|
|
1518
1725
|
} catch (error) {
|
|
1519
|
-
if (error
|
|
1520
|
-
|
|
1521
|
-
|
|
1726
|
+
if (!isModalNotFoundError(error)) throw error;
|
|
1727
|
+
// The cached app is gone: look it up again next pass.
|
|
1728
|
+
appIds.delete(modalConfig.appName);
|
|
1729
|
+
return { skipped: 'app_missing' };
|
|
1522
1730
|
}
|
|
1523
|
-
return await sweepOrphanEarlyModalSandboxes({
|
|
1524
|
-
client: modalConfig.client,
|
|
1525
|
-
modalAppId,
|
|
1526
|
-
});
|
|
1527
1731
|
}
|
|
1528
1732
|
|
|
1529
1733
|
/**
|
|
@@ -1536,6 +1740,7 @@ async function createEarlyModalSandbox(
|
|
|
1536
1740
|
key: string;
|
|
1537
1741
|
orgId: string;
|
|
1538
1742
|
hintAtMs: number;
|
|
1743
|
+
scope: EarlySandboxScope;
|
|
1539
1744
|
},
|
|
1540
1745
|
): Promise<EarlyModalSandboxEntry> {
|
|
1541
1746
|
const { key, orgId, hintAtMs } = input;
|
|
@@ -1543,7 +1748,7 @@ async function createEarlyModalSandbox(
|
|
|
1543
1748
|
runtimeSchedulerSchema: input.runtimeSchedulerSchema,
|
|
1544
1749
|
limits: null,
|
|
1545
1750
|
});
|
|
1546
|
-
const
|
|
1751
|
+
const supervisorSidecar = DURABLE_RUNS_ROLLOUT.modalSupervisorSidecar;
|
|
1547
1752
|
const memoryPolicy = resolveModalSandboxMemoryPolicy({
|
|
1548
1753
|
limits: modalConfig.limits,
|
|
1549
1754
|
runtimeSchedulerSchema: input.runtimeSchedulerSchema,
|
|
@@ -1587,24 +1792,29 @@ async function createEarlyModalSandbox(
|
|
|
1587
1792
|
),
|
|
1588
1793
|
})
|
|
1589
1794
|
: baseImage;
|
|
1590
|
-
const
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
const earlyParams = {
|
|
1594
|
-
cpu,
|
|
1595
|
-
cpuLimit: cpu,
|
|
1596
|
-
timeoutMs,
|
|
1597
|
-
// Orphan guard: an unadopted early sandbox runs no command and
|
|
1598
|
-
// terminates after this idle window (PB runs one; the exact-id reaper
|
|
1599
|
-
// ends that sandbox, see PREBOOT_RUNNER_IN_EARLY_SANDBOX).
|
|
1600
|
-
idleTimeoutMs: EARLY_SANDBOX_IDLE_TIMEOUT_MS,
|
|
1795
|
+
const earlyParams = earlyModalSandboxCreateParams({
|
|
1796
|
+
limits: modalConfig.limits,
|
|
1797
|
+
memoryPolicy,
|
|
1601
1798
|
workdir: modalConfig.workdir,
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1799
|
+
outboundCidrAllowlist: modalConfig.outboundCidrAllowlist,
|
|
1800
|
+
supervisorSidecar,
|
|
1801
|
+
});
|
|
1802
|
+
// The key names the scope the hint was accepted for; the create must carry
|
|
1803
|
+
// exactly that egress policy, in this environment.
|
|
1804
|
+
const createScope = modalSandboxCreateScope(earlyParams);
|
|
1805
|
+
if (
|
|
1806
|
+
createScope.environment !== input.scope.environment ||
|
|
1807
|
+
createScope.egressKey !== input.scope.egressKey
|
|
1808
|
+
) {
|
|
1809
|
+
throw new Error(
|
|
1810
|
+
`EARLY_MODAL_SANDBOX_SCOPE_CHANGED: the early create's ${
|
|
1811
|
+
createScope.environment !== input.scope.environment
|
|
1812
|
+
? 'environment'
|
|
1813
|
+
: 'egress policy'
|
|
1814
|
+
} differs from the one its key names; no early sandbox was created.`,
|
|
1815
|
+
);
|
|
1816
|
+
}
|
|
1817
|
+
const createRequestedAtMs = Date.now();
|
|
1608
1818
|
// PB: the pre-boot claim rides on the create tags, so no other process
|
|
1609
1819
|
// can see this sandbox without it.
|
|
1610
1820
|
const preboot =
|
|
@@ -1619,12 +1829,9 @@ async function createEarlyModalSandbox(
|
|
|
1619
1829
|
orgId,
|
|
1620
1830
|
workflowId: input.workflowId,
|
|
1621
1831
|
createRequestedAtMs,
|
|
1622
|
-
limitsKey:
|
|
1623
|
-
cpu,
|
|
1624
|
-
memoryMiB: earlyParams.memoryMiB,
|
|
1625
|
-
timeoutMs,
|
|
1626
|
-
}),
|
|
1832
|
+
limitsKey: modalSandboxLimitsKey(earlyParams),
|
|
1627
1833
|
preboot,
|
|
1834
|
+
...input.scope,
|
|
1628
1835
|
});
|
|
1629
1836
|
const createEarly = () =>
|
|
1630
1837
|
modalConfig.client.sandboxes.create(app, image, {
|
|
@@ -1676,6 +1883,7 @@ async function createEarlyModalSandbox(
|
|
|
1676
1883
|
calls: lookups,
|
|
1677
1884
|
key,
|
|
1678
1885
|
sandboxId: sandbox.sandboxId,
|
|
1886
|
+
registry: earlyModalSandboxes,
|
|
1679
1887
|
});
|
|
1680
1888
|
if (preboot) {
|
|
1681
1889
|
earlyModalPreboots.set(
|
|
@@ -1695,13 +1903,17 @@ async function createEarlyModalSandbox(
|
|
|
1695
1903
|
}),
|
|
1696
1904
|
);
|
|
1697
1905
|
}
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1906
|
+
// S1 needs the sidecar profile: without it there is no sidecar to start.
|
|
1907
|
+
const earlySupervisor =
|
|
1908
|
+
supervisorSidecar &&
|
|
1909
|
+
resolveExperimentSwitch(
|
|
1910
|
+
'S1',
|
|
1911
|
+
input.experimentSwitchOverrides,
|
|
1912
|
+
START_SUPERVISOR_WITH_EARLY_SANDBOX,
|
|
1913
|
+
);
|
|
1703
1914
|
// PB's claim rode on the create tags, so it is already on the sandbox.
|
|
1704
|
-
if (preboot)
|
|
1915
|
+
if (preboot)
|
|
1916
|
+
earlyModalForeignAdoptionClaims.set(sandbox, Promise.resolve());
|
|
1705
1917
|
let tags: Record<string, string> = earlyTags;
|
|
1706
1918
|
if (earlySupervisor) {
|
|
1707
1919
|
tags = { ...earlyTags, [EARLY_SUPERVISOR_TAG]: '1' };
|
|
@@ -1747,21 +1959,162 @@ async function createEarlyModalSandbox(
|
|
|
1747
1959
|
return { sandbox, startedAtMs: createRequestedAtMs, tags };
|
|
1748
1960
|
}
|
|
1749
1961
|
|
|
1962
|
+
/** The deployment's outbound allowlist; null when unset. */
|
|
1963
|
+
export type ModalOutboundCidrAllowlistRead = {
|
|
1964
|
+
allowlist: string[] | null;
|
|
1965
|
+
/** Set when reading failed for any reason but an unset allowlist. */
|
|
1966
|
+
error: string | null;
|
|
1967
|
+
};
|
|
1968
|
+
|
|
1969
|
+
/**
|
|
1970
|
+
* The deployment's outbound allowlist. Production refuses an unset one
|
|
1971
|
+
* (`ModalSandboxAllowlistRequiredError`), which reads as unset; any other
|
|
1972
|
+
* failure is returned with its message, and the gate refuses on it.
|
|
1973
|
+
*/
|
|
1974
|
+
export function readModalOutboundCidrAllowlist(input: {
|
|
1975
|
+
runtimeSchedulerSchema: string | null;
|
|
1976
|
+
resolve?: typeof resolveModalSandboxNetworkPolicy;
|
|
1977
|
+
}): ModalOutboundCidrAllowlistRead {
|
|
1978
|
+
const resolve = input.resolve ?? resolveModalSandboxNetworkPolicy;
|
|
1979
|
+
try {
|
|
1980
|
+
return {
|
|
1981
|
+
allowlist: resolve({
|
|
1982
|
+
runtimeSchedulerSchema: input.runtimeSchedulerSchema,
|
|
1983
|
+
}).outboundCidrAllowlist,
|
|
1984
|
+
error: null,
|
|
1985
|
+
};
|
|
1986
|
+
} catch (error) {
|
|
1987
|
+
if (error instanceof ModalSandboxAllowlistRequiredError)
|
|
1988
|
+
return { allowlist: null, error: null };
|
|
1989
|
+
return {
|
|
1990
|
+
allowlist: null,
|
|
1991
|
+
error: error instanceof Error ? error.message : String(error),
|
|
1992
|
+
};
|
|
1993
|
+
}
|
|
1994
|
+
}
|
|
1995
|
+
|
|
1996
|
+
/** The gateways' IPv4 addresses, for the early-sandbox egress gate. */
|
|
1997
|
+
const earlyModalGatewayAddresses = new EarlySandboxGatewayAddressWatch();
|
|
1998
|
+
|
|
1999
|
+
/**
|
|
2000
|
+
* Resolve the gateway addresses now and every 5 minutes, so the first
|
|
2001
|
+
* early-start hint after boot is not refused as `egress_gateway_dns_pending`.
|
|
2002
|
+
* Idempotent. The gate also starts it on first use.
|
|
2003
|
+
*/
|
|
2004
|
+
export function startEarlyModalSandboxEgressWatch(): void {
|
|
2005
|
+
earlyModalGatewayAddresses.start();
|
|
2006
|
+
}
|
|
2007
|
+
|
|
2008
|
+
/**
|
|
2009
|
+
* The fail-closed egress gate for an early sandbox without the sidecar (see
|
|
2010
|
+
* `../early-sandbox-egress.ts`): refuse, loudly, unless the early create's
|
|
2011
|
+
* allowlist is non-empty, no entry is wider than /24, and every resolved IPv4
|
|
2012
|
+
* address of both gateways is covered. A refusal starts nothing; the launch
|
|
2013
|
+
* creates its own sandbox, as today.
|
|
2014
|
+
*/
|
|
2015
|
+
export function earlyModalSandboxEgressRefusal(
|
|
2016
|
+
input: {
|
|
2017
|
+
runtimeSchedulerSchema?: string | null;
|
|
2018
|
+
gateway?: EarlySandboxGatewayAddressWatch;
|
|
2019
|
+
readAllowlist?: () => ModalOutboundCidrAllowlistRead;
|
|
2020
|
+
nowMs?: number;
|
|
2021
|
+
} = {},
|
|
2022
|
+
): EarlySandboxEgressRefusal | null {
|
|
2023
|
+
const gateway = input.gateway ?? earlyModalGatewayAddresses;
|
|
2024
|
+
gateway.start();
|
|
2025
|
+
const read = (
|
|
2026
|
+
input.readAllowlist ??
|
|
2027
|
+
(() =>
|
|
2028
|
+
readModalOutboundCidrAllowlist({
|
|
2029
|
+
runtimeSchedulerSchema: input.runtimeSchedulerSchema ?? null,
|
|
2030
|
+
}))
|
|
2031
|
+
)();
|
|
2032
|
+
return assertEarlySandboxEgress({
|
|
2033
|
+
logScope: EARLY_MODAL_LOG_SCOPE,
|
|
2034
|
+
outboundCidrAllowlist: read.allowlist,
|
|
2035
|
+
allowlistError: read.error,
|
|
2036
|
+
gatewayHosts: earlySandboxGatewayHosts(),
|
|
2037
|
+
gateway: gateway.state(),
|
|
2038
|
+
nowMs: input.nowMs ?? Date.now(),
|
|
2039
|
+
});
|
|
2040
|
+
}
|
|
2041
|
+
|
|
1750
2042
|
/**
|
|
1751
|
-
*
|
|
1752
|
-
*
|
|
2043
|
+
* Why this process may not start an early Modal sandbox now, or null. An
|
|
2044
|
+
* unknown DEEPLINE_RUNTIME_ENVIRONMENT refuses first (nothing is tagged with
|
|
2045
|
+
* a guessed environment); then, without the sidecar, the egress gate.
|
|
2046
|
+
*/
|
|
2047
|
+
export function earlyModalSandboxStartUnavailable(
|
|
2048
|
+
input: Parameters<typeof earlyModalSandboxEgressRefusal>[0] = {},
|
|
2049
|
+
): EarlySandboxEgressRefusal | null {
|
|
2050
|
+
try {
|
|
2051
|
+
earlySandboxEnvironment();
|
|
2052
|
+
} catch (error) {
|
|
2053
|
+
if (!(error instanceof EarlySandboxEnvironmentError)) throw error;
|
|
2054
|
+
console.error(
|
|
2055
|
+
JSON.stringify({
|
|
2056
|
+
event: `${EARLY_MODAL_LOG_SCOPE}.start_refused`,
|
|
2057
|
+
reason: 'environment_unknown',
|
|
2058
|
+
error: error.message,
|
|
2059
|
+
}),
|
|
2060
|
+
);
|
|
2061
|
+
return 'environment_unknown';
|
|
2062
|
+
}
|
|
2063
|
+
return DURABLE_RUNS_ROLLOUT.modalSupervisorSidecar
|
|
2064
|
+
? null
|
|
2065
|
+
: earlyModalSandboxEgressRefusal(input);
|
|
2066
|
+
}
|
|
2067
|
+
|
|
2068
|
+
/**
|
|
2069
|
+
* The environment an ordinary launch adopts an early sandbox under, or null
|
|
2070
|
+
* (one loud line) when DEEPLINE_RUNTIME_ENVIRONMENT is unknown: the launch
|
|
2071
|
+
* then creates its own sandbox, as with E2 off. When known, it equals
|
|
2072
|
+
* modalLaunchRuntimeEnvironment.
|
|
2073
|
+
*/
|
|
2074
|
+
export function earlyModalAdoptionEnvironment(
|
|
2075
|
+
env: Readonly<Record<string, string | undefined>> = process.env,
|
|
2076
|
+
): EarlySandboxEnvironment | null {
|
|
2077
|
+
try {
|
|
2078
|
+
return earlySandboxEnvironment(env);
|
|
2079
|
+
} catch (error) {
|
|
2080
|
+
if (!(error instanceof EarlySandboxEnvironmentError)) throw error;
|
|
2081
|
+
console.error(
|
|
2082
|
+
JSON.stringify({
|
|
2083
|
+
event: `${EARLY_MODAL_LOG_SCOPE}.adoption_refused`,
|
|
2084
|
+
reason: 'environment_unknown',
|
|
2085
|
+
error: error.message,
|
|
2086
|
+
}),
|
|
2087
|
+
);
|
|
2088
|
+
return null;
|
|
2089
|
+
}
|
|
2090
|
+
}
|
|
2091
|
+
|
|
2092
|
+
/**
|
|
2093
|
+
* Modal's early-sandbox Adapter. Under the modal_sidecar profile the early
|
|
2094
|
+
* sandbox has no egress (the sidecar is its only peer). Without it, it
|
|
2095
|
+
* carries the launch's outbound allowlist, behind the egress gate.
|
|
1753
2096
|
*/
|
|
1754
2097
|
export const modalEarlySandboxAdapter: EarlySandboxAdapter<ModalSandbox> = {
|
|
1755
2098
|
provider: 'modal',
|
|
1756
2099
|
logScope: EARLY_MODAL_LOG_SCOPE,
|
|
1757
2100
|
registry: earlyModalSandboxes,
|
|
1758
|
-
startUnavailable: () =>
|
|
1759
|
-
|
|
2101
|
+
startUnavailable: () => earlyModalSandboxStartUnavailable(),
|
|
2102
|
+
scope: (input) => {
|
|
2103
|
+
const read = readModalOutboundCidrAllowlist({
|
|
2104
|
+
runtimeSchedulerSchema: input.runtimeSchedulerSchema,
|
|
2105
|
+
});
|
|
2106
|
+
if (read.error) throw new Error(read.error);
|
|
2107
|
+
return modalSandboxCreateScope(
|
|
2108
|
+
modalSandboxNetworkParams({
|
|
2109
|
+
supervisorSidecar: DURABLE_RUNS_ROLLOUT.modalSupervisorSidecar,
|
|
2110
|
+
outboundCidrAllowlist: read.allowlist,
|
|
2111
|
+
}),
|
|
2112
|
+
);
|
|
2113
|
+
},
|
|
1760
2114
|
createEarly: createEarlyModalSandbox,
|
|
1761
2115
|
sweepOrphansForWorker: sweepOrphanEarlyModalSandboxesForWorker,
|
|
1762
2116
|
};
|
|
1763
2117
|
|
|
1764
|
-
|
|
1765
2118
|
/**
|
|
1766
2119
|
* Adopt this run's early Modal sandbox by exact id, or return null so the
|
|
1767
2120
|
* launch creates its own (see adoptEarlySandbox). A sandbox whose S1 sidecar
|
|
@@ -1771,6 +2124,8 @@ export async function adoptEarlyModalSandbox(input: {
|
|
|
1771
2124
|
client: ModalClient;
|
|
1772
2125
|
modalAppId: string;
|
|
1773
2126
|
workflowId: string;
|
|
2127
|
+
/** This launch's environment and the egress of the create it would make. */
|
|
2128
|
+
scope: EarlySandboxScope;
|
|
1774
2129
|
expectedLimitsKey: string;
|
|
1775
2130
|
createTags: Record<string, string>;
|
|
1776
2131
|
context: PlayRunnerExecutionConfig['context'];
|
|
@@ -1791,6 +2146,7 @@ export async function adoptEarlyModalSandbox(input: {
|
|
|
1791
2146
|
orgId: input.context.orgId,
|
|
1792
2147
|
runId: input.context.runId,
|
|
1793
2148
|
experimentSwitchOverrides: input.context.experimentSwitchOverrides,
|
|
2149
|
+
scope: input.scope,
|
|
1794
2150
|
expectedLimitsKey: input.expectedLimitsKey,
|
|
1795
2151
|
createTags: input.createTags,
|
|
1796
2152
|
preboot: input.preboot,
|
|
@@ -1853,6 +2209,18 @@ export const modalPlayRunnerBackend: PlayRunnerBackend = {
|
|
|
1853
2209
|
// build failure still surfaces where the payload is staged.
|
|
1854
2210
|
const bundlePromise = buildPlayRunnerBundle();
|
|
1855
2211
|
bundlePromise.catch(() => undefined);
|
|
2212
|
+
// Resolved before the circuit probe claim; neither throws. The records'
|
|
2213
|
+
// environment keeps its original mapping; an unknown value only turns
|
|
2214
|
+
// early-sandbox adoption off (loudly), never the launch.
|
|
2215
|
+
const runtimeEnvironment = modalLaunchRuntimeEnvironment();
|
|
2216
|
+
const earlyAdoptionEnvironment =
|
|
2217
|
+
resolveExperimentSwitch(
|
|
2218
|
+
'E2',
|
|
2219
|
+
config.context.experimentSwitchOverrides,
|
|
2220
|
+
EARLY_SANDBOX_START,
|
|
2221
|
+
) && config.context.workflowId
|
|
2222
|
+
? earlyModalAdoptionEnvironment()
|
|
2223
|
+
: null;
|
|
1856
2224
|
const providerCircuitClaim =
|
|
1857
2225
|
await callbacks?.shouldAttemptSandboxProvider?.('modal');
|
|
1858
2226
|
if (providerCircuitClaim && !providerCircuitClaim.allowed) {
|
|
@@ -2038,10 +2406,7 @@ export const modalPlayRunnerBackend: PlayRunnerBackend = {
|
|
|
2038
2406
|
}
|
|
2039
2407
|
await callbacks.onAmbiguousModalCreateIntent({
|
|
2040
2408
|
modalAppId: app.appId,
|
|
2041
|
-
runtimeEnvironment
|
|
2042
|
-
process.env.DEEPLINE_RUNTIME_ENVIRONMENT === 'preview'
|
|
2043
|
-
? 'preview'
|
|
2044
|
-
: 'production',
|
|
2409
|
+
runtimeEnvironment,
|
|
2045
2410
|
tags: createTags,
|
|
2046
2411
|
...(capacityReservation
|
|
2047
2412
|
? { sandboxCapacityLeaseId: capacityReservation.leaseId }
|
|
@@ -2051,52 +2416,31 @@ export const modalPlayRunnerBackend: PlayRunnerBackend = {
|
|
|
2051
2416
|
elapsedMs: Date.now() - startedAt,
|
|
2052
2417
|
});
|
|
2053
2418
|
createSent = true;
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
resources.physicalCpuCores,
|
|
2061
|
-
timeoutMs: modalSandboxLifetimeMs(modalConfig.limits),
|
|
2062
|
-
idleTimeoutMs: modalSandboxLifetimeMs(modalConfig.limits),
|
|
2419
|
+
// The same builder as the early create, so a sandbox this launch
|
|
2420
|
+
// adopts was created with these parameters (its limits key and
|
|
2421
|
+
// egress key say so).
|
|
2422
|
+
const sandboxParams = modalSandboxCreateParams({
|
|
2423
|
+
limits: modalConfig.limits,
|
|
2424
|
+
memoryPolicy,
|
|
2063
2425
|
workdir: modalConfig.workdir,
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
// the supervisor sidecar is its only peer.
|
|
2069
|
-
...(supervisorPlan
|
|
2070
|
-
? {
|
|
2071
|
-
outboundCidrAllowlist: [],
|
|
2072
|
-
regions:
|
|
2073
|
-
modalSupervisorLaunch().regions ??
|
|
2074
|
-
MODAL_SUPERVISOR_DEFAULT_REGIONS,
|
|
2075
|
-
}
|
|
2076
|
-
: modalConfig.outboundCidrAllowlist
|
|
2077
|
-
? { outboundCidrAllowlist: modalConfig.outboundCidrAllowlist }
|
|
2078
|
-
: {}),
|
|
2079
|
-
};
|
|
2426
|
+
outboundCidrAllowlist: modalConfig.outboundCidrAllowlist,
|
|
2427
|
+
supervisorSidecar: supervisorPlan !== null,
|
|
2428
|
+
});
|
|
2429
|
+
const createParams = { ...sandboxParams, tags: createTags };
|
|
2080
2430
|
const createSandbox = () =>
|
|
2081
2431
|
modalConfig.client.sandboxes.create(app, image, createParams);
|
|
2082
2432
|
sandbox = await awaitModalSandboxCreate({
|
|
2083
2433
|
create:
|
|
2084
|
-
|
|
2085
|
-
'E2',
|
|
2086
|
-
config.context.experimentSwitchOverrides,
|
|
2087
|
-
EARLY_SANDBOX_START,
|
|
2088
|
-
) &&
|
|
2089
|
-
supervisorPlan &&
|
|
2090
|
-
config.context.workflowId
|
|
2434
|
+
earlyAdoptionEnvironment && config.context.workflowId
|
|
2091
2435
|
? adoptEarlyModalSandbox({
|
|
2092
2436
|
client: modalConfig.client,
|
|
2093
2437
|
modalAppId: app.appId,
|
|
2094
2438
|
workflowId: config.context.workflowId,
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
timeoutMs: createParams.timeoutMs,
|
|
2439
|
+
// The early create's scope builder, so the two cannot drift.
|
|
2440
|
+
scope: modalSandboxCreateScope(sandboxParams, {
|
|
2441
|
+
environment: earlyAdoptionEnvironment,
|
|
2099
2442
|
}),
|
|
2443
|
+
expectedLimitsKey: modalSandboxLimitsKey(sandboxParams),
|
|
2100
2444
|
createTags,
|
|
2101
2445
|
context: config.context,
|
|
2102
2446
|
preboot: {
|
|
@@ -2131,10 +2475,7 @@ export const modalPlayRunnerBackend: PlayRunnerBackend = {
|
|
|
2131
2475
|
resource: {
|
|
2132
2476
|
kind: 'modal_sandbox',
|
|
2133
2477
|
sandboxId: lateSandbox.sandboxId,
|
|
2134
|
-
runtimeEnvironment
|
|
2135
|
-
process.env.DEEPLINE_RUNTIME_ENVIRONMENT === 'preview'
|
|
2136
|
-
? 'preview'
|
|
2137
|
-
: 'production',
|
|
2478
|
+
runtimeEnvironment,
|
|
2138
2479
|
modalAppId: app.appId,
|
|
2139
2480
|
billingStartedAt: modalCreateRequestedAt,
|
|
2140
2481
|
lateAcquired: true,
|
|
@@ -2335,10 +2676,7 @@ export const modalPlayRunnerBackend: PlayRunnerBackend = {
|
|
|
2335
2676
|
await callbacks?.onRuntimeResourceAcquired?.({
|
|
2336
2677
|
kind: 'modal_sandbox',
|
|
2337
2678
|
sandboxId: sandbox.sandboxId,
|
|
2338
|
-
runtimeEnvironment
|
|
2339
|
-
process.env.DEEPLINE_RUNTIME_ENVIRONMENT === 'preview'
|
|
2340
|
-
? 'preview'
|
|
2341
|
-
: 'production',
|
|
2679
|
+
runtimeEnvironment,
|
|
2342
2680
|
modalAppId: app.appId,
|
|
2343
2681
|
billingStartedAt,
|
|
2344
2682
|
maxBillingDurationSeconds:
|