automify 0.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.
Files changed (47) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/LICENSE +21 -0
  3. package/README.md +401 -0
  4. package/SECURITY.md +17 -0
  5. package/examples/anthropic-provider.js +18 -0
  6. package/examples/browser-basic.js +30 -0
  7. package/examples/browser-with-safety.js +38 -0
  8. package/examples/claude-model-adapter.js +141 -0
  9. package/examples/cli-basic.js +20 -0
  10. package/examples/cli-docker.js +42 -0
  11. package/examples/custom-computer.js +18 -0
  12. package/examples/custom-model-adapter.js +48 -0
  13. package/examples/desktop-docker.js +37 -0
  14. package/examples/desktop-local.js +28 -0
  15. package/examples/evaluate-image.js +26 -0
  16. package/examples/files-and-shared-folder.js +42 -0
  17. package/package.json +74 -0
  18. package/scripts/generate-argument-reference.js +17 -0
  19. package/scripts/install-browser.js +12 -0
  20. package/scripts/install-desktop.js +281 -0
  21. package/src/index.d.ts +1049 -0
  22. package/src/index.js +83 -0
  23. package/src/lib/adapter-locks.js +93 -0
  24. package/src/lib/adapter-toolkit.js +239 -0
  25. package/src/lib/anthropic-model-adapter.js +451 -0
  26. package/src/lib/argument-reference.js +98 -0
  27. package/src/lib/automify.js +938 -0
  28. package/src/lib/browser-automify.js +89 -0
  29. package/src/lib/cli-automify.js +520 -0
  30. package/src/lib/computer-automify.js +103 -0
  31. package/src/lib/docker-cli-automify.js +517 -0
  32. package/src/lib/docker-desktop-computer.js +725 -0
  33. package/src/lib/errors.js +24 -0
  34. package/src/lib/file-data.js +140 -0
  35. package/src/lib/init.js +217 -0
  36. package/src/lib/local-desktop-computer.js +963 -0
  37. package/src/lib/model-adapter.js +32 -0
  38. package/src/lib/openai-responses-client.js +162 -0
  39. package/src/lib/output.js +57 -0
  40. package/src/lib/playwright-computer.js +363 -0
  41. package/src/lib/presets.js +141 -0
  42. package/src/lib/result.js +95 -0
  43. package/src/lib/runtime.js +471 -0
  44. package/src/lib/virtual-shared-folder.js +109 -0
  45. package/src/lib/zod-output.js +26 -0
  46. package/src/zod.d.ts +12 -0
  47. package/src/zod.js +5 -0
