@easbot/plugin 0.2.6 → 0.2.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 -21
- package/README.md +116 -116
- package/package.json +3 -3
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026 houjallen
|
|
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.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 houjallen
|
|
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
CHANGED
|
@@ -1,116 +1,116 @@
|
|
|
1
|
-
[English](./README.en.md) | 中文
|
|
2
|
-
|
|
3
|
-
# @easbot/plugin
|
|
4
|
-
|
|
5
|
-
EASBot 插件系统 - Hook、命令和工具管理
|
|
6
|
-
|
|
7
|
-
## 特性
|
|
8
|
-
|
|
9
|
-
- **Hook 系统**:事件驱动的 Hook 机制,扩展 Agent 行为
|
|
10
|
-
- **命令系统**:可扩展的命令注册和执行
|
|
11
|
-
- **工具系统**:插件工具与权限控制
|
|
12
|
-
- **Shell 集成**:Shell 命令执行支持
|
|
13
|
-
|
|
14
|
-
## 安装
|
|
15
|
-
|
|
16
|
-
```bash
|
|
17
|
-
pnpm add @easbot/plugin
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
## 快速开始
|
|
21
|
-
|
|
22
|
-
### Hook 系统
|
|
23
|
-
|
|
24
|
-
```typescript
|
|
25
|
-
import { createHookRegistry, HOOK_EVENTS } from '@easbot/plugin';
|
|
26
|
-
|
|
27
|
-
// 创建 Hook 注册表
|
|
28
|
-
const hooks = createHookRegistry();
|
|
29
|
-
|
|
30
|
-
// 注册 Hook
|
|
31
|
-
hooks.register(HOOK_EVENTS.BEFORE_TOOL_CALL, async (tool, context) => {
|
|
32
|
-
console.log('Tool called:', tool.name);
|
|
33
|
-
return context;
|
|
34
|
-
});
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
### 命令系统
|
|
38
|
-
|
|
39
|
-
```typescript
|
|
40
|
-
import { createCommandRegistry } from '@easbot/plugin';
|
|
41
|
-
|
|
42
|
-
const commands = createCommandRegistry();
|
|
43
|
-
|
|
44
|
-
// 注册命令
|
|
45
|
-
commands.register({
|
|
46
|
-
name: 'hello',
|
|
47
|
-
description: '打招呼',
|
|
48
|
-
execute: async (args, session) => {
|
|
49
|
-
await session.send('你好!');
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
### 工具系统
|
|
55
|
-
|
|
56
|
-
```typescript
|
|
57
|
-
import { createTool } from '@easbot/plugin';
|
|
58
|
-
|
|
59
|
-
const tool = createTool({
|
|
60
|
-
name: 'my-tool',
|
|
61
|
-
description: '自定义工具',
|
|
62
|
-
parameters: z.object({
|
|
63
|
-
input: z.string()
|
|
64
|
-
}),
|
|
65
|
-
execute: async ({ input }) => {
|
|
66
|
-
return { result: input.toUpperCase() };
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
## API
|
|
72
|
-
|
|
73
|
-
### HookRegistry
|
|
74
|
-
|
|
75
|
-
| 方法 | 说明 |
|
|
76
|
-
|------|------|
|
|
77
|
-
| `register(event, handler)` | 注册 Hook 处理器 |
|
|
78
|
-
| `unregister(event, handler)` | 移除 Hook 处理器 |
|
|
79
|
-
| `clear(event)` | 清除事件的所有处理器 |
|
|
80
|
-
|
|
81
|
-
### CommandRegistry
|
|
82
|
-
|
|
83
|
-
| 方法 | 说明 |
|
|
84
|
-
|------|------|
|
|
85
|
-
| `register(command)` | 注册命令 |
|
|
86
|
-
| `get(name)` | 获取命令 |
|
|
87
|
-
| `execute(name, args)` | 执行命令 |
|
|
88
|
-
|
|
89
|
-
### createTool
|
|
90
|
-
|
|
91
|
-
| 属性 | 类型 | 说明 |
|
|
92
|
-
|------|------|------|
|
|
93
|
-
| name | string | 工具名称 |
|
|
94
|
-
| description | string | 工具描述 |
|
|
95
|
-
| parameters | ZodSchema | 参数模式 |
|
|
96
|
-
| execute | function | 工具实现 |
|
|
97
|
-
|
|
98
|
-
## 开发
|
|
99
|
-
|
|
100
|
-
```bash
|
|
101
|
-
# 安装依赖
|
|
102
|
-
pnpm install
|
|
103
|
-
|
|
104
|
-
# 构建
|
|
105
|
-
pnpm build
|
|
106
|
-
|
|
107
|
-
# 测试
|
|
108
|
-
pnpm test
|
|
109
|
-
|
|
110
|
-
# 类型检查
|
|
111
|
-
pnpm type-check
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
## 许可证
|
|
115
|
-
|
|
116
|
-
MIT
|
|
1
|
+
[English](./README.en.md) | 中文
|
|
2
|
+
|
|
3
|
+
# @easbot/plugin
|
|
4
|
+
|
|
5
|
+
EASBot 插件系统 - Hook、命令和工具管理
|
|
6
|
+
|
|
7
|
+
## 特性
|
|
8
|
+
|
|
9
|
+
- **Hook 系统**:事件驱动的 Hook 机制,扩展 Agent 行为
|
|
10
|
+
- **命令系统**:可扩展的命令注册和执行
|
|
11
|
+
- **工具系统**:插件工具与权限控制
|
|
12
|
+
- **Shell 集成**:Shell 命令执行支持
|
|
13
|
+
|
|
14
|
+
## 安装
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
pnpm add @easbot/plugin
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## 快速开始
|
|
21
|
+
|
|
22
|
+
### Hook 系统
|
|
23
|
+
|
|
24
|
+
```typescript
|
|
25
|
+
import { createHookRegistry, HOOK_EVENTS } from '@easbot/plugin';
|
|
26
|
+
|
|
27
|
+
// 创建 Hook 注册表
|
|
28
|
+
const hooks = createHookRegistry();
|
|
29
|
+
|
|
30
|
+
// 注册 Hook
|
|
31
|
+
hooks.register(HOOK_EVENTS.BEFORE_TOOL_CALL, async (tool, context) => {
|
|
32
|
+
console.log('Tool called:', tool.name);
|
|
33
|
+
return context;
|
|
34
|
+
});
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### 命令系统
|
|
38
|
+
|
|
39
|
+
```typescript
|
|
40
|
+
import { createCommandRegistry } from '@easbot/plugin';
|
|
41
|
+
|
|
42
|
+
const commands = createCommandRegistry();
|
|
43
|
+
|
|
44
|
+
// 注册命令
|
|
45
|
+
commands.register({
|
|
46
|
+
name: 'hello',
|
|
47
|
+
description: '打招呼',
|
|
48
|
+
execute: async (args, session) => {
|
|
49
|
+
await session.send('你好!');
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### 工具系统
|
|
55
|
+
|
|
56
|
+
```typescript
|
|
57
|
+
import { createTool } from '@easbot/plugin';
|
|
58
|
+
|
|
59
|
+
const tool = createTool({
|
|
60
|
+
name: 'my-tool',
|
|
61
|
+
description: '自定义工具',
|
|
62
|
+
parameters: z.object({
|
|
63
|
+
input: z.string()
|
|
64
|
+
}),
|
|
65
|
+
execute: async ({ input }) => {
|
|
66
|
+
return { result: input.toUpperCase() };
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## API
|
|
72
|
+
|
|
73
|
+
### HookRegistry
|
|
74
|
+
|
|
75
|
+
| 方法 | 说明 |
|
|
76
|
+
|------|------|
|
|
77
|
+
| `register(event, handler)` | 注册 Hook 处理器 |
|
|
78
|
+
| `unregister(event, handler)` | 移除 Hook 处理器 |
|
|
79
|
+
| `clear(event)` | 清除事件的所有处理器 |
|
|
80
|
+
|
|
81
|
+
### CommandRegistry
|
|
82
|
+
|
|
83
|
+
| 方法 | 说明 |
|
|
84
|
+
|------|------|
|
|
85
|
+
| `register(command)` | 注册命令 |
|
|
86
|
+
| `get(name)` | 获取命令 |
|
|
87
|
+
| `execute(name, args)` | 执行命令 |
|
|
88
|
+
|
|
89
|
+
### createTool
|
|
90
|
+
|
|
91
|
+
| 属性 | 类型 | 说明 |
|
|
92
|
+
|------|------|------|
|
|
93
|
+
| name | string | 工具名称 |
|
|
94
|
+
| description | string | 工具描述 |
|
|
95
|
+
| parameters | ZodSchema | 参数模式 |
|
|
96
|
+
| execute | function | 工具实现 |
|
|
97
|
+
|
|
98
|
+
## 开发
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
# 安装依赖
|
|
102
|
+
pnpm install
|
|
103
|
+
|
|
104
|
+
# 构建
|
|
105
|
+
pnpm build
|
|
106
|
+
|
|
107
|
+
# 测试
|
|
108
|
+
pnpm test
|
|
109
|
+
|
|
110
|
+
# 类型检查
|
|
111
|
+
pnpm type-check
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
## 许可证
|
|
115
|
+
|
|
116
|
+
MIT
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@easbot/plugin",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.7",
|
|
4
4
|
"description": "EASBot Plugin for client applications",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.cjs",
|
|
@@ -44,8 +44,8 @@
|
|
|
44
44
|
],
|
|
45
45
|
"dependencies": {
|
|
46
46
|
"zod": "^4.4.3",
|
|
47
|
-
"@easbot/sdk": "0.2.
|
|
48
|
-
"@easbot/types": "0.2.
|
|
47
|
+
"@easbot/sdk": "0.2.7",
|
|
48
|
+
"@easbot/types": "0.2.7"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"@types/node": "^25.6.2",
|