activitysmith-cli 0.1.7 → 1.0.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 +86 -27
  2. package/package.json +3 -3
  3. package/src/cli.js +100 -22
package/README.md CHANGED
@@ -30,11 +30,9 @@ Set `ACTIVITYSMITH_API_KEY` or pass `--api-key`.
30
30
 
31
31
  For the skill scripts, you can also copy `skills/activitysmith/.env.example` to `skills/activitysmith/.env`.
32
32
 
33
- ## Usage
33
+ ## Push Notifications
34
34
 
35
- ```bash
36
- activitysmith --help
37
- ```
35
+ Run `activitysmith --help` to inspect available commands.
38
36
 
39
37
  ### Send Push Notification
40
38
 
@@ -44,6 +42,61 @@ activitysmith push \
44
42
  --message "CI pipeline failed on main branch"
45
43
  ```
46
44
 
45
+ ### Rich Push Notifications with Media
46
+
47
+ <p align="center">
48
+ <img src="https://cdn.activitysmith.com/features/rich-push-notification-with-image.png" alt="Rich push notification with image" width="680" />
49
+ </p>
50
+
51
+ ```bash
52
+ activitysmith push \
53
+ --title "Homepage ready" \
54
+ --message "Your agent finished the redesign." \
55
+ --media "https://cdn.example.com/output/homepage-v2.png" \
56
+ --redirection "https://github.com/acme/web/pull/482"
57
+ ```
58
+
59
+ 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.
60
+
61
+ <p align="center">
62
+ <img src="https://cdn.activitysmith.com/features/rich-push-notification-with-audio.png" alt="Rich push notification with audio" width="680" />
63
+ </p>
64
+
65
+ What will work:
66
+
67
+ - direct image URL: `.jpg`, `.png`, `.gif`, etc.
68
+ - direct audio file URL: `.mp3`, `.m4a`, etc.
69
+ - direct video file URL: `.mp4`, `.mov`, etc.
70
+ - URL that responds with a proper media `Content-Type`, even if the path has no extension
71
+
72
+ `--media` can be combined with `--redirection`, but not with `--actions` or `--actions-file`.
73
+
74
+ ### Actionable Push Notifications
75
+
76
+ <p align="center">
77
+ <img src="https://cdn.activitysmith.com/features/actionable-push-notifications-2.png" alt="Actionable push notification example" width="680" />
78
+ </p>
79
+
80
+ Actionable push notifications can open a URL on tap or trigger actions when someone long-presses the notification.
81
+ Webhooks are executed by the ActivitySmith backend.
82
+
83
+ ```bash
84
+ activitysmith push \
85
+ --title "Build Failed 🚨" \
86
+ --message "CI pipeline failed on main branch" \
87
+ --redirection "https://github.com/org/repo/actions/runs/123456789" \
88
+ --actions '[{"title":"Open Failing Run","type":"open_url","url":"https://github.com/org/repo/actions/runs/123456789"},{"title":"Create Incident","type":"webhook","url":"https://hooks.example.com/incidents/create","method":"POST","body":{"service":"payments-api","severity":"high","source":"activitysmith-cli"}}]'
89
+ ```
90
+
91
+ You can also load actions from a file:
92
+
93
+ ```bash
94
+ activitysmith push \
95
+ --title "Build Failed 🚨" \
96
+ --message "CI pipeline failed on main branch" \
97
+ --actions-file "./actions.json"
98
+ ```
99
+
47
100
  ## Live Activities
48
101
 
49
102
  Live Activities come in two UI types, but the lifecycle stays the same:
@@ -148,43 +201,40 @@ activitysmith activity end \
148
201
  --content-state '{"title":"EV Charging","subtitle":"Added 200 mi range","percentage":100,"autoDismissMinutes":2}'
149
202
  ```
150
203
 
151
- ### Channels
204
+ ### Live Activity Action
152
205
 
153
- Channels are used to target specific team members or devices. Can be used for both push notifications and live activities.
206
+ Just like Actionable Push Notifications, Live Activities can have a button that opens provided URL in a browser or triggers a webhook. Webhooks are executed by the ActivitySmith backend.
207
+
208
+ <p align="center">
209
+ <img src="https://cdn.activitysmith.com/features/live-activity-with-action.png?v=20260319-1" alt="Live Activity with action" width="680" />
210
+ </p>
211
+
212
+ #### Open URL action
154
213
 
