dsh-mnemon-provider-openviking 0.5.8 → 0.5.9

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/README.md CHANGED
@@ -6,6 +6,10 @@ Requires a reachable OpenViking endpoint supporting `POST /api/v1/content/write`
6
6
 
7
7
  The supported scope is `viking://user/<user>/memories`. Existing `viking://user/memories` settings resolve through the configured user or authenticated `/api/v1/system/status` identity, without rewriting the local registry. A failed response, timeout, or mismatched readback produces an error instead of a committed receipt. When the server refused the write (an HTTP 4xx other than 408 or 409), the error says nothing was stored; otherwise it includes the requested URI because remote content may remain, so inspect it before retrying. Existing memories remain readable, and downgrading does not remove files written by this adapter.
8
8
 
9
+ ## Search
10
+
11
+ OpenViking `keyword` search uses `POST /api/v1/search/grep` for case-insensitive literal text, with regex metacharacters escaped. It scopes `uri` to the selected user memory root and bounds `node_limit` to the Source search budget (1–50; direct adapter default 10). Repeated lines in one file count as one result; only safe in-root memory Markdown files are hydrated through `content/read`, and no relevance score is invented. `smart`/`basic` keep `search/find`. A missing grep endpoint or invalid response is reported as an error rather than a semantic fallback; arbitrary regular-expression input is not exposed. The request uses the common fields of OpenViking 0.4.16 and 0.5.1.1.
12
+
9
13
  ## Use
10
14
 
11
15
  The default `dsh-mnemon` Starter already installs this package. Enable and configure the service on the `dsh-mnemon` page under **Plugins**, then inspect its synchronized Memory Spaces.
