@agenzo/merchant-cli 0.9.6 → 0.10.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/index.js CHANGED
@@ -2873,6 +2873,65 @@ var flightRefundConfirmSchema = flightSchema(
2873
2873
  { status: { type: "int", description: "Refund status after the action." } },
2874
2874
  { command: "agenzo-merchant-cli flight-flink refund-confirm --refund-order-no R1 --confirm 1 --idempotency-key k7", output_summary: "Refund confirmed or cancelled." }
2875
2875
  );
2876
+ var DATA_NOUN = "data-aisa";
2877
+ function dataSchema(spec) {
2878
+ return { cli: CLI_NAME, noun: DATA_NOUN, ...spec };
2879
+ }
2880
+ var dataListCategoriesSchema = dataSchema({
2881
+ verb: "list-categories",
2882
+ description: "List the data categories and how many capabilities each one holds. Free: answered from the bundled index, no upstream call.",
2883
+ flags: {
2884
+ // No flags of its own — authentication rides on the global --api-key.
2885
+ },
2886
+ response: {
2887
+ categories: { type: "array", description: "Categories ordered by size; each item is {category, endpoints}." }
2888
+ },
2889
+ example: { command: "agenzo-merchant-cli data-aisa list-categories", output_summary: 'The data categories with a capability count each \u2014 use it to answer "what can you look up".' }
2890
+ });
2891
+ var dataSearchSchema = dataSchema({
2892
+ verb: "search",
2893
+ description: "Find a data capability by keyword. Free: answered from the bundled index, no upstream call. Returns operationId + method + tags + summary + price_usd for each hit.",
2894
+ flags: {
2895
+ keyword: { type: "string", required: false, constraints: "Space- or comma-separated tokens, matched against the capability index (identifier, summary, tags). Omitted returns the first `limit` capabilities as examples.", description: "What to look for, e.g. 'crypto price' or 'reddit'." },
2896
+ limit: { type: "int", required: false, default: 15, constraints: "1..50; defaults to 15.", description: "How many hits to return." }
2897
+ },
2898
+ response: {
2899
+ results: { type: "array", description: "Matching capabilities; each item is {operationId, method, tags, summary, price_usd}. Relay operationId VERBATIM into describe / query." }
2900
+ },
2901
+ example: { command: "agenzo-merchant-cli data-aisa search --keyword 'crypto price' --limit 5", output_summary: "Hits with operationId + price_usd; describe the chosen one before running it." }
2902
+ });
2903
+ var dataDescribeSchema = dataSchema({
2904
+ verb: "describe",
2905
+ description: "Read one capability's parameter spec, usage hint and unit price before calling it. Free: answered from the bundled index, no upstream call.",
2906
+ flags: {
2907
+ "operation-id": { type: "string", required: true, constraints: "An operationId returned by search, verbatim.", description: "Which capability to describe." }
2908
+ },
2909
+ response: {
2910
+ operationId: { type: "string", description: "The capability id \u2014 pass it unchanged to query." },
2911
+ method: { type: "string", description: "Upstream HTTP method of the capability. GET and POST are both reads; POST does not mean a write." },
2912
+ params: { type: "array", description: "Declared parameters; each item is {name, in, required, type, desc}. `desc` may be an empty string." },
2913
+ required: { type: "array", description: "Names of the required parameters." },
2914
+ usage: { type: "string", description: "Human-readable call guidance: which params are required, where each one sits, how to assemble --params." },
2915
+ price_usd: { type: "number|null", description: "Unit price of one query call, in USD." },
2916
+ tags: { type: "array", description: "Categories this capability belongs to." },
2917
+ cost_tier: { type: "string|null", description: "Coarse price band of this capability." }
2918
+ },
2919
+ example: { command: "agenzo-merchant-cli data-aisa describe --operation-id get_coingecko_simple_price", output_summary: "Parameter spec + unit price; build --params from params[].name, then query." }
2920
+ });
2921
+ var dataQuerySchema = dataSchema({
2922
+ verb: "query",
2923
+ description: "Run one capability and return its data. Charged per call. READ-ONLY: it fetches data and nothing else.",
2924
+ flags: {
2925
+ "operation-id": { type: "string", required: true, constraints: "An operationId returned by search, verbatim.", description: "Which capability to run." },
2926
+ params: { type: "object", required: false, constraints: "A JSON object keyed by the parameter names from describe. Passed through as a whole; unknown keys are dropped.", description: "The capability's parameters." },
2927
+ "idempotency-key": { type: "string", required: false, constraints: "Optional. [A-Za-z0-9_-]{1,128}. When absent the request is still sent (no prompt, nothing generated) and de-duplication falls back to the result cache.", description: "Caller-supplied de-duplication key, forwarded verbatim as the Idempotency-Key header." }
2928
+ },
2929
+ response: {
2930
+ data: { type: "object", description: "The capability response, verbatim." },
2931
+ cost_usd: { type: "number", description: "What this call cost, in USD." }
2932
+ },
2933
+ example: { command: `agenzo-merchant-cli data-aisa query --operation-id get_coingecko_simple_price --params '{"ids":"bitcoin","vs_currencies":"usd"}'`, output_summary: "Returns data (upstream payload, verbatim) plus cost_usd for this call." }
2934
+ });
2876
2935
 
