deepline 0.3.499 → 0.3.501

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 (178) hide show
  1. package/dist/bundling-sources/sdk/src/plays/client-core.ts +45 -7
  2. package/dist/bundling-sources/sdk/src/release.ts +1 -1
  3. package/dist/bundling-sources/shared_libs/observability/scheduled-jobs.json +36 -0
  4. package/dist/bundling-sources/shared_libs/play-data-plane/r2.ts +155 -0
  5. package/dist/bundling-sources/shared_libs/play-runtime/app-runtime-api.ts +7 -1
  6. package/dist/bundling-sources/shared_libs/play-runtime/context.ts +2 -1
  7. package/dist/bundling-sources/shared_libs/play-runtime/durable-invocation-fence.ts +3 -1
  8. package/dist/bundling-sources/shared_libs/play-runtime/internal-bootstrap-token.ts +54 -1
  9. package/dist/bundling-sources/shared_libs/play-runtime/launch-identity.ts +12 -0
  10. package/dist/bundling-sources/shared_libs/play-runtime/protocol.ts +13 -0
  11. package/dist/bundling-sources/shared_libs/play-runtime/run-identity.ts +56 -0
  12. package/dist/bundling-sources/shared_libs/play-runtime/runner-app/index.ts +21 -10
  13. package/dist/bundling-sources/shared_libs/play-runtime/runner-app/runtime-heartbeat.ts +1 -1
  14. package/dist/bundling-sources/shared_libs/play-runtime/runner-app/runtime-progress-push.ts +1 -2
  15. package/dist/bundling-sources/shared_libs/play-runtime/runner-app/runtime-terminal-push.ts +1 -1
  16. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-launch-transport.ts +9 -2
  17. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-lifecycle.ts +31 -1
  18. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-payload-transport.ts +74 -3
  19. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-runtime-watchdog.ts +226 -2
  20. package/dist/bundling-sources/shared_libs/play-runtime/runtime-api-paths.ts +41 -0
  21. package/dist/bundling-sources/shared_libs/play-runtime/runtime-api.ts +5 -1
  22. package/dist/bundling-sources/shared_libs/play-runtime/runtime-app-transport.ts +374 -0
  23. package/dist/bundling-sources/shared_libs/play-runtime/runtime-authority.ts +5 -0
  24. package/dist/bundling-sources/shared_libs/play-runtime/runtime-environment.ts +49 -9
  25. package/dist/bundling-sources/shared_libs/play-runtime/runtime-gateway-oidc.ts +25 -3
  26. package/dist/bundling-sources/shared_libs/play-runtime/runtime-gateway-profile.ts +12 -1
  27. package/dist/bundling-sources/shared_libs/play-runtime/runtime-gateway-sandbox-credential.ts +338 -0
  28. package/dist/bundling-sources/shared_libs/play-runtime/runtime-gateway-staging.ts +417 -0
  29. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backend.ts +15 -0
  30. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-runtime-worker.ts +184 -11
  31. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-shared.ts +17 -3
  32. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/gateway-progress-registry.ts +9 -0
  33. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres-progress.ts +18 -2
  34. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres.ts +176 -16
  35. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-gateway-attempt.ts +81 -0
  36. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-gateway-staging-journal.ts +708 -0
  37. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-gateway-staging-teardown.ts +160 -0
  38. package/dist/bundling-sources/shared_libs/play-runtime/workflow-executor-auth.ts +4 -0
  39. package/dist/cli/{auth-TECJ27G3.mjs → auth-6ECHXOI4.mjs} +5 -5
  40. package/dist/cli/auth-VP7PMXKQ.js +43 -0
  41. package/dist/cli/{billing-PMKO73VG.mjs → billing-75NZYRXA.mjs} +8 -8
  42. package/dist/cli/{billing-ULZGAED6.js → billing-QRR7O6BD.js} +81 -81
  43. package/dist/cli/{chunk-K54BUQSK.js → chunk-463ZOO2L.js} +7 -7
  44. package/dist/cli/{chunk-L6C7C7IJ.js → chunk-4OXHLTCP.js} +1 -1
  45. package/dist/cli/{chunk-3GP52OHV.mjs → chunk-5S7MLAI7.mjs} +11 -11
  46. package/dist/cli/{chunk-7OQZZHZ4.js → chunk-5X4AUFYW.js} +7 -7
  47. package/dist/cli/{chunk-56JE475N.mjs → chunk-66XDYH5T.mjs} +2 -2
  48. package/dist/cli/{chunk-A2VCFBZN.mjs → chunk-7L6QNHUL.mjs} +1 -1
  49. package/dist/cli/{chunk-UOQUCFAK.js → chunk-APAHMCGR.js} +53 -53
  50. package/dist/cli/{chunk-UBKA33KY.mjs → chunk-BMCRTI6Z.mjs} +22 -1
  51. package/dist/cli/{chunk-WSOM3TY6.js → chunk-BOFCF4L7.js} +3 -3
  52. package/dist/cli/{chunk-SLWCXGKP.js → chunk-CJJ7JBM2.js} +16 -16
  53. package/dist/cli/{chunk-JM52ATUS.mjs → chunk-EHVFBD36.mjs} +1 -1
  54. package/dist/cli/{chunk-7WUMIRBV.js → chunk-EKF4DKUA.js} +5 -5
  55. package/dist/cli/{chunk-AGZRRHSB.js → chunk-EKZQ5LQO.js} +3 -3
  56. package/dist/cli/{chunk-5IDORX4E.mjs → chunk-EOO7OSS4.mjs} +4 -4
  57. package/dist/cli/{chunk-2PKZ3RUU.js → chunk-FS7XYDOF.js} +16 -16
  58. package/dist/cli/{chunk-Z2MO7FZG.js → chunk-HDKXSHGA.js} +53 -53
  59. package/dist/cli/{chunk-YRQWGWRJ.js → chunk-J6SVNKRP.js} +2 -2
  60. package/dist/cli/{chunk-QXI2W7YY.mjs → chunk-J74N375S.mjs} +4 -4
  61. package/dist/cli/{chunk-KLQ5CR77.js → chunk-KTOAJP4N.js} +6 -6
  62. package/dist/cli/{chunk-ZVAD65CF.mjs → chunk-MADTHS56.mjs} +1 -1
  63. package/dist/cli/{chunk-UMPCQ4EE.mjs → chunk-MSLXAVVK.mjs} +2 -2
  64. package/dist/cli/{chunk-JIZHGOZ5.js → chunk-N2TJJNCW.js} +96 -96
  65. package/dist/cli/{chunk-CS2AEAD6.mjs → chunk-N4TR6QRI.mjs} +1 -1
  66. package/dist/cli/{chunk-43ZERPGR.mjs → chunk-NA3J3F2Z.mjs} +1 -1
  67. package/dist/cli/{chunk-JQHJKARU.mjs → chunk-O3DDVP7Z.mjs} +1 -1
  68. package/dist/cli/{chunk-JUQESEJX.mjs → chunk-OKOXB3LY.mjs} +2 -2
  69. package/dist/cli/{chunk-FG5OZ5FB.js → chunk-PNF2ZU4R.js} +8 -8
  70. package/dist/cli/{chunk-KZJKRU24.mjs → chunk-PXIF74UJ.mjs} +4 -4
  71. package/dist/cli/{chunk-TUDYBF4Y.js → chunk-QQ3JJYE2.js} +14 -14
  72. package/dist/cli/{chunk-IGCSKXGK.mjs → chunk-RFV7PPLS.mjs} +3 -3
  73. package/dist/cli/{chunk-EQR5O2D2.js → chunk-RNSHCJME.js} +3 -3
  74. package/dist/cli/{chunk-PE3UHMMZ.js → chunk-RU5ROUFO.js} +5 -5
  75. package/dist/cli/{chunk-2RZHMCDL.js → chunk-SV2TEZ2M.js} +4 -4
  76. package/dist/cli/{chunk-P3MGNLZF.mjs → chunk-T4U245E4.mjs} +2 -2
  77. package/dist/cli/{chunk-7UC2UZYW.mjs → chunk-T7E3XEPG.mjs} +6 -6
  78. package/dist/cli/{chunk-LUNXREUI.js → chunk-TOE7LHEA.js} +6 -6
  79. package/dist/cli/{chunk-OWHQ4OG5.mjs → chunk-UJRN6YP6.mjs} +3 -3
  80. package/dist/cli/{chunk-XSUQAUG4.js → chunk-UR7JOSLT.js} +360 -300
  81. package/dist/cli/{chunk-KOD45UP5.mjs → chunk-V5NHEYU7.mjs} +5 -5
  82. package/dist/cli/{chunk-PSYGSXDS.mjs → chunk-VD2374K7.mjs} +1 -1
  83. package/dist/cli/{chunk-57LW4TGY.js → chunk-VL72UKNW.js} +26 -26
  84. package/dist/cli/{chunk-YAW7ET4P.mjs → chunk-VTDAJZIJ.mjs} +90 -30
  85. package/dist/cli/{chunk-AKLI4XSG.js → chunk-VVEMPC2I.js} +2 -2
  86. package/dist/cli/{chunk-L7O7AFSF.js → chunk-W6JTHVPF.js} +21 -21
  87. package/dist/cli/{chunk-MQ5YPD7K.mjs → chunk-WJUDAHIQ.mjs} +1 -1
  88. package/dist/cli/{chunk-XDVT3GOM.js → chunk-WSGXBROE.js} +22 -1
  89. package/dist/cli/{chunk-G7BB2VOC.js → chunk-XEBFJ2PH.js} +41 -41
  90. package/dist/cli/{chunk-WEVIUQGZ.mjs → chunk-Z6AUOV7D.mjs} +2 -2
  91. package/dist/cli/{chunk-BBFWIYAF.mjs → chunk-ZUOKIBLJ.mjs} +2 -2
  92. package/dist/cli/{chunk-C2V5U6HO.mjs → chunk-ZUQHQGC5.mjs} +5 -5
  93. package/dist/cli/{csv-VGSQ3JYE.js → csv-JXX2LXK5.js} +13 -13
  94. package/dist/cli/{csv-ACO5YC46.mjs → csv-RZJ4SOIL.mjs} +4 -4
  95. package/dist/cli/{db-CXNZOXGM.mjs → db-MUTT2NWI.mjs} +8 -8
  96. package/dist/cli/{db-QOUPHFFN.js → db-T2KJNONM.js} +29 -29
  97. package/dist/cli/{describe-J4O5GCJS.mjs → describe-K3UMAAVO.mjs} +19 -19
  98. package/dist/cli/describe-SEXUJLE4.js +50 -0
  99. package/dist/cli/describe-core.d.mts +2 -2
  100. package/dist/cli/describe-core.d.ts +2 -2
  101. package/dist/cli/{executions-YIECH2CL.js → executions-7HSLDRHR.js} +10 -10
  102. package/dist/cli/{executions-SJETRLXW.mjs → executions-PHS4R2OX.mjs} +8 -8
  103. package/dist/cli/{feedback-5BRCNERV.js → feedback-BJZRM637.js} +8 -8
  104. package/dist/cli/{feedback-GSAFFMF6.mjs → feedback-RWMDCIDF.mjs} +4 -4
  105. package/dist/cli/git-VNS7UQWN.js +25 -0
  106. package/dist/cli/{git-SF5XIGLU.mjs → git-YW6VHYZG.mjs} +5 -5
  107. package/dist/cli/index.js +137 -137
  108. package/dist/cli/index.mjs +40 -40
  109. package/dist/cli/{legacy-noops-5TBT4XC6.js → legacy-noops-2WUV2XD7.js} +8 -8
  110. package/dist/cli/{legacy-noops-TZA3CALE.mjs → legacy-noops-5UBSUPGG.mjs} +5 -5
  111. package/dist/cli/{monitors-XAYWJNSV.mjs → monitors-HWOQO3OK.mjs} +9 -9
  112. package/dist/cli/{monitors-XNB5YNC3.js → monitors-YZZRKSTG.js} +97 -97
  113. package/dist/cli/{org-2UYWJXG7.js → org-JY7HLHBA.js} +74 -74
  114. package/dist/cli/{org-S5VZL5KZ.mjs → org-NCXT6RB4.mjs} +8 -8
  115. package/dist/cli/{pages-ZQRRTZIT.js → pages-6ZOHXL6X.js} +20 -20
  116. package/dist/cli/{pages-NGVJO7PA.mjs → pages-QJO53QAT.mjs} +8 -8
  117. package/dist/cli/{play-3JNERHSC.mjs → play-SQRS7JN3.mjs} +20 -20
  118. package/dist/cli/{play-P3OYQ7JV.js → play-TAYGSR35.js} +336 -336
  119. package/dist/cli/{providers-27O6BOAP.mjs → providers-3IR3N5DT.mjs} +8 -8
  120. package/dist/cli/{providers-2FFGAPUR.js → providers-4Q5LOIQ5.js} +11 -11
  121. package/dist/cli/{quickstart-5G2UPKJV.js → quickstart-ITNUZENY.js} +6 -6
  122. package/dist/cli/{quickstart-B2EXIAU6.mjs → quickstart-KCZCYO6B.mjs} +4 -4
  123. package/dist/cli/{run-3QFXYV3Z.mjs → run-JCWRWDSK.mjs} +24 -24
  124. package/dist/cli/{run-2TGD7FAL.js → run-YQ57LMKN.js} +42 -42
  125. package/dist/cli/run-identity-HFYABUJS.js +31 -0
  126. package/dist/cli/{run-identity-MRNCEGV2.mjs → run-identity-MNRZS2N3.mjs} +9 -3
  127. package/dist/cli/{search-GXEEOMVD.mjs → search-FUM27HQP.mjs} +9 -9
  128. package/dist/cli/search-I425FRTK.js +32 -0
  129. package/dist/cli/{search-output-DMIJQTAA.mjs → search-output-EWEYT34M.mjs} +4 -4
  130. package/dist/cli/{search-output-I4RZPHU6.js → search-output-XAMWKRJH.js} +6 -6
  131. package/dist/cli/{secrets-MJMNRXZX.js → secrets-2IRRRZBL.js} +17 -17
  132. package/dist/cli/{secrets-DQI5YCS6.mjs → secrets-YTI4IAKR.mjs} +8 -8
  133. package/dist/cli/{sessions-HAUN3VYE.mjs → sessions-EFS4KUPF.mjs} +5 -5
  134. package/dist/cli/{sessions-QS74ZTRH.js → sessions-HWTRDXBQ.js} +6 -6
  135. package/dist/cli/{settings-VQBOS6VU.js → settings-FRVEIOKR.js} +80 -80
  136. package/dist/cli/{settings-E64HIUXW.mjs → settings-NTOO42DY.mjs} +13 -13
  137. package/dist/cli/{setup-KRW3JCJE.js → setup-6ZIOAE2V.js} +49 -49
  138. package/dist/cli/{setup-NRUG42F2.mjs → setup-PAVQPALX.mjs} +9 -9
  139. package/dist/cli/{skills-AHLZRTKZ.mjs → skills-3O3XTPUM.mjs} +7 -7
  140. package/dist/cli/skills-6ZNMO2PR.js +36 -0
  141. package/dist/cli/{tools-INRRIWOU.mjs → tools-7QSB65UL.mjs} +18 -18
  142. package/dist/cli/tools-DPV2JES6.js +57 -0
  143. package/dist/cli/update-Q5GUDEAW.js +34 -0
  144. package/dist/cli/{update-ETOWEJ7D.mjs → update-T6CYS5ZT.mjs} +9 -9
  145. package/dist/cli/{workflow-RUAYQK4D.js → workflow-4KMJBMGX.js} +19 -19
  146. package/dist/cli/{workflow-JT2DOSCJ.mjs → workflow-OMSXZ73T.mjs} +9 -9
  147. package/dist/{client-Cj3UqrCZ.d.ts → client-Bn8FwKGO.d.ts} +1 -1
  148. package/dist/{client-DSCTVVRj.d.mts → client-CfNRmjLK.d.mts} +1 -1
  149. package/dist/{client-core-dI4KTuWS.d.ts → client-core-B91EV0WS.d.ts} +19 -0
  150. package/dist/{client-core-B-8DTIN1.d.mts → client-core-BG8Cgrmk.d.mts} +19 -0
  151. package/dist/index.d.mts +3 -3
  152. package/dist/index.d.ts +3 -3
  153. package/dist/index.js +19 -19
  154. package/dist/index.mjs +8 -8
  155. package/dist/install-integrity.json +114 -108
  156. package/dist/plays/play-description.d.mts +1 -1
  157. package/dist/plays/play-description.d.ts +1 -1
  158. package/dist/plays/run-request.d.mts +1 -1
  159. package/dist/plays/run-request.d.ts +1 -1
  160. package/dist/plays/run-request.js +3 -3
  161. package/dist/plays/run-request.mjs +2 -2
  162. package/dist/release.d.mts +1 -1
  163. package/dist/release.d.ts +1 -1
  164. package/dist/release.js +2 -2
  165. package/dist/release.mjs +1 -1
  166. package/dist/server.d.mts +2 -2
  167. package/dist/server.d.ts +2 -2
  168. package/dist/server.js +7 -7
  169. package/dist/server.mjs +5 -5
  170. package/package.json +1 -1
  171. package/dist/cli/auth-32FRISRT.js +0 -43
  172. package/dist/cli/describe-DEXYQMBO.js +0 -50
  173. package/dist/cli/git-RDKLITUC.js +0 -25
  174. package/dist/cli/run-identity-G257GQED.js +0 -25
  175. package/dist/cli/search-YKTYDBCN.js +0 -32
  176. package/dist/cli/skills-PGVIJK6Q.js +0 -36
  177. package/dist/cli/tools-IXXN2RE4.js +0 -57
  178. package/dist/cli/update-QW4RV2UX.js +0 -34
