deepline 0.3.477 → 0.3.478

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 (165) hide show
  1. package/dist/bundling-sources/sdk/src/client-core.ts +5 -4
  2. package/dist/bundling-sources/sdk/src/http-core.ts +84 -3
  3. package/dist/bundling-sources/sdk/src/http.ts +2 -0
  4. package/dist/bundling-sources/sdk/src/play.ts +8 -2
  5. package/dist/bundling-sources/sdk/src/release.ts +1 -1
  6. package/dist/bundling-sources/shared_libs/observability/scheduled-jobs.json +18 -0
  7. package/dist/bundling-sources/shared_libs/play-runtime/context.ts +10 -2
  8. package/dist/bundling-sources/shared_libs/play-runtime/governor/app-runtime-rate-state-backend.ts +11 -1
  9. package/dist/bundling-sources/shared_libs/play-runtime/protocol.ts +5 -0
  10. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-payload-transport.ts +77 -4
  11. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-session-execution.ts +83 -1
  12. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona.ts +7 -0
  13. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres-rate-state.ts +60 -27
  14. package/dist/bundling-sources/shared_libs/plays/authoring-contract.ts +13 -12
  15. package/dist/bundling-sources/shared_libs/plays/bundling/index.ts +5 -2
  16. package/dist/bundling-sources/shared_libs/plays/sandbox-runtime-limits.ts +37 -12
  17. package/dist/bundling-sources/shared_libs/product-notifications/billing-sales.ts +1 -0
  18. package/dist/bundling-sources/shared_libs/product-notifications/catalog.ts +29 -0
  19. package/dist/bundling-sources/shared_libs/product-notifications/events.ts +15 -0
  20. package/dist/cli/{auth-XVXRRWIQ.mjs → auth-SA4DJCSO.mjs} +5 -5
  21. package/dist/cli/auth-U5SNVC5F.js +41 -0
  22. package/dist/cli/{billing-2H7GFJDT.js → billing-462SAHWX.js} +107 -87
  23. package/dist/cli/{billing-EOPUJ4JI.mjs → billing-Z4D35MV5.mjs} +34 -14
  24. package/dist/cli/{chunk-SG2SZQ4K.mjs → chunk-2FTUPGTN.mjs} +2 -2
  25. package/dist/cli/{chunk-NO7ZC2GV.mjs → chunk-2JS5DNVX.mjs} +5 -5
  26. package/dist/cli/{chunk-3UKKM6OS.js → chunk-2MSKG4ER.js} +7 -6
  27. package/dist/cli/{chunk-ISEUOYCB.mjs → chunk-3LTLQAU4.mjs} +4 -4
  28. package/dist/cli/{chunk-C2V2HQDW.mjs → chunk-3V7INABZ.mjs} +2 -2
  29. package/dist/cli/{chunk-C2AN2HTB.mjs → chunk-4C3TMIF3.mjs} +4 -4
  30. package/dist/cli/{chunk-2YNLW43I.mjs → chunk-4RJRGQ5Y.mjs} +2 -2
  31. package/dist/cli/{chunk-M2UL4ZS5.js → chunk-4RV7U3RP.js} +7 -7
  32. package/dist/cli/{chunk-PQQNMMWM.mjs → chunk-645RNF2Y.mjs} +1 -1
  33. package/dist/cli/{chunk-THMGJOR4.js → chunk-6EEMW7YP.js} +8 -8
  34. package/dist/cli/{chunk-YZA5UJXM.mjs → chunk-75DAGCEX.mjs} +1 -1
  35. package/dist/cli/{chunk-QODW5ILA.mjs → chunk-7HTWT3Z4.mjs} +2 -2
  36. package/dist/cli/chunk-7I4B6V2S.mjs +127 -0
  37. package/dist/cli/{chunk-MZSLFWOT.js → chunk-7UFFWPQ2.js} +13 -9
  38. package/dist/cli/{chunk-23EEVP5W.js → chunk-A5LPDB6N.js} +6 -6
  39. package/dist/cli/{chunk-NJMYX2TP.mjs → chunk-ABBP5ZCI.mjs} +3 -3
  40. package/dist/cli/{chunk-347EE4YE.js → chunk-AQYSZYNE.js} +8 -8
  41. package/dist/cli/{chunk-RGNMMDSJ.js → chunk-AYW242XF.js} +37 -37
  42. package/dist/cli/{chunk-6IJJCRE5.mjs → chunk-BLAZVZVD.mjs} +23 -5
  43. package/dist/cli/{chunk-ZDPL5AIK.js → chunk-D2LKEQKI.js} +5 -5
  44. package/dist/cli/{chunk-RLCAECZH.mjs → chunk-F2SJYUBW.mjs} +5 -5
  45. package/dist/cli/{chunk-XQLYPHYW.mjs → chunk-F44O4PEP.mjs} +1 -1
  46. package/dist/cli/{chunk-7CILZKLE.js → chunk-HMUBLAT4.js} +5 -5
  47. package/dist/cli/{chunk-UYA7LJGC.mjs → chunk-IL5AF6AR.mjs} +4 -2
  48. package/dist/cli/{chunk-4RAENEAX.js → chunk-IWYWZXCA.js} +53 -53
  49. package/dist/cli/{chunk-2QT6KN54.js → chunk-J3ZYRN5L.js} +10 -10
  50. package/dist/cli/{chunk-RHIFH3GD.mjs → chunk-JH775FF6.mjs} +1 -1
  51. package/dist/cli/{chunk-ACDXGOXE.js → chunk-KBBZXWXF.js} +63 -11
  52. package/dist/cli/{chunk-LJYTYNQZ.mjs → chunk-M5USVQ33.mjs} +55 -3
  53. package/dist/cli/{chunk-2GZFIWSA.mjs → chunk-N573OK4W.mjs} +4 -4
  54. package/dist/cli/{chunk-WFVEMDQL.js → chunk-OKAZHDYN.js} +4 -2
  55. package/dist/cli/{chunk-DFKHXZQ7.mjs → chunk-PHBOI24Y.mjs} +10 -10
  56. package/dist/cli/{chunk-WRHLAAGN.mjs → chunk-PLJV6SX4.mjs} +1 -1
  57. package/dist/cli/{chunk-C46DWB56.mjs → chunk-PPHHPAQV.mjs} +1 -1
  58. package/dist/cli/{chunk-UBNS6GSV.js → chunk-PZHRNSMU.js} +21 -21
  59. package/dist/cli/{chunk-KMXBZIKO.mjs → chunk-QB3Q73LP.mjs} +2 -2
  60. package/dist/cli/{chunk-255O6APS.js → chunk-QVZNUQAP.js} +2 -2
  61. package/dist/cli/{chunk-6KKDIISC.js → chunk-S3BKOCVB.js} +1 -1
  62. package/dist/cli/{chunk-JS4UO6G4.mjs → chunk-S7UEKKOX.mjs} +2 -1
  63. package/dist/cli/{chunk-KWQNNPMH.js → chunk-SCHE5QRN.js} +3 -3
  64. package/dist/cli/{chunk-E2CUSH56.js → chunk-SXY4DOVA.js} +16 -16
  65. package/dist/cli/{chunk-SVU2VR6Q.mjs → chunk-TLF3KGWG.mjs} +2 -2
  66. package/dist/cli/{chunk-LXKGZKTL.js → chunk-TQWI7LJX.js} +26 -26
  67. package/dist/cli/{chunk-NC52JG66.js → chunk-TW3TTKW5.js} +3 -3
  68. package/dist/cli/{chunk-R5FNCFEK.js → chunk-UXQVSDFP.js} +3 -3
  69. package/dist/cli/{chunk-DMWHEYZM.js → chunk-V7I65ME7.js} +2 -2
  70. package/dist/cli/{chunk-CH4VMDB5.js → chunk-VE25VUTE.js} +70 -52
  71. package/dist/cli/{chunk-3W6E3WVU.js → chunk-XFY3JOP2.js} +9 -9
  72. package/dist/cli/{chunk-75NLWBYQ.js → chunk-XOORR6P3.js} +93 -93
  73. package/dist/cli/chunk-YGCKMI5P.js +127 -0
  74. package/dist/cli/{chunk-3A7TDUZV.mjs → chunk-ZBSUXXZS.mjs} +13 -9
  75. package/dist/cli/{chunk-DS3DZUES.mjs → chunk-ZSU3C4ST.mjs} +2 -2
  76. package/dist/cli/command-docs.js +2 -2
  77. package/dist/cli/command-docs.mjs +1 -1
  78. package/dist/cli/{csv-IDRPTSSC.mjs → csv-3SNWBO5F.mjs} +4 -4
  79. package/dist/cli/{csv-ECB7TYR2.js → csv-LAYTDYIF.js} +13 -13
  80. package/dist/cli/{db-FOBZD44N.mjs → db-72JKGQSK.mjs} +6 -6
  81. package/dist/cli/{db-S74XZZ77.js → db-OOUOSURL.js} +27 -27
  82. package/dist/cli/describe-7HYV44MO.js +48 -0
  83. package/dist/cli/{describe-KMTPPI2J.mjs → describe-KDPNOEUJ.mjs} +17 -17
  84. package/dist/cli/describe-core.d.mts +3 -3
  85. package/dist/cli/describe-core.d.ts +3 -3
  86. package/dist/cli/{executions-4JAIVE2E.mjs → executions-O6JS3UKX.mjs} +6 -6
  87. package/dist/cli/{executions-ZE3JMNA4.js → executions-RJNMGJEE.js} +8 -8
  88. package/dist/cli/{feedback-W6VA47A3.js → feedback-FXB6NV3Y.js} +8 -8
  89. package/dist/cli/{feedback-EUX5PDBA.mjs → feedback-T3JH3CWC.mjs} +4 -4
  90. package/dist/cli/git-5LTKPXGN.js +25 -0
  91. package/dist/cli/{git-UOVG4PLH.mjs → git-6KAQSH5J.mjs} +5 -5
  92. package/dist/cli/index.js +161 -142
  93. package/dist/cli/index.mjs +65 -46
  94. package/dist/cli/{legacy-noops-ZBWUNFWV.mjs → legacy-noops-7HDGEGTK.mjs} +5 -5
  95. package/dist/cli/{legacy-noops-3H35EH5Y.js → legacy-noops-PAOGRKUK.js} +8 -8
  96. package/dist/cli/{monitors-PI3KPLR2.js → monitors-KQFI7TVJ.js} +91 -91
  97. package/dist/cli/{monitors-AYSGSUAK.mjs → monitors-LE2AYK3Z.mjs} +7 -7
  98. package/dist/cli/{org-MVS3Y6BK.js → org-J6XFHDJE.js} +72 -72
  99. package/dist/cli/{org-2BIG7U4V.mjs → org-Z4DMJ72I.mjs} +6 -6
  100. package/dist/cli/{pages-4TRRL24G.mjs → pages-5LYS6Y4I.mjs} +6 -6
  101. package/dist/cli/{pages-VB6FOVDE.js → pages-FIXBZQJG.js} +17 -17
  102. package/dist/cli/{play-BLT6IT2O.js → play-D7WPXADH.js} +585 -678
  103. package/dist/cli/{play-JR3VUOZM.mjs → play-GILXXIN7.mjs} +26 -119
  104. package/dist/cli/{providers-BBXIAGW4.js → providers-KN7YACT6.js} +9 -9
  105. package/dist/cli/{providers-547DPK4S.mjs → providers-OQWL4Q4W.mjs} +6 -6
  106. package/dist/cli/{quickstart-NTLXD7HS.mjs → quickstart-2LRIORFM.mjs} +4 -4
  107. package/dist/cli/{quickstart-RNPI5B6J.js → quickstart-M2OBP3W3.js} +6 -6
  108. package/dist/cli/{run-BCCEXBOG.js → run-6YZZO7VM.js} +36 -36
  109. package/dist/cli/{run-QZ4SFECD.mjs → run-GYRBKQZT.mjs} +22 -22
  110. package/dist/cli/search-OVKWA4AV.js +32 -0
  111. package/dist/cli/{search-PYNELH4C.mjs → search-VUPK6BNU.mjs} +7 -7
  112. package/dist/cli/{secrets-VD35LMYJ.js → secrets-RE3UMZB7.js} +15 -15
  113. package/dist/cli/{secrets-O5WGREQ7.mjs → secrets-ULRGU7NM.mjs} +6 -6
  114. package/dist/cli/{sessions-2TL6Z5J5.mjs → sessions-2ZZVJ3P2.mjs} +5 -5
  115. package/dist/cli/{sessions-NGGIBYXF.js → sessions-T4UMHNDW.js} +6 -6
  116. package/dist/cli/{settings-ERFNZRHO.js → settings-BRV6AYFM.js} +78 -78
  117. package/dist/cli/{settings-6KM74AJT.mjs → settings-PDY4TJU6.mjs} +11 -11
  118. package/dist/cli/{setup-Y3BN6XRS.mjs → setup-CXL6C5Z5.mjs} +9 -9
  119. package/dist/cli/{setup-6X7EJ6RG.js → setup-JONYJYBK.js} +44 -44
  120. package/dist/cli/{skills-OUBQASHI.mjs → skills-TOMVQD5O.mjs} +7 -7
  121. package/dist/cli/skills-UK5AK35I.js +33 -0
  122. package/dist/cli/{tools-EELZ5FF5.mjs → tools-B2LJK4MM.mjs} +16 -16
  123. package/dist/cli/tools-HH6E5G7J.js +55 -0
  124. package/dist/cli/{update-TX7SW32Y.mjs → update-CD6T2REC.mjs} +9 -9
  125. package/dist/cli/update-EGXT3EIJ.js +33 -0
  126. package/dist/cli/{workflow-5AI2BJA7.js → workflow-PZML43E2.js} +17 -17
  127. package/dist/cli/{workflow-PUNQG7LG.mjs → workflow-ZAOBP6I7.mjs} +7 -7
  128. package/dist/{client-AjmfA5nR.d.mts → client-B1s1yJdT.d.mts} +1 -1
  129. package/dist/{client-DMyY-QL8.d.ts → client-DqUseRzd.d.ts} +1 -1
  130. package/dist/{client-core-C705vFyV.d.ts → client-core-Bd7tP9Uz.d.ts} +45 -6
  131. package/dist/{client-core-CpBbvLEX.d.mts → client-core-BijQEQ70.d.mts} +45 -6
  132. package/dist/{compiler-manifest-hqIAukR0.d.mts → compiler-manifest-B1m5tRzz.d.mts} +23 -17
  133. package/dist/{compiler-manifest-hqIAukR0.d.ts → compiler-manifest-B1m5tRzz.d.ts} +23 -17
  134. package/dist/{errors-CRO2qQ6k.d.ts → errors-3g71OMXy.d.ts} +1 -1
  135. package/dist/{errors-DIHVetNY.d.mts → errors-QiC6am-q.d.mts} +1 -1
  136. package/dist/{index-DVZ_X4Gb.d.mts → index-Biz5toO4.d.mts} +1 -1
  137. package/dist/{index-B8DVoeYt.d.ts → index-CIBiwzhK.d.ts} +1 -1
  138. package/dist/index.d.mts +15 -9
  139. package/dist/index.d.ts +15 -9
  140. package/dist/index.js +9 -9
  141. package/dist/index.mjs +6 -6
  142. package/dist/install-integrity.json +112 -110
  143. package/dist/plays/bundle-play-file.d.mts +3 -3
  144. package/dist/plays/bundle-play-file.d.ts +3 -3
  145. package/dist/plays/bundle-play-file.mjs +2 -1
  146. package/dist/plays/play-description.d.mts +2 -2
  147. package/dist/plays/play-description.d.ts +2 -2
  148. package/dist/plays/run-request.d.mts +2 -2
  149. package/dist/plays/run-request.d.ts +2 -2
  150. package/dist/release.d.mts +1 -1
  151. package/dist/release.d.ts +1 -1
  152. package/dist/release.js +2 -2
  153. package/dist/release.mjs +1 -1
  154. package/dist/server.d.mts +4 -4
  155. package/dist/server.d.ts +4 -4
  156. package/dist/server.js +5 -5
  157. package/dist/server.mjs +3 -3
  158. package/package.json +1 -1
  159. package/dist/cli/auth-QITP34OX.js +0 -41
  160. package/dist/cli/describe-PI7HCT7K.js +0 -48
  161. package/dist/cli/git-NDOGCQZY.js +0 -25
  162. package/dist/cli/search-YHEICYQL.js +0 -32
  163. package/dist/cli/skills-F7MPYC4P.js +0 -33
  164. package/dist/cli/tools-MCWDAK53.js +0 -55
  165. package/dist/cli/update-G5BRJOVT.js +0 -33
