@zshuangmu/agenthub 0.4.14 → 0.4.16

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.
Files changed (43) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +268 -268
  3. package/package.json +41 -41
  4. package/src/api-server.js +518 -244
  5. package/src/cli.js +714 -671
  6. package/src/commands/api.js +9 -9
  7. package/src/commands/doctor.js +335 -335
  8. package/src/commands/info.js +15 -15
  9. package/src/commands/install.js +56 -56
  10. package/src/commands/list.js +78 -78
  11. package/src/commands/pack.js +249 -156
  12. package/src/commands/publish-remote.js +9 -9
  13. package/src/commands/publish.js +7 -7
  14. package/src/commands/rollback.js +59 -59
  15. package/src/commands/search.js +14 -14
  16. package/src/commands/serve.js +9 -9
  17. package/src/commands/stats.js +105 -105
  18. package/src/commands/uninstall.js +76 -76
  19. package/src/commands/update.js +54 -54
  20. package/src/commands/verify.js +133 -133
  21. package/src/commands/versions.js +75 -75
  22. package/src/commands/web.js +9 -9
  23. package/src/index.js +18 -18
  24. package/src/lib/auth.js +301 -0
  25. package/src/lib/bundle-transfer.js +58 -58
  26. package/src/lib/colors.js +60 -60
  27. package/src/lib/database.js +450 -244
  28. package/src/lib/debug.js +135 -135
  29. package/src/lib/fs-utils.js +107 -50
  30. package/src/lib/html.js +2163 -1824
  31. package/src/lib/http.js +168 -168
  32. package/src/lib/install.js +60 -60
  33. package/src/lib/manifest.js +124 -124
  34. package/src/lib/openclaw-config.js +40 -40
  35. package/src/lib/permissions.js +105 -0
  36. package/src/lib/privacy-engine.js +220 -0
  37. package/src/lib/registry.js +130 -130
  38. package/src/lib/remote.js +11 -11
  39. package/src/lib/security-scanner.js +233 -233
  40. package/src/lib/signing.js +158 -0
  41. package/src/lib/version-manager.js +77 -77
  42. package/src/server.js +176 -176
  43. package/src/web-server.js +135 -135