155
214
  ```bash
156
- activitysmith push \
157
- --title "Build Failed 🚨" \
158
- --message "CI pipeline failed on main branch" \
159
- --channels "devs,ops"
215
+ activitysmith activity start \
216
+ --content-state '{"title":"Deploying payments-api","subtitle":"Running database migrations","numberOfSteps":5,"currentStep":3,"type":"segmented_progress"}' \
217
+ --action '{"title":"Open Workflow","type":"open_url","url":"https://github.com/acme/payments-api/actions/runs/1234567890"}'
160
218
  ```
161
219
 
162
- ### Push Notification Redirection and Actions
163
-
164
- 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.
165
- Webhooks are executed by ActivitySmith backend.
220
+ #### Webhook action
166
221
 
167
222
  ```bash
168
- activitysmith push \
169
- --title "Build Failed 🚨" \
170
- --message "CI pipeline failed on main branch" \
171
- --redirection "https://github.com/org/repo/actions/runs/123456789" \
172
- --actions '[{"title":"Open Failing Run","type":"open_url","url":"https://github.com/org/repo/actions/runs/123456789"},{"title":"Create Incident","type":"webhook","url":"https://hooks.example.com/incidents/create","method":"POST","body":{"service":"payments-api","severity":"high","source":"activitysmith-cli"}}]'
223
+ activitysmith activity update \
224
+ --activity-id "<activityId>" \
225
+ --content-state '{"title":"Reindexing product search","subtitle":"Shard 7 of 12","numberOfSteps":12,"currentStep":7}' \
226
+ --action '{"title":"Pause Reindex","type":"webhook","url":"https://ops.example.com/hooks/search/reindex/pause","method":"POST","body":{"job_id":"reindex-2026-03-19","requested_by":"activitysmith-cli"}}'
173
227
  ```
174
228
 
175
- You can also load actions from a file:
229
+ ## Channels
230
+
231
+ Channels are used to target specific team members or devices. Can be used for both push notifications and live activities.
176
232
 
177
233
  ```bash
178
234
  activitysmith push \
179
235
  --title "Build Failed 🚨" \
180
236
  --message "CI pipeline failed on main branch" \
181
- --actions-file "./actions.json"
182
- ```
183
-
184
- ### JSON Output
185
-
186
- ```bash
187
- activitysmith push --title "Hello" --json
237
+ --channels "devs,ops"
188
238
  ```
189
239
 
190
240
  ## Aliases
@@ -215,6 +265,11 @@ Or use flags to build the payload:
215
265
  - `--step-color <color>`
216
266
  - `--auto-dismiss-minutes <number>`
217
267
 
268
+ Live Activity action options:
269
+
270
+ - `--action <json>`
271
+ - `--action-file <path>`
272
+
218
273
  Targeting options:
219
274
 
220
275
  - `--channels <comma-separated-slugs>` (for `push` and `activity start`)
@@ -228,3 +283,7 @@ Required fields:
228
283
  ## Output
229
284
 
230
285
  Use `--json` for machine-readable output.
