@elizaos/plugin-commands 2.0.3-beta.2 → 2.0.3-beta.3
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 +1757 -0
- package/dist/cjs/index.cjs.map +23 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1719 -0
- package/dist/index.js.map +23 -0
- package/dist/src/actions/command-actions.d.ts +17 -0
- package/dist/src/actions/command-actions.d.ts.map +1 -0
- package/dist/src/actions/command-settings.d.ts +35 -0
- package/dist/src/actions/command-settings.d.ts.map +1 -0
- package/dist/src/actions/dispatch.d.ts +54 -0
- package/dist/src/actions/dispatch.d.ts.map +1 -0
- package/dist/src/actions/handlers.d.ts +26 -0
- package/dist/src/actions/handlers.d.ts.map +1 -0
- package/dist/src/actions/index.d.ts +19 -0
- package/dist/src/actions/index.d.ts.map +1 -0
- package/dist/src/actions/shortcuts.d.ts +41 -0
- package/dist/src/actions/shortcuts.d.ts.map +1 -0
- package/dist/src/connector-bridge.d.ts +128 -0
- package/dist/src/connector-bridge.d.ts.map +1 -0
- package/dist/src/connector-catalog.d.ts +71 -0
- package/dist/src/connector-catalog.d.ts.map +1 -0
- package/dist/src/index.d.ts +68 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/navigation-commands.d.ts +28 -0
- package/dist/src/navigation-commands.d.ts.map +1 -0
- package/dist/src/parser.d.ts +32 -0
- package/dist/src/parser.d.ts.map +1 -0
- package/dist/src/registry.d.ts +66 -0
- package/dist/src/registry.d.ts.map +1 -0
- package/dist/src/serialize.d.ts +30 -0
- package/dist/src/serialize.d.ts.map +1 -0
- package/dist/src/settings-sections.d.ts +32 -0
- package/dist/src/settings-sections.d.ts.map +1 -0
- package/dist/src/types.d.ts +175 -0
- package/dist/src/types.d.ts.map +1 -0
- package/package.json +4 -3
- package/registry-entry.json +63 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/index.ts", "../src/registry.ts", "../src/parser.ts", "../src/actions/command-settings.ts", "../src/actions/handlers.ts", "../src/actions/dispatch.ts", "../src/actions/command-actions.ts", "../src/actions/shortcuts.ts", "../src/actions/index.ts", "../src/connector-bridge.ts", "../src/settings-sections.ts", "../src/navigation-commands.ts", "../src/serialize.ts", "../src/connector-catalog.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"/**\n * Plugin Commands - Chat command system for Eliza agents\n *\n * Provides a slash-command system with:\n * - /help, /status, /commands for information\n * - /stop, /reset, /compact for session control\n * - /think, /verbose, /model for options\n * - /allowlist, /approve for management\n * - /tts for media\n * - /bash for tools (elevated)\n *\n * INTEGRATION NOTES:\n * - Commands are registered as Actions with strict validate() that only\n * matches slash-prefixed messages (e.g. /help, !stop). This prevents\n * conflicts with bootstrap actions (STATUS, IGNORE) and messaging plugins.\n * - Similes use ONLY slash-command forms (no natural language) so the LLM\n * won't accidentally route \"I need help\" to HELP_COMMAND instead of REPLY.\n * - The registry is scoped per runtime to prevent cross-agent state leaks.\n * - The COMMAND_REGISTRY provider includes the command list in the LLM context\n * ONLY when the message is a command, reducing prompt noise for normal messages.\n */\n\nimport {\n\ttype IAgentRuntime,\n\tlogger,\n\ttype Memory,\n\ttype Plugin,\n\ttype Provider,\n\ttype ProviderResult,\n\ttype State,\n} from \"@elizaos/core\";\n// Deterministic command action layer (#8790): handlers, dispatch, settings,\n// and the registered *_COMMAND actions.\nimport { commandActions, commandShortcuts } from \"./actions\";\nimport { detectCommand, hasCommand, normalizeCommandBody } from \"./parser\";\nimport {\n\tfindCommandByAlias,\n\tfindCommandByKey,\n\tgetCommandsByCategory,\n\tgetEnabledCommands,\n\tgetEnabledCommandsForRuntime,\n\tinitForRuntime,\n\tregisterCommand,\n\tunregisterCommand,\n} from \"./registry\";\nimport type { CommandContext, CommandDefinition, CommandResult } from \"./types\";\n\n// Connector-neutral command catalog (getConnectorCommands / ConnectorCommand)\n// + settings-section resolution (resolveSettingsSection).\nexport * from \"./actions\";\n// The documented ConnectorCommandBridge contract + shared auth-gating helpers\n// every communication connector implements (#8790).\nexport * from \"./connector-bridge\";\nexport * from \"./connector-catalog\";\nexport * from \"./navigation-commands\";\nexport * from \"./parser\";\nexport * from \"./registry\";\n// Canonical serialization (serializeCommand / commandVisibleForSurface).\nexport * from \"./serialize\";\nexport * from \"./settings-sections\";\n// Re-export everything\nexport * from \"./types\";\n\n/**\n * Provider that exposes available commands to the LLM context.\n *\n * Only injects the full command list when the message looks like a command.\n * For normal messages, returns a minimal hint so the LLM knows commands\n * exist but doesn't get a wall of command documentation in its context.\n */\nexport const commandRegistryProvider: Provider = {\n\tname: \"COMMAND_REGISTRY\",\n\tdescription: \"Available chat commands and their descriptions\",\n\tdescriptionCompressed: \"Available chat commands and descriptions.\",\n\tdynamic: true,\n\tcontexts: [\"general\", \"automation\"],\n\tcontextGate: { anyOf: [\"general\", \"automation\"] },\n\tcacheStable: true,\n\tcacheScope: \"agent\",\n\tasync get(\n\t\truntime: IAgentRuntime,\n\t\tmessage: Memory,\n\t\t_state: State,\n\t): Promise<ProviderResult> {\n\t\tconst text = message.content.text ?? \"\";\n\t\tconst isCommand = hasCommand(text);\n\t\tconst commands = getEnabledCommandsForRuntime(runtime.agentId);\n\n\t\tif (isCommand) {\n\t\t\t// Full command context for command messages — helps the LLM select\n\t\t\t// the right action\n\t\t\tconst commandList = commands.map((cmd) => {\n\t\t\t\tconst auth = cmd.requiresAuth ? \" (requires auth)\" : \"\";\n\t\t\t\treturn `- ${cmd.textAliases[0]}: ${cmd.description}${auth}`;\n\t\t\t});\n\n\t\t\treturn {\n\t\t\t\ttext: `The user sent a slash command. Available commands:\\n${commandList.join(\"\\n\")}\\n\\nIMPORTANT: This is a slash command — respond by executing the matching command action, not with conversational text.`,\n\t\t\t\tvalues: {\n\t\t\t\t\tcommandCount: commands.length,\n\t\t\t\t\tisCommand: true,\n\t\t\t\t\thasElevatedCommands: commands.some((c) => c.requiresElevated),\n\t\t\t\t},\n\t\t\t\tdata: { commands, isCommand: true },\n\t\t\t};\n\t\t}\n\n\t\t// Minimal context for non-command messages — don't pollute the prompt\n\t\treturn {\n\t\t\ttext: \"\",\n\t\t\tvalues: {\n\t\t\t\tcommandCount: commands.length,\n\t\t\t\tisCommand: false,\n\t\t\t},\n\t\t\tdata: { isCommand: false },\n\t\t};\n\t},\n};\n\n/**\n * Format command result for display\n */\nexport function formatCommandResult(result: CommandResult): string {\n\tif (result.error) {\n\t\treturn `Error: ${result.error}`;\n\t}\n\treturn result.reply ?? \"Command executed\";\n}\n\n/**\n * Check if a sender is authorized\n */\nexport function isAuthorized(\n\tcontext: CommandContext,\n\tcommand: CommandDefinition,\n): boolean {\n\tif (!command.requiresAuth) {\n\t\treturn true;\n\t}\n\treturn context.isAuthorized;\n}\n\n/**\n * Check if a sender has elevated permissions\n */\nexport function isElevated(\n\tcontext: CommandContext,\n\tcommand: CommandDefinition,\n): boolean {\n\tif (!command.requiresElevated) {\n\t\treturn true;\n\t}\n\treturn context.isElevated;\n}\n\n/**\n * Plugin Commands\n *\n * Provides chat commands as Eliza actions. Commands are detected\n * by their text aliases (e.g., /help, /status) and executed as actions.\n *\n * Design decisions for messaging integration:\n * 1. Actions use strict validate() — only true for slash-prefixed messages\n * 2. Similes are slash-only — no natural language to prevent LLM misrouting\n * 3. Provider is context-aware — full docs for commands, empty for normal msgs\n * 4. Registry is scoped per agentId — no cross-agent contamination\n * 5. Events use proper EventType enums — not raw strings\n */\nexport const commandsPlugin: Plugin = {\n\tname: \"commands\",\n\tdescription: \"Chat command system with /help, /status, /reset, etc.\",\n\n\tproviders: [commandRegistryProvider],\n\n\t// Deterministic agent-target command handlers (#8790). Each action's\n\t// validate() is strictly slash-only, so they never intercept conversational\n\t// messages. The pre-LLM shortcut gate dispatches these before inference; the\n\t// actions are also registered so the planner can route to them as a fallback.\n\tactions: commandActions,\n\n\t// Slash-command shortcuts (#8791): the pre-LLM gate matches these explicit\n\t// aliases and fires the matching *_COMMAND action deterministically, before\n\t// any model call, identically on every surface.\n\tshortcuts: commandShortcuts,\n\n\t// Self-declared auto-enable: activate when features.commands is enabled.\n\tautoEnable: {\n\t\tshouldEnable: (_env, config) => {\n\t\t\tconst f = (config.features as Record<string, unknown> | undefined)\n\t\t\t\t?.commands;\n\t\t\treturn (\n\t\t\t\tf === true ||\n\t\t\t\t(typeof f === \"object\" &&\n\t\t\t\t\tf !== null &&\n\t\t\t\t\t(f as { enabled?: unknown }).enabled !== false)\n\t\t\t);\n\t\t},\n\t},\n\n\tconfig: {\n\t\tCOMMANDS_CONFIG_ENABLED: \"false\",\n\t\tCOMMANDS_DEBUG_ENABLED: \"false\",\n\t\tCOMMANDS_BASH_ENABLED: \"false\",\n\t\tCOMMANDS_RESTART_ENABLED: \"true\",\n\t},\n\n\ttests: [\n\t\t{\n\t\t\tname: \"command-detection\",\n\t\t\ttests: [\n\t\t\t\t{\n\t\t\t\t\tname: \"Detect command prefix\",\n\t\t\t\t\tfn: async (_runtime: IAgentRuntime) => {\n\t\t\t\t\t\tif (!hasCommand(\"/help\")) {\n\t\t\t\t\t\t\tthrow new Error(\"Should detect /help command\");\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (!hasCommand(\"/status test\")) {\n\t\t\t\t\t\t\tthrow new Error(\"Should detect /status with args\");\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (hasCommand(\"hello world\")) {\n\t\t\t\t\t\t\tthrow new Error(\"Should not detect plain text as command\");\n\t\t\t\t\t\t}\n\t\t\t\t\t\tlogger.success(\"Command prefix detection works correctly\");\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tname: \"Parse command with args\",\n\t\t\t\t\tfn: async (_runtime: IAgentRuntime) => {\n\t\t\t\t\t\tconst detection = detectCommand(\"/think:high\");\n\t\t\t\t\t\tif (!detection.isCommand) {\n\t\t\t\t\t\t\tthrow new Error(\"Should detect think command\");\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (detection.command?.key !== \"think\") {\n\t\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t\t`Expected key 'think', got '${detection.command?.key}'`,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (detection.command.args[0] !== \"high\") {\n\t\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t\t`Expected arg 'high', got '${detection.command.args[0]}'`,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tlogger.success(\"Command argument parsing works correctly\");\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tname: \"Normalize command body\",\n\t\t\t\t\tfn: async (_runtime: IAgentRuntime) => {\n\t\t\t\t\t\tconst normalized1 = normalizeCommandBody(\"/status: test\");\n\t\t\t\t\t\tif (normalized1 !== \"/status test\") {\n\t\t\t\t\t\t\tthrow new Error(`Expected '/status test', got '${normalized1}'`);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst normalized2 = normalizeCommandBody(\"@bot /help\", \"bot\");\n\t\t\t\t\t\tif (normalized2 !== \"/help\") {\n\t\t\t\t\t\t\tthrow new Error(`Expected '/help', got '${normalized2}'`);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tlogger.success(\"Command normalization works correctly\");\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tname: \"Find command by alias\",\n\t\t\t\t\tfn: async (_runtime: IAgentRuntime) => {\n\t\t\t\t\t\tconst cmd = findCommandByAlias(\"/h\");\n\t\t\t\t\t\tif (!cmd) {\n\t\t\t\t\t\t\tthrow new Error(\"Should find help command by /h alias\");\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (cmd.key !== \"help\") {\n\t\t\t\t\t\t\tthrow new Error(`Expected key 'help', got '${cmd.key}'`);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tlogger.success(\"Command alias lookup works correctly\");\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tname: \"Find command by key\",\n\t\t\t\t\tfn: async (_runtime: IAgentRuntime) => {\n\t\t\t\t\t\tconst cmd = findCommandByKey(\"status\");\n\t\t\t\t\t\tif (!cmd) {\n\t\t\t\t\t\t\tthrow new Error(\"Should find status command by key\");\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (cmd.key !== \"status\") {\n\t\t\t\t\t\t\tthrow new Error(`Expected key 'status', got '${cmd.key}'`);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tlogger.success(\"Command key lookup works correctly\");\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t],\n\t\t},\n\t\t{\n\t\t\tname: \"command-registry\",\n\t\t\ttests: [\n\t\t\t\t{\n\t\t\t\t\tname: \"Get enabled commands\",\n\t\t\t\t\tfn: async (_runtime: IAgentRuntime) => {\n\t\t\t\t\t\tconst commands = getEnabledCommands();\n\t\t\t\t\t\tif (commands.length === 0) {\n\t\t\t\t\t\t\tthrow new Error(\"Should have enabled commands\");\n\t\t\t\t\t\t}\n\t\t\t\t\t\t// Check some expected commands exist\n\t\t\t\t\t\tconst cmdHelp = commands.some((c) => c.key === \"help\");\n\t\t\t\t\t\tconst cmdStatus = commands.some((c) => c.key === \"status\");\n\t\t\t\t\t\tif (!cmdHelp || !cmdStatus) {\n\t\t\t\t\t\t\tthrow new Error(\"Should have help and status commands\");\n\t\t\t\t\t\t}\n\t\t\t\t\t\tlogger.success(\"Command registry works correctly\");\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tname: \"Register custom command\",\n\t\t\t\t\tfn: async (_runtime: IAgentRuntime) => {\n\t\t\t\t\t\tconst customCmd: CommandDefinition = {\n\t\t\t\t\t\t\tkey: \"test-custom\",\n\t\t\t\t\t\t\tdescription: \"Test custom command\",\n\t\t\t\t\t\t\ttextAliases: [\"/test-custom\", \"/tc\"],\n\t\t\t\t\t\t\tscope: \"text\",\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\tregisterCommand(customCmd);\n\t\t\t\t\t\tconst found = findCommandByKey(\"test-custom\");\n\t\t\t\t\t\tif (!found) {\n\t\t\t\t\t\t\tthrow new Error(\"Should find registered custom command\");\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tunregisterCommand(\"test-custom\");\n\t\t\t\t\t\tconst notFound = findCommandByKey(\"test-custom\");\n\t\t\t\t\t\tif (notFound) {\n\t\t\t\t\t\t\tthrow new Error(\"Should not find unregistered command\");\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tlogger.success(\"Custom command registration works correctly\");\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tname: \"Get commands by category\",\n\t\t\t\t\tfn: async (_runtime: IAgentRuntime) => {\n\t\t\t\t\t\tconst statusCommands = getCommandsByCategory(\"status\");\n\t\t\t\t\t\tif (statusCommands.length === 0) {\n\t\t\t\t\t\t\tthrow new Error(\"Should have status category commands\");\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst allStatus = statusCommands.every(\n\t\t\t\t\t\t\t(c) => c.category === \"status\",\n\t\t\t\t\t\t);\n\t\t\t\t\t\tif (!allStatus) {\n\t\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t\t\"All returned commands should be in status category\",\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tlogger.success(\"Command categorization works correctly\");\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t],\n\t\t},\n\t],\n\n\tasync init(config, runtime) {\n\t\tlogger.log(\"[plugin-commands] Initializing command system\");\n\n\t\t// Initialize an isolated command store for this runtime\n\t\t// This prevents cross-agent contamination in multi-agent deployments\n\t\tinitForRuntime(runtime.agentId);\n\n\t\t// Configure command enablement from config\n\t\tconst configEnabled = config.COMMANDS_CONFIG_ENABLED === \"true\";\n\t\tconst debugEnabled = config.COMMANDS_DEBUG_ENABLED === \"true\";\n\t\tconst bashEnabled = config.COMMANDS_BASH_ENABLED === \"true\";\n\t\tconst restartEnabled = config.COMMANDS_RESTART_ENABLED !== \"false\";\n\n\t\t// Update command enabled states (now on the isolated copy)\n\t\tconst configCmd = findCommandByKey(\"config\");\n\t\tif (configCmd) {\n\t\t\tconfigCmd.enabled = configEnabled;\n\t\t}\n\n\t\tconst debugCmd = findCommandByKey(\"debug\");\n\t\tif (debugCmd) {\n\t\t\tdebugCmd.enabled = debugEnabled;\n\t\t}\n\n\t\tconst bashCmd = findCommandByKey(\"bash\");\n\t\tif (bashCmd) {\n\t\t\tbashCmd.enabled = bashEnabled;\n\t\t}\n\n\t\tconst restartCmd = findCommandByKey(\"restart\");\n\t\tif (restartCmd) {\n\t\t\trestartCmd.enabled = restartEnabled;\n\t\t}\n\n\t\tconst enabledCount = getEnabledCommands().length;\n\t\tlogger.log(\n\t\t\t`[plugin-commands] ${enabledCount} commands enabled for agent ${runtime.agentId}`,\n\t\t);\n\t},\n};\n\nexport default commandsPlugin;\n",
|
|
6
|
+
"/**\n * Command registry - defines all available chat commands\n *\n * IMPORTANT: The registry uses module-level state for convenience, but\n * provides `cloneCommands()` and `resetCommands()` so that `init()` can\n * work on isolated copies per runtime. The `init()` function in the main\n * plugin file should clone before mutating to avoid cross-agent contamination.\n */\n\nimport type { CommandDefinition } from \"./types\";\n\n// Default command definitions (frozen reference — never mutate these directly)\nexport const DEFAULT_COMMANDS: ReadonlyArray<CommandDefinition> = [\n\t// Status commands\n\t{\n\t\tkey: \"help\",\n\t\tnativeName: \"help\",\n\t\tdescription: \"Show available commands\",\n\t\ttextAliases: [\"/help\", \"/h\", \"/?\"],\n\t\tscope: \"both\",\n\t\tcategory: \"status\",\n\t\tacceptsArgs: false,\n\t},\n\t{\n\t\tkey: \"commands\",\n\t\tnativeName: \"commands\",\n\t\tdescription: \"List all commands\",\n\t\ttextAliases: [\"/commands\", \"/cmds\"],\n\t\tscope: \"both\",\n\t\tcategory: \"status\",\n\t\tacceptsArgs: false,\n\t},\n\t{\n\t\tkey: \"status\",\n\t\tnativeName: \"status\",\n\t\tdescription: \"Show current session status\",\n\t\ttextAliases: [\"/status\", \"/s\"],\n\t\tscope: \"both\",\n\t\tcategory: \"status\",\n\t\tacceptsArgs: false,\n\t},\n\t{\n\t\tkey: \"context\",\n\t\tnativeName: \"context\",\n\t\tdescription: \"Show current context information\",\n\t\ttextAliases: [\"/context\", \"/ctx\"],\n\t\tscope: \"both\",\n\t\tcategory: \"status\",\n\t\tacceptsArgs: true,\n\t\targs: [{ name: \"mode\", description: \"Output mode (list, detail, json)\" }],\n\t},\n\t{\n\t\tkey: \"whoami\",\n\t\tnativeName: \"whoami\",\n\t\tdescription: \"Show your identity information\",\n\t\ttextAliases: [\"/whoami\", \"/who\"],\n\t\tscope: \"both\",\n\t\tcategory: \"status\",\n\t\tacceptsArgs: false,\n\t},\n\n\t// Session commands\n\t{\n\t\tkey: \"stop\",\n\t\tnativeName: \"stop\",\n\t\tdescription: \"Stop current operation\",\n\t\ttextAliases: [\"/stop\", \"/abort\", \"/cancel\"],\n\t\tscope: \"both\",\n\t\tcategory: \"session\",\n\t\tacceptsArgs: false,\n\t},\n\t{\n\t\tkey: \"restart\",\n\t\tnativeName: \"restart\",\n\t\tdescription: \"Restart the session\",\n\t\ttextAliases: [\"/restart\"],\n\t\tscope: \"both\",\n\t\tcategory: \"session\",\n\t\tacceptsArgs: false,\n\t\trequiresAuth: true,\n\t},\n\t{\n\t\tkey: \"reset\",\n\t\tnativeName: \"reset\",\n\t\tdescription: \"Reset session state\",\n\t\ttextAliases: [\"/reset\"],\n\t\tscope: \"both\",\n\t\tcategory: \"session\",\n\t\tacceptsArgs: false,\n\t\trequiresAuth: true,\n\t},\n\t{\n\t\tkey: \"new\",\n\t\tnativeName: \"new\",\n\t\tdescription: \"Start a new conversation\",\n\t\ttextAliases: [\"/new\"],\n\t\tscope: \"both\",\n\t\tcategory: \"session\",\n\t\tacceptsArgs: false,\n\t},\n\t{\n\t\tkey: \"compact\",\n\t\tnativeName: \"compact\",\n\t\tdescription: \"Compact conversation history\",\n\t\ttextAliases: [\"/compact\"],\n\t\tscope: \"both\",\n\t\tcategory: \"session\",\n\t\tacceptsArgs: true,\n\t\trequiresAuth: true,\n\t\targs: [\n\t\t\t{ name: \"instructions\", description: \"Optional compaction instructions\" },\n\t\t],\n\t},\n\n\t// Options commands\n\t{\n\t\tkey: \"think\",\n\t\tnativeName: \"think\",\n\t\tdescription: \"Set thinking level\",\n\t\ttextAliases: [\"/think\", \"/thinking\", \"/t\"],\n\t\tscope: \"both\",\n\t\tcategory: \"options\",\n\t\tacceptsArgs: true,\n\t\targs: [\n\t\t\t{ name: \"level\", description: \"off, minimal, low, medium, high, xhigh\" },\n\t\t],\n\t},\n\t{\n\t\tkey: \"verbose\",\n\t\tnativeName: \"verbose\",\n\t\tdescription: \"Set verbose output level\",\n\t\ttextAliases: [\"/verbose\", \"/v\"],\n\t\tscope: \"both\",\n\t\tcategory: \"options\",\n\t\tacceptsArgs: true,\n\t\targs: [{ name: \"level\", description: \"off, on, full\" }],\n\t},\n\t{\n\t\tkey: \"reasoning\",\n\t\tnativeName: \"reasoning\",\n\t\tdescription: \"Set reasoning visibility\",\n\t\ttextAliases: [\"/reasoning\", \"/reason\"],\n\t\tscope: \"both\",\n\t\tcategory: \"options\",\n\t\tacceptsArgs: true,\n\t\targs: [{ name: \"level\", description: \"off, on, stream\" }],\n\t},\n\t{\n\t\tkey: \"elevated\",\n\t\tnativeName: \"elevated\",\n\t\tdescription: \"Set elevated permission mode\",\n\t\ttextAliases: [\"/elevated\", \"/elev\"],\n\t\tscope: \"both\",\n\t\tcategory: \"options\",\n\t\tacceptsArgs: true,\n\t\targs: [{ name: \"level\", description: \"off, on, ask, full\" }],\n\t\trequiresAuth: true,\n\t},\n\t{\n\t\tkey: \"model\",\n\t\tnativeName: \"model\",\n\t\tdescription: \"Set or show current model\",\n\t\ttextAliases: [\"/model\", \"/m\"],\n\t\tscope: \"both\",\n\t\tcategory: \"options\",\n\t\tacceptsArgs: true,\n\t\targs: [\n\t\t\t{\n\t\t\t\tname: \"model\",\n\t\t\t\tdescription: \"provider/model or alias\",\n\t\t\t\tdynamicChoices: \"models\",\n\t\t\t},\n\t\t],\n\t},\n\t{\n\t\tkey: \"models\",\n\t\tnativeName: \"models\",\n\t\tdescription: \"List available models\",\n\t\ttextAliases: [\"/models\"],\n\t\tscope: \"both\",\n\t\tcategory: \"options\",\n\t\tacceptsArgs: false,\n\t},\n\t{\n\t\tkey: \"usage\",\n\t\tnativeName: \"usage\",\n\t\tdescription: \"Show token usage\",\n\t\ttextAliases: [\"/usage\"],\n\t\tscope: \"both\",\n\t\tcategory: \"options\",\n\t\tacceptsArgs: false,\n\t},\n\t{\n\t\tkey: \"queue\",\n\t\tnativeName: \"queue\",\n\t\tdescription: \"Set queue mode\",\n\t\ttextAliases: [\"/queue\", \"/q\"],\n\t\tscope: \"both\",\n\t\tcategory: \"options\",\n\t\tacceptsArgs: true,\n\t\targs: [\n\t\t\t{\n\t\t\t\tname: \"mode\",\n\t\t\t\tdescription: \"steer, followup, collect, interrupt, or options\",\n\t\t\t},\n\t\t],\n\t},\n\n\t// Management commands\n\t{\n\t\tkey: \"allowlist\",\n\t\tnativeName: \"allowlist\",\n\t\tdescription: \"Manage sender allowlist\",\n\t\ttextAliases: [\"/allowlist\", \"/allow\"],\n\t\tscope: \"both\",\n\t\tcategory: \"management\",\n\t\tacceptsArgs: true,\n\t\targs: [\n\t\t\t{ name: \"action\", description: \"list, add, remove\" },\n\t\t\t{ name: \"value\", description: \"sender to add/remove\" },\n\t\t],\n\t\trequiresAuth: true,\n\t},\n\t{\n\t\tkey: \"approve\",\n\t\tnativeName: \"approve\",\n\t\tdescription: \"Approve or deny a pending action\",\n\t\ttextAliases: [\"/approve\"],\n\t\tscope: \"both\",\n\t\tcategory: \"management\",\n\t\tacceptsArgs: true,\n\t\targs: [\n\t\t\t{ name: \"id\", description: \"Approval ID\", required: true },\n\t\t\t{ name: \"action\", description: \"allow-once, allow-always, deny\" },\n\t\t],\n\t\trequiresAuth: true,\n\t},\n\t{\n\t\tkey: \"subagents\",\n\t\tnativeName: \"subagents\",\n\t\tdescription: \"Manage subagents\",\n\t\ttextAliases: [\"/subagents\", \"/sub\"],\n\t\tscope: \"both\",\n\t\tcategory: \"management\",\n\t\tacceptsArgs: true,\n\t\targs: [{ name: \"action\", description: \"list, stop, log, info, send\" }],\n\t\trequiresAuth: true,\n\t},\n\t{\n\t\tkey: \"config\",\n\t\tnativeName: \"config\",\n\t\tdescription: \"View or set configuration\",\n\t\ttextAliases: [\"/config\", \"/cfg\"],\n\t\tscope: \"both\",\n\t\tcategory: \"management\",\n\t\tacceptsArgs: true,\n\t\targs: [\n\t\t\t{ name: \"key\", description: \"Configuration key\" },\n\t\t\t{ name: \"value\", description: \"Value to set\" },\n\t\t],\n\t\trequiresAuth: true,\n\t\tenabled: false, // Disabled by default\n\t},\n\t{\n\t\tkey: \"debug\",\n\t\tnativeName: \"debug\",\n\t\tdescription: \"Debug information\",\n\t\ttextAliases: [\"/debug\"],\n\t\tscope: \"both\",\n\t\tcategory: \"management\",\n\t\tacceptsArgs: true,\n\t\trequiresAuth: true,\n\t\tenabled: false, // Disabled by default\n\t},\n\n\t// Media commands\n\t{\n\t\tkey: \"tts\",\n\t\tnativeName: \"tts\",\n\t\tdescription: \"Text-to-speech settings\",\n\t\ttextAliases: [\"/tts\", \"/voice\"],\n\t\tscope: \"both\",\n\t\tcategory: \"media\",\n\t\tacceptsArgs: true,\n\t\targs: [\n\t\t\t{\n\t\t\t\tname: \"action\",\n\t\t\t\tdescription: \"on, off, status, provider, limit, audio\",\n\t\t\t},\n\t\t],\n\t},\n\t{\n\t\tkey: \"transcribe\",\n\t\tnativeName: \"transcribe\",\n\t\tdescription:\n\t\t\t\"Toggle long-form transcription mode (record-only; agent stays silent until an exit phrase)\",\n\t\ttextAliases: [\"/transcribe\", \"/transcription\", \"/dictate\"],\n\t\tscope: \"both\",\n\t\tcategory: \"media\",\n\t\tacceptsArgs: false,\n\t},\n\n\t// Tools commands\n\t{\n\t\tkey: \"bash\",\n\t\tnativeName: \"bash\",\n\t\tdescription: \"Execute shell command\",\n\t\ttextAliases: [\"/bash\", \"/sh\", \"/!\"],\n\t\tscope: \"text\",\n\t\tcategory: \"tools\",\n\t\tacceptsArgs: true,\n\t\targs: [\n\t\t\t{\n\t\t\t\tname: \"command\",\n\t\t\t\tdescription: \"Shell command to execute\",\n\t\t\t\tcaptureRemaining: true,\n\t\t\t},\n\t\t],\n\t\trequiresAuth: true,\n\t\trequiresElevated: true,\n\t},\n];\n\n// ── Per-runtime command storage ──────────────────────────────────────────\n// Each agent runtime gets its own isolated command set via `initForRuntime()`.\n// The module-level state is used as a fallback for convenience (tests, etc.).\n//\n// Why a WeakMap? Agent runtimes may be created/destroyed; we don't want to\n// leak memory by holding strong references to disposed runtimes.\n\ninterface CommandStore {\n\tcommands: CommandDefinition[];\n\taliasMap: Map<string, CommandDefinition> | null;\n}\n\n/** Per-runtime stores keyed by agentId */\nconst runtimeStores = new Map<string, CommandStore>();\n/** Fallback store for when no runtime context is set */\nconst fallbackStore: CommandStore = {\n\tcommands: DEFAULT_COMMANDS.map((c) => ({ ...c })),\n\taliasMap: null,\n};\n/** Currently active store (set during init, reset on test teardown) */\nlet activeStore: CommandStore = fallbackStore;\n\n/**\n * Initialize an isolated command store for a specific runtime.\n * Called from plugin init() to prevent cross-agent contamination.\n */\nexport function initForRuntime(agentId: string): void {\n\tconst store: CommandStore = {\n\t\tcommands: DEFAULT_COMMANDS.map((c) => ({ ...c })),\n\t\taliasMap: null,\n\t};\n\truntimeStores.set(agentId, store);\n\tactiveStore = store;\n}\n\n/**\n * Set the active command store for a given runtime.\n * Providers and actions should call this before accessing commands.\n */\nexport function useRuntime(agentId: string): void {\n\tactiveStore = storeForRuntime(agentId);\n}\n\n/**\n * Get all registered commands\n */\nexport function getCommands(): CommandDefinition[] {\n\treturn [...activeStore.commands];\n}\n\n/**\n * Get enabled commands\n */\nexport function getEnabledCommands(): CommandDefinition[] {\n\treturn activeStore.commands.filter((cmd) => cmd.enabled !== false);\n}\n\n/**\n * Get commands by category\n */\nexport function getCommandsByCategory(category: string): CommandDefinition[] {\n\treturn activeStore.commands.filter(\n\t\t(cmd) => cmd.category === category && cmd.enabled !== false,\n\t);\n}\n\n/**\n * Register a custom command\n */\nexport function registerCommand(command: CommandDefinition): void {\n\t// Remove existing command with same key\n\tactiveStore.commands = activeStore.commands.filter(\n\t\t(c) => c.key !== command.key,\n\t);\n\tactiveStore.commands.push(command);\n\tactiveStore.aliasMap = null; // Invalidate cache\n}\n\n/**\n * Register multiple commands\n */\nexport function registerCommands(newCommands: CommandDefinition[]): void {\n\tfor (const command of newCommands) {\n\t\tregisterCommand(command);\n\t}\n}\n\n/**\n * Unregister a command\n */\nexport function unregisterCommand(key: string): void {\n\tactiveStore.commands = activeStore.commands.filter((c) => c.key !== key);\n\tactiveStore.aliasMap = null;\n}\n\n/**\n * Reset to default commands (for the active store)\n */\nexport function resetCommands(): void {\n\tactiveStore.commands = DEFAULT_COMMANDS.map((c) => ({ ...c }));\n\tactiveStore.aliasMap = null;\n}\n\n/**\n * Build and cache alias map for the active store\n */\nfunction getAliasMap(): Map<string, CommandDefinition> {\n\tif (activeStore.aliasMap) return activeStore.aliasMap;\n\n\tactiveStore.aliasMap = new Map();\n\tfor (const command of activeStore.commands) {\n\t\tif (command.enabled === false) continue;\n\n\t\tfor (const alias of command.textAliases) {\n\t\t\tconst normalized = alias.toLowerCase().trim();\n\t\t\tif (!activeStore.aliasMap.has(normalized)) {\n\t\t\t\tactiveStore.aliasMap.set(normalized, command);\n\t\t\t}\n\t\t}\n\t}\n\treturn activeStore.aliasMap;\n}\n\n/**\n * Find command by alias\n */\nexport function findCommandByAlias(\n\talias: string,\n): CommandDefinition | undefined {\n\tconst map = getAliasMap();\n\treturn map.get(alias.toLowerCase().trim());\n}\n\n/**\n * Find command by key\n */\nexport function findCommandByKey(key: string): CommandDefinition | undefined {\n\treturn activeStore.commands.find((c) => c.key === key);\n}\n\n/**\n * Check if text starts with any command alias\n */\nexport function startsWithCommand(text: string): CommandDefinition | undefined {\n\tconst map = getAliasMap();\n\tconst normalized = text.toLowerCase().trim();\n\n\t// Check exact match first\n\tfor (const [alias, command] of map) {\n\t\tif (normalized === alias) {\n\t\t\treturn command;\n\t\t}\n\t\tconst remainder = normalized.slice(alias.length);\n\t\tif (normalized.startsWith(alias) && /^[\\s:]/.test(remainder)) {\n\t\t\treturn command;\n\t\t}\n\t}\n\n\treturn undefined;\n}\n\nfunction storeForRuntime(agentId?: string | null): CommandStore {\n\tif (!agentId) return fallbackStore;\n\treturn runtimeStores.get(agentId) ?? fallbackStore;\n}\n\nfunction getEnabledCommandsFromStore(store: CommandStore): CommandDefinition[] {\n\treturn store.commands.filter((cmd) => cmd.enabled !== false);\n}\n\nfunction getCommandsByCategoryFromStore(\n\tstore: CommandStore,\n\tcategory: string,\n): CommandDefinition[] {\n\treturn store.commands.filter(\n\t\t(cmd) => cmd.category === category && cmd.enabled !== false,\n\t);\n}\n\nfunction getAliasMapForStore(\n\tstore: CommandStore,\n): Map<string, CommandDefinition> {\n\tif (store.aliasMap) return store.aliasMap;\n\n\tstore.aliasMap = new Map();\n\tfor (const command of store.commands) {\n\t\tif (command.enabled === false) continue;\n\n\t\tfor (const alias of command.textAliases) {\n\t\t\tconst normalized = alias.toLowerCase().trim();\n\t\t\tif (!store.aliasMap.has(normalized)) {\n\t\t\t\tstore.aliasMap.set(normalized, command);\n\t\t\t}\n\t\t}\n\t}\n\treturn store.aliasMap;\n}\n\nexport function getCommandsForRuntime(\n\tagentId?: string | null,\n): CommandDefinition[] {\n\treturn [...storeForRuntime(agentId).commands];\n}\n\nexport function getEnabledCommandsForRuntime(\n\tagentId?: string | null,\n): CommandDefinition[] {\n\treturn getEnabledCommandsFromStore(storeForRuntime(agentId));\n}\n\nexport function getCommandsByCategoryForRuntime(\n\tcategory: string,\n\tagentId?: string | null,\n): CommandDefinition[] {\n\treturn getCommandsByCategoryFromStore(storeForRuntime(agentId), category);\n}\n\nexport function findCommandByAliasForRuntime(\n\talias: string,\n\tagentId?: string | null,\n): CommandDefinition | undefined {\n\treturn getAliasMapForStore(storeForRuntime(agentId)).get(\n\t\talias.toLowerCase().trim(),\n\t);\n}\n\nexport function findCommandByKeyForRuntime(\n\tkey: string,\n\tagentId?: string | null,\n): CommandDefinition | undefined {\n\treturn storeForRuntime(agentId).commands.find((c) => c.key === key);\n}\n",
|
|
7
|
+
"/**\n * Command parser - detects and parses commands from message text\n */\n\nimport { startsWithCommand } from \"./registry\";\nimport type {\n\tCommandDefinition,\n\tCommandDetectionResult,\n\tParsedCommand,\n} from \"./types\";\n\nconst escapeRegExp = (value: string) =>\n\tvalue.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n\n/**\n * Check if text contains a command\n */\nexport function hasCommand(text: string): boolean {\n\tif (!text) return false;\n\tconst trimmed = text.trim();\n\tif (!trimmed.startsWith(\"/\") && !trimmed.startsWith(\"!\")) return false;\n\treturn Boolean(startsWithCommand(trimmed));\n}\n\n/**\n * Detect command in text\n */\nexport function detectCommand(text: string): CommandDetectionResult {\n\tif (!text) {\n\t\treturn { isCommand: false };\n\t}\n\n\tconst trimmed = text.trim();\n\n\t// Quick check for command prefix\n\tif (!trimmed.startsWith(\"/\") && !trimmed.startsWith(\"!\")) {\n\t\treturn { isCommand: false };\n\t}\n\n\tconst command = startsWithCommand(trimmed);\n\tif (!command) {\n\t\treturn { isCommand: false };\n\t}\n\n\tconst parsed = parseCommand(trimmed, command);\n\tif (!parsed) {\n\t\treturn { isCommand: false };\n\t}\n\n\treturn { isCommand: true, command: parsed };\n}\n\n/**\n * Parse a command from text\n */\nexport function parseCommand(\n\ttext: string,\n\tdefinition: CommandDefinition,\n): ParsedCommand | null {\n\tconst trimmed = text.trim();\n\n\t// Find the matching alias\n\tlet matchedAlias: string | null = null;\n\tfor (const alias of definition.textAliases) {\n\t\tconst normalized = alias.toLowerCase();\n\t\tif (trimmed.toLowerCase() === normalized) {\n\t\t\tmatchedAlias = alias;\n\t\t\tbreak;\n\t\t}\n\t\tconst remainder = trimmed.slice(alias.length);\n\t\tif (\n\t\t\ttrimmed.toLowerCase().startsWith(normalized) &&\n\t\t\t/^[\\s:]/.test(remainder)\n\t\t) {\n\t\t\tmatchedAlias = alias;\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tif (!matchedAlias) {\n\t\treturn null;\n\t}\n\n\t// Extract arguments\n\tlet rawArgs = trimmed.slice(matchedAlias.length).trim();\n\n\t// Handle colon separator (e.g., /think:high)\n\tif (rawArgs.startsWith(\":\")) {\n\t\trawArgs = rawArgs.slice(1).trim();\n\t}\n\n\t// Parse arguments\n\tconst args = parseArgs(rawArgs, definition);\n\n\tconst parsed: ParsedCommand = {\n\t\tkey: definition.key,\n\t\tcanonical: definition.textAliases[0] ?? `/${definition.key}`,\n\t\targs,\n\t};\n\tif (rawArgs) {\n\t\tparsed.rawArgs = rawArgs;\n\t}\n\treturn parsed;\n}\n\n/**\n * Parse arguments based on command definition\n */\nfunction parseArgs(rawArgs: string, definition: CommandDefinition): string[] {\n\tif (!rawArgs || !definition.acceptsArgs) {\n\t\treturn [];\n\t}\n\n\tconst parsing = definition.argsParsing ?? \"positional\";\n\n\tif (parsing === \"none\") {\n\t\t// Return entire string as single argument\n\t\treturn rawArgs ? [rawArgs] : [];\n\t}\n\n\t// Positional parsing\n\tconst args: string[] = [];\n\tconst argDefs = definition.args ?? [];\n\n\t// Split by whitespace, respecting quotes\n\tconst tokens = tokenize(rawArgs);\n\n\tfor (const [i, token] of tokens.entries()) {\n\t\tconst argDef = argDefs[i];\n\n\t\t// If this arg captures remaining, join all remaining tokens\n\t\tif (argDef?.captureRemaining) {\n\t\t\targs.push(tokens.slice(i).join(\" \"));\n\t\t\tbreak;\n\t\t}\n\n\t\targs.push(token);\n\t}\n\n\treturn args;\n}\n\n/**\n * Tokenize argument string, respecting quotes\n */\nfunction tokenize(input: string): string[] {\n\tconst tokens: string[] = [];\n\tlet current = \"\";\n\tlet inQuote = false;\n\tlet quoteChar = \"\";\n\n\tfor (const char of input) {\n\t\tif (inQuote) {\n\t\t\tif (char === quoteChar) {\n\t\t\t\tinQuote = false;\n\t\t\t\tif (current) {\n\t\t\t\t\ttokens.push(current);\n\t\t\t\t\tcurrent = \"\";\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tcurrent += char;\n\t\t\t}\n\t\t} else if (char === '\"' || char === \"'\") {\n\t\t\tinQuote = true;\n\t\t\tquoteChar = char;\n\t\t} else if (/\\s/.test(char)) {\n\t\t\tif (current) {\n\t\t\t\ttokens.push(current);\n\t\t\t\tcurrent = \"\";\n\t\t\t}\n\t\t} else {\n\t\t\tcurrent += char;\n\t\t}\n\t}\n\n\tif (current) {\n\t\ttokens.push(current);\n\t}\n\n\treturn tokens;\n}\n\n/**\n * Normalize command body (handle bot mentions, colon syntax, etc.)\n */\nexport function normalizeCommandBody(\n\ttext: string,\n\tbotMention?: string,\n): string {\n\tlet normalized = text.trim();\n\n\t// Remove bot mention prefix (e.g., \"@bot /status\" -> \"/status\")\n\tif (botMention) {\n\t\tconst mentionPattern = new RegExp(`^@${escapeRegExp(botMention)}\\\\s*`, \"i\");\n\t\tnormalized = normalized.replace(mentionPattern, \"\");\n\t}\n\n\t// Handle colon in command (e.g., \"/command: args\" -> \"/command args\")\n\tnormalized = normalized.replace(/^([/!][^\\s:]+):\\s*/, \"$1 \");\n\n\treturn normalized.trim();\n}\n\n/**\n * Check if text is a command-only message (no other content)\n */\nexport function isCommandOnly(text: string): boolean {\n\tconst detection = detectCommand(text);\n\tif (!detection.isCommand || !detection.command) {\n\t\treturn false;\n\t}\n\n\t// If there's no rawArgs, it's command-only\n\tif (!detection.command.rawArgs) {\n\t\treturn true;\n\t}\n\n\t// Check if rawArgs is just whitespace\n\treturn detection.command.rawArgs.trim().length === 0;\n}\n\n/**\n * Get command and remaining text\n */\nexport function extractCommand(\n\ttext: string,\n): { command: ParsedCommand; remainingText: string } | null {\n\tconst detection = detectCommand(text);\n\tif (!detection.isCommand || !detection.command) {\n\t\treturn null;\n\t}\n\n\tconst { command } = detection;\n\n\t// For commands that don't accept args, remaining text is everything after the command\n\tif (!command.rawArgs) {\n\t\treturn { command, remainingText: \"\" };\n\t}\n\n\treturn { command, remainingText: command.rawArgs };\n}\n",
|
|
8
|
+
"/**\n * Per-conversation command settings.\n *\n * The option commands (`/think`, `/verbose`, `/reasoning`, `/queue`,\n * `/elevated`, `/model`, `/tts`) persist their value here, keyed by room, via\n * the runtime cache. This is real, queryable state: setting `/think high` then\n * reading it back returns `high`. Each setter validates its argument against an\n * allowed set so a bad value is rejected deterministically rather than guessed.\n */\n\nimport type { IAgentRuntime } from \"@elizaos/core\";\n\nexport interface CommandSettings {\n\tthinking?: string;\n\tverbose?: string;\n\treasoning?: string;\n\tqueue?: string;\n\televated?: string;\n\tmodel?: string;\n\ttts?: string;\n}\n\n/** Allowed values per option command (lowercased). `null` = free-form. */\nexport const COMMAND_SETTING_CHOICES: Record<\n\tkeyof CommandSettings,\n\treadonly string[] | null\n> = {\n\tthinking: [\"off\", \"minimal\", \"low\", \"medium\", \"high\", \"xhigh\"],\n\tverbose: [\"off\", \"on\", \"full\"],\n\treasoning: [\"off\", \"on\", \"stream\"],\n\tqueue: [\"steer\", \"followup\", \"collect\", \"interrupt\"],\n\televated: [\"off\", \"on\", \"ask\", \"full\"],\n\tmodel: null,\n\ttts: [\"on\", \"off\"],\n};\n\nfunction cacheKey(roomId: string): string {\n\treturn `command-settings:${roomId}`;\n}\n\n/** Clear the persisted command settings for a room. */\nexport async function clearCommandSettings(\n\truntime: IAgentRuntime,\n\troomId: string,\n): Promise<boolean> {\n\treturn runtime.deleteCache(cacheKey(roomId));\n}\n\n/** Read the persisted command settings for a room (empty object if none). */\nexport async function getCommandSettings(\n\truntime: IAgentRuntime,\n\troomId: string,\n): Promise<CommandSettings> {\n\tconst stored = await runtime.getCache<CommandSettings>(cacheKey(roomId));\n\treturn stored ?? {};\n}\n\n/**\n * Validate and persist a single command setting. Returns the normalized value\n * on success, or `{ error }` when the value is not an allowed choice.\n */\nexport async function setCommandSetting(\n\truntime: IAgentRuntime,\n\troomId: string,\n\tkey: keyof CommandSettings,\n\trawValue: string,\n): Promise<{ value: string } | { error: string }> {\n\tconst value = rawValue.trim().toLowerCase();\n\tconst choices = COMMAND_SETTING_CHOICES[key];\n\tif (choices && !choices.includes(value)) {\n\t\treturn {\n\t\t\terror: `Invalid ${key} value \"${rawValue}\". Choose one of: ${choices.join(\", \")}.`,\n\t\t};\n\t}\n\t// `model` is free-form — keep the original casing (e.g. provider/Model-Name).\n\tconst normalized = choices ? value : rawValue.trim();\n\tconst current = await getCommandSettings(runtime, roomId);\n\tawait runtime.setCache<CommandSettings>(cacheKey(roomId), {\n\t\t...current,\n\t\t[key]: normalized,\n\t});\n\treturn { value: normalized };\n}\n",
|
|
9
|
+
"/**\n * Deterministic command handlers.\n *\n * `runCommand` is the single source of truth for what an agent-target command\n * does. It reads real runtime/registry state, persists option settings, invokes\n * owned runtime actions when needed, and returns a deterministic\n * `CommandResult`. No LLM improvisation: the same command path runs on web,\n * TUI, Discord, and Telegram.\n */\n\nimport type {\n\tAction,\n\tHandlerCallback,\n\tIAgentRuntime,\n\tMemory,\n\tUUID,\n} from \"@elizaos/core\";\nimport {\n\tfindCommandByKeyForRuntime,\n\tgetCommandsByCategoryForRuntime,\n\tgetEnabledCommandsForRuntime,\n\tuseRuntime,\n} from \"../registry\";\nimport type {\n\tCommandCategory,\n\tCommandContext,\n\tCommandResult,\n\tParsedCommand,\n} from \"../types\";\nimport {\n\ttype CommandSettings,\n\tclearCommandSettings,\n\tgetCommandSettings,\n\tsetCommandSetting,\n} from \"./command-settings\";\n\n/**\n * Commands whose effects are fully owned by this deterministic layer. Broader\n * lifecycle/management commands (`stop`, `restart`, `allowlist`, `approve`, …)\n * still flow through the pipeline that owns their side effects.\n */\nexport const DETERMINISTIC_COMMAND_KEYS: readonly string[] = [\n\t\"help\",\n\t\"commands\",\n\t\"status\",\n\t\"whoami\",\n\t\"context\",\n\t\"reset\",\n\t\"new\",\n\t\"compact\",\n\t\"models\",\n\t\"usage\",\n\t\"think\",\n\t\"verbose\",\n\t\"reasoning\",\n\t\"queue\",\n\t\"elevated\",\n\t\"model\",\n\t\"tts\",\n];\n\nconst DETERMINISTIC_KEYS: ReadonlySet<string> = new Set(\n\tDETERMINISTIC_COMMAND_KEYS,\n);\n\n/** Whether a command's whole effect is handled by this deterministic layer. */\nexport function isDeterministicCommand(key: string): boolean {\n\treturn DETERMINISTIC_KEYS.has(key);\n}\n\nconst CATEGORY_ORDER: CommandCategory[] = [\n\t\"status\",\n\t\"session\",\n\t\"options\",\n\t\"media\",\n\t\"management\",\n\t\"tools\",\n\t\"docks\",\n\t\"skills\",\n];\n\nconst OPTION_COMMANDS = {\n\tthink: { key: \"thinking\", label: \"Thinking\" },\n\tverbose: { key: \"verbose\", label: \"Verbose\" },\n\treasoning: { key: \"reasoning\", label: \"Reasoning\" },\n\tqueue: { key: \"queue\", label: \"Queue mode\" },\n\televated: { key: \"elevated\", label: \"Elevated mode\" },\n\tmodel: { key: \"model\", label: \"Model\" },\n\ttts: { key: \"tts\", label: \"TTS\" },\n} as const satisfies Record<\n\tstring,\n\t{ key: keyof CommandSettings; label: string }\n>;\n\nfunction reply(text: string): CommandResult {\n\treturn { handled: true, reply: text, shouldContinue: false };\n}\n\nfunction authError(): CommandResult {\n\treturn reply(\"This command requires authorization.\");\n}\n\nfunction formatCommandList(agentId?: string | null): string {\n\tconst lines: string[] = [];\n\tfor (const category of CATEGORY_ORDER) {\n\t\tconst commands = getCommandsByCategoryForRuntime(category, agentId);\n\t\tif (commands.length === 0) continue;\n\t\tlines.push(`**${category}**`);\n\t\tfor (const command of commands) {\n\t\t\tconst alias = command.textAliases[0] ?? `/${command.key}`;\n\t\t\tconst auth = command.requiresAuth ? \" (requires auth)\" : \"\";\n\t\t\tlines.push(` ${alias} — ${command.description}${auth}`);\n\t\t}\n\t}\n\treturn lines.join(\"\\n\");\n}\n\nfunction resolveModelLabel(runtime: IAgentRuntime): string {\n\tconst fromSetting =\n\t\truntime.getSetting(\"LARGE_MODEL\") ??\n\t\truntime.getSetting(\"ANTHROPIC_LARGE_MODEL\") ??\n\t\truntime.getSetting(\"OPENAI_LARGE_MODEL\");\n\tif (typeof fromSetting === \"string\" && fromSetting.trim()) {\n\t\treturn fromSetting.trim();\n\t}\n\tconst fromCharacter = (\n\t\truntime.character?.settings as Record<string, unknown> | undefined\n\t)?.model;\n\tif (typeof fromCharacter === \"string\" && fromCharacter.trim()) {\n\t\treturn fromCharacter.trim();\n\t}\n\treturn \"default\";\n}\n\nasync function countRoomMessages(\n\truntime: IAgentRuntime,\n\troomId: string,\n): Promise<number | null> {\n\tif (typeof runtime.countMemories !== \"function\") return null;\n\ttry {\n\t\treturn await runtime.countMemories({\n\t\t\troomIds: [roomId as UUID],\n\t\t\ttableName: \"messages\",\n\t\t\tunique: false,\n\t\t});\n\t} catch {\n\t\treturn null;\n\t}\n}\n\nasync function clearRoomMessages(\n\truntime: IAgentRuntime,\n\troomId: string,\n): Promise<number | null> {\n\tconst before = await countRoomMessages(runtime, roomId);\n\tif (typeof runtime.deleteAllMemories !== \"function\") return null;\n\tawait runtime.deleteAllMemories([roomId as UUID], \"messages\");\n\treturn before;\n}\n\nfunction findAction(runtime: IAgentRuntime, name: string): Action | undefined {\n\treturn runtime.actions?.find((action) => action.name === name);\n}\n\nasync function runCompactAction(\n\truntime: IAgentRuntime,\n\tmessage: Memory | undefined,\n\tcallback?: HandlerCallback,\n): Promise<CommandResult> {\n\tconst action = findAction(runtime, \"COMPACT_CONVERSATION\");\n\tif (!action || !message) {\n\t\treturn reply(\"Conversation compaction is not available in this runtime.\");\n\t}\n\tconst result = await action.handler(\n\t\truntime,\n\t\tmessage,\n\t\tundefined,\n\t\tundefined,\n\t\tcallback,\n\t);\n\tif (result?.text && result.text.trim().length > 0) return reply(result.text);\n\treturn reply(\"Conversation compaction completed.\");\n}\n\nasync function setOptionCommand(\n\truntime: IAgentRuntime,\n\troomId: string,\n\tparsed: ParsedCommand,\n\toption: { key: keyof CommandSettings; label: string },\n): Promise<CommandResult> {\n\tconst rawValue = parsed.rawArgs?.trim() ?? parsed.args[0]?.trim() ?? \"\";\n\tif (!rawValue) {\n\t\tconst settings = await getCommandSettings(runtime, roomId);\n\t\tconst current =\n\t\t\toption.key === \"model\"\n\t\t\t\t? (settings.model ?? resolveModelLabel(runtime))\n\t\t\t\t: (settings[option.key] ?? \"default\");\n\t\treturn reply(`${option.label} is ${current}.`);\n\t}\n\n\tconst result = await setCommandSetting(runtime, roomId, option.key, rawValue);\n\tif (\"error\" in result) return reply(result.error);\n\treturn reply(`${option.label} set to ${result.value}.`);\n}\n\n/**\n * Run a parsed command deterministically. Returns a `CommandResult` whose\n * `reply` is shown to the user. `handled: false` means this layer doesn't own\n * the command (the caller should let it flow to the normal pipeline).\n */\nexport async function runCommand(\n\truntime: IAgentRuntime,\n\tparsed: ParsedCommand,\n\tcontext: CommandContext,\n): Promise<CommandResult> {\n\tconst agentId = runtime.agentId;\n\tuseRuntime(agentId);\n\tconst definition = findCommandByKeyForRuntime(parsed.key, agentId);\n\n\t// Auth gate — enforced server-side on every surface, never client-trusted.\n\tif (definition?.requiresAuth && !context.isAuthorized) return authError();\n\tif (definition?.requiresElevated && !context.isElevated) {\n\t\treturn reply(\"This command requires elevated permissions.\");\n\t}\n\n\tconst roomId = context.roomId;\n\n\tswitch (parsed.key) {\n\t\tcase \"help\":\n\t\tcase \"commands\":\n\t\t\treturn reply(`Available commands:\\n${formatCommandList(agentId)}`);\n\n\t\tcase \"status\": {\n\t\t\tconst settings = await getCommandSettings(runtime, roomId);\n\t\t\tconst messageCount = await countRoomMessages(runtime, roomId);\n\t\t\tconst lines = [\n\t\t\t\t`Agent: ${runtime.character?.name ?? runtime.agentId}`,\n\t\t\t\t`Model: ${settings.model ?? resolveModelLabel(runtime)}`,\n\t\t\t\t`Thinking: ${settings.thinking ?? \"default\"}`,\n\t\t\t\t`Reasoning: ${settings.reasoning ?? \"default\"}`,\n\t\t\t\t`Verbose: ${settings.verbose ?? \"default\"}`,\n\t\t\t\t`Queue: ${settings.queue ?? \"default\"}`,\n\t\t\t\t`TTS: ${settings.tts ?? \"default\"}`,\n\t\t\t\tmessageCount === null ? null : `Messages: ${messageCount}`,\n\t\t\t\t`Commands enabled: ${getEnabledCommandsForRuntime(agentId).length}`,\n\t\t\t].filter(Boolean) as string[];\n\t\t\treturn reply(lines.join(\"\\n\"));\n\t\t}\n\n\t\tcase \"whoami\": {\n\t\t\tconst who = context.senderName ?? context.senderId ?? \"you\";\n\t\t\treturn reply(\n\t\t\t\t`You are ${who}.\\nAuthorized: ${context.isAuthorized ? \"yes\" : \"no\"}\\nElevated: ${context.isElevated ? \"yes\" : \"no\"}`,\n\t\t\t);\n\t\t}\n\n\t\tcase \"context\": {\n\t\t\tconst settings = await getCommandSettings(runtime, roomId);\n\t\t\tconst lines = [\n\t\t\t\t`Room: ${roomId}`,\n\t\t\t\tcontext.channelId ? `Channel: ${context.channelId}` : null,\n\t\t\t\t`Active settings: ${describeSettings(settings)}`,\n\t\t\t].filter(Boolean) as string[];\n\t\t\treturn reply(lines.join(\"\\n\"));\n\t\t}\n\n\t\tcase \"models\":\n\t\t\treturn reply(`Current model: ${resolveModelLabel(runtime)}`);\n\n\t\tcase \"usage\": {\n\t\t\tconst usage = await runtime.getCache<{\n\t\t\t\tpromptTokens?: number;\n\t\t\t\tcompletionTokens?: number;\n\t\t\t\ttotalTokens?: number;\n\t\t\t}>(`token-usage:${roomId}`);\n\t\t\tif (!usage?.totalTokens) {\n\t\t\t\treturn reply(\"No token usage recorded for this conversation yet.\");\n\t\t\t}\n\t\t\treturn reply(\n\t\t\t\t`Token usage — prompt: ${usage.promptTokens ?? 0}, completion: ${usage.completionTokens ?? 0}, total: ${usage.totalTokens}.`,\n\t\t\t);\n\t\t}\n\n\t\tcase \"think\":\n\t\tcase \"verbose\":\n\t\tcase \"reasoning\":\n\t\tcase \"queue\":\n\t\tcase \"elevated\":\n\t\tcase \"model\":\n\t\tcase \"tts\":\n\t\t\treturn setOptionCommand(\n\t\t\t\truntime,\n\t\t\t\troomId,\n\t\t\t\tparsed,\n\t\t\t\tOPTION_COMMANDS[parsed.key],\n\t\t\t);\n\n\t\tcase \"reset\": {\n\t\t\tawait clearCommandSettings(runtime, roomId);\n\t\t\tconst deleted = await clearRoomMessages(runtime, roomId);\n\t\t\tif (deleted === null) {\n\t\t\t\treturn reply(\n\t\t\t\t\t\"Reset command settings for this room. Message history is unchanged because memory deletion is unavailable.\",\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn reply(\n\t\t\t\t`Reset this room: cleared command settings and ${deleted} message(s).`,\n\t\t\t);\n\t\t}\n\n\t\tcase \"new\":\n\t\t\tawait clearCommandSettings(runtime, roomId);\n\t\t\treturn reply(\"Started a new conversation context for this room.\");\n\n\t\tcase \"compact\":\n\t\t\treturn runCompactAction(runtime, context.message, context.callback);\n\n\t\tdefault:\n\t\t\treturn { handled: false, shouldContinue: true };\n\t}\n}\n\nfunction describeSettings(settings: CommandSettings): string {\n\tconst entries = Object.entries(settings).filter(([, v]) => v);\n\tif (entries.length === 0) return \"none\";\n\treturn entries.map(([k, v]) => `${k}=${v}`).join(\", \");\n}\n",
|
|
10
|
+
"/**\n * Command dispatch — the one entry point that turns a slash-command message\n * into a deterministic reply. Reused by:\n * - the agent's command actions (the registered `*_COMMAND` actions),\n * - the pre-LLM shortcut gate (slash commands are always-on shortcuts), and\n * - connector bridges that want an instant local reply.\n *\n * It detects + parses the command, builds a `CommandContext`, runs `runCommand`,\n * and (when the command was handled) fires the callback with the reply. Returns\n * whether it owned the message, so callers can fall through to the normal\n * pipeline when it didn't.\n */\n\nimport type { HandlerCallback, IAgentRuntime, Memory } from \"@elizaos/core\";\nimport { detectCommand, hasCommand } from \"../parser\";\nimport { findCommandByKeyForRuntime } from \"../registry\";\nimport type { CommandContext, ParsedCommand } from \"../types\";\nimport { isDeterministicCommand, runCommand } from \"./handlers\";\n\nexport interface CommandDispatchOptions {\n\t/**\n\t * Trust level for the sender, used to gate `requiresAuth`/`requiresElevated`\n\t * commands. The caller knows the surface: the local dashboard/TUI sender is\n\t * the owner (authorized + elevated); a connector resolves it from pairing /\n\t * allowlist. Defaults to unauthorized so a missing resolver fails closed.\n\t */\n\tisAuthorized?: boolean;\n\tisElevated?: boolean;\n\tsenderName?: string;\n\tcallback?: HandlerCallback;\n\t/**\n\t * When true (the default), only commands owned by the deterministic command\n\t * layer are dispatched; broader management commands fall through to the\n\t * pipeline that owns their side effects.\n\t */\n\tdeterministicOnly?: boolean;\n\t/** @deprecated Use `deterministicOnly`. */\n\tgateSafeOnly?: boolean;\n}\n\n/** What a successful dispatch resolved to. */\nexport interface CommandDispatchResult {\n\thandled: boolean;\n\treply?: string;\n\tcommand?: ParsedCommand;\n}\n\nfunction buildContext(\n\tmessage: Memory,\n\toptions: CommandDispatchOptions,\n): CommandContext {\n\tconst content = message.content as {\n\t\tchannelId?: string;\n\t\tsource?: string;\n\t};\n\tconst context: CommandContext = {\n\t\tsenderId: message.entityId,\n\t\tisAuthorized: options.isAuthorized ?? false,\n\t\tisElevated: options.isElevated ?? false,\n\t\troomId: message.roomId,\n\t\tmessage,\n\t};\n\tif (options.senderName) context.senderName = options.senderName;\n\tif (options.callback) context.callback = options.callback;\n\tconst channelId = content.channelId ?? content.source;\n\tif (channelId) context.channelId = channelId;\n\treturn context;\n}\n\n/**\n * Detect, parse, and deterministically run a slash command. Does NOT fire a\n * callback — returns the result so the caller controls how to surface the reply.\n */\nexport async function resolveCommand(\n\truntime: IAgentRuntime,\n\tmessage: Memory,\n\toptions: CommandDispatchOptions = {},\n): Promise<CommandDispatchResult> {\n\tconst text = message.content.text ?? \"\";\n\tif (!hasCommand(text)) return { handled: false };\n\n\tconst detection = detectCommand(text);\n\tif (!detection.isCommand || !detection.command) return { handled: false };\n\n\tconst parsed = detection.command;\n\tconst definition = findCommandByKeyForRuntime(parsed.key, runtime.agentId);\n\t// Only agent-target commands are dispatched here; navigate/client targets are\n\t// resolved by the client/connector, never the agent.\n\tif (definition?.target && definition.target.kind !== \"agent\") {\n\t\treturn { handled: false, command: parsed };\n\t}\n\tconst deterministicOnly =\n\t\toptions.deterministicOnly ?? options.gateSafeOnly ?? true;\n\tif (deterministicOnly && !isDeterministicCommand(parsed.key)) {\n\t\treturn { handled: false, command: parsed };\n\t}\n\n\tconst result = await runCommand(\n\t\truntime,\n\t\tparsed,\n\t\tbuildContext(message, options),\n\t);\n\tif (!result.handled) return { handled: false, command: parsed };\n\tconst dispatched: CommandDispatchResult = { handled: true, command: parsed };\n\tif (result.reply !== undefined) dispatched.reply = result.reply;\n\treturn dispatched;\n}\n\n/**\n * Resolve a command and, when handled, fire `callback` with the reply. Returns\n * true when the command was handled (so the caller skips the LLM pipeline).\n */\nexport async function dispatchCommandMessage(\n\truntime: IAgentRuntime,\n\tmessage: Memory,\n\tcallback: (reply: { text: string; source?: string }) => unknown,\n\toptions: CommandDispatchOptions = {},\n): Promise<boolean> {\n\tconst result = await resolveCommand(runtime, message, options);\n\tif (!result.handled || result.reply === undefined) return false;\n\tawait callback({ text: result.reply, source: \"command\" });\n\treturn true;\n}\n",
|
|
11
|
+
"/**\n * Command actions — the registered elizaOS `Action`s for agent-target commands.\n *\n * One action per deterministic command (`/help`, `/status`, `/models`, …).\n * Each action's `validate()` is strictly slash-only (it matches just its own\n * command key) and its `similes` are the slash aliases only — no natural\n * language — so the LLM never misroutes a conversational message to a command.\n * The handler delegates to the shared `resolveCommand`, so an action invoked by\n * the planner produces the exact same deterministic reply as the pre-LLM gate.\n */\n\nimport type { Action, IAgentRuntime, Memory } from \"@elizaos/core\";\nimport { detectCommand, hasCommand } from \"../parser\";\nimport { findCommandByKey } from \"../registry\";\nimport { resolveCommand } from \"./dispatch\";\nimport { isDeterministicCommand } from \"./handlers\";\n\n/** Sources that are the local owner surface (authorized + elevated). */\nconst OWNER_SOURCES: ReadonlySet<string> = new Set([\n\t\"client_chat\",\n\t\"gui\",\n\t\"tui\",\n\t\"direct\",\n\t\"dashboard\",\n]);\n\n/**\n * Trust for a message reaching the agent pipeline as a command action. Local\n * owner surfaces are trusted; connectors gate auth-required commands explicitly\n * via `dispatchCommandMessage` options, so a connector message stays untrusted\n * here (auth-required commands fail closed).\n */\nfunction resolveTrust(message: Memory): {\n\tisAuthorized: boolean;\n\tisElevated: boolean;\n} {\n\tconst source = (message.content as { source?: string }).source;\n\tconst trusted = !source || OWNER_SOURCES.has(source);\n\treturn { isAuthorized: trusted, isElevated: trusted };\n}\n\nfunction buildAction(\n\tkey: string,\n\t_nativeName: string,\n\tdescription: string,\n\taliases: string[],\n): Action {\n\treturn {\n\t\tname: `${key.toUpperCase()}_COMMAND`,\n\t\tdescription,\n\t\t// Slash-only similes — never natural language (prevents LLM misrouting).\n\t\tsimiles: aliases,\n\t\tsuppressEarlyReply: true,\n\t\tsuppressPostActionContinuation: true,\n\t\tvalidate: async (_runtime: IAgentRuntime, message: Memory) => {\n\t\t\tconst text = message.content.text ?? \"\";\n\t\t\tif (!hasCommand(text)) return false;\n\t\t\tconst detection = detectCommand(text);\n\t\t\treturn detection.isCommand && detection.command?.key === key;\n\t\t},\n\t\thandler: async (runtime, message, _state, _options, callback) => {\n\t\t\tconst result = await resolveCommand(runtime, message, {\n\t\t\t\t...resolveTrust(message),\n\t\t\t\tdeterministicOnly: true,\n\t\t\t\t...(callback ? { callback } : {}),\n\t\t\t});\n\t\t\tif (!result.handled || result.reply === undefined) {\n\t\t\t\treturn { success: false };\n\t\t\t}\n\t\t\tif (callback) {\n\t\t\t\tawait callback({ text: result.reply, source: \"command\" });\n\t\t\t}\n\t\t\treturn { success: true, text: result.reply };\n\t\t},\n\t};\n}\n\n/**\n * Build the deterministic command actions for the per-runtime registry. One\n * action per deterministic agent-target command. Call after `useRuntime(agentId)`.\n */\nexport function createCommandActions(commandKeys: string[]): Action[] {\n\tconst actions: Action[] = [];\n\tfor (const key of commandKeys) {\n\t\tif (!isDeterministicCommand(key)) continue;\n\t\tconst definition = findCommandByKey(key);\n\t\tif (!definition) continue;\n\t\tif (definition.target && definition.target.kind !== \"agent\") continue;\n\t\tactions.push(\n\t\t\tbuildAction(\n\t\t\t\tkey,\n\t\t\t\tdefinition.nativeName ?? key,\n\t\t\t\tdefinition.description,\n\t\t\t\tdefinition.textAliases,\n\t\t\t),\n\t\t);\n\t}\n\treturn actions;\n}\n",
|
|
12
|
+
"/**\n * Slash-command shortcuts (#8790 × #8791).\n *\n * Each deterministic agent-target command is registered as an *explicit* shortcut\n * into the runtime's `ShortcutRegistry`. The pre-LLM gate matches the slash/`!`\n * alias and fires the command's `*_COMMAND` action directly — so `/help`,\n * `/status`, `/models`, … resolve deterministically before any model call,\n * identically on every surface. Explicit shortcuts are always-on (a slash is an\n * unambiguous invocation); they carry no auth flag here because the command\n * action re-checks sender trust itself.\n */\n\nimport type { ShortcutDefinition } from \"@elizaos/core\";\nimport { findCommandByKey } from \"../registry\";\nimport { DETERMINISTIC_COMMAND_KEYS } from \"./handlers\";\n\n/**\n * Build the explicit slash-command shortcuts for the built-in deterministic\n * commands, from the default registry. Built once at module load; each\n * shortcut targets the matching `<KEY>_COMMAND` action.\n */\nexport function createCommandShortcuts(\n\tcommandKeys: readonly string[] = DETERMINISTIC_COMMAND_KEYS,\n): ShortcutDefinition[] {\n\tconst shortcuts: ShortcutDefinition[] = [];\n\tfor (const key of commandKeys) {\n\t\tconst definition = findCommandByKey(key);\n\t\tif (!definition) continue;\n\t\tif (definition.target && definition.target.kind !== \"agent\") continue;\n\t\tshortcuts.push({\n\t\t\tid: `cmd:${key}`,\n\t\t\tkind: \"explicit\",\n\t\t\taliases: definition.textAliases,\n\t\t\ttarget: { kind: \"action\", name: `${key.toUpperCase()}_COMMAND` },\n\t\t});\n\t}\n\treturn shortcuts;\n}\n\n/** The explicit slash-command shortcuts for built-in deterministic commands. */\nexport const explicitCommandShortcuts: ShortcutDefinition[] =\n\tcreateCommandShortcuts();\n\n/**\n * Natural-language shortcuts (#8791 C6).\n *\n * These are narrow, anchored, and confidence-floored. Each one targets an\n * UNAMBIGUOUS deterministic intent that maps onto a deterministic `*_COMMAND`\n * action, so the pre-LLM gate can fire it with zero inference.\n *\n * The sole production shortcut here is \"what commands can I use\" / \"show me the\n * commands\" / \"list the available commands\" → `COMMANDS_COMMAND`. The patterns\n * are anchored (`^…$`) over ASR-normalized text and require both a list/show\n * verb and the literal word \"commands\", so a conversational message like \"can\n * you help me with this command line\" never matches — it lacks the anchored\n * verb+\"commands\" shape and falls through to the LLM.\n */\nexport const naturalShortcuts: ShortcutDefinition[] = [\n\t{\n\t\tid: \"nl:commands\",\n\t\tkind: \"natural\",\n\t\tpatterns: [\n\t\t\t// \"what commands can i use\", \"what commands are available\", \"what commands do you have\"\n\t\t\t{\n\t\t\t\tregex:\n\t\t\t\t\t/^what commands (?:can i (?:use|run)|are (?:there|available)|do you (?:have|support))$/u,\n\t\t\t},\n\t\t\t// \"show/list/give me the commands\", \"show me a list of commands\",\n\t\t\t// \"list available commands\", \"list all the commands\", \"what are the commands\"\n\t\t\t{\n\t\t\t\tregex:\n\t\t\t\t\t/^(?:show|list|give|tell)(?: me)?(?: a list of| the list of| all(?: of)?| the| your| available)* commands$/u,\n\t\t\t},\n\t\t\t{ regex: /^what are(?: all)?(?: the| your| available)* commands$/u },\n\t\t],\n\t\ttarget: { kind: \"action\", name: \"COMMANDS_COMMAND\" },\n\t\trequiresAction: \"COMMANDS_COMMAND\",\n\t\tconfidence: 0.95,\n\t},\n];\n\n/**\n * All command shortcuts the plugin registers: the explicit slash-command\n * shortcuts plus the narrow natural-language shortcuts.\n */\nexport const commandShortcuts: ShortcutDefinition[] = [\n\t...explicitCommandShortcuts,\n\t...naturalShortcuts,\n];\n",
|
|
13
|
+
"/**\n * Command action layer (#8790).\n *\n * Exports the deterministic command handlers, the per-conversation settings\n * store, the dispatch helper (used by the pre-LLM gate and connectors), and the\n * registered `*_COMMAND` actions.\n */\n\nimport { createCommandActions } from \"./command-actions\";\nimport { DETERMINISTIC_COMMAND_KEYS } from \"./handlers\";\n\nexport * from \"./command-actions\";\nexport * from \"./command-settings\";\nexport * from \"./dispatch\";\nexport * from \"./handlers\";\nexport * from \"./shortcuts\";\n\n/**\n * The deterministic command actions for the built-in deterministic commands. Built\n * from the default registry so they can be registered statically on the plugin;\n * request-time command resolution reads the per-runtime store directly.\n */\nexport const commandActions = createCommandActions([\n\t...DETERMINISTIC_COMMAND_KEYS,\n]);\n",
|
|
14
|
+
"/**\n * ConnectorCommandBridge — the one documented contract every communication\n * connector (Discord, Telegram, …) implements to register and dispatch the\n * universal slash-command catalog onto its native command surface (#8790).\n *\n * The catalog (`getConnectorCommands(surface)`) is connector-neutral; each\n * connector still has to (a) map those commands onto its own command registry\n * and (b) run them when invoked. Before this contract, each connector invented\n * its own register/dispatch shape and — critically — neither gated\n * `requiresAuth` / `requiresElevated` commands at the connector boundary. This\n * module pins down a single shape so the two connectors behave consistently and\n * share one auth-gating decision instead of two divergent copies.\n *\n * The bridge is deliberately a thin interface + a few pure helpers, NOT a\n * framework: connectors keep owning their own message pipelines and reply\n * mechanics. What they share is:\n *\n * 1. the three target kinds and how they route (`agent` / `navigate` /\n * `client`),\n * 2. one auth-gating decision (`gateConnectorCommand`) producing one refusal\n * message, and\n * 3. one place to read a command's auth requirements\n * (`resolveConnectorCommandAuth`).\n *\n * Auth model: the connector resolves the *sender's* trust level\n * (`isAuthorized` / `isElevated`) using whatever owner/allowlist mechanism it\n * already has — the canonical-owner / world-role model in `@elizaos/core`\n * (`hasRoleAccess`). The bridge does not invent a new auth model; it only\n * decides whether a given command may run for an already-resolved sender.\n */\n\nimport { findCommandByKeyForRuntime } from \"./registry\";\nimport type { CommandTarget } from \"./types\";\n\n/**\n * The sender's resolved trust level on a connector surface. The connector fills\n * this in from its own owner/allowlist resolution before dispatching; the\n * bridge treats missing/false as \"fails closed\" (unauthorized).\n */\nexport interface ConnectorSenderAuth {\n\tisAuthorized: boolean;\n\tisElevated: boolean;\n\t/** Optional human label for `/whoami`-style replies. */\n\tsenderName?: string;\n}\n\n/** A command's auth requirements, read from its catalog definition. */\nexport interface ConnectorCommandAuth {\n\trequiresAuth: boolean;\n\trequiresElevated: boolean;\n}\n\n/** The outcome of gating a command for a sender. */\nexport type ConnectorGateDecision =\n\t| { allowed: true }\n\t| { allowed: false; reply: string };\n\n/**\n * Resolve a command's auth requirements from the active command registry.\n * `name` is the connector command name (`ConnectorCommand.name`), which is the\n * command's `nativeName ?? key`; the registry is keyed by `key`, so the lookup\n * tries the name as a key directly. Unknown commands are treated as requiring\n * no special auth (the catalog only emits real commands, and agent-target\n * commands are auth-gated again inside `runCommand`).\n *\n * The lookup is scoped directly by `agentId` so concurrent connector requests\n * cannot move a shared active-store cursor underneath each other.\n */\nexport function resolveConnectorCommandAuth(\n\tagentId: string,\n\tname: string,\n): ConnectorCommandAuth {\n\tconst definition = findCommandByKeyForRuntime(name, agentId);\n\treturn {\n\t\trequiresAuth: definition?.requiresAuth ?? false,\n\t\trequiresElevated: definition?.requiresElevated ?? false,\n\t};\n}\n\n/**\n * The single auth-gating decision both connectors share. Given a command's\n * requirements and the sender's resolved trust level, decide whether the\n * command may run — and, when it may not, produce the one refusal message\n * every connector emits. Fails closed: an unresolved sender (`isAuthorized:\n * false`) is refused for any auth-gated command.\n */\nexport function gateConnectorCommand(\n\trequirements: ConnectorCommandAuth,\n\tsender: ConnectorSenderAuth,\n): ConnectorGateDecision {\n\tif (requirements.requiresAuth && !sender.isAuthorized) {\n\t\treturn {\n\t\t\tallowed: false,\n\t\t\treply:\n\t\t\t\t\"This command requires authorization. Pair your account or ask an owner to run it.\",\n\t\t};\n\t}\n\tif (requirements.requiresElevated && !sender.isElevated) {\n\t\treturn {\n\t\t\tallowed: false,\n\t\t\treply: \"This command requires elevated permissions.\",\n\t\t};\n\t}\n\treturn { allowed: true };\n}\n\n/**\n * Convenience: resolve a command's requirements and gate it in one call.\n */\nexport function gateConnectorCommandByName(\n\tagentId: string,\n\tname: string,\n\tsender: ConnectorSenderAuth,\n): ConnectorGateDecision {\n\treturn gateConnectorCommand(\n\t\tresolveConnectorCommandAuth(agentId, name),\n\t\tsender,\n\t);\n}\n\n/**\n * The contract every connector command bridge implements. `TCommand` is the\n * connector's native command shape (Discord `SlashCommand`, Telegram\n * descriptor, …) and `TContext` is its per-invocation context (a Discord\n * interaction, a Telegraf `Context`, …). Implementations are expected to:\n *\n * - `registerCommands()` — project `getConnectorCommands(surface)` onto\n * the native command registry (deduping against\n * connector built-ins) and return what was\n * registered.\n * - `dispatch(target, ...)` — run a single command, branching on its target\n * kind, after the sender has been gated. The\n * bridge's auth helpers (`gateConnectorCommand`)\n * are applied before `dispatch` so refused\n * commands never reach it.\n *\n * The three target kinds behave consistently across connectors:\n *\n * - `agent` → run the command. Gate-safe deterministic commands\n * (help/status/models/usage/…) resolve to a local reply via\n * `resolveCommand`; option/lifecycle commands route the\n * reconstructed command text through the connector's message\n * pipeline and surface the agent reply.\n * - `navigate` → reply with a description of the in-app destination (a deep\n * link); the connector cannot open the Eliza app itself.\n * - `client` → a GUI/TUI-only behavior with no remote surface; the catalog\n * filters these off connector surfaces, so this is defensive.\n */\nexport interface ConnectorCommandBridge<TCommand, TContext> {\n\t/** The catalog surface this bridge serves (\"discord\" | \"telegram\"). */\n\treadonly surface: string;\n\n\t/**\n\t * Project the catalog onto the connector's native command registry and\n\t * return the registered native commands. Deduping against connector\n\t * built-ins is the implementation's responsibility.\n\t */\n\tregisterCommands(): TCommand[];\n\n\t/**\n\t * Resolve the invoking sender's trust level from the connector's own\n\t * owner/allowlist mechanism. Fails closed (unauthorized) when identity\n\t * cannot be resolved.\n\t */\n\tresolveSenderAuth(context: TContext): Promise<ConnectorSenderAuth>;\n\n\t/**\n\t * Run a single command for an already-gated sender, branching on its target\n\t * kind. Returns once the reply has been surfaced on the connector.\n\t */\n\tdispatch(\n\t\ttarget: CommandTarget,\n\t\tcontext: TContext,\n\t\tsender: ConnectorSenderAuth,\n\t): Promise<void>;\n}\n",
|
|
15
|
+
"/**\n * Settings sections — the canonical destinations the `/settings <section>`\n * command can open in the Eliza app.\n *\n * Each section has a stable `id` (the canonical token connectors advertise and\n * the app routes on), a human `label`, and optional `aliases` that map common\n * synonyms onto the canonical id. `resolveSettingsSection` turns any raw token\n * (id or alias) into its canonical id.\n */\n\nexport interface SettingsSection {\n\t/** Canonical, stable section id used for routing and as the choice token. */\n\tid: string;\n\t/** Human-readable label for display. */\n\tlabel: string;\n\t/** Alternate tokens that resolve to this section. */\n\taliases?: string[];\n}\n\nconst SETTINGS_SECTIONS: ReadonlyArray<SettingsSection> = [\n\t{\n\t\tid: \"ai-model\",\n\t\tlabel: \"AI Model & Providers\",\n\t\taliases: [\"model\", \"models\", \"providers\", \"provider\", \"llm\"],\n\t},\n\t{ id: \"general\", label: \"General\", aliases: [\"basics\"] },\n\t{ id: \"agent\", label: \"Agent\", aliases: [\"character\", \"persona\"] },\n\t{ id: \"voice\", label: \"Voice\", aliases: [\"audio\", \"tts\", \"speech\"] },\n\t{ id: \"connectors\", label: \"Connectors\", aliases: [\"integrations\"] },\n\t{ id: \"skills\", label: \"Skills\" },\n\t{ id: \"memory\", label: \"Memory\", aliases: [\"knowledge\"] },\n\t{ id: \"permissions\", label: \"Permissions\", aliases: [\"security\", \"access\"] },\n\t{ id: \"billing\", label: \"Billing\", aliases: [\"plan\", \"subscription\"] },\n\t{ id: \"appearance\", label: \"Appearance\", aliases: [\"theme\", \"display\"] },\n\t{ id: \"notifications\", label: \"Notifications\", aliases: [\"alerts\"] },\n\t{ id: \"advanced\", label: \"Advanced\", aliases: [\"developer\", \"debug\"] },\n];\n\n/** Lazily-built lookup from id/alias → canonical section. */\nlet lookup: Map<string, SettingsSection> | null = null;\n\nfunction getLookup(): Map<string, SettingsSection> {\n\tif (lookup) return lookup;\n\tconst map = new Map<string, SettingsSection>();\n\tfor (const section of SETTINGS_SECTIONS) {\n\t\tmap.set(section.id, section);\n\t\tfor (const alias of section.aliases ?? []) {\n\t\t\tmap.set(alias, section);\n\t\t}\n\t}\n\tlookup = map;\n\treturn map;\n}\n\n/** All canonical section ids, in declaration order. */\nexport function getSettingsSections(): SettingsSection[] {\n\treturn [...SETTINGS_SECTIONS];\n}\n\n/**\n * Canonical section ids, usable directly as connector option choices.\n *\n * Returns ids only (not aliases) so the choice list stays small and stable; the\n * count is well under Discord's 25-choice cap.\n */\nexport function getSettingsSectionChoices(): string[] {\n\treturn SETTINGS_SECTIONS.map((section) => section.id);\n}\n\n/**\n * Resolve a raw `/settings` section token (canonical id or alias) to its\n * canonical section id. Returns `undefined` when the token matches nothing.\n */\nexport function resolveSettingsSection(raw: string): string | undefined {\n\tconst normalized = raw.trim().toLowerCase();\n\tif (!normalized) return undefined;\n\treturn getLookup().get(normalized)?.id;\n}\n",
|
|
16
|
+
"/**\n * Navigation + client commands as first-class `CommandDefinition`s.\n *\n * These used to be defined inline in `connector-catalog.ts` as bare\n * `ConnectorCommand`s, which meant they could not carry `surfaces`, auth flags,\n * `category`, or flow through `serializeCommand` like agent commands do (#8790).\n * Defining them as `CommandDefinition`s with an explicit `target` and `surfaces`\n * lets the catalog treat agent / navigate / client commands uniformly:\n *\n * - `navigate` commands open a destination in the Eliza app; `path` is the\n * in-app deep link a connector advertises, `tab`/`viewId`/`section` are the\n * routing hints the GUI/TUI use to open it deterministically. Offered on\n * every surface (chat connectors reply with the deep link).\n * - `client` commands run a GUI/TUI-only behavior with no remote surface, so\n * they declare `surfaces: [\"gui\", \"tui\"]` and are filtered off chat\n * connectors by surface, not by an ad-hoc branch.\n *\n * The `path`/`tab` values mirror the canonical route table in `@elizaos/ui`\n * (`navigation/index.ts` `TAB_PATHS`); keep them in sync there.\n */\n\nimport { getSettingsSectionChoices } from \"./settings-sections\";\nimport type { CommandDefinition, CommandSurface } from \"./types\";\n\nconst IN_APP_SURFACES: CommandSurface[] = [\"gui\", \"tui\"];\n\n/** Navigation destinations — open an in-app route on any surface. */\nconst NAVIGATE_COMMANDS: CommandDefinition[] = [\n\t{\n\t\tkey: \"settings\",\n\t\tnativeName: \"settings\",\n\t\tdescription: \"Open agent settings\",\n\t\ttextAliases: [\"/settings\"],\n\t\tscope: \"both\",\n\t\tcategory: \"docks\",\n\t\ticon: \"settings\",\n\t\ttarget: { kind: \"navigate\", path: \"/settings\", tab: \"settings\" },\n\t\tacceptsArgs: true,\n\t\targs: [\n\t\t\t{\n\t\t\t\tname: \"section\",\n\t\t\t\tdescription: \"Settings section to open\",\n\t\t\t\trequired: false,\n\t\t\t\tchoices: getSettingsSectionChoices(),\n\t\t\t\tdynamicChoices: \"settings-sections\",\n\t\t\t},\n\t\t],\n\t},\n\t{\n\t\tkey: \"chat\",\n\t\tnativeName: \"chat\",\n\t\tdescription: \"Return to the chat\",\n\t\ttextAliases: [\"/chat\"],\n\t\tscope: \"both\",\n\t\tcategory: \"docks\",\n\t\ticon: \"message-circle\",\n\t\ttarget: { kind: \"navigate\", path: \"/chat\", tab: \"chat\" },\n\t},\n\t{\n\t\tkey: \"views\",\n\t\tnativeName: \"views\",\n\t\tdescription: \"Open the agent's views\",\n\t\ttextAliases: [\"/views\"],\n\t\tscope: \"both\",\n\t\tcategory: \"docks\",\n\t\ticon: \"layout-grid\",\n\t\ttarget: { kind: \"navigate\", path: \"/views\", tab: \"views\" },\n\t\tacceptsArgs: true,\n\t\targs: [\n\t\t\t{\n\t\t\t\tname: \"view\",\n\t\t\t\tdescription: \"View to open\",\n\t\t\t\trequired: false,\n\t\t\t\tdynamicChoices: \"views\",\n\t\t\t},\n\t\t],\n\t},\n\t{\n\t\tkey: \"orchestrator\",\n\t\tnativeName: \"orchestrator\",\n\t\tdescription: \"Open the agent orchestrator\",\n\t\ttextAliases: [\"/orchestrator\"],\n\t\tscope: \"both\",\n\t\tcategory: \"docks\",\n\t\ticon: \"workflow\",\n\t\ttarget: { kind: \"navigate\", path: \"/orchestrator\", viewId: \"orchestrator\" },\n\t},\n\t{\n\t\tkey: \"character\",\n\t\tnativeName: \"character\",\n\t\tdescription: \"Open the character editor\",\n\t\ttextAliases: [\"/character\"],\n\t\tscope: \"both\",\n\t\tcategory: \"docks\",\n\t\ticon: \"user\",\n\t\ttarget: { kind: \"navigate\", path: \"/character\", tab: \"character\" },\n\t},\n\t{\n\t\tkey: \"knowledge\",\n\t\tnativeName: \"knowledge\",\n\t\tdescription: \"Open the knowledge base\",\n\t\ttextAliases: [\"/knowledge\"],\n\t\tscope: \"both\",\n\t\tcategory: \"docks\",\n\t\ticon: \"book-open\",\n\t\ttarget: {\n\t\t\tkind: \"navigate\",\n\t\t\tpath: \"/character/documents\",\n\t\t\ttab: \"documents\",\n\t\t},\n\t},\n\t{\n\t\tkey: \"wallet\",\n\t\tnativeName: \"wallet\",\n\t\tdescription: \"Open the wallet & inventory\",\n\t\ttextAliases: [\"/wallet\"],\n\t\tscope: \"both\",\n\t\tcategory: \"docks\",\n\t\ticon: \"wallet\",\n\t\ttarget: { kind: \"navigate\", path: \"/wallet\", tab: \"inventory\" },\n\t},\n\t{\n\t\tkey: \"automations\",\n\t\tnativeName: \"automations\",\n\t\tdescription: \"Open automations\",\n\t\ttextAliases: [\"/automations\"],\n\t\tscope: \"both\",\n\t\tcategory: \"docks\",\n\t\ticon: \"zap\",\n\t\ttarget: { kind: \"navigate\", path: \"/automations\", tab: \"automations\" },\n\t},\n\t{\n\t\tkey: \"tasks\",\n\t\tnativeName: \"tasks\",\n\t\tdescription: \"Open tasks\",\n\t\ttextAliases: [\"/tasks\"],\n\t\tscope: \"both\",\n\t\tcategory: \"docks\",\n\t\ticon: \"check-square\",\n\t\ttarget: { kind: \"navigate\", path: \"/apps/tasks\", tab: \"tasks\" },\n\t},\n\t{\n\t\tkey: \"skills\",\n\t\tnativeName: \"skills\",\n\t\tdescription: \"Open the skills library\",\n\t\ttextAliases: [\"/skills\"],\n\t\tscope: \"both\",\n\t\tcategory: \"docks\",\n\t\ticon: \"sparkles\",\n\t\ttarget: { kind: \"navigate\", path: \"/apps/skills\", tab: \"skills\" },\n\t},\n\t{\n\t\tkey: \"plugins\",\n\t\tnativeName: \"plugins\",\n\t\tdescription: \"Open installed plugins\",\n\t\ttextAliases: [\"/plugins\"],\n\t\tscope: \"both\",\n\t\tcategory: \"docks\",\n\t\ticon: \"plug\",\n\t\ttarget: { kind: \"navigate\", path: \"/apps/plugins\", tab: \"plugins\" },\n\t},\n\t{\n\t\tkey: \"logs\",\n\t\tnativeName: \"logs\",\n\t\tdescription: \"Open the logs\",\n\t\ttextAliases: [\"/logs\"],\n\t\tscope: \"both\",\n\t\tcategory: \"docks\",\n\t\ticon: \"scroll-text\",\n\t\ttarget: { kind: \"navigate\", path: \"/apps/logs\", tab: \"logs\" },\n\t},\n\t{\n\t\tkey: \"database\",\n\t\tnativeName: \"database\",\n\t\tdescription: \"Open the database browser\",\n\t\ttextAliases: [\"/database\"],\n\t\tscope: \"both\",\n\t\tcategory: \"docks\",\n\t\ticon: \"database\",\n\t\ttarget: { kind: \"navigate\", path: \"/apps/database\", tab: \"database\" },\n\t},\n];\n\n/**\n * Client-only behaviors — run in the GUI/TUI, filtered off chat connectors by\n * surface (a Discord/Telegram user has nothing to clear or full-screen).\n */\nconst CLIENT_COMMANDS: CommandDefinition[] = [\n\t{\n\t\tkey: \"clear\",\n\t\tnativeName: \"clear\",\n\t\tdescription: \"Clear the current chat\",\n\t\ttextAliases: [\"/clear\"],\n\t\tscope: \"both\",\n\t\tcategory: \"docks\",\n\t\ticon: \"eraser\",\n\t\tsurfaces: IN_APP_SURFACES,\n\t\ttarget: { kind: \"client\", clientAction: \"clear-chat\" },\n\t},\n\t{\n\t\tkey: \"fullscreen\",\n\t\tnativeName: \"fullscreen\",\n\t\tdescription: \"Toggle full-screen chat\",\n\t\ttextAliases: [\"/fullscreen\"],\n\t\tscope: \"both\",\n\t\tcategory: \"docks\",\n\t\ticon: \"maximize\",\n\t\tsurfaces: IN_APP_SURFACES,\n\t\ttarget: { kind: \"client\", clientAction: \"toggle-fullscreen\" },\n\t},\n\t{\n\t\tkey: \"transcribe\",\n\t\tnativeName: \"transcribe\",\n\t\tdescription:\n\t\t\t\"Toggle long-form transcription mode (record-only; agent stays silent until an exit phrase)\",\n\t\ttextAliases: [\"/transcribe\"],\n\t\tscope: \"both\",\n\t\tcategory: \"docks\",\n\t\ticon: \"mic\",\n\t\tsurfaces: IN_APP_SURFACES,\n\t\ttarget: { kind: \"client\", clientAction: \"toggle-transcription\" },\n\t},\n];\n\n/**\n * View-dependent action commands (#8798). Unlike the global navigation commands\n * above (which *open* a view), these invoke the in-view domain action and are\n * surfaced only while their view is foreground — the `views` scope is honoured by\n * `commandVisibleForView` and the active view is resolved server-side in\n * `/api/commands` (or passed as `?view=`). They target the agent so the planner\n * routes the body to the same action the in-view control invokes (calendar add →\n * CALENDAR, todos done → TODOS, …), keeping one canonical action per capability.\n * In-app only: a chat connector has no foreground view to scope against.\n */\nconst VIEW_SCOPED_COMMANDS: CommandDefinition[] = [\n\t{\n\t\tkey: \"calendar-add\",\n\t\tnativeName: \"calendar-add\",\n\t\tdescription: \"Add a calendar event (in the calendar view)\",\n\t\ttextAliases: [\"/calendar-add\"],\n\t\tscope: \"both\",\n\t\tcategory: \"docks\",\n\t\ticon: \"calendar-plus\",\n\t\tsurfaces: IN_APP_SURFACES,\n\t\tviews: [\"calendar\"],\n\t\ttarget: { kind: \"agent\" },\n\t\tacceptsArgs: true,\n\t\targs: [{ name: \"event\", description: \"What to schedule\", required: false }],\n\t},\n\t{\n\t\tkey: \"todos-add\",\n\t\tnativeName: \"todos-add\",\n\t\tdescription: \"Add a to-do (in the todos view)\",\n\t\ttextAliases: [\"/todos-add\"],\n\t\tscope: \"both\",\n\t\tcategory: \"docks\",\n\t\ticon: \"list-plus\",\n\t\tsurfaces: IN_APP_SURFACES,\n\t\tviews: [\"todos\"],\n\t\ttarget: { kind: \"agent\" },\n\t\tacceptsArgs: true,\n\t\targs: [{ name: \"task\", description: \"What to do\", required: false }],\n\t},\n\t{\n\t\tkey: \"todos-done\",\n\t\tnativeName: \"todos-done\",\n\t\tdescription: \"Complete a to-do (in the todos view)\",\n\t\ttextAliases: [\"/todos-done\"],\n\t\tscope: \"both\",\n\t\tcategory: \"docks\",\n\t\ticon: \"check\",\n\t\tsurfaces: IN_APP_SURFACES,\n\t\tviews: [\"todos\"],\n\t\ttarget: { kind: \"agent\" },\n\t\tacceptsArgs: true,\n\t\targs: [\n\t\t\t{ name: \"task\", description: \"Which to-do to complete\", required: false },\n\t\t],\n\t},\n\t{\n\t\tkey: \"documents-search\",\n\t\tnativeName: \"documents-search\",\n\t\tdescription: \"Search the knowledge base (in the documents view)\",\n\t\ttextAliases: [\"/documents-search\"],\n\t\tscope: \"both\",\n\t\tcategory: \"docks\",\n\t\ticon: \"search\",\n\t\tsurfaces: IN_APP_SURFACES,\n\t\tviews: [\"documents\"],\n\t\ttarget: { kind: \"agent\" },\n\t\tacceptsArgs: true,\n\t\targs: [\n\t\t\t{ name: \"query\", description: \"What to search for\", required: false },\n\t\t],\n\t},\n];\n\n/**\n * Navigation + client commands the app surfaces in addition to the agent\n * capabilities from the text command registry. Returns a fresh array so callers\n * can't mutate the shared definitions.\n */\nexport function navigationCommandDefinitions(): CommandDefinition[] {\n\treturn [...NAVIGATE_COMMANDS, ...CLIENT_COMMANDS, ...VIEW_SCOPED_COMMANDS];\n}\n",
|
|
17
|
+
"/**\n * Canonical command serialization.\n *\n * `serializeCommand` is the single projection from a `CommandDefinition` onto\n * the wire-safe `SerializedCommand` shape every client consumes (web composer,\n * TUI autocomplete, connector bridges). The `GET /api/commands` route is a pure\n * pass-through of this function — it fabricates nothing. This is what closes the\n * \"catalog contract dropped at the route\" gap (#8790): `surfaces`, auth flags,\n * `category`, real `dynamicChoices`, `icon`, and the full `textAliases` all\n * survive instead of being hardcoded to `false`/`\"both\"`/`\"builtin\"`.\n */\n\nimport type {\n\tCommandArgDefinition,\n\tCommandDefinition,\n\tCommandSurface,\n\tSerializedCommand,\n\tSerializedCommandArg,\n\tSerializedCommandSource,\n} from \"./types\";\n\n/** Default target when a definition doesn't declare one: run through the agent. */\nconst DEFAULT_TARGET = { kind: \"agent\" as const };\n\n/**\n * Whether a command is offered on `surface`. A definition with no `surfaces`\n * is offered everywhere (the default). When `surface` is omitted the command is\n * always included (the catalog query is surface-agnostic).\n */\nexport function commandVisibleForSurface(\n\tsurfaces: readonly CommandSurface[] | undefined,\n\tsurface: CommandSurface | null | undefined,\n): boolean {\n\tif (!surface) return true;\n\tif (!surfaces || surfaces.length === 0) return true;\n\treturn surfaces.includes(surface);\n}\n\n/** Project a definition's argument onto its wire shape. */\nfunction serializeArg(arg: CommandArgDefinition): SerializedCommandArg {\n\tconst serialized: SerializedCommandArg = {\n\t\tname: arg.name,\n\t\tdescription: arg.description,\n\t};\n\tif (arg.required) serialized.required = true;\n\tif (arg.captureRemaining) serialized.captureRemaining = true;\n\tif (arg.dynamicChoices) serialized.dynamicChoices = arg.dynamicChoices;\n\t// Function-valued choices need a live provider/model context, so they drop\n\t// to a dynamic source (if tagged) rather than a fabricated static list.\n\tif (Array.isArray(arg.choices) && arg.choices.length > 0) {\n\t\tserialized.choices = arg.choices;\n\t}\n\treturn serialized;\n}\n\n/**\n * Serialize a `CommandDefinition` onto the canonical `SerializedCommand` wire\n * shape. Every field is read from the definition — nothing is fabricated.\n *\n * @param command the registry definition.\n * @param options.source where the item came from (default `\"builtin\"`); skills\n * pass `\"custom-action\"`/`\"saved\"` so the menu can group/label them.\n */\nexport function serializeCommand(\n\tcommand: CommandDefinition,\n\toptions: { source?: SerializedCommandSource } = {},\n): SerializedCommand {\n\tconst args = (command.args ?? []).map(serializeArg);\n\tconst serialized: SerializedCommand = {\n\t\tkey: command.key,\n\t\tnativeName: command.nativeName ?? command.key,\n\t\tdescription: command.description,\n\t\ttextAliases: command.textAliases,\n\t\tscope: command.scope,\n\t\tacceptsArgs: command.acceptsArgs ?? args.length > 0,\n\t\targs,\n\t\trequiresAuth: command.requiresAuth ?? false,\n\t\trequiresElevated: command.requiresElevated ?? false,\n\t\ttarget: command.target ?? DEFAULT_TARGET,\n\t\tsource: options.source ?? \"builtin\",\n\t};\n\tif (command.category) serialized.category = command.category;\n\tif (command.surfaces && command.surfaces.length > 0) {\n\t\tserialized.surfaces = command.surfaces;\n\t}\n\tif (command.icon) serialized.icon = command.icon;\n\tif (command.views && command.views.length > 0) {\n\t\tserialized.views = command.views;\n\t}\n\treturn serialized;\n}\n",
|
|
18
|
+
"/**\n * Connector-neutral command catalog.\n *\n * The text command registry (`registry.ts`) describes the agent's slash\n * capabilities; `navigation-commands.ts` describes the app's navigation/client\n * commands. Both are `CommandDefinition`s now, so the catalog treats them\n * uniformly: it unions them, dedupes (navigation wins name collisions), filters\n * by surface (`surfaces`) and active view (`views`), and projects onto either:\n *\n * - `ConnectorCommand` — the shape a connector (Discord, Telegram, …) maps\n * onto its native command surface (`getConnectorCommands`), or\n * - `SerializedCommand` — the wire shape `GET /api/commands` serves the web\n * composer / TUI (`getCatalogCommands`), via `serializeCommand`.\n *\n * Each command declares a `target` discriminating where it executes (`agent` /\n * `navigate` / `client`). `ConnectorCommand` options carry a fully-resolved\n * `choices: string[]` so connectors never evaluate function-valued choices.\n */\n\nimport { navigationCommandDefinitions } from \"./navigation-commands\";\nimport { DEFAULT_COMMANDS, getEnabledCommandsForRuntime } from \"./registry\";\nimport { commandVisibleForSurface, serializeCommand } from \"./serialize\";\nimport type {\n\tCommandDefinition,\n\tCommandSurface,\n\tCommandTarget,\n\tSerializedCommand,\n\tSerializedCommandSource,\n} from \"./types\";\n\n// Re-export the canonical command-target types for connectors that still import\n// them from here. `ConnectorCommandTarget` is now an alias of `CommandTarget`.\nexport type { ClientCommandAction, CommandTarget } from \"./types\";\nexport type ConnectorCommandTarget = CommandTarget;\n\n/** A single argument of a connector command. */\nexport interface ConnectorCommandOption {\n\tname: string;\n\tdescription: string;\n\trequired: boolean;\n\t/** Resolved choice values; empty when the option is free-form. */\n\tchoices: string[];\n}\n\n/** A connector-neutral command ready to map onto a native command surface. */\nexport interface ConnectorCommand {\n\tname: string;\n\tdescription: string;\n\ttarget: CommandTarget;\n\toptions: ConnectorCommandOption[];\n\t/**\n\t * View ids this command is scoped to (#8798): present only while one of these\n\t * views is the active surface. Omitted = globally available.\n\t */\n\tviews?: string[];\n}\n\nconst KNOWN_SURFACES: ReadonlySet<string> = new Set([\n\t\"gui\",\n\t\"tui\",\n\t\"discord\",\n\t\"telegram\",\n]);\n\n/**\n * Whether a command with the given `views` scoping is visible for the active\n * view. Global commands (no `views`, or an empty list) are always visible;\n * view-scoped commands appear only when their view is foreground. (#8798)\n */\nexport function commandVisibleForView(\n\tviews: readonly string[] | undefined,\n\tactiveViewId: string | null | undefined,\n): boolean {\n\tif (!views || views.length === 0) return true;\n\tif (!activeViewId) return false;\n\treturn views.includes(activeViewId);\n}\n\n/**\n * Connectors expose a native command surface, so only commands that make sense\n * remotely are emitted. The text registry's `scope` encodes this: `text`-only\n * commands (e.g. `/bash`) are local-shell behaviors that never belong on a\n * connector surface.\n */\nfunction isConnectorScoped(command: CommandDefinition): boolean {\n\treturn command.scope !== \"text\";\n}\n\nfunction commandName(command: CommandDefinition): string {\n\treturn command.nativeName ?? command.key;\n}\n\n/**\n * The unified command list: enabled, connector-scoped agent commands from the\n * text registry plus the navigation/client commands. Navigation/client commands\n * win on name collisions (they own those surfaces).\n */\nfunction unifiedDefinitions(agentId?: string | null): CommandDefinition[] {\n\tconst agentCommands = agentId\n\t\t? getEnabledCommandsForRuntime(agentId)\n\t\t: DEFAULT_COMMANDS.filter((command) => command.enabled !== false);\n\tconst agent = agentCommands.filter(isConnectorScoped);\n\tconst navigation = navigationCommandDefinitions();\n\tconst navigationNames = new Set(navigation.map(commandName));\n\tconst agentOnly = agent.filter(\n\t\t(command) => !navigationNames.has(commandName(command)),\n\t);\n\treturn [...agentOnly, ...navigation];\n}\n\nfunction normalizeSurface(surface: string): CommandSurface | null {\n\treturn KNOWN_SURFACES.has(surface) ? (surface as CommandSurface) : null;\n}\n\n/** The surface- and view-filtered unified definitions. */\nfunction visibleDefinitions(\n\tsurface: string,\n\tactiveViewId: string | null | undefined,\n\tagentId?: string | null,\n): CommandDefinition[] {\n\tconst normalized = normalizeSurface(surface);\n\treturn unifiedDefinitions(agentId)\n\t\t.filter((command) => commandVisibleForSurface(command.surfaces, normalized))\n\t\t.filter((command) => commandVisibleForView(command.views, activeViewId));\n}\n\nfunction mapDefinitionArg(\n\targ: NonNullable<CommandDefinition[\"args\"]>[number],\n): ConnectorCommandOption {\n\treturn {\n\t\tname: arg.name,\n\t\tdescription: arg.description,\n\t\trequired: arg.required ?? false,\n\t\tchoices: Array.isArray(arg.choices) ? arg.choices : [],\n\t};\n}\n\n/** Project a definition onto the connector-neutral `ConnectorCommand` shape. */\nfunction toConnectorCommand(command: CommandDefinition): ConnectorCommand {\n\treturn {\n\t\tname: commandName(command),\n\t\tdescription: command.description,\n\t\ttarget: command.target ?? { kind: \"agent\" },\n\t\toptions: (command.args ?? []).map(mapDefinitionArg),\n\t\t...(command.views && command.views.length > 0\n\t\t\t? { views: command.views }\n\t\t\t: {}),\n\t};\n}\n\n/**\n * Build the connector command catalog for a given surface (Discord, Telegram, …).\n *\n * @param surface \"gui\" | \"tui\" | \"discord\" | \"telegram\".\n * @param options.activeViewId when set, view-scoped commands (#8798) are\n * included only if this is one of their views; global commands always appear.\n * When unset, view-scoped commands are filtered out entirely.\n */\nexport function getConnectorCommands(\n\tsurface: string,\n\toptions: { activeViewId?: string | null; agentId?: string | null } = {},\n): ConnectorCommand[] {\n\treturn visibleDefinitions(surface, options.activeViewId, options.agentId).map(\n\t\ttoConnectorCommand,\n\t);\n}\n\n/**\n * Build the wire-safe catalog (`SerializedCommand[]`) served by\n * `GET /api/commands`. This is the pure projection: surface- and view-filtered\n * unified definitions, each run through `serializeCommand` so `surfaces`, auth\n * flags, `category`, `dynamicChoices`, and `icon` all survive intact.\n */\nexport function getCatalogCommands(\n\tsurface: string,\n\toptions: {\n\t\tactiveViewId?: string | null;\n\t\tagentId?: string | null;\n\t\tsource?: SerializedCommandSource;\n\t} = {},\n): SerializedCommand[] {\n\treturn visibleDefinitions(surface, options.activeViewId, options.agentId).map(\n\t\t(command) =>\n\t\t\tserializeCommand(\n\t\t\t\tcommand,\n\t\t\t\toptions.source ? { source: options.source } : {},\n\t\t\t),\n\t);\n}\n"
|
|
19
|
+
],
|
|
20
|
+
"mappings": ";AAsBA;AAAA;AAAA;;;ACVO,IAAM,mBAAqD;AAAA,EAEjE;AAAA,IACC,KAAK;AAAA,IACL,YAAY;AAAA,IACZ,aAAa;AAAA,IACb,aAAa,CAAC,SAAS,MAAM,IAAI;AAAA,IACjC,OAAO;AAAA,IACP,UAAU;AAAA,IACV,aAAa;AAAA,EACd;AAAA,EACA;AAAA,IACC,KAAK;AAAA,IACL,YAAY;AAAA,IACZ,aAAa;AAAA,IACb,aAAa,CAAC,aAAa,OAAO;AAAA,IAClC,OAAO;AAAA,IACP,UAAU;AAAA,IACV,aAAa;AAAA,EACd;AAAA,EACA;AAAA,IACC,KAAK;AAAA,IACL,YAAY;AAAA,IACZ,aAAa;AAAA,IACb,aAAa,CAAC,WAAW,IAAI;AAAA,IAC7B,OAAO;AAAA,IACP,UAAU;AAAA,IACV,aAAa;AAAA,EACd;AAAA,EACA;AAAA,IACC,KAAK;AAAA,IACL,YAAY;AAAA,IACZ,aAAa;AAAA,IACb,aAAa,CAAC,YAAY,MAAM;AAAA,IAChC,OAAO;AAAA,IACP,UAAU;AAAA,IACV,aAAa;AAAA,IACb,MAAM,CAAC,EAAE,MAAM,QAAQ,aAAa,mCAAmC,CAAC;AAAA,EACzE;AAAA,EACA;AAAA,IACC,KAAK;AAAA,IACL,YAAY;AAAA,IACZ,aAAa;AAAA,IACb,aAAa,CAAC,WAAW,MAAM;AAAA,IAC/B,OAAO;AAAA,IACP,UAAU;AAAA,IACV,aAAa;AAAA,EACd;AAAA,EAG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UAAU;AAAA,MACb,SAAS,UAAU;AAAA,IACpB;AAAA,IAEA,MAAM,UAAU,iBAAiB,MAAM;AAAA,IACvC,IAAI,SAAS;AAAA,MACZ,QAAQ,UAAU;AAAA,IACnB;AAAA,IAEA,MAAM,aAAa,iBAAiB,SAAS;AAAA,IAC7C,IAAI,YAAY;AAAA,MACf,WAAW,UAAU;AAAA,IACtB;AAAA,IAEA,MAAM,eAAe,mBAAmB,EAAE;AAAA,IAC1C,OAAO,IACN,qBAAqB,2CAA2C,QAAQ,SACzE;AAAA;AAEF;AAEA,IAAe;",
|
|
21
|
+
"debugId": "0416CA3D9EF6001864756E2164756E21",
|
|
22
|
+
"names": []
|
|
23
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Command actions — the registered elizaOS `Action`s for agent-target commands.
|
|
3
|
+
*
|
|
4
|
+
* One action per deterministic command (`/help`, `/status`, `/models`, …).
|
|
5
|
+
* Each action's `validate()` is strictly slash-only (it matches just its own
|
|
6
|
+
* command key) and its `similes` are the slash aliases only — no natural
|
|
7
|
+
* language — so the LLM never misroutes a conversational message to a command.
|
|
8
|
+
* The handler delegates to the shared `resolveCommand`, so an action invoked by
|
|
9
|
+
* the planner produces the exact same deterministic reply as the pre-LLM gate.
|
|
10
|
+
*/
|
|
11
|
+
import type { Action } from "@elizaos/core";
|
|
12
|
+
/**
|
|
13
|
+
* Build the deterministic command actions for the per-runtime registry. One
|
|
14
|
+
* action per deterministic agent-target command. Call after `useRuntime(agentId)`.
|
|
15
|
+
*/
|
|
16
|
+
export declare function createCommandActions(commandKeys: string[]): Action[];
|
|
17
|
+
//# sourceMappingURL=command-actions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command-actions.d.ts","sourceRoot":"","sources":["../../../src/actions/command-actions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAyB,MAAM,eAAe,CAAC;AAkEnE;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,WAAW,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAiBpE"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Per-conversation command settings.
|
|
3
|
+
*
|
|
4
|
+
* The option commands (`/think`, `/verbose`, `/reasoning`, `/queue`,
|
|
5
|
+
* `/elevated`, `/model`, `/tts`) persist their value here, keyed by room, via
|
|
6
|
+
* the runtime cache. This is real, queryable state: setting `/think high` then
|
|
7
|
+
* reading it back returns `high`. Each setter validates its argument against an
|
|
8
|
+
* allowed set so a bad value is rejected deterministically rather than guessed.
|
|
9
|
+
*/
|
|
10
|
+
import type { IAgentRuntime } from "@elizaos/core";
|
|
11
|
+
export interface CommandSettings {
|
|
12
|
+
thinking?: string;
|
|
13
|
+
verbose?: string;
|
|
14
|
+
reasoning?: string;
|
|
15
|
+
queue?: string;
|
|
16
|
+
elevated?: string;
|
|
17
|
+
model?: string;
|
|
18
|
+
tts?: string;
|
|
19
|
+
}
|
|
20
|
+
/** Allowed values per option command (lowercased). `null` = free-form. */
|
|
21
|
+
export declare const COMMAND_SETTING_CHOICES: Record<keyof CommandSettings, readonly string[] | null>;
|
|
22
|
+
/** Clear the persisted command settings for a room. */
|
|
23
|
+
export declare function clearCommandSettings(runtime: IAgentRuntime, roomId: string): Promise<boolean>;
|
|
24
|
+
/** Read the persisted command settings for a room (empty object if none). */
|
|
25
|
+
export declare function getCommandSettings(runtime: IAgentRuntime, roomId: string): Promise<CommandSettings>;
|
|
26
|
+
/**
|
|
27
|
+
* Validate and persist a single command setting. Returns the normalized value
|
|
28
|
+
* on success, or `{ error }` when the value is not an allowed choice.
|
|
29
|
+
*/
|
|
30
|
+
export declare function setCommandSetting(runtime: IAgentRuntime, roomId: string, key: keyof CommandSettings, rawValue: string): Promise<{
|
|
31
|
+
value: string;
|
|
32
|
+
} | {
|
|
33
|
+
error: string;
|
|
34
|
+
}>;
|
|
35
|
+
//# sourceMappingURL=command-settings.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command-settings.d.ts","sourceRoot":"","sources":["../../../src/actions/command-settings.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAEnD,MAAM,WAAW,eAAe;IAC/B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC;CACb;AAED,0EAA0E;AAC1E,eAAO,MAAM,uBAAuB,EAAE,MAAM,CAC3C,MAAM,eAAe,EACrB,SAAS,MAAM,EAAE,GAAG,IAAI,CASxB,CAAC;AAMF,uDAAuD;AACvD,wBAAsB,oBAAoB,CACzC,OAAO,EAAE,aAAa,EACtB,MAAM,EAAE,MAAM,GACZ,OAAO,CAAC,OAAO,CAAC,CAElB;AAED,6EAA6E;AAC7E,wBAAsB,kBAAkB,CACvC,OAAO,EAAE,aAAa,EACtB,MAAM,EAAE,MAAM,GACZ,OAAO,CAAC,eAAe,CAAC,CAG1B;AAED;;;GAGG;AACH,wBAAsB,iBAAiB,CACtC,OAAO,EAAE,aAAa,EACtB,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,MAAM,eAAe,EAC1B,QAAQ,EAAE,MAAM,GACd,OAAO,CAAC;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC,CAgBhD"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Command dispatch — the one entry point that turns a slash-command message
|
|
3
|
+
* into a deterministic reply. Reused by:
|
|
4
|
+
* - the agent's command actions (the registered `*_COMMAND` actions),
|
|
5
|
+
* - the pre-LLM shortcut gate (slash commands are always-on shortcuts), and
|
|
6
|
+
* - connector bridges that want an instant local reply.
|
|
7
|
+
*
|
|
8
|
+
* It detects + parses the command, builds a `CommandContext`, runs `runCommand`,
|
|
9
|
+
* and (when the command was handled) fires the callback with the reply. Returns
|
|
10
|
+
* whether it owned the message, so callers can fall through to the normal
|
|
11
|
+
* pipeline when it didn't.
|
|
12
|
+
*/
|
|
13
|
+
import type { HandlerCallback, IAgentRuntime, Memory } from "@elizaos/core";
|
|
14
|
+
import type { ParsedCommand } from "../types";
|
|
15
|
+
export interface CommandDispatchOptions {
|
|
16
|
+
/**
|
|
17
|
+
* Trust level for the sender, used to gate `requiresAuth`/`requiresElevated`
|
|
18
|
+
* commands. The caller knows the surface: the local dashboard/TUI sender is
|
|
19
|
+
* the owner (authorized + elevated); a connector resolves it from pairing /
|
|
20
|
+
* allowlist. Defaults to unauthorized so a missing resolver fails closed.
|
|
21
|
+
*/
|
|
22
|
+
isAuthorized?: boolean;
|
|
23
|
+
isElevated?: boolean;
|
|
24
|
+
senderName?: string;
|
|
25
|
+
callback?: HandlerCallback;
|
|
26
|
+
/**
|
|
27
|
+
* When true (the default), only commands owned by the deterministic command
|
|
28
|
+
* layer are dispatched; broader management commands fall through to the
|
|
29
|
+
* pipeline that owns their side effects.
|
|
30
|
+
*/
|
|
31
|
+
deterministicOnly?: boolean;
|
|
32
|
+
/** @deprecated Use `deterministicOnly`. */
|
|
33
|
+
gateSafeOnly?: boolean;
|
|
34
|
+
}
|
|
35
|
+
/** What a successful dispatch resolved to. */
|
|
36
|
+
export interface CommandDispatchResult {
|
|
37
|
+
handled: boolean;
|
|
38
|
+
reply?: string;
|
|
39
|
+
command?: ParsedCommand;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Detect, parse, and deterministically run a slash command. Does NOT fire a
|
|
43
|
+
* callback — returns the result so the caller controls how to surface the reply.
|
|
44
|
+
*/
|
|
45
|
+
export declare function resolveCommand(runtime: IAgentRuntime, message: Memory, options?: CommandDispatchOptions): Promise<CommandDispatchResult>;
|
|
46
|
+
/**
|
|
47
|
+
* Resolve a command and, when handled, fire `callback` with the reply. Returns
|
|
48
|
+
* true when the command was handled (so the caller skips the LLM pipeline).
|
|
49
|
+
*/
|
|
50
|
+
export declare function dispatchCommandMessage(runtime: IAgentRuntime, message: Memory, callback: (reply: {
|
|
51
|
+
text: string;
|
|
52
|
+
source?: string;
|
|
53
|
+
}) => unknown, options?: CommandDispatchOptions): Promise<boolean>;
|
|
54
|
+
//# sourceMappingURL=dispatch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dispatch.d.ts","sourceRoot":"","sources":["../../../src/actions/dispatch.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAG5E,OAAO,KAAK,EAAkB,aAAa,EAAE,MAAM,UAAU,CAAC;AAG9D,MAAM,WAAW,sBAAsB;IACtC;;;;;OAKG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,eAAe,CAAC;IAC3B;;;;OAIG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,2CAA2C;IAC3C,YAAY,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,8CAA8C;AAC9C,MAAM,WAAW,qBAAqB;IACrC,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,aAAa,CAAC;CACxB;AAwBD;;;GAGG;AACH,wBAAsB,cAAc,CACnC,OAAO,EAAE,aAAa,EACtB,OAAO,EAAE,MAAM,EACf,OAAO,GAAE,sBAA2B,GAClC,OAAO,CAAC,qBAAqB,CAAC,CA6BhC;AAED;;;GAGG;AACH,wBAAsB,sBAAsB,CAC3C,OAAO,EAAE,aAAa,EACtB,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,CAAC,KAAK,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,KAAK,OAAO,EAC/D,OAAO,GAAE,sBAA2B,GAClC,OAAO,CAAC,OAAO,CAAC,CAKlB"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Deterministic command handlers.
|
|
3
|
+
*
|
|
4
|
+
* `runCommand` is the single source of truth for what an agent-target command
|
|
5
|
+
* does. It reads real runtime/registry state, persists option settings, invokes
|
|
6
|
+
* owned runtime actions when needed, and returns a deterministic
|
|
7
|
+
* `CommandResult`. No LLM improvisation: the same command path runs on web,
|
|
8
|
+
* TUI, Discord, and Telegram.
|
|
9
|
+
*/
|
|
10
|
+
import type { IAgentRuntime } from "@elizaos/core";
|
|
11
|
+
import type { CommandContext, CommandResult, ParsedCommand } from "../types";
|
|
12
|
+
/**
|
|
13
|
+
* Commands whose effects are fully owned by this deterministic layer. Broader
|
|
14
|
+
* lifecycle/management commands (`stop`, `restart`, `allowlist`, `approve`, …)
|
|
15
|
+
* still flow through the pipeline that owns their side effects.
|
|
16
|
+
*/
|
|
17
|
+
export declare const DETERMINISTIC_COMMAND_KEYS: readonly string[];
|
|
18
|
+
/** Whether a command's whole effect is handled by this deterministic layer. */
|
|
19
|
+
export declare function isDeterministicCommand(key: string): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Run a parsed command deterministically. Returns a `CommandResult` whose
|
|
22
|
+
* `reply` is shown to the user. `handled: false` means this layer doesn't own
|
|
23
|
+
* the command (the caller should let it flow to the normal pipeline).
|
|
24
|
+
*/
|
|
25
|
+
export declare function runCommand(runtime: IAgentRuntime, parsed: ParsedCommand, context: CommandContext): Promise<CommandResult>;
|
|
26
|
+
//# sourceMappingURL=handlers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handlers.d.ts","sourceRoot":"","sources":["../../../src/actions/handlers.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAGX,aAAa,EAGb,MAAM,eAAe,CAAC;AAOvB,OAAO,KAAK,EAEX,cAAc,EACd,aAAa,EACb,aAAa,EACb,MAAM,UAAU,CAAC;AAQlB;;;;GAIG;AACH,eAAO,MAAM,0BAA0B,EAAE,SAAS,MAAM,EAkBvD,CAAC;AAMF,+EAA+E;AAC/E,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAE3D;AAyID;;;;GAIG;AACH,wBAAsB,UAAU,CAC/B,OAAO,EAAE,aAAa,EACtB,MAAM,EAAE,aAAa,EACrB,OAAO,EAAE,cAAc,GACrB,OAAO,CAAC,aAAa,CAAC,CA0GxB"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Command action layer (#8790).
|
|
3
|
+
*
|
|
4
|
+
* Exports the deterministic command handlers, the per-conversation settings
|
|
5
|
+
* store, the dispatch helper (used by the pre-LLM gate and connectors), and the
|
|
6
|
+
* registered `*_COMMAND` actions.
|
|
7
|
+
*/
|
|
8
|
+
export * from "./command-actions";
|
|
9
|
+
export * from "./command-settings";
|
|
10
|
+
export * from "./dispatch";
|
|
11
|
+
export * from "./handlers";
|
|
12
|
+
export * from "./shortcuts";
|
|
13
|
+
/**
|
|
14
|
+
* The deterministic command actions for the built-in deterministic commands. Built
|
|
15
|
+
* from the default registry so they can be registered statically on the plugin;
|
|
16
|
+
* request-time command resolution reads the per-runtime store directly.
|
|
17
|
+
*/
|
|
18
|
+
export declare const commandActions: import("@elizaos/core").Action[];
|
|
19
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/actions/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAE5B;;;;GAIG;AACH,eAAO,MAAM,cAAc,kCAEzB,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Slash-command shortcuts (#8790 × #8791).
|
|
3
|
+
*
|
|
4
|
+
* Each deterministic agent-target command is registered as an *explicit* shortcut
|
|
5
|
+
* into the runtime's `ShortcutRegistry`. The pre-LLM gate matches the slash/`!`
|
|
6
|
+
* alias and fires the command's `*_COMMAND` action directly — so `/help`,
|
|
7
|
+
* `/status`, `/models`, … resolve deterministically before any model call,
|
|
8
|
+
* identically on every surface. Explicit shortcuts are always-on (a slash is an
|
|
9
|
+
* unambiguous invocation); they carry no auth flag here because the command
|
|
10
|
+
* action re-checks sender trust itself.
|
|
11
|
+
*/
|
|
12
|
+
import type { ShortcutDefinition } from "@elizaos/core";
|
|
13
|
+
/**
|
|
14
|
+
* Build the explicit slash-command shortcuts for the built-in deterministic
|
|
15
|
+
* commands, from the default registry. Built once at module load; each
|
|
16
|
+
* shortcut targets the matching `<KEY>_COMMAND` action.
|
|
17
|
+
*/
|
|
18
|
+
export declare function createCommandShortcuts(commandKeys?: readonly string[]): ShortcutDefinition[];
|
|
19
|
+
/** The explicit slash-command shortcuts for built-in deterministic commands. */
|
|
20
|
+
export declare const explicitCommandShortcuts: ShortcutDefinition[];
|
|
21
|
+
/**
|
|
22
|
+
* Natural-language shortcuts (#8791 C6).
|
|
23
|
+
*
|
|
24
|
+
* These are narrow, anchored, and confidence-floored. Each one targets an
|
|
25
|
+
* UNAMBIGUOUS deterministic intent that maps onto a deterministic `*_COMMAND`
|
|
26
|
+
* action, so the pre-LLM gate can fire it with zero inference.
|
|
27
|
+
*
|
|
28
|
+
* The sole production shortcut here is "what commands can I use" / "show me the
|
|
29
|
+
* commands" / "list the available commands" → `COMMANDS_COMMAND`. The patterns
|
|
30
|
+
* are anchored (`^…$`) over ASR-normalized text and require both a list/show
|
|
31
|
+
* verb and the literal word "commands", so a conversational message like "can
|
|
32
|
+
* you help me with this command line" never matches — it lacks the anchored
|
|
33
|
+
* verb+"commands" shape and falls through to the LLM.
|
|
34
|
+
*/
|
|
35
|
+
export declare const naturalShortcuts: ShortcutDefinition[];
|
|
36
|
+
/**
|
|
37
|
+
* All command shortcuts the plugin registers: the explicit slash-command
|
|
38
|
+
* shortcuts plus the narrow natural-language shortcuts.
|
|
39
|
+
*/
|
|
40
|
+
export declare const commandShortcuts: ShortcutDefinition[];
|
|
41
|
+
//# sourceMappingURL=shortcuts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shortcuts.d.ts","sourceRoot":"","sources":["../../../src/actions/shortcuts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAIxD;;;;GAIG;AACH,wBAAgB,sBAAsB,CACrC,WAAW,GAAE,SAAS,MAAM,EAA+B,GACzD,kBAAkB,EAAE,CActB;AAED,gFAAgF;AAChF,eAAO,MAAM,wBAAwB,EAAE,kBAAkB,EAChC,CAAC;AAE1B;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,gBAAgB,EAAE,kBAAkB,EAsBhD,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,gBAAgB,EAAE,kBAAkB,EAGhD,CAAC"}
|