@alva-ai/toolkit 0.38.0-beta.0 → 0.38.0-beta.2

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
@@ -2106,6 +2106,25 @@ interface ThesisPositionReturn {
2106
2106
  end: 'PENDING' | 'NEXT_UPDATE' | 'LATEST';
2107
2107
  positionReturn: number;
2108
2108
  currency: string;
2109
+ /** The Update's target share of this position; equal shares when it states none. */
2110
+ weight: number;
2111
+ }
2112
+ /** One long or short of a target portfolio. */
2113
+ interface ThesisHolding {
2114
+ entityId: string;
2115
+ symbol: string;
2116
+ direction: 'BULLISH' | 'BEARISH';
2117
+ /** Target share as a fraction; equal shares when the Update states none. */
2118
+ weight: number;
2119
+ }
2120
+ /**
2121
+ * The current target portfolio: the shares the latest Update set, not drifted
2122
+ * with prices. Holdings and cash sum to 1; cash is 1 with no direction or
2123
+ * while archived.
2124
+ */
2125
+ interface ThesisAllocation {
2126
+ holdings: ThesisHolding[];
2127
+ cash: number;
2109
2128
  }
2110
2129
  /** One Update on the return chart. */
2111
2130
  interface ThesisUpdateReturn {
@@ -2124,6 +2143,8 @@ interface ThesisReturnValue {
2124
2143
  stale: boolean;
2125
2144
  computedAtMs: number;
2126
2145
  updates: ThesisUpdateReturn[];
2146
+ /** The current target portfolio, with detail; null on card reads. */
2147
+ allocation: ThesisAllocation | null;
2127
2148
  }
2128
2149
  interface ThesisReturnResult {
2129
2150
  playbookId: string;
@@ -2159,6 +2180,14 @@ interface ThesisEntityStance {
2159
2180
  stance: ThesisAssetStance;
2160
2181
  /** Full direction in responses; stance reports none as unknown there. */
2161
2182
  direction?: ThesisAssetStance;
2183
+ /**
2184
+ * The Update's share of this long or short as a fraction (0.4 is 40%), with
2185
+ * at most four decimals. On create and update give one to every bullish or
2186
+ * bearish entity, and the rest is cash, or to none, and the shares follow
2187
+ * the default rules and what the body says. Responses carry it only on an
2188
+ * Update published with weights.
2189
+ */
2190
+ weight?: number;
2162
2191
  }
2163
2192
  /** GraphQL direction, including NONE. */
2164
2193
  type ThesisDirection = 'UNKNOWN' | 'BULLISH' | 'BEARISH' | 'NONE';
@@ -2236,6 +2265,10 @@ interface Thesis {
2236
2265
  interface ThesisResponse {
2237
2266
  thesis: Thesis;
2238
2267
  }
2268
+ /** A created Thesis and its clickable web url, e.g. `https://alva.ai/thesis/123`. */
2269
+ interface ThesisCreateResponse extends ThesisResponse {
2270
+ url: string;
2271
+ }
2239
2272
  interface ThesisAuthor {
2240
2273
  id: ThesisID;
2241
2274
  kind: string;
@@ -2312,6 +2345,25 @@ interface CreateThesisParams {
2312
2345
  visibility?: 'public' | 'private';
2313
2346
  /** Thesis return switch; omitted keeps the default (on). */
2314
2347
  track_return?: boolean;
2348
+ /** Which Signals the Thesis shows; omitted shows every Signal. */
2349
+ signal_preferences?: ThesisSignalPreferences;
2350
+ }
2351
+ /** What a Thesis Signal is about. */
2352
+ type ThesisSignalKind = 'fundamentals' | 'macro' | 'technicals' | 'commentary';
2353
+ /** The least important Signals a Thesis shows; notable means notable and major. */
2354
+ type ThesisSignalMinImportance = 'all' | 'notable' | 'major';
2355
+ /**
2356
+ * Which Signals a Thesis shows to every reader, chosen by its author. Signals
2357
+ * without a label always show.
2358
+ */
2359
+ interface ThesisSignalPreferences {
2360
+ kinds: ThesisSignalKind[];
2361
+ min_importance: ThesisSignalMinImportance;
2362
+ }
2363
+ interface ThesisSignalPreferencesResponse {
2364
+ /** The Thesis read or written; null for the caller's last choice. */
2365
+ thesis_id: ThesisID | null;
2366
+ preferences: ThesisSignalPreferences;
2315
2367
  }
2316
2368
  interface UpdateThesisParams {
2317
2369
  /** Full media replacement; pass current medias for a text-only update. */
@@ -2379,7 +2431,7 @@ declare class ThesesResource {
2379
2431
  * things the Thesis depends on, or that would show it right or wrong.
2380
2432
  */
2381
2433
  watchpoints(id: ThesisID): Promise<ThesisWatchpointsResult>;
2382
- create(params: CreateThesisParams): Promise<ThesisResponse>;
2434
+ create(params: CreateThesisParams): Promise<ThesisCreateResponse>;
2383
2435
  get(id: ThesisID): Promise<ThesisGetResponse>;
2384
2436
  getVersion(id: ThesisID, authorVersionID: ThesisID): Promise<ThesisResponse>;
2385
2437
  /** Lists reader-visible Updates, with editorial revisions folded together. */
@@ -2399,6 +2451,17 @@ declare class ThesesResource {
2399
2451
  */
2400
2452
  setArchived(id: ThesisID, params: SetThesisArchivedParams): Promise<ThesisResponse>;
2401
2453
  setStarred(id: ThesisID, isStarred: boolean): Promise<ThesisStarredResponse>;
2454
+ /**
2455
+ * Reads which Signals one of the caller's Theses shows: its setting, or every
2456
+ * kind and `all` when it has none. Without an id, reads the setting the caller
2457
+ * last saved, which prefills a new Thesis. Only the Thesis's author can read it.
2458
+ */
2459
+ getSignalPreferences(id?: ThesisID): Promise<ThesisSignalPreferencesResponse>;
2460
+ /**
2461
+ * Replaces which Signals one of the caller's Theses shows, for every reader,
2462
+ * and records it as the caller's last choice. Author only.
2463
+ */
2464
+ setSignalPreferences(id: ThesisID, preferences: ThesisSignalPreferences): Promise<ThesisSignalPreferencesResponse>;
2402
2465
  setSignalEnabled(id: ThesisID, enabled: boolean): Promise<ThesisSignalEnabledResponse>;
2403
2466
  setVisibility(id: ThesisID, params: SetThesisVisibilityParams): Promise<ThesisResponse>;
2404
2467
  rewrite(params: RewriteThesisParams): Promise<RewriteThesisResponse>;
@@ -2512,12 +2575,10 @@ interface FollowingThesesParams {
2512
2575
  first?: number;
2513
2576
  }
2514
2577
  /** The author of a Thesis in the following feed. */
2578
+ /** The followed user who wrote a Thesis Update. Persons cannot be followed. */
2515
2579
  interface FollowingThesisAuthor {
2516
- kind: 'user' | 'person';
2517
- /** Set for a user. */
2518
- username?: string;
2519
- /** Set for a person. */
2520
- slug?: string;
2580
+ kind: 'user';
2581
+ username: string;
2521
2582
  display_name: string;
2522
2583
  }
2523
2584
  interface FollowingThesisItem {
@@ -3374,4 +3435,4 @@ declare const installPlaybookRuntime: (targetWindow?: Window) => void;
3374
3435
  /** SDK version, injected at build time from package.json. */
3375
3436
  declare const VERSION: string;
3376
3437
 
3377
- export { type AddToWatchlistResult, type AgentSchedule, type AgentScheduleBounds, type AgentScheduleFailureCode, type AgentScheduleRule, type AgentScheduleStatus, type AgentScheduleTarget, AlertsResource, AlvaClient, type AlvaClientConfig, AlvaError, type AutomationAlertDelivery, type AutomationAlertDeliveryGetRequest, AutomationAlertDeliveryResource, type AutomationAlertDeliveryUpdateRequest, type AutomationAlertDeliveryUpdateResponse, type AutomationEmailDelivery, AutomationResource, type ChannelGroupAdminInfo, type ChannelGroupCallerInfo, type ChannelGroupHistoryParams, type ChannelGroupHistoryResponse, type ChannelGroupSubscription, type ChannelGroupSubscriptionContextResponse, type ChannelGroupSubscriptionListResponse, type ChannelGroupSubscriptionMutationParams, type ChannelGroupSubscriptionMutationResponse, type ChannelGroupSubscriptionSessionParams, type ChannelGroupSubscriptionTarget, type ChannelGroupSubscriptionTargetType, CliUsageError, type CompanyEarningsCatalog, type CompanyEarningsContentStatus, type CompanyEarningsContext, type CompanyEarningsEvent, type CompanyEarningsParams, type CompanyEarningsPeriod, type CompanyEarningsRelease, type CompanyEarningsSession, type CompanyEarningsStatus, type CompanyEarningsTranscript, type CompanyEarningsTranscriptEntry, type CompanyEarningsTranscriptSection, type CompanyFiscalQuarter, type CompanyNarrative, type CompanyNarrativeChangeLogEntry, type CompanyNarrativeContext, type CompanyNarrativeHistory, type CompanyNarrativeSnapshot, CompanyNewsResource, type CompanyPostEarningsSummary, type CompanyPreEarningsAnalysis, type CreateAllowanceParams, type CreateAllowanceResponse, type CreateCompanyNewsParams, type CreateCompanyNewsResponse, type CreateThesisParams, type CreditAllowance, type CreditWallet, type CreditWalletItem, type CreditWalletItemConnection, type CreditWalletItemEdge, type CreditWalletItemsParams, type CreditWalletItemsResponse, type CreditWalletPageInfo, type DeleteFunctionParams, type FeedDeleteRequest, type FeedDeleteResponse, type FeedListItem, type FeedListParams, type FeedListResponse, type FeedListStatus, type FeedStatusUpdateRequest, type FeedStatusUpdateResponse, type FollowPageInfo, type FollowPageParams, type FollowPlaybookResponse, type FollowProfile, type FollowProfileKind, type FollowedProfilesParams, type FollowingThesesPage, type FollowingThesesParams, type FollowingThesisAuthor, type FollowingThesisItem, FollowsResource, type ForYouConnection, type ForYouEntry, type ForYouListParams, ForYouResource, type ForYouThesesParams, 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 GroupChatMessage, type InvokeFunctionParams, type InvokeFunctionResponse, type ListAllowancesResponse, type ListFunctionsParams, type ListFunctionsResponse, type ListThesesParams, type ListThesisSignalsParams, type ManageAgentScheduleParams, MarketsResource, type NotificationPreference, type NotificationPreferenceKey, type NotificationPreferenceUpdateParams, type NotificationPreferenceUpdateResponse, type NotificationPreferencesResponse, PBSV_UPDATE_MESSAGE, type PlaybookFollowParams, type PlaybookFunction, type PlaybookSkillFile, type PlaybookSkillFileMeta, type PlaybookSkillMeta, type PlaybookSkillSummary, type PlaybookSkillTagEntry, type ProfileFollowResult, type ProfileRefParams, type ProfilesPage, type PutAgentScheduleParams, type RegisterFunctionParams, type RegisterFunctionResponse, type RelatedThesesPage, type RemoveFromWatchlistResult, type ResolvedTicker, type RevokeAllowanceParams, type RevokeAllowanceResponse, type RewriteThesisParams, type RewriteThesisResponse, SUBSCRIBE_MANAGE_MESSAGE, SUBSCRIBE_PROPOSE_MESSAGE, SUBSCRIBE_RESULT_MESSAGE, SchedulesResource, type SearchProfilesParams, type SetThesisArchivedParams, type SetThesisVisibilityParams, type SkillDoc, type SkillEndpointMetadata, type SkillEndpointTier, type SkillMetadata, type SkillSummary, type StewardBriefedParams, type StewardDecideParams, type StewardDecision, type StewardDigestRun, type StewardDigestRunParams, type StewardDigestRunState, type StewardForwardParams, type StewardPendingFullParams, type StewardPendingItem, type StewardPendingPage, type StewardPendingPageParams, type StewardPendingParams, type StewardPendingResult, StewardResource, type StewardSendDigestRunParams, type StewardSendParams, type StewardTarget, type SubmitFeedbackRequest, type SubmitFeedbackResponse, type SubscribeApi, type SubscribeBatchParams, type SubscribeBatchResponse, type SubscribeProposalInput, type SubscribeProposalResult, ThesesResource, type Thesis, type ThesisAssetCandidate, type ThesisAssetCandidatesResponse, type ThesisAssetMention, type ThesisAssetStance, type ThesisAuthor, type ThesisEntity, type ThesisEntityStance, type ThesisGetResponse, type ThesisID, type ThesisListPage, type ThesisMedia, type ThesisPageParams, type ThesisPublicationSummary, type ThesisPublisher, type ThesisReadScope, type ThesisRecommendation, type ThesisRecommendationPage, type ThesisResearchStatus, type ThesisResponse, type ThesisRewriteMode, type ThesisSignal, type ThesisSignalEnabledResponse, type ThesisSignalEntry, type ThesisSignalEvidenceExcerpt, type ThesisSignalSource, type ThesisSignalsResponse, type ThesisSourceReference, type ThesisStarredResponse, type ThesisVisibility, type TradingPairCandidate, type TradingPairSearchParams, type TradingPairSearchResponse, TradingPairsResource, 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, type UnfollowPlaybookResponse, type UnresolvedTicker, type UnsubscribeBatchParams, type UnsubscribeBatchResponse, type UpdateThesisParams, VERSION, type WatchlistPage, type WatchlistTicker, type WatchlistTickerKind, type WatchlistTickerSpec, type WatchlistTickersParams, type XAccount, type XConnectionStatus, type XPost, type XReadPage, type XReadParams, XResource, getViewerToken, installPlaybookRuntime, mapUdfErrorResponse, playbookIdFromToken, subscribe, udf };
3438
+ export { type AddToWatchlistResult, type AgentSchedule, type AgentScheduleBounds, type AgentScheduleFailureCode, type AgentScheduleRule, type AgentScheduleStatus, type AgentScheduleTarget, AlertsResource, AlvaClient, type AlvaClientConfig, AlvaError, type AutomationAlertDelivery, type AutomationAlertDeliveryGetRequest, AutomationAlertDeliveryResource, type AutomationAlertDeliveryUpdateRequest, type AutomationAlertDeliveryUpdateResponse, type AutomationEmailDelivery, AutomationResource, type ChannelGroupAdminInfo, type ChannelGroupCallerInfo, type ChannelGroupHistoryParams, type ChannelGroupHistoryResponse, type ChannelGroupSubscription, type ChannelGroupSubscriptionContextResponse, type ChannelGroupSubscriptionListResponse, type ChannelGroupSubscriptionMutationParams, type ChannelGroupSubscriptionMutationResponse, type ChannelGroupSubscriptionSessionParams, type ChannelGroupSubscriptionTarget, type ChannelGroupSubscriptionTargetType, CliUsageError, type CompanyEarningsCatalog, type CompanyEarningsContentStatus, type CompanyEarningsContext, type CompanyEarningsEvent, type CompanyEarningsParams, type CompanyEarningsPeriod, type CompanyEarningsRelease, type CompanyEarningsSession, type CompanyEarningsStatus, type CompanyEarningsTranscript, type CompanyEarningsTranscriptEntry, type CompanyEarningsTranscriptSection, type CompanyFiscalQuarter, type CompanyNarrative, type CompanyNarrativeChangeLogEntry, type CompanyNarrativeContext, type CompanyNarrativeHistory, type CompanyNarrativeSnapshot, CompanyNewsResource, type CompanyPostEarningsSummary, type CompanyPreEarningsAnalysis, type CreateAllowanceParams, type CreateAllowanceResponse, type CreateCompanyNewsParams, type CreateCompanyNewsResponse, type CreateThesisParams, type CreditAllowance, type CreditWallet, type CreditWalletItem, type CreditWalletItemConnection, type CreditWalletItemEdge, type CreditWalletItemsParams, type CreditWalletItemsResponse, type CreditWalletPageInfo, type DeleteFunctionParams, type FeedDeleteRequest, type FeedDeleteResponse, type FeedListItem, type FeedListParams, type FeedListResponse, type FeedListStatus, type FeedStatusUpdateRequest, type FeedStatusUpdateResponse, type FollowPageInfo, type FollowPageParams, type FollowPlaybookResponse, type FollowProfile, type FollowProfileKind, type FollowedProfilesParams, type FollowingThesesPage, type FollowingThesesParams, type FollowingThesisAuthor, type FollowingThesisItem, FollowsResource, type ForYouConnection, type ForYouEntry, type ForYouListParams, ForYouResource, type ForYouThesesParams, 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 GroupChatMessage, type InvokeFunctionParams, type InvokeFunctionResponse, type ListAllowancesResponse, type ListFunctionsParams, type ListFunctionsResponse, type ListThesesParams, type ListThesisSignalsParams, type ManageAgentScheduleParams, MarketsResource, type NotificationPreference, type NotificationPreferenceKey, type NotificationPreferenceUpdateParams, type NotificationPreferenceUpdateResponse, type NotificationPreferencesResponse, PBSV_UPDATE_MESSAGE, type PlaybookFollowParams, type PlaybookFunction, type PlaybookSkillFile, type PlaybookSkillFileMeta, type PlaybookSkillMeta, type PlaybookSkillSummary, type PlaybookSkillTagEntry, type ProfileFollowResult, type ProfileRefParams, type ProfilesPage, type PutAgentScheduleParams, type RegisterFunctionParams, type RegisterFunctionResponse, type RelatedThesesPage, type RemoveFromWatchlistResult, type ResolvedTicker, type RevokeAllowanceParams, type RevokeAllowanceResponse, type RewriteThesisParams, type RewriteThesisResponse, SUBSCRIBE_MANAGE_MESSAGE, SUBSCRIBE_PROPOSE_MESSAGE, SUBSCRIBE_RESULT_MESSAGE, SchedulesResource, type SearchProfilesParams, type SetThesisArchivedParams, type SetThesisVisibilityParams, type SkillDoc, type SkillEndpointMetadata, type SkillEndpointTier, type SkillMetadata, type SkillSummary, type StewardBriefedParams, type StewardDecideParams, type StewardDecision, type StewardDigestRun, type StewardDigestRunParams, type StewardDigestRunState, type StewardForwardParams, type StewardPendingFullParams, type StewardPendingItem, type StewardPendingPage, type StewardPendingPageParams, type StewardPendingParams, type StewardPendingResult, StewardResource, type StewardSendDigestRunParams, type StewardSendParams, type StewardTarget, type SubmitFeedbackRequest, type SubmitFeedbackResponse, type SubscribeApi, type SubscribeBatchParams, type SubscribeBatchResponse, type SubscribeProposalInput, type SubscribeProposalResult, ThesesResource, type Thesis, type ThesisAssetCandidate, type ThesisAssetCandidatesResponse, type ThesisAssetMention, type ThesisAssetStance, type ThesisAuthor, type ThesisCreateResponse, type ThesisEntity, type ThesisEntityStance, type ThesisGetResponse, type ThesisID, type ThesisListPage, type ThesisMedia, type ThesisPageParams, type ThesisPublicationSummary, type ThesisPublisher, type ThesisReadScope, type ThesisRecommendation, type ThesisRecommendationPage, type ThesisResearchStatus, type ThesisResponse, type ThesisRewriteMode, type ThesisSignal, type ThesisSignalEnabledResponse, type ThesisSignalEntry, type ThesisSignalEvidenceExcerpt, type ThesisSignalSource, type ThesisSignalsResponse, type ThesisSourceReference, type ThesisStarredResponse, type ThesisVisibility, type TradingPairCandidate, type TradingPairSearchParams, type TradingPairSearchResponse, TradingPairsResource, 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, type UnfollowPlaybookResponse, type UnresolvedTicker, type UnsubscribeBatchParams, type UnsubscribeBatchResponse, type UpdateThesisParams, VERSION, type WatchlistPage, type WatchlistTicker, type WatchlistTickerKind, type WatchlistTickerSpec, type WatchlistTickersParams, type XAccount, type XConnectionStatus, type XPost, type XReadPage, type XReadParams, XResource, getViewerToken, installPlaybookRuntime, mapUdfErrorResponse, playbookIdFromToken, subscribe, udf };
package/dist/index.d.ts CHANGED
@@ -2106,6 +2106,25 @@ interface ThesisPositionReturn {
2106
2106
  end: 'PENDING' | 'NEXT_UPDATE' | 'LATEST';
2107
2107
  positionReturn: number;
2108
2108
  currency: string;
2109
+ /** The Update's target share of this position; equal shares when it states none. */
2110
+ weight: number;
2111
+ }
2112
+ /** One long or short of a target portfolio. */
2113
+ interface ThesisHolding {
2114
+ entityId: string;
2115
+ symbol: string;
2116
+ direction: 'BULLISH' | 'BEARISH';
2117
+ /** Target share as a fraction; equal shares when the Update states none. */
2118
+ weight: number;
2119
+ }
2120
+ /**
2121
+ * The current target portfolio: the shares the latest Update set, not drifted
2122
+ * with prices. Holdings and cash sum to 1; cash is 1 with no direction or
2123
+ * while archived.
2124
+ */
2125
+ interface ThesisAllocation {
2126
+ holdings: ThesisHolding[];
2127
+ cash: number;
2109
2128
  }
2110
2129
  /** One Update on the return chart. */
2111
2130
  interface ThesisUpdateReturn {
@@ -2124,6 +2143,8 @@ interface ThesisReturnValue {
2124
2143
  stale: boolean;
2125
2144
  computedAtMs: number;
2126
2145
  updates: ThesisUpdateReturn[];
2146
+ /** The current target portfolio, with detail; null on card reads. */
2147
+ allocation: ThesisAllocation | null;
2127
2148
  }
2128
2149
  interface ThesisReturnResult {
2129
2150
  playbookId: string;
@@ -2159,6 +2180,14 @@ interface ThesisEntityStance {
2159
2180
  stance: ThesisAssetStance;
2160
2181
  /** Full direction in responses; stance reports none as unknown there. */
2161
2182
  direction?: ThesisAssetStance;
2183
+ /**
2184
+ * The Update's share of this long or short as a fraction (0.4 is 40%), with
2185
+ * at most four decimals. On create and update give one to every bullish or
2186
+ * bearish entity, and the rest is cash, or to none, and the shares follow
2187
+ * the default rules and what the body says. Responses carry it only on an
2188
+ * Update published with weights.
2189
+ */
2190
+ weight?: number;
2162
2191
  }
2163
2192
  /** GraphQL direction, including NONE. */
2164
2193
  type ThesisDirection = 'UNKNOWN' | 'BULLISH' | 'BEARISH' | 'NONE';
@@ -2236,6 +2265,10 @@ interface Thesis {
2236
2265
  interface ThesisResponse {
2237
2266
  thesis: Thesis;
2238
2267
  }
2268
+ /** A created Thesis and its clickable web url, e.g. `https://alva.ai/thesis/123`. */
2269
+ interface ThesisCreateResponse extends ThesisResponse {
2270
+ url: string;
2271
+ }
2239
2272
  interface ThesisAuthor {
2240
2273
  id: ThesisID;
2241
2274
  kind: string;
@@ -2312,6 +2345,25 @@ interface CreateThesisParams {
2312
2345
  visibility?: 'public' | 'private';
2313
2346
  /** Thesis return switch; omitted keeps the default (on). */
2314
2347
  track_return?: boolean;
2348
+ /** Which Signals the Thesis shows; omitted shows every Signal. */
2349
+ signal_preferences?: ThesisSignalPreferences;
2350
+ }
2351
+ /** What a Thesis Signal is about. */
2352
+ type ThesisSignalKind = 'fundamentals' | 'macro' | 'technicals' | 'commentary';
2353
+ /** The least important Signals a Thesis shows; notable means notable and major. */
2354
+ type ThesisSignalMinImportance = 'all' | 'notable' | 'major';
2355
+ /**
2356
+ * Which Signals a Thesis shows to every reader, chosen by its author. Signals
2357
+ * without a label always show.
2358
+ */
2359
+ interface ThesisSignalPreferences {
2360
+ kinds: ThesisSignalKind[];
2361
+ min_importance: ThesisSignalMinImportance;
2362
+ }
2363
+ interface ThesisSignalPreferencesResponse {
2364
+ /** The Thesis read or written; null for the caller's last choice. */
2365
+ thesis_id: ThesisID | null;
2366
+ preferences: ThesisSignalPreferences;
2315
2367
  }
2316
2368
  interface UpdateThesisParams {
2317
2369
  /** Full media replacement; pass current medias for a text-only update. */
@@ -2379,7 +2431,7 @@ declare class ThesesResource {
2379
2431
  * things the Thesis depends on, or that would show it right or wrong.
2380
2432
  */
2381
2433
  watchpoints(id: ThesisID): Promise<ThesisWatchpointsResult>;
2382
- create(params: CreateThesisParams): Promise<ThesisResponse>;
2434
+ create(params: CreateThesisParams): Promise<ThesisCreateResponse>;
2383
2435
  get(id: ThesisID): Promise<ThesisGetResponse>;
2384
2436
  getVersion(id: ThesisID, authorVersionID: ThesisID): Promise<ThesisResponse>;
2385
2437
  /** Lists reader-visible Updates, with editorial revisions folded together. */
@@ -2399,6 +2451,17 @@ declare class ThesesResource {
2399
2451
  */
2400
2452
  setArchived(id: ThesisID, params: SetThesisArchivedParams): Promise<ThesisResponse>;
2401
2453
  setStarred(id: ThesisID, isStarred: boolean): Promise<ThesisStarredResponse>;
2454
+ /**
2455
+ * Reads which Signals one of the caller's Theses shows: its setting, or every
2456
+ * kind and `all` when it has none. Without an id, reads the setting the caller
2457
+ * last saved, which prefills a new Thesis. Only the Thesis's author can read it.
2458
+ */
2459
+ getSignalPreferences(id?: ThesisID): Promise<ThesisSignalPreferencesResponse>;
2460
+ /**
2461
+ * Replaces which Signals one of the caller's Theses shows, for every reader,
2462
+ * and records it as the caller's last choice. Author only.
2463
+ */
2464
+ setSignalPreferences(id: ThesisID, preferences: ThesisSignalPreferences): Promise<ThesisSignalPreferencesResponse>;
2402
2465
  setSignalEnabled(id: ThesisID, enabled: boolean): Promise<ThesisSignalEnabledResponse>;
2403
2466
  setVisibility(id: ThesisID, params: SetThesisVisibilityParams): Promise<ThesisResponse>;
2404
2467
  rewrite(params: RewriteThesisParams): Promise<RewriteThesisResponse>;
@@ -2512,12 +2575,10 @@ interface FollowingThesesParams {
2512
2575
  first?: number;
2513
2576
  }
2514
2577
  /** The author of a Thesis in the following feed. */
2578
+ /** The followed user who wrote a Thesis Update. Persons cannot be followed. */
2515
2579
  interface FollowingThesisAuthor {
2516
- kind: 'user' | 'person';
2517
- /** Set for a user. */
2518
- username?: string;
2519
- /** Set for a person. */
2520
- slug?: string;
2580
+ kind: 'user';
2581
+ username: string;
2521
2582
  display_name: string;
2522
2583
  }
2523
2584
  interface FollowingThesisItem {
@@ -3374,4 +3435,4 @@ declare const installPlaybookRuntime: (targetWindow?: Window) => void;
3374
3435
  /** SDK version, injected at build time from package.json. */
3375
3436
  declare const VERSION: string;
3376
3437
 
3377
- export { type AddToWatchlistResult, type AgentSchedule, type AgentScheduleBounds, type AgentScheduleFailureCode, type AgentScheduleRule, type AgentScheduleStatus, type AgentScheduleTarget, AlertsResource, AlvaClient, type AlvaClientConfig, AlvaError, type AutomationAlertDelivery, type AutomationAlertDeliveryGetRequest, AutomationAlertDeliveryResource, type AutomationAlertDeliveryUpdateRequest, type AutomationAlertDeliveryUpdateResponse, type AutomationEmailDelivery, AutomationResource, type ChannelGroupAdminInfo, type ChannelGroupCallerInfo, type ChannelGroupHistoryParams, type ChannelGroupHistoryResponse, type ChannelGroupSubscription, type ChannelGroupSubscriptionContextResponse, type ChannelGroupSubscriptionListResponse, type ChannelGroupSubscriptionMutationParams, type ChannelGroupSubscriptionMutationResponse, type ChannelGroupSubscriptionSessionParams, type ChannelGroupSubscriptionTarget, type ChannelGroupSubscriptionTargetType, CliUsageError, type CompanyEarningsCatalog, type CompanyEarningsContentStatus, type CompanyEarningsContext, type CompanyEarningsEvent, type CompanyEarningsParams, type CompanyEarningsPeriod, type CompanyEarningsRelease, type CompanyEarningsSession, type CompanyEarningsStatus, type CompanyEarningsTranscript, type CompanyEarningsTranscriptEntry, type CompanyEarningsTranscriptSection, type CompanyFiscalQuarter, type CompanyNarrative, type CompanyNarrativeChangeLogEntry, type CompanyNarrativeContext, type CompanyNarrativeHistory, type CompanyNarrativeSnapshot, CompanyNewsResource, type CompanyPostEarningsSummary, type CompanyPreEarningsAnalysis, type CreateAllowanceParams, type CreateAllowanceResponse, type CreateCompanyNewsParams, type CreateCompanyNewsResponse, type CreateThesisParams, type CreditAllowance, type CreditWallet, type CreditWalletItem, type CreditWalletItemConnection, type CreditWalletItemEdge, type CreditWalletItemsParams, type CreditWalletItemsResponse, type CreditWalletPageInfo, type DeleteFunctionParams, type FeedDeleteRequest, type FeedDeleteResponse, type FeedListItem, type FeedListParams, type FeedListResponse, type FeedListStatus, type FeedStatusUpdateRequest, type FeedStatusUpdateResponse, type FollowPageInfo, type FollowPageParams, type FollowPlaybookResponse, type FollowProfile, type FollowProfileKind, type FollowedProfilesParams, type FollowingThesesPage, type FollowingThesesParams, type FollowingThesisAuthor, type FollowingThesisItem, FollowsResource, type ForYouConnection, type ForYouEntry, type ForYouListParams, ForYouResource, type ForYouThesesParams, 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 GroupChatMessage, type InvokeFunctionParams, type InvokeFunctionResponse, type ListAllowancesResponse, type ListFunctionsParams, type ListFunctionsResponse, type ListThesesParams, type ListThesisSignalsParams, type ManageAgentScheduleParams, MarketsResource, type NotificationPreference, type NotificationPreferenceKey, type NotificationPreferenceUpdateParams, type NotificationPreferenceUpdateResponse, type NotificationPreferencesResponse, PBSV_UPDATE_MESSAGE, type PlaybookFollowParams, type PlaybookFunction, type PlaybookSkillFile, type PlaybookSkillFileMeta, type PlaybookSkillMeta, type PlaybookSkillSummary, type PlaybookSkillTagEntry, type ProfileFollowResult, type ProfileRefParams, type ProfilesPage, type PutAgentScheduleParams, type RegisterFunctionParams, type RegisterFunctionResponse, type RelatedThesesPage, type RemoveFromWatchlistResult, type ResolvedTicker, type RevokeAllowanceParams, type RevokeAllowanceResponse, type RewriteThesisParams, type RewriteThesisResponse, SUBSCRIBE_MANAGE_MESSAGE, SUBSCRIBE_PROPOSE_MESSAGE, SUBSCRIBE_RESULT_MESSAGE, SchedulesResource, type SearchProfilesParams, type SetThesisArchivedParams, type SetThesisVisibilityParams, type SkillDoc, type SkillEndpointMetadata, type SkillEndpointTier, type SkillMetadata, type SkillSummary, type StewardBriefedParams, type StewardDecideParams, type StewardDecision, type StewardDigestRun, type StewardDigestRunParams, type StewardDigestRunState, type StewardForwardParams, type StewardPendingFullParams, type StewardPendingItem, type StewardPendingPage, type StewardPendingPageParams, type StewardPendingParams, type StewardPendingResult, StewardResource, type StewardSendDigestRunParams, type StewardSendParams, type StewardTarget, type SubmitFeedbackRequest, type SubmitFeedbackResponse, type SubscribeApi, type SubscribeBatchParams, type SubscribeBatchResponse, type SubscribeProposalInput, type SubscribeProposalResult, ThesesResource, type Thesis, type ThesisAssetCandidate, type ThesisAssetCandidatesResponse, type ThesisAssetMention, type ThesisAssetStance, type ThesisAuthor, type ThesisEntity, type ThesisEntityStance, type ThesisGetResponse, type ThesisID, type ThesisListPage, type ThesisMedia, type ThesisPageParams, type ThesisPublicationSummary, type ThesisPublisher, type ThesisReadScope, type ThesisRecommendation, type ThesisRecommendationPage, type ThesisResearchStatus, type ThesisResponse, type ThesisRewriteMode, type ThesisSignal, type ThesisSignalEnabledResponse, type ThesisSignalEntry, type ThesisSignalEvidenceExcerpt, type ThesisSignalSource, type ThesisSignalsResponse, type ThesisSourceReference, type ThesisStarredResponse, type ThesisVisibility, type TradingPairCandidate, type TradingPairSearchParams, type TradingPairSearchResponse, TradingPairsResource, 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, type UnfollowPlaybookResponse, type UnresolvedTicker, type UnsubscribeBatchParams, type UnsubscribeBatchResponse, type UpdateThesisParams, VERSION, type WatchlistPage, type WatchlistTicker, type WatchlistTickerKind, type WatchlistTickerSpec, type WatchlistTickersParams, type XAccount, type XConnectionStatus, type XPost, type XReadPage, type XReadParams, XResource, getViewerToken, installPlaybookRuntime, mapUdfErrorResponse, playbookIdFromToken, subscribe, udf };
3438
+ export { type AddToWatchlistResult, type AgentSchedule, type AgentScheduleBounds, type AgentScheduleFailureCode, type AgentScheduleRule, type AgentScheduleStatus, type AgentScheduleTarget, AlertsResource, AlvaClient, type AlvaClientConfig, AlvaError, type AutomationAlertDelivery, type AutomationAlertDeliveryGetRequest, AutomationAlertDeliveryResource, type AutomationAlertDeliveryUpdateRequest, type AutomationAlertDeliveryUpdateResponse, type AutomationEmailDelivery, AutomationResource, type ChannelGroupAdminInfo, type ChannelGroupCallerInfo, type ChannelGroupHistoryParams, type ChannelGroupHistoryResponse, type ChannelGroupSubscription, type ChannelGroupSubscriptionContextResponse, type ChannelGroupSubscriptionListResponse, type ChannelGroupSubscriptionMutationParams, type ChannelGroupSubscriptionMutationResponse, type ChannelGroupSubscriptionSessionParams, type ChannelGroupSubscriptionTarget, type ChannelGroupSubscriptionTargetType, CliUsageError, type CompanyEarningsCatalog, type CompanyEarningsContentStatus, type CompanyEarningsContext, type CompanyEarningsEvent, type CompanyEarningsParams, type CompanyEarningsPeriod, type CompanyEarningsRelease, type CompanyEarningsSession, type CompanyEarningsStatus, type CompanyEarningsTranscript, type CompanyEarningsTranscriptEntry, type CompanyEarningsTranscriptSection, type CompanyFiscalQuarter, type CompanyNarrative, type CompanyNarrativeChangeLogEntry, type CompanyNarrativeContext, type CompanyNarrativeHistory, type CompanyNarrativeSnapshot, CompanyNewsResource, type CompanyPostEarningsSummary, type CompanyPreEarningsAnalysis, type CreateAllowanceParams, type CreateAllowanceResponse, type CreateCompanyNewsParams, type CreateCompanyNewsResponse, type CreateThesisParams, type CreditAllowance, type CreditWallet, type CreditWalletItem, type CreditWalletItemConnection, type CreditWalletItemEdge, type CreditWalletItemsParams, type CreditWalletItemsResponse, type CreditWalletPageInfo, type DeleteFunctionParams, type FeedDeleteRequest, type FeedDeleteResponse, type FeedListItem, type FeedListParams, type FeedListResponse, type FeedListStatus, type FeedStatusUpdateRequest, type FeedStatusUpdateResponse, type FollowPageInfo, type FollowPageParams, type FollowPlaybookResponse, type FollowProfile, type FollowProfileKind, type FollowedProfilesParams, type FollowingThesesPage, type FollowingThesesParams, type FollowingThesisAuthor, type FollowingThesisItem, FollowsResource, type ForYouConnection, type ForYouEntry, type ForYouListParams, ForYouResource, type ForYouThesesParams, 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 GroupChatMessage, type InvokeFunctionParams, type InvokeFunctionResponse, type ListAllowancesResponse, type ListFunctionsParams, type ListFunctionsResponse, type ListThesesParams, type ListThesisSignalsParams, type ManageAgentScheduleParams, MarketsResource, type NotificationPreference, type NotificationPreferenceKey, type NotificationPreferenceUpdateParams, type NotificationPreferenceUpdateResponse, type NotificationPreferencesResponse, PBSV_UPDATE_MESSAGE, type PlaybookFollowParams, type PlaybookFunction, type PlaybookSkillFile, type PlaybookSkillFileMeta, type PlaybookSkillMeta, type PlaybookSkillSummary, type PlaybookSkillTagEntry, type ProfileFollowResult, type ProfileRefParams, type ProfilesPage, type PutAgentScheduleParams, type RegisterFunctionParams, type RegisterFunctionResponse, type RelatedThesesPage, type RemoveFromWatchlistResult, type ResolvedTicker, type RevokeAllowanceParams, type RevokeAllowanceResponse, type RewriteThesisParams, type RewriteThesisResponse, SUBSCRIBE_MANAGE_MESSAGE, SUBSCRIBE_PROPOSE_MESSAGE, SUBSCRIBE_RESULT_MESSAGE, SchedulesResource, type SearchProfilesParams, type SetThesisArchivedParams, type SetThesisVisibilityParams, type SkillDoc, type SkillEndpointMetadata, type SkillEndpointTier, type SkillMetadata, type SkillSummary, type StewardBriefedParams, type StewardDecideParams, type StewardDecision, type StewardDigestRun, type StewardDigestRunParams, type StewardDigestRunState, type StewardForwardParams, type StewardPendingFullParams, type StewardPendingItem, type StewardPendingPage, type StewardPendingPageParams, type StewardPendingParams, type StewardPendingResult, StewardResource, type StewardSendDigestRunParams, type StewardSendParams, type StewardTarget, type SubmitFeedbackRequest, type SubmitFeedbackResponse, type SubscribeApi, type SubscribeBatchParams, type SubscribeBatchResponse, type SubscribeProposalInput, type SubscribeProposalResult, ThesesResource, type Thesis, type ThesisAssetCandidate, type ThesisAssetCandidatesResponse, type ThesisAssetMention, type ThesisAssetStance, type ThesisAuthor, type ThesisCreateResponse, type ThesisEntity, type ThesisEntityStance, type ThesisGetResponse, type ThesisID, type ThesisListPage, type ThesisMedia, type ThesisPageParams, type ThesisPublicationSummary, type ThesisPublisher, type ThesisReadScope, type ThesisRecommendation, type ThesisRecommendationPage, type ThesisResearchStatus, type ThesisResponse, type ThesisRewriteMode, type ThesisSignal, type ThesisSignalEnabledResponse, type ThesisSignalEntry, type ThesisSignalEvidenceExcerpt, type ThesisSignalSource, type ThesisSignalsResponse, type ThesisSourceReference, type ThesisStarredResponse, type ThesisVisibility, type TradingPairCandidate, type TradingPairSearchParams, type TradingPairSearchResponse, TradingPairsResource, 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, type UnfollowPlaybookResponse, type UnresolvedTicker, type UnsubscribeBatchParams, type UnsubscribeBatchResponse, type UpdateThesisParams, VERSION, type WatchlistPage, type WatchlistTicker, type WatchlistTickerKind, type WatchlistTickerSpec, type WatchlistTickersParams, type XAccount, type XConnectionStatus, type XPost, type XReadPage, type XReadParams, XResource, getViewerToken, installPlaybookRuntime, mapUdfErrorResponse, playbookIdFromToken, subscribe, udf };
package/dist/index.js CHANGED
@@ -1297,6 +1297,20 @@ function graphQLErrorMessage(errors) {
1297
1297
  return messages.length > 0 ? messages.join("; ") : "GraphQL request failed";
1298
1298
  }
1299
1299
 
1300
+ // src/resources/webOrigin.ts
1301
+ function webOriginFromApiBase(apiBaseUrl) {
1302
+ try {
1303
+ const host = new URL(apiBaseUrl).hostname;
1304
+ const match = /^api-llm\.([a-z0-9-]+)\.alva\.ai$/i.exec(host);
1305
+ if (match) {
1306
+ const env = match[1].toLowerCase();
1307
+ return env === "prd" ? "https://alva.ai" : `https://${env}.alva.ai`;
1308
+ }
1309
+ } catch {
1310
+ }
1311
+ return "https://alva.ai";
1312
+ }
1313
+
1300
1314
  // src/resources/playbooks.ts
1301
1315
  var PLAYBOOK_VISIBILITIES = [
1302
1316
  "public",
@@ -1447,18 +1461,6 @@ var PlaybooksResource = class {
1447
1461
  );
1448
1462
  }
1449
1463
  };
1450
- function webOriginFromApiBase(apiBaseUrl) {
1451
- try {
1452
- const host = new URL(apiBaseUrl).hostname;
1453
- const match = /^api-llm\.([a-z0-9-]+)\.alva\.ai$/i.exec(host);
1454
- if (match) {
1455
- const env = match[1].toLowerCase();
1456
- return env === "prd" ? "https://alva.ai" : `https://${env}.alva.ai`;
1457
- }
1458
- } catch {
1459
- }
1460
- return "https://alva.ai";
1461
- }
1462
1464
  function toAgentPlaybook(raw, webOrigin) {
1463
1465
  const username = raw.creator?.name ?? "";
1464
1466
  const name = raw.name ?? "";
@@ -3015,7 +3017,8 @@ var RETURN_QUERY = `query ToolkitThesisReturn($id: ID!, $detail: Boolean!) {
3015
3017
  thesisReturn(detail: $detail) {
3016
3018
  live value firstFillAtMs pricedAtMs stale computedAtMs
3017
3019
  updates { authorVersionId publishedAtMs startValue updateReturn
3018
- positions { entityId symbol direction startPrice startAtMs endPrice endAtMs end positionReturn currency } }
3020
+ positions { entityId symbol direction startPrice startAtMs endPrice endAtMs end positionReturn currency weight } }
3021
+ allocation { holdings { entityId symbol direction weight } cash }
3019
3022
  }
3020
3023
  } } } }
3021
3024
  }`;
@@ -3084,16 +3087,21 @@ async function thesisWatchpoints(client, id) {
3084
3087
  return { playbookId: id, watchpoints };
3085
3088
  }
3086
3089
  function validThesisReturn(value) {
3087
- if (!record2(value) || typeof value.live !== "boolean" || typeof value.value !== "number" || typeof value.stale !== "boolean" || typeof value.computedAtMs !== "number" || !Array.isArray(value.updates))
3090
+ if (!record2(value) || typeof value.live !== "boolean" || typeof value.value !== "number" || typeof value.stale !== "boolean" || typeof value.computedAtMs !== "number" || !Array.isArray(value.updates) || value.allocation !== null && !validAllocation(value.allocation))
3088
3091
  return false;
3089
3092
  return value.updates.every(
3090
3093
  (update) => record2(update) && nonempty(update.authorVersionId) && typeof update.publishedAtMs === "number" && typeof update.startValue === "number" && Array.isArray(update.positions) && update.positions.every(
3091
3094
  (position) => record2(position) && nonempty(position.symbol) && ["BULLISH", "BEARISH"].includes(position.direction) && ["PENDING", "NEXT_UPDATE", "LATEST"].includes(
3092
3095
  position.end
3093
- ) && typeof position.positionReturn === "number"
3096
+ ) && typeof position.positionReturn === "number" && typeof position.weight === "number"
3094
3097
  )
3095
3098
  );
3096
3099
  }
3100
+ function validAllocation(value) {
3101
+ return record2(value) && typeof value.cash === "number" && Array.isArray(value.holdings) && value.holdings.every(
3102
+ (holding) => record2(holding) && nonempty(holding.entityId) && nonempty(holding.symbol) && ["BULLISH", "BEARISH"].includes(holding.direction) && typeof holding.weight === "number"
3103
+ );
3104
+ }
3097
3105
  async function graphql(client, document, variables) {
3098
3106
  const response = await client._request("POST", "/query", {
3099
3107
  body: { query: document, variables }
@@ -3150,6 +3158,13 @@ function notFound() {
3150
3158
  }
3151
3159
 
3152
3160
  // src/resources/theses.ts
3161
+ var THESIS_SIGNAL_KINDS = [
3162
+ "fundamentals",
3163
+ "macro",
3164
+ "technicals",
3165
+ "commentary"
3166
+ ];
3167
+ var THESIS_SIGNAL_MIN_IMPORTANCES = ["all", "notable", "major"];
3153
3168
  var SET_THESIS_STARRED = `mutation SetThesisStarred($input: SetThesisStarredInput!) {
3154
3169
  setThesisStarred(input: $input) {
3155
3170
  thesisId
@@ -3255,9 +3270,12 @@ var ThesesResource = class {
3255
3270
  async create(params) {
3256
3271
  this.client._requireAuth();
3257
3272
  const body = createBody(params);
3258
- return thesisResponse(
3273
+ const response = thesisResponse(
3259
3274
  await this.client._request("POST", "/api/v1/theses", { body })
3260
3275
  );
3276
+ requireKeptWeights(body.entity_stances, response.thesis.entity_stances);
3277
+ const webOrigin = webOriginFromApiBase(this.client.baseUrl);
3278
+ return { ...response, url: `${webOrigin}/thesis/${response.thesis.id}` };
3261
3279
  }
3262
3280
  async get(id) {
3263
3281
  this.client._requireAuth();
@@ -3346,6 +3364,7 @@ var ThesesResource = class {
3346
3364
  if (response.thesis.id !== thesisID) {
3347
3365
  throw invalidResponse3("update response must match the requested thesis");
3348
3366
  }
3367
+ requireKeptWeights(body.entity_stances, response.thesis.entity_stances);
3349
3368
  return response;
3350
3369
  }
3351
3370
  /**
@@ -3380,7 +3399,11 @@ var ThesesResource = class {
3380
3399
  body: current.thesis.body,
3381
3400
  title: current.thesis.title,
3382
3401
  entity_ids: current.thesis.entity_ids,
3383
- entity_stances: current.thesis.entity_stances,
3402
+ // Directions only: archiving keeps the current Update and unarchiving
3403
+ // keeps its shares without restating them.
3404
+ entity_stances: current.thesis.entity_stances?.map(
3405
+ ({ entity_id, stance }) => ({ entity_id, stance })
3406
+ ),
3384
3407
  visibility: current.thesis.visibility,
3385
3408
  archived: params.archived,
3386
3409
  medias: current.thesis.medias,
@@ -3427,6 +3450,45 @@ var ThesesResource = class {
3427
3450
  is_starred: returnedStarred
3428
3451
  };
3429
3452
  }
3453
+ /**
3454
+ * Reads which Signals one of the caller's Theses shows: its setting, or every
3455
+ * kind and `all` when it has none. Without an id, reads the setting the caller
3456
+ * last saved, which prefills a new Thesis. Only the Thesis's author can read it.
3457
+ */
3458
+ async getSignalPreferences(id) {
3459
+ this.client._requireAuth();
3460
+ if (id === void 0) {
3461
+ return signalPreferencesResponse(
3462
+ await this.client._request("GET", "/api/v1/theses/signal-preferences"),
3463
+ null
3464
+ );
3465
+ }
3466
+ const thesisID = requireID(id, "id");
3467
+ return signalPreferencesResponse(
3468
+ await this.client._request(
3469
+ "GET",
3470
+ `/api/v1/theses/${thesisID}/signal-preferences`
3471
+ ),
3472
+ thesisID
3473
+ );
3474
+ }
3475
+ /**
3476
+ * Replaces which Signals one of the caller's Theses shows, for every reader,
3477
+ * and records it as the caller's last choice. Author only.
3478
+ */
3479
+ async setSignalPreferences(id, preferences) {
3480
+ this.client._requireAuth();
3481
+ const thesisID = requireID(id, "id");
3482
+ const input = requireSignalPreferences(preferences);
3483
+ return signalPreferencesResponse(
3484
+ await this.client._request(
3485
+ "PUT",
3486
+ `/api/v1/theses/${thesisID}/signal-preferences`,
3487
+ { body: { signal_preferences: input } }
3488
+ ),
3489
+ thesisID
3490
+ );
3491
+ }
3430
3492
  async setSignalEnabled(id, enabled) {
3431
3493
  this.client._requireAuth();
3432
3494
  const thesisID = requireID(id, "id");
@@ -3533,6 +3595,10 @@ function createBody(params) {
3533
3595
  body.tickers = requireTickers(params.tickers);
3534
3596
  if (params.track_return !== void 0)
3535
3597
  body.track_return = requireTrackReturn(params.track_return);
3598
+ if (params.signal_preferences !== void 0)
3599
+ body.signal_preferences = requireSignalPreferences(
3600
+ params.signal_preferences
3601
+ );
3536
3602
  if (params.entity_stances !== void 0) {
3537
3603
  body.entity_stances = requireEntityStances(
3538
3604
  params.entity_stances,
@@ -3541,6 +3607,43 @@ function createBody(params) {
3541
3607
  }
3542
3608
  return body;
3543
3609
  }
3610
+ function requireSignalPreferences(value) {
3611
+ if (!isRecord(value) || !Array.isArray(value.kinds))
3612
+ throw invalidArgument(
3613
+ "signal_preferences must have kinds and min_importance"
3614
+ );
3615
+ const kinds = [...new Set(value.kinds)];
3616
+ if (kinds.length === 0 || !kinds.every(
3617
+ (kind) => THESIS_SIGNAL_KINDS.includes(kind)
3618
+ ))
3619
+ throw invalidArgument(
3620
+ `signal kinds must be one or more of ${THESIS_SIGNAL_KINDS.join(", ")}`
3621
+ );
3622
+ if (!THESIS_SIGNAL_MIN_IMPORTANCES.includes(
3623
+ value.min_importance
3624
+ ))
3625
+ throw invalidArgument(
3626
+ `min_importance must be ${THESIS_SIGNAL_MIN_IMPORTANCES.join(", ")}`
3627
+ );
3628
+ return {
3629
+ kinds,
3630
+ min_importance: value.min_importance
3631
+ };
3632
+ }
3633
+ function signalPreferencesResponse(value, thesisID) {
3634
+ if (!isRecord(value) || value.thesis_id !== thesisID)
3635
+ throw invalidResponse3(
3636
+ "Signal setting response must name the requested thesis"
3637
+ );
3638
+ try {
3639
+ return {
3640
+ thesis_id: thesisID,
3641
+ preferences: requireSignalPreferences(value.signal_preferences)
3642
+ };
3643
+ } catch {
3644
+ throw invalidResponse3("response contains an unknown Signal setting");
3645
+ }
3646
+ }
3544
3647
  var ENTITY_STANCES = [
3545
3648
  "unknown",
3546
3649
  "bullish",
@@ -3606,9 +3709,44 @@ function requireEntityStances(value, entityIDs) {
3606
3709
  seen.add(entityID);
3607
3710
  if (!ENTITY_STANCES.includes(item.stance))
3608
3711
  throw invalidArgument(`entity_stances[${index}].stance is invalid`);
3609
- return { entity_id: entityID, stance: item.stance };
3712
+ const stance = {
3713
+ entity_id: entityID,
3714
+ stance: item.stance
3715
+ };
3716
+ if (item.weight !== void 0) {
3717
+ if (!validWeight(item.weight))
3718
+ throw invalidArgument(
3719
+ `entity_stances[${index}].weight must be a fraction in (0, 1] with at most four decimals`
3720
+ );
3721
+ if (stance.stance !== "bullish" && stance.stance !== "bearish")
3722
+ throw invalidArgument(
3723
+ `entity_stances[${index}].weight needs a bullish or bearish stance`
3724
+ );
3725
+ stance.weight = item.weight;
3726
+ }
3727
+ return stance;
3610
3728
  });
3611
3729
  }
3730
+ function validWeight(value) {
3731
+ if (typeof value !== "number" || !Number.isFinite(value)) return false;
3732
+ const bps = Math.round(value * 1e4);
3733
+ return bps >= 1 && bps <= 1e4 && Math.abs(value * 1e4 - bps) <= 1e-6;
3734
+ }
3735
+ function requireKeptWeights(sent, returned) {
3736
+ if (!Array.isArray(sent)) return;
3737
+ const weights = /* @__PURE__ */ new Map();
3738
+ for (const item of returned ?? []) {
3739
+ if (item.weight !== void 0) weights.set(item.entity_id, item.weight);
3740
+ }
3741
+ for (const item of sent) {
3742
+ if (item.weight === void 0) continue;
3743
+ const kept = weights.get(item.entity_id);
3744
+ if (kept === void 0 || Math.abs(kept - item.weight) > 1e-9)
3745
+ throw invalidResponse3(
3746
+ "the Update was published without the weights sent: the server predates weights"
3747
+ );
3748
+ }
3749
+ }
3612
3750
  function updateBody(params) {
3613
3751
  const body = {
3614
3752
  request_id: requireRequestID(params.request_id),
@@ -3716,6 +3854,13 @@ function thesisResponse(response) {
3716
3854
  );
3717
3855
  stance.direction = item.direction;
3718
3856
  }
3857
+ if (item.weight !== void 0) {
3858
+ if (!validWeight(item.weight))
3859
+ throw invalidResponse3(
3860
+ "thesis.entity_stances contains invalid weight"
3861
+ );
3862
+ stance.weight = item.weight;
3863
+ }
3719
3864
  return stance;
3720
3865
  });
3721
3866
  }
@@ -4580,13 +4725,12 @@ function followingThesesPage(value) {
4580
4725
  }
4581
4726
  function followingThesisAuthor(value) {
4582
4727
  if (value === null) return null;
4583
- if (!record3(value) || value.kind !== "user" && value.kind !== "person" || typeof value.display_name !== "string" || value.username !== void 0 && typeof value.username !== "string" || value.slug !== void 0 && typeof value.slug !== "string") {
4728
+ if (!record3(value) || value.kind !== "user" || typeof value.username !== "string" || typeof value.display_name !== "string") {
4584
4729
  throw invalidFollowingTheses("invalid following theses author");
4585
4730
  }
4586
4731
  return {
4587
4732
  kind: value.kind,
4588
- ...value.username === void 0 ? {} : { username: value.username },
4589
- ...value.slug === void 0 ? {} : { slug: value.slug },
4733
+ username: value.username,
4590
4734
  display_name: value.display_name
4591
4735
  };
4592
4736
  }
@@ -7262,7 +7406,7 @@ var installPlaybookRuntime = (targetWindow) => {
7262
7406
  };
7263
7407
 
7264
7408
  // src/index.ts
7265
- var VERSION = true ? "0.38.0-beta.0" : "dev";
7409
+ var VERSION = true ? "0.38.0-beta.2" : "dev";
7266
7410
  export {
7267
7411
  AlertsResource,
7268
7412
  AlvaClient,