deepline 0.3.534 → 0.3.536
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 +254 -147
- package/dist/bundling-sources/sdk/src/index.ts +4 -0
- package/dist/bundling-sources/sdk/src/plays/local-file-discovery.ts +27 -1
- package/dist/bundling-sources/sdk/src/plays/run-request.ts +16 -5
- package/dist/bundling-sources/sdk/src/release.ts +1 -1
- package/dist/bundling-sources/sdk/src/types.ts +2 -23
- package/dist/bundling-sources/shared_libs/integration-contracts/monitor-fleet-contract.ts +26 -14
- package/dist/bundling-sources/shared_libs/integration-contracts/monitor-input-contract.ts +33 -8
- package/dist/bundling-sources/shared_libs/monitors/fleets/count-drift-alert.ts +121 -0
- package/dist/bundling-sources/shared_libs/monitors/fleets/limits.ts +8 -0
- package/dist/bundling-sources/shared_libs/monitors/fleets/plan.ts +14 -82
- package/dist/bundling-sources/shared_libs/monitors/package.json +1 -0
- package/dist/bundling-sources/shared_libs/observability/scheduled-jobs.json +4 -4
- package/dist/bundling-sources/shared_libs/play-data-plane/r2.ts +0 -26
- package/dist/bundling-sources/shared_libs/play-runtime/activity-observation.ts +36 -0
- package/dist/bundling-sources/shared_libs/play-runtime/app-runtime-api.ts +21 -31
- package/dist/bundling-sources/shared_libs/play-runtime/call-requeue-state-machine.ts +420 -0
- package/dist/bundling-sources/shared_libs/play-runtime/context.ts +727 -102
- package/dist/bundling-sources/shared_libs/play-runtime/ctx-types.ts +26 -0
- package/dist/bundling-sources/shared_libs/play-runtime/durable-retry-policy.ts +624 -0
- package/dist/bundling-sources/shared_libs/play-runtime/durable-runs-rollout.ts +12 -10
- package/dist/bundling-sources/shared_libs/play-runtime/durable-summary-events.ts +3 -1
- package/dist/bundling-sources/shared_libs/play-runtime/governor/app-runtime-rate-state-backend.ts +71 -2
- package/dist/bundling-sources/shared_libs/play-runtime/governor/governor.ts +60 -1
- package/dist/bundling-sources/shared_libs/play-runtime/governor/rate-state-backend.ts +2 -0
- package/dist/bundling-sources/shared_libs/play-runtime/launch-identity.ts +1 -0
- package/dist/bundling-sources/shared_libs/play-runtime/map-memory-limits.ts +372 -10
- package/dist/bundling-sources/shared_libs/play-runtime/memory-ledger.ts +15 -2
- package/dist/bundling-sources/shared_libs/play-runtime/output-size-limits.ts +21 -0
- package/dist/bundling-sources/shared_libs/play-runtime/prebuilt-result-quality.ts +1 -1
- package/dist/bundling-sources/shared_libs/play-runtime/protocol.ts +6 -0
- package/dist/bundling-sources/shared_libs/play-runtime/provider-capacity/fixture-capacity-simulator.ts +1 -0
- package/dist/bundling-sources/shared_libs/play-runtime/provider-capacity/gradient2-concurrency-controller.ts +41 -0
- package/dist/bundling-sources/shared_libs/play-runtime/provider-capacity/provider-capacity-policy.ts +6 -0
- package/dist/bundling-sources/shared_libs/play-runtime/provider-capacity/provider-concurrency-policy.ts +9 -0
- package/dist/bundling-sources/shared_libs/play-runtime/provider-no-progress.ts +6 -2
- package/dist/bundling-sources/shared_libs/play-runtime/resource-governor.ts +17 -0
- package/dist/bundling-sources/shared_libs/play-runtime/run-failure.ts +2 -2
- package/dist/bundling-sources/shared_libs/play-runtime/run-ledger.ts +5 -2
- package/dist/bundling-sources/shared_libs/play-runtime/runner-app/runtime-tool-hooks.ts +63 -3
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-operation-contract.ts +7 -0
- package/dist/bundling-sources/shared_libs/play-runtime/sandbox-compute-usage.ts +31 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backend.ts +6 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-runtime-worker.ts +26 -1
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres-rate-scope.ts +11 -4
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres-rate-state.ts +73 -18
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres.ts +169 -2
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-sandbox-capacity.ts +26 -4
- package/dist/bundling-sources/shared_libs/play-runtime/tool-execute-retry-policy.ts +90 -49
- package/dist/bundling-sources/shared_libs/plays/authoring-contract.ts +136 -30
- package/dist/bundling-sources/shared_libs/plays/launch/input-contract.ts +13 -1
- package/dist/bundling-sources/shared_libs/plays/local-file-discovery.ts +68 -1
- package/dist/bundling-sources/shared_libs/plays/share/static-pipeline-summary.ts +63 -13
- package/dist/bundling-sources/shared_libs/product-notifications/configuration-draft.ts +57 -1
- package/dist/bundling-sources/shared_libs/product-notifications/configuration.ts +22 -9
- package/dist/cli/auth-6XQKFOLG.js +43 -0
- package/dist/cli/{auth-MHQYIMVX.mjs → auth-KCTCUO7P.mjs} +7 -7
- package/dist/cli/{billing-YQLNP4S5.js → billing-4VBGZ3CT.js} +273 -112
- package/dist/cli/{billing-LX2PSBJ4.mjs → billing-OOJHKLNS.mjs} +185 -24
- package/dist/cli/{chunk-DGKTHWWH.js → chunk-2B4IOGFD.js} +406 -382
- package/dist/cli/{chunk-MQORQ7WL.js → chunk-2FCSUOYN.js} +55 -55
- package/dist/cli/{chunk-T2N3B7IQ.js → chunk-2GJZLIKW.js} +8 -8
- package/dist/cli/{chunk-6IFZPEJE.mjs → chunk-2YWJS76L.mjs} +1 -1
- package/dist/cli/{chunk-E7TP25I2.mjs → chunk-3PCYV6ZJ.mjs} +2 -2
- package/dist/cli/{chunk-LGRZCHKC.js → chunk-4E5JXZ3W.js} +18 -20
- package/dist/cli/{chunk-R4RG4FV5.mjs → chunk-4KWD3MX2.mjs} +13 -10
- package/dist/cli/{chunk-SUWTLXCV.js → chunk-6BBGUQJJ.js} +67 -146
- package/dist/cli/{chunk-JBBJDFUJ.js → chunk-6VUGBQZQ.js} +5 -5
- package/dist/cli/{chunk-2P3NVX65.mjs → chunk-AB2GBOD4.mjs} +40 -27
- package/dist/cli/{chunk-62SOZ67Y.mjs → chunk-ANUKBZ6W.mjs} +475 -11
- package/dist/cli/{chunk-MG6YL4M7.mjs → chunk-BASLYGXK.mjs} +101 -77
- package/dist/cli/{chunk-SQWET4SL.js → chunk-BBTKAASQ.js} +2 -1
- package/dist/cli/{chunk-NRO3NTVO.js → chunk-CBV7AKWM.js} +5 -5
- package/dist/cli/{chunk-RH3YRMUY.js → chunk-CIDN5K23.js} +1 -1
- package/dist/cli/{chunk-QNHHZ63P.mjs → chunk-CQBIO6HW.mjs} +1 -1
- package/dist/cli/{chunk-2KHUFWTK.js → chunk-CQDQNZGH.js} +42 -37
- package/dist/cli/{chunk-UWNVFAFN.js → chunk-CWSLUNA6.js} +33 -33
- package/dist/cli/{chunk-5FXMEEF4.mjs → chunk-CXTW7SRW.mjs} +67 -146
- package/dist/cli/{chunk-O53LHONF.mjs → chunk-DA2I2M7D.mjs} +2 -2
- package/dist/cli/{chunk-EYXUAJAU.mjs → chunk-DQHUJMCL.mjs} +5 -5
- package/dist/cli/{chunk-7GFR5Y4J.mjs → chunk-DUYAMLOC.mjs} +1 -1
- package/dist/cli/{chunk-OMVVHX4U.mjs → chunk-E24UGPGG.mjs} +13 -15
- package/dist/cli/{chunk-STR5LXK4.mjs → chunk-FSIVF2SI.mjs} +1 -1
- package/dist/cli/{chunk-KJVY7V2X.mjs → chunk-GF32SBST.mjs} +1 -1
- package/dist/cli/{chunk-AK622KIG.mjs → chunk-GHLDCLSC.mjs} +1 -1
- package/dist/cli/{chunk-A6HNT4EE.js → chunk-GTVZKY3F.js} +2 -2
- package/dist/cli/{chunk-BXIUZM5N.mjs → chunk-HAJQGP5V.mjs} +2 -2
- package/dist/cli/{chunk-6CEUQYMB.js → chunk-HWDKRN7L.js} +3 -3
- package/dist/cli/{chunk-5YAJGRWB.js → chunk-IPVRMYWT.js} +7 -7
- package/dist/cli/{chunk-ZPGGW27Q.mjs → chunk-JL2OTMSG.mjs} +1 -0
- package/dist/cli/{chunk-WR4WETRU.mjs → chunk-JUHDJNSI.mjs} +4 -4
- package/dist/cli/{chunk-TQH3533L.mjs → chunk-KPQHUVYW.mjs} +5 -5
- package/dist/cli/{chunk-V7SCRUFQ.js → chunk-KWYGWO4Y.js} +9 -6
- package/dist/cli/{chunk-DZS4JC7I.js → chunk-LDGZFDUB.js} +2 -2
- package/dist/cli/{chunk-EGTUOYYG.js → chunk-LN6RXDTB.js} +523 -59
- package/dist/cli/{chunk-DQ5ADV2J.mjs → chunk-LZXZQPA2.mjs} +4 -1
- package/dist/cli/{chunk-MYSKWJMA.js → chunk-MSP4DTSD.js} +13 -13
- package/dist/cli/{chunk-BNH4Y35W.mjs → chunk-OLH2PHMC.mjs} +2 -2
- package/dist/cli/{chunk-NNAE7E23.mjs → chunk-OUDTOMZC.mjs} +7 -9
- package/dist/cli/{chunk-GESIFFQX.mjs → chunk-OVX3Q5Q3.mjs} +1 -1
- package/dist/cli/{chunk-ENCA6O2D.mjs → chunk-PNY3BWHP.mjs} +2 -2
- package/dist/cli/{chunk-KSA2XE4T.js → chunk-Q4MNUOS4.js} +316 -303
- package/dist/cli/{chunk-GTXSUPCJ.js → chunk-Q5CXV3E3.js} +2 -2
- package/dist/cli/{chunk-VAG5YKP6.mjs → chunk-RVSSQPQO.mjs} +1 -1
- package/dist/cli/{chunk-VE7ZPLN2.js → chunk-SLPJ3LXI.js} +22 -22
- package/dist/cli/{chunk-IX45S5VC.js → chunk-TX5TUHJN.js} +17 -19
- package/dist/cli/{chunk-IF75RD6U.js → chunk-U2LVWCTD.js} +18 -6
- package/dist/cli/{chunk-ZS2WHWWL.js → chunk-UNDLNT3V.js} +1 -1
- package/dist/cli/{chunk-NDFNBJGL.js → chunk-VBDZIMWD.js} +26 -26
- package/dist/cli/{chunk-GVGQ6NZW.js → chunk-W7AEIGZR.js} +41 -41
- package/dist/cli/{chunk-WDNRPZED.mjs → chunk-WC5M3JXE.mjs} +2 -2
- package/dist/cli/{chunk-C374C22Y.js → chunk-WOQO3GV4.js} +14 -11
- package/dist/cli/{chunk-MQX363YF.js → chunk-XBAH3TKU.js} +5 -5
- package/dist/cli/{chunk-BDWZBMGV.mjs → chunk-XJD2GYUP.mjs} +5 -5
- package/dist/cli/{chunk-XRZJKHUA.mjs → chunk-XVZRJJDS.mjs} +4 -4
- package/dist/cli/{chunk-TVINIDHB.js → chunk-Y2NTPYGS.js} +17 -17
- package/dist/cli/{chunk-6GTGWZJG.mjs → chunk-YBMHOH6H.mjs} +4 -4
- package/dist/cli/{chunk-TG2UB3A5.mjs → chunk-YRLAUGQY.mjs} +3 -3
- package/dist/cli/{chunk-FKD3KL5Q.mjs → chunk-Z2XA6YU4.mjs} +10 -5
- package/dist/cli/{chunk-KXQCUX3X.mjs → chunk-Z7UIOGW4.mjs} +3 -3
- package/dist/cli/{chunk-HCD36BP6.js → chunk-ZEV2Y56V.js} +44 -44
- package/dist/cli/{chunk-MI6ZP7XI.mjs → chunk-ZG7BOECV.mjs} +18 -6
- package/dist/cli/{chunk-XBK6WCVA.js → chunk-ZILSRDIN.js} +8 -8
- package/dist/cli/{chunk-B2AS3R5W.js → chunk-ZISEH7OL.js} +16 -16
- package/dist/cli/{chunk-HPJAE6PP.js → chunk-ZZ4MF2GI.js} +6 -6
- package/dist/cli/command-docs.js +2 -2
- package/dist/cli/command-docs.mjs +1 -1
- package/dist/cli/{csv-U3M2G76R.js → csv-2V2DIFNG.js} +15 -15
- package/dist/cli/{csv-4ID4E5W3.mjs → csv-P3HLK4GO.mjs} +6 -6
- package/dist/cli/{db-IHAQIKEQ.js → db-MREAQVW6.js} +36 -36
- package/dist/cli/{db-LHX5BBCZ.mjs → db-ZYOY3QRQ.mjs} +9 -9
- package/dist/cli/describe-IKZFOADR.mjs +49 -0
- package/dist/cli/describe-WW3OQRLP.js +49 -0
- package/dist/cli/describe-core.d.mts +3 -3
- package/dist/cli/describe-core.d.ts +3 -3
- package/dist/cli/describe-core.js +5 -5
- package/dist/cli/describe-core.mjs +4 -4
- package/dist/cli/{executions-CJ5LV23G.js → executions-H5IJ7QSQ.js} +11 -11
- package/dist/cli/{executions-UJ6JZUL5.mjs → executions-KTSY5M34.mjs} +9 -9
- package/dist/cli/{feedback-TGUBVGRP.js → feedback-724QK3Z5.js} +16 -16
- package/dist/cli/{feedback-YGTPJBRJ.mjs → feedback-WWJRIXEU.mjs} +8 -8
- package/dist/cli/git-PHYRD56H.js +25 -0
- package/dist/cli/{git-3DOTQHJO.mjs → git-R5VRG7X6.mjs} +7 -7
- package/dist/cli/index.js +151 -157
- package/dist/cli/index.mjs +51 -57
- package/dist/cli/{legacy-noops-BHEHVFHI.js → legacy-noops-C6GDEGPU.js} +11 -11
- package/dist/cli/{legacy-noops-RBBYRVLG.mjs → legacy-noops-PWZ5XLAO.mjs} +8 -8
- package/dist/cli/{monitors-XECKLAXA.js → monitors-VAVQ4WCE.js} +125 -122
- package/dist/cli/{monitors-5AJCG6IV.mjs → monitors-WQSKMHAP.mjs} +19 -16
- package/dist/cli/{org-DOBAIYWG.js → org-CWWRWXZQ.js} +89 -89
- package/dist/cli/{org-ZAAIEZKB.mjs → org-MAL4QPVF.mjs} +9 -9
- package/dist/cli/{play-KLYRMQPF.mjs → play-ILW6MSNG.mjs} +174 -80
- package/dist/cli/{play-E74VN6B7.js → play-WJOWK5PQ.js} +690 -596
- package/dist/cli/{providers-XTQXV5LB.mjs → providers-4V2NMLZZ.mjs} +9 -9
- package/dist/cli/{providers-APZ6SOSK.js → providers-W662ANCH.js} +12 -12
- package/dist/cli/{quickstart-S6WN6NWW.js → quickstart-BW6EBUYX.js} +8 -8
- package/dist/cli/{quickstart-X7RHHQCH.mjs → quickstart-C22BR743.mjs} +6 -6
- package/dist/cli/{run-3YLIJJ57.js → run-KW7KW4FX.js} +50 -53
- package/dist/cli/{run-TZPBBSPX.mjs → run-SPAU5IMW.mjs} +31 -34
- package/dist/cli/search-HLE54W5G.js +32 -0
- package/dist/cli/{search-VLHE2CMZ.mjs → search-XPC75HLM.mjs} +10 -11
- package/dist/cli/{search-output-73BYB7UE.mjs → search-output-JKYJSEPM.mjs} +6 -6
- package/dist/cli/{search-output-GCT7PQIT.js → search-output-VJYE7USJ.js} +8 -8
- package/dist/cli/{secrets-RLOTGKQZ.mjs → secrets-OJG73GXQ.mjs} +9 -9
- package/dist/cli/{secrets-J6CEKXKQ.js → secrets-YB57KGSB.js} +18 -18
- package/dist/cli/{sessions-7HZ7OZ62.mjs → sessions-7ZL37BW4.mjs} +8 -8
- package/dist/cli/sessions-VEBYZIEU.js +22 -0
- package/dist/cli/{settings-WRV5XEZC.js → settings-A7DD2ZYE.js} +88 -89
- package/dist/cli/{settings-72K5YCIS.mjs → settings-RKSQB7FA.mjs} +15 -16
- package/dist/cli/{setup-KQFY6WT4.mjs → setup-NXDUTITY.mjs} +11 -12
- package/dist/cli/{setup-QVXWT2EQ.js → setup-S3K5YU62.js} +51 -52
- package/dist/cli/skills-NVQ744CN.js +36 -0
- package/dist/cli/{skills-C3K3E473.mjs → skills-VMFAIDO6.mjs} +9 -10
- package/dist/cli/{tools-4A2OH6MB.mjs → tools-52NTHBSJ.mjs} +20 -21
- package/dist/cli/tools-SBDUL3WB.js +56 -0
- package/dist/cli/update-HHVFZPCV.js +34 -0
- package/dist/cli/{update-BS6USKPR.mjs → update-SAKBEKMV.mjs} +11 -12
- package/dist/cli/{views-WB6GFTRX.mjs → views-ACRV7MD6.mjs} +54 -10
- package/dist/cli/{views-4NZGAXHL.js → views-C3GJOBDG.js} +66 -22
- package/dist/cli/{workflow-2D4WX55R.mjs → workflow-CS22E7TC.mjs} +10 -10
- package/dist/cli/{workflow-L2QTQZYV.js → workflow-ZNWCZEGN.js} +20 -20
- package/dist/{client-DoUVSkqC.d.mts → client-BlLYQDNo.d.mts} +1 -1
- package/dist/{client-DQm56zMs.d.ts → client-DSQlkIDO.d.ts} +1 -1
- package/dist/{client-core-C7KkUIE_.d.ts → client-core-CDwapXy5.d.ts} +167 -108
- package/dist/{client-core-CPlwsC1Q.d.mts → client-core-rX7n2H8U.d.mts} +167 -108
- package/dist/{compiler-manifest-DsxsQP-T.d.mts → compiler-manifest-BHNC4RL-.d.mts} +58 -21
- package/dist/{compiler-manifest-DsxsQP-T.d.ts → compiler-manifest-BHNC4RL-.d.ts} +58 -21
- package/dist/{errors-qdJUVQ3g.d.mts → errors-D7sPXrvB.d.mts} +1 -1
- package/dist/{errors-Bk5h1D-C.d.ts → errors-lhtIWG5Z.d.ts} +1 -1
- package/dist/{index-bL66eHYz.d.ts → index-CQTBHXHr.d.ts} +1 -1
- package/dist/{index-PaupwX1B.d.mts → index-NaDZq2xf.d.mts} +1 -1
- package/dist/index.d.mts +7 -7
- package/dist/index.d.ts +7 -7
- package/dist/index.js +15 -15
- package/dist/index.mjs +11 -11
- package/dist/install-integrity.json +131 -132
- package/dist/monitor-fleet-contract.d.mts +17 -11
- package/dist/monitor-fleet-contract.d.ts +17 -11
- package/dist/monitor-fleet-contract.js +3 -3
- package/dist/monitor-fleet-contract.mjs +2 -2
- package/dist/monitor-input-contract.js +2 -2
- package/dist/monitor-input-contract.mjs +1 -1
- package/dist/plays/bundle-play-file.d.mts +3 -3
- package/dist/plays/bundle-play-file.d.ts +3 -3
- package/dist/plays/bundle-play-file.mjs +67 -3
- package/dist/plays/csv-data-input.js +3 -3
- package/dist/plays/csv-data-input.mjs +2 -2
- 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/plays/run-request.js +3 -3
- package/dist/plays/run-request.mjs +2 -2
- package/dist/release.d.mts +1 -1
- package/dist/release.d.ts +1 -1
- package/dist/release.js +2 -2
- package/dist/release.mjs +1 -1
- package/dist/server.d.mts +4 -4
- package/dist/server.d.ts +4 -4
- package/dist/server.js +12 -12
- package/dist/server.mjs +6 -6
- package/package.json +1 -1
- package/dist/cli/auth-UP2RGPI6.js +0 -43
- package/dist/cli/chunk-5LZ5VSOK.mjs +0 -405
- package/dist/cli/chunk-D3J2Y2BP.js +0 -405
- package/dist/cli/describe-CI4MREFF.mjs +0 -50
- package/dist/cli/describe-IVTSD7ST.js +0 -50
- package/dist/cli/git-R3W25XIF.js +0 -25
- package/dist/cli/pages-FUOSF6BE.mjs +0 -266
- package/dist/cli/pages-TLC2N6L7.js +0 -266
- package/dist/cli/search-NB5CBALV.js +0 -33
- package/dist/cli/sessions-SFCZSB77.js +0 -22
- package/dist/cli/skills-WIJEHVLA.js +0 -37
- package/dist/cli/tools-VMMERMLO.js +0 -57
- package/dist/cli/update-54WZQDTS.js +0 -35
|
@@ -376,7 +376,7 @@ type RuntimeApiRequest =
|
|
|
376
376
|
action: 'governor_budget_charge';
|
|
377
377
|
} & PlayRunnerBudgetChargeInput)
|
|
378
378
|
| { action: 'get_billing_entitlements' }
|
|
379
|
-
|
|
|
379
|
+
| { action: 'list_views' }
|
|
380
380
|
| { action: 'get_runtime_traffic_policy' }
|
|
381
381
|
| RuntimeReceiptAction;
|
|
382
382
|
|
|
@@ -2456,51 +2456,41 @@ export async function getBillingEntitlementsViaAppRuntime(
|
|
|
2456
2456
|
}
|
|
2457
2457
|
}
|
|
2458
2458
|
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
contentType: string;
|
|
2463
|
-
description?: string;
|
|
2464
|
-
/** Exactly one of these carries the content. */
|
|
2465
|
-
contentText?: string;
|
|
2466
|
-
contentBase64?: string;
|
|
2467
|
-
};
|
|
2468
|
-
|
|
2469
|
-
export type PlayPageWriteResult = {
|
|
2459
|
+
/** A view of the running Play, as `deepline.views.list()` returns it. */
|
|
2460
|
+
export type PlayViewLink = {
|
|
2461
|
+
id: string;
|
|
2470
2462
|
name: string;
|
|
2463
|
+
/** Opens the view at its latest run. */
|
|
2471
2464
|
url: string;
|
|
2472
|
-
|
|
2473
|
-
|
|
2474
|
-
|
|
2465
|
+
/** Opens the view at the run that asked. */
|
|
2466
|
+
runUrl: string;
|
|
2467
|
+
access: 'workspace' | 'public';
|
|
2475
2468
|
};
|
|
2476
2469
|
|
|
2477
|
-
export async function
|
|
2470
|
+
export async function listViewsViaAppRuntime(
|
|
2478
2471
|
context: WorkerRuntimeApiContext,
|
|
2479
|
-
|
|
2480
|
-
): Promise<PlayPageWriteResult> {
|
|
2472
|
+
): Promise<PlayViewLink[]> {
|
|
2481
2473
|
try {
|
|
2482
|
-
|
|
2483
|
-
|
|
2484
|
-
|
|
2485
|
-
|
|
2474
|
+
const result = await postAppRuntimeApi<{ views: PlayViewLink[] }>(
|
|
2475
|
+
context,
|
|
2476
|
+
{ action: 'list_views' },
|
|
2477
|
+
);
|
|
2478
|
+
return result.views;
|
|
2486
2479
|
} catch (error) {
|
|
2487
|
-
// An older receiver does not know
|
|
2488
|
-
//
|
|
2489
|
-
// page.write, so either exact 403 means page writes are not available yet.
|
|
2480
|
+
// An older receiver does not know list_views. Say so instead of returning
|
|
2481
|
+
// an empty list, which would read as "this Play has no views".
|
|
2490
2482
|
if (
|
|
2491
2483
|
error instanceof AppRuntimeApiResponseError &&
|
|
2492
2484
|
error.status === 403 &&
|
|
2493
2485
|
error.code === null &&
|
|
2494
|
-
|
|
2495
|
-
error.detail ===
|
|
2496
|
-
'Workflow executor token does not permit this operation.')
|
|
2486
|
+
error.detail === 'Unsupported runtime action capability scope.'
|
|
2497
2487
|
) {
|
|
2498
2488
|
throw new AppRuntimeApiResponseError({
|
|
2499
|
-
action: '
|
|
2489
|
+
action: 'list_views',
|
|
2500
2490
|
status: 503,
|
|
2501
|
-
code: '
|
|
2491
|
+
code: 'VIEWS_UNAVAILABLE',
|
|
2502
2492
|
retryable: false,
|
|
2503
|
-
detail: '
|
|
2493
|
+
detail: 'Listing views is not available to this run yet.',
|
|
2504
2494
|
});
|
|
2505
2495
|
}
|
|
2506
2496
|
throw error;
|
|
@@ -0,0 +1,420 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The call requeue state machine: what happens to one logical Play tool call
|
|
3
|
+
* after its in-call retries are spent on a retryable error class.
|
|
4
|
+
*
|
|
5
|
+
* absent ──start──▶ in_call ──succeed──▶ succeeded (terminal)
|
|
6
|
+
* │ ├────exhaust──▶ exhausted (terminal)
|
|
7
|
+
* │ ├───────park──▶ parked
|
|
8
|
+
* │ └─wait_for_billing─▶ waiting_for_billing
|
|
9
|
+
* parked / waiting_for_billing ──resume──▶ resumed ──retry──▶ in_call
|
|
10
|
+
*
|
|
11
|
+
* The record lives in the run checkpoint (`PlayCheckpoint.callRequeueStates`),
|
|
12
|
+
* keyed by the call's durable receipt identity, and only `transitionCallRequeue`
|
|
13
|
+
* changes it. A terminal transition removes the record, so the checkpoint
|
|
14
|
+
* holds only calls that are parked or being retried. Every park records the
|
|
15
|
+
* Durable retry policy version it used.
|
|
16
|
+
*
|
|
17
|
+
* The decision (`decideCallRequeue`) reads only the policy snapshot taken at
|
|
18
|
+
* attempt start; it never fetches.
|
|
19
|
+
*/
|
|
20
|
+
import type { PlayToolCallRetryPolicy } from '../plays/authoring-contract';
|
|
21
|
+
import type {
|
|
22
|
+
DurableRetryErrorClass,
|
|
23
|
+
DurableRetryPolicySnapshot,
|
|
24
|
+
} from './durable-retry-policy';
|
|
25
|
+
import { EXECUTION_GATEWAY_MAX_REQUEUE_PARKS } from './tool-execute-retry-policy';
|
|
26
|
+
|
|
27
|
+
export const CALL_REQUEUE_STATES = [
|
|
28
|
+
'in_call',
|
|
29
|
+
'parked',
|
|
30
|
+
'waiting_for_billing',
|
|
31
|
+
'resumed',
|
|
32
|
+
'succeeded',
|
|
33
|
+
'exhausted',
|
|
34
|
+
] as const;
|
|
35
|
+
export type CallRequeueState = (typeof CALL_REQUEUE_STATES)[number];
|
|
36
|
+
|
|
37
|
+
export const CALL_REQUEUE_TERMINAL_STATES: ReadonlySet<CallRequeueState> =
|
|
38
|
+
new Set(['succeeded', 'exhausted']);
|
|
39
|
+
|
|
40
|
+
export const CALL_REQUEUE_TRANSITIONS = {
|
|
41
|
+
start: { from: ['absent'], to: 'in_call' },
|
|
42
|
+
succeed: { from: ['in_call'], to: 'succeeded' },
|
|
43
|
+
exhaust: { from: ['in_call'], to: 'exhausted' },
|
|
44
|
+
park: { from: ['in_call'], to: 'parked' },
|
|
45
|
+
wait_for_billing: { from: ['in_call'], to: 'waiting_for_billing' },
|
|
46
|
+
resume: { from: ['parked', 'waiting_for_billing'], to: 'resumed' },
|
|
47
|
+
retry: { from: ['resumed'], to: 'in_call' },
|
|
48
|
+
} as const satisfies Record<
|
|
49
|
+
string,
|
|
50
|
+
{ from: readonly (CallRequeueState | 'absent')[]; to: CallRequeueState }
|
|
51
|
+
>;
|
|
52
|
+
export type CallRequeueTransition = keyof typeof CALL_REQUEUE_TRANSITIONS;
|
|
53
|
+
|
|
54
|
+
/** Persisted per call while it is not terminal. Fixed size. */
|
|
55
|
+
export type CallRequeueRecord = {
|
|
56
|
+
state: CallRequeueState;
|
|
57
|
+
errorClass: DurableRetryErrorClass | null;
|
|
58
|
+
/** Stored policy version the last park used; null means compiled defaults. */
|
|
59
|
+
policySequence: number | null;
|
|
60
|
+
parks: number;
|
|
61
|
+
/** Parks in a row that ended in the same class again. */
|
|
62
|
+
consecutive: number;
|
|
63
|
+
firstParkAtMs: number | null;
|
|
64
|
+
retryAtMs: number | null;
|
|
65
|
+
/** Window extensions granted so far. */
|
|
66
|
+
extensionsUsed: number;
|
|
67
|
+
/**
|
|
68
|
+
* The invocation attempt the call resumes at after its latest park; a
|
|
69
|
+
* fenced resend claims it so the gateway checks prior outcomes per park
|
|
70
|
+
* segment (`requeue_from_invocation_attempt`). Optional: absent in records
|
|
71
|
+
* written before it existed.
|
|
72
|
+
*/
|
|
73
|
+
requeueFromInvocationAttempt?: number | null;
|
|
74
|
+
/**
|
|
75
|
+
* Requests the provider received for this call so far, in-call resends and
|
|
76
|
+
* durable retries together; a call's `retry.maximumAttempts` bounds it.
|
|
77
|
+
* Refusals before dispatch are not counted. Optional: absent in records
|
|
78
|
+
* written before it existed (read as `parks`, the fewest it can be).
|
|
79
|
+
*/
|
|
80
|
+
sends?: number;
|
|
81
|
+
lastTransition: CallRequeueTransition;
|
|
82
|
+
lastTransitionAtMs: number;
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
export class IllegalCallRequeueTransitionError extends Error {
|
|
86
|
+
constructor(transition: CallRequeueTransition, from: string) {
|
|
87
|
+
super(`Call requeue transition ${transition} is not allowed from ${from}.`);
|
|
88
|
+
this.name = 'IllegalCallRequeueTransitionError';
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* The only writer of a call's requeue state. Returns the new record, or null
|
|
94
|
+
* when the call reached a terminal state (the owner deletes it).
|
|
95
|
+
*/
|
|
96
|
+
export function transitionCallRequeue(
|
|
97
|
+
record: CallRequeueRecord | undefined,
|
|
98
|
+
transition: CallRequeueTransition,
|
|
99
|
+
nowMs: number,
|
|
100
|
+
patch: Partial<
|
|
101
|
+
Omit<CallRequeueRecord, 'state' | 'lastTransition' | 'lastTransitionAtMs'>
|
|
102
|
+
> = {},
|
|
103
|
+
): CallRequeueRecord | null {
|
|
104
|
+
const rule = CALL_REQUEUE_TRANSITIONS[transition];
|
|
105
|
+
const from = record?.state ?? 'absent';
|
|
106
|
+
if (!(rule.from as readonly string[]).includes(from)) {
|
|
107
|
+
throw new IllegalCallRequeueTransitionError(transition, from);
|
|
108
|
+
}
|
|
109
|
+
if (CALL_REQUEUE_TERMINAL_STATES.has(rule.to)) return null;
|
|
110
|
+
return {
|
|
111
|
+
errorClass: null,
|
|
112
|
+
policySequence: null,
|
|
113
|
+
parks: 0,
|
|
114
|
+
consecutive: 0,
|
|
115
|
+
firstParkAtMs: null,
|
|
116
|
+
retryAtMs: null,
|
|
117
|
+
extensionsUsed: 0,
|
|
118
|
+
...record,
|
|
119
|
+
...patch,
|
|
120
|
+
state: rule.to,
|
|
121
|
+
lastTransition: transition,
|
|
122
|
+
lastTransitionAtMs: nowMs,
|
|
123
|
+
} as CallRequeueRecord;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export type CallRequeueExhaustReason =
|
|
127
|
+
| 'not_in_call'
|
|
128
|
+
| 'park_limit'
|
|
129
|
+
| 'park_disabled'
|
|
130
|
+
| 'not_eligible'
|
|
131
|
+
| 'consecutive_limit'
|
|
132
|
+
| 'window'
|
|
133
|
+
/** The call's own `retry.nonRetryable` lists the class. */
|
|
134
|
+
| 'non_retryable'
|
|
135
|
+
/** The call's own `retry.maximumAttempts` is spent. */
|
|
136
|
+
| 'maximum_attempts';
|
|
137
|
+
|
|
138
|
+
export type CallRequeueDecision =
|
|
139
|
+
| {
|
|
140
|
+
kind: 'park';
|
|
141
|
+
transition: 'park' | 'wait_for_billing';
|
|
142
|
+
retryAtMs: number;
|
|
143
|
+
waitMs: number;
|
|
144
|
+
/** The record to persist (already transitioned). */
|
|
145
|
+
record: CallRequeueRecord;
|
|
146
|
+
}
|
|
147
|
+
| { kind: 'exhaust'; reason: CallRequeueExhaustReason };
|
|
148
|
+
|
|
149
|
+
export const BILLING_ERROR_CLASSES: ReadonlySet<DurableRetryErrorClass> =
|
|
150
|
+
new Set(['billing_insufficient_credits', 'billing_monthly_cap']);
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* The Durable retry class of a failure whose in-call retries are spent, or
|
|
154
|
+
* null when it never parks (caller errors, customer-set run caps, and
|
|
155
|
+
* failures this build does not classify). Structured fields only, never text.
|
|
156
|
+
*/
|
|
157
|
+
export function classifyDurableRetryErrorClass(input: {
|
|
158
|
+
status: number;
|
|
159
|
+
/** `ToolExecuteHttpFailureOutcome.reason`. */
|
|
160
|
+
reason: string;
|
|
161
|
+
knownNotDispatched: boolean;
|
|
162
|
+
/** `ToolExecutionError.origin` when the envelope is structured. */
|
|
163
|
+
origin: string | null;
|
|
164
|
+
/** The failure's code (`ToolExecutionError.code` or body `code`). */
|
|
165
|
+
code: string | null;
|
|
166
|
+
/**
|
|
167
|
+
* The provider's own HTTP status (failure body `upstream_status`). The
|
|
168
|
+
* execute route answers every provider 5xx with 502, so the provider's 500
|
|
169
|
+
* is only visible here. Absent or invalid: the response status is used.
|
|
170
|
+
*/
|
|
171
|
+
upstreamStatus?: number | null;
|
|
172
|
+
/**
|
|
173
|
+
* The failure body's raw `error_category`. `model_output` is a
|
|
174
|
+
* provider-origin 500 that is the model's answer (MODEL_OUTPUT_INVALID),
|
|
175
|
+
* not an outage, and never parks.
|
|
176
|
+
*/
|
|
177
|
+
category?: string | null;
|
|
178
|
+
/**
|
|
179
|
+
* The failure body's `network_kind` for a provider transport failure. The
|
|
180
|
+
* execute route answers every one with 502, so a response-wait timeout is
|
|
181
|
+
* only visible here.
|
|
182
|
+
*/
|
|
183
|
+
networkKind?: string | null;
|
|
184
|
+
}): DurableRetryErrorClass | null {
|
|
185
|
+
if (input.reason === 'hard_billing_error') {
|
|
186
|
+
if (input.code === 'INSUFFICIENT_CREDITS') {
|
|
187
|
+
return 'billing_insufficient_credits';
|
|
188
|
+
}
|
|
189
|
+
if (input.code === 'MONTHLY_BILLING_LIMIT_EXCEEDED') {
|
|
190
|
+
return 'billing_monthly_cap';
|
|
191
|
+
}
|
|
192
|
+
// RUN_BILLING_CAP_EXCEEDED and every other denial is the customer's own
|
|
193
|
+
// limit or a terminal answer: never parked.
|
|
194
|
+
return null;
|
|
195
|
+
}
|
|
196
|
+
if (input.knownNotDispatched) return 'never_sent';
|
|
197
|
+
if (input.status === 429) {
|
|
198
|
+
return input.origin === 'provider' ? 'rate_limit_429' : null;
|
|
199
|
+
}
|
|
200
|
+
if (input.origin !== 'provider') return null;
|
|
201
|
+
if (input.category === 'model_output') return null;
|
|
202
|
+
// A transport timeout: a failure proven to be before send is `never_sent`
|
|
203
|
+
// above, so this one may have reached the provider. Owner rule: a timeout
|
|
204
|
+
// is not retried (the class is off unless turned on live).
|
|
205
|
+
if (input.networkKind === 'timeout') return 'timeout_after_send';
|
|
206
|
+
const upstream = input.upstreamStatus;
|
|
207
|
+
const status =
|
|
208
|
+
typeof upstream === 'number' &&
|
|
209
|
+
Number.isSafeInteger(upstream) &&
|
|
210
|
+
upstream >= 400 &&
|
|
211
|
+
upstream <= 599
|
|
212
|
+
? upstream
|
|
213
|
+
: input.status;
|
|
214
|
+
if (status === 502 || status === 503) return 'provider_unavailable';
|
|
215
|
+
// A gateway timeout after the request reached the provider: owner rule, a
|
|
216
|
+
// timeout is not retried (the class is off unless turned on live).
|
|
217
|
+
if (status === 504) return 'timeout_after_send';
|
|
218
|
+
if (status === 500) return 'provider_ambiguous_500';
|
|
219
|
+
return null;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* Decide, after a call's in-call retries are spent, whether it parks and
|
|
224
|
+
* until when, or is exhausted (the original error reaches the Play).
|
|
225
|
+
*/
|
|
226
|
+
export function decideCallRequeue(input: {
|
|
227
|
+
record: CallRequeueRecord | undefined;
|
|
228
|
+
errorClass: DurableRetryErrorClass;
|
|
229
|
+
snapshot: DurableRetryPolicySnapshot;
|
|
230
|
+
/** null when the action's effect is unknown: treated as a write. */
|
|
231
|
+
effect: 'read' | 'write' | 'destructive' | null;
|
|
232
|
+
/** The provider honors the stable idempotency key the runtime sends. */
|
|
233
|
+
idempotencyKeyHonored: boolean;
|
|
234
|
+
/**
|
|
235
|
+
* The write's class (`@deepline/integrations/write-idempotency`); null
|
|
236
|
+
* when unknown, which counts as non-idempotent.
|
|
237
|
+
*/
|
|
238
|
+
writeIdempotency?: 'idempotent_write' | 'non_idempotent_write' | null;
|
|
239
|
+
nowMs: number;
|
|
240
|
+
random?: () => number;
|
|
241
|
+
/** The invocation attempt that just failed; the resume starts after it. */
|
|
242
|
+
failedInvocationAttempt?: number;
|
|
243
|
+
/** The call runs under the gateway's durable execution fence. */
|
|
244
|
+
fenced?: boolean;
|
|
245
|
+
/**
|
|
246
|
+
* The call's own retry policy (`ctx.tools.execute({ retry })`). Its fields
|
|
247
|
+
* replace the class rule's: `maximumAttempts` bounds every request the
|
|
248
|
+
* provider received (`sends`), like an activity retry policy; the interval
|
|
249
|
+
* fields replace the park ladder.
|
|
250
|
+
*/
|
|
251
|
+
callRetry?: PlayToolCallRetryPolicy;
|
|
252
|
+
/**
|
|
253
|
+
* Requests the provider received for this call so far, the burst that just
|
|
254
|
+
* failed included. Absent: the prior record's count plus one.
|
|
255
|
+
*/
|
|
256
|
+
sends?: number;
|
|
257
|
+
}): CallRequeueDecision {
|
|
258
|
+
const rule = input.snapshot.policy.classes[input.errorClass];
|
|
259
|
+
const callRetry = input.callRetry;
|
|
260
|
+
if (callRetry?.nonRetryable?.includes(input.errorClass)) {
|
|
261
|
+
return { kind: 'exhaust', reason: 'non_retryable' };
|
|
262
|
+
}
|
|
263
|
+
// Every request the provider received counts, in-call resends and durable
|
|
264
|
+
// retries alike. The call's own limit applies before the class rule, like
|
|
265
|
+
// an activity retry policy.
|
|
266
|
+
const sends = input.sends ?? callRequeueSends(input.record) + 1;
|
|
267
|
+
if (
|
|
268
|
+
callRetry?.maximumAttempts !== undefined &&
|
|
269
|
+
sends >= callRetry.maximumAttempts
|
|
270
|
+
) {
|
|
271
|
+
return { kind: 'exhaust', reason: 'maximum_attempts' };
|
|
272
|
+
}
|
|
273
|
+
if (!rule.park.enabled) return { kind: 'exhaust', reason: 'park_disabled' };
|
|
274
|
+
const isRead = input.effect === 'read';
|
|
275
|
+
const writes = rule.eligibility.writes;
|
|
276
|
+
const eligible = isRead
|
|
277
|
+
? rule.eligibility.reads
|
|
278
|
+
: writes === 'all' ||
|
|
279
|
+
((writes === 'idempotency_key' || writes === 'idempotent_write') &&
|
|
280
|
+
input.idempotencyKeyHonored) ||
|
|
281
|
+
(writes === 'idempotent_write' &&
|
|
282
|
+
input.writeIdempotency === 'idempotent_write');
|
|
283
|
+
if (!eligible) return { kind: 'exhaust', reason: 'not_eligible' };
|
|
284
|
+
|
|
285
|
+
const prior = input.record;
|
|
286
|
+
// Only a call being retried (or never parked) can park. A record in any
|
|
287
|
+
// other state means another invocation owns it: fail normally rather than
|
|
288
|
+
// replace the Play's error with an illegal-transition error.
|
|
289
|
+
if (prior && prior.state !== 'in_call') {
|
|
290
|
+
return { kind: 'exhaust', reason: 'not_in_call' };
|
|
291
|
+
}
|
|
292
|
+
// A call is judged only on its own history (as a Temporal activity is):
|
|
293
|
+
// other rows or calls succeeding never reset it or extend its window.
|
|
294
|
+
const sameClass = prior?.errorClass === input.errorClass;
|
|
295
|
+
const consecutive = sameClass ? (prior?.consecutive ?? 0) + 1 : 1;
|
|
296
|
+
const limit = rule.park.consecutiveFailureLimit;
|
|
297
|
+
if (limit !== null && consecutive > limit) {
|
|
298
|
+
return { kind: 'exhaust', reason: 'consecutive_limit' };
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
const parks = prior?.parks ?? 0;
|
|
302
|
+
// The gateway accepts at most this many parks for a fenced call; stop
|
|
303
|
+
// before a resend it would refuse, whatever the live policy allows.
|
|
304
|
+
if (
|
|
305
|
+
input.fenced === true &&
|
|
306
|
+
parks + 1 > EXECUTION_GATEWAY_MAX_REQUEUE_PARKS
|
|
307
|
+
) {
|
|
308
|
+
return { kind: 'exhaust', reason: 'park_limit' };
|
|
309
|
+
}
|
|
310
|
+
const ladder = rule.park.ladderMs;
|
|
311
|
+
const base =
|
|
312
|
+
callRetryIntervalMs(callRetry, parks, ladder) ??
|
|
313
|
+
ladder[Math.min(parks, ladder.length - 1)]!;
|
|
314
|
+
const jitter = rule.inCall.jitterRatio;
|
|
315
|
+
const waitMs = Math.max(
|
|
316
|
+
1_000,
|
|
317
|
+
Math.round(base * (1 + ((input.random ?? Math.random)() * 2 - 1) * jitter)),
|
|
318
|
+
);
|
|
319
|
+
const retryAtMs = input.nowMs + waitMs;
|
|
320
|
+
const firstParkAtMs = prior?.firstParkAtMs ?? input.nowMs;
|
|
321
|
+
|
|
322
|
+
// The window starts at the call's first park and grows on a fixed
|
|
323
|
+
// schedule (12 h, then 18 h, then 24 h by default): each extension is
|
|
324
|
+
// entered when the next wait would pass the current end.
|
|
325
|
+
let extensionsUsed = prior?.extensionsUsed ?? 0;
|
|
326
|
+
const windowEnd = () =>
|
|
327
|
+
firstParkAtMs +
|
|
328
|
+
rule.window.initialMs +
|
|
329
|
+
rule.window.extensionsMs
|
|
330
|
+
.slice(0, extensionsUsed)
|
|
331
|
+
.reduce((sum, step) => sum + step, 0);
|
|
332
|
+
while (
|
|
333
|
+
retryAtMs > windowEnd() &&
|
|
334
|
+
extensionsUsed < rule.window.extensionsMs.length
|
|
335
|
+
) {
|
|
336
|
+
extensionsUsed += 1;
|
|
337
|
+
}
|
|
338
|
+
if (retryAtMs > windowEnd()) return { kind: 'exhaust', reason: 'window' };
|
|
339
|
+
|
|
340
|
+
const transition = BILLING_ERROR_CLASSES.has(input.errorClass)
|
|
341
|
+
? ('wait_for_billing' as const)
|
|
342
|
+
: ('park' as const);
|
|
343
|
+
const record = transitionCallRequeue(
|
|
344
|
+
prior ?? transitionCallRequeue(undefined, 'start', input.nowMs)!,
|
|
345
|
+
transition,
|
|
346
|
+
input.nowMs,
|
|
347
|
+
{
|
|
348
|
+
errorClass: input.errorClass,
|
|
349
|
+
policySequence: input.snapshot.sequence,
|
|
350
|
+
parks: parks + 1,
|
|
351
|
+
sends,
|
|
352
|
+
consecutive,
|
|
353
|
+
firstParkAtMs,
|
|
354
|
+
retryAtMs,
|
|
355
|
+
extensionsUsed,
|
|
356
|
+
// A never_sent refusal wrote no outcome for its attempt, so the resume
|
|
357
|
+
// reuses that attempt; every other class resumes after it.
|
|
358
|
+
requeueFromInvocationAttempt:
|
|
359
|
+
input.failedInvocationAttempt === undefined
|
|
360
|
+
? null
|
|
361
|
+
: input.errorClass === 'never_sent'
|
|
362
|
+
? input.failedInvocationAttempt
|
|
363
|
+
: input.failedInvocationAttempt + 1,
|
|
364
|
+
},
|
|
365
|
+
)!;
|
|
366
|
+
return { kind: 'park', transition, retryAtMs, waitMs, record };
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
/** Requests the provider received for a call before this burst. */
|
|
370
|
+
export function callRequeueSends(
|
|
371
|
+
record: CallRequeueRecord | undefined,
|
|
372
|
+
): number {
|
|
373
|
+
if (!record) return 0;
|
|
374
|
+
return record.sends ?? record.parks;
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
/**
|
|
378
|
+
* The wait before retry `parks + 1` under a call's own interval fields, or
|
|
379
|
+
* null when it sets none (the class ladder applies). Unset fields take the
|
|
380
|
+
* ladder's first step, a coefficient of 2, and the ladder's longest step.
|
|
381
|
+
*/
|
|
382
|
+
export function callRetryIntervalMs(
|
|
383
|
+
callRetry: PlayToolCallRetryPolicy | undefined,
|
|
384
|
+
parks: number,
|
|
385
|
+
ladder: readonly number[],
|
|
386
|
+
): number | null {
|
|
387
|
+
if (
|
|
388
|
+
!callRetry ||
|
|
389
|
+
(callRetry.initialIntervalMs === undefined &&
|
|
390
|
+
callRetry.backoffCoefficient === undefined &&
|
|
391
|
+
callRetry.maximumIntervalMs === undefined)
|
|
392
|
+
) {
|
|
393
|
+
return null;
|
|
394
|
+
}
|
|
395
|
+
const initial = callRetry.initialIntervalMs ?? ladder[0]!;
|
|
396
|
+
const coefficient = callRetry.backoffCoefficient ?? 2;
|
|
397
|
+
const maximum = Math.max(
|
|
398
|
+
initial,
|
|
399
|
+
callRetry.maximumIntervalMs ?? Math.max(...ladder),
|
|
400
|
+
);
|
|
401
|
+
return Math.min(maximum, Math.round(initial * coefficient ** parks));
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
/**
|
|
405
|
+
* A generic HTTP request's write class by method: GET (the default), HEAD,
|
|
406
|
+
* PUT and DELETE are idempotent; POST and anything else is not. The one
|
|
407
|
+
* definition; `@deepline/integrations/write-idempotency` re-exports it.
|
|
408
|
+
*/
|
|
409
|
+
export function genericHttpWriteIdempotency(
|
|
410
|
+
method: unknown,
|
|
411
|
+
): 'idempotent_write' | 'non_idempotent_write' {
|
|
412
|
+
const normalized =
|
|
413
|
+
typeof method === 'string' ? method.trim().toUpperCase() : 'GET';
|
|
414
|
+
return normalized === 'GET' ||
|
|
415
|
+
normalized === 'HEAD' ||
|
|
416
|
+
normalized === 'PUT' ||
|
|
417
|
+
normalized === 'DELETE'
|
|
418
|
+
? 'idempotent_write'
|
|
419
|
+
: 'non_idempotent_write';
|
|
420
|
+
}
|