@heyamiko/amiko-cli 0.5.17 → 0.5.19
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 +48 -23
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -75831,41 +75831,70 @@ function registerUpdateCommand(program2) {
|
|
|
75831
75831
|
}
|
|
75832
75832
|
|
|
75833
75833
|
// src/commands/search.ts
|
|
75834
|
+
var TREASURY = "FPiZAf3jEnNfCwfvbv46jdPfHbmSepD4Q6iHiLJDQXvb";
|
|
75834
75835
|
function registerSearchCommand(program2) {
|
|
75835
|
-
program2.command("search <query>").description("Search
|
|
75836
|
-
const spinner = ora("
|
|
75836
|
+
program2.command("search <query>").description("X Search — pays 1 AMIKO token per search").option("--raw", "Output raw JSON").action(async (query, opts) => {
|
|
75837
|
+
const spinner = ora("X Search...").start();
|
|
75837
75838
|
try {
|
|
75838
75839
|
const config2 = loadConfig();
|
|
75839
75840
|
const auth = resolveAuth(config2);
|
|
75840
75841
|
const mppBase2 = (config2.apiBase || "https://mpp.amikomarkets.com").replace(/\/$/, "");
|
|
75841
|
-
|
|
75842
|
+
const billingBase2 = auth.billingBase || "https://billing.heyamiko.com";
|
|
75843
|
+
const billingToken = auth.platformKey || auth.twinToken || auth.privyToken;
|
|
75844
|
+
if (auth.mode === "none" || !billingToken) {
|
|
75842
75845
|
spinner.stop();
|
|
75843
75846
|
console.error(error("Not connected."));
|
|
75844
75847
|
process.exit(1);
|
|
75845
75848
|
}
|
|
75846
|
-
const
|
|
75847
|
-
const
|
|
75848
|
-
if (!
|
|
75849
|
+
const allWallets = auth.agentWallets || config2.agentWallets || [];
|
|
75850
|
+
const solanaWallet = allWallets.find((w5) => w5.chain === "solana")?.address;
|
|
75851
|
+
if (!solanaWallet) {
|
|
75849
75852
|
spinner.stop();
|
|
75850
|
-
console.error(error("No
|
|
75853
|
+
console.error(error("No Solana wallet found for AMIKO payment."));
|
|
75851
75854
|
process.exit(1);
|
|
75852
75855
|
}
|
|
75853
|
-
|
|
75854
|
-
const
|
|
75855
|
-
|
|
75856
|
-
headers
|
|
75857
|
-
|
|
75858
|
-
|
|
75856
|
+
spinner.text = "Paying 1 AMIKO...";
|
|
75857
|
+
const transferRes = await fetch(`${billingBase2}/api/crossmint/wallets/${encodeURIComponent(solanaWallet)}/transfer`, {
|
|
75858
|
+
method: "POST",
|
|
75859
|
+
headers: {
|
|
75860
|
+
"Content-Type": "application/json",
|
|
75861
|
+
Authorization: `Bearer ${billingToken}`
|
|
75862
|
+
},
|
|
75863
|
+
body: JSON.stringify({
|
|
75864
|
+
to: TREASURY,
|
|
75865
|
+
amount: "1",
|
|
75866
|
+
token: "AMIKO",
|
|
75867
|
+
chain: "solana"
|
|
75868
|
+
})
|
|
75869
|
+
});
|
|
75870
|
+
if (!transferRes.ok) {
|
|
75871
|
+
spinner.stop();
|
|
75872
|
+
const err = await transferRes.json().catch(() => ({ error: "Transfer failed" }));
|
|
75873
|
+
console.error(error(err.error || `AMIKO payment failed: ${transferRes.status}`));
|
|
75874
|
+
process.exit(1);
|
|
75859
75875
|
}
|
|
75860
|
-
const
|
|
75861
|
-
|
|
75862
|
-
if (
|
|
75863
|
-
|
|
75876
|
+
const transferData = await transferRes.json();
|
|
75877
|
+
const txHash = transferData.txHash;
|
|
75878
|
+
if (!txHash) {
|
|
75879
|
+
spinner.stop();
|
|
75880
|
+
console.error(error("Payment sent but no tx hash returned."));
|
|
75864
75881
|
process.exit(1);
|
|
75865
75882
|
}
|
|
75883
|
+
spinner.text = `Paid 1 AMIKO — searching X...`;
|
|
75884
|
+
const params = new URLSearchParams({ q: query });
|
|
75885
|
+
const res = await fetch(`${mppBase2}/v1/x/search?${params}`, {
|
|
75886
|
+
headers: {
|
|
75887
|
+
"Content-Type": "application/json",
|
|
75888
|
+
"X-Payment-Tx": txHash,
|
|
75889
|
+
"X-Payment-Amount": "1",
|
|
75890
|
+
"X-Payment-Token": "AMIKO"
|
|
75891
|
+
}
|
|
75892
|
+
});
|
|
75893
|
+
spinner.stop();
|
|
75866
75894
|
if (!res.ok) {
|
|
75867
75895
|
const text = await res.text().catch(() => "");
|
|
75868
75896
|
console.error(error(`Search failed: ${res.status} ${text.slice(0, 200)}`));
|
|
75897
|
+
console.log(dim(`Payment tx: https://solscan.io/tx/${txHash}`));
|
|
75869
75898
|
process.exit(1);
|
|
75870
75899
|
}
|
|
75871
75900
|
const data = await res.json();
|
|
@@ -75873,8 +75902,7 @@ function registerSearchCommand(program2) {
|
|
|
75873
75902
|
console.log(JSON.stringify(data, null, 2));
|
|
75874
75903
|
return;
|
|
75875
75904
|
}
|
|
75876
|
-
|
|
75877
|
-
console.log(heading(`X Search: "${query}"
|
|
75905
|
+
console.log(heading(`X Search — "${query}"
|
|
75878
75906
|
`));
|
|
75879
75907
|
const tweets = data.data || [];
|
|
75880
75908
|
if (tweets.length === 0) {
|
|
@@ -75892,10 +75920,7 @@ function registerSearchCommand(program2) {
|
|
|
75892
75920
|
console.log("");
|
|
75893
75921
|
}
|
|
75894
75922
|
}
|
|
75895
|
-
|
|
75896
|
-
if (paymentBalance)
|
|
75897
|
-
footer += dim(` (balance: $${paymentBalance})`);
|
|
75898
|
-
console.log(footer);
|
|
75923
|
+
console.log(success("Paid 1 AMIKO") + dim(` tx: ${txHash.slice(0, 16)}...`));
|
|
75899
75924
|
} catch (err) {
|
|
75900
75925
|
spinner.stop();
|
|
75901
75926
|
console.error(error(err instanceof Error ? err.message : "Search failed"));
|