package/src/index.d.ts ADDED
@@ -0,0 +1,1049 @@
1
+ export type ComputerUseEnvironment = "browser" | "mac" | "windows" | "ubuntu" | string;
2
+
3
+ export type ComputerAction =
4
+ | { type: "click"; x: number; y: number; button?: "left" | "right" | "middle" | string }
5
+ | { type: "double_click"; x: number; y: number; button?: "left" | "right" | "middle" | string }
6
+ | { type: "scroll"; x: number; y: number; scroll_x?: number; scroll_y?: number }
7
+ | { type: "keypress"; keys: string[] }
8
+ | { type: "type"; text: string }
9
+ | { type: "wait" }
10
+ | { type: "screenshot" }
11
+ | { type: "move"; x: number; y: number }
12
+ | { type: "drag"; x: number; y: number; path?: Array<{ x: number; y: number }> }
13
+ | { type: string; [key: string]: unknown };
14
+
15
+ export type Screenshot = string | ArrayBuffer | Uint8Array | Buffer;
16
+ export type DomainRule = string | RegExp | ((url: URL) => boolean);
17
+ export type CommandRule = string | RegExp | ((command: string) => boolean);
18
+ export type DebugLogger = boolean | ((message: string, details?: unknown) => void);
19
+ export type ScreenshotDetail = "auto" | "low" | "high" | "original" | string;
20
+ export type BrowserPreset = "browser-review";
21
+ export type CliPreset = "repo" | "locked-down-cli";
22
+ export type DockerCliPreset = CliPreset;
23
+ export type DockerDesktopPreset = "desktop-review";
24
+ export type VirtualCliPreset = CliPreset;
25
+ export type VirtualDesktopPreset = "desktop-review";
26
+ export interface ArgumentReferenceEntry {
27
+ surface: string;
28
+ preferred: string[];
29
+ notes: string;
30
+ }
31
+ export type OutputFormat =
32
+ | { type: "text" }
33
+ | { type: "json_object"; parse?: boolean }
34
+ | {
35
+ type: "json_schema";
36
+ name: string;
37
+ schema: Record<string, unknown>;
38
+ description?: string;
39
+ strict?: boolean;
40
+ parse?: boolean;
41
+ };
42
+
43
+ export interface ViewportOptions {
44
+ width?: number;
45
+ height?: number;
46
+ depth?: number;
47
+ }
48
+
49
+ export interface DockerContainerOptions {
50
+ docker?: string;
51
+ dockerCommand?: string;
52
+ image?: string;
53
+ name?: string;
54
+ existing?: boolean;
55
+ keep?: boolean;
56
+ autoRemove?: boolean;
57
+ sandbox?: boolean;
58
+ readOnly?: boolean;
59
+ network?: string | false;
60
+ cpus?: number | string;
61
+ memory?: number | string;
62
+ memorySwap?: number | string;
63
+ cpuShares?: number;
64
+ cpusetCpus?: string;
65
+ pidsLimit?: number;
66
+ shmSize?: string;
67
+ tmpfsTmp?: string;
68
+ tmpfsRun?: string;
69
+ volumes?: string[];
70
+ env?: string[];
71
+ timeoutMs?: number;
72
+ cwd?: string;
73
+ workdir?: string;
74
+ startupCommand?: string;
75
+ packages?: string[];
76
+ additionalAptPackages?: string[];
77
+ installDependencies?: boolean;
78
+ }
79
+
80
+ export type JsonOutputShape = Record<
81
+ string,
82
+ "string" | "number" | "integer" | "boolean" | "object" | "array" | "null" | Record<string, unknown>
83
+ >;
84
+
85
+ export interface JsonOutputOptions {
86
+ description?: string;
87
+ strict?: boolean;
88
+ parse?: boolean;
89
+ }
90
+
91
+ export function jsonOutput(
92
+ name: string,
93
+ shape: JsonOutputShape | Record<string, unknown>,
94
+ options?: JsonOutputOptions
95
+ ): OutputFormat;
96
+
97
+ export interface ComputerAdapter {
98
+ displayWidth?: number;
99
+ displayHeight?: number;
100
+ environment?: ComputerUseEnvironment;
101
+ instructions?: string;
102
+ execute(action: ComputerAction, context: Record<string, unknown>): Promise<void> | void;
103
+ screenshot(context?: Record<string, unknown>): Promise<Screenshot> | Screenshot;
104
+ currentUrl?(): Promise<string | null | undefined> | string | null | undefined;
105
+ close?(): Promise<void> | void;
106
+ }
107
+
108
+ export interface AutomifyOptions {
109
+ openaiApiKey?: string;
110
+ client?: ModelAdapter;
111
+ computer: ComputerAdapter;
112
+ model?: string;
113
+ baseURL?: string;
114
+ fetchImpl?: typeof fetch;
115
+ maxSteps?: number;
116
+ limits?: RunLimitsOptions;
117
+ requestOptions?: Record<string, unknown>;
118
+ viewport?: ViewportOptions;
119
+ displayWidth?: number;
120
+ displayHeight?: number;
121
+ environment?: ComputerUseEnvironment;
122
+ reasoning?: Record<string, unknown>;
123
+ safety?: DoSafetyOptions;
124
+ safetyIdentifier?: string;
125
+ allowedDomains?: DomainRule[];
126
+ hooks?: DoHooksOptions<AutomifyCompleteEvent>;
127
+ onStep?: (event: Record<string, unknown>) => Promise<void> | void;
128
+ onRequest?: (payload: Record<string, unknown>, meta: Record<string, unknown>) => Promise<void> | void;
129
+ onResponse?: (response: Record<string, unknown>, meta: Record<string, unknown>) => Promise<void> | void;
130
+ onComplete?: (event: AutomifyCompleteEvent) => Promise<void> | void;
131
+ screenshot?: DoScreenshotOptions;
132
+ redactScreenshot?: (screenshot: Screenshot, context: Record<string, unknown>) => Promise<Screenshot> | Screenshot;
133
+ screenshotDetail?: ScreenshotDetail;
134
+ screenshotMaxWidth?: number | false;
135
+ screenshotMaxHeight?: number | false;
136
+ screenshotResize?: (
137
+ screenshot: Screenshot,
138
+ target: { width: number; height: number }
139
+ ) => Promise<Screenshot> | Screenshot;
140
+ sendInitialScreenshot?: boolean;
141
+ initialScreenshot?: string;
142
+ finalScreenshot?: string;
143
+ actionScreenshots?: string;
144
+ screenshots?: DoScreenshotsOptions;
145
+ trace?: boolean;
146
+ silent?: boolean;
147
+ debug?: DebugLogger;
148
+ /**
149
+ * Append automation debug events as JSON Lines to this file.
150
+ */
151
+ logFile?: string;
152
+ }
153
+
154
+ export interface BrowserAutomifyOptions extends Omit<AutomifyOptions, "computer">, BrowserComputerOptions {
155
+ preset?: BrowserPreset;
156
+ computer?: BrowserComputer;
157
+ }
158
+
159
+ export type DockerComputerAutomifyOptions = Omit<AutomifyOptions, "computer"> &
160
+ DockerDesktopComputerOptions & {
161
+ computer?: ComputerAdapter & { session: DockerDesktopSession; sharedFolder?: VirtualSharedFolderData };
162
+ };
163
+
164
+ export interface LocalComputerAutomifyOptions extends Omit<AutomifyOptions, "computer">, LocalDesktopComputerOptions {
165
+ computer?: ComputerAdapter;
166
+ }
167
+
168
+ export interface LocalDesktopComputerOptions {
169
+ nut?: Record<string, unknown>;
170
+ viewport?: ViewportOptions;
171
+ displayWidth?: number;
172
+ displayHeight?: number;
173
+ environment?: ComputerUseEnvironment;
174
+ waitMs?: number;
175
+ actionDelayMs?: number;
176
+ instructions?: string;
177
+ screenshotPath?: string;
178
+ /**
179
+ * Screenshot pixels per native mouse coordinate. On macOS Retina displays the
180
+ * default is inferred as 2; use 1 for non-Retina external displays.
181
+ */
182
+ pixelScale?: number;
183
+ mouseScaleX?: number;
184
+ mouseScaleY?: number;
185
+ mouseOffsetX?: number;
186
+ mouseOffsetY?: number;
187
+ mouseAutoDelayMs?: number;
188
+ keyboardAutoDelayMs?: number;
189
+ mouse?: {
190
+ scaleX?: number;
191
+ scaleY?: number;
192
+ offsetX?: number;
193
+ offsetY?: number;
194
+ autoDelayMs?: number;
195
+ speed?: number;
196
+ smooth?: boolean;
197
+ configure?: boolean;
198
+ };
199
+ keyboard?: {
200
+ autoDelayMs?: number;
201
+ configure?: boolean;
202
+ };
203
+ calibration?: {
204
+ pixelScale?: number;
205
+ mouseScaleX?: number;
206
+ mouseScaleY?: number;
207
+ mouseOffsetX?: number;
208
+ mouseOffsetY?: number;
209
+ screenshot?: boolean;
210
+ required?: boolean;
211
+ };
212
+ /**
213
+ * Linux only. Defaults to true when DISPLAY is missing. Starts Xvfb so the
214
+ * local nut.js desktop adapter can run on headless servers.
215
+ */
216
+ virtualDisplay?:
217
+ | boolean
218
+ | {
219
+ display?: string;
220
+ width?: number;
221
+ height?: number;
222
+ depth?: number;
223
+ command?: string;
224
+ args?: string[];
225
+ startupMs?: number;
226
+ };
227
+ forceVirtualDisplay?: boolean;
228
+ display?:
229
+ | string
230
+ | {
231
+ width?: number;
232
+ height?: number;
233
+ pixelScale?: number;
234
+ };
235
+ virtualDisplayDisplay?: string;
236
+ virtualDisplayWidth?: number;
237
+ virtualDisplayHeight?: number;
238
+ virtualDisplayDepth?: number;
239
+ virtualDisplayCommand?: string;
240
+ virtualDisplayArgs?: string[];
241
+ virtualDisplayStartupMs?: number;
242
+ mouseSpeed?: number;
243
+ smoothMouseMove?: boolean;
244
+ configureMouse?: boolean;
245
+ configureKeyboard?: boolean;
246
+ macCommandTabHoldMs?: number;
247
+ macCommandTabSettleMs?: number;
248
+ silent?: boolean;
249
+ debug?: DebugLogger;
250
+ /**
251
+ * Append local desktop adapter debug events as JSON Lines to this file.
252
+ */
253
+ logFile?: string;
254
+ macosDisplayInfo?:
255
+ | false
256
+ | {
257
+ width?: number;
258
+ height?: number;
259
+ visibleX?: number;
260
+ visibleY?: number;
261
+ visibleWidth?: number;
262
+ visibleHeight?: number;
263
+ backingScaleFactor?: number;
264
+ };
265
+ calibrateScreenshot?: boolean;
266
+ /**
267
+ * Defaults to true. When true, createLocalDesktopComputer() verifies screenshot
268
+ * capture during setup so bad macOS Screen Recording/Accessibility grants fail
269
+ * before the model starts producing desktop coordinates.
270
+ */
271
+ requireCalibration?: boolean;
272
+ screenshot?: (context?: Record<string, unknown>) => Promise<Screenshot> | Screenshot;
273
+ onUnknownAction?: (action: ComputerAction, context?: Record<string, unknown>) => Promise<void> | void;
274
+ }
275
+
276
+ export interface DockerDesktopOptions {
277
+ startupCommand: string;
278
+ windowManagerCommand?: string;
279
+ packages?: string[];
280
+ additionalAptPackages?: string[];
281
+ installDependencies?: boolean;
282
+ packageManager?: "apt" | string;
283
+ }
284
+
285
+ interface DockerDesktopComputerBaseOptions {
286
+ preset?: DockerDesktopPreset;
287
+ container?: DockerContainerOptions;
288
+ dockerCommand?: string;
289
+ image?: string;
290
+ containerName?: string;
291
+ existingContainer?: boolean;
292
+ keepContainer?: boolean;
293
+ start?: boolean;
294
+ display?: string;
295
+ viewport?: ViewportOptions;
296
+ displayWidth?: number;
297
+ displayHeight?: number;
298
+ displayDepth?: number;
299
+ environment?: ComputerUseEnvironment;
300
+ instructions?: string;
301
+ desktop?: DockerDesktopOptions;
302
+ /**
303
+ * Required command launched after Xvfb and the window manager.
304
+ */
305
+ startupCommand?: string;
306
+ windowManagerCommand?: string;
307
+ /**
308
+ * Defaults to false so startup failures can include Docker logs. Set true to
309
+ * ask Docker to remove the container automatically when the process exits.
310
+ */
311
+ autoRemove?: boolean;
312
+ /**
313
+ * Defaults to true for prepared images. It is relaxed automatically while
314
+ * installDependencies is true because apt needs normal root capabilities.
315
+ */
316
+ sandbox?: boolean;
317
+ /**
318
+ * Defaults to true for apt-based base distro images such as
319
+ * debian:bookworm-slim or ubuntu:24.04, and false for custom images. When true, the container
320
+ * installs the desktop packages before starting Xvfb.
321
+ */
322
+ installDependencies?: boolean;
323
+ /**
324
+ * Replaces the default desktop package set. Use additionalAptPackages when you
325
+ * only need to add tools such as chromium.
326
+ */
327
+ desktopPackages?: string[];
328
+ /**
329
+ * Extra apt packages installed alongside the default desktop packages while
330
+ * installDependencies is true.
331
+ */
332
+ additionalAptPackages?: string[];
333
+ /**
334
+ * Docker network used for the container. Defaults to "bridge"; pass false or
335
+ * "none" when the image does not need network access.
336
+ */
337
+ network?: string | false;
338
+ cpus?: number | string;
339
+ memory?: number | string;
340
+ memorySwap?: number | string;
341
+ cpuShares?: number;
342
+ cpusetCpus?: string;
343
+ /**
344
+ * Either "apt" for Debian/Ubuntu images or a shell snippet that installs the
345
+ * required desktop packages for another distro.
346
+ */
347
+ packageManager?: "apt" | string;
348
+ readOnly?: boolean;
349
+ pidsLimit?: number;
350
+ shmSize?: string;
351
+ tmpfsTmp?: string;
352
+ tmpfsRun?: string;
353
+ volumes?: string[];
354
+ env?: string[];
355
+ shared?: VirtualSharedFolderInput;
356
+ sharedFolder?: VirtualSharedFolderInput;
357
+ sharedFiles?: VirtualSharedFileInput[];
358
+ files?: VirtualSharedFileInput[];
359
+ waitMs?: number;
360
+ startupTimeoutMs?: number;
361
+ dockerTimeoutMs?: number;
362
+ screenshotMaxBuffer?: number;
363
+ logsMaxBuffer?: number;
364
+ execFile?: (...args: unknown[]) => Promise<{ stdout?: Buffer | string; stderr?: Buffer | string }>;
365
+ silent?: boolean;
366
+ debug?: DebugLogger;
367
+ /**
368
+ * Append Docker desktop adapter debug events as JSON Lines to this file.
369
+ */
370
+ logFile?: string;
371
+ onUnknownAction?: (action: ComputerAction, context?: Record<string, unknown>) => Promise<void> | void;
372
+ }
373
+
374
+ export type DockerDesktopComputerOptions =
375
+ | (DockerDesktopComputerBaseOptions & { startupCommand: string })
376
+ | (DockerDesktopComputerBaseOptions & { desktop: DockerDesktopOptions });
377
+
378
+ export type VirtualDesktopComputerOptions = DockerDesktopComputerOptions;
379
+
380
+ export type VirtualSharedFolderInput =
381
+ | true
382
+ | string
383
+ | {
384
+ hostPath?: string;
385
+ path?: string;
386
+ containerPath?: string;
387
+ readOnly?: boolean;
388
+ cleanup?: boolean;
389
+ files?: VirtualSharedFileInput[];
390
+ };
391
+
392
+ export type VirtualSharedFileInput =
393
+ | string
394
+ | {
395
+ path: string;
396
+ name?: string;
397
+ targetPath?: string;
398
+ };
399
+
400
+ export interface VirtualSharedFolderData {
401
+ hostPath: string;
402
+ containerPath: string;
403
+ files: Array<{
404
+ name: string;
405
+ relativePath: string;
406
+ hostPath: string;
407
+ containerPath: string;
408
+ size: number;
409
+ }>;
410
+ }
411
+
412
+ export class DockerDesktopSession {
413
+ constructor(options?: DockerDesktopComputerOptions);
414
+ readonly name: string;
415
+ readonly display: string;
416
+ readonly width: number;
417
+ readonly height: number;
418
+ start(): Promise<void>;
419
+ execute(action: ComputerAction): Promise<void>;
420
+ screenshot(): Promise<Buffer>;
421
+ close(): Promise<void>;
422
+ }
423
+
424
+ export { DockerDesktopSession as DockerVirtualDesktopSession };
425
+
426
+ export interface OpenAIProviderConfig {
427
+ type: "openai";
428
+ apiKey: string;
429
+ model: string;
430
+ computerModel?: string;
431
+ baseURL?: string;
432
+ fetchImpl?: typeof fetch;
433
+ timeoutMs?: number;
434
+ maxRetries?: number;
435
+ retryDelayMs?: number;
436
+ }
437
+
438
+ export interface AnthropicProviderConfig extends Omit<AnthropicModelAdapterOptions, "anthropicApiKey"> {
439
+ type: "anthropic";
440
+ apiKey: string;
441
+ model: string;
442
+ }
443
+
444
+ export interface CustomProviderConfig {
445
+ type: "custom";
446
+ model: string;
447
+ adapter?: ModelAdapterInput;
448
+ client?: ModelAdapter;
449
+ options?: Record<string, unknown>;
450
+ }
451
+
452
+ export type ProviderConfig = OpenAIProviderConfig | AnthropicProviderConfig | CustomProviderConfig;
453
+
454
+ export interface InitAutomifyOptions {
455
+ provider: ProviderConfig;
456
+ computerModel?: string;
457
+ maxSteps?: number;
458
+ limits?: RunLimitsOptions;
459
+ requestOptions?: Record<string, unknown>;
460
+ reasoning?: Record<string, unknown>;
461
+ safety?: DoSafetyOptions;
462
+ safetyIdentifier?: string;
463
+ allowedDomains?: DomainRule[];
464
+ hooks?: DoHooksOptions;
465
+ onStep?: (event: Record<string, unknown>) => Promise<void> | void;
466
+ onRequest?: (payload: Record<string, unknown>, meta: Record<string, unknown>) => Promise<void> | void;
467
+ onResponse?: (response: Record<string, unknown>, meta: Record<string, unknown>) => Promise<void> | void;
468
+ onComplete?: (event: AutomifyCompleteEvent | CliAutomifyCompleteEvent) => Promise<void> | void;
469
+ screenshot?: DoScreenshotOptions;
470
+ redactScreenshot?: (screenshot: Screenshot, context: Record<string, unknown>) => Promise<Screenshot> | Screenshot;
471
+ screenshotDetail?: ScreenshotDetail;
472
+ screenshotMaxWidth?: number | false;
473
+ screenshotMaxHeight?: number | false;
474
+ screenshotResize?: (
475
+ screenshot: Screenshot,
476
+ target: { width: number; height: number }
477
+ ) => Promise<Screenshot> | Screenshot;
478
+ sendInitialScreenshot?: boolean;
479
+ initialScreenshot?: string;
480
+ finalScreenshot?: string;
481
+ actionScreenshots?: string;
482
+ screenshots?: DoScreenshotsOptions;
483
+ trace?: boolean;
484
+ silent?: boolean;
485
+ debug?: DebugLogger;
486
+ }
487
+
488
+ export interface DoOptions {
489
+ data?: Record<string, unknown>;
490
+ evaluate?: FileToEvaluateInput | FileToEvaluateInput[];
491
+ filesToEvaluate?: FileToEvaluateInput | FileToEvaluateInput[];
492
+ model?: string;
493
+ maxSteps?: number;
494
+ limits?: RunLimitsOptions;
495
+ request?: Record<string, unknown>;
496
+ requestOptions?: Record<string, unknown>;
497
+ output?: OutputFormat;
498
+ displayWidth?: number;
499
+ displayHeight?: number;
500
+ environment?: ComputerUseEnvironment;
501
+ reasoning?: Record<string, unknown>;
502
+ safety?: DoSafetyOptions;
503
+ safetyIdentifier?: string;
504
+ allowedDomains?: DomainRule[];
505
+ hooks?: DoHooksOptions<AutomifyCompleteEvent>;
506
+ onStep?: (event: Record<string, unknown>) => Promise<void> | void;
507
+ onComplete?: (event: AutomifyCompleteEvent) => Promise<void> | void;
508
+ screenshot?: DoScreenshotOptions;
509
+ redactScreenshot?: (screenshot: Screenshot, context: Record<string, unknown>) => Promise<Screenshot> | Screenshot;
510
+ screenshotDetail?: ScreenshotDetail;
511
+ screenshotMaxWidth?: number | false;
512
+ screenshotMaxHeight?: number | false;
513
+ screenshotResize?: (
514
+ screenshot: Screenshot,
515
+ target: { width: number; height: number }
516
+ ) => Promise<Screenshot> | Screenshot;
517
+ sendInitialScreenshot?: boolean;
518
+ initialScreenshot?: string;
519
+ finalScreenshot?: string;
520
+ actionScreenshots?: string;
521
+ screenshots?: DoScreenshotsOptions;
522
+ trace?: boolean;
523
+ silent?: boolean;
524
+ onSafetyCheck?: (event: {
525
+ checks: Array<Record<string, unknown>>;
526
+ action: ComputerAction;
527
+ call: Record<string, unknown>;
528
+ response: Record<string, unknown>;
529
+ }) => Promise<boolean> | boolean;
530
+ }
531
+
532
+ export interface RunLimitsOptions {
533
+ steps?: number;
534
+ maxSteps?: number;
535
+ }
536
+
537
+ export interface DoScreenshotsOptions {
538
+ initial?: string;
539
+ final?: string;
540
+ actions?: string;
541
+ actionScreenshots?: string;
542
+ }
543
+
544
+ export interface DoScreenshotOptions {
545
+ detail?: ScreenshotDetail;
546
+ maxWidth?: number | false;
547
+ maxHeight?: number | false;
548
+ sendInitialScreenshot?: boolean;
549
+ resize?: (screenshot: Screenshot, target: { width: number; height: number }) => Promise<Screenshot> | Screenshot;
550
+ redact?: (screenshot: Screenshot, context: Record<string, unknown>) => Promise<Screenshot> | Screenshot;
551
+ }
552
+
553
+ export interface DoSafetyOptions {
554
+ identifier?: string;
555
+ safetyIdentifier?: string;
556
+ domains?: DomainRule[];
557
+ allowedDomains?: DomainRule[];
558
+ onCheck?: DoOptions["onSafetyCheck"];
559
+ onSafetyCheck?: DoOptions["onSafetyCheck"];
560
+ }
561
+
562
+ export interface DoHooksOptions<CompleteEvent = AutomifyCompleteEvent | CliAutomifyCompleteEvent> {
563
+ step?: (event: Record<string, unknown>) => Promise<void> | void;
564
+ onStep?: (event: Record<string, unknown>) => Promise<void> | void;
565
+ complete?: (event: CompleteEvent) => Promise<void> | void;
566
+ onComplete?: (event: CompleteEvent) => Promise<void> | void;
567
+ }
568
+
569
+ export interface CliCommandOptions {
570
+ cwd?: string;
571
+ env?: Record<string, string>;
572
+ shell?: boolean | string;
573
+ timeoutMs?: number;
574
+ timeout?: number;
575
+ approval?: "always" | "never";
576
+ allow?: CommandRule[];
577
+ allowed?: CommandRule[];
578
+ allowedCommands?: CommandRule[];
579
+ block?: CommandRule[];
580
+ blocked?: CommandRule[];
581
+ blockedCommands?: CommandRule[];
582
+ confirm?: CliAutomifyOptions["confirmCommand"];
583
+ confirmCommand?: CliAutomifyOptions["confirmCommand"];
584
+ }
585
+
586
+ export interface AutomifyResult {
587
+ response: Record<string, unknown>;
588
+ steps: Array<Record<string, unknown>>;
589
+ trace?: Array<Record<string, unknown>>;
590
+ ok: boolean;
591
+ status: "succeeded";
592
+ completed: boolean;
593
+ stopReason: "done";
594
+ text: string;
595
+ parsed?: unknown;
596
+ finalScreenshot?: {
597
+ path: string;
598
+ bytes?: number;
599
+ };
600
+ }
601
+
602
+ export interface AutomifyCompleteEvent {
603
+ instruction: string;
604
+ data: Record<string, unknown>;
605
+ result: AutomifyResult;
606
+ response: Record<string, unknown>;
607
+ steps: Array<Record<string, unknown>>;
608
+ ok: boolean;
609
+ status: "succeeded";
610
+ completed: boolean;
611
+ stopReason: "done";
612
+ surface: "browser" | "desktop" | "computer" | string;
613
+ }
614
+
615
+ export class Automify {
616
+ constructor(options: AutomifyOptions);
617
+ do(instruction: string, options?: DoOptions): Promise<AutomifyResult>;
618
+ }
619
+
620
+ export function createAutomify(options: AutomifyOptions): Automify;
621
+
622
+ export function createComputerAutomify(options: AutomifyOptions): Automify;
623
+
624
+ export interface InitializedAutomify {
625
+ client: ModelAdapter;
626
+ browser(options?: Omit<BrowserAutomifyOptions, "openaiApiKey" | "client">): Promise<BrowserAutomify>;
627
+ withBrowser<T>(
628
+ options: Omit<BrowserAutomifyOptions, "openaiApiKey" | "client">,
629
+ run: (automify: BrowserAutomify) => Promise<T> | T
630
+ ): Promise<T>;
631
+ cli(options?: Omit<CliAutomifyOptions, "openaiApiKey" | "client">): CliAutomify;
632
+ dockerCli(options?: Omit<DockerCliAutomifyOptions, "openaiApiKey" | "client">): DockerCliAutomify;
633
+ dockerComputer(
634
+ options?: Omit<DockerComputerAutomifyOptions, "openaiApiKey" | "client">
635
+ ): Promise<DockerComputerAutomify>;
636
+ localComputer(
637
+ options?: Omit<LocalComputerAutomifyOptions, "openaiApiKey" | "client">
638
+ ): Promise<LocalComputerAutomify>;
639
+ virtualCli(options?: Omit<DockerCliAutomifyOptions, "openaiApiKey" | "client">): DockerCliAutomify;
640
+ computer(options: Omit<AutomifyOptions, "openaiApiKey" | "client">): Automify;
641
+ custom(options: Omit<AutomifyOptions, "openaiApiKey" | "client">): Automify;
642
+ }
643
+
644
+ export function initAutomify(options: InitAutomifyOptions): InitializedAutomify;
645
+
646
+ export interface ModelAdapter {
647
+ createResponse(payload: Record<string, unknown>, context?: ModelAdapterContext): Promise<Record<string, unknown>>;
648
+ }
649
+
650
+ export interface RespondModelAdapter {
651
+ respond(payload: Record<string, unknown>, context?: ModelAdapterContext): Promise<Record<string, unknown>>;
652
+ }
653
+
654
+ export interface ModelAdapterFactory {
655
+ options?: Record<string, unknown>;
656
+ create(options?: Record<string, unknown>): ModelAdapter | RespondModelAdapter;
657
+ }
658
+
659
+ export type ModelAdapterInput =
660
+ | ModelAdapter
661
+ | RespondModelAdapter
662
+ | ModelAdapterFactory
663
+ | ((options?: Record<string, unknown>) => ModelAdapter | RespondModelAdapter | ModelAdapterFactory);
664
+
665
+ export interface ModelAdapterContext {
666
+ phase?: string;
667
+ surface?: "computer" | "cli" | string;
668
+ step?: number;
669
+ requestOptions?: Record<string, unknown>;
670
+ }
671
+
672
+ export function createModelAdapter(adapter: ModelAdapterInput): ModelAdapter;
673
+
674
+ export function response(options?: {
675
+ id?: string;
676
+ output?: Array<Record<string, unknown>>;
677
+ [key: string]: unknown;
678
+ }): Record<string, unknown>;
679
+ export function message(text: string, options?: Record<string, unknown>): Record<string, unknown>;
680
+ export function computerCall(action: ComputerAction, options?: Record<string, unknown>): Record<string, unknown>;
681
+ export function runCommandCall(command: string, options?: Record<string, unknown>): Record<string, unknown>;
682
+ export function functionCall(
683
+ name: string,
684
+ args?: Record<string, unknown> | string,
685
+ options?: Record<string, unknown>
686
+ ): Record<string, unknown>;
687
+ export function getInputText(payload: Record<string, unknown>): string;
688
+ export function getTool(payload: Record<string, unknown>, typeOrName: string): Record<string, unknown> | null;
689
+ export function getComputerTool(payload: Record<string, unknown>): Record<string, unknown> | null;
690
+ export function getLastComputerScreenshot(payload: Record<string, unknown>): {
691
+ mediaType: string;
692
+ base64: string;
693
+ buffer: Buffer;
694
+ } | null;
695
+ export function getFunctionOutputs(payload: Record<string, unknown>): Array<{ callId: string; output: unknown }>;
696
+ export function getOutputText(response: Record<string, unknown>): string;
697
+ export function parseOutputJson(response: Record<string, unknown>): unknown;
698
+ export function parseDataUrl(value: string): { mediaType: string; base64: string; buffer: Buffer };
699
+ export function toDataUrl(input: Screenshot, mediaType?: string): string;
700
+ export function testModelAdapter(adapter: ModelAdapterInput, scenarios?: Array<Record<string, unknown>>): Promise<void>;
701
+ export function defaultAdapterScenarios(): Array<Record<string, unknown>>;
702
+
703
+ export class BrowserAutomify extends Automify {
704
+ browser: unknown;
705
+ context: unknown;
706
+ page: unknown;
707
+ goto(url: string, gotoOptions?: Record<string, unknown>): Promise<void>;
708
+ close(): Promise<void>;
709
+ }
710
+
711
+ export class DockerComputerAutomify extends Automify {
712
+ session: DockerDesktopSession;
713
+ sharedFolder?: VirtualSharedFolderData;
714
+ close(): Promise<void>;
715
+ }
716
+
717
+ export class LocalComputerAutomify extends Automify {
718
+ close(): Promise<void>;
719
+ }
720
+
721
+ export function createBrowserAutomify(options: BrowserAutomifyOptions): Promise<BrowserAutomify>;
722
+ export function withBrowserAutomify<T>(
723
+ options: BrowserAutomifyOptions,
724
+ run: (automify: BrowserAutomify) => Promise<T> | T
725
+ ): Promise<T>;
726
+ export function createDockerComputerAutomify(options?: DockerComputerAutomifyOptions): Promise<DockerComputerAutomify>;
727
+ export function createLocalComputerAutomify(options?: LocalComputerAutomifyOptions): Promise<LocalComputerAutomify>;
728
+
729
+ export function createLocalDesktopComputer(options?: LocalDesktopComputerOptions): Promise<ComputerAdapter>;
730
+ export function executeLocalDesktopAction(action: ComputerAction, options?: LocalDesktopComputerOptions): Promise<void>;
731
+ export function captureLocalDesktopScreenshot(options?: LocalDesktopComputerOptions): Promise<Screenshot>;
732
+ export const argumentReference: ArgumentReferenceEntry[];
733
+ export function createDockerDesktopComputer(
734
+ options?: DockerDesktopComputerOptions
735
+ ): Promise<ComputerAdapter & { session: DockerDesktopSession; sharedFolder?: VirtualSharedFolderData }>;
736
+ export function createVirtualDesktopComputer(
737
+ options?: DockerDesktopComputerOptions
738
+ ): Promise<ComputerAdapter & { session: DockerDesktopSession; sharedFolder?: VirtualSharedFolderData }>;
739
+ export function defaultDockerDesktopImage(): string;
740
+ export function defaultVirtualDesktopImage(): string;
741
+ export function dockerDesktopDockerfile(): string;
742
+ export function virtualDesktopDockerfile(): string;
743
+
744
+ export interface CliAutomifyOptions extends Omit<InitAutomifyOptions, "model" | "onComplete"> {
745
+ preset?: CliPreset;
746
+ model?: string;
747
+ command?: CliCommandOptions;
748
+ commands?: CliCommandOptions;
749
+ cwd?: string;
750
+ env?: Record<string, string>;
751
+ shell?: boolean | string;
752
+ timeoutMs?: number;
753
+ maxSteps?: number;
754
+ requestOptions?: Record<string, unknown>;
755
+ runner?: (
756
+ command: string,
757
+ options: { cwd?: string; env?: Record<string, string>; shell?: boolean | string; timeoutMs?: number }
758
+ ) => Promise<Record<string, unknown>>;
759
+ confirmCommand?: (event: {
760
+ command: { command: string; cwd?: string; timeoutMs?: number };
761
+ call: Record<string, unknown>;
762
+ response: Record<string, unknown>;
763
+ }) => Promise<boolean> | boolean;
764
+ approval?: "always" | "never";
765
+ allowedCommands?: CommandRule[];
766
+ blockedCommands?: CommandRule[];
767
+ onStep?: (event: Record<string, unknown>) => Promise<void> | void;
768
+ onRequest?: (payload: Record<string, unknown>, meta: Record<string, unknown>) => Promise<void> | void;
769
+ onResponse?: (response: Record<string, unknown>, meta: Record<string, unknown>) => Promise<void> | void;
770
+ onComplete?: (event: CliAutomifyCompleteEvent) => Promise<void> | void;
771
+ silent?: boolean;
772
+ debug?: DebugLogger;
773
+ /**
774
+ * Append CLI debug events as JSON Lines to this file.
775
+ */
776
+ logFile?: string;
777
+ reasoning?: Record<string, unknown>;
778
+ safetyIdentifier?: string;
779
+ }
780
+
781
+ export interface CliDoOptions {
782
+ data?: Record<string, unknown>;
783
+ evaluate?: FileToEvaluateInput | FileToEvaluateInput[];
784
+ filesToEvaluate?: FileToEvaluateInput | FileToEvaluateInput[];
785
+ model?: string;
786
+ maxSteps?: number;
787
+ limits?: RunLimitsOptions;
788
+ request?: Record<string, unknown>;
789
+ requestOptions?: Record<string, unknown>;
790
+ output?: OutputFormat;
791
+ command?: CliCommandOptions;
792
+ commands?: CliCommandOptions;
793
+ cwd?: string;
794
+ env?: Record<string, string>;
795
+ shell?: boolean | string;
796
+ timeoutMs?: number;
797
+ approval?: "always" | "never";
798
+ allowedCommands?: CommandRule[];
799
+ blockedCommands?: CommandRule[];
800
+ instructions?: string;
801
+ confirmCommand?: CliAutomifyOptions["confirmCommand"];
802
+ hooks?: DoHooksOptions<CliAutomifyCompleteEvent>;
803
+ onStep?: (event: Record<string, unknown>) => Promise<void> | void;
804
+ onComplete?: (event: CliAutomifyCompleteEvent) => Promise<void> | void;
805
+ reasoning?: Record<string, unknown>;
806
+ safetyIdentifier?: string;
807
+ silent?: boolean;
808
+ }
809
+
810
+ export type CliAutomifyDoOptions = CliDoOptions;
811
+
812
+ export interface CliAutomifyResult {
813
+ response: Record<string, unknown>;
814
+ steps: Array<Record<string, unknown>>;
815
+ ok: boolean;
816
+ status: "succeeded";
817
+ completed: boolean;
818
+ stopReason: "done";
819
+ text: string;
820
+ parsed?: unknown;
821
+ }
822
+
823
+ export interface CliAutomifyCompleteEvent {
824
+ instruction: string;
825
+ data: Record<string, unknown>;
826
+ result: CliAutomifyResult;
827
+ response: Record<string, unknown>;
828
+ steps: Array<Record<string, unknown>>;
829
+ ok: boolean;
830
+ status: "succeeded";
831
+ completed: boolean;
832
+ stopReason: "done";
833
+ surface: "cli";
834
+ }
835
+
836
+ export class CliAutomify {
837
+ constructor(options: CliAutomifyOptions);
838
+ do(instruction: string, options?: CliAutomifyDoOptions): Promise<CliAutomifyResult>;
839
+ }
840
+
841
+ export function createCliAutomify(options: CliAutomifyOptions): CliAutomify;
842
+ export function runShellCommand(
843
+ command: string,
844
+ options?: { cwd?: string; env?: Record<string, string>; shell?: boolean | string; timeoutMs?: number }
845
+ ): Promise<Record<string, unknown>>;
846
+
847
+ export interface FileToDataOptions {
848
+ format?: "text" | "metadata" | "base64" | "data_url" | "dataUrl" | "buffer";
849
+ mediaType?: string;
850
+ encoding?: BufferEncoding;
851
+ }
852
+
853
+ export interface FileToEvaluateOptions {
854
+ mediaType?: string;
855
+ encoding?: BufferEncoding;
856
+ detail?: "auto" | "low" | "high" | string;
857
+ maxBytes?: number;
858
+ }
859
+
860
+ export type FileToDataInput =
861
+ | string
862
+ | {
863
+ path: string;
864
+ name?: string;
865
+ mediaType?: string;
866
+ format?: FileToDataOptions["format"];
867
+ encoding?: BufferEncoding;
868
+ };
869
+
870
+ export type FileToEvaluateInput =
871
+ | string
872
+ | {
873
+ path: string;
874
+ name?: string;
875
+ mediaType?: string;
876
+ encoding?: BufferEncoding;
877
+ detail?: FileToEvaluateOptions["detail"];
878
+ maxBytes?: number;
879
+ };
880
+
881
+ export function fileToData(file: FileToDataInput, options?: FileToDataOptions): Promise<Record<string, unknown>>;
882
+ export function filesToData(
883
+ files: FileToDataInput | FileToDataInput[],
884
+ options?: FileToDataOptions
885
+ ): Promise<Array<Record<string, unknown>>>;
886
+ export function fileToEvaluate(
887
+ file: FileToEvaluateInput,
888
+ options?: FileToEvaluateOptions
889
+ ): Promise<Record<string, unknown>>;
890
+ export function filesToEvaluate(
891
+ files: FileToEvaluateInput | FileToEvaluateInput[],
892
+ options?: FileToEvaluateOptions
893
+ ): Promise<Array<Record<string, unknown>>>;
894
+
895
+ export interface DockerCliAutomifyOptions extends CliAutomifyOptions {
896
+ preset?: DockerCliPreset;
897
+ container?: DockerContainerOptions;
898
+ dockerCommand?: string;
899
+ image?: string;
900
+ containerName?: string;
901
+ existingContainer?: boolean;
902
+ keepContainer?: boolean;
903
+ workdir?: string;
904
+ workspacePath?: string;
905
+ containerCwd?: string;
906
+ startupCommand?: string;
907
+ packages?: string[];
908
+ additionalAptPackages?: string[];
909
+ installDependencies?: boolean;
910
+ autoRemove?: boolean;
911
+ sandbox?: boolean;
912
+ readOnly?: boolean;
913
+ network?: string | false;
914
+ cpus?: number | string;
915
+ memory?: number | string;
916
+ memorySwap?: number | string;
917
+ cpuShares?: number;
918
+ cpusetCpus?: string;
919
+ pidsLimit?: number;
920
+ shmSize?: string;
921
+ tmpfsTmp?: string;
922
+ volumes?: string[];
923
+ containerEnv?: string[];
924
+ shared?: VirtualSharedFolderInput;
925
+ sharedFolder?: VirtualSharedFolderInput;
926
+ sharedFiles?: VirtualSharedFileInput[];
927
+ files?: VirtualSharedFileInput[];
928
+ dockerTimeoutMs?: number;
929
+ commandMaxBuffer?: number;
930
+ execFile?: (...args: unknown[]) => Promise<{ stdout?: Buffer | string; stderr?: Buffer | string }>;
931
+ }
932
+
933
+ export type VirtualCliAutomifyOptions = DockerCliAutomifyOptions;
934
+
935
+ export class DockerCliSession {
936
+ constructor(options?: DockerCliAutomifyOptions);
937
+ readonly name: string;
938
+ readonly cwd: string;
939
+ readonly sharedFolder?: { data: VirtualSharedFolderData };
940
+ start(): Promise<void>;
941
+ run(
942
+ command: string,
943
+ options?: { cwd?: string; env?: Record<string, string>; timeoutMs?: number }
944
+ ): Promise<Record<string, unknown>>;
945
+ close(): Promise<void>;
946
+ }
947
+
948
+ export class DockerCliAutomify extends CliAutomify {
949
+ session: DockerCliSession;
950
+ readonly sharedFolder?: VirtualSharedFolderData;
951
+ do(instruction: string, options?: CliAutomifyDoOptions): Promise<CliAutomifyResult>;
952
+ close(): Promise<void>;
953
+ }
954
+
955
+ export { DockerCliAutomify as VirtualCliAutomify, DockerCliSession as DockerVirtualCliSession };
956
+
957
+ export function createDockerCliAutomify(options: DockerCliAutomifyOptions): DockerCliAutomify;
958
+ export function createVirtualCliAutomify(options: DockerCliAutomifyOptions): DockerCliAutomify;
959
+
960
+ export class OpenAIResponsesClient {
961
+ constructor(options: {
962
+ openaiApiKey?: string;
963
+ baseURL?: string;
964
+ fetchImpl?: typeof fetch;
965
+ timeoutMs?: number;
966
+ maxRetries?: number;
967
+ retryDelayMs?: number;
968
+ });
969
+ createResponse(payload: Record<string, unknown>): Promise<Record<string, unknown>>;
970
+ }
971
+
972
+ export interface AnthropicModelAdapterOptions {
973
+ anthropicApiKey?: string;
974
+ baseURL?: string;
975
+ version?: string;
976
+ betas?: string | string[];
977
+ fetchImpl?: typeof fetch;
978
+ maxTokens?: number;
979
+ computerToolType?: string;
980
+ requestTransform?: (
981
+ request: Record<string, unknown>,
982
+ context: { payload: Record<string, unknown>; context?: ModelAdapterContext }
983
+ ) => Promise<Record<string, unknown>> | Record<string, unknown>;
984
+ responseTransform?: (
985
+ response: Record<string, unknown>,
986
+ context: { payload: Record<string, unknown>; context?: ModelAdapterContext; request: Record<string, unknown> }
987
+ ) => Promise<Record<string, unknown>> | Record<string, unknown>;
988
+ }
989
+
990
+ export class AnthropicModelAdapter implements ModelAdapter {
991
+ constructor(options: AnthropicModelAdapterOptions);
992
+ createResponse(payload: Record<string, unknown>, context?: ModelAdapterContext): Promise<Record<string, unknown>>;
993
+ }
994
+
995
+ export function createAnthropicModelAdapter(options: AnthropicModelAdapterOptions): AnthropicModelAdapter;
996
+
997
+ export class AutomifyError extends Error {}
998
+ export class SafetyCheckError extends AutomifyError {
999
+ checks: Array<Record<string, unknown>>;
1000
+ action: ComputerAction;
1001
+ }
1002
+ export class MaxStepsExceededError extends AutomifyError {
1003
+ maxSteps: number;
1004
+ }
1005
+
1006
+ export interface BrowserComputerOptions {
1007
+ playwright?: Record<string, unknown>;
1008
+ browser?: "chromium" | "firefox" | "webkit" | string;
1009
+ browserName?: "chromium" | "firefox" | "webkit" | string;
1010
+ headless?: boolean;
1011
+ startUrl?: string;
1012
+ url?: string;
1013
+ viewport?: ViewportOptions;
1014
+ displayWidth?: number;
1015
+ displayHeight?: number;
1016
+ environment?: ComputerUseEnvironment;
1017
+ launch?: Record<string, unknown>;
1018
+ launchOptions?: Record<string, unknown>;
1019
+ context?: Record<string, unknown>;
1020
+ contextOptions?: Record<string, unknown>;
1021
+ navigation?: Record<string, unknown>;
1022
+ gotoOptions?: Record<string, unknown>;
1023
+ actionDelayMs?: number;
1024
+ waitMs?: number;
1025
+ instructions?: string;
1026
+ silent?: boolean;
1027
+ debug?: DebugLogger;
1028
+ /**
1029
+ * Append browser adapter debug events as JSON Lines to this file.
1030
+ */
1031
+ logFile?: string;
1032
+ onUnknownAction?: (action: ComputerAction) => Promise<void> | void;
1033
+ }
1034
+
1035
+ export interface BrowserComputer extends ComputerAdapter {
1036
+ browser: unknown;
1037
+ context: unknown;
1038
+ page: unknown;
1039
+ goto(url: string, gotoOptions?: Record<string, unknown>): Promise<void>;
1040
+ close(): Promise<void>;
1041
+ }
1042
+
1043
+ export function createBrowserComputer(options?: BrowserComputerOptions): Promise<BrowserComputer>;
1044
+ export function createPlaywrightComputer(page: unknown, options?: Record<string, unknown>): ComputerAdapter;
1045
+ export function executePlaywrightAction(
1046
+ page: unknown,
1047
+ action: ComputerAction,
1048
+ options?: Record<string, unknown>
1049
+ ): Promise<void>;