@alva-ai/toolkit 0.9.4 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -9730,6 +9730,11 @@ var FeedResource = class {
9730
9730
  };
9731
9731
 
9732
9732
  // src/resources/playbooks.ts
9733
+ var PLAYBOOK_VISIBILITIES = [
9734
+ "public",
9735
+ "private",
9736
+ "paid"
9737
+ ];
9733
9738
  var PlaybooksResource = class {
9734
9739
  constructor(client) {
9735
9740
  this.client = client;
@@ -9763,6 +9768,30 @@ var PlaybooksResource = class {
9763
9768
  has_next: raw.has_next ?? false
9764
9769
  };
9765
9770
  }
9771
+ /**
9772
+ * Set a playbook's visibility. Requires authentication; the owner is
9773
+ * resolved server-side from the authenticated user, so only the playbook
9774
+ * `name` is needed.
9775
+ *
9776
+ * Note: `private` and `paid` are paid-tier capabilities. A free-tier user
9777
+ * receives a `PERMISSION_DENIED` error from the gateway, which is surfaced
9778
+ * here unchanged.
9779
+ */
9780
+ async setVisibility(params) {
9781
+ if (!PLAYBOOK_VISIBILITIES.includes(params.visibility)) {
9782
+ throw new AlvaError(
9783
+ "INVALID_ARGUMENT",
9784
+ `Invalid visibility "${params.visibility}". Expected one of: ${PLAYBOOK_VISIBILITIES.join(", ")}.`,
9785
+ 400
9786
+ );
9787
+ }
9788
+ this.client._requireAuth();
9789
+ return await this.client._request(
9790
+ "POST",
9791
+ `/api/v1/playbook/${encodeURIComponent(params.name)}/visibility`,
9792
+ { body: { visibility: params.visibility } }
9793
+ );
9794
+ }
9766
9795
  };