@@ -328,13 +328,13 @@ async function queryRateStateWithProbeBaseline<
328
328
  parameters: unknown[],
329
329
  ) {
330
330
  try {
331
- return await client.query<Row>(sql(true), parameters);
331
+ return await queryBoundedRateState<Row>(client, sql(true), parameters);
332
332
  } catch (error) {
333
333
  if (!isMissingProbeBaselineColumnError(error)) throw error;
334
334
  // PostgreSQL rejects the statement before any grant or reservation writes.
335
335
  // Retry only that statement; previously accepted success feedback is not
336
336
  // applied twice. No DDL, migration preflight, or global schema floor.
337
- return await client.query<Row>(sql(false), parameters);
337
+ return await queryBoundedRateState<Row>(client, sql(false), parameters);
338
338
  }
339
339
  }
340
340
 
@@ -1891,6 +1891,26 @@ async function boundRateStateTransaction(
1891
1891
  );
1892
1892
  }
1893
1893
 
1894
+ /** Bound one formerly-autocommit statement without leaking session settings. */
1895
+ async function queryBoundedRateState<
1896
+ Row extends Record<string, unknown> = Record<string, unknown>,
1897
+ >(client: PostgresSchedulerQueryClient, sql: string, parameters?: unknown[]) {
1898
+ await client.query('BEGIN');
1899
+ try {
1900
+ await boundRateStateTransaction(client);
1901
+ const result = await client.query<Row>(sql, parameters);
1902
+ await client.query('COMMIT');
1903
+ return result;
1904
+ } catch (error) {
1905
+ try {
1906
+ await client.query('ROLLBACK');
1907
+ } catch {
1908
+ // Preserve the original statement error.
1909
+ }
1910
+ throw rateStateLockBusyOr(error);
1911
+ }
1912
+ }
1913
+
1894
1914
  /** A scope row another transaction still holds after the lock budget. */
