@web42/cli 0.2.3 → 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/commands/serve.js +46 -3
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/dist/commands/serve.js
CHANGED
|
@@ -89,6 +89,30 @@ class OpenClawAgentExecutor {
|
|
|
89
89
|
cancelTask = async () => { };
|
|
90
90
|
}
|
|
91
91
|
// ---------------------------------------------------------------------------
|
|
92
|
+
// Helpers
|
|
93
|
+
// ---------------------------------------------------------------------------
|
|
94
|
+
async function publishLiveUrl({ apiUrl, token, slug, a2aUrl, enabled, gatewayStatus, }) {
|
|
95
|
+
try {
|
|
96
|
+
const res = await fetch(`${apiUrl}/api/agents/${slug}/a2a`, {
|
|
97
|
+
method: 'POST',
|
|
98
|
+
headers: {
|
|
99
|
+
Authorization: `Bearer ${token}`,
|
|
100
|
+
'Content-Type': 'application/json',
|
|
101
|
+
},
|
|
102
|
+
body: JSON.stringify({ a2a_url: a2aUrl, a2a_enabled: enabled, gateway_status: gatewayStatus }),
|
|
103
|
+
});
|
|
104
|
+
if (!res.ok) {
|
|
105
|
+
console.warn(chalk.yellow(`⚠ Could not register URL with marketplace: ${res.status}`));
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
console.log(chalk.dim(' Registered with marketplace ✓'));
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
catch (err) {
|
|
112
|
+
console.warn(chalk.yellow(`⚠ Could not register URL with marketplace: ${String(err)}`));
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
// ---------------------------------------------------------------------------
|
|
92
116
|
// Command
|
|
93
117
|
// ---------------------------------------------------------------------------
|
|
94
118
|
export const serveCommand = new Command('serve')
|
|
@@ -100,8 +124,10 @@ export const serveCommand = new Command('serve')
|
|
|
100
124
|
.option('--openclaw-agent <id>', 'OpenClaw agent ID to target', 'main')
|
|
101
125
|
.action(async (opts) => {
|
|
102
126
|
// 1. Must be logged into web42
|
|
127
|
+
let token;
|
|
103
128
|
try {
|
|
104
|
-
requireAuth();
|
|
129
|
+
const authConfig = requireAuth();
|
|
130
|
+
token = authConfig.token;
|
|
105
131
|
}
|
|
106
132
|
catch {
|
|
107
133
|
console.error(chalk.red('Not authenticated. Run `web42 auth login` first.'));
|
|
@@ -187,8 +213,9 @@ export const serveCommand = new Command('serve')
|
|
|
187
213
|
// 5. Mount A2A SDK handlers
|
|
188
214
|
app.use('/.well-known/agent-card.json', agentCardHandler({ agentCardProvider: requestHandler }));
|
|
189
215
|
app.use('/a2a/jsonrpc', jsonRpcHandler({ requestHandler, userBuilder }));
|
|
216
|
+
const a2aUrl = `${publicUrl ?? `http://localhost:${port}`}/a2a/jsonrpc`;
|
|
190
217
|
// 6. Start listening
|
|
191
|
-
app.listen(port, () => {
|
|
218
|
+
app.listen(port, async () => {
|
|
192
219
|
spinner.stop();
|
|
193
220
|
console.log(chalk.green(`\n✓ Agent "${manifest.name}" is live`));
|
|
194
221
|
console.log(chalk.dim(` Local: http://localhost:${port}`));
|
|
@@ -196,11 +223,27 @@ export const serveCommand = new Command('serve')
|
|
|
196
223
|
console.log(chalk.dim(` Public: ${publicUrl}`));
|
|
197
224
|
console.log(chalk.dim(` Agent card: http://localhost:${port}/.well-known/agent-card.json`));
|
|
198
225
|
console.log(chalk.dim(` JSON-RPC: http://localhost:${port}/a2a/jsonrpc`));
|
|
226
|
+
await publishLiveUrl({
|
|
227
|
+
apiUrl: web42ApiUrl,
|
|
228
|
+
token,
|
|
229
|
+
slug: manifest.name,
|
|
230
|
+
a2aUrl,
|
|
231
|
+
enabled: true,
|
|
232
|
+
gatewayStatus: 'live',
|
|
233
|
+
});
|
|
234
|
+
if (!publicUrl) {
|
|
235
|
+
console.log(chalk.yellow(' ⚠ No --url provided. Registered localhost URL is not publicly reachable; buyers cannot connect.'));
|
|
236
|
+
}
|
|
199
237
|
console.log(chalk.dim('\nWaiting for requests... (Ctrl+C to stop)\n'));
|
|
200
238
|
});
|
|
201
239
|
// 7. Keep process alive
|
|
202
|
-
process.on('SIGINT', () => {
|
|
240
|
+
process.on('SIGINT', async () => {
|
|
203
241
|
console.log(chalk.dim('\nShutting down...'));
|
|
242
|
+
await fetch(`${web42ApiUrl}/api/agents/${manifest.name}/a2a`, {
|
|
243
|
+
method: 'POST',
|
|
244
|
+
headers: { Authorization: `Bearer ${token}`, 'Content-Type': 'application/json' },
|
|
245
|
+
body: JSON.stringify({ a2a_url: null, a2a_enabled: false, gateway_status: 'offline' }),
|
|
246
|
+
}).catch(() => { }); // best-effort
|
|
204
247
|
process.exit(0);
|
|
205
248
|
});
|
|
206
249
|
});
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const CLI_VERSION = "0.2.
|
|
1
|
+
export declare const CLI_VERSION = "0.2.4";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const CLI_VERSION = "0.2.
|
|
1
|
+
export const CLI_VERSION = "0.2.4";
|