9767
9796
  function toAgentPlaybook(raw) {
9768
9797
  const username = raw.creator?.name ?? "";
@@ -11030,6 +11059,17 @@ function metadataSummaryForSkill(skill) {
11030
11059
  }
11031
11060
 
11032
11061
  // src/resources/playbookSkills.ts
11062
+ function normalizePlaybookSkillSummary(raw) {
11063
+ return {
11064
+ username: raw.username,
11065
+ name: raw.name,
11066
+ display_name: raw.display_name,
11067
+ description: raw.description,
11068
+ tags: raw.tags,
11069
+ creator_uid: raw.creator_uid,
11070
+ updated_at: raw.updated_at
11071
+ };
11072
+ }
11033
11073
  function parsePlaybookSkillId(s) {
11034
11074
  const parts = s.split("/");
11035
11075
  if (parts.length !== 2 || !parts[0] || !parts[1]) {
@@ -11053,7 +11093,7 @@ var PlaybookSkillsResource = class {
11053
11093
  const res = await this.client._request("GET", "/api/v1/skills", {
11054
11094
  query
11055
11095
  });
11056
- return { skills: res.data ?? [] };
11096
+ return { skills: (res.data ?? []).map(normalizePlaybookSkillSummary) };
11057
11097
  }
11058
11098
  async tags() {
11059
11099
  const res = await this.client._request(
@@ -11078,7 +11118,10 @@ var PlaybookSkillsResource = class {
11078
11118
  0
11079
11119
  );
11080
11120
  }
11081
- return meta;
11121
+ return {
11122
+ ...normalizePlaybookSkillSummary(meta),
11123
+ files: meta.files ?? []
11124
+ };
11082
11125
  }
11083
11126
  async file(id, path) {
11084
11127
  const { username, name } = parsePlaybookSkillId(id);
@@ -11389,66 +11432,56 @@ var NotificationPreferencesResource = class {
11389
11432
  }
11390
11433
  };
11391
11434
 
11392
- // src/resources/pushSubscriptions.ts
11393
- var PushSubscriptionsResource = class {
11435
+ // src/resources/subscriptions.ts
11436
+ var SubscriptionsResource = class {
11394
11437
  constructor(client) {
11395
11438
  this.client = client;
11396
11439
  }
11397
11440
  client;
11398
11441
  /**
11399
- * Opt into personal push for one playbook `(username, name)`.
11400
- * Fires for any feed of that playbook. Idempotent. Auth: callers must
11401
- * be able to read the playbook (public/paid pass; private requires
11402
- * explicit alfs grant).
11442
+ * Subscribe to a playbook `(username, name)`: follow it and enable alerts
11443
+ * on all its push-enabled automations. Idempotent. Auth: the caller must be
11444
+ * able to read the playbook — public passes; paid requires an active unlock;
11445
+ * private requires owner/admin.
11403
11446
  */
11404
11447
  async subscribePlaybook(params) {
11405
11448
  this.client._requireAuth();
11406
- const path = `/api/v1/push-subscriptions/playbook/${encodeURIComponent(params.username)}/${encodeURIComponent(params.name)}`;
11449
+ const path = `/api/v1/subscriptions/playbook/${encodeURIComponent(params.username)}/${encodeURIComponent(params.name)}`;
11407
11450
  return this.client._request(
11408
11451
  "POST",
11409
11452
  path
11410
11453
  );
11411
11454
  }
11412
11455
  /**
11413
- * Soft-disable personal push for one playbook `(username, name)`.
11414
- * Does NOT remove any social follow. Idempotent.
11456
+ * Unsubscribe from a playbook `(username, name)`: unfollow it and disable
11457
+ * all of its push alerts for the caller. Idempotent.
11415
11458
  */
11416
11459
  async unsubscribePlaybook(params) {
11417
11460
  this.client._requireAuth();
11418
- const path = `/api/v1/push-subscriptions/playbook/${encodeURIComponent(params.username)}/${encodeURIComponent(params.name)}`;
11419
- return this.client._request(
11420
- "DELETE",
11421
- path
11422
- );
11461
+ const path = `/api/v1/subscriptions/playbook/${encodeURIComponent(params.username)}/${encodeURIComponent(params.name)}`;
11462
+ return this.client._request("DELETE", path);
11423
11463
  }
11424
11464
  /**
11425
- * Opt into personal push for one feed `(username, name)`. Fires for
11426
- * that specific feed regardless of which playbook(s) consume it; if
11427
- * the feed is shared across playbooks the subscriber receives one
11428
- * push per playbook context. Idempotent.
11465
+ * Subscribe to one feed `(username, name)` — enable personal push for that
11466
+ * single automation's alerts, regardless of which playbook(s) consume it.
11467
+ * Does NOT follow any playbook. Idempotent.
11429
11468
  */
11430
11469
  async subscribeFeed(params) {
11431
11470
  this.client._requireAuth();
11432
- const path = `/api/v1/push-subscriptions/feed/${encodeURIComponent(params.username)}/${encodeURIComponent(params.name)}`;
11433
- return this.client._request(
11434
- "POST",
11435
- path
11436
- );
11471
+ const path = `/api/v1/subscriptions/feed/${encodeURIComponent(params.username)}/${encodeURIComponent(params.name)}`;
11472
+ return this.client._request("POST", path);
11437
11473
  }
11438
11474
  /**
11439
- * Soft-disable personal push for one feed `(username, name)`.
11440
- * Idempotent.
11475
+ * Unsubscribe from one feed `(username, name)` — disable that automation's
11476
+ * alerts for the caller. Idempotent.
11441
11477
  */
11442
11478
  async unsubscribeFeed(params) {
11443
11479
  this.client._requireAuth();
11444
- const path = `/api/v1/push-subscriptions/feed/${encodeURIComponent(params.username)}/${encodeURIComponent(params.name)}`;
11445
- return this.client._request(
11446
- "DELETE",
11447
- path
11448
- );
11480
+ const path = `/api/v1/subscriptions/feed/${encodeURIComponent(params.username)}/${encodeURIComponent(params.name)}`;
11481
+ return this.client._request("DELETE", path);
11449
11482
  }
11450
11483
  /**
11451
- * List the caller's currently active personal push subscriptions.
11484
+ * List the caller's currently active subscriptions.
11452
11485
  * Results are cursor-paginated.
11453
11486
  */
11454
11487
  async list(params = {}) {
@@ -11458,7 +11491,7 @@ var PushSubscriptionsResource = class {
11458
11491
  query.first = String(params.first);
11459
11492
  }
11460
11493
  if (params.cursor) query.cursor = params.cursor;
11461
- return this.client._request("GET", "/api/v1/me/push-subscriptions", {
11494
+ return this.client._request("GET", "/api/v1/me/subscriptions", {
11462
11495
  query
11463
11496
  });
11464
11497
  }
@@ -11558,7 +11591,7 @@ var AlvaClient = class {
11558
11591
  _arraysJwt;
11559
11592
  _notifications;
11560
11593
  _notificationPreferences;
11561
- _pushSubscriptions;
11594
+ _subscriptions;
11562
11595
  _channelGroupSubscriptions;
11563
11596
  constructor(config) {
11564
11597
  this.baseUrl = config.baseUrl ?? DEFAULT_BASE_URL;
@@ -11627,8 +11660,8 @@ var AlvaClient = class {
11627
11660
  get notificationPreferences() {
11628
11661
  return this._notificationPreferences ??= new NotificationPreferencesResource(this);
11629
11662
  }
11630
- get pushSubscriptions() {
11631
- return this._pushSubscriptions ??= new PushSubscriptionsResource(this);
11663
+ get subscriptions() {
11664
+ return this._subscriptions ??= new SubscriptionsResource(this);
11632
11665
  }
11633
11666
  get channelGroupSubscriptions() {
11634
11667
  return this._channelGroupSubscriptions ??= new ChannelGroupSubscriptionsResource(this);
@@ -12486,7 +12519,7 @@ function formatPlaybookSkillFile(file) {
12486
12519
  import * as fs2 from "fs";
12487
12520
  import * as os2 from "os";
12488
12521
  import * as fsPromises2 from "fs/promises";
12489
- var CLI_VERSION = true ? "0.9.4" : "dev";
12522
+ var CLI_VERSION = true ? "0.11.0" : "dev";
12490
12523
  function isVersionOlderThan(a, b) {
12491
12524
  const parse4 = (v) => {
12492
12525
  if (!v) return null;
@@ -12516,7 +12549,7 @@ Commands:
12516
12549
  release Feed and playbook releases (feed, playbook-draft, playbook)
12517
12550
  lint Design-system lint (playbook)
12518
12551
  feed Feed lifecycle management (delete)
12519
- playbooks Playbook discovery (trending)
12552
+ playbooks Playbook discovery (trending) and visibility
12520
12553
  secrets Secret management (create, list, get, update, delete)
12521
12554
  sdk SDK documentation (doc, partitions, partition-summary)
12522
12555
  skillhub Playbook skills (list, tags, get, file)
@@ -12524,7 +12557,7 @@ Commands:
12524
12557
  comments Playbook comments (create, pin, unpin)
12525
12558
  notification-history Notification delivery history (list-playbook, list-feed)
12526
12559
  notification-preferences Notification preferences (list, enable-session-completed, disable-session-completed)
12527
- push-subscriptions Personal push opt-in (subscribe-playbook, unsubscribe-playbook, subscribe-feed, unsubscribe-feed, list)
12560
+ subscriptions Subscribe to playbooks/feeds (subscribe-playbook, unsubscribe-playbook, subscribe-feed, unsubscribe-feed, list)
12528
12561
  channel Channel group operations (group-subscriptions context, list, subscribe, unsubscribe)
12529
12562
  remix Save playbook remix lineage
12530
12563
  portfolio Connected-account portfolio (accounts, summary, activities)
@@ -12838,7 +12871,8 @@ Examples:
12838
12871
  Find public playbooks with an agent-friendly response shape.
12839
12872
 
12840
12873
  Subcommands:
12841
- trending List trending playbooks
12874
+ trending List trending playbooks
12875
+ set-visibility Set a playbook's visibility (requires auth)
12842
12876
 
12843
12877
  Trending flags:
12844
12878
  --keyword <text> Search text
@@ -12849,6 +12883,10 @@ Trending flags:
12849
12883
  --cursor <cursor> Pagination cursor from previous response
12850
12884
  --current <cursor> Backward-compatible cursor alias
12851
12885
 
12886
+ Set-visibility flags:
12887
+ --name <name> Playbook name (required; owner derived from auth)
12888
+ --visibility <v> public, private, or paid (required, case-insensitive)
12889
+
12852
12890
  Response fields:
12853
12891
  playbooks[].ref "username/name" identifier for agents
12854
12892
  playbooks[].url_path Web path: /username/playbooks/name
@@ -12857,10 +12895,17 @@ Response fields:
12857
12895
  playbooks[].follow_count Social proof signal
12858
12896
  playbooks[].cursor Cursor for pagination
12859
12897
  has_next Whether another page exists
12898
+ playbook_path "<owner>/<name>" echoed by set-visibility
12899
+
12900
+ Notes:
12901
+ private and paid are paid-tier features; free-tier accounts get a
12902
+ PERMISSION_DENIED error from the gateway.
12860
12903
 
12861
12904
  Examples:
12862
12905
  alva playbooks trending --keyword scanner --tags macro,ai --sort recent --limit 5
12863
- alva playbooks trending --tag btc --cursor abc`,
12906
+ alva playbooks trending --tag btc --cursor abc
12907
+ alva playbooks set-visibility --name my-scanner --visibility private
12908
+ alva playbooks set-visibility --name my-scanner --visibility public`,
12864
12909
  release: `Usage: alva release <subcommand> [options]
12865
12910
 
12866
12911
  Publish feeds and playbooks to the Alva platform. The typical workflow:
@@ -13035,7 +13080,7 @@ fetch individual file contents (progressive loading).
13035
13080
 
13036
13081
  Subcommands:
13037
13082
  list List skill summaries (filter by --tag and/or --username)
13038
- tags Distinct tag set used across all skills
13083
+ tags Distinct tag set used across skills
13039
13084
  get Get one skill's metadata + file listing (path + size_bytes only)
13040
13085
  file Get one file's content from a skill
13041
13086
 
@@ -13112,19 +13157,21 @@ Examples:
13112
13157
  alva notification-preferences list
13113
13158
  alva notification-preferences disable-session-completed
13114
13159
  alva notification-preferences enable-session-completed`,
13115
- "push-subscriptions": `Usage: alva push-subscriptions <subcommand> [options]
13160
+ subscriptions: `Usage: alva subscriptions <subcommand> [options]
13116
13161
 
13117
- Personal opt-in for DM/web push notifications. Independent of social
13118
- follow: subscribing does not start following, unsubscribing does not
13119
- unfollow. Following a playbook elsewhere does not create or revive a
13120
- push subscription.
13162
+ Subscribe to playbooks and feeds.
13163
+ - subscribe-playbook is a CASCADE: follows the playbook AND enables alerts
13164
+ on all its push-enabled automations (one call). unsubscribe-playbook
13165
+ reverses both (unfollow + disable all of its alerts).
13166
+ - subscribe-feed / unsubscribe-feed toggle ONE feed's alert (a single
13167
+ automation) without touching the playbook follow.
13121
13168
 
13122
13169
  Subcommands:
13123
- subscribe-playbook Opt into push for a playbook (any of its feeds)
13124
- unsubscribe-playbook Opt out of push for a playbook (soft-disable)
13125
- subscribe-feed Opt into push for a single feed
13126
- unsubscribe-feed Opt out of push for a single feed (soft-disable)
13127
- list List the caller's push subscriptions
13170
+ subscribe-playbook Subscribe a playbook (follow + enable all its alerts)
13171
+ unsubscribe-playbook Unsubscribe a playbook (unfollow + disable its alerts)
13172
+ subscribe-feed Enable alerts for a single feed
13173
+ unsubscribe-feed Disable alerts for a single feed
13174
+ list List the caller's active subscriptions
13128
13175
 
13129
13176
  Subscribe/unsubscribe flags (playbook + feed):
13130
13177
  --username <user> Owner's username (required)
@@ -13135,10 +13182,10 @@ List flags:
13135
13182
  --cursor <token> Optional cursor from the previous page
13136
13183
 
13137
13184
  Examples:
13138
- alva push-subscriptions subscribe-playbook --username alice --name btc-dashboard
13139
- alva push-subscriptions subscribe-feed --username alice --name btc-ema-cross
13140
- alva push-subscriptions unsubscribe-feed --username alice --name btc-ema-cross
13141
- alva push-subscriptions list --first 20`,
13185
+ alva subscriptions subscribe-playbook --username alice --name btc-dashboard
13186
+ alva subscriptions subscribe-feed --username alice --name btc-ema-cross
13187
+ alva subscriptions unsubscribe-feed --username alice --name btc-ema-cross
13188
+ alva subscriptions list --first 20`,
13142
13189
  channel: `Usage: alva channel group-subscriptions <subcommand> [options]
13143
13190
 
13144
13191
  Manage push notifications delivered into the external group chat attached
@@ -13460,6 +13507,16 @@ function trendingPlaybooksSort(val) {
13460
13507
  "playbooks"
13461
13508
  );
13462
13509
  }
13510
+ function playbookVisibility(val) {
13511
+ const normalized = val.trim().toLowerCase();
13512
+ if (PLAYBOOK_VISIBILITIES.includes(normalized)) {
13513
+ return normalized;
13514
+ }
13515
+ throw new CliUsageError(
13516
+ `--visibility must be one of ${PLAYBOOK_VISIBILITIES.join(", ")} for 'playbooks set-visibility', got '${val}'`,
13517
+ "playbooks"
13518
+ );
13519
+ }
13463
13520
  function jsonParse(val) {
13464
13521
  if (val === void 0) return void 0;
13465
13522
  try {
@@ -13736,6 +13793,13 @@ async function dispatch(client, args, meta) {
13736
13793
  cursor: flags["cursor"],
13737
13794
  current: flags["current"]
13738
13795
  });
13796
+ case "set-visibility":
13797
+ return client.playbooks.setVisibility({
13798
+ name: requireFlag(flags, "name", "playbooks set-visibility"),
13799
+ visibility: playbookVisibility(
13800
+ requireFlag(flags, "visibility", "playbooks set-visibility")
13801
+ )
13802
+ });
13739
13803
  default:
13740
13804
  throw new CliUsageError(
13741
13805
  `Unknown subcommand: playbooks ${subcommand}`,
@@ -14077,74 +14141,66 @@ async function dispatch(client, args, meta) {
14077
14141
  );
14078
14142
  }
14079
14143
  }
14080
- case "push-subscriptions": {
14144
+ case "subscriptions": {
14081
14145
  if (!subcommand)
14082
14146
  throw new CliUsageError(
14083
- "Missing subcommand for push-subscriptions",
14084
- "push-subscriptions"
14147
+ "Missing subcommand for subscriptions",
14148
+ "subscriptions"
14085
14149
  );
14086
14150
  switch (subcommand) {
14087
14151
  case "subscribe-playbook":
14088
- return client.pushSubscriptions.subscribePlaybook({
14152
+ return client.subscriptions.subscribePlaybook({
14089
14153
  username: requireFlag(
14090
14154
  flags,
14091
14155
  "username",
14092
- "push-subscriptions subscribe-playbook"
14156
+ "subscriptions subscribe-playbook"
14093
14157
  ),
14094
14158
  name: requireFlag(
14095
14159
  flags,
14096
14160
  "name",
14097
- "push-subscriptions subscribe-playbook"
14161
+ "subscriptions subscribe-playbook"
14098
14162
  )
14099
14163
  });
14100
14164
  case "unsubscribe-playbook":
14101
- return client.pushSubscriptions.unsubscribePlaybook({
14165
+ return client.subscriptions.unsubscribePlaybook({
14102
14166
  username: requireFlag(
14103
14167
  flags,
14104
14168
  "username",
14105
- "push-subscriptions unsubscribe-playbook"
14169
+ "subscriptions unsubscribe-playbook"
14106
14170
  ),
14107
14171
  name: requireFlag(
14108
14172
  flags,
14109
14173
  "name",
14110
- "push-subscriptions unsubscribe-playbook"
14174
+ "subscriptions unsubscribe-playbook"
14111
14175
  )
14112
14176
  });
14113
14177
  case "subscribe-feed":
14114
- return client.pushSubscriptions.subscribeFeed({
14178
+ return client.subscriptions.subscribeFeed({
14115
14179
  username: requireFlag(
14116
14180
  flags,
14117
14181
  "username",
14118
- "push-subscriptions subscribe-feed"
14182
+ "subscriptions subscribe-feed"
14119
14183
  ),
14120
- name: requireFlag(
14121
- flags,
14122
- "name",
14123
- "push-subscriptions subscribe-feed"
14124
- )
14184
+ name: requireFlag(flags, "name", "subscriptions subscribe-feed")
14125
14185
  });
14126
14186
  case "unsubscribe-feed":
14127
- return client.pushSubscriptions.unsubscribeFeed({
14187
+ return client.subscriptions.unsubscribeFeed({
14128
14188
  username: requireFlag(
14129
14189
  flags,
14130
14190
  "username",
14131
- "push-subscriptions unsubscribe-feed"
14191
+ "subscriptions unsubscribe-feed"
14132
14192
  ),
14133
- name: requireFlag(
14134
- flags,
14135
- "name",
14136
- "push-subscriptions unsubscribe-feed"
14137
- )
14193
+ name: requireFlag(flags, "name", "subscriptions unsubscribe-feed")
14138
14194
  });
14139
14195
  case "list":
14140
- return client.pushSubscriptions.list({
14196
+ return client.subscriptions.list({
14141
14197
  first: num(flags["first"]),
14142
14198
  cursor: flags["cursor"]
14143
14199
  });
14144
14200
  default:
14145
14201
  throw new CliUsageError(
14146
- `Unknown subcommand: push-subscriptions ${subcommand}`,
14147
- "push-subscriptions"
14202
+ `Unknown subcommand: subscriptions ${subcommand}`,
14203
+ "subscriptions"
14148
14204
  );
14149
14205
  }
14150
14206
  }