@namzu/sdk 48.2.0 → 48.3.1

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 (28) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/runtime/jobs/registry.d.ts.map +1 -1
  3. package/dist/runtime/jobs/registry.js +15 -7
  4. package/dist/runtime/jobs/registry.js.map +1 -1
  5. package/dist/tools/builtins/computer-use-coordinates.d.ts +13 -1
  6. package/dist/tools/builtins/computer-use-coordinates.d.ts.map +1 -1
  7. package/dist/tools/builtins/computer-use-coordinates.js +46 -0
  8. package/dist/tools/builtins/computer-use-coordinates.js.map +1 -1
  9. package/dist/tools/builtins/computer-use.d.ts +135 -0
  10. package/dist/tools/builtins/computer-use.d.ts.map +1 -1
  11. package/dist/tools/builtins/computer-use.js +255 -54
  12. package/dist/tools/builtins/computer-use.js.map +1 -1
  13. package/dist/tools/builtins/wait-for-job-bounds.d.ts.map +1 -1
  14. package/dist/tools/builtins/wait-for-job-bounds.js +4 -0
  15. package/dist/tools/builtins/wait-for-job-bounds.js.map +1 -1
  16. package/dist/tools/coordinator/wait-with-idle-bound.d.ts.map +1 -1
  17. package/dist/tools/coordinator/wait-with-idle-bound.js +4 -0
  18. package/dist/tools/coordinator/wait-with-idle-bound.js.map +1 -1
  19. package/dist/types/computer-use/index.d.ts +56 -1
  20. package/dist/types/computer-use/index.d.ts.map +1 -1
  21. package/dist/types/computer-use/index.js.map +1 -1
  22. package/package.json +1 -1
  23. package/src/runtime/jobs/registry.ts +14 -7
  24. package/src/tools/builtins/computer-use-coordinates.ts +58 -1
  25. package/src/tools/builtins/computer-use.ts +336 -54
  26. package/src/tools/builtins/wait-for-job-bounds.ts +3 -0
  27. package/src/tools/coordinator/wait-with-idle-bound.ts +3 -0
  28. package/src/types/computer-use/index.ts +65 -7
@@ -91,6 +91,7 @@ export async function waitForJobWithBounds(
91
91
  let output = ''
92
92
  let droppedBytes = 0
93
93
  let settled = false
94
+ let poll: ReturnType<typeof setInterval> | undefined
94
95
 
95
96
  /** Read whatever is new since `cursor`, and count it as progress if it is. */
96
97
  const drain = (): void => {
@@ -153,6 +154,7 @@ export async function waitForJobWithBounds(
153
154
  }
154
155
  }
155
156
  }, POLL_INTERVAL_MS)
157
+ poll = tick
156
158
  // Never the reason a process stays alive — this races a real
157
159
  // exit promise, so the wait is held open by work that is
158
160
  // genuinely outstanding rather than by this timer.
@@ -162,6 +164,7 @@ export async function waitForJobWithBounds(
162
164
  return await Promise.race([exited, expiry])
163
165
  } finally {
164
166
  settled = true
167
+ if (poll !== undefined) clearInterval(poll)
165
168
  }
166
169
  }
167
170
 
@@ -69,6 +69,7 @@ export async function waitForTaskWithBounds(
69
69
  const startedAt = now()
70
70
  let lastProgressAt = startedAt
71
71
  let settled = false
72
+ let poll: ReturnType<typeof setInterval> | undefined
72
73
 
73
74
  const detach = gateway.onTaskProgress?.((id) => {
74
75
  if (id === taskId) lastProgressAt = now()
@@ -107,6 +108,7 @@ export async function waitForTaskWithBounds(
107
108
  }
108
109
  }
109
110
  }, POLL_INTERVAL_MS)
111
+ poll = tick
110
112
  // Never the reason a process stays alive. This one is safe to unref
111
113
  // where the park recorder was not, because nothing AWAITS it alone:
112
114
  // it races a real completion promise, so the wait is held open by
@@ -117,6 +119,7 @@ export async function waitForTaskWithBounds(
117
119
  return await Promise.race([completion, expiry])
118
120
  } finally {
119
121
  settled = true
122
+ if (poll !== undefined) clearInterval(poll)
120
123
  detach?.()
121
124
  }
122
125
  }
