@heyamiko/amiko-cli 0.3.1 → 0.3.2

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 +32 -8
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -26703,18 +26703,36 @@ function registerCreditsCommand(program2) {
26703
26703
  {
26704
26704
  const spinner2 = ora("Fetching credit balance...").start();
26705
26705
  try {
26706
- let creditsData = null;
26706
+ let balance = null;
26707
26707
  const billingToken = auth.platformKey || auth.privyToken;
26708
26708
  if (auth.billingBase && billingToken) {
26709
- const res = await fetch(`${auth.billingBase}/api/credits`, {
26710
- headers: { Authorization: `Bearer ${billingToken}` }
26711
- });
26712
- if (res.ok)
26713
- creditsData = await res.json();
26709
+ try {
26710
+ const orRes = await fetch(`${auth.billingBase}/api/usage/openrouter`, {
26711
+ headers: { Authorization: `Bearer ${billingToken}` }
26712
+ });
26713
+ if (orRes.ok) {
26714
+ const orData = await orRes.json();
26715
+ const remaining = Number(orData.totalLimitRemaining);
26716
+ if (Number.isFinite(remaining)) {
26717
+ balance = remaining;
26718
+ }
26719
+ }
26720
+ } catch {}
26721
+ if (balance === null) {
26722
+ try {
26723
+ const res = await fetch(`${auth.billingBase}/api/credits`, {
26724
+ headers: { Authorization: `Bearer ${billingToken}` }
26725
+ });
26726
+ if (res.ok) {
26727
+ const raw = await res.json();
26728
+ balance = Number(raw.credits?.balance || 0);
26729
+ }
26730
+ } catch {}
26731
+ }
26714
26732
  }
26715
26733
  spinner2.stop();
26716
- if (creditsData) {
26717
- console.log(label("Balance", source_default.bold(Number(creditsData.balance || 0).toLocaleString())));
26734
+ if (balance !== null) {
26735
+ console.log(label("Balance", source_default.bold(balance.toLocaleString()) + " credits"));
26718
26736
  console.log("");
26719
26737
  } else {
26720
26738
  console.log(dim(" Could not fetch credit balance"));
@@ -26870,6 +26888,10 @@ function registerCreditsCommand(program2) {
26870
26888
  process.exit(1);
26871
26889
  }
26872
26890
  }
26891
+ if (["base", "ethereum", "tempo"].includes(walletChain)) {
26892
+ console.error(error("EVM topup not supported yet. Use a Solana wallet with --token AMIKO, USDC, USDT, or SOL."));
26893
+ process.exit(1);
26894
+ }
26873
26895
  const TREASURY = "FPiZAf3jEnNfCwfvbv46jdPfHbmSepD4Q6iHiLJDQXvb";
26874
26896
  const spinner3 = ora("Transferring tokens to treasury...").start();
26875
26897
  const transferRes = await fetch(`${auth.billingBase}/api/crossmint/wallets/${encodeURIComponent(walletAddr)}/transfer`, {
@@ -26886,6 +26908,8 @@ function registerCreditsCommand(program2) {
26886
26908
  spinner3.stop();
26887
26909
  const err = await transferRes.json().catch(() => ({ error: "Transfer failed" }));
26888
26910
  console.error(error(err.error || `Transfer failed: ${transferRes.status}`));
26911
+ if (err.details)
26912
+ console.error(dim(typeof err.details === "string" ? err.details : JSON.stringify(err.details)));
26889
26913
  process.exit(1);
26890
26914
  }
26891
26915
  const transferData = await transferRes.json();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@heyamiko/amiko-cli",
3
- "version": "0.3.1",
3
+ "version": "0.3.2",
4
4
  "description": "Amiko CLI — manage agents, wallets, credits, and marketplace on the MPP payment rail",
5
5
  "type": "module",
6
6
  "bin": {