@amalgm/browser 0.1.2-preview.37556903313 → 0.1.2-preview.44182723491

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 (95) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/PURPOSE.md +16 -15
  3. package/README.md +19 -37
  4. package/dist/src/adapters/http/request.d.ts +0 -1
  5. package/dist/src/adapters/http/request.js +0 -7
  6. package/dist/src/adapters/http/request.js.map +1 -1
  7. package/dist/src/adapters/http/server.js +1 -15
  8. package/dist/src/adapters/http/server.js.map +1 -1
  9. package/dist/src/adapters/http/types.d.ts +0 -3
  10. package/dist/src/adapters/mcp/server.js +1 -28
  11. package/dist/src/adapters/mcp/server.js.map +1 -1
  12. package/dist/src/adapters/mcp/types.d.ts +0 -1
  13. package/dist/src/artifacts.d.ts +3 -4
  14. package/dist/src/artifacts.js +5 -9
  15. package/dist/src/artifacts.js.map +1 -1
  16. package/dist/src/cookies/database.d.ts +0 -1
  17. package/dist/src/cookies/database.js +5 -24
  18. package/dist/src/cookies/database.js.map +1 -1
  19. package/dist/src/defaults.d.ts +3 -16
  20. package/dist/src/defaults.js +12 -42
  21. package/dist/src/defaults.js.map +1 -1
  22. package/dist/src/index.d.ts +2 -4
  23. package/dist/src/index.js +1 -3
  24. package/dist/src/index.js.map +1 -1
  25. package/dist/src/persistence/sqlite-registry.d.ts +1 -5
  26. package/dist/src/persistence/sqlite-registry.js +1 -24
  27. package/dist/src/persistence/sqlite-registry.js.map +1 -1
  28. package/dist/src/ports.d.ts +0 -1
  29. package/dist/src/product-service.d.ts +0 -1
  30. package/dist/src/product-service.js +1 -1
  31. package/dist/src/product-service.js.map +1 -1
  32. package/dist/src/recording/service.d.ts +2 -2
  33. package/dist/src/recording/service.js +4 -9
  34. package/dist/src/recording/service.js.map +1 -1
  35. package/dist/src/types.d.ts +0 -1
  36. package/docs/ACTIONS.md +1 -2
  37. package/docs/ARCHITECTURE.md +5 -6
  38. package/docs/AXIOMS.md +1 -1
  39. package/docs/COMPATIBILITY.md +0 -6
  40. package/docs/MCP.md +7 -6
  41. package/docs/OPERATIONS.md +12 -26
  42. package/docs/README.md +3 -3
  43. package/docs/REALTIME_BOUNDARY.md +4 -5
  44. package/docs/RECORDING.md +5 -7
  45. package/docs/REST.md +7 -14
  46. package/docs/SDK.md +9 -11
  47. package/docs/SHELL_INTEGRATION.md +2 -8
  48. package/docs/TESTING.md +8 -8
  49. package/docs/TOOLBOX_INTEGRATION.md +1 -1
  50. package/docs/TROUBLESHOOTING.md +4 -13
  51. package/examples/basic.ts +3 -1
  52. package/package.json +5 -13
  53. package/skills/use-amalgm-browser/SKILL.md +11 -37
  54. package/skills/use-amalgm-browser/references/actions.md +1 -1
  55. package/dist/bin/amalgm-browser-mcp.d.ts +0 -2
  56. package/dist/bin/amalgm-browser-mcp.js +0 -4
  57. package/dist/bin/amalgm-browser-mcp.js.map +0 -1
  58. package/dist/bin/amalgm-browser-rest.d.ts +0 -2
  59. package/dist/bin/amalgm-browser-rest.js +0 -10
  60. package/dist/bin/amalgm-browser-rest.js.map +0 -1
  61. package/dist/bin/amalgm-browser.d.ts +0 -2
  62. package/dist/bin/amalgm-browser.js +0 -4
  63. package/dist/bin/amalgm-browser.js.map +0 -1
  64. package/dist/src/adapters/cli/actions.d.ts +0 -6
  65. package/dist/src/adapters/cli/actions.js +0 -56
  66. package/dist/src/adapters/cli/actions.js.map +0 -1
  67. package/dist/src/adapters/cli/args.d.ts +0 -8
  68. package/dist/src/adapters/cli/args.js +0 -41
  69. package/dist/src/adapters/cli/args.js.map +0 -1
  70. package/dist/src/adapters/cli/help.d.ts +0 -1
  71. package/dist/src/adapters/cli/help.js +0 -26
  72. package/dist/src/adapters/cli/help.js.map +0 -1
  73. package/dist/src/adapters/cli/resources.d.ts +0 -4
  74. package/dist/src/adapters/cli/resources.js +0 -94
  75. package/dist/src/adapters/cli/resources.js.map +0 -1
  76. package/dist/src/adapters/cli/run.d.ts +0 -7
  77. package/dist/src/adapters/cli/run.js +0 -114
  78. package/dist/src/adapters/cli/run.js.map +0 -1
  79. package/dist/src/cli.d.ts +0 -2
  80. package/dist/src/cli.js +0 -3
  81. package/dist/src/cli.js.map +0 -1
  82. package/dist/src/migration/legacy-cookies.d.ts +0 -2
  83. package/dist/src/migration/legacy-cookies.js +0 -60
  84. package/dist/src/migration/legacy-cookies.js.map +0 -1
  85. package/dist/src/migration/legacy-crypto.d.ts +0 -1
  86. package/dist/src/migration/legacy-crypto.js +0 -35
  87. package/dist/src/migration/legacy-crypto.js.map +0 -1
  88. package/dist/src/migration/legacy-migration.d.ts +0 -19
  89. package/dist/src/migration/legacy-migration.js +0 -75
  90. package/dist/src/migration/legacy-migration.js.map +0 -1
  91. package/dist/src/migration/legacy-rows.d.ts +0 -4
  92. package/dist/src/migration/legacy-rows.js +0 -58
  93. package/dist/src/migration/legacy-rows.js.map +0 -1
  94. package/docs/CLI.md +0 -93
  95. package/docs/MIGRATION.md +0 -71
