@agenzo/merchant-cli 0.9.6 → 0.10.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/index.js +230 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2873,6 +2873,66 @@ 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 + path + tags + summary + price_usd for each hit.",
|
|
2894
|
+
flags: {
|
|
2895
|
+
keyword: { type: "string", required: false, constraints: "Space- or comma-separated tokens, matched against operationId / path / 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, path, 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." },
|
|
2912
|
+
path: { type: "string", description: "Upstream path of the capability." },
|
|
2913
|
+
params: { type: "array", description: "Declared parameters; each item is {name, in, required, type, desc}. `desc` may be an empty string." },
|
|
2914
|
+
required: { type: "array", description: "Names of the required parameters." },
|
|
2915
|
+
usage: { type: "string", description: "Human-readable call guidance: which params are required, where each one sits, how to assemble --params." },
|
|
2916
|
+
price_usd: { type: "number|null", description: "Unit price of one query call, in USD." },
|
|
2917
|
+
tags: { type: "array", description: "Categories this capability belongs to." },
|
|
2918
|
+
cost_tier: { type: "string|null", description: "Coarse price band of this capability." }
|
|
2919
|
+
},
|
|
2920
|
+
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." }
|
|
2921
|
+
});
|
|
2922
|
+
var dataQuerySchema = dataSchema({
|
|
2923
|
+
verb: "query",
|
|
2924
|
+
description: "Run one capability and return its data. Charged per call. READ-ONLY: it fetches data and nothing else.",
|
|
2925
|
+
flags: {
|
|
2926
|
+
"operation-id": { type: "string", required: true, constraints: "An operationId returned by search, verbatim.", description: "Which capability to run." },
|
|
2927
|
+
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." },
|
|
2928
|
+
"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." }
|
|
2929
|
+
},
|
|
2930
|
+
response: {
|
|
2931
|
+
data: { type: "object", description: "The capability response, verbatim." },
|
|
2932
|
+
cost_usd: { type: "number", description: "What this call cost, in USD." }
|
|
2933
|
+
},
|
|
2934
|
+
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." }
|
|
2935
|
+
});
|
|
2876
2936
|
|
|
2877
2937
|
// src/ride-elife/quote.ts
|
|
2878
2938
|
function need(value, flag) {
|
|
@@ -7503,6 +7563,169 @@ function registerFlightSkillCommand(parent) {
|
|
|
7503
7563
|
});
|
|
7504
7564
|
}
|
|
7505
7565
|
|
|
7566
|
+
// src/data-aisa/_helpers.ts
|
|
7567
|
+
function need23(value, flag) {
|
|
7568
|
+
if (value === void 0) {
|
|
7569
|
+
throw new CliError("PARAM_INVALID", `Missing required --${flag}.`);
|
|
7570
|
+
}
|
|
7571
|
+
return value;
|
|
7572
|
+
}
|
|
7573
|
+
function num11(value, flag) {
|
|
7574
|
+
const n = Number(need23(value, flag));
|
|
7575
|
+
if (!Number.isFinite(n)) {
|
|
7576
|
+
throw new CliError("PARAM_INVALID", `--${flag} must be a number.`);
|
|
7577
|
+
}
|
|
7578
|
+
return n;
|
|
7579
|
+
}
|
|
7580
|
+
function jsonObject(raw, flag) {
|
|
7581
|
+
let parsed;
|
|
7582
|
+
try {
|
|
7583
|
+
parsed = JSON.parse(raw);
|
|
7584
|
+
} catch {
|
|
7585
|
+
throw new CliError("PARAM_INVALID", `--${flag} must be a JSON object.`);
|
|
7586
|
+
}
|
|
7587
|
+
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
|
|
7588
|
+
throw new CliError("PARAM_INVALID", `--${flag} must be a JSON object.`);
|
|
7589
|
+
}
|
|
7590
|
+
return parsed;
|
|
7591
|
+
}
|
|
7592
|
+
function verbatimIdempotencyKey(raw, flag) {
|
|
7593
|
+
if (!IDEMPOTENCY_KEY_PATTERN.test(raw)) {
|
|
7594
|
+
throw new CliError(
|
|
7595
|
+
"PARAM_INVALID",
|
|
7596
|
+
`Invalid --${flag}: "${raw}". ${IDEMPOTENCY_KEY_RULE}`
|
|
7597
|
+
);
|
|
7598
|
+
}
|
|
7599
|
+
return raw;
|
|
7600
|
+
}
|
|
7601
|
+
function resolveApiKey2(flag) {
|
|
7602
|
+
return PromptEngine.resolveInput(flag, { message: "API Key:", type: "password" });
|
|
7603
|
+
}
|
|
7604
|
+
async function render4(data, format, text) {
|
|
7605
|
+
const resolved = resolveFormat(format);
|
|
7606
|
+
const result = { data, text: () => text(data) };
|
|
7607
|
+
await renderWithContext(result, { format: resolved }, new ConfigManager());
|
|
7608
|
+
}
|
|
7609
|
+
function kv(data) {
|
|
7610
|
+
const lines = Object.entries(data).map(([k, v]) => [
|
|
7611
|
+
k,
|
|
7612
|
+
typeof v === "object" && v !== null ? JSON.stringify(v) : String(v ?? "-")
|
|
7613
|
+
]);
|
|
7614
|
+
return Formatter.keyValue(lines);
|
|
7615
|
+
}
|
|
7616
|
+
|
|
7617
|
+
// src/data-aisa/list-categories.ts
|
|
7618
|
+
function registerDataListCategoriesCommand(parent, deps) {
|
|
7619
|
+
const cmd = parent.command("list-categories").description(
|
|
7620
|
+
"List the data categories and how many capabilities each one holds. Free (answered from the bundled index, no upstream call), read-only."
|
|
7621
|
+
).option("--api-key <key>", "API Key for authentication (X-Api-Key)");
|
|
7622
|
+
attachSchemaHelp(cmd, dataListCategoriesSchema);
|
|
7623
|
+
cmd.action(async () => {
|
|
7624
|
+
const opts = cmd.optsWithGlobals();
|
|
7625
|
+
const format = resolveFormat(opts.format);
|
|
7626
|
+
const apiKey = await resolveApiKey2(opts.apiKey);
|
|
7627
|
+
const spinner = format === "json" ? null : createSpinner("Fetching data categories...");
|
|
7628
|
+
const result = await deps.apiClient.get("/data/categories", {
|
|
7629
|
+
type: "api-key",
|
|
7630
|
+
key: apiKey
|
|
7631
|
+
});
|
|
7632
|
+
spinner?.stop();
|
|
7633
|
+
if (!result.success) throw CliError.fromApi(result, { auth: "api-key" });
|
|
7634
|
+
await render4(result.data, opts.format, (d) => JSON.stringify(d, null, 2));
|
|
7635
|
+
});
|
|
7636
|
+
}
|
|
7637
|
+
|
|
7638
|
+
// src/data-aisa/search.ts
|
|
7639
|
+
function registerDataSearchCommand(parent, deps) {
|
|
7640
|
+
const cmd = parent.command("search").description(
|
|
7641
|
+
"Find a data capability by keyword. Free (answered from the bundled index, no upstream call), read-only. Returns operationId + method + path + tags + summary + price_usd for each hit."
|
|
7642
|
+
).option("--api-key <key>", "API Key for authentication (X-Api-Key)").option(
|
|
7643
|
+
"--keyword <kw>",
|
|
7644
|
+
"What to look for, e.g. 'crypto price' or 'reddit'. Space- or comma-separated tokens; omitted returns the first --limit capabilities as examples."
|
|
7645
|
+
).option("--limit <n>", "How many hits to return (1-50)", "15");
|
|
7646
|
+
attachSchemaHelp(cmd, dataSearchSchema);
|
|
7647
|
+
cmd.action(async () => {
|
|
7648
|
+
const opts = cmd.optsWithGlobals();
|
|
7649
|
+
const format = resolveFormat(opts.format);
|
|
7650
|
+
const apiKey = await resolveApiKey2(opts.apiKey);
|
|
7651
|
+
const params = {};
|
|
7652
|
+
if (opts.keyword !== void 0) params.keyword = String(opts.keyword);
|
|
7653
|
+
if (opts.limit !== void 0) {
|
|
7654
|
+
params.limit = String(num11(opts.limit, "limit"));
|
|
7655
|
+
}
|
|
7656
|
+
const spinner = format === "json" ? null : createSpinner("Searching data capabilities...");
|
|
7657
|
+
const result = await deps.apiClient.get(
|
|
7658
|
+
"/data/search",
|
|
7659
|
+
{ type: "api-key", key: apiKey },
|
|
7660
|
+
params
|
|
7661
|
+
);
|
|
7662
|
+
spinner?.stop();
|
|
7663
|
+
if (!result.success) throw CliError.fromApi(result, { auth: "api-key" });
|
|
7664
|
+
await render4(result.data, opts.format, (d) => JSON.stringify(d, null, 2));
|
|
7665
|
+
});
|
|
7666
|
+
}
|
|
7667
|
+
|
|
7668
|
+
// src/data-aisa/describe.ts
|
|
7669
|
+
function registerDataDescribeCommand(parent, deps) {
|
|
7670
|
+
const cmd = parent.command("describe").description(
|
|
7671
|
+
"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."
|
|
7672
|
+
).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");
|
|
7673
|
+
attachSchemaHelp(cmd, dataDescribeSchema);
|
|
7674
|
+
cmd.action(async () => {
|
|
7675
|
+
const opts = cmd.optsWithGlobals();
|
|
7676
|
+
const format = resolveFormat(opts.format);
|
|
7677
|
+
const operationId = need23(opts.operationId, "operation-id");
|
|
7678
|
+
const apiKey = await resolveApiKey2(opts.apiKey);
|
|
7679
|
+
const spinner = format === "json" ? null : createSpinner("Fetching capability spec...");
|
|
7680
|
+
const result = await deps.apiClient.get(
|
|
7681
|
+
`/data/describe/${encodeURIComponent(operationId)}`,
|
|
7682
|
+
{ type: "api-key", key: apiKey }
|
|
7683
|
+
);
|
|
7684
|
+
spinner?.stop();
|
|
7685
|
+
if (!result.success) throw CliError.fromApi(result, { auth: "api-key" });
|
|
7686
|
+
await render4(result.data, opts.format, (d) => kv(d));
|
|
7687
|
+
});
|
|
7688
|
+
}
|
|
7689
|
+
|
|
7690
|
+
// src/data-aisa/query.ts
|
|
7691
|
+
function registerDataQueryCommand(parent, deps) {
|
|
7692
|
+
const cmd = parent.command("query").description(
|
|
7693
|
+
"Run one capability and return its data. Charged per call. READ-ONLY: it fetches data and nothing else."
|
|
7694
|
+
).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(
|
|
7695
|
+
"--params <json>",
|
|
7696
|
+
"The capability's parameters as a JSON object keyed by the parameter names from describe. Passed through as a whole; unknown keys are dropped."
|
|
7697
|
+
).option(
|
|
7698
|
+
"--idempotency-key <key>",
|
|
7699
|
+
"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"
|
|
7700
|
+
);
|
|
7701
|
+
attachSchemaHelp(cmd, dataQuerySchema);
|
|
7702
|
+
cmd.action(async () => {
|
|
7703
|
+
const opts = cmd.optsWithGlobals();
|
|
7704
|
+
const format = resolveFormat(opts.format);
|
|
7705
|
+
const operationId = need23(opts.operationId, "operation-id");
|
|
7706
|
+
const body = { operation_id: operationId };
|
|
7707
|
+
if (opts.params !== void 0) {
|
|
7708
|
+
body.params = jsonObject(opts.params, "params");
|
|
7709
|
+
}
|
|
7710
|
+
let idempotencyKey;
|
|
7711
|
+
if (opts.idempotencyKey !== void 0) {
|
|
7712
|
+
idempotencyKey = verbatimIdempotencyKey(opts.idempotencyKey, "idempotency-key");
|
|
7713
|
+
}
|
|
7714
|
+
const extraHeaders = idempotencyKey ? { "Idempotency-Key": idempotencyKey } : void 0;
|
|
7715
|
+
const apiKey = await resolveApiKey2(opts.apiKey);
|
|
7716
|
+
const spinner = format === "json" ? null : createSpinner("Fetching data...");
|
|
7717
|
+
const result = await deps.apiClient.post(
|
|
7718
|
+
"/data/query",
|
|
7719
|
+
{ type: "api-key", key: apiKey },
|
|
7720
|
+
body,
|
|
7721
|
+
extraHeaders
|
|
7722
|
+
);
|
|
7723
|
+
spinner?.stop();
|
|
7724
|
+
if (!result.success) throw CliError.fromApi(result, { auth: "api-key" });
|
|
7725
|
+
await render4(result.data, opts.format, (d) => kv(d));
|
|
7726
|
+
});
|
|
7727
|
+
}
|
|
7728
|
+
|
|
7506
7729
|
// src/index.ts
|
|
7507
7730
|
var programRef;
|
|
7508
7731
|
async function main() {
|
|
@@ -7673,6 +7896,13 @@ Key notes:
|
|
|
7673
7896
|
registerRefundDetailCommand(flightCmd, deps);
|
|
7674
7897
|
registerRefundConfirmCommand(flightCmd, deps);
|
|
7675
7898
|
registerFlightSkillCommand(flightCmd);
|
|
7899
|
+
const dataCmd = program.command("data-aisa").description(
|
|
7900
|
+
"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."
|
|
7901
|
+
);
|
|
7902
|
+
registerDataListCategoriesCommand(dataCmd, deps);
|
|
7903
|
+
registerDataSearchCommand(dataCmd, deps);
|
|
7904
|
+
registerDataDescribeCommand(dataCmd, deps);
|
|
7905
|
+
registerDataQueryCommand(dataCmd, deps);
|
|
7676
7906
|
await program.parseAsync(process.argv);
|
|
7677
7907
|
}
|
|
7678
7908
|
function resolveActiveFormat() {
|