deepline 0.3.551 → 0.3.552

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 (167) hide show
  1. package/dist/bundling-sources/sdk/src/client-core.ts +23 -0
  2. package/dist/bundling-sources/sdk/src/http-core.ts +6 -2
  3. package/dist/bundling-sources/sdk/src/release.ts +1 -1
  4. package/dist/bundling-sources/sdk/src/runs/watch-polling.ts +58 -29
  5. package/dist/bundling-sources/shared_libs/monitors/package.json +2 -0
  6. package/dist/bundling-sources/shared_libs/monitors/provider-monitor-upstream-identity.ts +80 -13
  7. package/dist/bundling-sources/shared_libs/monitors/tamradar-countries.ts +285 -0
  8. package/dist/bundling-sources/shared_libs/observability/scheduled-jobs.json +144 -0
  9. package/dist/bundling-sources/shared_libs/play-runtime/context.ts +137 -0
  10. package/dist/bundling-sources/shared_libs/play-runtime/durable-runs-rollout.ts +14 -2
  11. package/dist/bundling-sources/shared_libs/play-runtime/experiment-switches.ts +20 -16
  12. package/dist/bundling-sources/shared_libs/play-runtime/runner-app/index.ts +47 -14
  13. package/dist/bundling-sources/shared_libs/play-runtime/runtime-api.ts +48 -3
  14. package/dist/bundling-sources/shared_libs/play-runtime/runtime-constants.ts +9 -0
  15. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres-rate-state.ts +32 -10
  16. package/dist/bundling-sources/shared_libs/play-runtime/tool-result.ts +37 -7
  17. package/dist/cli/{auth-E7BH4GMJ.mjs → auth-KVSBJZOX.mjs} +5 -5
  18. package/dist/cli/auth-MMNVWATX.js +43 -0
  19. package/dist/cli/{billing-OXKU462W.mjs → billing-54RHFEBI.mjs} +19 -12
  20. package/dist/cli/{billing-DNQAZGX7.js → billing-FQREA7UA.js} +105 -98
  21. package/dist/cli/{chunk-5VVSEU67.js → chunk-3FD5EQ62.js} +6 -6
  22. package/dist/cli/{chunk-WKBHUB6R.js → chunk-45PVGZST.js} +99 -99
  23. package/dist/cli/{chunk-COGREZAO.js → chunk-4MK42735.js} +44 -44
  24. package/dist/cli/{chunk-T2B5BVZE.js → chunk-4NQF6KJ3.js} +13 -13
  25. package/dist/cli/{chunk-V6SCP4B7.mjs → chunk-4TALT2M3.mjs} +1 -1
  26. package/dist/cli/{chunk-C4CUZH57.js → chunk-4UUR4TCH.js} +2 -2
  27. package/dist/cli/{chunk-PM7MO62Y.mjs → chunk-57VZVF5D.mjs} +3 -3
  28. package/dist/cli/{chunk-VTGG2RT3.js → chunk-634ZDA3F.js} +1 -1
  29. package/dist/cli/{chunk-E64HFB4L.mjs → chunk-6O5HOODW.mjs} +11 -11
  30. package/dist/cli/{chunk-GGB3JYCW.mjs → chunk-6PRW5UBA.mjs} +2 -2
  31. package/dist/cli/{chunk-GVYLCCKN.mjs → chunk-6RZOWL2V.mjs} +1 -1
  32. package/dist/cli/{chunk-POLUE7D5.js → chunk-6YCA5NKJ.js} +7 -7
  33. package/dist/cli/{chunk-5LUF4LAR.mjs → chunk-6ZORHRKB.mjs} +1 -0
  34. package/dist/cli/{chunk-PPSDCN6C.js → chunk-77AAAGVB.js} +2 -2
  35. package/dist/cli/{chunk-UDXULACQ.js → chunk-7IKQKKNX.js} +3 -3
  36. package/dist/cli/{chunk-2ZYRBMQM.js → chunk-ADRC5I3R.js} +22 -22
  37. package/dist/cli/{chunk-2UXDHFSF.mjs → chunk-AQWQ2BFX.mjs} +1 -1
  38. package/dist/cli/{chunk-D6M5HFBB.mjs → chunk-AWJPDPMA.mjs} +1 -1
  39. package/dist/cli/{chunk-CLRAANWH.mjs → chunk-AZQ264ID.mjs} +1 -1
  40. package/dist/cli/{chunk-NMWGZD6Y.js → chunk-BAIST2BR.js} +26 -26
  41. package/dist/cli/{chunk-5S6PHKRV.mjs → chunk-DJ2JDK4O.mjs} +1 -1
  42. package/dist/cli/{chunk-MNSTCJMX.mjs → chunk-EOPEYCY7.mjs} +3 -3
  43. package/dist/cli/{chunk-HEHVGEZV.mjs → chunk-EUPVF4SU.mjs} +5 -5
  44. package/dist/cli/{chunk-3G6QZACZ.js → chunk-F2LH7TGF.js} +15 -15
  45. package/dist/cli/{chunk-BIIJATTX.mjs → chunk-FTJLJCE5.mjs} +1 -1
  46. package/dist/cli/{chunk-XYE5XPGF.js → chunk-G4O75EXF.js} +9 -9
  47. package/dist/cli/{chunk-Z2FIOG3V.js → chunk-GKYAYLRI.js} +12 -12
  48. package/dist/cli/{chunk-3KYBDAR3.js → chunk-HO3XK3R7.js} +5 -5
  49. package/dist/cli/{chunk-FOTGUFVK.mjs → chunk-HYC4MKGK.mjs} +2 -2
  50. package/dist/cli/{chunk-44I675YK.js → chunk-IDVVIXPJ.js} +41 -41
  51. package/dist/cli/{chunk-ZCDKE4UH.js → chunk-IHRKLXZN.js} +5 -5
  52. package/dist/cli/{chunk-6PWJKMFQ.mjs → chunk-IYSTRCLX.mjs} +4 -4
  53. package/dist/cli/{chunk-CQ6JYQSW.js → chunk-JWUAX6OP.js} +10 -10
  54. package/dist/cli/{chunk-W2ZWQUHT.js → chunk-MF2GHZDO.js} +2 -2
  55. package/dist/cli/{chunk-LPJPCGT3.js → chunk-PFO3ISXA.js} +26 -15
  56. package/dist/cli/{chunk-W425ERWN.mjs → chunk-PTVD2GVQ.mjs} +5 -5
  57. package/dist/cli/{chunk-5IL7SC45.mjs → chunk-QAORXEY3.mjs} +2 -2
  58. package/dist/cli/{chunk-RE5MJBEV.mjs → chunk-QILKGXYF.mjs} +2 -2
  59. package/dist/cli/{chunk-VWLHRZFG.mjs → chunk-QPKH23EC.mjs} +4 -4
  60. package/dist/cli/{chunk-7DOQ3OEX.mjs → chunk-QX7LFGJR.mjs} +1 -1
  61. package/dist/cli/{chunk-3T65J5RG.mjs → chunk-QY3ZNU6Z.mjs} +2 -2
  62. package/dist/cli/{chunk-PACD5DGC.js → chunk-RBEUVDZF.js} +10 -6
  63. package/dist/cli/{chunk-4OMAGJ6U.js → chunk-RQZQVFCJ.js} +2 -2
  64. package/dist/cli/{chunk-MR5LTVHD.js → chunk-S46HWQKO.js} +53 -53
  65. package/dist/cli/{chunk-44KSACJW.mjs → chunk-S5S355UY.mjs} +2 -2
  66. package/dist/cli/{chunk-QM6Y6S4E.js → chunk-SHLFOPD6.js} +5 -5
  67. package/dist/cli/{chunk-MXGA6JFI.mjs → chunk-U7QRMBIY.mjs} +2 -2
  68. package/dist/cli/{chunk-R7J7CJPZ.js → chunk-V436Z54K.js} +1 -0
  69. package/dist/cli/{chunk-ZDQFBJPO.js → chunk-VQALXEXO.js} +19 -19
  70. package/dist/cli/{chunk-7WQNWJQW.mjs → chunk-WE5HES3H.mjs} +5 -5
  71. package/dist/cli/{chunk-54EEYLTF.js → chunk-WLN3SUIA.js} +3 -3
  72. package/dist/cli/{chunk-7RSIFA72.js → chunk-XVB7V4N7.js} +16 -16
  73. package/dist/cli/{chunk-I4VKGNAQ.mjs → chunk-YJHE3O5M.mjs} +5 -5
  74. package/dist/cli/{chunk-4D3WIZST.mjs → chunk-YLTMXJFC.mjs} +7 -3
  75. package/dist/cli/{chunk-ZMNGZ6XS.mjs → chunk-Z5TSLLOW.mjs} +19 -8
  76. package/dist/cli/{chunk-S7IZWGUA.mjs → chunk-ZIAXDBXX.mjs} +2 -2
  77. package/dist/cli/command-docs.js +3 -3
  78. package/dist/cli/command-docs.mjs +2 -2
  79. package/dist/cli/concurrent-runs-help-FQAIHKKC.js +21 -0
  80. package/dist/cli/{concurrent-runs-help-C6L6I5OR.mjs → concurrent-runs-help-Q4KPAUJX.mjs} +6 -6
  81. package/dist/cli/{csv-SYSDXFEM.mjs → csv-2PTVDNO6.mjs} +4 -4
  82. package/dist/cli/{csv-QMF4FWE7.js → csv-F5VAGX4K.js} +13 -13
  83. package/dist/cli/{db-Q7HURWRZ.mjs → db-IEDXAUF7.mjs} +6 -6
  84. package/dist/cli/{db-YSHPPA4H.js → db-Z3OIUFMM.js} +27 -27
  85. package/dist/cli/{describe-YGMQBV44.mjs → describe-QDANCTS3.mjs} +18 -18
  86. package/dist/cli/describe-VUTT5ZKU.js +50 -0
  87. package/dist/cli/describe-core.d.mts +2 -2
  88. package/dist/cli/describe-core.d.ts +2 -2
  89. package/dist/cli/{executions-MWBC5TAW.js → executions-H6H5655J.js} +8 -8
  90. package/dist/cli/{executions-G7U3VUXN.mjs → executions-R3LP74QN.mjs} +6 -6
  91. package/dist/cli/{feedback-SD55OY6H.js → feedback-VFOUR66B.js} +14 -14
  92. package/dist/cli/{feedback-GMHIFLBJ.mjs → feedback-WL3MRVT5.mjs} +6 -6
  93. package/dist/cli/git-ETB3GH3K.js +25 -0
  94. package/dist/cli/{git-HPE45OPD.mjs → git-YX2J4GCI.mjs} +5 -5
  95. package/dist/cli/index.js +147 -147
  96. package/dist/cli/index.mjs +46 -46
  97. package/dist/cli/{integrations-2W4MGIQR.mjs → integrations-5ZK5KLVP.mjs} +7 -7
  98. package/dist/cli/{integrations-HFKVBY6G.js → integrations-E2JZYKHS.js} +15 -15
  99. package/dist/cli/{legacy-noops-SXVNDEXN.js → legacy-noops-3VW4IJTH.js} +9 -9
  100. package/dist/cli/{legacy-noops-GZYKNU2Z.mjs → legacy-noops-SMN3GSXY.mjs} +6 -6
  101. package/dist/cli/{mcp-PJRHQHHU.js → mcp-UQV2K4EW.js} +24 -24
  102. package/dist/cli/{mcp-BWA6KULG.mjs → mcp-V6MGCYAG.mjs} +4 -4
  103. package/dist/cli/{monitors-SYQKCATO.mjs → monitors-GGKS5W6M.mjs} +7 -7
  104. package/dist/cli/{monitors-K2WSI6CR.js → monitors-R3BBDCRC.js} +100 -100
  105. package/dist/cli/{org-YQ2CR32B.js → org-GRYVMNSW.js} +88 -88
  106. package/dist/cli/{org-5KD7X7IA.mjs → org-Z37NGJV4.mjs} +6 -6
  107. package/dist/cli/{play-SZXY2F2S.js → play-2MVO27VO.js} +319 -319
  108. package/dist/cli/{play-TTMABJEI.mjs → play-MDWPR4XG.mjs} +18 -18
  109. package/dist/cli/{providers-YDHCTZAF.js → providers-2AACRUZH.js} +9 -9
  110. package/dist/cli/{providers-GQIOMRQO.mjs → providers-AKDYFZJZ.mjs} +6 -6
  111. package/dist/cli/{quickstart-BNYOXQXG.js → quickstart-H6IV3PV3.js} +6 -6
  112. package/dist/cli/{quickstart-PHSSMKCA.mjs → quickstart-QDGRJFZY.mjs} +4 -4
  113. package/dist/cli/{run-GFIAZXVL.js → run-2634REDK.js} +43 -43
  114. package/dist/cli/{run-74C3C75C.mjs → run-RTSQNGRD.mjs} +23 -23
  115. package/dist/cli/{search-3SWUB7KX.mjs → search-6AOJ4XPP.mjs} +7 -7
  116. package/dist/cli/search-VTW2YNBS.js +32 -0
  117. package/dist/cli/{search-output-K2SWHVHQ.mjs → search-output-6ADMTOU5.mjs} +4 -4
  118. package/dist/cli/{search-output-6JF3S4TP.js → search-output-S5ODBL5E.js} +6 -6
  119. package/dist/cli/{secrets-2SAKLH2H.js → secrets-LHCIIHMT.js} +15 -15
  120. package/dist/cli/{secrets-2M4XWEKE.mjs → secrets-TFIFBFB3.mjs} +6 -6
  121. package/dist/cli/sessions-CJ4FJ2WB.js +22 -0
  122. package/dist/cli/{sessions-A64BCXTO.mjs → sessions-WHBVUHVW.mjs} +6 -6
  123. package/dist/cli/{settings-HV64WIJF.js → settings-CP4FVK2W.js} +85 -85
  124. package/dist/cli/{settings-SVGEC3FI.mjs → settings-EBONWL5C.mjs} +12 -12
  125. package/dist/cli/{setup-EDC3NEJ3.mjs → setup-I5AZE3IU.mjs} +9 -9
  126. package/dist/cli/{setup-FHXOLQGQ.js → setup-LFGHTNLQ.js} +49 -49
  127. package/dist/cli/skills-R7EBXREW.js +36 -0
  128. package/dist/cli/{skills-3HGHZMXB.mjs → skills-W76AO5XE.mjs} +7 -7
  129. package/dist/cli/{tools-P2QS6A6Q.mjs → tools-7IJHGF6W.mjs} +17 -17
  130. package/dist/cli/tools-V7U2BDXM.js +57 -0
  131. package/dist/cli/update-4COPZETK.js +34 -0
  132. package/dist/cli/{update-552BYQM4.mjs → update-GFOPZTHY.mjs} +9 -9
  133. package/dist/cli/{views-PA25NAE3.js → views-BPL2TQJ4.js} +21 -21
  134. package/dist/cli/{views-LD5HXJYY.mjs → views-D4NX4SBG.mjs} +6 -6
  135. package/dist/cli/{workflow-LDYFGBYP.mjs → workflow-YXP42FUI.mjs} +7 -7
  136. package/dist/cli/{workflow-FIDBUQV6.js → workflow-ZYNAUCKC.js} +17 -17
  137. package/dist/{client-t9HZAkFD.d.ts → client-Bf3IpUKN.d.ts} +1 -1
  138. package/dist/{client-DuDFiJDU.d.mts → client-CyXGrO4D.d.mts} +1 -1
  139. package/dist/{client-core-CJRzLanv.d.ts → client-core-BWd0lX0Z.d.ts} +17 -0
  140. package/dist/{client-core-DydMQOft.d.mts → client-core-BxsLnXlm.d.mts} +17 -0
  141. package/dist/index.d.mts +3 -3
  142. package/dist/index.d.ts +3 -3
  143. package/dist/index.js +9 -9
  144. package/dist/index.mjs +6 -6
  145. package/dist/install-integrity.json +119 -118
  146. package/dist/plays/play-description.d.mts +1 -1
  147. package/dist/plays/play-description.d.ts +1 -1
  148. package/dist/plays/run-request.d.mts +1 -1
  149. package/dist/plays/run-request.d.ts +1 -1
  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 +2 -2
  155. package/dist/server.d.ts +2 -2
  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-B4PI7GVY.js +0 -43
  160. package/dist/cli/concurrent-runs-help-JEFQZTJI.js +0 -21
  161. package/dist/cli/describe-PXTSBJTL.js +0 -50
  162. package/dist/cli/git-I3JV7IGH.js +0 -25
  163. package/dist/cli/search-2RRRF4LW.js +0 -32
  164. package/dist/cli/sessions-SBH27JNW.js +0 -22
  165. package/dist/cli/skills-Y3SRLOYD.js +0 -36
  166. package/dist/cli/tools-OFYPUPUV.js +0 -57
  167. package/dist/cli/update-SOUSCLB7.js +0 -34
