activitysmith-cli 1.18.0 → 1.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -111,22 +111,6 @@ activitysmith keys create --name "Ops alerts" --channels ops,alerts
111
111
 
112
112
  An API key cannot create another key. This command always uses the browser sign-in, even when `ACTIVITYSMITH_API_KEY` is set.
113
113
 
114
- ## Paired Devices
115
-
116
- List the iPhones and iPads paired to your account. Active devices come first:
117
-
118
- ```bash
119
- activitysmith devices list
120
- ```
121
-
122
- If no device is paired, the command prints the App Store link. Install ActivitySmith on your iPhone, sign in with the same account, and allow notifications.
123
-
124
- Add `--include-inactive` to also list devices that can no longer receive deliveries:
125
-
126
- ```bash
127
- activitysmith devices list --include-inactive
128
- ```
129
-
130
114
  ## Push Notifications
131
115
 
132
116
  ### Send a Push Notification
@@ -252,7 +236,7 @@ activitysmith push \
252
236
  --actions-file "./actions.json"
253
237
  ```
254
238
 
255
- ### Push Notification Interruption Levels
239
+ ### Interruption Levels
256
240
 
257
241
  ![Time Sensitive Push Notification](https://cdn.activitysmith.com/features/time-sensitive-push-notifications.png)
258
242
 
@@ -311,6 +295,23 @@ activitysmith push \
311
295
  --message "Error rate is back to normal. Incident resolved."
312
296
  ```
313
297
 
298
+ ### Dismiss a Push Notification
299
+
300
+ Pass the `Notification ID` to `push dismiss` when a Push Notification no longer needs attention, for example after you answered an agent's question somewhere else.
301
+
302
+ Dismissing clears it from the Lock Screen and Notification Center on every device it was sent to. History keeps it.
303
+
304
+ Devices clear the notification in the background, so it can take a moment.
305
+
306
+ ```bash
307
+ activitysmith push \
308
+ --title "🙋 Agent needs your input" \
309
+ --message "Approve the database migration?"
310
+ # Notification ID: Xk3pQ8mV2nR7tL9wB4yZ
311
+
312
+ activitysmith push dismiss "Xk3pQ8mV2nR7tL9wB4yZ"
313
+ ```
314
+
314
315
  ## Live Activities
315
316
 
316
317
  Choose the Live Activity type that matches what you want to show:
@@ -527,13 +528,13 @@ activitysmith activity stream nightly-backup \
527
528
  }'
528
529
  ```
529
530
 
530
- ### Live Activity Colors
531
+ ### Colors
531
532
 
532
533
  Choose from these colors for the Live Activity accent, including progress bars and action buttons, or apply them to an individual icon or badge:
533
534
 
534
535
  `lime`, `green`, `cyan`, `blue`, `purple`, `magenta`, `red`, `orange`, `yellow`, `gray`
535
536
 
536
- ### Live Activity Action
537
+ ### Actions
537
538
 
538
539
  ![Metrics Live Activity with action](https://cdn.activitysmith.com/features/metrics-live-activity-action.png)
539
540
 
@@ -654,11 +655,9 @@ activitysmith activity stream agent-approval \
654
655
 
655
656
  ![Lock screen widgets](https://cdn.activitysmith.com/features/lock-screen-widgets.png)
656
657
 
657
- 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.
658
+ 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. Send a value to a metric key, add a widget to your Lock Screen, and it fetches the latest value automatically.
658
659
 
659
- ![Create widget metric](https://cdn.activitysmith.com/features/create-widget-metric.png)
660
-
661
- Use the metric key to update its value.
660
+ Use the metric key to update its value. The first value creates the metric.
662
661
 
663
662
  ```bash
664
663
  activitysmith metrics update deploy.success_rate 99.9
@@ -670,6 +669,23 @@ String metric values work too.
670
669
  activitysmith metrics update prod.status healthy
671
670
  ```
672
671
 
672
+ ### Create a metric
673
+
674
+ Use `create` to set the label and how widgets show the value, such as currency, percent, or a unit. Omitted fields keep their current values, so you can call it every time your app starts.
675
+
676
+ ```bash
677
+ activitysmith metrics create mrr \
678
+ --label MRR \
679
+ --format currency \
680
+ --currency-code USD
681
+
682
+ activitysmith metrics update mrr 12450
683
+ ```
684
+
685
+ You can also create and edit metrics in the [web app](https://activitysmith.com/app/widgets).
686
+
687
+ ![Create widget metric](https://cdn.activitysmith.com/features/create-widget-metric.png)
688
+
673
689
  ## App Icon Badge
674
690
 
675
691
  ![ActivitySmith app icon with an App Icon Badge](https://cdn.activitysmith.com/features/badge-count.png)
@@ -835,6 +851,22 @@ activitysmith activity stream nightly-backup \
835
851
  activitysmith badge 3 --channels "sales,customer-success"
836
852
  ```
837
853
 
854
+ ## Paired Devices
855
+
856
+ List the iPhones and iPads paired to your account. Active devices come first:
857
+
858
+ ```bash
859
+ activitysmith devices list
860
+ ```
861
+
862
+ If no device is paired, the command prints the App Store link. Install ActivitySmith on your iPhone, sign in with the same account, and allow notifications.
863
+
864
+ Add `--include-inactive` to also list devices that can no longer receive deliveries:
865
+
866
+ ```bash
867
+ activitysmith devices list --include-inactive
868
+ ```
869
+
838
870
  ## Output
839
871
 
840
872
  Use `--json` for machine-readable output:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "activitysmith-cli",
