@xdarkicex/openclaw-memory-libravdb 1.9.10-beta.16 → 1.9.10-beta.17
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.js +34 -7
- package/dist/index.js +22447 -36208
- package/dist/libravdb-client.d.ts +3 -1
- package/dist/libravdb-client.js +9 -0
- package/dist/tools/memory-recall.d.ts +48 -0
- package/dist/tools/memory-recall.js +89 -0
- 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, 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,8 @@ 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>;
|
|
68
70
|
close(): void;
|
|
69
71
|
}
|
|
70
72
|
export declare function loadSecretFromEnv(logger?: LoggerLike): string | undefined;
|
package/dist/libravdb-client.js
CHANGED
|
@@ -337,6 +337,15 @@ 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
|
+
}
|
|
340
349
|
close() {
|
|
341
350
|
this.closed = true;
|
|
342
351
|
}
|
|
@@ -141,4 +141,52 @@ 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
|
+
};
|
|
144
192
|
export {};
|
|
@@ -422,3 +422,92 @@ 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: "Read what you know about a speaker. Returns the full prose card with metadata. " +
|
|
490
|
+
"Use this when you need to remember who someone is, or before making a claim about them " +
|
|
491
|
+
"that might be wrong. Cross-reference with memory_search for deeper context.",
|
|
492
|
+
parameters: GET_USER_CARD_SCHEMA,
|
|
493
|
+
execute: async (_toolCallId, rawParams) => {
|
|
494
|
+
const params = asParams(rawParams);
|
|
495
|
+
const userId = readStr(params, "user_id");
|
|
496
|
+
if (!userId)
|
|
497
|
+
throw new Error("get_user_card requires user_id");
|
|
498
|
+
try {
|
|
499
|
+
const client = await getClient();
|
|
500
|
+
const resp = await client.getUserCard({ userId });
|
|
501
|
+
return jsonResult({
|
|
502
|
+
card: resp.cardJson || null,
|
|
503
|
+
updatedAt: resp.updatedAt ? Number(resp.updatedAt) : undefined,
|
|
504
|
+
version: resp.version || undefined,
|
|
505
|
+
});
|
|
506
|
+
}
|
|
507
|
+
catch (error) {
|
|
508
|
+
logger.warn?.(`get_user_card failed: ${formatError(error)}`);
|
|
509
|
+
return jsonResult({ error: formatError(error) });
|
|
510
|
+
}
|
|
511
|
+
},
|
|
512
|
+
};
|
|
513
|
+
}
|
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.17",
|
|
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
|
}
|