@epsilon-asi/actors 0.0.1

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 (381) hide show
  1. package/.ai/generators/_template.ts +37 -0
  2. package/.ai/generators/abstract.ts +24 -0
  3. package/.ai/generators/actor-task-form-filler.ts +140 -0
  4. package/.ai/generators/actor-task.ts +122 -0
  5. package/.ai/generators/auth-core.ts +126 -0
  6. package/.ai/generators/browser-runtime.ts +114 -0
  7. package/.ai/generators/cli-command.ts +96 -0
  8. package/.ai/generators/core-framework.ts +80 -0
  9. package/.ai/generators/docs.ts +92 -0
  10. package/.ai/generators/error-logging.ts +102 -0
  11. package/.ai/generators/extraction-helper.ts +96 -0
  12. package/.ai/generators/interaction-behavior.ts +129 -0
  13. package/.ai/generators/site-actor.ts +125 -0
  14. package/.ai/generators/site-login-flow.ts +117 -0
  15. package/.ai/generators/unit-test.ts +109 -0
  16. package/.ai/workflows/_template.ts +20 -0
  17. package/.ai/workflows/starter.ts +20 -0
  18. package/README.md +435 -0
  19. package/ai-gen.config.ts +67 -0
  20. package/dist/auth/AuthStateDetector.d.ts +6 -0
  21. package/dist/auth/AuthStateDetector.d.ts.map +1 -0
  22. package/dist/auth/AuthStateDetector.js +14 -0
  23. package/dist/auth/AuthStateDetector.js.map +1 -0
  24. package/dist/auth/CredentialsProvider.d.ts +22 -0
  25. package/dist/auth/CredentialsProvider.d.ts.map +1 -0
  26. package/dist/auth/CredentialsProvider.js +30 -0
  27. package/dist/auth/CredentialsProvider.js.map +1 -0
  28. package/dist/auth/LoginFlow.d.ts +27 -0
  29. package/dist/auth/LoginFlow.d.ts.map +1 -0
  30. package/dist/auth/LoginFlow.js +233 -0
  31. package/dist/auth/LoginFlow.js.map +1 -0
  32. package/dist/auth/LoginFlow.types.d.ts +123 -0
  33. package/dist/auth/LoginFlow.types.d.ts.map +1 -0
  34. package/dist/auth/LoginFlow.types.js +7 -0
  35. package/dist/auth/LoginFlow.types.js.map +1 -0
  36. package/dist/auth/SessionStore.d.ts +16 -0
  37. package/dist/auth/SessionStore.d.ts.map +1 -0
  38. package/dist/auth/SessionStore.js +8 -0
  39. package/dist/auth/SessionStore.js.map +1 -0
  40. package/dist/auth/index.d.ts +6 -0
  41. package/dist/auth/index.d.ts.map +1 -0
  42. package/dist/auth/index.js +6 -0
  43. package/dist/auth/index.js.map +1 -0
  44. package/dist/browser/BrowserFactory.d.ts +16 -0
  45. package/dist/browser/BrowserFactory.d.ts.map +1 -0
  46. package/dist/browser/BrowserFactory.js +209 -0
  47. package/dist/browser/BrowserFactory.js.map +1 -0
  48. package/dist/browser/BrowserSession.d.ts +15 -0
  49. package/dist/browser/BrowserSession.d.ts.map +1 -0
  50. package/dist/browser/BrowserSession.js +42 -0
  51. package/dist/browser/BrowserSession.js.map +1 -0
  52. package/dist/browser/PuppeteerLike.d.ts +45 -0
  53. package/dist/browser/PuppeteerLike.d.ts.map +1 -0
  54. package/dist/browser/PuppeteerLike.js +10 -0
  55. package/dist/browser/PuppeteerLike.js.map +1 -0
  56. package/dist/browser/RuntimeConfig.d.ts +82 -0
  57. package/dist/browser/RuntimeConfig.d.ts.map +1 -0
  58. package/dist/browser/RuntimeConfig.js +64 -0
  59. package/dist/browser/RuntimeConfig.js.map +1 -0
  60. package/dist/browser/index.d.ts +6 -0
  61. package/dist/browser/index.d.ts.map +1 -0
  62. package/dist/browser/index.js +6 -0
  63. package/dist/browser/index.js.map +1 -0
  64. package/dist/browser/profileValidation.d.ts +6 -0
  65. package/dist/browser/profileValidation.d.ts.map +1 -0
  66. package/dist/browser/profileValidation.js +59 -0
  67. package/dist/browser/profileValidation.js.map +1 -0
  68. package/dist/cli/run.d.ts +3 -0
  69. package/dist/cli/run.d.ts.map +1 -0
  70. package/dist/cli/run.js +103 -0
  71. package/dist/cli/run.js.map +1 -0
  72. package/dist/core/Actor.d.ts +54 -0
  73. package/dist/core/Actor.d.ts.map +1 -0
  74. package/dist/core/Actor.js +68 -0
  75. package/dist/core/Actor.js.map +1 -0
  76. package/dist/core/ActorContext.d.ts +32 -0
  77. package/dist/core/ActorContext.d.ts.map +1 -0
  78. package/dist/core/ActorContext.js +2 -0
  79. package/dist/core/ActorContext.js.map +1 -0
  80. package/dist/core/ActorRegistry.d.ts +8 -0
  81. package/dist/core/ActorRegistry.d.ts.map +1 -0
  82. package/dist/core/ActorRegistry.js +22 -0
  83. package/dist/core/ActorRegistry.js.map +1 -0
  84. package/dist/core/ActorRunner.d.ts +57 -0
  85. package/dist/core/ActorRunner.d.ts.map +1 -0
  86. package/dist/core/ActorRunner.js +157 -0
  87. package/dist/core/ActorRunner.js.map +1 -0
  88. package/dist/core/defineActor.d.ts +3 -0
  89. package/dist/core/defineActor.d.ts.map +1 -0
  90. package/dist/core/defineActor.js +4 -0
  91. package/dist/core/defineActor.js.map +1 -0
  92. package/dist/core/index.d.ts +6 -0
  93. package/dist/core/index.d.ts.map +1 -0
  94. package/dist/core/index.js +6 -0
  95. package/dist/core/index.js.map +1 -0
  96. package/dist/errors/AuthError.d.ts +5 -0
  97. package/dist/errors/AuthError.d.ts.map +1 -0
  98. package/dist/errors/AuthError.js +7 -0
  99. package/dist/errors/AuthError.js.map +1 -0
  100. package/dist/errors/AutomationError.d.ts +17 -0
  101. package/dist/errors/AutomationError.d.ts.map +1 -0
  102. package/dist/errors/AutomationError.js +17 -0
  103. package/dist/errors/AutomationError.js.map +1 -0
  104. package/dist/errors/ConfigError.d.ts +5 -0
  105. package/dist/errors/ConfigError.d.ts.map +1 -0
  106. package/dist/errors/ConfigError.js +7 -0
  107. package/dist/errors/ConfigError.js.map +1 -0
  108. package/dist/errors/ExtractionError.d.ts +5 -0
  109. package/dist/errors/ExtractionError.d.ts.map +1 -0
  110. package/dist/errors/ExtractionError.js +7 -0
  111. package/dist/errors/ExtractionError.js.map +1 -0
  112. package/dist/errors/NavigationError.d.ts +5 -0
  113. package/dist/errors/NavigationError.d.ts.map +1 -0
  114. package/dist/errors/NavigationError.js +7 -0
  115. package/dist/errors/NavigationError.js.map +1 -0
  116. package/dist/errors/SelectorError.d.ts +6 -0
  117. package/dist/errors/SelectorError.d.ts.map +1 -0
  118. package/dist/errors/SelectorError.js +9 -0
  119. package/dist/errors/SelectorError.js.map +1 -0
  120. package/dist/errors/index.d.ts +7 -0
  121. package/dist/errors/index.d.ts.map +1 -0
  122. package/dist/errors/index.js +7 -0
  123. package/dist/errors/index.js.map +1 -0
  124. package/dist/extraction/Extractor.d.ts +16 -0
  125. package/dist/extraction/Extractor.d.ts.map +1 -0
  126. package/dist/extraction/Extractor.js +54 -0
  127. package/dist/extraction/Extractor.js.map +1 -0
  128. package/dist/extraction/Pagination.d.ts +16 -0
  129. package/dist/extraction/Pagination.d.ts.map +1 -0
  130. package/dist/extraction/Pagination.js +36 -0
  131. package/dist/extraction/Pagination.js.map +1 -0
  132. package/dist/extraction/index.d.ts +3 -0
  133. package/dist/extraction/index.d.ts.map +1 -0
  134. package/dist/extraction/index.js +3 -0
  135. package/dist/extraction/index.js.map +1 -0
  136. package/dist/index.d.ts +10 -0
  137. package/dist/index.d.ts.map +1 -0
  138. package/dist/index.js +10 -0
  139. package/dist/index.js.map +1 -0
  140. package/dist/interaction/FieldClearer.d.ts +7 -0
  141. package/dist/interaction/FieldClearer.d.ts.map +1 -0
  142. package/dist/interaction/FieldClearer.js +53 -0
  143. package/dist/interaction/FieldClearer.js.map +1 -0
  144. package/dist/interaction/Forms.d.ts +13 -0
  145. package/dist/interaction/Forms.d.ts.map +1 -0
  146. package/dist/interaction/Forms.js +22 -0
  147. package/dist/interaction/Forms.js.map +1 -0
  148. package/dist/interaction/GhostCursorAdapter.d.ts +27 -0
  149. package/dist/interaction/GhostCursorAdapter.d.ts.map +1 -0
  150. package/dist/interaction/GhostCursorAdapter.js +51 -0
  151. package/dist/interaction/GhostCursorAdapter.js.map +1 -0
  152. package/dist/interaction/HumanInteractor.d.ts +29 -0
  153. package/dist/interaction/HumanInteractor.d.ts.map +1 -0
  154. package/dist/interaction/HumanInteractor.js +2 -0
  155. package/dist/interaction/HumanInteractor.js.map +1 -0
  156. package/dist/interaction/HumanTyping.d.ts +43 -0
  157. package/dist/interaction/HumanTyping.d.ts.map +1 -0
  158. package/dist/interaction/HumanTyping.js +85 -0
  159. package/dist/interaction/HumanTyping.js.map +1 -0
  160. package/dist/interaction/NativePuppeteerInteractor.d.ts +20 -0
  161. package/dist/interaction/NativePuppeteerInteractor.d.ts.map +1 -0
  162. package/dist/interaction/NativePuppeteerInteractor.js +47 -0
  163. package/dist/interaction/NativePuppeteerInteractor.js.map +1 -0
  164. package/dist/interaction/Navigation.d.ts +17 -0
  165. package/dist/interaction/Navigation.d.ts.map +1 -0
  166. package/dist/interaction/Navigation.js +28 -0
  167. package/dist/interaction/Navigation.js.map +1 -0
  168. package/dist/interaction/PageAdapter.d.ts +32 -0
  169. package/dist/interaction/PageAdapter.d.ts.map +1 -0
  170. package/dist/interaction/PageAdapter.js +62 -0
  171. package/dist/interaction/PageAdapter.js.map +1 -0
  172. package/dist/interaction/Waits.d.ts +3 -0
  173. package/dist/interaction/Waits.d.ts.map +1 -0
  174. package/dist/interaction/Waits.js +4 -0
  175. package/dist/interaction/Waits.js.map +1 -0
  176. package/dist/interaction/index.d.ts +10 -0
  177. package/dist/interaction/index.d.ts.map +1 -0
  178. package/dist/interaction/index.js +10 -0
  179. package/dist/interaction/index.js.map +1 -0
  180. package/dist/interaction/textToKeystrokeEvents.d.ts +13 -0
  181. package/dist/interaction/textToKeystrokeEvents.d.ts.map +1 -0
  182. package/dist/interaction/textToKeystrokeEvents.js +15 -0
  183. package/dist/interaction/textToKeystrokeEvents.js.map +1 -0
  184. package/dist/logging/ConsoleLogger.d.ts +12 -0
  185. package/dist/logging/ConsoleLogger.d.ts.map +1 -0
  186. package/dist/logging/ConsoleLogger.js +42 -0
  187. package/dist/logging/ConsoleLogger.js.map +1 -0
  188. package/dist/logging/Logger.d.ts +14 -0
  189. package/dist/logging/Logger.d.ts.map +1 -0
  190. package/dist/logging/Logger.js +2 -0
  191. package/dist/logging/Logger.js.map +1 -0
  192. package/dist/logging/MemoryLogger.d.ts +10 -0
  193. package/dist/logging/MemoryLogger.d.ts.map +1 -0
  194. package/dist/logging/MemoryLogger.js +28 -0
  195. package/dist/logging/MemoryLogger.js.map +1 -0
  196. package/dist/logging/NullLogger.d.ts +8 -0
  197. package/dist/logging/NullLogger.d.ts.map +1 -0
  198. package/dist/logging/NullLogger.js +7 -0
  199. package/dist/logging/NullLogger.js.map +1 -0
  200. package/dist/logging/index.d.ts +5 -0
  201. package/dist/logging/index.d.ts.map +1 -0
  202. package/dist/logging/index.js +5 -0
  203. package/dist/logging/index.js.map +1 -0
  204. package/dist/sites/example/example.actor.d.ts +6 -0
  205. package/dist/sites/example/example.actor.d.ts.map +1 -0
  206. package/dist/sites/example/example.actor.js +47 -0
  207. package/dist/sites/example/example.actor.js.map +1 -0
  208. package/dist/sites/example/example.selectors.d.ts +18 -0
  209. package/dist/sites/example/example.selectors.d.ts.map +1 -0
  210. package/dist/sites/example/example.selectors.js +18 -0
  211. package/dist/sites/example/example.selectors.js.map +1 -0
  212. package/dist/sites/example/example.types.d.ts +16 -0
  213. package/dist/sites/example/example.types.d.ts.map +1 -0
  214. package/dist/sites/example/example.types.js +2 -0
  215. package/dist/sites/example/example.types.js.map +1 -0
  216. package/dist/sites/example/index.d.ts +4 -0
  217. package/dist/sites/example/index.d.ts.map +1 -0
  218. package/dist/sites/example/index.js +4 -0
  219. package/dist/sites/example/index.js.map +1 -0
  220. package/dist/sites/index.d.ts +4 -0
  221. package/dist/sites/index.d.ts.map +1 -0
  222. package/dist/sites/index.js +4 -0
  223. package/dist/sites/index.js.map +1 -0
  224. package/dist/sites/myvistage-com/index.d.ts +4 -0
  225. package/dist/sites/myvistage-com/index.d.ts.map +1 -0
  226. package/dist/sites/myvistage-com/index.js +4 -0
  227. package/dist/sites/myvistage-com/index.js.map +1 -0
  228. package/dist/sites/myvistage-com/myvistage-com.actor.d.ts +6 -0
  229. package/dist/sites/myvistage-com/myvistage-com.actor.d.ts.map +1 -0
  230. package/dist/sites/myvistage-com/myvistage-com.actor.js +44 -0
  231. package/dist/sites/myvistage-com/myvistage-com.actor.js.map +1 -0
  232. package/dist/sites/myvistage-com/myvistage-com.selectors.d.ts +15 -0
  233. package/dist/sites/myvistage-com/myvistage-com.selectors.d.ts.map +1 -0
  234. package/dist/sites/myvistage-com/myvistage-com.selectors.js +15 -0
  235. package/dist/sites/myvistage-com/myvistage-com.selectors.js.map +1 -0
  236. package/dist/sites/myvistage-com/myvistage-com.types.d.ts +16 -0
  237. package/dist/sites/myvistage-com/myvistage-com.types.d.ts.map +1 -0
  238. package/dist/sites/myvistage-com/myvistage-com.types.js +2 -0
  239. package/dist/sites/myvistage-com/myvistage-com.types.js.map +1 -0
  240. package/dist/sites/upwork-com/index.d.ts +6 -0
  241. package/dist/sites/upwork-com/index.d.ts.map +1 -0
  242. package/dist/sites/upwork-com/index.js +6 -0
  243. package/dist/sites/upwork-com/index.js.map +1 -0
  244. package/dist/sites/upwork-com/upwork-com.actor.d.ts +6 -0
  245. package/dist/sites/upwork-com/upwork-com.actor.d.ts.map +1 -0
  246. package/dist/sites/upwork-com/upwork-com.actor.js +82 -0
  247. package/dist/sites/upwork-com/upwork-com.actor.js.map +1 -0
  248. package/dist/sites/upwork-com/upwork-com.runner.d.ts +2 -0
  249. package/dist/sites/upwork-com/upwork-com.runner.d.ts.map +1 -0
  250. package/dist/sites/upwork-com/upwork-com.runner.js +14 -0
  251. package/dist/sites/upwork-com/upwork-com.runner.js.map +1 -0
  252. package/dist/sites/upwork-com/upwork-com.selectors.d.ts +11 -0
  253. package/dist/sites/upwork-com/upwork-com.selectors.d.ts.map +1 -0
  254. package/dist/sites/upwork-com/upwork-com.selectors.js +11 -0
  255. package/dist/sites/upwork-com/upwork-com.selectors.js.map +1 -0
  256. package/dist/sites/upwork-com/upwork-com.types.d.ts +88 -0
  257. package/dist/sites/upwork-com/upwork-com.types.d.ts.map +1 -0
  258. package/dist/sites/upwork-com/upwork-com.types.js +63 -0
  259. package/dist/sites/upwork-com/upwork-com.types.js.map +1 -0
  260. package/dist/sites/upwork-com/upwork-com.util.d.ts +4 -0
  261. package/dist/sites/upwork-com/upwork-com.util.d.ts.map +1 -0
  262. package/dist/sites/upwork-com/upwork-com.util.js +43 -0
  263. package/dist/sites/upwork-com/upwork-com.util.js.map +1 -0
  264. package/dist/utils/delay.d.ts +2 -0
  265. package/dist/utils/delay.d.ts.map +1 -0
  266. package/dist/utils/delay.js +6 -0
  267. package/dist/utils/delay.js.map +1 -0
  268. package/dist/utils/index.d.ts +6 -0
  269. package/dist/utils/index.d.ts.map +1 -0
  270. package/dist/utils/index.js +6 -0
  271. package/dist/utils/index.js.map +1 -0
  272. package/dist/utils/invariant.d.ts +2 -0
  273. package/dist/utils/invariant.d.ts.map +1 -0
  274. package/dist/utils/invariant.js +7 -0
  275. package/dist/utils/invariant.js.map +1 -0
  276. package/dist/utils/redact.d.ts +6 -0
  277. package/dist/utils/redact.d.ts.map +1 -0
  278. package/dist/utils/redact.js +40 -0
  279. package/dist/utils/redact.js.map +1 -0
  280. package/dist/utils/retry.d.ts +8 -0
  281. package/dist/utils/retry.d.ts.map +1 -0
  282. package/dist/utils/retry.js +23 -0
  283. package/dist/utils/retry.js.map +1 -0
  284. package/dist/utils/url.d.ts +2 -0
  285. package/dist/utils/url.d.ts.map +1 -0
  286. package/dist/utils/url.js +9 -0
  287. package/dist/utils/url.js.map +1 -0
  288. package/package.json +39 -0
  289. package/src/auth/AuthStateDetector.ts +18 -0
  290. package/src/auth/CredentialsProvider.ts +48 -0
  291. package/src/auth/LoginFlow.ts +332 -0
  292. package/src/auth/LoginFlow.types.ts +141 -0
  293. package/src/auth/SessionStore.ts +21 -0
  294. package/src/auth/index.ts +5 -0
  295. package/src/browser/BrowserFactory.ts +253 -0
  296. package/src/browser/BrowserSession.ts +50 -0
  297. package/src/browser/PuppeteerLike.ts +65 -0
  298. package/src/browser/RuntimeConfig.ts +152 -0
  299. package/src/browser/index.ts +5 -0
  300. package/src/browser/profileValidation.ts +73 -0
  301. package/src/cli/run.ts +112 -0
  302. package/src/core/Actor.ts +167 -0
  303. package/src/core/ActorContext.ts +34 -0
  304. package/src/core/ActorRegistry.ts +26 -0
  305. package/src/core/ActorRunner.ts +240 -0
  306. package/src/core/defineActor.ts +5 -0
  307. package/src/core/index.ts +5 -0
  308. package/src/errors/AuthError.ts +7 -0
  309. package/src/errors/AutomationError.ts +26 -0
  310. package/src/errors/ConfigError.ts +7 -0
  311. package/src/errors/ExtractionError.ts +7 -0
  312. package/src/errors/NavigationError.ts +7 -0
  313. package/src/errors/SelectorError.ts +10 -0
  314. package/src/errors/index.ts +6 -0
  315. package/src/extraction/Extractor.ts +65 -0
  316. package/src/extraction/Pagination.ts +47 -0
  317. package/src/extraction/index.ts +2 -0
  318. package/src/index.ts +9 -0
  319. package/src/interaction/FieldClearer.ts +73 -0
  320. package/src/interaction/Forms.ts +27 -0
  321. package/src/interaction/GhostCursorAdapter.ts +79 -0
  322. package/src/interaction/HumanInteractor.ts +32 -0
  323. package/src/interaction/HumanTyping.ts +157 -0
  324. package/src/interaction/NativePuppeteerInteractor.ts +68 -0
  325. package/src/interaction/Navigation.ts +37 -0
  326. package/src/interaction/PageAdapter.ts +86 -0
  327. package/src/interaction/Waits.ts +5 -0
  328. package/src/interaction/index.ts +9 -0
  329. package/src/logging/ConsoleLogger.ts +44 -0
  330. package/src/logging/Logger.ts +15 -0
  331. package/src/logging/MemoryLogger.ts +34 -0
  332. package/src/logging/NullLogger.ts +8 -0
  333. package/src/logging/index.ts +4 -0
  334. package/src/sites/example/example.actor.ts +53 -0
  335. package/src/sites/example/example.selectors.ts +17 -0
  336. package/src/sites/example/example.types.ts +18 -0
  337. package/src/sites/example/index.ts +3 -0
  338. package/src/sites/index.ts +3 -0
  339. package/src/sites/myvistage-com/index.ts +3 -0
  340. package/src/sites/myvistage-com/login-action-list.json +349 -0
  341. package/src/sites/myvistage-com/myvistage-com.actor.ts +50 -0
  342. package/src/sites/myvistage-com/myvistage-com.selectors.ts +14 -0
  343. package/src/sites/myvistage-com/myvistage-com.types.ts +18 -0
  344. package/src/sites/myvistage-com/post-comment-action.json +81 -0
  345. package/src/sites/upwork-com/index.ts +6 -0
  346. package/src/sites/upwork-com/upwork-com.actor.ts +97 -0
  347. package/src/sites/upwork-com/upwork-com.runner.ts +17 -0
  348. package/src/sites/upwork-com/upwork-com.selectors.ts +10 -0
  349. package/src/sites/upwork-com/upwork-com.types.ts +102 -0
  350. package/src/sites/upwork-com/upwork-com.util.ts +41 -0
  351. package/src/utils/delay.ts +4 -0
  352. package/src/utils/index.ts +5 -0
  353. package/src/utils/invariant.ts +7 -0
  354. package/src/utils/redact.ts +53 -0
  355. package/src/utils/retry.ts +31 -0
  356. package/src/utils/url.ts +7 -0
  357. package/tests/fixtures/FakeCredentialsProvider.ts +12 -0
  358. package/tests/fixtures/FakeCursor.ts +48 -0
  359. package/tests/fixtures/FakePage.ts +266 -0
  360. package/tests/fixtures/makeContext.ts +76 -0
  361. package/tests/unit/auth/AuthStateDetector.test.ts +80 -0
  362. package/tests/unit/auth/LoginFlow.test.ts +296 -0
  363. package/tests/unit/browser/BrowserFactory.test.ts +370 -0
  364. package/tests/unit/core/ActorRunner.test.ts +370 -0
  365. package/tests/unit/core/defineActor.test.ts +112 -0
  366. package/tests/unit/extraction/Extractor.test.ts +48 -0
  367. package/tests/unit/extraction/Pagination.test.ts +54 -0
  368. package/tests/unit/interaction/FieldClearer.test.ts +29 -0
  369. package/tests/unit/interaction/Forms.test.ts +35 -0
  370. package/tests/unit/interaction/GhostCursorAdapter.test.ts +68 -0
  371. package/tests/unit/interaction/HumanTyping.test.ts +54 -0
  372. package/tests/unit/interaction/NativePuppeteerInteractor.test.ts +22 -0
  373. package/tests/unit/interaction/PageAdapter.test.ts +25 -0
  374. package/tests/unit/logging/redact.test.ts +36 -0
  375. package/tests/unit/sites/myvistage-com.actor.test.ts +19 -0
  376. package/tests/unit/sites/myvistage-com.login.test.ts +22 -0
  377. package/tests/unit/sites/myvistage-com.postComment.test.ts +70 -0
  378. package/tests/unit/sites/upwork-com.login.test.ts +52 -0
  379. package/tsconfig.build.json +9 -0
  380. package/tsconfig.json +22 -0
  381. package/vitest.config.ts +12 -0
