hyperclaw 5.2.8 → 5.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.
Files changed (138) hide show
  1. package/dist/a2ui-protocol-DEsfqO7h.js +75 -0
  2. package/dist/agents-routing-ChorJKFL.js +6 -0
  3. package/dist/agents-routing-Cpg20-1e.js +398 -0
  4. package/dist/api-key-validation-DgOBmp8Y.js +64 -0
  5. package/dist/api-keys-guide--73Bq0Ey.js +149 -0
  6. package/dist/audit-Dntx9fG9.js +445 -0
  7. package/dist/banner-B_rR7FPO.js +7 -0
  8. package/dist/banner-Bb7CderS.js +143 -0
  9. package/dist/bounty-tools-Dn9Yq7V1.js +211 -0
  10. package/dist/browser-tools-CJ9M9o22.js +179 -0
  11. package/dist/browser-tools-CXxWxA1c.js +5 -0
  12. package/dist/chat-D1Zc73I5.js +513 -0
  13. package/dist/claw-tasks-ChqkHdFs.js +80 -0
  14. package/dist/config-Bzues-G2.js +7 -0
  15. package/dist/config-DGAAJ49A.js +261 -0
  16. package/dist/connector-1efnZgQN.js +566 -0
  17. package/dist/connector-B5q1_srT.js +286 -0
  18. package/dist/connector-BMFLJ4fr.js +508 -0
  19. package/dist/connector-BZYv9siY.js +189 -0
  20. package/dist/connector-B_XkXm-j.js +218 -0
  21. package/dist/connector-BkY1I6gf.js +189 -0
  22. package/dist/connector-C2Z3RN1z.js +350 -0
  23. package/dist/connector-C7aYvVzU.js +225 -0
  24. package/dist/connector-CXXYOyHw.js +164 -0
  25. package/dist/connector-Ca1J23HX.js +167 -0
  26. package/dist/connector-Cjqc656I.js +181 -0
  27. package/dist/connector-CluRienN.js +425 -0
  28. package/dist/connector-CuNz2eP-.js +305 -0
  29. package/dist/connector-DHL_oeHy.js +552 -0
  30. package/dist/connector-DJ79rd1L.js +173 -0
  31. package/dist/connector-DcLE6xCZ.js +239 -0
  32. package/dist/connector-DcyQTJnJ.js +162 -0
  33. package/dist/connector-DgyX9qSc.js +192 -0
  34. package/dist/connector-DnDXXZ7L.js +182 -0
  35. package/dist/connector-DqUslg-X.js +213 -0
  36. package/dist/connector-Duc-HmRZ.js +85 -0
  37. package/dist/connector-IV0QFer8.js +498 -0
  38. package/dist/connector-OnsLxE8G.js +194 -0
  39. package/dist/connector-UYu_TS0X.js +204 -0
  40. package/dist/connector-cCA5ffmp.js +340 -0
  41. package/dist/connector-fbNfx4_L.js +568 -0
  42. package/dist/connector-fi2vlwbO.js +276 -0
  43. package/dist/connector-l3LD8IDN.js +419 -0
  44. package/dist/cost-tracker-DCXDUzBI.js +103 -0
  45. package/dist/credentials-store-Bmm9e1SS.js +7 -0
  46. package/dist/credentials-store-D8ERbGR2.js +89 -0
  47. package/dist/cron-tasks-OQbgmenS.js +85 -0
  48. package/dist/daemon-aVX-WGz1.js +421 -0
  49. package/dist/daemon-iFmVBPXN.js +7 -0
  50. package/dist/delivery-Pko6sSkt.js +4 -0
  51. package/dist/delivery-hMHFRZwy.js +95 -0
  52. package/dist/destructive-gate-C2TrWsp2.js +101 -0
  53. package/dist/developer-keys-BWXHaWxY.js +127 -0
  54. package/dist/developer-keys-CzDxVczE.js +8 -0
  55. package/dist/device-auth-store-C1bCwXO2.js +7 -0
  56. package/dist/device-auth-store-DIZTOz4V.js +88 -0
  57. package/dist/doctor-C6nAGdH8.js +233 -0
  58. package/dist/doctor-mgWumA25.js +6 -0
  59. package/dist/engine-BGRTi0fo.js +327 -0
  60. package/dist/engine-BvCEhaUn.js +7 -0
  61. package/dist/env-resolve-CHxjGo8u.js +151 -0
  62. package/dist/env-resolve-pIETNTpQ.js +10 -0
  63. package/dist/extraction-tools-BE6z_Yw5.js +91 -0
  64. package/dist/extraction-tools-CJsdyBST.js +5 -0
  65. package/dist/form_data-B2_0EoWj.js +8657 -0
  66. package/dist/gmail-watch-setup-1RGIHNdu.js +42 -0
  67. package/dist/health-BMUmUNoe.js +152 -0
  68. package/dist/health-C8n9RH5O.js +6 -0
  69. package/dist/heartbeat-engine-aRbab8a5.js +89 -0
  70. package/dist/hub-BJM2KXLO.js +6 -0
  71. package/dist/hub-Bb_dYECE.js +512 -0
  72. package/dist/hyperclawbot-CgrV46DA.js +516 -0
  73. package/dist/inference-CFBkvLpE.js +2854 -0
  74. package/dist/inference-G4MbdErG.js +8 -0
  75. package/dist/knowledge-graph-9UNrsiIY.js +134 -0
  76. package/dist/loader-DIPs649t.js +410 -0
  77. package/dist/loader-Dq_cDlOW.js +6 -0
  78. package/dist/logger-CG38Idq4.js +86 -0
  79. package/dist/manager--wG9JdFW.js +120 -0
  80. package/dist/manager-BNc21xgG.js +6 -0
  81. package/dist/manager-DWJ7WZcY.js +250 -0
  82. package/dist/manager-DYfzqckn.js +35 -0
  83. package/dist/mcp-SsMEvl28.js +142 -0
  84. package/dist/mcp-loader-DLrp_oZJ.js +93 -0
  85. package/dist/memory-BCYvdqwo.js +273 -0
  86. package/dist/memory-BGgCBSx1.js +6 -0
  87. package/dist/memory-auto-Bh52cQJP.js +5 -0
  88. package/dist/memory-auto-BupvVwNd.js +306 -0
  89. package/dist/memory-integration-4oGqX6rr.js +91 -0
  90. package/dist/moltbook-B3DNdh40.js +81 -0
  91. package/dist/node-C4esBfbX.js +226 -0
  92. package/dist/nodes-registry-DLUZhEMS.js +52 -0
  93. package/dist/oauth-flow-BbLQTzZk.js +148 -0
  94. package/dist/oauth-provider-UZyG84s7.js +111 -0
  95. package/dist/observability-BtLyuxcz.js +89 -0
  96. package/dist/onboard-B3drurt-.js +3812 -0
  97. package/dist/onboard-DEwuHrMj.js +14 -0
  98. package/dist/orchestrator-BXyIgAeH.js +189 -0
  99. package/dist/orchestrator-MLTc4NYu.js +6 -0
  100. package/dist/osint-Bsf6RGPv.js +283 -0
  101. package/dist/osint-chat-Ark94iFc.js +789 -0
  102. package/dist/pairing-2vAiDBjN.js +6 -0
  103. package/dist/pairing-B4NoBvyE.js +207 -0
  104. package/dist/pc-access-BLnc-DYp.js +858 -0
  105. package/dist/pc-access-CTNtG2LD.js +8 -0
  106. package/dist/pending-approval-C4ZaHHWl.js +22 -0
  107. package/dist/reminders-store-BixTWL1h.js +58 -0
  108. package/dist/renderer-B1ToXngl.js +228 -0
  109. package/dist/rules-Cqen1Mpt.js +106 -0
  110. package/dist/run-main.js +94 -93
  111. package/dist/runner-Cr1_mwnU.js +1274 -0
  112. package/dist/security-B4vH02lO.js +4 -0
  113. package/dist/security-HOOGCw5z.js +90 -0
  114. package/dist/server-CRhXiGI9.js +4 -0
  115. package/dist/server-De4H45Ju.js +1365 -0
  116. package/dist/session-store-7sEPyV16.js +5 -0
  117. package/dist/session-store-Ce2QMSL_.js +141 -0
  118. package/dist/sessions-tools-CWr_pDtp.js +5 -0
  119. package/dist/sessions-tools-DKVu9aIN.js +95 -0
  120. package/dist/skill-loader-DK19Jm4e.js +7 -0
  121. package/dist/skill-loader-Dfs9VNM-.js +160 -0
  122. package/dist/skill-runtime-BeKh2rD_.js +5 -0
  123. package/dist/skill-runtime-CcpC2Zfc.js +104 -0
  124. package/dist/src-BxmkZ9RH.js +63 -0
  125. package/dist/src-DjTtmSRg.js +20 -0
  126. package/dist/src-n_46LPDi.js +458 -0
  127. package/dist/sub-agent-tools-q5JqEze_.js +39 -0
  128. package/dist/tool-policy-QXF3MMxu.js +189 -0
  129. package/dist/tts-elevenlabs-y6HGWWDS.js +64 -0
  130. package/dist/update-check-C4te7JmY.js +6 -0
  131. package/dist/update-check-GDue_it1.js +98 -0
  132. package/dist/vision-tools-CbVfyTZT.js +5 -0
  133. package/dist/vision-tools-DieVQp6s.js +51 -0
  134. package/dist/vision-u4kMThdo.js +167 -0
  135. package/dist/voice-transcription-DgON5qaF.js +170 -0
  136. package/dist/website-watch-tools-B8L_NgwT.js +5 -0
  137. package/dist/website-watch-tools-Drm5HjIX.js +176 -0
  138. package/package.json +1 -1
