@alva-ai/toolkit 0.11.2 → 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/index.d.cts CHANGED
@@ -13,6 +13,7 @@ interface UserProfile {
13
13
  username: string;
14
14
  subscription_tier: 'free' | 'pro';
15
15
  telegram_username: string | null;
16
+ slack_username: string | null;
16
17
  /** Caller's alfs home directory, e.g. `/alva/home/<username>`. */
17
18
  home_path: string;
18
19
  }
@@ -628,6 +629,29 @@ interface PushSubscription {
628
629
  /** Playbooks whose latest release currently references this feed. */
629
630
  used_by?: PushSubscriptionUsedBy[];
630
631
  used_by_total?: number;
632
+ /**
633
+ * Row-shape discriminator: PLAYBOOK_ALERTS = a playbook-level wildcard
634
+ * (alerts for every push-enabled automation of the playbook);
635
+ * FEED_ALERT = a single feed's alert.
636
+ */
637
+ kind?: 'PLAYBOOK_ALERTS' | 'FEED_ALERT' | 'UNSPECIFIED' | string;
638
+ /**
639
+ * Whether the caller also FOLLOWS the target playbook — the social
640
+ * relation, distinct from this alert row. Always false for FEED targets.
641
+ */
642
+ following?: boolean;
643
+ /**
644
+ * Target lifecycle: TARGET_DELETED marks a ghost row (the playbook/feed
645
+ * was deleted) — clear it with unsubscribeBatch by target id.
646
+ */
647
+ target_status?: 'ACTIVE' | 'TARGET_DELETED' | 'PAUSED' | 'UNSPECIFIED' | string;
648
+ /** Playbook identity, present for PLAYBOOK targets on list responses. */
649
+ playbook?: PushSubscriptionPlaybookInfo;
650
+ }
651
+ interface PushSubscriptionPlaybookInfo {
652
+ owner_username: string;
653
+ name: string;
654
+ display_name: string;
631
655
  }
