@alva-ai/toolkit 0.15.0 → 0.16.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/dist/cli.js CHANGED
@@ -9480,6 +9480,9 @@ var init_lint2 = __esm({
9480
9480
  }
9481
9481
  });
9482
9482
 
9483
+ // src/cli/index.ts
9484
+ import * as crypto3 from "crypto";
9485
+
9483
9486
  // src/error.ts
9484
9487
  var AlvaError = class extends Error {
9485
9488
  code;
@@ -9879,6 +9882,19 @@ var FeedResource = class {
9879
9882
  this.client = client;
9880
9883
  }
9881
9884
  client;
9885
+ /**
9886
+ * List feeds owned by the caller. Backed by GET /api/v1/feed.
9887
+ */
9888
+ async list(params = {}) {
9889
+ this.client._requireAuth();
9890
+ return this.client._request("GET", "/api/v1/feed", {
9891
+ query: {
9892
+ limit: params.limit,
9893
+ cursor: params.cursor,
9894
+ status: params.status
9895
+ }
9896
+ });
9897
+ }
9882
9898
  /**
9883
9899
  * Stop a feed's producer cronjob. This pauses future scheduled runs while
9884
9900
  * preserving the feed and its existing data.
@@ -9922,6 +9938,29 @@ var FeedResource = class {
9922
9938
  `/api/v1/feed/${encodeURIComponent(String(id))}`
9923
9939
  );
9924
9940
  }
9941
+ /**
9942
+ * Publish or unpublish a feed. Backed by POST /api/v1/feed/:id/visibility.
9943
+ *
9944
+ * Setting visibility to 'public' publishes the feed (the backend sets
9945
+ * feeds.is_public and projects the ALFS public read grant in the same
9946
+ * transaction); 'private' unpublishes it. Prefer this over granting the
9947
+ * ALFS public read subject directly (e.g. `alva fs grant`), which bypasses
9948
+ * the is_public flag and causes drift.
9949
+ *
9950
+ * Auth: caller must own the feed (uid match), enforced by the backend.
9951
+ */
9952
+ async setVisibility(params) {
9953
+ this.client._requireAuth();
9954
+ const id = requireFeedID(params.id);
9955
+ if (params.visibility !== "public" && params.visibility !== "private") {
9956
+ throw new Error("visibility must be 'public' or 'private'");
9957
+ }
9958
+ return this.client._request(
9959
+ "POST",
9960
+ `/api/v1/feed/${encodeURIComponent(String(id))}/visibility`,
9961
+ { body: { visibility: params.visibility } }
9962
+ );
9963
+ }
9925
9964
  };
