@elizaos/plugin-shell 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.
Files changed (62) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +111 -0
  3. package/auto-enable.ts +37 -0
  4. package/package.json +46 -20
  5. package/dist/actions/clearHistory.d.ts +0 -4
  6. package/dist/actions/clearHistory.d.ts.map +0 -1
  7. package/dist/actions/index.d.ts +0 -2
  8. package/dist/actions/index.d.ts.map +0 -1
  9. package/dist/approvals/allowlist.d.ts +0 -76
  10. package/dist/approvals/allowlist.d.ts.map +0 -1
  11. package/dist/approvals/analysis.d.ts +0 -76
  12. package/dist/approvals/analysis.d.ts.map +0 -1
  13. package/dist/approvals/index.d.ts +0 -12
  14. package/dist/approvals/index.d.ts.map +0 -1
  15. package/dist/approvals/service.d.ts +0 -121
  16. package/dist/approvals/service.d.ts.map +0 -1
  17. package/dist/approvals/types.d.ts +0 -219
  18. package/dist/approvals/types.d.ts.map +0 -1
  19. package/dist/build.d.ts +0 -2
  20. package/dist/build.d.ts.map +0 -1
  21. package/dist/generated/prompts/typescript/prompts.d.ts +0 -12
  22. package/dist/generated/prompts/typescript/prompts.d.ts.map +0 -1
  23. package/dist/generated/specs/spec-helpers.d.ts +0 -49
  24. package/dist/generated/specs/spec-helpers.d.ts.map +0 -1
  25. package/dist/generated/specs/specs.d.ts +0 -73
  26. package/dist/generated/specs/specs.d.ts.map +0 -1
  27. package/dist/index.browser.d.ts +0 -4
  28. package/dist/index.browser.d.ts.map +0 -1
  29. package/dist/index.d.ts +0 -14
  30. package/dist/index.d.ts.map +0 -1
  31. package/dist/index.js +0 -5278
  32. package/dist/index.js.map +0 -35
  33. package/dist/providers/index.d.ts +0 -2
  34. package/dist/providers/index.d.ts.map +0 -1
  35. package/dist/providers/shellHistoryProvider.d.ts +0 -4
  36. package/dist/providers/shellHistoryProvider.d.ts.map +0 -1
  37. package/dist/providers/terminalUsage.d.ts +0 -3
  38. package/dist/providers/terminalUsage.d.ts.map +0 -1
  39. package/dist/services/index.d.ts +0 -3
  40. package/dist/services/index.d.ts.map +0 -1
  41. package/dist/services/processRegistry.d.ts +0 -25
  42. package/dist/services/processRegistry.d.ts.map +0 -1
  43. package/dist/services/shellService.d.ts +0 -91
  44. package/dist/services/shellService.d.ts.map +0 -1
  45. package/dist/types/index.d.ts +0 -144
  46. package/dist/types/index.d.ts.map +0 -1
  47. package/dist/utils/config.d.ts +0 -4
  48. package/dist/utils/config.d.ts.map +0 -1
  49. package/dist/utils/index.d.ts +0 -7
  50. package/dist/utils/index.d.ts.map +0 -1
  51. package/dist/utils/pathUtils.d.ts +0 -5
  52. package/dist/utils/pathUtils.d.ts.map +0 -1
  53. package/dist/utils/processQueue.d.ts +0 -136
  54. package/dist/utils/processQueue.d.ts.map +0 -1
  55. package/dist/utils/ptyKeys.d.ts +0 -23
  56. package/dist/utils/ptyKeys.d.ts.map +0 -1
  57. package/dist/utils/shellArgv.d.ts +0 -37
  58. package/dist/utils/shellArgv.d.ts.map +0 -1
  59. package/dist/utils/shellUtils.d.ts +0 -103
  60. package/dist/utils/shellUtils.d.ts.map +0 -1
  61. package/dist/vitest.config.d.ts +0 -3
  62. package/dist/vitest.config.d.ts.map +0 -1
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 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,111 @@
1
+ # @elizaos/plugin-shell
2
+
3
+ Shell command execution plugin for elizaOS. Adds sandboxed shell access, PTY support, background session management, command approval, and shell history to an Eliza agent.
4
+
5
+ ## What it does
6
+
7
+ - Executes shell commands restricted to a configured directory (`SHELL_ALLOWED_DIRECTORY`).
8
+ - Supports interactive terminal applications via PTY (`@lydell/node-pty`, optional).
9
+ - Runs long commands in the background with named sessions; poll, send-keys, paste, and kill them later.
10
+ - Maintains per-conversation command history with stdout/stderr/exit-code capture.
11
+ - Provides the `SHELL_HISTORY` context provider so the agent always knows its cwd and recent commands.
12
+ - Provides `ExecApprovalService` to gate commands through an allowlist and user-approval flow.
13
+
14
+ The agent-facing `SHELL` action that exposes shell execution is in `@elizaos/plugin-coding-tools`, which consumes this plugin's services. Its `action` parameter (list/poll/kill/etc.) drives `ShellService.processAction()`.
15
+
16
+ ## Installation
17
+
18
+ ```bash
19
+ bun add @elizaos/plugin-shell
20
+ ```
21
+
22
+ ## Configuration
23
+
24
+ ```bash
25
+ # Required — commands cannot execute outside this directory
26
+ SHELL_ALLOWED_DIRECTORY=/path/to/safe/workspace
27
+
28
+ # Optional
29
+ SHELL_TIMEOUT=30000 # per-command timeout ms (simple executeCommand)
30
+ SHELL_FORBIDDEN_COMMANDS=rm,mv # comma-separated additions to the default blocklist
31
+ SHELL_MAX_OUTPUT_CHARS=200000 # max captured output chars per session
32
+ SHELL_BACKGROUND_MS=10000 # yield window before auto-backgrounding (ms)
33
+ SHELL_ALLOW_BACKGROUND=true # set "false" to disable background execution
34
+ SHELL_JOB_TTL_MS=1800000 # finished session record TTL (ms)
35
+ ```
36
+
37
+ `SHELL_ALLOWED_DIRECTORY` must point to an existing directory. The service throws at start if it is missing.
38
+
39
+ ## Enabling
40
+
41
+ Auto-enabled when `config.features.shell` is truthy. Not available on iOS, `ELIZA_BUILD_VARIANT=store` builds, or Android unless `ELIZA_RUNTIME_MODE=local-yolo`.
42
+
43
+ To enable explicitly in a character file:
44
+
45
+ ```typescript
46
+ import shellPlugin from "@elizaos/plugin-shell";
47
+
48
+ const character = {
49
+ plugins: [shellPlugin],
50
+ };
51
+ ```
52
+
53
+ ## Security
54
+
55
+ - All commands execute within `SHELL_ALLOWED_DIRECTORY`. Path traversal and absolute paths outside the boundary are rejected.
56
+ - A built-in blocklist prevents the most destructive commands (see `DEFAULT_FORBIDDEN_COMMANDS` in `utils/config.ts`).
57
+ - Additional forbidden commands can be added via `SHELL_FORBIDDEN_COMMANDS`.
58
+ - Commands time out automatically. Output is capped at `SHELL_MAX_OUTPUT_CHARS`.
59
+ - `ExecApprovalService` can gate commands through an allowlist + user approval before execution.
60
+ - Local execution is disabled in cloud mode (`isCloudExecutionMode`).
61
+
62
+ ## Process actions
63
+
64
+ Background sessions support these operations via `ShellService.processAction()`:
65
+
66
+ | Action | Description |
67
+ |---|---|
68
+ | `list` | List all running and finished sessions |
69
+ | `poll` | Drain new output from a running session |
70
+ | `log` | Read session output with offset/limit pagination |
71
+ | `write` | Write raw data to session stdin |
72
+ | `send-keys` | Send terminal key sequences (arrows, ctrl+c, etc.) |
73
+ | `submit` | Send carriage return (Enter) |
74
+ | `paste` | Paste text with bracketed paste mode |
75
+ | `kill` | Kill a running session |
76
+ | `clear` | Remove a finished session record |
77
+ | `remove` | Kill (if running) and remove a session |
78
+
79
+ ## Usage from code
80
+
81
+ ```typescript
82
+ import { ShellService } from "@elizaos/plugin-shell";
83
+
84
+ // Simple synchronous execution
85
+ const shellService = runtime.getService<ShellService>("shell");
86
+ const result = await shellService.executeCommand("ls -la", conversationId);
87
+
88
+ // Advanced: PTY + background
89
+ const execResult = await shellService.exec("bun install", {
90
+ pty: true,
91
+ yieldMs: 5000, // background after 5 s if still running
92
+ timeout: 300, // 5-minute hard timeout (seconds)
93
+ workdir: "/project",
94
+ });
95
+
96
+ if (execResult.status === "running") {
97
+ // Poll later
98
+ const poll = await shellService.processAction({
99
+ action: "poll",
100
+ sessionId: execResult.sessionId,
101
+ });
102
+ }
103
+ ```
104
+
105
+ ## Development
106
+
107
+ ```bash
108
+ bun run --cwd plugins/plugin-shell build # build dist/
109
+ bun run --cwd plugins/plugin-shell test # vitest
110
+ bun run --cwd plugins/plugin-shell dev # hot-reload build
111
+ ```
package/auto-enable.ts ADDED
@@ -0,0 +1,37 @@
1
+ // Auto-enable check for @elizaos/plugin-shell.
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(config: PluginAutoEnableContext["config"], key: string): boolean {
10
+ const f = (config.features as Record<string, unknown> | undefined)?.[key];
11
+ if (f === true) return true;
12
+ if (f && typeof f === "object" && f !== null) {
13
+ return (f as Record<string, unknown>).enabled !== false;
14
+ }
15
+ return false;
16
+ }
17
+
18
+ function terminalSupportedByEnv(ctx: PluginAutoEnableContext): boolean {
19
+ const env = ctx.env;
20
+ const variant = (env.ELIZA_BUILD_VARIANT ?? "").trim().toLowerCase();
21
+ if (variant === "store") return false;
22
+
23
+ const platform = env.ELIZA_PLATFORM?.trim().toLowerCase();
24
+ const mobile =
25
+ platform === "android" || platform === "ios" || Boolean(env.ANDROID_ROOT || env.ANDROID_DATA);
26
+ if (!mobile) return true;
27
+
28
+ const mode = (env.ELIZA_RUNTIME_MODE ?? env.RUNTIME_MODE ?? env.LOCAL_RUNTIME_MODE ?? "")
29
+ .trim()
30
+ .toLowerCase();
31
+ return platform === "android" && mode === "local-yolo";
32
+ }
33
+
34
+ /** Enable when `config.features.shell` is truthy / not explicitly disabled. */
35
+ export function shouldEnable(ctx: PluginAutoEnableContext): boolean {
36
+ return isFeatureEnabled(ctx.config, "shell") && terminalSupportedByEnv(ctx);
37
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elizaos/plugin-shell",
3
- "version": "2.0.0-alpha.9",
3
+ "version": "2.0.11-beta.7",
4
4
  "description": "Shell history and observability plugin for ElizaOS",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -15,13 +15,30 @@
15
15
  "./package.json": "./package.json",
16
16
  ".": {
17
17
  "types": "./dist/index.d.ts",
18
+ "bun": "./index.ts",
19
+ "development": "./index.ts",
18
20
  "import": "./dist/index.js",
19
21
  "default": "./dist/index.js"
22
+ },
23
+ "./*.css": "./dist/*.css",
24
+ "./*": {
25
+ "types": "./dist/*.d.ts",
26
+ "import": "./dist/*.js",
27
+ "default": "./dist/*.js"
20
28
  }
21
29
  },
