@alva-ai/toolkit 0.34.0 → 0.36.0-beta.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.d.ts CHANGED
@@ -2015,6 +2015,142 @@ declare class SubscriptionsResource {
2015
2015
  unsubscribeBatch(params: UnsubscribeBatchParams): Promise<UnsubscribeBatchResponse>;
2016
2016
  }
2017
2017
 
2018
+ /** Market entity kinds that can be added to the watchlist. */
2019
+ type WatchlistTickerKind = 'STOCK' | 'ETF' | 'CRYPTO';
2020
+ /** Public profile kinds: USER is an Alva user, PERSON a curated person. */
2021
+ type FollowProfileKind = 'USER' | 'PERSON';
2022
+ /** One requested symbol with an optional kind for just that symbol. */
2023
+ interface WatchlistTickerSpec {
2024
+ ticker: string;
2025
+ kind?: WatchlistTickerKind;
2026
+ }
2027
+ interface WatchlistTickersParams {
2028
+ /**
2029
+ * 1-50 ticker symbols, matched exactly (case-insensitive). A spec's own
2030
+ * kind overrides `kind`, so one call can mix kinds (NVDA and BTC:crypto).
2031
+ */
2032
+ tickers: Array<string | WatchlistTickerSpec>;
2033
+ /** Default kind for tickers without their own kind. */
2034
+ kind?: WatchlistTickerKind;
2035
+ }
2036
+ interface ResolvedTicker {
2037
+ /** The symbol as the caller supplied it, normalized to upper case. */
2038
+ input: string;
2039
+ entityId: string;
2040
+ ticker: string;
2041
+ name: string;
2042
+ kind: string;
2043
+ }
2044
+ interface UnresolvedTicker {
2045
+ input: string;
2046
+ /** The kind the lookup was restricted to, when one was given. */
2047
+ kind?: WatchlistTickerKind;
2048
+ /** NOT_FOUND or FAILED_PRECONDITION (several entities share the symbol). */
2049
+ code: string;
2050
+ message: string;
2051
+ }
2052
+ interface AddToWatchlistResult {
2053
+ /** Tickers newly added to the watchlist by this call. */
2054
+ added: ResolvedTicker[];
2055
+ /** Tickers already in the watchlist; nothing was written for them. */
2056
+ unchanged: ResolvedTicker[];
2057
+ unresolved: UnresolvedTicker[];
2058
+ }
2059
+ interface RemoveFromWatchlistResult {
2060
+ /** Tickers removed from the watchlist by this call. */
2061
+ removed: ResolvedTicker[];
2062
+ /**
2063
+ * Tickers that were not in the watchlist. The removal is still recorded, so
2064
+ * holdings sync will not add them later.
2065
+ */
2066
+ unchanged: ResolvedTicker[];
2067
+ unresolved: UnresolvedTicker[];
2068
+ }
2069
+ interface FollowPageParams {
2070
+ first?: number;
2071
+ after?: string;
2072
+ }
2073
+ interface FollowPageInfo {
2074
+ endCursor: string;
2075
+ hasNextPage: boolean;
2076
+ }
2077
+ interface WatchlistTicker {
2078
+ entityId: string;
2079
+ ticker: string;
2080
+ name: string;
2081
+ kind: string;
2082
+ addedAtMs: number;
2083
+ }
2084
+ interface WatchlistPage {
2085
+ totalCount: number;
2086
+ tickers: WatchlistTicker[];
2087
+ pageInfo: FollowPageInfo;
2088
+ }
2089
+ interface FollowProfile {
2090
+ kind: FollowProfileKind;
2091
+ id: string;
2092
+ displayName: string;
2093
+ /** Alva username; USER profiles only. */
2094
+ username?: string;
2095
+ /** URL slug; PERSON profiles only. */
2096
+ slug?: string;
2097
+ /** X handle without "@"; PERSON profiles only, null when absent. */
2098
+ xHandle?: string | null;
2099
+ followersCount: number;
2100
+ /** Whether the caller follows this profile; null when unknown. */
2101
+ following: boolean | null;
2102
+ }
2103
+ interface SearchProfilesParams {
2104
+ query: string;
2105
+ kind?: FollowProfileKind;
2106
+ first?: number;
2107
+ }
2108
+ interface ProfileRefParams {
2109
+ kind: FollowProfileKind;
2110
+ id: string;
2111
+ }
2112
+ interface FollowedProfilesParams extends FollowPageParams {
2113
+ kind?: FollowProfileKind;
2114
+ }
2115
+ interface ProfilesPage {
2116
+ profiles: FollowProfile[];
2117
+ pageInfo: FollowPageInfo;
2118
+ }
2119
+ interface ProfileFollowResult {
2120
+ following: boolean;
2121
+ profile: FollowProfile | null;
2122
+ }
2123
+ /**
2124
+ * The Alva App's ticker watchlist (add/remove) and people follows (Alva users
2125
+ * and curated people). Gateway stores watchlist entries as ticker follows.
2126
+ * Playbook follows stay in `client.subscriptions`; Thesis bookmarks are
2127
+ * Thesis star/unstar. The user always comes from the API key; there is no
2128
+ * identity override.
2129
+ */
2130
+ declare class FollowsResource {
2131
+ private client;
2132
+ constructor(client: AlvaClient);
2133
+ /** Add tickers to the watchlist by exact symbol in one atomic batch. */
2134
+ addToWatchlist(params: WatchlistTickersParams): Promise<AddToWatchlistResult>;
2135
+ /** Remove tickers from the watchlist by exact symbol in one atomic batch. */
2136
+ removeFromWatchlist(params: WatchlistTickersParams): Promise<RemoveFromWatchlistResult>;
2137
+ /** One page of the watchlist, most recently added first. */
2138
+ watchlist(params?: FollowPageParams): Promise<WatchlistPage>;
2139
+ /** Search public profiles (Alva users and curated people). */
2140
+ searchProfiles(params: SearchProfilesParams): Promise<ProfilesPage>;
2141
+ /** One page of profiles the caller follows. */
2142
+ profiles(params?: FollowedProfilesParams): Promise<ProfilesPage>;
2143
+ /** Follow one profile. Idempotent. */
2144
+ followProfile(params: ProfileRefParams): Promise<ProfileFollowResult>;
2145
+ /** Unfollow one profile. Idempotent. */
2146
+ unfollowProfile(params: ProfileRefParams): Promise<ProfileFollowResult>;
2147
+ private profilesPage;
2148
+ private changeProfile;
2149
+ private changeWatchlist;
2150
+ private lookupTickers;
2151
+ private lookupTicker;
2152
+ }
2153
+
2018
2154
  /**
2019
2155
  * Product-facing alert API. The current transport still calls the legacy
2020
2156
  * subscription and notification-history endpoints.
@@ -2389,7 +2525,7 @@ interface StewardSendParams extends StewardTarget {
2389
2525
  }
2390
2526
  type StewardSourceKind = 'FEED' | 'MARKET_ENTITY' | 'THESIS_FEED';
2391
2527
  interface StewardPendingParams extends StewardTarget {
2392
- /** Opaque cursor from the previous page's `nextCursor`; carries the window. */
2528
+ /** @deprecated Use `pendingPage` for explicit single-page reads. */
2393
2529
  after?: string;
