activitysmith-cli 1.7.0 → 1.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +98 -15
  2. package/package.json +4 -3
  3. package/src/cli.js +163 -13
package/README.md CHANGED
@@ -17,8 +17,9 @@ CLI wrapper for the ActivitySmith API using the official Node SDK.
17
17
  - [Live Activity Action](#live-activity-action)
18
18
  - [Icons and Badges](#icons-and-badges)
19
19
  - [Live Activity Colors](#live-activity-colors)
20
- - [Channels](#channels)
21
20
  - [Widgets](#widgets)
21
+ - [App Icon Badge Count](#app-icon-badge-count)
22
+ - [Channels](#channels)
22
23
  - [Aliases](#aliases)
23
24
  - [Content State Options](#content-state-options)
24
25
  - [Output](#output)
@@ -51,6 +52,7 @@ The skill maps those requests to the CLI:
51
52
  - action buttons for follow-up links or Shortcut buttons
52
53
  - Live Activities for long-running progress
53
54
  - widget metrics for values that should stay visible
55
+ - App Icon Badge Counts for a number that should stay on the app icon
54
56
 
55
57
  Install the public skill from this repo:
56
58
 
@@ -339,7 +341,7 @@ activitysmith activity end-stream prod-web-1 \
339
341
 
340
342
  ### Live Activity Action
341
343
 
342
- Live Activities can include one optional action button.
344
+ Live Activities can include an action button.
343
345
 
344
346
  - `open_url`: open an HTTPS URL.
345
347
  - `open_url` with a `shortcuts://` URL: run an Apple Shortcut, for example to open an app.
@@ -347,7 +349,7 @@ Live Activities can include one optional action button.
347
349
 
348
350
  <p align="center">
349
351
  <img
350
- src="https://cdn.activitysmith.com/features/live-activity-with-action.png?v=20260319-1"
352
+ src="https://cdn.activitysmith.com/features/metrics-live-activity-action.png"
351
353
  alt="Live Activity with action button"
352
354
  width="680"
353
355
  />
@@ -414,6 +416,46 @@ activitysmith activity stream search-reindex \
414
416
  }'
415
417
  ```
416
418
 
419
+ #### Secondary action
420
+
421
+ <p align="center">
422
+ <img
423
+ src="https://cdn.activitysmith.com/features/live-activity-secondary-action.png"
424
+ alt="Alert Live Activity with primary and secondary action buttons"
425
+ width="680"
426
+ />
427
+ </p>
428
+
429
+ Use `--secondary-action` when you want a second button beside the primary `--action`.
430
+
431
+ The secondary action button is supported for `alert`, `progress`, and `segmented_progress` Live Activities. Both buttons use the same `open_url`, `webhook`, and Apple Shortcut payload shapes.
432
+
433
+ ```bash
434
+ activitysmith activity stream agent-approval \
435
+ --content-state '{
436
+ "title": "Approval Needed",
437
+ "message": "Should I send the follow-up email to Brightlane?",
438
+ "type": "alert",
439
+ "color": "green",
440
+ "icon": { "symbol": "sparkles", "color": "green" },
441
+ "badge": { "title": "Agent", "color": "green" }
442
+ }' \
443
+ --action '{
444
+ "title": "Send",
445
+ "type": "webhook",
446
+ "url": "https://hooks.example.com/agent/approval",
447
+ "method": "POST",
448
+ "body": { "decision": "send" }
449
+ }' \
450
+ --secondary-action '{
451
+ "title": "Deny",
452
+ "type": "webhook",
453
+ "url": "https://hooks.example.com/agent/approval",
454
+ "method": "POST",
455
+ "body": { "decision": "deny" }
456
+ }'
457
+ ```
458
+
417
459
  ### Icons and Badges
418
460
 
419
461
  Add more context to Live Activities with icons and badges.
@@ -479,17 +521,6 @@ Choose from these colors for the Live Activity accent, including progress bars a
479
521
 
480
522
  `lime`, `green`, `cyan`, `blue`, `purple`, `magenta`, `red`, `orange`, `yellow`, `gray`
481
523
 
482
- ## Channels
483
-
484
- Channels are used to target specific team members or devices. Can be used for both push notifications and live activities.
485
-
486
- ```bash
487
- activitysmith push \
488
- --title "Build Failed 🚨" \
489
- --message "CI pipeline failed on main branch" \
490
- --channels "devs,ops"
491
- ```
492
-
493
524
  ## Widgets
494
525
 
495
526
  <p align="center">
@@ -514,6 +545,56 @@ String metric values work too.
514
545
  activitysmith metrics update prod.status healthy
515
546
  ```
516
547
 
548
+ ## App Icon Badge Count
549
+
550
+ <p align="center">
551
+ <img src="https://cdn.activitysmith.com/features/badge-count.png" alt="ActivitySmith app icon with an App Icon Badge Count" width="680" />
552
+ </p>
553
+
554
+ Show the number you care about on your ActivitySmith app icon. Track MRR, a customer count, a stock price, or any other value you want to keep in view.
555
+
556
+ Set or update the badge value.
557
+
558
+ ```bash
559
+ activitysmith badge 8333
560
+ ```
561
+
562
+ To clear the badge, set its value to 0.
563
+
564
+ ```bash
565
+ activitysmith badge 0
566
+ ```
567
+
568
+ ## Channels
569
+
570
+ Use `--channels` to target specific team members or devices
571
+
572
+ ### Push Notifications
573
+
574
+ ```bash
575
+ activitysmith push \
576
+ --title "New subscription 💸" \
577
+ --message "Customer upgraded to Pro plan" \
578
+ --channels "sales,customer-success"
579
+ ```
580
+
581
+ ### Live Activities
582
+
583
+ ```bash
584
+ activitysmith activity start \
585
+ --title "Nightly Database Backup" \
586
+ --subtitle "verify restore" \
587
+ --type progress \
588
+ --percentage 62 \
589
+ --channels "sales,customer-success"
590
+ ```
591
+
592
+ ### App Icon Badge Count
593
+
594
+ ```bash
595
+ activitysmith badge 3 --channels "sales,customer-success"
596
+ ```
597
+
517
598
  ## Aliases
518
599
 
519
600
  The CLI installs two bin names:
@@ -555,10 +636,12 @@ Live Activity action options:
555
636
 
556
637
  - `--action <json>`
557
638
  - `--action-file <path>`
639
+ - `--secondary-action <json>`
640
+ - `--secondary-action-file <path>`
558
641
 
559
642
  Targeting options:
560
643
 
561
- - `--channels <comma-separated-slugs>` (for `push`, `activity stream`, and `activity start`)
644
+ - `--channels <comma-separated-slugs>` (for `push`, `badge`, `activity stream`, and `activity start`)
562
645
 
563
646
  Widget metric options:
564
647
 
package/package.json CHANGED
@@ -1,11 +1,12 @@
1
1
  {
2
2
  "name": "activitysmith-cli",
3
- "version": "1.7.0",
4
- "description": "Command-line interface for ActivitySmith. Send push notifications and manage Live Activities from your terminal.",
3
+ "version": "1.9.0",
4
+ "description": "Command-line interface for ActivitySmith. Send push notifications, manage Live Activities, and set App Icon Badge Counts from your terminal.",
5
5
  "keywords": [
6
6
  "activitysmith",
7
7
  "live-activities",
8
8
  "push-notifications",
9
+ "app-icon-badge",
9
10
  "api",
10
11
  "cli",
11
12
  "deployment",
@@ -40,7 +41,7 @@
40
41
  "lint": "node --check src/cli.js"
41
42
  },
42
43
  "dependencies": {
43
- "activitysmith": "^1.7.0",
44
+ "activitysmith": "^1.9.0",
44
45
  "commander": "^12.1.0"
45
46
  }
46
47
  }
package/src/cli.js CHANGED
@@ -29,6 +29,16 @@ const parseIntegerOption = (label) => (value) => {
29
29
  return parsed;
30
30
  };
31
31
 
32
+ const parseBadgeCountArgument = (value) => {
33
+ const badge = parseIntegerOption("badge")(value);
34
+ if (badge < 0 || badge > 2147483647) {
35
+ throw new InvalidArgumentError(
36
+ "badge must be an integer between 0 and 2147483647"
37
+ );
38
+ }
39
+ return badge;
40
+ };
41
+
32
42
  const parseNumberOption = (label) => (value) => {
33
43
  const parsed = Number(value);
34
44
  if (!Number.isFinite(parsed)) {
@@ -210,12 +220,24 @@ const addContentStateOptions = (command, { includeAutoDismiss } = {}) => {
210
220
  const addLiveActivityActionOptions = (command) =>
211
221
  command
212
222
  .option("--action <json>", "Live Activity action as JSON object")
213
- .option("--action-file <path>", "Live Activity action JSON file path");
223
+ .option("--action-file <path>", "Live Activity action JSON file path")
224
+ .option(
225
+ "--secondary-action <json>",
226
+ "Secondary Live Activity action as JSON object"
227
+ )
228
+ .option(
229
+ "--secondary-action-file <path>",
230
+ "Secondary Live Activity action JSON file path"
231
+ );
214
232
 
215
233
  const getApiKey = (options) =>
216
234
  options.apiKey || process.env.ACTIVITYSMITH_API_KEY;
217
235
 
218
- const createClient = (apiKey) => new ActivitySmith({ apiKey });
236
+ const createClient = (apiKey) =>
237
+ new ActivitySmith({
238
+ apiKey,
239
+ sdk: { name: "cli", version },
240
+ });
219
241
 
220
242
  const assertPlainObject = (value, label) => {
221
243
  const isPlainObject =
@@ -695,6 +717,32 @@ const loadLiveActivityAction = async (options) => {
695
717
  return parseAction(action, "action");
696
718
  };
697
719
 
720
+ const loadLiveActivitySecondaryAction = async (options) => {
721
+ if (options.secondaryAction && options.secondaryActionFile) {
722
+ throw new Error(
723
+ "Provide either --secondary-action or --secondary-action-file, not both."
724
+ );
725
+ }
726
+
727
+ let action;
728
+ if (options.secondaryActionFile) {
729
+ action = await readJsonFile(
730
+ options.secondaryActionFile,
731
+ "secondary-action-file"
732
+ );
733
+ }
734
+
735
+ if (options.secondaryAction) {
736
+ action = parseJsonString(options.secondaryAction, "secondary-action");
737
+ }
738
+
739
+ if (action === undefined) {
740
+ return undefined;
741
+ }
742
+
743
+ return parseAction(action, "secondary_action");
744
+ };
745
+
698
746
  const validatePushMediaOptions = ({ media, actions }) => {
699
747
  if (media === undefined || actions === undefined) {
700
748
  return;
@@ -828,7 +876,11 @@ const toApiContentState = (contentState) => {
828
876
  return mapped;
829
877
  };
830
878
 
831
- const toApiLiveActivityStartRequest = (contentState, action) => {
879
+ const toApiLiveActivityStartRequest = (
880
+ contentState,
881
+ action,
882
+ secondaryAction
883
+ ) => {
832
884
  const request = {
833
885
  content_state: toApiContentState(contentState),
834
886
  };
@@ -837,6 +889,10 @@ const toApiLiveActivityStartRequest = (contentState, action) => {
837
889
  request.action = action;
838
890
  }
839
891
 
892
+ if (secondaryAction !== undefined) {
893
+ request.secondary_action = secondaryAction;
894
+ }
895
+
840
896
  return request;
841
897
  };
842
898
 
@@ -853,7 +909,12 @@ const withTargetChannels = (request, channels) => {
853
909
  };
854
910
  };
855
911
 
856
- const toApiLiveActivityUpdateRequest = (activityId, contentState, action) => {
912
+ const toApiLiveActivityUpdateRequest = (
913
+ activityId,
914
+ contentState,
915
+ action,
916
+ secondaryAction
917
+ ) => {
857
918
  const request = {
858
919
  activity_id: activityId,
859
920
  content_state: toApiContentState(contentState),
@@ -863,10 +924,19 @@ const toApiLiveActivityUpdateRequest = (activityId, contentState, action) => {
863
924
  request.action = action;
864
925
  }
865
926
 
927
+ if (secondaryAction !== undefined) {
928
+ request.secondary_action = secondaryAction;
929
+ }
930
+
866
931
  return request;
867
932
  };
868
933
 
869
- const toApiLiveActivityEndRequest = (activityId, contentState, action) => {
934
+ const toApiLiveActivityEndRequest = (
935
+ activityId,
936
+ contentState,
937
+ action,
938
+ secondaryAction
939
+ ) => {
870
940
  const request = {
871
941
  activity_id: activityId,
872
942
  content_state: toApiContentState(contentState),
@@ -876,10 +946,18 @@ const toApiLiveActivityEndRequest = (activityId, contentState, action) => {
876
946
  request.action = action;
877
947
  }
878
948
 
949
+ if (secondaryAction !== undefined) {
950
+ request.secondary_action = secondaryAction;
951
+ }
952
+
879
953
  return request;
880
954
  };
881
955
 
882
- const toApiLiveActivityStreamRequest = (contentState, action) => {
956
+ const toApiLiveActivityStreamRequest = (
957
+ contentState,
958
+ action,
959
+ secondaryAction
960
+ ) => {
883
961
  const request = {
884
962
  content_state: toApiContentState(contentState),
885
963
  };
@@ -888,10 +966,18 @@ const toApiLiveActivityStreamRequest = (contentState, action) => {
888
966
  request.action = action;
889
967
  }
890
968
 
969
+ if (secondaryAction !== undefined) {
970
+ request.secondary_action = secondaryAction;
971
+ }
972
+
891
973
  return request;
892
974
  };
893
975
 
894
- const toApiLiveActivityStreamDeleteRequest = (contentState, action) => {
976
+ const toApiLiveActivityStreamDeleteRequest = (
977
+ contentState,
978
+ action,
979
+ secondaryAction
980
+ ) => {
895
981
  const request = {};
896
982
 
897
983
  if (contentState !== undefined) {
@@ -902,6 +988,10 @@ const toApiLiveActivityStreamDeleteRequest = (contentState, action) => {
902
988
  request.action = action;
903
989
  }
904
990
 
991
+ if (secondaryAction !== undefined) {
992
+ request.secondary_action = secondaryAction;
993
+ }
994
+
905
995
  return request;
906
996
  };
907
997
 
@@ -1157,6 +1247,45 @@ program
1157
1247
  }
1158
1248
  });
1159
1249
 
1250
+ program
1251
+ .command("badge")
1252
+ .alias("badge-count")
1253
+ .description("Set App Icon Badge Count; pass 0 to clear it")
1254
+ .argument(
1255
+ "<value>",
1256
+ "App Icon Badge Count; pass 0 to clear it",
1257
+ parseBadgeCountArgument
1258
+ )
1259
+ .option(
1260
+ "--channels <channels>",
1261
+ "Comma-separated channel slugs (optional)",
1262
+ parseChannelsOption
1263
+ )
1264
+ .action(async (value, options) => {
1265
+ const globalOptions = program.opts();
1266
+
1267
+ try {
1268
+ const apiKey = requireApiKey(globalOptions);
1269
+ const client = createClient(apiKey);
1270
+ const response = await client.badgeCount(
1271
+ value,
1272
+ options.channels ? { channels: options.channels } : undefined
1273
+ );
1274
+
1275
+ outputResult(response, globalOptions, [
1276
+ value === 0
1277
+ ? "App Icon Badge Count cleared."
1278
+ : "App Icon Badge Count updated.",
1279
+ response?.badge !== undefined ? `Badge: ${response.badge}` : null,
1280
+ response?.devicesNotified !== undefined
1281
+ ? `Devices notified: ${response.devicesNotified}`
1282
+ : null,
1283
+ ]);
1284
+ } catch (error) {
1285
+ await handleError(error, globalOptions);
1286
+ }
1287
+ });
1288
+
1160
1289
  const metricsCommand = program
1161
1290
  .command("metrics")
1162
1291
  .alias("metric")
@@ -1204,11 +1333,16 @@ addLiveActivityActionOptions(addContentStateOptions(
1204
1333
  const client = createClient(apiKey);
1205
1334
  const contentState = await loadContentState(options, "stream");
1206
1335
  const action = await loadLiveActivityAction(options);
1336
+ const secondaryAction = await loadLiveActivitySecondaryAction(options);
1207
1337
 
1208
1338
  const response = await client.liveActivities.stream(
1209
1339
  streamKey,
1210
1340
  withTargetChannels(
1211
- toApiLiveActivityStreamRequest(contentState, action),
1341
+ toApiLiveActivityStreamRequest(
1342
+ contentState,
1343
+ action,
1344
+ secondaryAction
1345
+ ),
1212
1346
  options.channels
1213
1347
  )
1214
1348
  );
@@ -1244,10 +1378,15 @@ addLiveActivityActionOptions(addContentStateOptions(
1244
1378
  const client = createClient(apiKey);
1245
1379
  const contentState = await loadContentState(options, "start");
1246
1380
  const action = await loadLiveActivityAction(options);
1381
+ const secondaryAction = await loadLiveActivitySecondaryAction(options);
1247
1382
 
1248
1383
  const response = await client.liveActivities.startLiveActivity({
1249
1384
  liveActivityStartRequest: withTargetChannels(
1250
- toApiLiveActivityStartRequest(contentState, action),
1385
+ toApiLiveActivityStartRequest(
1386
+ contentState,
1387
+ action,
1388
+ secondaryAction
1389
+ ),
1251
1390
  options.channels
1252
1391
  ),
1253
1392
  });
@@ -1276,12 +1415,14 @@ addLiveActivityActionOptions(addContentStateOptions(
1276
1415
  const client = createClient(apiKey);
1277
1416
  const contentState = await loadContentState(options, "update");
1278
1417
  const action = await loadLiveActivityAction(options);
1418
+ const secondaryAction = await loadLiveActivitySecondaryAction(options);
1279
1419
 
1280
1420
  const response = await client.liveActivities.updateLiveActivity({
1281
1421
  liveActivityUpdateRequest: toApiLiveActivityUpdateRequest(
1282
1422
  options.activityId,
1283
1423
  contentState,
1284
- action
1424
+ action,
1425
+ secondaryAction
1285
1426
  ),
1286
1427
  });
1287
1428
 
@@ -1308,12 +1449,14 @@ addLiveActivityActionOptions(addContentStateOptions(
1308
1449
  const client = createClient(apiKey);
1309
1450
  const contentState = await loadContentState(options, "end");
1310
1451
  const action = await loadLiveActivityAction(options);
1452
+ const secondaryAction = await loadLiveActivitySecondaryAction(options);
1311
1453
 
1312
1454
  const response = await client.liveActivities.endLiveActivity({
1313
1455
  liveActivityEndRequest: toApiLiveActivityEndRequest(
1314
1456
  options.activityId,
1315
1457
  contentState,
1316
- action
1458
+ action,
1459
+ secondaryAction
1317
1460
  ),
1318
1461
  });
1319
1462
 
@@ -1341,10 +1484,17 @@ addLiveActivityActionOptions(addContentStateOptions(
1341
1484
  const client = createClient(apiKey);
1342
1485
  const contentState = await loadOptionalContentState(options, "end");
1343
1486
  const action = await loadLiveActivityAction(options);
1487
+ const secondaryAction = await loadLiveActivitySecondaryAction(options);
1344
1488
 
1345
1489
  const request =
1346
- contentState !== undefined || action !== undefined
1347
- ? toApiLiveActivityStreamDeleteRequest(contentState, action)
1490
+ contentState !== undefined ||
1491
+ action !== undefined ||
1492
+ secondaryAction !== undefined
1493
+ ? toApiLiveActivityStreamDeleteRequest(
1494
+ contentState,
1495
+ action,
1496
+ secondaryAction
1497
+ )
1348
1498
  : undefined;
1349
1499
 
1350
1500
  const response = await client.liveActivities.endStream(streamKey, request);