58 lines
2.6 KiB
C#
58 lines
2.6 KiB
C#
using System.Text.Json.Serialization;
|
||
|
||
namespace AgentWorker.WindowsRunner;
|
||
|
||
// actuate 协议扩展提案:在不动 observe 契约的前提下增加执行类操作。
|
||
// 设计原则与 observe 完全一致:单请求单响应、稳定错误码、宿主固定证据根目录。
|
||
// 本文件只新增类型;Program.cs 的分发改造见 PATCH-NOTES.md(diff 指引)。
|
||
//
|
||
// 与 observe 的关键差异(由 RPA 桌面驱动语义决定):
|
||
// 1. Action 携带具体执行参数(坐标/文本/命令),全部字段服务端可审计;
|
||
// 2. 坐标一律物理屏幕像素,与 RPA 驱动现状及 CoordinateSpace 契约一致;
|
||
// 3. WindowTitle 必须是 AllowedWindows 的精确成员(模糊匹配在 TS 宿主 observe 阶段完成解析),
|
||
// RPA 侧"标题包含匹配"的旧语义不进入原生层。
|
||
|
||
// 操作闭集:mouse_move / mouse_click / mouse_drag / mouse_scroll / mouse_move_smooth /
|
||
// keyboard_send / window_activate / window_set_state / window_set_bounds / window_close。
|
||
// 与 observe 相同:模型不能直接指定 HWND;证据目录来自宿主启动参数。
|
||
internal sealed record ActuateRequest(
|
||
int ProtocolVersion,
|
||
string RequestId,
|
||
string Operation,
|
||
string WindowTitle,
|
||
DesktopPolicy Policy,
|
||
ActuateAction Action);
|
||
|
||
// 每个字段都可被逐项审计;不支持的 Kind 由原生层拒绝,不静默降级为观察。
|
||
internal sealed record ActuateAction(
|
||
string Kind,
|
||
int? X,
|
||
int? Y,
|
||
int? ToX,
|
||
int? ToY,
|
||
// 滚轮 delta(120 的倍数,负值向下)或窗口 ShowWindow 命令值。
|
||
int? Amount,
|
||
// keyboard_send 文本;上限由 64 KiB 请求预算约束。
|
||
string? Text,
|
||
// keyboard_send 三模式:"clipboard"(粘贴)/ "chars"(逐字符)/ "keys"(整段 SendKeys)。
|
||
string? Mode,
|
||
int? IntervalMs,
|
||
bool? Double,
|
||
// "left"(默认)或 "right"。
|
||
string? Button,
|
||
// mouse_move_smooth:false=匀速直线,true/缺省=缓入缓出+抖动。
|
||
bool? Ease,
|
||
// mouse_move_smooth 速度 1-100(默认 35,与 RPA 驱动一致)。
|
||
int? Speed,
|
||
// window_set_bounds 用(x/y 复用 X/Y,Amount 不用)。
|
||
int? Width,
|
||
int? Height,
|
||
int? HoldMs,
|
||
int? ReleaseDelayMs,
|
||
int? SettleMs);
|
||
|
||
// 动作结果:证据前后各一张,宿主 TS 适配器按 EvidenceRef 逐项复核。
|
||
// Data 与 ErrorCode 互斥,与 RunnerResponse 同规则。
|
||
internal sealed record ActuateResult(string ActionKind, string CapturedAt,
|
||
ObservedWindow ObservedWindow, IReadOnlyList<EvidenceRef> Evidence, int DurationMs);
|