activitysmith-cli 1.9.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 +242 -304
- package/package.json +5 -4
- package/src/cli.js +155 -33
- package/src/metadata.js +27 -0
package/README.md
CHANGED
|
@@ -1,30 +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
|
-
- [Aliases](#aliases)
|
|
24
|
-
- [Content State Options](#content-state-options)
|
|
25
|
-
- [Output](#output)
|
|
26
|
-
|
|
27
|
-
## Install
|
|
3
|
+
[Documentation](https://activitysmith.com/docs/sdks/cli)
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
Install the ActivitySmith CLI globally with npm:
|
|
28
8
|
|
|
29
9
|
```bash
|
|
30
10
|
npm install -g activitysmith-cli
|
|
@@ -32,79 +12,65 @@ npm install -g activitysmith-cli
|
|
|
32
12
|
|
|
33
13
|
## Agent Skill
|
|
34
14
|
|
|
35
|
-
|
|
36
|
-
<img src="https://cdn.activitysmith.com/features/apple-shortcut-actions.png" alt="ActivitySmith Push Notification Actions with an Apple Shortcut action" width="680" />
|
|
37
|
-
</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.
|
|
38
16
|
|
|
39
|
-
|
|
17
|
+
```bash
|
|
18
|
+
npx -y skills@latest add ActivitySmithHQ/activitysmith-cli --skill activitysmith
|
|
19
|
+
```
|
|
40
20
|
|
|
41
|
-
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.
|
|
42
22
|
|
|
43
|
-
|
|
44
|
-
- "Send me a push notification if you get blocked."
|
|
45
|
-
- "When the task finishes, the notification tap should run my Test Shortcut."
|
|
46
|
-
- "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.
|
|
47
24
|
|
|
48
|
-
|
|
25
|
+
## Quickstart
|
|
49
26
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
- Live Activities for long-running progress
|
|
54
|
-
- widget metrics for values that should stay visible
|
|
55
|
-
- 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.
|
|
56
30
|
|
|
57
|
-
|
|
31
|
+
Use the environment variable when you want the cleanest shell scripts:
|
|
58
32
|
|
|
59
33
|
```bash
|
|
60
|
-
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
Skill path in this repo:
|
|
34
|
+
export ACTIVITYSMITH_API_KEY="YOUR-API-KEY"
|
|
64
35
|
|
|
65
|
-
|
|
66
|
-
skills/activitysmith
|
|
36
|
+
activitysmith --help
|
|
67
37
|
```
|
|
68
38
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
## Auth
|
|
39
|
+
Or pass the key directly:
|
|
72
40
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
41
|
+
```bash
|
|
42
|
+
activitysmith --api-key "YOUR-API-KEY" push --title "Hello"
|
|
43
|
+
```
|
|
76
44
|
|
|
77
45
|
## Push Notifications
|
|
78
46
|
|
|
79
|
-
|
|
47
|
+
### Send a Push Notification
|
|
80
48
|
|
|
81
|
-
|
|
49
|
+
Send an immediate notification for a completed task or event.
|
|
50
|
+
|
|
51
|
+

|
|
82
52
|
|
|
83
53
|
```bash
|
|
84
54
|
activitysmith push \
|
|
85
55
|
--title "Build Failed 🚨" \
|
|
86
|
-
--message "CI pipeline failed on main branch"
|
|
56
|
+
--message "CI pipeline failed on main branch" \
|
|
57
|
+
--subtitle "main"
|
|
87
58
|
```
|
|
88
59
|
|
|
89
60
|
### Rich Push Notifications with Media
|
|
90
61
|
|
|
91
|
-
|
|
92
|
-
<img src="https://cdn.activitysmith.com/features/rich-push-notification-with-image.png" alt="Rich push notification with image" width="680" />
|
|
93
|
-
</p>
|
|
62
|
+

|
|
94
63
|
|
|
95
64
|
```bash
|
|
96
65
|
activitysmith push \
|
|
97
66
|
--title "Homepage ready" \
|
|
98
67
|
--message "Your agent finished the redesign." \
|
|
99
|
-
--media "https://cdn.example.com/output/homepage-v2.png"
|
|
100
|
-
--redirection "https://github.com/acme/web/pull/482"
|
|
68
|
+
--media "https://cdn.example.com/output/homepage-v2.png"
|
|
101
69
|
```
|
|
102
70
|
|
|
103
|
-
|
|
71
|
+
Attach images, videos, or audio to your Push Notifications. Press and hold the notification to preview the media.
|
|
104
72
|
|
|
105
|
-
|
|
106
|
-
<img src="https://cdn.activitysmith.com/features/rich-push-notification-with-audio.png" alt="Rich push notification with audio" width="680" />
|
|
107
|
-
</p>
|
|
73
|
+

|
|
108
74
|
|
|
109
75
|
What will work:
|
|
110
76
|
|
|
@@ -113,25 +79,50 @@ What will work:
|
|
|
113
79
|
- direct video file URL: `.mp4`, `.mov`, etc.
|
|
114
80
|
- URL that responds with a proper media `Content-Type`, even if the path has no extension
|
|
115
81
|
|
|
116
|
-
`--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
|
+
```
|
|
117
102
|
|
|
118
103
|
### Actionable Push Notifications
|
|
119
104
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
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:
|
|
123
108
|
|
|
124
|
-
|
|
125
|
-
|
|
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.
|
|
126
118
|
|
|
127
119
|
```bash
|
|
128
120
|
activitysmith push \
|
|
129
121
|
--title "Build Failed 🚨" \
|
|
130
122
|
--message "CI pipeline failed on main branch" \
|
|
131
|
-
--redirection "https://github.com/org/repo/actions/runs/123456789" \
|
|
132
123
|
--actions '[
|
|
133
124
|
{
|
|
134
|
-
"title": "Open
|
|
125
|
+
"title": "Open Build",
|
|
135
126
|
"type": "open_url",
|
|
136
127
|
"url": "https://github.com/org/repo/actions/runs/123456789"
|
|
137
128
|
},
|
|
@@ -154,7 +145,7 @@ activitysmith push \
|
|
|
154
145
|
]'
|
|
155
146
|
```
|
|
156
147
|
|
|
157
|
-
You can also
|
|
148
|
+
You can also save the JSON array above as `actions.json` and load it from a file:
|
|
158
149
|
|
|
159
150
|
```bash
|
|
160
151
|
activitysmith push \
|
|
@@ -165,14 +156,31 @@ activitysmith push \
|
|
|
165
156
|
|
|
166
157
|
## Live Activities
|
|
167
158
|
|
|
168
|
-
|
|
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
|
+

|
|
169
174
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
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.
|
|
176
184
|
|
|
177
185
|
### Start & Update Live Activity
|
|
178
186
|
|
|
@@ -180,13 +188,7 @@ Use a stable `stream_key` to identify the metric, job, deployment, or system you
|
|
|
180
188
|
|
|
181
189
|
#### Stats
|
|
182
190
|
|
|
183
|
-
|
|
184
|
-
<img
|
|
185
|
-
src="https://cdn.activitysmith.com/features/stats-live-activity.png"
|
|
186
|
-
alt="Stats Live Activity stream example"
|
|
187
|
-
width="680"
|
|
188
|
-
/>
|
|
189
|
-
</p>
|
|
191
|
+

|
|
190
192
|
|
|
191
193
|
```bash
|
|
192
194
|
activitysmith activity stream sales-hourly \
|
|
@@ -207,13 +209,7 @@ activitysmith activity stream sales-hourly \
|
|
|
207
209
|
|
|
208
210
|
#### Metrics
|
|
209
211
|
|
|
210
|
-
|
|
211
|
-
<img
|
|
212
|
-
src="https://cdn.activitysmith.com/features/metrics-live-activity-start.png"
|
|
213
|
-
alt="Metrics Live Activity stream example"
|
|
214
|
-
width="680"
|
|
215
|
-
/>
|
|
216
|
-
</p>
|
|
212
|
+

|
|
217
213
|
|
|
218
214
|
```bash
|
|
219
215
|
activitysmith activity stream prod-web-1 \
|
|
@@ -230,13 +226,7 @@ activitysmith activity stream prod-web-1 \
|
|
|
230
226
|
|
|
231
227
|
#### Segmented Progress
|
|
232
228
|
|
|
233
|
-
|
|
234
|
-
<img
|
|
235
|
-
src="https://cdn.activitysmith.com/features/update-live-activity.png"
|
|
236
|
-
alt="Segmented Progress Live Activity stream example"
|
|
237
|
-
width="680"
|
|
238
|
-
/>
|
|
239
|
-
</p>
|
|
229
|
+

|
|
240
230
|
|
|
241
231
|
```bash
|
|
242
232
|
activitysmith activity stream nightly-backup \
|
|
@@ -251,13 +241,7 @@ activitysmith activity stream nightly-backup \
|
|
|
251
241
|
|
|
252
242
|
#### Progress
|
|
253
243
|
|
|
254
|
-
|
|
255
|
-
<img
|
|
256
|
-
src="https://cdn.activitysmith.com/features/progress-live-activity.png"
|
|
257
|
-
alt="Progress Live Activity stream example"
|
|
258
|
-
width="680"
|
|
259
|
-
/>
|
|
260
|
-
</p>
|
|
244
|
+

|
|
261
245
|
|
|
262
246
|
```bash
|
|
263
247
|
activitysmith activity stream search-reindex \
|
|
@@ -271,13 +255,7 @@ activitysmith activity stream search-reindex \
|
|
|
271
255
|
|
|
272
256
|
#### Alert
|
|
273
257
|
|
|
274
|
-
|
|
275
|
-
<img
|
|
276
|
-
src="https://cdn.activitysmith.com/features/alert-live-activity.png"
|
|
277
|
-
alt="Alert Live Activity stream example"
|
|
278
|
-
width="680"
|
|
279
|
-
/>
|
|
280
|
-
</p>
|
|
258
|
+

|
|
281
259
|
|
|
282
260
|
```bash
|
|
283
261
|
activitysmith activity stream customer-ops \
|
|
@@ -298,13 +276,7 @@ activitysmith activity stream customer-ops \
|
|
|
298
276
|
|
|
299
277
|
#### Timer
|
|
300
278
|
|
|
301
|
-
|
|
302
|
-
<img
|
|
303
|
-
src="https://cdn.activitysmith.com/features/timer-live-activity.png"
|
|
304
|
-
alt="Timer Live Activity showing a benchmark run countdown"
|
|
305
|
-
width="680"
|
|
306
|
-
/>
|
|
307
|
-
</p>
|
|
279
|
+

|
|
308
280
|
|
|
309
281
|
```bash
|
|
310
282
|
activitysmith activity stream benchmark-run \
|
|
@@ -317,16 +289,17 @@ activitysmith activity stream benchmark-run \
|
|
|
317
289
|
}'
|
|
318
290
|
```
|
|
319
291
|
|
|
320
|
-
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.
|
|
321
293
|
|
|
322
|
-
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`.
|
|
323
295
|
|
|
324
296
|
### End Live Activity
|
|
325
297
|
|
|
326
|
-
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`.
|
|
327
299
|
|
|
328
300
|
```bash
|
|
329
301
|
activitysmith activity end-stream prod-web-1 \
|
|
302
|
+
--auto-dismiss-seconds 30 \
|
|
330
303
|
--content-state '{
|
|
331
304
|
"title": "Server Health",
|
|
332
305
|
"subtitle": "prod-web-1",
|
|
@@ -334,29 +307,66 @@ activitysmith activity end-stream prod-web-1 \
|
|
|
334
307
|
"metrics": [
|
|
335
308
|
{ "label": "CPU", "value": 7, "unit": "%" },
|
|
336
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": "%" }
|
|
337
328
|
],
|
|
338
|
-
"
|
|
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" }
|
|
339
345
|
}'
|
|
340
346
|
```
|
|
341
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
|
+
|
|
342
354
|
### Live Activity Action
|
|
343
355
|
|
|
344
|
-
Live
|
|
356
|
+

|
|
345
357
|
|
|
346
|
-
|
|
347
|
-
- `open_url` with a `shortcuts://` URL: run an Apple Shortcut, for example to open an app.
|
|
348
|
-
- `webhook`: trigger a backend GET/POST workflow.
|
|
358
|
+
Live Activities can include an action button.
|
|
349
359
|
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
src="https://cdn.activitysmith.com/features/metrics-live-activity-action.png"
|
|
353
|
-
alt="Live Activity with action button"
|
|
354
|
-
width="680"
|
|
355
|
-
/>
|
|
356
|
-
</p>
|
|
360
|
+
- `open_url`: Open a web page or run an iOS Shortcut
|
|
361
|
+
- `webhook`: Trigger a backend GET/POST workflow
|
|
357
362
|
|
|
358
363
|
#### Open URL action
|
|
359
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
|
+
|
|
360
370
|
```bash
|
|
361
371
|
activitysmith activity stream prod-web-1 \
|
|
362
372
|
--content-state '{
|
|
@@ -371,20 +381,22 @@ activitysmith activity stream prod-web-1 \
|
|
|
371
381
|
--action '{
|
|
372
382
|
"title": "Dashboard",
|
|
373
383
|
"type": "open_url",
|
|
374
|
-
"url": "https://
|
|
384
|
+
"url": "https://status.example.com/servers/prod-web-1"
|
|
375
385
|
}'
|
|
376
386
|
```
|
|
377
387
|
|
|
378
388
|
#### Apple Shortcut action
|
|
379
389
|
|
|
380
390
|
```bash
|
|
381
|
-
activitysmith activity stream
|
|
391
|
+
activitysmith activity stream prod-web-1 \
|
|
382
392
|
--content-state '{
|
|
383
|
-
"title": "
|
|
384
|
-
"subtitle": "
|
|
385
|
-
"type": "
|
|
386
|
-
"
|
|
387
|
-
|
|
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
|
+
]
|
|
388
400
|
}' \
|
|
389
401
|
--action '{
|
|
390
402
|
"title": "Chat with Jarvis",
|
|
@@ -418,13 +430,7 @@ activitysmith activity stream search-reindex \
|
|
|
418
430
|
|
|
419
431
|
#### Secondary action
|
|
420
432
|
|
|
421
|
-
|
|
422
|
-
<img
|
|
423
|
-
src="https://cdn.activitysmith.com/features/live-activity-secondary-action.png"
|
|
424
|
-
alt="Alert Live Activity with primary and secondary action buttons"
|
|
425
|
-
width="680"
|
|
426
|
-
/>
|
|
427
|
-
</p>
|
|
433
|
+

|
|
428
434
|
|
|
429
435
|
Use `--secondary-action` when you want a second button beside the primary `--action`.
|
|
430
436
|
|
|
@@ -443,95 +449,32 @@ activitysmith activity stream agent-approval \
|
|
|
443
449
|
--action '{
|
|
444
450
|
"title": "Send",
|
|
445
451
|
"type": "webhook",
|
|
446
|
-
"url": "https://
|
|
452
|
+
"url": "https://agent.example.com/live-activity/approve",
|
|
447
453
|
"method": "POST",
|
|
448
|
-
"body": {
|
|
454
|
+
"body": {
|
|
455
|
+
"approval_id": "approval_01JY3J7Q9S0P8M1V5PZK7DR4M2",
|
|
456
|
+
"decision": "send"
|
|
457
|
+
}
|
|
449
458
|
}' \
|
|
450
459
|
--secondary-action '{
|
|
451
460
|
"title": "Deny",
|
|
452
461
|
"type": "webhook",
|
|
453
|
-
"url": "https://
|
|
462
|
+
"url": "https://agent.example.com/live-activity/deny",
|
|
454
463
|
"method": "POST",
|
|
455
|
-
"body": {
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
### Icons and Badges
|
|
460
|
-
|
|
461
|
-
Add more context to Live Activities with icons and badges.
|
|
462
|
-
|
|
463
|
-
#### Icon
|
|
464
|
-
|
|
465
|
-
Supported Live Activity types: `stats`, `metrics`, `progress`, `segmented_progress`, and `alert`.
|
|
466
|
-
|
|
467
|
-
<p align="center">
|
|
468
|
-
<img
|
|
469
|
-
src="https://cdn.activitysmith.com/features/metrics-live-activity-with-icon.png"
|
|
470
|
-
alt="Metrics Live Activity with an SF Symbol icon on the iPhone Lock Screen"
|
|
471
|
-
width="680"
|
|
472
|
-
/>
|
|
473
|
-
</p>
|
|
474
|
-
|
|
475
|
-
```bash
|
|
476
|
-
activitysmith activity stream prod-web-1 \
|
|
477
|
-
--content-state '{
|
|
478
|
-
"title": "Server Health",
|
|
479
|
-
"subtitle": "prod-web-1",
|
|
480
|
-
"type": "metrics",
|
|
481
|
-
"icon": { "symbol": "server.rack", "color": "blue" },
|
|
482
|
-
"metrics": [
|
|
483
|
-
{ "label": "CPU", "value": 18, "unit": "%" },
|
|
484
|
-
{ "label": "MEM", "value": 42, "unit": "%" }
|
|
485
|
-
]
|
|
486
|
-
}'
|
|
487
|
-
```
|
|
488
|
-
|
|
489
|
-
The `icon.symbol` value is an Apple SF Symbol name. Browse the catalog with one of these tools:
|
|
490
|
-
|
|
491
|
-
- [ActivitySmith app](https://apps.apple.com/us/app/activitysmith/id6752254835) - Open Settings -> SF Symbols to browse 45 hand-picked icons ready to use
|
|
492
|
-
- [SF Symbols](https://developer.apple.com/sf-symbols/) - Apple's official macOS app
|
|
493
|
-
- [Interactful](https://apps.apple.com/app/interactful/id1528095640) - free third-party iOS app listing all SF Symbols under Foundations -> Iconography
|
|
494
|
-
|
|
495
|
-
#### Badge
|
|
496
|
-
|
|
497
|
-
Badges are supported by `alert`, `progress`, and `segmented_progress` Live Activities.
|
|
498
|
-
|
|
499
|
-
<p align="center">
|
|
500
|
-
<img
|
|
501
|
-
src="https://cdn.activitysmith.com/features/progress-live-activity-with-badge.png"
|
|
502
|
-
alt="Progress Live Activity with a badge on the iPhone Lock Screen"
|
|
503
|
-
width="680"
|
|
504
|
-
/>
|
|
505
|
-
</p>
|
|
506
|
-
|
|
507
|
-
```bash
|
|
508
|
-
activitysmith activity stream nightly-database-backup \
|
|
509
|
-
--content-state '{
|
|
510
|
-
"title": "Nightly Database Backup",
|
|
511
|
-
"subtitle": "verify restore",
|
|
512
|
-
"type": "progress",
|
|
513
|
-
"badge": { "title": "S3", "color": "cyan" },
|
|
514
|
-
"percentage": 62
|
|
464
|
+
"body": {
|
|
465
|
+
"approval_id": "approval_01JY3J7Q9S0P8M1V5PZK7DR4M2",
|
|
466
|
+
"decision": "deny"
|
|
467
|
+
}
|
|
515
468
|
}'
|
|
516
469
|
```
|
|
517
470
|
|
|
518
|
-
|
|
471
|
+
## Lock Screen Widgets
|
|
519
472
|
|
|
520
|
-
|
|
473
|
+

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

|
|
535
478
|
|
|
536
479
|
Use the metric key to update its value.
|
|
537
480
|
|
|
@@ -547,119 +490,114 @@ activitysmith metrics update prod.status healthy
|
|
|
547
490
|
|
|
548
491
|
## App Icon Badge Count
|
|
549
492
|
|
|
550
|
-
|
|
551
|
-
<img src="https://cdn.activitysmith.com/features/badge-count.png" alt="ActivitySmith app icon with an App Icon Badge Count" width="680" />
|
|
552
|
-
</p>
|
|
493
|
+

|
|
553
494
|
|
|
554
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.
|
|
555
496
|
|
|
556
|
-
Set or update the badge value
|
|
497
|
+
### Set or update the badge value
|
|
557
498
|
|
|
558
499
|
```bash
|
|
559
500
|
activitysmith badge 8333
|
|
560
501
|
```
|
|
561
502
|
|
|
562
|
-
|
|
503
|
+
### Clear the badge
|
|
504
|
+
|
|
505
|
+
Pass `0` to clear the badge.
|
|
563
506
|
|
|
564
507
|
```bash
|
|
565
508
|
activitysmith badge 0
|
|
566
509
|
```
|
|
567
510
|
|
|
568
|
-
##
|
|
569
|
-
|
|
570
|
-
Use `--channels` to target specific team members or devices
|
|
511
|
+
## Metadata
|
|
571
512
|
|
|
572
|
-
|
|
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.
|
|
573
514
|
|
|
574
515
|
```bash
|
|
575
516
|
activitysmith push \
|
|
576
517
|
--title "New subscription 💸" \
|
|
577
518
|
--message "Customer upgraded to Pro plan" \
|
|
578
|
-
--
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
519
|
+
--metadata '{
|
|
520
|
+
"customer_id": "382",
|
|
521
|
+
"plan": "Pro",
|
|
522
|
+
"amount": 29,
|
|
523
|
+
"trial": false
|
|
524
|
+
}'
|
|
582
525
|
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
--title "Nightly Database Backup" \
|
|
586
|
-
--subtitle "verify restore" \
|
|
526
|
+
activitysmith activity stream customer-import \
|
|
527
|
+
--title "Customer Import" \
|
|
587
528
|
--type progress \
|
|
588
|
-
--percentage
|
|
589
|
-
--
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
```bash
|
|
595
|
-
activitysmith badge 3 --channels "sales,customer-success"
|
|
529
|
+
--percentage 60 \
|
|
530
|
+
--metadata '{
|
|
531
|
+
"job_id": "import-382",
|
|
532
|
+
"records": 1200
|
|
533
|
+
}'
|
|
596
534
|
```
|
|
597
535
|
|
|
598
|
-
|
|
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.
|
|
599
537
|
|
|
600
|
-
|
|
538
|
+
## Tags
|
|
601
539
|
|
|
602
|
-
|
|
603
|
-
- `activitysmith-cli` (alias)
|
|
540
|
+
Use `tags` to organize and filter your Push Notification and Live Activity history. Tags are created automatically when you first use them.
|
|
604
541
|
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
542
|
+
```bash
|
|
543
|
+
activitysmith push \
|
|
544
|
+
--title "New subscription 💸" \
|
|
545
|
+
--message "Customer upgraded to Pro plan" \
|
|
546
|
+
--tags "user:382,billing"
|
|
547
|
+
```
|
|
611
548
|
|
|
612
|
-
For `
|
|
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
|
-
|
|
551
|
+
```bash
|
|
552
|
+
activitysmith activity stream customer-import \
|
|
553
|
+
--title "Customer Import" \
|
|
554
|
+
--type progress \
|
|
555
|
+
--percentage 60 \
|
|
556
|
+
--clear-tags
|
|
557
|
+
```
|
|
616
558
|
|
|
617
|
-
|
|
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.
|
|
618
560
|
|
|
619
|
-
|
|
620
|
-
- `--subtitle <subtitle>`
|
|
621
|
-
- `--type <type>`
|
|
622
|
-
- `--number-of-steps <number>`
|
|
623
|
-
- `--current-step <number>`
|
|
624
|
-
- `--percentage <number>`
|
|
625
|
-
- `--value <number>`
|
|
626
|
-
- `--upper-limit <number>`
|
|
627
|
-
- `--duration-seconds <number>`
|
|
628
|
-
- `--counts-down <true|false>`
|
|
629
|
-
- `--color <color>`
|
|
630
|
-
- `--step-color <color>`
|
|
631
|
-
- `--auto-dismiss-minutes <number>`
|
|
561
|
+
## Channels
|
|
632
562
|
|
|
633
|
-
|
|
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.
|
|
634
564
|
|
|
635
|
-
|
|
565
|
+
```bash
|
|
566
|
+
activitysmith push \
|
|
567
|
+
--title "Build Failed 🚨" \
|
|
568
|
+
--message "CI pipeline failed on main branch" \
|
|
569
|
+
--channels "devs,ops"
|
|
570
|
+
```
|
|
636
571
|
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
-
|
|
640
|
-
|
|
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
|
+
```
|
|
641
582
|
|
|
642
|
-
|
|
583
|
+
```bash
|
|
584
|
+
activitysmith badge 3 --channels "sales,customer-success"
|
|
585
|
+
```
|
|
643
586
|
|
|
644
|
-
|
|
587
|
+
## Output
|
|
645
588
|
|
|
646
|
-
|
|
589
|
+
Use `--json` for machine-readable output:
|
|
647
590
|
|
|
648
|
-
|
|
649
|
-
|
|
591
|
+
```bash
|
|
592
|
+
activitysmith push --title "Hello" --json
|
|
593
|
+
```
|
|
650
594
|
|
|
651
|
-
|
|
595
|
+
## Error Handling
|
|
652
596
|
|
|
653
|
-
-
|
|
654
|
-
- `activity start`: `--title`, `--type`, plus `--metrics`, `--number-of-steps` and `--current-step`, `--percentage`, `--value` with `--upper-limit`, or timer fields
|
|
655
|
-
- `activity update`: `--title`, plus `--metrics`, `--current-step`, `--percentage`, `--value` with `--upper-limit`, or timer fields
|
|
656
|
-
- `activity end`: `--title`, plus `--metrics`, `--current-step`, `--percentage`, `--value` with `--upper-limit`, or timer fields
|
|
657
|
-
- `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.
|
|
658
598
|
|
|
659
|
-
##
|
|
599
|
+
## Additional Resources
|
|
660
600
|
|
|
661
|
-
|
|
601
|
+
### [NPM Package](https://www.npmjs.com/package/activitysmith-cli)
|
|
662
602
|
|
|
663
|
-
|
|
664
|
-
activitysmith push --title "Hello" --json
|
|
665
|
-
```
|
|
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",
|
|
@@ -38,10 +38,11 @@
|
|
|
38
38
|
"node": ">=24"
|
|
39
39
|
},
|
|
40
40
|
"scripts": {
|
|
41
|
-
"lint": "node --check src/cli.js"
|
|
41
|
+
"lint": "node --check src/cli.js",
|
|
42
|
+
"test": "node --test"
|
|
42
43
|
},
|
|
43
44
|
"dependencies": {
|
|
44
|
-
"activitysmith": "^1.
|
|
45
|
+
"activitysmith": "^1.11.0",
|
|
45
46
|
"commander": "^12.1.0"
|
|
46
47
|
}
|
|
47
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";
|
|
@@ -80,6 +81,23 @@ const parseChannelsOption = (value) => {
|
|
|
80
81
|
return channels;
|
|
81
82
|
};
|
|
82
83
|
|
|
84
|
+
const parseTagsOption = (value, previous = []) => {
|
|
85
|
+
if (typeof value !== "string") {
|
|
86
|
+
throw new InvalidArgumentError("tags must be a comma-separated string");
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const tags = value
|
|
90
|
+
.split(",")
|
|
91
|
+
.map((tag) => tag.trim())
|
|
92
|
+
.filter((tag) => tag.length > 0);
|
|
93
|
+
|
|
94
|
+
if (tags.length === 0) {
|
|
95
|
+
throw new InvalidArgumentError("tags must contain at least one tag");
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
return [...previous, ...tags];
|
|
99
|
+
};
|
|
100
|
+
|
|
83
101
|
const parseMetricValueArgument = (value) => {
|
|
84
102
|
if (typeof value !== "string") {
|
|
85
103
|
throw new InvalidArgumentError("value must be a string or number");
|
|
@@ -143,18 +161,30 @@ const normalizeUrlWithSchemes = (value, label, schemes) => {
|
|
|
143
161
|
return parsed.toString();
|
|
144
162
|
};
|
|
145
163
|
|
|
146
|
-
const normalizeActionUrl = (value, label, type) => {
|
|
164
|
+
const normalizeActionUrl = (value, label, type, push = false) => {
|
|
147
165
|
if (type === "open_url") {
|
|
148
|
-
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"]);
|
|
149
169
|
}
|
|
150
170
|
|
|
151
171
|
return normalizeHttpsUrl(value, label);
|
|
152
172
|
};
|
|
153
173
|
|
|
154
|
-
const normalizeOpenUrl = (value, label) =>
|
|
155
|
-
|
|
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
|
+
};
|
|
156
186
|
|
|
157
|
-
const addContentStateOptions = (command, { includeAutoDismiss } = {}) => {
|
|
187
|
+
const addContentStateOptions = (command, { includeAutoDismiss, includeAutoDismissSeconds } = {}) => {
|
|
158
188
|
command
|
|
159
189
|
.option("--content-state <json>", "Content state as JSON string")
|
|
160
190
|
.option("--content-state-file <path>", "Content state JSON file path")
|
|
@@ -214,6 +244,14 @@ const addContentStateOptions = (command, { includeAutoDismiss } = {}) => {
|
|
|
214
244
|
);
|
|
215
245
|
}
|
|
216
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
|
+
|
|
217
255
|
return command;
|
|
218
256
|
};
|
|
219
257
|
|
|
@@ -371,6 +409,13 @@ const validateContentState = (contentState, mode) => {
|
|
|
371
409
|
const hasCountsDown = hasOwn(contentState, "countsDown");
|
|
372
410
|
const hasTimerFields = hasDurationSeconds || hasCountsDown;
|
|
373
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
|
+
|
|
374
419
|
if (hasValue !== hasUpperLimit) {
|
|
375
420
|
throw new Error(
|
|
376
421
|
"contentState.value and contentState.upperLimit must be provided together"
|
|
@@ -455,7 +500,7 @@ const validateContentState = (contentState, mode) => {
|
|
|
455
500
|
}
|
|
456
501
|
|
|
457
502
|
if (
|
|
458
|
-
|
|
503
|
+
hasMessage &&
|
|
459
504
|
(hasMetrics || hasSegmentedFields || hasProgressFields || hasStepColor)
|
|
460
505
|
) {
|
|
461
506
|
throw new Error(
|
|
@@ -535,7 +580,7 @@ const validateContentState = (contentState, mode) => {
|
|
|
535
580
|
}
|
|
536
581
|
|
|
537
582
|
if (effectiveType === "timer") {
|
|
538
|
-
if (!hasDurationSeconds && contentState.countsDown !== false) {
|
|
583
|
+
if (mode === "start" && !hasDurationSeconds && contentState.countsDown !== false) {
|
|
539
584
|
throw new Error(
|
|
540
585
|
`timer ${mode} requires contentState.durationSeconds, or contentState.countsDown=false`
|
|
541
586
|
);
|
|
@@ -620,7 +665,7 @@ const validateContentState = (contentState, mode) => {
|
|
|
620
665
|
}
|
|
621
666
|
};
|
|
622
667
|
|
|
623
|
-
const parseAction = (value, label) => {
|
|
668
|
+
const parseAction = (value, label, push = false) => {
|
|
624
669
|
assertPlainObject(value, label);
|
|
625
670
|
|
|
626
671
|
if (typeof value.title !== "string" || value.title.trim().length === 0) {
|
|
@@ -639,7 +684,7 @@ const parseAction = (value, label) => {
|
|
|
639
684
|
const action = {
|
|
640
685
|
title: value.title.trim(),
|
|
641
686
|
type: normalizedType,
|
|
642
|
-
url: normalizeActionUrl(value.url, `${label}.url`, normalizedType),
|
|
687
|
+
url: normalizeActionUrl(value.url, `${label}.url`, normalizedType, push),
|
|
643
688
|
};
|
|
644
689
|
|
|
645
690
|
if (value.method !== undefined) {
|
|
@@ -665,7 +710,7 @@ const parseAction = (value, label) => {
|
|
|
665
710
|
return action;
|
|
666
711
|
};
|
|
667
712
|
|
|
668
|
-
const parsePushAction = (value, index) => parseAction(value, `actions[${index}]
|
|
713
|
+
const parsePushAction = (value, index) => parseAction(value, `actions[${index}]`, true);
|
|
669
714
|
|
|
670
715
|
const loadPushActions = async (options) => {
|
|
671
716
|
if (options.actions && options.actionsFile) {
|
|
@@ -828,6 +873,10 @@ const buildContentStateFromOptions = (options) => {
|
|
|
828
873
|
contentState.stepColor = options.stepColor;
|
|
829
874
|
}
|
|
830
875
|
|
|
876
|
+
if (options.autoDismissSeconds !== undefined) {
|
|
877
|
+
contentState.autoDismissSeconds = options.autoDismissSeconds;
|
|
878
|
+
}
|
|
879
|
+
|
|
831
880
|
if (options.autoDismissMinutes !== undefined) {
|
|
832
881
|
contentState.autoDismissMinutes = options.autoDismissMinutes;
|
|
833
882
|
}
|
|
@@ -858,6 +907,7 @@ const toApiContentState = (contentState) => {
|
|
|
858
907
|
upperLimit: "upper_limit",
|
|
859
908
|
stepColor: "step_color",
|
|
860
909
|
autoDismissMinutes: "auto_dismiss_minutes",
|
|
910
|
+
autoDismissSeconds: "auto_dismiss_seconds",
|
|
861
911
|
durationSeconds: "duration_seconds",
|
|
862
912
|
countsDown: "counts_down",
|
|
863
913
|
};
|
|
@@ -909,6 +959,18 @@ const withTargetChannels = (request, channels) => {
|
|
|
909
959
|
};
|
|
910
960
|
};
|
|
911
961
|
|
|
962
|
+
const withTags = (request, tags, metadata) => {
|
|
963
|
+
if (metadata !== undefined) request = { ...request, metadata };
|
|
964
|
+
if (tags === undefined) {
|
|
965
|
+
return request;
|
|
966
|
+
}
|
|
967
|
+
|
|
968
|
+
return {
|
|
969
|
+
...request,
|
|
970
|
+
tags,
|
|
971
|
+
};
|
|
972
|
+
};
|
|
973
|
+
|
|
912
974
|
const toApiLiveActivityUpdateRequest = (
|
|
913
975
|
activityId,
|
|
914
976
|
contentState,
|
|
@@ -1199,7 +1261,14 @@ program
|
|
|
1199
1261
|
"Comma-separated channel slugs (optional)",
|
|
1200
1262
|
parseChannelsOption
|
|
1201
1263
|
)
|
|
1202
|
-
.
|
|
1264
|
+
.option(
|
|
1265
|
+
"--tags <tags>",
|
|
1266
|
+
"Comma-separated tags for organizing history (repeatable)",
|
|
1267
|
+
parseTagsOption
|
|
1268
|
+
)
|
|
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) => {
|
|
1203
1272
|
const globalOptions = program.opts();
|
|
1204
1273
|
|
|
1205
1274
|
try {
|
|
@@ -1225,6 +1294,8 @@ program
|
|
|
1225
1294
|
? normalizeOpenUrl(options.redirection, "redirection")
|
|
1226
1295
|
: undefined,
|
|
1227
1296
|
actions,
|
|
1297
|
+
tags: options.tags,
|
|
1298
|
+
metadata: await loadMetadata(options),
|
|
1228
1299
|
},
|
|
1229
1300
|
options.channels
|
|
1230
1301
|
);
|
|
@@ -1277,8 +1348,8 @@ program
|
|
|
1277
1348
|
? "App Icon Badge Count cleared."
|
|
1278
1349
|
: "App Icon Badge Count updated.",
|
|
1279
1350
|
response?.badge !== undefined ? `Badge: ${response.badge}` : null,
|
|
1280
|
-
response?.devicesNotified !== undefined
|
|
1281
|
-
? `Devices
|
|
1351
|
+
response?.devicesUpdated !== undefined || response?.devicesNotified !== undefined
|
|
1352
|
+
? `Devices updated: ${response.devicesUpdated ?? response.devicesNotified}`
|
|
1282
1353
|
: null,
|
|
1283
1354
|
]);
|
|
1284
1355
|
} catch (error) {
|
|
@@ -1296,7 +1367,9 @@ metricsCommand
|
|
|
1296
1367
|
.description("Update a widget metric value")
|
|
1297
1368
|
.argument("<metric-key>", "Metric key")
|
|
1298
1369
|
.argument("<value>", "Metric value")
|
|
1299
|
-
.
|
|
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) => {
|
|
1300
1373
|
const globalOptions = program.opts();
|
|
1301
1374
|
|
|
1302
1375
|
try {
|
|
@@ -1313,7 +1386,7 @@ metricsCommand
|
|
|
1313
1386
|
|
|
1314
1387
|
const activityCommand = program
|
|
1315
1388
|
.command("activity")
|
|
1316
|
-
.description("
|
|
1389
|
+
.description("Start, update, and end Live Activities");
|
|
1317
1390
|
|
|
1318
1391
|
addLiveActivityActionOptions(addContentStateOptions(
|
|
1319
1392
|
activityCommand
|
|
@@ -1325,10 +1398,21 @@ addLiveActivityActionOptions(addContentStateOptions(
|
|
|
1325
1398
|
"Comma-separated channel slugs (optional)",
|
|
1326
1399
|
parseChannelsOption
|
|
1327
1400
|
)
|
|
1401
|
+
.option(
|
|
1402
|
+
"--tags <tags>",
|
|
1403
|
+
"Comma-separated tags for organizing history (repeatable)",
|
|
1404
|
+
parseTagsOption
|
|
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")
|
|
1328
1409
|
.action(async (streamKey, options) => {
|
|
1329
1410
|
const globalOptions = program.opts();
|
|
1330
1411
|
|
|
1331
1412
|
try {
|
|
1413
|
+
if (options.clearTags && options.tags !== undefined) {
|
|
1414
|
+
throw new Error("Use either --tags or --clear-tags, not both.");
|
|
1415
|
+
}
|
|
1332
1416
|
const apiKey = requireApiKey(globalOptions);
|
|
1333
1417
|
const client = createClient(apiKey);
|
|
1334
1418
|
const contentState = await loadContentState(options, "stream");
|
|
@@ -1337,13 +1421,17 @@ addLiveActivityActionOptions(addContentStateOptions(
|
|
|
1337
1421
|
|
|
1338
1422
|
const response = await client.liveActivities.stream(
|
|
1339
1423
|
streamKey,
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1424
|
+
withTags(
|
|
1425
|
+
withTargetChannels(
|
|
1426
|
+
toApiLiveActivityStreamRequest(
|
|
1427
|
+
contentState,
|
|
1428
|
+
action,
|
|
1429
|
+
secondaryAction
|
|
1430
|
+
),
|
|
1431
|
+
options.channels
|
|
1345
1432
|
),
|
|
1346
|
-
options.
|
|
1433
|
+
options.clearTags ? [] : options.tags,
|
|
1434
|
+
await loadMetadata(options)
|
|
1347
1435
|
)
|
|
1348
1436
|
);
|
|
1349
1437
|
|
|
@@ -1370,6 +1458,13 @@ addLiveActivityActionOptions(addContentStateOptions(
|
|
|
1370
1458
|
"Comma-separated channel slugs (optional)",
|
|
1371
1459
|
parseChannelsOption
|
|
1372
1460
|
)
|
|
1461
|
+
.option(
|
|
1462
|
+
"--tags <tags>",
|
|
1463
|
+
"Comma-separated tags for organizing history (repeatable)",
|
|
1464
|
+
parseTagsOption
|
|
1465
|
+
)
|
|
1466
|
+
.option("--metadata <json>", "Metadata JSON object shown in ActivitySmith details")
|
|
1467
|
+
.option("--metadata-file <path>", "Path to a Metadata JSON object file")
|
|
1373
1468
|
.action(async (options) => {
|
|
1374
1469
|
const globalOptions = program.opts();
|
|
1375
1470
|
|
|
@@ -1381,13 +1476,17 @@ addLiveActivityActionOptions(addContentStateOptions(
|
|
|
1381
1476
|
const secondaryAction = await loadLiveActivitySecondaryAction(options);
|
|
1382
1477
|
|
|
1383
1478
|
const response = await client.liveActivities.startLiveActivity({
|
|
1384
|
-
liveActivityStartRequest:
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1479
|
+
liveActivityStartRequest: withTags(
|
|
1480
|
+
withTargetChannels(
|
|
1481
|
+
toApiLiveActivityStartRequest(
|
|
1482
|
+
contentState,
|
|
1483
|
+
action,
|
|
1484
|
+
secondaryAction
|
|
1485
|
+
),
|
|
1486
|
+
options.channels
|
|
1389
1487
|
),
|
|
1390
|
-
options.
|
|
1488
|
+
options.tags,
|
|
1489
|
+
await loadMetadata(options)
|
|
1391
1490
|
),
|
|
1392
1491
|
});
|
|
1393
1492
|
|
|
@@ -1407,10 +1506,17 @@ addLiveActivityActionOptions(addContentStateOptions(
|
|
|
1407
1506
|
.command("update")
|
|
1408
1507
|
.description("Update a Live Activity")
|
|
1409
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")
|
|
1410
1513
|
.action(async (options) => {
|
|
1411
1514
|
const globalOptions = program.opts();
|
|
1412
1515
|
|
|
1413
1516
|
try {
|
|
1517
|
+
if (options.clearTags && options.tags !== undefined) {
|
|
1518
|
+
throw new Error("Use either --tags or --clear-tags, not both.");
|
|
1519
|
+
}
|
|
1414
1520
|
const apiKey = requireApiKey(globalOptions);
|
|
1415
1521
|
const client = createClient(apiKey);
|
|
1416
1522
|
const contentState = await loadContentState(options, "update");
|
|
@@ -1418,12 +1524,12 @@ addLiveActivityActionOptions(addContentStateOptions(
|
|
|
1418
1524
|
const secondaryAction = await loadLiveActivitySecondaryAction(options);
|
|
1419
1525
|
|
|
1420
1526
|
const response = await client.liveActivities.updateLiveActivity({
|
|
1421
|
-
liveActivityUpdateRequest: toApiLiveActivityUpdateRequest(
|
|
1527
|
+
liveActivityUpdateRequest: withTags(toApiLiveActivityUpdateRequest(
|
|
1422
1528
|
options.activityId,
|
|
1423
1529
|
contentState,
|
|
1424
1530
|
action,
|
|
1425
1531
|
secondaryAction
|
|
1426
|
-
),
|
|
1532
|
+
), options.clearTags ? [] : options.tags, await loadMetadata(options)),
|
|
1427
1533
|
});
|
|
1428
1534
|
|
|
1429
1535
|
outputResult(response, globalOptions, [
|
|
@@ -1441,10 +1547,17 @@ addLiveActivityActionOptions(addContentStateOptions(
|
|
|
1441
1547
|
.command("end")
|
|
1442
1548
|
.description("End a Live Activity")
|
|
1443
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")
|
|
1444
1554
|
.action(async (options) => {
|
|
1445
1555
|
const globalOptions = program.opts();
|
|
1446
1556
|
|
|
1447
1557
|
try {
|
|
1558
|
+
if (options.clearTags && options.tags !== undefined) {
|
|
1559
|
+
throw new Error("Use either --tags or --clear-tags, not both.");
|
|
1560
|
+
}
|
|
1448
1561
|
const apiKey = requireApiKey(globalOptions);
|
|
1449
1562
|
const client = createClient(apiKey);
|
|
1450
1563
|
const contentState = await loadContentState(options, "end");
|
|
@@ -1452,12 +1565,12 @@ addLiveActivityActionOptions(addContentStateOptions(
|
|
|
1452
1565
|
const secondaryAction = await loadLiveActivitySecondaryAction(options);
|
|
1453
1566
|
|
|
1454
1567
|
const response = await client.liveActivities.endLiveActivity({
|
|
1455
|
-
liveActivityEndRequest: toApiLiveActivityEndRequest(
|
|
1568
|
+
liveActivityEndRequest: withTags(toApiLiveActivityEndRequest(
|
|
1456
1569
|
options.activityId,
|
|
1457
1570
|
contentState,
|
|
1458
1571
|
action,
|
|
1459
1572
|
secondaryAction
|
|
1460
|
-
),
|
|
1573
|
+
), options.clearTags ? [] : options.tags, await loadMetadata(options)),
|
|
1461
1574
|
});
|
|
1462
1575
|
|
|
1463
1576
|
outputResult(response, globalOptions, [
|
|
@@ -1476,10 +1589,17 @@ addLiveActivityActionOptions(addContentStateOptions(
|
|
|
1476
1589
|
.command("end-stream")
|
|
1477
1590
|
.description("End a stateless Live Activity stream")
|
|
1478
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")
|
|
1479
1596
|
.action(async (streamKey, options) => {
|
|
1480
1597
|
const globalOptions = program.opts();
|
|
1481
1598
|
|
|
1482
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);
|
|
1483
1603
|
const apiKey = requireApiKey(globalOptions);
|
|
1484
1604
|
const client = createClient(apiKey);
|
|
1485
1605
|
const contentState = await loadOptionalContentState(options, "end");
|
|
@@ -1489,7 +1609,7 @@ addLiveActivityActionOptions(addContentStateOptions(
|
|
|
1489
1609
|
const request =
|
|
1490
1610
|
contentState !== undefined ||
|
|
1491
1611
|
action !== undefined ||
|
|
1492
|
-
secondaryAction !== undefined
|
|
1612
|
+
secondaryAction !== undefined || tags !== undefined || metadata !== undefined
|
|
1493
1613
|
? toApiLiveActivityStreamDeleteRequest(
|
|
1494
1614
|
contentState,
|
|
1495
1615
|
action,
|
|
@@ -1497,6 +1617,8 @@ addLiveActivityActionOptions(addContentStateOptions(
|
|
|
1497
1617
|
)
|
|
1498
1618
|
: undefined;
|
|
1499
1619
|
|
|
1620
|
+
if (tags !== undefined) request.tags = tags;
|
|
1621
|
+
if (metadata !== undefined) request.metadata = metadata;
|
|
1500
1622
|
const response = await client.liveActivities.endStream(streamKey, request);
|
|
1501
1623
|
|
|
1502
1624
|
const activityId = response?.activityId ?? response?.activity_id;
|
|
@@ -1511,7 +1633,7 @@ addLiveActivityActionOptions(addContentStateOptions(
|
|
|
1511
1633
|
await handleError(error, globalOptions);
|
|
1512
1634
|
}
|
|
1513
1635
|
}),
|
|
1514
|
-
{ includeAutoDismiss: true }
|
|
1636
|
+
{ includeAutoDismiss: true, includeAutoDismissSeconds: true }
|
|
1515
1637
|
));
|
|
1516
1638
|
|
|
1517
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
|
+
}
|