2394
2530
  /** First page only: lower bound on decision time. */
2395
2531
  sinceMs?: number;
@@ -2397,10 +2533,26 @@ interface StewardPendingParams extends StewardTarget {
2397
2533
  untilMs?: number;
2398
2534
  first?: number;
2399
2535
  }
2536
+ interface StewardPendingPageParams extends StewardPendingParams {
2537
+ /** Opaque cursor from the previous page's `nextCursor`; carries the window. */
2538
+ after?: string;
2539
+ }
2540
+ type StewardPendingFullParams = Omit<StewardPendingParams, 'after'> & {
2541
+ after?: undefined;
2542
+ };
2400
2543
  interface StewardBriefedParams extends StewardTarget {
2401
2544
  deliveryIds: string[];
2402
2545
  digestRunId: string;
2403
2546
  }
2547
+ interface StewardDigestRunParams extends StewardTarget {
2548
+ digestRunId: string;
2549
+ }
2550
+ interface StewardSendDigestRunParams extends StewardDigestRunParams {
2551
+ /** Exact reviewed coverage; omit or pass [] for a For-You-only Brief. */
2552
+ deliveryIds?: string[];
2553
+ /** Omit when complete reviewed coverage produces no useful Brief content. */
2554
+ body?: string;
2555
+ }
2404
2556
  interface StewardDecideResult {
2405
2557
  state: string;
2406
2558
  }
