@amalgm/browser 0.1.2-preview.35541635545 → 0.1.2-preview.37254096068

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 (390) hide show
  1. package/PURPOSE.md +119 -97
  2. package/README.md +51 -56
  3. package/SECURITY.md +10 -8
  4. package/dist/bin/amalgm-browser-mcp.js +2 -3
  5. package/dist/bin/amalgm-browser-mcp.js.map +1 -1
  6. package/dist/bin/amalgm-browser-rest.js +8 -18
  7. package/dist/bin/amalgm-browser-rest.js.map +1 -1
  8. package/dist/src/account.d.ts +8 -0
  9. package/dist/src/account.js +42 -0
  10. package/dist/src/account.js.map +1 -0
  11. package/dist/src/action.d.ts +1 -2
  12. package/dist/src/action.js +3 -7
  13. package/dist/src/action.js.map +1 -1
  14. package/dist/src/adapters/cli/actions.d.ts +0 -1
  15. package/dist/src/adapters/cli/actions.js +0 -7
  16. package/dist/src/adapters/cli/actions.js.map +1 -1
  17. package/dist/src/adapters/cli/help.d.ts +1 -1
  18. package/dist/src/adapters/cli/help.js +1 -4
  19. package/dist/src/adapters/cli/help.js.map +1 -1
  20. package/dist/src/adapters/cli/resources.js +0 -22
  21. package/dist/src/adapters/cli/resources.js.map +1 -1
  22. package/dist/src/adapters/cli/run.js +25 -19
  23. package/dist/src/adapters/cli/run.js.map +1 -1
  24. package/dist/src/adapters/execute.js +2 -2
  25. package/dist/src/adapters/execute.js.map +1 -1
  26. package/dist/src/adapters/http/events.d.ts +5 -2
  27. package/dist/src/adapters/http/events.js +18 -2
  28. package/dist/src/adapters/http/events.js.map +1 -1
  29. package/dist/src/adapters/http/internal-routes.js +9 -4
  30. package/dist/src/adapters/http/internal-routes.js.map +1 -1
  31. package/dist/src/adapters/http/navigation-stream.d.ts +4 -0
  32. package/dist/src/adapters/http/navigation-stream.js +17 -0
  33. package/dist/src/adapters/http/navigation-stream.js.map +1 -0
  34. package/dist/src/adapters/http/openapi.js +2 -8
  35. package/dist/src/adapters/http/openapi.js.map +1 -1
  36. package/dist/src/adapters/http/server.js +54 -14
  37. package/dist/src/adapters/http/server.js.map +1 -1
  38. package/dist/src/adapters/http/session-routes.js +0 -1
  39. package/dist/src/adapters/http/session-routes.js.map +1 -1
  40. package/dist/src/adapters/http/stream.d.ts +6 -0
  41. package/dist/src/adapters/http/stream.js +89 -0
  42. package/dist/src/adapters/http/stream.js.map +1 -0
  43. package/dist/src/adapters/mcp/server.js +2 -2
  44. package/dist/src/adapters/mcp/server.js.map +1 -1
  45. package/dist/src/adapters/mcp/tools.js +2 -4
  46. package/dist/src/adapters/mcp/tools.js.map +1 -1
  47. package/dist/src/adapters/mcp/types.d.ts +3 -2
  48. package/dist/src/adapters/toolbox/manifest.js +1 -1
  49. package/dist/src/adapters/toolbox/manifest.js.map +1 -1
  50. package/dist/src/auth/login.d.ts +3 -1
  51. package/dist/src/auth/login.js +48 -33
  52. package/dist/src/auth/login.js.map +1 -1
  53. package/dist/src/auth/service.js +56 -67
  54. package/dist/src/auth/service.js.map +1 -1
  55. package/dist/src/{drivers/cdp → cdp}/capture.d.ts +1 -1
  56. package/dist/src/{drivers/cdp → cdp}/capture.js +1 -1
  57. package/dist/src/cdp/capture.js.map +1 -0
  58. package/dist/src/{drivers/cdp → cdp}/client.d.ts +3 -1
  59. package/dist/src/{drivers/cdp → cdp}/client.js +51 -14
  60. package/dist/src/cdp/client.js.map +1 -0
  61. package/dist/src/cdp/input.js.map +1 -0
  62. package/dist/src/cdp/navigation.d.ts +5 -0
  63. package/dist/src/cdp/navigation.js +47 -0
  64. package/dist/src/cdp/navigation.js.map +1 -0
  65. package/dist/src/{drivers/cdp → cdp}/screencast.js +1 -1
  66. package/dist/src/cdp/screencast.js.map +1 -0
  67. package/dist/src/chrome/cookie-adapter.d.ts +23 -0
  68. package/dist/src/chrome/cookie-adapter.js +74 -0
  69. package/dist/src/chrome/cookie-adapter.js.map +1 -0
  70. package/dist/src/chrome/cookie-changes.d.ts +12 -0
  71. package/dist/src/chrome/cookie-changes.js +100 -0
  72. package/dist/src/chrome/cookie-changes.js.map +1 -0
  73. package/dist/src/chrome/cookie-observer.d.ts +20 -0
  74. package/dist/src/chrome/cookie-observer.js +44 -0
  75. package/dist/src/chrome/cookie-observer.js.map +1 -0
  76. package/dist/src/chrome/executable.d.ts +1 -0
  77. package/dist/src/chrome/executable.js +55 -0
  78. package/dist/src/chrome/executable.js.map +1 -0
  79. package/dist/src/chrome/flags.d.ts +7 -0
  80. package/dist/src/chrome/flags.js +59 -0
  81. package/dist/src/chrome/flags.js.map +1 -0
  82. package/dist/src/chrome/host.d.ts +25 -0
  83. package/dist/src/chrome/host.js +137 -0
  84. package/dist/src/chrome/host.js.map +1 -0
  85. package/dist/src/chrome/launch.d.ts +11 -0
  86. package/dist/src/chrome/launch.js +105 -0
  87. package/dist/src/chrome/launch.js.map +1 -0
  88. package/dist/src/chrome/relay/editing.d.ts +2 -0
  89. package/dist/src/chrome/relay/editing.js +14 -0
  90. package/dist/src/chrome/relay/editing.js.map +1 -0
  91. package/dist/src/chrome/relay/server.d.ts +18 -0
  92. package/dist/src/chrome/relay/server.js +120 -0
  93. package/dist/src/chrome/relay/server.js.map +1 -0
  94. package/dist/src/chrome/relay/targets.d.ts +11 -0
  95. package/dist/src/chrome/relay/targets.js +59 -0
  96. package/dist/src/chrome/relay/targets.js.map +1 -0
  97. package/dist/src/chrome/relay/view.d.ts +34 -0
  98. package/dist/src/chrome/relay/view.js +185 -0
  99. package/dist/src/chrome/relay/view.js.map +1 -0
  100. package/dist/src/cookies/adapter-credential.d.ts +6 -0
  101. package/dist/src/cookies/adapter-credential.js +33 -0
  102. package/dist/src/cookies/adapter-credential.js.map +1 -0
  103. package/dist/src/cookies/coordinator.d.ts +14 -13
  104. package/dist/src/cookies/coordinator.js +157 -75
  105. package/dist/src/cookies/coordinator.js.map +1 -1
  106. package/dist/src/cookies/database.d.ts +29 -0
  107. package/dist/src/cookies/database.js +113 -0
  108. package/dist/src/cookies/database.js.map +1 -0
  109. package/dist/src/cookies/diff.d.ts +6 -0
  110. package/dist/src/cookies/diff.js +19 -0
  111. package/dist/src/cookies/diff.js.map +1 -0
  112. package/dist/src/cookies/http-store.d.ts +7 -0
  113. package/dist/src/cookies/http-store.js +105 -0
  114. package/dist/src/cookies/http-store.js.map +1 -0
  115. package/dist/src/cookies/jar.d.ts +12 -11
  116. package/dist/src/cookies/jar.js +128 -120
  117. package/dist/src/cookies/jar.js.map +1 -1
  118. package/dist/src/cookies/policy.js +10 -4
  119. package/dist/src/cookies/policy.js.map +1 -1
  120. package/dist/src/cookies/secret-file.d.ts +4 -0
  121. package/dist/src/cookies/secret-file.js +47 -9
  122. package/dist/src/cookies/secret-file.js.map +1 -1
  123. package/dist/src/cookies/types.d.ts +34 -2
  124. package/dist/src/cookies.d.ts +2 -0
  125. package/dist/src/cookies.js +2 -0
  126. package/dist/src/cookies.js.map +1 -1
  127. package/dist/src/defaults.d.ts +1 -5
  128. package/dist/src/defaults.js +49 -58
  129. package/dist/src/defaults.js.map +1 -1
  130. package/dist/src/driver/cli-policy.d.ts +1 -0
  131. package/dist/src/driver/cli-policy.js +17 -0
  132. package/dist/src/driver/cli-policy.js.map +1 -0
  133. package/dist/src/{drivers/headless → driver}/command.d.ts +3 -7
  134. package/dist/src/{drivers/headless → driver}/command.js +29 -29
  135. package/dist/src/driver/command.js.map +1 -0
  136. package/dist/src/{drivers/headless → driver}/driver.d.ts +13 -10
  137. package/dist/src/{drivers/headless → driver}/driver.js +67 -82
  138. package/dist/src/driver/driver.js.map +1 -0
  139. package/dist/src/{interaction/delta.d.ts → driver/evidence.d.ts} +3 -2
  140. package/dist/src/{interaction/delta.js → driver/evidence.js} +6 -3
  141. package/dist/src/driver/evidence.js.map +1 -0
  142. package/dist/src/driver/executable.js.map +1 -0
  143. package/dist/src/driver/stream.d.ts +1 -0
  144. package/dist/src/driver/stream.js +22 -0
  145. package/dist/src/driver/stream.js.map +1 -0
  146. package/dist/src/driver/wait.d.ts +6 -0
  147. package/dist/src/driver/wait.js +28 -0
  148. package/dist/src/driver/wait.js.map +1 -0
  149. package/dist/src/electron/adblock/cache.js.map +1 -0
  150. package/dist/src/electron/adblock/cosmetics.js.map +1 -0
  151. package/dist/src/{drivers/electron/native → electron}/adblock/index.d.ts +0 -1
  152. package/dist/src/{drivers/electron/native → electron}/adblock/index.js +0 -1
  153. package/dist/src/{drivers/electron/native → electron}/adblock/index.js.map +1 -1
  154. package/dist/src/electron/adblock/policy.js.map +1 -0
  155. package/dist/src/electron/adblock/preload.js.map +1 -0
  156. package/dist/src/electron/adblock/settings.js.map +1 -0
  157. package/dist/src/{drivers/electron/native → electron}/contracts.d.ts +0 -14
  158. package/dist/src/{drivers/electron/native → electron}/contracts.js +0 -1
  159. package/dist/src/electron/contracts.js.map +1 -0
  160. package/dist/src/{drivers/electron → electron}/cookie-adapter.d.ts +4 -4
  161. package/dist/src/{drivers/electron → electron}/cookie-adapter.js +9 -6
  162. package/dist/src/electron/cookie-adapter.js.map +1 -0
  163. package/dist/src/electron/cookie-sync.d.ts +6 -0
  164. package/dist/src/electron/cookie-sync.js +18 -0
  165. package/dist/src/electron/cookie-sync.js.map +1 -0
  166. package/dist/src/electron/policy.js.map +1 -0
  167. package/dist/src/electron/session.d.ts +2 -0
  168. package/dist/src/electron/session.js +9 -0
  169. package/dist/src/electron/session.js.map +1 -0
  170. package/dist/src/electron/shell/adblock-ipc.js.map +1 -0
  171. package/dist/src/electron/shell/context-menu.js.map +1 -0
  172. package/dist/src/electron/shell/downloads.js.map +1 -0
  173. package/dist/src/electron/shell/helpers.js.map +1 -0
  174. package/dist/src/electron/shell/permissions.js.map +1 -0
  175. package/dist/src/{drivers/electron/native → electron}/shell/sites.d.ts +1 -3
  176. package/dist/src/{drivers/electron/native → electron}/shell/sites.js +2 -34
  177. package/dist/src/electron/shell/sites.js.map +1 -0
  178. package/dist/src/{drivers/electron/native → electron}/shell/types.d.ts +0 -1
  179. package/dist/src/electron/shell/types.js.map +1 -0
  180. package/dist/src/electron/shell.d.ts +13 -0
  181. package/dist/src/electron/shell.js +73 -0
  182. package/dist/src/electron/shell.js.map +1 -0
  183. package/dist/src/electron/surface/commands.js.map +1 -0
  184. package/dist/src/{drivers/electron/native → electron}/surface/create.js +0 -6
  185. package/dist/src/electron/surface/create.js.map +1 -0
  186. package/dist/src/{drivers/electron/native → electron}/surface/events.js +1 -13
  187. package/dist/src/electron/surface/events.js.map +1 -0
  188. package/dist/src/{drivers/electron/native → electron}/surface/presentation.d.ts +2 -9
  189. package/dist/src/electron/surface/presentation.js +29 -0
  190. package/dist/src/electron/surface/presentation.js.map +1 -0
  191. package/dist/src/{drivers/electron/native → electron}/surface/state.d.ts +5 -0
  192. package/dist/src/{drivers/electron/native → electron}/surface/state.js +10 -4
  193. package/dist/src/electron/surface/state.js.map +1 -0
  194. package/dist/src/{drivers/electron/native → electron}/surface/types.d.ts +2 -8
  195. package/dist/src/electron/surface/types.js.map +1 -0
  196. package/dist/src/{drivers/electron/native → electron}/surface-controller.js +9 -12
  197. package/dist/src/electron/surface-controller.js.map +1 -0
  198. package/dist/src/electron-preload.cjs +1 -1
  199. package/dist/src/electron.cjs +587 -820
  200. package/dist/src/electron.d.cts +4 -14
  201. package/dist/src/electron.d.ts +4 -14
  202. package/dist/src/electron.js +4 -14
  203. package/dist/src/electron.js.map +1 -1
  204. package/dist/src/errors.d.ts +1 -1
  205. package/dist/src/errors.js.map +1 -1
  206. package/dist/src/index.d.ts +2 -3
  207. package/dist/src/index.js +0 -2
  208. package/dist/src/index.js.map +1 -1
  209. package/dist/src/migration/legacy-migration.d.ts +0 -1
  210. package/dist/src/migration/legacy-migration.js +3 -9
  211. package/dist/src/migration/legacy-migration.js.map +1 -1
  212. package/dist/src/migration/legacy-rows.d.ts +1 -2
  213. package/dist/src/migration/legacy-rows.js +0 -14
  214. package/dist/src/migration/legacy-rows.js.map +1 -1
  215. package/dist/src/ports.d.ts +12 -15
  216. package/dist/src/ports.js.map +1 -1
  217. package/dist/src/process.d.ts +1 -0
  218. package/dist/src/process.js +11 -0
  219. package/dist/src/process.js.map +1 -1
  220. package/dist/src/product-service.d.ts +4 -6
  221. package/dist/src/product-service.js +21 -15
  222. package/dist/src/product-service.js.map +1 -1
  223. package/dist/src/recording/encoder.js +1 -1
  224. package/dist/src/recording/encoder.js.map +1 -1
  225. package/dist/src/recording/service.d.ts +4 -0
  226. package/dist/src/recording/service.js +72 -62
  227. package/dist/src/recording/service.js.map +1 -1
  228. package/dist/src/recording/source.js +1 -1
  229. package/dist/src/recording/source.js.map +1 -1
  230. package/dist/src/registry.d.ts +4 -0
  231. package/dist/src/registry.js +17 -0
  232. package/dist/src/registry.js.map +1 -1
  233. package/dist/src/service-options.d.ts +5 -7
  234. package/dist/src/service.d.ts +16 -18
  235. package/dist/src/service.js +108 -108
  236. package/dist/src/service.js.map +1 -1
  237. package/dist/src/sessions/operations.d.ts +12 -0
  238. package/dist/src/sessions/operations.js +56 -0
  239. package/dist/src/sessions/operations.js.map +1 -0
  240. package/dist/src/testing.d.ts +8 -4
  241. package/dist/src/testing.js +7 -5
  242. package/dist/src/testing.js.map +1 -1
  243. package/dist/src/types.d.ts +0 -39
  244. package/docs/ACTIONS.md +0 -4
  245. package/docs/ARCHITECTURE.md +51 -55
  246. package/docs/AUTHENTICATION.md +41 -36
  247. package/docs/AXIOMS.md +13 -11
  248. package/docs/CHROME.md +143 -0
  249. package/docs/CLI.md +63 -31
  250. package/docs/COMPATIBILITY.md +14 -23
  251. package/docs/COOKIES.md +95 -52
  252. package/docs/ELECTRON_INTEGRATION.md +84 -77
  253. package/docs/EVENTS.md +5 -9
  254. package/docs/MCP.md +10 -6
  255. package/docs/MIGRATION.md +43 -36
  256. package/docs/OPERATIONS.md +48 -40
  257. package/docs/README.md +5 -5
  258. package/docs/REALTIME_BOUNDARY.md +3 -3
  259. package/docs/RECORDING.md +16 -15
  260. package/docs/REST.md +57 -26
  261. package/docs/SDK.md +65 -55
  262. package/docs/SHELL_INTEGRATION.md +78 -36
  263. package/docs/TESTING.md +58 -42
  264. package/docs/TOOLBOX_INTEGRATION.md +9 -4
  265. package/docs/TROUBLESHOOTING.md +68 -40
  266. package/examples/basic.ts +1 -0
  267. package/package.json +8 -15
  268. package/skills/use-amalgm-browser/SKILL.md +16 -29
  269. package/skills/use-amalgm-browser/references/actions.md +2 -2
  270. package/dist/src/adapters/http/profile-routes.d.ts +0 -2
  271. package/dist/src/adapters/http/profile-routes.js +0 -42
  272. package/dist/src/adapters/http/profile-routes.js.map +0 -1
  273. package/dist/src/auth/transport.d.ts +0 -8
  274. package/dist/src/auth/transport.js +0 -45
  275. package/dist/src/auth/transport.js.map +0 -1
  276. package/dist/src/drivers/cdp/capture.js.map +0 -1
  277. package/dist/src/drivers/cdp/client.js.map +0 -1
  278. package/dist/src/drivers/cdp/input.js.map +0 -1
  279. package/dist/src/drivers/cdp/screencast.js.map +0 -1
  280. package/dist/src/drivers/cdp/target.d.ts +0 -4
  281. package/dist/src/drivers/cdp/target.js +0 -34
  282. package/dist/src/drivers/cdp/target.js.map +0 -1
  283. package/dist/src/drivers/electron/advertisement.d.ts +0 -12
  284. package/dist/src/drivers/electron/advertisement.js +0 -57
  285. package/dist/src/drivers/electron/advertisement.js.map +0 -1
  286. package/dist/src/drivers/electron/contracts.d.ts +0 -45
  287. package/dist/src/drivers/electron/contracts.js +0 -10
  288. package/dist/src/drivers/electron/contracts.js.map +0 -1
  289. package/dist/src/drivers/electron/cookie-adapter.js.map +0 -1
  290. package/dist/src/drivers/electron/driver.d.ts +0 -19
  291. package/dist/src/drivers/electron/driver.js +0 -115
  292. package/dist/src/drivers/electron/driver.js.map +0 -1
  293. package/dist/src/drivers/electron/native/adblock/cache.js.map +0 -1
  294. package/dist/src/drivers/electron/native/adblock/cosmetics.js.map +0 -1
  295. package/dist/src/drivers/electron/native/adblock/policy.js.map +0 -1
  296. package/dist/src/drivers/electron/native/adblock/preload.js.map +0 -1
  297. package/dist/src/drivers/electron/native/adblock/settings.js.map +0 -1
  298. package/dist/src/drivers/electron/native/config.d.ts +0 -4
  299. package/dist/src/drivers/electron/native/config.js +0 -9
  300. package/dist/src/drivers/electron/native/config.js.map +0 -1
  301. package/dist/src/drivers/electron/native/contracts.js.map +0 -1
  302. package/dist/src/drivers/electron/native/policy.js.map +0 -1
  303. package/dist/src/drivers/electron/native/session.d.ts +0 -4
  304. package/dist/src/drivers/electron/native/session.js +0 -11
  305. package/dist/src/drivers/electron/native/session.js.map +0 -1
  306. package/dist/src/drivers/electron/native/shell/adblock-ipc.js.map +0 -1
  307. package/dist/src/drivers/electron/native/shell/context-menu.js.map +0 -1
  308. package/dist/src/drivers/electron/native/shell/downloads.js.map +0 -1
  309. package/dist/src/drivers/electron/native/shell/helpers.js.map +0 -1
  310. package/dist/src/drivers/electron/native/shell/permissions.js.map +0 -1
  311. package/dist/src/drivers/electron/native/shell/sites.js.map +0 -1
  312. package/dist/src/drivers/electron/native/shell/types.js.map +0 -1
  313. package/dist/src/drivers/electron/native/shell.d.ts +0 -14
  314. package/dist/src/drivers/electron/native/shell.js +0 -115
  315. package/dist/src/drivers/electron/native/shell.js.map +0 -1
  316. package/dist/src/drivers/electron/native/surface/commands.js.map +0 -1
  317. package/dist/src/drivers/electron/native/surface/create.js.map +0 -1
  318. package/dist/src/drivers/electron/native/surface/events.js.map +0 -1
  319. package/dist/src/drivers/electron/native/surface/presentation.js +0 -87
  320. package/dist/src/drivers/electron/native/surface/presentation.js.map +0 -1
  321. package/dist/src/drivers/electron/native/surface/state.js.map +0 -1
  322. package/dist/src/drivers/electron/native/surface/types.js.map +0 -1
  323. package/dist/src/drivers/electron/native/surface-controller.js.map +0 -1
  324. package/dist/src/drivers/electron/policy.d.ts +0 -4
  325. package/dist/src/drivers/electron/policy.js +0 -39
  326. package/dist/src/drivers/electron/policy.js.map +0 -1
  327. package/dist/src/drivers/electron/session.d.ts +0 -4
  328. package/dist/src/drivers/electron/session.js +0 -5
  329. package/dist/src/drivers/electron/session.js.map +0 -1
  330. package/dist/src/drivers/headless/command.js.map +0 -1
  331. package/dist/src/drivers/headless/cookie-adapter.d.ts +0 -16
  332. package/dist/src/drivers/headless/cookie-adapter.js +0 -59
  333. package/dist/src/drivers/headless/cookie-adapter.js.map +0 -1
  334. package/dist/src/drivers/headless/driver.js.map +0 -1
  335. package/dist/src/drivers/headless/executable.js.map +0 -1
  336. package/dist/src/drivers/headless/screencast.d.ts +0 -3
  337. package/dist/src/drivers/headless/screencast.js +0 -21
  338. package/dist/src/drivers/headless/screencast.js.map +0 -1
  339. package/dist/src/headless.d.ts +0 -3
  340. package/dist/src/headless.js +0 -4
  341. package/dist/src/headless.js.map +0 -1
  342. package/dist/src/interaction/delta.js.map +0 -1
  343. package/dist/src/interaction/typing.d.ts +0 -39
  344. package/dist/src/interaction/typing.js +0 -189
  345. package/dist/src/interaction/typing.js.map +0 -1
  346. package/dist/src/profiles/directories.d.ts +0 -9
  347. package/dist/src/profiles/directories.js +0 -57
  348. package/dist/src/profiles/directories.js.map +0 -1
  349. package/dist/src/profiles/service.d.ts +0 -30
  350. package/dist/src/profiles/service.js +0 -89
  351. package/dist/src/profiles/service.js.map +0 -1
  352. package/dist/src/runtime-selector.d.ts +0 -12
  353. package/dist/src/runtime-selector.js +0 -72
  354. package/dist/src/runtime-selector.js.map +0 -1
  355. package/docs/HEADLESS_RUNTIME.md +0 -58
  356. package/examples/custom-driver.ts +0 -45
  357. /package/dist/src/{drivers/cdp → cdp}/input.d.ts +0 -0
  358. /package/dist/src/{drivers/cdp → cdp}/input.js +0 -0
  359. /package/dist/src/{drivers/cdp → cdp}/screencast.d.ts +0 -0
  360. /package/dist/src/{drivers/headless → driver}/executable.d.ts +0 -0
  361. /package/dist/src/{drivers/headless → driver}/executable.js +0 -0
  362. /package/dist/src/{drivers/electron/native → electron}/adblock/cache.d.ts +0 -0
  363. /package/dist/src/{drivers/electron/native → electron}/adblock/cache.js +0 -0
  364. /package/dist/src/{drivers/electron/native → electron}/adblock/cosmetics.d.ts +0 -0
  365. /package/dist/src/{drivers/electron/native → electron}/adblock/cosmetics.js +0 -0
  366. /package/dist/src/{drivers/electron/native → electron}/adblock/policy.d.ts +0 -0
  367. /package/dist/src/{drivers/electron/native → electron}/adblock/policy.js +0 -0
  368. /package/dist/src/{drivers/electron/native → electron}/adblock/preload.d.ts +0 -0
  369. /package/dist/src/{drivers/electron/native → electron}/adblock/preload.js +0 -0
  370. /package/dist/src/{drivers/electron/native → electron}/adblock/settings.d.ts +0 -0
  371. /package/dist/src/{drivers/electron/native → electron}/adblock/settings.js +0 -0
  372. /package/dist/src/{drivers/electron/native → electron}/policy.d.ts +0 -0
  373. /package/dist/src/{drivers/electron/native → electron}/policy.js +0 -0
  374. /package/dist/src/{drivers/electron/native → electron}/shell/adblock-ipc.d.ts +0 -0
  375. /package/dist/src/{drivers/electron/native → electron}/shell/adblock-ipc.js +0 -0
  376. /package/dist/src/{drivers/electron/native → electron}/shell/context-menu.d.ts +0 -0
  377. /package/dist/src/{drivers/electron/native → electron}/shell/context-menu.js +0 -0
  378. /package/dist/src/{drivers/electron/native → electron}/shell/downloads.d.ts +0 -0
  379. /package/dist/src/{drivers/electron/native → electron}/shell/downloads.js +0 -0
  380. /package/dist/src/{drivers/electron/native → electron}/shell/helpers.d.ts +0 -0
  381. /package/dist/src/{drivers/electron/native → electron}/shell/helpers.js +0 -0
  382. /package/dist/src/{drivers/electron/native → electron}/shell/permissions.d.ts +0 -0
  383. /package/dist/src/{drivers/electron/native → electron}/shell/permissions.js +0 -0
  384. /package/dist/src/{drivers/electron/native → electron}/shell/types.js +0 -0
  385. /package/dist/src/{drivers/electron/native → electron}/surface/commands.d.ts +0 -0
  386. /package/dist/src/{drivers/electron/native → electron}/surface/commands.js +0 -0
  387. /package/dist/src/{drivers/electron/native → electron}/surface/create.d.ts +0 -0
  388. /package/dist/src/{drivers/electron/native → electron}/surface/events.d.ts +0 -0
  389. /package/dist/src/{drivers/electron/native → electron}/surface/types.js +0 -0
  390. /package/dist/src/{drivers/electron/native → electron}/surface-controller.d.ts +0 -0
