deepline 0.3.509 → 0.3.511

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 (152) hide show
  1. package/dist/bundling-sources/sdk/src/client-core.ts +159 -0
  2. package/dist/bundling-sources/sdk/src/release.ts +1 -1
  3. package/dist/bundling-sources/shared_libs/monitors/org-monitor-limits.ts +7 -2
  4. package/dist/bundling-sources/shared_libs/observability/scheduled-jobs.json +3 -3
  5. package/dist/bundling-sources/shared_libs/play-runtime/deployment/commands/roll-execution-relay.ts +94 -43
  6. package/dist/bundling-sources/shared_libs/play-runtime/deployment/commands/roll-receipt-gateway.ts +111 -27
  7. package/dist/bundling-sources/shared_libs/play-runtime/deployment/commands/runtime-topology.ts +79 -6
  8. package/dist/bundling-sources/shared_libs/play-runtime/deployment/fly-machines.ts +80 -6
  9. package/dist/bundling-sources/shared_libs/play-runtime/deployment/fly-transient-retry.ts +571 -0
  10. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-runtime-worker.ts +218 -33
  11. package/dist/cli/artifacts-G6JHRHY5.mjs +268 -0
  12. package/dist/cli/artifacts-PLF5ZUS7.js +268 -0
  13. package/dist/cli/{auth-6IR2QH4N.mjs → auth-2XMJMDWG.mjs} +5 -5
  14. package/dist/cli/auth-PI2KS2CD.js +43 -0
  15. package/dist/cli/{billing-WEWHH6ST.mjs → billing-6C5AI42X.mjs} +7 -7
  16. package/dist/cli/{billing-SYBK3ZYU.js → billing-Z3XFXP3H.js} +82 -82
  17. package/dist/cli/{chunk-JZJNA57M.js → chunk-2Q4H2Y6N.js} +6 -6
  18. package/dist/cli/{chunk-VTVZ7EUA.js → chunk-2YVRIXVR.js} +9 -9
  19. package/dist/cli/{chunk-RSKAPLST.mjs → chunk-5WTLXL6O.mjs} +1 -1
  20. package/dist/cli/{chunk-YJM3NOME.mjs → chunk-77DPQI6W.mjs} +94 -10
  21. package/dist/cli/{chunk-FNLGMMJJ.mjs → chunk-ASXOFBF7.mjs} +2 -2
  22. package/dist/cli/{chunk-AO63MXT6.js → chunk-BHV7JKXQ.js} +1 -1
  23. package/dist/cli/{chunk-RA2NKHV5.js → chunk-D5VWSR4D.js} +5 -5
  24. package/dist/cli/{chunk-CMSPA5VX.js → chunk-FAGSSIOY.js} +6 -6
  25. package/dist/cli/{chunk-J5P4PDRT.js → chunk-FF25PDQ2.js} +94 -10
  26. package/dist/cli/{chunk-SEQIB5WJ.mjs → chunk-FTT2SBBH.mjs} +5 -5
  27. package/dist/cli/{chunk-5Y3I5LEQ.js → chunk-FV4PASXH.js} +16 -16
  28. package/dist/cli/{chunk-GTAU4C44.js → chunk-GD3ES3JU.js} +14 -14
  29. package/dist/cli/{chunk-HMAETS53.js → chunk-GGQHOLH6.js} +3 -3
  30. package/dist/cli/{chunk-T67NAGSD.mjs → chunk-GJWL4KTY.mjs} +4 -4
  31. package/dist/cli/{chunk-6KBVQ76G.mjs → chunk-HLEZQDEZ.mjs} +2 -2
  32. package/dist/cli/{chunk-WJ6H2W3O.mjs → chunk-ISY7PBIK.mjs} +5 -5
  33. package/dist/cli/{chunk-AD45WJHN.js → chunk-IYWN7M4I.js} +5 -5
  34. package/dist/cli/{chunk-3CZHC24N.mjs → chunk-JDDKJIZU.mjs} +1 -1
  35. package/dist/cli/{chunk-E3HWUGDT.mjs → chunk-JHBZBCU4.mjs} +1 -1
  36. package/dist/cli/{chunk-7KALZEDZ.js → chunk-JIY25SUX.js} +4 -4
  37. package/dist/cli/{chunk-726UDAV2.js → chunk-JYFLIQPE.js} +7 -7
  38. package/dist/cli/{chunk-DGOSW42X.js → chunk-K4JB2BZP.js} +96 -96
  39. package/dist/cli/{chunk-XEQH65DT.mjs → chunk-KK6NZHAJ.mjs} +1 -1
  40. package/dist/cli/chunk-KUDNPJ43.js +77 -0
  41. package/dist/cli/{chunk-IZW7IOD6.mjs → chunk-KXGH4YUQ.mjs} +1 -1
  42. package/dist/cli/{chunk-Q7G6WORO.js → chunk-KZBKQPSA.js} +2 -2
  43. package/dist/cli/{chunk-4DVANPBN.js → chunk-LDZYGM7W.js} +41 -41
  44. package/dist/cli/{chunk-XPKBYMJH.js → chunk-LKSJXTRP.js} +53 -53
  45. package/dist/cli/{chunk-Q5UO2ENN.js → chunk-NVMNMKZW.js} +3 -3
  46. package/dist/cli/{chunk-VZ773N7G.js → chunk-O37BQ2CG.js} +21 -10
  47. package/dist/cli/{chunk-OOD5LGUS.mjs → chunk-OQ4YBPOQ.mjs} +3 -3
  48. package/dist/cli/{chunk-UART6FGK.mjs → chunk-PCI4MMH7.mjs} +1 -1
  49. package/dist/cli/{chunk-2ZJRCAHG.js → chunk-PI45LZ5B.js} +11 -11
  50. package/dist/cli/{chunk-O527H5GY.js → chunk-PUFEARWT.js} +16 -16
  51. package/dist/cli/{chunk-25MAOMVS.mjs → chunk-QDWNVTTO.mjs} +2 -2
  52. package/dist/cli/{chunk-WUKNKFB3.mjs → chunk-RPPU3XB3.mjs} +2 -2
  53. package/dist/cli/{chunk-XIBNY6H6.mjs → chunk-S5C4CWSS.mjs} +5 -5
  54. package/dist/cli/{chunk-2U7Z4LFG.mjs → chunk-S6KEACD3.mjs} +6 -6
  55. package/dist/cli/{chunk-Y4M5HPQV.mjs → chunk-SI4QXATV.mjs} +5 -5
  56. package/dist/cli/{chunk-R2KNJMOY.mjs → chunk-VEOFISLZ.mjs} +1 -1
  57. package/dist/cli/{chunk-Z2LVZDO5.js → chunk-VHFTN6VY.js} +44 -44
  58. package/dist/cli/{chunk-54YPOG5W.mjs → chunk-VQ74WMKG.mjs} +15 -4
  59. package/dist/cli/{chunk-ZXGMWXZW.js → chunk-WDBEWOU6.js} +2 -2
  60. package/dist/cli/{chunk-6TBRWRJ2.js → chunk-XGXXNT4O.js} +270 -199
  61. package/dist/cli/chunk-XREZY4FA.mjs +77 -0
  62. package/dist/cli/{chunk-K2RCVD7S.mjs → chunk-XSBGWMI6.mjs} +72 -1
  63. package/dist/cli/{chunk-S7JEF2MR.mjs → chunk-XXQZYLLL.mjs} +2 -2
  64. package/dist/cli/{chunk-EEEWADSR.mjs → chunk-XZ6IZIQJ.mjs} +2 -2
  65. package/dist/cli/{chunk-WPBTWRKG.js → chunk-YX7E2VQM.js} +26 -26
  66. package/dist/cli/{chunk-FQCIYGQY.mjs → chunk-ZFJ2U76O.mjs} +2 -2
  67. package/dist/cli/{chunk-7NMPGX3W.js → chunk-ZWGBQKW7.js} +21 -21
  68. package/dist/cli/{chunk-VH522HUP.mjs → chunk-ZYVR4A4P.mjs} +10 -10
  69. package/dist/cli/command-docs.js +2 -2
  70. package/dist/cli/command-docs.mjs +1 -1
  71. package/dist/cli/{csv-4LAJ2ZKG.mjs → csv-CNK6ZF3T.mjs} +4 -4
  72. package/dist/cli/{csv-5KNONIAX.js → csv-S44OGG2O.js} +13 -13
  73. package/dist/cli/{db-BEVCJI66.mjs → db-AVO6QJU6.mjs} +6 -6
  74. package/dist/cli/{db-5PEXOSN3.js → db-WKZ6EXNG.js} +27 -27
  75. package/dist/cli/{describe-TDJIUSD6.mjs → describe-2HQRT5MI.mjs} +18 -18
  76. package/dist/cli/describe-CCK77NER.js +50 -0
  77. package/dist/cli/describe-core.d.mts +2 -2
  78. package/dist/cli/describe-core.d.ts +2 -2
  79. package/dist/cli/{executions-KXCPU6YC.mjs → executions-DKHOR7HD.mjs} +6 -6
  80. package/dist/cli/{executions-36GV3A27.js → executions-MTAHNARA.js} +8 -8
  81. package/dist/cli/{feedback-GEUUT4S7.mjs → feedback-K6SJS4LG.mjs} +11 -7
  82. package/dist/cli/{feedback-SPQABV33.js → feedback-R2UABU3E.js} +15 -11
  83. package/dist/cli/{git-AE36X2R6.mjs → git-3EPA7433.mjs} +5 -5
  84. package/dist/cli/git-7L3PY2A4.js +25 -0
  85. package/dist/cli/index.js +177 -156
  86. package/dist/cli/index.mjs +80 -59
  87. package/dist/cli/{legacy-noops-TKPHN7WT.js → legacy-noops-3Q2D2F24.js} +9 -8
  88. package/dist/cli/{legacy-noops-LUEDAK7J.mjs → legacy-noops-66OPCJJD.mjs} +6 -5
  89. package/dist/cli/{monitors-JHJZ5XG7.mjs → monitors-2PYPRWT4.mjs} +7 -7
  90. package/dist/cli/{monitors-B2EAIGZI.js → monitors-KHH4MZDF.js} +100 -100
  91. package/dist/cli/{org-GUICCEBZ.mjs → org-WAW3OL7B.mjs} +6 -6
  92. package/dist/cli/{org-PYCPXEAU.js → org-X5G36B2Q.js} +72 -72
  93. package/dist/cli/{pages-Y2XI36HY.mjs → pages-KABWXDGW.mjs} +6 -6
  94. package/dist/cli/{pages-CV4TQNFY.js → pages-XDPHCHHU.js} +18 -18
  95. package/dist/cli/{play-VWCQNGZZ.mjs → play-654B2HQU.mjs} +18 -18
  96. package/dist/cli/{play-MTVK66JK.js → play-UE5FKQCO.js} +317 -317
  97. package/dist/cli/{providers-N72BUCXZ.js → providers-QT2BZMJ7.js} +9 -9
  98. package/dist/cli/{providers-ZOZTST3A.mjs → providers-SKNGX6IT.mjs} +6 -6
  99. package/dist/cli/{quickstart-DXIC3NHS.mjs → quickstart-BX7XMJIQ.mjs} +4 -4
  100. package/dist/cli/{quickstart-FK53VZB3.js → quickstart-XWDVAQTT.js} +6 -6
  101. package/dist/cli/{run-NNAYDCEN.js → run-C6YYD4AK.js} +41 -41
  102. package/dist/cli/{run-IL2KI33N.mjs → run-JTU4K4MY.mjs} +23 -23
  103. package/dist/cli/{search-7IPVMQCO.mjs → search-NHV4Y4SX.mjs} +8 -8
  104. package/dist/cli/search-RIFW5JCK.js +33 -0
  105. package/dist/cli/{search-output-ZY2GE35S.mjs → search-output-AAOMFK7K.mjs} +4 -4
  106. package/dist/cli/{search-output-YHTWLSDE.js → search-output-WLFFEGCY.js} +6 -6
  107. package/dist/cli/{secrets-ZML76SH2.js → secrets-H4WTLQJJ.js} +15 -15
  108. package/dist/cli/{secrets-BGUMHDZ7.mjs → secrets-S66PZSRO.mjs} +6 -6
  109. package/dist/cli/sessions-EFWO62XJ.js +18 -0
  110. package/dist/cli/{sessions-F5XO6HZJ.mjs → sessions-PY6FJX3O.mjs} +6 -5
  111. package/dist/cli/{settings-73SMIICV.mjs → settings-V7BM42KQ.mjs} +39 -12
  112. package/dist/cli/{settings-TOX2P5M5.js → settings-YO4FFPN6.js} +109 -82
  113. package/dist/cli/{setup-DNFHFQ7N.js → setup-IFZYYQ2W.js} +50 -50
  114. package/dist/cli/{setup-FDJZYBMS.mjs → setup-VUBM2HMH.mjs} +10 -10
  115. package/dist/cli/{skills-6HJ2IAY6.mjs → skills-EYWRSQQJ.mjs} +8 -8
  116. package/dist/cli/skills-LFP53SWQ.js +37 -0
  117. package/dist/cli/tools-SR2Q7KC5.js +57 -0
  118. package/dist/cli/{tools-4FJIIE4R.mjs → tools-VZOW4MUD.mjs} +17 -17
  119. package/dist/cli/update-ADZBZZZS.js +35 -0
  120. package/dist/cli/{update-UMRPPILV.mjs → update-CQDJJYU2.mjs} +10 -10
  121. package/dist/cli/{workflow-LSFOG5VU.mjs → workflow-2VRDIPF3.mjs} +7 -7
  122. package/dist/cli/{workflow-SK3BUHB4.js → workflow-XS3JEU6X.js} +17 -17
  123. package/dist/{client-DMpsMNH9.d.mts → client-By7bUS8h.d.mts} +1 -1
  124. package/dist/{client-BlwD-G4v.d.ts → client-CmlKSBXd.d.ts} +1 -1
  125. package/dist/{client-core-DwBLuEkm.d.ts → client-core-BM0mKhgp.d.ts} +93 -1
  126. package/dist/{client-core-CITtRTbB.d.mts → client-core-BZ3tpY_J.d.mts} +93 -1
  127. package/dist/index.d.mts +3 -3
  128. package/dist/index.d.ts +3 -3
  129. package/dist/index.js +9 -9
  130. package/dist/index.mjs +6 -6
  131. package/dist/install-integrity.json +111 -106
  132. package/dist/plays/play-description.d.mts +1 -1
  133. package/dist/plays/play-description.d.ts +1 -1
  134. package/dist/plays/run-request.d.mts +1 -1
  135. package/dist/plays/run-request.d.ts +1 -1
  136. package/dist/release.d.mts +1 -1
  137. package/dist/release.d.ts +1 -1
  138. package/dist/release.js +2 -2
  139. package/dist/release.mjs +1 -1
  140. package/dist/server.d.mts +2 -2
  141. package/dist/server.d.ts +2 -2
  142. package/dist/server.js +5 -5
  143. package/dist/server.mjs +3 -3
  144. package/package.json +1 -1
  145. package/dist/cli/auth-SUTQ4SZQ.js +0 -43
  146. package/dist/cli/describe-ZB6G6DOV.js +0 -50
  147. package/dist/cli/git-UX7L6R32.js +0 -25
  148. package/dist/cli/search-OZHP5ZE2.js +0 -33
  149. package/dist/cli/sessions-WDINUUZ3.js +0 -17
  150. package/dist/cli/skills-NE7WN5PP.js +0 -37
  151. package/dist/cli/tools-ETX4MNNO.js +0 -57
  152. package/dist/cli/update-N2DMPSUH.js +0 -35
