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
|
@@ -108,6 +108,16 @@ export type RuntimeDispatchFlowInput = {
|
|
|
108
108
|
providerDispatchAtGateway?: boolean;
|
|
109
109
|
/** Emits the request-side transport wait observed by the caller's metrics. */
|
|
110
110
|
onTransportAdmitted?: (waitMs: number) => void;
|
|
111
|
+
/**
|
|
112
|
+
* Capacity the caller already took without waiting (read-through). It is
|
|
113
|
+
* used for the first admission instead of acquiring; a later re-admission
|
|
114
|
+
* (stale permit) acquires as usual. The flow owns it from here.
|
|
115
|
+
*/
|
|
116
|
+
preAdmitted?: {
|
|
117
|
+
providerPermit: RuntimeDispatchProviderPermit;
|
|
118
|
+
executionSlot: RuntimeFlowLease;
|
|
119
|
+
integrationRequestLease: RuntimeFlowLease | null;
|
|
120
|
+
} | null;
|
|
111
121
|
};
|
|
112
122
|
|
|
113
123
|
type RuntimeDispatchPermit<
|
|
@@ -143,15 +153,20 @@ export type RuntimeDispatchScope = {
|
|
|
143
153
|
/**
|
|
144
154
|
* Persist response feedback while the lease is live. Return
|
|
145
155
|
* `not_dispatched` only for a definite rejection before provider work;
|
|
146
|
-
* this refunds the reservation.
|
|
156
|
+
* this refunds the reservation. `returned_unused` is a definite answer
|
|
157
|
+
* that did no provider work at all (a read-through hit or decline): the
|
|
158
|
+
* permit goes back to its local block (`park`) exactly as if it had never
|
|
159
|
+
* been drawn. Ambiguous outcomes retain release semantics.
|
|
147
160
|
*/
|
|
148
161
|
beforeRelease?: () =>
|
|
149
162
|
| void
|
|
150
|
-
|
|
|
151
|
-
| Promise<void |
|
|
163
|
+
| RuntimeDispatchUndispatched
|
|
164
|
+
| Promise<void | RuntimeDispatchUndispatched>,
|
|
152
165
|
): Promise<Output>;
|
|
153
166
|
};
|
|
154
167
|
|
|
168
|
+
export type RuntimeDispatchUndispatched = 'not_dispatched' | 'returned_unused';
|
|
169
|
+
|
|
155
170
|
export type RuntimeDispatchFlow<
|
|
156
171
|
ProviderPermit extends RuntimeDispatchProviderPermit,
|
|
157
172
|
> = {
|
|
@@ -300,8 +315,17 @@ export function createRuntimeDispatchFlow<
|
|
|
300
315
|
admission: RuntimeDispatchFlowInput,
|
|
301
316
|
work: (scope: RuntimeDispatchScope) => Output | Promise<Output>,
|
|
302
317
|
): Promise<Output> {
|
|
303
|
-
let permit =
|
|
318
|
+
let permit: RuntimeDispatchPermit<ProviderPermit> = admission.preAdmitted
|
|
319
|
+
? {
|
|
320
|
+
providerPermit: admission.preAdmitted
|
|
321
|
+
.providerPermit as ProviderPermit,
|
|
322
|
+
executionSlot: admission.preAdmitted.executionSlot,
|
|
323
|
+
integrationRequestLease:
|
|
324
|
+
admission.preAdmitted.integrationRequestLease,
|
|
325
|
+
}
|
|
326
|
+
: await admit(admission);
|
|
304
327
|
let transportLease = permit.integrationRequestLease;
|
|
328
|
+
let parkUnstartedPermit = false;
|
|
305
329
|
let requiresTransportPermitForReacquire =
|
|
306
330
|
admission.requiresTransportPermit;
|
|
307
331
|
let requestStarted = false;
|
|
@@ -317,6 +341,7 @@ export function createRuntimeDispatchFlow<
|
|
|
317
341
|
executionSlot: permit.executionSlot,
|
|
318
342
|
providerPermit: permit.providerPermit,
|
|
319
343
|
requestStarted,
|
|
344
|
+
parkUnstarted: parkUnstartedPermit,
|
|
320
345
|
});
|
|
321
346
|
};
|
|
322
347
|
try {
|
|
@@ -329,8 +354,8 @@ export function createRuntimeDispatchFlow<
|
|
|
329
354
|
) => RequestOutput | Promise<RequestOutput>,
|
|
330
355
|
beforeRelease?: () =>
|
|
331
356
|
| void
|
|
332
|
-
|
|
|
333
|
-
| Promise<void |
|
|
357
|
+
| RuntimeDispatchUndispatched
|
|
358
|
+
| Promise<void | RuntimeDispatchUndispatched>,
|
|
334
359
|
): Promise<RequestOutput> => {
|
|
335
360
|
if (!scopeOpen) {
|
|
336
361
|
return Promise.reject(
|
|
@@ -440,13 +465,17 @@ export function createRuntimeDispatchFlow<
|
|
|
440
465
|
// always release all leases even when feedback persistence
|
|
441
466
|
// fails.
|
|
442
467
|
try {
|
|
468
|
+
const undispatched = requestStarted
|
|
469
|
+
? await beforeRelease?.()
|
|
470
|
+
: undefined;
|
|
443
471
|
if (
|
|
444
|
-
|
|
445
|
-
|
|
472
|
+
undispatched === 'not_dispatched' ||
|
|
473
|
+
undispatched === 'returned_unused'
|
|
446
474
|
) {
|
|
447
475
|
// A definite receiver rejection returns the reservation.
|
|
448
476
|
// Ambiguous exchanges retain ordinary release semantics.
|
|
449
477
|
requestStarted = false;
|
|
478
|
+
parkUnstartedPermit = undispatched === 'returned_unused';
|
|
450
479
|
}
|
|
451
480
|
} finally {
|
|
452
481
|
await releasePermit();
|
|
@@ -536,6 +565,8 @@ async function releaseRuntimeDispatchPermit<
|
|
|
536
565
|
executionSlot: RuntimeFlowLease;
|
|
537
566
|
providerPermit: ProviderPermit;
|
|
538
567
|
requestStarted: boolean;
|
|
568
|
+
/** An unstarted permit returns to its local block instead of a refund. */
|
|
569
|
+
parkUnstarted?: boolean;
|
|
539
570
|
}): Promise<void> {
|
|
540
571
|
let failure: unknown = null;
|
|
541
572
|
let hasFailure = false;
|
|
@@ -564,6 +595,9 @@ async function releaseRuntimeDispatchPermit<
|
|
|
564
595
|
release(() => input.executionSlot.release());
|
|
565
596
|
if (input.requestStarted) {
|
|
566
597
|
release(() => input.providerPermit.release());
|
|
598
|
+
} else if (input.parkUnstarted && input.providerPermit.park) {
|
|
599
|
+
const park = input.providerPermit.park.bind(input.providerPermit);
|
|
600
|
+
await releaseAsync(async () => await park());
|
|
567
601
|
} else {
|
|
568
602
|
await releaseAsync(async () => await input.providerPermit.cancel());
|
|
569
603
|
}
|
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
import type { RuntimeStepReceipt } from './ctx-types';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Local-permit read-through: one sandbox request for a warm direct tool call.
|
|
5
|
+
*
|
|
6
|
+
* Today a direct edition-11 `staleAfterSeconds: 0` call reads its operation
|
|
7
|
+
* and result receipts (one request), then takes a provider permit, then
|
|
8
|
+
* executes (a second request, which also finishes the receipts when the relay
|
|
9
|
+
* supports finish-in-execute). When every piece of dispatch capacity is
|
|
10
|
+
* already on hand locally (a due permit in the rate block, an execution slot,
|
|
11
|
+
* a transport slot and reserved tool-call budget) the runner takes them
|
|
12
|
+
* without waiting and sends the receipt keys with the execute request on a
|
|
13
|
+
* named action instead. The execution relay reads those keys first:
|
|
14
|
+
*
|
|
15
|
+
* - any record exists: it returns the records and executes nothing; the
|
|
16
|
+
* runner returns every piece of capacity it took through the existing
|
|
17
|
+
* undispatched paths and classifies the records exactly as its own read
|
|
18
|
+
* would have;
|
|
19
|
+
* - nothing exists: it executes with the supplied permit and finishes the
|
|
20
|
+
* receipts in the same request (finish-in-execute);
|
|
21
|
+
* - its bounded read lane is busy: it declines without executing and the
|
|
22
|
+
* runner reads for itself.
|
|
23
|
+
*
|
|
24
|
+
* Older relays reject the named action before any work (403 route not
|
|
25
|
+
* allowed), so a call whose read was skipped can never execute on a relay
|
|
26
|
+
* that did not read. The runner then remembers that relay and reads for
|
|
27
|
+
* itself.
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
/** Appended to `/execute`: `/api/v2/integrations/{tool}/execute-read-through`. */
|
|
31
|
+
export const TOOL_EXECUTE_READ_THROUGH_PATH_SUFFIX = '-read-through';
|
|
32
|
+
/** Request header: the JSON array of receipt keys the relay must read first. */
|
|
33
|
+
export const RUNTIME_READ_THROUGH_KEYS_HEADER =
|
|
34
|
+
'x-deepline-runtime-read-through-keys';
|
|
35
|
+
/**
|
|
36
|
+
* Response header minted only by a supporting relay on the named action:
|
|
37
|
+
* `hit`, `miss` (the relay read nothing and executed) or `declined`.
|
|
38
|
+
*/
|
|
39
|
+
export const RUNTIME_READ_THROUGH_RECEIVER_HEADER =
|
|
40
|
+
'x-deepline-read-through-receiver';
|
|
41
|
+
/** The operation receipt and the call's own result receipt. */
|
|
42
|
+
export const RUNTIME_READ_THROUGH_MAX_KEYS = 4;
|
|
43
|
+
export const RUNTIME_READ_THROUGH_MAX_KEY_LENGTH = 512;
|
|
44
|
+
/**
|
|
45
|
+
* A hit is not a provider answer. It uses a status no provider success can
|
|
46
|
+
* have, so a response that lost its receiver header fails loudly instead of
|
|
47
|
+
* being parsed as a tool result.
|
|
48
|
+
*/
|
|
49
|
+
export const RUNTIME_READ_THROUGH_HIT_STATUS = 409;
|
|
50
|
+
export const RUNTIME_READ_THROUGH_DECLINED_STATUS = 503;
|
|
51
|
+
|
|
52
|
+
export type RuntimeReadThroughOutcome = 'hit' | 'miss' | 'declined';
|
|
53
|
+
|
|
54
|
+
export function readThroughExecuteCanonicalPath(
|
|
55
|
+
pathname: string,
|
|
56
|
+
): string | null {
|
|
57
|
+
return /^\/api\/v2\/integrations\/[^/]+\/execute-read-through$/.test(pathname)
|
|
58
|
+
? pathname.slice(0, -TOOL_EXECUTE_READ_THROUGH_PATH_SUFFIX.length)
|
|
59
|
+
: null;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export function encodeRuntimeReadThroughKeys(
|
|
63
|
+
keys: readonly string[],
|
|
64
|
+
): string | null {
|
|
65
|
+
const decoded = decodeRuntimeReadThroughKeys(JSON.stringify(keys));
|
|
66
|
+
return decoded ? JSON.stringify(decoded) : null;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** Null for anything but 1..4 distinct, bounded, non-empty keys. */
|
|
70
|
+
export function decodeRuntimeReadThroughKeys(
|
|
71
|
+
value: string | null | undefined,
|
|
72
|
+
): string[] | null {
|
|
73
|
+
if (!value) return null;
|
|
74
|
+
let parsed: unknown;
|
|
75
|
+
try {
|
|
76
|
+
parsed = JSON.parse(value);
|
|
77
|
+
} catch {
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
if (
|
|
81
|
+
!Array.isArray(parsed) ||
|
|
82
|
+
parsed.length === 0 ||
|
|
83
|
+
parsed.length > RUNTIME_READ_THROUGH_MAX_KEYS
|
|
84
|
+
) {
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
const keys: string[] = [];
|
|
88
|
+
for (const key of parsed) {
|
|
89
|
+
if (
|
|
90
|
+
typeof key !== 'string' ||
|
|
91
|
+
!key.trim() ||
|
|
92
|
+
key !== key.trim() ||
|
|
93
|
+
key.length > RUNTIME_READ_THROUGH_MAX_KEY_LENGTH ||
|
|
94
|
+
keys.includes(key)
|
|
95
|
+
) {
|
|
96
|
+
return null;
|
|
97
|
+
}
|
|
98
|
+
keys.push(key);
|
|
99
|
+
}
|
|
100
|
+
return keys;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export function runtimeReadThroughOutcome(
|
|
104
|
+
response: Pick<Response, 'headers'>,
|
|
105
|
+
): RuntimeReadThroughOutcome | null {
|
|
106
|
+
const value = response.headers.get(RUNTIME_READ_THROUGH_RECEIVER_HEADER);
|
|
107
|
+
return value === 'hit' || value === 'miss' || value === 'declined'
|
|
108
|
+
? value
|
|
109
|
+
: null;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/** An older relay refuses the named action before admission or any work. */
|
|
113
|
+
export function isReadThroughExecuteReceiverUnavailable(
|
|
114
|
+
response: Pick<Response, 'headers' | 'status'>,
|
|
115
|
+
bodyText: string,
|
|
116
|
+
): boolean {
|
|
117
|
+
if (response.headers.has(RUNTIME_READ_THROUGH_RECEIVER_HEADER)) return false;
|
|
118
|
+
if (response.status === 404) return true;
|
|
119
|
+
if (response.status !== 403) return false;
|
|
120
|
+
try {
|
|
121
|
+
return (
|
|
122
|
+
JSON.parse(bodyText)?.error === 'Execution gateway route is not allowed.'
|
|
123
|
+
);
|
|
124
|
+
} catch {
|
|
125
|
+
return false;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/** The records a hit returns, in request-key order. */
|
|
130
|
+
export function parseRuntimeReadThroughHit(
|
|
131
|
+
bodyText: string,
|
|
132
|
+
keyCount: number,
|
|
133
|
+
): Array<RuntimeStepReceipt | null> | null {
|
|
134
|
+
let parsed: unknown;
|
|
135
|
+
try {
|
|
136
|
+
parsed = JSON.parse(bodyText);
|
|
137
|
+
} catch {
|
|
138
|
+
return null;
|
|
139
|
+
}
|
|
140
|
+
const receipts =
|
|
141
|
+
parsed && typeof parsed === 'object' && !Array.isArray(parsed)
|
|
142
|
+
? (parsed as { receipts?: unknown }).receipts
|
|
143
|
+
: null;
|
|
144
|
+
if (!Array.isArray(receipts) || receipts.length !== keyCount) return null;
|
|
145
|
+
if (
|
|
146
|
+
receipts.some(
|
|
147
|
+
(receipt) =>
|
|
148
|
+
receipt !== null &&
|
|
149
|
+
(typeof receipt !== 'object' || Array.isArray(receipt)),
|
|
150
|
+
)
|
|
151
|
+
) {
|
|
152
|
+
return null;
|
|
153
|
+
}
|
|
154
|
+
return receipts as Array<RuntimeStepReceipt | null>;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Why a speculative call did not execute. The freshness layer catches it,
|
|
159
|
+
* after every piece of capacity went back, and continues exactly as its own
|
|
160
|
+
* read would have: with `receipts` when the relay read them, else by reading.
|
|
161
|
+
*/
|
|
162
|
+
export class RuntimeReadThroughFallback extends Error {
|
|
163
|
+
constructor(
|
|
164
|
+
readonly reason:
|
|
165
|
+
| 'hit'
|
|
166
|
+
| 'declined'
|
|
167
|
+
| 'receiver_unavailable'
|
|
168
|
+
| 'not_finishable',
|
|
169
|
+
readonly receipts: ReadonlyArray<RuntimeStepReceipt | null> | null = null,
|
|
170
|
+
/**
|
|
171
|
+
* An earlier attempt of this call was sent without a definite answer and
|
|
172
|
+
* may have executed. Its capacity and budget stay spent; only this
|
|
173
|
+
* attempt's own permit and slots went back.
|
|
174
|
+
*/
|
|
175
|
+
readonly earlierAttemptMayHaveRun = false,
|
|
176
|
+
) {
|
|
177
|
+
super(`Read-through did not execute (${reason}).`);
|
|
178
|
+
this.name = 'RuntimeReadThroughFallback';
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
export function isRuntimeReadThroughFallback(
|
|
183
|
+
error: unknown,
|
|
184
|
+
): error is RuntimeReadThroughFallback {
|
|
185
|
+
return error instanceof RuntimeReadThroughFallback;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Relays that refused the named action, by execution base URL. One refusal
|
|
190
|
+
* is enough: the process keeps today's read for that relay until it ends.
|
|
191
|
+
*/
|
|
192
|
+
const readThroughUnavailableRelays = new Set<string>();
|
|
193
|
+
|
|
194
|
+
export function rememberReadThroughUnavailable(baseUrl: string): void {
|
|
195
|
+
readThroughUnavailableRelays.add(baseUrl.replace(/\/$/, ''));
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
export function isReadThroughUnavailable(baseUrl: string): boolean {
|
|
199
|
+
return readThroughUnavailableRelays.has(baseUrl.replace(/\/$/, ''));
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
export type RuntimeReadThroughLease = { release(): void };
|
|
203
|
+
|
|
204
|
+
/** A provider permit as the dispatch flow consumes it. */
|
|
205
|
+
export type RuntimeReadThroughPermit = RuntimeReadThroughLease & {
|
|
206
|
+
cancel(): Promise<void>;
|
|
207
|
+
park?(): Promise<void>;
|
|
208
|
+
};
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* Capacity taken without waiting for one speculative dispatch. The dispatch
|
|
212
|
+
* flow takes the permit and slots once; the budget stays with the grant.
|
|
213
|
+
*/
|
|
214
|
+
export type RuntimeReadThroughGrant<
|
|
215
|
+
Permit extends RuntimeReadThroughPermit = RuntimeReadThroughPermit,
|
|
216
|
+
> = {
|
|
217
|
+
/** Operation receipt first, then the call's planned result receipt. */
|
|
218
|
+
readonly keys: readonly string[];
|
|
219
|
+
/** The pre-admitted dispatch capacity, handed out at most once. */
|
|
220
|
+
takeDispatchCapacity(): {
|
|
221
|
+
providerPermit: Permit;
|
|
222
|
+
executionSlot: RuntimeReadThroughLease;
|
|
223
|
+
integrationRequestLease: RuntimeReadThroughLease | null;
|
|
224
|
+
} | null;
|
|
225
|
+
/**
|
|
226
|
+
* The dispatch reached the point where the ordinary path charges the
|
|
227
|
+
* tool-call budget, so the grant's charge now stands for it.
|
|
228
|
+
*/
|
|
229
|
+
markChargeUsed(): void;
|
|
230
|
+
/**
|
|
231
|
+
* Return everything still held: an untaken permit through `park` (back to
|
|
232
|
+
* its block) and its slots. The budget is refunded unless the charge was
|
|
233
|
+
* used, and always after a fallback (nothing executed). Idempotent.
|
|
234
|
+
*/
|
|
235
|
+
settle(outcome: 'fallback' | 'done'): Promise<void>;
|
|
236
|
+
};
|
|
237
|
+
|
|
238
|
+
export function createRuntimeReadThroughGrant<
|
|
239
|
+
Permit extends RuntimeReadThroughPermit,
|
|
240
|
+
>(input: {
|
|
241
|
+
keys: readonly string[];
|
|
242
|
+
providerPermit: Permit;
|
|
243
|
+
executionSlot: RuntimeReadThroughLease;
|
|
244
|
+
integrationRequestLease: RuntimeReadThroughLease | null;
|
|
245
|
+
/** `commit` (when present) is told the charge stands for executed work. */
|
|
246
|
+
budget: { refund(): void; commit?(): void };
|
|
247
|
+
}): RuntimeReadThroughGrant<Permit> {
|
|
248
|
+
let capacity: {
|
|
249
|
+
providerPermit: Permit;
|
|
250
|
+
executionSlot: RuntimeReadThroughLease;
|
|
251
|
+
integrationRequestLease: RuntimeReadThroughLease | null;
|
|
252
|
+
} | null = {
|
|
253
|
+
providerPermit: input.providerPermit,
|
|
254
|
+
executionSlot: input.executionSlot,
|
|
255
|
+
integrationRequestLease: input.integrationRequestLease,
|
|
256
|
+
};
|
|
257
|
+
let chargeUsed = false;
|
|
258
|
+
let settled = false;
|
|
259
|
+
return {
|
|
260
|
+
keys: [...input.keys],
|
|
261
|
+
takeDispatchCapacity() {
|
|
262
|
+
const taken = capacity;
|
|
263
|
+
capacity = null;
|
|
264
|
+
return taken;
|
|
265
|
+
},
|
|
266
|
+
markChargeUsed() {
|
|
267
|
+
chargeUsed = true;
|
|
268
|
+
},
|
|
269
|
+
async settle(outcome) {
|
|
270
|
+
if (settled) return;
|
|
271
|
+
settled = true;
|
|
272
|
+
const held = capacity;
|
|
273
|
+
capacity = null;
|
|
274
|
+
try {
|
|
275
|
+
if (held) {
|
|
276
|
+
held.integrationRequestLease?.release();
|
|
277
|
+
held.executionSlot.release();
|
|
278
|
+
if (held.providerPermit.park) await held.providerPermit.park();
|
|
279
|
+
else await held.providerPermit.cancel();
|
|
280
|
+
}
|
|
281
|
+
} finally {
|
|
282
|
+
if (outcome === 'fallback' || !chargeUsed) input.budget.refund();
|
|
283
|
+
else input.budget.commit?.();
|
|
284
|
+
}
|
|
285
|
+
},
|
|
286
|
+
};
|
|
287
|
+
}
|