Commit Graph

30 Commits

Author SHA1 Message Date
whatevertogo
3d5c8f7ff7 feat(protocol): 优化协议模块导出,确保根目录专注于原生 v4 模型,遗留适配器从子模块显式导入 2026-03-13 06:34:57 +08:00
whatevertogo
a93f267d8a feat(loader): enhance plugin import handling and legacy compatibility
- Updated `import_string` to evict conflicting cached top-level plugin packages, ensuring proper isolation of plugins with the same package names.
- Preserved the order of legacy handler declarations in `_iter_discoverable_names` to maintain expected behavior for legacy plugins.
- Added tests to verify the isolation of top-level packages and the preservation of handler declaration order.
- Improved module cleanup in tests to prevent conflicts between plugins.
2026-03-13 06:32:26 +08:00
whatevertogo
4b6e20468b feat: 更新文档和代码,优化运行时模块的导出,确保高级原语的稳定性和兼容性 2026-03-13 06:23:00 +08:00
whatevertogo
9c5ecf0a13 feat: Enhance plugin capability support and legacy compatibility
- Introduced LoadedCapability class to manage plugin capabilities.
- Updated load_plugin function to discover and load capabilities alongside handlers.
- Enhanced Peer class to handle remote provided capabilities during initialization.
- Added tests for capability registration and invocation in legacy plugins.
- Improved MessageChain and message component handling in legacy plugins.
- Added comprehensive tests for legacy plugin integration and compatibility.
- Updated protocol messages to include provided capabilities in initialization.
- Enhanced top-level module imports to include capability-related functions.
2026-03-13 06:16:57 +08:00
whatevertogo
d7aa75aff0 fix: 优化配置值规范化逻辑,确保类型检查更为严谨 2026-03-13 05:48:58 +08:00
whatevertogo
72d600679f feat: 更新遗留 API,支持标量 JSON 值和兼容性文档,增强消息组件和事件过滤器功能 2026-03-13 05:44:01 +08:00
whatevertogo
96ea836edc feat: Enhance legacy API with message chain support and new context handling
- Updated `LegacyContext.send_message` to handle rich message chains using `send_chain`.
- Introduced `LegacyStar` class for backward compatibility with legacy plugins.
- Added `register` decorator for legacy plugin metadata.
- Enhanced `MessageChain` class with `to_payload` and `is_plain_text_only` methods.
- Updated `AstrMessageEvent.send` method to utilize `send_chain` for rich messages.
- Implemented `send_chain` method in `PlatformClient` for sending complex message structures.
- Added capability routing for `platform.send_chain`.
- Introduced tests for new functionality, ensuring compatibility with legacy plugins and message handling.
2026-03-13 05:34:14 +08:00
whatevertogo
9d05934d53 feat: 添加稳定错误码常量,重构能力描述符以使用协议模式,更新相关测试用例 2026-03-13 04:46:00 +08:00
whatevertogo
a106354e20 feat: 更新文档和代码,移除过时注释,增强兼容性和错误处理,添加新测试用例 2026-03-13 04:39:12 +08:00
whatevertogo
7d0802fb9e feat: 更新运行时模块,增强 Peer 和 HandlerDispatcher 功能,优化插件加载和请求处理逻辑,添加新测试用例 2026-03-13 04:28:07 +08:00
whatevertogo
8ebf5489b6 feat: 更新协议模块,增强 v4 协议适配器和消息解析功能,添加新测试用例 2026-03-13 04:15:43 +08:00
whatevertogo
ae5d6dc692 feat: 增强 v4 客户端功能,添加内存获取和错误处理,更新文档和测试用例 2026-03-13 04:02:07 +08:00
whatevertogo
298ccf7437 feat: 更新调度触发器以支持别名,优化 Peer 类的关闭逻辑,增强插件发现功能 2026-03-13 03:48:43 +08:00
whatevertogo
4627276187 feat: 更新文档和测试,确保 LegacyContext 共享和兼容性 2026-03-13 03:42:16 +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
97ac3ee76b feat: 添加对 astrbot_sdk 第一层模块的测试,确保模块可导入及公共 API 正确导出 2026-03-13 02:28:15 +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
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
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
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
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