@elizaos/plugin-commands 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.
- package/dist/cjs/index.cjs +77 -37
- package/dist/cjs/index.cjs.map +10 -10
- package/dist/index.js +78 -38
- package/dist/index.js.map +10 -10
- package/package.json +96 -96
package/dist/cjs/index.cjs
CHANGED
|
@@ -417,7 +417,7 @@ function startsWithCommand(text) {
|
|
|
417
417
|
if (normalized === alias) {
|
|
418
418
|
return command;
|
|
419
419
|
}
|
|
420
|
-
if (normalized.startsWith(alias
|
|
420
|
+
if (normalized.startsWith(`${alias} `) || normalized.startsWith(`${alias}:`)) {
|
|
421
421
|
return command;
|
|
422
422
|
}
|
|
423
423
|
}
|
|
@@ -461,7 +461,7 @@ function parseCommand(text, definition) {
|
|
|
461
461
|
matchedAlias = alias;
|
|
462
462
|
break;
|
|
463
463
|
}
|
|
464
|
-
if (trimmed.toLowerCase().startsWith(normalized
|
|
464
|
+
if (trimmed.toLowerCase().startsWith(`${normalized} `) || trimmed.toLowerCase().startsWith(`${normalized}:`)) {
|
|
465
465
|
matchedAlias = alias;
|
|
466
466
|
break;
|
|
467
467
|
}
|
|
@@ -572,12 +572,20 @@ var commandsListAction = {
|
|
|
572
572
|
name: "COMMANDS_LIST",
|
|
573
573
|
description: "List all available commands with their aliases. Only activates for /commands or /cmds slash commands.",
|
|
574
574
|
similes: ["/commands", "/cmds"],
|
|
575
|
-
async
|
|
576
|
-
const
|
|
577
|
-
const
|
|
575
|
+
validate: async (runtime, message) => {
|
|
576
|
+
const textRaw = message.content?.text ?? "";
|
|
577
|
+
const text = textRaw.toLowerCase();
|
|
578
|
+
const hasKeyword = text.includes("/commands") || text.includes("/cmds") || text.includes("commands");
|
|
579
|
+
const hasRegex = /^(?:\/|!)\s*(?:commands|cmds)\b/i.test(textRaw);
|
|
580
|
+
const hasContext = Boolean(runtime?.agentId || message?.roomId || message?.content);
|
|
581
|
+
const hasInput = textRaw.trim().length > 0;
|
|
582
|
+
if (!(hasKeyword && hasRegex && hasContext && hasInput)) {
|
|
583
|
+
return false;
|
|
584
|
+
}
|
|
585
|
+
const detection = detectCommand(textRaw);
|
|
578
586
|
return detection.isCommand && detection.command?.key === "commands";
|
|
579
587
|
},
|
|
580
|
-
async handler(
|
|
588
|
+
async handler(_runtime, _message, _state, _options, callback) {
|
|
581
589
|
const commands = getEnabledCommands();
|
|
582
590
|
const lines = [`**Commands (${commands.length}):**
|
|
583
591
|
`];
|
|
@@ -598,9 +606,9 @@ var commandsListAction = {
|
|
|
598
606
|
},
|
|
599
607
|
examples: [
|
|
600
608
|
[
|
|
601
|
-
{
|
|
609
|
+
{ name: "user", content: { text: "/commands" } },
|
|
602
610
|
{
|
|
603
|
-
|
|
611
|
+
name: "assistant",
|
|
604
612
|
content: {
|
|
605
613
|
text: `**Commands (15):**
|
|
606
614
|
|
|
@@ -651,12 +659,20 @@ var helpAction = {
|
|
|
651
659
|
name: "HELP_COMMAND",
|
|
652
660
|
description: "Show available commands and their descriptions. Only activates for /help, /h, or /? slash commands.",
|
|
653
661
|
similes: ["/help", "/h", "/?"],
|
|
654
|
-
async
|
|
655
|
-
const
|
|
656
|
-
const
|
|
662
|
+
validate: async (runtime, message) => {
|
|
663
|
+
const textRaw = message.content?.text ?? "";
|
|
664
|
+
const text = textRaw.toLowerCase();
|
|
665
|
+
const hasKeyword = text.includes("/help") || text.includes("/h") || text.includes("/?");
|
|
666
|
+
const hasRegex = /^(?:\/|!)\s*(?:help|h|\?)(?:\s|$|:)/i.test(textRaw);
|
|
667
|
+
const hasContext = Boolean(runtime?.agentId || message?.roomId || message?.content);
|
|
668
|
+
const hasInput = textRaw.trim().length > 0;
|
|
669
|
+
if (!(hasKeyword && hasRegex && hasContext && hasInput)) {
|
|
670
|
+
return false;
|
|
671
|
+
}
|
|
672
|
+
const detection = detectCommand(textRaw);
|
|
657
673
|
return detection.isCommand && detection.command?.key === "help";
|
|
658
674
|
},
|
|
659
|
-
async handler(
|
|
675
|
+
async handler(_runtime, _message, _state, _options, callback) {
|
|
660
676
|
const commands = getEnabledCommands();
|
|
661
677
|
const helpText = formatCommandList(commands);
|
|
662
678
|
await callback?.({ text: helpText });
|
|
@@ -668,9 +684,9 @@ var helpAction = {
|
|
|
668
684
|
},
|
|
669
685
|
examples: [
|
|
670
686
|
[
|
|
671
|
-
{
|
|
687
|
+
{ name: "user", content: { text: "/help" } },
|
|
672
688
|
{
|
|
673
|
-
|
|
689
|
+
name: "assistant",
|
|
674
690
|
content: {
|
|
675
691
|
text: `**Available Commands:**
|
|
676
692
|
|
|
@@ -680,9 +696,9 @@ var helpAction = {
|
|
|
680
696
|
}
|
|
681
697
|
],
|
|
682
698
|
[
|
|
683
|
-
{
|
|
699
|
+
{ name: "user", content: { text: "/?" } },
|
|
684
700
|
{
|
|
685
|
-
|
|
701
|
+
name: "assistant",
|
|
686
702
|
content: {
|
|
687
703
|
text: `**Available Commands:**
|
|
688
704
|
|
|
@@ -720,12 +736,20 @@ var modelsAction = {
|
|
|
720
736
|
name: "MODELS_COMMAND",
|
|
721
737
|
description: "List available AI models and providers. Only activates for /models slash command.",
|
|
722
738
|
similes: ["/models"],
|
|
723
|
-
async
|
|
724
|
-
const
|
|
725
|
-
const
|
|
739
|
+
validate: async (runtime, message) => {
|
|
740
|
+
const textRaw = message.content?.text ?? "";
|
|
741
|
+
const text = textRaw.toLowerCase();
|
|
742
|
+
const hasKeyword = text.includes("/models") || text.includes("models");
|
|
743
|
+
const hasRegex = /^(?:\/|!)\s*models\b/i.test(textRaw);
|
|
744
|
+
const hasContext = Boolean(runtime?.agentId || message?.roomId || message?.content);
|
|
745
|
+
const hasInput = textRaw.trim().length > 0;
|
|
746
|
+
if (!(hasKeyword && hasRegex && hasContext && hasInput)) {
|
|
747
|
+
return false;
|
|
748
|
+
}
|
|
749
|
+
const detection = detectCommand(textRaw);
|
|
726
750
|
return detection.isCommand && detection.command?.key === "models";
|
|
727
751
|
},
|
|
728
|
-
async handler(runtime,
|
|
752
|
+
async handler(runtime, _message, _state, _options, callback) {
|
|
729
753
|
const lines = [`**Available Models:**
|
|
730
754
|
`];
|
|
731
755
|
try {
|
|
@@ -777,9 +801,9 @@ _Use /model <provider/model> to switch models._`);
|
|
|
777
801
|
},
|
|
778
802
|
examples: [
|
|
779
803
|
[
|
|
780
|
-
{
|
|
804
|
+
{ name: "user", content: { text: "/models" } },
|
|
781
805
|
{
|
|
782
|
-
|
|
806
|
+
name: "assistant",
|
|
783
807
|
content: {
|
|
784
808
|
text: "**Available Models:**\n\n**Registered Model Types:**\n• Text (Large) (`text_large`)\n• Text (Small) (`text_small`)..."
|
|
785
809
|
}
|
|
@@ -826,12 +850,20 @@ var statusAction = {
|
|
|
826
850
|
name: "STATUS_COMMAND",
|
|
827
851
|
description: "Show session directive settings via /status slash command. Only activates for /status or /s prefix.",
|
|
828
852
|
similes: ["/status", "/s"],
|
|
829
|
-
async
|
|
830
|
-
const
|
|
831
|
-
const
|
|
853
|
+
validate: async (runtime, message) => {
|
|
854
|
+
const textRaw = message.content?.text ?? "";
|
|
855
|
+
const text = textRaw.toLowerCase();
|
|
856
|
+
const hasKeyword = text.includes("/status") || text.includes("/s") || text.includes("status");
|
|
857
|
+
const hasRegex = /^(?:\/|!)\s*(?:status|s)\b/i.test(textRaw);
|
|
858
|
+
const hasContext = Boolean(runtime?.agentId || message?.roomId || message?.content);
|
|
859
|
+
const hasInput = textRaw.trim().length > 0;
|
|
860
|
+
if (!(hasKeyword && hasRegex && hasContext && hasInput)) {
|
|
861
|
+
return false;
|
|
862
|
+
}
|
|
863
|
+
const detection = detectCommand(textRaw);
|
|
832
864
|
return detection.isCommand && detection.command?.key === "status";
|
|
833
865
|
},
|
|
834
|
-
async handler(runtime, message,
|
|
866
|
+
async handler(runtime, message, _state, _options, callback) {
|
|
835
867
|
const statusText = await buildStatusReport(runtime, message.roomId);
|
|
836
868
|
await callback?.({ text: statusText });
|
|
837
869
|
return {
|
|
@@ -841,9 +873,9 @@ var statusAction = {
|
|
|
841
873
|
},
|
|
842
874
|
examples: [
|
|
843
875
|
[
|
|
844
|
-
{
|
|
876
|
+
{ name: "user", content: { text: "/status" } },
|
|
845
877
|
{
|
|
846
|
-
|
|
878
|
+
name: "assistant",
|
|
847
879
|
content: {
|
|
848
880
|
text: `**Session Status:**
|
|
849
881
|
|
|
@@ -864,12 +896,20 @@ var stopAction = {
|
|
|
864
896
|
name: "STOP_COMMAND",
|
|
865
897
|
description: "Stop current operation or abort running tasks. Triggered by /stop, /abort, or /cancel slash commands only.",
|
|
866
898
|
similes: ["/stop", "/abort", "/cancel"],
|
|
867
|
-
async
|
|
868
|
-
const
|
|
869
|
-
const
|
|
899
|
+
validate: async (runtime, message) => {
|
|
900
|
+
const textRaw = message.content?.text ?? "";
|
|
901
|
+
const text = textRaw.toLowerCase();
|
|
902
|
+
const hasKeyword = text.includes("/stop") || text.includes("/abort") || text.includes("/cancel") || text.includes("stop");
|
|
903
|
+
const hasRegex = /^(?:\/|!)\s*(?:stop|abort|cancel)\b/i.test(textRaw);
|
|
904
|
+
const hasContext = Boolean(runtime?.agentId || message?.roomId || message?.content);
|
|
905
|
+
const hasInput = textRaw.trim().length > 0;
|
|
906
|
+
if (!(hasKeyword && hasRegex && hasContext && hasInput)) {
|
|
907
|
+
return false;
|
|
908
|
+
}
|
|
909
|
+
const detection = detectCommand(textRaw);
|
|
870
910
|
return detection.isCommand && ["stop", "abort", "cancel"].includes(detection.command?.key ?? "");
|
|
871
911
|
},
|
|
872
|
-
async handler(runtime, message,
|
|
912
|
+
async handler(runtime, message, _state, _options, callback) {
|
|
873
913
|
try {
|
|
874
914
|
await runtime.emitEvent(import_core2.EventType.HOOK_COMMAND_STOP, {
|
|
875
915
|
runtime,
|
|
@@ -896,18 +936,18 @@ var stopAction = {
|
|
|
896
936
|
},
|
|
897
937
|
examples: [
|
|
898
938
|
[
|
|
899
|
-
{
|
|
939
|
+
{ name: "user", content: { text: "/stop" } },
|
|
900
940
|
{
|
|
901
|
-
|
|
941
|
+
name: "assistant",
|
|
902
942
|
content: {
|
|
903
943
|
text: "✓ Stop requested. Current operations will be cancelled."
|
|
904
944
|
}
|
|
905
945
|
}
|
|
906
946
|
],
|
|
907
947
|
[
|
|
908
|
-
{
|
|
948
|
+
{ name: "user", content: { text: "/abort" } },
|
|
909
949
|
{
|
|
910
|
-
|
|
950
|
+
name: "assistant",
|
|
911
951
|
content: {
|
|
912
952
|
text: "✓ Stop requested. Current operations will be cancelled."
|
|
913
953
|
}
|
|
@@ -1154,4 +1194,4 @@ var commandsPlugin = {
|
|
|
1154
1194
|
};
|
|
1155
1195
|
var src_default = commandsPlugin;
|
|
1156
1196
|
|
|
1157
|
-
//# debugId=
|
|
1197
|
+
//# debugId=82FB2D1F707579D364756E2164756E21
|