@t0ken.ai/memoryx-openclaw-plugin 2.2.72 → 2.2.74

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.
@@ -1,4 +1,4 @@
1
- export declare const PLUGIN_VERSION = "2.2.72";
1
+ export declare const PLUGIN_VERSION = "2.2.74";
2
2
  export declare const DEFAULT_API_BASE = "https://t0ken.ai/api";
3
3
  export declare const PLUGIN_DIR: string;
4
4
  /** 真实上游 baseUrl 缓存文件:重启后若配置已被改成 localhost,从此文件恢复各厂商真实地址。 */
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.72";
7
+ export const PLUGIN_VERSION = "2.2.74";
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,从此文件恢复各厂商真实地址。 */
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAG/C,OAAO,EAAE,aAAa,EAAU,MAAM,kBAAkB,CAAC;;;;;;kBAwBvC,GAAG,iBAAiB,YAAY,GAAG,IAAI;;AARzD,wBAwIE;AAEF,OAAO,EAAE,aAAa,EAAE,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAG/C,OAAO,EAAE,aAAa,EAAU,MAAM,kBAAkB,CAAC;;;;;;kBAwBvC,GAAG,iBAAiB,YAAY,GAAG,IAAI;;AARzD,wBA6IE;AAEF,OAAO,EAAE,aAAa,EAAE,CAAC"}
package/dist/index.js CHANGED
@@ -101,11 +101,15 @@ export default {
101
101
  const credentials = extractProviderCredentials(api.config);
102
102
  const defaults = getDefaultModelAndProvider(credentials, api.config);
103
103
  const realUpstreamCredentials = realUpstreamCredentialsForSidecar(credentials, savedRealUpstreamUrls);
104
+ const agentTimeoutSeconds = runtimeSnapshot?.agents?.defaults?.timeoutSeconds ||
105
+ api.config?.agents?.defaults?.timeoutSeconds ||
106
+ 600;
104
107
  sidecar = new SidecarServer(realUpstreamCredentials, { model: defaults.model, provider: defaults.provider }, defaults.availableProviders, {
105
108
  proxyUrl,
106
109
  getSDK,
107
110
  pluginConfig,
108
111
  onStarted: (logFile) => api.logger.info(`[MemoryX] Plugin log file: ${logFile}`),
112
+ agentTimeoutSeconds,
109
113
  });
110
114
  await sidecar.start();
111
115
  api.logger.info(`[MemoryX] Sidecar started on port ${sidecar.getPort()}`);
package/dist/sidecar.d.ts CHANGED
@@ -12,6 +12,7 @@ export interface SidecarOptions {
12
12
  getSDK: GetSDK;
13
13
  pluginConfig?: PluginConfig;
14
14
  onStarted?: (logFile: string) => void;
15
+ agentTimeoutSeconds?: number;
15
16
  }
16
17
  export declare class SidecarServer {
17
18
  private server;
@@ -1 +1 @@
1
- {"version":3,"file":"sidecar.d.ts","sourceRoot":"","sources":["../src/sidecar.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;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,Y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,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;IACtC,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAChC;AAED,qBAAa,aAAa;IACtB,OAAO,CAAC,MAAM,CAA4B;IAC1C,OAAO,CAAC,WAAW,CAAmC;IACtD,OAAO,CAAC,eAAe,CAAsC;IAC7D,OAAO,CAAC,kBAAkB,CAA6C;IACvE,OAAO,CAAC,OAAO,CAAiB;IAEhC,OAAO,CAAC,gBAAgB,CAAuC;IAC/D,OAAO,CAAC,mBAAmB,CAAc;IACzC,OAAO,CAAC,aAAa,CAAc;IACnC,OAAO,CAAC,mBAAmB,CAAS;gBAGhC,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;IA6BtB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAa3B,OAAO,IAAI,MAAM;YAMH,UAAU;IAuBxB,OAAO,CAAC,aAAa;IAIrB;;;;OAIG;YACW,kBAAkB;YA0GlB,aAAa;IAsM3B,OAAO,CAAC,QAAQ;CAQnB"}
package/dist/sidecar.js CHANGED
@@ -43,6 +43,8 @@ export class SidecarServer {
43
43
  });
44
44
  server.listen(SIDECAR_PORT, () => {
45
45
  this.server = server;
46
+ const agentTimeout = this.options.agentTimeoutSeconds || 600;
47
+ log(`[Sidecar] agentTimeoutSeconds=${agentTimeout}, fetchTimeout=${Math.round(agentTimeout * 1.2)}s`, { console: true });
46
48
  const baseUrl = `http://localhost:${SIDECAR_PORT}`;
47
49
  log(`[Sidecar] Started on port ${SIDECAR_PORT}. OpenClaw base URL: ${baseUrl} (proxy: ${this.options.proxyUrl})`);
48
50
  log(`[Sidecar] Log file: ${LOG_FILE}`, { console: true });
@@ -109,11 +111,6 @@ export class SidecarServer {
109
111
  return false;
110
112
  }
111
113
  const fallbackBody = { ...parsedBody };
112
- if (fallbackBody.model === "auto") {
113
- const match = this.availableProviders.find(p => p.provider === provider);
114
- if (match?.model)
115
- fallbackBody.model = match.model;
116
- }
117
114
  const upstreamUrl = realBaseUrl.replace(/\/+$/, "") + reqUrl;
118
115
  const headers = { "Content-Type": "application/json" };
119
116
  if (requestFormat === "anthropic") {
@@ -125,7 +122,8 @@ export class SidecarServer {
125
122
  }
126
123
  log(`[Sidecar] ${reqId} fallback → ${provider} ${upstreamUrl} model=${fallbackBody.model} fmt=${requestFormat}`, { console: true });
127
124
  const stream = !!fallbackBody.stream;
128
- const timeout = stream ? 120_000 : 90_000;
125
+ const fallbackAgentMs = (this.options.agentTimeoutSeconds || 600) * 1_000;
126
+ const timeout = stream ? Math.round(fallbackAgentMs * 1.2) : 90_000;
129
127
  const abort = new AbortController();
130
128
  const timer = setTimeout(() => abort.abort(), timeout);
131
129
  let resp;
@@ -159,7 +157,7 @@ export class SidecarServer {
159
157
  res.writeHead(resp.status, {
160
158
  "Content-Type": resp.headers.get("content-type") || "text/event-stream",
161
159
  });
162
- const FIRST_CHUNK_TIMEOUT = 120_000;
160
+ const FIRST_CHUNK_TIMEOUT = Math.round(fallbackAgentMs * 1.2);
163
161
  const CHUNK_TIMEOUT = 30_000;
164
162
  let isFirst = true;
165
163
  try {
@@ -251,30 +249,23 @@ export class SidecarServer {
251
249
  const incomingApiKey = authHeader.startsWith("Bearer ")
252
250
  ? authHeader.slice(7).trim()
253
251
  : req.headers["x-api-key"]?.trim() || authHeader;
254
- const realProvider = urlProvider || this.defaultProvider.provider || "";
255
- const credentialsObj = {};
256
- for (const [id, creds] of this.credentials) {
257
- const realBaseUrl = baseUrlMapObj[id] || creds.baseUrl || "";
258
- credentialsObj[id] = { baseUrl: realBaseUrl, apiKey: creds.apiKey || "" };
259
- }
260
- const messages = parsedBody.messages || [];
261
- const lastUserMsg = [...messages].reverse().find((m) => m.role === "user");
262
- const searchQuery = typeof lastUserMsg?.content === "string" ? lastUserMsg.content : "";
252
+ const realProvider = req.headers["x-memoryx-real-provider"]?.trim()
253
+ || urlProvider
254
+ || this.defaultProvider.provider
255
+ || "";
256
+ const realBaseUrl = baseUrlMapObj[realProvider] || "";
263
257
  const proxyRequestBody = {
264
- base_url_map: baseUrlMapObj,
265
- credentials: credentialsObj,
266
- incoming_api_key: incomingApiKey || undefined,
267
258
  body: parsedBody,
259
+ provider: realProvider,
260
+ api_base: realBaseUrl,
261
+ api_key: incomingApiKey,
268
262
  request_format: requestFormat,
269
- request_headers: { "x-memoryx-real-provider": realProvider },
270
- search_query: searchQuery,
271
- agent_id: this.cachedAgentId,
272
- available_models: this.availableProviders.map((p) => `${p.provider}/${p.model}`),
273
263
  };
274
264
  const pathLog = url.split("?")[0] || "/";
275
265
  log(`[Sidecar] ${reqId} ${method} ${pathLog} fmt=${requestFormat} provider=${realProvider} model=${parsedBody.model ?? "-"} stream=${stream}`, { console: true });
276
- const FETCH_TIMEOUT = stream ? 120_000 : 90_000;
277
- const REASONING_CHUNK_TIMEOUT = 120_000;
266
+ const agentTimeoutMs = (this.options.agentTimeoutSeconds || 600) * 1_000;
267
+ const FETCH_TIMEOUT = stream ? Math.round(agentTimeoutMs * 1.2) : 90_000;
268
+ const REASONING_CHUNK_TIMEOUT = Math.round(agentTimeoutMs * 1.2);
278
269
  const CHUNK_TIMEOUT = 30_000;
279
270
  const fetchAbort = new AbortController();
280
271
  const fetchTimer = setTimeout(() => fetchAbort.abort(), FETCH_TIMEOUT);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@t0ken.ai/memoryx-openclaw-plugin",
3
- "version": "2.2.72",
3
+ "version": "2.2.74",
4
4
  "description": "MemoryX real-time memory capture and recall plugin for OpenClaw (powered by @t0ken.ai/memoryx-sdk)",
5
5
  "type": "module",
6
6
  "author": "MemoryX Team",