@@ -1,71 +1,67 @@
1
1
  # Architecture
2
2
 
3
- `BrowserProductService` is the product boundary. It composes session and
4
- profile policy, encrypted cookie coordination, auth bundles, login handoffs,
5
- and recording lifecycles. Drivers operate physical browsers. Transport
6
- adapters translate their inputs into this service and do not own browser
7
- policy.
3
+ `BrowserProductService` is the product boundary. It holds session policy, the
4
+ account, auth bundles, login handoffs, recordings, and the account's cookie
5
+ jar. The driver operates the runtime's one Chrome. Transport adapters turn
6
+ their inputs into service calls and own no browser policy.
8
7
 
9
- ## Derivation
8
+ ## Flow of one action
10
9
 
11
- The purpose requires one meaning for every browser action across desktop and
12
- server environments. Therefore:
10
+ 1. An adapter picks the session (an explicit `session`, else the caller's
11
+ `callerId`, else `default`) and calls `createSession`, which creates it or,
12
+ after a restart, reopens it.
13
+ 2. `BrowserService.execute` checks the session is ready and idle, authorizes
14
+ the action, and takes the session lease.
15
+ 3. The driver runs the action through the session's agent-browser daemon, or
16
+ over CDP for capture and some input, and then syncs cookies.
17
+ 4. The service stores the result and emits a sanitized event.
13
18
 
