@namzu/computer-use 4.3.1 → 4.4.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.
Files changed (39) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/SubprocessComputerUseHost.d.ts +13 -0
  3. package/dist/SubprocessComputerUseHost.d.ts.map +1 -1
  4. package/dist/SubprocessComputerUseHost.js +52 -11
  5. package/dist/SubprocessComputerUseHost.js.map +1 -1
  6. package/dist/a11y/a11y.d.ts +1 -0
  7. package/dist/a11y/a11y.d.ts.map +1 -1
  8. package/dist/a11y/a11y.js +11 -0
  9. package/dist/a11y/a11y.js.map +1 -1
  10. package/dist/a11y/interface.d.ts +5 -0
  11. package/dist/a11y/interface.d.ts.map +1 -1
  12. package/dist/a11y/interface.js.map +1 -1
  13. package/dist/adapters/cua-driver/adapter.d.ts +26 -0
  14. package/dist/adapters/cua-driver/adapter.d.ts.map +1 -1
  15. package/dist/adapters/cua-driver/adapter.js +176 -3
  16. package/dist/adapters/cua-driver/adapter.js.map +1 -1
  17. package/dist/adapters/cua-driver/client.d.ts +5 -0
  18. package/dist/adapters/cua-driver/client.d.ts.map +1 -1
  19. package/dist/adapters/cua-driver/client.js +31 -0
  20. package/dist/adapters/cua-driver/client.js.map +1 -1
  21. package/dist/adapters/types.d.ts +5 -0
  22. package/dist/adapters/types.d.ts.map +1 -1
  23. package/dist/adapters/types.js.map +1 -1
  24. package/dist/foreground/guard.d.ts.map +1 -1
  25. package/dist/foreground/guard.js +2 -0
  26. package/dist/foreground/guard.js.map +1 -1
  27. package/dist/presence/presence.d.ts +8 -0
  28. package/dist/presence/presence.d.ts.map +1 -1
  29. package/dist/presence/presence.js +15 -0
  30. package/dist/presence/presence.js.map +1 -1
  31. package/package.json +2 -2
  32. package/src/SubprocessComputerUseHost.ts +54 -8
  33. package/src/a11y/a11y.ts +11 -0
  34. package/src/a11y/interface.ts +5 -0
  35. package/src/adapters/cua-driver/adapter.ts +190 -2
  36. package/src/adapters/cua-driver/client.ts +27 -0
  37. package/src/adapters/types.ts +5 -0
  38. package/src/foreground/guard.ts +1 -0
  39. package/src/presence/presence.ts +20 -0
