@sparkelf/dsh-dataops-managed 0.3.54 → 0.4.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/lib/client.js +154 -154
- package/lib/client.js.map +1 -1
- package/lib/index.js +592 -113
- package/lib/types/collect-api.d.ts +19 -10
- package/lib/types/tool-scope.d.ts +14 -1
- package/package.json +4 -2
- package/skills/browser/SKILL.md +44 -33
- package/skills/{browser-bridge-companion/SKILL.md → browser/references/bridge.md} +1 -6
- package/skills/browser/references/chrome-install.md +309 -0
- package/skills/browser/references/chrome-install.openai.yaml +4 -0
- package/skills/{browser-headless/SKILL.md → browser/references/headless.md} +1 -6
- package/skills/browser/references/scripts/check_browser_bridge_status.js +33 -0
- package/skills/browser/references/scripts/cleanup_isolated_chrome.ps1 +10 -0
- package/skills/browser/references/scripts/start_isolated_chrome.ps1 +25 -0
- package/skills/browser/references/scripts/start_test_browser_bridge.cjs +245 -0
- package/skills/dataops-collect/SKILL.md +57 -96
- package/skills/dataops-collect/references/append.md +137 -0
- package/skills/dataops-collect/references/execution.md +133 -0
- package/skills/dataops-collect/references/plan-schema.md +142 -0
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* DataOps spreadsheet-import transport for the collection skill.
|
|
3
3
|
*
|
|
4
|
-
* The host reads a workspace attachment, uploads it as multipart,
|
|
5
|
-
* create-table or existing-table plan
|
|
6
|
-
*
|
|
7
|
-
*
|
|
4
|
+
* The host reads a workspace attachment, uploads it as multipart, and validates the
|
|
5
|
+
* create-table or existing-table plan the current conversation model wrote. DataOps only
|
|
6
|
+
* normalizes that plan and returns SQL/mapping summaries; it never selects or calls a shared
|
|
7
|
+
* model. Execution is the single mutating call and stays behind the user's explicit
|
|
8
|
+
* confirmation.
|
|
8
9
|
*
|
|
9
10
|
* @module collect-api
|
|
10
11
|
*/
|
|
@@ -33,10 +34,10 @@ export interface CollectPreview {
|
|
|
33
34
|
columns?: Array<Record<string, unknown>>;
|
|
34
35
|
[key: string]: unknown;
|
|
35
36
|
}
|
|
36
|
-
/**
|
|
37
|
-
export interface
|
|
37
|
+
/** The deterministic validation result: the normalized plan and its session context. */
|
|
38
|
+
export interface CollectValidatePlanResult {
|
|
39
|
+
success?: boolean;
|
|
38
40
|
session?: Record<string, unknown>;
|
|
39
|
-
model?: Record<string, unknown>;
|
|
40
41
|
plan?: Record<string, unknown>;
|
|
41
42
|
[key: string]: unknown;
|
|
42
43
|
}
|
|
@@ -85,15 +86,23 @@ export declare class CollectApi {
|
|
|
85
86
|
constructor(reviewApi: ReviewApi);
|
|
86
87
|
preview(filePath: string): Promise<CollectPreview>;
|
|
87
88
|
dataSources(): Promise<CollectDataSource[]>;
|
|
88
|
-
|
|
89
|
+
/**
|
|
90
|
+
* Validate and normalize a plan written by the current conversation model.
|
|
91
|
+
*
|
|
92
|
+
* Read-only and model-free: the backend runs the same deterministic sanitizers as
|
|
93
|
+
* `/plan` and `/execute`, then returns the normalized plan, CREATE TABLE SQL or mapping
|
|
94
|
+
* summary. It never resolves a shared `AiModelConfig` or calls a provider.
|
|
95
|
+
*/
|
|
96
|
+
validatePlan(payload: {
|
|
89
97
|
sessionId: string;
|
|
90
98
|
dataSourceUrn?: string;
|
|
91
99
|
targetTable?: {
|
|
92
100
|
schema: string;
|
|
93
101
|
table: string;
|
|
94
102
|
};
|
|
95
|
-
|
|
96
|
-
|
|
103
|
+
createPlan?: Record<string, unknown>;
|
|
104
|
+
mappings?: unknown[];
|
|
105
|
+
}): Promise<CollectValidatePlanResult>;
|
|
97
106
|
execute(payload: Record<string, unknown>): Promise<CollectExecuteResult>;
|
|
98
107
|
listResources(query?: string, limit?: number): Promise<CollectResourceRow[]>;
|
|
99
108
|
}
|
|
@@ -157,7 +157,7 @@ export declare const AI_TOOL_ACCESS: {
|
|
|
157
157
|
readonly dataops_collect_preview: {
|
|
158
158
|
readonly permission: "data:resource:manage";
|
|
159
159
|
};
|
|
160
|
-
readonly
|
|
160
|
+
readonly dataops_collect_validate_plan: {
|
|
161
161
|
readonly permission: "data:resource:manage";
|
|
162
162
|
};
|
|
163
163
|
readonly dataops_collect_execute: {
|
|
@@ -167,6 +167,19 @@ export declare const AI_TOOL_ACCESS: {
|
|
|
167
167
|
readonly permission: "data:resource:read";
|
|
168
168
|
};
|
|
169
169
|
readonly dataops_open_resource_tab: {};
|
|
170
|
+
readonly dataops_user_lookup: {
|
|
171
|
+
readonly permission: "system:user:read";
|
|
172
|
+
};
|
|
173
|
+
readonly dataops_user_create: {
|
|
174
|
+
readonly capability: "admin.manage";
|
|
175
|
+
readonly adminOnly: true;
|
|
176
|
+
readonly defaultEnabled: true;
|
|
177
|
+
};
|
|
178
|
+
readonly dataops_role_assign: {
|
|
179
|
+
readonly capability: "admin.manage";
|
|
180
|
+
readonly adminOnly: true;
|
|
181
|
+
readonly defaultEnabled: true;
|
|
182
|
+
};
|
|
170
183
|
readonly dataops_resource_pending_list: {
|
|
171
184
|
readonly capability: "resource.manage";
|
|
172
185
|
readonly adminOnly: true;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sparkelf/dsh-dataops-managed",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "DataOps JWT intake and credential-backed MCP tools for managed DeepSeek Harness workspaces.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./lib/index.js",
|
|
@@ -42,10 +42,12 @@
|
|
|
42
42
|
"skills/dataops-query/SKILL.md",
|
|
43
43
|
"skills/dataops-query/i18n/zh.json",
|
|
44
44
|
"skills/dataops-collect/SKILL.md",
|
|
45
|
+
"skills/dataops-collect/references/*.md",
|
|
45
46
|
"skills/admin-workspace-rescue/SKILL.md",
|
|
46
47
|
"README.md",
|
|
47
48
|
"LICENSE",
|
|
48
|
-
"skills/**/SKILL.md"
|
|
49
|
+
"skills/**/SKILL.md",
|
|
50
|
+
"skills/browser/references/**/*"
|
|
49
51
|
],
|
|
50
52
|
"scripts": {
|
|
51
53
|
"build": "rm -rf lib && tsc -p tsconfig.build.json && tsdown",
|
package/skills/browser/SKILL.md
CHANGED
|
@@ -1,15 +1,25 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: browser
|
|
3
|
-
description:
|
|
3
|
+
description: 浏览器自动化总入口。抓取网页/大屏/表格、登录后取数、或用用户本地 Chrome/Edge 操作内网系统时使用。默认工作区 Playwright headless;只有用户明确要求本地浏览器、已登录 Chrome 或 Companion 才走 Browser Bridge。包含 headless、Companion 桥接与旧 Chrome 安装排查三套按需参考。
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# Browser
|
|
7
7
|
|
|
8
|
+
浏览器自动化只有一个入口。先按用户意图选模式,再按需读取对应参考;不要把两套运行方式混在一起,也不要用 curl/静态抓取冒充浏览器操作。
|
|
9
|
+
|
|
10
|
+
## 触发条件
|
|
11
|
+
|
|
12
|
+
- 抓取网页、大屏、表格、图表数据,或把页面结果整理成 JSON / 截图;
|
|
13
|
+
- 用给定账号密码登录后取数;
|
|
14
|
+
- 在用户自己的本地 Chrome/Edge 里打开内网系统、登录、点击、填表、截图;
|
|
15
|
+
- 需要用户扫码、短信验证码或 MFA 接管;
|
|
16
|
+
- 排查 Browser Bridge / Companion / 旧 Chrome 扩展的安装与连接问题。
|
|
17
|
+
|
|
8
18
|
## 先选模式
|
|
9
19
|
|
|
10
20
|
```text
|
|
11
21
|
默认:headless
|
|
12
|
-
|
|
22
|
+
只有用户明确要求本地浏览器或已登录 Chrome → companion
|
|
13
23
|
```
|
|
14
24
|
|
|
15
25
|
| 用户意图 | 模式 |
|
|
@@ -19,52 +29,53 @@ description: 浏览器自动化总入口。默认用工作区 Playwright headles
|
|
|
19
29
|
| “用我电脑上的浏览器” | companion |
|
|
20
30
|
| “用我已经登录的 Chrome” | companion |
|
|
21
31
|
| “用 companion” | companion |
|
|
32
|
+
| 需要扫码/短信/MFA 接管 | companion |
|
|
22
33
|
|
|
23
|
-
Agent
|
|
24
|
-
|
|
25
|
-
## Headless
|
|
26
|
-
|
|
27
|
-
先读 `browser-headless` 技能,然后:
|
|
34
|
+
Agent 不得自行切换 companion;需要时先询问用户。
|
|
28
35
|
|
|
29
|
-
|
|
30
|
-
2. 用工作区 Chromium 运行;
|
|
31
|
-
3. 产出 `result.json` + `screenshot.png`;
|
|
32
|
-
4. 校验数据条数/字段/接口状态。
|
|
36
|
+
## 按需加载
|
|
33
37
|
|
|
34
|
-
|
|
38
|
+
主文件只负责路由和硬规则。进入某个模式后,再读取对应参考:
|
|
35
39
|
|
|
36
|
-
|
|
40
|
+
- **headless(默认)**:[references/headless.md](references/headless.md) — Playwright + Chromium 工作流、脚本模板、凭据登录、大屏抓取、失败处理、输出约定。
|
|
41
|
+
- **companion(本地浏览器)**:[references/bridge.md](references/bridge.md) — `browser_bridge_status` / `browser_bridge_connect` 探测、门户一键配对、`browser_*` 工具流程、安全边界与常见错误。
|
|
42
|
+
- **旧 Chrome 扩展安装/排查**:[references/chrome-install.md](references/chrome-install.md) — 已废弃的扩展安装流程,仅在排查旧环境时读取;脚本在 [references/scripts/](references/scripts/) 下。
|
|
37
43
|
|
|
38
|
-
|
|
39
|
-
2. 未连接则 `browser_bridge_connect`;
|
|
40
|
-
3. 用 `browser_navigate` / `browser_snapshot` 等现有工具;
|
|
41
|
-
4. 不要用 headless 脚本冒充 companion。
|
|
44
|
+
## 通用硬规则
|
|
42
45
|
|
|
43
|
-
|
|
46
|
+
### 凭据
|
|
44
47
|
|
|
45
|
-
-
|
|
48
|
+
- 用户账号密码先存凭据插件,Agent 只拿 `secretRef`;
|
|
46
49
|
- 密码不得出现在 prompt、脚本、日志、截图;
|
|
47
50
|
- headless 通过环境变量/secretRef 登录;
|
|
48
|
-
-
|
|
51
|
+
- 登录失败、验证码或短信验证时停止并询问;不要自动切 companion。
|
|
49
52
|
|
|
50
|
-
|
|
53
|
+
### 安全
|
|
51
54
|
|
|
52
|
-
-
|
|
53
|
-
-
|
|
55
|
+
- headless 只访问用户明确给出的域名;禁止 localhost、127.0.0.1、169.254.169.254、内网管理端口;
|
|
56
|
+
- companion 只操作用户明确授权的域名,允许用户已登录的内网系统;授权边界见 [references/bridge.md](references/bridge.md);
|
|
54
57
|
- 并发 1,默认超时 60s;
|
|
55
|
-
-
|
|
56
|
-
-
|
|
58
|
+
- 独立 context,不持久化 cookie;
|
|
59
|
+
- 提交、下单、删除、发布前必须用户确认;
|
|
60
|
+
- 不读取、不导出、不上传 Cookie、LocalStorage 或密码;不绕过验证码和风控。
|
|
61
|
+
|
|
62
|
+
### 成功判据
|
|
63
|
+
|
|
64
|
+
- 不以“点击成功”或“页面打开了”作为成功;必须校验数据条数、字段、接口状态或页面关键文本;
|
|
65
|
+
- 抓取结果同时写入 `result.json` 与 `screenshot.png`(路径见对应参考);
|
|
66
|
+
- 页面为空或结构变化时报告事实,不猜数据、不伪造结果。
|
|
57
67
|
|
|
58
68
|
## 输出
|
|
59
69
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
70
|
+
```text
|
|
71
|
+
/workspace/outputs/browser/<task>/
|
|
72
|
+
├── result.json # 数据、来源 URL、抓取时间
|
|
73
|
+
└── screenshot.png # 关键页面
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
回复用户:数据条数、字段、来源 URL、异常;不要把整页 HTML 贴进回答。
|
|
64
77
|
|
|
65
78
|
## 相关技能
|
|
66
79
|
|
|
67
|
-
- `browser-
|
|
68
|
-
- `
|
|
69
|
-
- `browser-bridge-companion`:Companion 工具;
|
|
70
|
-
- `browser-bridge-chrome-install`:Companion 安装。
|
|
80
|
+
- `browser-cdp-automation`:接管真实 Chrome / CDP 的通用排障(本技能之外的环境问题)。
|
|
81
|
+
- `dataops-collect`:把抓到的表格/Excel/CSV 建成可问数的数据资源。
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: browser-bridge-companion
|
|
3
|
-
description: 用户要在自己的本地 Chrome/Edge 里打开内网系统、登录、点页面、填表、截图或做网页自动化时使用。先调用 browser_bridge_status 探测 Companion;未连接时调用 browser_bridge_connect 主动连接,仍失败再让用户打开门户「浏览器桥接」一键配对或启动托盘。不要向用户索取配对码、密码或 Cookie。
|
|
4
|
-
---
|
|
5
|
-
|
|
6
1
|
# 浏览器桥接 Companion
|
|
7
2
|
|
|
8
3
|
用户说「打开这个网页」「登录内网系统」「帮我点一下」「填这个表」「截个图」并涉及**用户本地浏览器**时,按本技能执行。
|
|
@@ -58,4 +53,4 @@ description: 用户要在自己的本地 Chrome/Edge 里打开内网系统、登
|
|
|
58
53
|
## 当前版本说明
|
|
59
54
|
|
|
60
55
|
安装包是离线 Windows 包,内含 Chromium、Node 和 Playwright MCP;安装和启动不需要外网。
|
|
61
|
-
本次交付未重打安装包,已安装机器通过替换 `companion.mjs` / `tray.ps1` 获得生产链路与托盘。
|
|
56
|
+
本次交付未重打安装包,已安装机器通过替换 `companion.mjs` / `tray.ps1` 获得生产链路与托盘。
|
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
> **已废弃(2026-11):** 本参考描述的是旧 Chrome 扩展安装流程。现在请优先使用 [bridge.md](bridge.md) 的离线 Companion + Playwright MCP。保留本文仅用于排查旧环境。
|
|
2
|
+
|
|
3
|
+
# Browser Bridge Chrome Install
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
Prepare a local browser for DataOps `browser` tool verification on Windows.
|
|
8
|
+
|
|
9
|
+
This skill covers the stable operator workflow for automated test-browser startup, unpacked extension refresh, backend bridge verification, and the fallback manual Google Chrome flow.
|
|
10
|
+
|
|
11
|
+
## Preconditions
|
|
12
|
+
|
|
13
|
+
- Work from the `dataops` repo on the same Windows machine that runs Chrome/Chromium.
|
|
14
|
+
- The snippets read the admin password from `DATAOPS_ADMIN_PASSWORD`; never paste a real credential into this file, a script, or a log.
|
|
15
|
+
- `references/scripts/start_test_browser_bridge.cjs` also needs `DATAOPS_PROJECTS_ROOT` pointing at the directory that contains the `dataops` checkout, and `DATAOPS_BROWSER_BRIDGE_PASSWORD` for the login.
|
|
16
|
+
- Reuse the current DataOps backend/frontend when available; do not restart them unless the user asks.
|
|
17
|
+
- Treat browser-side install as local-machine state. It is acceptable to open browser UI, but do not mutate unrelated browser profiles.
|
|
18
|
+
- Prefer an isolated Playwright Chromium profile for automated testing. Only use the user's Google Chrome profile when they explicitly ask to.
|
|
19
|
+
|
|
20
|
+
## Stable Workflow
|
|
21
|
+
|
|
22
|
+
### 1. Confirm backend truth first
|
|
23
|
+
|
|
24
|
+
Run these checks before touching the browser:
|
|
25
|
+
|
|
26
|
+
```powershell
|
|
27
|
+
Get-NetTCPConnection -State Listen -LocalPort 3000,3101 -ErrorAction SilentlyContinue |
|
|
28
|
+
Select-Object LocalPort,OwningProcess,State
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
```powershell
|
|
32
|
+
@'
|
|
33
|
+
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
|
|
34
|
+
(async() => {
|
|
35
|
+
const loginResponse = await fetch('https://127.0.0.1:3101/api/auth/login', {
|
|
36
|
+
method: 'POST',
|
|
37
|
+
headers: { 'content-type': 'application/json' },
|
|
38
|
+
body: JSON.stringify({ account: 'admin', password: process.env.DATAOPS_ADMIN_PASSWORD }),
|
|
39
|
+
});
|
|
40
|
+
const loginPayload = await loginResponse.json();
|
|
41
|
+
const toolsResponse = await fetch('https://127.0.0.1:3101/api/ai/tools', {
|
|
42
|
+
headers: { Authorization: `Bearer ${loginPayload.accessToken}` },
|
|
43
|
+
});
|
|
44
|
+
const toolsPayload = await toolsResponse.json();
|
|
45
|
+
const browserTool = toolsPayload.tools.find((tool) => tool.name === 'browser');
|
|
46
|
+
console.log(JSON.stringify({
|
|
47
|
+
browserBridge: browserTool?.browserBridge ?? null,
|
|
48
|
+
dependencyPackage: browserTool?.dependencyPackage ?? null,
|
|
49
|
+
}, null, 2));
|
|
50
|
+
})();
|
|
51
|
+
'@ | node -
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Interpretation:
|
|
55
|
+
|
|
56
|
+
- `dependencyPackage.available = true` means backend package generation works.
|
|
57
|
+
- `browserBridge.connected = false` means Chrome-side install/connect work is still required.
|
|
58
|
+
- `workspaceStatus = RUNNING` is needed later for screenshot persistence, but not for extension install.
|
|
59
|
+
|
|
60
|
+
### 2. Download and unpack the extension package
|
|
61
|
+
|
|
62
|
+
Save the package and unpack it into a predictable local folder:
|
|
63
|
+
|
|
64
|
+
```powershell
|
|
65
|
+
@'
|
|
66
|
+
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
|
|
67
|
+
(async() => {
|
|
68
|
+
const fs = require('fs');
|
|
69
|
+
const loginResponse = await fetch('https://127.0.0.1:3101/api/auth/login', {
|
|
70
|
+
method: 'POST',
|
|
71
|
+
headers: { 'content-type': 'application/json' },
|
|
72
|
+
body: JSON.stringify({ account: 'admin', password: process.env.DATAOPS_ADMIN_PASSWORD }),
|
|
73
|
+
});
|
|
74
|
+
const loginPayload = await loginResponse.json();
|
|
75
|
+
const response = await fetch('https://127.0.0.1:3101/api/ai/tools/browser/dependency-package', {
|
|
76
|
+
headers: { Authorization: `Bearer ${loginPayload.accessToken}` },
|
|
77
|
+
});
|
|
78
|
+
fs.writeFileSync('D:/project/projects/tmp-dataops-browser-bridge.zip', Buffer.from(await response.arrayBuffer()));
|
|
79
|
+
})();
|
|
80
|
+
'@ | node -
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
```powershell
|
|
84
|
+
if (Test-Path D:\project\projects\tmp-dataops-browser-bridge) {
|
|
85
|
+
Remove-Item -LiteralPath D:\project\projects\tmp-dataops-browser-bridge -Recurse -Force
|
|
86
|
+
}
|
|
87
|
+
Expand-Archive -LiteralPath D:\project\projects\tmp-dataops-browser-bridge.zip `
|
|
88
|
+
-DestinationPath D:\project\projects\tmp-dataops-browser-bridge -Force
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
The unpacked extension root is:
|
|
92
|
+
|
|
93
|
+
- `D:\project\projects\tmp-dataops-browser-bridge\extension`
|
|
94
|
+
|
|
95
|
+
### 3. Preferred automated path: launch the test browser
|
|
96
|
+
|
|
97
|
+
The preferred automated path is the Playwright Chromium browser that loads the latest unpacked Browser Bridge and connects it to the current backend automatically.
|
|
98
|
+
|
|
99
|
+
Run from this skill's base directory (the directory containing this `references/` folder):
|
|
100
|
+
|
|
101
|
+
```powershell
|
|
102
|
+
node .\references\scripts\start_test_browser_bridge.cjs --keep-open
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
Expected success signal:
|
|
106
|
+
|
|
107
|
+
- the script prints `backendBridge.connected = true`
|
|
108
|
+
- the script prints an `extensionId`, `workerUrl`, and non-empty `sessionId`
|
|
109
|
+
- backend `GET /api/ai/tools` shows `browser.browserBridge.connected = true`
|
|
110
|
+
|
|
111
|
+
What the script does:
|
|
112
|
+
|
|
113
|
+
- logs into backend with the current admin account
|
|
114
|
+
- reads `browser.dependencyPackage.version` from backend truth
|
|
115
|
+
- downloads and unpacks the latest Browser Bridge package when the local unpacked directory is missing or when the recorded package version no longer matches backend truth
|
|
116
|
+
- launches a persistent Playwright Chromium profile
|
|
117
|
+
- loads the unpacked extension with `--disable-extensions-except` and `--load-extension`
|
|
118
|
+
- opens the DataOps frontend, injects the login token into the page, opens the extension popup, fills the DataOps URL, and lets the extension auto-poll until it resolves the same-origin signed-in session and connects
|
|
119
|
+
- polls both popup state and backend state until the bridge is connected
|
|
120
|
+
|
|
121
|
+
Use this path for automated testing and repeatable local verification.
|
|
122
|
+
|
|
123
|
+
### 4. Fallback manual path: isolated Google Chrome
|
|
124
|
+
|
|
125
|
+
Use a dedicated profile and CDP port so manual Google Chrome validation does not collide with the user's normal Chrome windows:
|
|
126
|
+
|
|
127
|
+
```powershell
|
|
128
|
+
$chrome = 'C:\Users\Administrator\AppData\Local\Google\Chrome\Bin\chrome.exe'
|
|
129
|
+
$profile = 'D:\project\projects\tmp-chrome-browser-bridge-profile'
|
|
130
|
+
$extension = 'D:\project\projects\tmp-dataops-browser-bridge\extension'
|
|
131
|
+
New-Item -ItemType Directory -Force -Path $profile | Out-Null
|
|
132
|
+
Start-Process -FilePath $chrome -ArgumentList @(
|
|
133
|
+
"--user-data-dir=$profile",
|
|
134
|
+
'--disable-background-networking',
|
|
135
|
+
'--remote-debugging-port=9999',
|
|
136
|
+
"--disable-extensions-except=$extension",
|
|
137
|
+
"--load-extension=$extension",
|
|
138
|
+
'--no-first-run',
|
|
139
|
+
'--no-default-browser-check',
|
|
140
|
+
'--ignore-certificate-errors',
|
|
141
|
+
'--new-window',
|
|
142
|
+
'https://127.0.0.1:3000'
|
|
143
|
+
)
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
Confirm CDP is reachable:
|
|
147
|
+
|
|
148
|
+
```powershell
|
|
149
|
+
curl.exe http://127.0.0.1:9999/json/version
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### 5. Manual install and reload method
|
|
153
|
+
|
|
154
|
+
Use this path only when the user explicitly wants Google Chrome itself rather than the automated test browser:
|
|
155
|
+
|
|
156
|
+
1. Open `chrome://extensions/`
|
|
157
|
+
2. Turn on `Developer mode`
|
|
158
|
+
3. Click `Load unpacked`
|
|
159
|
+
4. Select `D:\project\projects\tmp-dataops-browser-bridge\extension`
|
|
160
|
+
5. Open a logged-in DataOps tab in the same Chrome instance
|
|
161
|
+
6. Open the `DataOps Browser Bridge` popup
|
|
162
|
+
7. Enter the DataOps URL or paste a full DataOps page URL
|
|
163
|
+
8. Leave the popup open while it auto-polls for the same-origin signed-in session and connects; `Connect bridge` is only an immediate manual retry.
|
|
164
|
+
|
|
165
|
+
For an already installed unpacked extension after code changes:
|
|
166
|
+
|
|
167
|
+
1. Keep the unpacked folder path stable
|
|
168
|
+
2. Open `chrome://extensions/`
|
|
169
|
+
3. Use the existing extension card's `Reload`
|
|
170
|
+
4. Reopen the popup and wait for auto-connect if backend restarted
|
|
171
|
+
|
|
172
|
+
### 6. Current automation boundary
|
|
173
|
+
|
|
174
|
+
What automation can do reliably today:
|
|
175
|
+
|
|
176
|
+
- confirm backend Browser Bridge truth
|
|
177
|
+
- download and unpack the extension package
|
|
178
|
+
- launch Playwright Chromium with the extension and connect it automatically
|
|
179
|
+
- launch isolated Google Chrome with CDP
|
|
180
|
+
- open `chrome://extensions/`
|
|
181
|
+
- click `Load unpacked`
|
|
182
|
+
- detect the native folder-picker dialog and enumerate its controls
|
|
183
|
+
|
|
184
|
+
What remains unreliable and should be treated as a manual confirmation point:
|
|
185
|
+
|
|
186
|
+
- consumer Google Chrome on Windows does not provide a stable script-only path for registering the unpacked extension into `chrome.management`
|
|
187
|
+
- in project-local verification, Google Chrome logs `--disable-extensions-except is not allowed in Google Chrome, ignoring.`, so the automated path must target Playwright Chromium rather than the user's regular Google Chrome installation
|
|
188
|
+
- the native Windows Google Chrome folder picker for unpacked extensions does not reliably accept Win32 `WM_SETTEXT`, synthetic `SendKeys`, or repeated button invoke attempts in a way that registers the unpacked extension into `chrome.management`
|
|
189
|
+
- in the current verified environment, Google Chrome can still expose `chrome-extension://.../popup.html` targets that resolve to `chrome-error://chromewebdata/ ERR_FILE_NOT_FOUND`; do not treat those targets as proof the extension is installed
|
|
190
|
+
|
|
191
|
+
Therefore the stable workflow is:
|
|
192
|
+
|
|
193
|
+
- use Playwright Chromium for any automated Browser Bridge testing
|
|
194
|
+
- reserve Google Chrome for manual operator validation only
|
|
195
|
+
- if Google Chrome must be used, let the operator manually confirm the `extension/` directory in the folder picker and then continue with popup import/connect validation
|
|
196
|
+
|
|
197
|
+
## Verification
|
|
198
|
+
|
|
199
|
+
### Automated test-browser verification
|
|
200
|
+
|
|
201
|
+
After `start_test_browser_bridge.cjs`, verify backend state directly:
|
|
202
|
+
|
|
203
|
+
```powershell
|
|
204
|
+
cd dataops
|
|
205
|
+
node .\references\scripts\check_browser_bridge_status.js
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
Success condition:
|
|
209
|
+
|
|
210
|
+
- `browserBridge.connected = true`
|
|
211
|
+
- `activeSessionCount >= 1`
|
|
212
|
+
|
|
213
|
+
### Manual Google Chrome verification
|
|
214
|
+
|
|
215
|
+
After manual confirmation, verify the extension is real rather than trusting stale popup targets:
|
|
216
|
+
|
|
217
|
+
```powershell
|
|
218
|
+
@'
|
|
219
|
+
const path = require('path');
|
|
220
|
+
const { createRequire } = require('module');
|
|
221
|
+
const frontendRequire = createRequire(path.resolve('d:/project/projects/dataops/frontend/package.json'));
|
|
222
|
+
const { chromium } = frontendRequire('playwright');
|
|
223
|
+
(async () => {
|
|
224
|
+
const browser = await chromium.connectOverCDP('http://127.0.0.1:9999');
|
|
225
|
+
const context = browser.contexts()[0];
|
|
226
|
+
const page = await context.newPage();
|
|
227
|
+
await page.goto('chrome://extensions/', { waitUntil: 'domcontentloaded', timeout: 60000 });
|
|
228
|
+
const result = await page.evaluate(() => new Promise((resolve, reject) => {
|
|
229
|
+
chrome.management.getAll((items) => {
|
|
230
|
+
const err = chrome.runtime?.lastError?.message;
|
|
231
|
+
if (err) return reject(new Error(err));
|
|
232
|
+
resolve(items.map((item) => ({
|
|
233
|
+
id: item.id,
|
|
234
|
+
name: item.name,
|
|
235
|
+
enabled: item.enabled,
|
|
236
|
+
installType: item.installType,
|
|
237
|
+
type: item.type,
|
|
238
|
+
})));
|
|
239
|
+
});
|
|
240
|
+
}));
|
|
241
|
+
console.log(JSON.stringify(result, null, 2));
|
|
242
|
+
await browser.close();
|
|
243
|
+
})();
|
|
244
|
+
'@ | node -
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
Success condition:
|
|
248
|
+
|
|
249
|
+
- `chrome.management.getAll()` contains `DataOps Browser Bridge`
|
|
250
|
+
|
|
251
|
+
Failure condition:
|
|
252
|
+
|
|
253
|
+
- `getAll()` stays empty or does not include the Browser Bridge entry
|
|
254
|
+
- any `chrome-extension://.../popup.html` target still renders `chrome-error://chromewebdata/ ERR_FILE_NOT_FOUND`
|
|
255
|
+
|
|
256
|
+
### Backend-side verification
|
|
257
|
+
|
|
258
|
+
After popup auto-connect, backend must flip to connected:
|
|
259
|
+
|
|
260
|
+
```powershell
|
|
261
|
+
@'
|
|
262
|
+
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
|
|
263
|
+
(async() => {
|
|
264
|
+
const loginResponse = await fetch('https://127.0.0.1:3101/api/auth/login', {
|
|
265
|
+
method: 'POST',
|
|
266
|
+
headers: { 'content-type': 'application/json' },
|
|
267
|
+
body: JSON.stringify({ account: 'admin', password: process.env.DATAOPS_ADMIN_PASSWORD }),
|
|
268
|
+
});
|
|
269
|
+
const loginPayload = await loginResponse.json();
|
|
270
|
+
const toolsResponse = await fetch('https://127.0.0.1:3101/api/ai/tools', {
|
|
271
|
+
headers: { Authorization: `Bearer ${loginPayload.accessToken}` },
|
|
272
|
+
});
|
|
273
|
+
const toolsPayload = await toolsResponse.json();
|
|
274
|
+
const browserTool = toolsPayload.tools.find((tool) => tool.name === 'browser');
|
|
275
|
+
console.log(JSON.stringify(browserTool?.browserBridge ?? null, null, 2));
|
|
276
|
+
})();
|
|
277
|
+
'@ | node -
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
Success condition:
|
|
281
|
+
|
|
282
|
+
- `connected = true`
|
|
283
|
+
- `activeSessionCount >= 1`
|
|
284
|
+
|
|
285
|
+
## Recovery Notes
|
|
286
|
+
|
|
287
|
+
- If backend still shows `Bridge required`, reopen the popup in the same browser instance and wait for auto-connect.
|
|
288
|
+
- If `start_test_browser_bridge.cjs` fails before backend flips to connected, rerun it with the latest unpacked package in place and read the emitted popup/backend state rather than switching immediately to the manual Chrome path.
|
|
289
|
+
- If `chrome.management.getAll()` does not show `DataOps Browser Bridge` in Google Chrome, do not keep retrying synthetic text-entry against the folder picker. Reopen `chrome://extensions/` and perform the final folder selection manually.
|
|
290
|
+
- If Chrome is already running on the default profile, prefer the isolated profile/CDP launch above instead of reusing the default profile for automation.
|
|
291
|
+
|
|
292
|
+
## Cleanup
|
|
293
|
+
|
|
294
|
+
Only remove temporary artifacts that were created for isolated automation:
|
|
295
|
+
|
|
296
|
+
```powershell
|
|
297
|
+
Get-CimInstance Win32_Process -Filter \"Name = 'chrome.exe'\" |
|
|
298
|
+
Where-Object { $_.CommandLine -like '*tmp-chrome-browser-bridge-profile*' } |
|
|
299
|
+
ForEach-Object { Stop-Process -Id $_.ProcessId -Force }
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
```powershell
|
|
303
|
+
Remove-Item D:\project\projects\tmp-dataops-browser-bridge.zip -Force -ErrorAction SilentlyContinue
|
|
304
|
+
Remove-Item D:\project\projects\tmp-dataops-browser-bridge -Recurse -Force -ErrorAction SilentlyContinue
|
|
305
|
+
Remove-Item D:\project\projects\tmp-chrome-browser-bridge-profile -Recurse -Force -ErrorAction SilentlyContinue
|
|
306
|
+
Remove-Item D:\project\projects\tmp-chrome-browser-bridge-profile-2 -Recurse -Force -ErrorAction SilentlyContinue
|
|
307
|
+
Remove-Item D:\project\projects\tmp-playwright-browser-bridge-profile -Recurse -Force -ErrorAction SilentlyContinue
|
|
308
|
+
Remove-Item D:\project\projects\tmp-chrome-browser-bridge-profile-log -Recurse -Force -ErrorAction SilentlyContinue
|
|
309
|
+
```
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: browser-headless
|
|
3
|
-
description: 用工作区 Playwright + Chromium 无头抓取网页/大屏数据。默认模式;支持账号密码登录(凭据插件注入)、表格/文本/截图/JSON 输出。需要用户已登录的本地浏览器时改用 browser-bridge-companion。
|
|
4
|
-
---
|
|
5
|
-
|
|
6
1
|
# Browser Headless
|
|
7
2
|
|
|
8
3
|
## 前置
|
|
@@ -109,4 +104,4 @@ try {
|
|
|
109
104
|
└── screenshot.png
|
|
110
105
|
```
|
|
111
106
|
|
|
112
|
-
回复用户:数据条数、字段、来源 URL、异常;不要把整页 HTML 贴进回答。
|
|
107
|
+
回复用户:数据条数、字段、来源 URL、异常;不要把整页 HTML 贴进回答。
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
|
|
2
|
+
|
|
3
|
+
async function main() {
|
|
4
|
+
const backendOrigin = process.env.DATAOPS_BROWSER_BRIDGE_BACKEND_ORIGIN || 'https://127.0.0.1:3101';
|
|
5
|
+
const account = process.env.DATAOPS_BROWSER_BRIDGE_ACCOUNT || 'admin';
|
|
6
|
+
const password = process.env.DATAOPS_BROWSER_BRIDGE_PASSWORD;
|
|
7
|
+
if (!password) {
|
|
8
|
+
throw new Error('set DATAOPS_BROWSER_BRIDGE_PASSWORD before running this script');
|
|
9
|
+
}
|
|
10
|
+
const loginResponse = await fetch(`${backendOrigin}/api/auth/login`, {
|
|
11
|
+
method: 'POST',
|
|
12
|
+
headers: { 'content-type': 'application/json' },
|
|
13
|
+
body: JSON.stringify({ account, password }),
|
|
14
|
+
});
|
|
15
|
+
if (!loginResponse.ok) {
|
|
16
|
+
throw new Error(`Login failed: ${loginResponse.status}`);
|
|
17
|
+
}
|
|
18
|
+
const loginPayload = await loginResponse.json();
|
|
19
|
+
const toolsResponse = await fetch(`${backendOrigin}/api/ai/tools`, {
|
|
20
|
+
headers: { Authorization: `Bearer ${loginPayload.accessToken}` },
|
|
21
|
+
});
|
|
22
|
+
if (!toolsResponse.ok) {
|
|
23
|
+
throw new Error(`GET /api/ai/tools failed: ${toolsResponse.status}`);
|
|
24
|
+
}
|
|
25
|
+
const toolsPayload = await toolsResponse.json();
|
|
26
|
+
const browserTool = toolsPayload.tools.find((tool) => tool.name === 'browser');
|
|
27
|
+
console.log(JSON.stringify(browserTool ?? null, null, 2));
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
main().catch((error) => {
|
|
31
|
+
console.error(String(error));
|
|
32
|
+
process.exit(1);
|
|
33
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
Get-CimInstance Win32_Process -Filter "Name = 'chrome.exe'" |
|
|
2
|
+
Where-Object { $_.CommandLine -like '*tmp-chrome-browser-bridge-profile*' } |
|
|
3
|
+
ForEach-Object { Stop-Process -Id $_.ProcessId -Force }
|
|
4
|
+
|
|
5
|
+
Remove-Item D:\project\projects\tmp-dataops-browser-bridge.zip -Force -ErrorAction SilentlyContinue
|
|
6
|
+
Remove-Item D:\project\projects\tmp-dataops-browser-bridge -Recurse -Force -ErrorAction SilentlyContinue
|
|
7
|
+
Remove-Item D:\project\projects\tmp-chrome-browser-bridge-profile -Recurse -Force -ErrorAction SilentlyContinue
|
|
8
|
+
Remove-Item D:\project\projects\tmp-chrome-browser-bridge-profile-2 -Recurse -Force -ErrorAction SilentlyContinue
|
|
9
|
+
Remove-Item D:\project\projects\tmp-playwright-browser-bridge-profile -Recurse -Force -ErrorAction SilentlyContinue
|
|
10
|
+
Remove-Item D:\project\projects\tmp-chrome-browser-bridge-profile-log -Recurse -Force -ErrorAction SilentlyContinue
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
$chrome = 'C:\Users\Administrator\AppData\Local\Google\Chrome\Bin\chrome.exe'
|
|
2
|
+
$profile = 'D:\project\projects\tmp-chrome-browser-bridge-profile'
|
|
3
|
+
$extension = 'D:\project\projects\tmp-dataops-browser-bridge\extension'
|
|
4
|
+
|
|
5
|
+
if (-not (Test-Path $chrome)) {
|
|
6
|
+
throw "Chrome executable not found at $chrome"
|
|
7
|
+
}
|
|
8
|
+
if (-not (Test-Path $extension)) {
|
|
9
|
+
throw "Unpacked extension directory not found at $extension"
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
New-Item -ItemType Directory -Force -Path $profile | Out-Null
|
|
13
|
+
|
|
14
|
+
Start-Process -FilePath $chrome -ArgumentList @(
|
|
15
|
+
"--user-data-dir=$profile",
|
|
16
|
+
'--disable-background-networking',
|
|
17
|
+
'--remote-debugging-port=9999',
|
|
18
|
+
"--disable-extensions-except=$extension",
|
|
19
|
+
"--load-extension=$extension",
|
|
20
|
+
'--no-first-run',
|
|
21
|
+
'--no-default-browser-check',
|
|
22
|
+
'--ignore-certificate-errors',
|
|
23
|
+
'--new-window',
|
|
24
|
+
'https://127.0.0.1:3000'
|
|
25
|
+
)
|