@heyamiko/amiko-cli 0.5.15 → 0.5.17

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.
Files changed (2) hide show
  1. package/dist/index.js +22 -19
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -75832,29 +75832,35 @@ function registerUpdateCommand(program2) {
75832
75832
 
75833
75833
  // src/commands/search.ts
75834
75834
  function registerSearchCommand(program2) {
75835
- program2.command("search <query>").description("Search X/Twitter via MPP (paid with credits or AMIKO)").option("--limit <n>", "Number of results", "10").option("--raw", "Output raw JSON").action(async (query, opts) => {
75835
+ program2.command("search <query>").description("Search X/Twitter — pays with AMIKO credits").option("--raw", "Output raw JSON").action(async (query, opts) => {
75836
75836
  const spinner = ora("Searching X...").start();
75837
75837
  try {
75838
75838
  const config2 = loadConfig();
75839
75839
  const auth = resolveAuth(config2);
75840
75840
  const mppBase2 = (config2.apiBase || "https://mpp.amikomarkets.com").replace(/\/$/, "");
75841
- const headers = { "Content-Type": "application/json" };
75841
+ if (auth.mode === "none") {
75842
+ spinner.stop();
75843
+ console.error(error("Not connected."));
75844
+ process.exit(1);
75845
+ }
75842
75846
  const apiKey = config2.apiKey || auth.platformKey;
75843
- if (apiKey) {
75844
- headers["X-Amiko-Key"] = apiKey;
75847
+ const twinToken = auth.twinToken;
75848
+ if (!apiKey && !twinToken) {
75849
+ spinner.stop();
75850
+ console.error(error("No API key or twin token."));
75851
+ process.exit(1);
75845
75852
  }
75846
75853
  const params = new URLSearchParams({ q: query });
75847
- let res = await fetch(`${mppBase2}/v1/x/search?${params}`, { headers });
75848
- if (res.status === 402 && auth.twinToken && !apiKey) {
75849
- res = await fetch(`${mppBase2}/v1/x/search?${params}`, {
75850
- headers: { ...headers, Authorization: `Bearer ${auth.twinToken}` }
75851
- });
75854
+ const headers = { "Content-Type": "application/json" };
75855
+ if (apiKey) {
75856
+ headers["X-Amiko-Key"] = apiKey;
75857
+ } else if (twinToken) {
75858
+ headers["Authorization"] = `Bearer ${twinToken}`;
75852
75859
  }
75860
+ const res = await fetch(`${mppBase2}/v1/x/search?${params}`, { headers });
75853
75861
  spinner.stop();
75854
75862
  if (res.status === 402) {
75855
- console.error(error("Payment required — no credits or API key."));
75856
- console.log(dim("Set your API key: amiko config set apiKey amk_<key>"));
75857
- console.log(dim("Or top up credits: amiko credits topup 10000 --token AMIKO --yes"));
75863
+ console.error(error("Insufficient credits. Top up: amiko credits topup 10000 --token AMIKO --yes"));
75858
75864
  process.exit(1);
75859
75865
  }
75860
75866
  if (!res.ok) {
@@ -75867,7 +75873,6 @@ function registerSearchCommand(program2) {
75867
75873
  console.log(JSON.stringify(data, null, 2));
75868
75874
  return;
75869
75875
  }
75870
- const paymentMethod = res.headers.get("x-payment-method");
75871
75876
  const paymentBalance = res.headers.get("x-payment-balance");
75872
75877
  console.log(heading(`X Search: "${query}"
75873
75878
  `));
@@ -75887,12 +75892,10 @@ function registerSearchCommand(program2) {
75887
75892
  console.log("");
75888
75893
  }
75889
75894
  }
75890
- if (paymentMethod) {
75891
- let footer = dim(`Paid via ${paymentMethod}`);
75892
- if (paymentBalance)
75893
- footer += dim(` (balance: $${paymentBalance})`);
75894
- console.log(footer);
75895
- }
75895
+ let footer = success("Paid with AMIKO credits");
75896
+ if (paymentBalance)
75897
+ footer += dim(` (balance: $${paymentBalance})`);
75898
+ console.log(footer);
75896
75899
  } catch (err) {
75897
75900
  spinner.stop();
75898
75901
  console.error(error(err instanceof Error ? err.message : "Search failed"));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@heyamiko/amiko-cli",
3
- "version": "0.5.15",
3
+ "version": "0.5.17",
4
4
  "description": "Amiko CLI — swap tokens, manage credits, bridge cross-chain, and call marketplace agents",
5
5
  "type": "module",
6
6
  "bin": {