@heyamiko/amiko-cli 0.4.0 → 0.4.1
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.
- package/dist/index.js +18 -5
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -67249,18 +67249,31 @@ function registerCreditsCommand(program2) {
|
|
|
67249
67249
|
const spinner2 = ora("Fetching credit balance...").start();
|
|
67250
67250
|
try {
|
|
67251
67251
|
let balance = null;
|
|
67252
|
-
|
|
67253
|
-
if (auth.billingBase && billingToken) {
|
|
67252
|
+
if (auth.mode === "agent" && auth.platformUrl && auth.twinId && auth.twinToken) {
|
|
67254
67253
|
try {
|
|
67255
|
-
const res = await fetch(`${auth.
|
|
67256
|
-
headers: { Authorization: `Bearer ${
|
|
67254
|
+
const res = await fetch(`${auth.platformUrl}/api/agents/${auth.twinId}/credits/balance`, {
|
|
67255
|
+
headers: { Authorization: `Bearer ${auth.twinToken}` }
|
|
67257
67256
|
});
|
|
67258
67257
|
if (res.ok) {
|
|
67259
67258
|
const data = await res.json();
|
|
67260
|
-
balance = data.
|
|
67259
|
+
balance = data.balance != null ? Math.round(Number(data.balance)) : null;
|
|
67261
67260
|
}
|
|
67262
67261
|
} catch {}
|
|
67263
67262
|
}
|
|
67263
|
+
if (balance === null) {
|
|
67264
|
+
const billingToken = auth.platformKey || auth.privyToken;
|
|
67265
|
+
if (auth.billingBase && billingToken) {
|
|
67266
|
+
try {
|
|
67267
|
+
const res = await fetch(`${auth.billingBase}/api/credits`, {
|
|
67268
|
+
headers: { Authorization: `Bearer ${billingToken}` }
|
|
67269
|
+
});
|
|
67270
|
+
if (res.ok) {
|
|
67271
|
+
const data = await res.json();
|
|
67272
|
+
balance = data.displayBalance ?? Math.round(Number(data.credits?.balance || 0));
|
|
67273
|
+
}
|
|
67274
|
+
} catch {}
|
|
67275
|
+
}
|
|
67276
|
+
}
|
|
67264
67277
|
spinner2.stop();
|
|
67265
67278
|
if (balance !== null) {
|
|
67266
67279
|
console.log(label("Balance", source_default.bold(balance.toLocaleString()) + " credits"));
|