@xdarkicex/openclaw-memory-libravdb 1.9.10-beta.2 → 1.9.10-beta.21
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/dist/context-engine.d.ts +5 -0
- package/dist/context-engine.js +180 -11
- package/dist/index.js +22542 -36060
- package/dist/libravdb-client.d.ts +4 -1
- package/dist/libravdb-client.js +13 -0
- package/dist/tools/memory-recall.d.ts +69 -0
- package/dist/tools/memory-recall.js +146 -0
- package/openclaw.plugin.json +10 -3
- package/package.json +3 -8
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Interceptor } from "@connectrpc/connect";
|
|
2
2
|
import type { PartialMessage } from "@bufbuild/protobuf";
|
|
3
3
|
import type { LoggerLike } from "./types.js";
|
|
4
|
-
import type { AfterTurnKernelRequest, AfterTurnKernelResponse, BeforeTurnKernelRequest, BeforeTurnKernelResponse, AssembleContextInternalRequest, AssembleContextInternalResponse, BootstrapSessionKernelRequest, BootstrapSessionKernelResponse, CompactSessionRequest, CompactSessionResponse, DeleteAuthoredDocumentRequest, DeleteAuthoredDocumentResponse, DreamPromotionResponse, ExportMemoryRequest, ExportMemoryResponse, FlushNamespaceRequest, FlushNamespaceResponse, FlushRequest, FlushResponse, HealthRequest, HealthResponse, IngestMarkdownDocumentRequest, IngestMarkdownDocumentResponse, IngestMessageKernelRequest, IngestMessageKernelResponse, ListCollectionRequest, ListCollectionResponse, ListLifecycleJournalRequest, ListLifecycleJournalResponse, MarkMemorySupersededRequest, MarkMemorySupersededResponse, MemoryStatusRequest, MemoryStatusResponse, PromoteDreamEntriesRequest, RankCandidatesRequest, RankCandidatesResponse, RebuildIndexRequest, RebuildIndexResponse, ReindexAuthoredDocumentRequest, ReindexAuthoredDocumentResponse, SearchTextCollectionsRequest, SearchTextRequest, SearchTextResponse, SessionLifecycleHintRequest, SessionLifecycleHintResponse, SummarizeMessagesRequest, SummarizeMessagesResponse, ExpandSummaryRequest, ExpandSummaryResponse } from "@xdarkicex/libravdb-contracts";
|
|
4
|
+
import type { AfterTurnKernelRequest, AfterTurnKernelResponse, BeforeTurnKernelRequest, BeforeTurnKernelResponse, AssembleContextInternalRequest, AssembleContextInternalResponse, BootstrapSessionKernelRequest, BootstrapSessionKernelResponse, CompactSessionRequest, CompactSessionResponse, DeleteAuthoredDocumentRequest, DeleteAuthoredDocumentResponse, DreamPromotionResponse, ExportMemoryRequest, ExportMemoryResponse, FlushNamespaceRequest, FlushNamespaceResponse, FlushRequest, FlushResponse, HealthRequest, HealthResponse, IngestMarkdownDocumentRequest, IngestMarkdownDocumentResponse, IngestMessageKernelRequest, IngestMessageKernelResponse, ListByMetaRequest, ListByMetaResponse, ListCollectionRequest, ListCollectionResponse, ListLifecycleJournalRequest, ListLifecycleJournalResponse, MarkMemorySupersededRequest, MarkMemorySupersededResponse, MemoryStatusRequest, MemoryStatusResponse, PromoteDreamEntriesRequest, RankCandidatesRequest, RankCandidatesResponse, RebuildIndexRequest, RebuildIndexResponse, ReindexAuthoredDocumentRequest, ReindexAuthoredDocumentResponse, SearchTextCollectionsRequest, SearchTextRequest, SearchTextResponse, SessionLifecycleHintRequest, SessionLifecycleHintResponse, SummarizeMessagesRequest, SummarizeMessagesResponse, ExpandSummaryRequest, ExpandSummaryResponse, UpsertUserCardRequest, UpsertUserCardResponse, GetUserCardRequest, GetUserCardResponse } from "@xdarkicex/libravdb-contracts";
|
|
5
5
|
export interface LibravDBClientOptions {
|
|
6
6
|
endpoint?: string;
|
|
7
7
|
secret?: string;
|
|
@@ -65,6 +65,9 @@ export declare class LibravDBClient {
|
|
|
65
65
|
summarizeMessages(req: PartialMessage<SummarizeMessagesRequest>): Promise<SummarizeMessagesResponse>;
|
|
66
66
|
expandSummary(req: PartialMessage<ExpandSummaryRequest>): Promise<ExpandSummaryResponse>;
|
|
67
67
|
rankCandidates(req: PartialMessage<RankCandidatesRequest>): Promise<RankCandidatesResponse>;
|
|
68
|
+
upsertUserCard(req: PartialMessage<UpsertUserCardRequest>): Promise<UpsertUserCardResponse>;
|
|
69
|
+
getUserCard(req: PartialMessage<GetUserCardRequest>): Promise<GetUserCardResponse>;
|
|
70
|
+
listByMeta(req: PartialMessage<ListByMetaRequest>): Promise<ListByMetaResponse>;
|
|
68
71
|
close(): void;
|
|
69
72
|
}
|
|
70
73
|
export declare function loadSecretFromEnv(logger?: LoggerLike): string | undefined;
|
package/dist/libravdb-client.js
CHANGED
|
@@ -337,6 +337,19 @@ export class LibravDBClient {
|
|
|
337
337
|
this.guardOpen();
|
|
338
338
|
return this.client.rankCandidates(req);
|
|
339
339
|
}
|
|
340
|
+
// ── User Card ────────────────────────────────────────────────────
|
|
341
|
+
async upsertUserCard(req) {
|
|
342
|
+
this.guardOpen();
|
|
343
|
+
return this.client.upsertUserCard(req);
|
|
344
|
+
}
|
|
345
|
+
async getUserCard(req) {
|
|
346
|
+
this.guardOpen();
|
|
347
|
+
return this.client.getUserCard(req);
|
|
348
|
+
}
|
|
349
|
+
async listByMeta(req) {
|
|
350
|
+
this.guardOpen();
|
|
351
|
+
return this.client.listByMeta(req);
|
|
352
|
+
}
|
|
340
353
|
close() {
|
|
341
354
|
this.closed = true;
|
|
342
355
|
}
|
|
@@ -141,4 +141,73 @@ export declare function createMemoryGrepTool(getClient: ClientGetter, getSession
|
|
|
141
141
|
execute: (_toolCallId: string, rawParams: unknown) => Promise<ToolResult<MemoryGrepDetails>>;
|
|
142
142
|
};
|
|
143
143
|
export declare function memoryRecallPromptSection(): string[];
|
|
144
|
+
type UpdateUserCardDetails = {
|
|
145
|
+
ok: boolean;
|
|
146
|
+
error?: string;
|
|
147
|
+
};
|
|
148
|
+
type GetUserCardDetails = {
|
|
149
|
+
card?: string | null;
|
|
150
|
+
updatedAt?: number;
|
|
151
|
+
version?: number;
|
|
152
|
+
error?: string;
|
|
153
|
+
};
|
|
154
|
+
export declare function createUpdateUserCardTool(getClient: ClientGetter, logger?: LoggerLike): {
|
|
155
|
+
name: string;
|
|
156
|
+
label: string;
|
|
157
|
+
description: string;
|
|
158
|
+
parameters: {
|
|
159
|
+
readonly type: "object";
|
|
160
|
+
readonly additionalProperties: false;
|
|
161
|
+
readonly properties: {
|
|
162
|
+
readonly user_id: {
|
|
163
|
+
readonly type: "string";
|
|
164
|
+
readonly description: "The user ID to update the card for.";
|
|
165
|
+
};
|
|
166
|
+
readonly card: {
|
|
167
|
+
readonly type: "string";
|
|
168
|
+
readonly description: "Prose description of what you've learned about this person. Write like describing a friend. Include identity, values, history, communication style, triggers, and what matters to them. Merge with previous understanding — don't replace entirely unless the user explicitly contradicts the record. Max ~1200 characters.";
|
|
169
|
+
};
|
|
170
|
+
};
|
|
171
|
+
readonly required: readonly ["user_id", "card"];
|
|
172
|
+
};
|
|
173
|
+
execute: (_toolCallId: string, rawParams: unknown) => Promise<ToolResult<UpdateUserCardDetails>>;
|
|
174
|
+
};
|
|
175
|
+
export declare function createGetUserCardTool(getClient: ClientGetter, logger?: LoggerLike): {
|
|
176
|
+
name: string;
|
|
177
|
+
label: string;
|
|
178
|
+
description: string;
|
|
179
|
+
parameters: {
|
|
180
|
+
readonly type: "object";
|
|
181
|
+
readonly additionalProperties: false;
|
|
182
|
+
readonly properties: {
|
|
183
|
+
readonly user_id: {
|
|
184
|
+
readonly type: "string";
|
|
185
|
+
readonly description: "The user ID to retrieve the card for.";
|
|
186
|
+
};
|
|
187
|
+
};
|
|
188
|
+
readonly required: readonly ["user_id"];
|
|
189
|
+
};
|
|
190
|
+
execute: (_toolCallId: string, rawParams: unknown) => Promise<ToolResult<GetUserCardDetails>>;
|
|
191
|
+
};
|
|
192
|
+
type ListUserCardsDetails = {
|
|
193
|
+
users: Array<{
|
|
194
|
+
user_id: string;
|
|
195
|
+
preview: string;
|
|
196
|
+
updated_at?: number;
|
|
197
|
+
version?: number;
|
|
198
|
+
}>;
|
|
199
|
+
total: number;
|
|
200
|
+
error?: string;
|
|
201
|
+
};
|
|
202
|
+
export declare function createListUserCardsTool(getClient: ClientGetter, logger?: LoggerLike): {
|
|
203
|
+
name: string;
|
|
204
|
+
label: string;
|
|
205
|
+
description: string;
|
|
206
|
+
parameters: {
|
|
207
|
+
readonly type: "object";
|
|
208
|
+
readonly additionalProperties: false;
|
|
209
|
+
readonly properties: {};
|
|
210
|
+
};
|
|
211
|
+
execute: (_toolCallId: string, _rawParams: unknown) => Promise<ToolResult<ListUserCardsDetails>>;
|
|
212
|
+
};
|
|
144
213
|
export {};
|
|
@@ -422,3 +422,149 @@ const RECALL_GUIDANCE = [
|
|
|
422
422
|
export function memoryRecallPromptSection() {
|
|
423
423
|
return [...RECALL_GUIDANCE];
|
|
424
424
|
}
|
|
425
|
+
// ── User Card tool schemas ──
|
|
426
|
+
const UPDATE_USER_CARD_SCHEMA = {
|
|
427
|
+
type: "object",
|
|
428
|
+
additionalProperties: false,
|
|
429
|
+
properties: {
|
|
430
|
+
user_id: {
|
|
431
|
+
type: "string",
|
|
432
|
+
description: "The user ID to update the card for.",
|
|
433
|
+
},
|
|
434
|
+
card: {
|
|
435
|
+
type: "string",
|
|
436
|
+
description: "Prose description of what you've learned about this person. Write like describing a friend. Include identity, values, history, communication style, triggers, and what matters to them. Merge with previous understanding — don't replace entirely unless the user explicitly contradicts the record. Max ~1200 characters.",
|
|
437
|
+
},
|
|
438
|
+
},
|
|
439
|
+
required: ["user_id", "card"],
|
|
440
|
+
};
|
|
441
|
+
const GET_USER_CARD_SCHEMA = {
|
|
442
|
+
type: "object",
|
|
443
|
+
additionalProperties: false,
|
|
444
|
+
properties: {
|
|
445
|
+
user_id: {
|
|
446
|
+
type: "string",
|
|
447
|
+
description: "The user ID to retrieve the card for.",
|
|
448
|
+
},
|
|
449
|
+
},
|
|
450
|
+
required: ["user_id"],
|
|
451
|
+
};
|
|
452
|
+
// ── User Card tool factories ──
|
|
453
|
+
export function createUpdateUserCardTool(getClient, logger = console) {
|
|
454
|
+
return {
|
|
455
|
+
name: "update_user_card",
|
|
456
|
+
label: "Update User Card",
|
|
457
|
+
description: "Write what you've learned about a speaker. Prose format — write like you're describing a friend. " +
|
|
458
|
+
"Include identity, values, history, communication style, triggers, and what matters to them. " +
|
|
459
|
+
"This is the canonical record of who they are. If something changes, update it. " +
|
|
460
|
+
"Merge with previous understanding, don't replace entirely unless the user explicitly contradicts the record.",
|
|
461
|
+
parameters: UPDATE_USER_CARD_SCHEMA,
|
|
462
|
+
execute: async (_toolCallId, rawParams) => {
|
|
463
|
+
const params = asParams(rawParams);
|
|
464
|
+
const userId = readStr(params, "user_id");
|
|
465
|
+
const card = readStr(params, "card");
|
|
466
|
+
if (!userId)
|
|
467
|
+
throw new Error("update_user_card requires user_id");
|
|
468
|
+
if (!card)
|
|
469
|
+
throw new Error("update_user_card requires card");
|
|
470
|
+
try {
|
|
471
|
+
const client = await getClient();
|
|
472
|
+
const resp = await client.upsertUserCard({
|
|
473
|
+
userId,
|
|
474
|
+
cardJson: JSON.stringify({ card, updatedAt: Date.now() }),
|
|
475
|
+
});
|
|
476
|
+
return jsonResult({ ok: resp.ok });
|
|
477
|
+
}
|
|
478
|
+
catch (error) {
|
|
479
|
+
logger.warn?.(`update_user_card failed: ${formatError(error)}`);
|
|
480
|
+
return jsonResult({ error: formatError(error), ok: false });
|
|
481
|
+
}
|
|
482
|
+
},
|
|
483
|
+
};
|
|
484
|
+
}
|
|
485
|
+
export function createGetUserCardTool(getClient, logger = console) {
|
|
486
|
+
return {
|
|
487
|
+
name: "get_user_card",
|
|
488
|
+
label: "Get User Card",
|
|
489
|
+
description: "PRIMARY identity lookup. Call this FIRST whenever someone asks about a person " +
|
|
490
|
+
"('who is X', 'tell me about X', 'what do you know about X'). " +
|
|
491
|
+
"Returns the full prose identity card with metadata. " +
|
|
492
|
+
"Only use memory_search AFTER get_user_card if the card lacks detail.",
|
|
493
|
+
parameters: GET_USER_CARD_SCHEMA,
|
|
494
|
+
execute: async (_toolCallId, rawParams) => {
|
|
495
|
+
const params = asParams(rawParams);
|
|
496
|
+
const userId = readStr(params, "user_id");
|
|
497
|
+
if (!userId)
|
|
498
|
+
throw new Error("get_user_card requires user_id");
|
|
499
|
+
try {
|
|
500
|
+
const client = await getClient();
|
|
501
|
+
const resp = await client.getUserCard({ userId });
|
|
502
|
+
return jsonResult({
|
|
503
|
+
card: resp.cardJson || null,
|
|
504
|
+
updatedAt: resp.updatedAt ? Number(resp.updatedAt) : undefined,
|
|
505
|
+
version: resp.version || undefined,
|
|
506
|
+
});
|
|
507
|
+
}
|
|
508
|
+
catch (error) {
|
|
509
|
+
logger.warn?.(`get_user_card failed: ${formatError(error)}`);
|
|
510
|
+
return jsonResult({ error: formatError(error) });
|
|
511
|
+
}
|
|
512
|
+
},
|
|
513
|
+
};
|
|
514
|
+
}
|
|
515
|
+
export function createListUserCardsTool(getClient, logger = console) {
|
|
516
|
+
return {
|
|
517
|
+
name: "list_user_cards",
|
|
518
|
+
label: "List User Cards",
|
|
519
|
+
description: "List every person you have a user card for. Returns user IDs and card previews. " +
|
|
520
|
+
"Use this FIRST when asked about multiple people, 'who do you know?', 'who is everyone?', " +
|
|
521
|
+
"or when you're unsure which people have cards. Then use get_user_card on specific IDs " +
|
|
522
|
+
"for full detail. Use memory_search only to supplement gaps.",
|
|
523
|
+
parameters: { type: "object", additionalProperties: false, properties: {} },
|
|
524
|
+
execute: async (_toolCallId, _rawParams) => {
|
|
525
|
+
try {
|
|
526
|
+
const client = await getClient();
|
|
527
|
+
const resp = await client.listByMeta({
|
|
528
|
+
collection: "",
|
|
529
|
+
key: "type",
|
|
530
|
+
value: "user_card",
|
|
531
|
+
});
|
|
532
|
+
const users = [];
|
|
533
|
+
for (const result of resp.results) {
|
|
534
|
+
let userId = "";
|
|
535
|
+
let preview = "";
|
|
536
|
+
let updatedAt;
|
|
537
|
+
let version;
|
|
538
|
+
if (result.metadataJson && result.metadataJson.length > 0) {
|
|
539
|
+
try {
|
|
540
|
+
const decoder = new TextDecoder();
|
|
541
|
+
const meta = JSON.parse(decoder.decode(result.metadataJson));
|
|
542
|
+
userId = typeof meta._user_id === "string" ? meta._user_id : "";
|
|
543
|
+
const cardJson = typeof meta.card_json === "string" ? meta.card_json : null;
|
|
544
|
+
if (cardJson) {
|
|
545
|
+
try {
|
|
546
|
+
preview = JSON.parse(cardJson).card ?? cardJson;
|
|
547
|
+
}
|
|
548
|
+
catch {
|
|
549
|
+
preview = cardJson;
|
|
550
|
+
}
|
|
551
|
+
preview = preview.slice(0, 200);
|
|
552
|
+
}
|
|
553
|
+
updatedAt = typeof meta.updated_at === "number" ? meta.updated_at : undefined;
|
|
554
|
+
version = typeof meta.version === "number" ? meta.version : undefined;
|
|
555
|
+
}
|
|
556
|
+
catch { /* best-effort metadata parse */ }
|
|
557
|
+
}
|
|
558
|
+
if (!userId)
|
|
559
|
+
continue;
|
|
560
|
+
users.push({ user_id: userId, preview, updated_at: updatedAt, version });
|
|
561
|
+
}
|
|
562
|
+
return jsonResult({ users, total: users.length });
|
|
563
|
+
}
|
|
564
|
+
catch (error) {
|
|
565
|
+
logger.warn?.(`list_user_cards failed: ${formatError(error)}`);
|
|
566
|
+
return jsonResult({ users: [], total: 0, error: formatError(error) });
|
|
567
|
+
}
|
|
568
|
+
},
|
|
569
|
+
};
|
|
570
|
+
}
|
package/openclaw.plugin.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"id": "libravdb-memory",
|
|
3
3
|
"name": "LibraVDB Memory",
|
|
4
|
-
"description": "
|
|
5
|
-
"version": "1.9.10-beta.
|
|
4
|
+
"description": "Cognitive memory engine — causal graph reasoning, predictive context, identity tracking, and hybrid vector recall with back-door adjustment scoring",
|
|
5
|
+
"version": "1.9.10-beta.21",
|
|
6
6
|
"kind": [
|
|
7
7
|
"memory",
|
|
8
8
|
"context-engine"
|
|
@@ -15,7 +15,10 @@
|
|
|
15
15
|
"memory_get",
|
|
16
16
|
"memory_describe",
|
|
17
17
|
"memory_expand",
|
|
18
|
-
"memory_grep"
|
|
18
|
+
"memory_grep",
|
|
19
|
+
"update_user_card",
|
|
20
|
+
"get_user_card",
|
|
21
|
+
"list_user_cards"
|
|
19
22
|
]
|
|
20
23
|
},
|
|
21
24
|
"activation": {
|
|
@@ -178,6 +181,10 @@
|
|
|
178
181
|
"beforeTurnEnabled": {
|
|
179
182
|
"type": "boolean"
|
|
180
183
|
},
|
|
184
|
+
"beforeTurnDebug": {
|
|
185
|
+
"type": "boolean",
|
|
186
|
+
"description": "Enable verbose BeforeTurnKernel diagnostic logging. Default: false"
|
|
187
|
+
},
|
|
181
188
|
"beforeTurnTimeoutMs": {
|
|
182
189
|
"type": "number"
|
|
183
190
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xdarkicex/openclaw-memory-libravdb",
|
|
3
|
-
"version": "1.9.10-beta.
|
|
3
|
+
"version": "1.9.10-beta.21",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
"build:daemon": "bash scripts/build-daemon.sh"
|
|
66
66
|
},
|
|
67
67
|
"devDependencies": {
|
|
68
|
-
"@bufbuild/protobuf": "1.
|
|
68
|
+
"@bufbuild/protobuf": "1.10.1",
|
|
69
69
|
"@grpc/grpc-js": "^1.14.3",
|
|
70
70
|
"@grpc/proto-loader": "^0.8.0",
|
|
71
71
|
"@openclaw/plugin-inspector": "0.3.7",
|
|
@@ -80,11 +80,6 @@
|
|
|
80
80
|
"dependencies": {
|
|
81
81
|
"@connectrpc/connect": "^1.7.0",
|
|
82
82
|
"@connectrpc/connect-node": "^1.7.0",
|
|
83
|
-
"@xdarkicex/libravdb-contracts": "^2.0.
|
|
84
|
-
},
|
|
85
|
-
"pnpm": {
|
|
86
|
-
"overrides": {
|
|
87
|
-
"undici": "8.3.0"
|
|
88
|
-
}
|
|
83
|
+
"@xdarkicex/libravdb-contracts": "^2.0.25"
|
|
89
84
|
}
|
|
90
85
|
}
|