@namzu/sdk 48.1.0 → 48.3.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 +14 -0
- package/dist/tools/builtins/computer-use-coordinates.d.ts +13 -1
- package/dist/tools/builtins/computer-use-coordinates.d.ts.map +1 -1
- package/dist/tools/builtins/computer-use-coordinates.js +46 -0
- package/dist/tools/builtins/computer-use-coordinates.js.map +1 -1
- package/dist/tools/builtins/computer-use.d.ts +135 -0
- package/dist/tools/builtins/computer-use.d.ts.map +1 -1
- package/dist/tools/builtins/computer-use.js +255 -54
- package/dist/tools/builtins/computer-use.js.map +1 -1
- package/dist/tools/schedules/schedule-tool.d.ts.map +1 -1
- package/dist/tools/schedules/schedule-tool.js +12 -5
- package/dist/tools/schedules/schedule-tool.js.map +1 -1
- package/dist/tools/schedules/types.d.ts +6 -0
- package/dist/tools/schedules/types.d.ts.map +1 -1
- package/dist/types/computer-use/index.d.ts +56 -1
- package/dist/types/computer-use/index.d.ts.map +1 -1
- package/dist/types/computer-use/index.js.map +1 -1
- package/package.json +1 -1
- package/src/tools/builtins/computer-use-coordinates.ts +58 -1
- package/src/tools/builtins/computer-use.ts +336 -54
- package/src/tools/schedules/schedule-tool.ts +16 -5
- package/src/tools/schedules/types.ts +6 -0
- package/src/types/computer-use/index.ts +65 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/types/computer-use/index.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,0DAA0D;AAC1D,8EAA8E;AAI9E,MAAM,UAAU,mBAAmB,CAAC,KAAoB;IACvD,QAAQ,KAAK,EAAE,CAAC;QACf,KAAK,QAAQ,CAAC;QACd,KAAK,OAAO,CAAC;QACb,KAAK,KAAK,CAAC;QACX,KAAK,SAAS,CAAC;QACf,KAAK,SAAS;YACb,OAAM;QACP,OAAO,CAAC,CAAC,CAAC;YACT,MAAM,WAAW,GAAU,KAAK,CAAA;YAChC,MAAM,IAAI,KAAK,CAAC,0BAA0B,WAAW,EAAE,CAAC,CAAA;QACzD,CAAC;IACF,CAAC;AACF,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/types/computer-use/index.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,0DAA0D;AAC1D,8EAA8E;AAI9E,MAAM,UAAU,mBAAmB,CAAC,KAAoB;IACvD,QAAQ,KAAK,EAAE,CAAC;QACf,KAAK,QAAQ,CAAC;QACd,KAAK,OAAO,CAAC;QACb,KAAK,KAAK,CAAC;QACX,KAAK,SAAS,CAAC;QACf,KAAK,SAAS;YACb,OAAM;QACP,OAAO,CAAC,CAAC,CAAC;YACT,MAAM,WAAW,GAAU,KAAK,CAAA;YAChC,MAAM,IAAI,KAAK,CAAC,0BAA0B,WAAW,EAAE,CAAC,CAAA;QACzD,CAAC;IACF,CAAC;AACF,CAAC;AAqSD,MAAM,UAAU,2BAA2B,CAAC,IAA+B;IAC1E,QAAQ,IAAI,EAAE,CAAC;QACd,KAAK,YAAY,CAAC;QAClB,KAAK,iBAAiB,CAAC;QACvB,KAAK,YAAY,CAAC;QAClB,KAAK,aAAa,CAAC;QACnB,KAAK,YAAY,CAAC;QAClB,KAAK,QAAQ,CAAC;QACd,KAAK,WAAW,CAAC;QACjB,KAAK,KAAK;YACT,OAAM;QACP,OAAO,CAAC,CAAC,CAAC;YACT,MAAM,WAAW,GAAU,IAAI,CAAA;YAC/B,MAAM,IAAI,KAAK,CAAC,mCAAmC,WAAW,EAAE,CAAC,CAAA;QAClE,CAAC;IACF,CAAC;AACF,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type {
|
|
2
|
+
DisplayInfo,
|
|
3
|
+
Point,
|
|
4
|
+
Rect,
|
|
5
|
+
WindowScreenshotResult,
|
|
6
|
+
} from '../../types/computer-use/index.js'
|
|
2
7
|
|
|
3
8
|
/**
|
|
4
9
|
* One screenshot the model was shown: its id, the size of the image it saw,
|
|
@@ -12,6 +17,8 @@ export interface ScreenshotFrame {
|
|
|
12
17
|
readonly imageHeight: number
|
|
13
18
|
/** Physical size and virtual-desktop origin of what the image shows. */
|
|
14
19
|
readonly display: DisplayInfo
|
|
20
|
+
/** Present only for an explicit capture of one window. */
|
|
21
|
+
readonly window?: Omit<WindowScreenshotResult, 'data'> & { readonly data?: Buffer }
|
|
15
22
|
}
|
|
16
23
|
|
|
17
24
|
/**
|
|
@@ -28,7 +35,16 @@ export class ScreenshotFrames {
|
|
|
28
35
|
|
|
29
36
|
constructor(private readonly capacity = 32) {}
|
|
30
37
|
|
|
38
|
+
/** Only the newest window PNG is needed for zoom; older tokens cannot act. */
|
|
39
|
+
private discardOldWindowPixels(): void {
|
|
40
|
+
for (const [id, frame] of this.frames) {
|
|
41
|
+
if (frame.window?.data)
|
|
42
|
+
this.frames.set(id, { ...frame, window: { ...frame.window, data: undefined } })
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
31
46
|
record(image: { width: number; height: number }, display: DisplayInfo): ScreenshotFrame {
|
|
47
|
+
this.discardOldWindowPixels()
|
|
32
48
|
this.counter += 1
|
|
33
49
|
const frame: ScreenshotFrame = {
|
|
34
50
|
id: `s${this.counter}`,
|
|
@@ -46,6 +62,38 @@ export class ScreenshotFrames {
|
|
|
46
62
|
return frame
|
|
47
63
|
}
|
|
48
64
|
|
|
65
|
+
recordWindow(
|
|
66
|
+
image: { width: number; height: number },
|
|
67
|
+
window: WindowScreenshotResult,
|
|
68
|
+
): ScreenshotFrame {
|
|
69
|
+
this.discardOldWindowPixels()
|
|
70
|
+
this.counter += 1
|
|
71
|
+
const frame: ScreenshotFrame = {
|
|
72
|
+
id: `s${this.counter}`,
|
|
73
|
+
imageWidth: image.width,
|
|
74
|
+
imageHeight: image.height,
|
|
75
|
+
// Kept only for the common image-size helpers; a window frame never
|
|
76
|
+
// enters a display-coordinate action or virtual-desktop projection.
|
|
77
|
+
display: {
|
|
78
|
+
id: window.window.id,
|
|
79
|
+
x: window.window.bounds.x,
|
|
80
|
+
y: window.window.bounds.y,
|
|
81
|
+
width: window.width,
|
|
82
|
+
height: window.height,
|
|
83
|
+
scaleFactor: 1,
|
|
84
|
+
},
|
|
85
|
+
window,
|
|
86
|
+
}
|
|
87
|
+
this.frames.set(frame.id, frame)
|
|
88
|
+
this.newest = frame
|
|
89
|
+
while (this.frames.size > this.capacity) {
|
|
90
|
+
const oldest = this.frames.keys().next().value
|
|
91
|
+
if (oldest === undefined) break
|
|
92
|
+
this.frames.delete(oldest)
|
|
93
|
+
}
|
|
94
|
+
return frame
|
|
95
|
+
}
|
|
96
|
+
|
|
49
97
|
latest(): ScreenshotFrame | undefined {
|
|
50
98
|
return this.newest
|
|
51
99
|
}
|
|
@@ -96,6 +144,15 @@ export function toDisplayPoint(frame: ScreenshotFrame, point: Point): Point {
|
|
|
96
144
|
}
|
|
97
145
|
}
|
|
98
146
|
|
|
147
|
+
/** Model image pixels to the exact PNG pixel space accepted by the window driver. */
|
|
148
|
+
export function toWindowPoint(frame: ScreenshotFrame, point: Point): Point {
|
|
149
|
+
if (!frame.window) throw new Error('computer_use: expected a window screenshot')
|
|
150
|
+
return {
|
|
151
|
+
x: axisToDisplay(point.x, frame.imageWidth, frame.window.width),
|
|
152
|
+
y: axisToDisplay(point.y, frame.imageHeight, frame.window.height),
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
99
156
|
/** A display-relative physical pixel as the image pixel of `frame` that shows it. */
|
|
100
157
|
export function toImagePoint(frame: ScreenshotFrame, point: Point): Point {
|
|
101
158
|
return {
|