activitysmith-cli 0.1.8 → 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 +83 -53
  2. package/package.json +2 -2
  3. package/src/cli.js +78 -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,72 +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
152
-
153
- Channels are used to target specific team members or devices. Can be used for both push notifications and live activities.
154
-
155
- ```bash
156
- activitysmith push \
157
- --title "Build Failed 🚨" \
158
- --message "CI pipeline failed on main branch" \
159
- --channels "devs,ops"
160
- ```
204
+ ### Live Activity Action
161
205
 
162
- ### Rich Push Notifications with Media
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.
163
207
 
164
208
  <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" />
209
+ <img src="https://cdn.activitysmith.com/features/live-activity-with-action.png?v=20260319-1" alt="Live Activity with action" width="680" />
166
210
  </p>
167
211
 
212
+ #### Open URL action
213
+
168
214
  ```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"
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"}'
174
218
  ```
175
219
 
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
-
191
- ### Push Notification Redirection and Actions
192
-
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.
194
- Webhooks are executed by ActivitySmith backend.
220
+ #### Webhook action
195
221
 
196
222
  ```bash
197
- activitysmith push \
198
- --title "Build Failed 🚨" \
199
- --message "CI pipeline failed on main branch" \
200
- --redirection "https://github.com/org/repo/actions/runs/123456789" \
201
- --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"}}'
202
227
  ```
203
228
 
204
- 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.
205
232
 
206
233
  ```bash
207
234
  activitysmith push \
208
235
  --title "Build Failed 🚨" \
209
236
  --message "CI pipeline failed on main branch" \
210
- --actions-file "./actions.json"
211
- ```
212
-
213
- ### JSON Output
214
-
215
- ```bash
216
- activitysmith push --title "Hello" --json
237
+ --channels "devs,ops"
217
238
  ```
218
239
 
219
240
  ## Aliases
@@ -244,6 +265,11 @@ Or use flags to build the payload:
244
265
  - `--step-color <color>`
245
266
  - `--auto-dismiss-minutes <number>`
246
267
 
268
+ Live Activity action options:
269
+
270
+ - `--action <json>`
271
+ - `--action-file <path>`
272
+
247
273
  Targeting options:
248
274
 
249
275
  - `--channels <comma-separated-slugs>` (for `push` and `activity start`)
@@ -257,3 +283,7 @@ Required fields:
257
283
  ## Output
258
284
 
259
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.8",
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",
@@ -40,7 +40,7 @@
40
40
  "lint": "node --check src/cli.js"
41
41
  },
42
42
  "dependencies": {
43
- "activitysmith": "^0.1.8",
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,27 @@ 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
+
403
430
  const validatePushMediaOptions = ({ media, actions }) => {
404
431
  if (media === undefined || actions === undefined) {
405
432
  return;
@@ -483,9 +510,17 @@ const toApiContentState = (contentState) => {
483
510
  return mapped;
484
511
  };
485
512
 
486
- const toApiLiveActivityStartRequest = (contentState) => ({
487
- content_state: toApiContentState(contentState),
488
- });
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
+ };
489
524
 
490
525
  const withTargetChannels = (request, channels) => {
491
526
  if (!channels || channels.length === 0) {
@@ -500,15 +535,31 @@ const withTargetChannels = (request, channels) => {
500
535
  };
501
536
  };
502
537
 
503
- const toApiLiveActivityUpdateRequest = (activityId, contentState) => ({
504
- activity_id: activityId,
505
- content_state: toApiContentState(contentState),
506
- });
538
+ const toApiLiveActivityUpdateRequest = (activityId, contentState, action) => {
539
+ const request = {
540
+ activity_id: activityId,
541
+ content_state: toApiContentState(contentState),
542
+ };
543
+
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
+ };
507
556
 
508
- const toApiLiveActivityEndRequest = (activityId, contentState) => ({
509
- activity_id: activityId,
510
- content_state: toApiContentState(contentState),
511
- });
557
+ if (action !== undefined) {
558
+ request.action = action;
559
+ }
560
+
561
+ return request;
562
+ };
512
563
 
513
564
  const loadContentState = async (options, mode) => {
514
565
  let contentState = {};
@@ -727,7 +778,7 @@ const activityCommand = program
727
778
  .command("activity")
728
779
  .description("Manage Live Activities");
729
780
 
730
- addContentStateOptions(
781
+ addLiveActivityActionOptions(addContentStateOptions(
731
782
  activityCommand
732
783
  .command("start")
733
784
  .description("Start a Live Activity")
@@ -743,10 +794,11 @@ addContentStateOptions(
743
794
  const apiKey = requireApiKey(globalOptions);
744
795
  const client = createClient(apiKey);
745
796
  const contentState = await loadContentState(options, "start");
797
+ const action = await loadLiveActivityAction(options);
746
798
 
747
799
  const response = await client.liveActivities.startLiveActivity({
748
800
  liveActivityStartRequest: withTargetChannels(
749
- toApiLiveActivityStartRequest(contentState),
801
+ toApiLiveActivityStartRequest(contentState, action),
750
802
  options.channels
751
803
  ),
752
804
  });
@@ -760,9 +812,9 @@ addContentStateOptions(
760
812
  await handleError(error, globalOptions);
761
813
  }
762
814
  })
763
- );
815
+ ));
764
816
 
765
- addContentStateOptions(
817
+ addLiveActivityActionOptions(addContentStateOptions(
766
818
  activityCommand
767
819
  .command("update")
768
820
  .description("Update a Live Activity")
@@ -774,11 +826,13 @@ addContentStateOptions(
774
826
  const apiKey = requireApiKey(globalOptions);
775
827
  const client = createClient(apiKey);
776
828
  const contentState = await loadContentState(options, "update");
829
+ const action = await loadLiveActivityAction(options);
777
830
 
778
831
  const response = await client.liveActivities.updateLiveActivity({
779
832
  liveActivityUpdateRequest: toApiLiveActivityUpdateRequest(
780
833
  options.activityId,
781
- contentState
834
+ contentState,
835
+ action
782
836
  ),
783
837
  });
784
838
 
@@ -790,9 +844,9 @@ addContentStateOptions(
790
844
  await handleError(error, globalOptions);
791
845
  }
792
846
  })
793
- );
847
+ ));
794
848
 
795
- addContentStateOptions(
849
+ addLiveActivityActionOptions(addContentStateOptions(
796
850
  activityCommand
797
851
  .command("end")
798
852
  .description("End a Live Activity")
@@ -804,11 +858,13 @@ addContentStateOptions(
804
858
  const apiKey = requireApiKey(globalOptions);
805
859
  const client = createClient(apiKey);
806
860
  const contentState = await loadContentState(options, "end");
861
+ const action = await loadLiveActivityAction(options);
807
862
 
808
863
  const response = await client.liveActivities.endLiveActivity({
809
864
  liveActivityEndRequest: toApiLiveActivityEndRequest(
810
865
  options.activityId,
811
- contentState
866
+ contentState,
867
+ action
812
868
  ),
813
869
  });
814
870
 
@@ -821,7 +877,7 @@ addContentStateOptions(
821
877
  }
822
878
  }),
823
879
  { includeAutoDismiss: true }
824
- );
880
+ ));
825
881
 
826
882
  program.showHelpAfterError(true);
827
883
  program.parseAsync(process.argv);