@caravo/cli 0.2.2 → 0.2.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/dist/cli.js +9 -1
- package/dist/commands/logout.js +30 -0
- package/package.json +11 -2
package/dist/cli.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import { createRequire } from "module";
|
|
2
3
|
import { resolveAuth } from "./lib/auth.js";
|
|
3
4
|
import { log } from "./lib/output.js";
|
|
5
|
+
const require = createRequire(import.meta.url);
|
|
6
|
+
const { version: VERSION } = require("../package.json");
|
|
4
7
|
const HELP = `caravo — Caravo CLI
|
|
5
8
|
|
|
6
9
|
Usage:
|
|
@@ -23,6 +26,7 @@ Commands:
|
|
|
23
26
|
Submit a tool request
|
|
24
27
|
request-upvote <req-id> Upvote a tool request
|
|
25
28
|
login Connect your Caravo account via browser (saves API key)
|
|
29
|
+
logout Disconnect account and switch to x402 wallet payments
|
|
26
30
|
wallet Show wallet + balance info
|
|
27
31
|
fetch [METHOD] <url> Raw x402 HTTP request
|
|
28
32
|
|
|
@@ -179,7 +183,6 @@ function parseArgs(argv) {
|
|
|
179
183
|
}
|
|
180
184
|
return args;
|
|
181
185
|
}
|
|
182
|
-
const VERSION = "0.2.2";
|
|
183
186
|
async function main() {
|
|
184
187
|
const args = parseArgs(process.argv.slice(2));
|
|
185
188
|
if (args.version) {
|
|
@@ -288,6 +291,11 @@ async function main() {
|
|
|
288
291
|
await runLogin(auth.baseUrl);
|
|
289
292
|
break;
|
|
290
293
|
}
|
|
294
|
+
case "logout": {
|
|
295
|
+
const { runLogout } = await import("./commands/logout.js");
|
|
296
|
+
runLogout();
|
|
297
|
+
break;
|
|
298
|
+
}
|
|
291
299
|
case "wallet": {
|
|
292
300
|
const { run } = await import("./commands/wallet-cmd.js");
|
|
293
301
|
await run(auth, args.compact);
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { readFileSync, writeFileSync, mkdirSync, existsSync } from "fs";
|
|
2
|
+
import { homedir } from "os";
|
|
3
|
+
import { join } from "path";
|
|
4
|
+
const CONFIG_DIR = join(homedir(), ".caravo");
|
|
5
|
+
const CONFIG_FILE = join(CONFIG_DIR, "config.json");
|
|
6
|
+
function loadConfig() {
|
|
7
|
+
try {
|
|
8
|
+
if (!existsSync(CONFIG_FILE))
|
|
9
|
+
return {};
|
|
10
|
+
return JSON.parse(readFileSync(CONFIG_FILE, "utf-8"));
|
|
11
|
+
}
|
|
12
|
+
catch {
|
|
13
|
+
return {};
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
function saveConfig(data) {
|
|
17
|
+
mkdirSync(CONFIG_DIR, { recursive: true });
|
|
18
|
+
writeFileSync(CONFIG_FILE, JSON.stringify(data, null, 2), { mode: 0o600 });
|
|
19
|
+
}
|
|
20
|
+
export function runLogout() {
|
|
21
|
+
const config = loadConfig();
|
|
22
|
+
if (!config.api_key) {
|
|
23
|
+
process.stdout.write("Not logged in — already using x402 wallet payments.\n");
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
delete config.api_key;
|
|
27
|
+
saveConfig(config);
|
|
28
|
+
process.stdout.write(`✓ Logged out. API key removed from ${CONFIG_FILE}\n`);
|
|
29
|
+
process.stdout.write(`Now using x402 wallet payments.\n`);
|
|
30
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@caravo/cli",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.4",
|
|
4
4
|
"description": "Caravo CLI — search, execute, and review tools with API key or x402 USDC payments",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -17,7 +17,16 @@
|
|
|
17
17
|
"typescript": "^5.8.2",
|
|
18
18
|
"@types/node": "^22"
|
|
19
19
|
},
|
|
20
|
-
"keywords": [
|
|
20
|
+
"keywords": [
|
|
21
|
+
"caravo",
|
|
22
|
+
"marketplace",
|
|
23
|
+
"cli",
|
|
24
|
+
"x402",
|
|
25
|
+
"usdc",
|
|
26
|
+
"base",
|
|
27
|
+
"agent",
|
|
28
|
+
"mcp"
|
|
29
|
+
],
|
|
21
30
|
"repository": {
|
|
22
31
|
"type": "git",
|
|
23
32
|
"url": "https://github.com/Caravo-AI/Caravo-CLI"
|