@web42/cli 0.2.7 → 0.2.9
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/search.js +20 -15
- package/dist/commands/send.js +75 -41
- package/dist/commands/serve.d.ts +1 -1
- package/dist/commands/serve.js +160 -114
- package/dist/index.js +1 -19
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
- package/dist/commands/config.d.ts +0 -2
- package/dist/commands/config.js +0 -27
- package/dist/commands/init.d.ts +0 -2
- package/dist/commands/init.js +0 -451
- package/dist/commands/install.d.ts +0 -3
- package/dist/commands/install.js +0 -231
- package/dist/commands/list.d.ts +0 -3
- package/dist/commands/list.js +0 -22
- package/dist/commands/pack.d.ts +0 -2
- package/dist/commands/pack.js +0 -210
- package/dist/commands/pull.d.ts +0 -2
- package/dist/commands/pull.js +0 -202
- package/dist/commands/push.d.ts +0 -2
- package/dist/commands/push.js +0 -374
- package/dist/commands/remix.d.ts +0 -2
- package/dist/commands/remix.js +0 -49
- package/dist/commands/sync.d.ts +0 -2
- package/dist/commands/sync.js +0 -98
- package/dist/commands/uninstall.d.ts +0 -3
- package/dist/commands/uninstall.js +0 -54
- package/dist/commands/update.d.ts +0 -3
- package/dist/commands/update.js +0 -59
- package/dist/platforms/base.d.ts +0 -82
- package/dist/platforms/base.js +0 -1
- package/dist/platforms/claude/__tests__/adapter.test.d.ts +0 -1
- package/dist/platforms/claude/__tests__/adapter.test.js +0 -257
- package/dist/platforms/claude/__tests__/security.test.d.ts +0 -1
- package/dist/platforms/claude/__tests__/security.test.js +0 -166
- package/dist/platforms/claude/adapter.d.ts +0 -34
- package/dist/platforms/claude/adapter.js +0 -525
- package/dist/platforms/claude/security.d.ts +0 -15
- package/dist/platforms/claude/security.js +0 -67
- package/dist/platforms/claude/templates.d.ts +0 -5
- package/dist/platforms/claude/templates.js +0 -22
- package/dist/platforms/openclaw/adapter.d.ts +0 -12
- package/dist/platforms/openclaw/adapter.js +0 -476
- package/dist/platforms/openclaw/templates.d.ts +0 -7
- package/dist/platforms/openclaw/templates.js +0 -369
- package/dist/platforms/registry.d.ts +0 -6
- package/dist/platforms/registry.js +0 -32
- package/dist/types/sync.d.ts +0 -74
- package/dist/types/sync.js +0 -7
- package/dist/utils/bundled-skills.d.ts +0 -6
- package/dist/utils/bundled-skills.js +0 -29
- package/dist/utils/secrets.d.ts +0 -32
- package/dist/utils/secrets.js +0 -118
- package/dist/utils/skill.d.ts +0 -6
- package/dist/utils/skill.js +0 -42
- package/dist/utils/sync.d.ts +0 -14
- package/dist/utils/sync.js +0 -242
package/dist/commands/serve.js
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import { existsSync, readFileSync } from
|
|
2
|
-
import { join } from
|
|
3
|
-
import { Command } from
|
|
4
|
-
import chalk from
|
|
5
|
-
import ora from
|
|
6
|
-
import express from
|
|
7
|
-
import { agentCardHandler, jsonRpcHandler, } from
|
|
8
|
-
import { DefaultRequestHandler, InMemoryTaskStore, } from
|
|
9
|
-
import { requireAuth } from
|
|
10
|
-
import { getConfig } from '../utils/config.js';
|
|
1
|
+
import { existsSync, readFileSync } from "fs";
|
|
2
|
+
import { join } from "path";
|
|
3
|
+
import { Command } from "commander";
|
|
4
|
+
import chalk from "chalk";
|
|
5
|
+
import ora from "ora";
|
|
6
|
+
import express from "express";
|
|
7
|
+
import { agentCardHandler, jsonRpcHandler, } from "@a2a-js/sdk/server/express";
|
|
8
|
+
import { DefaultRequestHandler, InMemoryTaskStore, } from "@a2a-js/sdk/server";
|
|
9
|
+
import { requireAuth, getConfig } from "../utils/config.js";
|
|
11
10
|
class OpenClawAgentExecutor {
|
|
12
11
|
opts;
|
|
13
12
|
verbose;
|
|
@@ -18,7 +17,7 @@ class OpenClawAgentExecutor {
|
|
|
18
17
|
async execute(requestContext, eventBus) {
|
|
19
18
|
const { taskId, contextId, userMessage } = requestContext;
|
|
20
19
|
const userText = userMessage.parts
|
|
21
|
-
.find((p) => p.kind ===
|
|
20
|
+
.find((p) => p.kind === "text")?.text ?? "";
|
|
22
21
|
if (this.verbose) {
|
|
23
22
|
console.log(chalk.gray(`[verbose] → OpenClaw request: agent=${this.opts.openClawAgent} session=${contextId} port=${this.opts.openClawPort}`));
|
|
24
23
|
console.log(chalk.gray(`[verbose] → message text: "${userText.slice(0, 100)}"`));
|
|
@@ -26,17 +25,17 @@ class OpenClawAgentExecutor {
|
|
|
26
25
|
let response;
|
|
27
26
|
try {
|
|
28
27
|
response = await fetch(`http://localhost:${this.opts.openClawPort}/v1/chat/completions`, {
|
|
29
|
-
method:
|
|
28
|
+
method: "POST",
|
|
30
29
|
headers: {
|
|
31
30
|
Authorization: `Bearer ${this.opts.openClawToken}`,
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
31
|
+
"Content-Type": "application/json",
|
|
32
|
+
"x-openclaw-agent-id": this.opts.openClawAgent,
|
|
33
|
+
"x-openclaw-session-key": `agent:${this.opts.openClawAgent}:${contextId}`,
|
|
35
34
|
},
|
|
36
35
|
body: JSON.stringify({
|
|
37
|
-
model:
|
|
36
|
+
model: "openclaw",
|
|
38
37
|
stream: true,
|
|
39
|
-
messages: [{ role:
|
|
38
|
+
messages: [{ role: "user", content: userText }],
|
|
40
39
|
}),
|
|
41
40
|
});
|
|
42
41
|
}
|
|
@@ -49,27 +48,27 @@ class OpenClawAgentExecutor {
|
|
|
49
48
|
}
|
|
50
49
|
if (!response.ok) {
|
|
51
50
|
if (this.verbose) {
|
|
52
|
-
const body = await response.text().catch(() =>
|
|
51
|
+
const body = await response.text().catch(() => "(unreadable)");
|
|
53
52
|
console.log(chalk.gray(`[verbose] ← response body: ${body}`));
|
|
54
53
|
}
|
|
55
54
|
throw new Error(`OpenClaw error: ${response.status} ${response.statusText}`);
|
|
56
55
|
}
|
|
57
56
|
const reader = response.body.getReader();
|
|
58
57
|
const decoder = new TextDecoder();
|
|
59
|
-
let buffer =
|
|
58
|
+
let buffer = "";
|
|
60
59
|
let tokenCount = 0;
|
|
61
60
|
while (true) {
|
|
62
61
|
const { done, value } = await reader.read();
|
|
63
62
|
if (done)
|
|
64
63
|
break;
|
|
65
64
|
buffer += decoder.decode(value, { stream: true });
|
|
66
|
-
const lines = buffer.split(
|
|
67
|
-
buffer = lines.pop() ??
|
|
65
|
+
const lines = buffer.split("\n");
|
|
66
|
+
buffer = lines.pop() ?? "";
|
|
68
67
|
for (const line of lines) {
|
|
69
|
-
if (!line.startsWith(
|
|
68
|
+
if (!line.startsWith("data: "))
|
|
70
69
|
continue;
|
|
71
70
|
const data = line.slice(6).trim();
|
|
72
|
-
if (data ===
|
|
71
|
+
if (data === "[DONE]")
|
|
73
72
|
continue;
|
|
74
73
|
try {
|
|
75
74
|
const chunk = JSON.parse(data);
|
|
@@ -77,12 +76,12 @@ class OpenClawAgentExecutor {
|
|
|
77
76
|
if (token) {
|
|
78
77
|
tokenCount++;
|
|
79
78
|
eventBus.publish({
|
|
80
|
-
kind:
|
|
79
|
+
kind: "artifact-update",
|
|
81
80
|
taskId,
|
|
82
81
|
contextId,
|
|
83
82
|
artifact: {
|
|
84
|
-
artifactId:
|
|
85
|
-
parts: [{ kind:
|
|
83
|
+
artifactId: "response",
|
|
84
|
+
parts: [{ kind: "text", text: token }],
|
|
86
85
|
},
|
|
87
86
|
});
|
|
88
87
|
}
|
|
@@ -96,10 +95,10 @@ class OpenClawAgentExecutor {
|
|
|
96
95
|
console.log(chalk.gray(`[verbose] ← stream complete: ${tokenCount} tokens received`));
|
|
97
96
|
}
|
|
98
97
|
eventBus.publish({
|
|
99
|
-
kind:
|
|
98
|
+
kind: "status-update",
|
|
100
99
|
taskId,
|
|
101
100
|
contextId,
|
|
102
|
-
status: { state:
|
|
101
|
+
status: { state: "completed", timestamp: new Date().toISOString() },
|
|
103
102
|
final: true,
|
|
104
103
|
});
|
|
105
104
|
eventBus.finished();
|
|
@@ -112,35 +111,37 @@ class OpenClawAgentExecutor {
|
|
|
112
111
|
async function publishLiveUrl({ apiUrl, token, slug, a2aUrl, enabled, gatewayStatus, }) {
|
|
113
112
|
try {
|
|
114
113
|
const res = await fetch(`${apiUrl}/api/agents/${slug}/a2a`, {
|
|
115
|
-
method:
|
|
114
|
+
method: "POST",
|
|
116
115
|
headers: {
|
|
117
116
|
Authorization: `Bearer ${token}`,
|
|
118
|
-
|
|
117
|
+
"Content-Type": "application/json",
|
|
119
118
|
},
|
|
120
119
|
body: JSON.stringify({ a2a_url: a2aUrl, a2a_enabled: enabled, gateway_status: gatewayStatus }),
|
|
121
120
|
});
|
|
122
121
|
if (!res.ok) {
|
|
123
|
-
console.warn(chalk.yellow(
|
|
122
|
+
console.warn(chalk.yellow(` Could not register URL with marketplace: ${res.status}`));
|
|
124
123
|
}
|
|
125
124
|
else {
|
|
126
|
-
console.log(chalk.dim(
|
|
125
|
+
console.log(chalk.dim(" Registered with marketplace"));
|
|
127
126
|
}
|
|
128
127
|
}
|
|
129
128
|
catch (err) {
|
|
130
|
-
console.warn(chalk.yellow(
|
|
129
|
+
console.warn(chalk.yellow(` Could not register URL with marketplace: ${String(err)}`));
|
|
131
130
|
}
|
|
132
131
|
}
|
|
133
132
|
// ---------------------------------------------------------------------------
|
|
134
133
|
// Command
|
|
135
134
|
// ---------------------------------------------------------------------------
|
|
136
|
-
export const serveCommand = new Command(
|
|
137
|
-
.description(
|
|
138
|
-
.option(
|
|
139
|
-
.option(
|
|
140
|
-
.option(
|
|
141
|
-
.option(
|
|
142
|
-
.option(
|
|
143
|
-
.option(
|
|
135
|
+
export const serveCommand = new Command("serve")
|
|
136
|
+
.description("Start a local A2A server for your agent")
|
|
137
|
+
.option("--port <port>", "Port to listen on", "4000")
|
|
138
|
+
.option("--url <url>", "Public URL (e.g. from ngrok) for registration and AgentCard")
|
|
139
|
+
.option("--openclaw-port <port>", "OpenClaw gateway port", "18789")
|
|
140
|
+
.option("--openclaw-token <token>", "OpenClaw gateway auth token (or set OPENCLAW_GATEWAY_TOKEN)")
|
|
141
|
+
.option("--openclaw-agent <id>", "OpenClaw agent ID to target", "main")
|
|
142
|
+
.option("--client-id <id>", "Developer app client ID (or set WEB42_CLIENT_ID)")
|
|
143
|
+
.option("--client-secret <secret>", "Developer app client secret (or set WEB42_CLIENT_SECRET)")
|
|
144
|
+
.option("--verbose", "Enable verbose request/response logging")
|
|
144
145
|
.action(async (opts) => {
|
|
145
146
|
const verbose = opts.verbose ?? false;
|
|
146
147
|
// 1. Must be logged into web42
|
|
@@ -150,131 +151,176 @@ export const serveCommand = new Command('serve')
|
|
|
150
151
|
token = authConfig.token;
|
|
151
152
|
}
|
|
152
153
|
catch {
|
|
153
|
-
console.error(chalk.red(
|
|
154
|
+
console.error(chalk.red("Not authenticated. Run `web42 auth login` first."));
|
|
155
|
+
process.exit(1);
|
|
156
|
+
}
|
|
157
|
+
const clientId = opts.clientId ?? process.env.WEB42_CLIENT_ID;
|
|
158
|
+
const clientSecret = opts.clientSecret ?? process.env.WEB42_CLIENT_SECRET;
|
|
159
|
+
if (!clientId || !clientSecret) {
|
|
160
|
+
console.error(chalk.red("Developer app credentials required.\n" +
|
|
161
|
+
" Provide --client-id and --client-secret flags,\n" +
|
|
162
|
+
" or set WEB42_CLIENT_ID and WEB42_CLIENT_SECRET env vars.\n" +
|
|
163
|
+
" Create them at: https://web42.ai/settings/developer-apps"));
|
|
154
164
|
process.exit(1);
|
|
155
165
|
}
|
|
156
|
-
const cwd = process.cwd();
|
|
157
|
-
const port = parseInt(opts.port, 10);
|
|
158
166
|
const openClawPort = parseInt(opts.openclawPort, 10);
|
|
159
|
-
const openClawToken = opts.openclawToken ?? process.env.OPENCLAW_GATEWAY_TOKEN ??
|
|
167
|
+
const openClawToken = opts.openclawToken ?? process.env.OPENCLAW_GATEWAY_TOKEN ?? "";
|
|
160
168
|
const openClawAgent = opts.openclawAgent;
|
|
169
|
+
const cwd = process.cwd();
|
|
170
|
+
const port = parseInt(opts.port, 10);
|
|
161
171
|
const publicUrl = opts.url;
|
|
162
|
-
|
|
163
|
-
const
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
172
|
+
const config = getConfig();
|
|
173
|
+
const web42ApiUrl = config.apiUrl ?? "https://web42.ai";
|
|
174
|
+
// 2. Read agent-card.json from cwd
|
|
175
|
+
const cardPath = join(cwd, "agent-card.json");
|
|
176
|
+
if (!existsSync(cardPath)) {
|
|
177
|
+
console.error(chalk.red("No agent-card.json found in current directory."));
|
|
178
|
+
console.error(chalk.dim("Create an agent-card.json with your agent's A2A card."));
|
|
167
179
|
process.exit(1);
|
|
168
180
|
}
|
|
169
|
-
let
|
|
181
|
+
let cardData;
|
|
170
182
|
try {
|
|
171
|
-
|
|
183
|
+
cardData = JSON.parse(readFileSync(cardPath, "utf-8"));
|
|
172
184
|
}
|
|
173
185
|
catch {
|
|
174
|
-
console.error(chalk.red(
|
|
186
|
+
console.error(chalk.red("Failed to parse agent-card.json."));
|
|
175
187
|
process.exit(1);
|
|
176
188
|
}
|
|
177
|
-
|
|
178
|
-
|
|
189
|
+
const agentName = cardData.name ?? "Untitled Agent";
|
|
190
|
+
if (!agentName || agentName === "Untitled Agent") {
|
|
191
|
+
console.error(chalk.red('agent-card.json must have a "name" field.'));
|
|
179
192
|
process.exit(1);
|
|
180
193
|
}
|
|
181
|
-
const
|
|
182
|
-
|
|
183
|
-
const spinner = ora('Starting A2A server...').start();
|
|
184
|
-
// 3. Build AgentCard from manifest
|
|
194
|
+
const spinner = ora("Starting A2A server...").start();
|
|
195
|
+
// 3. Build AgentCard from local file + overrides
|
|
185
196
|
const agentCard = {
|
|
186
|
-
name:
|
|
187
|
-
description:
|
|
188
|
-
protocolVersion:
|
|
189
|
-
version:
|
|
197
|
+
name: agentName,
|
|
198
|
+
description: cardData.description ?? "",
|
|
199
|
+
protocolVersion: cardData.protocolVersion ?? "0.3.0",
|
|
200
|
+
version: cardData.version ?? "1.0.0",
|
|
190
201
|
url: `${publicUrl ?? `http://localhost:${port}`}/a2a/jsonrpc`,
|
|
191
|
-
skills:
|
|
192
|
-
id: s.name.toLowerCase().replace(/\s+/g, '-'),
|
|
193
|
-
name: s.name,
|
|
194
|
-
description: s.description ?? '',
|
|
195
|
-
tags: [],
|
|
196
|
-
})),
|
|
202
|
+
skills: cardData.skills ?? [],
|
|
197
203
|
capabilities: {
|
|
198
204
|
streaming: true,
|
|
199
205
|
pushNotifications: false,
|
|
206
|
+
...(cardData.capabilities ?? {}),
|
|
200
207
|
},
|
|
201
|
-
defaultInputModes: [
|
|
202
|
-
defaultOutputModes: [
|
|
208
|
+
defaultInputModes: cardData.defaultInputModes ?? ["text"],
|
|
209
|
+
defaultOutputModes: cardData.defaultOutputModes ?? ["text"],
|
|
203
210
|
securitySchemes: {
|
|
204
|
-
Web42Bearer: { type:
|
|
211
|
+
Web42Bearer: { type: "http", scheme: "bearer" },
|
|
205
212
|
},
|
|
206
213
|
security: [{ Web42Bearer: [] }],
|
|
207
214
|
};
|
|
208
215
|
// 4. Start Express server
|
|
209
216
|
const app = express();
|
|
210
|
-
// Auth: validate caller's
|
|
217
|
+
// Auth: validate caller's Bearer token via Web42 introspection with Basic auth
|
|
218
|
+
const basicAuth = `Basic ${Buffer.from(`${clientId}:${clientSecret}`).toString("base64")}`;
|
|
211
219
|
const userBuilder = async (req) => {
|
|
212
|
-
const callerToken = req.headers.authorization?.split(
|
|
220
|
+
const callerToken = req.headers.authorization?.split(" ")[1];
|
|
213
221
|
if (!callerToken)
|
|
214
|
-
throw new Error(
|
|
222
|
+
throw new Error("Missing token");
|
|
215
223
|
if (verbose) {
|
|
216
|
-
|
|
217
|
-
console.log(chalk.gray(`[verbose] userBuilder: token=${masked} → introspecting...`));
|
|
224
|
+
console.log(chalk.gray(`[verbose] Introspecting token ${callerToken.slice(0, 8)}...`));
|
|
218
225
|
}
|
|
219
226
|
const res = await fetch(`${web42ApiUrl}/api/auth/introspect`, {
|
|
220
|
-
method:
|
|
221
|
-
headers: {
|
|
222
|
-
|
|
227
|
+
method: "POST",
|
|
228
|
+
headers: {
|
|
229
|
+
Authorization: basicAuth,
|
|
230
|
+
"Content-Type": "application/x-www-form-urlencoded",
|
|
231
|
+
},
|
|
232
|
+
body: new URLSearchParams({ token: callerToken }),
|
|
223
233
|
});
|
|
224
234
|
if (!res.ok)
|
|
225
|
-
throw new Error(
|
|
235
|
+
throw new Error("Introspect call failed");
|
|
226
236
|
const result = (await res.json());
|
|
227
237
|
if (verbose) {
|
|
228
|
-
console.log(chalk.gray(`[verbose]
|
|
238
|
+
console.log(chalk.gray(`[verbose] active=${result.active} sub=${result.sub ?? "(none)"}`));
|
|
229
239
|
}
|
|
230
240
|
if (!result.active)
|
|
231
|
-
throw new Error(
|
|
232
|
-
const userId = result.sub ?? '';
|
|
241
|
+
throw new Error("Unauthorized");
|
|
233
242
|
return {
|
|
234
243
|
get isAuthenticated() { return true; },
|
|
235
|
-
get userName() { return
|
|
244
|
+
get userName() { return result.sub ?? ""; },
|
|
236
245
|
};
|
|
237
246
|
};
|
|
238
|
-
const executor = new OpenClawAgentExecutor({
|
|
247
|
+
const executor = new OpenClawAgentExecutor({
|
|
248
|
+
openClawPort,
|
|
249
|
+
openClawToken,
|
|
250
|
+
openClawAgent,
|
|
251
|
+
verbose,
|
|
252
|
+
});
|
|
239
253
|
const requestHandler = new DefaultRequestHandler(agentCard, new InMemoryTaskStore(), executor);
|
|
240
254
|
// 5. Mount A2A SDK handlers
|
|
241
|
-
app.use(
|
|
242
|
-
app.use(
|
|
255
|
+
app.use("/.well-known/agent-card.json", agentCardHandler({ agentCardProvider: requestHandler }));
|
|
256
|
+
app.use("/a2a/jsonrpc", jsonRpcHandler({ requestHandler, userBuilder }));
|
|
243
257
|
const a2aUrl = `${publicUrl ?? `http://localhost:${port}`}/a2a/jsonrpc`;
|
|
244
|
-
// 6. Start listening
|
|
258
|
+
// 6. Start listening, then register
|
|
245
259
|
app.listen(port, async () => {
|
|
246
260
|
spinner.stop();
|
|
247
|
-
console.log(chalk.green(`\n
|
|
248
|
-
console.log(chalk.dim(` Local:
|
|
261
|
+
console.log(chalk.green(`\n Agent "${agentName}" is live`));
|
|
262
|
+
console.log(chalk.dim(` Local: http://localhost:${port}`));
|
|
249
263
|
if (publicUrl)
|
|
250
|
-
console.log(chalk.dim(` Public:
|
|
264
|
+
console.log(chalk.dim(` Public: ${publicUrl}`));
|
|
251
265
|
console.log(chalk.dim(` Agent card: http://localhost:${port}/.well-known/agent-card.json`));
|
|
252
266
|
console.log(chalk.dim(` JSON-RPC: http://localhost:${port}/a2a/jsonrpc`));
|
|
253
267
|
if (verbose) {
|
|
254
|
-
console.log(chalk.gray(`[verbose]
|
|
255
|
-
|
|
268
|
+
console.log(chalk.gray(`[verbose] OpenClaw target: http://localhost:${openClawPort}/v1/chat/completions agent=${openClawAgent}`));
|
|
269
|
+
}
|
|
270
|
+
// Register agent with marketplace — API crawls back to fetch the card
|
|
271
|
+
const registrationUrl = publicUrl ?? `http://localhost:${port}`;
|
|
272
|
+
let registeredSlug = null;
|
|
273
|
+
try {
|
|
274
|
+
const regRes = await fetch(`${web42ApiUrl}/api/agents`, {
|
|
275
|
+
method: "POST",
|
|
276
|
+
headers: {
|
|
277
|
+
Authorization: `Bearer ${token}`,
|
|
278
|
+
"Content-Type": "application/json",
|
|
279
|
+
},
|
|
280
|
+
body: JSON.stringify({ url: registrationUrl }),
|
|
281
|
+
});
|
|
282
|
+
if (regRes.ok) {
|
|
283
|
+
const regData = (await regRes.json());
|
|
284
|
+
registeredSlug = regData.agent?.slug ?? null;
|
|
285
|
+
console.log(chalk.dim(` Registered with marketplace (slug: ${registeredSlug})`));
|
|
286
|
+
}
|
|
287
|
+
else {
|
|
288
|
+
const errBody = await regRes.json().catch(() => ({}));
|
|
289
|
+
console.warn(chalk.yellow(` Could not register with marketplace: ${errBody.error ?? regRes.status}`));
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
catch (err) {
|
|
293
|
+
console.warn(chalk.yellow(` Could not register with marketplace: ${String(err)}`));
|
|
294
|
+
}
|
|
295
|
+
// Publish live A2A URL
|
|
296
|
+
if (registeredSlug) {
|
|
297
|
+
await publishLiveUrl({
|
|
298
|
+
apiUrl: web42ApiUrl,
|
|
299
|
+
token,
|
|
300
|
+
slug: registeredSlug,
|
|
301
|
+
a2aUrl,
|
|
302
|
+
enabled: true,
|
|
303
|
+
gatewayStatus: "live",
|
|
304
|
+
});
|
|
256
305
|
}
|
|
257
|
-
await publishLiveUrl({
|
|
258
|
-
apiUrl: web42ApiUrl,
|
|
259
|
-
token,
|
|
260
|
-
slug: manifest.name,
|
|
261
|
-
a2aUrl,
|
|
262
|
-
enabled: true,
|
|
263
|
-
gatewayStatus: 'live',
|
|
264
|
-
});
|
|
265
306
|
if (!publicUrl) {
|
|
266
|
-
console.log(chalk.yellow(
|
|
307
|
+
console.log(chalk.yellow(" No --url provided. Registered localhost URL is not publicly reachable."));
|
|
267
308
|
}
|
|
268
|
-
console.log(chalk.dim(
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
309
|
+
console.log(chalk.dim("\nWaiting for requests... (Ctrl+C to stop)\n"));
|
|
310
|
+
// 7. Graceful shutdown
|
|
311
|
+
process.on("SIGINT", async () => {
|
|
312
|
+
console.log(chalk.dim("\nShutting down..."));
|
|
313
|
+
if (registeredSlug) {
|
|
314
|
+
await publishLiveUrl({
|
|
315
|
+
apiUrl: web42ApiUrl,
|
|
316
|
+
token,
|
|
317
|
+
slug: registeredSlug,
|
|
318
|
+
a2aUrl: null,
|
|
319
|
+
enabled: false,
|
|
320
|
+
gatewayStatus: "offline",
|
|
321
|
+
}).catch(() => { });
|
|
322
|
+
}
|
|
323
|
+
process.exit(0);
|
|
324
|
+
});
|
|
279
325
|
});
|
|
280
326
|
});
|
package/dist/index.js
CHANGED
|
@@ -1,23 +1,15 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { Command } from "commander";
|
|
3
3
|
import { authCommand } from "./commands/auth.js";
|
|
4
|
-
import { configCommand } from "./commands/config.js";
|
|
5
|
-
import { initCommand } from "./commands/init.js";
|
|
6
|
-
import { packCommand } from "./commands/pack.js";
|
|
7
|
-
import { pushCommand } from "./commands/push.js";
|
|
8
|
-
import { pullCommand } from "./commands/pull.js";
|
|
9
|
-
import { remixCommand } from "./commands/remix.js";
|
|
10
4
|
import { searchCommand } from "./commands/search.js";
|
|
11
5
|
import { sendCommand } from "./commands/send.js";
|
|
12
6
|
import { serveCommand } from "./commands/serve.js";
|
|
13
|
-
import { syncCommand } from "./commands/sync.js";
|
|
14
|
-
import { getAllPlatformCommands } from "./platforms/registry.js";
|
|
15
7
|
import { setApiUrl } from "./utils/config.js";
|
|
16
8
|
import { CLI_VERSION } from "./version.js";
|
|
17
9
|
const program = new Command();
|
|
18
10
|
program
|
|
19
11
|
.name("web42")
|
|
20
|
-
.description("Web42
|
|
12
|
+
.description("Web42 CLI — authenticate, discover, and communicate with A2A agents")
|
|
21
13
|
.version(CLI_VERSION)
|
|
22
14
|
.option("--api-url <url>", "Override the API URL for this invocation")
|
|
23
15
|
.hook("preAction", (thisCommand) => {
|
|
@@ -27,17 +19,7 @@ program
|
|
|
27
19
|
}
|
|
28
20
|
});
|
|
29
21
|
program.addCommand(authCommand);
|
|
30
|
-
program.addCommand(configCommand);
|
|
31
|
-
program.addCommand(initCommand);
|
|
32
|
-
program.addCommand(packCommand);
|
|
33
|
-
program.addCommand(pushCommand);
|
|
34
|
-
program.addCommand(pullCommand);
|
|
35
|
-
program.addCommand(remixCommand);
|
|
36
22
|
program.addCommand(searchCommand);
|
|
37
23
|
program.addCommand(sendCommand);
|
|
38
24
|
program.addCommand(serveCommand);
|
|
39
|
-
program.addCommand(syncCommand);
|
|
40
|
-
for (const platformCmd of getAllPlatformCommands()) {
|
|
41
|
-
program.addCommand(platformCmd);
|
|
42
|
-
}
|
|
43
25
|
program.parse();
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const CLI_VERSION = "0.2.
|
|
1
|
+
export declare const CLI_VERSION = "0.2.9";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const CLI_VERSION = "0.2.
|
|
1
|
+
export const CLI_VERSION = "0.2.9";
|
package/package.json
CHANGED
package/dist/commands/config.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { Command } from "commander";
|
|
2
|
-
import chalk from "chalk";
|
|
3
|
-
import { getConfig, setApiUrl } from "../utils/config.js";
|
|
4
|
-
export const configCommand = new Command("config").description("View or update CLI configuration");
|
|
5
|
-
configCommand
|
|
6
|
-
.command("show")
|
|
7
|
-
.description("Show the current configuration")
|
|
8
|
-
.action(() => {
|
|
9
|
-
const cfg = getConfig();
|
|
10
|
-
console.log(chalk.bold("Web42 CLI Configuration"));
|
|
11
|
-
console.log();
|
|
12
|
-
console.log(` API URL: ${chalk.cyan(cfg.apiUrl)}`);
|
|
13
|
-
console.log(` Authenticated: ${cfg.authenticated ? chalk.green("yes") : chalk.yellow("no")}`);
|
|
14
|
-
if (cfg.username) {
|
|
15
|
-
console.log(` User: ${chalk.cyan(`@${cfg.username}`)}`);
|
|
16
|
-
}
|
|
17
|
-
if (cfg.fullName) {
|
|
18
|
-
console.log(` Name: ${cfg.fullName}`);
|
|
19
|
-
}
|
|
20
|
-
});
|
|
21
|
-
configCommand
|
|
22
|
-
.command("set-url <url>")
|
|
23
|
-
.description("Persistently set the API URL (e.g. http://localhost:3000)")
|
|
24
|
-
.action((url) => {
|
|
25
|
-
setApiUrl(url);
|
|
26
|
-
console.log(chalk.green(`API URL set to ${chalk.bold(url)}`));
|
|
27
|
-
});
|
package/dist/commands/init.d.ts
DELETED