@@ -2956,6 +2956,49 @@ export type HostedPageLink = {
2956
2956
  created_at: number;
2957
2957
  };
2958
2958
 
2959
+ export type ArtifactAccess = 'workspace' | 'public';
2960
+
2961
+ export type Artifact = {
2962
+ id: string;
2963
+ name: string;
2964
+ description: string | null;
2965
+ url: string;
2966
+ play: string;
2967
+ input: Record<string, unknown>;
2968
+ access: ArtifactAccess;
2969
+ created_at: number;
2970
+ updated_at: number;
2971
+ };
2972
+
2973
+ export type ArtifactAbilities = {
2974
+ create: boolean;
2975
+ edit: boolean;
2976
+ delete: boolean;
2977
+ setAccess: boolean;
2978
+ refresh: boolean;
2979
+ admin: boolean;
2980
+ };
2981
+
2982
+ export type ArtifactDetail = Artifact & {
2983
+ can: ArtifactAbilities | null;
2984
+ };
2985
+
2986
+ export type ArtifactRunSummary = {
2987
+ run_id: string;
2988
+ status: string;
2989
+ created_at: number;
2990
+ finished_at: number | null;
2991
+ };
2992
+
2993
+ export type ArtifactPermissionLevel = 'members' | 'admins';
2994
+ export type ArtifactPermissionRules = {
2995
+ create: ArtifactPermissionLevel;
2996
+ edit: ArtifactPermissionLevel;
2997
+ delete: ArtifactPermissionLevel;
2998
+ setAccess: ArtifactPermissionLevel;
2999
+ refresh: ArtifactPermissionLevel;
3000
+ };
3001
+
2959
3002
  /**
2960
3003
  * Low-level typed REST client with authentication, retries, and localhost failover.
2961
3004
  *
@@ -3340,6 +3383,122 @@ export class DeeplineClient {
3340
3383
  );
3341
3384
  }
3342
3385
 
3386
+ // ——————————————————————————————————————————————————————————
3387
+ // Artifacts
3388
+ // ——————————————————————————————————————————————————————————
3389
+
3390
+ /** List this workspace's artifacts, most recently changed first. */
3391
+ async listArtifacts(input?: {
3392
+ cursor?: string;
3393
+ limit?: number;
3394
+ }): Promise<{ artifacts: Artifact[]; next_cursor: string | null }> {
3395
+ const params = new URLSearchParams();
3396
+ if (input?.cursor) params.set('cursor', input.cursor);
3397
+ if (input?.limit) params.set('limit', String(input.limit));
3398
+ const query = params.size > 0 ? `?${params}` : '';
3399
+ return await this.http.get(`/api/v2/artifacts${query}`);
3400
+ }
3401
+
3402
+ /** One artifact and what the caller may do with it. */
3403
+ async getArtifact(id: string): Promise<ArtifactDetail> {
3404
+ return await this.http.get<ArtifactDetail>(
3405
+ `/api/v2/artifacts/${encodeURIComponent(id)}`,
3406
+ );
3407
+ }
3408
+
3409
+ /** Create an artifact that shows a Play's runs at a fixed URL. */
3410
+ async createArtifact(input: {
3411
+ name: string;
3412
+ play: string;
3413
+ input?: Record<string, unknown>;
3414
+ description?: string;
3415
+ }): Promise<Artifact> {
3416
+ return await this.http.post<Artifact>('/api/v2/artifacts', input);
3417
+ }
3418
+
3419
+ /** Change the name, description, Play, or saved input. */
3420
+ async updateArtifact(
3421
+ id: string,
3422
+ input: {
3423
+ name?: string;
3424
+ description?: string | null;
3425
+ play?: string;
3426
+ input?: Record<string, unknown>;
3427
+ },
3428
+ ): Promise<Artifact> {
3429
+ return await this.http.patch<Artifact>(
3430
+ `/api/v2/artifacts/${encodeURIComponent(id)}`,
3431
+ input,
3432
+ );
3433
+ }
3434
+
3435
+ /** Who can open an artifact: workspace members, or anyone with its URL. */
3436
+ async setArtifactAccess(
3437
+ id: string,
3438
+ access: ArtifactAccess,
3439
+ ): Promise<Artifact> {
3440
+ return await this.http.post<Artifact>(
3441
+ `/api/v2/artifacts/${encodeURIComponent(id)}/access`,
3442
+ { access },
3443
+ );
3444
+ }
3445
+
3446
+ /** Every run of the artifact's Play, newest first. */
3447
+ async listArtifactRuns(
3448
+ id: string,
3449
+ input?: { limit?: number; offset?: number },
3450
+ ): Promise<{ runs: ArtifactRunSummary[]; total: number }> {
3451
+ const params = new URLSearchParams();
3452
+ if (input?.limit) params.set('limit', String(input.limit));
3453
+ if (input?.offset) params.set('offset', String(input.offset));
3454
+ const query = params.size > 0 ? `?${params}` : '';
3455
+ return await this.http.get(
3456
+ `/api/v2/artifacts/${encodeURIComponent(id)}/runs${query}`,
3457
+ );
3458
+ }
3459
+
3460
+ /**
3461
+ * Refresh an artifact: run its Play with its saved input (or `input`). The run
3462
+ * goes through the normal run API; the artifact shows it when it finishes.
3463
+ */
3464
+ async refreshArtifact(
3465
+ id: string,
3466
+ input?: Record<string, unknown>,
3467
+ ): Promise<PlayRunStart & { artifact: string }> {
3468
+ const intent = await this.http.post<{
3469
+ id: string;
3470
+ play: string;
3471
+ input: Record<string, unknown>;
3472
+ }>(`/api/v2/artifacts/${encodeURIComponent(id)}/refresh`, {});
3473
+ const started = await this.startPlayRun({
3474
+ name: intent.play,
3475
+ input: input ?? intent.input,
3476
+ });
3477
+ return { ...started, artifact: intent.id };
3478
+ }
3479
+
3480
+ /** Delete an artifact. Its Play and runs are not touched. */
3481
+ async deleteArtifact(id: string): Promise<{ id: string; deleted: boolean }> {
3482
+ return await this.http.delete(
3483
+ `/api/v2/artifacts/${encodeURIComponent(id)}`,
3484
+ );
3485
+ }
3486
+
3487
+ /** The workspace artifact rules and what the caller may do. */
3488
+ async getArtifactPermissions(): Promise<{
3489
+ rules: ArtifactPermissionRules;
3490
+ can: ArtifactAbilities | null;
3491
+ }> {
3492
+ return await this.http.get('/api/v2/artifacts/permissions');
3493
+ }
3494
+
3495
+ /** Change artifact rules. Admins only; omitted verbs keep their rule. */
3496
+ async setArtifactPermissions(
3497
+ rules: Partial<ArtifactPermissionRules>,
3498
+ ): Promise<{ rules: ArtifactPermissionRules }> {
3499
+ return await this.http.put('/api/v2/artifacts/permissions', { rules });
3500
+ }
3501
+
3343
3502
  /** List secret metadata visible to the current workspace. */
