@heyamiko/amiko-cli 0.6.3 → 0.6.4

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 +150 -2
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -76030,8 +76030,155 @@ function registerImageCommand(program2) {
76030
76030
  });
76031
76031
  }
76032
76032
 
76033
- // src/commands/services.ts
76033
+ // src/commands/amazon.ts
76034
76034
  var TREASURY3 = "FPiZAf3jEnNfCwfvbv46jdPfHbmSepD4Q6iHiLJDQXvb";
76035
+ async function payAmiko(billingBase2, billingToken, solanaWallet, amount2) {
76036
+ const res = await fetch(`${billingBase2}/api/crossmint/wallets/${encodeURIComponent(solanaWallet)}/transfer`, {
76037
+ method: "POST",
76038
+ headers: {
76039
+ "Content-Type": "application/json",
76040
+ Authorization: `Bearer ${billingToken}`
76041
+ },
76042
+ body: JSON.stringify({ to: TREASURY3, amount: amount2, token: "AMIKO", chain: "solana" })
76043
+ });
76044
+ if (!res.ok) {
76045
+ const err = await res.json().catch(() => ({ error: "Transfer failed" }));
76046
+ throw new Error(err.error || `Payment failed: ${res.status}`);
76047
+ }
76048
+ const data = await res.json();
76049
+ if (!data.txHash)
76050
+ throw new Error("No tx hash returned.");
76051
+ return data.txHash;
76052
+ }
76053
+ function registerAmazonCommand(program2) {
76054
+ const cmd = program2.command("amazon").description("Search and buy products on Amazon — paid with AMIKO");
76055
+ cmd.command("search <query>").description("Search Amazon products — 1 AMIKO").option("--limit <n>", "Number of results", "5").option("--raw", "Output raw JSON").action(async (query, opts) => {
76056
+ const spinner = ora("Searching Amazon...").start();
76057
+ try {
76058
+ const config2 = loadConfig();
76059
+ const auth = resolveAuth(config2);
76060
+ const mppBase2 = (config2.apiBase || "https://mpp.amikomarkets.com").replace(/\/$/, "");
76061
+ const billingBase2 = auth.billingBase || "https://billing.heyamiko.com";
76062
+ const billingToken = auth.platformKey || auth.twinToken || auth.privyToken;
76063
+ if (!billingToken) {
76064
+ spinner.stop();
76065
+ console.error(error("Not connected."));
76066
+ process.exit(1);
76067
+ }
76068
+ const allWallets = auth.agentWallets || config2.agentWallets || [];
76069
+ const solanaWallet = allWallets.find((w5) => w5.chain === "solana")?.address;
76070
+ if (!solanaWallet) {
76071
+ spinner.stop();
76072
+ console.error(error("No Solana wallet."));
76073
+ process.exit(1);
76074
+ }
76075
+ spinner.text = "Paying 1 AMIKO...";
76076
+ const txHash = await payAmiko(billingBase2, billingToken, solanaWallet, "1");
76077
+ spinner.text = "Searching Amazon...";
76078
+ const params = new URLSearchParams({
76079
+ q: `site:amazon.com ${query}`
76080
+ });
76081
+ const res = await fetch(`${mppBase2}/v1/search/google_shopping?${params}`, {
76082
+ headers: { "X-Payment-Tx": txHash }
76083
+ });
76084
+ spinner.stop();
76085
+ if (!res.ok) {
76086
+ const text = await res.text().catch(() => "");
76087
+ console.error(error(`Search failed: ${res.status} ${text.slice(0, 200)}`));
76088
+ process.exit(1);
76089
+ }
76090
+ const data = await res.json();
76091
+ if (opts.raw) {
76092
+ console.log(JSON.stringify(data, null, 2));
76093
+ return;
76094
+ }
76095
+ console.log(heading(`Amazon: "${query}"
76096
+ `));
76097
+ const results = data.shopping_results || data.organic_results || [];
76098
+ const limit = parseInt(opts.limit) || 5;
76099
+ for (const item of results.slice(0, limit)) {
76100
+ const title = item.title || "Unknown";
76101
+ const price = item.price || item.extracted_price || "";
76102
+ const link = item.link || item.product_link || "";
76103
+ const asin = link.match(/\/dp\/([A-Z0-9]{10})/)?.[1] || "";
76104
+ console.log(` ${source_default.cyan(title)}`);
76105
+ if (price)
76106
+ console.log(` ${source_default.yellow(typeof price === "string" ? price : `$${price}`)}`);
76107
+ if (asin)
76108
+ console.log(dim(` ASIN: ${asin}`));
76109
+ if (link)
76110
+ console.log(dim(` ${link.slice(0, 80)}`));
76111
+ console.log("");
76112
+ }
76113
+ if (results.length === 0) {
76114
+ console.log(dim(" No results found."));
76115
+ }
76116
+ console.log(success("Paid 1 AMIKO") + dim(` tx: ${txHash.slice(0, 16)}...`));
76117
+ } catch (err) {
76118
+ spinner.stop();
76119
+ console.error(error(err instanceof Error ? err.message : "Search failed"));
76120
+ process.exit(1);
76121
+ }
76122
+ });
76123
+ cmd.command("quote <product>").description("Get price quote for an Amazon product (ASIN or URL) — free").option("--raw", "Output raw JSON").action(async (product, opts) => {
76124
+ const spinner = ora("Getting quote...").start();
76125
+ try {
76126
+ const config2 = loadConfig();
76127
+ const auth = resolveAuth(config2);
76128
+ const mppBase2 = (config2.apiBase || "https://mpp.amikomarkets.com").replace(/\/$/, "");
76129
+ const res = await fetch(`${mppBase2}/v1/amazon/quote`, {
76130
+ method: "POST",
76131
+ headers: { "Content-Type": "application/json" },
76132
+ body: JSON.stringify({
76133
+ items: [{ product, quantity: 1 }],
76134
+ recipient: {
76135
+ email: "quote@heyamiko.com",
76136
+ address: {
76137
+ name: "Quote",
76138
+ line1: "123 Main St",
76139
+ city: "New York",
76140
+ state: "NY",
76141
+ postalCode: "10001",
76142
+ country: "US"
76143
+ }
76144
+ }
76145
+ })
76146
+ });
76147
+ spinner.stop();
76148
+ if (!res.ok) {
76149
+ const text = await res.text().catch(() => "");
76150
+ console.error(error(`Quote failed: ${res.status} ${text.slice(0, 300)}`));
76151
+ process.exit(1);
76152
+ }
76153
+ const data = await res.json();
76154
+ if (opts.raw) {
76155
+ console.log(JSON.stringify(data, null, 2));
76156
+ return;
76157
+ }
76158
+ console.log(heading(`Amazon Quote
76159
+ `));
76160
+ if (data.total)
76161
+ console.log(label("Total", `$${data.total}`));
76162
+ if (data.product)
76163
+ console.log(label("Product", `$${data.product}`));
76164
+ if (data.margin)
76165
+ console.log(label("Fee (5%)", `$${data.margin}`));
76166
+ if (data.orderId)
76167
+ console.log(label("Order ID", dim(data.orderId)));
76168
+ const items = data.items || [];
76169
+ for (const item of items) {
76170
+ console.log(label("Item", `${item.product} x${item.quantity} — $${item.unitPrice || "?"}`));
76171
+ }
76172
+ } catch (err) {
76173
+ spinner.stop();
76174
+ console.error(error(err instanceof Error ? err.message : "Quote failed"));
76175
+ process.exit(1);
76176
+ }
76177
+ });
76178
+ }
76179
+
76180
+ // src/commands/services.ts
76181
+ var TREASURY4 = "FPiZAf3jEnNfCwfvbv46jdPfHbmSepD4Q6iHiLJDQXvb";
76035
76182
  var AMIKO_MINT = "AY1Ww6MxwC3cCiyrandHqLrp4FXvzgcwQTZpJ2FEpump";
76036
76183
  var USDC_MINT = "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v";
76037
76184
  async function getAmikoPrice() {
@@ -76080,7 +76227,7 @@ async function payAndCall(mppBase2, method, path, billingBase2, billingToken, so
76080
76227
  Authorization: `Bearer ${billingToken}`
76081
76228
  },
76082
76229
  body: JSON.stringify({
76083
- to: TREASURY3,
76230
+ to: TREASURY4,
76084
76231
  amount: amount2,
76085
76232
  token,
76086
76233
  chain: "solana"
@@ -76266,6 +76413,7 @@ registerConnectCommand(program2);
76266
76413
  registerCreditsCommand(program2);
76267
76414
  registerSearchCommand(program2);
76268
76415
  registerImageCommand(program2);
76416
+ registerAmazonCommand(program2);
76269
76417
  registerSwapCommand(program2);
76270
76418
  registerBridgeCommand(program2);
76271
76419
  registerBrowseCommand(program2);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@heyamiko/amiko-cli",
3
- "version": "0.6.3",
3
+ "version": "0.6.4",
4
4
  "description": "Amiko CLI — swap tokens, manage credits, bridge cross-chain, and call marketplace agents",
5
5
  "type": "module",
6
6
  "bin": {