foliko 1.0.60 → 1.0.62
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 +142 -141
- package/.env.example +8 -4
- package/README.md +127 -8
- package/SPEC.md +83 -30
- package/package.json +1 -1
- package/plugins/ambient-agent-plugin.js +228 -188
- package/plugins/email.js +43 -36
- package/plugins/feishu-plugin.js +48 -0
- package/plugins/scheduler-plugin.js +181 -29
- package/plugins/weixin-plugin.js +54 -0
package/SPEC.md
CHANGED
|
@@ -303,34 +303,41 @@ const response = await agent.chat('你好')
|
|
|
303
303
|
'plugin:disabled' // 插件禁用
|
|
304
304
|
'agent:message' // Agent消息
|
|
305
305
|
'agent:tool-call' // Agent调用工具
|
|
306
|
-
'agent:tool-result'
|
|
307
|
-
'
|
|
308
|
-
'scheduler:
|
|
309
|
-
'scheduler:task_completed' // 定时任务完成
|
|
310
|
-
'scheduler:task_failed' // 定时任务失败
|
|
311
|
-
'scheduler:reminder' // 定时提醒触发
|
|
306
|
+
'agent:tool-result' // 工具执行结果
|
|
307
|
+
'notification' // 统一通知事件(推送用户)
|
|
308
|
+
'scheduler:reminder' // 定时提醒触发(业务事件)
|
|
312
309
|
'think:thought_completed' // 思考完成
|
|
313
|
-
'
|
|
310
|
+
'email:received' // 收到新邮件
|
|
311
|
+
'webhook:received' // 收到Webhook请求
|
|
314
312
|
```
|
|
315
313
|
|
|
316
|
-
###
|
|
314
|
+
### 通知事件 (notification)
|
|
317
315
|
|
|
318
|
-
|
|
316
|
+
统一的通知事件,用于向用户发送通知。消息插件(微信、飞书、Telegram)监听此事件并推送给用户。
|
|
319
317
|
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
318
|
+
```javascript
|
|
319
|
+
{
|
|
320
|
+
title: '目标完成', // 通知标题
|
|
321
|
+
message: '目标 "xxx" 已完成', // 通知内容
|
|
322
|
+
source: 'ambient', // 来源:'scheduler' | 'ambient' | 'email' | 'webhook'
|
|
323
|
+
level: 'success', // 级别:'info' | 'warning' | 'success' | 'error'
|
|
324
|
+
sessionId: 'weixin_xxx', // 会话ID(可选)
|
|
325
|
+
timestamp: new Date() // 时间戳
|
|
326
|
+
}
|
|
327
|
+
```
|
|
327
328
|
|
|
328
|
-
|
|
329
|
+
### 业务事件
|
|
330
|
+
|
|
331
|
+
业务事件用于触发 Ambient Agent 的目标,不直接通知用户。
|
|
329
332
|
|
|
330
333
|
| 事件 | 数据 | 说明 |
|
|
331
334
|
|------|------|------|
|
|
332
|
-
| `
|
|
333
|
-
| `think:
|
|
335
|
+
| `scheduler:reminder` | `{ taskId, taskName, message, sessionId, llm }` | 定时提醒触发时 |
|
|
336
|
+
| `think:thought_completed` | `thought` | 思考完成时 |
|
|
337
|
+
| `email:received` | `email` | 收到新邮件时 |
|
|
338
|
+
| `webhook:received` | `{ webhook, data, response, sessionId }` | 收到Webhook请求时 |
|
|
339
|
+
| `tool:result` | `{ name, args, result }` | 工具执行结果 |
|
|
340
|
+
| `agent:message` | `{ content }` | Agent发送消息时 |
|
|
334
341
|
|
|
335
342
|
## 六、热重载机制
|
|
336
343
|
|
|
@@ -463,18 +470,64 @@ agent.chat('请重载 my-plugin 插件')
|
|
|
463
470
|
- 简单提醒(喝水、吃饭)→ 直接显示
|
|
464
471
|
- 查询/分析任务(查看列表、分析数据)→ 启用 LLM
|
|
465
472
|
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
473
|
+
**持久化**:
|
|
474
|
+
- 任务自动保存到 `.agent/data/scheduler/tasks.json`
|
|
475
|
+
- 重启后自动恢复 Cron 任务和未执行的一次性任务
|
|
476
|
+
|
|
477
|
+
**通知**:
|
|
478
|
+
- 任务完成/失败/取消时发送 `notification` 事件
|
|
479
|
+
- 消息插件(微信、飞书)自动推送给用户
|
|
480
|
+
|
|
481
|
+
## 八、Ambient Agent 插件
|
|
482
|
+
|
|
483
|
+
### 8.1 Ambient Agent (plugins/ambient-agent-plugin.js)
|
|
484
|
+
|
|
485
|
+
**功能**:
|
|
486
|
+
- 持续后台运行的智能代理
|
|
487
|
+
- 监控事件并主动执行操作
|
|
488
|
+
- 目标(Goal)管理系统
|
|
489
|
+
- 持久化记忆
|
|
490
|
+
|
|
491
|
+
**支持的事件**:
|
|
492
|
+
- `tool:result` - 工具执行结果
|
|
493
|
+
- `scheduler:reminder` - 定时提醒
|
|
494
|
+
- `agent:message` - 代理消息
|
|
495
|
+
- `think:thought_completed` - 思考完成
|
|
496
|
+
- `email:received` - 收到邮件
|
|
497
|
+
- `webhook:received` - 收到Webhook
|
|
498
|
+
|
|
499
|
+
**工具**:
|
|
500
|
+
- `ambient_goals` - 管理目标(列出/创建/更新/删除/激活)
|
|
501
|
+
- `ambient_status` - 获取状态
|
|
502
|
+
- `ambient_think` - 触发主动思考
|
|
503
|
+
- `ambient_remember` - 存储/检索记忆
|
|
504
|
+
- `ambient_control` - 控制循环(暂停/恢复/调整)
|
|
505
|
+
|
|
506
|
+
**目标结构**:
|
|
507
|
+
```javascript
|
|
508
|
+
{
|
|
509
|
+
title: '目标标题',
|
|
510
|
+
description: '目标描述',
|
|
511
|
+
priority: 5, // 1-10,数值越高越重要
|
|
512
|
+
actions: [ // 操作列表
|
|
513
|
+
{ type: 'tool', name: 'tool_name', args: {...} },
|
|
514
|
+
{ type: 'message', content: '消息内容' },
|
|
515
|
+
{ type: 'think', mode: 'reflect', topic: '思考主题' }
|
|
516
|
+
],
|
|
517
|
+
conditions: { // 激活条件(可选)
|
|
518
|
+
events: ['email:received'], // 监听的事件类型
|
|
519
|
+
toolNames: ['email_read'] // 过滤的工具名称
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
```
|
|
523
|
+
|
|
524
|
+
**通知**:
|
|
525
|
+
- 目标完成时发送 `notification` 事件(level: 'success')
|
|
526
|
+
- 目标失败时发送 `notification` 事件(level: 'error')
|
|
474
527
|
|
|
475
|
-
##
|
|
528
|
+
## 九、使用示例
|
|
476
529
|
|
|
477
|
-
###
|
|
530
|
+
### 9.1 基础用法
|
|
478
531
|
|
|
479
532
|
```javascript
|
|
480
533
|
const { Framework } = require('./src')
|
|
@@ -505,7 +558,7 @@ const response = await agent.chat('你好')
|
|
|
505
558
|
console.log(response)
|
|
506
559
|
```
|
|
507
560
|
|
|
508
|
-
###
|
|
561
|
+
### 9.2 热重载
|
|
509
562
|
|
|
510
563
|
```javascript
|
|
511
564
|
// 重载单个插件
|