@t0ken.ai/memoryx-openclaw-plugin 1.1.6 → 1.1.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.
- package/dist/index.d.ts +2 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -21
- package/package.json +2 -6
package/dist/index.d.ts
CHANGED
|
@@ -31,35 +31,28 @@ 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
|
|
41
|
+
private readonly MAX_CHARS_PER_MESSAGE;
|
|
44
42
|
constructor();
|
|
45
|
-
private getEncoder;
|
|
46
43
|
private generateId;
|
|
47
|
-
private countTokens;
|
|
48
44
|
addMessage(role: string, content: string): boolean;
|
|
49
45
|
shouldFlush(): boolean;
|
|
50
46
|
flush(): {
|
|
51
47
|
conversation_id: string;
|
|
52
48
|
messages: Message[];
|
|
53
|
-
total_tokens: number;
|
|
54
49
|
};
|
|
55
50
|
forceFlush(): {
|
|
56
51
|
conversation_id: string;
|
|
57
52
|
messages: Message[];
|
|
58
|
-
total_tokens: number;
|
|
59
53
|
} | null;
|
|
60
54
|
getStatus(): {
|
|
61
55
|
messageCount: number;
|
|
62
|
-
tokenCount: number;
|
|
63
56
|
conversationId: string;
|
|
64
57
|
};
|
|
65
58
|
}
|
|
@@ -85,7 +78,7 @@ declare class MemoryXPlugin {
|
|
|
85
78
|
hasApiKey: boolean;
|
|
86
79
|
bufferStatus: {
|
|
87
80
|
messageCount: number;
|
|
88
|
-
|
|
81
|
+
conversationId: string;
|
|
89
82
|
};
|
|
90
83
|
};
|
|
91
84
|
}
|
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;IAC7C,OAAO,CAAC,QAAQ,CAAC,qBAAqB,CAAS;;IAM/C,OAAO,CAAC,UAAU;IAIlB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO;IA2BlD,WAAW,IAAI,OAAO;IAiBtB,KAAK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
|
|
9
9
|
* - Configurable API base URL
|
|
10
10
|
* - Precise token counting with tiktoken
|
|
11
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,34 @@ 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
|
-
|
|
119
|
+
MAX_CHARS_PER_MESSAGE = 32000;
|
|
123
120
|
constructor() {
|
|
124
121
|
this.conversationId = this.generateId();
|
|
125
122
|
}
|
|
126
|
-
getEncoder() {
|
|
127
|
-
if (!this.encoder) {
|
|
128
|
-
this.encoder = getEncoding("cl100k_base");
|
|
129
|
-
}
|
|
130
|
-
return this.encoder;
|
|
131
|
-
}
|
|
132
123
|
generateId() {
|
|
133
124
|
return `conv_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
|
|
134
125
|
}
|
|
135
|
-
countTokens(text) {
|
|
136
|
-
return this.getEncoder().encode(text).length;
|
|
137
|
-
}
|
|
138
126
|
addMessage(role, content) {
|
|
139
127
|
if (!content || content.length < 2) {
|
|
140
128
|
return false;
|
|
141
129
|
}
|
|
142
|
-
|
|
143
|
-
if (tokens > this.MAX_TOKENS_PER_MESSAGE) {
|
|
130
|
+
if (content.length > this.MAX_CHARS_PER_MESSAGE) {
|
|
144
131
|
return false;
|
|
145
132
|
}
|
|
146
133
|
const message = {
|
|
147
134
|
role,
|
|
148
135
|
content,
|
|
149
|
-
tokens,
|
|
136
|
+
tokens: 0,
|
|
150
137
|
timestamp: Date.now()
|
|
151
138
|
};
|
|
152
139
|
this.messages.push(message);
|
|
153
|
-
this.tokenCount += tokens;
|
|
154
140
|
this.lastActivityAt = Date.now();
|
|
155
141
|
if (role === "assistant" && this.lastRole === "user") {
|
|
156
142
|
this.roundCount++;
|
|
@@ -174,11 +160,9 @@ class ConversationBuffer {
|
|
|
174
160
|
flush() {
|
|
175
161
|
const data = {
|
|
176
162
|
conversation_id: this.conversationId,
|
|
177
|
-
messages: [...this.messages]
|
|
178
|
-
total_tokens: this.tokenCount
|
|
163
|
+
messages: [...this.messages]
|
|
179
164
|
};
|
|
180
165
|
this.messages = [];
|
|
181
|
-
this.tokenCount = 0;
|
|
182
166
|
this.roundCount = 0;
|
|
183
167
|
this.lastRole = "";
|
|
184
168
|
this.conversationId = this.generateId();
|
|
@@ -195,7 +179,6 @@ class ConversationBuffer {
|
|
|
195
179
|
getStatus() {
|
|
196
180
|
return {
|
|
197
181
|
messageCount: this.messages.length,
|
|
198
|
-
tokenCount: this.tokenCount,
|
|
199
182
|
conversationId: this.conversationId
|
|
200
183
|
};
|
|
201
184
|
}
|
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.7",
|
|
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
|
}
|