diff --git a/.changeset/wild-books-do.md b/.changeset/wild-books-do.md
new file mode 100644
index 000000000..43fd911be
--- /dev/null
+++ b/.changeset/wild-books-do.md
@@ -0,0 +1,5 @@
+---
+"koishi-plugin-yesimbot-extension-sticker-manager": patch
+---
+
+fix authority
diff --git a/.editorconfig b/.editorconfig
index 7eadd8401..27f7f30a4 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -15,10 +15,13 @@ trim_trailing_whitespace = true
end_of_line = lf
indent_style = space
indent_size = 4
-max_line_length = 140
+max_line_length = 120
[*.json]
indent_size = 2
[*.yml]
+indent_size = 2
+
+[*.vue]
indent_size = 2
\ No newline at end of file
diff --git a/.gitignore b/.gitignore
index 358255d16..b73dc8fbf 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,6 +1,7 @@
-lib
-dist
-external
+lib/
+dist/
+external/
+conversation/
node_modules
npm-debug.log
@@ -10,20 +11,13 @@ tsconfig.tsbuildinfo
tsconfig.temp.json
package-lock.json
yarn.lock
+bun.lock
*.tgz
.turbo
-.eslintcache
-.DS_Store
.idea
.vscode
-*.suo
-*.ntvs*
-*.njsproj
-*.sln
-bun.lock
-*.mdt
coverage
data/logs
data/cache
@@ -32,3 +26,7 @@ data/queue.json
data/emojis.json
__snapshots__
+
+.github/instructions
+.github/prompts
+.github/copilot-instructions.md
diff --git a/.husky/commit-msg b/.husky/commit-msg
deleted file mode 100644
index 3365136a0..000000000
--- a/.husky/commit-msg
+++ /dev/null
@@ -1 +0,0 @@
-bunx commitlint --edit "$1"
\ No newline at end of file
diff --git a/.prettierrc b/.prettierrc
index d30f0cbc8..931ed1b11 100644
--- a/.prettierrc
+++ b/.prettierrc
@@ -4,5 +4,5 @@
"semi": true,
"singleQuote": false,
"arrowParens": "always",
- "trailingComma": "es5"
+ "trailingComma": "all"
}
\ No newline at end of file
diff --git a/README.md b/README.md
index 8d171a615..66064fee2 100644
--- a/README.md
+++ b/README.md
@@ -1,90 +1,251 @@
# YesImBot / Athena
-

+

