mirror of
https://github.com/kunkundi/crossdesk.git
synced 2026-11-07 06:39:10 +08:00
[feat] acknowledge remote input and wait for visual changes
This commit is contained in:
@@ -296,6 +296,16 @@ export function createServer(
|
||||
},
|
||||
{ ui: true },
|
||||
);
|
||||
add(
|
||||
"crossdesk_wait",
|
||||
z.strictObject({ session_id: id, observation_id: id,
|
||||
condition: z.enum(["changed", "stable"]),
|
||||
stable_ms: z.int().min(100).max(5000).default(500),
|
||||
timeout_ms: z.int().min(0).max(25000).default(5000) }),
|
||||
"Wait for the observed screenshot region to change or remain stable. Returns matched, wait_timed_out and a fresh screenshot on success. A visual condition can be checked after an action with a separate screenshot observation. Remote input receipts report native input acceptance; verify the application's intended result visually.",
|
||||
async (p, ctx) => output(await sessions.waitFor(p, ctx.mcpReq.signal)),
|
||||
{ readOnly: true },
|
||||
);
|
||||
add(
|
||||
"crossdesk_set_control",
|
||||
z.strictObject({ session_id: id, enabled: z.boolean() }),
|
||||
|
||||
@@ -459,6 +459,13 @@ export class Sessions {
|
||||
}
|
||||
return result;
|
||||
}
|
||||
async waitFor(p: Data, signal?: AbortSignal): Promise<Data> {
|
||||
const { session_id, ...args } = p;
|
||||
const result = await this.session(session_id).native.request(
|
||||
"wait_frame", args, (args.timeout_ms ?? 5000) + 3000, signal);
|
||||
if (result.matched) result.observation = await this.screenshot({ session_id }, signal);
|
||||
return result;
|
||||
}
|
||||
async control(id: string, enabled: boolean) {
|
||||
if (!enabled) this.cancelUnlock(this.session(id));
|
||||
return this.session(id).native.request("control", { enabled });
|
||||
|
||||
Reference in New Issue
Block a user