foliko 2.0.4 → 2.0.6
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/.claude/settings.local.json +4 -1
- package/.cli_default_systemPrompt.md +291 -0
- package/CLAUDE.md +3 -0
- package/README.md +20 -3
- package/docs/architecture.md +34 -2
- package/docs/extensions.md +199 -0
- package/docs/migration.md +100 -0
- package/docs/public-api.md +1180 -6
- package/docs/usage.md +122 -30
- package/package.json +1 -1
- package/plugins/core/audit/index.js +1 -1
- package/plugins/core/default/bootstrap.js +65 -19
- package/plugins/core/python-loader/index.js +43 -25
- package/plugins/core/skill-manager/PROMPT.md +6 -0
- package/plugins/core/skill-manager/index.js +538 -93
- package/plugins/core/sub-agent/PROMPT.md +10 -0
- package/plugins/core/sub-agent/index.js +36 -3
- package/plugins/core/think/index.js +1 -0
- package/plugins/core/workflow/index.js +106 -22
- package/plugins/executors/data-splitter/PROMPT.md +13 -0
- package/plugins/executors/data-splitter/index.js +5 -4
- package/plugins/executors/extension/extension-registry.js +145 -0
- package/plugins/executors/extension/index.js +405 -437
- package/plugins/executors/extension/prompt-builder.js +359 -0
- package/plugins/executors/extension/skill-helper.js +143 -0
- package/plugins/messaging/feishu/index.js +5 -3
- package/plugins/messaging/qq/index.js +6 -4
- package/plugins/messaging/telegram/index.js +6 -3
- package/plugins/messaging/weixin/index.js +5 -3
- package/plugins/tools/PROMPT.md +26 -0
- package/plugins/tools/index.js +6 -5
- package/skills/foliko/AGENTS.md +196 -43
- package/skills/foliko/SKILL.md +157 -28
- package/skills/mcp/SKILL.md +77 -118
- package/skills/plugins/SKILL.md +89 -3
- package/skills/python/SKILL.md +57 -39
- package/skills/skill-guide/SKILL.md +42 -34
- package/skills/workflows/SKILL.md +224 -9
- package/skills/workflows/workflow-troubleshooting/SKILL.md +221 -281
- package/src/agent/chat.js +48 -27
- package/src/agent/main.js +34 -13
- package/src/agent/prompt-registry.js +133 -87
- package/src/agent/prompts/PROMPT.md +3 -0
- package/src/agent/sub.js +1 -1
- package/src/cli/ui/chat-ui-old.js +5 -2
- package/src/cli/ui/chat-ui.js +5 -2
- package/src/common/constants.js +12 -0
- package/src/common/error-capture.js +91 -0
- package/src/common/logger.js +2 -2
- package/src/context/compressor.js +6 -2
- package/src/executors/mcp-executor.js +105 -125
- package/src/framework/framework.js +632 -6
- package/src/index.js +4 -0
- package/src/plugin/base.js +913 -10
- package/src/plugin/manager.js +29 -8
- package/src/tool/schema.js +32 -9
- package/tests/core/plugin-prompts.test.js +13 -13
- package/tests/core/prompt-registry.test.js +59 -51
- package/website/index.html +821 -0
package/skills/foliko/AGENTS.md
CHANGED
|
@@ -63,19 +63,18 @@ module.exports = function (Plugin) {
|
|
|
63
63
|
this.priority = 10;
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
66
|
+
onStart(framework) {
|
|
67
|
+
// Register AI SDK tool
|
|
68
|
+
this.tool.register({
|
|
69
69
|
name: 'my_tool',
|
|
70
70
|
description: '工具描述',
|
|
71
|
-
inputSchema: z.object({
|
|
72
|
-
param: z.string().describe('参数描述'),
|
|
71
|
+
inputSchema: framework.z.object({
|
|
72
|
+
param: framework.z.string().describe('参数描述'),
|
|
73
73
|
}),
|
|
74
|
-
execute: async (args
|
|
74
|
+
execute: async (args) => {
|
|
75
75
|
return { success: true, result: args.param };
|
|
76
76
|
},
|
|
77
77
|
});
|
|
78
|
-
return this;
|
|
79
78
|
}
|
|
80
79
|
|
|
81
80
|
uninstall(framework) {
|
|
@@ -119,18 +118,17 @@ class MyPlugin extends Plugin {
|
|
|
119
118
|
this.priority = 10;
|
|
120
119
|
}
|
|
121
120
|
|
|
122
|
-
|
|
123
|
-
|
|
121
|
+
onStart(framework) {
|
|
122
|
+
this.tool.register({
|
|
124
123
|
name: 'my_tool',
|
|
125
124
|
description: '工具描述',
|
|
126
|
-
inputSchema: z.object({
|
|
127
|
-
param: z.string().describe('参数描述'),
|
|
125
|
+
inputSchema: framework.z.object({
|
|
126
|
+
param: framework.z.string().describe('参数描述'),
|
|
128
127
|
}),
|
|
129
|
-
execute: async (args
|
|
128
|
+
execute: async (args) => {
|
|
130
129
|
return { success: true, result: args.param };
|
|
131
130
|
},
|
|
132
131
|
});
|
|
133
|
-
return this;
|
|
134
132
|
}
|
|
135
133
|
|
|
136
134
|
uninstall(framework) {}
|
|
@@ -150,47 +148,204 @@ module.exports = { MyPlugin };
|
|
|
150
148
|
|
|
151
149
|
## Lifecycle Methods
|
|
152
150
|
|
|
153
|
-
| Method
|
|
154
|
-
|
|
155
|
-
| `install(framework)`
|
|
156
|
-
| `
|
|
157
|
-
| `
|
|
158
|
-
| `
|
|
151
|
+
| Method | Called When | Required | Description |
|
|
152
|
+
|--------|-------------|----------|-------------|
|
|
153
|
+
| `install(framework)` | Plugin installed | ✅ | Initialize, get framework |
|
|
154
|
+
| `onStart(framework)` | start/enable/reload | Recommended | Register tools, extensions, sub-agents |
|
|
155
|
+
| `onStop()` | disable | Optional | Cleanup resources |
|
|
156
|
+
| `reload(framework)` | Hot reload | Optional | prompts auto cleanup/register |
|
|
157
|
+
| `uninstall(framework)` | Plugin uninstalled | Recommended | Cleanup resources |
|
|
158
|
+
|
|
159
|
+
### onStart / onStop (Recommended)
|
|
160
|
+
|
|
161
|
+
**Use `onStart` to register tools and extensions** - base class handles lifecycle automatically:
|
|
162
|
+
|
|
163
|
+
```javascript
|
|
164
|
+
class MyPlugin extends Plugin {
|
|
165
|
+
name = 'my-plugin';
|
|
166
|
+
version = '1.0.0';
|
|
167
|
+
description = '我的插件';
|
|
168
|
+
|
|
169
|
+
onStart(framework) {
|
|
170
|
+
// Register AI SDK tool (direct call)
|
|
171
|
+
this.tool.register({
|
|
172
|
+
name: 'hello',
|
|
173
|
+
description: '打招呼',
|
|
174
|
+
inputSchema: framework.z.object({
|
|
175
|
+
name: framework.z.string().describe('姓名')
|
|
176
|
+
}),
|
|
177
|
+
execute: async (args) => ({ message: `Hello, ${args.name}!` }),
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
// Register extension tool (via ext_call)
|
|
181
|
+
this.extension.register({
|
|
182
|
+
name: 'greet',
|
|
183
|
+
description: '打招呼扩展',
|
|
184
|
+
inputSchema: framework.z.object({
|
|
185
|
+
name: framework.z.string()
|
|
186
|
+
}),
|
|
187
|
+
execute: async (args) => ({ message: `Hi, ${args.name}!` }),
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
### Lifecycle Auto-Management
|
|
194
|
+
|
|
195
|
+
| Operation | Effect |
|
|
196
|
+
|-----------|--------|
|
|
197
|
+
| `disable` | Auto-remove tools/extensions (keep registration records) |
|
|
198
|
+
| `enable` | Auto re-register tools/extensions |
|
|
199
|
+
| `reload` | Remove and re-register |
|
|
200
|
+
| `uninstall` | Remove and clear registration records |
|
|
159
201
|
|
|
160
202
|
## Tool Registration
|
|
161
203
|
|
|
162
|
-
|
|
204
|
+
### Recommended: `this.tool.register()` in `onStart`
|
|
205
|
+
|
|
206
|
+
```javascript
|
|
207
|
+
onStart(framework) {
|
|
208
|
+
this.tool.register({
|
|
209
|
+
name: 'my_tool',
|
|
210
|
+
description: 'Tool description',
|
|
211
|
+
inputSchema: framework.z.object({
|
|
212
|
+
param: framework.z.string().describe('Parameter description')
|
|
213
|
+
}),
|
|
214
|
+
execute: async (args) => ({ success: true, result: args.param })
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
### Alternative: `this.tools = {}` (ExtensionExecutor auto-scan)
|
|
220
|
+
|
|
221
|
+
```javascript
|
|
222
|
+
class MyPlugin extends Plugin {
|
|
223
|
+
name = 'my-plugin';
|
|
224
|
+
|
|
225
|
+
tools = {
|
|
226
|
+
my_tool: {
|
|
227
|
+
description: 'Tool description',
|
|
228
|
+
inputSchema: z.object({
|
|
229
|
+
param: z.string().describe('Parameter description')
|
|
230
|
+
}),
|
|
231
|
+
execute: async (args) => ({ success: true })
|
|
232
|
+
}
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
### Legacy: `framework.registerTool()` in `install()`
|
|
163
238
|
|
|
164
239
|
```javascript
|
|
165
240
|
install(framework) {
|
|
166
|
-
const { z } = require('zod')
|
|
167
241
|
framework.registerTool({
|
|
168
242
|
name: 'my_tool',
|
|
169
|
-
description: '
|
|
170
|
-
inputSchema: z.object({
|
|
171
|
-
param: z.string().describe('
|
|
243
|
+
description: 'Tool description',
|
|
244
|
+
inputSchema: framework.z.object({
|
|
245
|
+
param: framework.z.string().describe('Parameter description')
|
|
172
246
|
}),
|
|
173
|
-
execute: async (args
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
247
|
+
execute: async (args) => ({ success: true })
|
|
248
|
+
});
|
|
249
|
+
return this;
|
|
250
|
+
}
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
## Extension Registration
|
|
254
|
+
|
|
255
|
+
```javascript
|
|
256
|
+
onStart(framework) {
|
|
257
|
+
this.extension.register({
|
|
258
|
+
name: 'my_ext_tool',
|
|
259
|
+
description: 'Extension tool',
|
|
260
|
+
inputSchema: framework.z.object({
|
|
261
|
+
param: framework.z.string()
|
|
262
|
+
}),
|
|
263
|
+
execute: async (args) => ({ success: true })
|
|
264
|
+
});
|
|
178
265
|
}
|
|
179
266
|
```
|
|
180
267
|
|
|
268
|
+
## Tool/Extension Operations
|
|
269
|
+
|
|
270
|
+
```javascript
|
|
271
|
+
// Register
|
|
272
|
+
this.tool.register({ name: 'xxx', ... });
|
|
273
|
+
this.extension.register({ name: 'xxx', ... });
|
|
274
|
+
|
|
275
|
+
// Remove
|
|
276
|
+
this.tool.remove('xxx');
|
|
277
|
+
this.extension.remove('xxx');
|
|
278
|
+
|
|
279
|
+
// Execute
|
|
280
|
+
const r1 = await this.tool.execute('any-tool', { arg: 'value' }); // Execute any registered tool
|
|
281
|
+
const r2 = await this.extension.execute('xxx', { arg: 'value' }); // Execute current plugin's extension
|
|
282
|
+
const r3 = await this.extension.execute('plugin-name', 'xxx', { arg: 'value' }); // Execute specified plugin's extension
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
## Workflow Operations
|
|
286
|
+
|
|
287
|
+
```javascript
|
|
288
|
+
// Register workflow
|
|
289
|
+
this.workflow.register('my-workflow', {
|
|
290
|
+
name: 'my-workflow',
|
|
291
|
+
description: 'My workflow',
|
|
292
|
+
steps: [
|
|
293
|
+
{ type: 'tool', tool: 'hello', args: {} }
|
|
294
|
+
]
|
|
295
|
+
});
|
|
296
|
+
|
|
297
|
+
// Execute workflow
|
|
298
|
+
const result = await this.workflow.execute('my-workflow', { input: 'value' });
|
|
299
|
+
|
|
300
|
+
// Remove workflow
|
|
301
|
+
this.workflow.remove('my-workflow');
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
## Agent Operations
|
|
305
|
+
|
|
306
|
+
```javascript
|
|
307
|
+
// Register sub-agent
|
|
308
|
+
this.agent.register({
|
|
309
|
+
name: 'my-agent',
|
|
310
|
+
role: 'Assistant',
|
|
311
|
+
goal: 'Description',
|
|
312
|
+
tools: {},
|
|
313
|
+
parentTools: ['read_file', 'write_file']
|
|
314
|
+
});
|
|
315
|
+
|
|
316
|
+
// Get sub-agent
|
|
317
|
+
const agent = this.agent.get('my-agent');
|
|
318
|
+
|
|
319
|
+
// Remove sub-agent
|
|
320
|
+
this.agent.remove('my-agent');
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
## Prompt Operations
|
|
324
|
+
|
|
325
|
+
```javascript
|
|
326
|
+
// Register prompt
|
|
327
|
+
this.prompt.register('my-prompt', () => 'Prompt content', {
|
|
328
|
+
scope: 'global',
|
|
329
|
+
priority: 50
|
|
330
|
+
});
|
|
331
|
+
|
|
332
|
+
// Remove prompt
|
|
333
|
+
this.prompt.remove('my-prompt');
|
|
334
|
+
```
|
|
335
|
+
|
|
181
336
|
## Framework Object
|
|
182
337
|
|
|
183
338
|
The framework object provides:
|
|
184
339
|
|
|
185
|
-
| Method
|
|
186
|
-
|
|
187
|
-
| `framework.registerTool(tool)`
|
|
188
|
-
| `framework.getTools()`
|
|
189
|
-
| `framework.executeTool(name, args)` | Execute tool
|
|
190
|
-
| `framework.callTool(name, args)`
|
|
191
|
-
| `framework.createAgent(config)`
|
|
192
|
-
| `framework.reloadPlugin(name)`
|
|
193
|
-
| `framework.reloadAllPlugins()`
|
|
340
|
+
| Method | Description |
|
|
341
|
+
|--------|-------------|
|
|
342
|
+
| `framework.registerTool(tool)` | Register tool (legacy) |
|
|
343
|
+
| `framework.getTools()` | Get all tools |
|
|
344
|
+
| `framework.executeTool(name, args)` | Execute tool |
|
|
345
|
+
| `framework.callTool(name, args)` | Call tool (for installing deps) |
|
|
346
|
+
| `framework.createAgent(config)` | Create Agent |
|
|
347
|
+
| `framework.reloadPlugin(name)` | Reload single plugin |
|
|
348
|
+
| `framework.reloadAllPlugins()` | Reload all plugins |
|
|
194
349
|
|
|
195
350
|
## Dependency Management
|
|
196
351
|
|
|
@@ -229,8 +384,6 @@ await framework.callTool('install', {
|
|
|
229
384
|
|
|
230
385
|
## Common Mistakes
|
|
231
386
|
|
|
232
|
-
1. ❌
|
|
233
|
-
2. ❌ Forgetting `
|
|
234
|
-
3. ❌ Using
|
|
235
|
-
4. ❌ Registering tools outside `install()`
|
|
236
|
-
5. ❌ Using same name for folder and file - folder takes priority, file will be ignored
|
|
387
|
+
1. ❌ Using `parameters` instead of `inputSchema`
|
|
388
|
+
2. ❌ Forgetting `framework.` prefix when using `framework.z.object()`
|
|
389
|
+
3. ❌ Using same name for folder and file - folder takes priority, file will be ignored
|
package/skills/foliko/SKILL.md
CHANGED
|
@@ -341,28 +341,69 @@ module.exports = MyPlugin;
|
|
|
341
341
|
|
|
342
342
|
## 生命周期
|
|
343
343
|
|
|
344
|
-
| 方法
|
|
345
|
-
|
|
346
|
-
| `install(framework)`
|
|
347
|
-
| `
|
|
348
|
-
| `
|
|
349
|
-
| `
|
|
344
|
+
| 方法 | 调用时机 | 必须实现 | 说明 |
|
|
345
|
+
|------|----------|----------|------|
|
|
346
|
+
| `install(framework)` | 插件安装时 | ✅ | 初始化,获取 framework |
|
|
347
|
+
| `onStart(framework)` | start/enable/reload 时 | 推荐 | 注册工具、扩展、子代理 |
|
|
348
|
+
| `onStop()` | disable 时 | 可选 | 清理资源 |
|
|
349
|
+
| `reload(framework)` | 热重载时 | 可选 | prompts 自动清理/注册 |
|
|
350
|
+
| `uninstall(framework)` | 卸载时 | 推荐 | 清理资源 |
|
|
351
|
+
|
|
352
|
+
### onStart / onStop(推荐方式)
|
|
353
|
+
|
|
354
|
+
**推荐使用 `onStart` 注册工具和扩展**,基类自动处理生命周期:
|
|
355
|
+
|
|
356
|
+
```javascript
|
|
357
|
+
class MyPlugin extends Plugin {
|
|
358
|
+
name = 'my-plugin';
|
|
359
|
+
version = '1.0.0';
|
|
360
|
+
description = '我的工具插件';
|
|
361
|
+
|
|
362
|
+
onStart(framework) {
|
|
363
|
+
// 注册 AI SDK 工具(直接调用)
|
|
364
|
+
this.tool.register({
|
|
365
|
+
name: 'hello',
|
|
366
|
+
description: '打招呼',
|
|
367
|
+
inputSchema: framework.z.object({
|
|
368
|
+
name: framework.z.string().describe('姓名')
|
|
369
|
+
}),
|
|
370
|
+
execute: async (args) => ({ message: `Hello, ${args.name}!` }),
|
|
371
|
+
});
|
|
372
|
+
|
|
373
|
+
// 注册扩展工具(通过 ext_call 调用)
|
|
374
|
+
this.extension.register({
|
|
375
|
+
name: 'greet',
|
|
376
|
+
description: '打招呼扩展',
|
|
377
|
+
inputSchema: framework.z.object({
|
|
378
|
+
name: framework.z.string()
|
|
379
|
+
}),
|
|
380
|
+
execute: async (args) => ({ message: `Hi, ${args.name}!` }),
|
|
381
|
+
});
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
```
|
|
385
|
+
|
|
386
|
+
### 生命周期自动管理
|
|
387
|
+
|
|
388
|
+
| 操作 | 效果 |
|
|
389
|
+
|------|------|
|
|
390
|
+
| `disable` | 自动移除工具/扩展(保留注册记录) |
|
|
391
|
+
| `enable` | 自动重新注册工具/扩展 |
|
|
392
|
+
| `reload` | 移除后重新注册 |
|
|
393
|
+
| `uninstall` | 移除并清空注册记录 |
|
|
350
394
|
|
|
351
395
|
---
|
|
352
396
|
|
|
353
397
|
## 注册工具
|
|
354
398
|
|
|
355
|
-
###
|
|
399
|
+
### 方式1:`this.tools = {}`(ExtensionExecutor 自动扫描)
|
|
356
400
|
|
|
357
|
-
插件将工具定义在 `this.tools = {}` 中,ExtensionExecutor
|
|
401
|
+
插件将工具定义在 `this.tools = {}` 中,ExtensionExecutor 会自动扫描并注册:
|
|
358
402
|
|
|
359
403
|
```javascript
|
|
360
404
|
class MyPlugin extends Plugin {
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
this.name = 'my-plugin';
|
|
364
|
-
this.description = '我的工具插件';
|
|
365
|
-
}
|
|
405
|
+
name = 'my-plugin';
|
|
406
|
+
description = '我的工具插件';
|
|
366
407
|
|
|
367
408
|
tools = {
|
|
368
409
|
my_tool: {
|
|
@@ -378,37 +419,125 @@ class MyPlugin extends Plugin {
|
|
|
378
419
|
}
|
|
379
420
|
```
|
|
380
421
|
|
|
381
|
-
### 方式2
|
|
422
|
+
### 方式2:`this.tool.register()`(推荐)
|
|
382
423
|
|
|
383
|
-
|
|
424
|
+
在 `onStart` 中使用,支持完整的生命周期管理:
|
|
384
425
|
|
|
385
426
|
```javascript
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
// 方式1:分开传 name 和 def
|
|
390
|
-
this.registerTool('my_tool', {
|
|
427
|
+
onStart(framework) {
|
|
428
|
+
this.tool.register({
|
|
429
|
+
name: 'my_tool',
|
|
391
430
|
description: '我的工具',
|
|
392
|
-
inputSchema: z.object({
|
|
393
|
-
param: z.string().describe('参数描述')
|
|
431
|
+
inputSchema: framework.z.object({
|
|
432
|
+
param: framework.z.string().describe('参数描述')
|
|
394
433
|
}),
|
|
395
434
|
execute: async (args) => {
|
|
396
435
|
return { success: true, result: args.param };
|
|
397
436
|
}
|
|
398
437
|
});
|
|
438
|
+
}
|
|
439
|
+
```
|
|
399
440
|
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
441
|
+
### 方式3:`this.registerTool()`(旧方式)
|
|
442
|
+
|
|
443
|
+
```javascript
|
|
444
|
+
install(framework) {
|
|
445
|
+
this.registerTool('my_tool', {
|
|
446
|
+
description: '我的工具',
|
|
447
|
+
inputSchema: framework.z.object({
|
|
448
|
+
param: framework.z.string().describe('参数描述')
|
|
449
|
+
}),
|
|
405
450
|
execute: async (args) => ({ success: true })
|
|
406
451
|
});
|
|
407
|
-
|
|
408
452
|
return this;
|
|
409
453
|
}
|
|
410
454
|
```
|
|
411
455
|
|
|
456
|
+
### 注册扩展工具
|
|
457
|
+
|
|
458
|
+
```javascript
|
|
459
|
+
onStart(framework) {
|
|
460
|
+
this.extension.register({
|
|
461
|
+
name: 'my_ext_tool',
|
|
462
|
+
description: '扩展工具',
|
|
463
|
+
inputSchema: framework.z.object({
|
|
464
|
+
param: framework.z.string()
|
|
465
|
+
}),
|
|
466
|
+
execute: async (args) => ({ success: true })
|
|
467
|
+
});
|
|
468
|
+
}
|
|
469
|
+
```
|
|
470
|
+
|
|
471
|
+
---
|
|
472
|
+
|
|
473
|
+
## 工具/扩展操作
|
|
474
|
+
|
|
475
|
+
```javascript
|
|
476
|
+
// 注册
|
|
477
|
+
this.tool.register({ name: 'xxx', ... });
|
|
478
|
+
this.extension.register({ name: 'xxx', ... });
|
|
479
|
+
|
|
480
|
+
// 移除
|
|
481
|
+
this.tool.remove('xxx');
|
|
482
|
+
this.extension.remove('xxx');
|
|
483
|
+
|
|
484
|
+
// 执行
|
|
485
|
+
const r1 = await this.tool.execute('any-tool', { arg: 'value' }); // 执行任何已注册工具
|
|
486
|
+
const r2 = await this.extension.execute('xxx', { arg: 'value' }); // 执行当前插件的扩展
|
|
487
|
+
const r3 = await this.extension.execute('plugin-name', 'xxx', { arg: 'value' }); // 执行指定插件的扩展
|
|
488
|
+
```
|
|
489
|
+
|
|
490
|
+
## 工作流操作
|
|
491
|
+
|
|
492
|
+
```javascript
|
|
493
|
+
// 注册工作流
|
|
494
|
+
this.workflow.register('my-workflow', {
|
|
495
|
+
name: 'my-workflow',
|
|
496
|
+
description: '我的工作流',
|
|
497
|
+
steps: [
|
|
498
|
+
{ type: 'tool', tool: 'hello', args: {} }
|
|
499
|
+
]
|
|
500
|
+
});
|
|
501
|
+
|
|
502
|
+
// 执行工作流
|
|
503
|
+
const result = await this.workflow.execute('my-workflow', { input: 'value' });
|
|
504
|
+
|
|
505
|
+
// 移除工作流
|
|
506
|
+
this.workflow.remove('my-workflow');
|
|
507
|
+
```
|
|
508
|
+
|
|
509
|
+
## 子代理操作
|
|
510
|
+
|
|
511
|
+
```javascript
|
|
512
|
+
// 注册子代理
|
|
513
|
+
this.agent.register({
|
|
514
|
+
name: 'my-agent',
|
|
515
|
+
role: '助手',
|
|
516
|
+
goal: '描述',
|
|
517
|
+
tools: {},
|
|
518
|
+
parentTools: ['read_file', 'write_file']
|
|
519
|
+
});
|
|
520
|
+
|
|
521
|
+
// 获取子代理
|
|
522
|
+
const agent = this.agent.get('my-agent');
|
|
523
|
+
|
|
524
|
+
// 移除子代理
|
|
525
|
+
this.agent.remove('my-agent');
|
|
526
|
+
```
|
|
527
|
+
|
|
528
|
+
## Prompt 操作
|
|
529
|
+
|
|
530
|
+
```javascript
|
|
531
|
+
// 注册 prompt
|
|
532
|
+
this.prompt.register('my-prompt', () => 'Prompt content', {
|
|
533
|
+
scope: 'global',
|
|
534
|
+
priority: 50
|
|
535
|
+
});
|
|
536
|
+
|
|
537
|
+
// 移除 prompt
|
|
538
|
+
this.prompt.remove('my-prompt');
|
|
539
|
+
```
|
|
540
|
+
|
|
412
541
|
---
|
|
413
542
|
|
|
414
543
|
## 核心规则
|