Commit Graph

234 Commits

Author SHA1 Message Date
雅诺狐
5f87605eba Add rare easter egg message and adjust weights
Introduced a new rare easter egg message to the items list and updated the selection weights to make the new message extremely rare while adjusting the probabilities of the existing messages.
2025-08-19 12:05:32 +08:00
minecraft1024a
89cc1d2f6d Merge branch 'master' of https://github.com/MaiBot-Plus/MaiMbot-Pro-Max 2025-08-19 12:01:16 +08:00
minecraft1024a
86c76d002b Merge branch 'master' of https://github.com/MaiBot-Plus/MaiMbot-Pro-Max 2025-08-19 12:01:11 +08:00
ikun两年半
3b295938e0 更新 bot.py
修改彩蛋权重喵~主打一个众生平等喵
2025-08-19 11:59:15 +08:00
minecraft1024a
1951f5d2b4 Merge branch 'master' of https://github.com/MaiBot-Plus/MaiMbot-Pro-Max 2025-08-19 11:55:52 +08:00
雅诺狐
5e91f9ef5f Remove unused imports across multiple modules
Cleaned up various files by removing unused or redundant import statements to improve code readability and reduce potential confusion. No functional changes were made.
2025-08-19 11:55:24 +08:00
minecraft1024a
c1eedca19b Merge branch 'master' of https://github.com/MaiBot-Plus/MaiMbot-Pro-Max 2025-08-19 11:54:48 +08:00
雅诺狐
bd3cfc47f6 Merge branch 'master' of https://github.com/MaiBot-Plus/MaiMbot-Pro-Max 2025-08-19 11:54:14 +08:00
minecraft1024a
c36d653dee chore(deps): remove legacy gemini client and fix easter egg range 2025-08-19 11:54:00 +08:00
雅诺狐
723a9d0098 Add weighted_choice utility and improve easter_egg randomness
Introduced a weighted_choice function for weighted random selection. Refactored the easter_egg function to use weighted_choice for more flexible and controlled message selection, replacing the previous randint-based logic.
2025-08-19 11:53:01 +08:00
ikun两年半
db7df3f137 更新 bot.py
喵喵~修复了彩蛋概率问题喵~
2025-08-19 11:51:33 +08:00
minecraft1024a
5cce105acc feat(彩蛋): 增加彩蛋文本的随机性
在 `easter_egg` 函数中引入了随机数生成逻辑。
现在有20%的概率显示猫娘文本,80%的概率显示一个原有的文本,增加了趣味性。
2025-08-19 11:34:53 +08:00
minecraft1024a
25bcc96092 feat(video): 视频识别功能开关与日志优化
根据全局配置 `global_config.video_analysis.enable` 控制视频识别功能的启用与禁用。

- 当视频识别功能禁用时,收到视频消息将直接返回 `[视频]` 或空字符串,不再进行分析,以节约资源。
2025-08-19 11:27:53 +08:00
ikun-11451
bfc131afdf 喵喵~ 2025-08-19 05:55:42 +08:00
雅诺狐
bc1339411e Create dependabot.yml 2025-08-18 22:41:42 +08:00
minecraft1024a
ec61a9ccf0 新增反击模式支持,允许在检测到提示词注入攻击时生成反击响应并发送。更新相关配置和处理逻辑,增强系统的防护能力。 2025-08-18 22:13:23 +08:00
tt-P607
15ae0ea609 <Thinking>
我需要分析这个git diff,并生成一个与之前完全不同的commit message。

让我先分析变更内容:

1. **主要变更**:
   - 在 `anti_injector.py` 中添加了新的 `auto` 处理模式
   - 添加了命令跳过列表功能 (`command_skip_list`)
   - 重构了反注入管理命令,从独立插件移动到核心动作插件
   - 更新了配置文件以支持新功能
   - 在插件管理器中添加了跳过列表刷新逻辑

2. **之前的commit message重点**:
   - 强调了"advanced anti-injection capabilities"
   - 重点描述了"intelligent 'auto' mode"
   - 提到了"command skip list"
   - 强调了"dynamically assesses threats"
   - 提到了"refactored and integrated into core actions plugin"

3. **我需要完全不同的角度**:
   - 可以从架构重构的角度
   - 可以从用户体验改进的角度
   - 可以从系统集成的角度
   - 可以从性能优化的角度