14
- 1. A typed action enters `BrowserService`.
15
- 2. The service authorizes it, checks session state and capabilities, and
16
- acquires the session lease.
17
- 3. The session's immutable backend selects exactly one driver.
18
- 4. The driver acts on the session's exact page or verified visible surface.
19
- 5. The service persists the transition and emits a sanitized event.
20
-
21
- CLI, MCP, REST, and Toolbox all dispatch through the same canonical action
22
- descriptor array. The generated reachability test calls all 22 actions through
23
- all five surfaces.
19
+ CLI, MCP, REST, and Toolbox dispatch through one action descriptor array. The
20
+ parity test calls all 22 actions through all five surfaces.
24
21
 
25
22
  ## Ownership map
26
23
 
27
- - `service.ts`, `product-service.ts` — mutation boundary and product services
28
- - `sessions/`, `profiles/` — leases and lifecycle policy
29
- - `drivers/headless/` — `agent-browser`, CDP, profiles, and physical cookies
30
- - `drivers/electron/` — verified visible driver and host advertisement
31
- - `drivers/electron/native/` — `WebContentsView` shell, surfaces, policy,
32
- downloads, permissions, menus, and native ad blocking
33
- - `drivers/cdp/` — exact-target capture, input, and cancellable protocol client
34
- - `cookies/` — encrypted logical authority and adapter reconciliation
35
- - `auth/` — explicit bundles and TTL-bound human login
36
- - `recording/` — page screencast, latest-frame sampler, and bounded encoder
37
- - `persistence/`, `migration/` — SQLite state and idempotent legacy import
38
- - `adapters/` — CLI, MCP, REST/SSE, and Toolbox projections
24
+ - `service.ts`, `product-service.ts`, `account.ts`: the mutation boundary,
25
+ product services, and the one browsing identity
26
+ - `sessions/`: leases and pruning
27
+ - `chrome/`: finding, launching, owning, and restarting Chrome; the per-session
28
+ CDP relay; the Chrome cookie adapter
29
+ - `driver/`: the agent-browser driver, command runner, waits, action evidence,
30
+ and live-view stream
31
+ - `cdp/`: page capture, screencast, input, and a cancellable protocol client
32
+ - `cookies/`: the encrypted jar, cookie policy, and the coordinator that syncs
33
+ each browser with the jar
34
+ - `electron/`: the Electron shell (native tabs, policy, downloads,
35
+ permissions, context menus, ad blocking) and a cookie adapter for its
36
+ partition
37
+ - `auth/`: named bundles and TTL-bound human login
38
+ - `recording/`: screencast sampling and the bounded WebM encoder
39
+ - `persistence/`, `migration/`: SQLite state and the one-time legacy import
40
+ - `adapters/`: CLI, MCP, REST with SSE and the live-view WebSocket, and Toolbox
39
41
 