286
+
287
+ ```bash
288
+ activitysmith push --title "Hello" --json
289
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "activitysmith-cli",
3
- "version": "0.1.7",
3
+ "version": "1.0.0",
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": "^1.0.0",
44
44
  "commander": "^12.1.0"
45
45
  }
46
46
  }
package/src/cli.js CHANGED
@@ -119,6 +119,11 @@ const addContentStateOptions = (command, { includeAutoDismiss } = {}) => {
119
119
  return command;
120
120
  };
121
121
 
122
+ const addLiveActivityActionOptions = (command) =>
123
+ command
124
+ .option("--action <json>", "Live Activity action as JSON object")
125
+ .option("--action-file <path>", "Live Activity action JSON file path");
126
+
122
127
  const getApiKey = (options) =>
123
128
  options.apiKey || process.env.ACTIVITYSMITH_API_KEY;
124
129
 
@@ -325,8 +330,7 @@ const validateContentState = (contentState, mode) => {
325
330
  }
326
331
  };
327
332
 
328
- const parsePushAction = (value, index) => {
329
- const label = `actions[${index}]`;
333
+ const parseAction = (value, label) => {
330
334
  assertPlainObject(value, label);
331
335
 
332
336
  if (typeof value.title !== "string" || value.title.trim().length === 0) {
@@ -371,6 +375,8 @@ const parsePushAction = (value, index) => {
371
375
  return action;
372
376
  };
373
377
 
378
+ const parsePushAction = (value, index) => parseAction(value, `actions[${index}]`);
379
+
374
380
  const loadPushActions = async (options) => {
375
381
  if (options.actions && options.actionsFile) {
376
382
  throw new Error("Provide either --actions or --actions-file, not both.");
@@ -400,6 +406,37 @@ const loadPushActions = async (options) => {
400
406
  return actions.map(parsePushAction);
401
407
  };
402
408
 
409
+ const loadLiveActivityAction = async (options) => {
410
+ if (options.action && options.actionFile) {
411
+ throw new Error("Provide either --action or --action-file, not both.");
412
+ }
413
+
414
+ let action;
415
+ if (options.actionFile) {
416
+ action = await readJsonFile(options.actionFile, "action-file");
417
+ }
418
+
419
+ if (options.action) {
420
+ action = parseJsonString(options.action, "action");
421
+ }
422
+
423
+ if (action === undefined) {
424
+ return undefined;
425
+ }
426
+
427
+ return parseAction(action, "action");
428
+ };
429
+
430
+ const validatePushMediaOptions = ({ media, actions }) => {
431
+ if (media === undefined || actions === undefined) {
432
+ return;
433
+ }
434
+
435
+ if (actions.length > 0) {
436
+ throw new Error("media cannot be combined with actions");
437
+ }
438
+ };
439
+
403
440
  const buildContentStateFromOptions = (options) => {
404
441
  const contentState = {};
405
442
 
@@ -473,9 +510,17 @@ const toApiContentState = (contentState) => {
473
510
  return mapped;
474
511
  };
475
512
 
476
- const toApiLiveActivityStartRequest = (contentState) => ({
477
- content_state: toApiContentState(contentState),
478
- });
513
+ const toApiLiveActivityStartRequest = (contentState, action) => {
514
+ const request = {
515
+ content_state: toApiContentState(contentState),
516
+ };
517
+
518
+ if (action !== undefined) {
519
+ request.action = action;
520
+ }
521
+
522
+ return request;
523
+ };
479
524
 
480
525
  const withTargetChannels = (request, channels) => {
481
526
  if (!channels || channels.length === 0) {
@@ -490,15 +535,31 @@ const withTargetChannels = (request, channels) => {
490
535
  };
491
536
  };
492
537
 
493
- const toApiLiveActivityUpdateRequest = (activityId, contentState) => ({
494
- activity_id: activityId,
495
- content_state: toApiContentState(contentState),
496
- });
538
+ const toApiLiveActivityUpdateRequest = (activityId, contentState, action) => {
539
+ const request = {
540
+ activity_id: activityId,
541
+ content_state: toApiContentState(contentState),
542
+ };
497
543
 
498
- const toApiLiveActivityEndRequest = (activityId, contentState) => ({
499
- activity_id: activityId,
500
- content_state: toApiContentState(contentState),
501
- });
544
+ if (action !== undefined) {
545
+ request.action = action;
546
+ }
547
+
548
+ return request;
549
+ };
550
+
551
+ const toApiLiveActivityEndRequest = (activityId, contentState, action) => {
552
+ const request = {
553
+ activity_id: activityId,
554
+ content_state: toApiContentState(contentState),
555
+ };
556
+
557
+ if (action !== undefined) {
558
+ request.action = action;
559
+ }
560
+
561
+ return request;
562
+ };
502
563
 
503
564
  const loadContentState = async (options, mode) => {
504
565
  let contentState = {};
@@ -652,6 +713,10 @@ program
652
713
  .requiredOption("--title <title>", "Push title")
653
714
  .option("--message <message>", "Push message")
654
715
  .option("--subtitle <subtitle>", "Push subtitle")
716
+ .option(
717
+ "--media <url>",
718
+ "HTTPS URL for image, audio, or video shown when the notification is expanded"
719
+ )
655
720
  .option("--redirection <url>", "HTTPS URL opened when notification is tapped")
656
721
  .option("--actions <json>", "Actions JSON array (max 4)")
657
722
  .option("--actions-file <path>", "Path to actions JSON array file")
@@ -667,12 +732,20 @@ program
667
732
  const apiKey = requireApiKey(globalOptions);
668
733
  const client = createClient(apiKey);
669
734
  const actions = await loadPushActions(options);
735
+ validatePushMediaOptions({
736
+ media: options.media,
737
+ actions,
738
+ });
670
739
 
671
740
  const pushNotificationRequest = withTargetChannels(
672
741
  {
673
742
  title: options.title,
674
743
  message: options.message,
675
744
  subtitle: options.subtitle,
745
+ media:
746
+ options.media !== undefined
747
+ ? normalizeHttpsUrl(options.media, "media")
748
+ : undefined,
676
749
  redirection:
677
750
  options.redirection !== undefined
678
751
  ? normalizeHttpsUrl(options.redirection, "redirection")
@@ -705,7 +778,7 @@ const activityCommand = program
705
778
  .command("activity")
706
779
  .description("Manage Live Activities");
707
780
 
708
- addContentStateOptions(
781
+ addLiveActivityActionOptions(addContentStateOptions(
709
782
  activityCommand
710
783
  .command("start")
711
784
  .description("Start a Live Activity")
@@ -721,10 +794,11 @@ addContentStateOptions(
721
794
  const apiKey = requireApiKey(globalOptions);
722
795
  const client = createClient(apiKey);
723
796
  const contentState = await loadContentState(options, "start");
797
+ const action = await loadLiveActivityAction(options);
724
798
 
725
799
  const response = await client.liveActivities.startLiveActivity({
726
800
  liveActivityStartRequest: withTargetChannels(
727
- toApiLiveActivityStartRequest(contentState),
801
+ toApiLiveActivityStartRequest(contentState, action),
728
802
  options.channels
729
803
  ),
730
804
  });
@@ -738,9 +812,9 @@ addContentStateOptions(
738
812
  await handleError(error, globalOptions);
739
813
  }
740
814
  })
741
- );
815
+ ));
742
816
 
743
- addContentStateOptions(
817
+ addLiveActivityActionOptions(addContentStateOptions(
744
818
  activityCommand
745
819
  .command("update")
746
820
  .description("Update a Live Activity")
@@ -752,11 +826,13 @@ addContentStateOptions(
752
826
  const apiKey = requireApiKey(globalOptions);
753
827
  const client = createClient(apiKey);
754
828
  const contentState = await loadContentState(options, "update");
829
+ const action = await loadLiveActivityAction(options);
755
830
 
756
831
  const response = await client.liveActivities.updateLiveActivity({
757
832
  liveActivityUpdateRequest: toApiLiveActivityUpdateRequest(
758
833
  options.activityId,
759
- contentState
834
+ contentState,
835
+ action
760
836
  ),
761
837
  });
762
838
 
@@ -768,9 +844,9 @@ addContentStateOptions(
768
844
  await handleError(error, globalOptions);
769
845
  }
770
846
  })
771
- );
847
+ ));
772
848
 
773
- addContentStateOptions(
849
+ addLiveActivityActionOptions(addContentStateOptions(
774
850
  activityCommand
775
851
  .command("end")
776
852
  .description("End a Live Activity")
@@ -782,11 +858,13 @@ addContentStateOptions(
782
858
  const apiKey = requireApiKey(globalOptions);
783
859
  const client = createClient(apiKey);
784
860
  const contentState = await loadContentState(options, "end");
861
+ const action = await loadLiveActivityAction(options);
785
862
 
786
863
  const response = await client.liveActivities.endLiveActivity({
787
864
  liveActivityEndRequest: toApiLiveActivityEndRequest(
788
865
  options.activityId,
789
- contentState
866
+ contentState,
867
+ action
790
868
  ),
791
869
  });
792
870
 
@@ -799,7 +877,7 @@ addContentStateOptions(
799
877
  }
800
878
  }),
801
879
  { includeAutoDismiss: true }
802
- );
880
+ ));
803
881
 
804
882
  program.showHelpAfterError(true);
805
883
  program.parseAsync(process.argv);