@web42/w42 0.1.21 → 0.1.23
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/intent.js +1 -1
- package/dist/commands/register.js +10 -19
- package/dist/commands/search.js +24 -2
- package/dist/commands/send.js +2 -4
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +2 -2
package/dist/commands/intent.js
CHANGED
|
@@ -73,7 +73,7 @@ intentCommand
|
|
|
73
73
|
.command("propose")
|
|
74
74
|
.description("Generate an intent creation URL for the user to authorize in the browser")
|
|
75
75
|
.requiredOption("--nick <nick>", "Short identifier for the intent")
|
|
76
|
-
.requiredOption("--agents <slugs>", "Comma-separated merchant agent slugs (e.g.
|
|
76
|
+
.requiredOption("--agents <slugs>", "Comma-separated merchant agent slugs (e.g. w42/starbucks)")
|
|
77
77
|
.requiredOption("--max-amount <dollars>", "Max amount per transaction in dollars")
|
|
78
78
|
.requiredOption("--prompt-playback <text>", "Human-readable description of the intent")
|
|
79
79
|
.option("--currency <code>", "Currency code", "USD")
|
|
@@ -3,7 +3,7 @@ import { Command } from "commander";
|
|
|
3
3
|
import inquirer from "inquirer";
|
|
4
4
|
import ora from "ora";
|
|
5
5
|
import { apiGet, apiPost, hintForError } from "../utils/api.js";
|
|
6
|
-
import { getConfig
|
|
6
|
+
import { getConfig } from "../utils/config.js";
|
|
7
7
|
function toSlugPart(name) {
|
|
8
8
|
return name
|
|
9
9
|
.toLowerCase()
|
|
@@ -46,7 +46,7 @@ export const registerCommand = new Command("register")
|
|
|
46
46
|
const check = await apiGet(`/api/agents/check?url=${encodeURIComponent(url)}`);
|
|
47
47
|
if (check.registered) {
|
|
48
48
|
alreadyRegistered = true;
|
|
49
|
-
const displaySlug = check.slug
|
|
49
|
+
const displaySlug = check.slug;
|
|
50
50
|
checkSpinner.warn(`Already registered as ${chalk.cyan(displaySlug)}`);
|
|
51
51
|
}
|
|
52
52
|
else {
|
|
@@ -68,16 +68,8 @@ export const registerCommand = new Command("register")
|
|
|
68
68
|
if (!proceed)
|
|
69
69
|
process.exit(0);
|
|
70
70
|
}
|
|
71
|
-
// ── Step 3:
|
|
72
|
-
if (!isAuthenticated()) {
|
|
73
|
-
console.log();
|
|
74
|
-
console.log(chalk.yellow("You must be logged in to register an agent."));
|
|
75
|
-
console.log(chalk.dim("Run: ") + chalk.cyan("w42 auth login"));
|
|
76
|
-
process.exit(0);
|
|
77
|
-
}
|
|
71
|
+
// ── Step 3: Slug prompt + availability check ───────────────────────────
|
|
78
72
|
const cfg = getConfig();
|
|
79
|
-
const username = cfg.username;
|
|
80
|
-
// ── Step 4: Slug prompt + availability check ───────────────────────────
|
|
81
73
|
const defaultSlugPart = toSlugPart(agentCard.name ?? "my-agent") || "my-agent";
|
|
82
74
|
console.log();
|
|
83
75
|
if (agentCard.name)
|
|
@@ -91,7 +83,7 @@ export const registerCommand = new Command("register")
|
|
|
91
83
|
{
|
|
92
84
|
type: "input",
|
|
93
85
|
name: "slugPart",
|
|
94
|
-
message: `Agent slug ${chalk.dim(
|
|
86
|
+
message: `Agent slug ${chalk.dim("(w42/")}`,
|
|
95
87
|
default: defaultSlugPart,
|
|
96
88
|
validate: (input) => {
|
|
97
89
|
if (!input)
|
|
@@ -103,12 +95,12 @@ export const registerCommand = new Command("register")
|
|
|
103
95
|
},
|
|
104
96
|
]);
|
|
105
97
|
slugPart = answer.slugPart;
|
|
106
|
-
const fullSlug =
|
|
98
|
+
const fullSlug = "w42/" + slugPart;
|
|
107
99
|
const slugSpinner = ora("Checking slug availability...").start();
|
|
108
100
|
try {
|
|
109
101
|
const check = await apiGet(`/api/agents/check?slug=${encodeURIComponent(fullSlug)}`);
|
|
110
102
|
if (check.taken) {
|
|
111
|
-
slugSpinner.fail(`${chalk.cyan(
|
|
103
|
+
slugSpinner.fail(`${chalk.cyan(`w42/${slugPart}`)} is already taken — choose another`);
|
|
112
104
|
continue;
|
|
113
105
|
}
|
|
114
106
|
slugSpinner.stop();
|
|
@@ -116,7 +108,7 @@ export const registerCommand = new Command("register")
|
|
|
116
108
|
catch {
|
|
117
109
|
slugSpinner.warn("Could not verify slug — proceeding anyway");
|
|
118
110
|
}
|
|
119
|
-
console.log(chalk.dim(` Full slug:
|
|
111
|
+
console.log(chalk.dim(` Full slug: w42/${slugPart}`));
|
|
120
112
|
break;
|
|
121
113
|
}
|
|
122
114
|
// ── Step 5: POST ───────────────────────────────────────────────────────
|
|
@@ -130,15 +122,14 @@ export const registerCommand = new Command("register")
|
|
|
130
122
|
const data = await apiPost("/api/agents", body);
|
|
131
123
|
const slug = data.agent?.slug ?? "unknown";
|
|
132
124
|
const name = data.agent?.agent_card?.name ?? agentCard.name ?? slug;
|
|
133
|
-
const displaySlug = slug.replace("~", "/");
|
|
134
125
|
if (data.created) {
|
|
135
|
-
registerSpinner.succeed(`Registered "${name}" (${
|
|
126
|
+
registerSpinner.succeed(`Registered "${name}" (${slug})`);
|
|
136
127
|
}
|
|
137
128
|
else {
|
|
138
|
-
registerSpinner.succeed(`Updated "${name}" (${
|
|
129
|
+
registerSpinner.succeed(`Updated "${name}" (${slug})`);
|
|
139
130
|
}
|
|
140
131
|
console.log(chalk.dim(` Send: w42 send ${slug} "hello"`));
|
|
141
|
-
console.log(chalk.dim(` View: ${cfg.apiUrl}/${
|
|
132
|
+
console.log(chalk.dim(` View: ${cfg.apiUrl}/${slug}`));
|
|
142
133
|
}
|
|
143
134
|
catch (err) {
|
|
144
135
|
registerSpinner.fail("Registration failed");
|
package/dist/commands/search.js
CHANGED
|
@@ -59,6 +59,25 @@ function formatSkills(skills) {
|
|
|
59
59
|
const skillNames = skills.map((s) => `${s.name}`);
|
|
60
60
|
return `Skills: ${skillNames.join(" • ")}`;
|
|
61
61
|
}
|
|
62
|
+
function getSecurityIndicator(card) {
|
|
63
|
+
const security = card?.security;
|
|
64
|
+
if (!security || security.length === 0)
|
|
65
|
+
return "";
|
|
66
|
+
const isWeb42 = security.some((req) => "Web42Bearer" in req);
|
|
67
|
+
return isWeb42 ? chalk.green("🛡") : chalk.dim("🛡");
|
|
68
|
+
}
|
|
69
|
+
function getPaymentIndicator(card) {
|
|
70
|
+
const exts = card?.capabilities?.extensions;
|
|
71
|
+
if (!exts)
|
|
72
|
+
return "";
|
|
73
|
+
const hasPayment = exts.some((e) => e.uri.includes("payments"));
|
|
74
|
+
if (!hasPayment)
|
|
75
|
+
return "";
|
|
76
|
+
// Check for Web42 payments (has client_id in network extension)
|
|
77
|
+
const networkExt = card?.capabilities?.extensions?.find((e) => e.uri === "https://web42.ai/ext/network/v1");
|
|
78
|
+
const clientId = networkExt?.params?.client_id;
|
|
79
|
+
return clientId ? chalk.blue("💳") : chalk.dim("💳");
|
|
80
|
+
}
|
|
62
81
|
export const searchCommand = new Command("search")
|
|
63
82
|
.description("Search the network for agents")
|
|
64
83
|
.argument("<query>", "Search query")
|
|
@@ -83,11 +102,14 @@ export const searchCommand = new Command("search")
|
|
|
83
102
|
const description = getCardDescription(agent.agent_card);
|
|
84
103
|
const stars = agent.stars_count > 0 ? `★ ${agent.stars_count}` : "";
|
|
85
104
|
const skills = formatSkills(agent.agent_card.skills);
|
|
86
|
-
// Header: - <name (link)> | <slug> | <stars>
|
|
87
|
-
const nameLink = chalk.bold.cyan(terminalLink(name, `${config.apiUrl}/${agent.slug
|
|
105
|
+
// Header: - <name (link)> | <slug> | <badges> | <stars>
|
|
106
|
+
const nameLink = chalk.bold.cyan(terminalLink(name, `${config.apiUrl}/${agent.slug}`));
|
|
88
107
|
const slugLabel = chalk.dim(agent.slug);
|
|
89
108
|
const separator = chalk.dim(" | ");
|
|
109
|
+
const badges = [getSecurityIndicator(agent.agent_card), getPaymentIndicator(agent.agent_card)].filter(Boolean).join(" ");
|
|
90
110
|
const headerParts = [nameLink, slugLabel];
|
|
111
|
+
if (badges)
|
|
112
|
+
headerParts.push(badges);
|
|
91
113
|
if (stars)
|
|
92
114
|
headerParts.push(chalk.yellow(stars));
|
|
93
115
|
console.log(`- ${headerParts.join(separator)}`);
|
package/dist/commands/send.js
CHANGED
|
@@ -131,10 +131,8 @@ export const sendCommand = new Command("send")
|
|
|
131
131
|
.option("--task-id <id>", "Reply to a specific task (e.g. one in input-required state)")
|
|
132
132
|
.option("--pay <tx_id>", "Attach PaymentMandate from a transaction (use tx ID from w42 cart list)")
|
|
133
133
|
.action(async (rawAgent, userMessage, opts) => {
|
|
134
|
-
//
|
|
135
|
-
const agent = rawAgent
|
|
136
|
-
? rawAgent.replace("/", "~")
|
|
137
|
-
: rawAgent;
|
|
134
|
+
// Agent slug can be provided directly (no conversion needed)
|
|
135
|
+
const agent = rawAgent;
|
|
138
136
|
const config = requireAuth();
|
|
139
137
|
let agentUrl;
|
|
140
138
|
let bearerToken;
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const CLI_VERSION = "0.1.
|
|
1
|
+
export declare const CLI_VERSION = "0.1.23";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const CLI_VERSION = "0.1.
|
|
1
|
+
export const CLI_VERSION = "0.1.23";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@web42/w42",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.23",
|
|
4
4
|
"description": "CLI for the Web42 Agent Network — discover, register, and communicate with A2A agents",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"ora": "^8.1.0",
|
|
19
19
|
"uuid": "^13.0.0",
|
|
20
20
|
"zod": "^3.22.4",
|
|
21
|
-
"@web42/auth": "0.
|
|
21
|
+
"@web42/auth": "0.2.0"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
24
|
"@types/express": "^5.0.6",
|