@elizaos/plugin-zai 2.0.3-beta.5
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 +23 -0
- package/README.md +48 -0
- package/auto-enable.ts +17 -0
- package/package.json +169 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 elizaOS
|
|
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.
|
|
22
|
+
|
|
23
|
+
|
package/README.md
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# @elizaos/plugin-zai
|
|
2
|
+
|
|
3
|
+
First-party z.ai model provider plugin for elizaOS.
|
|
4
|
+
|
|
5
|
+
This plugin targets **z.ai's general OpenAI-compatible API** and supports:
|
|
6
|
+
|
|
7
|
+
- `TEXT_SMALL`, `TEXT_LARGE`
|
|
8
|
+
|
|
9
|
+
## Install
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
eliza plugins install @elizaos/plugin-zai
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Configuration
|
|
16
|
+
|
|
17
|
+
| Variable | Required | Default | Description |
|
|
18
|
+
| --- | --- | --- | --- |
|
|
19
|
+
| `ZAI_API_KEY` | Yes | – | z.ai API key |
|
|
20
|
+
| `Z_AI_API_KEY` | No | – | Legacy alias accepted when `ZAI_API_KEY` is unset |
|
|
21
|
+
| `ZAI_BASE_URL` | No | `https://api.z.ai/api/paas/v4` | General API base URL. Coding Plan and Anthropic-compatible coding-tool endpoints are rejected here. |
|
|
22
|
+
| `ZAI_SMALL_MODEL` | No | `glm-4.5-air` | Small model id |
|
|
23
|
+
| `ZAI_LARGE_MODEL` | No | `glm-5.1` | Large model id |
|
|
24
|
+
| `ZAI_THINKING_TYPE` | No | – | Optional thinking mode override: `enabled` or `disabled`; unset uses z.ai's default |
|
|
25
|
+
| `ZAI_COT_BUDGET` | No | – | Deprecated compatibility setting. Positive values enable thinking mode; z.ai does not accept Anthropic `budget_tokens`. |
|
|
26
|
+
| `ZAI_COT_BUDGET_SMALL` | No | – | Deprecated compatibility setting for small-model calls |
|
|
27
|
+
| `ZAI_COT_BUDGET_LARGE` | No | – | Deprecated compatibility setting for large-model calls |
|
|
28
|
+
|
|
29
|
+
Prefer `ZAI_API_KEY` for new configuration. `Z_AI_API_KEY` exists only for compatibility with older z.ai wiring.
|
|
30
|
+
|
|
31
|
+
This plugin targets z.ai's general API only. Do not point it at
|
|
32
|
+
`https://api.z.ai/api/coding/paas/v4` or `https://api.z.ai/api/anthropic`; those
|
|
33
|
+
paths are reserved for z.ai's coding tools and `getBaseURL` rejects them.
|
|
34
|
+
|
|
35
|
+
## Usage
|
|
36
|
+
|
|
37
|
+
```ts
|
|
38
|
+
import { AgentRuntime, ModelType } from "@elizaos/core";
|
|
39
|
+
import zaiPlugin from "@elizaos/plugin-zai";
|
|
40
|
+
|
|
41
|
+
const runtime = new AgentRuntime({ plugins: [zaiPlugin] });
|
|
42
|
+
|
|
43
|
+
const text = await runtime.useModel(ModelType.TEXT_LARGE, {
|
|
44
|
+
prompt: "Write a haiku about local-first AI.",
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
console.log(text);
|
|
48
|
+
```
|
package/auto-enable.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// Auto-enable check for @elizaos/plugin-zai.
|
|
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.
|
|
6
|
+
type PluginAutoEnableContext = {
|
|
7
|
+
env: Record<string, string | undefined>;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
/** Enable when a z.ai API key is present in the environment. */
|
|
11
|
+
export function shouldEnable(ctx: PluginAutoEnableContext): boolean {
|
|
12
|
+
const env = ctx.env;
|
|
13
|
+
return Boolean(
|
|
14
|
+
(env.ZAI_API_KEY && env.ZAI_API_KEY.trim() !== "") ||
|
|
15
|
+
(env.Z_AI_API_KEY && env.Z_AI_API_KEY.trim() !== "")
|
|
16
|
+
);
|
|
17
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@elizaos/plugin-zai",
|
|
3
|
+
"version": "2.0.3-beta.5",
|
|
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
|
+
"browser": "dist/browser/index.browser.js",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/elizaos-plugins/plugin-zai.git"
|
|
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
|
+
"import": {
|
|
28
|
+
"types": "./dist/node/index.d.ts",
|
|
29
|
+
"default": "./dist/node/index.node.js"
|
|
30
|
+
},
|
|
31
|
+
"default": {
|
|
32
|
+
"types": "./dist/node/index.d.ts",
|
|
33
|
+
"default": "./dist/node/index.node.js"
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
"./*.css": "./dist/*.css",
|
|
37
|
+
"./*": {
|
|
38
|
+
"types": "./dist/*.d.ts",
|
|
39
|
+
"import": "./dist/*.js",
|
|
40
|
+
"default": "./dist/*.js"
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
"files": [
|
|
44
|
+
"dist",
|
|
45
|
+
"auto-enable.ts"
|
|
46
|
+
],
|
|
47
|
+
"elizaos": {
|
|
48
|
+
"plugin": {
|
|
49
|
+
"autoEnableModule": "./auto-enable.ts",
|
|
50
|
+
"capabilities": [
|
|
51
|
+
"text-large",
|
|
52
|
+
"text-small"
|
|
53
|
+
]
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
"sideEffects": false,
|
|
57
|
+
"dependencies": {
|
|
58
|
+
"@ai-sdk/openai-compatible": "^2.0.51",
|
|
59
|
+
"@elizaos/core": "2.0.3-beta.5",
|
|
60
|
+
"ai": "^6.0.23"
|
|
61
|
+
},
|
|
62
|
+
"devDependencies": {
|
|
63
|
+
"@biomejs/biome": "^2.4.14",
|
|
64
|
+
"@types/bun": "^1.3.10",
|
|
65
|
+
"@types/node": "^25.0.3",
|
|
66
|
+
"typescript": "^6.0.3",
|
|
67
|
+
"vitest": "^4.1.4"
|
|
68
|
+
},
|
|
69
|
+
"scripts": {
|
|
70
|
+
"dev": "bun run build.ts --watch",
|
|
71
|
+
"clean": "node ../../packages/scripts/rm-path-recursive.mjs dist .turbo .turbo-tsconfig.json tsconfig.tsbuildinfo",
|
|
72
|
+
"format": "bunx @biomejs/biome format --write .",
|
|
73
|
+
"format:check": "bunx @biomejs/biome format .",
|
|
74
|
+
"lint": "bunx @biomejs/biome check --write --unsafe .",
|
|
75
|
+
"lint:check": "bunx @biomejs/biome check . --no-errors-on-unmatched",
|
|
76
|
+
"typecheck": "tsgo --noEmit -p tsconfig.json",
|
|
77
|
+
"test": "bunx vitest run --config vitest.config.ts",
|
|
78
|
+
"test:watch": "bunx vitest --config vitest.config.ts",
|
|
79
|
+
"build": "bun run build.ts",
|
|
80
|
+
"build:ts": "bun run build.ts"
|
|
81
|
+
},
|
|
82
|
+
"publishConfig": {
|
|
83
|
+
"access": "public"
|
|
84
|
+
},
|
|
85
|
+
"agentConfig": {
|
|
86
|
+
"pluginType": "elizaos:plugin:1.0.0",
|
|
87
|
+
"pluginParameters": {
|
|
88
|
+
"ZAI_API_KEY": {
|
|
89
|
+
"type": "string",
|
|
90
|
+
"description": "API key used to authenticate requests to z.ai's general OpenAI-compatible API",
|
|
91
|
+
"required": true,
|
|
92
|
+
"sensitive": true
|
|
93
|
+
},
|
|
94
|
+
"ZAI_BASE_URL": {
|
|
95
|
+
"type": "string",
|
|
96
|
+
"description": "Base URL for z.ai's general OpenAI-compatible API. Coding Plan and Anthropic-compatible coding-tool endpoints are intentionally rejected here.",
|
|
97
|
+
"required": false,
|
|
98
|
+
"default": "https://api.z.ai/api/paas/v4",
|
|
99
|
+
"sensitive": false
|
|
100
|
+
},
|
|
101
|
+
"ZAI_SMALL_MODEL": {
|
|
102
|
+
"type": "string",
|
|
103
|
+
"description": "Override the default z.ai small model identifier",
|
|
104
|
+
"required": false,
|
|
105
|
+
"default": "glm-4.5-air",
|
|
106
|
+
"sensitive": false
|
|
107
|
+
},
|
|
108
|
+
"ZAI_LARGE_MODEL": {
|
|
109
|
+
"type": "string",
|
|
110
|
+
"description": "Override the default z.ai large model identifier",
|
|
111
|
+
"required": false,
|
|
112
|
+
"default": "glm-5.1",
|
|
113
|
+
"sensitive": false
|
|
114
|
+
},
|
|
115
|
+
"ZAI_EXPERIMENTAL_TELEMETRY": {
|
|
116
|
+
"type": "boolean",
|
|
117
|
+
"description": "Enable experimental telemetry features for enhanced debugging and usage analytics.",
|
|
118
|
+
"required": false,
|
|
119
|
+
"default": false,
|
|
120
|
+
"sensitive": false
|
|
121
|
+
},
|
|
122
|
+
"ZAI_BROWSER_BASE_URL": {
|
|
123
|
+
"type": "string",
|
|
124
|
+
"description": "Browser-only proxy endpoint base URL for z.ai requests. Do not expose API keys in browser clients.",
|
|
125
|
+
"required": false,
|
|
126
|
+
"sensitive": false
|
|
127
|
+
},
|
|
128
|
+
"ZAI_COT_BUDGET": {
|
|
129
|
+
"type": "string",
|
|
130
|
+
"description": "Deprecated compatibility setting. A positive value enables z.ai thinking mode, but z.ai's OpenAI-compatible API does not accept Anthropic budget_tokens.",
|
|
131
|
+
"required": false,
|
|
132
|
+
"sensitive": false
|
|
133
|
+
},
|
|
134
|
+
"ZAI_COT_BUDGET_SMALL": {
|
|
135
|
+
"type": "string",
|
|
136
|
+
"description": "Deprecated compatibility setting. A positive value enables z.ai thinking mode for small-model calls.",
|
|
137
|
+
"required": false,
|
|
138
|
+
"sensitive": false
|
|
139
|
+
},
|
|
140
|
+
"ZAI_COT_BUDGET_LARGE": {
|
|
141
|
+
"type": "string",
|
|
142
|
+
"description": "Deprecated compatibility setting. A positive value enables z.ai thinking mode for large-model calls.",
|
|
143
|
+
"required": false,
|
|
144
|
+
"sensitive": false
|
|
145
|
+
},
|
|
146
|
+
"ZAI_THINKING_TYPE": {
|
|
147
|
+
"type": "string",
|
|
148
|
+
"description": "Optional z.ai thinking mode override: enabled or disabled. When unset, z.ai uses its service default.",
|
|
149
|
+
"required": false,
|
|
150
|
+
"sensitive": false
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
},
|
|
154
|
+
"eliza": {
|
|
155
|
+
"platforms": [
|
|
156
|
+
"browser",
|
|
157
|
+
"node"
|
|
158
|
+
],
|
|
159
|
+
"runtime": "both",
|
|
160
|
+
"platformDetails": {
|
|
161
|
+
"browser": "Browser-compatible build available via exports.browser",
|
|
162
|
+
"node": "Node.js build available via exports.node"
|
|
163
|
+
}
|
|
164
|
+
},
|
|
165
|
+
"peerDependencies": {
|
|
166
|
+
"@elizaos/core": "2.0.3-beta.5"
|
|
167
|
+
},
|
|
168
|
+
"gitHead": "ff6157011c9459670021cc28a6797592a78b8817"
|
|
169
|
+
}
|