@copylee/dsh-computer-use 0.14.1 → 0.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/helper/Native.cs +9 -2
- package/helper/Overlay.cs +210 -54
- package/helper/Program.cs +1 -0
- package/helper/Uia.cs +40 -7
- package/lib/index.js +245 -52
- package/lib/types/computer.d.ts +27 -6
- package/lib/types/diagnostics.d.ts +10 -0
- package/lib/types/helper-client.d.ts +1 -0
- package/lib/types/overlay.d.ts +3 -0
- package/lib/types/routes.d.ts +5 -1
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -1270,9 +1270,10 @@ var OverlayController = class {
|
|
|
1270
1270
|
if (controlSignal?.aborted) onControlAbort();
|
|
1271
1271
|
else controlSignal?.addEventListener("abort", onControlAbort, { once: true });
|
|
1272
1272
|
this.waitSkippers.add(skip);
|
|
1273
|
-
this.helper.call("overlay_waiting", { waiting: true }).
|
|
1273
|
+
const ready = this.helper.call("overlay_waiting", { waiting: true }, 2e3).then(() => {}, () => {});
|
|
1274
1274
|
return {
|
|
1275
1275
|
signal: ctrl.signal,
|
|
1276
|
+
ready,
|
|
1276
1277
|
skipped: () => wasSkipped && !signal.aborted && !wasStopped,
|
|
1277
1278
|
controlStopped: () => wasStopped,
|
|
1278
1279
|
done: () => {
|
|
@@ -1285,6 +1286,14 @@ var OverlayController = class {
|
|
|
1285
1286
|
}
|
|
1286
1287
|
};
|
|
1287
1288
|
}
|
|
1289
|
+
/** Mark that the computer-use tool finished and we are now waiting for the LLM API response. */
|
|
1290
|
+
awaitingModel(agent) {
|
|
1291
|
+
if (!this.visible || this.paused || this.stopping) return;
|
|
1292
|
+
if (agent !== void 0 && this.agent !== void 0 && agent !== this.agent) return;
|
|
1293
|
+
this.thinking = "";
|
|
1294
|
+
this.reply = "";
|
|
1295
|
+
this.helper.call("overlay_phase", { phase: "llm" }).catch(() => {});
|
|
1296
|
+
}
|
|
1288
1297
|
recordUserAction(action) {
|
|
1289
1298
|
const prev = this.userActions.at(-1);
|
|
1290
1299
|
if (action.kind === "type" && prev?.kind === "type" && prev.exe === action.exe && prev.role === action.role && prev.name === action.name && action.at - prev.at < 8e3) {
|
|
@@ -1366,6 +1375,7 @@ var OverlayController = class {
|
|
|
1366
1375
|
this.cardOpacity = settings.cardOpacity;
|
|
1367
1376
|
await this.helper.call("card_opacity", { opacity: settings.cardOpacity }).catch(() => {});
|
|
1368
1377
|
}
|
|
1378
|
+
this.helper.call("overlay_phase", { phase: "tool" }).catch(() => {});
|
|
1369
1379
|
await this.status(status);
|
|
1370
1380
|
}
|
|
1371
1381
|
async start(agent, status, settings) {
|
|
@@ -1436,6 +1446,7 @@ var OverlayController = class {
|
|
|
1436
1446
|
if (frame.type === "start") {
|
|
1437
1447
|
this.thinking = "";
|
|
1438
1448
|
this.reply = "";
|
|
1449
|
+
if (this.visible && agent === this.agent) this.helper.call("overlay_phase", { phase: "llm" }).catch(() => {});
|
|
1439
1450
|
this.schedulePush();
|
|
1440
1451
|
return;
|
|
1441
1452
|
}
|
|
@@ -1444,6 +1455,7 @@ var OverlayController = class {
|
|
|
1444
1455
|
if (!chunk) return;
|
|
1445
1456
|
if (chunk.type === "text-delta" && chunk.text) {
|
|
1446
1457
|
if (this.visible && this.agent && agent === this.agent && !this.paused && !this.stopping) {
|
|
1458
|
+
this.helper.call("overlay_phase", { phase: "" }).catch(() => {});
|
|
1447
1459
|
if (this.settings().hostWindow === "pet") {
|
|
1448
1460
|
this.reply = plainLine(this.reply + chunk.text).slice(-300);
|
|
1449
1461
|
this.schedulePush();
|
|
@@ -1455,6 +1467,7 @@ var OverlayController = class {
|
|
|
1455
1467
|
return;
|
|
1456
1468
|
}
|
|
1457
1469
|
if (chunk.type !== "reasoning-delta" || !chunk.text) return;
|
|
1470
|
+
if (this.thinking === "" && this.visible && agent === this.agent) this.helper.call("overlay_phase", { phase: "" }).catch(() => {});
|
|
1458
1471
|
this.reply = "";
|
|
1459
1472
|
this.thinking = plainLine(this.thinking + chunk.text).slice(-300);
|
|
1460
1473
|
this.schedulePush();
|
|
@@ -1736,6 +1749,8 @@ const ACTIONS = [
|
|
|
1736
1749
|
"cursor_position",
|
|
1737
1750
|
"ui_action"
|
|
1738
1751
|
];
|
|
1752
|
+
/** Controls whose labels indicate non-idempotent/destructive actions: never auto-retry via physical click after UIA invoke. */
|
|
1753
|
+
const NON_IDEMPOTENT_CONTROL = /\b(submit|delete|remove|pay|checkout|purchase|send|confirm|transfer|order)\b|提交|删除|移除|支付|付款|下单|转账|确认删除|清空|发送/i;
|
|
1739
1754
|
/** Actions that change something on screen and deserve a fresh screenshot. */
|
|
1740
1755
|
const MUTATING = /* @__PURE__ */ new Set([
|
|
1741
1756
|
"left_click",
|
|
@@ -1785,8 +1800,10 @@ var Computer = class Computer {
|
|
|
1785
1800
|
heldButton = false;
|
|
1786
1801
|
/** Dimensions of the latest full-display screenshot shown to the model (keeps coordinate conversion exact across detail modes). */
|
|
1787
1802
|
lastShot;
|
|
1788
|
-
/** Recent click locations (repeat counter + auto physical-click fallback if a UIA invoke had no effect). */
|
|
1803
|
+
/** Recent click locations (repeat counter + scoped auto physical-click fallback if a UIA invoke had no effect). */
|
|
1789
1804
|
clickHistory = [];
|
|
1805
|
+
/** Rolling per-phase timing samples (settle + screenshot) for diagnostics & performance profiling. */
|
|
1806
|
+
phaseSamples = [];
|
|
1790
1807
|
/** The agent that last wrote the clipboard; when it goes idle the user's clipboard comes back. */
|
|
1791
1808
|
clipboardAgent;
|
|
1792
1809
|
/** Single-machine desktop control lease preventing concurrent sessions from colliding. */
|
|
@@ -2009,7 +2026,7 @@ var Computer = class Computer {
|
|
|
2009
2026
|
}) ?? "unchanged";
|
|
2010
2027
|
}
|
|
2011
2028
|
/** Record a click position and return how many times this spot (±24 px) was clicked in the last 2 minutes. */
|
|
2012
|
-
noteClick(point, helperRepeat, via = "physical") {
|
|
2029
|
+
noteClick(point, helperRepeat, via = "physical", meta) {
|
|
2013
2030
|
const now = Date.now();
|
|
2014
2031
|
while (this.clickHistory.length > 0 && now - this.clickHistory[0].at > REPEAT_WINDOW_MS) this.clickHistory.shift();
|
|
2015
2032
|
let local = 0;
|
|
@@ -2018,23 +2035,55 @@ var Computer = class Computer {
|
|
|
2018
2035
|
x: point.x,
|
|
2019
2036
|
y: point.y,
|
|
2020
2037
|
at: now,
|
|
2021
|
-
via
|
|
2038
|
+
via,
|
|
2039
|
+
...meta?.session ? { session: meta.session } : {},
|
|
2040
|
+
...meta?.hwnd !== void 0 ? { hwnd: meta.hwnd } : {},
|
|
2041
|
+
...meta?.name ? { name: meta.name } : {}
|
|
2022
2042
|
});
|
|
2023
2043
|
for (const entry of this.clickHistory) if (Math.abs(entry.x - point.x) <= REPEAT_RADIUS_PX && Math.abs(entry.y - point.y) <= REPEAT_RADIUS_PX) local++;
|
|
2024
2044
|
}
|
|
2025
2045
|
return typeof helperRepeat === "number" && Number.isFinite(helperRepeat) && helperRepeat > 0 ? helperRepeat : local;
|
|
2026
2046
|
}
|
|
2027
|
-
/**
|
|
2028
|
-
|
|
2047
|
+
/**
|
|
2048
|
+
* Whether this spot (±24 px) in the same session & window was recently invoked via UIA
|
|
2049
|
+
* (and is NOT a non-idempotent submit/delete/pay button), so a retry upgrades to physical click.
|
|
2050
|
+
*/
|
|
2051
|
+
hadRecentUiaClickAt(point, session, hwnd, windowMs = 3e4) {
|
|
2029
2052
|
if (!point) return false;
|
|
2030
2053
|
const now = Date.now();
|
|
2031
2054
|
for (let i = this.clickHistory.length - 1; i >= 0; i--) {
|
|
2032
2055
|
const entry = this.clickHistory[i];
|
|
2033
2056
|
if (now - entry.at > windowMs) break;
|
|
2034
|
-
if (
|
|
2057
|
+
if (session && entry.session && entry.session !== session) continue;
|
|
2058
|
+
if (hwnd !== void 0 && entry.hwnd !== void 0 && entry.hwnd !== hwnd) continue;
|
|
2059
|
+
if (Math.abs(entry.x - point.x) <= REPEAT_RADIUS_PX && Math.abs(entry.y - point.y) <= REPEAT_RADIUS_PX) {
|
|
2060
|
+
if (entry.via !== "uia") return false;
|
|
2061
|
+
if (entry.name && NON_IDEMPOTENT_CONTROL.test(entry.name)) return false;
|
|
2062
|
+
return true;
|
|
2063
|
+
}
|
|
2035
2064
|
}
|
|
2036
2065
|
return false;
|
|
2037
2066
|
}
|
|
2067
|
+
/** Rolling average settle/screenshot phase timings for diagnostics. */
|
|
2068
|
+
timingSummary() {
|
|
2069
|
+
const n = this.phaseSamples.length;
|
|
2070
|
+
if (n === 0) return {
|
|
2071
|
+
samples: 0,
|
|
2072
|
+
avgSettleMs: 0,
|
|
2073
|
+
avgShotMs: 0
|
|
2074
|
+
};
|
|
2075
|
+
let settleSum = 0;
|
|
2076
|
+
let shotSum = 0;
|
|
2077
|
+
for (const s of this.phaseSamples) {
|
|
2078
|
+
settleSum += s.settleMs;
|
|
2079
|
+
shotSum += s.shotMs;
|
|
2080
|
+
}
|
|
2081
|
+
return {
|
|
2082
|
+
samples: n,
|
|
2083
|
+
avgSettleMs: Math.round(settleSum / n),
|
|
2084
|
+
avgShotMs: Math.round(shotSum / n)
|
|
2085
|
+
};
|
|
2086
|
+
}
|
|
2038
2087
|
async foreground() {
|
|
2039
2088
|
const win = await this.helper.call("foreground");
|
|
2040
2089
|
if (!win || typeof win.hwnd !== "number") return void 0;
|
|
@@ -2052,6 +2101,29 @@ var Computer = class Computer {
|
|
|
2052
2101
|
if (!fg || !(isHostWindow(fg) || isTransientShell(fg)) || !target || target.hwnd === fg.hwnd) return;
|
|
2053
2102
|
if ((await this.focus(target).catch(() => void 0))?.focused) await setTimeout$1(80);
|
|
2054
2103
|
}
|
|
2104
|
+
/** Prefer sampling the visible foreground target window (clamped to current display) so taskbar/side-app animations never disrupt settle detection. */
|
|
2105
|
+
async settleRect() {
|
|
2106
|
+
const display = await this.display();
|
|
2107
|
+
const fg = await this.foreground().catch(() => void 0);
|
|
2108
|
+
if (fg && !isHostWindow(fg) && !isTransientShell(fg) && !fg.minimized && fg.width >= 120 && fg.height >= 80) {
|
|
2109
|
+
const x1 = Math.max(display.x, fg.x);
|
|
2110
|
+
const y1 = Math.max(display.y, fg.y);
|
|
2111
|
+
const x2 = Math.min(display.x + display.width, fg.x + fg.width);
|
|
2112
|
+
const y2 = Math.min(display.y + display.height, fg.y + fg.height);
|
|
2113
|
+
if (x2 - x1 >= 120 && y2 - y1 >= 80) return {
|
|
2114
|
+
x: x1,
|
|
2115
|
+
y: y1,
|
|
2116
|
+
width: x2 - x1,
|
|
2117
|
+
height: y2 - y1
|
|
2118
|
+
};
|
|
2119
|
+
}
|
|
2120
|
+
return {
|
|
2121
|
+
x: display.x,
|
|
2122
|
+
y: display.y,
|
|
2123
|
+
width: display.width,
|
|
2124
|
+
height: display.height
|
|
2125
|
+
};
|
|
2126
|
+
}
|
|
2055
2127
|
/** Wait at most `maxMs`, returning once the screen settles (for waits ≥ 4s, waits for a real visual update first and emits progress checkpoints if still changing so AI can act early or wait again). */
|
|
2056
2128
|
async waitForQuiet(maxMs, signal, wait) {
|
|
2057
2129
|
const started = Date.now();
|
|
@@ -2077,20 +2149,20 @@ var Computer = class Computer {
|
|
|
2077
2149
|
skipped: false
|
|
2078
2150
|
};
|
|
2079
2151
|
}
|
|
2080
|
-
const
|
|
2152
|
+
const rect = await this.settleRect();
|
|
2081
2153
|
const waitForChange = maxMs >= 4e3;
|
|
2082
2154
|
const settlePromise = this.helper.call("settle", {
|
|
2083
|
-
x:
|
|
2084
|
-
y:
|
|
2085
|
-
width:
|
|
2086
|
-
height:
|
|
2155
|
+
x: rect.x,
|
|
2156
|
+
y: rect.y,
|
|
2157
|
+
width: rect.width,
|
|
2158
|
+
height: rect.height,
|
|
2087
2159
|
minMs: 300,
|
|
2088
2160
|
maxMs,
|
|
2089
|
-
quietMs: waitForChange ?
|
|
2161
|
+
quietMs: waitForChange ? 800 : 600,
|
|
2090
2162
|
...waitForChange ? {
|
|
2091
2163
|
waitForChange: true,
|
|
2092
|
-
checkpointMs:
|
|
2093
|
-
noChangeMaxMs: Math.min(maxMs,
|
|
2164
|
+
checkpointMs: 3500,
|
|
2165
|
+
noChangeMaxMs: Math.min(maxMs, 4e3)
|
|
2094
2166
|
} : {}
|
|
2095
2167
|
}, maxMs + 1e4).catch(() => null);
|
|
2096
2168
|
const abortPromise = new Promise((resolve) => {
|
|
@@ -2131,12 +2203,12 @@ var Computer = class Computer {
|
|
|
2131
2203
|
/** Wait until the screen stops changing (bounded), instead of a fixed delay. */
|
|
2132
2204
|
async settle(signal) {
|
|
2133
2205
|
const s = this.settings();
|
|
2134
|
-
const
|
|
2206
|
+
const rect = await this.settleRect();
|
|
2135
2207
|
if (await this.helper.call("settle", {
|
|
2136
|
-
x:
|
|
2137
|
-
y:
|
|
2138
|
-
width:
|
|
2139
|
-
height:
|
|
2208
|
+
x: rect.x,
|
|
2209
|
+
y: rect.y,
|
|
2210
|
+
width: rect.width,
|
|
2211
|
+
height: rect.height,
|
|
2140
2212
|
minMs: s.settleMs,
|
|
2141
2213
|
maxMs: Math.max(s.settleMs, 2500)
|
|
2142
2214
|
}, 15e3).catch(() => null) === null) await setTimeout$1(s.settleMs, void 0, { signal });
|
|
@@ -2357,29 +2429,55 @@ var Computer = class Computer {
|
|
|
2357
2429
|
if (!res || !Array.isArray(res.elements)) return void 0;
|
|
2358
2430
|
return {
|
|
2359
2431
|
...res,
|
|
2360
|
-
elements: res.elements
|
|
2432
|
+
elements: res.elements,
|
|
2433
|
+
...res.truncated !== void 0 ? { truncated: res.truncated } : {}
|
|
2361
2434
|
};
|
|
2362
2435
|
}
|
|
2363
2436
|
/**
|
|
2364
|
-
* Look for a named control via
|
|
2365
|
-
*
|
|
2366
|
-
*
|
|
2437
|
+
* Look for a named control via tiered C#-side targeted UIA lookup:
|
|
2438
|
+
* 1. Exact AutomationId native PropertyCondition
|
|
2439
|
+
* 2. Exact Name (+ optional Role) native PropertyCondition
|
|
2440
|
+
* 3. Role + fuzzy query (accepting unique results only when not truncated)
|
|
2441
|
+
* 4. Full window UIA -> popup UIA -> Windows OCR fallback.
|
|
2367
2442
|
*/
|
|
2368
2443
|
async find(target, hwnd) {
|
|
2369
2444
|
const parsed = parseTarget(target);
|
|
2370
|
-
if (parsed.automationId
|
|
2445
|
+
if (parsed.automationId) {
|
|
2371
2446
|
const fast = await this.findElements({
|
|
2372
2447
|
...hwnd === void 0 ? {} : { hwnd },
|
|
2373
|
-
|
|
2448
|
+
automationId: parsed.automationId,
|
|
2374
2449
|
...parsed.role ? { role: parsed.role } : {},
|
|
2375
|
-
...parsed.name && !parsed.automationId ? { query: parsed.name } : {},
|
|
2376
2450
|
maxMatches: 24
|
|
2377
2451
|
});
|
|
2378
|
-
if (fast && fast.elements.length > 0) {
|
|
2452
|
+
if (fast && fast.elements.length > 0 && !fast.truncated) {
|
|
2379
2453
|
const fastMatch = matchTarget(fast.elements, target);
|
|
2380
2454
|
if (fastMatch.kind !== "missing") return fastMatch;
|
|
2381
2455
|
}
|
|
2382
2456
|
}
|
|
2457
|
+
if (parsed.name && !parsed.automationId) {
|
|
2458
|
+
const exact = await this.findElements({
|
|
2459
|
+
...hwnd === void 0 ? {} : { hwnd },
|
|
2460
|
+
name: parsed.name,
|
|
2461
|
+
...parsed.role ? { role: parsed.role } : {},
|
|
2462
|
+
maxMatches: 24
|
|
2463
|
+
});
|
|
2464
|
+
if (exact && exact.elements.length > 0 && !exact.truncated) {
|
|
2465
|
+
const exactMatch = matchTarget(exact.elements, target);
|
|
2466
|
+
if (exactMatch.kind !== "missing") return exactMatch;
|
|
2467
|
+
}
|
|
2468
|
+
}
|
|
2469
|
+
if (parsed.role && !parsed.automationId) {
|
|
2470
|
+
const fuzzy = await this.findElements({
|
|
2471
|
+
...hwnd === void 0 ? {} : { hwnd },
|
|
2472
|
+
role: parsed.role,
|
|
2473
|
+
...parsed.name ? { query: parsed.name } : {},
|
|
2474
|
+
maxMatches: 24
|
|
2475
|
+
});
|
|
2476
|
+
if (fuzzy && fuzzy.elements.length > 0 && !fuzzy.truncated) {
|
|
2477
|
+
const fuzzyMatch = matchTarget(fuzzy.elements, target);
|
|
2478
|
+
if (fuzzyMatch.kind !== "missing") return fuzzyMatch;
|
|
2479
|
+
}
|
|
2480
|
+
}
|
|
2383
2481
|
const inWindow = await this.elements("window", hwnd).catch(() => []);
|
|
2384
2482
|
const match = matchTarget(inWindow, target);
|
|
2385
2483
|
if (match.kind !== "missing") return match;
|
|
@@ -2720,6 +2818,7 @@ var Computer = class Computer {
|
|
|
2720
2818
|
case "wait": {
|
|
2721
2819
|
const wait = this.overlay.beginWait?.(call.signal);
|
|
2722
2820
|
try {
|
|
2821
|
+
if (wait?.ready) await wait.ready;
|
|
2723
2822
|
if (input.until) return { text: await this.waitUntil(input, call.signal, wait) };
|
|
2724
2823
|
const seconds = Math.min(30, Math.max(0, Number(input.duration ?? 1) || 0));
|
|
2725
2824
|
const res = await this.waitForQuiet(seconds * 1e3, call.signal, wait);
|
|
@@ -2750,11 +2849,16 @@ var Computer = class Computer {
|
|
|
2750
2849
|
const button = action === "right_click" ? "right" : action === "middle_click" ? "middle" : "left";
|
|
2751
2850
|
const count = action === "double_click" ? 2 : action === "triple_click" ? 3 : 1;
|
|
2752
2851
|
const modifiers = parseModifiers(input.modifiers ?? input.text);
|
|
2753
|
-
const
|
|
2852
|
+
const clickHwnd = named?.window.hwnd ?? hitWin?.hwnd;
|
|
2853
|
+
const retryAfterUia = action === "left_click" && modifiers.length === 0 && this.hadRecentUiaClickAt(p, call.session, clickHwnd);
|
|
2754
2854
|
if (action === "left_click" && named && modifiers.length === 0 && !retryAfterUia) {
|
|
2755
2855
|
const semantic = named.element.role === "Edit" || named.element.editable ? "focus" : "invoke";
|
|
2756
2856
|
if (await this.semanticAction(call, named, semantic)) {
|
|
2757
|
-
this.noteClick(p, void 0, "uia"
|
|
2857
|
+
this.noteClick(p, void 0, "uia", {
|
|
2858
|
+
session: call.session,
|
|
2859
|
+
hwnd: named.window.hwnd,
|
|
2860
|
+
name: named.element.name
|
|
2861
|
+
});
|
|
2758
2862
|
return { text: `${semantic === "focus" ? "Focused" : "Invoked"}${label}.` };
|
|
2759
2863
|
}
|
|
2760
2864
|
}
|
|
@@ -2772,7 +2876,11 @@ var Computer = class Computer {
|
|
|
2772
2876
|
}
|
|
2773
2877
|
if (hit?.ok === true) {
|
|
2774
2878
|
this.invalidateMarks();
|
|
2775
|
-
const repeat = this.noteClick(p, void 0, "uia"
|
|
2879
|
+
const repeat = this.noteClick(p, void 0, "uia", {
|
|
2880
|
+
session: call.session,
|
|
2881
|
+
...hitWin ? { hwnd: hitWin.hwnd } : {},
|
|
2882
|
+
...hit.name ? { name: hit.name } : {}
|
|
2883
|
+
});
|
|
2776
2884
|
const repeatHint = repeat >= 3 ? ` (same spot clicked ${repeat} times — screenshot before clicking again)` : "";
|
|
2777
2885
|
return { text: `Invoked ${hit.name ? `${hit.role || "control"} "${hit.name.slice(0, 40)}"` : hit.role || "control"}${label} in background (${hit.mechanism || "uia"}).${repeatHint}` };
|
|
2778
2886
|
}
|
|
@@ -2805,7 +2913,10 @@ var Computer = class Computer {
|
|
|
2805
2913
|
x: clickRes.x,
|
|
2806
2914
|
y: clickRes.y
|
|
2807
2915
|
} : void 0);
|
|
2808
|
-
const repeat = this.noteClick(clickedAt, clickRes?.repeat, "physical"
|
|
2916
|
+
const repeat = this.noteClick(clickedAt, clickRes?.repeat, "physical", {
|
|
2917
|
+
session: call.session,
|
|
2918
|
+
...clickHwnd !== void 0 ? { hwnd: clickHwnd } : {}
|
|
2919
|
+
});
|
|
2809
2920
|
const repeatHint = repeat >= 3 ? ` (same spot clicked ${repeat} times — screenshot before clicking again)` : "";
|
|
2810
2921
|
const fallbackNote = retryAfterUia ? " (physical click after prior UIA invoke at same spot)" : "";
|
|
2811
2922
|
return { text: `${action.replace("_", " ")}${label}${modifiers.length ? ` holding ${input.modifiers ?? input.text}` : ""}.${fallbackNote}${repeatHint}` };
|
|
@@ -2920,11 +3031,40 @@ var Computer = class Computer {
|
|
|
2920
3031
|
}, 4e3);
|
|
2921
3032
|
if (res?.performed !== true) throw new Error(`UI Automation could not perform "${op}" on ${element.role} "${element.name.slice(0, 50)}" (control may not support this pattern).`);
|
|
2922
3033
|
const desc = `${element.role} "${element.name.slice(0, 50)}"`;
|
|
2923
|
-
|
|
2924
|
-
if (op === "
|
|
2925
|
-
|
|
2926
|
-
|
|
2927
|
-
|
|
3034
|
+
const verified = res.verified === true;
|
|
3035
|
+
if (op === "set_checked") {
|
|
3036
|
+
const actualState = res.toggleState ?? (res.checked === true ? "On" : res.checked === false ? "Off" : desiredChecked ? "On" : "Off");
|
|
3037
|
+
const suffix = res.verified === false ? ` (unverified: actual state is ${actualState})` : "";
|
|
3038
|
+
return {
|
|
3039
|
+
text: `${res.changed === false ? "Already" : "Set"} ${desiredChecked ? "checked" : "unchecked"} on ${desc}.${suffix}`,
|
|
3040
|
+
verified
|
|
3041
|
+
};
|
|
3042
|
+
}
|
|
3043
|
+
if (op === "expand" || op === "collapse") {
|
|
3044
|
+
const suffix = res.verified === false ? ` (unverified: actual state is ${res.state ?? "unknown"})` : "";
|
|
3045
|
+
return {
|
|
3046
|
+
text: `${res.changed === false ? "Already " : ""}${op === "expand" ? "Expanded" : "Collapsed"} ${desc}.${suffix}`,
|
|
3047
|
+
verified
|
|
3048
|
+
};
|
|
3049
|
+
}
|
|
3050
|
+
if (op === "select") {
|
|
3051
|
+
const suffix = res.verified === false ? " (unverified: control did not report IsSelected=true)" : "";
|
|
3052
|
+
return {
|
|
3053
|
+
text: `${res.changed === false ? "Already selected" : "Selected"} ${desc}.${suffix}`,
|
|
3054
|
+
verified
|
|
3055
|
+
};
|
|
3056
|
+
}
|
|
3057
|
+
if (op === "set_value") {
|
|
3058
|
+
const suffix = res.verified === false ? ` (unverified: read back ${res.actualLength ?? 0} chars)` : "";
|
|
3059
|
+
return {
|
|
3060
|
+
text: `Set value (${desiredValue.length} chars) on ${desc} via UIA ValuePattern.${suffix}`,
|
|
3061
|
+
verified
|
|
3062
|
+
};
|
|
3063
|
+
}
|
|
3064
|
+
return {
|
|
3065
|
+
text: `${op === "focus" ? "Focused" : "Invoked"} ${desc}.`,
|
|
3066
|
+
...op === "focus" ? { verified: true } : {}
|
|
3067
|
+
};
|
|
2928
3068
|
}
|
|
2929
3069
|
default: throw new Error(`Unknown action: ${String(action)}`);
|
|
2930
3070
|
}
|
|
@@ -3000,12 +3140,22 @@ var Computer = class Computer {
|
|
|
3000
3140
|
* (vision models only). A wait already waited, so it is captured at once:
|
|
3001
3141
|
* "wait, then look" should be one step, not two.
|
|
3002
3142
|
*/
|
|
3003
|
-
async after(inputs, call, detail) {
|
|
3004
|
-
if (!this.settings().autoScreenshot || !call.vision) return void 0;
|
|
3143
|
+
async after(inputs, call, detail, forceScreenshot = false) {
|
|
3144
|
+
if (!this.settings().autoScreenshot && !forceScreenshot || !call.vision) return void 0;
|
|
3005
3145
|
const mutating = inputs.some((input) => MUTATING.has(input.action));
|
|
3006
|
-
if (!mutating && !inputs.some((input) => input.action === "wait")) return void 0;
|
|
3146
|
+
if (!forceScreenshot && !mutating && !inputs.some((input) => input.action === "wait")) return void 0;
|
|
3147
|
+
const t0 = Date.now();
|
|
3007
3148
|
if (mutating) await this.settle(call.signal);
|
|
3008
|
-
|
|
3149
|
+
const settleMs = Date.now() - t0;
|
|
3150
|
+
const t1 = Date.now();
|
|
3151
|
+
const shot = await this.freshShot(detail ?? inputs.at(-1)?.detail);
|
|
3152
|
+
const shotMs = Date.now() - t1;
|
|
3153
|
+
this.phaseSamples.push({
|
|
3154
|
+
settleMs,
|
|
3155
|
+
shotMs
|
|
3156
|
+
});
|
|
3157
|
+
if (this.phaseSamples.length > 40) this.phaseSamples.shift();
|
|
3158
|
+
return shot;
|
|
3009
3159
|
}
|
|
3010
3160
|
/** Bring a window forward and verify it is the foreground window. */
|
|
3011
3161
|
async focus(win) {
|
|
@@ -3131,7 +3281,8 @@ function buildDiagnosticSnapshot(options) {
|
|
|
3131
3281
|
blockedAppsCount: s.blockedApps.length,
|
|
3132
3282
|
hasCustomHarnessUrl: Boolean(s.harnessUrl)
|
|
3133
3283
|
},
|
|
3134
|
-
recentCalls: options.recentCalls
|
|
3284
|
+
recentCalls: options.recentCalls,
|
|
3285
|
+
...options.phaseTiming ? { phaseTiming: options.phaseTiming } : {}
|
|
3135
3286
|
};
|
|
3136
3287
|
}
|
|
3137
3288
|
function formatDiagnosticText(snap) {
|
|
@@ -3140,6 +3291,7 @@ function formatDiagnosticText(snap) {
|
|
|
3140
3291
|
`Generated: ${snap.generatedAt}`,
|
|
3141
3292
|
`Plugin: ${snap.pluginVersion} | Node: ${snap.nodeVersion} | OS: ${snap.os}`,
|
|
3142
3293
|
`Helper: ${snap.helper.status} | Native koffi available: ${snap.helper.nativeAvailable}${snap.helper.error ? ` | Error: ${snap.helper.error}` : ""}`,
|
|
3294
|
+
...snap.phaseTiming && snap.phaseTiming.samples > 0 ? [`Phase timing (${snap.phaseTiming.samples} samples): avg settle=${snap.phaseTiming.avgSettleMs}ms | avg screenshot=${snap.phaseTiming.avgShotMs}ms`] : [],
|
|
3143
3295
|
"",
|
|
3144
3296
|
"--- Displays ---",
|
|
3145
3297
|
...snap.displays.length === 0 ? ["(none)"] : snap.displays.map((d) => `#${d.index}${d.primary ? " (primary)" : ""}: ${d.width}x${d.height} @ ${Math.round(d.dpi / 96 * 100)}% DPI | shot=${d.shot.width}x${d.shot.height} (${d.shot.megapixels}MP, ${d.shot.limitedBy}) | compact=${d.compactShot.width}x${d.compactShot.height}`),
|
|
@@ -3268,6 +3420,7 @@ var HelperClient = class HelperClient {
|
|
|
3268
3420
|
pending = /* @__PURE__ */ new Map();
|
|
3269
3421
|
listeners = /* @__PURE__ */ new Set();
|
|
3270
3422
|
cardChildren = /* @__PURE__ */ new WeakSet();
|
|
3423
|
+
overlayChildren = /* @__PURE__ */ new WeakSet();
|
|
3271
3424
|
nextId = 0;
|
|
3272
3425
|
disposed = false;
|
|
3273
3426
|
constructor(log = () => {}) {
|
|
@@ -3296,7 +3449,9 @@ var HelperClient = class HelperClient {
|
|
|
3296
3449
|
timer,
|
|
3297
3450
|
child
|
|
3298
3451
|
});
|
|
3299
|
-
if (cmd === "window_card"
|
|
3452
|
+
if (cmd === "window_card") this.cardChildren.add(child);
|
|
3453
|
+
else if (cmd === "overlay_show") this.overlayChildren.add(child);
|
|
3454
|
+
else if (cmd === "overlay_hide") this.overlayChildren.delete(child);
|
|
3300
3455
|
child.stdin.write(`${JSON.stringify({
|
|
3301
3456
|
...args,
|
|
3302
3457
|
id,
|
|
@@ -3392,7 +3547,7 @@ var HelperClient = class HelperClient {
|
|
|
3392
3547
|
entry.reject(/* @__PURE__ */ new Error(`computer-use helper exited (code ${String(code)})`));
|
|
3393
3548
|
this.pending.delete(id);
|
|
3394
3549
|
}
|
|
3395
|
-
if (this.cardChildren.has(child) && (!this.disposed || code !== 0)) {
|
|
3550
|
+
if ((this.cardChildren.has(child) || this.overlayChildren.has(child)) && (!this.disposed || code !== 0)) {
|
|
3396
3551
|
const recovery = this.disposed ? new HelperClient(this.log) : this;
|
|
3397
3552
|
recovery.call("window_recover").catch((error) => {
|
|
3398
3553
|
if (!recovery.disposed) this.log(`recover host window: ${String(error)}`);
|
|
@@ -3742,7 +3897,7 @@ ${mode === "per-app" ? "- Before acting on an app, call request_access once with
|
|
|
3742
3897
|
- Prefer reliable keyboard shortcuts (ctrl+l for a browser address bar, ctrl+s, alt+F4, ctrl+t). Click the center of targets. When text is too small to read, zoom once on a generous region that contains everything you need (zooming step by step wastes calls).
|
|
3743
3898
|
- Actions return a fresh screenshot taken once the screen stops changing (page loads included, up to a few seconds), so you rarely need wait. If something is still loading, use wait: it also returns a screenshot, so never follow it with a separate screenshot call. Explicit screenshot and zoom skip sending duplicate pixels when nothing changed (pass force: true to capture anyway); pass detail: "low" when you only need a quick visual confirmation rather than reading small text.
|
|
3744
3899
|
- When the overlay is enabled, a colored pointer cursor with a subtle click ripple briefly stays visible in the next screenshot at the click position (blue = left click, purple = double click, green = right click, cyan = middle click, orange = triple click) so you can verify exactly where your click landed. If you see a repeat-click warning on the same spot, inspect the screen before clicking again.
|
|
3745
|
-
- For windows with sparse or empty UI Automation trees (canvas UIs, games, custom-drawn apps), use ui_elements with ocr: true to read visible text and clickable center coordinates via built-in Windows OCR; target lookups and ui_elements with text: true also fall back to Windows OCR automatically when UIA finds nothing. To look up specific controls without dumping the whole tree, pass query and/or role to ui_elements (e.g. query: "保存", role: "Button"). For idempotent native UIA operations (checking/unchecking checkboxes, expanding trees/menus, selecting list items, or setting values directly), use computer action "ui_action" with target and operation ("set_checked" | "expand" | "collapse" | "select" | "set_value" | "invoke" | "focus"). On repeated inspections of the same window, pass diff: true to ui_elements to receive only added/changed/removed controls and save tokens. On dense UIs with duplicate button labels, use ui_elements with marks: true to get a Set-of-Marks numbered screenshot and click or type by target "#12" (marks expire automatically after any action or window change). When CDP is enabled in settings, ui_elements with cdp: true reads visible DOM elements of the active matched browser tab.
|
|
3900
|
+
- For windows with sparse or empty UI Automation trees (canvas UIs, games, custom-drawn apps), use ui_elements with ocr: true to read visible text and clickable center coordinates via built-in Windows OCR; target lookups and ui_elements with text: true also fall back to Windows OCR automatically when UIA finds nothing. To look up specific controls without dumping the whole tree, pass query and/or role to ui_elements (e.g. query: "保存", role: "Button"). For idempotent native UIA operations (checking/unchecking checkboxes, expanding trees/menus, selecting list items, or setting values directly), use computer action "ui_action" with target and operation ("set_checked" | "expand" | "collapse" | "select" | "set_value" | "invoke" | "focus") — verified ui_action calls return their read-back state automatically without taking a redundant screenshot (pass feedback: "screenshot" when visual inspection is needed, or feedback: "none"/"diff" on other actions to save time and tokens). On repeated inspections of the same window, pass diff: true to ui_elements to receive only added/changed/removed controls and save tokens. On dense UIs with duplicate button labels, use ui_elements with marks: true to get a Set-of-Marks numbered screenshot and click or type by target "#12" (marks expire automatically after any action or window change). When CDP is enabled in settings, ui_elements with cdp: true reads visible DOM elements of the active matched browser tab.
|
|
3746
3901
|
- When replacing text in an existing field, pass replace: true to type so it selects all and replaces in one step. Password fields are protected by default: never attempt to type passwords; stop and ask the user.
|
|
3747
3902
|
- When the user asks you to write something in an app, enter it there with type, even long or multi-line Markdown: the user watches it appear (long text is streamed in paragraph by paragraph, literally, without the editor's auto-formatting getting in the way). Do not write the file from a shell and reopen it instead, and do not put text on the clipboard with shell commands (Set-Clipboard, clip): that clutters the user's clipboard history.
|
|
3748
3903
|
- App skills & macros: open_application returns your saved notes for the app it opens; follow them instead of rediscovering how the app behaves. After working out an unfamiliar app (or finding a note wrong), record the reusable part with app_skill rather than in general memory. For repeatable multi-step routines, save parameterized sequences via app_skill save_macro and replay them with computer_batch macro.
|
|
@@ -4411,7 +4566,7 @@ function sessionRoute(gate, settings, parentIdsFor, sync) {
|
|
|
4411
4566
|
};
|
|
4412
4567
|
}
|
|
4413
4568
|
/** Export a sanitized diagnostic report (plain text by default, or JSON with ?format=json). */
|
|
4414
|
-
function diagnosticsRoute(helper, settings, diagnostics, pluginVersion) {
|
|
4569
|
+
function diagnosticsRoute(helper, settings, diagnostics, pluginVersion, phaseTiming) {
|
|
4415
4570
|
return async (req, res) => {
|
|
4416
4571
|
const s = settings();
|
|
4417
4572
|
let displays = [];
|
|
@@ -4430,7 +4585,8 @@ function diagnosticsRoute(helper, settings, diagnostics, pluginVersion) {
|
|
|
4430
4585
|
helperStatus,
|
|
4431
4586
|
...helperError ? { helperError } : {},
|
|
4432
4587
|
nativeAvailable: helper.available === true,
|
|
4433
|
-
recentCalls: diagnostics.recent()
|
|
4588
|
+
recentCalls: diagnostics.recent(),
|
|
4589
|
+
...phaseTiming ? { phaseTiming: phaseTiming() } : {}
|
|
4434
4590
|
});
|
|
4435
4591
|
if (new URL(req.url ?? "/api/dsh-computer-use/diagnostics", "http://127.0.0.1").searchParams.get("format") === "json") {
|
|
4436
4592
|
json(res, 200, {
|
|
@@ -10887,7 +11043,18 @@ const actionProperties = {
|
|
|
10887
11043
|
},
|
|
10888
11044
|
replace: {
|
|
10889
11045
|
type: "boolean",
|
|
10890
|
-
description: "type: select all (Ctrl+A)
|
|
11046
|
+
description: "type: select all (Ctrl+A) before entering replacement text."
|
|
11047
|
+
},
|
|
11048
|
+
feedback: {
|
|
11049
|
+
type: "string",
|
|
11050
|
+
enum: [
|
|
11051
|
+
"auto",
|
|
11052
|
+
"state",
|
|
11053
|
+
"diff",
|
|
11054
|
+
"screenshot",
|
|
11055
|
+
"none"
|
|
11056
|
+
],
|
|
11057
|
+
description: "Post-action feedback: \"auto\" (default: skips settle/screenshot for verified ui_action, returns screenshot otherwise), \"state\"/\"none\" (skip screenshot), \"diff\" (UIA delta instead of screenshot), \"screenshot\" (force visual screenshot)."
|
|
10891
11058
|
}
|
|
10892
11059
|
};
|
|
10893
11060
|
const BATCH_ACTIONS = ACTIONS.filter((action) => action !== "screenshot");
|
|
@@ -10908,7 +11075,28 @@ function createTools(host) {
|
|
|
10908
11075
|
const outcome = await computer.run(input, call);
|
|
10909
11076
|
if (outcome.image) return withShot(host, outcome.text, outcome.image, call);
|
|
10910
11077
|
if (input.action === "screenshot" || input.action === "zoom") return { text: outcome.text };
|
|
10911
|
-
const
|
|
11078
|
+
const fb = input.feedback ?? "auto";
|
|
11079
|
+
if (fb === "none" || fb === "state") return { text: outcome.text };
|
|
11080
|
+
if (fb === "auto" && input.action === "ui_action" && outcome.verified === true) return { text: `${outcome.text} (verified via UIA; skipped screenshot)` };
|
|
11081
|
+
if (fb === "diff") {
|
|
11082
|
+
const uiRes = await computer.helper.call("ui", {
|
|
11083
|
+
includeText: false,
|
|
11084
|
+
popups: true,
|
|
11085
|
+
maxNodes: 120
|
|
11086
|
+
}, 1e4).catch(() => void 0);
|
|
11087
|
+
if (uiRes && typeof uiRes.hwnd === "number" && Array.isArray(uiRes.elements)) {
|
|
11088
|
+
const delta = computer.uiDiff.diff({
|
|
11089
|
+
sessionId: call.session,
|
|
11090
|
+
hwnd: uiRes.hwnd,
|
|
11091
|
+
pid: uiRes.pid,
|
|
11092
|
+
queryProfile: "0:120"
|
|
11093
|
+
}, String(uiRes.title ?? ""), uiRes.elements);
|
|
11094
|
+
const summary = delta.isBaseline ? `${uiRes.elements.length} UI elements` : delta.added.length === 0 && delta.changed.length === 0 && delta.removed.length === 0 ? "UI tree unchanged" : `+${delta.added.length} added, ~${delta.changed.length} changed, -${delta.removed.length} removed`;
|
|
11095
|
+
return { text: `${outcome.text} [${uiRes.exe}: ${summary}]` };
|
|
11096
|
+
}
|
|
11097
|
+
return { text: outcome.text };
|
|
11098
|
+
}
|
|
11099
|
+
const shot = await computer.after([input], call, input.detail, fb === "screenshot");
|
|
10912
11100
|
return withShot(host, shot === void 0 && input.action !== "wait" && input.action !== "cursor_position" ? `${outcome.text} ${await computer.describeForeground()}` : outcome.text, shot, call);
|
|
10913
11101
|
} catch (error) {
|
|
10914
11102
|
if (call.signal.aborted) await computer.releaseHeld();
|
|
@@ -12153,7 +12341,7 @@ function apply(ctx, config = {}) {
|
|
|
12153
12341
|
ctx.on("agent/assistant-stream", ({ agent, frame }) => {
|
|
12154
12342
|
overlay.stream(agent, frame);
|
|
12155
12343
|
});
|
|
12156
|
-
ctx.on("tools/pre-execute", (exec, next) => {
|
|
12344
|
+
ctx.on("tools/pre-execute", async (exec, next) => {
|
|
12157
12345
|
if (!OWN_TOOLS.has(exec.name)) {
|
|
12158
12346
|
const args = exec.arguments ?? {};
|
|
12159
12347
|
const detail = [
|
|
@@ -12164,8 +12352,13 @@ function apply(ctx, config = {}) {
|
|
|
12164
12352
|
args.url
|
|
12165
12353
|
].find((value) => typeof value === "string");
|
|
12166
12354
|
overlay.toolStarted(exec.agent, exec.name, (detail ?? "").split("\n")[0].slice(0, 120));
|
|
12355
|
+
return next();
|
|
12356
|
+
}
|
|
12357
|
+
try {
|
|
12358
|
+
return await next();
|
|
12359
|
+
} finally {
|
|
12360
|
+
overlay.awaitingModel(exec.agent);
|
|
12167
12361
|
}
|
|
12168
|
-
return next();
|
|
12169
12362
|
});
|
|
12170
12363
|
overlay.onMessage = (agent, text) => {
|
|
12171
12364
|
const steer = agent.steer;
|
|
@@ -12248,7 +12441,7 @@ function apply(ctx, config = {}) {
|
|
|
12248
12441
|
route(SCREENSHOTS_CLEAN_ROUTE, screenshotsCleanRoute(screenshots));
|
|
12249
12442
|
route(SKILLS_ROUTE, skillsRoute(skills));
|
|
12250
12443
|
route(SESSION_ROUTE, sessionRoute(sessionGate, settings, parentIdsFor, syncAllAgents));
|
|
12251
|
-
route(DIAGNOSTICS_ROUTE, diagnosticsRoute(helper, settings, diagnostics, PLUGIN_VERSION));
|
|
12444
|
+
route(DIAGNOSTICS_ROUTE, diagnosticsRoute(helper, settings, diagnostics, PLUGIN_VERSION, () => computer.timingSummary()));
|
|
12252
12445
|
route(UPDATE_ROUTE, updateRoute(PLUGIN_VERSION));
|
|
12253
12446
|
route(WINDOWS_ROUTE, windowsRoute(helper));
|
|
12254
12447
|
});
|
package/lib/types/computer.d.ts
CHANGED
|
@@ -88,6 +88,7 @@ export interface CallContext {
|
|
|
88
88
|
export declare const ACTIONS: readonly ["screenshot", "left_click", "right_click", "middle_click", "double_click", "triple_click", "mouse_move", "left_click_drag", "left_mouse_down", "left_mouse_up", "scroll", "type", "key", "hold_key", "wait", "zoom", "cursor_position", "ui_action"];
|
|
89
89
|
export type Action = typeof ACTIONS[number];
|
|
90
90
|
export type UiSemanticOperation = 'invoke' | 'focus' | 'set_checked' | 'expand' | 'collapse' | 'select' | 'set_value';
|
|
91
|
+
export type ActionFeedback = 'auto' | 'state' | 'diff' | 'screenshot' | 'none';
|
|
91
92
|
export interface ActionInput {
|
|
92
93
|
action: Action;
|
|
93
94
|
coordinate?: number[];
|
|
@@ -116,6 +117,8 @@ export interface ActionInput {
|
|
|
116
117
|
detail?: ScreenshotDetail;
|
|
117
118
|
/** type: select all (Ctrl+A) before entering replacement text. */
|
|
118
119
|
replace?: boolean;
|
|
120
|
+
/** Post-action feedback mode: 'auto' skips screenshots for verified deterministic ui_action, 'state'/'none' skips screenshot, 'diff' returns UIA delta, 'screenshot' forces visual capture. */
|
|
121
|
+
feedback?: ActionFeedback;
|
|
119
122
|
}
|
|
120
123
|
export interface ActionOutcome {
|
|
121
124
|
text: string;
|
|
@@ -123,6 +126,8 @@ export interface ActionOutcome {
|
|
|
123
126
|
image?: Shot | 'unchanged';
|
|
124
127
|
/** The action was not performed because the user took over the keyboard. */
|
|
125
128
|
skipped?: boolean;
|
|
129
|
+
/** True when a deterministic UIA Control Pattern read back and verified the desired post-state. */
|
|
130
|
+
verified?: boolean;
|
|
126
131
|
}
|
|
127
132
|
export interface ClickResult {
|
|
128
133
|
x?: number;
|
|
@@ -164,8 +169,10 @@ export declare class Computer {
|
|
|
164
169
|
private heldButton;
|
|
165
170
|
/** Dimensions of the latest full-display screenshot shown to the model (keeps coordinate conversion exact across detail modes). */
|
|
166
171
|
private lastShot;
|
|
167
|
-
/** Recent click locations (repeat counter + auto physical-click fallback if a UIA invoke had no effect). */
|
|
172
|
+
/** Recent click locations (repeat counter + scoped auto physical-click fallback if a UIA invoke had no effect). */
|
|
168
173
|
private readonly clickHistory;
|
|
174
|
+
/** Rolling per-phase timing samples (settle + screenshot) for diagnostics & performance profiling. */
|
|
175
|
+
private readonly phaseSamples;
|
|
169
176
|
/** The agent that last wrote the clipboard; when it goes idle the user's clipboard comes back. */
|
|
170
177
|
clipboardAgent: CancellableAgent | undefined;
|
|
171
178
|
/** Single-machine desktop control lease preventing concurrent sessions from colliding. */
|
|
@@ -227,8 +234,17 @@ export declare class Computer {
|
|
|
227
234
|
}): Promise<Shot | 'unchanged'>;
|
|
228
235
|
/** Record a click position and return how many times this spot (±24 px) was clicked in the last 2 minutes. */
|
|
229
236
|
private noteClick;
|
|
230
|
-
/**
|
|
237
|
+
/**
|
|
238
|
+
* Whether this spot (±24 px) in the same session & window was recently invoked via UIA
|
|
239
|
+
* (and is NOT a non-idempotent submit/delete/pay button), so a retry upgrades to physical click.
|
|
240
|
+
*/
|
|
231
241
|
private hadRecentUiaClickAt;
|
|
242
|
+
/** Rolling average settle/screenshot phase timings for diagnostics. */
|
|
243
|
+
timingSummary(): {
|
|
244
|
+
samples: number;
|
|
245
|
+
avgSettleMs: number;
|
|
246
|
+
avgShotMs: number;
|
|
247
|
+
};
|
|
232
248
|
foreground(): Promise<WindowInfo | undefined>;
|
|
233
249
|
/**
|
|
234
250
|
* The user clicked into the DeepSeek Harness card (to read or scroll the
|
|
@@ -236,6 +252,8 @@ export declare class Computer {
|
|
|
236
252
|
* in front instead of refusing.
|
|
237
253
|
*/
|
|
238
254
|
private refocusFromHost;
|
|
255
|
+
/** Prefer sampling the visible foreground target window (clamped to current display) so taskbar/side-app animations never disrupt settle detection. */
|
|
256
|
+
private settleRect;
|
|
239
257
|
/** Wait at most `maxMs`, returning once the screen settles (for waits ≥ 4s, waits for a real visual update first and emits progress checkpoints if still changing so AI can act early or wait again). */
|
|
240
258
|
waitForQuiet(maxMs: number, signal: AbortSignal, wait?: WaitHandle): Promise<{
|
|
241
259
|
ms: number;
|
|
@@ -296,11 +314,14 @@ export declare class Computer {
|
|
|
296
314
|
maxMatches?: number;
|
|
297
315
|
}): Promise<(Partial<WindowInfo> & {
|
|
298
316
|
elements: UiElement[];
|
|
317
|
+
truncated?: boolean;
|
|
299
318
|
}) | undefined>;
|
|
300
319
|
/**
|
|
301
|
-
* Look for a named control via
|
|
302
|
-
*
|
|
303
|
-
*
|
|
320
|
+
* Look for a named control via tiered C#-side targeted UIA lookup:
|
|
321
|
+
* 1. Exact AutomationId native PropertyCondition
|
|
322
|
+
* 2. Exact Name (+ optional Role) native PropertyCondition
|
|
323
|
+
* 3. Role + fuzzy query (accepting unique results only when not truncated)
|
|
324
|
+
* 4. Full window UIA -> popup UIA -> Windows OCR fallback.
|
|
304
325
|
*/
|
|
305
326
|
private find;
|
|
306
327
|
/**
|
|
@@ -343,7 +364,7 @@ export declare class Computer {
|
|
|
343
364
|
* (vision models only). A wait already waited, so it is captured at once:
|
|
344
365
|
* "wait, then look" should be one step, not two.
|
|
345
366
|
*/
|
|
346
|
-
after(inputs: readonly ActionInput[], call: CallContext, detail?: ScreenshotDetail): Promise<Shot | 'unchanged' | undefined>;
|
|
367
|
+
after(inputs: readonly ActionInput[], call: CallContext, detail?: ScreenshotDetail, forceScreenshot?: boolean): Promise<Shot | 'unchanged' | undefined>;
|
|
347
368
|
/** Bring a window forward and verify it is the foreground window. */
|
|
348
369
|
focus(win: WindowInfo): Promise<WindowInfo & {
|
|
349
370
|
focused: boolean;
|