memory-search-plugin 0.3.0 → 0.4.0

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 (2) hide show
  1. package/index.ts +18 -9
  2. package/package.json +1 -1
package/index.ts CHANGED
@@ -87,7 +87,7 @@ const buildPromptSection = ({
87
87
  return lines;
88
88
  };
89
89
 
90
- // ── 路径判断 ───────────────────────────────────────────���
90
+ // ── 路径判断 ────────────────────────────────────────────
91
91
 
92
92
  /**
93
93
  * 判断是否是 MEMORY 路径
@@ -270,7 +270,7 @@ export default definePluginEntry({
270
270
 
271
271
  try {
272
272
  const fallbackTool =
273
- api.runtime.tools.createMemorySearchTool({
273
+ api.runtime?.tools?.createMemorySearchTool({
274
274
  config: ctx.config,
275
275
  agentSessionKey: ctx.sessionKey,
276
276
  });
@@ -309,12 +309,6 @@ export default definePluginEntry({
309
309
  const fallbackIdentity = ctx.sessionKey ? resolveIdentity(ctx.sessionKey) : null;
310
310
  const fallbackAgentId = ctx.sessionKey ? extractAgentId(ctx.sessionKey) : null;
311
311
 
312
- // 获取原始 memory_get 实现,用于非 MEMORY 路径的 passthrough
313
- const originalGetTool = api.runtime.tools.createMemoryGetTool({
314
- config: ctx.config,
315
- agentSessionKey: ctx.sessionKey,
316
- });
317
-
318
312
  return {
319
313
  name: "memory_get",
320
314
  description:
@@ -376,6 +370,17 @@ export default definePluginEntry({
376
370
  };
377
371
  }
378
372
 
373
+ // 懒加载原始 memory_get 实现,用于非 MEMORY 路径的 passthrough
374
+ let originalGetTool: any = null;
375
+ try {
376
+ originalGetTool = api.runtime?.tools?.createMemoryGetTool({
377
+ config: ctx.config,
378
+ agentSessionKey: ctx.sessionKey,
379
+ });
380
+ } catch {
381
+ // memory-core 被替换后 api.runtime.tools 不可用,忽略
382
+ }
383
+
379
384
  // ── 路径分流 ──
380
385
  if (isMemoryPath(path)) {
381
386
  const agentId = params.agent_id?.trim() || fallbackAgentId || "main";
@@ -464,7 +469,11 @@ export default definePluginEntry({
464
469
  // ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
465
470
  api.registerCli(
466
471
  ({ program }: any) => {
467
- api.runtime.tools.registerMemoryCli(program);
472
+ try {
473
+ api.runtime?.tools?.registerMemoryCli(program);
474
+ } catch {
475
+ // memory-core 被替换后 api.runtime.tools 不可用,忽略
476
+ }
468
477
  },
469
478
  { commands: ["memory"] }
470
479
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "memory-search-plugin",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "type": "module",
5
5
  "main": "index.ts",
6
6
  "files": [