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
366 changes: 132 additions & 234 deletions AGENTS-CN.md

Large diffs are not rendered by default.

461 changes: 135 additions & 326 deletions AGENTS.md

Large diffs are not rendered by default.

11 changes: 6 additions & 5 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,8 @@ in end-user `release` builds.

## Code Standards and Architecture Constraints

Use [`AGENTS.md`](AGENTS.md) as the canonical source for architecture-sensitive
rules, module boundaries, and the verification matrix. In contributor-facing
terms:
Use [`AGENTS.md`](AGENTS.md) as the canonical source for repository-wide rules,
layer boundaries, and how to choose verification. In contributor-facing terms:

- Logs are English-only and should stay useful, not noisy.
- User-visible copy should use the project i18n flow; do not share Web UI
Expand All @@ -109,7 +108,8 @@ terms:
- Tauri commands use `snake_case` command names and structured `request`
payloads.
- Product architecture, feature-boundary, dependency-boundary, and build-speed
work must follow `docs/architecture/product-architecture.md`.
work must follow `docs/architecture/product-architecture.md` and
`docs/architecture/rust-build-dependency-boundaries.md`.
- Feature-specific rules belong in the nearest module `AGENTS.md`.

## Key Contribution Focus Areas
Expand Down Expand Up @@ -190,7 +190,8 @@ Common local checks:
| Mobile web | `pnpm --dir src/mobile-web run type-check` |
| Rust shared runtime or services | Follow the nearest module `AGENTS.md`: one package/test target and the minimum required features |
| Desktop/Tauri integration | `cargo check -p openbitfun-desktop` |
| i18n resources or contract | use the matching i18n row in `AGENTS.md` |
| i18n resources | `pnpm run i18n:audit` |
| i18n contract or shared terms | `pnpm run i18n:generate && pnpm run i18n:contract:test && pnpm run i18n:audit` |

For UI changes, include screenshots or a short recording when helpful. If you
cannot run a relevant check, explain why in the PR and provide a lower-risk
Expand Down
10 changes: 6 additions & 4 deletions CONTRIBUTING_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ pnpm run e2e:test
`.openbitfun/desktop-dev/` 下。显式设置的数据目录环境变量仍优先生效;
`--shared-data` 保留为默认模式的兼容写法。

> 完整脚本列表见 [`package.json`](package.json)。agent 专用命令、验证与架构规则见 [`AGENTS.md`](AGENTS.md)。
> 完整脚本列表见 [`package.json`](package.json)。agent 专用命令、验证与架构规则见 [`AGENTS-CN.md`](AGENTS-CN.md)。

### 桌面端调试工具

