@skillful-agents/agent-computer 0.0.4 → 0.0.5

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 (49) hide show
  1. package/bin/ac-core-darwin-arm64 +0 -0
  2. package/bin/ac-core-darwin-x64 +0 -0
  3. package/bin/ac-core-win32-arm64.exe +0 -0
  4. package/bin/ac-core-win32-x64.exe +0 -0
  5. package/dist/src/platform/resolve.d.ts.map +1 -1
  6. package/dist/src/platform/resolve.js +17 -4
  7. package/dist/src/platform/resolve.js.map +1 -1
  8. package/dist-cjs/bin/ac.js +127 -0
  9. package/dist-cjs/package.json +1 -0
  10. package/dist-cjs/src/bridge.js +693 -0
  11. package/dist-cjs/src/cdp/ax-tree.js +162 -0
  12. package/dist-cjs/src/cdp/bounds.js +66 -0
  13. package/dist-cjs/src/cdp/client.js +272 -0
  14. package/dist-cjs/src/cdp/connection.js +285 -0
  15. package/dist-cjs/src/cdp/diff.js +55 -0
  16. package/dist-cjs/src/cdp/discovery.js +91 -0
  17. package/dist-cjs/src/cdp/index.js +27 -0
  18. package/dist-cjs/src/cdp/interactions.js +301 -0
  19. package/dist-cjs/src/cdp/port-manager.js +68 -0
  20. package/dist-cjs/src/cdp/role-map.js +102 -0
  21. package/dist-cjs/src/cdp/types.js +2 -0
  22. package/dist-cjs/src/cli/commands/apps.js +63 -0
  23. package/dist-cjs/src/cli/commands/batch.js +37 -0
  24. package/dist-cjs/src/cli/commands/click.js +61 -0
  25. package/dist-cjs/src/cli/commands/clipboard.js +31 -0
  26. package/dist-cjs/src/cli/commands/dialog.js +45 -0
  27. package/dist-cjs/src/cli/commands/drag.js +26 -0
  28. package/dist-cjs/src/cli/commands/find.js +99 -0
  29. package/dist-cjs/src/cli/commands/menu.js +36 -0
  30. package/dist-cjs/src/cli/commands/screenshot.js +27 -0
  31. package/dist-cjs/src/cli/commands/scroll.js +77 -0
  32. package/dist-cjs/src/cli/commands/session.js +27 -0
  33. package/dist-cjs/src/cli/commands/snapshot.js +24 -0
  34. package/dist-cjs/src/cli/commands/type.js +69 -0
  35. package/dist-cjs/src/cli/commands/windowmgmt.js +62 -0
  36. package/dist-cjs/src/cli/commands/windows.js +10 -0
  37. package/dist-cjs/src/cli/commands.js +215 -0
  38. package/dist-cjs/src/cli/output.js +253 -0
  39. package/dist-cjs/src/cli/parser.js +128 -0
  40. package/dist-cjs/src/config.js +79 -0
  41. package/dist-cjs/src/daemon.js +183 -0
  42. package/dist-cjs/src/errors.js +118 -0
  43. package/dist-cjs/src/index.js +24 -0
  44. package/dist-cjs/src/platform/index.js +16 -0
  45. package/dist-cjs/src/platform/resolve.js +83 -0
  46. package/dist-cjs/src/refs.js +91 -0
  47. package/dist-cjs/src/sdk.js +288 -0
  48. package/dist-cjs/src/types.js +11 -0
  49. package/package.json +4 -2
