feat: 统一日志系统——结构化滚动文件 + api.log 插件通道 + 73 个 IPC 通道追踪 + pi 事件/渲染层错误归档

This commit is contained in:
Rick Ye
2026-09-11 02:12:40 +08:00
parent 2ad1743e10
commit 8e4b5496e8
9 changed files with 332 additions and 98 deletions
+11
View File
@@ -14,6 +14,15 @@ export interface PluginStorage {
delete(key: string): void
}
/** 插件日志通道:宿主注入,写入统一日志文件(userData/logs/,带 pluginId 字段)。
* Agent 自诊断依赖该通道——插件应当把装载/激活/关键决策与失败都记到这里。 */
export interface PluginLogger {
debug(message: string, kv?: Record<string, unknown>): void
info(message: string, kv?: Record<string, unknown>): void
warn(message: string, kv?: Record<string, unknown>): void
error(message: string, kv?: Record<string, unknown>): void
}
/** harness 侧 UI 能力(Electron 版槽位,语义对位 pi TUI 的 ctx.ui.*)。
* 内联槽位全部数据驱动;插件页内 UI 由插件页自理,不经此 API。 */
export interface HarnessUiApi {
@@ -42,6 +51,8 @@ export interface HarnessPluginApi {
pi: ExtensionAPI
ui: HarnessUiApi
storage: PluginStorage
/** 结构化日志(scope=plugin,自动带 pluginId;error 级别会进日志文件) */
log: PluginLogger
manifest: PluginManifest
}