@@ -1 +1 @@
1
- {"version":3,"file":"guard.js","sourceRoot":"","sources":["../../src/foreground/guard.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAA;AAEzD,OAAO,EAAE,YAAY,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAA;AAGpE,2DAA2D;AAC3D,MAAM,cAAc,GAAG,IAAI,GAAG,CAA4B;IACzD,YAAY;IACZ,aAAa;IACb,YAAY;IACZ,QAAQ;IACR,WAAW;IACX,KAAK;CACL,CAAC,CAAA;AAEF,MAAM,QAAQ,GAAG,CAAC,EAAU,EAAU,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAA;AAErF;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAAC,OAGhC;IACA,IAAI,OAAO,CAAC,OAAO;QAAE,OAAO,YAAY,CAAA;IACxC,IAAI,OAAO,CAAC,UAAU;QACrB,OAAO,uKAAuK,CAAA;IAC/K,OAAO,SAAS,CAAA;AACjB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAC/B,OAA6D;IAE7D,IAAI,OAAO,CAAC,WAAW,KAAK,KAAK;QAAE,OAAO,SAAS,CAAA;IACnD,OAAO,GAAG,OAAO,CAAC,eAAe,IAAI,yDAAyD,oGAAoG,CAAA;AACnM,CAAC;AAED,mFAAmF;AACnF,MAAM,UAAU,cAAc,CAC7B,OAA6D;IAE7D,MAAM,GAAG,GACR,OAAO,CAAC,kBAAkB,IAAI,OAAO,CAAC,cAAc;QACnD,CAAC,CAAC,+DAA+D;QACjE,CAAC,CAAC,OAAO,CAAC,WAAW;YACnB,OAAO,CAAC,W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5B,IAAI,MAAM;YAAG,OAA8C,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;IACzF,CAAC;IACD,OAAO,OAAO,CAAA;AACf,CAAC;AAED,SAAS,SAAS,CACjB,MAAkD,EAClD,IAAY;IAEZ,OAAO;QACN,IAAI,EAAE,IAAI;QACV,QAAQ,EAAE,MAAM,CAAC,QAAQ,KAAK,eAAe,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,sBAAsB;QACxF,WAAW,EAAE,MAAM,CAAC,QAAQ,KAAK,eAAe,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,WAAW,IAAI,MAAM,CAAC,CAAC,CAAC,CAAC,QAAQ;QAC5F,MAAM,EAAE,CAAC,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;KACvD,CAAA;AACF,CAAC"}
@@ -26,6 +26,11 @@ export interface Presence {
26
26
  warm(): void;
27
27
  /** Removes both at once: the task ended or the session stopped. */
28
28
  hide(): void;
29
+ /**
30
+ * Ends the helper process while nobody is using it; the next `warm()` or `mark()` starts it again.
31
+ * Optional: a presence that holds no process has nothing to end.
32
+ */
33
+ release?(): void;
29
34
  dispose(): Promise<void>;
30
35
  }
31
36
  /** The ends of a started helper; the real one is a child process. */
@@ -57,12 +62,15 @@ export declare class WindowsPresence implements Presence {
57
62
  private dead;
58
63
  private restarts;
59
64
  private disposed;
65
+ /** Helpers let go of on purpose: their exit is not a crash. */
66
+ private readonly released;
60
67
  constructor(options: WindowsPresenceOptions);
61
68
  /** Whether the overlay is available; false once it failed to start or exited. */
62
69
  get available(): boolean;
63
70
  mark(mark: PresenceMark): void;
64
71
  warm(): void;
65
72
  hide(): void;
73
+ release(): void;
66
74
  dispose(): Promise<void>;
67
75
  private send;
68
76
  private start;
@@ -1 +1 @@
1
- {"version":3,"file":"presence.d.ts","sourceRoot":"","sources":["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  disposed = false;
52
+ /** Helpers let go of on purpose: their exit is not a crash. */
53
+ released = new WeakSet();
52
54
  constructor(options) {
53
55
  this.options = options;
54
56
  }
@@ -76,6 +78,15 @@ export class WindowsPresence {
76
78
  if (this.proc && this.available)
77
79
  this.proc.write(JSON.stringify({ cmd: 'hide' }));
78
80
  }
81
+ release() {
82
+ const proc = this.proc;
83
+ if (!proc)
84
+ return;
85
+ this.released.add(proc);
86
+ this.proc = undefined;
87
+ this.starting = undefined;
88
+ proc.kill();
89
+ }
79
90
  async dispose() {
80
91
  this.disposed = true;
81
92
  const proc = this.proc;
@@ -109,6 +120,10 @@ export class WindowsPresence {
109
120
  timer.unref();
110
121
  proc.onExit(() => {
111
122
  clearTimeout(timer);
123
+ if (this.released.has(proc)) {
124
+ resolve(false);
125
+ return;
126
+ }
112
127
  // A helper that was running and ended (it crashed, or its host closed it) is
113
128
  // started again by the next action, a few times; one that never came up stays off.
114
129
  if (greeted && this.proc === proc && !this.disposed && this.restarts < MAX_RESTARTS) {
@@ -1 +1 @@
1
- {"version":3,"file":"presence.js","sourceRoot":"","sources":["../../src/presence/presence.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAC/C,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAA;AAkD3E,SAAS,eAAe,CAAC,OAA+B;IACvD,MAAM,KAAK,GAAG,KAAK,CAClB,OAAO,CAAC,UAAU,EAClB;QACC,YAAY;QACZ,iBAAiB;QACjB,kBAAkB;QAClB,QAAQ;QACR,iBAAiB;QACjB,MAAM,CAAC,IAAI,CAAC,kBAAkB,EAAE,SAAS,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC;KAC7D,EACD,EAAE,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,C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;oBAAM,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;gBACvB,OAAO,CAAC,KAAK,CAAC,CAAA;YACf,CAAC,CAAC,CAAA;YACF,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE;gBACpB,IAAI,OAAO;oBAAE,OAAM;gBACnB,OAAO,GAAG,IAAI,CAAA;gBACd,YAAY,CAAC,KAAK,CAAC,CAAA;gBACnB,IAAI,KAA2C,CAAA;gBAC/C,IAAI,CAAC;oBACJ,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAyC,CAAA;gBACjE,CAAC;gBAAC,MAAM,CAAC;oBACR,IAAI,EAAE,CAAA;oBACN,OAAM;gBACP,CAAC;gBACD,kFAAkF;gBAClF,IAAI,KAAK,CAAC,EAAE,KAAK,IAAI,IAAI,KAAK,CAAC,QAAQ,KAAK,IAAI;oBAAE,IAAI,EAAE,CAAA;;oBACnD,OAAO,CAAC,IAAI,CAAC,CAAA;YACnB,CAAC,CAAC,CAAA;YACF,IAAI,CAAC,KAAK,CAAC,kBAAkB,EAAE,CAAC,CAAA;QACjC,CAAC,CAAC,CAAA;QACF,OAAO,IAAI,CAAC,QAAQ,CAAA;IACrB,CAAC;CACD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@namzu/computer-use",
3
- "version": "4.3.1",
3
+ "version": "4.4.0",
4
4
  "description": "Subprocess-based computer-use host for @namzu/sdk. Screenshot, mouse, and keyboard control via platform-native CLIs (screencapture/osascript on darwin, xdotool/maim on Linux X11, grim/wtype/ydotool on Wayland, PowerShell on Windows).",
5
5
  "license": "FSL-1.1-MIT",
6
6
  "engines": {
@@ -53,7 +53,7 @@
53
53
  "@types/node": "^22.19.17",
54
54
  "typescript": "^5.5.0",
55
55
  "vitest": "^4.1.11",
56
- "@namzu/sdk": "^62.6.1"
56
+ "@namzu/sdk": "^67.0.0"
57
57
  },
58
58
  "scripts": {
59
59
  "build": "tsc --build",
@@ -55,6 +55,9 @@ const UNSAFE_TO_REPLAY_AFTER_START = new Set<ComputerUseAction['type']>([
55
55
  'key',
56
56
  ])
57
57
 
58
+ /** How long an unused host keeps its adapter's process (see `idleReleaseMs`). */
59
+ const DEFAULT_IDLE_RELEASE_MS = 60_000
60
+
58
61
  export interface SubprocessComputerUseHostOptions {
59
62
  readonly env?: NodeJS.ProcessEnv
60
63
  readonly platform?: NodeJS.Platform
@@ -90,6 +93,13 @@ export interface SubprocessComputerUseHostOptions {
90
93
  * for this machine (for tests).
91
94
  */
92
95
  readonly a11y?: boolean | AccessibilityBackend
96
+ /**
97
+ * How long the host may sit unused before it lets go of what its adapter keeps running (on Windows
98
+ * the cua-driver process and the cursor overlay it draws). The next call starts it again. Without
99
+ * this, every conversation of an app keeps its own driver until the conversation closes. Default 60
100
+ * seconds; 0 keeps it for the life of the host.
101
+ */
102
+ readonly idleReleaseMs?: number
93
103
  }
94
104
 
95
105
  export interface SubprocessComputerUseHostForegroundOptions {
@@ -132,6 +142,10 @@ export class SubprocessComputerUseHost implements ComputerUseHost {
132
142
  private ladder: ForegroundLadder | undefined
133
143
  private presence: Presence | undefined
134
144
  private a11y: AccessibilityBackend | undefined
145
+ private idleTimer: NodeJS.Timeout | undefined
146
+ private busy = 0
147
+ /** Counts every call start, so a release can tell that one began while it was winding down. */
148
+ private useEpoch = 0
135
149
 
136
150
  constructor(private readonly options: SubprocessComputerUseHostOptions = {}) {
137
151
  const displayServer = detectDisplayServer(options.env, options.platform)
@@ -226,6 +240,7 @@ export class SubprocessComputerUseHost implements ComputerUseHost {
226
240
  }
227
241
  this.adapter = adapter
228
242
  this._capabilities = adapter.capabilities
243
+ this.armIdleRelease()
229
244
  }
230
245
 
231
246
  async getDisplayGeometry(): Promise<DisplayGeometry> {
@@ -441,6 +456,8 @@ export class SubprocessComputerUseHost implements ComputerUseHost {
441
456
 
442
457
  /** Stops whatever the adapter keeps running (the Windows cua-driver process). */
443
458
  async dispose(): Promise<void> {
459
+ if (this.idleTimer) clearTimeout(this.idleTimer)
460
+ this.idleTimer = undefined
444
461
  const adapter = this.adapter
445
462
  this.adapter = null
446
463
  await adapter?.dispose?.()
@@ -473,15 +490,41 @@ export class SubprocessComputerUseHost implements ComputerUseHost {
473
490
  run: () => Promise<T>,
474
491
  onAbort?: (sent: boolean) => T,
475
492
  ): Promise<T> {
476
- return inCallScope(signal, async (scope) => {
477
- try {
478
- return await run()
479
- } catch (error) {
480
- if (!(error instanceof CallAbortedError)) throw error
481
- if (!onAbort) throw error
482
- return onAbort(scope.sent || error.sent)
493
+ this.busy += 1
494
+ try {
495
+ return await inCallScope(signal, async (scope) => {
496
+ try {
497
+ return await run()
498
+ } catch (error) {
499
+ if (!(error instanceof CallAbortedError)) throw error
500
+ if (!onAbort) throw error
501
+ return onAbort(scope.sent || error.sent)
502
+ }
503
+ })
504
+ } finally {
505
+ this.busy -= 1
506
+ this.armIdleRelease()
507
+ }
508
+ }
509
+
510
+ /** Start counting an idle stretch again; when it runs out with no call in flight the adapter lets go of its process. */
511
+ private armIdleRelease(): void {
512
+ const wait = this.options.idleReleaseMs ?? DEFAULT_IDLE_RELEASE_MS
513
+ if (this.idleTimer) clearTimeout(this.idleTimer)
514
+ this.idleTimer = undefined
515
+ if (wait <= 0 || !this.adapter?.release) return
516
+ this.idleTimer = setTimeout(() => {
517
+ this.idleTimer = undefined
518
+ if (this.busy > 0) {
519
+ this.armIdleRelease()
520
+ return
483
521
  }
484
- })
522
+ const epoch = this.useEpoch
523
+ void this.adapter
524
+ ?.release?.(() => this.busy === 0 && this.useEpoch === epoch)
525
+ .catch(() => undefined)
526
+ }, wait)
527
+ this.idleTimer.unref?.()
485
528
  }
486
529
 
487
530
  /** True when the computer is known to be locked; false when it is not or cannot be told. */
@@ -505,6 +548,9 @@ export class SubprocessComputerUseHost implements ComputerUseHost {
505
548
 
506
549
  private requireAdapter(): Adapter {
507
550
  if (this.ladder?.stopped) throw new ComputerUseStoppedError()
551
+ // A call is starting: the idle stretch starts over.
552
+ this.useEpoch += 1
553
+ this.armIdleRelease()
508
554
  if (!this.adapter) {
509
555
  throw new Error(
510
556
  'SubprocessComputerUseHost: adapter not initialised — call `await host.initialize()` first',
package/src/a11y/a11y.ts CHANGED
@@ -153,6 +153,17 @@ export class WindowsA11yHost implements AccessibilityBackend {
153
153
  if (!this.dead && !this.closed) void this.start()
154
154
  }
155
155
 
156
+ release(): void {
157
+ const proc = this.proc
158
+ if (!proc) return
159
+ // Replaced, not ended: its exit is not a crash (see the exit handler).
160
+ this.proc = undefined
161
+ this.starting = undefined
162
+ this.up = false
163
+ this.failAll(new A11yError('helper_exited', 'the accessibility host was released'))
164
+ proc.kill()
165
+ }
166
+
156
167
  ready(): Promise<boolean> {
157
168
  if (this.dead || this.closed) return Promise.resolve(false)
158
169
  return this.start()
@@ -188,6 +188,11 @@ export interface AccessibilityBackend {
188
188
  readonly isReady: boolean
189
189
  /** Starts the backend ahead of the first question. Does not wait; safe to repeat. */
190
190
  warm(): void
191
+ /**
192
+ * Ends the backend's process while nobody is using it; the next `warm()` or question starts it again
193
+ * (a marker taken before is then stale). Optional: a backend that holds no process has nothing to end.
194
+ */
195
+ release?(): void
191
196
  /** Resolves true when the backend is up; false (never throws) when it cannot be. */
192
197
  ready(): Promise<boolean>
193
198
  /** The visible, un-cloaked, non-tool top-level windows, front to back. */
@@ -52,6 +52,7 @@ import { menuAcceleratorOf, translateKeyForCuaDriver } from './keys.js'
52
52
  import {
53
53
  type Observation,
54
54
  type ObservedVerdict,
55
+ changeBetween,
55
56
  judgeEdit,
56
57
  judgeEditBetween,
57
58
  judgeObserved,
@@ -154,6 +155,8 @@ const SPARSE_TREE = 12
154
155
  const CHOICE_ROLES = /^(ComboBox|List|ListBox)$/i
155
156
  /** Waits (ms) before each read that looks for an input's effect: at once, then a little later. */
156
157
  const OBSERVE_WAITS_MS = [0, 80, 200, 450] as const
158
+ /** expand and collapse: a first read after the click, and a second one this much later that must agree. */
159
+ const EXPAND_WAITS_MS = [150, 450] as const
157
160
  /**
158
161
  * How old (ms) the window list read just before an input may be and still
159
162
  * stand for the check that the window has not moved. A list takes over a
@@ -430,6 +433,8 @@ export class CuaDriverAdapter implements Adapter {
430
433
  private driverCursorOff: boolean | undefined
431
434
  /** cua-driver's screenshot resize registry is per PID, so only this capture may drive input. */
432
435
  private windowFrame: WindowCaptureFrame | undefined
436
+ /** The process count at the last idle release, for a screenshot taken from that process. */
437
+ private releasedStarts: number | undefined
433
438
  /** Capture and scoped input must not race over cua-driver's per-PID resize ratio. */
434
439
  private windowOperation: Promise<void> = Promise.resolve()
435
440
  /** Refs the model holds, by the adapter's ref. A handle is usable only in its window's latest read; otherwise the ref is found again. */
@@ -714,6 +719,27 @@ export class CuaDriverAdapter implements Adapter {
714
719
  return this.serializeWindowOperation(() => this.captureWindowInternal(id))
715
720
  }
716
721
 
722
+ /**
723
+ * Read the window again with a screenshot, so the driver can place pixels of `frame` on it.
724
+ * True when that read has the size of the screenshot the model is looking at.
725
+ */
726
+ private async restoreDriverFrame(frame: WindowCaptureFrame): Promise<boolean> {
727
+ const hwnd = parseWindowId(frame.window.id)
728
+ if (hwnd === undefined) return false
729
+ try {
730
+ const result = await this.callTool('get_window_state', {
731
+ pid: frame.window.pid,
732
+ window_id: hwnd,
733
+ include_accessibility_tree: false,
734
+ include_screenshot: true,
735
+ })
736
+ const facts = structured(result, 'get_window_state')
737
+ return facts.screenshot_width === frame.width && facts.screenshot_height === frame.height
738
+ } catch {
739
+ return false
740
+ }
741
+ }
742
+
717
743
  private async captureWindowInternal(id: string): Promise<WindowScreenshotResult> {
718
744
  const target = await this.resolveWindow(id)
719
745
  // A failed or overlapping capture invalidates the old resize ratio even
@@ -884,6 +910,7 @@ export class CuaDriverAdapter implements Adapter {
884
910
  action: WindowInputAction,
885
911
  route: InputRoute,
886
912
  ): Promise<WindowInputResult | undefined> {
913
+ await this.carryFrameOver(captureId)
887
914
  const frame = this.windowFrame
888
915
  const watched =
889
916
  action.type === 'type_text' || action.type === 'key' || action.type === 'mouse_click'
@@ -1100,6 +1127,7 @@ export class CuaDriverAdapter implements Adapter {
1100
1127
  route: InputRoute = { foreground: false, onScreen: false },
1101
1128
  listing?: WindowListing,
1102
1129
  ): Promise<WindowInputResult | undefined> {
1130
+ await this.carryFrameOver(captureId)
1103
1131
  const frame = this.windowFrame
1104
1132
  if (!frame || frame.id !== captureId)
1105
1133
  throw new Error(
@@ -1150,7 +1178,18 @@ export class CuaDriverAdapter implements Adapter {
1150
1178
  )
1151
1179
  this.showPresence(frame, current.bounds, name, args)
1152
1180
  await this.markForSettle(target.window_id as number)
1153
- return this.callTool(name, { ...target, ...args }, undefined, undefined, undefined, frame)
1181
+ const sendOnce = () =>
1182
+ this.callTool(name, { ...target, ...args }, undefined, undefined, undefined, frame)
1183
+ try {
1184
+ return await sendOnce()
1185
+ } catch (error) {
1186
+ // The driver keeps one latest read per window, and a read of the controls (made just before
1187
+ // an input to judge it) replaces a screenshot with one that has none. It then refuses a
1188
+ // pixel input and sends nothing. The window is unchanged (checked above), so the same
1189
+ // screenshot is taken again for the driver and the input goes once more.
1190
+ if (!isNoDriverFrame(error) || !(await this.restoreDriverFrame(frame))) throw error
1191
+ return await sendOnce()
1192
+ }
1154
1193
  }
1155
1194
  // The driver's hotkey finds a shortcut only through an accelerator the window names, and refuses (sending
1156
1195
  // nothing) when there is none; the same combination as a key with modifiers is real input.
@@ -1676,9 +1715,10 @@ export class CuaDriverAdapter implements Adapter {
1676
1715
  )
1677
1716
  try {
1678
1717
  switch (action) {
1679
- case 'invoke':
1680
1718
  case 'expand':
1681
1719
  case 'collapse':
1720
+ return await this.expandAndWatch(facts, uiRef, action)
1721
+ case 'invoke':
1682
1722
  // cua-driver's click on an element token performs the control's
1683
1723
  // own pattern in the background (Invoke, or a posted click at its
1684
1724
  // centre), with no pointer move and no change of foreground.
@@ -2008,6 +2048,91 @@ export class CuaDriverAdapter implements Adapter {
2008
2048
  }
2009
2049
  }
2010
2050
 
2051
+ /**
2052
+ * expand or collapse, which the driver sends as a click and cannot read back: the control reports no
2053
+ * expanded state. What counts is what the window shows afterwards, and it has to still be there a
2054
+ * moment later. A menu that opened and closed again is not an expanded menu.
2055
+ */
2056
+ private async expandAndWatch(
2057
+ facts: UiRefEntry,
2058
+ uiRef: { readonly ref: string; readonly facts: UiRefEntry },
2059
+ want: 'expand' | 'collapse',
2060
+ ): Promise<UiActResult> {
2061
+ const target = { hwnd: facts.hwnd, pid: facts.pid }
2062
+ const before = await this.observe(target)
2063
+ const windows = await this.windowIdsOf(target.pid)
2064
+ // Each read of the window replaces the driver's handles: click through the refreshed one.
2065
+ const current = this.uiRefs.get(uiRef.ref) ?? facts
2066
+ const sent = await this.clickRef(current, { ref: uiRef.ref, facts: current })
2067
+ if (!sent.ok || sent.delivery === 'not_delivered') return sent
2068
+ const what = describeEvidence(current)
2069
+ const unverified = (detail: string): UiActResult => ({
2070
+ ok: true,
2071
+ delivery: 'delivered_unverified',
2072
+ retrySafety: 'unsafe',
2073
+ detail,
2074
+ })
2075
+ if (!before)
2076
+ return unverified(
2077
+ `the click on ${what} was sent, but the window could not be read to see whether it ${want === 'expand' ? 'opened' : 'closed'}. Look at the window before repeating it.`,
2078
+ )
2079
+ const readState = async (): Promise<
2080
+ { shown: string | undefined; held: boolean } | undefined
2081
+ > => {
2082
+ const newWindow = windows ? await this.newWindowOf(target.pid, windows) : undefined
2083
+ const after = await this.observe(target)
2084
+ if (!after) return undefined
2085
+ const change = changeBetween(before, after)
2086
+ const gone = windows ? await this.windowGone(target.pid, windows) : false
2087
+ if (want === 'expand') {
2088
+ const shown = newWindow?.title.trim() || change.added[0]
2089
+ return { shown, held: newWindow !== undefined || change.added.length > 0 }
2090
+ }
2091
+ return { shown: change.removed[0], held: gone || change.removed.length > 0 }
2092
+ }
2093
+ await this.settle(EXPAND_WAITS_MS[0])
2094
+ const first = await readState()
2095
+ if (!first)
2096
+ return unverified(
2097
+ `the click on ${what} was sent, but the window could not be read afterwards. Look at the window before repeating it.`,
2098
+ )
2099
+ await this.settle(EXPAND_WAITS_MS[1])
2100
+ const second = await readState()
2101
+ if (first.held && second?.held)
2102
+ return {
2103
+ ok: true,
2104
+ delivery: 'delivered_verified',
2105
+ retrySafety: 'unsafe',
2106
+ ...(second.shown !== undefined ? { readBack: { observed: trimText(second.shown) } } : {}),
2107
+ detail:
2108
+ want === 'expand'
2109
+ ? `${what} is open: the window shows what it opened, and still did a moment later.`
2110
+ : `${what} is closed: what it showed is gone, and stayed gone a moment later.`,
2111
+ }
2112
+ if (first.held && second && !second.held)
2113
+ return unverified(
2114
+ want === 'expand'
2115
+ ? `${what} opened and closed again, so it is not open now. Look at the window; a menu that closes on its own may need the keyboard (alt+letter) or a click in the foreground.`
2116
+ : `${what} looked closed, but what it showed is back. Look at the window before repeating it.`,
2117
+ )
2118
+ return unverified(
2119
+ want === 'expand'
2120
+ ? `the click on ${what} was sent, but no menu or new control showed in the window afterwards, so it may not be open. Look at the window (a window screenshot) before repeating it.`
2121
+ : `the click on ${what} was sent, but nothing in the window changed, so it may still be open. Look at the window before repeating it.`,
2122
+ )
2123
+ }
2124
+
2125
+ /** Whether a window the program had before (a popup that was open) is no longer listed. */
2126
+ private async windowGone(pid: number, known: ReadonlySet<string>): Promise<boolean> {
2127
+ try {
2128
+ const now = new Set((await this.listWindows()).filter((w) => w.pid === pid).map((w) => w.id))
2129
+ for (const id of known) if (!now.has(id)) return true
2130
+ return false
2131
+ } catch {
2132
+ return false
2133
+ }
2134
+ }
2135
+
2011
2136
  /**
2012
2137
  * A click on a control by its driver token, in the background. Where the
2013
2138
  * driver says the window cannot take background input (or is covered) the
@@ -2111,6 +2236,46 @@ export class CuaDriverAdapter implements Adapter {
2111
2236
  await this.client.dispose()
2112
2237
  }
2113
2238
 
2239
+ /**
2240
+ * Let go of the driver process (and the agent cursor it draws) while nobody is using it. The next
2241
+ * call starts it again; every screenshot and ref taken from the old process is then stale, which
2242
+ * the process counter already says.
2243
+ */
2244
+ async release(stillIdle: () => boolean = () => true): Promise<void> {
2245
+ const before = this.client.starts
2246
+ const ended = await this.client.release()
2247
+ // Nothing below runs unless the process really ended and no call began while it wound down;
2248
+ // a call that did started its own process, and its frame and helpers are not ours to clear.
2249
+ if (!ended || this.client.starts !== before || !stillIdle()) return
2250
+ // The refs read from the old process are dead. The window screenshot is kept: the model may
2251
+ // still be looking at it, and the first input on it reads the window again for the new process.
2252
+ this.windowReads.clear()
2253
+ this.releasedStarts = before
2254
+ // The helpers started beside it (the overlay, the accessibility host) are processes too; the
2255
+ // next window list starts them again.
2256
+ this.presence?.release?.()
2257
+ this.a11y?.release?.()
2258
+ }
2259
+
2260
+ /**
2261
+ * After an idle release the screenshot the model took is still the one it acts on. Read the window
2262
+ * again for the new process (the same size is required) and carry the screenshot over to it.
2263
+ */
2264
+ private async carryFrameOver(captureId: string): Promise<void> {
2265
+ const frame = this.windowFrame
2266
+ if (
2267
+ !frame ||
2268
+ frame.id !== captureId ||
2269
+ this.releasedStarts !== frame.processStarts ||
2270
+ frame.generation !== this.sessionGeneration
2271
+ )
2272
+ return
2273
+ if (!(await this.restoreDriverFrame(frame))) return
2274
+ if (this.windowFrame !== frame) return
2275
+ this.windowFrame = { ...frame, processStarts: this.client.starts }
2276
+ this.releasedStarts = undefined
2277
+ }
2278
+
2114
2279
  /** Tells the overlay where the agent is about to act in a window; never waits and never fails the action. */
2115
2280
  private showPresence(
2116
2281
  frame: WindowCaptureFrame,
@@ -2465,6 +2630,12 @@ export function failureDelivery(error: McpToolError): WindowInputResult {
2465
2630
  typeof refusal?.message === 'string' ? refusal.message : error.message,
2466
2631
  )
2467
2632
  }
2633
+ if (isNoDriverFrame(error))
2634
+ return verdict(
2635
+ 'not_delivered',
2636
+ 'safe',
2637
+ 'the driver had no screenshot of this window to place the pixels on, so nothing was sent. Take a new window screenshot and click again.',
2638
+ )
2468
2639
  if (/stale (window|screenshot)/i.test(error.message))
2469
2640
  return verdict('not_delivered', 'safe', trimText(error.message, 300))
2470
2641
  if (/stale/i.test(`${error.message} ${JSON.stringify(facts)}`))
@@ -2482,6 +2653,11 @@ export function failureDelivery(error: McpToolError): WindowInputResult {
2482
2653
  )
2483
2654
  }
2484
2655
 
2656
+ /** The driver refused a pixel input because it holds no screenshot of the window (nothing was sent). */
2657
+ function isNoDriverFrame(error: unknown): boolean {
2658
+ return error instanceof McpToolError && /No screenshot frame for/i.test(error.message)
2659
+ }
2660
+
2485
2661
  /** The driver refused a handle a newer read of its window replaced (nothing was sent). */
2486
2662
  function isStaleHandle(error: McpToolError): boolean {
2487
2663
  if (/stale (window|screenshot)/i.test(error.message)) return false
@@ -2640,6 +2816,18 @@ export function windowIdOf(hwnd: number): string {
2640
2816
  }
2641
2817
 
2642
2818
  export function parseWindowId(value: unknown): number | undefined {
2819
+ // A handle as an object ({ hwnd }, { id }, { window_id } ...) is read by the id inside it.
2820
+ if (typeof value === 'object' && value !== null && !Array.isArray(value)) {
2821
+ const record = value as Record<string, unknown>
2822
+ for (const key of ['window_id', 'windowId', 'hwnd', 'handle', 'id', 'value']) {
2823
+ if (record[key] === undefined || typeof record[key] === 'object') continue
2824
+ const found = parseWindowId(record[key])
2825
+ if (found !== undefined) return found
2826
+ }
2827
+ return undefined
2828
+ }
2829
+ if (typeof value === 'bigint')
2830
+ return value > 0n && value <= BigInt(Number.MAX_SAFE_INTEGER) ? Number(value) : undefined
2643
2831
  if (typeof value === 'number') return Number.isSafeInteger(value) && value > 0 ? value : undefined
2644
2832
  if (typeof value !== 'string') return undefined
2645
2833
  const text = value.trim().toLowerCase()
@@ -199,6 +199,33 @@ export class McpStdioClient {
199
199
  }
200
200
  }
201
201
 
202
+ /**
203
+ * Stop the running process and keep the client: the next call starts a new one (the same path as
204
+ * after a crash). For a client nobody is using, so it holds no process while it waits.
205
+ */
206
+ async release(): Promise<boolean> {
207
+ if (this.inFlight > 0) return false
208
+ const running = this.running ?? (await this.starting?.catch(() => undefined))
209
+ if (!running) return true
210
+ if (running.exited) return true
211
+ if (this.inFlight > 0) return false
212
+ // A call that arrives while it winds down starts a new process; it never meets this one.
213
+ if (this.running === running) this.running = undefined
214
+ running.killedFor = 'dispose'
215
+ running.child.stdin.end()
216
+ let timer: NodeJS.Timeout | undefined
217
+ const late = new Promise<'late'>((resolve) => {
218
+ timer = setTimeout(() => resolve('late'), 2_000)
219
+ })
220
+ const outcome = await Promise.race([running.closed.then(() => 'closed' as const), late])
221
+ clearTimeout(timer)
222
+ if (outcome === 'late') {
223
+ running.child.kill('SIGKILL')
224
+ await running.closed
225
+ }
226
+ return true
227
+ }
228
+
202
229
  private async ensureStarted(): Promise<Running> {
203
230
  if (this.disposed) throw new Error(`${this.options.command}: the client was disposed.`)
204
231
  if (this.running && !this.running.exited) return this.running
@@ -62,6 +62,11 @@ export interface Adapter {
62
62
  /** With `capabilities.uiTree`. */
63
63
  uiAct?(ref: string, action: UiElementAction, value?: string): Promise<UiActResult>
64
64
  dispose?(): Promise<void>
65
+ /**
66
+ * Lets go of what the adapter keeps running while nobody uses it; the next call starts it again.
67
+ * Optional: an adapter that holds nothing between calls has nothing to let go of.
68
+ */
69
+ release?(stillIdle?: () => boolean): Promise<void>
65
70
  }
66
71
 
67
72
  /**
@@ -117,6 +117,7 @@ export function guardForeground(adapter: Adapter, ladder: ForegroundLadder): Ada
117
117
  await adapter.dispose?.()
118
118
  },
119
119
  }
120
+ if (adapter.release) guarded.release = adapter.release.bind(adapter)
120
121
  if (adapter.listWindows) {
121
122
  const list = adapter.listWindows.bind(adapter)
122
123
  guarded.listWindows = async () => {