deepline 0.2.39 → 0.2.40

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.
package/dist/cli/index.js CHANGED
@@ -1044,7 +1044,7 @@ var SDK_RELEASE = {
1044
1044
  // 0.2.0 makes Dataset Handles uniformly async-only after 0.1.320 briefly
1045
1045
  // exposed storage-dependent synchronous access. This deliberate minor
1046
1046
  // release keeps lazy paging semantics independent of row residency.
1047
- version: "0.2.39",
1047
+ version: "0.2.40",
1048
1048
  contracts: {
1049
1049
  api: {
1050
1050
  name: "sdk-http-api",
@@ -1672,6 +1672,9 @@ var HttpClient = class {
1672
1672
  headers
1673
1673
  });
1674
1674
  }
1675
+ async put(path, body, headers) {
1676
+ return this.request(path, { method: "PUT", body, headers });
1677
+ }
1675
1678
  /**
1676
1679
  * Send a DELETE request.
1677
1680
  *
@@ -1822,6 +1825,61 @@ function withCoworkNetworkHint(message) {
1822
1825
  ${COWORK_NETWORK_HINT}`;
1823
1826
  }
1824
1827
 
1828
+ // ../shared_libs/product-notifications/contract.ts
1829
+ var PRODUCT_NOTIFICATION_EVENT_CATALOG = [
1830
+ {
1831
+ id: "play.cron.succeeded",
1832
+ label: "Cron success",
1833
+ description: "A scheduled Play run completed successfully.",
1834
+ source: "cron",
1835
+ outcome: "succeeded",
1836
+ defaultEnabled: true
1837
+ },
1838
+ {
1839
+ id: "play.cron.failed",
1840
+ label: "Cron failure",
1841
+ description: "A scheduled Play could not start or its run reached a failed terminal state.",
1842
+ source: "cron",
1843
+ outcome: "failed",
1844
+ defaultEnabled: true
1845
+ },
1846
+ {
1847
+ id: "play.webhook.succeeded",
1848
+ label: "Webhook success",
1849
+ description: "An accepted webhook-triggered Play completed successfully.",
1850
+ source: "webhook",
1851
+ outcome: "succeeded",
1852
+ defaultEnabled: true
1853
+ },
1854
+ {
1855
+ id: "play.webhook.failed",
1856
+ label: "Webhook failure",
1857
+ description: "An accepted webhook-triggered Play reached a failed terminal state.",
1858
+ source: "webhook",
1859
+ outcome: "failed",
1860
+ defaultEnabled: true
1861
+ }
1862
+ ];
1863
+ var PRODUCT_NOTIFICATION_EVENT_TYPE_SET = new Set(
1864
+ PRODUCT_NOTIFICATION_EVENT_CATALOG.map((event) => event.id)
1865
+ );
1866
+ var PRODUCT_NOTIFICATION_SLACK_OAUTH_SCOPES = [
1867
+ "channels:read",
1868
+ "chat:write",
1869
+ "groups:read"
1870
+ ];
1871
+ var PRODUCT_NOTIFICATION_RETRY_DELAYS_MS = [
1872
+ 0,
1873
+ 6e4,
1874
+ 5 * 6e4,
1875
+ 15 * 6e4,
1876
+ 60 * 6e4
1877
+ ];
1878
+ var PRODUCT_NOTIFICATION_MAX_ATTEMPTS = PRODUCT_NOTIFICATION_RETRY_DELAYS_MS.length;
1879
+ var PRODUCT_NOTIFICATION_DELIVERY_LEASE_MS = 2 * 6e4;
1880
+ var PRODUCT_NOTIFICATION_SUCCESS_TTL_MS = 15 * 6e4;
1881
+ var PRODUCT_NOTIFICATION_FAILURE_TTL_MS = 24 * 60 * 6e4;
1882
+
1825
1883
  // src/stream-reconnect.ts
1826
1884
  var STREAM_RECONNECT_BASE_DELAY_MS = 500;
1827
1885
  var STREAM_RECONNECT_MAX_DELAY_MS = 15e3;
@@ -5378,6 +5436,95 @@ var DeeplineClient = class {
5378
5436
  );
5379
5437
  return response.plays ?? [];
5380
5438
  }
5439
+ /** Read product-notification destinations, subscriptions, event catalog, and DLQ health. */
5440
+ async getNotificationSettings() {
5441
+ return this.http.get("/api/v2/settings/notifications");
5442
+ }
5443
+ /** Start the Slack OAuth flow required by product notifications. */
5444
+ async connectNotificationSlack(options) {
5445
+ return this.http.post("/api/v2/integrations/connect", {
5446
+ provider: "slack",
5447
+ scopes: [...PRODUCT_NOTIFICATION_SLACK_OAUTH_SCOPES],
5448
+ ...options?.successUrl ? { success_url: options.successUrl } : {},
5449
+ ...options?.failureUrl ? { failure_url: options.failureUrl } : {}
5450
+ });
5451
+ }
5452
+ /** List Slack channels visible to the connected Deepline Slack app. */
5453
+ async listNotificationSlackChannels(query) {
5454
+ const suffix = query ? `?query=${encodeURIComponent(query)}` : "";
5455
+ return this.http.get(`/api/v2/settings/notifications/channels${suffix}`);
5456
+ }
5457
+ /** Select the Slack channel used for product notifications. */
5458
+ async setNotificationSlack(channel) {
5459
+ return this.http.put("/api/v2/settings/notifications", { channel });
5460
+ }
5461
+ /** Send one synchronous test ping and return Slack's delivery result. */
5462
+ async testNotificationSlack() {
5463
+ return this.http.post("/api/v2/settings/notifications/test", {});
5464
+ }
5465
+ /** Disable Slack product notifications without deleting the OAuth connection. */
5466
+ async disableNotificationSlack() {
5467
+ return this.http.delete("/api/v2/settings/notifications");
5468
+ }
5469
+ /** Enable or disable event IDs from the server-provided notification catalog. */
5470
+ async setNotificationSubscriptions(eventTypes, enabled) {
5471
+ return this.http.patch("/api/v2/settings/notifications/subscriptions", {
5472
+ eventTypes,
5473
+ enabled
5474
+ });
5475
+ }
5476
+ /** List exhausted deliveries. Dead-lettered messages never replay automatically. */
5477
+ async listNotificationDlq(limit = 25) {
5478
+ return this.http.get(
5479
+ `/api/v2/settings/notifications/dlq?limit=${encodeURIComponent(String(limit))}`
5480
+ );
5481
+ }
5482
+ /** Inspect one exhausted notification delivery. */
5483
+ async getNotificationDlqDelivery(deliveryId) {
5484
+ return this.http.get(
5485
+ `/api/v2/settings/notifications/dlq/${encodeURIComponent(deliveryId)}`
5486
+ );
5487
+ }
5488
+ /** Explicitly retry or archive one dead-lettered notification delivery. */
5489
+ async updateNotificationDlqDelivery(deliveryId, action) {
5490
+ return this.http.post(
5491
+ `/api/v2/settings/notifications/dlq/${encodeURIComponent(deliveryId)}`,
5492
+ { action }
5493
+ );
5494
+ }
5495
+ /** List the workspace's named notification rules. */
5496
+ async getNotifications() {
5497
+ return this.http.get("/api/v2/notifications");
5498
+ }
5499
+ /** List Slack channels available to an already-connected Slack integration. */
5500
+ async listNotificationChannels(query) {
5501
+ const suffix = query ? `?search=${encodeURIComponent(query)}` : "";
5502
+ return this.http.get(`/api/v2/notifications/slack/channels${suffix}`);
5503
+ }
5504
+ /** Create a named notification routed through an existing provider integration. */
5505
+ async createNotification(input2) {
5506
+ return this.http.post("/api/v2/notifications", input2);
5507
+ }
5508
+ /** Update a notification's target, event selection, or enabled state. */
5509
+ async updateNotification(notificationId, input2) {
5510
+ return this.http.patch(
5511
+ `/api/v2/notifications/${encodeURIComponent(notificationId)}`,
5512
+ input2
5513
+ );
5514
+ }
5515
+ /** Send a validation ping to one notification. */
5516
+ async testNotification(notificationId) {
5517
+ return this.http.post(
5518
+ `/api/v2/notifications/${encodeURIComponent(notificationId)}/test`,
5519
+ {}
5520
+ );
5521
+ }
5522
+ /** Archive one notification without touching its provider integration. */
5523
+ async deleteNotification(notificationId) {
5524
+ return this.http.delete(
5525
+ `/api/v2/notifications/${encodeURIComponent(notificationId)}`
5526
+ );
5527
+ }
5381
5528
  /**
5382
5529
  * Search callable plays and return compact play descriptions.
5383
5530
  *
@@ -22743,6 +22890,20 @@ async function handlePlayList(args) {
22743
22890
  if (play.inputSchema || play.hasInputSchema) {
22744
22891
  process.stdout.write(" inputSchema: yes\n");
22745
22892
  }
22893
+ const configuredTriggers = [
22894
+ play.triggerStatus?.cron ? `cron=${play.triggerStatus.cron}` : null,
22895
+ play.triggerStatus?.webhook ? `webhook=${play.triggerStatus.webhook}` : null
22896
+ ].filter(Boolean);
22897
+ if (configuredTriggers.length > 0) {
22898
+ process.stdout.write(` triggers: ${configuredTriggers.join(", ")}
22899
+ `);
22900
+ if (play.triggerStatus?.blockedReason) {
22901
+ process.stdout.write(
22902
+ ` trigger issue: ${play.triggerStatus.blockedReason}
22903
+ `
22904
+ );
22905
+ }
22906
+ }
22746
22907
  process.stdout.write(` run: deepline plays run ${reference} --watch
22747
22908
  `);
22748
22909
  }
@@ -36037,6 +36198,7 @@ var SDK_SIDECAR_CRITICAL_PACKAGE_FILES = [
36037
36198
  "dist/bundling-sources/shared_libs/observability/telemetry.ts",
36038
36199
  "dist/bundling-sources/shared_libs/play-runtime/backend.ts",
36039
36200
  "dist/bundling-sources/shared_libs/plays/bundling/index.ts",
36201
+ "dist/bundling-sources/shared_libs/product-notifications/contract.ts",
36040
36202
  "dist/bundling-sources/shared_libs/tool-execution-error.ts"
36041
36203
  ];
36042
36204
  var SDK_SIDECAR_CRITICAL_DEPENDENCY_FILES = [
@@ -37894,6 +38056,588 @@ Examples:
37894
38056
  });
37895
38057
  }
37896
38058
 
38059
+ // src/cli/commands/settings.ts
38060
+ var eventHelp = PRODUCT_NOTIFICATION_EVENT_CATALOG.map(
38061
+ (event) => ` ${event.id.padEnd(28)} ${event.description}`
38062
+ ).join("\n");
38063
+ function slackDestination(settings) {
38064
+ return settings.destinations.find((entry) => entry.kind === "slack");
38065
+ }
38066
+ function eventLines(settings) {
38067
+ const enabled = new Map(
38068
+ settings.subscriptions.map((entry) => [entry.eventType, entry.enabled])
38069
+ );
38070
+ return settings.catalog.map(
38071
+ (event) => `${event.id}: ${enabled.get(event.id) === true ? "enabled" : "disabled"} \u2014 ${event.description}`
38072
+ );
38073
+ }
38074
+ function requireCatalogEvent(settings, eventType) {
38075
+ const event = settings.catalog.find((entry) => entry.id === eventType);
38076
+ if (!event) {
38077
+ throw new Error(
38078
+ `Unknown notification event "${eventType}". Run deepline settings notifications subscriptions list.`
38079
+ );
38080
+ }
38081
+ return event;
38082
+ }
38083
+ async function printSettings(options) {
38084
+ const settings = await new DeeplineClient().getNotificationSettings();
38085
+ const slack = slackDestination(settings);
38086
+ printCommandEnvelope(
38087
+ {
38088
+ settings,
38089
+ render: {
38090
+ sections: [
38091
+ {
38092
+ title: "Slack destination",
38093
+ lines: slack ? [
38094
+ `status: ${String(slack.status ?? "unknown")}`,
38095
+ `channel: #${String(slack.channelName ?? slack.channelId ?? "unknown")}`,
38096
+ ...slack.lastErrorMessage ? [`issue: ${String(slack.lastErrorMessage)}`] : []
38097
+ ] : ["Not configured."]
38098
+ },
38099
+ { title: "subscriptions", lines: eventLines(settings) },
38100
+ {
38101
+ title: "dead letter queue",
38102
+ lines: [
38103
+ `${settings.dlq.count}${settings.dlq.capped ? "+" : ""} deliveries require review`
38104
+ ]
38105
+ }
38106
+ ],
38107
+ actions: slack ? [
38108
+ {
38109
+ label: "Validate Slack",
38110
+ command: "deepline settings notifications test slack"
38111
+ }
38112
+ ] : [
38113
+ {
38114
+ label: "Connect Slack",
38115
+ command: "deepline settings notifications connect slack --open"
38116
+ }
38117
+ ]
38118
+ }
38119
+ },
38120
+ { json: options.json }
38121
+ );
38122
+ }
38123
+ function registerSettingsCommands(program) {
38124
+ const settings = program.command("settings").description("Manage workspace product settings.");
38125
+ const notifications = settings.command("notifications").description(
38126
+ "Configure Deepline product notifications and delivery safety."
38127
+ ).addHelpText(
38128
+ "after",
38129
+ `
38130
+ Workflow:
38131
+ 1. deepline settings notifications connect slack --open
38132
+ 2. deepline settings notifications channels --query pipeline
38133
+ 3. deepline settings notifications set slack --channel '#pipeline-alerts'
38134
+ 4. deepline settings notifications test slack
38135
+ 5. deepline settings notifications subscriptions list
38136
+
38137
+ Slack is the delivery integration. This command group only manages product
38138
+ notifications; there is no general integrations CLI.
38139
+ `
38140
+ );
38141
+ notifications.command("get").description("Show destination, subscriptions, and DLQ health.").option("--json", "Emit JSON output").action(printSettings);
38142
+ 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(
38143
+ async (destination, options) => {
38144
+ if (destination !== "slack")
38145
+ throw new Error("Only slack is supported.");
38146
+ if (options.dryRun) {
38147
+ printCommandEnvelope(
38148
+ { dryRun: true, destination, action: "start_oauth" },
38149
+ { json: options.json }
38150
+ );
38151
+ return;
38152
+ }
38153
+ const result = await new DeeplineClient().connectNotificationSlack();
38154
+ const browser = options.open ? openInBrowser(result.redirect_url, { deduplicate: false }) : "not_requested";
38155
+ printCommandEnvelope(
38156
+ {
38157
+ ...result,
38158
+ browser,
38159
+ render: {
38160
+ sections: [
38161
+ {
38162
+ title: "Slack authorization",
38163
+ lines: [result.redirect_url, `browser: ${browser}`]
38164
+ }
38165
+ ],
38166
+ actions: [
38167
+ {
38168
+ label: "After authorization",
38169
+ command: "deepline settings notifications set slack --channel '#channel'"
38170
+ }
38171
+ ]
38172
+ }
38173
+ },
38174
+ { json: options.json }
38175
+ );
38176
+ }
38177
+ );
38178
+ 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) => {
38179
+ const result = await new DeeplineClient().listNotificationSlackChannels(
38180
+ options.query
38181
+ );
38182
+ printCommandEnvelope(
38183
+ {
38184
+ ...result,
38185
+ render: {
38186
+ sections: [
38187
+ {
38188
+ title: "Slack channels",
38189
+ lines: result.channels.length ? result.channels.map(
38190
+ (channel) => `#${channel.name} (${channel.id})${channel.isPrivate ? " private" : ""}`
38191
+ ) : ["No visible channels matched."]
38192
+ }
38193
+ ]
38194
+ }
38195
+ },
38196
+ { json: options.json }
38197
+ );
38198
+ });
38199
+ 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(
38200
+ async (destination, options) => {
38201
+ if (destination !== "slack")
38202
+ throw new Error("Only slack is supported.");
38203
+ if (options.dryRun) {
38204
+ printCommandEnvelope(
38205
+ { dryRun: true, destination, channel: options.channel },
38206
+ { json: options.json }
38207
+ );
38208
+ return;
38209
+ }
38210
+ const result = await new DeeplineClient().setNotificationSlack(
38211
+ options.channel
38212
+ );
38213
+ printCommandEnvelope(
38214
+ {
38215
+ ok: true,
38216
+ result,
38217
+ render: {
38218
+ sections: [
38219
+ { title: "Slack destination saved", lines: [options.channel] }
38220
+ ],
38221
+ actions: [
38222
+ {
38223
+ label: "Validate delivery",
38224
+ command: "deepline settings notifications test slack"
38225
+ }
38226
+ ]
38227
+ }
38228
+ },
38229
+ { json: options.json }
38230
+ );
38231
+ }
38232
+ );
38233
+ 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) => {
38234
+ if (destination !== "slack") throw new Error("Only slack is supported.");
38235
+ if (options.dryRun) {
38236
+ printCommandEnvelope(
38237
+ { dryRun: true, destination, action: "send_test_ping" },
38238
+ { json: options.json }
38239
+ );
38240
+ return;
38241
+ }
38242
+ const result = await new DeeplineClient().testNotificationSlack();
38243
+ printCommandEnvelope(
38244
+ {
38245
+ ...result,
38246
+ render: {
38247
+ sections: [{ title: "Slack validation", lines: [result.message] }]
38248
+ }
38249
+ },
38250
+ { json: options.json }
38251
+ );
38252
+ });
38253
+ 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) => {
38254
+ if (destination !== "slack") throw new Error("Only slack is supported.");
38255
+ if (options.dryRun) {
38256
+ printCommandEnvelope(
38257
+ { dryRun: true, destination, action: "disable" },
38258
+ { json: options.json }
38259
+ );
38260
+ return;
38261
+ }
38262
+ const result = await new DeeplineClient().disableNotificationSlack();
38263
+ printCommandEnvelope(
38264
+ {
38265
+ ok: true,
38266
+ result,
38267
+ render: {
38268
+ sections: [{ title: "Slack destination", lines: ["disabled"] }]
38269
+ }
38270
+ },
38271
+ { json: options.json }
38272
+ );
38273
+ });
38274
+ const subscriptions = notifications.command("subscriptions").description("List and configure supported notification events.").addHelpText(
38275
+ "after",
38276
+ `
38277
+ Supported events (shared product catalog):
38278
+ ${eventHelp}
38279
+ `
38280
+ );
38281
+ subscriptions.command("list").description("List every supported event and its current state.").option("--json", "Emit JSON output").action(async (options) => {
38282
+ const current = await new DeeplineClient().getNotificationSettings();
38283
+ printCommandEnvelope(
38284
+ {
38285
+ catalog: current.catalog,
38286
+ subscriptions: current.subscriptions,
38287
+ render: {
38288
+ sections: [{ title: "subscriptions", lines: eventLines(current) }]
38289
+ }
38290
+ },
38291
+ { json: options.json }
38292
+ );
38293
+ });
38294
+ 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) => {
38295
+ const current = await new DeeplineClient().getNotificationSettings();
38296
+ const event = requireCatalogEvent(current, eventType);
38297
+ const subscription = current.subscriptions.find(
38298
+ (entry) => entry.eventType === event.id
38299
+ );
38300
+ printCommandEnvelope(
38301
+ {
38302
+ event,
38303
+ enabled: subscription?.enabled === true,
38304
+ render: {
38305
+ sections: [
38306
+ {
38307
+ title: event.id,
38308
+ lines: [
38309
+ event.description,
38310
+ `enabled: ${subscription?.enabled === true}`
38311
+ ]
38312
+ }
38313
+ ]
38314
+ }
38315
+ },
38316
+ { json: options.json }
38317
+ );
38318
+ });
38319
+ for (const enabled of [true, false]) {
38320
+ 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) => {
38321
+ const client2 = new DeeplineClient();
38322
+ const current = await client2.getNotificationSettings();
38323
+ const event = requireCatalogEvent(current, eventType);
38324
+ if (options.dryRun) {
38325
+ printCommandEnvelope(
38326
+ { dryRun: true, event, enabled },
38327
+ { json: options.json }
38328
+ );
38329
+ return;
38330
+ }
38331
+ const result = await client2.setNotificationSubscriptions(
38332
+ [event.id],
38333
+ enabled
38334
+ );
38335
+ printCommandEnvelope(
38336
+ {
38337
+ ok: true,
38338
+ event: event.id,
38339
+ enabled,
38340
+ result,
38341
+ render: {
38342
+ sections: [
38343
+ {
38344
+ title: "subscription updated",
38345
+ lines: [`${event.id}: ${enabled ? "enabled" : "disabled"}`]
38346
+ }
38347
+ ]
38348
+ }
38349
+ },
38350
+ { json: options.json }
38351
+ );
38352
+ });
38353
+ }
38354
+ const dlq = notifications.command("dlq").description("Inspect and explicitly resolve inert failed deliveries.");
38355
+ dlq.command("list").option("--limit <count>", "Maximum deliveries", "25").option("--json", "Emit JSON output").action(async (options) => {
38356
+ const result = await new DeeplineClient().listNotificationDlq(
38357
+ Number(options.limit)
38358
+ );
38359
+ const deliveries = result.deliveries ?? [];
38360
+ printCommandEnvelope(
38361
+ {
38362
+ ...result,
38363
+ render: {
38364
+ sections: [
38365
+ {
38366
+ title: "dead letter queue",
38367
+ lines: deliveries.length ? deliveries.map(
38368
+ (entry) => `${String(entry._id)}: ${String(entry.lastErrorCode ?? "delivery_failed")}`
38369
+ ) : ["empty"]
38370
+ }
38371
+ ]
38372
+ }
38373
+ },
38374
+ { json: options.json }
38375
+ );
38376
+ });
38377
+ dlq.command("get").argument("<delivery-id>").option("--json", "Emit JSON output").action(async (deliveryId, options) => {
38378
+ const result = await new DeeplineClient().getNotificationDlqDelivery(
38379
+ deliveryId
38380
+ );
38381
+ printCommandEnvelope(result, {
38382
+ json: options.json
38383
+ });
38384
+ });
38385
+ for (const action of ["retry", "archive"]) {
38386
+ dlq.command(action).description(
38387
+ `${action === "retry" ? "Replay once from attempt zero" : "Archive"} one delivery.`
38388
+ ).argument("<delivery-id>").option("--dry-run", "Describe the mutation without changing state").option("--json", "Emit JSON output").action(async (deliveryId, options) => {
38389
+ if (options.dryRun) {
38390
+ printCommandEnvelope(
38391
+ { dryRun: true, action, deliveryId },
38392
+ { json: options.json }
38393
+ );
38394
+ return;
38395
+ }
38396
+ const result = await new DeeplineClient().updateNotificationDlqDelivery(
38397
+ deliveryId,
38398
+ action
38399
+ );
38400
+ printCommandEnvelope(
38401
+ { ok: true, action, deliveryId, result },
38402
+ { json: options.json }
38403
+ );
38404
+ });
38405
+ }
38406
+ }
38407
+ function notificationByName(settings, reference) {
38408
+ const notification = (settings.notifications ?? []).find(
38409
+ (entry) => entry.id === reference || entry.name === reference
38410
+ );
38411
+ if (!notification) {
38412
+ throw new Error(
38413
+ `No notification named "${reference}". Run deepline notifications list.`
38414
+ );
38415
+ }
38416
+ return notification;
38417
+ }
38418
+ function parseSlackTarget(value) {
38419
+ const match = /^slack:(.+)$/i.exec(value.trim());
38420
+ if (!match?.[1]) {
38421
+ throw new Error("Use --to slack:#channel.");
38422
+ }
38423
+ return match[1];
38424
+ }
38425
+ function collectEvent(value, previous = []) {
38426
+ return [...previous, value];
38427
+ }
38428
+ function registerNotificationCommands(program) {
38429
+ const notifications = program.command("notifications").description("Choose which Play outcomes notify which people and channels.").addHelpText(
38430
+ "after",
38431
+ `
38432
+ Examples:
38433
+ deepline notifications events
38434
+ deepline notifications slack channels --search pipeline
38435
+ deepline notifications add pipeline-watchdog --to slack:#pipeline-alerts --for play.cron.failed
38436
+ deepline notifications test pipeline-watchdog
38437
+
38438
+ Slack connections are managed in Dashboard \u2192 Integrations. This command only
38439
+ chooses the connected Slack channel and the events it receives.
38440
+ `
38441
+ );
38442
+ notifications.command("events").description("List the Play events available to a notification.").option("--json", "Emit JSON output").action(async (options) => {
38443
+ const settings = await new DeeplineClient().getNotifications();
38444
+ printCommandEnvelope(
38445
+ {
38446
+ events: settings.catalog,
38447
+ render: {
38448
+ sections: [
38449
+ {
38450
+ title: "available events",
38451
+ lines: settings.catalog.length ? settings.catalog.map(
38452
+ (event) => `${event.id}: ${event.description}`
38453
+ ) : ["No notification events are available."]
38454
+ }
38455
+ ]
38456
+ }
38457
+ },
38458
+ { json: options.json }
38459
+ );
38460
+ });
38461
+ 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) => {
38462
+ const settings = await new DeeplineClient().getNotifications();
38463
+ const rules = settings.notifications ?? [];
38464
+ printCommandEnvelope(
38465
+ {
38466
+ notifications: options.compact ? rules.map((rule) => ({
38467
+ id: rule.id,
38468
+ name: rule.name,
38469
+ enabled: rule.enabled,
38470
+ target: `#${rule.target.name}`,
38471
+ eventTypes: rule.eventTypes
38472
+ })) : rules,
38473
+ count: rules.length,
38474
+ render: {
38475
+ sections: [
38476
+ {
38477
+ title: "notifications",
38478
+ lines: rules.length ? rules.map(
38479
+ (rule) => `${rule.name}: ${rule.enabled ? "on" : "paused"} \u2192 #${rule.target.name} (${rule.eventTypes.join(", ") || "no events"})`
38480
+ ) : [
38481
+ "None yet. Add one with deepline notifications add <name> --to slack:#channel --for play.cron.failed."
38482
+ ]
38483
+ }
38484
+ ]
38485
+ }
38486
+ },
38487
+ { json: options.json }
38488
+ );
38489
+ });
38490
+ notifications.command("get").argument("<name>", "Notification name or ID").description("Show one named notification.").option("--json", "Emit JSON output").action(async (name, options) => {
38491
+ const rule = notificationByName(
38492
+ await new DeeplineClient().getNotifications(),
38493
+ name
38494
+ );
38495
+ printCommandEnvelope({ notification: rule }, { json: options.json });
38496
+ });
38497
+ notifications.command("add").argument("<name>", "Short stable name, for example pipeline-watchdog").requiredOption(
38498
+ "--to <target>",
38499
+ "Target, for example slack:#pipeline-alerts"
38500
+ ).option(
38501
+ "--for <event>",
38502
+ "Event ID; repeat for more events. Run notifications events to list them",
38503
+ collectEvent,
38504
+ []
38505
+ ).option("--dry-run", "Describe the notification without saving it").option("--json", "Emit JSON output").action(
38506
+ async (name, options) => {
38507
+ if (!options.for.length) {
38508
+ throw new Error("Choose at least one event with --for <event>.");
38509
+ }
38510
+ const channel = parseSlackTarget(options.to);
38511
+ if (options.dryRun) {
38512
+ printCommandEnvelope(
38513
+ { dryRun: true, name, target: options.to, eventTypes: options.for },
38514
+ { json: options.json }
38515
+ );
38516
+ return;
38517
+ }
38518
+ const result = await new DeeplineClient().createNotification({
38519
+ name,
38520
+ provider: "slack",
38521
+ channel,
38522
+ eventTypes: options.for
38523
+ });
38524
+ printCommandEnvelope(
38525
+ {
38526
+ notification: result,
38527
+ render: {
38528
+ sections: [{ title: "notification saved", lines: [name] }],
38529
+ actions: [
38530
+ {
38531
+ label: "Send a test",
38532
+ command: `deepline notifications test ${name}`
38533
+ }
38534
+ ]
38535
+ }
38536
+ },
38537
+ { json: options.json }
38538
+ );
38539
+ }
38540
+ );
38541
+ notifications.command("edit").argument("<name>", "Notification name or ID").option("--to <target>", "New target, for example slack:#pipeline-alerts").option(
38542
+ "--for <event>",
38543
+ "Replace selected events; repeat for more events. Run notifications events to list them",
38544
+ collectEvent,
38545
+ []
38546
+ ).option("--dry-run", "Describe the change without saving it").option("--json", "Emit JSON output").action(
38547
+ async (name, options) => {
38548
+ const client2 = new DeeplineClient();
38549
+ const rule = notificationByName(await client2.getNotifications(), name);
38550
+ const channel = options.to ? parseSlackTarget(options.to) : rule.target.name;
38551
+ const eventTypes = options.for.length ? options.for : rule.eventTypes;
38552
+ if (options.dryRun) {
38553
+ printCommandEnvelope(
38554
+ { dryRun: true, notification: rule.id, channel, eventTypes },
38555
+ { json: options.json }
38556
+ );
38557
+ return;
38558
+ }
38559
+ const result = await client2.updateNotification(rule.id, {
38560
+ name: rule.name,
38561
+ channel,
38562
+ eventTypes
38563
+ });
38564
+ printCommandEnvelope({ notification: result }, { json: options.json });
38565
+ }
38566
+ );
38567
+ const slack = notifications.command("slack").description("Select a channel from the connected Slack integration.");
38568
+ slack.command("channels").option("--search <text>", "Filter channel names").option("--json", "Emit JSON output").action(async (options) => {
38569
+ const result = await new DeeplineClient().listNotificationChannels(
38570
+ options.search
38571
+ );
38572
+ printCommandEnvelope(
38573
+ {
38574
+ ...result,
38575
+ render: {
38576
+ sections: [
38577
+ {
38578
+ title: "Slack channels",
38579
+ lines: result.channels.length ? result.channels.map((channel) => `#${channel.name}`) : ["No visible channels matched."]
38580
+ }
38581
+ ]
38582
+ }
38583
+ },
38584
+ { json: options.json }
38585
+ );
38586
+ });
38587
+ for (const [command, enabled] of [
38588
+ ["pause", false],
38589
+ ["resume", true]
38590
+ ]) {
38591
+ 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) => {
38592
+ const client2 = new DeeplineClient();
38593
+ const rule = notificationByName(await client2.getNotifications(), name);
38594
+ if (options.dryRun) {
38595
+ printCommandEnvelope(
38596
+ { dryRun: true, notification: rule.id, enabled },
38597
+ { json: options.json }
38598
+ );
38599
+ return;
38600
+ }
38601
+ const result = await client2.updateNotification(rule.id, { enabled });
38602
+ printCommandEnvelope({ notification: result }, { json: options.json });
38603
+ });
38604
+ }
38605
+ 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) => {
38606
+ const client2 = new DeeplineClient();
38607
+ const rule = notificationByName(await client2.getNotifications(), name);
38608
+ if (options.dryRun) {
38609
+ printCommandEnvelope(
38610
+ { dryRun: true, notification: rule.id, action: "send_test" },
38611
+ { json: options.json }
38612
+ );
38613
+ return;
38614
+ }
38615
+ const result = await client2.testNotification(rule.id);
38616
+ printCommandEnvelope(
38617
+ { ...result, notification: rule.name },
38618
+ { json: options.json }
38619
+ );
38620
+ });
38621
+ notifications.command("delete").argument("<name>", "Notification name or ID").description(
38622
+ "Archive one notification without touching its provider integration."
38623
+ ).option("--dry-run", "Describe the deletion without changing state").option("--json", "Emit JSON output").action(async (name, options) => {
38624
+ const client2 = new DeeplineClient();
38625
+ const rule = notificationByName(await client2.getNotifications(), name);
38626
+ if (options.dryRun) {
38627
+ printCommandEnvelope(
38628
+ { dryRun: true, notification: rule.id, action: "archive" },
38629
+ { json: options.json }
38630
+ );
38631
+ return;
38632
+ }
38633
+ const result = await client2.deleteNotification(rule.id);
38634
+ printCommandEnvelope(
38635
+ { ...result, notification: rule.name },
38636
+ { json: options.json }
38637
+ );
38638
+ });
38639
+ }
38640
+
37897
38641
  // ../shared_libs/cli/command-compatibility.json
37898
38642
  var command_compatibility_default = {
37899
38643
  enrich: {
@@ -39030,6 +39774,8 @@ Exit codes:
39030
39774
  registerSessionsCommands(program);
39031
39775
  registerWorkflowCommands(program);
39032
39776
  registerSecretsCommands(program);
39777
+ registerSettingsCommands(program);
39778
+ registerNotificationCommands(program);
39033
39779
  registerBillingCommands(program);
39034
39780
  registerMonitorsCommands(program);
39035
39781
  registerOrgCommands(program);