deepline 0.3.502 → 0.3.504

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.
Files changed (211) hide show
  1. package/dist/bundling-sources/sdk/src/client-core.ts +26 -0
  2. package/dist/bundling-sources/sdk/src/index.ts +1 -0
  3. package/dist/bundling-sources/sdk/src/release.ts +1 -1
  4. package/dist/bundling-sources/sdk/src/types.ts +9 -0
  5. package/dist/bundling-sources/shared_libs/monitors/http-error-response.ts +35 -0
  6. package/dist/bundling-sources/shared_libs/monitors/provider-monitor-batch-operation.ts +1 -1
  7. package/dist/bundling-sources/shared_libs/monitors/provider-monitor-public-aliases.ts +13 -0
  8. package/dist/bundling-sources/shared_libs/monitors/starter-templates.ts +0 -8
  9. package/dist/bundling-sources/shared_libs/observability/dlq.ts +174 -0
  10. package/dist/bundling-sources/shared_libs/observability/queue-health.ts +9 -0
  11. package/dist/bundling-sources/shared_libs/observability/queue-item-connectors.ts +1 -0
  12. package/dist/bundling-sources/shared_libs/observability/scheduled-jobs.json +18 -0
  13. package/dist/bundling-sources/shared_libs/play-runtime/activity-observation.ts +20 -0
  14. package/dist/bundling-sources/shared_libs/play-runtime/app-runtime-api.ts +62 -2
  15. package/dist/bundling-sources/shared_libs/play-runtime/context.ts +667 -62
  16. package/dist/bundling-sources/shared_libs/play-runtime/ctx-types.ts +55 -0
  17. package/dist/bundling-sources/shared_libs/play-runtime/durable-receipt-execution.ts +20 -2
  18. package/dist/bundling-sources/shared_libs/play-runtime/durable-runs-rollout.ts +46 -0
  19. package/dist/bundling-sources/shared_libs/play-runtime/execution-gateway-invocation-fence.ts +80 -4
  20. package/dist/bundling-sources/shared_libs/play-runtime/fixture-egress-fetch.ts +95 -0
  21. package/dist/bundling-sources/shared_libs/play-runtime/freshness-receipt-execution.ts +292 -45
  22. package/dist/bundling-sources/shared_libs/play-runtime/internal-bootstrap-token.ts +15 -0
  23. package/dist/bundling-sources/shared_libs/play-runtime/launch-identity.ts +3 -0
  24. package/dist/bundling-sources/shared_libs/play-runtime/play-http-request.ts +7 -3
  25. package/dist/bundling-sources/shared_libs/play-runtime/play-runtime-semantics.ts +31 -1
  26. package/dist/bundling-sources/shared_libs/play-runtime/post-code-recovery-policy.ts +231 -0
  27. package/dist/bundling-sources/shared_libs/play-runtime/protocol.ts +4 -0
  28. package/dist/bundling-sources/shared_libs/play-runtime/run-ending-event.ts +55 -0
  29. package/dist/bundling-sources/shared_libs/play-runtime/run-ledger.ts +126 -0
  30. package/dist/bundling-sources/shared_libs/play-runtime/runner-app/index.ts +38 -1
  31. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-launch-transport.ts +2 -9
  32. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-lifecycle.ts +51 -19
  33. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/local-process.ts +9 -4
  34. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/modal.ts +2 -0
  35. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/runtime-sandbox-reconciliation.ts +2 -0
  36. package/dist/bundling-sources/shared_libs/play-runtime/runtime-actions.ts +12 -1
  37. package/dist/bundling-sources/shared_libs/play-runtime/runtime-authority.ts +3 -0
  38. package/dist/bundling-sources/shared_libs/play-runtime/runtime-incident-drills.ts +42 -0
  39. package/dist/bundling-sources/shared_libs/play-runtime/runtime-operation-contract.ts +7 -0
  40. package/dist/bundling-sources/shared_libs/play-runtime/runtime-receipt-store-adapter.ts +26 -1
  41. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backend.ts +13 -0
  42. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-deadline-reconciliation.ts +53 -0
  43. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-runtime-worker.ts +631 -19
  44. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/durable-run-inventory.ts +719 -0
  45. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/durable-run-sql.ts +206 -0
  46. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/latest-cache-result.ts +83 -0
  47. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres.ts +1432 -157
  48. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/receipt-gateway.ts +61 -0
  49. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-event-search.ts +29 -8
  50. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-queue-health.ts +27 -2
  51. package/dist/bundling-sources/shared_libs/play-runtime/test-runtime-seams.ts +45 -0
  52. package/dist/bundling-sources/shared_libs/play-runtime/tool-cache-policy.ts +18 -0
  53. package/dist/bundling-sources/shared_libs/play-runtime/tool-execute-retry-policy.ts +129 -14
  54. package/dist/bundling-sources/shared_libs/play-runtime/workflow-executor-auth.ts +2 -0
  55. package/dist/bundling-sources/shared_libs/plays/authoring-contract.ts +10 -1
  56. package/dist/cli/{auth-EFHLOVG4.mjs → auth-3L5AA5AX.mjs} +5 -5
  57. package/dist/cli/auth-UPK4IIIN.js +43 -0
  58. package/dist/cli/{billing-Q5XKEYPP.mjs → billing-E7EASVPO.mjs} +19 -12
  59. package/dist/cli/{billing-SKT2VE34.js → billing-HOGXVE2V.js} +92 -85
  60. package/dist/cli/{chunk-L5CTJY74.mjs → chunk-22OCKCYS.mjs} +2 -2
  61. package/dist/cli/{chunk-YWOQYYYS.mjs → chunk-2ABRDH3B.mjs} +2 -2
  62. package/dist/cli/{chunk-IL666WJE.js → chunk-2W77YCKH.js} +5 -5
  63. package/dist/cli/{chunk-2MVIS2UI.mjs → chunk-3MLFFWDM.mjs} +2 -2
  64. package/dist/cli/{chunk-HMZF2CSP.mjs → chunk-4CC67XH5.mjs} +2 -2
  65. package/dist/cli/{chunk-NXVYLX3F.mjs → chunk-5CHBIJIM.mjs} +10 -6
  66. package/dist/cli/chunk-5LUF4LAR.mjs +209 -0
  67. package/dist/cli/{chunk-JL6H4H3G.js → chunk-5Z6EULD5.js} +6 -6
  68. package/dist/cli/{chunk-32YQBJON.js → chunk-67OI26OE.js} +7 -7
  69. package/dist/cli/{chunk-LA3UYRVZ.js → chunk-6JNBMTCZ.js} +1 -1
  70. package/dist/cli/{chunk-DYHTXGLX.js → chunk-6SMR7LU7.js} +2 -2
  71. package/dist/cli/{chunk-OFBLT2LQ.mjs → chunk-7F4OEHQK.mjs} +1 -1
  72. package/dist/cli/{chunk-DRBD4IYQ.mjs → chunk-7MJYZ33I.mjs} +2 -6
  73. package/dist/cli/{chunk-UOANF3DR.js → chunk-7P2QVMBP.js} +26 -7
  74. package/dist/cli/{chunk-GINKIZ7S.js → chunk-A6LA42JY.js} +16 -16
  75. package/dist/cli/{chunk-FVM4PS5Q.js → chunk-BN5VKY4X.js} +25 -12
  76. package/dist/cli/{chunk-Z2H7OQ6E.mjs → chunk-BTWUNKKX.mjs} +2 -2
  77. package/dist/cli/{chunk-R5F7JXT4.mjs → chunk-BX45XMXZ.mjs} +2 -2
  78. package/dist/cli/{chunk-NKLM4J4X.mjs → chunk-DEAJVQEG.mjs} +1 -1
  79. package/dist/cli/{chunk-JFBJLNBI.js → chunk-FISP4LCK.js} +53 -53
  80. package/dist/cli/{chunk-OEUMXKR5.js → chunk-FTRVCIGC.js} +26 -26
  81. package/dist/cli/{chunk-YL2CCF6T.mjs → chunk-GGBXNQCR.mjs} +4 -4
  82. package/dist/cli/{chunk-YPTZJ7LO.js → chunk-GJ2DA35C.js} +100 -17
  83. package/dist/cli/{chunk-2S2F6YSI.js → chunk-GRAGUYIE.js} +41 -41
  84. package/dist/cli/{chunk-2JS3H6H6.mjs → chunk-HUX5DZO6.mjs} +3 -3
  85. package/dist/cli/{chunk-4CCMD7QM.mjs → chunk-IGNQKOWT.mjs} +32 -15
  86. package/dist/cli/{chunk-WKFAX2K7.js → chunk-IPAMOMGP.js} +21 -21
  87. package/dist/cli/{chunk-SAW3FBCA.mjs → chunk-ITJ7NB2D.mjs} +6 -0
  88. package/dist/cli/{chunk-Q3NM6ZL3.js → chunk-JPR2546F.js} +23 -21
  89. package/dist/cli/{chunk-X5MGQ7UT.js → chunk-KCKAFTPY.js} +10 -10
  90. package/dist/cli/{chunk-TAK3MVXY.js → chunk-KGUGNEKL.js} +284 -267
  91. package/dist/cli/{chunk-OVZOMSH2.js → chunk-LHXYCZYO.js} +8 -8
  92. package/dist/cli/{chunk-QOJBRCAS.js → chunk-MJTK6Q3G.js} +3 -3
  93. package/dist/cli/{chunk-MYUISF3P.mjs → chunk-MLMWM5DV.mjs} +5 -5
  94. package/dist/cli/{chunk-JO5FFSR7.js → chunk-NTLBZUHD.js} +6 -0
  95. package/dist/cli/{chunk-MP5QY4A2.mjs → chunk-NZ7Z7WNM.mjs} +2 -2
  96. package/dist/cli/{chunk-HIVRCTDR.mjs → chunk-OX2D6BG4.mjs} +20 -1
  97. package/dist/cli/{chunk-YDXEXVBV.js → chunk-QKKU2FH4.js} +7 -7
  98. package/dist/cli/{chunk-3KEZVGGV.mjs → chunk-QOLX2O2S.mjs} +4 -4
  99. package/dist/cli/{chunk-JFUXUSKB.mjs → chunk-R2VZVHJP.mjs} +15 -2
  100. package/dist/cli/chunk-R7J7CJPZ.js +209 -0
  101. package/dist/cli/{chunk-XMKUJ44Z.js → chunk-SMSQVRHE.js} +5 -5
  102. package/dist/cli/{chunk-54QXWK3C.mjs → chunk-SVFTZTCI.mjs} +1 -1
  103. package/dist/cli/{chunk-FWDAEWCD.js → chunk-TMQUMILM.js} +19 -23
  104. package/dist/cli/{chunk-TFFJ2PRN.mjs → chunk-UFYJTRSF.mjs} +98 -15
  105. package/dist/cli/{chunk-EUWRKWT4.js → chunk-UJMBG5JU.js} +5 -4
  106. package/dist/cli/{chunk-DKAMCJIT.js → chunk-USTJEEND.js} +17 -13
  107. package/dist/cli/{chunk-AJL2Q6IQ.js → chunk-UXQQPMYO.js} +2 -2
  108. package/dist/cli/{chunk-7ZYSXSJJ.mjs → chunk-VJVJWZ6I.mjs} +5 -5
  109. package/dist/cli/{chunk-JLYDLK6X.js → chunk-WBIDPDKJ.js} +3 -3
  110. package/dist/cli/{chunk-QNELA7SX.js → chunk-WZSFIJMG.js} +53 -53
  111. package/dist/cli/{chunk-NZXB27TP.mjs → chunk-XHZSPMNC.mjs} +4 -4
  112. package/dist/cli/{chunk-W5CHE5Q2.mjs → chunk-Y6XKCEPK.mjs} +1 -1
  113. package/dist/cli/{chunk-4WTC5SSN.mjs → chunk-Y7VEHKID.mjs} +10 -8
  114. package/dist/cli/{chunk-3MJSWVQ2.mjs → chunk-YOQ2NNDO.mjs} +2 -1
  115. package/dist/cli/{chunk-ZNB6GR3P.mjs → chunk-Z6FXUDIL.mjs} +1 -1
  116. package/dist/cli/command-docs.d.mts +2 -1
  117. package/dist/cli/command-docs.d.ts +2 -1
  118. package/dist/cli/command-docs.js +6 -2
  119. package/dist/cli/command-docs.mjs +5 -1
  120. package/dist/cli/{csv-OXGSCV75.js → csv-2XWGPITO.js} +13 -13
  121. package/dist/cli/{csv-6AEPKKCO.mjs → csv-433JEHLQ.mjs} +4 -4
  122. package/dist/cli/{db-K3KRK4CZ.mjs → db-K747DH43.mjs} +6 -6
  123. package/dist/cli/{db-6NVHDUZY.js → db-PJJMD4VH.js} +27 -27
  124. package/dist/cli/describe-OYS7LZJD.js +49 -0
  125. package/dist/cli/{describe-P3ZJS7TQ.mjs → describe-VEDDYW4P.mjs} +20 -20
  126. package/dist/cli/describe-core.d.mts +8 -4
  127. package/dist/cli/describe-core.d.ts +8 -4
  128. package/dist/cli/describe-core.js +4 -4
  129. package/dist/cli/describe-core.mjs +3 -3
  130. package/dist/cli/{executions-2C2FFG52.js → executions-HM5T72H6.js} +8 -8
  131. package/dist/cli/{executions-I7XW6WWK.mjs → executions-JWRX3XCT.mjs} +6 -6
  132. package/dist/cli/{feedback-47B57A5Y.js → feedback-34UG4BO3.js} +8 -8
  133. package/dist/cli/{feedback-RSTNBJAI.mjs → feedback-MNSIA63Y.mjs} +4 -4
  134. package/dist/cli/git-5YQJSJFR.js +25 -0
  135. package/dist/cli/{git-3G5AFKBT.mjs → git-ZKEOXV3A.mjs} +5 -5
  136. package/dist/cli/index.js +144 -142
  137. package/dist/cli/index.mjs +44 -42
  138. package/dist/cli/{legacy-noops-NQ262TKL.mjs → legacy-noops-5M4T4ZVT.mjs} +5 -5
  139. package/dist/cli/{legacy-noops-P665PBG4.js → legacy-noops-YXSI4FVU.js} +8 -8
  140. package/dist/cli/{monitors-KUPZODZS.mjs → monitors-C65OC4AW.mjs} +7 -7
  141. package/dist/cli/{monitors-IPWAD7LS.js → monitors-O25GDOYE.js} +95 -95
  142. package/dist/cli/{org-WFC3N672.js → org-2GSPLY2A.js} +72 -72
  143. package/dist/cli/{org-ZCQGEM3L.mjs → org-ZRMG5NS2.mjs} +6 -6
  144. package/dist/cli/{pages-N5BNC67L.js → pages-45DPADK6.js} +18 -18
  145. package/dist/cli/{pages-VE66IU7B.mjs → pages-TZZUFBRO.mjs} +6 -6
  146. package/dist/cli/{play-EIMDIAJB.mjs → play-3D7HH273.mjs} +138 -226
  147. package/dist/cli/{play-NKIRJSKX.js → play-RCGMND6X.js} +454 -542
  148. package/dist/cli/{providers-XU3AGY2F.js → providers-3N3ECMTY.js} +9 -9
  149. package/dist/cli/{providers-KDTJ63ED.mjs → providers-PSAKV6CJ.mjs} +6 -6
  150. package/dist/cli/{quickstart-TXFXUODF.mjs → quickstart-2A35SMGC.mjs} +4 -4
  151. package/dist/cli/{quickstart-OSCHOSXU.js → quickstart-6R6AIXM6.js} +6 -6
  152. package/dist/cli/{run-ODGML35U.mjs → run-F3TLDGUO.mjs} +25 -25
  153. package/dist/cli/{run-ET2KVTPK.js → run-F6ZXTASZ.js} +44 -44
  154. package/dist/cli/{search-DK67K6PR.mjs → search-CZLCY3D2.mjs} +7 -7
  155. package/dist/cli/search-R5VEWJO2.js +32 -0
  156. package/dist/cli/{search-output-6SOKQTCW.mjs → search-output-MQTSTLN5.mjs} +5 -5
  157. package/dist/cli/{search-output-KXP4FA62.js → search-output-R5XDNILW.js} +7 -7
  158. package/dist/cli/{secrets-C6SYTMU7.mjs → secrets-D3GF4B2Z.mjs} +6 -6
  159. package/dist/cli/{secrets-WPS6NMNK.js → secrets-DCJYHDSY.js} +15 -15
  160. package/dist/cli/{sessions-PXVOH34X.mjs → sessions-QGEQ2UYZ.mjs} +5 -5
  161. package/dist/cli/{sessions-IP562J5Z.js → sessions-Z4JYJSDP.js} +6 -6
  162. package/dist/cli/{settings-FBUQGYVJ.mjs → settings-G7QEXA4N.mjs} +11 -11
  163. package/dist/cli/{settings-SUDUIVMY.js → settings-UVXXAT4A.js} +78 -78
  164. package/dist/cli/{setup-I5H6IOEY.js → setup-5I42W7D4.js} +49 -49
  165. package/dist/cli/{setup-JSIMTR73.mjs → setup-QHJU3DUI.mjs} +9 -9
  166. package/dist/cli/{skills-FJQ3LX6N.mjs → skills-5LRF4UKX.mjs} +7 -7
  167. package/dist/cli/skills-FB6TV52O.js +36 -0
  168. package/dist/cli/tools-L2364RPA.js +56 -0
  169. package/dist/cli/{tools-IGBK4BVE.mjs → tools-PUT6STVG.mjs} +18 -18
  170. package/dist/cli/{update-7MTT6F5K.mjs → update-CJ2GA64X.mjs} +9 -9
  171. package/dist/cli/update-ESYJGYVZ.js +34 -0
  172. package/dist/cli/{workflow-PM2J2OU3.mjs → workflow-HVEWRTXD.mjs} +7 -7
  173. package/dist/cli/{workflow-UX3ZX6BQ.js → workflow-O67MEBCP.js} +17 -17
  174. package/dist/{client-Bn8FwKGO.d.ts → client-CIwenMFS.d.ts} +1 -1
  175. package/dist/{client-CfNRmjLK.d.mts → client-DYAfJpaN.d.mts} +1 -1
  176. package/dist/{client-core-B91EV0WS.d.ts → client-core-CRjtyMAI.d.ts} +25 -2
  177. package/dist/{client-core-BG8Cgrmk.d.mts → client-core-DlzP8vEs.d.mts} +25 -2
  178. package/dist/{compiler-manifest-DlXDyndN.d.mts → compiler-manifest-DaJrA2KV.d.mts} +1 -1
  179. package/dist/{compiler-manifest-DlXDyndN.d.ts → compiler-manifest-DaJrA2KV.d.ts} +1 -1
  180. package/dist/{errors-BtriA2ld.d.mts → errors-BKnSYueU.d.mts} +1 -1
  181. package/dist/{errors-DmcLykM7.d.ts → errors-KLga4bLr.d.ts} +1 -1
  182. package/dist/{index-DI0sR_fX.d.mts → index-C-8AFpWy.d.mts} +1 -1
  183. package/dist/{index--Jw-slHY.d.ts → index-C5nAZ-VS.d.ts} +1 -1
  184. package/dist/index.d.mts +7 -7
  185. package/dist/index.d.ts +7 -7
  186. package/dist/index.js +9 -9
  187. package/dist/index.mjs +6 -6
  188. package/dist/install-integrity.json +125 -116
  189. package/dist/plays/bundle-play-file.d.mts +3 -3
  190. package/dist/plays/bundle-play-file.d.ts +3 -3
  191. package/dist/plays/bundle-play-file.mjs +12 -5
  192. package/dist/plays/play-description.d.mts +2 -2
  193. package/dist/plays/play-description.d.ts +2 -2
  194. package/dist/plays/run-request.d.mts +2 -2
  195. package/dist/plays/run-request.d.ts +2 -2
  196. package/dist/release.d.mts +1 -1
  197. package/dist/release.d.ts +1 -1
  198. package/dist/release.js +2 -2
  199. package/dist/release.mjs +1 -1
  200. package/dist/server.d.mts +4 -4
  201. package/dist/server.d.ts +4 -4
  202. package/dist/server.js +5 -5
  203. package/dist/server.mjs +3 -3
  204. package/package.json +1 -1
  205. package/dist/cli/auth-VM3IKP5F.js +0 -43
  206. package/dist/cli/describe-JOUAXXPE.js +0 -49
  207. package/dist/cli/git-OPKIC6JQ.js +0 -25
  208. package/dist/cli/search-6U54Y3OK.js +0 -32
  209. package/dist/cli/skills-VHININXC.js +0 -36
  210. package/dist/cli/tools-XMBMHVKF.js +0 -56
  211. package/dist/cli/update-H7JVW43I.js +0 -34