@@ -0,0 +1,288 @@
1
+ "use strict";
2
+ // High-level SDK wrapping Bridge with typed methods
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.AC = void 0;
5
+ const bridge_js_1 = require("./bridge.js");
6
+ /**
7
+ * High-level AC SDK for programmatic macOS desktop automation.
8
+ *
9
+ * @example
10
+ * ```ts
11
+ * import { AC } from '@skillful-agents/ac';
12
+ *
13
+ * const ac = new AC();
14
+ * await ac.launch('TextEdit');
15
+ * const snap = await ac.snapshot({ interactive: true });
16
+ * const textarea = snap.elements.find(e => e.role === 'textarea');
17
+ * if (textarea) {
18
+ * await ac.fill(textarea.ref, 'Hello from AC!');
19
+ * }
20
+ * await ac.quit('TextEdit');
21
+ * await ac.disconnect();
22
+ * ```
23
+ */
24
+ class AC {
25
+ bridge;
26
+ constructor(options = {}) {
27
+ this.bridge = new bridge_js_1.Bridge(options);
28
+ }
29
+ // MARK: - Snapshot & Observation
30
+ /** Take a snapshot of the accessibility tree */
31
+ async snapshot(options = {}) {
32
+ return await this.bridge.send('snapshot', { ...options });
33
+ }
34
+ /** Find elements by text and/or role */
35
+ async find(text, options = {}) {
36
+ return await this.bridge.send('find', { text, ...options });
37
+ }
38
+ /** Read an element's value */
39
+ async read(ref, attr) {
40
+ return await this.bridge.send('read', { ref, ...(attr ? { attr } : {}) });
41
+ }
42
+ /** Get element bounds */
43
+ async box(ref) {
44
+ return await this.bridge.send('box', { ref });
45
+ }
46
+ /** Check element state (visible, enabled, focused, checked) */
47
+ async is(state, ref) {
48
+ return await this.bridge.send('is', { state, ref });
49
+ }
50
+ /** Get children of an element */
51
+ async children(ref) {
52
+ return await this.bridge.send('children', { ref });
53
+ }
54
+ // MARK: - Actions
55
+ /** Click an element by ref */
56
+ async click(ref, options = {}) {
57
+ await this.bridge.send('click', { ref, ...options });
58
+ }
59
+ /** Click at screen coordinates */
60
+ async clickAt(x, y, options = {}) {
61
+ await this.bridge.send('click', { x, y, ...options });
62
+ }
63
+ /** Hover over an element */
64
+ async hover(ref) {
65
+ await this.bridge.send('hover', { ref });
66
+ }
67
+ /** Hover at coordinates */
68
+ async hoverAt(x, y) {
69
+ await this.bridge.send('hover', { x, y });
70
+ }
71
+ /** Type text into the frontmost app */
72
+ async type(text, options = {}) {
73
+ await this.bridge.send('type', { text, ...options });
74
+ }
75
+ /** Fill an element with text (focus, clear, type) */
76
+ async fill(ref, text) {
77
+ await this.bridge.send('fill', { ref, text });
78
+ }
79
+ /** Press a key combination */
80
+ async key(combo, repeat) {
81
+ await this.bridge.send('key', { combo, ...(repeat ? { repeat } : {}) });
82
+ }
83
+ /** Paste text via clipboard */
84
+ async paste(text) {
85
+ await this.bridge.send('paste', { text });
86
+ }
87
+ /** Focus an element */
88
+ async focus(ref) {
89
+ await this.bridge.send('focus', { ref });
90
+ }
91
+ /** Check a checkbox */
92
+ async check(ref) {
93
+ await this.bridge.send('check', { ref });
94
+ }
95
+ /** Uncheck a checkbox */
96
+ async uncheck(ref) {
97
+ await this.bridge.send('uncheck', { ref });
98
+ }
99
+ /** Select a value in a dropdown */
100
+ async select(ref, value) {
101
+ await this.bridge.send('select', { ref, value });
102
+ }
103
+ /** Set a value on an element */
104
+ async set(ref, value) {
105
+ await this.bridge.send('set', { ref, value });
106
+ }
107
+ /** Scroll in a direction */
108
+ async scroll(direction, options = {}) {
109
+ await this.bridge.send('scroll', { direction, ...options });
110
+ }
111
+ /** Drag from one element/position to another */
112
+ async drag(from, to, options = {}) {
113
+ const params = { ...options };
114
+ if (typeof from === 'string')
115
+ params.from_ref = from;
116
+ else {
117
+ params.from_x = from.x;
118
+ params.from_y = from.y;
119
+ }
120
+ if (typeof to === 'string')
121
+ params.to_ref = to;
122
+ else {
123
+ params.to_x = to.x;
124
+ params.to_y = to.y;
125
+ }
126
+ await this.bridge.send('drag', params);
127
+ }
128
+ // MARK: - Menu
129
+ /** Click a menu item by path (e.g. "File > Save") */
130
+ async menuClick(path, app) {
131
+ await this.bridge.send('menu_click', { path, ...(app ? { app } : {}) });
132
+ }
133
+ /** List menu items */
134
+ async menuList(menuName, options = {}) {
135
+ return await this.bridge.send('menu_list', { ...(menuName ? { menu: menuName } : {}), ...options });
136
+ }
137
+ // MARK: - Apps & Windows
138
+ /** List running applications */
139
+ async apps() {
140
+ return await this.bridge.send('apps');
141
+ }
142
+ /** Launch an application */
143
+ async launch(name, options = {}) {
144
+ await this.bridge.send('launch', { name, ...options });
145
+ }
146
+ /** Quit an application */
147
+ async quit(name, options = {}) {
148
+ await this.bridge.send('quit', { name, ...options });
149
+ }
150
+ /** Relaunch an application with CDP support (quit + launch with --remote-debugging-port) */
151
+ async relaunch(name, options = {}) {
152
+ await this.bridge.send('relaunch', { name, ...options });
153
+ }
154
+ /** Switch to (activate) an application */
155
+ async switch(name) {
156
+ await this.bridge.send('switch', { name });
157
+ }
158
+ /** List windows */
159
+ async windows(app) {
160
+ return await this.bridge.send('windows', app ? { app } : {});
161
+ }
162
+ /** Grab (lock onto) a window for subsequent commands */
163
+ async grab(refOrApp) {
164
+ if (refOrApp.startsWith('@')) {
165
+ await this.bridge.send('grab', { ref: refOrApp });
166
+ }
167
+ else {
168
+ await this.bridge.send('grab', { app: refOrApp });
169
+ }
170
+ }
171
+ /** Release the grabbed window */
172
+ async ungrab() {
173
+ await this.bridge.send('ungrab');
174
+ }
175
+ // MARK: - Window Management
176
+ async minimize(ref) {
177
+ await this.bridge.send('minimize', ref ? { ref } : {});
178
+ }
179
+ async maximize(ref) {
180
+ await this.bridge.send('maximize', ref ? { ref } : {});
181
+ }
182
+ async fullscreen(ref) {
183
+ await this.bridge.send('fullscreen', ref ? { ref } : {});
184
+ }
185
+ async closeWindow(ref) {
186
+ await this.bridge.send('close', ref ? { ref } : {});
187
+ }
188
+ async raise(ref) {
189
+ await this.bridge.send('raise', ref ? { ref } : {});
190
+ }
191
+ async move(x, y, ref) {
192
+ await this.bridge.send('move', { x, y, ...(ref ? { ref } : {}) });
193
+ }
194
+ async resize(width, height, ref) {
195
+ await this.bridge.send('resize', { width, height, ...(ref ? { ref } : {}) });
196
+ }
197
+ async bounds(preset, ref) {
198
+ await this.bridge.send('bounds', { preset, ...(ref ? { ref } : {}) });
199
+ }
200
+ // MARK: - Screenshot & Displays
201
+ /** Take a screenshot */
202
+ async screenshot(options = {}) {
203
+ return await this.bridge.send('screenshot', { ...options });
204
+ }
205
+ /** List displays */
206
+ async displays() {
207
+ return await this.bridge.send('displays');
208
+ }
209
+ // MARK: - Clipboard
210
+ /** Read clipboard contents */
211
+ async clipboardRead() {
212
+ return await this.bridge.send('clipboard_read');
213
+ }
214
+ /** Set clipboard contents */
215
+ async clipboardSet(text) {
216
+ await this.bridge.send('clipboard_set', { text });
217
+ }
218
+ // MARK: - Dialog
219
+ /** Detect if a dialog/alert is visible */
220
+ async dialog(app) {
221
+ return await this.bridge.send('dialog', app ? { app } : {});
222
+ }
223
+ /** Accept (click OK/Save) the current dialog */
224
+ async dialogAccept(app) {
225
+ await this.bridge.send('dialog_accept', app ? { app } : {});
226
+ }
227
+ /** Cancel/dismiss the current dialog */
228
+ async dialogCancel(app) {
229
+ await this.bridge.send('dialog_cancel', app ? { app } : {});
230
+ }
231
+ /** Set the filename in a file dialog */
232
+ async dialogFile(path, app) {
233
+ await this.bridge.send('dialog_file', { path, ...(app ? { app } : {}) });
234
+ }
235
+ // MARK: - Wait
236
+ /** Wait for a fixed duration */
237
+ async wait(ms) {
238
+ await this.bridge.send('wait', { ms });
239
+ }
240
+ /** Wait for an app to launch */
241
+ async waitForApp(name, options = {}) {
242
+ await this.bridge.send('wait', { app: name, ...options });
243
+ }
244
+ /** Wait for a window with a given title */
245
+ async waitForWindow(title, options = {}) {
246
+ await this.bridge.send('wait', { window: title, ...options });
247
+ }
248
+ /** Wait for text to appear on screen */
249
+ async waitForText(text, options = {}) {
250
+ await this.bridge.send('wait', { text, ...options });
251
+ }
252
+ // MARK: - Batch & Diff
253
+ /** Execute a batch of commands sequentially */
254
+ async batch(commands, stopOnError = true) {
255
+ return await this.bridge.send('batch', { commands, stop_on_error: stopOnError });
256
+ }
257
+ /** Check if the UI has changed since last snapshot */
258
+ async changed(app) {
259
+ return await this.bridge.send('changed', app ? { app } : {});
260
+ }
261
+ /** Get a diff of what changed since last snapshot */
262
+ async diff(app) {
263
+ return await this.bridge.send('diff', app ? { app } : {});
264
+ }
265
+ // MARK: - Status
266
+ /** Get daemon status */
267
+ async status() {
268
+ return await this.bridge.send('status');
269
+ }
270
+ /** Check permissions */
271
+ async permissions() {
272
+ return await this.bridge.send('permissions');
273
+ }
274
+ /** Get window title */
275
+ async title() {
276
+ return await this.bridge.send('title');
277
+ }
278
+ // MARK: - Lifecycle
279
+ /** Disconnect from the daemon */
280
+ async disconnect() {
281
+ await this.bridge.disconnect();
282
+ }
283
+ /** Shut down the daemon */
284
+ async shutdown() {
285
+ await this.bridge.shutdown();
286
+ }
287
+ }
288
+ exports.AC = AC;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NORMALIZED_ROLES = void 0;
4
+ // Normalized role names used across platforms
5
+ exports.NORMALIZED_ROLES = [
6
+ 'button', 'textfield', 'textarea', 'link', 'checkbox', 'radio',
7
+ 'slider', 'dropdown', 'image', 'group', 'window', 'table', 'row',
8
+ 'cell', 'tabgroup', 'tab', 'menubar', 'menuitem', 'scrollarea',
9
+ 'text', 'toolbar', 'combobox', 'stepper', 'splitgroup', 'timeline',
10
+ 'progress', 'treeview', 'webarea', 'generic',
11
+ ];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skillful-agents/agent-computer",
3
- "version": "0.0.4",
3
+ "version": "0.0.5",
4
4
  "description": "Agent Computer — cross-platform desktop automation CLI for AI agents",
5
5
  "type": "module",
6
6
  "bin": {
@@ -11,11 +11,13 @@
11
11
  "exports": {
12
12
  ".": {
13
13
  "import": "./dist/src/index.js",
14
+ "require": "./dist-cjs/src/index.js",
14
15
  "types": "./dist/src/index.d.ts"
15
16
  }
16
17
  },
17
18
  "files": [
18
19
  "dist/",
20
+ "dist-cjs/",
19
21
  "bin/ac-core-*",
20
22
  "scripts/",
21
23
  "schema/",
@@ -23,7 +25,7 @@
23
25
  "LICENSE"
24
26
  ],
25
27
  "scripts": {
26
- "build": "tsc",
28
+ "build": "tsc && tsc -p tsconfig.cjs.json && echo '{\"type\":\"commonjs\"}' > dist-cjs/package.json",
27
29
  "build:swift": "cd native/macos && swift build -c release",
28
30
  "build:dotnet": "cd native/windows && dotnet build ACCore/ACCore.csproj",
29
31
  "build:all": "npm run build && (node -e \"process.exit(process.platform==='win32'?0:1)\" && npm run build:dotnet || npm run build:swift)",