Expand All @@ -90,14 +90,15 @@ DevTools;`Cmd/Ctrl + Shift + I` 切换 OpenBitFun 元素检查器,`Cmd/Ctrl

## 代码规范与架构约束

架构敏感规则、模块边界和验证矩阵以 [`AGENTS.md`](AGENTS.md) 为准。面向贡献者只需把握:
仓库级规则、分层边界和验证选择方式以 [`AGENTS-CN.md`](AGENTS-CN.md) 为准。面向贡献者只需把握:

- 日志只使用英文,并保持必要、可读。
- 用户可见文案走项目 i18n 流程;不要把 Web UI locale catalog 共享给较小产品形态。
- shared core 必须保持平台无关;Desktop/Tauri 细节属于 app adapter,并通过类型化能力接口回流;需要事件投递时使用已有生产 transport adapter。
- Tauri command 使用 `snake_case` 命令名和结构化 `request` 参数。
- core 拆解、feature 边界、依赖边界和构建提速重构必须遵循
`docs/architecture/product-architecture.md`。
`docs/architecture/product-architecture.md` 和
`docs/architecture/rust-build-dependency-boundaries.md`。
- 功能级规则应放在离代码最近的模块 `AGENTS.md` 中。

## 重点关注的贡献方向
Expand Down Expand Up @@ -174,7 +175,8 @@ Repository Object Sizes 检查会拒绝超过 5 MiB 的 Git 文件对象,包
| Mobile web | `pnpm --dir src/mobile-web run type-check` |
| Rust 共享 runtime 或 services | 遵循最近模块的 `AGENTS.md`,选择单个包/测试目标和最小所需 feature |
| Desktop/Tauri 集成 | `cargo check -p openbitfun-desktop` |
| i18n 资源或契约 | 使用 `AGENTS.md` 中匹配的 i18n 验证行 |
| i18n 资源 | `pnpm run i18n:audit` |
| i18n 契约或共享术语 | `pnpm run i18n:generate && pnpm run i18n:contract:test && pnpm run i18n:audit` |

UI 改动在有帮助时附截图或短录屏。无法运行相关检查时,在 PR 中说明原因,并提供风险更低的手动验证路径。

Expand Down
65 changes: 41 additions & 24 deletions docs/architecture/computer-use-control.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,19 +156,35 @@ background input.

## Ownership and execution

Portable DTOs and `AppInputAction` live in `tool-contracts`; the host port lives in
Core. Desktop owns native resources and platform adapters. Assembly must not own
OS APIs, native focus workarounds or concrete capture implementations.

The shared action catalog and structural target validation live in
`tool-contracts`. Desktop's `control_session/admission.rs` is a deterministic
owner/mode/lease state machine; its facade alone performs native cleanup and
carries tokens across workers. `desktop_host/observation.rs` coordinates native
reads, while `observation_cache.rs` stores bounded references without owning input
permission. `computer_use_geometry` adapts the independent `computer-use-rust`
project's image/content/surface mapping for all three platforms. The reference
project's macOS-only capture/input and standalone MCP/session shell are not a
replacement for the existing Windows, Linux or product runtime providers.
This section details the split stated in
[Native provider ownership](#native-provider-ownership). Core does not depend on
`services/computer-use`; it reaches the provider only through the injected port.

| Owner | Owns | Must not |
|---|---|---|
| `tool-contracts` (`computer_use*` modules) | Portable DTOs, `AppInputAction` and its structural target validation, the shared action catalog (`ControlActionPolicy`), control and permission facts, `CaptureGeometry`, the settle decision and the `ComputerUseHost` port | Hold OS handles or make permission decisions |
| `services/computer-use` | Native resources and platform adapters for Windows, macOS and Linux: capture, AX/UIA/AT-SPI, input, OS permission probes and requests, remembered grants, the control session and `NativeComputerUseHost`; `host_runtime` holds CLI graphical-session admission and the macOS main run loop | Import Core, Tauri or the CLI, or discover Core config |
| Core (Assembly) | The ComputerUse tool and its permission policy, the `computer_use_program` executor, the `ai.computer_use_enabled`, missing-provider and remote-workspace gates, and release of a turn's control through the port; its `computer_use_host` module only re-exports that port | Own OS APIs, native focus workarounds or concrete capture implementations |
| Desktop | Provider injection and its diagnostic directory, the Tauri status, permission, sharing and preview commands, and the devtools-only full Tool fixtures | Reintroduce a native implementation |
| CLI | Provider injection and its diagnostic directory for chat/exec inside a graphical login session, the main-thread run-loop adapter and the `computer-use` command | Reintroduce a native implementation, or infer a provider for Dispatch, ACP or the stdio server |

Service paths below are relative to
`src/crates/services/computer-use/src/computer_use/`.
`control_session/admission.rs` is a deterministic owner/mode/lease state machine
with no OS handles; its facade `control_session.rs` alone performs native
cleanup and carries tokens across workers. `desktop_host/` implements the port
for `NativeComputerUseHost`. The directory kept its name when it moved out of
the Desktop app; Desktop and CLI share it. `desktop_host/observation.rs`
coordinates native reads, while `observation_cache.rs` stores bounded references
without owning input permission. The
[Native Computer Use guide](../../src/crates/services/computer-use/AGENTS.md)
has the full module map.

`tool-contracts::computer_use_geometry` adapts the independent
`computer-use-rust` project's image/content/surface mapping for all three
platforms. The reference project's macOS-only capture/input and standalone
MCP/session shell are not a replacement for the existing Windows, Linux or
product runtime providers.

### Reference implementation migration

Expand All @@ -178,8 +194,8 @@ runtime, build, test or filesystem dependency of OpenBitFun.

| Area | Reference source | OpenBitFun owner and adaptation |
|---|---|---|
| Permission query/request | `src/native/permissions.rs`, native permission probes | `computer_use_permissions` contracts, Desktop `permissions.rs`, `ComputerUsePermissions.tsx`; four separate read-only probes and explicit request receipts; Windows capability/UIPI facts and Linux AT-SPI/session consent replace macOS-specific assumptions |
| App sharing and control grants | `src/sharing.rs`, `src/grants.rs`, sharing controls in `src/gui.rs` | Admission state machine plus Desktop `sharing.rs`, `shared_preview.rs`, `process_identity.rs`, `grants.rs`, `share_grants.rs`; user-selected native window, observe first, separate revocable grant, executable-bound remembered preference, manual preview gestures |
| Permission query/request | `src/native/permissions.rs`, native permission probes | `computer_use_permissions` contracts, native service `permissions.rs`, Web `ComputerUsePermissions.tsx`; four separate read-only probes and explicit request receipts; Windows capability/UIPI facts and Linux AT-SPI/session consent replace macOS-specific assumptions |
| App sharing and control grants | `src/sharing.rs`, `src/grants.rs`, sharing controls in `src/gui.rs` | Admission state machine plus native service `sharing.rs`, `shared_preview.rs`, `process_identity.rs`, `grants.rs`, `share_grants.rs`; user-selected native window, observe first, separate revocable grant, executable-bound remembered preference, manual preview gestures |
| Coordinate conversion | `CoordinateMap` in `src/sharing.rs` | Portable `CaptureGeometry` and Web `previewGeometry.ts`; image/content/global/preview round trips, aspect fit, negative origins, independent X/Y scales, strict padding rejection and immutable screenshot identity |
| Virtual mouse | `src/cursor.rs`, GUI cursor rendering | Web `VirtualCursor.ts` ports the deterministic physical model, rendered by `PreviewCursor.tsx`; 63 Rust-generated reference samples cover movement, retargeting, immediate placement, resize and visibility. Existing passive native overlays remain platform adapters |
| Background control | Native directed/semantic input and desktop-state comparison | Existing AX/UIA/AT-SPI and directed-input providers plus `background_guard.rs`; diagnostic focus/pointer/window-order evidence, explicit unsupported routes, no restore or replay. Concurrent human input does not revoke Agent control. The reference's implicit Command modifier is not copied because it changes the requested click |
Expand Down Expand Up @@ -407,15 +423,16 @@ until the next information boundary and reuses the returned observation. It does
not reduce the user's selected reasoning effort or impose step/retry-count caps.

`get_app_state`, `app_batch` and single app-input aliases accept optional
`include_image` (default `true`). With `false`, Desktop reads AX and refreshes
observation/node identities without retrieving or encoding a model screenshot.
This is suitable for sufficient semantic state or known keyboard flows. Canvas,
visual verification and selecting image coordinates still need an image-bearing
observation. Target preparation, control leases, cancellation and native consent
remain unchanged; AX-only is not a different input route. Legacy port providers
can retain their old capture path and omit the image from its result. Existing
callers/persisted tool calls omit the field and retain their previous behavior.
The option is local tool presentation, not a new remote GUI capability.
`include_image` (default `true`). With `false`, the native provider reads AX and
refreshes observation/node identities without retrieving or encoding a model
screenshot. This is suitable for sufficient semantic state or known keyboard
flows. Canvas, visual verification and selecting image coordinates still need an
image-bearing observation. Target preparation, control leases, cancellation and
native consent remain unchanged; AX-only is not a different input route. Legacy
port providers can retain their old capture path and omit the image from its
result. Existing callers/persisted tool calls omit the field and retain their
previous behavior. The option is local tool presentation, not a new remote GUI
capability.

Program receipts include `observation_elapsed_ms` alongside per-step and total
elapsed time. These measure host execution, not model reasoning or end-to-end
Expand Down
Loading
Loading