@alva-ai/toolkit 0.22.0 → 0.23.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.
@@ -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
  }
@@ -1973,7 +2102,7 @@ declare const BOOLEAN_FLAGS: Set<string>;
1973
2102
  * Compares major.minor.patch as integers. Returns false on malformed input.
1974
2103
  */
1975
2104
  declare function isVersionOlderThan(a: string, b: string): boolean;
1976
- declare const HELP_TEXT = "Usage: alva <command> [options]\n\nCommands:\n configure Save API key and endpoint to a named profile\n whoami Verify credentials and show current identity\n user User profile operations (me)\n fs Filesystem operations (read, write, stat, readdir, mkdir, remove, rename, copy, symlink, readlink, chmod, grant, revoke)\n run Execute code in the Alva runtime\n deploy Cronjob management (create, list, get, update, delete, pause, resume, runs, run-logs)\n loop Self-scheduled in-channel goal loops (create)\n service-account Restricted run-as identities (create, list, delete, grant, revoke)\n release Feed and playbook releases (feed, playbook-draft, playbook)\n lint Design-system lint (playbook)\n automation Automation management (list, inspect, publish, update, stop, resume, delete)\n alert Alert management (list, follows, enable, disable, history, preferences, enable-session-completed, disable-session-completed)\n feed Legacy automation alias (list, stop, resume, delete, set-visibility)\n playbooks Playbook discovery (trending, get, list) and visibility\n functions Playbook UDF function management (register, list, delete, invoke, allowance)\n credits Credit wallet and self-scoped usage history (wallet, items)\n secrets Secret management (create, list, get, update, delete)\n sdk SDK documentation (doc, partitions, partition-summary)\n skillhub Playbook skills (list, tags, get, file)\n data-skills Data-skill documentation from the Arrays backend (list, summary, endpoint)\n comments Playbook comments (create, pin, unpin)\n notification-history Feed notification delivery history (list-feed)\n notification-preferences Notification preferences (list, enable-session-completed, disable-session-completed)\n feedback Submit user-confirmed Alva platform feedback (submit)\n subscriptions Playbook follows and feed alert subscriptions\n remix Save playbook remix lineage\n portfolio Connected-account portfolio (accounts, summary, activities)\n trading Trading operations (accounts, portfolio, orders, subscriptions, equity-history, risk-rules, subscribe, unsubscribe, execute, update-risk-rules)\n broker Agentic order execution \u2014 venue-native passthrough to trex (accounts, quote, order, balance, positions, ...; run 'alva broker describe')\n auth Authentication (login)\n screenshot Capture a web screenshot as PNG\n arrays Arrays backend operations (token ensure, token status)\n\nGlobal options:\n --api-key <key> API key (overrides env and config file)\n --base-url <url> API base URL (overrides env and config file)\n --profile <name> Named profile to use (default: \"default\")\n --arrays-endpoint <url> Arrays backend URL (or ARRAYS_ENDPOINT env; default: https://data-tools.prd.space.id)\n -v, --version Show CLI version\n --help Show help (use 'alva <command> --help' for command details)\n\nConfig resolution: --api-key flag > ALVA_API_KEY env > profile in ~/.config/alva/config.json\nProfile resolution: --profile flag > ALVA_PROFILE env > \"default\"\n\nQuick start:\n npm install -g @alva-ai/toolkit\n alva configure --api-key alva_your_key_here\n alva whoami";
2105
+ declare const HELP_TEXT = "Usage: alva <command> [options]\n\nCommands:\n configure Save API key and endpoint to a named profile\n whoami Verify credentials and show current identity\n user User profile operations (me)\n fs Filesystem operations (read, write, stat, readdir, mkdir, remove, rename, copy, symlink, readlink, chmod, grant, revoke)\n run Execute code in the Alva runtime\n deploy Cronjob management (create, list, get, update, delete, pause, resume, runs, run-logs)\n loop Self-scheduled in-channel goal loops (create)\n service-account Restricted run-as identities (create, list, delete, grant, revoke)\n release Feed and playbook releases (feed, playbook-draft, playbook)\n lint Design-system lint (playbook)\n automation Automation management (list, inspect, publish, update, stop, resume, delete)\n alert Alert management (list, follows, enable, disable, history, preferences, enable-session-completed, disable-session-completed)\n feed Legacy automation alias (list, stop, resume, delete, set-visibility)\n playbooks Playbook discovery (trending, get, list) and visibility\n functions Playbook UDF function management (register, list, delete, invoke, allowance)\n credits Credit wallet and self-scoped usage history (wallet, items)\n secrets Secret management (create, list, get, update, delete)\n sdk SDK documentation (doc, partitions, partition-summary)\n skillhub Playbook skills (list, tags, get, file)\n data-skills Data-skill documentation from the Arrays backend (list, summary, endpoint)\n comments Playbook comments (create, pin, unpin)\n notification-history Feed notification delivery history (list-feed)\n notification-preferences Notification preferences (list, enable-session-completed, disable-session-completed)\n feedback Submit user-confirmed Alva platform feedback (submit)\n subscriptions Playbook follows and feed alert subscriptions\n remix Save playbook remix lineage\n portfolio Connected-account portfolio (accounts, summary, activities)\n markets Company narrative and earnings context (narrative, earnings)\n trading Trading operations (accounts, portfolio, orders, subscriptions, equity-history, risk-rules, subscribe, unsubscribe, execute, update-risk-rules)\n broker Agentic order execution \u2014 venue-native passthrough to trex (accounts, quote, order, balance, positions, ...; run 'alva broker describe')\n auth Authentication (login)\n screenshot Capture a web screenshot as PNG\n arrays Arrays backend operations (token ensure, token status)\n\nGlobal options:\n --api-key <key> API key (overrides env and config file)\n --base-url <url> API base URL (overrides env and config file)\n --profile <name> Named profile to use (default: \"default\")\n --arrays-endpoint <url> Arrays backend URL (or ARRAYS_ENDPOINT env; default: https://data-tools.prd.space.id)\n -v, --version Show CLI version\n --help Show help (use 'alva <command> --help' for command details)\n\nConfig resolution: --api-key flag > ALVA_API_KEY env > profile in ~/.config/alva/config.json\nProfile resolution: --profile flag > ALVA_PROFILE env > \"default\"\n\nQuick start:\n npm install -g @alva-ai/toolkit\n alva configure --api-key alva_your_key_here\n alva whoami";
1977
2106
  declare const COMMAND_HELP: Record<string, string>;