@@ -71,6 +71,18 @@ export interface RowState {
71
71
  results: Map<string, unknown>;
72
72
  }
73
73
 
74
+ /**
75
+ * An older-edition tool call's access to the org-wide newest shared result
76
+ * (`ctx:{org}:cache:v1:*`), the same entry edition-11 reads use.
77
+ */
78
+ export type LegacyLatestCacheAccess = {
79
+ key: string;
80
+ /** The call's own staleAfterSeconds in ms; null accepts any age. */
81
+ maxAgeMs: number | null;
82
+ read: boolean;
83
+ publish: boolean;
84
+ };
85
+
74
86
  export interface ToolCallRequest {
75
87
  /** Internal delivery identity, unique for each invocation. */
76
88
  callId: string;
@@ -88,6 +100,11 @@ export interface ToolCallRequest {
88
100
  receiptKey?: string | null;
89
101
  /** Pre-cutover result-cache keys to read before executing a canonical miss. */
90
102
  legacyReceiptKeys?: string[];
103
+ /**
104
+ * Older editions only: the request's newest shared result, read after the
105
+ * play-local keys miss and published after a live result.
106
+ */
107
+ latestCache?: LegacyLatestCacheAccess;
91
108
  executionAuthScopeDigest?: string | null;
92
109
  receiptLeaseId?: string | null;
93
110
  receiptLeaseExpiresAt?: string | null;
@@ -184,6 +201,30 @@ export type ReleaseRuntimeReceiptExecutionLockInput = {
184
201
  ownerExecutionId: string;
185
202
  };
186
203
 
204
+ /**
205
+ * The newest shared result for one read request. The receiver stamps
206
+ * `recordedAtMs` from its database clock and keeps the newer of two entries;
207
+ * the caller never supplies the time.
208
+ */
209
+ export type PublishLatestCacheResultInput = {
210
+ key: string;
211
+ runId: string;
212
+ output: {
213
+ kind: 'latest_cache_result';
214
+ value?: unknown;
215
+ valueReceiptKey?: string;
216
+ undefinedValue?: true;
217
+ };
218
+ };
219
+
220
+ /**
221
+ * `unavailable`: the receiver predates the action, so nothing was written.
222
+ * `value_too_large`: the inline value exceeds the receipt inline limit.
223
+ */
224
+ export type PublishLatestCacheResultOutcome =
225
+ | { published: true; recordedAtMs: number }
226
+ | { published: false; reason: 'older' | 'unavailable' | 'value_too_large' };
227
+
187
228
  export interface GetRuntimeStepReceiptInput {
188
229
  key: string;
189
230
  /** Read the bounded receipt manifest, not its output body. */
@@ -1129,6 +1170,11 @@ export interface ContextOptions {
1129
1170
  ) => Promise<{ origin: string } | null>;
1130
1171
  /** Original run for an explicit customer rerun, never an automatic retry. */
1131
1172
  replayedFromRunId?: string | null;
1173
+ /**
1174
+ * Launch fact: run-scoped keys come from the executing run rather than an
1175
+ * inline child's composition namespace. Absent on older launches.
1176
+ */
1177
+ runScopedKeys?: boolean;
1132
1178
  getToolRateScope?: (
1133
1179
  toolId: string,
1134
1180
  provider: string,
@@ -1243,6 +1289,9 @@ export interface ContextOptions {
1243
1289
  completeRuntimeStepReceipt?: (
1244
1290
  input: CompleteRuntimeStepReceiptInput,
1245
1291
  ) => Promise<RuntimeStepReceipt | null> | RuntimeStepReceipt | null;
1292
+ publishLatestCacheResult?: (
1293
+ input: PublishLatestCacheResultInput,
1294
+ ) => Promise<PublishLatestCacheResultOutcome>;
1246
1295
  releaseRuntimeStepReceipt?: (
1247
1296
  input: ReleaseRuntimeStepReceiptInput,
1248
1297
  ) => Promise<RuntimeStepReceipt | null> | RuntimeStepReceipt | null;
@@ -1300,6 +1349,12 @@ export interface PlayCheckpoint {
1300
1349
  boundaryId: string;
1301
1350
  runnerAttempt: number;
1302
1351
  heartbeatIdentity: string | null;
1352
+ /**
1353
+ * Latest time the worker's own probe saw the platform down while this
1354
+ * heartbeat was lapsed. Written only by the worker's park; the sandbox
1355
+ * cannot set it, because the park rebuilds this record on every wake.
1356
+ */
1357
+ controlPlaneOutageObservedAtMs?: number;
1303
1358
  };
1304
1359
  /** Last completed runner invocation within the current scheduler attempt. */
1305
1360
  workCounterInvocationAttempt?: number;
@@ -6,7 +6,11 @@ import {
6
6
  } from './tool-result';
7
7
  export { executeWithFreshnessReceipt } from './freshness-receipt-execution';
8
8
  import { assertNoSecretTaint } from './secret-capability';
9
- import type { RuntimeStepReceipt } from './ctx-types';
9
+ import type {
10
+ PublishLatestCacheResultInput,
11
+ PublishLatestCacheResultOutcome,
12
+ RuntimeStepReceipt,
13
+ } from './ctx-types';
10
14
  import {
11
15
  percentile,
12
16
  runtimeJsonByteLength,
@@ -824,7 +828,14 @@ export type DurableReceiptOperation = 'step' | 'tool' | 'fetch' | 'runPlay';
824
828
  export type DurableReceiptExecutionStore = {
825
829
  enabled: boolean;
826
830
  get(receiptKey: string): Promise<RuntimeStepReceipt | null>;
827
- getMany(receiptKeys: string[]): Promise<Map<string, RuntimeStepReceipt>>;
831
+ /**
832
+ * `hydrateOutput: false` asks for bounded manifests (status and
833
+ * `outputByteLength`, no body). A store may still return bodies.
834
+ */
835
+ getMany(
836
+ receiptKeys: string[],
837
+ options?: { hydrateOutput?: boolean },
838
+ ): Promise<Map<string, RuntimeStepReceipt>>;
828
839
  claim(
829
840
  receiptKey: string,
830
841
  runId: string,
@@ -843,6 +854,13 @@ export type DurableReceiptExecutionStore = {
843
854
  output: unknown | null,
844
855
  leaseId?: string | null,
845
856
  ): Promise<RuntimeStepReceipt | null>;
857
+ /**
858
+ * Newest-wins shared read result (`ctx:{org}:cache:v1:*`). The receiver
859
+ * stamps the time; absent when the host has no receipt gateway.
860
+ */
861
+ publishLatestCacheResult?(
862
+ input: PublishLatestCacheResultInput,
863
+ ): Promise<PublishLatestCacheResultOutcome>;
846
864
  release(
847
865
  receiptKey: string,
848
866
  runId: string,
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Writer switches for durable Play runs (automatic recovery, `runs resume`,
3
+ * run-scoped keys, the shared read cache).
4
+ *
5
+ * Every reader for these features ships unconditionally. Each writer below
6
+ * stays off until every runtime lane, gateway and app deploy runs the
7
+ * matching reader, then a separate rollout PR flips it, in this order. A
8
+ * newer build must always read what an older build wrote, so a switch is
9
+ * never flipped back once data in the new shape exists: recovery from a bad
10
+ * flip is a newer deploy.
11
+ */
12
+ export const DURABLE_RUNS_ROLLOUT = {
13
+ /**
14
+ * Admission stamps the `runScopedKeys` launch fact, so new runs derive
15
+ * inline-child history, SQL and idempotency keys from the executing run.
16
+ */
17
+ runScopedKeysAtAdmission: false,
18
+ /**
19
+ * The worker defers a replay-safe run whose attempt ended in a post-code
20
+ * platform failure instead of failing it.
21
+ */
22
+ automaticPostCodeRecovery: false,
23
+ /**
24
+ * After a live edition-11 read with `staleAfterSeconds` other than 0
25
+ * (including one refreshed by `--refresh-cache`), also publish the result
26
+ * as the request's newest shared result (`ctx:{org}:cache:v1:{hash}`),
27
+ * stamped by the database clock. Readers of
28
+ * that key already ship; a gateway without `publish_latest_cache_result`
29
+ * turns the write into a no-op.
30
+ */
31
+ sharedReadCacheWrites: false,
32
+ /**
33
+ * A provider's 5xx is retried inside the attempt with exponential backoff
34
+ * and jitter, sending the same provider idempotency key, even for an
35
+ * action not declared transient-HTTP safe. Only successes are final; a
36
+ * provider that ignores idempotency keys may see a write twice. The
37
+ * runner and the gateway's previous-outcome check use this same decision,
38
+ * so both must run it before it is flipped.
39
+ */
40
+ retryProviderServerErrors: false,
41
+ /**
42
+ * `runs resume` continues a stopped run. Off, the API refuses with
43
+ * `resume_unavailable`; readers for resumed runs ship regardless.
44
+ */
45
+ runsResume: false,
46
+ } as const;
@@ -62,6 +62,44 @@ export type DurableInvocationDiagnostic = {
62
62
  error?: unknown;
63
63
  };
64
64
 
65
+ /**
66
+ * Fence owner ID for one delivery: `{runId}:a{attempt}:{uuid}`, or the legacy
67
+ * `{runId}:{uuid}` when the attempt is unknown. The attempt lets a newer
68
+ * attempt of the same run take over a call an older attempt abandoned; a
69
+ * legacy owner is never taken over.
70
+ */
71
+ export function buildFenceOwnerId(
72
+ runId: string,
73
+ attempt: number | null | undefined,
74
+ uuid: string,
75
+ ): string {
76
+ return typeof attempt === 'number' && Number.isSafeInteger(attempt)
77
+ ? `${runId}:a${attempt}:${uuid}`
78
+ : `${runId}:${uuid}`;
79
+ }
80
+
81
+ const FENCE_OWNER_ATTEMPT_PATTERN = /:a(\d+):[0-9a-fA-F-]{36}$/;
82
+
83
+ export function fenceOwnerAttempt(ownerId: string): number | null {
84
+ const match = FENCE_OWNER_ATTEMPT_PATTERN.exec(ownerId);
85
+ return match ? Number(match[1]) : null;
86
+ }
87
+
88
+ /** Whether `existing` was written by an older attempt than `current`. */
89
+ export function isOlderAttemptFenceOwner(
90
+ existingOwnerId: string,
91
+ currentOwnerId: string,
92
+ ): boolean {
93
+ const existing = fenceOwnerAttempt(existingOwnerId);
94
+ const current = fenceOwnerAttempt(currentOwnerId);
95
+ return existing !== null && current !== null && existing < current;
96
+ }
97
+
98
+ /** SQL for the attempt encoded in an owner ID expression, else NULL. */
99
+ export function fenceOwnerAttemptSql(ownerIdExpression: string): string {
100
+ return `nullif(substring(${ownerIdExpression} from ':a([0-9]+):[0-9a-fA-F-]{36}$'), '')::integer`;
101
+ }
102
+
65
103
  /** Authenticated transport proof that this owner sent no provider request. */
66
104
  export class DurableInvocationDispatchNotStartedError extends Error {
67
105
  constructor(readonly reason: string) {
@@ -90,10 +128,36 @@ export class DurableInvocationOutcomeUnknownError extends Error {
90
128
  }
91
129
  }
92
130
 
131
+ /**
132
+ * The call a delivery is waiting on. When an older attempt of the same run
133
+ * owns it, the waiter knows when that call goes stale and may be sent again.
134
+ */
135
+ export type DurableInvocationBlocker = {
136
+ ownerAttemptOlder: boolean;
137
+ staleAtMs: number | null;
138
+ };
139
+
140
+ export function durableInvocationBlocker(input: {
141
+ blocking: { ownerId: string; updatedAt: string };
142
+ currentOwnerId: string;
143
+ runningStaleAfterMs: number;
144
+ }): DurableInvocationBlocker {
145
+ const updatedAtMs = Date.parse(input.blocking.updatedAt);
146
+ return {
147
+ ownerAttemptOlder: isOlderAttemptFenceOwner(
148
+ input.blocking.ownerId,
149
+ input.currentOwnerId,
150
+ ),
151
+ staleAtMs: Number.isFinite(updatedAtMs)
152
+ ? updatedAtMs + input.runningStaleAfterMs
153
+ : null,
154
+ };
155
+ }
156
+
93
157
  export class DurableInvocationInProgressError extends Error {
94
158
  readonly code = 'GATEWAY_INVOCATION_IN_PROGRESS';
95
159
 
96
- constructor() {
160
+ constructor(readonly blocker: DurableInvocationBlocker | null = null) {
97
161
  super(
98
162
  'The same durable invocation is still executing. Retry this transport delivery with the same invocation attempt.',
99
163
  );
@@ -235,7 +299,10 @@ export async function executeWithDurableInvocationFence(input: {
235
299
  });
236
300
  if (marked?.state === 'indeterminate') {
237
301
  diagnose('stale_running_indeterminate');
238
- if (marked.parentRunId !== input.parentRunId) {
302
+ if (
303
+ marked.parentRunId !== input.parentRunId ||
304
+ isOlderAttemptFenceOwner(marked.ownerId, input.ownerId)
305
+ ) {
239
306
  return await input.store.begin({
240
307
  invocationKey: input.invocationKey,
241
308
  requestFingerprint: input.requestFingerprint,
@@ -421,6 +488,7 @@ export async function executeWithDurableInvocationFence(input: {
421
488
  }
422
489
 
423
490
  const maxWaitAttempts = input.maxWaitAttempts ?? 20;
491
+ let blocking: DurableInvocationRecord = begun;
424
492
  for (let attempt = 1; attempt <= maxWaitAttempts; attempt += 1) {
425
493
  await (input.wait?.(attempt) ??
426
494
  new Promise<void>((resolve) => setTimeout(resolve, 250)));
@@ -428,6 +496,7 @@ export async function executeWithDurableInvocationFence(input: {
428
496
  invocationKey: input.invocationKey,
429
497
  });
430
498
  if (!latest) continue;
499
+ blocking = latest;
431
500
  assertMatchingRequest(
432
501
  latest,
433
502
  input.requestFingerprint,
@@ -435,7 +504,8 @@ export async function executeWithDurableInvocationFence(input: {
435
504
  );
436
505
  if (
437
506
  latest.state === 'indeterminate' &&
438
- latest.parentRunId !== input.parentRunId
507
+ (latest.parentRunId !== input.parentRunId ||
508
+ isOlderAttemptFenceOwner(latest.ownerId, input.ownerId))
439
509
  ) {
440
510
  return await executeWithDurableInvocationFence(input);
441
511
  }
@@ -458,5 +528,11 @@ export async function executeWithDurableInvocationFence(input: {
458
528
  }
459
529
  diagnose('wait_exhausted');
460
530
  input.onOutcome?.('in_progress');
461
- throw new DurableInvocationInProgressError();
531
+ throw new DurableInvocationInProgressError(
532
+ durableInvocationBlocker({
533
+ blocking,
534
+ currentOwnerId: input.ownerId,
535
+ runningStaleAfterMs: input.runningStaleAfterMs ?? 30 * 60_000,
536
+ }),
537
+ );
462
538
  }
@@ -0,0 +1,95 @@
1
+ import { PLAY_RUNTIME_EGRESS_FETCH_CURRENT_PATH } from './runtime-api-paths';
2
+
3
+ /** A fixture egress refusal that retrying cannot change. */
4
+ export class FixtureEgressFetchError extends Error {
5
+ override readonly name = 'FixtureEgressFetchError';
6
+ }
7
+
8
+ /**
9
+ * In fixture runs, ctx.fetch must not reach the network. This sends the
10
+ * request to the runtime egress route, which answers from the fixture engine
11
+ * and records the fixture execute boundary. A request the fixture engine does
12
+ * not support throws here, so an authored catch cannot turn a missing fixture
13
+ * into a live call.
14
+ */
15
+ export function createFixtureEgressFetch(input: {
16
+ baseUrl: string;
17
+ executorToken: string;
18
+ extraHeaders?: () => Promise<Record<string, string>>;
19
+ }): (url: string | URL, init?: RequestInit) => Promise<Response> {
20
+ const endpoint = `${input.baseUrl.replace(/\/$/, '')}${PLAY_RUNTIME_EGRESS_FETCH_CURRENT_PATH}`;
21
+ return async (url, init) => {
22
+ const headers = Object.fromEntries(new Headers(init?.headers).entries());
23
+ const body = init?.body;
24
+ if (
25
+ body !== undefined &&
26
+ body !== null &&
27
+ typeof body !== 'string' &&
28
+ !(body instanceof URLSearchParams)
29
+ ) {
30
+ throw new Error(
31
+ 'Fixture ctx.fetch supports only string or URLSearchParams bodies.',
32
+ );
33
+ }
34
+ const response = await fetch(endpoint, {
35
+ method: 'POST',
36
+ redirect: 'manual',
37
+ signal: init?.signal ?? undefined,
38
+ headers: {
39
+ Authorization: `Bearer ${input.executorToken}`,
40
+ 'Content-Type': 'application/json',
41
+ ...(await input.extraHeaders?.()),
42
+ },
43
+ // Older brokers reject this envelope before opening an outbound socket.
44
+ body: JSON.stringify({
45
+ fixtureRequest: {
46
+ url: String(url),
47
+ method: init?.method ?? 'GET',
48
+ headers,
49
+ body:
50
+ body === undefined || body === null
51
+ ? { kind: 'none' }
52
+ : typeof body === 'string'
53
+ ? { kind: 'string', value: body }
54
+ : { kind: 'urlSearchParams', value: body.toString() },
55
+ // ctx.fetch redacts its secret header values from the response itself.
56
+ sensitiveHeaders: [],
57
+ },
58
+ }),
59
+ });
60
+ const envelope = (await response.json().catch(() => null)) as {
61
+ error?: unknown;
62
+ status?: unknown;
63
+ statusText?: unknown;
64
+ headers?: unknown;
65
+ bodyText?: unknown;
66
+ } | null;
67
+ if (!response.ok || !envelope || typeof envelope.bodyText !== 'string') {
68
+ const reason =
69
+ typeof envelope?.error === 'string'
70
+ ? envelope.error
71
+ : `HTTP ${response.status}`;
72
+ const message = `Fixture ctx.fetch(${String(url)}) failed: ${reason}`;
73
+ // A missing fixture (501) or rejected request (4xx) will not change on
74
+ // retry. A 5xx, 408 or 429 from the egress route is transient.
75
+ if (
76
+ response.status === 501 ||
77
+ (response.status < 500 &&
78
+ response.status !== 408 &&
79
+ response.status !== 429)
80
+ ) {
81
+ throw new FixtureEgressFetchError(message);
82
+ }
83
+ throw new Error(message);
84
+ }
85
+ return new Response(envelope.bodyText, {
86
+ status: typeof envelope.status === 'number' ? envelope.status : 200,
87
+ statusText:
88
+ typeof envelope.statusText === 'string' ? envelope.statusText : '',
89
+ headers:
90
+ envelope.headers && typeof envelope.headers === 'object'
91
+ ? (envelope.headers as Record<string, string>)
92
+ : undefined,
93
+ });
94
+ };
95
+ }