@seekskyworld/open-browser 0.0.0-stage → 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/CONTRIBUTING.md +15 -0
- package/Docs/Agent/346/265/217/350/247/210/345/231/250/346/200/273/344/275/223/346/236/266/346/236/204.md +58 -0
- package/Docs/THIRD-PARTY-NOTICES.md +12 -0
- package/Docs/open-browser-api.d.ts +291 -0
- package/Docs/open-browser/344/273/273/345/212/241/350/257/204/346/265/213/346/214/207/345/215/227.md +59 -0
- package/Docs/open-browser/351/232/220/347/247/201/344/270/216/345/274/200/346/272/220/345/256/241/350/256/241.md +37 -0
- package/Docs//346/216/247/345/210/266/345/217/260/345/210/206/347/273/204/344/270/216/346/216/245/347/256/241/346/226/271/346/241/210.md +31 -0
- 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 +84 -0
- package/LICENSE +200 -0
- package/README.md +159 -2
- package/README.zh-CN.md +166 -0
- package/SECURITY.md +9 -0
- package/access-registry.mjs +156 -0
- package/action-execution.mjs +385 -0
- package/activity-notifier.mjs +34 -0
- package/api-contract.mjs +134 -0
- package/browser-extension/icons/open-browser-128.png +0 -0
- package/browser-extension/icons/open-browser-16.png +0 -0
- package/browser-extension/icons/open-browser-32.png +0 -0
- package/browser-extension/icons/open-browser-48.png +0 -0
- package/browser-extension/icons/open-browser-wordmark.png +0 -0
- package/browser-extension/manifest.json +35 -0
- package/browser-extension/newtab.css +26 -0
- package/browser-extension/newtab.html +19 -0
- package/browser-extension/newtab.js +174 -0
- package/browser-extension/phase-labels.js +9 -0
- package/browser-extension/popup.css +19 -0
- package/browser-extension/popup.html +56 -0
- package/browser-extension/popup.js +405 -0
- package/browser-extension/tab-action.js +138 -0
- package/browser-extension/worker.js +281 -0
- package/browser-extension/workspace-title.js +15 -0
- package/build-profile.mjs +23 -0
- package/capability-matrix.mjs +21 -0
- package/chromium-host.mjs +209 -0
- package/chromium-shell.mjs +179 -0
- package/cli.mjs +141 -0
- package/contract-validation.mjs +27 -0
- package/control.mjs +107 -0
- package/desktop/Info.plist +13 -0
- package/desktop/Launcher.m +117 -0
- package/desktop/OBControlBar.h +7 -0
- package/desktop/OBControlBar.m +217 -0
- package/desktop/OBPageView.h +6 -0
- package/desktop/OBPageView.m +348 -0
- package/desktop/WorkspacePanel.h +16 -0
- package/desktop/WorkspacePanel.m +916 -0
- package/desktop/archive-release.py +129 -0
- package/desktop/brand-keychain.py +111 -0
- package/desktop/brand-locales.py +93 -0
- package/desktop/brand-macos-icons.py +24 -0
- package/desktop/brand-windows-icons.mjs +48 -0
- package/desktop/build-macos.mjs +112 -0
- package/desktop/build-managed-input.mjs +37 -0
- package/desktop/build-portable.mjs +95 -0
- package/desktop/build-profile.mjs +6 -0
- package/desktop/build.mjs +13 -0
- package/desktop/create-shortcut.ps1 +9 -0
- package/desktop/generate-icons.py +39 -0
- package/desktop/icons/open-browser.icns +0 -0
- package/desktop/icons/open-browser.ico +0 -0
- package/desktop/install-menu-entry.mjs +24 -0
- package/desktop/macos-entitlements.plist +12 -0
- package/desktop/notarize-macos.mjs +145 -0
- package/desktop/package-assets.mjs +34 -0
- package/desktop/package-macos.mjs +54 -0
- package/desktop/patches/chromium-macos-keychain-service.patch +18 -0
- package/desktop/patches/chromium-managed-input.patch +144 -0
- package/desktop/portable-archive.py +22 -0
- package/desktop/sign.mjs +77 -0
- package/desktop/smoke-portable.mjs +65 -0
- package/desktop/start-profile.mjs +5 -0
- package/desktop/start.mjs +34 -0
- package/desktop/verify-macos-release.mjs +61 -0
- package/desktop/verify-upgrade.mjs +74 -0
- package/desktop/verify-version.mjs +12 -0
- package/desktop-page.mjs +211 -0
- package/diagnostics.mjs +37 -0
- package/downloads.mjs +110 -0
- package/engine-service.mjs +1158 -0
- package/hosted/README.md +74 -0
- package/hosted/cli.mjs +17 -0
- package/hosted/directory.mjs +261 -0
- package/hosted/init.mjs +37 -0
- package/hosted/server.mjs +129 -0
- package/managed-input.mjs +138 -0
- package/managed-popup.mjs +54 -0
- package/mcp-http.mjs +84 -0
- package/mcp-server.mjs +41 -0
- package/mcp.mjs +5 -0
- package/network-policy.mjs +107 -0
- package/output-store.mjs +96 -0
- package/package.json +77 -4
- package/page-activity.mjs +188 -0
- package/page-dialogs.mjs +53 -0
- package/page-observation.mjs +318 -0
- package/paths.mjs +22 -0
- package/privacy-config.mjs +95 -0
- package/receipt-store.mjs +198 -0
- package/runtime.mjs +53 -0
- package/scheduler.mjs +70 -0
- package/sdk.mjs +193 -0
- package/service.mjs +290 -0
- package/site-workflow.mjs +115 -0
- package/skill-links.mjs +90 -0
- package/skills/open-browser/SKILL.macos.md +112 -0
- package/skills/open-browser/SKILL.md +107 -0
- package/skills/open-browser/SKILL.windows.md +112 -0
- package/skills/open-browser/scripts/bootstrap.mjs +213 -0
- package/skills/open-browser/scripts/open-browser +21 -0
- package/skills/open-browser/scripts/open-browser.cmd +9 -0
- package/skills/open-browser/workflows/login-export.json +10 -0
- package/skills/open-browser/workflows/upload-verify.json +8 -0
- package/studio/demo-site.mjs +111 -0
- package/studio/demo.css +1 -0
- package/studio/index.html +66 -0
- package/studio/index.mjs +57 -0
- package/studio/native-demo.mjs +124 -0
- package/studio/studio.css +119 -0
- package/studio/studio.js +438 -0
- package/tab-adoption.mjs +77 -0
- package/uploads.mjs +63 -0
- package/visual-page.mjs +306 -0
- package/workspace-lifecycle.mjs +238 -0
- package/workspace-state.mjs +107 -0
package/api-contract.mjs
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { desktopCapabilities, readCapabilities } from './capability-matrix.mjs';
|
|
2
|
+
|
|
3
|
+
const id = { type: 'string', minLength: 1 };
|
|
4
|
+
function object(properties, required = Object.keys(properties)) {
|
|
5
|
+
return { type: 'object', properties, required, additionalProperties: false };
|
|
6
|
+
}
|
|
7
|
+
const workspace = { workspaceId: id };
|
|
8
|
+
const page = { ...workspace, pageId: id };
|
|
9
|
+
const operation = { ...workspace, operationId: id };
|
|
10
|
+
const point={x:{type:'number'},y:{type:'number'}};
|
|
11
|
+
const region=object({...point,width:{type:'integer',minimum:1},height:{type:'integer',minimum:1}});
|
|
12
|
+
const spatialAction={oneOf:[
|
|
13
|
+
object({type:{enum:['click','hover','tap']},...point}),
|
|
14
|
+
object({type:{const:'drag'},...point,toX:{type:'number'},toY:{type:'number'}}),
|
|
15
|
+
object({type:{const:'scroll'},...point,deltaX:{type:'number'},deltaY:{type:'number'}}),
|
|
16
|
+
object({type:{const:'key'},...point,keys:{type:'array',minItems:1,maxItems:3,items:id}}),
|
|
17
|
+
object({type:{const:'text'},...point,text:{type:'string',minLength:1,maxLength:2048}}),
|
|
18
|
+
]};
|
|
19
|
+
const action = {
|
|
20
|
+
oneOf: [
|
|
21
|
+
object({kind:{const:'upload'},fileId:id,ref:id}),
|
|
22
|
+
object({kind:{const:'spatial'},frameId:id,action:spatialAction}),
|
|
23
|
+
object({ kind: { const: 'wait' }, text: id, timeoutMs:{type:'integer',minimum:1,maximum:10000} }, ['kind','text']),
|
|
24
|
+
object({kind:{const:'wait'},url:{type:'string',format:'uri'},timeoutMs:{type:'integer',minimum:1,maximum:10000}},['kind','url']),
|
|
25
|
+
object({kind:{const:'wait'},absent:object({role:id,name:id}),timeoutMs:{type:'integer',minimum:1,maximum:10000}},['kind','absent']),
|
|
26
|
+
object({kind:{const:'wait'},navigation:{const:'commit'},timeoutMs:{type:'integer',minimum:1,maximum:10000}},['kind','navigation']),
|
|
27
|
+
object({kind:{const:'wait'},element:object({role:id,name:id,checked:{enum:[true,false,'mixed']},pressed:{enum:[true,false,'mixed']},expanded:{type:'boolean'},selected:{type:'boolean'}},['role','name']),timeoutMs:{type:'integer',minimum:1,maximum:10000}},['kind','element']),
|
|
28
|
+
object({kind:{const:'setChecked'},ref:id,checked:{type:'boolean'}}),
|
|
29
|
+
object({ kind: { const: 'select' }, ref:id, value:{type:'string'} }),
|
|
30
|
+
object({ kind: { const: 'click' }, ref: id }),
|
|
31
|
+
object({ kind: { const: 'doubleClick' }, ref: id }),
|
|
32
|
+
object({ kind: { const: 'hover' }, ref: id }),
|
|
33
|
+
object({ kind: { const: 'press' }, ref: id, key: id }),
|
|
34
|
+
object({ kind: { const: 'scroll' }, ref: id, deltaX:{type:'number'}, deltaY:{type:'number'} }, ['kind','ref','deltaY']),
|
|
35
|
+
object({ kind: { const: 'drag' }, ref: id, toRef: id }),
|
|
36
|
+
object({ kind: { const: 'fill' }, ref: id, value: { type: 'string' } }),
|
|
37
|
+
object({ kind: { const: 'fillCredential' }, ref: id, credentialRef: id }),
|
|
38
|
+
],
|
|
39
|
+
};
|
|
40
|
+
const history = {...workspace, after:{type:'integer',minimum:0},limit:{type:'integer',minimum:1,maximum:100}};
|
|
41
|
+
const semanticTarget=object({role:id,name:id,within:object({role:id,name:id})},['role','name']);
|
|
42
|
+
const expectedState=object({checked:{enum:[true,false,'mixed']},pressed:{enum:[true,false,'mixed']},
|
|
43
|
+
expanded:{type:'boolean'},selected:{type:'boolean'}},[]);
|
|
44
|
+
const workflowStep={oneOf:[
|
|
45
|
+
object({kind:{const:'click'},target:semanticTarget}),
|
|
46
|
+
object({kind:{enum:['upload','fillCredential']},target:semanticTarget,binding:{type:'string',maxLength:80,pattern:'^[a-zA-Z][a-zA-Z0-9_-]*$'}}),
|
|
47
|
+
object({kind:{const:'expect'},target:semanticTarget,state:expectedState,
|
|
48
|
+
timeoutMs:{type:'integer',minimum:1,maximum:10000}},['kind','target']),
|
|
49
|
+
]};
|
|
50
|
+
const definitions = {
|
|
51
|
+
runWorkflow:['Run a local origin-bound semantic workflow and poll its operation receipt. Bind only granted file IDs or credential references. The optional timeout is a wall-clock budget shared by queueing and execution.',{
|
|
52
|
+
...page,operationId:id,documentId:id,controlGeneration:id,
|
|
53
|
+
timeoutMs:{type:'integer',minimum:1,maximum:60000},
|
|
54
|
+
workflow:object({version:{const:1},origin:{type:'string',format:'uri'},steps:{type:'array',minItems:1,maxItems:32,items:workflowStep}}),
|
|
55
|
+
bindings:{type:'object',maxProperties:32,additionalProperties:{type:'string',minLength:1,maxLength:160}},
|
|
56
|
+
},['workspaceId','pageId','documentId','controlGeneration','operationId','workflow']],
|
|
57
|
+
|
|
58
|
+
capabilities: ['Discover service version, enabled inputs, limits and privacy mode before using optional features.',{}],
|
|
59
|
+
captureVisual: ['Capture approved masked viewport pixels. Coordinates use viewport CSS pixels.',{...page,region,ref:id},Object.keys(page)],
|
|
60
|
+
listWorkspaces: ['List the workspaces available to this agent.', {}],
|
|
61
|
+
createWorkspace: ['Create a browser workspace. Every task must provide a clear non-empty name. Each subagent should pass its own display name in agentName.', {
|
|
62
|
+
profileId:{type:'string',pattern:'^[a-z0-9][a-z0-9_-]{0,47}$'},
|
|
63
|
+
name: { type: 'string', minLength: 1, maxLength: 120 },
|
|
64
|
+
agentName: { type: 'string', maxLength: 80 },
|
|
65
|
+
resourceOrigins: { type: 'array',maxItems:32,items:{type:'string',format:'uri'} },
|
|
66
|
+
allowedOrigins: { type: 'array', maxItems: 32, items: { type: 'string', format: 'uri' } },
|
|
67
|
+
}, ['name']],
|
|
68
|
+
open: ['Create a named workspace for one explicit URL and open its first page in one call.', {
|
|
69
|
+
profileId:{type:'string',pattern:'^[a-z0-9][a-z0-9_-]{0,47}$'},
|
|
70
|
+
name: { type: 'string', minLength: 1, maxLength: 120 },
|
|
71
|
+
agentName: { type: 'string', maxLength: 80 },
|
|
72
|
+
url: { type: 'string', format: 'uri' },
|
|
73
|
+
resourceOrigins: { type: 'array',maxItems:32,items:{type:'string',format:'uri'} },
|
|
74
|
+
allowedOrigins: { type: 'array', maxItems:32, items:{type:'string',format:'uri'} },
|
|
75
|
+
}, ['url','name']],
|
|
76
|
+
grantOrigin: ['Grant one origin already recorded as blocked for this workspace. Use only after checking blockedOrigins and obtaining workspace control.', {
|
|
77
|
+
...workspace, controlGeneration: id, origin: { type:'string', format:'uri' },
|
|
78
|
+
scope: { enum:['navigation','resource'], type:'string' },
|
|
79
|
+
}, ['workspaceId','controlGeneration','origin','scope']],
|
|
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']],
|
|
85
|
+
openPage: ['Open a page in the workspace.', { ...workspace, url: { type: 'string', format: 'uri' } }],
|
|
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.', {
|
|
87
|
+
...page, includeFrames:{type:'boolean'}, frameControls:{type:'boolean'},
|
|
88
|
+
locator:object({role:id,name:id,within:object({role:id,name:id})},['role','name']),
|
|
89
|
+
cursor:id, limit:{type:'integer',minimum:1,maximum:180}, name:id, region,
|
|
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']],
|
|
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.', {
|
|
100
|
+
...page, operationId: id, documentId: id, controlGeneration: id,
|
|
101
|
+
timeoutMs:{type:'integer',minimum:1,maximum:60000},
|
|
102
|
+
observeAfter:{enum:['full','delta']},
|
|
103
|
+
actions: { type: 'array', minItems: 1, maxItems:32, items: action },
|
|
104
|
+
}, ['workspaceId','pageId','operationId','documentId','controlGeneration','actions']],
|
|
105
|
+
respondDialog:['Respond once to a pending JavaScript dialog in the controlled page.',{...page,dialogId:id,controlGeneration:id,accept:{type:'boolean'},text:{type:'string',maxLength:2048}},[...Object.keys(page),'dialogId','controlGeneration','accept']],
|
|
106
|
+
listUploads:['List live desktop file grants for this workspace.',workspace],
|
|
107
|
+
listDownloads:['List downloads for this workspace and their current state.',workspace],
|
|
108
|
+
listOutputs:['List locally delivered output manifests for this workspace.',workspace],
|
|
109
|
+
readOutput:['Read one locally delivered output in bounded base64 chunks. Use nextOffset to continue.',{...workspace,outputId:id,partName:{type:'string',maxLength:180},offset:{type:'integer',minimum:0},limit:{type:'integer',minimum:1,maximum:65536}},['workspaceId','outputId']],
|
|
110
|
+
cancelDownload:['Cancel a download belonging to this workspace.',{...workspace,downloadId:id}],
|
|
111
|
+
eventCursor:['Get the current workspace event cursor before triggering an action.',workspace],
|
|
112
|
+
waitForEvent:['Wait for a matching page event. Reuse the same cursor to read it after reconnecting.',
|
|
113
|
+
{...page,kind:{enum:['dialog','download','popup']},after:{type:'integer',minimum:0},operationId:id,
|
|
114
|
+
timeoutMs:{type:'integer',minimum:1,maximum:10000}},[...Object.keys(page),'kind','after']],
|
|
115
|
+
listEvents:['Poll redacted changes since a sequence number.',history,['workspaceId']],
|
|
116
|
+
getRecoverySummary:['Read task recovery steps, delivered objects and page availability. Observe or verify before resuming.',{...history,objectsAfter:{type:'integer',minimum:0}},['workspaceId']],
|
|
117
|
+
listOperations:['Read redacted receipt history.',history,['workspaceId']],
|
|
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']],
|
|
119
|
+
diagnoseOperation: ['Preview a redacted diagnostic with the next safe action. Use it after a timeout, disconnect or outcome_unknown.', operation],
|
|
120
|
+
getOperation: ['Read an operation receipt, including its completed step count.', operation],
|
|
121
|
+
cancelOperation: ['Cancel the remaining steps of an operation.', operation],
|
|
122
|
+
handOff: ['Hand control of the workspace to its user.', workspace],
|
|
123
|
+
closeWorkspace: ['Close the workspace and its managed pages.', workspace],
|
|
124
|
+
};
|
|
125
|
+
export const tools = Object.freeze(Object.entries(definitions).map(([name, [description, fields, required]]) =>
|
|
126
|
+
({ name, description, inputSchema:object(fields, required) })));
|
|
127
|
+
export const agentMethods = Object.freeze(tools.map(tool => tool.name));
|
|
128
|
+
export const capabilityProfiles = Object.freeze({
|
|
129
|
+
agent: agentMethods,
|
|
130
|
+
read: readCapabilities,
|
|
131
|
+
desktop: desktopCapabilities,
|
|
132
|
+
});
|
|
133
|
+
export const limits = Object.freeze({requestBytes:256*1024, responseBytes:8*1024*1024, clientTimeoutMs:60000, runTimeoutMs:60000,
|
|
134
|
+
actionsPerOperation:32, waitMs:10000, observationControls:180, uploadFileBytes:8*1024*1024, visualPngBytes:3*1024*1024});
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"manifest_version": 3,
|
|
3
|
+
"name": "open-browser",
|
|
4
|
+
"version": "0.2.0",
|
|
5
|
+
"description": "管理本机 Agent 工作区与 Chromium 标签组",
|
|
6
|
+
"key": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAhZVSXIA/vfzO0jj4ebn25I3lbL//y8FbZUeQ8Q9shwfMWTbl3bsjcHzIITSGg5+NqVTAEB1AgjFZDi/Idoj+tgsvwQxXbMBzgdZA1tQMASXcbFRdVNTxWbRBSd4JXtsFfD7H6QeBwXuIHNqUeyQYD0sYn8Ot0c4KJCzsYshYPLU56+Lzdoy+7l6ydmmw31T4tpanZHJvUgyzATOjEekFJii+9IEI/G4BUGQhKdPqR/MBYiqzxgPB5WIr3w25z6bH5KC6wnUxblLQM0RAHa4hot38NOFul5JCW6BOLHEes7Pz3DOUpWFP+DFSkY42r0dt1Kh/5CFKr6ED3agcc+tB1wIDAQAB",
|
|
7
|
+
"permissions": [
|
|
8
|
+
"debugger",
|
|
9
|
+
"tabGroups",
|
|
10
|
+
"storage",
|
|
11
|
+
"contextMenus"
|
|
12
|
+
],
|
|
13
|
+
"background": {
|
|
14
|
+
"service_worker": "worker.js"
|
|
15
|
+
},
|
|
16
|
+
"action": {
|
|
17
|
+
"default_title": "open-browser 工作区",
|
|
18
|
+
"default_popup": "popup.html",
|
|
19
|
+
"default_icon": {
|
|
20
|
+
"16": "icons/open-browser-16.png",
|
|
21
|
+
"32": "icons/open-browser-32.png",
|
|
22
|
+
"48": "icons/open-browser-48.png",
|
|
23
|
+
"128": "icons/open-browser-128.png"
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"content_security_policy": {
|
|
27
|
+
"extension_pages": "script-src 'self'; object-src 'none'; connect-src 'none'; frame-ancestors 'none'; base-uri 'none'"
|
|
28
|
+
},
|
|
29
|
+
"icons": {
|
|
30
|
+
"16": "icons/open-browser-16.png",
|
|
31
|
+
"32": "icons/open-browser-32.png",
|
|
32
|
+
"48": "icons/open-browser-48.png",
|
|
33
|
+
"128": "icons/open-browser-128.png"
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
:root { color-scheme: light dark; font: 14px/1.5 system-ui, sans-serif; }
|
|
2
|
+
* { box-sizing: border-box; }
|
|
3
|
+
body { margin: 0; min-width: 620px; background: Canvas; color: CanvasText; }
|
|
4
|
+
header { height: 58px; display: flex; align-items: center; justify-content: space-between; padding: 0 34px; border-bottom: 1px solid color-mix(in srgb, CanvasText 14%, transparent); }
|
|
5
|
+
.brand { display: flex; align-items: center; gap: 10px; font-size: 17px; letter-spacing: -.2px; } .brand img { border-radius: 7px; }
|
|
6
|
+
#status { color: color-mix(in srgb, CanvasText 62%, Canvas); font-size: 12px; }
|
|
7
|
+
main { width: min(980px, calc(100% - 68px)); margin: 42px auto 72px; }
|
|
8
|
+
.hero, .section-title { display: flex; align-items: center; justify-content: space-between; gap: 20px; } h1 { margin: 0; font-size: 28px; letter-spacing: -.8px; } h2 { margin: 0; font-size: 16px; } p { margin: 6px 0 0; color: color-mix(in srgb, CanvasText 66%, Canvas); }
|
|
9
|
+
section { margin-top: 34px; } .section-title { margin-bottom: 12px; }
|
|
10
|
+
.how-to { padding: 18px; border: 1px solid color-mix(in srgb, CanvasText 14%, transparent); border-radius: 10px; background: color-mix(in srgb, CanvasText 3%, Canvas); }
|
|
11
|
+
.how-to p { margin-top: 0; }
|
|
12
|
+
#agent-prompt { width: 100%; min-height: 84px; margin-top: 12px; padding: 11px 12px; resize: vertical; border: 1px solid color-mix(in srgb, CanvasText 18%, transparent); border-radius: 8px; background: Canvas; color: CanvasText; font: 12px/1.6 ui-monospace, SFMono-Regular, Menlo, monospace; }
|
|
13
|
+
.workspace-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; }
|
|
14
|
+
.card { padding: 16px; border: 1px solid color-mix(in srgb, CanvasText 16%, transparent); border-radius: 10px; background: color-mix(in srgb, CanvasText 4%, Canvas); }
|
|
15
|
+
.card strong { display: block; font-size: 14px; } .detail, .agent-name { display: block; margin-top: 5px; color: color-mix(in srgb, CanvasText 62%, Canvas); font-size: 12px; } .name-hint { display: block; margin-top: 8px; color: #a05b00; font-size: 12px; font-weight: 600; } .card .state { margin-top: 14px; color: #28734c; font-weight: 600; }
|
|
16
|
+
.history-list { display: grid; gap: 2px; border-top: 1px solid color-mix(in srgb, CanvasText 12%, transparent); }
|
|
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
|
+
.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%; }
|
|
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; }
|
|
26
|
+
@media (max-width: 700px) { body { min-width: 0; } header { padding: 0 20px; } main { width: calc(100% - 40px); margin-top: 28px; } }
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<meta charset="utf-8">
|
|
3
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
4
|
+
<title>open-browser 控制台</title>
|
|
5
|
+
<link rel="icon" type="image/png" href="icons/open-browser-32.png">
|
|
6
|
+
<link rel="stylesheet" href="newtab.css">
|
|
7
|
+
<script defer src="phase-labels.js"></script>
|
|
8
|
+
<script defer src="workspace-title.js"></script>
|
|
9
|
+
<script defer src="newtab.js"></script>
|
|
10
|
+
<body>
|
|
11
|
+
<header><div class="brand"><img src="icons/open-browser-48.png" width="28" height="28" alt=""><strong>open-browser</strong></div><span id="status">正在连接…</span></header>
|
|
12
|
+
<main>
|
|
13
|
+
<section class="hero"><div><h1>Agent 控制台</h1><p>查看 Agent 当前任务和运行记录。</p></div><button id="refresh" class="quiet" type="button">刷新</button></section>
|
|
14
|
+
<section class="how-to"><div class="section-title"><h2>Agent 如何使用</h2><button id="copy-prompt" class="quiet" type="button">复制提示词</button></div><p>把下面的提示词交给 Agent,它会按 open-browser 的安全流程操作浏览器。</p><textarea id="agent-prompt" readonly spellcheck="false">请使用 open-browser Skill 控制浏览器。先调用 listWorkspaces,继续已有工作区。创建新任务时必须填写清晰的 name 任务名称和 agentName Agent 名称,再用 open 打开明确网址,按 observe → act → getOperation → observe 核对结果,完成后调用 finishWorkspace。遇到接管、stale_ref、outcome_unknown 或 host_unavailable 时,按返回的 nextAction 处理,不要重复提交。</textarea></section>
|
|
15
|
+
<section><div class="section-title"><h2>正在运行的 Agent</h2><span id="workspace-count"></span></div><div id="workspaces" class="workspace-grid"></div><p id="empty" class="empty">当前没有正在运行的 Agent。</p></section>
|
|
16
|
+
<section><div class="section-title"><h2>运行历史</h2><span id="history-count"></span></div><div id="history" class="history-list"></div><p id="history-empty" class="empty">暂无运行历史。</p></section>
|
|
17
|
+
<p id="notice" role="status" hidden></p>
|
|
18
|
+
</main>
|
|
19
|
+
</body>
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const el = id => document.getElementById(id);
|
|
4
|
+
const phases = globalThis.openBrowserPhaseLabels;
|
|
5
|
+
const modes = globalThis.openBrowserModeLabels;
|
|
6
|
+
|
|
7
|
+
async function call(method, params = {}) {
|
|
8
|
+
const reply = await chrome.runtime.sendMessage({ method, params });
|
|
9
|
+
if (!reply || reply.error) throw new Error(reply?.error || 'host_unavailable');
|
|
10
|
+
return reply.result;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function notify(message) {
|
|
14
|
+
el('notice').textContent = message;
|
|
15
|
+
el('notice').hidden = !message;
|
|
16
|
+
el('notice').classList.toggle('error', Boolean(message));
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function friendlyError(error) {
|
|
20
|
+
const code = error?.message || '';
|
|
21
|
+
if (code === 'host_unavailable' || code === 'host_timeout') return code === 'host_timeout'
|
|
22
|
+
? 'open-browser 已收到请求,但服务响应超时,请检查应用后重试。'
|
|
23
|
+
: 'open-browser 服务未连接,请先启动应用后点击刷新。';
|
|
24
|
+
if (code === 'extension_worker_timeout') return 'open-browser 扩展响应超时,请重新加载扩展或重启应用。';
|
|
25
|
+
if (code === 'extension_unavailable') return 'open-browser 工作区扩展未运行,请重新启动应用。';
|
|
26
|
+
return code || '暂时无法读取 Agent 状态,请点击刷新重试。';
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function stateLabel(workspace) {
|
|
30
|
+
if (workspace.activity?.needsHumanVerification) return '需要人工验证';
|
|
31
|
+
if (workspace.activity?.needsCredential) return '等待凭据';
|
|
32
|
+
return modes[workspace.mode] || phases[workspace.activity?.current?.phase] || phases[workspace.activity?.phase] || '待命';
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const formatWorkspaceTitle = globalThis.openBrowserWorkspaceTitle;
|
|
36
|
+
const needsTaskName = globalThis.openBrowserWorkspaceNeedsName;
|
|
37
|
+
|
|
38
|
+
function line(text, className = '') {
|
|
39
|
+
const node = document.createElement('span');
|
|
40
|
+
node.textContent = text;
|
|
41
|
+
if (className) node.className = className;
|
|
42
|
+
return node;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function eventLabel(event) {
|
|
46
|
+
const state = event.state || 'unknown';
|
|
47
|
+
const steps = Number.isInteger(event.completedSteps) ? ` · ${event.completedSteps} 步` : '';
|
|
48
|
+
const operation = event.operationId ? ` · ${event.operationId.slice(0, 8)}` : '';
|
|
49
|
+
return `${event.kind || '事件'} · ${phases[state] || state}${steps}${operation}`;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
async function showEvents(workspaceId, host) {
|
|
53
|
+
const timeline = host.querySelector('.timeline');
|
|
54
|
+
if (!timeline) return;
|
|
55
|
+
if (!timeline.hidden) {
|
|
56
|
+
timeline.hidden = true;
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
timeline.hidden = false;
|
|
60
|
+
timeline.replaceChildren(line('正在读取记录…', 'detail'));
|
|
61
|
+
try {
|
|
62
|
+
const result = await call('listEvents', { workspaceId, after: 0, limit: 24 });
|
|
63
|
+
const events = result?.events || [];
|
|
64
|
+
timeline.replaceChildren(...(events.length
|
|
65
|
+
? events.map(event => line(eventLabel(event), 'timeline-row'))
|
|
66
|
+
: [line('暂无可显示的脱敏事件。', 'detail')]));
|
|
67
|
+
} catch (error) {
|
|
68
|
+
timeline.replaceChildren(line(friendlyError(error), 'detail'));
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function recordButton(workspaceId, host) {
|
|
73
|
+
const button = document.createElement('button');
|
|
74
|
+
button.type = 'button';
|
|
75
|
+
button.className = 'quiet record-button';
|
|
76
|
+
button.textContent = '查看记录';
|
|
77
|
+
button.onclick = () => void showEvents(workspaceId, host);
|
|
78
|
+
return button;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function renderWorkspaces(items) {
|
|
82
|
+
el('workspace-count').textContent = items.length ? `${items.length} 个` : '';
|
|
83
|
+
el('empty').hidden = items.length > 0;
|
|
84
|
+
el('workspaces').replaceChildren(...items.map(workspace => {
|
|
85
|
+
const card = document.createElement('article');
|
|
86
|
+
card.className = 'card live-card';
|
|
87
|
+
const title = document.createElement('strong');
|
|
88
|
+
title.textContent = formatWorkspaceTitle(workspace);
|
|
89
|
+
const status = line(stateLabel(workspace), 'state');
|
|
90
|
+
const current = workspace.activity?.current;
|
|
91
|
+
const detail = line(current
|
|
92
|
+
? `${current.kind || '操作'} · ${current.completedSteps || 0}/${current.totalSteps || 0} 步`
|
|
93
|
+
: `${workspace.pages?.length || 0} 个页面 · 暂无正在执行的操作`, 'detail');
|
|
94
|
+
const agent = line(workspace.agentName || 'Agent', 'agent-name');
|
|
95
|
+
card.append(title, agent, status, detail);
|
|
96
|
+
if (needsTaskName(workspace)) card.append(line('请为此任务命名', 'name-hint'));
|
|
97
|
+
const timeline = document.createElement('div');
|
|
98
|
+
timeline.className = 'timeline';
|
|
99
|
+
timeline.hidden = true;
|
|
100
|
+
card.append(recordButton(workspace.workspaceId, card), timeline);
|
|
101
|
+
return card;
|
|
102
|
+
}));
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function operationLabel(operation) {
|
|
106
|
+
if (!operation) return '暂无操作记录';
|
|
107
|
+
const phase = operation.phase || operation.state;
|
|
108
|
+
const progress = operation.totalSteps ? `${operation.completedSteps || 0}/${operation.totalSteps} 步` : `${operation.completedSteps || 0} 步`;
|
|
109
|
+
return `${operation.kind || '操作'} · ${phases[phase] || phase} · ${progress}`;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function formatTime(value) {
|
|
113
|
+
if (!Number.isFinite(value) || value <= 0) return '';
|
|
114
|
+
return new Intl.DateTimeFormat('zh-CN', { month: 'numeric', day: 'numeric', hour: '2-digit', minute: '2-digit' }).format(value);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function renderHistory(items) {
|
|
118
|
+
el('history-count').textContent = items.length ? `${items.length} 条` : '';
|
|
119
|
+
el('history-empty').hidden = items.length > 0;
|
|
120
|
+
el('history').replaceChildren(...items.map(item => {
|
|
121
|
+
const row = document.createElement('article');
|
|
122
|
+
row.className = 'history-row';
|
|
123
|
+
const main = document.createElement('div');
|
|
124
|
+
main.append(line(formatWorkspaceTitle(item), 'history-title'), line(operationLabel(item.recentOperation), 'detail'));
|
|
125
|
+
if (needsTaskName(item)) main.append(line('请为此任务命名', 'name-hint'));
|
|
126
|
+
const meta = document.createElement('div');
|
|
127
|
+
meta.className = 'history-meta';
|
|
128
|
+
meta.append(line(phases[item.state] || item.state || '已完成', `history-state ${item.state || ''}`));
|
|
129
|
+
const time = formatTime(item.updatedAt || item.createdAt);
|
|
130
|
+
if (time) meta.append(line(time, 'detail'));
|
|
131
|
+
const timeline = document.createElement('div');
|
|
132
|
+
timeline.className = 'timeline';
|
|
133
|
+
timeline.hidden = true;
|
|
134
|
+
const actions = document.createElement('div');
|
|
135
|
+
actions.className = 'history-actions';
|
|
136
|
+
actions.append(recordButton(item.workspaceId, row));
|
|
137
|
+
row.append(main, meta, actions, timeline);
|
|
138
|
+
return row;
|
|
139
|
+
}));
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
async function refresh() {
|
|
143
|
+
try {
|
|
144
|
+
const [workspaces, history] = await Promise.all([
|
|
145
|
+
call('listWorkspaces'),
|
|
146
|
+
call('listAgentHistory', { limit: 24 }),
|
|
147
|
+
]);
|
|
148
|
+
renderWorkspaces(workspaces);
|
|
149
|
+
renderHistory(history);
|
|
150
|
+
el('status').textContent = '本机服务已连接';
|
|
151
|
+
notify('');
|
|
152
|
+
} catch (error) {
|
|
153
|
+
el('status').textContent = '服务未连接';
|
|
154
|
+
notify(friendlyError(error));
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
el('refresh').onclick = () => void refresh();
|
|
159
|
+
el('copy-prompt').onclick = async () => {
|
|
160
|
+
const prompt = el('agent-prompt').value;
|
|
161
|
+
try {
|
|
162
|
+
await navigator.clipboard.writeText(prompt);
|
|
163
|
+
} catch {
|
|
164
|
+
el('agent-prompt').select();
|
|
165
|
+
document.execCommand('copy');
|
|
166
|
+
el('agent-prompt').setSelectionRange(0, 0);
|
|
167
|
+
}
|
|
168
|
+
const button = el('copy-prompt');
|
|
169
|
+
const label = button.textContent;
|
|
170
|
+
button.textContent = '已复制';
|
|
171
|
+
setTimeout(() => { button.textContent = label; }, 1600);
|
|
172
|
+
};
|
|
173
|
+
void refresh();
|
|
174
|
+
setInterval(() => void refresh(), 5000);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
globalThis.openBrowserPhaseLabels = Object.freeze({
|
|
4
|
+
idle: '等待指令', queued: '已排队', running: '执行中', actionability: '检查目标',
|
|
5
|
+
dispatching: '正在派发', waiting: '等待页面', verifying: '核对结果',
|
|
6
|
+
needs_credential: '等待凭据', needs_human_verification: '需要人工验证', completed: '已完成', failed: '失败',
|
|
7
|
+
cancelled: '已取消', outcome_unknown: '结果待核实',
|
|
8
|
+
});
|
|
9
|
+
globalThis.openBrowserModeLabels = Object.freeze({ agent: 'Agent 控制', human: '人工接管', transferring: '交接中' });
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
:root { color-scheme: light dark; font: 13px/1.5 system-ui, sans-serif; }
|
|
2
|
+
* { box-sizing: border-box; }
|
|
3
|
+
body { width: 332px; margin: 0; background: Canvas; color: CanvasText; }
|
|
4
|
+
header { display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid color-mix(in srgb, CanvasText 16%, transparent); padding: 13px 16px; }
|
|
5
|
+
header strong { display: flex; align-items: center; gap: 8px; }
|
|
6
|
+
strong { font-size: 17px; letter-spacing: -.3px; }
|
|
7
|
+
#status, label, #credential-target { color: color-mix(in srgb, CanvasText 75%, Canvas); }
|
|
8
|
+
main { padding: 0 16px 14px; } section, form, details { margin-top: 14px; }
|
|
9
|
+
h2 { font-size: 14px; margin: 0 0 3px; } p { margin: 8px 0; overflow-wrap: anywhere; }
|
|
10
|
+
label { display: block; margin: 8px 0 3px; }
|
|
11
|
+
select, #adoption input, input[type=password] { width: 100%; height: 30px; font: inherit; }
|
|
12
|
+
input[type=password] { padding: 3px 6px; }
|
|
13
|
+
button { font: inherit; border: 1px solid transparent; border-radius: 5px; padding: 4px 10px; background: #176244; color: white; cursor: pointer; }
|
|
14
|
+
button.secondary { background: ButtonFace; color: ButtonText; border-color: color-mix(in srgb, ButtonText 25%, transparent); }
|
|
15
|
+
button:disabled { opacity: .55; cursor: default; }
|
|
16
|
+
.action { display: flex; gap: 7px; margin-top: 9px; }
|
|
17
|
+
form, details { border-top: 1px solid color-mix(in srgb, CanvasText 16%, transparent); padding-top: 10px; }
|
|
18
|
+
summary { cursor: pointer; } .check { margin: 9px 0; } .check input { vertical-align: middle; }
|
|
19
|
+
#notice { margin: 12px 0 0; } [hidden] { display: none !important; }
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="zh-CN">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
6
|
+
<title>open-browser 工作区</title>
|
|
7
|
+
<link rel="icon" type="image/png" href="icons/open-browser-32.png">
|
|
8
|
+
<link rel="stylesheet" href="popup.css">
|
|
9
|
+
<script defer src="workspace-title.js"></script>
|
|
10
|
+
<script defer src="phase-labels.js"></script>
|
|
11
|
+
<script defer src="popup.js"></script>
|
|
12
|
+
</head>
|
|
13
|
+
<body>
|
|
14
|
+
<header><strong><img src="icons/open-browser-48.png" width="24" height="24" alt="">open-browser</strong><span id="status" role="status">正在连接…</span></header>
|
|
15
|
+
<main>
|
|
16
|
+
<p id="empty" hidden>当前没有活动任务。新标签页会显示 Agent 控制台。</p>
|
|
17
|
+
<section id="adoption" hidden>
|
|
18
|
+
<p id="adopt-site"></p>
|
|
19
|
+
<label for="adopt-task">授权给哪个 Agent 任务</label><select id="adopt-task"></select>
|
|
20
|
+
<label for="adopt-alias">账号别名(选填)</label><input id="adopt-alias" maxlength="48" placeholder="例如:工作账号">
|
|
21
|
+
<div class="action"><button id="adopt" type="button">让 Agent 操作此页</button></div>
|
|
22
|
+
<label id="adopt-result" hidden>将以下授权交给所选 Agent,两分钟内有效<input id="adopt-token" readonly></label>
|
|
23
|
+
</section>
|
|
24
|
+
<section id="workspace" hidden>
|
|
25
|
+
<div id="context-selection" hidden>
|
|
26
|
+
<label for="workspaces">工作区</label><select id="workspaces"></select>
|
|
27
|
+
<label for="pages">标签页</label><select id="pages"></select>
|
|
28
|
+
</div>
|
|
29
|
+
<p id="page-details"></p>
|
|
30
|
+
<div class="action"><button id="control" type="button"></button></div>
|
|
31
|
+
<div id="dialogs"></div>
|
|
32
|
+
<div id="blocked"></div>
|
|
33
|
+
<details id="uploads"><summary>授权上传文件</summary><p id="upload-origin"></p>
|
|
34
|
+
<input id="upload-file" type="file"><div id="upload-list"></div></details>
|
|
35
|
+
<details id="downloads" hidden><summary>任务下载</summary><div id="download-list"></div></details>
|
|
36
|
+
<p id="visual-status" hidden></p>
|
|
37
|
+
<details><summary>导出错误日志</summary>
|
|
38
|
+
<p>导出当前任务的脱敏失败记录,便于排查问题。</p>
|
|
39
|
+
<button id="diagnostic-export-button" type="button" class="secondary">导出错误日志</button>
|
|
40
|
+
<a id="diagnostic-export" download="open-browser-error-log.json" hidden>下载错误日志</a>
|
|
41
|
+
</details>
|
|
42
|
+
<details id="delivery"><summary>结束任务</summary>
|
|
43
|
+
<p>勾选要留给自己的标签,其余任务标签将关闭。</p>
|
|
44
|
+
<div id="keep"></div><button id="finish" type="button">结束</button>
|
|
45
|
+
</details>
|
|
46
|
+
</section>
|
|
47
|
+
<form id="credential" hidden>
|
|
48
|
+
<h2>补充凭据</h2>
|
|
49
|
+
<p id="credential-target"></p>
|
|
50
|
+
<label for="secret">凭据值</label><input id="secret" type="password" autocomplete="off" required>
|
|
51
|
+
<div class="action"><button id="save" type="submit">绑定凭据</button></div>
|
|
52
|
+
</form>
|
|
53
|
+
<p id="notice" role="status" hidden></p>
|
|
54
|
+
</main>
|
|
55
|
+
</body>
|
|
56
|
+
</html>
|