@namzu/computer-use 2.0.2 → 3.1.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/CHANGELOG.md +12 -0
- package/README.md +47 -6
- package/dist/SubprocessComputerUseHost.d.ts +4 -1
- package/dist/SubprocessComputerUseHost.d.ts.map +1 -1
- package/dist/SubprocessComputerUseHost.js +20 -0
- package/dist/SubprocessComputerUseHost.js.map +1 -1
- package/dist/adapters/cua-driver/adapter.d.ts +29 -8
- package/dist/adapters/cua-driver/adapter.d.ts.map +1 -1
- package/dist/adapters/cua-driver/adapter.js +364 -28
- package/dist/adapters/cua-driver/adapter.js.map +1 -1
- package/dist/adapters/cua-driver/client.d.ts +8 -2
- package/dist/adapters/cua-driver/client.d.ts.map +1 -1
- package/dist/adapters/cua-driver/client.js +18 -5
- package/dist/adapters/cua-driver/client.js.map +1 -1
- package/dist/adapters/types.d.ts +5 -1
- package/dist/adapters/types.d.ts.map +1 -1
- package/dist/adapters/types.js.map +1 -1
- package/package.json +2 -2
- package/src/SubprocessComputerUseHost.ts +21 -0
- package/src/adapters/cua-driver/adapter.ts +462 -40
- package/src/adapters/cua-driver/client.ts +26 -4
- package/src/adapters/types.ts +6 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 3.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 072bb74: Windows computer use can capture pixels for one named window with `screenshot {window_id}` and keep background clicks and drags, text and keys bound to that window. Window `type_text` and `key` can explicitly request `delivery_mode: 'foreground'` for browser text or modifier shortcuts that cannot run in the background; this may briefly bring the verified window forward. The pinned driver sets `windowScroll: false` and refuses scoped pixel scrolling because its wheel input cannot prove which window receives it; a host that supports safe window scrolling can offer it. Capture identity and window geometry are checked before input; moved windows, old captures and restarted driver sessions require a new window screenshot. Hosts can offer window capture without display capture, in which case `window_id` is required and plain display screenshots remain unavailable. A failed window capture never broadens to a display capture. When both browser and computer-use tools are ready, the CLI routes a named existing browser window to computer use, leaving browser tools for the separate Namzu-managed profile.
|
|
8
|
+
|
|
9
|
+
## 3.0.0
|
|
10
|
+
|
|
11
|
+
### Major Changes
|
|
12
|
+
|
|
13
|
+
- c8bb87a: The Windows cua-driver backend now revives an implicit session after its five-minute idle expiry and retries a call that the driver explicitly refused before dispatch. UI Automation snapshots now return adapter-owned refs instead of raw cua-driver element tokens. Callers passing raw tokens to `uiAct` must use refs from the latest `uiSnapshot`; old refs cannot address a different control when the driver reuses a token after session revival or process restart. Calls whose outcomes are unknown are still not retried automatically.
|
|
14
|
+
|
|
3
15
|
## 2.0.2
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -80,13 +80,19 @@ report a clean completion, the host throws
|
|
|
80
80
|
SDK returns that state to the model with `retrySafety: 'unsafe'` instead of
|
|
81
81
|
inviting an automatic replay.
|
|
82
82
|
|
|
83
|
-
|
|
84
|
-
pixels of the captured bitmap, never points or DPI-scaled units. A capture
|
|
83
|
+
Display coordinates and sizes crossing the host are in **physical pixels**:
|
|
84
|
+
the pixels of the captured bitmap, never points or DPI-scaled units. A capture
|
|
85
85
|
carries `display` (origin, size, `scaleFactor`) and action points are
|
|
86
86
|
relative to that display. On a Retina Mac the adapter converts to points for
|
|
87
87
|
`cliclick` itself, so a click at the pixel you saw lands there; on Windows
|
|
88
88
|
every backend is DPI aware.
|
|
89
89
|
|
|
90
|
+
The Windows cua-driver backend can also capture one named window. Its PNG
|
|
91
|
+
pixels are window-local; `executeWindow` takes an opaque capture id and
|
|
92
|
+
rejects it if the window moved or the driver session changed. The SDK maps
|
|
93
|
+
fitted model coordinates back to that PNG before sending input. A plain
|
|
94
|
+
`screenshot` remains a display capture.
|
|
95
|
+
|
|
90
96
|
`host.dispose()` stops whatever the adapter keeps running. Call it when the
|
|
91
97
|
session ends.
|
|
92
98
|
|
|
@@ -112,9 +118,37 @@ standard streams:
|
|
|
112
118
|
forwarded through `WSLENV`), without any environment variable whose name
|
|
113
119
|
looks like a secret, and with its animated agent cursor off. Measured: a
|
|
114
120
|
whole session left nothing in the Windows user profile.
|
|
121
|
+
- **Idle recovery.** cua-driver ends its implicit desktop session after five
|
|
122
|
+
minutes without a completed call, even while its MCP process stays running.
|
|
123
|
+
When it explicitly refuses the next call with its structured `session_ended`
|
|
124
|
+
code before dispatch, the adapter revives that session, switches the agent
|
|
125
|
+
cursor off again, and retries the refused call once. An expired UI Automation
|
|
126
|
+
snapshot must be taken again before acting on a control. The adapter gives
|
|
127
|
+
every snapshot fresh refs and rejects old refs after a driver restart, even
|
|
128
|
+
if the driver reuses a raw element token. A lost response or driver crash
|
|
129
|
+
still leaves a changing action's outcome unknown and is never replayed
|
|
130
|
+
automatically.
|
|
115
131
|
- **Windows.** `capabilities.windows` is `true`: `listWindows()` and
|
|
116
132
|
`focusWindow(id)` (which restores a minimized window, gets past the
|
|
117
133
|
foreground lock and reports what is actually in front afterwards).
|
|
134
|
+
- **Window capture.** `capabilities.windowCapture` is `true`:
|
|
135
|
+
`captureWindow(id)` gets a PNG for that window without walking its UIA
|
|
136
|
+
tree; `executeWindow(captureId, action)` sends a click, drag, text or key to
|
|
137
|
+
the captured PID and HWND. Window text and keys default to background
|
|
138
|
+
delivery; `delivery_mode: 'foreground'` explicitly allows the driver to
|
|
139
|
+
bring the verified window forward for browser text and modifier shortcuts
|
|
140
|
+
that background delivery cannot send. To focus a browser field, click its
|
|
141
|
+
window-image point first; an atomic foreground focus-and-type is not offered
|
|
142
|
+
because the native focus click could hit an overlay. `windowScroll: false`
|
|
143
|
+
declares that window pixel scrolling
|
|
144
|
+
is refused: its background path does not deliver, and its foreground wheel
|
|
145
|
+
can reach a covering window. Use a foreground `PAGE_DOWN` key on the window
|
|
146
|
+
when appropriate. A new window capture invalidates the
|
|
147
|
+
previous token, including another window of the same process. A stale
|
|
148
|
+
token never falls back to desktop input. The pinned driver's screen-region
|
|
149
|
+
fallback may show a covering window, and its MCP result does not report
|
|
150
|
+
whether that happened; inspect the image and recapture after focusing the
|
|
151
|
+
target if it appears covered or blank.
|
|
118
152
|
- **Controls (experimental).** `capabilities.uiTree` is `true`:
|
|
119
153
|
`uiSnapshot(windowId?)` reads a window's UI Automation tree (the window in
|
|
120
154
|
front without an id) and `uiAct(ref, action, value?)` acts on a control of
|
|
@@ -165,16 +199,23 @@ Measured on Windows 10 22H2 from WSL2, one 3440x1440 display at 100 %:
|
|
|
165
199
|
| focus a window | not offered | 4–22 ms |
|
|
166
200
|
| list windows | not offered | 1.2–1.9 s |
|
|
167
201
|
|
|
168
|
-
What cua-driver does not do, and so neither does this host on Windows:
|
|
169
|
-
captures the primary display only; it has no
|
|
170
|
-
full capture instead); its window list
|
|
171
|
-
cloaked (a suspended Settings app, the text-input
|
|
202
|
+
What cua-driver does not do, and so neither does this host on Windows: its
|
|
203
|
+
plain display screenshot captures the primary display only; it has no
|
|
204
|
+
display-region capture (the SDK crops a full capture instead); its window list
|
|
205
|
+
includes windows Windows keeps cloaked (a suspended Settings app, the text-input
|
|
206
|
+
host), and it does not say
|
|
172
207
|
which window has focus — `focused` is the front-most window that is not
|
|
173
208
|
minimized. A single punctuation key (`/`, `+`) is typed as text, because
|
|
174
209
|
cua-driver resolves it to a key without its shift state and on a Turkish
|
|
175
210
|
layout `/` came out as `7`; a chord such as `ctrl+/` still goes through
|
|
176
211
|
cua-driver's key mapping.
|
|
177
212
|
|
|
213
|
+
A window-only image can miss a browser permission bubble drawn outside the
|
|
214
|
+
native window. The driver's fallback capture may also include pixels from a
|
|
215
|
+
window covering the target; the current driver does not always identify that
|
|
216
|
+
case. Take a deliberate display screenshot if the window view does not show
|
|
217
|
+
the control the task needs.
|
|
218
|
+
|
|
178
219
|
## Documentation
|
|
179
220
|
|
|
180
221
|
- [Namzu docs](https://github.com/cogitave/namzu/tree/main/docs)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ComputerUseAction, ComputerUseCapabilities, ComputerUseHost, ComputerUseResult, DisplayGeometry, FocusWindowResult, Rect, ScreenshotResult, UiActResult, UiElementAction, UiSnapshot, WindowInfo } from '@namzu/sdk';
|
|
1
|
+
import type { ComputerUseAction, ComputerUseCapabilities, ComputerUseHost, ComputerUseResult, DisplayGeometry, FocusWindowResult, Rect, ScreenshotResult, UiActResult, UiElementAction, UiSnapshot, WindowInfo, WindowInputAction, WindowScreenshotResult } from '@namzu/sdk';
|
|
2
2
|
import { type Adapter } from './adapters/types.js';
|
|
3
3
|
import type { Win32AdapterOptions } from './adapters/win32.js';
|
|
4
4
|
export interface SubprocessComputerUseHostOptions {
|
|
@@ -52,6 +52,9 @@ export declare class SubprocessComputerUseHost implements ComputerUseHost {
|
|
|
52
52
|
listWindows(): Promise<readonly WindowInfo[]>;
|
|
53
53
|
/** Offered to the model only when `capabilities.windows` is true. */
|
|
54
54
|
focusWindow(id: string): Promise<FocusWindowResult>;
|
|
55
|
+
/** Window-local PNG and input, only when the selected adapter supports both. */
|
|
56
|
+
captureWindow(id: string): Promise<WindowScreenshotResult>;
|
|
57
|
+
executeWindow(captureId: string, action: WindowInputAction): Promise<void>;
|
|
55
58
|
/** Offered to the model only when `capabilities.regionCapture` is true. */
|
|
56
59
|
captureRegion(rect: Rect): Promise<ScreenshotResult>;
|
|
57
60
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SubprocessComputerUseHost.d.ts","sourceRoot":"","sources":["../src/SubprocessComputerUseHost.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,iBAAiB,EACjB,uBAAuB,EACvB,eAAe,EACf,iBAAiB,EACjB,eAAe,EACf,iBAAiB,EACjB,IAAI,EACJ,gBAAgB,EAChB,WAAW,EACX,eAAe,EACf,UAAU,EACV,UAAU,EACV,MAAM,YAAY,CAAA;AACnB,OAAO,EAAE,KAAK,OAAO,EAA2B,MAAM,qBAAqB,CAAA;AAC3E,OAAO,KAAK,EAAE,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,26 @@ export class SubprocessComputerUseHost {
|
|
|
124
124
|
throw unsupported('focusWindow', this._capabilities.displayServer);
|
|
125
125
|
return adapter.focusWindow(id);
|
|
126
126
|
}
|
|
127
|
+
/** Window-local PNG and input, only when the selected adapter supports both. */
|
|
128
|
+
async captureWindow(id) {
|
|
129
|
+
const adapter = this.requireAdapter();
|
|
130
|
+
if (!adapter.captureWindow)
|
|
131
|
+
throw unsupported('captureWindow', this._capabilities.displayServer);
|
|
132
|
+
return adapter.captureWindow(id);
|
|
133
|
+
}
|
|
134
|
+
async executeWindow(captureId, action) {
|
|
135
|
+
const adapter = this.requireAdapter();
|
|
136
|
+
if (!adapter.executeWindow)
|
|
137
|
+
throw unsupported('executeWindow', this._capabilities.displayServer);
|
|
138
|
+
try {
|
|
139
|
+
await adapter.executeWindow(captureId, action);
|
|
140
|
+
}
|
|
141
|
+
catch (error) {
|
|
142
|
+
if (error instanceof SpawnError && UNSAFE_TO_REPLAY_AFTER_START.has(action.type))
|
|
143
|
+
throw new ComputerUseOutcomeUnknownError(action.type, error);
|
|
144
|
+
throw error;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
127
147
|
/** Offered to the model only when `capabilities.regionCapture` is true. */
|
|
128
148
|
async captureRegion(rect) {
|
|
129
149
|
const adapter = this.requireAdapter();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SubprocessComputerUseHost.js","sourceRoot":"","sources":["../src/SubprocessComputerUseHost.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"SubprocessComputerUseHost.js","sourceRoot":"","sources":["../src/SubprocessComputerUseHost.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAgB,uBAAuB,EAAE,MAAM,qBAAqB,CAAA;AAE3E,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAA;AACvD,OAAO,EAAE,8BAA8B,EAAE,MAAM,aAAa,CAAA;AAC5D,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAE5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AC,yBAAyB,CAAC,CAAA;YACnE,OAAO,eAAe,CAAC,MAAM,EAAE,CAAA;QAChC,CAAC;QACD,KAAK,SAAS,CAAC,CAAC,CAAC;YAChB,MAAM,EAAE,mBAAmB,EAAE,GAAG,MAAM,MAAM,CAAC,6BAA6B,CAAC,CAAA;YAC3E,OAAO,mBAAmB,CAAC,MAAM,EAAE,CAAA;QACpC,CAAC;QACD,KAAK,OAAO,CAAC,CAAC,CAAC;YACd,MAAM,EAAE,YAAY,EAAE,GAAG,MAAM,MAAM,CAAC,qBAAqB,CAAC,CAAA;YAC5D,OAAO,YAAY,CAAC,MAAM,CAAC;gBAC1B,GAAG,OAAO,CAAC,OAAO;gBAClB,GAAG,CAAC,OAAO,CAAC,GAAG,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;gBAC1D,GAAG,CAAC,OAAO,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;aACzE,CAAC,CAAA;QACH,CAAC;QACD,KAAK,SAAS;YACb,MAAM,IAAI,KAAK,CACd,sEAAsE,aAAa,OAAO,CAC1F,CAAA;IACH,CAAC;AACF,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ComputerUseAction, ComputerUseCapabilities, ComputerUseResult, DisplayGeometry, FocusWindowResult, UiActResult, UiElementAction, UiSnapshot, WindowInfo } from '@namzu/sdk';
|
|
1
|
+
import type { ComputerUseAction, ComputerUseCapabilities, ComputerUseResult, DisplayGeometry, FocusWindowResult, UiActResult, UiElementAction, UiSnapshot, WindowInfo, WindowInputAction, WindowScreenshotResult } from '@namzu/sdk';
|
|
2
2
|
import type { Adapter } from '../types.js';
|
|
3
3
|
import { type McpStdioClientOptions, type McpToolResult } from './client.js';
|
|
4
4
|
/**
|
|
@@ -6,10 +6,9 @@ import { type McpStdioClientOptions, type McpToolResult } from './client.js';
|
|
|
6
6
|
* `cua-driver.exe mcp` process for the adapter's lifetime, spoken to as an
|
|
7
7
|
* MCP server over its standard streams.
|
|
8
8
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* different model this adapter does not expose.
|
|
9
|
+
* Display input uses `desktop` scope. A capture explicitly addressed to a
|
|
10
|
+
* window enables `window` scope, whose pixels are relative to that PNG and
|
|
11
|
+
* whose actions carry the captured PID and HWND.
|
|
13
12
|
*
|
|
14
13
|
* What the adapter adds on top:
|
|
15
14
|
* - the animated agent cursor is switched off for its session: with it, a
|
|
@@ -21,8 +20,8 @@ import { type McpStdioClientOptions, type McpToolResult } from './client.js';
|
|
|
21
20
|
* - the window list drops cua-driver's own overlay, the shell's desktop and
|
|
22
21
|
* 1-pixel windows, and orders it front to back;
|
|
23
22
|
* - a window's UI Automation tree (`get_window_state`) becomes a `UiSnapshot`
|
|
24
|
-
*
|
|
25
|
-
*
|
|
23
|
+
* with adapter-owned refs; `uiAct` translates them to driver element tokens:
|
|
24
|
+
* UIA Invoke for a button, ValuePattern for a field, falling back
|
|
26
25
|
* to typing into a field that is empty and has no settable value (classic
|
|
27
26
|
* Notepad's editor is one).
|
|
28
27
|
*/
|
|
@@ -45,8 +44,18 @@ export declare class CuaDriverAdapter implements Adapter {
|
|
|
45
44
|
private readonly client;
|
|
46
45
|
/** Window id → owning pid, from the latest list; `bring_to_front` needs both. */
|
|
47
46
|
private readonly windowPids;
|
|
48
|
-
/**
|
|
47
|
+
/** cua-driver's screenshot resize registry is per PID, so only this capture may drive input. */
|
|
48
|
+
private windowFrame;
|
|
49
|
+
/** Capture and scoped input must not race over cua-driver's per-PID resize ratio. */
|
|
50
|
+
private windowOperation;
|
|
51
|
+
/** Only refs from the latest snapshot may address driver tokens. */
|
|
49
52
|
private uiRefs;
|
|
53
|
+
private readonly uiRefNamespace;
|
|
54
|
+
private nextSnapshot;
|
|
55
|
+
/** A successful revival invalidates refusals from the previous lifecycle episode. */
|
|
56
|
+
private sessionGeneration;
|
|
57
|
+
/** Share one revival among calls refused by the same expired implicit session. */
|
|
58
|
+
private sessionRevival;
|
|
50
59
|
constructor(options: CuaDriverAdapterOptions);
|
|
51
60
|
/** How many driver processes this adapter has started (a restart after a crash counts). */
|
|
52
61
|
get processStarts(): number;
|
|
@@ -54,6 +63,10 @@ export declare class CuaDriverAdapter implements Adapter {
|
|
|
54
63
|
execute(action: ComputerUseAction): Promise<ComputerUseResult>;
|
|
55
64
|
listWindows(): Promise<readonly WindowInfo[]>;
|
|
56
65
|
focusWindow(id: string): Promise<FocusWindowResult>;
|
|
66
|
+
captureWindow(id: string): Promise<WindowScreenshotResult>;
|
|
67
|
+
private captureWindowInternal;
|
|
68
|
+
executeWindow(captureId: string, action: WindowInputAction): Promise<void>;
|
|
69
|
+
private executeWindowInternal;
|
|
57
70
|
/**
|
|
58
71
|
* One window's controls. Without an id, the window in front — which,
|
|
59
72
|
* for an agent run from a terminal, is usually that terminal.
|
|
@@ -61,6 +74,14 @@ export declare class CuaDriverAdapter implements Adapter {
|
|
|
61
74
|
uiSnapshot(windowId?: string): Promise<UiSnapshot>;
|
|
62
75
|
uiAct(ref: string, action: UiElementAction, value?: string): Promise<UiActResult>;
|
|
63
76
|
dispose(): Promise<void>;
|
|
77
|
+
private serializeWindowOperation;
|
|
78
|
+
/**
|
|
79
|
+
* cua-driver refuses an expired implicit session before dispatch, with a
|
|
80
|
+
* structured `session_ended` code. Only that exact refusal is safe to replay.
|
|
81
|
+
* A lost response or transport failure still has an unknown action outcome.
|
|
82
|
+
*/
|
|
83
|
+
private callTool;
|
|
84
|
+
private reviveSession;
|
|
64
85
|
/** A window id (or the window in front) → its handle and owning process. */
|
|
65
86
|
private resolveWindow;
|
|
66
87
|
private pointer;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../../src/adapters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