3344
3503
  async listSecrets(): Promise<PlaySecretMetadata[]> {
3345
3504
  const response = await this.http.get<{ secrets?: PlaySecretMetadata[] }>(
@@ -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.509',
208
+ version: '0.3.511',
209
209
  updateSummary: {
210
210
  introducedIn: '0.3.90',
211
211
  summary:
@@ -2,8 +2,8 @@
2
2
  * What an organization may watch.
3
3
  *
4
4
  * Monitors are priced and reasoned about in accounts, not in rows: an
5
- * organization watches five thousand companies, and watches up to five signals
6
- * on each of them. A flat monitor ceiling could not express either half - it
5
+ * workspace can watch up to its plan's account limit and watch several signals
6
+ * on each account. A flat monitor ceiling could not express either half - it
7
7
  * let one company consume the whole allowance, and it made "how many accounts
8
8
  * can I watch" unanswerable without knowing how many signals each would use.
9
9
  *
@@ -11,8 +11,13 @@
11
11
  * product and is deliberately not a third number to reason about.
12
12
  */
13
13
  import { ORG_LIMITS, OrgLimit } from '@deepline/billing/org-limits/registry';
14
+ import {
15
+ DEFAULT_PLAN_KEY,
16
+ PLAN_LIMITS,
17
+ } from '@deepline/billing/org-limits/plans';
14
18
 
15
19
  export const DEFAULT_ORG_MONITOR_ENTITY_LIMIT =
20
+ PLAN_LIMITS[DEFAULT_PLAN_KEY][OrgLimit.MonitorWatchedEntities] ??
16
21
  ORG_LIMITS[OrgLimit.MonitorWatchedEntities].defaultValue;
17
22
 
18
23
  /** Signals one account may be watched with, e.g. jobs + funding + news. */
@@ -1400,15 +1400,15 @@
1400
1400
  "id": "convex.refresh-tool-usage-popularity",
1401
1401
  "name": "Refresh tool usage popularity",
1402
1402
  "scheduler": "convex_cron",
1403
- "cadence": "37 0 * * *",
1403
+ "cadence": "37 * * * *",
1404
1404
  "timezone": "UTC",
1405
1405
  "source": "packages/convex/crons.ts",
1406
1406
  "locator": "refresh tool usage popularity snapshot",
1407
1407
  "owner": "integrations",
1408
1408
  "criticality": "operational",
1409
1409
  "purpose": "Sum distinct user-days per tool over the last 28 complete UTC days into the snapshot tools search uses as a ranking prior, then delete user-day rows past retention.",
1410
- "successDefinition": "A new snapshot row is written and expired user-day rows are drained; an empty snapshot is valid before any usage is folded.",
1411
- "failureDefinition": "Reading daily counts, writing the snapshot, or draining expired rows fails, leaving search on the previous snapshot.",
1410
+ "successDefinition": "A complete snapshot is published and up to 2,000 expired user-day records are removed; an empty snapshot is valid before usage is folded.",
1411
+ "failureDefinition": "If a scan exceeds its input budget or any required read or write fails, Search keeps serving the previous snapshot.",
1412
1412
  "startGraceMs": 120000,
1413
1413
  "runTimeoutMs": 1800000,
1414
1414
  "failureAlert": "convex_action_wrapper",
@@ -11,6 +11,13 @@
11
11
  */
12
12
  import { spawnSync } from 'node:child_process';
13
13
  import { FlyMachinesClient, requireFlyToken } from '../fly-machines';
14
+ import {
15
+ applyToEveryMachine,
16
+ classifyFlyRequestError,
17
+ createWithReadBeforeRetry,
18
+ describeMachineFailures,
19
+ runFlyctlWithTransientRetry,
20
+ } from '../fly-transient-retry';
14
21
  import { machineIsServingRuntimeGateway } from '../runtime-gateway-capacity';
15
22
  import {
16
23
  RECEIPT_GATEWAY_DRAIN_TIMEOUT,
@@ -217,14 +224,33 @@ export async function restoreRelaySourceGeneration(input: {
217
224
  'Execution relay rollback requires exact green and blue Machine identities.',
218
225
  );
219
226
  }
220
- for (const machineId of input.blueMachineIds) {
221
- await input.uncordon(machineId);
227
+ // Attempt every source Machine even when one fails, so one provider error
228
+ // cannot leave the rest of the retained fleet cordoned and unreported.
229
+ const restored = await applyToEveryMachine({
230
+ machineIds: input.blueMachineIds,
231
+ action: 'uncordon',
232
+ apply: input.uncordon,
233
+ });
234
+ if (restored.failed.length > 0) {
235
+ // Keep the candidate generation admitted: cordoning it beside an
236
+ // incomplete source fleet could drop relay capacity below its minimum.
237
+ // Rerunning rollback converges because uncordon is idempotent.
238
+ throw new Error(
239
+ `Execution relay rollback could not restore ${restored.failed.length}/${input.blueMachineIds.length} source Machine(s) [${restored.failed.map(({ machineId }) => machineId).join(', ')}]; the candidate generation [${input.greenMachineIds.join(', ')}] stays admitted: ${describeMachineFailures('uncordon', restored.failed)}`,
240
+ );
222
241
  }
223
242
  await Promise.all(input.blueMachineIds.map(input.assertReady));
224
- for (const machineId of input.greenMachineIds) {
225
- await input.cordon(machineId);
226
- }
243
+ const removed = await applyToEveryMachine({
244
+ machineIds: input.greenMachineIds,
245
+ action: 'cordon',
246
+ apply: input.cordon,
247
+ });
227
248
  await Promise.all(input.blueMachineIds.map(input.assertReady));
249
+ if (removed.failed.length > 0) {
250
+ throw new Error(
251
+ `Execution relay rollback restored the source generation but could not cordon ${removed.failed.length}/${input.greenMachineIds.length} candidate Machine(s) [${removed.failed.map(({ machineId }) => machineId).join(', ')}]: ${describeMachineFailures('cordon', removed.failed)}`,
252
+ );
253
+ }
228
254
  }
229
255
 
230
256
  function run(command: string, args: string[]): void {
@@ -237,6 +263,26 @@ function run(command: string, args: string[]): void {
237
263
  `${command} ${args.join(' ')} failed with ${result.status}.`,
238
264
  );
239
265
  }
266
+
267
+ /** Cordon and uncordon converge when repeated; retry transient Fly errors. */
268
+ async function setMachineRouting(
269
+ transition: 'cordon' | 'uncordon',
270
+ machineId: string,
271
+ ): Promise<void> {
272
+ await runFlyctlWithTransientRetry(
273
+ ['machine', transition, machineId, '-a', app],
274
+ {
275
+ operation: 'idempotent-write',
276
+ spawn: spawnSync,
277
+ },
278
+ );
279
+ }
280
+
281
+ function releaseFlyClient(): FlyMachinesClient {
282
+ return new FlyMachinesClient(app, requireFlyToken(), fetch, {
283
+ transientRetry: true,
284
+ });
285
+ }
240
286
  async function inventory(client: FlyMachinesClient): Promise<FlyMachine[]> {
241
287
  return await client.listMachines();
242
288
  }
@@ -309,7 +355,7 @@ async function assertExactReady(machineId: string): Promise<void> {
309
355
  }
310
356
  async function prepare(sha: string): Promise<void> {
311
357
  run('bun', productionGatewayImageEnsureArgs('executionRelay', sha));
312
- const client = new FlyMachinesClient(app, requireFlyToken(), fetch);
358
+ const client = releaseFlyClient();
313
359
  const initial = await inventory(client);
314
360
  const existing = candidates(initial, sha);
315
361
  const blue = serving(initial);
@@ -332,6 +378,29 @@ async function prepare(sha: string): Promise<void> {
332
378
  return;
333
379
  }
334
380
  }
381
+ const createCandidate = (name: string, source: FlyMachine) =>
382
+ client.createMachine({
383
+ name,
384
+ region: topology.region,
385
+ skip_service_registration: true,
386
+ config: gatewayMachineConfig({
387
+ profile: 'production',
388
+ role: 'execution',
389
+ image: image(sha),
390
+ metadata: {
391
+ deepline_gateway_role: 'execution',
392
+ [EXECUTION_RELAY_ROLLOUT_METADATA]: sha,
393
+ [EXECUTION_RELAY_SOURCE_METADATA]: source.id!,
394
+ fly_process_group: topology.processGroup,
395
+ ...(source.config?.metadata?.[
396
+ RUNTIME_GATEWAY_AUTOSCALED_METADATA_KEY
397
+ ] === '1' ||
398
+ source.name?.startsWith('execution-relay-autoscale-') === true
399
+ ? { [RUNTIME_GATEWAY_AUTOSCALED_METADATA_KEY]: '1' }
400
+ : {}),
401
+ },
402
+ }),
403
+ });
335
404
  if (existing.length === 0) {
336
405
  if (
337
406
  blue.length < topology.minimumMachines ||
@@ -341,27 +410,17 @@ async function prepare(sha: string): Promise<void> {
341
410
  'Cannot prepare an execution relay generation without a healthy serving fleet.',
342
411
  );
343
412
  for (const [index, source] of blue.entries()) {
344
- await client.createMachine({
345
- name: candidateName(sha, index),
346
- region: topology.region,
347
- skip_service_registration: true,
348
- config: gatewayMachineConfig({
349
- profile: 'production',
350
- role: 'execution',
351
- image: image(sha),
352
- metadata: {
353
- deepline_gateway_role: 'execution',
354
- [EXECUTION_RELAY_ROLLOUT_METADATA]: sha,
355
- [EXECUTION_RELAY_SOURCE_METADATA]: source.id!,
356
- fly_process_group: topology.processGroup,
357
- ...(source.config?.metadata?.[
358
- RUNTIME_GATEWAY_AUTOSCALED_METADATA_KEY
359
- ] === '1' ||
360
- source.name?.startsWith('execution-relay-autoscale-') === true
361
- ? { [RUNTIME_GATEWAY_AUTOSCALED_METADATA_KEY]: '1' }
362
- : {}),
363
- },
364
- }),
413
+ const name = candidateName(sha, index);
414
+ // A transient create failure is ambiguous; re-read before any retry
415
+ // so a candidate Fly already created is adopted, never duplicated.
416
+ await createWithReadBeforeRetry({
417
+ create: () => createCandidate(name, source),
418
+ findExisting: async () =>
419
+ candidates(await inventory(client), sha).find(
420
+ (machine) => machine.name === name,
421
+ ),
422
+ classify: classifyFlyRequestError,
423
+ options: { label: `Create execution relay candidate ${name}` },
365
424
  });
366
425
  }
367
426
  }
@@ -379,7 +438,7 @@ async function prepare(sha: string): Promise<void> {
379
438
  // separately; do not assume the header is the blocker.
380
439
  }
381
440
  async function activate(sha: string): Promise<void> {
382
- const client = new FlyMachinesClient(app, requireFlyToken(), fetch);
441
+ const client = releaseFlyClient();
383
442
  const machines = await inventory(client);
384
443
  const green = candidates(machines, sha);
385
444
  if (
@@ -409,13 +468,9 @@ async function activate(sha: string): Promise<void> {
409
468
  machineIdsToUncordon: green
410
469
  .filter((machine) => machine.cordoned === true)
411
470
  .map((machine) => machine.id!),
412
- uncordon: async (machineId) => {
413
- run('flyctl', ['machine', 'uncordon', machineId, '-a', app]);
414
- },
471
+ uncordon: (machineId) => setMachineRouting('uncordon', machineId),
415
472
  assertReady: assertExactReady,
416
- cordon: async (machineId) => {
417
- run('flyctl', ['machine', 'cordon', machineId, '-a', app]);
418
- },
473
+ cordon: (machineId) => setMachineRouting('cordon', machineId),
419
474
  });
420
475
  const refreshed = await inventory(client);
421
476
  for (const machineId of sourceMachineIds as string[]) {
@@ -427,13 +482,13 @@ async function activate(sha: string): Promise<void> {
427
482
  );
428
483
  }
429
484
  if (blue.cordoned === false) {
430
- run('flyctl', ['machine', 'cordon', machineId, '-a', app]);
485
+ await setMachineRouting('cordon', machineId);
431
486
  }
432
487
  }
433
488
  }
434
489
 
435
490
  async function rollback(sha: string): Promise<void> {
436
- const client = new FlyMachinesClient(app, requireFlyToken(), fetch);
491
+ const client = releaseFlyClient();
437
492
  const current = await inventory(client);
438
493
  const green = candidates(current, sha);
439
494
  if (
@@ -467,19 +522,15 @@ async function rollback(sha: string): Promise<void> {
467
522
  await restoreRelaySourceGeneration({
468
523
  greenMachineIds: green.map((machine) => machine.id!),
469
524
  blueMachineIds: sourceMachineIds as string[],
470
- uncordon: async (machineId) => {
471
- run('flyctl', ['machine', 'uncordon', machineId, '-a', app]);
472
- },
473
- cordon: async (machineId) => {
474
- run('flyctl', ['machine', 'cordon', machineId, '-a', app]);
475
- },
525
+ uncordon: (machineId) => setMachineRouting('uncordon', machineId),
526
+ cordon: (machineId) => setMachineRouting('cordon', machineId),
476
527
  assertReady: assertExactReady,
477
528
  });
478
529
  }
479
530
  /** Remove only a candidate that never received public traffic. This mirrors
480
531
  * receipt cleanup so a failed pre-commit proof cannot strand relay Machines. */
481
532
  async function cleanup(sha: string): Promise<void> {
482
- const client = new FlyMachinesClient(app, requireFlyToken(), fetch);
533
+ const client = releaseFlyClient();
483
534
  const targets = candidates(await inventory(client), sha);
484
535
  if (targets.some((machine) => !machine.id)) {
485
536
  throw new Error(