22
30
  "files": [
23
- "dist"
31
+ "dist",
32
+ "auto-enable.ts"
24
33
  ],
34
+ "elizaos": {
35
+ "plugin": {
36
+ "autoEnableModule": "./auto-enable.ts",
37
+ "capabilities": [
38
+ "shell-access"
39
+ ]
40
+ }
41
+ },
25
42
  "keywords": [
26
43
  "eliza",
27
44
  "plugin",
@@ -33,23 +50,43 @@
33
50
  "author": "elizaOS",
34
51
  "license": "MIT",
35
52
  "dependencies": {
36
- "@elizaos/core": "next",
53
+ "@elizaos/core": "2.0.11-beta.7",
54
+ "@elizaos/shared": "2.0.11-beta.7",
37
55
  "cross-spawn": "^7.0.6",
38
- "zod": "^4.3.6"
56
+ "zod": "^4.4.3"
39
57
  },
40
58
  "optionalDependencies": {
41
59
  "@lydell/node-pty": "^1.1.0"
42
60
  },
43
61
  "devDependencies": {
44
- "@biomejs/biome": "^2.3.11",
62
+ "@biomejs/biome": "^2.4.14",
45
63
  "@types/cross-spawn": "^6.0.6",
46
64
  "@types/node": "^25.0.3",
47
- "typescript": "^5.9.3",
65
+ "bun-types": "^1.2.25",
66
+ "typescript": "^6.0.3",
48
67
  "vitest": "^4.0.0"
49
68
  },
69
+ "scripts": {
70
+ "build": "bun run build.ts",
71
+ "build:ts": "bun run build.ts",
72
+ "dev": "bun --hot build.ts",
73
+ "clean": "rm -rf dist .turbo",
74
+ "test": "vitest run",
75
+ "typecheck": "tsgo --noEmit -p tsconfig.json",
76
+ "lint": "bunx @biomejs/biome check .",
77
+ "lint:check": "bun run lint",
78
+ "format": "bunx @biomejs/biome format --write .",
79
+ "format:check": "bunx @biomejs/biome format ."
80
+ },
50
81
  "publishConfig": {
51
82
  "access": "public"
52
83
  },
84
+ "resolutions": {
85
+ "@noble/hashes": "2.2.0"
86
+ },
87
+ "overrides": {
88
+ "@noble/hashes": "2.2.0"
89
+ },
53
90
  "agentConfig": {
54
91
  "pluginType": "elizaos:plugin:1.0.0",
55
92
  "pluginParameters": {
@@ -102,7 +139,7 @@
102
139
  }
103
140
  }
104
141
  },