package/docs/SDK.md CHANGED
@@ -8,20 +8,18 @@ import { createBrowser, BrowserError } from '@amalgm/browser';
8
8
  const browser = createBrowser({ root, account: { id: user.id, name: user.name } });
9
9
  ```
10
10
 
11
- `createBrowser(options)` returns the browser service (`BrowserService`). Every
12
- option is optional:
11
+ `createBrowser(options)` returns the browser service (`BrowserService`):
13
12
 
14
- - `root`: state root (see [operations](./OPERATIONS.md))
13
+ - `root` (required): the one folder Browser keeps everything in, recordings
14
+ included. The host chooses it; Browser never defaults one (see
15
+ [operations](./OPERATIONS.md))
15
16
  - `account`: who every session browses as; default `{ id: 'local', name: 'Local' }`
16
- - `legacyDatabaseFile`: legacy import source, or `false` (see
17
- [migration](./MIGRATION.md))
18
17
  - injected ports: `registry`, `driver`, `eventSink`, `clock`, `logger`,
19
- `authorization`, `id`, `artifactStore`, `processLauncher`, `cookieJar`,
20
- `authVault`, `loginSecrets`, and `ffmpegBinary`
18
+ `authorization`, and `id`
21
19
 
22
20
  By default Browser uses a SQLite registry, the runtime's Chrome driver, an
23
- event bus, a local artifact store, encrypted cookie rows and auth files under
24
- the root. Chrome starts on the first action. [`examples/basic.ts`](../examples/basic.ts)
21
+ event bus, encrypted cookie rows and auth files, and recordings, all under the
22
+ root. Chrome starts on the first action. [`examples/basic.ts`](../examples/basic.ts)
25
23
  opens a page, snapshots it, and closes.
26
24
 
27
25
  ## Account
@@ -85,7 +83,7 @@ See [RECORDING.md](./RECORDING.md).
85
83
  ## Runtime context
86
84
 
87
85
  `BrowserRuntimeContext` accepts opaque `ownerId`, `callerId`, `clientKind`,
88
- `projectRef`, `cwdRef`, `artifactDestination`, `authorization`, and `signal`.
86
+ `projectRef`, `cwdRef`, `authorization`, and `signal`.
89
87
  Browser does not discover these from Chat or a workspace registry. An
90
88
  injected `authorization` port is asked before `sessions.create`,
91
89
  `sessions.close`, `sessions.stream`, `actions.<type>`, `auth.export`, and
@@ -99,7 +97,7 @@ Failures are `BrowserError` values with one of these codes: `ABORTED`,
99
97
 
100
98
  ## Entry points
101
99
 
102
- - `@amalgm/browser`: service, ports, types, persistence, migration
100
+ - `@amalgm/browser`: service, ports, types, persistence
103
101
  - `@amalgm/browser/electron`: the desktop app's in-app browser
104
102
  - `@amalgm/browser/cookies`: cookie jar, coordinator, and policy
105
103
  - `@amalgm/browser/recording`: recording components
@@ -16,8 +16,9 @@ Shell creates the service lazily, as the signed-in Amalgm account:
16
16
  ```ts
17
17
  import { createBrowser } from '@amalgm/browser';
18
18
 
