opencode-fractal-memory 0.6.11 → 0.6.12

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.
@@ -1,12 +1,22 @@
1
1
  import * as path from "node:path";
2
2
  import { memLog } from "./logging";
3
3
  let activeProcess = null;
4
+ let mgmtConfig = null;
5
+ export function isManagementServerRunning() {
6
+ return activeProcess !== null;
7
+ }
8
+ export function ensureManagementServer() {
9
+ if (mgmtConfig && mgmtConfig.enabled) {
10
+ startManagementServer(null, mgmtConfig.directory, { enabled: true, port: mgmtConfig.port });
11
+ }
12
+ }
4
13
  export function startManagementServer(_store, directory, config) {
5
14
  if (activeProcess) {
6
15
  memLog("warn", "management", "Management server already running, killing old instance");
7
16
  stopManagementServer();
8
17
  }
9
18
  const standalonePath = path.join(__dirname, "management-standalone.js");
19
+ mgmtConfig = { enabled: config.enabled, port: config.port, directory };
10
20
  try {
11
21
  const proc = Bun.spawn(["bun", standalonePath], {
12
22
  env: {
@@ -35,7 +45,7 @@ export function startManagementServer(_store, directory, config) {
35
45
  export function stopManagementServer() {
36
46
  if (activeProcess) {
37
47
  try {
38
- activeProcess.kill("SIGTERM");
48
+ activeProcess.kill("SIGKILL");
39
49
  memLog("info", "management", `Management server process ${activeProcess.pid} killed`);
40
50
  }
41
51
  catch (err) {
@@ -2,7 +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
+ import { stopManagementServer, ensureManagementServer } from "../management-server";
6
6
  export const MemoryPlugin = async (ctx) => {
7
7
  const { directory, client } = ctx;
8
8
  const t0 = perfNow();
@@ -40,9 +40,15 @@ export const MemoryPlugin = async (ctx) => {
40
40
  ...handlers,
41
41
  ...(autoRetrieveHook || {}),
42
42
  tool: toolMap,
43
- cleanup: async () => {
43
+ "session.created": async (event) => {
44
+ const existing = handlers["session.created"];
45
+ if (existing) {
46
+ await existing(event);
47
+ }
48
+ ensureManagementServer();
49
+ },
50
+ "session.deleted": async () => {
44
51
  stopManagementServer();
45
- await store.close();
46
52
  },
47
53
  };
48
54
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-fractal-memory",
3
- "version": "0.6.11",
3
+ "version": "0.6.12",
4
4
  "description": "Fractal memory system for OpenCode with semantic search and automatic compression.",
5
5
  "main": "dist/plugin.js",
6
6
  "exports": {