让我从**系统架构优化和插件整合**的角度来写这个commit message,重点强调:
- 插件系统的重构和整合
- 管理命令的迁移和统一
- 跳过机制的实现
- 自动化决策系统的引入

这样就能避免使用之前message中的关键词和结构。
</Thinking>

refactor(plugins): 重构反注入插件架构并优化命令管理体系

将反注入管理功能从独立插件迁移至核心动作模块,实现更好的系统集成。新增智能跳过机制,允许已注册的插件命令绕过检测流程,有效减少误判。同时引入自适应处理策略,系统可根据威胁评估结果自主选择最适当的响应方式。

插件管理器现已集成自动刷新功能,确保跳过列表与插件状态保持同步。配置系统扩展支持多种跳过模式和自定义规则,提升了整体可维护性和用户体验。
ps:谢谢雅诺狐姐姐投喂的提交喵^ω^
2025-08-18 21:49:17 +08:00
minecraft1024a
fb02896359 feat(cache): 用文件修改时间替换源码哈希生成缓存键
BREAKING CHANGE: CacheManager 的 _generate_key/get/set 方法签名变更,现在需要传入 tool_file_path 而非 tool_class 实例,所有调用方需跟进适配。
2025-08-18 20:07:59 +08:00
Furina-1013-create
e1d4c30363 更新template里面关于视频识别的部分,并增加了一些描述
这应该是我今天最后一次commit了
2025-08-18 18:42:02 +08:00
Furina-1013-create
078eaa0655 Merge branch 'master' of https://github.com/MaiBot-Plus/MaiMbot-Pro-Max 2025-08-18 18:36:34 +08:00
Furina-1013-create
de64284109 解决多帧视频识别失败的问题并对视频重复性检测增加一种方法 -特征识别 降低重复识别率
并删除雅诺狐上传的测试文件
2025-08-18 18:36:17 +08:00
雅诺狐
80064a4878 Merge branch 'master' of https://github.com/MaiBot-Plus/MaiMbot-Pro-Max 2025-08-18 18:31:50 +08:00
雅诺狐
bcbcabb0d8 Refactor cache L2 storage to use SQLAlchemy DB
Replaces the L2 cache layer's SQLite implementation with an async SQLAlchemy-based database model (CacheEntries). Updates cache_manager.py to use db_query and db_save for cache operations, adds semantic cache handling with ChromaDB, and introduces async cache clearing and expiration cleaning methods. Adds the CacheEntries model and integrates it into the database API.
2025-08-18 18:30:17 +08:00
minecraft1024a
483c470acf 修复缓存管理器中的异常处理逻辑
- 将捕获的异常类型从 `TypeError` 和 `OSError` 修改为 `Exception`,以涵盖更多潜在错误。
- 增强日志记录,提供更清晰的类名和简化的错误信息,便于调试和问题追踪。
2025-08-18 18:29:42 +08:00
minecraft1024a
1a3eb58d26 Merge branch 'master' of https://github.com/MaiBot-Plus/MaiMbot-Pro-Max 2025-08-18 18:08:18 +08:00
minecraft1024a
584b552415 feat(cache): 增强嵌入向量处理的健壮性和验证
- 新增 `_validate_embedding` 方法,用于在存入缓存前对嵌入向量进行严格的格式检查、维度验证和数值有效性校验。
- 在缓存查询 (`get`) 和写入 (`set`) 流程中,集成此验证逻辑,确保只有合规的向量才能被处理和存储。
- 增加了在L1和L2向量索引操作中的异常捕获,防止因向量处理失败导致缓存功能中断,提升了系统的整体稳定性。
2025-08-18 18:08:14 +08:00
雅诺狐
7856c6a8e9 Expand dangerous keyword list in message shielding
Extended the list of dangerous keywords in the _partially_shield_content method to cover more attack vectors, including system commands, privilege escalation, information leakage, and social engineering. This enhances the robustness of the message shielding mechanism against prompt injection and related attacks.
2025-08-18 18:08:10 +08:00
雅诺狐
ceb8150914 Expand and update prompt injection detection patterns
Enhanced the default_patterns list in PromptInjectionDetector with more comprehensive and specific regular expressions to improve detection of prompt injection attempts, including new patterns for admin commands, system prompts, privilege escalation, and sensitive information leakage. This update aims to strengthen the robustness of the anti-prompt-injection mechanism.
2025-08-18 18:04:44 +08:00
雅诺狐
9c23ceae01 Merge branch 'master' of https://github.com/MaiBot-Plus/MaiMbot-Pro-Max 2025-08-18 17:51:50 +08:00
雅诺狐
f61710b0ce Refactor anti-injector process result handling
Introduced a ProcessResult enum to standardize anti-injector message processing outcomes. Updated anti_injector.py to return ProcessResult values instead of booleans, and refactored bot.py to handle these results with improved logging and clearer control flow. This change improves code clarity and maintainability for anti-prompt injection logic.
2025-08-18 17:51:44 +08:00
Furina-1013-create
8959ffebb0 Merge branch 'master' of https://github.com/MaiBot-Plus/MaiMbot-Pro-Max 2025-08-18 17:37:57 +08:00
Furina-1013-create
247235c5ba 之前单等于的原因是被Rust带歪了( 2025-08-18 17:37:19 +08:00
雅诺狐
f3958ef484 Merge branch 'master' of https://github.com/MaiBot-Plus/MaiMbot-Pro-Max 2025-08-18 17:29:32 +08:00
雅诺狐
689aface9d Add LLM anti-prompt injection system
Introduces a comprehensive anti-prompt injection system for LLMs, including rule-based and LLM-based detection, user ban/whitelist management, message shielding, and statistics tracking. Adds new modules under src/chat/antipromptinjector, integrates anti-injection checks into the message receive flow, updates configuration and database models, and provides test scripts. Also updates templates and logger aliases to support the new system.
2025-08-18 17:27:59 +08:00
Furina-1013-create
6eec2daaa6 修复视频只有单帧被识别的问题并再次更新requirements.txt 2025-08-18 17:11:09 +08:00
Furina-1013-create
23aec68cc0 修复Gemini api专属的那个gemini_client.py里面的一个潜在的导入问题并增加回退机制 2025-08-18 16:18:21 +08:00
Furina-1013-create
9205edf8ca 更新一闪忘记更新的requirements.txt 2025-08-18 15:47:36 +08:00
minecraft1024a
22f6cd2d94 feat(deps): 实现依赖包智能别名解析
引入了依赖包智能别名解析机制,以解决 Python 生态中常见的安装名与导入名不一致的问题(如 `beautifulsoup4` -> `bs4`)。

当通过包名直接导入失败时,依赖管理器会自动查询一个内置的别名映射表,并尝试使用别名再次导入。这大大提升了开发者在定义简单字符串格式依赖时的体验,减少了因名称不一致导致的依赖检查失败。

同时,更新了相关文档,详细说明了该功能的工作原理、解决了什么问题,并更新了最佳实践。
2025-08-18 13:48:55 +08:00
minecraft1024a
d43d352ca5 refactor(config): 移除视频分析相关重复的配置及未使用的导入(所以我挺好奇为什么VideoAnalysisConfig能有两个)
同时,清理了多个文件中未使用的导入,包括 `inspect`、`base64` 和 `get_image_manager`,以保持代码库的整洁。
2025-08-18 13:16:54 +08:00
minecraft1024a
3b3eb080da feat(plugin): 实现插件配置集中化管理
将插件配置文件从各自的插件目录迁移至项目根目录下的 `config/plugins/` 文件夹中,方便用户统一管理和修改。

主要变更:
- 新增 `plugins.centralized_config` 总开关,用于控制是否启用此功能。
- 修改插件加载逻辑,现在会从 `config/plugins/<plugin_name>/` 目录读取用户配置。
- 如果用户配置不存在,会自动从插件目录下的模板配置文件复制一份。
- 保留了原有的配置版本检查和自动迁移功能,现在作用于用户配置文件。
2025-08-18 13:00:13 +08:00
minecraft1024a
dcc2e4caff feat(maizone): 新增定时任务随机间隔功能
为了避免定时任务在完全相同的时间点触发,引入了随机延迟机制。

现在,定时任务的执行间隔将在设定的最小和最大分钟数之间随机波动,使行为模式更难被预测。
此功能可通过配置项进行调整,默认间隔为 5 到 15 分钟。

Co-Authored-By: tt-P607 <68868379+tt-P607@users.noreply.github.com>
2025-08-18 12:04:35 +08:00
minecraft1024a
c47d666d07 chore(deps): 移除未使用的 ModelTaskConfig 导入
从 cache_manager.py 文件中删除了对 `src.config.api_ada_configs` 中 `ModelTaskConfig` 的导入,因为它在该文件中并未被使用。

添加了记忆系统的大饼

Co-authored-by: 雅诺狐 <foxcyber907@users.noreply.github.com>
2025-08-18 11:54:00 +08:00
minecraft1024a
51c0d2a1e8 refactor(cache): 重构缓存系统为分层语义缓存
将原有的基于文件的 `ToolCache` 替换为全新的 `CacheManager`,引入了更复杂和高效的分层语义缓存机制。

新系统特性:
- **分层缓存**:
  - L1 缓存: 内存字典 (KV) + FAISS (向量),用于极速访问。
  - L2 缓存: SQLite (KV) + ChromaDB (向量),用于持久化存储。
- **语义缓存**: 利用嵌入模型 (Embedding) 对查询进行向量化,实现基于语义相似度的缓存命中,显著提高了缓存命中率。
- **自动失效**: 缓存键包含工具源代码的哈希值,当工具代码更新时,相关缓存会自动失效,避免了脏数据问题。
- **异步支持**: 缓存的 `get` 和 `set` 方法现在是异步的,以适应项目中异步化的工具调用流程。

`web_search_tool` 已更新以使用新的 `CacheManager`,在调用缓存时传递 `tool_class` 和 `semantic_query` 以充分利用新功能。

Co-Authored-By: tt-P607 <68868379+tt-P607@users.noreply.github.com>
2025-08-17 22:18:26 +08:00
minecraft1024a
b45a992484 Merge branch 'master' of https://github.com/MaiBot-Plus/MaiMbot-Pro-Max 2025-08-17 21:26:42 +08:00
minecraft1024a
1752831024 perf(web_search): 缓存网络工具调用以加速响应
为 `WebSurfingTool` 和 `URLParserTool` 集成 `tool_cache`,避免对相同参数的重复请求。

此更改通过在执行网络搜索或URL解析前检查缓存来优化性能。如果找到先前成功的结果,则立即返回缓存数据,从而显著减少延迟和外部API的使用。仅当缓存未命中时,工具才会继续执行其原始逻辑,并将成功的结果存入缓存以备将来使用。
2025-08-17 21:26:35 +08:00
雅诺狐
aaaf8f5ef7 Update TODO: Mark MCP SSE support as incomplete
Changed the MCP SSE support item from completed to incomplete in the TODO list to reflect current project status.

Co-Authored-By: tt-P607 <68868379+tt-P607@users.noreply.github.com>
2025-08-17 21:08:49 +08:00
雅诺狐
74ae472005 Add ToolCache class for tool result caching
Introduces a ToolCache class to manage caching of tool invocation results with support for both exact and approximate (similarity-based) query matching. Includes methods for cache retrieval, storage, expiration, cleanup, and statistics. This helps improve efficiency by reusing previous results and reducing redundant tool executions.

Co-Authored-By: tt-P607 <68868379+tt-P607@users.noreply.github.com>
2025-08-17 21:06:25 +08:00
雅诺狐
3155c4713f Remove Nix, pre-commit, and related config files
Deleted Nix flake files, pre-commit configuration, environment files, sample data, and a batch script. Also commented out automatic triggers in the Docker GitHub Actions workflow, leaving only manual dispatch. This simplifies the repository by removing development environment and automation tooling.

Co-Authored-By: tt-P607 <68868379+tt-P607@users.noreply.github.com>
2025-08-17 21:03:27 +08:00
雅诺狐
b618953322 Remove GitHub PR template and workflow files
Deleted the pull request template and related GitHub Actions workflows for precheck and Ruff checks. This streamlines the repository by removing automated PR checks and formatting enforcement.

Co-Authored-By: tt-P607 <68868379+tt-P607@users.noreply.github.com>
2025-08-17 20:57:21 +08:00
雅诺狐
cb65d91c7a Refactor antiprompt flowchart and fix indentation
Updated the antipromptinjector flowchart for improved clarity and logic. Fixed indentation in expression_selector.py to correct code structure. Removed obsolete db_migration_plan.md documentation.
2025-08-17 20:51:52 +08:00