@@ -2432,16 +2584,50 @@ interface StewardPendingPage {
2432
2584
  windowSinceMs: number;
2433
2585
  windowUntilMs: number;
2434
2586
  }
2587
+ interface StewardPendingResult {
2588
+ items: StewardPendingItem[];
2589
+ /** The fixed window used for the complete read. */
2590
+ windowSinceMs: number;
2591
+ windowUntilMs: number;
2592
+ }
2593
+ type StewardDigestRunState = 'EXPECTED' | 'RUNNING' | 'SEND_UNCERTAIN' | 'SENT' | 'INTENTIONALLY_EMPTY' | 'FAILED_BEFORE_SEND' | 'FAILED' | 'FAILED_EXPIRED';
2594
+ interface StewardDigestRun {
2595
+ digestRunId: string;
2596
+ state: StewardDigestRunState;
2597
+ scheduleId: string;
2598
+ scheduleVersion: number;
2599
+ occurrenceIndex: number;
2600
+ windowSinceMs: number;
2601
+ windowUntilMs: number;
2602
+ scanCompletedAtMs?: number | null;
2603
+ bodySha256?: string | null;
2604
+ coverageSha256?: string | null;
2605
+ channelMessageId?: string | null;
2606
+ attempts: number;
2607
+ lastError: string;
2608
+ startedAtMs?: number | null;
2609
+ completedAtMs?: number | null;
2610
+ sendUncertainAtMs?: number | null;
2611
+ }
2435
2612
  declare class StewardResource {
2436
2613
  private client;
2437
2614
  constructor(client: AlvaClient);
2438
2615
  decide(params: StewardDecideParams): Promise<StewardDecideResult>;
2439
2616
  forward(params: StewardForwardParams): Promise<StewardForwardResult>;
2440
2617
  send(params: StewardSendParams): Promise<StewardSendResult>;
2441
- pending(params: StewardPendingParams): Promise<StewardPendingPage>;
2618
+ pending(params: StewardPendingParams & {
2619
+ after: string;
2620
+ }): Promise<StewardPendingPage>;
2621
+ pending(params: StewardPendingFullParams): Promise<StewardPendingResult>;
2622
+ pending(params: StewardPendingParams): Promise<StewardPendingResult | StewardPendingPage>;
2623
+ pendingPage(params: StewardPendingPageParams): Promise<StewardPendingPage>;
2624
+ private pendingPageWithRetry;
2442
2625
  briefed(params: StewardBriefedParams): Promise<{
2443
2626
  ok: true;
2444
2627
  }>;
2628
+ digestRun(params: StewardDigestRunParams): Promise<StewardDigestRun>;
2629
+ digestRunPending(params: StewardDigestRunParams): Promise<StewardPendingItem[]>;
2630
+ sendDigestRun(params: StewardSendDigestRunParams): Promise<StewardDigestRun>;
2445
2631
  private graphql;
2446
2632
  }
2447
2633
 
@@ -2557,14 +2743,87 @@ interface RelatedThesesPage {
2557
2743
  }[];
2558
2744
  nextCursor: string | null;
2559
2745
  }
2746
+ interface ThesisReturnParams {
2747
+ /** Revalue at the latest prices and include each Update's positions. */
2748
+ detail?: boolean;
2749
+ }
2750
+ /** A position of one Update, as ThesisPositionReturn in GraphQL. */
2751
+ interface ThesisPositionReturn {
2752
+ entityId: string;
2753
+ symbol: string;
2754
+ direction: 'BULLISH' | 'BEARISH';
2755
+ startPrice: number | null;
2756
+ startAtMs: number | null;
2757
+ endPrice: number | null;
2758
+ endAtMs: number | null;
2759
+ end: 'PENDING' | 'NEXT_UPDATE' | 'LATEST';
2760
+ positionReturn: number;
2761
+ currency: string;
2762
+ }
2763
+ /** One Update on the return chart. */
2764
+ interface ThesisUpdateReturn {
2765
+ authorVersionId: string;
2766
+ publishedAtMs: number;
2767
+ startValue: number;
2768
+ updateReturn: number | null;
2769
+ positions: ThesisPositionReturn[];
2770
+ }
2771
+ /** The Thesis return; values are fractions (0.05 is +5%). */
2772
+ interface ThesisReturnValue {
2773
+ live: boolean;
2774
+ value: number;
2775
+ firstFillAtMs: number | null;
2776
+ pricedAtMs: number | null;
2777
+ stale: boolean;
2778
+ computedAtMs: number;
2779
+ updates: ThesisUpdateReturn[];
2780
+ }
2781
+ interface ThesisReturnResult {
2782
+ playbookId: string;
2783
+ /** UNSET, ON or OFF; null when the current publication is not readable. */
2784
+ returnTracking: 'UNSET' | 'ON' | 'OFF' | null;
2785
+ /** Null when the Thesis is not tracked. */
2786
+ thesisReturn: ThesisReturnValue | null;
2787
+ }
2560
2788
 
