deepline 0.3.526 → 0.3.528
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundling-sources/sdk/src/release.ts +1 -1
- package/dist/bundling-sources/shared_libs/play-runtime/context.ts +141 -211
- package/dist/bundling-sources/shared_libs/play-runtime/ctx-types.ts +5 -0
- package/dist/bundling-sources/shared_libs/play-runtime/deployment/fly-machines.ts +66 -1
- package/dist/bundling-sources/shared_libs/play-runtime/freshness-receipt-execution.ts +135 -161
- package/dist/bundling-sources/shared_libs/play-runtime/play-run-recovery-policy.ts +56 -1
- package/dist/bundling-sources/shared_libs/play-runtime/play-runs/sandbox-cleanup/contracts.ts +11 -1
- package/dist/bundling-sources/shared_libs/play-runtime/play-runs/sandbox-cleanup/job.ts +36 -6
- package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-lifecycle.ts +59 -8
- package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-start-admission.ts +12 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona.ts +1 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/types.ts +16 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-capacity-policy.ts +25 -5
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-telemetry.ts +6 -0
- package/dist/bundling-sources/shared_libs/play-runtime/sandbox-runs/runner-backend-adapter.ts +6 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-claim-loop-timing.ts +145 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-pool.ts +48 -5
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-runtime-worker.ts +316 -71
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-shared.ts +13 -5
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/play-run-recovery.ts +30 -1
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres.ts +105 -13
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-sandbox-capacity.ts +12 -0
- package/dist/bundling-sources/shared_libs/play-runtime/tool-call/result-receipt-policy.ts +10 -1
- package/dist/bundling-sources/shared_libs/play-runtime/tool-execute-retry-policy.ts +50 -8
- package/dist/cli/auth-CWJZYLTB.js +43 -0
- package/dist/cli/{auth-JATW5XZE.mjs → auth-PPOTNK4T.mjs} +5 -5
- package/dist/cli/{billing-TSHBJIJS.js → billing-3C7T7CUQ.js} +79 -79
- package/dist/cli/{billing-UT5LIESH.mjs → billing-OEZUQ2K6.mjs} +6 -6
- package/dist/cli/{chunk-UWCEBS7F.js → chunk-237PKFIQ.js} +14 -14
- package/dist/cli/{chunk-TBQC2XS3.js → chunk-36UD7H7Y.js} +41 -41
- package/dist/cli/{chunk-26ULNPQ7.mjs → chunk-42ZSDTOC.mjs} +2 -2
- package/dist/cli/{chunk-O7WUATQC.js → chunk-4SBUXDKZ.js} +13 -13
- package/dist/cli/{chunk-SCLRGDF4.js → chunk-5MJ4CDAQ.js} +44 -44
- package/dist/cli/{chunk-BFH3DJYV.mjs → chunk-6OLQWQU5.mjs} +3 -3
- package/dist/cli/{chunk-UTCGCES2.js → chunk-7WZXUAQW.js} +7 -7
- package/dist/cli/{chunk-CYN2AHR6.js → chunk-7X3NLHI7.js} +6 -6
- package/dist/cli/{chunk-D5OEUPPM.js → chunk-ADZGTMLU.js} +98 -98
- package/dist/cli/{chunk-6COGHW7B.mjs → chunk-AFIAVG5T.mjs} +2 -2
- package/dist/cli/{chunk-BYEF4RBX.js → chunk-B3HQF2CA.js} +11 -11
- package/dist/cli/{chunk-DY2AT3JQ.mjs → chunk-B6YWCGVC.mjs} +10 -10
- package/dist/cli/{chunk-BVITYMBK.mjs → chunk-CMTY6SVY.mjs} +2 -2
- package/dist/cli/{chunk-WOLY6SU4.mjs → chunk-DCVNL5XN.mjs} +1 -1
- package/dist/cli/{chunk-6JMWATX5.mjs → chunk-FPHAUP55.mjs} +5 -5
- package/dist/cli/{chunk-7COEN3IR.js → chunk-FXYWEKUK.js} +4 -4
- package/dist/cli/{chunk-J5OXJ4JI.js → chunk-G7RTPKRJ.js} +2 -2
- package/dist/cli/{chunk-RZJWHL7L.js → chunk-GCBFSFLA.js} +5 -5
- package/dist/cli/{chunk-C3EW6I65.mjs → chunk-GFGFAAY2.mjs} +1 -1
- package/dist/cli/{chunk-XVIMOB2U.mjs → chunk-GP7E4TE4.mjs} +2 -2
- package/dist/cli/{chunk-HPACLONQ.mjs → chunk-GSBKODMU.mjs} +2 -2
- package/dist/cli/{chunk-EEYZLTXX.mjs → chunk-HJVNCRXY.mjs} +1 -1
- package/dist/cli/{chunk-WITNIMLE.js → chunk-IJAEYEJM.js} +3 -3
- package/dist/cli/{chunk-YNFPZVII.mjs → chunk-IM5XQ4DG.mjs} +5 -5
- package/dist/cli/{chunk-46HEYGLY.js → chunk-IXEEXYE2.js} +9 -9
- package/dist/cli/{chunk-MQB25LMV.mjs → chunk-IYCRX34W.mjs} +5 -5
- package/dist/cli/{chunk-6H56LKJB.js → chunk-KHVCHFE3.js} +16 -16
- package/dist/cli/{chunk-TVHDWS5U.mjs → chunk-KLGYBOGZ.mjs} +1 -1
- package/dist/cli/{chunk-UUIC2JFZ.mjs → chunk-KWIKFR7Y.mjs} +1 -1
- package/dist/cli/{chunk-ED2N4NRI.js → chunk-LT4IEJ6V.js} +16 -16
- package/dist/cli/{chunk-WBY3R55B.js → chunk-LU4EA3ET.js} +2 -2
- package/dist/cli/{chunk-477PXM65.js → chunk-MLNH4DK2.js} +22 -22
- package/dist/cli/{chunk-77RAGJIZ.mjs → chunk-NCOTOGTK.mjs} +2 -2
- package/dist/cli/{chunk-IMP7WR22.mjs → chunk-NZM4KWWV.mjs} +5 -5
- package/dist/cli/{chunk-B33J4YCC.js → chunk-OEI7YUEF.js} +3 -3
- package/dist/cli/{chunk-3MYI3IXW.js → chunk-OGVUT2KM.js} +7 -7
- package/dist/cli/{chunk-SJ6KUCGM.js → chunk-OVZSNBDJ.js} +53 -53
- package/dist/cli/{chunk-D2XMFXFM.mjs → chunk-PS2UYVAE.mjs} +6 -6
- package/dist/cli/{chunk-3ZEV5BS5.js → chunk-R5ZQVQ3K.js} +26 -26
- package/dist/cli/{chunk-TCLJXJAG.mjs → chunk-RC5CG5SE.mjs} +4 -4
- package/dist/cli/{chunk-6DHEV6IA.js → chunk-RFTBMEWL.js} +2 -2
- package/dist/cli/{chunk-2GJW4RAQ.mjs → chunk-RML3VSTN.mjs} +1 -1
- package/dist/cli/{chunk-2JNX3MDG.mjs → chunk-SP2KZ7SH.mjs} +1 -1
- package/dist/cli/{chunk-IWLDJQGV.mjs → chunk-T4QPRL3P.mjs} +3 -3
- package/dist/cli/{chunk-Y47OCS5V.mjs → chunk-ULUI2FEM.mjs} +1 -1
- package/dist/cli/{chunk-FMPGWAIR.js → chunk-WXHBD6H7.js} +1 -1
- package/dist/cli/{chunk-CDP3LMDT.js → chunk-XD2DRBPH.js} +6 -6
- package/dist/cli/{chunk-TXJW6RIM.mjs → chunk-Z25KC5V2.mjs} +1 -1
- package/dist/cli/{chunk-U6OUX47C.mjs → chunk-Z44S7VWO.mjs} +2 -2
- package/dist/cli/{chunk-F5KFGF45.js → chunk-ZFD5FJCZ.js} +5 -5
- package/dist/cli/{csv-4BLFRED6.mjs → csv-K7TRWOFJ.mjs} +4 -4
- package/dist/cli/{csv-KSJB5Z3M.js → csv-OTRVTHD2.js} +13 -13
- package/dist/cli/{db-OVW6C3DV.mjs → db-C7GQU3TZ.mjs} +6 -6
- package/dist/cli/{db-G7Z5CKO2.js → db-UO2ZFLFN.js} +27 -27
- package/dist/cli/describe-IK4UYJ5M.js +50 -0
- package/dist/cli/{describe-OEFTD7WQ.mjs → describe-LG4CPTIV.mjs} +18 -18
- package/dist/cli/{executions-O7USCBCW.js → executions-LHFVPO7E.js} +8 -8
- package/dist/cli/{executions-7ZKQ4ZU3.mjs → executions-P3INNVZE.mjs} +6 -6
- package/dist/cli/{feedback-KUBL5E3I.mjs → feedback-H22FWG63.mjs} +6 -6
- package/dist/cli/{feedback-Y55WCRIQ.js → feedback-M3HZQAWX.js} +14 -14
- package/dist/cli/git-72ADWRUQ.js +25 -0
- package/dist/cli/{git-C6ZAU5JA.mjs → git-G2N7PVFI.mjs} +5 -5
- package/dist/cli/index.js +141 -141
- package/dist/cli/index.mjs +43 -43
- package/dist/cli/{legacy-noops-OVWX4KB3.js → legacy-noops-2RVROWBY.js} +9 -9
- package/dist/cli/{legacy-noops-MUXD4HRC.mjs → legacy-noops-LDYSWTL2.mjs} +6 -6
- package/dist/cli/{monitors-2ZSGBY52.mjs → monitors-IYT3VON7.mjs} +7 -7
- package/dist/cli/{monitors-3QVYGYWA.js → monitors-U4RE6KN5.js} +100 -100
- package/dist/cli/{org-RDSPE5FB.mjs → org-R3JE22GS.mjs} +6 -6
- package/dist/cli/{org-S6Z3SDLI.js → org-SO52ZGRP.js} +86 -86
- package/dist/cli/{pages-K5DSMHLJ.mjs → pages-5RLT5YTF.mjs} +6 -6
- package/dist/cli/{pages-VUWF2OR7.js → pages-SWXJQJXH.js} +18 -18
- package/dist/cli/{play-PZLXOYEX.mjs → play-2ELYCSXZ.mjs} +18 -18
- package/dist/cli/{play-SQOJTUFC.js → play-J4UXOQOJ.js} +317 -317
- package/dist/cli/{providers-AMIGP3D4.mjs → providers-IXITXHTS.mjs} +6 -6
- package/dist/cli/{providers-FZBEPUOI.js → providers-VVUDGV2D.js} +9 -9
- package/dist/cli/{quickstart-HNOQKGOF.mjs → quickstart-HQCGDPPL.mjs} +4 -4
- package/dist/cli/{quickstart-QIHZDBGM.js → quickstart-XPH6MT47.js} +6 -6
- package/dist/cli/{run-JDW6BDNT.mjs → run-H2HQPWC4.mjs} +23 -23
- package/dist/cli/{run-IQGM3TO2.js → run-OR646AC6.js} +41 -41
- package/dist/cli/search-D27DZH2D.js +33 -0
- package/dist/cli/{search-DMVUKJ23.mjs → search-MBPI5SBW.mjs} +8 -8
- package/dist/cli/{search-output-5UAPUUHH.mjs → search-output-CYOMJNRV.mjs} +4 -4
- package/dist/cli/{search-output-UUW6UNHF.js → search-output-YGNSHBXX.js} +6 -6
- package/dist/cli/{secrets-U532KN24.js → secrets-HVZKNNLZ.js} +15 -15
- package/dist/cli/{secrets-46KSTPFN.mjs → secrets-NK2CN7WI.mjs} +6 -6
- package/dist/cli/sessions-MTISSOZ4.js +22 -0
- package/dist/cli/{sessions-RUNWYHYX.mjs → sessions-NY4G427U.mjs} +6 -6
- package/dist/cli/{settings-O2A37FFA.js → settings-PVJRDEN2.js} +86 -86
- package/dist/cli/{settings-56L3WHCY.mjs → settings-RC4FGYY2.mjs} +13 -13
- package/dist/cli/{setup-ETFSMSCH.js → setup-B7QB4YV2.js} +50 -50
- package/dist/cli/{setup-Q27X6JZY.mjs → setup-YT3XSY6X.mjs} +10 -10
- package/dist/cli/{skills-WFQRZL4D.mjs → skills-5ILFNAHR.mjs} +8 -8
- package/dist/cli/skills-BHF35NLX.js +37 -0
- package/dist/cli/{tools-EV6CKJOX.mjs → tools-7PAY32OZ.mjs} +17 -17
- package/dist/cli/tools-W5BZ37L6.js +57 -0
- package/dist/cli/update-M65CGK42.js +35 -0
- package/dist/cli/{update-KIPPFVCH.mjs → update-Z27QYB6O.mjs} +10 -10
- package/dist/cli/{views-LMJXWD4N.mjs → views-2IANF6KR.mjs} +6 -6
- package/dist/cli/{views-DNZ2HFTA.js → views-NP2SCMOV.js} +18 -18
- package/dist/cli/{workflow-ZUDTIOK6.js → workflow-2GNQL646.js} +17 -17
- package/dist/cli/{workflow-3XKUQ73U.mjs → workflow-CAMEZLLY.mjs} +7 -7
- package/dist/index.js +9 -9
- package/dist/index.mjs +6 -6
- package/dist/install-integrity.json +105 -104
- package/dist/release.d.mts +1 -1
- package/dist/release.d.ts +1 -1
- package/dist/release.js +2 -2
- package/dist/release.mjs +1 -1
- package/dist/server.js +5 -5
- package/dist/server.mjs +3 -3
- package/package.json +1 -1
- package/dist/cli/auth-L2POG3LL.js +0 -43
- package/dist/cli/describe-KMYR2JBC.js +0 -50
- package/dist/cli/git-NBVQ3VGW.js +0 -25
- package/dist/cli/search-BNWRL3YY.js +0 -33
- package/dist/cli/sessions-JZUONXH4.js +0 -22
- package/dist/cli/skills-IKDJ5JDN.js +0 -37
- package/dist/cli/tools-B735AA67.js +0 -57
- package/dist/cli/update-CNNURAM3.js +0 -35
|
@@ -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.528',
|
|
209
209
|
updateSummary: {
|
|
210
210
|
introducedIn: '0.3.90',
|
|
211
211
|
summary:
|
|
@@ -293,9 +293,9 @@ import {
|
|
|
293
293
|
completedCallForResult,
|
|
294
294
|
type DeferredReceiptPublication,
|
|
295
295
|
executeWithFreshnessReceipt,
|
|
296
|
+
type FreshExecutionReplay,
|
|
296
297
|
latestCacheResultKey,
|
|
297
298
|
latestCacheResultOutput,
|
|
298
|
-
type LegacySlotSearch,
|
|
299
299
|
type ReplayRefusal,
|
|
300
300
|
parseLatestCacheResult,
|
|
301
301
|
type ReplayMismatchPolicy,
|
|
@@ -657,12 +657,11 @@ function recordReplayCallAdvance(key: string, advance: number): void {
|
|
|
657
657
|
}
|
|
658
658
|
}
|
|
659
659
|
|
|
660
|
-
/**
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
const LEGACY_SLOT_SEARCH_LOOKAHEAD = 16;
|
|
660
|
+
/** Memoizes a lazy computation. */
|
|
661
|
+
function once<T>(compute: () => Promise<T>): () => Promise<T> {
|
|
662
|
+
let computed: Promise<T> | null = null;
|
|
663
|
+
return () => (computed ??= compute());
|
|
664
|
+
}
|
|
666
665
|
|
|
667
666
|
function nextReplayableCallIndex(key: string, freshIndex: number): number {
|
|
668
667
|
const indexes = rowContext.getStore()?.replayCallIndexes;
|
|
@@ -3185,33 +3184,8 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
|
|
|
3185
3184
|
inputFingerprint: string;
|
|
3186
3185
|
/** The invocation id itself is numbered among identical requests. */
|
|
3187
3186
|
keyEncodesRequest?: true;
|
|
3188
|
-
/**
|
|
3189
|
-
|
|
3190
|
-
}
|
|
3191
|
-
>();
|
|
3192
|
-
/**
|
|
3193
|
-
* Per call-order scope, for receipts recorded before bindings: whether each
|
|
3194
|
-
* slot read in this attempt held an unbound receipt, and which slots a call
|
|
3195
|
-
* has already proven and taken.
|
|
3196
|
-
*/
|
|
3197
|
-
private readonly legacySlotVerdicts = new Map<
|
|
3198
|
-
string,
|
|
3199
|
-
(unbound: boolean) => void
|
|
3200
|
-
>();
|
|
3201
|
-
private readonly legacySlotScopes = new Map<
|
|
3202
|
-
string,
|
|
3203
|
-
{
|
|
3204
|
-
/** Verdicts of slots allocated but not yet read, by index. */
|
|
3205
|
-
pending: Map<number, Promise<boolean>>;
|
|
3206
|
-
/** A slot of this scope held an unbound receipt in this attempt. */
|
|
3207
|
-
anyUnbound: boolean;
|
|
3208
|
-
/**
|
|
3209
|
-
* Slots taken by a proven pre-binding recovery, with the invocation
|
|
3210
|
-
* that took them. The same invocation may take its slot again (a row
|
|
3211
|
-
* re-entered after provider backpressure restores its call index);
|
|
3212
|
-
* a sibling may not.
|
|
3213
|
-
*/
|
|
3214
|
-
consumed: Map<number, string>;
|
|
3187
|
+
/** A tool call's call-order slot, for the legacy empty-slot guard. */
|
|
3188
|
+
callOrderSlot?: { scope: string; index: number };
|
|
3215
3189
|
}
|
|
3216
3190
|
>();
|
|
3217
3191
|
/** Authored calls whose unverified recovery was already reported. */
|
|
@@ -4323,14 +4297,10 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
|
|
|
4323
4297
|
this.exactRequestInvocationIds.set(callOrder.id, {
|
|
4324
4298
|
exactRequestInvocationId: slot(exactRequestScope).id,
|
|
4325
4299
|
inputFingerprint: requestDigest,
|
|
4326
|
-
// Only tools record request identities a slot search can prove.
|
|
4327
4300
|
...(operation === 'tool'
|
|
4328
|
-
? {
|
|
4301
|
+
? { callOrderSlot: { scope: callOrderScope, index: callOrder.index } }
|
|
4329
4302
|
: {}),
|
|
4330
4303
|
});
|
|
4331
|
-
if (operation === 'tool') {
|
|
4332
|
-
this.registerLegacySlot(callOrder.id, callOrderScope, callOrder.index);
|
|
4333
|
-
}
|
|
4334
4304
|
}
|
|
4335
4305
|
return callOrder.id;
|
|
4336
4306
|
}
|
|
@@ -4376,106 +4346,6 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
|
|
|
4376
4346
|
* in. Only receipts proven by a recorded request identity are taken, each
|
|
4377
4347
|
* at most once per attempt.
|
|
4378
4348
|
*/
|
|
4379
|
-
/**
|
|
4380
|
-
* Registered when the slot is allocated, in allocation order, so a later
|
|
4381
|
-
* sibling can wait for this slot's verdict. Settled by the freshness layer
|
|
4382
|
-
* once the slot is read, or by `settleLegacySlot` when the call ends first.
|
|
4383
|
-
* A scope without unbound receipts is dropped once its slots settle, so
|
|
4384
|
-
* runs without pre-binding receipts keep no state here.
|
|
4385
|
-
*/
|
|
4386
|
-
private registerLegacySlot(
|
|
4387
|
-
invocationId: string,
|
|
4388
|
-
scopeKey: string,
|
|
4389
|
-
index: number,
|
|
4390
|
-
): void {
|
|
4391
|
-
// A re-entered row reuses its slot; release the earlier registration.
|
|
4392
|
-
this.settleLegacySlot(invocationId, { keepSlotEntry: true });
|
|
4393
|
-
let scope = this.legacySlotScopes.get(scopeKey);
|
|
4394
|
-
if (!scope) {
|
|
4395
|
-
scope = { pending: new Map(), anyUnbound: false, consumed: new Map() };
|
|
4396
|
-
this.legacySlotScopes.set(scopeKey, scope);
|
|
4397
|
-
}
|
|
4398
|
-
const state = scope;
|
|
4399
|
-
let resolve!: (unbound: boolean) => void;
|
|
4400
|
-
const verdict: Promise<boolean> = new Promise<boolean>(
|
|
4401
|
-
(settle) => (resolve = settle),
|
|
4402
|
-
).then((unbound) => {
|
|
4403
|
-
if (unbound) state.anyUnbound = true;
|
|
4404
|
-
if (state.pending.get(index) === verdict) state.pending.delete(index);
|
|
4405
|
-
if (
|
|
4406
|
-
state.pending.size === 0 &&
|
|
4407
|
-
!state.anyUnbound &&
|
|
4408
|
-
state.consumed.size === 0 &&
|
|
4409
|
-
this.legacySlotScopes.get(scopeKey) === state
|
|
4410
|
-
) {
|
|
4411
|
-
this.legacySlotScopes.delete(scopeKey);
|
|
4412
|
-
}
|
|
4413
|
-
return unbound;
|
|
4414
|
-
});
|
|
4415
|
-
state.pending.set(index, verdict);
|
|
4416
|
-
this.legacySlotVerdicts.set(invocationId, resolve);
|
|
4417
|
-
}
|
|
4418
|
-
|
|
4419
|
-
/** The call ended (or never reached the freshness layer): release waiters. */
|
|
4420
|
-
private settleLegacySlot(
|
|
4421
|
-
invocationId: string,
|
|
4422
|
-
options?: { keepSlotEntry: true },
|
|
4423
|
-
): void {
|
|
4424
|
-
this.legacySlotVerdicts.get(invocationId)?.(false);
|
|
4425
|
-
this.legacySlotVerdicts.delete(invocationId);
|
|
4426
|
-
if (!options?.keepSlotEntry) {
|
|
4427
|
-
this.exactRequestInvocationIds.delete(invocationId);
|
|
4428
|
-
}
|
|
4429
|
-
}
|
|
4430
|
-
|
|
4431
|
-
private legacySlotSearch(
|
|
4432
|
-
invocationId: string,
|
|
4433
|
-
slot: { scope: string; index: number },
|
|
4434
|
-
): LegacySlotSearch {
|
|
4435
|
-
const scope = this.legacySlotScopes.get(slot.scope)!;
|
|
4436
|
-
const verdict = this.legacySlotVerdicts.get(invocationId);
|
|
4437
|
-
return {
|
|
4438
|
-
ownIndex: slot.index,
|
|
4439
|
-
reportOwnSlot: (unbound) => verdict?.(unbound),
|
|
4440
|
-
priorSlotsUnbound: async () => {
|
|
4441
|
-
await Promise.all(
|
|
4442
|
-
[...scope.pending]
|
|
4443
|
-
.filter(([index]) => index < slot.index)
|
|
4444
|
-
.map(([, observed]) => observed),
|
|
4445
|
-
);
|
|
4446
|
-
return scope.anyUnbound;
|
|
4447
|
-
},
|
|
4448
|
-
candidates: () => {
|
|
4449
|
-
const candidates: Array<{ index: number; invocationId: string }> = [];
|
|
4450
|
-
const allocated = Math.max(
|
|
4451
|
-
this.freshnessCallIndexByKey.get(slot.scope) ?? 0,
|
|
4452
|
-
slot.index + 1,
|
|
4453
|
-
);
|
|
4454
|
-
const end = allocated + LEGACY_SLOT_SEARCH_LOOKAHEAD;
|
|
4455
|
-
for (let index = 0; index < end; index += 1) {
|
|
4456
|
-
const claimant = scope.consumed.get(index);
|
|
4457
|
-
if (
|
|
4458
|
-
index === slot.index ||
|
|
4459
|
-
(claimant !== undefined && claimant !== invocationId)
|
|
4460
|
-
) {
|
|
4461
|
-
continue;
|
|
4462
|
-
}
|
|
4463
|
-
candidates.push({
|
|
4464
|
-
index,
|
|
4465
|
-
invocationId: sha256Hex(`${slot.scope}:${index}`),
|
|
4466
|
-
});
|
|
4467
|
-
}
|
|
4468
|
-
return candidates;
|
|
4469
|
-
},
|
|
4470
|
-
consume: (index) => {
|
|
4471
|
-
const claimant = scope.consumed.get(index);
|
|
4472
|
-
if (claimant !== undefined && claimant !== invocationId) return false;
|
|
4473
|
-
scope.consumed.set(index, invocationId);
|
|
4474
|
-
return true;
|
|
4475
|
-
},
|
|
4476
|
-
};
|
|
4477
|
-
}
|
|
4478
|
-
|
|
4479
4349
|
/**
|
|
4480
4350
|
* One structured line per replay refusal, emitted where the refusal is
|
|
4481
4351
|
* decided, so a Play that catches the error cannot hide it. Rate-limited
|
|
@@ -4535,7 +4405,10 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
|
|
|
4535
4405
|
semanticKey: string;
|
|
4536
4406
|
invocationId: string;
|
|
4537
4407
|
policy: { requested: number | null; effective: number | null };
|
|
4538
|
-
execute: (
|
|
4408
|
+
execute: (
|
|
4409
|
+
publication: DeferredReceiptPublication,
|
|
4410
|
+
replay?: FreshExecutionReplay,
|
|
4411
|
+
) => Promise<T>;
|
|
4539
4412
|
completedAt?: (value: T) => number | undefined;
|
|
4540
4413
|
sharesResult?: (value: T) => boolean;
|
|
4541
4414
|
eligibleAnswer?: (value: T) => boolean;
|
|
@@ -4549,7 +4422,7 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
|
|
|
4549
4422
|
*/
|
|
4550
4423
|
replayMismatchPolicy?: () => Promise<ReplayMismatchPolicy>;
|
|
4551
4424
|
/** See `executeWithFreshnessReceipt`. */
|
|
4552
|
-
legacyRequestIdentities?: () => Promise<readonly string[]>;
|
|
4425
|
+
legacyRequestIdentities?: () => Promise<readonly string[] | null>;
|
|
4553
4426
|
operationKeyEncodesRequest?: true;
|
|
4554
4427
|
}): Promise<T> {
|
|
4555
4428
|
const orgId = this.#options.orgId?.trim();
|
|
@@ -4560,7 +4433,7 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
|
|
|
4560
4433
|
}
|
|
4561
4434
|
const slots = this.exactRequestInvocationIds.get(input.invocationId);
|
|
4562
4435
|
this.exactRequestInvocationIds.delete(input.invocationId);
|
|
4563
|
-
return executeWithFreshnessReceipt({
|
|
4436
|
+
return await executeWithFreshnessReceipt({
|
|
4564
4437
|
orgId,
|
|
4565
4438
|
semanticKey: input.semanticKey,
|
|
4566
4439
|
invocationId: input.invocationId,
|
|
@@ -4574,15 +4447,6 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
|
|
|
4574
4447
|
...(input.legacyRequestIdentities
|
|
4575
4448
|
? { legacyRequestIdentities: input.legacyRequestIdentities }
|
|
4576
4449
|
: {}),
|
|
4577
|
-
...(slots?.legacySlot &&
|
|
4578
|
-
this.legacySlotScopes.has(slots.legacySlot.scope)
|
|
4579
|
-
? {
|
|
4580
|
-
legacySlotSearch: this.legacySlotSearch(
|
|
4581
|
-
input.invocationId,
|
|
4582
|
-
slots.legacySlot,
|
|
4583
|
-
),
|
|
4584
|
-
}
|
|
4585
|
-
: {}),
|
|
4586
4450
|
...(input.replayMismatchPolicy
|
|
4587
4451
|
? { replayMismatchPolicy: input.replayMismatchPolicy }
|
|
4588
4452
|
: {}),
|
|
@@ -4591,6 +4455,9 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
|
|
|
4591
4455
|
onLegacyRecoveryProven: () =>
|
|
4592
4456
|
this.reportLegacyOperationRecovery(input.operation, input.id),
|
|
4593
4457
|
onRefusal: (refusal) => this.reportReplayRefusal(refusal),
|
|
4458
|
+
...(slots?.callOrderSlot
|
|
4459
|
+
? { callOrdinal: slots.callOrderSlot.index }
|
|
4460
|
+
: {}),
|
|
4594
4461
|
runId: this.currentReceiptOwnerRunId,
|
|
4595
4462
|
receiptOwnerRunId: this.currentReceiptOwnerRunId,
|
|
4596
4463
|
// Launches admitted without run-scoped keys wrote this operation under
|
|
@@ -4621,8 +4488,8 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
|
|
|
4621
4488
|
),
|
|
4622
4489
|
{ ...options, source: 'durable_operation' },
|
|
4623
4490
|
),
|
|
4624
|
-
execute: async (publication) => {
|
|
4625
|
-
const value = await input.execute(publication);
|
|
4491
|
+
execute: async (publication, replay) => {
|
|
4492
|
+
const value = await input.execute(publication, replay);
|
|
4626
4493
|
this.assertNoPendingDurableSuspension();
|
|
4627
4494
|
return value;
|
|
4628
4495
|
},
|
|
@@ -7993,6 +7860,7 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
|
|
|
7993
7860
|
runId: this.currentReceiptOwnerRunId,
|
|
7994
7861
|
logicalCallId: request.logicalCallId,
|
|
7995
7862
|
force: request.force === true,
|
|
7863
|
+
...(request.occurrenceBound ? { occurrenceBound: true } : {}),
|
|
7996
7864
|
});
|
|
7997
7865
|
}
|
|
7998
7866
|
|
|
@@ -14983,27 +14851,6 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
|
|
|
14983
14851
|
toolId: string,
|
|
14984
14852
|
input: Record<string, unknown>,
|
|
14985
14853
|
options?: ToolCallOptions,
|
|
14986
|
-
): Promise<unknown> {
|
|
14987
|
-
let invocationId: string | null = null;
|
|
14988
|
-
try {
|
|
14989
|
-
return await this.executeToolInternalWithSlot(
|
|
14990
|
-
key,
|
|
14991
|
-
toolId,
|
|
14992
|
-
input,
|
|
14993
|
-
options,
|
|
14994
|
-
(allocated) => (invocationId = allocated),
|
|
14995
|
-
);
|
|
14996
|
-
} finally {
|
|
14997
|
-
if (invocationId) this.settleLegacySlot(invocationId);
|
|
14998
|
-
}
|
|
14999
|
-
}
|
|
15000
|
-
|
|
15001
|
-
private async executeToolInternalWithSlot(
|
|
15002
|
-
key: string,
|
|
15003
|
-
toolId: string,
|
|
15004
|
-
input: Record<string, unknown>,
|
|
15005
|
-
options: ToolCallOptions | undefined,
|
|
15006
|
-
onSlotAllocated: (invocationId: string) => void,
|
|
15007
14854
|
): Promise<unknown> {
|
|
15008
14855
|
if (!this.usesExplicitFreshness) {
|
|
15009
14856
|
return this.executeToolLegacyInternal(key, toolId, input, options);
|
|
@@ -15031,7 +14878,28 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
|
|
|
15031
14878
|
normalizedKey,
|
|
15032
14879
|
this.callSlotRequestDigest({ toolId, input }),
|
|
15033
14880
|
);
|
|
15034
|
-
|
|
14881
|
+
// Reserve the call's occurrence among identical requests now, in the same
|
|
14882
|
+
// order as its operation slot, whether the call later recovers or
|
|
14883
|
+
// executes. Otherwise a recovered occurrence would not advance it, and the
|
|
14884
|
+
// next identical occurrence would take the recovered one's logical
|
|
14885
|
+
// identity and its forced result receipt instead of executing. SQL
|
|
14886
|
+
// requests carry their own operation key, so they never repeat.
|
|
14887
|
+
const reservedCallIndexKey = isCustomerDbDatasetTool(toolId)
|
|
14888
|
+
? undefined
|
|
14889
|
+
: this.toolCallIndexKey(normalizedKey, toolId, input);
|
|
14890
|
+
const reservedCallIndex =
|
|
14891
|
+
reservedCallIndexKey === undefined
|
|
14892
|
+
? undefined
|
|
14893
|
+
: this.nextToolCallIndex(reservedCallIndexKey);
|
|
14894
|
+
/**
|
|
14895
|
+
* A call that may not reuse the tool layer's pre-binding result receipts
|
|
14896
|
+
* (its own slot held a pre-binding record it could not reuse) dispatches
|
|
14897
|
+
* under this identity instead: deterministic from its operation slot, so a
|
|
14898
|
+
* later replay of the same call reuses its new receipt rather than
|
|
14899
|
+
* sending again.
|
|
14900
|
+
*/
|
|
14901
|
+
const freshLogicalCallId = () =>
|
|
14902
|
+
stableDigest(`replay-fresh:${invocationId}`);
|
|
15035
14903
|
const sqlTool = isCustomerDbDatasetTool(toolId);
|
|
15036
14904
|
const scalarCustomerDbQuery = sqlTool && input.result_mode === 'rows';
|
|
15037
14905
|
const liveDataset =
|
|
@@ -15111,7 +14979,7 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
|
|
|
15111
14979
|
* scope, action version and the run's cache epoch. They prove an unbound
|
|
15112
14980
|
* recorded operation is this call's.
|
|
15113
14981
|
*/
|
|
15114
|
-
const
|
|
14982
|
+
const legacyIdentities =
|
|
15115
14983
|
(staleAfterSeconds: number | null | undefined) => async () => {
|
|
15116
14984
|
const identity = {
|
|
15117
14985
|
toolId,
|
|
@@ -15123,11 +14991,24 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
|
|
|
15123
14991
|
staleAfterSeconds,
|
|
15124
14992
|
}).staleAfterSeconds,
|
|
15125
14993
|
};
|
|
15126
|
-
const [keys, legacy] = await Promise.all([
|
|
14994
|
+
const [keys, legacy, idempotencyScope, eventWait] = await Promise.all([
|
|
15127
14995
|
this.compatibleDurableToolCallCacheKeys(identity),
|
|
15128
14996
|
this.legacyDurableToolCallCacheKey(identity),
|
|
14997
|
+
this.#options.getToolIdempotencyScope?.(toolId),
|
|
14998
|
+
this.#options.getIntegrationEventWaitHandler?.(toolId),
|
|
15129
14999
|
]);
|
|
15130
|
-
|
|
15000
|
+
// An invocation-scoped tool recorded its keys scoped by an old
|
|
15001
|
+
// logical call whose numbering cannot be reconstructed: nothing it
|
|
15002
|
+
// retained can prove or disprove this request.
|
|
15003
|
+
if (!eventWait && idempotencyScope === 'invocation') return null;
|
|
15004
|
+
const cacheKeys = legacy ? [...keys, legacy] : keys;
|
|
15005
|
+
// Request identity only (input, credential scope, action revision,
|
|
15006
|
+
// policy, run cache epoch). A build before bindings numbered identical
|
|
15007
|
+
// requests in tool-layer entry order, so no key it recorded proves
|
|
15008
|
+
// WHICH identical occurrence it was; the call-order slot is the only
|
|
15009
|
+
// occurrence evidence. SQL requests also carry their slot's runtime
|
|
15010
|
+
// operation key.
|
|
15011
|
+
return cacheKeys;
|
|
15131
15012
|
};
|
|
15132
15013
|
|
|
15133
15014
|
if (
|
|
@@ -15145,13 +15026,18 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
|
|
|
15145
15026
|
semanticKey,
|
|
15146
15027
|
invocationId,
|
|
15147
15028
|
policy: { requested: policy.requested, effective: 0 },
|
|
15148
|
-
legacyRequestIdentities:
|
|
15149
|
-
execute: async () =>
|
|
15150
|
-
await this.executeToolLegacyInternal(
|
|
15151
|
-
|
|
15152
|
-
|
|
15153
|
-
|
|
15154
|
-
|
|
15029
|
+
legacyRequestIdentities: once(legacyIdentities(0)),
|
|
15030
|
+
execute: async (_publication, replay) =>
|
|
15031
|
+
await this.executeToolLegacyInternal(
|
|
15032
|
+
key,
|
|
15033
|
+
toolId,
|
|
15034
|
+
requestInput,
|
|
15035
|
+
{ ...options, force: true, staleAfterSeconds: 0 },
|
|
15036
|
+
false,
|
|
15037
|
+
undefined,
|
|
15038
|
+
reservedCallIndex,
|
|
15039
|
+
replay?.freshInvocation ? freshLogicalCallId() : undefined,
|
|
15040
|
+
),
|
|
15155
15041
|
});
|
|
15156
15042
|
}
|
|
15157
15043
|
|
|
@@ -15163,6 +15049,9 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
|
|
|
15163
15049
|
toolId,
|
|
15164
15050
|
requestInput,
|
|
15165
15051
|
{ ...options, force: true, staleAfterSeconds: 0 },
|
|
15052
|
+
false,
|
|
15053
|
+
undefined,
|
|
15054
|
+
reservedCallIndex,
|
|
15166
15055
|
);
|
|
15167
15056
|
const freshness: CallFreshnessMetadata = {
|
|
15168
15057
|
requestedStaleAfterSeconds: policy.requested,
|
|
@@ -15190,8 +15079,8 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
|
|
|
15190
15079
|
policy,
|
|
15191
15080
|
toolId,
|
|
15192
15081
|
replayMismatchPolicy: () => this.toolReplayMismatchPolicy(toolId, input),
|
|
15193
|
-
legacyRequestIdentities:
|
|
15194
|
-
options?.staleAfterSeconds,
|
|
15082
|
+
legacyRequestIdentities: once(
|
|
15083
|
+
legacyIdentities(options?.staleAfterSeconds),
|
|
15195
15084
|
),
|
|
15196
15085
|
...(publishLatestOnRefresh
|
|
15197
15086
|
? { publishLatestOnRefresh: true as const }
|
|
@@ -15209,7 +15098,7 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
|
|
|
15209
15098
|
},
|
|
15210
15099
|
sharesResult: isCompletedSuccessfulAnswer,
|
|
15211
15100
|
eligibleAnswer: isCompletedSuccessfulAnswer,
|
|
15212
|
-
execute: async (publication) => {
|
|
15101
|
+
execute: async (publication, replay) => {
|
|
15213
15102
|
// The freshness layer is the only reuse authority here. The legacy
|
|
15214
15103
|
// durable call cache below it would otherwise hand back an earlier
|
|
15215
15104
|
// completed-but-ineligible answer (a pending or empty result) that the
|
|
@@ -15221,6 +15110,8 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
|
|
|
15221
15110
|
{ ...options, force: true },
|
|
15222
15111
|
true,
|
|
15223
15112
|
publication,
|
|
15113
|
+
reservedCallIndex,
|
|
15114
|
+
replay?.freshInvocation ? freshLogicalCallId() : undefined,
|
|
15224
15115
|
);
|
|
15225
15116
|
if ((await this.resolveToolAuthScopeDigest(toolId)) !== authScope) {
|
|
15226
15117
|
throw new Error(
|
|
@@ -15321,6 +15212,46 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
|
|
|
15321
15212
|
});
|
|
15322
15213
|
}
|
|
15323
15214
|
|
|
15215
|
+
/** The occurrence counter key of a tool request in its row/workflow scope. */
|
|
15216
|
+
private toolCallIndexKey(
|
|
15217
|
+
normalizedKey: string,
|
|
15218
|
+
toolId: string,
|
|
15219
|
+
input: Record<string, unknown>,
|
|
15220
|
+
): string {
|
|
15221
|
+
const toolRequestIdentity = deriveToolRequestIdentity({
|
|
15222
|
+
toolId,
|
|
15223
|
+
requestInput: input,
|
|
15224
|
+
});
|
|
15225
|
+
const store = rowContext.getStore();
|
|
15226
|
+
const logicalCallScope = store
|
|
15227
|
+
? [
|
|
15228
|
+
'row',
|
|
15229
|
+
store.tableNamespace?.trim() || 'map',
|
|
15230
|
+
store.rowKey?.trim() || String(store.rowId),
|
|
15231
|
+
store.fieldName?.trim() || 'field',
|
|
15232
|
+
].join(':')
|
|
15233
|
+
: 'workflow';
|
|
15234
|
+
return `${this.currentExecutionScope.receipt.namespace}:${logicalCallScope}:${normalizedKey}:${toolRequestIdentity}`;
|
|
15235
|
+
}
|
|
15236
|
+
|
|
15237
|
+
/**
|
|
15238
|
+
* Next occurrence of an identical tool request. It names the call's
|
|
15239
|
+
* logical identity (forced result receipt, provider operation key). A held
|
|
15240
|
+
* row re-entered after backpressure restores its recorded positions.
|
|
15241
|
+
*/
|
|
15242
|
+
private nextToolCallIndex(callIndexKey: string): number {
|
|
15243
|
+
const freshCallIndex = this.toolCallIndexByKey.get(callIndexKey) ?? 0;
|
|
15244
|
+
const callIndex = nextReplayableCallIndex(
|
|
15245
|
+
`tool:${callIndexKey}`,
|
|
15246
|
+
freshCallIndex,
|
|
15247
|
+
);
|
|
15248
|
+
this.toolCallIndexByKey.set(
|
|
15249
|
+
callIndexKey,
|
|
15250
|
+
Math.max(freshCallIndex, callIndex + 1),
|
|
15251
|
+
);
|
|
15252
|
+
return callIndex;
|
|
15253
|
+
}
|
|
15254
|
+
|
|
15324
15255
|
private async executeToolLegacyInternal(
|
|
15325
15256
|
key: string,
|
|
15326
15257
|
toolId: string,
|
|
@@ -15332,6 +15263,17 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
|
|
|
15332
15263
|
* its own finishing writes, before the call returns to customer code.
|
|
15333
15264
|
*/
|
|
15334
15265
|
publication?: DeferredReceiptPublication,
|
|
15266
|
+
/**
|
|
15267
|
+
* This call's occurrence among identical requests, reserved by the
|
|
15268
|
+
* edition-11 caller when it allocated the call's operation slot. See
|
|
15269
|
+
* `reserveToolCallIndex`.
|
|
15270
|
+
*/
|
|
15271
|
+
reservedCallIndex?: number,
|
|
15272
|
+
/**
|
|
15273
|
+
* Replaces the call's logical identity (and with it the forced result
|
|
15274
|
+
* receipt and provider operation key) for a fresh dispatch.
|
|
15275
|
+
*/
|
|
15276
|
+
logicalCallIdOverride?: string,
|
|
15335
15277
|
): Promise<unknown> {
|
|
15336
15278
|
if (!rowContext.getStore()) this.assertRowAdmissionOpen();
|
|
15337
15279
|
this.assertNoPendingDurableSuspension();
|
|
@@ -15368,30 +15310,16 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
|
|
|
15368
15310
|
? this.materializeToolExecutionResult(result)
|
|
15369
15311
|
: result;
|
|
15370
15312
|
const toolCachePolicy = this.effectiveToolCallCachePolicy(options);
|
|
15371
|
-
const toolRequestIdentity = deriveToolRequestIdentity({
|
|
15372
|
-
toolId,
|
|
15373
|
-
requestInput: input,
|
|
15374
|
-
});
|
|
15375
15313
|
const store = rowContext.getStore();
|
|
15376
|
-
const
|
|
15377
|
-
|
|
15378
|
-
|
|
15379
|
-
|
|
15380
|
-
|
|
15381
|
-
|
|
15382
|
-
|
|
15383
|
-
|
|
15384
|
-
|
|
15385
|
-
const freshCallIndex = this.toolCallIndexByKey.get(callIndexKey) ?? 0;
|
|
15386
|
-
const callIndex = nextReplayableCallIndex(
|
|
15387
|
-
`tool:${callIndexKey}`,
|
|
15388
|
-
freshCallIndex,
|
|
15389
|
-
);
|
|
15390
|
-
this.toolCallIndexByKey.set(
|
|
15391
|
-
callIndexKey,
|
|
15392
|
-
Math.max(freshCallIndex, callIndex + 1),
|
|
15393
|
-
);
|
|
15394
|
-
const logicalCallId = stableDigest(`${callIndexKey}:${callIndex}`);
|
|
15314
|
+
const callIndexKey = this.toolCallIndexKey(normalizedKey, toolId, input);
|
|
15315
|
+
const callIndex =
|
|
15316
|
+
reservedCallIndex ?? this.nextToolCallIndex(callIndexKey);
|
|
15317
|
+
const logicalCallId =
|
|
15318
|
+
logicalCallIdOverride ?? stableDigest(`${callIndexKey}:${callIndex}`);
|
|
15319
|
+
// Reserved with its operation slot (or a fresh replay identity): its forced
|
|
15320
|
+
// result receipt is keyed in the reserved namespace, never the older one.
|
|
15321
|
+
const occurrenceBound =
|
|
15322
|
+
reservedCallIndex !== undefined || logicalCallIdOverride !== undefined;
|
|
15395
15323
|
this.resourceGovernor.recordLogicalToolCall();
|
|
15396
15324
|
let executionAuthScopeDigest =
|
|
15397
15325
|
(await this.resolveToolAuthScopeDigest(toolId))?.trim() ?? null;
|
|
@@ -15812,6 +15740,7 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
|
|
|
15812
15740
|
logicalCallId,
|
|
15813
15741
|
force: toolCachePolicy.force,
|
|
15814
15742
|
canStoreResult: this.durableDirectToolResultsBackedByReceipts,
|
|
15743
|
+
...(occurrenceBound ? { occurrenceBound: true } : {}),
|
|
15815
15744
|
});
|
|
15816
15745
|
const toolRetryPolicy = await this.#options
|
|
15817
15746
|
.getToolRetryPolicy?.(toolId, input)
|
|
@@ -16167,6 +16096,7 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
|
|
|
16167
16096
|
const dispatchRequest: ToolCallRequest = {
|
|
16168
16097
|
callId,
|
|
16169
16098
|
logicalCallId,
|
|
16099
|
+
...(occurrenceBound ? { occurrenceBound: true as const } : {}),
|
|
16170
16100
|
cacheKey: toolResultCacheKey,
|
|
16171
16101
|
providerIdempotencyKeyBase,
|
|
16172
16102
|
providerActionVersion,
|
|
@@ -91,6 +91,11 @@ export interface ToolCallRequest {
|
|
|
91
91
|
* result cache and the author-supplied call id.
|
|
92
92
|
*/
|
|
93
93
|
logicalCallId?: string;
|
|
94
|
+
/**
|
|
95
|
+
* The logical call's occurrence index was reserved with its operation slot;
|
|
96
|
+
* its forced result receipt lives in the reserved namespace.
|
|
97
|
+
*/
|
|
98
|
+
occurrenceBound?: true;
|
|
94
99
|
cacheKey: string;
|
|
95
100
|
/** Stable external-operation identity, independent of receipt serialization. */
|
|
96
101
|
providerIdempotencyKeyBase?: string | null;
|
|
@@ -75,6 +75,11 @@ export const SOURCE_IMAGE_METADATA_KEY = 'deepline_source_image';
|
|
|
75
75
|
export const ROLLBACK_HOLD_UNTIL_METADATA_KEY = 'rollback_hold_until_ms';
|
|
76
76
|
export const RUNTIME_DEPLOY_VERSION_ENV = 'DEEPLINE_RUNTIME_DEPLOY_VERSION';
|
|
77
77
|
export const DRAIN_EXIT_ENV = 'DEEPLINE_ABSURD_DRAIN_EXIT';
|
|
78
|
+
/** Fly's `worker_alive` check grace period on a booted worker Machine. The
|
|
79
|
+
* scaler treats a Machine started within it, whose check has not passed or
|
|
80
|
+
* failed yet, as capacity still booting. */
|
|
81
|
+
export const ABSURD_WORKER_ALIVE_GRACE_PERIOD_SECONDS = 30;
|
|
82
|
+
|
|
78
83
|
// This is an image compatibility contract, not the current source location.
|
|
79
84
|
// Historical images only have this path; new images retain it as a thin entrypoint
|
|
80
85
|
// so both old and new scalers can boot, drain, or recover either generation.
|
|
@@ -622,7 +627,7 @@ export function buildBootMachineConfig(input: {
|
|
|
622
627
|
path: '/healthz',
|
|
623
628
|
interval: '15s',
|
|
624
629
|
timeout: '5s',
|
|
625
|
-
grace_period:
|
|
630
|
+
grace_period: `${ABSURD_WORKER_ALIVE_GRACE_PERIOD_SECONDS}s`,
|
|
626
631
|
},
|
|
627
632
|
},
|
|
628
633
|
guest: {
|
|
@@ -730,6 +735,66 @@ export function buildRollbackHoldUpdateConfig(
|
|
|
730
735
|
};
|
|
731
736
|
}
|
|
732
737
|
|
|
738
|
+
const FLY_DURATION_UNIT_MS: Record<string, number> = {
|
|
739
|
+
h: 3_600_000,
|
|
740
|
+
m: 60_000,
|
|
741
|
+
s: 1_000,
|
|
742
|
+
ms: 1,
|
|
743
|
+
us: 0.001,
|
|
744
|
+
µs: 0.001,
|
|
745
|
+
ns: 0.000_001,
|
|
746
|
+
};
|
|
747
|
+
|
|
748
|
+
/** A Fly (Go) duration such as "300s", "5m0s" or "1h2m3.5s" in milliseconds;
|
|
749
|
+
* null when the value is not one. Fly echoes "300s" back as "5m0s". */
|
|
750
|
+
export function parseFlyDurationMs(value: unknown): number | null {
|
|
751
|
+
if (typeof value !== 'string') return null;
|
|
752
|
+
const text = value.trim();
|
|
753
|
+
if (!/^(?:\d+(?:\.\d+)?(?:h|ms|m|s|us|µs|ns))+$/.test(text)) return null;
|
|
754
|
+
let totalMs = 0;
|
|
755
|
+
for (const [, amount, unit] of text.matchAll(
|
|
756
|
+
/(\d+(?:\.\d+)?)(h|ms|m|s|us|µs|ns)/g,
|
|
757
|
+
)) {
|
|
758
|
+
totalMs += Number(amount) * FLY_DURATION_UNIT_MS[unit!]!;
|
|
759
|
+
}
|
|
760
|
+
return totalMs;
|
|
761
|
+
}
|
|
762
|
+
|
|
763
|
+
export type WorkerSlotCapUpdateReason =
|
|
764
|
+
| 'config_unreadable'
|
|
765
|
+
| 'exec_differs'
|
|
766
|
+
| 'stop_signal_differs'
|
|
767
|
+
| 'stop_timeout_differs';
|
|
768
|
+
|
|
769
|
+
/**
|
|
770
|
+
* Why `buildWorkerSlotCapUpdateConfig` would change this Machine, or null
|
|
771
|
+
* when its exec and stop config already match what the update writes. A
|
|
772
|
+
* config that cannot be read counts as different, so it is still updated.
|
|
773
|
+
*/
|
|
774
|
+
export function workerSlotCapUpdateReason(
|
|
775
|
+
machine: FlyMachine,
|
|
776
|
+
): WorkerSlotCapUpdateReason | null {
|
|
777
|
+
const exec = machine.config?.init?.exec;
|
|
778
|
+
const stop = machine.config?.stop_config;
|
|
779
|
+
const timeoutMs = parseFlyDurationMs(stop?.timeout);
|
|
780
|
+
if (!Array.isArray(exec) || !stop?.signal || timeoutMs === null) {
|
|
781
|
+
return 'config_unreadable';
|
|
782
|
+
}
|
|
783
|
+
if (
|
|
784
|
+
exec.length !== ABSURD_RUNTIME_WORKER_EXEC.length ||
|
|
785
|
+
exec.some((value, index) => value !== ABSURD_RUNTIME_WORKER_EXEC[index])
|
|
786
|
+
) {
|
|
787
|
+
return 'exec_differs';
|
|
788
|
+
}
|
|
789
|
+
if (stop.signal !== DEFAULT_LANE_REPLACEMENT_STOP_SIGNAL) {
|
|
790
|
+
return 'stop_signal_differs';
|
|
791
|
+
}
|
|
792
|
+
if (timeoutMs !== parseFlyDurationMs(DEFAULT_LANE_REPLACEMENT_STOP_TIMEOUT)) {
|
|
793
|
+
return 'stop_timeout_differs';
|
|
794
|
+
}
|
|
795
|
+
return null;
|
|
796
|
+
}
|
|
797
|
+
|
|
733
798
|
export function buildWorkerSlotCapUpdateConfig(machine: FlyMachine): {
|
|
734
799
|
config: Record<string, unknown>;
|
|
735
800
|
skip_launch?: boolean;
|