Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,11 @@ and milestone verification gates.
keeps filesystem IO, worker runtime, `PathManager`, and port adapters until a
reviewed runtime migration exists.
- Remote-connect port baselines live in `bitfun-runtime-ports` and
`bitfun-services-integrations`; `AgentSubmissionPort` still rejects generic
attachments until image/multimodal equivalence tests and a runtime migration
plan are reviewed.
`bitfun-services-integrations`; tracker state and tracker event reduction
belong in `bitfun-services-integrations`, while core still owns dispatcher
assembly, session restore, terminal pre-warm, and product execution routing.
`AgentSubmissionPort` still rejects generic attachments until
image/multimodal equivalence tests and a runtime migration plan are reviewed.

### DeepReview guardrails

Expand Down
5 changes: 4 additions & 1 deletion docs/architecture/core-decomposition.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ Rust 编译和链接面。
| `bitfun-agent-tools` | 轻量 tool DTO / contract、runtime restriction、generic registry / provider container | partial:product manifest、`ToolUseContext`、`GetToolSpec` 和 concrete tools 仍在 core |
| `bitfun-tool-packs` | 由 feature group 隔离的具体工具实现 | target/scaffold:不得声明 concrete tools 已迁移 |
| `bitfun-services-core` | Config、session、workspace、storage、filesystem、system services | partial:部分 pure helper 已迁出;config/workspace/filesystem runtime 多数仍在 core |
| `bitfun-services-integrations` | Git、MCP、remote SSH、remote connect、file watch integrations | partial:MCP runtime 已迁入;remote SSH / remote-connect 仍只迁移低风险 contracts/helpers |
| `bitfun-services-integrations` | Git、MCP、remote SSH、remote connect、file watch integrations | partial:MCP runtime 已迁入;remote SSH 仍只迁移低风险 contracts/helpers;remote-connect 已拥有 wire DTO、request builder、tracker state 与 tracker event reduction,dispatcher/product execution 仍在 core |
| `bitfun-product-domains` | Miniapp 和 function-agent 产品子域 | partial:pure decision、port、storage layout 可迁入;IO、worker、Git/AI service runtime 仍在 core |
| `terminal-core` | 已有 terminal package,移动到 workspace 顶层 `src/crates/terminal` 路径 | done:已在 workspace 顶层 |
| `tool-runtime` | 已有 tool runtime,移动到 workspace 顶层路径 | done:已在 workspace 顶层 |
Expand Down Expand Up @@ -97,6 +97,9 @@ owner 边界,否则不要把一个 feature group 继续拆成更小的 crate
- remote runtime port baseline 当前只提供契约和 core-owned adapter:`AgentSubmissionPort`
仍拒绝 generic attachments;remote image DTO、turn cancellation、remote state 和 event facts
不等于 remote-connect runtime 或多模态执行路径已经迁移。
- remote-connect tracker state 可由 `bitfun-services-integrations` 拥有;core 只保留
`EventSubscriber` adapter、global dispatcher、session restore、terminal pre-warm 和实际
dialog submission routing。不要把 tracker state 回写到 core。
- `bitfun-core-types` 不得依赖 runtime manager、service crate、agent runtime、
app crate、Tauri、network client、process execution,或 `git2`、`rmcp`、`image`、
`tokio-tungstenite` 等重集成依赖。
Expand Down
9 changes: 5 additions & 4 deletions docs/plans/core-decomposition-plan.md
Original file line number Diff line number Diff line change
Expand Up @@ -975,13 +975,14 @@ product-full = ["git", "mcp", "remote-ssh", "remote-connect", "announcement", "f
- [x] 先迁移 `announcement` 的纯 types contract,scheduler / state store / content loader / remote fetch 仍保留在 core。
- [x] 先完成 `remote-connect` contract slice:remote chat/image/tool/session wire DTO 与 relay/bot session/submission request builder 由 `bitfun-services-integrations` 拥有,relay/bot session 创建通过 `AgentSubmissionPort`。
- [x] 已补齐 remote runtime 迁移前的第一层 port baseline:`SessionTranscriptReader`、`AgentTurnCancellationPort`、`RemoteControlStatePort`、`RuntimeEventSink` 与 remote image attachment/request DTO;完整 `remote-connect` runtime 仍需后续单独迁移并补 queue/event/image 行为等价测试。
- [x] `RemoteSessionStateTracker`、`TrackerEvent` 与 remote tool preview slimming helper 已迁入 `bitfun-services-integrations`;core 只保留 `EventSubscriber` adapter、dispatcher、session restore、terminal pre-warm 与实际 dialog submission routing。
- [x] 已迁移的集成能力保持 core 旧路径 re-export。
- [x] 产品完整 runtime 通过 `services-integrations/product-full` 启用已迁移集成能力。

**当前安全迁移状态(2026-05-13):**
**当前安全迁移状态(2026-05-15):**

- 已迁移到 `bitfun-services-integrations`:`service::file_watch`,通过 `file-watch` / `product-full` feature 启用,并保持 `core::service::file_watch` 旧路径。
- `git` 已完成 DTO/params/graph/raw command output/text parser/arg builder、`GitError`、`GitService` runtime implementation 与 git utils 迁移;`bitfun-core::service::git::*` 仅保留 legacy facade re-export。`remote-ssh` 已迁移纯 contract/type、workspace path/identity helper 与 unresolved-session-key helper;SSH runtime manager / fs / terminal、password vault 与 PathManager-backed session mirror assembly 仍保留在 core。`mcp` 已迁移 tool-name / tool-info / protocol types / config location / server type-status、server config、cursor-format、JSON-RPC request builder、JSON config format/validation helper、config merge / remote authorization helper、OAuth credential vault / authorization bootstrap contract、remote auth error classifier、legacy remote header fallback helper、transport Authorization 归一化 helper、remote client capability helper、rmcp 到 BitFun protocol 的纯映射 helper、resource/prompt adapter、catalog cache、list-changed/reconnect policy、config service save-load orchestration、server process / local-remote transport lifecycle、dynamic tool descriptor / provider / result rendering helper,并用 owner crate contract test 锁定 wire shape、transport default、validation message、Cursor 兼容格式、config precedence / dedup 语义、OAuth vault 存储路径注入、NeedsAuth 分类、旧 env Authorization fallback、remote client capabilities、remote result metadata / structured content 映射、config load/save/delete contract、unsupported remote transport contract、context resource selection 和 dynamic manifest;`bitfun-core` 继续负责 core `ConfigService` store adapter、OAuth data-dir 注入、`BitFunError` 映射、legacy facade 和全局 tool registry / manifest 组装。`announcement` 仅迁移了纯 types contract,scheduler / state store / content loader / remote fetch 仍保留在 core;`remote-connect` 已完成 contract/request-builder slice,并补齐 cancellation/state/event/image 第一层 port baseline,但远程消息执行、image context 真正接入、tracker event、terminal pre-warm 与 workspace/session restore 仍保留在 core。它们涉及 SSH runtime、remote agent submission runtime、product tool manifest/exposure owner 化与 announcement config/path 边界,继续前需要单独确认端口方案与等价性测试。
- `git` 已完成 DTO/params/graph/raw command output/text parser/arg builder、`GitError`、`GitService` runtime implementation 与 git utils 迁移;`bitfun-core::service::git::*` 仅保留 legacy facade re-export。`remote-ssh` 已迁移纯 contract/type、workspace path/identity helper 与 unresolved-session-key helper;SSH runtime manager / fs / terminal、password vault 与 PathManager-backed session mirror assembly 仍保留在 core。`mcp` 已迁移 tool-name / tool-info / protocol types / config location / server type-status、server config、cursor-format、JSON-RPC request builder、JSON config format/validation helper、config merge / remote authorization helper、OAuth credential vault / authorization bootstrap contract、remote auth error classifier、legacy remote header fallback helper、transport Authorization 归一化 helper、remote client capability helper、rmcp 到 BitFun protocol 的纯映射 helper、resource/prompt adapter、catalog cache、list-changed/reconnect policy、config service save-load orchestration、server process / local-remote transport lifecycle、dynamic tool descriptor / provider / result rendering helper,并用 owner crate contract test 锁定 wire shape、transport default、validation message、Cursor 兼容格式、config precedence / dedup 语义、OAuth vault 存储路径注入、NeedsAuth 分类、旧 env Authorization fallback、remote client capabilities、remote result metadata / structured content 映射、config load/save/delete contract、unsupported remote transport contract、context resource selection 和 dynamic manifest;`bitfun-core` 继续负责 core `ConfigService` store adapter、OAuth data-dir 注入、`BitFunError` 映射、legacy facade 和全局 tool registry / manifest 组装。`announcement` 仅迁移了纯 types contract,scheduler / state store / content loader / remote fetch 仍保留在 core;`remote-connect` 已完成 contract/request-builder slice,补齐 cancellation/state/event/image 第一层 port baseline,并迁出 tracker state / tracker event reduction / remote tool preview slimming helper,但远程消息执行、image context 真正接入、terminal pre-warm 与 workspace/session restore 仍保留在 core。它们涉及 SSH runtime、remote agent submission runtime、product tool manifest/exposure owner 化与 announcement config/path 边界,继续前需要单独确认端口方案与等价性测试。
- 最新主干的 Deep Review capacity / cost / queue、context profile、evidence ledger、session manifest、stream dedupe、search remote/fallback 与 session rollback persistence 仍属于 core runtime 或对应产品 runtime,不在本轮 `services-integrations` 迁移范围内;如果后续迁移 remote-connect / MCP / search / session,需要先定义运行状态 port 合约和等价测试。

**验证:**
Expand Down Expand Up @@ -1614,7 +1615,7 @@ P2 后产品表面契约轨道(contract-only):
- 保留边界:`bitfun-core` 只保留 core `ConfigService` store adapter、OAuth data-dir 注入、`BitFunError` 映射、legacy facade 和与全局 tool registry / manifest 的组装调用;配置写入、OAuth、SSE/session 与 registry / manifest 行为不得在本 PR 中改变。
- 后续切片:MCP concrete tool integration / product registry / manifest assembly 继续保留 dynamic provider metadata、工具清单顺序、expanded/collapsed exposure 和 snapshot wrapper 等价测试。
- 文档校正:P2 后补充文档中的 MCP runtime step 已由本 PR2 闭环;后续 MCP 相关工作只保留 concrete tool implementation 迁移或 product registry / manifest assembly,不再重复迁移 config/process/transport lifecycle。
3. 已完成:remote-connect port baseline:产品表面 DTO、remote chat/image/tool/session wire DTO、relay/bot session/submission request builder、remote image attachment/request DTO、`AgentTurnCancellationPort`、`RemoteControlStatePort` 和 `RuntimeEventSink` 已具备 owner/port 契约;完整 remote runtime 仍保留在 core
3. 已完成:remote-connect tracker owner slice:产品表面 DTO、remote chat/image/tool/session wire DTO、relay/bot session/submission request builder、remote image attachment/request DTO、`AgentTurnCancellationPort`、`RemoteControlStatePort`、`RuntimeEventSink`、`RemoteSessionStateTracker` 和 `TrackerEvent` 已具备 owner/port 契约;core 仍保留 dispatcher/product execution
- 后续切片:完整 remote-connect runtime 迁移必须单独执行,且先补 queue/event/image/cancel 等价测试,不得混入 tool/provider owner 化。
4. 已完成本轮可提交闭环:agent tools + `tool-packs` owner 化低风险部分。纯 tool contract/provider metadata、runtime restriction DTO、path resolution DTO、generic tool registry / dynamic provider container 已迁入 `bitfun-agent-tools`,并为 dynamic provider contract 提供 `agent-tools` 兼容 re-export;core tool runtime 保留产品完整工具列表、snapshot decorator、`dyn Tool` 适配、tool exposure / manifest resolution 和 `GetToolSpec` 按需工具说明发现。`ToolUseContext`、tool manifest/exposure 与 concrete tool implementation 按 feature group 外移需要新的 port/provider 设计,必须保持 builtin/readonly/dynamic manifest、expanded/collapsed exposure、prompt stub、unlock state、snapshot wrapping、runtime restrictions、cancellation 与 Deep Review tool flow 等价,作为后续高风险迁移单独审视。
5. `product-domains` runtime + core facade finalization:迁移 miniapp runtime/compiler/builtin 与 function-agent 运行逻辑,最后把 `bitfun-core` 收敛为 facade + product runtime assembly;不在本 PR 中修改 `bitfun-core default = []` 或 per-product feature matrix。
Expand Down Expand Up @@ -1722,7 +1723,7 @@ git diff -- package.json scripts/dev.cjs scripts/desktop-tauri-build.mjs scripts
11. 已提交:PR 2 `Services/Product Runtime Owner Closure`,收口 remote-SSH session identity / mirror path / unresolved-session layout 与 MiniApp storage file layout owner;core 保留 `PathManager` 注入、SSH manager、remote FS / terminal、MiniApp filesystem IO 和 worker runtime。
12. 历史已完成:MCP runtime 与 dynamic tools;已迁移 config service orchestration、server process / transport lifecycle、adapter、dynamic tool/resource/prompt provider,core 保留 ConfigService store adapter、OAuth data-dir 注入、BitFunError 映射、legacy facade 和 product registry / manifest assembly。
13. P2 后前置轨道:产品表面 contract-only 补强,可在后续 PR 第一组提交中处理;只允许 DTO/port、round-trip/no-op tests 和 boundary check,不实现 CLI/Desktop/Remote/ACP UI 或命令变更。
14. 已完成:remote-connect port baseline:产品表面 DTO 已以 contract-only 方式进入 `bitfun-core-types`;`bitfun-services-integrations` 的 `remote-connect` feature 拥有 remote chat/image/tool/session wire DTO、relay/bot session/submission request builderremote image attachment/request DTO;relay/bot 创建 session 通过 `AgentSubmissionPort`,取消、远程状态读取和事件事实已有 `runtime-ports` 契约。远程消息执行、image context 真正接入、tracker event、terminal pre-warm 与 workspace/session restore 仍保留在 `bitfun-core` product runtime assembly。
14. 已完成:remote-connect tracker owner slice:产品表面 DTO 已以 contract-only 方式进入 `bitfun-core-types`;`bitfun-services-integrations` 的 `remote-connect` feature 拥有 remote chat/image/tool/session wire DTO、relay/bot session/submission request builderremote image attachment/request DTO、tracker state 与 tracker event reduction;relay/bot 创建 session 通过 `AgentSubmissionPort`,取消、远程状态读取和事件事实已有 `runtime-ports` 契约。远程消息执行、image context 真正接入、terminal pre-warm 与 workspace/session restore 仍保留在 `bitfun-core` product runtime assembly。
15. 已完成:agent tools + `tool-packs` owner 化低风险闭环;tool contract / DTO、runtime restriction、path resolution、generic registry / dynamic provider container 已归属 `bitfun-agent-tools`,core 保留产品工具列表、snapshot decorator、`ToolUseContext` 和 concrete tool implementation,后续外移需单独 port/provider 设计。
16. 已完成:关键语义回归 baseline,不移动 runtime owner。覆盖 MCP config failure / catalog invalidation / 既有 list-changed helper / dynamic manifest、tool manifest / `GetToolSpec`、product-domains adapter equivalence、remote workspace search fallback 的 focused tests 或 snapshots。
17. 下一步:remote-connect runtime 迁移前快照。先基于当前 port baseline 记录 remote session restore、active turn、cancel、image context、tracker event、queue/event fanout 的输入输出和验证命令;证明等价后再移动 runtime owner,不能把 generic attachment guard 当作已接入多模态行为。
Expand Down
35 changes: 35 additions & 0 deletions scripts/check-core-boundaries.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -822,6 +822,26 @@ const forbiddenContentRules = [
regex: /\bpub struct SessionInfo\b/,
message: 'core remote-connect server must not redefine session info DTOs; use the integrations contract',
},
{
regex: /\bstruct TrackerState\b/,
message: 'core remote-connect server must not own tracker state; use the integrations tracker',
},
{
regex: /\bpub enum TrackerEvent\b/,
message: 'core remote-connect server must not redefine tracker events; use the integrations tracker',
},
{
regex: /\bpub struct RemoteSessionStateTracker\b/,
message: 'core remote-connect server must not own tracker state; use the integrations tracker',
},
{
regex: /\bfn make_slim_params\b/,
message: 'core remote-connect server must not own remote tool preview slimming; use the integrations helper',
},
{
regex: /\bmatch mobile_type\b/,
message: 'core remote-connect server must not own remote agent type alias mapping; use the integrations helper',
},
],
},
{
Expand Down Expand Up @@ -1807,6 +1827,16 @@ function runManifestParserSelfTest() {
'generic attachments',
],
},
{
path: 'src/crates/services-integrations/src/remote_connect.rs',
contracts: [
'RemoteSessionStateTracker',
'TrackerEvent',
'make_slim_tool_params',
'handle_agentic_event',
'resolve_remote_agent_type',
],
},
{
path: 'src/crates/core/src/agentic/tools/registry.rs',
contracts: ['register_all_tools', 'GetToolSpecTool', 'get_collapsed_tool_names'],
Expand Down Expand Up @@ -2227,6 +2257,11 @@ function runManifestParserSelfTest() {
'RemoteToolStatus',
'ActiveTurnSnapshot',
'SessionInfo',
'TrackerState',
'TrackerEvent',
'RemoteSessionStateTracker',
'make_slim_params',
'match mobile_type',
];
const remoteConnectRuleText = remoteConnectRule.patterns
.map((pattern) => pattern.regex.source)
Expand Down
Loading
Loading