@seekskyworld/open-browser 0.1.0 → 0.2.0
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/Docs/open-browser-api.d.ts +23 -5
- package/Docs//350/267/250/345/271/263/345/217/260/350/257/225/347/224/250/344/270/216/345/217/221/350/241/214.md +51 -3
- package/README.md +14 -5
- package/README.zh-CN.md +16 -5
- package/access-registry.mjs +5 -0
- package/action-execution.mjs +32 -21
- package/api-contract.mjs +14 -2
- package/browser-extension/manifest.json +1 -4
- package/browser-extension/newtab.css +6 -0
- package/browser-extension/newtab.js +53 -2
- package/browser-extension/phase-labels.js +1 -1
- package/browser-extension/popup.css +1 -1
- package/browser-extension/popup.html +14 -4
- package/browser-extension/popup.js +101 -20
- package/browser-extension/tab-action.js +3 -2
- package/browser-extension/worker.js +102 -9
- package/build-profile.mjs +23 -0
- package/capability-matrix.mjs +3 -3
- package/chromium-host.mjs +78 -18
- package/chromium-shell.mjs +77 -48
- package/cli.mjs +59 -1
- package/contract-validation.mjs +1 -1
- package/desktop/Info.plist +1 -1
- package/desktop/OBControlBar.m +7 -3
- package/desktop/WorkspacePanel.m +2 -1
- package/desktop/brand-keychain.py +20 -4
- package/desktop/build-macos.mjs +26 -10
- package/desktop/build-managed-input.mjs +37 -0
- package/desktop/build-profile.mjs +6 -0
- package/desktop/build.mjs +8 -0
- package/desktop/macos-entitlements.plist +12 -0
- package/desktop/notarize-macos.mjs +145 -0
- package/desktop/package-macos.mjs +54 -0
- package/desktop/patches/chromium-managed-input.patch +144 -0
- package/desktop/sign.mjs +48 -4
- package/desktop/start-profile.mjs +5 -0
- package/desktop/start.mjs +25 -3
- package/desktop/verify-macos-release.mjs +61 -0
- package/diagnostics.mjs +9 -0
- package/engine-service.mjs +174 -18
- package/managed-input.mjs +138 -0
- package/mcp-http.mjs +84 -0
- package/mcp-server.mjs +41 -0
- package/mcp.mjs +2 -40
- package/package.json +22 -2
- package/page-activity.mjs +95 -28
- package/page-observation.mjs +41 -3
- package/paths.mjs +5 -3
- package/receipt-store.mjs +9 -2
- package/runtime.mjs +10 -1
- package/sdk.mjs +32 -15
- package/service.mjs +21 -2
- package/skill-links.mjs +90 -0
- package/skills/open-browser/SKILL.macos.md +112 -0
- package/skills/open-browser/SKILL.md +24 -3
- package/skills/open-browser/SKILL.windows.md +112 -0
- package/skills/open-browser/scripts/bootstrap.mjs +80 -1
- package/tab-adoption.mjs +77 -0
- package/uploads.mjs +4 -4
- package/workspace-lifecycle.mjs +74 -6
- package/workspace-state.mjs +14 -2
|
@@ -13,14 +13,19 @@ export interface WorkspaceInfo {
|
|
|
13
13
|
agentName: string;
|
|
14
14
|
mode: 'agent' | 'transferring' | 'human';
|
|
15
15
|
controlGeneration: string;
|
|
16
|
-
|
|
16
|
+
security:{inputGuard:'native'|'fallback'|'off'|'unavailable'|'not_required'};
|
|
17
|
+
scope:'workspace'|'single_tab';
|
|
18
|
+
pageAvailability:'managed'|'closed'|'unregistered'|'sync_pending';
|
|
19
|
+
nextAction:'wait_for_sync'|'reattachPage'|'request_tab_selection'|'wait_for_agent_control';
|
|
20
|
+
accountAlias?:string;
|
|
21
|
+
pages: ReadonlyArray<PageHandle & { ownership:'user'|'agent'; syncState:'synced'|'not_required'|'sync_pending'; syncRevision:number; lastSyncedAt:number|null; documentId:string; origin: string; title: string; openerPageId?:string; openedByOperationId?:string }>;
|
|
17
22
|
activity: WorkspaceActivity;
|
|
18
23
|
blockedOrigins?: Array<{origin:string; scope:'resource'|'navigation'; reason:string; resourceType:string}>;
|
|
19
24
|
}
|
|
20
25
|
|
|
21
26
|
export interface WorkspaceOperation {
|
|
22
27
|
pageId?: string;
|
|
23
|
-
kind: 'openPage' | 'observe' | 'act' | 'captureVisual';
|
|
28
|
+
kind: 'openPage' | 'observe' | 'act' | 'captureVisual' | 'adoptCurrentTab' | 'canvasSnapshot';
|
|
24
29
|
state: OperationReceipt['state'];
|
|
25
30
|
completedSteps: number;
|
|
26
31
|
totalSteps: number;
|
|
@@ -33,12 +38,14 @@ export interface WorkspaceOperation {
|
|
|
33
38
|
}
|
|
34
39
|
|
|
35
40
|
export interface WorkspaceActivity {
|
|
36
|
-
phase: 'idle' | 'needs_credential' | OperationReceipt['state'];
|
|
41
|
+
phase: 'idle' | 'needs_credential' | 'needs_human_verification' | OperationReceipt['state'];
|
|
37
42
|
queued: number;
|
|
38
43
|
running: WorkspaceOperation[];
|
|
39
44
|
current: WorkspaceOperation | null;
|
|
40
45
|
recent: WorkspaceOperation | null;
|
|
41
46
|
needsCredential: boolean;
|
|
47
|
+
needsHumanVerification: boolean;
|
|
48
|
+
securityChallenge?: { provider: 'cloudflare' | string; origin: string; status: number; detectedAt: number };
|
|
42
49
|
/** Only getWorkspace returns request metadata. No credential values are returned. */
|
|
43
50
|
credentialRequest: {
|
|
44
51
|
documentId: string;
|
|
@@ -105,6 +112,8 @@ export interface OutputChunk {
|
|
|
105
112
|
data: string;
|
|
106
113
|
}
|
|
107
114
|
export interface PageObservation extends PageHandle {
|
|
115
|
+
/** Unique identifier for this observation payload. */
|
|
116
|
+
observationId: string;
|
|
108
117
|
documentId: string;
|
|
109
118
|
/** Changes whenever workspace control changes hands, even without navigation. */
|
|
110
119
|
controlGeneration: string;
|
|
@@ -195,7 +204,16 @@ export interface OpenBrowserV1 {
|
|
|
195
204
|
listWorkspaces(): Promise<WorkspaceInfo[]>;
|
|
196
205
|
getWorkspace(workspaceId: string): Promise<WorkspaceInfo>;
|
|
197
206
|
openPage(workspaceId: string, url: string): Promise<PageHandle>;
|
|
207
|
+
adoptCurrentTab(workspaceId:string, adoptionToken:string):Promise<PageHandle>;
|
|
208
|
+
reattachPage(page:PageHandle, options?:{waitMs?:number}):Promise<PageObservation>;
|
|
209
|
+
previewFinish(workspaceId:string, keepPageIds?:string[]):Promise<{previewId:string; keptPageIds:string[]; closedPageIds:string[]}>;
|
|
210
|
+
canvasSnapshot(page:PageHandle):Promise<PageHandle & {documentId:string; controlGeneration:string; snapshotVersion:string;
|
|
211
|
+
adapter:'react-flow'|'chat'|'unsupported'; nodes:Array<{id:string; label:string; selected:boolean}>;
|
|
212
|
+
edges:Array<{id:string; label:string; selected:boolean; source?:string; target?:string}>; messages:Array<{role:string; text:string}>;
|
|
213
|
+
attachments:Array<{label:string}>; truncated:boolean}>;
|
|
198
214
|
observe(page: PageHandle & ObserveOptions): Promise<PageObservation>;
|
|
215
|
+
/** SDK convenience. Observes and queues an action batch through one service request. */
|
|
216
|
+
observeAndAct(page: PageHandle & ObserveOptions, request: {actions: readonly PageAction[];operationId?:string;observeAfter?:'full'|'delta';timeoutMs?:number}): Promise<{observation:PageObservation;receipt:OperationReceipt}>;
|
|
199
217
|
runWorkflow(page:PageHandle,request:WorkflowRequest):Promise<OperationReceipt>;
|
|
200
218
|
act(page: PageHandle, request: {
|
|
201
219
|
operationId: string;
|
|
@@ -210,7 +228,7 @@ export interface OpenBrowserV1 {
|
|
|
210
228
|
actAfterObserve(page: PageHandle, request: {actions: readonly PageAction[];operationId?:string;observeAfter?:'full'|'delta';timeoutMs?:number}): Promise<{observation:PageObservation;receipt:OperationReceipt}>;
|
|
211
229
|
diagnoseOperation(workspaceId:string,operationId:string):Promise<{version:1;state:string;phase?:OperationReceipt['phase'];totalSteps?:number;completedSteps:number;dispatchRecorded:boolean;category:string;nextAction:string}>;
|
|
212
230
|
getOperation(workspaceId: string, operationId: string): Promise<OperationReceipt>;
|
|
213
|
-
finishWorkspace(workspaceId:string, keepPageIds:string[], operationId:string): Promise<OperationReceipt>;
|
|
231
|
+
finishWorkspace(workspaceId:string, keepPageIds:string[], operationId:string, previewId?:string): Promise<OperationReceipt>;
|
|
214
232
|
/** SDK convenience. Generates a fresh idempotency key for finishing a workspace. */
|
|
215
233
|
finish(workspaceId:string, keepPageIds?:string[]): Promise<OperationReceipt>;
|
|
216
234
|
respondDialog(page:PageHandle, response:{controlGeneration:string;dialogId:string;accept:boolean;text?:string}):Promise<{dialogId:string;accepted:boolean}>;
|
|
@@ -220,7 +238,7 @@ export interface OpenBrowserV1 {
|
|
|
220
238
|
readOutput(workspaceId:string, outputId:string, options?:{partName?:string;offset?:number;limit?:number}): Promise<OutputChunk>;
|
|
221
239
|
cancelDownload(workspaceId:string,downloadId:string): Promise<WorkspaceDownload>;
|
|
222
240
|
getRecoverySummary(workspaceId:string, options?:{after?:number;objectsAfter?:number;limit?:number}): Promise<{
|
|
223
|
-
workspaceId:string; mode:WorkspaceInfo['mode']|'unavailable'; pages:Array<{pageId:string;next:'observe'|'handle_unavailable'}>;
|
|
241
|
+
workspaceId:string; mode:WorkspaceInfo['mode']|'unavailable'; pages:Array<{pageId:string;next:'observe'|'handle_unavailable'; lastDisposition?:'released'|'closed'; pageAvailability:'managed'|'unregistered'|'closed'; nextAction:string}>;
|
|
224
242
|
deliveries:Array<{downloadId:string}>; outputs:Array<{outputId:string}>; operations:Array<OperationReceipt & {next:'verify_site'|'poll'|'already_completed'|'inspect_receipt'}>;
|
|
225
243
|
nextCursor:number|null; nextObjectCursor:number|null;
|
|
226
244
|
}>;
|
|
@@ -11,21 +11,57 @@ Windows x64 下载 `open-browser-win32-x64.zip` 并完整解压,运行 `open-b
|
|
|
11
11
|
|
|
12
12
|
在对应的 x64 平台,`npm run build` 自动选取本机目标。构建环境需要 Node.js 22 或更新版本、Python 3、curl、tar 及 npm。运行 `npm ci` 后,在仓库根目录执行对应命令。
|
|
13
13
|
|
|
14
|
+
### 一键打包命令
|
|
15
|
+
|
|
16
|
+
这些命令按 profile 与 target 命名方式组织,构建、归档和 SHA-256 文件由同一个入口完成。
|
|
17
|
+
|
|
18
|
+
| 命令 | 用途 | 主要输出 |
|
|
19
|
+
| --- | --- | --- |
|
|
20
|
+
| `npm run package:macos` | 构建 Stable arm64 macOS 应用并生成 ZIP、DMG | `dist/open-browser.app`、`dist/open-browser-macos-arm64.zip`、`dist/open-browser-macos-arm64.dmg` |
|
|
21
|
+
| `npm run package:macos:dmg` | 只生成带 `Applications` 快捷方式的 arm64 DMG | `dist/open-browser-macos-arm64.dmg` |
|
|
22
|
+
| `npm run package:macos:arm64` | 显式构建 arm64 macOS 应用并生成 ZIP、DMG | `dist/open-browser-macos-arm64.*` |
|
|
23
|
+
| `npm run package:macos:x64` | 构建 x64 macOS 应用并生成 ZIP、DMG | `dist/open-browser-x64.app`、`dist/open-browser-macos-x64.*` |
|
|
24
|
+
| `npm run package:windows:x64` | 构建 Windows x64 便携包 | `dist/open-browser-win32-x64.zip` |
|
|
25
|
+
| `npm run package:linux:x64` | 构建 Linux x64 便携包 | `dist/open-browser-linux-x64.tar.gz` |
|
|
26
|
+
| `npm run package:portable:all` | 依次生成 Windows、Linux 便携包 | 两个平台的归档和校验和 |
|
|
27
|
+
| `npm run package:all` | 生成 macOS、Windows、Linux 全部本地发行包 | `dist/` 下全部平台归档 |
|
|
28
|
+
|
|
29
|
+
macOS 正式公证发行仍使用 `npm run build:release-macos:arm64` 或 `npm run build:release-macos:x64`,然后运行 `npm run release:verify-macos`。本地 DMG 和 ZIP 适合安装测试,正式对外发布前需要完成 Apple 公证。
|
|
30
|
+
|
|
31
|
+
开发构建使用 `npm run build:dev` 或 `npm run start:dev`。开发构建自动使用 `~/.open-browser/dev`,并隔离 PID、socket、回执数据库、Chromium profile 和 macOS 应用标识。稳定构建使用 `npm run build:stable` 或 `npm start`,数据目录为 `~/.open-browser`。
|
|
32
|
+
|
|
14
33
|
| 目标 | 构建 | 输出 |
|
|
15
34
|
| --- | --- | --- |
|
|
16
|
-
| macOS arm64
|
|
35
|
+
| macOS arm64 开发构建 | `npm run browser:install`,然后 `npm run build:macos:arm64` | `dist/open-browser.app`,需要 arm64 macOS 和 Developer ID Application 签名证书 |
|
|
36
|
+
| macOS x64 开发构建 | `npm run browser:install`,然后 `npm run build:macos:x64` | `dist/open-browser-x64.app`,需要 x64 macOS、Rosetta 下的 x64 Node,或 x64 CI runner |
|
|
37
|
+
| macOS arm64 GitHub 发行 | `npm run build:release-macos:arm64` | 公证并固化票据的 `dist/open-browser-macos-arm64.zip` 及 SHA-256 |
|
|
38
|
+
| macOS x64 GitHub 发行 | `npm run build:release-macos:x64` | 公证并固化票据的 `dist/open-browser-macos-x64.zip` 及 SHA-256 |
|
|
17
39
|
| Linux x64 | `node desktop/build-portable.mjs linux-x64` | `dist/open-browser-linux-x64.tar.gz` 和 SHA-256 文件 |
|
|
18
40
|
| Windows x64 | `node desktop/build-portable.mjs win32-x64` | `dist/open-browser-win32-x64.zip` 和 SHA-256 文件 |
|
|
19
41
|
|
|
20
42
|
在 Linux 或 macOS 运行 `shasum -a 256 -c 文件名.sha256`,在 Windows PowerShell 运行 `Get-FileHash 文件名 -Algorithm SHA256` 并与随附的 SHA-256 比较。便携包可在 macOS 交叉打包。在对应平台解压包后,进入解压目录,Linux 运行 `./node/bin/node verify.mjs .`,Windows 运行 `.\node\node.exe verify.mjs .`,检查实际归档能启动服务和扩展、创建工作区并通过 CLI 读取本地测试页面,再验证临时服务退出。
|
|
21
43
|
|
|
22
|
-
无需签名证书的贡献者可运行 `npm ci`、`npm run browser:install`、`node --test clients.test.mjs control.test.mjs engine-service.test.mjs`。Linux 和 Windows CI 还运行真实扩展登录、接管测试及解压后的服务验收。签名 macOS 构建机上运行 `npm run test:all` 和 `codesign --verify --strict --deep dist/open-browser.app
|
|
44
|
+
无需签名证书的贡献者可运行 `npm ci`、`npm run browser:install`、`node --test clients.test.mjs control.test.mjs engine-service.test.mjs`。Linux 和 Windows CI 还运行真实扩展登录、接管测试及解压后的服务验收。签名 macOS 构建机上运行 `npm run test:all` 和 `codesign --verify --strict --deep dist/open-browser.app`;检查实际可见标签打开、接管交回、普通标签不受影响及升级后登录态。正式发行运行 `npm run build:release-macos`,它会用 `xcrun notarytool` 提交公证,执行 `xcrun stapler staple`,重新生成含票据的 GitHub ZIP,并运行 `npm run release:verify-macos` 验收 Hardened Runtime、票据、Gatekeeper 和 SHA-256。
|
|
45
|
+
|
|
46
|
+
### macOS 签名与公证凭据
|
|
47
|
+
|
|
48
|
+
`desktop/sign.mjs` 默认启用可靠时间戳和 Hardened Runtime,并应用 `desktop/macos-entitlements.plist` 中 Chromium 所需的 JIT、未签名可执行内存和动态库加载权限。仅在离线开发调试时可设置 `OPEN_BROWSER_CODESIGN_TIMESTAMP=none`。正式构建不要设置该变量。签名身份可通过 `OPEN_BROWSER_SIGN_IDENTITY` 指定完整证书名称或 SHA-1。
|
|
49
|
+
|
|
50
|
+
公证凭据按以下顺序读取,密钥不会写入仓库。
|
|
51
|
+
|
|
52
|
+
1. 推荐使用本机钥匙串中的 notarytool 配置,设置 `OPEN_BROWSER_NOTARY_PROFILE`。可先运行 `xcrun notarytool store-credentials <profile>` 保存 API Key 或 Apple ID 应用专用密码。
|
|
53
|
+
2. CI 使用 App Store Connect API Key,设置 `OPEN_BROWSER_NOTARY_KEY`、`OPEN_BROWSER_NOTARY_KEY_ID`,团队密钥再设置 `OPEN_BROWSER_NOTARY_ISSUER`。`OPEN_BROWSER_NOTARY_KEY` 只接受 CI Secret 提供的 `.p8` 文件路径。
|
|
54
|
+
3. Apple ID 模式设置 `OPEN_BROWSER_NOTARY_APPLE_ID`、`OPEN_BROWSER_NOTARY_TEAM_ID` 和 `OPEN_BROWSER_NOTARY_PASSWORD`。也可把应用专用密码保存到钥匙串服务 `open-browser-notary`,脚本会按 Apple ID 账户读取。应用专用密码不能使用 Apple ID 登录密码。
|
|
55
|
+
|
|
56
|
+
脚本也兼容现有 GoLutra 发布环境的变量名。若本机已有 `~/.golutra-macos-release.env`,可运行 `source ~/.golutra-macos-release.env` 后直接执行发行命令。`APPLE_SIGNING_IDENTITY`、`APPLE_API_KEY_PATH`、`APPLE_API_KEY`、`APPLE_API_ISSUER`、`APPLE_ID`、`APPLE_PASSWORD` 和 `APPLE_TEAM_ID` 会自动映射到 open-browser 的发行流程。
|
|
57
|
+
|
|
58
|
+
当前发行目标采用 GitHub ZIP。若需改变产物路径,可设置 `OPEN_BROWSER_NOTARY_ZIP` 或传入 `--zip`。公证完成后,使用 `npm run release:verify-macos`,并保存构建提交、系统架构、ZIP SHA-256、notarytool Request ID 和验收日志。
|
|
23
59
|
|
|
24
60
|
## 发行记录
|
|
25
61
|
|
|
26
62
|
核对 `Docs/THIRD-PARTY-NOTICES.md`、分发内 `app/third-party-packages.json`、Node LICENSE、引擎的 ABOUT 与运行中的 `chrome://credits/`。保存构建所用提交、系统和架构、Node/Chromium 版本、包 SHA-256、测试输出与已知限制。CI 执行构建和验收;对外发布版本、选定项目许可证及上传 macOS 公证均由项目所有者决定。
|
|
27
63
|
|
|
28
|
-
在项目根目录运行 `python3 desktop/archive-release.py snapshot` 会生成保留执行位、固定时间戳的源码归档和校验和,包含 Git 已跟踪和未忽略的源码。归档保存在 `dist/open-browser-source-0.
|
|
64
|
+
在项目根目录运行 `python3 desktop/archive-release.py snapshot` 会生成保留执行位、固定时间戳的源码归档和校验和,包含 Git 已跟踪和未忽略的源码。归档保存在 `dist/open-browser-source-0.2.0.tar.gz`。macOS 构建机可以用以下命令归档已签名应用,再比对发行包中的应用源文件、第三方声明与源码快照。在此期间保持工作树稳定。
|
|
29
65
|
|
|
30
66
|
```sh
|
|
31
67
|
ditto -c -k --keepParent --sequesterRsrc dist/open-browser.app dist/open-browser-macos-arm64.zip
|
|
@@ -34,3 +70,15 @@ python3 desktop/archive-release.py verify
|
|
|
34
70
|
```
|
|
35
71
|
|
|
36
72
|
验证通过后,`dist/SHA256SUMS` 记录源码和三个应用归档的完整 SHA-256。
|
|
73
|
+
|
|
74
|
+
### Dev 原生输入保护实验
|
|
75
|
+
|
|
76
|
+
使用已由 depot_tools 同步依赖的 Chromium 源码树,版本为 `159.0.8154.6`,提交为 `98a2592026af8d673b9fa83b626ac68bdf4ae78a`。在目标架构的构建机上执行以下命令。脚本检查提交、应用输入保护补丁、构建浏览器和 content_browsertests,再执行工作区输入过滤的原生回归。
|
|
77
|
+
|
|
78
|
+
```sh
|
|
79
|
+
node desktop/build-managed-input.mjs /path/to/chromium/src
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
在图形桌面的交互终端运行 `node benchmarks/managed-input.mjs <上一步生成的浏览器可执行文件>`。按屏幕提示点击主文档、跨源子文档和普通标签。测试还会输出关闭和启用保护时各 100 次 Agent 点击的 P50 与 P95。
|
|
83
|
+
|
|
84
|
+
在项目目录将 `OPEN_BROWSER_DEV_CHROMIUM` 设为上述可执行文件的绝对路径,执行 `npm run start:dev`。服务在临时浏览器资料中启动,通过扩展工具栏接管或交回工作区。未包含输入补丁的引擎会使用页面捕获层 `fallback` 输入锁定。只有显式设置 `OPEN_BROWSER_INPUT_GUARD=native` 时才要求引擎提供原生输入守卫。本实验的图形桌面验收和发行包验收须按平台记录。
|
package/README.md
CHANGED
|
@@ -13,7 +13,10 @@ open-browser is an open-source desktop browser for agents. It runs locally and s
|
|
|
13
13
|
## What you can do
|
|
14
14
|
|
|
15
15
|
- **Run tasks in parallel.** Workspaces progress independently and actions on each page stay in order. The service keeps same-page actions ordered while independent workspaces run concurrently. Use `npm run test:unit` and `npm run test:contract` to reproduce the local regression suites.
|
|
16
|
+
- **Use an existing signed-in tab.** Ask the agent to create a named workspace. Open the extension on the desired open-browser tab, choose that task, and pass the two-minute authorization to the agent. The tab stays open when the task finishes.
|
|
16
17
|
- **Share a live task with an agent.** Take over during sign-in, complete the form in place and hand the same tab back with its session intact. For routine sign-ins, bind a credential to the workspace and site so the agent can fill it by reference. [Workspace and handoff guide](Docs/控制台分组与接管方案.md)
|
|
18
|
+
- **Keep Agent input visibly exclusive.** While a workspace is in Agent control, the managed page rejects human page input and shows the existing task border and action cursor. Each Agent action opens a scoped dispatch window, then the page locks again. Use **人工接管** to edit the page yourself and **交回 Agent** to resume.
|
|
19
|
+
- **Pause safely for site verification.** When a site returns a recognized security challenge, the workspace stops Agent actions and shows **需要人工验证**. Take over the visible page, complete the site's own verification, then return control and observe again. open-browser does not hide automation signals or bypass the challenge.
|
|
17
20
|
- **See the work without another dashboard window.** Every new tab opens the local Agent console with active workspaces, agent names, current status and recent operation records. The native task bar keeps only takeover and a one-click **End** action.
|
|
18
21
|
- **Delegate only the access a task needs.** Grant read access to an agent that checks results and control access to one that fills forms. Managed tabs have a list of permitted origins. Reading screenshots requires a separate pixel grant. [API types](Docs/open-browser-api.d.ts)
|
|
19
22
|
- **Find out what happened after a disconnect.** The local service keeps the workspace alive when the CLI exits. Look up the receipt by operation ID. If submission is uncertain, check the site's result before retrying. [Evaluation guide](Docs/open-browser任务评测指南.md)
|
|
@@ -34,7 +37,7 @@ To try the control API, run the integration test. It starts a temporary local se
|
|
|
34
37
|
node --test service.integration.test.mjs
|
|
35
38
|
```
|
|
36
39
|
|
|
37
|
-
To open the desktop browser, run `npm start`. The first macOS desktop build requires Xcode command line tools and a Developer ID Application certificate. If you already have a build, open `dist/open-browser.app`.
|
|
40
|
+
To open the stable desktop browser, run `npm start`. Use `npm run start:dev` for an isolated development build with separate state, PID, socket, receipts and macOS app identity. The first macOS desktop build requires Xcode command line tools and a Developer ID Application certificate. If you already have a build, open `dist/open-browser.app`. For a public GitHub ZIP, set a notarytool profile or CI credentials and run `npm run build:release-macos`, then run `npm run release:verify-macos`. Windows and Linux support running from source and x64 portable builds. For a headless service, run `node service.mjs --headless`. [Platform prerequisites and packaging](Docs/跨平台试用与发行.md)
|
|
38
41
|
|
|
39
42
|
## Try a handoff
|
|
40
43
|
|
|
@@ -54,9 +57,13 @@ To open the desktop browser, run `npm start`. The first macOS desktop build requ
|
|
|
54
57
|
The CLI and MCP server use the same SDK to call the local API. The service drives Chromium through Playwright Core and shares page state, permissions and operation receipts across clients.
|
|
55
58
|
Every new workspace must include a clear `name` task label. The label appears in the Agent console, native sidebar and browser tab group.
|
|
56
59
|
|
|
57
|
-
The scoped npm package exposes the same implementation through separate entry points. Install it with `npm install @seekskyworld/open-browser`. Run `open-browser` for CLI calls, configure `open-browser-mcp` as an MCP stdio server, or run `open-browser-
|
|
60
|
+
The scoped npm package exposes the same implementation through separate entry points. Install it with `npm install @seekskyworld/open-browser`. Run `open-browser` for CLI calls, configure `open-browser-mcp` as an MCP stdio server, or run `open-browser-mcp-http` for an authenticated loopback MCP endpoint. JavaScript clients can import `OpenBrowserClient` from `@seekskyworld/open-browser`.
|
|
58
61
|
|
|
59
|
-
Agents using the [open-browser Skill](skills/open-browser/SKILL.md) call the CLI through `skills/open-browser/scripts/open-browser`. The Skill starts the local open-browser app or portable service when needed and retries once after it becomes ready. Set `OPEN_BROWSER_AUTOSTART=0` to require an already running service. Start the app manually or run `npm start` when you want to open the desktop window before creating a task. Pass method arguments as JSON on standard input. Use `node cli.mjs --help` to list methods.
|
|
62
|
+
Agents using the [open-browser Skill](skills/open-browser/SKILL.md) call the CLI through `skills/open-browser/scripts/open-browser`. The Skill starts the local open-browser app or portable service when needed and retries once after it becomes ready. Set `OPEN_BROWSER_AUTOSTART=0` to require an already running service. Start the app manually or run `npm start` when you want to open the desktop window before creating a task. Pass method arguments as JSON on standard input. Use `node cli.mjs --help` to list methods. Run `open-browser skill` to print the platform-matched guide without starting the service.
|
|
63
|
+
|
|
64
|
+
The optional `open-browser-mcp-http` command binds only to loopback, uses the profile token as Bearer authentication, and serves `/mcp` for clients that require URL-based MCP configuration. Set `OPEN_BROWSER_MCP_HTTP_PORT` to choose a port.
|
|
65
|
+
|
|
66
|
+
On the first Skill or service start, open-browser detects existing Skill directories for Codex, Claude Code, Cursor, Windsurf, Gemini CLI, Cline, Roo Code and OpenCode. It creates an `open-browser` relative symlink in each detected directory, preserving existing files and links. Windsurf's standard `~/.codeium/windsurf/skills` directory and its legacy `~/.windsurf/skills` directory are both supported. Set `OPEN_BROWSER_AUTO_INSTALL_SKILLS=0` to disable this behavior. Add agent-specific Skill directories with the `OPEN_BROWSER_AGENT_SKILL_DIRS` path-list variable.
|
|
60
67
|
|
|
61
68
|
For one explicit URL, an agent can use one `open` call to create a workspace and open the page. This shortcut keeps Chromium's normal page network so cross-origin CSS, scripts, fonts and images render normally. Observation and actions remain bound to the target workspace and origin. Use `createWorkspace` when strict origin isolation is required.
|
|
62
69
|
|
|
@@ -64,7 +71,9 @@ For one explicit URL, an agent can use one `open` call to create a workspace and
|
|
|
64
71
|
printf '%s\n' '{"url":"https://example.org","name":"Page check"}' | node cli.mjs open
|
|
65
72
|
```
|
|
66
73
|
|
|
67
|
-
The SDK also provides `openAndObserve(options)`, `actAfterObserve(page, { actions })` and `finish(workspaceId, keepPageIds)`.
|
|
74
|
+
The SDK also provides `openAndObserve(options)`, `observeAndAct(page, { actions })`, `actAfterObserve(page, { actions })` and `finish(workspaceId, keepPageIds)`. Observation and action submission can use one service request while preserving fresh document IDs, control generations, workspace permissions and idempotent operation receipts.
|
|
75
|
+
|
|
76
|
+
For continuous tasks, run `open-browser session` and send one JSON request per line with `id`, `method` and `params`. The session reuses one Node client and local connection to avoid process startup on every action.
|
|
68
77
|
|
|
69
78
|
For multi-step work, use the full SDK lifecycle.
|
|
70
79
|
|
|
@@ -100,7 +109,7 @@ Client tokens live under `~/.open-browser/`. Clients connect over a Unix socket
|
|
|
100
109
|
<details>
|
|
101
110
|
<summary>Existing profiles, macOS Keychain and privacy settings</summary>
|
|
102
111
|
|
|
103
|
-
The default desktop profile lives at `~/.open-browser/open-browser-profile-v2/` on macOS and `~/.open-browser/open-browser-profile/` on Windows and Linux. Site-data encryption uses the system Keychain item named `open-browser Keychain`. Builders can select a signing identity with `OPEN_BROWSER_SIGN_IDENTITY`. [Build check](desktop/brand-keychain.py)
|
|
112
|
+
The default desktop profile lives at `~/.open-browser/open-browser-profile-v2/` on macOS and `~/.open-browser/open-browser-profile/` on Windows and Linux. Site-data encryption uses the system Keychain item named `open-browser Keychain`. Builders can select a signing identity with `OPEN_BROWSER_SIGN_IDENTITY`. macOS release credentials are read from `OPEN_BROWSER_NOTARY_PROFILE` or CI-provided API Key and Apple ID variables. [Build check](desktop/brand-keychain.py)
|
|
104
113
|
|
|
105
114
|
</details>
|
|
106
115
|
|
package/README.zh-CN.md
CHANGED
|
@@ -13,7 +13,10 @@ open-browser 是一个本机运行的开源 Agent 浏览器,自带 Chromium。
|
|
|
13
13
|
## 用它做什么
|
|
14
14
|
|
|
15
15
|
- **后台并行处理网页。** 不同工作区可以同时推进,同一页的动作按顺序执行。服务保证同页动作按顺序执行,同时允许不同工作区并发。可运行 `npm run test:unit` 和 `npm run test:contract` 重现本机回归套件。
|
|
16
|
+
- **把打开的标签页交给 Agent。** 让 Agent 创建命名任务,在 open-browser 中已登录的标签页打开扩展,选择任务并点「让 Agent 操作此页」。把面板里的授权交给 Agent 即可继续,任务结束后原标签会保留。
|
|
16
17
|
- **人和 Agent 接力完成任务。** 登录需要你确认时,接管原标签就能继续操作,保留当前表单和登录态。交回后,Agent 重新观察页面再继续。你也可以预先为指定站点绑定凭据,让常规登录自动完成。[工作区与接管](Docs/控制台分组与接管方案.md)
|
|
18
|
+
- **Agent 操作时锁定页面输入。** Agent 控制工作区时,受管页面会拒绝人工鼠标、触控板和键盘输入,同时显示任务边框和动作光标。每次 Agent 动作结束后立即恢复锁定。点击 **人工接管** 后可以直接编辑原页,完成后点击 **交回 Agent**。
|
|
19
|
+
- **站点安全验证暂停。** 检测到站点返回安全验证挑战时,工作区会停止 Agent 操作并显示“需要人工验证”。用户在可见页面完成站点自己的验证后交回控制权,再重新观察。open-browser 不隐藏自动化信号,也不绕过验证。
|
|
17
20
|
- **新标签页就是任务控制台。** 每个新标签页只显示正在运行的 Agent 和运行历史,包含 Agent 名称、任务状态、最近步骤和时间。页面底部悬浮栏只保留人工接管和一键「结束」,结束时保留现有页面并撤销任务分组,不再弹出交付窗口。
|
|
18
21
|
- **给 Agent 刚好够用的权限。** 给核对结果的助手授予只读权限,给填写表单的助手授予控制权限。受管页面按任务授权访问站点,读取截图还需要单独的像素授权。[接口与权限](Docs/open-browser-api.d.ts)
|
|
19
22
|
- **断线后查清上一步。** CLI 进程退出后,工作区由本机服务继续管理。连接恢复时,可以凭操作 ID 查询回执。遇到提交结果未知的情况,先核对站点,避免把同一张表单再交一次。[任务评测指南](Docs/open-browser任务评测指南.md)
|
|
@@ -34,7 +37,9 @@ npm run browser:install
|
|
|
34
37
|
node --test service.integration.test.mjs
|
|
35
38
|
```
|
|
36
39
|
|
|
37
|
-
|
|
40
|
+
**打开稳定桌面浏览器**,运行 `npm start`。开发构建使用 `npm run start:dev`,它会隔离开发状态目录、PID、socket、回执和 macOS 应用标识。macOS 首次启动会构建签名应用,需要 Xcode 命令行工具和 Developer ID Application 证书。公开发布 GitHub ZIP 时,配置 notarytool 钥匙串配置或 CI 凭据,运行 `npm run build:release-macos`,再运行 `npm run release:verify-macos`。Windows、Linux 支持从源码启动和 x64 便携包。仅需无头服务时运行 `node service.mjs --headless`。[各平台构建、系统依赖与校验](Docs/跨平台试用与发行.md)
|
|
41
|
+
|
|
42
|
+
本地生成可安装的 macOS 默认包可运行 `npm run package:macos`,它会同时生成 `.app`、ZIP 和带 `Applications` 快捷方式的 DMG。只需要 DMG 时运行 `npm run package:macos:dmg`。Windows、Linux 包分别使用 `npm run package:windows:x64` 和 `npm run package:linux:x64`。
|
|
38
43
|
|
|
39
44
|
## 试一次人工接管
|
|
40
45
|
|
|
@@ -54,9 +59,13 @@ node --test service.integration.test.mjs
|
|
|
54
59
|
CLI 和 MCP 都通过同一个 SDK 调用本机 API。服务端使用 Playwright Core 驱动专用 Chromium,并在各入口之间共享页面、权限和操作回执。
|
|
55
60
|
每个新工作区都必须填写清晰的 `name` 任务名称,该名称会显示在 Agent 控制台、原生侧栏和浏览器标签组中。
|
|
56
61
|
|
|
57
|
-
Scoped npm
|
|
62
|
+
Scoped npm 包提供同一套实现的多个入口。运行 `npm install @seekskyworld/open-browser` 后,使用 `open-browser` 调用 CLI,使用 `open-browser-mcp` 配置 MCP stdio 服务,或使用 `open-browser-mcp-http` 启动经过 Bearer 认证的本机回环 MCP 地址。JavaScript 客户端可以从 `@seekskyworld/open-browser` 导入 `OpenBrowserClient`。
|
|
63
|
+
|
|
64
|
+
Agent 使用 [open-browser Skill](skills/open-browser/SKILL.md) 时,通过 `skills/open-browser/scripts/open-browser` 调用 CLI。Skill 会在需要时启动本机 open-browser 应用或便携服务,等待就绪后自动重试一次。设置 `OPEN_BROWSER_AUTOSTART=0` 可要求服务必须已运行。希望先打开桌面窗口时,也可以手动启动应用或执行 `npm start`。运行 `open-browser skill` 可以直接输出当前安装包对应平台的 Skill 指南,不会启动服务。
|
|
58
65
|
|
|
59
|
-
|
|
66
|
+
首次运行 Skill 或本机服务时,open-browser 会检测已经存在的 Codex、Claude Code、Cursor、Windsurf、Gemini CLI、Cline、Roo Code 和 OpenCode Skill 目录,并在其中创建 `open-browser` 相对符号链接。已有文件和非 open-browser 符号链接会保留。Windsurf 的标准目录 `~/.codeium/windsurf/skills` 和旧版目录 `~/.windsurf/skills` 都支持。设置 `OPEN_BROWSER_AUTO_INSTALL_SKILLS=0` 可关闭自动安装,也可以通过 `OPEN_BROWSER_AGENT_SKILL_DIRS` 路径列表补充其他 Agent 的 Skill 目录。
|
|
67
|
+
|
|
68
|
+
需要 URL 形式 MCP 配置时,可运行 `open-browser-mcp-http`。它只监听本机回环地址 `/mcp`,默认读取当前 profile 的 token 作为 Bearer 认证,端口可用 `OPEN_BROWSER_MCP_HTTP_PORT` 设置。
|
|
60
69
|
|
|
61
70
|
先打开应用或执行 `npm start`。在项目根目录运行 `node cli.mjs createWorkspace` 创建工作区,运行 `node cli.mjs listWorkspaces` 查看结果。带参数的命令通过标准输入传入 JSON。`node cli.mjs --help` 列出全部方法。
|
|
62
71
|
|
|
@@ -66,7 +75,9 @@ Agent 使用 [open-browser Skill](skills/open-browser/SKILL.md) 时,通过 `sk
|
|
|
66
75
|
printf '%s\n' '{"url":"https://example.org","name":"网页检查"}' | node cli.mjs open
|
|
67
76
|
```
|
|
68
77
|
|
|
69
|
-
SDK 还提供 `openAndObserve(options)`、`actAfterObserve(page, { actions })` 和 `finish(workspaceId, keepPageIds)
|
|
78
|
+
SDK 还提供 `openAndObserve(options)`、`observeAndAct(page, { actions })`、`actAfterObserve(page, { actions })` 和 `finish(workspaceId, keepPageIds)`。观察和动作可以通过一次服务请求完成,同时仍使用最新文档 ID、控制代次、工作区权限和幂等操作回执。
|
|
79
|
+
|
|
80
|
+
连续任务可以运行 `open-browser session`,按行发送带 `id`、`method` 和 `params` 的 JSON。该模式复用一个 Node 客户端和本地连接,减少每个动作的进程启动成本。
|
|
70
81
|
|
|
71
82
|
需要跨多步复用工作区时,使用完整的 SDK 生命周期。
|
|
72
83
|
|
|
@@ -102,7 +113,7 @@ MCP 客户端使用 stdio。下面的示例假设已把应用移到 `/Applicatio
|
|
|
102
113
|
<details>
|
|
103
114
|
<summary>已有资料、macOS 钥匙串与隐私配置</summary>
|
|
104
115
|
|
|
105
|
-
桌面资料默认保存在 `~/.open-browser/open-browser-profile-v2/`(macOS)或 `~/.open-browser/open-browser-profile/`(Windows、Linux)。站点数据的加密密钥保存在系统钥匙串的 `open-browser Keychain` 项目中。构建机可以通过 `OPEN_BROWSER_SIGN_IDENTITY` 选择签名证书。[构建校验](desktop/brand-keychain.py)
|
|
116
|
+
桌面资料默认保存在 `~/.open-browser/open-browser-profile-v2/`(macOS)或 `~/.open-browser/open-browser-profile/`(Windows、Linux)。站点数据的加密密钥保存在系统钥匙串的 `open-browser Keychain` 项目中。构建机可以通过 `OPEN_BROWSER_SIGN_IDENTITY` 选择签名证书。macOS 公证凭据从 `OPEN_BROWSER_NOTARY_PROFILE` 或 CI 提供的 API Key、Apple ID 变量读取。[构建校验](desktop/brand-keychain.py)
|
|
106
117
|
|
|
107
118
|
</details>
|
|
108
119
|
|
package/access-registry.mjs
CHANGED
|
@@ -45,6 +45,9 @@ export class AccessRegistry {
|
|
|
45
45
|
owner(task) {
|
|
46
46
|
return typeof task === 'string' && this.db.prepare('SELECT owner FROM tasks WHERE id=?').get(task)?.owner;
|
|
47
47
|
}
|
|
48
|
+
hasDelegates(task) {
|
|
49
|
+
return !!this.db.prepare('SELECT 1 FROM grants WHERE task=? LIMIT 1').get(task);
|
|
50
|
+
}
|
|
48
51
|
permission(client, task) {
|
|
49
52
|
if (client === this.owner(task)) return 'owner';
|
|
50
53
|
return typeof task === 'string' && this.db.prepare('SELECT permission FROM grants WHERE client=? AND task=?').get(client,task)?.permission;
|
|
@@ -79,6 +82,7 @@ export class AccessRegistry {
|
|
|
79
82
|
if (client === 'local' && !this.owner(task)) return engine.call(method,validateRequest(method,params),client);
|
|
80
83
|
fail('workspace_not_found');
|
|
81
84
|
}
|
|
85
|
+
if (method === 'adoptCurrentTab' && (permission !== 'owner' || this.hasDelegates(task))) fail('forbidden');
|
|
82
86
|
if (permission === 'read' && !readMethods.has(method)) fail('forbidden');
|
|
83
87
|
const scopedMethod = permission === 'read' && method === 'observe' ? 'observeReadOnly' : method;
|
|
84
88
|
const result = await engine.call(scopedMethod,validateRequest(method,params),this.owner(task),client);
|
|
@@ -134,6 +138,7 @@ export class AccessRegistry {
|
|
|
134
138
|
} else {
|
|
135
139
|
const owner = this.owner(workspaceId);
|
|
136
140
|
if (!owner || owner === principalId) fail('invalid_workspace');
|
|
141
|
+
if (method === 'grant' && engine.workspaces.get(workspaceId)?.singleTab) fail('single_tab_scope');
|
|
137
142
|
const prev = this.permission(principalId,workspaceId);
|
|
138
143
|
if (method === 'grant' && ['read','control'].includes(permission))
|
|
139
144
|
this.db.prepare('INSERT OR REPLACE INTO grants VALUES(?,?,?)').run(principalId,workspaceId,permission);
|
package/action-execution.mjs
CHANGED
|
@@ -43,6 +43,10 @@ async function fillOutcome(handle, expected, credential) {
|
|
|
43
43
|
return actual ? 'transformed' : 'unchanged';
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
+
async function agentDispatch(service, tab, work) {
|
|
47
|
+
return service.withAgentInput ? service.withAgentInput(tab, work) : work();
|
|
48
|
+
}
|
|
49
|
+
|
|
46
50
|
function beforeDispatch(service, ws, tab, op, documentId, generation) {
|
|
47
51
|
if (op.cancel) fail('operation_cancelled');
|
|
48
52
|
ensureBudget(op);
|
|
@@ -109,22 +113,27 @@ async function waitActionable(service, ws, tab, op, el, kind, documentId, genera
|
|
|
109
113
|
ensureBudget(op);
|
|
110
114
|
service.requireControl(ws, generation);
|
|
111
115
|
if (tab.documentId !== documentId) fail('stale_document');
|
|
112
|
-
const visible = await el.isVisible();
|
|
113
|
-
if (!visible && await el.evaluate(node => !node.isConnected)) fail('stale_ref');
|
|
114
116
|
const pointerAction = ['click', 'doubleClick', 'hover', 'drag', 'press', 'scroll'].includes(kind);
|
|
115
|
-
if (
|
|
116
|
-
// Trial performs Chromium's hit and stability checks
|
|
117
|
-
//
|
|
117
|
+
if (pointerAction) {
|
|
118
|
+
// Trial performs Chromium's hit, visibility, enabled and stability checks in
|
|
119
|
+
// one Playwright call. Avoid separate visibility and enabled RPCs for the
|
|
120
|
+
// common pointer path.
|
|
118
121
|
try {
|
|
119
122
|
if (kind === 'hover') await el.hover({ trial: true, timeout: Math.max(1, deadline - Date.now()) });
|
|
120
123
|
else await el.click({ trial: true, timeout: Math.max(1, deadline - Date.now()) });
|
|
121
124
|
return;
|
|
122
125
|
} catch (error) {
|
|
123
126
|
if (error.name !== 'TimeoutError') throw error;
|
|
127
|
+
if (!await el.evaluate(node => node.isConnected).catch(() => false)) fail('stale_ref');
|
|
124
128
|
if (op.cancel) fail('operation_cancelled');
|
|
125
|
-
|
|
129
|
+
if (Date.now() >= deadline)
|
|
130
|
+
fail(error.message.includes('intercepts pointer events') ? 'target_obscured' : 'target_not_actionable');
|
|
131
|
+
await delay(40, undefined, {signal:op.controller.signal});
|
|
132
|
+
continue;
|
|
126
133
|
}
|
|
127
134
|
}
|
|
135
|
+
const visible = await el.isVisible();
|
|
136
|
+
if (!visible && await el.evaluate(node => !node.isConnected)) fail('stale_ref');
|
|
128
137
|
if (visible && !pointerAction && await el.isEditable()) return;
|
|
129
138
|
if (Date.now() >= deadline) fail('timeout');
|
|
130
139
|
await delay(40, undefined, {signal:op.controller.signal});
|
|
@@ -198,8 +207,8 @@ export async function perform(service, ws, tab, { documentId, controlGeneration,
|
|
|
198
207
|
}
|
|
199
208
|
if (action.kind === 'spatial') {
|
|
200
209
|
try {
|
|
201
|
-
await service.visual.input(ws,tab,service.actors.getStore(),{...action,documentId,controlGeneration},'agent',
|
|
202
|
-
() => beforeDispatch(service, ws,tab,op,documentId,controlGeneration));
|
|
210
|
+
await agentDispatch(service, tab, () => service.visual.input(ws,tab,service.actors.getStore(),{...action,documentId,controlGeneration},'agent',
|
|
211
|
+
() => beforeDispatch(service, ws,tab,op,documentId,controlGeneration)));
|
|
203
212
|
} catch (error) {
|
|
204
213
|
if (!op.dispatched) fail(error.code || 'visual_action_failed');
|
|
205
214
|
tab.needsSubmissionReview=true;
|
|
@@ -215,7 +224,6 @@ export async function perform(service, ws, tab, { documentId, controlGeneration,
|
|
|
215
224
|
const frameEntry=tab.frameRefs.get(action.ref);
|
|
216
225
|
const el=frameEntry?.handle ?? tab.refs.get(action.ref);
|
|
217
226
|
if (!el) fail('stale_ref');
|
|
218
|
-
await service.checkSemanticTarget(ws,tab,action.ref,frameEntry,el,action.kind==='upload' ? 'click' : action.kind);
|
|
219
227
|
let destination;
|
|
220
228
|
if (action.kind === 'drag') {
|
|
221
229
|
const destinationFrame = tab.frameRefs.get(action.toRef);
|
|
@@ -245,8 +253,10 @@ export async function perform(service, ws, tab, { documentId, controlGeneration,
|
|
|
245
253
|
if (frameEntry) fail('file_origin_mismatch');
|
|
246
254
|
try { ws.uploads.get(ws,tab,action.fileId); } catch(error) { fail(error.code); }
|
|
247
255
|
await waitActionable(service, ws,tab,op,el,'click',documentId,controlGeneration);
|
|
256
|
+
await service.checkSemanticTarget(ws,tab,action.ref,frameEntry,el,'click');
|
|
248
257
|
await chooseGrantedFile(ws,tab,el,action.fileId,
|
|
249
258
|
()=>beforeDispatch(service, ws,tab,op,documentId,controlGeneration),
|
|
259
|
+
work => agentDispatch(service, tab, work),
|
|
250
260
|
()=>{ service.requireControl(ws,controlGeneration); if (op.cancel) fail('operation_cancelled'); });
|
|
251
261
|
} else if (action.kind === 'setChecked') {
|
|
252
262
|
const state = await el.evaluate(readCheckState);
|
|
@@ -258,7 +268,7 @@ export async function perform(service, ws, tab, { documentId, controlGeneration,
|
|
|
258
268
|
await service.checkSemanticTarget(ws,tab,action.ref,frameEntry,el,action.kind);
|
|
259
269
|
if (await el.evaluate(readCheckState) !== action.checked) {
|
|
260
270
|
beforeDispatch(service, ws,tab,op,documentId,controlGeneration);
|
|
261
|
-
await el.click({timeout:5000});
|
|
271
|
+
await agentDispatch(service, tab, () => el.click({timeout:5000}));
|
|
262
272
|
if (await el.evaluate(readCheckState) !== action.checked) fail('state_mismatch');
|
|
263
273
|
}
|
|
264
274
|
}
|
|
@@ -273,7 +283,7 @@ export async function perform(service, ws, tab, { documentId, controlGeneration,
|
|
|
273
283
|
rememberBlock(ws, webOrigin(target), 'navigation', 'document', 'origin_denied');
|
|
274
284
|
fail('origin_denied');
|
|
275
285
|
}
|
|
276
|
-
service.notifyTarget(ws, tab, el, documentId, controlGeneration, origin);
|
|
286
|
+
service.notifyTarget(ws, tab, el, documentId, controlGeneration, origin, action.kind);
|
|
277
287
|
await waitActionable(service, ws, tab, op, el, action.kind, documentId, controlGeneration);
|
|
278
288
|
await service.checkSemanticTarget(ws,tab,action.ref,frameEntry,el,action.kind);
|
|
279
289
|
clickProbe = await armClickProbe(el, 1);
|
|
@@ -296,33 +306,33 @@ export async function perform(service, ws, tab, { documentId, controlGeneration,
|
|
|
296
306
|
interrupt = () => { if (tab.dialog) reject(new ServiceError('operation_cancelled')); };
|
|
297
307
|
op.controller.signal.addEventListener('abort',interrupt,{once:true});
|
|
298
308
|
});
|
|
299
|
-
try { await Promise.race([el.click({timeout:5000,noWaitAfter:!!navigationStart}), suspended]); }
|
|
309
|
+
try { await agentDispatch(service, tab, () => Promise.race([el.click({timeout:5000,noWaitAfter:!!navigationStart}), suspended])); }
|
|
300
310
|
finally { op.controller.signal.removeEventListener('abort',interrupt); }
|
|
301
311
|
if (lease.opening) await lease.opening;
|
|
302
312
|
}
|
|
303
313
|
} else if (action.kind === 'doubleClick' || action.kind === 'hover' || action.kind === 'press' || action.kind === 'scroll' || action.kind === 'drag') {
|
|
304
|
-
service.notifyTarget(ws, tab, el, documentId, controlGeneration, origin);
|
|
314
|
+
service.notifyTarget(ws, tab, el, documentId, controlGeneration, origin, action.kind);
|
|
305
315
|
await waitActionable(service, ws, tab, op, el, action.kind, documentId, controlGeneration);
|
|
306
316
|
await service.checkSemanticTarget(ws,tab,action.ref,frameEntry,el,action.kind);
|
|
307
317
|
if (action.kind === 'doubleClick') clickProbe = await armClickProbe(el, 2);
|
|
308
318
|
beforeDispatch(service, ws, tab, op, documentId, controlGeneration);
|
|
309
319
|
if (action.kind === 'doubleClick') {
|
|
310
|
-
await el.dblclick({timeout:5000});
|
|
320
|
+
await agentDispatch(service, tab, () => el.dblclick({timeout:5000}));
|
|
311
321
|
}
|
|
312
|
-
else if (action.kind === 'hover') await el.hover({timeout:5000});
|
|
313
|
-
else if (action.kind === 'press') await el.press(action.key, {timeout:5000});
|
|
322
|
+
else if (action.kind === 'hover') await agentDispatch(service, tab, () => el.hover({timeout:5000}));
|
|
323
|
+
else if (action.kind === 'press') await agentDispatch(service, tab, () => el.press(action.key, {timeout:5000}));
|
|
314
324
|
else if (action.kind === 'scroll') {
|
|
315
325
|
await el.scrollIntoViewIfNeeded({timeout:5000});
|
|
316
|
-
await tab.page.mouse.wheel(action.deltaX ?? 0, action.deltaY);
|
|
317
|
-
} else await el.dragTo(destination, {timeout:5000});
|
|
326
|
+
await agentDispatch(service, tab, () => tab.page.mouse.wheel(action.deltaX ?? 0, action.deltaY));
|
|
327
|
+
} else await agentDispatch(service, tab, () => el.dragTo(destination, {timeout:5000}));
|
|
318
328
|
} else {
|
|
319
|
-
service.notifyTarget(ws, tab, el, documentId, controlGeneration, origin);
|
|
329
|
+
service.notifyTarget(ws, tab, el, documentId, controlGeneration, origin, action.kind);
|
|
320
330
|
await waitActionable(service, ws, tab, op, el, action.kind, documentId, controlGeneration);
|
|
321
331
|
await service.checkSemanticTarget(ws,tab,action.ref,frameEntry,el,action.kind);
|
|
322
332
|
beforeDispatch(service, ws, tab, op, documentId, controlGeneration);
|
|
323
|
-
if (action.kind === 'select') await el.selectOption({ value }, {timeout:5000});
|
|
333
|
+
if (action.kind === 'select') await agentDispatch(service, tab, () => el.selectOption({ value }, {timeout:5000}));
|
|
324
334
|
else {
|
|
325
|
-
await el.fill(value, {timeout:5000});
|
|
335
|
+
await agentDispatch(service, tab, () => el.fill(value, {timeout:5000}));
|
|
326
336
|
receipt.fillOutcome = await fillOutcome(el, value, action.kind === 'fillCredential');
|
|
327
337
|
}
|
|
328
338
|
}
|
|
@@ -344,6 +354,7 @@ export async function perform(service, ws, tab, { documentId, controlGeneration,
|
|
|
344
354
|
return;
|
|
345
355
|
}
|
|
346
356
|
receipt.completedSteps++;
|
|
357
|
+
service.invalidateObservation?.(tab);
|
|
347
358
|
receipt.phase = 'verifying';
|
|
348
359
|
op.dispatched = false;
|
|
349
360
|
service.store.save(ws.owner, ws.id, op.digest, receipt);
|
package/api-contract.mjs
CHANGED
|
@@ -77,13 +77,25 @@ const definitions = {
|
|
|
77
77
|
...workspace, controlGeneration: id, origin: { type:'string', format:'uri' },
|
|
78
78
|
scope: { enum:['navigation','resource'], type:'string' },
|
|
79
79
|
}, ['workspaceId','controlGeneration','origin','scope']],
|
|
80
|
-
|
|
80
|
+
canvasSnapshot: ['Read visible React Flow nodes and edges, chat turns and download labels. Compare snapshotVersion after an action. Unsupported markup is reported explicitly.',page],
|
|
81
|
+
adoptCurrentTab: ['Redeem the two-minute token issued by the user for this empty named workspace. The original tab stays open at finish.', {...workspace,adoptionToken:{type:'string',pattern:'^[0-9a-f]{64}$'}}],
|
|
82
|
+
reattachPage: ['Refresh the exact managed page after the user returns control. Returns a fresh observation. Set waitMs to wait for human control to return.',{...page,waitMs:{type:'integer',minimum:1,maximum:30000}},Object.keys(page)],
|
|
83
|
+
previewFinish: ['Preview which pages will stay open and which will close. Pass previewId to finishWorkspace to require this plan.',{...workspace,keepPageIds:{type:'array',uniqueItems:true,items:id}}],
|
|
84
|
+
getWorkspace: ['Read workspace control, page availability and extension synchronization. Supply profileId to verify the expected profile.', {...workspace,profileId:id},['workspaceId']],
|
|
81
85
|
openPage: ['Open a page in the workspace.', { ...workspace, url: { type: 'string', format: 'uri' } }],
|
|
82
86
|
observe: ['Read visible controls. Continue a truncated observation with nextCursor or filter by name or viewport region. After stale_ref, stale_document or user handoff, observe again before acting.', {
|
|
83
87
|
...page, includeFrames:{type:'boolean'}, frameControls:{type:'boolean'},
|
|
84
88
|
locator:object({role:id,name:id,within:object({role:id,name:id})},['role','name']),
|
|
85
89
|
cursor:id, limit:{type:'integer',minimum:1,maximum:180}, name:id, region,
|
|
86
90
|
}, Object.keys(page)],
|
|
91
|
+
observeAndAct: ['Observe the current page and submit an ordered action batch through one service request. The service binds the actions to the returned document and control generation before queueing them.', {
|
|
92
|
+
...page, includeFrames:{type:'boolean'}, frameControls:{type:'boolean'},
|
|
93
|
+
locator:object({role:id,name:id,within:object({role:id,name:id})},['role','name']),
|
|
94
|
+
cursor:id, limit:{type:'integer',minimum:1,maximum:180}, name:id, region,
|
|
95
|
+
operationId:id, timeoutMs:{type:'integer',minimum:1,maximum:60000},
|
|
96
|
+
observeAfter:{enum:['full','delta']},
|
|
97
|
+
actions:{type:'array',minItems:1,maxItems:32,items:action},
|
|
98
|
+
}, ['workspaceId','pageId','operationId','actions']],
|
|
87
99
|
act: ['Submit ordered actions for the observed document and control generation. Use fillCredential for login secrets. Supply a unique operationId. The optional timeout is a wall-clock budget shared by queueing and execution. After a timeout or outcome_unknown, query the receipt and verify the site before retrying.', {
|
|
88
100
|
...page, operationId: id, documentId: id, controlGeneration: id,
|
|
89
101
|
timeoutMs:{type:'integer',minimum:1,maximum:60000},
|
|
@@ -103,7 +115,7 @@ const definitions = {
|
|
|
103
115
|
listEvents:['Poll redacted changes since a sequence number.',history,['workspaceId']],
|
|
104
116
|
getRecoverySummary:['Read task recovery steps, delivered objects and page availability. Observe or verify before resuming.',{...history,objectsAfter:{type:'integer',minimum:0}},['workspaceId']],
|
|
105
117
|
listOperations:['Read redacted receipt history.',history,['workspaceId']],
|
|
106
|
-
finishWorkspace:['Call when the overall task is complete, before reporting success. Keep selected result tabs as ordinary tabs and remove the task group. Use an empty list when there are no results to keep.',{...operation,keepPageIds:{type:'array',uniqueItems:true,items:id}}],
|
|
118
|
+
finishWorkspace:['Call when the overall task is complete, before reporting success. Keep selected result tabs as ordinary tabs and remove the task group. Use an empty list when there are no results to keep.',{...operation,keepPageIds:{type:'array',uniqueItems:true,items:id},previewId:id},['workspaceId','operationId','keepPageIds']],
|
|
107
119
|
diagnoseOperation: ['Preview a redacted diagnostic with the next safe action. Use it after a timeout, disconnect or outcome_unknown.', operation],
|
|
108
120
|
getOperation: ['Read an operation receipt, including its completed step count.', operation],
|
|
109
121
|
cancelOperation: ['Cancel the remaining steps of an operation.', operation],
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"manifest_version": 3,
|
|
3
3
|
"name": "open-browser",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.2.0",
|
|
5
5
|
"description": "管理本机 Agent 工作区与 Chromium 标签组",
|
|
6
6
|
"key": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAhZVSXIA/vfzO0jj4ebn25I3lbL//y8FbZUeQ8Q9shwfMWTbl3bsjcHzIITSGg5+NqVTAEB1AgjFZDi/Idoj+tgsvwQxXbMBzgdZA1tQMASXcbFRdVNTxWbRBSd4JXtsFfD7H6QeBwXuIHNqUeyQYD0sYn8Ot0c4KJCzsYshYPLU56+Lzdoy+7l6ydmmw31T4tpanZHJvUgyzATOjEekFJii+9IEI/G4BUGQhKdPqR/MBYiqzxgPB5WIr3w25z6bH5KC6wnUxblLQM0RAHa4hot38NOFul5JCW6BOLHEes7Pz3DOUpWFP+DFSkY42r0dt1Kh/5CFKr6ED3agcc+tB1wIDAQAB",
|
|
7
7
|
"permissions": [
|
|
@@ -23,9 +23,6 @@
|
|
|
23
23
|
"128": "icons/open-browser-128.png"
|
|
24
24
|
}
|
|
25
25
|
},
|
|
26
|
-
"chrome_url_overrides": {
|
|
27
|
-
"newtab": "newtab.html"
|
|
28
|
-
},
|
|
29
26
|
"content_security_policy": {
|
|
30
27
|
"extension_pages": "script-src 'self'; object-src 'none'; connect-src 'none'; frame-ancestors 'none'; base-uri 'none'"
|
|
31
28
|
},
|
|
@@ -16,5 +16,11 @@ section { margin-top: 34px; } .section-title { margin-bottom: 12px; }
|
|
|
16
16
|
.history-list { display: grid; gap: 2px; border-top: 1px solid color-mix(in srgb, CanvasText 12%, transparent); }
|
|
17
17
|
.history-row { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 12px 2px; border-bottom: 1px solid color-mix(in srgb, CanvasText 10%, transparent); }
|
|
18
18
|
.history-title { display: block; font-size: 14px; font-weight: 600; } .history-meta { display: grid; justify-items: end; gap: 4px; white-space: nowrap; } .history-state { font-size: 12px; font-weight: 600; color: #28734c; } .history-state.failed, .history-state.outcome_unknown { color: #a44b2b; }
|
|
19
|
+
.record-button { margin-top: 10px; font-size: 12px; }
|
|
20
|
+
.timeline { display: grid; gap: 4px; margin-top: 10px; padding: 8px 10px; border-left: 2px solid color-mix(in srgb, CanvasText 20%, transparent); }
|
|
21
|
+
.timeline-row { display: block; color: color-mix(in srgb, CanvasText 70%, Canvas); font: 11px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; }
|
|
22
|
+
.history-actions { display: flex; align-items: center; }
|
|
23
|
+
.history-row { flex-wrap: wrap; }
|
|
24
|
+
.history-row .timeline { flex-basis: 100%; }
|
|
19
25
|
.empty { padding: 22px 0; } .quiet { cursor: pointer; color: color-mix(in srgb, CanvasText 68%, Canvas); background: none; border: 0; text-decoration: none; padding: 4px 0; font: inherit; } #notice.error { color: #a44b2b; } [hidden] { display: none !important; }
|
|
20
26
|
@media (max-width: 700px) { body { min-width: 0; } header { padding: 0 20px; } main { width: calc(100% - 40px); margin-top: 28px; } }
|