@alva-ai/toolkit 0.11.3-beta.0 → 0.12.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
@@ -7761,7 +7761,7 @@ body {
7761
7761
  .markdown-container code {
7762
7762
  display: inline-block;
7763
7763
  vertical-align: middle;
7764
- box-shadow: inset 0 0 0 1px var(--line-l07);
7764
+ box-shadow: inset 0 0 0 0.5px var(--line-l12);
7765
7765
  font-size: 12px;
7766
7766
  line-height: 20px;
7767
7767
  letter-spacing: 0.12px;
@@ -7769,7 +7769,8 @@ body {
7769
7769
  margin: 0 var(--spacing-xxs);
7770
7770
  }
7771
7771
  .markdown-container pre {
7772
- border: 1px solid var(--line-l07);
7772
+ border: 0.5px solid var(--line-l12);
7773
+ border-radius: var(--radius-ct-s);
7773
7774
  font-size: 12px;
7774
7775
  line-height: 20px;
7775
7776
  letter-spacing: 0.12px;
@@ -9843,6 +9844,69 @@ var PlaybooksResource = class {
9843
9844
  this.client = client;
9844
9845
  }
9845
9846
  client;
9847
+ /**
9848
+ * Resolve playbook ids to named, addressable records (mono-meta#584 A2).
9849
+ * Visibility-gated server-side; ids the caller cannot see — and DELETED
9850
+ * playbook ids — return no row. Treat a missing id as "deleted or not
9851
+ * visible" (the subscriptions list's `target_status` distinguishes ghosts).
9852
+ * Ids are strings (snowflake-safe). Max 100 per call.
9853
+ *
9854
+ * Auth is optional (like `trending`): with an API key, private/paid
9855
+ * visibility is evaluated for the caller; without one, only public
9856
+ * playbooks resolve. The server decides — no client-side gate.
9857
+ */
9858
+ async getByIds(ids) {
9859
+ return await this.client._request("GET", "/api/v1/playbooks", {
9860
+ query: { ids: ids.join(",") }
9861
+ });
9862
+ }
9863
+ /**
9864
+ * List a user's playbooks by owner username (mono-meta#584 C10).
9865
+ * Visibility-gated: another user's private playbooks are omitted.
9866
+ * Auth is optional (like `trending`); without credentials only public
9867
+ * playbooks are listed.
9868
+ */
9869
+ async listByOwner(params) {
9870
+ const query = { owner: params.owner };
9871
+ if (params.limit !== void 0 && params.limit > 0) {
9872
+ query.limit = String(params.limit);
9873
+ }
9874
+ if (params.cursor) query.cursor = params.cursor;
9875
+ return await this.client._request("GET", "/api/v1/playbooks", {
9876
+ query
9877
+ });
9878
+ }
9879
+ /**
9880
+ * Get one playbook by numeric id or by "owner/name" ref. Returns null when
9881
+ * not found / not visible / deleted.
9882
+ */
9883
+ async get(params) {
9884
+ if (params.id) {
9885
+ const resp = await this.getByIds([params.id]);
9886
+ return resp.items[0] ?? null;
9887
+ }
9888
+ if (params.ref) {
9889
+ const slash = params.ref.indexOf("/");
9890
+ if (slash <= 0 || slash === params.ref.length - 1) {
9891
+ throw new AlvaError(
9892
+ "INVALID_ARGUMENT",
9893
+ `Invalid ref "${params.ref}". Expected "owner/name".`,
9894
+ 400
9895
+ );
9896
+ }
9897
+ const owner = params.ref.slice(0, slash);
9898
+ const name = params.ref.slice(slash + 1);
9899
+ let cursor;
9900
+ for (; ; ) {
9901
+ const page = await this.listByOwner({ owner, cursor, limit: 100 });
9902
+ const hit = page.items.find((item) => item.name === name);
9903
+ if (hit) return hit;
9904
+ if (!page.has_next || !page.next_cursor) return null;
9905
+ cursor = page.next_cursor;
9906
+ }
9907
+ }
9908
+ throw new AlvaError("INVALID_ARGUMENT", "id or ref is required", 400);
9909
+ }
9846
9910
  /**
9847
9911
  * List trending / searchable playbooks. Auth is optional: when the client
9848
9912
  * has an API key it is forwarded, otherwise this uses the public surface.
@@ -11628,6 +11692,42 @@ var SubscriptionsResource = class {
11628
11692
  query
11629
11693
  });
11630
11694
  }
11695
+ /**
11696
+ * List the playbooks the caller FOLLOWS (the social relation — the UI's
11697
+ * "Subscribed Playbooks"). Rows carry the playbook identity; follows of
11698
+ * deleted playbooks are filtered server-side. Cursor-paginated.
11699
+ */
11700
+ async follows(params = {}) {
11701
+ this.client._requireAuth();
11702
+ const query = {};
11703
+ if (params.limit !== void 0 && params.limit > 0) {
11704
+ query.limit = String(params.limit);
11705
+ }
11706
+ if (params.cursor) query.cursor = params.cursor;
11707
+ return this.client._request("GET", "/api/v1/me/follows", {
11708
+ query
11709
+ });
11710
+ }
11711
+ /**
11712
+ * Disable alerts for many playbook/feed targets BY TARGET ID in one
11713
+ * idempotent call (max 100 ids). Ids are strings (snowflake-safe). Works
11714
+ * for ghost rows (deleted targets) because no name resolution happens —
11715
+ * the per-id results report `INVALID_ID` for malformed entries while
11716
+ * valid ones proceed. Safe to re-run: already-gone rows are no-ops.
11717
+ */
11718
+ async unsubscribeBatch(params) {
11719
+ this.client._requireAuth();
11720
+ return this.client._request(
11721
+ "POST",
11722
+ "/api/v1/subscriptions/unsubscribe-batch",
11723
+ {
11724
+ body: {
11725
+ playbook_ids: params.playbookIds ?? [],
11726
+ feed_ids: params.feedIds ?? []
11727
+ }
11728
+ }
11729
+ );
11730
+ }
11631
11731
  };
11632
11732
 
11633
11733
  // src/resources/channelGroupSubscriptions.ts
@@ -12828,7 +12928,7 @@ function formatPlaybookSkillFile(file) {
12828
12928
  import * as fs2 from "fs";
12829
12929
  import * as os2 from "os";
12830
12930
  import * as fsPromises2 from "fs/promises";
12831
- var CLI_VERSION = true ? "0.11.3-beta.0" : "dev";
12931
+ var CLI_VERSION = true ? "0.12.0" : "dev";
12832
12932
  function isVersionOlderThan(a, b) {
12833
12933
  const parse4 = (v) => {
12834
12934
  if (!v) return null;
@@ -12858,7 +12958,7 @@ Commands:
12858
12958
  release Feed and playbook releases (feed, playbook-draft, playbook)
12859
12959
  lint Design-system lint (playbook)
12860
12960
  feed Feed lifecycle management (delete)
12861
- playbooks Playbook discovery (trending) and visibility
12961
+ playbooks Playbook discovery (trending, get, list) and visibility
12862
12962
  functions Playbook UDF function management (register, list, delete, invoke, allowance)
12863
12963
  secrets Secret management (create, list, get, update, delete)
12864
12964
  sdk SDK documentation (doc, partitions, partition-summary)
@@ -12868,7 +12968,7 @@ Commands:
12868
12968
  notification-history Notification delivery history (list-playbook, list-feed)
12869
12969
  notification-preferences Notification preferences (list, enable-session-completed, disable-session-completed)
12870
12970
  feedback Submit user-confirmed Alva platform feedback (submit)
12871
- subscriptions Subscribe to playbooks/feeds (subscribe-playbook, unsubscribe-playbook, subscribe-feed, unsubscribe-feed, list)
12971
+ subscriptions Follows + push alerts (subscribe-playbook, unsubscribe-playbook, subscribe-feed, unsubscribe-feed, unsubscribe, list, follows)
12872
12972
  channel Channel group operations (group-subscriptions context, list, subscribe, unsubscribe)
12873
12973
  remix Save playbook remix lineage
12874
12974
  portfolio Connected-account portfolio (accounts, summary, activities)
@@ -13185,12 +13285,25 @@ Examples:
13185
13285
  alva feed delete --id 42`,
13186
13286
  playbooks: `Usage: alva playbooks <subcommand> [options]
13187
13287
 
13188
- Find public playbooks with an agent-friendly response shape.
13288
+ Find and resolve playbooks with an agent-friendly response shape.
13189
13289
 
13190
13290
  Subcommands:
13191
13291
  trending List trending playbooks
13292
+ get Resolve playbooks by id(s) or "owner/name" ref
13293
+ list List a user's playbooks by owner username
13192
13294
  set-visibility Set a playbook's visibility (requires auth)
13193
13295
 
13296
+ Get flags:
13297
+ --id <n> Single numeric playbook id
13298
+ --ids <a,b> Comma-separated ids (max 100); ids you cannot see
13299
+ \u2014 and DELETED playbooks \u2014 return no row
13300
+ --ref <owner/name> Resolve by handle
13301
+
13302
+ List flags:
13303
+ --owner <username> Owner username (required)
13304
+ --limit <n> Max results per page
13305
+ --cursor <cursor> Pagination cursor from previous response
13306
+
13194
13307
  Trending flags:
13195
13308
  --keyword <text> Search text
13196
13309
  --tags <a,b> Comma-separated tags
@@ -13220,7 +13333,9 @@ Notes:
13220
13333
 
13221
13334
  Examples:
13222
13335
  alva playbooks trending --keyword scanner --tags macro,ai --sort recent --limit 5
13223
- alva playbooks trending --tag btc --cursor abc
13336
+ alva playbooks get --ids 8009,8010
13337
+ alva playbooks get --ref alice/btc-dashboard
13338
+ alva playbooks list --owner alice
13224
13339
  alva playbooks set-visibility --name my-scanner --visibility private
13225
13340
  alva playbooks set-visibility --name my-scanner --visibility public`,
13226
13341
  functions: `Usage: alva functions <subcommand> [options]
@@ -13556,33 +13671,63 @@ Examples:
13556
13671
  alva feedback submit --summary "bad quote data" --category data_quality`,
13557
13672
  subscriptions: `Usage: alva subscriptions <subcommand> [options]
13558
13673
 
13559
- Subscribe to playbooks and feeds.
13674
+ Three DISTINCT concepts share the word "subscribe" in the product:
13675
+ - FOLLOW \u2014 the social relation (the UI's "Subscribed Playbooks").
13676
+ Enumerate with: alva subscriptions follows
13677
+ - ALERTS \u2014 push/notification opt-ins (what list returns).
13678
+ - PURCHASE \u2014 paid playbook access / the SaaS plan. NOT this command.
13679
+
13680
+ Operations:
13560
13681
  - subscribe-playbook is a CASCADE: follows the playbook AND enables alerts
13561
13682
  on all its push-enabled automations (one call). unsubscribe-playbook
13562
- reverses both (unfollow + disable all of its alerts).
13683
+ reverses both and reports exactly what it changed
13684
+ ({unfollowed, wildcard_disabled}).
13563
13685
  - subscribe-feed / unsubscribe-feed toggle ONE feed's alert (a single
13564
13686
  automation) without touching the playbook follow.
13687
+ - unsubscribe disables alerts BY TARGET ID \u2014 bulk, idempotent, and the
13688
+ only way to clear ghost rows whose playbook/feed was deleted
13689
+ (name-addressed unsubscribe 404s on deleted targets).
13565
13690
 
13566
13691
  Subcommands:
13567
13692
  subscribe-playbook Subscribe a playbook (follow + enable all its alerts)
13568
13693
  unsubscribe-playbook Unsubscribe a playbook (unfollow + disable its alerts)
13569
13694
  subscribe-feed Enable alerts for a single feed
13570
13695
  unsubscribe-feed Disable alerts for a single feed
13571
- list List the caller's active subscriptions
13696
+ unsubscribe Bulk disable alerts by target id (handles ghosts)
13697
+ list List the caller's active alert subscriptions
13698
+ follows List the playbooks the caller follows
13572
13699
 
13573
- Subscribe/unsubscribe flags (playbook + feed):
13700
+ Subscribe/unsubscribe flags (playbook + feed, name-addressed):
13574
13701
  --username <user> Owner's username (required)
13575
13702
  --name <name> URL-safe playbook or feed name (required)
13576
13703
 
13704
+ Unsubscribe (by id) flags:
13705
+ --playbook-ids <a,b> Comma-separated playbook target ids
13706
+ --feed-ids <a,b> Comma-separated feed target ids
13707
+ (at least one of the two; max 100 ids total)
13708
+
13577
13709
  List flags:
13578
- --first <n> Optional page size
13710
+ --first <n> Optional page size (response carries total_count \u2014
13711
+ when items < total_count, keep paginating)
13579
13712
  --cursor <token> Optional cursor from the previous page
13580
13713
 
13714
+ Follows flags:
13715
+ --limit <n> Optional page size
13716
+ --cursor <token> Optional cursor from the previous page
13717
+
13718
+ List response notes:
13719
+ items[].kind PLAYBOOK_ALERTS (playbook-level wildcard) | FEED_ALERT
13720
+ items[].following Whether the caller also FOLLOWS the playbook
13721
+ items[].target_status ACTIVE | TARGET_DELETED (ghost \u2014 clear via
13722
+ unsubscribe --playbook-ids/--feed-ids) | PAUSED
13723
+ items[].playbook {owner_username, name, display_name} for PLAYBOOK rows
13724
+
13581
13725
  Examples:
13582
13726
  alva subscriptions subscribe-playbook --username alice --name btc-dashboard
13583
13727
  alva subscriptions subscribe-feed --username alice --name btc-ema-cross
13584
- alva subscriptions unsubscribe-feed --username alice --name btc-ema-cross
13585
- alva subscriptions list --first 20`,
13728
+ alva subscriptions unsubscribe --playbook-ids 8009,8010 --feed-ids 13292
13729
+ alva subscriptions list --first 200
13730
+ alva subscriptions follows`,
13586
13731
  channel: `Usage: alva channel group-subscriptions <subcommand> [options]
13587
13732
 
13588
13733
  Manage push notifications delivered into the external group chat attached
@@ -14270,6 +14415,28 @@ async function dispatch(client, args, meta) {
14270
14415
  requireFlag(flags, "visibility", "playbooks set-visibility")
14271
14416
  )
14272
14417
  });
14418
+ case "get": {
14419
+ const ids = csvList(flags["ids"]);
14420
+ if (ids && ids.length > 0) {
14421
+ return client.playbooks.getByIds(ids);
14422
+ }
14423
+ if (flags["id"]) {
14424
+ return client.playbooks.get({ id: flags["id"] });
14425
+ }
14426
+ if (flags["ref"]) {
14427
+ return client.playbooks.get({ ref: flags["ref"] });
14428
+ }
14429
+ throw new CliUsageError(
14430
+ "--id, --ids or --ref is required",
14431
+ "playbooks"
14432
+ );
14433
+ }
14434
+ case "list":
14435
+ return client.playbooks.listByOwner({
14436
+ owner: requireFlag(flags, "owner", "playbooks list"),
14437
+ limit: num(flags["limit"]),
14438
+ cursor: flags["cursor"]
14439
+ });
14273
14440
  default:
14274
14441
  throw new CliUsageError(
14275
14442
  `Unknown subcommand: playbooks ${subcommand}`,
@@ -14807,6 +14974,25 @@ async function dispatch(client, args, meta) {
14807
14974
  first: num(flags["first"]),
14808
14975
  cursor: flags["cursor"]
14809
14976
  });
14977
+ case "follows":
14978
+ return client.subscriptions.follows({
14979
+ limit: num(flags["limit"]),
14980
+ cursor: flags["cursor"]
14981
+ });
14982
+ case "unsubscribe": {
14983
+ const playbookIds = csvList(flags["playbook-ids"]) ?? [];
14984
+ const feedIds = csvList(flags["feed-ids"]) ?? [];
14985
+ if (playbookIds.length === 0 && feedIds.length === 0) {
14986
+ throw new CliUsageError(
14987
+ "--playbook-ids or --feed-ids is required",
14988
+ "subscriptions"
14989
+ );
14990
+ }
14991
+ return client.subscriptions.unsubscribeBatch({
14992
+ playbookIds,
14993
+ feedIds
14994
+ });
14995
+ }
14810
14996
  default:
14811
14997
  throw new CliUsageError(
14812
14998
  `Unknown subcommand: subscriptions ${subcommand}`,