package/lib/index.d.ts CHANGED
@@ -8,7 +8,9 @@ interface OpenVikingProviderOptions {
8
8
  declare class OpenVikingProvider implements MemoryProviderAdapter {
9
9
  private readonly memorySpaces;
10
10
  readonly id: "openviking";
11
- readonly scoreSemantics: import("dsh-mnemon-source-memory-spaces/provider-sdk").ProviderScoreSemantics;
11
+ readonly scoreSemantics: Readonly<{
12
+ kind: "provider-native";
13
+ }>;
12
14
  private readonly requestFetch;
13
15
  private readonly requestTimeoutMs;
14
16
  constructor(memorySpaces: MemorySpaceAuthority, options?: OpenVikingProviderOptions);
package/lib/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { t as descriptor } from "./descriptor-1h1ZrvkP.js";
2
- import { CATEGORIES, MEMORY_SPACE_PROVIDER_API_VERSION, NORMALIZED_RELEVANCE_SCORE, defineMemorySpaceProvider, defineMemorySpaceProviderDefinition } from "dsh-mnemon-source-memory-spaces/provider-sdk";
2
+ import { CATEGORIES, MEMORY_SPACE_PROVIDER_API_VERSION, defineMemorySpaceProvider, defineMemorySpaceProviderDefinition } from "dsh-mnemon-source-memory-spaces/provider-sdk";
3
3
  import { randomUUID } from "node:crypto";
4
4
  //#region src/driver.ts
5
5
  function object(value) {
@@ -83,7 +83,7 @@ function refused(error) {
83
83
  var OpenVikingProvider = class {
84
84
  memorySpaces;
85
85
  id = "openviking";
86
- scoreSemantics = NORMALIZED_RELEVANCE_SCORE;
86
+ scoreSemantics = Object.freeze({ kind: "provider-native" });
87
87
  requestFetch;
88
88
  requestTimeoutMs;
89
89
  constructor(memorySpaces, options = {}) {
@@ -158,21 +158,36 @@ var OpenVikingProvider = class {
158
158
  }
159
159
  }
160
160
  async search(body, request, signal) {
161
+ const keyword = request.mode === "keyword";
162
+ signal?.throwIfAborted();
163
+ if (keyword && request.query.trim() === "") return { results: [] };
164
+ const limit = keyword ? Math.min(50, Math.max(1, Math.floor(number(request.limit) ?? 10))) : request.limit;
161
165
  const memoryRoot = await this.memoryRoot(body, signal);
162
- const root = object(await this.request(body, "/api/v1/search/find", {
166
+ const root = object(await this.request(body, keyword ? "/api/v1/search/grep" : "/api/v1/search/find", {
163
167
  method: "POST",
164
- body: JSON.stringify({
168
+ body: JSON.stringify(keyword ? {
169
+ uri: memoryRoot,
170
+ pattern: request.query.replace(/[.*+?^${}()|[\]\\]/gu, "\\$&"),
171
+ case_insensitive: true,
172
+ node_limit: limit
173
+ } : {
165
174
  query: request.query,
166
175
  target_uri: memoryRoot,
167
176
  context_type: ["memory"],
168
177
  limit: request.limit
169
178
  })
170
179
  }, { signal }));
171
- const matches = (Array.isArray(root?.memories) ? root.memories : []).flatMap((value) => {
180
+ if (keyword && !Array.isArray(root?.matches)) throw new Error("OpenViking keyword search did not return matches");
181
+ const values = keyword ? root?.matches : root?.memories;
182
+ const entries = Array.isArray(values) ? values : [];
183
+ const seen = /* @__PURE__ */ new Set();
184
+ const matches = entries.flatMap((value) => {
172
185
  const item = object(value);
173
186
  const uri = string(item?.uri);
174
187
  if (uri === void 0 || !isMemoryFile(uri, memoryRoot)) return [];
175
- const score = number(item?.score);
188
+ if (keyword && seen.has(uri)) return [];
189
+ seen.add(uri);
190
+ const score = keyword ? void 0 : number(item?.score);
176
191
  return [{
177
192
  id: uri,
178
193
  externalUri: uri,
@@ -181,11 +196,11 @@ var OpenVikingProvider = class {
181
196
  source: "external",
182
197
  ...score === void 0 ? {} : { score }
183
198
  }];
184
- }).slice(0, request.limit);
199
+ }).slice(0, limit);
185
200
  const { read, skipped } = await this.readAll(body, matches, signal);
186
201
  return {
187
202
  results: read,
188
- ...skipped === 0 ? {} : { hint: `${skipped} OpenViking ${skipped === 1 ? "result" : "results"} could not be read and ${skipped === 1 ? "was" : "were"} left out; the server's index can list a file it no longer holds.` }
203
+ ...skipped === 0 ? {} : { hint: `${skipped} OpenViking ${skipped === 1 ? "result" : "results"} could not be read and ${skipped === 1 ? "was" : "were"} left out; the server can list a file it no longer holds.` }
189
204
  };
190
205
  }
191
206
  async graph(body, signal) {
@@ -268,8 +283,7 @@ var OpenVikingProvider = class {
268
283
  uri,
269
284
  content: request.content,
270
285
  mode: "create",
271
- wait: true,
272
- timeout: this.requestTimeoutMs / 1e3
286
+ wait: true
273
287
  })
274
288
  }, { signal }));
275
289
  } catch (error) {
@@ -277,7 +291,7 @@ var OpenVikingProvider = class {
277
291
  throw new Error(`OpenViking write was not verified at ${uri}; remote content may remain. Inspect this URI before retrying. ${error instanceof Error ? error.message : String(error)}`, { cause: error });
278
292
  }
279
293
  try {
280
- if (written?.uri !== uri || written.content_updated !== true || written.written_bytes !== writtenBytes || written.mode !== "create" || written.context_type !== "memory" || written.vector_status !== "complete" || !["complete", "skipped"].includes(String(written.semantic_status)) || queueFailed(written.queue_status)) throw new Error("content API did not confirm this exact memory and completed indexing");
294
+ if (written?.uri !== uri || written.content_updated !== true || (number(written.written_bytes) ?? -1) < writtenBytes || written.mode !== "create" || written.context_type !== "memory" || written.vector_status !== "complete" || !["complete", "skipped"].includes(String(written.semantic_status)) || queueFailed(written.queue_status)) throw new Error("content API did not confirm this exact memory and completed indexing");
281
295
  if (await this.readContent(body, uri, signal) !== request.content) throw new Error("stored content does not match the requested text");
282
296
  signal?.throwIfAborted();
283
297
  } catch (error) {
@@ -428,7 +442,7 @@ const definition = defineMemorySpaceProviderDefinition({
428
442
  kind: "provider",
429
443
  typeId: descriptor.id,
430
444
  packageName: "dsh-mnemon-provider-openviking",
431
- version: "0.5.8",
445
+ version: "0.5.9",
432
446
  label: descriptor.label,
433
447
  icon: descriptor.icon,
434
448
  summary: descriptor.summary,
@@ -439,7 +453,7 @@ const definition = defineMemorySpaceProviderDefinition({
439
453
  capabilities: descriptor.capabilities,
440
454
  fields: descriptor.fields,
441
455
  secrets: descriptor.fields.filter((field) => field.input === "secret").map((field) => field.key),
442
- scoreSemantics: "normalized-relevance"
456
+ scoreSemantics: "provider-native"
443
457
  },
444
458
  create: (context) => new OpenVikingProvider(context.memorySpaces ?? context.memoryBodies, { requestTimeoutMs: context.config.timeoutMs })
445
459
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-mnemon-provider-openviking",
3
- "version": "0.5.8",
3
+ "version": "0.5.9",
4
4
  "description": "OpenViking Provider child for the Memory Spaces Source.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -34,7 +34,7 @@
34
34
  },
35
35
  "devDependencies": {
36
36
  "@types/node": "^22.0.0",
37
- "dsh-mnemon-source-memory-spaces": "^0.5.19",
37
+ "dsh-mnemon-source-memory-spaces": "^0.5.23",
38
38
  "tsdown": "^0.22.0",
39
39
  "typescript": "^5.9.0",
40
40
  "vitest": "^3.2.0"