tab-ferre 0.0.0-stage → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CONTEXT.md +29 -0
- package/INSTALL.md +110 -0
- package/INSTALL.zh-CN.md +45 -0
- package/README.md +152 -2
- package/README.zh-CN.md +151 -0
- package/assets/logo.png +0 -0
- package/bin/bootstrap.sh +77 -0
- package/bin/tab-ferre.js +415 -0
- package/docs/reference.md +218 -0
- package/docs/reference.zh-CN.md +218 -0
- package/extension/_locales/en/messages.json +88 -0
- package/extension/_locales/zh_CN/messages.json +88 -0
- package/extension/command.js +84 -0
- package/extension/connection.js +140 -0
- package/extension/errors.js +53 -0
- package/extension/icon-128.png +0 -0
- package/extension/icon-16.png +0 -0
- package/extension/icon-32.png +0 -0
- package/extension/icon-48.png +0 -0
- package/extension/input.js +114 -0
- package/extension/managed-tabs.js +839 -0
- package/extension/manifest.json +18 -0
- package/extension/native-page.js +1336 -0
- package/extension/options.css +5 -0
- package/extension/options.html +9 -0
- package/extension/options.js +21 -0
- package/extension/page.js +443 -0
- package/extension/policy.js +95 -0
- package/extension/worker.js +3 -0
- package/package.json +53 -4
- package/skill/GUIDE.md +76 -0
- package/skill/SKILL.md +16 -0
- package/skills/tab-ferre.yaml +5 -0
- package/src/actions.js +305 -0
- package/src/agent-clients.js +140 -0
- package/src/archive.js +58 -0
- package/src/batch.js +164 -0
- package/src/browser.js +95 -0
- package/src/chrome-profile.js +126 -0
- package/src/client-config.js +243 -0
- package/src/client.js +55 -0
- package/src/config.js +35 -0
- package/src/doctor.js +115 -0
- package/src/errors.js +96 -0
- package/src/files.js +18 -0
- package/src/framing.js +31 -0
- package/src/host.js +181 -0
- package/src/install-state.js +39 -0
- package/src/installation.js +159 -0
- package/src/lifecycle.js +41 -0
- package/src/mcp.js +134 -0
- package/src/native-bridge.js +85 -0
- package/src/native-launcher.cjs +53 -0
- package/src/report.js +116 -0
- package/src/rpc.js +13 -0
- package/src/runtime.js +188 -0
- package/src/service.js +40 -0
- package/src/setup.js +182 -0
- package/src/skills.js +73 -0
- package/src/uninstall.js +96 -0
- package/src/update.js +150 -0
- package/src/workspace.js +425 -0
package/CONTEXT.md
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# TabFerre
|
|
2
|
+
|
|
3
|
+
TabFerre 为 Agent 提供日常浏览器中的后台标签,并让用户随时接管。以下词汇描述租户、轮次、标签和控制权之间的关系。
|
|
4
|
+
|
|
5
|
+
## Language
|
|
6
|
+
|
|
7
|
+
**租户**(owner):
|
|
8
|
+
一个 MCP 进程或 CLI Agent 在 host 中的隔离命名空间,拥有自己的会话、轮次、配额和租约。租户之间不能互相观测或操作。
|
|
9
|
+
_Avoid_:用户、账号
|
|
10
|
+
|
|
11
|
+
**轮次**(round):
|
|
12
|
+
一条用户消息对应的工作单元。它有名字(用户意图)、一个 Chrome 标签组和最多 10 个并发后台标签;轮次结束时关闭 Agent 标签并移除分组。
|
|
13
|
+
_Avoid_:任务、分组
|
|
14
|
+
|
|
15
|
+
**后台标签**:
|
|
16
|
+
TabFerre 为当前轮次创建并管理的浏览器标签;用户可接管其中的页面。同一个轮次里的标签共用一个 Chrome 分组。
|
|
17
|
+
_Avoid_:沙箱浏览器、普通标签
|
|
18
|
+
|
|
19
|
+
**会话**:
|
|
20
|
+
host 中一个后台标签的身份与活动记录,关联站点、所属租户和所属轮次;标签关闭后记录仍可保留。
|
|
21
|
+
_Avoid_:轮次、分组
|
|
22
|
+
|
|
23
|
+
**控制权**:
|
|
24
|
+
决定某个后台标签当前由 Agent 还是用户操作的独占资格。
|
|
25
|
+
_Avoid_:焦点、连接状态
|
|
26
|
+
|
|
27
|
+
**快照**:
|
|
28
|
+
页面在某一时刻的语义描述,包含可识别的页面内容、控件状态及元素引用。
|
|
29
|
+
_Avoid_:截图
|
package/INSTALL.md
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
# Install TabFerre — instructions for the agent
|
|
2
|
+
|
|
3
|
+
[English](INSTALL.md) · [简体中文](INSTALL.zh-CN.md)
|
|
4
|
+
|
|
5
|
+
When the user asks to install, connect, repair, update or uninstall TabFerre,
|
|
6
|
+
carry out the commands yourself. Complete the local work before handing a Chrome
|
|
7
|
+
confirmation to the user. Resume verification after the user finishes that
|
|
8
|
+
confirmation.
|
|
9
|
+
|
|
10
|
+
## Platform support
|
|
11
|
+
|
|
12
|
+
TabFerre supports macOS and Linux with desktop Chrome 120+. Windows is not
|
|
13
|
+
supported yet: Chrome native messaging on Windows needs registry registration
|
|
14
|
+
and an executable launcher, which this release does not provide. The npm package
|
|
15
|
+
declares `os: ["darwin", "linux"]`, and setup reports `UNSUPPORTED_PLATFORM` on
|
|
16
|
+
Windows. Do not claim a Windows installation succeeded. The extension UI follows
|
|
17
|
+
Chrome's UI language; this guide is available in English and Chinese
|
|
18
|
+
(`tab-ferre install-guide --zh-CN`).
|
|
19
|
+
|
|
20
|
+
## Install
|
|
21
|
+
|
|
22
|
+
1. Check the OS and `node --version`. Native host registration supports macOS and
|
|
23
|
+
Linux. Report `UNSUPPORTED_PLATFORM` on Windows; do not claim it is installed.
|
|
24
|
+
2. With Node.js 22+ and npx available, execute:
|
|
25
|
+
|
|
26
|
+
```sh
|
|
27
|
+
npx -y tab-ferre@latest setup --json
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
With Node absent or older, execute this distribution's
|
|
31
|
+
[`bin/bootstrap.sh`](bin/bootstrap.sh). It downloads Node 24 from nodejs.org,
|
|
32
|
+
verifies its SHA-256 checksum and installs it privately under
|
|
33
|
+
`~/.tab-ferre/node`, then runs the same setup. It needs curl, tar and a SHA-256
|
|
34
|
+
tool. Use the bootstrap from the same trusted release or repository as this
|
|
35
|
+
document. No sudo, global Node replacement or shell profile edits are needed.
|
|
36
|
+
3. Parse the JSON. `ok: true` means local installation finished; `ready: true`
|
|
37
|
+
means the browser connection and selected client registrations are ready.
|
|
38
|
+
Setup installs the runtime, native host and skill, and registers detected
|
|
39
|
+
agent clients (CLI, desktop and IDE). `--client <id>[,<id>]` or
|
|
40
|
+
`--client none` selects an explicit scope; ids are listed by setup and in
|
|
41
|
+
`src/client-config.js`.
|
|
42
|
+
4. Handle each `next` item in order:
|
|
43
|
+
- `actor: agent`: fix or retry the reported local step. For client registration
|
|
44
|
+
failures, inspect `clients` and use its executable/argument array or the
|
|
45
|
+
returned `mcp` configuration. Preserve unrelated client settings.
|
|
46
|
+
- `actor: human`: open the returned Chrome URL with the available approved
|
|
47
|
+
browser path, then hand off for Chrome's installation/permission confirmation.
|
|
48
|
+
Keep the question limited to that confirmation. When Chrome is closed,
|
|
49
|
+
running setup with `--open-extension-page` enables developer mode, opens
|
|
50
|
+
`chrome://extensions` and copies the unpacked directory; the human still
|
|
51
|
+
selects the directory and confirms.
|
|
52
|
+
- The store URL and ID come from the installer. A release without a configured
|
|
53
|
+
store ID returns the unpacked directory and developer-mode handoff instead.
|
|
54
|
+
This is a development build, not a completed store release.
|
|
55
|
+
5. Use the returned absolute `mcp.command` as Node and `mcp.args[0]` as the installed
|
|
56
|
+
CLI path for subsequent shell calls. This also works with the private Node.
|
|
57
|
+
Run that CLI with `start`, then `doctor --json`. Doctor must report `ok: true`.
|
|
58
|
+
A client may need its MCP connection reloaded before new tools appear.
|
|
59
|
+
6. Verify one actual browser operation with CLI or newly available MCP tools:
|
|
60
|
+
open `https://example.org` in a new round named `verify install`, snapshot it,
|
|
61
|
+
confirm its title, then end the round. Finish only when this succeeds, or report
|
|
62
|
+
the exact remaining handoff/error. Never claim success solely from setup's exit code.
|
|
63
|
+
|
|
64
|
+
Setup is repeatable. A concurrent installer or unfinished browser task returns
|
|
65
|
+
`UPDATE_BUSY`; finish your own tasks, then retry. Leave other agents' and human
|
|
66
|
+
tabs alone. `HOST_MIGRATION_REQUIRED` identifies an old host without maintenance
|
|
67
|
+
support: let the user finish their work and quit Chrome, run setup while Chrome
|
|
68
|
+
is closed, then reopen it and verify. Restarting Chrome before setup would
|
|
69
|
+
launch the same old host again.
|
|
70
|
+
|
|
71
|
+
## Update and repair
|
|
72
|
+
|
|
73
|
+
Published npm installations enable local automatic updates by default.
|
|
74
|
+
Source installs leave them off. `setup --auto-update` or
|
|
75
|
+
`setup --auto-update=false` sets the preference explicitly.
|
|
76
|
+
|
|
77
|
+
While Chrome runs, the host checks for releases at most daily, with an hourly
|
|
78
|
+
retry after network failures. Downloads use exact stable versions from npm's
|
|
79
|
+
canonical registry, integrity verification and disabled install scripts. Active
|
|
80
|
+
tabs defer activation; an idle installation applies a pending update within about
|
|
81
|
+
a minute. All managed tabs, including human-controlled tabs, must be finished.
|
|
82
|
+
There is no scheduled task when Chrome is closed.
|
|
83
|
+
|
|
84
|
+
For a manual update, run the installed CLI with `update --json`.
|
|
85
|
+
`state: deferred` means the download is ready and activation will wait for idle.
|
|
86
|
+
`state: previous_failure` means the automatic updater is retaining the working
|
|
87
|
+
version after a failed installation or startup; inspect `~/.tab-ferre/updates.json` and repair
|
|
88
|
+
before retrying manually. Re-running `npx -y tab-ferre@latest setup --json` also
|
|
89
|
+
repairs integration files and refreshes the skill.
|
|
90
|
+
|
|
91
|
+
The previous runtime is retained. Activation errors restore it; the stable native
|
|
92
|
+
launcher also restores it if a new host exits before initializing its socket.
|
|
93
|
+
The extension and local program negotiate a protocol version, so compatible
|
|
94
|
+
release numbers can differ. `VERSION_MISMATCH` needs an agent-assisted upgrade of
|
|
95
|
+
both components. Store extensions update through Chrome; unpacked development
|
|
96
|
+
extensions still need a human reload.
|
|
97
|
+
|
|
98
|
+
## Uninstall
|
|
99
|
+
|
|
100
|
+
When the user asks to remove TabFerre, run the installed CLI with
|
|
101
|
+
`uninstall --json` (or `npx -y tab-ferre@latest uninstall --json`). The command
|
|
102
|
+
removes the native host manifests and wrapper, the unpacked extension directory,
|
|
103
|
+
the agent skill and the `tab-ferre` entries from detected MCP clients. It refuses
|
|
104
|
+
to run while managed browser tasks are active (`UPDATE_BUSY`). Add `--keep-state`
|
|
105
|
+
to preserve `~/.tab-ferre` logs, sessions and runtime.
|
|
106
|
+
|
|
107
|
+
After it finishes, tell the user to remove TabFerre in `chrome://extensions` and
|
|
108
|
+
restart Chrome; the CLI cannot remove an extension loaded in a running browser.
|
|
109
|
+
If the package was installed globally, also run `npm uninstall -g tab-ferre`.
|
|
110
|
+
Do not delete unrelated MCP client settings.
|
package/INSTALL.zh-CN.md
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# 安装 TabFerre —— 给 Agent 的说明
|
|
2
|
+
|
|
3
|
+
[English](INSTALL.md) · [简体中文](INSTALL.zh-CN.md)
|
|
4
|
+
|
|
5
|
+
当用户要求安装、连接、修复、更新或卸载 TabFerre 时,由你执行这些命令。先完成本地步骤,再把 Chrome 的确认交给用户;用户确认后继续验证。
|
|
6
|
+
|
|
7
|
+
## 平台支持
|
|
8
|
+
|
|
9
|
+
TabFerre 支持 macOS 与 Linux + 桌面 Chrome 120+。Windows 尚未支持:Windows 上的 Chrome native messaging 需要注册表和可执行 launcher,本版本没有提供。npm 包声明了 `os: ["darwin", "linux"]`,setup 在 Windows 上会返回 `UNSUPPORTED_PLATFORM`。不要声称 Windows 安装成功。扩展界面跟随 Chrome 的界面语言;本文档提供中英两版(`tab-ferre install-guide --zh-CN`)。
|
|
10
|
+
|
|
11
|
+
## 安装
|
|
12
|
+
|
|
13
|
+
1. 检查操作系统和 `node --version`。native host 注册支持 macOS 与 Linux;Windows 返回 `UNSUPPORTED_PLATFORM`,不要声称已安装。
|
|
14
|
+
2. Node.js 22+ 且 npx 可用时,执行:
|
|
15
|
+
|
|
16
|
+
```sh
|
|
17
|
+
npx -y tab-ferre@latest setup --json
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Node 缺失或过旧时,执行本发行版的 [`bin/bootstrap.sh`](bin/bootstrap.sh)。它会从 nodejs.org 下载 Node 24、校验 SHA-256,并私有安装到 `~/.tab-ferre/node`,然后运行同样的 setup。它需要 curl、tar 和 SHA-256 工具。请使用与本文档相同可信发行版或仓库中的 bootstrap。不需要 sudo、替换全局 Node 或修改 shell profile。
|
|
21
|
+
3. 解析 JSON。`ok: true` 表示本地安装完成;`ready: true` 表示浏览器连接和所选客户端注册都已就绪。setup 会安装运行时、native host 和 skill,并注册检测到的 Agent 客户端(CLI、桌面和 IDE)。`--client <id>[,<id>]` 或 `--client none` 指定范围;id 列表见 setup 输出和 `src/client-config.js`。
|
|
22
|
+
4. 按顺序处理每个 `next` 项:
|
|
23
|
+
- `actor: agent`:修复或重试报告的本地步骤。客户端注册失败时,检查 `clients`,使用其中的可执行文件/参数数组或返回的 `mcp` 配置;保留无关的客户端设置。
|
|
24
|
+
- `actor: human`:用可用的已批准浏览器路径打开返回的 Chrome URL,然后交给用户完成 Chrome 的安装/权限确认。问题只限定在这个确认上。Chrome 未运行时,带 `--open-extension-page` 的 setup 会尝试开启开发者模式、打开 `chrome://extensions` 并复制解压目录;用户仍需选择目录并确认。
|
|
25
|
+
- store URL 和 ID 来自安装器。没有配置 store ID 的发行版会返回解压目录和开发者模式交接;这是开发构建,不是已完成的商店发行。
|
|
26
|
+
5. 后续 shell 调用使用返回的绝对 `mcp.command` 作为 Node、`mcp.args[0]` 作为已安装 CLI 路径。私有 Node 也适用。运行该 CLI 的 `start`,再运行 `doctor --json`;doctor 必须返回 `ok: true`。客户端可能需要重载 MCP 连接后才会出现新工具。
|
|
27
|
+
6. 用 CLI 或新出现的 MCP 工具验证一次真实浏览器操作:打开 `https://example.org`,新建名为 `验证安装` 的轮次,快照并确认标题,然后结束轮次。只有成功时才结束;否则报告确切的剩余交接/错误。不要仅凭 setup 的退出码声称成功。
|
|
28
|
+
|
|
29
|
+
setup 可重复运行。并发安装或未完成的浏览器任务会返回 `UPDATE_BUSY`;完成自己的任务后重试,不要动其他 Agent 或用户接管的标签。`HOST_MIGRATION_REQUIRED` 表示旧 host 不支持维护流程:让用户完成工作并退出 Chrome,在 Chrome 关闭时运行 setup,再打开 Chrome 验证。提前重启 Chrome 只会再次启动旧 host。
|
|
30
|
+
|
|
31
|
+
## 更新与修复
|
|
32
|
+
|
|
33
|
+
已发布的 npm 安装默认开启本地自动更新;源码安装默认关闭。`setup --auto-update` 或 `setup --auto-update=false` 可显式设置。
|
|
34
|
+
|
|
35
|
+
Chrome 运行时,host 每天最多检查一次发行版;网络失败后每小时重试。下载使用 npm 官方 registry 的精确稳定版本,并校验完整性、禁用安装脚本。有活动标签时推迟激活;空闲安装会在一分钟左右应用待定更新。所有受管标签(包括人工接管的标签)都必须结束。Chrome 关闭时没有计划任务。
|
|
36
|
+
|
|
37
|
+
手动更新时,运行已安装 CLI 的 `update --json`。`state: deferred` 表示下载已就绪,激活会等待空闲;`state: previous_failure` 表示上次安装或启动失败后自动更新器保留了可用版本,检查 `~/.tab-ferre/updates.json` 并修复后再手动重试。重跑 `npx -y tab-ferre@latest setup --json` 也会修复集成文件并刷新 skill。
|
|
38
|
+
|
|
39
|
+
上一版运行时会保留。激活失败会恢复它;新 host 在初始化 socket 前退出时,稳定的 native launcher 也会恢复它。扩展与本地程序会协商协议版本,因此兼容的发行版本号可以不同。`VERSION_MISMATCH` 需要 Agent 协助同时升级扩展和本地程序。商店扩展通过 Chrome 更新;解压的开发版仍需人工重载。
|
|
40
|
+
|
|
41
|
+
## 卸载
|
|
42
|
+
|
|
43
|
+
用户要求移除 TabFerre 时,运行已安装 CLI 的 `uninstall --json`(或 `npx -y tab-ferre@latest uninstall --json`)。该命令会移除 native host manifest 和 wrapper、解压扩展目录、Agent skill,以及检测到的 MCP 客户端中的 `tab-ferre` 条目。有受管浏览器任务进行中时会拒绝执行(`UPDATE_BUSY`)。加 `--keep-state` 可保留 `~/.tab-ferre` 下的日志、会话和运行时。
|
|
44
|
+
|
|
45
|
+
完成后告诉用户在 `chrome://extensions` 移除 TabFerre 并重启 Chrome;CLI 无法移除运行中浏览器里的扩展。如果是全局安装,再运行 `npm uninstall -g tab-ferre`。不要删除无关的 MCP 客户端设置。
|
package/README.md
CHANGED
|
@@ -1,3 +1,153 @@
|
|
|
1
|
-
|
|
1
|
+
<div align="center">
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
<img src="https://raw.githubusercontent.com/lvhao/tab-ferre/main/assets/logo.png" alt="TabFerre" width="340">
|
|
4
|
+
|
|
5
|
+
# TabFerre
|
|
6
|
+
|
|
7
|
+
### Let your agent use your everyday Chrome, not another browser
|
|
8
|
+
|
|
9
|
+
**Browsing happens in new background tabs, grouped by request, with human takeover for sign-in and verification.**<br>
|
|
10
|
+
Your agent can open, read, click, fill and capture pages without stealing focus;<br>
|
|
11
|
+
the local host uses a local socket only — no listening port and no cookie export.
|
|
12
|
+
|
|
13
|
+