1895
1915
  class RateStateLockBusyError extends Error {
1896
1916
  constructor(cause: unknown) {
@@ -2530,19 +2550,23 @@ export async function acquirePostgresRateState(
2530
2550
  ): Promise<PlayRunnerRateStateAcquireResult> {
2531
2551
  return await withRateStateAvailabilityGuard(input, async () => {
2532
2552
  try {
2533
- return await acquireRateStateStatements(client, input);
2553
+ const result = await acquireRateStateStatements(client, input);
2554
+ return {
2555
+ ...result,
2556
+ acknowledgedObservationBatch: concurrencyObservationBatchFrom(
2557
+ input.concurrencyObservationBatch,
2558
+ ),
2559
+ };
2534
2560
  } catch (error) {
2535
- // A store error spends the runner's fail-closed retry ladder, so a stuck
2536
- // holder elsewhere would fail this run. A busy scope is not a broken
2537
- // store: answer as for any other wait. Feedback rolled back with a busy
2538
- // feedback step is not re-sent, because the runner acknowledges any
2539
- // answer. A lost success sample only slows the next ramp, and its batch
2540
- // identity still prevents a double apply.
2561
+ // A busy scope is normal backpressure. A rolled-back feedback fold must
2562
+ // keep its exact batch on the runner; a committed fold is safe to replay
2563
+ // after an uncertain grant because the observer watermark deduplicates it.
2541
2564
  if (!(error instanceof RateStateLockBusyError)) throw error;
2542
2565
  return {
2543
2566
  granted: 0,
2544
2567
  waitMs: RATE_STATE_LOCK_BUSY_WAIT_MS,
2545
2568
  leaseIds: [],
2569
+ acknowledgedObservationBatch: null,
2546
2570
  };
2547
2571
  }
2548
2572
  });
@@ -2560,10 +2584,11 @@ export async function validatePostgresRateStatePermit(
2560
2584
  },
2561
2585
  ): Promise<PlayRunnerRateStateValidateResult> {
2562
2586
  return await withRateStateAvailabilityGuard(input, async () => {
2563
- const result = await client.query<{
2587
+ const result = await queryBoundedRateState<{
2564
2588
  server_now_ms: string | number;
2565
2589
  retry_at_ms: string | number;
2566
2590
  }>(
2591
+ client,
2567
2592
  `
2568
2593
  WITH now_value AS (
2569
2594
  SELECT COALESCE(
@@ -2621,13 +2646,14 @@ export async function claimPostgresProviderDispatch(
2621
2646
  }
2622
2647
  > {
2623
2648
  return withRateStateAvailabilityGuard(input, async () => {
2624
- const result = await client.query<{
2649
+ const result = await queryBoundedRateState<{
2625
2650
  server_now_ms: string | number;
2626
2651
  retry_at_ms: string | number;
2627
2652
  allowed: boolean;
2628
2653
  cadence_wait: boolean;
2629
2654
  stale_permit: boolean;
2630
2655
  }>(
2656
+ client,
2631
2657
  `
2632
2658
  WITH now_value AS (
2633
2659
  SELECT COALESCE($2::bigint,
@@ -2884,11 +2910,12 @@ async function concurrencyThrottleFrom(
2884
2910
  if (concurrencyRuleIds.length === 0) {
2885
2911
  return { attribution: 'not_observed', observations: [], batch: null };
2886
2912
  }
2887
- const attributedLease = await client.query<{
2913
+ const attributedLease = await queryBoundedRateState<{
2888
2914
  in_flight_at_start: number | null;
2889
2915
  target_requests_per_second: number | null;
2890
2916
  minimum_rtt_ms: number | null;
2891
2917
  }>(
2918
+ client,
2892
2919
  `
2893
2920
  SELECT
2894
2921
  in_flight_at_start,
@@ -2964,8 +2991,6 @@ async function applyConcurrencyObservations(
2964
2991
  rules: readonly AcquirePacingRule[],
2965
2992
  observations: readonly ConcurrencyObservation[],
2966
2993
  batch: ConcurrencyObservationBatch | null,
2967
- /** Acquire bounds its lock waits; release and penalty keep their behaviour. */
2968
- options: { bounded?: boolean } = {},
2969
2994
  ): Promise<{
2970
2995
  disposition: 'unbatched' | 'applied' | 'already_applied';
2971
2996
  ruleCount: number;
@@ -2978,13 +3003,17 @@ async function applyConcurrencyObservations(
2978
3003
  const concurrencyRules = rules.filter(
2979
3004
  (rule) => rule.maxConcurrency != null && rule.maxConcurrency > 0,
2980
3005
  );
2981
- const countSuccesses = async () => {
3006
+ const countSuccesses = async (bounded = false) => {
2982
3007
  const successes = Math.max(
2983
3008
  0,
2984
3009
  Math.min(1_000_000, Math.trunc(input.observedSuccesses ?? 0)),
2985
3010
  );
2986
3011
  if (successes <= 0) return;
2987
- await client.query(
3012
+ const query = bounded
3013
+ ? (sql: string, params: unknown[]) =>
3014
+ queryBoundedRateState(client, sql, params)
3015
+ : (sql: string, params: unknown[]) => client.query(sql, params);
3016
+ await query(
2988
3017
  `
2989
3018
  UPDATE ${scopeHoldTableName(input)}
2990
3019
  SET rate_successes = rate_successes + $2::bigint,
@@ -3009,7 +3038,7 @@ async function applyConcurrencyObservations(
3009
3038
  if (batch === null) {
3010
3039
  // Legacy writers have no observation identity. Preserve their success
3011
3040
  // input; new writers always supply the replay-safe batch below.
3012
- await countSuccesses();
3041
+ await countSuccesses(true);
3013
3042
  return {
3014
3043
  disposition: 'unbatched',
3015
3044
  ruleCount: 0,
@@ -3023,7 +3052,7 @@ async function applyConcurrencyObservations(
3023
3052
 
3024
3053
  await client.query('BEGIN');
3025
3054
  try {
3026
- if (options.bounded) await boundRateStateTransaction(client);
3055
+ await boundRateStateTransaction(client);
3027
3056
  const accepted = await client.query<{ last_sequence: number }>(
3028
3057
  `
3029
3058
  WITH now_value AS (
@@ -3232,7 +3261,7 @@ async function applyConcurrencyObservations(
3232
3261
  } catch {
3233
3262
  // Preserve the original controller/storage error.
3234
3263
  }
3235
- throw options.bounded ? rateStateLockBusyOr(error) : error;
3264
+ throw rateStateLockBusyOr(error);
3236
3265
  }
3237
3266
  }
3238
3267
 
@@ -3259,8 +3288,8 @@ async function acquireRateStateStatements(
3259
3288
  : acquirePureRate(client, grantInput, rules, seeds, requested);
3260
3289
 
3261
3290
  // Cold path only: seed missing rows / refresh changed configuration. A warm
3262
- // pure-rate acquire is exactly one statement. Concurrency-bearing acquires
3263
- // take the scope lock before the lease-count statement gets its snapshot.
3291
+ // pure-rate acquire has one grant statement in a bounded transaction.
3292
+ // Concurrency-bearing acquires lock the scope before the lease snapshot.
3264
3293
  let seeded = false;
3265
3294
  if (!warmRateBuckets.has(warmKey)) {
3266
3295
  await seedBucketRows(client, input, seeds, nowMs);
@@ -3272,7 +3301,6 @@ async function acquireRateStateStatements(
3272
3301
  rules,
3273
3302
  concurrencyObservationsFrom(input.concurrencyObservations),
3274
3303
  concurrencyObservationBatchFrom(input.concurrencyObservationBatch),
3275
- { bounded: true },
3276
3304
  );
3277
3305
  // The buffered success count and RTT observations share one identity. If a
3278
3306
  // runner lost the prior acquire response, its retry still needs a fresh
@@ -3376,7 +3404,8 @@ async function releaseRateStateStatements(
3376
3404
  // no scope owner. Create its uninitialized hold before taking the normal
3377
3405
  // hold -> reservation -> rule lock path; seedBucketRows will initialize its
3378
3406
  // learner on the next admission and preserve this inherited deadline.
3379
- await client.query(
3407
+ await queryBoundedRateState(
3408
+ client,
3380
3409
  `
3381
3410
  INSERT INTO ${scopeHoldTableName(input)} (bucket_id, retry_at_ms)
3382
3411
  SELECT bucket_id, MAX(claimed_retry_at_ms)
@@ -3392,7 +3421,8 @@ async function releaseRateStateStatements(
3392
3421
  // a bucket, and an HTTP retry sees no reservation left to refund. The shared
3393
3422
  // dispatch cursor deliberately stays monotonic, so cancellation can never
3394
3423
  // compress provider starts into a burst.
3395
- await client.query(
3424
+ await queryBoundedRateState(
3425
+ client,
3396
3426
  `
3397
3427
  WITH now_value AS (
3398
3428
  SELECT COALESCE(
@@ -3478,7 +3508,8 @@ async function releaseRateStateStatements(
3478
3508
  ];
3479
3509
  if (leaseIds.length === 0) return;
3480
3510
  // DELETE by holder token is naturally idempotent, including HTTP retries.
3481
- await client.query(
3511
+ await queryBoundedRateState(
3512
+ client,
3482
3513
  `
3483
3514
  DELETE FROM ${concurrencyLeaseTableName(input)}
3484
3515
  WHERE bucket_id = $1
@@ -3536,11 +3567,12 @@ async function penalizeRateStateStatements(
3536
3567
  // min_rps.
3537
3568
  // - seen_backpressure flips the ramp from slow-start (x2) to additive.
3538
3569
  // - tokens drained: no more grants until refill re-accrues past the cooldown.
3539
- await client.query(
3570
+ await queryBoundedRateState(
3571
+ client,
3540
3572
  `INSERT INTO ${scopeHoldTableName(input)} (bucket_id) VALUES ($1) ON CONFLICT DO NOTHING`,
3541
3573
  [input.bucketId],
3542
3574
  );
3543
- const rateStateResult = await client.query<{
3575
+ const rateStateResult = await queryBoundedRateState<{
3544
3576
  retry_at_ms: string | number | null;
3545
3577
  cool_until_ms: string | number | null;
3546
3578
  rate_rule_count: string | number;
@@ -3552,6 +3584,7 @@ async function penalizeRateStateStatements(
3552
3584
  observation_cycle_max_ms: string | number | null;
3553
3585
  confirmed_successes_max: string | number | null;
3554
3586
  }>(
3587
+ client,
3555
3588
  `
3556
3589
  WITH now_value AS (
3557
3590
  SELECT COALESCE(
@@ -3,9 +3,10 @@ export type { BillingEntitlements } from '../integration-contracts/billing-entit
3
3
  import { Type, type Static, type TSchema } from '@sinclair/typebox';
4
4
  import { Value } from '@sinclair/typebox/value';
5
5
  import type { PreviousCell } from './cell-staleness';
6
- import type {
7
- PlaySandboxRuntimeLimits,
8
- PlaySandboxSize,
6
+ import {
7
+ PLAY_SANDBOX_SIZE_INPUTS,
8
+ type PlaySandboxRuntimeLimits,
9
+ type PlaySandboxSizeInput,
9
10
  } from './sandbox-runtime-limits';
10
11
  import type {
11
12
  BasicToolExecuteResult,
@@ -867,7 +868,7 @@ export type PlayAuthoringBindings<TInput = Record<string, unknown>> = {
867
868
  */
868
869
  runtime?: {
869
870
  timeout?: string;
870
- size?: PlaySandboxSize;
871
+ size?: PlaySandboxSizeInput;
871
872
  };
872
873
  /**
873
874
  * Start at most one run of this Play per window, whatever started it.
@@ -2971,11 +2972,9 @@ export const PLAY_AUTHORING_FIELD_REGISTRY = {
2971
2972
  'rateLimit.every must be a static duration from "10s" to "24h", such as "5m".',
2972
2973
  },
2973
2974
  'runtime.size': {
2974
- schema: Type.Union([
2975
- Type.Literal('standard'),
2976
- Type.Literal('large'),
2977
- Type.Literal('xlarge'),
2978
- ]),
2975
+ schema: Type.Union(
2976
+ PLAY_SANDBOX_SIZE_INPUTS.map((size) => Type.Literal(size)),
2977
+ ),
2979
2978
  fixtures: {
2980
2979
  valid: 'large',
2981
2980
  invalid: 'xxlarge',
@@ -2983,14 +2982,16 @@ export const PLAY_AUTHORING_FIELD_REGISTRY = {
2983
2982
  unresolved: { expression: 'size' },
2984
2983
  edition1: 'standard',
2985
2984
  },
2986
- referenceType: "'standard' | 'large' | 'xlarge'",
2985
+ referenceType: PLAY_SANDBOX_SIZE_INPUTS.map((size) => `'${size}'`).join(
2986
+ ' | ',
2987
+ ),
2987
2988
  required: false,
2988
2989
  resolution: 'static-required',
2989
2990
  issueCode: 'play_authoring_binding_invalid',
2990
2991
  description:
2991
- 'Deepline-managed sandbox size: standard (1 GiB memory, 1 CPU), large (4 GiB, 2 CPU), or xlarge (8 GiB, 4 CPU). Standard is the default. Compute pricing follows the workspace plan and selected size.',
2992
+ 'Deepline-managed sandbox size: standard or 1gb (1 GiB memory, 1 CPU), large or 4gb (4 GiB, 2 CPU), or xlarge or 8gb (8 GiB, 4 CPU). Standard is the default. Each alias selects the same resource profile and compute price as its named size.',
2992
2993
  errorMessage:
2993
- 'runtime.size must be the static literal "standard", "large", or "xlarge".',
2994
+ 'runtime.size must be the static literal "standard", "large", "xlarge", "1gb", "4gb", or "8gb".',
2994
2995
  },
2995
2996
  'ctx.customerDb.query.statement': {
2996
2997
  schema: Type.Union([
@@ -57,7 +57,10 @@ export {
57
57
  type DocflowSymbolResolution,
58
58
  } from '../docflow-binding';
59
59
  import type { ToolExecutionErrorSchemaVersion } from '../tool-execution-error';
60
- import type { PlaySandboxRuntimeDeclaration } from '../sandbox-runtime-limits';
60
+ import {
61
+ SUPPORTED_PLAY_SANDBOX_SIZES,
62
+ type PlaySandboxRuntimeDeclaration,
63
+ } from '../sandbox-runtime-limits';
61
64
  import { validatePlaySourceFilesHaveNoInlineSecrets } from '../secret-guardrails';
62
65
  import { MAX_PLAY_BUNDLE_BYTES } from './limits';
63
66
  import {
@@ -1125,7 +1128,7 @@ function sandboxRuntimeDeclarationFromOptions(
1125
1128
  if (unsupportedProperties.length > 0) {
1126
1129
  throw new Error(
1127
1130
  `Unsupported runtime sandbox option${unsupportedProperties.length === 1 ? '' : 's'} "${unsupportedProperties.join('", "')}". ` +
1128
- 'Use runtime.size with a Deepline prebuilt sandbox. Supported sizes: "standard", "large", or "xlarge".',
1131
+ `Use runtime.size with a Deepline prebuilt sandbox. Supported sizes: ${SUPPORTED_PLAY_SANDBOX_SIZES}.`,
1129
1132
  );
1130
1133
  }
1131
1134
  const timeout = resolveStaticProperty(runtime.value, 'timeout', context);
@@ -28,6 +28,23 @@ export const PLAY_SANDBOX_SIZE_LIMITS = {
28
28
  Omit<PlaySandboxRuntimeLimits, 'timeoutSeconds'>
29
29
  >;
30
30
 
31
+ export const PLAY_SANDBOX_SIZE_ALIASES = {
32
+ '1gb': 'standard',
33
+ '4gb': 'large',
34
+ '8gb': 'xlarge',
35
+ } as const satisfies Record<string, PlaySandboxSize>;
36
+
37
+ export type PlaySandboxSizeInput =
38
+ | PlaySandboxSize
39
+ | keyof typeof PLAY_SANDBOX_SIZE_ALIASES;
40
+
41
+ export const PLAY_SANDBOX_SIZE_INPUTS: readonly PlaySandboxSizeInput[] = [
42
+ ...(Object.keys(PLAY_SANDBOX_SIZE_LIMITS) as PlaySandboxSize[]),
43
+ ...(Object.keys(
44
+ PLAY_SANDBOX_SIZE_ALIASES,
45
+ ) as (keyof typeof PLAY_SANDBOX_SIZE_ALIASES)[]),
46
+ ];
47
+
31
48
  export const STANDARD_PLAY_SANDBOX_RUNTIME_LIMITS: PlaySandboxRuntimeLimits = {
32
49
  timeoutSeconds: 30 * 60,
33
50
  ...PLAY_SANDBOX_SIZE_LIMITS.standard,
@@ -77,15 +94,23 @@ export function playSandboxSizeForLimits(
77
94
  );
78
95
  }
79
96
 
80
- const supportedPlaySandboxSizes = Object.keys(PLAY_SANDBOX_SIZE_LIMITS).join(
81
- ', ',
82
- );
97
+ export const SUPPORTED_PLAY_SANDBOX_SIZES = PLAY_SANDBOX_SIZE_INPUTS.join(', ');
83
98
 
84
99
  export type PlaySandboxRuntimeDeclaration = {
85
100
  timeout?: string;
86
- size?: PlaySandboxSize;
101
+ size?: PlaySandboxSizeInput;
87
102
  };
88
103
 
104
+ function normalizePlaySandboxSize(value: unknown): PlaySandboxSize | null {
105
+ if (typeof value !== 'string') return null;
106
+ if (Object.hasOwn(PLAY_SANDBOX_SIZE_LIMITS, value)) {
107
+ return value as PlaySandboxSize;
108
+ }
109
+ return Object.hasOwn(PLAY_SANDBOX_SIZE_ALIASES, value)
110
+ ? PLAY_SANDBOX_SIZE_ALIASES[value as keyof typeof PLAY_SANDBOX_SIZE_ALIASES]
111
+ : null;
112
+ }
113
+
89
114
  function parseTimeout(value: string): number | null {
90
115
  const match = /^(\d+)\s*([mh])$/i.exec(value.trim());
91
116
  if (!match) return null;
@@ -100,7 +125,7 @@ export function validatePlaySandboxRuntimeLimits(
100
125
  if (!playSandboxSizeForLimits(value)) {
101
126
  throw new Error(
102
127
  `Unsupported runtime sandbox resources: cpu=${value.cpu} memoryGiB=${value.memoryGiB} diskGiB=${value.diskGiB}. ` +
103
- `Use runtime.size with a Deepline prebuilt sandbox. Supported sizes: ${supportedPlaySandboxSizes}.`,
128
+ `Use runtime.size with a Deepline prebuilt sandbox. Supported sizes: ${SUPPORTED_PLAY_SANDBOX_SIZES}.`,
104
129
  );
105
130
  }
106
131
  if (
@@ -130,15 +155,16 @@ export function resolvePlaySandboxRuntimeLimits(
130
155
  if (unsupportedProperties.length > 0) {
131
156
  throw new Error(
132
157
  `Unsupported runtime sandbox option${unsupportedProperties.length === 1 ? '' : 's'}: ${unsupportedProperties.join(', ')}. ` +
133
- `Use runtime.size with a Deepline prebuilt sandbox. Supported sizes: ${supportedPlaySandboxSizes}.`,
158
+ `Use runtime.size with a Deepline prebuilt sandbox. Supported sizes: ${SUPPORTED_PLAY_SANDBOX_SIZES}.`,
134
159
  );
135
160
  }
136
- if (
137
- declaration.size !== undefined &&
138
- !Object.hasOwn(PLAY_SANDBOX_SIZE_LIMITS, declaration.size)
139
- ) {
161
+ const size =
162
+ declaration.size === undefined
163
+ ? 'standard'
164
+ : normalizePlaySandboxSize(declaration.size);
165
+ if (!size) {
140
166
  throw new Error(
141
- `Unsupported runtime sandbox size "${String(declaration.size)}". Supported sizes: ${supportedPlaySandboxSizes}.`,
167
+ `Unsupported runtime sandbox size "${String(declaration.size)}". Supported sizes: ${SUPPORTED_PLAY_SANDBOX_SIZES}.`,
142
168
  );
143
169
  }
144
170
  const timeoutSeconds = declaration.timeout
@@ -149,7 +175,6 @@ export function resolvePlaySandboxRuntimeLimits(
149
175
  'Invalid runtime sandbox timeout. Use timeout like "90m" or "2h".',
150
176
  );
151
177
  }
152
- const size = declaration.size ?? 'standard';
153
178
  return validatePlaySandboxRuntimeLimits({
154
179
  timeoutSeconds,
155
180
  ...PLAY_SANDBOX_SIZE_LIMITS[size],
@@ -44,6 +44,7 @@ export const BILLING_SALES_RULE_KEYS: readonly string[] = [
44
44
  'internal.billing.usage_charge',
45
45
  'internal.billing.credit_purchase',
46
46
  'internal.billing.paid_plan',
47
+ 'internal.billing.allowance_exhausted',
47
48
  ...BILLING_DELIVERY_LATE_RULE_KEYS,
48
49
  ];
49
50
 
@@ -1035,6 +1035,35 @@ const PRODUCT_NOTIFICATION_TYPE_REGISTRY = [
1035
1035
  }),
1036
1036
  },
1037
1037
  },
1038
+ {
1039
+ id: 'internal.billing.allowance_exhausted',
1040
+ eventName: ProductNotificationEvent.BillingAllowanceExhausted,
1041
+ requiredFilter: {},
1042
+ allowedTriggers: ['each_match'],
1043
+ catalog: undefined,
1044
+ shadow: true,
1045
+ rule: {
1046
+ default: {
1047
+ ruleKey: 'internal.billing.allowance_exhausted',
1048
+ groupKey: BILLING_SALES_GROUP_KEY,
1049
+ },
1050
+ create: (_input, base) => ({
1051
+ ...base,
1052
+ repeatMode: 'every_match',
1053
+ trigger: { kind: 'each_match' },
1054
+ }),
1055
+ present: ({ payload }) => ({
1056
+ title: `Free allowance reached · ${payload.allowance}`,
1057
+ summary: [{ workspace: true }, ` used its included ${payload.limit}.`],
1058
+ details: [
1059
+ `Allowance period ends ${new Date(Number(payload.resetsAt)).toISOString()} (UTC).`,
1060
+ ],
1061
+ targetUrl: String(payload.targetUrl),
1062
+ subjectKind: 'workspace',
1063
+ subjectId: String(payload.accountId),
1064
+ }),
1065
+ },
1066
+ },
1038
1067
  lateCreditDeliveryRegistration(
1039
1068
  BILLING_PURCHASE_LATE_RULE_KEY,
1040
1069
  ProductNotificationEvent.BillingPurchaseLate,
@@ -33,6 +33,7 @@ export const ProductNotificationEvent = {
33
33
  BillingPurchaseLate: 'billing.purchase.late',
34
34
  BillingRenewalLate: 'billing.renewal.late',
35
35
  BillingUsageChargeObserved: 'billing.usage.charge_observed',
36
+ BillingAllowanceExhausted: 'billing.allowance.exhausted',
36
37
  MonitorLifecycleChanged: 'monitor.lifecycle.changed',
37
38
  PlayLifecycleChanged: 'play.lifecycle.changed',
38
39
  PlayRunCompleted: 'play.run.completed',
@@ -78,6 +79,7 @@ export const PRODUCT_NOTIFICATION_EVENT_NAMES = [
78
79
  ProductNotificationEvent.BillingPurchaseLate,
79
80
  ProductNotificationEvent.BillingRenewalLate,
80
81
  ProductNotificationEvent.BillingUsageChargeObserved,
82
+ ProductNotificationEvent.BillingAllowanceExhausted,
81
83
  ] as const;
82
84
 
83
85
  export const PRODUCT_NOTIFICATION_COMPATIBILITY_EVENT_NAMES = [
@@ -283,6 +285,19 @@ export const PRODUCT_NOTIFICATION_EVENT_DEFINITIONS: readonly ProductNotificatio
283
285
  orderingSubjectFact: 'chargeId',
284
286
  allowedTriggers: ['each_match'],
285
287
  },
288
+ {
289
+ eventName: ProductNotificationEvent.BillingAllowanceExhausted,
290
+ producerKey: ProductNotificationProducerKey.BillingUsage,
291
+ requiredFacts: {
292
+ accountId: 'string',
293
+ allowance: 'string',
294
+ limit: 'string',
295
+ resetsAt: 'number',
296
+ targetUrl: 'string',
297
+ },
298
+ orderingSubjectFact: 'accountId',
299
+ allowedTriggers: ['each_match'],
300
+ },
286
301
  {
287
302
  eventName: ProductNotificationEvent.BillingRenewalLate,
288
303
  producerKey: ProductNotificationProducerKey.BillingPurchases,
@@ -13,14 +13,14 @@ import {
13
13
  reportSetupCompleted,
14
14
  resolvePendingAuthClaimForResume,
15
15
  statusBannerLine
16
- } from "./chunk-6IJJCRE5.mjs";
17
- import "./chunk-QODW5ILA.mjs";
18
- import "./chunk-YZA5UJXM.mjs";
19
- import "./chunk-LJYTYNQZ.mjs";
16
+ } from "./chunk-BLAZVZVD.mjs";
17
+ import "./chunk-7HTWT3Z4.mjs";
18
+ import "./chunk-75DAGCEX.mjs";
19
+ import "./chunk-M5USVQ33.mjs";
20
20
  import "./chunk-4QF2K7TM.mjs";
21
21
  import "./chunk-DLIRSHV6.mjs";
22
22
  import "./chunk-HBL4PM5Q.mjs";
23
- import "./chunk-PQQNMMWM.mjs";
23
+ import "./chunk-645RNF2Y.mjs";
24
24
  import "./chunk-WZYKRD7T.mjs";
25
25
  import "./chunk-KRD6H754.mjs";
26
26
  export {
@@ -0,0 +1,41 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+
4
+
5
+
6
+
7
+
8
+
9
+
10
+
11
+
12
+
13
+
14
+
15
+
16
+ var _chunkVE25VUTEjs = require('./chunk-VE25VUTE.js');
17
+ require('./chunk-4RV7U3RP.js');
18
+ require('./chunk-TW3TTKW5.js');
19
+ require('./chunk-KBBZXWXF.js');
20
+ require('./chunk-ALJJRZNJ.js');
21
+ require('./chunk-XNYIZMNQ.js');
22
+ require('./chunk-DIAWYWT5.js');
23
+ require('./chunk-S3BKOCVB.js');
24
+ require('./chunk-OG64RBAC.js');
25
+ require('./chunk-COGTRVWW.js');
26
+
27
+
28
+
29
+
30
+
31
+
32
+
33
+
34
+
35
+
36
+
37
+
38
+
39
+
40
+
41
+ exports.EXIT_WORKSPACE_MISMATCH = _chunkVE25VUTEjs.EXIT_WORKSPACE_MISMATCH; exports.authStatusLine = _chunkVE25VUTEjs.authStatusLine; exports.clearPendingClaim = _chunkVE25VUTEjs.clearPendingClaim; exports.clearSatisfiedPendingClaim = _chunkVE25VUTEjs.clearSatisfiedPendingClaim; exports.handleRegister = _chunkVE25VUTEjs.handleRegister; exports.handleStatus = _chunkVE25VUTEjs.handleStatus; exports.handleWait = _chunkVE25VUTEjs.handleWait; exports.httpJson = _chunkVE25VUTEjs.httpJson; exports.readPendingAuthClaim = _chunkVE25VUTEjs.readPendingAuthClaim; exports.readStatusBanner = _chunkVE25VUTEjs.readStatusBanner; exports.registerAuthCommands = _chunkVE25VUTEjs.registerAuthCommands; exports.reportSetupCompleted = _chunkVE25VUTEjs.reportSetupCompleted; exports.resolvePendingAuthClaimForResume = _chunkVE25VUTEjs.resolvePendingAuthClaimForResume; exports.statusBannerLine = _chunkVE25VUTEjs.statusBannerLine;