activitysmith-cli 1.10.0 → 1.11.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 +234 -312
- package/package.json +3 -3
- package/src/cli.js +97 -25
- package/src/metadata.js +27 -0
package/README.md
CHANGED
|
@@ -1,31 +1,10 @@
|
|
|
1
1
|
# ActivitySmith CLI
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
##
|
|
6
|
-
|
|
7
|
-
|
|
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
|
-
|
|
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
|
-
|
|
17
|
+
```bash
|
|
18
|
+
npx -y skills@latest add ActivitySmithHQ/activitysmith-cli --skill activitysmith
|
|
19
|
+
```
|
|
41
20
|
|
|
42
|
-
Use
|
|
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
|
-
|
|
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
|
-
|
|
25
|
+
## Quickstart
|
|
50
26
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
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
|
-
|
|
31
|
+
Use the environment variable when you want the cleanest shell scripts:
|
|
59
32
|
|
|
60
33
|
```bash
|
|
61
|
-
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
Skill path in this repo:
|
|
34
|
+
export ACTIVITYSMITH_API_KEY="YOUR-API-KEY"
|
|
65
35
|
|
|
66
|
-
|
|
67
|
-
skills/activitysmith
|
|
36
|
+
activitysmith --help
|
|
68
37
|
```
|
|
69
38
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
## Auth
|
|
39
|
+
Or pass the key directly:
|
|
73
40
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
41
|
+
```bash
|
|
42
|
+
activitysmith --api-key "YOUR-API-KEY" push --title "Hello"
|
|
43
|
+
```
|
|
77
44
|
|
|
78
45
|
## Push Notifications
|
|
79
46
|
|
|
80
|
-
|
|
47
|
+
### Send a Push Notification
|
|
81
48
|
|
|
82
|
-
|
|
49
|
+
Send an immediate notification for a completed task or event.
|
|
50
|
+
|
|
51
|
+

|
|
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
|
-
|
|
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
|
+

|
|
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
|
-
|
|
71
|
+
Attach images, videos, or audio to your Push Notifications. Press and hold the notification to preview the media.
|
|
105
72
|
|
|
106
|
-
|
|
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
|
+

|
|
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`
|
|
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
|
-
|
|
122
|
-
|
|
123
|
-
|
|
105
|
+

|
|
106
|
+
|
|
107
|
+
`open_url` actions open a web page, run an iOS Shortcut, or open an app when someone taps the button. Supported links:
|
|
124
108
|
|
|
125
|
-
|
|
126
|
-
|
|
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
|
|
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
|
|
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,14 +156,31 @@ activitysmith push \
|
|
|
166
156
|
|
|
167
157
|
## Live Activities
|
|
168
158
|
|
|
169
|
-
|
|
159
|
+
Choose the Live Activity type that matches what you want to show:
|
|
160
|
+
|
|
161
|
+

|
|
162
|
+
|
|
163
|
+
**Stats**: Show up to 8 labeled values on your Lock Screen, from revenue and orders to uptime and conversion.
|
|
164
|
+
|
|
165
|
+

|
|
166
|
+
|
|
167
|
+
**Metrics**: Track two related values with segmented bars, such as CPU and memory.
|
|
168
|
+
|
|
169
|
+

|
|
170
|
+
|
|
171
|
+
**Segmented Progress**: Show progress through a known set of steps, like build, test, deploy, and verify.
|
|
172
|
+
|
|
173
|
+

|
|
170
174
|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
175
|
+
**Progress**: Show percentage progress for jobs that move continuously toward completion.
|
|
176
|
+
|
|
177
|
+

|
|
178
|
+
|
|
179
|
+
**Alert**: Show status updates with a clear message, badge, and icon. When you add an action button, `color` controls the button tint.
|
|
180
|
+
|
|
181
|
+

|
|
182
|
+
|
|
183
|
+
**Timer**: Count down from a duration, or count up from 00:00 while a job runs.
|
|
177
184
|
|
|
178
185
|
### Start & Update Live Activity
|
|
179
186
|
|
|
@@ -181,13 +188,7 @@ Use a stable `stream_key` to identify the metric, job, deployment, or system you
|
|
|
181
188
|
|
|
182
189
|
#### Stats
|
|
183
190
|
|
|
184
|
-
|
|
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>
|
|
191
|
+

|
|
191
192
|
|
|
192
193
|
```bash
|
|
193
194
|
activitysmith activity stream sales-hourly \
|
|
@@ -208,13 +209,7 @@ activitysmith activity stream sales-hourly \
|
|
|
208
209
|
|
|
209
210
|
#### Metrics
|
|
210
211
|
|
|
211
|
-
|
|
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>
|
|
212
|
+

|
|
218
213
|
|
|
219
214
|
```bash
|
|
220
215
|
activitysmith activity stream prod-web-1 \
|
|
@@ -231,13 +226,7 @@ activitysmith activity stream prod-web-1 \
|
|
|
231
226
|
|
|
232
227
|
#### Segmented Progress
|
|
233
228
|
|
|
234
|
-
|
|
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>
|
|
229
|
+

|
|
241
230
|
|
|
242
231
|
```bash
|
|
243
232
|
activitysmith activity stream nightly-backup \
|
|
@@ -252,13 +241,7 @@ activitysmith activity stream nightly-backup \
|
|
|
252
241
|
|
|
253
242
|
#### Progress
|
|
254
243
|
|
|
255
|
-
|
|
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>
|
|
244
|
+