40
- ## Runtime selection
42
+ ## One Chrome, many sessions
41
43
 
42
- Selection happens once before open. A forced backend or explicit CDP endpoint
43
- wins. A fresh, compatible, loopback Electron host advertisement selects
44
- Electron only for a desktop owner. Everything else selects headless. A visible
45
- session never falls back to headless after identity loss.
44
+ A runtime has one `ChromeHost`. Each session reaches it through its own relay
45
+ endpoint, which shows the session only its own tabs and places new tabs in the
46
+ account's browser context. All sessions therefore share one set of cookies.
47
+ See [Chrome runtime](./CHROME.md).
46
48
 
47
49
  ## Persistence and concurrency
48
50
 
49
- SQLite stores each metadata entity independently, uses WAL and a busy timeout,
50
- and holds cross-process session leases. Encrypted cookie/auth payloads use
51
- atomic private files because their security and integrity envelope is a better
52
- fit than ordinary database rows. Registry and migration writes are
53
- transactional. A restarted service reopens a persisted ready session through
54
- its assigned driver before acting.
55
-
56
- ## Visible surfaces
57
-
58
- The Electron host creates native `WebContentsView` pages in the isolated
59
- Browser partition. Protocol-6 identity combines a session stamp, surface ID,
60
- marker URL, and declared target type. The driver verifies that identity before
61
- every action. It may reattach once only when the original surface is genuinely
62
- gone; ambiguity or mismatch fails before page input.
51
+ SQLite stores each metadata entity separately, uses WAL and a busy timeout,
52
+ and holds cross-process session leases. Encrypted cookie, login, and auth
53
+ payloads live in atomic private files. Registry and migration writes are
54
+ transactional. Sessions are durable: after a restart, a ready session reopens
55
+ when `createSession` names it again. Chrome itself has one owning process per
56
+ root, enforced by the OS-held `<root>/chrome.lease.sqlite` lease.
57
+ `browser.close()` stops admission, cancels and drains admitted work, then stops
58
+ recordings, detaches every session, stops Chrome, and closes the registry.
63
59
 