105
- "milady": {
142
+ "eliza": {
106
143
  "platforms": [
107
144
  "node"
108
145
  ],
@@ -111,16 +148,5 @@
111
148
  "node": "Default export (Node.js)"
112
149
  }
113
150
  },
114
- "scripts": {
115
- "build": "bun run build.ts",
116
- "build:ts": "bun run build.ts",
117
- "dev": "bun --hot build.ts",
118
- "clean": "rm -rf dist .turbo node_modules",
119
- "test": "vitest run",
120
- "typecheck": "echo \"Typecheck skipped for release\"",
121
- "lint": "echo \"Lint skipped for release\"",
122
- "lint:check": "bun run lint",
123
- "format": "bunx @biomejs/biome format --write .",
124
- "format:check": "bunx @biomejs/biome format ."
125
- }
126
- }
151
+ "gitHead": "cdbc876f793d96073d7eb0d09715a031ce0cd32e"
152
+ }
@@ -1,4 +0,0 @@
1
- import { type Action } from "@elizaos/core";
2
- export declare const clearHistory: Action;
3
- export default clearHistory;
4
- //# sourceMappingURL=clearHistory.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"clearHistory.d.ts","sourceRoot":"","sources":["../../actions/clearHistory.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,MAAM,EASX,MAAM,eAAe,CAAC;AAMvB,eAAO,MAAM,YAAY,EAAE,MAsG1B,CAAC;AAEF,eAAe,YAAY,CAAC"}
@@ -1,2 +0,0 @@
1
- export { clearHistory } from "./clearHistory";
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../actions/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC"}
@@ -1,76 +0,0 @@
1
- /**
2
- * Allowlist Management
3
- *
4
- * Functions for managing the exec approval allowlist.
5
- * Handles loading, saving, and modifying allowlist entries.
6
- */
7
- import type { CommandResolution, ExecAllowlistEntry, ExecApprovalsDefaults, ExecApprovalsFile, ExecApprovalsResolved, ExecApprovalsSnapshot, ExecAsk, ExecSecurity } from "./types";
8
- /**
9
- * Get the default approval file path
10
- */
11
- export declare function getApprovalFilePath(): string;
12
- /**
13
- * Get the default socket path
14
- */
15
- export declare function getApprovalSocketPath(): string;
16
- /**
17
- * Normalize approval configuration file
18
- */
19
- export declare function normalizeApprovals(file: ExecApprovalsFile): ExecApprovalsFile;
20
- /**
21
- * Read approval configuration snapshot
22
- */
23
- export declare function readApprovalsSnapshot(): ExecApprovalsSnapshot;
24
- /**
25
- * Load approval configuration
26
- */
27
- export declare function loadApprovals(): ExecApprovalsFile;
28
- /**
29
- * Save approval configuration
30
- * @throws Error if file cannot be written
31
- */
32
- export declare function saveApprovals(file: ExecApprovalsFile): void;
33
- /**
34
- * Ensure approval configuration exists with socket/token
35
- * @throws Error if configuration cannot be loaded or saved
36
- */
37
- export declare function ensureApprovals(): ExecApprovalsFile;
38
- /**
39
- * Resolve approval configuration for an agent
40
- * @throws Error if configuration cannot be loaded or saved
41
- */
42
- export declare function resolveApprovals(agentId?: string, overrides?: Partial<ExecApprovalsDefaults>): ExecApprovalsResolved;
43
- /**
44
- * Resolve approval configuration from a loaded file
45
- */
46
- export declare function resolveApprovalsFromFile(params: {
47
- file: ExecApprovalsFile;
48
- agentId?: string;
49
- overrides?: Partial<ExecApprovalsDefaults>;
50
- path?: string;
51
- socketPath?: string;
52
- token?: string;
53
- }): ExecApprovalsResolved;
54
- /**
55
- * Match command against allowlist
56
- */
57
- export declare function matchAllowlist(entries: ExecAllowlistEntry[], resolution: CommandResolution | null): ExecAllowlistEntry | null;
58
- /**
59
- * Record allowlist usage
60
- * @returns true if successful, false if save failed
61
- */
62
- export declare function recordAllowlistUse(approvals: ExecApprovalsFile, agentId: string | undefined, entry: ExecAllowlistEntry, command: string, resolvedPath?: string): boolean;
63
- /**
64
- * Add a new allowlist entry
65
- * @returns true if entry was added, false if already exists or save failed
66
- */
67
- export declare function addAllowlistEntry(approvals: ExecApprovalsFile, agentId: string | undefined, pattern: string): boolean;
68
- /**
69
- * Get minimum security level
70
- */
71
- export declare function minSecurity(a: ExecSecurity, b: ExecSecurity): ExecSecurity;
72
- /**
73
- * Get maximum ask level
74
- */
75
- export declare function maxAsk(a: ExecAsk, b: ExecAsk): ExecAsk;
76
- //# sourceMappingURL=allowlist.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"allowlist.d.ts","sourceRoot":"","sources":["../../approvals/allowlist.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAOH,OAAO,KAAK,EACX,iBAAiB,EACjB,kBAAkB,EAElB,qBAAqB,EACrB,iBAAiB,EACjB,qBAAqB,EACrB,qBAAqB,EACrB,OAAO,EACP,YAAY,EACZ,MAAM,SAAS,CAAC;AAgCjB;;GAEG;AACH,wBAAgB,mBAAmB,IAAI,MAAM,CAE5C;AAED;;GAEG;AACH,wBAAgB,qBAAqB,IAAI,MA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S,EAC3B,OAAO,EAAE,MAAM,GACb,OAAO,CA8CT;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,EAAE,YAAY,GAAG,YAAY,CAO1E;AAED;;GAEG;AACH,wBAAgB,MAAM,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,GAAG,OAAO,CAGtD"}
@@ -1,76 +0,0 @@
1
- /**
2
- * Command Analysis
3
- *
4
- * Functions for analyzing shell commands for security evaluation.
5
- * Parses commands, resolves executables, and evaluates against allowlists.
6
- */
7
- import type { CommandResolution, ExecAllowlistAnalysis, ExecAllowlistEntry, ExecAllowlistEvaluation, ExecCommandAnalysis } from "./types";
8
- /**
9
- * Resolve command to executable info
10
- */
11
- export declare function resolveCommandResolution(command: string, cwd?: string, env?: NodeJS.ProcessEnv): CommandResolution | null;
12
- /**
13
- * Resolve command from argv
14
- */
15
- export declare function resolveCommandFromArgv(argv: string[], cwd?: string, env?: NodeJS.ProcessEnv): CommandResolution | null;
16
- /**
17
- * Analyze a shell command
18
- */
19
- export declare function analyzeShellCommand(params: {
20
- command: string;
21
- cwd?: string;
22
- env?: NodeJS.ProcessEnv;
23
- platform?: string | null;
24
- }): ExecCommandAnalysis;
25
- /**
26
- * Normalize safe bins set
27
- */
28
- export declare function normalizeSafeBins(entries?: string[]): Set<string>;
29
- /**
30
- * Resolve safe bins with defaults
31
- */
32
- export declare function resolveSafeBins(entries?: string[] | null): Set<string>;
33
- /**
34
- * Check if command is safe bin usage (no file args)
35
- */
36
- export declare function isSafeBinUsage(params: {
37
- argv: string[];
38
- resolution: CommandResolution | null;
39
- safeBins: Set<string>;
40
- cwd?: string;
41
- fileExists?: (filePath: string) => boolean;
42
- }): boolean;
43
- /**
44
- * Evaluate command against allowlist
45
- */
46
- export declare function evaluateExecAllowlist(params: {
47
- analysis: ExecCommandAnalysis;
48
- allowlist: ExecAllowlistEntry[];
49
- safeBins: Set<string>;
50
- cwd?: string;
51
- skillBins?: Set<string>;
52
- autoAllowSkills?: boolean;
53
- }): ExecAllowlistEvaluation;
54
- /**
55
- * Evaluate shell command for allowlist (combined analysis + evaluation)
56
- */
57
- export declare function evaluateShellAllowlist(params: {
58
- command: string;
59
- allowlist: ExecAllowlistEntry[];
60
- safeBins: Set<string>;
61
- cwd?: string;
62
- env?: NodeJS.ProcessEnv;
63
- skillBins?: Set<string>;
64
- autoAllowSkills?: boolean;
65
- platform?: string | null;
66
- }): ExecAllowlistAnalysis;
67
- /**
68
- * Check if approval is required
69
- */
70
- export declare function requiresExecApproval(params: {
71
- ask: "off" | "on-miss" | "always";
72
- security: "deny" | "allowlist" | "full";
73
- analysisOk: boolean;
74
- allowlistSatisfied: boolean;
75
- }): boolean;
76
- //# sourceMappingURL=analysis.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"analysis.d.ts","sourceRoot":"","sources":["../../approvals/analysis.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,OAAO,KAAK,EACX,iBAAiB,EACjB,qBAAqB,EACrB,kBAAkB,EAClB,uBAAuB,EACvB,mBAAmB,EAEnB,MAAM,SAAS,CAAC;AAgJjB;;GAEG;AACH,wBAAgB,wBAAwB,CACvC,OAAO,EAAE,MAAM,EACf,GAAG,CAAC,EAAE,MAAM,EACZ,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,GACrB,iBAAiB,GAAG,IAAI,CAU1B;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CACrC,IAAI,EAAE,MAAM,EAAE,EACd,GAAG,CAAC,EAAE,MAAM,EACZ,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,GACrB,iBAAiB,GAAG,IAAI,CAU1B;AAsQD;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE;IAC3C,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;IACxB,QAAQ,C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,CAAC;IACxB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACzB,GAAG,qBAAqB,CAwFxB;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE;IAC5C,GAAG,EAAE,KAAK,GAAG,SAAS,GAAG,QAAQ,CAAC;IAClC,QAAQ,EAAE,MAAM,GAAG,WAAW,GAAG,MAAM,CAAC;IACxC,UAAU,EAAE,OAAO,CAAC;IACpB,kBAAkB,EAAE,OAAO,CAAC;CAC5B,GAAG,OAAO,CAOV"}
@@ -1,12 +0,0 @@
1
- /**
2
- * Exec Approvals Module
3
- *
4
- * Command execution approval system for plugin-shell.
5
- * Provides allowlist management, command analysis, and approval workflows.
6
- */
7
- export { addAllowlistEntry, ensureApprovals, getApprovalFilePath, getApprovalSocketPath, loadApprovals, matchAllowlist, maxAsk, minSecurity, normalizeApprovals, readApprovalsSnapshot, recordAllowlistUse, resolveApprovals, resolveApprovalsFromFile, saveApprovals, } from "./allowlist";
8
- export { analyzeShellCommand, evaluateExecAllowlist, evaluateShellAllowlist, isSafeBinUsage, normalizeSafeBins, requiresExecApproval, resolveCommandFromArgv, resolveCommandResolution, resolveSafeBins, } from "./analysis";
9
- export { type CommandCheckResult, ExecApprovalService } from "./service";
10
- export type { CommandResolution, ExecAllowlistAnalysis, ExecAllowlistEntry, ExecAllowlistEvaluation, ExecApprovalDecision, ExecApprovalRequest, ExecApprovalResult, ExecApprovalsAgent, ExecApprovalsDefaults, ExecApprovalsFile, ExecApprovalsResolved, ExecApprovalsSnapshot, ExecAsk, ExecCommandAnalysis, ExecCommandSegment, ExecHost, ExecSecurity, } from "./types";
11
- export { DEFAULT_SAFE_BINS, EXEC_APPROVAL_DEFAULTS } from "./types";
12
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../approvals/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EACN,iBAAiB,EACjB,eAAe,EACf,mBAAmB,EACnB,qBAAqB,EACrB,aAAa,EACb,cAAc,EACd,MAAM,EACN,WAAW,EACX,kBAAkB,EAClB,qBAAqB,EACrB,kBAAkB,EAClB,gBAAgB,EAChB,wBAAwB,EACxB,aAAa,GACb,MAAM,aAAa,CAAC;AAErB,OAAO,EACN,mBAAmB,EACnB,qBAAqB,EACrB,sBAAsB,EACtB,cAAc,EACd,iBAAiB,EACjB,oBAAoB,EACpB,sBAAsB,EACtB,wBAAwB,EACxB,eAAe,GACf,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,KAAK,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAEzE,YAAY,EACX,iBAAiB,EACjB,qBAAqB,EACrB,kBAAkB,EAClB,uBAAuB,EACvB,oBAAoB,EACpB,mBAAmB,EACnB,kBAAkB,EAClB,kBAAkB,EAClB,qBAAqB,EACrB,iBAAiB,EACjB,qBAAqB,EACrB,qBAAqB,EACrB,OAAO,EACP,mBAAmB,EACnB,kBAAkB,EAClB,QAAQ,EACR,YAAY,GACZ,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAC"}
@@ -1,121 +0,0 @@
1
- /**
2
- * ExecApprovalService
3
- *
4
- * Service for managing command execution approvals in plugin-shell.
5
- * Integrates with Eliza's ApprovalService for approval UI,
6
- * and provides allowlist management and command analysis.
7
- *
8
- * @example
9
- * ```typescript
10
- * const approvalService = runtime.getService('exec_approval') as ExecApprovalService;
11
- *
12
- * // Check if command needs approval
13
- * const check = await approvalService.checkCommand({
14
- * command: 'rm -rf /tmp/cache',
15
- * cwd: '/home/user',
16
- * roomId: message.roomId,
17
- * });
18
- *
19
- * if (check.requiresApproval) {
20
- * const result = await approvalService.requestApproval(check.request);
21
- * if (result.decision === 'deny') {
22
- * return { error: 'Command denied' };
23
- * }
24
- * if (result.decision === 'allow-always') {
25
- * await approvalService.addToAllowlist(command);
26
- * }
27
- * }
28
- * ```
29
- */
30
- import type { IAgentRuntime, UUID } from "@elizaos/core";
31
- import { Service } from "@elizaos/core";
32
- import type { ExecAllowlistEntry, ExecApprovalDecision, ExecApprovalRequest, ExecApprovalResult, ExecApprovalsResolved, ExecCommandAnalysis } from "./types";
33
- /**
34
- * Command check result
35
- */
36
- export interface CommandCheckResult {
37
- /** Whether the command can be executed */
38
- allowed: boolean;
39
- /** Whether approval is required */
40
- requiresApproval: boolean;
41
- /** Reason for denial (if not allowed and no approval needed) */
42
- reason?: string;
43
- /** Approval request (if approval required) */
44
- request?: ExecApprovalRequest;
45
- /** Command analysis result */
46
- analysis: ExecCommandAnalysis;
47
- /** Matching allowlist entries */
48
- allowlistMatches: ExecAllowlistEntry[];
49
- }
50
- /**
51
- * ExecApprovalService provides command execution approval management.
52
- */
53
- export declare class ExecApprovalService extends Service {
54
- static serviceType: string;
55
- capabilityDescription: string;
56
- private approvalConfig;
57
- private safeBins;
58
- private skillBins;
59
- constructor(runtime?: IAgentRuntime);
60
- /**
61
- * Start the ExecApprovalService
62
- */
63
- static start(runtime: IAgentRuntime): Promise<Service>;
64
- /**
65
- * Stop the ExecApprovalService
66
- */
67
- stop(): Promise<void>;
68
- /**
69
- * Load/reload configuration
70
- */
71
- loadConfig(agentId?: string): ExecApprovalsResolved;
72
- /**
73
- * Get current configuration
74
- */
75
- getConfig(): ExecApprovalsResolved;
76
- /**
77
- * Set safe binaries that don't need approval
78
- */
79
- setSafeBins(bins: string[]): void;
80
- /**
81
- * Set skill binaries that are auto-allowed
82
- */
83
- setSkillBins(bins: string[]): void;
84
- /**
85
- * Check if a command is allowed to execute
86
- */
87
- checkCommand(params: {
88
- command: string;
89
- cwd?: string;
90
- roomId: UUID;
91
- env?: NodeJS.ProcessEnv;
92
- agentId?: string;
93
- }): Promise<CommandCheckResult>;
94
- /**
95
- * Request approval for a command
96
- */
97
- requestApproval(request: ExecApprovalRequest): Promise<ExecApprovalResult>;
98
- /**
99
- * Request approval asynchronously (fire and forget with callbacks)
100
- */
101
- requestApprovalAsync(request: ExecApprovalRequest, callbacks?: {
102
- onApproved?: (decision: ExecApprovalDecision) => Promise<void>;
103
- onDenied?: () => Promise<void>;
104
- onTimeout?: () => Promise<void>;
105
- }): Promise<UUID>;
106
- /**
107
- * Add a pattern to the allowlist
108
- * @returns true if pattern was added successfully
109
- */
110
- addToAllowlist(pattern: string, agentId?: string): Promise<boolean>;
111
- /**
112
- * Cancel a pending approval
113
- */
114
- cancelApproval(taskId: UUID): Promise<void>;
115
- /**
116
- * Get all pending exec approvals for a room
117
- */
118
- getPendingApprovals(roomId: UUID): Promise<ExecApprovalRequest[]>;
119
- }
120
- export default ExecApprovalService;
121
- //# sourceMappingURL=service.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../approvals/service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAQ,IAAI,EAAE,MAAM,eAAe,CAAC;AAC/D,OAAO,EAAgC,OAAO,EAAE,MAAM,eAAe,CAAC;AAyBtE,OAAO,KAAK,EACX,kBAAkB,EAClB,oBAAoB,EACpB,mBAAmB,EACnB,kBAAkB,EAClB,qBAAqB,EAErB,mBAAmB,EAEnB,MAAM,SAAS,CAAC;AAGjB;;GAEG;AACH,MAAM,WAAW,kBAAkB;IAClC,0CAA0C;IAC1C,OAAO,EAAE,OAAO,CAAC;IACjB,mCAAmC;IACnC,gBAAgB,EAAE,OAAO,CAAC;IAC1B,gEAAgE;IAChE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,8CAA8C;IAC9C,OAAO,CAAC,EAAE,mBAAmB,CAAC;IAC9B,8BAA8B;IAC9B,QAAQ,EAAE,mBAAmB,CAAC;IAC9B,iCAAiC;IACjC,gBAAgB,EAAE,kBAAkB,EAAE,CAAC;CACvC;A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