activitysmith-cli 1.20.1 → 1.21.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.
package/README.md CHANGED
@@ -279,6 +279,25 @@ activitysmith push \
279
279
  --interruption-level "time-sensitive"
280
280
  ```
281
281
 
282
+ ### Push Notification Sounds
283
+
284
+ Use `--sound` to choose the sound a Push Notification plays. Omit it to play the Push Notifications sound picked in the ActivitySmith app under Settings > Sounds.
285
+
286
+ | Value | Behavior |
287
+ | --- | --- |
288
+ | `default` | Plays the sound picked on the device. This is the same as omitting `--sound`. |
289
+ | `none` | Plays no sound. |
290
+ | A sound name | Plays one of the sounds bundled with the app: `arrive`, `bell`, `bells`, `bitflip`, `bloom`, `callout`, `chime`, `coin`, `corrupt`, `crest`, `cue`, `ding`, `drop`, `ember`, `emblem`, `flourish`, `glimmer`, `glint`, `glitch`, `lantern`, `nightfall`, `nudge`, `pixel`, `pop`, `signal`, `streak`, `tally`, `wand`, `whoosh`, or `zip`. |
291
+
292
+ Passive Push Notifications play no sound.
293
+
294
+ ```bash
295
+ activitysmith push \
296
+ --title "💸 New sale" \
297
+ --message "Pro plan, \$29/month" \
298
+ --sound "coin"
299
+ ```
300
+
282
301
  ### Replace a Push Notification
283
302
 
284
303
  Every `push` prints a `Notification ID`. Pass it to `--replace` to update a Push Notification you already sent, for example when an incident you alerted on is resolved. The replacement takes the old notification's place on the Lock Screen and in history instead of stacking a second one. It arrives silently, without sound or waking the screen, and goes to the same recipients as the original, so `--channels` and `--interruption-level` don't apply.
@@ -476,6 +495,19 @@ For a countdown, send `durationSeconds`. Leave it out on later stream updates to
476
495
 
477
496
  To start at 00:00 and count up, set `countsDown` to `false` and leave out `durationSeconds`.
478
497
 
498
+ To count down to a set time, send `timerEndAt` instead of `durationSeconds`. If the timer started earlier, also send `timerStartAt`. The progress bar then shows the time already gone.
499
+
500
+ ```bash
501
+ activitysmith activity stream nightly-backup \
502
+ --content-state '{
503
+ "title": "Nightly Backup",
504
+ "subtitle": "uploading archive",
505
+ "type": "timer",
506
+ "timerStartAt": "2026-11-19T01:00:00Z",
507
+ "timerEndAt": "2026-11-19T02:00:00Z"
508
+ }'
509
+ ```
510
+
479
511
  ### End Live Activity
480
512
 
481
513
  Call `activity end-stream` with the same `stream_key` to dismiss the Live Activity. You can include final values before it is removed. Use `--auto-dismiss-seconds` or `--auto-dismiss-minutes` to delay dismissal. Use `0` for immediate dismissal. Seconds take precedence if both are set. JSON content state also accepts `autoDismissSeconds` or `auto_dismiss_seconds`.
@@ -651,6 +683,23 @@ activitysmith activity stream agent-approval \
651
683
  }'
652
684
  ```
653
685
 
