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.
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.41",
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;
@@ -3214,6 +3272,7 @@ async function* observeRunEvents(options) {
3214
3272
  // ../shared_libs/integrations/theirstack-execution-policy.ts
3215
3273
  var THEIRSTACK_SLOW_JOB_SEARCH_PROVIDER_TIMEOUT_MS = 135e3;
3216
3274
  var THEIRSTACK_SLOW_JOB_SEARCH_CLIENT_TIMEOUT_MS = 6e4 + THEIRSTACK_SLOW_JOB_SEARCH_PROVIDER_TIMEOUT_MS + 15e3;
3275
+ var THEIRSTACK_COMPANY_SEARCH_CLIENT_TIMEOUT_MS = 21e4;
3217
3276
  var LONG_JOB_SEARCH_WINDOW_MS = 365 * 24 * 60 * 60 * 1e3;
3218
3277
  var DATE_ONLY_PATTERN = /^\d{4}-\d{2}-\d{2}$/;
3219
3278
  function parseDateOnly(value) {
@@ -3257,6 +3316,12 @@ function usesExtendedTheirstackJobSearchBudget(endpointId, payload) {
3257
3316
  const maxAgeDays = parseMaxAgeDays(payload.posted_at_max_age_days);
3258
3317
  return maxAgeDays !== null && maxAgeDays >= 365 ? true : usesLongExplicitDateWindow(payload);
3259
3318
  }
3319
+ function resolveTheirstackClientTimeoutMs(endpointId, payload) {
3320
+ if (endpointId === "theirstack_company_search") {
3321
+ return THEIRSTACK_COMPANY_SEARCH_CLIENT_TIMEOUT_MS;
3322
+ }
3323
+ return usesExtendedTheirstackJobSearchBudget(endpointId, payload) ? THEIRSTACK_SLOW_JOB_SEARCH_CLIENT_TIMEOUT_MS : null;
3324
+ }
3260
3325
 
3261
3326
  // ../shared_libs/play-runtime/backend.ts
3262
3327
  var PLAY_RUNTIME_BACKENDS = {
@@ -3503,9 +3568,11 @@ function resolveToolExecuteTimeoutMs(toolId, input2) {
3503
3568
  return Math.floor(requestedTimeoutMs) + APIFY_SYNC_RESPONSE_GRACE_MS;
3504
3569
  }
3505
3570
  }
3506
- if (usesExtendedTheirstackJobSearchBudget(normalized, input2)) {
3507
- return THEIRSTACK_SLOW_JOB_SEARCH_CLIENT_TIMEOUT_MS;
3508
- }
3571
+ const theirstackTimeoutMs = resolveTheirstackClientTimeoutMs(
3572
+ normalized,
3573
+ input2
3574
+ );
3575
+ if (theirstackTimeoutMs !== null) return theirstackTimeoutMs;
3509
3576
  return normalized === "deeplineagent" || normalized === "deeplineagent_deeplineagent" || normalized === "ai_inference" || normalized === "deeplineagent_ai_inference" || normalized === "aiinference" ? DEEPLINEAGENT_EXECUTE_TIMEOUT_MS : void 0;
3510
3577
  }
3511
3578
  var RUNS_FAILED_LOG_LIMIT = 20;
@@ -5378,6 +5445,95 @@ var DeeplineClient = class {
5378
5445
  );
5379
5446
  return response.plays ?? [];
5380
5447
  }
