@web42/w42 0.1.22 → 0.1.25
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/auth.js +1 -1
- package/dist/commands/intent.js +1 -2
- package/dist/commands/register.js +1 -1
- package/dist/commands/search.js +24 -2
- package/dist/commands/send.js +1 -1
- package/dist/commands/serve.js +4 -6
- package/dist/index.js +1 -9
- package/dist/utils/api.js +3 -2
- package/dist/utils/config.d.ts +0 -2
- package/dist/utils/config.js +0 -5
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +2 -2
package/dist/commands/auth.js
CHANGED
|
@@ -15,7 +15,7 @@ authCommand
|
|
|
15
15
|
try {
|
|
16
16
|
await apiPost("/api/auth/cli", { action: "register", code });
|
|
17
17
|
spinner.stop();
|
|
18
|
-
const loginUrl =
|
|
18
|
+
const loginUrl = `https://web42.ai/login?cli_code=${code}`;
|
|
19
19
|
console.log();
|
|
20
20
|
console.log(chalk.bold("Open this URL in your browser to authenticate:"));
|
|
21
21
|
console.log();
|
package/dist/commands/intent.js
CHANGED
|
@@ -87,7 +87,6 @@ intentCommand
|
|
|
87
87
|
console.error(chalk.red("No username found. Please log in again."));
|
|
88
88
|
process.exit(1);
|
|
89
89
|
}
|
|
90
|
-
const baseUrl = cfg.apiUrl ?? "https://web42-network.vercel.app";
|
|
91
90
|
const params = new URLSearchParams({
|
|
92
91
|
nick: opts.nick,
|
|
93
92
|
agents: opts.agents,
|
|
@@ -100,6 +99,6 @@ intentCommand
|
|
|
100
99
|
params.set("budget", opts.budget);
|
|
101
100
|
if (opts.expires)
|
|
102
101
|
params.set("expires_at", opts.expires);
|
|
103
|
-
const url =
|
|
102
|
+
const url = `https://web42.ai/@${username}/intents/create?${params.toString()}`;
|
|
104
103
|
console.log(JSON.stringify({ url }, null, 2));
|
|
105
104
|
});
|
|
@@ -129,7 +129,7 @@ export const registerCommand = new Command("register")
|
|
|
129
129
|
registerSpinner.succeed(`Updated "${name}" (${slug})`);
|
|
130
130
|
}
|
|
131
131
|
console.log(chalk.dim(` Send: w42 send ${slug} "hello"`));
|
|
132
|
-
console.log(chalk.dim(` View:
|
|
132
|
+
console.log(chalk.dim(` View: https://web42.ai/${slug}`));
|
|
133
133
|
}
|
|
134
134
|
catch (err) {
|
|
135
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,
|
|
105
|
+
// Header: - <name (link)> | <slug> | <badges> | <stars>
|
|
106
|
+
const nameLink = chalk.bold.cyan(terminalLink(name, `https://web42.ai/${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
|
@@ -90,7 +90,7 @@ function handleTaskState(state, taskId) {
|
|
|
90
90
|
}
|
|
91
91
|
function submitMetric(slug, responseTimeMs, success) {
|
|
92
92
|
const cfg = getConfig();
|
|
93
|
-
fetch(
|
|
93
|
+
fetch(`https://web42.ai/api/agents/metrics`, {
|
|
94
94
|
method: "POST",
|
|
95
95
|
headers: {
|
|
96
96
|
"Content-Type": "application/json",
|
package/dist/commands/serve.js
CHANGED
|
@@ -68,9 +68,9 @@ class OpenClawAgentExecutor {
|
|
|
68
68
|
// ---------------------------------------------------------------------------
|
|
69
69
|
// Helpers
|
|
70
70
|
// ---------------------------------------------------------------------------
|
|
71
|
-
async function unregisterAgent({
|
|
71
|
+
async function unregisterAgent({ token, slug, }) {
|
|
72
72
|
try {
|
|
73
|
-
await fetch(
|
|
73
|
+
await fetch(`https://web42.ai/api/agents?slug=${encodeURIComponent(slug)}`, {
|
|
74
74
|
method: "DELETE",
|
|
75
75
|
headers: { Authorization: `Bearer ${token}` },
|
|
76
76
|
});
|
|
@@ -121,7 +121,6 @@ export const serveCommand = new Command("serve")
|
|
|
121
121
|
const port = parseInt(opts.port, 10);
|
|
122
122
|
const publicUrl = opts.url;
|
|
123
123
|
const config = getConfig();
|
|
124
|
-
const web42ApiUrl = config.apiUrl ?? "http://localhost:3000";
|
|
125
124
|
// 2. Read agent-card.json from cwd
|
|
126
125
|
const cardPath = join(cwd, "agent-card.json");
|
|
127
126
|
if (!existsSync(cardPath)) {
|
|
@@ -145,7 +144,6 @@ export const serveCommand = new Command("serve")
|
|
|
145
144
|
}
|
|
146
145
|
const spinner = ora("Starting A2A server...").start();
|
|
147
146
|
const web42Client = new Web42Client({
|
|
148
|
-
baseUrl: web42ApiUrl,
|
|
149
147
|
clientId,
|
|
150
148
|
clientSecret,
|
|
151
149
|
});
|
|
@@ -195,7 +193,7 @@ export const serveCommand = new Command("serve")
|
|
|
195
193
|
const registrationUrl = publicUrl ?? `http://localhost:${port}`;
|
|
196
194
|
let registeredSlug = null;
|
|
197
195
|
try {
|
|
198
|
-
const regRes = await fetch(
|
|
196
|
+
const regRes = await fetch(`https://web42.ai/api/agents`, {
|
|
199
197
|
method: "POST",
|
|
200
198
|
headers: {
|
|
201
199
|
Authorization: `Bearer ${token}`,
|
|
@@ -227,7 +225,7 @@ export const serveCommand = new Command("serve")
|
|
|
227
225
|
process.on("SIGINT", async () => {
|
|
228
226
|
console.log(chalk.dim("\nShutting down..."));
|
|
229
227
|
if (registeredSlug) {
|
|
230
|
-
await unregisterAgent({
|
|
228
|
+
await unregisterAgent({ token, slug: registeredSlug });
|
|
231
229
|
}
|
|
232
230
|
process.exit(0);
|
|
233
231
|
});
|
package/dist/index.js
CHANGED
|
@@ -8,20 +8,12 @@ import { searchCommand } from "./commands/search.js";
|
|
|
8
8
|
import { sendCommand } from "./commands/send.js";
|
|
9
9
|
import { serveCommand } from "./commands/serve.js";
|
|
10
10
|
import { telemetryCommand } from "./commands/telemetry.js";
|
|
11
|
-
import { setApiUrl } from "./utils/config.js";
|
|
12
11
|
import { CLI_VERSION } from "./version.js";
|
|
13
12
|
const program = new Command();
|
|
14
13
|
program
|
|
15
14
|
.name("w42")
|
|
16
15
|
.description("W42 CLI — discover, register, and talk to A2A agents on the Web42 Network")
|
|
17
|
-
.version(CLI_VERSION)
|
|
18
|
-
.option("--api-url <url>", "Override the API URL for this invocation")
|
|
19
|
-
.hook("preAction", (thisCommand) => {
|
|
20
|
-
const opts = thisCommand.opts();
|
|
21
|
-
if (opts.apiUrl) {
|
|
22
|
-
setApiUrl(opts.apiUrl);
|
|
23
|
-
}
|
|
24
|
-
});
|
|
16
|
+
.version(CLI_VERSION);
|
|
25
17
|
program.addCommand(authCommand);
|
|
26
18
|
program.addCommand(cartCommand);
|
|
27
19
|
program.addCommand(intentCommand);
|
package/dist/utils/api.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { getConfig } from "./config.js";
|
|
2
|
+
const API_BASE_URL = "https://web42.ai";
|
|
2
3
|
export async function apiRequest(path, options = {}) {
|
|
3
4
|
const config = getConfig();
|
|
4
|
-
const url = `${
|
|
5
|
+
const url = `${API_BASE_URL}${path}`;
|
|
5
6
|
const headers = {
|
|
6
7
|
"Content-Type": "application/json",
|
|
7
8
|
...options.headers,
|
|
@@ -65,7 +66,7 @@ export async function apiDelete(path) {
|
|
|
65
66
|
}
|
|
66
67
|
export async function apiFormData(path, formData) {
|
|
67
68
|
const config = getConfig();
|
|
68
|
-
const url = `${
|
|
69
|
+
const url = `${API_BASE_URL}${path}`;
|
|
69
70
|
const headers = {};
|
|
70
71
|
if (config.token) {
|
|
71
72
|
headers["Authorization"] = `Bearer ${config.token}`;
|
package/dist/utils/config.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
interface W42Config {
|
|
2
|
-
apiUrl: string;
|
|
3
2
|
userId?: string;
|
|
4
3
|
username?: string;
|
|
5
4
|
fullName?: string;
|
|
@@ -17,7 +16,6 @@ export declare function setAuth(data: {
|
|
|
17
16
|
avatarUrl?: string;
|
|
18
17
|
}): void;
|
|
19
18
|
export declare function clearAuth(): void;
|
|
20
|
-
export declare function setApiUrl(url: string): void;
|
|
21
19
|
export declare function isAuthenticated(): boolean;
|
|
22
20
|
export declare function requireAuth(): W42Config;
|
|
23
21
|
export declare function setConfigValue(key: string, value: string): void;
|
package/dist/utils/config.js
CHANGED
|
@@ -2,14 +2,12 @@ import Conf from "conf";
|
|
|
2
2
|
const config = new Conf({
|
|
3
3
|
projectName: "w42",
|
|
4
4
|
defaults: {
|
|
5
|
-
apiUrl: "https://web42-network.vercel.app",
|
|
6
5
|
authenticated: false,
|
|
7
6
|
telemetry: true,
|
|
8
7
|
},
|
|
9
8
|
});
|
|
10
9
|
export function getConfig() {
|
|
11
10
|
return {
|
|
12
|
-
apiUrl: config.get("apiUrl"),
|
|
13
11
|
userId: config.get("userId"),
|
|
14
12
|
username: config.get("username"),
|
|
15
13
|
fullName: config.get("fullName"),
|
|
@@ -36,9 +34,6 @@ export function clearAuth() {
|
|
|
36
34
|
config.delete("token");
|
|
37
35
|
config.set("authenticated", false);
|
|
38
36
|
}
|
|
39
|
-
export function setApiUrl(url) {
|
|
40
|
-
config.set("apiUrl", url);
|
|
41
|
-
}
|
|
42
37
|
export function isAuthenticated() {
|
|
43
38
|
return config.get("authenticated") === true && !!config.get("userId") && !!config.get("token");
|
|
44
39
|
}
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const CLI_VERSION = "0.1.
|
|
1
|
+
export declare const CLI_VERSION = "0.1.25";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const CLI_VERSION = "0.1.
|
|
1
|
+
export const CLI_VERSION = "0.1.25";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@web42/w42",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.25",
|
|
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",
|