686
+ ### Live Activity Sounds
687
+
688
+ Starting a Live Activity plays the Live Activities sound picked in the ActivitySmith app. Updates and ends are silent. Set `--sound` on a start, update, or end to choose its sound, with the same values as [Push Notification Sounds](#push-notification-sounds). A sound on an update or end also expands the Live Activity on the Lock Screen, so use it for moments that need attention, such as a failed step.
689
+
690
+ ```bash
691
+ activitysmith activity stream deploy-api \
692
+ --content-state '{
693
+ "title": "Deploying API",
694
+ "subtitle": "Step 3 failed",
695
+ "type": "segmented_progress",
696
+ "numberOfSteps": 4,
697
+ "currentStep": 3,
698
+ "color": "red"
699
+ }' \
700
+ --sound "glitch"
701
+ ```
702
+
654
703
  ## Lock Screen Widgets
655
704
 
656
705
  ![Lock screen widgets](https://cdn.activitysmith.com/features/lock-screen-widgets.png)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "activitysmith-cli",
3
- "version": "1.20.1",
3
+ "version": "1.21.0",
4
4
  "description": "Command-line interface for ActivitySmith. Send Push Notifications, start, update, and end Live Activities, and set App Icon Badge Counts from your terminal.",
5
5
  "keywords": [
6
6
  "activitysmith",
package/src/approvals.js CHANGED
@@ -135,7 +135,7 @@ export const readGitChanges = async (range, { cwd = process.cwd() } = {}) => {
135
135
  }
136
136
  };
137
137
 
138
- // The name the review screen shows: the last path component. Full paths never leave the machine.
138
+ // The name the review screen shows: the last path component.
139
139
  export const changedFileName = (path) => {
140
140
  const trimmed = path.trim().replace(/[\\/]+$/, "");
141
141
  const name = trimmed.slice(Math.max(trimmed.lastIndexOf("/"), trimmed.lastIndexOf("\\")) + 1) || trimmed;
package/src/cli.js CHANGED
@@ -73,6 +73,13 @@ const parseNumberOption = (label) => (value) => {
73
73
  return parsed;
74
74
  };
75
75
 
76
+ const parseDateOption = (label) => (value) => {
77
+ if (typeof value !== "string" || Number.isNaN(Date.parse(value))) {
78
+ throw new InvalidArgumentError(`${label} must be an ISO 8601 date-time`);
79
+ }
80
+ return new Date(value).toISOString();
81
+ };
82
+
76
83
  const parseBooleanOption = (label) => (value) => {
77
84
  if (typeof value !== "string") {
78
85
  throw new InvalidArgumentError(`${label} must be true or false`);
@@ -123,6 +130,19 @@ const parseTagsOption = (value, previous = []) => {
123
130
  return [...previous, ...tags];
124
131
  };
125
132
 
133
+ // The API also accepts sound names outside the bundled list, so only the length is checked here.
134
+ const parseSoundOption = (value) => {
135
+ if (typeof value !== "string" || value.trim() === "" || value.length > 50) {
136
+ throw new InvalidArgumentError("sound must be 1-50 characters, such as chime, default, or none");
137
+ }
138
+ return value;
139
+ };
140
+
141
+ const SOUND_HELP = "Sound to play: a bundled sound name, default, or none";
142
+ const LIVE_ACTIVITY_CHANGE_SOUND_HELP = `${SOUND_HELP}. Silent by default; a sound also expands the Live Activity on the Lock Screen`;
143
+
144
+ const withSound = (request, sound) => (sound === undefined ? request : { ...request, sound });
145
+
126
146
  const parseMetricValueArgument = (value) => {
127
147
  if (typeof value !== "string") {
128
148
  throw new InvalidArgumentError("value must be a string or number");
@@ -252,6 +272,16 @@ const addContentStateOptions = (command, { includeAutoDismiss, includeAutoDismis
252
272
  "Timer duration in seconds",
253
273
  parseNumberOption("duration-seconds")
254
274
  )
275
+ .option(
276
+ "--timer-start-at <date>",
277
+ "Timer start time as an ISO 8601 date-time",
278
+ parseDateOption("timer-start-at")
279
+ )
280
+ .option(
281
+ "--timer-end-at <date>",
282
+ "Timer end time as an ISO 8601 date-time (instead of --duration-seconds)",
283
+ parseDateOption("timer-end-at")
284
+ )
255
285
  .option(
256
286
  "--counts-down <boolean>",
257
287
  "Set to false for an elapsed timer",
@@ -442,7 +472,27 @@ const validateContentState = (contentState, mode) => {
442
472
  const hasMetrics = hasOwn(contentState, "metrics");
443
473
  const hasDurationSeconds = hasOwn(contentState, "durationSeconds");
444
474
  const hasCountsDown = hasOwn(contentState, "countsDown");
445
- const hasTimerFields = hasDurationSeconds || hasCountsDown;
475
+ const hasTimerStartAt =
476
+ hasOwn(contentState, "timerStartAt") || hasOwn(contentState, "timer_start_at");
477
+ const hasTimerEndAt =
478
+ hasOwn(contentState, "timerEndAt") || hasOwn(contentState, "timer_end_at");
479
+ const hasTimerFields =
480
+ hasDurationSeconds || hasCountsDown || hasTimerStartAt || hasTimerEndAt;
481
+
482
+ for (const key of ["timerStartAt", "timer_start_at", "timerEndAt", "timer_end_at"]) {
483
+ if (!hasOwn(contentState, key)) continue;
484
+ const value = contentState[key];
485
+ if (typeof value !== "string" || Number.isNaN(Date.parse(value))) {
486
+ throw new Error(`contentState.${key} must be an ISO 8601 date-time`);
487
+ }
488
+ contentState[key] = new Date(value).toISOString();
489
+ }
490
+
491
+ if (hasDurationSeconds && hasTimerEndAt) {
492
+ throw new Error(
493
+ "Provide either contentState.durationSeconds or contentState.timerEndAt, not both"
494
+ );
495
+ }
446
496
 
447
497
  for (const key of ["autoDismissSeconds", "auto_dismiss_seconds"]) {
448
498
  if (hasOwn(contentState, key) &&
@@ -625,9 +675,14 @@ const validateContentState = (contentState, mode) => {
625
675
  }
626
676
 
627
677
  if (effectiveType === "timer") {
628
- if (mode === "start" && !hasDurationSeconds && contentState.countsDown !== false) {
678
+ if (
679
+ mode === "start" &&
680
+ !hasDurationSeconds &&
681
+ !hasTimerEndAt &&
682
+ contentState.countsDown !== false
683
+ ) {
629
684
  throw new Error(
630
- `timer ${mode} requires contentState.durationSeconds, or contentState.countsDown=false`
685
+ `timer ${mode} requires contentState.durationSeconds or contentState.timerEndAt, or contentState.countsDown=false`
631
686
  );
632
687
  }
633
688
  return;
@@ -908,6 +963,14 @@ const buildContentStateFromOptions = (options) => {
908
963
  contentState.durationSeconds = options.durationSeconds;
909
964
  }
910
965
 
966
+ if (options.timerStartAt !== undefined) {
967
+ contentState.timerStartAt = options.timerStartAt;
968
+ }
969
+
970
+ if (options.timerEndAt !== undefined) {
971
+ contentState.timerEndAt = options.timerEndAt;
972
+ }
973
+
911
974
  if (options.countsDown !== undefined) {
912
975
  contentState.countsDown = options.countsDown;
913
976
  }
@@ -957,6 +1020,8 @@ const toApiContentState = (contentState) => {
957
1020
  autoDismissSeconds: "auto_dismiss_seconds",
958
1021
  durationSeconds: "duration_seconds",
959
1022
  countsDown: "counts_down",
1023
+ timerStartAt: "timer_start_at",
1024
+ timerEndAt: "timer_end_at",
960
1025
  };
961
1026
 
962
1027
  const mapped = {};
@@ -1325,6 +1390,11 @@ const pushCommand = program
1325
1390
  "time-sensitive",
1326
1391
  ])
1327
1392
  )
1393
+ .option(
1394
+ "--sound <name>",
1395
+ `${SOUND_HELP} (defaults to your Push Notifications sound)`,
1396
+ parseSoundOption
1397
+ )
1328
1398
  .option("--redirection <url>", "HTTPS or shortcuts:// URL opened when notification is tapped")
1329
1399
  .option("--actions <json>", "Actions JSON array (max 4)")
1330
1400
  .option("--actions-file <path>", "Path to actions JSON array file")
@@ -1356,9 +1426,13 @@ const pushCommand = program
1356
1426
  actions,
1357
1427
  });
1358
1428
  if (options.replace !== undefined) {
1359
- if (options.channels !== undefined || options.interruptionLevel !== undefined) {
1429
+ if (
1430
+ options.channels !== undefined ||
1431
+ options.interruptionLevel !== undefined ||
1432
+ options.sound !== undefined
1433
+ ) {
1360
1434
  throw new Error(
1361
- "--channels and --interruption-level cannot be combined with --replace. Replacements go to the original recipients and arrive silently."
1435
+ "--channels, --interruption-level, and --sound cannot be combined with --replace. Replacements go to the original recipients and arrive silently."
1362
1436
  );
1363
1437
  }
1364
1438
  if (options.replace.trim() === "") {
@@ -1380,6 +1454,7 @@ const pushCommand = program
1380
1454
  ? normalizeHttpsUrl(options.icon, "icon")
1381
1455
  : undefined,
1382
1456
  interruption_level: options.interruptionLevel,
1457
+ sound: options.sound,
1383
1458
  redirection:
1384
1459
  options.redirection !== undefined
1385
1460
  ? normalizeOpenUrl(options.redirection, "redirection")
@@ -1567,6 +1642,11 @@ addLiveActivityActionOptions(addContentStateOptions(
1567
1642
  parseTagsOption
1568
1643
  )
1569
1644
  .option("--clear-tags", "Remove all Tags from this stream")
1645
+ .option(
1646
+ "--sound <name>",
1647
+ `${SOUND_HELP}. A new stream defaults to your Live Activities sound; updates are silent by default, and a sound also expands the Live Activity on the Lock Screen`,
1648
+ parseSoundOption
1649
+ )
1570
1650
  .option("--metadata <json>", "Metadata JSON object shown in ActivitySmith details")
1571
1651
  .option("--metadata-file <path>", "Path to a Metadata JSON object file")
1572
1652
  .action(async (streamKey, options) => {
@@ -1584,17 +1664,20 @@ addLiveActivityActionOptions(addContentStateOptions(
1584
1664
 
1585
1665
  const response = await client.liveActivities.stream(
1586
1666
  streamKey,
1587
- withTags(
1588
- withTargetChannels(
1589
- toApiLiveActivityStreamRequest(
1590
- contentState,
1591
- action,
1592
- secondaryAction
1667
+ withSound(
1668
+ withTags(
1669
+ withTargetChannels(
1670
+ toApiLiveActivityStreamRequest(
1671
+ contentState,
1672
+ action,
1673
+ secondaryAction
1674
+ ),
1675
+ options.channels
1593
1676
  ),
1594
- options.channels
1677
+ options.clearTags ? [] : options.tags,
1678
+ await loadMetadata(options)
1595
1679
  ),
1596
- options.clearTags ? [] : options.tags,
1597
- await loadMetadata(options)
1680
+ options.sound
1598
1681
  )
1599
1682
  );
1600
1683
 
@@ -1626,6 +1709,11 @@ addLiveActivityActionOptions(addContentStateOptions(
1626
1709
  "Comma-separated tags for organizing history (repeatable)",
1627
1710
  parseTagsOption
1628
1711
  )
1712
+ .option(
1713
+ "--sound <name>",
1714
+ `${SOUND_HELP} (defaults to your Live Activities sound)`,
1715
+ parseSoundOption
1716
+ )
1629
1717
  .option("--metadata <json>", "Metadata JSON object shown in ActivitySmith details")
1630
1718
  .option("--metadata-file <path>", "Path to a Metadata JSON object file")
1631
1719
  .action(async (options) => {
@@ -1639,17 +1727,20 @@ addLiveActivityActionOptions(addContentStateOptions(
1639
1727
  const secondaryAction = await loadLiveActivitySecondaryAction(options);
1640
1728
 
1641
1729
  const response = await client.liveActivities.startLiveActivity({
1642
- liveActivityStartRequest: withTags(
1643
- withTargetChannels(
1644
- toApiLiveActivityStartRequest(
1645
- contentState,
1646
- action,
1647
- secondaryAction
1730
+ liveActivityStartRequest: withSound(
1731
+ withTags(
1732
+ withTargetChannels(
1733
+ toApiLiveActivityStartRequest(
1734
+ contentState,
1735
+ action,
1736
+ secondaryAction
1737
+ ),
1738
+ options.channels
1648
1739
  ),
1649
- options.channels
1740
+ options.tags,
1741
+ await loadMetadata(options)
1650
1742
  ),
1651
- options.tags,
1652
- await loadMetadata(options)
1743
+ options.sound
1653
1744
  ),
1654
1745
  });
1655
1746
 
@@ -1671,6 +1762,7 @@ addLiveActivityActionOptions(addContentStateOptions(
1671
1762
  .requiredOption("--activity-id <id>", "Live Activity ID")
1672
1763
  .option("--tags <tags>", "Replace Tags for this Live Activity (repeatable)", parseTagsOption)
1673
1764
  .option("--clear-tags", "Remove all Tags from this Live Activity")
1765
+ .option("--sound <name>", LIVE_ACTIVITY_CHANGE_SOUND_HELP, parseSoundOption)
1674
1766
  .option("--metadata <json>", "Metadata JSON object shown in ActivitySmith details")
1675
1767
  .option("--metadata-file <path>", "Path to a Metadata JSON object file")
1676
1768
  .action(async (options) => {
@@ -1687,12 +1779,12 @@ addLiveActivityActionOptions(addContentStateOptions(
1687
1779
  const secondaryAction = await loadLiveActivitySecondaryAction(options);
1688
1780
 
1689
1781
  const response = await client.liveActivities.updateLiveActivity({
1690
- liveActivityUpdateRequest: withTags(toApiLiveActivityUpdateRequest(
1782
+ liveActivityUpdateRequest: withSound(withTags(toApiLiveActivityUpdateRequest(
1691
1783
  options.activityId,
1692
1784
  contentState,
1693
1785
  action,
1694
1786
  secondaryAction
1695
- ), options.clearTags ? [] : options.tags, await loadMetadata(options)),
1787
+ ), options.clearTags ? [] : options.tags, await loadMetadata(options)), options.sound),
1696
1788
  });
1697
1789
 
1698
1790
  outputResult(response, globalOptions, [
@@ -1712,6 +1804,7 @@ addLiveActivityActionOptions(addContentStateOptions(
1712
1804
  .requiredOption("--activity-id <id>", "Live Activity ID")
1713
1805
  .option("--tags <tags>", "Replace Tags for this Live Activity (repeatable)", parseTagsOption)
1714
1806
  .option("--clear-tags", "Remove all Tags from this Live Activity")
1807
+ .option("--sound <name>", LIVE_ACTIVITY_CHANGE_SOUND_HELP, parseSoundOption)
1715
1808
  .option("--metadata <json>", "Metadata JSON object shown in ActivitySmith details")
1716
1809
  .option("--metadata-file <path>", "Path to a Metadata JSON object file")
1717
1810
  .action(async (options) => {
@@ -1728,12 +1821,12 @@ addLiveActivityActionOptions(addContentStateOptions(
1728
1821
  const secondaryAction = await loadLiveActivitySecondaryAction(options);
1729
1822
 
1730
1823
  const response = await client.liveActivities.endLiveActivity({
1731
- liveActivityEndRequest: withTags(toApiLiveActivityEndRequest(
1824
+ liveActivityEndRequest: withSound(withTags(toApiLiveActivityEndRequest(
1732
1825
  options.activityId,
1733
1826
  contentState,
1734
1827
  action,
1735
1828
  secondaryAction
1736
- ), options.clearTags ? [] : options.tags, await loadMetadata(options)),
1829
+ ), options.clearTags ? [] : options.tags, await loadMetadata(options)), options.sound),
1737
1830
  });
1738
1831
 
1739
1832
  outputResult(response, globalOptions, [
@@ -1754,6 +1847,7 @@ addLiveActivityActionOptions(addContentStateOptions(
1754
1847
  .argument("<stream-key>", "Stable stream key")
1755
1848
  .option("--tags <tags>", "Comma-separated Tags", parseTagsOption)
1756
1849
  .option("--clear-tags", "Clear existing Tags")
1850
+ .option("--sound <name>", LIVE_ACTIVITY_CHANGE_SOUND_HELP, parseSoundOption)
1757
1851
  .option("--metadata <json>", "Metadata as a JSON object")
1758
1852
  .option("--metadata-file <path>", "Metadata JSON file path")
1759
1853
  .action(async (streamKey, options) => {
@@ -1772,7 +1866,8 @@ addLiveActivityActionOptions(addContentStateOptions(
1772
1866
  const request =
1773
1867
  contentState !== undefined ||
1774
1868
  action !== undefined ||
1775
- secondaryAction !== undefined || tags !== undefined || metadata !== undefined
1869
+ secondaryAction !== undefined || tags !== undefined || metadata !== undefined ||
1870
+ options.sound !== undefined
1776
1871
  ? toApiLiveActivityStreamDeleteRequest(
1777
1872
  contentState,
1778
1873
  action,
@@ -1782,6 +1877,7 @@ addLiveActivityActionOptions(addContentStateOptions(
1782
1877
 
1783
1878
  if (tags !== undefined) request.tags = tags;
1784
1879
  if (metadata !== undefined) request.metadata = metadata;
1880
+ if (options.sound !== undefined) request.sound = options.sound;
1785
1881
  const response = await client.liveActivities.endStream(streamKey, request);
1786
1882
 
1787
1883
  const activityId = response?.activityId ?? response?.activity_id;