@@ -1,15 +1,15 @@
1
- import path from "node:path";
2
- import { readAgentInfo, parseSpec } from "../lib/registry.js";
3
- import { fetchRemoteJson } from "../lib/remote.js";
4
-
5
- export async function infoCommand(agentSpec, options = {}) {
6
- if (options.registry) {
7
- return readAgentInfo(path.resolve(options.registry), agentSpec);
8
- }
9
-
10
- const { slug, version } = parseSpec(agentSpec);
11
- const params = new URLSearchParams();
12
- if (version) params.set("version", version);
13
- const qs = params.toString();
14
- return fetchRemoteJson(`/api/agents/${slug}${qs ? `?${qs}` : ""}`, options);
15
- }
1
+ import path from "node:path";
2
+ import { readAgentInfo, parseSpec } from "../lib/registry.js";
3
+ import { fetchRemoteJson } from "../lib/remote.js";
4
+
5
+ export async function infoCommand(agentSpec, options = {}) {
6
+ if (options.registry) {
7
+ return readAgentInfo(path.resolve(options.registry), agentSpec);
8
+ }
9
+
10
+ const { slug, version } = parseSpec(agentSpec);
11
+ const params = new URLSearchParams();
12
+ if (version) params.set("version", version);
13
+ const qs = params.toString();
14
+ return fetchRemoteJson(`/api/agents/${slug}${qs ? `?${qs}` : ""}`, options);
15
+ }
@@ -1,56 +1,56 @@
1
- import path from "node:path";
2
- import { installBundle } from "../lib/install.js";
3
- import { writeJson } from "../lib/fs-utils.js";
4
-
5
- export async function installCommand(agentSpec, options) {
6
- // 未显式提供时,默认在当前目录执行安装
7
- const targetWorkspace = path.resolve(options.targetWorkspace || process.cwd());
8
-
9
- // 默认走远程服务器,提升网站复制命令可用性
10
- if (!options.registry && !options.server) {
11
- options.server = "https://agenthub.cyou";
12
- }
13
-
14
- const debugEnabled = Boolean(process.env.AGENTHUB_DEBUG_INSTALL);
15
- const debug = (message, details) => {
16
- if (!debugEnabled) return;
17
- console.error(`[agenthub:install] ${message} | ${JSON.stringify(details)}`);
18
- };
19
-
20
- debug("start install", {
21
- agentSpec,
22
- hasRegistry: Boolean(options.registry),
23
- hasServer: Boolean(options.server),
24
- targetWorkspace,
25
- });
26
-
27
- let result;
28
- if (options.registry) {
29
- result = await installBundle({
30
- registryDir: path.resolve(options.registry),
31
- agentSpec,
32
- targetWorkspace,
33
- });
34
- } else {
35
- result = await installBundle({
36
- serverUrl: options.server,
37
- agentSpec,
38
- targetWorkspace,
39
- });
40
- }
41
-
42
- debug("install finished", {
43
- slug: result.manifest.slug,
44
- version: result.manifest.version,
45
- installedAt: new Date().toISOString(),
46
- });
47
-
48
- const installRecordPath = path.join(targetWorkspace, ".agenthub", "install.json");
49
- await writeJson(installRecordPath, {
50
- slug: result.manifest.slug,
51
- version: result.manifest.version,
52
- installedAt: new Date().toISOString(),
53
- });
54
-
55
- return result;
56
- }
1
+ import path from "node:path";
2
+ import { installBundle } from "../lib/install.js";
3
+ import { writeJson } from "../lib/fs-utils.js";
4
+
5
+ export async function installCommand(agentSpec, options) {
6
+ // 未显式提供时,默认在当前目录执行安装
7
+ const targetWorkspace = path.resolve(options.targetWorkspace || process.cwd());
8
+
9
+ // 默认走远程服务器,提升网站复制命令可用性
10
+ if (!options.registry && !options.server) {
11
+ options.server = "https://agenthub.cyou";
12
+ }
13
+
14
+ const debugEnabled = Boolean(process.env.AGENTHUB_DEBUG_INSTALL);
15
+ const debug = (message, details) => {
16
+ if (!debugEnabled) return;
17
+ console.error(`[agenthub:install] ${message} | ${JSON.stringify(details)}`);
18
+ };
19
+
20
+ debug("start install", {
21
+ agentSpec,
22
+ hasRegistry: Boolean(options.registry),
23
+ hasServer: Boolean(options.server),
24
+ targetWorkspace,
25
+ });
26
+
27
+ let result;
28
+ if (options.registry) {
29
+ result = await installBundle({
30
+ registryDir: path.resolve(options.registry),
31
+ agentSpec,
32
+ targetWorkspace,
33
+ });
34
+ } else {
35
+ result = await installBundle({
36
+ serverUrl: options.server,
37
+ agentSpec,
38
+ targetWorkspace,
39
+ });
40
+ }
41
+
42
+ debug("install finished", {
43
+ slug: result.manifest.slug,
44
+ version: result.manifest.version,
45
+ installedAt: new Date().toISOString(),
46
+ });
47
+
48
+ const installRecordPath = path.join(targetWorkspace, ".agenthub", "install.json");
49
+ await writeJson(installRecordPath, {
50
+ slug: result.manifest.slug,
51
+ version: result.manifest.version,
52
+ installedAt: new Date().toISOString(),
53
+ });
54
+
55
+ return result;
56
+ }
@@ -1,78 +1,78 @@
1
- /**
2
- * List Command
3
- * 列出已安装的 Agent
4
- */
5
-
6
- import path from "node:path";
7
- import { pathExists, readJson } from "../lib/fs-utils.js";
8
-
9
- export async function listCommand(options = {}) {
10
- // 检查多个可能的安装位置
11
- const locations = [];
12
-
13
- // 1. 当前目录的 .agenthub
14
- const cwd = process.cwd();
15
- const cwdAgenthub = path.join(cwd, ".agenthub");
16
- if (await pathExists(cwdAgenthub)) {
17
- const installs = await findInstallsInDir(cwd);
18
- locations.push(...installs.map((i) => ({ ...i, location: cwd })));
19
- }
20
-
21
- // 2. 如果指定了 target-workspace
22
- if (options.targetWorkspace) {
23
- const targetPath = path.resolve(options.targetWorkspace);
24
- const installs = await findInstallsInDir(targetPath);
25
- locations.push(...installs.map((i) => ({ ...i, location: targetPath })));
26
- }
27
-
28
- return locations;
29
- }
30
-
31
- async function findInstallsInDir(dirPath) {
32
- const installs = [];
33
- const agenthubDir = path.join(dirPath, ".agenthub");
34
- const installRecordPath = path.join(agenthubDir, "install.json");
35
-
36
- if (await pathExists(installRecordPath)) {
37
- try {
38
- const record = await readJson(installRecordPath);
39
- installs.push({
40
- slug: record.slug,
41
- version: record.version,
42
- installedAt: record.installedAt || record.updatedAt,
43
- rolledBackAt: record.rolledBackAt,
44
- });
45
- } catch {
46
- // 无效的安装记录
47
- }
48
- }
49
-
50
- return installs;
51
- }
52
-
53
- export function formatListOutput(installs) {
54
- if (installs.length === 0) {
55
- return "\n📭 暂无已安装的 Agent\n\n安装命令: agenthub install <agent-slug>\n";
56
- }
57
-
58
- const lines = [];
59
- lines.push("\n📦 已安装的 Agent:\n");
60
- lines.push("─".repeat(60));
61
-
62
- for (const install of installs) {
63
- const status = install.rolledBackAt ? "↩️ " : "✓ ";
64
- lines.push(` ${status} ${install.slug}@${install.version}`);
65
- if (install.location) {
66
- lines.push(` 位置: ${install.location}`);
67
- }
68
- if (install.installedAt) {
69
- lines.push(` 安装时间: ${install.installedAt}`);
70
- }
71
- lines.push("");
72
- }
73
-
74
- lines.push("─".repeat(60));
75
- lines.push(`\n共 ${installs.length} 个已安装的 Agent\n`);
76
-
77
- return lines.join("\n");
78
- }
1
+ /**
2
+ * List Command
3
+ * 列出已安装的 Agent
4
+ */
5
+
6
+ import path from "node:path";
7
+ import { pathExists, readJson } from "../lib/fs-utils.js";
8
+
9
+ export async function listCommand(options = {}) {
10
+ // 检查多个可能的安装位置
11
+ const locations = [];
12
+
13
+ // 1. 当前目录的 .agenthub
14
+ const cwd = process.cwd();
15
+ const cwdAgenthub = path.join(cwd, ".agenthub");
16
+ if (await pathExists(cwdAgenthub)) {
17
+ const installs = await findInstallsInDir(cwd);
18
+ locations.push(...installs.map((i) => ({ ...i, location: cwd })));
19
+ }
20
+
21
+ // 2. 如果指定了 target-workspace
22
+ if (options.targetWorkspace) {
23
+ const targetPath = path.resolve(options.targetWorkspace);
24
+ const installs = await findInstallsInDir(targetPath);
25
+ locations.push(...installs.map((i) => ({ ...i, location: targetPath })));
26
+ }
27
+
28
+ return locations;
29
+ }
30
+
31
+ async function findInstallsInDir(dirPath) {
32
+ const installs = [];
33
+ const agenthubDir = path.join(dirPath, ".agenthub");
34
+ const installRecordPath = path.join(agenthubDir, "install.json");
35
+
36
+ if (await pathExists(installRecordPath)) {
37
+ try {
38
+ const record = await readJson(installRecordPath);
39
+ installs.push({
40
+ slug: record.slug,
41
+ version: record.version,
42
+ installedAt: record.installedAt || record.updatedAt,
43
+ rolledBackAt: record.rolledBackAt,
44
+ });
45
+ } catch {
46
+ // 无效的安装记录
47
+ }
48
+ }
49
+
50
+ return installs;
51
+ }
52
+
53
+ export function formatListOutput(installs) {
54
+ if (installs.length === 0) {
55
+ return "\n📭 暂无已安装的 Agent\n\n安装命令: agenthub install <agent-slug>\n";
56
+ }
57
+
58
+ const lines = [];
59
+ lines.push("\n📦 已安装的 Agent:\n");
60
+ lines.push("─".repeat(60));
61
+
62
+ for (const install of installs) {
63
+ const status = install.rolledBackAt ? "↩️ " : "✓ ";
64
+ lines.push(` ${status} ${install.slug}@${install.version}`);
65
+ if (install.location) {
66
+ lines.push(` 位置: ${install.location}`);
67
+ }
68
+ if (install.installedAt) {
69
+ lines.push(` 安装时间: ${install.installedAt}`);
70
+ }
71
+ lines.push("");
72
+ }
73
+
74
+ lines.push("─".repeat(60));
75
+ lines.push(`\n共 ${installs.length} 个已安装的 Agent\n`);
76
+
77
+ return lines.join("\n");
78
+ }