@heyamiko/amiko-cli 0.6.1 → 0.6.3

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 +104 -2
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -75929,8 +75929,109 @@ function registerSearchCommand(program2) {
75929
75929
  });
75930
75930
  }
75931
75931
 
75932
- // src/commands/services.ts
75932
+ // src/commands/image.ts
75933
75933
  var TREASURY2 = "FPiZAf3jEnNfCwfvbv46jdPfHbmSepD4Q6iHiLJDQXvb";
75934
+ function registerImageCommand(program2) {
75935
+ program2.command("image <prompt>").alias("img").description("Generate an image with DALL-E — costs 5 AMIKO").option("--size <size>", "Image size: 1024x1024, 1024x1792, 1792x1024", "1024x1024").option("--quality <q>", "Quality: standard or hd", "standard").option("--model <model>", "Model: dall-e-3 or dall-e-2", "dall-e-3").option("--raw", "Output raw JSON").action(async (prompt2, opts) => {
75936
+ const spinner = ora("Generating image...").start();
75937
+ try {
75938
+ const config2 = loadConfig();
75939
+ const auth = resolveAuth(config2);
75940
+ const mppBase2 = (config2.apiBase || "https://mpp.amikomarkets.com").replace(/\/$/, "");
75941
+ const billingBase2 = auth.billingBase || "https://billing.heyamiko.com";
75942
+ const billingToken = auth.platformKey || auth.twinToken || auth.privyToken;
75943
+ if (!billingToken) {
75944
+ spinner.stop();
75945
+ console.error(error("Not connected."));
75946
+ process.exit(1);
75947
+ }
75948
+ const allWallets = auth.agentWallets || config2.agentWallets || [];
75949
+ const solanaWallet = allWallets.find((w5) => w5.chain === "solana")?.address;
75950
+ if (!solanaWallet) {
75951
+ spinner.stop();
75952
+ console.error(error("No Solana wallet for AMIKO payment."));
75953
+ process.exit(1);
75954
+ }
75955
+ spinner.text = "Paying 5 AMIKO...";
75956
+ const transferRes = await fetch(`${billingBase2}/api/crossmint/wallets/${encodeURIComponent(solanaWallet)}/transfer`, {
75957
+ method: "POST",
75958
+ headers: {
75959
+ "Content-Type": "application/json",
75960
+ Authorization: `Bearer ${billingToken}`
75961
+ },
75962
+ body: JSON.stringify({
75963
+ to: TREASURY2,
75964
+ amount: "5",
75965
+ token: "AMIKO",
75966
+ chain: "solana"
75967
+ })
75968
+ });
75969
+ if (!transferRes.ok) {
75970
+ spinner.stop();
75971
+ const err = await transferRes.json().catch(() => ({ error: "Transfer failed" }));
75972
+ console.error(error(err.error || `Payment failed: ${transferRes.status}`));
75973
+ process.exit(1);
75974
+ }
75975
+ const transferData = await transferRes.json();
75976
+ const txHash = transferData.txHash;
75977
+ if (!txHash) {
75978
+ spinner.stop();
75979
+ console.error(error("Payment sent but no tx hash returned."));
75980
+ process.exit(1);
75981
+ }
75982
+ spinner.text = "Generating image...";
75983
+ const res = await fetch(`${mppBase2}/v1/ai/openai/images`, {
75984
+ method: "POST",
75985
+ headers: {
75986
+ "Content-Type": "application/json",
75987
+ "X-Payment-Tx": txHash
75988
+ },
75989
+ body: JSON.stringify({
75990
+ prompt: prompt2,
75991
+ size: opts.size,
75992
+ quality: opts.quality,
75993
+ model: opts.model
75994
+ })
75995
+ });
75996
+ spinner.stop();
75997
+ if (!res.ok) {
75998
+ const text = await res.text().catch(() => "");
75999
+ console.error(error(`Image generation failed: ${res.status} ${text.slice(0, 300)}`));
76000
+ console.log(dim(`Payment tx: https://solscan.io/tx/${txHash}`));
76001
+ process.exit(1);
76002
+ }
76003
+ const data = await res.json();
76004
+ if (opts.raw) {
76005
+ console.log(JSON.stringify(data, null, 2));
76006
+ return;
76007
+ }
76008
+ console.log(heading(`Image Generated
76009
+ `));
76010
+ console.log(label("Prompt", prompt2));
76011
+ console.log(label("Model", opts.model));
76012
+ console.log(label("Size", opts.size));
76013
+ console.log("");
76014
+ const images = data.images || data.data || [];
76015
+ for (const img of images) {
76016
+ const url2 = img.url || img.revised_prompt || "";
76017
+ if (url2)
76018
+ console.log(label("URL", url2));
76019
+ if (img.revised_prompt && img.revised_prompt !== prompt2) {
76020
+ console.log(label("Revised", dim(img.revised_prompt)));
76021
+ }
76022
+ }
76023
+ console.log("");
76024
+ console.log(success("Paid 5 AMIKO") + dim(` tx: ${txHash.slice(0, 16)}...`));
76025
+ } catch (err) {
76026
+ spinner.stop();
76027
+ console.error(error(err instanceof Error ? err.message : "Image generation failed"));
76028
+ process.exit(1);
76029
+ }
76030
+ });
76031
+ }
76032
+
76033
+ // src/commands/services.ts
76034
+ var TREASURY3 = "FPiZAf3jEnNfCwfvbv46jdPfHbmSepD4Q6iHiLJDQXvb";
75934
76035
  var AMIKO_MINT = "AY1Ww6MxwC3cCiyrandHqLrp4FXvzgcwQTZpJ2FEpump";
75935
76036
  var USDC_MINT = "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v";
75936
76037
  async function getAmikoPrice() {
@@ -75979,7 +76080,7 @@ async function payAndCall(mppBase2, method, path, billingBase2, billingToken, so
75979
76080
  Authorization: `Bearer ${billingToken}`
75980
76081
  },
75981
76082
  body: JSON.stringify({
75982
- to: TREASURY2,
76083
+ to: TREASURY3,
75983
76084
  amount: amount2,
75984
76085
  token,
75985
76086
  chain: "solana"
@@ -76164,6 +76265,7 @@ program2.name("amiko").description("Amiko CLI — swap tokens, manage credits, b
76164
76265
  registerConnectCommand(program2);
76165
76266
  registerCreditsCommand(program2);
76166
76267
  registerSearchCommand(program2);
76268
+ registerImageCommand(program2);
76167
76269
  registerSwapCommand(program2);
76168
76270
  registerBridgeCommand(program2);
76169
76271
  registerBrowseCommand(program2);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@heyamiko/amiko-cli",
3
- "version": "0.6.1",
3
+ "version": "0.6.3",
4
4
  "description": "Amiko CLI — swap tokens, manage credits, bridge cross-chain, and call marketplace agents",
5
5
  "type": "module",
6
6
  "bin": {