@elizaos/plugin-lmstudio 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 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,79 @@
1
+ # @elizaos/plugin-lmstudio
2
+
3
+ Connects [LM Studio](https://lmstudio.ai/) to elizaOS agents as a local inference backend via LM Studio's built-in OpenAI-compatible API.
4
+
5
+ ## What it does
6
+
7
+ This plugin registers text-generation and embedding model handlers for every elizaOS model tier. When active, all agent inference calls (chat, action planning, response handling, embeddings) are routed to a locally-running LM Studio instance instead of a cloud provider.
8
+
9
+ **Capabilities declared in `package.json`:** `text-large`, `text-small`, `embedding`.
10
+
11
+ ## Auto-enable behavior
12
+
13
+ The plugin activates automatically when either condition is true:
14
+
15
+ - `LMSTUDIO_BASE_URL` is set in the environment, **or**
16
+ - `http://localhost:1234/v1/models` responds successfully at startup (the default LM Studio port).
17
+
18
+ No manual plugin registration is needed in the common case.
19
+
20
+ ## Requirements
21
+
22
+ - [LM Studio](https://lmstudio.ai/) installed and running with its **Local Server** enabled (default port 1234).
23
+ - At least one model loaded in LM Studio.
24
+ - Node.js 20+ or Bun 1.x. Browser build is included but LM Studio is a local desktop server — browser use requires a CORS-permissive reverse proxy.
25
+
26
+ ## Configuration
27
+
28
+ All settings are optional. Use environment variables or character/agent settings (`runtime.getSetting`).
29
+
30
+ | Variable | Default | Description |
31
+ |---|---|---|
32
+ | `LMSTUDIO_BASE_URL` | `http://localhost:1234/v1` | LM Studio server URL. The plugin appends `/v1` if omitted. |
33
+ | `LMSTUDIO_API_KEY` | _(none)_ | Bearer token. Not needed unless LM Studio sits behind an auth proxy. |
34
+ | `LMSTUDIO_SMALL_MODEL` | _(auto)_ | Model identifier for small/nano/medium tiers. Falls back to the first model returned by `/v1/models`. |
35
+ | `LMSTUDIO_LARGE_MODEL` | _(auto)_ | Model identifier for large/mega/action-planner tiers. Same fallback. |
36
+ | `LMSTUDIO_EMBEDDING_MODEL` | _(none)_ | Model identifier for embedding calls. **Required** for memory/recall features. Without it, embeddings return a zero vector. |
37
+ | `LMSTUDIO_AUTO_DETECT` | `true` | Set to `0` or `false` to skip the init-time `/v1/models` probe. |
38
+
39
+ ### Example `.env`
40
+
41
+ ```
42
+ LMSTUDIO_BASE_URL=http://localhost:1234/v1
43
+ LMSTUDIO_SMALL_MODEL=llama-3.2-3b-instruct
44
+ LMSTUDIO_LARGE_MODEL=llama-3.3-70b-instruct
45
+ LMSTUDIO_EMBEDDING_MODEL=nomic-embed-text-v1.5
46
+ ```
47
+
48
+ ## Model tier mapping
49
+
50
+ | elizaOS tier | Routed to |
51
+ |---|---|
52
+ | `TEXT_NANO`, `TEXT_SMALL`, `TEXT_MEDIUM` | `LMSTUDIO_SMALL_MODEL` (or first loaded model) |
53
+ | `TEXT_LARGE`, `TEXT_MEGA`, `ACTION_PLANNER` | `LMSTUDIO_LARGE_MODEL` (or first loaded model) |
54
+ | `RESPONSE_HANDLER` | `LMSTUDIO_SMALL_MODEL` |
55
+ | `TEXT_EMBEDDING` | `LMSTUDIO_EMBEDDING_MODEL` |
56
+
57
+ ## Features
58
+
59
+ - **Streaming**: enabled by default when `params.stream` is set; streaming is disabled automatically when structured output (JSON schema) is also requested.
60
+ - **Structured output**: `responseSchema` is converted to `Output.object` via the Vercel AI SDK.
61
+ - **Tool calls**: native tool definitions are normalized and forwarded to the model.
62
+ - **Usage tracking**: emits `MODEL_USED` events with token counts (real or estimated) for each call.
63
+ - **Graceful degradation**: init-time detection failures are logged but do not crash the agent.
64
+
65
+ ## Installation
66
+
67
+ ```bash
68
+ # elizaOS picks it up automatically if LM Studio is running.
69
+ # To add it explicitly:
70
+ bun add @elizaos/plugin-lmstudio
71
+ ```
72
+
73
+ Then reference it in your character file or plugin list:
74
+
75
+ ```json
76
+ {
77
+ "plugins": ["@elizaos/plugin-lmstudio"]
78
+ }
79
+ ```
package/auto-enable.ts ADDED
@@ -0,0 +1,24 @@
1
+ // Auto-enable check for @elizaos/plugin-lmstudio.
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
+ //
8
+ // LM Studio activates when either:
9
+ // 1. The operator opted in explicitly via `LMSTUDIO_BASE_URL`, or
10
+ // 2. The default `http://localhost:1234/v1/models` endpoint is reachable —
11
+ // handled at runtime by the plugin's `autoEnable.shouldEnable` predicate.
12
+ // This manifest just registers the env signal; the live probe is the
13
+ // plugin's responsibility so the autoenable engine can stay synchronous.
14
+
15
+ import type { PluginAutoEnableContext } from "@elizaos/core";
16
+
17
+ const ENV_KEYS = ["LMSTUDIO_BASE_URL"] as const;
18
+
19
+ export function shouldEnable(ctx: PluginAutoEnableContext): boolean {
20
+ return ENV_KEYS.some((k) => {
21
+ const v = ctx.env[k];
22
+ return typeof v === "string" && v.trim() !== "";
23
+ });
24
+ }
package/package.json ADDED
@@ -0,0 +1,141 @@
1
+ {
2
+ "name": "@elizaos/plugin-lmstudio",
3
+ "version": "2.0.11-beta.7",
4
+ "type": "module",
5
+ "main": "dist/node/index.node.js",
6
+ "module": "dist/node/index.node.js",
7
+ "types": "dist/node/index.d.ts",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/elizaOS/eliza.git",
11
+ "directory": "plugins/plugin-lmstudio"
12
+ },
13
+ "exports": {
14
+ "./package.json": "./package.json",
15
+ ".": {
16
+ "types": "./dist/node/index.d.ts",
17
+ "browser": {
18
+ "types": "./dist/browser/index.d.ts",
19
+ "import": "./dist/browser/index.browser.js",
20
+ "default": "./dist/browser/index.browser.js"
21
+ },
22
+ "node": {
23
+ "types": "./dist/node/index.d.ts",
24
+ "import": "./dist/node/index.node.js",
25
+ "default": "./dist/node/index.node.js"
26
+ },
27
+ "bun": {
28
+ "types": "./dist/node/index.d.ts",
29
+ "default": "./dist/node/index.node.js"
30
+ },
31
+ "default": "./dist/node/index.node.js"
32
+ },
33
+ "./*.css": "./dist/*.css",
34
+ "./*": {
35
+ "types": "./dist/*.d.ts",
36
+ "import": "./dist/*.js",
37
+ "default": "./dist/*.js"
38
+ }
39
+ },
40
+ "files": [
41
+ "dist",
42
+ "auto-enable.ts"
43
+ ],
44
+ "elizaos": {
45
+ "plugin": {
46
+ "autoEnableModule": "./auto-enable.ts",
47
+ "capabilities": [
48
+ "text-large",
49
+ "text-small",
50
+ "embedding"
51
+ ]
52
+ }
53
+ },
54
+ "sideEffects": false,
55
+ "dependencies": {
56
+ "@ai-sdk/openai-compatible": "^2.0.51",
57
+ "ai": "^6.0.174"
58
+ },
59
+ "devDependencies": {
60
+ "@biomejs/biome": "^2.4.14",
61
+ "@elizaos/core": "2.0.11-beta.7",
62
+ "@types/node": "^25.0.3",
63
+ "bun-types": "^1.3.12",
64
+ "typescript": "^6.0.3",
65
+ "vitest": "^4.0.0"
66
+ },
67
+ "peerDependencies": {
68
+ "@elizaos/core": "2.0.11-beta.7"
69
+ },
70
+ "scripts": {
71
+ "dev": "bun run build.ts --watch",
72
+ "lint": "bunx @biomejs/biome check --write --unsafe .",
73
+ "clean": "rm -rf dist .turbo .turbo-tsconfig.json tsconfig.tsbuildinfo",
74
+ "format": "bunx @biomejs/biome format --write .",
75
+ "format:check": "bunx @biomejs/biome format .",
76
+ "typecheck": "tsc --noEmit --noCheck -p tsconfig.json",
77
+ "test": "vitest run --config ./vitest.config.ts __tests__/",
78
+ "test:unit": "vitest run --config ./vitest.config.ts __tests__/",
79
+ "lint:check": "bunx @biomejs/biome check .",
80
+ "build": "bun run build.ts",
81
+ "build:ts": "bun run build.ts"
82
+ },
83
+ "publishConfig": {
84
+ "access": "public"
85
+ },
86
+ "agentConfig": {
87
+ "pluginType": "elizaos:plugin:1.0.0",
88
+ "pluginParameters": {
89
+ "LMSTUDIO_BASE_URL": {
90
+ "type": "string",
91
+ "description": "Base URL for the LM Studio OpenAI-compatible API (default http://localhost:1234/v1).",
92
+ "required": false,
93
+ "default": "http://localhost:1234/v1",
94
+ "sensitive": false
95
+ },
96
+ "LMSTUDIO_API_KEY": {
97
+ "type": "string",
98
+ "description": "Optional API key. LM Studio does not require one by default; set this only if you've put it behind an auth proxy.",
99
+ "required": false,
100
+ "sensitive": true
101
+ },
102
+ "LMSTUDIO_SMALL_MODEL": {
103
+ "type": "string",
104
+ "description": "Identifier of the small-sized LM Studio model to use for text generation.",
105
+ "required": false,
106
+ "sensitive": false
107
+ },
108
+ "LMSTUDIO_LARGE_MODEL": {
109
+ "type": "string",
110
+ "description": "Identifier of the large-sized LM Studio model to use for text generation.",
111
+ "required": false,
112
+ "sensitive": false
113
+ },
114
+ "LMSTUDIO_EMBEDDING_MODEL": {
115
+ "type": "string",
116
+ "description": "Identifier of the LM Studio model used to generate text embeddings, when embeddings are served by the same LM Studio instance.",
117
+ "required": false,
118
+ "sensitive": false
119
+ },
120
+ "LMSTUDIO_AUTO_DETECT": {
121
+ "type": "string",
122
+ "description": "When set to 1/true, the plugin probes http://localhost:1234/v1/models on init and logs a clear warning if LM Studio is not reachable.",
123
+ "required": false,
124
+ "default": "true",
125
+ "sensitive": false
126
+ }
127
+ }
128
+ },
129
+ "eliza": {
130
+ "platforms": [
131
+ "browser",
132
+ "node"
133
+ ],
134
+ "runtime": "both",
135
+ "platformDetails": {
136
+ "browser": "Browser-compatible build available via exports.browser",
137
+ "node": "Node.js build available via exports.node"
138
+ }
139
+ },
140
+ "gitHead": "cdbc876f793d96073d7eb0d09715a031ce0cd32e"
141
+ }