5448
+ /** Read product-notification destinations, subscriptions, event catalog, and DLQ health. */
5449
+ async getNotificationSettings() {
5450
+ return this.http.get("/api/v2/settings/notifications");
5451
+ }
5452
+ /** Start the Slack OAuth flow required by product notifications. */
5453
+ async connectNotificationSlack(options) {
5454
+ return this.http.post("/api/v2/integrations/connect", {
5455
+ provider: "slack",
5456
+ scopes: [...PRODUCT_NOTIFICATION_SLACK_OAUTH_SCOPES],
5457
+ ...options?.successUrl ? { success_url: options.successUrl } : {},
5458
+ ...options?.failureUrl ? { failure_url: options.failureUrl } : {}
5459
+ });
5460
+ }
5461
+ /** List Slack channels visible to the connected Deepline Slack app. */
5462
+ async listNotificationSlackChannels(query) {
5463
+ const suffix = query ? `?query=${encodeURIComponent(query)}` : "";
5464
+ return this.http.get(`/api/v2/settings/notifications/channels${suffix}`);
5465
+ }
5466
+ /** Select the Slack channel used for product notifications. */
5467
+ async setNotificationSlack(channel) {
5468
+ return this.http.put("/api/v2/settings/notifications", { channel });
5469
+ }
5470
+ /** Send one synchronous test ping and return Slack's delivery result. */
5471
+ async testNotificationSlack() {
5472
+ return this.http.post("/api/v2/settings/notifications/test", {});
5473
+ }
5474
+ /** Disable Slack product notifications without deleting the OAuth connection. */
5475
+ async disableNotificationSlack() {
5476
+ return this.http.delete("/api/v2/settings/notifications");
5477
+ }
5478
+ /** Enable or disable event IDs from the server-provided notification catalog. */
5479
+ async setNotificationSubscriptions(eventTypes, enabled) {
5480
+ return this.http.patch("/api/v2/settings/notifications/subscriptions", {
5481
+ eventTypes,
5482
+ enabled
5483
+ });
5484
+ }
5485
+ /** List exhausted deliveries. Dead-lettered messages never replay automatically. */
5486
+ async listNotificationDlq(limit = 25) {
5487
+ return this.http.get(
5488
+ `/api/v2/settings/notifications/dlq?limit=${encodeURIComponent(String(limit))}`
5489
+ );
5490
+ }
5491
+ /** Inspect one exhausted notification delivery. */
5492
+ async getNotificationDlqDelivery(deliveryId) {
5493
+ return this.http.get(
5494
+ `/api/v2/settings/notifications/dlq/${encodeURIComponent(deliveryId)}`
5495
+ );
5496
+ }
5497
+ /** Explicitly retry or archive one dead-lettered notification delivery. */
5498
+ async updateNotificationDlqDelivery(deliveryId, action) {
5499
+ return this.http.post(
5500
+ `/api/v2/settings/notifications/dlq/${encodeURIComponent(deliveryId)}`,
5501
+ { action }
5502
+ );
5503
+ }
5504
+ /** List the workspace's named notification rules. */
5505
+ async getNotifications() {
5506
+ return this.http.get("/api/v2/notifications");
5507
+ }
5508
+ /** List Slack channels available to an already-connected Slack integration. */
5509
+ async listNotificationChannels(query) {
5510
+ const suffix = query ? `?search=${encodeURIComponent(query)}` : "";
5511
+ return this.http.get(`/api/v2/notifications/slack/channels${suffix}`);
5512
+ }
5513
+ /** Create a named notification routed through an existing provider integration. */
5514
+ async createNotification(input2) {
5515
+ return this.http.post("/api/v2/notifications", input2);
5516
+ }
5517
+ /** Update a notification's target, event selection, or enabled state. */
5518
+ async updateNotification(notificationId, input2) {
5519
+ return this.http.patch(
5520
+ `/api/v2/notifications/${encodeURIComponent(notificationId)}`,
5521
+ input2
5522
+ );
5523
+ }
5524
+ /** Send a validation ping to one notification. */
5525
+ async testNotification(notificationId) {
5526
+ return this.http.post(
5527
+ `/api/v2/notifications/${encodeURIComponent(notificationId)}/test`,
5528
+ {}
5529
+ );
5530
+ }
5531
+ /** Archive one notification without touching its provider integration. */
5532
+ async deleteNotification(notificationId) {
5533
+ return this.http.delete(
5534
+ `/api/v2/notifications/${encodeURIComponent(notificationId)}`
5535
+ );
5536
+ }
5381
5537
  /**
5382
5538
  * Search callable plays and return compact play descriptions.
5383
5539
  *
@@ -22743,6 +22899,20 @@ async function handlePlayList(args) {
22743
22899
  if (play.inputSchema || play.hasInputSchema) {
22744
22900
  process.stdout.write(" inputSchema: yes\n");
22745
22901
  }
22902
+ const configuredTriggers = [
22903
+ play.triggerStatus?.cron ? `cron=${play.triggerStatus.cron}` : null,
22904
+ play.triggerStatus?.webhook ? `webhook=${play.triggerStatus.webhook}` : null
22905
+ ].filter(Boolean);
22906
+ if (configuredTriggers.length > 0) {
22907
+ process.stdout.write(` triggers: ${configuredTriggers.join(", ")}
22908
+ `);
22909
+ if (play.triggerStatus?.blockedReason) {
22910
+ process.stdout.write(
22911
+ ` trigger issue: ${play.triggerStatus.blockedReason}
22912
+ `
22913
+ );
22914
+ }
22915
+ }
22746
22916
  process.stdout.write(` run: deepline plays run ${reference} --watch
22747
22917
  `);
22748
22918
  }
@@ -36037,6 +36207,7 @@ var SDK_SIDECAR_CRITICAL_PACKAGE_FILES = [
36037
36207
  "dist/bundling-sources/shared_libs/observability/telemetry.ts",
36038
36208
  "dist/bundling-sources/shared_libs/play-runtime/backend.ts",
36039
36209
  "dist/bundling-sources/shared_libs/plays/bundling/index.ts",
36210
+ "dist/bundling-sources/shared_libs/product-notifications/contract.ts",
36040
36211
  "dist/bundling-sources/shared_libs/tool-execution-error.ts"
36041
36212
  ];
36042
36213
  var SDK_SIDECAR_CRITICAL_DEPENDENCY_FILES = [
@@ -37894,6 +38065,588 @@ Examples:
37894
38065
  });
37895
38066
  }
37896
38067
 
38068
+ // src/cli/commands/settings.ts
38069
+ var eventHelp = PRODUCT_NOTIFICATION_EVENT_CATALOG.map(
38070
+ (event) => ` ${event.id.padEnd(28)} ${event.description}`
38071
+ ).join("\n");
38072
+ function slackDestination(settings) {
38073
+ return settings.destinations.find((entry) => entry.kind === "slack");
38074
+ }
38075
+ function eventLines(settings) {
38076
+ const enabled = new Map(
38077
+ settings.subscriptions.map((entry) => [entry.eventType, entry.enabled])
38078
+ );
38079
+ return settings.catalog.map(
38080
+ (event) => `${event.id}: ${enabled.get(event.id) === true ? "enabled" : "disabled"} \u2014 ${event.description}`
38081
+ );
38082
+ }
38083
+ function requireCatalogEvent(settings, eventType) {
38084
+ const event = settings.catalog.find((entry) => entry.id === eventType);
38085
+ if (!event) {
38086
+ throw new Error(
38087
+ `Unknown notification event "${eventType}". Run deepline settings notifications subscriptions list.`
38088
+ );
38089
+ }
38090
+ return event;
38091
+ }
38092
+ async function printSettings(options) {
38093
+ const settings = await new DeeplineClient().getNotificationSettings();
38094
+ const slack = slackDestination(settings);
38095
+ printCommandEnvelope(
38096
+ {
38097
+ settings,
38098
+ render: {
38099
+ sections: [
38100
+ {
38101
+ title: "Slack destination",
38102
+ lines: slack ? [
38103
+ `status: ${String(slack.status ?? "unknown")}`,
38104
+ `channel: #${String(slack.channelName ?? slack.channelId ?? "unknown")}`,
38105
+ ...slack.lastErrorMessage ? [`issue: ${String(slack.lastErrorMessage)}`] : []
38106
+ ] : ["Not configured."]
38107
+ },
38108
+ { title: "subscriptions", lines: eventLines(settings) },
38109
+ {
38110
+ title: "dead letter queue",
38111
+ lines: [
38112
+ `${settings.dlq.count}${settings.dlq.capped ? "+" : ""} deliveries require review`
38113
+ ]
38114
+ }
38115
+ ],
38116
+ actions: slack ? [
38117
+ {
38118
+ label: "Validate Slack",
38119
+ command: "deepline settings notifications test slack"
38120
+ }
38121
+ ] : [
38122
+ {
38123
+ label: "Connect Slack",
38124
+ command: "deepline settings notifications connect slack --open"
38125
+ }
38126
+ ]
38127
+ }
38128
+ },
38129
+ { json: options.json }
38130
+ );
38131
+ }
38132
+ function registerSettingsCommands(program) {
38133
+ const settings = program.command("settings").description("Manage workspace product settings.");
38134
+ const notifications = settings.command("notifications").description(
38135
+ "Configure Deepline product notifications and delivery safety."
38136
+ ).addHelpText(
38137
+ "after",
38138
+ `
38139
+ Workflow:
38140
+ 1. deepline settings notifications connect slack --open
38141
+ 2. deepline settings notifications channels --query pipeline
38142
+ 3. deepline settings notifications set slack --channel '#pipeline-alerts'
38143
+ 4. deepline settings notifications test slack
38144
+ 5. deepline settings notifications subscriptions list
38145
+
38146
+ Slack is the delivery integration. This command group only manages product
38147
+ notifications; there is no general integrations CLI.
38148
+ `
38149
+ );
38150
+ notifications.command("get").description("Show destination, subscriptions, and DLQ health.").option("--json", "Emit JSON output").action(printSettings);
38151
+ 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(
38152
+ async (destination, options) => {
38153
+ if (destination !== "slack")
38154
+ throw new Error("Only slack is supported.");
38155
+ if (options.dryRun) {
38156
+ printCommandEnvelope(
38157
+ { dryRun: true, destination, action: "start_oauth" },
38158
+ { json: options.json }
38159
+ );
38160
+ return;
38161
+ }
38162
+ const result = await new DeeplineClient().connectNotificationSlack();
38163
+ const browser = options.open ? openInBrowser(result.redirect_url, { deduplicate: false }) : "not_requested";
38164
+ printCommandEnvelope(
38165
+ {
38166
+ ...result,
38167
+ browser,
38168
+ render: {
38169
+ sections: [
38170
+ {
38171
+ title: "Slack authorization",
38172
+ lines: [result.redirect_url, `browser: ${browser}`]
38173
+ }
38174
+ ],
38175
+ actions: [
38176
+ {
38177
+ label: "After authorization",
38178
+ command: "deepline settings notifications set slack --channel '#channel'"
38179
+ }
38180
+ ]
38181
+ }
38182
+ },
38183
+ { json: options.json }
38184
+ );
38185
+ }
38186
+ );
38187
+ 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) => {
38188
+ const result = await new DeeplineClient().listNotificationSlackChannels(
38189
+ options.query
38190
+ );
38191
+ printCommandEnvelope(
38192
+ {
38193
+ ...result,
38194
+ render: {
38195
+ sections: [
38196
+ {
38197
+ title: "Slack channels",
38198
+ lines: result.channels.length ? result.channels.map(
38199
+ (channel) => `#${channel.name} (${channel.id})${channel.isPrivate ? " private" : ""}`
38200
+ ) : ["No visible channels matched."]
38201
+ }
38202
+ ]
38203
+ }
38204
+ },
38205
+ { json: options.json }
38206
+ );
38207
+ });
38208
+ 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(
38209
+ async (destination, options) => {
38210
+ if (destination !== "slack")
38211
+ throw new Error("Only slack is supported.");
38212
+ if (options.dryRun) {
38213
+ printCommandEnvelope(
38214
+ { dryRun: true, destination, channel: options.channel },
38215
+ { json: options.json }
38216
+ );
38217
+ return;
38218
+ }
38219
+ const result = await new DeeplineClient().setNotificationSlack(
38220
+ options.channel
38221
+ );
38222
+ printCommandEnvelope(
38223
+ {
38224
+ ok: true,
38225
+ result,
38226
+ render: {
38227
+ sections: [
38228
+ { title: "Slack destination saved", lines: [options.channel] }
38229
+ ],
38230
+ actions: [
38231
+ {
38232
+ label: "Validate delivery",
38233
+ command: "deepline settings notifications test slack"
38234
+ }
38235
+ ]
38236
+ }
38237
+ },
38238
+ { json: options.json }
38239
+ );
38240
+ }
38241
+ );
38242
+ 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) => {
38243
+ if (destination !== "slack") throw new Error("Only slack is supported.");
38244
+ if (options.dryRun) {
38245
+ printCommandEnvelope(
38246
+ { dryRun: true, destination, action: "send_test_ping" },
38247
+ { json: options.json }
38248
+ );
38249
+ return;
38250
+ }
38251
+ const result = await new DeeplineClient().testNotificationSlack();
38252
+ printCommandEnvelope(
38253
+ {
38254
+ ...result,
38255
+ render: {
38256
+ sections: [{ title: "Slack validation", lines: [result.message] }]
38257
+ }
38258
+ },
38259
+ { json: options.json }
38260
+ );
38261
+ });
38262
+ 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) => {
38263
+ if (destination !== "slack") throw new Error("Only slack is supported.");
38264
+ if (options.dryRun) {
38265
+ printCommandEnvelope(
38266
+ { dryRun: true, destination, action: "disable" },
38267
+ { json: options.json }
38268
+ );
38269
+ return;
38270
+ }
38271
+ const result = await new DeeplineClient().disableNotificationSlack();
38272
+ printCommandEnvelope(
38273
+ {
38274
+ ok: true,
38275
+ result,
38276
+ render: {
38277
+ sections: [{ title: "Slack destination", lines: ["disabled"] }]
38278
+ }
38279
+ },
38280
+ { json: options.json }
38281
+ );
38282
+ });
38283
+ const subscriptions = notifications.command("subscriptions").description("List and configure supported notification events.").addHelpText(
38284
+ "after",
38285
+ `
38286
+ Supported events (shared product catalog):
38287
+ ${eventHelp}
38288
+ `
38289
+ );
38290
+ subscriptions.command("list").description("List every supported event and its current state.").option("--json", "Emit JSON output").action(async (options) => {
38291
+ const current = await new DeeplineClient().getNotificationSettings();
38292
+ printCommandEnvelope(
38293
+ {
38294
+ catalog: current.catalog,
38295
+ subscriptions: current.subscriptions,
38296
+ render: {
38297
+ sections: [{ title: "subscriptions", lines: eventLines(current) }]
38298
+ }
38299
+ },
38300
+ { json: options.json }
38301
+ );
38302
+ });
38303
+ 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) => {
38304
+ const current = await new DeeplineClient().getNotificationSettings();
38305
+ const event = requireCatalogEvent(current, eventType);
38306
+ const subscription = current.subscriptions.find(
38307
+ (entry) => entry.eventType === event.id
38308
+ );
38309
+ printCommandEnvelope(
38310
+ {
38311
+ event,
38312
+ enabled: subscription?.enabled === true,
38313
+ render: {
38314
+ sections: [
38315
+ {
38316
+ title: event.id,
38317
+ lines: [
38318
+ event.description,
38319
+ `enabled: ${subscription?.enabled === true}`
38320
+ ]
38321
+ }
38322
+ ]
38323
+ }
38324
+ },
38325
+ { json: options.json }
38326
+ );
38327
+ });
38328
+ for (const enabled of [true, false]) {
38329
+ 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) => {
38330
+ const client2 = new DeeplineClient();
38331
+ const current = await client2.getNotificationSettings();
38332
+ const event = requireCatalogEvent(current, eventType);
38333
+ if (options.dryRun) {
38334
+ printCommandEnvelope(
38335
+ { dryRun: true, event, enabled },
38336
+ { json: options.json }
38337
+ );
38338
+ return;
38339
+ }
38340
+ const result = await client2.setNotificationSubscriptions(
38341
+ [event.id],
38342
+ enabled
38343
+ );
38344
+ printCommandEnvelope(
38345
+ {
38346
+ ok: true,
38347
+ event: event.id,
38348
+ enabled,
38349
+ result,
38350
+ render: {
38351
+ sections: [
38352
+ {
38353
+ title: "subscription updated",
38354
+ lines: [`${event.id}: ${enabled ? "enabled" : "disabled"}`]
38355
+ }
38356
+ ]
38357
+ }
38358
+ },
38359
+ { json: options.json }
38360
+ );
38361
+ });
38362
+ }
38363
+ const dlq = notifications.command("dlq").description("Inspect and explicitly resolve inert failed deliveries.");
38364
+ dlq.command("list").option("--limit <count>", "Maximum deliveries", "25").option("--json", "Emit JSON output").action(async (options) => {
38365
+ const result = await new DeeplineClient().listNotificationDlq(
38366
+ Number(options.limit)
38367
+ );
38368
+ const deliveries = result.deliveries ?? [];
38369
+ printCommandEnvelope(
38370
+ {
38371
+ ...result,
38372
+ render: {
38373
+ sections: [
38374
+ {
38375
+ title: "dead letter queue",
38376
+ lines: deliveries.length ? deliveries.map(
38377
+ (entry) => `${String(entry._id)}: ${String(entry.lastErrorCode ?? "delivery_failed")}`
38378
+ ) : ["empty"]
38379
+ }
38380
+ ]
38381
+ }
38382
+ },
38383
+ { json: options.json }
38384
+ );
38385
+ });
38386
+ dlq.command("get").argument("<delivery-id>").option("--json", "Emit JSON output").action(async (deliveryId, options) => {
38387
+ const result = await new DeeplineClient().getNotificationDlqDelivery(
38388
+ deliveryId
38389
+ );
38390
+ printCommandEnvelope(result, {
38391
+ json: options.json
38392
+ });
38393
+ });
38394
+ for (const action of ["retry", "archive"]) {
38395
+ dlq.command(action).description(
38396
+ `${action === "retry" ? "Replay once from attempt zero" : "Archive"} one delivery.`
38397
+ ).argument("<delivery-id>").option("--dry-run", "Describe the mutation without changing state").option("--json", "Emit JSON output").action(async (deliveryId, options) => {
38398
+ if (options.dryRun) {
38399
+ printCommandEnvelope(
38400
+ { dryRun: true, action, deliveryId },
38401
+ { json: options.json }
38402
+ );
38403
+ return;
38404
+ }
38405
+ const result = await new DeeplineClient().updateNotificationDlqDelivery(
38406
+ deliveryId,
38407
+ action
38408
+ );
38409
+ printCommandEnvelope(
38410
+ { ok: true, action, deliveryId, result },
38411
+ { json: options.json }
38412
+ );
38413
+ });
38414
+ }
38415
+ }
38416
+ function notificationByName(settings, reference) {
38417
+ const notification = (settings.notifications ?? []).find(
38418
+ (entry) => entry.id === reference || entry.name === reference
38419
+ );
38420
+ if (!notification) {
38421
+ throw new Error(
38422
+ `No notification named "${reference}". Run deepline notifications list.`
38423
+ );
38424
+ }
38425
+ return notification;
38426
+ }
38427
+ function parseSlackTarget(value) {
38428
+ const match = /^slack:(.+)$/i.exec(value.trim());
38429
+ if (!match?.[1]) {
38430
+ throw new Error("Use --to slack:#channel.");
38431
+ }
38432
+ return match[1];
38433
+ }
38434
+ function collectEvent(value, previous = []) {
38435
+ return [...previous, value];
38436
+ }
38437
+ function registerNotificationCommands(program) {
38438
+ const notifications = program.command("notifications").description("Choose which Play outcomes notify which people and channels.").addHelpText(
38439
+ "after",
38440
+ `
38441
+ Examples:
38442
+ deepline notifications events
38443
+ deepline notifications slack channels --search pipeline
38444
+ deepline notifications add pipeline-watchdog --to slack:#pipeline-alerts --for play.cron.failed
38445
+ deepline notifications test pipeline-watchdog
38446
+
38447
+ Slack connections are managed in Dashboard \u2192 Integrations. This command only
38448
+ chooses the connected Slack channel and the events it receives.
38449
+ `
38450
+ );
38451
+ notifications.command("events").description("List the Play events available to a notification.").option("--json", "Emit JSON output").action(async (options) => {
38452
+ const settings = await new DeeplineClient().getNotifications();
38453
+ printCommandEnvelope(
38454
+ {
38455
+ events: settings.catalog,
38456
+ render: {
38457
+ sections: [
38458
+ {
38459
+ title: "available events",
38460
+ lines: settings.catalog.length ? settings.catalog.map(
38461
+ (event) => `${event.id}: ${event.description}`
38462
+ ) : ["No notification events are available."]
38463
+ }
38464
+ ]
38465
+ }
38466
+ },
38467
+ { json: options.json }
38468
+ );
38469
+ });
38470
+ 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) => {
38471
+ const settings = await new DeeplineClient().getNotifications();
38472
+ const rules = settings.notifications ?? [];
38473
+ printCommandEnvelope(
38474
+ {
38475
+ notifications: options.compact ? rules.map((rule) => ({
38476
+ id: rule.id,
38477
+ name: rule.name,
38478
+ enabled: rule.enabled,
38479
+ target: `#${rule.target.name}`,
38480
+ eventTypes: rule.eventTypes
38481
+ })) : rules,
38482
+ count: rules.length,
38483
+ render: {
38484
+ sections: [
38485
+ {
38486
+ title: "notifications",
38487
+ lines: rules.length ? rules.map(
38488
+ (rule) => `${rule.name}: ${rule.enabled ? "on" : "paused"} \u2192 #${rule.target.name} (${rule.eventTypes.join(", ") || "no events"})`
38489
+ ) : [
38490
+ "None yet. Add one with deepline notifications add <name> --to slack:#channel --for play.cron.failed."
38491
+ ]
38492
+ }
38493
+ ]
38494
+ }
38495
+ },
38496
+ { json: options.json }
38497
+ );
38498
+ });
38499
+ notifications.command("get").argument("<name>", "Notification name or ID").description("Show one named notification.").option("--json", "Emit JSON output").action(async (name, options) => {
38500
+ const rule = notificationByName(
38501
+ await new DeeplineClient().getNotifications(),
38502
+ name
38503
+ );
38504
+ printCommandEnvelope({ notification: rule }, { json: options.json });
38505
+ });
38506
+ notifications.command("add").argument("<name>", "Short stable name, for example pipeline-watchdog").requiredOption(
38507
+ "--to <target>",
38508
+ "Target, for example slack:#pipeline-alerts"
38509
+ ).option(
38510
+ "--for <event>",
38511
+ "Event ID; repeat for more events. Run notifications events to list them",
38512
+ collectEvent,
38513
+ []
38514
+ ).option("--dry-run", "Describe the notification without saving it").option("--json", "Emit JSON output").action(
38515
+ async (name, options) => {
38516
+ if (!options.for.length) {
38517
+ throw new Error("Choose at least one event with --for <event>.");
38518
+ }
38519
+ const channel = parseSlackTarget(options.to);
38520
+ if (options.dryRun) {
38521
+ printCommandEnvelope(
38522
+ { dryRun: true, name, target: options.to, eventTypes: options.for },
38523
+ { json: options.json }
38524
+ );
38525
+ return;
38526
+ }
38527
+ const result = await new DeeplineClient().createNotification({
38528
+ name,
38529
+ provider: "slack",
38530
+ channel,
38531
+ eventTypes: options.for
38532
+ });
38533
+ printCommandEnvelope(
38534
+ {
38535
+ notification: result,
38536
+ render: {
38537
+ sections: [{ title: "notification saved", lines: [name] }],
38538
+ actions: [
38539
+ {
38540
+ label: "Send a test",
38541
+ command: `deepline notifications test ${name}`
38542
+ }
38543
+ ]
38544
+ }
38545
+ },
38546
+ { json: options.json }
38547
+ );
38548
+ }
38549
+ );
38550
+ notifications.command("edit").argument("<name>", "Notification name or ID").option("--to <target>", "New target, for example slack:#pipeline-alerts").option(
38551
+ "--for <event>",
38552
+ "Replace selected events; repeat for more events. Run notifications events to list them",
38553
+ collectEvent,
38554
+ []
38555
+ ).option("--dry-run", "Describe the change without saving it").option("--json", "Emit JSON output").action(
38556
+ async (name, options) => {
38557
+ const client2 = new DeeplineClient();
38558
+ const rule = notificationByName(await client2.getNotifications(), name);
38559
+ const channel = options.to ? parseSlackTarget(options.to) : rule.target.name;
38560
+ const eventTypes = options.for.length ? options.for : rule.eventTypes;
38561
+ if (options.dryRun) {
38562
+ printCommandEnvelope(
38563
+ { dryRun: true, notification: rule.id, channel, eventTypes },
38564
+ { json: options.json }
38565
+ );
38566
+ return;
38567
+ }
38568
+ const result = await client2.updateNotification(rule.id, {
38569
+ name: rule.name,
38570
+ channel,
38571
+ eventTypes
38572
+ });
38573
+ printCommandEnvelope({ notification: result }, { json: options.json });
38574
+ }
38575
+ );
38576
+ const slack = notifications.command("slack").description("Select a channel from the connected Slack integration.");
38577
+ slack.command("channels").option("--search <text>", "Filter channel names").option("--json", "Emit JSON output").action(async (options) => {
38578
+ const result = await new DeeplineClient().listNotificationChannels(
38579
+ options.search
38580
+ );
38581
+ printCommandEnvelope(
38582
+ {
38583
+ ...result,
38584
+ render: {
38585
+ sections: [
38586
+ {
38587
+ title: "Slack channels",
38588
+ lines: result.channels.length ? result.channels.map((channel) => `#${channel.name}`) : ["No visible channels matched."]
38589
+ }
38590
+ ]
38591
+ }
38592
+ },
38593
+ { json: options.json }
38594
+ );
38595
+ });
38596
+ for (const [command, enabled] of [
38597
+ ["pause", false],
38598
+ ["resume", true]
38599
+ ]) {
38600
+ 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) => {
38601
+ const client2 = new DeeplineClient();
38602
+ const rule = notificationByName(await client2.getNotifications(), name);
38603
+ if (options.dryRun) {
38604
+ printCommandEnvelope(
38605
+ { dryRun: true, notification: rule.id, enabled },
38606
+ { json: options.json }
38607
+ );
38608
+ return;
38609
+ }
38610
+ const result = await client2.updateNotification(rule.id, { enabled });
38611
+ printCommandEnvelope({ notification: result }, { json: options.json });
38612
+ });
38613
+ }
38614
+ 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) => {
38615
+ const client2 = new DeeplineClient();
38616
+ const rule = notificationByName(await client2.getNotifications(), name);
38617
+ if (options.dryRun) {
38618
+ printCommandEnvelope(
38619
+ { dryRun: true, notification: rule.id, action: "send_test" },
38620
+ { json: options.json }
38621
+ );
38622
+ return;
38623
+ }
38624
+ const result = await client2.testNotification(rule.id);
38625
+ printCommandEnvelope(
38626
+ { ...result, notification: rule.name },
38627
+ { json: options.json }
38628
+ );
38629
+ });
38630
+ notifications.command("delete").argument("<name>", "Notification name or ID").description(
38631
+ "Archive one notification without touching its provider integration."
38632
+ ).option("--dry-run", "Describe the deletion without changing state").option("--json", "Emit JSON output").action(async (name, options) => {
38633
+ const client2 = new DeeplineClient();
38634
+ const rule = notificationByName(await client2.getNotifications(), name);
38635
+ if (options.dryRun) {
38636
+ printCommandEnvelope(
38637
+ { dryRun: true, notification: rule.id, action: "archive" },
38638
+ { json: options.json }
38639
+ );
38640
+ return;
38641
+ }
38642
+ const result = await client2.deleteNotification(rule.id);
38643
+ printCommandEnvelope(
38644
+ { ...result, notification: rule.name },
38645
+ { json: options.json }
38646
+ );
38647
+ });
38648
+ }
38649
+
37897
38650
  // ../shared_libs/cli/command-compatibility.json
37898
38651
  var command_compatibility_default = {
37899
38652
  enrich: {
@@ -39030,6 +39783,8 @@ Exit codes:
39030
39783
  registerSessionsCommands(program);
39031
39784
  registerWorkflowCommands(program);
39032
39785
  registerSecretsCommands(program);
39786
+ registerSettingsCommands(program);
39787
+ registerNotificationCommands(program);
39033
39788
  registerBillingCommands(program);
39034
39789
  registerMonitorsCommands(program);
39035
39790
  registerOrgCommands(program);