@@ -35,6 +35,7 @@ import {
35
35
  normalizePlayRunRuntimeSelection,
36
36
  type PlayRunRuntimeSelection,
37
37
  } from '../../../shared_libs/play-runtime/runtime-environment.js';
38
+ import { normalizeRuntimeGatewayProfileId } from '../../../shared_libs/play-runtime/runtime-gateway-profile.js';
38
39
  import { decodePlayRunPublicStatus } from '../../../shared_libs/play-runtime/run-lifecycle-policy.js';
39
40
 
40
41
  export function normalizePlayRunIntegrationMode(
@@ -82,8 +83,14 @@ function resolvePlayRunRuntimeSelection(
82
83
  const configuredToken = env.DEEPLINE_RUNTIME_ENVIRONMENT_TOKEN?.trim();
83
84
  const configuredPlacementPolicy =
84
85
  env.DEEPLINE_RUNTIME_SANDBOX_PLACEMENT_POLICY?.trim();
86
+ const configuredGatewayProfile = env.DEEPLINE_RUNTIME_GATEWAY_PROFILE?.trim();
85
87
  if (!configured) {
86
- if (configuredNamespace || configuredToken || configuredPlacementPolicy) {
88
+ if (
89
+ configuredNamespace ||
90
+ configuredToken ||
91
+ configuredPlacementPolicy ||
92
+ configuredGatewayProfile
93
+ ) {
87
94
  // Name the variables that are actually set. This branch is almost always
88
95
  // hit by a stale value auto-loaded from a .env/.env.local rather than by
89
96
  // a deliberate export, so the message has to say where to look and how
@@ -94,6 +101,9 @@ function resolvePlayRunRuntimeSelection(
94
101
  if (configuredPlacementPolicy) {
95
102
  present.push('DEEPLINE_RUNTIME_SANDBOX_PLACEMENT_POLICY');
96
103
  }
104
+ if (configuredGatewayProfile) {
105
+ present.push('DEEPLINE_RUNTIME_GATEWAY_PROFILE');
106
+ }
97
107
  const isPlural = present.length > 1;
98
108
  throw new DeeplineError(
99
109
  [
@@ -108,20 +118,47 @@ function resolvePlayRunRuntimeSelection(
108
118
  }
109
119
  return undefined;
110
120
  }
121
+ // Validated only once a runtime environment is configured: a stale value
122
+ // without one gets the "unset them" guidance above instead.
123
+ const selectedGatewayProfile = configuredGatewayProfile
124
+ ? normalizeRuntimeGatewayProfileId(configuredGatewayProfile)
125
+ : undefined;
126
+ if (configuredGatewayProfile && !selectedGatewayProfile) {
127
+ throw new DeeplineError(
128
+ `DEEPLINE_RUNTIME_GATEWAY_PROFILE must be a supported versioned gateway profile id such as vercel_app@1. Received "${configuredGatewayProfile}".`,
129
+ undefined,
130
+ 'INVALID_RUNTIME_GATEWAY_PROFILE',
131
+ );
132
+ }
133
+ const gatewayProfile = selectedGatewayProfile
134
+ ? { gatewayProfile: selectedGatewayProfile }
135
+ : {};
111
136
  if (configured === 'native') {
112
137
  // The app's own runtime on a named placement policy. The server decides
113
138
  // from the API key's account whether this caller may ask for it.
114
- const sandboxPlacementPolicy = normalizePlayRuntimeSandboxPlacementPolicy(
115
- configuredPlacementPolicy,
116
- );
117
- if (configuredNamespace || !sandboxPlacementPolicy) {
139
+ const sandboxPlacementPolicy = configuredPlacementPolicy
140
+ ? normalizePlayRuntimeSandboxPlacementPolicy(configuredPlacementPolicy)
141
+ : undefined;
142
+ if (
143
+ configuredNamespace ||
144
+ (configuredPlacementPolicy && !sandboxPlacementPolicy) ||
145
+ (!sandboxPlacementPolicy && !selectedGatewayProfile)
146
+ ) {
118
147
  throw new DeeplineError(
119
- 'DEEPLINE_RUNTIME_ENVIRONMENT=native requires DEEPLINE_RUNTIME_SANDBOX_PLACEMENT_POLICY (such as modal_only@1) and no DEEPLINE_RUNTIME_NAMESPACE.',
148
+ 'DEEPLINE_RUNTIME_ENVIRONMENT=native requires DEEPLINE_RUNTIME_SANDBOX_PLACEMENT_POLICY (such as modal_only@1) and/or DEEPLINE_RUNTIME_GATEWAY_PROFILE (such as vercel_app@1), and no DEEPLINE_RUNTIME_NAMESPACE.',
120
149
  undefined,
121
150
  'INVALID_RUNTIME_ENVIRONMENT',
122
151
  );
123
152
  }
124
- return { environment: 'native', sandboxPlacementPolicy };
153
+ // The guard above leaves at least one of the two selected.
154
+ if (sandboxPlacementPolicy) {
155
+ return {
156
+ environment: 'native',
157
+ sandboxPlacementPolicy,
158
+ ...gatewayProfile,
159
+ };
160
+ }
161
+ return { environment: 'native', gatewayProfile: selectedGatewayProfile! };
125
162
  }
126
163
  const environment = normalizePlayRuntimeEnvironment(configured);
127
164
  if (!environment) {
@@ -168,6 +205,7 @@ function resolvePlayRunRuntimeSelection(
168
205
  ...(configuredPlacementPolicy
169
206
  ? { sandboxPlacementPolicy: configuredPlacementPolicy }
170
207
  : {}),
208
+ ...gatewayProfile,
171
209
  };
172
210
  }
173
211
 
@@ -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.499',
208
+ version: '0.3.501',
209
209
  updateSummary: {
210
210
  introducedIn: '0.3.90',
211
211
  summary:
@@ -568,6 +568,24 @@
568
568
  "failureAlert": "github_workflow_run",
569
569
  "domainReportRequired": true
570
570
  },
571
+ {
572
+ "id": "github.refresh-gauntlet-target-weights",
573
+ "name": "Refresh Gauntlet target weights",
574
+ "scheduler": "github_actions",
575
+ "cadence": "0 6 * * 1",
576
+ "timezone": "UTC",
577
+ "source": ".github/workflows/refresh-gauntlet-target-weights.yml",
578
+ "locator": "schedule:",
579
+ "owner": "platform",
580
+ "criticality": "maintenance",
581
+ "purpose": "Re-measure Absurd PR target shard durations from recent shard jobs, rebuild the weight profile and holdout, and open or update the refresh PR.",
582
+ "successDefinition": "A complete holdout run and training runs are measured, the scheduler model tests pass with the new profile, and the PR is updated; no change is a valid no-op.",
583
+ "failureDefinition": "No complete run is measurable, the refreshed profile fails the scheduler model tests, or the PR cannot be updated.",
584
+ "startGraceMs": 600000,
585
+ "runTimeoutMs": 1800000,
586
+ "failureAlert": "github_workflow_run",
587
+ "domainReportRequired": true
588
+ },
571
589
  {
572
590
  "id": "github.refresh-vitest-shard-weights",
573
591
  "name": "Refresh Vitest shard weights",
@@ -892,6 +910,24 @@
892
910
  "failureAlert": "vercel_route_wrapper",
893
911
  "domainReportRequired": true
894
912
  },
913
+ {
914
+ "id": "vercel.runtime-gateway-staging-retirement",
915
+ "name": "Runtime gateway staged-body retirement",
916
+ "scheduler": "vercel_cron",
917
+ "cadence": "7,22,37,52 * * * *",
918
+ "timezone": "UTC",
919
+ "source": "apps/deepline-api/vercel.json",
920
+ "locator": "/api/v2/cron/runtime-gateway-staging-retirement",
921
+ "owner": "runtime",
922
+ "criticality": "maintenance",
923
+ "purpose": "Retire app-hosted Runtime gateway staged bodies past their retirement time: delete each exact object, confirm it absent, then mark its custody row deleted; prune long-deleted rows.",
924
+ "successDefinition": "Every scheduler schema served by the deployment was probed; each due row was either confirmed absent and marked deleted or released for the next pass; an idle journal is a valid no-op.",
925
+ "failureDefinition": "A schema's journal probe, claim or prune fails, or target discovery fails, leaving due staged bodies unretired.",
926
+ "startGraceMs": 300000,
927
+ "runTimeoutMs": 300000,
928
+ "failureAlert": "vercel_route_wrapper",
929
+ "domainReportRequired": true
930
+ },
895
931
  {
896
932
  "id": "vercel.scheduled-work-health-snapshot",
897
933
  "name": "Scheduled-work health snapshot",
@@ -79,6 +79,18 @@ function resolveBucket(kind: R2BucketKind): string {
79
79
  return requireEnv('CLOUDFLARE_R2_BUCKET_NAME');
80
80
  }
81
81
 
82
+ /**
83
+ * Nonsecret identity of the bucket a configuration addresses: SHA-256 of the
84
+ * bucket name and the endpoint host. Two processes address the same bucket
85
+ * only when their fingerprints match. Resolves no credentials.
86
+ */
87
+ export function getR2BucketFingerprint(kind: R2BucketKind = 'default'): string {
88
+ const host = new URL(requireEnv('CLOUDFLARE_R2_ENDPOINT')).host.toLowerCase();
89
+ return createHash('sha256')
90
+ .update(`${resolveBucket(kind)}\n${host}`)
91
+ .digest('hex');
92
+ }
93
+
82
94
  export function getR2Config(kind: R2BucketKind = 'default') {
83
95
  return {
84
96
  endpoint: requireEnv('CLOUDFLARE_R2_ENDPOINT'),
@@ -191,12 +203,14 @@ export async function r2ObjectExists(
191
203
  export async function confirmR2ObjectAbsent(
192
204
  key: string,
193
205
  kind: R2BucketKind = 'default',
206
+ options?: { abortSignal?: AbortSignal },
194
207
  ): Promise<boolean> {
195
208
  const config = getR2Config(kind);
196
209
  const client = getR2Client(config);
197
210
  try {
198
211
  await client.send(
199
212
  new HeadObjectCommand({ Bucket: config.bucket, Key: key }),
213
+ { abortSignal: options?.abortSignal },
200
214
  );
201
215
  return false;
202
216
  } catch (error) {
@@ -312,6 +326,7 @@ export async function listR2Keys(
312
326
  export async function deleteR2Object(
313
327
  key: string,
314
328
  kind: R2BucketKind = 'default',
329
+ options?: { abortSignal?: AbortSignal },
315
330
  ): Promise<void> {
316
331
  const startedAt = Date.now();
317
332
  const config = getR2Config(kind);
@@ -321,6 +336,7 @@ export async function deleteR2Object(
321
336
  Bucket: config.bucket,
322
337
  Key: key,
323
338
  }),
339
+ { abortSignal: options?.abortSignal },
324
340
  );
325
341
  logR2Perf('delete', key, startedAt, { kind });
326
342
  }
@@ -392,3 +408,142 @@ export async function createSignedR2WriteUrl(input: {
392
408
  expiresAt: new Date(Date.now() + expiresInSeconds * 1000).toISOString(),
393
409
  };
394
410
  }
411
+
412
+ /** Ceiling for a create-once upload grant: 15 minutes. */
413
+ export const R2_CREATE_ONCE_UPLOAD_MAX_EXPIRES_SECONDS = 15 * 60;
414
+
415
+ /**
416
+ * Sign an exact-size, create-once PUT (`If-None-Match: *`) valid for at most
417
+ * 15 minutes. This bounds what the URL can write; it does not verify the
418
+ * digest or retire the object. The caller persists custody before calling
419
+ * this, verifies the stored bytes before use, and deletes the key only after
420
+ * the URL has expired (until then the URL could recreate a deleted key).
421
+ */
422
+ export async function createSignedR2CreateOnceUrl(input: {
423
+ key: string;
424
+ kind?: R2BucketKind;
425
+ contentType: string;
426
+ byteLength: number;
427
+ maxBytes: number;
428
+ expiresInSeconds: number;
429
+ }): Promise<{
430
+ url: string;
431
+ expiresAt: string;
432
+ headers: {
433
+ 'content-type': string;
434
+ 'content-length': string;
435
+ 'if-none-match': '*';
436
+ };
437
+ }> {
438
+ if (!input.key || !input.contentType) {
439
+ throw new Error('R2 create-once upload requires a key and content type.');
440
+ }
441
+ if (
442
+ !Number.isSafeInteger(input.byteLength) ||
443
+ !Number.isSafeInteger(input.maxBytes) ||
444
+ input.byteLength < 0 ||
445
+ input.maxBytes < 0 ||
446
+ input.byteLength > input.maxBytes
447
+ ) {
448
+ throw new Error('R2 create-once upload size exceeds its allowed bound.');
449
+ }
450
+ if (
451
+ !Number.isSafeInteger(input.expiresInSeconds) ||
452
+ input.expiresInSeconds < 1 ||
453
+ input.expiresInSeconds > R2_CREATE_ONCE_UPLOAD_MAX_EXPIRES_SECONDS
454
+ ) {
455
+ throw new Error(
456
+ `R2 create-once upload expiry must be between 1 and ${R2_CREATE_ONCE_UPLOAD_MAX_EXPIRES_SECONDS} seconds.`,
457
+ );
458
+ }
459
+ const kind = input.kind ?? 'default';
460
+ const config = getR2Config(kind);
461
+ const client = createR2Client(config);
462
+ const command = new PutObjectCommand({
463
+ Bucket: config.bucket,
464
+ Key: input.key,
465
+ ContentType: input.contentType,
466
+ ContentLength: input.byteLength,
467
+ IfNoneMatch: '*',
468
+ });
469
+ // SigV4 timestamps have whole-second precision. Report that exact deadline.
470
+ const signingDate = new Date(Math.floor(Date.now() / 1000) * 1000);
471
+ const url = await getSignedUrl(
472
+ client as R2PresignerClient,
473
+ command as R2PresignerCommand,
474
+ {
475
+ expiresIn: input.expiresInSeconds,
476
+ signingDate,
477
+ signableHeaders: new Set([
478
+ 'content-length',
479
+ 'content-type',
480
+ 'if-none-match',
481
+ ]),
482
+ },
483
+ );
484
+ return {
485
+ url,
486
+ expiresAt: new Date(
487
+ signingDate.getTime() + input.expiresInSeconds * 1000,
488
+ ).toISOString(),
489
+ headers: {
490
+ 'content-type': input.contentType,
491
+ 'content-length': String(input.byteLength),
492
+ 'if-none-match': '*',
493
+ },
494
+ };
495
+ }
496
+
497
+ /** R2 answered that the key does not exist (as opposed to failing). */
498
+ export function isR2NotFoundError(error: unknown): boolean {
499
+ const details = error as {
500
+ name?: string;
501
+ Code?: string;
502
+ $metadata?: { httpStatusCode?: number };
503
+ } | null;
504
+ return (
505
+ !!details &&
506
+ (details.$metadata?.httpStatusCode === 404 ||
507
+ details.name === 'NotFound' ||
508
+ details.name === 'NoSuchKey' ||
509
+ details.Code === 'NotFound' ||
510
+ details.Code === 'NoSuchKey')
511
+ );
512
+ }
513
+
514
+ /**
515
+ * Read one object, refusing before buffering when it is larger than
516
+ * `maxBytes`. Returns null only when R2 says the key does not exist; every
517
+ * other failure throws, so callers never mistake an outage for absence.
518
+ */
519
+ export async function getBoundedBufferFromR2(
520
+ key: string,
521
+ maxBytes: number,
522
+ kind: R2BucketKind = 'default',
523
+ ): Promise<Buffer | null> {
524
+ const startedAt = Date.now();
525
+ const config = getR2Config(kind);
526
+ const client = getR2Client(config);
527
+ let response;
528
+ try {
529
+ response = await client.send(
530
+ new GetObjectCommand({ Bucket: config.bucket, Key: key }),
531
+ );
532
+ } catch (error) {
533
+ if (isR2NotFoundError(error)) return null;
534
+ throw error;
535
+ }
536
+ if (
537
+ typeof response.ContentLength === 'number' &&
538
+ response.ContentLength > maxBytes
539
+ ) {
540
+ (response.Body as { destroy?: () => void } | undefined)?.destroy?.();
541
+ throw new Error(`R2 object ${key} exceeds ${maxBytes} bytes.`);
542
+ }
543
+ const bytes = await response.Body!.transformToByteArray();
544
+ if (bytes.byteLength > maxBytes) {
545
+ throw new Error(`R2 object ${key} exceeds ${maxBytes} bytes.`);
546
+ }
547
+ logR2Perf('get-bounded', key, startedAt, { kind, bytes: bytes.byteLength });
548
+ return Buffer.from(bytes);
549
+ }
@@ -1007,8 +1007,14 @@ function appRuntimeProjectionMismatch(
1007
1007
  }
1008
1008
  }
1009
1009
 
1010
+ /**
1011
+ * A 500 body that names a transient failure. `INTERNAL_FUNCTION_INVOCATION_FAILED`
1012
+ * is Vercel's own platform error page (the function was not invoked or its
1013
+ * invocation was lost inside Vercel), not an app outcome; only replay-safe
1014
+ * actions reach this check, so retrying it is safe.
1015
+ */
1010
1016
  export function isTransientAppRuntimeFailureBody(body: string): boolean {
1011
- return /WorkerOverloaded|"\s*code\s*"\s*:\s*"\s*InternalServerError\s*"|Your request couldn't be completed\. Try again later\.|timeout exceeded when trying to connect|timed out|fetch failed|ECONNRESET|ECONNREFUSED|UND_ERR_CONNECT_TIMEOUT|tuple concurrently updated|RUNTIME_SCHEDULER_(?:SATURATED|UNAVAILABLE|SCHEMA_NOT_READY)|Runtime scheduler DB pool is saturated|Runtime scheduler DB circuit breaker is open|Runtime scheduler schema .* is not ready|OptimisticConcurrencyControlFailure|changed while this mutation was being run|Documents read from or written to the .* table changed while this mutation/i.test(
1017
+ return /\bINTERNAL_FUNCTION_INVOCATION_FAILED\b|WorkerOverloaded|"\s*code\s*"\s*:\s*"\s*InternalServerError\s*"|Your request couldn't be completed\. Try again later\.|timeout exceeded when trying to connect|timed out|fetch failed|ECONNRESET|ECONNREFUSED|UND_ERR_CONNECT_TIMEOUT|tuple concurrently updated|RUNTIME_SCHEDULER_(?:SATURATED|UNAVAILABLE|SCHEMA_NOT_READY)|Runtime scheduler DB pool is saturated|Runtime scheduler DB circuit breaker is open|Runtime scheduler schema .* is not ready|OptimisticConcurrencyControlFailure|changed while this mutation was being run|Documents read from or written to the .* table changed while this mutation/i.test(
1012
1018
  body,
1013
1019
  );
1014
1020
  }
@@ -98,6 +98,7 @@ import {
98
98
  resolveMapRowOutcomeKey,
99
99
  } from './map-row-outcome';
100
100
  import {
101
+ integrationExecutePath,
101
102
  PLAY_RUNTIME_API_COMPAT_PATH,
102
103
  PLAY_RUNTIME_OPERATION_ATTEMPT_HEADER,
103
104
  PLAY_RUNTIME_OPERATION_ID_HEADER,
@@ -19660,7 +19661,7 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
19660
19661
  DURABLE_INVOCATION_FENCE_VERSION,
19661
19662
  )
19662
19663
  : 'execute';
19663
- const url = `${executionBaseUrl.replace(/\/$/, '')}/api/v2/integrations/${encodeURIComponent(toolId)}/${executeSuffix}`;
19664
+ const url = `${executionBaseUrl.replace(/\/$/, '')}${integrationExecutePath(toolId, executeSuffix)}`;
19664
19665
  const fixtureReplaySafe = this.#options.integrationMode === 'fixture';
19665
19666
  const readOnlyQuery = isQueryResultDatasetReadRequest(
19666
19667
  toolId,
@@ -66,6 +66,8 @@ export function durableInvocationFenceAttestationHeaders(): Record<
66
66
  };
67
67
  }
68
68
 
69
- export function durableInvocationFenceExecutePath(version: 1 | 2): string {
69
+ export function durableInvocationFenceExecutePath(
70
+ version: 1 | 2,
71
+ ): 'execute-fenced-v1' | 'execute-fenced-v2' {
70
72
  return `execute-fenced-v${version}`;
71
73
  }
@@ -302,6 +302,14 @@ type WorkflowInternalTokenBaseClaims = {
302
302
  v: typeof INTERNAL_BOOTSTRAP_TOKEN_VERSION;
303
303
  };
304
304
 
305
+ /** Vercel deployment id shape carried by `runtime_gateway_deployment_id`. */
306
+ const RUNTIME_GATEWAY_DEPLOYMENT_ID_CLAIM_PATTERN = /^dpl_[A-Za-z0-9]+$/;
307
+ /**
308
+ * Versioned profile id shape. Membership is checked by the gateway that serves
309
+ * the profile, so a token naming a newer profile still verifies here.
310
+ */
311
+ const RUNTIME_GATEWAY_PROFILE_CLAIM_PATTERN = /^[a-z][a-z0-9_]*@[1-9][0-9]*$/;
312
+
305
313
  export type WorkflowRunExecutionTokenClaims =
306
314
  WorkflowInternalTokenBaseClaims & {
307
315
  purpose: typeof INTERNAL_WORKFLOW_EXECUTION_PURPOSE;
@@ -349,6 +357,13 @@ export type WorkflowRunExecutionTokenClaims =
349
357
  capabilities: RuntimeExecutionCapability[];
350
358
  /** Trusted deployment origin that issued this run token. */
351
359
  runtime_origin?: string;
360
+ /**
361
+ * Runtime gateway pin: the immutable app deployment (`dpl_...`) whose
362
+ * in-process gateway alone may accept this token. Absent on unpinned runs.
363
+ */
364
+ runtime_gateway_deployment_id?: string;
365
+ /** Runtime gateway profile id paired with `runtime_gateway_deployment_id`. */
366
+ runtime_gateway_profile?: string;
352
367
  /** Immutable receiver advertising leased Run Ledger ingress-prefix support. */
353
368
  run_ledger_ingress_prefix_origin?: string;
354
369
  };
@@ -665,6 +680,18 @@ function isValidWorkflowClaimsShape(
665
680
  typeof claims.terminal_contract === 'string') &&
666
681
  (claims.runtime_origin === undefined ||
667
682
  isValidRuntimeOrigin(claims.runtime_origin)) &&
683
+ (claims.runtime_gateway_deployment_id === undefined ||
684
+ (typeof claims.runtime_gateway_deployment_id === 'string' &&
685
+ RUNTIME_GATEWAY_DEPLOYMENT_ID_CLAIM_PATTERN.test(
686
+ claims.runtime_gateway_deployment_id,
687
+ ))) &&
688
+ (claims.runtime_gateway_profile === undefined ||
689
+ (typeof claims.runtime_gateway_profile === 'string' &&
690
+ RUNTIME_GATEWAY_PROFILE_CLAIM_PATTERN.test(
691
+ claims.runtime_gateway_profile,
692
+ ))) &&
693
+ (claims.runtime_gateway_deployment_id === undefined) ===
694
+ (claims.runtime_gateway_profile === undefined) &&
668
695
  (claims.run_ledger_ingress_prefix_origin === undefined ||
669
696
  isValidRuntimeOrigin(claims.run_ledger_ingress_prefix_origin)) &&
670
697
  Array.isArray(claims.capabilities) &&
@@ -761,12 +788,32 @@ export async function mintWorkflowRunExecutionToken(input: {
761
788
  terminalContract?: DirectCompletedTerminalContract | null;
762
789
  capabilities?: readonly RuntimeExecutionCapability[];
763
790
  runtimeOrigin?: string | null;
791
+ /** Both or neither: the pinned deployment and its gateway profile id. */
792
+ runtimeGatewayDeploymentId?: string | null;
793
+ runtimeGatewayProfileId?: string | null;
764
794
  runLedgerIngressPrefixOrigin?: string | null;
765
795
  subject?: string | null;
766
796
  nowMs?: number;
767
797
  }): Promise<string> {
768
798
  const fixtureBehavior = validateFixtureBehavior(input.fixtureBehavior);
769
- if (!fixtureBehavior.ok) throw new Error(fixtureBehavior.error);
799
+ const runtimeGatewayDeploymentId =
800
+ input.runtimeGatewayDeploymentId?.trim() || null;
801
+ const runtimeGatewayProfileId = input.runtimeGatewayProfileId?.trim() || null;
802
+ if (
803
+ (runtimeGatewayDeploymentId === null) !==
804
+ (runtimeGatewayProfileId === null) ||
805
+ (runtimeGatewayDeploymentId !== null &&
806
+ !RUNTIME_GATEWAY_DEPLOYMENT_ID_CLAIM_PATTERN.test(
807
+ runtimeGatewayDeploymentId,
808
+ )) ||
809
+ (runtimeGatewayProfileId !== null &&
810
+ !RUNTIME_GATEWAY_PROFILE_CLAIM_PATTERN.test(runtimeGatewayProfileId))
811
+ ) {
812
+ throw new Error(
813
+ 'Runtime gateway token claims require a valid deployment id and profile id together.',
814
+ );
815
+ }
816
+ if (fixtureBehavior.ok === false) throw new Error(fixtureBehavior.error);
770
817
  if (fixtureBehavior.behavior && input.integrationMode !== 'fixture') {
771
818
  throw new Error(
772
819
  'fixtureBehavior requires workflow integration mode "fixture".',
@@ -841,6 +888,12 @@ export async function mintWorkflowRunExecutionToken(input: {
841
888
  ...(input.runtimeOrigin?.trim()
842
889
  ? { runtime_origin: new URL(input.runtimeOrigin).origin }
843
890
  : {}),
891
+ ...(runtimeGatewayDeploymentId && runtimeGatewayProfileId
892
+ ? {
893
+ runtime_gateway_deployment_id: runtimeGatewayDeploymentId,
894
+ runtime_gateway_profile: runtimeGatewayProfileId,
895
+ }
896
+ : {}),
844
897
  ...(input.runLedgerIngressPrefixOrigin?.trim()
845
898
  ? {
846
899
  run_ledger_ingress_prefix_origin: new URL(
@@ -73,6 +73,18 @@ export const PLAY_LAUNCH_ENVELOPE_FIELD_ROLES: {
73
73
  runLedgerExecutorToken: 'detail',
74
74
  runtimeAuthority: 'detail',
75
75
  runtimeApiBaseUrl: 'detail',
76
+ // Runtime gateway pin: hosting/transport, not customer intent. The URLs,
77
+ // deployment id and pin time name whichever deployment admitted the run, so
78
+ // a retry of the same launch through another deployment must deduplicate to
79
+ // the first admission (whose pin stands) rather than conflict. The profile
80
+ // id follows them: a profile changes where gateways run, never what the run
81
+ // computes, and keeping it out of the digest leaves every existing launch
82
+ // digest byte-identical.
83
+ runtimeGatewayProfileId: 'detail',
84
+ runtimeReceiptGatewayBaseUrl: 'detail',
85
+ runtimeExecutionGatewayBaseUrl: 'detail',
86
+ runtimeGatewayDeploymentId: 'detail',
87
+ runtimeGatewayPinnedAtMs: 'detail',
76
88
  arrayInputTerminalRetirementSupported: 'detail',
77
89
  arrayInputTerminalProjectionOrigin: 'detail',
78
90
  runtimeTokenOrigin: 'detail',
@@ -245,6 +245,19 @@ export interface PlayRunnerContextConfig extends RetainedPipelineCarrier {
245
245
  */
246
246
  executionGatewayBaseUrl?: string | null;
247
247
  receiptGatewayBaseUrl?: string | null;
248
+ /**
249
+ * Runtime gateway profile pin (`runtime-gateway-profile.ts`). Absent on
250
+ * unpinned runs. Set only by the worker from a validated launch pin; the
251
+ * gateway URLs above then name the pinned deployment.
252
+ */
253
+ runtimeGatewayProfileId?: string | null;
254
+ runtimeGatewayDeploymentId?: string | null;
255
+ /** Exact origin and gateway path prefixes that may receive the OIDC token. */
256
+ runtimeGatewayCredentialScope?:
257
+ | import('./runtime-gateway-sandbox-credential').RuntimeGatewayCredentialScope
258
+ | null;
259
+ /** Short-lived edge credential for the pinned gateway; renewed by the watchdog. */
260
+ runtimeGatewayOidcToken?: string | null;
248
261
  /**
249
262
  * Internal fixture-canary pin for a cordoned receipt-gateway candidate. This
250
263
  * is a signed launch fact, never a customer-authored or sandbox-supplied
@@ -229,3 +229,59 @@ export function buildAsyncPlayRequestFingerprint(input: {
229
229
  }),
230
230
  );
231
231
  }
232
+
233
+ /**
234
+ * Longest run id any runtime scope accepts. Play names are Postgres
235
+ * identifiers (at most 63 characters), so every built id is far below it.
236
+ */
237
+ export const PLAY_RUN_ID_MAX_LENGTH = 256;
238
+
239
+ const RUNTIME_SCOPE_RUN_ID_PATTERN = /^[A-Za-z0-9_.:@/-]+$/;
240
+
241
+ /**
242
+ * The one run-id check that may gate a request: a non-empty id of at most
243
+ * `PLAY_RUN_ID_MAX_LENGTH` characters from the path-safe alphabet. Run ids are
244
+ * path-shaped (`play/<family>/run/<suffix>`), so `/` is allowed. It is
245
+ * deliberately permissive: it never parses the id, so a scheduler row with an
246
+ * older or foreign id shape is still served.
247
+ */
248
+ export function isRuntimeScopeRunId(value: unknown): value is string {
249
+ return (
250
+ typeof value === 'string' &&
251
+ value.length > 0 &&
252
+ value.length <= PLAY_RUN_ID_MAX_LENGTH &&
253
+ RUNTIME_SCOPE_RUN_ID_PATTERN.test(value)
254
+ );
255
+ }
256
+
257
+ export type ParsedPlayRunId = Readonly<{
258
+ familyKey: string;
259
+ startedAtMs: number;
260
+ kind: 'root' | 'caller' | 'async' | 'rerun';
261
+ }>;
262
+
263
+ const PLAY_RUN_ID_PATTERN =
264
+ /^play\/([a-z0-9-]+(?:\/[a-z0-9-]+)*)\/run\/\d{8}t\d{6}-\d{3}(?:-[a-z0-9]{8}(-caller-[a-f0-9]{64})?|(-async-[a-f0-9]{20})|(-rerun-[a-f0-9]{20}))?$/;
265
+
266
+ /**
267
+ * Parse an id built by this module's builders. Diagnostic only: use
268
+ * `isRuntimeScopeRunId` to admit or refuse a request.
269
+ */
270
+ export function parsePlayRunId(value: unknown): ParsedPlayRunId | null {
271
+ if (!isRuntimeScopeRunId(value)) return null;
272
+ const match = PLAY_RUN_ID_PATTERN.exec(value);
273
+ if (!match) return null;
274
+ const startedAtMs = canonicalPlayRunStartedAtMs(value);
275
+ if (startedAtMs === null) return null;
276
+ return Object.freeze({
277
+ familyKey: match[1]!,
278
+ startedAtMs,
279
+ kind: match[2]
280
+ ? 'caller'
281
+ : match[3]
282
+ ? 'async'
283
+ : match[4]
284
+ ? 'rerun'
285
+ : 'root',
286
+ });
287
+ }