@heyamiko/amiko-cli 0.6.4 → 0.6.5

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 +53 -72
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -71871,6 +71871,25 @@ function tryLoadConfig(filePath) {
71871
71871
  }
71872
71872
  }
71873
71873
  function resolveAuth(cliConfig) {
71874
+ const agentConfig = loadAgentConfig();
71875
+ if (agentConfig?.agentWallets?.length && !cliConfig.agentWallets?.length) {
71876
+ cliConfig.agentWallets = agentConfig.agentWallets;
71877
+ }
71878
+ if (agentConfig?.billingBase && !cliConfig.billingBase) {
71879
+ cliConfig.billingBase = agentConfig.billingBase;
71880
+ }
71881
+ if (agentConfig?.twinToken && !cliConfig.twinToken) {
71882
+ cliConfig.twinToken = agentConfig.twinToken;
71883
+ }
71884
+ if (agentConfig?.twinId && !cliConfig.twinId) {
71885
+ cliConfig.twinId = agentConfig.twinId;
71886
+ }
71887
+ if (agentConfig?.userId && !cliConfig.userId) {
71888
+ cliConfig.userId = agentConfig.userId;
71889
+ }
71890
+ if (agentConfig?.platformKey && !cliConfig.apiKey) {
71891
+ cliConfig.apiKey = agentConfig.platformKey;
71892
+ }
71874
71893
  if (cliConfig.agentWallets?.length) {
71875
71894
  return {
71876
71895
  mode: "connected",
@@ -71916,7 +71935,6 @@ function resolveAuth(cliConfig) {
71916
71935
  platformUrl: process.env.AMIKO_PLATFORM_URL
71917
71936
  };
71918
71937
  }
71919
- const agentConfig = loadAgentConfig();
71920
71938
  if (agentConfig?.twinToken) {
71921
71939
  return {
71922
71940
  mode: "agent",
@@ -72981,25 +72999,6 @@ async function get(path) {
72981
72999
  }
72982
73000
  return res.json();
72983
73001
  }
72984
- async function post(path, body) {
72985
- const res = await fetch(`${mppBase()}${path}`, {
72986
- method: "POST",
72987
- headers: authHeaders(),
72988
- body: body ? JSON.stringify(body) : undefined
72989
- });
72990
- if (res.status === 402) {
72991
- const data = await res.json();
72992
- const err = new Error("Payment required");
72993
- err.status = 402;
72994
- err.data = data;
72995
- throw err;
72996
- }
72997
- if (!res.ok) {
72998
- const text = await res.text().catch(() => "");
72999
- throw new Error(`${res.status} ${res.statusText}: ${text}`);
73000
- }
73001
- return res.json();
73002
- }
73003
73002
  async function creatorPost(path, body) {
73004
73003
  const res = await fetch(`${billingBase()}${path}`, {
73005
73004
  method: "POST",
@@ -73531,7 +73530,7 @@ function sanitizeTempoWhoamiOutput(output) {
73531
73530
  function buildConnectedKeyTopupInput(config, amount) {
73532
73531
  const token = getPrivyToken(config);
73533
73532
  if (!token) {
73534
- throw new Error('Not signed in. Run "amiko login" first.');
73533
+ throw new Error("Not signed in. Check .amiko.json credentials.");
73535
73534
  }
73536
73535
  if (!config.connectedKeyId) {
73537
73536
  throw new Error("No connected API key is attached to this account. Sign in again after creating a server-side key.");
@@ -73557,32 +73556,6 @@ function openUrl(url) {
73557
73556
  }
73558
73557
  function registerWalletCommand(program2) {
73559
73558
  const cmd = program2.command("wallet").description("Manage MPP wallets");
73560
- cmd.command("create").description("Create a new MPP wallet on Tempo").option("--save", "Save the wallet address to CLI config").action(async (opts) => {
73561
- const spinner = ora("Creating wallet...").start();
73562
- try {
73563
- const data = await post("/v1/wallet/create");
73564
- spinner.stop();
73565
- console.log(success("Wallet created"));
73566
- console.log("");
73567
- console.log(label("Address", source_default.cyan(data.address)));
73568
- console.log(label("Wallet ID", data.walletId));
73569
- if (data.chain)
73570
- console.log(label("Chain", data.chain));
73571
- console.log("");
73572
- console.log(dim("Fund it with USDC.e on Tempo to start using paid services."));
73573
- if (opts.save) {
73574
- saveConfig({ wallet: data.address });
73575
- console.log(success("Saved to CLI config"));
73576
- } else {
73577
- console.log(dim(`
73578
- Tip: amiko config set wallet ${data.address}`));
73579
- }
73580
- } catch (err) {
73581
- spinner.stop();
73582
- console.error(error(err instanceof Error ? err.message : "Failed to create wallet"));
73583
- process.exit(1);
73584
- }
73585
- });
73586
73559
  cmd.command("balance").description("Check wallet balance").argument("[address]", "Wallet address (uses configured wallet if omitted)").option("-w, --watch", "Poll balance every 5 seconds").option("--interval <seconds>", "Poll interval in seconds (with --watch)", "5").action(async (address, opts) => {
73587
73560
  const addr = address || loadConfig().wallet;
73588
73561
  if (!addr) {
@@ -73721,12 +73694,12 @@ Tip: add --open to auto-launch in browser.`));
73721
73694
  }
73722
73695
  const agentWallet = config.agentWallets?.find((w5) => w5.address === fromAddr);
73723
73696
  if (!agentWallet?.signerSecret) {
73724
- console.error(error('No signer secret for this wallet. Re-run "amiko connect" to fetch it.'));
73697
+ console.error(error("No signer secret for this wallet. Re-init from the Amiko dashboard to provision wallet keys."));
73725
73698
  process.exit(1);
73726
73699
  }
73727
73700
  const apiKey = process.env.CROSSMINT_API_KEY || config.apiKey;
73728
73701
  if (!apiKey) {
73729
- console.error(error('No API key. Set CROSSMINT_API_KEY or run "amiko connect".'));
73702
+ console.error(error("No API key. Check platformKey in .amiko.json or set CROSSMINT_API_KEY."));
73730
73703
  process.exit(1);
73731
73704
  }
73732
73705
  const spinner = ora(`Sending ${amount} ${token} to ${truncAddr(to)}...`).start();
@@ -73782,7 +73755,7 @@ function requireCreatorToken() {
73782
73755
  const token = getPrivyToken(config);
73783
73756
  if (!token) {
73784
73757
  console.error(error("Not signed in."));
73785
- console.log(dim("Run: amiko login"));
73758
+ console.log(dim("Check .amiko.json credentials."));
73786
73759
  process.exit(1);
73787
73760
  }
73788
73761
  return token;
@@ -75256,7 +75229,7 @@ function registerCreditsCommand(program2) {
75256
75229
  const auth = resolveAuth(loadConfig());
75257
75230
  if (auth.mode === "none") {
75258
75231
  spinner.stop();
75259
- console.error(error("Not connected"));
75232
+ console.error(error("Not authenticated. Check .amiko.json credentials."));
75260
75233
  process.exit(1);
75261
75234
  }
75262
75235
  spinner.stop();
@@ -75365,19 +75338,19 @@ function registerCreditsCommand(program2) {
75365
75338
  const auth = resolveAuth(loadConfig());
75366
75339
  if (auth.mode === "none") {
75367
75340
  spinner.stop();
75368
- console.error(error("Not connected"));
75341
+ console.error(error("Not authenticated. Check .amiko.json credentials."));
75369
75342
  process.exit(1);
75370
75343
  }
75371
75344
  const billingBase2 = auth.billingBase || "https://billing.heyamiko.com";
75372
75345
  if (!billingBase2) {
75373
75346
  spinner.stop();
75374
- console.error(error("Billing service not configured. Run: amiko connect"));
75347
+ console.error(error("Billing service not configured. Check billingBase in .amiko.json."));
75375
75348
  process.exit(1);
75376
75349
  }
75377
75350
  const authToken = auth.platformKey || auth.twinToken || auth.privyToken;
75378
75351
  if (!authToken) {
75379
75352
  spinner.stop();
75380
- console.error(error("No API key or auth token. Run: amiko connect"));
75353
+ console.error(error("No API key or auth token. Check platformKey in .amiko.json."));
75381
75354
  process.exit(1);
75382
75355
  }
75383
75356
  const authHeaders2 = {
@@ -75661,7 +75634,7 @@ function registerSwapCommand(program2) {
75661
75634
  const config2 = loadConfig();
75662
75635
  const auth = resolveAuth(config2);
75663
75636
  if (auth.mode === "none") {
75664
- console.error(error("Not connected. Set up .amiko.json or run: amiko connect"));
75637
+ console.error(error("Not authenticated. Check .amiko.json credentials."));
75665
75638
  process.exit(1);
75666
75639
  }
75667
75640
  const allWallets = auth.agentWallets || config2.agentWallets || [];
@@ -75833,7 +75806,7 @@ function registerUpdateCommand(program2) {
75833
75806
  // src/commands/search.ts
75834
75807
  var TREASURY = "FPiZAf3jEnNfCwfvbv46jdPfHbmSepD4Q6iHiLJDQXvb";
75835
75808
  function registerSearchCommand(program2) {
75836
- program2.command("search <query>").description("X Search — pays 1 AMIKO token per search").option("--raw", "Output raw JSON").action(async (query, opts) => {
75809
+ program2.command("search <query>").description("X Search — pays 1 AMIKO token per search").option("--raw", "Output raw JSON").option("--token <token>", "Payment token (AMIKO, USDC, SOL)", "AMIKO").action(async (query, opts) => {
75837
75810
  const spinner = ora("X Search...").start();
75838
75811
  try {
75839
75812
  const config2 = loadConfig();
@@ -75843,18 +75816,25 @@ function registerSearchCommand(program2) {
75843
75816
  const billingToken = auth.platformKey || auth.twinToken || auth.privyToken;
75844
75817
  if (auth.mode === "none" || !billingToken) {
75845
75818
  spinner.stop();
75846
- console.error(error("Not connected."));
75819
+ console.error(error("Not authenticated. Check .amiko.json has valid credentials."));
75847
75820
  process.exit(1);
75848
75821
  }
75849
75822
  const allWallets = auth.agentWallets || config2.agentWallets || [];
75850
75823
  const solanaWallet = allWallets.find((w5) => w5.chain === "solana")?.address;
75851
- if (!solanaWallet) {
75824
+ const evmWallet = allWallets.find((w5) => w5.chain === "base" || w5.chain === "evm" || w5.chain === "tempo")?.address;
75825
+ if (!solanaWallet && !evmWallet) {
75852
75826
  spinner.stop();
75853
- console.error(error("No Solana wallet found for AMIKO payment."));
75827
+ console.error(error("No wallet found. Your twin needs a Solana or EVM wallet."));
75828
+ console.log(dim(" Re-init your twin from the Amiko dashboard to provision wallets."));
75854
75829
  process.exit(1);
75855
75830
  }
75856
- spinner.text = "Paying 1 AMIKO...";
75857
- const transferRes = await fetch(`${billingBase2}/api/crossmint/wallets/${encodeURIComponent(solanaWallet)}/transfer`, {
75831
+ const payWithSolana = !!solanaWallet;
75832
+ const wallet = payWithSolana ? solanaWallet : evmWallet;
75833
+ const chain = payWithSolana ? "solana" : "base";
75834
+ const token = payWithSolana ? opts.token || "AMIKO" : "USDC";
75835
+ const amount2 = token === "AMIKO" ? "1" : "0.01";
75836
+ spinner.text = `Paying ${amount2} ${token} (${chain})...`;
75837
+ const transferRes = await fetch(`${billingBase2}/api/crossmint/wallets/${encodeURIComponent(wallet)}/transfer`, {
75858
75838
  method: "POST",
75859
75839
  headers: {
75860
75840
  "Content-Type": "application/json",
@@ -75862,15 +75842,15 @@ function registerSearchCommand(program2) {
75862
75842
  },
75863
75843
  body: JSON.stringify({
75864
75844
  to: TREASURY,
75865
- amount: "1",
75866
- token: "AMIKO",
75867
- chain: "solana"
75845
+ amount: amount2,
75846
+ token,
75847
+ chain
75868
75848
  })
75869
75849
  });
75870
75850
  if (!transferRes.ok) {
75871
75851
  spinner.stop();
75872
75852
  const err = await transferRes.json().catch(() => ({ error: "Transfer failed" }));
75873
- console.error(error(err.error || `AMIKO payment failed: ${transferRes.status}`));
75853
+ console.error(error(err.error || `${token} payment failed: ${transferRes.status}`));
75874
75854
  process.exit(1);
75875
75855
  }
75876
75856
  const transferData = await transferRes.json();
@@ -75880,21 +75860,22 @@ function registerSearchCommand(program2) {
75880
75860
  console.error(error("Payment sent but no tx hash returned."));
75881
75861
  process.exit(1);
75882
75862
  }
75883
- spinner.text = `Paid 1 AMIKO — searching X...`;
75863
+ spinner.text = `Paid ${amount2} ${token} — searching X...`;
75884
75864
  const params = new URLSearchParams({ q: query });
75885
75865
  const res = await fetch(`${mppBase2}/v1/x/search?${params}`, {
75886
75866
  headers: {
75887
75867
  "Content-Type": "application/json",
75888
75868
  "X-Payment-Tx": txHash,
75889
- "X-Payment-Amount": "1",
75890
- "X-Payment-Token": "AMIKO"
75869
+ "X-Payment-Amount": amount2,
75870
+ "X-Payment-Token": token
75891
75871
  }
75892
75872
  });
75893
75873
  spinner.stop();
75894
75874
  if (!res.ok) {
75895
75875
  const text = await res.text().catch(() => "");
75896
75876
  console.error(error(`Search failed: ${res.status} ${text.slice(0, 200)}`));
75897
- console.log(dim(`Payment tx: https://solscan.io/tx/${txHash}`));
75877
+ const explorer = chain === "solana" ? `https://solscan.io/tx/${txHash}` : `https://explorer.tempo.xyz/tx/${txHash}`;
75878
+ console.log(dim(`Payment tx: ${explorer}`));
75898
75879
  process.exit(1);
75899
75880
  }
75900
75881
  const data = await res.json();
@@ -75920,7 +75901,7 @@ function registerSearchCommand(program2) {
75920
75901
  console.log("");
75921
75902
  }
75922
75903
  }
75923
- console.log(success("Paid 1 AMIKO") + dim(` tx: ${txHash.slice(0, 16)}...`));
75904
+ console.log(success(`Paid ${amount2} ${token}`) + dim(` tx: ${txHash.slice(0, 16)}...`));
75924
75905
  } catch (err) {
75925
75906
  spinner.stop();
75926
75907
  console.error(error(err instanceof Error ? err.message : "Search failed"));
@@ -75942,7 +75923,7 @@ function registerImageCommand(program2) {
75942
75923
  const billingToken = auth.platformKey || auth.twinToken || auth.privyToken;
75943
75924
  if (!billingToken) {
75944
75925
  spinner.stop();
75945
- console.error(error("Not connected."));
75926
+ console.error(error("Not authenticated. Check .amiko.json credentials."));
75946
75927
  process.exit(1);
75947
75928
  }
75948
75929
  const allWallets = auth.agentWallets || config2.agentWallets || [];
@@ -76062,7 +76043,7 @@ function registerAmazonCommand(program2) {
76062
76043
  const billingToken = auth.platformKey || auth.twinToken || auth.privyToken;
76063
76044
  if (!billingToken) {
76064
76045
  spinner.stop();
76065
- console.error(error("Not connected."));
76046
+ console.error(error("Not authenticated. Check .amiko.json credentials."));
76066
76047
  process.exit(1);
76067
76048
  }
76068
76049
  const allWallets = auth.agentWallets || config2.agentWallets || [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@heyamiko/amiko-cli",
3
- "version": "0.6.4",
3
+ "version": "0.6.5",
4
4
  "description": "Amiko CLI — swap tokens, manage credits, bridge cross-chain, and call marketplace agents",
5
5
  "type": "module",
6
6
  "bin": {