hyperclaw 4.0.0 → 4.0.2
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/README.md +53 -18
- package/dist/a2ui-protocol-CT_jDEU9.js +75 -0
- package/dist/agents-routing-683Q2JGp.js +129 -0
- package/dist/agents-routing-BpZBswBH.js +4 -0
- package/dist/api-keys-guide-Bzig1R5W.js +149 -0
- package/dist/api-keys-guide-Dq5Obbp4.js +149 -0
- package/dist/audit-BYxPlnTQ.js +248 -0
- package/dist/bounty-tools-C6LyzxM-.js +211 -0
- package/dist/browser-tools-CQBSbIuO.js +5 -0
- package/dist/browser-tools-YQmwRLLM.js +179 -0
- package/dist/claw-tasks-BRLUvFRD.js +80 -0
- package/dist/connector-3HnyH8fn.js +167 -0
- package/dist/connector-6PMZo5Ky.js +189 -0
- package/dist/connector-B6eoF3DD.js +181 -0
- package/dist/connector-B9tLG8UZ.js +196 -0
- package/dist/connector-BOlqjXWP.js +182 -0
- package/dist/connector-BP8zsbP8.js +189 -0
- package/dist/connector-BPoSevxp.js +286 -0
- package/dist/connector-BRHj773i.js +163 -0
- package/dist/connector-BToxU-jV.js +267 -0
- package/dist/connector-BliDVsJQ.js +239 -0
- package/dist/connector-Bv6s9oP7.js +88 -0
- package/dist/connector-By5wWGTR.js +343 -0
- package/dist/connector-C1BaFFgN.js +213 -0
- package/dist/connector-CRRWY5Wv.js +167 -0
- package/dist/connector-CXPQVGyI.js +85 -0
- package/dist/connector-Cdk1CXKi.js +194 -0
- package/dist/connector-CwlgFgjx.js +181 -0
- package/dist/connector-DFchk6l7.js +178 -0
- package/dist/connector-DKw7tRAy.js +192 -0
- package/dist/connector-DRv1ahC_.js +343 -0
- package/dist/connector-DU63KW94.js +165 -0
- package/dist/connector-Dbvb1Cj9.js +280 -0
- package/dist/connector-DcZdQcgR.js +173 -0
- package/dist/connector-DxKL8VvZ.js +182 -0
- package/dist/connector-T_YdZtzv.js +162 -0
- package/dist/connector-i4gOS9xL.js +154 -0
- package/dist/connector-rHXE1ZD2.js +167 -0
- package/dist/connector-wdUXChwa.js +172 -0
- package/dist/cost-tracker-pVE15Yq4.js +103 -0
- package/dist/credentials-store-BvnMPJwi.js +4 -0
- package/dist/credentials-store-sb-TRLwR.js +77 -0
- package/dist/cron-tasks-BvDFNyiE.js +82 -0
- package/dist/delivery-B-SJqXLn.js +95 -0
- package/dist/delivery-D5Z98EVq.js +95 -0
- package/dist/delivery-DCOXhXEO.js +5 -0
- package/dist/delivery-VgFeuu2J.js +5 -0
- package/dist/destructive-gate-m-dWqUFg.js +101 -0
- package/dist/developer-keys-JaJK3T27.js +127 -0
- package/dist/developer-keys-kyqmtWK3.js +8 -0
- package/dist/doctor-3oi89QIc.js +175 -0
- package/dist/doctor-Cf1XSfp9.js +4 -0
- package/dist/engine-B4eMiTgl.js +7 -0
- package/dist/engine-B8M7dYul.js +7 -0
- package/dist/engine-BhT-1M9W.js +256 -0
- package/dist/engine-D49jnSd_.js +256 -0
- package/dist/env-resolve-DWOQ45jG.js +9 -0
- package/dist/env-resolve-szSWl0UF.js +94 -0
- package/dist/extraction-tools-D3qDFBJ1.js +91 -0
- package/dist/extraction-tools-DLr_AEwq.js +5 -0
- package/dist/form_data-B_hIUrxU.js +8657 -0
- package/dist/gmail-watch-setup-Czt8rXaX.js +40 -0
- package/dist/heartbeat-engine-CRqfPcFM.js +83 -0
- package/dist/hub-DTsqe5Bt.js +6 -0
- package/dist/hub-FrPTA33j.js +515 -0
- package/dist/hyperclawbot-D9KCtc4P.js +480 -0
- package/dist/hyperclawbot-DfMGowZC.js +480 -0
- package/dist/hyperclawbot-Dw27pJo4.js +480 -0
- package/dist/inference-CTWJeX9Q.js +922 -0
- package/dist/inference-ix607p7k.js +6 -0
- package/dist/knowledge-graph-DqA-Fztl.js +131 -0
- package/dist/loader-CISCqBto.js +400 -0
- package/dist/loader-CYMQ8VOS.js +4 -0
- package/dist/logger-8tEtAd3y.js +83 -0
- package/dist/manager-CPjeRe-6.js +4 -0
- package/dist/manager-Cwzj7w5R.js +105 -0
- package/dist/manager-DLmZI-9R.js +6 -0
- package/dist/manager-DSGhn5i3.js +117 -0
- package/dist/manager-DgyF52mg.js +218 -0
- package/dist/manager-Dm8nrMFx.js +40 -0
- package/dist/mcp-B_9Ber63.js +139 -0
- package/dist/mcp-loader-DSM5UiFG.js +94 -0
- package/dist/mcp-loader-j5ZLLw5O.js +94 -0
- package/dist/memory-BI1kPkAN.js +4 -0
- package/dist/memory-BVFGkxxK.js +270 -0
- package/dist/memory-auto-Bc7euou4.js +306 -0
- package/dist/memory-auto-DPfbkMVt.js +5 -0
- package/dist/memory-integration-DZExqWr4.js +91 -0
- package/dist/moltbook-B6ZeGN5_.js +81 -0
- package/dist/node-pwL6O_KX.js +222 -0
- package/dist/nodes-registry-CsPm_-CJ.js +52 -0
- package/dist/oauth-flow-CpWlgvNB.js +150 -0
- package/dist/oauth-provider-BZb6qOw5.js +110 -0
- package/dist/observability-B43YvNQV.js +89 -0
- package/dist/onboard-3q20ZyHj.js +9 -0
- package/dist/onboard-Bd_wsYdi.js +4086 -0
- package/dist/onboard-CAN7x3me.js +3026 -0
- package/dist/onboard-DnegOHMh.js +3026 -0
- package/dist/onboard-RYtDlYBw.js +9 -0
- package/dist/onboard-aTwlQs-4.js +9 -0
- package/dist/orchestrator-BSp2M5EU.js +189 -0
- package/dist/orchestrator-C7ko5tWa.js +6 -0
- package/dist/orchestrator-DfPkIx2Z.js +6 -0
- package/dist/orchestrator-NJQsmiBE.js +189 -0
- package/dist/pairing-DU0_J28n.js +87 -0
- package/dist/pairing-DWllbSbO.js +4 -0
- package/dist/pc-access-Ly-uA8mn.js +8 -0
- package/dist/pc-access-NxBvTrRj.js +819 -0
- package/dist/pending-approval-DIHvwwWS.js +22 -0
- package/dist/puppeteer-2o3QOwAy.js +2 -2
- package/dist/puppeteer-BYTMp3BI.js +2 -2
- package/dist/puppeteer-DQ45qwWk.js +2 -2
- package/dist/reminders-store-D79qdfN0.js +58 -0
- package/dist/renderer-pqlDRKbH.js +225 -0
- package/dist/rules-BooT_qFP.js +103 -0
- package/dist/run-main.js +366 -1109
- package/dist/runner-Bu--_RXw.js +810 -0
- package/dist/runner-D1rjuMTJ.js +810 -0
- package/dist/sdk/index.js +2 -2
- package/dist/sdk/index.mjs +2 -2
- package/dist/security-C-5URby1.js +73 -0
- package/dist/security-_xve79aq.js +4 -0
- package/dist/server-0kgyELx4.js +1047 -0
- package/dist/server-BIuTobTC.js +4 -0
- package/dist/server-BRlCEjyT.js +1047 -0
- package/dist/server-CCI1hv45.js +1047 -0
- package/dist/server-DU9POoWc.js +4 -0
- package/dist/server-RBqwE_GN.js +4 -0
- package/dist/session-store-CujxByI6.js +113 -0
- package/dist/session-store-qpJUg2M1.js +5 -0
- package/dist/sessions-tools-CB2qbwIk.js +5 -0
- package/dist/sessions-tools-DHMaTZIs.js +95 -0
- package/dist/skill-loader-BkceKkIg.js +7 -0
- package/dist/skill-loader-DhgIwK4J.js +159 -0
- package/dist/skill-runtime--LqxWrp5.js +102 -0
- package/dist/skill-runtime-C5l0Tgt-.js +5 -0
- package/dist/skill-runtime-DsXK_HYG.js +102 -0
- package/dist/skill-runtime-IVTiqrMR.js +5 -0
- package/dist/src-BEVLgaF1.js +63 -0
- package/dist/src-Bgu_OxTQ.js +458 -0
- package/dist/src-Bq-oKt7Z.js +458 -0
- package/dist/src-DWCUhnD4.js +20 -0
- package/dist/src-cfRTjFef.js +63 -0
- package/dist/sub-agent-tools-BD9DF8_g.js +39 -0
- package/dist/sub-agent-tools-V7b3T9_s.js +39 -0
- package/dist/tool-policy-DNvNRnve.js +189 -0
- package/dist/tts-elevenlabs-BUOGKL-k.js +61 -0
- package/dist/update-check-BD4qH7Am.js +81 -0
- package/dist/vision-DRq-f-Dj.js +121 -0
- package/dist/vision-tools-CFZEpQKm.js +5 -0
- package/dist/vision-tools-CQnBI9aa.js +51 -0
- package/dist/voice-transcription-CbQBToY0.js +138 -0
- package/dist/voice-transcription-CgWq54hn.js +138 -0
- package/dist/website-watch-tools-Bk_TnwuE.js +5 -0
- package/dist/website-watch-tools-DraMPxdl.js +139 -0
- package/package.json +1 -1
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
const require_chunk = require('./chunk-jS-bbMI5.js');
|
|
2
|
+
|
|
3
|
+
//#region src/infra/destructive-gate.ts
|
|
4
|
+
function isDangerousShellCommand(cmd) {
|
|
5
|
+
const c = (cmd || "").trim();
|
|
6
|
+
for (const re of DANGEROUS_SHELL_PATTERNS) if (re.test(c)) return true;
|
|
7
|
+
return false;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
|
|
11
|
+
* Wrap tools so destructive ones are gated. When sessionId set, stores pending for confirm flow.
|
|
12
|
+
|
|
13
|
+
*/
|
|
14
|
+
function applyDestructiveGate(tools, opts) {
|
|
15
|
+
const { elevated, source, sessionId } = opts;
|
|
16
|
+
const fromChannel = source && CHANNEL_SOURCES.has(source);
|
|
17
|
+
if (!fromChannel || elevated) return tools;
|
|
18
|
+
return tools.map((t) => {
|
|
19
|
+
if (DESTRUCTIVE_TOOLS.includes(t.name)) {
|
|
20
|
+
const orig = t.handler;
|
|
21
|
+
return {
|
|
22
|
+
...t,
|
|
23
|
+
handler: async (input) => {
|
|
24
|
+
if (sessionId) {
|
|
25
|
+
const { setPending } = await Promise.resolve().then(() => require("./pending-approval-DIHvwwWS.js"));
|
|
26
|
+
setPending(sessionId, {
|
|
27
|
+
toolName: t.name,
|
|
28
|
+
input,
|
|
29
|
+
execute: () => orig(input)
|
|
30
|
+
});
|
|
31
|
+
return PENDING_MSG;
|
|
32
|
+
}
|
|
33
|
+
return BLOCKED_MSG;
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
if (t.name === "run_shell") {
|
|
38
|
+
const orig = t.handler;
|
|
39
|
+
return {
|
|
40
|
+
...t,
|
|
41
|
+
handler: async (input) => {
|
|
42
|
+
const cmd = input.command || "";
|
|
43
|
+
if (isDangerousShellCommand(cmd)) {
|
|
44
|
+
if (sessionId) {
|
|
45
|
+
const { setPending } = await Promise.resolve().then(() => require("./pending-approval-DIHvwwWS.js"));
|
|
46
|
+
setPending(sessionId, {
|
|
47
|
+
toolName: "run_shell",
|
|
48
|
+
input,
|
|
49
|
+
execute: () => orig(input)
|
|
50
|
+
});
|
|
51
|
+
return PENDING_MSG;
|
|
52
|
+
}
|
|
53
|
+
return BLOCKED_MSG;
|
|
54
|
+
}
|
|
55
|
+
return orig(input);
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
return t;
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
var DESTRUCTIVE_TOOLS, DANGEROUS_SHELL_PATTERNS, CHANNEL_SOURCES, BLOCKED_MSG, PENDING_MSG;
|
|
63
|
+
var init_destructive_gate = require_chunk.__esm({ "src/infra/destructive-gate.ts"() {
|
|
64
|
+
DESTRUCTIVE_TOOLS = ["delete_file", "kill_process"];
|
|
65
|
+
DANGEROUS_SHELL_PATTERNS = [
|
|
66
|
+
/\brm\s+-[rf]\b|\brm\s+--recursive|\brm\s+-rf\b/,
|
|
67
|
+
/\bmkfs\.|format\s+/i,
|
|
68
|
+
/\bdd\s+if=/,
|
|
69
|
+
/\b>\/dev\/sd[a-z]/,
|
|
70
|
+
/\bshutdown\s+-/,
|
|
71
|
+
/\breboot\b/i,
|
|
72
|
+
/\b:\(\)\s*\{\s*:\s*\|\s*:\s*&\s*\}/,
|
|
73
|
+
/\bcurl\s+.*\s*\|\s*sh\b/,
|
|
74
|
+
/\bwget\s+.*\s*\|\s*(bash|sh)\b/
|
|
75
|
+
];
|
|
76
|
+
CHANNEL_SOURCES = new Set([
|
|
77
|
+
"telegram",
|
|
78
|
+
"discord",
|
|
79
|
+
"whatsapp",
|
|
80
|
+
"slack",
|
|
81
|
+
"signal",
|
|
82
|
+
"matrix",
|
|
83
|
+
"line",
|
|
84
|
+
"nostr",
|
|
85
|
+
"feishu",
|
|
86
|
+
"msteams",
|
|
87
|
+
"teams",
|
|
88
|
+
"instagram",
|
|
89
|
+
"messenger",
|
|
90
|
+
"twitter",
|
|
91
|
+
"viber",
|
|
92
|
+
"zalo",
|
|
93
|
+
"webhook:inbound"
|
|
94
|
+
]);
|
|
95
|
+
BLOCKED_MSG = "Blocked: destructive action requires elevated session. Use \"elevate\" or run from CLI with full access.";
|
|
96
|
+
PENDING_MSG = "This action requires confirmation. Ask the user to reply \"confirm\" to proceed.";
|
|
97
|
+
} });
|
|
98
|
+
|
|
99
|
+
//#endregion
|
|
100
|
+
init_destructive_gate();
|
|
101
|
+
exports.applyDestructiveGate = applyDestructiveGate;
|
|
@@ -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-JaJK3T27.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,175 @@
|
|
|
1
|
+
const require_chunk = require('./chunk-jS-bbMI5.js');
|
|
2
|
+
const chalk = require_chunk.__toESM(require("chalk"));
|
|
3
|
+
const ora = require_chunk.__toESM(require("ora"));
|
|
4
|
+
const fs_extra = require_chunk.__toESM(require("fs-extra"));
|
|
5
|
+
const path = require_chunk.__toESM(require("path"));
|
|
6
|
+
const os = require_chunk.__toESM(require("os"));
|
|
7
|
+
const net = require_chunk.__toESM(require("net"));
|
|
8
|
+
|
|
9
|
+
//#region src/commands/doctor.ts
|
|
10
|
+
async function isPortOpen(port) {
|
|
11
|
+
return new Promise((resolve) => {
|
|
12
|
+
const s = new net.default.Socket();
|
|
13
|
+
s.setTimeout(500);
|
|
14
|
+
s.on("connect", () => {
|
|
15
|
+
s.destroy();
|
|
16
|
+
resolve(true);
|
|
17
|
+
});
|
|
18
|
+
s.on("error", () => resolve(false));
|
|
19
|
+
s.on("timeout", () => resolve(false));
|
|
20
|
+
try {
|
|
21
|
+
s.connect(port, "127.0.0.1");
|
|
22
|
+
} catch {
|
|
23
|
+
resolve(false);
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
async function runDoctor(fix = false) {
|
|
28
|
+
const spinner = (0, ora.default)("Running health checks...").start();
|
|
29
|
+
await new Promise((r) => setTimeout(r, 800));
|
|
30
|
+
spinner.stop();
|
|
31
|
+
const configDir = path.default.join(os.default.homedir(), ".hyperclaw");
|
|
32
|
+
const configFile = path.default.join(configDir, "config.json");
|
|
33
|
+
const agentsFile = path.default.join(configDir, "AGENTS.md");
|
|
34
|
+
const authFile = path.default.join(configDir, "auth.json");
|
|
35
|
+
const pairingFile = path.default.join(configDir, "pairing-store.json");
|
|
36
|
+
let cfg = null;
|
|
37
|
+
try {
|
|
38
|
+
cfg = fs_extra.default.readJsonSync(configFile);
|
|
39
|
+
} catch {}
|
|
40
|
+
const issues = [];
|
|
41
|
+
if (!cfg) issues.push({
|
|
42
|
+
id: "no-config",
|
|
43
|
+
severity: "error",
|
|
44
|
+
title: "No configuration found",
|
|
45
|
+
detail: "Run: hyperclaw init",
|
|
46
|
+
fixable: false
|
|
47
|
+
});
|
|
48
|
+
else {
|
|
49
|
+
const hasToken = !!cfg.gateway?.authToken;
|
|
50
|
+
issues.push({
|
|
51
|
+
id: "gateway-token",
|
|
52
|
+
severity: hasToken ? "ok" : "warn",
|
|
53
|
+
title: hasToken ? "Gateway auth token set" : "Gateway auth token missing",
|
|
54
|
+
detail: hasToken ? "Token is configured" : "Set a strong token in gateway config",
|
|
55
|
+
fixable: !hasToken,
|
|
56
|
+
fix: async () => {
|
|
57
|
+
const crypto = await import("crypto");
|
|
58
|
+
cfg.gateway = cfg.gateway || {};
|
|
59
|
+
cfg.gateway.authToken = crypto.randomBytes(32).toString("hex");
|
|
60
|
+
fs_extra.default.writeJsonSync(configFile, cfg, { spaces: 2 });
|
|
61
|
+
console.log(chalk.default.green(" ✔ Generated and saved gateway auth token"));
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
const channels = cfg.channels || [];
|
|
65
|
+
const channelConfigs = cfg.channelConfigs || {};
|
|
66
|
+
for (const ch of channels) {
|
|
67
|
+
const dmPolicy = channelConfigs[ch]?.dmPolicy?.policy;
|
|
68
|
+
if (dmPolicy === "open") issues.push({
|
|
69
|
+
id: `dm-open-${ch}`,
|
|
70
|
+
severity: "warn",
|
|
71
|
+
title: `DM policy is "open" on ${ch}`,
|
|
72
|
+
detail: `Anyone can DM your agent on ${ch}. Consider using "pairing" or "allowlist".`,
|
|
73
|
+
fixable: false
|
|
74
|
+
});
|
|
75
|
+
if (dmPolicy === "allowlist") {
|
|
76
|
+
const allowFrom = channelConfigs[ch]?.dmPolicy?.allowFrom || [];
|
|
77
|
+
if (allowFrom.length === 0) issues.push({
|
|
78
|
+
id: `dm-empty-allowlist-${ch}`,
|
|
79
|
+
severity: "error",
|
|
80
|
+
title: `Empty allowlist on ${ch} — DMs will be silently dropped`,
|
|
81
|
+
detail: `channel.${ch}.dmPolicy.allowFrom is empty. Add users or change policy.`,
|
|
82
|
+
fixable: true,
|
|
83
|
+
fix: async () => {
|
|
84
|
+
try {
|
|
85
|
+
const pairingEntries = fs_extra.default.readJsonSync(pairingFile);
|
|
86
|
+
const approved = pairingEntries.filter((e) => e.channelId === ch && e.status === "approved" && e.userId);
|
|
87
|
+
if (approved.length > 0) {
|
|
88
|
+
channelConfigs[ch].dmPolicy.allowFrom = approved.map((e) => e.userId);
|
|
89
|
+
cfg.channelConfigs = channelConfigs;
|
|
90
|
+
fs_extra.default.writeJsonSync(configFile, cfg, { spaces: 2 });
|
|
91
|
+
console.log(chalk.default.green(` ✔ Restored ${approved.length} user(s) from pairing store to ${ch} allowlist`));
|
|
92
|
+
}
|
|
93
|
+
} catch {}
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
const hasApiKey = !!cfg.provider?.apiKey;
|
|
99
|
+
const isLocal = cfg.provider?.providerId === "local";
|
|
100
|
+
if (!hasApiKey && !isLocal) issues.push({
|
|
101
|
+
id: "no-api-key",
|
|
102
|
+
severity: "error",
|
|
103
|
+
title: "No AI provider API key configured",
|
|
104
|
+
detail: "Run: hyperclaw config set-key",
|
|
105
|
+
fixable: false
|
|
106
|
+
});
|
|
107
|
+
else issues.push({
|
|
108
|
+
id: "api-key",
|
|
109
|
+
severity: "ok",
|
|
110
|
+
title: "AI provider key configured",
|
|
111
|
+
detail: `Provider: ${cfg.provider?.providerId}`,
|
|
112
|
+
fixable: false
|
|
113
|
+
});
|
|
114
|
+
issues.push({
|
|
115
|
+
id: "agents-md",
|
|
116
|
+
severity: await fs_extra.default.pathExists(agentsFile) ? "ok" : "warn",
|
|
117
|
+
title: await fs_extra.default.pathExists(agentsFile) ? "AGENTS.md exists" : "AGENTS.md missing",
|
|
118
|
+
detail: await fs_extra.default.pathExists(agentsFile) ? agentsFile : "Run: hyperclaw memory init to generate",
|
|
119
|
+
fixable: false
|
|
120
|
+
});
|
|
121
|
+
const port = cfg.gateway?.port || 1515;
|
|
122
|
+
const running = await isPortOpen(port);
|
|
123
|
+
issues.push({
|
|
124
|
+
id: "gateway-running",
|
|
125
|
+
severity: running ? "ok" : "warn",
|
|
126
|
+
title: running ? `Gateway running on port ${port}` : `Gateway not running on port ${port}`,
|
|
127
|
+
detail: running ? `ws://127.0.0.1:${port}` : "Run: hyperclaw daemon start",
|
|
128
|
+
fixable: false
|
|
129
|
+
});
|
|
130
|
+
if (await fs_extra.default.pathExists(authFile)) {
|
|
131
|
+
const stat = await fs_extra.default.stat(authFile);
|
|
132
|
+
const unsafe = (stat.mode & 63) !== 0;
|
|
133
|
+
issues.push({
|
|
134
|
+
id: "auth-permissions",
|
|
135
|
+
severity: unsafe ? "warn" : "ok",
|
|
136
|
+
title: unsafe ? "Auth store has unsafe permissions" : "Auth store permissions OK",
|
|
137
|
+
detail: unsafe ? `chmod 600 ${authFile}` : `Mode: 600`,
|
|
138
|
+
fixable: unsafe,
|
|
139
|
+
fix: async () => {
|
|
140
|
+
await fs_extra.default.chmod(authFile, 384);
|
|
141
|
+
console.log(chalk.default.green(` ✔ Fixed permissions on ${authFile}`));
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
console.log(chalk.default.bold.cyan("\n 🩺 HYPERCLAW DOCTOR\n"));
|
|
147
|
+
let errorCount = 0, warnCount = 0;
|
|
148
|
+
for (const issue of issues) {
|
|
149
|
+
const icon = {
|
|
150
|
+
error: chalk.default.red("✖"),
|
|
151
|
+
warn: chalk.default.yellow("⚠"),
|
|
152
|
+
ok: chalk.default.green("✔")
|
|
153
|
+
}[issue.severity];
|
|
154
|
+
console.log(` ${icon} ${chalk.default.white(issue.title)}`);
|
|
155
|
+
console.log(` ${chalk.default.gray(issue.detail)}`);
|
|
156
|
+
if (issue.fixable && fix && issue.fix) await issue.fix();
|
|
157
|
+
else if (issue.fixable && !fix) console.log(chalk.default.gray(" Run with --fix to auto-repair"));
|
|
158
|
+
if (issue.severity === "error") errorCount++;
|
|
159
|
+
if (issue.severity === "warn") warnCount++;
|
|
160
|
+
console.log();
|
|
161
|
+
}
|
|
162
|
+
const total = issues.length;
|
|
163
|
+
const okCount = total - errorCount - warnCount;
|
|
164
|
+
console.log(` ${chalk.default.bold("Summary:")} ${chalk.default.green(`${okCount} ok`)} ${chalk.default.yellow(`${warnCount} warnings`)} ${chalk.default.red(`${errorCount} errors`)}`);
|
|
165
|
+
if (errorCount > 0 || warnCount > 0) console.log(chalk.default.gray("\n Run: hyperclaw doctor --fix to auto-repair fixable issues\n"));
|
|
166
|
+
else console.log(chalk.default.green("\n ✔ All checks passed!\n"));
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
//#endregion
|
|
170
|
+
Object.defineProperty(exports, 'runDoctor', {
|
|
171
|
+
enumerable: true,
|
|
172
|
+
get: function () {
|
|
173
|
+
return runDoctor;
|
|
174
|
+
}
|
|
175
|
+
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
const require_chunk = require('./chunk-jS-bbMI5.js');
|
|
2
|
+
require('./paths-AIyBxIzm.js');
|
|
3
|
+
require('./src-DWCUhnD4.js');
|
|
4
|
+
const require_engine = require('./engine-BhT-1M9W.js');
|
|
5
|
+
|
|
6
|
+
require_engine.init_engine();
|
|
7
|
+
exports.runAgentEngine = require_engine.runAgentEngine;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
const require_chunk = require('./chunk-jS-bbMI5.js');
|
|
2
|
+
require('./paths-AIyBxIzm.js');
|
|
3
|
+
require('./src-BeacbqsZ.js');
|
|
4
|
+
const require_engine = require('./engine-D49jnSd_.js');
|
|
5
|
+
|
|
6
|
+
require_engine.init_engine();
|
|
7
|
+
exports.runAgentEngine = require_engine.runAgentEngine;
|
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
const require_chunk = require('./chunk-jS-bbMI5.js');
|
|
2
|
+
const require_paths = require('./paths-AIyBxIzm.js');
|
|
3
|
+
const require_src = require('./src-DWCUhnD4.js');
|
|
4
|
+
const fs_extra = require_chunk.__toESM(require("fs-extra"));
|
|
5
|
+
const path = require_chunk.__toESM(require("path"));
|
|
6
|
+
|
|
7
|
+
//#region packages/core/src/agent/engine.ts
|
|
8
|
+
/**
|
|
9
|
+
|
|
10
|
+
* Load workspace context: SOUL, AGENTS, MEMORY + custom .md
|
|
11
|
+
|
|
12
|
+
*/
|
|
13
|
+
async function loadWorkspaceContext(hcDir) {
|
|
14
|
+
const dir = hcDir || require_paths.getHyperClawDir();
|
|
15
|
+
let context = "";
|
|
16
|
+
const core = [
|
|
17
|
+
"SOUL.md",
|
|
18
|
+
"AGENTS.md",
|
|
19
|
+
"MEMORY.md"
|
|
20
|
+
];
|
|
21
|
+
for (const f of core) {
|
|
22
|
+
const fp = path.default.join(dir, f);
|
|
23
|
+
if (fs_extra.default.pathExistsSync(fp)) context += `## ${f}\n${fs_extra.default.readFileSync(fp, "utf8")}\n\n`;
|
|
24
|
+
}
|
|
25
|
+
try {
|
|
26
|
+
const entries = fs_extra.default.readdirSync(dir);
|
|
27
|
+
for (const f of entries) if (f.endsWith(".md") && !core.includes(f)) {
|
|
28
|
+
const fp = path.default.join(dir, f);
|
|
29
|
+
if (fs_extra.default.statSync(fp).isFile()) context += `## ${f}\n${fs_extra.default.readFileSync(fp, "utf8")}\n\n`;
|
|
30
|
+
}
|
|
31
|
+
} catch {}
|
|
32
|
+
return context;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
|
|
36
|
+
* Load skills context (bundled + workspace)
|
|
37
|
+
|
|
38
|
+
*/
|
|
39
|
+
async function loadSkillsContext() {
|
|
40
|
+
const { loadSkills, buildSkillsContext } = await Promise.resolve().then(() => require("./skill-loader-BkceKkIg.js"));
|
|
41
|
+
const skills = await loadSkills();
|
|
42
|
+
return skills.length > 0 ? buildSkillsContext(skills) : "";
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
|
|
46
|
+
* Resolve tools with policy, PC access, elevation.
|
|
47
|
+
|
|
48
|
+
*/
|
|
49
|
+
async function resolveTools(opts) {
|
|
50
|
+
const { config, source, elevated, sessionId, daemonMode, activeServer } = opts;
|
|
51
|
+
const cfg = config;
|
|
52
|
+
const sandboxNonMain = cfg?.agents?.defaults?.sandbox?.mode === "non-main" && source && CHANNEL_SOURCES.includes(source);
|
|
53
|
+
const { loadPCAccessConfig, getPCAccessTools } = await Promise.resolve().then(() => require("./pc-access-Ly-uA8mn.js"));
|
|
54
|
+
const pcCfg = await loadPCAccessConfig({ daemonMode });
|
|
55
|
+
const dockerSandbox = cfg?.tools?.dockerSandbox?.enabled === true;
|
|
56
|
+
const pcTools = pcCfg.enabled && (!sandboxNonMain || elevated) ? getPCAccessTools({ dockerSandbox }) : [];
|
|
57
|
+
const { getSessionsTools } = await Promise.resolve().then(() => require("./sessions-tools-CB2qbwIk.js"));
|
|
58
|
+
const sessionsTools = getSessionsTools(() => activeServer ?? null, sessionId);
|
|
59
|
+
const { InferenceEngine, getBuiltinTools } = await Promise.resolve().then(() => require("./inference-ix607p7k.js"));
|
|
60
|
+
const { getSubAgentTools } = await Promise.resolve().then(() => require("./sub-agent-tools-BD9DF8_g.js"));
|
|
61
|
+
const { getBrowserTools } = await Promise.resolve().then(() => require("./browser-tools-CQBSbIuO.js"));
|
|
62
|
+
const { getExtractionTools } = await Promise.resolve().then(() => require("./extraction-tools-DLr_AEwq.js"));
|
|
63
|
+
const { getWebsiteWatchTools } = await Promise.resolve().then(() => require("./website-watch-tools-Bk_TnwuE.js"));
|
|
64
|
+
const { getVisionTools } = await Promise.resolve().then(() => require("./vision-tools-CFZEpQKm.js"));
|
|
65
|
+
const { getBountyTools } = await Promise.resolve().then(() => require("./bounty-tools-C6LyzxM-.js"));
|
|
66
|
+
const { loadMCPTools } = await Promise.resolve().then(() => require("./mcp-loader-DSM5UiFG.js"));
|
|
67
|
+
const { applyToolPolicy } = await Promise.resolve().then(() => require("./tool-policy-DNvNRnve.js"));
|
|
68
|
+
const isLocal = cfg?.provider?.providerId === "local" || cfg?.provider?.providerId === "ollama";
|
|
69
|
+
const provider = cfg?.provider?.providerId === "anthropic" ? "anthropic" : cfg?.provider?.providerId === "custom" || isLocal ? "custom" : "openrouter";
|
|
70
|
+
const visionProvider = cfg?.provider?.providerId === "custom" || isLocal ? "openrouter" : provider === "anthropic" ? "anthropic" : "openrouter";
|
|
71
|
+
const apiKey = await (await Promise.resolve().then(() => require("./env-resolve-DWOQ45jG.js"))).getProviderCredentialAsync(cfg);
|
|
72
|
+
const visionTools = getVisionTools({
|
|
73
|
+
apiKey: apiKey || "",
|
|
74
|
+
provider: visionProvider
|
|
75
|
+
});
|
|
76
|
+
const bountyTools = getBountyTools(cfg);
|
|
77
|
+
let skillInvokeTools = [];
|
|
78
|
+
try {
|
|
79
|
+
const { loadSkills } = await Promise.resolve().then(() => require("./skill-loader-BkceKkIg.js"));
|
|
80
|
+
const { getSkillInvokeTools } = await Promise.resolve().then(() => require("./skill-runtime-C5l0Tgt-.js"));
|
|
81
|
+
const loaded = await loadSkills();
|
|
82
|
+
skillInvokeTools = getSkillInvokeTools(loaded);
|
|
83
|
+
} catch {}
|
|
84
|
+
let allTools = [
|
|
85
|
+
...getBuiltinTools(),
|
|
86
|
+
...getSubAgentTools(),
|
|
87
|
+
...sessionsTools,
|
|
88
|
+
...pcTools,
|
|
89
|
+
...getBrowserTools(),
|
|
90
|
+
...getExtractionTools(),
|
|
91
|
+
...getWebsiteWatchTools(),
|
|
92
|
+
...visionTools,
|
|
93
|
+
...bountyTools,
|
|
94
|
+
...skillInvokeTools
|
|
95
|
+
];
|
|
96
|
+
try {
|
|
97
|
+
const mcpTools = await loadMCPTools();
|
|
98
|
+
if (mcpTools.length > 0) allTools = [...allTools, ...mcpTools];
|
|
99
|
+
} catch {}
|
|
100
|
+
const policyConfig = cfg?.tools ? {
|
|
101
|
+
profile: cfg.tools.profile,
|
|
102
|
+
allow: cfg.tools.allow ?? cfg.tools.allowlist,
|
|
103
|
+
deny: cfg.tools.deny ?? cfg.tools.blocklist,
|
|
104
|
+
byProvider: cfg.tools.byProvider
|
|
105
|
+
} : void 0;
|
|
106
|
+
let tools = applyToolPolicy(allTools, policyConfig, {
|
|
107
|
+
provider: cfg?.provider?.providerId === "anthropic" ? "anthropic" : "openrouter",
|
|
108
|
+
model: cfg?.provider?.modelId
|
|
109
|
+
});
|
|
110
|
+
const { applyDestructiveGate } = await Promise.resolve().then(() => require("./destructive-gate-m-dWqUFg.js"));
|
|
111
|
+
tools = applyDestructiveGate(tools, {
|
|
112
|
+
elevated: elevated ?? false,
|
|
113
|
+
source,
|
|
114
|
+
sessionId
|
|
115
|
+
});
|
|
116
|
+
return tools;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
|
|
120
|
+
* Run agent: context + tools + inference.
|
|
121
|
+
|
|
122
|
+
*/
|
|
123
|
+
async function runAgentEngine(message, opts) {
|
|
124
|
+
const cfg = await fs_extra.default.readJson(require_paths.getConfigPath()).catch(() => ({}));
|
|
125
|
+
const isLocalProvider = cfg?.provider?.providerId === "local" || cfg?.provider?.providerId === "ollama";
|
|
126
|
+
const apiKey = await (await Promise.resolve().then(() => require("./env-resolve-DWOQ45jG.js"))).getProviderCredentialAsync(cfg);
|
|
127
|
+
if (!apiKey && !isLocalProvider) return {
|
|
128
|
+
text: "No API key configured. Run: hyperclaw config set-key",
|
|
129
|
+
error: "no_api_key"
|
|
130
|
+
};
|
|
131
|
+
const sid = opts.sessionId;
|
|
132
|
+
if (sid && opts.appendTranscript) opts.appendTranscript(sid, "user", message);
|
|
133
|
+
let context = await loadWorkspaceContext(opts.workspace);
|
|
134
|
+
try {
|
|
135
|
+
const { getContextSummary } = await Promise.resolve().then(() => require("./knowledge-graph-DqA-Fztl.js"));
|
|
136
|
+
const kg = await getContextSummary(25);
|
|
137
|
+
if (kg) context += kg + "\n\n";
|
|
138
|
+
} catch {}
|
|
139
|
+
context += await loadSkillsContext();
|
|
140
|
+
const serviceKeys = cfg?.skills?.apiKeys ? Object.keys(cfg.skills.apiKeys) : [];
|
|
141
|
+
if (serviceKeys.length > 0) context += `\n## Service API Keys (configured)\nAvailable for research/skills: ${serviceKeys.join(", ")}. Use hackerone_list_programs, bugcrowd_list_programs, synack_list_targets when applicable, or create_skill for custom integrations.\n\n`;
|
|
142
|
+
const tools = await resolveTools({
|
|
143
|
+
config: cfg,
|
|
144
|
+
source: opts.source,
|
|
145
|
+
elevated: opts.elevated,
|
|
146
|
+
sessionId: sid,
|
|
147
|
+
daemonMode: opts.daemonMode,
|
|
148
|
+
activeServer: opts.activeServer
|
|
149
|
+
});
|
|
150
|
+
const rawModel = opts.modelOverride || cfg?.provider?.modelId || "claude-sonnet-4-5";
|
|
151
|
+
const isLocal2 = cfg?.provider?.providerId === "local" || cfg?.provider?.providerId === "ollama";
|
|
152
|
+
const model = rawModel.startsWith("ollama/") ? rawModel.slice(7) : rawModel;
|
|
153
|
+
const provider = cfg?.provider?.providerId === "anthropic" ? "anthropic" : cfg?.provider?.providerId === "custom" || isLocal2 ? "custom" : "openrouter";
|
|
154
|
+
const ollamaBaseUrl = isLocal2 ? cfg?.provider?.baseUrl || "http://localhost:11434/v1" : void 0;
|
|
155
|
+
const thinkingBudget = opts.thinkingBudget ?? 0;
|
|
156
|
+
const maxTokens = thinkingBudget > 0 ? thinkingBudget + 4096 : 4096;
|
|
157
|
+
try {
|
|
158
|
+
const { InferenceEngine } = await Promise.resolve().then(() => require("./inference-ix607p7k.js"));
|
|
159
|
+
const engineOpts = {
|
|
160
|
+
model,
|
|
161
|
+
apiKey,
|
|
162
|
+
provider,
|
|
163
|
+
system: context || void 0,
|
|
164
|
+
tools,
|
|
165
|
+
maxTokens,
|
|
166
|
+
onToken: opts.onToken ?? (() => {}),
|
|
167
|
+
onThinking: opts.onThinking,
|
|
168
|
+
onToolCall: opts.onToolCall,
|
|
169
|
+
onToolResult: opts.onToolResult,
|
|
170
|
+
...provider === "custom" ? { baseUrl: ollamaBaseUrl || cfg?.provider?.baseUrl || "" } : {},
|
|
171
|
+
...thinkingBudget > 0 && (model.includes("claude") || model.includes("anthropic")) ? { thinking: { budget_tokens: thinkingBudget } } : {}
|
|
172
|
+
};
|
|
173
|
+
const engine = new InferenceEngine(engineOpts);
|
|
174
|
+
const result = await engine.run([{
|
|
175
|
+
role: "user",
|
|
176
|
+
content: message
|
|
177
|
+
}]);
|
|
178
|
+
const text = result.text || "(empty)";
|
|
179
|
+
if (sid && opts.appendTranscript) opts.appendTranscript(sid, "assistant", text);
|
|
180
|
+
try {
|
|
181
|
+
const { AutoMemory } = await Promise.resolve().then(() => require("./memory-auto-DPfbkMVt.js"));
|
|
182
|
+
const mem = new AutoMemory({ extractEveryNTurns: 1 });
|
|
183
|
+
mem.addTurn("user", message);
|
|
184
|
+
mem.addTurn("assistant", text);
|
|
185
|
+
await mem.extract();
|
|
186
|
+
} catch {}
|
|
187
|
+
opts.onDone?.(text);
|
|
188
|
+
opts.onRunEnd?.(result.usage);
|
|
189
|
+
return {
|
|
190
|
+
text,
|
|
191
|
+
usage: result.usage
|
|
192
|
+
};
|
|
193
|
+
} catch (e) {
|
|
194
|
+
const errText = `Error: ${e.message}`;
|
|
195
|
+
opts.onDone?.(errText);
|
|
196
|
+
opts.onRunEnd?.(void 0, e.message);
|
|
197
|
+
return {
|
|
198
|
+
text: errText,
|
|
199
|
+
error: e.message
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
var CHANNEL_SOURCES;
|
|
204
|
+
var init_engine = require_chunk.__esm({ "packages/core/src/agent/engine.ts"() {
|
|
205
|
+
require_src.init_src();
|
|
206
|
+
CHANNEL_SOURCES = [
|
|
207
|
+
"telegram",
|
|
208
|
+
"discord",
|
|
209
|
+
"whatsapp",
|
|
210
|
+
"slack",
|
|
211
|
+
"signal",
|
|
212
|
+
"matrix",
|
|
213
|
+
"line",
|
|
214
|
+
"nostr",
|
|
215
|
+
"feishu",
|
|
216
|
+
"msteams",
|
|
217
|
+
"teams",
|
|
218
|
+
"instagram",
|
|
219
|
+
"messenger",
|
|
220
|
+
"twitter",
|
|
221
|
+
"viber",
|
|
222
|
+
"zalo"
|
|
223
|
+
];
|
|
224
|
+
} });
|
|
225
|
+
|
|
226
|
+
//#endregion
|
|
227
|
+
Object.defineProperty(exports, 'init_engine', {
|
|
228
|
+
enumerable: true,
|
|
229
|
+
get: function () {
|
|
230
|
+
return init_engine;
|
|
231
|
+
}
|
|
232
|
+
});
|
|
233
|
+
Object.defineProperty(exports, 'loadSkillsContext', {
|
|
234
|
+
enumerable: true,
|
|
235
|
+
get: function () {
|
|
236
|
+
return loadSkillsContext;
|
|
237
|
+
}
|
|
238
|
+
});
|
|
239
|
+
Object.defineProperty(exports, 'loadWorkspaceContext', {
|
|
240
|
+
enumerable: true,
|
|
241
|
+
get: function () {
|
|
242
|
+
return loadWorkspaceContext;
|
|
243
|
+
}
|
|
244
|
+
});
|
|
245
|
+
Object.defineProperty(exports, 'resolveTools', {
|
|
246
|
+
enumerable: true,
|
|
247
|
+
get: function () {
|
|
248
|
+
return resolveTools;
|
|
249
|
+
}
|
|
250
|
+
});
|
|
251
|
+
Object.defineProperty(exports, 'runAgentEngine', {
|
|
252
|
+
enumerable: true,
|
|
253
|
+
get: function () {
|
|
254
|
+
return runAgentEngine;
|
|
255
|
+
}
|
|
256
|
+
});
|