|
|
14
|
+

|
|
15
|
+

|
|
16
|
+

|
|
17
|
+

|
|
18
|
+
|
|
19
|
+
[Quick start](#quick-start) · [Capabilities](#capabilities) · [MCP clients](#mcp-clients) · [CLI reference](#cli-reference) · [Updates](#updates-and-maintenance) · [Troubleshooting](#troubleshooting) · [Docs](#documentation)
|
|
20
|
+
|
|
21
|
+
</div>
|
|
22
|
+
|
|
23
|
+
[English](README.md) · [简体中文](README.zh-CN.md)
|
|
24
|
+
|
|
25
|
+
> **Release status:** npm 0.1.1 is published. The Chrome Web Store listing is not published yet, so the extension is loaded as an unpacked build in developer mode (step 2).
|
|
26
|
+
|
|
27
|
+
## What is TabFerre?
|
|
28
|
+
|
|
29
|
+
TabFerre is an MCP plugin: your agent's browser commands travel through the CLI or a stdio MCP server into **new background tabs in your everyday Chrome**, instead of launching a separate browser.
|
|
30
|
+
|
|
31
|
+
- **No separate browser:** no bundled Chromium, no window focus, no touching your existing tabs. Every action happens in tabs created by the extension.
|
|
32
|
+
- **One round per request:** tabs opened for one user message join a single `✨️` Chrome tab group (collapsed by default, at most 10 concurrent tabs). `round-end` closes the agent tabs and removes the group.
|
|
33
|
+
- **Semantic snapshots, not raw DOM:** the extension reads Chrome's native accessibility tree through `chrome.debugger`. Snapshots expose roles, names and control states; clicks, fills and waits use snapshot references that are revalidated before each action. Arbitrary JavaScript is not exposed.
|
|
34
|
+
- **A clear human boundary:** for sign-in, CAPTCHAs or high-risk writes, hand the tab to the person with the in-page **Take over** control. The agent resumes after **Hand back to agent** and takes a fresh snapshot. A human-controlled tab cannot be operated by the agent; other tabs keep working.
|
|
35
|
+
|
|
36
|
+
**Good fit:** a resident AI agent (Claude Code, Codex and other MCP clients) that needs to research, read pages or fill forms, without opening another browser or taking over your foreground.
|
|
37
|
+
**Not a fit:** headless bulk scraping, bypassing site risk controls, or pure CI use. TabFerre runs in a real person's Chrome, and sign-in/CAPTCHA flows are meant to be handed to that person.
|
|
38
|
+
|
|
39
|
+
Supported: **macOS and Linux with desktop Chrome 120+**; **Windows is not supported yet** (native host registration and an executable launcher are not implemented). Requires **Node.js ≥22**. The extension UI follows Chrome's UI language, and the documentation is available in English and Chinese.
|
|
40
|
+
|
|
41
|
+
## Quick start
|
|
42
|
+
|
|
43
|
+
**1 · Install.**
|
|
44
|
+
|
|
45
|
+
**Automatic (recommended):** fetch the latest release from npm, prepare dependencies and configure the local installation:
|
|
46
|
+
|
|
47
|
+
```sh
|
|
48
|
+
npx -y tab-ferre@latest setup
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
**From source (development or code changes):** get this repository, then from the directory containing `package.json`:
|
|
52
|
+
|
|
53
|
+
```sh
|
|
54
|
+
npm ci
|
|
55
|
+
node bin/tab-ferre.js setup
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
`npm ci` installs dependencies from `package-lock.json`; `node bin/tab-ferre.js setup` then installs from the current source.
|
|
59
|
+
|
|
60
|
+
Both paths install the runtime, the Chrome native host and the agent skill, and register/configure detected MCP clients (Codex, Claude Code, Cursor, Windsurf, Gemini CLI, VS Code, Zed and others). To choose clients, add `--client auto|none|id[,id]` to `setup` (for example `--client codex,claude`; use `--client none` to skip registration). Agents should add `--json` for a structured result.
|
|
61
|
+
|
|
62
|
+
Setup exits when the local work is done. Continue with the next step to load and enable the extension.
|
|
63
|
+
|
|
64
|
+
**2 · Load the Chrome extension.** Open `chrome://extensions`, enable **Developer mode**, choose **Load unpacked**, and select the directory returned by setup (default `~/.tab-ferre/chrome-extension`). `setup --open-extension-page` can open the page, try to enable developer mode, and copy the extension directory to the clipboard.
|
|
65
|
+
|
|
66
|
+
**3 · Verify a browser action.** Do not type commands by hand; ask the connected agent, for example:
|
|
67
|
+
|
|
68
|
+
> Use TabFerre to open https://example.org and take a snapshot, to verify the installation.
|
|
69
|
+
|
|
70
|
+
The agent runs `open` → `snapshot` → `round-end`. A successful snapshot of the page title and a clean `round-end` complete the basic check.
|
|
71
|
+
|
|
72
|
+
If the agent session existed before installation, reload the MCP connection or restart the session until `tab_ferre_*` tools appear (see [MCP clients](#mcp-clients)).
|
|
73
|
+
|
|
74
|
+
Both installation paths behave the same: setup points the MCP entry at the installed runtime, so the sentence above works directly. When Chrome is not running, `open`/`start` launches Chrome and waits for the extension (30 seconds by default; `TAB_FERRE_CHROME_WAIT_MS` changes it). `status`, `list` and `doctor` do not launch Chrome.
|
|
75
|
+
|
|
76
|
+
## Capabilities
|
|
77
|
+
|
|
78
|
+
### Rounds: grouped background tabs
|
|
79
|
+
|
|
80
|
+
| Goal | How |
|
|
81
|
+
| :-- | :-- |
|
|
82
|
+
| Start a round | `open URL "round name" --new-round`; the group title is `✨️ round name` (collapsed by default) |
|
|
83
|
+
| Join the current round | Keep calling `open URL "name"`; at most 10 concurrent tabs per round |
|
|
84
|
+
| End a round | `round-end`: close this round's agent tabs and remove the group; human-controlled tabs are ungrouped, not closed |
|
|
85
|
+
|
|
86
|
+
### Snapshots and semantic actions
|
|
87
|
+
|
|
88
|
+
Every agent action is based on an explicit snapshot. Only `snapshot` publishes actionable references; after navigation, takeover or page changes, take a fresh snapshot instead of reusing stale refs.
|
|
89
|
+
|
|
90
|
+
### Human takeover
|
|
91
|
+
|
|
92
|
+
| Situation | How |
|
|
93
|
+
| :-- | :-- |
|
|
94
|
+
| Sign-in, CAPTCHA, high-risk writes | `handoff SESSION`, or click **Take over** on the page edge |
|
|
95
|
+
| Return control | The person clicks **Hand back to agent**; the agent takes a fresh `snapshot` |
|
|
96
|
+
|
|
97
|
+
A compact floating control sits at the page edge: blue for agent control, amber for human control. It can be dragged and avoids text. Takeover happens at each tab's operation boundary: completed actions are not undone, and queued actions check control before running. Only the person can hand control back.
|
|
98
|
+
|
|
99
|
+
### Human-like input on high-risk sites
|
|
100
|
+
|
|
101
|
+
For 60+ high-risk sites in the default list, TabFerre enables human-like input so keystroke and pointer timing falls inside a human distribution. CAPTCHAs, sliders and sign-in still require human takeover; TabFerre does not promise to bypass site risk controls.
|
|
102
|
+
|
|
103
|
+
### Screenshots, PDFs and diagnostics
|
|
104
|
+
|
|
105
|
+
Screenshots, PDFs, action logs and the AX tree, console/uncaught errors, device and network emulation, and dialogs are all session-scoped. Screenshots and PDFs never overwrite existing files. TabFerre does not record video; use `inspect --sections logs` to review what the agent did (fill values are not stored).
|
|
106
|
+
|
|
107
|
+
### Trust boundary and data retention
|
|
108
|
+
|
|
109
|
+
- Local socket only (`~/.tab-ferre/host.sock`); no network listening port, no cookie export, and action logs are not uploaded to a remote service.
|
|
110
|
+
- Only extension-created tabs are operated; arbitrary tab IDs, CDP commands, cookie reads and JS evaluation are not accepted. Each session is bound to one origin.
|
|
111
|
+
- `keys.json` is equivalent to the CLI identity and can operate tabs on behalf of the client; do not share it. Action logs omit fill values, but **titles and AX names may contain sensitive information**.
|
|
112
|
+
- Use a normal everyday Chrome window. Incognito is not supported, and Chromium variants such as Arc or Brave are not certified.
|
|
113
|
+
|
|
114
|
+
## MCP clients
|
|
115
|
+
|
|
116
|
+
Setup registers/configured detected mainstream MCP clients (see [Quick start](#quick-start)). Usually no manual configuration is needed. If automatic registration is unavailable or fails, use the `mcp.command` (absolute Node path) and `mcp.args[0]` (absolute CLI path) returned by setup. JSON examples and Codex / Claude Code commands are in the **MCP clients** section of [docs/reference.md](https://github.com/lvhao/tab-ferre/blob/main/docs/reference.md). Reload the MCP connection after configuring (restart the client if it has no reload action); `tab_ferre_*` tools appearing in the tool list means the connection is ready. The agent-side round convention is in the **MCP operation conventions** section of the same reference.
|
|
117
|
+
|
|
118
|
+
## CLI reference
|
|
119
|
+
|
|
120
|
+
See [docs/reference.md](https://github.com/lvhao/tab-ferre/blob/main/docs/reference.md): the **Commands** section groups CLI and MCP entry points by task, and **YAML workflows** describes built-in workflows. In a source checkout, replace `npx -y tab-ferre` with `node bin/tab-ferre.js`.
|
|
121
|
+
|
|
122
|
+
## Updates and maintenance
|
|
123
|
+
|
|
124
|
+
- **Source updates:** rerun `node bin/tab-ferre.js setup` when dependencies are unchanged; run `npm ci` first if dependencies changed; reload the extension in `chrome://extensions` after extension code changes.
|
|
125
|
+
- **npm installation (0.1.1 published):** run `npx -y tab-ferre@latest update` to update, or rerun `npx -y tab-ferre@latest setup` to repair the installation and reconnect clients. npm installations enable local automatic updates by default (at most once a day while Chrome runs); source installations leave them off. Use `setup --auto-update[=false]` to set it explicitly.
|
|
126
|
+
- **Self-check:** `doctor` runs a read-only check and prints repair commands. See [docs/reference.md](https://github.com/lvhao/tab-ferre/blob/main/docs/reference.md).
|
|
127
|
+
- **Uninstall:** run `npx -y tab-ferre uninstall` to remove the native host, extension directory, skill and MCP client entries. Then remove TabFerre in `chrome://extensions` and restart Chrome. Add `--keep-state` to preserve logs, sessions and the runtime under `~/.tab-ferre`.
|
|
128
|
+
|
|
129
|
+
## Troubleshooting
|
|
130
|
+
|
|
131
|
+
| Symptom | What to do |
|
|
132
|
+
| :-- | :-- |
|
|
133
|
+
| `doctor` has failing checks | Follow the commands it prints; it checks Node, state, host, build, extension, native host and skill |
|
|
134
|
+
| Extension not connected, or asks to update connection info | Confirm the extension is installed and enabled in the correct Chrome profile; reload the development build in `chrome://extensions`; if it still fails, rerun setup to repair the native host. Keep only one TabFerre extension instance enabled |
|
|
135
|
+
| Installation reports `UPDATE_BUSY` | Wait for another installation or the current browser task to finish, then retry. Do not force-close other agents or human-controlled tabs |
|
|
136
|
+
| Upgrade reports `HOST_MIGRATION_REQUIRED` | Finish your work and quit Chrome; run setup while Chrome is closed, then reopen Chrome and verify |
|
|
137
|
+
| Chrome restricts page access | In the extension details, set **Site access** to **On all sites** |
|
|
138
|
+
| Service will not start | Check `~/.tab-ferre/host.log` (or the same file under `TAB_FERRE_HOME` if you use a custom state directory) |
|
|
139
|
+
| MCP cannot find the command | Use the absolute paths from the [MCP clients](#mcp-clients) section |
|
|
140
|
+
|
|
141
|
+
## Documentation
|
|
142
|
+
|
|
143
|
+
| Document | Contents |
|
|
144
|
+
| :-- | :-- |
|
|
145
|
+
| [INSTALL.md](https://github.com/lvhao/tab-ferre/blob/main/INSTALL.md) | Agent instructions for installation, repair, updates and uninstall |
|
|
146
|
+
| [docs/reference.md](https://github.com/lvhao/tab-ferre/blob/main/docs/reference.md) | Command reference: command groups, MCP client setup, operation conventions and FAQ |
|
|
147
|
+
| [README.zh-CN.md](https://github.com/lvhao/tab-ferre/blob/main/README.zh-CN.md) | 简体中文 README |
|
|
148
|
+
| [INSTALL.zh-CN.md](https://github.com/lvhao/tab-ferre/blob/main/INSTALL.zh-CN.md) | 中文安装说明 |
|
|
149
|
+
| [docs/reference.zh-CN.md](https://github.com/lvhao/tab-ferre/blob/main/docs/reference.zh-CN.md) | 中文命令参考 |
|
|
150
|
+
|
|
151
|
+
## License
|
|
152
|
+
|
|
153
|
+
This repository does not include a LICENSE file or license statement yet. Contact the author before redistributing or reusing it.
|
package/README.zh-CN.md
ADDED
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
<img src="https://raw.githubusercontent.com/lvhao/tab-ferre/main/assets/logo.png" alt="TabFerre" width="340">
|
|
4
|
+
|
|
5
|
+
# TabFerre
|
|
6
|
+
|
|
7
|
+
### 让 Agent 用你日常的 Chrome,而不是再开一个浏览器
|
|
8
|
+
|
|
9
|
+
**浏览在新后台标签里完成,按轮次收进一个分组,登录和验证码随时人工接管。**<br>
|
|
10
|
+
Agent 打开、读取、点击、填表、截图,都不抢你的窗口焦点;<br>
|
|
11
|
+
本机 host 只走本地 socket——不监听端口、不导出 Cookie。
|
|
12
|
+
|
|
13
|
+

|
|
14
|
+

|
|
15
|
+

|
|
16
|
+

|
|
17
|
+

|
|
18
|
+
|
|
19
|
+
[快速开始](#快速开始) · [核心能力](#核心能力) · [MCP 客户端](#mcp-客户端) · [CLI 参考](#cli-参考) · [更新与维护](#更新与维护) · [故障排查](#故障排查) · [文档](#文档链接)
|
|
20
|
+
|
|
21
|
+
</div>
|
|
22
|
+
|
|
23
|
+
[English](README.md) · [简体中文](README.zh-CN.md)
|
|
24
|
+
|
|
25
|
+
> **发布状态**:npm 已发布 0.1.1;Chrome Web Store 尚未发布,扩展需按第 2 步用开发者模式加载。
|
|
26
|
+
|
|
27
|
+
## TabFerre 是什么
|
|
28
|
+
|
|
29
|
+
TabFerre 是一个 MCP 插件:Agent 的浏览命令经 CLI 或 stdio MCP 投递到**你日常 Chrome 的新后台标签**里执行,不另起浏览器实例。
|
|
30
|
+
|
|
31
|
+
- **不另起浏览器**:不启动独立 Chromium、不聚焦窗口、不动你已打开的标签;所有操作都发生在扩展创建的后台标签里。
|
|
32
|
+
- **每个请求一个「轮次」**:同一条用户消息打开的标签自动收进同一个 `✨️` Chrome 标签组(默认折叠,每轮最多 10 个并发标签),处理完 `round-end` 一键关闭并移除分组。
|
|
33
|
+
- **语义快照,而不是裸 DOM**:扩展通过 `chrome.debugger` 读取 Chrome 原生无障碍树,快照给出角色、名称和控件状态;点击、填表、等待都基于快照引用并在操作前重新校验,不开放任意 JavaScript。
|
|
34
|
+
- **人机边界清晰**:登录、验证码、高危写入,在页面边缘点「人工接管」交给用户,用完点「交还 Agent」,Agent 重新快照继续;接管期间 Agent 不能操作该标签,其他标签不受影响。
|
|
35
|
+
|
|
36
|
+
**适合你**:常驻的 AI Agent(Claude Code、Codex 等 MCP 客户端)需要查资料、读页面、填表单,而你不想让它另开一个浏览器实例或抢你的前台。
|
|
37
|
+
**不适合**:无头批量抓取、绕过站点风控、纯 CI 场景——TabFerre 跑在真人日常 Chrome 里,验证码和登录本来就要交给人。
|
|
38
|
+
|
|
39
|
+
支持 **macOS 与 Linux + 桌面 Chrome 120+**;**Windows 尚未支持**(native host 注册与可执行 launcher 未实现),需要 **Node.js ≥22**。扩展界面跟随 Chrome 的界面语言,文档提供中英两版。
|
|
40
|
+
|
|
41
|
+
## 快速开始
|
|
42
|
+
|
|
43
|
+
**1 · 选择安装方式。**
|
|
44
|
+
|
|
45
|
+
**自动安装(推荐)**:一条命令从 npm 获取最新版,自动准备依赖并完成本地安装配置:
|
|
46
|
+
|
|
47
|
+
```sh
|
|
48
|
+
npx -y tab-ferre@latest setup
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
**手动从源码安装(开发或修改代码时)**:取得本仓库源码,在含 `package.json` 的目录依次执行:
|
|
52
|
+
|
|
53
|
+
```sh
|
|
54
|
+
npm ci
|
|
55
|
+
node bin/tab-ferre.js setup
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
`npm ci` 按 `package-lock.json` 安装项目依赖;`node bin/tab-ferre.js setup` 再用当前源码执行安装配置。
|
|
59
|
+
|
|
60
|
+
两种方式都会安装运行时、Chrome native host 和 skill,并自动注册/配置检测到的主流 MCP 客户端(Codex、Claude Code、Cursor、Windsurf、Gemini CLI、VS Code、Zed 等)。需要指定客户端时,在 `setup` 后加 `--client auto|none|id[,id]`(例如 `--client codex,claude`,跳过注册用 `--client none`);Agent 执行安装时加 `--json` 读取结构化结果。
|
|
61
|
+
|
|
62
|
+
setup 安装完成后退出,按下一步加载并启用扩展即可使用。
|
|
63
|
+
|
|
64
|
+
**2 · 加载 Chrome 扩展。** 打开 `chrome://extensions`,开启「开发者模式」→「加载已解压的扩展程序」,选择 setup 返回的目录(默认 `~/.tab-ferre/chrome-extension`)。setup 加 `--open-extension-page` 可代劳这一步:它会打开 `chrome://extensions`、尝试开启开发者模式,并尝试把扩展目录复制到剪贴板。
|
|
65
|
+
|
|
66
|
+
**3 · 验证浏览器操作。** 不用自己敲命令:对已连接 MCP 的 Agent 说一句话即可,例如:
|
|
67
|
+
|
|
68
|
+
> 用 TabFerre 打开 https://example.org 并快照,验证安装是否正常
|
|
69
|
+
|
|
70
|
+
Agent 会按轮次完成 `open` → `snapshot` → `round-end`。snapshot 能读到页面标题、round-end 正常收尾,即完成基本验收。
|
|
71
|
+
|
|
72
|
+
如果 Agent 会话是在安装前开的,先重载 MCP 连接或重开会话,工具列表出现 `tab_ferre_*` 后再试(见 [MCP 客户端](#mcp-客户端))。
|
|
73
|
+
|
|
74
|
+
两种安装方式都一样:setup 已把 MCP 入口指向安装好的运行时,直接对 Agent 说上面这句话即可。Chrome 未运行时,`open`/`start` 会自动启动 Chrome 并等待扩展连接(默认 30 秒,`TAB_FERRE_CHROME_WAIT_MS` 可调);`status`、`list`、`doctor` 不会启动浏览器。
|
|
75
|
+
|
|
76
|
+
## 核心能力
|
|
77
|
+
|
|
78
|
+
### 轮次:带分组的后台标签
|
|
79
|
+
|
|
80
|
+
| 做什么 | 怎么做 |
|
|
81
|
+
| :-- | :-- |
|
|
82
|
+
| 新开一轮 | `open URL "轮次名" --new-round`,标签组标题为 `✨️ 轮次名`(默认折叠) |
|
|
83
|
+
| 并入当前轮 | 继续 `open URL "名字"`;同轮最多 10 个并发标签 |
|
|
84
|
+
| 结束一轮 | `round-end`:关闭本轮 Agent 标签并移除分组;人工接管的标签只解除分组、不关闭 |
|
|
85
|
+
|
|
86
|
+
### 快照与语义操作
|
|
87
|
+
|
|
88
|
+
Agent 每次操作都基于显式快照,只有 `snapshot` 发布可操作引用;导航、接管或页面变化后重新快照,不会拿旧引用误操作。
|
|
89
|
+
|
|
90
|
+
### 人工接管
|
|
91
|
+
|
|
92
|
+
| 场景 | 做法 |
|
|
93
|
+
| :-- | :-- |
|
|
94
|
+
| 登录、验证码、高危写入 | `handoff SESSION`,或在页面边缘点「人工接管」 |
|
|
95
|
+
| 交还 | 用户在页面边缘点「交还 Agent」,Agent 重新 `snapshot` |
|
|
96
|
+
|
|
97
|
+
页面边缘有一个紧凑浮动入口:蓝色为 Agent 控制,琥珀色为人工接管,可拖动位置并避让文字。接管发生在每个标签的操作边界:已执行的动作不撤销,排队的动作执行前先检查控制权。只有用户点「交还 Agent」才能继续。
|
|
98
|
+
|
|
99
|
+
### 高危站点拟人输入
|
|
100
|
+
|
|
101
|
+
对默认名单里的 60 余个国内站点,TabFerre 默认启用拟人输入,让输入节奏落在真人分布内;验证码、滑块和登录仍需人工接管,不承诺绕过站点风控。
|
|
102
|
+
|
|
103
|
+
### 截图、PDF 与诊断
|
|
104
|
+
|
|
105
|
+
截图、PDF、动作日志与 AX 树、console / 未捕获错误、设备与网络仿真、对话框,都按会话操作。截图与 PDF 不覆盖已有文件;TabFerre 不自动录屏,需要核对 Agent 做过什么时看 `inspect --sections logs`(不含填入的参数值)。
|
|
106
|
+
|
|
107
|
+
### 信任边界与数据留存
|
|
108
|
+
|
|
109
|
+
- 只走本机 socket(`~/.tab-ferre/host.sock`),不监听网络端口;不导出 Cookie,动作日志不上传远程服务。
|
|
110
|
+
- 只操作扩展创建的标签:不接受任意 tab ID、CDP 命令、Cookie 读取或 JS 求值;每个会话绑定单一来源。
|
|
111
|
+
- `keys.json` 等价于 CLI 身份,可代表客户端操作标签,不要外传;动作日志不保存填入的参数,但**标题与 AX 名称可能含敏感信息**。
|
|
112
|
+
- 使用日常普通窗口;不支持隐身模式,Arc / Brave 等 Chromium 分支未经认证。
|
|
113
|
+
|
|
114
|
+
## MCP 客户端
|
|
115
|
+
|
|
116
|
+
setup 自动注册/配置检测到的主流 MCP 客户端(范围见[快速开始](#快速开始)),通常无需手动配置。自动注册未覆盖或失败时,用 setup 返回的 `mcp.command`(Node 绝对路径)与 `mcp.args[0]`(CLI 绝对路径)接入,JSON 示例与 Codex / Claude Code 命令见 [docs/reference.md](https://github.com/lvhao/tab-ferre/blob/main/docs/reference.md) 的「MCP 客户端」一节。配置后重载 MCP 连接(没有该入口就重启客户端),工具列表出现 `tab_ferre_*` 即接入成功;Agent 侧轮次约定见 reference.md 的「MCP 操作约定」一节。
|
|
117
|
+
|
|
118
|
+
## CLI 参考
|
|
119
|
+
|
|
120
|
+
完整命令参考见 [docs/reference.zh-CN.md](https://github.com/lvhao/tab-ferre/blob/main/docs/reference.zh-CN.md):「命令」一节按用途列出 CLI 与 MCP 入口,「YAML 流程」一节说明内置流程;源码目录用 `node bin/tab-ferre.js` 代替 `npx -y tab-ferre`。
|
|
121
|
+
|
|
122
|
+
## 更新与维护
|
|
123
|
+
|
|
124
|
+
- **源码更新**:依赖未变时重跑 `node bin/tab-ferre.js setup`;依赖变了先 `npm ci`;改了扩展代码再在 `chrome://extensions` 重载扩展。
|
|
125
|
+
- **npm 安装(0.1.1 已发布)**:运行 `npx -y tab-ferre@latest update` 更新,或重跑 `npx -y tab-ferre@latest setup` 修复安装与重新接入客户端。npm 安装默认开启本地自动更新(Chrome 运行时每天最多检查一次),源码安装默认关闭,可用 `setup --auto-update[=false]` 设置。
|
|
126
|
+
- **自检**:`doctor` 做只读自检并给出修复命令,详见 [docs/reference.zh-CN.md](https://github.com/lvhao/tab-ferre/blob/main/docs/reference.zh-CN.md)。
|
|
127
|
+
- **卸载**:先运行 `npx -y tab-ferre uninstall` 移除 native host、扩展目录、skill 和 MCP 客户端配置;然后在 `chrome://extensions` 移除 TabFerre 并重启 Chrome。加 `--keep-state` 可保留 `~/.tab-ferre` 下的日志、会话和运行时。
|
|
128
|
+
|
|
129
|
+
## 故障排查
|
|
130
|
+
|
|
131
|
+
| 现象 | 处理 |
|
|
132
|
+
| :-- | :-- |
|
|
133
|
+
| `doctor` 有未通过项 | 按它给出的命令处理;它检查 Node、state、host、构建、扩展、native host 和 skill |
|
|
134
|
+
| 扩展未连接,或提示需要更新连接信息 | 确认正确 Chrome 配置文件里已安装并启用扩展;开发版在 `chrome://extensions` 重载;仍失败时运行 setup 修复 native host。只启用一个 TabFerre 扩展实例 |
|
|
135
|
+
| 安装提示 `UPDATE_BUSY` | 等其他安装结束或当前浏览器任务完成后重试;不强制关闭其他 Agent 或人工接管的标签 |
|
|
136
|
+
| 升级旧版提示 `HOST_MIGRATION_REQUIRED` | 任务结束后退出 Chrome,在 Chrome 关闭时运行 setup,完成后再打开验证 |
|
|
137
|
+
| Chrome 限制了网页访问 | 在 Chrome 的扩展详情里把「网站访问权限」设为「在所有网站上」 |
|
|
138
|
+
| 服务无法启动 | 查看 `~/.tab-ferre/host.log`(自定义状态目录时看 `TAB_FERRE_HOME` 下的同名文件) |
|
|
139
|
+
| MCP 找不到命令 | 使用 [MCP 客户端](#mcp-客户端)小节里的绝对路径配置 |
|
|
140
|
+
|
|
141
|
+
## 文档链接
|
|
142
|
+
|
|
143
|
+
| 文档 | 内容 |
|
|
144
|
+
| :-- | :-- |
|
|
145
|
+
| [INSTALL.zh-CN.md](https://github.com/lvhao/tab-ferre/blob/main/INSTALL.zh-CN.md) | 给 Agent 的安装、修复、更新与卸载说明 |
|
|
146
|
+
| [docs/reference.zh-CN.md](https://github.com/lvhao/tab-ferre/blob/main/docs/reference.zh-CN.md) | 命令参考:命令分组、MCP 客户端接入、操作约定与常见问题 |
|
|
147
|
+
| [README.md](https://github.com/lvhao/tab-ferre/blob/main/README.md) | English README |
|
|
148
|
+
|
|
149
|
+
## License
|
|
150
|
+
|
|
151
|
+
本仓库暂未包含 LICENSE 文件或许可声明;分发或引用前请与作者确认。
|
package/assets/logo.png
ADDED
|
Binary file
|
package/bin/bootstrap.sh
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
# Agent entry point for macOS/Linux, including machines without Node.
|
|
3
|
+
set -eu
|
|
4
|
+
|
|
5
|
+
if command -v node >/dev/null 2>&1 && command -v npx >/dev/null 2>&1 &&
|
|
6
|
+
node -e 'process.exit(Number(process.versions.node.split(".")[0]) >= 22 ? 0 : 1)' >/dev/null 2>&1; then
|
|
7
|
+
exec npx -y tab-ferre@latest setup --json "$@"
|
|
8
|
+
fi
|
|
9
|
+
|
|
10
|
+
tabferre_state=${TAB_FERRE_HOME:-"$HOME/.tab-ferre"}
|
|
11
|
+
tabferre_node="$tabferre_state/node"
|
|
12
|
+
run_local_node() {
|
|
13
|
+
PATH="$tabferre_node/bin:$PATH"
|
|
14
|
+
export PATH
|
|
15
|
+
exec "$tabferre_node/bin/node" "$tabferre_node/lib/node_modules/npm/bin/npx-cli.js" \
|
|
16
|
+
-y tab-ferre@latest setup --json "$@"
|
|
17
|
+
}
|
|
18
|
+
if [ -x "$tabferre_node/bin/node" ] &&
|
|
19
|
+
"$tabferre_node/bin/node" -e 'process.exit(Number(process.versions.node.split(".")[0]) >= 22 ? 0 : 1)' >/dev/null 2>&1; then
|
|
20
|
+
run_local_node "$@"
|
|
21
|
+
fi
|
|
22
|
+
|
|
23
|
+
case "$(uname -s)" in
|
|
24
|
+
Darwin) tabferre_os=darwin ;;
|
|
25
|
+
Linux) tabferre_os=linux ;;
|
|
26
|
+
*) echo 'TabFerre bootstrap supports macOS and Linux.' >&2; exit 1 ;;
|
|
27
|
+
esac
|
|
28
|
+
case "$(uname -m)" in
|
|
29
|
+
arm64|aarch64) tabferre_arch=arm64 ;;
|
|
30
|
+
x86_64|amd64) tabferre_arch=x64 ;;
|
|
31
|
+
*) echo 'TabFerre bootstrap supports x64 and arm64.' >&2; exit 1 ;;
|
|
32
|
+
esac
|
|
33
|
+
|
|
34
|
+
umask 077
|
|
35
|
+
mkdir -p "$tabferre_state"
|
|
36
|
+
if ! mkdir "$tabferre_state/node-install.lock" 2>/dev/null; then
|
|
37
|
+
echo 'Another Node bootstrap may be running. Retry when it finishes.' >&2
|
|
38
|
+
exit 1
|
|
39
|
+
fi
|
|
40
|
+
tabferre_temp=$(mktemp -d "$tabferre_state/node-download.XXXXXX")
|
|
41
|
+
trap 'rm -rf "$tabferre_temp"; rmdir "$tabferre_state/node-install.lock"' EXIT
|
|
42
|
+
trap 'exit 1' HUP INT TERM
|
|
43
|
+
tabferre_dist=https://nodejs.org/dist/latest-v24.x
|
|
44
|
+
curl --fail --silent --show-error --location --proto '=https' --tlsv1.2 --retry 2 --max-time 120 \
|
|
45
|
+
"$tabferre_dist/SHASUMS256.txt" -o "$tabferre_temp/SHASUMS256.txt"
|
|
46
|
+
tabferre_archive=$(awk -v suffix="-$tabferre_os-$tabferre_arch.tar.gz" \
|
|
47
|
+
'$2 ~ /^node-v24\.[0-9]+\.[0-9]+-(darwin|linux)-(x64|arm64)\.tar\.gz$/ &&
|
|
48
|
+
substr($2, length($2) - length(suffix) + 1) == suffix { print $2; exit }' \
|
|
49
|
+
"$tabferre_temp/SHASUMS256.txt")
|
|
50
|
+
if [ -z "$tabferre_archive" ]; then
|
|
51
|
+
echo 'A supported Node.js release could not be resolved.' >&2
|
|
52
|
+
exit 1
|
|
53
|
+
fi
|
|
54
|
+
curl --fail --silent --show-error --location --proto '=https' --tlsv1.2 --retry 2 --max-time 180 \
|
|
55
|
+
"$tabferre_dist/$tabferre_archive" -o "$tabferre_temp/$tabferre_archive"
|
|
56
|
+
tabferre_expected=$(awk -v file="$tabferre_archive" '$2 == file { print $1; exit }' "$tabferre_temp/SHASUMS256.txt")
|
|
57
|
+
if command -v sha256sum >/dev/null 2>&1; then
|
|
58
|
+
tabferre_actual=$(sha256sum "$tabferre_temp/$tabferre_archive" | awk '{print $1}')
|
|
59
|
+
else
|
|
60
|
+
tabferre_actual=$(shasum -a 256 "$tabferre_temp/$tabferre_archive" | awk '{print $1}')
|
|
61
|
+
fi
|
|
62
|
+
if [ "$tabferre_expected" != "$tabferre_actual" ]; then
|
|
63
|
+
echo 'Node.js archive checksum mismatch.' >&2
|
|
64
|
+
exit 1
|
|
65
|
+
fi
|
|
66
|
+
mkdir "$tabferre_temp/unpacked"
|
|
67
|
+
tar -xzf "$tabferre_temp/$tabferre_archive" -C "$tabferre_temp/unpacked" --strip-components=1
|
|
68
|
+
"$tabferre_temp/unpacked/bin/node" -e 'process.exit(Number(process.versions.node.split(".")[0]) >= 22 ? 0 : 1)'
|
|
69
|
+
if [ -e "$tabferre_node" ]; then
|
|
70
|
+
echo 'The private Node directory already exists but is unusable; inspect it before retrying.' >&2
|
|
71
|
+
exit 1
|
|
72
|
+
fi
|
|
73
|
+
mv "$tabferre_temp/unpacked" "$tabferre_node"
|
|
74
|
+
rm -rf "$tabferre_temp"
|
|
75
|
+
rmdir "$tabferre_state/node-install.lock"
|
|
76
|
+
trap - EXIT HUP INT TERM
|
|
77
|
+
run_local_node "$@"
|