@epsilon-asi/actors 0.0.22 → 0.0.32

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 (193) hide show
  1. package/dist/browser/RuntimeConfig.d.ts +26 -0
  2. package/dist/browser/RuntimeConfig.d.ts.map +1 -1
  3. package/dist/browser/RuntimeConfig.js +29 -1
  4. package/dist/browser/RuntimeConfig.js.map +1 -1
  5. package/dist/core/ActorContext.d.ts +2 -0
  6. package/dist/core/ActorContext.d.ts.map +1 -1
  7. package/dist/core/ActorRunner.d.ts +3 -0
  8. package/dist/core/ActorRunner.d.ts.map +1 -1
  9. package/dist/core/ActorRunner.js +11 -1
  10. package/dist/core/ActorRunner.js.map +1 -1
  11. package/dist/index.d.ts +2 -0
  12. package/dist/index.d.ts.map +1 -1
  13. package/dist/index.js +2 -0
  14. package/dist/index.js.map +1 -1
  15. package/dist/native/CompositeNativeWindowDriver.d.ts +11 -0
  16. package/dist/native/CompositeNativeWindowDriver.d.ts.map +1 -0
  17. package/dist/native/CompositeNativeWindowDriver.js +31 -0
  18. package/dist/native/CompositeNativeWindowDriver.js.map +1 -0
  19. package/dist/native/NativeActionRegistry.d.ts +14 -0
  20. package/dist/native/NativeActionRegistry.d.ts.map +1 -0
  21. package/dist/native/NativeActionRegistry.js +101 -0
  22. package/dist/native/NativeActionRegistry.js.map +1 -0
  23. package/dist/native/NativeAutomation.d.ts +3 -0
  24. package/dist/native/NativeAutomation.d.ts.map +1 -0
  25. package/dist/native/NativeAutomation.js +12 -0
  26. package/dist/native/NativeAutomation.js.map +1 -0
  27. package/dist/native/NativeCoordinateMapper.d.ts +23 -0
  28. package/dist/native/NativeCoordinateMapper.d.ts.map +1 -0
  29. package/dist/native/NativeCoordinateMapper.js +201 -0
  30. package/dist/native/NativeCoordinateMapper.js.map +1 -0
  31. package/dist/native/NativeFileDialogService.d.ts +26 -0
  32. package/dist/native/NativeFileDialogService.d.ts.map +1 -0
  33. package/dist/native/NativeFileDialogService.js +121 -0
  34. package/dist/native/NativeFileDialogService.js.map +1 -0
  35. package/dist/native/NativeImageFinder.d.ts +12 -0
  36. package/dist/native/NativeImageFinder.d.ts.map +1 -0
  37. package/dist/native/NativeImageFinder.js +29 -0
  38. package/dist/native/NativeImageFinder.js.map +1 -0
  39. package/dist/native/NativeKeyboard.d.ts +10 -0
  40. package/dist/native/NativeKeyboard.d.ts.map +1 -0
  41. package/dist/native/NativeKeyboard.js +16 -0
  42. package/dist/native/NativeKeyboard.js.map +1 -0
  43. package/dist/native/NativeMouse.d.ts +38 -0
  44. package/dist/native/NativeMouse.d.ts.map +1 -0
  45. package/dist/native/NativeMouse.js +82 -0
  46. package/dist/native/NativeMouse.js.map +1 -0
  47. package/dist/native/NativeWindowService.d.ts +31 -0
  48. package/dist/native/NativeWindowService.d.ts.map +1 -0
  49. package/dist/native/NativeWindowService.js +183 -0
  50. package/dist/native/NativeWindowService.js.map +1 -0
  51. package/dist/native/UnsupportedNativeAutomation.d.ts +4 -0
  52. package/dist/native/UnsupportedNativeAutomation.d.ts.map +1 -0
  53. package/dist/native/UnsupportedNativeAutomation.js +77 -0
  54. package/dist/native/UnsupportedNativeAutomation.js.map +1 -0
  55. package/dist/native/WindowMatcher.d.ts +4 -0
  56. package/dist/native/WindowMatcher.d.ts.map +1 -0
  57. package/dist/native/WindowMatcher.js +39 -0
  58. package/dist/native/WindowMatcher.js.map +1 -0
  59. package/dist/native/drivers.d.ts +37 -0
  60. package/dist/native/drivers.d.ts.map +1 -0
  61. package/dist/native/drivers.js +2 -0
  62. package/dist/native/drivers.js.map +1 -0
  63. package/dist/native/errors.d.ts +23 -0
  64. package/dist/native/errors.d.ts.map +1 -0
  65. package/dist/native/errors.js +45 -0
  66. package/dist/native/errors.js.map +1 -0
  67. package/dist/native/index.d.ts +13 -0
  68. package/dist/native/index.d.ts.map +1 -0
  69. package/dist/native/index.js +13 -0
  70. package/dist/native/index.js.map +1 -0
  71. package/dist/native/macos/MacOSAccessibilityWindowDriver.d.ts +11 -0
  72. package/dist/native/macos/MacOSAccessibilityWindowDriver.d.ts.map +1 -0
  73. package/dist/native/macos/MacOSAccessibilityWindowDriver.js +180 -0
  74. package/dist/native/macos/MacOSAccessibilityWindowDriver.js.map +1 -0
  75. package/dist/native/macos/MacOSAppleScriptClient.d.ts +24 -0
  76. package/dist/native/macos/MacOSAppleScriptClient.d.ts.map +1 -0
  77. package/dist/native/macos/MacOSAppleScriptClient.js +163 -0
  78. package/dist/native/macos/MacOSAppleScriptClient.js.map +1 -0
  79. package/dist/native/macos/MacOSFileDialogAccessibilityStrategy.d.ts +10 -0
  80. package/dist/native/macos/MacOSFileDialogAccessibilityStrategy.d.ts.map +1 -0
  81. package/dist/native/macos/MacOSFileDialogAccessibilityStrategy.js +12 -0
  82. package/dist/native/macos/MacOSFileDialogAccessibilityStrategy.js.map +1 -0
  83. package/dist/native/macos/MacOSNativeAutomation.d.ts +3 -0
  84. package/dist/native/macos/MacOSNativeAutomation.d.ts.map +1 -0
  85. package/dist/native/macos/MacOSNativeAutomation.js +88 -0
  86. package/dist/native/macos/MacOSNativeAutomation.js.map +1 -0
  87. package/dist/native/nut/NutNativeImageFinder.d.ts +17 -0
  88. package/dist/native/nut/NutNativeImageFinder.d.ts.map +1 -0
  89. package/dist/native/nut/NutNativeImageFinder.js +84 -0
  90. package/dist/native/nut/NutNativeImageFinder.js.map +1 -0
  91. package/dist/native/nut/NutNativeKeyboardDriver.d.ts +8 -0
  92. package/dist/native/nut/NutNativeKeyboardDriver.d.ts.map +1 -0
  93. package/dist/native/nut/NutNativeKeyboardDriver.js +39 -0
  94. package/dist/native/nut/NutNativeKeyboardDriver.js.map +1 -0
  95. package/dist/native/nut/NutNativeMouseDriver.d.ts +8 -0
  96. package/dist/native/nut/NutNativeMouseDriver.d.ts.map +1 -0
  97. package/dist/native/nut/NutNativeMouseDriver.js +24 -0
  98. package/dist/native/nut/NutNativeMouseDriver.js.map +1 -0
  99. package/dist/native/nut/NutNativeScreenDriver.d.ts +6 -0
  100. package/dist/native/nut/NutNativeScreenDriver.d.ts.map +1 -0
  101. package/dist/native/nut/NutNativeScreenDriver.js +12 -0
  102. package/dist/native/nut/NutNativeScreenDriver.js.map +1 -0
  103. package/dist/native/nut/NutNativeWindowDriver.d.ts +6 -0
  104. package/dist/native/nut/NutNativeWindowDriver.d.ts.map +1 -0
  105. package/dist/native/nut/NutNativeWindowDriver.js +53 -0
  106. package/dist/native/nut/NutNativeWindowDriver.js.map +1 -0
  107. package/dist/native/nut/loadNut.d.ts +58 -0
  108. package/dist/native/nut/loadNut.d.ts.map +1 -0
  109. package/dist/native/nut/loadNut.js +25 -0
  110. package/dist/native/nut/loadNut.js.map +1 -0
  111. package/dist/native/types.d.ts +194 -0
  112. package/dist/native/types.d.ts.map +1 -0
  113. package/dist/native/types.js +2 -0
  114. package/dist/native/types.js.map +1 -0
  115. package/dist/native/utils/appleScriptEscape.d.ts +7 -0
  116. package/dist/native/utils/appleScriptEscape.d.ts.map +1 -0
  117. package/dist/native/utils/appleScriptEscape.js +11 -0
  118. package/dist/native/utils/appleScriptEscape.js.map +1 -0
  119. package/dist/native/utils/geometry.d.ts +12 -0
  120. package/dist/native/utils/geometry.d.ts.map +1 -0
  121. package/dist/native/utils/geometry.js +77 -0
  122. package/dist/native/utils/geometry.js.map +1 -0
  123. package/dist/native/utils/redactNative.d.ts +2 -0
  124. package/dist/native/utils/redactNative.d.ts.map +1 -0
  125. package/dist/native/utils/redactNative.js +7 -0
  126. package/dist/native/utils/redactNative.js.map +1 -0
  127. package/dist/native/utils/waitFor.d.ts +7 -0
  128. package/dist/native/utils/waitFor.d.ts.map +1 -0
  129. package/dist/native/utils/waitFor.js +17 -0
  130. package/dist/native/utils/waitFor.js.map +1 -0
  131. package/dist/sites/upwork-com/upwork-com.actor.d.ts +4 -1
  132. package/dist/sites/upwork-com/upwork-com.actor.d.ts.map +1 -1
  133. package/dist/sites/upwork-com/upwork-com.actor.js +30 -11
  134. package/dist/sites/upwork-com/upwork-com.actor.js.map +1 -1
  135. package/dist/sites/upwork-com/upwork-com.types.d.ts +3 -1
  136. package/dist/sites/upwork-com/upwork-com.types.d.ts.map +1 -1
  137. package/dist/sites/upwork-com/upwork-com.types.js.map +1 -1
  138. package/dist/sites/upwork-com/util/parseJobApplicationDetails.d.ts +70 -0
  139. package/dist/sites/upwork-com/util/parseJobApplicationDetails.d.ts.map +1 -0
  140. package/dist/sites/upwork-com/util/parseJobApplicationDetails.js +334 -0
  141. package/dist/sites/upwork-com/util/parseJobApplicationDetails.js.map +1 -0
  142. package/package.json +5 -1
  143. package/src/browser/RuntimeConfig.ts +57 -1
  144. package/src/core/ActorContext.ts +2 -0
  145. package/src/core/ActorRunner.ts +13 -1
  146. package/src/index.ts +2 -0
  147. package/src/native/CompositeNativeWindowDriver.ts +30 -0
  148. package/src/native/NativeActionRegistry.ts +114 -0
  149. package/src/native/NativeAutomation.ts +15 -0
  150. package/src/native/NativeCoordinateMapper.ts +258 -0
  151. package/src/native/NativeFileDialogService.ts +138 -0
  152. package/src/native/NativeImageFinder.ts +33 -0
  153. package/src/native/NativeKeyboard.ts +18 -0
  154. package/src/native/NativeMouse.ts +116 -0
  155. package/src/native/NativeWindowService.ts +229 -0
  156. package/src/native/UnsupportedNativeAutomation.ts +92 -0
  157. package/src/native/WindowMatcher.ts +31 -0
  158. package/src/native/drivers.ts +38 -0
  159. package/src/native/errors.ts +51 -0
  160. package/src/native/index.ts +12 -0
  161. package/src/native/macos/MacOSAccessibilityWindowDriver.ts +183 -0
  162. package/src/native/macos/MacOSAppleScriptClient.ts +182 -0
  163. package/src/native/macos/MacOSFileDialogAccessibilityStrategy.ts +11 -0
  164. package/src/native/macos/MacOSNativeAutomation.ts +86 -0
  165. package/src/native/nut/NutNativeImageFinder.ts +98 -0
  166. package/src/native/nut/NutNativeKeyboardDriver.ts +38 -0
  167. package/src/native/nut/NutNativeMouseDriver.ts +27 -0
  168. package/src/native/nut/NutNativeScreenDriver.ts +14 -0
  169. package/src/native/nut/NutNativeWindowDriver.ts +61 -0
  170. package/src/native/nut/loadNut.ts +86 -0
  171. package/src/native/types.ts +224 -0
  172. package/src/native/utils/appleScriptEscape.ts +11 -0
  173. package/src/native/utils/geometry.ts +88 -0
  174. package/src/native/utils/redactNative.ts +6 -0
  175. package/src/native/utils/waitFor.ts +25 -0
  176. package/src/sites/upwork-com/upwork-com.actor.ts +46 -14
  177. package/src/sites/upwork-com/upwork-com.types.ts +4 -1
  178. package/src/sites/upwork-com/util/parseJobApplicationDetails.ts +622 -0
  179. package/tests/fixtures/makeContext.ts +7 -2
  180. package/tests/fixtures/native/FakeNativeAutomation.ts +138 -0
  181. package/tests/unit/browser/RuntimeConfig.native.test.ts +63 -0
  182. package/tests/unit/core/ActorRunner.native.test.ts +69 -0
  183. package/tests/unit/native/MacOSAppleScriptClient.test.ts +35 -0
  184. package/tests/unit/native/NativeActionRegistry.test.ts +34 -0
  185. package/tests/unit/native/NativeCoordinateMapper.test.ts +92 -0
  186. package/tests/unit/native/NativeFileDialogService.test.ts +91 -0
  187. package/tests/unit/native/NativeMouse.test.ts +91 -0
  188. package/tests/unit/native/NativeWindowService.test.ts +87 -0
  189. package/tests/unit/native/WindowMatcher.test.ts +32 -0
  190. package/tests/unit/native/appleScriptEscape.test.ts +9 -0
  191. package/tests/unit/sites/myvistage-com.login.test.ts +1 -1
  192. package/tests/unit/sites/myvistage-com.postComment.test.ts +0 -1
  193. package/tests/unit/sites/upwork-com.login.test.ts +1 -1
