@agentis-hq/cli 0.1.2 → 0.1.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.
- package/README.md +8 -0
- package/dist/index.js +111 -5
- package/package.json +20 -1
package/README.md
CHANGED
|
@@ -169,6 +169,13 @@ Deposit USDC into Jupiter Earn:
|
|
|
169
169
|
agentis earn deposit research-agent --asset USDC --amount 1 --mainnet
|
|
170
170
|
```
|
|
171
171
|
|
|
172
|
+
Withdraw USDC from Jupiter Earn. Omit `--amount` to redeem the full USDC Earn position:
|
|
173
|
+
|
|
174
|
+
```bash
|
|
175
|
+
agentis earn withdraw research-agent --asset USDC --mainnet
|
|
176
|
+
agentis earn withdraw research-agent --asset USDC --amount 1 --mainnet
|
|
177
|
+
```
|
|
178
|
+
|
|
172
179
|
Show positions:
|
|
173
180
|
|
|
174
181
|
```bash
|
|
@@ -253,6 +260,7 @@ agentis wallet create --help
|
|
|
253
260
|
agentis agent send --help
|
|
254
261
|
agentis fetch --help
|
|
255
262
|
agentis earn deposit --help
|
|
263
|
+
agentis earn withdraw --help
|
|
256
264
|
agentis privacy create-utxo --help
|
|
257
265
|
agentis facilitator publish --help
|
|
258
266
|
```
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
|
|
3
|
+
// src/index.ts
|
|
4
|
+
import { readFileSync as readFileSync2 } from "fs";
|
|
5
|
+
import { dirname as dirname2, join as join3 } from "path";
|
|
6
|
+
import { fileURLToPath } from "url";
|
|
7
|
+
|
|
3
8
|
// src/lib/keychain.ts
|
|
4
9
|
import { Entry } from "@napi-rs/keyring";
|
|
5
10
|
var entry = new Entry("agentis-cli", "account-key");
|
|
@@ -269,6 +274,31 @@ function recordLocalSpend(wallet, spend) {
|
|
|
269
274
|
return updated;
|
|
270
275
|
}
|
|
271
276
|
|
|
277
|
+
// src/lib/format-agent.ts
|
|
278
|
+
function formatPolicy(agent) {
|
|
279
|
+
const mode = agent.policyMode ?? "backend";
|
|
280
|
+
if (mode !== "onchain") return "policy=backend";
|
|
281
|
+
return `policy=onchain:${agent.onchainPolicy?.initialized ? "ready" : "pending"}`;
|
|
282
|
+
}
|
|
283
|
+
function formatPrivacy(agent) {
|
|
284
|
+
if (!agent.privacyEnabled && !agent.umbraStatus) return null;
|
|
285
|
+
return `privacy=${agent.umbraStatus ?? "enabled"}`;
|
|
286
|
+
}
|
|
287
|
+
function formatLocalPolicy(wallet) {
|
|
288
|
+
return wallet.policy.killSwitch ? "policy=local:killed" : "policy=local";
|
|
289
|
+
}
|
|
290
|
+
function formatBadges(parts) {
|
|
291
|
+
return parts.filter(Boolean).join(", ");
|
|
292
|
+
}
|
|
293
|
+
function formatHostedAgentLine(agent) {
|
|
294
|
+
const badges = formatBadges(["hosted", formatPolicy(agent), formatPrivacy(agent)]);
|
|
295
|
+
return ` ${agent.name.padEnd(20)} ${agent.walletAddress} [${agent.id}] ${badges}`;
|
|
296
|
+
}
|
|
297
|
+
function formatLocalWalletLine(wallet) {
|
|
298
|
+
const badges = formatBadges(["local", formatLocalPolicy(wallet)]);
|
|
299
|
+
return ` ${wallet.name.padEnd(20)} ${wallet.solanaAddress} [${wallet.id}] ${badges}`;
|
|
300
|
+
}
|
|
301
|
+
|
|
272
302
|
// src/commands/agent.ts
|
|
273
303
|
import { checkPolicy } from "@agentis-hq/core";
|
|
274
304
|
import {
|
|
@@ -329,7 +359,7 @@ async function agentList() {
|
|
|
329
359
|
}
|
|
330
360
|
console.log();
|
|
331
361
|
for (const a of agents) {
|
|
332
|
-
console.log(
|
|
362
|
+
console.log(formatHostedAgentLine(a));
|
|
333
363
|
}
|
|
334
364
|
console.log();
|
|
335
365
|
}
|
|
@@ -550,7 +580,7 @@ async function walletList() {
|
|
|
550
580
|
if (hosted.length > 0) {
|
|
551
581
|
console.log("\nHosted wallets:");
|
|
552
582
|
for (const a of hosted) {
|
|
553
|
-
console.log(
|
|
583
|
+
console.log(formatHostedAgentLine(a));
|
|
554
584
|
}
|
|
555
585
|
}
|
|
556
586
|
}
|
|
@@ -560,7 +590,7 @@ async function walletList() {
|
|
|
560
590
|
if (localWallets.length > 0) {
|
|
561
591
|
console.log("\nLocal wallets:");
|
|
562
592
|
for (const w of localWallets) {
|
|
563
|
-
console.log(
|
|
593
|
+
console.log(formatLocalWalletLine(w));
|
|
564
594
|
}
|
|
565
595
|
}
|
|
566
596
|
if (localWallets.length === 0 && !token) {
|
|
@@ -1044,6 +1074,9 @@ async function earnCommand(args2) {
|
|
|
1044
1074
|
case "deposit":
|
|
1045
1075
|
await earnDeposit(args2.slice(1));
|
|
1046
1076
|
break;
|
|
1077
|
+
case "withdraw":
|
|
1078
|
+
await earnWithdraw(args2.slice(1));
|
|
1079
|
+
break;
|
|
1047
1080
|
case "positions":
|
|
1048
1081
|
await earnPositions(args2.slice(1));
|
|
1049
1082
|
break;
|
|
@@ -1051,7 +1084,7 @@ async function earnCommand(args2) {
|
|
|
1051
1084
|
await earnSweep(args2.slice(1));
|
|
1052
1085
|
break;
|
|
1053
1086
|
default:
|
|
1054
|
-
console.log("Usage: agentis earn <deposit|positions|sweep>");
|
|
1087
|
+
console.log("Usage: agentis earn <deposit|withdraw|positions|sweep>");
|
|
1055
1088
|
}
|
|
1056
1089
|
}
|
|
1057
1090
|
async function earnDeposit(args2) {
|
|
@@ -1091,6 +1124,47 @@ Depositing ${amountNum} ${asset.toUpperCase()} into Jupiter Earn from ${agent.na
|
|
|
1091
1124
|
console.log(` Explorer: https://solscan.io/tx/${data.signature}
|
|
1092
1125
|
`);
|
|
1093
1126
|
}
|
|
1127
|
+
async function earnWithdraw(args2) {
|
|
1128
|
+
const agentName = args2[0];
|
|
1129
|
+
const asset = getFlag3(args2, "--asset") ?? "USDC";
|
|
1130
|
+
const amount = getFlag3(args2, "--amount");
|
|
1131
|
+
const mainnet = args2.includes("--mainnet");
|
|
1132
|
+
if (!agentName || !mainnet) {
|
|
1133
|
+
console.error("Usage: agentis earn withdraw <agent> --asset USDC [--amount <amount>] --mainnet");
|
|
1134
|
+
process.exit(1);
|
|
1135
|
+
}
|
|
1136
|
+
if (amount !== void 0) {
|
|
1137
|
+
const amountNum = Number(amount);
|
|
1138
|
+
if (!Number.isFinite(amountNum) || amountNum <= 0) {
|
|
1139
|
+
console.error("Invalid amount");
|
|
1140
|
+
process.exit(1);
|
|
1141
|
+
}
|
|
1142
|
+
}
|
|
1143
|
+
const token = await requireAuth3();
|
|
1144
|
+
const agent = await resolveAccountAgent(agentName, token);
|
|
1145
|
+
const amountLabel = amount === void 0 ? "all supplied" : `${amount} ${asset.toUpperCase()}`;
|
|
1146
|
+
console.log(`
|
|
1147
|
+
Withdrawing ${amountLabel} from Jupiter Earn to ${agent.name} on mainnet...`);
|
|
1148
|
+
const res = await apiFetch(`/agents/${agent.id}/earn/withdraw`, {
|
|
1149
|
+
method: "POST",
|
|
1150
|
+
body: JSON.stringify({
|
|
1151
|
+
network: "mainnet",
|
|
1152
|
+
asset,
|
|
1153
|
+
amount
|
|
1154
|
+
})
|
|
1155
|
+
}, token);
|
|
1156
|
+
const data = await res.json().catch(() => ({}));
|
|
1157
|
+
if (!res.ok) {
|
|
1158
|
+
console.error("Earn withdraw failed:", data.error ?? res.statusText);
|
|
1159
|
+
process.exit(1);
|
|
1160
|
+
}
|
|
1161
|
+
console.log("\nEarn withdraw submitted.");
|
|
1162
|
+
console.log(` Signature: ${data.signature}`);
|
|
1163
|
+
console.log(` Amount: ${data.amount} ${asset.toUpperCase()}`);
|
|
1164
|
+
console.log(` Mode: ${data.mode}`);
|
|
1165
|
+
console.log(` Explorer: https://solscan.io/tx/${data.signature}
|
|
1166
|
+
`);
|
|
1167
|
+
}
|
|
1094
1168
|
async function earnPositions(args2) {
|
|
1095
1169
|
const agentName = args2[0];
|
|
1096
1170
|
const mainnet = args2.includes("--mainnet");
|
|
@@ -1273,6 +1347,16 @@ var green = "\x1B[38;5;114m";
|
|
|
1273
1347
|
var muted = "\x1B[38;5;244m";
|
|
1274
1348
|
var bold = "\x1B[1m";
|
|
1275
1349
|
var reset = "\x1B[0m";
|
|
1350
|
+
function readCliVersion() {
|
|
1351
|
+
try {
|
|
1352
|
+
const packageJsonPath = join3(dirname2(fileURLToPath(import.meta.url)), "..", "package.json");
|
|
1353
|
+
const packageJson = JSON.parse(readFileSync2(packageJsonPath, "utf8"));
|
|
1354
|
+
return packageJson.version ?? "unknown";
|
|
1355
|
+
} catch {
|
|
1356
|
+
return "unknown";
|
|
1357
|
+
}
|
|
1358
|
+
}
|
|
1359
|
+
var version = readCliVersion();
|
|
1276
1360
|
var helpSpecs = {
|
|
1277
1361
|
login: {
|
|
1278
1362
|
usage: "agentis login",
|
|
@@ -1286,6 +1370,10 @@ var helpSpecs = {
|
|
|
1286
1370
|
usage: "agentis whoami",
|
|
1287
1371
|
description: "Show the currently authenticated Agentis account key in masked form."
|
|
1288
1372
|
},
|
|
1373
|
+
version: {
|
|
1374
|
+
usage: "agentis version",
|
|
1375
|
+
description: "Show the installed Agentis CLI version."
|
|
1376
|
+
},
|
|
1289
1377
|
wallet: {
|
|
1290
1378
|
usage: "agentis wallet <command>",
|
|
1291
1379
|
description: "Create and list hosted or local Solana wallets.",
|
|
@@ -1359,6 +1447,7 @@ var helpSpecs = {
|
|
|
1359
1447
|
description: "Manage Jupiter Earn deposits and positions for hosted agent wallets.",
|
|
1360
1448
|
commands: [
|
|
1361
1449
|
["deposit <agent> --asset USDC --amount <amount> --mainnet", "deposit mainnet USDC into Jupiter Earn"],
|
|
1450
|
+
["withdraw <agent> --asset USDC [--amount <amount>] --mainnet", "withdraw mainnet USDC from Jupiter Earn"],
|
|
1362
1451
|
["positions <agent> --mainnet [--all]", "show Jupiter Earn positions"],
|
|
1363
1452
|
["sweep [--dry-run|--no-dry-run]", "sweep all hosted agents mainnet USDC into Jupiter Earn"]
|
|
1364
1453
|
]
|
|
@@ -1373,6 +1462,16 @@ var helpSpecs = {
|
|
|
1373
1462
|
["-h, --help", "display help for command"]
|
|
1374
1463
|
]
|
|
1375
1464
|
},
|
|
1465
|
+
"earn withdraw": {
|
|
1466
|
+
usage: "agentis earn withdraw <agent> --asset USDC [--amount <amount>] --mainnet",
|
|
1467
|
+
description: "Withdraw mainnet USDC from Jupiter Earn back to a hosted agent wallet. Omitting --amount redeems the full USDC Earn position.",
|
|
1468
|
+
options: [
|
|
1469
|
+
["--asset USDC", "asset to withdraw; currently USDC"],
|
|
1470
|
+
["--amount <amount>", "optional UI amount, for example 1 for 1 USDC"],
|
|
1471
|
+
["--mainnet", "required safety flag"],
|
|
1472
|
+
["-h, --help", "display help for command"]
|
|
1473
|
+
]
|
|
1474
|
+
},
|
|
1376
1475
|
"earn positions": {
|
|
1377
1476
|
usage: "agentis earn positions <agent> --mainnet [--all]",
|
|
1378
1477
|
description: "Show Jupiter Earn positions for a hosted agent wallet.",
|
|
@@ -1529,7 +1628,7 @@ function showHelp() {
|
|
|
1529
1628
|
\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2550\u255D \u2588\u2588\u2551\u255A\u2588\u2588\u2557\u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551\u255A\u2550\u2550\u2550\u2550\u2588\u2588\u2551
|
|
1530
1629
|
\u2588\u2588\u2551 \u2588\u2588\u2551\u255A\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2551 \u255A\u2588\u2588\u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2551
|
|
1531
1630
|
\u255A\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u2550\u255D\u255A\u2550\u255D \u255A\u2550\u2550\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u255D\u255A\u2550\u2550\u2550\u2550\u2550\u2550\u255D
|
|
1532
|
-
${reset}${muted}
|
|
1631
|
+
${reset}${muted}v${version}${reset}
|
|
1533
1632
|
|
|
1534
1633
|
${bold}Agentis${reset} \u2014 financial infrastructure for AI agents
|
|
1535
1634
|
|
|
@@ -1537,6 +1636,7 @@ ${green}${bold}Commands:${reset}
|
|
|
1537
1636
|
login authenticate with your Agentis account
|
|
1538
1637
|
logout remove stored credentials
|
|
1539
1638
|
whoami show current account
|
|
1639
|
+
version show installed CLI version
|
|
1540
1640
|
|
|
1541
1641
|
wallet create --name <name> create hosted wallet (requires login)
|
|
1542
1642
|
wallet create --name <name> --local create local encrypted wallet
|
|
@@ -1556,6 +1656,8 @@ ${green}${bold}Commands:${reset}
|
|
|
1556
1656
|
--asset USDC asset to deposit
|
|
1557
1657
|
--amount <amount> UI amount, e.g. 1 for 1 USDC
|
|
1558
1658
|
--mainnet required safety flag
|
|
1659
|
+
earn withdraw <agent> --mainnet withdraw all USDC from Jupiter Earn
|
|
1660
|
+
--amount <amount> optional UI amount, e.g. 1 for 1 USDC
|
|
1559
1661
|
earn positions <agent> --mainnet show Jupiter Earn positions
|
|
1560
1662
|
earn sweep [--dry-run|--no-dry-run] sweep all agents' mainnet USDC into Earn
|
|
1561
1663
|
|
|
@@ -1624,6 +1726,10 @@ function showCommandHelp(path) {
|
|
|
1624
1726
|
console.log();
|
|
1625
1727
|
}
|
|
1626
1728
|
async function main() {
|
|
1729
|
+
if (cmd === "--version" || cmd === "-v" || cmd === "version") {
|
|
1730
|
+
console.log(version);
|
|
1731
|
+
return;
|
|
1732
|
+
}
|
|
1627
1733
|
if (!cmd || hasHelpFlag(args)) {
|
|
1628
1734
|
showCommandHelp(helpPath(args));
|
|
1629
1735
|
return;
|
package/package.json
CHANGED
|
@@ -1,11 +1,30 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agentis-hq/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"bin": {
|
|
6
6
|
"agentis": "dist/index.js"
|
|
7
7
|
},
|
|
8
8
|
"description": "Agentis CLI",
|
|
9
|
+
"keywords": [
|
|
10
|
+
"agentis",
|
|
11
|
+
"ai",
|
|
12
|
+
"agents",
|
|
13
|
+
"ai-agents",
|
|
14
|
+
"agentic",
|
|
15
|
+
"cli",
|
|
16
|
+
"solana",
|
|
17
|
+
"payments",
|
|
18
|
+
"crypto",
|
|
19
|
+
"wallet",
|
|
20
|
+
"agent-wallets",
|
|
21
|
+
"crypto-payments",
|
|
22
|
+
"x402",
|
|
23
|
+
"mpp",
|
|
24
|
+
"jupiter",
|
|
25
|
+
"umbra",
|
|
26
|
+
"mcp"
|
|
27
|
+
],
|
|
9
28
|
"exports": {
|
|
10
29
|
"./package.json": "./package.json"
|
|
11
30
|
},
|