@t0ken.ai/memoryx-openclaw-plugin 2.2.65 → 2.2.66
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/constants.d.ts +1 -1
- package/dist/constants.js +1 -1
- package/dist/sidecar.d.ts.map +1 -1
- package/dist/sidecar.js +31 -9
- package/package.json +1 -1
package/dist/constants.d.ts
CHANGED
package/dist/constants.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import * as path from "path";
|
|
5
5
|
import * as os from "os";
|
|
6
6
|
// Plugin version - synced from package.json by prebuild script
|
|
7
|
-
export const PLUGIN_VERSION = "2.2.
|
|
7
|
+
export const PLUGIN_VERSION = "2.2.66";
|
|
8
8
|
export const DEFAULT_API_BASE = "https://t0ken.ai/api";
|
|
9
9
|
export const PLUGIN_DIR = path.join(os.homedir(), ".openclaw", "extensions", "memoryx-openclaw-plugin");
|
|
10
10
|
/** 真实上游 baseUrl 缓存文件:重启后若配置已被改成 localhost,从此文件恢复各厂商真实地址。 */
|
package/dist/sidecar.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sidecar.d.ts","sourceRoot":"","sources":["../src/sidecar.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AACtD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAK/C,MAAM,MAAM,MAAM,GAAG,CAAC,MAAM,CAAC,EAAE,YAAY,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;AAE7D,MAAM,WAAW,cAAc;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;CACzC;AAED,qBAAa,aAAa;IACtB,OAAO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gBAG5B,WAAW,EAAE,GAAG,CAAC,MAAM,EAAE,mBAAmB,CAAC,EAC7C,eAAe,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,EACpD,kBAAkB,EAAE,KAAK,CAAC;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,EAC9D,OAAO,EAAE,cAAc;IAQrB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAwBtB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAa3B,OAAO,IAAI,MAAM;YAMH,aAAa;IAgM3B,OAAO,CAAC,QAAQ;CAQnB"}
|
package/dist/sidecar.js
CHANGED
|
@@ -143,17 +143,24 @@ export class SidecarServer {
|
|
|
143
143
|
};
|
|
144
144
|
const pathLog = (req.url || "/").split("?")[0] || "/";
|
|
145
145
|
log(`[Sidecar] ${reqId} ${method} ${pathLog} model=${openaiRequest.model ?? "-"} stream=${stream} → proxy ${proxyUrl}`, { console: true });
|
|
146
|
+
const fetchAbort = new AbortController();
|
|
147
|
+
const fetchTimer = setTimeout(() => fetchAbort.abort(), 120_000);
|
|
146
148
|
let proxyResponse = null;
|
|
147
149
|
try {
|
|
148
150
|
proxyResponse = await fetch(proxyUrl, {
|
|
149
151
|
method: "POST",
|
|
150
152
|
headers: { "Content-Type": "application/json", "X-API-Key": memoryxApiKey },
|
|
151
153
|
body: JSON.stringify(proxyRequestBody),
|
|
154
|
+
signal: fetchAbort.signal,
|
|
152
155
|
});
|
|
153
156
|
}
|
|
154
157
|
catch (e) {
|
|
155
158
|
proxyResponse = null;
|
|
156
|
-
|
|
159
|
+
const msg = fetchAbort.signal.aborted ? "fetch timeout (120s)" : (e?.message ?? String(e));
|
|
160
|
+
log(`[Sidecar] ${reqId} err proxy fetch: ${msg}`, { console: true });
|
|
161
|
+
}
|
|
162
|
+
finally {
|
|
163
|
+
clearTimeout(fetchTimer);
|
|
157
164
|
}
|
|
158
165
|
const proxyFailed = !proxyResponse || proxyResponse.status >= 500;
|
|
159
166
|
if (proxyFailed) {
|
|
@@ -180,15 +187,20 @@ export class SidecarServer {
|
|
|
180
187
|
const proxy = proxyResponse;
|
|
181
188
|
if (openaiRequest.stream && proxy.body) {
|
|
182
189
|
const reader = proxy.body.getReader();
|
|
190
|
+
const CHUNK_TIMEOUT = 90_000;
|
|
191
|
+
const readWithTimeout = () => Promise.race([
|
|
192
|
+
reader.read(),
|
|
193
|
+
new Promise((_, rej) => setTimeout(() => rej(new Error("chunk timeout")), CHUNK_TIMEOUT)),
|
|
194
|
+
]);
|
|
183
195
|
let firstChunk;
|
|
184
196
|
try {
|
|
185
|
-
firstChunk = await
|
|
186
|
-
reader.read(),
|
|
187
|
-
new Promise((_, rej) => setTimeout(() => rej(new Error("First chunk timeout")), 60000)),
|
|
188
|
-
]);
|
|
197
|
+
firstChunk = await readWithTimeout();
|
|
189
198
|
}
|
|
190
199
|
catch (firstErr) {
|
|
191
|
-
|
|
200
|
+
try {
|
|
201
|
+
reader.releaseLock();
|
|
202
|
+
}
|
|
203
|
+
catch (_) { }
|
|
192
204
|
log(`[Sidecar] ${reqId} err stream first chunk: ${firstErr?.message ?? "timeout"}`, { console: true });
|
|
193
205
|
res.writeHead(502, { "Content-Type": "application/json" });
|
|
194
206
|
res.end(JSON.stringify({ error: "MemoryX proxy stream failed" }));
|
|
@@ -201,14 +213,24 @@ export class SidecarServer {
|
|
|
201
213
|
if (!firstChunk.done && firstChunk.value)
|
|
202
214
|
res.write(Buffer.from(firstChunk.value));
|
|
203
215
|
while (true) {
|
|
204
|
-
|
|
205
|
-
|
|
216
|
+
if (res.destroyed) {
|
|
217
|
+
log(`[Sidecar] ${reqId} client disconnected, aborting stream`, { console: true });
|
|
218
|
+
break;
|
|
219
|
+
}
|
|
220
|
+
const { done, value } = await readWithTimeout();
|
|
221
|
+
if (done || !value)
|
|
206
222
|
break;
|
|
207
223
|
res.write(Buffer.from(value));
|
|
208
224
|
}
|
|
209
225
|
}
|
|
226
|
+
catch (streamErr) {
|
|
227
|
+
log(`[Sidecar] ${reqId} stream error: ${streamErr?.message ?? "unknown"}`, { console: true });
|
|
228
|
+
}
|
|
210
229
|
finally {
|
|
211
|
-
|
|
230
|
+
try {
|
|
231
|
+
reader.releaseLock();
|
|
232
|
+
}
|
|
233
|
+
catch (_) { }
|
|
212
234
|
}
|
|
213
235
|
res.end();
|
|
214
236
|
log(`[Sidecar] ${reqId} ← ${proxy.status} stream`, { console: true });
|
package/package.json
CHANGED