@heyamiko/amiko-cli 0.5.16 → 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 +18 -76
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -75831,45 +75831,8 @@ function registerUpdateCommand(program2) {
75831
75831
  }
75832
75832
 
75833
75833
  // src/commands/search.ts
75834
- var AMIKO_MINT = "AY1Ww6MxwC3cCiyrandHqLrp4FXvzgcwQTZpJ2FEpump";
75835
- var TREASURY = "FPiZAf3jEnNfCwfvbv46jdPfHbmSepD4Q6iHiLJDQXvb";
75836
- async function payWithAmiko(auth, amountUsd) {
75837
- const billingBase2 = auth.billingBase || "https://billing.heyamiko.com";
75838
- const billingToken = auth.platformKey || auth.twinToken || auth.privyToken;
75839
- if (!billingToken)
75840
- return null;
75841
- const allWallets = auth.agentWallets || [];
75842
- const solanaWallet = allWallets.find((w5) => w5.chain === "solana")?.address;
75843
- if (!solanaWallet)
75844
- return null;
75845
- const jupRes = await fetch(`https://lite-api.jup.ag/swap/v1/quote?inputMint=${AMIKO_MINT}&outputMint=EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v&amount=${Math.pow(10, 6)}&slippageBps=100`);
75846
- if (!jupRes.ok)
75847
- return null;
75848
- const jupData = await jupRes.json();
75849
- const pricePerToken = parseFloat(jupData.outAmount) / 1e6;
75850
- if (!pricePerToken || pricePerToken <= 0)
75851
- return null;
75852
- const tokenAmount = (amountUsd / pricePerToken).toFixed(6);
75853
- const transferRes = await fetch(`${billingBase2}/api/crossmint/wallets/${encodeURIComponent(solanaWallet)}/transfer`, {
75854
- method: "POST",
75855
- headers: {
75856
- "Content-Type": "application/json",
75857
- Authorization: `Bearer ${billingToken}`
75858
- },
75859
- body: JSON.stringify({
75860
- to: TREASURY,
75861
- amount: tokenAmount,
75862
- token: "AMIKO",
75863
- chain: "solana"
75864
- })
75865
- });
75866
- if (!transferRes.ok)
75867
- return null;
75868
- const transferData = await transferRes.json();
75869
- return transferData.txHash || null;
75870
- }
75871
75834
  function registerSearchCommand(program2) {
75872
- program2.command("search <query>").description("Search X/Twitter via MPP (pays with AMIKO tokens)").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) => {
75873
75836
  const spinner = ora("Searching X...").start();
75874
75837
  try {
75875
75838
  const config2 = loadConfig();
@@ -75877,41 +75840,27 @@ function registerSearchCommand(program2) {
75877
75840
  const mppBase2 = (config2.apiBase || "https://mpp.amikomarkets.com").replace(/\/$/, "");
75878
75841
  if (auth.mode === "none") {
75879
75842
  spinner.stop();
75880
- console.error(error("Not connected. Set up .amiko.json or run: amiko connect"));
75843
+ console.error(error("Not connected."));
75881
75844
  process.exit(1);
75882
75845
  }
75883
- const headers = { "Content-Type": "application/json" };
75884
75846
  const apiKey = config2.apiKey || auth.platformKey;
75885
- if (apiKey) {
75886
- 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);
75887
75852
  }
75888
75853
  const params = new URLSearchParams({ q: query });
75889
- let res = await fetch(`${mppBase2}/v1/x/search?${params}`, { headers });
75890
- if (res.status === 402) {
75891
- spinner.text = "Paying with AMIKO tokens...";
75892
- const challenge2 = await res.json().catch(() => null);
75893
- const amountUsd = 0.01;
75894
- const txHash = await payWithAmiko(auth, amountUsd);
75895
- if (txHash) {
75896
- spinner.text = `Paid (tx: ${txHash.slice(0, 12)}...) — retrying search...`;
75897
- res = await fetch(`${mppBase2}/v1/x/search?${params}`, {
75898
- headers: {
75899
- ...headers,
75900
- "X-Payment-Tx": txHash,
75901
- ...apiKey ? { "X-Amiko-Key": apiKey } : {}
75902
- }
75903
- });
75904
- if (res.status === 402) {
75905
- await new Promise((r19) => setTimeout(r19, 3000));
75906
- res = await fetch(`${mppBase2}/v1/x/search?${params}`, { headers });
75907
- }
75908
- }
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}`;
75909
75859
  }
75860
+ const res = await fetch(`${mppBase2}/v1/x/search?${params}`, { headers });
75910
75861
  spinner.stop();
75911
75862
  if (res.status === 402) {
75912
- console.error(error("Payment failed — insufficient AMIKO balance or no wallet."));
75913
- console.log(dim("Check balance: amiko credits balance"));
75914
- console.log(dim("Top up: amiko credits topup 10000 --token AMIKO --yes"));
75863
+ console.error(error("Insufficient credits. Top up: amiko credits topup 10000 --token AMIKO --yes"));
75915
75864
  process.exit(1);
75916
75865
  }
75917
75866
  if (!res.ok) {
@@ -75924,9 +75873,7 @@ function registerSearchCommand(program2) {
75924
75873
  console.log(JSON.stringify(data, null, 2));
75925
75874
  return;
75926
75875
  }
75927
- const paymentMethod = res.headers.get("x-payment-method");
75928
75876
  const paymentBalance = res.headers.get("x-payment-balance");
75929
- const paymentTx = res.headers.get("x-payment-tx");
75930
75877
  console.log(heading(`X Search: "${query}"
75931
75878
  `));
75932
75879
  const tweets = data.data || [];
@@ -75945,15 +75892,10 @@ function registerSearchCommand(program2) {
75945
75892
  console.log("");
75946
75893
  }
75947
75894
  }
75948
- if (paymentMethod) {
75949
- let footer = success("Paid");
75950
- footer += dim(` via ${paymentMethod}`);
75951
- if (paymentBalance)
75952
- footer += dim(` (balance: $${paymentBalance})`);
75953
- console.log(footer);
75954
- }
75955
- if (paymentTx)
75956
- console.log(dim(`tx: ${paymentTx}`));
75895
+ let footer = success("Paid with AMIKO credits");
75896
+ if (paymentBalance)
75897
+ footer += dim(` (balance: $${paymentBalance})`);
75898
+ console.log(footer);
75957
75899
  } catch (err) {
75958
75900
  spinner.stop();
75959
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.16",
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": {