activitysmith-cli 0.1.7 → 0.1.8

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 +29 -0
  2. package/package.json +3 -3
  3. package/src/cli.js +22 -0
package/README.md CHANGED
@@ -159,6 +159,35 @@ activitysmith push \
159
159
  --channels "devs,ops"
160
160
  ```
161
161
 
162
+ ### Rich Push Notifications with Media
163
+
164
+ <p align="center">
165
+ <img src="https://cdn.activitysmith.com/features/rich-push-notification-with-image.png" alt="Rich push notification with image" width="680" />
166
+ </p>
167
+
168
+ ```bash
169
+ activitysmith push \
170
+ --title "Homepage ready" \
171
+ --message "Your agent finished the redesign." \
172
+ --media "https://cdn.example.com/output/homepage-v2.png" \
173
+ --redirection "https://github.com/acme/web/pull/482"
174
+ ```
175
+
176
+ Send images, videos, or audio with your push notifications, press and hold to preview media directly from the notification, then tap through to open the linked content.
177
+
178
+ <p align="center">
179
+ <img src="https://cdn.activitysmith.com/features/rich-push-notification-with-audio.png" alt="Rich push notification with audio" width="680" />
180
+ </p>
181
+
182
+ What will work:
183
+
184
+ - direct image URL: `.jpg`, `.png`, `.gif`, etc.
185
+ - direct audio file URL: `.mp3`, `.m4a`, etc.
186
+ - direct video file URL: `.mp4`, `.mov`, etc.
187
+ - URL that responds with a proper media `Content-Type`, even if the path has no extension
188
+
189
+ `--media` can be combined with `--redirection`, but not with `--actions` or `--actions-file`.
190
+
162
191
  ### Push Notification Redirection and Actions
163
192
 
164
193
  Push notification redirection and actions are optional and can be used to redirect the user to a specific URL when they tap the notification or to trigger a specific action when they long-press the notification.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "activitysmith-cli",
3
- "version": "0.1.7",
3
+ "version": "0.1.8",
4
4
  "description": "Command-line interface for ActivitySmith. Send push notifications, start, update and end live activities directly from your terminal.",
5
5
  "keywords": [
6
6
  "activitysmith",
@@ -34,13 +34,13 @@
34
34
  "src"
35
35
  ],
36
36
  "engines": {
37
- "node": ">=18"
37
+ "node": ">=24"
38
38
  },
39
39
  "scripts": {
40
40
  "lint": "node --check src/cli.js"
41
41
  },
42
42
  "dependencies": {
43
- "activitysmith": "^0.1.5",
43
+ "activitysmith": "^0.1.8",
44
44
  "commander": "^12.1.0"
45
45
  }
46
46
  }
package/src/cli.js CHANGED
@@ -400,6 +400,16 @@ const loadPushActions = async (options) => {
400
400
  return actions.map(parsePushAction);
401
401
  };
402
402
 
403
+ const validatePushMediaOptions = ({ media, actions }) => {
404
+ if (media === undefined || actions === undefined) {
405
+ return;
406
+ }
407
+
408
+ if (actions.length > 0) {
409
+ throw new Error("media cannot be combined with actions");
410
+ }
411
+ };
412
+
403
413
  const buildContentStateFromOptions = (options) => {
404
414
  const contentState = {};
405
415
 
@@ -652,6 +662,10 @@ program
652
662
  .requiredOption("--title <title>", "Push title")
653
663
  .option("--message <message>", "Push message")
654
664
  .option("--subtitle <subtitle>", "Push subtitle")
665
+ .option(
666
+ "--media <url>",
667
+ "HTTPS URL for image, audio, or video shown when the notification is expanded"
668
+ )
655
669
  .option("--redirection <url>", "HTTPS URL opened when notification is tapped")
656
670
  .option("--actions <json>", "Actions JSON array (max 4)")
657
671
  .option("--actions-file <path>", "Path to actions JSON array file")
@@ -667,12 +681,20 @@ program
667
681
  const apiKey = requireApiKey(globalOptions);
668
682
  const client = createClient(apiKey);
669
683
  const actions = await loadPushActions(options);
684
+ validatePushMediaOptions({
685
+ media: options.media,
686
+ actions,
687
+ });
670
688
 
671
689
  const pushNotificationRequest = withTargetChannels(
672
690
  {
673
691
  title: options.title,
674
692
  message: options.message,
675
693
  subtitle: options.subtitle,
694
+ media:
695
+ options.media !== undefined
696
+ ? normalizeHttpsUrl(options.media, "media")
697
+ : undefined,
676
698
  redirection:
677
699
  options.redirection !== undefined
678
700
  ? normalizeHttpsUrl(options.redirection, "redirection")