@heyamiko/amiko-cli 0.5.17 → 0.5.18

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 +46 -21
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -75831,41 +75831,70 @@ function registerUpdateCommand(program2) {
75831
75831
  }
75832
75832
 
75833
75833
  // src/commands/search.ts
75834
+ var TREASURY = "FPiZAf3jEnNfCwfvbv46jdPfHbmSepD4Q6iHiLJDQXvb";
75834
75835
  function registerSearchCommand(program2) {
75835
- program2.command("search <query>").description("Search X/Twitter — pays with AMIKO credits").option("--raw", "Output raw JSON").action(async (query, opts) => {
75836
+ program2.command("search <query>").description("Search X/Twitter — pays 1 AMIKO token per search").option("--raw", "Output raw JSON").action(async (query, opts) => {
75836
75837
  const spinner = ora("Searching X...").start();
75837
75838
  try {
75838
75839
  const config2 = loadConfig();
75839
75840
  const auth = resolveAuth(config2);
75840
75841
  const mppBase2 = (config2.apiBase || "https://mpp.amikomarkets.com").replace(/\/$/, "");
75841
- if (auth.mode === "none") {
75842
+ const billingBase2 = auth.billingBase || "https://billing.heyamiko.com";
75843
+ const billingToken = auth.platformKey || auth.twinToken || auth.privyToken;
75844
+ if (auth.mode === "none" || !billingToken) {
75842
75845
  spinner.stop();
75843
75846
  console.error(error("Not connected."));
75844
75847
  process.exit(1);
75845
75848
  }
75846
- const apiKey = config2.apiKey || auth.platformKey;
75847
- const twinToken = auth.twinToken;
75848
- if (!apiKey && !twinToken) {
75849
+ const allWallets = auth.agentWallets || config2.agentWallets || [];
75850
+ const solanaWallet = allWallets.find((w5) => w5.chain === "solana")?.address;
75851
+ if (!solanaWallet) {
75849
75852
  spinner.stop();
75850
- console.error(error("No API key or twin token."));
75853
+ console.error(error("No Solana wallet found for AMIKO payment."));
75851
75854
  process.exit(1);
75852
75855
  }
75853
- const params = new URLSearchParams({ q: query });
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}`;
75856
+ spinner.text = "Paying 1 AMIKO...";
75857
+ const transferRes = await fetch(`${billingBase2}/api/crossmint/wallets/${encodeURIComponent(solanaWallet)}/transfer`, {
75858
+ method: "POST",
75859
+ headers: {
75860
+ "Content-Type": "application/json",
75861
+ Authorization: `Bearer ${billingToken}`
75862
+ },
75863
+ body: JSON.stringify({
75864
+ to: TREASURY,
75865
+ amount: "1",
75866
+ token: "AMIKO",
75867
+ chain: "solana"
75868
+ })
75869
+ });
75870
+ if (!transferRes.ok) {
75871
+ spinner.stop();
75872
+ const err = await transferRes.json().catch(() => ({ error: "Transfer failed" }));
75873
+ console.error(error(err.error || `AMIKO payment failed: ${transferRes.status}`));
75874
+ process.exit(1);
75859
75875
  }
75860
- const res = await fetch(`${mppBase2}/v1/x/search?${params}`, { headers });
75861
- spinner.stop();
75862
- if (res.status === 402) {
75863
- console.error(error("Insufficient credits. Top up: amiko credits topup 10000 --token AMIKO --yes"));
75876
+ const transferData = await transferRes.json();
75877
+ const txHash = transferData.txHash;
75878
+ if (!txHash) {
75879
+ spinner.stop();
75880
+ console.error(error("Payment sent but no tx hash returned."));
75864
75881
  process.exit(1);
75865
75882
  }
75883
+ spinner.text = `Paid 1 AMIKO — searching X...`;
75884
+ const params = new URLSearchParams({ q: query });
75885
+ const res = await fetch(`${mppBase2}/v1/x/search?${params}`, {
75886
+ headers: {
75887
+ "Content-Type": "application/json",
75888
+ "X-Payment-Tx": txHash,
75889
+ "X-Payment-Amount": "1",
75890
+ "X-Payment-Token": "AMIKO"
75891
+ }
75892
+ });
75893
+ spinner.stop();
75866
75894
  if (!res.ok) {
75867
75895
  const text = await res.text().catch(() => "");
75868
75896
  console.error(error(`Search failed: ${res.status} ${text.slice(0, 200)}`));
75897
+ console.log(dim(`Payment tx: https://solscan.io/tx/${txHash}`));
75869
75898
  process.exit(1);
75870
75899
  }
75871
75900
  const data = await res.json();
@@ -75873,7 +75902,6 @@ function registerSearchCommand(program2) {
75873
75902
  console.log(JSON.stringify(data, null, 2));
75874
75903
  return;
75875
75904
  }
75876
- const paymentBalance = res.headers.get("x-payment-balance");
75877
75905
  console.log(heading(`X Search: "${query}"
75878
75906
  `));
75879
75907
  const tweets = data.data || [];
@@ -75892,10 +75920,7 @@ function registerSearchCommand(program2) {
75892
75920
  console.log("");
75893
75921
  }
75894
75922
  }
75895
- let footer = success("Paid with AMIKO credits");
75896
- if (paymentBalance)
75897
- footer += dim(` (balance: $${paymentBalance})`);
75898
- console.log(footer);
75923
+ console.log(success("Paid 1 AMIKO") + dim(` tx: ${txHash.slice(0, 16)}...`));
75899
75924
  } catch (err) {
75900
75925
  spinner.stop();
75901
75926
  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.17",
3
+ "version": "0.5.18",
4
4
  "description": "Amiko CLI — swap tokens, manage credits, bridge cross-chain, and call marketplace agents",
5
5
  "type": "module",
6
6
  "bin": {