@elizaos/plugin-commands 2.0.0-alpha.9 → 2.0.11-beta.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +83 -0
- package/auto-enable.ts +24 -0
- package/package.json +115 -97
- package/dist/cjs/index.cjs +0 -1214
- package/dist/cjs/index.cjs.map +0 -17
- package/dist/index.js +0 -1176
- package/dist/index.js.map +0 -17
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Shaw Walters and elizaOS Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# @elizaos/plugin-commands
|
|
2
|
+
|
|
3
|
+
Chat command system for [elizaOS](https://github.com/elizaos/eliza) agents. Adds a `/help`-style slash-command surface with a shared registry, parser, and LLM context provider.
|
|
4
|
+
|
|
5
|
+
## What it does
|
|
6
|
+
|
|
7
|
+
- Provides a typed command registry that other plugins and the agent runtime use to register slash commands.
|
|
8
|
+
- Detects `/` and `!`-prefixed messages and parses them into structured `ParsedCommand` objects.
|
|
9
|
+
- Injects a `COMMAND_REGISTRY` provider into the LLM context — full command documentation only when the message is a command, an empty hint otherwise (keeps normal-message prompts clean).
|
|
10
|
+
- Ships 25 built-in command *definitions* grouped by category. The actual Action handlers live in the agent or other plugins.
|
|
11
|
+
|
|
12
|
+
## Built-in commands
|
|
13
|
+
|
|
14
|
+
| Category | Commands |
|
|
15
|
+
|---|---|
|
|
16
|
+
| Status | `/help` (`/h`, `/?`), `/commands` (`/cmds`), `/status` (`/s`), `/context` (`/ctx`), `/whoami` (`/who`) |
|
|
17
|
+
| Session | `/stop` (`/abort`, `/cancel`), `/restart`\*, `/reset`\*, `/new`, `/compact` |
|
|
18
|
+
| Options | `/think` (`/thinking`, `/t`), `/verbose` (`/v`), `/reasoning` (`/reason`), `/elevated`\* (`/elev`), `/model` (`/m`), `/models`, `/usage`, `/queue` (`/q`) |
|
|
19
|
+
| Management | `/allowlist`\* (`/allow`), `/approve`\*, `/subagents`\* (`/sub`), `/config`\*† (`/cfg`), `/debug`\*† |
|
|
20
|
+
| Media | `/tts` (`/voice`) |
|
|
21
|
+
| Tools | `/bash`\*‡ (`/sh`, `/!`) |
|
|
22
|
+
|
|
23
|
+
\* Requires auth (`requiresAuth: true`).
|
|
24
|
+
† Disabled by default.
|
|
25
|
+
‡ Requires elevated permissions AND is disabled by default.
|
|
26
|
+
|
|
27
|
+
## Installation
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
bun add @elizaos/plugin-commands
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
The plugin is **opt-in**. It auto-enables when `config.features.commands` is truthy in your agent configuration.
|
|
34
|
+
|
|
35
|
+
## Configuration
|
|
36
|
+
|
|
37
|
+
Add to your agent's character/config file:
|
|
38
|
+
|
|
39
|
+
```json
|
|
40
|
+
{
|
|
41
|
+
"features": {
|
|
42
|
+
"commands": true
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### Environment variables
|
|
48
|
+
|
|
49
|
+
| Variable | Default | Description |
|
|
50
|
+
|---|---|---|
|
|
51
|
+
| `COMMANDS_CONFIG_ENABLED` | `false` | Enable `/config` command |
|
|
52
|
+
| `COMMANDS_DEBUG_ENABLED` | `false` | Enable `/debug` command |
|
|
53
|
+
| `COMMANDS_BASH_ENABLED` | `false` | Enable `/bash` shell execution (elevated) |
|
|
54
|
+
| `COMMANDS_RESTART_ENABLED` | `true` | Enable `/restart` command |
|
|
55
|
+
|
|
56
|
+
## Registering a custom command
|
|
57
|
+
|
|
58
|
+
```ts
|
|
59
|
+
import { registerCommand } from "@elizaos/plugin-commands";
|
|
60
|
+
|
|
61
|
+
registerCommand({
|
|
62
|
+
key: "ping",
|
|
63
|
+
description: "Ping the agent",
|
|
64
|
+
textAliases: ["/ping"],
|
|
65
|
+
scope: "both",
|
|
66
|
+
category: "status",
|
|
67
|
+
acceptsArgs: false,
|
|
68
|
+
});
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
You still need an `Action` in your plugin to handle the command. Use `hasCommand()` and `detectCommand()` from `@elizaos/plugin-commands` in your action's `validate()` to match the right key.
|
|
72
|
+
|
|
73
|
+
## Parser API
|
|
74
|
+
|
|
75
|
+
```ts
|
|
76
|
+
import { hasCommand, detectCommand, normalizeCommandBody } from "@elizaos/plugin-commands";
|
|
77
|
+
|
|
78
|
+
hasCommand("/help"); // true
|
|
79
|
+
hasCommand("hello world"); // false
|
|
80
|
+
detectCommand("/think:high"); // { isCommand: true, command: { key: "think", args: ["high"], ... } }
|
|
81
|
+
normalizeCommandBody("@bot /status", "bot"); // "/status"
|
|
82
|
+
```
|
|
83
|
+
|
package/auto-enable.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// Auto-enable check for @elizaos/plugin-commands.
|
|
2
|
+
//
|
|
3
|
+
// Plugin manifest entry-point — referenced by package.json's
|
|
4
|
+
// `elizaos.plugin.autoEnableModule`. Keep this module light: env reads only,
|
|
5
|
+
// no service init, no transitive imports of the full plugin runtime. The
|
|
6
|
+
// auto-enable engine loads dozens of these per boot.
|
|
7
|
+
import type { PluginAutoEnableContext } from "@elizaos/core";
|
|
8
|
+
|
|
9
|
+
function isFeatureEnabled(
|
|
10
|
+
config: PluginAutoEnableContext["config"],
|
|
11
|
+
key: string,
|
|
12
|
+
): boolean {
|
|
13
|
+
const f = (config.features as Record<string, unknown> | undefined)?.[key];
|
|
14
|
+
if (f === true) return true;
|
|
15
|
+
if (f && typeof f === "object" && f !== null) {
|
|
16
|
+
return (f as Record<string, unknown>).enabled !== false;
|
|
17
|
+
}
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** Enable when `config.features.commands` is truthy / not explicitly disabled. */
|
|
22
|
+
export function shouldEnable(ctx: PluginAutoEnableContext): boolean {
|
|
23
|
+
return isFeatureEnabled(ctx.config, "commands");
|
|
24
|
+
}
|
package/package.json
CHANGED
|
@@ -1,99 +1,117 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
2
|
+
"name": "@elizaos/plugin-commands",
|
|
3
|
+
"version": "2.0.11-beta.7",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"module": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"sideEffects": false,
|
|
9
|
+
"description": "Chat command system for Eliza agents (/help, /status, /reset, etc.)",
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "git+https://github.com/elizaos/eliza.git"
|
|
13
|
+
},
|
|
14
|
+
"exports": {
|
|
15
|
+
"./package.json": "./package.json",
|
|
16
|
+
".": {
|
|
17
|
+
"types": "./dist/index.d.ts",
|
|
18
|
+
"eliza-source": {
|
|
19
|
+
"types": "./src/index.ts",
|
|
20
|
+
"import": "./src/index.ts",
|
|
21
|
+
"default": "./src/index.ts"
|
|
22
|
+
},
|
|
23
|
+
"import": "./dist/index.js",
|
|
24
|
+
"default": "./dist/index.js"
|
|
25
|
+
},
|
|
26
|
+
"./*.css": "./dist/*.css",
|
|
27
|
+
"./*": {
|
|
28
|
+
"types": "./dist/*.d.ts",
|
|
29
|
+
"eliza-source": {
|
|
30
|
+
"types": "./src/*.ts",
|
|
31
|
+
"import": "./src/*.ts",
|
|
32
|
+
"default": "./src/*.ts"
|
|
33
|
+
},
|
|
34
|
+
"import": "./dist/*.js",
|
|
35
|
+
"default": "./dist/*.js"
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
"files": [
|
|
39
|
+
"dist",
|
|
40
|
+
"auto-enable.ts"
|
|
41
|
+
],
|
|
42
|
+
"elizaos": {
|
|
43
|
+
"plugin": {
|
|
44
|
+
"autoEnableModule": "./auto-enable.ts",
|
|
45
|
+
"capabilities": [
|
|
46
|
+
"chat-commands"
|
|
47
|
+
]
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
"dependencies": {
|
|
51
|
+
"@elizaos/core": "2.0.11-beta.7"
|
|
52
|
+
},
|
|
53
|
+
"devDependencies": {
|
|
54
|
+
"@biomejs/biome": "^2.4.14",
|
|
55
|
+
"@types/bun": "^1.2.22",
|
|
56
|
+
"@types/node": "^24.5.2",
|
|
57
|
+
"typescript": "^6.0.3",
|
|
58
|
+
"vitest": "^4.0.18"
|
|
59
|
+
},
|
|
60
|
+
"scripts": {
|
|
61
|
+
"build": "bun run build.ts && tsc --emitDeclarationOnly",
|
|
62
|
+
"dev": "bun --hot build.ts",
|
|
63
|
+
"test": "vitest run",
|
|
64
|
+
"clean": "rm -rf dist .turbo .turbo-tsconfig.json tsconfig.tsbuildinfo",
|
|
65
|
+
"format": "bunx @biomejs/biome format --write .",
|
|
66
|
+
"format:check": "bunx @biomejs/biome format .",
|
|
67
|
+
"lint": "bunx @biomejs/biome check --write --unsafe .",
|
|
68
|
+
"lint:check": "bunx @biomejs/biome check .",
|
|
69
|
+
"typecheck": "tsgo --noEmit"
|
|
70
|
+
},
|
|
71
|
+
"publishConfig": {
|
|
72
|
+
"access": "public"
|
|
73
|
+
},
|
|
74
|
+
"agentConfig": {
|
|
75
|
+
"pluginType": "elizaos:plugin:1.0.0",
|
|
76
|
+
"pluginParameters": {
|
|
77
|
+
"COMMANDS_CONFIG_ENABLED": {
|
|
78
|
+
"type": "boolean",
|
|
79
|
+
"description": "Enable /config command",
|
|
80
|
+
"required": false,
|
|
81
|
+
"default": "false",
|
|
82
|
+
"sensitive": false
|
|
83
|
+
},
|
|
84
|
+
"COMMANDS_DEBUG_ENABLED": {
|
|
85
|
+
"type": "boolean",
|
|
86
|
+
"description": "Enable /debug command",
|
|
87
|
+
"required": false,
|
|
88
|
+
"default": "false",
|
|
89
|
+
"sensitive": false
|
|
90
|
+
},
|
|
91
|
+
"COMMANDS_BASH_ENABLED": {
|
|
92
|
+
"type": "boolean",
|
|
93
|
+
"description": "Enable /bash command (elevated)",
|
|
94
|
+
"required": false,
|
|
95
|
+
"default": "false",
|
|
96
|
+
"sensitive": false
|
|
97
|
+
},
|
|
98
|
+
"COMMANDS_RESTART_ENABLED": {
|
|
99
|
+
"type": "boolean",
|
|
100
|
+
"description": "Enable /restart command",
|
|
101
|
+
"required": false,
|
|
102
|
+
"default": "true",
|
|
103
|
+
"sensitive": false
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
"eliza": {
|
|
108
|
+
"platforms": [
|
|
109
|
+
"node"
|
|
110
|
+
],
|
|
111
|
+
"runtime": "node",
|
|
112
|
+
"platformDetails": {
|
|
113
|
+
"node": "Default export (Node.js)"
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
"gitHead": "cdbc876f793d96073d7eb0d09715a031ce0cd32e"
|
|
99
117
|
}
|