19
+ // user = userLayout(lane.user(email)) from @amalgm/core/identity
19
20
  const browser = createBrowser({
20
- root: runtimeBrowserRoot,
21
+ root: user.computer.browser, // required: ~/amalgm/users/<user>/.amalgm/browser
21
22
  account: { id: userId, name: userEmail },
22
23
  eventSink: browserEventRelay, // optional
23
24
  authorization: shellBrowserAuthorization, // optional
@@ -87,10 +88,3 @@ Electron's `defaultSession`; websites stay in the account-specific
87
88
  `persist:amalgm-browser-<account hash>` partition. Its cookies sync with the
88
89
  runtime through Browser's private adapter port. Managed UI and Shell bind to
89
90
  the same exact published Browser release.
90
-
91
- ## Legacy import
92
-
93
- Legacy Engine data may be imported once through `legacyDatabaseFile` (see
94
- [migration](./MIGRATION.md)). The importer never writes to the legacy
95
- database. Legacy and current writers must never run against the same Browser
96
- state.
package/docs/TESTING.md CHANGED
@@ -18,7 +18,7 @@ npm run verify # check, build, test, package/install
18
18
  cannot be reassigned to another account
19
19
  - restart reopen, cross-process leases, one action per session, cancellation
20
20
  - a session's own live view, and closing the runtime releases Chrome
21
- - all 22 actions reachable through SDK, CLI, MCP, REST, and Toolbox, from one
21
+ - all 22 actions reachable through SDK, MCP, REST, and Toolbox, from one
22
22
  action manifest; an MCP call without a session uses its chat's session
23
23
  - two-way cookie sync: sign-ins and sign-outs reach the account, failed
24
24
  applies retry without echo, echoes reported after a newer write,
@@ -28,8 +28,8 @@ npm run verify # check, build, test, package/install
28
28
  serialized live login transitions
29
29
  - recording frame pacing, backpressure, ffmpeg checks, viability deadline,
30
30
  cancellation, and dead-owner recovery
31
- - SQLite cross-process writes and the encrypted legacy import
32
- - REST auth, loopback binding, SSE, redaction, and MCP cancellation
31
+ - SQLite cross-process writes
32
+ - REST auth, SSE, redaction, and MCP cancellation
33
33
  - argv process safety, bounded output and termination, asar resolution
34
34
  - Electron URL, popup, permission, download, and ad-block policy, and the
35
35
  Electron cookie adapter against an injected store
@@ -64,17 +64,17 @@ sharing and deletion, account switching, sign-out, and fractional native bounds.
64
64
  ## Package verification
65
65
 
66
66
  `verify:pack` runs `npm pack`, checks the tarball for required files and for
67
- runtime data or secrets, checks the compiled CLIs, installs the tarball into a
67
+ runtime data or secrets, installs the tarball into a
68
68
  temporary consumer without Electron, imports the core entry points, and
69
69
  confirms the Electron entry resolves to its CommonJS build.
70
70
 
71
- TypeScript in `src/`, `bin/`, and `test/` is limited to 220 lines per file.
72
- The tree check also fails on empty or untracked source files, JavaScript
73
- source in `src/` or `bin/`, and tracked build or runtime artifacts.
71
+ TypeScript in `src/` and `test/` is limited to 220 lines per file. The tree
72
+ check also fails on empty or untracked source files, JavaScript source in
73
+ `src/`, and tracked build or runtime artifacts.
74
74
 
75
75
  ## Adding behavior
76
76
 
77
77
  Update the purpose and axioms if the model changes, then the typed SDK, the
78
78
  shared action descriptor, every transport projection, the documentation, and
79
- an invariant test. A new action that is not reachable through all five public
79
+ an invariant test. A new action that is not reachable through all four public
80
80
  surfaces fails the parity suite.
@@ -35,5 +35,5 @@ grants are adapter aliases. They do not create new SDK action identities. In
35
35
  particular, never generate `toolbox__browser_browser_<action>`.
36
36
 
37
37
  The parity contract executes every canonical action through the Toolbox
38
- executor as well as SDK, CLI, MCP, and REST. Adding an action descriptor without
38
+ executor as well as SDK, MCP, and REST. Adding an action descriptor without
39
39
  a reachable Toolbox projection fails verification.
@@ -16,8 +16,8 @@ Chrome's stderr. On Linux as root, Browser already adds `--no-sandbox` and
16
16
  ## "This browser profile already has a live owner."
17
17
 
18
18
  Another live process holds this root's Chrome lease (`chrome.lease.sqlite`). This happens
19
- when a one-shot CLI command runs beside `mcp`, `serve`, or an embedding host on
20
- the same root. Send the work to that process, stop it, or use another root.
19
+ when a second process creates a Browser service on a root another runtime is
20
+ using. Send the work to that runtime or stop it.
21
21
  Never delete the lease file or Chrome's lock files. An owner that has died
22
22
  releases its lease automatically; the next start retires its orphaned Chrome
23
23
  through the exact endpoint published by that profile.
@@ -43,8 +43,7 @@ old ref fails with `PROCESS_FAILED`. Take a new snapshot.
43
43
 
44
44
  ## agent-browser is missing
45
45
 
46
- Run `amalgm-browser doctor`, reinstall production dependencies, or set
47
- `AMALGM_AGENT_BROWSER_BIN`. In packaged Electron builds, make sure native
46
+ Reinstall production dependencies or set `AMALGM_AGENT_BROWSER_BIN`. In packaged Electron builds, make sure native
48
47
  assets are unpacked from `app.asar`.
49
48
 
50
49
  ## "Browser IPC requires a private, user-owned temporary directory"
@@ -79,8 +78,7 @@ machine; the next Chrome start tries the extension again.
79
78
 
80
79
  Health is the only unauthenticated route. Send the exact runtime token.
81
80
  Internal cookie routes also need `X-Browser-Adapter-Token`. A live-view
82
- WebSocket closing with `4401` is the same token failure. Non-loopback binding
83
- requires explicit remote opt-in.
81
+ WebSocket closing with `4401` is the same token failure.
84
82
 
85
83
  ## Login handoff fails
86
84
 
@@ -94,10 +92,3 @@ is available.
94
92
  Each session allows one action at a time, and another process may hold the
95
93
  session's lease. Let the operation finish or cancel it through the owning
96
94
  process; stale leases expire. Avoid filesystems with broken SQLite locking.
97
-
98
- ## Migration fails
99
-
100
- Keep old writers stopped. Check that the legacy database exists, the source
101
- auth blob hashes match, and the legacy 32-byte key is available. The importer
102
- is transactional and does not mark completion on failure; fix the problem and
103
- rerun rather than editing the migration marker.
package/examples/basic.ts CHANGED
@@ -1,6 +1,8 @@
1
+ import path from 'node:path';
1
2
  import { createBrowser } from '@amalgm/browser';
2
3
 
3
- const browser = createBrowser();
4
+ // Browser keeps everything (Chrome profile, cookies, recordings) in the folder it is handed.
5
+ const browser = createBrowser({ root: path.resolve('browser-state') });
4
6
  const session = await browser.createSession({ id: 'example' });
5
7
  await browser.execute(session.id, { type: 'open', url: 'https://example.com' });
6
8
  console.log(await browser.execute(session.id, { type: 'snapshot' }));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@amalgm/browser",
3
- "version": "0.1.2-preview.37556903313",
3
+ "version": "0.1.2-preview.44182723491",
4
4
  "description": "The amalgm runtime's browser: one Chrome, a session per chat, and the account's cookies in every view.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -58,11 +58,6 @@
58
58
  "import": "./dist/src/testing.js"
59
59
  }
60
60
  },
