@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.
package/dist/index.js CHANGED
@@ -97,7 +97,9 @@ var DEFAULT_COMMANDS = [
97
97
  scope: "both",
98
98
  category: "session",
99
99
  acceptsArgs: true,
100
- args: [{ name: "instructions", description: "Optional compaction instructions" }]
100
+ args: [
101
+ { name: "instructions", description: "Optional compaction instructions" }
102
+ ]
101
103
  },
102
104
  {
103
105
  key: "think",
@@ -107,7 +109,9 @@ var DEFAULT_COMMANDS = [
107
109
  scope: "both",
108
110
  category: "options",
109
111
  acceptsArgs: true,
110
- args: [{ name: "level", description: "off, minimal, low, medium, high, xhigh" }]
112
+ args: [
113
+ { name: "level", description: "off, minimal, low, medium, high, xhigh" }
114
+ ]
111
115
  },
112
116
  {
113
117
  key: "verbose",
@@ -513,10 +517,19 @@ function extractCommand(text) {
513
517
  var commandsListAction = {
514
518
  name: "COMMANDS_LIST",
515
519
  description: "List all available commands with their aliases. Only activates for /commands or /cmds slash commands.",
520
+ descriptionCompressed: "List available commands. Trigger: /commands, /cmds.",
516
521
  similes: ["/commands", "/cmds"],
517
- async validate(_runtime, message) {
518
- const text = message.content?.text ?? "";
519
- const detection = detectCommand(text);
522
+ validate: async (runtime, message) => {
523
+ const textRaw = message.content?.text ?? "";
524
+ const text = textRaw.toLowerCase();
525
+ const hasKeyword = text.includes("/commands") || text.includes("/cmds") || text.includes("commands");
526
+ const hasRegex = /^(?:\/|!)\s*(?:commands|cmds)\b/i.test(textRaw);
527
+ const hasContext = Boolean(runtime?.agentId || message?.roomId || message?.content);
528
+ const hasInput = textRaw.trim().length > 0;
529
+ if (!(hasKeyword && hasRegex && hasContext && hasInput)) {
530
+ return false;
531
+ }
532
+ const detection = detectCommand(textRaw);
520
533
  return detection.isCommand && detection.command?.key === "commands";
521
534
  },
522
535
  async handler(_runtime, _message, _state, _options, callback) {
@@ -540,9 +553,9 @@ var commandsListAction = {
540
553
  },
541
554
  examples: [
542
555
  [
543
- { user: "user", content: { text: "/commands" } },
556
+ { name: "user", content: { text: "/commands" } },
544
557
  {
545
- user: "assistant",
558
+ name: "assistant",
546
559
  content: {
547
560
  text: `**Commands (15):**
548
561
 
@@ -592,13 +605,26 @@ function formatCommandList(commands) {
592
605
  var helpAction = {
593
606
  name: "HELP_COMMAND",
594
607
  description: "Show available commands and their descriptions. Only activates for /help, /h, or /? slash commands.",
608
+ descriptionCompressed: "Show commands and descriptions. Trigger: /help, /h, /?.",
595
609
  similes: ["/help", "/h", "/?"],
596
- async validate(_runtime, message) {
597
- const text = message.content?.text ?? "";
598
- const detection = detectCommand(text);
610
+ validate: async (runtime, message) => {
611
+ const textRaw = message.content?.text ?? "";
612
+ const text = textRaw.toLowerCase();
613
+ const hasKeyword = text.includes("/help") || text.includes("/h") || text.includes("/?");
614
+ const hasRegex = /^(?:\/|!)\s*(?:help|h|\?)(?:\s|$|:)/i.test(textRaw);
615
+ const hasContext = Boolean(runtime?.agentId || message?.roomId || message?.content);
616
+ const hasInput = textRaw.trim().length > 0;
617
+ if (!(hasKeyword && hasRegex && hasContext && hasInput)) {
618
+ return false;
619
+ }
620
+ const detection = detectCommand(textRaw);
599
621
  return detection.isCommand && detection.command?.key === "help";
600
622
  },
601
- async handler(_runtime, _message, _state, _options, callback) {
623
+ async handler(_runtime, message, _state, _options, callback) {
624
+ const detection = detectCommand(message?.content?.text ?? "");
625
+ if (!detection.isCommand || detection.command?.key !== "help") {
626
+ return { success: false, text: "" };
627
+ }
602
628
  const commands = getEnabledCommands();
603
629
  const helpText = formatCommandList(commands);
604
630
  await callback?.({ text: helpText });
@@ -610,9 +636,9 @@ var helpAction = {
610
636
  },
611
637
  examples: [
612
638
  [
613
- { user: "user", content: { text: "/help" } },
639
+ { name: "user", content: { text: "/help" } },
614
640
  {
615
- user: "assistant",
641
+ name: "assistant",
616
642
  content: {
617
643
  text: `**Available Commands:**
618
644
 
@@ -622,9 +648,9 @@ var helpAction = {
622
648
  }
623
649
  ],
624
650
  [
625
- { user: "user", content: { text: "/?" } },
651
+ { name: "user", content: { text: "/?" } },
626
652
  {
627
- user: "assistant",
653
+ name: "assistant",
628
654
  content: {
629
655
  text: `**Available Commands:**
630
656
 
@@ -642,8 +668,6 @@ function describeModelType(modelType) {
642
668
  const descriptions = {
643
669
  [ModelType.TEXT_SMALL]: "Text (Small)",
644
670
  [ModelType.TEXT_LARGE]: "Text (Large)",
645
- [ModelType.TEXT_REASONING_SMALL]: "Reasoning (Small)",
646
- [ModelType.TEXT_REASONING_LARGE]: "Reasoning (Large)",
647
671
  [ModelType.TEXT_COMPLETION]: "Text Completion",
648
672
  [ModelType.TEXT_EMBEDDING]: "Embedding",
649
673
  [ModelType.IMAGE]: "Image Generation",
@@ -661,10 +685,19 @@ function describeModelType(modelType) {
661
685
  var modelsAction = {
662
686
  name: "MODELS_COMMAND",
663
687
  description: "List available AI models and providers. Only activates for /models slash command.",
688
+ descriptionCompressed: "List AI models/providers. Trigger: /models.",
664
689
  similes: ["/models"],
665
- async validate(_runtime, message) {
666
- const text = message.content?.text ?? "";
667
- const detection = detectCommand(text);
690
+ validate: async (runtime, message) => {
691
+ const textRaw = message.content?.text ?? "";
692
+ const text = textRaw.toLowerCase();
693
+ const hasKeyword = text.includes("/models") || text.includes("models");
694
+ const hasRegex = /^(?:\/|!)\s*models\b/i.test(textRaw);
695
+ const hasContext = Boolean(runtime?.agentId || message?.roomId || message?.content);
696
+ const hasInput = textRaw.trim().length > 0;
697
+ if (!(hasKeyword && hasRegex && hasContext && hasInput)) {
698
+ return false;
699
+ }
700
+ const detection = detectCommand(textRaw);
668
701
  return detection.isCommand && detection.command?.key === "models";
669
702
  },
670
703
  async handler(runtime, _message, _state, _options, callback) {
@@ -719,9 +752,9 @@ _Use /model <provider/model> to switch models._`);
719
752
  },
720
753
  examples: [
721
754
  [
722
- { user: "user", content: { text: "/models" } },
755
+ { name: "user", content: { text: "/models" } },
723
756
  {
724
- user: "assistant",
757
+ name: "assistant",
725
758
  content: {
726
759
  text: "**Available Models:**\n\n**Registered Model Types:**\n• Text (Large) (`text_large`)\n• Text (Small) (`text_small`)..."
727
760
  }
@@ -755,7 +788,10 @@ async function buildStatusReport(runtime, roomId) {
755
788
  }
756
789
  } catch {}
757
790
  try {
758
- const tasks = await runtime.getTasks({ roomId });
791
+ const tasks = await runtime.getTasks({
792
+ roomId,
793
+ agentIds: [runtime.agentId]
794
+ });
759
795
  if (tasks.length > 0) {
760
796
  lines.push(`
761
797
  **Tasks:** ${tasks.length} pending`);
@@ -767,10 +803,19 @@ async function buildStatusReport(runtime, roomId) {
767
803
  var statusAction = {
768
804
  name: "STATUS_COMMAND",
769
805
  description: "Show session directive settings via /status slash command. Only activates for /status or /s prefix.",
806
+ descriptionCompressed: "Show session settings. Trigger: /status, /s.",
770
807
  similes: ["/status", "/s"],
771
- async validate(_runtime, message) {
772
- const text = message.content?.text ?? "";
773
- const detection = detectCommand(text);
808
+ validate: async (runtime, message) => {
809
+ const textRaw = message.content?.text ?? "";
810
+ const text = textRaw.toLowerCase();
811
+ const hasKeyword = text.includes("/status") || text.includes("/s") || text.includes("status");
812
+ const hasRegex = /^(?:\/|!)\s*(?:status|s)\b/i.test(textRaw);
813
+ const hasContext = Boolean(runtime?.agentId || message?.roomId || message?.content);
814
+ const hasInput = textRaw.trim().length > 0;
815
+ if (!(hasKeyword && hasRegex && hasContext && hasInput)) {
816
+ return false;
817
+ }
818
+ const detection = detectCommand(textRaw);
774
819
  return detection.isCommand && detection.command?.key === "status";
775
820
  },
776
821
  async handler(runtime, message, _state, _options, callback) {
@@ -783,9 +828,9 @@ var statusAction = {
783
828
  },
784
829
  examples: [
785
830
  [
786
- { user: "user", content: { text: "/status" } },
831
+ { name: "user", content: { text: "/status" } },
787
832
  {
788
- user: "assistant",
833
+ name: "assistant",
789
834
  content: {
790
835
  text: `**Session Status:**
791
836
 
@@ -805,10 +850,19 @@ import { EventType, logger as logger2 } from "@elizaos/core";
805
850
  var stopAction = {
806
851
  name: "STOP_COMMAND",
807
852
  description: "Stop current operation or abort running tasks. Triggered by /stop, /abort, or /cancel slash commands only.",
853
+ descriptionCompressed: "Stop/abort running tasks. Trigger: /stop, /abort, /cancel.",
808
854
  similes: ["/stop", "/abort", "/cancel"],
809
- async validate(_runtime, message) {
810
- const text = message.content?.text ?? "";
811
- const detection = detectCommand(text);
855
+ validate: async (runtime, message) => {
856
+ const textRaw = message.content?.text ?? "";
857
+ const text = textRaw.toLowerCase();
858
+ const hasKeyword = text.includes("/stop") || text.includes("/abort") || text.includes("/cancel") || text.includes("stop");
859
+ const hasRegex = /^(?:\/|!)\s*(?:stop|abort|cancel)\b/i.test(textRaw);
860
+ const hasContext = Boolean(runtime?.agentId || message?.roomId || message?.content);
861
+ const hasInput = textRaw.trim().length > 0;
862
+ if (!(hasKeyword && hasRegex && hasContext && hasInput)) {
863
+ return false;
864
+ }
865
+ const detection = detectCommand(textRaw);
812
866
  return detection.isCommand && ["stop", "abort", "cancel"].includes(detection.command?.key ?? "");
813
867
  },
814
868
  async handler(runtime, message, _state, _options, callback) {
@@ -838,18 +892,18 @@ var stopAction = {
838
892
  },
839
893
  examples: [
840
894
  [
841
- { user: "user", content: { text: "/stop" } },
895
+ { name: "user", content: { text: "/stop" } },
842
896
  {
843
- user: "assistant",
897
+ name: "assistant",
844
898
  content: {
845
899
  text: "✓ Stop requested. Current operations will be cancelled."
846
900
  }
847
901
  }
848
902
  ],
849
903
  [
850
- { user: "user", content: { text: "/abort" } },
904
+ { name: "user", content: { text: "/abort" } },
851
905
  {
852
- user: "assistant",
906
+ name: "assistant",
853
907
  content: {
854
908
  text: "✓ Stop requested. Current operations will be cancelled."
855
909
  }
@@ -862,6 +916,7 @@ var stopAction = {
862
916
  var commandRegistryProvider = {
863
917
  name: "COMMAND_REGISTRY",
864
918
  description: "Available chat commands and their descriptions",
919
+ descriptionCompressed: "Available chat commands and descriptions.",
865
920
  dynamic: true,
866
921
  async get(runtime, message, _state) {
867
922
  useRuntime(runtime.agentId);
@@ -919,7 +974,13 @@ var commandsPlugin = {
919
974
  name: "commands",
920
975
  description: "Chat command system with /help, /status, /reset, etc.",
921
976
  providers: [commandRegistryProvider],
922
- actions: [helpAction, statusAction, stopAction, modelsAction, commandsListAction],
977
+ actions: [
978
+ helpAction,
979
+ statusAction,
980
+ stopAction,
981
+ modelsAction,
982
+ commandsListAction
983
+ ],
923
984
  config: {
924
985
  COMMANDS_ENABLED: "true",
925
986
  COMMANDS_CONFIG_ENABLED: "false",
@@ -1116,4 +1177,4 @@ export {
1116
1177
  commandRegistryProvider
1117
1178
  };
1118
1179
 
1119
- //# debugId=0433499C9EE6AF7764756E2164756E21
1180
+ //# debugId=CAE533D89EAF426E64756E2164756E21