@elizaos/plugin-commands 2.0.0-alpha.5 → 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
 
@@ -417,7 +427,7 @@ function startsWithCommand(text) {
417
427
  if (normalized === alias) {
418
428
  return command;
419
429
  }
420
- if (normalized.startsWith(alias + " ") || normalized.startsWith(alias + ":")) {
430
+ if (normalized.startsWith(`${alias} `) || normalized.startsWith(`${alias}:`)) {
421
431
  return command;
422
432
  }
423
433
  }
@@ -461,7 +471,7 @@ function parseCommand(text, definition) {
461
471
  matchedAlias = alias;
462
472
  break;
463
473
  }
464
- if (trimmed.toLowerCase().startsWith(normalized + " ") || trimmed.toLowerCase().startsWith(normalized + ":")) {
474
+ if (trimmed.toLowerCase().startsWith(`${normalized} `) || trimmed.toLowerCase().startsWith(`${normalized}:`)) {
465
475
  matchedAlias = alias;
466
476
  break;
467
477
  }
@@ -571,13 +581,22 @@ function extractCommand(text) {
571
581
  var commandsListAction = {
572
582
  name: "COMMANDS_LIST",
573
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.",
574
585
  similes: ["/commands", "/cmds"],
575
- async validate(runtime, message) {
576
- const text = message.content?.text ?? "";
577
- 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);
578
597
  return detection.isCommand && detection.command?.key === "commands";
579
598
  },
580
- async handler(runtime, message, state, options, callback) {
599
+ async handler(_runtime, _message, _state, _options, callback) {
581
600
  const commands = getEnabledCommands();
582
601
  const lines = [`**Commands (${commands.length}):**
583
602
  `];
@@ -598,9 +617,9 @@ var commandsListAction = {
598
617
  },
599
618
  examples: [
600
619
  [
601
- { user: "user", content: { text: "/commands" } },
620
+ { name: "user", content: { text: "/commands" } },
602
621
  {
603
- user: "assistant",
622
+ name: "assistant",
604
623
  content: {
605
624
  text: `**Commands (15):**
606
625
 
@@ -650,13 +669,26 @@ function formatCommandList(commands) {
650
669
  var helpAction = {
651
670
  name: "HELP_COMMAND",
652
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, /?.",
653
673
  similes: ["/help", "/h", "/?"],
654
- async validate(runtime, message) {
655
- const text = message.content?.text ?? "";
656
- 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);
657
685
  return detection.isCommand && detection.command?.key === "help";
658
686
  },
659
- 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
+ }
660
692
  const commands = getEnabledCommands();
661
693
  const helpText = formatCommandList(commands);
662
694
  await callback?.({ text: helpText });
@@ -668,9 +700,9 @@ var helpAction = {
668
700
  },
669
701
  examples: [
670
702
  [
671
- { user: "user", content: { text: "/help" } },
703
+ { name: "user", content: { text: "/help" } },
672
704
  {
673
- user: "assistant",
705
+ name: "assistant",
674
706
  content: {
675
707
  text: `**Available Commands:**
676
708
 
@@ -680,9 +712,9 @@ var helpAction = {
680
712
  }
681
713
  ],
682
714
  [
683
- { user: "user", content: { text: "/?" } },
715
+ { name: "user", content: { text: "/?" } },
684
716
  {
685
- user: "assistant",
717
+ name: "assistant",
686
718
  content: {
687
719
  text: `**Available Commands:**
688
720
 
@@ -700,8 +732,6 @@ function describeModelType(modelType) {
700
732
  const descriptions = {
701
733
  [import_core.ModelType.TEXT_SMALL]: "Text (Small)",
702
734
  [import_core.ModelType.TEXT_LARGE]: "Text (Large)",
703
- [import_core.ModelType.TEXT_REASONING_SMALL]: "Reasoning (Small)",
704
- [import_core.ModelType.TEXT_REASONING_LARGE]: "Reasoning (Large)",
705
735
  [import_core.ModelType.TEXT_COMPLETION]: "Text Completion",
706
736
  [import_core.ModelType.TEXT_EMBEDDING]: "Embedding",
707
737
  [import_core.ModelType.IMAGE]: "Image Generation",
@@ -719,13 +749,22 @@ function describeModelType(modelType) {
719
749
  var modelsAction = {
720
750
  name: "MODELS_COMMAND",
721
751
  description: "List available AI models and providers. Only activates for /models slash command.",
752
+ descriptionCompressed: "List AI models/providers. Trigger: /models.",
722
753
  similes: ["/models"],
723
- async validate(runtime, message) {
724
- const text = message.content?.text ?? "";
725
- 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);
726
765
  return detection.isCommand && detection.command?.key === "models";
727
766
  },
728
- async handler(runtime, message, state, options, callback) {
767
+ async handler(runtime, _message, _state, _options, callback) {
729
768
  const lines = [`**Available Models:**
730
769
  `];
731
770
  try {
@@ -777,9 +816,9 @@ _Use /model <provider/model> to switch models._`);
777
816
  },
778
817
  examples: [
779
818
  [
780
- { user: "user", content: { text: "/models" } },
819
+ { name: "user", content: { text: "/models" } },
781
820
  {
782
- user: "assistant",
821
+ name: "assistant",
783
822
  content: {
784
823
  text: "**Available Models:**\n\n**Registered Model Types:**\n• Text (Large) (`text_large`)\n• Text (Small) (`text_small`)..."
785
824
  }
@@ -813,7 +852,10 @@ async function buildStatusReport(runtime, roomId) {
813
852
  }
814
853
  } catch {}
815
854
  try {
816
- const tasks = await runtime.getTasks({ roomId });
855
+ const tasks = await runtime.getTasks({
856
+ roomId,
857
+ agentIds: [runtime.agentId]
858
+ });
817
859
  if (tasks.length > 0) {
818
860
  lines.push(`
819
861
  **Tasks:** ${tasks.length} pending`);
@@ -825,13 +867,22 @@ async function buildStatusReport(runtime, roomId) {
825
867
  var statusAction = {
826
868
  name: "STATUS_COMMAND",
827
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.",
828
871
  similes: ["/status", "/s"],
829
- async validate(runtime, message) {
830
- const text = message.content?.text ?? "";
831
- 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);
832
883
  return detection.isCommand && detection.command?.key === "status";
833
884
  },
834
- async handler(runtime, message, state, options, callback) {
885
+ async handler(runtime, message, _state, _options, callback) {
835
886
  const statusText = await buildStatusReport(runtime, message.roomId);
836
887
  await callback?.({ text: statusText });
837
888
  return {
@@ -841,9 +892,9 @@ var statusAction = {
841
892
  },
842
893
  examples: [
843
894
  [
844
- { user: "user", content: { text: "/status" } },
895
+ { name: "user", content: { text: "/status" } },
845
896
  {
846
- user: "assistant",
897
+ name: "assistant",
847
898
  content: {
848
899
  text: `**Session Status:**
849
900
 
@@ -863,13 +914,22 @@ var import_core2 = require("@elizaos/core");
863
914
  var stopAction = {
864
915
  name: "STOP_COMMAND",
865
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.",
866
918
  similes: ["/stop", "/abort", "/cancel"],
867
- async validate(runtime, message) {
868
- const text = message.content?.text ?? "";
869
- 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);
870
930
  return detection.isCommand && ["stop", "abort", "cancel"].includes(detection.command?.key ?? "");
871
931
  },
872
- async handler(runtime, message, state, options, callback) {
932
+ async handler(runtime, message, _state, _options, callback) {
873
933
  try {
874
934
  await runtime.emitEvent(import_core2.EventType.HOOK_COMMAND_STOP, {
875
935
  runtime,
@@ -896,18 +956,18 @@ var stopAction = {
896
956
  },
897
957
  examples: [
898
958
  [
899
- { user: "user", content: { text: "/stop" } },
959
+ { name: "user", content: { text: "/stop" } },
900
960
  {
901
- user: "assistant",
961
+ name: "assistant",
902
962
  content: {
903
963
  text: "✓ Stop requested. Current operations will be cancelled."
904
964
  }
905
965
  }
906
966
  ],
907
967
  [
908
- { user: "user", content: { text: "/abort" } },
968
+ { name: "user", content: { text: "/abort" } },
909
969
  {
910
- user: "assistant",
970
+ name: "assistant",
911
971
  content: {
912
972
  text: "✓ Stop requested. Current operations will be cancelled."
913
973
  }
@@ -920,6 +980,7 @@ var stopAction = {
920
980
  var commandRegistryProvider = {
921
981
  name: "COMMAND_REGISTRY",
922
982
  description: "Available chat commands and their descriptions",
983
+ descriptionCompressed: "Available chat commands and descriptions.",
923
984
  dynamic: true,
924
985
  async get(runtime, message, _state) {
925
986
  useRuntime(runtime.agentId);
@@ -1154,4 +1215,4 @@ var commandsPlugin = {
1154
1215
  };
1155
1216
  var src_default = commandsPlugin;
1156
1217
 
1157
- //# debugId=C959FE7FE395530C64756E2164756E21
1218
+ //# debugId=CE65926111087B2964756E2164756E21