@xdarkicex/openclaw-memory-libravdb 1.4.6 → 1.4.7

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.
Files changed (75) hide show
  1. package/HOOK.md +14 -0
  2. package/README.md +32 -2
  3. package/dist/cli.d.ts +39 -0
  4. package/dist/cli.js +208 -0
  5. package/dist/context-engine.d.ts +56 -0
  6. package/dist/context-engine.js +125 -0
  7. package/dist/dream-promotion.d.ts +47 -0
  8. package/dist/dream-promotion.js +363 -0
  9. package/dist/dream-routing.d.ts +6 -0
  10. package/dist/dream-routing.js +31 -0
  11. package/dist/durable-namespace.d.ts +6 -0
  12. package/dist/durable-namespace.js +24 -0
  13. package/dist/grpc-client.d.ts +23 -0
  14. package/dist/grpc-client.js +104 -0
  15. package/dist/index.d.ts +10 -0
  16. package/dist/index.js +40 -0
  17. package/dist/lifecycle-hooks.d.ts +4 -0
  18. package/dist/lifecycle-hooks.js +64 -0
  19. package/dist/markdown-hash.d.ts +3 -0
  20. package/dist/markdown-hash.js +82 -0
  21. package/dist/markdown-ingest.d.ts +43 -0
  22. package/dist/markdown-ingest.js +464 -0
  23. package/dist/memory-provider.d.ts +4 -0
  24. package/dist/memory-provider.js +13 -0
  25. package/dist/memory-runtime.d.ts +118 -0
  26. package/dist/memory-runtime.js +217 -0
  27. package/dist/plugin-runtime.d.ts +28 -0
  28. package/dist/plugin-runtime.js +127 -0
  29. package/dist/proto/intelligence_kernel/v1/kernel.proto +378 -0
  30. package/dist/recall-cache.d.ts +2 -0
  31. package/dist/recall-cache.js +30 -0
  32. package/dist/rpc-protobuf-codecs.d.ts +70 -0
  33. package/dist/rpc-protobuf-codecs.js +77 -0
  34. package/dist/rpc.d.ts +14 -0
  35. package/dist/rpc.js +121 -0
  36. package/dist/sidecar.d.ts +34 -0
  37. package/dist/sidecar.js +535 -0
  38. package/dist/types.d.ts +163 -0
  39. package/dist/types.js +1 -0
  40. package/docs/contributing.md +14 -13
  41. package/docs/install.md +7 -9
  42. package/docs/installation.md +23 -16
  43. package/docs/uninstall.md +1 -1
  44. package/index.js +2 -0
  45. package/openclaw.plugin.json +2 -2
  46. package/package.json +39 -16
  47. package/packaging/README.md +0 -71
  48. package/packaging/homebrew/libravdbd.rb.tmpl +0 -224
  49. package/packaging/launchd/com.xdarkicex.libravdbd.plist +0 -32
  50. package/packaging/systemd/libravdbd.service +0 -12
  51. package/src/cli.ts +0 -299
  52. package/src/comparison-experiments.ts +0 -128
  53. package/src/context-engine.ts +0 -1645
  54. package/src/continuity.ts +0 -93
  55. package/src/dream-promotion.ts +0 -492
  56. package/src/dream-routing.ts +0 -40
  57. package/src/durable-namespace.ts +0 -34
  58. package/src/index.ts +0 -47
  59. package/src/lifecycle-hooks.ts +0 -96
  60. package/src/markdown-hash.ts +0 -104
  61. package/src/markdown-ingest.ts +0 -627
  62. package/src/memory-provider.ts +0 -25
  63. package/src/memory-runtime.ts +0 -283
  64. package/src/openclaw-plugin-sdk.d.ts +0 -59
  65. package/src/plugin-runtime.ts +0 -119
  66. package/src/recall-cache.ts +0 -34
  67. package/src/recall-utils.ts +0 -131
  68. package/src/rpc.ts +0 -92
  69. package/src/scoring.ts +0 -632
  70. package/src/sidecar.ts +0 -583
  71. package/src/temporal.ts +0 -1031
  72. package/src/tokens.ts +0 -52
  73. package/src/types.ts +0 -278
  74. package/tsconfig.json +0 -20
  75. package/tsconfig.tests.json +0 -12
