@alva-ai/toolkit 0.2.1 → 0.4.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
@@ -2,12 +2,27 @@ interface AlvaClientConfig {
2
2
  viewer_token?: string;
3
3
  apiKey?: string;
4
4
  baseUrl?: string;
5
+ arraysBaseUrl?: string;
5
6
  }
6
7
  interface UserProfile {
7
8
  id: number;
8
9
  username: string;
9
10
  subscription_tier: 'free' | 'pro';
10
11
  telegram_username: string | null;
12
+ /** Caller's alfs home directory, e.g. `/alva/home/<username>`. */
13
+ home_path: string;
14
+ }
15
+ type SubscriptionTier = 'SUBSCRIPTION_TIER_UNSPECIFIED' | 'SUBSCRIPTION_TIER_FREE' | 'SUBSCRIPTION_TIER_PRO';
16
+ interface EnsureArraysJwtResponse {
17
+ expires_at: number;
18
+ tier: SubscriptionTier;
19
+ renewed: boolean;
20
+ }
21
+ interface ArraysJwtStatusResponse {
22
+ exists: boolean;
23
+ expires_at: number;
24
+ tier: SubscriptionTier;
25
+ renewal_needed: boolean;
11
26
  }
12
27
  interface FsReadParams {
13
28
  path: string;
@@ -168,11 +183,14 @@ interface FeedReleaseRequest {
168
183
  cronjob_id: number;
169
184
  view_json?: Record<string, unknown>;
170
185
  description?: string;
186
+ changelog?: string;
171
187
  }
172
188
  interface FeedReleaseResponse {
173
189
  feed_id: number;
174
190
  name: string;
175
191
  feed_major: number;
192
+ /** Canonical alfs path: `/alva/home/<username>/feeds/<name>`. */
193
+ feed_path: string;
176
194
  }
177
195
  interface PlaybookDraftRequest {
178
196
  name: string;
@@ -183,11 +201,12 @@ interface PlaybookDraftRequest {
183
201
  feed_major?: number;
184
202
  }>;
185
203
  trading_symbols?: string[];
186
- changelog?: string;
187
204
  }
188
205
  interface PlaybookDraftResponse {
189
206
  playbook_id: number;
190
207
  playbook_version_id: number;
208
+ /** Canonical alfs path: `/alva/home/<username>/playbooks/<name>`. */
209
+ playbook_path: string;
191
210
  }
192
211
  interface PlaybookReleaseRequest {
193
212
  name: string;
@@ -202,6 +221,8 @@ interface PlaybookReleaseResponse {
202
221
  playbook_id: number;
203
222
  version: string;
204
223
  published_url: string;
224
+ /** Canonical alfs path: `/alva/home/<username>/playbooks/<name>`. */
225
+ playbook_path: string;
205
226
  }
206
227
  interface CreateSecretRequest {
207
228
  name: string;
@@ -359,6 +380,91 @@ interface ExecuteSignalResult {
359
380
  orders: ExecuteSignalOrder[];
360
381
  error?: string;
361
382
  }
383
+ interface NotificationListParams {
384
+ username: string;
385
+ name: string;
386
+ channel?: string;
387
+ /** `sent` / `failed` / `filtered`. */
388
+ status?: string;
389
+ /** Unix seconds; only notifications newer than this. */
390
+ since_time?: number;
391
+ /** Page size, default 50, max 200. */
392
+ first?: number;
393
+ /** Opaque cursor token from previous page's `next_cursor`. */
394
+ cursor?: string;
395
+ }
396
+ interface NotificationEvent {
397
+ id: string;
398
+ event_type: string;
399
+ user_id: string;
400
+ channel: string;
401
+ /** `sent` / `failed` / `filtered`. */
402
+ status: string;
403
+ /** Unix seconds. */
404
+ created_at: number;
405
+ message?: string;
406
+ error_msg?: string;
407
+ /** Present when notification is playbook-scoped. */
408
+ playbook_id?: string;
409
+ /** Present when notification is feed-scoped. */
410
+ feed_id?: string;
411
+ }
412
+ interface PlaybookNotificationListResponse {
413
+ items: NotificationEvent[];
414
+ /** Empty when there is no next page. */
415
+ next_cursor: string;
416
+ /** Canonical alfs path: `/alva/home/<username>/playbooks/<name>`. */
417
+ playbook_path: string;
418
+ }
419
+ interface FeedNotificationListResponse {
420
+ items: NotificationEvent[];
421
+ next_cursor: string;
422
+ /** Canonical alfs path: `/alva/home/<username>/feeds/<name>`. */
423
+ feed_path: string;
424
+ }
425
+ /**
426
+ * Identifies the asset a personal push subscription is keyed to.
427
+ * `PLAYBOOK` is the only target supported today; `FEED` is reserved for
428
+ * a future phase where users can subscribe to a feed independent of any
429
+ * playbook that consumes it.
430
+ */
431
+ type PushTargetType = 'PLAYBOOK' | 'FEED' | 'UNSPECIFIED';
432
+ interface PushTarget {
433
+ type: PushTargetType;
434
+ /** Numeric id encoded as a string (matches the rest of the SDK). */
435
+ id: string;
436
+ }
437
+ interface PushSubscription {
438
+ target: PushTarget;
439
+ /**
440
+ * `true` when the row is currently active. `false` means the user
441
+ * previously subscribed and then unsubscribed; the row is preserved
442
+ * so re-subscribe restores seniority via UPSERT-revive. Only present
443
+ * when `include_history=true` is passed to `list`.
444
+ */
445
+ subscribed: boolean;
446
+ created_at_ms: number;
447
+ updated_at_ms: number;
448
+ }
449
+ interface PushSubscriptionPlaybookParams {
450
+ username: string;
451
+ name: string;
452
+ }
453
+ interface PushSubscriptionListParams {
454
+ /** Default `false`. When `true`, include rows with `subscribed=false`. */
455
+ include_history?: boolean;
456
+ }
457
+ interface PushSubscriptionListResponse {
458
+ items: PushSubscription[];
459
+ }
460
+ interface SubscribePushTargetResponse {
461
+ subscription: PushSubscription;
462
+ /** Canonical alfs path: `/alva/home/<username>/playbooks/<name>`. */
463
+ playbook_path: string;
464
+ }
465
+ interface UnsubscribePushTargetResponse {
466
+ ok: true;
467
+ }
362
468
 
363
469
  declare class FsResource {
364
470
  private client;
@@ -456,6 +562,30 @@ declare class SdkDocsResource {
456
562
  }): Promise<PartitionSummaryResponse>;
457
563
  }
458
564
 
565
+ interface SkillSummary {
566
+ name: string;
567
+ description: string;
568
+ }
569
+ interface SkillDoc {
570
+ name: string;
571
+ description: string;
572
+ content: string;
573
+ }
574
+ declare class SkillsResource {
575
+ private client;
576
+ constructor(client: AlvaClient);
577
+ list(): Promise<{
578
+ skills: SkillSummary[];
579
+ }>;
580
+ summary(params: {
581
+ name: string;
582
+ }): Promise<SkillDoc>;
583
+ endpoint(params: {
584
+ name: string;
585
+ file: string;
586
+ }): Promise<SkillDoc>;
587
+ }
588
+
459
589
  declare class CommentsResource {
460
590
  private client;
461
591
  constructor(client: AlvaClient);
@@ -526,14 +656,79 @@ declare class TradingResource {
526
656
  updateRiskRules(rules: TradingRiskRuleInput): Promise<TradingRiskRule>;
527
657
  }
528
658
 
659
+ declare class ArraysJwtResource {
660
+ private client;
661
+ constructor(client: AlvaClient);
662
+ /** Idempotently sign-or-renew the Arrays JWT server-side. */
663
+ ensure(): Promise<EnsureArraysJwtResponse>;
664
+ /** Report the current Arrays JWT state for the authenticated user. */
665
+ status(): Promise<ArraysJwtStatusResponse>;
666
+ }
667
+
668
+ declare class NotificationsResource {
669
+ private client;
670
+ constructor(client: AlvaClient);
671
+ /**
672
+ * List the caller's notification history for one playbook
673
+ * `(username, name)`. Returns `NOT_FOUND` when the playbook is
674
+ * private or does not exist (the two cases are deliberately
675
+ * indistinguishable to prevent namespace enumeration).
676
+ */
677
+ listPlaybook(params: NotificationListParams): Promise<PlaybookNotificationListResponse>;
678
+ /**
679
+ * List the caller's notification history for one feed
680
+ * `(username, name)`. Authorization is alfs read on
681
+ * `/alva/home/<username>/feeds/<name>`.
682
+ */
683
+ listFeed(params: NotificationListParams): Promise<FeedNotificationListResponse>;
684
+ }
685
+
686
+ /**
687
+ * Personal push subscriptions — opt the caller in or out of personal
688
+ * DM/web push for a target. Independent of social follow:
689
+ *
690
+ * - `subscribePlaybook` does not start following.
691
+ * - `unsubscribePlaybook` does not unfollow.
692
+ * - Following a playbook elsewhere will compound-subscribe automatically.
693
+ *
694
+ * Backed by alva-gateway REST (mirrors the GraphQL surface in
695
+ * `pkg/schema/push_subscription.graphql`).
696
+ */
697
+ declare class PushSubscriptionsResource {
698
+ private client;
699
+ constructor(client: AlvaClient);
700
+ /**
701
+ * Opt into personal push for one playbook `(username, name)`.
702
+ * Idempotent. Auth: callers must be able to read the playbook
703
+ * (public/paid pass; private requires explicit alfs grant).
704
+ */
705
+ subscribePlaybook(params: PushSubscriptionPlaybookParams): Promise<SubscribePushTargetResponse>;
706
+ /**
707
+ * Soft-disable personal push for one playbook `(username, name)`.
708
+ * Does NOT remove any social follow. Idempotent.
709
+ */
710
+ unsubscribePlaybook(params: PushSubscriptionPlaybookParams): Promise<UnsubscribePushTargetResponse>;
711
+ /**
712
+ * List the caller's personal push subscriptions across all targets.
713
+ * Defaults to currently-active rows only; pass `include_history=true`
714
+ * to also return previously-unsubscribed rows.
715
+ */
716
+ list(params?: PushSubscriptionListParams): Promise<PushSubscriptionListResponse>;
717
+ }
718
+
529
719
  interface RequestOptions {
530
720
  query?: Record<string, unknown>;
531
721
  body?: unknown;
532
722
  /** Send raw body with application/octet-stream content type (for binary writes). */
533
723
  rawBody?: BodyInit;
724
+ /** Override the base URL for this request (e.g. the Arrays data-tools endpoint). */
725
+ baseUrl?: string;
726
+ /** If true, skip attaching any Alva auth header (X-Alva-Api-Key / x-Playbook-Viewer). */
727
+ noAuth?: boolean;
534
728
  }
535
729
  declare class AlvaClient {
536
730
  readonly baseUrl: string;
731
+ readonly arraysBaseUrl: string;
537
732
  readonly viewer_token?: string;
538
733
  readonly apiKey?: string;
539
734
  private _fs?;
@@ -542,11 +737,15 @@ declare class AlvaClient {
542
737
  private _release?;
543
738
  private _secrets?;
544
739
  private _sdk?;
740
+ private _skills?;
545
741
  private _comments?;
546
742
  private _remix?;
547
743
  private _screenshot?;
548
744
  private _user?;
549
745
  private _trading?;
746
+ private _arraysJwt?;
747
+ private _notifications?;
748
+ private _pushSubscriptions?;
550
749
  constructor(config: AlvaClientConfig);
551
750
  get fs(): FsResource;
552
751
  get run(): RunResource;
@@ -554,11 +753,15 @@ declare class AlvaClient {
554
753
  get release(): ReleaseResource;
555
754
  get secrets(): SecretsResource;
556
755
  get sdk(): SdkDocsResource;
756
+ get skills(): SkillsResource;
557
757
  get comments(): CommentsResource;
558
758
  get remix(): RemixResource;
559
759
  get screenshot(): ScreenshotResource;
560
760
  get user(): UserResource;
561
761
  get trading(): TradingResource;
762
+ get arraysJwt(): ArraysJwtResource;
763
+ get notifications(): NotificationsResource;
764
+ get pushSubscriptions(): PushSubscriptionsResource;
562
765
  _requireAuth(): void;
563
766
  _request(method: string, path: string, options?: RequestOptions): Promise<unknown>;
564
767
  }
package/dist/index.d.ts CHANGED
@@ -2,12 +2,27 @@ interface AlvaClientConfig {
2
2
  viewer_token?: string;
3
3
  apiKey?: string;
4
4
  baseUrl?: string;
5
+ arraysBaseUrl?: string;
5
6
  }
6
7
  interface UserProfile {
7
8
  id: number;
8
9
  username: string;
9
10
  subscription_tier: 'free' | 'pro';
10
11
  telegram_username: string | null;
12
+ /** Caller's alfs home directory, e.g. `/alva/home/<username>`. */
13
+ home_path: string;
14
+ }
15
+ type SubscriptionTier = 'SUBSCRIPTION_TIER_UNSPECIFIED' | 'SUBSCRIPTION_TIER_FREE' | 'SUBSCRIPTION_TIER_PRO';
16
+ interface EnsureArraysJwtResponse {
17
+ expires_at: number;
18
+ tier: SubscriptionTier;
19
+ renewed: boolean;
20
+ }
21
+ interface ArraysJwtStatusResponse {
22
+ exists: boolean;
23
+ expires_at: number;
24
+ tier: SubscriptionTier;
25
+ renewal_needed: boolean;
11
26
  }
12
27
  interface FsReadParams {
13
28
  path: string;
@@ -168,11 +183,14 @@ interface FeedReleaseRequest {
168
183
  cronjob_id: number;
169
184
  view_json?: Record<string, unknown>;
170
185
  description?: string;
186
+ changelog?: string;
171
187
  }
172
188
  interface FeedReleaseResponse {
173
189
  feed_id: number;
174
190
  name: string;
175
191
  feed_major: number;
192
+ /** Canonical alfs path: `/alva/home/<username>/feeds/<name>`. */
193
+ feed_path: string;
176
194
  }
177
195
  interface PlaybookDraftRequest {
178
196
  name: string;
@@ -183,11 +201,12 @@ interface PlaybookDraftRequest {
183
201
  feed_major?: number;
184
202
  }>;
185
203
  trading_symbols?: string[];
186
- changelog?: string;
187
204
  }
188
205
  interface PlaybookDraftResponse {
189
206
  playbook_id: number;
190
207
  playbook_version_id: number;
208
+ /** Canonical alfs path: `/alva/home/<username>/playbooks/<name>`. */
209
+ playbook_path: string;
191
210
  }
192
211
  interface PlaybookReleaseRequest {
193
212
  name: string;
@@ -202,6 +221,8 @@ interface PlaybookReleaseResponse {
202
221
  playbook_id: number;
203
222
  version: string;
204
223
  published_url: string;
224
+ /** Canonical alfs path: `/alva/home/<username>/playbooks/<name>`. */
225
+ playbook_path: string;
205
226
  }
206
227
  interface CreateSecretRequest {
207
228
  name: string;
@@ -359,6 +380,91 @@ interface ExecuteSignalResult {
359
380
  orders: ExecuteSignalOrder[];
360
381
  error?: string;
361
382
  }
383
+ interface NotificationListParams {
384
+ username: string;
385
+ name: string;
386
+ channel?: string;
387
+ /** `sent` / `failed` / `filtered`. */
388
+ status?: string;
389
+ /** Unix seconds; only notifications newer than this. */
390
+ since_time?: number;
391
+ /** Page size, default 50, max 200. */
392
+ first?: number;
393
+ /** Opaque cursor token from previous page's `next_cursor`. */
394
+ cursor?: string;
395
+ }
396
+ interface NotificationEvent {
397
+ id: string;
398
+ event_type: string;
399
+ user_id: string;
400
+ channel: string;
401
+ /** `sent` / `failed` / `filtered`. */
402
+ status: string;
403
+ /** Unix seconds. */
404
+ created_at: number;
405
+ message?: string;
406
+ error_msg?: string;
407
+ /** Present when notification is playbook-scoped. */
408
+ playbook_id?: string;
409
+ /** Present when notification is feed-scoped. */
410
+ feed_id?: string;
411
+ }
412
+ interface PlaybookNotificationListResponse {
413
+ items: NotificationEvent[];
414
+ /** Empty when there is no next page. */
415
+ next_cursor: string;
416
+ /** Canonical alfs path: `/alva/home/<username>/playbooks/<name>`. */
417
+ playbook_path: string;
418
+ }
419
+ interface FeedNotificationListResponse {
420
+ items: NotificationEvent[];
421
+ next_cursor: string;
422
+ /** Canonical alfs path: `/alva/home/<username>/feeds/<name>`. */
423
+ feed_path: string;
424
+ }
425
+ /**
426
+ * Identifies the asset a personal push subscription is keyed to.
427
+ * `PLAYBOOK` is the only target supported today; `FEED` is reserved for
428
+ * a future phase where users can subscribe to a feed independent of any
429
+ * playbook that consumes it.
430
+ */
431
+ type PushTargetType = 'PLAYBOOK' | 'FEED' | 'UNSPECIFIED';
432
+ interface PushTarget {
433
+ type: PushTargetType;
434
+ /** Numeric id encoded as a string (matches the rest of the SDK). */
435
+ id: string;
436
+ }
437
+ interface PushSubscription {
438
+ target: PushTarget;
439
+ /**
440
+ * `true` when the row is currently active. `false` means the user
441
+ * previously subscribed and then unsubscribed; the row is preserved
442
+ * so re-subscribe restores seniority via UPSERT-revive. Only present
443
+ * when `include_history=true` is passed to `list`.
444
+ */
445
+ subscribed: boolean;
446
+ created_at_ms: number;
447
+ updated_at_ms: number;
448
+ }
449
+ interface PushSubscriptionPlaybookParams {
450
+ username: string;
451
+ name: string;
452
+ }
453
+ interface PushSubscriptionListParams {
454
+ /** Default `false`. When `true`, include rows with `subscribed=false`. */
455
+ include_history?: boolean;
456
+ }
457
+ interface PushSubscriptionListResponse {
458
+ items: PushSubscription[];
459
+ }
460
+ interface SubscribePushTargetResponse {
461
+ subscription: PushSubscription;
462
+ /** Canonical alfs path: `/alva/home/<username>/playbooks/<name>`. */
463
+ playbook_path: string;
464
+ }
465
+ interface UnsubscribePushTargetResponse {
466
+ ok: true;
467
+ }
362
468
 
363
469
  declare class FsResource {
364
470
  private client;
@@ -456,6 +562,30 @@ declare class SdkDocsResource {
456
562
  }): Promise<PartitionSummaryResponse>;
457
563
  }
458
564
 
565
+ interface SkillSummary {
566
+ name: string;
567
+ description: string;
568
+ }
569
+ interface SkillDoc {
570
+ name: string;
571
+ description: string;
572
+ content: string;
573
+ }
574
+ declare class SkillsResource {
575
+ private client;
576
+ constructor(client: AlvaClient);
577
+ list(): Promise<{
578
+ skills: SkillSummary[];
579
+ }>;
580
+ summary(params: {
581
+ name: string;
582
+ }): Promise<SkillDoc>;
583
+ endpoint(params: {
584
+ name: string;
585
+ file: string;
586
+ }): Promise<SkillDoc>;
587
+ }
588
+
459
589
  declare class CommentsResource {
460
590
  private client;
461
591
  constructor(client: AlvaClient);
@@ -526,14 +656,79 @@ declare class TradingResource {
526
656
  updateRiskRules(rules: TradingRiskRuleInput): Promise<TradingRiskRule>;
527
657
  }
528
658
 
659
+ declare class ArraysJwtResource {
660
+ private client;
661
+ constructor(client: AlvaClient);
662
+ /** Idempotently sign-or-renew the Arrays JWT server-side. */
663
+ ensure(): Promise<EnsureArraysJwtResponse>;
664
+ /** Report the current Arrays JWT state for the authenticated user. */
665
+ status(): Promise<ArraysJwtStatusResponse>;
666
+ }
667
+
668
+ declare class NotificationsResource {
669
+ private client;
670
+ constructor(client: AlvaClient);
671
+ /**
672
+ * List the caller's notification history for one playbook
673
+ * `(username, name)`. Returns `NOT_FOUND` when the playbook is
674
+ * private or does not exist (the two cases are deliberately
675
+ * indistinguishable to prevent namespace enumeration).
676
+ */
677
+ listPlaybook(params: NotificationListParams): Promise<PlaybookNotificationListResponse>;
678
+ /**
679
+ * List the caller's notification history for one feed
680
+ * `(username, name)`. Authorization is alfs read on
681
+ * `/alva/home/<username>/feeds/<name>`.
682
+ */
683
+ listFeed(params: NotificationListParams): Promise<FeedNotificationListResponse>;
684
+ }
685
+
686
+ /**
687
+ * Personal push subscriptions — opt the caller in or out of personal
688
+ * DM/web push for a target. Independent of social follow:
689
+ *
690
+ * - `subscribePlaybook` does not start following.
691
+ * - `unsubscribePlaybook` does not unfollow.
692
+ * - Following a playbook elsewhere will compound-subscribe automatically.
693
+ *
694
+ * Backed by alva-gateway REST (mirrors the GraphQL surface in
695
+ * `pkg/schema/push_subscription.graphql`).
696
+ */
697
+ declare class PushSubscriptionsResource {
698
+ private client;
699
+ constructor(client: AlvaClient);
700
+ /**
701
+ * Opt into personal push for one playbook `(username, name)`.
702
+ * Idempotent. Auth: callers must be able to read the playbook
703
+ * (public/paid pass; private requires explicit alfs grant).
704
+ */
705
+ subscribePlaybook(params: PushSubscriptionPlaybookParams): Promise<SubscribePushTargetResponse>;
706
+ /**
707
+ * Soft-disable personal push for one playbook `(username, name)`.
708
+ * Does NOT remove any social follow. Idempotent.
709
+ */
710
+ unsubscribePlaybook(params: PushSubscriptionPlaybookParams): Promise<UnsubscribePushTargetResponse>;
711
+ /**
712
+ * List the caller's personal push subscriptions across all targets.
713
+ * Defaults to currently-active rows only; pass `include_history=true`
714
+ * to also return previously-unsubscribed rows.
715
+ */
716
+ list(params?: PushSubscriptionListParams): Promise<PushSubscriptionListResponse>;
717
+ }
718
+
529
719
  interface RequestOptions {
530
720
  query?: Record<string, unknown>;
531
721
  body?: unknown;
532
722
  /** Send raw body with application/octet-stream content type (for binary writes). */
533
723
  rawBody?: BodyInit;
724
+ /** Override the base URL for this request (e.g. the Arrays data-tools endpoint). */
725
+ baseUrl?: string;
726
+ /** If true, skip attaching any Alva auth header (X-Alva-Api-Key / x-Playbook-Viewer). */
727
+ noAuth?: boolean;
534
728
  }
535
729
  declare class AlvaClient {
536
730
  readonly baseUrl: string;
731
+ readonly arraysBaseUrl: string;
537
732
  readonly viewer_token?: string;
538
733
  readonly apiKey?: string;
539
734
  private _fs?;
@@ -542,11 +737,15 @@ declare class AlvaClient {
542
737
  private _release?;
543
738
  private _secrets?;
544
739
  private _sdk?;
740
+ private _skills?;
545
741
  private _comments?;
546
742
  private _remix?;
547
743
  private _screenshot?;
548
744
  private _user?;
549
745
  private _trading?;
746
+ private _arraysJwt?;
747
+ private _notifications?;
748
+ private _pushSubscriptions?;
550
749
  constructor(config: AlvaClientConfig);
551
750
  get fs(): FsResource;
552
751
  get run(): RunResource;
@@ -554,11 +753,15 @@ declare class AlvaClient {
554
753
  get release(): ReleaseResource;
555
754
  get secrets(): SecretsResource;
556
755
  get sdk(): SdkDocsResource;
756
+ get skills(): SkillsResource;
557
757
  get comments(): CommentsResource;
558
758
  get remix(): RemixResource;
559
759
  get screenshot(): ScreenshotResource;
560
760
  get user(): UserResource;
561
761
  get trading(): TradingResource;
762
+ get arraysJwt(): ArraysJwtResource;
763
+ get notifications(): NotificationsResource;
764
+ get pushSubscriptions(): PushSubscriptionsResource;
562
765
  _requireAuth(): void;
563
766
  _request(method: string, path: string, options?: RequestOptions): Promise<unknown>;
564
767
  }