-[](https://www.npmjs.com/package/koishi-plugin-yesimbot) [](http://choosealicense.com/licenses/mit/)   [](https://deepwiki.com/MiaowFISH/YesImBot)
+[](https://www.npmjs.com/package/koishi-plugin-yesimbot)
+[](http://choosealicense.com/licenses/mit/)
+
+
+[](https://deepwiki.com/MiaowFISH/YesImBot)
-**✨ 机器壳,人类心。✨**
+**✨ 机器壳,人类心 ✨**
_让 AI 大模型自然融入群聊的智能机器人系统_
+[快速开始](#-快速开始) • [核心特性](#-核心特性) • [项目结构](#-项目结构) • [文档](#-文档) • [社区](#-社区支持)
+
+---
+
## 📖 项目简介
-YesImBot (Athena) 是一个基于 [Koishi](https://koishi.chat/zh-CN/) 的智能聊天机器人系统,旨在让人工智能大模型能够自然地参与到群聊讨论中,模拟真实的人类互动体验。通过先进的意愿值系统、记忆管理和工具扩展,为用户提供更加人性化的 AI 交流体验。
+YesImBot (Athena) 是一个基于 [Koishi](https://koishi.chat/zh-CN/) 的智能聊天机器人插件,旨在让人工智能大模型能够自然地参与到群聊讨论中,模拟真实的人类互动体验。通过先进的意愿值系统、智能记忆管理和可扩展的工具框架,为用户提供更加人性化、更有温度的 AI 交流体验。
+
+不同于传统的命令式 AI 助手,Athena 的设计理念是让机器人像真正的群友一样参与对话——它会观察群聊氛围、记住对话内容、选择合适的时机发言,而不是被动地等待指令。
## 🎯 核心特性
-- **🧠 智能对话管理**:基于意愿值系统控制 Bot 的主动发言频率,模拟真实人类的交流模式
-- **💾 记忆系统**:通过 Memory 和 Scenario 管理上下文,使机器人能够记住和理解对话历史
-- **🔗 多适配器支持**:支持多种 LLM API(OpenAI、Cloudflare、Ollama 等),实现负载均衡和故障转移
-- **🛠️ 可扩展的工具系统**:基于工具调用框架,允许机器人执行各种操作
-- **🎭 自定义人格**:轻松定制 Bot 的名字、性格、响应模式等
-- **📱 Web 管理界面**:提供直观的 Web 界面进行配置和管理
-- **🔌 MCP 扩展支持**:支持 Model Context Protocol 扩展,实现更强大的功能集成
+- **🧠 智能意愿系统** - 基于意愿值算法控制 Bot 的主动发言频率,模拟真实人类的交流节奏。Bot 会根据群聊活跃度、@消息、话题相关性等因素动态调整参与意愿,避免过度活跃或过于沉默
+
+- **💾 上下文感知记忆** - 通过 Memory 和 Scenario 系统管理对话上下文,机器人能够记住历史对话、理解话题延续,并在合适的时机回忆起相关内容。支持短期记忆(会话内)和长期记忆(跨会话)
+
+- **🔗 多模型适配器** - 支持多种 LLM API(OpenAI、Cloudflare Workers AI、Ollama 等),内置负载均衡和故障转移机制,确保服务稳定性。可根据任务类型动态选择最合适的模型
+
+- **🛠️ 可扩展工具系统** - 基于工具调用(Function Calling)框架,允许机器人执行各种操作:发送消息、管理记忆、搜索信息、调用外部 API 等。开发者可以轻松添加自定义工具
+
+- **🌍 世界状态管理** - 采用 WorldState 上下文工程设计,将群聊背景、用户信息、时间、环境等信息提炼为结构化的"世界状态",为 AI 提供完整的场景认知
+
+- **🎭 人格化定制** - 支持自定义 Bot 的名字、性格特征、说话风格、兴趣爱好等。通过 Persona 配置和提示词模板,打造独一无二的虚拟角色
+
+- **🔌 插件生态集成** - 充分利用 Koishi 的插件机制,与现有生态无缝集成。支持 Model Context Protocol (MCP) 扩展,可接入更多外部服务和能力
+
+- **📊 智能调度系统** - 内置心跳处理器和事件调度机制,支持定时任务、延迟响应、消息合并等高级功能,让 Bot 的行为更加自然流畅
+
+## 🏗️ 项目架构
+
+Athena 采用模块化设计,核心功能由多个服务层协作完成:
+
+```
+packages/
+├── core/ # 核心插件
+│ ├── agent/ # 智能体系统(意愿值、调度)
+│ ├── services/
+│ │ ├── memory/ # 记忆管理服务
+│ │ ├── model/ # LLM 模型适配服务
+│ │ ├── prompt/ # 提示词管理服务
+│ │ ├── plugin/ # 工具/插件系统
+│ │ ├── horizon/ # 策略与场景管理
+│ │ ├── worldstate/ # 世界状态服务
+│ │ └── ...
+│ └── resources/ # 资源文件(提示词模板等)
+├── shared-model/ # 共享模型工具库
+└── plugins/
+ └── provider-openai/ # OpenAI 提供者插件
+```
+
+### 架构特点
+
+- **Service-Oriented** - 各功能模块以服务形式独立,通过依赖注入协作
+- **Middleware-Based** - 可在消息处理流程的各个阶段插入自定义逻辑
+- **Event-Driven** - 基于事件驱动架构,支持异步处理和灵活的消息流转
+- **Highly Extensible** - 清晰的接口设计,便于二次开发和功能扩展
## 📦 项目结构
-本项目采用 monorepo 架构,包含以下主要包:
+本项目采用 Monorepo 架构管理,使用 Turborepo 和 Yarn Workspaces:
+
+| 包 | 描述 | NPM 包名 | 状态 |
+| --------------------- | ------------------------------- | ------------------------------- | ---- |
+| `packages/core` | 核心机器人插件 | `koishi-plugin-yesimbot` | ✅ |
+| `packages/shared-model` | 共享的模型工具和类型定义 | `@yesimbot/shared-model` | ✅ |
+| `plugins/provider-openai` | OpenAI 兼容的模型提供者 | `koishi-plugin-yesimbot-provider-openai` | ✅ |
+
+## 🚀 快速开始
+
+### 前置要求
+
+- [Node.js](https://nodejs.org/) >= 18.17.0
+- [Koishi](https://koishi.chat/zh-CN/) >= 4.18.7
+- 一个可用的 LLM API(如 OpenAI API、Ollama 等)
+
+### 安装
+
+在 Koishi 控制台的插件市场中搜索 `yesimbot`,点击安装即可。
+
+或者使用命令行安装:
+
+```bash
+npm install koishi-plugin-yesimbot
+# 或
+yarn add koishi-plugin-yesimbot
+```
+### 基础配置
+
+安装后,在 Koishi 配置文件中添加以下配置:
+
+```yaml
+plugins:
+ yesimbot:
+ # 记忆槽位配置
+ MemorySlot:
+ SlotContains:
+ - 123456789 # 群号
+ SlotSize: 20
+ AtReactPossibility: 0.5
+ IncreaseWillingnessOn:
+ Message: 15
+ At: 80
+ Threshold: 80
+ MessageWaitTime: 2000
+
+ # LLM API 配置
+ API:
+ APIList:
+ - APIType: OpenAI
+ BaseURL: https://api.openai.com/v1
+ APIKey: sk-your-api-key-here
+ AIModel: gpt-4o-mini
+
+ # Bot 设定
+ Bot:
+ WordsPerSecond: 20
```
-YesImBot/
-├── packages/
-│ ├── core/ # 🎯 核心插件包
-│ ├── mcp/ # 🔌 MCP扩展包
-│ └── webui/ # 📱 Web管理界面
-├── package.json # 项目根配置
-└── README.md # 项目说明
+
+详细配置说明请参考 [packages/core/README.md](packages/core/README.md)。
+
+### 快速测试
+
+配置完成后,将 Bot 添加到群聊中。发送消息并 @ 机器人,它应该会根据配置的意愿值系统做出响应。
+
+> [!TIP]
+> 如果想要 Bot 更活跃,可以降低 `Threshold` 值;如果想让它更安静,则提高此值。开启 `Debug.TestMode` 可以让每条消息都触发回复,便于测试。
+
+## 📋 文档
+
+### 在线文档
+
+访问官方文档站了解更多:[https://docs.yesimbot.chat/](https://docs.yesimbot.chat/)
+
+### 仓库文档
+
+| 文档 | 描述 |
+| ------------------------------------------ | ---------------------------------------- |
+| [packages/core/README.md](packages/core/README.md) | 核心插件详细使用说明和配置指南 |
+| [conversation/](conversation/) | 设计文档和开发历程记录 |
+| [conversation/docs/](conversation/docs/) | 架构设计文档(记忆系统、WorldState 等) |
+
+### 关键概念
+
+- **意愿值系统(Willingness)** - 控制 Bot 主动发言的核心机制
+- **记忆槽位(Memory Slot)** - 管理不同会话的上下文隔离和共享
+- **世界状态(WorldState)** - 结构化的场景信息,为 AI 提供完整的上下文认知
+- **工具调用(Tool Calling)** - 让 AI 能够执行具体操作的框架
+- **策略系统(Strategy)** - 根据不同场景选择最合适的提示词策略
+
+## 🛠️ 开发
+
+### 环境设置
+
+```bash
+# 克隆仓库
+git clone https://github.com/HydroGest/YesImBot.git
+cd YesImBot
+
+# 安装依赖
+yarn install
+
+# 构建所有包
+yarn build
+
+# 开发模式(监听文件变化)
+yarn dev
```
-### 📦 包说明
+### 项目脚本
+
+- `yarn build` - 构建所有包
+- `yarn dev` - 开发模式
+- `yarn lint` - 运行代码检查
+- `yarn test` - 运行测试
+- `yarn clean` - 清理构建产物
-| 包名 | 描述 | NPM 包名 |
-| --------- | --------------------------- | -------------------------------------- |
-| **core** | 核心聊天机器人功能 | `koishi-plugin-yesimbot` |
-| **mcp** | Model Context Protocol 扩展 | `koishi-plugin-yesimbot-extension-mcp` |
-| **webui** | Web 管理界面 | _开发中_ |
+### 扩展开发
-## 📋 文档导航
+Athena 提供了丰富的扩展点,开发者可以:
-除了文档站([https://docs.yesimbot.chat/](https://docs.yesimbot.chat/))的文档外,仓库内还有内置的文档可供参考:
+1. **添加自定义工具** - 实现新的工具函数,让 AI 能够执行更多操作
+2. **扩展服务层** - 增加新的服务模块,如外部 API 集成、数据分析等
+3. **定制提示词策略** - 为特定场景设计专门的提示词模板
+4. **集成 MCP 协议** - 接入支持 Model Context Protocol 的外部服务
-| 文档类型 | 文件路径 | 描述 |
-| --------------- | -------------------------------------------------------------------------------- | ----------------------------------- |
-| 🎯 **核心功能** | [packages/core/README.md](packages/core/README.md) | 核心插件的详细使用说明和配置指南 |
-| 🏗️ **架构设计** | [packages/core/DESIGN.md](packages/core/DESIGN.md) | 系统架构、中间件设计和核心组件说明 |
-| 🔧 **扩展开发** | [packages/core/src/extensions/README.md](packages/core/src/extensions/README.md) | 扩展系统开发指南和 API 文档 |
-| 🔌 **MCP 扩展** | [packages/mcp/README.md](packages/mcp/README.md) | Model Context Protocol 扩展使用说明 |
-| 📱 **Web 界面** | [packages/webui/README.md](packages/webui/README.md) | Web 管理界面使用和开发文档 |
+详见开发文档(敬请期待)。
## 🤝 贡献
-我们欢迎所有形式的贡献!
+我们欢迎各种形式的贡献!无论是报告 Bug、提出新功能建议、改进文档,还是提交代码,都对项目的发展有重要意义。
### 贡献者
-感谢所有贡献者们,是你们让 Athena 成为可能。
+感谢所有为 Athena 做出贡献的开发者们:

-## 💬 社区支持
+### 如何贡献
-- 🐛 **问题反馈**: [GitHub Issues](https://github.com/HydroGest/YesImBot/issues)
-- 💬 **QQ 交流群**: [857518324](http://qm.qq.com/cgi-bin/qm/qr?_wv=1027&k=k3O5_1kNFJMERGxBOj1ci43jHvLvfru9&authKey=TkOxmhIa6kEQxULtJ0oMVU9FxoY2XNiA%2B7bQ4K%2FNx5%2F8C8ToakYZeDnQjL%2B31Rx%2B&noverify=0&group_code=857518324)
+1. Fork 本仓库
+2. 创建你的特性分支 (`git checkout -b feature/AmazingFeature`)
+3. 提交你的更改 (`git commit -m 'Add some AmazingFeature'`)
+4. 推送到分支 (`git push origin feature/AmazingFeature`)
+5. 开启一个 Pull Request
-## 📄 许可证
+## 💬 社区支持
+
+### 获取帮助
-本项目采用 MIT 许可证 - 查看 [LICENSE](LICENSE) 文件了解详情。
+- **问题反馈** - [GitHub Issues](https://github.com/HydroGest/YesImBot/issues)
+- **功能建议** - [GitHub Discussions](https://github.com/HydroGest/YesImBot/discussions)
+- **QQ 交流群** - [857518324](http://qm.qq.com/cgi-bin/qm/qr?_wv=1027&k=k3O5_1kNFJMERGxBOj1ci43jHvLvfru9&authKey=TkOxmhIa6kEQxULtJ0oMVU9FxoY2XNiA%2B7bQ4K%2FNx5%2F8C8ToakYZeDnQjL%2B31Rx%2B&noverify=0&group_code=857518324)
-## 🌟 支持项目
+### 相关资源
-如果这个项目对您有帮助,请考虑给我们一个 ⭐️!
+- [Koishi 官方文档](https://koishi.chat/zh-CN/)
+- [Koishi 插件市场](https://koishi.chat/zh-CN/market.html)
## ⭐ Star 历史
-[](https://star-history.com/#Hydrogest/Yesimbot&Date)
+如果这个项目对你有帮助,请考虑给我们一个 ⭐ Star!
+
+[](https://star-history.com/#Hydrogest/Yesimbot&Date)
+
+## 🙏 致谢
+
+- 感谢 [Koishi](https://koishi.chat/) 提供的强大机器人框架
+- 感谢 [Letta](https://github.com/letta-ai/letta)(原 MemGPT)项目的设计灵感
+- 感谢 [@MizuAsaka](https://github.com/MizuAsaka) 设计的精美 Logo
+- 感谢所有贡献者和社区成员的支持
---
@@ -92,4 +253,6 @@ YesImBot/
**让 AI 更像人类,让聊天更有温度** 💝
+Made with ❤️ by the YesImBot Team
+
diff --git a/bump.config.ts b/bump.config.ts
new file mode 100644
index 000000000..f509dc178
--- /dev/null
+++ b/bump.config.ts
@@ -0,0 +1,7 @@
+import { defineConfig } from "bumpp";
+
+export default defineConfig({
+ all: true,
+ push: false,
+ recursive: true,
+});
diff --git a/commitlint.config.mjs b/commitlint.config.mjs
index 0e132fb4a..9d2fd93ae 100644
--- a/commitlint.config.mjs
+++ b/commitlint.config.mjs
@@ -47,18 +47,20 @@ export default {
* subject-case: 限制 subject(变更描述)的格式
* 这里设置为禁止首字母大写,保持简洁
*/
- "subject-case": [2, "always", "lower-case"],
+ "subject-case": [1, "always", "lower-case"],
/**
* scope-case: 限制 scope 的格式,这里强制小写
*/
- "scope-case": [2, "always", "lower-case"],
+ "scope-case": [1, "always", "lower-case"],
/**
* header-max-length: 限制头部信息最大长度(type+scope+subject)
* 这里参考 GitHub 推荐值 72
*/
- "header-max-length": [2, "always", 72],
+ "header-max-length": [1, "always", 72],
+
+ "body-max-line-length": [1, "always", 100],
},
prompt: {
@@ -113,7 +115,6 @@ export default {
allowBreakingChanges: ['feat', 'fix'],
// 其他配置
- breaklineNumber: 100,
breaklineChar: '|',
skipQuestions: [],
issuePrefixes: [
@@ -122,8 +123,5 @@ export default {
allowCustomIssuePrefix: true,
allowEmptyIssuePrefix: true,
confirmColorize: true,
- maxHeaderLength: 72,
- maxSubjectLength: 72,
- minSubjectLength: 1
},
};
diff --git a/eslint.config.ts b/eslint.config.ts
new file mode 100644
index 000000000..9a312e7f9
--- /dev/null
+++ b/eslint.config.ts
@@ -0,0 +1,33 @@
+import antfu from "@antfu/eslint-config";
+
+export default antfu({
+ // type: "lib",
+
+ ignores: [
+ "**/fixtures",
+ ],
+
+ gitignore: true,
+
+ stylistic: {
+ indent: 4,
+ quotes: "double",
+ semi: true,
+ },
+
+ typescript: true,
+ vue: true,
+
+ jsonc: false,
+ yaml: false,
+
+ rules: {
+ "no-console": "off",
+ "import/no-duplicates": "off",
+ "unused-imports/no-unused-vars": "off",
+ "ts/no-empty-object-type": "off",
+ "ts/no-redeclare": "warn",
+ "style/arrow-parens": "off",
+ "style/brace-style": "off",
+ },
+});
diff --git a/package.json b/package.json
index 115664a88..4b39af7dc 100644
--- a/package.json
+++ b/package.json
@@ -1,60 +1,45 @@
{
"name": "@root/yesimbot",
"version": "0.0.0",
- "packageManager": "bun@1.2.0",
"private": true,
- "homepage": "https://github.com/HydroGest/YesImBot",
+ "packageManager": "yarn@4.5.3",
"contributors": [
"HydroGest <2445691453@qq.com>",
"Dispure <3116716016@qq.com>",
- "Miaowfish <1293865264@qq.com>",
+ "MiaowFISH <1293865264@qq.com>",
"Touch-Night <1762918301@qq.com>"
],
"license": "MIT",
+ "homepage": "github:HydroGest/YesImBot",
"workspaces": [
- "packages/*"
+ "packages/*",
+ "plugins/*"
],
"scripts": {
- "dev": "turbo run dev",
"build": "turbo run build",
- "test": "turbo run test",
- "lint": "turbo run lint",
"clean": "turbo run clean && rm -rf .turbo",
- "pack": "turbo run pack",
+ "dev": "turbo run dev",
+ "lint": "turbo run lint",
"prepare": "husky install",
- "add-changeset": "changeset add",
- "version-packages": "changeset version",
- "release": "bun run build && changeset publish",
- "create-packages": "changeset version && turbo run pack",
- "collect-packages": "bun scripts/collect-packages.js",
- "optimize-canary-version": "node scripts/optimize-canary-version.js",
- "sync-npmmirror": "node scripts/sync-npmmirror.js",
- "sync-npmmirror:test": "node scripts/sync-npmmirror.js --dry-run",
- "commit": "cz"
+ "test": "turbo run test",
+ "bump": "bumpp"
},
"devDependencies": {
- "@changesets/cli": "^2.29.5",
- "@commitlint/cli": "^19.8.1",
- "@commitlint/config-conventional": "^19.8.1",
+ "@antfu/eslint-config": "^4.16.2",
"@types/node": "^22.16.2",
- "commitizen": "^4.3.1",
- "cz-git": "^1.12.0",
- "esbuild": "^0.25.6",
- "glob": "^11.0.3",
+ "bumpp": "^10.2.0",
+ "dumble": "^0.2.2",
+ "esbuild": "^0.27.1",
+ "eslint": "^9.33.0",
"husky": "^9.1.7",
- "lint-staged": "^16.1.2",
+ "lint-staged": "^16.2.7",
+ "pkgroll": "^2.21.4",
"prettier": "^3.6.2",
- "tsc-alias": "^1.8.16",
- "turbo": "2.5.4",
- "typescript": "^5.8.3",
+ "turbo": "^2.6.3",
+ "typescript": "^5.9.3",
"yml-register": "^1.2.5"
},
"lint-staged": {
"*.{js,ts,jsx,tsx,json,md,yml}": "prettier --write"
- },
- "config": {
- "commitizen": {
- "path": "cz-git"
- }
}
}
diff --git a/packages/code-executor/CHANGELOG.md b/packages/code-executor/CHANGELOG.md
deleted file mode 100644
index 69b87143b..000000000
--- a/packages/code-executor/CHANGELOG.md
+++ /dev/null
@@ -1,32 +0,0 @@
-# @yesimbot/koishi-plugin-code-executor
-
-## 1.2.1
-
-### Patch Changes
-
-- 018350c: refactor(logger): 更新日志记录方式,移除对 Logger 服务的直接依赖
-- Updated dependencies [018350c]
-- Updated dependencies [018350c]
- - koishi-plugin-yesimbot@3.0.2
-
-## 1.2.0
-
-### Minor Changes
-
-- 移除 JavaScript
-
-## 1.1.0
-
-### Minor Changes
-
-- 0c77684: prerelease
-
-### Patch Changes
-
-- 2ed195c: 修改依赖版本
-- 1cc0267: use changesets to manage version
-- Updated dependencies [b74e863]
-- Updated dependencies [106be97]
-- Updated dependencies [1cc0267]
-- Updated dependencies [b852677]
- - koishi-plugin-yesimbot@3.0.0
diff --git a/packages/code-executor/README.md b/packages/code-executor/README.md
deleted file mode 100644
index 2a52db5d7..000000000
--- a/packages/code-executor/README.md
+++ /dev/null
@@ -1,25 +0,0 @@
-# YesImBot 扩展插件:代码执行器 (Code Executor)
-
-[](https://www.npmjs.com/package/@yesimbot/koishi-plugin-code-executor)
-[](https://www.npmjs.com/package/@yesimbot/koishi-plugin-code-executor)
-
-为 [YesImBot](https://github.com/YesWeAreBot/YesImBot) 提供一个**安全、隔离、功能强大**的 Python 代码执行环境。
-
-这个插件允许 AI 智能体编写并执行代码来完成复杂的任务,例如:
-
-- 进行精确的数学计算和数据分析
-- 调用外部 API 获取实时信息
-- 处理和转换文本或数据
-- 执行任何可以通过编程逻辑实现的复杂工作流
-
-所有代码都在一个受限的沙箱环境中运行,确保了主系统的安全
-
-## ✨ 主要特性
-
-- **🔒 安全至上**: 基于 `pyodide` 构建隔离沙箱,有效防止恶意代码访问文件系统、子进程或不安全的内置模块。
-- **🧩 无缝集成 YesImBot**: 作为 `yesimbot` 的扩展插件自动注册,其工具(`execute_python`)会直接添加到智能体的可用工具集中。
-- **📦 动态依赖管理**: 智能体可以通过 `import` 语法请求外部模块。插件会自动解析并安装在白名单内的依赖。
-- **⚙️ 高度可配置**: 管理员可以通过白名单精确控制允许使用的内置模块和第三方模块。
-- **⏱️ 超时与保护**: 对每一次代码执行都设置了超时限制,有效防止因死循环或长时间运行的任务而导致的资源耗尽。
-- **🤖 AI 友好反馈**: 当代码执行失败时,插件会返回清晰的错误信息和**可行动的修复建议**,引导 AI 智能体自我修正代码,提高任务成功率。
-- **⚡️ 结果缓存**: 可选的执行结果缓存功能,对于重复执行相同代码的场景,可以秒速返回结果,降低延迟和资源消耗。
diff --git a/packages/code-executor/esbuild.config.mjs b/packages/code-executor/esbuild.config.mjs
deleted file mode 100644
index 8e362a11d..000000000
--- a/packages/code-executor/esbuild.config.mjs
+++ /dev/null
@@ -1,12 +0,0 @@
-import { build } from 'esbuild';
-
-// 执行 esbuild 构建
-build({
- entryPoints: ['src/**/*.ts'],
- outdir: 'lib',
- bundle: false,
- platform: 'node', // 目标平台
- format: 'cjs', // 输出格式 (CommonJS, 适合 Node)
- minify: false,
- sourcemap: true,
-}).catch(() => process.exit(1));
\ No newline at end of file
diff --git a/packages/code-executor/package.json b/packages/code-executor/package.json
deleted file mode 100644
index c27bda75a..000000000
--- a/packages/code-executor/package.json
+++ /dev/null
@@ -1,65 +0,0 @@
-{
- "name": "@yesimbot/koishi-plugin-code-executor",
- "description": "Yes! I'm Bot! 代码执行器扩展插件",
- "version": "1.2.1",
- "main": "lib/index.js",
- "typings": "lib/index.d.ts",
- "homepage": "https://github.com/YesWeAreBot/YesImBot",
- "files": [
- "lib",
- "dist",
- "resources"
- ],
- "scripts": {
- "build": "tsc && node esbuild.config.mjs",
- "dev": "tsc -w --preserveWatchOutput",
- "lint": "eslint . --ext .ts",
- "clean": "rm -rf lib .turbo tsconfig.tsbuildinfo",
- "pack": "bun pm pack"
- },
- "license": "MIT",
- "contributors": [
- "MiaowFISH "
- ],
- "keywords": [
- "koishi",
- "plugin",
- "code",
- "interpreter",
- "yesimbot",
- "extension"
- ],
- "repository": {
- "type": "git",
- "url": "git+https://github.com/YesWeAreBot/YesImBot.git",
- "directory": "packages/code-executor"
- },
- "bugs": {
- "url": "https://github.com/YesWeAreBot/YesImBot/issues"
- },
- "dependencies": {
- "pyodide": "0.28.2"
- },
- "devDependencies": {
- "koishi": "^4.18.7",
- "koishi-plugin-yesimbot": "^3.0.2"
- },
- "peerDependencies": {
- "koishi": "^4.18.7",
- "koishi-plugin-yesimbot": "^3.0.2"
- },
- "publishConfig": {
- "access": "public"
- },
- "koishi": {
- "description": {
- "zh": "为 YesImBot 提供一个安全、隔离的代码执行器",
- "en": "Provides a secure and isolated code interpreter for the YesImBot"
- },
- "service": {
- "required": [
- "yesimbot"
- ]
- }
- }
-}
diff --git a/packages/code-executor/src/config.ts b/packages/code-executor/src/config.ts
deleted file mode 100644
index cb690efd5..000000000
--- a/packages/code-executor/src/config.ts
+++ /dev/null
@@ -1,39 +0,0 @@
-import { Schema } from "koishi";
-
-// import { JavaScriptConfig, JavaScriptConfigSchema } from "./executors/javascript";
-import { PythonConfig, PythonConfigSchema } from "./executors/python";
-
-export interface SharedConfig {
- dependenciesPath: string;
- // artifactsPath: string;
- // artifactsUrlBase: string;
- maxOutputSize: number;
-}
-
-export interface Config {
- shared: SharedConfig;
- engines: {
- // javascript: JavaScriptConfig;
- python: PythonConfig;
- };
-}
-
-export const SharedConfig: Schema = Schema.object({
- dependenciesPath: Schema.path({ filters: ["directory"], allowCreate: true })
- .default("data/code-executor/deps")
- .description("JS/Python等引擎动态安装依赖的存放路径"),
- // artifactsPath: Schema.path({ filters: ["directory"], allowCreate: true })
- // .default("data/code-executor/artifacts")
- // .description("执行结果(如图片、文件)的存放路径"),
- // artifactsUrlBase: Schema.string().description("产物文件的公开访问URL前缀例如: https://my.domain/artifacts"),
- maxOutputSize: Schema.number().default(10240).description("输出内容(stdout/stderr)的最大字符数,超出部分将被截断"),
-});
-
-// 组合成总配置
-export const Config = Schema.object({
- shared: SharedConfig.description("全局共享配置"),
- engines: Schema.object({
- // javascript: JavaScriptConfigSchema,
- python: PythonConfigSchema,
- }).description("执行引擎配置"),
-});
diff --git a/packages/code-executor/src/executors/base.ts b/packages/code-executor/src/executors/base.ts
deleted file mode 100644
index 169d1e1cd..000000000
--- a/packages/code-executor/src/executors/base.ts
+++ /dev/null
@@ -1,83 +0,0 @@
-import { ToolCallResult, ToolDefinition, ToolError } from "koishi-plugin-yesimbot/services";
-
-/**
- * 代表一个标准化的执行错误结构。
- * 旨在为上层应用(特别是LLM)提供清晰、可操作的错误信息。
- */
-export interface ExecutionError extends ToolError {
- /**
- * 错误类型/名称,例如 'SyntaxError', 'EnvironmentError', 'TimeoutError'。
- */
- name: string;
- /**
- * 具体的错误信息,描述发生了什么。
- */
- message: string;
- /**
- * 可选的堆栈跟踪信息,用于调试。
- */
- stack?: string;
- /**
- * 针对此错误的修复建议,主要提供给LLM用于自我纠正。
- */
- suggestion?: string;
-}
-
-/**
- * 代表一个执行后产生的文件或可视化产物。
- */
-export interface ExecutionArtifact {
- /**
- * 资源的唯一ID,由 `ResourceManager.create` 返回。
- * 这是与资源交互的唯一标识符。
- */
- assetId: string;
-
- /**
- * AI请求创建时使用的原始文件名或描述。
- * 例如 "monthly_sales_chart.png"。这对于向用户展示非常重要。
- */
- fileName: string;
-}
-
-/**
- * 标准化的代码执行成功时的返回结果。
- */
-export interface CodeExecutionSuccessResult {
- /** 标准输出流的内容 */
- stdout: string;
- /** 标准错误流的内容 (即使执行成功,也可能有警告信息) */
- stderr: string;
- /** 执行过程中产生的结构化产物 */
- artifacts?: ExecutionArtifact[];
-}
-
-/**
- * 标准化的代码执行结果接口,继承自ToolCallResult。
- * 它封装了成功和失败两种状态。
- */
-export type CodeExecutionResult = ToolCallResult;
-
-/**
- * 所有代码执行引擎必须实现的接口。
- * 定义了一个代码执行器的标准契约。
- */
-export interface CodeExecutor {
- /**
- * 引擎的唯一类型标识符,例如 'javascript', 'python'。
- */
- readonly type: string;
-
- /**
- * 执行给定的代码。
- * @param code 要执行的代码字符串。
- * @returns 返回一个包含执行状态、输出和错误的标准化结果。
- */
- execute(code: string): Promise;
-
- /**
- * 生成并返回该执行器对应的 Koishi 工具定义。
- * @returns 工具定义对象,用于集成到LLM的工具集中。
- */
- getToolDefinition(): ToolDefinition;
-}
diff --git a/packages/code-executor/src/executors/index.ts b/packages/code-executor/src/executors/index.ts
deleted file mode 100644
index 7dcb27462..000000000
--- a/packages/code-executor/src/executors/index.ts
+++ /dev/null
@@ -1,2 +0,0 @@
-// export * from "./javascript";
-export * from "./python";
diff --git a/packages/code-executor/src/executors/javascript/index.ts b/packages/code-executor/src/executors/javascript/index.ts
deleted file mode 100644
index ea1ce4313..000000000
--- a/packages/code-executor/src/executors/javascript/index.ts
+++ /dev/null
@@ -1,504 +0,0 @@
-// import { exec } from "child_process";
-// import fs from "fs/promises";
-// import ivm from "isolated-vm";
-// import { Context, Logger, Schema } from "koishi";
-// import { AssetService, ToolDefinition, withInnerThoughts } from "koishi-plugin-yesimbot/services";
-// import { Services } from "koishi-plugin-yesimbot/shared";
-// import path from "path";
-// import { promisify } from "util";
-
-// import { SharedConfig } from "../../config";
-// import { CodeExecutionResult, CodeExecutor, ExecutionArtifact, ExecutionError } from "../base";
-
-// const asyncExec = promisify(exec);
-
-// interface ProcessedArtifactsResult {
-// artifacts: ExecutionArtifact[];
-// errorMessages: string[];
-// }
-
-// export interface JavaScriptConfig {
-// type: "javascript";
-// enabled: boolean;
-// packageManager: "npm" | "yarn" | "bun" | "pnpm";
-// registry: string;
-// timeout: number;
-// memoryLimit: number;
-// allowedBuiltins: string[];
-// allowedModules: string[];
-// customToolDescription: string;
-// }
-
-// export const JavaScriptConfigSchema: Schema = Schema.intersect([
-// Schema.object({
-// type: Schema.const("javascript").hidden().description("引擎类型"),
-// enabled: Schema.boolean().default(false).description("是否启用此引擎"),
-// }).description("JavaScript 执行引擎"),
-// Schema.union([
-// Schema.object({
-// enabled: Schema.const(true).required(),
-// timeout: Schema.number().default(10000).description("代码执行的超时时间(毫秒)"),
-// packageManager: Schema.union(["npm", "yarn", "bun", "pnpm"]).default("npm").description("用于动态安装依赖的包管理器"),
-// registry: Schema.string().default("https://registry.npmmirror.com").description("npm包的自定义注册表URL"),
-// memoryLimit: Schema.number().min(64).default(128).description("代码执行的内存限制(MB)"),
-// allowedBuiltins: Schema.array(String)
-// .default(["path", "util", "crypto"])
-// .role("table")
-// .description("允许使用的Node.js内置模块"),
-// allowedModules: Schema.array(String).default([]).role("table").description("允许动态安装的外部npm模块白名单"),
-// customToolDescription: Schema.string()
-// .role("textarea", { rows: [2, 4] })
-// .description("自定义工具描述,留空则使用默认描述"),
-// }),
-// Schema.object({}),
-// ]),
-// ]) as Schema;
-
-// export class JavaScriptExecutor implements CodeExecutor {
-// public static readonly type = "javascript";
-// readonly type = JavaScriptExecutor.type;
-
-// private readonly logger: Logger;
-// private assetService: AssetService;
-
-// private isolate: ivm.Isolate;
-// private hostRequireCallback: ivm.Callback;
-
-// private proxiedModuleCache = new Map();
-// private proxyToTargetMap = new WeakMap