11// GENERATED — do not edit. Source of truth: mothership worker packages/contracts/src/computer-use.ts
22// Regenerate with `bun run contracts:sync` in the worker.
33
4- import { z } from ' zod'
4+ import { z } from " zod" ;
55
66const BundleId = z
77 . string ( )
88 . min ( 1 )
99 . max ( 255 )
1010 . describe (
11- ' Exact bundleId returned by list_apps or a known installed macOS app. get_app_state may launch it.'
12- )
11+ " Exact bundleId returned by list_apps or a known installed macOS app. get_app_state may launch it." ,
12+ ) ;
1313const SnapshotId = z
1414 . string ( )
1515 . min ( 1 )
1616 . max ( 128 )
17- . describe ( ' Latest unconsumed snapshotId from get_app_state for this app. Actions consume it.' )
18- const ElementId = z . string ( ) . min ( 1 ) . max ( 128 ) . describe ( ' Element reference from that snapshot.' )
19- const WindowId = z . string ( ) . min ( 1 ) . max ( 128 ) . describe ( ' Window reference from that snapshot.' )
20- const Coordinate = z . number ( ) . nonnegative ( ) . max ( 100_000 )
21- const ElementTarget = { bundleId : BundleId , snapshotId : SnapshotId , elementId : ElementId }
22- const WindowTarget = { bundleId : BundleId , snapshotId : SnapshotId , windowId : WindowId }
23- const PointTarget = { ...WindowTarget , x : Coordinate , y : Coordinate }
17+ . describe ( " Latest unconsumed snapshotId from get_app_state for this app. Actions consume it." ) ;
18+ const ElementId = z . string ( ) . min ( 1 ) . max ( 128 ) . describe ( " Element reference from that snapshot." ) ;
19+ const WindowId = z . string ( ) . min ( 1 ) . max ( 128 ) . describe ( " Window reference from that snapshot." ) ;
20+ const Coordinate = z . number ( ) . nonnegative ( ) . max ( 100_000 ) ;
21+ const ElementTarget = { bundleId : BundleId , snapshotId : SnapshotId , elementId : ElementId } ;
22+ const WindowTarget = { bundleId : BundleId , snapshotId : SnapshotId , windowId : WindowId } ;
23+ const PointTarget = { ...WindowTarget , x : Coordinate , y : Coordinate } ;
2424const ClickOptions = {
25- button : z . enum ( [ ' left' , ' right' ] ) . optional ( ) ,
25+ button : z . enum ( [ " left" , " right" ] ) . optional ( ) ,
2626 clickCount : z . number ( ) . int ( ) . min ( 1 ) . max ( 3 ) . optional ( ) ,
27- }
27+ } ;
2828const ScrollOffsets = {
2929 deltaX : z
3030 . number ( )
3131 . min ( - 10_000 )
3232 . max ( 10_000 )
33- . describe ( ' Horizontal scroll distance in points; positive scrolls right, negative left.' ) ,
33+ . describe ( " Horizontal scroll distance in points; positive scrolls right, negative left." ) ,
3434 deltaY : z
3535 . number ( )
3636 . min ( - 10_000 )
3737 . max ( 10_000 )
38- . describe ( ' Vertical scroll distance in points; positive scrolls down, negative up.' ) ,
39- }
38+ . describe ( " Vertical scroll distance in points; positive scrolls down, negative up." ) ,
39+ } ;
4040
4141/** Strict branches require an observed, unambiguous target before native input. */
4242export const ComputerUseSchema = z . union ( [
43- z . strictObject ( { action : z . literal ( ' status' ) } ) ,
44- z . strictObject ( { action : z . literal ( ' list_apps' ) } ) ,
45- z . strictObject ( { action : z . literal ( ' activate_app' ) , bundleId : BundleId } ) ,
43+ z . strictObject ( { action : z . literal ( " status" ) } ) ,
44+ z . strictObject ( { action : z . literal ( " list_apps" ) } ) ,
45+ z . strictObject ( { action : z . literal ( " activate_app" ) , bundleId : BundleId } ) ,
4646 z . strictObject ( {
47- action : z . literal ( ' get_app_state' ) ,
47+ action : z . literal ( " get_app_state" ) ,
4848 bundleId : BundleId ,
4949 windowId : WindowId . optional ( ) ,
5050 includeScreenshot : z
5151 . boolean ( )
5252 . optional ( )
53- . describe ( ' Set true to include an image of the selected window.' ) ,
53+ . describe ( " Set true to include an image of the selected window." ) ,
5454 } ) ,
55- z . strictObject ( { action : z . literal ( ' click' ) , ...ElementTarget , ...ClickOptions } ) ,
56- z . strictObject ( { action : z . literal ( ' click' ) , ...PointTarget , ...ClickOptions } ) ,
55+ z . strictObject ( { action : z . literal ( " click" ) , ...ElementTarget , ...ClickOptions } ) ,
56+ z . strictObject ( { action : z . literal ( " click" ) , ...PointTarget , ...ClickOptions } ) ,
5757 z . strictObject ( {
58- action : z . literal ( ' type_text' ) ,
58+ action : z . literal ( " type_text" ) ,
5959 ...ElementTarget ,
60- text : z
61- . string ( )
62- . max ( 32_000 )
63- . describe ( 'Literal text to type into the observed editable element.' ) ,
60+ text : z . string ( ) . max ( 32_000 ) . describe ( "Literal text to type into the observed editable element." ) ,
6461 } ) ,
6562 z . strictObject ( {
66- action : z . literal ( ' press_key' ) ,
63+ action : z . literal ( " press_key" ) ,
6764 ...WindowTarget ,
68- key : z
69- . string ( )
70- . min ( 1 )
71- . max ( 128 )
72- . describe ( 'One key or chord, such as Enter, Tab, Escape, or Cmd+A.' ) ,
65+ key : z . string ( ) . min ( 1 ) . max ( 128 ) . describe ( "One key or chord, such as Enter, Tab, Escape, or Cmd+A." ) ,
7366 } ) ,
74- z . strictObject ( { action : z . literal ( ' scroll' ) , ...ElementTarget , ...ScrollOffsets } ) ,
75- z . strictObject ( { action : z . literal ( ' scroll' ) , ...PointTarget , ...ScrollOffsets } ) ,
76- z . strictObject ( { action : z . literal ( ' drag' ) , ...PointTarget , toX : Coordinate , toY : Coordinate } ) ,
67+ z . strictObject ( { action : z . literal ( " scroll" ) , ...ElementTarget , ...ScrollOffsets } ) ,
68+ z . strictObject ( { action : z . literal ( " scroll" ) , ...PointTarget , ...ScrollOffsets } ) ,
69+ z . strictObject ( { action : z . literal ( " drag" ) , ...PointTarget , toX : Coordinate , toY : Coordinate } ) ,
7770 z . strictObject ( {
78- action : z . literal ( ' set_value' ) ,
71+ action : z . literal ( " set_value" ) ,
7972 ...ElementTarget ,
80- value : z
81- . string ( )
82- . max ( 32_000 )
83- . describe ( 'Replacement value for an accessibility-writable element.' ) ,
73+ value : z . string ( ) . max ( 32_000 ) . describe ( "Replacement value for an accessibility-writable element." ) ,
8474 } ) ,
8575 z . strictObject ( {
86- action : z . literal ( ' perform_action' ) ,
76+ action : z . literal ( " perform_action" ) ,
8777 ...ElementTarget ,
88- accessibilityAction : z
89- . string ( )
90- . min ( 1 )
91- . max ( 128 )
92- . describe ( 'Exact action advertised by this element.' ) ,
78+ accessibilityAction : z . string ( ) . min ( 1 ) . max ( 128 ) . describe ( "Exact action advertised by this element." ) ,
9379 } ) ,
94- ] )
95- export type ComputerUseInput = z . infer < typeof ComputerUseSchema >
80+ ] ) ;
81+ export type ComputerUseInput = z . infer < typeof ComputerUseSchema > ;
9682
9783export const ComputerUseStatusSchema = z . strictObject ( {
98- kind : z . literal ( ' status' ) ,
99- platform : z . literal ( ' darwin' ) ,
84+ kind : z . literal ( " status" ) ,
85+ platform : z . literal ( " darwin" ) ,
10086 accessibility : z . boolean ( ) ,
10187 screenRecording : z . boolean ( ) ,
102- } )
103- export type ComputerUseStatus = z . infer < typeof ComputerUseStatusSchema >
88+ } ) ;
89+ export type ComputerUseStatus = z . infer < typeof ComputerUseStatusSchema > ;
10490
10591export const ComputerUseAppSchema = z . strictObject ( {
10692 bundleId : BundleId ,
10793 name : z . string ( ) . max ( 1024 ) ,
10894 pid : z . number ( ) . int ( ) . positive ( ) . optional ( ) ,
10995 isActive : z . boolean ( ) ,
110- } )
111- export type ComputerUseApp = z . infer < typeof ComputerUseAppSchema >
96+ } ) ;
97+ export type ComputerUseApp = z . infer < typeof ComputerUseAppSchema > ;
11298
11399export const ComputerUseWindowSchema = z . strictObject ( {
114100 windowId : WindowId ,
@@ -117,8 +103,8 @@ export const ComputerUseWindowSchema = z.strictObject({
117103 y : z . number ( ) ,
118104 width : z . number ( ) . nonnegative ( ) ,
119105 height : z . number ( ) . nonnegative ( ) ,
120- } )
121- export type ComputerUseWindow = z . infer < typeof ComputerUseWindowSchema >
106+ } ) ;
107+ export type ComputerUseWindow = z . infer < typeof ComputerUseWindowSchema > ;
122108
123109const ComputerUseNodeSchema = z . strictObject ( {
124110 elementId : ElementId ,
@@ -129,21 +115,21 @@ const ComputerUseNodeSchema = z.strictObject({
129115 enabled : z . boolean ( ) . optional ( ) ,
130116 actions : z . array ( z . string ( ) . max ( 128 ) ) . max ( 128 ) ,
131117 windowId : WindowId . optional ( ) ,
132- x : z . number ( ) . optional ( ) . describe ( ' Global screen coordinate in points, not window-local.' ) ,
133- y : z . number ( ) . optional ( ) . describe ( ' Global screen coordinate in points, not window-local.' ) ,
118+ x : z . number ( ) . optional ( ) . describe ( " Global screen coordinate in points, not window-local." ) ,
119+ y : z . number ( ) . optional ( ) . describe ( " Global screen coordinate in points, not window-local." ) ,
134120 width : z . number ( ) . nonnegative ( ) . optional ( ) ,
135121 height : z . number ( ) . nonnegative ( ) . optional ( ) ,
136- } )
122+ } ) ;
137123
138124export const ComputerUseScreenshotSchema = z . strictObject ( {
139125 base64 : z . string ( ) . min ( 1 ) . max ( 11_200_000 ) ,
140- mimeType : z . literal ( ' image/png' ) ,
126+ mimeType : z . literal ( " image/png" ) ,
141127 width : z . number ( ) . int ( ) . positive ( ) ,
142128 height : z . number ( ) . int ( ) . positive ( ) ,
143- } )
129+ } ) ;
144130
145131export const ComputerUseSnapshotSchema = z . strictObject ( {
146- kind : z . literal ( ' state' ) ,
132+ kind : z . literal ( " state" ) ,
147133 bundleId : BundleId ,
148134 snapshotId : SnapshotId ,
149135 windowId : WindowId ,
@@ -152,39 +138,36 @@ export const ComputerUseSnapshotSchema = z.strictObject({
152138 truncated : z . boolean ( ) ,
153139 screenshot : ComputerUseScreenshotSchema . optional ( ) ,
154140 screenshotError : z . string ( ) . max ( 2000 ) . optional ( ) ,
155- } )
156- export type ComputerUseSnapshot = z . infer < typeof ComputerUseSnapshotSchema >
141+ } ) ;
142+ export type ComputerUseSnapshot = z . infer < typeof ComputerUseSnapshotSchema > ;
157143
158- export const ComputerUseResultSchema = z . discriminatedUnion ( ' kind' , [
144+ export const ComputerUseResultSchema = z . discriminatedUnion ( " kind" , [
159145 ComputerUseStatusSchema ,
160- z . strictObject ( { kind : z . literal ( ' apps' ) , apps : z . array ( ComputerUseAppSchema ) . max ( 1000 ) } ) ,
146+ z . strictObject ( { kind : z . literal ( " apps" ) , apps : z . array ( ComputerUseAppSchema ) . max ( 1000 ) } ) ,
161147 ComputerUseSnapshotSchema ,
162148 z . strictObject ( {
163- kind : z . literal ( ' action' ) ,
149+ kind : z . literal ( " action" ) ,
164150 action : z . enum ( [
165- ' activate_app' ,
166- ' click' ,
167- ' type_text' ,
168- ' press_key' ,
169- ' scroll' ,
170- ' drag' ,
171- ' set_value' ,
172- ' perform_action' ,
151+ " activate_app" ,
152+ " click" ,
153+ " type_text" ,
154+ " press_key" ,
155+ " scroll" ,
156+ " drag" ,
157+ " set_value" ,
158+ " perform_action" ,
173159 ] ) ,
174160 bundleId : BundleId ,
175161 dispatched : z . literal ( true ) ,
176162 verified : z . boolean ( ) ,
177163 } ) ,
178- ] )
179- export type ComputerUseResult = z . infer < typeof ComputerUseResultSchema >
164+ ] ) ;
165+ export type ComputerUseResult = z . infer < typeof ComputerUseResultSchema > ;
180166
181167export const ComputerUseNativeReplySchema = z . union ( [
182168 z . strictObject ( { id : z . string ( ) . min ( 1 ) . max ( 128 ) , result : ComputerUseResultSchema } ) ,
183169 z . strictObject ( {
184170 id : z . string ( ) . min ( 1 ) . max ( 128 ) ,
185- error : z . strictObject ( {
186- code : z . string ( ) . min ( 1 ) . max ( 128 ) ,
187- message : z . string ( ) . min ( 1 ) . max ( 2000 ) ,
188- } ) ,
171+ error : z . strictObject ( { code : z . string ( ) . min ( 1 ) . max ( 128 ) , message : z . string ( ) . min ( 1 ) . max ( 2000 ) } ) ,
189172 } ) ,
190- ] )
173+ ] ) ;
0 commit comments