@alva-ai/toolkit 0.16.1-beta.0 → 0.16.1-beta.2

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/dist/cli.js CHANGED
@@ -9506,6 +9506,7 @@ var CliUsageError = class extends Error {
9506
9506
  };
9507
9507
 
9508
9508
  // src/resources/fs.ts
9509
+ var WRITE_FLAG_APPEND = 1 << 0;
9509
9510
  function isValidUtf8(bytes) {
9510
9511
  let i = 0;
9511
9512
  while (i < bytes.length) {
@@ -9573,7 +9574,8 @@ var FsResource = class {
9573
9574
  body: {
9574
9575
  path: params.path,
9575
9576
  data: params.data,
9576
- mkdir_parents: params.mkdir_parents
9577
+ mkdir_parents: params.mkdir_parents,
9578
+ ...params.append ? { flags: WRITE_FLAG_APPEND } : {}
9577
9579
  }
9578
9580
  });
9579
9581
  }
@@ -9583,7 +9585,8 @@ var FsResource = class {
9583
9585
  return this.client._request("POST", "/api/v1/fs/write", {
9584
9586
  query: {
9585
9587
  path: params.path,
9586
- mkdir_parents: params.mkdir_parents
9588
+ mkdir_parents: params.mkdir_parents,
9589
+ ...params.append ? { flags: WRITE_FLAG_APPEND } : {}
9587
9590
  },
9588
9591
  rawBody: params.body
9589
9592
  });
@@ -9705,7 +9708,9 @@ var DeployResource = class {
9705
9708
  push_notify: params.push_notify,
9706
9709
  max_heap_size_mb: params.max_heap_size_mb,
9707
9710
  run_as_user_id: params.run_as_user_id,
9708
- end_at: params.end_at
9711
+ start_at: params.start_at,
9712
+ end_at: params.end_at,
9713
+ max_runs: params.max_runs
9709
9714
  }
9710
9715
  });
9711
9716
  }