@@ -1,96 +0,0 @@
1
- import type { PluginRuntime } from "./plugin-runtime.js";
2
- import type { LoggerLike } from "./types.js";
3
-
4
- type AgentContext = {
5
- agentId?: string;
6
- sessionId?: string;
7
- sessionKey?: string;
8
- workspaceDir?: string;
9
- };
10
-
11
- type BeforeResetEvent = {
12
- sessionFile?: string;
13
- messages?: unknown[];
14
- reason?: string;
15
- };
16
-
17
- type SessionEndEvent = {
18
- sessionId?: string;
19
- sessionKey?: string;
20
- messageCount?: number;
21
- durationMs?: number;
22
- reason?: string;
23
- sessionFile?: string;
24
- transcriptArchived?: boolean;
25
- nextSessionId?: string;
26
- nextSessionKey?: string;
27
- };
28
-
29
- export function createBeforeResetHook(runtime: PluginRuntime, logger: LoggerLike = console) {
30
- return async (event: unknown, ctx: unknown): Promise<void> => {
31
- const typedEvent = asBeforeResetEvent(event);
32
- const typedCtx = asAgentContext(ctx);
33
- try {
34
- await runtime.emitLifecycleHint({
35
- hook: "before_reset",
36
- reason: typedEvent.reason,
37
- sessionFile: typedEvent.sessionFile,
38
- sessionId: typedCtx.sessionId,
39
- sessionKey: typedCtx.sessionKey,
40
- agentId: typedCtx.agentId,
41
- workspaceDir: typedCtx.workspaceDir,
42
- messageCount: Array.isArray(typedEvent.messages) ? typedEvent.messages.length : undefined,
43
- });
44
- } catch (error) {
45
- logger.warn?.(`LibraVDB before_reset hint failed: ${formatError(error)}`);
46
- }
47
- };
48
- }
49
-
50
- export function createSessionEndHook(runtime: PluginRuntime, logger: LoggerLike = console) {
51
- return async (event: unknown, ctx: unknown): Promise<void> => {
52
- const typedEvent = asSessionEndEvent(event);
53
- const typedCtx = asAgentContext(ctx);
54
- try {
55
- await runtime.emitLifecycleHint({
56
- hook: "session_end",
57
- reason: typedEvent.reason,
58
- sessionFile: typedEvent.sessionFile,
59
- sessionId: typedEvent.sessionId ?? typedCtx.sessionId,
60
- sessionKey: typedEvent.sessionKey ?? typedCtx.sessionKey,
61
- agentId: typedCtx.agentId,
62
- workspaceDir: typedCtx.workspaceDir,
63
- messageCount: typedEvent.messageCount,
64
- durationMs: typedEvent.durationMs,
65
- transcriptArchived: typedEvent.transcriptArchived,
66
- nextSessionId: typedEvent.nextSessionId,
67
- nextSessionKey: typedEvent.nextSessionKey,
68
- });
69
- } catch (error) {
70
- logger.warn?.(`LibraVDB session_end hint failed: ${formatError(error)}`);
71
- }
72
- };
73
- }
74
-
75
- function asAgentContext(value: unknown): AgentContext {
76
- return isRecord(value) ? value as AgentContext : {};
77
- }
78
-
79
- function asBeforeResetEvent(value: unknown): BeforeResetEvent {
80
- return isRecord(value) ? value as BeforeResetEvent : {};
81
- }
82
-
83
- function asSessionEndEvent(value: unknown): SessionEndEvent {
84
- return isRecord(value) ? value as SessionEndEvent : {};
85
- }
86
-
87
- function isRecord(value: unknown): value is Record<string, unknown> {
88
- return typeof value === "object" && value !== null;
89
- }
90
-
91
- function formatError(error: unknown): string {
92
- if (error instanceof Error && error.message.trim()) {
93
- return error.message;
94
- }
95
- return String(error);
96
- }
@@ -1,104 +0,0 @@
1
- const WASM_BYTES = new Uint8Array([
2
- 0x00, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00, 0x01, 0x07, 0x01, 0x60,
3
- 0x02, 0x7f, 0x7f, 0x01, 0x7e, 0x03, 0x02, 0x01, 0x00, 0x04, 0x05, 0x01,
4
- 0x70, 0x01, 0x01, 0x01, 0x05, 0x03, 0x01, 0x00, 0x10, 0x06, 0x09, 0x01,
5
- 0x7f, 0x01, 0x41, 0x80, 0x80, 0xc0, 0x00, 0x0b, 0x07, 0x19, 0x02, 0x06,
6
- 0x6d, 0x65, 0x6d, 0x6f, 0x72, 0x79, 0x02, 0x00, 0x0c, 0x68, 0x61, 0x73,
7
- 0x68, 0x5f, 0x66, 0x6e, 0x76, 0x31, 0x61, 0x36, 0x34, 0x00, 0x00, 0x0a,
8
- 0x41, 0x01, 0x3f, 0x01, 0x01, 0x7e, 0x42, 0x83, 0x87, 0xf4, 0x9c, 0x87,
9
- 0xf6, 0xc3, 0xb2, 0x14, 0x21, 0x02, 0x02, 0x40, 0x20, 0x01, 0x45, 0x0d,
10
- 0x00, 0x03, 0x40, 0x20, 0x02, 0x20, 0x00, 0x31, 0x00, 0x00, 0x85, 0x42,
11
- 0xb3, 0x83, 0x80, 0x80, 0x80, 0x20, 0x7e, 0x21, 0x02, 0x20, 0x00, 0x41,
12
- 0x01, 0x6a, 0x21, 0x00, 0x20, 0x01, 0x41, 0x7f, 0x6a, 0x22, 0x01, 0x0d,
13
- 0x00, 0x0b, 0x0b, 0x20, 0x02, 0x0b,
14
- ]);
15
-
16
- const textEncoder = new TextEncoder();
17
- const FNV_OFFSET_BASIS = 0xcbf29ce484222325n;
18
- const FNV_PRIME = 0x100000001b3n;
19
-
20
- interface HashBackend {
21
- kind: string;
22
- hash(bytes: Uint8Array): string;
23
- }
24
-
25
- interface WasmExports {
26
- memory: WebAssembly.Memory;
27
- hash_fnv1a64(ptr: number, len: number): bigint;
28
- }
29
-
30
- class Fnv64Fallback implements HashBackend {
31
- kind = "js-fnv1a64";
32
-
33
- hash(bytes: Uint8Array): string {
34
- let hash = FNV_OFFSET_BASIS;
35
- for (let i = 0; i < bytes.length; i++) {
36
- hash ^= BigInt(bytes[i] ?? 0);
37
- hash = BigInt.asUintN(64, hash * FNV_PRIME);
38
- }
39
- return hash.toString(16).padStart(16, "0");
40
- }
41
- }
42
-
43
- class WasmFnv64 implements HashBackend {
44
- kind = "wasm-fnv1a64";
45
- private readonly memory: WebAssembly.Memory;
46
- private readonly hashFn: (ptr: number, len: number) => bigint;
47
- private view: Uint8Array;
48
-
49
- constructor() {
50
- const module = new WebAssembly.Module(WASM_BYTES);
51
- const instance = new WebAssembly.Instance(module, {});
52
- const exports = instance.exports as unknown as WasmExports;
53
- this.memory = exports.memory;
54
- this.hashFn = exports.hash_fnv1a64;
55
- this.view = new Uint8Array(this.memory.buffer);
56
- }
57
-
58
- hash(bytes: Uint8Array): string {
59
- this.ensureCapacity(bytes.length);
60
- this.view.set(bytes, 0);
61
- const raw = this.hashFn(0, bytes.length);
62
- return BigInt.asUintN(64, raw).toString(16).padStart(16, "0");
63
- }
64
-
65
- private ensureCapacity(size: number): void {
66
- if (this.view.byteLength >= size) {
67
- return;
68
- }
69
-
70
- const pageSize = 65536;
71
- const requiredPages = Math.ceil(size / pageSize);
72
- const currentPages = this.memory.buffer.byteLength / pageSize;
73
- const deltaPages = requiredPages - currentPages;
74
- if (deltaPages > 0) {
75
- this.memory.grow(deltaPages);
76
- this.view = new Uint8Array(this.memory.buffer);
77
- }
78
- }
79
- }
80
-
81
- let backend: HashBackend | null = null;
82
-
83
- function getBackend(): HashBackend {
84
- if (!backend) {
85
- try {
86
- backend = new WasmFnv64();
87
- } catch {
88
- backend = new Fnv64Fallback();
89
- }
90
- }
91
- return backend;
92
- }
93
-
94
- export function hashBytes(bytes: Uint8Array): string {
95
- return getBackend().hash(bytes);
96
- }
97
-
98
- export function hashText(text: string): string {
99
- return hashBytes(textEncoder.encode(text));
100
- }
101
-
102
- export function getHashBackendName(): string {
103
- return getBackend().kind;
104
- }