activitysmith-cli 1.1.0 → 1.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +114 -255
  2. package/package.json +2 -2
  3. package/src/cli.js +94 -8
package/README.md CHANGED
@@ -2,6 +2,25 @@
2
2
 
3
3
  CLI wrapper for the ActivitySmith API using the official Node SDK.
4
4
 
5
+ ## Table of Contents
6
+
7
+ - [Install](#install)
8
+ - [Install Skill (Codex/Claude/Other Skills-Compatible Agents)](#install-skill-codexclaudeother-skills-compatible-agents)
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
+ - [Channels](#channels)
19
+ - [Widgets](#widgets)
20
+ - [Aliases](#aliases)
21
+ - [Content State Options](#content-state-options)
22
+ - [Output](#output)
23
+
5
24
  ## Install
6
25
 
7
26
  ```bash
@@ -116,40 +135,52 @@ activitysmith push \
116
135
 
117
136
  ## Live Activities
118
137
 
119
- <p align="center">
120
- <img src="https://cdn.activitysmith.com/features/metrics-live-activity-action.png" alt="Live Activities example" width="680" />
121
- </p>
122
-
123
- ActivitySmith supports two ways to drive Live Activities:
124
-
125
- - Recommended: stream updates with `activitysmith activity stream ...`
126
- - Advanced: manual lifecycle control with `activity start`, `activity update`, and `activity end`
138
+ There are four types of Live Activities:
127
139
 
128
- Use stream updates when you want the easiest, stateless flow. You do not need to
129
- store `activity_id` or manage lifecycle state yourself. Send the latest state
130
- for a stable `stream_key` and ActivitySmith will start or update the Live
131
- Activity for you. When the tracked process is over, call `activity end-stream`.
140
+ - `stats`: best for showing business numbers side by side, such as revenue, sales, new users, conversion, refunds, or any other value you want visible at a glance
141
+ - `metrics`: best for live percentage values that change often, like server CPU, memory usage, disk usage, or error rate
142
+ - `segmented_progress`: best for anything that moves through clear stages, like deployments, onboarding flows, backups, ETL pipelines, migrations, and AI agent runs
143
+ - `progress`: best for tracking real-time progress with percentage, like tasks, backups, migrations, syncs, or uploads
132
144
 
133
- Use the manual lifecycle commands when you need direct control over a specific
134
- Live Activity instance.
145
+ ### Start & Update Live Activity
135
146
 
136
- Live Activity UI types:
147
+ Use a stable `stream_key` to identify the metric, job, deployment, or system you want to keep visible. The first `activity stream` command starts the Live Activity. Later commands with the same `stream_key` update it.
137
148
 
138
- - `metrics`: best for live operational stats like server CPU and memory, queue depth, or replica lag
139
- - `segmented_progress`: best for step-based workflows like deployments, backups, and ETL pipelines
140
- - `progress`: best for continuous jobs like uploads, reindexes, and long-running migrations tracked as a percentage
149
+ #### Stats
141
150
 
142
- ### Recommended: Stream updates
151
+ <p align="center">
152
+ <img
153
+ src="https://cdn.activitysmith.com/features/stats-live-activity.png"
154
+ alt="Stats Live Activity stream example"
155
+ width="680"
156
+ />
157
+ </p>
143
158
 
144
- Use a stable `stream_key` to identify the system or workflow you are tracking,
145
- such as a server, deployment, build pipeline, cron job, or charging session.
146
- This is especially useful for cron jobs and other scheduled tasks where you do
147
- not want to store `activity_id` between runs.
159
+ ```bash
160
+ activitysmith activity stream sales-hourly \
161
+ --content-state '{
162
+ "title": "Sales",
163
+ "subtitle": "last hour",
164
+ "type": "stats",
165
+ "metrics": [
166
+ { "label": "Revenue", "value": "$2430", "color": "blue" },
167
+ { "label": "Orders", "value": "37", "color": "green" },
168
+ { "label": "Conversion", "value": "4.8%", "color": "magenta" },
169
+ { "label": "Avg Order", "value": "$65.68", "color": "yellow" },
170
+ { "label": "Refunds", "value": "$84", "color": "red" },
171
+ { "label": "New Buyers", "value": "18", "color": "cyan" }
172
+ ]
173
+ }'
174
+ ```
148
175
 
149
176
  #### Metrics
150
177
 
151
178
  <p align="center">
152
- <img src="https://cdn.activitysmith.com/features/metrics-live-activity-start.png" alt="Metrics stream example" width="680" />
179
+ <img
180
+ src="https://cdn.activitysmith.com/features/metrics-live-activity-start.png"
181
+ alt="Metrics Live Activity stream example"
182
+ width="680"
183
+ />
153
184
  </p>
154
185
 
155
186
  ```bash
@@ -165,10 +196,14 @@ activitysmith activity stream prod-web-1 \
165
196
  }'
166
197
  ```
167
198
 
168
- #### Segmented progress
199
+ #### Segmented Progress
169
200
 
170
201
  <p align="center">
171
- <img src="https://cdn.activitysmith.com/features/update-live-activity.png" alt="Segmented progress stream example" width="680" />
202
+ <img
203
+ src="https://cdn.activitysmith.com/features/update-live-activity.png"
204
+ alt="Segmented Progress Live Activity stream example"
205
+ width="680"
206
+ />
172
207
  </p>
173
208
 
174
209
  ```bash
@@ -185,7 +220,11 @@ activitysmith activity stream nightly-backup \
185
220
  #### Progress
186
221
 
187
222
  <p align="center">
188
- <img src="https://cdn.activitysmith.com/features/progress-live-activity.png" alt="Progress stream example" width="680" />
223
+ <img
224
+ src="https://cdn.activitysmith.com/features/progress-live-activity.png"
225
+ alt="Progress Live Activity stream example"
226
+ width="680"
227
+ />
189
228
  </p>
190
229
 
191
230
  ```bash
@@ -198,107 +237,12 @@ activitysmith activity stream search-reindex \
198
237
  }'
199
238
  ```
200
239
 
201
- Run `activitysmith activity stream <stream-key> ...` again with the same
202
- `stream_key` whenever the state changes.
203
-
204
- #### End a stream
240
+ ### End Live Activity
205
241
 
206
- Use this when the tracked process is finished and you no longer want the Live
207
- Activity on devices. `content_state` is optional here; include it if you want
208
- to end the stream with a final state.
242
+ Call `activity end-stream` with the same `stream_key` to dismiss the Live Activity. You can include final values before it is removed. By default, iOS removes the Live Activity after two minutes. Set `autoDismissMinutes` to choose a different dismissal time, including `0` for immediate dismissal.
209
243
 
210
244
  ```bash
211
245
  activitysmith activity end-stream prod-web-1 \
212
- --content-state '{
213
- "title": "Server Health",
214
- "subtitle": "prod-web-1",
215
- "type": "metrics",
216
- "metrics": [
217
- { "label": "CPU", "value": 7, "unit": "%" },
218
- { "label": "MEM", "value": 38, "unit": "%" }
219
- ]
220
- }'
221
- ```
222
-
223
- If you later send another `activity stream` request with the same `stream_key`,
224
- ActivitySmith starts a new Live Activity for that stream again.
225
-
226
- Stream responses include an `operation` field:
227
-
228
- - `started`: ActivitySmith started a new Live Activity for this `stream_key`
229
- - `updated`: ActivitySmith updated the current Live Activity
230
- - `rotated`: ActivitySmith ended the previous Live Activity and started a new one
231
- - `noop`: the incoming state matched the current state, so no update was sent
232
- - `paused`: the stream is paused, so no Live Activity was started or updated
233
- - `ended`: returned by `activity end-stream` after the stream is ended
234
-
235
- ### Advanced: Manual lifecycle control
236
-
237
- Use these commands when you want to manage the Live Activity lifecycle yourself.
238
-
239
- #### Shared flow
240
-
241
- 1. Run `activitysmith activity start ...`.
242
- 2. Save the returned `activity_id`.
243
- 3. Run `activitysmith activity update ...` as progress changes.
244
- 4. Run `activitysmith activity end ...` when the work is finished.
245
-
246
- You can use `--content-state <json>` for the examples below, or build the same
247
- payload with flags as documented in `Content State Options`.
248
-
249
- ### Metrics Type
250
-
251
- Use `metrics` when you want to keep a small set of live stats visible, such as
252
- server health, queue pressure, or database load.
253
-
254
- #### Start
255
-
256
- <p align="center">
257
- <img src="https://cdn.activitysmith.com/features/metrics-live-activity-start.png" alt="Metrics start example" width="680" />
258
- </p>
259
-
260
- ```bash
261
- activitysmith activity start \
262
- --content-state '{
263
- "title": "Server Health",
264
- "subtitle": "prod-web-1",
265
- "type": "metrics",
266
- "metrics": [
267
- { "label": "CPU", "value": 9, "unit": "%" },
268
- { "label": "MEM", "value": 45, "unit": "%" }
269
- ]
270
- }'
271
- ```
272
-
273
- #### Update
274
-
275
- <p align="center">
276
- <img src="https://cdn.activitysmith.com/features/metrics-live-activity-update.png" alt="Metrics update example" width="680" />
277
- </p>
278
-
279
- ```bash
280
- activitysmith activity update \
281
- --activity-id "<activityId>" \
282
- --content-state '{
283
- "title": "Server Health",
284
- "subtitle": "prod-web-1",
285
- "type": "metrics",
286
- "metrics": [
287
- { "label": "CPU", "value": 76, "unit": "%" },
288
- { "label": "MEM", "value": 52, "unit": "%" }
289
- ]
290
- }'
291
- ```
292
-
293
- #### End
294
-
295
- <p align="center">
296
- <img src="https://cdn.activitysmith.com/features/metrics-live-activity-end.png" alt="Metrics end example" width="680" />
297
- </p>
298
-
299
- ```bash
300
- activitysmith activity end \
301
- --activity-id "<activityId>" \
302
246
  --content-state '{
303
247
  "title": "Server Health",
304
248
  "subtitle": "prod-web-1",
@@ -311,133 +255,22 @@ activitysmith activity end \
311
255
  }'
312
256
  ```
313
257
 
314
- ### Segmented Progress Type
315
-
316
- Use `segmented_progress` when progress is easier to follow as steps instead of a
317
- raw percentage. It fits jobs like deployments, backups, ETL pipelines, and
318
- checklists where "step 2 of 3" is more useful than "67%". `numberOfSteps` is
319
- dynamic, so you can increase or decrease it later if the workflow changes.
320
-
321
- #### Start
322
-
323
- <p align="center">
324
- <img src="https://cdn.activitysmith.com/features/start-live-activity.png" alt="Segmented progress start example" width="680" />
325
- </p>
326
-
327
- ```bash
328
- activitysmith activity start \
329
- --content-state '{
330
- "title": "Nightly database backup",
331
- "subtitle": "create snapshot",
332
- "numberOfSteps": 3,
333
- "currentStep": 1,
334
- "type": "segmented_progress",
335
- "color": "yellow"
336
- }'
337
- ```
338
-
339
- #### Update
340
-
341
- <p align="center">
342
- <img src="https://cdn.activitysmith.com/features/update-live-activity.png" alt="Segmented progress update example" width="680" />
343
- </p>
344
-
345
- ```bash
346
- activitysmith activity update \
347
- --activity-id "<activityId>" \
348
- --content-state '{
349
- "title": "Nightly database backup",
350
- "subtitle": "upload archive",
351
- "numberOfSteps": 3,
352
- "currentStep": 2
353
- }'
354
- ```
355
-
356
- #### End
357
-
358
- <p align="center">
359
- <img src="https://cdn.activitysmith.com/features/end-live-activity.png" alt="Segmented progress end example" width="680" />
360
- </p>
361
-
362
- ```bash
363
- activitysmith activity end \
364
- --activity-id "<activityId>" \
365
- --content-state '{
366
- "title": "Nightly database backup",
367
- "subtitle": "verify restore",
368
- "numberOfSteps": 3,
369
- "currentStep": 3,
370
- "autoDismissMinutes": 2
371
- }'
372
- ```
373
-
374
- ### Progress Type
375
-
376
- Use `progress` when the state is naturally continuous. It fits charging,
377
- downloads, sync jobs, uploads, timers, and any flow where a percentage or
378
- numeric range is the clearest signal.
379
-
380
- #### Start
381
-
382
- <p align="center">
383
- <img src="https://cdn.activitysmith.com/features/progress-live-activity-start.png" alt="Progress start example" width="680" />
384
- </p>
385
-
386
- ```bash
387
- activitysmith activity start \
388
- --content-state '{
389
- "title": "EV Charging",
390
- "subtitle": "Added 30 mi range",
391
- "type": "progress",
392
- "percentage": 15
393
- }'
394
- ```
395
-
396
- #### Update
397
-
398
- <p align="center">
399
- <img src="https://cdn.activitysmith.com/features/progress-live-activity-update.png" alt="Progress update example" width="680" />
400
- </p>
401
-
402
- ```bash
403
- activitysmith activity update \
404
- --activity-id "<activityId>" \
405
- --content-state '{
406
- "title": "EV Charging",
407
- "subtitle": "Added 120 mi range",
408
- "percentage": 60
409
- }'
410
- ```
411
-
412
- #### End
413
-
414
- <p align="center">
415
- <img src="https://cdn.activitysmith.com/features/progress-live-activity-end.png" alt="Progress end example" width="680" />
416
- </p>
417
-
418
- ```bash
419
- activitysmith activity end \
420
- --activity-id "<activityId>" \
421
- --content-state '{
422
- "title": "EV Charging",
423
- "subtitle": "Added 200 mi range",
424
- "percentage": 100,
425
- "autoDismissMinutes": 2
426
- }'
427
- ```
428
-
429
258
  ### Live Activity Action
430
259
 
431
- Just like Actionable Push Notifications, Live Activities can have a button that opens a URL in a browser or triggers a webhook. Webhooks are executed by the ActivitySmith backend.
260
+ Live Activities can include one optional action button. Use it to open a URL from the Live Activity or trigger a backend webhook.
432
261
 
433
262
  <p align="center">
434
- <img src="https://cdn.activitysmith.com/features/metrics-live-activity-action.png" alt="Metrics Live Activity with action" width="680" />
263
+ <img
264
+ src="https://cdn.activitysmith.com/features/live-activity-with-action.png?v=20260319-1"
265
+ alt="Live Activity with action button"
266
+ width="680"
267
+ />
435
268
  </p>
436
269
 
437
270
  #### Open URL action
438
271
 
439
272
  ```bash
440
- activitysmith activity start \
273
+ activitysmith activity stream prod-web-1 \
441
274
  --content-state '{
442
275
  "title": "Server Health",
443
276
  "subtitle": "prod-web-1",
@@ -457,24 +290,21 @@ activitysmith activity start \
457
290
  #### Webhook action
458
291
 
459
292
  ```bash
460
- activitysmith activity update \
461
- --activity-id "<activityId>" \
293
+ activitysmith activity stream search-reindex \
462
294
  --content-state '{
463
- "title": "Server Health",
464
- "subtitle": "prod-web-1",
465
- "type": "metrics",
466
- "metrics": [
467
- { "label": "CPU", "value": 91, "unit": "%" },
468
- { "label": "MEM", "value": 57, "unit": "%" }
469
- ]
295
+ "title": "Reindexing product search",
296
+ "subtitle": "Shard 7 of 12",
297
+ "type": "segmented_progress",
298
+ "numberOfSteps": 12,
299
+ "currentStep": 7
470
300
  }' \
471
301
  --action '{
472
- "title": "Restart Service",
302
+ "title": "Pause Reindex",
473
303
  "type": "webhook",
474
- "url": "https://ops.example.com/hooks/servers/prod-web-1/restart",
304
+ "url": "https://ops.example.com/hooks/search/reindex/pause",
475
305
  "method": "POST",
476
306
  "body": {
477
- "server_id": "prod-web-1",
307
+ "job_id": "reindex-2026-03-19",
478
308
  "requested_by": "activitysmith-cli"
479
309
  }
480
310
  }'
@@ -491,6 +321,30 @@ activitysmith push \
491
321
  --channels "devs,ops"
492
322
  ```
493
323
 
324
+ ## Widgets
325
+
326
+ <p align="center">
327
+ <img src="https://cdn.activitysmith.com/features/lock-screen-widgets.png" alt="Lock screen widgets" width="680" />
328
+ </p>
329
+
330
+ 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.
331
+
332
+ <p align="center">
333
+ <img src="https://cdn.activitysmith.com/features/create-widget-metric.png" alt="Create widget metric" width="680" />
334
+ </p>
335
+
336
+ Use the metric key to update its value.
337
+
338
+ ```bash
339
+ activitysmith metrics update deploy.success_rate 99.9
340
+ ```
341
+
342
+ String metric values work too.
343
+
344
+ ```bash
345
+ activitysmith metrics update prod.status healthy
346
+ ```
347
+
494
348
  ## Aliases
495
349
 
496
350
  The CLI installs two bin names:
@@ -505,7 +359,7 @@ For `activity stream|start|update|end|end-stream`, you can pass content state vi
505
359
  - `--content-state <json>`
506
360
  - `--content-state-file <path>`
507
361
 
508
- For `metrics`, you can also pass the metrics array directly:
362
+ For `metrics` and `stats`, you can also pass the metrics array directly:
509
363
 
510
364
  - `--metrics <json-array>`
511
365
  - `--metrics-file <path>`
@@ -533,6 +387,11 @@ Targeting options:
533
387
 
534
388
  - `--channels <comma-separated-slugs>` (for `push`, `activity stream`, and `activity start`)
535
389
 
390
+ Widget metric options:
391
+
392
+ - `activitysmith metrics update <metric-key> <value>`
393
+ - `activitysmith metric update <metric-key> <value>` (alias)
394
+
536
395
  Required fields:
537
396
 
538
397
  - `activity stream`: `--title`, `--type`, plus `--metrics`, `--number-of-steps` and `--current-step`, `--percentage`, or `--value` with `--upper-limit`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "activitysmith-cli",
3
- "version": "1.1.0",
3
+ "version": "1.3.1",
4
4
  "description": "Command-line interface for ActivitySmith. Send push notifications and manage Live Activities from your terminal.",
5
5
  "keywords": [
6
6
  "activitysmith",
@@ -40,7 +40,7 @@
40
40
  "lint": "node --check src/cli.js"
41
41
  },
42
42
  "dependencies": {
43
- "activitysmith": "^1.1.0",
43
+ "activitysmith": "^1.3.1",
44
44
  "commander": "^12.1.0"
45
45
  }
46
46
  }
package/src/cli.js CHANGED
@@ -54,6 +54,30 @@ const parseChannelsOption = (value) => {
54
54
  return channels;
55
55
  };
56
56
 
57
+ const parseMetricValueArgument = (value) => {
58
+ if (typeof value !== "string") {
59
+ throw new InvalidArgumentError("value must be a string or number");
60
+ }
61
+
62
+ const trimmed = value.trim();
63
+ if (trimmed.length === 0) {
64
+ throw new InvalidArgumentError("value cannot be empty");
65
+ }
66
+
67
+ try {
68
+ const parsed = JSON.parse(trimmed);
69
+ if (typeof parsed === "string" || typeof parsed === "number") {
70
+ return parsed;
71
+ }
72
+ throw new InvalidArgumentError("value must be a string or number");
73
+ } catch (error) {
74
+ if (error instanceof InvalidArgumentError) {
75
+ throw error;
76
+ }
77
+ return value;
78
+ }
79
+ };
80
+
57
81
  const normalizeHttpsUrl = (value, label) => {
58
82
  if (typeof value !== "string" || value.trim().length === 0) {
59
83
  throw new Error(`${label} must be a non-empty string`);
@@ -212,6 +236,18 @@ const isNonEmptyString = (value) =>
212
236
  const hasOwn = (object, key) =>
213
237
  Object.prototype.hasOwnProperty.call(object, key);
214
238
 
239
+ const liveActivityMetricColors = new Set([
240
+ "blue",
241
+ "cyan",
242
+ "green",
243
+ "lime",
244
+ "magenta",
245
+ "orange",
246
+ "purple",
247
+ "red",
248
+ "yellow",
249
+ ]);
250
+
215
251
  const validateContentState = (contentState, mode) => {
216
252
  const normalizedType =
217
253
  typeof contentState.type === "string" ? contentState.type.trim() : undefined;
@@ -224,10 +260,11 @@ const validateContentState = (contentState, mode) => {
224
260
  normalizedType !== undefined &&
225
261
  normalizedType !== "segmented_progress" &&
226
262
  normalizedType !== "progress" &&
227
- normalizedType !== "metrics"
263
+ normalizedType !== "metrics" &&
264
+ normalizedType !== "stats"
228
265
  ) {
229
266
  throw new Error(
230
- "contentState.type must be one of: segmented_progress, progress, metrics"
267
+ "contentState.type must be one of: segmented_progress, progress, metrics, stats"
231
268
  );
232
269
  }
233
270
 
@@ -284,17 +321,41 @@ const validateContentState = (contentState, mode) => {
284
321
  throw new Error("contentState.metrics must be a non-empty array");
285
322
  }
286
323
 
324
+ if (normalizedType === "stats" && contentState.metrics.length > 8) {
325
+ throw new Error("stats contentState.metrics supports up to 8 items");
326
+ }
327
+
287
328
  contentState.metrics.forEach((metric, index) => {
288
329
  assertPlainObject(metric, `contentState.metrics[${index}]`);
289
330
  if (!isNonEmptyString(metric.label)) {
290
331
  throw new Error(`contentState.metrics[${index}].label is required`);
291
332
  }
292
- if (!Number.isFinite(metric.value)) {
293
- throw new Error(`contentState.metrics[${index}].value must be a number`);
333
+ if (normalizedType === "stats") {
334
+ if (!Number.isFinite(metric.value) && !isNonEmptyString(metric.value)) {
335
+ throw new Error(
336
+ `contentState.metrics[${index}].value must be a number or non-empty string`
337
+ );
338
+ }
339
+ } else if (!Number.isFinite(metric.value)) {
340
+ throw new Error(
341
+ `contentState.metrics[${index}].value must be a number. Use contentState.type=stats for string values`
342
+ );
294
343
  }
295
344
  if (metric.unit !== undefined && typeof metric.unit !== "string") {
296
345
  throw new Error(`contentState.metrics[${index}].unit must be a string`);
297
346
  }
347
+ if (metric.color !== undefined) {
348
+ if (!isNonEmptyString(metric.color)) {
349
+ throw new Error(`contentState.metrics[${index}].color must be a string`);
350
+ }
351
+ if (!liveActivityMetricColors.has(metric.color.trim())) {
352
+ throw new Error(
353
+ `contentState.metrics[${index}].color must be one of: ${[
354
+ ...liveActivityMetricColors,
355
+ ].join(", ")}`
356
+ );
357
+ }
358
+ }
298
359
  });
299
360
  }
300
361
 
@@ -314,9 +375,9 @@ const validateContentState = (contentState, mode) => {
314
375
  return;
315
376
  }
316
377
 
317
- if (effectiveType === "metrics") {
378
+ if (effectiveType === "metrics" || effectiveType === "stats") {
318
379
  if (!hasMetrics) {
319
- throw new Error(`metrics ${mode} requires contentState.metrics`);
380
+ throw new Error(`${effectiveType} ${mode} requires contentState.metrics`);
320
381
  }
321
382
  return;
322
383
  }
@@ -347,9 +408,9 @@ const validateContentState = (contentState, mode) => {
347
408
  return;
348
409
  }
349
410
 
350
- if (effectiveType === "metrics") {
411
+ if (effectiveType === "metrics" || effectiveType === "stats") {
351
412
  if (!hasMetrics) {
352
- throw new Error(`metrics ${mode} requires contentState.metrics`);
413
+ throw new Error(`${effectiveType} ${mode} requires contentState.metrics`);
353
414
  }
354
415
  return;
355
416
  }
@@ -903,6 +964,31 @@ program
903
964
  }
904
965
  });
905
966
 
967
+ const metricsCommand = program
968
+ .command("metrics")
969
+ .alias("metric")
970
+ .description("Update widget metric values");
971
+
972
+ metricsCommand
973
+ .command("update")
974
+ .description("Update a widget metric value")
975
+ .argument("<metric-key>", "Metric key")
976
+ .argument("<value>", "Metric value")
977
+ .action(async (metricKey, rawValue) => {
978
+ const globalOptions = program.opts();
979
+
980
+ try {
981
+ const apiKey = requireApiKey(globalOptions);
982
+ const client = createClient(apiKey);
983
+ const value = parseMetricValueArgument(rawValue);
984
+ const response = await client.metrics.update(metricKey, value);
985
+
986
+ outputResult(response, globalOptions, ["Metric value updated."]);
987
+ } catch (error) {
988
+ await handleError(error, globalOptions);
989
+ }
990
+ });
991
+
906
992
  const activityCommand = program
907
993
  .command("activity")
908
994
  .description("Manage Live Activities");