activitysmith-cli 1.21.0 → 1.23.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 +28 -3
  2. package/package.json +1 -1
  3. package/src/cli.js +59 -46
package/README.md CHANGED
@@ -572,15 +572,20 @@ Choose from these colors for the Live Activity accent, including progress bars a
572
572
 
573
573
  Live Activities can include an action button.
574
574
 
575
- - `open_url`: Open a web page or run an iOS Shortcut
575
+ - `open_url`: Open a web page, run an iOS Shortcut, or open an app
576
576
  - `webhook`: Trigger a backend GET/POST workflow
577
577
 
578
578
  #### Open URL action
579
579
 
580
- Open a web page or run an iOS Shortcut when someone taps the button. Supported links:
580
+ Open a web page, run an iOS Shortcut, or open an app when someone taps the button. Supported links:
581
581
 
582
582
  - **HTTP/HTTPS:** Web pages, e.g. `https://example.com`
583
583
  - **Shortcuts:** Run Jarvis with `shortcuts://run-shortcut?name=Jarvis` <!-- full-width -->
584
+ - **App deep links:** Installed apps or specific content within them
585
+ - **Spotify:** A track, e.g. `spotify:track:6rqhFgbbKwnb9MLmUQDhG6`
586
+ - **Termius:** `termius://` to open the app
587
+ - **Claude:** `claude://code` to open the Code tab
588
+ - **ChatGPT:** `chatgpt://` to open the app <!-- Verify ChatGPT URL scheme on iOS before publishing -->
584
589
 
585
590
  ```bash
586
591
  activitysmith activity stream prod-web-1 \
@@ -620,6 +625,26 @@ activitysmith activity stream prod-web-1 \
620
625
  }'
621
626
  ```
622
627
 
628
+ #### End after the tap
629
+
630
+ Set `dismiss_after_action` on an `open_url` button to end the Live Activity when someone taps it. The button opens its link, then the Live Activity ends.
631
+
632
+ ```bash
633
+ activitysmith activity stream agent-review \
634
+ --content-state '{
635
+ "title": "Review Ready",
636
+ "message": "Claude finished the checkout refactor.",
637
+ "type": "alert",
638
+ "color": "green"
639
+ }' \
640
+ --action '{
641
+ "title": "Open Claude",
642
+ "type": "open_url",
643
+ "url": "claude://code",
644
+ "dismiss_after_action": true
645
+ }'
646
+ ```
647
+
623
648
  #### Webhook action
624
649
 
625
650
  ```bash
@@ -685,7 +710,7 @@ activitysmith activity stream agent-approval \
685
710
 
686
711
  ### Live Activity Sounds
687
712
 
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.
713
+ 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 plays only while the screen is on. Use it for moments that need attention, such as a failed step.
689
714
 
690
715
  ```bash
691
716
  activitysmith activity stream deploy-api \
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "activitysmith-cli",
3
- "version": "1.21.0",
3
+ "version": "1.23.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/cli.js CHANGED
@@ -139,10 +139,23 @@ const parseSoundOption = (value) => {
139
139
  };
140
140
 
