deepline 0.3.115 → 0.3.117

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 (28) hide show
  1. package/dist/bundling-sources/sdk/src/client.ts +356 -12
  2. package/dist/bundling-sources/sdk/src/index.ts +12 -1
  3. package/dist/bundling-sources/sdk/src/release.ts +1 -1
  4. package/dist/bundling-sources/shared_libs/monitors/billing/state.ts +36 -6
  5. package/dist/bundling-sources/shared_libs/monitors/billing/types.ts +0 -1
  6. package/dist/bundling-sources/shared_libs/monitors/deactivation-reasons.ts +6 -3
  7. package/dist/bundling-sources/shared_libs/monitors/fleets/verdict.ts +52 -15
  8. package/dist/bundling-sources/shared_libs/monitors/monitor-job-state.ts +44 -0
  9. package/dist/bundling-sources/shared_libs/monitors/package.json +2 -0
  10. package/dist/bundling-sources/shared_libs/monitors/provider-monitor-batch-operation.ts +76 -3
  11. package/dist/bundling-sources/shared_libs/monitors/provider-monitor-state.ts +81 -6
  12. package/dist/bundling-sources/shared_libs/monitors/provider-monitor-status.ts +26 -10
  13. package/dist/bundling-sources/shared_libs/observability/queue-health.ts +128 -0
  14. package/dist/bundling-sources/shared_libs/observability/scheduled-jobs.json +18 -0
  15. package/dist/bundling-sources/shared_libs/observability/scheduled-work-manual.ts +1 -0
  16. package/dist/bundling-sources/shared_libs/plays/share/static-pipeline-summary.ts +2 -2
  17. package/dist/cli/index.js +413 -68
  18. package/dist/cli/index.mjs +413 -68
  19. package/dist/index.d.mts +155 -13
  20. package/dist/index.d.ts +155 -13
  21. package/dist/index.js +137 -2
  22. package/dist/index.mjs +134 -2
  23. package/dist/install-integrity.json +1 -0
  24. package/dist/release.d.mts +1 -1
  25. package/dist/release.d.ts +1 -1
  26. package/dist/release.js +1 -1
  27. package/dist/release.mjs +1 -1
  28. package/package.json +1 -1
@@ -867,10 +867,29 @@ export type MonitorsAvailableOptions = {
867
867
  compact?: boolean;
868
868
  };
869
869
 
870
+ /**
871
+ * Stable customer-facing Monitor/Fleet state.
872
+ *
873
+ * Provider provisioning, cleanup, retries, and failures are Monitor Job
874
+ * progress and must never be added to this union. The `status` and `active`
875
+ * fields below are retained only as deprecated compatibility aliases for
876
+ * older API responses.
877
+ */
878
+ export type MonitorState = 'active' | 'billing_suspended' | 'disabled';
879
+
880
+ /** List filters accepted by the canonical state surface. */
881
+ export type MonitorStateFilter = MonitorState | 'all';
882
+
883
+ /** The pre-state list filter retained for installed-client compatibility. */
884
+ export type LegacyMonitorStatusFilter = 'active' | 'inactive' | 'all';
885
+
870
886
  /** One deployed monitor row returned by `client.monitors.list(...)`. */
