@seekskyworld/open-browser 0.1.0 → 0.3.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 +32 -10
- 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 +13 -3
- package/action-execution.mjs +60 -24
- package/api-contract.mjs +19 -7
- package/browser-extension/manifest.json +1 -4
- package/browser-extension/newtab.css +6 -0
- package/browser-extension/newtab.js +54 -2
- package/browser-extension/phase-labels.js +1 -1
- package/browser-extension/popup.css +1 -1
- package/browser-extension/popup.html +16 -4
- package/browser-extension/popup.js +122 -21
- package/browser-extension/tab-action.js +4 -2
- package/browser-extension/worker.js +102 -9
- package/build-profile.mjs +23 -0
- package/capability-matrix.mjs +4 -4
- package/chromium-host.mjs +81 -25
- package/chromium-shell.mjs +78 -49
- package/cli.mjs +63 -5
- package/contract-validation.mjs +1 -1
- package/desktop/Info.plist +2 -2
- package/desktop/OBControlBar.m +7 -3
- package/desktop/WorkspacePanel.m +4 -2
- package/desktop/brand-keychain.py +20 -4
- package/desktop/build-macos.mjs +31 -12
- 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 +189 -0
- package/desktop/package-macos.mjs +54 -0
- package/desktop/patches/chromium-managed-input.patch +144 -0
- package/desktop/sign.mjs +63 -4
- package/desktop/start-profile.mjs +5 -0
- package/desktop/start.mjs +25 -3
- package/desktop/verify-macos-release.mjs +69 -0
- package/desktop/verify-version.mjs +22 -2
- package/diagnostics.mjs +9 -0
- package/engine-service.mjs +244 -29
- package/managed-input.mjs +155 -0
- package/mcp-http.mjs +84 -0
- package/mcp-server.mjs +57 -0
- package/mcp.mjs +3 -40
- package/package.json +24 -3
- package/page-activity.mjs +97 -29
- package/page-observation.mjs +44 -3
- package/paths.mjs +5 -3
- package/receipt-store.mjs +24 -7
- package/runtime.mjs +10 -1
- package/sdk.mjs +53 -26
- package/service.mjs +45 -10
- package/skill-links.mjs +144 -0
- package/skills/open-browser/SKILL.md +8 -76
- package/skills/open-browser/references/macos.md +3 -0
- package/skills/open-browser/references/operations.md +59 -0
- package/skills/open-browser/references/recovery.md +36 -0
- package/skills/open-browser/references/windows.md +3 -0
- package/skills/open-browser/scripts/bootstrap.mjs +112 -45
- package/skills/open-browser/scripts/guide.mjs +17 -0
- package/studio/studio.js +2 -2
- package/tab-adoption.mjs +83 -0
- package/tab-recovery.mjs +100 -0
- package/uploads.mjs +4 -4
- package/visual-page.mjs +17 -7
- package/workspace-lifecycle.mjs +92 -8
- package/workspace-state.mjs +65 -12
|
@@ -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 & { readyForAgent:boolean; 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;
|
|
@@ -167,6 +176,7 @@ export interface OperationReceipt {
|
|
|
167
176
|
stepKind?: PageAction['kind'];
|
|
168
177
|
completedSteps: number;
|
|
169
178
|
error?: string;
|
|
179
|
+
obstruction?:{targetBounds:{x:number;y:number;width:number;height:number};element:string;inDialog:boolean;inputGuard:string;cause:'foreground_dialog'|'element_intercepts_pointer'|'unknown';nextAction:'inspect_dialog'|'observe_target';dialogBounds?:{x:number;y:number;width:number;height:number}};
|
|
170
180
|
observation?: PageObservation;
|
|
171
181
|
delta?: {changed?: ObservedElement[]; textChanged:boolean; text?:string; added:Array<{role:string;name:string}>; removed:Array<{role:string;name:string}>};
|
|
172
182
|
dialogIds?: string[];
|
|
@@ -179,7 +189,7 @@ export interface OperationReceipt {
|
|
|
179
189
|
|
|
180
190
|
/** CLI and MCP call this surface through the same SDK. */
|
|
181
191
|
export interface OpenBrowserV1 {
|
|
182
|
-
capabilities(): Promise<{version:number;contractVersion?:number;methods?:readonly string[];limits?:Readonly<Record<string,number>>;privacy?:{
|
|
192
|
+
capabilities(options?:{signal?:AbortSignal}): Promise<{version:number;contractVersion?:number;methods?:readonly string[];limits?:Readonly<Record<string,number>>;privacy?:{
|
|
183
193
|
profile:'strict'|'compatibility'|string;
|
|
184
194
|
telemetry:'disabled';
|
|
185
195
|
chromiumServices:'reduced'|'compatibility';
|
|
@@ -187,7 +197,7 @@ export interface OpenBrowserV1 {
|
|
|
187
197
|
diagnostics:'redacted';
|
|
188
198
|
credentials:'memory-scoped';
|
|
189
199
|
};visual:{enabled:boolean;actions:readonly string[]}}>;
|
|
190
|
-
captureVisual(page:PageHandle,options?:{region?:VisualRect;ref?:string}):Promise<VisualFrame>;
|
|
200
|
+
captureVisual(page:PageHandle,options?:{region?:VisualRect;ref?:string;liveCanvas?:boolean}):Promise<VisualFrame>;
|
|
191
201
|
createWorkspace(options?: CreateWorkspaceOptions): Promise<WorkspaceInfo>;
|
|
192
202
|
open(options: OpenOptions): Promise<PageHandle>;
|
|
193
203
|
/** SDK convenience. Opens one URL and observes it with fresh document metadata. */
|
|
@@ -195,7 +205,17 @@ export interface OpenBrowserV1 {
|
|
|
195
205
|
listWorkspaces(): Promise<WorkspaceInfo[]>;
|
|
196
206
|
getWorkspace(workspaceId: string): Promise<WorkspaceInfo>;
|
|
197
207
|
openPage(workspaceId: string, url: string): Promise<PageHandle>;
|
|
208
|
+
adoptCurrentTab(workspaceId:string, adoptionToken:string):Promise<PageHandle>;
|
|
209
|
+
reattachPage(page:PageHandle, options?:{waitMs?:number}):Promise<PageObservation>;
|
|
210
|
+
previewFinish(workspaceId:string, keepPageIds?:string[]):Promise<{previewId:string; keptPageIds:string[]; closedPageIds:string[]}>;
|
|
211
|
+
canvasSnapshot(page:PageHandle):Promise<PageHandle & {documentId:string; controlGeneration:string; snapshotVersion:string;
|
|
212
|
+
adapter:'react-flow'|'chat'|'unsupported'; reason?:'canvas_without_semantic_adapter'|'no_supported_markup';
|
|
213
|
+
fallback?:{dom:'observe';visualStatus:string;visual?:'captureVisual';grant?:'admin.setPixelPermission'|'extension_pixel_permission';origin?:string}; nodes:Array<{id:string; label:string; selected:boolean}>;
|
|
214
|
+
edges:Array<{id:string; label:string; selected:boolean; source?:string; target?:string}>; messages:Array<{role:string; text:string}>;
|
|
215
|
+
attachments:Array<{label:string}>; truncated:boolean}>;
|
|
198
216
|
observe(page: PageHandle & ObserveOptions): Promise<PageObservation>;
|
|
217
|
+
/** SDK convenience. Observes and queues an action batch through one service request. */
|
|
218
|
+
observeAndAct(page: PageHandle & ObserveOptions, request: {actions: readonly PageAction[];operationId?:string;waitMs?:number;observeAfter?:'full'|'delta';timeoutMs?:number}): Promise<{observation:PageObservation;receipt:OperationReceipt}>;
|
|
199
219
|
runWorkflow(page:PageHandle,request:WorkflowRequest):Promise<OperationReceipt>;
|
|
200
220
|
act(page: PageHandle, request: {
|
|
201
221
|
operationId: string;
|
|
@@ -207,10 +227,10 @@ export interface OpenBrowserV1 {
|
|
|
207
227
|
timeoutMs?: number;
|
|
208
228
|
}): Promise<OperationReceipt>;
|
|
209
229
|
/** SDK convenience. Observes immediately before acting and generates an operation ID when omitted. */
|
|
210
|
-
actAfterObserve(page: PageHandle, request: {actions: readonly PageAction[];operationId?:string;observeAfter?:'full'|'delta';timeoutMs?:number}): Promise<{observation:PageObservation;receipt:OperationReceipt}>;
|
|
230
|
+
actAfterObserve(page: PageHandle, request: {actions: readonly PageAction[];operationId?:string;waitMs?:number;observeAfter?:'full'|'delta';timeoutMs?:number}): Promise<{observation:PageObservation;receipt:OperationReceipt}>;
|
|
211
231
|
diagnoseOperation(workspaceId:string,operationId:string):Promise<{version:1;state:string;phase?:OperationReceipt['phase'];totalSteps?:number;completedSteps:number;dispatchRecorded:boolean;category:string;nextAction:string}>;
|
|
212
|
-
getOperation(workspaceId: string, operationId: string): Promise<OperationReceipt>;
|
|
213
|
-
finishWorkspace(workspaceId:string, keepPageIds:string[], operationId:string): Promise<OperationReceipt>;
|
|
232
|
+
getOperation(workspaceId: string, operationId: string, options?:{waitMs?:number}): Promise<OperationReceipt>;
|
|
233
|
+
finishWorkspace(workspaceId:string, keepPageIds:string[], operationId:string, previewId?:string): Promise<OperationReceipt>;
|
|
214
234
|
/** SDK convenience. Generates a fresh idempotency key for finishing a workspace. */
|
|
215
235
|
finish(workspaceId:string, keepPageIds?:string[]): Promise<OperationReceipt>;
|
|
216
236
|
respondDialog(page:PageHandle, response:{controlGeneration:string;dialogId:string;accept:boolean;text?:string}):Promise<{dialogId:string;accepted:boolean}>;
|
|
@@ -220,12 +240,14 @@ export interface OpenBrowserV1 {
|
|
|
220
240
|
readOutput(workspaceId:string, outputId:string, options?:{partName?:string;offset?:number;limit?:number}): Promise<OutputChunk>;
|
|
221
241
|
cancelDownload(workspaceId:string,downloadId:string): Promise<WorkspaceDownload>;
|
|
222
242
|
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'}>;
|
|
243
|
+
workspaceId:string; mode:WorkspaceInfo['mode']|'unavailable'; closeReason?:'explicit_close'|'idle_timeout'|'finished'|'service_shutdown'|'open_failed'|'unknown'; pages:Array<{pageId:string;origin?:string;next:'observe'|'handle_unavailable'; lastDisposition?:'released'|'closed'; pageAvailability:'managed'|'restorable'|'unregistered'|'closed'; nextAction:string}>;
|
|
224
244
|
deliveries:Array<{downloadId:string}>; outputs:Array<{outputId:string}>; operations:Array<OperationReceipt & {next:'verify_site'|'poll'|'already_completed'|'inspect_receipt'}>;
|
|
225
245
|
nextCursor:number|null; nextObjectCursor:number|null;
|
|
226
246
|
}>;
|
|
227
247
|
listOperations(workspaceId:string, options?:{after?:number;limit?:number}): Promise<{operations:OperationReceipt[];nextCursor:number|null}>;
|
|
228
248
|
eventCursor(workspaceId:string):Promise<{nextCursor:number}>;
|
|
249
|
+
waitForEvent(page:{workspaceId:string}, options:{after:number;kind:'page_bound';timeoutMs?:number}):
|
|
250
|
+
Promise<{event:null|{sequence:number;kind:string;state:string;pageId:string;resourceId:string};nextCursor:number}>;
|
|
229
251
|
waitForEvent(page:PageHandle, options:{after:number;kind:'dialog'|'download'|'popup';operationId?:string;timeoutMs?:number}):
|
|
230
252
|
Promise<{event:null|{sequence:number;kind:string;state:string;pageId:string;resourceId:string;operationId?:string};nextCursor:number}>;
|
|
231
253
|
listEvents(workspaceId:string, options?:{after?:number;limit?:number}): Promise<{
|
|
@@ -261,7 +283,7 @@ export interface OpenBrowserHostV1 {
|
|
|
261
283
|
previewPage(page: PageHandle): Promise<Omit<PageObservation, 'elements'>>;
|
|
262
284
|
showPage(page: PageHandle): Promise<PageHandle>;
|
|
263
285
|
takeControl(params: { workspaceId: string; pageId?: string; controlGeneration?: string }): Promise<WorkspaceInfo>;
|
|
264
|
-
returnToAgent(params: { workspaceId: string; controlGeneration?: string }): Promise<WorkspaceInfo>;
|
|
286
|
+
returnToAgent(params: { workspaceId: string; pageId?:string; controlGeneration?: string }): Promise<WorkspaceInfo & {observation?:PageObservation;pageError?:{pageId:string;code:string}}>;
|
|
265
287
|
grantOrigin(params:{workspaceId:string;controlGeneration:string;origin:string;scope:'resource'|'navigation'}):Promise<unknown>;
|
|
266
288
|
resolveCredential(params:PageHandle & {documentId:string;controlGeneration:string;operationId:string;origin:string;credentialRef:string;value:string}):Promise<{credentialRef:string;saved:true}>;
|
|
267
289
|
setCredential(params: {
|
|
@@ -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
|
+
每次公开发行都要提供 Apple Silicon 和 Intel 两份 DMG。两个架构分别使用 `npm run build:release-macos:arm64` 和 `npm run build:release-macos:x64`。脚本先公证应用并固化票据,再对最终 DMG 签名、单独提交 Apple 公证并固化镜像票据。使用 `npm run release:verify-macos -- dist/open-browser.app` 和 `npm run release:verify-macos -- dist/open-browser-x64.app` 分别验收。`npm run package:macos*` 只用于本地安装测试。
|
|
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.dmg`、ZIP 及 SHA-256 |
|
|
38
|
+
| macOS x64 GitHub 发行 | `npm run build:release-macos:x64` | 已公证并固化票据的 `dist/open-browser-macos-x64.dmg`、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:arm64` 或 `npm run build:release-macos:x64`,它会用 `xcrun notarytool` 提交公证,执行 `xcrun stapler staple`,生成含票据的 GitHub DMG 和 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 DMG 和 ZIP。若需改变产物路径,可设置 `OPEN_BROWSER_NOTARY_ZIP`、`OPEN_BROWSER_NOTARY_DMG` 或传入 `--zip`、`--dmg`。公证完成后,使用 `npm run release:verify-macos`,并保存构建提交、系统架构、DMG 和 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.3.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 approve control of that tab. 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 public GitHub DMG and ZIP releases, set a notarytool profile or CI credentials and run `npm run build:release-macos:arm64` or `npm run build:release-macos:x64`, 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
|
|
62
|
+
Agents using the [open-browser Skill](skills/open-browser/SKILL.md) call the CLI through `skills/open-browser/scripts/open-browser`. The launcher starts the local app or portable service if needed. It retries once when the service could not accept the request. If a write loses its reply, the launcher returns `RESPONSE_LOST`. Check the workspace or operation receipt before submitting again. 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
|
+
At service startup and on the first Skill call, 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 user files and unrelated links. Windows uses a directory junction when the account lacks permission to create symbolic links. Skill calls reuse a successful scan for ten minutes. Newly installed agents are discovered on the next service start or the first call after the cache expires. Run `node skill-links.mjs` from the package directory for an immediate scan. 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 DMG 和 ZIP 时,配置 notarytool 钥匙串配置或 CI 凭据,运行 `npm run build:release-macos:arm64` 或 `npm run build:release-macos:x64`,再运行 `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。启动器按需启动本机应用或便携服务。如果服务尚未接收请求,就绪后会重试一次。写操作发出后回包中断时会返回 `RESPONSE_LOST`,请先核对工作区或操作回执。设置 `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` 相对符号链接。已有文件和指向其他内容的链接会保留。Windows 账号缺少创建符号链接的权限时,会使用目录联接。Skill 会复用最近十分钟内的成功扫描。新装的 Agent 会在服务下次启动或缓存过期后的首次调用时补链。在包目录运行 `node skill-links.mjs` 可立即扫描。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
|
@@ -26,6 +26,9 @@ export class AccessRegistry {
|
|
|
26
26
|
id TEXT PRIMARY KEY, owner TEXT NOT NULL, name TEXT NOT NULL DEFAULT '',
|
|
27
27
|
agentName TEXT NOT NULL DEFAULT '', createdAt INTEGER NOT NULL DEFAULT 0,
|
|
28
28
|
updatedAt INTEGER NOT NULL DEFAULT 0);
|
|
29
|
+
CREATE TABLE IF NOT EXISTS resumable_tabs(
|
|
30
|
+
task TEXT PRIMARY KEY REFERENCES tasks(id) ON DELETE CASCADE,
|
|
31
|
+
page TEXT NOT NULL, origin TEXT NOT NULL, entry TEXT NOT NULL, expires INTEGER NOT NULL);
|
|
29
32
|
CREATE TABLE IF NOT EXISTS grants(client TEXT REFERENCES clients(id) ON DELETE CASCADE,
|
|
30
33
|
task TEXT REFERENCES tasks(id) ON DELETE CASCADE,permission TEXT NOT NULL,PRIMARY KEY(client,task));`);
|
|
31
34
|
const taskColumns = new Set(this.db.prepare('PRAGMA table_info(tasks)').all().map(field => field.name));
|
|
@@ -45,22 +48,27 @@ export class AccessRegistry {
|
|
|
45
48
|
owner(task) {
|
|
46
49
|
return typeof task === 'string' && this.db.prepare('SELECT owner FROM tasks WHERE id=?').get(task)?.owner;
|
|
47
50
|
}
|
|
51
|
+
hasDelegates(task) {
|
|
52
|
+
return !!this.db.prepare('SELECT 1 FROM grants WHERE task=? LIMIT 1').get(task);
|
|
53
|
+
}
|
|
48
54
|
permission(client, task) {
|
|
49
55
|
if (client === this.owner(task)) return 'owner';
|
|
50
56
|
return typeof task === 'string' && this.db.prepare('SELECT permission FROM grants WHERE client=? AND task=?').get(client,task)?.permission;
|
|
51
57
|
}
|
|
52
58
|
async call(engine, client, method, params) {
|
|
53
|
-
if (['capabilities','listWorkspaces','createWorkspace'].includes(method)) params = validateRequest(method,params);
|
|
59
|
+
if (['capabilities','listWorkspaces','createWorkspace','open'].includes(method)) params = validateRequest(method,params);
|
|
54
60
|
if (method === 'capabilities') return engine.call(method,{},client);
|
|
55
|
-
if (method === 'createWorkspace') {
|
|
61
|
+
if (method === 'createWorkspace' || method === 'open') {
|
|
56
62
|
const info = await engine.call(method, params, client);
|
|
57
63
|
if (client !== 'local' && !this.db.prepare('SELECT id FROM clients WHERE id=?').get(client)) {
|
|
58
64
|
await engine.call('closeWorkspace', {workspaceId:info.workspaceId}, client);
|
|
59
65
|
fail('forbidden');
|
|
60
66
|
}
|
|
67
|
+
const workspace = engine.workspaces.get(info.workspaceId);
|
|
68
|
+
if (!workspace) fail('workspace_not_found');
|
|
61
69
|
const now = Date.now();
|
|
62
70
|
this.db.prepare('INSERT INTO tasks(id,owner,name,agentName,createdAt,updatedAt) VALUES(?,?,?,?,?,?)')
|
|
63
|
-
.run(info.workspaceId, client,
|
|
71
|
+
.run(info.workspaceId, client, workspace.name, workspace.agentName, now, now);
|
|
64
72
|
return info;
|
|
65
73
|
}
|
|
66
74
|
if (method === 'listWorkspaces') {
|
|
@@ -79,6 +87,7 @@ export class AccessRegistry {
|
|
|
79
87
|
if (client === 'local' && !this.owner(task)) return engine.call(method,validateRequest(method,params),client);
|
|
80
88
|
fail('workspace_not_found');
|
|
81
89
|
}
|
|
90
|
+
if (method === 'adoptCurrentTab' && (permission !== 'owner' || this.hasDelegates(task))) fail('forbidden');
|
|
82
91
|
if (permission === 'read' && !readMethods.has(method)) fail('forbidden');
|
|
83
92
|
const scopedMethod = permission === 'read' && method === 'observe' ? 'observeReadOnly' : method;
|
|
84
93
|
const result = await engine.call(scopedMethod,validateRequest(method,params),this.owner(task),client);
|
|
@@ -134,6 +143,7 @@ export class AccessRegistry {
|
|
|
134
143
|
} else {
|
|
135
144
|
const owner = this.owner(workspaceId);
|
|
136
145
|
if (!owner || owner === principalId) fail('invalid_workspace');
|
|
146
|
+
if (method === 'grant' && engine.workspaces.get(workspaceId)?.singleTab) fail('single_tab_scope');
|
|
137
147
|
const prev = this.permission(principalId,workspaceId);
|
|
138
148
|
if (method === 'grant' && ['read','control'].includes(permission))
|
|
139
149
|
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);
|
|
@@ -98,6 +102,21 @@ async function consumeClickProbe(handle, probeId, expectedClicks) {
|
|
|
98
102
|
} catch { return false; }
|
|
99
103
|
}
|
|
100
104
|
|
|
105
|
+
// Report only geometry and a small vocabulary of roles from the target frame.
|
|
106
|
+
function inspectObstruction(target) {
|
|
107
|
+
const rect = target.getBoundingClientRect();
|
|
108
|
+
const hit = document.elementFromPoint(rect.x + rect.width / 2, rect.y + rect.height / 2);
|
|
109
|
+
const blocked = hit && hit !== target && !target.contains(hit);
|
|
110
|
+
const element = blocked && ['button','div','dialog','section','aside','iframe'].includes(hit.localName)
|
|
111
|
+
? hit.localName : blocked ? 'other' : 'unknown';
|
|
112
|
+
const dialog = blocked && hit.closest('dialog,[role="dialog"],[role="alertdialog"],[aria-modal="true"]');
|
|
113
|
+
const bounds = r => ({x:r.x,y:r.y,width:r.width,height:r.height});
|
|
114
|
+
return {targetBounds:bounds(rect), element, inDialog:!!dialog,
|
|
115
|
+
cause:dialog ? 'foreground_dialog' : blocked ? 'element_intercepts_pointer' : 'unknown',
|
|
116
|
+
nextAction:dialog ? 'inspect_dialog' : 'observe_target',
|
|
117
|
+
...(dialog && {dialogBounds:bounds(dialog.getBoundingClientRect())})};
|
|
118
|
+
}
|
|
119
|
+
|
|
101
120
|
async function waitActionable(service, ws, tab, op, el, kind, documentId, generation) {
|
|
102
121
|
if (op.receipt.phase !== 'actionability') {
|
|
103
122
|
op.receipt.phase = 'actionability';
|
|
@@ -105,26 +124,34 @@ async function waitActionable(service, ws, tab, op, el, kind, documentId, genera
|
|
|
105
124
|
service.notify(ws);
|
|
106
125
|
}
|
|
107
126
|
const deadline = Math.min(Date.now() + 5000, op.deadline ?? Infinity);
|
|
127
|
+
let obscured = false;
|
|
108
128
|
while (!op.cancel) {
|
|
109
129
|
ensureBudget(op);
|
|
110
130
|
service.requireControl(ws, generation);
|
|
111
131
|
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
132
|
const pointerAction = ['click', 'doubleClick', 'hover', 'drag', 'press', 'scroll'].includes(kind);
|
|
115
|
-
if (
|
|
116
|
-
// Trial performs Chromium's hit and stability checks
|
|
117
|
-
//
|
|
133
|
+
if (pointerAction) {
|
|
134
|
+
// Trial performs Chromium's hit, visibility, enabled and stability checks in
|
|
135
|
+
// one Playwright call. Avoid separate visibility and enabled RPCs for the
|
|
136
|
+
// common pointer path.
|
|
118
137
|
try {
|
|
119
|
-
|
|
120
|
-
|
|
138
|
+
// Bound each trial so a human takeover can drain a blocked click promptly.
|
|
139
|
+
const timeout = Math.max(1, Math.min(350, deadline - Date.now()));
|
|
140
|
+
if (kind === 'hover') await el.hover({trial:true, timeout});
|
|
141
|
+
else await el.click({trial:true, timeout});
|
|
121
142
|
return;
|
|
122
143
|
} catch (error) {
|
|
123
144
|
if (error.name !== 'TimeoutError') throw error;
|
|
145
|
+
if (!await el.evaluate(node => node.isConnected).catch(() => false)) fail('stale_ref');
|
|
124
146
|
if (op.cancel) fail('operation_cancelled');
|
|
125
|
-
|
|
147
|
+
if (error.message.includes('intercepts pointer events')) obscured = true;
|
|
148
|
+
if (Date.now() >= deadline) fail(obscured ? 'target_obscured' : 'target_not_actionable');
|
|
149
|
+
await delay(40, undefined, {signal:op.controller.signal});
|
|
150
|
+
continue;
|
|
126
151
|
}
|
|
127
152
|
}
|
|
153
|
+
const visible = await el.isVisible();
|
|
154
|
+
if (!visible && await el.evaluate(node => !node.isConnected)) fail('stale_ref');
|
|
128
155
|
if (visible && !pointerAction && await el.isEditable()) return;
|
|
129
156
|
if (Date.now() >= deadline) fail('timeout');
|
|
130
157
|
await delay(40, undefined, {signal:op.controller.signal});
|
|
@@ -198,8 +225,8 @@ export async function perform(service, ws, tab, { documentId, controlGeneration,
|
|
|
198
225
|
}
|
|
199
226
|
if (action.kind === 'spatial') {
|
|
200
227
|
try {
|
|
201
|
-
await service.visual.input(ws,tab,service.actors.getStore(),{...action,documentId,controlGeneration},'agent',
|
|
202
|
-
() => beforeDispatch(service, ws,tab,op,documentId,controlGeneration));
|
|
228
|
+
await agentDispatch(service, tab, () => service.visual.input(ws,tab,service.actors.getStore(),{...action,documentId,controlGeneration},'agent',
|
|
229
|
+
() => beforeDispatch(service, ws,tab,op,documentId,controlGeneration)));
|
|
203
230
|
} catch (error) {
|
|
204
231
|
if (!op.dispatched) fail(error.code || 'visual_action_failed');
|
|
205
232
|
tab.needsSubmissionReview=true;
|
|
@@ -215,7 +242,6 @@ export async function perform(service, ws, tab, { documentId, controlGeneration,
|
|
|
215
242
|
const frameEntry=tab.frameRefs.get(action.ref);
|
|
216
243
|
const el=frameEntry?.handle ?? tab.refs.get(action.ref);
|
|
217
244
|
if (!el) fail('stale_ref');
|
|
218
|
-
await service.checkSemanticTarget(ws,tab,action.ref,frameEntry,el,action.kind==='upload' ? 'click' : action.kind);
|
|
219
245
|
let destination;
|
|
220
246
|
if (action.kind === 'drag') {
|
|
221
247
|
const destinationFrame = tab.frameRefs.get(action.toRef);
|
|
@@ -245,8 +271,10 @@ export async function perform(service, ws, tab, { documentId, controlGeneration,
|
|
|
245
271
|
if (frameEntry) fail('file_origin_mismatch');
|
|
246
272
|
try { ws.uploads.get(ws,tab,action.fileId); } catch(error) { fail(error.code); }
|
|
247
273
|
await waitActionable(service, ws,tab,op,el,'click',documentId,controlGeneration);
|
|
274
|
+
await service.checkSemanticTarget(ws,tab,action.ref,frameEntry,el,'click');
|
|
248
275
|
await chooseGrantedFile(ws,tab,el,action.fileId,
|
|
249
276
|
()=>beforeDispatch(service, ws,tab,op,documentId,controlGeneration),
|
|
277
|
+
work => agentDispatch(service, tab, work),
|
|
250
278
|
()=>{ service.requireControl(ws,controlGeneration); if (op.cancel) fail('operation_cancelled'); });
|
|
251
279
|
} else if (action.kind === 'setChecked') {
|
|
252
280
|
const state = await el.evaluate(readCheckState);
|
|
@@ -258,7 +286,7 @@ export async function perform(service, ws, tab, { documentId, controlGeneration,
|
|
|
258
286
|
await service.checkSemanticTarget(ws,tab,action.ref,frameEntry,el,action.kind);
|
|
259
287
|
if (await el.evaluate(readCheckState) !== action.checked) {
|
|
260
288
|
beforeDispatch(service, ws,tab,op,documentId,controlGeneration);
|
|
261
|
-
await el.click({timeout:5000});
|
|
289
|
+
await agentDispatch(service, tab, () => el.click({timeout:5000}));
|
|
262
290
|
if (await el.evaluate(readCheckState) !== action.checked) fail('state_mismatch');
|
|
263
291
|
}
|
|
264
292
|
}
|
|
@@ -273,7 +301,7 @@ export async function perform(service, ws, tab, { documentId, controlGeneration,
|
|
|
273
301
|
rememberBlock(ws, webOrigin(target), 'navigation', 'document', 'origin_denied');
|
|
274
302
|
fail('origin_denied');
|
|
275
303
|
}
|
|
276
|
-
service.notifyTarget(ws, tab, el, documentId, controlGeneration, origin);
|
|
304
|
+
service.notifyTarget(ws, tab, el, documentId, controlGeneration, origin, action.kind);
|
|
277
305
|
await waitActionable(service, ws, tab, op, el, action.kind, documentId, controlGeneration);
|
|
278
306
|
await service.checkSemanticTarget(ws,tab,action.ref,frameEntry,el,action.kind);
|
|
279
307
|
clickProbe = await armClickProbe(el, 1);
|
|
@@ -296,38 +324,45 @@ export async function perform(service, ws, tab, { documentId, controlGeneration,
|
|
|
296
324
|
interrupt = () => { if (tab.dialog) reject(new ServiceError('operation_cancelled')); };
|
|
297
325
|
op.controller.signal.addEventListener('abort',interrupt,{once:true});
|
|
298
326
|
});
|
|
299
|
-
try { await Promise.race([el.click({timeout:5000,noWaitAfter:!!navigationStart}), suspended]); }
|
|
327
|
+
try { await agentDispatch(service, tab, () => Promise.race([el.click({timeout:5000,noWaitAfter:!!navigationStart}), suspended])); }
|
|
300
328
|
finally { op.controller.signal.removeEventListener('abort',interrupt); }
|
|
301
329
|
if (lease.opening) await lease.opening;
|
|
302
330
|
}
|
|
303
331
|
} 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);
|
|
332
|
+
service.notifyTarget(ws, tab, el, documentId, controlGeneration, origin, action.kind);
|
|
305
333
|
await waitActionable(service, ws, tab, op, el, action.kind, documentId, controlGeneration);
|
|
306
334
|
await service.checkSemanticTarget(ws,tab,action.ref,frameEntry,el,action.kind);
|
|
307
335
|
if (action.kind === 'doubleClick') clickProbe = await armClickProbe(el, 2);
|
|
308
336
|
beforeDispatch(service, ws, tab, op, documentId, controlGeneration);
|
|
309
337
|
if (action.kind === 'doubleClick') {
|
|
310
|
-
await el.dblclick({timeout:5000});
|
|
338
|
+
await agentDispatch(service, tab, () => el.dblclick({timeout:5000}));
|
|
311
339
|
}
|
|
312
|
-
else if (action.kind === 'hover') await el.hover({timeout:5000});
|
|
313
|
-
else if (action.kind === 'press') await el.press(action.key, {timeout:5000});
|
|
340
|
+
else if (action.kind === 'hover') await agentDispatch(service, tab, () => el.hover({timeout:5000}));
|
|
341
|
+
else if (action.kind === 'press') await agentDispatch(service, tab, () => el.press(action.key, {timeout:5000}));
|
|
314
342
|
else if (action.kind === 'scroll') {
|
|
315
343
|
await el.scrollIntoViewIfNeeded({timeout:5000});
|
|
316
|
-
await tab.page.mouse.wheel(action.deltaX ?? 0, action.deltaY);
|
|
317
|
-
} else await el.dragTo(destination, {timeout:5000});
|
|
344
|
+
await agentDispatch(service, tab, () => tab.page.mouse.wheel(action.deltaX ?? 0, action.deltaY));
|
|
345
|
+
} else await agentDispatch(service, tab, () => el.dragTo(destination, {timeout:5000}));
|
|
318
346
|
} else {
|
|
319
|
-
service.notifyTarget(ws, tab, el, documentId, controlGeneration, origin);
|
|
347
|
+
service.notifyTarget(ws, tab, el, documentId, controlGeneration, origin, action.kind);
|
|
320
348
|
await waitActionable(service, ws, tab, op, el, action.kind, documentId, controlGeneration);
|
|
321
349
|
await service.checkSemanticTarget(ws,tab,action.ref,frameEntry,el,action.kind);
|
|
322
350
|
beforeDispatch(service, ws, tab, op, documentId, controlGeneration);
|
|
323
|
-
if (action.kind === 'select') await el.selectOption({ value }, {timeout:5000});
|
|
351
|
+
if (action.kind === 'select') await agentDispatch(service, tab, () => el.selectOption({ value }, {timeout:5000}));
|
|
324
352
|
else {
|
|
325
|
-
await el.fill(value, {timeout:5000});
|
|
353
|
+
await agentDispatch(service, tab, () => el.fill(value, {timeout:5000}));
|
|
326
354
|
receipt.fillOutcome = await fillOutcome(el, value, action.kind === 'fillCredential');
|
|
327
355
|
}
|
|
328
356
|
}
|
|
329
357
|
} catch (error) {
|
|
330
|
-
if (!op.dispatched)
|
|
358
|
+
if (!op.dispatched) {
|
|
359
|
+
if (error.code === 'target_obscured' && tab.documentId === documentId && ws.generation === controlGeneration) {
|
|
360
|
+
const obstruction = await el.evaluate(inspectObstruction).catch(() => null);
|
|
361
|
+
if (obstruction) tab.actionObstruction = {operationId:receipt.operationId, documentId, controlGeneration,
|
|
362
|
+
origin, obstruction:{...obstruction,inputGuard:ws.inputGuardMode || 'unavailable'}};
|
|
363
|
+
}
|
|
364
|
+
throw error;
|
|
365
|
+
}
|
|
331
366
|
if (clickProbe && !tab.dialog && await consumeClickProbe(el, clickProbe, action.kind === 'doubleClick' ? 2 : 1)) {
|
|
332
367
|
receipt.completedSteps++;
|
|
333
368
|
op.dispatched = false;
|
|
@@ -344,6 +379,7 @@ export async function perform(service, ws, tab, { documentId, controlGeneration,
|
|
|
344
379
|
return;
|
|
345
380
|
}
|
|
346
381
|
receipt.completedSteps++;
|
|
382
|
+
service.invalidateObservation?.(tab);
|
|
347
383
|
receipt.phase = 'verifying';
|
|
348
384
|
op.dispatched = false;
|
|
349
385
|
service.store.save(ws.owner, ws.id, op.digest, receipt);
|