3
- "version": "1.18.0",
3
+ "version": "1.19.0",
4
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",
package/src/agent.js ADDED
@@ -0,0 +1,49 @@
1
+ // The coding agent running the CLI, read from the environment it sets for its shell commands.
2
+ // Requests send it as X-ActivitySmith-Agent, so Push Notifications and approvals show the agent's
3
+ // name and icon, such as "Claude Code needs your approval", instead of the CLI's own sign-in name.
4
+ // The API accepts only the ids below and ignores anything else.
5
+
6
+ // AI_AGENT is the shared convention ("claude-code_2-1-321_agent"); check it by prefix.
7
+ const AI_AGENT_PREFIXES = [
8
+ ["claude-code", "claude-code"],
9
+ ["codex", "codex"],
10
+ ["cursor", "cursor"],
11
+ ];
12
+
13
+ /** Environment variables this reads, so tests can clear them. */
14
+ export const AGENT_ENV_VARS = [
15
+ "AI_AGENT",
16
+ "CLAUDECODE",
17
+ "CLAUDE_CODE",
18
+ "CLAUDE_CODE_IS_COWORK",
19
+ "CODEX_THREAD_ID",
20
+ "CODEX_SANDBOX",
21
+ "CODEX_CI",
22
+ "CURSOR_AGENT",
23
+ "CURSOR_EXTENSION_HOST_ROLE",
24
+ "CURSOR_TRACE_ID",
25
+ ];
26
+
27
+ export function detectAgent(env = process.env) {
28
+ // Cowork runs Claude Code, so it is checked before AI_AGENT names Claude Code.
29
+ if ((env.CLAUDECODE || env.CLAUDE_CODE) && env.CLAUDE_CODE_IS_COWORK) return "claude-cowork";
30
+
31
+ const aiAgent = String(env.AI_AGENT ?? "").trim().toLowerCase();
32
+ const fromAiAgent = AI_AGENT_PREFIXES.find(([prefix]) => aiAgent.startsWith(prefix));
33
+ if (fromAiAgent) return fromAiAgent[1];
34
+
35
+ if (env.CLAUDECODE || env.CLAUDE_CODE) return "claude-code";
36
+ if (env.CODEX_THREAD_ID || env.CODEX_SANDBOX || env.CODEX_CI) return "codex";
37
+ if (env.CURSOR_AGENT || env.CURSOR_EXTENSION_HOST_ROLE === "agent-exec") return "cursor";
38
+ // Every terminal in Cursor sets this, so it comes last: Claude Code or Codex running inside
39
+ // Cursor's terminal is still that agent.
40
+ if (env.CURSOR_TRACE_ID) return "cursor";
41
+ return null;
42
+ }
43
+
44
+ export const AGENT_HEADER = "X-ActivitySmith-Agent";
45
+
46
+ export function agentHeaders(env = process.env) {
47
+ const agent = detectAgent(env);
48
+ return agent ? { [AGENT_HEADER]: agent } : {};
49
+ }
package/src/cli.js CHANGED
@@ -1,6 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  import { Command, InvalidArgumentError, Option } from "commander";
4
+ import { agentHeaders } from "./agent.js";
4
5
  import { loadMetadata } from "./metadata.js";
5
6
  import {
6
7
  API_KEYS_SCOPE,
@@ -285,6 +286,12 @@ const credentialSource = (options) => {
285
286
  return readCredentials() ? "auth login" : null;
286
287
  };
287
288
 
289
+ // Names the coding agent running the CLI, so its Push Notifications show that agent's icon.
290
+ const agentRequestInit = () => {
291
+ const headers = agentHeaders();
292
+ return Object.keys(headers).length > 0 ? { headers } : undefined;
293
+ };
294
+
288
295
  const createClient = (apiKey) =>
289
296
  new ActivitySmith({
290
297
  apiKey,
@@ -391,7 +398,7 @@ const validateContentState = (contentState, mode) => {
391
398
  const normalizedType =
392
399
  typeof contentState.type === "string" ? contentState.type.trim() : undefined;
393
400
 
394
- if (!isNonEmptyString(contentState.title)) {
401
+ if (typeof contentState.title !== "string") {
395
402
  throw new Error("contentState.title is required");
396
403
  }
397
404
 
@@ -1373,10 +1380,10 @@ const pushCommand = program
1373
1380
 
1374
1381
  const isReplacement = options.replace !== undefined;
1375
1382
  const response = isReplacement
1376
- ? await client.notifications.replace(options.replace.trim(), pushNotificationRequest)
1383
+ ? await client.notifications.replace(options.replace.trim(), pushNotificationRequest, agentRequestInit())
1377
1384
  : await client.notifications.sendPushNotification({
1378
1385
  pushNotificationRequest,
1379
- });
1386
+ }, agentRequestInit());
1380
1387
  const devicesNotified = response?.devices_notified ?? response?.devicesNotified;
1381
1388
  const notificationId = response?.notification_id ?? response?.notificationId;
1382
1389
 
@@ -1790,6 +1797,7 @@ const apiRequest = async (path, { token, method = "GET", body } = {}) => {
1790
1797
  Authorization: `Bearer ${token}`,
1791
1798
  Accept: "application/json",
1792
1799
  "X-ActivitySmith-SDK": `cli-v${version}`,
1800
+ ...agentHeaders(),
1793
1801
  ...(body ? { "Content-Type": "application/json" } : {}),
1794
1802
  },
1795
1803
  ...(body ? { body: JSON.stringify(body) } : {}),