deepline 0.3.520 → 0.3.521
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/plays/client-core.ts +16 -45
- package/dist/bundling-sources/sdk/src/release.ts +1 -1
- package/dist/bundling-sources/shared_libs/observability/scheduled-jobs.json +0 -18
- package/dist/bundling-sources/shared_libs/play-data-plane/r2.ts +0 -155
- package/dist/bundling-sources/shared_libs/play-runtime/fixture-behavior.ts +24 -0
- package/dist/bundling-sources/shared_libs/play-runtime/internal-bootstrap-token.ts +1 -54
- package/dist/bundling-sources/shared_libs/play-runtime/launch-identity.ts +2 -7
- package/dist/bundling-sources/shared_libs/play-runtime/protocol.ts +0 -13
- package/dist/bundling-sources/shared_libs/play-runtime/run-identity.ts +0 -56
- package/dist/bundling-sources/shared_libs/play-runtime/runner-app/index.ts +10 -21
- package/dist/bundling-sources/shared_libs/play-runtime/runner-app/runtime-heartbeat.ts +1 -1
- package/dist/bundling-sources/shared_libs/play-runtime/runner-app/runtime-progress-push.ts +2 -1
- package/dist/bundling-sources/shared_libs/play-runtime/runner-app/runtime-terminal-push.ts +1 -1
- package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-lifecycle.ts +2 -37
- package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-payload-transport.ts +3 -74
- package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-runtime-watchdog.ts +2 -226
- package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/modal.ts +3 -36
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-api-paths.ts +0 -26
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-api.ts +1 -9
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-authority.ts +0 -5
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-environment.ts +9 -49
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-gateway-oidc.ts +11 -447
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backend.ts +5 -4
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-runtime-worker.ts +12 -207
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-shared.ts +3 -17
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/gateway-progress-registry.ts +0 -9
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres-progress.ts +2 -18
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres.ts +15 -175
- package/dist/bundling-sources/shared_libs/play-runtime/workflow-executor-auth.ts +0 -4
- package/dist/cli/{artifacts-4DSPSIU5.js → artifacts-JGH464N2.js} +20 -20
- package/dist/cli/{artifacts-D6PU7SBC.mjs → artifacts-TYPU37IU.mjs} +8 -8
- package/dist/cli/auth-JWR3VSNT.js +43 -0
- package/dist/cli/{auth-MXKNPUXW.mjs → auth-XPQT6NUB.mjs} +5 -5
- package/dist/cli/{billing-SQ26NKGH.mjs → billing-47AMHOMP.mjs} +8 -8
- package/dist/cli/{billing-WEYCNJIR.js → billing-6D4KXBFJ.js} +81 -81
- package/dist/cli/{chunk-TQTQ3YYA.mjs → chunk-2DQPB5HT.mjs} +5 -5
- package/dist/cli/{chunk-6Y3DDRRN.js → chunk-2KHUFWTK.js} +3 -3
- package/dist/cli/{chunk-2BJILUE3.js → chunk-3Q7HEEH2.js} +10 -10
- package/dist/cli/{chunk-NWSKBWQM.mjs → chunk-4DB6JV7X.mjs} +2 -2
- package/dist/cli/{chunk-M6YHS5V7.mjs → chunk-4GGXAYKI.mjs} +3 -3
- package/dist/cli/{chunk-V6BUWQBI.mjs → chunk-4I7I5CGB.mjs} +1 -1
- package/dist/cli/{chunk-ORAWUIMN.js → chunk-4MN65FRF.js} +53 -53
- package/dist/cli/{chunk-U5646OVV.mjs → chunk-4MONKWYE.mjs} +5 -5
- package/dist/cli/{chunk-KKSMHTQO.mjs → chunk-5T7QKHQL.mjs} +1 -1
- package/dist/cli/{chunk-XXDY7K7F.js → chunk-6DCBTJZP.js} +3 -3
- package/dist/cli/{chunk-LUIPBI6P.js → chunk-6N72GHAV.js} +2 -2
- package/dist/cli/{chunk-ASGGZ6BI.mjs → chunk-6UHYXNCP.mjs} +2 -2
- package/dist/cli/{chunk-YVQLXMJU.mjs → chunk-6V2RI3AL.mjs} +3 -3
- package/dist/cli/{chunk-6GI7BYSL.mjs → chunk-7AUXX6M5.mjs} +1 -1
- package/dist/cli/{chunk-6T2LB43P.mjs → chunk-7IYDCHTG.mjs} +2 -2
- package/dist/cli/{chunk-NNUJQ5O2.mjs → chunk-7LRALARF.mjs} +1 -1
- package/dist/cli/{chunk-5TEXJM6F.mjs → chunk-A2B5AAU3.mjs} +11 -11
- package/dist/cli/{chunk-NLIO6QLP.mjs → chunk-A6USUS4L.mjs} +2 -2
- package/dist/cli/{chunk-3YHS4BLB.js → chunk-AMVKLEPH.js} +2 -2
- package/dist/cli/{chunk-YP3G2CP6.mjs → chunk-CBBCUYIN.mjs} +2 -2
- package/dist/cli/{chunk-QQGRQRCS.mjs → chunk-DQURY3WH.mjs} +1 -1
- package/dist/cli/{chunk-7VJKHJY7.js → chunk-DY6634MN.js} +14 -14
- package/dist/cli/{chunk-XU57CH42.mjs → chunk-E4ZS2B2J.mjs} +1 -1
- package/dist/cli/{chunk-UA4MXESL.js → chunk-EILHJRPW.js} +3 -3
- package/dist/cli/{chunk-AM7HMWNA.js → chunk-EW3EAEWZ.js} +5 -5
- package/dist/cli/{chunk-NPRSGUHB.mjs → chunk-EZNZDOAG.mjs} +5 -5
- package/dist/cli/{chunk-HT675XNR.mjs → chunk-FKD3KL5Q.mjs} +1 -1
- package/dist/cli/{chunk-SHB2BNI6.mjs → chunk-FQJFONFT.mjs} +37 -90
- package/dist/cli/{chunk-FWGTBR3W.js → chunk-FTZX4QZN.js} +2 -2
- package/dist/cli/{chunk-5ECMRQCL.js → chunk-GNYSODBR.js} +1 -1
- package/dist/cli/{chunk-Y5QYWFRI.js → chunk-HD3KYCDC.js} +7 -7
- package/dist/cli/{chunk-6VY2SJ6B.mjs → chunk-HHBJJYKL.mjs} +5 -5
- package/dist/cli/{chunk-DQQ6FDE6.mjs → chunk-HRWVEIAX.mjs} +1 -1
- package/dist/cli/{chunk-BHAP6FIZ.js → chunk-HSFLMTED.js} +4 -4
- package/dist/cli/{chunk-KTAOVRXT.js → chunk-JFQJNYTB.js} +16 -16
- package/dist/cli/{chunk-JO2MQ6XR.js → chunk-LGU2NIOT.js} +98 -98
- package/dist/cli/{chunk-QSWPDYOP.mjs → chunk-LNBMEFOI.mjs} +4 -4
- package/dist/cli/{chunk-GVTHFDKN.js → chunk-MD43YAL6.js} +6 -6
- package/dist/cli/{chunk-AVW2LKRF.js → chunk-MRU4N33M.js} +6 -6
- package/dist/cli/{chunk-2EDGA7OE.mjs → chunk-NNDAVVBG.mjs} +2 -2
- package/dist/cli/{chunk-4VR5OTYP.js → chunk-PUKWFJXW.js} +44 -44
- package/dist/cli/{chunk-VSPNBBRT.js → chunk-QGTWGHYD.js} +66 -119
- package/dist/cli/{chunk-A5VR463F.mjs → chunk-TBIWR7M2.mjs} +1 -1
- package/dist/cli/{chunk-I4GBCKBL.js → chunk-UAZKOH3J.js} +5 -5
- package/dist/cli/{chunk-BMCRTI6Z.mjs → chunk-UBKA33KY.mjs} +1 -22
- package/dist/cli/{chunk-6XJA23MZ.js → chunk-ULW2KBKL.js} +26 -26
- package/dist/cli/{chunk-D5VTWJ7K.js → chunk-VSH3AE5E.js} +16 -16
- package/dist/cli/{chunk-74MOIEDC.js → chunk-VYY5V4M5.js} +11 -11
- package/dist/cli/{chunk-YHHLLONU.js → chunk-WL6WPW6X.js} +14 -14
- package/dist/cli/{chunk-WSGXBROE.js → chunk-XDVT3GOM.js} +1 -22
- package/dist/cli/{chunk-7QAX5VBT.js → chunk-Y23TOHNV.js} +41 -41
- package/dist/cli/{chunk-VSLU4JZV.mjs → chunk-Y7IR4LBU.mjs} +3 -3
- package/dist/cli/{chunk-LYIJ3YUP.js → chunk-YROP3H6T.js} +22 -22
- package/dist/cli/{chunk-KCISDDNK.mjs → chunk-ZO2XJVFH.mjs} +6 -6
- package/dist/cli/{csv-VJNR6FOZ.js → csv-5TM2OSYP.js} +13 -13
- package/dist/cli/{csv-T7HIELZ2.mjs → csv-PM3WDXDF.mjs} +4 -4
- package/dist/cli/{db-JF2I54V7.js → db-3LJ32FZM.js} +29 -29
- package/dist/cli/{db-OE2EXZXL.mjs → db-5P72NPRL.mjs} +8 -8
- package/dist/cli/describe-GRS3IRSX.js +50 -0
- package/dist/cli/{describe-HXZZC3LC.mjs → describe-ZLCMBGHG.mjs} +20 -20
- package/dist/cli/describe-core.d.mts +2 -2
- package/dist/cli/describe-core.d.ts +2 -2
- package/dist/cli/{executions-UQ2H6MJZ.js → executions-4AJ5TQVY.js} +10 -10
- package/dist/cli/{executions-4BXRIJFF.mjs → executions-JMFL6AV7.mjs} +8 -8
- package/dist/cli/{feedback-TXF5CQKA.mjs → feedback-DKMG2QB7.mjs} +5 -5
- package/dist/cli/{feedback-MKFN7DYY.js → feedback-I2BLXMGH.js} +10 -10
- package/dist/cli/git-2LNT43A2.js +25 -0
- package/dist/cli/{git-MG3NAV65.mjs → git-ARG223MY.mjs} +5 -5
- package/dist/cli/index.js +141 -141
- package/dist/cli/index.mjs +43 -43
- package/dist/cli/{legacy-noops-XSDY46XD.mjs → legacy-noops-24LOAOZN.mjs} +6 -6
- package/dist/cli/{legacy-noops-R76I2OWW.js → legacy-noops-N7SVA7PL.js} +9 -9
- package/dist/cli/{monitors-NVT5YQKV.mjs → monitors-RYQFWM2T.mjs} +9 -9
- package/dist/cli/{monitors-FS3DIDM7.js → monitors-XNCYLOJM.js} +102 -102
- package/dist/cli/{org-SBI6FC6D.js → org-I33TKZXF.js} +74 -74
- package/dist/cli/{org-XU7JONWS.mjs → org-ORIH56E5.mjs} +8 -8
- package/dist/cli/{pages-2CZFJJV6.js → pages-2UXXGIMF.js} +20 -20
- package/dist/cli/{pages-AFB5DVBR.mjs → pages-ME43HSBL.mjs} +8 -8
- package/dist/cli/{play-WZH72UGC.js → play-F4QOFU37.js} +338 -338
- package/dist/cli/{play-EQEIT5S4.mjs → play-XEKNY46M.mjs} +21 -21
- package/dist/cli/{providers-SHSVUQA3.js → providers-E7DPCBNX.js} +11 -11
- package/dist/cli/{providers-3VXTATHF.mjs → providers-XKU44G74.mjs} +8 -8
- package/dist/cli/{quickstart-KPVPK3VL.js → quickstart-ICLF2F6A.js} +6 -6
- package/dist/cli/{quickstart-45YS4SOD.mjs → quickstart-J7NVEXV5.mjs} +4 -4
- package/dist/cli/{run-U5RWBX5J.js → run-HJMHUQBN.js} +43 -43
- package/dist/cli/{run-XEHRZT57.mjs → run-MQ5ZONGL.mjs} +25 -25
- package/dist/cli/run-identity-G257GQED.js +25 -0
- package/dist/cli/{run-identity-MNRZS2N3.mjs → run-identity-MRNCEGV2.mjs} +3 -9
- package/dist/cli/{search-V7XIWBQ2.mjs → search-GGRC77CV.mjs} +10 -10
- package/dist/cli/search-V6IBJ4TX.js +33 -0
- package/dist/cli/{search-output-ZNIICV5Z.js → search-output-MXZTZI2P.js} +6 -6
- package/dist/cli/{search-output-3KAJUV2A.mjs → search-output-NY4GDBRU.mjs} +4 -4
- package/dist/cli/{secrets-SCSG3QXJ.mjs → secrets-FA37G4Q2.mjs} +8 -8
- package/dist/cli/{secrets-53TUV6JK.js → secrets-PFESG72B.js} +17 -17
- package/dist/cli/{sessions-MCTHLLK3.mjs → sessions-BLLXPETU.mjs} +6 -6
- package/dist/cli/sessions-DNFTQOQH.js +18 -0
- package/dist/cli/{settings-ZNOXOIX2.js → settings-32VPG4Z2.js} +88 -88
- package/dist/cli/{settings-Q2HKACSE.mjs → settings-U26S7MPH.mjs} +15 -15
- package/dist/cli/{setup-WKM35SZJ.mjs → setup-4AXBCX7C.mjs} +10 -10
- package/dist/cli/{setup-GO4EULLY.js → setup-R6NSENH7.js} +50 -50
- package/dist/cli/skills-G4ZE3OS5.js +37 -0
- package/dist/cli/{skills-DZZLW6OV.mjs → skills-JUH7AVUL.mjs} +8 -8
- package/dist/cli/tools-27LHZFJD.js +57 -0
- package/dist/cli/{tools-EKVSK6X4.mjs → tools-FOYLU3FH.mjs} +19 -19
- package/dist/cli/{update-FPHYVHSC.mjs → update-FUVX22VM.mjs} +10 -10
- package/dist/cli/update-KNZ7N242.js +35 -0
- package/dist/cli/{workflow-27H3NCNY.js → workflow-JACZW4GJ.js} +19 -19
- package/dist/cli/{workflow-5YAZK5EI.mjs → workflow-QLT22BLT.mjs} +9 -9
- package/dist/{client-DhEOE19l.d.ts → client-B-2Am2y6.d.ts} +1 -1
- package/dist/{client-lJmz2QwF.d.mts → client-DA71-2_u.d.mts} +1 -1
- package/dist/{client-core-BGiSMrBD.d.mts → client-core-BXbds1cb.d.mts} +0 -19
- package/dist/{client-core-DYCGaRBZ.d.ts → client-core-C0IzDKMJ.d.ts} +0 -19
- package/dist/index.d.mts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +19 -19
- package/dist/index.mjs +8 -8
- package/dist/install-integrity.json +114 -122
- package/dist/plays/play-description.d.mts +1 -1
- package/dist/plays/play-description.d.ts +1 -1
- package/dist/plays/run-request.d.mts +1 -1
- package/dist/plays/run-request.d.ts +1 -1
- package/dist/plays/run-request.js +3 -3
- package/dist/plays/run-request.mjs +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 +2 -2
- package/dist/server.d.ts +2 -2
- package/dist/server.js +7 -7
- package/dist/server.mjs +5 -5
- package/package.json +1 -1
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-app-transport.ts +0 -374
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-gateway-egress.ts +0 -55
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-gateway-profile.ts +0 -329
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-gateway-sandbox-credential.ts +0 -338
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-gateway-staging.ts +0 -417
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-gateway-attempt.ts +0 -81
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-gateway-staging-journal.ts +0 -708
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-gateway-staging-teardown.ts +0 -160
- package/dist/cli/auth-TH4JV6BH.js +0 -43
- package/dist/cli/describe-4FLGKRCA.js +0 -50
- package/dist/cli/git-B2QO3SLK.js +0 -25
- package/dist/cli/run-identity-HFYABUJS.js +0 -31
- package/dist/cli/search-Z2V43OPM.js +0 -33
- package/dist/cli/sessions-BOJCVLR7.js +0 -18
- package/dist/cli/skills-B4BAH2B2.js +0 -37
- package/dist/cli/tools-Z5NCKIAB.js +0 -57
- package/dist/cli/update-XCL7F5T6.js +0 -35
|
@@ -1,417 +0,0 @@
|
|
|
1
|
-
import { isRuntimeScopeRunId } from './run-identity';
|
|
2
|
-
import { RUNNER_TERMINAL_PUSH_MAX_BODY_BYTES } from './output-size-limits';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Staged bodies for app-hosted Runtime gateways (profile `vercel_app@1`).
|
|
6
|
-
*
|
|
7
|
-
* Vercel functions accept and return at most ~4.5 MB per body, while the Fly
|
|
8
|
-
* gateway contract is 16 MiB per request (one legal 10 MiB receipt plus its
|
|
9
|
-
* envelope) and 16 MiB per runtime response. A pinned sandbox moves any body
|
|
10
|
-
* above the inline ceiling through object storage instead:
|
|
11
|
-
*
|
|
12
|
-
* - Request: the sandbox asks the gateway for a staged upload (size and
|
|
13
|
-
* SHA-256 only). The gateway persists the upload's custody row, then returns
|
|
14
|
-
* a create-once presigned PUT for one exact key under the run's
|
|
15
|
-
* org/run/attempt prefix. The sandbox uploads, then sends the original
|
|
16
|
-
* request with an empty body and the upload id. The gateway reads the
|
|
17
|
-
* object with its own credentials, checks length and SHA-256, and only then
|
|
18
|
-
* hands the bytes to the same gateway code the Fly gateway runs.
|
|
19
|
-
* - Response: when the sandbox advertises staging, a response above the
|
|
20
|
-
* inline ceiling is written to the same prefix after its custody row
|
|
21
|
-
* exists, and the sandbox receives a short-lived presigned GET plus the
|
|
22
|
-
* expected length and SHA-256.
|
|
23
|
-
*
|
|
24
|
-
* Unpinned runs never reach this code: only the pinned sandbox credential
|
|
25
|
-
* wrapper and the app-hosted gateway routes use it.
|
|
26
|
-
*/
|
|
27
|
-
|
|
28
|
-
/** Bodies up to this size travel inline; Vercel's ceiling is ~4.5 MB. */
|
|
29
|
-
export const RUNTIME_GATEWAY_STAGING_INLINE_MAX_BYTES = 4 * 1024 * 1024;
|
|
30
|
-
/** Same request ceiling as the Fly gateway (`EXECUTION_GATEWAY_MAX_BODY_BYTES`). */
|
|
31
|
-
export const RUNTIME_GATEWAY_STAGED_REQUEST_MAX_BYTES =
|
|
32
|
-
RUNNER_TERMINAL_PUSH_MAX_BODY_BYTES;
|
|
33
|
-
/** Same decoded-response budget the runtime client applies to a Fly gateway. */
|
|
34
|
-
export const RUNTIME_GATEWAY_STAGED_RESPONSE_MAX_BYTES =
|
|
35
|
-
RUNNER_TERMINAL_PUSH_MAX_BODY_BYTES;
|
|
36
|
-
/** Lifetime of one presigned PUT or GET. Never above 15 minutes. */
|
|
37
|
-
export const RUNTIME_GATEWAY_STAGING_GRANT_TTL_SECONDS = 10 * 60;
|
|
38
|
-
export const RUNTIME_GATEWAY_STAGING_GRANT_MAX_TTL_SECONDS = 15 * 60;
|
|
39
|
-
/**
|
|
40
|
-
* A staged object is retired only after its grant expired and any gateway
|
|
41
|
-
* invocation that could still be reading it (maxDuration 900 s) has ended. A
|
|
42
|
-
* create-once PUT URL can recreate a deleted key until it expires, so the
|
|
43
|
-
* final delete and its absence readback happen after this point.
|
|
44
|
-
*/
|
|
45
|
-
export const RUNTIME_GATEWAY_STAGING_RETIRE_GRACE_SECONDS = 15 * 60;
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Per-attempt deadline for one staged send (reserve, PUT, gateway call):
|
|
49
|
-
* the 10 s inline deadline plus 2 s per started MiB (a conservative
|
|
50
|
-
* 512 KiB/s upload), capped at 45 s. A 16 MiB body gets 42 s instead of
|
|
51
|
-
* being cut at 10 s; an inline-size body keeps 10 s.
|
|
52
|
-
*
|
|
53
|
-
* Self-contained on purpose: the crash terminal pusher embeds its source.
|
|
54
|
-
*/
|
|
55
|
-
export function runtimeGatewayStagedSendTimeoutMs(byteLength: number): number {
|
|
56
|
-
const baseMs = 10_000;
|
|
57
|
-
const perMibMs = 2_000;
|
|
58
|
-
const maxMs = 45_000;
|
|
59
|
-
if (!Number.isFinite(byteLength) || byteLength <= 0) return baseMs;
|
|
60
|
-
return Math.min(
|
|
61
|
-
maxMs,
|
|
62
|
-
baseMs + Math.ceil(byteLength / (1024 * 1024)) * perMibMs,
|
|
63
|
-
);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
/** Path below the profile's receipt or execution prefix. */
|
|
67
|
-
export const RUNTIME_GATEWAY_STAGED_UPLOAD_PATH = '/staged-uploads';
|
|
68
|
-
/** Request header: the sandbox can stage bodies and read staged responses. */
|
|
69
|
-
export const RUNTIME_GATEWAY_STAGING_HEADER = 'x-deepline-runtime-staging';
|
|
70
|
-
/** Request header: the body of this request is the named staged upload. */
|
|
71
|
-
export const RUNTIME_GATEWAY_STAGED_BODY_HEADER =
|
|
72
|
-
'x-deepline-runtime-staged-body';
|
|
73
|
-
/** Response header: the body is a staged-response descriptor. */
|
|
74
|
-
export const RUNTIME_GATEWAY_STAGED_RESPONSE_HEADER =
|
|
75
|
-
'x-deepline-runtime-staged-response';
|
|
76
|
-
/** Every key lives below `<prefix>/<org>/<run>/<attempt>/`. */
|
|
77
|
-
export const RUNTIME_GATEWAY_STAGING_KEY_PREFIX = 'runtime-gateway-staging/v1';
|
|
78
|
-
|
|
79
|
-
export const RUNTIME_GATEWAY_STAGING_ERROR_CODES = {
|
|
80
|
-
/** The custody journal table is absent: staging cannot run. Not retryable. */
|
|
81
|
-
journalMissing: 'runtime_gateway_staging_journal_missing',
|
|
82
|
-
/** Object storage gave no definite answer. Retry with a fresh upload. */
|
|
83
|
-
retryable: 'runtime_gateway_staging_retryable',
|
|
84
|
-
/** The sandbox's direct PUT or GET did not succeed. Retryable. */
|
|
85
|
-
transferFailed: 'runtime_gateway_staging_transfer_failed',
|
|
86
|
-
/** Staged bytes differ from the declared length or SHA-256. Retryable. */
|
|
87
|
-
integrityMismatch: 'runtime_gateway_staging_integrity_mismatch',
|
|
88
|
-
/** The upload id is unknown for this run attempt, or already used. */
|
|
89
|
-
uploadUnusable: 'runtime_gateway_staging_upload_unusable',
|
|
90
|
-
/** Body above the Fly-parity ceiling. */
|
|
91
|
-
requestTooLarge: 'runtime_gateway_request_too_large',
|
|
92
|
-
responseTooLarge: 'runtime_gateway_response_too_large',
|
|
93
|
-
invalidRequest: 'runtime_gateway_staging_invalid_request',
|
|
94
|
-
} as const;
|
|
95
|
-
|
|
96
|
-
export type RuntimeGatewayStagingErrorCode =
|
|
97
|
-
(typeof RUNTIME_GATEWAY_STAGING_ERROR_CODES)[keyof typeof RUNTIME_GATEWAY_STAGING_ERROR_CODES];
|
|
98
|
-
|
|
99
|
-
export type RuntimeGatewayStagingDirection = 'request' | 'response';
|
|
100
|
-
|
|
101
|
-
export type RuntimeGatewayStagingScope = Readonly<{
|
|
102
|
-
orgId: string;
|
|
103
|
-
runId: string;
|
|
104
|
-
attempt: number;
|
|
105
|
-
}>;
|
|
106
|
-
|
|
107
|
-
const SCOPE_ID_PATTERN = /^[A-Za-z0-9_.:@-]{1,256}$/;
|
|
108
|
-
const UPLOAD_ID_PATTERN =
|
|
109
|
-
/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
|
|
110
|
-
const SHA256_PATTERN = /^[0-9a-f]{64}$/;
|
|
111
|
-
|
|
112
|
-
export function isRuntimeGatewayStagingUploadId(
|
|
113
|
-
value: unknown,
|
|
114
|
-
): value is string {
|
|
115
|
-
return typeof value === 'string' && UPLOAD_ID_PATTERN.test(value);
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
export function isRuntimeGatewayStagingSha256(value: unknown): value is string {
|
|
119
|
-
return typeof value === 'string' && SHA256_PATTERN.test(value);
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
export function assertRuntimeGatewayStagingScope(
|
|
123
|
-
scope: RuntimeGatewayStagingScope,
|
|
124
|
-
): void {
|
|
125
|
-
if (
|
|
126
|
-
!SCOPE_ID_PATTERN.test(scope.orgId) ||
|
|
127
|
-
// Run ids are path-shaped (`play/<name>/run/<id>`). The object key
|
|
128
|
-
// percent-encodes the run id into one segment, so `/` cannot add a level.
|
|
129
|
-
!isRuntimeScopeRunId(scope.runId) ||
|
|
130
|
-
!Number.isSafeInteger(scope.attempt) ||
|
|
131
|
-
scope.attempt < 0
|
|
132
|
-
) {
|
|
133
|
-
throw new Error('Runtime gateway staging scope is invalid.');
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
/** The one object key for an upload. Built from the authenticated scope only. */
|
|
138
|
-
export function runtimeGatewayStagingObjectKey(
|
|
139
|
-
scope: RuntimeGatewayStagingScope,
|
|
140
|
-
direction: RuntimeGatewayStagingDirection,
|
|
141
|
-
uploadId: string,
|
|
142
|
-
): string {
|
|
143
|
-
assertRuntimeGatewayStagingScope(scope);
|
|
144
|
-
if (!isRuntimeGatewayStagingUploadId(uploadId)) {
|
|
145
|
-
throw new Error('Runtime gateway staging upload id is invalid.');
|
|
146
|
-
}
|
|
147
|
-
return [
|
|
148
|
-
RUNTIME_GATEWAY_STAGING_KEY_PREFIX,
|
|
149
|
-
encodeURIComponent(scope.orgId),
|
|
150
|
-
encodeURIComponent(scope.runId),
|
|
151
|
-
String(scope.attempt),
|
|
152
|
-
direction,
|
|
153
|
-
uploadId,
|
|
154
|
-
].join('/');
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
/** Bounds a presigned grant lifetime to the 15-minute ceiling. */
|
|
158
|
-
export function assertRuntimeGatewayStagingGrantTtl(seconds: number): void {
|
|
159
|
-
if (
|
|
160
|
-
!Number.isSafeInteger(seconds) ||
|
|
161
|
-
seconds < 1 ||
|
|
162
|
-
seconds > RUNTIME_GATEWAY_STAGING_GRANT_MAX_TTL_SECONDS
|
|
163
|
-
) {
|
|
164
|
-
throw new Error(
|
|
165
|
-
`Runtime gateway staging grant lifetime must be 1-${RUNTIME_GATEWAY_STAGING_GRANT_MAX_TTL_SECONDS} seconds.`,
|
|
166
|
-
);
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
/** Limits a sandbox client applies; passed in so the client stays self-contained. */
|
|
171
|
-
export type RuntimeGatewayStagingClientLimits = Readonly<{
|
|
172
|
-
inlineMaxBytes: number;
|
|
173
|
-
requestMaxBytes: number;
|
|
174
|
-
responseMaxBytes: number;
|
|
175
|
-
pathPrefixes: readonly string[];
|
|
176
|
-
}>;
|
|
177
|
-
|
|
178
|
-
export function runtimeGatewayStagingClientLimits(
|
|
179
|
-
pathPrefixes: readonly string[],
|
|
180
|
-
): RuntimeGatewayStagingClientLimits {
|
|
181
|
-
return Object.freeze({
|
|
182
|
-
inlineMaxBytes: RUNTIME_GATEWAY_STAGING_INLINE_MAX_BYTES,
|
|
183
|
-
requestMaxBytes: RUNTIME_GATEWAY_STAGED_REQUEST_MAX_BYTES,
|
|
184
|
-
responseMaxBytes: RUNTIME_GATEWAY_STAGED_RESPONSE_MAX_BYTES,
|
|
185
|
-
pathPrefixes: Object.freeze([...pathPrefixes]),
|
|
186
|
-
});
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
/**
|
|
190
|
-
* Send one code-owned request to a pinned app-hosted gateway, staging an
|
|
191
|
-
* oversize body and resolving a staged response.
|
|
192
|
-
*
|
|
193
|
-
* `init.headers` must already carry the run's executor token and gateway
|
|
194
|
-
* credential; they are copied onto the reserve call only. Object-storage
|
|
195
|
-
* calls carry no Deepline credential at all. Every failure is returned as a
|
|
196
|
-
* gateway-shaped JSON response with a named `code`: transfer failures use
|
|
197
|
-
* 503 so existing runtime retry ladders retry them with a fresh upload, and a
|
|
198
|
-
* missing custody journal stays non-retryable.
|
|
199
|
-
*
|
|
200
|
-
* Self-contained on purpose: the crash terminal pusher embeds this
|
|
201
|
-
* function's source, so it must not reference imports, module state, or
|
|
202
|
-
* nested named functions.
|
|
203
|
-
*/
|
|
204
|
-
export async function runtimeGatewayStagedSend(
|
|
205
|
-
send: typeof fetch,
|
|
206
|
-
target: string,
|
|
207
|
-
init: RequestInit,
|
|
208
|
-
limits: RuntimeGatewayStagingClientLimits,
|
|
209
|
-
): Promise<Response> {
|
|
210
|
-
const headers = new Headers(init.headers);
|
|
211
|
-
headers.set('x-deepline-runtime-staging', '1');
|
|
212
|
-
const body = init.body;
|
|
213
|
-
let bytes: Uint8Array | null = null;
|
|
214
|
-
if (typeof body === 'string') bytes = new TextEncoder().encode(body);
|
|
215
|
-
else if (body instanceof Uint8Array) bytes = body;
|
|
216
|
-
else if (body instanceof ArrayBuffer) bytes = new Uint8Array(body);
|
|
217
|
-
let sendInit: RequestInit = { ...init, headers };
|
|
218
|
-
if (bytes && bytes.byteLength > limits.inlineMaxBytes) {
|
|
219
|
-
if (bytes.byteLength > limits.requestMaxBytes) {
|
|
220
|
-
return Response.json(
|
|
221
|
-
{
|
|
222
|
-
error: 'Execution gateway request body is too large.',
|
|
223
|
-
code: 'runtime_gateway_request_too_large',
|
|
224
|
-
},
|
|
225
|
-
{ status: 413 },
|
|
226
|
-
);
|
|
227
|
-
}
|
|
228
|
-
const url = new URL(target);
|
|
229
|
-
const prefix = limits.pathPrefixes.find(
|
|
230
|
-
(candidate) =>
|
|
231
|
-
url.pathname === candidate || url.pathname.startsWith(candidate + '/'),
|
|
232
|
-
);
|
|
233
|
-
if (!prefix) {
|
|
234
|
-
return Response.json(
|
|
235
|
-
{
|
|
236
|
-
error: 'Runtime gateway staging target is outside the gateway.',
|
|
237
|
-
code: 'runtime_gateway_staging_invalid_request',
|
|
238
|
-
},
|
|
239
|
-
{ status: 400 },
|
|
240
|
-
);
|
|
241
|
-
}
|
|
242
|
-
const digest = await crypto.subtle.digest(
|
|
243
|
-
'SHA-256',
|
|
244
|
-
bytes as Uint8Array<ArrayBuffer>,
|
|
245
|
-
);
|
|
246
|
-
const sha256 = Array.from(new Uint8Array(digest), (byte) =>
|
|
247
|
-
byte.toString(16).padStart(2, '0'),
|
|
248
|
-
).join('');
|
|
249
|
-
const reserveHeaders = new Headers(headers);
|
|
250
|
-
reserveHeaders.delete('content-length');
|
|
251
|
-
reserveHeaders.delete('content-encoding');
|
|
252
|
-
reserveHeaders.set('content-type', 'application/json');
|
|
253
|
-
const reserved = await send(url.origin + prefix + '/staged-uploads', {
|
|
254
|
-
method: 'POST',
|
|
255
|
-
headers: reserveHeaders,
|
|
256
|
-
body: JSON.stringify({ byteLength: bytes.byteLength, sha256 }),
|
|
257
|
-
redirect: 'manual',
|
|
258
|
-
signal: init.signal,
|
|
259
|
-
});
|
|
260
|
-
// Refusals (journal missing, too large, capacity) reach the caller as the
|
|
261
|
-
// gateway stated them.
|
|
262
|
-
if (!reserved.ok) return reserved;
|
|
263
|
-
const grant = (await reserved.json().catch(() => null)) as {
|
|
264
|
-
uploadId?: unknown;
|
|
265
|
-
url?: unknown;
|
|
266
|
-
headers?: unknown;
|
|
267
|
-
} | null;
|
|
268
|
-
let putUrl: URL | null = null;
|
|
269
|
-
try {
|
|
270
|
-
putUrl = new URL(String(grant?.url));
|
|
271
|
-
} catch {
|
|
272
|
-
putUrl = null;
|
|
273
|
-
}
|
|
274
|
-
if (
|
|
275
|
-
!grant ||
|
|
276
|
-
typeof grant.uploadId !== 'string' ||
|
|
277
|
-
!putUrl ||
|
|
278
|
-
putUrl.protocol !== 'https:' ||
|
|
279
|
-
putUrl.origin === url.origin ||
|
|
280
|
-
!grant.headers ||
|
|
281
|
-
typeof grant.headers !== 'object'
|
|
282
|
-
) {
|
|
283
|
-
return Response.json(
|
|
284
|
-
{
|
|
285
|
-
error: 'Runtime gateway returned an unusable staged upload grant.',
|
|
286
|
-
code: 'runtime_gateway_staging_transfer_failed',
|
|
287
|
-
},
|
|
288
|
-
{ status: 503 },
|
|
289
|
-
);
|
|
290
|
-
}
|
|
291
|
-
let putStatus = 0;
|
|
292
|
-
try {
|
|
293
|
-
const put = await send(putUrl.href, {
|
|
294
|
-
method: 'PUT',
|
|
295
|
-
headers: grant.headers as Record<string, string>,
|
|
296
|
-
body: bytes as Uint8Array<ArrayBuffer>,
|
|
297
|
-
redirect: 'manual',
|
|
298
|
-
signal: init.signal,
|
|
299
|
-
});
|
|
300
|
-
putStatus = put.status;
|
|
301
|
-
await put.text().catch(() => '');
|
|
302
|
-
} catch (error) {
|
|
303
|
-
if (init.signal?.aborted) throw error;
|
|
304
|
-
putStatus = 0;
|
|
305
|
-
}
|
|
306
|
-
// 412: an earlier delivery of this exact create-once PUT already landed;
|
|
307
|
-
// the gateway verifies the stored bytes before using them.
|
|
308
|
-
if (!(putStatus >= 200 && putStatus < 300) && putStatus !== 412) {
|
|
309
|
-
return Response.json(
|
|
310
|
-
{
|
|
311
|
-
error: `Runtime gateway staged upload did not reach object storage (status ${putStatus}).`,
|
|
312
|
-
code: 'runtime_gateway_staging_transfer_failed',
|
|
313
|
-
retry_after_ms: 1000,
|
|
314
|
-
},
|
|
315
|
-
{ status: 503 },
|
|
316
|
-
);
|
|
317
|
-
}
|
|
318
|
-
const stagedHeaders = new Headers(headers);
|
|
319
|
-
stagedHeaders.delete('content-length');
|
|
320
|
-
stagedHeaders.set('x-deepline-runtime-staged-body', grant.uploadId);
|
|
321
|
-
sendInit = { ...init, headers: stagedHeaders, body: null };
|
|
322
|
-
}
|
|
323
|
-
const response = await send(target, sendInit);
|
|
324
|
-
if (response.headers.get('x-deepline-runtime-staged-response') !== '1') {
|
|
325
|
-
return response;
|
|
326
|
-
}
|
|
327
|
-
const descriptor = (await response.json().catch(() => null)) as {
|
|
328
|
-
url?: unknown;
|
|
329
|
-
sha256?: unknown;
|
|
330
|
-
byteLength?: unknown;
|
|
331
|
-
status?: unknown;
|
|
332
|
-
headers?: unknown;
|
|
333
|
-
} | null;
|
|
334
|
-
let getUrl: URL | null = null;
|
|
335
|
-
try {
|
|
336
|
-
getUrl = new URL(String(descriptor?.url));
|
|
337
|
-
} catch {
|
|
338
|
-
getUrl = null;
|
|
339
|
-
}
|
|
340
|
-
if (
|
|
341
|
-
!descriptor ||
|
|
342
|
-
!getUrl ||
|
|
343
|
-
getUrl.protocol !== 'https:' ||
|
|
344
|
-
getUrl.origin === new URL(target).origin ||
|
|
345
|
-
typeof descriptor.sha256 !== 'string' ||
|
|
346
|
-
typeof descriptor.byteLength !== 'number' ||
|
|
347
|
-
!Number.isSafeInteger(descriptor.byteLength) ||
|
|
348
|
-
descriptor.byteLength < 0 ||
|
|
349
|
-
typeof descriptor.status !== 'number' ||
|
|
350
|
-
!descriptor.headers ||
|
|
351
|
-
typeof descriptor.headers !== 'object'
|
|
352
|
-
) {
|
|
353
|
-
return Response.json(
|
|
354
|
-
{
|
|
355
|
-
error: 'Runtime gateway returned an unusable staged response.',
|
|
356
|
-
code: 'runtime_gateway_staging_transfer_failed',
|
|
357
|
-
},
|
|
358
|
-
{ status: 503 },
|
|
359
|
-
);
|
|
360
|
-
}
|
|
361
|
-
if (descriptor.byteLength > limits.responseMaxBytes) {
|
|
362
|
-
return Response.json(
|
|
363
|
-
{
|
|
364
|
-
error: 'Runtime gateway staged response is too large.',
|
|
365
|
-
code: 'runtime_gateway_response_too_large',
|
|
366
|
-
},
|
|
367
|
-
{ status: 502 },
|
|
368
|
-
);
|
|
369
|
-
}
|
|
370
|
-
let staged: Uint8Array | null = null;
|
|
371
|
-
try {
|
|
372
|
-
const download = await send(getUrl.href, {
|
|
373
|
-
method: 'GET',
|
|
374
|
-
redirect: 'manual',
|
|
375
|
-
signal: init.signal,
|
|
376
|
-
});
|
|
377
|
-
if (download.ok) staged = new Uint8Array(await download.arrayBuffer());
|
|
378
|
-
else await download.text().catch(() => '');
|
|
379
|
-
} catch (error) {
|
|
380
|
-
if (init.signal?.aborted) throw error;
|
|
381
|
-
staged = null;
|
|
382
|
-
}
|
|
383
|
-
if (!staged) {
|
|
384
|
-
return Response.json(
|
|
385
|
-
{
|
|
386
|
-
error: 'Runtime gateway staged response could not be downloaded.',
|
|
387
|
-
code: 'runtime_gateway_staging_transfer_failed',
|
|
388
|
-
retry_after_ms: 1000,
|
|
389
|
-
},
|
|
390
|
-
{ status: 503 },
|
|
391
|
-
);
|
|
392
|
-
}
|
|
393
|
-
const stagedDigest = await crypto.subtle.digest(
|
|
394
|
-
'SHA-256',
|
|
395
|
-
staged as Uint8Array<ArrayBuffer>,
|
|
396
|
-
);
|
|
397
|
-
const stagedSha256 = Array.from(new Uint8Array(stagedDigest), (byte) =>
|
|
398
|
-
byte.toString(16).padStart(2, '0'),
|
|
399
|
-
).join('');
|
|
400
|
-
if (
|
|
401
|
-
staged.byteLength !== descriptor.byteLength ||
|
|
402
|
-
stagedSha256 !== descriptor.sha256
|
|
403
|
-
) {
|
|
404
|
-
return Response.json(
|
|
405
|
-
{
|
|
406
|
-
error: 'Runtime gateway staged response failed its integrity check.',
|
|
407
|
-
code: 'runtime_gateway_staging_integrity_mismatch',
|
|
408
|
-
retry_after_ms: 1000,
|
|
409
|
-
},
|
|
410
|
-
{ status: 503 },
|
|
411
|
-
);
|
|
412
|
-
}
|
|
413
|
-
return new Response(staged as Uint8Array<ArrayBuffer>, {
|
|
414
|
-
status: descriptor.status,
|
|
415
|
-
headers: descriptor.headers as Record<string, string>,
|
|
416
|
-
});
|
|
417
|
-
}
|
package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-gateway-attempt.ts
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
mintRuntimeGatewayAttemptOidcToken,
|
|
3
|
-
readExecutorTokenClaimsUnverified,
|
|
4
|
-
} from '../runtime-app-transport';
|
|
5
|
-
import {
|
|
6
|
-
assertRuntimeGatewayPinFresh,
|
|
7
|
-
readRuntimeGatewayLaunchPin,
|
|
8
|
-
RuntimeGatewayLaunchError,
|
|
9
|
-
type RuntimeGatewayLaunchFields,
|
|
10
|
-
type RuntimeGatewayLaunchPin,
|
|
11
|
-
} from '../runtime-gateway-profile';
|
|
12
|
-
import type { RuntimeGatewayOidcSigningKey } from '../runtime-gateway-oidc';
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Worker-side checks for a pinned launch. Every function is a no-op (null)
|
|
16
|
-
* for unpinned launches, so the default path is unchanged.
|
|
17
|
-
*/
|
|
18
|
-
|
|
19
|
-
/** Attempt start / resume: refuse an expired or unreadable pin loudly. */
|
|
20
|
-
export function assertRuntimeGatewayAttemptStartable(
|
|
21
|
-
launch: RuntimeGatewayLaunchFields,
|
|
22
|
-
nowMs: number,
|
|
23
|
-
): RuntimeGatewayLaunchPin | null {
|
|
24
|
-
const pin = readRuntimeGatewayLaunchPin(launch);
|
|
25
|
-
if (pin) assertRuntimeGatewayPinFresh(pin, nowMs);
|
|
26
|
-
return pin;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* The app minted the primary executor token. For a pinned launch it must
|
|
31
|
-
* carry `runtime_gateway_deployment_id` equal to the pin; an older app that
|
|
32
|
-
* ignored the pin would otherwise hand the sandbox a token the pinned gateway
|
|
33
|
-
* refuses, or quietly route the run elsewhere. The signature is verified by
|
|
34
|
-
* the gateway on use; here only the claim's presence and value are checked.
|
|
35
|
-
*/
|
|
36
|
-
export function assertExecutorTokenCarriesRuntimeGatewayPin(
|
|
37
|
-
executorToken: string,
|
|
38
|
-
pin: RuntimeGatewayLaunchPin,
|
|
39
|
-
): void {
|
|
40
|
-
const claims = readExecutorTokenClaimsUnverified(executorToken);
|
|
41
|
-
if (
|
|
42
|
-
claims?.runtime_gateway_deployment_id !== pin.deploymentId ||
|
|
43
|
-
claims?.runtime_gateway_profile !== pin.profile.id
|
|
44
|
-
) {
|
|
45
|
-
throw new RuntimeGatewayLaunchError(
|
|
46
|
-
'runtime_gateway_executor_token_unpinned',
|
|
47
|
-
`The executor token for a launch pinned to ${pin.deploymentId} (${pin.profile.id}) does not carry the matching runtime gateway claims; the issuing app does not support Runtime gateway profiles.`,
|
|
48
|
-
);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* The runner config a sandbox launch receives. Unpinned launches return the
|
|
54
|
-
* same object. Pinned launches re-check pin age and carry a fresh credential.
|
|
55
|
-
*/
|
|
56
|
-
export function withRuntimeGatewayAttemptCredential<
|
|
57
|
-
T extends { context: { runtimeGatewayOidcToken?: string | null } },
|
|
58
|
-
>(input: {
|
|
59
|
-
config: T;
|
|
60
|
-
launch: RuntimeGatewayLaunchFields;
|
|
61
|
-
runId: string;
|
|
62
|
-
attempt: number;
|
|
63
|
-
nowMs: number;
|
|
64
|
-
signingKey: () => RuntimeGatewayOidcSigningKey | null;
|
|
65
|
-
}): T {
|
|
66
|
-
const pin = assertRuntimeGatewayAttemptStartable(input.launch, input.nowMs);
|
|
67
|
-
if (!pin) return input.config;
|
|
68
|
-
return {
|
|
69
|
-
...input.config,
|
|
70
|
-
context: {
|
|
71
|
-
...input.config.context,
|
|
72
|
-
runtimeGatewayOidcToken: mintRuntimeGatewayAttemptOidcToken({
|
|
73
|
-
pin,
|
|
74
|
-
runId: input.runId,
|
|
75
|
-
attempt: input.attempt,
|
|
76
|
-
nowMs: input.nowMs,
|
|
77
|
-
signingKey: input.signingKey(),
|
|
78
|
-
}),
|
|
79
|
-
},
|
|
80
|
-
} as T;
|
|
81
|
-
}
|