@elizaos/plugin-commands 2.0.0-alpha.4 → 2.0.0-alpha.537

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.
@@ -2,27 +2,37 @@ var __defProp = Object.defineProperty;
2
2
  var __getOwnPropNames = Object.getOwnPropertyNames;
3
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
4
  var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __moduleCache = /* @__PURE__ */ new WeakMap;
5
+ function __accessProp(key) {
6
+ return this[key];
7
+ }
6
8
  var __toCommonJS = (from) => {
7
- var entry = __moduleCache.get(from), desc;
9
+ var entry = (__moduleCache ??= new WeakMap).get(from), desc;
8
10
  if (entry)
9
11
  return entry;
10
12
  entry = __defProp({}, "__esModule", { value: true });
11
- if (from && typeof from === "object" || typeof from === "function")
12
- __getOwnPropNames(from).map((key) => !__hasOwnProp.call(entry, key) && __defProp(entry, key, {
13
- get: () => from[key],
14
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
15
- }));
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (var key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(entry, key))
16
+ __defProp(entry, key, {
17
+ get: __accessProp.bind(from, key),
18
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
19
+ });
20
+ }
16
21
  __moduleCache.set(from, entry);
17
22
  return entry;
18
23
  };
24
+ var __moduleCache;
25
+ var __returnValue = (v) => v;
26
+ function __exportSetter(name, newValue) {
27
+ this[name] = __returnValue.bind(null, newValue);
28
+ }
19
29
  var __export = (target, all) => {
20
30
  for (var name in all)
21
31
  __defProp(target, name, {
22
32
  get: all[name],
23
33
  enumerable: true,
24
34
  configurable: true,
25
- set: (newValue) => all[name] = () => newValue
35
+ set: __exportSetter.bind(all, name)
26
36
  });
27
37
  };
28
38
 
@@ -151,7 +161,9 @@ var DEFAULT_COMMANDS = [
151
161
  scope: "both",
152
162
  category: "session",
153
163
  acceptsArgs: true,
154
- args: [{ name: "instructions", description: "Optional compaction instructions" }]
164
+ args: [
165
+ { name: "instructions", description: "Optional compaction instructions" }
166
+ ]
155
167
  },
