@jackwener/browsermcp 0.0.34-embedded.1 → 0.0.34-embedded.3
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.
- package/CHANGELOG.md +12 -0
- package/README.md +4 -5
- package/dist/docs/api-reference.md +6 -3
- package/dist/docs/js-tool.md +2 -0
- package/dist/docs/tab-lifecycle.md +2 -2
- package/dist/src/api/browser.d.ts +1 -0
- package/dist/src/api/browser.js +16 -3
- package/dist/src/api/browser.js.map +1 -1
- package/dist/src/api/tab.d.ts +8 -1
- package/dist/src/api/tab.js +14 -1
- package/dist/src/api/tab.js.map +1 -1
- package/dist/src/backends/managed-page.d.ts +2 -0
- package/dist/src/docs/embedded.js +6 -2
- package/dist/src/docs/embedded.js.map +1 -1
- package/dist/src/electron/backend.d.ts +5 -3
- package/dist/src/electron/backend.js +69 -58
- package/dist/src/electron/backend.js.map +1 -1
- package/dist/src/electron/registry.d.ts +14 -3
- package/dist/src/electron/registry.js +89 -32
- package/dist/src/electron/registry.js.map +1 -1
- package/dist/src/embedded/index.d.ts +3 -5
- package/dist/src/embedded/index.js +4 -2
- package/dist/src/embedded/index.js.map +1 -1
- package/dist/src/mcp/js-worker.mjs +5 -0
- package/dist/src/mcp/server.js +2 -2
- package/dist/src/mcp/server.js.map +1 -1
- package/dist/src/protocol.d.ts +1 -1
- package/dist/src/runtime/runtime.d.ts +1 -1
- package/dist/src/runtime/runtime.js +2 -2
- package/dist/src/runtime/runtime.js.map +1 -1
- package/docs/api-reference.md +6 -3
- package/docs/js-tool.md +2 -0
- package/docs/releasing.md +14 -3
- package/docs/tab-lifecycle.md +2 -2
- package/extension/dist/background.js +3 -4
- package/package.json +2 -2
package/docs/api-reference.md
CHANGED
|
@@ -34,7 +34,7 @@ class Browser {
|
|
|
34
34
|
};
|
|
35
35
|
tabs: {
|
|
36
36
|
new(url?: string): Promise<Tab>;
|
|
37
|
-
list(): Promise<Array<{ id?: string; tabId: number; pending?: true; url?: string; title?: string; active: boolean; selected: boolean; origin: "agent" | "user"; state: "active" | "handoff"; }>>;
|
|
37
|
+
list(): Promise<Array<{ id?: string; tabId: number; pending?: true; url?: string; title?: string; active: boolean; selected: boolean; lifecycle?: "dormant" | "loading" | "ready"; origin: "agent" | "user"; state: "active" | "handoff"; }>>;
|
|
38
38
|
get(tab: string | { tab?: string; tabId: number; }, opts?: { timeoutMs?: number; }): Promise<Tab>;
|
|
39
39
|
selected(): Promise<Tab | undefined>;
|
|
40
40
|
finalize(opts?: { keep?: Array<{ tab: string | Tab; status: "handoff" | "deliverable"; }>; }): Promise<{ closed: Array<string>; kept: Array<string>; failed: Array<{ page: string; reason: string; }>; }>;
|
|
@@ -53,9 +53,12 @@ class Browser {
|
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
class Tab {
|
|
56
|
-
tabId?: number; // `id` is the
|
|
56
|
+
tabId?: number; // `id` is the stable backend page handle; `tabId` is the numeric backend id when claimed from a user tab.
|
|
57
57
|
id: string;
|
|
58
58
|
goto(url: string, opts?: { waitUntil?: "load" | "none"; settleMs?: number; }): Promise<{ url: string | null; title: string | null; }>;
|
|
59
|
+
markDeliverable(): Promise<void>; // Preserve this tab for the user when the session is finalized.
|
|
60
|
+
markHandoff(): Promise<void>; // Preserve this tab for a subsequent turn; it must be claimed again after finalization.
|
|
61
|
+
clearRetention(): Promise<void>; // Restore default cleanup: close agent tabs, release borrowed user tabs.
|
|
59
62
|
url(): Promise<string | null>;
|
|
60
63
|
title(): Promise<string | null>;
|
|
61
64
|
back(): Promise<void>;
|
|
@@ -164,7 +167,7 @@ interface DialogInfo { type: 'alert' | 'confirm' | 'prompt' | 'beforeunload'; me
|
|
|
164
167
|
|
|
165
168
|
interface ConsoleEntry { seq: number; level: 'debug' | 'info' | 'log' | 'warn' | 'error'; message: string; timestamp: string; url?: string; line?: number }
|
|
166
169
|
|
|
167
|
-
interface UserTabInfo { tabId: number; title?: string; url?: string; windowId: number; active: boolean; groupId?: number; lastAccessed?: number }
|
|
170
|
+
interface UserTabInfo { tabId: number; title?: string; url?: string; windowId: number; active: boolean; groupId?: number; lastAccessed?: number; lifecycle?: 'dormant' | 'loading' | 'ready'; availability?: 'ready' | 'load_required' | 'host_attachment_required' }
|
|
168
171
|
|
|
169
172
|
interface CloseUserTabsResult {
|
|
170
173
|
complete: boolean;
|
package/docs/js-tool.md
CHANGED
|
@@ -34,3 +34,5 @@ Refs are opaque Element identities shared by ARIA, DOM and find. Copy them uncha
|
|
|
34
34
|
Finish with `session_finalize`. Use `doctor` for connection/execution status and `js_reset` to stop JavaScript, clear bindings and close explicit subscriptions; tabs stay open. Read `repl-session` for Node declaration semantics, errors, timeout/reset and images. Request `api-reference` with `member:"Tab.act"`, `"Tab.network"`, `"Browser"` or another class/member for exact signatures; omit member for the full reference.
|
|
35
35
|
|
|
36
36
|
Reuse the same target for verification: `await tab.expect({target, value:"42"})`. Continue captured output with `tab.observe(result.next)` or `tab.read(result.next)`. Pass an `openedTabs` entry directly to `browser.tabs.get`, and the returned download object to `tab.download(result.download)`.
|
|
37
|
+
|
|
38
|
+
Tab handles expose async methods: use `await tab.url()` and `await tab.title()`. Entries returned by `browser.tabs.list()` are snapshots with string `url` and `title` fields. Inspecting or converting a remote method to a string describes the method locally; it never reads the page.
|
package/docs/releasing.md
CHANGED
|
@@ -7,13 +7,16 @@ The npm package and Chrome extension have separate versions. Each npm release al
|
|
|
7
7
|
In the [browsermcp npm package settings](https://www.npmjs.com/package/@jackwener/browsermcp), add a **Trusted Publisher** for GitHub Actions:
|
|
8
8
|
|
|
9
9
|
- GitHub owner: `jackwener`
|
|
10
|
-
- Repository: `
|
|
10
|
+
- Repository: `BrowserMCP` (case-sensitive)
|
|
11
11
|
- Workflow filename: `release.yml`
|
|
12
12
|
- Environment: leave blank
|
|
13
|
+
- Allowed actions: enable **Allow npm publish** for direct, unattended releases. Stage-only publishing requires human approval for every release.
|
|
14
|
+
|
|
15
|
+
The owner, repository and workflow filename must match exactly. New publisher configurations must complete their first successful publish within two days; expired or incorrectly configured entries must be replaced in npm package settings.
|
|
13
16
|
|
|
14
17
|
The workflow uses GitHub OIDC to publish to npm. It does not need an `NPM_TOKEN` secret. GitHub Actions must be enabled for this repository.
|
|
15
18
|
|
|
16
|
-
|
|
19
|
+
Trusted Publisher configuration belongs to `@jackwener/browsermcp`; another package's configuration does not carry over. Upload **BrowserMCP Connector** as an update to the existing Web Store item, preserving its extension ID and incrementing the extension version.
|
|
17
20
|
|
|
18
21
|
## Each release
|
|
19
22
|
|
|
@@ -21,7 +24,7 @@ The rename creates a new npm package, `@jackwener/browsermcp`. Before the first
|
|
|
21
24
|
2. Open [Actions → Release npm package and manual extension](https://github.com/jackwener/browsermcp/actions/workflows/release.yml), choose **Run workflow** on `main`, and enter an unused version such as `0.0.20`.
|
|
22
25
|
3. Optionally enter release notes. If omitted, the workflow uses commit subjects since the previous tag. An existing `CHANGELOG.md` section for that version takes precedence.
|
|
23
26
|
|
|
24
|
-
The workflow updates `package.json`, `package-lock.json`, and `CHANGELOG.md`, runs a small set of checks, builds and installs the tarball, validates that the extension's public key produces the ID allowed by the native host, commits the release version, pushes its tag, publishes to npm with provenance, creates a GitHub Release with the tarball and manual-install extension zip
|
|
27
|
+
The workflow updates `package.json`, `package-lock.json`, and `CHANGELOG.md`, runs a small set of checks, builds and installs the tarball, validates that the extension's public key produces the ID allowed by the native host, commits the release version, pushes its tag, publishes to npm with provenance, verifies the version and channel on npm, and only then creates a GitHub Release with the tarball and manual-install extension zip. Re-run the same version if publication or release creation fails after the tag was pushed; it checks the existing tag and package instead of bumping again.
|
|
25
28
|
|
|
26
29
|
The manual-install zip keeps `manifest.key` and is meant to be extracted and loaded through Chrome's **Load unpacked**. The `npm run pack:store` zip removes that key and is only for Web Store upload. Do not use the store zip for manual installation. The extension manifest version is independent of the npm package version.
|
|
27
30
|
|
|
@@ -34,3 +37,11 @@ The embedded job checks types and adapter isolation, builds the package, and run
|
|
|
34
37
|
Consumers install `npm install @jackwener/browsermcp@embedded` and import `@jackwener/browsermcp/embedded`. Pin the exact prerelease version for reproducible application builds.
|
|
35
38
|
|
|
36
39
|
Keep `codex/embedded-electron` exactly one commit above current `main`: land shared changes on `main`, then rebase and squash the Electron-specific change. The embedded release job enforces this relationship and amends version/changelog changes into that single commit, pushing with an explicit lease. Existing published tags remain immutable.
|
|
40
|
+
|
|
41
|
+
## Authentication failures
|
|
42
|
+
|
|
43
|
+
Do not fall back to local `npm login`, interactive publishing, or a long-lived `NPM_TOKEN`. Inspect the package's Trusted Publisher configuration against the values above, especially repository capitalization, `release.yml`, the blank environment and **Allow npm publish**. The workflow already runs on GitHub-hosted runners with Node 24, npm 11.5.1+ and `id-token: write`. `npm whoami` checks local credentials, not OIDC permissions. Verify the configuration by publishing through this workflow.
|
|
44
|
+
|
|
45
|
+
The workflow never requests a maintainer's OTP. If direct publishing is not permitted, fix the one-time trust configuration rather than approving a staged package for each release. Keep published tags immutable; retry the same version only from the same release commit.
|
|
46
|
+
|
|
47
|
+
Reference: [npm Trusted Publishing](https://docs.npmjs.com/trusted-publishers/).
|
package/docs/tab-lifecycle.md
CHANGED
|
@@ -4,11 +4,11 @@ Use these methods in `js`, awaiting every call. Start with `await browser.nameSe
|
|
|
4
4
|
|
|
5
5
|
To use an existing tab, call `await browser.user.openTabs({query:'…',limit:20})`, then `let tab = await browser.user.claimTab({tabId})`. Discovery is recency-sorted, defaults to 20 matches and is capped at 100; it is not a complete browser inventory. To claim the foreground tab, use `{active:true}`. Unique URL/title lookup is also supported; `expectedUrl` and `expectedTitle` check exact identity when necessary. Claiming alone does not observe the page. Claimed user tabs stay outside the agent group and are never closed by finalize.
|
|
6
6
|
|
|
7
|
-
`await browser.tabs.list()` returns controlled tabs with string `id`, numeric
|
|
7
|
+
`await browser.tabs.list()` returns controlled tabs with string `id`, numeric backend `tabId`, `origin` and `state`. Obtain a handle with `await browser.tabs.get(id)`. The page id is stable across navigation and becomes stale after logical closure. In Electron it also survives WebContents replacement; `lifecycle` reports dormant, loading or ready. A newly attaching extension tab may return `pending:true` without an id; match its numeric `tabId` on a later list call. Unknown ids are rejected rather than adopted.
|
|
8
8
|
|
|
9
9
|
`await tab.release()` keeps the tab open and gives up control; an agent-created tab leaves only its temporary session group and is unmuted unless its mute state is native (a raw-created tab or an explicit `tabs.update({muted})` call). User-arranged groups are preserved. `await tab.close()` closes a controlled tab. For bulk user-tab cleanup, use `await browser.user.closeTabs([tabId1,tabId2])` without claiming; its result reports `closed` and `failed` ids. Keep discovery and planning in REPL variables, and return a summary before the next decision. Do not move every row into the conversation.
|
|
10
10
|
|
|
11
|
-
Finish with the MCP tool `session_finalize`, or `await browser.tabs.finalize({keep:[{tab,status:'deliverable'}]})` in `js`. `deliverable` tabs leave temporary session groups and stay open; explicitly arranged groups are preserved; `handoff` tabs stay grouped for a later turn; other agent tabs close. Failed tabs retain their lease for retry. After successful finalize, old handles are released; obtain fresh handles in a later turn. Let running JavaScript finish before calling the separate finalize tool.
|
|
11
|
+
Prefer `await tab.markDeliverable()` to preserve a result, `await tab.markHandoff()` to retain control for a later turn, and `await tab.clearRetention()` to remove a mark. Marks belong to the logical tab and do not require a loaded page. Finish with the MCP tool `session_finalize`, or `await browser.tabs.finalize({keep:[{tab,status:'deliverable'}]})` in `js`. Explicit keep entries override stored marks and require the complete `tab.id` or a Tab handle in JavaScript, never a variable name or numeric `tabId`. Invalid keep entries abort before any cleanup. `deliverable` tabs leave temporary session groups and stay open; explicitly arranged groups are preserved; `handoff` tabs stay grouped for a later turn; other agent tabs close. Failed tabs retain their lease for retry. After successful finalize, old handles are released; obtain fresh handles in a later turn. Let running JavaScript finish before calling the separate finalize tool.
|
|
12
12
|
|
|
13
13
|
Resetting JavaScript leaves browser tabs open. Closing the MCP client closes its local IPC connection and finalizes only that connection’s session. A host restart creates a new session; `session_restarted` means rebuild REPL bindings and inspect the browser before continuing. An idle browser session is finalized after an hour.
|
|
14
14
|
|
|
@@ -2087,10 +2087,9 @@ var SessionManager = class {
|
|
|
2087
2087
|
const failed = [];
|
|
2088
2088
|
const keepByTab = /* @__PURE__ */ new Map();
|
|
2089
2089
|
for (const k of keep) {
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
}
|
|
2090
|
+
const tabId = await resolveTabId(k.page);
|
|
2091
|
+
if (!s.leases.has(tabId)) throw new SessionError("page_not_in_session", `Cannot keep tab ${k.page}: it is not owned by this session`);
|
|
2092
|
+
keepByTab.set(tabId, k.status);
|
|
2094
2093
|
}
|
|
2095
2094
|
for (const lease of [...s.leases.values()]) {
|
|
2096
2095
|
const status = keepByTab.get(lease.tabId) ?? lease.mark ?? null;
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jackwener/browsermcp",
|
|
3
|
-
"version": "0.0.34-embedded.
|
|
3
|
+
"version": "0.0.34-embedded.3",
|
|
4
4
|
"description": "Chrome-backed MCP browser service with optional site adapters.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
|
-
"url": "git+https://github.com/jackwener/
|
|
7
|
+
"url": "git+https://github.com/jackwener/BrowserMCP.git"
|
|
8
8
|
},
|
|
9
9
|
"keywords": [
|
|
10
10
|
"mcp",
|