871
887
  export type MonitorListEntry = {
872
888
  key?: string;
873
889
  monitor_key?: string;
890
+ /** Canonical customer-facing lifecycle state. */
891
+ state?: MonitorState;
892
+ /** @deprecated Use state. `inactive` is projected as `disabled`. */
874
893
  status?: string;
875
894
  tool?: string;
876
895
  /** Generic provider-authored event category for this deployed monitor. */
@@ -900,7 +919,15 @@ export type MonitorsListResult = {
900
919
  /** @deprecated Use has_more. */
901
920
  is_truncated?: boolean;
902
921
  next_cursor?: string | null;
922
+ /** Canonical state filter echoed by newer servers. */
923
+ state_filter_applied?: MonitorStateFilter;
924
+ /** Canonical state counts. */
925
+ state_summary?: Array<{ state: MonitorState; count: number }>;
926
+ /** Whether state_summary counts this page or the full applied state filter. */
927
+ state_summary_scope?: 'page' | 'filter_total';
928
+ /** @deprecated Use state_filter_applied. */
903
929
  status_filter_applied?: string;
930
+ /** @deprecated Use state_summary. */
904
931
  status_summary?: Array<{ status: string; count: number }>;
905
932
  include_consumers?: boolean;
906
933
  [key: string]: unknown;
@@ -908,8 +935,10 @@ export type MonitorsListResult = {
908
935
 
909
936
  /** Options for `client.monitors.list(...)`. */
910
937
  export type MonitorsListOptions = {
911
- /** active (default), disabled, or all. */
912
- status?: string;
938
+ /** Canonical customer state filter; active is the default. */
939
+ state?: MonitorStateFilter;
940
+ /** @deprecated Use state. `inactive` remains accepted for old servers. */
941
+ status?: LegacyMonitorStatusFilter | (string & {});
913
942
  limit?: number | string;
914
943
  /** Page past a truncated result using a prior response's `next_cursor`. */
915
944
  cursor?: string;
@@ -941,6 +970,12 @@ export type MonitorSpec = {
941
970
 
942
971
  /** One deployed-monitor read. The server may add monitor-specific fields. */
943
972
  export type MonitorDetail = Record<string, unknown> & {
973
+ /** Canonical customer-facing lifecycle state. */
974
+ state?: MonitorState;
975
+ /** @deprecated Use state. */
976
+ status?: string;
977
+ /** @deprecated Use state. */
978
+ active?: boolean;
944
979
  monitor_spec?: MonitorSpec;
945
980
  };
946
981
  export type MonitorDependents = Record<string, unknown>;
@@ -991,21 +1026,122 @@ export type MonitorValidateResult = Record<string, unknown>;
991
1026
  /**
992
1027
  * Server-owned fleet response envelope.
993
1028
  *
994
- * The server computes `status` (`converging` | `converged` | `degraded` |
995
- * `deactivating` | `deactivated`) and the SDK never recomputes it: a client
996
- * that derives its own verdict from counts drifts from the control plane the
997
- * moment the server changes what "converged" means.
1029
+ * The server computes the canonical customer `state` and the SDK never
1030
+ * recomputes it. Transitional convergence details remain in the owning Fleet
1031
+ * Job; the deprecated `status` alias is retained only for installed clients.
998
1032
  */
999
- export type MonitorFleetResult = Record<string, unknown>;
1033
+ export type MonitorFleetResult = Record<string, unknown> & {
1034
+ /** Canonical customer-facing Fleet state. */
1035
+ state?: MonitorState;
1036
+ /** @deprecated Fleet operation/convergence status; use state + jobs. */
1037
+ status?: string;
1038
+ };
1039
+
1040
+ /** Standalone SDK mirror of the server-owned Monitor Job contract. */
1041
+ export const MONITOR_JOB_STATES = [
1042
+ 'queued',
1043
+ 'running',
1044
+ 'cancelling',
1045
+ 'succeeded',
1046
+ 'failed',
1047
+ 'cancelled',
1048
+ ] as const;
1049
+ export type MonitorJobState = (typeof MONITOR_JOB_STATES)[number];
1050
+
1051
+ export const MONITOR_JOB_PHASES = [
1052
+ 'queued',
1053
+ 'provider_create',
1054
+ 'provider_readback',
1055
+ 'reconciliation',
1056
+ 'completed',
1057
+ ] as const;
1058
+ export type MonitorJobPhase = (typeof MONITOR_JOB_PHASES)[number];
1059
+
1060
+ export const MONITOR_JOB_RECONCILIATION_STATES = [
1061
+ 'pending',
1062
+ 'aligned',
1063
+ 'partial',
1064
+ 'mismatched',
1065
+ ] as const;
1066
+ export type MonitorJobReconciliationState =
1067
+ (typeof MONITOR_JOB_RECONCILIATION_STATES)[number];
1068
+
1069
+ export type MonitorJobProjection = {
1070
+ id: string;
1071
+ kind: 'batch_deploy' | 'fleet_deploy';
1072
+ state: MonitorJobState;
1073
+ phase: MonitorJobPhase;
1074
+ target: {
1075
+ monitor_key?: string;
1076
+ batch_id?: string;
1077
+ generation?: number;
1078
+ fleet_id?: string;
1079
+ };
1080
+ counts: {
1081
+ requested: number;
1082
+ valid: number;
1083
+ queued: number;
1084
+ running: number;
1085
+ created: number;
1086
+ updated: number;
1087
+ removed: number;
1088
+ unchanged: number;
1089
+ settled: number;
1090
+ verified: number;
1091
+ failed: number;
1092
+ cancelled_before_start: number;
1093
+ };
1094
+ reconciliation: {
1095
+ state: MonitorJobReconciliationState;
1096
+ expected_bindings: number;
1097
+ observed_bindings: number;
1098
+ active_mismatches: number;
1099
+ provider_only_matching_markers: number;
1100
+ next?: string;
1101
+ };
1102
+ error?: string;
1103
+ };
1000
1104
 
1001
- /** Shared response envelope for immutable batch and desired-set Monitor Jobs. */
1002
- export type MonitorJobResult = Record<string, unknown>;
1105
+ export type MonitorNamedBatchProjection = {
1106
+ id: string;
1107
+ state: 'active' | 'stopped';
1108
+ generation: number;
1109
+ desired_count: number;
1110
+ retained_count: number;
1111
+ last_job_id: string;
1112
+ updated_at: string;
1113
+ };
1114
+
1115
+ /** Shared typed envelope for immutable batch and desired-set Monitor Jobs. */
1116
+ export type MonitorJobResult = {
1117
+ ok?: boolean;
1118
+ job?: MonitorJobProjection;
1119
+ batch?: MonitorNamedBatchProjection;
1120
+ logs?: Array<{
1121
+ level: string;
1122
+ phase: string;
1123
+ message: string;
1124
+ monitor_key?: string;
1125
+ at: string;
1126
+ }>;
1127
+ replayed?: boolean;
1128
+ already_terminal?: boolean;
1129
+ next?: string;
1130
+ [key: string]: unknown;
1131
+ };
1003
1132
 
1004
1133
  export type MonitorJobDeployOptions = {
1005
1134
  /** Stable retry key; the server binds it to the submitted immutable set. */
1006
1135
  idempotencyKey?: string;
1007
1136
  };
1008
1137
 
1138
+ export type MonitorLifecycleOptions = {
1139
+ /** Return the plan without changing provider state. */
1140
+ dryRun?: boolean;
1141
+ /** Stable retry key for durable start/stop work. */
1142
+ idempotencyKey?: string;
1143
+ };
1144
+
1009
1145
  export type MonitorJobLogsOptions = { limit?: number };
1010
1146
 
1011
1147
  export type MonitorJobWaitOptions = {
@@ -1126,7 +1262,8 @@ export type MonitorBatchOperationResult = {
1126
1262
  | 'deactivate'
1127
1263
  | 'reactivate'
1128
1264
  | 'deploy'
1129
- | 'repair';
1265
+ | 'repair'
1266
+ | 'named_batch';
1130
1267
  state: 'running' | 'retry_scheduled' | 'completed' | 'failed' | 'cancelled';
1131
1268
  dryRun: boolean;
1132
1269
  scope: unknown;
@@ -1179,6 +1316,16 @@ export type MonitorFleetsNamespace = {
1179
1316
  fleetId: string,
1180
1317
  options?: MonitorFleetReactivateOptions,
1181
1318
  ) => Promise<MonitorFleetResult>;
1319
+ /** Customer-facing alias for `reactivate`. */
1320
+ start: (
1321
+ fleetId: string,
1322
+ options?: MonitorFleetReactivateOptions,
1323
+ ) => Promise<MonitorFleetResult>;
1324
+ /** Customer-facing alias for `deactivate`. */
1325
+ stop: (
1326
+ fleetId: string,
1327
+ options?: MonitorFleetDeactivateOptions,
1328
+ ) => Promise<MonitorFleetResult>;
1182
1329
  /** Poll the fleet until the server reports a terminal status (or the timeout elapses). */
1183
1330
  waitForConvergence: (
1184
1331
  fleetId: string,
@@ -1201,6 +1348,28 @@ export type MonitorBatchNamespace = {
1201
1348
  ) => Promise<MonitorBatchOperationResult>;
1202
1349
  };
1203
1350
 
1351
+ export type MonitorNamedBatchOptions = {
1352
+ idempotencyKey?: string;
1353
+ expectedGeneration?: number;
1354
+ };
1355
+
1356
+ export type MonitorNamedBatchesNamespace = {
1357
+ sync: (
1358
+ batchId: string,
1359
+ definitions: MonitorDefinition[],
1360
+ options?: MonitorNamedBatchOptions,
1361
+ ) => Promise<MonitorJobResult>;
1362
+ start: (
1363
+ batchId: string,
1364
+ options?: Pick<MonitorNamedBatchOptions, 'idempotencyKey'>,
1365
+ ) => Promise<MonitorJobResult>;
1366
+ stop: (
1367
+ batchId: string,
1368
+ options?: Pick<MonitorNamedBatchOptions, 'idempotencyKey'>,
1369
+ ) => Promise<MonitorJobResult>;
1370
+ get: (batchId: string) => Promise<MonitorJobResult>;
1371
+ };
1372
+
1204
1373
  /**
1205
1374
  * Delivery and convergence health for a scope, from
1206
1375
  * `GET /api/v2/monitors/health`.
@@ -1263,6 +1432,7 @@ export type MonitorsHealth = {
1263
1432
  | 'audit'
1264
1433
  | 'converge'
1265
1434
  | 'deactivate'
1435
+ | 'named_batch'
1266
1436
  | 'reactivate'
1267
1437
  | 'repair'
1268
1438
  | 'deploy';
@@ -1371,7 +1541,14 @@ export type MonitorsNamespace = {
1371
1541
  definition: MonitorDefinition,
1372
1542
  options?: { dryRun?: boolean },
1373
1543
  ) => Promise<MonitorDeployResult>;
1374
- /** List deployed monitors (active by default). `includeConsumers` requires a limit of 20 or fewer. */
1544
+ /** Set the desired definition for one stable monitor key. */
1545
+ sync: (
1546
+ definition: MonitorDefinition,
1547
+ options?: MonitorLifecycleOptions,
1548
+ ) => Promise<MonitorJobResult | MonitorDeployResult>;
1549
+ /** List deployed monitors (active by default). Use `state` to filter the
1550
+ * three customer states; `status` is retained for older servers.
1551
+ * `includeConsumers` requires a limit of 20 or fewer. */
1375
1552
  list: (options?: MonitorsListOptions) => Promise<MonitorsListResult>;
1376
1553
  /** Fetch one deployed monitor by public key with bounded current listener health. */
1377
1554
  get: (key: string) => Promise<MonitorDetail>;
@@ -1399,6 +1576,16 @@ export type MonitorsNamespace = {
1399
1576
  key: string,
1400
1577
  options?: { dryRun?: boolean },
1401
1578
  ) => Promise<MonitorReactivateResult>;
1579
+ /** Explicitly apply the retained definition for a stopped monitor. */
1580
+ start: (
1581
+ key: string,
1582
+ options?: MonitorLifecycleOptions,
1583
+ ) => Promise<MonitorJobResult | MonitorBatchOperationResult>;
1584
+ /** Converge one monitor to inactive while retaining its definition. */
1585
+ stop: (
1586
+ key: string,
1587
+ options?: MonitorLifecycleOptions,
1588
+ ) => Promise<MonitorJobResult | MonitorBatchOperationResult>;
1402
1589
  /**
1403
1590
  * Re-read what the provider holds onto the monitors that claim it. Bounded
1404
1591
  * and idempotent: pass `cursor` back while `audit.cursor` is non-null.
@@ -1421,6 +1608,8 @@ export type MonitorsNamespace = {
1421
1608
  fleets: MonitorFleetsNamespace;
1422
1609
  /** Deploy an immutable one-off list through the common Monitor Job engine. */
1423
1610
  batch: MonitorBatchNamespace;
1611
+ /** Reconcile and control a stable named static Batch. */
1612
+ batches: MonitorNamedBatchesNamespace;
1424
1613
  /** Read, wait for, inspect, or cancel Monitor Jobs. */
1425
1614
  jobs: MonitorJobsNamespace;
1426
1615
  };
@@ -2373,6 +2562,10 @@ export class DeeplineClient {
2373
2562
  this.getMonitorsAvailable(toolIdOrOptions, options),
2374
2563
  check: (definition) => this.checkMonitor(definition),
2375
2564
  deploy: (definition, options) => this.deployMonitor(definition, options),
2565
+ sync: (definition, options) =>
2566
+ options?.dryRun
2567
+ ? this.deployMonitor(definition, { dryRun: true })
2568
+ : this.syncScalarMonitor(definition, options),
2376
2569
  list: (options) => this.listMonitors(options),
2377
2570
  get: (key) => this.getMonitor(key),
2378
2571
  test: (key, payload, options) =>
@@ -2382,6 +2575,28 @@ export class DeeplineClient {
2382
2575
  update: (key, patch) => this.updateMonitor(key, patch),
2383
2576
  delete: (key, options) => this.deleteMonitor(key, options),
2384
2577
  reactivate: (key, options) => this.reactivateMonitor(key, options),
2578
+ start: (key, options) =>
2579
+ options?.dryRun
2580
+ ? this.submitMonitorBatch({
2581
+ kind: 'reactivate',
2582
+ scope: { kind: 'keys', monitorKeys: [key] },
2583
+ dryRun: true,
2584
+ idempotencyKey:
2585
+ options.idempotencyKey ??
2586
+ this.monitorJobIdempotencyKey(`start-${key}`),
2587
+ })
2588
+ : this.submitScalarMonitorLifecycle(key, 'start', options),
2589
+ stop: (key, options) =>
2590
+ options?.dryRun
2591
+ ? this.submitMonitorBatch({
2592
+ kind: 'deactivate',
2593
+ scope: { kind: 'keys', monitorKeys: [key] },
2594
+ dryRun: true,
2595
+ idempotencyKey:
2596
+ options.idempotencyKey ??
2597
+ this.monitorJobIdempotencyKey(`stop-${key}`),
2598
+ })
2599
+ : this.submitScalarMonitorLifecycle(key, 'stop', options),
2385
2600
  audit: (options) => this.auditMonitors(options),
2386
2601
  repair: (options) => this.repairMonitors(options),
2387
2602
  health: (options) => this.readMonitorsHealth(options),
@@ -2392,6 +2607,15 @@ export class DeeplineClient {
2392
2607
  get: (operationId, options) =>
2393
2608
  this.getMonitorBatch(operationId, options),
2394
2609
  },
2610
+ batches: {
2611
+ sync: (batchId, definitions, options) =>
2612
+ this.syncNamedMonitorBatch(batchId, definitions, options),
2613
+ start: (batchId, options) =>
2614
+ this.startNamedMonitorBatch(batchId, options),
2615
+ stop: (batchId, options) =>
2616
+ this.stopNamedMonitorBatch(batchId, options),
2617
+ get: (batchId) => this.getNamedMonitorBatch(batchId),
2618
+ },
2395
2619
  jobs: {
2396
2620
  get: (jobId) => this.getMonitorJob(jobId),
2397
2621
  logs: (jobId, options) => this.getMonitorJobLogs(jobId, options),
@@ -2412,6 +2636,10 @@ export class DeeplineClient {
2412
2636
  this.deactivateMonitorFleet(fleetId, options),
2413
2637
  reactivate: (fleetId, options) =>
2414
2638
  this.reactivateMonitorFleet(fleetId, options),
2639
+ start: (fleetId, options) =>
2640
+ this.reactivateMonitorFleet(fleetId, options),
2641
+ stop: (fleetId, options) =>
2642
+ this.deactivateMonitorFleet(fleetId, options),
2415
2643
  waitForConvergence: (fleetId, options) =>
2416
2644
  this.waitForMonitorFleetConvergence(fleetId, options),
2417
2645
  },
@@ -5978,7 +6206,11 @@ export class DeeplineClient {
5978
6206
  options?: MonitorsListOptions,
5979
6207
  ): Promise<MonitorsListResult> {
5980
6208
  const params = new URLSearchParams();
5981
- if (options?.status) params.set('status', options.status);
6209
+ // `state` is the canonical filter. Keep sending the historical `status`
6210
+ // parameter when callers use it so installed clients continue to work
6211
+ // against older servers; never send both filters for one request.
6212
+ if (options?.state) params.set('state', options.state);
6213
+ else if (options?.status) params.set('status', options.status);
5982
6214
  if (options?.limit !== undefined)
5983
6215
  params.set('limit', String(options.limit));
5984
6216
  if (options?.cursor) params.set('cursor', options.cursor);
@@ -6165,6 +6397,118 @@ export class DeeplineClient {
6165
6397
  );
6166
6398
  }
6167
6399
 
6400
+ private namedMonitorBatchPath(batchId: string): string {
6401
+ return `/api/v2/monitors/batches/${encodeURIComponent(batchId)}`;
6402
+ }
6403
+
6404
+ async syncNamedMonitorBatch(
6405
+ batchId: string,
6406
+ definitions: MonitorDefinition[],
6407
+ options?: MonitorNamedBatchOptions,
6408
+ ): Promise<MonitorJobResult> {
6409
+ return this.http.request<MonitorJobResult>(
6410
+ this.namedMonitorBatchPath(batchId),
6411
+ {
6412
+ method: 'PUT',
6413
+ body: {
6414
+ version: 1,
6415
+ kind: 'batch',
6416
+ monitors: definitions,
6417
+ ...(options?.expectedGeneration === undefined
6418
+ ? {}
6419
+ : { expected_generation: options.expectedGeneration }),
6420
+ },
6421
+ headers: this.monitorJobHeaders(
6422
+ `batch-sync-${batchId}`,
6423
+ options?.idempotencyKey,
6424
+ ),
6425
+ maxRetries: 0,
6426
+ exactUrlOnly: true,
6427
+ },
6428
+ );
6429
+ }
6430
+
6431
+ async startNamedMonitorBatch(
6432
+ batchId: string,
6433
+ options?: Pick<MonitorNamedBatchOptions, 'idempotencyKey'>,
6434
+ ): Promise<MonitorJobResult> {
6435
+ return this.http.request<MonitorJobResult>(
6436
+ `${this.namedMonitorBatchPath(batchId)}/start`,
6437
+ {
6438
+ method: 'POST',
6439
+ body: {},
6440
+ headers: this.monitorJobHeaders(
6441
+ `batch-start-${batchId}`,
6442
+ options?.idempotencyKey,
6443
+ ),
6444
+ maxRetries: 0,
6445
+ exactUrlOnly: true,
6446
+ },
6447
+ );
6448
+ }
6449
+
6450
+ async stopNamedMonitorBatch(
6451
+ batchId: string,
6452
+ options?: Pick<MonitorNamedBatchOptions, 'idempotencyKey'>,
6453
+ ): Promise<MonitorJobResult> {
6454
+ return this.http.request<MonitorJobResult>(
6455
+ this.namedMonitorBatchPath(batchId),
6456
+ {
6457
+ method: 'DELETE',
6458
+ body: {},
6459
+ headers: this.monitorJobHeaders(
6460
+ `batch-stop-${batchId}`,
6461
+ options?.idempotencyKey,
6462
+ ),
6463
+ maxRetries: 0,
6464
+ exactUrlOnly: true,
6465
+ },
6466
+ );
6467
+ }
6468
+
6469
+ async getNamedMonitorBatch(batchId: string): Promise<MonitorJobResult> {
6470
+ return this.http.request<MonitorJobResult>(
6471
+ this.namedMonitorBatchPath(batchId),
6472
+ { method: 'GET' },
6473
+ );
6474
+ }
6475
+
6476
+ async submitScalarMonitorLifecycle(
6477
+ monitorKey: string,
6478
+ action: 'start' | 'stop',
6479
+ options?: Pick<MonitorLifecycleOptions, 'idempotencyKey'>,
6480
+ ): Promise<MonitorJobResult> {
6481
+ return this.http.request<MonitorJobResult>(
6482
+ `/api/v2/monitors/deployed/${encodeURIComponent(monitorKey)}/${action}`,
6483
+ {
6484
+ method: 'POST',
6485
+ body: {},
6486
+ headers: this.monitorJobHeaders(
6487
+ `${action}-${monitorKey}`,
6488
+ options?.idempotencyKey,
6489
+ ),
6490
+ maxRetries: 0,
6491
+ exactUrlOnly: true,
6492
+ },
6493
+ );
6494
+ }
6495
+
6496
+ async syncScalarMonitor(
6497
+ definition: MonitorDefinition,
6498
+ options?: Pick<MonitorLifecycleOptions, 'idempotencyKey'>,
6499
+ ): Promise<MonitorJobResult> {
6500
+ return this.http.request<MonitorJobResult>('/api/v2/monitors/sync', {
6501
+ method: 'POST',
6502
+ body: definition,
6503
+ headers: this.monitorJobHeaders(
6504
+ `sync-${definition.key}`,
6505
+ options?.idempotencyKey,
6506
+ ),
6507
+ maxRetries: 0,
6508
+ exactUrlOnly: true,
6509
+ });
6510
+ }
6511
+
6168
6512
  async getMonitorJob(jobId: string): Promise<MonitorJobResult> {
6169
6513
  return this.http.request<MonitorJobResult>(
6170
6514
  `/api/v2/monitors/jobs/${encodeURIComponent(jobId)}`,
@@ -55,7 +55,12 @@
55
55
  */
56
56
 
57
57
  // ——— Client ———
58
- export { DeeplineClient } from './client.js';
58
+ export {
59
+ DeeplineClient,
60
+ MONITOR_JOB_PHASES,
61
+ MONITOR_JOB_RECONCILIATION_STATES,
62
+ MONITOR_JOB_STATES,
63
+ } from './client.js';
59
64
  export { CtxFetchHttpError } from './play.js';
60
65
  export { RunObserveTransportUnavailableError } from './runs/observe-transport.js';
61
66
  export type {
@@ -76,6 +81,9 @@ export type {
76
81
  MonitorsAvailableResult,
77
82
  MonitorsListOptions,
78
83
  MonitorsListResult,
84
+ MonitorState,
85
+ MonitorStateFilter,
86
+ LegacyMonitorStatusFilter,
79
87
  MonitorListEntry,
80
88
  MonitorCheckResult,
81
89
  MonitorDeployResult,
@@ -86,6 +94,9 @@ export type {
86
94
  MonitorUpdateResult,
87
95
  MonitorDeleteResult,
88
96
  MonitorReactivateResult,
97
+ MonitorJobPhase,
98
+ MonitorJobReconciliationState,
99
+ MonitorJobState,
89
100
  MonitorJobResult,
90
101
  MonitorJobDeployOptions,
91
102
  MonitorJobLogsOptions,
@@ -200,7 +200,7 @@ export const SDK_RELEASE = {
200
200
  // getters keep their established compatibility behavior.
201
201
  // 0.3.1 deprecated the legacy `deepline enrich` command in favor of Plays.
202
202
  // 0.3.90 is the first deliberately versioned SDK release for API v3.
203
- version: '0.3.115',
203
+ version: '0.3.117',
204
204
  updateSummary:
205
205
  'Play grep now returns concise results with the matched fields and terms. Automatic CLI updates are enabled by default; use `deepline settings autoupdate off` to opt out, `deepline settings autoupdate on` to re-enable updates, or `deepline settings autoupdate pin <version>` to hold an exact release.',
206
206
  packageCapabilities: {
@@ -4,6 +4,7 @@ import type {
4
4
  MonitorBillingPolicy,
5
5
  } from '@deepline/monitors/billing/types';
6
6
  import type { PublicMonitorCustomerChargeSummary } from '@deepline/monitors/billing/charges';
7
+ import type { ProviderMonitorCustomerState } from '@deepline/monitors/provider-monitor-state';
7
8
 
8
9
  export type StoredMonitorBillingState = {
9
10
  state: MonitorBillingState;
@@ -31,13 +32,14 @@ const SUBSCRIPTION_RENEWAL_GUARD_MS = 24 * 60 * 60 * 1000;
31
32
 
32
33
  export type PublicMonitorBillingSummary = Pick<
33
34
  StoredMonitorBillingState,
34
- | 'state'
35
35
  | 'lifecycle_charge_credits'
36
36
  | 'usage_charge_pending'
37
37
  | 'reactivation_required'
38
38
  | 'suspension_reason'
39
39
  | 'next_renewal_at'
40
40
  > & {
41
+ /** Customer projection; provider cleanup phases remain internal. */
42
+ state: ProviderMonitorCustomerState;
41
43
  create_charge?: PublicMonitorCustomerChargeSummary;
42
44
  reactivate_charge?: PublicMonitorCustomerChargeSummary;
43
45
  };
@@ -75,13 +77,17 @@ function readBillingState(value: unknown): MonitorBillingState {
75
77
  const state = readString(value);
76
78
  switch (state) {
77
79
  case 'active':
78
- case 'preflight_denied':
79
80
  case 'billing_pending':
80
81
  case 'billing_suspended':
81
82
  case 'upstream_disable_pending':
82
83
  case 'upstream_disable_failed':
83
84
  case 'disabled':
84
85
  return state;
86
+ // Historical readers accepted this value, but no production writer ever
87
+ // produced it. Normalize a persisted legacy payload instead of retaining a
88
+ // dead state in the current billing state machine.
89
+ case 'preflight_denied':
90
+ return 'disabled';
85
91
  default:
86
92
  return 'billing_pending';
87
93
  }
@@ -160,15 +166,41 @@ export function parseStoredMonitorBillingState(
160
166
  };
161
167
  }
162
168
 
169
+ /**
170
+ * Whether persisted billing truth forbids an automatic lifecycle revival.
171
+ *
172
+ * These states all represent an event-time billing suspension whose recovery
173
+ * is deliberately customer-driven. Provider cleanup may still be pending or
174
+ * may have failed, but neither a wallet top-up nor a policy sweep is authority
175
+ * to recreate the provider resource. Keep this predicate with the billing
176
+ * state decoder so every policy caller reads legacy/unknown payloads the same
177
+ * way.
178
+ */
179
+ export function monitorBillingRequiresExplicitReactivation(
180
+ value: unknown,
181
+ ): boolean {
182
+ const state = parseStoredMonitorBillingState(value).state;
183
+ return (
184
+ state === 'billing_suspended' ||
185
+ state === 'upstream_disable_pending' ||
186
+ state === 'upstream_disable_failed'
187
+ );
188
+ }
189
+
163
190
  export function publicMonitorBillingSummary(
164
191
  state: StoredMonitorBillingState,
192
+ customerState: ProviderMonitorCustomerState,
165
193
  charges?: {
166
194
  create_charge?: PublicMonitorCustomerChargeSummary;
167
195
  reactivate_charge?: PublicMonitorCustomerChargeSummary;
168
196
  },
169
197
  ): PublicMonitorBillingSummary {
198
+ const suspensionReason =
199
+ state.suspension_reason === 'billing_failure_upstream_disable_failed'
200
+ ? 'billing_failure'
201
+ : state.suspension_reason;
170
202
  return {
171
- state: state.state,
203
+ state: customerState,
172
204
  lifecycle_charge_credits: state.lifecycle_charge_credits,
173
205
  usage_charge_pending: state.usage_charge_pending,
174
206
  reactivation_required: state.reactivation_required,
@@ -176,9 +208,7 @@ export function publicMonitorBillingSummary(
176
208
  ...(charges?.reactivate_charge
177
209
  ? { reactivate_charge: charges.reactivate_charge }
178
210
  : {}),
179
- ...(state.suspension_reason
180
- ? { suspension_reason: state.suspension_reason }
181
- : {}),
211
+ ...(suspensionReason ? { suspension_reason: suspensionReason } : {}),
182
212
  ...(state.next_renewal_at !== undefined
183
213
  ? { next_renewal_at: state.next_renewal_at }
184
214
  : {}),
@@ -9,7 +9,6 @@ export type MonitorBillingPhase =
9
9
 
10
10
  export type MonitorBillingState =
11
11
  | 'active'
12
- | 'preflight_denied'
13
12
  | 'billing_pending'
14
13
  | 'billing_suspended'
15
14
  | 'upstream_disable_pending'
@@ -1,3 +1,5 @@
1
+ import { monitorBillingRequiresExplicitReactivation } from './billing/state';
2
+
1
3
  /**
2
4
  * Why a monitor is desired-inactive.
3
5
  *
@@ -60,8 +62,7 @@ export const MONITOR_DEACTIVATION_REASONS: readonly MonitorDeactivationReasonDef
60
62
  {
61
63
  id: 'billing_failure',
62
64
  owner: 'policy',
63
- summary:
64
- 'Deactivated because monitor event billing was denied.',
65
+ summary: 'Deactivated because monitor event billing was denied.',
65
66
  resolution:
66
67
  'Resolve the billing restriction, then explicitly reactivate the monitors you want restored.',
67
68
  },
@@ -144,6 +145,7 @@ export function balanceAdmitsMonitors(balance: number | null): boolean {
144
145
  export type MonitorPolicyRow = {
145
146
  desired?: 'active' | 'inactive' | undefined;
146
147
  deactivationReason?: string | undefined;
148
+ billingState?: unknown;
147
149
  };
148
150
 
149
151
  export type MonitorPolicyDecision =
@@ -194,7 +196,8 @@ export function decideMonitorBalancePolicy(input: {
194
196
  if (
195
197
  input.balance !== null &&
196
198
  input.row.desired === 'inactive' &&
197
- reason === 'insufficient_balance'
199
+ reason === 'insufficient_balance' &&
200
+ !monitorBillingRequiresExplicitReactivation(input.row.billingState)
198
201
  ) {
199
202
  return { kind: 'reactivate' };
200
203
  }