@context-vault/core 2.8.14 → 2.8.15

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@context-vault/core",
3
- "version": "2.8.14",
3
+ "version": "2.8.15",
4
4
  "type": "module",
5
5
  "description": "Shared core: capture, index, retrieve, tools, and utilities for context-vault",
6
6
  "main": "src/index.js",
@@ -99,9 +99,9 @@ export async function embedBatch(texts) {
99
99
  `Unexpected embedding dimension: ${result.data.length} / ${texts.length} = ${dim}`,
100
100
  );
101
101
  }
102
- return texts.map(
103
- (_, i) => new Float32Array(result.data.buffer, i * dim * 4, dim),
104
- );
102
+ // subarray() creates a view into result.data's index-space, correctly
103
+ // accounting for any non-zero byteOffset on the source typed array.
104
+ return texts.map((_, i) => result.data.subarray(i * dim, (i + 1) * dim));
105
105
  }
106
106
 
107
107
  /** Force re-initialization on next embed call. */
@@ -32,10 +32,16 @@ export async function handler({ id }, ctx, { ensureIndexed }) {
32
32
  }
33
33
 
34
34
  // Delete file from disk first (source of truth)
35
+ let fileWarning = null;
35
36
  if (entry.file_path) {
36
37
  try {
37
38
  unlinkSync(entry.file_path);
38
- } catch {}
39
+ } catch (e) {
40
+ // ENOENT = already gone — not an error worth surfacing
41
+ if (e.code !== "ENOENT") {
42
+ fileWarning = `file could not be removed from disk (${e.code}): ${entry.file_path}`;
43
+ }
44
+ }
39
45
  }
40
46
 
41
47
  // Delete vector embedding
@@ -49,5 +55,6 @@ export async function handler({ id }, ctx, { ensureIndexed }) {
49
55
  // Delete DB row (FTS trigger handles FTS cleanup)
50
56
  ctx.stmts.deleteEntry.run(id);
51
57
 
52
- return ok(`Deleted ${entry.kind}: ${entry.title || "(untitled)"} [${id}]`);
58
+ const msg = `Deleted ${entry.kind}: ${entry.title || "(untitled)"} [${id}]`;
59
+ return ok(fileWarning ? `${msg}\nWarning: ${fileWarning}` : msg);
53
60
  }
@@ -28,9 +28,11 @@ export function registerTools(server, ctx) {
28
28
  return async (...args) => {
29
29
  if (ctx.activeOps) ctx.activeOps.count++;
30
30
  let timer;
31
+ let handlerPromise;
31
32
  try {
33
+ handlerPromise = Promise.resolve(handler(...args));
32
34
  return await Promise.race([
33
- Promise.resolve(handler(...args)),
35
+ handlerPromise,
34
36
  new Promise((_, reject) => {
35
37
  timer = setTimeout(
36
38
  () => reject(new Error("TOOL_TIMEOUT")),
@@ -40,6 +42,9 @@ export function registerTools(server, ctx) {
40
42
  ]);
41
43
  } catch (e) {
42
44
  if (e.message === "TOOL_TIMEOUT") {
45
+ // Suppress any late rejection from the still-running handler to
46
+ // prevent unhandled promise rejection warnings in the host process.
47
+ handlerPromise?.catch(() => {});
43
48
  return err(
44
49
  "Tool timed out after 60s. Try a simpler query or run `context-vault reindex` first.",
45
50
  "TIMEOUT",