@t0ken.ai/memoryx-openclaw-plugin 1.1.6 → 1.1.8
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/index.d.ts +1 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -23
- package/package.json +2 -6
package/dist/index.d.ts
CHANGED
|
@@ -31,35 +31,27 @@ interface RecallResult {
|
|
|
31
31
|
}
|
|
32
32
|
declare class ConversationBuffer {
|
|
33
33
|
private messages;
|
|
34
|
-
private tokenCount;
|
|
35
34
|
private roundCount;
|
|
36
35
|
private lastRole;
|
|
37
36
|
private conversationId;
|
|
38
37
|
private startedAt;
|
|
39
38
|
private lastActivityAt;
|
|
40
|
-
private encoder;
|
|
41
39
|
private readonly ROUND_THRESHOLD;
|
|
42
40
|
private readonly TIMEOUT_MS;
|
|
43
|
-
private readonly MAX_TOKENS_PER_MESSAGE;
|
|
44
41
|
constructor();
|
|
45
|
-
private getEncoder;
|
|
46
42
|
private generateId;
|
|
47
|
-
private countTokens;
|
|
48
43
|
addMessage(role: string, content: string): boolean;
|
|
49
44
|
shouldFlush(): boolean;
|
|
50
45
|
flush(): {
|
|
51
46
|
conversation_id: string;
|
|
52
47
|
messages: Message[];
|
|
53
|
-
total_tokens: number;
|
|
54
48
|
};
|
|
55
49
|
forceFlush(): {
|
|
56
50
|
conversation_id: string;
|
|
57
51
|
messages: Message[];
|
|
58
|
-
total_tokens: number;
|
|
59
52
|
} | null;
|
|
60
53
|
getStatus(): {
|
|
61
54
|
messageCount: number;
|
|
62
|
-
tokenCount: number;
|
|
63
55
|
conversationId: string;
|
|
64
56
|
};
|
|
65
57
|
}
|
|
@@ -85,7 +77,7 @@ declare class MemoryXPlugin {
|
|
|
85
77
|
hasApiKey: boolean;
|
|
86
78
|
bufferStatus: {
|
|
87
79
|
messageCount: number;
|
|
88
|
-
|
|
80
|
+
conversationId: string;
|
|
89
81
|
};
|
|
90
82
|
};
|
|
91
83
|
}
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAqCH,UAAU,YAAY;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;CACvB;AAUD,UAAU,OAAO;IACb,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;CACrB;AAED,UAAU,YAAY;IAClB,QAAQ,EAAE,KAAK,CAAC;QACZ,EAAE,EAAE,MAAM,CAAC;QACX,OAAO,EAAE,MAAM,CAAC;QAChB,QAAQ,EAAE,MAAM,CAAC;QACjB,KAAK,EAAE,MAAM,CAAC;KACjB,CAAC,CAAC;IACH,SAAS,EAAE,OAAO,CAAC;IACnB,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;CACxB;AA6ED,cAAM,kBAAkB;IACpB,OAAO,CAAC,QAAQ,CAAiB;IACjC,OAAO,CAAC,UAAU,CAAa;IAC/B,OAAO,CAAC,QAAQ,CAAc;IAC9B,OAAO,CAAC,cAAc,CAAc;IACpC,OAAO,CAAC,SAAS,CAAsB;IACvC,OAAO,CAAC,cAAc,CAAsB;IAE5C,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAK;IACrC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAkB;;IAM7C,OAAO,CAAC,UAAU;IAIlB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO;IAuBlD,WAAW,IAAI,OAAO;IAiBtB,KAAK,IAAI;QAAE,eAAe,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,OAAO,E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11
|
*/
|
|
12
|
-
import { getEncoding } from "js-tiktoken";
|
|
13
12
|
import * as fs from "fs";
|
|
14
13
|
import * as path from "path";
|
|
15
14
|
import * as os from "os";
|
|
@@ -110,47 +109,30 @@ class SQLiteStorage {
|
|
|
110
109
|
}
|
|
111
110
|
class ConversationBuffer {
|
|
112
111
|
messages = [];
|
|
113
|
-
tokenCount = 0;
|
|
114
112
|
roundCount = 0;
|
|
115
113
|
lastRole = "";
|
|
116
114
|
conversationId = "";
|
|
117
115
|
startedAt = Date.now();
|
|
118
116
|
lastActivityAt = Date.now();
|
|
119
|
-
encoder = null;
|
|
120
117
|
ROUND_THRESHOLD = 2;
|
|
121
118
|
TIMEOUT_MS = 30 * 60 * 1000;
|
|
122
|
-
MAX_TOKENS_PER_MESSAGE = 8000;
|
|
123
119
|
constructor() {
|
|
124
120
|
this.conversationId = this.generateId();
|
|
125
121
|
}
|
|
126
|
-
getEncoder() {
|
|
127
|
-
if (!this.encoder) {
|
|
128
|
-
this.encoder = getEncoding("cl100k_base");
|
|
129
|
-
}
|
|
130
|
-
return this.encoder;
|
|
131
|
-
}
|
|
132
122
|
generateId() {
|
|
133
123
|
return `conv_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
|
|
134
124
|
}
|
|
135
|
-
countTokens(text) {
|
|
136
|
-
return this.getEncoder().encode(text).length;
|
|
137
|
-
}
|
|
138
125
|
addMessage(role, content) {
|
|
139
126
|
if (!content || content.length < 2) {
|
|
140
127
|
return false;
|
|
141
128
|
}
|
|
142
|
-
const tokens = this.countTokens(content);
|
|
143
|
-
if (tokens > this.MAX_TOKENS_PER_MESSAGE) {
|
|
144
|
-
return false;
|
|
145
|
-
}
|
|
146
129
|
const message = {
|
|
147
130
|
role,
|
|
148
131
|
content,
|
|
149
|
-
tokens,
|
|
132
|
+
tokens: 0,
|
|
150
133
|
timestamp: Date.now()
|
|
151
134
|
};
|
|
152
135
|
this.messages.push(message);
|
|
153
|
-
this.tokenCount += tokens;
|
|
154
136
|
this.lastActivityAt = Date.now();
|
|
155
137
|
if (role === "assistant" && this.lastRole === "user") {
|
|
156
138
|
this.roundCount++;
|
|
@@ -174,11 +156,9 @@ class ConversationBuffer {
|
|
|
174
156
|
flush() {
|
|
175
157
|
const data = {
|
|
176
158
|
conversation_id: this.conversationId,
|
|
177
|
-
messages: [...this.messages]
|
|
178
|
-
total_tokens: this.tokenCount
|
|
159
|
+
messages: [...this.messages]
|
|
179
160
|
};
|
|
180
161
|
this.messages = [];
|
|
181
|
-
this.tokenCount = 0;
|
|
182
162
|
this.roundCount = 0;
|
|
183
163
|
this.lastRole = "";
|
|
184
164
|
this.conversationId = this.generateId();
|
|
@@ -195,7 +175,6 @@ class ConversationBuffer {
|
|
|
195
175
|
getStatus() {
|
|
196
176
|
return {
|
|
197
177
|
messageCount: this.messages.length,
|
|
198
|
-
tokenCount: this.tokenCount,
|
|
199
178
|
conversationId: this.conversationId
|
|
200
179
|
};
|
|
201
180
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@t0ken.ai/memoryx-openclaw-plugin",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.8",
|
|
4
4
|
"description": "MemoryX real-time memory capture and recall plugin for OpenClaw",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": "MemoryX Team",
|
|
@@ -36,10 +36,6 @@
|
|
|
36
36
|
"typescript": "^5.0.0"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"
|
|
40
|
-
"better-sqlite3": "^11.0.0",
|
|
41
|
-
"js-tiktoken": "^1.0.21",
|
|
42
|
-
"onnxruntime-node": "^1.24.1",
|
|
43
|
-
"onnxruntime-web": "^1.24.1"
|
|
39
|
+
"better-sqlite3": "^11.0.0"
|
|
44
40
|
}
|
|
45
41
|
}
|