@@ -0,0 +1,127 @@
1
+ const require_chunk = require('./chunk-jS-bbMI5.js');
2
+ const require_paths = require('./paths-AIyBxIzm.js');
3
+ const fs_extra = require_chunk.__toESM(require("fs-extra"));
4
+ const path = require_chunk.__toESM(require("path"));
5
+ const crypto = require_chunk.__toESM(require("crypto"));
6
+
7
+ //#region src/infra/developer-keys.ts
8
+ require_paths.init_paths();
9
+ const KEYS_FILE = "developer-keys.json";
10
+ function getKeysPath(baseDir) {
11
+ const root = baseDir ?? require_paths.getHyperClawDir();
12
+ return path.default.join(root, KEYS_FILE);
13
+ }
14
+ function hashKey(key) {
15
+ return crypto.default.createHash("sha256").update(key, "utf8").digest("hex");
16
+ }
17
+ function generateKey() {
18
+ return `hc_${crypto.default.randomBytes(24).toString("base64url")}`;
19
+ }
20
+ async function loadKeys(baseDir) {
21
+ const fp = getKeysPath(baseDir);
22
+ if (!await fs_extra.default.pathExists(fp)) return [];
23
+ try {
24
+ const data = await fs_extra.default.readJson(fp);
25
+ return Array.isArray(data.keys) ? data.keys : [];
26
+ } catch {
27
+ return [];
28
+ }
29
+ }
30
+ async function saveKeys(keys, baseDir) {
31
+ const fp = getKeysPath(baseDir);
32
+ const dir = path.default.dirname(fp);
33
+ await fs_extra.default.ensureDir(dir);
34
+ await fs_extra.default.writeJson(fp, {
35
+ keys,
36
+ updatedAt: (/* @__PURE__ */ new Date()).toISOString()
37
+ }, { spaces: 2 });
38
+ }
39
+ /** Create a new developer key. Returns the raw key (show once). Optional tenantId for multi-tenant. */
40
+ async function createDeveloperKey(name, opts) {
41
+ const rawKey = generateKey();
42
+ const keyHash = hashKey(rawKey);
43
+ const id = `key_${crypto.default.randomBytes(8).toString("hex")}`;
44
+ const entry = {
45
+ id,
46
+ name: name || "Unnamed",
47
+ keyHash,
48
+ tenantId: opts?.tenantId,
49
+ createdAt: (/* @__PURE__ */ new Date()).toISOString()
50
+ };
51
+ const keys = await loadKeys(opts?.baseDir);
52
+ keys.push(entry);
53
+ await saveKeys(keys, opts?.baseDir);
54
+ return {
55
+ id,
56
+ key: rawKey,
57
+ name: entry.name,
58
+ tenantId: entry.tenantId
59
+ };
60
+ }
61
+ /** List developer keys (without raw keys). Optional tenantId filter. */
62
+ async function listDeveloperKeys(opts) {
63
+ let keys = await loadKeys(opts?.baseDir);
64
+ if (opts?.tenantId) keys = keys.filter((k) => k.tenantId === opts.tenantId);
65
+ return keys.map((k) => ({
66
+ id: k.id,
67
+ name: k.name,
68
+ tenantId: k.tenantId,
69
+ createdAt: k.createdAt,
70
+ lastUsedAt: k.lastUsedAt
71
+ }));
72
+ }
73
+ /** Revoke a developer key by id. */
74
+ async function revokeDeveloperKey(id) {
75
+ const keys = await loadKeys();
76
+ const before = keys.length;
77
+ const filtered = keys.filter((k) => k.id !== id);
78
+ if (filtered.length === before) return false;
79
+ await saveKeys(filtered);
80
+ return true;
81
+ }
82
+ /**
83
+
84
+ * Validate a Bearer token. Returns { valid: true, tenantId?: string } or { valid: false }.
85
+
86
+ * Use with gateway token check: valid = gatewayToken OR result.valid.
87
+
88
+ */
89
+ async function validateDeveloperKey(bearer, opts) {
90
+ if (!bearer || bearer.length < 20) return { valid: false };
91
+ const keys = await loadKeys(opts?.baseDir);
92
+ const hash = hashKey(bearer);
93
+ const idx = keys.findIndex((k) => k.keyHash === hash);
94
+ if (idx < 0) return { valid: false };
95
+ keys[idx].lastUsedAt = (/* @__PURE__ */ new Date()).toISOString();
96
+ await saveKeys(keys, opts?.baseDir).catch(() => {});
97
+ return {
98
+ valid: true,
99
+ tenantId: keys[idx].tenantId
100
+ };
101
+ }
102
+
103
+ //#endregion
104
+ Object.defineProperty(exports, 'createDeveloperKey', {
105
+ enumerable: true,
106
+ get: function () {
107
+ return createDeveloperKey;
108
+ }
109
+ });
110
+ Object.defineProperty(exports, 'listDeveloperKeys', {
111
+ enumerable: true,
112
+ get: function () {
113
+ return listDeveloperKeys;
114
+ }
115
+ });
116
+ Object.defineProperty(exports, 'revokeDeveloperKey', {
117
+ enumerable: true,
118
+ get: function () {
119
+ return revokeDeveloperKey;
120
+ }
121
+ });
122
+ Object.defineProperty(exports, 'validateDeveloperKey', {
123
+ enumerable: true,
124
+ get: function () {
125
+ return validateDeveloperKey;
126
+ }
127
+ });
@@ -0,0 +1,8 @@
1
+ const require_chunk = require('./chunk-jS-bbMI5.js');
2
+ require('./paths-AIyBxIzm.js');
3
+ const require_developer_keys = require('./developer-keys-BWXHaWxY.js');
4
+
5
+ exports.createDeveloperKey = require_developer_keys.createDeveloperKey;
6
+ exports.listDeveloperKeys = require_developer_keys.listDeveloperKeys;
7
+ exports.revokeDeveloperKey = require_developer_keys.revokeDeveloperKey;
8
+ exports.validateDeveloperKey = require_developer_keys.validateDeveloperKey;
@@ -0,0 +1,7 @@
1
+ const require_chunk = require('./chunk-jS-bbMI5.js');
2
+ require('./paths-AIyBxIzm.js');
3
+ require('./paths-DPovhojT.js');
4
+ const require_device_auth_store = require('./device-auth-store-DIZTOz4V.js');
5
+
6
+ require_device_auth_store.init_device_auth_store();
7
+ exports.AuthStore = require_device_auth_store.AuthStore;
@@ -0,0 +1,88 @@
1
+ const require_chunk = require('./chunk-jS-bbMI5.js');
2
+ const require_paths = require('./paths-AIyBxIzm.js');
3
+ const require_paths$1 = require('./paths-DPovhojT.js');
4
+ const chalk = require_chunk.__toESM(require("chalk"));
5
+ const fs_extra = require_chunk.__toESM(require("fs-extra"));
6
+ const path = require_chunk.__toESM(require("path"));
7
+
8
+ //#region src/infra/device-auth-store.ts
9
+ var AuthStore;
10
+ var init_device_auth_store = require_chunk.__esm({ "src/infra/device-auth-store.ts"() {
11
+ require_paths$1.init_paths();
12
+ AuthStore = class {
13
+ storePath;
14
+ constructor(storeDir) {
15
+ const dir = storeDir ?? require_paths.getHyperClawDir();
16
+ this.storePath = path.default.join(dir, "auth.json");
17
+ }
18
+ async readStore() {
19
+ try {
20
+ const stat = await fs_extra.default.stat(this.storePath);
21
+ if ((stat.mode & 63) !== 0) {
22
+ console.log(chalk.default.yellow(" ⚠ Auth store has unsafe permissions — fixing..."));
23
+ await fs_extra.default.chmod(this.storePath, 384);
24
+ }
25
+ return await fs_extra.default.readJson(this.storePath);
26
+ } catch {
27
+ return null;
28
+ }
29
+ }
30
+ async writeStore(store) {
31
+ await fs_extra.default.ensureDir(path.default.dirname(this.storePath));
32
+ await fs_extra.default.writeFile(this.storePath, `${JSON.stringify(store, null, 2)}\n`, { mode: 384 });
33
+ }
34
+ async getGatewayToken() {
35
+ return (await this.readStore())?.gatewayToken;
36
+ }
37
+ async setGatewayToken(token) {
38
+ const store = await this.readStore() || this.emptyStore();
39
+ store.gatewayToken = token;
40
+ store.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
41
+ await this.writeStore(store);
42
+ }
43
+ async setProviderKey(providerId, apiKey) {
44
+ const store = await this.readStore() || this.emptyStore();
45
+ store.providers[providerId] = { apiKey };
46
+ store.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
47
+ await this.writeStore(store);
48
+ }
49
+ async getProviderKey(providerId) {
50
+ return (await this.readStore())?.providers[providerId]?.apiKey;
51
+ }
52
+ async listProviders() {
53
+ return Object.keys((await this.readStore())?.providers || {});
54
+ }
55
+ async scrubSensitive() {
56
+ const store = await this.readStore();
57
+ if (!store) return null;
58
+ const scrubbed = JSON.parse(JSON.stringify(store));
59
+ if (scrubbed.gatewayToken) scrubbed.gatewayToken = "***";
60
+ for (const p of Object.keys(scrubbed.providers || {})) {
61
+ if (scrubbed.providers[p].apiKey) scrubbed.providers[p].apiKey = "***";
62
+ if (scrubbed.providers[p].refreshToken) scrubbed.providers[p].refreshToken = "***";
63
+ }
64
+ return scrubbed;
65
+ }
66
+ emptyStore() {
67
+ return {
68
+ providers: {},
69
+ createdAt: (/* @__PURE__ */ new Date()).toISOString(),
70
+ updatedAt: (/* @__PURE__ */ new Date()).toISOString()
71
+ };
72
+ }
73
+ };
74
+ } });
75
+
76
+ //#endregion
77
+ Object.defineProperty(exports, 'AuthStore', {
78
+ enumerable: true,
79
+ get: function () {
80
+ return AuthStore;
81
+ }
82
+ });
83
+ Object.defineProperty(exports, 'init_device_auth_store', {
84
+ enumerable: true,
85
+ get: function () {
86
+ return init_device_auth_store;
87
+ }
88
+ });
@@ -0,0 +1,233 @@
1
+ const require_chunk = require('./chunk-jS-bbMI5.js');
2
+ const require_paths = require('./paths-AIyBxIzm.js');
3
+ const require_paths$1 = require('./paths-DPovhojT.js');
4
+ const chalk = require_chunk.__toESM(require("chalk"));
5
+ const ora = require_chunk.__toESM(require("ora"));
6
+ const fs_extra = require_chunk.__toESM(require("fs-extra"));
7
+ const path = require_chunk.__toESM(require("path"));
8
+ const net = require_chunk.__toESM(require("net"));
9
+
10
+ //#region src/commands/doctor.ts
11
+ require_paths$1.init_paths();
12
+ async function isPortOpen(port) {
13
+ return new Promise((resolve) => {
14
+ const s = new net.default.Socket();
15
+ s.setTimeout(500);
16
+ s.on("connect", () => {
17
+ s.destroy();
18
+ resolve(true);
19
+ });
20
+ s.on("error", () => resolve(false));
21
+ s.on("timeout", () => resolve(false));
22
+ try {
23
+ s.connect(port, "127.0.0.1");
24
+ } catch {
25
+ resolve(false);
26
+ }
27
+ });
28
+ }
29
+ async function runDoctor(fix = false, opts = {}) {
30
+ const doFix = fix || opts.repair || opts.fix || false;
31
+ const force = opts.force || false;
32
+ const nonInteractive = opts.nonInteractive || opts.yes || false;
33
+ const deep = opts.deep || false;
34
+ const spinner = (0, ora.default)("Running health checks...").start();
35
+ await new Promise((r) => setTimeout(r, 400));
36
+ spinner.stop();
37
+ const configDir = require_paths.getHyperClawDir();
38
+ const configFile = require_paths.getConfigPath();
39
+ const agentsFile = path.default.join(configDir, "AGENTS.md");
40
+ const authFile = path.default.join(configDir, "auth.json");
41
+ const credentialsDir = path.default.join(configDir, "credentials");
42
+ const pairingFile = path.default.join(credentialsDir, "discord-pairing.json");
43
+ let cfg = null;
44
+ try {
45
+ cfg = await fs_extra.default.readJson(configFile);
46
+ } catch {}
47
+ const issues = [];
48
+ if (!cfg) issues.push({
49
+ id: "no-config",
50
+ severity: "error",
51
+ title: "No configuration found",
52
+ detail: "Run: hyperclaw init",
53
+ fixable: false
54
+ });
55
+ else {
56
+ const hasToken = !!cfg.gateway?.authToken;
57
+ issues.push({
58
+ id: "gateway-token",
59
+ severity: hasToken ? "ok" : "warn",
60
+ title: hasToken ? "Gateway auth token set" : "Gateway auth token missing",
61
+ detail: hasToken ? "Token is configured" : "Set a strong token in gateway config",
62
+ fixable: !hasToken,
63
+ fix: async () => {
64
+ const crypto = await import("crypto");
65
+ cfg.gateway = cfg.gateway || {};
66
+ cfg.gateway.authToken = crypto.randomBytes(32).toString("hex");
67
+ const tmp = configFile + ".tmp";
68
+ fs_extra.default.writeJsonSync(tmp, cfg, { spaces: 2 });
69
+ fs_extra.default.renameSync(tmp, configFile);
70
+ console.log(chalk.default.green(" ✔ Generated and saved gateway auth token"));
71
+ }
72
+ });
73
+ const channels = cfg.gateway?.enabledChannels || cfg.channels || [];
74
+ const channelConfigs = typeof cfg.channelConfigs === "object" && !Array.isArray(cfg.channelConfigs) ? cfg.channelConfigs : {};
75
+ const chList = Array.isArray(channels) ? channels : Object.keys(channelConfigs);
76
+ for (const ch of chList) {
77
+ const chCfg = typeof channelConfigs === "object" && !Array.isArray(channelConfigs) ? channelConfigs[ch] : null;
78
+ const dmPolicy = chCfg?.dmPolicy?.policy ?? (typeof chCfg?.dmPolicy === "string" ? chCfg.dmPolicy : null);
79
+ if (dmPolicy === "open") issues.push({
80
+ id: `dm-open-${ch}`,
81
+ severity: "warn",
82
+ title: `DM policy is "open" on ${ch}`,
83
+ detail: `Anyone can DM your agent on ${ch}. Consider using "pairing" or "allowlist".`,
84
+ fixable: false
85
+ });
86
+ if (dmPolicy === "allowlist") {
87
+ const allowFrom = chCfg?.dmPolicy?.allowFrom ?? chCfg?.allowFrom ?? [];
88
+ const arr = Array.isArray(allowFrom) ? allowFrom : [];
89
+ if (arr.length === 0) issues.push({
90
+ id: `dm-empty-allowlist-${ch}`,
91
+ severity: "error",
92
+ title: `Empty allowlist on ${ch} — DMs will be silently dropped`,
93
+ detail: `channel.${ch}.allowFrom or dmPolicy.allowFrom is empty. Add users or change policy.`,
94
+ fixable: true,
95
+ fix: async () => {
96
+ try {
97
+ const allowFromPath = path.default.join(credentialsDir, `${ch}-allowFrom.json`);
98
+ if (await fs_extra.default.pathExists(allowFromPath)) {
99
+ const af = await fs_extra.default.readJson(allowFromPath);
100
+ const ids = af.senderIds;
101
+ if (ids?.length) {
102
+ cfg.channelConfigs = cfg.channelConfigs || {};
103
+ const existing = cfg.channelConfigs[ch] || {};
104
+ const merged = {
105
+ ...existing,
106
+ allowFrom: ids
107
+ };
108
+ if (typeof existing.dmPolicy === "object") merged.dmPolicy = {
109
+ ...existing.dmPolicy,
110
+ allowFrom: ids
111
+ };
112
+ cfg.channelConfigs[ch] = merged;
113
+ const tmp = configFile + ".tmp";
114
+ await fs_extra.default.writeJson(tmp, cfg, { spaces: 2 });
115
+ await fs_extra.default.rename(tmp, configFile);
116
+ console.log(chalk.default.green(` ✔ Restored ${ids.length} user(s) from allowFrom store`));
117
+ }
118
+ }
119
+ } catch (e) {
120
+ if (process.env.DEBUG) console.error("[doctor] restore allowFrom:", e?.message);
121
+ }
122
+ }
123
+ });
124
+ }
125
+ }
126
+ const hasApiKey = !!cfg.provider?.apiKey;
127
+ const isLocal = cfg.provider?.providerId === "local";
128
+ if (!hasApiKey && !isLocal) issues.push({
129
+ id: "no-api-key",
130
+ severity: "error",
131
+ title: "No AI provider API key configured",
132
+ detail: "Run: hyperclaw config set-key",
133
+ fixable: false
134
+ });
135
+ else issues.push({
136
+ id: "api-key",
137
+ severity: "ok",
138
+ title: "AI provider key configured",
139
+ detail: `Provider: ${cfg.provider?.providerId}`,
140
+ fixable: false
141
+ });
142
+ issues.push({
143
+ id: "agents-md",
144
+ severity: await fs_extra.default.pathExists(agentsFile) ? "ok" : "warn",
145
+ title: await fs_extra.default.pathExists(agentsFile) ? "AGENTS.md exists" : "AGENTS.md missing",
146
+ detail: await fs_extra.default.pathExists(agentsFile) ? agentsFile : "Run: hyperclaw memory init to generate",
147
+ fixable: false
148
+ });
149
+ const port = cfg.gateway?.port || 18789;
150
+ const running = await isPortOpen(port);
151
+ issues.push({
152
+ id: "gateway-running",
153
+ severity: running ? "ok" : "warn",
154
+ title: running ? `Gateway running on port ${port}` : `Gateway not running on port ${port}`,
155
+ detail: running ? `ws://127.0.0.1:${port}` : "Run: hyperclaw daemon start",
156
+ fixable: false
157
+ });
158
+ if (await fs_extra.default.pathExists(configFile)) {
159
+ const stat = await fs_extra.default.stat(configFile);
160
+ const unsafe = (stat.mode & 63) !== 0;
161
+ if (unsafe) issues.push({
162
+ id: "config-permissions",
163
+ severity: "warn",
164
+ title: "Config file has unsafe permissions",
165
+ detail: `chmod 600 ${configFile}`,
166
+ fixable: true,
167
+ fix: async () => {
168
+ await fs_extra.default.chmod(configFile, 384);
169
+ console.log(chalk.default.green(` ✔ Fixed permissions on ${configFile}`));
170
+ }
171
+ });
172
+ }
173
+ const stateWritable = await fs_extra.default.pathExists(configDir) && (await fs_extra.default.stat(configDir).catch(() => null))?.isDirectory?.();
174
+ issues.push({
175
+ id: "state-dir",
176
+ severity: stateWritable ? "ok" : "error",
177
+ title: stateWritable ? "State directory OK" : "State directory missing or not writable",
178
+ detail: stateWritable ? configDir : `Ensure ${configDir} exists and is writable`,
179
+ fixable: !stateWritable,
180
+ fix: async () => {
181
+ await fs_extra.default.ensureDir(configDir);
182
+ console.log(chalk.default.green(` ✔ Created state directory: ${configDir}`));
183
+ }
184
+ });
185
+ if (await fs_extra.default.pathExists(authFile)) {
186
+ const stat = await fs_extra.default.stat(authFile);
187
+ const unsafe = (stat.mode & 63) !== 0;
188
+ issues.push({
189
+ id: "auth-permissions",
190
+ severity: unsafe ? "warn" : "ok",
191
+ title: unsafe ? "Auth store has unsafe permissions" : "Auth store permissions OK",
192
+ detail: unsafe ? `chmod 600 ${authFile}` : `Mode: 600`,
193
+ fixable: unsafe,
194
+ fix: async () => {
195
+ await fs_extra.default.chmod(authFile, 384);
196
+ console.log(chalk.default.green(` ✔ Fixed permissions on ${authFile}`));
197
+ }
198
+ });
199
+ }
200
+ }
201
+ console.log(chalk.default.bold.cyan("\n 🩺 HYPERCLAW DOCTOR\n"));
202
+ let errorCount = 0, warnCount = 0;
203
+ for (const issue of issues) {
204
+ const icon = {
205
+ error: chalk.default.red("✖"),
206
+ warn: chalk.default.yellow("⚠"),
207
+ ok: chalk.default.green("✔")
208
+ }[issue.severity];
209
+ console.log(` ${icon} ${chalk.default.white(issue.title)}`);
210
+ console.log(` ${chalk.default.gray(issue.detail)}`);
211
+ if (issue.fixable && doFix && issue.fix) await issue.fix();
212
+ else if (issue.fixable && !fix) console.log(chalk.default.gray(" Run with --fix to auto-repair"));
213
+ if (issue.severity === "error") errorCount++;
214
+ if (issue.severity === "warn") warnCount++;
215
+ console.log();
216
+ }
217
+ const total = issues.length;
218
+ const okCount = total - errorCount - warnCount;
219
+ console.log(` ${chalk.default.bold("Summary:")} ${chalk.default.green(`${okCount} ok`)} ${chalk.default.yellow(`${warnCount} warnings`)} ${chalk.default.red(`${errorCount} errors`)}`);
220
+ if (errorCount > 0 || warnCount > 0) {
221
+ console.log(chalk.default.gray("\n Run: hyperclaw doctor --fix to auto-repair fixable issues"));
222
+ if (deep) console.log(chalk.default.gray(" Use --deep to scan for extra gateway services (launchd/systemd/schtasks)\n"));
223
+ else console.log();
224
+ } else console.log(chalk.default.green("\n ✔ All checks passed!\n"));
225
+ }
226
+
227
+ //#endregion
228
+ Object.defineProperty(exports, 'runDoctor', {
229
+ enumerable: true,
230
+ get: function () {
231
+ return runDoctor;
232
+ }
233
+ });
@@ -0,0 +1,6 @@
1
+ const require_chunk = require('./chunk-jS-bbMI5.js');
2
+ require('./paths-AIyBxIzm.js');
3
+ require('./paths-DPovhojT.js');
4
+ const require_doctor = require('./doctor-C6nAGdH8.js');
5
+
6
+ exports.runDoctor = require_doctor.runDoctor;