156
168
  {
157
169
  key: "think",
@@ -161,7 +173,9 @@ var DEFAULT_COMMANDS = [
161
173
  scope: "both",
162
174
  category: "options",
163
175
  acceptsArgs: true,
164
- args: [{ name: "level", description: "off, minimal, low, medium, high, xhigh" }]
176
+ args: [
177
+ { name: "level", description: "off, minimal, low, medium, high, xhigh" }
178
+ ]
165
179
  },
166
180
  {
167
181
  key: "verbose",
@@ -567,10 +581,19 @@ function extractCommand(text) {
567
581
  var commandsListAction = {
568
582
  name: "COMMANDS_LIST",
569
583
  description: "List all available commands with their aliases. Only activates for /commands or /cmds slash commands.",
584
+ descriptionCompressed: "List available commands. Trigger: /commands, /cmds.",
570
585
  similes: ["/commands", "/cmds"],
571
- async validate(_runtime, message) {
572
- const text = message.content?.text ?? "";
573
- const detection = detectCommand(text);
586
+ validate: async (runtime, message) => {
587
+ const textRaw = message.content?.text ?? "";
588
+ const text = textRaw.toLowerCase();
589
+ const hasKeyword = text.includes("/commands") || text.includes("/cmds") || text.includes("commands");
590
+ const hasRegex = /^(?:\/|!)\s*(?:commands|cmds)\b/i.test(textRaw);
591
+ const hasContext = Boolean(runtime?.agentId || message?.roomId || message?.content);
592
+ const hasInput = textRaw.trim().length > 0;
593
+ if (!(hasKeyword && hasRegex && hasContext && hasInput)) {
594
+ return false;
595
+ }
596
+ const detection = detectCommand(textRaw);
574
597
  return detection.isCommand && detection.command?.key === "commands";
575
598
  },
576
599
  async handler(_runtime, _message, _state, _options, callback) {
@@ -594,9 +617,9 @@ var commandsListAction = {
594
617
  },
595
618
  examples: [
596
619
  [
597
- { user: "user", content: { text: "/commands" } },
620
+ { name: "user", content: { text: "/commands" } },
598
621
  {
599
- user: "assistant",
622
+ name: "assistant",
600
623
  content: {
601
624
  text: `**Commands (15):**
602
625
 
@@ -646,13 +669,26 @@ function formatCommandList(commands) {
646
669
  var helpAction = {
647
670
  name: "HELP_COMMAND",
648
671
  description: "Show available commands and their descriptions. Only activates for /help, /h, or /? slash commands.",
672
+ descriptionCompressed: "Show commands and descriptions. Trigger: /help, /h, /?.",
649
673
  similes: ["/help", "/h", "/?"],
650
- async validate(_runtime, message) {
651
- const text = message.content?.text ?? "";
652
- const detection = detectCommand(text);
674
+ validate: async (runtime, message) => {
675
+ const textRaw = message.content?.text ?? "";
676
+ const text = textRaw.toLowerCase();
677
+ const hasKeyword = text.includes("/help") || text.includes("/h") || text.includes("/?");
678
+ const hasRegex = /^(?:\/|!)\s*(?:help|h|\?)(?:\s|$|:)/i.test(textRaw);
679
+ const hasContext = Boolean(runtime?.agentId || message?.roomId || message?.content);
680
+ const hasInput = textRaw.trim().length > 0;
681
+ if (!(hasKeyword && hasRegex && hasContext && hasInput)) {
682
+ return false;
683
+ }
684
+ const detection = detectCommand(textRaw);
653
685
  return detection.isCommand && detection.command?.key === "help";
654
686
  },
655
- async handler(_runtime, _message, _state, _options, callback) {
687
+ async handler(_runtime, message, _state, _options, callback) {
688
+ const detection = detectCommand(message?.content?.text ?? "");
689
+ if (!detection.isCommand || detection.command?.key !== "help") {
690
+ return { success: false, text: "" };
691
+ }
656
692
  const commands = getEnabledCommands();
657
693
  const helpText = formatCommandList(commands);
658
694
  await callback?.({ text: helpText });
@@ -664,9 +700,9 @@ var helpAction = {
664
700
  },
665
701
  examples: [
666
702
  [
667
- { user: "user", content: { text: "/help" } },
703
+ { name: "user", content: { text: "/help" } },
668
704
  {
669
- user: "assistant",
705
+ name: "assistant",
670
706
  content: {
671
707
  text: `**Available Commands:**
672
708
 
@@ -676,9 +712,9 @@ var helpAction = {
676
712
  }
677
713
  ],
678
714
  [
679
- { user: "user", content: { text: "/?" } },
715
+ { name: "user", content: { text: "/?" } },
680
716
  {
681
- user: "assistant",
717
+ name: "assistant",
682
718
  content: {
683
719
  text: `**Available Commands:**
684
720
 
@@ -696,8 +732,6 @@ function describeModelType(modelType) {
696
732
  const descriptions = {
697
733
  [import_core.ModelType.TEXT_SMALL]: "Text (Small)",
698
734
  [import_core.ModelType.TEXT_LARGE]: "Text (Large)",
699
- [import_core.ModelType.TEXT_REASONING_SMALL]: "Reasoning (Small)",
700
- [import_core.ModelType.TEXT_REASONING_LARGE]: "Reasoning (Large)",
701
735
  [import_core.ModelType.TEXT_COMPLETION]: "Text Completion",
702
736
  [import_core.ModelType.TEXT_EMBEDDING]: "Embedding",
703
737
  [import_core.ModelType.IMAGE]: "Image Generation",
@@ -715,10 +749,19 @@ function describeModelType(modelType) {
715
749
  var modelsAction = {
716
750
  name: "MODELS_COMMAND",
717
751
  description: "List available AI models and providers. Only activates for /models slash command.",
752
+ descriptionCompressed: "List AI models/providers. Trigger: /models.",
718
753
  similes: ["/models"],
719
- async validate(_runtime, message) {
720
- const text = message.content?.text ?? "";
721
- const detection = detectCommand(text);
754
+ validate: async (runtime, message) => {
755
+ const textRaw = message.content?.text ?? "";
756
+ const text = textRaw.toLowerCase();
757
+ const hasKeyword = text.includes("/models") || text.includes("models");
758
+ const hasRegex = /^(?:\/|!)\s*models\b/i.test(textRaw);
759
+ const hasContext = Boolean(runtime?.agentId || message?.roomId || message?.content);
760
+ const hasInput = textRaw.trim().length > 0;
761
+ if (!(hasKeyword && hasRegex && hasContext && hasInput)) {
762
+ return false;
763
+ }
764
+ const detection = detectCommand(textRaw);
722
765
  return detection.isCommand && detection.command?.key === "models";
723
766
  },
724
767
  async handler(runtime, _message, _state, _options, callback) {
@@ -773,9 +816,9 @@ _Use /model <provider/model> to switch models._`);
773
816
  },
774
817
  examples: [
775
818
  [
776
- { user: "user", content: { text: "/models" } },
819
+ { name: "user", content: { text: "/models" } },
777
820
  {
778
- user: "assistant",
821
+ name: "assistant",
779
822
  content: {
780
823
  text: "**Available Models:**\n\n**Registered Model Types:**\n• Text (Large) (`text_large`)\n• Text (Small) (`text_small`)..."
781
824
  }
@@ -809,7 +852,10 @@ async function buildStatusReport(runtime, roomId) {
809
852
  }
810
853
  } catch {}
811
854
  try {
812
- const tasks = await runtime.getTasks({ roomId });
855
+ const tasks = await runtime.getTasks({
856
+ roomId,
857
+ agentIds: [runtime.agentId]
858
+ });
813
859
  if (tasks.length > 0) {
814
860
  lines.push(`
815
861
  **Tasks:** ${tasks.length} pending`);
@@ -821,10 +867,19 @@ async function buildStatusReport(runtime, roomId) {
821
867
  var statusAction = {
822
868
  name: "STATUS_COMMAND",
823
869
  description: "Show session directive settings via /status slash command. Only activates for /status or /s prefix.",
870
+ descriptionCompressed: "Show session settings. Trigger: /status, /s.",
824
871
  similes: ["/status", "/s"],
825
- async validate(_runtime, message) {
826
- const text = message.content?.text ?? "";
827
- const detection = detectCommand(text);
872
+ validate: async (runtime, message) => {
873
+ const textRaw = message.content?.text ?? "";
874
+ const text = textRaw.toLowerCase();
875
+ const hasKeyword = text.includes("/status") || text.includes("/s") || text.includes("status");
876
+ const hasRegex = /^(?:\/|!)\s*(?:status|s)\b/i.test(textRaw);
877
+ const hasContext = Boolean(runtime?.agentId || message?.roomId || message?.content);
878
+ const hasInput = textRaw.trim().length > 0;
879
+ if (!(hasKeyword && hasRegex && hasContext && hasInput)) {
880
+ return false;
881
+ }
882
+ const detection = detectCommand(textRaw);
828
883
  return detection.isCommand && detection.command?.key === "status";
829
884
  },
830
885
  async handler(runtime, message, _state, _options, callback) {
@@ -837,9 +892,9 @@ var statusAction = {
837
892
  },
838
893
  examples: [
839
894
  [
840
- { user: "user", content: { text: "/status" } },
895
+ { name: "user", content: { text: "/status" } },
841
896
  {
842
- user: "assistant",
897
+ name: "assistant",
843
898
  content: {
844
899
  text: `**Session Status:**
845
900
 
@@ -859,10 +914,19 @@ var import_core2 = require("@elizaos/core");
859
914
  var stopAction = {
860
915
  name: "STOP_COMMAND",
861
916
  description: "Stop current operation or abort running tasks. Triggered by /stop, /abort, or /cancel slash commands only.",
917
+ descriptionCompressed: "Stop/abort running tasks. Trigger: /stop, /abort, /cancel.",
862
918
  similes: ["/stop", "/abort", "/cancel"],
863
- async validate(_runtime, message) {
864
- const text = message.content?.text ?? "";
865
- const detection = detectCommand(text);
919
+ validate: async (runtime, message) => {
920
+ const textRaw = message.content?.text ?? "";
921
+ const text = textRaw.toLowerCase();
922
+ const hasKeyword = text.includes("/stop") || text.includes("/abort") || text.includes("/cancel") || text.includes("stop");
923
+ const hasRegex = /^(?:\/|!)\s*(?:stop|abort|cancel)\b/i.test(textRaw);
924
+ const hasContext = Boolean(runtime?.agentId || message?.roomId || message?.content);
925
+ const hasInput = textRaw.trim().length > 0;
926
+ if (!(hasKeyword && hasRegex && hasContext && hasInput)) {
927
+ return false;
928
+ }
929
+ const detection = detectCommand(textRaw);
866
930
  return detection.isCommand && ["stop", "abort", "cancel"].includes(detection.command?.key ?? "");
867
931
  },
868
932
  async handler(runtime, message, _state, _options, callback) {
@@ -892,18 +956,18 @@ var stopAction = {
892
956
  },
893
957
  examples: [
894
958
  [
895
- { user: "user", content: { text: "/stop" } },
959
+ { name: "user", content: { text: "/stop" } },
896
960
  {
897
- user: "assistant",
961
+ name: "assistant",
898
962
  content: {
899
963
  text: "✓ Stop requested. Current operations will be cancelled."
900
964
  }
901
965
  }
902
966
  ],
903
967
  [
904
- { user: "user", content: { text: "/abort" } },
968
+ { name: "user", content: { text: "/abort" } },
905
969
  {
906
- user: "assistant",
970
+ name: "assistant",
907
971
  content: {
908
972
  text: "✓ Stop requested. Current operations will be cancelled."
909
973
  }
@@ -916,6 +980,7 @@ var stopAction = {
916
980
  var commandRegistryProvider = {
917
981
  name: "COMMAND_REGISTRY",
918
982
  description: "Available chat commands and their descriptions",
983
+ descriptionCompressed: "Available chat commands and descriptions.",
919
984
  dynamic: true,
920
985
  async get(runtime, message, _state) {
921
986
  useRuntime(runtime.agentId);
@@ -973,7 +1038,13 @@ var commandsPlugin = {
973
1038
  name: "commands",
974
1039
  description: "Chat command system with /help, /status, /reset, etc.",
975
1040
  providers: [commandRegistryProvider],
976
- actions: [helpAction, statusAction, stopAction, modelsAction, commandsListAction],
1041
+ actions: [
1042
+ helpAction,
1043
+ statusAction,
1044
+ stopAction,
1045
+ modelsAction,
1046
+ commandsListAction
1047
+ ],
977
1048
  config: {
978
1049
  COMMANDS_ENABLED: "true",
979
1050
  COMMANDS_CONFIG_ENABLED: "false",
@@ -1144,4 +1215,4 @@ var commandsPlugin = {
1144
1215
  };
1145
1216
  var src_default = commandsPlugin;
1146
1217
 
1147
- //# debugId=6FF2A15CEA611B5664756E2164756E21
1218
+ //# debugId=CE65926111087B2964756E2164756E21