@@ -0,0 +1,87 @@
1
+ import { describe, expect, it } from 'vitest';
2
+ import { DefaultNativeWindowService } from '../../../src/native/NativeWindowService.js';
3
+ import type { NativeScreenDriver, NativeWindowDriver, NativeWindowHandle } from '../../../src/native/drivers.js';
4
+ import type { NativePoint, NativeSize, NativeWindowInfo } from '../../../src/native/types.js';
5
+
6
+ class FakeWindowHandle implements NativeWindowHandle {
7
+ focusCalls = 0;
8
+ minimizeCalls = 0;
9
+ restoreCalls = 0;
10
+ moveCalls: NativePoint[] = [];
11
+ resizeCalls: NativeSize[] = [];
12
+ setFullscreenCalls: boolean[] = [];
13
+ toggleFullscreenCalls = 0;
14
+
15
+ constructor(private current: NativeWindowInfo) {}
16
+
17
+ async info(): Promise<NativeWindowInfo> { return this.current; }
18
+ async focus(): Promise<void> { this.focusCalls += 1; this.current = { ...this.current, isFocused: true }; }
19
+ async minimize(): Promise<void> { this.minimizeCalls += 1; this.current = { ...this.current, isMinimized: true }; }
20
+ async restore(): Promise<void> { this.restoreCalls += 1; this.current = { ...this.current, isMinimized: false }; }
21
+ async move(point: NativePoint): Promise<void> { this.moveCalls.push(point); this.current = { ...this.current, region: { ...this.current.region, ...point } }; }
22
+ async resize(size: NativeSize): Promise<void> { this.resizeCalls.push(size); this.current = { ...this.current, region: { ...this.current.region, ...size } }; }
23
+ async setFullscreen(fullscreen: boolean): Promise<void> { this.setFullscreenCalls.push(fullscreen); this.current = { ...this.current, isFullscreen: fullscreen }; }
24
+ async toggleFullscreen(): Promise<void> { this.toggleFullscreenCalls += 1; }
25
+ }
26
+
27
+ class FakeWindowDriver implements NativeWindowDriver {
28
+ constructor(readonly handles: FakeWindowHandle[]) {}
29
+ async list(): Promise<NativeWindowHandle[]> { return this.handles; }
30
+ }
31
+
32
+ class FakeScreenDriver implements NativeScreenDriver {
33
+ async width(): Promise<number> { return 500; }
34
+ async height(): Promise<number> { return 400; }
35
+ }
36
+
37
+ describe('DefaultNativeWindowService', () => {
38
+ it('detects whether a matching window is open', async () => {
39
+ const handle = new FakeWindowHandle({ title: 'Upwork', appName: 'Google Chrome', region: { x: 0, y: 0, width: 100, height: 100 } });
40
+ const service = new DefaultNativeWindowService({ driver: new FakeWindowDriver([handle]), screen: new FakeScreenDriver() });
41
+
42
+ await expect(service.isOpen({ title: 'Upwork' })).resolves.toBe(true);
43
+ await expect(service.isOpen({ title: 'Other' })).resolves.toBe(false);
44
+ });
45
+
46
+ it('restores, focuses, and moves an off-screen window into view', async () => {
47
+ const handle = new FakeWindowHandle({ title: 'Chrome', isMinimized: true, region: { x: -900, y: -800, width: 200, height: 150 } });
48
+ const service = new DefaultNativeWindowService({ driver: new FakeWindowDriver([handle]), screen: new FakeScreenDriver() });
49
+
50
+ const info = await service.ensureInView({ title: 'Chrome' });
51
+
52
+ expect(handle.restoreCalls).toBe(1);
53
+ expect(handle.focusCalls).toBe(1);
54
+ expect(handle.moveCalls).toEqual([{ x: 0, y: 0 }]);
55
+ expect(info.region).toMatchObject({ x: 0, y: 0 });
56
+ });
57
+
58
+ it('does not toggle fullscreen when the requested state already matches', async () => {
59
+ const handle = new FakeWindowHandle({ title: 'Chrome', isFullscreen: true, region: { x: 0, y: 0, width: 500, height: 400 } });
60
+ const service = new DefaultNativeWindowService({ driver: new FakeWindowDriver([handle]), screen: new FakeScreenDriver() });
61
+
62
+ await service.setFullscreen({ title: 'Chrome' }, true);
63
+
64
+ expect(handle.setFullscreenCalls).toEqual([]);
65
+ expect(handle.toggleFullscreenCalls).toBe(0);
66
+ });
67
+
68
+ it('sets fullscreen through the handle when state differs', async () => {
69
+ const handle = new FakeWindowHandle({ title: 'Chrome', isFullscreen: false, region: { x: 0, y: 0, width: 500, height: 400 } });
70
+ const service = new DefaultNativeWindowService({ driver: new FakeWindowDriver([handle]), screen: new FakeScreenDriver() });
71
+
72
+ await service.setFullscreen({ title: 'Chrome' }, true);
73
+
74
+ expect(handle.setFullscreenCalls).toEqual([true]);
75
+ });
76
+
77
+ it('minimizes via the native minimize operation instead of fullscreen toggle', async () => {
78
+ const handle = new FakeWindowHandle({ title: 'Chrome', isFullscreen: true, region: { x: 0, y: 0, width: 500, height: 400 } });
79
+ const service = new DefaultNativeWindowService({ driver: new FakeWindowDriver([handle]), screen: new FakeScreenDriver() });
80
+
81
+ await service.minimize({ title: 'Chrome' });
82
+
83
+ expect(handle.minimizeCalls).toBe(1);
84
+ expect(handle.setFullscreenCalls).toEqual([]);
85
+ expect(handle.toggleFullscreenCalls).toBe(0);
86
+ });
87
+ });
@@ -0,0 +1,32 @@
1
+ import { describe, expect, it } from 'vitest';
2
+ import { matchesWindow, matcherToString } from '../../../src/native/WindowMatcher.js';
3
+ import type { NativeWindowInfo } from '../../../src/native/types.js';
4
+
5
+ const windowInfo: NativeWindowInfo = {
6
+ title: 'Upwork - Google Chrome',
7
+ appName: 'Google Chrome',
8
+ bundleId: 'com.google.Chrome',
9
+ role: 'AXWindow',
10
+ region: { x: 0, y: 0, width: 1200, height: 800 }
11
+ };
12
+
13
+ describe('WindowMatcher', () => {
14
+ it('matches exact title, app name, bundle id, role, includes, and regex', () => {
15
+ expect(matchesWindow(windowInfo, { title: 'Upwork - Google Chrome' })).toBe(true);
16
+ expect(matchesWindow(windowInfo, { appName: 'Google Chrome', titleIncludes: 'Upwork' })).toBe(true);
17
+ expect(matchesWindow(windowInfo, { bundleId: 'com.google.Chrome', role: 'AXWindow' })).toBe(true);
18
+ expect(matchesWindow(windowInfo, { titleRegex: /Upwork/ })).toBe(true);
19
+ expect(matchesWindow(windowInfo, { titleRegex: 'Google Chrome$' })).toBe(true);
20
+ });
21
+
22
+ it('rejects non-matching window attributes', () => {
23
+ expect(matchesWindow(windowInfo, { appName: 'Safari' })).toBe(false);
24
+ expect(matchesWindow(windowInfo, { titleIncludes: 'LinkedIn' })).toBe(false);
25
+ expect(matchesWindow(windowInfo, { titleRegex: /^Safari/ })).toBe(false);
26
+ });
27
+
28
+ it('summarizes matchers for diagnostics', () => {
29
+ expect(matcherToString({ appName: 'Google Chrome', titleIncludes: 'Upwork' })).toBe('app=Google Chrome, titleIncludes=Upwork');
30
+ expect(matcherToString({})).toBe('<any window>');
31
+ });
32
+ });
@@ -0,0 +1,9 @@
1
+ import { describe, expect, it } from 'vitest';
2
+ import { appleScriptString } from '../../../src/native/utils/appleScriptEscape.js';
3
+
4
+ describe('appleScriptString', () => {
5
+ it('escapes quotes, backslashes, spaces, apostrophes, and unicode safely', () => {
6
+ expect(appleScriptString('/Users/me/A "quoted" \\ file’s résumé.pdf'))
7
+ .toBe('"/Users/me/A \\"quoted\\" \\\\ file’s résumé.pdf"');
8
+ });
9
+ });
@@ -8,7 +8,7 @@ describe('myvistage-com actor login flow', () => {
8
8
 
9
9
  expect(auth).toBeDefined();
10
10
  expect(auth?.loginUrl).toBe('https://myvistage.com');
11
- expect(auth?.credentials).toEqual({ id: 'myvistage-com' });
11
+ expect(auth?.credentials).toEqual({ id: 'myvistage_com' });
12
12
  expect(auth?.selectors).toEqual(myvistageComSelectors.login);
13
13
  expect(auth?.steps).toBeUndefined();
14
14
  });
@@ -20,7 +20,6 @@ describe('myvistage-com actor postComment task', () => {
20
20
  subject: 'Quick follow-up'
21
21
  });
22
22
 
23
- expect(fakePage.gotos[0]?.url).toBe('https://myvistage.com/?status/151341-151341-1779377493/');
24
23
  expect(fakeInteractor.typed).toEqual([
25
24
  {
26
25
  selector: myvistageComSelectors.postComment.comment,
@@ -7,7 +7,7 @@ describe('upwork-com actor login flow', () => {
7
7
  const auth = upworkComActor.auth;
8
8
 
9
9
  expect(auth).toBeDefined();
10
- expect(auth?.loginUrl).toBe('https://www.upwork.com/ab/account-security/login');
10
+
11
11
  expect(auth?.credentials).toEqual({ id: 'upwork' });
12
12
  expect(auth?.selectors.loggedInSignal).toBe(upworkComSelectors.login.loggedInSignal);
13
13
  expect(auth?.selectors.errorMessage).toBe(upworkComSelectors.login.errorMessage);