@heyamiko/amiko-cli 0.3.8 → 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 +66 -29
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -27463,14 +27463,14 @@ function loadAgentConfig() {
|
|
|
27463
27463
|
const raw = readFileSync2(filePath, "utf-8");
|
|
27464
27464
|
const parsed = JSON.parse(raw);
|
|
27465
27465
|
const config = {};
|
|
27466
|
-
if (parsed.amikoTwinToken)
|
|
27467
|
-
config.twinToken = parsed.amikoTwinToken;
|
|
27468
|
-
if (parsed.amikoTwinId)
|
|
27469
|
-
config.twinId = parsed.amikoTwinId;
|
|
27470
|
-
if (parsed.amikoUserId)
|
|
27471
|
-
config.userId = parsed.amikoUserId;
|
|
27472
|
-
if (parsed.amikoPlatformUrl)
|
|
27473
|
-
config.platformUrl = parsed.amikoPlatformUrl;
|
|
27466
|
+
if (parsed.amikoTwinToken || parsed.AMIKO_TWIN_TOKEN)
|
|
27467
|
+
config.twinToken = parsed.amikoTwinToken || parsed.AMIKO_TWIN_TOKEN;
|
|
27468
|
+
if (parsed.amikoTwinId || parsed.AMIKO_TWIN_ID)
|
|
27469
|
+
config.twinId = parsed.amikoTwinId || parsed.AMIKO_TWIN_ID;
|
|
27470
|
+
if (parsed.amikoUserId || parsed.AMIKO_USER_ID)
|
|
27471
|
+
config.userId = parsed.amikoUserId || parsed.AMIKO_USER_ID;
|
|
27472
|
+
if (parsed.amikoPlatformUrl || parsed.AMIKO_PLATFORM_URL)
|
|
27473
|
+
config.platformUrl = parsed.amikoPlatformUrl || parsed.AMIKO_PLATFORM_URL;
|
|
27474
27474
|
return Object.keys(config).length > 0 ? config : null;
|
|
27475
27475
|
} catch {
|
|
27476
27476
|
return null;
|
|
@@ -66305,17 +66305,41 @@ var CHAIN_NAMES = {
|
|
|
66305
66305
|
534352: "Scroll",
|
|
66306
66306
|
7777777: "Zora"
|
|
66307
66307
|
};
|
|
66308
|
-
var
|
|
66309
|
-
|
|
66310
|
-
|
|
66311
|
-
|
|
66312
|
-
|
|
66313
|
-
|
|
66314
|
-
|
|
66315
|
-
|
|
66316
|
-
|
|
66317
|
-
|
|
66308
|
+
var TOKEN_ADDRESSES = {
|
|
66309
|
+
usdc: {
|
|
66310
|
+
[CHAINS.solana]: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
|
|
66311
|
+
[CHAINS.tempo]: "0x20C000000000000000000000b9537d11c60E8b50",
|
|
66312
|
+
[CHAINS.ethereum]: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
|
|
66313
|
+
[CHAINS.optimism]: "0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85",
|
|
66314
|
+
[CHAINS.arbitrum]: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
|
|
66315
|
+
[CHAINS.base]: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
|
|
66316
|
+
[CHAINS.polygon]: "0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359",
|
|
66317
|
+
[CHAINS.linea]: "0x176211869cA2b568f2A7D4EE941E073a821EE1ff",
|
|
66318
|
+
[CHAINS.zksync]: "0x1d17CBcF0D6D143135aE902365D2E5e2A16538D4"
|
|
66319
|
+
},
|
|
66320
|
+
usdt: {
|
|
66321
|
+
[CHAINS.solana]: "Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB",
|
|
66322
|
+
[CHAINS.ethereum]: "0xdAC17F958D2ee523a2206206994597C13D831ec7",
|
|
66323
|
+
[CHAINS.optimism]: "0x94b008aA00579c1307B0EF2c499aD98a8ce58e58",
|
|
66324
|
+
[CHAINS.arbitrum]: "0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9",
|
|
66325
|
+
[CHAINS.base]: "0xfde4C96c8593536E31F229EA8f37b2ADa2699bb2",
|
|
66326
|
+
[CHAINS.polygon]: "0xc2132D05D31c914a87C6611C10748AEb04B58e8F"
|
|
66327
|
+
}
|
|
66318
66328
|
};
|
|
66329
|
+
var USDC_ADDRESSES = TOKEN_ADDRESSES.usdc;
|
|
66330
|
+
function getTokenAddress(chainId, token) {
|
|
66331
|
+
const lower = token.toLowerCase();
|
|
66332
|
+
const bySymbol = TOKEN_ADDRESSES[lower];
|
|
66333
|
+
if (bySymbol) {
|
|
66334
|
+
const addr = bySymbol[chainId];
|
|
66335
|
+
if (!addr) {
|
|
66336
|
+
const name = CHAIN_NAMES[chainId] || `chain ${chainId}`;
|
|
66337
|
+
throw new Error(`${token.toUpperCase()} not available on ${name}`);
|
|
66338
|
+
}
|
|
66339
|
+
return addr;
|
|
66340
|
+
}
|
|
66341
|
+
return token;
|
|
66342
|
+
}
|
|
66319
66343
|
function qs(params) {
|
|
66320
66344
|
const entries = Object.entries(params).filter(([, v8]) => v8 !== undefined);
|
|
66321
66345
|
return entries.map(([k7, v8]) => `${encodeURIComponent(k7)}=${encodeURIComponent(String(v8))}`).join("&");
|
|
@@ -66418,13 +66442,13 @@ var DEFAULT_ORIGIN = CHAINS.solana;
|
|
|
66418
66442
|
var DEFAULT_DESTINATION = CHAINS.tempo;
|
|
66419
66443
|
function registerBridgeCommand(program2) {
|
|
66420
66444
|
const cmd = program2.command("bridge").description("Bridge USDC across chains via Across Protocol");
|
|
66421
|
-
cmd.command("quote").description("Get a bridge quote
|
|
66445
|
+
cmd.command("quote").description("Get a bridge quote (USDC default, or specify --token)").argument("<amount>", "Amount to bridge (e.g., 10, 5.50)").option("--from <chain>", "Origin chain (default: solana)", "solana").option("--to <chain>", "Destination chain (default: tempo)", "tempo").option("--token <symbol>", "Token to bridge: usdc, usdt, or address (default: usdc)", "usdc").option("--output-token <symbol>", "Output token on destination (default: usdc)", "usdc").option("--recipient <address>", "Recipient address on destination chain").option("--depositor <address>", "Depositor address on origin chain").action(async (amountStr, opts) => {
|
|
66422
66446
|
const spinner = ora("Fetching bridge quote...").start();
|
|
66423
66447
|
try {
|
|
66424
66448
|
const originChainId = resolveChainId(opts.from);
|
|
66425
66449
|
const destChainId = resolveChainId(opts.to);
|
|
66426
|
-
const inputToken =
|
|
66427
|
-
const outputToken =
|
|
66450
|
+
const inputToken = getTokenAddress(originChainId, opts.token);
|
|
66451
|
+
const outputToken = getTokenAddress(destChainId, opts.outputToken);
|
|
66428
66452
|
const amount = parseUsdcAmount(amountStr);
|
|
66429
66453
|
const depositor = opts.depositor || loadConfig().wallet;
|
|
66430
66454
|
if (!depositor) {
|
|
@@ -66486,13 +66510,13 @@ function registerBridgeCommand(program2) {
|
|
|
66486
66510
|
process.exit(1);
|
|
66487
66511
|
}
|
|
66488
66512
|
});
|
|
66489
|
-
cmd.command("send").description("Execute a
|
|
66513
|
+
cmd.command("send").description("Execute a bridge transfer via Across").argument("<amount>", "Amount to bridge (e.g., 10, 5.50)").option("--from <chain>", "Origin chain (default: solana)", "solana").option("--to <chain>", "Destination chain (default: tempo)", "tempo").option("--token <symbol>", "Token to bridge: usdc, usdt, or address (default: usdc)", "usdc").option("--output-token <symbol>", "Output token on destination (default: usdc)", "usdc").option("--recipient <address>", "Recipient address on destination chain").option("--depositor <address>", "Depositor address on origin chain").option("--raw", "Output raw transaction JSON for manual signing").action(async (amountStr, opts) => {
|
|
66490
66514
|
const spinner = ora("Preparing bridge transaction...").start();
|
|
66491
66515
|
try {
|
|
66492
66516
|
const originChainId = resolveChainId(opts.from);
|
|
66493
66517
|
const destChainId = resolveChainId(opts.to);
|
|
66494
|
-
const inputToken =
|
|
66495
|
-
const outputToken =
|
|
66518
|
+
const inputToken = getTokenAddress(originChainId, opts.token);
|
|
66519
|
+
const outputToken = getTokenAddress(destChainId, opts.outputToken);
|
|
66496
66520
|
const amount = parseUsdcAmount(amountStr);
|
|
66497
66521
|
const depositor = opts.depositor || loadConfig().wallet;
|
|
66498
66522
|
if (!depositor) {
|
|
@@ -67225,18 +67249,31 @@ function registerCreditsCommand(program2) {
|
|
|
67225
67249
|
const spinner2 = ora("Fetching credit balance...").start();
|
|
67226
67250
|
try {
|
|
67227
67251
|
let balance = null;
|
|
67228
|
-
|
|
67229
|
-
if (auth.billingBase && billingToken) {
|
|
67252
|
+
if (auth.mode === "agent" && auth.platformUrl && auth.twinId && auth.twinToken) {
|
|
67230
67253
|
try {
|
|
67231
|
-
const res = await fetch(`${auth.
|
|
67232
|
-
headers: { Authorization: `Bearer ${
|
|
67254
|
+
const res = await fetch(`${auth.platformUrl}/api/agents/${auth.twinId}/credits/balance`, {
|
|
67255
|
+
headers: { Authorization: `Bearer ${auth.twinToken}` }
|
|
67233
67256
|
});
|
|
67234
67257
|
if (res.ok) {
|
|
67235
67258
|
const data = await res.json();
|
|
67236
|
-
balance = data.
|
|
67259
|
+
balance = data.balance != null ? Math.round(Number(data.balance)) : null;
|
|
67237
67260
|
}
|
|
67238
67261
|
} catch {}
|
|
67239
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
|
+
}
|
|
67240
67277
|
spinner2.stop();
|
|
67241
67278
|
if (balance !== null) {
|
|
67242
67279
|
console.log(label("Balance", source_default.bold(balance.toLocaleString()) + " credits"));
|