@@ -30,7 +30,7 @@ export interface ComputerUseCapabilities {
30
30
  readonly keyboard: boolean
31
31
  readonly cursorPosition: boolean
32
32
  readonly clipboard: boolean
33
- /** Exact action subset when known. Refines the broad flags; absent retains their legacy interpretation. */
33
+ /** Display action subset when known. Window capture and input are a separate path. */
34
34
  readonly supportedActions?: readonly ComputerUseAction['type'][]
35
35
  /** Supported click buttons; absent leaves button admission to the host. */
36
36
  readonly mouseClickButtons?: readonly MouseButton[]
@@ -50,6 +50,16 @@ export interface ComputerUseCapabilities {
50
50
  * offer `list_windows` or `focus_window`, even when the methods exist.
51
51
  */
52
52
  readonly windows?: boolean
53
+ /**
54
+ * The host can capture and act on one named window without sharing the
55
+ * whole desktop. Requires `captureWindow` and `executeWindow`.
56
+ */
57
+ readonly windowCapture?: boolean
58
+ /**
59
+ * Whether scoped pixel scrolling can be delivered safely. Explicit false
60
+ * refuses it before a batch starts; absent retains host-defined behavior.
61
+ */
62
+ readonly windowScroll?: boolean
53
63
  /**
54
64
  * The host implements {@link ComputerUseHost.captureRegion}. Absent or
55
65
  * false, `zoom` still works: the tool crops a full capture instead, which
@@ -71,12 +81,13 @@ export interface ComputerUseCapabilities {
71
81
  // ---------------------------------------------------------------------------
72
82
  // Geometry + screenshot payload
73
83
  //
74
- // Units, once for the whole file: every coordinate and size a host accepts or
75
- // returns is in PHYSICAL pixels — the pixels of the captured bitmap, not
76
- // logical points or DPI-scaled units. A 3440x1440 monitor at 150 % scaling is
77
- // 3440x1440 here. A point a host is asked to act on is relative to the
78
- // top-left of the display it last captured (the primary display until a host
79
- // offers display selection); the host adds that display's origin itself.
84
+ // Display actions use PHYSICAL pixels, not logical points or DPI-scaled
85
+ // units. A 3440x1440 monitor at 150 % scaling is 3440x1440 here. A point a
86
+ // host is asked to act on is relative to the top-left of the display it last
87
+ // captured (the primary display until a host offers display selection); the
88
+ // host adds that display's origin itself. Window actions are the explicit
89
+ // exception: their coordinates are pixels of captureWindow's returned PNG,
90
+ // which the window driver may have downscaled.
80
91
  // Window and UI-element bounds are the exception and say so: they are in
81
92
  // virtual-desktop physical pixels, because a window can span displays.
82
93
  // ---------------------------------------------------------------------------
@@ -146,6 +157,45 @@ export interface WindowInfo {
146
157
  readonly minimized: boolean
147
158
  }
148
159
 
160
+ /** A PNG of one window. Its pixels are window-local, not display-relative. */
161
+ export interface WindowScreenshotResult {
162
+ readonly data: Buffer
163
+ readonly mimeType: 'image/png'
164
+ /** Pixel size of the exact PNG returned by the host. */
165
+ readonly width: number
166
+ readonly height: number
167
+ readonly window: WindowInfo
168
+ /**
169
+ * Opaque capture token. The host rejects actions after another window
170
+ * capture, driver restart, session revival, or target geometry change.
171
+ */
172
+ readonly captureId: string
173
+ /** A limitation of this capture, when the driver reports one. */
174
+ readonly captureCoverage?: string
175
+ }
176
+
177
+ /** How input is delivered to a captured window. Foreground may briefly activate it. */
178
+ export type WindowDeliveryMode = 'background' | 'foreground'
179
+
180
+ /** Window-local actions. A window-scoped mouse move is not a real OS move. */
181
+ export type WindowInputAction =
182
+ | Extract<ComputerUseAction, { readonly type: 'mouse_click' | 'mouse_drag' | 'scroll' }>
183
+ /** Foreground delivery sends text to the verified target window. */
184
+ | {
185
+ readonly type: 'type_text'
186
+ readonly text: string
187
+ readonly delivery_mode?: WindowDeliveryMode
188
+ }
189
+ /**
190
+ * `foreground` explicitly permits the host to bring the verified target
191
+ * window forward for keys its background input path cannot deliver.
192
+ */
193
+ | {
194
+ readonly type: 'key'
195
+ readonly keys: string
196
+ readonly delivery_mode?: WindowDeliveryMode
197
+ }
198
+
149
199
  /**
150
200
  * What {@link ComputerUseHost.focusWindow} achieved. Bringing a window to
151
201
  * the front is a request the operating system can refuse (Windows'
@@ -334,6 +384,14 @@ export interface ComputerUseHost {
334
384
  * with {@link ComputerUseCapabilities.windows}.
335
385
  */
336
386
  focusWindow?(id: string): Promise<FocusWindowResult>
387
+ /** Capture a named window. Never silently replace a failed capture with the desktop. */
388
+ captureWindow?(id: string): Promise<WindowScreenshotResult>
389
+ /**
390
+ * Act in the PNG pixel space of `captureId`. The host must verify the
391
+ * capture is current and still belongs to the same process/window before
392
+ * dispatching input. No implicit fallback to display input is permitted.
393
+ */
394
+ executeWindow?(captureId: string, action: WindowInputAction): Promise<void>
337
395
  /**
338
396
  * Capture one region of the current display at full physical resolution.
339
397
  * `rect` is display-relative physical pixels; the result's `width` and