deepline 0.3.569 → 0.3.571
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/release.ts +1 -1
- package/dist/bundling-sources/shared_libs/play-runtime/app-runtime-api.ts +25 -0
- package/dist/bundling-sources/shared_libs/play-runtime/context.ts +1 -0
- package/dist/bundling-sources/shared_libs/play-runtime/resource-governor.ts +17 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runner-app/index.ts +2 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/modal.ts +1 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/early-sandbox.ts +17 -1
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-api-connection-probe.ts +199 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres.ts +43 -0
- package/dist/cli/{auth-VNJLXDGF.mjs → auth-ARGNQK7A.mjs} +5 -5
- package/dist/cli/auth-FKYYYCME.js +44 -0
- package/dist/cli/{billing-OTIIK5ZQ.js → billing-KAKODYTN.js} +99 -99
- package/dist/cli/{billing-6HD5LEI2.mjs → billing-QRZTHCBX.mjs} +8 -8
- package/dist/cli/{chunk-HLRSNCPM.js → chunk-2IZOCGOA.js} +53 -53
- package/dist/cli/{chunk-FPRLFIYT.mjs → chunk-336AHC7H.mjs} +4 -4
- package/dist/cli/{chunk-FSAOU4HA.js → chunk-6N3NTEJ6.js} +20 -20
- package/dist/cli/{chunk-H3SQMLHO.js → chunk-6OP5UW7C.js} +48 -48
- package/dist/cli/{chunk-MIGJHZ3P.js → chunk-73P76DCN.js} +20 -20
- package/dist/cli/{chunk-JXRWSBJZ.mjs → chunk-7HAYEKC4.mjs} +1 -1
- package/dist/cli/{chunk-H7DRZXYF.js → chunk-7JGHNZTD.js} +4 -4
- package/dist/cli/{chunk-7QH52S3E.mjs → chunk-A3B54QEW.mjs} +3 -3
- package/dist/cli/{chunk-IEOIGU5A.mjs → chunk-A3IVPA6Q.mjs} +1 -1
- package/dist/cli/{chunk-WVS2ITKP.js → chunk-A5HDA22N.js} +3 -3
- package/dist/cli/{chunk-6HEZRKAO.mjs → chunk-AD7BGMTL.mjs} +2 -2
- package/dist/cli/{chunk-N5ZOD3LA.js → chunk-AOMVAXGX.js} +10 -10
- package/dist/cli/{chunk-SWREMC6J.js → chunk-C27FK36H.js} +5 -5
- package/dist/cli/{chunk-6Z7B3IOW.js → chunk-C3FHMJ4A.js} +2 -2
- package/dist/cli/{chunk-X4WPW5O3.mjs → chunk-C6XV2DPY.mjs} +3 -3
- package/dist/cli/{chunk-OFBP336D.mjs → chunk-CF6CSAMJ.mjs} +4 -4
- package/dist/cli/{chunk-EDNWMQZQ.mjs → chunk-CFMIWRGD.mjs} +2 -2
- package/dist/cli/{chunk-YTOILYBU.js → chunk-CITDBSXI.js} +26 -26
- package/dist/cli/{chunk-D3BJ2KZX.mjs → chunk-CR6IPQBB.mjs} +1 -1
- package/dist/cli/{chunk-YTYDKSK7.mjs → chunk-ETGM6PIR.mjs} +5 -5
- package/dist/cli/{chunk-CK6U2NH2.mjs → chunk-FQP5VSVF.mjs} +1 -1
- package/dist/cli/{chunk-PAFSVZCZ.js → chunk-GACQOGRS.js} +15 -15
- package/dist/cli/{chunk-UOMMXLDU.mjs → chunk-GCE5KOJJ.mjs} +11 -11
- package/dist/cli/{chunk-ANXJNE2G.js → chunk-GOUKX6XD.js} +3 -3
- package/dist/cli/{chunk-45OTCUAC.mjs → chunk-GRD3DLH7.mjs} +2 -2
- package/dist/cli/{chunk-DG6ILAO7.mjs → chunk-H6QMUX7Y.mjs} +2 -2
- package/dist/cli/{chunk-S4MDYDCF.js → chunk-HGER4CJA.js} +5 -5
- package/dist/cli/{chunk-TZVKEUM6.js → chunk-IFKZQCPX.js} +1 -1
- package/dist/cli/{chunk-IGIUAHTR.js → chunk-ILKUKEWX.js} +41 -41
- package/dist/cli/{chunk-4CLEOTG6.js → chunk-IXFFOZZQ.js} +2 -2
- package/dist/cli/{chunk-YNSVWNRY.mjs → chunk-J5KW2ZDB.mjs} +1 -1
- package/dist/cli/{chunk-QLMMNBJW.js → chunk-MFBFQUQK.js} +6 -6
- package/dist/cli/{chunk-TH2GHSF6.js → chunk-NAGGCF6Y.js} +5 -5
- package/dist/cli/{chunk-AKNJDDSM.mjs → chunk-PO3NOBHU.mjs} +1 -1
- package/dist/cli/{chunk-LOF7H5V3.js → chunk-PTM5V5FV.js} +7 -7
- package/dist/cli/{chunk-P2LVKWU6.mjs → chunk-QRMTITKL.mjs} +2 -2
- package/dist/cli/{chunk-44HOKKIN.js → chunk-RBPR5ZNN.js} +100 -100
- package/dist/cli/{chunk-3WZ3X46C.js → chunk-SJYLLHHZ.js} +13 -13
- package/dist/cli/{chunk-7NP7WZV2.mjs → chunk-TJU2BECV.mjs} +3 -3
- package/dist/cli/{chunk-SRMDDVWK.mjs → chunk-UBNRPJKO.mjs} +5 -5
- package/dist/cli/{chunk-TRE5X6VQ.mjs → chunk-UTGHPC5D.mjs} +1 -1
- package/dist/cli/{chunk-S3VGWMFX.js → chunk-VLQB65HI.js} +9 -9
- package/dist/cli/{chunk-WPCY5PR3.mjs → chunk-VULSFPD4.mjs} +5 -5
- package/dist/cli/{chunk-7MZUSBSI.js → chunk-WOU2WS6S.js} +23 -23
- package/dist/cli/{chunk-6D4WBX7E.mjs → chunk-WZOUXILM.mjs} +1 -1
- package/dist/cli/{chunk-IS4NFIQY.js → chunk-XD4MT4BH.js} +8 -8
- package/dist/cli/{chunk-YLZ63U7S.mjs → chunk-YDM5WSXO.mjs} +5 -5
- package/dist/cli/{chunk-GSUHJUNZ.mjs → chunk-YDULFKDL.mjs} +2 -2
- package/dist/cli/{chunk-SMAXLMM3.js → chunk-YGGHPEWP.js} +15 -15
- package/dist/cli/{chunk-QKPKVLTG.js → chunk-YQ36Z23U.js} +2 -2
- package/dist/cli/{chunk-TALKTQK5.mjs → chunk-Z3DSCE5F.mjs} +1 -1
- package/dist/cli/{chunk-6SBGYX25.mjs → chunk-Z6OUUAIV.mjs} +2 -2
- package/dist/cli/{concurrent-runs-help-BVBGDMNV.mjs → concurrent-runs-help-VPYB4ODC.mjs} +6 -6
- package/dist/cli/concurrent-runs-help-VUMIMYO7.js +22 -0
- package/dist/cli/{csv-G25E43QV.js → csv-GHGDSFNV.js} +13 -13
- package/dist/cli/{csv-BUZIP2TV.mjs → csv-RALLG3MG.mjs} +4 -4
- package/dist/cli/{db-KYIDDEEE.js → db-722SKSIB.js} +27 -27
- package/dist/cli/{db-EUN7RRDX.mjs → db-HB65VYRR.mjs} +6 -6
- package/dist/cli/{describe-CTYSKRQB.mjs → describe-Q6M7PUBU.mjs} +18 -18
- package/dist/cli/describe-SG2N62VE.js +50 -0
- package/dist/cli/{executions-BRSOIIV7.mjs → executions-G3M75HW2.mjs} +6 -6
- package/dist/cli/{executions-LQA34Z76.js → executions-GQNV3LNU.js} +8 -8
- package/dist/cli/{feedback-RVYWQRSZ.js → feedback-B43F2FBL.js} +14 -14
- package/dist/cli/{feedback-JYL2FTWI.mjs → feedback-CSDBYSRS.mjs} +6 -6
- package/dist/cli/git-IJHKRWTR.js +26 -0
- package/dist/cli/{git-2Z2KYPCV.mjs → git-IZ4Y3RAW.mjs} +5 -5
- package/dist/cli/index.js +143 -143
- package/dist/cli/index.mjs +45 -45
- package/dist/cli/{integrations-QFS62VWE.mjs → integrations-DT7EGM2Y.mjs} +7 -7
- package/dist/cli/{integrations-JK3OT5BT.js → integrations-OLCUWZ6Z.js} +29 -29
- package/dist/cli/{legacy-noops-NBKBFVDO.mjs → legacy-noops-4TPT534L.mjs} +6 -6
- package/dist/cli/{legacy-noops-RYP5LN5D.js → legacy-noops-FTGNTO3U.js} +9 -9
- package/dist/cli/{mcp-KPY7NZPI.js → mcp-3IDWLBKK.js} +24 -24
- package/dist/cli/{mcp-KVGJK3SM.mjs → mcp-5KDJJT7M.mjs} +4 -4
- package/dist/cli/{monitors-DE5SX3CP.js → monitors-7GOZBKJR.js} +100 -100
- package/dist/cli/{monitors-H3UWQMMI.mjs → monitors-EOAA5RQO.mjs} +7 -7
- package/dist/cli/{org-N6I5K56T.mjs → org-H5I56A4F.mjs} +6 -6
- package/dist/cli/{org-CDCSMG3J.js → org-UJ5SWQJ5.js} +121 -121
- package/dist/cli/{outcomes-UNAOLWWO.js → outcomes-24KFY2X5.js} +14 -14
- package/dist/cli/{outcomes-EPEMTJVB.mjs → outcomes-MG57YXJX.mjs} +6 -6
- package/dist/cli/{play-VVM5XJFT.mjs → play-MXPXRAUM.mjs} +19 -19
- package/dist/cli/{play-7TVJ3DFQ.js → play-PPPACSQE.js} +324 -324
- package/dist/cli/{providers-47CT527B.mjs → providers-5ZN3MO6E.mjs} +6 -6
- package/dist/cli/{providers-ANYRJ56K.js → providers-LTYNEXLB.js} +9 -9
- package/dist/cli/{quickstart-QHMC5YCM.mjs → quickstart-ENDTTNLE.mjs} +4 -4
- package/dist/cli/{quickstart-H4MI6LVO.js → quickstart-UBDHX7PT.js} +6 -6
- package/dist/cli/{run-V4UAYPAX.js → run-6O6LQVWD.js} +44 -44
- package/dist/cli/{run-NXC5W5CW.mjs → run-QJJSP35C.mjs} +23 -23
- package/dist/cli/{search-BEU4VBY4.mjs → search-PXZPVXDK.mjs} +7 -7
- package/dist/cli/search-TYPJWK4I.js +32 -0
- package/dist/cli/{search-output-NUGUU7VJ.js → search-output-H3ZQLJUF.js} +6 -6
- package/dist/cli/{search-output-DUA3WDB7.mjs → search-output-KRR4YOJX.mjs} +4 -4
- package/dist/cli/{secrets-XQOOWTH2.mjs → secrets-HIGERL4N.mjs} +6 -6
- package/dist/cli/{secrets-PFDBC5KO.js → secrets-QZMXBI64.js} +15 -15
- package/dist/cli/{sessions-U2ZS5R42.mjs → sessions-4SGQAX3F.mjs} +6 -6
- package/dist/cli/sessions-OS4ZBU4K.js +23 -0
- package/dist/cli/{settings-ATYARYCR.js → settings-FFTTVDRV.js} +85 -85
- package/dist/cli/{settings-GPDE7DL2.mjs → settings-UQLHVBOP.mjs} +12 -12
- package/dist/cli/{setup-UDO6BY5A.mjs → setup-R5MBUG5M.mjs} +9 -9
- package/dist/cli/{setup-4AYMU7NK.js → setup-SS3MABJP.js} +49 -49
- package/dist/cli/skills-FVDSEEUL.js +37 -0
- package/dist/cli/{skills-RACTA7VV.mjs → skills-X6PNEVWX.mjs} +7 -7
- package/dist/cli/tools-ORTGWD63.js +57 -0
- package/dist/cli/{tools-TXI6XFHE.mjs → tools-YFW3FXAB.mjs} +17 -17
- package/dist/cli/{update-VHTKWNXO.mjs → update-HX5BNFLQ.mjs} +9 -9
- package/dist/cli/update-RWVNNNHN.js +37 -0
- package/dist/cli/{views-DVBO3L63.js → views-BGCRC22G.js} +21 -21
- package/dist/cli/{views-GCNEHB7D.mjs → views-FH5XL2PU.mjs} +6 -6
- package/dist/cli/{workflow-TFRJ5JKX.js → workflow-UY5PZBIK.js} +17 -17
- package/dist/cli/{workflow-R3A6EGB5.mjs → workflow-VLNDGNJI.mjs} +7 -7
- package/dist/index.js +9 -9
- package/dist/index.mjs +6 -6
- package/dist/install-integrity.json +113 -112
- 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.js +5 -5
- package/dist/server.mjs +3 -3
- package/package.json +1 -1
- package/dist/cli/auth-77NOPZ6A.js +0 -44
- package/dist/cli/concurrent-runs-help-QPUTOBFB.js +0 -22
- package/dist/cli/describe-PJIQSXJ4.js +0 -50
- package/dist/cli/git-MJRG55H7.js +0 -26
- package/dist/cli/search-TUK2STXB.js +0 -32
- package/dist/cli/sessions-5333FFSY.js +0 -23
- package/dist/cli/skills-LB56HJOY.js +0 -37
- package/dist/cli/tools-3Y7KCKZX.js +0 -57
- package/dist/cli/update-EWOLMH3E.js +0 -37
|
@@ -205,7 +205,7 @@ export const SDK_RELEASE = {
|
|
|
205
205
|
// getters keep their established compatibility behavior.
|
|
206
206
|
// 0.3.1 deprecated the legacy `deepline enrich` command in favor of Plays.
|
|
207
207
|
// 0.3.90 is the first deliberately versioned SDK release for API v3.
|
|
208
|
-
version: '0.3.
|
|
208
|
+
version: '0.3.571',
|
|
209
209
|
updateSummary: {
|
|
210
210
|
introducedIn: '0.3.90',
|
|
211
211
|
summary:
|
|
@@ -5,6 +5,11 @@ import {
|
|
|
5
5
|
import { prepareRetainedPlayPipelinesForTransport } from '../plays/execution-pipeline';
|
|
6
6
|
import { createWriteStream } from 'node:fs';
|
|
7
7
|
import { createHash, randomUUID } from 'node:crypto';
|
|
8
|
+
import {
|
|
9
|
+
runtimeApiConnectionProbe,
|
|
10
|
+
settledRuntimeApiConnectionProbe,
|
|
11
|
+
type RuntimeApiConnectionProbe,
|
|
12
|
+
} from './runtime-api-connection-probe';
|
|
8
13
|
import { stat } from 'node:fs/promises';
|
|
9
14
|
import { Readable } from 'node:stream';
|
|
10
15
|
import { pipeline } from 'node:stream/promises';
|
|
@@ -423,6 +428,12 @@ export type WorkerRuntimeApiContext = {
|
|
|
423
428
|
* gateway record that produced it.
|
|
424
429
|
*/
|
|
425
430
|
onResponseMeta?: (meta: RuntimeApiResponseMeta) => void;
|
|
431
|
+
/**
|
|
432
|
+
* Measure one fresh connection to this origin once per process (DNS, TCP
|
|
433
|
+
* connect, TLS) off the request path and report it on `onResponseMeta` as
|
|
434
|
+
* `connectionProbe`. Only the runner's receipt gateway context sets it.
|
|
435
|
+
*/
|
|
436
|
+
probeConnection?: boolean;
|
|
426
437
|
/**
|
|
427
438
|
* Observe each request attempt as it is sent. `onResponseMeta` only fires
|
|
428
439
|
* for a successful response, so an attempt that is aborted or times out
|
|
@@ -517,6 +528,13 @@ export type RuntimeApiResponseMeta = {
|
|
|
517
528
|
* network time.
|
|
518
529
|
*/
|
|
519
530
|
requestBodyPackMs?: number | null;
|
|
531
|
+
/**
|
|
532
|
+
* One fresh connection's setup cost to this origin, measured once per
|
|
533
|
+
* process off the request path (`runtime-api-connection-probe.ts`). Null
|
|
534
|
+
* until it has settled. Compare its `connectMs` with `roundTripMs` to tell
|
|
535
|
+
* path latency from per-request connection setup.
|
|
536
|
+
*/
|
|
537
|
+
connectionProbe?: RuntimeApiConnectionProbe | null;
|
|
520
538
|
};
|
|
521
539
|
|
|
522
540
|
const RUNTIME_API_DIAGNOSTIC_HEADER_MAX_CHARS = 256;
|
|
@@ -1737,6 +1755,10 @@ async function postAppRuntimeApiAttempts<TResponse>(
|
|
|
1737
1755
|
}
|
|
1738
1756
|
const runtimeFetch = context.fetch ?? fetch;
|
|
1739
1757
|
const boundaryLabel = runtimeApiBoundaryLabel(context);
|
|
1758
|
+
// Diagnostic only: one fresh-connection measurement per process and origin,
|
|
1759
|
+
// started on the first observed request and never awaited.
|
|
1760
|
+
if (context.probeConnection && context.onResponseMeta)
|
|
1761
|
+
void runtimeApiConnectionProbe(baseUrl);
|
|
1740
1762
|
const fastRunLedgerBypass =
|
|
1741
1763
|
body.action === 'append_run_events' || body.action === 'project_run_events';
|
|
1742
1764
|
const vercelHeaders = fastRunLedgerBypass
|
|
@@ -2015,6 +2037,9 @@ async function postAppRuntimeApiAttempts<TResponse>(
|
|
|
2015
2037
|
requestBodyWireBytes: wireBody.wireBytes,
|
|
2016
2038
|
requestBodySerializeMs,
|
|
2017
2039
|
requestBodyPackMs,
|
|
2040
|
+
connectionProbe: context.probeConnection
|
|
2041
|
+
? settledRuntimeApiConnectionProbe(baseUrl)
|
|
2042
|
+
: null,
|
|
2018
2043
|
});
|
|
2019
2044
|
} catch {
|
|
2020
2045
|
// Observation must never affect durable delivery.
|
|
@@ -20164,6 +20164,7 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
|
|
|
20164
20164
|
// it serialized and what it actually sent.
|
|
20165
20165
|
gatewayRequestRawBytes: meta.requestBodyRawBytes ?? null,
|
|
20166
20166
|
gatewayRequestWireBytes: meta.requestBodyWireBytes ?? null,
|
|
20167
|
+
gatewayConnectionProbe: meta.connectionProbe ?? null,
|
|
20167
20168
|
});
|
|
20168
20169
|
}
|
|
20169
20170
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { RuntimeApiConnectionProbe } from './runtime-api-connection-probe';
|
|
1
2
|
import type { RuntimeMapHeapAdmissionSnapshot } from './map-memory-limits';
|
|
2
3
|
import type {
|
|
3
4
|
RuntimeMemoryLedger,
|
|
@@ -193,6 +194,8 @@ export type RuntimeResourceObservation = {
|
|
|
193
194
|
*/
|
|
194
195
|
gatewayRequestRawBytes?: number | null;
|
|
195
196
|
gatewayRequestWireBytes?: number | null;
|
|
197
|
+
/** One fresh connection's setup cost to the gateway origin (once per process). */
|
|
198
|
+
gatewayConnectionProbe?: RuntimeApiConnectionProbe | null;
|
|
196
199
|
/** Completion enqueue to the launch of the batch that carries it. */
|
|
197
200
|
receiptCompletionQueueMs?: number | null;
|
|
198
201
|
/**
|
|
@@ -455,6 +458,13 @@ export type RuntimeResourceSnapshot = {
|
|
|
455
458
|
rawBytes: number;
|
|
456
459
|
wireBytes: number;
|
|
457
460
|
};
|
|
461
|
+
/**
|
|
462
|
+
* One fresh connection to the gateway origin, measured once per runner
|
|
463
|
+
* process off the request path: DNS, TCP connect (about one round trip)
|
|
464
|
+
* and TLS. Set against `phases.gatewayRoundTrip` it says whether requests
|
|
465
|
+
* reuse connections. Absent until measured, and on older runners.
|
|
466
|
+
*/
|
|
467
|
+
connectionProbe?: RuntimeApiConnectionProbe;
|
|
458
468
|
};
|
|
459
469
|
providers: Record<
|
|
460
470
|
string,
|
|
@@ -1348,6 +1358,7 @@ export function createRuntimeResourceGovernor(input: {
|
|
|
1348
1358
|
upstreamHeadersMs: 0,
|
|
1349
1359
|
upstreamBodyMs: 0,
|
|
1350
1360
|
};
|
|
1361
|
+
let gatewayConnectionProbe: RuntimeApiConnectionProbe | null = null;
|
|
1351
1362
|
const gatewayAuthSessionCounters = {
|
|
1352
1363
|
hit: 0,
|
|
1353
1364
|
miss: 0,
|
|
@@ -1754,6 +1765,9 @@ export function createRuntimeResourceGovernor(input: {
|
|
|
1754
1765
|
if (observation.gatewayAuthSession != null) {
|
|
1755
1766
|
gatewayAuthSessionCounters[observation.gatewayAuthSession] += 1;
|
|
1756
1767
|
}
|
|
1768
|
+
if (observation.gatewayConnectionProbe != null) {
|
|
1769
|
+
gatewayConnectionProbe = observation.gatewayConnectionProbe;
|
|
1770
|
+
}
|
|
1757
1771
|
// Raw is the authority for the count: every request has serialized bytes,
|
|
1758
1772
|
// so a missing wire size (an older transport) adds nothing rather than
|
|
1759
1773
|
// silently reporting a request that moved zero bytes.
|
|
@@ -2225,6 +2239,9 @@ export function createRuntimeResourceGovernor(input: {
|
|
|
2225
2239
|
},
|
|
2226
2240
|
authSession: { ...gatewayAuthSessionCounters },
|
|
2227
2241
|
requestBody: { ...gatewayRequestBodyCounters },
|
|
2242
|
+
...(gatewayConnectionProbe
|
|
2243
|
+
? { connectionProbe: { ...gatewayConnectionProbe } }
|
|
2244
|
+
: {}),
|
|
2228
2245
|
},
|
|
2229
2246
|
rows: {
|
|
2230
2247
|
acquired: rowCounters.acquired,
|
|
@@ -2692,6 +2692,8 @@ async function run(
|
|
|
2692
2692
|
boundary: 'receipt_gateway' as const,
|
|
2693
2693
|
requestTimeoutMs: RUNTIME_RECEIPT_GATEWAY_REQUEST_TIMEOUT_MS,
|
|
2694
2694
|
onResponseMeta: receiptGatewayResponseObserver.onResponseMeta,
|
|
2695
|
+
// One fresh-connection measurement per runner process (diagnostic).
|
|
2696
|
+
probeConnection: true,
|
|
2695
2697
|
}
|
|
2696
2698
|
: null;
|
|
2697
2699
|
const canUseRuntimeStepReceipts = playRunnerRuntimeReceiptsEnabled(
|
|
@@ -1872,6 +1872,7 @@ async function createEarlyModalSandbox(
|
|
|
1872
1872
|
try {
|
|
1873
1873
|
const confirmAttempts = await terminateEarlySandboxConfirmed({
|
|
1874
1874
|
sandbox: late,
|
|
1875
|
+
reattach: lookups.fromId,
|
|
1875
1876
|
readExitCode: readEarlySandboxExitCode(lookups),
|
|
1876
1877
|
sleep: sleepMs,
|
|
1877
1878
|
attempts: EARLY_SANDBOX_TERMINATE_CONFIRM_ATTEMPTS,
|
|
@@ -546,13 +546,27 @@ const earlyTerminateConfirmDelayMs = (attempt: number) =>
|
|
|
546
546
|
*/
|
|
547
547
|
export async function terminateEarlySandboxConfirmed(input: {
|
|
548
548
|
sandbox: Pick<EarlySandboxHandle, 'terminate' | 'sandboxId'>;
|
|
549
|
+
/**
|
|
550
|
+
* A fresh handle for each re-terminate. Modal's `terminate()` detaches the
|
|
551
|
+
* handle it was called on, so re-terminating the same object throws
|
|
552
|
+
* "Unable to perform operation on a detached sandbox" (Production
|
|
553
|
+
* 2026-11-29, sb-jUEG8DC959LBI3LAEr2dUp: the first terminate went through,
|
|
554
|
+
* the confirmation reported unconfirmed).
|
|
555
|
+
*/
|
|
556
|
+
reattach: (
|
|
557
|
+
sandboxId: string,
|
|
558
|
+
) => Promise<Pick<EarlySandboxHandle, 'terminate'>>;
|
|
549
559
|
readExitCode: (sandboxId: string) => Promise<number | null>;
|
|
550
560
|
sleep: (ms: number) => Promise<void>;
|
|
551
561
|
attempts: number;
|
|
552
562
|
}): Promise<number> {
|
|
553
563
|
for (let attempt = 1; attempt <= input.attempts; attempt++) {
|
|
554
564
|
// Idempotent; repeated because a not-yet-running sandbox may miss it.
|
|
555
|
-
|
|
565
|
+
const handle =
|
|
566
|
+
attempt === 1
|
|
567
|
+
? input.sandbox
|
|
568
|
+
: await input.reattach(input.sandbox.sandboxId);
|
|
569
|
+
await handle.terminate();
|
|
556
570
|
if ((await input.readExitCode(input.sandbox.sandboxId)) !== null)
|
|
557
571
|
return attempt;
|
|
558
572
|
await input.sleep(earlyTerminateConfirmDelayMs(attempt));
|
|
@@ -591,6 +605,7 @@ export async function reapEarlySandboxById(input: {
|
|
|
591
605
|
if (!isUnadoptedEarlySandbox(tags)) return 'not_early';
|
|
592
606
|
const confirmAttempts = await terminateEarlySandboxConfirmed({
|
|
593
607
|
sandbox: fresh,
|
|
608
|
+
reattach: input.calls.fromId,
|
|
594
609
|
readExitCode: readEarlySandboxExitCode(input.calls),
|
|
595
610
|
sleep: input.sleep ?? sleepMs,
|
|
596
611
|
attempts: input.attempts ?? EARLY_SANDBOX_TERMINATE_CONFIRM_ATTEMPTS,
|
|
@@ -740,6 +755,7 @@ export async function sweepOrphanEarlySandboxes(input: {
|
|
|
740
755
|
claimed += 1;
|
|
741
756
|
const confirmAttempts = await terminateEarlySandboxConfirmed({
|
|
742
757
|
sandbox: fresh,
|
|
758
|
+
reattach: input.calls.fromId,
|
|
743
759
|
readExitCode: readEarlySandboxExitCode(input.calls),
|
|
744
760
|
sleep: input.sleep ?? sleepMs,
|
|
745
761
|
attempts: EARLY_SANDBOX_SWEEP_CONFIRM_ATTEMPTS,
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
import { lookup } from 'node:dns/promises';
|
|
2
|
+
import { connect as tlsConnect, type TLSSocket } from 'node:tls';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* One fresh connection's setup cost to the runtime API origin, measured once
|
|
6
|
+
* per runner process and origin, off the request path.
|
|
7
|
+
*
|
|
8
|
+
* Why: a receipt gateway round trip from a Modal sandbox is ~83 ms at p50
|
|
9
|
+
* while the gateway's own work is ~9 ms (Production, 2026-11-30). This probe
|
|
10
|
+
* separates path latency from per-request connection setup: compare
|
|
11
|
+
* `connectMs` (one TCP round trip) with the run's `gatewayRoundTrip`. A round
|
|
12
|
+
* trip near `connectMs` means requests reuse a connection; near
|
|
13
|
+
* `connectMs + tlsMs + connectMs` means each request pays a new connection.
|
|
14
|
+
*
|
|
15
|
+
* Bounded and allowlisted: numbers, the negotiated TLS protocol and ALPN, and a
|
|
16
|
+
* short error code. Never the URL, host, address, or any header.
|
|
17
|
+
*/
|
|
18
|
+
export type RuntimeApiConnectionProbe = {
|
|
19
|
+
outcome: 'ok' | 'error' | 'timeout';
|
|
20
|
+
/** DNS resolution of the origin host. */
|
|
21
|
+
dnsMs: number | null;
|
|
22
|
+
/** TCP connect: about one network round trip. */
|
|
23
|
+
connectMs: number | null;
|
|
24
|
+
/** TLS handshake after TCP connect. */
|
|
25
|
+
tlsMs: number | null;
|
|
26
|
+
totalMs: number;
|
|
27
|
+
tlsProtocol: string | null;
|
|
28
|
+
alpn: string | null;
|
|
29
|
+
errorCode: string | null;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export const RUNTIME_API_CONNECTION_PROBE_TIMEOUT_MS = 2_000;
|
|
33
|
+
const ERROR_CODE_PATTERN = /^[A-Z0-9_]{1,40}$/;
|
|
34
|
+
const TLS_PROTOCOL_PATTERN = /^TLSv1(\.[0-3])?$/;
|
|
35
|
+
const ALPN_PATTERN = /^(h2|http\/1\.1)$/;
|
|
36
|
+
|
|
37
|
+
const probes = new Map<string, Promise<RuntimeApiConnectionProbe | null>>();
|
|
38
|
+
const settled = new Map<string, RuntimeApiConnectionProbe | null>();
|
|
39
|
+
|
|
40
|
+
type ProbeDeps = {
|
|
41
|
+
lookup: (host: string) => Promise<{ address: string; family: number }>;
|
|
42
|
+
connect: typeof tlsConnect;
|
|
43
|
+
now: () => number;
|
|
44
|
+
timeoutMs: number;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const DEFAULT_DEPS: ProbeDeps = {
|
|
48
|
+
lookup: (host) => lookup(host),
|
|
49
|
+
connect: tlsConnect,
|
|
50
|
+
now: () => performance.now(),
|
|
51
|
+
timeoutMs: RUNTIME_API_CONNECTION_PROBE_TIMEOUT_MS,
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
function round(ms: number): number {
|
|
55
|
+
return Math.max(0, Math.round(ms));
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function errorCodeOf(error: unknown): string | null {
|
|
59
|
+
const code = (error as { code?: unknown } | null)?.code;
|
|
60
|
+
return typeof code === 'string' && ERROR_CODE_PATTERN.test(code)
|
|
61
|
+
? code
|
|
62
|
+
: null;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/** Measure one fresh connection to `baseUrl`'s origin. Never throws. */
|
|
66
|
+
export async function measureRuntimeApiConnection(
|
|
67
|
+
baseUrl: string,
|
|
68
|
+
deps: ProbeDeps = DEFAULT_DEPS,
|
|
69
|
+
): Promise<RuntimeApiConnectionProbe | null> {
|
|
70
|
+
let url: URL;
|
|
71
|
+
try {
|
|
72
|
+
url = new URL(baseUrl);
|
|
73
|
+
} catch {
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
if (url.protocol !== 'https:') return null;
|
|
77
|
+
const port = url.port ? Number(url.port) : 443;
|
|
78
|
+
const startedAt = deps.now();
|
|
79
|
+
let dnsMs: number | null = null;
|
|
80
|
+
let connectMs: number | null = null;
|
|
81
|
+
let tlsMs: number | null = null;
|
|
82
|
+
let socket: TLSSocket | null = null;
|
|
83
|
+
const result = (
|
|
84
|
+
outcome: RuntimeApiConnectionProbe['outcome'],
|
|
85
|
+
extra: Partial<RuntimeApiConnectionProbe> = {},
|
|
86
|
+
): RuntimeApiConnectionProbe => ({
|
|
87
|
+
outcome,
|
|
88
|
+
dnsMs,
|
|
89
|
+
connectMs,
|
|
90
|
+
tlsMs,
|
|
91
|
+
totalMs: round(deps.now() - startedAt),
|
|
92
|
+
tlsProtocol: null,
|
|
93
|
+
alpn: null,
|
|
94
|
+
errorCode: null,
|
|
95
|
+
...extra,
|
|
96
|
+
});
|
|
97
|
+
let timer: ReturnType<typeof setTimeout> | undefined;
|
|
98
|
+
const timeout = new Promise<RuntimeApiConnectionProbe>((resolve) => {
|
|
99
|
+
timer = setTimeout(() => resolve(result('timeout')), deps.timeoutMs);
|
|
100
|
+
(timer as { unref?: () => void }).unref?.();
|
|
101
|
+
});
|
|
102
|
+
const measured = (async (): Promise<RuntimeApiConnectionProbe> => {
|
|
103
|
+
try {
|
|
104
|
+
const dnsStartedAt = deps.now();
|
|
105
|
+
const { address } = await deps.lookup(url.hostname);
|
|
106
|
+
dnsMs = round(deps.now() - dnsStartedAt);
|
|
107
|
+
const connectStartedAt = deps.now();
|
|
108
|
+
return await new Promise<RuntimeApiConnectionProbe>((resolve) => {
|
|
109
|
+
let tcpAt: number | null = null;
|
|
110
|
+
socket = deps.connect({
|
|
111
|
+
host: address,
|
|
112
|
+
port,
|
|
113
|
+
servername: url.hostname,
|
|
114
|
+
ALPNProtocols: ['h2', 'http/1.1'],
|
|
115
|
+
});
|
|
116
|
+
socket.once('connect', () => {
|
|
117
|
+
tcpAt = deps.now();
|
|
118
|
+
connectMs = round(tcpAt - connectStartedAt);
|
|
119
|
+
});
|
|
120
|
+
socket.once('secureConnect', () => {
|
|
121
|
+
const secureAt = deps.now();
|
|
122
|
+
tlsMs = round(secureAt - (tcpAt ?? connectStartedAt));
|
|
123
|
+
const protocol = socket?.getProtocol?.() ?? null;
|
|
124
|
+
const alpn = socket?.alpnProtocol;
|
|
125
|
+
resolve(
|
|
126
|
+
result('ok', {
|
|
127
|
+
tlsProtocol:
|
|
128
|
+
typeof protocol === 'string' &&
|
|
129
|
+
TLS_PROTOCOL_PATTERN.test(protocol)
|
|
130
|
+
? protocol
|
|
131
|
+
: null,
|
|
132
|
+
alpn:
|
|
133
|
+
typeof alpn === 'string' && ALPN_PATTERN.test(alpn)
|
|
134
|
+
? alpn
|
|
135
|
+
: null,
|
|
136
|
+
}),
|
|
137
|
+
);
|
|
138
|
+
});
|
|
139
|
+
// Persistent: a socket that errors again after the first error (or
|
|
140
|
+
// after destroy) must never surface an unhandled 'error' event in
|
|
141
|
+
// the runner process. Resolving twice is a no-op.
|
|
142
|
+
socket.on('error', (error) =>
|
|
143
|
+
resolve(result('error', { errorCode: errorCodeOf(error) })),
|
|
144
|
+
);
|
|
145
|
+
});
|
|
146
|
+
} catch (error) {
|
|
147
|
+
return result('error', { errorCode: errorCodeOf(error) });
|
|
148
|
+
}
|
|
149
|
+
})();
|
|
150
|
+
try {
|
|
151
|
+
return await Promise.race([measured, timeout]);
|
|
152
|
+
} finally {
|
|
153
|
+
clearTimeout(timer);
|
|
154
|
+
(socket as TLSSocket | null)?.destroy();
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Start the probe for `baseUrl`'s origin once per process; later calls share
|
|
160
|
+
* the first. The returned promise never rejects.
|
|
161
|
+
*/
|
|
162
|
+
export function runtimeApiConnectionProbe(
|
|
163
|
+
baseUrl: string,
|
|
164
|
+
): Promise<RuntimeApiConnectionProbe | null> {
|
|
165
|
+
let origin: string;
|
|
166
|
+
try {
|
|
167
|
+
origin = new URL(baseUrl).origin;
|
|
168
|
+
} catch {
|
|
169
|
+
return Promise.resolve(null);
|
|
170
|
+
}
|
|
171
|
+
let probe = probes.get(origin);
|
|
172
|
+
if (!probe) {
|
|
173
|
+
probe = measureRuntimeApiConnection(origin)
|
|
174
|
+
.catch(() => null)
|
|
175
|
+
.then((value) => {
|
|
176
|
+
settled.set(origin, value);
|
|
177
|
+
return value;
|
|
178
|
+
});
|
|
179
|
+
probes.set(origin, probe);
|
|
180
|
+
}
|
|
181
|
+
return probe;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/** The probe for `baseUrl`'s origin once it has settled; null until then. */
|
|
185
|
+
export function settledRuntimeApiConnectionProbe(
|
|
186
|
+
baseUrl: string,
|
|
187
|
+
): RuntimeApiConnectionProbe | null {
|
|
188
|
+
try {
|
|
189
|
+
return settled.get(new URL(baseUrl).origin) ?? null;
|
|
190
|
+
} catch {
|
|
191
|
+
return null;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/** Test seam: forget probes so each test starts fresh. */
|
|
196
|
+
export function resetRuntimeApiConnectionProbesForTests(): void {
|
|
197
|
+
probes.clear();
|
|
198
|
+
settled.clear();
|
|
199
|
+
}
|
|
@@ -20314,6 +20314,49 @@ export async function executePostgresSchedulerClaim(
|
|
|
20314
20314
|
terminalFailureResult,
|
|
20315
20315
|
options.terminalLogOutbox,
|
|
20316
20316
|
);
|
|
20317
|
+
// A stop committed before this failure is the run's real outcome: the
|
|
20318
|
+
// cancellation's own sandbox termination is what usually fails a launch
|
|
20319
|
+
// ("Modal Sandbox is shutting down"). Settle it through the owner's
|
|
20320
|
+
// cancellation transition instead of recording a failure; the queued
|
|
20321
|
+
// request's reconciler then finds the run terminal and retires it. The
|
|
20322
|
+
// typed-wait failure path keeps its own guard for this case, and a
|
|
20323
|
+
// preserved runner terminal (detached recovery) is never overridden: a
|
|
20324
|
+
// runner that already pushed its own terminal keeps it.
|
|
20325
|
+
if (
|
|
20326
|
+
!options.protectWaitingSuspensionFailure &&
|
|
20327
|
+
!options.preserveRunnerTerminal
|
|
20328
|
+
) {
|
|
20329
|
+
const requestedCancellation = await client.query<{
|
|
20330
|
+
reason: string | null;
|
|
20331
|
+
}>(
|
|
20332
|
+
`SELECT value->>'reason' AS reason
|
|
20333
|
+
FROM ${tableName('control', options)}
|
|
20334
|
+
WHERE key = 'runtime_cancel:' || $1`,
|
|
20335
|
+
[claim.runId],
|
|
20336
|
+
);
|
|
20337
|
+
const cancellation = requestedCancellation.rows[0];
|
|
20338
|
+
if (
|
|
20339
|
+
cancellation &&
|
|
20340
|
+
(await cancelPostgresSchedulerRun(
|
|
20341
|
+
client,
|
|
20342
|
+
{
|
|
20343
|
+
runId: claim.runId,
|
|
20344
|
+
reason: cancellation.reason?.trim() || 'Cancelled play run.',
|
|
20345
|
+
},
|
|
20346
|
+
options,
|
|
20347
|
+
))
|
|
20348
|
+
) {
|
|
20349
|
+
console.info(
|
|
20350
|
+
'[postgres-scheduler] failure_superseded_by_cancellation',
|
|
20351
|
+
{
|
|
20352
|
+
runId: claim.runId,
|
|
20353
|
+
attempt: claim.attempt,
|
|
20354
|
+
error: message.slice(0, 500),
|
|
20355
|
+
},
|
|
20356
|
+
);
|
|
20357
|
+
return { status: 'idle' };
|
|
20358
|
+
}
|
|
20359
|
+
}
|
|
20317
20360
|
const failed = await failPostgresSchedulerAttempt(
|
|
20318
20361
|
client,
|
|
20319
20362
|
{
|
|
@@ -14,15 +14,15 @@ import {
|
|
|
14
14
|
reportSetupCompleted,
|
|
15
15
|
resolvePendingAuthClaimForResume,
|
|
16
16
|
statusBannerLine
|
|
17
|
-
} from "./chunk-
|
|
18
|
-
import "./chunk-
|
|
19
|
-
import "./chunk-
|
|
20
|
-
import "./chunk-
|
|
17
|
+
} from "./chunk-C6XV2DPY.mjs";
|
|
18
|
+
import "./chunk-QRMTITKL.mjs";
|
|
19
|
+
import "./chunk-CR6IPQBB.mjs";
|
|
20
|
+
import "./chunk-A3IVPA6Q.mjs";
|
|
21
21
|
import "./chunk-ASB47RXJ.mjs";
|
|
22
22
|
import "./chunk-DLIRSHV6.mjs";
|
|
23
23
|
import "./chunk-Z3A2S3QM.mjs";
|
|
24
24
|
import "./chunk-2MGZAI54.mjs";
|
|
25
|
-
import "./chunk-
|
|
25
|
+
import "./chunk-Z3DSCE5F.mjs";
|
|
26
26
|
import "./chunk-WZYKRD7T.mjs";
|
|
27
27
|
import "./chunk-KRD6H754.mjs";
|
|
28
28
|
export {
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
var _chunk2IZOCGOAjs = require('./chunk-2IZOCGOA.js');
|
|
18
|
+
require('./chunk-6N3NTEJ6.js');
|
|
19
|
+
require('./chunk-A5HDA22N.js');
|
|
20
|
+
require('./chunk-7JGHNZTD.js');
|
|
21
|
+
require('./chunk-6VLFQZK6.js');
|
|
22
|
+
require('./chunk-XNYIZMNQ.js');
|
|
23
|
+
require('./chunk-LFQJW4S2.js');
|
|
24
|
+
require('./chunk-CFJFUVX2.js');
|
|
25
|
+
require('./chunk-IFKZQCPX.js');
|
|
26
|
+
require('./chunk-OG64RBAC.js');
|
|
27
|
+
require('./chunk-COGTRVWW.js');
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
exports.EXIT_WORKSPACE_MISMATCH = _chunk2IZOCGOAjs.EXIT_WORKSPACE_MISMATCH; exports.authStatusLine = _chunk2IZOCGOAjs.authStatusLine; exports.clearPendingClaim = _chunk2IZOCGOAjs.clearPendingClaim; exports.clearSatisfiedPendingClaim = _chunk2IZOCGOAjs.clearSatisfiedPendingClaim; exports.handleRegister = _chunk2IZOCGOAjs.handleRegister; exports.handleStatus = _chunk2IZOCGOAjs.handleStatus; exports.handleWait = _chunk2IZOCGOAjs.handleWait; exports.httpJson = _chunk2IZOCGOAjs.httpJson; exports.readPendingAuthClaim = _chunk2IZOCGOAjs.readPendingAuthClaim; exports.readStatusBanner = _chunk2IZOCGOAjs.readStatusBanner; exports.registerAuthCommands = _chunk2IZOCGOAjs.registerAuthCommands; exports.reportApprovalLinkShown = _chunk2IZOCGOAjs.reportApprovalLinkShown; exports.reportSetupCompleted = _chunk2IZOCGOAjs.reportSetupCompleted; exports.resolvePendingAuthClaimForResume = _chunk2IZOCGOAjs.resolvePendingAuthClaimForResume; exports.statusBannerLine = _chunk2IZOCGOAjs.statusBannerLine;
|