Files
isphere-ai-bridge/docs/superpowers/plans/2026-07-11-a-route-rpa-send.md
2026-07-11 11:16:53 +08:00

96 lines
4.9 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# A-Route RPA Send Implementation Plan
> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
**Goal:**`codex/a-route-rpa-send` 分支实现 A 方案:通过受控 UI Automation 路线让 `isphere_send_message` 能配置为真实 UI 写入并点击发送。
**Architecture:** Go MCP 继续保留稳定 `isphere_send_message` 接口、hash、idempotency、audit。新增 A-route connector 调用 C# `ISphereWinHelper` 的 UIA action opC# helper 根据窗口句柄、发送框 AutomationId、发送按钮 AutomationId 写入文本并点击。B-route sidecar 仍是主路线,但当前不可测时先实现 A-route 功能兜底。
**Tech Stack:** Go 1.23.4, github.com/modelcontextprotocol/go-sdk, Windows PowerShell, .NET Framework C# helper, Windows UI Automation.
## Global Constraints
- Repository root: `E:\coding\codex\isphere-ai-bridge`.
- Active branch: `codex/a-route-rpa-send`.
- Do not use `rg`; use `git ls-files`, `ag`, `grep -R`, or PowerShell commands.
- Local machine cannot log in; use synthetic WinForms/UIA verification for local tests.
- User explicitly removed human approval as a product gate for A-route; do not add approval IDs or approval queues in this plan.
- Keep audit redaction: do not store raw message body or raw idempotency key in committed docs/audit tests.
- Real UI action requires explicit env configuration; default MCP behavior remains preview/blocked.
---
## Task 1: Go connector must carry raw content to action connector
**Files:**
- Modify: `internal/tools/send_message_connector.go`
- Modify: `internal/tools/isphere_send_message.go`
- Modify: `internal/tools/isphere_send_message_test.go`
**Interfaces:**
- Produces: `SendMessageConnectorRequest.ContentText string` for connector execution only.
- Audit and response still omit raw content.
- [x] Write failing test proving injected connector receives raw `ContentText` while response/audit do not leak it.
- [x] Run focused test and confirm failure.
- [x] Add `ContentText` to normalized args and connector request.
- [x] Run focused send-message tests.
## Task 2: Go A-route UIA connector adapter
**Files:**
- Create: `internal/tools/send_message_uia_adapter.go`
- Create: `internal/tools/send_message_uia_adapter_test.go`
**Interfaces:**
- Produces: `type UiaSendMessageAdapterConfig struct { HelperPath string; TimeoutSeconds int; Hwnd string; SendEditorAutomationID string; SendButtonAutomationID string; Mode string }`.
- Produces: `NewUiaSendMessageConnector(config UiaSendMessageAdapterConfig, caller UiaHelperCaller) SendMessageConnector`.
- Helper op: `uia_send_message`.
- [x] Write failing tests for missing config and successful helper call using a fake helper caller.
- [x] Implement adapter request mapping.
- [x] Run focused adapter tests.
## Task 3: C# WinHelper UIA send action
**Files:**
- Create: `native/ISphereWinHelper/UiaSendAction.cs`
- Modify: `native/ISphereWinHelper/Program.cs`
- Modify: `scripts/verify-win-helper.ps1`
**Interfaces:**
- Helper op `uia_send_message` args: `hwnd`, `send_editor_automation_id`, `send_button_automation_id`, `content_text`, `content_sha256`, `target_ref`.
- Helper data: `action_mode="uia_send_message"`, `typed_text=true`, `clicked_ui=true`, `sent_message=true`, `content_sha256`, `target_ref`, `editor_found`, `button_found`.
- [x] Add synthetic WinForms verification that starts a form with `rtbSendMessage`, `btnSend`, invokes `uia_send_message`, and verifies button-click side effect in a label.
- [x] Implement `UiaSendAction` with ValuePattern/Win32 fallback and InvokePattern/click fallback.
- [x] Run `scripts\verify-win-helper.ps1`.
## Task 4: Wire A-route connector into MCP env config
**Files:**
- Modify: `internal/tools/isphere_send_message.go`
- Modify: `internal/mcpserver/server.go`
- Modify: `scripts/verify-go-mcp.ps1`
- Modify: `docs/go-mcp-runbook.md`
- Modify: `docs/current-status-card.md`
**Interfaces:**
- Env `ISPHERE_SEND_CONNECTOR_MODE=uia_rpa` enables A-route connector.
- Env `ISPHERE_SEND_UIA_HWND`, `ISPHERE_SEND_UIA_EDITOR_AUTOMATION_ID`, `ISPHERE_SEND_UIA_BUTTON_AUTOMATION_ID`, optional `ISPHERE_SEND_UIA_HELPER_PATH` configure the action.
- Default env remains no real send.
- [x] Add config loader and tests around production connector availability.
- [x] Keep standard smoke deterministic with env cleared.
- [x] Add server env routing test; helper synthetic UIA smoke covers the local write/click action.
- [x] Update docs with minimal usage.
## Task 5: Verification, commit, push
- [x] Run `git diff --check`.
- [x] Run `go test ./...`.
- [x] Run `go build ./cmd/isphere-mcp` then remove root binary.
- [x] Run `powershell -NoProfile -ExecutionPolicy Bypass -File scripts\verify-win-helper.ps1`.
- [x] Run `powershell -NoProfile -ExecutionPolicy Bypass -File scripts\verify-go-mcp.ps1`.
- [x] Commit and push branch `codex/a-route-rpa-send`.