@@ -0,0 +1,68 @@
1
+ import { describe, expect, it } from 'vitest';
2
+ import { GhostCursorAdapter } from '../../../src/interaction/GhostCursorAdapter.js';
3
+ import { FakeGhostCursor } from '../../fixtures/FakeCursor.js';
4
+ import { FakePage } from '../../fixtures/FakePage.js';
5
+
6
+ describe('GhostCursorAdapter', () => {
7
+ it('delegates clicks to ghost-cursor after waiting for the selector', async () => {
8
+ const page = new FakePage().setSelector('#button');
9
+ const cursor = new FakeGhostCursor();
10
+ const adapter = new GhostCursorAdapter(page, { cursor });
11
+
12
+ await adapter.click('#button', { cursorOptions: { waitForClick: 100 } });
13
+
14
+ expect(page.waitedSelectors[0]?.selector).toBe('#button');
15
+ expect(cursor.clicks).toEqual([{ selector: '#button', options: { waitForClick: 100 } }]);
16
+ });
17
+
18
+ it('delegates moves to ghost-cursor', async () => {
19
+ const page = new FakePage().setSelector('#target');
20
+ const cursor = new FakeGhostCursor();
21
+ const adapter = new GhostCursorAdapter(page, { cursor });
22
+
23
+ await adapter.move('#target', { cursorOptions: { moveSpeed: 700 } });
24
+
25
+ expect(cursor.moves).toEqual([{ selector: '#target', options: { moveSpeed: 700 } }]);
26
+ });
27
+
28
+ it('types by clicking, selecting/deleting existing content, then sending keys one by one', async () => {
29
+ const page = new FakePage().setSelector('#email', { value: 'old' });
30
+ const cursor = new FakeGhostCursor();
31
+ const sleeps: number[] = [];
32
+ const adapter = new GhostCursorAdapter(page, {
33
+ cursor,
34
+ random: () => 0.5,
35
+ sleep: async ms => { sleeps.push(ms); },
36
+ typing: { intervalJitterMs: 0 }
37
+ });
38
+
39
+ await adapter.type('#email', 'new', { delayMs: 5 });
40
+
41
+ expect(cursor.clicks.map(click => click.selector)).toContain('#email');
42
+ expect(page.keyboard.pressed).toEqual([{ key: 'Backspace' }]);
43
+ expect(page.keyboard.typed).toEqual([
44
+ { text: 'n', options: { delay: 5 } },
45
+ { text: 'e', options: { delay: 5 } },
46
+ { text: 'w', options: { delay: 5 } }
47
+ ]);
48
+ expect(sleeps).toEqual([185, 185]);
49
+ });
50
+
51
+ it('can disable human typing and send the whole value at once', async () => {
52
+ const page = new FakePage().setSelector('#email', { value: 'old' });
53
+ const cursor = new FakeGhostCursor();
54
+ const adapter = new GhostCursorAdapter(page, { cursor });
55
+
56
+ await adapter.type('#email', 'new@example.com', { delayMs: 5, typing: { enabled: false } });
57
+
58
+ expect(page.keyboard.typed).toEqual([{ text: 'new@example.com', options: { delay: 5 } }]);
59
+ });
60
+
61
+ it('scrolls an element into view', async () => {
62
+ const page = new FakePage().setSelector('#item');
63
+ const cursor = new FakeGhostCursor();
64
+ const adapter = new GhostCursorAdapter(page, { cursor });
65
+
66
+ await expect(adapter.scrollIntoView('#item')).resolves.toBeUndefined();
67
+ });
68
+ });
@@ -0,0 +1,54 @@
1
+ import { describe, expect, it } from 'vitest';
2
+ import {
3
+ characterIntervalMsForWordsPerMinute,
4
+ HumanTyper,
5
+ jitteredIntervalMs,
6
+ normalizeHumanTypingOptions
7
+ } from '../../../src/interaction/HumanTyping.js';
8
+ import { FakeKeyboard } from '../../fixtures/FakePage.js';
9
+
10
+ describe('HumanTyper', () => {
11
+ it('computes the 65 WPM cadence using five-character words', () => {
12
+ expect(characterIntervalMsForWordsPerMinute(65, 5)).toBeCloseTo(184.615, 3);
13
+ });
14
+
15
+ it('types key-by-key and waits between characters at approximately 65 WPM', async () => {
16
+ const keyboard = new FakeKeyboard();
17
+ const sleeps: number[] = [];
18
+ const typer = new HumanTyper({
19
+ random: () => 0.5,
20
+ sleep: async ms => { sleeps.push(ms); }
21
+ });
22
+
23
+ await typer.type(keyboard, 'abcd', { intervalJitterMs: 0 });
24
+
25
+ expect(keyboard.typed.map(record => record.text)).toEqual(['a', 'b', 'c', 'd']);
26
+ expect(sleeps).toEqual([185, 185, 185]);
27
+ });
28
+
29
+ it('applies small symmetric jitter to the inter-key interval', () => {
30
+ const base = characterIntervalMsForWordsPerMinute(65, 5);
31
+
32
+ expect(jitteredIntervalMs(base, 18, 20, () => 0)).toBe(167);
33
+ expect(jitteredIntervalMs(base, 18, 20, () => 0.5)).toBe(185);
34
+ expect(jitteredIntervalMs(base, 18, 20, () => 1)).toBe(203);
35
+ });
36
+
37
+ it('can fall back to bulk Puppeteer typing when human typing is disabled', async () => {
38
+ const keyboard = new FakeKeyboard();
39
+ const sleeps: number[] = [];
40
+ const typer = new HumanTyper({
41
+ sleep: async ms => { sleeps.push(ms); }
42
+ });
43
+
44
+ await typer.type(keyboard, 'hello', { enabled: false }, 7);
45
+
46
+ expect(keyboard.typed).toEqual([{ text: 'hello', options: { delay: 7 } }]);
47
+ expect(sleeps).toEqual([]);
48
+ });
49
+
50
+ it('validates typing configuration', () => {
51
+ expect(() => normalizeHumanTypingOptions({ targetWordsPerMinute: 0 })).toThrow(RangeError);
52
+ expect(() => normalizeHumanTypingOptions({ intervalJitterMs: -1 })).toThrow(RangeError);
53
+ });
54
+ });
@@ -0,0 +1,22 @@
1
+ import { describe, expect, it } from 'vitest';
2
+ import { NativePuppeteerInteractor } from '../../../src/interaction/NativePuppeteerInteractor.js';
3
+ import { FakePage } from '../../fixtures/FakePage.js';
4
+
5
+ describe('NativePuppeteerInteractor', () => {
6
+ it('uses the same key-by-key typing and select-delete clear behavior without ghost-cursor', async () => {
7
+ const page = new FakePage().setSelector('#field', { value: 'old' });
8
+ const sleeps: number[] = [];
9
+ const interactor = new NativePuppeteerInteractor(page, {
10
+ random: () => 0.5,
11
+ sleep: async ms => { sleeps.push(ms); },
12
+ typing: { intervalJitterMs: 0 }
13
+ });
14
+
15
+ await interactor.type('#field', 'ok');
16
+
17
+ expect(page.clicked).toEqual(['#field']);
18
+ expect(page.keyboard.pressed).toEqual([{ key: 'Backspace' }]);
19
+ expect(page.keyboard.typed.map(record => record.text)).toEqual(['o', 'k']);
20
+ expect(sleeps).toEqual([185]);
21
+ });
22
+ });
@@ -0,0 +1,25 @@
1
+ import { describe, expect, it } from 'vitest';
2
+ import { PuppeteerPageAdapter } from '../../../src/interaction/PageAdapter.js';
3
+ import { FakePage } from '../../fixtures/FakePage.js';
4
+
5
+ describe('PuppeteerPageAdapter', () => {
6
+ it('normalizes text content', async () => {
7
+ const fakePage = new FakePage().setSelector('#title', { textContent: ' Hello\n World ' });
8
+ const page = new PuppeteerPageAdapter(fakePage);
9
+
10
+ await expect(page.text('#title')).resolves.toBe('Hello World');
11
+ });
12
+
13
+ it('returns false when exists times out', async () => {
14
+ const page = new PuppeteerPageAdapter(new FakePage());
15
+
16
+ await expect(page.exists('#missing')).resolves.toBe(false);
17
+ });
18
+
19
+ it('reads attributes', async () => {
20
+ const fakePage = new FakePage().setSelector('a', { attributes: { href: '/x' } });
21
+ const page = new PuppeteerPageAdapter(fakePage);
22
+
23
+ await expect(page.attr('a', 'href')).resolves.toBe('/x');
24
+ });
25
+ });
@@ -0,0 +1,36 @@
1
+ import { describe, expect, it } from 'vitest';
2
+ import { redact } from '../../../src/utils/redact.js';
3
+
4
+ describe('redact', () => {
5
+ it('redacts nested sensitive values without mutating the original object', () => {
6
+ const input = {
7
+ username: 'alice',
8
+ password: 'secret',
9
+ nested: {
10
+ authorization: 'Bearer token',
11
+ safe: 'value'
12
+ },
13
+ items: [
14
+ { sessionCookie: 'abc123' },
15
+ { name: 'visible' }
16
+ ]
17
+ };
18
+
19
+ const output = redact(input);
20
+
21
+ expect(output).toEqual({
22
+ username: 'alice',
23
+ password: '[REDACTED]',
24
+ nested: {
25
+ authorization: '[REDACTED]',
26
+ safe: 'value'
27
+ },
28
+ items: [
29
+ { sessionCookie: '[REDACTED]' },
30
+ { name: 'visible' }
31
+ ]
32
+ });
33
+ expect(input.password).toBe('secret');
34
+ expect(input.nested.authorization).toBe('Bearer token');
35
+ });
36
+ });
@@ -0,0 +1,19 @@
1
+ import { describe, expect, it } from 'vitest';
2
+ import { myvistageComActor } from '../../../src/sites/myvistage-com/myvistage-com.actor.js';
3
+
4
+ describe('myvistageComActor', () => {
5
+ it('has expected metadata', () => {
6
+ expect(myvistageComActor.id).toBe('myvistage-com');
7
+ expect(myvistageComActor.baseUrl).toBe('https://myvistage.com');
8
+ });
9
+
10
+ it('ping task returns ok with null echo by default', async () => {
11
+ const output = await myvistageComActor.tasks.ping({} as never, {});
12
+ expect(output).toEqual({ ok: true, echo: null });
13
+ });
14
+
15
+ it('ping task echoes provided message', async () => {
16
+ const output = await myvistageComActor.tasks.ping({} as never, { message: 'hello' });
17
+ expect(output).toEqual({ ok: true, echo: 'hello' });
18
+ });
19
+ });
@@ -0,0 +1,22 @@
1
+ import { describe, expect, it } from 'vitest';
2
+ import { myvistageComActor } from '../../../src/sites/myvistage-com/myvistage-com.actor.js';
3
+ import { myvistageComSelectors } from '../../../src/sites/myvistage-com/myvistage-com.selectors.js';
4
+
5
+ describe('myvistage-com actor login flow', () => {
6
+ it('uses a one-page username/password login definition', () => {
7
+ const auth = myvistageComActor.auth;
8
+
9
+ expect(auth).toBeDefined();
10
+ expect(auth?.loginUrl).toBe('https://myvistage.com');
11
+ expect(auth?.credentials).toEqual({ id: 'myvistage-com' });
12
+ expect(auth?.selectors).toEqual(myvistageComSelectors.login);
13
+ expect(auth?.steps).toBeUndefined();
14
+ });
15
+
16
+ it('keeps human-like typing behavior configured at the flow level', () => {
17
+ expect(myvistageComActor.auth?.behavior?.typing).toEqual({
18
+ targetWordsPerMinute: 65,
19
+ intervalJitterMs: 18
20
+ });
21
+ });
22
+ });
@@ -0,0 +1,70 @@
1
+ import { describe, expect, it } from 'vitest';
2
+ import { myvistageComActor } from '../../../src/sites/myvistage-com/myvistage-com.actor.js';
3
+ import { myvistageComSelectors } from '../../../src/sites/myvistage-com/myvistage-com.selectors.js';
4
+ import { makeContext } from '../../fixtures/makeContext.js';
5
+
6
+ describe('myvistage-com actor postComment task', () => {
7
+ it('fills fields in order, submits the form, and returns completion output', async () => {
8
+ const { context, fakePage, fakeInteractor } = makeContext({
9
+ actorId: 'myvistage-com',
10
+ baseUrl: 'https://myvistage.com'
11
+ });
12
+
13
+ fakePage
14
+ .setSelector(myvistageComSelectors.postComment.comment)
15
+ .setSelector(myvistageComSelectors.postComment.subject)
16
+ .setSelector(myvistageComSelectors.postComment.submit);
17
+
18
+ const result = await myvistageComActor.tasks.postComment(context, {
19
+ comment: 'Great insights, thank you for sharing.',
20
+ subject: 'Quick follow-up'
21
+ });
22
+
23
+ expect(fakePage.gotos[0]?.url).toBe('https://myvistage.com/?status/151341-151341-1779377493/');
24
+ expect(fakeInteractor.typed).toEqual([
25
+ {
26
+ selector: myvistageComSelectors.postComment.comment,
27
+ value: 'Great insights, thank you for sharing.',
28
+ options: { required: true }
29
+ },
30
+ {
31
+ selector: myvistageComSelectors.postComment.subject,
32
+ value: 'Quick follow-up',
33
+ options: { required: false }
34
+ }
35
+ ]);
36
+ expect(fakeInteractor.clicks).toEqual([{ selector: myvistageComSelectors.postComment.submit }]);
37
+ expect(result).toEqual({
38
+ submittedComment: 'Great insights, thank you for sharing.',
39
+ submittedSubject: 'Quick follow-up'
40
+ });
41
+ });
42
+
43
+ it('skips optional fields when not provided and still submits', async () => {
44
+ const { context, fakePage, fakeInteractor } = makeContext({
45
+ actorId: 'myvistage-com',
46
+ baseUrl: 'https://myvistage.com'
47
+ });
48
+
49
+ fakePage
50
+ .setSelector(myvistageComSelectors.postComment.comment)
51
+ .setSelector(myvistageComSelectors.postComment.submit);
52
+
53
+ const result = await myvistageComActor.tasks.postComment(context, {
54
+ comment: 'Posting without a subject.'
55
+ });
56
+
57
+ expect(fakeInteractor.typed).toEqual([
58
+ {
59
+ selector: myvistageComSelectors.postComment.comment,
60
+ value: 'Posting without a subject.',
61
+ options: { required: true }
62
+ }
63
+ ]);
64
+ expect(fakeInteractor.clicks).toEqual([{ selector: myvistageComSelectors.postComment.submit }]);
65
+ expect(result).toEqual({
66
+ submittedComment: 'Posting without a subject.',
67
+ submittedSubject: null
68
+ });
69
+ });
70
+ });
@@ -0,0 +1,52 @@
1
+ import { describe, expect, it } from 'vitest';
2
+ import { upworkComActor } from '../../../src/sites/upwork-com/upwork-com.actor.js';
3
+ import { upworkComSelectors } from '../../../src/sites/upwork-com/upwork-com.selectors.js';
4
+
5
+ describe('upwork-com actor login flow', () => {
6
+ it('uses a staged username-first/password-second login definition', () => {
7
+ const auth = upworkComActor.auth;
8
+
9
+ expect(auth).toBeDefined();
10
+ expect(auth?.loginUrl).toBe('https://www.upwork.com/ab/account-security/login');
11
+ expect(auth?.credentials).toEqual({ id: 'upwork' });
12
+ expect(auth?.selectors.loggedInSignal).toBe(upworkComSelectors.login.loggedInSignal);
13
+ expect(auth?.selectors.errorMessage).toBe(upworkComSelectors.login.errorMessage);
14
+
15
+ expect(auth?.steps).toEqual([
16
+ {
17
+ type: 'fill',
18
+ name: 'username',
19
+ selector: upworkComSelectors.login.username,
20
+ credential: 'username'
21
+ },
22
+ {
23
+ type: 'click',
24
+ name: 'continue to password',
25
+ selector: upworkComSelectors.login.continueToPassword,
26
+ waitForSelector: upworkComSelectors.login.password,
27
+ waitForSelectorTimeoutMs: 5_000
28
+ },
29
+ {
30
+ type: 'fill',
31
+ name: 'password',
32
+ selector: upworkComSelectors.login.password,
33
+ credential: 'password'
34
+ },
35
+ {
36
+ type: 'click',
37
+ name: 'submit password',
38
+ selector: upworkComSelectors.login.submit,
39
+ submit: true,
40
+ waitForNavigation: true,
41
+ checkForError: false
42
+ }
43
+ ]);
44
+ });
45
+
46
+ it('keeps human-like typing behavior configured at the flow level', () => {
47
+ expect(upworkComActor.auth?.behavior?.typing).toEqual({
48
+ targetWordsPerMinute: 65,
49
+ intervalJitterMs: 18
50
+ });
51
+ });
52
+ });
@@ -0,0 +1,9 @@
1
+ {
2
+ "extends": "./tsconfig.json",
3
+ "compilerOptions": {
4
+ "rootDir": "src",
5
+ "outDir": "dist"
6
+ },
7
+ "include": ["src/**/*.ts"],
8
+ "exclude": ["tests", "dist", "node_modules", "vitest.config.ts"]
9
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,22 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "module": "NodeNext",
5
+ "moduleResolution": "NodeNext",
6
+ "lib": ["ES2022", "DOM"],
7
+ "strict": true,
8
+ "noUncheckedIndexedAccess": true,
9
+ "exactOptionalPropertyTypes": true,
10
+ "esModuleInterop": true,
11
+ "forceConsistentCasingInFileNames": true,
12
+ "skipLibCheck": true,
13
+ "declaration": true,
14
+ "declarationMap": true,
15
+ "sourceMap": true,
16
+ "outDir": "dist",
17
+ "rootDir": ".",
18
+ "types": ["node", "vitest/globals"]
19
+ },
20
+ "include": ["src/**/*.ts", "tests/**/*.ts", "vitest.config.ts"],
21
+ "exclude": ["dist", "node_modules"]
22
+ }
@@ -0,0 +1,12 @@
1
+ import { defineConfig } from 'vitest/config';
2
+
3
+ export default defineConfig({
4
+ test: {
5
+ environment: 'node',
6
+ globals: true,
7
+ include: ['tests/**/*.test.ts'],
8
+ restoreMocks: true,
9
+ clearMocks: true,
10
+ mockReset: true
11
+ }
12
+ });