@alva-ai/toolkit 0.31.0 → 0.32.0-beta.1

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/dispatch.js CHANGED
@@ -6051,6 +6051,9 @@ var EMBEDDED_COMMAND_DEFINITIONS = [
6051
6051
  { values: ["delivery-ids", "digest-run-id"] },
6052
6052
  "steward-self"
6053
6053
  ),
6054
+ route("company-news create", "company-news create", {
6055
+ values: ["name", "tickers", "initial-lookback-hours", "page-size"]
6056
+ }),
6054
6057
  route("thesis create", "thesis create", {
6055
6058
  values: [
6056
6059
  "request-id",
@@ -6065,6 +6068,21 @@ var EMBEDDED_COMMAND_DEFINITIONS = [
6065
6068
  route("thesis asset-candidates", "thesis asset-candidates", {
6066
6069
  values: ["text"]
6067
6070
  }),
6071
+ route("thesis list", "thesis list", {
6072
+ values: [
6073
+ "person",
6074
+ "person-name",
6075
+ "user",
6076
+ "ticker",
6077
+ "entity-id",
6078
+ "status",
6079
+ "first",
6080
+ "cursor"
6081
+ ]
6082
+ }),
6083
+ route("thesis related", "thesis related", {
6084
+ values: ["id", "first", "cursor"]
6085
+ }),
6068
6086
  route("thesis get", "thesis get", { values: ["id"] }),
6069
6087
  route("thesis version get", "thesis version get", {
6070
6088
  values: ["id", "author-version-id"]
@@ -6495,7 +6513,8 @@ Commands:
6495
6513
  automation Create and operate scheduled automations
6496
6514
  schedule Manage future messages for this Session Inbox
6497
6515
  steward Push steward reports for this Session Inbox (decide, forward, send, pending, briefed)
6498
- thesis Create and manage authored theses
6516
+ thesis Read published viewpoints and manage authored theses
6517
+ company-news Create backend-managed multi-ticker News Feeds
6499
6518
  playbooks Discover, build, release, and manage Playbooks
6500
6519
  alert Manage personal automation alert bindings
6501
6520
  for-you Read your For You publications (list, theses)
@@ -6504,6 +6523,16 @@ Commands:
6504
6523
 
6505
6524
  Run 'alva <command> --help' for a command tree.`;
6506
6525
  var AGENT_COMMAND_HELP = {
6526
+ "company-news": `Usage: alva company-news create --name <name> --tickers <NVDA,AMD> [options]
6527
+
6528
+ Create one backend-managed News Feed for 1-1000 unique uppercase tickers.
6529
+ Optional: --initial-lookback-hours <0-168> (default 24), --page-size <0-100>
6530
+ (default 20). Zero selects the backend default. No script upload or path.
6531
+ Returns decimal-string feed_id and cronjob_id. New feeds are paused; creation
6532
+ does not start model work. Once resumed, the creator pays model credits.
6533
+ Pull-only: no push delivery is enabled. Repeating the same name/configuration
6534
+ returns the existing resource without changing its activation state.
6535
+ Authentication and endpoints belong to the host; no identity overrides.`,
6507
6536
  steward: `Usage: alva steward <subcommand> [options]
6508
6537
 
6509
6538
  Report this push steward's decisions for Feed alerts routed to its Inbox and
@@ -6582,7 +6611,21 @@ Examples:
6582
6611
  alva for-you theses --cursor '<nextCursor>'`,
6583
6612
  thesis: `Usage: alva thesis <subcommand> [options]
6584
6613
 
6585
- Subcommands: asset-candidates, create, get, version get, signals, set-visibility, update, close, delete, rewrite.
6614
+ Subcommands: list, related, asset-candidates, create, get, version get, signals, set-visibility, update, close, delete, rewrite.
6615
+
6616
+ list --person <slug> | --person-name <name> | --user <username>
6617
+ | --ticker <ticker> | --entity-id <id>
6618
+ [--status ACTIVE|ARCHIVED] [--first 10] [--cursor <nextCursor>]
6619
+ Choose one selector; --status is for author lists only (default ACTIVE).
6620
+ related --id <playbook-id> [--first 10] [--cursor <nextCursor>]
6621
+ Both read one page (default 10, maximum 50) with full bodies. Pass nextCursor
6622
+ to --cursor while it is non-null, even after an empty page. Name/ticker
6623
+ ambiguity returns candidates; retry with an exact slug or entity ID. A
6624
+ publisher's __typename picks its selector: Person --person <slug>, PublicUser
6625
+ --user <username>. publication.playbookId is the ID for get/version/signals/
6626
+ related; null publication means no readable snapshot. Author lists include the
6627
+ signed-in owner's private Theses. Related uses the source's current version
6628
+ (GENERATING, READY or FAILED), never a quoted historical version.
6586
6629
 
6587
6630
  asset-candidates --text <unsaved thesis text> reads catalog IDs and suggested
6588
6631
  directions without publishing. Use resolved entity IDs with create --entity-ids
@@ -6624,7 +6667,8 @@ Subcommands:
6624
6667
  run: `Usage: alva run (--code <js> | --entry-path <alfs-path>) [options]
6625
6668
 
6626
6669
  Execute JavaScript in the Jagent runtime. Local-file flags are unavailable in
6627
- the embedded Agent; use ALFS paths or inline code.`,
6670
+ the embedded Agent; use ALFS paths or inline code. Return values directly, not
6671
+ JSON.stringify(...).`,
6628
6672
  "data-skills": `Usage: alva data-skills <subcommand>
6629
6673
 
6630
6674
  Subcommands:
@@ -6788,10 +6832,10 @@ ${options.join("\n")}`;
6788
6832
  }
6789
6833
  function agentHelpFor(args) {
6790
6834
  const helpIndex = args.findIndex(
6791
- (argument) => argument === "--help" || argument === "-h"
6835
+ (argument2) => argument2 === "--help" || argument2 === "-h"
6792
6836
  );
6793
6837
  const path = (helpIndex === -1 ? args : args.slice(0, helpIndex)).filter(
6794
- (argument) => !argument.startsWith("-")
6838
+ (argument2) => !argument2.startsWith("-")
6795
6839
  );
6796
6840
  for (let length = path.length; length > 0; length--) {
6797
6841
  const command2 = path.slice(0, length).join(" ");
@@ -7032,6 +7076,116 @@ var parseEmbeddedCommand = createCommandParser(
7032
7076
  EMBEDDED_GLOBAL_FLAG_DEFINITIONS
7033
7077
  );
7034
7078
 
7079
+ // src/resources/thesisPublication.ts
7080
+ function record(value) {
7081
+ return typeof value === "object" && value !== null && !Array.isArray(value);
7082
+ }
7083
+ function isPositiveInt64(value) {
7084
+ return typeof value === "string" && /^[1-9]\d{0,18}$/.test(value) && BigInt(value) <= 9223372036854775807n;
7085
+ }
7086
+ var THESIS_PUBLICATION_FIELDS = `
7087
+ thesisId playbookId authorVersionId materialVersionId itemKey
7088
+ title body publishedAtMs changeKind visibility
7089
+ closed archived note closingNote researchPaused
7090
+ entityIds categoryIds
7091
+ entityStances { entityId stance }
7092
+ entities { id ticker name }
7093
+ publisher {
7094
+ __typename id displayName avatarUrl bio followersCount
7095
+ viewerState { following }
7096
+ ... on Person { slug }
7097
+ ... on PublicUser { username }
7098
+ }
7099
+ medias { type coverUrl url }
7100
+ signalFeed { id }
7101
+ snapshotRelease {
7102
+ versionId materialVersionId publishedAtMs changeKind
7103
+ sourceRefs {
7104
+ title sourceKind sourceContentId publicUrl sourceTimeMs locator
7105
+ }
7106
+ }
7107
+ `;
7108
+
7109
+ // src/resources/thesisReads.ts
7110
+ var PAGE = "pageInfo { endCursor hasNextPage }";
7111
+ var PERSON = "__typename id slug displayName bio";
7112
+ var USER = "__typename id username displayName bio";
7113
+ var ENTITY = "__typename id ticker name kind assetClass venue { id name }";
7114
+ var AUTHOR_THESES = `theses(input: $input) {
7115
+ edges { cursor node { id latestRelease { thesisPublication { ${THESIS_PUBLICATION_FIELDS} } } } }
7116
+ ${PAGE}
7117
+ }`;
7118
+ var PERSON_QUERY = `query ToolkitPersonTheses($slug: String!, $input: ProfileThesisConnectionInput) {
7119
+ scope: person(slug: $slug) { ${PERSON} ${AUTHOR_THESES} }
7120
+ }`;
7121
+ var USER_QUERY = `query ToolkitUserTheses($username: String!, $input: ProfileThesisConnectionInput) {
7122
+ scope: publicUser(username: $username) { ${USER} ${AUTHOR_THESES} }
7123
+ }`;
7124
+ var ENTITY_QUERY = `query ToolkitEntityTheses($id: ID!, $input: EntityThesisConnectionInput) {
7125
+ market { scope: entity(input: { id: $id }) { ${ENTITY}
7126
+ theses(input: $input) { edges { cursor node { ${THESIS_PUBLICATION_FIELDS} } } ${PAGE} }
7127
+ } }
7128
+ }`;
7129
+ var PEOPLE_QUERY = `query ToolkitThesisPeople($query: String!) {
7130
+ search: people(input: { query: $query, first: 50 }) {
7131
+ edges { node { ${PERSON} } } pageInfo { hasNextPage }
7132
+ }
7133
+ }`;
7134
+ var ENTITIES_QUERY = `query ToolkitThesisEntities($query: String!) {
7135
+ market { search: entities(input: { query: $query, first: 50, byPrefix: false }) {
7136
+ edges { node { ${ENTITY} } } pageInfo { hasNextPage }
7137
+ } }
7138
+ }`;
7139
+ var RELATED_QUERY = `query ToolkitRelatedTheses($id: ID!, $input: RelatedThesisInput) {
7140
+ node(id: $id) { ... on Playbook { relatedTheses(input: $input) {
7141
+ state nextCursor
7142
+ edges { cursor node { itemKey score publication { ${THESIS_PUBLICATION_FIELDS} } } }
7143
+ } } }
7144
+ }`;
7145
+ var SELECTORS = [
7146
+ "person",
7147
+ "personName",
7148
+ "user",
7149
+ "ticker",
7150
+ "entityId"
7151
+ ];
7152
+ function validateThesisPageParams(params) {
7153
+ if (!record(params)) throw argument("Thesis parameters must be an object");
7154
+ const first = params.first === void 0 ? 10 : params.first;
7155
+ if (typeof first !== "number" || !Number.isInteger(first) || first < 1 || first > 50) {
7156
+ throw argument("first must be an integer between 1 and 50");
7157
+ }
7158
+ if (params.cursor !== void 0 && !nonempty(params.cursor)) {
7159
+ throw argument("cursor must be non-empty");
7160
+ }
7161
+ }
7162
+ function validateListThesesParams(params) {
7163
+ validateThesisPageParams(params);
7164
+ const chosen = SELECTORS.filter((key) => params[key] !== void 0);
7165
+ if (chosen.length !== 1) {
7166
+ throw argument(
7167
+ "Choose exactly one of person, personName, user, ticker or entityId"
7168
+ );
7169
+ }
7170
+ if (!nonempty(params[chosen[0]]))
7171
+ throw argument(`${chosen[0]} must be non-empty`);
7172
+ if (params.entityId !== void 0 && !isPositiveInt64(params.entityId)) {
7173
+ throw argument("entityId must be a positive int64 string");
7174
+ }
7175
+ if (params.status !== void 0 && params.status !== "ACTIVE" && params.status !== "ARCHIVED") {
7176
+ throw argument("status must be ACTIVE or ARCHIVED");
7177
+ }
7178
+ if (params.status !== void 0 && (params.ticker !== void 0 || params.entityId !== void 0)) {
7179
+ throw argument("status applies only to author lists");
7180
+ }
7181
+ }
7182
+ function nonempty(value) {
7183
+ return typeof value === "string" && value.trim().length > 0;
7184
+ }
7185
+ function argument(message) {
7186
+ return new AlvaError("INVALID_ARGUMENT", message, 400);
7187
+ }
7188
+
7035
7189
  // src/resources/forYou.ts
7036
7190
  var FOR_YOU_QUERY = `
7037
7191
  query ToolkitForYou($input: FeedEntryConnectionInput) {
@@ -7061,9 +7215,6 @@ query ToolkitForYou($input: FeedEntryConnectionInput) {
7061
7215
  }
7062
7216
  }
7063
7217
  `.trim();
7064
- function record(value) {
7065
- return typeof value === "object" && value !== null && !Array.isArray(value);
7066
- }
7067
7218
  function validateForYouListParams(params) {
7068
7219
  if (!record(params)) throw new Error("For You parameters must be an object");
7069
7220
  const first = params.first === void 0 ? 20 : params.first;
@@ -7080,9 +7231,6 @@ function validateForYouListParams(params) {
7080
7231
  throw new Error("feedId must be a positive decimal int64 string");
7081
7232
  }
7082
7233
  }
7083
- function isPositiveInt64(value) {
7084
- return typeof value === "string" && /^[1-9]\d{0,18}$/.test(value) && BigInt(value) <= 9223372036854775807n;
7085
- }
7086
7234
  var THESIS_RECOMMENDATION_QUERY = `
7087
7235
  query ToolkitForYouTheses($input: ThesisRecommendationInput) {
7088
7236
  viewer {
@@ -7094,24 +7242,7 @@ query ToolkitForYouTheses($input: ThesisRecommendationInput) {
7094
7242
  node {
7095
7243
  itemKey
7096
7244
  publication {
7097
- thesisId playbookId authorVersionId materialVersionId itemKey
7098
- title body publishedAtMs changeKind visibility
7099
- closed archived note closingNote researchPaused
7100
- entityIds categoryIds
7101
- entityStances { entityId stance }
7102
- entities { id ticker name }
7103
- publisher {
7104
- id displayName avatarUrl bio followersCount
7105
- viewerState { following }
7106
- }
7107
- medias { type coverUrl url }
7108
- signalFeed { id }
7109
- snapshotRelease {
7110
- versionId materialVersionId publishedAtMs changeKind
7111
- sourceRefs {
7112
- title sourceKind sourceContentId publicUrl sourceTimeMs locator
7113
- }
7114
- }
7245
+ ${THESIS_PUBLICATION_FIELDS}
7115
7246
  }
7116
7247
  }
7117
7248
  }
@@ -7175,6 +7306,39 @@ function requireDecision(value) {
7175
7306
  return value;
7176
7307
  }
7177
7308
 
7309
+ // src/resources/companyNews.ts
7310
+ function validateCompanyNewsCreateParams(params) {
7311
+ if (typeof params?.name !== "string" || params.name.trim() !== params.name || !/^[a-zA-Z0-9][a-zA-Z0-9-]{0,63}$/.test(params.name) || params.name === "news-lane") {
7312
+ throw new AlvaError(
7313
+ "INVALID_ARGUMENT",
7314
+ "name must be 1-64 alphanumeric/hyphen characters and distinct from news-lane",
7315
+ 400
7316
+ );
7317
+ }
7318
+ if (!Array.isArray(params.tickers) || params.tickers.length < 1 || params.tickers.length > 1e3 || params.tickers.some(
7319
+ (ticker) => typeof ticker !== "string" || ticker.trim() !== ticker || !/^[A-Z0-9][A-Z0-9.-]{0,19}$/.test(ticker)
7320
+ ) || new Set(params.tickers).size !== params.tickers.length) {
7321
+ throw new AlvaError(
7322
+ "INVALID_ARGUMENT",
7323
+ "tickers must contain 1-1000 unique uppercase symbols",
7324
+ 400
7325
+ );
7326
+ }
7327
+ for (const [name, maximum] of [
7328
+ ["initial_lookback_hours", 168],
7329
+ ["page_size", 100]
7330
+ ]) {
7331
+ const value = params[name];
7332
+ if (value !== void 0 && (!Number.isInteger(value) || value < 0 || value > maximum)) {
7333
+ throw new AlvaError(
7334
+ "INVALID_ARGUMENT",
7335
+ `${name} must be an integer from 0 to ${maximum} (0 selects the default)`,
7336
+ 400
7337
+ );
7338
+ }
7339
+ }
7340
+ }
7341
+
7178
7342
  // src/resources/schedules.ts
7179
7343
  var SCHEDULE_FIELDS = `
7180
7344
  id
@@ -7400,6 +7564,9 @@ var COMMAND_DEFINITIONS = [
7400
7564
  command("steward briefed", {
7401
7565
  values: ["inbox-path", "delivery-ids", "digest-run-id"]
7402
7566
  }),
7567
+ command("company-news create", {
7568
+ values: ["name", "tickers", "initial-lookback-hours", "page-size"]
7569
+ }),
7403
7570
  command("thesis create", {
7404
7571
  values: [
7405
7572
  "request-id",
@@ -7414,6 +7581,19 @@ var COMMAND_DEFINITIONS = [
7414
7581
  booleans: ["body-stdin"]
7415
7582
  }),
7416
7583
  command("thesis asset-candidates", { values: ["text"] }),
7584
+ command("thesis list", {
7585
+ values: [
7586
+ "person",
7587
+ "person-name",
7588
+ "user",
7589
+ "ticker",
7590
+ "entity-id",
7591
+ "status",
7592
+ "first",
7593
+ "cursor"
7594
+ ]
7595
+ }),
7596
+ command("thesis related", { values: ["id", "first", "cursor"] }),
7417
7597
  command("thesis get", { values: ["id"] }),
7418
7598
  command("thesis version get", {
7419
7599
  values: ["id", "author-version-id"]
@@ -11565,7 +11745,7 @@ function formatTradingPairResolved(result) {
11565
11745
  }
11566
11746
 
11567
11747
  // src/cli/dispatch.ts
11568
- var CLI_VERSION = true ? "0.31.0" : "dev";
11748
+ var CLI_VERSION = true ? "0.32.0-beta.1" : "dev";
11569
11749
  var DEFAULT_RUN_TIMEOUT_MS = 6e5;
11570
11750
  var RUN_TIMEOUT_ENV = "ALVA_RUN_TIMEOUT_MS";
11571
11751
  var GLOBAL_VALUE_FLAGS = Object.entries(GLOBAL_FLAG_DEFINITIONS).filter(([, kind]) => kind === "value").map(([name]) => `--${name}`);
@@ -11599,6 +11779,27 @@ function isVersionOlderThan(a, b) {
11599
11779
  return false;
11600
11780
  }
11601
11781
  var COMMAND_HELP = {
11782
+ "company-news": `Usage: alva company-news create --name <name> --tickers <NVDA,AMD> [options]
11783
+
11784
+ Create one private, backend-managed Feed covering all supplied tickers.
11785
+ No script upload, entry path or cron deployment is required.
11786
+
11787
+ Options:
11788
+ --name <name> Owner-local name (1-64 alphanumeric/hyphen characters; not news-lane)
11789
+ --tickers <A,B,C> 1-1000 unique uppercase symbols
11790
+ --initial-lookback-hours <0-168> Initial history window (default: 24; 0 selects default)
11791
+ --page-size <0-100> Editorial batch size (default: 20; 0 selects default)
11792
+
11793
+ New feeds are paused. Returns decimal-string feed_id and cronjob_id.
11794
+ Creation does not run the model or resume the producer. After reviewing the
11795
+ configuration, use 'alva feed resume --id <feed_id>' to start paid execution.
11796
+ Model credits are charged to the authenticated creator, not the platform.
11797
+ This is pull-only: starting the producer does not enable push notifications.
11798
+ Retry an unclear result with the same name and configuration; an existing
11799
+ feed's current activation state is preserved. Different configuration conflicts.
11800
+ The backend and database migration must be deployed; no script fallback is used.
11801
+
11802
+ Example: alva company-news create --name my-company-news --tickers NVDA,AMD`,
11602
11803
  steward: `Usage: alva steward <subcommand> [options]
11603
11804
 
11604
11805
  Report a push steward's decisions for Feed alerts routed to its Session Inbox,
@@ -11875,7 +12076,8 @@ At least one of --code, --local-file, or --entry-path is required.
11875
12076
  These three options are mutually exclusive.
11876
12077
 
11877
12078
  Response fields:
11878
- result JSON-encoded return value of the script
12079
+ result The script's return value. Return objects directly; a script
12080
+ returning JSON.stringify(x) is shown as x.
11879
12081
  logs Captured stderr output
11880
12082
  status "completed" or "failed"
11881
12083
  error Error message (when status is "failed")
@@ -11897,13 +12099,14 @@ Constraints:
11897
12099
 
11898
12100
  Examples:
11899
12101
  alva run --code "1 + 2 + 3;"
11900
- alva run --code "JSON.stringify(require('env').args);" --args '{"symbol":"BTC"}'
12102
+ alva run --code "require('env').args;" --args '{"symbol":"BTC"}'
11901
12103
  alva run --entry-path "~/feeds/my-feed/v1/src/index.js"
11902
12104
  alva run --entry-path "~/tasks/analyze/src/index.js" --args '{"symbol":"NVDA","limit":50}'
11903
12105
  alva run --local-file ./my-script.js --args '{"symbol":"BTC"}'
11904
12106
  printf '%s' '{"symbol":"BTC"}' | alva run --local-file ./my-script.js --args-stdin
11905
12107
  alva run --entry-path "~/tasks/heavy/src/index.js" --max-heap-size-mb 1024
11906
- alva run --entry-path "~/feeds/slow/v1/src/index.js" --timeout-ms 900000`,
12108
+ alva run --entry-path "~/feeds/slow/v1/src/index.js" --timeout-ms 900000
12109
+ alva run --local-file ./research.js > research.json && jq -c '.result.income[:4]' research.json`,
11907
12110
  deploy: `Usage: alva deploy <subcommand> [options]
11908
12111
 
11909
12112
  Manage scheduled cronjobs that run your scripts on a cron schedule.
@@ -12910,6 +13113,8 @@ Create and update never rewrite text automatically.
12910
13113
 
12911
13114
  Subcommands:
12912
13115
  create Create a thesis
13116
+ list Read theses by author or market entity
13117
+ related Read related current publications
12913
13118
  get Get one thesis
12914
13119
  version get Get one exact author version
12915
13120
  signals Read published Signal history
@@ -12932,6 +13137,20 @@ Update requires --visibility explicitly so it cannot inadvertently publish.
12932
13137
 
12933
13138
  Other flags:
12934
13139
  create --request-id <uuid> --body ... [--title <text>] [--tickers <ticker,ticker>] [--entity-ids <id,id>] [--entity-stances <json>] [--visibility <value>]
13140
+ list --person <slug> | --person-name <name> | --user <username>
13141
+ | --ticker <ticker> | --entity-id <id>
13142
+ [--status ACTIVE|ARCHIVED] [--first 10] [--cursor <nextCursor>]
13143
+ Choose one selector; --status is for author lists only (default ACTIVE).
13144
+ Name/ticker ambiguity returns candidates; retry with an exact slug or entity ID.
13145
+ A publisher's __typename picks its selector: Person --person <slug>,
13146
+ PublicUser --user <username>.
13147
+ related --id <playbook-id> [--first 10] [--cursor <nextCursor>]
13148
+ Uses the source's current version; state is GENERATING, READY or FAILED.
13149
+ list/related read one page (default 10, maximum 50) with full bodies. Pass
13150
+ nextCursor to --cursor while it is non-null, even after an empty page.
13151
+ publication.playbookId is the ID for get/version/signals/related;
13152
+ publication=null means no readable snapshot. Author lists include the
13153
+ signed-in owner's private Theses (visibility private).
12935
13154
  asset-candidates --text <unsaved thesis text>
12936
13155
  get --id <signed-int64-decimal>
12937
13156
  version get --id <signed-int64-decimal> --author-version-id <signed-int64-decimal>
@@ -13019,6 +13238,16 @@ function requirePositiveIntegerStringFlag(flags, name, command2) {
13019
13238
  }
13020
13239
  return val;
13021
13240
  }
13241
+ function requireFeedIDFlag(flags, command2) {
13242
+ const value = requirePositiveIntegerStringFlag(flags, "id", command2);
13243
+ if (value.length > 19 || value.trim() !== value || BigInt(value) > 9223372036854775807n) {
13244
+ throw new CliUsageError(
13245
+ `--id must be a positive decimal int64 for '${command2}'`,
13246
+ "feed"
13247
+ );
13248
+ }
13249
+ return value;
13250
+ }
13022
13251
  function optionalBoundedIntegerFlag(flags, name, command2, min, max) {
13023
13252
  const val = flags[name];
13024
13253
  if (val === void 0) return void 0;
@@ -13560,6 +13789,24 @@ function assertLocalFileAvailable(command2, flag, deps) {
13560
13789
  throw localFileUnsupported(command2, flag);
13561
13790
  }
13562
13791
  }
13792
+ function decodeRunResult(result) {
13793
+ let value;
13794
+ try {
13795
+ value = JSON.parse(result);
13796
+ } catch {
13797
+ return result;
13798
+ }
13799
+ let inner = value;
13800
+ while (typeof inner === "string") {
13801
+ try {
13802
+ inner = JSON.parse(inner);
13803
+ } catch {
13804
+ break;
13805
+ }
13806
+ if (inner !== null && typeof inner === "object") return inner;
13807
+ }
13808
+ return value;
13809
+ }
13563
13810
  function readLocalTextFile(path, command2, flag, deps) {
13564
13811
  assertLocalFileAvailable(command2, flag, deps);
13565
13812
  if (!deps?.localFiles) {
@@ -13957,7 +14204,8 @@ async function executeParsedCommand(client, parsedCommand, meta, deps) {
13957
14204
  );
13958
14205
  }
13959
14206
  }
13960
- return serializedArgs === void 0 ? client.run.execute(params) : client.run._executeSerializedArgs(params, serializedArgs);
14207
+ const response = serializedArgs === void 0 ? await client.run.execute(params) : await client.run._executeSerializedArgs(params, serializedArgs);
14208
+ return { ...response, result: decodeRunResult(response.result) };
13961
14209
  }
13962
14210
  case "deploy": {
13963
14211
  if (!subcommand)
@@ -14207,6 +14455,38 @@ async function executeParsedCommand(client, parsedCommand, meta, deps) {
14207
14455
  );
14208
14456
  }
14209
14457
  }
14458
+ case "company-news": {
14459
+ if (subcommand !== "create") {
14460
+ throw new CliUsageError("Expected company-news create", "company-news");
14461
+ }
14462
+ const params = {
14463
+ name: requireFlag(flags, "name", "company-news create"),
14464
+ tickers: requireFlag(flags, "tickers", "company-news create").split(",").map((ticker) => ticker.trim())
14465
+ };
14466
+ for (const [flag, field] of [
14467
+ ["initial-lookback-hours", "initial_lookback_hours"],
14468
+ ["page-size", "page_size"]
14469
+ ]) {
14470
+ const value = flags[flag];
14471
+ if (value === void 0) continue;
14472
+ if (!/^\d+$/.test(value)) {
14473
+ throw new CliUsageError(
14474
+ `--${flag} must be a nonnegative integer`,
14475
+ "company-news"
14476
+ );
14477
+ }
14478
+ params[field] = Number(value);
14479
+ }
14480
+ try {
14481
+ validateCompanyNewsCreateParams(params);
14482
+ } catch (error) {
14483
+ throw new CliUsageError(
14484
+ error instanceof Error ? error.message : "Invalid company news configuration",
14485
+ "company-news"
14486
+ );
14487
+ }
14488
+ return client.companyNews.create(params);
14489
+ }
14210
14490
  case "thesis": {
14211
14491
  if (!subcommand) {
14212
14492
  throw new CliUsageError("Missing subcommand for thesis", "thesis");
@@ -14226,6 +14506,39 @@ async function executeParsedCommand(client, parsedCommand, meta, deps) {
14226
14506
  return client.theses.assetCandidates(
14227
14507
  requireFlag(flags, "text", "thesis asset-candidates")
14228
14508
  );
14509
+ case "list": {
14510
+ const params = {
14511
+ person: flags.person,
14512
+ personName: flags["person-name"],
14513
+ user: flags.user,
14514
+ ticker: flags.ticker,
14515
+ entityId: flags["entity-id"],
14516
+ status: flags.status,
14517
+ first: flags.first === void 0 ? void 0 : Number(flags.first),
14518
+ cursor: flags.cursor
14519
+ };
14520
+ try {
14521
+ validateListThesesParams(params);
14522
+ } catch (error) {
14523
+ throw new CliUsageError(error.message, "thesis");
14524
+ }
14525
+ return client.theses.list(params);
14526
+ }
14527
+ case "related": {
14528
+ const params = {
14529
+ first: flags.first === void 0 ? void 0 : Number(flags.first),
14530
+ cursor: flags.cursor
14531
+ };
14532
+ try {
14533
+ validateThesisPageParams(params);
14534
+ } catch (error) {
14535
+ throw new CliUsageError(error.message, "thesis");
14536
+ }
14537
+ return client.theses.related(
14538
+ requireFlag(flags, "id", "thesis related"),
14539
+ params
14540
+ );
14541
+ }
14229
14542
  case "get":
14230
14543
  return client.theses.get(requireFlag(flags, "id", "thesis get"));
14231
14544
  case "version":
@@ -14350,19 +14663,19 @@ async function executeParsedCommand(client, parsedCommand, meta, deps) {
14350
14663
  });
14351
14664
  case "stop":
14352
14665
  return client.feed.stop({
14353
- id: requireNumericFlag(flags, "id", "feed stop")
14666
+ id: requireFeedIDFlag(flags, "feed stop")
14354
14667
  });
14355
14668
  case "resume":
14356
14669
  return client.feed.resume({
14357
- id: requireNumericFlag(flags, "id", "feed resume")
14670
+ id: requireFeedIDFlag(flags, "feed resume")
14358
14671
  });
14359
14672
  case "delete":
14360
14673
  return client.feed.delete({
14361
- id: requireNumericFlag(flags, "id", "feed delete")
14674
+ id: requireFeedIDFlag(flags, "feed delete")
14362
14675
  });
14363
14676
  case "set-visibility":
14364
14677
  return client.feed.setVisibility({
14365
- id: requireNumericFlag(flags, "id", "feed set-visibility"),
14678
+ id: requireFeedIDFlag(flags, "feed set-visibility"),
14366
14679
  visibility: feedVisibility(
14367
14680
  requireFlag(flags, "visibility", "feed set-visibility")
14368
14681
  )
@@ -15980,18 +16293,18 @@ async function dispatchEmbedded(client, args, meta, deps) {
15980
16293
  return { _help: true, text: AGENT_HELP_TEXT };
15981
16294
  }
15982
16295
  const requestedHelpIndex = args.findIndex(
15983
- (argument) => argument === "--help" || argument === "-h"
16296
+ (argument2) => argument2 === "--help" || argument2 === "-h"
15984
16297
  );
15985
16298
  const requestedHelp = requestedHelpIndex !== -1;
15986
16299
  const brokerNativeHelp = args[0] === "trading" && args[1] === "broker" && requestedHelpIndex > 2;
15987
- const bareHelp = args.every((argument) => !argument.startsWith("-")) ? AGENT_COMMAND_HELP[args.join(" ")] : void 0;
16300
+ const bareHelp = args.every((argument2) => !argument2.startsWith("-")) ? AGENT_COMMAND_HELP[args.join(" ")] : void 0;
15988
16301
  if (bareHelp !== void 0) {
15989
16302
  return { _help: true, text: bareHelp };
15990
16303
  }
15991
16304
  if (requestedHelp && !brokerNativeHelp) {
15992
16305
  const helpIndex = requestedHelpIndex;
15993
16306
  const helpPath = args.slice(0, helpIndex);
15994
- const treeHelp = helpIndex === args.length - 1 && helpPath.every((argument) => !argument.startsWith("-")) ? AGENT_COMMAND_HELP[helpPath.join(" ")] : void 0;
16307
+ const treeHelp = helpIndex === args.length - 1 && helpPath.every((argument2) => !argument2.startsWith("-")) ? AGENT_COMMAND_HELP[helpPath.join(" ")] : void 0;
15995
16308
  if (treeHelp !== void 0 && !ALPI_ALVA_COMMAND_PATH_SET.has(helpPath.join(" "))) {
15996
16309
  return { _help: true, text: treeHelp };
15997
16310
  }
@@ -16018,7 +16331,7 @@ async function dispatchEmbedded(client, args, meta, deps) {
16018
16331
  );
16019
16332
  }
16020
16333
  const commandSelector = brokerArgv.findIndex(
16021
- (argument) => argument === "--command"
16334
+ (argument2) => argument2 === "--command"
16022
16335
  );
16023
16336
  const describedCommand = brokerArgv[commandSelector + 1];
16024
16337
  if (command2 === "describe" && commandSelector !== -1 && HIDDEN_BROKER_COMMANDS.has(describedCommand)) {