mirror of
https://github.com/AstrBotDevs/AstrBot
synced 2026-07-15 17:30:13 +08:00
dev
22 Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
18e66595f0 | chore: ruff check --fix && ruff format . | ||
|
|
ec1af1ac0f | ruff check --fix --select ALL | ||
|
|
95430ee6f8 |
Feat/sdk integration (#6807)
* Add legacy session waiter compatibility * Expand legacy astrbot package compatibility * Tighten external legacy plugin compatibility smoke tests * Consolidate controlled legacy facade compatibility * docs: clarify compat package boundaries * test: align runtime fixtures with maintained samples * fix: preserve unicode sample fixtures in runtime tests * Implement legacy hook and tool compat runtime * Refactor legacy runtime execution boundary * 增强旧版兼容性,添加多个旧路径入口和相关功能 * 增强旧版兼容性,添加适配器边界的启动和关闭钩子支持 * Refactor legacy API and LLM compatibility logic - Moved legacy LLM and tool compatibility logic from `_legacy_api.py` to a new module `_legacy_llm.py` for better organization and separation of concerns. - Updated `_legacy_api.py` to import necessary components from `_legacy_llm.py`, removing redundant code. - Enhanced database client functionality by adding support for batch read/write operations and change event subscriptions. - Improved documentation in the database client and capability router to reflect new features. - Refined environment management process in the loader to better handle plugin grouping and virtual environment management. * 补充插件分组环境测试覆盖 * feat: Enhance CLI and testing capabilities - Added a new script entry point `astrbot-sdk` in `pyproject.toml`. - Introduced `has_waiter` method in `SessionWaiterManager` to check for existing waiters. - Updated `cli.py` to improve error handling and added context to error messages. - Implemented local development support in `cli.py` with a new `dev` command for running plugins against a mock core. - Created a new testing module `astrbot_sdk.testing` with utilities for local development and plugin testing. - Added comprehensive tests for the new testing module and CLI commands. - Improved compatibility and error messaging for plugin loading failures. * feat: 添加插件初始化、验证和构建命令,增强 CLI 功能 * feat: add platform client documentation and examples - Introduced platform client documentation in `docs/v4/clients/platform.md` detailing methods for sending messages, images, and managing group members. - Added example plugins for LLM chat and database functionalities in `docs/v4/examples/README.md`, `docs/v4/examples/llm-chat/README.md`, and `docs/v4/examples/database/README.md`. - Enhanced quickstart guide with links to new documentation and example plugins. - Implemented runtime contract tests to ensure compatibility of public capabilities and hooks. * Refactor legacy runtime handling and improve plugin loading - Updated `handler_dispatcher.py` to streamline legacy runtime preparation and dispatching results. - Enhanced `loader.py` to simplify legacy plugin detection and manifest building. - Added tests for new HTTPClient and MetadataClient functionalities. - Introduced tests for legacy context metadata methods and legacy loader helpers. - Improved legacy runtime tests to cover new functionality and edge cases. * refactor: 更新兼容层和导入路径,优化文档描述 * Support grouped plugin workers in shared environments - add group metadata driven worker startup for shared env plans - track per-plugin handler and capability ownership inside grouped workers - update runtime and smoke tests for grouped worker session behavior * Add v4 compat layer and legacy shims - Introduce private v4 compatibility surface using _legacy_api.py, _legacy_runtime.py, _legacy_loader.py plus new _legacy_context.py and _legacy_star.py to centralize legacy adapters while keeping public APIs thin. - Extend InitializeOutput to carry protocol_version for negotiated protocol, enabling runtime to adapt to the chosen v4 version. - Add lightweight legacy support for Star/Context via new LegacyStar and LegacyContext shims and expose legacy API through the aggregate _legacy_api entry point. - Ensure legacy loader preserves class declaration order by iterating module.__dict__ instead of relying on alphabetical sorting. - Add tests: protocol_version handling in InitializeOutput, legacy main component order preservation, and embedded-newline framing in transport tests. * Add architecture doc and refine API compat - Add PROJECT_ARCHITECTURE.md documenting architecture, compat surface, and testing notes. - Update astrbot_sdk.api.__init__ to clarify it is a compatibility implementation layer, not a simple facade, and list migration targets. - Normalize platform in AstrMessageEvent.to_payload to emit a string id by using get_platform_id(). * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> * delete old sdk * delete old sdk (#7) Co-authored-by: whatevertogo <whatevertogo@users.noreply.github.com> * feat(cli): normalize plugin init skeletons Add interactive plugin init prompts and normalize generated plugin names to the astrbot_plugin_ convention. Update CLI tests for the new skeleton layout and ignore generated plugin directories in git and coverage tooling. Also include related runtime logging adjustments from the current worktree. * Create lint.yml * Update lint.yml * clean it * feat: Enhance handler and capability dispatchers with improved error handling - Updated HandlerDispatcher to raise TypeError for uninjectable required parameters, logging errors appropriately. - Refactored CapabilityDispatcher to raise TypeError for missing required parameters during capability execution. - Renamed _load_plugin_config to load_plugin_config for clarity and consistency. - Introduced _sync_plugin_registry method in SupervisorRuntime to manage plugin capabilities more effectively. - Enhanced capability registration logic to handle naming conflicts with better logging and automatic renaming. - Added tests for handler and capability dispatchers to ensure proper error handling and functionality. - Implemented new HTTP and metadata capabilities with corresponding tests for registration and retrieval. - Improved MemoryClient methods with additional tests for save_with_ttl, get_many, delete_many, and stats. - Added tests for the testing module to ensure proper import and functionality of PluginHarness. * feat: 更新 SDK 描述,重构插件调用上下文,移除插件 ID 传递,增强能力路由和 HTTP 客户端的插件身份管理 * refactor: 更新文档和代码注释,优化兼容性描述,增强可读性 * feat: 添加插件热重载功能,支持文件变更时自动重新加载插件 * feat: 增强错误处理,添加上下文信息,优化插件组件加载和参数注入校验 * feat: 添加 hello_plugin 示例,包含插件结构、命令处理和测试用例 * refactor: 删除过时的架构文档、变更日志和兼容矩阵文件 * refactor: 更新兼容层弃用通知,优化文档结构和可读性 * refactor: 更新项目架构文档,增强能力客户端和执行边界的描述,移除兼容层设计章节 * feat(errors): Enhance AstrBotError with detailed documentation and examples feat(events): Expand MessageEvent with reply capabilities and detailed docstrings fix(loader): Ensure plugin path is correctly managed in sys.path feat(star): Improve Star class documentation and lifecycle method descriptions feat(testing): Add plugin metadata handling in MockContext and enhance PluginHarness feat(hello): Refactor HelloPlugin to utilize new reply methods and structured capabilities test(decorators): Add tests for input/output model support in provide_capability test(events): Implement tests for reply_image and reply_chain methods in MessageEvent test(http): Validate API registration with capability handler references and error handling test(tests): Enhance tests for plugin harness and directory handling in dev commands * feat(runtime): add configurable msgpack wire codec support * fix(runtime): align msgpack framing with transport defaults * fix(runtime): preserve json transport compatibility * fix(cli): scope worker wire codec option * feat: 添加 AGENTS.md 文档,描述 v4 架构约束和开发命令 refactor: 更新 HandlerDispatcher 和 WorkerSession,增强参数处理和结果汇总逻辑 * fix(test): 更新 init_plugin 测试以匹配新的目录命名规范 CLI 的 _normalize_init_plugin_name 函数现在自动添加 astrbot_plugin_ 前缀, 测试期望的目录名从 demo_plugin 更新为 astrbot_plugin_demo_plugin。 * Refactor worker initialization and remove unused codec parameters; add schedule and session waiter modules - Simplified `GroupWorkerRuntime` and `PluginWorkerRuntime` constructors by removing the codec parameter and related logic. - Introduced `schedule.py` to define `ScheduleContext` for managing scheduled tasks with a clear structure and payload handling. - Added `session_waiter.py` for session-based conversational flow management, including `SessionController` and `SessionWaiterManager` for handling multi-turn dialogues. - Enhanced testing utilities in `testing.py` by removing unused classes and streamlining the structure. - Created `types.py` to introduce `GreedyStr` for improved command parameter parsing. * feat: 添加 LLM 工具管理和会话级别状态管理能力 - 新增 llm/ 模块,包含 LLMToolSpec、ProviderRequest、AgentSpec 等实体 - 新增 LLMToolManager 用于管理 LLM 工具注册和激活状态 - 新增 SessionPluginManager 用于会话级别的插件启用状态管理 - 新增 SessionServiceManager 用于会话级别的 LLM/TTS 服务状态管理 - 新增 RegistryClient 用于查询 handler 元数据和设置白名单 - 扩展 CapabilityRouter 内置能力,支持 session.* 和 registry.* 命名空间 - 增强描述符和装饰器以支持新的 trigger 类型 * feat: 大幅增强 SDK 核心功能和文档 新增模块: - clients/files.py: 文件上传/下载客户端 - clients/managers.py: 会话/LLM/Provider 管理器 - clients/provider.py: LLM Provider 客户端 - conversation.py: 对话上下文管理 - plugin_kv.py: 插件 KV 存储辅助 - runtime/limiter.py: 限流器 - star_tools.py: Star 工具函数 - docs/: 完整的 SDK 使用文档 (01-05) 功能增强: - Context 大幅扩展,增加 reply/send_image/typing 等便捷方法 - 装饰器增强,支持 on_llm_request/on_provider_request 等 - 内置 schemas 扩展,覆盖更多 capability 定义 - capability_router_builtins 大幅扩展内置能力实现 - handler_dispatcher 增强参数注入和错误处理 - Star 基类增加生命周期钩子和工具方法 * Add comprehensive API documentation for types and utilities in AstrBot SDK - Introduced `types.md` detailing type aliases, generics, and Pydantic models used in the SDK. - Added `utils.md` covering utility classes and functions including CancelToken, MessageSession, command groups, and session management. - Included usage examples and detailed descriptions for each component to enhance developer understanding and ease of use. * feat: 添加高级方法和辅助函数文档,增强消息组件和事件处理功能 * feat: 增强过滤器类型和能力路由文档,添加 Provider 和会话管理功能 * change location * delete no need thing * delete again * feat: add Star plugin base class and StarTools utility class - Introduced `Star` class as a base for v4 native plugins, providing lifecycle methods and context management. - Added `StarTools` class for accessing runtime context and managing LLM tools. - Implemented `PluginHarness` for local development and testing of plugins, allowing for message dispatching and lifecycle management. - Created `GreedyStr` type for enhanced command parameter parsing, enabling the capture of remaining command text as a single argument. - Added testing utilities and mock capabilities for plugin development. * delete: remove hello_plugin example and its related files * Remove obsolete test files for testing module, top-level modules, transport, and wire codecs - Deleted `test_testing_module.py` as it is no longer needed. - Removed `test_top_level_modules.py` which had no content. - Eliminated `test_transport.py` due to redundancy. - Cleared out `test_wire_codecs.py` as part of the cleanup. * fix(runtime): avoid creating Star instance in on_error fallback * fix(runtime): avoid virtual dispatch in Star.on_error fallback * refactor(runtime): unify command matching logic (#25) * refactor(testing): share command matching with handler dispatcher * fix:添加公共函数文件 * fix: simplify register_task completion handling (#27) * fix: simplify register_task completion handling Remove duplicated cancellation logging in Context.register_task while keeping Future inputs compatible with asyncio.create_task semantics. Add regression coverage for coroutine, Future, cancellation, and failure paths. * fix: prioritize local src in tests_v4 Ensure tests_v4 always imports the working tree package by moving src to sys.path[0] even when another checkout or installed copy is already present. * chore: sync subtree from AstrBot * feat: replay non-sdk changes on clean sdk subtree baseline * feat(sdk): add merged provider config capability support Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai> * feat(sdk): add merged provider config bridge and client Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai> * feat(sdk): add merged provider config capability support Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai> * fix(sdk): tighten bridge cast typing Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai> * feat(sdk): add merged provider config bridge and client Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai> * test(sdk): cover merged provider config parity Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai> * feat: 完善 memory 向量检索与索引统计 (#28) Co-authored-by: united_pooh <united_pooh@outlook.com> * feat(tests): 添加测试用例以验证 register_task 的行为并更新测试运行说明 * Merge commit 'e45bade147ff44b43860ecff12067309e59c151a' into feat/sdk-integration * Squashed 'astrbot-sdk/' changes from 7dda6077..85342f14 |
||
|
|
92bae1fdae | docs: replace prints with logger in upload_doc_images_to_r2.py | ||
|
|
fd223bb259 |
fix: resolve unhandled UTC timezone offset for timestamps in conversation records (#5580)
* fix: resolve unhandled UTC timezone offset for timestamps in conversation records * fix: standardize timezone imports * fix: unify UTC datetime normalization in dashboard routes --------- Co-authored-by: 邹永赫 <1259085392@qq.com> |
||
|
|
7dd95d8a59 |
chore: auto ann fix by ruff (#4903)
* chore: auto fix by ruff * refactor: 统一修正返回类型注解为 None/bool 以匹配实现 * refactor: 将 _get_next_page 改为异步并移除多余的请求错误抛出 * refactor: 将 get_client 的返回类型改为 object * style: 为 LarkMessageEvent 的相关方法添加返回类型注解 None --------- Co-authored-by: Soulter <37870767+Soulter@users.noreply.github.com> |
||
|
|
241f1c26d3 |
feat: context compress (#4322)
* feat: context compressor Co-authored-by: kawayiYokami <289104862@qq.com> * Add comprehensive tests for ContextManager and ContextTruncator - Implemented a full test suite for ContextManager covering initialization, message processing, token-based compression, and error handling. - Added tests for ContextTruncator focusing on message fixing, truncation by turns, dropping oldest turns, and halving. - Ensured that both test suites validate edge cases and maintain expected behavior with various message types, including system and tool messages. * feat: add MockProvider for LLM compression tests * chore: remove lock * ruff fix * fix * perf * feat: enhance context compression with token tracking and logging * feat: update logging for context compression trigger * feat: implement context compression logic with dynamic threshold and token tracking * fix: reorder import statements for consistency * feat: add token_usage tracking to conversations and update related processing logic --------- Co-authored-by: kawayiYokami <289104862@qq.com> |
||
|
|
50144ddcae |
refactor: revise LLM message schema and fix the reload logic when using dataclass-based LLM Tool registration (#3234)
* refactor: llm message schema * feat: implement MCPTool and local LLM tools with enhanced context handling * refactor: reorganize imports and enhance docstrings for clarity * refactor: enhance ContentPart validation and add message pair handling in ConversationManager * chore: ruff format * refactor: remove debug print statement from payloads in ProviderOpenAIOfficial * Update astrbot/core/agent/tool.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update astrbot/core/agent/message.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update astrbot/core/agent/message.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update astrbot/core/agent/tool.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update astrbot/core/pipeline/process_stage/method/llm_request.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update astrbot/core/agent/message.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * refactor: enhance documentation and import mcp in tool.py; update call method return type * fix: 修复以数据类的方式注册 tool 时的插件重载机制问题 * refactor: change role attributes to use Literal types for message segments * fix: add support for 'decorator_handler' method in call_local_llm_tool * fix: handle None prompt in text_chat method and ensure context is properly formatted --------- Co-authored-by: LIghtJUNction <lightjunction.me@gmail.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> |
||
|
|
0b7fc29ac4 |
style: add ruff lint module of isort and pyupgrade, and some ruff check fix (#3214)
Co-authored-by: Dt8333 <25431943+Dt8333@users.noreply.github.com> Co-authored-by: Soulter <905617992@qq.com> |
||
|
|
98a75e923d |
feat: 集成知识库到核心生命周期和消息流水线
- 在 AstrBotCoreLifecycle 中初始化知识库管理器 - 将知识库注入器添加到消息处理上下文 - 在消息流水线中添加 KBEnhanceStage(知识库增强阶段) - 实现会话删除时的知识库配置级联清理机制 - 添加会话管理器的回调注册机制,支持零侵入扩展 |
||
|
|
c2a34475f1 |
feat: 支持删除指定会话以及部分会话管理优化 (#2895)
* feat: add toast notification system with snackbar component * feat: add session deletion functionality * feat: support batch operations for updating session persona, provider, LLM, and TTS statuses fix: #2263 * feat: 修复对话状态关闭,删除对话管理库会导致对话无法恢复 fixes: #2309 |
||
|
|
69aaf09ac8 | chore: 修复当自动更新 webchat title 时,history 被重置的问题 | ||
|
|
64bcbc9fc0 | refactor: 重构 SharedPreference 类并采用数据库存储替换 json 存储 (#2482) | ||
|
|
842c3c8ea9 |
Refactor: using sqlmodel(sqlchemy+pydantic) as ORM framework and switch to async-based sqlite operation (#2294)
* stage * stage * refactor: using sqlchemy as ORM framework, switch to async-based sqlite operation - using sqlmodel as ORM(based on sqlchemy and pydantic) - add Persona, Preference, PlatformMessageHistory table * fix: conversation * fix: remove redundant explicit session.commit, and fix some type error * fix: conversation context issue * chore: remove comments * chore: remove exclude_content param |
||
|
|
14e0aa3ec5 |
perf: history 和 persona 指令当对话不存在的时候自动创建
fixes: #1997 |
||
|
|
d88420dd03 | fix: 修改获取人类可读的上下文的逻辑, 区分函数调用(无contents)和一般消息 | ||
|
|
1746684e52 | perf: 修改部分注释 | ||
|
|
9717a736b1 | perf: 更新部分描述 | ||
|
|
5c4326c302 | perf: 部分详细注释, 符合PEP8标准 | ||
|
|
49bba9bf98 | style: format codes | ||
|
|
67095f97b1 |
🐛 fix: delete conversation
✨ feat: supports active reply whitelist
|
||
|
|
12f4e1146f | feat: 更好的对话管理 |