@@ -9750,9 +9755,10 @@ var DeployResource = class {
9750
9755
  /**
9751
9756
  * Fire the cronjob workflow once, immediately, bypassing the schedule.
9752
9757
  * Async — returns the Hatchet workflow run id at enqueue. The
9753
- * `cronjob_runs` row appears only after the worker finishes the run;
9754
- * callers verify completion by polling `listRuns({cronjob_id})` and
9755
- * matching `runs[].workflow_run_id` against the returned id.
9758
+ * `cronjob_runs` row can appear as DISPATCHED/RUNNING before it reaches a
9759
+ * terminal status; callers verify completion by polling
9760
+ * `getRunStatus({cronjob_id, workflow_run_id})` with their own
9761
+ * timeout/deadline.
9756
9762
  *
9757
9763
  * Surfaces backend status as HTTP errors (handled by AlvaClient):
9758
9764
  * - 404 not found / cross-user
@@ -9776,6 +9782,13 @@ var DeployResource = class {
9776
9782
  }
9777
9783
  );
9778
9784
  }
9785
+ async getRunStatus(params) {
9786
+ this.client._requireAuth();
9787
+ return this.client._request(
9788
+ "GET",
9789
+ `/api/v1/deploy/cronjob/${params.cronjob_id}/runs/by-workflow/${encodeURIComponent(params.workflow_run_id)}`
9790
+ );
9791
+ }
9779
9792
  async getRunLogs(params) {
9780
9793
  this.client._requireAuth();
9781
9794
  return this.client._request(
@@ -11811,19 +11824,6 @@ var NotificationsResource = class {
11811
11824
  this.client = client;
11812
11825
  }
11813
11826
  client;
11814
- /**
11815
- * List the caller's notification history for one playbook
11816
- * `(username, name)`. Returns `NOT_FOUND` when the playbook is
11817
- * private or does not exist (the two cases are deliberately
11818
- * indistinguishable to prevent namespace enumeration).
11819
- */
11820
- async listPlaybook(params) {
11821
- this.client._requireAuth();
11822
- const path = `/api/v1/playbook/${encodeURIComponent(params.username)}/${encodeURIComponent(params.name)}/notifications`;
11823
- return this.client._request("GET", path, {
11824
- query: buildQuery(params)
11825
- });
11826
- }
11827
11827
  /**
11828
11828
  * List the caller's notification history for one feed
11829
11829
  * `(username, name)`. Authorization is alfs read on
@@ -11890,27 +11890,27 @@ var SubscriptionsResource = class {
11890
11890
  }
11891
11891
  client;
11892
11892
  /**
11893
- * Subscribe to a playbook `(username, name)`: follow it and enable alerts
11894
- * on all its push-enabled automations. Idempotent. Auth: the caller must be
11895
- * able to read the playbook — public passes; paid requires an active unlock;
11896
- * private requires owner/admin.
11893
+ * Follow a playbook `(username, name)`. Alerts are independent and require
11894
+ * explicit FEED subscriptions. Idempotent.
11897
11895
  */
11898
- async subscribePlaybook(params) {
11896
+ async followPlaybook(params) {
11899
11897
  this.client._requireAuth();
11900
- const path = `/api/v1/subscriptions/playbook/${encodeURIComponent(params.username)}/${encodeURIComponent(params.name)}`;
11898
+ const path = `/api/v1/follows/playbook/${encodeURIComponent(params.username)}/${encodeURIComponent(params.name)}`;
11901
11899
  return this.client._request(
11902
11900
  "POST",
11903
11901
  path
11904
11902
  );
11905
11903
  }
11906
11904
  /**
11907
- * Unsubscribe from a playbook `(username, name)`: unfollow it and disable
11908
- * all of its push alerts for the caller. Idempotent.
11905
+ * Unfollow a playbook `(username, name)` without changing FEED alerts.
11909
11906
  */
11910
- async unsubscribePlaybook(params) {
11907
+ async unfollowPlaybook(params) {
11911
11908
  this.client._requireAuth();
11912
- const path = `/api/v1/subscriptions/playbook/${encodeURIComponent(params.username)}/${encodeURIComponent(params.name)}`;
11913
- return this.client._request("DELETE", path);
11909
+ const path = `/api/v1/follows/playbook/${encodeURIComponent(params.username)}/${encodeURIComponent(params.name)}`;
11910
+ return this.client._request(
11911
+ "DELETE",
11912
+ path
11913
+ );
11914
11914
  }
11915
11915
  /**
11916
11916
  * Subscribe to one feed `(username, name)` — enable personal push for that
@@ -11962,12 +11962,23 @@ var SubscriptionsResource = class {
11962
11962
  query
11963
11963
  });
11964
11964
  }
11965
+ /** Atomically enable alerts for FEED target ids (max 100). */
11966
+ async subscribeBatch(params) {
11967
+ this.client._requireAuth();
11968
+ return this.client._request(
11969
+ "POST",
11970
+ "/api/v1/subscriptions/subscribe-batch",
11971
+ {
11972
+ body: {
11973
+ feed_ids: params.feedIds,
11974
+ channel_id: params.channelId
11975
+ }
11976
+ }
11977
+ );
11978
+ }
11965
11979
  /**
11966
- * Disable alerts for many playbook/feed targets BY TARGET ID in one
11967
- * idempotent call (max 100 ids). Ids are strings (snowflake-safe). Works
11968
- * for ghost rows (deleted targets) because no name resolution happens —
11969
- * the per-id results report `INVALID_ID` for malformed entries while
11970
- * valid ones proceed. Safe to re-run: already-gone rows are no-ops.
11980
+ * Disable alerts for many FEED targets by id in one idempotent call (max
11981
+ * 100 ids). The per-id results report `INVALID_ID` for malformed entries.
11971
11982
  */
11972
11983
  async unsubscribeBatch(params) {
11973
11984
  this.client._requireAuth();
@@ -11976,8 +11987,7 @@ var SubscriptionsResource = class {
11976
11987
  "/api/v1/subscriptions/unsubscribe-batch",
11977
11988
  {
11978
11989
  body: {
11979
- playbook_ids: params.playbookIds ?? [],
11980
- feed_ids: params.feedIds ?? []
11990
+ feed_ids: params.feedIds
11981
11991
  }
11982
11992
  }
11983
11993
  );
@@ -12002,11 +12012,8 @@ var AlertsResource = class {
12002
12012
  disableAutomation(params) {
12003
12013
  return this.client.subscriptions.unsubscribeFeed(params);
12004
12014
  }
12005
- enablePlaybook(params) {
12006
- return this.client.subscriptions.subscribePlaybook(params);
12007
- }
12008
- disablePlaybook(params) {
12009
- return this.client.subscriptions.unsubscribePlaybook(params);
12015
+ enableBatch(params) {
12016
+ return this.client.subscriptions.subscribeBatch(params);
12010
12017
  }
12011
12018
  disableBatch(params) {
12012
12019
  return this.client.subscriptions.unsubscribeBatch(params);
@@ -12014,9 +12021,6 @@ var AlertsResource = class {
12014
12021
  historyAutomation(params) {
12015
12022
  return this.client.notifications.listFeed(params);
12016
12023
  }
12017
- historyPlaybook(params) {
12018
- return this.client.notifications.listPlaybook(params);
12019
- }
12020
12024
  preferences() {
12021
12025
  return this.client.notificationPreferences.list();
12022
12026
  }
@@ -13639,9 +13643,6 @@ function formatAlertList(result) {
13639
13643
  return lines.join("\n");
13640
13644
  }
13641
13645
  function alertTitle(alert) {
13642
- if (alert.playbook) {
13643
- return `${alert.playbook.owner_username}/${alert.playbook.name}`;
13644
- }
13645
13646
  if (alert.feed_name) return alert.feed_name;
13646
13647
  return alert.target?.id ? `target ${alert.target.id}` : "(unknown target)";
13647
13648
  }
@@ -13651,7 +13652,7 @@ import * as fs2 from "fs";
13651
13652
  import * as os2 from "os";
13652
13653
  import * as fsPromises2 from "fs/promises";
13653
13654
  import { Agent, setGlobalDispatcher } from "undici";
13654
- var CLI_VERSION = true ? "0.16.1-beta.0" : "dev";
13655
+ var CLI_VERSION = true ? "0.16.1-beta.2" : "dev";
13655
13656
  var DEFAULT_RUN_TIMEOUT_MS = 6e5;
13656
13657
  var RUN_TIMEOUT_ENV = "ALVA_RUN_TIMEOUT_MS";
13657
13658
  var configuredRunFetchTimeoutMs;
@@ -13696,10 +13697,10 @@ Commands:
13696
13697
  skillhub Playbook skills (list, tags, get, file)
13697
13698
  data-skills Data-skill documentation from the Arrays backend (list, summary, endpoint)
13698
13699
  comments Playbook comments (create, pin, unpin)
13699
- notification-history Notification delivery history (list-playbook, list-feed)
13700
+ notification-history Feed notification delivery history (list-feed)
13700
13701
  notification-preferences Notification preferences (list, enable-session-completed, disable-session-completed)
13701
13702
  feedback Submit user-confirmed Alva platform feedback (submit)
13702
- subscriptions Legacy alert/follow operations (subscribe-playbook, subscribe-feed, list, follows)
13703
+ subscriptions Playbook follows and feed alert subscriptions
13703
13704
  channel Channel group operations (group-subscriptions context, list, subscribe, unsubscribe)
13704
13705
  remix Save playbook remix lineage
13705
13706
  portfolio Connected-account portfolio (accounts, summary, activities)
@@ -13796,9 +13797,13 @@ Subcommands:
13796
13797
  Response fields:
13797
13798
  id User ID
13798
13799
  username Username (used in ALFS paths and playbook URLs)
13799
- subscription_tier "free" or "pro" \u2014 determines release flow and feature gates
13800
- telegram_username Telegram username if connected, null otherwise
13801
- slack_username Slack display name if connected, null otherwise
13800
+ subscription_tier "free", "pro", or "max" \u2014 determines release flow and feature gates
13801
+ telegram_username Telegram display name if connected, empty otherwise
13802
+ discord_username Discord display name if connected, empty otherwise
13803
+ slack_username Slack display name if connected, empty otherwise
13804
+ whatsapp_username WhatsApp display name if connected, empty otherwise
13805
+ imessage_username iMessage display name if connected, empty otherwise
13806
+ active_channel Currently selected IM delivery channel
13802
13807
 
13803
13808
  Examples:
13804
13809
  alva user me`,
@@ -13849,7 +13854,7 @@ Subcommands:
13849
13854
  Subcommand flags:
13850
13855
  read --path (required), [--offset <n>], [--size <n>]
13851
13856
  write --path (required), --data <text> OR --file <local-path> (one required),
13852
- [--mkdir-parents | --no-mkdir-parents]
13857
+ [--append], [--mkdir-parents | --no-mkdir-parents]
13853
13858
  stat --path (required)
13854
13859
  readdir --path (required), [--recursive | --no-recursive]
13855
13860
  mkdir --path (required)
@@ -13887,6 +13892,7 @@ Examples:
13887
13892
  alva fs read --path "~/feeds/btc-ema/v1/data/metrics/prices/@last/100"
13888
13893
  alva fs read --path /alva/home/alice/feeds/btc-ema/v1/data/metrics/prices/@last/10
13889
13894
  alva fs write --path "~/hello.txt" --data "Hello, world!"
13895
+ alva fs write --path "~/journal.md" --data "New entry" --append
13890
13896
  alva fs write --path "~/feeds/my-feed/v1/src/index.js" --file ./local-script.js --mkdir-parents
13891
13897
  alva fs stat --path "~/hello.txt"
13892
13898
  alva fs mkdir --path "~/feeds/my-feed/v1/src"
@@ -13959,8 +13965,9 @@ Subcommands:
13959
13965
  pause Pause a running cronjob
13960
13966
  resume Resume a paused cronjob
13961
13967
  trigger Fire the cronjob once, immediately, bypassing the schedule
13962
- (returns workflow_run_id; poll 'runs' to verify completion)
13968
+ (returns workflow_run_id; poll 'run-status' with a timeout)
13963
13969
  runs List runs for a cronjob (cursor-paginated)
13970
+ run-status Get one triggered run's pollable status by workflow_run_id
13964
13971
  run-logs Get stdout/stderr logs for a single cronjob run
13965
13972
 
13966
13973
  Create/Update flags:
@@ -13989,6 +13996,10 @@ Runs flags:
13989
13996
  --first <n> Max results per page
13990
13997
  --cursor <cursor> Pagination cursor from previous response
13991
13998
 
13999
+ Run-status flags:
14000
+ --id <id> Cronjob ID (required)
14001
+ --workflow-run-id <id> Workflow run ID returned by deploy trigger
14002
+
13992
14003
  Run-logs flags:
13993
14004
  --id <id> Cronjob ID (required)
13994
14005
  --run-id <id> Run ID (required)
@@ -14015,25 +14026,29 @@ Examples:
14015
14026
  alva deploy delete --id 42
14016
14027
  alva deploy runs --id 42
14017
14028
  alva deploy runs --id 42 --first 10
14029
+ alva deploy run-status --id 42 --workflow-run-id hatchet-run-id
14018
14030
  alva deploy run-logs --id 42 --run-id 123
14019
14031
 
14020
- Build-time verify (fire once, then poll until your run completes):
14032
+ Build-time verify (fire once, then poll up to 5 minutes):
14021
14033
  WF=$(alva deploy trigger --id 42 | jq -r .workflow_run_id)
14022
- while ! ROW=$(alva deploy runs --id 42 --first 5 \\
14023
- | jq -e ".runs[] | select(.workflow_run_id==\\"$WF\\")"); do
14034
+ for _ in {1..60}; do
14035
+ STATUS_JSON=$(alva deploy run-status --id 42 --workflow-run-id "$WF")
14036
+ STATE=$(echo "$STATUS_JSON" | jq -r .state)
14037
+ case "$STATE" in PENDING|DISPATCHED|RUNNING) ;; *) break ;; esac
14024
14038
  sleep 5
14025
14039
  done
14026
- STATUS=$(echo "$ROW" | jq -r .status)
14027
- [ "$STATUS" = completed ] || alva deploy run-logs --id 42 \\
14028
- --run-id "$(echo "$ROW" | jq -r .id)"`,
14040
+ case "$STATE" in
14041
+ PENDING|DISPATCHED|RUNNING) echo "Timed out waiting for run completion" >&2; exit 1 ;;
14042
+ esac
14043
+ [ "$STATE" = COMPLETED ] || alva deploy run-logs --id 42 \\
14044
+ --run-id "$(echo "$STATUS_JSON" | jq -r .run.id)"`,
14029
14045
  loop: `Usage: alva loop <subcommand> [options]
14030
14046
 
14031
- Create a self-scheduled, in-channel goal loop: a cronjob that each tick runs
14047
+ Create a bounded, self-scheduled in-channel goal loop: a cronjob that each tick runs
14032
14048
  one fire-and-forget agent turn on a channel's stable main session (via the
14033
- @alva/loop SDK), continuing that channel's conversation toward a goal. Every
14034
- loop gets a lifetime ceiling (default 7 days) so a self-scheduled loop always
14035
- terminates. Sugar over 'alva deploy create' \u2014 it seeds a shared loop-runner
14036
- script and packs the goal/channel into the cronjob's args.
14049
+ @alva/loop SDK), continuing that channel's conversation toward a goal. Sugar
14050
+ over 'alva deploy create' \u2014 it seeds a shared loop-runner script and packs the
14051
+ goal/channel into the cronjob's args.
14037
14052
 
14038
14053
  Subcommands:
14039
14054
  create Create a loop (seeds the shared loop-runner + a cronjob)
@@ -14042,14 +14057,18 @@ Create flags:
14042
14057
  --goal <text> Instruction run each tick (required)
14043
14058
  --cron <expression> Cron schedule (required, e.g. "0 * * * *")
14044
14059
  --channel-id <id> Target channel id. Omit \u21D2 your DM/agent channel
14045
- --expires-in <dur> Lifetime: 30m | 24h | 7d, or 'never' (unbounded \u2014
14046
- discouraged). Default: 7d
14060
+ --start <time> First eligible time: 'now' (default) or RFC3339
14061
+ --until <time> Exclusive RFC3339 cutoff
14062
+ --runs <count> Maximum admitted runs after --start
14047
14063
  --name <name> Cronjob name (default: derived from --goal;
14048
14064
  1-63 lowercase alphanumeric/hyphens)
14049
14065
 
14066
+ At least one of --until or --runs is required. RFC3339 timestamps must include
14067
+ a timezone (Z or \xB1HH:MM).
14068
+
14050
14069
  Examples:
14051
- alva loop create --channel-id 7284... --goal "watch NVDA pre-market, alert on setup" --cron "0 * * * *"
14052
- alva loop create --goal "summarize my unread channels" --cron "0 8 * * *" --expires-in 30d`,
14070
+ alva loop create --channel-id 7284... --goal "watch NVDA pre-market, alert on setup" --cron "*/5 * * * *" --until "2026-07-15T09:30:00-04:00"
14071
+ alva loop create --goal "check the next 12 intervals" --cron "0 * * * *" --start now --runs 12`,
14053
14072
  "service-account": `Usage: alva service-account <subcommand> [options]
14054
14073
 
14055
14074
  Manage restricted run-as identities. A service account executes a UDF or
@@ -14113,27 +14132,25 @@ Examples:
14113
14132
  alva automation delete --id 42`,
14114
14133
  alert: `Usage: alva alert <subcommand> [options]
14115
14134
 
14116
- Manage alerts. Alerts are personal notification opt-ins for automations or
14117
- playbooks. Delivery history and global alert preferences live here too.
14135
+ Manage alerts. Alert subscriptions target automations (feeds) only. Playbook
14136
+ follows are independent; delivery history and global preferences live here too.
14118
14137
 
14119
14138
  Subcommands:
14120
14139
  list List the caller's active alerts
14121
14140
  follows List the playbooks the caller follows
14122
- enable Enable an alert for an automation or playbook
14123
- disable Disable alerts by automation/playbook name or id
14124
- history List alert delivery history for an automation or playbook
14141
+ enable Enable alerts by automation name or ids
14142
+ disable Disable alerts by automation name or ids
14143
+ history List alert delivery history for an automation
14125
14144
  preferences List global alert preferences
14126
14145
  enable-session-completed
14127
14146
  disable-session-completed
14128
14147
 
14129
14148
  Target flags:
14130
14149
  --automation <owner/name> Automation target
14131
- --playbook <owner/name> Playbook target
14132
14150
 
14133
- Disable-by-id flags:
14151
+ Enable/disable-by-id flags:
14134
14152
  --automation-ids <a,b> Comma-separated automation target ids
14135
- --playbook-ids <a,b> Comma-separated playbook target ids
14136
- --feed-ids <a,b> Legacy alias for --automation-ids
14153
+ --channel-id <id> Delivery channel for batch enable (optional)
14137
14154
 
14138
14155
  List flags:
14139
14156
  --first <n> Optional page size
@@ -14154,9 +14171,8 @@ Examples:
14154
14171
  alva alert follows --limit 20
14155
14172
  alva alert enable --automation alice/btc-ema
14156
14173
  alva alert disable --automation alice/btc-ema
14157
- alva alert enable --playbook alice/btc-dashboard
14174
+ alva alert enable --automation-ids 13292,13293
14158
14175
  alva alert disable --automation-ids 13292
14159
- alva alert disable --feed-ids 13292
14160
14176
  alva alert history --automation alice/btc-ema --status sent
14161
14177
  alva alert preferences`,
14162
14178
  feed: `Usage: alva feed <subcommand> [options]
@@ -14550,16 +14566,15 @@ Examples:
14550
14566
  alva comments unpin --comment-id 12`,
14551
14567
  "notification-history": `Usage: alva notification-history <subcommand> [options]
14552
14568
 
14553
- Read the caller's delivered notification history scoped to a playbook or feed.
14569
+ Read the caller's delivered notification history scoped to a feed.
14554
14570
  This is an audit/history surface, not a subscription toggle.
14555
14571
 
14556
14572
  Subcommands:
14557
- list-playbook List notification history for a playbook
14558
14573
  list-feed List notification history for a feed
14559
14574
 
14560
14575
  Common flags:
14561
14576
  --username <user> Owner's username (required)
14562
- --name <name> URL-safe playbook or feed name (required)
14577
+ --name <name> URL-safe feed name (required)
14563
14578
  --channel <name> Optional delivery channel filter (telegram, web, ...)
14564
14579
  --status <status> Optional status filter (sent, failed, filtered)
14565
14580
  --since <seconds> Optional Unix seconds lower bound
@@ -14567,7 +14582,6 @@ Common flags:
14567
14582
  --cursor <token> Optional cursor from the previous page
14568
14583
 
14569
14584
  Examples:
14570
- alva notification-history list-playbook --username alice --name btc-dashboard --first 5
14571
14585
  alva notification-history list-feed --username alice --name btc-ema --status sent`,
14572
14586
  "notification-preferences": `Usage: alva notification-preferences <subcommand>
14573
14587
 
@@ -14612,33 +14626,28 @@ Three DISTINCT concepts share the word "subscribe" in the product:
14612
14626
  - PURCHASE \u2014 paid playbook access / the SaaS plan. NOT this command.
14613
14627
 
14614
14628
  Operations:
14615
- - subscribe-playbook is a CASCADE: follows the playbook AND enables alerts
14616
- on all its push-enabled automations (one call). unsubscribe-playbook
14617
- reverses both and reports exactly what it changed
14618
- ({unfollowed, wildcard_disabled}).
14619
- - subscribe-feed / unsubscribe-feed toggle ONE feed's alert (a single
14620
- automation) without touching the playbook follow.
14621
- - unsubscribe disables alerts BY TARGET ID \u2014 bulk, idempotent, and the
14622
- only way to clear ghost rows whose playbook/feed was deleted
14623
- (name-addressed unsubscribe 404s on deleted targets).
14629
+ - follow-playbook / unfollow-playbook change only the social follow.
14630
+ - subscribe-feed / unsubscribe-feed toggle one feed's alert.
14631
+ - subscribe / unsubscribe toggle alerts for FEED ids in a batch. They never
14632
+ follow or unfollow a playbook.
14624
14633
 
14625
14634
  Subcommands:
14626
- subscribe-playbook Subscribe a playbook (follow + enable all its alerts)
14627
- unsubscribe-playbook Unsubscribe a playbook (unfollow + disable its alerts)
14635
+ follow-playbook Follow a playbook without changing alerts
14636
+ unfollow-playbook Unfollow a playbook without changing alerts
14628
14637
  subscribe-feed Enable alerts for a single feed
14629
14638
  unsubscribe-feed Disable alerts for a single feed
14630
- unsubscribe Bulk disable alerts by target id (handles ghosts)
14639
+ subscribe Bulk enable alerts by feed id
14640
+ unsubscribe Bulk disable alerts by feed id
14631
14641
  list List the caller's active alert subscriptions
14632
14642
  follows List the playbooks the caller follows
14633
14643
 
14634
- Subscribe/unsubscribe flags (playbook + feed, name-addressed):
14644
+ Name-addressed flags:
14635
14645
  --username <user> Owner's username (required)
14636
14646
  --name <name> URL-safe playbook or feed name (required)
14637
14647
 
14638
- Unsubscribe (by id) flags:
14639
- --playbook-ids <a,b> Comma-separated playbook target ids
14648
+ Batch flags:
14640
14649
  --feed-ids <a,b> Comma-separated feed target ids
14641
- (at least one of the two; max 100 ids total)
14650
+ --channel-id <id> Delivery channel for subscribe (optional)
14642
14651
 
14643
14652
  List flags:
14644
14653
  --first <n> Optional page size (response carries total_count \u2014
@@ -14650,43 +14659,41 @@ Follows flags:
14650
14659
  --cursor <token> Optional cursor from the previous page
14651
14660
 
14652
14661
  List response notes:
14653
- items[].kind PLAYBOOK_ALERTS (playbook-level wildcard) | FEED_ALERT
14654
- items[].following Whether the caller also FOLLOWS the playbook
14655
- items[].target_status ACTIVE | TARGET_DELETED (ghost \u2014 clear via
14656
- unsubscribe --playbook-ids/--feed-ids) | PAUSED
14657
- items[].playbook {owner_username, name, display_name} for PLAYBOOK rows
14662
+ items[].kind FEED_ALERT
14663
+ items[].target_status ACTIVE | TARGET_DELETED | PAUSED
14658
14664
 
14659
14665
  Examples:
14660
- alva subscriptions subscribe-playbook --username alice --name btc-dashboard
14666
+ alva subscriptions follow-playbook --username alice --name btc-dashboard
14661
14667
  alva subscriptions subscribe-feed --username alice --name btc-ema-cross
14662
- alva subscriptions unsubscribe --playbook-ids 8009,8010 --feed-ids 13292
14668
+ alva subscriptions subscribe --feed-ids 13292,13293
14669
+ alva subscriptions unsubscribe --feed-ids 13292,13293
14663
14670
  alva subscriptions list --first 200
14664
14671
  alva subscriptions follows`,
14665
14672
  channel: `Usage: alva channel group-subscriptions <subcommand> [options]
14666
14673
 
14667
14674
  Manage push notifications delivered into the external group chat attached
14668
- to a channel session. The group can subscribe to public feeds and playbooks.
14675
+ to a channel session. The group can subscribe to public feeds.
14669
14676
  Subscribe/unsubscribe are idempotent no-ops unless the authenticated caller
14670
14677
  is that group's Alva admin.
14671
14678
 
14672
14679
  Subcommands:
14673
14680
  context Show group admin status and current subscriptions
14674
14681
  list List active subscriptions for the group
14675
- subscribe Subscribe the group to a public feed or playbook
14676
- unsubscribe Unsubscribe the group from a feed or playbook
14682
+ subscribe Subscribe the group to a public feed
14683
+ unsubscribe Unsubscribe the group from a feed
14677
14684
 
14678
14685
  Common flags:
14679
14686
  --session-id <id> Channel session id for the group (required)
14680
14687
 
14681
14688
  Subscribe/unsubscribe flags:
14682
- --target-type <type> feed or playbook (required)
14683
- --target-id <id> Numeric feed_id or playbook_id (required)
14689
+ --target-type <type> feed (required)
14690
+ --target-id <id> Numeric feed_id (required)
14684
14691
 
14685
14692
  Examples:
14686
14693
  alva channel group-subscriptions context --session-id 123
14687
14694
  alva channel group-subscriptions list --session-id 123
14688
14695
  alva channel group-subscriptions subscribe --session-id 123 --target-type feed --target-id 8169
14689
- alva channel group-subscriptions unsubscribe --session-id 123 --target-type playbook --target-id 42`,
14696
+ alva channel group-subscriptions unsubscribe --session-id 123 --target-type feed --target-id 8169`,
14690
14697
  remix: `Usage: alva remix --child-username <u> --child-name <n> --parents <json>
14691
14698
 
14692
14699
  Record remix lineage when creating a playbook based on existing playbooks.
@@ -14867,6 +14874,7 @@ async function handleConfigure(args, deps) {
14867
14874
  var BOOLEAN_FLAGS = /* @__PURE__ */ new Set([
14868
14875
  "recursive",
14869
14876
  "mkdir-parents",
14877
+ "append",
14870
14878
  "push-notify",
14871
14879
  "help",
14872
14880
  "execute-latest",
@@ -15056,9 +15064,9 @@ function configureRunFetchTimeout(timeoutMs, deps) {
15056
15064
  }
15057
15065
  function requireGroupSubscriptionTargetType(flags, command) {
15058
15066
  const val = requireFlag(flags, "target-type", command).trim().toLowerCase();
15059
- if (val === "feed" || val === "playbook") return val;
15067
+ if (val === "feed") return val;
15060
15068
  throw new CliUsageError(
15061
- `--target-type must be feed or playbook for '${command}', got '${val}'`,
15069
+ `--target-type must be feed for '${command}', got '${val}'`,
15062
15070
  command.split(" ")[0]
15063
15071
  );
15064
15072
  }
@@ -15083,25 +15091,20 @@ function parseOwnerNameTarget(value, flag, command) {
15083
15091
  }
15084
15092
  return { username, name };
15085
15093
  }
15086
- function requireSingleAlertTarget(flags, command) {
15087
- const automation = flags["automation"];
15088
- const playbook = flags["playbook"];
15089
- if ((automation ? 1 : 0) + (playbook ? 1 : 0) !== 1) {
15094
+ function rejectPlaybookAlertTarget(flags, command) {
15095
+ if (flags["playbook"] !== void 0 || flags["playbook-ids"] !== void 0) {
15090
15096
  throw new CliUsageError(
15091
- `Provide exactly one of --automation or --playbook for '${command}'`,
15097
+ `Playbook alert targets are unsupported for '${command}'; use --automation or --automation-ids`,
15092
15098
  "alert"
15093
15099
  );
15094
15100
  }
15095
- if (automation) {
15096
- return {
15097
- kind: "automation",
15098
- target: parseOwnerNameTarget(automation, "automation", command)
15099
- };
15100
- }
15101
- return {
15102
- kind: "playbook",
15103
- target: parseOwnerNameTarget(playbook, "playbook", command)
15104
- };
15101
+ }
15102
+ function requireAutomationAlertTarget(flags, command) {
15103
+ return parseOwnerNameTarget(
15104
+ requireFlag(flags, "automation", command),
15105
+ "automation",
15106
+ command
15107
+ );
15105
15108
  }
15106
15109
  function feedReleaseParams(flags, command) {
15107
15110
  return {
@@ -15186,26 +15189,65 @@ var LOOP_RUNNER_SRC = [
15186
15189
  "loop(goal, channelId ? { channelId } : {});",
15187
15190
  ""
15188
15191
  ].join("\n");
15189
- function parseExpiresInToEndAt(value, command) {
15190
- const raw = (value ?? "7d").trim().toLowerCase();
15191
- if (raw === "never") return void 0;
15192
- const match = /^([1-9]\d*)([mhd])$/.exec(raw);
15192
+ function parseLoopTimestamp(value, flag) {
15193
+ const raw = value.trim();
15194
+ const match = /^(\d{4})-(\d{2})-(\d{2})[tT](\d{2}):(\d{2}):(\d{2})(?:\.\d+)?(?:[zZ]|([+-])(\d{2}):(\d{2}))$/.exec(
15195
+ raw
15196
+ );
15193
15197
  if (!match) {
15194
15198
  throw new CliUsageError(
15195
- `--expires-in must be a positive duration like 30m, 24h, 7d, or 'never', got '${value}'`,
15196
- command.split(" ")[0]
15199
+ `--${flag} must be an RFC3339 timestamp with a timezone (Z or \xB1HH:MM), got '${value}'`,
15200
+ "loop"
15197
15201
  );
15198
15202
  }
15199
- const amount = Number(match[1]);
15200
- const unit = match[2];
15201
- const durationMs = amount * (unit === "m" ? 6e4 : unit === "h" ? 36e5 : 864e5);
15202
- if (!Number.isSafeInteger(durationMs)) {
15203
+ const year = Number(match[1]);
15204
+ const month = Number(match[2]);
15205
+ const day = Number(match[3]);
15206
+ const hour = Number(match[4]);
15207
+ const minute = Number(match[5]);
15208
+ const second = Number(match[6]);
15209
+ const offsetHour = Number(match[8] ?? 0);
15210
+ const offsetMinute = Number(match[9] ?? 0);
15211
+ const leapYear = year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0);
15212
+ const monthDays = [
15213
+ 31,
15214
+ leapYear ? 29 : 28,
15215
+ 31,
15216
+ 30,
15217
+ 31,
15218
+ 30,
15219
+ 31,
15220
+ 31,
15221
+ 30,
15222
+ 31,
15223
+ 30,
15224
+ 31
15225
+ ];
15226
+ if (month < 1 || month > 12 || day < 1 || day > monthDays[month - 1] || hour > 23 || minute > 59 || second > 59 || offsetHour > 23 || offsetMinute > 59) {
15203
15227
  throw new CliUsageError(
15204
- `--expires-in is too large, got '${value}'`,
15205
- command.split(" ")[0]
15228
+ `--${flag} must be a valid RFC3339 timestamp, got '${value}'`,
15229
+ "loop"
15230
+ );
15231
+ }
15232
+ const timestamp = Date.parse(raw);
15233
+ if (!Number.isFinite(timestamp)) {
15234
+ throw new CliUsageError(
15235
+ `--${flag} must be a valid RFC3339 timestamp, got '${value}'`,
15236
+ "loop"
15206
15237
  );
15207
15238
  }
15208
- return new Date(Date.now() + durationMs).toISOString();
15239
+ return new Date(timestamp).toISOString();
15240
+ }
15241
+ function parseLoopRuns(value) {
15242
+ if (value === void 0) return void 0;
15243
+ if (!/^[1-9]\d*$/.test(value)) {
15244
+ throw new CliUsageError("--runs must be a positive integer", "loop");
15245
+ }
15246
+ const runs = Number(value);
15247
+ if (!Number.isSafeInteger(runs) || runs > 2147483647) {
15248
+ throw new CliUsageError("--runs is too large", "loop");
15249
+ }
15250
+ return runs;
15209
15251
  }
15210
15252
  function loopCronjobName(flags, goal) {
15211
15253
  if (flags["name"] !== void 0) return flags["name"];
@@ -15483,13 +15525,15 @@ async function dispatch(client, args, meta, deps) {
15483
15525
  return client.fs.rawWrite({
15484
15526
  path: requireFlag(flags, "path", "fs write"),
15485
15527
  body: fileData,
15486
- mkdir_parents: boolFlag(flags["mkdir-parents"]) ?? true
15528
+ mkdir_parents: boolFlag(flags["mkdir-parents"]) ?? true,
15529
+ append: boolFlag(flags["append"])
15487
15530
  });
15488
15531
  }
15489
15532
  return client.fs.write({
15490
15533
  path: requireFlag(flags, "path", "fs write"),
15491
15534
  data: requireFlag(flags, "data", "fs write"),
15492
- mkdir_parents: boolFlag(flags["mkdir-parents"]) ?? true
15535
+ mkdir_parents: boolFlag(flags["mkdir-parents"]) ?? true,
15536
+ append: boolFlag(flags["append"])
15493
15537
  });
15494
15538
  case "stat":
15495
15539
  return client.fs.stat({
@@ -15655,6 +15699,15 @@ async function dispatch(client, args, meta, deps) {
15655
15699
  first: num(flags["first"]),
15656
15700
  cursor: flags["cursor"]
15657
15701
  });
15702
+ case "run-status":
15703
+ return client.deploy.getRunStatus({
15704
+ cronjob_id: requireNumericFlag(flags, "id", "deploy run-status"),
15705
+ workflow_run_id: requireFlag(
15706
+ flags,
15707
+ "workflow-run-id",
15708
+ "deploy run-status"
15709
+ )
15710
+ });
15658
15711
  case "run-logs":
15659
15712
  return client.deploy.getRunLogs({
15660
15713
  cronjob_id: requireNumericFlag(flags, "id", "deploy run-logs"),
@@ -15672,13 +15725,31 @@ async function dispatch(client, args, meta, deps) {
15672
15725
  throw new CliUsageError("Missing subcommand for loop", "loop");
15673
15726
  switch (subcommand) {
15674
15727
  case "create": {
15728
+ if (flags["expires-in"] !== void 0) {
15729
+ throw new CliUsageError(
15730
+ "Unknown flag --expires-in; use --until and/or --runs",
15731
+ "loop"
15732
+ );
15733
+ }
15675
15734
  const goal = requireFlag(flags, "goal", "loop create");
15676
15735
  const cron = requireFlag(flags, "cron", "loop create");
15677
15736
  const channelId = flags["channel-id"];
15678
- const endAt = parseExpiresInToEndAt(
15679
- flags["expires-in"],
15680
- "loop create"
15681
- );
15737
+ const startRaw = (flags["start"] ?? "now").trim();
15738
+ const startAt = startRaw.toLowerCase() === "now" ? void 0 : parseLoopTimestamp(startRaw, "start");
15739
+ const endAt = flags["until"] ? parseLoopTimestamp(flags["until"], "until") : void 0;
15740
+ const maxRuns = parseLoopRuns(flags["runs"]);
15741
+ if (endAt === void 0 && maxRuns === void 0) {
15742
+ throw new CliUsageError(
15743
+ "loop create requires at least one of --until or --runs",
15744
+ "loop"
15745
+ );
15746
+ }
15747
+ if (startAt !== void 0 && endAt !== void 0 && endAt <= startAt) {
15748
+ throw new CliUsageError(
15749
+ "--until must be later than --start",
15750
+ "loop"
15751
+ );
15752
+ }
15682
15753
  await client.fs.write({
15683
15754
  path: LOOP_RUNNER_PATH,
15684
15755
  data: LOOP_RUNNER_SRC,
@@ -15689,7 +15760,9 @@ async function dispatch(client, args, meta, deps) {
15689
15760
  path: LOOP_RUNNER_PATH,
15690
15761
  cron_expression: cron,
15691
15762
  args: channelId ? { goal, channelId } : { goal },
15692
- end_at: endAt
15763
+ start_at: startAt,
15764
+ end_at: endAt,
15765
+ max_runs: maxRuns
15693
15766
  });
15694
15767
  }
15695
15768
  default:
@@ -16316,8 +16389,6 @@ async function dispatch(client, args, meta, deps) {
16316
16389
  cursor: flags["cursor"]
16317
16390
  };
16318
16391
  switch (subcommand) {
16319
- case "list-playbook":
16320
- return client.notifications.listPlaybook(params);
16321
16392
  case "list-feed":
16322
16393
  return client.notifications.listFeed(params);
16323
16394
  default:
@@ -16387,31 +16458,23 @@ async function dispatch(client, args, meta, deps) {
16387
16458
  "subscriptions"
16388
16459
  );
16389
16460
  switch (subcommand) {
16390
- case "subscribe-playbook":
16391
- return client.subscriptions.subscribePlaybook({
16461
+ case "follow-playbook":
16462
+ return client.subscriptions.followPlaybook({
16392
16463
  username: requireFlag(
16393
16464
  flags,
16394
16465
  "username",
16395
- "subscriptions subscribe-playbook"
16466
+ `subscriptions ${subcommand}`
16396
16467
  ),
16397
- name: requireFlag(
16398
- flags,
16399
- "name",
16400
- "subscriptions subscribe-playbook"
16401
- )
16468
+ name: requireFlag(flags, "name", `subscriptions ${subcommand}`)
16402
16469
  });
16403
- case "unsubscribe-playbook":
16404
- return client.subscriptions.unsubscribePlaybook({
16470
+ case "unfollow-playbook":
16471
+ return client.subscriptions.unfollowPlaybook({
16405
16472
  username: requireFlag(
16406
16473
  flags,
16407
16474
  "username",
16408
- "subscriptions unsubscribe-playbook"
16475
+ `subscriptions ${subcommand}`
16409
16476
  ),
16410
- name: requireFlag(
16411
- flags,
16412
- "name",
16413
- "subscriptions unsubscribe-playbook"
16414
- )
16477
+ name: requireFlag(flags, "name", `subscriptions ${subcommand}`)
16415
16478
  });
16416
16479
  case "subscribe-feed":
16417
16480
  return client.subscriptions.subscribeFeed({
@@ -16441,20 +16504,39 @@ async function dispatch(client, args, meta, deps) {
16441
16504
  limit: num(flags["limit"]),
16442
16505
  cursor: flags["cursor"]
16443
16506
  });
16444
- case "unsubscribe": {
16445
- const playbookIds = csvList(flags["playbook-ids"]) ?? [];
16446
- const feedIds = csvList(flags["feed-ids"]) ?? [];
16447
- if (playbookIds.length === 0 && feedIds.length === 0) {
16507
+ case "subscribe": {
16508
+ if (flags["playbook-ids"] !== void 0) {
16448
16509
  throw new CliUsageError(
16449
- "--playbook-ids or --feed-ids is required",
16510
+ "Playbook alert targets are unsupported; use --feed-ids",
16450
16511
  "subscriptions"
16451
16512
  );
16452
16513
  }
16453
- return client.subscriptions.unsubscribeBatch({
16454
- playbookIds,
16455
- feedIds
16514
+ const feedIds = csvList(flags["feed-ids"]) ?? [];
16515
+ if (feedIds.length === 0) {
16516
+ throw new CliUsageError("--feed-ids is required", "subscriptions");
16517
+ }
16518
+ return client.subscriptions.subscribeBatch({
16519
+ feedIds,
16520
+ channelId: flags["channel-id"] === void 0 ? void 0 : requirePositiveIntegerStringFlag(
16521
+ flags,
16522
+ "channel-id",
16523
+ "subscriptions subscribe"
16524
+ )
16456
16525
  });
16457
16526
  }
16527
+ case "unsubscribe": {
16528
+ if (flags["playbook-ids"] !== void 0) {
16529
+ throw new CliUsageError(
16530
+ "Playbook alert targets are unsupported; use --feed-ids",
16531
+ "subscriptions"
16532
+ );
16533
+ }
16534
+ const feedIds = csvList(flags["feed-ids"]) ?? [];
16535
+ if (feedIds.length === 0) {
16536
+ throw new CliUsageError("--feed-ids is required", "subscriptions");
16537
+ }
16538
+ return client.subscriptions.unsubscribeBatch({ feedIds });
16539
+ }
16458
16540
  default:
16459
16541
  throw new CliUsageError(
16460
16542
  `Unknown subcommand: subscriptions ${subcommand}`,
@@ -16479,33 +16561,57 @@ async function dispatch(client, args, meta, deps) {
16479
16561
  cursor: flags["cursor"]
16480
16562
  });
16481
16563
  case "enable": {
16482
- const target = requireSingleAlertTarget(flags, "alert enable");
16483
- return target.kind === "automation" ? client.alerts.enableAutomation(target.target) : client.alerts.enablePlaybook(target.target);
16564
+ rejectPlaybookAlertTarget(flags, "alert enable");
16565
+ const automationIds = csvList(flags["automation-ids"]) ?? [];
16566
+ if (automationIds.length > 0) {
16567
+ if (flags["automation"] !== void 0) {
16568
+ throw new CliUsageError(
16569
+ "Provide either --automation or --automation-ids for 'alert enable'",
16570
+ "alert"
16571
+ );
16572
+ }
16573
+ return client.alerts.enableBatch({
16574
+ feedIds: automationIds,
16575
+ channelId: flags["channel-id"] === void 0 ? void 0 : requirePositiveIntegerStringFlag(
16576
+ flags,
16577
+ "channel-id",
16578
+ "alert enable"
16579
+ )
16580
+ });
16581
+ }
16582
+ return client.alerts.enableAutomation(
16583
+ requireAutomationAlertTarget(flags, "alert enable")
16584
+ );
16484
16585
  }
16485
16586
  case "disable": {
16486
- const automationIds = csvList(flags["automation-ids"]) ?? csvList(flags["feed-ids"]) ?? [];
16487
- const playbookIds = csvList(flags["playbook-ids"]) ?? [];
16488
- if (automationIds.length > 0 || playbookIds.length > 0) {
16489
- return client.alerts.disableBatch({
16490
- playbookIds,
16491
- feedIds: automationIds
16492
- });
16587
+ rejectPlaybookAlertTarget(flags, "alert disable");
16588
+ const automationIds = csvList(flags["automation-ids"]) ?? [];
16589
+ if (automationIds.length > 0) {
16590
+ if (flags["automation"] !== void 0) {
16591
+ throw new CliUsageError(
16592
+ "Provide either --automation or --automation-ids for 'alert disable'",
16593
+ "alert"
16594
+ );
16595
+ }
16596
+ return client.alerts.disableBatch({ feedIds: automationIds });
16493
16597
  }
16494
- const target = requireSingleAlertTarget(flags, "alert disable");
16495
- return target.kind === "automation" ? client.alerts.disableAutomation(target.target) : client.alerts.disablePlaybook(target.target);
16598
+ return client.alerts.disableAutomation(
16599
+ requireAutomationAlertTarget(flags, "alert disable")
16600
+ );
16496
16601
  }
16497
16602
  case "history": {
16498
- const target = requireSingleAlertTarget(flags, "alert history");
16603
+ rejectPlaybookAlertTarget(flags, "alert history");
16604
+ const target = requireAutomationAlertTarget(flags, "alert history");
16499
16605
  const params = {
16500
- username: target.target.username,
16501
- name: target.target.name,
16606
+ username: target.username,
16607
+ name: target.name,
16502
16608
  channel: flags["channel"],
16503
16609
  status: flags["status"],
16504
16610
  since_time: num(flags["since"]),
16505
16611
  first: num(flags["first"]),
16506
16612
  cursor: flags["cursor"]
16507
16613
  };
16508
- return target.kind === "automation" ? client.alerts.historyAutomation(params) : client.alerts.historyPlaybook(params);
16614
+ return client.alerts.historyAutomation(params);
16509
16615
  }
16510
16616
  case "preferences":
16511
16617
  return client.alerts.preferences();