@web42/cli 0.2.10 → 0.2.12
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/commands/register.d.ts +2 -0
- package/dist/commands/register.js +61 -0
- package/dist/commands/search.js +1 -1
- package/dist/commands/send.js +6 -2
- package/dist/index.js +2 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { Command } from "commander";
|
|
2
|
+
import chalk from "chalk";
|
|
3
|
+
import ora from "ora";
|
|
4
|
+
import { requireAuth } from "../utils/config.js";
|
|
5
|
+
export const registerCommand = new Command("register")
|
|
6
|
+
.description("Register an agent with the Web42 marketplace")
|
|
7
|
+
.argument("<url>", "Public URL of the running agent (must serve /.well-known/agent-card.json)")
|
|
8
|
+
.option("--price <cents>", "Price in cents (default: 0 = free)")
|
|
9
|
+
.option("--license <license>", "License (e.g. MIT, Apache-2.0)")
|
|
10
|
+
.option("--visibility <vis>", "Visibility: public or private", "public")
|
|
11
|
+
.option("--tags <tags>", "Comma-separated tags")
|
|
12
|
+
.option("--categories <cats>", "Comma-separated categories")
|
|
13
|
+
.action(async (url, opts) => {
|
|
14
|
+
const config = requireAuth();
|
|
15
|
+
const web42ApiUrl = config.apiUrl ?? "https://web42.ai";
|
|
16
|
+
const spinner = ora("Registering agent...").start();
|
|
17
|
+
const body = { url };
|
|
18
|
+
if (opts.price !== undefined)
|
|
19
|
+
body.price_cents = parseInt(opts.price, 10);
|
|
20
|
+
if (opts.license)
|
|
21
|
+
body.license = opts.license;
|
|
22
|
+
if (opts.visibility)
|
|
23
|
+
body.visibility = opts.visibility;
|
|
24
|
+
if (opts.tags)
|
|
25
|
+
body.tags = opts.tags.split(",").map((t) => t.trim());
|
|
26
|
+
if (opts.categories)
|
|
27
|
+
body.categories = opts.categories.split(",").map((c) => c.trim());
|
|
28
|
+
try {
|
|
29
|
+
const res = await fetch(`${web42ApiUrl}/api/agents`, {
|
|
30
|
+
method: "POST",
|
|
31
|
+
headers: {
|
|
32
|
+
Authorization: `Bearer ${config.token}`,
|
|
33
|
+
"Content-Type": "application/json",
|
|
34
|
+
},
|
|
35
|
+
body: JSON.stringify(body),
|
|
36
|
+
});
|
|
37
|
+
if (!res.ok) {
|
|
38
|
+
const errBody = (await res.json().catch(() => ({})));
|
|
39
|
+
spinner.fail("Registration failed");
|
|
40
|
+
console.error(chalk.red(errBody.error ?? `HTTP ${res.status}`));
|
|
41
|
+
process.exit(1);
|
|
42
|
+
}
|
|
43
|
+
const data = (await res.json());
|
|
44
|
+
const slug = data.agent?.slug ?? "unknown";
|
|
45
|
+
const name = data.agent?.agent_card?.name ?? slug;
|
|
46
|
+
const displaySlug = slug.replace("~", "/");
|
|
47
|
+
if (data.created) {
|
|
48
|
+
spinner.succeed(`Registered "${name}" (${displaySlug})`);
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
spinner.succeed(`Updated "${name}" (${displaySlug})`);
|
|
52
|
+
}
|
|
53
|
+
console.log(chalk.dim(` Send: web42 send ${slug} "hello"`));
|
|
54
|
+
console.log(chalk.dim(` View: ${web42ApiUrl}/${displaySlug.replace("@", "")}`));
|
|
55
|
+
}
|
|
56
|
+
catch (err) {
|
|
57
|
+
spinner.fail("Registration failed");
|
|
58
|
+
console.error(chalk.red(String(err)));
|
|
59
|
+
process.exit(1);
|
|
60
|
+
}
|
|
61
|
+
});
|
package/dist/commands/search.js
CHANGED
|
@@ -38,7 +38,7 @@ export const searchCommand = new Command("search")
|
|
|
38
38
|
const name = getCardName(agent.agent_card);
|
|
39
39
|
const description = getCardDescription(agent.agent_card);
|
|
40
40
|
const priceCents = getMarketplacePrice(agent.agent_card);
|
|
41
|
-
const ref =
|
|
41
|
+
const ref = agent.slug.replace("~", "/");
|
|
42
42
|
const stars = agent.stars_count > 0 ? chalk.yellow(` \u2605 ${agent.stars_count}`) : "";
|
|
43
43
|
const price = priceCents > 0
|
|
44
44
|
? chalk.green(` $${(priceCents / 100).toFixed(2)}`)
|
package/dist/commands/send.js
CHANGED
|
@@ -23,11 +23,15 @@ function getCachedToken(slug) {
|
|
|
23
23
|
}
|
|
24
24
|
export const sendCommand = new Command("send")
|
|
25
25
|
.description("Send a message to an A2A agent")
|
|
26
|
-
.argument("<agent>", "Agent slug (e.g.
|
|
26
|
+
.argument("<agent>", "Agent slug (e.g. @yan/richard) or direct URL (http://localhost:3001)")
|
|
27
27
|
.argument("<message>", "Message to send")
|
|
28
28
|
.option("--new", "Start a new conversation (clears saved context)")
|
|
29
29
|
.option("--context <id>", "Use a specific context ID")
|
|
30
|
-
.action(async (
|
|
30
|
+
.action(async (rawAgent, userMessage, opts) => {
|
|
31
|
+
// Normalize slug: @user/name → @user~name (DB format)
|
|
32
|
+
const agent = rawAgent.includes("/") && !isUrl(rawAgent)
|
|
33
|
+
? rawAgent.replace("/", "~")
|
|
34
|
+
: rawAgent;
|
|
31
35
|
const config = requireAuth();
|
|
32
36
|
let agentUrl;
|
|
33
37
|
let bearerToken;
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { Command } from "commander";
|
|
3
3
|
import { authCommand } from "./commands/auth.js";
|
|
4
|
+
import { registerCommand } from "./commands/register.js";
|
|
4
5
|
import { searchCommand } from "./commands/search.js";
|
|
5
6
|
import { sendCommand } from "./commands/send.js";
|
|
6
7
|
import { serveCommand } from "./commands/serve.js";
|
|
@@ -19,6 +20,7 @@ program
|
|
|
19
20
|
}
|
|
20
21
|
});
|
|
21
22
|
program.addCommand(authCommand);
|
|
23
|
+
program.addCommand(registerCommand);
|
|
22
24
|
program.addCommand(searchCommand);
|
|
23
25
|
program.addCommand(sendCommand);
|
|
24
26
|
program.addCommand(serveCommand);
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const CLI_VERSION = "0.2.
|
|
1
|
+
export declare const CLI_VERSION = "0.2.12";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const CLI_VERSION = "0.2.
|
|
1
|
+
export const CLI_VERSION = "0.2.12";
|