dsh-mnemon-provider-openviking 0.5.3 → 0.5.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/README.md +7 -3
- package/lib/{descriptor-OAMVgT8m.js → descriptor-BGwdKZKn.js} +3 -3
- package/lib/descriptor.js +1 -1
- package/lib/index.d.ts +4 -7
- package/lib/index.js +99 -106
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
An adapter for an existing OpenViking HTTP service and its filesystem-shaped memory resources.
|
|
4
4
|
|
|
5
|
-
Requires a reachable OpenViking endpoint
|
|
5
|
+
Requires a reachable OpenViking endpoint supporting `POST /api/v1/content/write` with `mode: "create"`, `wait: true`, and tags. Agent-authored memories use unique Markdown files; the adapter verifies completed indexing and exact full-content readback before returning `stored` with a reversible `id`. It does not create extraction sessions.
|
|
6
|
+
|
|
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. The error includes the requested URI because remote content may remain; inspect it before retrying. Existing memories remain readable, and downgrading does not remove files written by this adapter.
|
|
6
8
|
|
|
7
9
|
## Use
|
|
8
10
|
|
|
@@ -18,10 +20,12 @@ providers:
|
|
|
18
20
|
|
|
19
21
|
This is a **Memory Spaces child module**, not a top-level Source or a complete Strategy. It registers through `dsh-mnemon-source-memory-spaces/provider-sdk`; each parent Source owns its child Fibers, connection settings and lifetime. Credentials stay on the Host.
|
|
20
22
|
|
|
21
|
-
[Provider setup and capability matrix](https://github.com/omdsh-dev/dsh-mnemon/blob/
|
|
23
|
+
[Provider setup and capability matrix](https://github.com/omdsh-dev/dsh-mnemon/blob/main/docs/en/guides/memory-providers.md) · [中文指南](https://github.com/omdsh-dev/dsh-mnemon/blob/main/docs/zh-CN/guides/memory-providers.md)
|
|
22
24
|
|
|
23
25
|
## Develop independently
|
|
24
26
|
|
|
25
27
|
From a source checkout with the declared dependencies installed, run `pnpm verify`. Tests, build and public exports belong to this package, without importing another package's controllers or repository configuration. Use the Source's public `/testing` fixtures for child registration and driver conformance; live service tests require a separately authorized environment.
|
|
26
28
|
|
|
27
|
-
|
|
29
|
+
To test a disposable local OpenViking service (never a personal store), run `MNEMON_OPENVIKING_TEST_ENDPOINT=http://127.0.0.1:1933 pnpm exec vitest run tests/integration.spec.ts`. Supply `MNEMON_OPENVIKING_TEST_API_KEY` when the service requires authentication. It creates one synthetic canary in the default user's namespace, reads/searches/browses it, and deletes its exact URI. Ordinary verification skips this optional integration test. On v0.4.20, UI discovery additionally requires an explicit account and an account-admin key; ROOT keys cannot access tenant data.
|
|
30
|
+
|
|
31
|
+
[Plugin author guide](https://github.com/omdsh-dev/dsh-mnemon/blob/main/docs/en/development/extensions.md)
|
|
@@ -10,7 +10,7 @@ const descriptor = {
|
|
|
10
10
|
},
|
|
11
11
|
"kind": "remote",
|
|
12
12
|
"workspaceBinding": "provider-global",
|
|
13
|
-
"summary": "Filesystem-shaped shared memory with
|
|
13
|
+
"summary": "Filesystem-shaped shared memory with verified exact writes and semantic retrieval.",
|
|
14
14
|
"summaryI18nKey": "overview.providerSummary.openviking",
|
|
15
15
|
"origin": "third-party",
|
|
16
16
|
"capabilities": {
|
|
@@ -22,7 +22,7 @@ const descriptor = {
|
|
|
22
22
|
"remember": true,
|
|
23
23
|
"link": false,
|
|
24
24
|
"forget": true,
|
|
25
|
-
"writeMode": "
|
|
25
|
+
"writeMode": "exact",
|
|
26
26
|
"deletionMode": "hard"
|
|
27
27
|
},
|
|
28
28
|
"fields": [
|
|
@@ -44,7 +44,7 @@ const descriptor = {
|
|
|
44
44
|
"required": true,
|
|
45
45
|
"defaultValue": "viking://user/memories",
|
|
46
46
|
"placeholder": "viking://user/memories",
|
|
47
|
-
"pattern": "^viking://user(?:/[
|
|
47
|
+
"pattern": "^viking://user(?:/(?!\\.{1,2}/)[a-zA-Z0-9_.@-]+)?/memories$",
|
|
48
48
|
"normalize": "trim-trailing-slash",
|
|
49
49
|
"validationMessage": "OpenViking memory URI must be a viking://user/.../memories root",
|
|
50
50
|
"i18nKey": "overview.providerTargetUri"
|
package/lib/descriptor.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as descriptor } from "./descriptor-
|
|
1
|
+
import { t as descriptor } from "./descriptor-BGwdKZKn.js";
|
|
2
2
|
export { descriptor };
|
package/lib/index.d.ts
CHANGED
|
@@ -4,18 +4,14 @@ import { Insight, JsonValue, MemoryBody, MemoryGraphSnapshot, MemoryListRequest,
|
|
|
4
4
|
interface OpenVikingProviderOptions {
|
|
5
5
|
fetch?: typeof fetch;
|
|
6
6
|
requestTimeoutMs?: number;
|
|
7
|
-
settlementTimeoutMs?: number;
|
|
8
|
-
pollIntervalMs?: number;
|
|
9
7
|
}
|
|
10
8
|
declare class OpenVikingProvider implements MemoryProviderAdapter {
|
|
11
|
-
private readonly
|
|
9
|
+
private readonly memorySpaces;
|
|
12
10
|
readonly id: "openviking";
|
|
13
11
|
readonly scoreSemantics: import("dsh-mnemon-source-memory-spaces/provider-sdk").ProviderScoreSemantics;
|
|
14
12
|
private readonly requestFetch;
|
|
15
13
|
private readonly requestTimeoutMs;
|
|
16
|
-
|
|
17
|
-
private readonly pollIntervalMs;
|
|
18
|
-
constructor(memoryBodies: MemorySpaceAuthority, options?: OpenVikingProviderOptions);
|
|
14
|
+
constructor(memorySpaces: MemorySpaceAuthority, options?: OpenVikingProviderOptions);
|
|
19
15
|
discover(connection: MemoryProviderConnection, signal?: AbortSignal): Promise<ProviderMemorySpace[]>;
|
|
20
16
|
status(body: MemoryBody, signal?: AbortSignal): Promise<ProviderBodyStatus>;
|
|
21
17
|
search(body: MemoryBody, request: SearchRequest, signal?: AbortSignal): Promise<ProviderSearchResult>;
|
|
@@ -24,7 +20,8 @@ declare class OpenVikingProvider implements MemoryProviderAdapter {
|
|
|
24
20
|
remember(body: MemoryBody, request: RememberRequest, signal?: AbortSignal): Promise<JsonValue>;
|
|
25
21
|
forget(body: MemoryBody, id: string, signal?: AbortSignal): Promise<JsonValue>;
|
|
26
22
|
private connection;
|
|
27
|
-
private
|
|
23
|
+
private memoryRoot;
|
|
24
|
+
private readContent;
|
|
28
25
|
private request;
|
|
29
26
|
private requestConnection;
|
|
30
27
|
}
|
package/lib/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as descriptor } from "./descriptor-
|
|
1
|
+
import { t as descriptor } from "./descriptor-BGwdKZKn.js";
|
|
2
2
|
import { MEMORY_SPACE_PROVIDER_API_VERSION, NORMALIZED_RELEVANCE_SCORE, defineMemorySpaceProvider, defineMemorySpaceProviderDefinition } from "dsh-mnemon-source-memory-spaces/provider-sdk";
|
|
3
3
|
import { randomUUID } from "node:crypto";
|
|
4
4
|
//#region src/driver.ts
|
|
@@ -11,18 +11,31 @@ function string(value) {
|
|
|
11
11
|
function number(value) {
|
|
12
12
|
return typeof value === "number" && Number.isFinite(value) ? value : void 0;
|
|
13
13
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
14
|
+
const MEMORY_FOLDERS = {
|
|
15
|
+
preference: "preferences",
|
|
16
|
+
insight: "experiences",
|
|
17
|
+
decision: "experiences",
|
|
18
|
+
context: "events",
|
|
19
|
+
fact: "entities",
|
|
20
|
+
general: "entities"
|
|
21
|
+
};
|
|
22
|
+
function memoryUri(root, category, content) {
|
|
23
|
+
const folder = Object.hasOwn(MEMORY_FOLDERS, category) ? MEMORY_FOLDERS[category] : "entities";
|
|
24
|
+
const firstLine = content.split("\n").find((line) => line.trim().length > 0) ?? "memory";
|
|
25
|
+
const slug = Array.from(firstLine.replace(/^#+\s*/u, "").replace(/[^\p{L}\p{N}]+/gu, "-").replace(/^-+|-+$/gu, "")).slice(0, 48).join("").toLowerCase() || "memory";
|
|
26
|
+
return `${root}/${folder}/${(/* @__PURE__ */ new Date()).toISOString().replace(/[-:T]/gu, "").slice(0, 14)}-${slug}-${randomUUID()}.md`;
|
|
27
|
+
}
|
|
28
|
+
function safeUser(user) {
|
|
29
|
+
return /^[a-zA-Z0-9_.@-]+$/u.test(user) && user !== "." && user !== ".." && (user.match(/@/gu)?.length ?? 0) <= 1;
|
|
30
|
+
}
|
|
31
|
+
function isMemoryFile(uri, root) {
|
|
32
|
+
if (!uri.startsWith(`${root}/`) || !uri.endsWith(".md") || /[%?#\\\u0000-\u001f\u007f]/u.test(uri)) return false;
|
|
33
|
+
return uri.slice(root.length + 1).split("/").every((part) => part !== "" && !part.startsWith(".") && part.trim() === part);
|
|
34
|
+
}
|
|
35
|
+
function queueFailed(value) {
|
|
36
|
+
return Object.values(object(value) ?? {}).some((entry) => {
|
|
37
|
+
const queue = object(entry);
|
|
38
|
+
return (number(queue?.error_count) ?? 0) > 0 || Array.isArray(queue?.errors) && queue.errors.length > 0;
|
|
26
39
|
});
|
|
27
40
|
}
|
|
28
41
|
function categoryFromUri(uri) {
|
|
@@ -30,19 +43,15 @@ function categoryFromUri(uri) {
|
|
|
30
43
|
return (uri.includes(marker) ? uri.slice(uri.indexOf(marker) + 10) : "").split("/")[0]?.replace(/\.md$/u, "") || "general";
|
|
31
44
|
}
|
|
32
45
|
var OpenVikingProvider = class {
|
|
33
|
-
|
|
46
|
+
memorySpaces;
|
|
34
47
|
id = "openviking";
|
|
35
48
|
scoreSemantics = NORMALIZED_RELEVANCE_SCORE;
|
|
36
49
|
requestFetch;
|
|
37
50
|
requestTimeoutMs;
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
constructor(memoryBodies, options = {}) {
|
|
41
|
-
this.memoryBodies = memoryBodies;
|
|
51
|
+
constructor(memorySpaces, options = {}) {
|
|
52
|
+
this.memorySpaces = memorySpaces;
|
|
42
53
|
this.requestFetch = options.fetch ?? globalThis.fetch;
|
|
43
54
|
this.requestTimeoutMs = options.requestTimeoutMs ?? 15e3;
|
|
44
|
-
this.settlementTimeoutMs = options.settlementTimeoutMs ?? 12e4;
|
|
45
|
-
this.pollIntervalMs = options.pollIntervalMs ?? 750;
|
|
46
55
|
}
|
|
47
56
|
async discover(connection, signal) {
|
|
48
57
|
let account = String(connection.account ?? "").trim();
|
|
@@ -62,13 +71,13 @@ var OpenVikingProvider = class {
|
|
|
62
71
|
return (Array.isArray(users) ? users : []).flatMap((value) => {
|
|
63
72
|
const item = object(value);
|
|
64
73
|
const user = string(item?.user_id) ?? string(item?.id) ?? string(item?.name);
|
|
65
|
-
if (user === void 0) return [];
|
|
74
|
+
if (user === void 0 || !safeUser(user)) return [];
|
|
66
75
|
return [{
|
|
67
76
|
externalId: `${account}:${user}`,
|
|
68
77
|
name: string(item?.display_name) ?? string(item?.name) ?? user,
|
|
69
78
|
description: string(item?.description) ?? string(item?.role) ?? `OpenViking memory namespace for ${user}`,
|
|
70
79
|
connection: {
|
|
71
|
-
targetUri:
|
|
80
|
+
targetUri: `viking://user/${user}/memories`,
|
|
72
81
|
user,
|
|
73
82
|
actorPeerId: "dsh"
|
|
74
83
|
}
|
|
@@ -90,20 +99,20 @@ var OpenVikingProvider = class {
|
|
|
90
99
|
}
|
|
91
100
|
}
|
|
92
101
|
async search(body, request, signal) {
|
|
93
|
-
const
|
|
102
|
+
const memoryRoot = await this.memoryRoot(body, signal);
|
|
94
103
|
const root = object(await this.request(body, "/api/v1/search/find", {
|
|
95
104
|
method: "POST",
|
|
96
105
|
body: JSON.stringify({
|
|
97
106
|
query: request.query,
|
|
98
|
-
target_uri:
|
|
107
|
+
target_uri: memoryRoot,
|
|
99
108
|
context_type: ["memory"],
|
|
100
109
|
limit: request.limit
|
|
101
110
|
})
|
|
102
111
|
}, { signal }));
|
|
103
|
-
|
|
112
|
+
const matches = (Array.isArray(root?.memories) ? root.memories : []).flatMap((value) => {
|
|
104
113
|
const item = object(value);
|
|
105
114
|
const uri = string(item?.uri);
|
|
106
|
-
if (uri === void 0) return [];
|
|
115
|
+
if (uri === void 0 || !isMemoryFile(uri, memoryRoot)) return [];
|
|
107
116
|
const score = number(item?.score);
|
|
108
117
|
return [{
|
|
109
118
|
id: uri,
|
|
@@ -113,7 +122,11 @@ var OpenVikingProvider = class {
|
|
|
113
122
|
source: "external",
|
|
114
123
|
...score === void 0 ? {} : { score }
|
|
115
124
|
}];
|
|
116
|
-
})
|
|
125
|
+
}).slice(0, request.limit);
|
|
126
|
+
return { results: await Promise.all(matches.map(async (item) => ({
|
|
127
|
+
...item,
|
|
128
|
+
content: await this.readContent(body, item.id, signal)
|
|
129
|
+
}))) };
|
|
117
130
|
}
|
|
118
131
|
async graph(body, signal) {
|
|
119
132
|
return {
|
|
@@ -126,9 +139,9 @@ var OpenVikingProvider = class {
|
|
|
126
139
|
};
|
|
127
140
|
}
|
|
128
141
|
async list(body, request, signal) {
|
|
129
|
-
const
|
|
142
|
+
const memoryRoot = await this.memoryRoot(body, signal);
|
|
130
143
|
const query = new URLSearchParams({
|
|
131
|
-
uri:
|
|
144
|
+
uri: memoryRoot,
|
|
132
145
|
recursive: "true",
|
|
133
146
|
output: "original"
|
|
134
147
|
});
|
|
@@ -138,20 +151,13 @@ var OpenVikingProvider = class {
|
|
|
138
151
|
const files = entries.flatMap((value) => {
|
|
139
152
|
const item = object(value);
|
|
140
153
|
const uri = string(item?.uri);
|
|
141
|
-
|
|
142
|
-
return item === void 0 || uri === void 0 || item.isDir === true || filename?.startsWith(".") === true || !uri.endsWith(".md") ? [] : [{
|
|
154
|
+
return item === void 0 || uri === void 0 || item.isDir === true || !isMemoryFile(uri, memoryRoot) ? [] : [{
|
|
143
155
|
item,
|
|
144
156
|
uri
|
|
145
157
|
}];
|
|
146
158
|
}).slice(0, limit);
|
|
147
159
|
return Promise.all(files.map(async ({ item, uri }) => {
|
|
148
|
-
|
|
149
|
-
if (content === "") try {
|
|
150
|
-
const read = await this.request(body, `/api/v1/content/abstract?uri=${encodeURIComponent(uri)}`, {}, { signal });
|
|
151
|
-
content = string(read) ?? string(object(read)?.content) ?? string(object(read)?.abstract) ?? uri;
|
|
152
|
-
} catch {
|
|
153
|
-
content = uri;
|
|
154
|
-
}
|
|
160
|
+
const content = await this.readContent(body, uri, signal);
|
|
155
161
|
const createdAt = string(item.modTime);
|
|
156
162
|
return {
|
|
157
163
|
id: uri,
|
|
@@ -164,76 +170,63 @@ var OpenVikingProvider = class {
|
|
|
164
170
|
}));
|
|
165
171
|
}
|
|
166
172
|
async remember(body, request, signal) {
|
|
167
|
-
const
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
sessionId
|
|
193
|
-
};
|
|
194
|
-
const task = await this.settleTask(body, taskId, signal);
|
|
195
|
-
if (task === void 0) return {
|
|
196
|
-
action: "queued",
|
|
197
|
-
provider: "openviking",
|
|
198
|
-
summary: "OpenViking accepted the session and is extracting durable memories asynchronously.",
|
|
199
|
-
status: "pending",
|
|
200
|
-
taskId,
|
|
201
|
-
sessionId,
|
|
202
|
-
...archiveUri === void 0 ? {} : { archiveUri }
|
|
203
|
-
};
|
|
204
|
-
const extracted = object(object(task.result)?.memories_extracted) ?? {};
|
|
205
|
-
const total = Object.values(extracted).reduce((sum, value) => sum + (number(value) ?? 0), 0);
|
|
173
|
+
const root = await this.memoryRoot(body, signal);
|
|
174
|
+
const category = string(request.category) ?? "general";
|
|
175
|
+
const uri = memoryUri(root, category, request.content);
|
|
176
|
+
const tags = ["source=mnemon", `category=${category}`];
|
|
177
|
+
const importance = number(request.importance);
|
|
178
|
+
if (importance !== void 0) tags.push(`importance=${importance}`);
|
|
179
|
+
const writtenBytes = Buffer.byteLength(request.content, "utf8");
|
|
180
|
+
try {
|
|
181
|
+
const written = object(await this.request(body, "/api/v1/content/write", {
|
|
182
|
+
method: "POST",
|
|
183
|
+
body: JSON.stringify({
|
|
184
|
+
uri,
|
|
185
|
+
content: request.content,
|
|
186
|
+
mode: "create",
|
|
187
|
+
wait: true,
|
|
188
|
+
timeout: this.requestTimeoutMs / 1e3,
|
|
189
|
+
tags
|
|
190
|
+
})
|
|
191
|
+
}, { signal }));
|
|
192
|
+
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");
|
|
193
|
+
if (await this.readContent(body, uri, signal) !== request.content) throw new Error("stored content does not match the requested text");
|
|
194
|
+
signal?.throwIfAborted();
|
|
195
|
+
} catch (error) {
|
|
196
|
+
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 });
|
|
197
|
+
}
|
|
206
198
|
return {
|
|
207
|
-
action:
|
|
199
|
+
action: "stored",
|
|
208
200
|
provider: "openviking",
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
201
|
+
id: uri,
|
|
202
|
+
uri,
|
|
203
|
+
externalUri: uri,
|
|
204
|
+
summary: `OpenViking stored the memory at ${uri} (category ${category}).`,
|
|
205
|
+
writtenBytes,
|
|
206
|
+
vectorStatus: "complete"
|
|
214
207
|
};
|
|
215
208
|
}
|
|
216
209
|
async forget(body, id, signal) {
|
|
217
|
-
const
|
|
210
|
+
const root = await this.memoryRoot(body, signal);
|
|
218
211
|
const uri = id.trim();
|
|
219
|
-
|
|
220
|
-
const filename = uri.slice(uri.lastIndexOf("/") + 1);
|
|
221
|
-
if (!uri.startsWith(`${root}/`) || !uri.endsWith(".md") || filename.startsWith(".")) throw new Error("OpenViking forget requires an exact non-generated .md memory URI inside this Memory Space");
|
|
212
|
+
if (!isMemoryFile(uri, root)) throw new Error("OpenViking forget requires an exact non-generated .md memory URI inside this Memory Space");
|
|
222
213
|
const query = new URLSearchParams({
|
|
223
214
|
uri,
|
|
224
215
|
recursive: "false"
|
|
225
216
|
});
|
|
226
217
|
const result = object(await this.request(body, `/api/v1/fs?${query}`, { method: "DELETE" }, { signal })) ?? {};
|
|
218
|
+
if (result.uri !== uri) throw new Error("OpenViking did not confirm deletion of the requested memory URI");
|
|
227
219
|
return {
|
|
228
220
|
action: "deleted",
|
|
229
221
|
provider: this.id,
|
|
230
|
-
|
|
222
|
+
id: uri,
|
|
223
|
+
uri,
|
|
231
224
|
...number(result.estimated_deleted_count) === void 0 ? {} : { estimatedDeletedCount: number(result.estimated_deleted_count) }
|
|
232
225
|
};
|
|
233
226
|
}
|
|
234
227
|
connection(body) {
|
|
235
228
|
if ((body.provider.typeId ?? body.provider.id) !== this.id) throw new Error(`OpenViking cannot serve provider ${body.provider.id}`);
|
|
236
|
-
const connection = this.
|
|
229
|
+
const connection = this.memorySpaces.providerConnection(body.id, body.provider.id);
|
|
237
230
|
return {
|
|
238
231
|
endpoint: String(connection.endpoint ?? ""),
|
|
239
232
|
targetUri: String(connection.targetUri ?? ""),
|
|
@@ -243,18 +236,21 @@ var OpenVikingProvider = class {
|
|
|
243
236
|
actorPeerId: String(connection.actorPeerId ?? "")
|
|
244
237
|
};
|
|
245
238
|
}
|
|
246
|
-
async
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
239
|
+
async memoryRoot(body, signal) {
|
|
240
|
+
signal?.throwIfAborted();
|
|
241
|
+
const connection = this.connection(body);
|
|
242
|
+
const root = connection.targetUri.replace(/\/+$/u, "");
|
|
243
|
+
const match = /^viking:\/\/user(?:\/([^/]+))?\/memories$/u.exec(root);
|
|
244
|
+
if (match === null || match[1] !== void 0 && !safeUser(match[1])) throw new Error("OpenViking memory URI must be a safe viking://user/<user>/memories root");
|
|
245
|
+
if (match[1] !== void 0) return root;
|
|
246
|
+
const user = connection.user?.trim() || string(object(await this.request(body, "/api/v1/system/status", {}, { signal }))?.user) || "";
|
|
247
|
+
if (!safeUser(user)) throw new Error("OpenViking could not resolve the memory owner; configure an explicit user memory URI");
|
|
248
|
+
return `viking://user/${user}/memories`;
|
|
249
|
+
}
|
|
250
|
+
async readContent(body, uri, signal) {
|
|
251
|
+
const result = await this.request(body, `/api/v1/content/read?${new URLSearchParams({ uri })}`, {}, { signal });
|
|
252
|
+
if (typeof result !== "string") throw new Error("OpenViking content read did not return text");
|
|
253
|
+
return result;
|
|
258
254
|
}
|
|
259
255
|
async request(body, path, init = {}, options = {}) {
|
|
260
256
|
const connection = this.connection(body);
|
|
@@ -302,7 +298,7 @@ const definition = defineMemorySpaceProviderDefinition({
|
|
|
302
298
|
kind: "provider",
|
|
303
299
|
typeId: descriptor.id,
|
|
304
300
|
packageName: "dsh-mnemon-provider-openviking",
|
|
305
|
-
version: "0.5.
|
|
301
|
+
version: "0.5.5",
|
|
306
302
|
label: descriptor.label,
|
|
307
303
|
icon: descriptor.icon,
|
|
308
304
|
summary: descriptor.summary,
|
|
@@ -315,10 +311,7 @@ const definition = defineMemorySpaceProviderDefinition({
|
|
|
315
311
|
secrets: descriptor.fields.filter((field) => field.input === "secret").map((field) => field.key),
|
|
316
312
|
scoreSemantics: "normalized-relevance"
|
|
317
313
|
},
|
|
318
|
-
create: (context) => new OpenVikingProvider(context.memoryBodies, {
|
|
319
|
-
requestTimeoutMs: context.config.timeoutMs,
|
|
320
|
-
settlementTimeoutMs: context.config.timeoutMs
|
|
321
|
-
})
|
|
314
|
+
create: (context) => new OpenVikingProvider(context.memorySpaces ?? context.memoryBodies, { requestTimeoutMs: context.config.timeoutMs })
|
|
322
315
|
});
|
|
323
316
|
var src_default = defineMemorySpaceProvider({
|
|
324
317
|
id: descriptor.id,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-mnemon-provider-openviking",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.5",
|
|
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.
|
|
37
|
+
"dsh-mnemon-source-memory-spaces": "^0.5.8",
|
|
38
38
|
"tsdown": "^0.22.0",
|
|
39
39
|
"typescript": "^5.9.0",
|
|
40
40
|
"vitest": "^3.2.0"
|