@alva-ai/toolkit 0.26.0 → 0.28.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.
package/dist/dispatch.js CHANGED
@@ -6088,6 +6088,28 @@ var EMBEDDED_COMMAND_DEFINITIONS = [
6088
6088
  route("markets earnings", "markets earnings", {
6089
6089
  values: ["ticker", "event", "fiscal-year", "fiscal-quarter"]
6090
6090
  }),
6091
+ route("trading-pairs search", "trading-pairs search", {
6092
+ values: [
6093
+ "symbol",
6094
+ "market",
6095
+ "instrument-type",
6096
+ "underlying-type",
6097
+ "quote",
6098
+ "limit"
6099
+ ],
6100
+ booleans: ["json"]
6101
+ }),
6102
+ route("trading-pairs resolve", "trading-pairs resolve", {
6103
+ values: [
6104
+ "pair",
6105
+ "symbol",
6106
+ "market",
6107
+ "instrument-type",
6108
+ "underlying-type",
6109
+ "quote"
6110
+ ],
6111
+ booleans: ["json"]
6112
+ }),
6091
6113
  action(
6092
6114
  "automation create",
6093
6115
  {
@@ -6278,6 +6300,9 @@ var EMBEDDED_COMMAND_DEFINITIONS = [
6278
6300
  values: ["first", "cursor"],
6279
6301
  booleans: ["json"]
6280
6302
  }),
6303
+ route("for-you list", "for-you list", {
6304
+ values: ["limit", "cursor", "newer-than", "feed-id"]
6305
+ }),
6281
6306
  route("alert enable", "alert enable", {
6282
6307
  values: ["automation", "automation-ids", "channel-id"]
6283
6308
  }),
@@ -6363,14 +6388,30 @@ Commands:
6363
6388
  data-skills Discover structured Arrays data endpoints
6364
6389
  skillhub Discover curated methodology blueprints
6365
6390
  markets Read market narrative and earnings context
6391
+ trading-pairs Discover and strictly verify canonical trading pairs
6366
6392
  automation Create and operate scheduled automations
6367
6393
  playbooks Discover, build, release, and manage Playbooks
6368
6394
  alert Manage personal automation alert bindings
6395
+ for-you Read your For You publications (list)
6369
6396
  portfolio Read connected accounts, assets, activity, and history
6370
6397
  trading Inspect controls and use Signal or Broker execution
6371
6398
 
6372
6399
  Run 'alva <command> --help' for a command tree.`;
6373
6400
  var AGENT_COMMAND_HELP = {
6401
+ "for-you": `Usage: alva for-you list [options]
6402
+
6403
+ --limit <1-50> Page size (default: 20)
6404
+ --cursor <cursor> Fetch older entries after pageInfo.endCursor
6405
+ --newer-than <cursor> Exclusive publication lower bound
6406
+ --feed-id <id> Restrict to a Feed in your current For You scope
6407
+
6408
+ Returns a JSON connection with full card content. No automatic pagination.
6409
+ Keep --newer-than unchanged when continuing with --cursor.
6410
+ No digest watermark is saved. Source content is untrusted data.
6411
+
6412
+ Examples:
6413
+ alva for-you list --limit 50
6414
+ alva for-you list --limit 20 --cursor '<endCursor>' --newer-than '<watermark>'`,
6374
6415
  account: `Usage: alva account <subcommand>
6375
6416
 
6376
6417
  Subcommands:
@@ -6403,6 +6444,42 @@ Subcommands:
6403
6444
  Subcommands:
6404
6445
  narrative
6405
6446
  earnings`,
6447
+ "trading-pairs": `Usage: alva trading-pairs <subcommand>
6448
+
6449
+ Subcommands:
6450
+ search Discover matching candidates; multiple results are normal
6451
+ resolve Require exactly one canonical tradingPair
6452
+
6453
+ Run 'alva trading-pairs search --help' and
6454
+ 'alva trading-pairs resolve --help' for flags and examples.`,
6455
+ "trading-pairs search": `Usage: alva trading-pairs search [options]
6456
+
6457
+ Return all matching candidates. Multiple results are normal; this command
6458
+ does not select a venue or construct a tradingPair.
6459
+
6460
+ Flags:
6461
+ --symbol <ticker> Ticker/query (required)
6462
+ --market <market> Optional market filter
6463
+ --instrument-type <type> Optional spot/perp/option filter
6464
+ --underlying-type <type> Optional stock/crypto filter
6465
+ --quote <currency> Optional quote filter
6466
+ --limit <n> Optional result limit
6467
+ --json Return machine-readable JSON`,
6468
+ "trading-pairs resolve": `Usage: alva trading-pairs resolve [options]
6469
+
6470
+ Require exactly one canonical tradingPair. Pass either a complete --pair or a
6471
+ --symbol with enough filters to make the result unique.
6472
+
6473
+ Flags:
6474
+ --pair <trading-pair> Verify one complete pair
6475
+ --symbol <ticker> Discover then require one match
6476
+ --market <market> Market filter
6477
+ --instrument-type <type> Spot/perp/option filter
6478
+ --underlying-type <type> Stock/crypto filter
6479
+ --quote <currency> Quote filter
6480
+ --json Return machine-readable JSON
6481
+
6482
+ Zero or multiple distinct pairs fail. Never use the first result.`,
6406
6483
  automation: `Usage: alva automation <subcommand>
6407
6484
 
6408
6485
  Subcommands:
@@ -6588,6 +6665,28 @@ function closestFlag(input, available) {
6588
6665
  const threshold = input.length <= 4 ? 1 : 2;
6589
6666
  return distance <= threshold ? closest : void 0;
6590
6667
  }
6668
+ var TOP_LEVEL_COMMAND_SUGGESTIONS = {
6669
+ market: "markets",
6670
+ data: "data-skills",
6671
+ feeds: "automation"
6672
+ };
6673
+ function closestCommand(input, available) {
6674
+ const terminology = TOP_LEVEL_COMMAND_SUGGESTIONS[input];
6675
+ if (terminology !== void 0 && available.has(terminology)) {
6676
+ return terminology;
6677
+ }
6678
+ let closest;
6679
+ let distance = Number.POSITIVE_INFINITY;
6680
+ for (const candidate of available.keys()) {
6681
+ const candidateDistance = editDistance(input, candidate);
6682
+ if (candidateDistance < distance) {
6683
+ closest = candidate;
6684
+ distance = candidateDistance;
6685
+ }
6686
+ }
6687
+ const threshold = input.length <= 4 ? 1 : 2;
6688
+ return distance <= threshold ? closest : void 0;
6689
+ }
6591
6690
  function mergeFlags(definition, globalFlags) {
6592
6691
  return { ...globalFlags, ...definition.flags };
6593
6692
  }
@@ -6605,7 +6704,9 @@ function resolveCommand(args, tree) {
6605
6704
  }
6606
6705
  if (node.definition !== void 0 && node.children.size === 0) break;
6607
6706
  if (consumed === 0) {
6608
- throw new CliUsageError(`Unknown command: '${input}'`);
6707
+ const suggestion = closestCommand(input, node.children);
6708
+ const recovery = suggestion === void 0 ? " Run 'alva --help' to list command families." : ` Did you mean '${suggestion}'?`;
6709
+ throw new CliUsageError(`Unknown command: '${input}'.${recovery}`);
6609
6710
  }
6610
6711
  const group2 = args[0];
6611
6712
  const command2 = args.slice(0, consumed).join(" ");
@@ -6735,6 +6836,58 @@ var parseEmbeddedCommand = createCommandParser(
6735
6836
  EMBEDDED_GLOBAL_FLAG_DEFINITIONS
6736
6837
  );
6737
6838
 
6839
+ // src/resources/forYou.ts
6840
+ var FOR_YOU_QUERY = `
6841
+ query ToolkitForYou($input: FeedEntryConnectionInput) {
6842
+ viewer {
6843
+ forYou(input: $input) {
6844
+ edges {
6845
+ cursor
6846
+ node {
6847
+ id
6848
+ feed { id }
6849
+ major { id feedId number }
6850
+ displayName source eventTimeMs publishedAtMs title body
6851
+ actions { type label url prompt }
6852
+ presentation {
6853
+ card {
6854
+ accentColor url thumbnailUrl footer
6855
+ fields { label value inline }
6856
+ }
6857
+ }
6858
+ tickers { symbol logoUrl sentiment }
6859
+ media { type coverUrl url }
6860
+ sources { type url iconUrl title subtitle description publishedAtMs }
6861
+ }
6862
+ }
6863
+ pageInfo { startCursor endCursor hasNextPage hasPreviousPage }
6864
+ }
6865
+ }
6866
+ }
6867
+ `.trim();
6868
+ function record(value) {
6869
+ return typeof value === "object" && value !== null && !Array.isArray(value);
6870
+ }
6871
+ function validateForYouListParams(params) {
6872
+ if (!record(params)) throw new Error("For You parameters must be an object");
6873
+ const first = params.first === void 0 ? 20 : params.first;
6874
+ if (typeof first !== "number" || !Number.isInteger(first) || first < 1 || first > 50) {
6875
+ throw new Error("first must be an integer between 1 and 50");
6876
+ }
6877
+ for (const field of ["after", "newerThan"]) {
6878
+ const value = params[field];
6879
+ if (value !== void 0 && (typeof value !== "string" || !value.trim())) {
6880
+ throw new Error(`${field} must be a non-empty cursor`);
6881
+ }
6882
+ }
6883
+ if (params.feedId !== void 0 && !isPositiveInt64(params.feedId)) {
6884
+ throw new Error("feedId must be a positive decimal int64 string");
6885
+ }
6886
+ }
6887
+ function isPositiveInt64(value) {
6888
+ return typeof value === "string" && /^[1-9]\d{0,18}$/.test(value) && BigInt(value) <= 9223372036854775807n;
6889
+ }
6890
+
6738
6891
  // src/cli/commandDefinitions.ts
6739
6892
  function command(path, {
6740
6893
  values = [],
@@ -6816,7 +6969,8 @@ var COMMAND_DEFINITIONS = [
6816
6969
  "args",
6817
6970
  "max-heap-size-mb",
6818
6971
  "timeout-ms"
6819
- ]
6972
+ ],
6973
+ booleans: ["args-stdin"]
6820
6974
  }),
6821
6975
  command("deploy create", {
6822
6976
  values: [
@@ -6927,6 +7081,10 @@ var COMMAND_DEFINITIONS = [
6927
7081
  command("automation resume", { values: ["id"] }),
6928
7082
  command("automation delete", { values: ["id"] }),
6929
7083
  command("credits wallet"),
7084
+ command("for-you"),
7085
+ command("for-you list", {
7086
+ values: ["limit", "cursor", "newer-than", "feed-id"]
7087
+ }),
6930
7088
  command("credits items", {
6931
7089
  values: ["last", "start", "end", "session-id", "first", "after"],
6932
7090
  booleans: ["today"]
@@ -7162,6 +7320,28 @@ var COMMAND_DEFINITIONS = [
7162
7320
  command("markets earnings", {
7163
7321
  values: ["ticker", "event", "fiscal-year", "fiscal-quarter"]
7164
7322
  }),
7323
+ command("trading-pairs search", {
7324
+ values: [
7325
+ "symbol",
7326
+ "market",
7327
+ "instrument-type",
7328
+ "underlying-type",
7329
+ "quote",
7330
+ "limit"
7331
+ ],
7332
+ booleans: ["json"]
7333
+ }),
7334
+ command("trading-pairs resolve", {
7335
+ values: [
7336
+ "pair",
7337
+ "symbol",
7338
+ "market",
7339
+ "instrument-type",
7340
+ "underlying-type",
7341
+ "quote"
7342
+ ],
7343
+ booleans: ["json"]
7344
+ }),
7165
7345
  command("trading accounts"),
7166
7346
  command("trading portfolio", { values: ["account-id"] }),
7167
7347
  command("trading orders", {
@@ -10935,8 +11115,41 @@ function validateSerializedArgs(raw) {
10935
11115
  validateJSONNumberTokens(raw);
10936
11116
  }
10937
11117
 
11118
+ // src/cli/tradingPairsFormat.ts
11119
+ function candidateLine(candidate) {
11120
+ const metadata = [
11121
+ `market=${candidate.market}`,
11122
+ `instrument=${candidate.instrumentType}`,
11123
+ candidate.underlyingType === void 0 ? void 0 : `underlying=${candidate.underlyingType}`,
11124
+ `quote=${candidate.quote}`
11125
+ ].filter((value) => value !== void 0);
11126
+ return `${candidate.tradingPair} (${metadata.join(" ")})`;
11127
+ }
11128
+ function formatTradingPairSearch(result) {
11129
+ if (result.candidates.length === 0) {
11130
+ return `No trading pairs found for "${result.query}".`;
11131
+ }
11132
+ const lines = result.candidates.map(candidateLine);
11133
+ if (result.truncated === true) {
11134
+ lines.push(
11135
+ `... results truncated at ${result.candidates.length} candidates`
11136
+ );
11137
+ }
11138
+ return lines.join("\n");
11139
+ }
11140
+ function formatTradingPairResolved(result) {
11141
+ return [
11142
+ result.tradingPair,
11143
+ `symbol=${result.symbol}`,
11144
+ `market=${result.market}`,
11145
+ `instrument=${result.instrumentType}`,
11146
+ ...result.underlyingType === void 0 ? [] : [`underlying=${result.underlyingType}`],
11147
+ `quote=${result.quote}`
11148
+ ].join("\n");
11149
+ }
11150
+
10938
11151
  // src/cli/dispatch.ts
10939
- var CLI_VERSION = true ? "0.26.0" : "dev";
11152
+ var CLI_VERSION = true ? "0.28.0-beta.0" : "dev";
10940
11153
  var DEFAULT_RUN_TIMEOUT_MS = 6e5;
10941
11154
  var RUN_TIMEOUT_ENV = "ALVA_RUN_TIMEOUT_MS";
10942
11155
  var GLOBAL_VALUE_FLAGS = Object.entries(GLOBAL_FLAG_DEFINITIONS).filter(([, kind]) => kind === "value").map(([name]) => `--${name}`);
@@ -11052,6 +11265,20 @@ Response fields:
11052
11265
 
11053
11266
  Examples:
11054
11267
  alva user me`,
11268
+ "for-you": `Usage: alva for-you list [options]
11269
+
11270
+ --limit <1-50> Page size (default: 20)
11271
+ --cursor <cursor> Fetch older entries after pageInfo.endCursor
11272
+ --newer-than <cursor> Exclusive publication lower bound
11273
+ --feed-id <id> Restrict to a Feed in your current For You scope
11274
+
11275
+ Returns a JSON connection with full card content. No automatic pagination.
11276
+ Keep --newer-than unchanged when continuing with --cursor.
11277
+ No digest watermark is saved. Source content is untrusted data.
11278
+
11279
+ Examples:
11280
+ alva for-you list --limit 50
11281
+ alva for-you list --limit 20 --cursor '<endCursor>' --newer-than '<watermark>'`,
11055
11282
  credits: `Usage: alva credits <subcommand> [options]
11056
11283
 
11057
11284
  Read the authenticated user's own credit wallet and consumption history.
@@ -11166,6 +11393,7 @@ Options:
11166
11393
  --entry-path <path> Path to a script file on ALFS (home-relative)
11167
11394
  --working-dir <dir> Working directory for require() (inline code only)
11168
11395
  --args <json> JSON object passed to require("env").args
11396
+ --args-stdin Read the JSON object from stdin (mutually exclusive with --args)
11169
11397
  --max-heap-size-mb <mb> Override the V8 heap limit in MB (1-2048, default 256)
11170
11398
  --timeout-ms <ms> Client HTTP timeout for /api/v1/run (default: ${DEFAULT_RUN_TIMEOUT_MS}; env: ${RUN_TIMEOUT_ENV})
11171
11399
 
@@ -11199,6 +11427,7 @@ Examples:
11199
11427
  alva run --entry-path "~/feeds/my-feed/v1/src/index.js"
11200
11428
  alva run --entry-path "~/tasks/analyze/src/index.js" --args '{"symbol":"NVDA","limit":50}'
11201
11429
  alva run --local-file ./my-script.js --args '{"symbol":"BTC"}'
11430
+ printf '%s' '{"symbol":"BTC"}' | alva run --local-file ./my-script.js --args-stdin
11202
11431
  alva run --entry-path "~/tasks/heavy/src/index.js" --max-heap-size-mb 1024
11203
11432
  alva run --entry-path "~/feeds/slow/v1/src/index.js" --timeout-ms 900000`,
11204
11433
  deploy: `Usage: alva deploy <subcommand> [options]
@@ -12087,6 +12316,34 @@ Examples:
12087
12316
  alva markets earnings --ticker AAPL
12088
12317
  alva markets earnings --ticker AAPL --event next-confirmed
12089
12318
  alva markets earnings --ticker AAPL --fiscal-year 2026 --fiscal-quarter Q3`,
12319
+ "trading-pairs": `Usage: alva trading-pairs <subcommand> [options]
12320
+
12321
+ Discover canonical trading-pair identities before backtesting or trading.
12322
+ The returned tradingPair is the exact value to use in OHLCV, Altra targets,
12323
+ positions, and orders. This command never constructs aliases or picks the
12324
+ first result.
12325
+
12326
+ Subcommands:
12327
+ search Return all matching candidates; multiple results are normal
12328
+ resolve Require exactly one matching canonical tradingPair
12329
+
12330
+ Search and resolve flags:
12331
+ --symbol <ticker> Underlying ticker/query (for example RKLB)
12332
+ --market <market> Venue/market filter (for example US, BINANCE)
12333
+ --instrument-type <type> spot, perp, option, ...
12334
+ --underlying-type <type> stock, crypto, ...
12335
+ --quote <currency> USD, USDT, USDC, ...
12336
+ --json Return the machine-readable result
12337
+
12338
+ Search-only flags:
12339
+ --limit <n> Limit returned candidates; truncation is reported
12340
+
12341
+ Resolve forms:
12342
+ alva trading-pairs resolve --pair US_SPOT_RKLB_USD --json
12343
+ alva trading-pairs resolve --symbol RKLB --market US --instrument-type spot --quote USD --json
12344
+
12345
+ Resolve fails when zero or multiple distinct pairs remain. Existing holdings
12346
+ must keep their stored full tradingPair instead of being resolved again.`,
12090
12347
  trading: `Usage: alva trading <subcommand> [options]
12091
12348
 
12092
12349
  Manage trading accounts, portfolios, orders, subscriptions, and risk rules.
@@ -12172,13 +12429,13 @@ function boolFlag(val) {
12172
12429
  if (val === "false") return false;
12173
12430
  return void 0;
12174
12431
  }
12175
- function serializedJSONFlag(value, command2) {
12432
+ function serializedJSONFlag(value, command2, flag = "--args") {
12176
12433
  if (value === void 0) return void 0;
12177
12434
  try {
12178
12435
  validateSerializedArgs(value);
12179
12436
  } catch (error) {
12180
12437
  throw new CliUsageError(
12181
- `--args must contain valid JSON for '${command2}': ${error instanceof Error ? error.message : String(error)}`,
12438
+ `${flag} must contain valid JSON for '${command2}': ${error instanceof Error ? error.message : String(error)}`,
12182
12439
  command2.split(" ")[0]
12183
12440
  );
12184
12441
  }
@@ -12363,19 +12620,19 @@ function deliveryProviderFilter(flags, command2) {
12363
12620
  }
12364
12621
  return flags["delivery-provider"];
12365
12622
  }
12366
- function projectUserProfileForCLI(record) {
12367
- const { active_channel: activeIMProvider, ...profile } = record;
12623
+ function projectUserProfileForCLI(record2) {
12624
+ const { active_channel: activeIMProvider, ...profile } = record2;
12368
12625
  return { ...profile, active_im_provider: activeIMProvider };
12369
12626
  }
12370
12627
  function projectNotificationHistoryForCLI(response) {
12371
12628
  if (response === null || typeof response !== "object" || Array.isArray(response)) {
12372
12629
  return response;
12373
12630
  }
12374
- const record = response;
12375
- if (!Array.isArray(record.items)) return response;
12631
+ const record2 = response;
12632
+ if (!Array.isArray(record2.items)) return response;
12376
12633
  return {
12377
- ...record,
12378
- items: record.items.map((item) => {
12634
+ ...record2,
12635
+ items: record2.items.map((item) => {
12379
12636
  if (item === null || typeof item !== "object" || Array.isArray(item)) {
12380
12637
  return item;
12381
12638
  }
@@ -12860,7 +13117,7 @@ async function executeParsedCommand(client, parsedCommand, meta, deps) {
12860
13117
  const positionals = parsedCommand.positionals;
12861
13118
  if (group === "whoami") {
12862
13119
  const user = await client.user.me();
12863
- const record = projectUserProfileForCLI(
13120
+ const record2 = projectUserProfileForCLI(
12864
13121
  user
12865
13122
  );
12866
13123
  const version = meta?.cliVersion ?? CLI_VERSION;
@@ -12877,10 +13134,10 @@ async function executeParsedCommand(client, parsedCommand, meta, deps) {
12877
13134
  metaBlock.arrays_jwt = arraysJwtStatus;
12878
13135
  }
12879
13136
  const result = {
12880
- ...record,
13137
+ ...record2,
12881
13138
  _meta: metaBlock
12882
13139
  };
12883
- const minVersion = record.toolkit_min_version;
13140
+ const minVersion = record2.toolkit_min_version;
12884
13141
  if (typeof minVersion === "string" && version && version !== "dev" && isVersionOlderThan(version, minVersion)) {
12885
13142
  result._warning = `Warning: your toolkit version (${version}) is older than the minimum recommended version (${minVersion}). Please upgrade: npm install -g @alva-ai/toolkit`;
12886
13143
  }
@@ -13020,7 +13277,30 @@ async function executeParsedCommand(client, parsedCommand, meta, deps) {
13020
13277
  ),
13021
13278
  timeout_ms
13022
13279
  };
13023
- const serializedArgs = serializedJSONFlag(flags["args"], "run");
13280
+ const argsFromStdin = boolFlag(flags["args-stdin"]) === true;
13281
+ if (argsFromStdin && flags["args"] !== void 0) {
13282
+ throw new CliUsageError(
13283
+ "--args and --args-stdin are mutually exclusive",
13284
+ "run"
13285
+ );
13286
+ }
13287
+ let serializedArgs = serializedJSONFlag(flags["args"], "run");
13288
+ if (argsFromStdin) {
13289
+ if (!deps?.readStdin) {
13290
+ throw new CliUsageError(
13291
+ "--args-stdin requires a Node.js runtime adapter",
13292
+ "run"
13293
+ );
13294
+ }
13295
+ const stdin = await deps.readStdin();
13296
+ serializedArgs = serializedJSONFlag(stdin, "run", "--args-stdin");
13297
+ if (serializedArgs === void 0) {
13298
+ throw new CliUsageError(
13299
+ "--args-stdin requires JSON input from stdin",
13300
+ "run"
13301
+ );
13302
+ }
13303
+ }
13024
13304
  return serializedArgs === void 0 ? client.run.execute(params) : client.run._executeSerializedArgs(params, serializedArgs);
13025
13305
  }
13026
13306
  case "deploy": {
@@ -13350,6 +13630,32 @@ async function executeParsedCommand(client, parsedCommand, meta, deps) {
13350
13630
  );
13351
13631
  }
13352
13632
  }
13633
+ case "for-you": {
13634
+ if (subcommand !== "list") {
13635
+ throw new CliUsageError("Expected for-you list", "for-you");
13636
+ }
13637
+ const params = {
13638
+ first: optionalBoundedIntegerFlag(
13639
+ flags,
13640
+ "limit",
13641
+ "for-you list",
13642
+ 1,
13643
+ 50
13644
+ ),
13645
+ after: flags.cursor,
13646
+ newerThan: flags["newer-than"],
13647
+ feedId: flags["feed-id"]
13648
+ };
13649
+ try {
13650
+ validateForYouListParams(params);
13651
+ } catch (error) {
13652
+ throw new CliUsageError(
13653
+ error instanceof Error ? error.message : String(error),
13654
+ "for-you"
13655
+ );
13656
+ }
13657
+ return client.forYou.list(params);
13658
+ }
13353
13659
  case "credits": {
13354
13660
  if (!subcommand)
13355
13661
  throw new CliUsageError("Missing subcommand for credits", "credits");
@@ -14346,6 +14652,61 @@ async function executeParsedCommand(client, parsedCommand, meta, deps) {
14346
14652
  );
14347
14653
  }
14348
14654
  }
14655
+ case "trading-pairs": {
14656
+ if (!subcommand) {
14657
+ throw new CliUsageError(
14658
+ "Missing subcommand for trading-pairs",
14659
+ "trading-pairs"
14660
+ );
14661
+ }
14662
+ const asJson = boolFlag(flags["json"]) ?? false;
14663
+ const filters = {
14664
+ market: flags["market"],
14665
+ instrumentType: flags["instrument-type"],
14666
+ underlyingType: flags["underlying-type"],
14667
+ quote: flags["quote"]
14668
+ };
14669
+ switch (subcommand) {
14670
+ case "search": {
14671
+ const limit = flags["limit"] === void 0 ? void 0 : requirePositiveIntegerFlag(
14672
+ flags,
14673
+ "limit",
14674
+ "trading-pairs search"
14675
+ );
14676
+ const result = await client.tradingPairs.search({
14677
+ symbol: requireFlag(flags, "symbol", "trading-pairs search"),
14678
+ ...filters,
14679
+ limit
14680
+ });
14681
+ return asJson ? result : formatTradingPairSearch(result);
14682
+ }
14683
+ case "resolve": {
14684
+ const pair = flags["pair"];
14685
+ const symbol = flags["symbol"];
14686
+ if (pair !== void 0 && symbol !== void 0) {
14687
+ throw new CliUsageError(
14688
+ "'trading-pairs resolve' accepts either --pair or --symbol, not both",
14689
+ "trading-pairs"
14690
+ );
14691
+ }
14692
+ if (pair === void 0 && symbol === void 0) {
14693
+ throw new CliUsageError(
14694
+ "'trading-pairs resolve' requires --pair or --symbol",
14695
+ "trading-pairs"
14696
+ );
14697
+ }
14698
+ const result = await client.tradingPairs.resolve(
14699
+ pair !== void 0 ? { pair, ...filters } : { symbol, ...filters }
14700
+ );
14701
+ return asJson ? result : formatTradingPairResolved(result);
14702
+ }
14703
+ default:
14704
+ throw new CliUsageError(
14705
+ `Unknown subcommand: trading-pairs ${subcommand}`,
14706
+ "trading-pairs"
14707
+ );
14708
+ }
14709
+ }
14349
14710
  case "trading": {
14350
14711
  if (!subcommand)
14351
14712
  throw new CliUsageError("Missing subcommand for trading", "trading");