64
60
  ## Data movement
65
61
 
66
- Physical Chromium stores remain isolated. Cookie adapters exchange normalized
67
- records with the encrypted logical jar, never with each other. Deletion is a
68
- tombstone and timestamp/source ordering makes merges deterministic. Named auth
69
- bundles are explicit filtered snapshots and can additionally contain supported
70
- origin storage. Events and ordinary resource projections contain metadata
71
- only.
62
+ The account's encrypted jar is the store of record for cookies. The
63
+ coordinator keeps each registered browser store in two-way sync with it; the
64
+ runtime registers Chrome's account context. Deletions are tombstones, and
65
+ ordering by timestamp then source makes merges deterministic. Named auth
66
+ bundles are explicit filtered snapshots and can also carry origin storage.
67
+ Events and ordinary resource projections contain metadata only.
@@ -1,56 +1,61 @@
1
1
  # Authentication and login handoff
2
2
 
3
- Browser separates working profiles, automatic cookies, named auth bundles,
4
- and human login sessions. None is an alias for another.
3
+ Browser keeps three things apart: the account's automatic cookies (see
4
+ [cookies](./COOKIES.md)), named auth bundles, and human login sessions.
5
5
 
6
6
  ## Named auth bundles
7
7
 
8
- `browser.auth.save` asks the assigned driver for state, filters it to explicit
9
- domains, encrypts the payload, and stores only metadata in SQLite. Supported
10
- payloads can include cookies, localStorage, and sessionStorage. List/get return
11
- ID, name, profile, domains, storage kinds, and timestamps—never values.
8
+ `browser.auth.save` takes the session's state through agent-browser
9
+ `state save`, filters it to explicit domains (or the page's domain), encrypts
10
+ the payload under `auth-bundles/`, and stores only metadata in SQLite. A
11
+ payload can hold cookies, localStorage, and sessionStorage. List and get
12
+ return ID, name, account (`profileId`), domains, storage kinds, and
13
+ timestamps, never values.
12
14
 
13
- Loading is explicit and requires a capable session. Deleting removes both the
14
- encrypted payload and metadata. A bundle's profile reference protects that
15
- profile from pruning.
15
+ `browser.auth.load` writes a bundle into a session through `state load`. All
16
+ sessions share the account's browser context, so loaded cookies are visible to
17
+ every session at once and reach the cookie jar at the next sync. Deleting
18
+ removes both the encrypted payload and the metadata.
16
19
 
17
- Portable export/import re-encrypts a bundle with an explicitly authorized
18
- 32-byte portable key and verifies metadata integrity on import. The portable
19
- resource is still ciphertext and should be handled as a credential.
20
+ Portable export and import re-encrypt a bundle with an explicitly authorized
21
+ 32-byte portable key and verify metadata integrity on import. The portable
22
+ resource is still ciphertext; handle it as a credential.
20
23
 
21
24
  ## Human login
22
25
 
23
- `browser.login.create` returns a session plus one random token and a
24
- token-bearing handoff URL. The credential is delivered only in that creation
25
- result. Browser stores a SHA-256 hash and compares verification values in
26
- constant time. Ordinary list/get never returns the token.
26
+ `browser.login.create` returns a login session, one random token, and a
27
+ handoff URL (`/browser-auth/<id>?token=<token>`). The token appears only in
28
+ that result. Browser stores its SHA-256 hash and compares in constant time;
29
+ list and get never return it.
27
30
 
28
- TTL defaults to 15 minutes and is clamped from one minute to one hour. A handoff
29
- uses a durable profile while pending or active:
31
+ TTL defaults to 15 minutes and is clamped to between one minute and one hour.
30
32
 
31
- 1. Create the handoff for a target URL and filtered domains.
32
- 2. Activate it after validating the token; Browser opens the owned profile.
33
- 3. Forward browser-scoped CUA screenshot/input while the human signs in.
34
- 4. Complete to save an encrypted named bundle and close the live session, or
35
- cancel to close it without saving.
33
+ 1. Create the handoff for a target URL and its domains.
34
+ 2. Activate it with the token. Browser opens browser session `login-<id>` on
35
+ the target URL.
36
+ 3. Forward screenshots and input (`input` takes a `cua` operation) while the
37
+ human signs in.
38
+ 4. Complete to save a named bundle and close the session, or cancel to close
39
+ it without saving.
36
40
 
37
- Expired active sessions are closed. Completed, cancelled, and expired tokens
38
- cannot be reused.
41
+ An expired active login's session is closed. Completed, cancelled, and expired
42
+ tokens cannot be reused. Each change publishes `login.updated`.
43
+ Transitions for one handoff are serialized. Repeating activation returns the
44
+ same active page without restarting navigation or interrupting the person's
45
+ input; cancellation and completion cannot be undone by an earlier activation.
39
46
 
40
- ## Transports
47
+ ## Presentation
41
48
 
42
- - `electron-surface` presents the verified page in the desktop app.
43
- - `novnc` uses `AMALGM_BROWSER_NOVNC_PUBLIC_URL` or
44
- `AMALGM_BROWSER_NOVNC_URL` when configured.
45
- - `external` provides a host-integrated handoff.
46
-
47
- Transport selection is presentation; the auth lifecycle and profile ownership
48
- remain Browser rules.
49
+ Every login uses its runtime session's ordinary live view in the canonical
50
+ browser component, including on Electron. New metadata uses `external` and
51
+ `ready`. Legacy `transport` and `liveUrl` inputs remain accepted for tool and
52
+ SDK compatibility, but do not select another browser or transport. Historical
53
+ metadata remains readable; there is no VNC implementation or configuration.
49
54
 
50
55
  ## Security boundary
51
56
 
52
57
  Device-local AES-GCM encryption protects against accidental plaintext
53
- exposure, not an attacker who can read both encrypted files and the local key.
54
- Treat token-bearing handoff URLs, portable resources, captures, and origin
58
+ exposure, not against an attacker who can read both the encrypted files and
59
+ the local key. Treat handoff URLs, portable resources, captures, and origin
55
60
  storage as credentials. They must not enter logs, events, chat history, or
56
- ordinary resource projections.
61
+ ordinary resource output.
package/docs/AXIOMS.md CHANGED
@@ -1,19 +1,21 @@
1
1
  # Axiom map
2
2
 
3
- [PURPOSE.md](../PURPOSE.md) is the authoritative list of primitives and 19
4
- product axioms. This document maps them to observable boundaries.
3
+ [PURPOSE.md](../PURPOSE.md) is the authoritative list of primitives and 21
4
+ numbered product axioms. This map ties them to the tests that show them.
5
5
 
6
6
  | Axioms | Consequence | Evidence |
7
7
  | --- | --- | --- |
8
- | 1–3 | Browser owns state; sessions bind one profile and immutable backend | service and restart contracts |
9
- | 4–5 | Electron identity is verified; ordinary fallback is headless | identity and advertisement tests |
10
- | 6–8 | Capabilities are honest; work is cancellable and bounded | driver, CDP, process, and parity tests |
11
- | 9–13 | Cookie stores are isolated and secrets remain encrypted | cookie, auth, partition, and migration tests |
12
- | 14 | Capture and recording address the actual page | DPR, target, sampler, and real-runtime tests |
13
- | 15 | Context enters through ports; events are sanitized | artifact and SSE contracts |
14
- | 16 | Existing state is imported safely | transactional legacy fixture test |
15
- | 17–18 | One TypeScript implementation works without Shell, Engine, or Electron | package install and adapter parity tests |
16
- | 19 | Shell composes one Browser service; Electron is a host adapter | Shell composition and Electron harness tests |
8
+ | 1–3 | Browser owns state; every session browses as the one account | `service.test.ts` account tests |
9
+ | 4 | One owned Chrome, restarted on next use | `real-browser.test.ts` crash recovery and competing-owner tests |
10
+ | 5–6 | Sessions see only their own tabs, reopen after restarts, and stream only themselves | real-browser side-by-side and live-view tests; real-lifecycle CDP and CLI isolation; `service.test.ts` restart reopen |
11
+ | 7–9 | Page identity, cancellation, and bounded output | real-browser duplicate-URL capture; real-lifecycle operation drain; `service`, `process` and `parity` tests |
12
+ | 10–14 | Cookies sync through the encrypted jar without idle scans; secrets stay out of output | `cookies`, `cookie-coordinator`, `cookie-notifications`, `auth`, `adapters` tests; real-browser idle and loopback tests |
13
+ | 15 | Recording proves capture and stays bounded | `recording.test.ts`; real-lifecycle records and decodes page imagery |
14
+ | 16 | Context enters through ports; events are sanitized | `events.test.ts`, `adapters.test.ts` |
15
+ | 17 | Existing state is imported safely | `persistence.test.ts` legacy upgrade |
16
+ | 18–19 | One TypeScript implementation works without Shell, Engine, or Electron | `parity.test.ts`, `surfaces.test.ts`, `verify:pack` |
17
+ | 20 | Shell composes one service; Electron keeps each account in its own partition | `electron-cookies`, `electron-policy` tests; UI's `test:browser` drives real Electron cookie sharing and sign-out through Shell |
18
+ | 21 | agent-browser IPC fits the socket limit | source only (`driver/command.ts`) |
17
19
 
18
20
  When behavior fails, classify it against this map. If code drifted, restore the
19
21
  axiom everywhere it applies. If the axiom is incomplete, update
package/docs/CHROME.md ADDED
@@ -0,0 +1,143 @@
1
+ # Chrome runtime
2
+
3
+ Each runtime runs one headless Chrome. Every session drives its own tabs in
4
+ that Chrome, and every tab browses as the runtime's account. `ChromeHost`
5
+ (`src/chrome/`) owns the Chrome process. `AgentBrowserDriver` (`src/driver/`)
6
+ runs each session's actions through its own agent-browser daemon.
7
+
8
+ ## Finding Chrome
9
+
10
+ Browser uses the first match:
11
+
12
+ 1. `AMALGM_BROWSER_EXECUTABLE_PATH` (or `AGENT_BROWSER_EXECUTABLE_PATH`). If
13
+ the path does not exist, launch fails.
14
+ 2. An installed Google Chrome, Chrome Canary, Chromium, or Brave in the
15
+ platform's usual install locations.
16
+ 3. Chrome for Testing downloaded by `npx agent-browser install` into
17
+ `~/.agent-browser/browsers`, newest first.
18
+
19
+ If nothing is found, the first action fails with `PROCESS_FAILED` and a hint
20
+ to install Chrome.
21
+
22
+ ## Launch
23
+
24
+ Chrome starts on the first action, not when the service is created. It runs
25
+ `--headless=new` with remote debugging on a random loopback port and its user
26
+ data in `<root>/chrome`. It presents a desktop user agent built from the
27
+ installed Chrome's version and turns off the `AutomationControlled` blink
28
+ feature, so sign-in pages see an ordinary desktop Chrome. Sync, first-run,
29
+ translate, and component-update behavior are off, and the window is 1280×800.
30
+ On Linux, `--no-sandbox` is added only when running as root.
31
+
32
+ Chrome's native debugging-listening event admits the process, within a
33
+ 20-second deadline. Browser attaches its private cookie extension to the
34
+ account's default profile and reconciles it with the encrypted jar
35
+ (see [cookies](./COOKIES.md)). The extension uses one session on the existing
36
+ control connection, independently of the number of pages. Chrome reports a
37
+ worker's context before it runs the worker script, so Browser's bindings can
38
+ arrive before or after that script. Both sides ask to start delivery, and
39
+ whichever comes second starts it; the worker then announces that it is
40
+ observing. Chrome stops an idle extension worker and restarts it for the next
41
+ cookie change; the new worker announces itself again, and that second
42
+ announcement brings one snapshot to cover the stop. Chrome keeps its
43
+ normal platform credential storage; Browser does not request the basic password
44
+ store or mock keychain.
45
+
46
+ ## One owner per root
47
+
48
+ Only one process may run a root's Chrome. An exclusive SQLite transaction in
49
+ `<root>/chrome.lease.sqlite` holds an OS lease for the process lifetime; another
50
+ owner gets `CONFLICT`. The file is never removed. After a dead owner releases
51
+ the lease, Browser retires its exact Chrome through the random browser endpoint
52
+ in that profile's `DevToolsActivePort`, then starts the replacement. No PID or
53
+ command-line match can authorize killing a process.
54
+
55
+ ## Restart on next use
56
+
57
+ If Chrome exits, Browser logs a warning and forgets it. The next action starts
58
+ a new Chrome and loads the account's cookies into it. Tabs that were open are
59
+ gone. An action caught by the crash can fail; retry it and it runs in the new
60
+ Chrome.
61
+
62
+ ## Sessions and the relay
63
+
64
+ Each session is one agent-browser daemon attached with `--cdp` to the session's
65
+ own relay endpoint, `ws://127.0.0.1:<port>/session/<id>`. The relay gives that
66
+ connection a filtered view of the shared Chrome:
67
+
68
+ - it lists and controls only the session's own tabs;
69
+ - every tab it opens is placed in a new window in the account's browser context;
70
+ - browser-wide methods (`Browser.close`, `Browser.crash`,
71
+ `Target.createBrowserContext`, `Target.disposeBrowserContext`,
72
+ `Target.attachToBrowserTarget`, `Target.setAutoAttach`) are refused.
73
+
74
+ The first time a process uses a session, Browser closes any daemon left by an
75
+ earlier process, then attaches a new one, which opens the session's first tab.
76
+ Closing a session detaches its daemon and closes its tabs in Chrome.
77
+
78
+ agent-browser's IPC sockets live in a private per-user directory under `/tmp`
79
+ (the OS temporary directory on Windows). Each daemon's name is a digest of the
80
+ real Browser root and the session ID, so long roots and IDs fit the socket
81
+ path limit.
82
+ The daemon uses Browser's own empty configuration and explicit launch inputs;
83
+ ambient agent-browser profiles, sessions and providers cannot alter this
84
+ identity. Page-operation argv travels through the CLI's JSON batch input,
85
+ separate from its global flag parser.
86
+
87
+ ## Capture and input
88
+
89
+ Snapshots give stable `@eN` references for ordinary DOM actions. Screenshots,
90
+ the `cua` double click, and recording connect straight to the session's page
91
+ over CDP. The relay records the selected target's identity; repeated URLs do
92
+ not make different tabs interchangeable. Without an owned selected target,
93
+ the operation fails with `SURFACE_IDENTITY_FAILED`.
94
+
95
+ Viewport screenshots are in CSS pixels at any device pixel ratio, and
96
+ full-page capture is capped at 8192×16384. Computer use supports screenshot,
97
+ click, double click, move, scroll, type, keypress, and drag. Use it for canvas,
98
+ WebGL, image-only, or hostile custom controls; prefer snapshot references
99
+ elsewhere.
100
+
101
+ ## Live view
102
+
103
+ `browser.streamUrl(sessionId)` returns agent-browser's stream for that session,
104
+ `ws://127.0.0.1:<port>`, and turns the stream on if needed. The stream sends
105
+ `status`, `tabs`, and `frame` messages and accepts `input_mouse`,
106
+ `input_keyboard`, and `input_touch`. It shows and drives only that session's
107
+ tabs. Viewers outside the process use the REST route
108
+ `/v1/sessions/<id>/stream` (see [REST](./REST.md)), which also reports the
109
+ selected page's actual Back/Forward availability. Editor shortcuts carry CDP
110
+ editor commands, so they behave consistently in a streamed headless page.
111
+ Navigation observation follows selected-tab and page events; an idle viewer
112
+ does not poll history, and closing it releases its observation connection.
113
+
114
+ ## Shutdown
115
+
116
+ `browser.close()` stops admission, cancels and drains in-flight operations,
117
+ then stops recordings, detaches every daemon, drains queued cookie changes,
118
+ stops Chrome (SIGTERM, then SIGKILL after 3 seconds), and closes the
119
+ registry. Chrome is also killed if the Node process exits.
120
+
121
+ ## Configuration
122
+
123
+ - `AMALGM_BROWSER_EXECUTABLE_PATH`: the Chrome executable
124
+ - `AMALGM_AGENT_BROWSER_BIN`: the agent-browser executable. Without it,
125
+ Browser uses the platform binary shipped with the `agent-browser` package
126
+ (from `app.asar.unpacked` in packaged Electron apps), then the package's
127
+ JavaScript wrapper, then `agent-browser` on `PATH`.
128
+ - `AMALGM_FFMPEG`: the ffmpeg executable for recording
129
+
130
+ ## Real verification
131
+
132
+ `npm run test:real` drives real Chrome and agent-browser against a real site. It
133
+ checks that chats browse side by side as one account, that a viewer can watch
134
+ and drive one chat's live view only with the runtime token, that sign-ins
135
+ survive restarts and follow sign-outs, that a chat keeps browsing after Chrome
136
+ is killed, and that loopback cookies never enter the account. It also measures
137
+ zero cookie scans and history reads while idle, including with a live viewer,
138
+ and verifies background cookie writes and tab-switch history updates. The busy
139
+ page examination starts with 1000 cookies and requires 60 edits to cause zero
140
+ full-store scans, exactly 60 encrypted row writes, and under 120 KB of encoded
141
+ state. Observer reload, worker restart, HttpOnly and partitioned events are exercised in real
142
+ Chrome. Timing/CPU observations describe this local workload, not a universal
143
+ website latency guarantee.
package/docs/CLI.md CHANGED
@@ -1,51 +1,87 @@
1
1
  # CLI
2
2
 
3
- `amalgm-browser` prints stable JSON to stdout and sanitized diagnostics to
4
- stderr. It never constructs a shell command.
3
+ `amalgm-browser` prints JSON to stdout and sanitized diagnostics to stderr. It
4
+ never constructs a shell command.
5
+
6
+ ## One-shot commands
7
+
8
+ Each action or resource command is one process. It starts the runtime's
9
+ Chrome, runs, and stops Chrome before exiting. The session record and the
10
+ account's cookies carry over to the next command; the open page does not. A
11
+ follow-up command in the same session starts on a new blank tab.
12
+
13
+ For multi-step browsing, keep one process running:
14
+
15
+ - `amalgm-browser mcp` for an MCP client
16
+ - `amalgm-browser serve` for REST
17
+
18
+ Only one process can run a root's Chrome at a time. While `mcp` or `serve` is
19
+ running, a one-shot command on the same root that needs Chrome fails with
20
+ `CONFLICT`.
5
21
 
6
22
  ## Actions
7
23
 
8
24
  ```text
9
25
  open <url> snapshot
10
- screenshot [--full-page] click <target>
11
- fill <target> <text> press <key>
12
- select <target> <value> eval <script>
13
- wait [--selector|--url|--ms] dialog|tab|console|cua --input <json>
14
- close action <name> --input <json>
26
+ screenshot [--full-page] click <target>
27
+ fill <target> <text> [--submit]
28
+ press <key> select <target> <value>
29
+ eval <script> wait [--selector css|--url value|--ms n]
30
+ cli <agent-browser args...> close
31
+ dialog|tab|console|cua --input <json>
32
+ action <name> --input <json>
15
33
  ```
16
34
 
17
- Use one `--session` value across related invocations. The generic `action`
18
- form reaches every canonical action, including recording and auth actions.
35
+ The generic `action` form reaches all 22 actions, including recording and
36
+ auth actions.
37
+
38
+ Advanced `cli` argv runs page operations in the current session. Browser owns
39
+ process, connection, account, recording and authentication lifecycle; raw CLI
40
+ management commands cannot replace those owners. Operation argv is sent as
41
+ JSON data, so literal text resembling launch flags stays page text.
19
42
 
20
43
  ## Resources
21
44
 
22
45
  ```text
23
- sessions list|get|close|cancel|prune [id]
24
- profiles list|get|create|update|delete|prune [id]
25
- auth list|link|save|load|delete [id]
26
- recordings start|stop|cancel|list|get [id]
27
- capabilities
46
+ sessions list|get|close|cancel|prune [id] [--max-age-ms n]
47
+ auth list
48
+ auth link --url <url> [--domains a,b] [--ttl-ms n] [--transport t] [--live-url u]
49
+ auth save [name] [--domains a,b]
50
+ auth load <bundleId>
51
+ auth delete <bundleId>
52
+ recordings start [--name n] [--fps n] [--duration-ms n]
53
+ recordings stop|cancel|list|get [id]
28
54
  doctor
29
- serve
55
+ serve [--port 0] [--host 127.0.0.1] [--token t] [--allow-remote]
30
56
  mcp
31
57
  ```
32
58
 
33
- Common options are `--session`, `--profile`, `--root`, `--cwd`, `--timeout`,
34
- `--headless`, `--headed`, and `--cdp`. `--cwd` supplies opaque cwd context and
35
- a local artifact destination; it does not create a Browser workspace model.
59
+ `recordings start` records until `--duration-ms` passes or the process gets
60
+ SIGINT or SIGTERM. In a one-shot command the recorded page is a new blank tab,
61
+ so record through MCP, REST, or the SDK.
36
62
 
37
- `--headed` is an explicit debug choice. Ordinary standalone and background use
38
- stays headless. `--cdp` attaches to an operator-provided endpoint.
63
+ ## Global options
39
64
 
40
- ## REST and MCP modes
41
-
42
- ```sh
43
- amalgm-browser mcp
44
- amalgm-browser serve --token "$AMALGM_BROWSER_TOKEN" --port 8787
65
+ ```text
66
+ --session <id> --root <path> --cwd <project> --json --timeout <ms>
45
67
  ```
46
68
 
47
- `serve` binds `127.0.0.1` unless `--host` is supplied. A non-loopback host also
48
- requires `--allow-remote`; bearer authentication remains mandatory.
69
+ - `--session` names the session; the default is `default`.
70
+ - `--root` sets the state root.
71
+ - `--cwd` supplies opaque cwd context and a local artifact destination. It
72
+ does not create a Browser workspace model.
73
+ - `--json` is accepted; output is always JSON.
74
+ - `--timeout` aborts the command after that many milliseconds and is passed
75
+ to actions that take `timeoutMs`.
76
+
77
+ ## serve
78
+
79
+ `serve` binds `127.0.0.1` on a random port unless `--host` or `--port` is
80
+ given, and prints the address to stderr. The bearer token comes from
81
+ `--token` or `AMALGM_BROWSER_TOKEN`. A non-loopback host also requires
82
+ `--allow-remote`. Set `AMALGM_BROWSER_ADAPTER_TOKEN` to enable the internal
83
+ cookie routes. `mcp` and `serve` run until SIGINT or SIGTERM (`mcp` also stops
84
+ when stdin ends), then stop Chrome.
49
85
 
50
86
  ## Exit codes
51
87
 
@@ -55,7 +91,3 @@ requires `--allow-remote`; bearer authentication remains mandatory.
55
91
  - `4` resource not found
56
92
  - `5` timeout or cancellation
57
93
  - `1` other typed failure
58
-
59
- Use `--timeout <ms>` to abort a blocking operation. Recording start without a
60
- duration remains active until SIGINT or SIGTERM, then stops and flushes within
61
- the encoder deadline.
@@ -6,11 +6,13 @@
6
6
  - modules: ESM core imports; ESM and generated CommonJS for
7
7
  `@amalgm/browser/electron`
8
8
  - Electron: optional peer, version 33 or newer
9
- - Electron surface protocols: writes protocol 6; reads protocols 5 and 6
10
- - Browser partition: exactly `persist:amalgm-browser`
9
+ - browser: an installed Chrome, Chrome Canary, Chromium, or Brave, or Chrome
10
+ for Testing (see [Chrome runtime](./CHROME.md))
11
+ - Electron browser partition: `persist:amalgm-browser-<SHA-256 account ID>`;
12
+ application authentication stays in Electron's default partition
11
13
 
12
- Core and headless imports do not load Electron. The Electron native code is
13
- available only from `@amalgm/browser/electron`.
14
+ Core imports do not load Electron. The Electron code is available only from
15
+ `@amalgm/browser/electron`.
14
16
 
15
17
  ## Action identities
16
18
 
@@ -22,25 +24,14 @@ Historical aggregate Browser grants, older prefixed IDs, and individual
22
24
  `cua_*` names are normalized in the Toolbox compatibility adapter. They are
23
25
  not core action aliases and never create doubled Browser prefixes.
24
26
 
25
- ## Historical Engine routes and data
27
+ ## Legacy data
26
28
 
27
- During a bounded historical cutover, Engine routes may delegate into this SDK.
28
- They must not remain as a parallel production implementation. Raw cookie
29
- bootstrap and merge use the restricted adapter transport, not public OpenAPI.
29
+ The versioned importer brings in legacy Engine auth bundles, the saved
30
+ cookie-source bundle with its tombstones, and login sessions, all under the
31
+ runtime's account (see [migration](./MIGRATION.md)).
30
32
 
31
- Legacy Engine profiles, encrypted auth/cookie-source bundles, cookie
32
- tombstones, and login sessions are supported by the versioned importer. Paths
33
- and the Electron partition are reused to avoid forced sign-in.
33
+ ## agent-browser output
34
34
 
35
- ## Backend differences
36
-
37
- Capabilities make differences explicit. Electron advertises visible-surface,
38
- live-login, and ad-blocking behavior. Headless advertises full-page capture and
39
- does not claim native Electron ad blocking. Unsupported operations return
40
- `CAPABILITY_UNSUPPORTED`; adapters must not synthesize a substitute.
41
-
42
- ## Agent-browser envelopes
43
-
44
- The headless adapter accepts supported historical JSON result envelopes and
45
- normalizes them at its boundary. The SDK result union is stable and does not
46
- expose agent-browser's transport format.
35
+ The driver accepts agent-browser's JSON result envelopes and unwraps them at
36
+ its boundary. The SDK result union is stable and does not expose
37
+ agent-browser's output format.