@sesamespace/hivemind 0.11.5 → 0.12.0
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/.session-log.json +58 -0
- package/dist/{chunk-NUMLGOLM.js → chunk-3EB4T7D4.js} +2 -2
- package/dist/{chunk-TTVGHFFT.js → chunk-6JB4OAB6.js} +3 -3
- package/dist/{chunk-HQTD25CP.js → chunk-G5LF3BSN.js} +2 -2
- package/dist/{chunk-GD6XTDQQ.js → chunk-JP3ZHMPE.js} +2 -2
- package/dist/{chunk-MWQZTAYA.js → chunk-YJW6OOEJ.js} +2 -2
- package/dist/{chunk-EKZ3IZU6.js → chunk-ZQ26EOYD.js} +286 -20
- package/dist/chunk-ZQ26EOYD.js.map +1 -0
- package/dist/commands/fleet.js +3 -3
- package/dist/commands/init.js +3 -3
- 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/package.json +1 -1
- package/dist/chunk-EKZ3IZU6.js.map +0 -1
- /package/dist/{chunk-NUMLGOLM.js.map → chunk-3EB4T7D4.js.map} +0 -0
- /package/dist/{chunk-TTVGHFFT.js.map → chunk-6JB4OAB6.js.map} +0 -0
- /package/dist/{chunk-HQTD25CP.js.map → chunk-G5LF3BSN.js.map} +0 -0
- /package/dist/{chunk-GD6XTDQQ.js.map → chunk-JP3ZHMPE.js.map} +0 -0
- /package/dist/{chunk-MWQZTAYA.js.map → chunk-YJW6OOEJ.js.map} +0 -0
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
{
|
|
2
|
+
"timestamp": "2026-03-10T00:00:00Z",
|
|
3
|
+
"summary": "Fixed stale PID reporting in `hivemind service status` by rewriting showStatus() to parse PIDs from `launchctl list` output instead of PID files. Added kickstart recovery for KeepAlive services (memory, watchdog). Removed hardcoded wrapper scripts from git tracking and added them to .gitignore since they are generated dynamically during `hivemind service install`.",
|
|
4
|
+
"decisions": [
|
|
5
|
+
{
|
|
6
|
+
"topic": "PID source",
|
|
7
|
+
"choice": "Parse PID from launchctl list output using regex",
|
|
8
|
+
"rationale": "launchctl is the authoritative source for launchd-managed process PIDs; PID files go stale when launchd restarts a crashed process",
|
|
9
|
+
"alternatives_considered": ["Keep PID file approach with periodic refresh", "Use ps/pgrep to find processes"]
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"topic": "Stale service recovery",
|
|
13
|
+
"choice": "Auto-kickstart KeepAlive services (memory, watchdog) but not agent",
|
|
14
|
+
"rationale": "Agent is managed by watchdog, so kickstarting it from status would bypass watchdog's coordination",
|
|
15
|
+
"alternatives_considered": ["Kickstart all services", "Only report status without recovery"]
|
|
16
|
+
}
|
|
17
|
+
],
|
|
18
|
+
"patterns": [
|
|
19
|
+
{
|
|
20
|
+
"pattern": "Wrapper scripts in bin/ are generated dynamically during `hivemind service install` with correct local paths — never commit them",
|
|
21
|
+
"scope": "project-wide"
|
|
22
|
+
}
|
|
23
|
+
],
|
|
24
|
+
"gotchas": [
|
|
25
|
+
{
|
|
26
|
+
"issue": "Wrapper scripts had hardcoded paths from another developer's machine committed to git",
|
|
27
|
+
"resolution": "Removed from git tracking with `git rm --cached`, added bin/*-wrapper.sh to .gitignore",
|
|
28
|
+
"prevention": "The .gitignore entry will prevent future accidental commits"
|
|
29
|
+
}
|
|
30
|
+
],
|
|
31
|
+
"files_changed": [
|
|
32
|
+
{
|
|
33
|
+
"path": "packages/cli/src/commands/service.ts",
|
|
34
|
+
"action": "modified",
|
|
35
|
+
"purpose": "Rewrote showStatus() to use launchctl as PID source with kickstart recovery"
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
"path": ".gitignore",
|
|
39
|
+
"action": "modified",
|
|
40
|
+
"purpose": "Added bin/*-wrapper.sh pattern"
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
"path": "bin/agent-wrapper.sh",
|
|
44
|
+
"action": "deleted",
|
|
45
|
+
"purpose": "Removed hardcoded wrapper script from git tracking"
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"path": "bin/memory-wrapper.sh",
|
|
49
|
+
"action": "deleted",
|
|
50
|
+
"purpose": "Removed hardcoded wrapper script from git tracking"
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
"path": "bin/watchdog-wrapper.sh",
|
|
54
|
+
"action": "deleted",
|
|
55
|
+
"purpose": "Removed hardcoded wrapper script from git tracking"
|
|
56
|
+
}
|
|
57
|
+
]
|
|
58
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
startPipeline
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-ZQ26EOYD.js";
|
|
4
4
|
|
|
5
5
|
// packages/cli/src/commands/start.ts
|
|
6
6
|
import { resolve } from "path";
|
|
@@ -66,4 +66,4 @@ Options:
|
|
|
66
66
|
export {
|
|
67
67
|
runStartCommand
|
|
68
68
|
};
|
|
69
|
-
//# sourceMappingURL=chunk-
|
|
69
|
+
//# sourceMappingURL=chunk-3EB4T7D4.js.map
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Watchdog
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-YJW6OOEJ.js";
|
|
4
4
|
import {
|
|
5
5
|
defaultSentinelConfig,
|
|
6
6
|
loadConfig
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-ZQ26EOYD.js";
|
|
8
8
|
|
|
9
9
|
// packages/cli/src/commands/watchdog.ts
|
|
10
10
|
import { resolve } from "path";
|
|
@@ -76,4 +76,4 @@ Options:
|
|
|
76
76
|
export {
|
|
77
77
|
runWatchdogCommand
|
|
78
78
|
};
|
|
79
|
-
//# sourceMappingURL=chunk-
|
|
79
|
+
//# sourceMappingURL=chunk-6JB4OAB6.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
FleetManager
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-YJW6OOEJ.js";
|
|
4
4
|
|
|
5
5
|
// packages/cli/src/commands/fleet.ts
|
|
6
6
|
function formatUptime(seconds) {
|
|
@@ -183,4 +183,4 @@ Commands:
|
|
|
183
183
|
export {
|
|
184
184
|
runFleetCommand
|
|
185
185
|
};
|
|
186
|
-
//# sourceMappingURL=chunk-
|
|
186
|
+
//# sourceMappingURL=chunk-G5LF3BSN.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
SesameClient,
|
|
3
3
|
getClaudeCodeOAuthToken
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-ZQ26EOYD.js";
|
|
5
5
|
|
|
6
6
|
// packages/cli/src/commands/init.ts
|
|
7
7
|
import { resolve, dirname } from "path";
|
|
@@ -436,4 +436,4 @@ Options:
|
|
|
436
436
|
export {
|
|
437
437
|
runInitCommand
|
|
438
438
|
};
|
|
439
|
-
//# sourceMappingURL=chunk-
|
|
439
|
+
//# sourceMappingURL=chunk-JP3ZHMPE.js.map
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
SesameClient2 as SesameClient,
|
|
8
8
|
WORKER_ROUTES,
|
|
9
9
|
createLogger
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-ZQ26EOYD.js";
|
|
11
11
|
|
|
12
12
|
// packages/runtime/src/watchdog.ts
|
|
13
13
|
import { execSync } from "child_process";
|
|
@@ -1095,4 +1095,4 @@ export {
|
|
|
1095
1095
|
WorkerMemorySync,
|
|
1096
1096
|
PrimaryMemorySync
|
|
1097
1097
|
};
|
|
1098
|
-
//# sourceMappingURL=chunk-
|
|
1098
|
+
//# sourceMappingURL=chunk-YJW6OOEJ.js.map
|
|
@@ -4225,12 +4225,12 @@ var LogWatcher = class extends BackgroundProcess {
|
|
|
4225
4225
|
}
|
|
4226
4226
|
savePositions() {
|
|
4227
4227
|
try {
|
|
4228
|
-
const { mkdirSync:
|
|
4229
|
-
const { dirname:
|
|
4230
|
-
const dir =
|
|
4231
|
-
if (!existsSync7(dir))
|
|
4228
|
+
const { mkdirSync: mkdirSync16, writeFileSync: writeFileSync10 } = __require("fs");
|
|
4229
|
+
const { dirname: dirname10 } = __require("path");
|
|
4230
|
+
const dir = dirname10(this.positionsFile);
|
|
4231
|
+
if (!existsSync7(dir)) mkdirSync16(dir, { recursive: true });
|
|
4232
4232
|
const data = Object.fromEntries(this.tailPositions);
|
|
4233
|
-
|
|
4233
|
+
writeFileSync10(this.positionsFile, JSON.stringify(data));
|
|
4234
4234
|
} catch (err) {
|
|
4235
4235
|
log2.warn("failed to save tail positions", {
|
|
4236
4236
|
error: err.message
|
|
@@ -7809,7 +7809,7 @@ function truncate2(text) {
|
|
|
7809
7809
|
import { execSync as execSync9 } from "child_process";
|
|
7810
7810
|
import { resolve as resolve17 } from "path";
|
|
7811
7811
|
var MAX_OUTPUT6 = 5e4;
|
|
7812
|
-
function registerCodingAgentTools(registry, workspaceDir) {
|
|
7812
|
+
function registerCodingAgentTools(registry, workspaceDir, contextBridge) {
|
|
7813
7813
|
registry.register(
|
|
7814
7814
|
"coding_agent",
|
|
7815
7815
|
"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.",
|
|
@@ -7827,6 +7827,31 @@ function registerCodingAgentTools(registry, workspaceDir) {
|
|
|
7827
7827
|
timeout: {
|
|
7828
7828
|
type: "number",
|
|
7829
7829
|
description: "Timeout in seconds. Default: 300"
|
|
7830
|
+
},
|
|
7831
|
+
requirements: {
|
|
7832
|
+
type: "array",
|
|
7833
|
+
items: { type: "string" },
|
|
7834
|
+
description: "Key requirements or constraints for the task"
|
|
7835
|
+
},
|
|
7836
|
+
recentErrors: {
|
|
7837
|
+
type: "array",
|
|
7838
|
+
items: { type: "string" },
|
|
7839
|
+
description: "Recent errors encountered that may be relevant"
|
|
7840
|
+
},
|
|
7841
|
+
relevantPatterns: {
|
|
7842
|
+
type: "array",
|
|
7843
|
+
items: { type: "string" },
|
|
7844
|
+
description: "Known patterns or approaches that might help"
|
|
7845
|
+
},
|
|
7846
|
+
workingFiles: {
|
|
7847
|
+
type: "array",
|
|
7848
|
+
items: { type: "string" },
|
|
7849
|
+
description: "Files currently being worked on"
|
|
7850
|
+
},
|
|
7851
|
+
knownConstraints: {
|
|
7852
|
+
type: "array",
|
|
7853
|
+
items: { type: "string" },
|
|
7854
|
+
description: "Known constraints or limitations to consider"
|
|
7830
7855
|
}
|
|
7831
7856
|
},
|
|
7832
7857
|
required: ["task"]
|
|
@@ -7835,8 +7860,24 @@ function registerCodingAgentTools(registry, workspaceDir) {
|
|
|
7835
7860
|
const task = params.task;
|
|
7836
7861
|
const timeoutSeconds = params.timeout || 300;
|
|
7837
7862
|
const cwd = params.workdir ? resolve17(workspaceDir, params.workdir) : workspaceDir;
|
|
7838
|
-
|
|
7839
|
-
|
|
7863
|
+
if (contextBridge) {
|
|
7864
|
+
const context = {
|
|
7865
|
+
goal: task,
|
|
7866
|
+
// Extract additional context from params if provided
|
|
7867
|
+
requirements: params.requirements || [],
|
|
7868
|
+
recentErrors: params.recentErrors || [],
|
|
7869
|
+
relevantPatterns: params.relevantPatterns || [],
|
|
7870
|
+
workingFiles: params.workingFiles || [],
|
|
7871
|
+
knownConstraints: params.knownConstraints || []
|
|
7872
|
+
};
|
|
7873
|
+
try {
|
|
7874
|
+
await contextBridge.prepareContext(context);
|
|
7875
|
+
} catch (err) {
|
|
7876
|
+
console.warn("Failed to prepare context for Claude Code:", err);
|
|
7877
|
+
}
|
|
7878
|
+
}
|
|
7879
|
+
const homedir2 = process.env.HOME || "/root";
|
|
7880
|
+
const extendedPath = `${homedir2}/.local/bin:/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin:${process.env.PATH}`;
|
|
7840
7881
|
try {
|
|
7841
7882
|
execSync9("which claude", { stdio: "ignore", env: { ...process.env, PATH: extendedPath } });
|
|
7842
7883
|
} catch {
|
|
@@ -8328,7 +8369,7 @@ function registerAllTools(hivemindHome, config) {
|
|
|
8328
8369
|
registerWatchTools(registry, workspaceDir, dataDir);
|
|
8329
8370
|
registerMacOSTools(registry, workspaceDir);
|
|
8330
8371
|
registerDataTools(registry, workspaceDir);
|
|
8331
|
-
registerCodingAgentTools(registry, workspaceDir);
|
|
8372
|
+
registerCodingAgentTools(registry, workspaceDir, config?.contextBridge);
|
|
8332
8373
|
registerLearnTools(registry, {
|
|
8333
8374
|
llmConfig: config?.llmConfig,
|
|
8334
8375
|
memoryDaemonUrl: config?.memoryDaemonUrl || "http://localhost:3434",
|
|
@@ -8537,13 +8578,224 @@ Path: ${skillDir}`;
|
|
|
8537
8578
|
}
|
|
8538
8579
|
|
|
8539
8580
|
// packages/runtime/src/pipeline.ts
|
|
8540
|
-
import { readFileSync as
|
|
8541
|
-
import { resolve as resolve20, dirname as
|
|
8581
|
+
import { readFileSync as readFileSync16, writeFileSync as writeFileSync9, unlinkSync as unlinkSync3 } from "fs";
|
|
8582
|
+
import { resolve as resolve20, dirname as dirname9 } from "path";
|
|
8542
8583
|
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
8584
|
+
|
|
8585
|
+
// packages/runtime/src/tools/context-bridge.ts
|
|
8586
|
+
import { writeFileSync as writeFileSync8, readFileSync as readFileSync15, existsSync as existsSync20, mkdirSync as mkdirSync15, watchFile, unwatchFile } from "fs";
|
|
8587
|
+
import { join as join8, dirname as dirname8 } from "path";
|
|
8588
|
+
import { homedir } from "os";
|
|
8589
|
+
import { EventEmitter as EventEmitter2 } from "events";
|
|
8590
|
+
var ClaudeContextBridge = class extends EventEmitter2 {
|
|
8591
|
+
workspaceDir;
|
|
8592
|
+
memoryClient;
|
|
8593
|
+
logger;
|
|
8594
|
+
sessionLogPath;
|
|
8595
|
+
contextFilePath;
|
|
8596
|
+
claudeSettingsPath;
|
|
8597
|
+
logWatcher;
|
|
8598
|
+
constructor(config) {
|
|
8599
|
+
super();
|
|
8600
|
+
this.workspaceDir = config.workspaceDir;
|
|
8601
|
+
this.memoryClient = config.memoryClient;
|
|
8602
|
+
this.logger = config.logger;
|
|
8603
|
+
this.sessionLogPath = join8(homedir(), ".claude", "session.log");
|
|
8604
|
+
this.contextFilePath = join8(this.workspaceDir, "CLAUDE_CONTEXT.md");
|
|
8605
|
+
this.claudeSettingsPath = join8(homedir(), ".claude", "settings.json");
|
|
8606
|
+
}
|
|
8607
|
+
/**
|
|
8608
|
+
* Initialize the context bridge
|
|
8609
|
+
*/
|
|
8610
|
+
async initialize() {
|
|
8611
|
+
const claudeDir = dirname8(this.claudeSettingsPath);
|
|
8612
|
+
if (!existsSync20(claudeDir)) {
|
|
8613
|
+
mkdirSync15(claudeDir, { recursive: true });
|
|
8614
|
+
}
|
|
8615
|
+
await this.setupClaudeSettings();
|
|
8616
|
+
this.startLogMonitoring();
|
|
8617
|
+
this.logger.info("Claude context bridge initialized");
|
|
8618
|
+
}
|
|
8619
|
+
/**
|
|
8620
|
+
* Configure Claude Code to report insights
|
|
8621
|
+
*/
|
|
8622
|
+
async setupClaudeSettings() {
|
|
8623
|
+
const customInstructions = `# Hivemind Context Bridge
|
|
8624
|
+
|
|
8625
|
+
When working on tasks, please report significant findings by writing to the session log:
|
|
8626
|
+
|
|
8627
|
+
- When you discover architecture/patterns: echo "DISCOVERY: [details]" >> ~/.claude/session.log
|
|
8628
|
+
- When you need more context: echo "NEED: [what you need]" >> ~/.claude/session.log
|
|
8629
|
+
- When you complete major steps: echo "COMPLETE: [what you did]" >> ~/.claude/session.log
|
|
8630
|
+
- When you find reusable solutions: echo "PATTERN: [approach]" >> ~/.claude/session.log
|
|
8631
|
+
- When you encounter errors: echo "ERROR: [error details]" >> ~/.claude/session.log
|
|
8632
|
+
|
|
8633
|
+
Always check ~/hivemind/workspace/CLAUDE_CONTEXT.md for task context and requirements.`;
|
|
8634
|
+
const settings = {
|
|
8635
|
+
customInstructions,
|
|
8636
|
+
alwaysIncludeFiles: [
|
|
8637
|
+
this.contextFilePath,
|
|
8638
|
+
join8(this.workspaceDir, "ARCHITECTURE.md"),
|
|
8639
|
+
join8(this.workspaceDir, "TOOLS.md")
|
|
8640
|
+
],
|
|
8641
|
+
// Enable verbose logging for better insights
|
|
8642
|
+
verboseLogging: true
|
|
8643
|
+
};
|
|
8644
|
+
writeFileSync8(this.claudeSettingsPath, JSON.stringify(settings, null, 2));
|
|
8645
|
+
this.logger.info("Claude settings configured for context bridge");
|
|
8646
|
+
}
|
|
8647
|
+
/**
|
|
8648
|
+
* Prepare context for a Claude Code session
|
|
8649
|
+
*/
|
|
8650
|
+
async prepareContext(context) {
|
|
8651
|
+
let content = `# Claude Code Context
|
|
8652
|
+
Generated: ${(/* @__PURE__ */ new Date()).toISOString()}
|
|
8653
|
+
|
|
8654
|
+
## Current Goal
|
|
8655
|
+
${context.goal}
|
|
8656
|
+
`;
|
|
8657
|
+
if (context.requirements?.length) {
|
|
8658
|
+
content += `
|
|
8659
|
+
## Requirements
|
|
8660
|
+
${context.requirements.map((r) => `- ${r}`).join("\n")}
|
|
8661
|
+
`;
|
|
8662
|
+
}
|
|
8663
|
+
if (context.recentErrors?.length) {
|
|
8664
|
+
content += `
|
|
8665
|
+
## Recent Errors
|
|
8666
|
+
\`\`\`
|
|
8667
|
+
${context.recentErrors.join("\n")}
|
|
8668
|
+
\`\`\`
|
|
8669
|
+
`;
|
|
8670
|
+
}
|
|
8671
|
+
if (context.relevantPatterns?.length) {
|
|
8672
|
+
content += `
|
|
8673
|
+
## Known Patterns
|
|
8674
|
+
${context.relevantPatterns.map((p) => `- ${p}`).join("\n")}
|
|
8675
|
+
`;
|
|
8676
|
+
}
|
|
8677
|
+
if (context.workingFiles?.length) {
|
|
8678
|
+
content += `
|
|
8679
|
+
## Working Files
|
|
8680
|
+
${context.workingFiles.map((f) => `- ${f}`).join("\n")}
|
|
8681
|
+
`;
|
|
8682
|
+
}
|
|
8683
|
+
if (context.knownConstraints?.length) {
|
|
8684
|
+
content += `
|
|
8685
|
+
## Known Constraints
|
|
8686
|
+
${context.knownConstraints.map((c) => `- ${c}`).join("\n")}
|
|
8687
|
+
`;
|
|
8688
|
+
}
|
|
8689
|
+
try {
|
|
8690
|
+
const memories = await this.getRelevantMemories(context.goal);
|
|
8691
|
+
if (memories.length > 0) {
|
|
8692
|
+
content += `
|
|
8693
|
+
## Relevant Knowledge
|
|
8694
|
+
${memories.join("\n\n")}
|
|
8695
|
+
`;
|
|
8696
|
+
}
|
|
8697
|
+
} catch (err) {
|
|
8698
|
+
this.logger.warn("Failed to fetch memories for context", err);
|
|
8699
|
+
}
|
|
8700
|
+
writeFileSync8(this.contextFilePath, content);
|
|
8701
|
+
this.logger.info("Context prepared for Claude Code", { goal: context.goal });
|
|
8702
|
+
}
|
|
8703
|
+
/**
|
|
8704
|
+
* Fetch relevant memories for the task
|
|
8705
|
+
*/
|
|
8706
|
+
async getRelevantMemories(goal) {
|
|
8707
|
+
try {
|
|
8708
|
+
const results = await this.memoryClient.search(goal, "global", 5);
|
|
8709
|
+
return results.map((r) => `- ${r.content}`);
|
|
8710
|
+
} catch (err) {
|
|
8711
|
+
return [];
|
|
8712
|
+
}
|
|
8713
|
+
}
|
|
8714
|
+
/**
|
|
8715
|
+
* Start monitoring Claude's session log for insights
|
|
8716
|
+
*/
|
|
8717
|
+
startLogMonitoring() {
|
|
8718
|
+
if (!existsSync20(this.sessionLogPath)) {
|
|
8719
|
+
writeFileSync8(this.sessionLogPath, "");
|
|
8720
|
+
}
|
|
8721
|
+
let lastSize = 0;
|
|
8722
|
+
watchFile(this.sessionLogPath, { interval: 1e3 }, (curr, prev) => {
|
|
8723
|
+
if (curr.size > lastSize) {
|
|
8724
|
+
const content = readFileSync15(this.sessionLogPath, "utf-8");
|
|
8725
|
+
const newContent = content.slice(lastSize);
|
|
8726
|
+
lastSize = curr.size;
|
|
8727
|
+
const lines = newContent.split("\n").filter((line) => line.trim());
|
|
8728
|
+
for (const line of lines) {
|
|
8729
|
+
this.processLogLine(line);
|
|
8730
|
+
}
|
|
8731
|
+
}
|
|
8732
|
+
});
|
|
8733
|
+
this.logger.info("Started monitoring Claude session log");
|
|
8734
|
+
}
|
|
8735
|
+
/**
|
|
8736
|
+
* Process a line from Claude's session log
|
|
8737
|
+
*/
|
|
8738
|
+
processLogLine(line) {
|
|
8739
|
+
const patterns = {
|
|
8740
|
+
DISCOVERY: /^DISCOVERY:\s*(.+)$/,
|
|
8741
|
+
NEED: /^NEED:\s*(.+)$/,
|
|
8742
|
+
COMPLETE: /^COMPLETE:\s*(.+)$/,
|
|
8743
|
+
PATTERN: /^PATTERN:\s*(.+)$/,
|
|
8744
|
+
ERROR: /^ERROR:\s*(.+)$/
|
|
8745
|
+
};
|
|
8746
|
+
for (const [type, pattern] of Object.entries(patterns)) {
|
|
8747
|
+
const match = line.match(pattern);
|
|
8748
|
+
if (match) {
|
|
8749
|
+
const content = match[1];
|
|
8750
|
+
this.handleInsight(type, content);
|
|
8751
|
+
break;
|
|
8752
|
+
}
|
|
8753
|
+
}
|
|
8754
|
+
}
|
|
8755
|
+
/**
|
|
8756
|
+
* Handle an insight from Claude Code
|
|
8757
|
+
*/
|
|
8758
|
+
async handleInsight(type, content) {
|
|
8759
|
+
this.logger.info(`Claude insight: ${type}`, { content });
|
|
8760
|
+
this.emit("insight", { type, content });
|
|
8761
|
+
if (["DISCOVERY", "PATTERN"].includes(type)) {
|
|
8762
|
+
try {
|
|
8763
|
+
await this.memoryClient.store({
|
|
8764
|
+
content: `Claude Code ${type}: ${content}`,
|
|
8765
|
+
metadata: {
|
|
8766
|
+
source: "claude-code",
|
|
8767
|
+
type: type.toLowerCase(),
|
|
8768
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
8769
|
+
}
|
|
8770
|
+
});
|
|
8771
|
+
} catch (err) {
|
|
8772
|
+
this.logger.warn("Failed to store Claude insight in memory", err);
|
|
8773
|
+
}
|
|
8774
|
+
}
|
|
8775
|
+
if (type === "NEED") {
|
|
8776
|
+
this.emit("context-request", content);
|
|
8777
|
+
}
|
|
8778
|
+
}
|
|
8779
|
+
/**
|
|
8780
|
+
* Clean up resources
|
|
8781
|
+
*/
|
|
8782
|
+
destroy() {
|
|
8783
|
+
if (this.sessionLogPath && existsSync20(this.sessionLogPath)) {
|
|
8784
|
+
unwatchFile(this.sessionLogPath);
|
|
8785
|
+
}
|
|
8786
|
+
}
|
|
8787
|
+
};
|
|
8788
|
+
async function createContextBridge(config) {
|
|
8789
|
+
const bridge = new ClaudeContextBridge(config);
|
|
8790
|
+
await bridge.initialize();
|
|
8791
|
+
return bridge;
|
|
8792
|
+
}
|
|
8793
|
+
|
|
8794
|
+
// packages/runtime/src/pipeline.ts
|
|
8543
8795
|
var PACKAGE_VERSION = "unknown";
|
|
8544
8796
|
try {
|
|
8545
|
-
const __dirname2 =
|
|
8546
|
-
const pkg = JSON.parse(
|
|
8797
|
+
const __dirname2 = dirname9(fileURLToPath3(import.meta.url));
|
|
8798
|
+
const pkg = JSON.parse(readFileSync16(resolve20(__dirname2, "../package.json"), "utf-8"));
|
|
8547
8799
|
PACKAGE_VERSION = pkg.version ?? "unknown";
|
|
8548
8800
|
} catch {
|
|
8549
8801
|
}
|
|
@@ -8585,7 +8837,7 @@ function startHealthServer(port) {
|
|
|
8585
8837
|
return server;
|
|
8586
8838
|
}
|
|
8587
8839
|
function writePidFile(path) {
|
|
8588
|
-
|
|
8840
|
+
writeFileSync9(path, String(process.pid));
|
|
8589
8841
|
console.log(`[hivemind] PID file written: ${path}`);
|
|
8590
8842
|
}
|
|
8591
8843
|
function cleanupPidFile(path) {
|
|
@@ -8626,20 +8878,34 @@ async function startPipeline(configPath) {
|
|
|
8626
8878
|
console.log("[hivemind] Global context already exists in memory daemon");
|
|
8627
8879
|
}
|
|
8628
8880
|
}
|
|
8629
|
-
const requestLogger = new RequestLogger(resolve20(
|
|
8881
|
+
const requestLogger = new RequestLogger(resolve20(dirname9(configPath), "data", "dashboard.db"));
|
|
8630
8882
|
const agent = new Agent(config);
|
|
8631
8883
|
startDashboardServer(requestLogger, config.memory, () => agent.getConversationHistories());
|
|
8632
8884
|
agent.setRequestLogger(requestLogger);
|
|
8633
8885
|
const hivemindHome = process.env.HIVEMIND_HOME || resolve20(process.env.HOME || "/root", "hivemind");
|
|
8886
|
+
const workspaceDir = resolve20(hivemindHome, config.agent.workspace || "workspace");
|
|
8887
|
+
let contextBridge;
|
|
8888
|
+
if (memoryConnected) {
|
|
8889
|
+
try {
|
|
8890
|
+
contextBridge = await createContextBridge({
|
|
8891
|
+
workspaceDir,
|
|
8892
|
+
memoryClient: memory,
|
|
8893
|
+
logger: createLogger("claude-bridge")
|
|
8894
|
+
});
|
|
8895
|
+
console.log("[hivemind] Claude context bridge initialized");
|
|
8896
|
+
} catch (err) {
|
|
8897
|
+
console.warn("[hivemind] Failed to create Claude context bridge:", err);
|
|
8898
|
+
}
|
|
8899
|
+
}
|
|
8634
8900
|
const toolRegistry = registerAllTools(hivemindHome, {
|
|
8635
8901
|
enabled: true,
|
|
8636
8902
|
workspace: config.agent.workspace || "workspace",
|
|
8637
8903
|
braveApiKey: process.env.BRAVE_API_KEY,
|
|
8638
8904
|
memoryDaemonUrl: config.memory.daemon_url,
|
|
8639
8905
|
configPath,
|
|
8640
|
-
llmConfig: config.llm
|
|
8906
|
+
llmConfig: config.llm,
|
|
8907
|
+
contextBridge
|
|
8641
8908
|
});
|
|
8642
|
-
const workspaceDir = resolve20(hivemindHome, config.agent.workspace || "workspace");
|
|
8643
8909
|
const skillsEngine = new SkillsEngine(workspaceDir, toolRegistry);
|
|
8644
8910
|
await skillsEngine.loadAll();
|
|
8645
8911
|
registerSkillsTools(toolRegistry, skillsEngine, workspaceDir);
|
|
@@ -8889,7 +9155,7 @@ async function runSpawnTask(config, configPath) {
|
|
|
8889
9155
|
const result = response.content;
|
|
8890
9156
|
console.log(`[spawn] Task completed (context: ${response.context})`);
|
|
8891
9157
|
if (spawnDir) {
|
|
8892
|
-
|
|
9158
|
+
writeFileSync9(resolve20(spawnDir, "result.txt"), result);
|
|
8893
9159
|
}
|
|
8894
9160
|
if (channelId && config.sesame.api_key) {
|
|
8895
9161
|
try {
|
|
@@ -8906,7 +9172,7 @@ async function runSpawnTask(config, configPath) {
|
|
|
8906
9172
|
const errorMsg = `[SPAWN ERROR] ${err.message}`;
|
|
8907
9173
|
console.error(`[spawn] ${errorMsg}`);
|
|
8908
9174
|
if (spawnDir) {
|
|
8909
|
-
|
|
9175
|
+
writeFileSync9(resolve20(spawnDir, "result.txt"), errorMsg);
|
|
8910
9176
|
}
|
|
8911
9177
|
process.exitCode = 1;
|
|
8912
9178
|
}
|
|
@@ -9418,4 +9684,4 @@ smol-toml/dist/index.js:
|
|
|
9418
9684
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
9419
9685
|
*)
|
|
9420
9686
|
*/
|
|
9421
|
-
//# sourceMappingURL=chunk-
|
|
9687
|
+
//# sourceMappingURL=chunk-ZQ26EOYD.js.map
|