@sesamespace/hivemind 0.12.2 → 0.12.4
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/{chunk-ZAPHLG7V.js → chunk-FIHSUSBJ.js} +2 -2
- package/dist/{chunk-EJM4KCCY.js → chunk-J3WGHS5W.js} +2 -2
- package/dist/{chunk-R7RHYYOM.js → chunk-PGLO6WA5.js} +189 -30
- package/dist/{chunk-R7RHYYOM.js.map → chunk-PGLO6WA5.js.map} +1 -1
- package/dist/{chunk-3F7M2BPR.js → chunk-TJBUZUVY.js} +3 -3
- package/dist/{chunk-SNW6Z2W4.js → chunk-XW4AQDZA.js} +2 -2
- package/dist/{chunk-ZI4AN7GT.js → chunk-YDK3Z5IW.js} +2 -2
- 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/test/claude-integration.test.ts +325 -0
- package/.session-log.json +0 -58
- /package/dist/{chunk-ZAPHLG7V.js.map → chunk-FIHSUSBJ.js.map} +0 -0
- /package/dist/{chunk-EJM4KCCY.js.map → chunk-J3WGHS5W.js.map} +0 -0
- /package/dist/{chunk-3F7M2BPR.js.map → chunk-TJBUZUVY.js.map} +0 -0
- /package/dist/{chunk-SNW6Z2W4.js.map → chunk-XW4AQDZA.js.map} +0 -0
- /package/dist/{chunk-ZI4AN7GT.js.map → chunk-YDK3Z5IW.js.map} +0 -0
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
SesameClient2 as SesameClient,
|
|
8
8
|
WORKER_ROUTES,
|
|
9
9
|
createLogger
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-PGLO6WA5.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-FIHSUSBJ.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
FleetManager
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-FIHSUSBJ.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-J3WGHS5W.js.map
|
|
@@ -5178,7 +5178,7 @@ function registerFileTools(registry, workspaceDir) {
|
|
|
5178
5178
|
required: []
|
|
5179
5179
|
},
|
|
5180
5180
|
async (params) => {
|
|
5181
|
-
const { readdirSync: readdirSync5, statSync:
|
|
5181
|
+
const { readdirSync: readdirSync5, statSync: statSync5 } = await import("fs");
|
|
5182
5182
|
const dirPath = params.path ? resolvePath(workspaceDir, params.path) : workspaceDir;
|
|
5183
5183
|
if (!existsSync10(dirPath)) {
|
|
5184
5184
|
return `Error: Directory not found: ${dirPath}`;
|
|
@@ -5189,7 +5189,7 @@ function registerFileTools(registry, workspaceDir) {
|
|
|
5189
5189
|
for (const entry of entries) {
|
|
5190
5190
|
if (entry.startsWith(".")) continue;
|
|
5191
5191
|
try {
|
|
5192
|
-
const stat =
|
|
5192
|
+
const stat = statSync5(resolve9(dirPath, entry));
|
|
5193
5193
|
results.push(stat.isDirectory() ? `${entry}/` : entry);
|
|
5194
5194
|
} catch {
|
|
5195
5195
|
results.push(entry);
|
|
@@ -7885,6 +7885,18 @@ function registerCodingAgentTools(registry, workspaceDir, contextBridge) {
|
|
|
7885
7885
|
}
|
|
7886
7886
|
const escapedTask = task.replace(/'/g, "'\\''");
|
|
7887
7887
|
const command = `claude --dangerously-skip-permissions -p '${escapedTask}'`;
|
|
7888
|
+
let needHandler;
|
|
7889
|
+
let errorHandler;
|
|
7890
|
+
if (contextBridge) {
|
|
7891
|
+
needHandler = (need) => {
|
|
7892
|
+
console.log(`[Claude needs context]: ${need}`);
|
|
7893
|
+
};
|
|
7894
|
+
contextBridge.on("context-request", needHandler);
|
|
7895
|
+
errorHandler = (error) => {
|
|
7896
|
+
console.log(`[Claude encountered error]: ${error}`);
|
|
7897
|
+
};
|
|
7898
|
+
contextBridge.on("error-encountered", errorHandler);
|
|
7899
|
+
}
|
|
7888
7900
|
try {
|
|
7889
7901
|
const output = await new Promise((resolve21, reject) => {
|
|
7890
7902
|
const child = exec2(command, {
|
|
@@ -7908,9 +7920,35 @@ function registerCodingAgentTools(registry, workspaceDir, contextBridge) {
|
|
|
7908
7920
|
});
|
|
7909
7921
|
child.stdin?.end();
|
|
7910
7922
|
});
|
|
7923
|
+
let summaryText = "";
|
|
7924
|
+
if (contextBridge) {
|
|
7925
|
+
try {
|
|
7926
|
+
const summary = await contextBridge.getSessionSummary();
|
|
7927
|
+
if (summary.discoveries.length > 0) {
|
|
7928
|
+
summaryText += `
|
|
7929
|
+
|
|
7930
|
+
## Discoveries Made:
|
|
7931
|
+
${summary.discoveries.map((d) => `- ${d}`).join("\n")}`;
|
|
7932
|
+
}
|
|
7933
|
+
if (summary.patterns.length > 0) {
|
|
7934
|
+
summaryText += `
|
|
7935
|
+
|
|
7936
|
+
## Patterns Found:
|
|
7937
|
+
${summary.patterns.map((p) => `- ${p}`).join("\n")}`;
|
|
7938
|
+
}
|
|
7939
|
+
if (summary.errors.length > 0) {
|
|
7940
|
+
summaryText += `
|
|
7941
|
+
|
|
7942
|
+
## Errors Encountered:
|
|
7943
|
+
${summary.errors.map((e) => `- ${e}`).join("\n")}`;
|
|
7944
|
+
}
|
|
7945
|
+
} catch (err) {
|
|
7946
|
+
console.warn("Failed to get session summary:", err);
|
|
7947
|
+
}
|
|
7948
|
+
}
|
|
7911
7949
|
const trimmed = output.length > MAX_OUTPUT6 ? output.slice(0, MAX_OUTPUT6) + `
|
|
7912
7950
|
... (truncated, ${output.length} total chars)` : output;
|
|
7913
|
-
return trimmed || "(no output)";
|
|
7951
|
+
return (trimmed || "(no output)") + summaryText;
|
|
7914
7952
|
} catch (err) {
|
|
7915
7953
|
if (err.killed) {
|
|
7916
7954
|
return `Error: Claude Code timed out after ${timeoutSeconds}s`;
|
|
@@ -7921,6 +7959,13 @@ function registerCodingAgentTools(registry, workspaceDir, contextBridge) {
|
|
|
7921
7959
|
const code = err.status ?? "unknown";
|
|
7922
7960
|
return `Claude Code failed (exit code ${code}):
|
|
7923
7961
|
${output || err.message}`;
|
|
7962
|
+
} finally {
|
|
7963
|
+
if (contextBridge && needHandler) {
|
|
7964
|
+
contextBridge.off("context-request", needHandler);
|
|
7965
|
+
}
|
|
7966
|
+
if (contextBridge && errorHandler) {
|
|
7967
|
+
contextBridge.off("error-encountered", errorHandler);
|
|
7968
|
+
}
|
|
7924
7969
|
}
|
|
7925
7970
|
}
|
|
7926
7971
|
);
|
|
@@ -8588,12 +8633,13 @@ Path: ${skillDir}`;
|
|
|
8588
8633
|
}
|
|
8589
8634
|
|
|
8590
8635
|
// packages/runtime/src/pipeline.ts
|
|
8591
|
-
import { readFileSync as
|
|
8636
|
+
import { readFileSync as readFileSync16, writeFileSync as writeFileSync9, unlinkSync as unlinkSync3 } from "fs";
|
|
8592
8637
|
import { resolve as resolve20, dirname as dirname8 } from "path";
|
|
8593
8638
|
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
8594
8639
|
|
|
8595
8640
|
// packages/runtime/src/tools/context-bridge.ts
|
|
8596
|
-
import { writeFileSync as writeFileSync8, existsSync as existsSync20, mkdirSync as mkdirSync15,
|
|
8641
|
+
import { writeFileSync as writeFileSync8, readFileSync as readFileSync15, statSync as statSync4, existsSync as existsSync20, mkdirSync as mkdirSync15, openSync, readSync, closeSync } from "fs";
|
|
8642
|
+
import { createHash as createHash2 } from "crypto";
|
|
8597
8643
|
import { join as join8 } from "path";
|
|
8598
8644
|
import { homedir } from "os";
|
|
8599
8645
|
import { EventEmitter as EventEmitter2 } from "events";
|
|
@@ -8603,6 +8649,9 @@ var ClaudeContextBridge = class extends EventEmitter2 {
|
|
|
8603
8649
|
logger;
|
|
8604
8650
|
sessionLogPath;
|
|
8605
8651
|
contextFilePath;
|
|
8652
|
+
watchInterval = null;
|
|
8653
|
+
lastLogSize = 0;
|
|
8654
|
+
seenPatterns = /* @__PURE__ */ new Set();
|
|
8606
8655
|
constructor(config) {
|
|
8607
8656
|
super();
|
|
8608
8657
|
this.workspaceDir = config.workspaceDir;
|
|
@@ -8693,7 +8742,7 @@ ${memories.join("\n\n")}
|
|
|
8693
8742
|
`;
|
|
8694
8743
|
}
|
|
8695
8744
|
} catch (err) {
|
|
8696
|
-
this.logger.warn("Failed to fetch memories for context", err);
|
|
8745
|
+
this.logger.warn("Failed to fetch memories for context", { error: String(err) });
|
|
8697
8746
|
}
|
|
8698
8747
|
writeFileSync8(this.contextFilePath, content);
|
|
8699
8748
|
this.logger.info("Context prepared for Claude Code", { goal: context.goal });
|
|
@@ -8721,25 +8770,33 @@ ${memories.join("\n\n")}
|
|
|
8721
8770
|
if (!existsSync20(this.sessionLogPath)) {
|
|
8722
8771
|
writeFileSync8(this.sessionLogPath, "");
|
|
8723
8772
|
}
|
|
8724
|
-
|
|
8725
|
-
|
|
8726
|
-
|
|
8727
|
-
|
|
8728
|
-
|
|
8729
|
-
|
|
8730
|
-
|
|
8731
|
-
|
|
8732
|
-
|
|
8733
|
-
|
|
8734
|
-
|
|
8735
|
-
|
|
8736
|
-
|
|
8737
|
-
|
|
8738
|
-
|
|
8773
|
+
const stats = existsSync20(this.sessionLogPath) ? statSync4(this.sessionLogPath) : { size: 0 };
|
|
8774
|
+
this.lastLogSize = stats.size;
|
|
8775
|
+
this.watchInterval = setInterval(() => {
|
|
8776
|
+
this.checkForLogUpdates();
|
|
8777
|
+
}, 500);
|
|
8778
|
+
this.logger.info("Started real-time monitoring of Claude session log");
|
|
8779
|
+
}
|
|
8780
|
+
/**
|
|
8781
|
+
* Check for new log entries
|
|
8782
|
+
*/
|
|
8783
|
+
checkForLogUpdates() {
|
|
8784
|
+
try {
|
|
8785
|
+
const stats = statSync4(this.sessionLogPath);
|
|
8786
|
+
if (stats.size > this.lastLogSize) {
|
|
8787
|
+
const fd = openSync(this.sessionLogPath, "r");
|
|
8788
|
+
const buf = Buffer.alloc(stats.size - this.lastLogSize);
|
|
8789
|
+
readSync(fd, buf, 0, buf.length, this.lastLogSize);
|
|
8790
|
+
closeSync(fd);
|
|
8791
|
+
this.lastLogSize = stats.size;
|
|
8792
|
+
const lines = buf.toString("utf-8").split("\n").filter((l) => l.trim());
|
|
8793
|
+
for (const line of lines) {
|
|
8794
|
+
this.processLogLine(line);
|
|
8739
8795
|
}
|
|
8740
8796
|
}
|
|
8741
|
-
})
|
|
8742
|
-
|
|
8797
|
+
} catch (err) {
|
|
8798
|
+
this.logger.warn("Failed to check session log", { error: String(err) });
|
|
8799
|
+
}
|
|
8743
8800
|
}
|
|
8744
8801
|
/**
|
|
8745
8802
|
* Process a line from Claude's session log
|
|
@@ -8769,6 +8826,14 @@ ${memories.join("\n\n")}
|
|
|
8769
8826
|
async handleInsight(type, content) {
|
|
8770
8827
|
this.logger.info(`Claude insight: ${type}`, { content });
|
|
8771
8828
|
this.emit("insight", { type, content });
|
|
8829
|
+
if (type === "PATTERN") {
|
|
8830
|
+
const patternHash = createHash2("md5").update(content).digest("hex");
|
|
8831
|
+
if (this.seenPatterns.has(patternHash)) {
|
|
8832
|
+
this.logger.debug("Skipping duplicate pattern", { content });
|
|
8833
|
+
return;
|
|
8834
|
+
}
|
|
8835
|
+
this.seenPatterns.add(patternHash);
|
|
8836
|
+
}
|
|
8772
8837
|
if (["DISCOVERY", "PATTERN"].includes(type)) {
|
|
8773
8838
|
try {
|
|
8774
8839
|
await this.memoryClient.storeEpisode({
|
|
@@ -8776,21 +8841,115 @@ ${memories.join("\n\n")}
|
|
|
8776
8841
|
role: "system",
|
|
8777
8842
|
content: `Claude Code ${type}: ${content}`
|
|
8778
8843
|
});
|
|
8844
|
+
this.logger.info(`Stored ${type} in memory`, { content });
|
|
8779
8845
|
} catch (err) {
|
|
8780
|
-
this.logger.warn("Failed to store Claude insight in memory", err);
|
|
8846
|
+
this.logger.warn("Failed to store Claude insight in memory", { error: String(err) });
|
|
8847
|
+
}
|
|
8848
|
+
}
|
|
8849
|
+
switch (type) {
|
|
8850
|
+
case "NEED":
|
|
8851
|
+
this.emit("context-request", content);
|
|
8852
|
+
await this.tryProvideContext(content);
|
|
8853
|
+
break;
|
|
8854
|
+
case "ERROR":
|
|
8855
|
+
this.emit("error-encountered", content);
|
|
8856
|
+
break;
|
|
8857
|
+
case "COMPLETE":
|
|
8858
|
+
this.emit("task-complete", content);
|
|
8859
|
+
break;
|
|
8860
|
+
}
|
|
8861
|
+
}
|
|
8862
|
+
/**
|
|
8863
|
+
* Try to provide additional context when Claude needs it
|
|
8864
|
+
*/
|
|
8865
|
+
async tryProvideContext(need) {
|
|
8866
|
+
try {
|
|
8867
|
+
const results = await Promise.race([
|
|
8868
|
+
this.memoryClient.search(need, "global", 3),
|
|
8869
|
+
new Promise(
|
|
8870
|
+
(_, reject) => setTimeout(() => reject(new Error("Memory search timeout")), 3e3)
|
|
8871
|
+
)
|
|
8872
|
+
]);
|
|
8873
|
+
if (results.length > 0) {
|
|
8874
|
+
let additionalContext = `
|
|
8875
|
+
|
|
8876
|
+
## Additional Context (Requested: ${(/* @__PURE__ */ new Date()).toISOString()})
|
|
8877
|
+
`;
|
|
8878
|
+
additionalContext += `### You asked about: ${need}
|
|
8879
|
+
|
|
8880
|
+
`;
|
|
8881
|
+
additionalContext += results.map((r) => `- ${r.content}`).join("\n");
|
|
8882
|
+
const currentContext = existsSync20(this.contextFilePath) ? readFileSync15(this.contextFilePath, "utf-8") : "";
|
|
8883
|
+
writeFileSync8(this.contextFilePath, currentContext + additionalContext);
|
|
8884
|
+
this.logger.info("Provided additional context to Claude", { need });
|
|
8781
8885
|
}
|
|
8886
|
+
} catch (err) {
|
|
8887
|
+
this.logger.warn("Failed to provide additional context", { error: String(err) });
|
|
8782
8888
|
}
|
|
8783
|
-
|
|
8784
|
-
|
|
8889
|
+
}
|
|
8890
|
+
/**
|
|
8891
|
+
* Get session insights summary
|
|
8892
|
+
*/
|
|
8893
|
+
async getSessionSummary() {
|
|
8894
|
+
try {
|
|
8895
|
+
const results = await Promise.race([
|
|
8896
|
+
this.memoryClient.search("", "claude-code-insights", 50),
|
|
8897
|
+
new Promise(
|
|
8898
|
+
(_, reject) => setTimeout(() => reject(new Error("Memory search timeout")), 3e3)
|
|
8899
|
+
)
|
|
8900
|
+
]);
|
|
8901
|
+
const summary = {
|
|
8902
|
+
discoveries: [],
|
|
8903
|
+
patterns: [],
|
|
8904
|
+
needs: [],
|
|
8905
|
+
errors: [],
|
|
8906
|
+
completions: []
|
|
8907
|
+
};
|
|
8908
|
+
for (const result of results) {
|
|
8909
|
+
const match = result.content.match(/^(DISCOVERY|PATTERN|NEED|ERROR|COMPLETE):\s*(.+)$/);
|
|
8910
|
+
if (match) {
|
|
8911
|
+
const [, type, content] = match;
|
|
8912
|
+
switch (type) {
|
|
8913
|
+
case "DISCOVERY":
|
|
8914
|
+
summary.discoveries.push(content);
|
|
8915
|
+
break;
|
|
8916
|
+
case "PATTERN":
|
|
8917
|
+
summary.patterns.push(content);
|
|
8918
|
+
break;
|
|
8919
|
+
case "NEED":
|
|
8920
|
+
summary.needs.push(content);
|
|
8921
|
+
break;
|
|
8922
|
+
case "ERROR":
|
|
8923
|
+
summary.errors.push(content);
|
|
8924
|
+
break;
|
|
8925
|
+
case "COMPLETE":
|
|
8926
|
+
summary.completions.push(content);
|
|
8927
|
+
break;
|
|
8928
|
+
}
|
|
8929
|
+
}
|
|
8930
|
+
}
|
|
8931
|
+
return summary;
|
|
8932
|
+
} catch (err) {
|
|
8933
|
+
this.logger.warn("Failed to get session summary", { error: String(err) });
|
|
8934
|
+
return {
|
|
8935
|
+
discoveries: [],
|
|
8936
|
+
patterns: [],
|
|
8937
|
+
needs: [],
|
|
8938
|
+
errors: [],
|
|
8939
|
+
completions: []
|
|
8940
|
+
};
|
|
8785
8941
|
}
|
|
8786
8942
|
}
|
|
8787
8943
|
/**
|
|
8788
8944
|
* Clean up resources
|
|
8789
8945
|
*/
|
|
8790
8946
|
destroy() {
|
|
8791
|
-
if (this.
|
|
8792
|
-
|
|
8947
|
+
if (this.watchInterval) {
|
|
8948
|
+
clearInterval(this.watchInterval);
|
|
8949
|
+
this.watchInterval = null;
|
|
8793
8950
|
}
|
|
8951
|
+
this.seenPatterns.clear();
|
|
8952
|
+
this.removeAllListeners();
|
|
8794
8953
|
}
|
|
8795
8954
|
};
|
|
8796
8955
|
async function createContextBridge(config) {
|
|
@@ -8803,7 +8962,7 @@ async function createContextBridge(config) {
|
|
|
8803
8962
|
var PACKAGE_VERSION = "unknown";
|
|
8804
8963
|
try {
|
|
8805
8964
|
const __dirname2 = dirname8(fileURLToPath3(import.meta.url));
|
|
8806
|
-
const pkg = JSON.parse(
|
|
8965
|
+
const pkg = JSON.parse(readFileSync16(resolve20(__dirname2, "../package.json"), "utf-8"));
|
|
8807
8966
|
PACKAGE_VERSION = pkg.version ?? "unknown";
|
|
8808
8967
|
} catch {
|
|
8809
8968
|
}
|
|
@@ -9695,4 +9854,4 @@ smol-toml/dist/index.js:
|
|
|
9695
9854
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
9696
9855
|
*)
|
|
9697
9856
|
*/
|
|
9698
|
-
//# sourceMappingURL=chunk-
|
|
9857
|
+
//# sourceMappingURL=chunk-PGLO6WA5.js.map
|