61
- "bin": {
62
- "amalgm-browser": "./dist/bin/amalgm-browser.js",
63
- "amalgm-browser-mcp": "./dist/bin/amalgm-browser-mcp.js",
64
- "amalgm-browser-rest": "./dist/bin/amalgm-browser-rest.js"
65
- },
66
61
  "files": [
67
62
  "dist",
68
63
  "docs",
@@ -94,7 +89,7 @@
94
89
  "node": ">=24"
95
90
  },
96
91
  "dependencies": {
97
- "@amalgm/core": "0.5.1-preview.37556608028",
92
+ "@amalgm/core": "0.5.1-preview.44182200738",
98
93
  "@ghostery/adblocker": "^2.18.1",
99
94
  "agent-browser": "0.26.0",
100
95
  "better-sqlite3": "^12.10.1",
@@ -130,9 +125,6 @@
130
125
  "real-browser (windows-latest)"
131
126
  ],
132
127
  "verify": "verify",
133
- "cli": [
134
- "amalgm-browser"
135
- ],
136
128
  "peerExports": [
137
129
  "./electron"
138
130
  ]
@@ -151,11 +143,11 @@
151
143
  "@amalgm/core"
152
144
  ]
153
145
  },
154
- "gitHead": "cc53de16c52790d06818838b2d91ea4edbbe4348",
146
+ "gitHead": "658e876d906c8bf791cbb18956a111053385ced9",
155
147
  "amalgmSource": {
156
148
  "repository": "amalgm-inc/amalgm-browser",
157
149
  "branch": "preview",
158
- "commit": "cc53de16c52790d06818838b2d91ea4edbbe4348",
159
- "occurrence": "37556903313"
150
+ "commit": "658e876d906c8bf791cbb18956a111053385ced9",
151
+ "occurrence": "44182723491"
160
152
  }
161
153
  }
@@ -1,46 +1,25 @@
1
1
  ---
2
2
  name: use-amalgm-browser
3
- description: Drive real web pages with Browser (@amalgm/browser) through its MCP server, CLI, or TypeScript SDK — persistent sessions, accessibility snapshots with stable @refs, screenshots, form filling, browser-scoped computer use, WebM recordings, and human login handoff. Use it whenever an agent needs to navigate a site, read or verify page content, fill and submit forms, operate canvas or image-only UIs, browse while authenticated, or record what happened on a page.
3
+ description: Drive real web pages with Browser (@amalgm/browser) through the Amalgm runtime's `browser_*` MCP tools (or `amalgm browser …` in a terminal) or its TypeScript SDK — persistent sessions, accessibility snapshots with stable @refs, screenshots, form filling, browser-scoped computer use, WebM recordings, and human login handoff. Use it whenever an agent needs to navigate a site, read or verify page content, fill and submit forms, operate canvas or image-only UIs, browse while authenticated, or record what happened on a page.
4
4
  ---
