deepline 0.2.39 → 0.2.41

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.
@@ -1030,7 +1030,7 @@ var SDK_RELEASE = {
1030
1030
  // 0.2.0 makes Dataset Handles uniformly async-only after 0.1.320 briefly
1031
1031
  // exposed storage-dependent synchronous access. This deliberate minor
1032
1032
  // release keeps lazy paging semantics independent of row residency.
1033
- version: "0.2.39",
1033
+ version: "0.2.41",
1034
1034
  contracts: {
1035
1035
  api: {
1036
1036
  name: "sdk-http-api",
@@ -1658,6 +1658,9 @@ var HttpClient = class {
1658
1658
  headers
1659
1659
  });
1660
1660
  }
1661
+ async put(path, body, headers) {
1662
+ return this.request(path, { method: "PUT", body, headers });
1663
+ }
1661
1664
  /**
1662
1665
  * Send a DELETE request.
1663
1666
  *
@@ -1808,6 +1811,61 @@ function withCoworkNetworkHint(message) {
1808
1811
  ${COWORK_NETWORK_HINT}`;
1809
1812
  }
1810
1813
 
1814
+ // ../shared_libs/product-notifications/contract.ts
1815
+ var PRODUCT_NOTIFICATION_EVENT_CATALOG = [
1816
+ {
1817
+ id: "play.cron.succeeded",
1818
+ label: "Cron success",
1819
+ description: "A scheduled Play run completed successfully.",
1820
+ source: "cron",
1821
+ outcome: "succeeded",
1822
+ defaultEnabled: true
1823
+ },
1824
+ {
1825
+ id: "play.cron.failed",
1826
+ label: "Cron failure",
1827
+ description: "A scheduled Play could not start or its run reached a failed terminal state.",
1828
+ source: "cron",
1829
+ outcome: "failed",
1830
+ defaultEnabled: true
1831
+ },
1832
+ {
1833
+ id: "play.webhook.succeeded",
1834
+ label: "Webhook success",
1835
+ description: "An accepted webhook-triggered Play completed successfully.",
1836
+ source: "webhook",
1837
+ outcome: "succeeded",
1838
+ defaultEnabled: true
1839
+ },
1840
+ {
1841
+ id: "play.webhook.failed",
1842
+ label: "Webhook failure",
1843
+ description: "An accepted webhook-triggered Play reached a failed terminal state.",
1844
+ source: "webhook",
1845
+ outcome: "failed",
1846
+ defaultEnabled: true
1847
+ }
1848
+ ];
1849
+ var PRODUCT_NOTIFICATION_EVENT_TYPE_SET = new Set(
1850
+ PRODUCT_NOTIFICATION_EVENT_CATALOG.map((event) => event.id)
1851
+ );
1852
+ var PRODUCT_NOTIFICATION_SLACK_OAUTH_SCOPES = [
1853
+ "channels:read",
1854
+ "chat:write",
1855
+ "groups:read"
1856
+ ];
1857
+ var PRODUCT_NOTIFICATION_RETRY_DELAYS_MS = [
1858
+ 0,
1859
+ 6e4,
1860
+ 5 * 6e4,
1861
+ 15 * 6e4,
1862
+ 60 * 6e4
1863
+ ];
1864
+ var PRODUCT_NOTIFICATION_MAX_ATTEMPTS = PRODUCT_NOTIFICATION_RETRY_DELAYS_MS.length;
1865
+ var PRODUCT_NOTIFICATION_DELIVERY_LEASE_MS = 2 * 6e4;
1866
+ var PRODUCT_NOTIFICATION_SUCCESS_TTL_MS = 15 * 6e4;
1867
+ var PRODUCT_NOTIFICATION_FAILURE_TTL_MS = 24 * 60 * 6e4;
1868
+
1811
1869
  // src/stream-reconnect.ts
1812
1870
  var STREAM_RECONNECT_BASE_DELAY_MS = 500;
1813
1871
  var STREAM_RECONNECT_MAX_DELAY_MS = 15e3;
@@ -3200,6 +3258,7 @@ async function* observeRunEvents(options) {
3200
3258
  // ../shared_libs/integrations/theirstack-execution-policy.ts
3201
3259
  var THEIRSTACK_SLOW_JOB_SEARCH_PROVIDER_TIMEOUT_MS = 135e3;
3202
3260
  var THEIRSTACK_SLOW_JOB_SEARCH_CLIENT_TIMEOUT_MS = 6e4 + THEIRSTACK_SLOW_JOB_SEARCH_PROVIDER_TIMEOUT_MS + 15e3;
3261
+ var THEIRSTACK_COMPANY_SEARCH_CLIENT_TIMEOUT_MS = 21e4;
3203
3262
  var LONG_JOB_SEARCH_WINDOW_MS = 365 * 24 * 60 * 60 * 1e3;
3204
3263
  var DATE_ONLY_PATTERN = /^\d{4}-\d{2}-\d{2}$/;
3205
3264
  function parseDateOnly(value) {
@@ -3243,6 +3302,12 @@ function usesExtendedTheirstackJobSearchBudget(endpointId, payload) {
3243
3302
  const maxAgeDays = parseMaxAgeDays(payload.posted_at_max_age_days);
3244
3303
  return maxAgeDays !== null && maxAgeDays >= 365 ? true : usesLongExplicitDateWindow(payload);
3245
3304
  }
3305
+ function resolveTheirstackClientTimeoutMs(endpointId, payload) {
3306
+ if (endpointId === "theirstack_company_search") {
3307
+ return THEIRSTACK_COMPANY_SEARCH_CLIENT_TIMEOUT_MS;
3308
+ }
3309
+ return usesExtendedTheirstackJobSearchBudget(endpointId, payload) ? THEIRSTACK_SLOW_JOB_SEARCH_CLIENT_TIMEOUT_MS : null;
3310
+ }
3246
3311
 
3247
3312
  // ../shared_libs/play-runtime/backend.ts
3248
3313
  var PLAY_RUNTIME_BACKENDS = {
@@ -3489,9 +3554,11 @@ function resolveToolExecuteTimeoutMs(toolId, input2) {
3489
3554
  return Math.floor(requestedTimeoutMs) + APIFY_SYNC_RESPONSE_GRACE_MS;
3490
3555
  }
3491
3556
  }
3492
- if (usesExtendedTheirstackJobSearchBudget(normalized, input2)) {
3493
- return THEIRSTACK_SLOW_JOB_SEARCH_CLIENT_TIMEOUT_MS;
3494
- }
3557
+ const theirstackTimeoutMs = resolveTheirstackClientTimeoutMs(
3558
+ normalized,
3559
+ input2
3560
+ );
3561
+ if (theirstackTimeoutMs !== null) return theirstackTimeoutMs;
3495
3562
  return normalized === "deeplineagent" || normalized === "deeplineagent_deeplineagent" || normalized === "ai_inference" || normalized === "deeplineagent_ai_inference" || normalized === "aiinference" ? DEEPLINEAGENT_EXECUTE_TIMEOUT_MS : void 0;
3496
3563
  }
3497
3564
  var RUNS_FAILED_LOG_LIMIT = 20;
@@ -5364,6 +5431,95 @@ var DeeplineClient = class {
5364
5431
  );
5365
5432
  return response.plays ?? [];
5366
5433
  }
5434
+ /** Read product-notification destinations, subscriptions, event catalog, and DLQ health. */
5435
+ async getNotificationSettings() {
5436
+ return this.http.get("/api/v2/settings/notifications");
5437
+ }
5438
+ /** Start the Slack OAuth flow required by product notifications. */
5439
+ async connectNotificationSlack(options) {
5440
+ return this.http.post("/api/v2/integrations/connect", {
5441
+ provider: "slack",
5442
+ scopes: [...PRODUCT_NOTIFICATION_SLACK_OAUTH_SCOPES],
5443
+ ...options?.successUrl ? { success_url: options.successUrl } : {},
5444
+ ...options?.failureUrl ? { failure_url: options.failureUrl } : {}
5445
+ });
5446
+ }
5447
+ /** List Slack channels visible to the connected Deepline Slack app. */
5448
+ async listNotificationSlackChannels(query) {
5449
+ const suffix = query ? `?query=${encodeURIComponent(query)}` : "";
5450
+ return this.http.get(`/api/v2/settings/notifications/channels${suffix}`);
5451
+ }
5452
+ /** Select the Slack channel used for product notifications. */
5453
+ async setNotificationSlack(channel) {
5454
+ return this.http.put("/api/v2/settings/notifications", { channel });
5455
+ }
5456
+ /** Send one synchronous test ping and return Slack's delivery result. */
5457
+ async testNotificationSlack() {
5458
+ return this.http.post("/api/v2/settings/notifications/test", {});
5459
+ }
5460
+ /** Disable Slack product notifications without deleting the OAuth connection. */
5461
+ async disableNotificationSlack() {
5462
+ return this.http.delete("/api/v2/settings/notifications");
5463
+ }
5464
+ /** Enable or disable event IDs from the server-provided notification catalog. */
5465
+ async setNotificationSubscriptions(eventTypes, enabled) {
5466
+ return this.http.patch("/api/v2/settings/notifications/subscriptions", {
5467
+ eventTypes,
5468
+ enabled
5469
+ });
5470
+ }
5471
+ /** List exhausted deliveries. Dead-lettered messages never replay automatically. */
5472
+ async listNotificationDlq(limit = 25) {
5473
+ return this.http.get(
5474
+ `/api/v2/settings/notifications/dlq?limit=${encodeURIComponent(String(limit))}`
5475
+ );
5476
+ }
5477
+ /** Inspect one exhausted notification delivery. */
5478
+ async getNotificationDlqDelivery(deliveryId) {
5479
+ return this.http.get(
5480
+ `/api/v2/settings/notifications/dlq/${encodeURIComponent(deliveryId)}`
5481
+ );
5482
+ }
5483
+ /** Explicitly retry or archive one dead-lettered notification delivery. */
5484
+ async updateNotificationDlqDelivery(deliveryId, action) {
5485
+ return this.http.post(
5486
+ `/api/v2/settings/notifications/dlq/${encodeURIComponent(deliveryId)}`,
5487
+ { action }
5488
+ );
5489
+ }
5490
+ /** List the workspace's named notification rules. */
5491
+ async getNotifications() {
5492
+ return this.http.get("/api/v2/notifications");
5493
+ }
5494
+ /** List Slack channels available to an already-connected Slack integration. */
5495
+ async listNotificationChannels(query) {
5496
+ const suffix = query ? `?search=${encodeURIComponent(query)}` : "";
5497
+ return this.http.get(`/api/v2/notifications/slack/channels${suffix}`);
5498
+ }
5499
+ /** Create a named notification routed through an existing provider integration. */
5500
+ async createNotification(input2) {
5501
+ return this.http.post("/api/v2/notifications", input2);
5502
+ }
5503
+ /** Update a notification's target, event selection, or enabled state. */
5504
+ async updateNotification(notificationId, input2) {
5505
+ return this.http.patch(
5506
+ `/api/v2/notifications/${encodeURIComponent(notificationId)}`,
5507
+ input2
5508
+ );
5509
+ }
5510
+ /** Send a validation ping to one notification. */
5511
+ async testNotification(notificationId) {
5512
+ return this.http.post(
5513
+ `/api/v2/notifications/${encodeURIComponent(notificationId)}/test`,
5514
+ {}
5515
+ );
5516
+ }
5517
+ /** Archive one notification without touching its provider integration. */
5518
+ async deleteNotification(notificationId) {
5519
+ return this.http.delete(
5520
+ `/api/v2/notifications/${encodeURIComponent(notificationId)}`
5521
+ );
5522
+ }
5367
5523
  /**
5368
5524
  * Search callable plays and return compact play descriptions.
5369
5525
  *
@@ -22787,6 +22943,20 @@ async function handlePlayList(args) {
22787
22943
  if (play.inputSchema || play.hasInputSchema) {
22788
22944
  process.stdout.write(" inputSchema: yes\n");
22789
22945
  }
22946
+ const configuredTriggers = [
22947
+ play.triggerStatus?.cron ? `cron=${play.triggerStatus.cron}` : null,
22948
+ play.triggerStatus?.webhook ? `webhook=${play.triggerStatus.webhook}` : null
22949
+ ].filter(Boolean);
22950
+ if (configuredTriggers.length > 0) {
22951
+ process.stdout.write(` triggers: ${configuredTriggers.join(", ")}
22952
+ `);
22953
+ if (play.triggerStatus?.blockedReason) {
22954
+ process.stdout.write(
22955
+ ` trigger issue: ${play.triggerStatus.blockedReason}
22956
+ `
22957
+ );
22958
+ }
22959
+ }
22790
22960
  process.stdout.write(` run: deepline plays run ${reference} --watch
22791
22961
  `);
22792
22962
  }
@@ -36109,6 +36279,7 @@ var SDK_SIDECAR_CRITICAL_PACKAGE_FILES = [
36109
36279
  "dist/bundling-sources/shared_libs/observability/telemetry.ts",
36110
36280
  "dist/bundling-sources/shared_libs/play-runtime/backend.ts",
36111
36281
  "dist/bundling-sources/shared_libs/plays/bundling/index.ts",
36282
+ "dist/bundling-sources/shared_libs/product-notifications/contract.ts",
36112
36283
  "dist/bundling-sources/shared_libs/tool-execution-error.ts"
36113
36284
  ];
36114
36285
  var SDK_SIDECAR_CRITICAL_DEPENDENCY_FILES = [
@@ -37974,6 +38145,588 @@ Examples:
37974
38145
  });
37975
38146
  }
37976
38147
 
38148
+ // src/cli/commands/settings.ts
38149
+ var eventHelp = PRODUCT_NOTIFICATION_EVENT_CATALOG.map(
38150
+ (event) => ` ${event.id.padEnd(28)} ${event.description}`
38151
+ ).join("\n");
38152
+ function slackDestination(settings) {
38153
+ return settings.destinations.find((entry) => entry.kind === "slack");
38154
+ }
38155
+ function eventLines(settings) {
38156
+ const enabled = new Map(
38157
+ settings.subscriptions.map((entry) => [entry.eventType, entry.enabled])
38158
+ );
38159
+ return settings.catalog.map(
38160
+ (event) => `${event.id}: ${enabled.get(event.id) === true ? "enabled" : "disabled"} \u2014 ${event.description}`
38161
+ );
38162
+ }
38163
+ function requireCatalogEvent(settings, eventType) {
38164
+ const event = settings.catalog.find((entry) => entry.id === eventType);
38165
+ if (!event) {
38166
+ throw new Error(
38167
+ `Unknown notification event "${eventType}". Run deepline settings notifications subscriptions list.`
38168
+ );
38169
+ }
38170
+ return event;
38171
+ }
38172
+ async function printSettings(options) {
38173
+ const settings = await new DeeplineClient().getNotificationSettings();
38174
+ const slack = slackDestination(settings);
38175
+ printCommandEnvelope(
38176
+ {
38177
+ settings,
38178
+ render: {
38179
+ sections: [
38180
+ {
38181
+ title: "Slack destination",
38182
+ lines: slack ? [
38183
+ `status: ${String(slack.status ?? "unknown")}`,
38184
+ `channel: #${String(slack.channelName ?? slack.channelId ?? "unknown")}`,
38185
+ ...slack.lastErrorMessage ? [`issue: ${String(slack.lastErrorMessage)}`] : []
38186
+ ] : ["Not configured."]
38187
+ },
38188
+ { title: "subscriptions", lines: eventLines(settings) },
38189
+ {
38190
+ title: "dead letter queue",
38191
+ lines: [
38192
+ `${settings.dlq.count}${settings.dlq.capped ? "+" : ""} deliveries require review`
38193
+ ]
38194
+ }
38195
+ ],
38196
+ actions: slack ? [
38197
+ {
38198
+ label: "Validate Slack",
38199
+ command: "deepline settings notifications test slack"
38200
+ }
38201
+ ] : [
38202
+ {
38203
+ label: "Connect Slack",
38204
+ command: "deepline settings notifications connect slack --open"
38205
+ }
38206
+ ]
38207
+ }
38208
+ },
38209
+ { json: options.json }
38210
+ );
38211
+ }
38212
+ function registerSettingsCommands(program) {
38213
+ const settings = program.command("settings").description("Manage workspace product settings.");
38214
+ const notifications = settings.command("notifications").description(
38215
+ "Configure Deepline product notifications and delivery safety."
38216
+ ).addHelpText(
38217
+ "after",
38218
+ `
38219
+ Workflow:
38220
+ 1. deepline settings notifications connect slack --open
38221
+ 2. deepline settings notifications channels --query pipeline
38222
+ 3. deepline settings notifications set slack --channel '#pipeline-alerts'
38223
+ 4. deepline settings notifications test slack
38224
+ 5. deepline settings notifications subscriptions list
38225
+
38226
+ Slack is the delivery integration. This command group only manages product
38227
+ notifications; there is no general integrations CLI.
38228
+ `
38229
+ );
38230
+ notifications.command("get").description("Show destination, subscriptions, and DLQ health.").option("--json", "Emit JSON output").action(printSettings);
38231
+ notifications.command("connect").description("Start the OAuth connection required by a destination.").argument("<destination>", "Destination kind (currently slack)").option("--open", "Open the Slack authorization URL in a browser").option("--dry-run", "Describe the mutation without starting OAuth").option("--json", "Emit JSON output").action(
38232
+ async (destination, options) => {
38233
+ if (destination !== "slack")
38234
+ throw new Error("Only slack is supported.");
38235
+ if (options.dryRun) {
38236
+ printCommandEnvelope(
38237
+ { dryRun: true, destination, action: "start_oauth" },
38238
+ { json: options.json }
38239
+ );
38240
+ return;
38241
+ }
38242
+ const result = await new DeeplineClient().connectNotificationSlack();
38243
+ const browser = options.open ? openInBrowser(result.redirect_url, { deduplicate: false }) : "not_requested";
38244
+ printCommandEnvelope(
38245
+ {
38246
+ ...result,
38247
+ browser,
38248
+ render: {
38249
+ sections: [
38250
+ {
38251
+ title: "Slack authorization",
38252
+ lines: [result.redirect_url, `browser: ${browser}`]
38253
+ }
38254
+ ],
38255
+ actions: [
38256
+ {
38257
+ label: "After authorization",
38258
+ command: "deepline settings notifications set slack --channel '#channel'"
38259
+ }
38260
+ ]
38261
+ }
38262
+ },
38263
+ { json: options.json }
38264
+ );
38265
+ }
38266
+ );
38267
+ notifications.command("channels").description("List Slack channels visible to the connected Deepline app.").option("--query <text>", "Filter channels by name").option("--json", "Emit JSON output").action(async (options) => {
38268
+ const result = await new DeeplineClient().listNotificationSlackChannels(
38269
+ options.query
38270
+ );
38271
+ printCommandEnvelope(
38272
+ {
38273
+ ...result,
38274
+ render: {
38275
+ sections: [
38276
+ {
38277
+ title: "Slack channels",
38278
+ lines: result.channels.length ? result.channels.map(
38279
+ (channel) => `#${channel.name} (${channel.id})${channel.isPrivate ? " private" : ""}`
38280
+ ) : ["No visible channels matched."]
38281
+ }
38282
+ ]
38283
+ }
38284
+ },
38285
+ { json: options.json }
38286
+ );
38287
+ });
38288
+ notifications.command("set").description("Set a product-notification destination.").argument("<destination>", "Destination kind (currently slack)").requiredOption("--channel <channel>", "Slack channel name or ID").option("--dry-run", "Validate intent without changing settings").option("--json", "Emit JSON output").action(
38289
+ async (destination, options) => {
38290
+ if (destination !== "slack")
38291
+ throw new Error("Only slack is supported.");
38292
+ if (options.dryRun) {
38293
+ printCommandEnvelope(
38294
+ { dryRun: true, destination, channel: options.channel },
38295
+ { json: options.json }
38296
+ );
38297
+ return;
38298
+ }
38299
+ const result = await new DeeplineClient().setNotificationSlack(
38300
+ options.channel
38301
+ );
38302
+ printCommandEnvelope(
38303
+ {
38304
+ ok: true,
38305
+ result,
38306
+ render: {
38307
+ sections: [
38308
+ { title: "Slack destination saved", lines: [options.channel] }
38309
+ ],
38310
+ actions: [
38311
+ {
38312
+ label: "Validate delivery",
38313
+ command: "deepline settings notifications test slack"
38314
+ }
38315
+ ]
38316
+ }
38317
+ },
38318
+ { json: options.json }
38319
+ );
38320
+ }
38321
+ );
38322
+ notifications.command("test").description("Send a validation ping to a destination.").argument("<destination>", "Destination kind (currently slack)").option("--dry-run", "Describe the external send without sending").option("--json", "Emit JSON output").action(async (destination, options) => {
38323
+ if (destination !== "slack") throw new Error("Only slack is supported.");
38324
+ if (options.dryRun) {
38325
+ printCommandEnvelope(
38326
+ { dryRun: true, destination, action: "send_test_ping" },
38327
+ { json: options.json }
38328
+ );
38329
+ return;
38330
+ }
38331
+ const result = await new DeeplineClient().testNotificationSlack();
38332
+ printCommandEnvelope(
38333
+ {
38334
+ ...result,
38335
+ render: {
38336
+ sections: [{ title: "Slack validation", lines: [result.message] }]
38337
+ }
38338
+ },
38339
+ { json: options.json }
38340
+ );
38341
+ });
38342
+ notifications.command("disable").description("Disable a product-notification destination.").argument("<destination>", "Destination kind (currently slack)").option("--dry-run", "Describe the mutation without changing settings").option("--json", "Emit JSON output").action(async (destination, options) => {
38343
+ if (destination !== "slack") throw new Error("Only slack is supported.");
38344
+ if (options.dryRun) {
38345
+ printCommandEnvelope(
38346
+ { dryRun: true, destination, action: "disable" },
38347
+ { json: options.json }
38348
+ );
38349
+ return;
38350
+ }
38351
+ const result = await new DeeplineClient().disableNotificationSlack();
38352
+ printCommandEnvelope(
38353
+ {
38354
+ ok: true,
38355
+ result,
38356
+ render: {
38357
+ sections: [{ title: "Slack destination", lines: ["disabled"] }]
38358
+ }
38359
+ },
38360
+ { json: options.json }
38361
+ );
38362
+ });
38363
+ const subscriptions = notifications.command("subscriptions").description("List and configure supported notification events.").addHelpText(
38364
+ "after",
38365
+ `
38366
+ Supported events (shared product catalog):
38367
+ ${eventHelp}
38368
+ `
38369
+ );
38370
+ subscriptions.command("list").description("List every supported event and its current state.").option("--json", "Emit JSON output").action(async (options) => {
38371
+ const current = await new DeeplineClient().getNotificationSettings();
38372
+ printCommandEnvelope(
38373
+ {
38374
+ catalog: current.catalog,
38375
+ subscriptions: current.subscriptions,
38376
+ render: {
38377
+ sections: [{ title: "subscriptions", lines: eventLines(current) }]
38378
+ }
38379
+ },
38380
+ { json: options.json }
38381
+ );
38382
+ });
38383
+ subscriptions.command("describe").description("Describe one event from the shared product catalog.").argument("<event>", "Event ID; run subscriptions list to enumerate").option("--json", "Emit JSON output").action(async (eventType, options) => {
38384
+ const current = await new DeeplineClient().getNotificationSettings();
38385
+ const event = requireCatalogEvent(current, eventType);
38386
+ const subscription = current.subscriptions.find(
38387
+ (entry) => entry.eventType === event.id
38388
+ );
38389
+ printCommandEnvelope(
38390
+ {
38391
+ event,
38392
+ enabled: subscription?.enabled === true,
38393
+ render: {
38394
+ sections: [
38395
+ {
38396
+ title: event.id,
38397
+ lines: [
38398
+ event.description,
38399
+ `enabled: ${subscription?.enabled === true}`
38400
+ ]
38401
+ }
38402
+ ]
38403
+ }
38404
+ },
38405
+ { json: options.json }
38406
+ );
38407
+ });
38408
+ for (const enabled of [true, false]) {
38409
+ subscriptions.command(enabled ? "enable" : "disable").description(`${enabled ? "Enable" : "Disable"} one supported event.`).argument("<event>", "Event ID; run subscriptions list to enumerate").option("--dry-run", "Validate intent without changing settings").option("--json", "Emit JSON output").action(async (eventType, options) => {
38410
+ const client2 = new DeeplineClient();
38411
+ const current = await client2.getNotificationSettings();
38412
+ const event = requireCatalogEvent(current, eventType);
38413
+ if (options.dryRun) {
38414
+ printCommandEnvelope(
38415
+ { dryRun: true, event, enabled },
38416
+ { json: options.json }
38417
+ );
38418
+ return;
38419
+ }
38420
+ const result = await client2.setNotificationSubscriptions(
38421
+ [event.id],
38422
+ enabled
38423
+ );
38424
+ printCommandEnvelope(
38425
+ {
38426
+ ok: true,
38427
+ event: event.id,
38428
+ enabled,
38429
+ result,
38430
+ render: {
38431
+ sections: [
38432
+ {
38433
+ title: "subscription updated",
38434
+ lines: [`${event.id}: ${enabled ? "enabled" : "disabled"}`]
38435
+ }
38436
+ ]
38437
+ }
38438
+ },
38439
+ { json: options.json }
38440
+ );
38441
+ });
38442
+ }
38443
+ const dlq = notifications.command("dlq").description("Inspect and explicitly resolve inert failed deliveries.");
38444
+ dlq.command("list").option("--limit <count>", "Maximum deliveries", "25").option("--json", "Emit JSON output").action(async (options) => {
38445
+ const result = await new DeeplineClient().listNotificationDlq(
38446
+ Number(options.limit)
38447
+ );
38448
+ const deliveries = result.deliveries ?? [];
38449
+ printCommandEnvelope(
38450
+ {
38451
+ ...result,
38452
+ render: {
38453
+ sections: [
38454
+ {
38455
+ title: "dead letter queue",
38456
+ lines: deliveries.length ? deliveries.map(
38457
+ (entry) => `${String(entry._id)}: ${String(entry.lastErrorCode ?? "delivery_failed")}`
38458
+ ) : ["empty"]
38459
+ }
38460
+ ]
38461
+ }
38462
+ },
38463
+ { json: options.json }
38464
+ );
38465
+ });
38466
+ dlq.command("get").argument("<delivery-id>").option("--json", "Emit JSON output").action(async (deliveryId, options) => {
38467
+ const result = await new DeeplineClient().getNotificationDlqDelivery(
38468
+ deliveryId
38469
+ );
38470
+ printCommandEnvelope(result, {
38471
+ json: options.json
38472
+ });
38473
+ });
38474
+ for (const action of ["retry", "archive"]) {
38475
+ dlq.command(action).description(
38476
+ `${action === "retry" ? "Replay once from attempt zero" : "Archive"} one delivery.`
38477
+ ).argument("<delivery-id>").option("--dry-run", "Describe the mutation without changing state").option("--json", "Emit JSON output").action(async (deliveryId, options) => {
38478
+ if (options.dryRun) {
38479
+ printCommandEnvelope(
38480
+ { dryRun: true, action, deliveryId },
38481
+ { json: options.json }
38482
+ );
38483
+ return;
38484
+ }
38485
+ const result = await new DeeplineClient().updateNotificationDlqDelivery(
38486
+ deliveryId,
38487
+ action
38488
+ );
38489
+ printCommandEnvelope(
38490
+ { ok: true, action, deliveryId, result },
38491
+ { json: options.json }
38492
+ );
38493
+ });
38494
+ }
38495
+ }
38496
+ function notificationByName(settings, reference) {
38497
+ const notification = (settings.notifications ?? []).find(
38498
+ (entry) => entry.id === reference || entry.name === reference
38499
+ );
38500
+ if (!notification) {
38501
+ throw new Error(
38502
+ `No notification named "${reference}". Run deepline notifications list.`
38503
+ );
38504
+ }
38505
+ return notification;
38506
+ }
38507
+ function parseSlackTarget(value) {
38508
+ const match = /^slack:(.+)$/i.exec(value.trim());
38509
+ if (!match?.[1]) {
38510
+ throw new Error("Use --to slack:#channel.");
38511
+ }
38512
+ return match[1];
38513
+ }
38514
+ function collectEvent(value, previous = []) {
38515
+ return [...previous, value];
38516
+ }
38517
+ function registerNotificationCommands(program) {
38518
+ const notifications = program.command("notifications").description("Choose which Play outcomes notify which people and channels.").addHelpText(
38519
+ "after",
38520
+ `
38521
+ Examples:
38522
+ deepline notifications events
38523
+ deepline notifications slack channels --search pipeline
38524
+ deepline notifications add pipeline-watchdog --to slack:#pipeline-alerts --for play.cron.failed
38525
+ deepline notifications test pipeline-watchdog
38526
+
38527
+ Slack connections are managed in Dashboard \u2192 Integrations. This command only
38528
+ chooses the connected Slack channel and the events it receives.
38529
+ `
38530
+ );
38531
+ notifications.command("events").description("List the Play events available to a notification.").option("--json", "Emit JSON output").action(async (options) => {
38532
+ const settings = await new DeeplineClient().getNotifications();
38533
+ printCommandEnvelope(
38534
+ {
38535
+ events: settings.catalog,
38536
+ render: {
38537
+ sections: [
38538
+ {
38539
+ title: "available events",
38540
+ lines: settings.catalog.length ? settings.catalog.map(
38541
+ (event) => `${event.id}: ${event.description}`
38542
+ ) : ["No notification events are available."]
38543
+ }
38544
+ ]
38545
+ }
38546
+ },
38547
+ { json: options.json }
38548
+ );
38549
+ });
38550
+ notifications.command("list").description("List named notifications and their selected Play events.").option("--json", "Emit JSON output").option("--compact", "Emit only names, state, target, and event IDs").action(async (options) => {
38551
+ const settings = await new DeeplineClient().getNotifications();
38552
+ const rules = settings.notifications ?? [];
38553
+ printCommandEnvelope(
38554
+ {
38555
+ notifications: options.compact ? rules.map((rule) => ({
38556
+ id: rule.id,
38557
+ name: rule.name,
38558
+ enabled: rule.enabled,
38559
+ target: `#${rule.target.name}`,
38560
+ eventTypes: rule.eventTypes
38561
+ })) : rules,
38562
+ count: rules.length,
38563
+ render: {
38564
+ sections: [
38565
+ {
38566
+ title: "notifications",
38567
+ lines: rules.length ? rules.map(
38568
+ (rule) => `${rule.name}: ${rule.enabled ? "on" : "paused"} \u2192 #${rule.target.name} (${rule.eventTypes.join(", ") || "no events"})`
38569
+ ) : [
38570
+ "None yet. Add one with deepline notifications add <name> --to slack:#channel --for play.cron.failed."
38571
+ ]
38572
+ }
38573
+ ]
38574
+ }
38575
+ },
38576
+ { json: options.json }
38577
+ );
38578
+ });
38579
+ notifications.command("get").argument("<name>", "Notification name or ID").description("Show one named notification.").option("--json", "Emit JSON output").action(async (name, options) => {
38580
+ const rule = notificationByName(
38581
+ await new DeeplineClient().getNotifications(),
38582
+ name
38583
+ );
38584
+ printCommandEnvelope({ notification: rule }, { json: options.json });
38585
+ });
38586
+ notifications.command("add").argument("<name>", "Short stable name, for example pipeline-watchdog").requiredOption(
38587
+ "--to <target>",
38588
+ "Target, for example slack:#pipeline-alerts"
38589
+ ).option(
38590
+ "--for <event>",
38591
+ "Event ID; repeat for more events. Run notifications events to list them",
38592
+ collectEvent,
38593
+ []
38594
+ ).option("--dry-run", "Describe the notification without saving it").option("--json", "Emit JSON output").action(
38595
+ async (name, options) => {
38596
+ if (!options.for.length) {
38597
+ throw new Error("Choose at least one event with --for <event>.");
38598
+ }
38599
+ const channel = parseSlackTarget(options.to);
38600
+ if (options.dryRun) {
38601
+ printCommandEnvelope(
38602
+ { dryRun: true, name, target: options.to, eventTypes: options.for },
38603
+ { json: options.json }
38604
+ );
38605
+ return;
38606
+ }
38607
+ const result = await new DeeplineClient().createNotification({
38608
+ name,
38609
+ provider: "slack",
38610
+ channel,
38611
+ eventTypes: options.for
38612
+ });
38613
+ printCommandEnvelope(
38614
+ {
38615
+ notification: result,
38616
+ render: {
38617
+ sections: [{ title: "notification saved", lines: [name] }],
38618
+ actions: [
38619
+ {
38620
+ label: "Send a test",
38621
+ command: `deepline notifications test ${name}`
38622
+ }
38623
+ ]
38624
+ }
38625
+ },
38626
+ { json: options.json }
38627
+ );
38628
+ }
38629
+ );
38630
+ notifications.command("edit").argument("<name>", "Notification name or ID").option("--to <target>", "New target, for example slack:#pipeline-alerts").option(
38631
+ "--for <event>",
38632
+ "Replace selected events; repeat for more events. Run notifications events to list them",
38633
+ collectEvent,
38634
+ []
38635
+ ).option("--dry-run", "Describe the change without saving it").option("--json", "Emit JSON output").action(
38636
+ async (name, options) => {
38637
+ const client2 = new DeeplineClient();
38638
+ const rule = notificationByName(await client2.getNotifications(), name);
38639
+ const channel = options.to ? parseSlackTarget(options.to) : rule.target.name;
38640
+ const eventTypes = options.for.length ? options.for : rule.eventTypes;
38641
+ if (options.dryRun) {
38642
+ printCommandEnvelope(
38643
+ { dryRun: true, notification: rule.id, channel, eventTypes },
38644
+ { json: options.json }
38645
+ );
38646
+ return;
38647
+ }
38648
+ const result = await client2.updateNotification(rule.id, {
38649
+ name: rule.name,
38650
+ channel,
38651
+ eventTypes
38652
+ });
38653
+ printCommandEnvelope({ notification: result }, { json: options.json });
38654
+ }
38655
+ );
38656
+ const slack = notifications.command("slack").description("Select a channel from the connected Slack integration.");
38657
+ slack.command("channels").option("--search <text>", "Filter channel names").option("--json", "Emit JSON output").action(async (options) => {
38658
+ const result = await new DeeplineClient().listNotificationChannels(
38659
+ options.search
38660
+ );
38661
+ printCommandEnvelope(
38662
+ {
38663
+ ...result,
38664
+ render: {
38665
+ sections: [
38666
+ {
38667
+ title: "Slack channels",
38668
+ lines: result.channels.length ? result.channels.map((channel) => `#${channel.name}`) : ["No visible channels matched."]
38669
+ }
38670
+ ]
38671
+ }
38672
+ },
38673
+ { json: options.json }
38674
+ );
38675
+ });
38676
+ for (const [command, enabled] of [
38677
+ ["pause", false],
38678
+ ["resume", true]
38679
+ ]) {
38680
+ notifications.command(command).argument("<name>", "Notification name or ID").option("--dry-run", "Describe the change without saving it").option("--json", "Emit JSON output").action(async (name, options) => {
38681
+ const client2 = new DeeplineClient();
38682
+ const rule = notificationByName(await client2.getNotifications(), name);
38683
+ if (options.dryRun) {
38684
+ printCommandEnvelope(
38685
+ { dryRun: true, notification: rule.id, enabled },
38686
+ { json: options.json }
38687
+ );
38688
+ return;
38689
+ }
38690
+ const result = await client2.updateNotification(rule.id, { enabled });
38691
+ printCommandEnvelope({ notification: result }, { json: options.json });
38692
+ });
38693
+ }
38694
+ notifications.command("test").argument("<name>", "Notification name or ID").option("--dry-run", "Describe the external send without sending").option("--json", "Emit JSON output").action(async (name, options) => {
38695
+ const client2 = new DeeplineClient();
38696
+ const rule = notificationByName(await client2.getNotifications(), name);
38697
+ if (options.dryRun) {
38698
+ printCommandEnvelope(
38699
+ { dryRun: true, notification: rule.id, action: "send_test" },
38700
+ { json: options.json }
38701
+ );
38702
+ return;
38703
+ }
38704
+ const result = await client2.testNotification(rule.id);
38705
+ printCommandEnvelope(
38706
+ { ...result, notification: rule.name },
38707
+ { json: options.json }
38708
+ );
38709
+ });
38710
+ notifications.command("delete").argument("<name>", "Notification name or ID").description(
38711
+ "Archive one notification without touching its provider integration."
38712
+ ).option("--dry-run", "Describe the deletion without changing state").option("--json", "Emit JSON output").action(async (name, options) => {
38713
+ const client2 = new DeeplineClient();
38714
+ const rule = notificationByName(await client2.getNotifications(), name);
38715
+ if (options.dryRun) {
38716
+ printCommandEnvelope(
38717
+ { dryRun: true, notification: rule.id, action: "archive" },
38718
+ { json: options.json }
38719
+ );
38720
+ return;
38721
+ }
38722
+ const result = await client2.deleteNotification(rule.id);
38723
+ printCommandEnvelope(
38724
+ { ...result, notification: rule.name },
38725
+ { json: options.json }
38726
+ );
38727
+ });
38728
+ }
38729
+
37977
38730
  // ../shared_libs/cli/command-compatibility.json
37978
38731
  var command_compatibility_default = {
37979
38732
  enrich: {
@@ -39116,6 +39869,8 @@ Exit codes:
39116
39869
  registerSessionsCommands(program);
39117
39870
  registerWorkflowCommands(program);
39118
39871
  registerSecretsCommands(program);
39872
+ registerSettingsCommands(program);
39873
+ registerNotificationCommands(program);
39119
39874
  registerBillingCommands(program);
39120
39875
  registerMonitorsCommands(program);
39121
39876
  registerOrgCommands(program);