2877
2936
  // src/ride-elife/quote.ts
2878
2937
  function need(value, flag) {
@@ -7503,6 +7562,169 @@ function registerFlightSkillCommand(parent) {
7503
7562
  });
7504
7563
  }
7505
7564
 
7565
+ // src/data-aisa/_helpers.ts
7566
+ function need23(value, flag) {
7567
+ if (value === void 0) {
7568
+ throw new CliError("PARAM_INVALID", `Missing required --${flag}.`);
7569
+ }
7570
+ return value;
7571
+ }
7572
+ function num11(value, flag) {
7573
+ const n = Number(need23(value, flag));
7574
+ if (!Number.isFinite(n)) {
7575
+ throw new CliError("PARAM_INVALID", `--${flag} must be a number.`);
7576
+ }
7577
+ return n;
7578
+ }
7579
+ function jsonObject(raw, flag) {
7580
+ let parsed;
7581
+ try {
7582
+ parsed = JSON.parse(raw);
7583
+ } catch {
7584
+ throw new CliError("PARAM_INVALID", `--${flag} must be a JSON object.`);
7585
+ }
7586
+ if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
7587
+ throw new CliError("PARAM_INVALID", `--${flag} must be a JSON object.`);
7588
+ }
7589
+ return parsed;
7590
+ }
7591
+ function verbatimIdempotencyKey(raw, flag) {
7592
+ if (!IDEMPOTENCY_KEY_PATTERN.test(raw)) {
7593
+ throw new CliError(
7594
+ "PARAM_INVALID",
7595
+ `Invalid --${flag}: "${raw}". ${IDEMPOTENCY_KEY_RULE}`
7596
+ );
7597
+ }
7598
+ return raw;
7599
+ }
7600
+ function resolveApiKey2(flag) {
7601
+ return PromptEngine.resolveInput(flag, { message: "API Key:", type: "password" });
7602
+ }
7603
+ async function render4(data, format, text) {
7604
+ const resolved = resolveFormat(format);
7605
+ const result = { data, text: () => text(data) };
7606
+ await renderWithContext(result, { format: resolved }, new ConfigManager());
7607
+ }
7608
+ function kv(data) {
7609
+ const lines = Object.entries(data).map(([k, v]) => [
7610
+ k,
7611
+ typeof v === "object" && v !== null ? JSON.stringify(v) : String(v ?? "-")
7612
+ ]);
7613
+ return Formatter.keyValue(lines);
7614
+ }
7615
+
7616
+ // src/data-aisa/list-categories.ts
7617
+ function registerDataListCategoriesCommand(parent, deps) {
7618
+ const cmd = parent.command("list-categories").description(
7619
+ "List the data categories and how many capabilities each one holds. Free (answered from the bundled index, no upstream call), read-only."
7620
+ ).option("--api-key <key>", "API Key for authentication (X-Api-Key)");
7621
+ attachSchemaHelp(cmd, dataListCategoriesSchema);
7622
+ cmd.action(async () => {
7623
+ const opts = cmd.optsWithGlobals();
7624
+ const format = resolveFormat(opts.format);
7625
+ const apiKey = await resolveApiKey2(opts.apiKey);
7626
+ const spinner = format === "json" ? null : createSpinner("Fetching data categories...");
7627
+ const result = await deps.apiClient.get("/data/categories", {
7628
+ type: "api-key",
7629
+ key: apiKey
7630
+ });
7631
+ spinner?.stop();
7632
+ if (!result.success) throw CliError.fromApi(result, { auth: "api-key" });
7633
+ await render4(result.data, opts.format, (d) => JSON.stringify(d, null, 2));
7634
+ });
7635
+ }
7636
+
7637
+ // src/data-aisa/search.ts
7638
+ function registerDataSearchCommand(parent, deps) {
7639
+ const cmd = parent.command("search").description(
7640
+ "Find a data capability by keyword. Free (answered from the bundled index, no upstream call), read-only. Returns operationId + method + tags + summary + price_usd for each hit."
7641
+ ).option("--api-key <key>", "API Key for authentication (X-Api-Key)").option(
7642
+ "--keyword <kw>",
7643
+ "What to look for, e.g. 'crypto price' or 'reddit'. Space- or comma-separated tokens; omitted returns the first --limit capabilities as examples."
7644
+ ).option("--limit <n>", "How many hits to return (1-50)", "15");
7645
+ attachSchemaHelp(cmd, dataSearchSchema);
7646
+ cmd.action(async () => {
7647
+ const opts = cmd.optsWithGlobals();
7648
+ const format = resolveFormat(opts.format);
7649
+ const apiKey = await resolveApiKey2(opts.apiKey);
7650
+ const params = {};
7651
+ if (opts.keyword !== void 0) params.keyword = String(opts.keyword);
7652
+ if (opts.limit !== void 0) {
7653
+ params.limit = String(num11(opts.limit, "limit"));
7654
+ }
7655
+ const spinner = format === "json" ? null : createSpinner("Searching data capabilities...");
7656
+ const result = await deps.apiClient.get(
7657
+ "/data/search",
7658
+ { type: "api-key", key: apiKey },
7659
+ params
7660
+ );
7661
+ spinner?.stop();
7662
+ if (!result.success) throw CliError.fromApi(result, { auth: "api-key" });
7663
+ await render4(result.data, opts.format, (d) => JSON.stringify(d, null, 2));
7664
+ });
7665
+ }
7666
+
7667
+ // src/data-aisa/describe.ts
7668
+ function registerDataDescribeCommand(parent, deps) {
7669
+ const cmd = parent.command("describe").description(
7670
+ "Read one capability's parameter spec, usage hint and unit price before calling it. Free (answered from the bundled index, no upstream call), read-only."
7671
+ ).option("--api-key <key>", "API Key for authentication (X-Api-Key)").option("--operation-id <id>", "Which capability to describe \u2014 an operationId returned by search, verbatim");
7672
+ attachSchemaHelp(cmd, dataDescribeSchema);
7673
+ cmd.action(async () => {
7674
+ const opts = cmd.optsWithGlobals();
7675
+ const format = resolveFormat(opts.format);
7676
+ const operationId = need23(opts.operationId, "operation-id");
7677
+ const apiKey = await resolveApiKey2(opts.apiKey);
7678
+ const spinner = format === "json" ? null : createSpinner("Fetching capability spec...");
7679
+ const result = await deps.apiClient.get(
7680
+ `/data/describe/${encodeURIComponent(operationId)}`,
7681
+ { type: "api-key", key: apiKey }
7682
+ );
7683
+ spinner?.stop();
7684
+ if (!result.success) throw CliError.fromApi(result, { auth: "api-key" });
7685
+ await render4(result.data, opts.format, (d) => kv(d));
7686
+ });
7687
+ }
7688
+
7689
+ // src/data-aisa/query.ts
7690
+ function registerDataQueryCommand(parent, deps) {
7691
+ const cmd = parent.command("query").description(
7692
+ "Run one capability and return its data. Charged per call. READ-ONLY: it fetches data and nothing else."
7693
+ ).option("--api-key <key>", "API Key for authentication (X-Api-Key)").option("--operation-id <id>", "Which capability to run \u2014 an operationId returned by search, verbatim").option(
7694
+ "--params <json>",
7695
+ "The capability's parameters as a JSON object keyed by the parameter names from describe. Passed through as a whole; unknown keys are dropped."
7696
+ ).option(
7697
+ "--idempotency-key <key>",
7698
+ "Optional de-duplication key (1-128 chars [A-Za-z0-9_-]) forwarded verbatim as the Idempotency-Key header; never auto-generated, and omitting it is fine"
7699
+ );
7700
+ attachSchemaHelp(cmd, dataQuerySchema);
7701
+ cmd.action(async () => {
7702
+ const opts = cmd.optsWithGlobals();
7703
+ const format = resolveFormat(opts.format);
7704
+ const operationId = need23(opts.operationId, "operation-id");
7705
+ const body = { operation_id: operationId };
7706
+ if (opts.params !== void 0) {
7707
+ body.params = jsonObject(opts.params, "params");
7708
+ }
7709
+ let idempotencyKey;
7710
+ if (opts.idempotencyKey !== void 0) {
7711
+ idempotencyKey = verbatimIdempotencyKey(opts.idempotencyKey, "idempotency-key");
7712
+ }
7713
+ const extraHeaders = idempotencyKey ? { "Idempotency-Key": idempotencyKey } : void 0;
7714
+ const apiKey = await resolveApiKey2(opts.apiKey);
7715
+ const spinner = format === "json" ? null : createSpinner("Fetching data...");
7716
+ const result = await deps.apiClient.post(
7717
+ "/data/query",
7718
+ { type: "api-key", key: apiKey },
7719
+ body,
7720
+ extraHeaders
7721
+ );
7722
+ spinner?.stop();
7723
+ if (!result.success) throw CliError.fromApi(result, { auth: "api-key" });
7724
+ await render4(result.data, opts.format, (d) => kv(d));
7725
+ });
7726
+ }
7727
+
7506
7728
  // src/index.ts
7507
7729
  var programRef;
7508
7730
  async function main() {
@@ -7673,6 +7895,13 @@ Key notes:
7673
7895
  registerRefundDetailCommand(flightCmd, deps);
7674
7896
  registerRefundConfirmCommand(flightCmd, deps);
7675
7897
  registerFlightSkillCommand(flightCmd);
7898
+ const dataCmd = program.command("data-aisa").description(
7899
+ "AIsa read-only information lookup (crypto, markets, web & news, SEO, social, prediction markets, research): list-categories / search / describe / query. Pay-per-call READ-ONLY lookups \u2014 it never places an order and never takes money."
7900
+ );
7901
+ registerDataListCategoriesCommand(dataCmd, deps);
7902
+ registerDataSearchCommand(dataCmd, deps);
7903
+ registerDataDescribeCommand(dataCmd, deps);
7904
+ registerDataQueryCommand(dataCmd, deps);
7676
7905
  await program.parseAsync(process.argv);
7677
7906
  }
7678
7907
  function resolveActiveFormat() {