632
656
  interface PushSubscriptionUsedBy {
633
657
  playbook_id: string;
@@ -654,6 +678,46 @@ interface PushSubscriptionListResponse {
654
678
  items: PushSubscription[];
655
679
  /** Empty when there is no next page. */
656
680
  next_cursor?: string;
681
+ /**
682
+ * Total active subscription rows independent of pagination — when
683
+ * items.length < total_count, the page is truncated; keep paginating.
684
+ */
685
+ total_count?: number;
686
+ }
687
+ interface FollowsListParams {
688
+ /** Page size, default 50, max 100 server-side. */
689
+ limit?: number;
690
+ /** Opaque cursor from the previous page's `next_cursor`. */
691
+ cursor?: string;
692
+ }
693
+ interface PlaybookFollowItem {
694
+ playbook_id: string;
695
+ owner_username: string;
696
+ name: string;
697
+ display_name: string;
698
+ followed_at_ms: number;
699
+ cursor: string;
700
+ }
701
+ interface FollowsListResponse {
702
+ items: PlaybookFollowItem[];
703
+ has_next: boolean;
704
+ next_cursor?: string;
705
+ }
706
+ interface UnsubscribeBatchParams {
707
+ /** Playbook target ids (strings — snowflake ids exceed JS safe integers). */
708
+ playbookIds?: string[];
709
+ /** Feed target ids (strings). */
710
+ feedIds?: string[];
711
+ }
712
+ interface UnsubscribeBatchResult {
713
+ id: string;
714
+ kind: 'PLAYBOOK' | 'FEED' | string;
715
+ ok: boolean;
716
+ status: 'UNSUBSCRIBED' | 'INVALID_ID' | string;
717
+ }
718
+ interface UnsubscribeBatchResponse {
719
+ results: UnsubscribeBatchResult[];
720
+ ok_count: number;
657
721
  }
658
722
  interface PlaybookFollow {
659
723
  id: string;
@@ -895,9 +959,65 @@ interface TrendingPlaybooksResponse {
895
959
  * Public playbook discovery. Backed by alva-gateway REST and mirrors the
896
960
  * GraphQL `trendingPlaybooks(cursor, sort, tags, keyword)` query.
897
961
  */
962
+ /** Compact discovery record returned by getByIds / listByOwner / get. */
963
+ interface PlaybookDiscoveryItem {
964
+ /** Numeric playbook id encoded as a string. */
965
+ id: string;
966
+ /** Owner username (empty when not resolvable). */
967
+ owner_username: string;
968
+ /** URL-safe playbook name. */
969
+ name: string;
970
+ display_name: string;
971
+ visibility: string;
972
+ /** Stable "owner/name" handle for name-addressed operations. */
973
+ ref?: string;
974
+ /** Present on listByOwner rows. */
975
+ cursor?: string;
976
+ }
977
+ interface DiscoveryByIDsResponse {
978
+ items: PlaybookDiscoveryItem[];
979
+ }
980
+ interface ListByOwnerParams {
981
+ owner: string;
982
+ /** Page size, default 50, max 100 server-side. */
983
+ limit?: number;
984
+ cursor?: string;
985
+ }
986
+ interface ListByOwnerResponse {
987
+ items: PlaybookDiscoveryItem[];
988
+ has_next: boolean;
989
+ next_cursor?: string;
990
+ }
898
991
  declare class PlaybooksResource {
899
992
  private client;
900
993
  constructor(client: AlvaClient);
994
+ /**
995
+ * Resolve playbook ids to named, addressable records (mono-meta#584 A2).
996
+ * Visibility-gated server-side; ids the caller cannot see — and DELETED
997
+ * playbook ids — return no row. Treat a missing id as "deleted or not
998
+ * visible" (the subscriptions list's `target_status` distinguishes ghosts).
999
+ * Ids are strings (snowflake-safe). Max 100 per call.
1000
+ *
1001
+ * Auth is optional (like `trending`): with an API key, private/paid
1002
+ * visibility is evaluated for the caller; without one, only public
1003
+ * playbooks resolve. The server decides — no client-side gate.
1004
+ */
1005
+ getByIds(ids: string[]): Promise<DiscoveryByIDsResponse>;
1006
+ /**
1007
+ * List a user's playbooks by owner username (mono-meta#584 C10).
1008
+ * Visibility-gated: another user's private playbooks are omitted.
1009
+ * Auth is optional (like `trending`); without credentials only public
1010
+ * playbooks are listed.
1011
+ */
1012
+ listByOwner(params: ListByOwnerParams): Promise<ListByOwnerResponse>;
1013
+ /**
1014
+ * Get one playbook by numeric id or by "owner/name" ref. Returns null when
1015
+ * not found / not visible / deleted.
1016
+ */
1017
+ get(params: {
1018
+ id?: string;
1019
+ ref?: string;
1020
+ }): Promise<PlaybookDiscoveryItem | null>;
901
1021
  /**
902
1022
  * List trending / searchable playbooks. Auth is optional: when the client
903
1023
  * has an API key it is forwarded, otherwise this uses the public surface.
@@ -1165,12 +1285,24 @@ declare class NotificationPreferencesResource {
1165
1285
  /**
1166
1286
  * Subscriptions — subscribe the caller to playbooks and feeds.
1167
1287
  *
1288
+ * Three DISTINCT concepts share the word "subscribe" in the product; this
1289
+ * resource touches the first two and never the third:
1290
+ *
1291
+ * - **follow** — the social relation ("Subscribed Playbooks" in the UI).
1292
+ * Enumerate with `follows()`.
1293
+ * - **alerts** — push/notification opt-ins (what `list()` returns).
1294
+ * - **purchase** — paid playbook access / the SaaS plan. NOT this resource.
1295
+ *
1296
+ * Operations:
1168
1297
  * - `subscribePlaybook` is a CASCADE: it follows the playbook AND enables
1169
1298
  * personal push for every push-enabled automation of its latest release,
1170
1299
  * in one call. `unsubscribePlaybook` reverses both (unfollow + disable
1171
- * all of the playbook's push alerts).
1300
+ * the playbook-level alert) and reports exactly what it changed.
1172
1301
  * - `subscribeFeed` / `unsubscribeFeed` toggle personal push for ONE feed
1173
1302
  * (a single automation's alert) without touching the playbook follow.
1303
+ * - `unsubscribeBatch` disables alerts by TARGET ID — bulk, idempotent,
1304
+ * and the only way to clear ghost rows whose target was deleted
1305
+ * (name-addressed unsubscribe 404s on deleted playbooks).
1174
1306
  *
1175
1307
  * Backed by alva-gateway REST under `/api/v1/subscriptions/...`.
1176
1308
  */
@@ -1205,6 +1337,20 @@ declare class SubscriptionsResource {
1205
1337
  * Results are cursor-paginated.
1206
1338
  */
1207
1339
  list(params?: PushSubscriptionListParams): Promise<PushSubscriptionListResponse>;
1340
+ /**
1341
+ * List the playbooks the caller FOLLOWS (the social relation — the UI's
1342
+ * "Subscribed Playbooks"). Rows carry the playbook identity; follows of
1343
+ * deleted playbooks are filtered server-side. Cursor-paginated.
1344
+ */
1345
+ follows(params?: FollowsListParams): Promise<FollowsListResponse>;
1346
+ /**
1347
+ * Disable alerts for many playbook/feed targets BY TARGET ID in one
1348
+ * idempotent call (max 100 ids). Ids are strings (snowflake-safe). Works
1349
+ * for ghost rows (deleted targets) because no name resolution happens —
1350
+ * the per-id results report `INVALID_ID` for malformed entries while
1351
+ * valid ones proceed. Safe to re-run: already-gone rows are no-ops.
1352
+ */
1353
+ unsubscribeBatch(params: UnsubscribeBatchParams): Promise<UnsubscribeBatchResponse>;
1208
1354
  }
1209
1355
 
1210
1356
  /**
@@ -1229,6 +1375,95 @@ declare class FeedbackResource {
1229
1375
  submit(params: SubmitFeedbackRequest): Promise<SubmitFeedbackResponse>;
1230
1376
  }
1231
1377
 
1378
+ interface PlaybookFunction {
1379
+ id: string | number;
1380
+ playbook_id: string | number;
1381
+ function_name: string;
1382
+ entry_script_path: string;
1383
+ created_at?: string;
1384
+ updated_at?: string;
1385
+ disabled?: boolean;
1386
+ params_schema?: string;
1387
+ allow_charges?: boolean;
1388
+ }
1389
+ interface RegisterFunctionParams {
1390
+ playbook_id: number;
1391
+ function_name: string;
1392
+ entry_script_path: string;
1393
+ params_schema?: string;
1394
+ allow_charges?: boolean;
1395
+ }
1396
+ interface RegisterFunctionResponse {
1397
+ function?: PlaybookFunction;
1398
+ }
1399
+ interface ListFunctionsParams {
1400
+ playbook_id: number;
1401
+ }
1402
+ interface ListFunctionsResponse {
1403
+ functions: PlaybookFunction[];
1404
+ }
1405
+ interface DeleteFunctionParams {
1406
+ playbook_id: number;
1407
+ function_name: string;
1408
+ }
1409
+ interface InvokeFunctionParams {
1410
+ playbook_id: number;
1411
+ function_name: string;
1412
+ parameters?: unknown;
1413
+ }
1414
+ interface InvokeFunctionResponse<TResult = unknown> {
1415
+ result: TResult;
1416
+ logs: string;
1417
+ credits_used_total: number;
1418
+ credits_charged_owner: number;
1419
+ credits_charged_consumer: number;
1420
+ }
1421
+ interface CreditAllowance {
1422
+ id: string | number;
1423
+ consumer_uid: string | number;
1424
+ playbook_id: string | number;
1425
+ amount: number;
1426
+ used: number;
1427
+ remaining: number;
1428
+ created_at_ms?: number;
1429
+ updated_at_ms?: number;
1430
+ }
1431
+ interface GetAllowanceParams {
1432
+ playbook_id: number;
1433
+ }
1434
+ interface ListAllowancesResponse {
1435
+ allowances: CreditAllowance[];
1436
+ }
1437
+ interface CreateAllowanceParams {
1438
+ playbook_id: number;
1439
+ amount: number;
1440
+ }
1441
+ interface CreateAllowanceResponse {
1442
+ allowance: CreditAllowance;
1443
+ }
1444
+ interface RevokeAllowanceParams {
1445
+ playbook_id: number;
1446
+ }
1447
+ interface RevokeAllowanceResponse {
1448
+ ok: boolean;
1449
+ }
1450
+ /**
1451
+ * Playbook function management. These functions are registered by a playbook
1452
+ * creator and invoked by released playbook UI through the browser UDF runtime.
1453
+ */
1454
+ declare class FunctionsResource {
1455
+ private client;
1456
+ constructor(client: AlvaClient);
1457
+ register(params: RegisterFunctionParams): Promise<RegisterFunctionResponse>;
1458
+ list(params: ListFunctionsParams): Promise<ListFunctionsResponse>;
1459
+ delete(params: DeleteFunctionParams): Promise<void>;
1460
+ invoke<TResult = unknown>(params: InvokeFunctionParams): Promise<InvokeFunctionResponse<TResult>>;
1461
+ getAllowance(params: GetAllowanceParams): Promise<CreditAllowance | null>;
1462
+ listAllowances(): Promise<ListAllowancesResponse>;
1463
+ createAllowance(params: CreateAllowanceParams): Promise<CreateAllowanceResponse>;
1464
+ revokeAllowance(params: RevokeAllowanceParams): Promise<RevokeAllowanceResponse>;
1465
+ }
1466
+
1232
1467
  interface RequestOptions {
1233
1468
  query?: Record<string, unknown>;
1234
1469
  body?: unknown;
@@ -1272,6 +1507,7 @@ declare class AlvaClient {
1272
1507
  private _subscriptions?;
1273
1508
  private _channelGroupSubscriptions?;
1274
1509
  private _feedback?;
1510
+ private _functions?;
1275
1511
  constructor(config: AlvaClientConfig);
1276
1512
  get fs(): FsResource;
1277
1513
  get run(): RunResource;
@@ -1295,6 +1531,7 @@ declare class AlvaClient {
1295
1531
  get subscriptions(): SubscriptionsResource;
1296
1532
  get channelGroupSubscriptions(): ChannelGroupSubscriptionsResource;
1297
1533
  get feedback(): FeedbackResource;
1534
+ get functions(): FunctionsResource;
1298
1535
  _requireAuth(): void;
1299
1536
  _request(method: string, path: string, options?: RequestOptions): Promise<unknown>;
1300
1537
  }
@@ -1316,6 +1553,20 @@ type UdfErrorBody = {
1316
1553
  metadata?: Record<string, unknown>;
1317
1554
  };
1318
1555
  };
1556
+ type SubscribeProposalResult = 'subscribed' | 'declined' | 'timeout' | 'error';
1557
+ type SubscribeProposalInput = {
1558
+ feedOwner: string;
1559
+ feedName: string;
1560
+ };
1561
+ type SubscribeApi = {
1562
+ /**
1563
+ * Ask the parent (main site) to offer the viewer a subscription to a feed.
1564
+ * The iframe CANNOT subscribe directly — it only proposes; the trusted
1565
+ * parent shows a confirm prompt and, on user confirmation, subscribes with
1566
+ * the viewer's own session. Resolves with the outcome.
1567
+ */
1568
+ propose: (input: SubscribeProposalInput) => Promise<SubscribeProposalResult>;
1569
+ };
1319
1570
  type UdfDescriptor = {
1320
1571
  name: string;
1321
1572
  params_schema: unknown | null;
@@ -1364,6 +1615,7 @@ declare global {
1364
1615
  interface Window {
1365
1616
  alva?: {
1366
1617
  udf?: UdfApi;
1618
+ subscribe?: SubscribeApi;
1367
1619
  [key: string]: unknown;
1368
1620
  };
1369
1621
  }
@@ -1411,13 +1663,16 @@ declare const PBSV_UPDATE_MESSAGE = "alva:pbsv:update";
1411
1663
  declare const UDF_CONSENT_REQUEST_MESSAGE = "alva:udf:consent-request";
1412
1664
  declare const UDF_CONSENT_RESPONSE_MESSAGE = "alva:udf:consent-response";
1413
1665
  declare const UDF_AUTH_REQUIRED_MESSAGE = "alva:udf:auth-required";
1666
+ declare const SUBSCRIBE_PROPOSE_MESSAGE = "alva:subscribe:propose";
1667
+ declare const SUBSCRIBE_RESULT_MESSAGE = "alva:subscribe:result";
1414
1668
  declare const playbookIdFromToken: (token: string | null) => string | null;
1415
1669
  declare const getViewerToken: () => string | null;
1416
1670
  declare const mapUdfErrorResponse: (body: UdfErrorBody, status?: number) => UdfError;
1671
+ declare const subscribe: SubscribeApi;
1417
1672
  declare const udf: UdfApi;
1418
1673
  declare const installPlaybookRuntime: (targetWindow?: Window) => void;
1419
1674
 
1420
1675
  /** SDK version, injected at build time from package.json. */
1421
1676
  declare const VERSION: string;
1422
1677
 
1423
- export { AlvaClient, type AlvaClientConfig, AlvaError, type ChannelGroupAdminInfo, type ChannelGroupCallerInfo, type ChannelGroupSubscription, type ChannelGroupSubscriptionContextResponse, type ChannelGroupSubscriptionListResponse, type ChannelGroupSubscriptionMutationParams, type ChannelGroupSubscriptionMutationResponse, type ChannelGroupSubscriptionSessionParams, type ChannelGroupSubscriptionTarget, type ChannelGroupSubscriptionTargetType, type FeedDeleteRequest, type FeedDeleteResponse, type FeedStatusUpdateRequest, type FeedStatusUpdateResponse, type FsChmodParams, type FsCopyParams, type FsEntry, type FsGrantParams, type FsMkdirParams, type FsRawWriteParams, type FsReadParams, type FsReaddirParams, type FsReaddirResponse, type FsReadlinkParams, type FsRemoveParams, type FsRenameParams, type FsRevokeParams, type FsStat, type FsSymlinkParams, type FsWriteParams, type FsWriteResponse, type NotificationPreference, type NotificationPreferenceKey, type NotificationPreferenceUpdateParams, type NotificationPreferenceUpdateResponse, type NotificationPreferencesResponse, PBSV_UPDATE_MESSAGE, type PlaybookSkillFile, type PlaybookSkillFileMeta, type PlaybookSkillMeta, type PlaybookSkillSummary, type PlaybookSkillTagEntry, type SkillDoc, type SkillEndpointMetadata, type SkillEndpointTier, type SkillMetadata, type SkillSummary, type SubmitFeedbackRequest, type SubmitFeedbackResponse, type TrendingPlaybookItem, type TrendingPlaybooksDir, type TrendingPlaybooksParams, type TrendingPlaybooksResponse, type TrendingPlaybooksSort, UDF_AUTH_REQUIRED_MESSAGE, UDF_CONSENT_REQUEST_MESSAGE, UDF_CONSENT_RESPONSE_MESSAGE, type UdfApi, UdfAuthRequiredError, type UdfButtonEventDetail, type UdfButtonOptions, UdfConsentDeniedError, UdfConsentRequiredError, UdfConsentTimeoutError, type UdfDescriptor, UdfError, UdfExecutionError, UdfFunctionDisabledError, UdfFunctionNotFoundError, UdfInsufficientCredits, type UdfInvokeResponse, UdfPidMismatchError, UdfRateLimitedError, UdfTokenExpiredError, UdfTokenInvalidError, UdfTransportError, VERSION, getViewerToken, installPlaybookRuntime, mapUdfErrorResponse, playbookIdFromToken, udf };
1678
+ export { AlvaClient, type AlvaClientConfig, AlvaError, type ChannelGroupAdminInfo, type ChannelGroupCallerInfo, type ChannelGroupSubscription, type ChannelGroupSubscriptionContextResponse, type ChannelGroupSubscriptionListResponse, type ChannelGroupSubscriptionMutationParams, type ChannelGroupSubscriptionMutationResponse, type ChannelGroupSubscriptionSessionParams, type ChannelGroupSubscriptionTarget, type ChannelGroupSubscriptionTargetType, type CreateAllowanceParams, type CreateAllowanceResponse, type CreditAllowance, type DeleteFunctionParams, type FeedDeleteRequest, type FeedDeleteResponse, type FeedStatusUpdateRequest, type FeedStatusUpdateResponse, type FsChmodParams, type FsCopyParams, type FsEntry, type FsGrantParams, type FsMkdirParams, type FsRawWriteParams, type FsReadParams, type FsReaddirParams, type FsReaddirResponse, type FsReadlinkParams, type FsRemoveParams, type FsRenameParams, type FsRevokeParams, type FsStat, type FsSymlinkParams, type FsWriteParams, type FsWriteResponse, type GetAllowanceParams, type InvokeFunctionParams, type InvokeFunctionResponse, type ListAllowancesResponse, type ListFunctionsParams, type ListFunctionsResponse, type NotificationPreference, type NotificationPreferenceKey, type NotificationPreferenceUpdateParams, type NotificationPreferenceUpdateResponse, type NotificationPreferencesResponse, PBSV_UPDATE_MESSAGE, type PlaybookFunction, type PlaybookSkillFile, type PlaybookSkillFileMeta, type PlaybookSkillMeta, type PlaybookSkillSummary, type PlaybookSkillTagEntry, type RegisterFunctionParams, type RegisterFunctionResponse, type RevokeAllowanceParams, type RevokeAllowanceResponse, SUBSCRIBE_PROPOSE_MESSAGE, SUBSCRIBE_RESULT_MESSAGE, type SkillDoc, type SkillEndpointMetadata, type SkillEndpointTier, type SkillMetadata, type SkillSummary, type SubmitFeedbackRequest, type SubmitFeedbackResponse, type SubscribeApi, type SubscribeProposalInput, type SubscribeProposalResult, type TrendingPlaybookItem, type TrendingPlaybooksDir, type TrendingPlaybooksParams, type TrendingPlaybooksResponse, type TrendingPlaybooksSort, UDF_AUTH_REQUIRED_MESSAGE, UDF_CONSENT_REQUEST_MESSAGE, UDF_CONSENT_RESPONSE_MESSAGE, type UdfApi, UdfAuthRequiredError, type UdfButtonEventDetail, type UdfButtonOptions, UdfConsentDeniedError, UdfConsentRequiredError, UdfConsentTimeoutError, type UdfDescriptor, UdfError, UdfExecutionError, UdfFunctionDisabledError, UdfFunctionNotFoundError, UdfInsufficientCredits, type UdfInvokeResponse, UdfPidMismatchError, UdfRateLimitedError, UdfTokenExpiredError, UdfTokenInvalidError, UdfTransportError, VERSION, getViewerToken, installPlaybookRuntime, mapUdfErrorResponse, playbookIdFromToken, subscribe, udf };