@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.
@@ -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" : "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)
@@ -10492,10 +10497,14 @@ Subcommand flags:
10492
10497
  revoke --path (required), --subject <s> (required), --permission <p> (required)
10493
10498
 
10494
10499
  Path conventions:
10495
- ~/... Home-relative path (expands to /alva/home/<username>/...)
10500
+ ~/... Home-relative filesystem location (for example, --path and --link-path)
10496
10501
  /alva/home/alice/... Absolute path (required for public/unauthenticated reads)
10497
10502
  Quote tilde paths to prevent shell expansion: --path "~/data" (not --path ~/data).
10498
10503
 
10504
+ Symlink targets:
10505
+ Symlink target paths are stored verbatim with POSIX semantics; they are not home-expanded.
10506
+ Use a path relative to the link's parent (for example, "real-file.txt") or a true /... absolute path.
10507
+
10499
10508
  Time series reads:
10500
10509
  Feed data directories are synth mounts. Their supported read suffixes are:
10501
10510
  @last/{n} Last N data points (chronological order)
@@ -10527,7 +10536,7 @@ Examples:
10527
10536
  alva fs chmod --path "~/script.js" --mode 755
10528
10537
  alva fs grant --path "~/feeds/btc-ema" --subject "special:user:*" --permission read
10529
10538
  alva fs revoke --path "~/feeds/btc-ema" --subject "special:user:*" --permission read
10530
- alva fs symlink --target-path "~/real-file.txt" --link-path "~/my-link.txt"
10539
+ alva fs symlink --target-path "real-file.txt" --link-path "~/my-link.txt"
10531
10540
  alva fs readlink --path "~/my-link.txt"`,
10532
10541
  run: `Usage: alva run [options]
10533
10542
 
@@ -11408,6 +11417,46 @@ Examples:
11408
11417
  alva portfolio accounts
11409
11418
  alva portfolio summary --account-id trex:123
11410
11419
  alva portfolio activities --account-id snaptrade:456 --limit 20`,
11420
+ markets: `Usage: alva markets <subcommand> [options]
11421
+
11422
+ Read the Markets backend's canonical company context. The Toolkit resolves
11423
+ earnings events through the backend period catalog; it does not construct ALFS
11424
+ owners, feed slugs, versions, or paths.
11425
+
11426
+ Subcommands:
11427
+ narrative Get the current narrative, history, and narrative change log
11428
+ earnings Get Pre, Release, Transcript, and Post for one fiscal event
11429
+
11430
+ Narrative flags:
11431
+ --ticker <symbol> Stock ticker (required)
11432
+
11433
+ Earnings flags:
11434
+ --ticker <symbol> Stock ticker (required)
11435
+ --event <selector> latest-completed (default) or next-confirmed
11436
+ --fiscal-year <year> Explicit fiscal year; requires --fiscal-quarter
11437
+ --fiscal-quarter <Q1..Q4> Explicit fiscal quarter; requires --fiscal-year
11438
+
11439
+ Do not combine --event with --fiscal-year/--fiscal-quarter. These commands read
11440
+ the current backend view; historical query-as-of gating is not supported yet.
11441
+
11442
+ Output semantics:
11443
+ Narrative is dated Alva analysis. Use current for present-tense company
11444
+ context and history only to explain changes; use separate sources for live
11445
+ prices and official facts.
11446
+
11447
+ Earnings covers one fiscal event. Pre is the dated expectation baseline;
11448
+ Release identifies the official source for reported facts; Transcript holds
11449
+ management statements; Post is Alva's dated interpretation.
11450
+
11451
+ Each Earnings stage has its own status. A missing or unavailable stage does
11452
+ not invalidate valid stages, and an unavailable requested event is never
11453
+ replaced with a different quarter.
11454
+
11455
+ Examples:
11456
+ alva markets narrative --ticker AAPL
11457
+ alva markets earnings --ticker AAPL
11458
+ alva markets earnings --ticker AAPL --event next-confirmed
11459
+ alva markets earnings --ticker AAPL --fiscal-year 2026 --fiscal-quarter Q3`,
11411
11460
  trading: `Usage: alva trading <subcommand> [options]
11412
11461
 
11413
11462
  Manage trading accounts, portfolios, orders, subscriptions, and risk rules.
@@ -13619,6 +13668,67 @@ async function dispatch(client, args, meta, deps) {
13619
13668
  );
13620
13669
  }
13621
13670
  }
13671
+ case "markets": {
13672
+ if (!subcommand)
13673
+ throw new CliUsageError("Missing subcommand for markets", "markets");
13674
+ const ticker = requireFlag(flags, "ticker", `markets ${subcommand}`);
13675
+ switch (subcommand) {
13676
+ case "narrative":
13677
+ return client.markets.narrative(ticker);
13678
+ case "earnings": {
13679
+ const event = flags["event"];
13680
+ const fiscalYear = optionalBoundedIntegerFlag(
13681
+ flags,
13682
+ "fiscal-year",
13683
+ "markets earnings",
13684
+ 1900,
13685
+ 9999
13686
+ );
13687
+ const fiscalQuarter = flags["fiscal-quarter"]?.toUpperCase();
13688
+ const hasExplicitPeriod = fiscalYear !== void 0 || fiscalQuarter !== void 0;
13689
+ if (event !== void 0 && hasExplicitPeriod) {
13690
+ throw new CliUsageError(
13691
+ "--event cannot be combined with --fiscal-year or --fiscal-quarter for 'markets earnings'",
13692
+ "markets"
13693
+ );
13694
+ }
13695
+ if (fiscalYear === void 0 !== (fiscalQuarter === void 0)) {
13696
+ throw new CliUsageError(
13697
+ "--fiscal-year and --fiscal-quarter must be provided together for 'markets earnings'",
13698
+ "markets"
13699
+ );
13700
+ }
13701
+ if (event !== void 0 && event !== "latest-completed" && event !== "next-confirmed") {
13702
+ throw new CliUsageError(
13703
+ "--event must be 'latest-completed' or 'next-confirmed' for 'markets earnings'",
13704
+ "markets"
13705
+ );
13706
+ }
13707
+ if (fiscalQuarter !== void 0 && !["Q1", "Q2", "Q3", "Q4"].includes(fiscalQuarter)) {
13708
+ throw new CliUsageError(
13709
+ "--fiscal-quarter must be Q1, Q2, Q3, or Q4 for 'markets earnings'",
13710
+ "markets"
13711
+ );
13712
+ }
13713
+ if (fiscalYear !== void 0 && fiscalQuarter !== void 0) {
13714
+ return client.markets.earnings({
13715
+ ticker,
13716
+ fiscalYear,
13717
+ fiscalQuarter
13718
+ });
13719
+ }
13720
+ return client.markets.earnings({
13721
+ ticker,
13722
+ event
13723
+ });
13724
+ }
13725
+ default:
13726
+ throw new CliUsageError(
13727
+ `Unknown subcommand: markets ${subcommand}`,
13728
+ "markets"
13729
+ );
13730
+ }
13731
+ }
13622
13732
  case "trading": {
13623
13733
  if (!subcommand)
13624
13734
  throw new CliUsageError("Missing subcommand for trading", "trading");