@zshuangmu/agenthub 0.4.11 → 0.4.13
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/package.json +1 -1
- package/src/api-server.js +2 -2
- package/src/cli.js +60 -1
- package/src/commands/api.js +2 -1
- package/src/commands/web.js +2 -1
- package/src/web-server.js +2 -2
package/package.json
CHANGED
package/src/api-server.js
CHANGED
|
@@ -66,7 +66,7 @@ function isValidSlug(slug) {
|
|
|
66
66
|
return /^[a-z0-9-]+$/.test(slug) && slug.length <= 100;
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
-
export async function createApiServer({ registryDir, port = 3000 }) {
|
|
69
|
+
export async function createApiServer({ registryDir, port = 3000, host = "0.0.0.0" }) {
|
|
70
70
|
// 初始化数据库
|
|
71
71
|
await initDatabase(registryDir);
|
|
72
72
|
|
|
@@ -228,7 +228,7 @@ export async function createApiServer({ registryDir, port = 3000 }) {
|
|
|
228
228
|
});
|
|
229
229
|
|
|
230
230
|
startRateLimiterCleanup();
|
|
231
|
-
await new Promise((resolve) => server.listen(port,
|
|
231
|
+
await new Promise((resolve) => server.listen(port, host, resolve));
|
|
232
232
|
const address = server.address();
|
|
233
233
|
const actualPort = typeof address === "object" && address ? address.port : port;
|
|
234
234
|
|
package/src/cli.js
CHANGED
|
@@ -258,6 +258,34 @@ agenthub rollback - 回滚 Agent 到指定版本
|
|
|
258
258
|
示例:
|
|
259
259
|
agenthub rollback workspace --to 1.0.0 --registry ./.registry --target-workspace ./my-workspace
|
|
260
260
|
agenthub rollback workspace --to 1.0.0 --server https://agenthub.cyou --target-workspace ./my-workspace
|
|
261
|
+
`,
|
|
262
|
+
info: `
|
|
263
|
+
agenthub info - 查看 Agent 详情
|
|
264
|
+
|
|
265
|
+
用法:
|
|
266
|
+
agenthub info <agent-slug> [--registry <dir> | --server <url>]
|
|
267
|
+
|
|
268
|
+
选项:
|
|
269
|
+
--registry <dir> 本地 Registry 目录(与 --server 二选一)
|
|
270
|
+
--server <url> 远程服务器地址(默认: https://agenthub.cyou)
|
|
271
|
+
--json JSON 格式输出
|
|
272
|
+
|
|
273
|
+
示例:
|
|
274
|
+
agenthub info code-review-assistant --registry ./.registry
|
|
275
|
+
agenthub info my-agent --server https://agenthub.cyou --json
|
|
276
|
+
`,
|
|
277
|
+
"publish-remote": `
|
|
278
|
+
agenthub publish-remote - 发布 Agent 到远程服务器
|
|
279
|
+
|
|
280
|
+
用法:
|
|
281
|
+
agenthub publish-remote <bundle-dir> --server <url>
|
|
282
|
+
|
|
283
|
+
选项:
|
|
284
|
+
--server <url> 远程服务器地址(默认: https://agenthub.cyou)
|
|
285
|
+
|
|
286
|
+
示例:
|
|
287
|
+
agenthub publish-remote ./bundles/my-agent.agent
|
|
288
|
+
agenthub publish-remote ./bundles/my-agent.agent --server https://agenthub.cyou
|
|
261
289
|
`,
|
|
262
290
|
stats: `
|
|
263
291
|
agenthub stats - 查看 Agent 统计信息
|
|
@@ -297,9 +325,39 @@ agenthub serve - 启动完整服务(前端+后端)
|
|
|
297
325
|
--registry <dir> Registry 目录 (必需)
|
|
298
326
|
--port <port> 前端端口号 (默认: 3000)
|
|
299
327
|
--api-port <port> 后端 API 端口号 (默认: 3001)
|
|
328
|
+
--host <host> 监听地址 (默认: 0.0.0.0)
|
|
300
329
|
|
|
301
330
|
示例:
|
|
302
331
|
agenthub serve --registry ./.registry --port 3000
|
|
332
|
+
agenthub serve --registry ./.registry --host 127.0.0.1
|
|
333
|
+
`,
|
|
334
|
+
api: `
|
|
335
|
+
agenthub api - 仅启动 API 后端服务
|
|
336
|
+
|
|
337
|
+
用法:
|
|
338
|
+
agenthub api --registry <dir> --port <port>
|
|
339
|
+
|
|
340
|
+
选项:
|
|
341
|
+
--registry <dir> Registry 目录 (必需)
|
|
342
|
+
--port <port> API 端口号 (默认: 3001)
|
|
343
|
+
--host <host> 监听地址 (默认: 0.0.0.0)
|
|
344
|
+
|
|
345
|
+
示例:
|
|
346
|
+
agenthub api --registry ./.registry --port 3001
|
|
347
|
+
`,
|
|
348
|
+
web: `
|
|
349
|
+
agenthub web - 仅启动 Web 前端服务
|
|
350
|
+
|
|
351
|
+
用法:
|
|
352
|
+
agenthub web --port <port> --api-base <url>
|
|
353
|
+
|
|
354
|
+
选项:
|
|
355
|
+
--port <port> Web 端口号 (默认: 3000)
|
|
356
|
+
--api-base <url> API 服务地址 (默认: http://127.0.0.1:3001)
|
|
357
|
+
--host <host> 监听地址 (默认: 0.0.0.0)
|
|
358
|
+
|
|
359
|
+
示例:
|
|
360
|
+
agenthub web --port 3000 --api-base http://127.0.0.1:3001
|
|
303
361
|
`,
|
|
304
362
|
};
|
|
305
363
|
|
|
@@ -537,7 +595,8 @@ async function main() {
|
|
|
537
595
|
case "web": {
|
|
538
596
|
const port = options.port || "3000";
|
|
539
597
|
const apiBase = options.apiBase || "http://127.0.0.1:3001";
|
|
540
|
-
const
|
|
598
|
+
const host = options.host || "0.0.0.0";
|
|
599
|
+
const result = await webCommand({ port, apiBase, host });
|
|
541
600
|
console.log(success(`Server listening at ${result.baseUrl}`));
|
|
542
601
|
console.log(`\n${highlight("🌐 Web 服务已启动")}`);
|
|
543
602
|
console.log(` ${muted("地址:")} ${result.baseUrl}`);
|
package/src/commands/api.js
CHANGED
|
@@ -3,6 +3,7 @@ import { createApiServer } from "../api-server.js";
|
|
|
3
3
|
export async function apiCommand(options) {
|
|
4
4
|
const registry = options.registry || "./.registry";
|
|
5
5
|
const port = parseInt(options.port || "3001", 10);
|
|
6
|
+
const host = options.host || "0.0.0.0";
|
|
6
7
|
|
|
7
|
-
return createApiServer({ registryDir: registry, port });
|
|
8
|
+
return createApiServer({ registryDir: registry, port, host });
|
|
8
9
|
}
|
package/src/commands/web.js
CHANGED
|
@@ -3,6 +3,7 @@ import { createWebServer } from "../web-server.js";
|
|
|
3
3
|
export async function webCommand(options) {
|
|
4
4
|
const port = parseInt(options.port || "3000", 10);
|
|
5
5
|
const apiBase = options.apiBase || "http://127.0.0.1:3001";
|
|
6
|
+
const host = options.host || "0.0.0.0";
|
|
6
7
|
|
|
7
|
-
return createWebServer({ port, apiBase });
|
|
8
|
+
return createWebServer({ port, apiBase, host });
|
|
8
9
|
}
|
package/src/web-server.js
CHANGED
|
@@ -11,7 +11,7 @@ async function fetchApi(endpoint, apiBaseUrl) {
|
|
|
11
11
|
return fetchJsonWithFallback(url);
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
export async function createWebServer({ port = 3000, apiBase = null }) {
|
|
14
|
+
export async function createWebServer({ port = 3000, apiBase = null, host = "0.0.0.0" }) {
|
|
15
15
|
const apiBaseUrl = apiBase || API_BASE;
|
|
16
16
|
|
|
17
17
|
const server = http.createServer(async (request, response) => {
|
|
@@ -81,7 +81,7 @@ export async function createWebServer({ port = 3000, apiBase = null }) {
|
|
|
81
81
|
}
|
|
82
82
|
});
|
|
83
83
|
|
|
84
|
-
await new Promise((resolve) => server.listen(port,
|
|
84
|
+
await new Promise((resolve) => server.listen(port, host, resolve));
|
|
85
85
|
const address = server.address();
|
|
86
86
|
const actualPort = typeof address === "object" && address ? address.port : port;
|
|
87
87
|
|