opencode-fractal-memory 0.6.3 → 0.6.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/management-server.js +46 -3
- package/dist/plugin/index.js +2 -0
- package/package.json +1 -1
|
@@ -1,4 +1,47 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import * as path from "node:path";
|
|
2
|
+
import { memLog } from "./logging";
|
|
3
|
+
let activeProcess = null;
|
|
4
|
+
export function startManagementServer(_store, directory, config) {
|
|
5
|
+
if (activeProcess) {
|
|
6
|
+
memLog("warn", "management", "Management server already running, killing old instance");
|
|
7
|
+
stopManagementServer();
|
|
8
|
+
}
|
|
9
|
+
const standalonePath = path.join(__dirname, "management-standalone.js");
|
|
10
|
+
try {
|
|
11
|
+
const proc = Bun.spawn(["bun", standalonePath], {
|
|
12
|
+
env: {
|
|
13
|
+
...process.env,
|
|
14
|
+
MGMT_PORT: String(config.port),
|
|
15
|
+
MGMT_PROJECT_DIR: directory,
|
|
16
|
+
},
|
|
17
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
18
|
+
});
|
|
19
|
+
activeProcess = proc;
|
|
20
|
+
proc.exited.then((code) => {
|
|
21
|
+
memLog("info", "management", `Management server exited (code: ${code})`);
|
|
22
|
+
if (activeProcess === proc)
|
|
23
|
+
activeProcess = null;
|
|
24
|
+
});
|
|
25
|
+
memLog("info", "management", `Management server started on http://localhost:${config.port} (pid: ${proc.pid})`);
|
|
26
|
+
}
|
|
27
|
+
catch (err) {
|
|
28
|
+
memLog("error", "management", "Failed to start management server", {
|
|
29
|
+
error: err instanceof Error ? err.message : String(err),
|
|
30
|
+
standalonePath,
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
export function stopManagementServer() {
|
|
35
|
+
if (activeProcess) {
|
|
36
|
+
try {
|
|
37
|
+
activeProcess.kill("SIGTERM");
|
|
38
|
+
memLog("info", "management", `Management server process ${activeProcess.pid} killed`);
|
|
39
|
+
}
|
|
40
|
+
catch (err) {
|
|
41
|
+
memLog("warn", "management", "Error killing management server", {
|
|
42
|
+
error: err instanceof Error ? err.message : String(err),
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
activeProcess = null;
|
|
46
|
+
}
|
|
4
47
|
}
|
package/dist/plugin/index.js
CHANGED
|
@@ -2,6 +2,7 @@ import { initStorage, loadPluginConfig, seedRuleNodes, backfillData, scheduleBac
|
|
|
2
2
|
import { createHookHandlers } from "./hooks";
|
|
3
3
|
import { createToolMap } from "./tools";
|
|
4
4
|
import { memLog, perfNow } from "../logging";
|
|
5
|
+
import { stopManagementServer } from "../management-server";
|
|
5
6
|
export const MemoryPlugin = async (ctx) => {
|
|
6
7
|
const { directory, client } = ctx;
|
|
7
8
|
const t0 = perfNow();
|
|
@@ -40,6 +41,7 @@ export const MemoryPlugin = async (ctx) => {
|
|
|
40
41
|
...(autoRetrieveHook || {}),
|
|
41
42
|
tool: toolMap,
|
|
42
43
|
cleanup: async () => {
|
|
44
|
+
stopManagementServer();
|
|
43
45
|
await store.close();
|
|
44
46
|
},
|
|
45
47
|
};
|