5
5
 
6
6
  # Browser
7
7
 
8
- Browser is one safe, persistent, observable way for agents to operate the web. You open a page once into a named session, read it as a structured accessibility snapshot, act on elements through stable references, and only fall back to pixels when pixels are the interface. MCP and the generic CLI action command expose twenty-two product actions. The SDK exposes core browsing through `browser.execute()` and authentication, login handoff, and recording through `browser.auth`, `browser.login`, and `browser.recordings`; REST exposes the same service through action and resource routes.
8
+ Browser is one safe, persistent, observable way for agents to operate the web. You open a page once into a named session, read it as a structured accessibility snapshot, act on elements through stable references, and only fall back to pixels when pixels are the interface. The MCP tools expose twenty-two product actions. The SDK exposes core browsing through `browser.execute()` and authentication, login handoff, and recording through `browser.auth`, `browser.login`, and `browser.recordings`; REST exposes the same service through action and resource routes.
9
9
 
10
- ## Installation
10
+ ## Where Browser runs
11
11
 
12
- Browser requires Node.js 24 or newer.
13
-
14
- ```bash
15
- npm install @amalgm/browser
16
- npx --no-install agent-browser install
17
- ```
18
-
19
- The package installs three executables alongside the SDK:
20
-
21
- - `amalgm-browser` — the CLI; prints stable JSON to stdout.
22
- - `amalgm-browser-mcp` — the MCP server (also reachable as `amalgm-browser mcp`).
23
- - `amalgm-browser-rest` — the authenticated loopback REST API (also `amalgm-browser serve --token <token>`).
12
+ The Amalgm runtime hosts one Browser service. Agents reach it through the platform's `browser_*` MCP tools, listed in [MCP tools](#mcp-tools); there is nothing to install or start. From a terminal, `amalgm browser …` calls the same tools on the running runtime, with the same JSON inputs and results. Screenshots come back as MCP image content; everything else is bounded, sanitized JSON.
24
13
 
25
14
  Browser runs one headless Chrome per runtime and drives it through the bundled `agent-browser`. It uses an installed Chrome, Chromium, or Brave, or the Chrome for Testing that `agent-browser install` downloads; `AMALGM_BROWSER_EXECUTABLE_PATH` picks a specific executable.
26
15
 
27
- ### MCP setup
28
-
29
- To register the MCP server with an MCP-capable client (Claude Code, Cursor, or any client that speaks MCP over stdio), point it at the `amalgm-browser-mcp` binary:
16
+ To embed Browser in your own Node.js 24+ program instead, install the SDK:
30
17
 
31
- ```json
32
- {
33
- "mcpServers": {
34
- "browser": {
35
- "command": "npx",
36
- "args": ["-y", "-p", "@amalgm/browser", "amalgm-browser-mcp"]
37
- }
38
- }
39
- }
18
+ ```bash
19
+ npm install @amalgm/browser
20
+ npx --no-install agent-browser install
40
21
  ```
41
22
 
42
- The server speaks newline-delimited JSON-RPC over stdio and exposes the tools listed in [MCP tools](#mcp-tools). Screenshots come back as MCP image content; everything else is bounded, sanitized JSON.
43
-
44
23
  ## Quickstart
45
24
 
46
25
  Open a page, read it, and click something. With the SDK:
@@ -48,7 +27,8 @@ Open a page, read it, and click something. With the SDK:
48
27
  ```ts
49
28
  import { createBrowser } from '@amalgm/browser';
50
29
 
51
- const browser = createBrowser();
30
+ // Browser keeps everything (Chrome profile, cookies, recordings) in this one folder.
31
+ const browser = createBrowser({ root: '/path/to/browser-state' });
52
32
  const session = await browser.createSession({ id: 'research' });
53
33
 
54
34
  await browser.execute(session.id, { type: 'open', url: 'https://example.com' });
@@ -64,8 +44,6 @@ await browser.close(); // stops Chrome
64
44
 
65
45
  Through MCP the identical sequence is `browser_open`, `browser_snapshot`, `browser_click`, `browser_close`, each taking an optional `session` field. Without it, a call uses the calling chat's session when the host names the chat, and `default` otherwise.
66
46
 
67
- Each CLI command is its own process: it starts Chrome, runs one step, and stops Chrome, so the next command starts on a new blank tab. Use the CLI for single steps such as `amalgm-browser open https://example.com`, and MCP, REST (`amalgm-browser serve`), or the SDK for multi-step flows.
68
-
69
47
  ## Core concepts
70
48
 
71
49
  ### Sessions