|
|
262
245
|
|
|
263
246
|
```bash
|
|
264
247
|
activitysmith activity stream search-reindex \
|
|
@@ -272,13 +255,7 @@ activitysmith activity stream search-reindex \
|
|
|
272
255
|
|
|
273
256
|
#### Alert
|
|
274
257
|
|
|
275
|
-
|
|
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>
|
|
258
|
+

|
|
282
259
|
|
|
283
260
|
```bash
|
|
284
261
|
activitysmith activity stream customer-ops \
|
|
@@ -299,13 +276,7 @@ activitysmith activity stream customer-ops \
|
|
|
299
276
|
|
|
300
277
|
#### Timer
|
|
301
278
|
|
|
302
|
-
|
|
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>
|
|
279
|
+

|
|
309
280
|
|
|
310
281
|
```bash
|
|
311
282
|
activitysmith activity stream benchmark-run \
|
|
@@ -318,16 +289,17 @@ activitysmith activity stream benchmark-run \
|
|
|
318
289
|
}'
|
|
319
290
|
```
|
|
320
291
|
|
|
321
|
-
For a countdown, send `
|
|
292
|
+
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
293
|
|
|
323
|
-
To start at 00:00 and count up, set `
|
|
294
|
+
To start at 00:00 and count up, set `countsDown` to `false` and leave out `durationSeconds`.
|
|
324
295
|
|
|
325
296
|
### End Live Activity
|
|
326
297
|
|
|
327
|
-
Call `activity end-stream` with the same `stream_key` to dismiss the Live Activity. You can include final values before it is removed.
|
|
298
|
+
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
299
|
|
|
329
300
|
```bash
|
|
330
301
|
activitysmith activity end-stream prod-web-1 \
|
|
302
|
+
--auto-dismiss-seconds 30 \
|
|
331
303
|
--content-state '{
|
|
332
304
|
"title": "Server Health",
|
|
333
305
|
"subtitle": "prod-web-1",
|
|
@@ -335,29 +307,66 @@ activitysmith activity end-stream prod-web-1 \
|
|
|
335
307
|
"metrics": [
|
|
336
308
|
{ "label": "CPU", "value": 7, "unit": "%" },
|
|
337
309
|
{ "label": "MEM", "value": 38, "unit": "%" }
|
|
310
|
+
]
|
|
311
|
+
}'
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
### Icons and Badges
|
|
315
|
+
|
|
316
|
+
Add more context to Live Activities with icons and badges.
|
|
317
|
+
|
|
318
|
+
#### Icon
|
|
319
|
+
|
|
320
|
+
```bash
|
|
321
|
+
activitysmith activity stream prod-web-1 \
|
|
322
|
+
--content-state '{
|
|
323
|
+
"title": "Server Health",
|
|
324
|
+
"type": "metrics",
|
|
325
|
+
"metrics": [
|
|
326
|
+
{ "label": "CPU", "value": 18, "unit": "%" },
|
|
327
|
+
{ "label": "MEM", "value": 42, "unit": "%" }
|
|
338
328
|
],
|
|
339
|
-
"
|
|
329
|
+
"icon": { "symbol": "server.rack", "color": "blue" }
|
|
330
|
+
}'
|
|
331
|
+
```
|
|
332
|
+
|
|
333
|
+
The `icon.symbol` value is an Apple SF Symbol name. Browse the catalog in the ActivitySmith iOS app under Settings > SF Symbols.
|
|
334
|
+
|
|
335
|
+
#### Badge
|
|
336
|
+
|
|
337
|
+
```bash
|
|
338
|
+
activitysmith activity stream nightly-backup \
|
|
339
|
+
--content-state '{
|
|
340
|
+
"title": "Nightly Database Backup",
|
|
341
|
+
"type": "segmented_progress",
|
|
342
|
+
"numberOfSteps": 3,
|
|
343
|
+
"currentStep": 2,
|
|
344
|
+
"badge": { "title": "S3", "color": "cyan" }
|
|
340
345
|
}'
|
|
341
346
|
```
|
|
342
347
|
|
|
348
|
+
### Live Activity Colors
|
|
349
|
+
|
|
350
|
+
Choose from these colors for the Live Activity accent, including progress bars and action buttons, or apply them to an individual icon or badge:
|
|
351
|
+
|
|
352
|
+
`lime`, `green`, `cyan`, `blue`, `purple`, `magenta`, `red`, `orange`, `yellow`, `gray`
|
|
353
|
+
|
|
343
354
|
### Live Activity Action
|
|
344
355
|
|
|
345
|
-
Live
|
|
356
|
+

|
|
346
357
|
|
|
347
|
-
|
|
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.
|
|
358
|
+
Live Activities can include an action button.
|
|
350
359
|
|
|
351
|
-
|
|
352
|
-
|
|
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>
|
|
360
|
+
- `open_url`: Open a web page or run an iOS Shortcut
|
|
361
|
+
- `webhook`: Trigger a backend GET/POST workflow
|
|
358
362
|
|
|
359
363
|
#### Open URL action
|
|
360
364
|
|
|
365
|
+
Open a web page or run an iOS Shortcut when someone taps the button. Supported links:
|
|
366
|
+
|
|
367
|
+
- **HTTP/HTTPS:** Web pages, e.g. `https://example.com`
|
|
368
|
+
- **Shortcuts:** Run Jarvis with `shortcuts://run-shortcut?name=Jarvis` <!-- full-width -->
|
|
369
|
+
|
|
361
370
|
```bash
|
|
362
371
|
activitysmith activity stream prod-web-1 \
|
|
363
372
|
--content-state '{
|
|
@@ -372,20 +381,22 @@ activitysmith activity stream prod-web-1 \
|
|
|
372
381
|
--action '{
|
|
373
382
|
"title": "Dashboard",
|
|
374
383
|
"type": "open_url",
|
|
375
|
-
"url": "https://
|
|
384
|
+
"url": "https://status.example.com/servers/prod-web-1"
|
|
376
385
|
}'
|
|
377
386
|
```
|
|
378
387
|
|
|
379
388
|
#### Apple Shortcut action
|
|
380
389
|
|
|
381
390
|
```bash
|
|
382
|
-
activitysmith activity stream
|
|
391
|
+
activitysmith activity stream prod-web-1 \
|
|
383
392
|
--content-state '{
|
|
384
|
-
"title": "
|
|
385
|
-
"subtitle": "
|
|
386
|
-
"type": "
|
|
387
|
-
"
|
|
388
|
-
|
|
393
|
+
"title": "Server Health",
|
|
394
|
+
"subtitle": "prod-web-1",
|
|
395
|
+
"type": "metrics",
|
|
396
|
+
"metrics": [
|
|
397
|
+
{ "label": "CPU", "value": 76, "unit": "%" },
|
|
398
|
+
{ "label": "MEM", "value": 52, "unit": "%" }
|
|
399
|
+
]
|
|
389
400
|
}' \
|
|
390
401
|
--action '{
|
|
391
402
|
"title": "Chat with Jarvis",
|
|
@@ -419,13 +430,7 @@ activitysmith activity stream search-reindex \
|
|
|
419
430
|
|
|
420
431
|
#### Secondary action
|
|
421
432
|
|
|
422
|
-
|
|
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>
|
|
433
|
+

|
|
429
434
|
|
|
430
435
|
Use `--secondary-action` when you want a second button beside the primary `--action`.
|
|
431
436
|
|
|
@@ -444,95 +449,32 @@ activitysmith activity stream agent-approval \
|
|
|
444
449
|
--action '{
|
|
445
450
|
"title": "Send",
|
|
446
451
|
"type": "webhook",
|
|
447
|
-
"url": "https://
|
|
452
|
+
"url": "https://agent.example.com/live-activity/approve",
|
|
448
453
|
"method": "POST",
|
|
449
|
-
"body": {
|
|
454
|
+
"body": {
|
|
455
|
+
"approval_id": "approval_01JY3J7Q9S0P8M1V5PZK7DR4M2",
|
|
456
|
+
"decision": "send"
|
|
457
|
+
}
|
|
450
458
|
}' \
|
|
451
459
|
--secondary-action '{
|
|
452
460
|
"title": "Deny",
|
|
453
461
|
"type": "webhook",
|
|
454
|
-
"url": "https://
|
|
462
|
+
"url": "https://agent.example.com/live-activity/deny",
|
|
455
463
|
"method": "POST",
|
|
456
|
-
"body": {
|
|
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
|
|
464
|
+
"body": {
|
|
465
|
+
"approval_id": "approval_01JY3J7Q9S0P8M1V5PZK7DR4M2",
|
|
466
|
+
"decision": "deny"
|
|
467
|
+
}
|
|
516
468
|
}'
|
|
517
469
|
```
|
|
518
470
|
|
|
519
|
-
|
|
471
|
+
## Lock Screen Widgets
|
|
520
472
|
|
|
521
|
-
|
|
473
|
+

