deepline 0.3.536 → 0.3.538
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundling-sources/sdk/src/client-core.ts +22 -5
- package/dist/bundling-sources/sdk/src/index.ts +2 -0
- package/dist/bundling-sources/sdk/src/plays/client-core.ts +18 -1
- package/dist/bundling-sources/sdk/src/release.ts +1 -1
- package/dist/bundling-sources/sdk/src/runs/watch-polling.ts +33 -4
- package/dist/bundling-sources/shared_libs/integration-contracts/billing-entitlements.ts +1 -1
- package/dist/bundling-sources/shared_libs/observability/scheduled-jobs.json +36 -0
- package/dist/bundling-sources/shared_libs/play-runtime/app-runtime-api.ts +1 -0
- package/dist/bundling-sources/shared_libs/play-runtime/baked-runner-image.ts +330 -0
- package/dist/bundling-sources/shared_libs/play-runtime/context.ts +717 -133
- package/dist/bundling-sources/shared_libs/play-runtime/coordinator-headers.ts +7 -0
- package/dist/bundling-sources/shared_libs/play-runtime/daytona-payload-contract.ts +22 -1
- package/dist/bundling-sources/shared_libs/play-runtime/durable-runs-rollout.ts +123 -0
- package/dist/bundling-sources/shared_libs/play-runtime/experiment-switches.ts +480 -0
- package/dist/bundling-sources/shared_libs/play-runtime/fixture-egress-fetch.ts +24 -16
- package/dist/bundling-sources/shared_libs/play-runtime/freshness-receipt-execution.ts +293 -53
- package/dist/bundling-sources/shared_libs/play-runtime/governor/block-reserving-budget-state-backend.ts +57 -2
- package/dist/bundling-sources/shared_libs/play-runtime/governor/budget-state-backend.ts +43 -0
- package/dist/bundling-sources/shared_libs/play-runtime/governor/governor.ts +141 -9
- package/dist/bundling-sources/shared_libs/play-runtime/launch-identity.ts +2 -0
- package/dist/bundling-sources/shared_libs/play-runtime/modal-runtime-config.ts +6 -0
- package/dist/bundling-sources/shared_libs/play-runtime/modal-supervisor-sidecar.ts +556 -0
- package/dist/bundling-sources/shared_libs/play-runtime/protocol.ts +27 -0
- package/dist/bundling-sources/shared_libs/play-runtime/resource-governor.ts +19 -0
- package/dist/bundling-sources/shared_libs/play-runtime/run-ledger.ts +54 -0
- package/dist/bundling-sources/shared_libs/play-runtime/run-snapshot-stream.ts +5 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runner-app/index.ts +155 -3
- package/dist/bundling-sources/shared_libs/play-runtime/runner-app/relay-connection-counter.ts +103 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runner-app/runtime-heartbeat.ts +75 -6
- package/dist/bundling-sources/shared_libs/play-runtime/runner-app/runtime-terminal-push.ts +59 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-payload-transport.ts +544 -73
- package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-runtime-watchdog.ts +8 -1
- package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/detached-runner-readiness-pacing.ts +19 -1
- package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/modal.ts +2390 -110
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-flow.ts +42 -8
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-read-through.ts +287 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-receipt-finish.ts +606 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-receipt-writer.ts +274 -119
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-traffic-policy.ts +54 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-work-counters.ts +10 -1
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backend.ts +15 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-play-run-task.ts +18 -1
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-pool.ts +18 -4
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-runtime-worker.ts +219 -7
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-shared.ts +3 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/early-sandbox-claim-affinity.ts +340 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/play-run-recovery.ts +1 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres-progress.ts +10 -1
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres-rate-state.ts +623 -7
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres.ts +340 -5
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runner-push.ts +61 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-event-search.ts +2 -1
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-sandbox-ledger-reconciliation.ts +269 -2
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-worker-wake.ts +238 -5
- package/dist/bundling-sources/shared_libs/play-runtime/startup-read-tool-ids.ts +47 -0
- package/dist/bundling-sources/shared_libs/play-runtime/tool-call/runtime-step-receipts-adapter.ts +5 -4
- package/dist/bundling-sources/shared_libs/play-runtime/tool-result.ts +6 -0
- package/dist/bundling-sources/shared_libs/play-runtime/transient-service-error.ts +11 -0
- package/dist/cli/auth-4WEVLYK4.js +43 -0
- package/dist/cli/{auth-KCTCUO7P.mjs → auth-KYH7N7RQ.mjs} +5 -5
- package/dist/cli/{billing-4VBGZ3CT.js → billing-4KTUVZ4S.js} +114 -90
- package/dist/cli/{billing-OOJHKLNS.mjs → billing-WK346KAI.mjs} +31 -7
- package/dist/cli/{chunk-4E5JXZ3W.js → chunk-25RGHJQL.js} +15 -15
- package/dist/cli/{chunk-MSP4DTSD.js → chunk-34PLG5OE.js} +13 -13
- package/dist/cli/{chunk-DQHUJMCL.mjs → chunk-35OCRH5C.mjs} +5 -5
- package/dist/cli/{chunk-2B4IOGFD.js → chunk-3I5TU5XE.js} +292 -279
- package/dist/cli/{chunk-Z7UIOGW4.mjs → chunk-4KZF6OYY.mjs} +3 -3
- package/dist/cli/{chunk-2YWJS76L.mjs → chunk-4NEOGPKD.mjs} +1 -1
- package/dist/cli/{chunk-LZXZQPA2.mjs → chunk-4WQR4DG4.mjs} +1 -1
- package/dist/cli/{chunk-KWYGWO4Y.js → chunk-5VSPRRTI.js} +7 -7
- package/dist/cli/{chunk-ANUKBZ6W.mjs → chunk-6JG3MRTM.mjs} +2 -2
- package/dist/cli/{chunk-VBDZIMWD.js → chunk-6SLQLWWL.js} +26 -26
- package/dist/cli/{chunk-E24UGPGG.mjs → chunk-7XDJKIM2.mjs} +4 -4
- package/dist/cli/{chunk-OUDTOMZC.mjs → chunk-A6E7TCK2.mjs} +5 -5
- package/dist/cli/{chunk-ZZ4MF2GI.js → chunk-ADLDU2QG.js} +6 -6
- package/dist/cli/{chunk-XVZRJJDS.mjs → chunk-ALARRSMZ.mjs} +3 -3
- package/dist/cli/{chunk-HWDKRN7L.js → chunk-B2BTBHX2.js} +3 -3
- package/dist/cli/{chunk-ZISEH7OL.js → chunk-BBS2BLPV.js} +16 -16
- package/dist/cli/{chunk-YRLAUGQY.mjs → chunk-CLO562KG.mjs} +3 -1
- package/dist/cli/{chunk-CXTW7SRW.mjs → chunk-E7D37PLM.mjs} +8 -0
- package/dist/cli/{chunk-SLPJ3LXI.js → chunk-ESX3H7Q7.js} +22 -22
- package/dist/cli/{chunk-AB2GBOD4.mjs → chunk-FJ5KPGCS.mjs} +10 -10
- package/dist/cli/{chunk-DUYAMLOC.mjs → chunk-FWE37N2P.mjs} +1 -1
- package/dist/cli/{chunk-3PCYV6ZJ.mjs → chunk-ICTA5ICE.mjs} +1 -1
- package/dist/cli/{chunk-ZILSRDIN.js → chunk-IMLFB66A.js} +3 -3
- package/dist/cli/{chunk-PNY3BWHP.mjs → chunk-IP3XJTWA.mjs} +2 -2
- package/dist/cli/{chunk-6VUGBQZQ.js → chunk-JCLRSMUP.js} +5 -5
- package/dist/cli/{chunk-YBMHOH6H.mjs → chunk-JPEBKN3K.mjs} +2 -2
- package/dist/cli/{chunk-GF32SBST.mjs → chunk-JTOV5RUA.mjs} +1 -1
- package/dist/cli/{chunk-Q5CXV3E3.js → chunk-KCUQNH4K.js} +2 -2
- package/dist/cli/{chunk-DA2I2M7D.mjs → chunk-KNIYEZVV.mjs} +2 -2
- package/dist/cli/{chunk-CWSLUNA6.js → chunk-LPTBHNGB.js} +7 -5
- package/dist/cli/{chunk-WC5M3JXE.mjs → chunk-M3NCXGNN.mjs} +2 -2
- package/dist/cli/{chunk-TX5TUHJN.js → chunk-MNBIGX6O.js} +10 -10
- package/dist/cli/{chunk-ZEV2Y56V.js → chunk-MYSPQUAO.js} +44 -44
- package/dist/cli/{chunk-KPQHUVYW.mjs → chunk-N2BCPZVR.mjs} +5 -5
- package/dist/cli/{chunk-XBAH3TKU.js → chunk-N5HSG4OV.js} +5 -5
- package/dist/cli/{chunk-GTVZKY3F.js → chunk-O765M4LT.js} +2 -2
- package/dist/cli/{chunk-2FCSUOYN.js → chunk-OOLBE6FR.js} +53 -53
- package/dist/cli/{chunk-W7AEIGZR.js → chunk-P3DP56HB.js} +41 -41
- package/dist/cli/{chunk-LN6RXDTB.js → chunk-PQKD5DMT.js} +19 -19
- package/dist/cli/{chunk-GHLDCLSC.mjs → chunk-T6GPTJ5F.mjs} +1 -1
- package/dist/cli/{chunk-XJD2GYUP.mjs → chunk-TWWYCJJW.mjs} +5 -5
- package/dist/cli/{chunk-BASLYGXK.mjs → chunk-UE7JHAZ2.mjs} +29 -16
- package/dist/cli/{chunk-Q4MNUOS4.js → chunk-UEZNIPFO.js} +107 -107
- package/dist/cli/{chunk-RVSSQPQO.mjs → chunk-VCHV4LS3.mjs} +1 -1
- package/dist/cli/{chunk-LDGZFDUB.js → chunk-VIFLWQXS.js} +2 -2
- package/dist/cli/{chunk-6BBGUQJJ.js → chunk-XTYHZEJ2.js} +8 -0
- package/dist/cli/{chunk-CIDN5K23.js → chunk-YQURGSRB.js} +1 -1
- package/dist/cli/{chunk-Y2NTPYGS.js → chunk-YZ2ZPHWR.js} +9 -9
- package/dist/cli/{chunk-HAJQGP5V.mjs → chunk-ZDLDCXY3.mjs} +2 -2
- package/dist/cli/{chunk-JUHDJNSI.mjs → chunk-ZU6JBRV5.mjs} +4 -4
- package/dist/cli/command-docs.js +2 -2
- package/dist/cli/command-docs.mjs +1 -1
- package/dist/cli/{csv-P3HLK4GO.mjs → csv-2YKLUKDR.mjs} +4 -4
- package/dist/cli/{csv-2V2DIFNG.js → csv-LM7FBECI.js} +13 -13
- package/dist/cli/{db-ZYOY3QRQ.mjs → db-234UBWJH.mjs} +6 -6
- package/dist/cli/{db-MREAQVW6.js → db-5PMA4IVW.js} +27 -27
- package/dist/cli/describe-C7GOSGYB.js +49 -0
- package/dist/cli/{describe-IKZFOADR.mjs → describe-W26LW5O7.mjs} +17 -17
- package/dist/cli/describe-core.d.mts +3 -3
- package/dist/cli/describe-core.d.ts +3 -3
- package/dist/cli/{executions-H5IJ7QSQ.js → executions-3S736GXX.js} +8 -8
- package/dist/cli/{executions-KTSY5M34.mjs → executions-GD7GXTJM.mjs} +6 -6
- package/dist/cli/{feedback-724QK3Z5.js → feedback-BUWTDY4R.js} +14 -14
- package/dist/cli/{feedback-WWJRIXEU.mjs → feedback-GBV5HJJZ.mjs} +6 -6
- package/dist/cli/git-YG36MROC.js +25 -0
- package/dist/cli/{git-R5VRG7X6.mjs → git-YXJGTDQL.mjs} +5 -5
- package/dist/cli/index.js +143 -143
- package/dist/cli/index.mjs +42 -42
- package/dist/cli/{legacy-noops-PWZ5XLAO.mjs → legacy-noops-UJM6GBNP.mjs} +6 -6
- package/dist/cli/{legacy-noops-C6GDEGPU.js → legacy-noops-ZSF64V2U.js} +9 -9
- package/dist/cli/{monitors-WQSKMHAP.mjs → monitors-UERUQ6CT.mjs} +7 -7
- package/dist/cli/{monitors-VAVQ4WCE.js → monitors-XQ2GNH6D.js} +100 -100
- package/dist/cli/{org-MAL4QPVF.mjs → org-CP4VLH6M.mjs} +6 -6
- package/dist/cli/{org-CWWRWXZQ.js → org-IF6MPVNR.js} +86 -86
- package/dist/cli/{play-WJOWK5PQ.js → play-2NHQO5MO.js} +317 -317
- package/dist/cli/{play-ILW6MSNG.mjs → play-ZWDYYVPI.mjs} +17 -17
- package/dist/cli/{providers-4V2NMLZZ.mjs → providers-2CVIATU4.mjs} +6 -6
- package/dist/cli/{providers-W662ANCH.js → providers-LOPXQN56.js} +9 -9
- package/dist/cli/{quickstart-C22BR743.mjs → quickstart-KVCFXLID.mjs} +4 -4
- package/dist/cli/{quickstart-BW6EBUYX.js → quickstart-N4WDEQZY.js} +6 -6
- package/dist/cli/{run-KW7KW4FX.js → run-BDT5LK3I.js} +42 -42
- package/dist/cli/{run-SPAU5IMW.mjs → run-RUXHYWLF.mjs} +22 -22
- package/dist/cli/search-ATDDVADT.js +32 -0
- package/dist/cli/{search-XPC75HLM.mjs → search-BFUTNPA5.mjs} +7 -7
- package/dist/cli/{search-output-VJYE7USJ.js → search-output-CTXI2QZU.js} +6 -6
- package/dist/cli/{search-output-JKYJSEPM.mjs → search-output-WUGH4PZA.mjs} +4 -4
- package/dist/cli/{secrets-YB57KGSB.js → secrets-BZJZYFOU.js} +15 -15
- package/dist/cli/{secrets-OJG73GXQ.mjs → secrets-Z4XQVTC6.mjs} +6 -6
- package/dist/cli/sessions-HNU35AFM.js +22 -0
- package/dist/cli/{sessions-7ZL37BW4.mjs → sessions-VZXR3MQZ.mjs} +6 -6
- package/dist/cli/{settings-RKSQB7FA.mjs → settings-VYEZFR4L.mjs} +12 -12
- package/dist/cli/{settings-A7DD2ZYE.js → settings-WBYA4JMM.js} +85 -85
- package/dist/cli/{setup-S3K5YU62.js → setup-FS2RMSS2.js} +49 -49
- package/dist/cli/{setup-NXDUTITY.mjs → setup-H7KCI4SO.mjs} +9 -9
- package/dist/cli/skills-VPIURCAZ.js +36 -0
- package/dist/cli/{skills-VMFAIDO6.mjs → skills-YQNSJUUG.mjs} +7 -7
- package/dist/cli/tools-273GS5HU.js +56 -0
- package/dist/cli/{tools-52NTHBSJ.mjs → tools-ZF6SVEGW.mjs} +16 -16
- package/dist/cli/{update-SAKBEKMV.mjs → update-RKQNNJM4.mjs} +9 -9
- package/dist/cli/update-TOD3XY55.js +34 -0
- package/dist/cli/{views-ACRV7MD6.mjs → views-JHHOTWDU.mjs} +6 -6
- package/dist/cli/{views-C3GJOBDG.js → views-KN7FEDGT.js} +21 -21
- package/dist/cli/{workflow-ZNWCZEGN.js → workflow-2WHSKTTV.js} +17 -17
- package/dist/cli/{workflow-CS22E7TC.mjs → workflow-AAYLCLWA.mjs} +7 -7
- package/dist/{client-BlLYQDNo.d.mts → client-D0uDBybG.d.mts} +1 -1
- package/dist/{client-DSQlkIDO.d.ts → client-DZTnAv4B.d.ts} +1 -1
- package/dist/{client-core-rX7n2H8U.d.mts → client-core-BhWf8Y1b.d.mts} +15 -2
- package/dist/{client-core-CDwapXy5.d.ts → client-core-og3AP1LL.d.ts} +15 -2
- package/dist/{compiler-manifest-BHNC4RL-.d.mts → compiler-manifest-Bes3OVA3.d.mts} +1 -1
- package/dist/{compiler-manifest-BHNC4RL-.d.ts → compiler-manifest-Bes3OVA3.d.ts} +1 -1
- package/dist/{errors-lhtIWG5Z.d.ts → errors-BJm4lLWc.d.ts} +1 -1
- package/dist/{errors-D7sPXrvB.d.mts → errors-Dc5r42ks.d.mts} +1 -1
- package/dist/{index-CQTBHXHr.d.ts → index-BfV7mRPF.d.ts} +1 -1
- package/dist/{index-NaDZq2xf.d.mts → index-DTkiz_Ur.d.mts} +1 -1
- package/dist/index.d.mts +7 -7
- package/dist/index.d.ts +7 -7
- package/dist/index.js +9 -9
- package/dist/index.mjs +6 -6
- package/dist/install-integrity.json +120 -112
- package/dist/plays/bundle-play-file.d.mts +3 -3
- package/dist/plays/bundle-play-file.d.ts +3 -3
- package/dist/plays/play-description.d.mts +2 -2
- package/dist/plays/play-description.d.ts +2 -2
- package/dist/plays/run-request.d.mts +2 -2
- package/dist/plays/run-request.d.ts +2 -2
- package/dist/release.d.mts +1 -1
- package/dist/release.d.ts +1 -1
- package/dist/release.js +2 -2
- package/dist/release.mjs +1 -1
- package/dist/server.d.mts +4 -4
- package/dist/server.d.ts +4 -4
- package/dist/server.js +5 -5
- package/dist/server.mjs +3 -3
- package/package.json +1 -1
- package/dist/cli/auth-6XQKFOLG.js +0 -43
- package/dist/cli/describe-WW3OQRLP.js +0 -49
- package/dist/cli/git-PHYRD56H.js +0 -25
- package/dist/cli/search-HLE54W5G.js +0 -32
- package/dist/cli/sessions-VEBYZIEU.js +0 -22
- package/dist/cli/skills-NVQ744CN.js +0 -36
- package/dist/cli/tools-SBDUL3WB.js +0 -56
- package/dist/cli/update-HHVFZPCV.js +0 -34
|
@@ -89,6 +89,7 @@ import {
|
|
|
89
89
|
normalizePlayRunIntegrationMode,
|
|
90
90
|
normalizePlayStatus,
|
|
91
91
|
resolveStartPlayRunRequest,
|
|
92
|
+
playRunStartHeaders,
|
|
92
93
|
runtimeSelectionHeaders,
|
|
93
94
|
} from './plays/client-core';
|
|
94
95
|
import { PRODUCT_NOTIFICATION_SLACK_OAUTH_SCOPES } from '../../shared_libs/product-notifications/contract.js';
|
|
@@ -2592,6 +2593,18 @@ export type WorkspacesNamespace = {
|
|
|
2592
2593
|
serviceAccounts: WorkspaceServiceAccountsNamespace;
|
|
2593
2594
|
};
|
|
2594
2595
|
|
|
2596
|
+
/** Recorded retained-result consumers, not counterfactual credit savings. */
|
|
2597
|
+
export type WorkspaceReuseResult = {
|
|
2598
|
+
org_id: string;
|
|
2599
|
+
reuse: {
|
|
2600
|
+
reused_result_calls: number;
|
|
2601
|
+
confirmed_runs: number;
|
|
2602
|
+
recorded_since: number;
|
|
2603
|
+
updated_at: number;
|
|
2604
|
+
coverage: 'confirmed_recorded_runs';
|
|
2605
|
+
} | null;
|
|
2606
|
+
};
|
|
2607
|
+
|
|
2595
2608
|
/** One authenticated per-request usage event from `/api/v2/usage/events`. */
|
|
2596
2609
|
export type BillingUsageEvent = {
|
|
2597
2610
|
id: string | null;
|
|
@@ -2783,6 +2796,8 @@ export type BillingNamespace = {
|
|
|
2783
2796
|
) => Promise<BillingUsageEventsResult>;
|
|
2784
2797
|
/** Read current billing usage, or look up one exact execution charge by request ID. */
|
|
2785
2798
|
usage: (options?: BillingUsageOptions) => Promise<BillingUsageResult>;
|
|
2799
|
+
/** Recorded result reuse; historical or incomplete runs are excluded. */
|
|
2800
|
+
reuse: () => Promise<WorkspaceReuseResult>;
|
|
2786
2801
|
/** Metronome-authored target catalog and current Contract projection. */
|
|
2787
2802
|
targetPlans: (options?: {
|
|
2788
2803
|
promoCode?: string;
|
|
@@ -3272,6 +3287,7 @@ export class DeeplineClient {
|
|
|
3272
3287
|
usageEvent: (requestId) => this.getBillingUsageEvent(requestId),
|
|
3273
3288
|
usageEvents: (options) => this.getBillingUsageEvents(options),
|
|
3274
3289
|
usage: (options) => this.getBillingUsage(options),
|
|
3290
|
+
reuse: () => this.http.get<WorkspaceReuseResult>('/api/v2/usage/reuse'),
|
|
3275
3291
|
targetPlans: (options) => this.getTargetBillingPlans(options),
|
|
3276
3292
|
targetStatus: () => this.getTargetBillingStatus(),
|
|
3277
3293
|
autoRecharge: {
|
|
@@ -3556,9 +3572,7 @@ export class DeeplineClient {
|
|
|
3556
3572
|
|
|
3557
3573
|
/** The view's share links, newest first. Their tokens are never returned. */
|
|
3558
3574
|
async listViewShareLinks(id: string): Promise<{ links: ViewShareLink[] }> {
|
|
3559
|
-
return await this.http.get(
|
|
3560
|
-
`/api/v2/views/${encodeURIComponent(id)}/links`,
|
|
3561
|
-
);
|
|
3575
|
+
return await this.http.get(`/api/v2/views/${encodeURIComponent(id)}/links`);
|
|
3562
3576
|
}
|
|
3563
3577
|
|
|
3564
3578
|
/**
|
|
@@ -3587,7 +3601,10 @@ export class DeeplineClient {
|
|
|
3587
3601
|
}
|
|
3588
3602
|
|
|
3589
3603
|
/** Revoke a share link. It stops opening the view at once. */
|
|
3590
|
-
async revokeViewShareLink(
|
|
3604
|
+
async revokeViewShareLink(
|
|
3605
|
+
id: string,
|
|
3606
|
+
linkId: string,
|
|
3607
|
+
): Promise<ViewShareLink> {
|
|
3591
3608
|
return await this.http.delete(
|
|
3592
3609
|
`/api/v2/views/${encodeURIComponent(id)}/links/${encodeURIComponent(linkId)}`,
|
|
3593
3610
|
);
|
|
@@ -4066,7 +4083,7 @@ export class DeeplineClient {
|
|
|
4066
4083
|
options,
|
|
4067
4084
|
);
|
|
4068
4085
|
const bodyJson = JSON.stringify(prepared.body);
|
|
4069
|
-
const runtimeHeaders =
|
|
4086
|
+
const runtimeHeaders = playRunStartHeaders(
|
|
4070
4087
|
resolved.runtime,
|
|
4071
4088
|
this.environment,
|
|
4072
4089
|
);
|
|
@@ -25,6 +25,7 @@ import {
|
|
|
25
25
|
type PlayRunStartOptions,
|
|
26
26
|
} from './run-request';
|
|
27
27
|
import {
|
|
28
|
+
EXPERIMENT_SWITCHES_HEADER,
|
|
28
29
|
RUNTIME_ENVIRONMENT_TOKEN_HEADER,
|
|
29
30
|
RETAINED_PIPELINE_RECEIVERS_HEADER,
|
|
30
31
|
} from '../../../shared_libs/play-runtime/coordinator-headers.js';
|
|
@@ -230,6 +231,22 @@ export function runtimeSelectionHeaders(
|
|
|
230
231
|
};
|
|
231
232
|
}
|
|
232
233
|
|
|
234
|
+
/**
|
|
235
|
+
* Headers for a Play run start: the runtime selection credential plus, for
|
|
236
|
+
* internal measurement only, `DEEPLINE_EXPERIMENT_SWITCHES` forwarded verbatim.
|
|
237
|
+
* The server validates and authorizes it and rejects a bad or unauthorized
|
|
238
|
+
* value; the SDK never interprets it.
|
|
239
|
+
*/
|
|
240
|
+
export function playRunStartHeaders(
|
|
241
|
+
runtime: PlayRunRuntimeSelection | undefined,
|
|
242
|
+
env: ClientEnvironment,
|
|
243
|
+
): Record<string, string> | undefined {
|
|
244
|
+
const headers = runtimeSelectionHeaders(runtime, env);
|
|
245
|
+
const experimentSwitches = env.DEEPLINE_EXPERIMENT_SWITCHES?.trim();
|
|
246
|
+
if (!experimentSwitches) return headers;
|
|
247
|
+
return { ...headers, [EXPERIMENT_SWITCHES_HEADER]: experimentSwitches };
|
|
248
|
+
}
|
|
249
|
+
|
|
233
250
|
function normalizeTestPolicyOverrides(
|
|
234
251
|
value: unknown,
|
|
235
252
|
source: string,
|
|
@@ -327,7 +344,7 @@ export class PlayClient {
|
|
|
327
344
|
options?: PlayRunStartOptions,
|
|
328
345
|
): Promise<PlayRunStart> {
|
|
329
346
|
const resolved = resolveStartPlayRunRequest(request, this.environment);
|
|
330
|
-
const headers =
|
|
347
|
+
const headers = playRunStartHeaders(resolved.runtime, this.environment);
|
|
331
348
|
return startPlayRun(
|
|
332
349
|
this.http,
|
|
333
350
|
resolved.request,
|
|
@@ -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.538',
|
|
209
209
|
updateSummary: {
|
|
210
210
|
introducedIn: '0.3.90',
|
|
211
211
|
summary:
|
|
@@ -15,6 +15,21 @@ export const RUN_WATCH_POLL_INTERVAL_MS = 2_000;
|
|
|
15
15
|
// two-second steady-state cadence below.
|
|
16
16
|
const RUN_WATCH_STARTUP_POLL_INTERVAL_MS = 300;
|
|
17
17
|
const RUN_WATCH_STARTUP_WINDOW_MS = 6_000;
|
|
18
|
+
/**
|
|
19
|
+
* Server-held wait per snapshot request once the startup window has passed:
|
|
20
|
+
* the run route answers as soon as the run is terminal, or after this bound,
|
|
21
|
+
* so terminal detection no longer waits out the 2 s cadence. 0 (off) keeps
|
|
22
|
+
* client-side polling only. Used only by watchers that defer logs, whose
|
|
23
|
+
* progress output does not depend on intermediate snapshots. Lands off.
|
|
24
|
+
*/
|
|
25
|
+
export const RUN_WATCH_SERVER_WAIT_MS = 0;
|
|
26
|
+
/**
|
|
27
|
+
* Use the server-held wait from the first snapshot request instead of only
|
|
28
|
+
* after the startup window, so a short run is seen as soon as it is terminal
|
|
29
|
+
* rather than on the next 300 ms poll. Same watchers (deferred logs) and the
|
|
30
|
+
* same bounded server wait. Off.
|
|
31
|
+
*/
|
|
32
|
+
export const RUN_WATCH_SERVER_WAIT_FROM_START = false;
|
|
18
33
|
export const TERMINAL_LOG_PROJECTION_RETRY_LIMIT = 3;
|
|
19
34
|
|
|
20
35
|
type WatchHttp = {
|
|
@@ -217,11 +232,23 @@ export async function* watchRunEvents(
|
|
|
217
232
|
const poll = ++pollCount;
|
|
218
233
|
// Keep terminal detection responsive through the sandbox startup window,
|
|
219
234
|
// then reduce snapshot reads for runs that continue beyond it.
|
|
235
|
+
const pastStartup =
|
|
236
|
+
pollStartedAt - watchStartedAt >= RUN_WATCH_STARTUP_WINDOW_MS;
|
|
237
|
+
const serverWaitMs =
|
|
238
|
+
options.pollIntervalMs === undefined &&
|
|
239
|
+
options.deferLogs &&
|
|
240
|
+
(pastStartup || RUN_WATCH_SERVER_WAIT_FROM_START) &&
|
|
241
|
+
RUN_WATCH_SERVER_WAIT_MS > 0
|
|
242
|
+
? RUN_WATCH_SERVER_WAIT_MS
|
|
243
|
+
: 0;
|
|
244
|
+
// A held request already waited server-side; poll again immediately.
|
|
220
245
|
const pollIntervalMs =
|
|
221
246
|
options.pollIntervalMs ??
|
|
222
|
-
(
|
|
223
|
-
?
|
|
224
|
-
:
|
|
247
|
+
(serverWaitMs > 0
|
|
248
|
+
? 0
|
|
249
|
+
: pastStartup
|
|
250
|
+
? RUN_WATCH_POLL_INTERVAL_MS
|
|
251
|
+
: RUN_WATCH_STARTUP_POLL_INTERVAL_MS);
|
|
225
252
|
let snapshot: PlayRunLiveSnapshot;
|
|
226
253
|
let terminalStatus: Record<string, unknown> | undefined;
|
|
227
254
|
let responseStatus: number | undefined;
|
|
@@ -242,7 +269,9 @@ export async function* watchRunEvents(
|
|
|
242
269
|
}
|
|
243
270
|
};
|
|
244
271
|
try {
|
|
245
|
-
const response = await http.get<unknown>(
|
|
272
|
+
const response = await http.get<unknown>(
|
|
273
|
+
serverWaitMs > 0 ? `${path}&waitForTerminalMs=${serverWaitMs}` : path,
|
|
274
|
+
{
|
|
246
275
|
signal,
|
|
247
276
|
...(options.onPoll
|
|
248
277
|
? {
|
|
@@ -72,7 +72,7 @@ export type BillingEntitlements = {
|
|
|
72
72
|
|
|
73
73
|
/** `GET`/`POST /api/v2/billing/included-compute`. */
|
|
74
74
|
export type IncludedCompute = {
|
|
75
|
-
/** `unavailable`:
|
|
75
|
+
/** `unavailable`: returned only by older deployments (retired November rollout). */
|
|
76
76
|
status: 'on' | 'off' | 'unavailable';
|
|
77
77
|
/** Credits per standard-equivalent sandbox minute; null at provider cost. */
|
|
78
78
|
credits_per_minute: number | null;
|
|
@@ -1828,6 +1828,24 @@
|
|
|
1828
1828
|
"failureAlert": "convex_action_wrapper",
|
|
1829
1829
|
"domainReportRequired": true
|
|
1830
1830
|
},
|
|
1831
|
+
{
|
|
1832
|
+
"id": "convex.people-search-claim-expiry",
|
|
1833
|
+
"name": "People search claim expiry",
|
|
1834
|
+
"scheduler": "convex_scheduled_mutation",
|
|
1835
|
+
"cadence": "runAfter 20 minutes from a free profile reservation",
|
|
1836
|
+
"timezone": "UTC",
|
|
1837
|
+
"source": "packages/convex/peopleSearchAllowance.ts",
|
|
1838
|
+
"locator": "expireClaim",
|
|
1839
|
+
"owner": "billing",
|
|
1840
|
+
"criticality": "standard",
|
|
1841
|
+
"purpose": "Release the original quota hold for an abandoned people-search claim.",
|
|
1842
|
+
"successDefinition": "The claim settles to zero atomically with the refund, or an already-settled claim is skipped.",
|
|
1843
|
+
"failureDefinition": "Convex reports a failed expiry mutation with no quota change.",
|
|
1844
|
+
"startGraceMs": 120000,
|
|
1845
|
+
"runTimeoutMs": 60000,
|
|
1846
|
+
"failureAlert": "convex_native_mutation",
|
|
1847
|
+
"domainReportRequired": true
|
|
1848
|
+
},
|
|
1831
1849
|
{
|
|
1832
1850
|
"id": "convex.sql-listener-dispatch-retry",
|
|
1833
1851
|
"name": "SQL-listener dispatch retry",
|
|
@@ -1917,5 +1935,23 @@
|
|
|
1917
1935
|
"runTimeoutMs": 800000,
|
|
1918
1936
|
"failureAlert": "vercel_route_wrapper",
|
|
1919
1937
|
"domainReportRequired": true
|
|
1938
|
+
},
|
|
1939
|
+
{
|
|
1940
|
+
"id": "convex.play-result-reuse-fold",
|
|
1941
|
+
"name": "Play result reuse summary fold",
|
|
1942
|
+
"scheduler": "convex_scheduled_mutation",
|
|
1943
|
+
"cadence": "runAfter(0) after confirmed terminal run summaries; lease-owned continuation",
|
|
1944
|
+
"timezone": "UTC",
|
|
1945
|
+
"source": "packages/convex/playRunReuse.ts",
|
|
1946
|
+
"locator": "drainDeltas",
|
|
1947
|
+
"owner": "platform",
|
|
1948
|
+
"criticality": "reporting",
|
|
1949
|
+
"purpose": "Fold confirmed terminal Play reuse contributions into a workspace total through the existing counter journal.",
|
|
1950
|
+
"successDefinition": "A bounded journal page applies and deletes atomically, or the owner observes no pending contributions.",
|
|
1951
|
+
"failureDefinition": "The native scheduled mutation fails; its unapplied journal contributions remain available to the owning drain.",
|
|
1952
|
+
"startGraceMs": 120000,
|
|
1953
|
+
"runTimeoutMs": 120000,
|
|
1954
|
+
"failureAlert": "convex_native_scheduled_function",
|
|
1955
|
+
"domainReportRequired": true
|
|
1920
1956
|
}
|
|
1921
1957
|
]
|
|
@@ -0,0 +1,330 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prebaked runner image contract (Modal published image).
|
|
3
|
+
*
|
|
4
|
+
* The play-runner bundle is static across runs of one deploy, yet every run
|
|
5
|
+
* used to gzip and upload it inside the payload envelope. A sandbox image that
|
|
6
|
+
* already carries the bundle at a path keyed by the bundle's own SHA-256 lets
|
|
7
|
+
* the launcher upload only the per-run config and Play artifact.
|
|
8
|
+
*
|
|
9
|
+
* Trust model: nothing here is assumed. The launcher only plans a baked run
|
|
10
|
+
* when an operator configured the expected hash AND that hash equals the hash
|
|
11
|
+
* of the bundle this very launcher would otherwise upload. It then verifies,
|
|
12
|
+
* inside the acquired sandbox and before any command that could start the
|
|
13
|
+
* runner, that the file exists and hashes to that value. Any other outcome
|
|
14
|
+
* (unset, stale, absent file, mismatched bytes, probe failure) keeps the
|
|
15
|
+
* existing full-upload path. No wire or schema version changes: the envelope
|
|
16
|
+
* field set is unchanged and `runnerCode: ''` simply means "already on disk".
|
|
17
|
+
*/
|
|
18
|
+
import { createHash } from 'node:crypto';
|
|
19
|
+
import { gzipSync } from 'node:zlib';
|
|
20
|
+
|
|
21
|
+
/** Operator opt-in. Unset (the default) keeps today's full upload. */
|
|
22
|
+
export const BAKED_RUNNER_HASH_ENV = 'DEEPLINE_BAKED_RUNNER_HASH';
|
|
23
|
+
export const BAKED_RUNNER_ROOT = '/opt/deepline/runner';
|
|
24
|
+
export const BAKED_RUNNER_FILE_NAME = 'play-runner.cjs';
|
|
25
|
+
|
|
26
|
+
const SHA256_HEX = /^[0-9a-f]{64}$/;
|
|
27
|
+
|
|
28
|
+
export function runnerBundleSha256(bundle: string): string {
|
|
29
|
+
return createHash('sha256').update(bundle, 'utf-8').digest('hex');
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
let lastHashed: { bundle: string; hash: string } | null = null;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* The bundle is cached per worker process, so the same string is hashed run
|
|
36
|
+
* after run. Single-entry memo by content: a changed bundle recomputes.
|
|
37
|
+
*/
|
|
38
|
+
export function runnerBundleSha256Memoized(bundle: string): string {
|
|
39
|
+
if (lastHashed && lastHashed.bundle === bundle) return lastHashed.hash;
|
|
40
|
+
const hash = runnerBundleSha256(bundle);
|
|
41
|
+
lastHashed = { bundle, hash };
|
|
42
|
+
return hash;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function bakedRunnerPath(hash: string): string {
|
|
46
|
+
if (!SHA256_HEX.test(hash)) {
|
|
47
|
+
throw new Error('Baked runner hash must be 64 lowercase hex characters.');
|
|
48
|
+
}
|
|
49
|
+
return `${BAKED_RUNNER_ROOT}/${hash}/${BAKED_RUNNER_FILE_NAME}`;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export type BakedRunnerPlan =
|
|
53
|
+
| { status: 'disabled' }
|
|
54
|
+
| { status: 'invalid_config' }
|
|
55
|
+
| { status: 'stale_config'; configuredHash: string; bundleHash: string }
|
|
56
|
+
| { status: 'expected'; hash: string; path: string };
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Decide whether this launch should try the baked path. `expected` is only a
|
|
60
|
+
* hypothesis that still has to be verified in the sandbox.
|
|
61
|
+
*/
|
|
62
|
+
export function planBakedRunner(input: {
|
|
63
|
+
configuredHash: string | null | undefined;
|
|
64
|
+
bundle: string;
|
|
65
|
+
}): BakedRunnerPlan {
|
|
66
|
+
const configured = input.configuredHash?.trim().toLowerCase() ?? '';
|
|
67
|
+
if (!configured) return { status: 'disabled' };
|
|
68
|
+
if (!SHA256_HEX.test(configured)) return { status: 'invalid_config' };
|
|
69
|
+
const bundleHash = runnerBundleSha256Memoized(input.bundle);
|
|
70
|
+
if (bundleHash !== configured) {
|
|
71
|
+
return { status: 'stale_config', configuredHash: configured, bundleHash };
|
|
72
|
+
}
|
|
73
|
+
return {
|
|
74
|
+
status: 'expected',
|
|
75
|
+
hash: configured,
|
|
76
|
+
path: bakedRunnerPath(configured),
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/** The configured hash when it is well formed; malformed config enables nothing. */
|
|
81
|
+
export function configuredBakedRunnerHash(
|
|
82
|
+
env: NodeJS.ProcessEnv = process.env,
|
|
83
|
+
): string | null {
|
|
84
|
+
const configured = env[BAKED_RUNNER_HASH_ENV]?.trim().toLowerCase() ?? '';
|
|
85
|
+
return SHA256_HEX.test(configured) ? configured : null;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const MODAL_IMAGE_PRESENT_TTL_MS = 10 * 60_000;
|
|
89
|
+
const MODAL_IMAGE_ABSENT_TTL_MS = 30_000;
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Modal published-image name for a runner hash. Modal object names must be
|
|
93
|
+
* shorter than 64 characters, so the tag is a 32-hex (128-bit) prefix; the
|
|
94
|
+
* full hash is still what the sandbox verifies before the file is used.
|
|
95
|
+
*/
|
|
96
|
+
export const BAKED_MODAL_IMAGE_NAME = 'deepline-play-runner';
|
|
97
|
+
|
|
98
|
+
export function bakedModalImageRef(hash: string): string {
|
|
99
|
+
if (!SHA256_HEX.test(hash)) {
|
|
100
|
+
throw new Error('Baked runner hash must be 64 lowercase hex characters.');
|
|
101
|
+
}
|
|
102
|
+
return `${BAKED_MODAL_IMAGE_NAME}:${hash.slice(0, 32)}`;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/** Below Linux's 128 KiB single-argument limit for each `/bin/sh -c` RUN. */
|
|
106
|
+
const MODAL_RUN_CHUNK_CHARS = 96 * 1024;
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Dockerfile commands that bake the runner into a Modal-built image. Modal's
|
|
110
|
+
* JS SDK cannot COPY from a local build context, so the gzipped bundle is
|
|
111
|
+
* carried as base64 in bounded RUN chunks and reassembled at
|
|
112
|
+
* /opt/deepline/runner/<sha256>/play-runner.cjs (file 0444, directory 0555),
|
|
113
|
+
* and the build fails unless the reassembled bytes hash to the bundle's SHA-256.
|
|
114
|
+
* The commands are a pure function of the bundle, so a rebuild is a cache hit.
|
|
115
|
+
*/
|
|
116
|
+
export function bakedRunnerModalDockerfileCommands(bundle: string): string[] {
|
|
117
|
+
if (bundle.length === 0) throw new Error('Runner bundle is empty.');
|
|
118
|
+
const hash = runnerBundleSha256(bundle);
|
|
119
|
+
const encoded = gzipSync(Buffer.from(bundle, 'utf-8'), { level: 9 }).toString(
|
|
120
|
+
'base64',
|
|
121
|
+
);
|
|
122
|
+
const staged = '/tmp/deepline-play-runner.gz.b64';
|
|
123
|
+
const commands = [`RUN rm -f ${staged}`];
|
|
124
|
+
for (
|
|
125
|
+
let offset = 0;
|
|
126
|
+
offset < encoded.length;
|
|
127
|
+
offset += MODAL_RUN_CHUNK_CHARS
|
|
128
|
+
) {
|
|
129
|
+
commands.push(
|
|
130
|
+
`RUN printf '%s' '${encoded.slice(offset, offset + MODAL_RUN_CHUNK_CHARS)}' >> ${staged}`,
|
|
131
|
+
);
|
|
132
|
+
}
|
|
133
|
+
const dir = `${BAKED_RUNNER_ROOT}/${hash}`;
|
|
134
|
+
commands.push(
|
|
135
|
+
[
|
|
136
|
+
'RUN set -eu',
|
|
137
|
+
`base64 -d < ${staged} | gzip -dc > /tmp/play-runner.cjs`,
|
|
138
|
+
`echo "${hash} /tmp/play-runner.cjs" | sha256sum -c -`,
|
|
139
|
+
`install -d -m 0755 "${dir}"`,
|
|
140
|
+
`install -m 0444 /tmp/play-runner.cjs "${dir}/${BAKED_RUNNER_FILE_NAME}"`,
|
|
141
|
+
`chmod 0555 "${dir}"`,
|
|
142
|
+
`rm -f /tmp/play-runner.cjs ${staged}`,
|
|
143
|
+
].join('; '),
|
|
144
|
+
);
|
|
145
|
+
return commands;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* The published image id, or null only when Modal says the name does not
|
|
150
|
+
* exist. Any other lookup failure (auth, network, throttling) is rethrown:
|
|
151
|
+
* a publisher must not read it as "absent" and rebuild over a live image.
|
|
152
|
+
*/
|
|
153
|
+
export async function existingPublishedModalImageId(
|
|
154
|
+
lookup: () => Promise<{ imageId: string }>,
|
|
155
|
+
): Promise<string | null> {
|
|
156
|
+
try {
|
|
157
|
+
return (await lookup()).imageId;
|
|
158
|
+
} catch (error) {
|
|
159
|
+
if (error instanceof Error && error.name === 'NotFoundError') return null;
|
|
160
|
+
throw error;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
type ModalImageLookup<TImage> = { image: TImage | null; expiresAtMs: number };
|
|
165
|
+
const modalImageCaches = new WeakMap<
|
|
166
|
+
object,
|
|
167
|
+
Map<string, Promise<ModalImageLookup<unknown>>>
|
|
168
|
+
>();
|
|
169
|
+
const MODAL_IMAGE_LOOKUP_TIMEOUT_MS = 5_000;
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Pick the image a new Modal sandbox is created from. The published baked
|
|
173
|
+
* image is chosen only when an operator configured a hash AND Modal resolves
|
|
174
|
+
* that exact published name; absence, any lookup failure, or a slow lookup
|
|
175
|
+
* keeps the profile's existing image. An operator-chosen runner image
|
|
176
|
+
* (DEEPLINE_MODAL_RUNNER_IMAGE) keeps its precedence: the baked image never
|
|
177
|
+
* replaces it, and the result says so (`skipped`) instead of silently. The runner file inside it is still
|
|
178
|
+
* verified in the sandbox before use, so a wrong image is harmless.
|
|
179
|
+
*
|
|
180
|
+
* Cached per Modal client (an image handle is bound to its client) for the
|
|
181
|
+
* 10 minutes when present and 30 seconds when absent; concurrent callers share
|
|
182
|
+
* one lookup.
|
|
183
|
+
*/
|
|
184
|
+
export async function resolveModalRunnerImage<TImage>(input: {
|
|
185
|
+
client: object;
|
|
186
|
+
configuredHash: string | null;
|
|
187
|
+
/** DEEPLINE_MODAL_RUNNER_IMAGE chose the default image. */
|
|
188
|
+
explicitImage?: boolean;
|
|
189
|
+
defaultImage: () => TImage;
|
|
190
|
+
lookupPublished: (ref: string) => Promise<TImage>;
|
|
191
|
+
now?: () => number;
|
|
192
|
+
timeoutMs?: number;
|
|
193
|
+
}): Promise<{
|
|
194
|
+
image: TImage;
|
|
195
|
+
baked: boolean;
|
|
196
|
+
ref: string | null;
|
|
197
|
+
skipped?: 'explicit_runner_image';
|
|
198
|
+
}> {
|
|
199
|
+
if (!input.configuredHash) {
|
|
200
|
+
return { image: input.defaultImage(), baked: false, ref: null };
|
|
201
|
+
}
|
|
202
|
+
if (input.explicitImage) {
|
|
203
|
+
return {
|
|
204
|
+
image: input.defaultImage(),
|
|
205
|
+
baked: false,
|
|
206
|
+
ref: null,
|
|
207
|
+
skipped: 'explicit_runner_image',
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
const ref = bakedModalImageRef(input.configuredHash);
|
|
211
|
+
const now = input.now ?? Date.now;
|
|
212
|
+
let cache = modalImageCaches.get(input.client);
|
|
213
|
+
if (!cache) {
|
|
214
|
+
cache = new Map();
|
|
215
|
+
modalImageCaches.set(input.client, cache);
|
|
216
|
+
}
|
|
217
|
+
let entry: ModalImageLookup<TImage> | null = null;
|
|
218
|
+
const cached = cache.get(ref) as
|
|
219
|
+
| Promise<ModalImageLookup<TImage>>
|
|
220
|
+
| undefined;
|
|
221
|
+
if (cached) {
|
|
222
|
+
entry = await cached;
|
|
223
|
+
if (entry.expiresAtMs <= now()) entry = null;
|
|
224
|
+
}
|
|
225
|
+
if (!entry) {
|
|
226
|
+
let timer: ReturnType<typeof setTimeout> | undefined;
|
|
227
|
+
const absent = (): ModalImageLookup<TImage> => ({
|
|
228
|
+
image: null,
|
|
229
|
+
expiresAtMs: now() + MODAL_IMAGE_ABSENT_TTL_MS,
|
|
230
|
+
});
|
|
231
|
+
const lookup = Promise.race([
|
|
232
|
+
// A synchronous throw (for example a client without named images) is
|
|
233
|
+
// a failed lookup like any other, never a failed launch.
|
|
234
|
+
Promise.resolve()
|
|
235
|
+
.then(() => input.lookupPublished(ref))
|
|
236
|
+
.then(
|
|
237
|
+
(image): ModalImageLookup<TImage> => ({
|
|
238
|
+
image,
|
|
239
|
+
expiresAtMs: now() + MODAL_IMAGE_PRESENT_TTL_MS,
|
|
240
|
+
}),
|
|
241
|
+
absent,
|
|
242
|
+
),
|
|
243
|
+
new Promise<ModalImageLookup<TImage>>((resolve) => {
|
|
244
|
+
timer = setTimeout(
|
|
245
|
+
() => resolve(absent()),
|
|
246
|
+
input.timeoutMs ?? MODAL_IMAGE_LOOKUP_TIMEOUT_MS,
|
|
247
|
+
);
|
|
248
|
+
}),
|
|
249
|
+
]).finally(() => {
|
|
250
|
+
if (timer) clearTimeout(timer);
|
|
251
|
+
});
|
|
252
|
+
cache.set(ref, lookup);
|
|
253
|
+
entry = await lookup;
|
|
254
|
+
}
|
|
255
|
+
return entry.image === null
|
|
256
|
+
? { image: input.defaultImage(), baked: false, ref }
|
|
257
|
+
: { image: entry.image, baked: true, ref };
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
const VERIFICATION_PREFIX = 'baked-runner:';
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* Runs inside the sandbox with Node alone. Arguments: absolute path, expected
|
|
264
|
+
* hash. Prints exactly one verdict line and always exits 0, so a probe failure
|
|
265
|
+
* is distinguishable from a verdict (no verdict line means "not verified").
|
|
266
|
+
*/
|
|
267
|
+
export function buildBakedRunnerVerifySource(): string {
|
|
268
|
+
return `const fs=require('node:fs');const c=require('node:crypto');let r='missing';try{r=c.createHash('sha256').update(fs.readFileSync(process.argv[1])).digest('hex')===process.argv[2]?'ok':'mismatch'}catch(e){}console.log('${VERIFICATION_PREFIX}'+r);`;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
/**
|
|
272
|
+
* `late`: no verdict line within the launcher's bound while the stream was
|
|
273
|
+
* still open. The in-sandbox guard alone decides then (it runs the baked file
|
|
274
|
+
* only on `ok`), and the detached-runner readiness check proves the runner
|
|
275
|
+
* live or recovers the attempt. A fallback on `late` could stop a runner that
|
|
276
|
+
* is already running.
|
|
277
|
+
*/
|
|
278
|
+
export type BakedRunnerVerdict =
|
|
279
|
+
| 'ok'
|
|
280
|
+
| 'mismatch'
|
|
281
|
+
| 'missing'
|
|
282
|
+
| 'no_verdict'
|
|
283
|
+
| 'late';
|
|
284
|
+
|
|
285
|
+
/** Whether the launcher must start today's full upload for this verdict. */
|
|
286
|
+
export function bakedVerdictRequiresFallback(
|
|
287
|
+
verdict: BakedRunnerVerdict,
|
|
288
|
+
): boolean {
|
|
289
|
+
return verdict !== 'ok' && verdict !== 'late';
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
/** Anything but an exact `ok` verdict is "not verified". */
|
|
293
|
+
export function parseBakedRunnerVerdict(stdout: string): BakedRunnerVerdict {
|
|
294
|
+
const line = stdout
|
|
295
|
+
.split(/\r?\n/)
|
|
296
|
+
.map((value) => value.trim())
|
|
297
|
+
.find((value) => value.startsWith(VERIFICATION_PREFIX));
|
|
298
|
+
const verdict = line?.slice(VERIFICATION_PREFIX.length);
|
|
299
|
+
return verdict === 'ok' || verdict === 'mismatch' || verdict === 'missing'
|
|
300
|
+
? verdict
|
|
301
|
+
: 'no_verdict';
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
/**
|
|
305
|
+
* The launch-time decision. Resolves to a plan only when the operator enabled
|
|
306
|
+
* the baked path and this deploy's bundle hashes to the configured value; a
|
|
307
|
+
* stale or disabled configuration returns undefined and leaves the full upload
|
|
308
|
+
* untouched. `onStale` lets the caller log the skipped, otherwise silent, case.
|
|
309
|
+
*/
|
|
310
|
+
export async function bakedRunnerPlanForLaunch(input: {
|
|
311
|
+
bundlePromise: Promise<string>;
|
|
312
|
+
configuredHash?: string | null;
|
|
313
|
+
onStale?: (
|
|
314
|
+
plan: Extract<BakedRunnerPlan, { status: 'stale_config' }>,
|
|
315
|
+
) => void;
|
|
316
|
+
}): Promise<{ hash: string; path: string } | undefined> {
|
|
317
|
+
const configuredHash =
|
|
318
|
+
input.configuredHash === undefined
|
|
319
|
+
? configuredBakedRunnerHash()
|
|
320
|
+
: input.configuredHash;
|
|
321
|
+
if (!configuredHash) return undefined;
|
|
322
|
+
const plan = planBakedRunner({
|
|
323
|
+
configuredHash,
|
|
324
|
+
bundle: await input.bundlePromise,
|
|
325
|
+
});
|
|
326
|
+
if (plan.status === 'stale_config') input.onStale?.(plan);
|
|
327
|
+
return plan.status === 'expected'
|
|
328
|
+
? { hash: plan.hash, path: plan.path }
|
|
329
|
+
: undefined;
|
|
330
|
+
}
|