2561
2789
  /** Thesis IDs are signed int64 values represented losslessly as decimal strings. */
2562
2790
  type ThesisID = string;
2563
2791
  type ThesisVisibility = 'public' | 'private' | 'paid';
2564
- type ThesisAssetStance = 'unknown' | 'bullish' | 'bearish';
2792
+ /** unknown: not judged; none: judged without a current long or short. */
2793
+ type ThesisAssetStance = 'unknown' | 'bullish' | 'bearish' | 'none';
2565
2794
  interface ThesisEntityStance {
2566
2795
  entity_id: ThesisID;
2567
2796
  stance: ThesisAssetStance;
2797
+ /** Full direction in responses; stance reports none as unknown there. */
2798
+ direction?: ThesisAssetStance;
2799
+ }
2800
+ /** GraphQL direction, including NONE. */
2801
+ type ThesisDirection = 'UNKNOWN' | 'BULLISH' | 'BEARISH' | 'NONE';
2802
+ interface ThesisSelectedDirection {
2803
+ entityId: ThesisID;
2804
+ direction: ThesisDirection;
2805
+ }
2806
+ type ThesisReturnTracking = 'UNSET' | 'ON' | 'OFF';
2807
+ /** What publishing the selected entities with their directions would store. */
2808
+ interface ThesisReturnPreview {
2809
+ /** The Thesis's return switch now; UNSET for a new Thesis. */
2810
+ tracking: ThesisReturnTracking;
2811
+ /** Ask the author whether to keep the return on. */
2812
+ askSwitch: boolean;
2813
+ /** Directions publishing would store; UNKNOWN could not be judged. */
2814
+ directions: ThesisSelectedDirection[];
2815
+ /** Exits that keep the previous direction (last-leg rule). */
2816
+ keptEntityIds: ThesisID[];
2817
+ /** Publishing this draft fails with THESIS_RETURN_LAST_LEG. */
2818
+ lastLegRemoved: boolean;
2819
+ }
2820
+ interface ThesisAssetCandidatesParams {
2821
+ /** Known catalog IDs to classify; with discover false, only these. */
2822
+ entityIds?: ThesisID[];
2823
+ /** The Thesis being updated: its current directions seed carried tickers. */
2824
+ thesisId?: ThesisID;
2825
+ /** False skips ticker discovery. Defaults to true. */
2826
+ discover?: boolean;
2568
2827
  }
