@elizaos/plugin-commands 2.0.0-alpha.8 → 2.0.0-beta.1
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/auto-enable.ts +24 -0
- package/dist/cjs/index.cjs +23 -408
- package/dist/cjs/index.cjs.map +5 -10
- package/dist/index.js +23 -408
- package/dist/index.js.map +5 -10
- package/package.json +105 -96
package/auto-enable.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// Auto-enable check for @elizaos/plugin-commands.
|
|
2
|
+
//
|
|
3
|
+
// Plugin manifest entry-point — referenced by package.json's
|
|
4
|
+
// `elizaos.plugin.autoEnableModule`. Keep this module light: env reads only,
|
|
5
|
+
// no service init, no transitive imports of the full plugin runtime. The
|
|
6
|
+
// auto-enable engine loads dozens of these per boot.
|
|
7
|
+
import type { PluginAutoEnableContext } from "@elizaos/core";
|
|
8
|
+
|
|
9
|
+
function isFeatureEnabled(
|
|
10
|
+
config: PluginAutoEnableContext["config"],
|
|
11
|
+
key: string,
|
|
12
|
+
): boolean {
|
|
13
|
+
const f = (config?.features as Record<string, unknown> | undefined)?.[key];
|
|
14
|
+
if (f === true) return true;
|
|
15
|
+
if (f && typeof f === "object" && f !== null) {
|
|
16
|
+
return (f as Record<string, unknown>).enabled !== false;
|
|
17
|
+
}
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** Enable when `config.features.commands` is truthy / not explicitly disabled. */
|
|
22
|
+
export function shouldEnable(ctx: PluginAutoEnableContext): boolean {
|
|
23
|
+
return isFeatureEnabled(ctx.config, "commands");
|
|
24
|
+
}
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -65,7 +65,7 @@ __export(exports_src, {
|
|
|
65
65
|
commandRegistryProvider: () => commandRegistryProvider
|
|
66
66
|
});
|
|
67
67
|
module.exports = __toCommonJS(exports_src);
|
|
68
|
-
var
|
|
68
|
+
var import_core = require("@elizaos/core");
|
|
69
69
|
|
|
70
70
|
// src/registry.ts
|
|
71
71
|
var DEFAULT_COMMANDS = [
|
|
@@ -577,400 +577,16 @@ function extractCommand(text) {
|
|
|
577
577
|
return { command, remainingText: command.rawArgs };
|
|
578
578
|
}
|
|
579
579
|
|
|
580
|
-
// src/actions/commands-list.ts
|
|
581
|
-
var commandsListAction = {
|
|
582
|
-
name: "COMMANDS_LIST",
|
|
583
|
-
description: "List all available commands with their aliases. Only activates for /commands or /cmds slash commands.",
|
|
584
|
-
similes: ["/commands", "/cmds"],
|
|
585
|
-
validate: async (runtime, message) => {
|
|
586
|
-
const textRaw = message.content?.text ?? "";
|
|
587
|
-
const text = textRaw.toLowerCase();
|
|
588
|
-
const hasKeyword = text.includes("/commands") || text.includes("/cmds") || text.includes("commands");
|
|
589
|
-
const hasRegex = /^(?:\/|!)\s*(?:commands|cmds)\b/i.test(textRaw);
|
|
590
|
-
const hasContext = Boolean(runtime?.agentId || message?.roomId || message?.content);
|
|
591
|
-
const hasInput = textRaw.trim().length > 0;
|
|
592
|
-
if (!(hasKeyword && hasRegex && hasContext && hasInput)) {
|
|
593
|
-
return false;
|
|
594
|
-
}
|
|
595
|
-
const detection = detectCommand(textRaw);
|
|
596
|
-
return detection.isCommand && detection.command?.key === "commands";
|
|
597
|
-
},
|
|
598
|
-
async handler(_runtime, _message, _state, _options, callback) {
|
|
599
|
-
const commands = getEnabledCommands();
|
|
600
|
-
const lines = [`**Commands (${commands.length}):**
|
|
601
|
-
`];
|
|
602
|
-
for (const cmd of commands) {
|
|
603
|
-
const aliases = cmd.textAliases.join(", ");
|
|
604
|
-
const authNote = cmd.requiresAuth ? " [auth]" : "";
|
|
605
|
-
const elevatedNote = cmd.requiresElevated ? " [elevated]" : "";
|
|
606
|
-
lines.push(`• **${cmd.key}**: ${aliases}${authNote}${elevatedNote}`);
|
|
607
|
-
}
|
|
608
|
-
const replyText = lines.join(`
|
|
609
|
-
`);
|
|
610
|
-
await callback?.({ text: replyText });
|
|
611
|
-
return {
|
|
612
|
-
success: true,
|
|
613
|
-
text: replyText,
|
|
614
|
-
data: { commandCount: commands.length }
|
|
615
|
-
};
|
|
616
|
-
},
|
|
617
|
-
examples: [
|
|
618
|
-
[
|
|
619
|
-
{ name: "user", content: { text: "/commands" } },
|
|
620
|
-
{
|
|
621
|
-
name: "assistant",
|
|
622
|
-
content: {
|
|
623
|
-
text: `**Commands (15):**
|
|
624
|
-
|
|
625
|
-
• **help**: /help, /h, /?
|
|
626
|
-
• **status**: /status, /s...`
|
|
627
|
-
}
|
|
628
|
-
}
|
|
629
|
-
]
|
|
630
|
-
]
|
|
631
|
-
};
|
|
632
|
-
|
|
633
|
-
// src/actions/help.ts
|
|
634
|
-
function formatCommandList(commands) {
|
|
635
|
-
const lines = [`**Available Commands:**
|
|
636
|
-
`];
|
|
637
|
-
const categories = [
|
|
638
|
-
{ key: "status", name: "Status" },
|
|
639
|
-
{ key: "session", name: "Session" },
|
|
640
|
-
{ key: "options", name: "Options" },
|
|
641
|
-
{ key: "management", name: "Management" },
|
|
642
|
-
{ key: "media", name: "Media" },
|
|
643
|
-
{ key: "tools", name: "Tools" }
|
|
644
|
-
];
|
|
645
|
-
for (const cat of categories) {
|
|
646
|
-
const catCommands = commands.filter((c) => c.category === cat.key);
|
|
647
|
-
if (catCommands.length === 0)
|
|
648
|
-
continue;
|
|
649
|
-
lines.push(`
|
|
650
|
-
**${cat.name}:**`);
|
|
651
|
-
for (const cmd of catCommands) {
|
|
652
|
-
const aliases = cmd.textAliases.slice(0, 2).join(", ");
|
|
653
|
-
lines.push(`• ${aliases} - ${cmd.description}`);
|
|
654
|
-
}
|
|
655
|
-
}
|
|
656
|
-
const uncategorized = commands.filter((c) => !c.category);
|
|
657
|
-
if (uncategorized.length > 0) {
|
|
658
|
-
lines.push(`
|
|
659
|
-
**Other:**`);
|
|
660
|
-
for (const cmd of uncategorized) {
|
|
661
|
-
const aliases = cmd.textAliases.slice(0, 2).join(", ");
|
|
662
|
-
lines.push(`• ${aliases} - ${cmd.description}`);
|
|
663
|
-
}
|
|
664
|
-
}
|
|
665
|
-
return lines.join(`
|
|
666
|
-
`);
|
|
667
|
-
}
|
|
668
|
-
var helpAction = {
|
|
669
|
-
name: "HELP_COMMAND",
|
|
670
|
-
description: "Show available commands and their descriptions. Only activates for /help, /h, or /? slash commands.",
|
|
671
|
-
similes: ["/help", "/h", "/?"],
|
|
672
|
-
validate: async (runtime, message) => {
|
|
673
|
-
const textRaw = message.content?.text ?? "";
|
|
674
|
-
const text = textRaw.toLowerCase();
|
|
675
|
-
const hasKeyword = text.includes("/help") || text.includes("/h") || text.includes("/?");
|
|
676
|
-
const hasRegex = /^(?:\/|!)\s*(?:help|h|\?)(?:\s|$|:)/i.test(textRaw);
|
|
677
|
-
const hasContext = Boolean(runtime?.agentId || message?.roomId || message?.content);
|
|
678
|
-
const hasInput = textRaw.trim().length > 0;
|
|
679
|
-
if (!(hasKeyword && hasRegex && hasContext && hasInput)) {
|
|
680
|
-
return false;
|
|
681
|
-
}
|
|
682
|
-
const detection = detectCommand(textRaw);
|
|
683
|
-
return detection.isCommand && detection.command?.key === "help";
|
|
684
|
-
},
|
|
685
|
-
async handler(_runtime, _message, _state, _options, callback) {
|
|
686
|
-
const commands = getEnabledCommands();
|
|
687
|
-
const helpText = formatCommandList(commands);
|
|
688
|
-
await callback?.({ text: helpText });
|
|
689
|
-
return {
|
|
690
|
-
success: true,
|
|
691
|
-
text: helpText,
|
|
692
|
-
data: { commandCount: commands.length }
|
|
693
|
-
};
|
|
694
|
-
},
|
|
695
|
-
examples: [
|
|
696
|
-
[
|
|
697
|
-
{ name: "user", content: { text: "/help" } },
|
|
698
|
-
{
|
|
699
|
-
name: "assistant",
|
|
700
|
-
content: {
|
|
701
|
-
text: `**Available Commands:**
|
|
702
|
-
|
|
703
|
-
**Status:**
|
|
704
|
-
• /help - Show available commands...`
|
|
705
|
-
}
|
|
706
|
-
}
|
|
707
|
-
],
|
|
708
|
-
[
|
|
709
|
-
{ name: "user", content: { text: "/?" } },
|
|
710
|
-
{
|
|
711
|
-
name: "assistant",
|
|
712
|
-
content: {
|
|
713
|
-
text: `**Available Commands:**
|
|
714
|
-
|
|
715
|
-
**Status:**
|
|
716
|
-
• /help - Show available commands...`
|
|
717
|
-
}
|
|
718
|
-
}
|
|
719
|
-
]
|
|
720
|
-
]
|
|
721
|
-
};
|
|
722
|
-
|
|
723
|
-
// src/actions/models.ts
|
|
724
|
-
var import_core = require("@elizaos/core");
|
|
725
|
-
function describeModelType(modelType) {
|
|
726
|
-
const descriptions = {
|
|
727
|
-
[import_core.ModelType.TEXT_SMALL]: "Text (Small)",
|
|
728
|
-
[import_core.ModelType.TEXT_LARGE]: "Text (Large)",
|
|
729
|
-
[import_core.ModelType.TEXT_REASONING_SMALL]: "Reasoning (Small)",
|
|
730
|
-
[import_core.ModelType.TEXT_REASONING_LARGE]: "Reasoning (Large)",
|
|
731
|
-
[import_core.ModelType.TEXT_COMPLETION]: "Text Completion",
|
|
732
|
-
[import_core.ModelType.TEXT_EMBEDDING]: "Embedding",
|
|
733
|
-
[import_core.ModelType.IMAGE]: "Image Generation",
|
|
734
|
-
[import_core.ModelType.IMAGE_DESCRIPTION]: "Image Description",
|
|
735
|
-
[import_core.ModelType.TRANSCRIPTION]: "Transcription",
|
|
736
|
-
[import_core.ModelType.TEXT_TO_SPEECH]: "Text-to-Speech",
|
|
737
|
-
[import_core.ModelType.AUDIO]: "Audio",
|
|
738
|
-
[import_core.ModelType.VIDEO]: "Video",
|
|
739
|
-
[import_core.ModelType.OBJECT_SMALL]: "Object (Small)",
|
|
740
|
-
[import_core.ModelType.OBJECT_LARGE]: "Object (Large)",
|
|
741
|
-
[import_core.ModelType.RESEARCH]: "Research"
|
|
742
|
-
};
|
|
743
|
-
return descriptions[modelType] ?? modelType;
|
|
744
|
-
}
|
|
745
|
-
var modelsAction = {
|
|
746
|
-
name: "MODELS_COMMAND",
|
|
747
|
-
description: "List available AI models and providers. Only activates for /models slash command.",
|
|
748
|
-
similes: ["/models"],
|
|
749
|
-
validate: async (runtime, message) => {
|
|
750
|
-
const textRaw = message.content?.text ?? "";
|
|
751
|
-
const text = textRaw.toLowerCase();
|
|
752
|
-
const hasKeyword = text.includes("/models") || text.includes("models");
|
|
753
|
-
const hasRegex = /^(?:\/|!)\s*models\b/i.test(textRaw);
|
|
754
|
-
const hasContext = Boolean(runtime?.agentId || message?.roomId || message?.content);
|
|
755
|
-
const hasInput = textRaw.trim().length > 0;
|
|
756
|
-
if (!(hasKeyword && hasRegex && hasContext && hasInput)) {
|
|
757
|
-
return false;
|
|
758
|
-
}
|
|
759
|
-
const detection = detectCommand(textRaw);
|
|
760
|
-
return detection.isCommand && detection.command?.key === "models";
|
|
761
|
-
},
|
|
762
|
-
async handler(runtime, _message, _state, _options, callback) {
|
|
763
|
-
const lines = [`**Available Models:**
|
|
764
|
-
`];
|
|
765
|
-
try {
|
|
766
|
-
const registeredTypes = [];
|
|
767
|
-
const seen = new Set;
|
|
768
|
-
for (const modelType of Object.values(import_core.ModelType)) {
|
|
769
|
-
if (seen.has(modelType))
|
|
770
|
-
continue;
|
|
771
|
-
seen.add(modelType);
|
|
772
|
-
try {
|
|
773
|
-
const handler = runtime.getModel(modelType);
|
|
774
|
-
if (handler) {
|
|
775
|
-
registeredTypes.push(modelType);
|
|
776
|
-
}
|
|
777
|
-
} catch {}
|
|
778
|
-
}
|
|
779
|
-
if (registeredTypes.length > 0) {
|
|
780
|
-
lines.push("**Registered Model Types:**");
|
|
781
|
-
for (const modelType of registeredTypes) {
|
|
782
|
-
lines.push(`• ${describeModelType(modelType)} (\`${modelType}\`)`);
|
|
783
|
-
}
|
|
784
|
-
} else {
|
|
785
|
-
lines.push("No model handlers are currently registered.");
|
|
786
|
-
}
|
|
787
|
-
const modelProvider = runtime.getSetting("MODEL_PROVIDER");
|
|
788
|
-
const modelName = runtime.getSetting("MODEL_NAME");
|
|
789
|
-
if (modelProvider || modelName) {
|
|
790
|
-
lines.push(`
|
|
791
|
-
**Current Configuration:**`);
|
|
792
|
-
if (modelProvider)
|
|
793
|
-
lines.push(`• Provider: ${modelProvider}`);
|
|
794
|
-
if (modelName)
|
|
795
|
-
lines.push(`• Model: ${modelName}`);
|
|
796
|
-
}
|
|
797
|
-
} catch (err) {
|
|
798
|
-
import_core.logger.warn({ src: "plugin-commands", err }, "Error querying runtime models");
|
|
799
|
-
lines.push("Unable to query available models.");
|
|
800
|
-
}
|
|
801
|
-
lines.push(`
|
|
802
|
-
|
|
803
|
-
_Use /model <provider/model> to switch models._`);
|
|
804
|
-
const replyText = lines.join(`
|
|
805
|
-
`);
|
|
806
|
-
await callback?.({ text: replyText });
|
|
807
|
-
return {
|
|
808
|
-
success: true,
|
|
809
|
-
text: replyText
|
|
810
|
-
};
|
|
811
|
-
},
|
|
812
|
-
examples: [
|
|
813
|
-
[
|
|
814
|
-
{ name: "user", content: { text: "/models" } },
|
|
815
|
-
{
|
|
816
|
-
name: "assistant",
|
|
817
|
-
content: {
|
|
818
|
-
text: "**Available Models:**\n\n**Registered Model Types:**\n• Text (Large) (`text_large`)\n• Text (Small) (`text_small`)..."
|
|
819
|
-
}
|
|
820
|
-
}
|
|
821
|
-
]
|
|
822
|
-
]
|
|
823
|
-
};
|
|
824
|
-
|
|
825
|
-
// src/actions/status.ts
|
|
826
|
-
async function buildStatusReport(runtime, roomId) {
|
|
827
|
-
const lines = [`**Session Status:**
|
|
828
|
-
`];
|
|
829
|
-
lines.push(`**Agent:** ${runtime.character.name ?? runtime.agentId}`);
|
|
830
|
-
lines.push(`**Room:** ${roomId}`);
|
|
831
|
-
try {
|
|
832
|
-
const directiveService = runtime.getService("directive-parser");
|
|
833
|
-
if (directiveService) {
|
|
834
|
-
const state = directiveService.getSessionState?.(roomId);
|
|
835
|
-
if (state) {
|
|
836
|
-
lines.push(`
|
|
837
|
-
**Directives:**`);
|
|
838
|
-
lines.push(`• Thinking: ${state.thinking}`);
|
|
839
|
-
lines.push(`• Verbose: ${state.verbose}`);
|
|
840
|
-
lines.push(`• Reasoning: ${state.reasoning}`);
|
|
841
|
-
lines.push(`• Elevated: ${state.elevated}`);
|
|
842
|
-
if (state.model?.provider || state.model?.model) {
|
|
843
|
-
const modelStr = state.model.provider ? `${state.model.provider}/${state.model.model}` : state.model.model;
|
|
844
|
-
lines.push(`• Model: ${modelStr}`);
|
|
845
|
-
}
|
|
846
|
-
}
|
|
847
|
-
}
|
|
848
|
-
} catch {}
|
|
849
|
-
try {
|
|
850
|
-
const tasks = await runtime.getTasks({ roomId });
|
|
851
|
-
if (tasks.length > 0) {
|
|
852
|
-
lines.push(`
|
|
853
|
-
**Tasks:** ${tasks.length} pending`);
|
|
854
|
-
}
|
|
855
|
-
} catch {}
|
|
856
|
-
return lines.join(`
|
|
857
|
-
`);
|
|
858
|
-
}
|
|
859
|
-
var statusAction = {
|
|
860
|
-
name: "STATUS_COMMAND",
|
|
861
|
-
description: "Show session directive settings via /status slash command. Only activates for /status or /s prefix.",
|
|
862
|
-
similes: ["/status", "/s"],
|
|
863
|
-
validate: async (runtime, message) => {
|
|
864
|
-
const textRaw = message.content?.text ?? "";
|
|
865
|
-
const text = textRaw.toLowerCase();
|
|
866
|
-
const hasKeyword = text.includes("/status") || text.includes("/s") || text.includes("status");
|
|
867
|
-
const hasRegex = /^(?:\/|!)\s*(?:status|s)\b/i.test(textRaw);
|
|
868
|
-
const hasContext = Boolean(runtime?.agentId || message?.roomId || message?.content);
|
|
869
|
-
const hasInput = textRaw.trim().length > 0;
|
|
870
|
-
if (!(hasKeyword && hasRegex && hasContext && hasInput)) {
|
|
871
|
-
return false;
|
|
872
|
-
}
|
|
873
|
-
const detection = detectCommand(textRaw);
|
|
874
|
-
return detection.isCommand && detection.command?.key === "status";
|
|
875
|
-
},
|
|
876
|
-
async handler(runtime, message, _state, _options, callback) {
|
|
877
|
-
const statusText = await buildStatusReport(runtime, message.roomId);
|
|
878
|
-
await callback?.({ text: statusText });
|
|
879
|
-
return {
|
|
880
|
-
success: true,
|
|
881
|
-
text: statusText
|
|
882
|
-
};
|
|
883
|
-
},
|
|
884
|
-
examples: [
|
|
885
|
-
[
|
|
886
|
-
{ name: "user", content: { text: "/status" } },
|
|
887
|
-
{
|
|
888
|
-
name: "assistant",
|
|
889
|
-
content: {
|
|
890
|
-
text: `**Session Status:**
|
|
891
|
-
|
|
892
|
-
**Agent:** Eliza
|
|
893
|
-
**Room:** room-456
|
|
894
|
-
|
|
895
|
-
**Directives:**
|
|
896
|
-
• Thinking: low...`
|
|
897
|
-
}
|
|
898
|
-
}
|
|
899
|
-
]
|
|
900
|
-
]
|
|
901
|
-
};
|
|
902
|
-
|
|
903
|
-
// src/actions/stop.ts
|
|
904
|
-
var import_core2 = require("@elizaos/core");
|
|
905
|
-
var stopAction = {
|
|
906
|
-
name: "STOP_COMMAND",
|
|
907
|
-
description: "Stop current operation or abort running tasks. Triggered by /stop, /abort, or /cancel slash commands only.",
|
|
908
|
-
similes: ["/stop", "/abort", "/cancel"],
|
|
909
|
-
validate: async (runtime, message) => {
|
|
910
|
-
const textRaw = message.content?.text ?? "";
|
|
911
|
-
const text = textRaw.toLowerCase();
|
|
912
|
-
const hasKeyword = text.includes("/stop") || text.includes("/abort") || text.includes("/cancel") || text.includes("stop");
|
|
913
|
-
const hasRegex = /^(?:\/|!)\s*(?:stop|abort|cancel)\b/i.test(textRaw);
|
|
914
|
-
const hasContext = Boolean(runtime?.agentId || message?.roomId || message?.content);
|
|
915
|
-
const hasInput = textRaw.trim().length > 0;
|
|
916
|
-
if (!(hasKeyword && hasRegex && hasContext && hasInput)) {
|
|
917
|
-
return false;
|
|
918
|
-
}
|
|
919
|
-
const detection = detectCommand(textRaw);
|
|
920
|
-
return detection.isCommand && ["stop", "abort", "cancel"].includes(detection.command?.key ?? "");
|
|
921
|
-
},
|
|
922
|
-
async handler(runtime, message, _state, _options, callback) {
|
|
923
|
-
try {
|
|
924
|
-
await runtime.emitEvent(import_core2.EventType.HOOK_COMMAND_STOP, {
|
|
925
|
-
runtime,
|
|
926
|
-
sessionKey: message.roomId,
|
|
927
|
-
messages: [],
|
|
928
|
-
timestamp: new Date,
|
|
929
|
-
context: {
|
|
930
|
-
entityId: message.entityId,
|
|
931
|
-
source: message.content?.source
|
|
932
|
-
},
|
|
933
|
-
command: "stop",
|
|
934
|
-
senderId: message.entityId,
|
|
935
|
-
commandSource: message.content?.source
|
|
936
|
-
});
|
|
937
|
-
} catch (err) {
|
|
938
|
-
import_core2.logger.warn({ src: "plugin-commands", err }, "Failed to emit HOOK_COMMAND_STOP event");
|
|
939
|
-
}
|
|
940
|
-
const replyText = "✓ Stop requested. Current operations will be cancelled.";
|
|
941
|
-
await callback?.({ text: replyText });
|
|
942
|
-
return {
|
|
943
|
-
success: true,
|
|
944
|
-
text: replyText
|
|
945
|
-
};
|
|
946
|
-
},
|
|
947
|
-
examples: [
|
|
948
|
-
[
|
|
949
|
-
{ name: "user", content: { text: "/stop" } },
|
|
950
|
-
{
|
|
951
|
-
name: "assistant",
|
|
952
|
-
content: {
|
|
953
|
-
text: "✓ Stop requested. Current operations will be cancelled."
|
|
954
|
-
}
|
|
955
|
-
}
|
|
956
|
-
],
|
|
957
|
-
[
|
|
958
|
-
{ name: "user", content: { text: "/abort" } },
|
|
959
|
-
{
|
|
960
|
-
name: "assistant",
|
|
961
|
-
content: {
|
|
962
|
-
text: "✓ Stop requested. Current operations will be cancelled."
|
|
963
|
-
}
|
|
964
|
-
}
|
|
965
|
-
]
|
|
966
|
-
]
|
|
967
|
-
};
|
|
968
|
-
|
|
969
580
|
// src/index.ts
|
|
970
581
|
var commandRegistryProvider = {
|
|
971
582
|
name: "COMMAND_REGISTRY",
|
|
972
583
|
description: "Available chat commands and their descriptions",
|
|
584
|
+
descriptionCompressed: "Available chat commands and descriptions.",
|
|
973
585
|
dynamic: true,
|
|
586
|
+
contexts: ["general", "automation"],
|
|
587
|
+
contextGate: { anyOf: ["general", "automation"] },
|
|
588
|
+
cacheStable: true,
|
|
589
|
+
cacheScope: "agent",
|
|
974
590
|
async get(runtime, message, _state) {
|
|
975
591
|
useRuntime(runtime.agentId);
|
|
976
592
|
const text = message.content?.text ?? "";
|
|
@@ -1027,13 +643,12 @@ var commandsPlugin = {
|
|
|
1027
643
|
name: "commands",
|
|
1028
644
|
description: "Chat command system with /help, /status, /reset, etc.",
|
|
1029
645
|
providers: [commandRegistryProvider],
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
],
|
|
646
|
+
autoEnable: {
|
|
647
|
+
shouldEnable: (_env, config) => {
|
|
648
|
+
const f = config?.features?.commands;
|
|
649
|
+
return f === true || typeof f === "object" && f !== null && f.enabled !== false;
|
|
650
|
+
}
|
|
651
|
+
},
|
|
1037
652
|
config: {
|
|
1038
653
|
COMMANDS_ENABLED: "true",
|
|
1039
654
|
COMMANDS_CONFIG_ENABLED: "false",
|
|
@@ -1057,7 +672,7 @@ var commandsPlugin = {
|
|
|
1057
672
|
if (hasCommand("hello world")) {
|
|
1058
673
|
throw new Error("Should not detect plain text as command");
|
|
1059
674
|
}
|
|
1060
|
-
|
|
675
|
+
import_core.logger.success("Command prefix detection works correctly");
|
|
1061
676
|
}
|
|
1062
677
|
},
|
|
1063
678
|
{
|
|
@@ -1073,7 +688,7 @@ var commandsPlugin = {
|
|
|
1073
688
|
if (detection.command?.args[0] !== "high") {
|
|
1074
689
|
throw new Error(`Expected arg 'high', got '${detection.command?.args[0]}'`);
|
|
1075
690
|
}
|
|
1076
|
-
|
|
691
|
+
import_core.logger.success("Command argument parsing works correctly");
|
|
1077
692
|
}
|
|
1078
693
|
},
|
|
1079
694
|
{
|
|
@@ -1087,7 +702,7 @@ var commandsPlugin = {
|
|
|
1087
702
|
if (normalized2 !== "/help") {
|
|
1088
703
|
throw new Error(`Expected '/help', got '${normalized2}'`);
|
|
1089
704
|
}
|
|
1090
|
-
|
|
705
|
+
import_core.logger.success("Command normalization works correctly");
|
|
1091
706
|
}
|
|
1092
707
|
},
|
|
1093
708
|
{
|
|
@@ -1100,7 +715,7 @@ var commandsPlugin = {
|
|
|
1100
715
|
if (cmd.key !== "help") {
|
|
1101
716
|
throw new Error(`Expected key 'help', got '${cmd.key}'`);
|
|
1102
717
|
}
|
|
1103
|
-
|
|
718
|
+
import_core.logger.success("Command alias lookup works correctly");
|
|
1104
719
|
}
|
|
1105
720
|
},
|
|
1106
721
|
{
|
|
@@ -1113,7 +728,7 @@ var commandsPlugin = {
|
|
|
1113
728
|
if (cmd.key !== "status") {
|
|
1114
729
|
throw new Error(`Expected key 'status', got '${cmd.key}'`);
|
|
1115
730
|
}
|
|
1116
|
-
|
|
731
|
+
import_core.logger.success("Command key lookup works correctly");
|
|
1117
732
|
}
|
|
1118
733
|
}
|
|
1119
734
|
]
|
|
@@ -1133,7 +748,7 @@ var commandsPlugin = {
|
|
|
1133
748
|
if (!cmdHelp || !cmdStatus) {
|
|
1134
749
|
throw new Error("Should have help and status commands");
|
|
1135
750
|
}
|
|
1136
|
-
|
|
751
|
+
import_core.logger.success("Command registry works correctly");
|
|
1137
752
|
}
|
|
1138
753
|
},
|
|
1139
754
|
{
|
|
@@ -1155,7 +770,7 @@ var commandsPlugin = {
|
|
|
1155
770
|
if (notFound) {
|
|
1156
771
|
throw new Error("Should not find unregistered command");
|
|
1157
772
|
}
|
|
1158
|
-
|
|
773
|
+
import_core.logger.success("Custom command registration works correctly");
|
|
1159
774
|
}
|
|
1160
775
|
},
|
|
1161
776
|
{
|
|
@@ -1169,14 +784,14 @@ var commandsPlugin = {
|
|
|
1169
784
|
if (!allStatus) {
|
|
1170
785
|
throw new Error("All returned commands should be in status category");
|
|
1171
786
|
}
|
|
1172
|
-
|
|
787
|
+
import_core.logger.success("Command categorization works correctly");
|
|
1173
788
|
}
|
|
1174
789
|
}
|
|
1175
790
|
]
|
|
1176
791
|
}
|
|
1177
792
|
],
|
|
1178
793
|
async init(config, runtime) {
|
|
1179
|
-
|
|
794
|
+
import_core.logger.log("[plugin-commands] Initializing command system");
|
|
1180
795
|
initForRuntime(runtime.agentId);
|
|
1181
796
|
const configEnabled = config.COMMANDS_CONFIG_ENABLED === "true";
|
|
1182
797
|
const debugEnabled = config.COMMANDS_DEBUG_ENABLED === "true";
|
|
@@ -1199,9 +814,9 @@ var commandsPlugin = {
|
|
|
1199
814
|
restartCmd.enabled = restartEnabled;
|
|
1200
815
|
}
|
|
1201
816
|
const enabledCount = getEnabledCommands().length;
|
|
1202
|
-
|
|
817
|
+
import_core.logger.log(`[plugin-commands] ${enabledCount} commands enabled for agent ${runtime.agentId}`);
|
|
1203
818
|
}
|
|
1204
819
|
};
|
|
1205
820
|
var src_default = commandsPlugin;
|
|
1206
821
|
|
|
1207
|
-
//# debugId=
|
|
822
|
+
//# debugId=00FC26667A6E870A64756E2164756E21
|