Commit Graph

46 Commits

Author SHA1 Message Date
whatevertogo
ffafd74881 docs: 增强 api 模块兼容层文档,提示插件作者迁移
- 添加 warning 块明确标注为 v3 兼容层
- 提示插件制作者迁移至新版导入路径
- 添加迁移示例代码对比旧版/新版导入方式
- 说明兼容层将在未来版本移除
2026-03-13 03:31:00 +08:00
whatevertogo
cdf72b75a4 feat: 实现 v4 API 兼容层,支持旧版插件导入路径
新增模块:
- api/basic/: AstrBotConfig, BaseConversationManager, Conversation
- api/event/: AstrMessageEvent, AstrBotMessage, EventType, MessageType,
  MessageSession, EventResult 等核心事件类型
- api/message/: MessageChain 及所有消息组件 (Plain, At, Image, File 等)
- api/platform/: PlatformMetadata 平台元数据类型
- api/provider/: LLMResponse 提供者响应实体
- api/star/star.py: StarMetadata 插件元数据类型

更新模块:
- api/__init__.py: 导出所有子模块
- api/components/: 扩展 Command 兼容性
- api/event/filter.py: 增强 filter 装饰器兼容性
- context.py, decorators.py, events.py: 顶层兼容入口

测试更新:
- test_api_event_filter.py: 验证 filter 兼容性
- test_api_modules.py: 验证新模块可导入
- test_handler_dispatcher.py: 验证处理器分发

文档更新:
- AGENTS.md/CLAUDE.md: 添加兼容层设计说明,避免重复造轮子