141
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`;
142
+ const LIVE_ACTIVITY_CHANGE_SOUND_HELP = `${SOUND_HELP}. Silent by default; iOS plays the sound only while the screen is on`;
143
143
 
144
144
  const withSound = (request, sound) => (sound === undefined ? request : { ...request, sound });
145
145
 
146
+ const parseRelevanceScoreOption = (value) => {
147
+ const parsed = typeof value === "string" && value.trim() !== "" ? Number(value) : Number.NaN;
148
+ if (!Number.isFinite(parsed) || parsed < 0 || parsed > 100) {
149
+ throw new InvalidArgumentError("relevance-score must be a number from 0 to 100");
150
+ }
151
+ return parsed;
152
+ };
153
+
154
+ const RELEVANCE_SCORE_HELP = "Order when several Live Activities run: 0 to 100, higher shows first";
155
+
156
+ const withRelevanceScore = (request, relevanceScore) =>
157
+ relevanceScore === undefined ? request : { ...request, relevance_score: relevanceScore };
158
+
146
159
  const parseMetricValueArgument = (value) => {
147
160
  if (typeof value !== "string") {
148
161
  throw new InvalidArgumentError("value must be a string or number");
@@ -186,31 +199,11 @@ const normalizeHttpsUrl = (value, label) => {
186
199
  return parsed.toString();
187
200
  };
188
201
 
189
- const normalizeUrlWithSchemes = (value, label, schemes) => {
190
- if (typeof value !== "string" || value.trim().length === 0) {
191
- throw new Error(`${label} must be a non-empty string`);
192
- }
193
-
194
- let parsed;
195
- try {
196
- parsed = new URL(value.trim());
197
- } catch {
198
- throw new Error(`${label} must be a valid URL`);
199
- }
200
-
201
- const allowedProtocols = schemes.map((scheme) => `${scheme}:`);
202
- if (!allowedProtocols.includes(parsed.protocol)) {
203
- throw new Error(`${label} must use ${schemes.join(" or ")}`);
204
- }
205
-
206
- return parsed.toString();
207
- };
208
-
209
202
  const normalizeActionUrl = (value, label, type, push = false) => {
210
203
  if (type === "open_url") {
211
204
  if (push) return normalizeOpenUrl(value, label);
212
205
  const normalized = typeof value === "string" ? value.trim().replace(/^x-safari-https:\/\//i, "https://") : value;
213
- return normalizeUrlWithSchemes(normalized, label, ["http", "https", "shortcuts"]);
206
+ return normalizeOpenUrl(normalized, label);
214
207
  }
215
208
 
216
209
  return normalizeHttpsUrl(value, label);
@@ -807,6 +800,16 @@ const parseAction = (value, label, push = false) => {
807
800
  throw new Error(`${label} with type=open_url cannot include method or body`);
808
801
  }
809
802
 
803
+ if (!push && value.dismiss_after_action !== undefined) {
804
+ if (typeof value.dismiss_after_action !== "boolean") {
805
+ throw new Error(`${label}.dismiss_after_action must be a boolean`);
806
+ }
807
+ if (normalizedType !== "open_url") {
808
+ throw new Error(`${label}.dismiss_after_action is only supported for open_url`);
809
+ }
810
+ action.dismiss_after_action = value.dismiss_after_action;
811
+ }
812
+
810
813
  return action;
811
814
  };
812
815
 
@@ -1644,9 +1647,10 @@ addLiveActivityActionOptions(addContentStateOptions(
1644
1647
  .option("--clear-tags", "Remove all Tags from this stream")
1645
1648
  .option(
1646
1649
  "--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`,
1650
+ `${SOUND_HELP}. A new stream defaults to your Live Activities sound; updates are silent by default, and iOS plays an update sound only while the screen is on`,
1648
1651
  parseSoundOption
1649
1652
  )
1653
+ .option("--relevance-score <number>", RELEVANCE_SCORE_HELP, parseRelevanceScoreOption)
1650
1654
  .option("--metadata <json>", "Metadata JSON object shown in ActivitySmith details")
1651
1655
  .option("--metadata-file <path>", "Path to a Metadata JSON object file")
