deepline 0.3.495 → 0.3.496

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 (156) hide show
  1. package/dist/bundling-sources/sdk/src/client-core.ts +91 -1
  2. package/dist/bundling-sources/sdk/src/plays/run-request.ts +5 -19
  3. package/dist/bundling-sources/sdk/src/release.ts +1 -1
  4. package/dist/bundling-sources/shared_libs/monitors/billing/credit-recovery.ts +79 -0
  5. package/dist/bundling-sources/shared_libs/observability/scheduled-jobs.json +18 -0
  6. package/dist/bundling-sources/shared_libs/observability/scheduled-work-control.ts +19 -3
  7. package/dist/bundling-sources/shared_libs/play-runtime/deployment/fly-machines.ts +7 -1
  8. package/dist/bundling-sources/shared_libs/play-runtime/deployment/runtime-gateway-drain.ts +110 -66
  9. package/dist/bundling-sources/shared_libs/play-runtime/deployment/vercel-fly-rollback-alignment.ts +57 -0
  10. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres.ts +15 -0
  11. package/dist/bundling-sources/shared_libs/plays/docflow.ts +19 -10
  12. package/dist/bundling-sources/shared_libs/plays/static-pipeline.ts +26 -6
  13. package/dist/bundling-sources/shared_libs/product-notifications/slack-payload.ts +4 -1
  14. package/dist/cli/{auth-B2YUNFQ6.mjs → auth-EU4EFRDJ.mjs} +5 -5
  15. package/dist/cli/auth-SHWC5FMY.js +43 -0
  16. package/dist/cli/{billing-2Q7TMNRE.js → billing-4JJLTVK4.js} +80 -80
  17. package/dist/cli/{billing-5TR7ZBZM.mjs → billing-GMVH3RBX.mjs} +7 -7
  18. package/dist/cli/{chunk-ACVT5LPN.js → chunk-3HIPDJWJ.js} +53 -53
  19. package/dist/cli/{chunk-DFK5IJMT.mjs → chunk-3KA466RV.mjs} +1 -1
  20. package/dist/cli/{chunk-SC5GHGFD.mjs → chunk-4NKAM4GX.mjs} +2 -2
  21. package/dist/cli/{chunk-Z33PZUWG.js → chunk-5GK6J7MH.js} +5 -5
  22. package/dist/cli/{chunk-TSKVPEVZ.mjs → chunk-5M4PLPTR.mjs} +46 -3
  23. package/dist/cli/{chunk-CTFR52JC.js → chunk-5YSIHOGV.js} +26 -26
  24. package/dist/cli/{chunk-RBBOUPME.mjs → chunk-6QIAEXRH.mjs} +1 -1
  25. package/dist/cli/{chunk-CKLJAQIV.mjs → chunk-6UUZM4FY.mjs} +5 -5
  26. package/dist/cli/{chunk-T4PGA6UD.js → chunk-73CBLBNP.js} +1 -1
  27. package/dist/cli/{chunk-FC4JGTFC.mjs → chunk-7NBDLK3N.mjs} +1 -1
  28. package/dist/cli/{chunk-HJ5LYO6U.mjs → chunk-7Q7VPFPR.mjs} +2 -2
  29. package/dist/cli/{chunk-I66IWCY4.mjs → chunk-7U6W3CKT.mjs} +4 -4
  30. package/dist/cli/{chunk-TUAEM76Y.js → chunk-AOBAVBSX.js} +108 -65
  31. package/dist/cli/{chunk-KG2FUYWB.mjs → chunk-CNMIYEB4.mjs} +3 -3
  32. package/dist/cli/{chunk-DVQHG6AM.mjs → chunk-CS2AEAD6.mjs} +63 -11
  33. package/dist/cli/{chunk-MG3WST3Z.mjs → chunk-DFW6P6ZN.mjs} +2 -2
  34. package/dist/cli/{chunk-L5ZXEYTQ.mjs → chunk-E3KXXJWR.mjs} +6 -6
  35. package/dist/cli/{chunk-PKV5CD3W.js → chunk-EQR5O2D2.js} +87 -35
  36. package/dist/cli/{chunk-CAWE3MS2.js → chunk-EX4JEFYI.js} +16 -16
  37. package/dist/cli/{chunk-S2QARJLX.mjs → chunk-FXPICCUU.mjs} +1 -1
  38. package/dist/cli/{chunk-7OGADAAA.js → chunk-GKZUGHDK.js} +6 -6
  39. package/dist/cli/{chunk-PHO53W67.js → chunk-GRIHMNYM.js} +4 -4
  40. package/dist/cli/{chunk-UKGOZOTT.js → chunk-HIAFBOYA.js} +8 -8
  41. package/dist/cli/{chunk-FLJSK32S.mjs → chunk-IMWJRBV5.mjs} +1 -1
  42. package/dist/cli/{chunk-OFBDI5S3.mjs → chunk-IXPZROZX.mjs} +2 -2
  43. package/dist/cli/{chunk-ZBQBH4IT.js → chunk-J55ZM5CK.js} +3 -3
  44. package/dist/cli/{chunk-TCNILHMS.js → chunk-JEPNE4N5.js} +5 -5
  45. package/dist/cli/{chunk-5OKQPDYJ.js → chunk-JU4LIA2T.js} +7 -7
  46. package/dist/cli/{chunk-UMFZQREB.js → chunk-KKI5GWED.js} +94 -94
  47. package/dist/cli/{chunk-UDFO2MWA.js → chunk-MWQ3WQ4Q.js} +41 -41
  48. package/dist/cli/{chunk-XR6RCBB3.mjs → chunk-O36ZPHJG.mjs} +10 -10
  49. package/dist/cli/{chunk-XAOLMEN5.js → chunk-PHVRS56F.js} +14 -14
  50. package/dist/cli/{chunk-WVL5HGUG.js → chunk-QEBQIGXP.js} +2 -2
  51. package/dist/cli/{chunk-LQKZG5RN.js → chunk-QN6IULFT.js} +53 -53
  52. package/dist/cli/{chunk-SR6VS5PG.mjs → chunk-QYXUZX5N.mjs} +4 -4
  53. package/dist/cli/{chunk-B3ROCZ5Y.js → chunk-QZ7I4NZZ.js} +2 -2
  54. package/dist/cli/{chunk-7LLUJQM5.mjs → chunk-R4H5MCG4.mjs} +4 -4
  55. package/dist/cli/{chunk-H5L2Q2GI.mjs → chunk-SH6HOR25.mjs} +2 -2
  56. package/dist/cli/{chunk-TMO7W4P2.mjs → chunk-U6SE6757.mjs} +1 -1
  57. package/dist/cli/{chunk-7YNZRALI.mjs → chunk-UT3ORL35.mjs} +3 -3
  58. package/dist/cli/{chunk-PEIOQKTA.js → chunk-UTG3STCR.js} +3 -3
  59. package/dist/cli/{chunk-XKYQR3QK.js → chunk-W7DZ6UGP.js} +3 -3
  60. package/dist/cli/{chunk-ZB6UYG5I.mjs → chunk-WCBZHSC4.mjs} +5 -5
  61. package/dist/cli/{chunk-Y2DUGUUU.js → chunk-WEGGJMNF.js} +21 -21
  62. package/dist/cli/{chunk-JRBQC6L4.mjs → chunk-WTZ7Y3IZ.mjs} +2 -2
  63. package/dist/cli/{chunk-TFMV3NKL.mjs → chunk-YHFW7MBT.mjs} +1 -1
  64. package/dist/cli/{chunk-XX6PRYFI.js → chunk-Z27R2BG7.js} +16 -16
  65. package/dist/cli/{chunk-MAMEKGLI.js → chunk-ZL4Q4T3G.js} +7 -7
  66. package/dist/cli/{csv-5UQXKWLE.mjs → csv-ET7ESAPM.mjs} +4 -4
  67. package/dist/cli/{csv-DZQ77T67.js → csv-JWBLNEPC.js} +13 -13
  68. package/dist/cli/{db-JIPLUHA6.js → db-3ZGQXWTQ.js} +28 -28
  69. package/dist/cli/{db-F62BVFTP.mjs → db-4PIWQPR6.mjs} +7 -7
  70. package/dist/cli/describe-KO3OQBIR.js +50 -0
  71. package/dist/cli/{describe-J7KYHONJ.mjs → describe-OREUCFC2.mjs} +18 -18
  72. package/dist/cli/describe-core.d.mts +3 -3
  73. package/dist/cli/describe-core.d.ts +3 -3
  74. package/dist/cli/{executions-XB4F2KZD.mjs → executions-HW6PMZOF.mjs} +7 -7
  75. package/dist/cli/{executions-XQ4FNJ27.js → executions-YR545MRU.js} +9 -9
  76. package/dist/cli/{feedback-5CR4CJ6W.mjs → feedback-B2FJ6HPA.mjs} +4 -4
  77. package/dist/cli/{feedback-Q6JRCMDV.js → feedback-FNVHJQEC.js} +8 -8
  78. package/dist/cli/{git-P5WBBUT3.mjs → git-CCNPW3CA.mjs} +5 -5
  79. package/dist/cli/git-X2QJ2B5O.js +25 -0
  80. package/dist/cli/index.js +137 -137
  81. package/dist/cli/index.mjs +40 -40
  82. package/dist/cli/{legacy-noops-EJAB6III.js → legacy-noops-2EBZS45D.js} +8 -8
  83. package/dist/cli/{legacy-noops-H5JJVYZ2.mjs → legacy-noops-VJLCXTPB.mjs} +5 -5
  84. package/dist/cli/{monitors-QPFAT2J5.mjs → monitors-4AMETRW7.mjs} +190 -8
  85. package/dist/cli/{monitors-7DOGM7RO.js → monitors-JNWKPCN5.js} +318 -136
  86. package/dist/cli/{org-QOBB4IN3.js → org-7FUHVFYU.js} +73 -73
  87. package/dist/cli/{org-BH7ATDIJ.mjs → org-LO6GSCCG.mjs} +7 -7
  88. package/dist/cli/{pages-PJH2TXZQ.mjs → pages-PJ32M2PU.mjs} +7 -7
  89. package/dist/cli/{pages-PLTE54KM.js → pages-TT4TZOOV.js} +19 -19
  90. package/dist/cli/{play-ULTJ3LPA.mjs → play-QJEZAIZB.mjs} +19 -48
  91. package/dist/cli/{play-XZAPTF3T.js → play-VN7DFYDP.js} +618 -647
  92. package/dist/cli/{providers-6NUTRVE4.mjs → providers-24ER3SND.mjs} +7 -7
  93. package/dist/cli/{providers-SKXLW7M3.js → providers-IDFN2FCR.js} +10 -10
  94. package/dist/cli/{quickstart-JFCIIGII.js → quickstart-AQDCRVUQ.js} +6 -6
  95. package/dist/cli/{quickstart-5HMJMXVT.mjs → quickstart-FKENQU34.mjs} +4 -4
  96. package/dist/cli/{run-BRAXLCBC.js → run-HCASJQZY.js} +37 -37
  97. package/dist/cli/{run-2BJZPY4K.mjs → run-KXMRE5ZD.mjs} +23 -23
  98. package/dist/cli/{search-IDXSB2CV.mjs → search-3F2T33OE.mjs} +8 -8
  99. package/dist/cli/search-OGY6SQDJ.js +32 -0
  100. package/dist/cli/{search-output-CJ4TNYF7.js → search-output-GFCEGNCJ.js} +6 -6
  101. package/dist/cli/{search-output-AATMH4QG.mjs → search-output-U6PM5KAH.mjs} +4 -4
  102. package/dist/cli/{secrets-6SMKTBFT.js → secrets-KYVUP755.js} +16 -16
  103. package/dist/cli/{secrets-UQNEJSNG.mjs → secrets-ZZSOVXOX.mjs} +7 -7
  104. package/dist/cli/{sessions-MHTUVPSR.mjs → sessions-4Z62CVHL.mjs} +5 -5
  105. package/dist/cli/{sessions-W3KU4Q4X.js → sessions-7JFKTUQS.js} +6 -6
  106. package/dist/cli/{settings-KNYJ6GXK.mjs → settings-OXG7IRVC.mjs} +12 -12
  107. package/dist/cli/{settings-BA52NEU5.js → settings-X4PSK4EW.js} +79 -79
  108. package/dist/cli/{setup-D5HCJAVU.js → setup-NCJEDW4W.js} +49 -49
  109. package/dist/cli/{setup-TLTZ2YCO.mjs → setup-RB7JE6KA.mjs} +9 -9
  110. package/dist/cli/{skills-DPLM4EGS.mjs → skills-D4BR2WU2.mjs} +7 -7
  111. package/dist/cli/skills-WWWFRDCA.js +36 -0
  112. package/dist/cli/{tools-I4ZOJV23.mjs → tools-CEOD7VD5.mjs} +17 -17
  113. package/dist/cli/tools-QMSAA3LC.js +57 -0
  114. package/dist/cli/update-HTDFPN7L.js +34 -0
  115. package/dist/cli/{update-VIFS7IK5.mjs → update-UKUMQ6FC.mjs} +9 -9
  116. package/dist/cli/{workflow-TAQBNDV7.mjs → workflow-EKKTTSCJ.mjs} +8 -8
  117. package/dist/cli/{workflow-7REPOHXM.js → workflow-LFWQWZKS.js} +18 -18
  118. package/dist/{client-CKVH6tmp.d.ts → client-Cj3UqrCZ.d.ts} +1 -1
  119. package/dist/{client-BDT_LwuM.d.mts → client-DSCTVVRj.d.mts} +1 -1
  120. package/dist/{client-core-CEixe_C0.d.mts → client-core-B-8DTIN1.d.mts} +44 -3
  121. package/dist/{client-core-RS-d-vtY.d.ts → client-core-dI4KTuWS.d.ts} +44 -3
  122. package/dist/{compiler-manifest-CPEF48NM.d.mts → compiler-manifest-DlXDyndN.d.mts} +2 -0
  123. package/dist/{compiler-manifest-CPEF48NM.d.ts → compiler-manifest-DlXDyndN.d.ts} +2 -0
  124. package/dist/{errors-BWbPzqwo.d.mts → errors-BtriA2ld.d.mts} +1 -1
  125. package/dist/{errors-B-PJXveg.d.ts → errors-DmcLykM7.d.ts} +1 -1
  126. package/dist/{index-CvVxPpE8.d.ts → index--Jw-slHY.d.ts} +1 -1
  127. package/dist/{index-BJ8AA1F9.d.mts → index-DI0sR_fX.d.mts} +1 -1
  128. package/dist/index.d.mts +7 -7
  129. package/dist/index.d.ts +7 -7
  130. package/dist/index.js +10 -10
  131. package/dist/index.mjs +7 -7
  132. package/dist/install-integrity.json +110 -110
  133. package/dist/plays/bundle-play-file.d.mts +3 -3
  134. package/dist/plays/bundle-play-file.d.ts +3 -3
  135. package/dist/plays/play-description.d.mts +2 -2
  136. package/dist/plays/play-description.d.ts +2 -2
  137. package/dist/plays/run-request.d.mts +2 -2
  138. package/dist/plays/run-request.d.ts +2 -2
  139. package/dist/plays/run-request.js +2 -2
  140. package/dist/plays/run-request.mjs +1 -1
  141. package/dist/release.d.mts +1 -1
  142. package/dist/release.d.ts +1 -1
  143. package/dist/release.js +2 -2
  144. package/dist/release.mjs +1 -1
  145. package/dist/server.d.mts +4 -4
  146. package/dist/server.d.ts +4 -4
  147. package/dist/server.js +6 -6
  148. package/dist/server.mjs +4 -4
  149. package/package.json +1 -1
  150. package/dist/cli/auth-GAOWVOK4.js +0 -43
  151. package/dist/cli/describe-BA4RAZ7J.js +0 -50
  152. package/dist/cli/git-EAO432S2.js +0 -25
  153. package/dist/cli/search-4MU2G6HV.js +0 -32
  154. package/dist/cli/skills-SVUWVXCE.js +0 -36
  155. package/dist/cli/tools-RJSP76HX.js +0 -57
  156. package/dist/cli/update-YT6JPIC6.js +0 -34