1978
2107
  type AlvaCliRuntimeMode = 'nodejs' | 'jagent';
1979
2108
  interface DispatchLocalFiles {
package/dist/dispatch.js CHANGED
@@ -6364,6 +6364,10 @@ var COMMAND_DEFINITIONS = [
6364
6364
  command("portfolio activities", {
6365
6365
  values: ["account-id", "limit", "page-token"]
6366
6366
  }),
6367
+ command("markets narrative", { values: ["ticker"] }),
6368
+ command("markets earnings", {
6369
+ values: ["ticker", "event", "fiscal-year", "fiscal-quarter"]
6370
+ }),
6367
6371
  command("trading accounts"),
6368
6372
  command("trading portfolio", { values: ["account-id"] }),
6369
6373
  command("trading orders", {
@@ -10264,7 +10268,7 @@ ${formatReport(report, "human")}
10264
10268
  }
10265
10269
 
10266
10270
  // src/cli/dispatch.ts
10267
- var CLI_VERSION = true ? "0.22.0" : "dev";
10271
+ var CLI_VERSION = true ? "0.23.0-beta.0" : "dev";
10268
10272
  var DEFAULT_RUN_TIMEOUT_MS = 6e5;
10269
10273
  var RUN_TIMEOUT_ENV = "ALVA_RUN_TIMEOUT_MS";
10270
10274
  var GLOBAL_VALUE_FLAGS = Object.entries(GLOBAL_FLAG_DEFINITIONS).filter(([, kind]) => kind === "value").map(([name]) => `--${name}`);
@@ -10327,6 +10331,7 @@ Commands:
10327
10331
  subscriptions Playbook follows and feed alert subscriptions
10328
10332
  remix Save playbook remix lineage
10329
10333
  portfolio Connected-account portfolio (accounts, summary, activities)
10334
+ markets Company narrative and earnings context (narrative, earnings)
10330
10335
  trading Trading operations (accounts, portfolio, orders, subscriptions, equity-history, risk-rules, subscribe, unsubscribe, execute, update-risk-rules)
10331
10336
  broker Agentic order execution \u2014 venue-native passthrough to trex (accounts, quote, order, balance, positions, ...; run 'alva broker describe')
10332
10337
  auth Authentication (login)
@@ -11408,6 +11413,33 @@ Examples:
11408
11413
  alva portfolio accounts
11409
11414
  alva portfolio summary --account-id trex:123
11410
11415
  alva portfolio activities --account-id snaptrade:456 --limit 20`,
11416
+ markets: `Usage: alva markets <subcommand> [options]
11417
+
11418
+ Read the Markets backend's canonical company context. The Toolkit resolves
11419
+ earnings events through the backend period catalog; it does not construct ALFS
11420
+ owners, feed slugs, versions, or paths.
11421
+
11422
+ Subcommands:
11423
+ narrative Get the current narrative, history, and narrative change log
11424
+ earnings Get Pre, Release, Transcript, and Post for one fiscal event
11425
+
11426
+ Narrative flags:
11427
+ --ticker <symbol> Stock ticker (required)
11428
+
11429
+ Earnings flags:
11430
+ --ticker <symbol> Stock ticker (required)
11431
+ --event <selector> latest-completed (default) or next-confirmed
11432
+ --fiscal-year <year> Explicit fiscal year; requires --fiscal-quarter
11433
+ --fiscal-quarter <Q1..Q4> Explicit fiscal quarter; requires --fiscal-year
11434
+
11435
+ Do not combine --event with --fiscal-year/--fiscal-quarter. These commands read
11436
+ the current backend view; historical query-as-of gating is not supported yet.
11437
+
11438
+ Examples:
11439
+ alva markets narrative --ticker AAPL
11440
+ alva markets earnings --ticker AAPL
11441
+ alva markets earnings --ticker AAPL --event next-confirmed
11442
+ alva markets earnings --ticker AAPL --fiscal-year 2026 --fiscal-quarter Q3`,
11411
11443
  trading: `Usage: alva trading <subcommand> [options]
11412
11444
 
11413
11445
  Manage trading accounts, portfolios, orders, subscriptions, and risk rules.
@@ -13619,6 +13651,67 @@ async function dispatch(client, args, meta, deps) {
13619
13651
  );
13620
13652
  }
13621
13653
  }
13654
+ case "markets": {
13655
+ if (!subcommand)
13656
+ throw new CliUsageError("Missing subcommand for markets", "markets");
13657
+ const ticker = requireFlag(flags, "ticker", `markets ${subcommand}`);
13658
+ switch (subcommand) {
13659
+ case "narrative":
13660
+ return client.markets.narrative(ticker);
13661
+ case "earnings": {
13662
+ const event = flags["event"];
13663
+ const fiscalYear = optionalBoundedIntegerFlag(
13664
+ flags,
13665
+ "fiscal-year",
13666
+ "markets earnings",
13667
+ 1900,
13668
+ 9999
13669
+ );
13670
+ const fiscalQuarter = flags["fiscal-quarter"]?.toUpperCase();
13671
+ const hasExplicitPeriod = fiscalYear !== void 0 || fiscalQuarter !== void 0;
13672
+ if (event !== void 0 && hasExplicitPeriod) {
13673
+ throw new CliUsageError(
13674
+ "--event cannot be combined with --fiscal-year or --fiscal-quarter for 'markets earnings'",
13675
+ "markets"
13676
+ );
13677
+ }
13678
+ if (fiscalYear === void 0 !== (fiscalQuarter === void 0)) {
13679
+ throw new CliUsageError(
13680
+ "--fiscal-year and --fiscal-quarter must be provided together for 'markets earnings'",
13681
+ "markets"
13682
+ );
13683
+ }
13684
+ if (event !== void 0 && event !== "latest-completed" && event !== "next-confirmed") {
13685
+ throw new CliUsageError(
13686
+ "--event must be 'latest-completed' or 'next-confirmed' for 'markets earnings'",
13687
+ "markets"
13688
+ );
13689
+ }
13690
+ if (fiscalQuarter !== void 0 && !["Q1", "Q2", "Q3", "Q4"].includes(fiscalQuarter)) {
13691
+ throw new CliUsageError(
13692
+ "--fiscal-quarter must be Q1, Q2, Q3, or Q4 for 'markets earnings'",
13693
+ "markets"
13694
+ );
13695
+ }
13696
+ if (fiscalYear !== void 0 && fiscalQuarter !== void 0) {
13697
+ return client.markets.earnings({
13698
+ ticker,
13699
+ fiscalYear,
13700
+ fiscalQuarter
13701
+ });
13702
+ }
13703
+ return client.markets.earnings({
13704
+ ticker,
13705
+ event
13706
+ });
13707
+ }
13708
+ default:
13709
+ throw new CliUsageError(
13710
+ `Unknown subcommand: markets ${subcommand}`,
13711
+ "markets"
13712
+ );
13713
+ }
13714
+ }
13622
13715
  case "trading": {
13623
13716
  if (!subcommand)
13624
13717
  throw new CliUsageError("Missing subcommand for trading", "trading");