@alva-ai/toolkit 0.7.0 → 0.9.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.ts CHANGED
@@ -1,8 +1,12 @@
1
1
  interface AlvaClientConfig {
2
2
  viewer_token?: string;
3
+ pbsvToken?: string;
3
4
  apiKey?: string;
4
5
  baseUrl?: string;
5
6
  arraysBaseUrl?: string;
7
+ gaClientId?: string;
8
+ gaSessionId?: string;
9
+ utmParams?: string;
6
10
  }
7
11
  interface UserProfile {
8
12
  id: string;
@@ -105,6 +109,11 @@ interface RunRequest {
105
109
  entry_path?: string;
106
110
  working_dir?: string;
107
111
  args?: Record<string, unknown>;
112
+ /**
113
+ * Override the server's default V8 heap limit, in MB. Valid range is
114
+ * 1–2048. Omitted means the server uses its default heap (256 MB).
115
+ */
116
+ max_heap_size_mb?: number;
108
117
  }
109
118
  interface RunResponse {
110
119
  result: string;
@@ -209,6 +218,14 @@ interface FeedReleaseResponse {
209
218
  /** Canonical alfs path: `/alva/home/<username>/feeds/<name>`. */
210
219
  feed_path: string;
211
220
  }
221
+ interface FeedDeleteRequest {
222
+ /** Numeric feed id to delete. */
223
+ id: number;
224
+ }
225
+ interface FeedDeleteResponse {
226
+ /** Echoed feed id (string form, matching gateway response). */
227
+ id: string;
228
+ }
212
229
  interface PlaybookDraftRequest {
213
230
  name: string;
214
231
  display_name: string;
@@ -219,11 +236,20 @@ interface PlaybookDraftRequest {
219
236
  }>;
220
237
  trading_symbols?: string[];
221
238
  /**
222
- * Optional source-template reference in "username/name" form (matches
223
- * playbook_templates PK, e.g. "alva/screener"). Persisted set-once on
224
- * the playbook's first draft; subsequent drafts ignore the field.
239
+ * Optional source-skill reference in "username/name" form (e.g.
240
+ * "alva/screener"). The value identifies a playbook skill published to
241
+ * Skillhub; discover available skills via `alva skillhub list`.
242
+ * Persisted set-once on the playbook's first draft; subsequent drafts
243
+ * ignore the field.
244
+ */
245
+ skill_id?: string;
246
+ /**
247
+ * Optional discovery tags (max 10, each up to 32 characters). On a
248
+ * playbook's first draft these merge with any template-inherited tags;
249
+ * on a re-draft of an existing playbook they replace the current tag
250
+ * set. Omitted/empty leaves tags unchanged.
225
251
  */
226
- template_id?: string;
252
+ tags?: string[];
227
253
  }
228
254
  interface PlaybookDraftResponse {
229
255
  playbook_id: number;
@@ -456,6 +482,21 @@ interface FeedNotificationListResponse {
456
482
  /** Canonical alfs path: `/alva/home/<username>/feeds/<name>`. */
457
483
  feed_path: string;
458
484
  }
485
+ type NotificationPreferenceKey = 'session_completed';
486
+ interface NotificationPreference {
487
+ key: NotificationPreferenceKey;
488
+ enabled: boolean;
489
+ }
490
+ interface NotificationPreferencesResponse {
491
+ settings: NotificationPreference[];
492
+ }
493
+ interface NotificationPreferenceUpdateParams {
494
+ key: NotificationPreferenceKey;
495
+ enabled: boolean;
496
+ }
497
+ interface NotificationPreferenceUpdateResponse {
498
+ setting: NotificationPreference;
499
+ }
459
500
  /**
460
501
  * Identifies the asset a personal push subscription is keyed to.
461
502
  * `PLAYBOOK` is the only target supported today; `FEED` is reserved for
@@ -470,15 +511,25 @@ interface PushTarget {
470
511
  }
471
512
  interface PushSubscription {
472
513
  target: PushTarget;
473
- /**
474
- * `true` when the row is currently active. `false` means the user
475
- * previously subscribed and then unsubscribed; the row is preserved
476
- * so re-subscribe restores seniority via UPSERT-revive. Only present
477
- * when `include_history=true` is passed to `list`.
478
- */
479
- subscribed: boolean;
480
514
  created_at_ms: number;
481
515
  updated_at_ms: number;
516
+ /** Present on list responses. */
517
+ cursor?: string;
518
+ /** Feed metadata is present for FEED targets when available. */
519
+ feed_name?: string;
520
+ feed_status?: 'ACTIVE' | 'PAUSED' | 'UNSPECIFIED' | string;
521
+ /** Unix milliseconds of the latest successful delivery for this user+target. */
522
+ last_pushed_at_ms?: number;
523
+ /** Playbooks whose latest release currently references this feed. */
524
+ used_by?: PushSubscriptionUsedBy[];
525
+ used_by_total?: number;
526
+ }
527
+ interface PushSubscriptionUsedBy {
528
+ playbook_id: string;
529
+ owner_username: string;
530
+ playbook_name: string;
531
+ display_name: string;
532
+ owner_avatar_url: string;
482
533
  }
483
534
  interface PushSubscriptionPlaybookParams {
484
535
  username: string;
@@ -489,11 +540,15 @@ interface PushSubscriptionFeedParams {
489
540
  name: string;
490
541
  }
491
542
  interface PushSubscriptionListParams {
492
- /** Default `false`. When `true`, include rows with `subscribed=false`. */
493
- include_history?: boolean;
543
+ /** Page size, default 50, max 200 server-side. */
544
+ first?: number;
545
+ /** Opaque cursor token from previous page's `next_cursor`. */
546
+ cursor?: string;
494
547
  }
495
548
  interface PushSubscriptionListResponse {
496
549
  items: PushSubscription[];
550
+ /** Empty when there is no next page. */
551
+ next_cursor?: string;
497
552
  }
498
553
  interface SubscribePushTargetResponse {
499
554
  subscription: PushSubscription;
@@ -636,6 +691,83 @@ declare class ReleaseResource {
636
691
  playbook(params: PlaybookReleaseRequest): Promise<PlaybookReleaseResponse>;
637
692
  }
638
693
 
694
+ /**
695
+ * Feed lifecycle management. Backed by alva-gateway REST (mirrors the
696
+ * GraphQL surface in `pkg/schema/feed.graphql`).
697
+ */
698
+ declare class FeedResource {
699
+ private client;
700
+ constructor(client: AlvaClient);
701
+ /**
702
+ * Soft-delete a feed and all its active majors. Cascades:
703
+ * - all active feed_majors are soft-deleted in the same transaction
704
+ * - associated producer cronjobs are removed best-effort (the cronjob
705
+ * scavenger reconciles any leftover rows on its next sweep)
706
+ *
707
+ * Auth: caller must own the feed (uid match), enforced by the backend.
708
+ */
709
+ delete(params: FeedDeleteRequest): Promise<FeedDeleteResponse>;
710
+ }
711
+
712
+ type TrendingPlaybooksSort = 'FOLLOWS' | 'RECENT';
713
+ type TrendingPlaybooksDir = 'FORWARD' | 'BACKWARD';
714
+ interface TrendingPlaybooksParams {
715
+ /** Opaque cursor returned on a previous item. Alias of `current`. */
716
+ cursor?: string;
717
+ /** GraphQL-compatible cursor field name. Alias of `cursor`. */
718
+ current?: string;
719
+ /** Page size, default 50, max 100 server-side. */
720
+ limit?: number;
721
+ /** Only FORWARD is supported by the gateway today. */
722
+ dir?: TrendingPlaybooksDir;
723
+ /** FOLLOWS = most followed, RECENT = newest first. */
724
+ sort?: TrendingPlaybooksSort;
725
+ /** Optional AND-filter tags. */
726
+ tags?: string[];
727
+ /** Optional weighted search across playbook and creator fields. */
728
+ keyword?: string;
729
+ }
730
+ interface TrendingPlaybookItem {
731
+ /** Numeric playbook id encoded as a string. */
732
+ id: string;
733
+ /** Stable "owner/name" handle, useful for follow-up tool calls. */
734
+ ref: string;
735
+ /** Owner username. */
736
+ username: string;
737
+ /** URL-safe playbook name. */
738
+ name: string;
739
+ display_name: string;
740
+ description: string;
741
+ tags: string[];
742
+ follow_count: number;
743
+ /** Relative web path for opening or citing the playbook. */
744
+ url_path: string;
745
+ /** README ALFS path when available. */
746
+ readme?: string;
747
+ /** Cursor to pass as `cursor` / `current` for pagination. */
748
+ cursor: string;
749
+ }
750
+ interface TrendingPlaybooksResponse {
751
+ playbooks: TrendingPlaybookItem[];
752
+ has_next: boolean;
753
+ }
754
+ /**
755
+ * Public playbook discovery. Backed by alva-gateway REST and mirrors the
756
+ * GraphQL `trendingPlaybooks(cursor, sort, tags, keyword)` query.
757
+ */
758
+ declare class PlaybooksResource {
759
+ private client;
760
+ constructor(client: AlvaClient);
761
+ /**
762
+ * List trending / searchable playbooks. Auth is optional: when the client
763
+ * has an API key it is forwarded, otherwise this uses the public surface.
764
+ *
765
+ * The gateway returns a frontend-oriented preview payload; this SDK projects
766
+ * it into a smaller, agent-friendly shape.
767
+ */
768
+ trending(params?: TrendingPlaybooksParams): Promise<TrendingPlaybooksResponse>;
769
+ }
770
+
639
771
  declare class SecretsResource {
640
772
  private client;
641
773
  constructor(client: AlvaClient);
@@ -853,13 +985,28 @@ declare class NotificationsResource {
853
985
  listFeed(params: NotificationListParams): Promise<FeedNotificationListResponse>;
854
986
  }
855
987
 
988
+ declare class NotificationPreferencesResource {
989
+ private client;
990
+ constructor(client: AlvaClient);
991
+ /**
992
+ * List the caller's notification preference settings. Server defaults
993
+ * are included even when the caller has not explicitly stored a setting.
994
+ */
995
+ list(): Promise<NotificationPreferencesResponse>;
996
+ /**
997
+ * Enable or disable one notification preference.
998
+ */
999
+ update(params: NotificationPreferenceUpdateParams): Promise<NotificationPreferenceUpdateResponse>;
1000
+ }
1001
+
856
1002
  /**
857
1003
  * Personal push subscriptions — opt the caller in or out of personal
858
1004
  * DM/web push for a target. Independent of social follow:
859
1005
  *
860
1006
  * - `subscribePlaybook` / `subscribeFeed` do not start following.
861
1007
  * - `unsubscribePlaybook` / `unsubscribeFeed` do not unfollow.
862
- * - Following a playbook elsewhere will compound-subscribe automatically.
1008
+ * - Following a playbook elsewhere does not create or revive a push
1009
+ * subscription.
863
1010
  *
864
1011
  * Backed by alva-gateway REST (mirrors the GraphQL surface in
865
1012
  * `pkg/schema/push_subscription.graphql`).
@@ -892,9 +1039,8 @@ declare class PushSubscriptionsResource {
892
1039
  */
893
1040
  unsubscribeFeed(params: PushSubscriptionFeedParams): Promise<UnsubscribePushTargetResponse>;
894
1041
  /**
895
- * List the caller's personal push subscriptions across all targets
896
- * (playbook + feed). Defaults to currently-active rows only; pass
897
- * `include_history=true` to also return previously-unsubscribed rows.
1042
+ * List the caller's currently active personal push subscriptions.
1043
+ * Results are cursor-paginated.
898
1044
  */
899
1045
  list(params?: PushSubscriptionListParams): Promise<PushSubscriptionListResponse>;
900
1046
  }
@@ -931,11 +1077,17 @@ declare class AlvaClient {
931
1077
  readonly baseUrl: string;
932
1078
  readonly arraysBaseUrl: string;
933
1079
  readonly viewer_token?: string;
1080
+ readonly pbsvToken?: string;
934
1081
  readonly apiKey?: string;
1082
+ readonly gaClientId?: string;
1083
+ readonly gaSessionId?: string;
1084
+ readonly utmParams?: string;
935
1085
  private _fs?;
936
1086
  private _run?;
937
1087
  private _deploy?;
938
1088
  private _release?;
1089
+ private _feed?;
1090
+ private _playbooks?;
939
1091
  private _secrets?;
940
1092
  private _sdk?;
941
1093
  private _dataSkills?;
@@ -947,6 +1099,7 @@ declare class AlvaClient {
947
1099
  private _trading?;
948
1100
  private _arraysJwt?;
949
1101
  private _notifications?;
1102
+ private _notificationPreferences?;
950
1103
  private _pushSubscriptions?;
951
1104
  private _channelGroupSubscriptions?;
952
1105
  constructor(config: AlvaClientConfig);
@@ -954,6 +1107,8 @@ declare class AlvaClient {
954
1107
  get run(): RunResource;
955
1108
  get deploy(): DeployResource;
956
1109
  get release(): ReleaseResource;
1110
+ get feed(): FeedResource;
1111
+ get playbooks(): PlaybooksResource;
957
1112
  get secrets(): SecretsResource;
958
1113
  get sdk(): SdkDocsResource;
959
1114
  get dataSkills(): DataSkillsResource;
@@ -965,6 +1120,7 @@ declare class AlvaClient {
965
1120
  get trading(): TradingResource;
966
1121
  get arraysJwt(): ArraysJwtResource;
967
1122
  get notifications(): NotificationsResource;
1123
+ get notificationPreferences(): NotificationPreferencesResource;
968
1124
  get pushSubscriptions(): PushSubscriptionsResource;
969
1125
  get channelGroupSubscriptions(): ChannelGroupSubscriptionsResource;
970
1126
  _requireAuth(): void;
@@ -977,7 +1133,110 @@ declare class AlvaError extends Error {
977
1133
  constructor(code: string, message: string, status: number);
978
1134
  }
979
1135
 
1136
+ type UdfErrorCode = 'PBSV_EXPIRED' | 'PBSV_INVALID' | 'PBSV_PID_MISMATCH' | 'CONSENT_REQUIRED' | 'INSUFFICIENT_CREDITS' | 'FUNCTION_NOT_FOUND' | 'FUNCTION_DISABLED' | 'RESOURCE_EXHAUSTED' | 'EXECUTION_FAILED' | 'UNAUTHENTICATED' | 'PERMISSION_DENIED' | 'INTERNAL';
1137
+ type UdfErrorBody = {
1138
+ error?: {
1139
+ code?: UdfErrorCode | string;
1140
+ message?: string;
1141
+ metadata?: Record<string, unknown>;
1142
+ };
1143
+ details?: {
1144
+ metadata?: Record<string, unknown>;
1145
+ };
1146
+ };
1147
+ type UdfDescriptor = {
1148
+ name: string;
1149
+ params_schema: unknown | null;
1150
+ };
1151
+ type UdfButtonOptions = {
1152
+ functionName: string;
1153
+ params?: unknown;
1154
+ label?: string;
1155
+ loadingLabel?: string;
1156
+ disabledLabel?: string;
1157
+ };
1158
+ type UdfButtonEventDetail<TResult = unknown> = {
1159
+ functionName: string;
1160
+ result?: TResult;
1161
+ error?: unknown;
1162
+ };
1163
+ type UdfApi = {
1164
+ call: <TResult = unknown>(functionName: string, params: unknown) => Promise<TResult>;
1165
+ list: () => Promise<UdfDescriptor[]>;
1166
+ getViewerToken: () => string | null;
1167
+ renderButton: (target: HTMLElement | string, options: UdfButtonOptions) => HTMLButtonElement;
1168
+ UdfError: typeof UdfError;
1169
+ UdfAuthRequiredError: typeof UdfAuthRequiredError;
1170
+ UdfTokenExpiredError: typeof UdfTokenExpiredError;
1171
+ UdfTokenInvalidError: typeof UdfTokenInvalidError;
1172
+ UdfPidMismatchError: typeof UdfPidMismatchError;
1173
+ UdfConsentRequiredError: typeof UdfConsentRequiredError;
1174
+ UdfConsentDeniedError: typeof UdfConsentDeniedError;
1175
+ UdfConsentTimeoutError: typeof UdfConsentTimeoutError;
1176
+ UdfInsufficientCredits: typeof UdfInsufficientCredits;
1177
+ UdfFunctionNotFoundError: typeof UdfFunctionNotFoundError;
1178
+ UdfFunctionDisabledError: typeof UdfFunctionDisabledError;
1179
+ UdfRateLimitedError: typeof UdfRateLimitedError;
1180
+ UdfExecutionError: typeof UdfExecutionError;
1181
+ UdfTransportError: typeof UdfTransportError;
1182
+ };
1183
+ declare global {
1184
+ interface Window {
1185
+ alva?: {
1186
+ udf?: UdfApi;
1187
+ [key: string]: unknown;
1188
+ };
1189
+ }
1190
+ }
1191
+ declare class UdfError extends Error {
1192
+ readonly code: string;
1193
+ readonly metadata: Record<string, unknown>;
1194
+ readonly status?: number;
1195
+ constructor(message: string, { code, metadata, status, }: {
1196
+ code: string;
1197
+ metadata?: Record<string, unknown>;
1198
+ status?: number;
1199
+ });
1200
+ }
1201
+ declare class UdfAuthRequiredError extends UdfError {
1202
+ constructor();
1203
+ }
1204
+ declare class UdfTokenExpiredError extends UdfError {
1205
+ }
1206
+ declare class UdfTokenInvalidError extends UdfError {
1207
+ }
1208
+ declare class UdfPidMismatchError extends UdfError {
1209
+ }
1210
+ declare class UdfConsentRequiredError extends UdfError {
1211
+ }
1212
+ declare class UdfConsentDeniedError extends UdfError {
1213
+ constructor();
1214
+ }
1215
+ declare class UdfConsentTimeoutError extends UdfError {
1216
+ constructor();
1217
+ }
1218
+ declare class UdfInsufficientCredits extends UdfError {
1219
+ }
1220
+ declare class UdfFunctionNotFoundError extends UdfError {
1221
+ }
1222
+ declare class UdfFunctionDisabledError extends UdfError {
1223
+ }
1224
+ declare class UdfRateLimitedError extends UdfError {
1225
+ }
1226
+ declare class UdfExecutionError extends UdfError {
1227
+ }
1228
+ declare class UdfTransportError extends UdfError {
1229
+ }
1230
+ declare const PBSV_UPDATE_MESSAGE = "alva:pbsv:update";
1231
+ declare const UDF_CONSENT_REQUEST_MESSAGE = "alva:udf:consent-request";
1232
+ declare const UDF_CONSENT_RESPONSE_MESSAGE = "alva:udf:consent-response";
1233
+ declare const playbookIdFromToken: (token: string | null) => string | null;
1234
+ declare const getViewerToken: () => string | null;
1235
+ declare const mapUdfErrorResponse: (body: UdfErrorBody, status?: number) => UdfError;
1236
+ declare const udf: UdfApi;
1237
+ declare const installPlaybookRuntime: (targetWindow?: Window) => void;
1238
+
980
1239
  /** SDK version, injected at build time from package.json. */
981
1240
  declare const VERSION: string;
982
1241
 
983
- 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 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 SkillDoc, type SkillEndpointMetadata, type SkillEndpointTier, type SkillMetadata, type SkillSummary, VERSION };
1242
+ 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 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 SkillDoc, type SkillEndpointMetadata, type SkillEndpointTier, type SkillMetadata, type SkillSummary, type TrendingPlaybookItem, type TrendingPlaybooksDir, type TrendingPlaybooksParams, type TrendingPlaybooksResponse, type TrendingPlaybooksSort, 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, UdfPidMismatchError, UdfRateLimitedError, UdfTokenExpiredError, UdfTokenInvalidError, UdfTransportError, VERSION, getViewerToken, installPlaybookRuntime, mapUdfErrorResponse, playbookIdFromToken, udf };