@alva-ai/toolkit 0.8.0 → 0.9.1

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;
@@ -431,6 +440,76 @@ interface ExecuteSignalResult {
431
440
  orders: ExecuteSignalOrder[];
432
441
  error?: string;
433
442
  }
443
+ interface PortfolioAccount {
444
+ id: string;
445
+ provider: 'TREX' | 'SNAPTRADE';
446
+ name: string;
447
+ institution: string;
448
+ identifier?: string;
449
+ readOnly: boolean;
450
+ paper: boolean;
451
+ exchange?: string;
452
+ createdAtMs?: number;
453
+ subscriptions: PortfolioAccountSubscription[];
454
+ status?: string;
455
+ statusReason?: string;
456
+ lastSyncedAtMs?: number;
457
+ connectionId?: string;
458
+ }
459
+ interface PortfolioAccountSubscription {
460
+ id: string;
461
+ sourceUsername: string;
462
+ sourceFeed: string;
463
+ playbookId: string;
464
+ playbookName: string;
465
+ playbookVersion: string;
466
+ active: boolean;
467
+ deactivateReason?: string;
468
+ createdAt: number;
469
+ watermark: number;
470
+ }
471
+ interface PortfolioMoney {
472
+ amount: number;
473
+ currency: string;
474
+ currencySymbol: string;
475
+ }
476
+ interface PortfolioHolding {
477
+ symbol: string;
478
+ side?: string;
479
+ quantity: number;
480
+ avgCost?: PortfolioMoney;
481
+ currentPrice?: PortfolioMoney;
482
+ marketValue?: PortfolioMoney;
483
+ unrealizedPnl?: PortfolioMoney;
484
+ allocation?: number;
485
+ }
486
+ interface PortfolioSummary {
487
+ totalValue?: PortfolioMoney;
488
+ cash?: PortfolioMoney;
489
+ unrealizedPnl?: PortfolioMoney;
490
+ holdings: PortfolioHolding[];
491
+ asOfMs?: number;
492
+ }
493
+ interface PortfolioActivity {
494
+ id: string;
495
+ kind: string;
496
+ type: string;
497
+ occurredAtMs?: number;
498
+ symbol?: string;
499
+ side?: string;
500
+ quantity?: number;
501
+ price?: PortfolioMoney;
502
+ amount?: PortfolioMoney;
503
+ fee?: PortfolioMoney;
504
+ status?: string;
505
+ sourceLabel?: string;
506
+ description?: string;
507
+ externalReferenceId?: string;
508
+ }
509
+ interface PortfolioActivityConnection {
510
+ activities: PortfolioActivity[];
511
+ nextPageToken?: string;
512
+ }
434
513
  interface NotificationListParams {
435
514
  username: string;
436
515
  name: string;
@@ -473,6 +552,21 @@ interface FeedNotificationListResponse {
473
552
  /** Canonical alfs path: `/alva/home/<username>/feeds/<name>`. */
474
553
  feed_path: string;
475
554
  }
555
+ type NotificationPreferenceKey = 'session_completed';
556
+ interface NotificationPreference {
557
+ key: NotificationPreferenceKey;
558
+ enabled: boolean;
559
+ }
560
+ interface NotificationPreferencesResponse {
561
+ settings: NotificationPreference[];
562
+ }
563
+ interface NotificationPreferenceUpdateParams {
564
+ key: NotificationPreferenceKey;
565
+ enabled: boolean;
566
+ }
567
+ interface NotificationPreferenceUpdateResponse {
568
+ setting: NotificationPreference;
569
+ }
476
570
  /**
477
571
  * Identifies the asset a personal push subscription is keyed to.
478
572
  * `PLAYBOOK` is the only target supported today; `FEED` is reserved for
@@ -685,6 +779,65 @@ declare class FeedResource {
685
779
  delete(params: FeedDeleteRequest): Promise<FeedDeleteResponse>;
686
780
  }
687
781
 
782
+ type TrendingPlaybooksSort = 'FOLLOWS' | 'RECENT';
783
+ type TrendingPlaybooksDir = 'FORWARD' | 'BACKWARD';
784
+ interface TrendingPlaybooksParams {
785
+ /** Opaque cursor returned on a previous item. Alias of `current`. */
786
+ cursor?: string;
787
+ /** GraphQL-compatible cursor field name. Alias of `cursor`. */
788
+ current?: string;
789
+ /** Page size, default 50, max 100 server-side. */
790
+ limit?: number;
791
+ /** Only FORWARD is supported by the gateway today. */
792
+ dir?: TrendingPlaybooksDir;
793
+ /** FOLLOWS = most followed, RECENT = newest first. */
794
+ sort?: TrendingPlaybooksSort;
795
+ /** Optional AND-filter tags. */
796
+ tags?: string[];
797
+ /** Optional weighted search across playbook and creator fields. */
798
+ keyword?: string;
799
+ }
800
+ interface TrendingPlaybookItem {
801
+ /** Numeric playbook id encoded as a string. */
802
+ id: string;
803
+ /** Stable "owner/name" handle, useful for follow-up tool calls. */
804
+ ref: string;
805
+ /** Owner username. */
806
+ username: string;
807
+ /** URL-safe playbook name. */
808
+ name: string;
809
+ display_name: string;
810
+ description: string;
811
+ tags: string[];
812
+ follow_count: number;
813
+ /** Relative web path for opening or citing the playbook. */
814
+ url_path: string;
815
+ /** README ALFS path when available. */
816
+ readme?: string;
817
+ /** Cursor to pass as `cursor` / `current` for pagination. */
818
+ cursor: string;
819
+ }
820
+ interface TrendingPlaybooksResponse {
821
+ playbooks: TrendingPlaybookItem[];
822
+ has_next: boolean;
823
+ }
824
+ /**
825
+ * Public playbook discovery. Backed by alva-gateway REST and mirrors the
826
+ * GraphQL `trendingPlaybooks(cursor, sort, tags, keyword)` query.
827
+ */
828
+ declare class PlaybooksResource {
829
+ private client;
830
+ constructor(client: AlvaClient);
831
+ /**
832
+ * List trending / searchable playbooks. Auth is optional: when the client
833
+ * has an API key it is forwarded, otherwise this uses the public surface.
834
+ *
835
+ * The gateway returns a frontend-oriented preview payload; this SDK projects
836
+ * it into a smaller, agent-friendly shape.
837
+ */
838
+ trending(params?: TrendingPlaybooksParams): Promise<TrendingPlaybooksResponse>;
839
+ }
840
+
688
841
  declare class SecretsResource {
689
842
  private client;
690
843
  constructor(client: AlvaClient);
@@ -875,6 +1028,18 @@ declare class TradingResource {
875
1028
  updateRiskRules(rules: TradingRiskRuleInput): Promise<TradingRiskRule>;
876
1029
  }
877
1030
 
1031
+ declare class PortfolioResource {
1032
+ private client;
1033
+ constructor(client: AlvaClient);
1034
+ accounts(): Promise<PortfolioAccount[]>;
1035
+ summary(accountId: string): Promise<PortfolioSummary>;
1036
+ activities(params: {
1037
+ accountId: string;
1038
+ limit?: number;
1039
+ pageToken?: string;
1040
+ }): Promise<PortfolioActivityConnection>;
1041
+ }
1042
+
878
1043
  declare class ArraysJwtResource {
879
1044
  private client;
880
1045
  constructor(client: AlvaClient);
@@ -902,6 +1067,20 @@ declare class NotificationsResource {
902
1067
  listFeed(params: NotificationListParams): Promise<FeedNotificationListResponse>;
903
1068
  }
904
1069
 
1070
+ declare class NotificationPreferencesResource {
1071
+ private client;
1072
+ constructor(client: AlvaClient);
1073
+ /**
1074
+ * List the caller's notification preference settings. Server defaults
1075
+ * are included even when the caller has not explicitly stored a setting.
1076
+ */
1077
+ list(): Promise<NotificationPreferencesResponse>;
1078
+ /**
1079
+ * Enable or disable one notification preference.
1080
+ */
1081
+ update(params: NotificationPreferenceUpdateParams): Promise<NotificationPreferenceUpdateResponse>;
1082
+ }
1083
+
905
1084
  /**
906
1085
  * Personal push subscriptions — opt the caller in or out of personal
907
1086
  * DM/web push for a target. Independent of social follow:
@@ -980,12 +1159,17 @@ declare class AlvaClient {
980
1159
  readonly baseUrl: string;
981
1160
  readonly arraysBaseUrl: string;
982
1161
  readonly viewer_token?: string;
1162
+ readonly pbsvToken?: string;
983
1163
  readonly apiKey?: string;
1164
+ readonly gaClientId?: string;
1165
+ readonly gaSessionId?: string;
1166
+ readonly utmParams?: string;
984
1167
  private _fs?;
985
1168
  private _run?;
986
1169
  private _deploy?;
987
1170
  private _release?;
988
1171
  private _feed?;
1172
+ private _playbooks?;
989
1173
  private _secrets?;
990
1174
  private _sdk?;
991
1175
  private _dataSkills?;
@@ -995,8 +1179,10 @@ declare class AlvaClient {
995
1179
  private _screenshot?;
996
1180
  private _user?;
997
1181
  private _trading?;
1182
+ private _portfolio?;
998
1183
  private _arraysJwt?;
999
1184
  private _notifications?;
1185
+ private _notificationPreferences?;
1000
1186
  private _pushSubscriptions?;
1001
1187
  private _channelGroupSubscriptions?;
1002
1188
  constructor(config: AlvaClientConfig);
@@ -1005,6 +1191,7 @@ declare class AlvaClient {
1005
1191
  get deploy(): DeployResource;
1006
1192
  get release(): ReleaseResource;
1007
1193
  get feed(): FeedResource;
1194
+ get playbooks(): PlaybooksResource;
1008
1195
  get secrets(): SecretsResource;
1009
1196
  get sdk(): SdkDocsResource;
1010
1197
  get dataSkills(): DataSkillsResource;
@@ -1014,8 +1201,10 @@ declare class AlvaClient {
1014
1201
  get screenshot(): ScreenshotResource;
1015
1202
  get user(): UserResource;
1016
1203
  get trading(): TradingResource;
1204
+ get portfolio(): PortfolioResource;
1017
1205
  get arraysJwt(): ArraysJwtResource;
1018
1206
  get notifications(): NotificationsResource;
1207
+ get notificationPreferences(): NotificationPreferencesResource;
1019
1208
  get pushSubscriptions(): PushSubscriptionsResource;
1020
1209
  get channelGroupSubscriptions(): ChannelGroupSubscriptionsResource;
1021
1210
  _requireAuth(): void;
@@ -1028,7 +1217,110 @@ declare class AlvaError extends Error {
1028
1217
  constructor(code: string, message: string, status: number);
1029
1218
  }
1030
1219
 
1220
+ 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';
1221
+ type UdfErrorBody = {
1222
+ error?: {
1223
+ code?: UdfErrorCode | string;
1224
+ message?: string;
1225
+ metadata?: Record<string, unknown>;
1226
+ };
1227
+ details?: {
1228
+ metadata?: Record<string, unknown>;
1229
+ };
1230
+ };
1231
+ type UdfDescriptor = {
1232
+ name: string;
1233
+ params_schema: unknown | null;
1234
+ };
1235
+ type UdfButtonOptions = {
1236
+ functionName: string;
1237
+ params?: unknown;
1238
+ label?: string;
1239
+ loadingLabel?: string;
1240
+ disabledLabel?: string;
1241
+ };
1242
+ type UdfButtonEventDetail<TResult = unknown> = {
1243
+ functionName: string;
1244
+ result?: TResult;
1245
+ error?: unknown;
1246
+ };
1247
+ type UdfApi = {
1248
+ call: <TResult = unknown>(functionName: string, params: unknown) => Promise<TResult>;
1249
+ list: () => Promise<UdfDescriptor[]>;
1250
+ getViewerToken: () => string | null;
1251
+ renderButton: (target: HTMLElement | string, options: UdfButtonOptions) => HTMLButtonElement;
1252
+ UdfError: typeof UdfError;
1253
+ UdfAuthRequiredError: typeof UdfAuthRequiredError;
1254
+ UdfTokenExpiredError: typeof UdfTokenExpiredError;
1255
+ UdfTokenInvalidError: typeof UdfTokenInvalidError;
1256
+ UdfPidMismatchError: typeof UdfPidMismatchError;
1257
+ UdfConsentRequiredError: typeof UdfConsentRequiredError;
1258
+ UdfConsentDeniedError: typeof UdfConsentDeniedError;
1259
+ UdfConsentTimeoutError: typeof UdfConsentTimeoutError;
1260
+ UdfInsufficientCredits: typeof UdfInsufficientCredits;
1261
+ UdfFunctionNotFoundError: typeof UdfFunctionNotFoundError;
1262
+ UdfFunctionDisabledError: typeof UdfFunctionDisabledError;
1263
+ UdfRateLimitedError: typeof UdfRateLimitedError;
1264
+ UdfExecutionError: typeof UdfExecutionError;
1265
+ UdfTransportError: typeof UdfTransportError;
1266
+ };
1267
+ declare global {
1268
+ interface Window {
1269
+ alva?: {
1270
+ udf?: UdfApi;
1271
+ [key: string]: unknown;
1272
+ };
1273
+ }
1274
+ }
1275
+ declare class UdfError extends Error {
1276
+ readonly code: string;
1277
+ readonly metadata: Record<string, unknown>;
1278
+ readonly status?: number;
1279
+ constructor(message: string, { code, metadata, status, }: {
1280
+ code: string;
1281
+ metadata?: Record<string, unknown>;
1282
+ status?: number;
1283
+ });
1284
+ }
1285
+ declare class UdfAuthRequiredError extends UdfError {
1286
+ constructor();
1287
+ }
1288
+ declare class UdfTokenExpiredError extends UdfError {
1289
+ }
1290
+ declare class UdfTokenInvalidError extends UdfError {
1291
+ }
1292
+ declare class UdfPidMismatchError extends UdfError {
1293
+ }
1294
+ declare class UdfConsentRequiredError extends UdfError {
1295
+ }
1296
+ declare class UdfConsentDeniedError extends UdfError {
1297
+ constructor();
1298
+ }
1299
+ declare class UdfConsentTimeoutError extends UdfError {
1300
+ constructor();
1301
+ }
1302
+ declare class UdfInsufficientCredits extends UdfError {
1303
+ }
1304
+ declare class UdfFunctionNotFoundError extends UdfError {
1305
+ }
1306
+ declare class UdfFunctionDisabledError extends UdfError {
1307
+ }
1308
+ declare class UdfRateLimitedError extends UdfError {
1309
+ }
1310
+ declare class UdfExecutionError extends UdfError {
1311
+ }
1312
+ declare class UdfTransportError extends UdfError {
1313
+ }
1314
+ declare const PBSV_UPDATE_MESSAGE = "alva:pbsv:update";
1315
+ declare const UDF_CONSENT_REQUEST_MESSAGE = "alva:udf:consent-request";
1316
+ declare const UDF_CONSENT_RESPONSE_MESSAGE = "alva:udf:consent-response";
1317
+ declare const playbookIdFromToken: (token: string | null) => string | null;
1318
+ declare const getViewerToken: () => string | null;
1319
+ declare const mapUdfErrorResponse: (body: UdfErrorBody, status?: number) => UdfError;
1320
+ declare const udf: UdfApi;
1321
+ declare const installPlaybookRuntime: (targetWindow?: Window) => void;
1322
+
1031
1323
  /** SDK version, injected at build time from package.json. */
1032
1324
  declare const VERSION: string;
1033
1325
 
1034
- 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 SkillDoc, type SkillEndpointMetadata, type SkillEndpointTier, type SkillMetadata, type SkillSummary, VERSION };
1326
+ 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 };