@alva-ai/toolkit 0.22.0 → 0.23.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
@@ -1860,6 +1860,133 @@ declare class CreditsResource {
1860
1860
  private graphql;
1861
1861
  }
1862
1862
 
1863
+ type CompanyFiscalQuarter = 'Q1' | 'Q2' | 'Q3' | 'Q4';
1864
+ type CompanyEarningsEvent = 'latest-completed' | 'next-confirmed';
1865
+ type CompanyEarningsStatus = 'UPCOMING' | 'COMPLETED';
1866
+ type CompanyEarningsContentStatus = 'AVAILABLE' | 'NOT_AVAILABLE_YET' | 'UNAVAILABLE';
1867
+ type CompanyEarningsSession = 'BEFORE_MARKET_OPEN' | 'AFTER_MARKET_CLOSE';
1868
+ interface CompanyNarrative {
1869
+ asOf: string;
1870
+ generatedAtMs: number;
1871
+ narrative: string;
1872
+ peers: string;
1873
+ }
1874
+ interface CompanyNarrativeSnapshot {
1875
+ asOf: string;
1876
+ generatedAtMs: number;
1877
+ narrative: string;
1878
+ }
1879
+ interface CompanyNarrativeChangeLogEntry {
1880
+ asOf: string;
1881
+ generatedAtMs: number;
1882
+ narrativeChangeLog: string | null;
1883
+ }
1884
+ interface CompanyNarrativeHistory {
1885
+ snapshots: CompanyNarrativeSnapshot[];
1886
+ changeLog: CompanyNarrativeChangeLogEntry[];
1887
+ }
1888
+ interface CompanyNarrativeContext {
1889
+ ticker: string;
1890
+ current: CompanyNarrative | null;
1891
+ history: CompanyNarrativeHistory | null;
1892
+ }
1893
+ interface CompanyEarningsPeriod {
1894
+ fiscalYear: number;
1895
+ fiscalQuarter: CompanyFiscalQuarter;
1896
+ label: string;
1897
+ fiscalDateEnding: string;
1898
+ earningsDate: string;
1899
+ session: CompanyEarningsSession | null;
1900
+ status: CompanyEarningsStatus;
1901
+ isDefault: boolean;
1902
+ }
1903
+ interface CompanyEarningsCatalog {
1904
+ periods: CompanyEarningsPeriod[];
1905
+ defaultPeriod: CompanyEarningsPeriod | null;
1906
+ unresolvedEventCount: number;
1907
+ }
1908
+ interface CompanyPreEarningsAnalysis {
1909
+ status: CompanyEarningsContentStatus;
1910
+ asOf: string | null;
1911
+ summary: string | null;
1912
+ whatWouldChangeView: string | null;
1913
+ mainQuestion: string | null;
1914
+ investorFocus: string[];
1915
+ consensusAndGuidance: string | null;
1916
+ stockSetup: string | null;
1917
+ eventRisk: string | null;
1918
+ whatWouldDriveUpside: string | null;
1919
+ bullCase: string | null;
1920
+ baseCase: string | null;
1921
+ bearCase: string | null;
1922
+ keyAsymmetry: string | null;
1923
+ consensusN: number | null;
1924
+ consensusObservedAt: string | null;
1925
+ }
1926
+ interface CompanyEarningsRelease {
1927
+ status: CompanyEarningsContentStatus;
1928
+ releaseDate: string | null;
1929
+ url: string | null;
1930
+ }
1931
+ interface CompanyEarningsTranscriptEntry {
1932
+ speaker: string;
1933
+ title: string;
1934
+ content: string;
1935
+ }
1936
+ interface CompanyEarningsTranscriptSection {
1937
+ name: string;
1938
+ entries: CompanyEarningsTranscriptEntry[];
1939
+ }
1940
+ interface CompanyEarningsTranscript {
1941
+ status: CompanyEarningsContentStatus;
1942
+ date: string | null;
1943
+ publishedAtMs: number | null;
1944
+ sections: CompanyEarningsTranscriptSection[];
1945
+ }
1946
+ interface CompanyPostEarningsSummary {
1947
+ status: CompanyEarningsContentStatus;
1948
+ asOf: string | null;
1949
+ reportedCurrency: string | null;
1950
+ evidenceState: 'INITIAL_PRINT' | 'POST_CALL' | null;
1951
+ openingQuote: string | null;
1952
+ openingQuoteSpeaker: string | null;
1953
+ openingQuoteTitle: string | null;
1954
+ openingQuoteNote: string | null;
1955
+ buriedSignals: string[];
1956
+ whatYouShouldKnow: string[];
1957
+ consensusN: number | null;
1958
+ consensusObservedAt: string | null;
1959
+ }
1960
+ interface CompanyEarningsContext {
1961
+ ticker: string;
1962
+ period: CompanyEarningsPeriod;
1963
+ preEarningsAnalysis: CompanyPreEarningsAnalysis;
1964
+ earningsRelease: CompanyEarningsRelease;
1965
+ earningsTranscript: CompanyEarningsTranscript;
1966
+ postEarningsSummary: CompanyPostEarningsSummary;
1967
+ }
1968
+ type CompanyEarningsParams = {
1969
+ ticker: string;
1970
+ event?: CompanyEarningsEvent;
1971
+ fiscalYear?: never;
1972
+ fiscalQuarter?: never;
1973
+ } | {
1974
+ ticker: string;
1975
+ event?: never;
1976
+ fiscalYear: number;
1977
+ fiscalQuarter: CompanyFiscalQuarter;
1978
+ };
1979
+ declare class MarketsResource {
1980
+ private client;
1981
+ constructor(client: AlvaClient);
1982
+ narrative(ticker: string): Promise<CompanyNarrativeContext>;
1983
+ earningsPeriods(ticker: string): Promise<CompanyEarningsCatalog>;
1984
+ earnings(params: CompanyEarningsParams): Promise<CompanyEarningsContext>;
1985
+ private selectPeriod;
1986
+ private notFound;
1987
+ private graphql;
1988
+ }
1989
+
1863
1990
  interface RequestOptions {
1864
1991
  query?: Record<string, unknown>;
1865
1992
  body?: unknown;
@@ -1924,6 +2051,7 @@ declare class AlvaClient {
1924
2051
  private _feedback?;
1925
2052
  private _functions?;
1926
2053
  private _credits?;
2054
+ private _markets?;
1927
2055
  constructor(config: AlvaClientConfig);
1928
2056
  get fs(): FsResource;
1929
2057
  get run(): RunResource;
@@ -1952,6 +2080,7 @@ declare class AlvaClient {
1952
2080
  get feedback(): FeedbackResource;
1953
2081
  get functions(): FunctionsResource;
1954
2082
  get credits(): CreditsResource;
2083
+ get markets(): MarketsResource;
1955
2084
  _requireAuth(): void;
1956
2085
  _request(method: string, path: string, options?: RequestOptions): Promise<unknown>;
1957
2086
  }
package/dist/cli.js CHANGED
@@ -8459,6 +8459,319 @@ var CreditsResource = class {
8459
8459
  }
8460
8460
  };
8461
8461
 
8462
+ // src/resources/markets.ts
8463
+ var FISCAL_QUARTERS = [
8464
+ "Q1",
8465
+ "Q2",
8466
+ "Q3",
8467
+ "Q4"
8468
+ ];
8469
+ var EARNINGS_EVENTS = [
8470
+ "latest-completed",
8471
+ "next-confirmed"
8472
+ ];
8473
+ var NARRATIVE_QUERY = `
8474
+ query ToolkitCompanyNarrative($ticker: String!) {
8475
+ market {
8476
+ entity(input: { ticker: $ticker, kind: STOCK }) {
8477
+ ticker
8478
+ companyInsight {
8479
+ asOf
8480
+ generatedAtMs
8481
+ narrative
8482
+ peers
8483
+ }
8484
+ companyInsightHistory {
8485
+ snapshots {
8486
+ asOf
8487
+ generatedAtMs
8488
+ narrative
8489
+ }
8490
+ changeLog {
8491
+ asOf
8492
+ generatedAtMs
8493
+ narrativeChangeLog
8494
+ }
8495
+ }
8496
+ }
8497
+ }
8498
+ }
8499
+ `.trim();
8500
+ var EARNINGS_CATALOG_QUERY = `
8501
+ query ToolkitCompanyEarningsCatalog($ticker: String!) {
8502
+ market {
8503
+ entity(input: { ticker: $ticker, kind: STOCK }) {
8504
+ ticker
8505
+ earningsPeriods {
8506
+ unresolvedEventCount
8507
+ defaultPeriod {
8508
+ fiscalYear
8509
+ fiscalQuarter
8510
+ label
8511
+ fiscalDateEnding
8512
+ earningsDate
8513
+ session
8514
+ status
8515
+ isDefault
8516
+ }
8517
+ periods {
8518
+ fiscalYear
8519
+ fiscalQuarter
8520
+ label
8521
+ fiscalDateEnding
8522
+ earningsDate
8523
+ session
8524
+ status
8525
+ isDefault
8526
+ }
8527
+ }
8528
+ }
8529
+ }
8530
+ }
8531
+ `.trim();
8532
+ var EARNINGS_QUERY = `
8533
+ query ToolkitCompanyEarnings($ticker: String!, $input: CompanyEarningsInput) {
8534
+ market {
8535
+ entity(input: { ticker: $ticker, kind: STOCK }) {
8536
+ ticker
8537
+ earnings(input: $input) {
8538
+ period {
8539
+ fiscalYear
8540
+ fiscalQuarter
8541
+ label
8542
+ fiscalDateEnding
8543
+ earningsDate
8544
+ session
8545
+ status
8546
+ isDefault
8547
+ }
8548
+ preEarningsAnalysis {
8549
+ status
8550
+ asOf
8551
+ summary
8552
+ whatWouldChangeView
8553
+ mainQuestion
8554
+ investorFocus
8555
+ consensusAndGuidance
8556
+ stockSetup
8557
+ eventRisk
8558
+ whatWouldDriveUpside
8559
+ bullCase
8560
+ baseCase
8561
+ bearCase
8562
+ keyAsymmetry
8563
+ consensusN
8564
+ consensusObservedAt
8565
+ }
8566
+ earningsRelease {
8567
+ status
8568
+ releaseDate
8569
+ url
8570
+ }
8571
+ earningsTranscript {
8572
+ status
8573
+ date
8574
+ publishedAtMs
8575
+ sections {
8576
+ name
8577
+ entries {
8578
+ speaker
8579
+ title
8580
+ content
8581
+ }
8582
+ }
8583
+ }
8584
+ postEarningsSummary {
8585
+ status
8586
+ asOf
8587
+ reportedCurrency
8588
+ evidenceState
8589
+ openingQuote
8590
+ openingQuoteSpeaker
8591
+ openingQuoteTitle
8592
+ openingQuoteNote
8593
+ buriedSignals
8594
+ whatYouShouldKnow
8595
+ consensusN
8596
+ consensusObservedAt
8597
+ }
8598
+ }
8599
+ }
8600
+ }
8601
+ }
8602
+ `.trim();
8603
+ function graphQLErrorMessage2(errors) {
8604
+ const messages = errors.map(
8605
+ (error) => typeof error.message === "string" && error.message ? error.message : void 0
8606
+ ).filter((message) => Boolean(message));
8607
+ return messages.length > 0 ? messages.join("; ") : "GraphQL request failed";
8608
+ }
8609
+ function normalizedTicker(ticker) {
8610
+ const normalized = ticker.trim().toUpperCase();
8611
+ if (!normalized) {
8612
+ throw new AlvaError("INVALID_ARGUMENT", "ticker is required", 400);
8613
+ }
8614
+ return normalized;
8615
+ }
8616
+ var MarketsResource = class {
8617
+ constructor(client) {
8618
+ this.client = client;
8619
+ }
8620
+ client;
8621
+ async narrative(ticker) {
8622
+ this.client._requireAuth();
8623
+ const requestedTicker = normalizedTicker(ticker);
8624
+ const data = await this.graphql(NARRATIVE_QUERY, {
8625
+ ticker: requestedTicker
8626
+ });
8627
+ const entity = data.market?.entity;
8628
+ if (!entity) {
8629
+ throw this.notFound(requestedTicker);
8630
+ }
8631
+ return {
8632
+ ticker: entity.ticker,
8633
+ current: entity.companyInsight,
8634
+ history: entity.companyInsightHistory
8635
+ };
8636
+ }
8637
+ async earningsPeriods(ticker) {
8638
+ this.client._requireAuth();
8639
+ const requestedTicker = normalizedTicker(ticker);
8640
+ const data = await this.graphql(
8641
+ EARNINGS_CATALOG_QUERY,
8642
+ { ticker: requestedTicker }
8643
+ );
8644
+ const entity = data.market?.entity;
8645
+ if (!entity) {
8646
+ throw this.notFound(requestedTicker);
8647
+ }
8648
+ if (!entity.earningsPeriods) {
8649
+ throw new AlvaError(
8650
+ "MARKETS_EARNINGS_NOT_COVERED",
8651
+ `No earnings periods are available for ${entity.ticker}`,
8652
+ 404,
8653
+ { ticker: entity.ticker }
8654
+ );
8655
+ }
8656
+ return entity.earningsPeriods;
8657
+ }
8658
+ async earnings(params) {
8659
+ this.client._requireAuth();
8660
+ const ticker = normalizedTicker(params.ticker);
8661
+ const requestedEvent = params.event;
8662
+ const requestedFiscalYear = params.fiscalYear;
8663
+ const requestedFiscalQuarter = params.fiscalQuarter;
8664
+ const hasExplicitPeriod = requestedFiscalYear !== void 0 || requestedFiscalQuarter !== void 0;
8665
+ if (requestedEvent !== void 0 && hasExplicitPeriod) {
8666
+ throw new AlvaError(
8667
+ "INVALID_ARGUMENT",
8668
+ "event cannot be combined with fiscalYear or fiscalQuarter",
8669
+ 400
8670
+ );
8671
+ }
8672
+ if (requestedFiscalYear === void 0 !== (requestedFiscalQuarter === void 0)) {
8673
+ throw new AlvaError(
8674
+ "INVALID_ARGUMENT",
8675
+ "fiscalYear and fiscalQuarter must be provided together",
8676
+ 400
8677
+ );
8678
+ }
8679
+ if (requestedEvent !== void 0 && !EARNINGS_EVENTS.includes(requestedEvent)) {
8680
+ throw new AlvaError(
8681
+ "INVALID_ARGUMENT",
8682
+ `Unknown earnings event selector: ${requestedEvent}`,
8683
+ 400
8684
+ );
8685
+ }
8686
+ if (requestedFiscalYear !== void 0 && (!Number.isInteger(requestedFiscalYear) || requestedFiscalYear < 1900 || requestedFiscalYear > 9999)) {
8687
+ throw new AlvaError(
8688
+ "INVALID_ARGUMENT",
8689
+ "fiscalYear must be an integer between 1900 and 9999",
8690
+ 400
8691
+ );
8692
+ }
8693
+ if (requestedFiscalQuarter !== void 0 && !FISCAL_QUARTERS.includes(requestedFiscalQuarter)) {
8694
+ throw new AlvaError(
8695
+ "INVALID_ARGUMENT",
8696
+ "fiscalQuarter must be Q1, Q2, Q3, or Q4",
8697
+ 400
8698
+ );
8699
+ }
8700
+ let fiscalYear;
8701
+ let fiscalQuarter;
8702
+ if (requestedFiscalYear !== void 0 && requestedFiscalQuarter !== void 0) {
8703
+ fiscalYear = requestedFiscalYear;
8704
+ fiscalQuarter = requestedFiscalQuarter;
8705
+ } else {
8706
+ const event = requestedEvent ?? "latest-completed";
8707
+ const catalog = await this.earningsPeriods(ticker);
8708
+ const period = this.selectPeriod(catalog, event, ticker);
8709
+ fiscalYear = period.fiscalYear;
8710
+ fiscalQuarter = period.fiscalQuarter;
8711
+ }
8712
+ const data = await this.graphql(EARNINGS_QUERY, {
8713
+ ticker,
8714
+ input: { fiscalYear, fiscalQuarter }
8715
+ });
8716
+ const entity = data.market?.entity;
8717
+ if (!entity) {
8718
+ throw this.notFound(ticker);
8719
+ }
8720
+ if (!entity.earnings) {
8721
+ throw new AlvaError(
8722
+ "MARKETS_EARNINGS_NOT_COVERED",
8723
+ `No earnings content is available for ${entity.ticker} FY${fiscalYear} ${fiscalQuarter}`,
8724
+ 404,
8725
+ { ticker: entity.ticker, fiscalYear, fiscalQuarter }
8726
+ );
8727
+ }
8728
+ return { ticker: entity.ticker, ...entity.earnings };
8729
+ }
8730
+ selectPeriod(catalog, event, ticker) {
8731
+ if (event === "latest-completed") {
8732
+ if (catalog.defaultPeriod) return catalog.defaultPeriod;
8733
+ } else {
8734
+ const upcoming = catalog.periods.filter((period) => period.status === "UPCOMING").sort((a, b) => a.earningsDate.localeCompare(b.earningsDate));
8735
+ if (upcoming.length > 0) return upcoming[0];
8736
+ }
8737
+ throw new AlvaError(
8738
+ "MARKETS_EARNINGS_EVENT_NOT_FOUND",
8739
+ `No ${event} earnings event is available for ${ticker}`,
8740
+ 404,
8741
+ { ticker, event }
8742
+ );
8743
+ }
8744
+ notFound(ticker) {
8745
+ return new AlvaError(
8746
+ "MARKETS_ENTITY_NOT_FOUND",
8747
+ `No stock entity was found for ${ticker}`,
8748
+ 404,
8749
+ { ticker }
8750
+ );
8751
+ }
8752
+ async graphql(query, variables) {
8753
+ const response = await this.client._request("POST", "/query", {
8754
+ body: { query, variables }
8755
+ });
8756
+ if (response.errors && response.errors.length > 0) {
8757
+ throw new AlvaError(
8758
+ "GRAPHQL_ERROR",
8759
+ graphQLErrorMessage2(response.errors),
8760
+ 400,
8761
+ { errors: response.errors }
8762
+ );
8763
+ }
8764
+ if (!response.data) {
8765
+ throw new AlvaError(
8766
+ "GRAPHQL_EMPTY_RESPONSE",
8767
+ "GraphQL response did not include data",
8768
+ 502
8769
+ );
8770
+ }
8771
+ return response.data;
8772
+ }
8773
+ };
8774
+
8462
8775
  // src/client.ts
8463
8776
  var DEFAULT_BASE_URL = "https://api-llm.prd.alva.ai";
8464
8777
  var DEFAULT_ARRAYS_BASE_URL = "https://data-tools.prd.space.id";
@@ -8566,6 +8879,7 @@ var AlvaClient = class {
8566
8879
  _feedback;
8567
8880
  _functions;
8568
8881
  _credits;
8882
+ _markets;
8569
8883
  constructor(config) {
8570
8884
  this.baseUrl = config.baseUrl ?? DEFAULT_BASE_URL;
8571
8885
  this.arraysBaseUrl = config.arraysBaseUrl ?? DEFAULT_ARRAYS_BASE_URL;
@@ -8660,6 +8974,9 @@ var AlvaClient = class {
8660
8974
  get credits() {
8661
8975
  return this._credits ??= new CreditsResource(this);
8662
8976
  }
8977
+ get markets() {
8978
+ return this._markets ??= new MarketsResource(this);
8979
+ }
8663
8980
  _requireAuth() {
8664
8981
  if (!this.pbsvToken && !this.viewer_token && !this.apiKey) {
8665
8982
  throw new AlvaError(
@@ -9369,6 +9686,10 @@ var COMMAND_DEFINITIONS = [
9369
9686
  command("portfolio activities", {
9370
9687
  values: ["account-id", "limit", "page-token"]
9371
9688
  }),
9689
+ command("markets narrative", { values: ["ticker"] }),
9690
+ command("markets earnings", {
9691
+ values: ["ticker", "event", "fiscal-year", "fiscal-quarter"]
9692
+ }),
9372
9693
  command("trading accounts"),
9373
9694
  command("trading portfolio", { values: ["account-id"] }),
9374
9695
  command("trading orders", {
@@ -13655,7 +13976,7 @@ ${formatReport(report, "human")}
13655
13976
  }
13656
13977
 
13657
13978
  // src/cli/dispatch.ts
13658
- var CLI_VERSION = true ? "0.22.0" : "dev";
13979
+ var CLI_VERSION = true ? "0.23.0" : "dev";
13659
13980
  var DEFAULT_RUN_TIMEOUT_MS = 6e5;
13660
13981
  var RUN_TIMEOUT_ENV = "ALVA_RUN_TIMEOUT_MS";
13661
13982
  var GLOBAL_VALUE_FLAGS = Object.entries(GLOBAL_FLAG_DEFINITIONS).filter(([, kind]) => kind === "value").map(([name]) => `--${name}`);
@@ -13718,6 +14039,7 @@ Commands:
13718
14039
  subscriptions Playbook follows and feed alert subscriptions
13719
14040
  remix Save playbook remix lineage
13720
14041
  portfolio Connected-account portfolio (accounts, summary, activities)
14042
+ markets Company narrative and earnings context (narrative, earnings)
13721
14043
  trading Trading operations (accounts, portfolio, orders, subscriptions, equity-history, risk-rules, subscribe, unsubscribe, execute, update-risk-rules)
13722
14044
  broker Agentic order execution \u2014 venue-native passthrough to trex (accounts, quote, order, balance, positions, ...; run 'alva broker describe')
13723
14045
  auth Authentication (login)
@@ -13883,10 +14205,14 @@ Subcommand flags:
13883
14205
  revoke --path (required), --subject <s> (required), --permission <p> (required)
13884
14206
 
13885
14207
  Path conventions:
13886
- ~/... Home-relative path (expands to /alva/home/<username>/...)
14208
+ ~/... Home-relative filesystem location (for example, --path and --link-path)
13887
14209
  /alva/home/alice/... Absolute path (required for public/unauthenticated reads)
13888
14210
  Quote tilde paths to prevent shell expansion: --path "~/data" (not --path ~/data).
13889
14211
 
14212
+ Symlink targets:
14213
+ Symlink target paths are stored verbatim with POSIX semantics; they are not home-expanded.
14214
+ Use a path relative to the link's parent (for example, "real-file.txt") or a true /... absolute path.
14215
+
13890
14216
  Time series reads:
13891
14217
  Feed data directories are synth mounts. Their supported read suffixes are:
13892
14218
  @last/{n} Last N data points (chronological order)
@@ -13918,7 +14244,7 @@ Examples:
13918
14244
  alva fs chmod --path "~/script.js" --mode 755
13919
14245
  alva fs grant --path "~/feeds/btc-ema" --subject "special:user:*" --permission read
13920
14246
  alva fs revoke --path "~/feeds/btc-ema" --subject "special:user:*" --permission read
13921
- alva fs symlink --target-path "~/real-file.txt" --link-path "~/my-link.txt"
14247
+ alva fs symlink --target-path "real-file.txt" --link-path "~/my-link.txt"
13922
14248
  alva fs readlink --path "~/my-link.txt"`,
13923
14249
  run: `Usage: alva run [options]
13924
14250
 
@@ -14799,6 +15125,46 @@ Examples:
14799
15125
  alva portfolio accounts
14800
15126
  alva portfolio summary --account-id trex:123
14801
15127
  alva portfolio activities --account-id snaptrade:456 --limit 20`,
15128
+ markets: `Usage: alva markets <subcommand> [options]
15129
+
15130
+ Read the Markets backend's canonical company context. The Toolkit resolves
15131
+ earnings events through the backend period catalog; it does not construct ALFS
15132
+ owners, feed slugs, versions, or paths.
15133
+
15134
+ Subcommands:
15135
+ narrative Get the current narrative, history, and narrative change log
15136
+ earnings Get Pre, Release, Transcript, and Post for one fiscal event
15137
+
15138
+ Narrative flags:
15139
+ --ticker <symbol> Stock ticker (required)
15140
+
15141
+ Earnings flags:
15142
+ --ticker <symbol> Stock ticker (required)
15143
+ --event <selector> latest-completed (default) or next-confirmed
15144
+ --fiscal-year <year> Explicit fiscal year; requires --fiscal-quarter
15145
+ --fiscal-quarter <Q1..Q4> Explicit fiscal quarter; requires --fiscal-year
15146
+
15147
+ Do not combine --event with --fiscal-year/--fiscal-quarter. These commands read
15148
+ the current backend view; historical query-as-of gating is not supported yet.
15149
+
15150
+ Output semantics:
15151
+ Narrative is dated Alva analysis. Use current for present-tense company
15152
+ context and history only to explain changes; use separate sources for live
15153
+ prices and official facts.
15154
+
15155
+ Earnings covers one fiscal event. Pre is the dated expectation baseline;
15156
+ Release identifies the official source for reported facts; Transcript holds
15157
+ management statements; Post is Alva's dated interpretation.
15158
+
15159
+ Each Earnings stage has its own status. A missing or unavailable stage does
15160
+ not invalidate valid stages, and an unavailable requested event is never
15161
+ replaced with a different quarter.
15162
+
15163
+ Examples:
15164
+ alva markets narrative --ticker AAPL
15165
+ alva markets earnings --ticker AAPL
15166
+ alva markets earnings --ticker AAPL --event next-confirmed
15167
+ alva markets earnings --ticker AAPL --fiscal-year 2026 --fiscal-quarter Q3`,
14802
15168
  trading: `Usage: alva trading <subcommand> [options]
14803
15169
 
14804
15170
  Manage trading accounts, portfolios, orders, subscriptions, and risk rules.
@@ -17010,6 +17376,67 @@ async function dispatch(client, args, meta, deps) {
17010
17376
  );
17011
17377
  }
17012
17378
  }
17379
+ case "markets": {
17380
+ if (!subcommand)
17381
+ throw new CliUsageError("Missing subcommand for markets", "markets");
17382
+ const ticker = requireFlag(flags, "ticker", `markets ${subcommand}`);
17383
+ switch (subcommand) {
17384
+ case "narrative":
17385
+ return client.markets.narrative(ticker);
17386
+ case "earnings": {
17387
+ const event = flags["event"];
17388
+ const fiscalYear = optionalBoundedIntegerFlag(
17389
+ flags,
17390
+ "fiscal-year",
17391
+ "markets earnings",
17392
+ 1900,
17393
+ 9999
17394
+ );
17395
+ const fiscalQuarter = flags["fiscal-quarter"]?.toUpperCase();
17396
+ const hasExplicitPeriod = fiscalYear !== void 0 || fiscalQuarter !== void 0;
17397
+ if (event !== void 0 && hasExplicitPeriod) {
17398
+ throw new CliUsageError(
17399
+ "--event cannot be combined with --fiscal-year or --fiscal-quarter for 'markets earnings'",
17400
+ "markets"
17401
+ );
17402
+ }
17403
+ if (fiscalYear === void 0 !== (fiscalQuarter === void 0)) {
17404
+ throw new CliUsageError(
17405
+ "--fiscal-year and --fiscal-quarter must be provided together for 'markets earnings'",
17406
+ "markets"
17407
+ );
17408
+ }
17409
+ if (event !== void 0 && event !== "latest-completed" && event !== "next-confirmed") {
17410
+ throw new CliUsageError(
17411
+ "--event must be 'latest-completed' or 'next-confirmed' for 'markets earnings'",
17412
+ "markets"
17413
+ );
17414
+ }
17415
+ if (fiscalQuarter !== void 0 && !["Q1", "Q2", "Q3", "Q4"].includes(fiscalQuarter)) {
17416
+ throw new CliUsageError(
17417
+ "--fiscal-quarter must be Q1, Q2, Q3, or Q4 for 'markets earnings'",
17418
+ "markets"
17419
+ );
17420
+ }
17421
+ if (fiscalYear !== void 0 && fiscalQuarter !== void 0) {
17422
+ return client.markets.earnings({
17423
+ ticker,
17424
+ fiscalYear,
17425
+ fiscalQuarter
17426
+ });
17427
+ }
17428
+ return client.markets.earnings({
17429
+ ticker,
17430
+ event
17431
+ });
17432
+ }
17433
+ default:
17434
+ throw new CliUsageError(
17435
+ `Unknown subcommand: markets ${subcommand}`,
17436
+ "markets"
17437
+ );
17438
+ }
17439
+ }
17013
17440
  case "trading": {
17014
17441
  if (!subcommand)
17015
17442
  throw new CliUsageError("Missing subcommand for trading", "trading");