这次提交的标题 ### Changes made to the code/files: Title: Remove PHP dependencies and refactor UI rendering to pure HTML templates Key features implemented: - Refactored dashboard plugin to remove PHP dependency and implement pure HTML/CSS/JS template rendering - Updated log-terminal plugin to replace PHP-based UI with native Python HTML template generation - Modified package manager plugin to eliminate PHP view files and use direct HTML string construction - Removed all PHP view template files across dashboard, log-terminal, and package manager plugins - Updated .gitignore to include additional build artifacts and environment files - Enhanced dashboard with real-time metrics, system information, and network statistics without external PHP processing The overall change migrates the system from requiring PHP for UI rendering to using pure Python-based HTML template generation, simplifying deployment and removing external dependencies.
plugin-bridge 插件桥接器
提供插件间的事件共享、广播、桥接和 RPC 服务调用。
功能
- 事件总线: 插件间共享事件(发布/订阅)
- 广播: 向多个插件发送消息
- 桥接: 将不同插件的事件互相映射
- RPC 服务调用: 插件 A 调用插件 B 的方法并获取返回值
事件总线(发布/订阅 + 解耦)
bridge = plugin_mgr.get("plugin-bridge")
bus = bridge.event_bus
# 订阅事件(发布者和订阅者解耦)
bus.on("http.request", lambda event: print(f"收到请求: {event.payload}"))
# 发布事件
bus.emit(BridgeEvent(
type="http.request",
source_plugin="http-api",
payload={"path": "/api/users"}
))
RPC 服务调用
# 插件 B 注册服务
bridge.services.register("plugin-b", "get_user", lambda user_id: {"id": user_id, "name": "test"})
# 插件 A 调用插件 B 的服务
result = bridge.services.call("plugin-b", "get_user", 123)
print(result) # {"id": 123, "name": "test"}
广播
broadcast = bridge.broadcast
# 创建频道
broadcast.create_channel("system", ["lifecycle", "metrics"])
# 广播消息
broadcast.broadcast("system", {"action": "shutdown"}, "plugin-loader")
桥接
bridge_mgr = bridge.bridge
# 创建桥接:将 http-api 的事件映射到 metrics
bridge_mgr.create_bridge(
name="http-to-metrics",
from_plugin="http-api",
to_plugin="metrics",
event_mapping={
"http.request": "metrics.http_request",
"http.error": "metrics.http_error",
}
)
事件历史
# 查询历史
history = bus.get_history("http.request")
# 清空历史
bus.clear_history()