@@ -1297,6 +1297,31 @@ export type MonitorsListOptions = {
1297
1297
  includeConsumers?: boolean;
1298
1298
  };
1299
1299
 
1300
+ /** Options for `client.monitors.ledger(...)`. */
1301
+ export type MonitorsLedgerOptions = {
1302
+ /** Search name, key, subject, signal and deploy filters. */
1303
+ search?: string;
1304
+ /** Customer statuses to include; every status except `stopped` by default. */
1305
+ states?: string[];
1306
+ /** Signal keys, as the response's `signals[].key` lists them. */
1307
+ signals?: string[];
1308
+ /** A Play definition id, or `none` for monitors no Play listens to. */
1309
+ play?: string;
1310
+ /** `findings` orders by the most findings in `window`. */
1311
+ sort?: 'recent' | 'installed' | 'name' | 'findings';
1312
+ /** The span each row's findings count covers; `30d` by default. */
1313
+ window?: '1d' | '7d' | '30d' | '90d' | '1y';
1314
+ limit?: number | string;
1315
+ cursor?: string;
1316
+ };
1317
+
1318
+ /** The Monitors list page: rows plus counts, options and failing Plays. */
1319
+ export type MonitorsLedgerResult = Record<string, unknown> & {
1320
+ monitors?: Array<Record<string, unknown>>;
1321
+ total?: number;
1322
+ next_cursor?: string | null;
1323
+ };
1324
+
1300
1325
  /**
1301
1326
  * Server-owned monitor payload shapes returned by the deploy/check/get/mutation
1302
1327
  * endpoints. Kept as open records because the render layer and the endpoints
@@ -1926,6 +1951,17 @@ export type MonitorsNamespace = {
1926
1951
  list: (options?: MonitorsListOptions) => Promise<MonitorsListResult>;
1927
1952
  /** Fetch one deployed monitor by public key with bounded current listener health. */