设计原则:
- 兼容层通过 thin re-export 方式暴露旧版 API
- 不复制独立运行时逻辑,保持架构清晰
- 新版推荐使用顶层模块导入路径
2026-03-13 03:17:03 +08:00
whatevertogo
54b6ca7b7d 修正重要说明中的标点,确保新实现兼容旧实现并遵循良好设计原则 2026-03-13 02:54:34 +08:00
whatevertogo
6f1373ed32 feat: 添加重要说明,确保新实现兼容旧实现并遵循良好设计原则 2026-03-13 02:51:31 +08:00
whatevertogo
9d83fccafd feat: 添加新旧架构对比文档,详细说明各模块的功能和结构变化 2026-03-13 02:44:53 +08:00
whatevertogo
ca2beb79a2 feat: 添加新旧对比文档,详细说明各模块结构变化及功能缺失 2026-03-13 02:44:42 +08:00
whatevertogo
3c158760f9 feat: 添加协议模块及消息定义,详细说明新版协议与旧版的差异 2026-03-13 02:37:13 +08:00
whatevertogo
bfe5b21f6b feat: 添加新版 API 模块文档,详细说明与旧版的差异及缺失内容 2026-03-13 02:33:42 +08:00
whatevertogo
921223d3e9 feat: 添加客户端模块文档,详细说明各模块功能及与旧版的对比 2026-03-13 02:32:04 +08:00
whatevertogo
97ac3ee76b feat: 添加对 astrbot_sdk 第一层模块的测试,确保模块可导入及公共 API 正确导出 2026-03-13 02:28:15 +08:00
whatevertogo
59715cffa1 feat: 添加 API 模块的兼容层文档,提供旧版接口的说明和迁移指南 2026-03-13 02:24:00 +08:00
whatevertogo
4694f250ba Refactor tests and add integration tests for runtime module
- Added integration tests for the runtime module covering subprocess lifecycle, concurrency, and real-world scenarios in `test_runtime_integration.py`.
- Updated existing test files to include a blank line after module docstrings for consistency.
- Enhanced `test_protocol_legacy_adapter.py` with additional assertions for message output.
- Modified `test_transport.py` to use concrete transport implementations for abstract method tests.
- Improved test cases for handling timeouts and remote handler tracking in `test_timeout_handling.py` and `test_peer_remote_handlers.py`.
2026-03-13 02:18:36 +08:00
whatevertogo
d330b595de fix: 修复 LegacyConversationManager 和 Peer 的异步处理逻辑,确保正确处理取消和初始化事件 2026-03-13 02:18:26 +08:00
whatevertogo
024b043567 Merge branch 'refact1/refactsome' of https://github.com/united-pooh/astrbot-sdk into refact1/refactsome 2026-03-13 01:45:30 +08:00
whatevertogo
4cb7cbdf96 Add comprehensive tests for HandlerDispatcher and Plugin loading utilities
- Implement tests for HandlerDispatcher in `tests_v4/test_handler_dispatcher.py`, covering initialization, invocation, cancellation, argument building, result consumption, error handling, and handler execution.
- Introduce tests for Plugin loading functionalities in `tests_v4/test_loader.py`, including plugin specification, discovery, environment management, and loading components and handlers.
2026-03-13 01:45:28 +08:00
whatevertogo
280e32bfae feat: 添加旧版会话管理器的兼容实现,支持会话数据的存储、获取和删除功能
feat: 在内存客户端中添加精确获取记忆项的功能
feat: 在事件消息中添加字段约束验证,确保各阶段的字段符合要求
feat: 在 SupervisorRuntime 中注册 handler 时处理冲突并输出警告
2026-03-13 01:45:17 +08:00
united_pooh
f865b2b7e9 chore(runtime): 使用 ruff format 并为 peer 补充中文文档
- 运行 ruff format 统一代码格式
- 说明 Peer 在协议层中的命名含义
- 为 Peer 类及其所有方法补充中文注释型文档
2026-03-13 01:39:22 +08:00
whatevertogo
0159b008c3 Add unit tests for protocol messages and transport implementations
- Created `test_protocol_messages.py` to cover tests for protocol message models including ErrorPayload, PeerInfo, InitializeMessage, ResultMessage, InvokeMessage, EventMessage, CancelMessage, and the parse_message function.
- Implemented validation tests to ensure required fields and serialization behavior.
- Added `test_transport.py` to test the Transport base class and its implementations: StdioTransport and WebSocketTransport.
- Included tests for lifecycle methods, message handling, and error conditions in transport classes.
2026-03-13 01:17:23 +08:00
whatevertogo
055198336e feat: 添加测试用例,覆盖各个客户端的实现,包括 CapabilityProxy、DBClient、LLMClient、MemoryClient 和 PlatformClient 2026-03-13 01:06:06 +08:00
whatevertogo
9d9cd9dd6d feat: 添加测试用例,覆盖 API 装饰器、事件过滤器和遗留上下文的功能 2026-03-13 00:47:31 +08:00
whatevertogo
9bf831810d feat: 添加测试框架和相关测试用例,涵盖 API 装饰器、事件、上下文和传输通信 2026-03-13 00:29:12 +08:00
united_pooh
c3ccc2b5da style: 🎨 使用ruff对项目进行format 2026-03-13 00:17:59 +08:00
whatevertogo
0d01998637 feat: 添加 AstrBot SDK v4 架构与实现文档,包含目录、核心设计原则及模块详解 2026-03-13 00:07:44 +08:00
whatevertogo
b2d87df223 feat: 增强 LegacyContext 和 WorkerSession 的消息处理,支持更灵活的参数传递和连接关闭管理 2026-03-13 00:07:34 +08:00
whatevertogo
8922e1409c Refactor code structure for improved readability and maintainability 2026-03-12 23:24:35 +08:00
whatevertogo
488c91d758 feat: 在初始化失败时停止 Peer 实例并更新测试用例以验证关闭状态 2026-03-12 22:59:51 +08:00
whatevertogo
61eecd2024 feat: 添加对保留能力命名空间的检查,防止暴露注册 2026-03-12 22:56:27 +08:00
whatevertogo
db9cb169e4 feat: Enhance Supervisor and Worker Runtime with Internal Capabilities and Lifecycle Hooks
- Added internal capability for handler invocation in SupervisorRuntime.
- Implemented lifecycle hooks (on_start, on_stop) in Star class and PluginWorkerRuntime.
- Updated CapabilityRouter to support request_id in call and stream handlers.
- Refactored message handling in PeerRuntime to include request_id.
- Introduced tests for API contract, legacy adapter, and migration scenarios.
- Improved WebSocketServerTransport to manage connection state more effectively.
- Enhanced plugin loading and discovery to maintain compatibility with legacy systems.
2026-03-12 22:46:22 +08:00
whatevertogo
140344322b refactor: 移除重构架构设计文档中的冗余内容 2026-03-12 22:01:45 +08:00
whatevertogo
9d04cec8a4 feat: Implement Peer and Transport layers for asynchronous communication
- Added Peer class for managing peer-to-peer communication, including initialization, invocation, and cancellation of requests.
- Introduced Transport abstract base class with StdioTransport and WebSocketTransport implementations for message handling.
- Created Star class for error handling in event-driven architecture.
- Developed MemoryTransport for testing purposes, allowing in-memory communication between peers.
- Implemented unit tests for Peer functionality, protocol message parsing, and runtime integration with plugins.
- Established entry point tests to ensure package import and command-line interface functionality.
2026-03-12 21:42:46 +08:00
united_pooh
b7d4b647be test: add independent worker resource benchmark 2026-03-12 01:22:20 +08:00
united_pooh
166bf4254c feat: restore independent plugin workers 2026-03-11 23:10:02 +08:00
Soulter
a04d668cf6 refactor: update put_kv_data and get_kv_data methods in Context class to accept dictionary values 2025-11-27 18:10:21 +08:00
Soulter
21a7e742f1 refactor: update component registration method in Context class to use private method 2025-11-27 16:47:57 +08:00
Soulter
9e6888201a feat: add conversation management features and enhance message handling in the API 2025-11-17 11:01:31 +08:00
Soulter
87c2678ae1 feat: implement NewStar class and associated utilities for plugin runtime management 2025-11-12 22:22:22 +08:00
Soulter
1e384d0cd3 feat: enhance RPC handling with streaming support and notifications 2025-11-12 22:05:04 +08:00
Soulter
0760e9eacd feat: implement RPCRequestHelper and refactor StarRunner for improved RPC handling 2025-11-12 21:11:18 +08:00
Soulter
ff904bae8f feat: add README files for Context API and RPC communication; implement StarManager for plugin discovery 2025-11-12 20:49:57 +08:00
Soulter
0612133cdf perf: normalize call_context_function rpc method 2025-11-12 20:41:14 +08:00
Soulter
363fda5a69 feat: enhance context management with component registration and RPC function handling 2025-11-11 20:22:13 +08:00
Soulter
8b34403587 perf: non block 2025-11-11 19:55:56 +08:00
Soulter
70dbe2a567 refactor: streamline context management and websocket server setup; remove deprecated start_server module 2025-11-11 19:02:55 +08:00
Soulter
67cc4c5715 refactor: remove unused hello command, echo listener, and related tools; add CLI and context enhancements 2025-11-11 17:22:03 +08:00
Soulter
e982e7798d refactor: remove unused echo listener and hello tool; add HelloCommand in test_plugin 2025-11-11 00:27:29 +08:00
Soulter
bba9b721fd chore: initialize 2025-11-11 00:23:48 +08:00