2569
2828
  interface ThesisAssetCandidate {
2570
2829
  entityId: ThesisID;
@@ -2581,6 +2840,8 @@ interface ThesisAssetMention {
2581
2840
  }
2582
2841
  interface ThesisAssetCandidatesResponse {
2583
2842
  mentions: ThesisAssetMention[];
2843
+ /** Null only from a server without the preview. */
2844
+ returnPreview: ThesisReturnPreview | null;
2584
2845
  }
2585
2846
  /** Canonical server-supported candidate rewrite operation. */
2586
2847
  type ThesisRewriteMode = 'reformat' | 'shorten' | 'enrich';
@@ -2684,6 +2945,8 @@ interface CreateThesisParams {
2684
2945
  tickers?: string[];
2685
2946
  /** Omitted means public, as defined by the REST contract. */
2686
2947
  visibility?: 'public' | 'private';
2948
+ /** Thesis return switch; omitted keeps the default (on). */
2949
+ track_return?: boolean;
2687
2950
  }
2688
2951
  interface UpdateThesisParams {
2689
2952
  /** Full media replacement; pass current medias for a text-only update. */
@@ -2698,9 +2961,10 @@ interface UpdateThesisParams {
2698
2961
  entity_stances?: ThesisEntityStance[];
2699
2962
  /** Required so an update cannot inadvertently publish a private thesis. */
2700
2963
  visibility: ThesisVisibility;
2701
- editorial?: boolean;
2702
2964
  archived?: boolean;
2703
2965
  note?: string;
2966
+ /** Thesis return switch; omitted keeps the current decision or default. */
2967
+ track_return?: boolean;
2704
2968
  }
2705
2969
  interface SetThesisArchivedParams {
2706
2970
  /** Caller-supplied, stable non-zero UUID for this archive transition. */
@@ -2723,10 +2987,6 @@ interface ThesisSignalEnabledResponse {
2723
2987
  interface SetThesisVisibilityParams {
2724
2988
  visibility: 'public' | 'private';
2725
2989
  }
2726
- interface CloseThesisParams {
2727
- expected_author_version_id: ThesisID;
2728
- note?: string;
2729
- }
2730
2990
  interface RewriteThesisParams {
2731
2991
  body: string;
2732
2992
  /** Omitted selects the canonical `reformat` mode. */
@@ -2746,7 +3006,9 @@ declare class ThesesResource {
2746
3006
  list(params: ListThesesParams): Promise<ThesisListPage>;
2747
3007
  /** Related publications always use the current source version. */
2748
3008
  related(id: ThesisID, params?: ThesisPageParams): Promise<RelatedThesesPage>;
2749
- assetCandidates(text: string): Promise<ThesisAssetCandidatesResponse>;
3009
+ assetCandidates(text: string, params?: ThesisAssetCandidatesParams): Promise<ThesisAssetCandidatesResponse>;
3010
+ /** The Thesis return of a Playbook's current publication; detail revalues it. */
3011
+ thesisReturn(id: ThesisID, params?: ThesisReturnParams): Promise<ThesisReturnResult>;
2750
3012
  create(params: CreateThesisParams): Promise<ThesisResponse>;
2751
3013
  get(id: ThesisID): Promise<ThesisGetResponse>;
2752
3014
  getVersion(id: ThesisID, authorVersionID: ThesisID): Promise<ThesisResponse>;
@@ -2758,8 +3020,6 @@ declare class ThesesResource {
2758
3020
  versions: Thesis[];
2759
3021
  next_cursor: string;
2760
3022
  }>;
2761
- /** Deletes only the selected Update; never falls back to whole-Thesis deletion. */
2762
- deleteUpdate(id: ThesisID, authorVersionID: ThesisID, expectedAuthorVersionID: ThesisID): Promise<ThesisResponse>;
2763
3023
  signals(id: ThesisID, params?: ListThesisSignalsParams): Promise<ThesisSignalsResponse>;
2764
3024
  update(id: ThesisID, params: UpdateThesisParams): Promise<ThesisResponse>;
2765
3025
  /** Archive or restore the current version without asking callers to resend its body. */
@@ -2767,8 +3027,6 @@ declare class ThesesResource {
2767
3027
  setStarred(id: ThesisID, isStarred: boolean): Promise<ThesisStarredResponse>;
2768
3028
  setSignalEnabled(id: ThesisID, enabled: boolean): Promise<ThesisSignalEnabledResponse>;
2769
3029
  setVisibility(id: ThesisID, params: SetThesisVisibilityParams): Promise<ThesisResponse>;
2770
- close(id: ThesisID, params: CloseThesisParams): Promise<ThesisResponse>;
2771
- delete(id: ThesisID): Promise<Record<string, never>>;
2772
3030
  rewrite(params: RewriteThesisParams): Promise<RewriteThesisResponse>;
2773
3031
  }
2774
3032
 
@@ -2851,6 +3109,7 @@ declare class AlvaClient {
2851
3109
  private _notifications?;
2852
3110
  private _notificationPreferences?;
2853
3111
  private _subscriptions?;
3112
+ private _follows?;
2854
3113
  private _alerts?;
2855
3114
  private _channelGroupSubscriptions?;
2856
3115
  private _feedback?;
@@ -2885,6 +3144,7 @@ declare class AlvaClient {
2885
3144
  get notifications(): NotificationsResource;
2886
3145
  get notificationPreferences(): NotificationPreferencesResource;
2887
3146
  get subscriptions(): SubscriptionsResource;
3147
+ get follows(): FollowsResource;
2888
3148
  get alerts(): AlertsResource;
2889
3149
  get channelGroupSubscriptions(): ChannelGroupSubscriptionsResource;
2890
3150
  get feedback(): FeedbackResource;