1928
1953
  get: (key: string) => Promise<MonitorDetail>;
1954
+ /** The Monitors list: monitors with status, radar filters and the Plays
1955
+ * each triggers, plus status counts and failing Plays. */
1956
+ ledger: (options?: MonitorsLedgerOptions) => Promise<MonitorsLedgerResult>;
1957
+ /** One monitor as its Monitors page shows it, with every Play it triggers. */
1958
+ ledgerGet: (key: string) => Promise<Record<string, unknown>>;
1959
+ /** One page of a monitor's delivered findings, newest first, with each
1960
+ * Play's recorded run per finding. */
1961
+ ledgerFindings: (
1962
+ key: string,
1963
+ options?: { cursor?: string },
1964
+ ) => Promise<Record<string, unknown>>;
1929
1965
  /** Test a deployed monitor's callback envelope without side effects. */
1930
1966
  test: (
1931
1967
  key: string,
@@ -3017,6 +3053,10 @@ export class DeeplineClient {
3017
3053
  ? this.deployMonitor(definition, { dryRun: true })
3018
3054
  : this.syncScalarMonitor(definition, options),
3019
3055
  list: (options) => this.listMonitors(options),
3056
+ ledger: (options) => this.listMonitorLedger(options),
3057
+ ledgerGet: (key) => this.getMonitorLedgerEntry(key),
3058
+ ledgerFindings: (key, options) =>
3059
+ this.listMonitorLedgerFindings(key, options),
3020
3060
  get: (key) => this.getMonitor(key),
3021
3061
  test: (key, payload, options) =>
3022
3062
  this.testMonitorWebhook(key, payload, options),
@@ -7222,6 +7262,51 @@ export class DeeplineClient {
7222
7262
  );
7223
7263
  }
7224
7264
 
7265
+ /** The Monitors list. Prefer `client.monitors.ledger(...)`. */
7266
+ async listMonitorLedger(
7267
+ options?: MonitorsLedgerOptions,
7268
+ ): Promise<MonitorsLedgerResult> {
7269
+ const params = new URLSearchParams();
7270
+ if (options?.search) params.set('q', options.search);
7271
+ for (const state of options?.states ?? []) params.append('state', state);
7272
+ for (const signal of options?.signals ?? [])
7273
+ params.append('signal', signal);
7274
+ if (options?.play) params.set('play', options.play);
7275
+ if (options?.sort) params.set('sort', options.sort);
7276
+ if (options?.window) params.set('window', options.window);
7277
+ if (options?.limit !== undefined)
7278
+ params.set('limit', String(options.limit));
7279
+ if (options?.cursor) params.set('cursor', options.cursor);
7280
+ const query = params.toString();
7281
+ const suffix = query ? `?${query}` : '';
7282
+ return this.http.request<MonitorsLedgerResult>(
7283
+ `/api/v2/monitors/ledger${suffix}`,
7284
+ { method: 'GET' },
7285
+ );
7286
+ }
7287
+
7288
+ /** One Monitors list entry. Prefer `client.monitors.ledgerGet(...)`. */
7289
+ async getMonitorLedgerEntry(key: string): Promise<Record<string, unknown>> {
7290
+ return this.http.request<Record<string, unknown>>(
7291
+ `/api/v2/monitors/ledger/${encodeURIComponent(key)}`,
7292
+ { method: 'GET' },
7293
+ );
7294
+ }
7295
+
7296
+ /** A monitor's recent findings. Prefer `client.monitors.ledgerFindings(...)`. */
7297
+ async listMonitorLedgerFindings(
7298
+ key: string,
7299
+ options?: { cursor?: string },
7300
+ ): Promise<Record<string, unknown>> {
7301
+ const suffix = options?.cursor
7302
+ ? `?cursor=${encodeURIComponent(options.cursor)}`
7303
+ : '';
7304
+ return this.http.request<Record<string, unknown>>(
7305
+ `/api/v2/monitors/ledger/${encodeURIComponent(key)}/findings${suffix}`,
7306
+ { method: 'GET' },
7307
+ );
7308
+ }
7309
+
7225
7310
  /** Fetch one deployed monitor by public key. Prefer `client.monitors.get(...)`. */
7226
7311
  async getMonitor(key: string): Promise<MonitorDetail> {
7227
7312
  return this.http.request<MonitorDetail>(
@@ -7707,7 +7792,12 @@ export class DeeplineClient {
7707
7792
  const terminal: ReadonlySet<string> =
7708
7793
  options?.until === 'deactivated'
7709
7794
  ? new Set(['deactivated', 'degraded', 'billing_suspended'])
7710
- : new Set(['converged', 'degraded', 'deactivated', 'billing_suspended']);
7795
+ : new Set([
7796
+ 'converged',
7797
+ 'degraded',
7798
+ 'deactivated',
7799
+ 'billing_suspended',
7800
+ ]);
7711
7801
  const startedAt = Date.now();
7712
7802
  let latest = await this.getMonitorFleet(fleetId);
7713
7803
  while (true) {
@@ -16,6 +16,7 @@
16
16
  * passed in as explicit request fields.
17
17
  */
18
18
  import { DeeplineError } from '../../../shared_libs/plays/tool-execution-error';
19
+ import { inputFieldsFromStaticCsvArgs } from '../../../shared_libs/plays/static-pipeline';
19
20
  import { isTerminalPlayRunLifecycleStatus } from '../../../shared_libs/play-runtime/run-lifecycle-policy.js';
20
21
  import {
21
22
  buildCallerPlayWorkflowId,
@@ -683,20 +684,6 @@ function stringMetadata(
683
684
  return typeof value === 'string' && value.trim() ? value.trim() : null;
684
685
  }
685
686
 
686
- function inputFieldFromCsvArg(csvArg: unknown): string | null {
687
- if (typeof csvArg !== 'string') return null;
688
- // The static pipeline preserves the authored expression, not just the
689
- // resolved source. A very common, valid form is
690
- // `ctx.csv(input.csv ?? 'default.csv')`: when the caller supplies --csv, the
691
- // input field still owns the staged file and must be rewritten to its logical
692
- // path before the runner starts.
693
- const match =
694
- /^\(?\s*input\.([A-Za-z_$][\w$]*)\s*\)?(?:\s*\?\?[\s\S]+)?$/.exec(
695
- csvArg.trim(),
696
- );
697
- return match?.[1] ?? null;
698
- }
699
-
700
687
  /** The `csvInput` binding a `CsvInput<Row>` field compiles to. */
701
688
  export function fileInputBindingsFromPlaySchema(
702
689
  inputSchema: Record<string, unknown> | null | undefined,
@@ -710,7 +697,7 @@ export function fileInputBindingsFromPlaySchema(
710
697
  ];
711
698
  }
712
699
 
713
- /** The input field a `ctx.csv(input.x)` call reads. */
700
+ /** Every input field read by an authored `ctx.csv(input.x)` call. */
714
701
  export function fileInputBindingsFromStaticPipeline(
715
702
  staticPipeline: unknown,
716
703
  ): FileInputBinding[] {
@@ -721,10 +708,9 @@ export function fileInputBindingsFromStaticPipeline(
721
708
  ) {
722
709
  return [];
723
710
  }
724
- const inputField = inputFieldFromCsvArg(
725
- (staticPipeline as Record<string, unknown>).csvArg,
726
- );
727
- return inputField ? [{ inputPath: inputField }] : [];
711
+ return inputFieldsFromStaticCsvArgs(
712
+ staticPipeline as Record<string, unknown>,
713
+ ).map((inputPath) => ({ inputPath }));
728
714
  }
729
715
 
730
716
  /** Every file-input binding of a Play definition, in staging order. */
@@ -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.495',
208
+ version: '0.3.496',
209
209
  updateSummary: {
210
210
  introducedIn: '0.3.90',
211
211
  summary:
@@ -69,6 +69,85 @@ function isDirectCreditSuspension(input: {
69
69
  );
70
70
  }
71
71
 
72
+ /**
73
+ * What a customer must fix for a billing-suspended monitor, from its public
74
+ * suspension reason. `payment_required` stays with credits: the dashboard has
75
+ * always told the customer to add credits for it, but it is never restored
76
+ * automatically (see `monitorRecoveryProjection`).
77
+ */
78
+ export type MonitorPauseKind = 'credits' | 'cap' | 'billing';
79
+
80
+ export function monitorPauseKind(reason: string | undefined): MonitorPauseKind {
81
+ if (isMonitorCapSuspensionReason(reason)) return 'cap';
82
+ if (
83
+ isCreditExhaustionSuspensionReason(reason) ||
84
+ reason === POLICY_CREDIT_SUSPENSION_REASON ||
85
+ reason === 'payment_required'
86
+ ) {
87
+ return 'credits';
88
+ }
89
+ return 'billing';
90
+ }
91
+
92
+ /**
93
+ * Whether a top-up or a cap change brings this suspended monitor back by
94
+ * itself, and if not, what is in the way. Customer copy promises an automatic
95
+ * resume only when `automatic` is true: it is the same selector credit and cap
96
+ * recovery run, so the promise and the behavior cannot drift apart.
97
+ */
98
+ export type MonitorRecoveryProjection = {
99
+ automatic: boolean;
100
+ /** Set when the pause kind would normally recover but this row cannot yet. */
101
+ blocked_by: 'cleanup_pending' | 'customer_stop' | 'review' | null;
102
+ };
103
+
104
+ export function monitorRecoveryProjection(input: {
105
+ fleetId?: string;
106
+ status: string;
107
+ desired?: 'active' | 'inactive';
108
+ deactivationReason?: string;
109
+ billingState: unknown;
110
+ providerBinding: unknown;
111
+ }): MonitorRecoveryProjection {
112
+ const billingState = parseStoredMonitorBillingState(input.billingState);
113
+ const reason = billingState.suspension_reason;
114
+ if (input.fleetId !== undefined) {
115
+ // Fleet members recover with their Fleet's lifecycle (KAR-43), which is
116
+ // selected from the Fleet's own suspension reason, not this row.
117
+ return {
118
+ automatic:
119
+ isCreditRestorableFleetSuspensionReason(reason) ||
120
+ isMonitorCapSuspensionReason(reason),
121
+ blocked_by: null,
122
+ };
123
+ }
124
+ if (
125
+ isCreditRestorableDirectMonitorSuspension(input) ||
126
+ isCapRestorableDirectMonitorSuspension(input)
127
+ ) {
128
+ return { automatic: true, blocked_by: null };
129
+ }
130
+ const kind = monitorPauseKind(reason);
131
+ const recoverableKind =
132
+ (kind === 'credits' && reason !== 'payment_required') || kind === 'cap';
133
+ if (!recoverableKind || billingState.state !== 'billing_suspended') {
134
+ return { automatic: false, blocked_by: null };
135
+ }
136
+ if (!hasConfirmedProviderMonitorUpstreamCleanup(input.providerBinding)) {
137
+ return { automatic: false, blocked_by: 'cleanup_pending' };
138
+ }
139
+ const policyProvenance =
140
+ input.deactivationReason === POLICY_CREDIT_SUSPENSION_REASON ||
141
+ input.deactivationReason === POLICY_CAP_SUSPENSION_REASON;
142
+ return {
143
+ automatic: false,
144
+ blocked_by:
145
+ input.desired === 'inactive' && !policyProvenance
146
+ ? 'customer_stop'
147
+ : 'review',
148
+ };
149
+ }
150
+
72
151
  /**
73
152
  * A billing suspension is not itself proof that TamRadar accepted the delete.
74
153
  * Keep this test beside the recovery selector so every automatic path rejects
@@ -472,6 +472,24 @@
472
472
  "failureAlert": "github_workflow_run",
473
473
  "domainReportRequired": true
474
474
  },
475
+ {
476
+ "id": "github.release-train",
477
+ "name": "Release train",
478
+ "scheduler": "github_actions",
479
+ "cadence": "*/5 * * * *",
480
+ "timezone": "UTC",
481
+ "source": ".github/workflows/release-train.yml",
482
+ "locator": "schedule:",
483
+ "owner": "platform",
484
+ "criticality": "operational",
485
+ "purpose": "Recheck whether the latest main commit can start a release train after a cadence or capacity deferral.",
486
+ "successDefinition": "The starter is disabled, or it records a dispatch or deferral decision and GitHub accepts any selected train dispatch.",
487
+ "failureDefinition": "Git ref or train history lookup fails, the configured cadence is invalid, or GitHub rejects the selected dispatch.",
488
+ "startGraceMs": 600000,
489
+ "runTimeoutMs": 300000,
490
+ "failureAlert": "github_workflow_run",
491
+ "domainReportRequired": true
492
+ },
475
493
  {
476
494
  "id": "github.runtime-lifecycle",
477
495
  "name": "On-Demand Runtime Lifecycle Load Check",
@@ -26,10 +26,24 @@ export type ScheduledWorkOrganizationTarget = {
26
26
  readonly orgId: string;
27
27
  };
28
28
 
29
+ export type HistoricalSettlementManifest = {
30
+ readonly deployment: string;
31
+ readonly cutoffMs: number;
32
+ readonly liabilityShard: number;
33
+ readonly rows: readonly {
34
+ readonly workId: string;
35
+ readonly reservationId: string;
36
+ readonly version: number;
37
+ readonly expectedDebitMicros: number;
38
+ }[];
39
+ };
40
+
41
+ export type ScheduledWorkPreviewMode = 'transactional' | 'read_only';
42
+
29
43
  export type ScheduledWorkPreviewResult = {
30
44
  readonly ok: boolean;
31
45
  readonly dryRun: true;
32
- readonly previewMode: 'transactional';
46
+ readonly previewMode: ScheduledWorkPreviewMode;
33
47
  readonly state: 'unknown' | 'inProgress' | 'success' | 'failed' | 'canceled';
34
48
  readonly processed: number;
35
49
  readonly isDone: boolean;
@@ -46,6 +60,7 @@ export type ScheduledWorkControlContext = {
46
60
  * lists in `orgScopedJobIds` accept it.
47
61
  */
48
62
  readonly orgScope?: readonly string[];
63
+ readonly historicalSettlementManifest?: HistoricalSettlementManifest;
49
64
  readonly requestedByUserId: string;
50
65
  readonly requestedByEmail: string;
51
66
  readonly reason: string;
@@ -68,6 +83,7 @@ export type ScheduledWorkControlConnector = {
68
83
  /** Jobs whose run may be restricted to an organization allow-list. */
69
84
  readonly orgScopedJobIds?: readonly string[];
70
85
  readonly previewActions?: readonly ScheduledWorkControlAction[];
86
+ readonly previewMode?: ScheduledWorkPreviewMode;
71
87
  preview?: (
72
88
  context: ScheduledWorkControlContext,
73
89
  action: ScheduledWorkControlAction,
@@ -98,7 +114,7 @@ export type ScheduledWorkControlCapability =
98
114
  readonly connectorId: string;
99
115
  readonly scheduler: string;
100
116
  readonly targetKind?: 'organization';
101
- readonly previewMode?: 'transactional';
117
+ readonly previewMode?: ScheduledWorkPreviewMode;
102
118
  }
103
119
  | {
104
120
  readonly available: false;
@@ -219,7 +235,7 @@ export class ScheduledWorkControlRegistry {
219
235
  scheduler: connector.scheduler,
220
236
  ...(connector.targetKind ? { targetKind: connector.targetKind } : {}),
221
237
  ...(connector.previewActions?.includes(action)
222
- ? { previewMode: 'transactional' as const }
238
+ ? { previewMode: connector.previewMode ?? 'transactional' }
223
239
  : {}),
224
240
  };
225
241
  }
@@ -984,8 +984,14 @@ export class FlyMachinesClient {
984
984
  async acquireMachineLease(
985
985
  id: string,
986
986
  options: { ttl: number; description: string },
987
+ leaseNonce?: string,
987
988
  ): Promise<string> {
988
- const result = await this.request('POST', `/machines/${id}/lease`, options);
989
+ const result = await this.request(
990
+ 'POST',
991
+ `/machines/${id}/lease`,
992
+ options,
993
+ leaseNonce,
994
+ );
989
995
  const nonce =
990
996
  result &&
991
997
  typeof result === 'object' &&
@@ -155,6 +155,11 @@ export async function selectDrainedGatewaySourceMachines(input: {
155
155
  return [...alreadyStopped, ...observed];
156
156
  }
157
157
 
158
+ // Continuation ownership is process-local; Fly owns expiry after a controller
159
+ // crash. Every pass refreshes the provider lease and re-reads source state.
160
+ const gatewayDrainLeaseNonces = new Map<string, string>();
161
+ const GATEWAY_DRAIN_LEASE_TTL_SECONDS = 120;
162
+
158
163
  /** One bounded reconciliation pass. Nonzero work is normal and is retained
159
164
  * for the next controller tick; metric/identity errors are intentionally loud
160
165
  * so no release can quietly fall back to a timeout-based delete. */
@@ -166,89 +171,128 @@ export async function reconcileGatewaySourceDrain(input: {
166
171
  inventory?: readonly FlyMachine[];
167
172
  retryDelaysMs?: readonly number[];
168
173
  sleep?: (delayMs: number) => Promise<void>;
174
+ leaseNonces?: Map<string, string>;
169
175
  }): Promise<{ deletedMachineIds: string[]; pendingMachineIds: string[] }> {
170
176
  const inventory = [
171
177
  ...(input.inventory ?? (await input.client.listMachines())),
172
178
  ];
173
179
  const sourceIds = [...new Set(input.sourceMachineIds)];
174
180
  const fetchImpl = input.fetchImpl ?? fetch;
175
- const deletedMachineIds = await selectDrainedGatewaySourceMachines({
176
- sourceMachineIds: sourceIds,
177
- inventory,
178
- readMetrics: async (machineId) => {
179
- return await readPrivateGatewayMetrics({
180
- app: input.app,
181
- machineId,
182
- fetchImpl,
183
- retryDelaysMs: input.retryDelaysMs,
184
- sleep: input.sleep,
181
+ const deletedMachineIds: string[] = [];
182
+ const leases = input.leaseNonces ?? gatewayDrainLeaseNonces;
183
+ const keyPrefix = `${input.app}/`;
184
+ for (const key of leases.keys()) {
185
+ if (
186
+ key.startsWith(keyPrefix) &&
187
+ !inventory.some((machine) => `${keyPrefix}${machine.id}` === key)
188
+ ) {
189
+ leases.delete(key);
190
+ }
191
+ }
192
+ for (const machineId of sourceIds) {
193
+ if (!inventory.some((machine) => machine.id === machineId)) continue;
194
+ // Fly Proxy can restart a stopped source before deletion. Hold provider
195
+ // ownership across the fresh drain proof, stop, and deletion so autostart
196
+ // cannot race that sequence. Never carry a pre-lease emptiness proof.
197
+ const leaseKey = `${keyPrefix}${machineId}`;
198
+ let nonce = leases.get(leaseKey);
199
+ const refreshLease = async () => {
200
+ const prior = nonce;
201
+ try {
202
+ nonce = await input.client.acquireMachineLease(
203
+ machineId,
204
+ {
205
+ ttl: GATEWAY_DRAIN_LEASE_TTL_SECONDS,
206
+ description: 'Gateway source retirement',
207
+ },
208
+ prior,
209
+ );
210
+ } catch (error) {
211
+ leases.delete(leaseKey);
212
+ throw error;
213
+ }
214
+ leases.set(leaseKey, nonce);
215
+ if (prior && nonce !== prior) {
216
+ // Ownership lapsed. A restarted source needs a fresh state/work proof;
217
+ // this pass must not continue from observations made under the old lease.
218
+ leases.delete(leaseKey);
219
+ await input.client.releaseMachineLease(machineId, nonce);
220
+ throw new Error(
221
+ 'Gateway drain lease changed; fresh source proof is required.',
222
+ );
223
+ }
224
+ };
225
+ await refreshLease();
226
+ let retainLease = false;
227
+ let providerConfirmedGone = false;
228
+ try {
229
+ const current = await input.client.getMachine(machineId);
230
+ if (current.cordoned !== true) {
231
+ throw new Error(
232
+ 'Gateway drain source Machine became public before deletion.',
233
+ );
234
+ }
235
+ if (['stopping', 'destroying'].includes(current.state ?? '')) {
236
+ retainLease = true;
237
+ continue;
238
+ }
239
+ const drained = await selectDrainedGatewaySourceMachines({
240
+ sourceMachineIds: [machineId],
241
+ inventory: [current],
242
+ readMetrics: () =>
243
+ readPrivateGatewayMetrics({
244
+ app: input.app,
245
+ machineId,
246
+ fetchImpl,
247
+ retryDelaysMs: input.retryDelaysMs,
248
+ sleep: input.sleep,
249
+ }),
185
250
  });
186
- },
187
- });
188
- if (deletedMachineIds.length > 0) {
189
- // Fly's client is asynchronous, so keep the provider inventory fresh
190
- // between stop and delete rather than pretending the pre-stop snapshot is
191
- // authoritative. Deletion is still exact-ID and provider-confirmed.
192
- await Promise.all(
193
- deletedMachineIds
194
- .filter((machineId) => {
195
- const machine = inventory.find((entry) => entry.id === machineId);
196
- return !['stopped', 'suspended'].includes(machine?.state ?? '');
197
- })
198
- .map((machineId) =>
199
- input.client.stopMachine(machineId, {
251
+ if (drained.length === 0) continue;
252
+ if (!['stopped', 'suspended'].includes(current.state ?? '')) {
253
+ // Refresh immediately before each effect. A provider request is bounded
254
+ // at 30 seconds, below this lease's 120 seconds; slow reads/retries cannot
255
+ // consume the fence needed by the following mutation.
256
+ await refreshLease();
257
+ retainLease = true;
258
+ await input.client.stopMachine(
259
+ machineId,
260
+ {
200
261
  signal: 'SIGTERM',
201
262
  timeout: '300s',
202
- }),
203
- ),
204
- );
205
- const deadline = Date.now() + 10 * 60_000;
206
- for (;;) {
207
- const current = await input.client.listMachines();
208
- const remaining = current.filter((machine) =>
209
- deletedMachineIds.includes(machine.id ?? ''),
263
+ },
264
+ nonce,
265
+ );
266
+ }
267
+ const stopped = (await input.client.listMachines()).find(
268
+ (machine) => machine.id === machineId,
210
269
  );
211
- if (
212
- remaining.every((machine) =>
213
- ['stopped', 'suspended'].includes(machine.state ?? ''),
214
- )
215
- ) {
216
- if (remaining.some((machine) => machine.cordoned !== true)) {
270
+ if (stopped) {
271
+ if (stopped.cordoned !== true) {
217
272
  throw new Error(
218
273
  'Gateway drain source Machine became public before deletion.',
219
274
  );
220
275
  }
221
- await Promise.all(
222
- remaining.map((machine) =>
223
- input.client.deleteMachine(machine.id!, false),
224
- ),
225
- );
226
- break;
276
+ // Stops and deletes are asynchronous. Resume from fresh provider truth
277
+ // next tick rather than blocking live capacity planning for ten minutes.
278
+ if (!['stopped', 'suspended'].includes(stopped.state ?? '')) continue;
279
+ await refreshLease();
280
+ retainLease = true;
281
+ await input.client.deleteMachine(machineId, false, nonce);
227
282
  }
228
- if (Date.now() >= deadline) {
229
- throw new Error(
230
- `Gateway drain sources did not stop within 600000 ms: ${remaining.map((machine) => `${machine.id}=${machine.state}`).join(', ')}.`,
231
- );
232
- }
233
- await new Promise((resolve) => setTimeout(resolve, 5_000));
234
- }
235
- for (;;) {
236
- const providerMachineIds = new Set(
237
- (await input.client.listMachines())
238
- .map((machine) => machine.id)
239
- .filter((id): id is string => Boolean(id)),
283
+ providerConfirmedGone = !(await input.client.listMachines()).some(
284
+ (machine) => machine.id === machineId,
240
285
  );
241
- if (
242
- deletedMachineIds.every(
243
- (machineId) => !providerMachineIds.has(machineId),
244
- )
245
- ) {
246
- break;
247
- }
248
- if (Date.now() >= deadline) {
249
- throw new Error('Gateway source deletion is not provider-confirmed.');
286
+ if (providerConfirmedGone) deletedMachineIds.push(machineId);
287
+ } finally {
288
+ if (providerConfirmedGone) {
289
+ leases.delete(leaseKey);
290
+ } else if (!retainLease && leases.get(leaseKey) === nonce) {
291
+ leases.delete(leaseKey);
292
+ await input.client.releaseMachineLease(machineId, nonce!);
250
293
  }
251
- await new Promise((resolve) => setTimeout(resolve, 5_000));
294
+ // Keep the lease through asynchronous stopping/deletion and ambiguous
295
+ // mutation outcomes. The next tick refreshes it; a crash lets Fly expire it.
252
296
  }
253
297
  }
254
298
  return {
@@ -53,6 +53,19 @@ export interface VercelDeploymentEventSummary {
53
53
  workerBuildId: string | null;
54
54
  }
55
55
 
56
+ export type VercelPromotionTiming = {
57
+ requestedAt: number;
58
+ previousReleaseAt?: number;
59
+ train?: { runId: string; attempt: string; durationMs: number };
60
+ };
61
+
62
+ export function vercelPromotionTimingKey(deploymentId: string): string {
63
+ if (!/^dpl_[a-zA-Z0-9]+$/.test(deploymentId)) {
64
+ throw new Error('Invalid Vercel deployment ID.');
65
+ }
66
+ return `production-releases/vercel-promotions/${deploymentId}.json`;
67
+ }
68
+
56
69
  function readRecord(value: unknown): Record<string, unknown> | null {
57
70
  if (!value || typeof value !== 'object' || Array.isArray(value)) return null;
58
71
  return value as Record<string, unknown>;
@@ -261,6 +274,7 @@ export function buildVercelRollbackSlackText(
261
274
 
262
275
  export function buildVercelDeploymentSlackText(
263
276
  summary: VercelDeploymentEventSummary,
277
+ promotion?: { promotedAt: number; timing: VercelPromotionTiming },
264
278
  ): string {
265
279
  const title =
266
280
  summary.eventType === 'deployment.succeeded'
@@ -276,5 +290,48 @@ export function buildVercelDeploymentSlackText(
276
290
  ? `Aligned worker build: ${summary.workerBuildId}`
277
291
  : null,
278
292
  ];
293
+ if (summary.eventType === 'deployment.promoted' && promotion) {
294
+ const { promotedAt, timing } = promotion;
295
+ const sinceRequest = promotedAt - timing.requestedAt;
296
+ // A later manual promotion must not pick up an abandoned CI intent.
297
+ if (
298
+ Number.isFinite(sinceRequest) &&
299
+ sinceRequest >= 0 &&
300
+ sinceRequest <= 600_000
301
+ ) {
302
+ const sinceRelease = promotedAt - (timing.previousReleaseAt ?? NaN);
303
+ if (Number.isFinite(sinceRelease) && sinceRelease >= 0) {
304
+ lines.push(
305
+ `Since last successful Production release: ${formatDuration(sinceRelease)}`,
306
+ );
307
+ }
308
+ const train = timing.train;
309
+ if (
310
+ train &&
311
+ /^[1-9]\d*$/.test(train.runId) &&
312
+ /^[1-9]\d*$/.test(train.attempt) &&
313
+ Number.isFinite(train.durationMs) &&
314
+ train.durationMs >= 0
315
+ ) {
316
+ const url = `https://github.com/getaero-io/deepline-api/actions/runs/${train.runId}/attempts/${train.attempt}`;
317
+ lines.push(
318
+ `CI train: ${formatDuration(train.durationMs)} · <${url}|View run>`,
319
+ );
320
+ }
321
+ }
322
+ }
279
323
  return lines.filter(Boolean).join('\n');
280
324
  }
325
+
326
+ function formatDuration(durationMs: number): string {
327
+ const seconds = Math.floor(durationMs / 1000);
328
+ const hours = Math.floor(seconds / 3600);
329
+ const minutes = Math.floor((seconds % 3600) / 60);
330
+ return [
331
+ hours ? `${hours}h` : '',
332
+ minutes || hours ? `${minutes}m` : '',
333
+ `${seconds % 60}s`,
334
+ ]
335
+ .filter(Boolean)
336
+ .join(' ');
337
+ }