@elizaos/plugin-scratchpad 2.0.0-alpha.5 → 2.0.0-alpha.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.
@@ -1 +1 @@
1
- {"version":3,"file":"append.d.ts","sourceRoot":"","sources":["../../actions/append.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,MAAM,EASZ,MAAM,eAAe,CAAC;AAkEvB,eAAO,MAAM,sBAAsB,EAAE,MAgGpC,CAAC;AAEF,eAAe,sBAAsB,CAAC"}
1
+ {"version":3,"file":"append.d.ts","sourceRoot":"","sources":["../../actions/append.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,MAAM,EASZ,MAAM,eAAe,CAAC;AAkEvB,eAAO,MAAM,sBAAsB,EAAE,MA8HpC,CAAC;AAEF,eAAe,sBAAsB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"delete.d.ts","sourceRoot":"","sources":["../../actions/delete.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,MAAM,EASZ,MAAM,eAAe,CAAC;AAyDvB,eAAO,MAAM,sBAAsB,EAAE,MAuFpC,CAAC;AAEF,eAAe,sBAAsB,CAAC"}
1
+ {"version":3,"file":"delete.d.ts","sourceRoot":"","sources":["../../actions/delete.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,MAAM,EASZ,MAAM,eAAe,CAAC;AAyDvB,eAAO,MAAM,sBAAsB,EAAE,MAqHpC,CAAC;AAEF,eAAe,sBAAsB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../actions/list.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,MAAM,EAOZ,MAAM,eAAe,CAAC;AAMvB,eAAO,MAAM,oBAAoB,EAAE,MAiElC,CAAC;AAEF,eAAe,oBAAoB,CAAC"}
1
+ {"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../actions/list.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,MAAM,EAOZ,MAAM,eAAe,CAAC;AAMvB,eAAO,MAAM,oBAAoB,EAAE,MA+FlC,CAAC;AAEF,eAAe,oBAAoB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"read.d.ts","sourceRoot":"","sources":["../../actions/read.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,MAAM,EASZ,MAAM,eAAe,CAAC;AAiEvB,eAAO,MAAM,oBAAoB,EAAE,MAoFlC,CAAC;AAEF,eAAe,oBAAoB,CAAC"}
1
+ {"version":3,"file":"read.d.ts","sourceRoot":"","sources":["../../actions/read.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,MAAM,EASZ,MAAM,eAAe,CAAC;AAiEvB,eAAO,MAAM,oBAAoB,EAAE,MAkHlC,CAAC;AAEF,eAAe,oBAAoB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../../actions/search.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,MAAM,EASZ,MAAM,eAAe,CAAC;AAsDvB,eAAO,MAAM,sBAAsB,EAAE,MA4FpC,CAAC;AAEF,eAAe,sBAAsB,CAAC"}
1
+ {"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../../actions/search.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,MAAM,EASZ,MAAM,eAAe,CAAC;AAsDvB,eAAO,MAAM,sBAAsB,EAAE,MA0HpC,CAAC;AAEF,eAAe,sBAAsB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"write.d.ts","sourceRoot":"","sources":["../../actions/write.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,MAAM,EASZ,MAAM,eAAe,CAAC;AA6EvB,eAAO,MAAM,qBAAqB,EAAE,MA4EnC,CAAC;AAEF,eAAe,qBAAqB,CAAC"}
1
+ {"version":3,"file":"write.d.ts","sourceRoot":"","sources":["../../actions/write.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,MAAM,EASZ,MAAM,eAAe,CAAC;AA6EvB,eAAO,MAAM,qBAAqB,EAAE,MA0GnC,CAAC;AAEF,eAAe,qBAAqB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../build.ts"],"names":[],"mappings":";AAEA,QAAA,MAAM,YAAY,UAAoB,CAAC;AAEvC,iBAAe,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CA2FpC"}
1
+ {"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../build.ts"],"names":[],"mappings":";AAEA,QAAA,MAAM,YAAY,UAAoB,CAAC;AAEvC,iBAAe,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAkGpC"}
@@ -57,7 +57,7 @@ __export(exports_index_node, {
57
57
  module.exports = __toCommonJS(exports_index_node);
58
58
 
59
59
  // index.ts
60
- var import_core9 = require("@elizaos/core");
60
+ var import_core10 = require("@elizaos/core");
61
61
 
62
62
  // actions/append.ts
63
63
  var import_core2 = require("@elizaos/core");
@@ -488,8 +488,29 @@ var scratchpadAppendAction = {
488
488
  name: spec.name,
489
489
  similes: spec.similes ? [...spec.similes] : [],
490
490
  description: spec.description,
491
- validate: async (_runtime, _message) => {
492
- return true;
491
+ validate: async (runtime, message, state, options) => {
492
+ const __avTextRaw = typeof message?.content?.text === "string" ? message.content.text : "";
493
+ const __avText = __avTextRaw.toLowerCase();
494
+ const __avKeywords = ["scratchpad", "append"];
495
+ const __avKeywordOk = __avKeywords.length > 0 && __avKeywords.some((kw) => kw.length > 0 && __avText.includes(kw));
496
+ const __avRegex = new RegExp("\\b(?:scratchpad|append)\\b", "i");
497
+ const __avRegexOk = __avRegex.test(__avText);
498
+ const __avSource = String(message?.content?.source ?? message?.source ?? "");
499
+ const __avExpectedSource = "";
500
+ const __avSourceOk = __avExpectedSource ? __avSource === __avExpectedSource : Boolean(__avSource || state || runtime?.agentId || runtime?.getService);
501
+ const __avOptions = options && typeof options === "object" ? options : {};
502
+ const __avInputOk = __avText.trim().length > 0 || Object.keys(__avOptions).length > 0 || Boolean(message?.content && typeof message.content === "object");
503
+ if (!(__avKeywordOk && __avRegexOk && __avSourceOk && __avInputOk)) {
504
+ return false;
505
+ }
506
+ const __avLegacyValidate = async (_runtime, _message) => {
507
+ return true;
508
+ };
509
+ try {
510
+ return Boolean(await __avLegacyValidate(runtime, message, state, options));
511
+ } catch {
512
+ return false;
513
+ }
493
514
  },
494
515
  handler: async (runtime, message, _stateFromTrigger, _options, callback, _responses) => {
495
516
  const service = createScratchpadService(runtime);
@@ -600,8 +621,29 @@ var scratchpadDeleteAction = {
600
621
  name: spec2.name,
601
622
  similes: spec2.similes ? [...spec2.similes] : [],
602
623
  description: spec2.description,
603
- validate: async (_runtime, _message) => {
604
- return true;
624
+ validate: async (runtime, message, state, options) => {
625
+ const __avTextRaw = typeof message?.content?.text === "string" ? message.content.text : "";
626
+ const __avText = __avTextRaw.toLowerCase();
627
+ const __avKeywords = ["scratchpad", "delete"];
628
+ const __avKeywordOk = __avKeywords.length > 0 && __avKeywords.some((kw) => kw.length > 0 && __avText.includes(kw));
629
+ const __avRegex = new RegExp("\\b(?:scratchpad|delete)\\b", "i");
630
+ const __avRegexOk = __avRegex.test(__avText);
631
+ const __avSource = String(message?.content?.source ?? message?.source ?? "");
632
+ const __avExpectedSource = "";
633
+ const __avSourceOk = __avExpectedSource ? __avSource === __avExpectedSource : Boolean(__avSource || state || runtime?.agentId || runtime?.getService);
634
+ const __avOptions = options && typeof options === "object" ? options : {};
635
+ const __avInputOk = __avText.trim().length > 0 || Object.keys(__avOptions).length > 0 || Boolean(message?.content && typeof message.content === "object");
636
+ if (!(__avKeywordOk && __avRegexOk && __avSourceOk && __avInputOk)) {
637
+ return false;
638
+ }
639
+ const __avLegacyValidate = async (_runtime, _message) => {
640
+ return true;
641
+ };
642
+ try {
643
+ return Boolean(await __avLegacyValidate(runtime, message, state, options));
644
+ } catch {
645
+ return false;
646
+ }
605
647
  },
606
648
  handler: async (runtime, message, _stateFromTrigger, _options, callback, _responses) => {
607
649
  const service = createScratchpadService(runtime);
@@ -674,8 +716,29 @@ var scratchpadListAction = {
674
716
  name: spec3.name,
675
717
  similes: spec3.similes ? [...spec3.similes] : [],
676
718
  description: spec3.description,
677
- validate: async (_runtime, _message) => {
678
- return true;
719
+ validate: async (runtime, message, state, options) => {
720
+ const __avTextRaw = typeof message?.content?.text === "string" ? message.content.text : "";
721
+ const __avText = __avTextRaw.toLowerCase();
722
+ const __avKeywords = ["scratchpad", "list"];
723
+ const __avKeywordOk = __avKeywords.length > 0 && __avKeywords.some((kw) => kw.length > 0 && __avText.includes(kw));
724
+ const __avRegex = new RegExp("\\b(?:scratchpad|list)\\b", "i");
725
+ const __avRegexOk = __avRegex.test(__avText);
726
+ const __avSource = String(message?.content?.source ?? message?.source ?? "");
727
+ const __avExpectedSource = "";
728
+ const __avSourceOk = __avExpectedSource ? __avSource === __avExpectedSource : Boolean(__avSource || state || runtime?.agentId || runtime?.getService);
729
+ const __avOptions = options && typeof options === "object" ? options : {};
730
+ const __avInputOk = __avText.trim().length > 0 || Object.keys(__avOptions).length > 0 || Boolean(message?.content && typeof message.content === "object");
731
+ if (!(__avKeywordOk && __avRegexOk && __avSourceOk && __avInputOk)) {
732
+ return false;
733
+ }
734
+ const __avLegacyValidate = async (_runtime, _message) => {
735
+ return true;
736
+ };
737
+ try {
738
+ return Boolean(await __avLegacyValidate(runtime, message, state, options));
739
+ } catch {
740
+ return false;
741
+ }
679
742
  },
680
743
  handler: async (runtime, message, _stateFromTrigger, _options, callback, _responses) => {
681
744
  try {
@@ -769,8 +832,29 @@ var scratchpadReadAction = {
769
832
  name: spec4.name,
770
833
  similes: spec4.similes ? [...spec4.similes] : [],
771
834
  description: spec4.description,
772
- validate: async (_runtime, _message) => {
773
- return true;
835
+ validate: async (runtime, message, state, options) => {
836
+ const __avTextRaw = typeof message?.content?.text === "string" ? message.content.text : "";
837
+ const __avText = __avTextRaw.toLowerCase();
838
+ const __avKeywords = ["scratchpad", "read"];
839
+ const __avKeywordOk = __avKeywords.length > 0 && __avKeywords.some((kw) => kw.length > 0 && __avText.includes(kw));
840
+ const __avRegex = new RegExp("\\b(?:scratchpad|read)\\b", "i");
841
+ const __avRegexOk = __avRegex.test(__avText);
842
+ const __avSource = String(message?.content?.source ?? message?.source ?? "");
843
+ const __avExpectedSource = "";
844
+ const __avSourceOk = __avExpectedSource ? __avSource === __avExpectedSource : Boolean(__avSource || state || runtime?.agentId || runtime?.getService);
845
+ const __avOptions = options && typeof options === "object" ? options : {};
846
+ const __avInputOk = __avText.trim().length > 0 || Object.keys(__avOptions).length > 0 || Boolean(message?.content && typeof message.content === "object");
847
+ if (!(__avKeywordOk && __avRegexOk && __avSourceOk && __avInputOk)) {
848
+ return false;
849
+ }
850
+ const __avLegacyValidate = async (_runtime, _message) => {
851
+ return true;
852
+ };
853
+ try {
854
+ return Boolean(await __avLegacyValidate(runtime, message, state, options));
855
+ } catch {
856
+ return false;
857
+ }
774
858
  },
775
859
  handler: async (runtime, message, _stateFromTrigger, _options, callback, _responses) => {
776
860
  const service = createScratchpadService(runtime);
@@ -871,10 +955,31 @@ var scratchpadSearchAction = {
871
955
  name: spec5.name,
872
956
  similes: spec5.similes ? [...spec5.similes] : [],
873
957
  description: spec5.description,
874
- validate: async (_runtime, message) => {
875
- const text = (message.content?.text ?? "").toLowerCase();
876
- const hasSearchIntent = text.includes("search") || text.includes("find") || text.includes("look for") || text.includes("scratchpad") || text.includes("notes") || text.includes("retrieve") || text.includes("lookup") || text.includes("what did i save");
877
- return hasSearchIntent;
958
+ validate: async (runtime, message, state, options) => {
959
+ const __avTextRaw = typeof message?.content?.text === "string" ? message.content.text : "";
960
+ const __avText = __avTextRaw.toLowerCase();
961
+ const __avKeywords = ["scratchpad", "search"];
962
+ const __avKeywordOk = __avKeywords.length > 0 && __avKeywords.some((kw) => kw.length > 0 && __avText.includes(kw));
963
+ const __avRegex = new RegExp("\\b(?:scratchpad|search)\\b", "i");
964
+ const __avRegexOk = __avRegex.test(__avText);
965
+ const __avSource = String(message?.content?.source ?? message?.source ?? "");
966
+ const __avExpectedSource = "";
967
+ const __avSourceOk = __avExpectedSource ? __avSource === __avExpectedSource : Boolean(__avSource || state || runtime?.agentId || runtime?.getService);
968
+ const __avOptions = options && typeof options === "object" ? options : {};
969
+ const __avInputOk = __avText.trim().length > 0 || Object.keys(__avOptions).length > 0 || Boolean(message?.content && typeof message.content === "object");
970
+ if (!(__avKeywordOk && __avRegexOk && __avSourceOk && __avInputOk)) {
971
+ return false;
972
+ }
973
+ const __avLegacyValidate = async (_runtime, message2) => {
974
+ const text = (message2.content?.text ?? "").toLowerCase();
975
+ const hasSearchIntent = text.includes("search") || text.includes("find") || text.includes("look for") || text.includes("scratchpad") || text.includes("notes") || text.includes("retrieve") || text.includes("lookup") || text.includes("what did i save");
976
+ return hasSearchIntent;
977
+ };
978
+ try {
979
+ return Boolean(await __avLegacyValidate(runtime, message, state, options));
980
+ } catch {
981
+ return false;
982
+ }
878
983
  },
879
984
  handler: async (runtime, message, _stateFromTrigger, _options, callback, _responses) => {
880
985
  const searchInfo = await extractSearchInfo(runtime, message);
@@ -987,10 +1092,31 @@ var scratchpadWriteAction = {
987
1092
  name: spec6.name,
988
1093
  similes: spec6.similes ? [...spec6.similes] : [],
989
1094
  description: spec6.description,
990
- validate: async (_runtime, message) => {
991
- const text = (message.content?.text ?? "").toLowerCase();
992
- const hasSaveIntent = text.includes("save") || text.includes("note") || text.includes("remember") || text.includes("write") || text.includes("scratchpad") || text.includes("jot down") || text.includes("store");
993
- return hasSaveIntent;
1095
+ validate: async (runtime, message, state, options) => {
1096
+ const __avTextRaw = typeof message?.content?.text === "string" ? message.content.text : "";
1097
+ const __avText = __avTextRaw.toLowerCase();
1098
+ const __avKeywords = ["scratchpad", "write"];
1099
+ const __avKeywordOk = __avKeywords.length > 0 && __avKeywords.some((kw) => kw.length > 0 && __avText.includes(kw));
1100
+ const __avRegex = new RegExp("\\b(?:scratchpad|write)\\b", "i");
1101
+ const __avRegexOk = __avRegex.test(__avText);
1102
+ const __avSource = String(message?.content?.source ?? message?.source ?? "");
1103
+ const __avExpectedSource = "";
1104
+ const __avSourceOk = __avExpectedSource ? __avSource === __avExpectedSource : Boolean(__avSource || state || runtime?.agentId || runtime?.getService);
1105
+ const __avOptions = options && typeof options === "object" ? options : {};
1106
+ const __avInputOk = __avText.trim().length > 0 || Object.keys(__avOptions).length > 0 || Boolean(message?.content && typeof message.content === "object");
1107
+ if (!(__avKeywordOk && __avRegexOk && __avSourceOk && __avInputOk)) {
1108
+ return false;
1109
+ }
1110
+ const __avLegacyValidate = async (_runtime, message2) => {
1111
+ const text = (message2.content?.text ?? "").toLowerCase();
1112
+ const hasSaveIntent = text.includes("save") || text.includes("note") || text.includes("remember") || text.includes("write") || text.includes("scratchpad") || text.includes("jot down") || text.includes("store");
1113
+ return hasSaveIntent;
1114
+ };
1115
+ try {
1116
+ return Boolean(await __avLegacyValidate(runtime, message, state, options));
1117
+ } catch {
1118
+ return false;
1119
+ }
994
1120
  },
995
1121
  handler: async (runtime, message, stateFromTrigger, _options, callback, _responses) => {
996
1122
  const state = stateFromTrigger ?? await runtime.composeState(message, []);
@@ -1037,10 +1163,35 @@ var scratchpadWriteAction = {
1037
1163
 
1038
1164
  // providers/scratchpad.ts
1039
1165
  var import_core8 = require("@elizaos/core");
1166
+ var import_core9 = require("@elizaos/core");
1040
1167
  var scratchpadProvider = {
1041
1168
  name: "scratchpad",
1042
1169
  description: "Provides information about the user's scratchpad entries - file-based notes and memories that persist across sessions.",
1170
+ dynamic: true,
1171
+ relevanceKeywords: [
1172
+ "scratchpad",
1173
+ "scratchpadprovider",
1174
+ "plugin",
1175
+ "status",
1176
+ "state",
1177
+ "context",
1178
+ "info",
1179
+ "details",
1180
+ "chat",
1181
+ "conversation",
1182
+ "agent",
1183
+ "room",
1184
+ "channel",
1185
+ "user"
1186
+ ],
1043
1187
  get: async (runtime, _message, _state) => {
1188
+ const __providerKeywords = ["scratchpad", "scratchpadprovider", "plugin", "status", "state", "context", "info", "details", "chat", "conversation", "agent", "room", "channel", "user"];
1189
+ const __providerRegex = new RegExp(`\\b(${__providerKeywords.join("|")})\\b`, "i");
1190
+ const __recentMessages = _state?.recentMessagesData || [];
1191
+ const __isRelevant = import_core9.validateActionKeywords(_message, __recentMessages, __providerKeywords) || import_core9.validateActionRegex(_message, __recentMessages, __providerRegex);
1192
+ if (!__isRelevant) {
1193
+ return { text: "" };
1194
+ }
1044
1195
  try {
1045
1196
  const service = createScratchpadService(runtime);
1046
1197
  const entries = await service.list();
@@ -1112,14 +1263,14 @@ var scratchpadPlugin = {
1112
1263
  ],
1113
1264
  async init(_config, _runtime) {
1114
1265
  try {
1115
- import_core9.logger.info("[ScratchpadPlugin] Initializing...");
1116
- import_core9.logger.info("[ScratchpadPlugin] Initialized successfully");
1266
+ import_core10.logger.info("[ScratchpadPlugin] Initializing...");
1267
+ import_core10.logger.info("[ScratchpadPlugin] Initialized successfully");
1117
1268
  } catch (error) {
1118
- import_core9.logger.error("[ScratchpadPlugin] Error initializing:", error instanceof Error ? error.message : String(error));
1269
+ import_core10.logger.error("[ScratchpadPlugin] Error initializing:", error instanceof Error ? error.message : String(error));
1119
1270
  throw error;
1120
1271
  }
1121
1272
  }
1122
1273
  };
1123
1274
  var typescript_default = scratchpadPlugin;
1124
1275
 
1125
- //# debugId=5719EF0D4A126C3364756E2164756E21
1276
+ //# debugId=1DD1935188500FEE64756E2164756E21