@@ -2266,6 +2266,14 @@ export type TargetBillingPlan = {
2266
2266
  */
2267
2267
  bonus_credits?: number | null;
2268
2268
  interval: 'month' | 'year';
2269
+ /**
2270
+ * The price of a year paid up front (`billingInterval: 'year'` on a plan
2271
+ * transition); null or absent when annual billing is not offered. Credits
2272
+ * and limits stay monthly.
2273
+ */
2274
+ annual_price_usd?: number | null;
2275
+ /** What the annual offer is called, such as "10% off"; null with no annual price. */
2276
+ annual_offer_label?: string | null;
2269
2277
  included_credits: number;
2270
2278
  /** Offered benefit terms; omitted by older API deployments. */
2271
2279
  benefits?: Partial<BillingBenefitValues>;
@@ -2340,6 +2348,10 @@ export type TargetBillingStatusResult = {
2340
2348
  pending_plan_starts_at?: string | null;
2341
2349
  /** Next cycle boundary from the current Contract’s retained cadence. */
2342
2350
  current_period_end?: string | null;
2351
+ /** 'year' while the plan is inside a prepaid annual term. */
2352
+ billing_interval?: 'month' | 'year' | null;
2353
+ /** The price of the paid year while the plan is billed annually. */
2354
+ annual_price_usd?: number | null;
2343
2355
  as_of: string | null;
2344
2356
  };
2345
2357
 
@@ -2435,6 +2447,11 @@ export type TargetBillingPlanTransitionOptions =
2435
2447
  billingEmail?: string;
2436
2448
  /** A plan promo code; an unknown, expired, or used code refuses the change. */
2437
2449
  promoCode?: string;
2450
+ /**
2451
+ * 'year' pays for a year up front; credits and limits stay monthly, and
2452
+ * a cancellation takes effect at the end of the paid year.
2453
+ */
2454
+ billingInterval?: 'month' | 'year';
2438
2455
  idempotencyKey: string;
2439
2456
  }