|
|
522
474
|
|
|
523
|
-
|
|
475
|
+
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.
|
|
524
476
|
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
<p align="center">
|
|
528
|
-
<img src="https://cdn.activitysmith.com/features/lock-screen-widgets.png" alt="Lock screen widgets" width="680" />
|
|
529
|
-
</p>
|
|
530
|
-
|
|
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.
|
|
532
|
-
|
|
533
|
-
<p align="center">
|
|
534
|
-
<img src="https://cdn.activitysmith.com/features/create-widget-metric.png" alt="Create widget metric" width="680" />
|
|
535
|
-
</p>
|
|
477
|
+

|
|
536
478
|
|
|
537
479
|
Use the metric key to update its value.
|
|
538
480
|
|
|
@@ -548,53 +490,50 @@ activitysmith metrics update prod.status healthy
|
|
|
548
490
|
|
|
549
491
|
## App Icon Badge Count
|
|
550
492
|
|
|
551
|
-
|
|
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>
|
|
493
|
+

|
|
554
494
|
|
|
555
495
|
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
496
|
|
|
557
|
-
Set or update the badge value
|
|
497
|
+
### Set or update the badge value
|
|
558
498
|
|
|
559
499
|
```bash
|
|
560
500
|
activitysmith badge 8333
|
|
561
501
|
```
|
|
562
502
|
|
|
563
|
-
|
|
503
|
+
### Clear the badge
|
|
504
|
+
|
|
505
|
+
Pass `0` to clear the badge.
|
|
564
506
|
|
|
565
507
|
```bash
|
|
566
508
|
activitysmith badge 0
|
|
567
509
|
```
|
|
568
510
|
|
|
569
|
-
##
|
|
570
|
-
|
|
571
|
-
Use `--channels` to target specific team members or devices
|
|
511
|
+
## Metadata
|
|
572
512
|
|
|
573
|
-
|
|
513
|
+
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
514
|
|
|
575
515
|
```bash
|
|
576
516
|
activitysmith push \
|
|
577
517
|
--title "New subscription 💸" \
|
|
578
518
|
--message "Customer upgraded to Pro plan" \
|
|
579
|
-
--
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
519
|
+
--metadata '{
|
|
520
|
+
"customer_id": "382",
|
|
521
|
+
"plan": "Pro",
|
|
522
|
+
"amount": 29,
|
|
523
|
+
"trial": false
|
|
524
|
+
}'
|
|
583
525
|
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
--title "Nightly Database Backup" \
|
|
587
|
-
--subtitle "verify restore" \
|
|
526
|
+
activitysmith activity stream customer-import \
|
|
527
|
+
--title "Customer Import" \
|
|
588
528
|
--type progress \
|
|
589
|
-
--percentage
|
|
590
|
-
--
|
|
529
|
+
--percentage 60 \
|
|
530
|
+
--metadata '{
|
|
531
|
+
"job_id": "import-382",
|
|
532
|
+
"records": 1200
|
|
533
|
+
}'
|
|
591
534
|
```
|
|
592
535
|
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
```bash
|
|
596
|
-
activitysmith badge 3 --channels "sales,customer-success"
|
|
597
|
-
```
|
|
536
|
+
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
537
|
|
|
599
538
|
## Tags
|
|
600
539
|
|
|
@@ -607,75 +546,58 @@ activitysmith push \
|
|
|
607
546
|
--tags "user:382,billing"
|
|
608
547
|
```
|
|
609
548
|
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
The CLI installs two bin names:
|
|
549
|
+
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.
|
|
613
550
|
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
- `--content-state <json>`
|
|
622
|
-
- `--content-state-file <path>`
|
|
623
|
-
|
|
624
|
-
For `metrics` and `stats`, you can also pass the metrics array directly:
|
|
625
|
-
|
|
626
|
-
- `--metrics <json-array>`
|
|
627
|
-
- `--metrics-file <path>`
|
|
628
|
-
|
|
629
|
-
Or use flags to build the rest of the payload:
|
|
630
|
-
|
|
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>`
|
|
551
|
+
```bash
|
|
552
|
+
activitysmith activity stream customer-import \
|
|
553
|
+
--title "Customer Import" \
|
|
554
|
+
--type progress \
|
|
555
|
+
--percentage 60 \
|
|
556
|
+
--clear-tags
|
|
557
|
+
```
|
|
644
558
|
|
|
645
|
-
|
|
559
|
+
`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.
|
|
646
560
|
|
|
647
|
-
|
|
561
|
+
## Channels
|
|
648
562
|
|
|
649
|
-
|
|
650
|
-
- `--action-file <path>`
|
|
651
|
-
- `--secondary-action <json>`
|
|
652
|
-
- `--secondary-action-file <path>`
|
|
563
|
+
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.
|
|
653
564
|
|
|
654
|
-
|
|
565
|
+
```bash
|
|
566
|
+
activitysmith push \
|
|
567
|
+
--title "Build Failed 🚨" \
|
|
568
|
+
--message "CI pipeline failed on main branch" \
|
|
569
|
+
--channels "devs,ops"
|
|
570
|
+
```
|
|
655
571
|
|
|
656
|
-
|
|
572
|
+
```bash
|
|
573
|
+
activitysmith activity stream nightly-backup \
|
|
574
|
+
--content-state '{
|
|
575
|
+
"title": "Nightly database backup",
|
|
576
|
+
"type": "segmented_progress",
|
|
577
|
+
"numberOfSteps": 4,
|
|
578
|
+
"currentStep": 1
|
|
579
|
+
}' \
|
|
580
|
+
--channels "devs,ops"
|
|
581
|
+
```
|
|
657
582
|
|
|
658
|
-
|
|
583
|
+
```bash
|
|
584
|
+
activitysmith badge 3 --channels "sales,customer-success"
|
|
585
|
+
```
|
|
659
586
|
|
|
660
|
-
|
|
587
|
+
## Output
|
|
661
588
|
|
|
662
|
-
|
|
589
|
+
Use `--json` for machine-readable output:
|
|
663
590
|
|
|
664
|
-
|
|
665
|
-
|
|
591
|
+
```bash
|
|
592
|
+
activitysmith push --title "Hello" --json
|
|
593
|
+
```
|
|
666
594
|
|
|
667
|
-
|
|
595
|
+
## Error Handling
|
|
668
596
|
|
|
669
|
-
-
|
|
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`
|
|
597
|
+
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.
|
|
674
598
|
|
|
675
|
-
##
|
|
599
|
+
## Additional Resources
|
|
676
600
|
|
|
677
|
-
|
|
601
|
+
### [NPM Package](https://www.npmjs.com/package/activitysmith-cli)
|
|
678
602
|
|
|
679
|
-
|
|
680
|
-
activitysmith push --title "Hello" --json
|
|
681
|
-
```
|
|
603
|
+
Install the ActivitySmith CLI from npm
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "activitysmith-cli",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "Command-line interface for ActivitySmith. Send
|
|
3
|
+
"version": "1.11.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.
|
|
45
|
+
"activitysmith": "^1.11.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
|
|
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
|
-
|
|
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")
|
|
@@ -231,6 +244,14 @@ const addContentStateOptions = (command, { includeAutoDismiss } = {}) => {
|
|
|
231
244
|
);
|
|
232
245
|
}
|
|
233
246
|
|
|
247
|
+
if (includeAutoDismissSeconds) {
|
|
248
|
+
command.option(
|
|
249
|
+
"--auto-dismiss-seconds <number>",
|
|
250
|
+
"Auto dismiss seconds for ended stream (takes precedence over minutes)",
|
|
251
|
+
parseIntegerOption("auto-dismiss-seconds")
|
|
252
|
+
);
|
|
253
|
+
}
|
|
254
|
+
|
|
234
255
|
return command;
|
|
235
256
|
};
|
|
236
257
|
|
|
@@ -388,6 +409,13 @@ const validateContentState = (contentState, mode) => {
|
|
|
388
409
|
const hasCountsDown = hasOwn(contentState, "countsDown");
|
|
389
410
|
const hasTimerFields = hasDurationSeconds || hasCountsDown;
|
|
390
411
|
|
|
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
|
+
|
|
391
419
|
if (hasValue !== hasUpperLimit) {
|
|
392
420
|
throw new Error(
|
|
393
421
|
"contentState.value and contentState.upperLimit must be provided together"
|
|
@@ -472,7 +500,7 @@ const validateContentState = (contentState, mode) => {
|
|
|
472
500
|
}
|
|
473
501
|
|
|
474
502
|
if (
|
|
475
|
-
|
|
503
|
+
hasMessage &&
|
|
476
504
|
(hasMetrics || hasSegmentedFields || hasProgressFields || hasStepColor)
|
|
477
505
|
) {
|
|
478
506
|
throw new Error(
|
|
@@ -552,7 +580,7 @@ const validateContentState = (contentState, mode) => {
|
|
|
552
580
|
}
|
|
553
581
|
|
|
554
582
|
if (effectiveType === "timer") {
|
|
555
|
-
if (!hasDurationSeconds && contentState.countsDown !== false) {
|
|
583
|
+
if (mode === "start" && !hasDurationSeconds && contentState.countsDown !== false) {
|
|
556
584
|
throw new Error(
|
|
557
585
|
`timer ${mode} requires contentState.durationSeconds, or contentState.countsDown=false`
|
|
558
586
|
);
|
|
@@ -637,7 +665,7 @@ const validateContentState = (contentState, mode) => {
|
|
|
637
665
|
}
|
|
638
666
|
};
|
|
639
667
|
|
|
640
|
-
const parseAction = (value, label) => {
|
|
668
|
+
const parseAction = (value, label, push = false) => {
|
|
641
669
|
assertPlainObject(value, label);
|
|
642
670
|
|
|
643
671
|
if (typeof value.title !== "string" || value.title.trim().length === 0) {
|
|
@@ -656,7 +684,7 @@ const parseAction = (value, label) => {
|
|
|
656
684
|
const action = {
|
|
657
685
|
title: value.title.trim(),
|
|
658
686
|
type: normalizedType,
|
|
659
|
-
url: normalizeActionUrl(value.url, `${label}.url`, normalizedType),
|
|
687
|
+
url: normalizeActionUrl(value.url, `${label}.url`, normalizedType, push),
|
|
660
688
|
};
|
|
661
689
|
|
|
662
690
|
if (value.method !== undefined) {
|
|
@@ -682,7 +710,7 @@ const parseAction = (value, label) => {
|
|
|
682
710
|
return action;
|
|
683
711
|
};
|
|
684
712
|
|
|
685
|
-
const parsePushAction = (value, index) => parseAction(value, `actions[${index}]
|
|
713
|
+
const parsePushAction = (value, index) => parseAction(value, `actions[${index}]`, true);
|
|
686
714
|
|
|
687
715
|
const loadPushActions = async (options) => {
|
|
688
716
|
if (options.actions && options.actionsFile) {
|
|
@@ -845,6 +873,10 @@ const buildContentStateFromOptions = (options) => {
|
|
|
845
873
|
contentState.stepColor = options.stepColor;
|
|
846
874
|
}
|
|
847
875
|
|
|
876
|
+
if (options.autoDismissSeconds !== undefined) {
|
|
877
|
+
contentState.autoDismissSeconds = options.autoDismissSeconds;
|
|
878
|
+
}
|
|
879
|
+
|
|
848
880
|
if (options.autoDismissMinutes !== undefined) {
|
|
849
881
|
contentState.autoDismissMinutes = options.autoDismissMinutes;
|
|
850
882
|
}
|
|
@@ -875,6 +907,7 @@ const toApiContentState = (contentState) => {
|
|
|
875
907
|
upperLimit: "upper_limit",
|
|
876
908
|
stepColor: "step_color",
|
|
877
909
|
autoDismissMinutes: "auto_dismiss_minutes",
|
|
910
|
+
autoDismissSeconds: "auto_dismiss_seconds",
|
|
878
911
|
durationSeconds: "duration_seconds",
|
|
879
912
|
countsDown: "counts_down",
|
|
880
913
|
};
|
|
@@ -926,8 +959,9 @@ const withTargetChannels = (request, channels) => {
|
|
|
926
959
|
};
|
|
927
960
|
};
|
|
928
961
|
|
|
929
|
-
const withTags = (request, tags) => {
|
|
930
|
-
if (
|
|
962
|
+
const withTags = (request, tags, metadata) => {
|
|
963
|
+
if (metadata !== undefined) request = { ...request, metadata };
|
|
964
|
+
if (tags === undefined) {
|
|
931
965
|
return request;
|
|
932
966
|
}
|
|
933
967
|
|
|
@@ -1232,7 +1266,9 @@ program
|
|
|
1232
1266
|
"Comma-separated tags for organizing history (repeatable)",
|
|
1233
1267
|
parseTagsOption
|
|
1234
1268
|
)
|
|
1235
|
-
.
|
|
1269
|
+
.option("--metadata <json>", "Metadata JSON object shown in ActivitySmith details")
|
|
1270
|
+
.option("--metadata-file <path>", "Path to a Metadata JSON object file")
|
|
1271
|
+
.action(async (options) => {
|
|
1236
1272
|
const globalOptions = program.opts();
|
|
1237
1273
|
|
|
1238
1274
|
try {
|
|
@@ -1259,6 +1295,7 @@ program
|
|
|
1259
1295
|
: undefined,
|
|
1260
1296
|
actions,
|
|
1261
1297
|
tags: options.tags,
|
|
1298
|
+
metadata: await loadMetadata(options),
|
|
1262
1299
|
},
|
|
1263
1300
|
options.channels
|
|
1264
1301
|
);
|
|
@@ -1311,8 +1348,8 @@ program
|
|
|
1311
1348
|
? "App Icon Badge Count cleared."
|
|
1312
1349
|
: "App Icon Badge Count updated.",
|
|
1313
1350
|
response?.badge !== undefined ? `Badge: ${response.badge}` : null,
|
|
1314
|
-
response?.devicesNotified !== undefined
|
|
1315
|
-
? `Devices
|
|
1351
|
+
response?.devicesUpdated !== undefined || response?.devicesNotified !== undefined
|
|
1352
|
+
? `Devices updated: ${response.devicesUpdated ?? response.devicesNotified}`
|
|
1316
1353
|
: null,
|
|
1317
1354
|
]);
|
|
1318
1355
|
} catch (error) {
|
|
@@ -1330,7 +1367,9 @@ metricsCommand
|
|
|
1330
1367
|
.description("Update a widget metric value")
|
|
1331
1368
|
.argument("<metric-key>", "Metric key")
|
|
1332
1369
|
.argument("<value>", "Metric value")
|
|
1333
|
-
.
|
|
1370
|
+
.option("--metadata <json>", "Metadata JSON object shown in ActivitySmith details")
|
|
1371
|
+
.option("--metadata-file <path>", "Path to a Metadata JSON object file")
|
|
1372
|
+
.action(async (metricKey, rawValue) => {
|
|
1334
1373
|
const globalOptions = program.opts();
|
|
1335
1374
|
|
|
1336
1375
|
try {
|
|
@@ -1347,7 +1386,7 @@ metricsCommand
|
|
|
1347
1386
|
|
|
1348
1387
|
const activityCommand = program
|
|
1349
1388
|
.command("activity")
|
|
1350
|
-
.description("
|
|
1389
|
+
.description("Start, update, and end Live Activities");
|
|
1351
1390
|
|
|
1352
1391
|
addLiveActivityActionOptions(addContentStateOptions(
|
|
1353
1392
|
activityCommand
|
|
@@ -1364,10 +1403,16 @@ addLiveActivityActionOptions(addContentStateOptions(
|
|
|
1364
1403
|
"Comma-separated tags for organizing history (repeatable)",
|
|
1365
1404
|
parseTagsOption
|
|
1366
1405
|
)
|
|
1406
|
+
.option("--clear-tags", "Remove all Tags from this stream")
|
|
1407
|
+
.option("--metadata <json>", "Metadata JSON object shown in ActivitySmith details")
|
|
1408
|
+
.option("--metadata-file <path>", "Path to a Metadata JSON object file")
|
|
1367
1409
|
.action(async (streamKey, options) => {
|
|
1368
1410
|
const globalOptions = program.opts();
|
|
1369
1411
|
|
|
1370
1412
|
try {
|
|
1413
|
+
if (options.clearTags && options.tags !== undefined) {
|
|
1414
|
+
throw new Error("Use either --tags or --clear-tags, not both.");
|
|
1415
|
+
}
|
|
1371
1416
|
const apiKey = requireApiKey(globalOptions);
|
|
1372
1417
|
const client = createClient(apiKey);
|
|
1373
1418
|
const contentState = await loadContentState(options, "stream");
|
|
@@ -1385,7 +1430,8 @@ addLiveActivityActionOptions(addContentStateOptions(
|
|
|
1385
1430
|
),
|
|
1386
1431
|
options.channels
|
|
1387
1432
|
),
|
|
1388
|
-
options.tags
|
|
1433
|
+
options.clearTags ? [] : options.tags,
|
|
1434
|
+
await loadMetadata(options)
|
|
1389
1435
|
)
|
|
1390
1436
|
);
|
|
1391
1437
|
|
|
@@ -1417,6 +1463,8 @@ addLiveActivityActionOptions(addContentStateOptions(
|
|
|
1417
1463
|
"Comma-separated tags for organizing history (repeatable)",
|
|
1418
1464
|
parseTagsOption
|
|
1419
1465
|
)
|
|
1466
|
+
.option("--metadata <json>", "Metadata JSON object shown in ActivitySmith details")
|
|
1467
|
+
.option("--metadata-file <path>", "Path to a Metadata JSON object file")
|
|
1420
1468
|
.action(async (options) => {
|
|
1421
1469
|
const globalOptions = program.opts();
|
|
1422
1470
|
|
|
@@ -1437,7 +1485,8 @@ addLiveActivityActionOptions(addContentStateOptions(
|
|
|
1437
1485
|
),
|
|
1438
1486
|
options.channels
|
|
1439
1487
|
),
|
|
1440
|
-
options.tags
|
|
1488
|
+
options.tags,
|
|
1489
|
+
await loadMetadata(options)
|
|
1441
1490
|
),
|
|
1442
1491
|
});
|
|
1443
1492
|
|
|
@@ -1457,10 +1506,17 @@ addLiveActivityActionOptions(addContentStateOptions(
|
|
|
1457
1506
|
.command("update")
|
|
1458
1507
|
.description("Update a Live Activity")
|
|
1459
1508
|
.requiredOption("--activity-id <id>", "Live Activity ID")
|
|
1509
|
+
.option("--tags <tags>", "Replace Tags for this Live Activity (repeatable)", parseTagsOption)
|
|
1510
|
+
.option("--clear-tags", "Remove all Tags from this Live Activity")
|
|
1511
|
+
.option("--metadata <json>", "Metadata JSON object shown in ActivitySmith details")
|
|
1512
|
+
.option("--metadata-file <path>", "Path to a Metadata JSON object file")
|
|
1460
1513
|
.action(async (options) => {
|
|
1461
1514
|
const globalOptions = program.opts();
|
|
1462
1515
|
|
|
1463
1516
|
try {
|
|
1517
|
+
if (options.clearTags && options.tags !== undefined) {
|
|
1518
|
+
throw new Error("Use either --tags or --clear-tags, not both.");
|
|
1519
|
+
}
|
|
1464
1520
|
const apiKey = requireApiKey(globalOptions);
|
|
1465
1521
|
const client = createClient(apiKey);
|
|
1466
1522
|
const contentState = await loadContentState(options, "update");
|
|
@@ -1468,12 +1524,12 @@ addLiveActivityActionOptions(addContentStateOptions(
|
|
|
1468
1524
|
const secondaryAction = await loadLiveActivitySecondaryAction(options);
|
|
1469
1525
|
|
|
1470
1526
|
const response = await client.liveActivities.updateLiveActivity({
|
|
1471
|
-
liveActivityUpdateRequest: toApiLiveActivityUpdateRequest(
|
|
1527
|
+
liveActivityUpdateRequest: withTags(toApiLiveActivityUpdateRequest(
|
|
1472
1528
|
options.activityId,
|
|
1473
1529
|
contentState,
|
|
1474
1530
|
action,
|
|
1475
1531
|
secondaryAction
|
|
1476
|
-
),
|
|
1532
|
+
), options.clearTags ? [] : options.tags, await loadMetadata(options)),
|
|
1477
1533
|
});
|
|
1478
1534
|
|
|
1479
1535
|
outputResult(response, globalOptions, [
|
|
@@ -1491,10 +1547,17 @@ addLiveActivityActionOptions(addContentStateOptions(
|
|
|
1491
1547
|
.command("end")
|
|
1492
1548
|
.description("End a Live Activity")
|
|
1493
1549
|
.requiredOption("--activity-id <id>", "Live Activity ID")
|
|
1550
|
+
.option("--tags <tags>", "Replace Tags for this Live Activity (repeatable)", parseTagsOption)
|
|
1551
|
+
.option("--clear-tags", "Remove all Tags from this Live Activity")
|
|
1552
|
+
.option("--metadata <json>", "Metadata JSON object shown in ActivitySmith details")
|
|
1553
|
+
.option("--metadata-file <path>", "Path to a Metadata JSON object file")
|
|
1494
1554
|
.action(async (options) => {
|
|
1495
1555
|
const globalOptions = program.opts();
|
|
1496
1556
|
|
|
1497
1557
|
try {
|
|
1558
|
+
if (options.clearTags && options.tags !== undefined) {
|
|
1559
|
+
throw new Error("Use either --tags or --clear-tags, not both.");
|
|
1560
|
+
}
|
|
1498
1561
|
const apiKey = requireApiKey(globalOptions);
|
|
1499
1562
|
const client = createClient(apiKey);
|
|
1500
1563
|
const contentState = await loadContentState(options, "end");
|
|
@@ -1502,12 +1565,12 @@ addLiveActivityActionOptions(addContentStateOptions(
|
|
|
1502
1565
|
const secondaryAction = await loadLiveActivitySecondaryAction(options);
|
|
1503
1566
|
|
|
1504
1567
|
const response = await client.liveActivities.endLiveActivity({
|
|
1505
|
-
liveActivityEndRequest: toApiLiveActivityEndRequest(
|
|
1568
|
+
liveActivityEndRequest: withTags(toApiLiveActivityEndRequest(
|
|
1506
1569
|
options.activityId,
|
|
1507
1570
|
contentState,
|
|
1508
1571
|
action,
|
|
1509
1572
|
secondaryAction
|
|
1510
|
-
),
|
|
1573
|
+
), options.clearTags ? [] : options.tags, await loadMetadata(options)),
|
|
1511
1574
|
});
|
|
1512
1575
|
|
|
1513
1576
|
outputResult(response, globalOptions, [
|
|
@@ -1526,10 +1589,17 @@ addLiveActivityActionOptions(addContentStateOptions(
|
|
|
1526
1589
|
.command("end-stream")
|
|
1527
1590
|
.description("End a stateless Live Activity stream")
|
|
1528
1591
|
.argument("<stream-key>", "Stable stream key")
|
|
1592
|
+
.option("--tags <tags>", "Comma-separated Tags", parseTagsOption)
|
|
1593
|
+
.option("--clear-tags", "Clear existing Tags")
|
|
1594
|
+
.option("--metadata <json>", "Metadata as a JSON object")
|
|
1595
|
+
.option("--metadata-file <path>", "Metadata JSON file path")
|
|
1529
1596
|
.action(async (streamKey, options) => {
|
|
1530
1597
|
const globalOptions = program.opts();
|
|
1531
1598
|
|
|
1532
1599
|
try {
|
|
1600
|
+
if (options.clearTags && options.tags !== undefined) throw new Error("Provide either --tags or --clear-tags, not both.");
|
|
1601
|
+
const tags = options.clearTags ? [] : options.tags;
|
|
1602
|
+
const metadata = await loadMetadata(options);
|
|
1533
1603
|
const apiKey = requireApiKey(globalOptions);
|
|
1534
1604
|
const client = createClient(apiKey);
|
|
1535
1605
|
const contentState = await loadOptionalContentState(options, "end");
|
|
@@ -1539,7 +1609,7 @@ addLiveActivityActionOptions(addContentStateOptions(
|
|
|
1539
1609
|
const request =
|
|
1540
1610
|
contentState !== undefined ||
|
|
1541
1611
|
action !== undefined ||
|
|
1542
|
-
secondaryAction !== undefined
|
|
1612
|
+
secondaryAction !== undefined || tags !== undefined || metadata !== undefined
|
|
1543
1613
|
? toApiLiveActivityStreamDeleteRequest(
|
|
1544
1614
|
contentState,
|
|
1545
1615
|
action,
|
|
@@ -1547,6 +1617,8 @@ addLiveActivityActionOptions(addContentStateOptions(
|
|
|
1547
1617
|
)
|
|
1548
1618
|
: undefined;
|
|
1549
1619
|
|
|
1620
|
+
if (tags !== undefined) request.tags = tags;
|
|
1621
|
+
if (metadata !== undefined) request.metadata = metadata;
|
|
1550
1622
|
const response = await client.liveActivities.endStream(streamKey, request);
|
|
1551
1623
|
|
|
1552
1624
|
const activityId = response?.activityId ?? response?.activity_id;
|
|
@@ -1561,7 +1633,7 @@ addLiveActivityActionOptions(addContentStateOptions(
|
|
|
1561
1633
|
await handleError(error, globalOptions);
|
|
1562
1634
|
}
|
|
1563
1635
|
}),
|
|
1564
|
-
{ includeAutoDismiss: true }
|
|
1636
|
+
{ includeAutoDismiss: true, includeAutoDismissSeconds: true }
|
|
1565
1637
|
));
|
|
1566
1638
|
|
|
1567
1639
|
program.showHelpAfterError(true);
|
package/src/metadata.js
ADDED
|
@@ -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
|
+
}
|