9926
9965
  function requireFeedID(id) {
9927
9966
  if (!Number.isInteger(id) || id <= 0) {
@@ -9930,6 +9969,46 @@ function requireFeedID(id) {
9930
9969
  return id;
9931
9970
  }
9932
9971
 
9972
+ // src/resources/automation.ts
9973
+ var AutomationResource = class {
9974
+ constructor(client) {
9975
+ this.client = client;
9976
+ }
9977
+ client;
9978
+ list(params = {}) {
9979
+ return this.client.feed.list(params);
9980
+ }
9981
+ /**
9982
+ * Inspect one automation. Backed by GET /api/v1/automation/:id.
9983
+ */
9984
+ async inspect(params) {
9985
+ this.client._requireAuth();
9986
+ const id = requireAutomationID(params.id);
9987
+ return this.client._request(
9988
+ "GET",
9989
+ `/api/v1/automation/${encodeURIComponent(String(id))}`
9990
+ );
9991
+ }
9992
+ stop(params) {
9993
+ return this.client.feed.stop(params);
9994
+ }
9995
+ resume(params) {
9996
+ return this.client.feed.resume(params);
9997
+ }
9998
+ delete(params) {
9999
+ return this.client.feed.delete(params);
10000
+ }
10001
+ publish(params) {
10002
+ return this.client.release.feed(params);
10003
+ }
10004
+ };
10005
+ function requireAutomationID(id) {
10006
+ if (!Number.isInteger(id) || id <= 0) {
10007
+ throw new Error("automation id must be a positive integer");
10008
+ }
10009
+ return id;
10010
+ }
10011
+
9933
10012
  // src/resources/playbooks.ts
9934
10013
  var PLAYBOOK_VISIBILITIES = [
9935
10014
  "public",
@@ -10182,16 +10261,6 @@ var SKILL_ENDPOINT_METADATA = [
10182
10261
  access: "free_and_pro",
10183
10262
  pro_required: false
10184
10263
  },
10185
- {
10186
- skill: "arrays-data-api-spot-market-price-and-volume",
10187
- file: "crypto-detail",
10188
- method: "GET",
10189
- path: "/api/v1/crypto/detail",
10190
- tier: "public",
10191
- required_subscription_tier: "free",
10192
- access: "free_and_pro",
10193
- pro_required: false
10194
- },
10195
10264
  {
10196
10265
  skill: "arrays-data-api-crypto-metrics-and-screener",
10197
10266
  file: "fear-greed-index",
@@ -10232,16 +10301,6 @@ var SKILL_ENDPOINT_METADATA = [
10232
10301
  access: "free_and_pro",
10233
10302
  pro_required: false
10234
10303
  },
10235
- {
10236
- skill: "arrays-data-api-crypto-metrics-and-screener",
10237
- file: "list",
10238
- method: "GET",
10239
- path: "/api/v1/crypto/list",
10240
- tier: "public",
10241
- required_subscription_tier: "free",
10242
- access: "free_and_pro",
10243
- pro_required: false
10244
- },
10245
10304
  {
10246
10305
  skill: "arrays-data-api-crypto-futures-data",
10247
10306
  file: "long-short-ratio",
@@ -10304,9 +10363,9 @@ var SKILL_ENDPOINT_METADATA = [
10304
10363
  },
10305
10364
  {
10306
10365
  skill: "arrays-data-api-crypto-metrics-and-screener",
10307
- file: "trading-pair",
10366
+ file: "crypto-detail",
10308
10367
  method: "GET",
10309
- path: "/api/v1/crypto/trading-pair",
10368
+ path: "/api/v1/crypto/detail",
10310
10369
  tier: "public",
10311
10370
  required_subscription_tier: "free",
10312
10371
  access: "free_and_pro",
@@ -10912,6 +10971,26 @@ var SKILL_ENDPOINT_METADATA = [
10912
10971
  access: "pro_only",
10913
10972
  pro_required: true
10914
10973
  },
10974
+ {
10975
+ skill: "arrays-data-api-options",
10976
+ file: "greeks",
10977
+ method: "GET",
10978
+ path: "/api/v1/options/greeks",
10979
+ tier: "alternative",
10980
+ required_subscription_tier: "pro",
10981
+ access: "pro_only",
10982
+ pro_required: true
10983
+ },
10984
+ {
10985
+ skill: "arrays-data-api-options",
10986
+ file: "chain",
10987
+ method: "GET",
10988
+ path: "/api/v1/options/chain",
10989
+ tier: "alternative",
10990
+ required_subscription_tier: "pro",
10991
+ access: "pro_only",
10992
+ pro_required: true
10993
+ },
10915
10994
  {
10916
10995
  skill: "arrays-data-api-equity-fundamentals",
10917
10996
  file: "company-executives",
@@ -11275,6 +11354,66 @@ var SKILL_ENDPOINT_METADATA = [
11275
11354
  required_subscription_tier: "free",
11276
11355
  access: "free_and_pro",
11277
11356
  pro_required: false
11357
+ },
11358
+ {
11359
+ skill: "arrays-data-api-semiconductor-price",
11360
+ file: "dram-spot-price",
11361
+ method: "GET",
11362
+ path: "/api/v1/other/semiconductor/dram-spot-price",
11363
+ tier: "alternative",
11364
+ required_subscription_tier: "pro",
11365
+ access: "pro_only",
11366
+ pro_required: true
11367
+ },
11368
+ {
11369
+ skill: "arrays-data-api-semiconductor-price",
11370
+ file: "dram-contract-price",
11371
+ method: "GET",
11372
+ path: "/api/v1/other/semiconductor/dram-contract-price",
11373
+ tier: "alternative",
11374
+ required_subscription_tier: "pro",
11375
+ access: "pro_only",
11376
+ pro_required: true
11377
+ },
11378
+ {
11379
+ skill: "arrays-data-api-semiconductor-price",
11380
+ file: "nand-flash-spot-price",
11381
+ method: "GET",
11382
+ path: "/api/v1/other/semiconductor/nand-flash-spot-price",
11383
+ tier: "alternative",
11384
+ required_subscription_tier: "pro",
11385
+ access: "pro_only",
11386
+ pro_required: true
11387
+ },
11388
+ {
11389
+ skill: "arrays-data-api-semiconductor-price",
11390
+ file: "nand-flash-contract-price",
11391
+ method: "GET",
11392
+ path: "/api/v1/other/semiconductor/nand-flash-contract-price",
11393
+ tier: "alternative",
11394
+ required_subscription_tier: "pro",
11395
+ access: "pro_only",
11396
+ pro_required: true
11397
+ },
11398
+ {
11399
+ skill: "arrays-data-api-semiconductor-price",
11400
+ file: "memory-card-price",
11401
+ method: "GET",
11402
+ path: "/api/v1/other/semiconductor/memory-card-price",
11403
+ tier: "alternative",
11404
+ required_subscription_tier: "pro",
11405
+ access: "pro_only",
11406
+ pro_required: true
11407
+ },
11408
+ {
11409
+ skill: "arrays-data-api-semiconductor-price",
11410
+ file: "dxi-index",
11411
+ method: "GET",
11412
+ path: "/api/v1/other/semiconductor/dxi-index",
11413
+ tier: "alternative",
11414
+ required_subscription_tier: "pro",
11415
+ access: "pro_only",
11416
+ pro_required: true
11278
11417
  }
11279
11418
  ];
11280
11419
  function getSkillEndpointMetadata(skill, file) {
@@ -11844,6 +11983,47 @@ var SubscriptionsResource = class {
11844
11983
  }
11845
11984
  };
11846
11985
 
11986
+ // src/resources/alerts.ts
11987
+ var AlertsResource = class {
11988
+ constructor(client) {
11989
+ this.client = client;
11990
+ }
11991
+ client;
11992
+ list(params = {}) {
11993
+ return this.client.subscriptions.list(params);
11994
+ }
11995
+ follows(params = {}) {
11996
+ return this.client.subscriptions.follows(params);
11997
+ }
11998
+ enableAutomation(params) {
11999
+ return this.client.subscriptions.subscribeFeed(params);
12000
+ }
12001
+ disableAutomation(params) {
12002
+ return this.client.subscriptions.unsubscribeFeed(params);
12003
+ }
12004
+ enablePlaybook(params) {
12005
+ return this.client.subscriptions.subscribePlaybook(params);
12006
+ }
12007
+ disablePlaybook(params) {
12008
+ return this.client.subscriptions.unsubscribePlaybook(params);
12009
+ }
12010
+ disableBatch(params) {
12011
+ return this.client.subscriptions.unsubscribeBatch(params);
12012
+ }
12013
+ historyAutomation(params) {
12014
+ return this.client.notifications.listFeed(params);
12015
+ }
12016
+ historyPlaybook(params) {
12017
+ return this.client.notifications.listPlaybook(params);
12018
+ }
12019
+ preferences() {
12020
+ return this.client.notificationPreferences.list();
12021
+ }
12022
+ updatePreference(params) {
12023
+ return this.client.notificationPreferences.update(params);
12024
+ }
12025
+ };
12026
+
11847
12027
  // src/resources/channelGroupSubscriptions.ts
11848
12028
  var ChannelGroupSubscriptionsResource = class {
11849
12029
  constructor(client) {
@@ -11882,6 +12062,24 @@ var ChannelGroupSubscriptionsResource = class {
11882
12062
  }
11883
12063
  );
11884
12064
  }
12065
+ /**
12066
+ * Read a group's buffered chat messages in a time window, for the group-chat
12067
+ * digest automation. Admin-gated: the authenticated caller must be that
12068
+ * group's Alva admin (a digest feed runs as that admin). Each message carries
12069
+ * a `permalink` deep-link back to the original message for "jump to original".
12070
+ * `from_micros`/`to_micros` are message-origin timestamps in microseconds.
12071
+ */
12072
+ async getGroupChatHistory(params) {
12073
+ this.client._requireAuth();
12074
+ return this.client._request("GET", "/api/v1/channel/group-history", {
12075
+ query: {
12076
+ channel: params.channel,
12077
+ remote_chat_id: params.remote_chat_id,
12078
+ from_micros: String(params.from_micros),
12079
+ to_micros: String(params.to_micros)
12080
+ }
12081
+ });
12082
+ }
11885
12083
  };
11886
12084
  function mutationBody(params) {
11887
12085
  return `{"session_id":${idLiteral(params.session_id)},"target_type":${JSON.stringify(params.target_type)},"target_id":${idLiteral(params.target_id)}}`;
@@ -12276,6 +12474,7 @@ var AlvaClient = class {
12276
12474
  _serviceAccount;
12277
12475
  _release;
12278
12476
  _feed;
12477
+ _automation;
12279
12478
  _playbooks;
12280
12479
  _secrets;
12281
12480
  _sdk;
@@ -12291,6 +12490,7 @@ var AlvaClient = class {
12291
12490
  _notifications;
12292
12491
  _notificationPreferences;
12293
12492
  _subscriptions;
12493
+ _alerts;
12294
12494
  _channelGroupSubscriptions;
12295
12495
  _feedback;
12296
12496
  _functions;
@@ -12325,6 +12525,9 @@ var AlvaClient = class {
12325
12525
  get feed() {
12326
12526
  return this._feed ??= new FeedResource(this);
12327
12527
  }
12528
+ get automation() {
12529
+ return this._automation ??= new AutomationResource(this);
12530
+ }
12328
12531
  get playbooks() {
12329
12532
  return this._playbooks ??= new PlaybooksResource(this);
12330
12533
  }
@@ -12370,6 +12573,9 @@ var AlvaClient = class {
12370
12573
  get subscriptions() {
12371
12574
  return this._subscriptions ??= new SubscriptionsResource(this);
12372
12575
  }
12576
+ get alerts() {
12577
+ return this._alerts ??= new AlertsResource(this);
12578
+ }
12373
12579
  get channelGroupSubscriptions() {
12374
12580
  return this._channelGroupSubscriptions ??= new ChannelGroupSubscriptionsResource(this);
12375
12581
  }
@@ -13361,12 +13567,90 @@ function discoveryItemLines(item, webOrigin) {
13361
13567
  return out;
13362
13568
  }
13363
13569
 
13570
+ // src/cli/productFormat.ts
13571
+ function formatAutomationList(result) {
13572
+ const automations = result.feeds ?? [];
13573
+ if (automations.length === 0) return "(no automations)\n";
13574
+ const lines = [`${automations.length} automation(s):`, ""];
13575
+ for (const automation of automations) {
13576
+ const status = automation.status ? ` [${automation.status}]` : "";
13577
+ lines.push(`\u2022 ${automation.name || "(unnamed)"}${status}`);
13578
+ lines.push(` id: ${automation.id}`);
13579
+ if (automation.cron_expression) {
13580
+ lines.push(` schedule: ${automation.cron_expression}`);
13581
+ }
13582
+ lines.push(` runs: ${automation.total_runs ?? 0}`);
13583
+ lines.push(` used by: ${automation.used_by_total ?? 0}`);
13584
+ lines.push("");
13585
+ }
13586
+ if (result.has_more) {
13587
+ lines.push("(more results \u2014 pass --cursor <next_cursor> to page)");
13588
+ if (result.next_cursor) lines.push(`next_cursor: ${result.next_cursor}`);
13589
+ lines.push("");
13590
+ }
13591
+ return lines.join("\n");
13592
+ }
13593
+ function formatAutomationDetail(result) {
13594
+ const status = result.status ? ` [${result.status}]` : "";
13595
+ const lines = [
13596
+ `${result.name || "(unnamed)"}${status}`,
13597
+ ` id: ${result.id}`
13598
+ ];
13599
+ if (result.feed_id && result.feed_id !== result.id) {
13600
+ lines.push(` feed id: ${result.feed_id}`);
13601
+ }
13602
+ if (result.cron_expression) {
13603
+ lines.push(` schedule: ${result.cron_expression}`);
13604
+ }
13605
+ lines.push(` runs: ${result.total_runs ?? 0}`);
13606
+ lines.push(` flow id: ${result.flow_id ?? "(none)"}`);
13607
+ lines.push(` flow config path: ${result.flow_config_path ?? "(none)"}`);
13608
+ return `${lines.join("\n")}
13609
+ `;
13610
+ }
13611
+ function formatAlertList(result) {
13612
+ const alerts = result.items ?? [];
13613
+ if (alerts.length === 0) return "(no alerts)\n";
13614
+ const lines = [`${alerts.length} alert(s):`, ""];
13615
+ for (const alert of alerts) {
13616
+ const targetType = alert.target?.type ?? "UNSPECIFIED";
13617
+ const status = alert.target_status ? ` [${alert.target_status}]` : "";
13618
+ lines.push(`\u2022 ${alertTitle(alert)}${status}`);
13619
+ lines.push(` target: ${targetType} ${alert.target?.id ?? ""}`.trimEnd());
13620
+ if (alert.kind) lines.push(` kind: ${alert.kind}`);
13621
+ if (alert.feed_status)
13622
+ lines.push(` automation status: ${alert.feed_status}`);
13623
+ if (alert.used_by_total !== void 0) {
13624
+ lines.push(` used by: ${alert.used_by_total}`);
13625
+ }
13626
+ if (alert.last_pushed_at_ms) {
13627
+ lines.push(
13628
+ ` last pushed: ${new Date(alert.last_pushed_at_ms).toISOString()}`
13629
+ );
13630
+ }
13631
+ lines.push("");
13632
+ }
13633
+ if (result.next_cursor) {
13634
+ lines.push("(more results \u2014 pass --cursor <next_cursor> to page)");
13635
+ lines.push(`next_cursor: ${result.next_cursor}`);
13636
+ lines.push("");
13637
+ }
13638
+ return lines.join("\n");
13639
+ }
13640
+ function alertTitle(alert) {
13641
+ if (alert.playbook) {
13642
+ return `${alert.playbook.owner_username}/${alert.playbook.name}`;
13643
+ }
13644
+ if (alert.feed_name) return alert.feed_name;
13645
+ return alert.target?.id ? `target ${alert.target.id}` : "(unknown target)";
13646
+ }
13647
+
13364
13648
  // src/cli/index.ts
13365
13649
  import * as fs2 from "fs";
13366
13650
  import * as os2 from "os";
13367
13651
  import * as fsPromises2 from "fs/promises";
13368
13652
  import { Agent, setGlobalDispatcher } from "undici";
13369
- var CLI_VERSION = true ? "0.15.0" : "dev";
13653
+ var CLI_VERSION = true ? "0.16.0" : "dev";
13370
13654
  var DEFAULT_RUN_TIMEOUT_MS = 6e5;
13371
13655
  var RUN_TIMEOUT_ENV = "ALVA_RUN_TIMEOUT_MS";
13372
13656
  var configuredRunFetchTimeoutMs;
@@ -13399,7 +13683,9 @@ Commands:
13399
13683
  service-account Restricted run-as identities (create, list, delete, grant, revoke)
13400
13684
  release Feed and playbook releases (feed, playbook-draft, playbook)
13401
13685
  lint Design-system lint (playbook)
13402
- feed Feed lifecycle management (delete)
13686
+ automation Automation management (list, inspect, publish, stop, resume, delete)
13687
+ alert Alert management (list, follows, enable, disable, history, preferences, enable-session-completed, disable-session-completed)
13688
+ feed Legacy automation alias (list, stop, resume, delete, set-visibility)
13403
13689
  playbooks Playbook discovery (trending, get, list) and visibility
13404
13690
  functions Playbook UDF function management (register, list, delete, invoke, allowance)
13405
13691
  credits Credit wallet and self-scoped usage history (wallet, items)
@@ -13411,11 +13697,12 @@ Commands:
13411
13697
  notification-history Notification delivery history (list-playbook, list-feed)
13412
13698
  notification-preferences Notification preferences (list, enable-session-completed, disable-session-completed)
13413
13699
  feedback Submit user-confirmed Alva platform feedback (submit)
13414
- subscriptions Follows + push alerts (subscribe-playbook, unsubscribe-playbook, subscribe-feed, unsubscribe-feed, unsubscribe, list, follows)
13700
+ subscriptions Legacy alert/follow operations (subscribe-playbook, subscribe-feed, list, follows)
13415
13701
  channel Channel group operations (group-subscriptions context, list, subscribe, unsubscribe)
13416
13702
  remix Save playbook remix lineage
13417
13703
  portfolio Connected-account portfolio (accounts, summary, activities)
13418
13704
  trading Trading operations (accounts, portfolio, orders, subscriptions, equity-history, risk-rules, subscribe, unsubscribe, execute, update-risk-rules)
13705
+ broker Agentic order execution \u2014 venue-native passthrough to trex (accounts, quote, order, balance, positions, ...; run 'alva broker describe')
13419
13706
  auth Authentication (login)
13420
13707
  screenshot Capture a web screenshot as PNG
13421
13708
  arrays Arrays backend operations (token ensure, token status)
@@ -13759,29 +14046,134 @@ Examples:
13759
14046
  --cron "0 */4 * * *" --run-as-service-account 90123
13760
14047
  alva service-account revoke --id 90123 --path '~/feeds/x/v1/' --permission read
13761
14048
  alva service-account delete --id 90123`,
14049
+ automation: `Usage: alva automation <subcommand> [options]
14050
+
14051
+ Manage automations. This is the product-facing surface for what older CLI
14052
+ commands called "feeds"; ids are currently the same underlying feed ids.
14053
+
14054
+ Subcommands:
14055
+ list List automations owned by the caller
14056
+ inspect Inspect one automation and show its flow config path when available
14057
+ publish Publish/register an automation after deploying its cronjob
14058
+ stop Stop an automation's producer cronjob
14059
+ resume Resume a stopped automation's producer cronjob
14060
+ delete Soft-delete an automation
14061
+
14062
+ List flags:
14063
+ --limit <n> Max results per page (default 50, max 100 server-side)
14064
+ --cursor <token> Pagination cursor from previous response
14065
+ --status <s> active | paused | all (default: active)
14066
+ --json Print raw JSON instead of a human-readable summary
14067
+
14068
+ Publish flags:
14069
+ --name <name> Automation name, unique per user (required)
14070
+ --version <version> Semantic version, e.g. "1.0.0" (required)
14071
+ --cronjob-id <id> ID of the backing cronjob (required)
14072
+ --view-json <json> View configuration JSON
14073
+ --description <text> Automation description
14074
+ --changelog <text> Per-major changelog summary
14075
+ --agent-type <type> Agent kind that produces this automation, e.g. "alpi"
14076
+
14077
+ Lifecycle flags:
14078
+ --id <automation_id> Numeric automation id (required for inspect/stop/resume/delete)
14079
+
14080
+ Examples:
14081
+ alva automation list
14082
+ alva automation list --status all --limit 20
14083
+ alva automation inspect --id 42
14084
+ alva automation publish --name btc-ema --version 1.0.0 --cronjob-id 42
14085
+ alva automation stop --id 42
14086
+ alva automation resume --id 42
14087
+ alva automation delete --id 42`,
14088
+ alert: `Usage: alva alert <subcommand> [options]
14089
+
14090
+ Manage alerts. Alerts are personal notification opt-ins for automations or
14091
+ playbooks. Delivery history and global alert preferences live here too.
14092
+
14093
+ Subcommands:
14094
+ list List the caller's active alerts
14095
+ follows List the playbooks the caller follows
14096
+ enable Enable an alert for an automation or playbook
14097
+ disable Disable alerts by automation/playbook name or id
14098
+ history List alert delivery history for an automation or playbook
14099
+ preferences List global alert preferences
14100
+ enable-session-completed
14101
+ disable-session-completed
14102
+
14103
+ Target flags:
14104
+ --automation <owner/name> Automation target
14105
+ --playbook <owner/name> Playbook target
14106
+
14107
+ Disable-by-id flags:
14108
+ --automation-ids <a,b> Comma-separated automation target ids
14109
+ --playbook-ids <a,b> Comma-separated playbook target ids
14110
+ --feed-ids <a,b> Legacy alias for --automation-ids
14111
+
14112
+ List flags:
14113
+ --first <n> Optional page size
14114
+ --cursor <token> Optional cursor from previous response
14115
+ --json Print raw JSON instead of a human-readable summary
14116
+
14117
+ Follows flags:
14118
+ --limit <n> Optional page size
14119
+ --cursor <token> Optional cursor from previous response
14120
+
14121
+ History flags:
14122
+ --channel <name> Optional delivery channel filter
14123
+ --status <status> Optional status filter (sent, failed, filtered)
14124
+ --since <seconds> Optional Unix seconds lower bound
14125
+
14126
+ Examples:
14127
+ alva alert list
14128
+ alva alert follows --limit 20
14129
+ alva alert enable --automation alice/btc-ema
14130
+ alva alert disable --automation alice/btc-ema
14131
+ alva alert enable --playbook alice/btc-dashboard
14132
+ alva alert disable --automation-ids 13292
14133
+ alva alert disable --feed-ids 13292
14134
+ alva alert history --automation alice/btc-ema --status sent
14135
+ alva alert preferences`,
13762
14136
  feed: `Usage: alva feed <subcommand> [options]
13763
14137
 
13764
- Feed lifecycle management.
14138
+ Legacy alias for automation lifecycle management. Prefer "alva automation".
13765
14139
 
13766
14140
  Subcommands:
13767
- stop Stop a feed's producer cronjob
13768
- resume Resume a stopped feed's producer cronjob
13769
- delete Soft-delete a feed and all its active majors
14141
+ list List feeds owned by the caller
14142
+ stop Stop a feed's producer cronjob
14143
+ resume Resume a stopped feed's producer cronjob
14144
+ delete Soft-delete a feed and all its active majors
14145
+ set-visibility Publish or unpublish a feed (--visibility public|private)
13770
14146
 
13771
14147
  Flags:
13772
- --id <feed_id> Numeric feed id (required, positive integer)
14148
+ --id <feed_id> Numeric feed id (required for stop/resume/delete/set-visibility)
14149
+ --visibility <level> public | private (required for set-visibility)
14150
+
14151
+ List flags:
14152
+ --limit <n> Max results per page (default 50, max 100 server-side)
14153
+ --cursor <token> Pagination cursor from previous response
14154
+ --status <s> active | paused | all (default: active)
13773
14155
 
13774
14156
  Notes:
14157
+ - list returns the raw JSON envelope. Prefer "alva automation list" for
14158
+ human-readable output or "alva automation list --json" for explicit JSON.
13775
14159
  - stop/resume affect future scheduled runs; existing feed data remains.
13776
14160
  - delete cascades to all active feed_majors in the same DB transaction.
13777
14161
  - delete removes producer cronjobs best-effort; the cronjob scavenger
13778
14162
  reconciles any leftover rows on its next sweep.
14163
+ - set-visibility publishes (public) or unpublishes (private) a feed; the
14164
+ backend sets feeds.is_public and projects the ALFS public read grant
14165
+ together. Prefer this over "alva fs grant" on the feed path, which causes
14166
+ drift.
13779
14167
  - Auth: caller must own the feed (uid match), enforced by the backend.
13780
14168
 
13781
14169
  Examples:
14170
+ alva feed list
14171
+ alva feed list --status all --limit 20
13782
14172
  alva feed stop --id 42
13783
14173
  alva feed resume --id 42
13784
- alva feed delete --id 42`,
14174
+ alva feed delete --id 42
14175
+ alva feed set-visibility --id 42 --visibility public
14176
+ alva feed set-visibility --id 42 --visibility private`,
13785
14177
  playbooks: `Usage: alva playbooks <subcommand> [options]
13786
14178
 
13787
14179
  Find and resolve playbooks with an agent-friendly response shape.
@@ -14654,6 +15046,48 @@ function csvList(val) {
14654
15046
  const values = val.split(",").map((item) => item.trim()).filter(Boolean);
14655
15047
  return values.length > 0 ? values : void 0;
14656
15048
  }
15049
+ function parseOwnerNameTarget(value, flag, command) {
15050
+ const [username, ...rest] = value.split("/");
15051
+ const name = rest.join("/");
15052
+ if (!username || !name || name.includes("/")) {
15053
+ throw new CliUsageError(
15054
+ `--${flag} must be in owner/name form for '${command}', got '${value}'`,
15055
+ command.split(" ")[0]
15056
+ );
15057
+ }
15058
+ return { username, name };
15059
+ }
15060
+ function requireSingleAlertTarget(flags, command) {
15061
+ const automation = flags["automation"];
15062
+ const playbook = flags["playbook"];
15063
+ if ((automation ? 1 : 0) + (playbook ? 1 : 0) !== 1) {
15064
+ throw new CliUsageError(
15065
+ `Provide exactly one of --automation or --playbook for '${command}'`,
15066
+ "alert"
15067
+ );
15068
+ }
15069
+ if (automation) {
15070
+ return {
15071
+ kind: "automation",
15072
+ target: parseOwnerNameTarget(automation, "automation", command)
15073
+ };
15074
+ }
15075
+ return {
15076
+ kind: "playbook",
15077
+ target: parseOwnerNameTarget(playbook, "playbook", command)
15078
+ };
15079
+ }
15080
+ function feedReleaseParams(flags, command) {
15081
+ return {
15082
+ name: requireFlag(flags, "name", command),
15083
+ version: requireFlag(flags, "version", command),
15084
+ cronjob_id: requireNumericFlag(flags, "cronjob-id", command),
15085
+ view_json: jsonParse(flags["view-json"]),
15086
+ description: flags["description"],
15087
+ changelog: flags["changelog"],
15088
+ agent_type: flags["agent-type"]
15089
+ };
15090
+ }
14657
15091
  function trendingPlaybooksSort(val) {
14658
15092
  if (val === void 0) return void 0;
14659
15093
  const normalized = val.trim().toUpperCase();
@@ -14673,6 +15107,16 @@ function playbookVisibility(val) {
14673
15107
  "playbooks"
14674
15108
  );
14675
15109
  }
15110
+ function feedVisibility(val) {
15111
+ const normalized = val.trim().toLowerCase();
15112
+ if (normalized === "public" || normalized === "private") {
15113
+ return normalized;
15114
+ }
15115
+ throw new CliUsageError(
15116
+ `--visibility must be one of public, private for 'feed set-visibility', got '${val}'`,
15117
+ "feed"
15118
+ );
15119
+ }
14676
15120
  function parseCreditsTimestamp(value, flag, command) {
14677
15121
  const trimmed = value.trim();
14678
15122
  if (/^\d+$/.test(trimmed)) {
@@ -14857,6 +15301,54 @@ function writeLocalFileBytes(path, data, command, flag, deps) {
14857
15301
  assertLocalFileAvailable(command, flag, deps);
14858
15302
  fs2.writeFileSync(path, data);
14859
15303
  }
15304
+ async function readAllStdin() {
15305
+ const chunks = [];
15306
+ for await (const chunk of process.stdin) {
15307
+ chunks.push(chunk);
15308
+ }
15309
+ return Buffer.concat(chunks).toString("utf8");
15310
+ }
15311
+ async function handleBroker(client, brokerArgv, deps) {
15312
+ let argv = brokerArgv;
15313
+ const isOrderPlace = brokerArgv[0] === "order" && brokerArgv[1] === "place";
15314
+ const hasFlag = (name) => brokerArgv.some((a) => a === name || a.startsWith(`${name}=`));
15315
+ const hasHandle = hasFlag("--intent-id") || hasFlag("--client-order-id");
15316
+ const isDryRun = hasFlag("--dry-run");
15317
+ if (isOrderPlace && !hasHandle && !isDryRun) {
15318
+ const intentId = crypto3.randomUUID();
15319
+ process.stderr.write(`alva broker: intent-id ${intentId}
15320
+ `);
15321
+ argv = [...brokerArgv, "--intent-id", intentId];
15322
+ }
15323
+ let stdin;
15324
+ if (hasFlag("--stdin")) {
15325
+ stdin = await readAllStdin();
15326
+ }
15327
+ let envelope;
15328
+ let exit = 2;
15329
+ try {
15330
+ const resp = await client._request("POST", "/api/v1/broker/invoke", {
15331
+ body: { argv, stdin }
15332
+ });
15333
+ envelope = resp.envelope;
15334
+ exit = resp.exit ?? 2;
15335
+ } catch (e) {
15336
+ const message = e instanceof Error ? e.message : String(e);
15337
+ envelope = {
15338
+ schemaVersion: 2,
15339
+ status: "error",
15340
+ reason: { code: "network", message }
15341
+ };
15342
+ exit = 2;
15343
+ }
15344
+ if (deps?.mode === "jagent") {
15345
+ return envelope;
15346
+ }
15347
+ await new Promise((resolve) => {
15348
+ process.stdout.write(JSON.stringify(envelope) + "\n", () => resolve());
15349
+ });
15350
+ process.exit(exit);
15351
+ }
14860
15352
  async function dispatch(client, args, meta, deps) {
14861
15353
  const group = args[0];
14862
15354
  if (!group || group === "--help" || group === "-h") {
@@ -14891,6 +15383,9 @@ async function dispatch(client, args, meta, deps) {
14891
15383
  }
14892
15384
  return result;
14893
15385
  }
15386
+ if (group === "broker") {
15387
+ return handleBroker(client, args.slice(1), deps);
15388
+ }
14894
15389
  const subcommand = args[1];
14895
15390
  const flags = parseFlags2(
14896
15391
  args.slice(
@@ -15160,6 +15655,12 @@ async function dispatch(client, args, meta, deps) {
15160
15655
  if (!subcommand)
15161
15656
  throw new CliUsageError("Missing subcommand for feed", "feed");
15162
15657
  switch (subcommand) {
15658
+ case "list":
15659
+ return client.feed.list({
15660
+ limit: num(flags["limit"]),
15661
+ cursor: flags["cursor"],
15662
+ status: flags["status"]
15663
+ });
15163
15664
  case "stop":
15164
15665
  return client.feed.stop({
15165
15666
  id: requireNumericFlag(flags, "id", "feed stop")
@@ -15172,6 +15673,13 @@ async function dispatch(client, args, meta, deps) {
15172
15673
  return client.feed.delete({
15173
15674
  id: requireNumericFlag(flags, "id", "feed delete")
15174
15675
  });
15676
+ case "set-visibility":
15677
+ return client.feed.setVisibility({
15678
+ id: requireNumericFlag(flags, "id", "feed set-visibility"),
15679
+ visibility: feedVisibility(
15680
+ requireFlag(flags, "visibility", "feed set-visibility")
15681
+ )
15682
+ });
15175
15683
  default:
15176
15684
  throw new CliUsageError(
15177
15685
  `Unknown subcommand: feed ${subcommand}`,
@@ -15179,6 +15687,50 @@ async function dispatch(client, args, meta, deps) {
15179
15687
  );
15180
15688
  }
15181
15689
  }
15690
+ case "automation": {
15691
+ if (!subcommand)
15692
+ throw new CliUsageError(
15693
+ "Missing subcommand for automation",
15694
+ "automation"
15695
+ );
15696
+ switch (subcommand) {
15697
+ case "list": {
15698
+ const result = await client.automation.list({
15699
+ limit: num(flags["limit"]),
15700
+ cursor: flags["cursor"],
15701
+ status: flags["status"]
15702
+ });
15703
+ return boolFlag(flags["json"]) ? result : formatAutomationList(result);
15704
+ }
15705
+ case "inspect": {
15706
+ const result = await client.automation.inspect({
15707
+ id: requireNumericFlag(flags, "id", "automation inspect")
15708
+ });
15709
+ return boolFlag(flags["json"]) ? result : formatAutomationDetail(result);
15710
+ }
15711
+ case "publish":
15712
+ return client.automation.publish(
15713
+ feedReleaseParams(flags, "automation publish")
15714
+ );
15715
+ case "stop":
15716
+ return client.automation.stop({
15717
+ id: requireNumericFlag(flags, "id", "automation stop")
15718
+ });
15719
+ case "resume":
15720
+ return client.automation.resume({
15721
+ id: requireNumericFlag(flags, "id", "automation resume")
15722
+ });
15723
+ case "delete":
15724
+ return client.automation.delete({
15725
+ id: requireNumericFlag(flags, "id", "automation delete")
15726
+ });
15727
+ default:
15728
+ throw new CliUsageError(
15729
+ `Unknown subcommand: automation ${subcommand}`,
15730
+ "automation"
15731
+ );
15732
+ }
15733
+ }
15182
15734
  case "credits": {
15183
15735
  if (!subcommand)
15184
15736
  throw new CliUsageError("Missing subcommand for credits", "credits");
@@ -15379,15 +15931,7 @@ async function dispatch(client, args, meta, deps) {
15379
15931
  throw new CliUsageError("Missing subcommand for release", "release");
15380
15932
  switch (subcommand) {
15381
15933
  case "feed":
15382
- return client.release.feed({
15383
- name: requireFlag(flags, "name", "release feed"),
15384
- version: requireFlag(flags, "version", "release feed"),
15385
- cronjob_id: requireNumericFlag(flags, "cronjob-id", "release feed"),
15386
- view_json: jsonParse(flags["view-json"]),
15387
- description: flags["description"],
15388
- changelog: flags["changelog"],
15389
- agent_type: flags["agent-type"]
15390
- });
15934
+ return client.release.feed(feedReleaseParams(flags, "release feed"));
15391
15935
  case "playbook-draft":
15392
15936
  return client.release.playbookDraft({
15393
15937
  name: requireFlag(flags, "name", "release playbook-draft"),
@@ -15826,6 +16370,70 @@ async function dispatch(client, args, meta, deps) {
15826
16370
  );
15827
16371
  }
15828
16372
  }
16373
+ case "alert": {
16374
+ if (!subcommand)
16375
+ throw new CliUsageError("Missing subcommand for alert", "alert");
16376
+ switch (subcommand) {
16377
+ case "list": {
16378
+ const result = await client.alerts.list({
16379
+ first: num(flags["first"]),
16380
+ cursor: flags["cursor"]
16381
+ });
16382
+ return boolFlag(flags["json"]) ? result : formatAlertList(result);
16383
+ }
16384
+ case "follows":
16385
+ return client.alerts.follows({
16386
+ limit: num(flags["limit"]),
16387
+ cursor: flags["cursor"]
16388
+ });
16389
+ case "enable": {
16390
+ const target = requireSingleAlertTarget(flags, "alert enable");
16391
+ return target.kind === "automation" ? client.alerts.enableAutomation(target.target) : client.alerts.enablePlaybook(target.target);
16392
+ }
16393
+ case "disable": {
16394
+ const automationIds = csvList(flags["automation-ids"]) ?? csvList(flags["feed-ids"]) ?? [];
16395
+ const playbookIds = csvList(flags["playbook-ids"]) ?? [];
16396
+ if (automationIds.length > 0 || playbookIds.length > 0) {
16397
+ return client.alerts.disableBatch({
16398
+ playbookIds,
16399
+ feedIds: automationIds
16400
+ });
16401
+ }
16402
+ const target = requireSingleAlertTarget(flags, "alert disable");
16403
+ return target.kind === "automation" ? client.alerts.disableAutomation(target.target) : client.alerts.disablePlaybook(target.target);
16404
+ }
16405
+ case "history": {
16406
+ const target = requireSingleAlertTarget(flags, "alert history");
16407
+ const params = {
16408
+ username: target.target.username,
16409
+ name: target.target.name,
16410
+ channel: flags["channel"],
16411
+ status: flags["status"],
16412
+ since_time: num(flags["since"]),
16413
+ first: num(flags["first"]),
16414
+ cursor: flags["cursor"]
16415
+ };
16416
+ return target.kind === "automation" ? client.alerts.historyAutomation(params) : client.alerts.historyPlaybook(params);
16417
+ }
16418
+ case "preferences":
16419
+ return client.alerts.preferences();
16420
+ case "enable-session-completed":
16421
+ return client.alerts.updatePreference({
16422
+ key: "session_completed",
16423
+ enabled: true
16424
+ });
16425
+ case "disable-session-completed":
16426
+ return client.alerts.updatePreference({
16427
+ key: "session_completed",
16428
+ enabled: false
16429
+ });
16430
+ default:
16431
+ throw new CliUsageError(
16432
+ `Unknown subcommand: alert ${subcommand}`,
16433
+ "alert"
16434
+ );
16435
+ }
16436
+ }
15829
16437
  case "channel": {
15830
16438
  if (!subcommand || subcommand === "--help" || subcommand === "-h") {
15831
16439
  return { _help: true, text: COMMAND_HELP.channel };
@@ -16173,6 +16781,10 @@ function stripGlobalFlags(argv) {
16173
16781
  const result = [];
16174
16782
  for (let i = 0; i < argv.length; i++) {
16175
16783
  const a = argv[i];
16784
+ if (a === "broker") {
16785
+ result.push(...argv.slice(i));
16786
+ break;
16787
+ }
16176
16788
  if (GLOBAL_FLAGS.includes(a)) {
16177
16789
  i++;
16178
16790
  continue;