@sesamespace/hivemind 0.8.4 → 0.8.5
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/.pnpmrc.json +1 -0
- package/DASHBOARD-PLAN.md +206 -0
- package/TOOL-USE-DESIGN.md +173 -0
- package/config/default.toml +3 -1
- package/dist/{chunk-3CQJQUY3.js → chunk-ELRUZHT5.js} +2 -2
- package/dist/{chunk-DODOQGIL.js → chunk-ESY7ZS46.js} +29 -11
- package/dist/chunk-ESY7ZS46.js.map +1 -0
- package/dist/{chunk-CSYDOZE6.js → chunk-FQ2HFJDZ.js} +2 -2
- package/dist/{chunk-6S5UKFTZ.js → chunk-Q5ZO5WXM.js} +236 -28
- package/dist/chunk-Q5ZO5WXM.js.map +1 -0
- package/dist/{chunk-66KRRXVF.js → chunk-TRRT2WFH.js} +2 -2
- package/dist/{chunk-HNXCZPSX.js → chunk-TTL73U2P.js} +3 -3
- package/dist/commands/fleet.js +3 -3
- package/dist/commands/init.js +1 -1
- package/dist/commands/start.js +3 -3
- package/dist/commands/watchdog.js +3 -3
- package/dist/index.js +2 -2
- package/dist/main.js +6 -6
- package/dist/start.js +1 -1
- package/docs/TOOL-PARITY-PLAN.md +191 -0
- package/package.json +22 -25
- package/dist/chunk-6S5UKFTZ.js.map +0 -1
- package/dist/chunk-DODOQGIL.js.map +0 -1
- package/install.sh +0 -131
- package/packages/memory/Cargo.lock +0 -6480
- package/packages/memory/Cargo.toml +0 -21
- package/packages/memory/src/src/context.rs +0 -179
- package/packages/memory/src/src/embeddings.rs +0 -51
- package/packages/memory/src/src/main.rs +0 -626
- package/packages/memory/src/src/promotion.rs +0 -637
- package/packages/memory/src/src/scoring.rs +0 -131
- package/packages/memory/src/src/store.rs +0 -460
- package/packages/memory/src/src/tasks.rs +0 -321
- /package/dist/{chunk-3CQJQUY3.js.map → chunk-ELRUZHT5.js.map} +0 -0
- /package/dist/{chunk-CSYDOZE6.js.map → chunk-FQ2HFJDZ.js.map} +0 -0
- /package/dist/{chunk-66KRRXVF.js.map → chunk-TRRT2WFH.js.map} +0 -0
- /package/dist/{chunk-HNXCZPSX.js.map → chunk-TTL73U2P.js.map} +0 -0
|
@@ -3,18 +3,92 @@ import {
|
|
|
3
3
|
} from "./chunk-GPI4RU7N.js";
|
|
4
4
|
|
|
5
5
|
// packages/runtime/src/llm-client.ts
|
|
6
|
+
function convertMessagesForAnthropic(messages) {
|
|
7
|
+
let system = "";
|
|
8
|
+
const converted = [];
|
|
9
|
+
for (const msg of messages) {
|
|
10
|
+
if (msg.role === "system") {
|
|
11
|
+
system = msg.content ?? "";
|
|
12
|
+
continue;
|
|
13
|
+
}
|
|
14
|
+
if (msg.role === "tool") {
|
|
15
|
+
converted.push({
|
|
16
|
+
role: "user",
|
|
17
|
+
content: [{
|
|
18
|
+
type: "tool_result",
|
|
19
|
+
tool_use_id: msg.tool_call_id,
|
|
20
|
+
content: msg.content ?? ""
|
|
21
|
+
}]
|
|
22
|
+
});
|
|
23
|
+
continue;
|
|
24
|
+
}
|
|
25
|
+
if (msg.role === "assistant" && msg.tool_calls) {
|
|
26
|
+
const content = [];
|
|
27
|
+
if (msg.content) content.push({ type: "text", text: msg.content });
|
|
28
|
+
for (const tc of msg.tool_calls) {
|
|
29
|
+
content.push({
|
|
30
|
+
type: "tool_use",
|
|
31
|
+
id: tc.id,
|
|
32
|
+
name: tc.function.name,
|
|
33
|
+
input: JSON.parse(tc.function.arguments)
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
converted.push({ role: "assistant", content });
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
converted.push({ role: msg.role, content: msg.content ?? "" });
|
|
40
|
+
}
|
|
41
|
+
return { system, messages: converted };
|
|
42
|
+
}
|
|
43
|
+
function convertToolsForAnthropic(tools) {
|
|
44
|
+
return tools.map((t) => ({
|
|
45
|
+
name: t.function.name,
|
|
46
|
+
description: t.function.description,
|
|
47
|
+
input_schema: t.function.parameters
|
|
48
|
+
}));
|
|
49
|
+
}
|
|
50
|
+
function parseAnthropicResponse(data) {
|
|
51
|
+
let textContent = "";
|
|
52
|
+
const toolCalls = [];
|
|
53
|
+
for (const block of data.content) {
|
|
54
|
+
if (block.type === "text") textContent += block.text;
|
|
55
|
+
if (block.type === "tool_use") {
|
|
56
|
+
toolCalls.push({
|
|
57
|
+
id: block.id,
|
|
58
|
+
type: "function",
|
|
59
|
+
function: {
|
|
60
|
+
name: block.name,
|
|
61
|
+
arguments: JSON.stringify(block.input)
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return {
|
|
67
|
+
content: textContent,
|
|
68
|
+
model: data.model,
|
|
69
|
+
tool_calls: toolCalls.length > 0 ? toolCalls : void 0,
|
|
70
|
+
finish_reason: data.stop_reason === "tool_use" ? "tool_calls" : "stop",
|
|
71
|
+
usage: data.usage ? {
|
|
72
|
+
prompt_tokens: data.usage.input_tokens,
|
|
73
|
+
completion_tokens: data.usage.output_tokens,
|
|
74
|
+
total_tokens: data.usage.input_tokens + data.usage.output_tokens
|
|
75
|
+
} : void 0
|
|
76
|
+
};
|
|
77
|
+
}
|
|
6
78
|
var LLMClient = class {
|
|
7
79
|
baseUrl;
|
|
8
80
|
model;
|
|
9
81
|
maxTokens;
|
|
10
82
|
temperature;
|
|
11
83
|
apiKey;
|
|
84
|
+
provider;
|
|
12
85
|
constructor(config) {
|
|
13
86
|
this.baseUrl = config.base_url;
|
|
14
87
|
this.model = config.model;
|
|
15
88
|
this.maxTokens = config.max_tokens;
|
|
16
89
|
this.temperature = config.temperature;
|
|
17
90
|
this.apiKey = config.api_key ?? "";
|
|
91
|
+
this.provider = config.provider ?? "openai";
|
|
18
92
|
}
|
|
19
93
|
/**
|
|
20
94
|
* Simple chat completion (no tools). Backwards compatible.
|
|
@@ -27,6 +101,13 @@ var LLMClient = class {
|
|
|
27
101
|
* Returns tool_calls if the model wants to use tools.
|
|
28
102
|
*/
|
|
29
103
|
async chatWithTools(messages, tools) {
|
|
104
|
+
if (this.provider === "anthropic") {
|
|
105
|
+
return this.chatAnthropic(messages, tools);
|
|
106
|
+
}
|
|
107
|
+
return this.chatOpenAI(messages, tools);
|
|
108
|
+
}
|
|
109
|
+
// --- OpenAI-compatible path (OpenRouter, etc.) ---
|
|
110
|
+
async chatOpenAI(messages, tools) {
|
|
30
111
|
const body = {
|
|
31
112
|
model: this.model,
|
|
32
113
|
messages,
|
|
@@ -75,6 +156,54 @@ var LLMClient = class {
|
|
|
75
156
|
}
|
|
76
157
|
throw lastError ?? new Error("LLM request failed after retries");
|
|
77
158
|
}
|
|
159
|
+
// --- Anthropic Messages API path ---
|
|
160
|
+
async chatAnthropic(messages, tools) {
|
|
161
|
+
const { system, messages: convertedMessages } = convertMessagesForAnthropic(messages);
|
|
162
|
+
const body = {
|
|
163
|
+
model: this.model,
|
|
164
|
+
max_tokens: this.maxTokens,
|
|
165
|
+
temperature: this.temperature,
|
|
166
|
+
messages: convertedMessages
|
|
167
|
+
};
|
|
168
|
+
if (system) {
|
|
169
|
+
body.system = system;
|
|
170
|
+
}
|
|
171
|
+
if (tools && tools.length > 0) {
|
|
172
|
+
body.tools = convertToolsForAnthropic(tools);
|
|
173
|
+
body.tool_choice = { type: "auto" };
|
|
174
|
+
}
|
|
175
|
+
const RETRYABLE_CODES = [429, 500, 502, 503, 529];
|
|
176
|
+
const MAX_RETRIES = 3;
|
|
177
|
+
let lastError = null;
|
|
178
|
+
for (let attempt = 0; attempt <= MAX_RETRIES; attempt++) {
|
|
179
|
+
if (attempt > 0) {
|
|
180
|
+
const delayMs = Math.pow(2, attempt) * 1e3;
|
|
181
|
+
console.log(`[llm] Retry ${attempt}/${MAX_RETRIES} after ${delayMs}ms...`);
|
|
182
|
+
await new Promise((r) => setTimeout(r, delayMs));
|
|
183
|
+
}
|
|
184
|
+
const resp = await fetch(`${this.baseUrl}/v1/messages`, {
|
|
185
|
+
method: "POST",
|
|
186
|
+
headers: {
|
|
187
|
+
"Content-Type": "application/json",
|
|
188
|
+
"x-api-key": this.apiKey,
|
|
189
|
+
"anthropic-version": "2023-06-01"
|
|
190
|
+
},
|
|
191
|
+
body: JSON.stringify(body)
|
|
192
|
+
});
|
|
193
|
+
if (!resp.ok) {
|
|
194
|
+
const text = await resp.text();
|
|
195
|
+
lastError = new Error(`Anthropic request failed: ${resp.status} ${text}`);
|
|
196
|
+
if (RETRYABLE_CODES.includes(resp.status) && attempt < MAX_RETRIES) {
|
|
197
|
+
console.warn(`[llm] Retryable error ${resp.status}: ${text.slice(0, 200)}`);
|
|
198
|
+
continue;
|
|
199
|
+
}
|
|
200
|
+
throw lastError;
|
|
201
|
+
}
|
|
202
|
+
const data = await resp.json();
|
|
203
|
+
return parseAnthropicResponse(data);
|
|
204
|
+
}
|
|
205
|
+
throw lastError ?? new Error("Anthropic request failed after retries");
|
|
206
|
+
}
|
|
78
207
|
};
|
|
79
208
|
|
|
80
209
|
// packages/runtime/src/memory-client.ts
|
|
@@ -2336,6 +2465,16 @@ function loadConfig(path) {
|
|
|
2336
2465
|
if (process.env.LLM_API_KEY) {
|
|
2337
2466
|
parsed.llm.api_key = process.env.LLM_API_KEY;
|
|
2338
2467
|
}
|
|
2468
|
+
if (process.env.ANTHROPIC_API_KEY && !parsed.llm.api_key) {
|
|
2469
|
+
parsed.llm.api_key = process.env.ANTHROPIC_API_KEY;
|
|
2470
|
+
if (!parsed.llm.provider) parsed.llm.provider = "anthropic";
|
|
2471
|
+
if (!process.env.LLM_BASE_URL && parsed.llm.base_url.includes("openrouter")) {
|
|
2472
|
+
parsed.llm.base_url = "https://api.anthropic.com";
|
|
2473
|
+
}
|
|
2474
|
+
}
|
|
2475
|
+
if (process.env.LLM_PROVIDER) {
|
|
2476
|
+
parsed.llm.provider = process.env.LLM_PROVIDER;
|
|
2477
|
+
}
|
|
2339
2478
|
if (process.env.LLM_BASE_URL) {
|
|
2340
2479
|
parsed.llm.base_url = process.env.LLM_BASE_URL;
|
|
2341
2480
|
}
|
|
@@ -5465,15 +5604,83 @@ function truncate2(text) {
|
|
|
5465
5604
|
return text;
|
|
5466
5605
|
}
|
|
5467
5606
|
|
|
5468
|
-
// packages/runtime/src/tools/
|
|
5607
|
+
// packages/runtime/src/tools/coding-agent.ts
|
|
5608
|
+
import { execSync as execSync7 } from "child_process";
|
|
5469
5609
|
import { resolve as resolve16 } from "path";
|
|
5610
|
+
var MAX_OUTPUT6 = 5e4;
|
|
5611
|
+
function registerCodingAgentTools(registry, workspaceDir) {
|
|
5612
|
+
registry.register(
|
|
5613
|
+
"coding_agent",
|
|
5614
|
+
"Spawn Claude Code CLI to perform a coding task. Use for writing code, debugging, refactoring, or any task that benefits from an AI coding assistant with full filesystem access. Requires the 'claude' CLI to be installed.",
|
|
5615
|
+
{
|
|
5616
|
+
type: "object",
|
|
5617
|
+
properties: {
|
|
5618
|
+
task: {
|
|
5619
|
+
type: "string",
|
|
5620
|
+
description: "The coding task or prompt to send to Claude Code"
|
|
5621
|
+
},
|
|
5622
|
+
workdir: {
|
|
5623
|
+
type: "string",
|
|
5624
|
+
description: "Working directory (relative to workspace). Defaults to workspace root."
|
|
5625
|
+
},
|
|
5626
|
+
timeout: {
|
|
5627
|
+
type: "number",
|
|
5628
|
+
description: "Timeout in seconds. Default: 300"
|
|
5629
|
+
}
|
|
5630
|
+
},
|
|
5631
|
+
required: ["task"]
|
|
5632
|
+
},
|
|
5633
|
+
async (params) => {
|
|
5634
|
+
const task = params.task;
|
|
5635
|
+
const timeoutSeconds = params.timeout || 300;
|
|
5636
|
+
const cwd = params.workdir ? resolve16(workspaceDir, params.workdir) : workspaceDir;
|
|
5637
|
+
try {
|
|
5638
|
+
execSync7("which claude", { stdio: "ignore" });
|
|
5639
|
+
} catch {
|
|
5640
|
+
return "Error: 'claude' CLI not found. Install Claude Code first: https://docs.anthropic.com/en/docs/claude-code";
|
|
5641
|
+
}
|
|
5642
|
+
const escapedTask = task.replace(/'/g, "'\\''");
|
|
5643
|
+
const command = `claude --dangerously-skip-permissions -p '${escapedTask}'`;
|
|
5644
|
+
try {
|
|
5645
|
+
const output = execSync7(command, {
|
|
5646
|
+
cwd,
|
|
5647
|
+
timeout: timeoutSeconds * 1e3,
|
|
5648
|
+
encoding: "utf-8",
|
|
5649
|
+
maxBuffer: 10 * 1024 * 1024,
|
|
5650
|
+
// 10MB
|
|
5651
|
+
shell: "/bin/sh",
|
|
5652
|
+
env: {
|
|
5653
|
+
...process.env,
|
|
5654
|
+
PATH: `/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin:${process.env.PATH}`
|
|
5655
|
+
}
|
|
5656
|
+
});
|
|
5657
|
+
const trimmed = output.length > MAX_OUTPUT6 ? output.slice(0, MAX_OUTPUT6) + `
|
|
5658
|
+
... (truncated, ${output.length} total chars)` : output;
|
|
5659
|
+
return trimmed || "(no output)";
|
|
5660
|
+
} catch (err) {
|
|
5661
|
+
if (err.killed) {
|
|
5662
|
+
return `Error: Claude Code timed out after ${timeoutSeconds}s`;
|
|
5663
|
+
}
|
|
5664
|
+
const stderr = err.stderr?.toString() || "";
|
|
5665
|
+
const stdout = err.stdout?.toString() || "";
|
|
5666
|
+
const output = (stdout + "\n" + stderr).trim();
|
|
5667
|
+
const code = err.status ?? "unknown";
|
|
5668
|
+
return `Claude Code failed (exit code ${code}):
|
|
5669
|
+
${output || err.message}`;
|
|
5670
|
+
}
|
|
5671
|
+
}
|
|
5672
|
+
);
|
|
5673
|
+
}
|
|
5674
|
+
|
|
5675
|
+
// packages/runtime/src/tools/register.ts
|
|
5676
|
+
import { resolve as resolve17 } from "path";
|
|
5470
5677
|
import { mkdirSync as mkdirSync12, existsSync as existsSync15 } from "fs";
|
|
5471
5678
|
function registerAllTools(hivemindHome, config) {
|
|
5472
5679
|
const registry = new ToolRegistry();
|
|
5473
5680
|
if (config?.enabled === false) {
|
|
5474
5681
|
return registry;
|
|
5475
5682
|
}
|
|
5476
|
-
const workspaceDir =
|
|
5683
|
+
const workspaceDir = resolve17(hivemindHome, config?.workspace || "workspace");
|
|
5477
5684
|
if (!existsSync15(workspaceDir)) {
|
|
5478
5685
|
mkdirSync12(workspaceDir, { recursive: true });
|
|
5479
5686
|
}
|
|
@@ -5481,7 +5688,7 @@ function registerAllTools(hivemindHome, config) {
|
|
|
5481
5688
|
registerFileTools(registry, workspaceDir);
|
|
5482
5689
|
registerWebTools(registry, { braveApiKey: config?.braveApiKey });
|
|
5483
5690
|
registerMemoryTools(registry, config?.memoryDaemonUrl || "http://localhost:3434");
|
|
5484
|
-
const dataDir =
|
|
5691
|
+
const dataDir = resolve17(hivemindHome, "data");
|
|
5485
5692
|
registerEventTools(registry, dataDir);
|
|
5486
5693
|
if (config?.configPath && !process.env.SPAWN_TASK) {
|
|
5487
5694
|
registerSpawnTools(registry, hivemindHome, dataDir, config.configPath);
|
|
@@ -5494,6 +5701,7 @@ function registerAllTools(hivemindHome, config) {
|
|
|
5494
5701
|
registerWatchTools(registry, workspaceDir, dataDir);
|
|
5495
5702
|
registerMacOSTools(registry, workspaceDir);
|
|
5496
5703
|
registerDataTools(registry, workspaceDir);
|
|
5704
|
+
registerCodingAgentTools(registry, workspaceDir);
|
|
5497
5705
|
return registry;
|
|
5498
5706
|
}
|
|
5499
5707
|
|
|
@@ -5531,9 +5739,9 @@ function registerMessagingTools(registry, sesame) {
|
|
|
5531
5739
|
|
|
5532
5740
|
// packages/runtime/src/tools/skills-tools.ts
|
|
5533
5741
|
import { existsSync as existsSync16, mkdirSync as mkdirSync13, writeFileSync as writeFileSync6, rmSync } from "fs";
|
|
5534
|
-
import { resolve as
|
|
5742
|
+
import { resolve as resolve18 } from "path";
|
|
5535
5743
|
function registerSkillsTools(registry, skillsEngine, workspaceDir) {
|
|
5536
|
-
const skillsDir =
|
|
5744
|
+
const skillsDir = resolve18(workspaceDir, "skills");
|
|
5537
5745
|
registry.register(
|
|
5538
5746
|
"skill_list",
|
|
5539
5747
|
"List all loaded skills with their registered tools and status.",
|
|
@@ -5600,7 +5808,7 @@ ${lines.join("\n\n")}`;
|
|
|
5600
5808
|
const name = params.name;
|
|
5601
5809
|
const description = params.description;
|
|
5602
5810
|
const tools = params.tools;
|
|
5603
|
-
const skillDir =
|
|
5811
|
+
const skillDir = resolve18(skillsDir, name);
|
|
5604
5812
|
if (existsSync16(skillDir)) {
|
|
5605
5813
|
return `Error: Skill directory "${name}" already exists. Use skill_reload to update it.`;
|
|
5606
5814
|
}
|
|
@@ -5614,7 +5822,7 @@ description: "${description}"
|
|
|
5614
5822
|
|
|
5615
5823
|
${description}
|
|
5616
5824
|
`;
|
|
5617
|
-
writeFileSync6(
|
|
5825
|
+
writeFileSync6(resolve18(skillDir, "SKILL.md"), skillMd);
|
|
5618
5826
|
if (tools && tools.length > 0) {
|
|
5619
5827
|
const toolsDef = {
|
|
5620
5828
|
tools: tools.map((t) => ({
|
|
@@ -5624,7 +5832,7 @@ ${description}
|
|
|
5624
5832
|
command: t.command
|
|
5625
5833
|
}))
|
|
5626
5834
|
};
|
|
5627
|
-
writeFileSync6(
|
|
5835
|
+
writeFileSync6(resolve18(skillDir, "tools.json"), JSON.stringify(toolsDef, null, 2) + "\n");
|
|
5628
5836
|
}
|
|
5629
5837
|
try {
|
|
5630
5838
|
await skillsEngine.loadSkill(name);
|
|
@@ -5677,7 +5885,7 @@ Path: ${skillDir}`;
|
|
|
5677
5885
|
},
|
|
5678
5886
|
async (params) => {
|
|
5679
5887
|
const name = params.name;
|
|
5680
|
-
const skillDir =
|
|
5888
|
+
const skillDir = resolve18(skillsDir, name);
|
|
5681
5889
|
if (!existsSync16(skillDir)) {
|
|
5682
5890
|
return `Error: Skill directory "${name}" does not exist.`;
|
|
5683
5891
|
}
|
|
@@ -5698,12 +5906,12 @@ Path: ${skillDir}`;
|
|
|
5698
5906
|
|
|
5699
5907
|
// packages/runtime/src/pipeline.ts
|
|
5700
5908
|
import { readFileSync as readFileSync12, writeFileSync as writeFileSync7, unlinkSync as unlinkSync3 } from "fs";
|
|
5701
|
-
import { resolve as
|
|
5909
|
+
import { resolve as resolve19, dirname as dirname7 } from "path";
|
|
5702
5910
|
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
5703
5911
|
var PACKAGE_VERSION = "unknown";
|
|
5704
5912
|
try {
|
|
5705
5913
|
const __dirname2 = dirname7(fileURLToPath3(import.meta.url));
|
|
5706
|
-
const pkg = JSON.parse(readFileSync12(
|
|
5914
|
+
const pkg = JSON.parse(readFileSync12(resolve19(__dirname2, "../package.json"), "utf-8"));
|
|
5707
5915
|
PACKAGE_VERSION = pkg.version ?? "unknown";
|
|
5708
5916
|
} catch {
|
|
5709
5917
|
}
|
|
@@ -5775,11 +5983,11 @@ async function startPipeline(configPath) {
|
|
|
5775
5983
|
console.log("[hivemind] Global context already exists in memory daemon");
|
|
5776
5984
|
}
|
|
5777
5985
|
}
|
|
5778
|
-
const requestLogger = new RequestLogger(
|
|
5986
|
+
const requestLogger = new RequestLogger(resolve19(dirname7(configPath), "data", "dashboard.db"));
|
|
5779
5987
|
startDashboardServer(requestLogger, config.memory);
|
|
5780
5988
|
const agent = new Agent(config);
|
|
5781
5989
|
agent.setRequestLogger(requestLogger);
|
|
5782
|
-
const hivemindHome = process.env.HIVEMIND_HOME ||
|
|
5990
|
+
const hivemindHome = process.env.HIVEMIND_HOME || resolve19(process.env.HOME || "/root", "hivemind");
|
|
5783
5991
|
const toolRegistry = registerAllTools(hivemindHome, {
|
|
5784
5992
|
enabled: true,
|
|
5785
5993
|
workspace: config.agent.workspace || "workspace",
|
|
@@ -5787,7 +5995,7 @@ async function startPipeline(configPath) {
|
|
|
5787
5995
|
memoryDaemonUrl: config.memory.daemon_url,
|
|
5788
5996
|
configPath
|
|
5789
5997
|
});
|
|
5790
|
-
const workspaceDir =
|
|
5998
|
+
const workspaceDir = resolve19(hivemindHome, config.agent.workspace || "workspace");
|
|
5791
5999
|
const skillsEngine = new SkillsEngine(workspaceDir, toolRegistry);
|
|
5792
6000
|
await skillsEngine.loadAll();
|
|
5793
6001
|
registerSkillsTools(toolRegistry, skillsEngine, workspaceDir);
|
|
@@ -5795,7 +6003,7 @@ async function startPipeline(configPath) {
|
|
|
5795
6003
|
process.on("exit", () => skillsEngine.stopWatching());
|
|
5796
6004
|
agent.setToolRegistry(toolRegistry);
|
|
5797
6005
|
console.log(`[hivemind] Context manager initialized (active: ${agent.getActiveContext()})`);
|
|
5798
|
-
const dataDir =
|
|
6006
|
+
const dataDir = resolve19(hivemindHome, "data");
|
|
5799
6007
|
if (config.sesame.api_key) {
|
|
5800
6008
|
await startSesameLoop(config, agent, toolRegistry, dataDir);
|
|
5801
6009
|
} else {
|
|
@@ -5969,8 +6177,8 @@ ${response.content}
|
|
|
5969
6177
|
console.error("Error:", err.message);
|
|
5970
6178
|
}
|
|
5971
6179
|
});
|
|
5972
|
-
return new Promise((
|
|
5973
|
-
rl.on("close",
|
|
6180
|
+
return new Promise((resolve20) => {
|
|
6181
|
+
rl.on("close", resolve20);
|
|
5974
6182
|
});
|
|
5975
6183
|
}
|
|
5976
6184
|
async function runSpawnTask(config, configPath) {
|
|
@@ -5981,7 +6189,7 @@ async function runSpawnTask(config, configPath) {
|
|
|
5981
6189
|
const spawnDir = process.env.SPAWN_DIR;
|
|
5982
6190
|
console.log(`[spawn] Sub-agent starting (id: ${spawnId}, context: ${context})`);
|
|
5983
6191
|
const agent = new Agent(config, context);
|
|
5984
|
-
const hivemindHome = process.env.HIVEMIND_HOME ||
|
|
6192
|
+
const hivemindHome = process.env.HIVEMIND_HOME || resolve19(process.env.HOME || "/root", "hivemind");
|
|
5985
6193
|
const toolRegistry = registerAllTools(hivemindHome, {
|
|
5986
6194
|
enabled: true,
|
|
5987
6195
|
workspace: config.agent.workspace || "workspace",
|
|
@@ -5994,7 +6202,7 @@ async function runSpawnTask(config, configPath) {
|
|
|
5994
6202
|
const result = response.content;
|
|
5995
6203
|
console.log(`[spawn] Task completed (context: ${response.context})`);
|
|
5996
6204
|
if (spawnDir) {
|
|
5997
|
-
writeFileSync7(
|
|
6205
|
+
writeFileSync7(resolve19(spawnDir, "result.txt"), result);
|
|
5998
6206
|
}
|
|
5999
6207
|
if (channelId && config.sesame.api_key) {
|
|
6000
6208
|
try {
|
|
@@ -6011,7 +6219,7 @@ async function runSpawnTask(config, configPath) {
|
|
|
6011
6219
|
const errorMsg = `[SPAWN ERROR] ${err.message}`;
|
|
6012
6220
|
console.error(`[spawn] ${errorMsg}`);
|
|
6013
6221
|
if (spawnDir) {
|
|
6014
|
-
writeFileSync7(
|
|
6222
|
+
writeFileSync7(resolve19(spawnDir, "result.txt"), errorMsg);
|
|
6015
6223
|
}
|
|
6016
6224
|
process.exitCode = 1;
|
|
6017
6225
|
}
|
|
@@ -6042,20 +6250,20 @@ var WorkerServer = class {
|
|
|
6042
6250
|
}
|
|
6043
6251
|
/** Start listening. */
|
|
6044
6252
|
async start() {
|
|
6045
|
-
return new Promise((
|
|
6253
|
+
return new Promise((resolve20, reject) => {
|
|
6046
6254
|
this.server = createServer4((req, res) => this.handleRequest(req, res));
|
|
6047
6255
|
this.server.on("error", reject);
|
|
6048
|
-
this.server.listen(this.port, () =>
|
|
6256
|
+
this.server.listen(this.port, () => resolve20());
|
|
6049
6257
|
});
|
|
6050
6258
|
}
|
|
6051
6259
|
/** Stop the server. */
|
|
6052
6260
|
async stop() {
|
|
6053
|
-
return new Promise((
|
|
6261
|
+
return new Promise((resolve20) => {
|
|
6054
6262
|
if (!this.server) {
|
|
6055
|
-
|
|
6263
|
+
resolve20();
|
|
6056
6264
|
return;
|
|
6057
6265
|
}
|
|
6058
|
-
this.server.close(() =>
|
|
6266
|
+
this.server.close(() => resolve20());
|
|
6059
6267
|
});
|
|
6060
6268
|
}
|
|
6061
6269
|
getPort() {
|
|
@@ -6178,10 +6386,10 @@ var WorkerServer = class {
|
|
|
6178
6386
|
}
|
|
6179
6387
|
};
|
|
6180
6388
|
function readBody(req) {
|
|
6181
|
-
return new Promise((
|
|
6389
|
+
return new Promise((resolve20, reject) => {
|
|
6182
6390
|
const chunks = [];
|
|
6183
6391
|
req.on("data", (chunk) => chunks.push(chunk));
|
|
6184
|
-
req.on("end", () =>
|
|
6392
|
+
req.on("end", () => resolve20(Buffer.concat(chunks).toString("utf-8")));
|
|
6185
6393
|
req.on("error", reject);
|
|
6186
6394
|
});
|
|
6187
6395
|
}
|
|
@@ -6515,4 +6723,4 @@ smol-toml/dist/index.js:
|
|
|
6515
6723
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
6516
6724
|
*)
|
|
6517
6725
|
*/
|
|
6518
|
-
//# sourceMappingURL=chunk-
|
|
6726
|
+
//# sourceMappingURL=chunk-Q5ZO5WXM.js.map
|