Conversation
## 核心改进 ### 1. 流式 Hooks 支持 (Precheck + Tee) - 新增 shouldProcessRequest/shouldProcessResponse precheck 方法 - 插件可声明是否需要处理请求/响应 body - 框架根据 precheck 结果决定是否 tee stream - 所有 5 个插件已实现 precheck 方法 ### 2. v7 分表数据库架构 (破坏性更新) - 主表 requests: 只存元数据,列表查询极快 - request_headers: 按 stage 存储各阶段 headers - request_bodies: 存储 BLOB 格式的 body (不再 base64 编码) - hook_layers: 记录每个插件的处理层 - 新增 plugin_info TEXT 字段存储插件信息 JSON ### 3. 插件信息持久化 - 从 headers 中解析 pluginInfo 并存入数据库 - 列表查询时返回 pluginInfo,刷新后仍可见 - 支持请求和响应 headers 中的插件信息 ### 4. 兼容层 - createProxyRequest/updateProxyRequest 保持旧接口 - 自动从 headers 解析 plugin_info - 自动处理 BLOB <-> Buffer 转换 ## 文件变更 新增: - src/lib/db-schema-v7.ts - v7 分表 schema - src/lib/db-requests-v7.ts - 数据库 API + 兼容层 - tests/db-init.test.ts - 数据库初始化测试 - tests/db-requests-v7.test.ts - SSE 流式测试 修改: - packages/proxy-plugin/src/types.ts - 新增 PrecheckResult 类型 - packages/proxy-plugin-*/src/plugin.ts - 实现 precheck 方法 - src/proxy-server.ts - 流式处理 + tee 逻辑 - src/lib/hooks-executor.ts - precheck 方法 - src/lib/db.ts - 使用 v7 schema ## 测试 390 tests passing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
核心改进
1. 流式 Hooks 支持 (Precheck + Tee)
shouldProcessRequest/shouldProcessResponseprecheck 方法2. v7 分表数据库架构 (破坏性更新)
requests主表: 只存元数据,列表查询极快request_headers: 按 stage 存储各阶段 headersrequest_bodies: 存储 BLOB 格式的 body (不再 base64 编码)hook_layers: 记录每个插件的处理层plugin_info TEXT字段存储插件信息 JSON3. 插件信息持久化
pluginInfo并存入数据库pluginInfo,刷新后仍可见4. 兼容层
createProxyRequest/updateProxyRequest保持旧接口plugin_info文件变更
新增:
src/lib/db-schema-v7.ts- v7 分表 schemasrc/lib/db-requests-v7.ts- 数据库 API + 兼容层tests/db-init.test.ts- 数据库初始化测试tests/db-requests-v7.test.ts- SSE 流式测试修改:
packages/proxy-plugin/src/types.ts- 新增PrecheckResult类型packages/proxy-plugin-*/src/plugin.ts- 实现 precheck 方法src/proxy-server.ts- 流式处理 + tee 逻辑src/lib/hooks-executor.ts- precheck 方法src/lib/db.ts- 使用 v7 schema测试
✅ 390 tests passing
注意
这是破坏性更新,需要清空旧数据库或等待自动迁移。