1652
1656
  .action(async (streamKey, options) => {
@@ -1664,20 +1668,23 @@ addLiveActivityActionOptions(addContentStateOptions(
1664
1668
 
1665
1669
  const response = await client.liveActivities.stream(
1666
1670
  streamKey,
1667
- withSound(
1668
- withTags(
1669
- withTargetChannels(
1670
- toApiLiveActivityStreamRequest(
1671
- contentState,
1672
- action,
1673
- secondaryAction
1671
+ withRelevanceScore(
1672
+ withSound(
1673
+ withTags(
1674
+ withTargetChannels(
1675
+ toApiLiveActivityStreamRequest(
1676
+ contentState,
1677
+ action,
1678
+ secondaryAction
1679
+ ),
1680
+ options.channels
1674
1681
  ),
1675
- options.channels
1682
+ options.clearTags ? [] : options.tags,
1683
+ await loadMetadata(options)
1676
1684
  ),
1677
- options.clearTags ? [] : options.tags,
1678
- await loadMetadata(options)
1685
+ options.sound
1679
1686
  ),
1680
- options.sound
1687
+ options.relevanceScore
1681
1688
  )
1682
1689
  );
1683
1690
 
@@ -1714,6 +1721,7 @@ addLiveActivityActionOptions(addContentStateOptions(
1714
1721
  `${SOUND_HELP} (defaults to your Live Activities sound)`,
1715
1722
  parseSoundOption
1716
1723
  )
1724
+ .option("--relevance-score <number>", RELEVANCE_SCORE_HELP, parseRelevanceScoreOption)
1717
1725
  .option("--metadata <json>", "Metadata JSON object shown in ActivitySmith details")
1718
1726
  .option("--metadata-file <path>", "Path to a Metadata JSON object file")
1719
1727
  .action(async (options) => {
@@ -1727,20 +1735,23 @@ addLiveActivityActionOptions(addContentStateOptions(
1727
1735
  const secondaryAction = await loadLiveActivitySecondaryAction(options);
1728
1736
 
1729
1737
  const response = await client.liveActivities.startLiveActivity({
1730
- liveActivityStartRequest: withSound(
1731
- withTags(
1732
- withTargetChannels(
1733
- toApiLiveActivityStartRequest(
1734
- contentState,
1735
- action,
1736
- secondaryAction
1738
+ liveActivityStartRequest: withRelevanceScore(
1739
+ withSound(
1740
+ withTags(
1741
+ withTargetChannels(
1742
+ toApiLiveActivityStartRequest(
1743
+ contentState,
1744
+ action,
1745
+ secondaryAction
1746
+ ),
1747
+ options.channels
1737
1748
  ),
1738
- options.channels
1749
+ options.tags,
1750
+ await loadMetadata(options)
1739
1751
  ),
1740
- options.tags,
1741
- await loadMetadata(options)
1752
+ options.sound
1742
1753
  ),
1743
- options.sound
1754
+ options.relevanceScore
1744
1755
  ),
1745
1756
  });
1746
1757
 
@@ -1763,6 +1774,7 @@ addLiveActivityActionOptions(addContentStateOptions(
1763
1774
  .option("--tags <tags>", "Replace Tags for this Live Activity (repeatable)", parseTagsOption)
1764
1775
  .option("--clear-tags", "Remove all Tags from this Live Activity")
1765
1776
  .option("--sound <name>", LIVE_ACTIVITY_CHANGE_SOUND_HELP, parseSoundOption)
1777
+ .option("--relevance-score <number>", RELEVANCE_SCORE_HELP, parseRelevanceScoreOption)
1766
1778
  .option("--metadata <json>", "Metadata JSON object shown in ActivitySmith details")
1767
1779
  .option("--metadata-file <path>", "Path to a Metadata JSON object file")
1768
1780
  .action(async (options) => {
@@ -1779,12 +1791,13 @@ addLiveActivityActionOptions(addContentStateOptions(
1779
1791
  const secondaryAction = await loadLiveActivitySecondaryAction(options);
1780
1792
 
1781
1793
  const response = await client.liveActivities.updateLiveActivity({
1782
- liveActivityUpdateRequest: withSound(withTags(toApiLiveActivityUpdateRequest(
1794
+ liveActivityUpdateRequest: withRelevanceScore(withSound(withTags(toApiLiveActivityUpdateRequest(
1783
1795
  options.activityId,
1784
1796
  contentState,
1785
1797
  action,
1786
1798
  secondaryAction
1787
1799
  ), options.clearTags ? [] : options.tags, await loadMetadata(options)), options.sound),
1800
+ options.relevanceScore),
1788
1801
  });
1789
1802
 
1790
1803
  outputResult(response, globalOptions, [