@@ -141,7 +119,7 @@ When a task needs a human to log in, let the host provide the login interface. `
141
119
 
142
120
  ## MCP tools
143
121
 
144
- The MCP server exposes twenty-two tools — the canonical action names prefixed with `browser_`. Session actions accept an optional `session` string; without it they use the calling chat's session when the host names the chat, and `default` otherwise. `browser_record_list` and `browser_auth_list` list service-wide metadata, while `browser_auth_link_create` creates a separate login session; these three tools do not accept `session`.
122
+ The runtime exposes twenty-two MCP tools — the canonical action names prefixed with `browser_`. Session actions accept an optional `session` string; without it they use the calling chat's session when the host names the chat, and `default` otherwise. `browser_record_list` and `browser_auth_list` list service-wide metadata, while `browser_auth_link_create` creates a separate login session; these three tools do not accept `session`.
145
123
 
146
124
  | Group | Tools |
147
125
  | --- | --- |
@@ -154,8 +132,6 @@ The MCP server exposes twenty-two tools — the canonical action names prefixed
154
132
 
155
133
  `browser_cli` is the escape hatch: it runs an advanced `agent-browser` argv action for operations outside the canonical set. Prefer the named tools whenever one exists.
156
134
 
157
- The CLI provides direct commands for the fifteen core browsing and computer-use actions, such as `amalgm-browser open` and `amalgm-browser snapshot`. Use `amalgm-browser action <name> --input <json>` for any of the twenty-two product actions, including authentication and recording, or use the resource commands (`sessions`, `auth`, `recordings`, `doctor`).
158
-
159
135
  ## Error handling
160
136
 
161
137
  Failures are typed `BrowserError` values with stable codes:
@@ -170,6 +146,4 @@ Failures are typed `BrowserError` values with stable codes:
170
146
  | `PROCESS_FAILED` | agent-browser, Chrome, or ffmpeg failed — including a stale `@ref` or missing target; re-snapshot and retry that step. |
171
147
  | `SURFACE_IDENTITY_FAILED` | A screenshot, computer-use double-click, or recording could not tell which of the session's tabs is its page; this fails closed. Switch to or close tabs, then retry. |
172
148
 
173
- CLI exit codes map the same taxonomy: `0` success, `2` invalid input, `3` authorization denied, `4` not found, `5` timeout or cancellation, `1` any other typed failure. Pass `--timeout <ms>` to bound any blocking CLI operation.
174
-
175
149
  For the complete target grammar, computer-use operation shapes, and tab, dialog, auth, and recording inputs, see [references/actions.md](references/actions.md).
@@ -1,6 +1,6 @@
1
1
  # Action reference
2
2
 
3
- MCP (`browser_<action>`) and the generic CLI command (`amalgm-browser action <name> --input <json>`) expose the product action catalog. The CLI also has direct commands for core browsing and computer use. SDK core actions use `browser.execute(sessionId, action)`; authentication, login, and recording use `browser.auth`, `browser.login`, and `browser.recordings`. REST provides action and resource routes over those services. This reference covers the input shapes that need more detail than the main page gives.
3
+ The MCP tools (`browser_<action>`, also reachable as `amalgm browser …`) expose the product action catalog. SDK core actions use `browser.execute(sessionId, action)`; authentication, login, and recording use `browser.auth`, `browser.login`, and `browser.recordings`. REST provides action and resource routes over those services. This reference covers the input shapes that need more detail than the main page gives.
4
4
 
5
5
  ## Targets
6
6
 
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- export {};
@@ -1,4 +0,0 @@
1
- #!/usr/bin/env node
2
- import { runBrowserCli } from '../src/cli.js';
3
- process.exitCode = await runBrowserCli(['mcp']);
4
- //# sourceMappingURL=amalgm-browser-mcp.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"amalgm-browser-mcp.js","sourceRoot":"","sources":["../../bin/amalgm-browser-mcp.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAE9C,OAAO,CAAC,QAAQ,GAAG,MAAM,aAAa,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC"}
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- export {};
@@ -1,10 +0,0 @@
1
- #!/usr/bin/env node
2
- import { runBrowserCli } from '../src/cli.js';
3
- // `amalgm-browser serve`, configured from the environment.
4
- const env = process.env;
5
- process.exitCode = await runBrowserCli(['serve',
6
- ...(env.AMALGM_BROWSER_HOST ? ['--host', env.AMALGM_BROWSER_HOST] : []),
7
- ...(env.AMALGM_BROWSER_PORT ? ['--port', env.AMALGM_BROWSER_PORT] : []),
8
- ...(env.AMALGM_BROWSER_ALLOW_REMOTE === '1' ? ['--allow-remote'] : []),
9
- ]);
10
- //# sourceMappingURL=amalgm-browser-rest.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"amalgm-browser-rest.js","sourceRoot":"","sources":["../../bin/amalgm-browser-rest.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAE9C,2DAA2D;AAC3D,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;AACxB,OAAO,CAAC,QAAQ,GAAG,MAAM,aAAa,CAAC,CAAC,OAAO;IAC7C,GAAG,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,GAAG,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IACvE,GAAG,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,GAAG,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IACvE,GAAG,CAAC,GAAG,CAAC,2BAA2B,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;CACvE,CAAC,CAAC"}
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- export {};
@@ -1,4 +0,0 @@
1
- #!/usr/bin/env node
2
- import { runBrowserCli } from '../src/cli.js';
3
- process.exitCode = await runBrowserCli();
4
- //# sourceMappingURL=amalgm-browser.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"amalgm-browser.js","sourceRoot":"","sources":["../../bin/amalgm-browser.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAE9C,OAAO,CAAC,QAAQ,GAAG,MAAM,aAAa,EAAE,CAAC"}
@@ -1,6 +0,0 @@
1
- import type { ProductActionName } from '../actions.js';
2
- import type { ParsedArgs } from './args.js';
3
- export declare function cliAction(args: ParsedArgs): {
4
- name: ProductActionName;
5
- input: Record<string, unknown>;
6
- } | null;
@@ -1,56 +0,0 @@
1
- import { enabled, flag, jsonFlag } from './args.js';
2
- export function cliAction(args) {
3
- const [command, first, second] = args.words;
4
- if (!command)
5
- return null;
6
- if (command === 'action')
7
- return { name: first, input: common(args, jsonFlag(args, 'input')) };
8
- if (!ACTION_NAMES.has(command))
9
- return null;
10
- const input = common(args, ['dialog', 'tab', 'console', 'cua'].includes(command) ? jsonFlag(args, 'input') : {});
11
- if (command === 'open')
12
- input.url = first;
13
- if (command === 'click')
14
- input.target = first;
15
- if (command === 'fill') {
16
- input.target = first;
17
- input.text = second;
18
- if (enabled(args, 'submit'))
19
- input.submit = true;
20
- }
21
- if (command === 'press')
22
- input.key = first;
23
- if (command === 'select') {
24
- input.target = first;
25
- input.value = second;
26
- }
27
- if (command === 'eval')
28
- input.script = first;
29
- if (command === 'wait') {
30
- if (flag(args, 'selector'))
31
- input.selector = flag(args, 'selector');
32
- if (flag(args, 'url'))
33
- input.url = flag(args, 'url');
34
- if (flag(args, 'ms'))
35
- input.ms = Number(flag(args, 'ms'));
36
- }
37
- if (command === 'screenshot' && enabled(args, 'full-page'))
38
- input.fullPage = true;
39
- if (command === 'cli')
40
- input.args = args.words.slice(1);
41
- return { name: command, input };
42
- }
43
- function common(args, input) {
44
- const session = flag(args, 'session');
45
- const timeout = flag(args, 'timeout');
46
- return {
47
- ...input,
48
- ...(session ? { session } : {}),
49
- ...(timeout ? { timeoutMs: Number(timeout) } : {}),
50
- };
51
- }
52
- const ACTION_NAMES = new Set([
53
- 'open', 'snapshot', 'screenshot', 'click', 'fill', 'press', 'select', 'eval',
54
- 'wait', 'cli', 'dialog', 'tab', 'console', 'cua', 'close',
55
- ]);
56
- //# sourceMappingURL=actions.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"actions.js","sourceRoot":"","sources":["../../../../src/adapters/cli/actions.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAEpD,MAAM,UAAU,SAAS,CAAC,IAAgB;IACxC,MAAM,CAAC,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC;IAC5C,IAAI,CAAC,OAAO;QAAE,OAAO,IAAI,CAAC;IAC1B,IAAI,OAAO,KAAK,QAAQ;QAAE,OAAO,EAAE,IAAI,EAAE,KAA0B,EAAE,KAAK,EAAE,MAAM,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,EAAE,CAAC;IACpH,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,OAAO,CAAC;QAAE,OAAO,I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;YAAE,KAAK,CAAC,EAAE,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;IAC5D,CAAC;IACD,IAAI,OAAO,KAAK,YAAY,IAAI,OAAO,CAAC,IAAI,EAAE,WAAW,CAAC;QAAE,KAAK,CAAC,QAAQ,GAAG,IAAI,CAAC;IAClF,IAAI,OAAO,KAAK,KAAK;QAAE,KAAK,CAAC,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACxD,OAAO,EAAE,IAAI,EAAE,OAA4B,EAAE,KAAK,EAAE,CAAC;AACvD,CAAC;AAED,SAAS,MAAM,CAAC,IAAgB,EAAE,KAA8B;IAC9D,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;IACtC,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;IACtC,OAAO;QACL,GAAG,KAAK;QACR,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC/B,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KACnD,CAAC;AACJ,CAAC;AAED,MAAM,YAAY,GAAG,IAAI,GAAG,CAAC;IAC3B,MAAM,EAAE,UAAU,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM;IAC5E,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO;CAC1D,CAAC,CAAC"}
@@ -1,8 +0,0 @@
1
- export interface ParsedArgs {
2
- words: string[];
3
- flags: Map<string, string | boolean>;
4
- }
5
- export declare function parseArgs(argv: string[]): ParsedArgs;
6
- export declare function flag(args: ParsedArgs, name: string): string | undefined;
7
- export declare function enabled(args: ParsedArgs, name: string): boolean;
8
- export declare function jsonFlag(args: ParsedArgs, name: string): Record<string, unknown>;
@@ -1,41 +0,0 @@
1
- export function parseArgs(argv) {
2
- const words = [];
3
- const flags = new Map();
4
- for (let index = 0; index < argv.length; index += 1) {
5
- const item = argv[index];
6
- if (!item?.startsWith('--')) {
7
- if (item !== undefined)
8
- words.push(item);
9
- continue;
10
- }
11
- const [name = '', inline] = item.slice(2).split('=', 2);
12
- const next = argv[index + 1];
13
- if (inline !== undefined)
14
- flags.set(name, inline);
15
- else if (next !== undefined && !next.startsWith('--')) {
16
- flags.set(name, next);
17
- index += 1;
18
- }
19
- else
20
- flags.set(name, true);
21
- }
22
- return { words, flags };
23
- }
24
- export function flag(args, name) {
25
- const value = args.flags.get(name);
26
- return typeof value === 'string' ? value : undefined;
27
- }
28
- export function enabled(args, name) {
29
- const value = args.flags.get(name);
30
- return value === true || value === 'true';
31
- }
32
- export function jsonFlag(args, name) {
33
- const value = flag(args, name);
34
- if (!value)
35
- return {};
36
- const parsed = JSON.parse(value);
37
- if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed))
38
- throw new Error(`--${name} must be a JSON object.`);
39
- return parsed;
40
- }
41
- //# sourceMappingURL=args.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"args.js","sourceRoot":"","sources":["../../../../src/adapters/cli/args.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,SAAS,CAAC,IAAc;IACtC,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,MAAM,KAAK,GAAG,IAAI,GAAG,EAA4B,CAAC;IAClD,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,IAAI,CAAC,MAAM,EAAE,KAAK,IAAI,CAAC,EAAE,CAAC;QACpD,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC;QACzB,IAAI,CAAC,IAAI,EAAE,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;YAAC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IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAC/B,IAAI,CAAC,KAAK;QAAE,OAAO,EAAE,CAAC;IACtB,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAY,CAAC;IAC5C,IAAI,CAAC,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,KAAK,IAAI,yBAAyB,CAAC,CAAC;IACxH,OAAO,MAAiC,CAAC;AAC3C,CAAC"}
@@ -1 +0,0 @@
1
- export declare const HELP = "amalgm-browser \u2014 persistent browser automation\n\nActions:\n amalgm-browser open <url> [--session id]\n amalgm-browser snapshot|screenshot|close\n amalgm-browser click <target>\n amalgm-browser fill <target> <text> [--submit]\n amalgm-browser press <key>\n amalgm-browser select <target> <value>\n amalgm-browser eval <script>\n amalgm-browser wait [--selector css|--url value|--ms number]\n amalgm-browser dialog|tab|console|cua --input <json>\n amalgm-browser action <name> --input <json>\n\nResources:\n amalgm-browser sessions list|get|close|cancel|prune [id]\n amalgm-browser auth list|link|save|load|delete\n amalgm-browser recordings start [--duration-ms n]|stop|cancel|list|get\n amalgm-browser doctor\n amalgm-browser serve [--port 0] [--host 127.0.0.1]\n amalgm-browser mcp\n\nGlobal options:\n --session <id> --root <path> --cwd <project> --json --timeout <ms>\n";
@@ -1,26 +0,0 @@
1
- export const HELP = `amalgm-browser — persistent browser automation
2
-
3
- Actions:
4
- amalgm-browser open <url> [--session id]
5
- amalgm-browser snapshot|screenshot|close
6
- amalgm-browser click <target>
7
- amalgm-browser fill <target> <text> [--submit]
8
- amalgm-browser press <key>
9
- amalgm-browser select <target> <value>
10
- amalgm-browser eval <script>
11
- amalgm-browser wait [--selector css|--url value|--ms number]
12
- amalgm-browser dialog|tab|console|cua --input <json>
13
- amalgm-browser action <name> --input <json>
14
-
15
- Resources:
16
- amalgm-browser sessions list|get|close|cancel|prune [id]
17
- amalgm-browser auth list|link|save|load|delete
18
- amalgm-browser recordings start [--duration-ms n]|stop|cancel|list|get
19
- amalgm-browser doctor
20
- amalgm-browser serve [--port 0] [--host 127.0.0.1]
21
- amalgm-browser mcp
22
-
23
- Global options:
24
- --session <id> --root <path> --cwd <project> --json --timeout <ms>
25
- `;
26
- //# sourceMappingURL=help.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"help.js","sourceRoot":"","sources":["../../../../src/adapters/cli/help.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,IAAI,GAAG;;;;;;;;;;;;;;;;;;;;;;;;CAwBnB,CAAC"}
@@ -1,4 +0,0 @@
1
- import type { BrowserProductService } from '../../product-service.js';
2
- import type { ParsedArgs } from './args.js';
3
- import type { BrowserRuntimeContext } from '../../types.js';
4
- export declare function resourceCommand(browser: BrowserProductService, args: ParsedArgs, context?: BrowserRuntimeContext): Promise<unknown>;