activitysmith-cli 1.10.0 → 1.12.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
@@ -1,31 +1,10 @@
1
1
  # ActivitySmith CLI
2
2
 
3
- CLI wrapper for the ActivitySmith API using the official Node SDK.
4
-
5
- ## Table of Contents
6
-
7
- - [Install](#install)
8
- - [Agent Skill](#agent-skill)
9
- - [Auth](#auth)
10
- - [Push Notifications](#push-notifications)
11
- - [Send Push Notification](#send-push-notification)
12
- - [Rich Push Notifications with Media](#rich-push-notifications-with-media)
13
- - [Actionable Push Notifications](#actionable-push-notifications)
14
- - [Live Activities](#live-activities)
15
- - [Start & Update Live Activity](#start--update-live-activity)
16
- - [End Live Activity](#end-live-activity)
17
- - [Live Activity Action](#live-activity-action)
18
- - [Icons and Badges](#icons-and-badges)
19
- - [Live Activity Colors](#live-activity-colors)
20
- - [Widgets](#widgets)
21
- - [App Icon Badge Count](#app-icon-badge-count)
22
- - [Channels](#channels)
23
- - [Tags](#tags)
24
- - [Aliases](#aliases)
25
- - [Content State Options](#content-state-options)
26
- - [Output](#output)
27
-
28
- ## Install
3
+ [Documentation](https://activitysmith.com/docs/sdks/cli)
4
+
5
+ ## Installation
6
+
7
+ Install the ActivitySmith CLI globally with npm:
29
8
 
30
9
  ```bash
31
10
  npm install -g activitysmith-cli
@@ -33,79 +12,65 @@ npm install -g activitysmith-cli
33
12
 
34
13
  ## Agent Skill
35
14
 
36
- <p align="center">
37
- <img src="https://cdn.activitysmith.com/features/apple-shortcut-actions.png" alt="ActivitySmith Push Notification Actions with an Apple Shortcut action" width="680" />
38
- </p>
15
+ Install the ActivitySmith skill when you want Codex, Claude, Cursor, or another skills-compatible agent to decide which ActivitySmith CLI command to run.
39
16
 
40
- The ActivitySmith skill helps coding agents decide when and how to notify you.
17
+ ```bash
18
+ npx -y skills@latest add ActivitySmithHQ/activitysmith-cli --skill activitysmith
19
+ ```
41
20
 
42
- Use it for prompts like:
21
+ Use the skill when an agent should notify you with Push Notifications, include a notification tap or action that can open a URL or run a specific iOS Shortcut, or keep task progress visible with Live Activities.
43
22
 
44
- - "Notify me when you're done."
45
- - "Send me a push notification if you get blocked."
46
- - "When the task finishes, the notification tap should run my Test Shortcut."
47
- - "Show progress on my Lock Screen while you work."
23
+ For example, a Codex agent can work on your computer, send a Push Notification when it needs your attention, and include a Shortcut action that runs an `OpenChatGPT` Shortcut on your iPhone so you can continue the conversation in the ChatGPT app.
48
24
 
49
- The skill maps those requests to the CLI:
25
+ ## Quickstart
50
26
 
51
- - Push Notifications for completion, blockers, and review requests
52
- - `shortcuts://` redirection for a specific iPhone Shortcut
53
- - action buttons for follow-up links or Shortcut buttons
54
- - Live Activities for long-running progress
55
- - widget metrics for values that should stay visible
56
- - App Icon Badge Counts for a number that should stay on the app icon
27
+ 1. [Create an API key](https://activitysmith.com/app/keys)
28
+ 2. Authenticate with `ACTIVITYSMITH_API_KEY` or pass `--api-key` per command.
29
+ 3. Run `activitysmith --help` to inspect available commands.
57
30
 
58
- Install the public skill from this repo:
31
+ Use the environment variable when you want the cleanest shell scripts:
59
32
 
60
33
  ```bash
61
- npx -y skills@latest add ActivitySmithHQ/activitysmith-cli --skill activitysmith
62
- ```
34
+ export ACTIVITYSMITH_API_KEY="YOUR-API-KEY"
63
35
 
64
- Skill path in this repo:
65
-
66
- ```text
67
- skills/activitysmith
36
+ activitysmith --help
68
37
  ```
69
38
 
70
- The skill is agent-neutral and recipe-driven. It uses `ACTIVITYSMITH_API_KEY` auth plus the same CLI commands shown below.
71
-
72
- ## Auth
39
+ Or pass the key directly:
73
40
 
74
- Set `ACTIVITYSMITH_API_KEY` or pass `--api-key`.
75
-
76
- For the skill scripts, you can also copy `skills/activitysmith/.env.example` to `skills/activitysmith/.env`.
41
+ ```bash
42
+ activitysmith --api-key "YOUR-API-KEY" push --title "Hello"
43
+ ```
77
44
 
78
45
  ## Push Notifications
79
46
 
80
- Run `activitysmith --help` to inspect available commands.
47
+ ### Send a Push Notification
48
+
49
+ Send an immediate notification for a completed task or event.
81
50
 
82
- ### Send Push Notification
51
+ ![Push Notification example](https://cdn.activitysmith.com/printkit/notification.png)
83
52
 
84
53
  ```bash
85
54
  activitysmith push \
86
55
  --title "Build Failed 🚨" \
87
- --message "CI pipeline failed on main branch"
56
+ --message "CI pipeline failed on main branch" \
57
+ --subtitle "main"
88
58
  ```
89
59
 
90
60
  ### Rich Push Notifications with Media
91
61
 
92
- <p align="center">
93
- <img src="https://cdn.activitysmith.com/features/rich-push-notification-with-image.png" alt="Rich push notification with image" width="680" />
94
- </p>
62
+ ![Rich Push Notification with image](https://cdn.activitysmith.com/features/rich-push-notification-with-image.png)
95
63
 
96
64
  ```bash
97
65
  activitysmith push \
98
66
  --title "Homepage ready" \
99
67
  --message "Your agent finished the redesign." \
100
- --media "https://cdn.example.com/output/homepage-v2.png" \
101
- --redirection "https://github.com/acme/web/pull/482"
68
+ --media "https://cdn.example.com/output/homepage-v2.png"
102
69
  ```
103
70
 
104
- 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.
71
+ Attach images, videos, or audio to your Push Notifications. Press and hold the notification to preview the media.
105
72
 
106
- <p align="center">
107
- <img src="https://cdn.activitysmith.com/features/rich-push-notification-with-audio.png" alt="Rich push notification with audio" width="680" />
108
- </p>
73
+ ![Rich Push Notification with audio](https://cdn.activitysmith.com/features/rich-push-notification-with-audio.png)
109
74
 
110
75
  What will work:
111
76
 
@@ -114,25 +79,50 @@ What will work:
114
79
  - direct video file URL: `.mp4`, `.mov`, etc.
115
80
  - URL that responds with a proper media `Content-Type`, even if the path has no extension
116
81
 
117
- `--media` can be combined with `--redirection`, but not with `--actions` or `--actions-file`.
82
+ `--media` cannot be combined with `--actions`.
83
+
84
+ ### Push Notifications with Redirection
85
+
86
+ Open a web page, run an iOS Shortcut, or open an app when someone taps the notification. `--redirection` supports:
87
+
88
+ - **HTTP/HTTPS:** Web pages, e.g. `https://example.com`
89
+ - **Shortcuts:** Run Jarvis with `shortcuts://run-shortcut?name=Jarvis` <!-- full-width -->
90
+ - **App deep links:** Installed apps or specific content within them
91
+ - **Spotify:** A track, e.g. `spotify:track:6rqhFgbbKwnb9MLmUQDhG6`
92
+ - **Termius:** `termius://` to open the app
93
+ - **Claude:** `claude://code` to open the Code tab
94
+ - **ChatGPT:** `chatgpt://` to open the app <!-- Verify ChatGPT URL scheme on iOS before publishing -->
95
+
96
+ ```bash
97
+ activitysmith push \
98
+ --title "Homepage ready" \
99
+ --message "Your agent finished the redesign." \
100
+ --redirection "https://github.com/acme/web/pull/482"
101
+ ```
118
102
 
119
103
  ### Actionable Push Notifications
120
104
 
121
- <p align="center">
122
- <img src="https://cdn.activitysmith.com/features/actionable-push-notifications-2.png" alt="Actionable push notification example" width="680" />
123
- </p>
105
+ ![Actionable Push Notification with redirection and actions](https://cdn.activitysmith.com/features/actionable-push-notifications-2.png)
124
106
 
125
- Push notification `--redirection` and `--actions` are optional. Use them to open HTTPS URLs, run a specific iPhone Shortcut with a `shortcuts://run-shortcut?name=...` URL, or trigger backend webhook workflows.
126
- Webhooks are executed by the ActivitySmith backend.
107
+ `open_url` actions open a web page, run an iOS Shortcut, or open an app when someone taps the button. Supported links:
108
+
109
+ - **HTTP/HTTPS:** Web pages, e.g. `https://example.com`
110
+ - **Shortcuts:** Run Jarvis with `shortcuts://run-shortcut?name=Jarvis` <!-- full-width -->
111
+ - **App deep links:** Installed apps or specific content within them
112
+ - **Spotify:** A track, e.g. `spotify:track:6rqhFgbbKwnb9MLmUQDhG6`
113
+ - **Termius:** `termius://` to open the app
114
+ - **Claude:** `claude://code` to open the Code tab
115
+ - **ChatGPT:** `chatgpt://` to open the app <!-- Verify ChatGPT URL scheme on iOS before publishing -->
116
+
117
+ Webhooks are executed by the ActivitySmith backend and must use HTTPS.
127
118
 
128
119
  ```bash
129
120
  activitysmith push \
130
121
  --title "Build Failed 🚨" \
131
122
  --message "CI pipeline failed on main branch" \
132
- --redirection "https://github.com/org/repo/actions/runs/123456789" \
133
123
  --actions '[
134
124
  {
135
- "title": "Open Failing Run",
125
+ "title": "Open Build",
136
126
  "type": "open_url",
137
127
  "url": "https://github.com/org/repo/actions/runs/123456789"
138
128
  },
@@ -155,7 +145,7 @@ activitysmith push \
155
145
  ]'
156
146
  ```
157
147
 
158
- You can also load actions from a file:
148
+ You can also save the JSON array above as `actions.json` and load it from a file:
159
149
 
160
150
  ```bash
161
151
  activitysmith push \
@@ -166,28 +156,47 @@ activitysmith push \
166
156
 
167
157
  ## Live Activities
168
158
 
169
- There are six types of Live Activities:
159
+ Choose the Live Activity type that matches what you want to show:
160
+
161
+ - ![Value Live Activity showing revenue with a growth badge](https://cdn.activitysmith.com/features/value-live-activity.png) **Value**: Show a single value on your Lock Screen, such as revenue, a queue count, or a temperature.
170
162
 
171
- - `stats`: best for showing business numbers side by side, such as revenue, sales, new users, conversion, refunds, or any other value you want visible at a glance
172
- - `metrics`: best for live percentage values that change often, like server CPU, memory usage, disk usage, or error rate
173
- - `segmented_progress`: best for anything that moves through clear stages, like deployments, onboarding flows, backups, ETL pipelines, migrations, and AI agent runs
174
- - `progress`: best for tracking real-time progress with percentage, like tasks, backups, migrations, syncs, or uploads
175
- - `alert`: best for status updates, such as feature adoption, reactivation, onboarding blockers, incidents, escalations, and other operational states
176
- - `timer`: best for countdowns and elapsed runtime, like benchmark runs, uploads, backups, transcodes, and long-running jobs
163
+ - ![Stats Live Activity with six labeled sales metrics](https://cdn.activitysmith.com/features/stats-live-activity.png) **Stats**: Show up to 8 labeled values on your Lock Screen, from revenue and orders to uptime and conversion.
164
+
165
+ - ![Alert Live Activity showing a customer reactivation update](https://cdn.activitysmith.com/features/alert-live-activity.png) **Alert**: Show status updates with a clear message, badge, and icon. When you add an action button, `color` controls the button tint.
166
+
167
+ - ![Metrics Live Activity with CPU and memory values](https://cdn.activitysmith.com/features/metrics-live-activity-start.png) **Metrics**: Track two related values with segmented bars, such as CPU and memory.
168
+
169
+ - ![Segmented Progress Live Activity showing a workflow step](https://cdn.activitysmith.com/features/update-live-activity.png) **Segmented Progress**: Show progress through a known set of steps, like build, test, deploy, and verify.
170
+
171
+ - ![Progress Live Activity showing percentage completion](https://cdn.activitysmith.com/features/progress-live-activity.png) **Progress**: Show percentage progress for jobs that move continuously toward completion.
172
+
173
+ - ![Timer Live Activity showing a benchmark run countdown](https://cdn.activitysmith.com/features/timer-live-activity.png) **Timer**: Count down from a duration, or count up from 00:00 while a job runs.
177
174
 
178
175
  ### Start & Update Live Activity
179
176
 
180
177
  Use a stable `stream_key` to identify the metric, job, deployment, or system you want to keep visible. The first `activity stream` command starts the Live Activity. Later commands with the same `stream_key` update it.
181
178
 
179
+ #### Value
180
+
181
+ ![Value Live Activity stream example](https://cdn.activitysmith.com/features/value-live-activity.png)
182
+
183
+ ```bash
184
+ activitysmith activity stream revenue-today \
185
+ --content-state '{
186
+ "title": "Revenue",
187
+ "type": "value",
188
+ "value": "$1,240",
189
+ "color": "green",
190
+ "icon": { "symbol": "dollarsign.circle", "color": "green" },
191
+ "badge": { "title": "↑ 18%", "color": "purple" }
192
+ }'
193
+ ```
194
+
195
+ Send a string or number in `value`. Strings keep their formatting, including currency symbols, units, and decimal places.
196
+
182
197
  #### Stats
183
198
 
184
- <p align="center">
185
- <img
186
- src="https://cdn.activitysmith.com/features/stats-live-activity.png"
187
- alt="Stats Live Activity stream example"
188
- width="680"
189
- />
190
- </p>
199
+ ![Stats Live Activity stream example](https://cdn.activitysmith.com/features/stats-live-activity.png)
191
200
 
192
201
  ```bash
193
202
  activitysmith activity stream sales-hourly \
@@ -206,15 +215,30 @@ activitysmith activity stream sales-hourly \
206
215
  }'
207
216
  ```
208
217
 
218
+ #### Alert
219
+
220
+ ![Alert Live Activity stream example](https://cdn.activitysmith.com/features/alert-live-activity.png)
221
+
222
+ ```bash
223
+ activitysmith activity stream customer-ops \
224
+ --content-state '{
225
+ "title": "Reactivation",
226
+ "message": "Lumen came back after 2 weeks",
227
+ "type": "alert",
228
+ "icon": {
229
+ "symbol": "cloud.sun",
230
+ "color": "yellow"
231
+ },
232
+ "badge": {
233
+ "title": "Customer",
234
+ "color": "magenta"
235
+ }
236
+ }'
237
+ ```
238
+
209
239
  #### Metrics
210
240
 
211
- <p align="center">
212
- <img
213
- src="https://cdn.activitysmith.com/features/metrics-live-activity-start.png"
214
- alt="Metrics Live Activity stream example"
215
- width="680"
216
- />
217
- </p>
241
+ ![Metrics Live Activity stream example](https://cdn.activitysmith.com/features/metrics-live-activity-start.png)
218
242
 
219
243
  ```bash
220
244
  activitysmith activity stream prod-web-1 \
@@ -231,13 +255,7 @@ activitysmith activity stream prod-web-1 \
231
255
 
232
256
  #### Segmented Progress
233
257
 
234
- <p align="center">
235
- <img
236
- src="https://cdn.activitysmith.com/features/update-live-activity.png"
237
- alt="Segmented Progress Live Activity stream example"
238
- width="680"
239
- />
240
- </p>
258
+ ![Segmented Progress Live Activity stream example](https://cdn.activitysmith.com/features/update-live-activity.png)
241
259
 
242
260
  ```bash
243
261
  activitysmith activity stream nightly-backup \
@@ -252,13 +270,7 @@ activitysmith activity stream nightly-backup \
252
270
 
253
271
  #### Progress
254
272
 
255
- <p align="center">
256
- <img
257
- src="https://cdn.activitysmith.com/features/progress-live-activity.png"
258
- alt="Progress Live Activity stream example"
259
- width="680"
260
- />
261
- </p>
273
+ ![Progress Live Activity stream example](https://cdn.activitysmith.com/features/progress-live-activity.png)
262
274
 
263
275
  ```bash
264
276
  activitysmith activity stream search-reindex \
@@ -270,42 +282,9 @@ activitysmith activity stream search-reindex \
270
282
  }'
271
283
  ```
272
284
 
273
- #### Alert
274
-
275
- <p align="center">
276
- <img
277
- src="https://cdn.activitysmith.com/features/alert-live-activity.png"
278
- alt="Alert Live Activity stream example"
279
- width="680"
280
- />
281
- </p>
282
-
283
- ```bash
284
- activitysmith activity stream customer-ops \
285
- --content-state '{
286
- "title": "Reactivation",
287
- "message": "Lumen came back after 2 weeks",
288
- "type": "alert",
289
- "icon": {
290
- "symbol": "cloud.sun",
291
- "color": "yellow"
292
- },
293
- "badge": {
294
- "title": "Customer",
295
- "color": "magenta"
296
- }
297
- }'
298
- ```
299
-
300
285
  #### Timer
301
286
 
302
- <p align="center">
303
- <img
304
- src="https://cdn.activitysmith.com/features/timer-live-activity.png"
305
- alt="Timer Live Activity showing a benchmark run countdown"
306
- width="680"
307
- />
308
- </p>
287
+ ![Timer Live Activity stream example](https://cdn.activitysmith.com/features/timer-live-activity.png)
309
288
 
310
289
  ```bash
311
290
  activitysmith activity stream benchmark-run \
@@ -318,16 +297,17 @@ activitysmith activity stream benchmark-run \
318
297
  }'
319
298
  ```
320
299
 
321
- For a countdown, send `duration_seconds`. You can update `title`, `subtitle`, `color`, or any other visible field as the work changes. Leave `duration_seconds` out unless you want to change the timer.
300
+ For a countdown, send `durationSeconds`. Leave it out on later stream updates to preserve the running timer. Supplying a new duration restarts the countdown.
322
301
 
323
- To start at 00:00 and count up, set `counts_down: false` and leave out `duration_seconds`.
302
+ To start at 00:00 and count up, set `countsDown` to `false` and leave out `durationSeconds`.
324
303
 
325
304
  ### End Live Activity
326
305
 
327
- Call `activity end-stream` with the same `stream_key` to dismiss the Live Activity. You can include final values before it is removed. By default, iOS removes the Live Activity after two minutes. Set `autoDismissMinutes` to choose a different dismissal time, including `0` for immediate dismissal.
306
+ 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`.
328
307
 
329
308
  ```bash
330
309
  activitysmith activity end-stream prod-web-1 \
310
+ --auto-dismiss-seconds 30 \
331
311
  --content-state '{
332
312
  "title": "Server Health",
333
313
  "subtitle": "prod-web-1",
@@ -335,29 +315,66 @@ activitysmith activity end-stream prod-web-1 \
335
315
  "metrics": [
336
316
  { "label": "CPU", "value": 7, "unit": "%" },
337
317
  { "label": "MEM", "value": 38, "unit": "%" }
318
+ ]
319
+ }'
320
+ ```
321
+
322
+ ### Icons and Badges
323
+
324
+ Add more context to Live Activities with icons and badges.
325
+
326
+ #### Icon
327
+
328
+ ```bash
329
+ activitysmith activity stream prod-web-1 \
330
+ --content-state '{
331
+ "title": "Server Health",
332
+ "type": "metrics",
333
+ "metrics": [
334
+ { "label": "CPU", "value": 18, "unit": "%" },
335
+ { "label": "MEM", "value": 42, "unit": "%" }
338
336
  ],
339
- "autoDismissMinutes": 2
337
+ "icon": { "symbol": "server.rack", "color": "blue" }
340
338
  }'
341
339
  ```
342
340
 
341
+ The `icon.symbol` value is an Apple SF Symbol name. Browse the catalog in the ActivitySmith iOS app under Settings > SF Symbols.
342
+
343
+ #### Badge
344
+
345
+ ```bash
346
+ activitysmith activity stream nightly-backup \
347
+ --content-state '{
348
+ "title": "Nightly Database Backup",
349
+ "type": "segmented_progress",
350
+ "numberOfSteps": 3,
351
+ "currentStep": 2,
352
+ "badge": { "title": "S3", "color": "cyan" }
353
+ }'
354
+ ```
355
+
356
+ ### Live Activity Colors
357
+
358
+ Choose from these colors for the Live Activity accent, including progress bars and action buttons, or apply them to an individual icon or badge:
359
+
360
+ `lime`, `green`, `cyan`, `blue`, `purple`, `magenta`, `red`, `orange`, `yellow`, `gray`
361
+
343
362
  ### Live Activity Action
344
363
 
345
- Live Activities can include an action button.
364
+ ![Metrics Live Activity with action](https://cdn.activitysmith.com/features/metrics-live-activity-action.png)
346
365
 
347
- - `open_url`: open an HTTPS URL.
348
- - `open_url` with a `shortcuts://` URL: run an Apple Shortcut, for example to open an app.
349
- - `webhook`: trigger a backend GET/POST workflow.
366
+ Live Activities can include an action button.
350
367
 
351
- <p align="center">
352
- <img
353
- src="https://cdn.activitysmith.com/features/metrics-live-activity-action.png"
354
- alt="Live Activity with action button"
355
- width="680"
356
- />
357
- </p>
368
+ - `open_url`: Open a web page or run an iOS Shortcut
369
+ - `webhook`: Trigger a backend GET/POST workflow
358
370
 
359
371
  #### Open URL action
360
372
 
373
+ Open a web page or run an iOS Shortcut when someone taps the button. Supported links:
374
+
375
+ - **HTTP/HTTPS:** Web pages, e.g. `https://example.com`
376
+ - **Shortcuts:** Run Jarvis with `shortcuts://run-shortcut?name=Jarvis` <!-- full-width -->
377
+
361
378
  ```bash
362
379
  activitysmith activity stream prod-web-1 \
363
380
  --content-state '{
@@ -372,20 +389,22 @@ activitysmith activity stream prod-web-1 \
372
389
  --action '{
373
390
  "title": "Dashboard",
374
391
  "type": "open_url",
375
- "url": "https://ops.example.com/servers/prod-web-1"
392
+ "url": "https://status.example.com/servers/prod-web-1"
376
393
  }'
377
394
  ```
378
395
 
379
396
  #### Apple Shortcut action
380
397
 
381
398
  ```bash
382
- activitysmith activity stream deploy-payments-api \
399
+ activitysmith activity stream prod-web-1 \
383
400
  --content-state '{
384
- "title": "Deploying payments-api",
385
- "subtitle": "Running database migrations",
386
- "type": "segmented_progress",
387
- "numberOfSteps": 5,
388
- "currentStep": 3
401
+ "title": "Server Health",
402
+ "subtitle": "prod-web-1",
403
+ "type": "metrics",
404
+ "metrics": [
405
+ { "label": "CPU", "value": 76, "unit": "%" },
406
+ { "label": "MEM", "value": 52, "unit": "%" }
407
+ ]
389
408
  }' \
390
409
  --action '{
391
410
  "title": "Chat with Jarvis",
@@ -419,17 +438,11 @@ activitysmith activity stream search-reindex \
419
438
 
420
439
  #### Secondary action
421
440
 
422
- <p align="center">
423
- <img
424
- src="https://cdn.activitysmith.com/features/live-activity-secondary-action.png"
425
- alt="Alert Live Activity with primary and secondary action buttons"
426
- width="680"
427
- />
428
- </p>
441
+ ![Alert Live Activity with primary and secondary action buttons](https://cdn.activitysmith.com/features/live-activity-secondary-action.png)
429
442
 
430
443
  Use `--secondary-action` when you want a second button beside the primary `--action`.
431
444
 
432
- The secondary action button is supported for `alert`, `progress`, and `segmented_progress` Live Activities. Both buttons use the same `open_url`, `webhook`, and Apple Shortcut payload shapes.
445
+ The secondary action button is supported for `value`, `alert`, `segmented_progress`, and `progress` Live Activities. Both buttons use the same `open_url`, `webhook`, and Apple Shortcut payload shapes.
433
446
 
434
447
  ```bash
435
448
  activitysmith activity stream agent-approval \
@@ -444,95 +457,32 @@ activitysmith activity stream agent-approval \
444
457
  --action '{
445
458
  "title": "Send",
446
459
  "type": "webhook",
447
- "url": "https://hooks.example.com/agent/approval",
460
+ "url": "https://agent.example.com/live-activity/approve",
448
461
  "method": "POST",
449
- "body": { "decision": "send" }
462
+ "body": {
463
+ "approval_id": "approval_01JY3J7Q9S0P8M1V5PZK7DR4M2",
464
+ "decision": "send"
465
+ }
450
466
  }' \
451
467
  --secondary-action '{
452
468
  "title": "Deny",
453
469
  "type": "webhook",
454
- "url": "https://hooks.example.com/agent/approval",
470
+ "url": "https://agent.example.com/live-activity/deny",
455
471
  "method": "POST",
456
- "body": { "decision": "deny" }
457
- }'
458
- ```
459
-
460
- ### Icons and Badges
461
-
462
- Add more context to Live Activities with icons and badges.
463
-
464
- #### Icon
465
-
466
- Supported Live Activity types: `stats`, `metrics`, `progress`, `segmented_progress`, and `alert`.
467
-
468
- <p align="center">
469
- <img
470
- src="https://cdn.activitysmith.com/features/metrics-live-activity-with-icon.png"
471
- alt="Metrics Live Activity with an SF Symbol icon on the iPhone Lock Screen"
472
- width="680"
473
- />
474
- </p>
475
-
476
- ```bash
477
- activitysmith activity stream prod-web-1 \
478
- --content-state '{
479
- "title": "Server Health",
480
- "subtitle": "prod-web-1",
481
- "type": "metrics",
482
- "icon": { "symbol": "server.rack", "color": "blue" },
483
- "metrics": [
484
- { "label": "CPU", "value": 18, "unit": "%" },
485
- { "label": "MEM", "value": 42, "unit": "%" }
486
- ]
487
- }'
488
- ```
489
-
490
- The `icon.symbol` value is an Apple SF Symbol name. Browse the catalog with one of these tools:
491
-
492
- - [ActivitySmith app](https://apps.apple.com/us/app/activitysmith/id6752254835) - Open Settings -> SF Symbols to browse 45 hand-picked icons ready to use
493
- - [SF Symbols](https://developer.apple.com/sf-symbols/) - Apple's official macOS app
494
- - [Interactful](https://apps.apple.com/app/interactful/id1528095640) - free third-party iOS app listing all SF Symbols under Foundations -> Iconography
495
-
496
- #### Badge
497
-
498
- Badges are supported by `alert`, `progress`, and `segmented_progress` Live Activities.
499
-
500
- <p align="center">
501
- <img
502
- src="https://cdn.activitysmith.com/features/progress-live-activity-with-badge.png"
503
- alt="Progress Live Activity with a badge on the iPhone Lock Screen"
504
- width="680"
505
- />
506
- </p>
507
-
508
- ```bash
509
- activitysmith activity stream nightly-database-backup \
510
- --content-state '{
511
- "title": "Nightly Database Backup",
512
- "subtitle": "verify restore",
513
- "type": "progress",
514
- "badge": { "title": "S3", "color": "cyan" },
515
- "percentage": 62
472
+ "body": {
473
+ "approval_id": "approval_01JY3J7Q9S0P8M1V5PZK7DR4M2",
474
+ "decision": "deny"
475
+ }
516
476
  }'
517
477
  ```
518
478
 
519
- ### Live Activity Colors
520
-
521
- Choose from these colors for the Live Activity accent, including progress bars and action buttons, or apply them to an individual icon or badge:
522
-
523
- `lime`, `green`, `cyan`, `blue`, `purple`, `magenta`, `red`, `orange`, `yellow`, `gray`
524
-
525
- ## Widgets
479
+ ## Lock Screen Widgets
526
480
 
527
- <p align="center">
528
- <img src="https://cdn.activitysmith.com/features/lock-screen-widgets.png" alt="Lock screen widgets" width="680" />
529
- </p>
481
+ ![Lock screen widgets](https://cdn.activitysmith.com/features/lock-screen-widgets.png)
530
482
 
531
- ActivitySmith lets you display any value on your Lock Screen with widgets - SaaS metrics, revenue, signups, uptime, habits, or anything else you want to track. Create a metric in the <a href="https://activitysmith.com/app/widgets" target="_blank" rel="noopener noreferrer">web app</a>, then update the metric value using our API, add a widget to your lock screen and it will fetch the latest update automatically.
483
+ ActivitySmith lets you display any value on your Lock Screen with widgets - SaaS metrics, revenue, signups, uptime, habits, or anything else you want to track. Create a metric in the [web app](https://activitysmith.com/app/widgets), then update the metric value using our API, add a widget to your lock screen and it will fetch the latest update automatically.
532
484
 
533
- <p align="center">
534
- <img src="https://cdn.activitysmith.com/features/create-widget-metric.png" alt="Create widget metric" width="680" />
535
- </p>
485
+ ![Create widget metric](https://cdn.activitysmith.com/features/create-widget-metric.png)
536
486
 
537
487
  Use the metric key to update its value.
538
488
 
@@ -548,53 +498,50 @@ activitysmith metrics update prod.status healthy
548
498
 
549
499
  ## App Icon Badge Count
550
500
 
551
- <p align="center">
552
- <img src="https://cdn.activitysmith.com/features/badge-count.png" alt="ActivitySmith app icon with an App Icon Badge Count" width="680" />
553
- </p>
501
+ ![ActivitySmith app icon with an App Icon Badge Count](https://cdn.activitysmith.com/features/badge-count.png)
554
502
 
555
503
  Show the number you care about on your ActivitySmith app icon. Track MRR, a customer count, a stock price, or any other value you want to keep in view.
556
504
 
557
- Set or update the badge value.
505
+ ### Set or update the badge value
558
506
 
559
507
  ```bash
560
508
  activitysmith badge 8333
561
509
  ```
562
510
 
563
- To clear the badge, set its value to 0.
511
+ ### Clear the badge
512
+
513
+ Pass `0` to clear the badge.
564
514
 
565
515
  ```bash
566
516
  activitysmith badge 0
567
517
  ```
568
518
 
569
- ## Channels
570
-
571
- Use `--channels` to target specific team members or devices
519
+ ## Metadata
572
520
 
573
- ### Push Notifications
521
+ Metadata adds extra information to Push Notification and Live Activity details in ActivitySmith. It does not appear in the notification or Live Activity on your device.
574
522
 
575
523
  ```bash
576
524
  activitysmith push \
577
525
  --title "New subscription 💸" \
578
526
  --message "Customer upgraded to Pro plan" \
579
- --channels "sales,customer-success"
580
- ```
581
-
582
- ### Live Activities
527
+ --metadata '{
528
+ "customer_id": "382",
529
+ "plan": "Pro",
530
+ "amount": 29,
531
+ "trial": false
532
+ }'
583
533
 
584
- ```bash
585
- activitysmith activity start \
586
- --title "Nightly Database Backup" \
587
- --subtitle "verify restore" \
534
+ activitysmith activity stream customer-import \
535
+ --title "Customer Import" \
588
536
  --type progress \
589
- --percentage 62 \
590
- --channels "sales,customer-success"
537
+ --percentage 60 \
538
+ --metadata '{
539
+ "job_id": "import-382",
540
+ "records": 1200
541
+ }'
591
542
  ```
592
543
 
593
- ### App Icon Badge Count
594
-
595
- ```bash
596
- activitysmith badge 3 --channels "sales,customer-success"
597
- ```
544
+ Values can be strings, numbers, or booleans. Metadata supports up to 50 entries and 16 KB of JSON, with keys up to 100 characters and strings up to 4,000 characters. Nested objects, arrays, and null values are not supported.
598
545
 
599
546
  ## Tags
600
547
 
@@ -607,75 +554,62 @@ activitysmith push \
607
554
  --tags "user:382,billing"
608
555
  ```
609
556
 
610
- ## Aliases
611
-
612
- The CLI installs two bin names:
613
-
614
- - `activitysmith` (recommended)
615
- - `activitysmith-cli` (alias)
616
-
617
- ## Content State Options
618
-
619
- For `activity stream|start|update|end|end-stream`, you can pass content state via JSON:
620
-
621
- - `--content-state <json>`
622
- - `--content-state-file <path>`
557
+ For `activity stream`, `activity update`, and `activity end`, omit `--tags` to keep existing Tags, pass `--tags` to replace them, or use `--clear-tags` to remove them. `--tags` and `--clear-tags` cannot be used together.
623
558
 
624
- For `metrics` and `stats`, you can also pass the metrics array directly:
625
-
626
- - `--metrics <json-array>`
627
- - `--metrics-file <path>`
559
+ ```bash
560
+ activitysmith activity stream customer-import \
561
+ --title "Customer Import" \
562
+ --type progress \
563
+ --percentage 60 \
564
+ --clear-tags
565
+ ```
628
566
 
629
- Or use flags to build the rest of the payload:
567
+ `activity end-stream` also accepts `--tags` or `--clear-tags` to replace or clear Tags in the final history entry. Omit both flags to preserve them.
630
568
 
631
- - `--title <title>`
632
- - `--subtitle <subtitle>`
633
- - `--type <type>`
634
- - `--number-of-steps <number>`
635
- - `--current-step <number>`
636
- - `--percentage <number>`
637
- - `--value <number>`
638
- - `--upper-limit <number>`
639
- - `--duration-seconds <number>`
640
- - `--counts-down <true|false>`
641
- - `--color <color>`
642
- - `--step-color <color>`
643
- - `--auto-dismiss-minutes <number>`
569
+ ## Channels
644
570
 
645
- For `timer`, use `--duration-seconds` for a countdown. To start at 00:00 and count up, use `--counts-down false` and leave out `--duration-seconds`.
571
+ Use `--channels` to target specific team members or devices when sending Push Notifications, Live Activities, or App Icon Badge Count updates. Omit it for account-wide delivery.
646
572
 
647
- Live Activity action options:
573
+ ```bash
574
+ activitysmith push \
575
+ --title "Build Failed 🚨" \
576
+ --message "CI pipeline failed on main branch" \
577
+ --channels "devs,ops"
578
+ ```
648
579
 
649
- - `--action <json>`
650
- - `--action-file <path>`
651
- - `--secondary-action <json>`
652
- - `--secondary-action-file <path>`
580
+ ```bash
581
+ activitysmith activity stream nightly-backup \
582
+ --content-state '{
583
+ "title": "Nightly database backup",
584
+ "type": "segmented_progress",
585
+ "numberOfSteps": 4,
586
+ "currentStep": 1
587
+ }' \
588
+ --channels "devs,ops"
589
+ ```
653
590
 
654
- Targeting options:
591
+ ```bash
592
+ activitysmith badge 3 --channels "sales,customer-success"
593
+ ```
655
594
 
656
- - `--channels <comma-separated-slugs>` (for `push`, `badge`, `activity stream`, and `activity start`)
595
+ ## Output
657
596
 
658
- Organization options:
597
+ Use `--json` for machine-readable output:
659
598
 
660
- - `--tags <comma-separated-tags>` (for `push`, `activity stream`, and `activity start`; repeat the option to add more tags)
599
+ ```bash
600
+ activitysmith push --title "Hello" --json
601
+ ```
661
602
 
662
- Widget metric options:
603
+ ## Error Handling
663
604
 
664
- - `activitysmith metrics update <metric-key> <value>`
665
- - `activitysmith metric update <metric-key> <value>` (alias)
605
+ The CLI exits non-zero on non-2xx responses and prints the API error body. That includes validation failures, rate limits, and Live Activity limit errors.
666
606
 
667
- Required fields:
607
+ ## Additional Resources
668
608
 
669
- - `activity stream`: `--title`, `--type`, plus `--metrics`, `--number-of-steps` and `--current-step`, `--percentage`, `--value` with `--upper-limit`, or timer fields
670
- - `activity start`: `--title`, `--type`, plus `--metrics`, `--number-of-steps` and `--current-step`, `--percentage`, `--value` with `--upper-limit`, or timer fields
671
- - `activity update`: `--title`, plus `--metrics`, `--current-step`, `--percentage`, `--value` with `--upper-limit`, or timer fields
672
- - `activity end`: `--title`, plus `--metrics`, `--current-step`, `--percentage`, `--value` with `--upper-limit`, or timer fields
673
- - `activity end-stream`: no content state is required, but if you provide one it follows the same rules as `activity end`
609
+ ### [NPM Package](https://www.npmjs.com/package/activitysmith-cli)
674
610
 
675
- ## Output
611
+ Install the ActivitySmith CLI from npm
676
612
 
677
- Use `--json` for machine-readable output.
613
+ ### [Source Code](https://github.com/ActivitySmithHQ/activitysmith-cli)
678
614
 
679
- ```bash
680
- activitysmith push --title "Hello" --json
681
- ```
615
+ View the CLI source on GitHub
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "activitysmith-cli",
3
- "version": "1.10.0",
4
- "description": "Command-line interface for ActivitySmith. Send push notifications, manage Live Activities, and set App Icon Badge Counts from your terminal.",
3
+ "version": "1.12.0",
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",
7
7
  "live-activities",
@@ -42,7 +42,7 @@
42
42
  "test": "node --test"
43
43
  },
44
44
  "dependencies": {
45
- "activitysmith": "^1.10.0",
45
+ "activitysmith": "^1.12.0",
46
46
  "commander": "^12.1.0"
47
47
  }
48
48
  }
package/src/cli.js CHANGED
@@ -1,6 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  import { Command, InvalidArgumentError } from "commander";
4
+ import { loadMetadata } from "./metadata.js";
4
5
  import ActivitySmith from "activitysmith";
5
6
  import { createRequire } from "module";
6
7
  import { readFile } from "fs/promises";
@@ -160,18 +161,30 @@ const normalizeUrlWithSchemes = (value, label, schemes) => {
160
161
  return parsed.toString();
161
162
  };
162
163
 
163
- const normalizeActionUrl = (value, label, type) => {
164
+ const normalizeActionUrl = (value, label, type, push = false) => {
164
165
  if (type === "open_url") {
165
- return normalizeUrlWithSchemes(value, label, ["https", "shortcuts"]);
166
+ if (push) return normalizeOpenUrl(value, label);
167
+ const normalized = typeof value === "string" ? value.trim().replace(/^x-safari-https:\/\//i, "https://") : value;
168
+ return normalizeUrlWithSchemes(normalized, label, ["http", "https", "shortcuts"]);
166
169
  }
167
170
 
168
171
  return normalizeHttpsUrl(value, label);
169
172
  };
170
173
 
171
- const normalizeOpenUrl = (value, label) =>
172
- normalizeUrlWithSchemes(value, label, ["https", "shortcuts"]);
174
+ const normalizeOpenUrl = (value, label) => {
175
+ if (typeof value !== "string") throw new Error(`${label} must be a string URL`);
176
+ const trimmed = value.trim();
177
+ if (!trimmed || trimmed.length > 2048 || /[\u0000-\u001f\u007f]/.test(trimmed)) {
178
+ throw new Error(`${label} must be a valid external URL of at most 2048 characters`);
179
+ }
180
+ let parsed;
181
+ try { parsed = new URL(trimmed); } catch { throw new Error(`${label} must be a valid external URL`); }
182
+ const blocked = ["about:", "activitysmith:", "app-prefs:", "blob:", "data:", "file:", "itms-services:", "javascript:", "prefs:"];
183
+ if (blocked.includes(parsed.protocol.toLowerCase())) throw new Error(`${label} uses a blocked URL scheme`);
184
+ return ["http:", "https:"].includes(parsed.protocol) ? parsed.toString() : trimmed;
185
+ };
173
186
 
174
- const addContentStateOptions = (command, { includeAutoDismiss } = {}) => {
187
+ const addContentStateOptions = (command, { includeAutoDismiss, includeAutoDismissSeconds } = {}) => {
175
188
  command
176
189
  .option("--content-state <json>", "Content state as JSON string")
177
190
  .option("--content-state-file <path>", "Content state JSON file path")
@@ -201,9 +214,8 @@ const addContentStateOptions = (command, { includeAutoDismiss } = {}) => {
201
214
  parseNumberOption("percentage")
202
215
  )
203
216
  .option(
204
- "--value <number>",
205
- "Content state value",
206
- parseNumberOption("value")
217
+ "--value <value>",
218
+ "Formatted Value readout, or numeric progress value"
207
219
  )
208
220
  .option(
209
221
  "--upper-limit <number>",
@@ -231,6 +243,14 @@ const addContentStateOptions = (command, { includeAutoDismiss } = {}) => {
231
243
  );
232
244
  }
233
245
 
246
+ if (includeAutoDismissSeconds) {
247
+ command.option(
248
+ "--auto-dismiss-seconds <number>",
249
+ "Auto dismiss seconds for ended stream (takes precedence over minutes)",
250
+ parseIntegerOption("auto-dismiss-seconds")
251
+ );
252
+ }
253
+
234
254
  return command;
235
255
  };
236
256
 
@@ -367,10 +387,11 @@ const validateContentState = (contentState, mode) => {
367
387
  normalizedType !== "metrics" &&
368
388
  normalizedType !== "stats" &&
369
389
  normalizedType !== "alert" &&
370
- normalizedType !== "timer"
390
+ normalizedType !== "timer" &&
391
+ normalizedType !== "value"
371
392
  ) {
372
393
  throw new Error(
373
- "contentState.type must be one of: segmented_progress, progress, metrics, stats, alert, timer"
394
+ "contentState.type must be one of: segmented_progress, progress, metrics, stats, alert, timer, value"
374
395
  );
375
396
  }
376
397
 
@@ -388,7 +409,14 @@ const validateContentState = (contentState, mode) => {
388
409
  const hasCountsDown = hasOwn(contentState, "countsDown");
389
410
  const hasTimerFields = hasDurationSeconds || hasCountsDown;
390
411
 
391
- if (hasValue !== hasUpperLimit) {
412
+ for (const key of ["autoDismissSeconds", "auto_dismiss_seconds"]) {
413
+ if (hasOwn(contentState, key) &&
414
+ (!Number.isInteger(contentState[key]) || contentState[key] < 0)) {
415
+ throw new Error(`contentState.${key} must be a non-negative integer`);
416
+ }
417
+ }
418
+
419
+ if (normalizedType !== "value" && hasValue !== hasUpperLimit) {
392
420
  throw new Error(
393
421
  "contentState.value and contentState.upperLimit must be provided together"
394
422
  );
@@ -422,7 +450,7 @@ const validateContentState = (contentState, mode) => {
422
450
  }
423
451
 
424
452
  const hasSegmentedFields = hasNumberOfSteps || hasCurrentStep || hasStepColor;
425
- const hasProgressFields = hasPercentage || hasValue || hasUpperLimit;
453
+ const hasProgressFields = hasPercentage || (hasValue && normalizedType !== "value") || hasUpperLimit;
426
454
  const hasAlertFields = hasMessage || hasIcon || hasBadge;
427
455
 
428
456
  if (hasIcon) {
@@ -472,7 +500,7 @@ const validateContentState = (contentState, mode) => {
472
500
  }
473
501
 
474
502
  if (
475
- hasAlertFields &&
503
+ hasMessage &&
476
504
  (hasMetrics || hasSegmentedFields || hasProgressFields || hasStepColor)
477
505
  ) {
478
506
  throw new Error(
@@ -521,6 +549,16 @@ const validateContentState = (contentState, mode) => {
521
549
  });
522
550
  }
523
551
 
552
+ if (normalizedType === "value") {
553
+ if (!hasValue || !(typeof contentState.value === "string" || Number.isFinite(contentState.value))) {
554
+ throw new Error("Value requires contentState.value as a string or finite number");
555
+ }
556
+ if (hasProgressFields || hasSegmentedFields || hasMetrics || hasTimerFields || hasMessage) {
557
+ throw new Error("Do not mix Value with other Live Activity type fields");
558
+ }
559
+ return;
560
+ }
561
+
524
562
  const effectiveType = normalizedType;
525
563
 
526
564
  if (mode === "start" || mode === "stream") {
@@ -552,7 +590,7 @@ const validateContentState = (contentState, mode) => {
552
590
  }
553
591
 
554
592
  if (effectiveType === "timer") {
555
- if (!hasDurationSeconds && contentState.countsDown !== false) {
593
+ if (mode === "start" && !hasDurationSeconds && contentState.countsDown !== false) {
556
594
  throw new Error(
557
595
  `timer ${mode} requires contentState.durationSeconds, or contentState.countsDown=false`
558
596
  );
@@ -637,7 +675,7 @@ const validateContentState = (contentState, mode) => {
637
675
  }
638
676
  };
639
677
 
640
- const parseAction = (value, label) => {
678
+ const parseAction = (value, label, push = false) => {
641
679
  assertPlainObject(value, label);
642
680
 
643
681
  if (typeof value.title !== "string" || value.title.trim().length === 0) {
@@ -656,7 +694,7 @@ const parseAction = (value, label) => {
656
694
  const action = {
657
695
  title: value.title.trim(),
658
696
  type: normalizedType,
659
- url: normalizeActionUrl(value.url, `${label}.url`, normalizedType),
697
+ url: normalizeActionUrl(value.url, `${label}.url`, normalizedType, push),
660
698
  };
661
699
 
662
700
  if (value.method !== undefined) {
@@ -682,7 +720,7 @@ const parseAction = (value, label) => {
682
720
  return action;
683
721
  };
684
722
 
685
- const parsePushAction = (value, index) => parseAction(value, `actions[${index}]`);
723
+ const parsePushAction = (value, index) => parseAction(value, `actions[${index}]`, true);
686
724
 
687
725
  const loadPushActions = async (options) => {
688
726
  if (options.actions && options.actionsFile) {
@@ -822,7 +860,9 @@ const buildContentStateFromOptions = (options) => {
822
860
  }
823
861
 
824
862
  if (options.value !== undefined) {
825
- contentState.value = options.value;
863
+ contentState.value = options.type === "value"
864
+ ? options.value
865
+ : parseNumberOption("value")(options.value);
826
866
  }
827
867
 
828
868
  if (options.upperLimit !== undefined) {
@@ -845,6 +885,10 @@ const buildContentStateFromOptions = (options) => {
845
885
  contentState.stepColor = options.stepColor;
846
886
  }
847
887
 
888
+ if (options.autoDismissSeconds !== undefined) {
889
+ contentState.autoDismissSeconds = options.autoDismissSeconds;
890
+ }
891
+
848
892
  if (options.autoDismissMinutes !== undefined) {
849
893
  contentState.autoDismissMinutes = options.autoDismissMinutes;
850
894
  }
@@ -875,6 +919,7 @@ const toApiContentState = (contentState) => {
875
919
  upperLimit: "upper_limit",
876
920
  stepColor: "step_color",
877
921
  autoDismissMinutes: "auto_dismiss_minutes",
922
+ autoDismissSeconds: "auto_dismiss_seconds",
878
923
  durationSeconds: "duration_seconds",
879
924
  countsDown: "counts_down",
880
925
  };
@@ -926,8 +971,9 @@ const withTargetChannels = (request, channels) => {
926
971
  };
927
972
  };
928
973
 
929
- const withTags = (request, tags) => {
930
- if (!tags || tags.length === 0) {
974
+ const withTags = (request, tags, metadata) => {
975
+ if (metadata !== undefined) request = { ...request, metadata };
976
+ if (tags === undefined) {
931
977
  return request;
932
978
  }
933
979
 
@@ -1232,7 +1278,9 @@ program
1232
1278
  "Comma-separated tags for organizing history (repeatable)",
1233
1279
  parseTagsOption
1234
1280
  )
1235
- .action(async (options) => {
1281
+ .option("--metadata <json>", "Metadata JSON object shown in ActivitySmith details")
1282
+ .option("--metadata-file <path>", "Path to a Metadata JSON object file")
1283
+ .action(async (options) => {
1236
1284
  const globalOptions = program.opts();
1237
1285
 
1238
1286
  try {
@@ -1259,6 +1307,7 @@ program
1259
1307
  : undefined,
1260
1308
  actions,
1261
1309
  tags: options.tags,
1310
+ metadata: await loadMetadata(options),
1262
1311
  },
1263
1312
  options.channels
1264
1313
  );
@@ -1311,8 +1360,8 @@ program
1311
1360
  ? "App Icon Badge Count cleared."
1312
1361
  : "App Icon Badge Count updated.",
1313
1362
  response?.badge !== undefined ? `Badge: ${response.badge}` : null,
1314
- response?.devicesNotified !== undefined
1315
- ? `Devices notified: ${response.devicesNotified}`
1363
+ response?.devicesUpdated !== undefined || response?.devicesNotified !== undefined
1364
+ ? `Devices updated: ${response.devicesUpdated ?? response.devicesNotified}`
1316
1365
  : null,
1317
1366
  ]);
1318
1367
  } catch (error) {
@@ -1330,7 +1379,9 @@ metricsCommand
1330
1379
  .description("Update a widget metric value")
1331
1380
  .argument("<metric-key>", "Metric key")
1332
1381
  .argument("<value>", "Metric value")
1333
- .action(async (metricKey, rawValue) => {
1382
+ .option("--metadata <json>", "Metadata JSON object shown in ActivitySmith details")
1383
+ .option("--metadata-file <path>", "Path to a Metadata JSON object file")
1384
+ .action(async (metricKey, rawValue) => {
1334
1385
  const globalOptions = program.opts();
1335
1386
 
1336
1387
  try {
@@ -1347,7 +1398,7 @@ metricsCommand
1347
1398
 
1348
1399
  const activityCommand = program
1349
1400
  .command("activity")
1350
- .description("Manage Live Activities");
1401
+ .description("Start, update, and end Live Activities");
1351
1402
 
1352
1403
  addLiveActivityActionOptions(addContentStateOptions(
1353
1404
  activityCommand
@@ -1364,10 +1415,16 @@ addLiveActivityActionOptions(addContentStateOptions(
1364
1415
  "Comma-separated tags for organizing history (repeatable)",
1365
1416
  parseTagsOption
1366
1417
  )
1418
+ .option("--clear-tags", "Remove all Tags from this stream")
1419
+ .option("--metadata <json>", "Metadata JSON object shown in ActivitySmith details")
1420
+ .option("--metadata-file <path>", "Path to a Metadata JSON object file")
1367
1421
  .action(async (streamKey, options) => {
1368
1422
  const globalOptions = program.opts();
1369
1423
 
1370
1424
  try {
1425
+ if (options.clearTags && options.tags !== undefined) {
1426
+ throw new Error("Use either --tags or --clear-tags, not both.");
1427
+ }
1371
1428
  const apiKey = requireApiKey(globalOptions);
1372
1429
  const client = createClient(apiKey);
1373
1430
  const contentState = await loadContentState(options, "stream");
@@ -1385,7 +1442,8 @@ addLiveActivityActionOptions(addContentStateOptions(
1385
1442
  ),
1386
1443
  options.channels
1387
1444
  ),
1388
- options.tags
1445
+ options.clearTags ? [] : options.tags,
1446
+ await loadMetadata(options)
1389
1447
  )
1390
1448
  );
1391
1449
 
@@ -1417,6 +1475,8 @@ addLiveActivityActionOptions(addContentStateOptions(
1417
1475
  "Comma-separated tags for organizing history (repeatable)",
1418
1476
  parseTagsOption
1419
1477
  )
1478
+ .option("--metadata <json>", "Metadata JSON object shown in ActivitySmith details")
1479
+ .option("--metadata-file <path>", "Path to a Metadata JSON object file")
1420
1480
  .action(async (options) => {
1421
1481
  const globalOptions = program.opts();
1422
1482
 
@@ -1437,7 +1497,8 @@ addLiveActivityActionOptions(addContentStateOptions(
1437
1497
  ),
1438
1498
  options.channels
1439
1499
  ),
1440
- options.tags
1500
+ options.tags,
1501
+ await loadMetadata(options)
1441
1502
  ),
1442
1503
  });
1443
1504
 
@@ -1457,10 +1518,17 @@ addLiveActivityActionOptions(addContentStateOptions(
1457
1518
  .command("update")
1458
1519
  .description("Update a Live Activity")
1459
1520
  .requiredOption("--activity-id <id>", "Live Activity ID")
1521
+ .option("--tags <tags>", "Replace Tags for this Live Activity (repeatable)", parseTagsOption)
1522
+ .option("--clear-tags", "Remove all Tags from this Live Activity")
1523
+ .option("--metadata <json>", "Metadata JSON object shown in ActivitySmith details")
1524
+ .option("--metadata-file <path>", "Path to a Metadata JSON object file")
1460
1525
  .action(async (options) => {
1461
1526
  const globalOptions = program.opts();
1462
1527
 
1463
1528
  try {
1529
+ if (options.clearTags && options.tags !== undefined) {
1530
+ throw new Error("Use either --tags or --clear-tags, not both.");
1531
+ }
1464
1532
  const apiKey = requireApiKey(globalOptions);
1465
1533
  const client = createClient(apiKey);
1466
1534
  const contentState = await loadContentState(options, "update");
@@ -1468,12 +1536,12 @@ addLiveActivityActionOptions(addContentStateOptions(
1468
1536
  const secondaryAction = await loadLiveActivitySecondaryAction(options);
1469
1537
 
1470
1538
  const response = await client.liveActivities.updateLiveActivity({
1471
- liveActivityUpdateRequest: toApiLiveActivityUpdateRequest(
1539
+ liveActivityUpdateRequest: withTags(toApiLiveActivityUpdateRequest(
1472
1540
  options.activityId,
1473
1541
  contentState,
1474
1542
  action,
1475
1543
  secondaryAction
1476
- ),
1544
+ ), options.clearTags ? [] : options.tags, await loadMetadata(options)),
1477
1545
  });
1478
1546
 
1479
1547
  outputResult(response, globalOptions, [
@@ -1491,10 +1559,17 @@ addLiveActivityActionOptions(addContentStateOptions(
1491
1559
  .command("end")
1492
1560
  .description("End a Live Activity")
1493
1561
  .requiredOption("--activity-id <id>", "Live Activity ID")
1562
+ .option("--tags <tags>", "Replace Tags for this Live Activity (repeatable)", parseTagsOption)
1563
+ .option("--clear-tags", "Remove all Tags from this Live Activity")
1564
+ .option("--metadata <json>", "Metadata JSON object shown in ActivitySmith details")
1565
+ .option("--metadata-file <path>", "Path to a Metadata JSON object file")
1494
1566
  .action(async (options) => {
1495
1567
  const globalOptions = program.opts();
1496
1568
 
1497
1569
  try {
1570
+ if (options.clearTags && options.tags !== undefined) {
1571
+ throw new Error("Use either --tags or --clear-tags, not both.");
1572
+ }
1498
1573
  const apiKey = requireApiKey(globalOptions);
1499
1574
  const client = createClient(apiKey);
1500
1575
  const contentState = await loadContentState(options, "end");
@@ -1502,12 +1577,12 @@ addLiveActivityActionOptions(addContentStateOptions(
1502
1577
  const secondaryAction = await loadLiveActivitySecondaryAction(options);
1503
1578
 
1504
1579
  const response = await client.liveActivities.endLiveActivity({
1505
- liveActivityEndRequest: toApiLiveActivityEndRequest(
1580
+ liveActivityEndRequest: withTags(toApiLiveActivityEndRequest(
1506
1581
  options.activityId,
1507
1582
  contentState,
1508
1583
  action,
1509
1584
  secondaryAction
1510
- ),
1585
+ ), options.clearTags ? [] : options.tags, await loadMetadata(options)),
1511
1586
  });
1512
1587
 
1513
1588
  outputResult(response, globalOptions, [
@@ -1526,10 +1601,17 @@ addLiveActivityActionOptions(addContentStateOptions(
1526
1601
  .command("end-stream")
1527
1602
  .description("End a stateless Live Activity stream")
1528
1603
  .argument("<stream-key>", "Stable stream key")
1604
+ .option("--tags <tags>", "Comma-separated Tags", parseTagsOption)
1605
+ .option("--clear-tags", "Clear existing Tags")
1606
+ .option("--metadata <json>", "Metadata as a JSON object")
1607
+ .option("--metadata-file <path>", "Metadata JSON file path")
1529
1608
  .action(async (streamKey, options) => {
1530
1609
  const globalOptions = program.opts();
1531
1610
 
1532
1611
  try {
1612
+ if (options.clearTags && options.tags !== undefined) throw new Error("Provide either --tags or --clear-tags, not both.");
1613
+ const tags = options.clearTags ? [] : options.tags;
1614
+ const metadata = await loadMetadata(options);
1533
1615
  const apiKey = requireApiKey(globalOptions);
1534
1616
  const client = createClient(apiKey);
1535
1617
  const contentState = await loadOptionalContentState(options, "end");
@@ -1539,7 +1621,7 @@ addLiveActivityActionOptions(addContentStateOptions(
1539
1621
  const request =
1540
1622
  contentState !== undefined ||
1541
1623
  action !== undefined ||
1542
- secondaryAction !== undefined
1624
+ secondaryAction !== undefined || tags !== undefined || metadata !== undefined
1543
1625
  ? toApiLiveActivityStreamDeleteRequest(
1544
1626
  contentState,
1545
1627
  action,
@@ -1547,6 +1629,8 @@ addLiveActivityActionOptions(addContentStateOptions(
1547
1629
  )
1548
1630
  : undefined;
1549
1631
 
1632
+ if (tags !== undefined) request.tags = tags;
1633
+ if (metadata !== undefined) request.metadata = metadata;
1550
1634
  const response = await client.liveActivities.endStream(streamKey, request);
1551
1635
 
1552
1636
  const activityId = response?.activityId ?? response?.activity_id;
@@ -1561,7 +1645,7 @@ addLiveActivityActionOptions(addContentStateOptions(
1561
1645
  await handleError(error, globalOptions);
1562
1646
  }
1563
1647
  }),
1564
- { includeAutoDismiss: true }
1648
+ { includeAutoDismiss: true, includeAutoDismissSeconds: true }
1565
1649
  ));
1566
1650
 
1567
1651
  program.showHelpAfterError(true);
@@ -0,0 +1,27 @@
1
+ import { readFile } from "node:fs/promises";
2
+
3
+ export async function loadMetadata(options) {
4
+ if (options.metadata !== undefined && options.metadataFile !== undefined) {
5
+ throw new Error("Use either --metadata or --metadata-file, not both.");
6
+ }
7
+ const raw = options.metadataFile !== undefined
8
+ ? await readFile(options.metadataFile, "utf8") : options.metadata;
9
+ if (raw === undefined) return undefined;
10
+ const value = JSON.parse(raw);
11
+ if (value === null || Array.isArray(value) || typeof value !== "object") {
12
+ throw new Error("Metadata must be a JSON object.");
13
+ }
14
+ if (Object.keys(value).length > 50 || Buffer.byteLength(JSON.stringify(value), "utf8") > 16384) {
15
+ throw new Error("Metadata supports at most 50 entries and 16 KB of JSON.");
16
+ }
17
+ for (const [key, item] of Object.entries(value)) {
18
+ if (!key.trim() || key.length > 100 || key === "__proto__") {
19
+ throw new Error("Metadata keys must contain 1-100 characters and cannot be __proto__.");
20
+ }
21
+ if (!(typeof item === "string" && item.length <= 4000) &&
22
+ !(typeof item === "number" && Number.isFinite(item)) && typeof item !== "boolean") {
23
+ throw new Error("Metadata values must be strings (up to 4000 characters), finite numbers, or booleans.");
24
+ }
25
+ }
26
+ return value;
27
+ }