2440
2457
  | {
@@ -7594,6 +7611,12 @@ export class DeeplineClient {
7594
7611
  ...(options.action === 'start_or_change' && options.promoCode
7595
7612
  ? { promo_code: options.promoCode }
7596
7613
  : {}),
7614
+ // Sent only for an annual purchase, so a monthly request's body (and
7615
+ // its idempotency hash) is unchanged.
7616
+ ...(options.action === 'start_or_change' &&
7617
+ options.billingInterval === 'year'
7618
+ ? { billing_interval: 'year' }
7619
+ : {}),
7597
7620
  },
7598
7621
  { 'Idempotency-Key': idempotencyKey },
7599
7622
  { maxRetries: 0, exactUrlOnly: true },
@@ -1258,8 +1258,12 @@ function parseRetryAfterHint(response: Response): RetryAfterHint | null {
1258
1258
  const header = response.headers.get('retry-after');
1259
1259
  if (header) {
1260
1260
  const seconds = Number(header);
1261
- if (Number.isFinite(seconds) && seconds > 0) {
1262
- return { delayMs: seconds * 1000, exact: false };
1261
+ if (Number.isFinite(seconds)) {
1262
+ return seconds > 0 ? { delayMs: seconds * 1000, exact: false } : null;
1263
+ }
1264
+ const retryAtMs = Date.parse(header);
1265
+ if (Number.isFinite(retryAtMs)) {
1266
+ return { delayMs: Math.max(0, retryAtMs - Date.now()), exact: false };
1263
1267
  }
1264
1268
  }
1265
1269
  return null;
@@ -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.551',
208
+ version: '0.3.552',
209
209
  updateSummary: {
210
210
  introducedIn: '0.3.90',
211
211
  summary:
@@ -7,6 +7,7 @@ import {
7
7
  type PlayRunStreamDiffState,
8
8
  type PlayRunStreamEvent,
9
9
  } from '../../../shared_libs/play-runtime/run-snapshot-stream.js';
10
+ import { DeeplineError } from '../errors';
10
11
  import { isTransientPlayRunReadError } from './read-errors';
11
12
 
12
13
  /** Steady-state cadence for the small authenticated REST snapshot. */
@@ -22,20 +23,25 @@ const RUN_WATCH_STARTUP_WINDOW_MS = 6_000;
22
23
  const RUN_WATCH_INTERACTIVE_POLL_INTERVAL_MS = 500;
23
24
  const RUN_WATCH_INTERACTIVE_WINDOW_MS = 30_000;
24
25
  /**
25
- * Server-held wait per snapshot request once the startup window has passed:
26
- * the run route answers as soon as the run is terminal, or after this bound,
27
- * so terminal detection no longer waits out the 2 s cadence. 0 (off) keeps
28
- * client-side polling only. Used only by watchers that defer logs, whose
29
- * progress output does not depend on intermediate snapshots. Lands off.
26
+ * Server-held wait per snapshot request: the run route answers as soon as the
27
+ * run is terminal, or after this bound, so terminal detection no longer waits
28
+ * out the client cadence. Used only by watchers that defer logs, whose
29
+ * progress output does not depend on intermediate snapshots. The route holds
30
+ * only for organizations its rollout lists and says so in
31
+ * `RUN_WATCH_HOLD_HEADER`; any other answer (an older server, an unlisted
32
+ * organization) ends server waiting for this watch, which then keeps its
33
+ * ordinary client cadence. 0 turns it off.
30
34
  */
31
- export const RUN_WATCH_SERVER_WAIT_MS = 0;
35
+ export const RUN_WATCH_SERVER_WAIT_MS = 20_000;
32
36
  /**
33
37
  * Use the server-held wait from the first snapshot request instead of only
34
38
  * after the startup window, so a short run is seen as soon as it is terminal
35
39
  * rather than on the next 300 ms poll. Same watchers (deferred logs) and the
36
- * same bounded server wait. Off.
40
+ * same bounded server wait.
37
41
  */
38
- export const RUN_WATCH_SERVER_WAIT_FROM_START = false;
42
+ export const RUN_WATCH_SERVER_WAIT_FROM_START = true;
43
+ /** Response header in which the run route reports whether it held a request. */
44
+ export const RUN_WATCH_HOLD_HEADER = 'x-deepline-run-watch-hold';
39
45
  export const TERMINAL_LOG_PROJECTION_RETRY_LIMIT = 3;
40
46
 
41
47
  type WatchHttp = {
@@ -232,6 +238,9 @@ export async function* watchRunEvents(
232
238
  let outageNoticeSent = false;
233
239
  let pollCount = 0;
234
240
  let terminalLogProjectionRetries = 0;
241
+ // Set once a held request comes back without `applied`: this watch then
242
+ // stops asking and keeps the ordinary client cadence.
243
+ let serverHoldDeclined = false;
235
244
 
236
245
  while (!signal?.aborted) {
237
246
  const pollStartedAt = Date.now();
@@ -244,20 +253,23 @@ export async function* watchRunEvents(
244
253
  const serverWaitMs =
245
254
  options.pollIntervalMs === undefined &&
246
255
  options.deferLogs &&
256
+ !serverHoldDeclined &&
247
257
  (pastStartup || RUN_WATCH_SERVER_WAIT_FROM_START) &&
248
258
  RUN_WATCH_SERVER_WAIT_MS > 0
249
259
  ? RUN_WATCH_SERVER_WAIT_MS
250
260
  : 0;
251
- // A held request already waited server-side; poll again immediately.
252
- const pollIntervalMs =
261
+ const clientPollIntervalMs =
253
262
  options.pollIntervalMs ??
254
- (serverWaitMs > 0
255
- ? 0
256
- : pastInteractive
257
- ? RUN_WATCH_POLL_INTERVAL_MS
258
- : pastStartup
259
- ? RUN_WATCH_INTERACTIVE_POLL_INTERVAL_MS
260
- : RUN_WATCH_STARTUP_POLL_INTERVAL_MS);
263
+ (pastInteractive
264
+ ? RUN_WATCH_POLL_INTERVAL_MS
265
+ : pastStartup
266
+ ? RUN_WATCH_INTERACTIVE_POLL_INTERVAL_MS
267
+ : RUN_WATCH_STARTUP_POLL_INTERVAL_MS);
268
+ // The client cadence is measured from the poll's start, so a request the
269
+ // server really held (up to its bound) is followed at once, while an
270
+ // instant answer of any kind still waits the ordinary interval: no server
271
+ // answer can make a loop.
272
+ const pollIntervalMs = clientPollIntervalMs;
261
273
  let snapshot: PlayRunLiveSnapshot;
262
274
  let terminalStatus: Record<string, unknown> | undefined;
263
275
  let responseStatus: number | undefined;
@@ -281,17 +293,27 @@ export async function* watchRunEvents(
281
293
  const response = await http.get<unknown>(
282
294
  serverWaitMs > 0 ? `${path}&waitForTerminalMs=${serverWaitMs}` : path,
283
295
  {
284
- signal,
285
- ...(options.onPoll
286
- ? {
287
- onResponse: (response: Response) => {
288
- responseStatus = response.status;
289
- serverTiming =
290
- response.headers.get('server-timing') ?? undefined;
291
- },
292
- }
293
- : {}),
294
- });
296
+ signal,
297
+ ...(options.onPoll || serverWaitMs > 0
298
+ ? {
299
+ onResponse: (response: Response) => {
300
+ responseStatus = response.status;
301
+ serverTiming =
302
+ response.headers.get('server-timing') ?? undefined;
303
+ // Only a successful answer says whether this server holds;
304
+ // a transient error leaves the ask in place.
305
+ if (
306
+ serverWaitMs > 0 &&
307
+ response.ok &&
308
+ response.headers.get(RUN_WATCH_HOLD_HEADER) !== 'applied'
309
+ ) {
310
+ serverHoldDeclined = true;
311
+ }
312
+ },
313
+ }
314
+ : {}),
315
+ },
316
+ );
295
317
  const parsed = readSnapshotResponse(response, runId);
296
318
  terminalStatus = parsed.terminalStatus;
297
319
  // Deferred watchers need the terminal tail, not a replay of every skipped log.
@@ -310,7 +332,14 @@ export async function* watchRunEvents(
310
332
  if (signal?.aborted) {
311
333
  return;
312
334
  }
313
- if (!isTransientPlayRunReadError(error)) {
335
+ // A client timeout shorter than the server hold: stop asking for the
336
+ // hold in this watch and keep polling, instead of failing it.
337
+ const heldTimeout =
338
+ serverWaitMs > 0 &&
339
+ error instanceof DeeplineError &&
340
+ error.code === 'NETWORK_TIMEOUT';
341
+ if (heldTimeout) serverHoldDeclined = true;
342
+ if (!heldTimeout && !isTransientPlayRunReadError(error)) {
314
343
  throw error;
315
344
  }
316
345
  consecutiveFailures += 1;
@@ -124,6 +124,8 @@
124
124
  "./snitcher-radar.js": "./snitcher-radar.ts",
125
125
  "./starter-templates": "./starter-templates.ts",
126
126
  "./starter-templates.js": "./starter-templates.ts",
127
+ "./tamradar-countries": "./tamradar-countries.ts",
128
+ "./tamradar-countries.js": "./tamradar-countries.ts",
127
129
  "./tracking-provider-guidance": "./tracking-provider-guidance.ts",
128
130
  "./tracking-provider-guidance.js": "./tracking-provider-guidance.ts",
129
131
  "./tracking-provider-integrations": "./tracking-provider-integrations.ts",
@@ -7,6 +7,8 @@
7
7
  // and declares the same fields on its capability; registry validation keeps the
8
8
  // two declarations aligned.
9
9
 
10
+ import { tamradarCanonicalCountryName } from './tamradar-countries';
11
+
10
12
  export type ProviderMonitorUpstreamIdentityValue = string | null;
11
13
 
12
14
  export type ProviderMonitorUpstreamIdentitySignature = {
@@ -32,15 +34,26 @@ type ProviderMonitorUpstreamIdentityDefinition = {
32
34
  */
33
35
  allowDistinctConfigurations?: boolean;
34
36
  /**
35
- * Scope values whose provider resource has no configuration of its own: a
36
- * global feed delivers the same findings whatever else the payload says.
37
- * Inside these scopes every other payload field (such as `updates_since`)
38
- * is left out of the claim, so a second monitor for the same feed is an
39
- * exact duplicate even when its other fields differ.
37
+ * Scope values whose provider resource is a global feed: it delivers the
38
+ * same findings whatever else the payload says, except for the scope's
39
+ * `configurationFields` filters. Inside these scopes every other payload
40
+ * field (such as `updates_since`) is left out of the claim, so a second
41
+ * monitor for the same feed with the same filters is an exact duplicate
42
+ * even when its other fields differ. A monitor that sets none of the
43
+ * filters keeps the scope-only key.
40
44
  */
41
45
  configurationFreeScopes?: readonly {
42
46
  field: string;
43
47
  values: readonly string[];
48
+ configurationFields?: readonly {
49
+ name: string;
50
+ /**
51
+ * The provider's one spelling for an accepted value, so aliases that
52
+ * select the same findings claim the same feed. Values it does not
53
+ * recognize key as written; the provider refuses them at create.
54
+ */
55
+ canonicalValue?: (value: string) => string | null;
56
+ }[];
44
57
  }[];
45
58
  /**
46
59
  * Payload fields that never change which findings the provider resource
@@ -71,12 +84,22 @@ const PROVIDER_MONITOR_UPSTREAM_IDENTITY_FIELDS = {
71
84
  { name: 'industry', runtimePayloadAliases: ['keyword'] },
72
85
  ],
73
86
  allowDistinctConfigurations: true,
74
- // TamRadar's funding-round and new-company radars take no filter, so one
75
- // per workspace is the whole feed.
87
+ // TamRadar's new-company radar takes no filter, so one per workspace is
88
+ // the whole feed. Its funding-round radar is the same global feed narrowed
89
+ // only by `countries` and `rounds` (2026-11-17), so one unfiltered and any
90
+ // number of differently filtered funding monitors can coexist.
76
91
  configurationFreeScopes: [
77
92
  {
78
93
  field: 'radar_type',
79
- values: ['industry_funding_rounds', 'industry_new_companies'],
94
+ values: ['industry_new_companies'],
95
+ },
96
+ {
97
+ field: 'radar_type',
98
+ values: ['industry_funding_rounds'],
99
+ configurationFields: [
100
+ { name: 'countries', canonicalValue: tamradarCanonicalCountryName },
101
+ { name: 'rounds' },
102
+ ],
80
103
  },
81
104
  ],
82
105
  nonConfigurationFields: ['updates_since'],
@@ -194,13 +217,29 @@ export function providerMonitorUpstreamIdentityClaimKey(
194
217
  PROVIDER_MONITOR_UPSTREAM_IDENTITY_FIELDS[
195
218
  signature.tool as keyof typeof PROVIDER_MONITOR_UPSTREAM_IDENTITY_FIELDS
196
219
  ];
197
- if (
198
- definition.configurationFreeScopes?.some((scope) => {
220
+ const configurationFreeScope = definition.configurationFreeScopes?.find(
221
+ (scope) => {
199
222
  const value = signature.key[scope.field];
200
223
  return typeof value === 'string' && scope.values.includes(value);
201
- })
202
- ) {
203
- return scopeKey;
224
+ },
225
+ );
226
+ if (configurationFreeScope) {
227
+ // Spelling, case and order do not change which findings the provider
228
+ // delivers, so each filter value is canonicalized, lowercased and sorted
229
+ // before keying: "us", "US" and "United States" claim one feed.
230
+ const filters = Object.fromEntries(
231
+ (configurationFreeScope.configurationFields ?? [])
232
+ .map(
233
+ (field) =>
234
+ [
235
+ field.name,
236
+ normalizeFilterValue(payload?.[field.name], field.canonicalValue),
237
+ ] as const,
238
+ )
239
+ .filter(([, value]) => !isEmptyFilterValue(value)),
240
+ );
241
+ if (Object.keys(filters).length === 0) return scopeKey;
242
+ return `${scopeKey}${CONFIGURATION_SEPARATOR}${stableJson(filters)}`;
204
243
  }
205
244
  const scopeAndAliases = new Set<string>(
206
245
  definition.fields.flatMap((field) => [
@@ -220,6 +259,34 @@ export function providerMonitorUpstreamIdentityClaimKey(
220
259
  return `${scopeKey}${CONFIGURATION_SEPARATOR}${stableJson(configuration)}`;
221
260
  }
222
261
 
262
+ /**
263
+ * A filter list canonicalized, trimmed, lowercased and sorted, keeping blank
264
+ * entries out.
265
+ */
266
+ function normalizeFilterValue(
267
+ value: unknown,
268
+ canonicalValue?: (value: string) => string | null,
269
+ ) {
270
+ if (!Array.isArray(value)) return value;
271
+ return value
272
+ .map((entry) =>
273
+ typeof entry === 'string'
274
+ ? (canonicalValue?.(entry) ?? entry).trim().toLowerCase()
275
+ : entry,
276
+ )
277
+ .filter((entry) => entry !== '' && entry !== null && entry !== undefined)
278
+ .sort((left, right) => stableJson(left).localeCompare(stableJson(right)));
279
+ }
280
+
281
+ /** An omitted filter and an empty list both mean "no filter". */
282
+ function isEmptyFilterValue(value: unknown) {
283
+ return (
284
+ value === undefined ||
285
+ value === null ||
286
+ (Array.isArray(value) && value.length === 0)
287
+ );
288
+ }
289
+
223
290
  function parseJsonObject(text: string): Record<string, unknown> | null {
224
291
  try {
225
292
  const parsed: unknown = JSON.parse(text);
@@ -0,0 +1,285 @@
1
+ // TamRadar's supported countries for the industry radar `countries` filter:
2
+ // each row is the two-letter code, the name TamRadar saves and returns, and
3
+ // its other accepted names. TamRadar matches any of them ignoring case and
4
+ // extra spaces, so "us", "US" and "United States" are one country.
5
+ // Source: https://docs.tamradar.com/guides/supported-countries (250 countries,
6
+ // Unicode CLDR 48 English names), read 2026-11-17. Runtime-neutral: Convex
7
+ // claim admission and the app derive the same identity key from it.
8
+ const TAMRADAR_COUNTRIES: readonly (
9
+ | readonly [code: string, name: string]
10
+ | readonly [code: string, name: string, alsoAccepted: readonly string[]]
11
+ )[] = [
12
+ ['AF', 'Afghanistan'],
13
+ ['AX', 'Åland Islands'],
14
+ ['AL', 'Albania'],
15
+ ['DZ', 'Algeria'],
16
+ ['AS', 'American Samoa'],
17
+ ['AD', 'Andorra'],
18
+ ['AO', 'Angola'],
19
+ ['AI', 'Anguilla'],
20
+ ['AQ', 'Antarctica'],
21
+ ['AG', 'Antigua & Barbuda'],
22
+ ['AR', 'Argentina'],
23
+ ['AM', 'Armenia'],
24
+ ['AW', 'Aruba'],
25
+ ['AU', 'Australia'],
26
+ ['AT', 'Austria'],
27
+ ['AZ', 'Azerbaijan'],
28
+ ['BS', 'Bahamas'],
29
+ ['BH', 'Bahrain'],
30
+ ['BD', 'Bangladesh'],
31
+ ['BB', 'Barbados'],
32
+ ['BY', 'Belarus'],
33
+ ['BE', 'Belgium'],
34
+ ['BZ', 'Belize'],
35
+ ['BJ', 'Benin'],
36
+ ['BM', 'Bermuda'],
37
+ ['BT', 'Bhutan'],
38
+ ['BO', 'Bolivia'],
39
+ ['BA', 'Bosnia & Herzegovina', ['Bosnia']],
40
+ ['BW', 'Botswana'],
41
+ ['BV', 'Bouvet Island'],
42
+ ['BR', 'Brazil'],
43
+ ['IO', 'British Indian Ocean Territory', ['Chagos Archipelago']],
44
+ ['VG', 'British Virgin Islands'],
45
+ ['BN', 'Brunei'],
46
+ ['BG', 'Bulgaria'],
47
+ ['BF', 'Burkina Faso'],
48
+ ['BI', 'Burundi'],
49
+ ['KH', 'Cambodia'],
50
+ ['CM', 'Cameroon'],
51
+ ['CA', 'Canada'],
52
+ ['CV', 'Cape Verde', ['Cabo Verde']],
53
+ ['BQ', 'Caribbean Netherlands'],
54
+ ['KY', 'Cayman Islands'],
55
+ ['CF', 'Central African Republic'],
56
+ ['TD', 'Chad'],
57
+ ['CL', 'Chile'],
58
+ ['CN', 'China'],
59
+ ['CX', 'Christmas Island'],
60
+ ['CC', 'Cocos (Keeling) Islands', ['Cocos Islands']],
61
+ ['CO', 'Colombia'],
62
+ ['KM', 'Comoros'],
63
+ ['CG', 'Congo - Brazzaville', ['Congo (Republic)']],
64
+ ['CD', 'Congo - Kinshasa', ['Congo (DRC)']],
65
+ ['CK', 'Cook Islands'],
66
+ ['CR', 'Costa Rica'],
67
+ ['CI', 'Côte d’Ivoire', ['Ivory Coast']],
68
+ ['HR', 'Croatia'],
69
+ ['CU', 'Cuba'],
70
+ ['CW', 'Curaçao'],
71
+ ['CY', 'Cyprus'],
72
+ ['CZ', 'Czechia', ['Czech Republic']],
73
+ ['DK', 'Denmark'],
74
+ ['DJ', 'Djibouti'],
75
+ ['DM', 'Dominica'],
76
+ ['DO', 'Dominican Republic'],
77
+ ['EC', 'Ecuador'],
78
+ ['EG', 'Egypt'],
79
+ ['SV', 'El Salvador'],
80
+ ['GQ', 'Equatorial Guinea'],
81
+ ['ER', 'Eritrea'],
82
+ ['EE', 'Estonia'],
83
+ ['SZ', 'Eswatini', ['Swaziland']],
84
+ ['ET', 'Ethiopia'],
85
+ ['FK', 'Falkland Islands', ['Falkland Islands (Islas Malvinas)']],
86
+ ['FO', 'Faroe Islands'],
87
+ ['FJ', 'Fiji'],
88
+ ['FI', 'Finland'],
89
+ ['FR', 'France'],
90
+ ['GF', 'French Guiana'],
91
+ ['PF', 'French Polynesia'],
92
+ ['TF', 'French Southern Territories'],
93
+ ['GA', 'Gabon'],
94
+ ['GM', 'Gambia'],
95
+ ['GE', 'Georgia'],
96
+ ['DE', 'Germany'],
97
+ ['GH', 'Ghana'],
98
+ ['GI', 'Gibraltar'],
99
+ ['GR', 'Greece'],
100
+ ['GL', 'Greenland'],
101
+ ['GD', 'Grenada'],
102
+ ['GP', 'Guadeloupe'],
103
+ ['GU', 'Guam'],
104
+ ['GT', 'Guatemala'],
105
+ ['GG', 'Guernsey'],
106
+ ['GN', 'Guinea'],
107
+ ['GW', 'Guinea-Bissau'],
108
+ ['GY', 'Guyana'],
109
+ ['HT', 'Haiti'],
110
+ ['HM', 'Heard & McDonald Islands'],
111
+ ['HN', 'Honduras'],
112
+ ['HK', 'Hong Kong SAR China', ['Hong Kong']],
113
+ ['HU', 'Hungary'],
114
+ ['IS', 'Iceland'],
115
+ ['IN', 'India'],
116
+ ['ID', 'Indonesia'],
117
+ ['IR', 'Iran'],
118
+ ['IQ', 'Iraq'],
119
+ ['IE', 'Ireland'],
120
+ ['IM', 'Isle of Man'],
121
+ ['IL', 'Israel'],
122
+ ['IT', 'Italy'],
123
+ ['JM', 'Jamaica'],
124
+ ['JP', 'Japan'],
125
+ ['JE', 'Jersey'],
126
+ ['JO', 'Jordan'],
127
+ ['KZ', 'Kazakhstan'],
128
+ ['KE', 'Kenya'],
129
+ ['KI', 'Kiribati'],
130
+ ['XK', 'Kosovo'],
131
+ ['KW', 'Kuwait'],
132
+ ['KG', 'Kyrgyzstan'],
133
+ ['LA', 'Laos'],
134
+ ['LV', 'Latvia'],
135
+ ['LB', 'Lebanon'],
136
+ ['LS', 'Lesotho'],
137
+ ['LR', 'Liberia'],
138
+ ['LY', 'Libya'],
139
+ ['LI', 'Liechtenstein'],
140
+ ['LT', 'Lithuania'],
141
+ ['LU', 'Luxembourg'],
142
+ ['MO', 'Macao SAR China', ['Macao']],
143
+ ['MG', 'Madagascar'],
144
+ ['MW', 'Malawi'],
145
+ ['MY', 'Malaysia'],
146
+ ['MV', 'Maldives'],
147
+ ['ML', 'Mali'],
148
+ ['MT', 'Malta'],
149
+ ['MH', 'Marshall Islands'],
150
+ ['MQ', 'Martinique'],
151
+ ['MR', 'Mauritania'],
152
+ ['MU', 'Mauritius'],
153
+ ['YT', 'Mayotte'],
154
+ ['MX', 'Mexico'],
155
+ ['FM', 'Micronesia'],
156
+ ['MD', 'Moldova'],
157
+ ['MC', 'Monaco'],
158
+ ['MN', 'Mongolia'],
159
+ ['ME', 'Montenegro'],
160
+ ['MS', 'Montserrat'],
161
+ ['MA', 'Morocco'],
162
+ ['MZ', 'Mozambique'],
163
+ ['MM', 'Myanmar (Burma)', ['Myanmar']],
164
+ ['NA', 'Namibia'],
165
+ ['NR', 'Nauru'],
166
+ ['NP', 'Nepal'],
167
+ ['NL', 'Netherlands'],
168
+ ['NC', 'New Caledonia'],
169
+ ['NZ', 'New Zealand', ['Aotearoa New Zealand']],
170
+ ['NI', 'Nicaragua'],
171
+ ['NE', 'Niger'],
172
+ ['NG', 'Nigeria'],
173
+ ['NU', 'Niue'],
174
+ ['NF', 'Norfolk Island'],
175
+ ['KP', 'North Korea'],
176
+ ['MK', 'North Macedonia'],
177
+ ['MP', 'Northern Mariana Islands'],
178
+ ['NO', 'Norway'],
179
+ ['OM', 'Oman'],
180
+ ['PK', 'Pakistan'],
181
+ ['PW', 'Palau'],
182
+ ['PS', 'Palestinian Territories', ['Palestine']],
183
+ ['PA', 'Panama'],
184
+ ['PG', 'Papua New Guinea'],
185
+ ['PY', 'Paraguay'],
186
+ ['PE', 'Peru'],
187
+ ['PH', 'Philippines'],
188
+ ['PN', 'Pitcairn Islands', ['Pitcairn']],
189
+ ['PL', 'Poland'],
190
+ ['PT', 'Portugal'],
191
+ ['PR', 'Puerto Rico'],
192
+ ['QA', 'Qatar'],
193
+ ['RE', 'Réunion'],
194
+ ['RO', 'Romania'],
195
+ ['RU', 'Russia'],
196
+ ['RW', 'Rwanda'],
197
+ ['WS', 'Samoa'],
198
+ ['SM', 'San Marino'],
199
+ ['ST', 'São Tomé & Príncipe'],
200
+ ['SA', 'Saudi Arabia'],
201
+ ['SN', 'Senegal'],
202
+ ['RS', 'Serbia'],
203
+ ['SC', 'Seychelles'],
204
+ ['SL', 'Sierra Leone'],
205
+ ['SG', 'Singapore'],
206
+ ['SX', 'Sint Maarten'],
207
+ ['SK', 'Slovakia'],
208
+ ['SI', 'Slovenia'],
209
+ ['SB', 'Solomon Islands'],
210
+ ['SO', 'Somalia'],
211
+ ['ZA', 'South Africa'],
212
+ ['GS', 'South Georgia & South Sandwich Islands'],
213
+ ['KR', 'South Korea'],
214
+ ['SS', 'South Sudan'],
215
+ ['ES', 'Spain'],
216
+ ['LK', 'Sri Lanka'],
217
+ ['BL', 'St. Barthélemy'],
218
+ ['SH', 'St. Helena'],
219
+ ['KN', 'St. Kitts & Nevis'],
220
+ ['LC', 'St. Lucia'],
221
+ ['MF', 'St. Martin'],
222
+ ['PM', 'St. Pierre & Miquelon'],
223
+ ['VC', 'St. Vincent & Grenadines'],
224
+ ['SD', 'Sudan'],
225
+ ['SR', 'Suriname'],
226
+ ['SJ', 'Svalbard & Jan Mayen'],
227
+ ['SE', 'Sweden'],
228
+ ['CH', 'Switzerland'],
229
+ ['SY', 'Syria'],
230
+ ['TW', 'Taiwan'],
231
+ ['TJ', 'Tajikistan'],
232
+ ['TZ', 'Tanzania'],
233
+ ['TH', 'Thailand'],
234
+ ['TL', 'Timor-Leste', ['East Timor']],
235
+ ['TG', 'Togo'],
236
+ ['TK', 'Tokelau'],
237
+ ['TO', 'Tonga'],
238
+ ['TT', 'Trinidad & Tobago'],
239
+ ['TN', 'Tunisia'],
240
+ ['TR', 'Türkiye', ['Turkey']],
241
+ ['TM', 'Turkmenistan'],
242
+ ['TC', 'Turks & Caicos Islands'],
243
+ ['TV', 'Tuvalu'],
244
+ ['UM', 'U.S. Outlying Islands'],
245
+ ['VI', 'U.S. Virgin Islands'],
246
+ ['UG', 'Uganda'],
247
+ ['UA', 'Ukraine'],
248
+ ['AE', 'United Arab Emirates'],
249
+ ['GB', 'United Kingdom', ['UK']],
250
+ ['US', 'United States'],
251
+ ['UY', 'Uruguay'],
252
+ ['UZ', 'Uzbekistan'],
253
+ ['VU', 'Vanuatu'],
254
+ ['VA', 'Vatican City'],
255
+ ['VE', 'Venezuela'],
256
+ ['VN', 'Vietnam'],
257
+ ['WF', 'Wallis & Futuna'],
258
+ ['EH', 'Western Sahara'],
259
+ ['YE', 'Yemen'],
260
+ ['ZM', 'Zambia'],
261
+ ['ZW', 'Zimbabwe'],
262
+ ];
263
+
264
+ function countryLookupKey(value: string) {
265
+ return value.trim().replace(/\s+/g, ' ').toLowerCase();
266
+ }
267
+
268
+ const TAMRADAR_COUNTRY_NAME_BY_LOOKUP_KEY: ReadonlyMap<string, string> =
269
+ new Map(
270
+ TAMRADAR_COUNTRIES.flatMap(([code, name, alsoAccepted = []]) =>
271
+ [code, name, ...alsoAccepted].map(
272
+ (accepted) => [countryLookupKey(accepted), name] as const,
273
+ ),
274
+ ),
275
+ );
276
+
277
+ /**
278
+ * The country name TamRadar saves for an accepted code or name, or null when
279
+ * TamRadar does not accept the value (it refuses the create with a 400).
280
+ */
281
+ export function tamradarCanonicalCountryName(value: string): string | null {
282
+ return (
283
+ TAMRADAR_COUNTRY_NAME_BY_LOOKUP_KEY.get(countryLookupKey(value)) ?? null
284
+ );
285
+ }