hyperclaw 5.2.7 → 5.2.8
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/agents-routing-Cee7wrfi.js +398 -0
- package/dist/agents-routing-uNzqjgOr.js +6 -0
- package/dist/api-key-validation-DydlUth1.js +64 -0
- package/dist/api-keys-guide-DqRGa4x7.js +149 -0
- package/dist/audit-CX5poVMR.js +445 -0
- package/dist/bounty-tools-BoU1NN5N.js +211 -0
- package/dist/chat-C07wF0mM.js +494 -0
- package/dist/claw-tasks-BLqd1a0Q.js +80 -0
- package/dist/config-BlLlJ6Er.js +7 -0
- package/dist/config-SgDxKyfV.js +261 -0
- package/dist/cost-tracker-CgEXyEtz.js +103 -0
- package/dist/credentials-store-1LDtNReY.js +89 -0
- package/dist/credentials-store-BFxEJR00.js +7 -0
- package/dist/cron-tasks-1E6wKpTv.js +85 -0
- package/dist/daemon-B13UIqvL.js +7 -0
- package/dist/daemon-CzOW-1PS.js +421 -0
- package/dist/delivery-B8YGmrq5.js +4 -0
- package/dist/delivery-DWsU6gx-.js +95 -0
- package/dist/destructive-gate-bnkroJWG.js +101 -0
- package/dist/engine-ByQ-0sWM.js +7 -0
- package/dist/engine-gnMjO743.js +327 -0
- package/dist/env-resolve-BdagnXhK.js +151 -0
- package/dist/env-resolve-NEtsGacw.js +10 -0
- package/dist/gmail-watch-setup-Brkj94Sy.js +42 -0
- package/dist/heartbeat-engine-D6oSpgxx.js +89 -0
- package/dist/hyperclawbot-DzP_v3iA.js +516 -0
- package/dist/inference-BHJFPEKL.js +8 -0
- package/dist/inference-vweXyh27.js +2854 -0
- package/dist/knowledge-graph-yeMPBPP8.js +134 -0
- package/dist/loader-BXYJl25e.js +6 -0
- package/dist/loader-gTdKBwiI.js +410 -0
- package/dist/logger-C3ZCDSkc.js +86 -0
- package/dist/manager-BI3izlRG.js +120 -0
- package/dist/manager-CQ3MWNHY.js +250 -0
- package/dist/mcp-CklaYr_6.js +142 -0
- package/dist/mcp-loader-9v8eUsNI.js +93 -0
- package/dist/memory-auto-Bow9u_L7.js +306 -0
- package/dist/memory-auto-CgBAI8mm.js +5 -0
- package/dist/memory-integration-CveUEI3V.js +91 -0
- package/dist/moltbook-xP7VXKlX.js +81 -0
- package/dist/node-urDjajMt.js +226 -0
- package/dist/nodes-registry-Cd4eWw80.js +52 -0
- package/dist/oauth-flow-Bt-LaRHV.js +148 -0
- package/dist/oauth-provider-CVTKgj35.js +111 -0
- package/dist/observability-lwYm4aoB.js +89 -0
- package/dist/onboard-BV5Poocl.js +13 -0
- package/dist/onboard-UiynbNQy.js +3909 -0
- package/dist/orchestrator-DMZkAVa5.js +189 -0
- package/dist/orchestrator-rVGu7yYr.js +6 -0
- package/dist/osint-chat-Hn8qpsC1.js +836 -0
- package/dist/osint-f9DeXT6j.js +283 -0
- package/dist/pending-approval-CHUZ_qT6.js +22 -0
- package/dist/run-main.js +68 -65
- package/dist/runner-B9xANekJ.js +1274 -0
- package/dist/security--17Fxo5Z.js +4 -0
- package/dist/security-DP1qtJfL.js +90 -0
- package/dist/server-DUDXqJSo.js +1365 -0
- package/dist/server-ha59nA8a.js +4 -0
- package/dist/skill-runtime-BRp2D8Jb.js +5 -0
- package/dist/skill-runtime-C8bNwKwz.js +104 -0
- package/dist/src-B8LzGLSY.js +63 -0
- package/dist/src-DUoc6_kn.js +458 -0
- package/dist/sub-agent-tools-CldaMfd5.js +39 -0
- package/dist/tool-policy-DtGf3Ifq.js +189 -0
- package/dist/tts-elevenlabs-1zWD3QJw.js +64 -0
- package/dist/vision-DV2ubVjr.js +167 -0
- package/dist/vision-tools-Cb86uMdh.js +5 -0
- package/dist/vision-tools-DlnxaZjg.js +51 -0
- package/dist/voice-transcription-BolTT_HG.js +170 -0
- package/package.json +4 -1
- package/static/chat.html +9 -3
|
@@ -0,0 +1,327 @@
|
|
|
1
|
+
const require_chunk = require('./chunk-jS-bbMI5.js');
|
|
2
|
+
const require_paths = require('./paths-AIyBxIzm.js');
|
|
3
|
+
const require_src = require('./src-CbTAVbeI.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
|
+
try {
|
|
24
|
+
context += `## ${f}\n${fs_extra.default.readFileSync(fp, "utf8")}\n\n`;
|
|
25
|
+
} catch {}
|
|
26
|
+
}
|
|
27
|
+
try {
|
|
28
|
+
const entries = fs_extra.default.readdirSync(dir);
|
|
29
|
+
for (const f of entries) if (f.endsWith(".md") && !core.includes(f)) {
|
|
30
|
+
const fp = path.default.join(dir, f);
|
|
31
|
+
try {
|
|
32
|
+
context += `## ${f}\n${fs_extra.default.readFileSync(fp, "utf8")}\n\n`;
|
|
33
|
+
} catch {}
|
|
34
|
+
}
|
|
35
|
+
} catch {}
|
|
36
|
+
return context;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
|
|
40
|
+
* Load skills context (bundled + workspace)
|
|
41
|
+
|
|
42
|
+
*/
|
|
43
|
+
async function loadSkillsContext() {
|
|
44
|
+
const { loadSkills, buildSkillsContext } = await Promise.resolve().then(() => require("./skill-loader-DwbmjEDa.js"));
|
|
45
|
+
const skills = await loadSkills();
|
|
46
|
+
return skills.length > 0 ? buildSkillsContext(skills) : "";
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
|
|
50
|
+
* Resolve tools with policy, PC access, elevation.
|
|
51
|
+
|
|
52
|
+
*/
|
|
53
|
+
async function resolveTools(opts) {
|
|
54
|
+
const { config, source, elevated, sessionId, daemonMode, activeServer } = opts;
|
|
55
|
+
const cfg = config;
|
|
56
|
+
const sandboxNonMain = cfg?.agents?.defaults?.sandbox?.mode === "non-main" && source && CHANNEL_SOURCES.includes(source);
|
|
57
|
+
const { loadPCAccessConfig, getPCAccessTools } = await Promise.resolve().then(() => require("./pc-access-CaE4x3Vt.js"));
|
|
58
|
+
const pcCfg = await loadPCAccessConfig({ daemonMode });
|
|
59
|
+
const dockerSandbox = cfg?.tools?.dockerSandbox?.enabled === true;
|
|
60
|
+
const pcTools = pcCfg.enabled && (!sandboxNonMain || elevated) ? getPCAccessTools({ dockerSandbox }) : [];
|
|
61
|
+
const { getSessionsTools } = await Promise.resolve().then(() => require("./sessions-tools-B5_ow-s7.js"));
|
|
62
|
+
const sessionsTools = getSessionsTools(() => activeServer ?? null, sessionId);
|
|
63
|
+
const { InferenceEngine, getBuiltinTools } = await Promise.resolve().then(() => require("./inference-BHJFPEKL.js"));
|
|
64
|
+
const { getSubAgentTools } = await Promise.resolve().then(() => require("./sub-agent-tools-CldaMfd5.js"));
|
|
65
|
+
const { getBrowserTools } = await Promise.resolve().then(() => require("./browser-tools-DF2nQ1hi.js"));
|
|
66
|
+
const { getExtractionTools } = await Promise.resolve().then(() => require("./extraction-tools-B8F3nsLR.js"));
|
|
67
|
+
const { getWebsiteWatchTools } = await Promise.resolve().then(() => require("./website-watch-tools-UPSrnBk2.js"));
|
|
68
|
+
const { getVisionTools } = await Promise.resolve().then(() => require("./vision-tools-Cb86uMdh.js"));
|
|
69
|
+
const { getBountyTools } = await Promise.resolve().then(() => require("./bounty-tools-BoU1NN5N.js"));
|
|
70
|
+
const { loadMCPTools } = await Promise.resolve().then(() => require("./mcp-loader-9v8eUsNI.js"));
|
|
71
|
+
const { applyToolPolicy } = await Promise.resolve().then(() => require("./tool-policy-DtGf3Ifq.js"));
|
|
72
|
+
const CUSTOM_BASEURL_PROVIDERS = new Set([
|
|
73
|
+
"groq",
|
|
74
|
+
"mistral",
|
|
75
|
+
"deepseek",
|
|
76
|
+
"perplexity",
|
|
77
|
+
"huggingface",
|
|
78
|
+
"ollama",
|
|
79
|
+
"lmstudio",
|
|
80
|
+
"local",
|
|
81
|
+
"xai",
|
|
82
|
+
"openai",
|
|
83
|
+
"google",
|
|
84
|
+
"minimax",
|
|
85
|
+
"moonshot",
|
|
86
|
+
"qwen",
|
|
87
|
+
"zai",
|
|
88
|
+
"litellm",
|
|
89
|
+
"cloudflare",
|
|
90
|
+
"copilot",
|
|
91
|
+
"vercel-ai",
|
|
92
|
+
"opencode-zen"
|
|
93
|
+
]);
|
|
94
|
+
const isLocal = cfg?.provider?.providerId === "local" || cfg?.provider?.providerId === "ollama" || cfg?.provider?.providerId === "lmstudio";
|
|
95
|
+
const provider = cfg?.provider?.providerId === "anthropic" || cfg?.provider?.providerId === "anthropic-oauth" || cfg?.provider?.providerId === "anthropic-setup-token" ? "anthropic" : cfg?.provider?.providerId === "custom" || isLocal || CUSTOM_BASEURL_PROVIDERS.has(cfg?.provider?.providerId ?? "") ? "custom" : "openrouter";
|
|
96
|
+
const visionProvider = cfg?.provider?.providerId === "custom" || isLocal ? "openrouter" : provider === "anthropic" ? "anthropic" : "openrouter";
|
|
97
|
+
const apiKey = await (await Promise.resolve().then(() => require("./env-resolve-NEtsGacw.js"))).getProviderCredentialAsync(cfg);
|
|
98
|
+
const visionTools = getVisionTools({
|
|
99
|
+
apiKey: apiKey || "",
|
|
100
|
+
provider: visionProvider
|
|
101
|
+
});
|
|
102
|
+
const bountyTools = getBountyTools(cfg);
|
|
103
|
+
let skillInvokeTools = [];
|
|
104
|
+
try {
|
|
105
|
+
const { loadSkills } = await Promise.resolve().then(() => require("./skill-loader-DwbmjEDa.js"));
|
|
106
|
+
const { getSkillInvokeTools } = await Promise.resolve().then(() => require("./skill-runtime-BRp2D8Jb.js"));
|
|
107
|
+
const loaded = await loadSkills();
|
|
108
|
+
skillInvokeTools = getSkillInvokeTools(loaded);
|
|
109
|
+
} catch (e) {
|
|
110
|
+
if (typeof process !== "undefined" && process.env?.DEBUG) console.error("[engine] loadSkills failed:", e?.message ?? e);
|
|
111
|
+
}
|
|
112
|
+
let allTools = [
|
|
113
|
+
...getBuiltinTools(),
|
|
114
|
+
...getSubAgentTools(),
|
|
115
|
+
...sessionsTools,
|
|
116
|
+
...pcTools,
|
|
117
|
+
...getBrowserTools(),
|
|
118
|
+
...getExtractionTools(),
|
|
119
|
+
...getWebsiteWatchTools(),
|
|
120
|
+
...visionTools,
|
|
121
|
+
...bountyTools,
|
|
122
|
+
...skillInvokeTools
|
|
123
|
+
];
|
|
124
|
+
try {
|
|
125
|
+
const mcpTools = await loadMCPTools();
|
|
126
|
+
if (mcpTools.length > 0) allTools = [...allTools, ...mcpTools];
|
|
127
|
+
} catch {}
|
|
128
|
+
const policyConfig = cfg?.tools ? {
|
|
129
|
+
profile: cfg.tools.profile,
|
|
130
|
+
allow: cfg.tools.allow ?? cfg.tools.allowlist,
|
|
131
|
+
deny: cfg.tools.deny ?? cfg.tools.blocklist,
|
|
132
|
+
byProvider: cfg.tools.byProvider
|
|
133
|
+
} : void 0;
|
|
134
|
+
let tools = applyToolPolicy(allTools, policyConfig, {
|
|
135
|
+
provider: cfg?.provider?.providerId === "anthropic" ? "anthropic" : "openrouter",
|
|
136
|
+
model: cfg?.provider?.modelId
|
|
137
|
+
});
|
|
138
|
+
const { applyDestructiveGate } = await Promise.resolve().then(() => require("./destructive-gate-bnkroJWG.js"));
|
|
139
|
+
tools = applyDestructiveGate(tools, {
|
|
140
|
+
elevated: elevated ?? false,
|
|
141
|
+
source,
|
|
142
|
+
sessionId
|
|
143
|
+
});
|
|
144
|
+
return tools;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
|
|
148
|
+
* Run agent: context + tools + inference.
|
|
149
|
+
|
|
150
|
+
*/
|
|
151
|
+
async function runAgentEngine(message, opts) {
|
|
152
|
+
const cfg = await fs_extra.default.readJson(require_paths.getConfigPath()).catch(() => ({}));
|
|
153
|
+
const CUSTOM_BASEURL_IDS = new Set([
|
|
154
|
+
"groq",
|
|
155
|
+
"mistral",
|
|
156
|
+
"deepseek",
|
|
157
|
+
"perplexity",
|
|
158
|
+
"huggingface",
|
|
159
|
+
"ollama",
|
|
160
|
+
"lmstudio",
|
|
161
|
+
"local",
|
|
162
|
+
"xai",
|
|
163
|
+
"openai",
|
|
164
|
+
"google",
|
|
165
|
+
"minimax",
|
|
166
|
+
"moonshot",
|
|
167
|
+
"qwen",
|
|
168
|
+
"zai",
|
|
169
|
+
"litellm",
|
|
170
|
+
"cloudflare",
|
|
171
|
+
"copilot",
|
|
172
|
+
"vercel-ai",
|
|
173
|
+
"opencode-zen"
|
|
174
|
+
]);
|
|
175
|
+
const isLocalProvider = cfg?.provider?.providerId === "local" || cfg?.provider?.providerId === "ollama" || cfg?.provider?.providerId === "lmstudio";
|
|
176
|
+
const apiKey = await (await Promise.resolve().then(() => require("./env-resolve-NEtsGacw.js"))).getProviderCredentialAsync(cfg);
|
|
177
|
+
if (!apiKey && !isLocalProvider) return {
|
|
178
|
+
text: "No API key configured. Run: hyperclaw config set-key",
|
|
179
|
+
error: "no_api_key"
|
|
180
|
+
};
|
|
181
|
+
const { getProvider } = await Promise.resolve().then(() => require("./providers-CFQC39vg.js"));
|
|
182
|
+
const providerMeta = getProvider(cfg?.provider?.providerId ?? "");
|
|
183
|
+
const registryBaseUrl = providerMeta?.baseUrl;
|
|
184
|
+
const sid = opts.sessionId;
|
|
185
|
+
const sessionKey = opts.sessionKey;
|
|
186
|
+
const effectiveKey = sessionKey || sid;
|
|
187
|
+
if (sessionKey && !opts.getTranscript && !opts.appendTranscript) console.warn("[engine] sessionKey provided but getTranscript/appendTranscript missing — session continuity disabled");
|
|
188
|
+
let messagesForInference = [{
|
|
189
|
+
role: "user",
|
|
190
|
+
content: message
|
|
191
|
+
}];
|
|
192
|
+
if (effectiveKey && opts.getTranscript) try {
|
|
193
|
+
const restored = await opts.getTranscript(effectiveKey);
|
|
194
|
+
if (restored && restored.length > 0) {
|
|
195
|
+
const valid = restored.filter((t) => (t.role === "user" || t.role === "assistant") && typeof t.content === "string");
|
|
196
|
+
messagesForInference = [...valid, {
|
|
197
|
+
role: "user",
|
|
198
|
+
content: message
|
|
199
|
+
}];
|
|
200
|
+
}
|
|
201
|
+
} catch (e) {
|
|
202
|
+
console.warn("[engine] Failed to restore transcript for", effectiveKey, e.message);
|
|
203
|
+
}
|
|
204
|
+
if (effectiveKey && opts.appendTranscript) opts.appendTranscript(effectiveKey, "user", message, opts.source);
|
|
205
|
+
let context = await loadWorkspaceContext(opts.workspace);
|
|
206
|
+
try {
|
|
207
|
+
const { getContextSummary } = await Promise.resolve().then(() => require("./knowledge-graph-yeMPBPP8.js"));
|
|
208
|
+
const kg = await getContextSummary(25);
|
|
209
|
+
if (kg) context += kg + "\n\n";
|
|
210
|
+
} catch {}
|
|
211
|
+
context += await loadSkillsContext();
|
|
212
|
+
const serviceKeys = cfg?.skills?.apiKeys ? Object.keys(cfg.skills.apiKeys) : [];
|
|
213
|
+
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`;
|
|
214
|
+
const tools = await resolveTools({
|
|
215
|
+
config: cfg,
|
|
216
|
+
source: opts.source,
|
|
217
|
+
elevated: opts.elevated,
|
|
218
|
+
sessionId: sid,
|
|
219
|
+
daemonMode: opts.daemonMode,
|
|
220
|
+
activeServer: opts.activeServer
|
|
221
|
+
});
|
|
222
|
+
const rawModel = opts.modelOverride || cfg?.provider?.modelId || "claude-sonnet-4-5";
|
|
223
|
+
const isLocal2 = cfg?.provider?.providerId === "local" || cfg?.provider?.providerId === "ollama" || cfg?.provider?.providerId === "lmstudio";
|
|
224
|
+
const model = rawModel.startsWith("ollama/") ? rawModel.slice(7) : rawModel;
|
|
225
|
+
const isAnthropicVariant = cfg?.provider?.providerId === "anthropic" || cfg?.provider?.providerId === "anthropic-oauth" || cfg?.provider?.providerId === "anthropic-setup-token";
|
|
226
|
+
const provider = isAnthropicVariant ? "anthropic" : cfg?.provider?.providerId === "custom" || isLocal2 || CUSTOM_BASEURL_IDS.has(cfg?.provider?.providerId ?? "") ? "custom" : "openrouter";
|
|
227
|
+
const resolvedBaseUrl = cfg?.provider?.baseUrl || registryBaseUrl || (isLocal2 ? "http://localhost:11434/v1" : void 0);
|
|
228
|
+
const ollamaBaseUrl = isLocal2 ? cfg?.provider?.baseUrl || "http://localhost:11434/v1" : void 0;
|
|
229
|
+
const thinkingBudget = opts.thinkingBudget ?? 0;
|
|
230
|
+
const maxTokens = thinkingBudget > 0 ? thinkingBudget + 4096 : 4096;
|
|
231
|
+
try {
|
|
232
|
+
const { InferenceEngine } = await Promise.resolve().then(() => require("./inference-BHJFPEKL.js"));
|
|
233
|
+
const engineOpts = {
|
|
234
|
+
model,
|
|
235
|
+
apiKey,
|
|
236
|
+
provider,
|
|
237
|
+
system: context || void 0,
|
|
238
|
+
tools,
|
|
239
|
+
maxTokens,
|
|
240
|
+
onToken: opts.onToken ?? (() => {}),
|
|
241
|
+
onThinking: opts.onThinking,
|
|
242
|
+
onToolCall: opts.onToolCall,
|
|
243
|
+
onToolResult: opts.onToolResult,
|
|
244
|
+
...provider === "custom" ? { baseUrl: ollamaBaseUrl || resolvedBaseUrl || "" } : {},
|
|
245
|
+
...thinkingBudget > 0 && (model.includes("claude") || model.includes("anthropic")) ? { thinking: { budget_tokens: thinkingBudget } } : {}
|
|
246
|
+
};
|
|
247
|
+
const engine = new InferenceEngine(engineOpts);
|
|
248
|
+
const result = await engine.run(messagesForInference);
|
|
249
|
+
const text = result.text || "(empty)";
|
|
250
|
+
if (effectiveKey && opts.appendTranscript) opts.appendTranscript(effectiveKey, "assistant", text, opts.source);
|
|
251
|
+
try {
|
|
252
|
+
const { AutoMemory } = await Promise.resolve().then(() => require("./memory-auto-CgBAI8mm.js"));
|
|
253
|
+
const mem = new AutoMemory({ extractEveryNTurns: 1 });
|
|
254
|
+
mem.addTurn("user", message);
|
|
255
|
+
mem.addTurn("assistant", text);
|
|
256
|
+
await mem.extract();
|
|
257
|
+
} catch {}
|
|
258
|
+
opts.onDone?.(text);
|
|
259
|
+
opts.onRunEnd?.(result.usage);
|
|
260
|
+
return {
|
|
261
|
+
text,
|
|
262
|
+
usage: result.usage
|
|
263
|
+
};
|
|
264
|
+
} catch (e) {
|
|
265
|
+
const errText = `Error: ${e.message}`;
|
|
266
|
+
opts.onDone?.(errText);
|
|
267
|
+
opts.onRunEnd?.(void 0, e.message);
|
|
268
|
+
return {
|
|
269
|
+
text: errText,
|
|
270
|
+
error: e.message
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
var CHANNEL_SOURCES;
|
|
275
|
+
var init_engine = require_chunk.__esm({ "packages/core/src/agent/engine.ts"() {
|
|
276
|
+
require_src.init_src();
|
|
277
|
+
CHANNEL_SOURCES = [
|
|
278
|
+
"telegram",
|
|
279
|
+
"discord",
|
|
280
|
+
"whatsapp",
|
|
281
|
+
"slack",
|
|
282
|
+
"signal",
|
|
283
|
+
"matrix",
|
|
284
|
+
"line",
|
|
285
|
+
"nostr",
|
|
286
|
+
"feishu",
|
|
287
|
+
"msteams",
|
|
288
|
+
"teams",
|
|
289
|
+
"instagram",
|
|
290
|
+
"messenger",
|
|
291
|
+
"twitter",
|
|
292
|
+
"viber",
|
|
293
|
+
"zalo"
|
|
294
|
+
];
|
|
295
|
+
} });
|
|
296
|
+
|
|
297
|
+
//#endregion
|
|
298
|
+
Object.defineProperty(exports, 'init_engine', {
|
|
299
|
+
enumerable: true,
|
|
300
|
+
get: function () {
|
|
301
|
+
return init_engine;
|
|
302
|
+
}
|
|
303
|
+
});
|
|
304
|
+
Object.defineProperty(exports, 'loadSkillsContext', {
|
|
305
|
+
enumerable: true,
|
|
306
|
+
get: function () {
|
|
307
|
+
return loadSkillsContext;
|
|
308
|
+
}
|
|
309
|
+
});
|
|
310
|
+
Object.defineProperty(exports, 'loadWorkspaceContext', {
|
|
311
|
+
enumerable: true,
|
|
312
|
+
get: function () {
|
|
313
|
+
return loadWorkspaceContext;
|
|
314
|
+
}
|
|
315
|
+
});
|
|
316
|
+
Object.defineProperty(exports, 'resolveTools', {
|
|
317
|
+
enumerable: true,
|
|
318
|
+
get: function () {
|
|
319
|
+
return resolveTools;
|
|
320
|
+
}
|
|
321
|
+
});
|
|
322
|
+
Object.defineProperty(exports, 'runAgentEngine', {
|
|
323
|
+
enumerable: true,
|
|
324
|
+
get: function () {
|
|
325
|
+
return runAgentEngine;
|
|
326
|
+
}
|
|
327
|
+
});
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
const require_chunk = require('./chunk-jS-bbMI5.js');
|
|
2
|
+
|
|
3
|
+
//#region src/infra/env-resolve.ts
|
|
4
|
+
function resolveGatewayToken(authTokenFromConfig) {
|
|
5
|
+
return authTokenFromConfig || process.env.HYPERCLAW_GATEWAY_TOKEN || "";
|
|
6
|
+
}
|
|
7
|
+
function resolveProviderApiKey(cfg) {
|
|
8
|
+
if (!cfg) return "";
|
|
9
|
+
const key = cfg.provider?.apiKey;
|
|
10
|
+
if (key) return key;
|
|
11
|
+
const pid = cfg.provider?.providerId || "openrouter";
|
|
12
|
+
switch (pid) {
|
|
13
|
+
case "openrouter": return process.env.OPENROUTER_API_KEY || "";
|
|
14
|
+
case "anthropic": return process.env.ANTHROPIC_API_KEY || "";
|
|
15
|
+
case "openai": return process.env.OPENAI_API_KEY || "";
|
|
16
|
+
case "xai": return process.env.XAI_API_KEY || "";
|
|
17
|
+
case "google": return process.env.GOOGLE_AI_API_KEY || "";
|
|
18
|
+
case "custom": return "";
|
|
19
|
+
default: return process.env.OPENROUTER_API_KEY || process.env.ANTHROPIC_API_KEY || "";
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
|
|
24
|
+
* H-2: Resolve API key or OAuth access token (async).
|
|
25
|
+
|
|
26
|
+
* Resolution order:
|
|
27
|
+
|
|
28
|
+
* 1. cfg.provider.apiKey (in config file)
|
|
29
|
+
|
|
30
|
+
* 2. CredentialsStore (~/.hyperclaw/credentials/<providerId>.json)
|
|
31
|
+
|
|
32
|
+
* 3. AuthStore (~/.hyperclaw/auth.json providers map)
|
|
33
|
+
|
|
34
|
+
* 4. Environment variables (per-provider mapping in resolveProviderApiKey)
|
|
35
|
+
|
|
36
|
+
* Also handles authType === 'oauth' via the oauth-provider service.
|
|
37
|
+
|
|
38
|
+
*/
|
|
39
|
+
async function getProviderCredentialAsync(cfg) {
|
|
40
|
+
if (!cfg?.provider) return "";
|
|
41
|
+
if (cfg.provider.authType === "oauth") {
|
|
42
|
+
const { getProviderCredentialAsync: getOAuth } = await Promise.resolve().then(() => require("./oauth-provider-CVTKgj35.js"));
|
|
43
|
+
return getOAuth(cfg);
|
|
44
|
+
}
|
|
45
|
+
if (cfg.provider.apiKey) return cfg.provider.apiKey;
|
|
46
|
+
const pid = cfg.provider.providerId || "openrouter";
|
|
47
|
+
try {
|
|
48
|
+
const { CredentialsStore } = await Promise.resolve().then(() => require("./credentials-store-BFxEJR00.js"));
|
|
49
|
+
const { getHyperClawDir } = await Promise.resolve().then(() => require("./paths-D-QecARF.js"));
|
|
50
|
+
const credStore = new CredentialsStore(getHyperClawDir());
|
|
51
|
+
const cred = await credStore.get(pid);
|
|
52
|
+
if (cred?.apiKey) return cred.apiKey;
|
|
53
|
+
} catch (e) {
|
|
54
|
+
if (process.env.DEBUG) console.error("[env-resolve] CredentialsStore:", e?.message);
|
|
55
|
+
}
|
|
56
|
+
try {
|
|
57
|
+
const { AuthStore } = await Promise.resolve().then(() => require("./device-auth-store-DgSabRGa.js"));
|
|
58
|
+
const { getHyperClawDir } = await Promise.resolve().then(() => require("./paths-D-QecARF.js"));
|
|
59
|
+
const authStore = new AuthStore(getHyperClawDir());
|
|
60
|
+
const key = await authStore.getProviderKey(pid);
|
|
61
|
+
if (key) return key;
|
|
62
|
+
} catch (e) {
|
|
63
|
+
if (process.env.DEBUG) console.error("[env-resolve] AuthStore:", e?.message);
|
|
64
|
+
}
|
|
65
|
+
return resolveProviderApiKey(cfg);
|
|
66
|
+
}
|
|
67
|
+
/** Resolve API key for a service (bug bounty, research apps, etc.). Config first, then env. */
|
|
68
|
+
function resolveServiceApiKey(serviceId, cfg) {
|
|
69
|
+
const key = cfg?.skills?.apiKeys?.[serviceId];
|
|
70
|
+
if (key) return key;
|
|
71
|
+
const envKey = SERVICE_ENV[serviceId] || `${serviceId.toUpperCase().replace(/-/g, "_")}_API_KEY`;
|
|
72
|
+
return process.env[envKey] || process.env[envKey.replace(/-/g, "_")] || "";
|
|
73
|
+
}
|
|
74
|
+
function resolveChannelToken(channelId, tokenFromConfig) {
|
|
75
|
+
if (tokenFromConfig) return tokenFromConfig;
|
|
76
|
+
const envKey = CHANNEL_ENV[channelId] || `${channelId.toUpperCase().replace(/-/g, "_")}_BOT_TOKEN`;
|
|
77
|
+
return process.env[envKey] || process.env[`${channelId.toUpperCase()}_BOT_TOKEN`] || "";
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
|
|
81
|
+
* Returns a summary of active path environment overrides.
|
|
82
|
+
|
|
83
|
+
* Useful for `hyperclaw health -v` and `hyperclaw status --all`.
|
|
84
|
+
|
|
85
|
+
*/
|
|
86
|
+
function resolvePathEnvOverrides() {
|
|
87
|
+
return {
|
|
88
|
+
...process.env.HYPERCLAW_HOME ? { hyperclawHome: process.env.HYPERCLAW_HOME } : {},
|
|
89
|
+
...process.env.HYPERCLAW_STATE_DIR ? { stateDir: process.env.HYPERCLAW_STATE_DIR } : {},
|
|
90
|
+
...process.env.HYPERCLAW_CONFIG_PATH ? { configPath: process.env.HYPERCLAW_CONFIG_PATH } : {},
|
|
91
|
+
...process.env.HYPERCLAW_GATEWAY_TOKEN ? { gatewayToken: "(set)" } : {}
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
var CHANNEL_ENV, SERVICE_ENV;
|
|
95
|
+
var init_env_resolve = require_chunk.__esm({ "src/infra/env-resolve.ts"() {
|
|
96
|
+
CHANNEL_ENV = {
|
|
97
|
+
telegram: "TELEGRAM_BOT_TOKEN",
|
|
98
|
+
discord: "DISCORD_BOT_TOKEN",
|
|
99
|
+
slack: "SLACK_BOT_TOKEN"
|
|
100
|
+
};
|
|
101
|
+
SERVICE_ENV = {
|
|
102
|
+
hackerone: "HACKERONE_API_USERNAME",
|
|
103
|
+
"hackerone-token": "HACKERONE_API_TOKEN",
|
|
104
|
+
bugcrowd: "BUGCROWD_API_TOKEN",
|
|
105
|
+
synack: "SYNACK_API_TOKEN"
|
|
106
|
+
};
|
|
107
|
+
} });
|
|
108
|
+
|
|
109
|
+
//#endregion
|
|
110
|
+
Object.defineProperty(exports, 'getProviderCredentialAsync', {
|
|
111
|
+
enumerable: true,
|
|
112
|
+
get: function () {
|
|
113
|
+
return getProviderCredentialAsync;
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
Object.defineProperty(exports, 'init_env_resolve', {
|
|
117
|
+
enumerable: true,
|
|
118
|
+
get: function () {
|
|
119
|
+
return init_env_resolve;
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
Object.defineProperty(exports, 'resolveChannelToken', {
|
|
123
|
+
enumerable: true,
|
|
124
|
+
get: function () {
|
|
125
|
+
return resolveChannelToken;
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
Object.defineProperty(exports, 'resolveGatewayToken', {
|
|
129
|
+
enumerable: true,
|
|
130
|
+
get: function () {
|
|
131
|
+
return resolveGatewayToken;
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
Object.defineProperty(exports, 'resolvePathEnvOverrides', {
|
|
135
|
+
enumerable: true,
|
|
136
|
+
get: function () {
|
|
137
|
+
return resolvePathEnvOverrides;
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
Object.defineProperty(exports, 'resolveProviderApiKey', {
|
|
141
|
+
enumerable: true,
|
|
142
|
+
get: function () {
|
|
143
|
+
return resolveProviderApiKey;
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
Object.defineProperty(exports, 'resolveServiceApiKey', {
|
|
147
|
+
enumerable: true,
|
|
148
|
+
get: function () {
|
|
149
|
+
return resolveServiceApiKey;
|
|
150
|
+
}
|
|
151
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
const require_chunk = require('./chunk-jS-bbMI5.js');
|
|
2
|
+
const require_env_resolve = require('./env-resolve-BdagnXhK.js');
|
|
3
|
+
|
|
4
|
+
require_env_resolve.init_env_resolve();
|
|
5
|
+
exports.getProviderCredentialAsync = require_env_resolve.getProviderCredentialAsync;
|
|
6
|
+
exports.resolveChannelToken = require_env_resolve.resolveChannelToken;
|
|
7
|
+
exports.resolveGatewayToken = require_env_resolve.resolveGatewayToken;
|
|
8
|
+
exports.resolvePathEnvOverrides = require_env_resolve.resolvePathEnvOverrides;
|
|
9
|
+
exports.resolveProviderApiKey = require_env_resolve.resolveProviderApiKey;
|
|
10
|
+
exports.resolveServiceApiKey = require_env_resolve.resolveServiceApiKey;
|
|
@@ -0,0 +1,42 @@
|
|
|
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 fs_extra = require_chunk.__toESM(require("fs-extra"));
|
|
5
|
+
const path = require_chunk.__toESM(require("path"));
|
|
6
|
+
|
|
7
|
+
//#region src/commands/gmail-watch-setup.ts
|
|
8
|
+
require_paths$1.init_paths();
|
|
9
|
+
async function getGmailAccessToken() {
|
|
10
|
+
const hcDir = require_paths.getHyperClawDir();
|
|
11
|
+
const paths = [path.default.join(hcDir, "oauth-google-gmail.json"), path.default.join(hcDir, "oauth-google.json")];
|
|
12
|
+
for (const p of paths) {
|
|
13
|
+
if (!await fs_extra.default.pathExists(p)) continue;
|
|
14
|
+
const data = await fs_extra.default.readJson(p);
|
|
15
|
+
if (data.access_token) return data.access_token;
|
|
16
|
+
}
|
|
17
|
+
throw new Error("No Gmail OAuth token found. Run: hyperclaw auth oauth google-gmail");
|
|
18
|
+
}
|
|
19
|
+
async function setupGmailWatch(opts) {
|
|
20
|
+
const token = await getGmailAccessToken();
|
|
21
|
+
const body = JSON.stringify({
|
|
22
|
+
topicName: opts.topicName,
|
|
23
|
+
labelIds: opts.labelIds || ["INBOX"],
|
|
24
|
+
labelFilterBehavior: "INCLUDE"
|
|
25
|
+
});
|
|
26
|
+
const res = await fetch("https://gmail.googleapis.com/gmail/v1/users/me/watch", {
|
|
27
|
+
method: "POST",
|
|
28
|
+
headers: {
|
|
29
|
+
Authorization: `Bearer ${token}`,
|
|
30
|
+
"Content-Type": "application/json"
|
|
31
|
+
},
|
|
32
|
+
body
|
|
33
|
+
});
|
|
34
|
+
if (!res.ok) {
|
|
35
|
+
const err = await res.text();
|
|
36
|
+
throw new Error(`Gmail API error ${res.status}: ${err}`);
|
|
37
|
+
}
|
|
38
|
+
return res.json();
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
//#endregion
|
|
42
|
+
exports.setupGmailWatch = setupGmailWatch;
|
|
@@ -0,0 +1,89 @@
|
|
|
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 fs_extra = require_chunk.__toESM(require("fs-extra"));
|
|
5
|
+
const path = require_chunk.__toESM(require("path"));
|
|
6
|
+
const http = require_chunk.__toESM(require("http"));
|
|
7
|
+
|
|
8
|
+
//#region src/services/heartbeat-engine.ts
|
|
9
|
+
require_paths$1.init_paths();
|
|
10
|
+
const HC_DIR = require_paths.getHyperClawDir();
|
|
11
|
+
async function getGatewayConfig() {
|
|
12
|
+
try {
|
|
13
|
+
const cfg = await fs_extra.default.readJson(require_paths.getConfigPath());
|
|
14
|
+
const authToken = cfg?.gateway?.authToken || process.env.HYPERCLAW_GATEWAY_TOKEN || "";
|
|
15
|
+
return {
|
|
16
|
+
port: cfg?.gateway?.port ?? 18789,
|
|
17
|
+
authToken: authToken || void 0
|
|
18
|
+
};
|
|
19
|
+
} catch {
|
|
20
|
+
return { port: 18789 };
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
function sanitizeBriefing(text) {
|
|
24
|
+
return text.replace(/\r\n/g, "\n").replace(/[^\x09\x0a\x0d\x20-\x7e]+/g, "").trim().slice(0, 12e3);
|
|
25
|
+
}
|
|
26
|
+
/** Generate morning briefing via agent (POST /api/chat). */
|
|
27
|
+
async function runMorningBriefing() {
|
|
28
|
+
const { port, authToken } = await getGatewayConfig();
|
|
29
|
+
const prompt = `Generate a brief morning briefing (3-5 bullets) for the user based on:
|
|
30
|
+
- MEMORY.md and knowledge graph (projects, preferences, recent facts)
|
|
31
|
+
- Today's reminders (list_reminders)
|
|
32
|
+
- Any relevant context
|
|
33
|
+
|
|
34
|
+
Be concise. Format as markdown bullets. No preamble.`;
|
|
35
|
+
return new Promise((resolve, reject) => {
|
|
36
|
+
const payload = JSON.stringify({ message: prompt });
|
|
37
|
+
const headers = {
|
|
38
|
+
"Content-Type": "application/json",
|
|
39
|
+
"Content-Length": String(Buffer.byteLength(payload))
|
|
40
|
+
};
|
|
41
|
+
if (authToken) headers["Authorization"] = `Bearer ${authToken}`;
|
|
42
|
+
const req = http.default.request({
|
|
43
|
+
hostname: "127.0.0.1",
|
|
44
|
+
port,
|
|
45
|
+
path: "/api/chat",
|
|
46
|
+
method: "POST",
|
|
47
|
+
headers
|
|
48
|
+
}, (res) => {
|
|
49
|
+
let data = "";
|
|
50
|
+
res.on("data", (c) => data += c);
|
|
51
|
+
res.on("end", () => {
|
|
52
|
+
try {
|
|
53
|
+
const j = JSON.parse(data);
|
|
54
|
+
resolve(j.response || j.error || "(no response)");
|
|
55
|
+
} catch {
|
|
56
|
+
resolve(data || "(parse error)");
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
req.on("error", reject);
|
|
61
|
+
req.setTimeout(6e4, () => {
|
|
62
|
+
req.destroy();
|
|
63
|
+
reject(new Error("Briefing timeout"));
|
|
64
|
+
});
|
|
65
|
+
req.write(payload);
|
|
66
|
+
req.end();
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
/** Persist briefing to HEARTBEAT.md and daily log. */
|
|
70
|
+
async function persistBriefing(text) {
|
|
71
|
+
const today = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
|
|
72
|
+
const ts = (/* @__PURE__ */ new Date()).toISOString();
|
|
73
|
+
const sanitized = sanitizeBriefing(text);
|
|
74
|
+
const heartbeatPath = path.default.join(HC_DIR, "HEARTBEAT.md");
|
|
75
|
+
const content = `## Morning Briefing — ${today}\n\n${sanitized}\n\n---\n*Generated ${ts}*\n`;
|
|
76
|
+
await fs_extra.default.ensureDir(HC_DIR);
|
|
77
|
+
if (await fs_extra.default.pathExists(heartbeatPath)) {
|
|
78
|
+
const existing = await fs_extra.default.readFile(heartbeatPath, "utf8");
|
|
79
|
+
await fs_extra.default.writeFile(heartbeatPath, content + "\n" + existing.slice(0, 8e3), "utf8");
|
|
80
|
+
} else await fs_extra.default.writeFile(heartbeatPath, `# HEARTBEAT.md — Proactive Briefings\n\n${content}`, "utf8");
|
|
81
|
+
const logDir = path.default.join(HC_DIR, "logs");
|
|
82
|
+
const logPath = path.default.join(logDir, `heartbeat-${today}.md`);
|
|
83
|
+
await fs_extra.default.ensureDir(logDir);
|
|
84
|
+
await fs_extra.default.appendFile(logPath, `\n## ${ts}\n\n${sanitized}\n`, "utf8");
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
//#endregion
|
|
88
|
+
exports.persistBriefing = persistBriefing;
|
|
89
|
+
exports.runMorningBriefing = runMorningBriefing;
|