@@ -9,10 +9,13 @@
|
9 | 9 | import { Buffer } from "node:buffer"; |
10 | 10 | import { randomUUID } from "node:crypto"; |
11 | 11 | import type * as LanceDB from "@lancedb/lancedb"; |
12 | | -import { optionalPositiveIntegerSchema } from "openclaw/plugin-sdk/channel-actions"; |
| 12 | +import { |
| 13 | +optionalFiniteNumberSchema, |
| 14 | +optionalPositiveIntegerSchema, |
| 15 | +} from "openclaw/plugin-sdk/channel-actions"; |
13 | 16 | import type { OpenClawConfig } from "openclaw/plugin-sdk/config-contracts"; |
14 | 17 | import type { MemoryEmbeddingProvider } from "openclaw/plugin-sdk/memory-core-host-engine-embeddings"; |
15 | | -import { readPositiveIntegerParam } from "openclaw/plugin-sdk/param-readers"; |
| 18 | +import { readFiniteNumberParam, readPositiveIntegerParam } from "openclaw/plugin-sdk/param-readers"; |
16 | 19 | import { resolveLivePluginConfigObject } from "openclaw/plugin-sdk/plugin-config-runtime"; |
17 | 20 | import { ensureGlobalUndiciEnvProxyDispatcher } from "openclaw/plugin-sdk/runtime-env"; |
18 | 21 | import { |
@@ -767,7 +770,11 @@ export default definePluginEntry({
|
767 | 770 | "Save important information in long-term memory. Use for preferences, facts, decisions.", |
768 | 771 | parameters: Type.Object({ |
769 | 772 | text: Type.String({ description: "Information to remember" }), |
770 | | -importance: Type.Optional(Type.Number({ description: "Importance 0-1 (default: 0.7)" })), |
| 773 | +importance: optionalFiniteNumberSchema({ |
| 774 | +description: "Importance 0-1 (default: 0.7)", |
| 775 | +minimum: 0, |
| 776 | +maximum: 1, |
| 777 | +}), |
771 | 778 | category: Type.Optional( |
772 | 779 | Type.Unsafe<MemoryCategory>({ |
773 | 780 | type: "string", |
@@ -776,15 +783,15 @@ export default definePluginEntry({
|
776 | 783 | ), |
777 | 784 | }), |
778 | 785 | async execute(_toolCallId, params) { |
779 | | -const { |
780 | | - text, |
781 | | - importance = 0.7, |
782 | | - category = "other", |
783 | | -} = params as { |
| 786 | +const { text, category = "other" } = params as { |
784 | 787 | text: string; |
785 | | -importance?: number; |
786 | 788 | category?: MemoryEntry["category"]; |
787 | 789 | }; |
| 790 | +const importance = |
| 791 | +readFiniteNumberParam(params as Record<string, unknown>, "importance", { |
| 792 | +min: 0, |
| 793 | +max: 1, |
| 794 | +}) ?? 0.7; |
788 | 795 | |
789 | 796 | if (looksLikePromptInjection(text)) { |
790 | 797 | return { |
|