pi-vault-mind 0.16.4 → 0.16.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/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.16.5 / 0.6.7 — 2026-07-18
4
+
5
+ ### Fixed
6
+
7
+ - **Vault-scoped runtime ownership.** The plugin serializes startup per vault, adopts only a healthy bridge for the same canonical vault, and uses the configured `vaultMind.files.serverState` discovery path. This prevents duplicate Pi runtime launches across plugin instances and reloads.
8
+ - **Post-setup chat handoff.** A successful setup refreshes the shared panel controller before revealing an existing Vault Mind leaf. The panel remains available with its retained status if that refresh transiently fails.
9
+ - **Setup REST identity.** `GET /vm/status` now returns the configured vault identity so the plugin can verify runtime ownership.
10
+
11
+ ### Tests
12
+
13
+ - Added focused coverage for same-vault startup serialization, custom runtime discovery paths, setup-to-chat refresh ordering, and mount-on-refresh-failure behavior.
14
+
3
15
  ## 0.16.4 / 0.6.6 — 2026-07-17
4
16
 
5
17
  ### Fixed
@@ -98,8 +98,13 @@ export function startServer(pi, serverState, watcherState, readinessCallback) {
98
98
  // Resolve the vault path from the loaded config's default vault, else cwd.
99
99
  const startupCfg = loadConfig(process.cwd());
100
100
  const defaultVault = startupCfg.vaultMind.vaults?.default?.path;
101
- const vaultPath = defaultVault && fs.existsSync(defaultVault) ? defaultVault : process.cwd();
102
- serverState.vaultPath = vaultPath;
101
+ const configuredVaultPath = defaultVault && fs.existsSync(defaultVault) ? defaultVault : process.cwd();
102
+ try {
103
+ serverState.vaultPath = fs.realpathSync.native(configuredVaultPath);
104
+ }
105
+ catch {
106
+ serverState.vaultPath = path.resolve(configuredVaultPath);
107
+ }
103
108
  serverState.server = http.createServer(async (req, res) => {
104
109
  applyCorsPolicy(req.headers.origin, serverState.port, res);
105
110
  res.setHeader("Content-Type", "application/json");
@@ -750,15 +755,25 @@ export function startServer(pi, serverState, watcherState, readinessCallback) {
750
755
  res.end(JSON.stringify({ error: message }));
751
756
  }
752
757
  });
753
- let retriedEphemeral = false;
754
758
  serverState.server.on("error", (err) => {
755
- if (err.code === "EADDRINUSE" && !retriedEphemeral) {
756
- retriedEphemeral = true;
757
- console.warn(`[pi-vault-mind] Port ${serverState.port} in use; retrying on ephemeral port.`);
758
- serverState.server?.listen(0, "127.0.0.1");
759
- }
760
- else if (err.code === "EADDRINUSE") {
761
- console.warn(`[pi-vault-mind] Port ${serverState.port} in use. HTTP server not started.`);
759
+ if (err.code === "EADDRINUSE") {
760
+ console.warn(`[pi-vault-mind] Port ${serverState.port} in use; HTTP server not started.`);
761
+ if (serverState.unsubQueue) {
762
+ serverState.unsubQueue();
763
+ serverState.unsubQueue = undefined;
764
+ }
765
+ if (serverState.unsubToolBus) {
766
+ serverState.unsubToolBus();
767
+ serverState.unsubToolBus = undefined;
768
+ }
769
+ if (serverState.wss) {
770
+ serverState.wss.close();
771
+ serverState.wss = null;
772
+ }
773
+ if (serverState.server) {
774
+ serverState.server.close();
775
+ serverState.server = null;
776
+ }
762
777
  }
763
778
  else {
764
779
  console.error("[pi-vault-mind] HTTP server error:", err);
@@ -1077,14 +1092,21 @@ function handleVaultMindContextGet(res, serverState) {
1077
1092
  // ── Stage 1 setup routes (auth-gated) ───────────────────────────────────────
1078
1093
  function handleVmStatus(res, serverState) {
1079
1094
  const ws = serverState.watcherState;
1080
- const cfg = loadConfig(process.cwd());
1081
- const configured = !!findConfig(process.cwd()).project;
1095
+ const vaultPath = serverState.vaultPath;
1096
+ if (!vaultPath) {
1097
+ res.writeHead(500);
1098
+ res.end(JSON.stringify({ error: "Vault path not set" }));
1099
+ return;
1100
+ }
1101
+ const cfg = loadConfig(vaultPath);
1102
+ const configured = !!findConfig(vaultPath).project;
1082
1103
  const model = cfg.vaultMind.embedding[EMBEDDING_FLAT_KEYS[2]] || "embeddinggemma";
1083
1104
  const dim = cfg.vaultMind.embedding[EMBEDDING_FLAT_KEYS[4]] ?? 768;
1084
1105
  res.writeHead(200);
1085
1106
  res.end(JSON.stringify({
1086
1107
  ok: true,
1087
1108
  configured,
1109
+ vaultPath,
1088
1110
  watcher: ws?.running ?? false,
1089
1111
  embedding: {
1090
1112
  model,
@@ -81,6 +81,13 @@ describe("REST setup routes", () => {
81
81
  const { status } = await fetchJson(port, "GET", "/vm/status");
82
82
  assert.equal(status, 401);
83
83
  });
84
+ it("GET /vm/status returns the configured vault identity", async () => {
85
+ writeVaultConfig(vaultPath);
86
+ const { status, body } = await fetchJson(port, "GET", "/vm/status", { token: TEST_TOKEN });
87
+ assert.equal(status, 200);
88
+ const b = body;
89
+ assert.equal(b.vaultPath, vaultPath, "status must expose the resolved vault path so clients can recheck vault identity");
90
+ });
84
91
  it("POST /vm/setup scaffolds config and vault-named collection file", async () => {
85
92
  const { status, body } = await fetchJson(port, "POST", "/vm/setup", {
86
93
  body: { vault: vaultPath },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-vault-mind",
3
- "version": "0.16.4",
3
+ "version": "0.16.5",
4
4
  "description": "Passive Obsidian vault extension for pi. Watches @agent markers, dispatches forked subagents (Miner, Broadcaster, Heavy-Lifter), stores in LanceDB with vector + FTS + graph. Multi-agent 'Drop & Forget' workflow for the pi agent ecosystem.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",