dsh-browser-cdp 0.18.21 → 1.1.5
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/dsh-plugin.json +148 -148
- package/lib/client.js +174 -10
- package/lib/index.js +242 -2
- package/package.json +27 -15
package/dsh-plugin.json
CHANGED
|
@@ -1,148 +1,148 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://dsh.community/schemas/dsh-plugin-0.15.json",
|
|
3
|
-
"id": "dsh-browser-cdp",
|
|
4
|
-
"name": "dsh-browser-cdp",
|
|
5
|
-
"version": "
|
|
6
|
-
"manifestVersion": "0.15",
|
|
7
|
-
"facets": {
|
|
8
|
-
"host": {
|
|
9
|
-
"entry": "lib/index.js",
|
|
10
|
-
"apiVersion": "v1alpha1"
|
|
11
|
-
}
|
|
12
|
-
},
|
|
13
|
-
"requires": {
|
|
14
|
-
"contracts": [
|
|
15
|
-
{
|
|
16
|
-
"apiVersion": "presentation.dsh/v1alpha1",
|
|
17
|
-
"kind": "OpenExternal",
|
|
18
|
-
"optional": true,
|
|
19
|
-
"fallback": "report the URL as text instead of opening it"
|
|
20
|
-
},
|
|
21
|
-
{
|
|
22
|
-
"apiVersion": "presentation.dsh/v1alpha1",
|
|
23
|
-
"kind": "Notification",
|
|
24
|
-
"optional": true,
|
|
25
|
-
"fallback": "log the notice to the browser-status scene"
|
|
26
|
-
}
|
|
27
|
-
]
|
|
28
|
-
},
|
|
29
|
-
"permissions": [],
|
|
30
|
-
"contributes": {
|
|
31
|
-
"commands": [],
|
|
32
|
-
"x-dsh-tui": [
|
|
33
|
-
{
|
|
34
|
-
"apiVersion": "tui.dsh/v1alpha1",
|
|
35
|
-
"kind": "Scene",
|
|
36
|
-
"id": "dsh-browser-cdp.watch",
|
|
37
|
-
"name": "agent_browser",
|
|
38
|
-
"spec": {
|
|
39
|
-
"title": "Agent 浏览器",
|
|
40
|
-
"titles": {
|
|
41
|
-
"en": "Agent Browser",
|
|
42
|
-
"zh": "Agent 浏览器"
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
"apiVersion": "tui.dsh/v1alpha1",
|
|
48
|
-
"kind": "SettingsSection",
|
|
49
|
-
"id": "dsh-browser-cdp.settings",
|
|
50
|
-
"name": "dsh_browser_cdp_settings",
|
|
51
|
-
"spec": {
|
|
52
|
-
"namespace": "dsh-browser-cdp",
|
|
53
|
-
"title": "Agent 浏览器",
|
|
54
|
-
"titles": {
|
|
55
|
-
"en": "Agent Browser",
|
|
56
|
-
"zh": "Agent 浏览器"
|
|
57
|
-
},
|
|
58
|
-
"fields": [
|
|
59
|
-
{
|
|
60
|
-
"path": [
|
|
61
|
-
"isolateSpaces"
|
|
62
|
-
],
|
|
63
|
-
"label": "任务空间沙盒隔离 (Space isolation)",
|
|
64
|
-
"kind": "boolean",
|
|
65
|
-
"hint": "默认关闭:使用磁盘持久化 Profile,任务中登录的账号跨电脑重启永久保留;开启后使用内存临时沙盒隔离,任务结束不落盘。"
|
|
66
|
-
},
|
|
67
|
-
{
|
|
68
|
-
"path": [
|
|
69
|
-
"idleTimeoutMin"
|
|
70
|
-
],
|
|
71
|
-
"label": "空闲自动回收 (Idle auto-stop, minutes)",
|
|
72
|
-
"kind": "number",
|
|
73
|
-
"hint": "N 分钟没有任何 bcdp_* 调用后自动关闭后台浏览器进程(0 = 关闭此功能)。下次调用会自动冷启动(约 2-4 秒)。观察窗正在观看不算活动。"
|
|
74
|
-
},
|
|
75
|
-
{
|
|
76
|
-
"path": [
|
|
77
|
-
"chromePath"
|
|
78
|
-
],
|
|
79
|
-
"label": "Browser binary path",
|
|
80
|
-
"kind": "text",
|
|
81
|
-
"hint": "Path to the Chrome/Chromium/Edge binary. Empty = auto-detect."
|
|
82
|
-
},
|
|
83
|
-
{
|
|
84
|
-
"path": [
|
|
85
|
-
"captureBackend"
|
|
86
|
-
],
|
|
87
|
-
"label": "Capture backend",
|
|
88
|
-
"kind": "select",
|
|
89
|
-
"options": [
|
|
90
|
-
{
|
|
91
|
-
"value": "auto",
|
|
92
|
-
"label": "Auto"
|
|
93
|
-
},
|
|
94
|
-
{
|
|
95
|
-
"value": "cdp",
|
|
96
|
-
"label": "CDP"
|
|
97
|
-
},
|
|
98
|
-
{
|
|
99
|
-
"value": "ffmpeg",
|
|
100
|
-
"label": "FFmpeg"
|
|
101
|
-
}
|
|
102
|
-
]
|
|
103
|
-
},
|
|
104
|
-
{
|
|
105
|
-
"path": [
|
|
106
|
-
"streamProfile"
|
|
107
|
-
],
|
|
108
|
-
"label": "Quality profile",
|
|
109
|
-
"kind": "select",
|
|
110
|
-
"options": [
|
|
111
|
-
{
|
|
112
|
-
"value": "balanced",
|
|
113
|
-
"label": "Balanced"
|
|
114
|
-
},
|
|
115
|
-
{
|
|
116
|
-
"value": "quality",
|
|
117
|
-
"label": "Quality"
|
|
118
|
-
},
|
|
119
|
-
{
|
|
120
|
-
"value": "speed",
|
|
121
|
-
"label": "Speed"
|
|
122
|
-
}
|
|
123
|
-
]
|
|
124
|
-
},
|
|
125
|
-
{
|
|
126
|
-
"path": [
|
|
127
|
-
"ffmpegPath"
|
|
128
|
-
],
|
|
129
|
-
"label": "FFmpeg binary path",
|
|
130
|
-
"kind": "text",
|
|
131
|
-
"hint": "Path to ffmpeg. Empty = auto-detect / on-demand install."
|
|
132
|
-
}
|
|
133
|
-
]
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
]
|
|
137
|
-
},
|
|
138
|
-
"subscriptions": [],
|
|
139
|
-
"license": "MIT",
|
|
140
|
-
"source": {
|
|
141
|
-
"repository": "https://github.com/drscrewdriver/dsh-browser-cdp"
|
|
142
|
-
},
|
|
143
|
-
"compat": {
|
|
144
|
-
"hosts": [
|
|
145
|
-
"dsh-tui"
|
|
146
|
-
]
|
|
147
|
-
}
|
|
148
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://dsh.community/schemas/dsh-plugin-0.15.json",
|
|
3
|
+
"id": "dsh-browser-cdp",
|
|
4
|
+
"name": "dsh-browser-cdp",
|
|
5
|
+
"version": "1.1.3",
|
|
6
|
+
"manifestVersion": "0.15",
|
|
7
|
+
"facets": {
|
|
8
|
+
"host": {
|
|
9
|
+
"entry": "lib/index.js",
|
|
10
|
+
"apiVersion": "v1alpha1"
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"requires": {
|
|
14
|
+
"contracts": [
|
|
15
|
+
{
|
|
16
|
+
"apiVersion": "presentation.dsh/v1alpha1",
|
|
17
|
+
"kind": "OpenExternal",
|
|
18
|
+
"optional": true,
|
|
19
|
+
"fallback": "report the URL as text instead of opening it"
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"apiVersion": "presentation.dsh/v1alpha1",
|
|
23
|
+
"kind": "Notification",
|
|
24
|
+
"optional": true,
|
|
25
|
+
"fallback": "log the notice to the browser-status scene"
|
|
26
|
+
}
|
|
27
|
+
]
|
|
28
|
+
},
|
|
29
|
+
"permissions": [],
|
|
30
|
+
"contributes": {
|
|
31
|
+
"commands": [],
|
|
32
|
+
"x-dsh-tui": [
|
|
33
|
+
{
|
|
34
|
+
"apiVersion": "tui.dsh/v1alpha1",
|
|
35
|
+
"kind": "Scene",
|
|
36
|
+
"id": "dsh-browser-cdp.watch",
|
|
37
|
+
"name": "agent_browser",
|
|
38
|
+
"spec": {
|
|
39
|
+
"title": "Agent 浏览器",
|
|
40
|
+
"titles": {
|
|
41
|
+
"en": "Agent Browser",
|
|
42
|
+
"zh": "Agent 浏览器"
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
"apiVersion": "tui.dsh/v1alpha1",
|
|
48
|
+
"kind": "SettingsSection",
|
|
49
|
+
"id": "dsh-browser-cdp.settings",
|
|
50
|
+
"name": "dsh_browser_cdp_settings",
|
|
51
|
+
"spec": {
|
|
52
|
+
"namespace": "dsh-browser-cdp",
|
|
53
|
+
"title": "Agent 浏览器",
|
|
54
|
+
"titles": {
|
|
55
|
+
"en": "Agent Browser",
|
|
56
|
+
"zh": "Agent 浏览器"
|
|
57
|
+
},
|
|
58
|
+
"fields": [
|
|
59
|
+
{
|
|
60
|
+
"path": [
|
|
61
|
+
"isolateSpaces"
|
|
62
|
+
],
|
|
63
|
+
"label": "任务空间沙盒隔离 (Space isolation)",
|
|
64
|
+
"kind": "boolean",
|
|
65
|
+
"hint": "默认关闭:使用磁盘持久化 Profile,任务中登录的账号跨电脑重启永久保留;开启后使用内存临时沙盒隔离,任务结束不落盘。"
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
"path": [
|
|
69
|
+
"idleTimeoutMin"
|
|
70
|
+
],
|
|
71
|
+
"label": "空闲自动回收 (Idle auto-stop, minutes)",
|
|
72
|
+
"kind": "number",
|
|
73
|
+
"hint": "N 分钟没有任何 bcdp_* 调用后自动关闭后台浏览器进程(0 = 关闭此功能)。下次调用会自动冷启动(约 2-4 秒)。观察窗正在观看不算活动。"
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
"path": [
|
|
77
|
+
"chromePath"
|
|
78
|
+
],
|
|
79
|
+
"label": "Browser binary path",
|
|
80
|
+
"kind": "text",
|
|
81
|
+
"hint": "Path to the Chrome/Chromium/Edge binary. Empty = auto-detect."
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
"path": [
|
|
85
|
+
"captureBackend"
|
|
86
|
+
],
|
|
87
|
+
"label": "Capture backend",
|
|
88
|
+
"kind": "select",
|
|
89
|
+
"options": [
|
|
90
|
+
{
|
|
91
|
+
"value": "auto",
|
|
92
|
+
"label": "Auto"
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
"value": "cdp",
|
|
96
|
+
"label": "CDP"
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
"value": "ffmpeg",
|
|
100
|
+
"label": "FFmpeg"
|
|
101
|
+
}
|
|
102
|
+
]
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
"path": [
|
|
106
|
+
"streamProfile"
|
|
107
|
+
],
|
|
108
|
+
"label": "Quality profile",
|
|
109
|
+
"kind": "select",
|
|
110
|
+
"options": [
|
|
111
|
+
{
|
|
112
|
+
"value": "balanced",
|
|
113
|
+
"label": "Balanced"
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
"value": "quality",
|
|
117
|
+
"label": "Quality"
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
"value": "speed",
|
|
121
|
+
"label": "Speed"
|
|
122
|
+
}
|
|
123
|
+
]
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
"path": [
|
|
127
|
+
"ffmpegPath"
|
|
128
|
+
],
|
|
129
|
+
"label": "FFmpeg binary path",
|
|
130
|
+
"kind": "text",
|
|
131
|
+
"hint": "Path to ffmpeg. Empty = auto-detect / on-demand install."
|
|
132
|
+
}
|
|
133
|
+
]
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
]
|
|
137
|
+
},
|
|
138
|
+
"subscriptions": [],
|
|
139
|
+
"license": "MIT",
|
|
140
|
+
"source": {
|
|
141
|
+
"repository": "https://github.com/drscrewdriver/dsh-browser-cdp"
|
|
142
|
+
},
|
|
143
|
+
"compat": {
|
|
144
|
+
"hosts": [
|
|
145
|
+
"dsh-tui"
|
|
146
|
+
]
|
|
147
|
+
}
|
|
148
|
+
}
|
package/lib/client.js
CHANGED
|
@@ -199,7 +199,38 @@ function applyProbe(links, id, outcome, at) {
|
|
|
199
199
|
//#endregion
|
|
200
200
|
//#region src/client/index.ts
|
|
201
201
|
var React = require("react");
|
|
202
|
-
var
|
|
202
|
+
var runtimeClient = null;
|
|
203
|
+
var createSnapshotStore = null;
|
|
204
|
+
function ensureSnapshotStoreCreator() {
|
|
205
|
+
if (createSnapshotStore !== null) return createSnapshotStore;
|
|
206
|
+
try {
|
|
207
|
+
runtimeClient = require("@deepseek-ai/dsh-client-store");
|
|
208
|
+
createSnapshotStore = runtimeClient.createSnapshotStore;
|
|
209
|
+
} catch (e) {
|
|
210
|
+
createSnapshotStore = function(initial) {
|
|
211
|
+
var value = initial;
|
|
212
|
+
var listeners = [];
|
|
213
|
+
return {
|
|
214
|
+
subscribe: function(fn) {
|
|
215
|
+
listeners.push(fn);
|
|
216
|
+
return function() {
|
|
217
|
+
listeners = listeners.filter(function(l) {
|
|
218
|
+
return l !== fn;
|
|
219
|
+
});
|
|
220
|
+
};
|
|
221
|
+
},
|
|
222
|
+
getSnapshot: function() {
|
|
223
|
+
return value;
|
|
224
|
+
},
|
|
225
|
+
update: function(fn) {
|
|
226
|
+
value = fn(value);
|
|
227
|
+
for (var i = 0; i < listeners.length; i++) listeners[i]();
|
|
228
|
+
}
|
|
229
|
+
};
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
return createSnapshotStore;
|
|
233
|
+
}
|
|
203
234
|
var useSyncExternalStore = React.useSyncExternalStore;
|
|
204
235
|
var useRef = React.useRef;
|
|
205
236
|
function bindSnapshotSelector(source) {
|
|
@@ -947,10 +978,136 @@ const ICON_REFRESH = `<svg width="15" height="15" viewBox="0 0 24 24" fill="none
|
|
|
947
978
|
const ICON_CLOCK = `<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round"><circle cx="12" cy="12" r="9"/><path d="M12 7.5V12l3 2"/></svg>`;
|
|
948
979
|
const ICON_CLOSE = `<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.9" stroke-linecap="round"><path d="M6 6l12 12M18 6L6 18"/></svg>`;
|
|
949
980
|
const ICON_GRIP = `<svg width="14" height="14" viewBox="0 0 24 24" fill="currentColor"><circle cx="8" cy="6" r="1.8"/><circle cx="16" cy="6" r="1.8"/><circle cx="8" cy="12" r="1.8"/><circle cx="16" cy="12" r="1.8"/><circle cx="8" cy="18" r="1.8"/><circle cx="16" cy="18" r="1.8"/></svg>`;
|
|
981
|
+
var BRIDGE_ROUTES = {
|
|
982
|
+
describe: "/api/dsh-browser-cdp/settings/describe",
|
|
983
|
+
mutate: "/api/dsh-browser-cdp/settings/mutate"
|
|
984
|
+
};
|
|
985
|
+
function bridgeDescriptorPlainValue(d) {
|
|
986
|
+
var v = d && d.value;
|
|
987
|
+
if (v !== null && typeof v === "object" && !Array.isArray(v)) {
|
|
988
|
+
var values = Object.keys(v);
|
|
989
|
+
if (values.length > 0 && values.every(function(k) {
|
|
990
|
+
var x = v[k];
|
|
991
|
+
return x !== null && typeof x === "object" && !Array.isArray(x) && Object.keys(x).length === 0;
|
|
992
|
+
})) {
|
|
993
|
+
var merged = {};
|
|
994
|
+
var pull = function(layer) {
|
|
995
|
+
if (layer !== null && typeof layer === "object" && !Array.isArray(layer)) for (var k in layer) merged[k] = layer[k];
|
|
996
|
+
};
|
|
997
|
+
pull(d.base);
|
|
998
|
+
pull(d.user);
|
|
999
|
+
return merged;
|
|
1000
|
+
}
|
|
1001
|
+
}
|
|
1002
|
+
return v;
|
|
1003
|
+
}
|
|
1004
|
+
function makeBridgeScope() {
|
|
1005
|
+
var listeners = [];
|
|
1006
|
+
var snapshot = {
|
|
1007
|
+
status: "loading",
|
|
1008
|
+
value: void 0,
|
|
1009
|
+
writable: true,
|
|
1010
|
+
mode: "bridge"
|
|
1011
|
+
};
|
|
1012
|
+
var revision = void 0;
|
|
1013
|
+
var retriesLeft = 4;
|
|
1014
|
+
var inflight = void 0;
|
|
1015
|
+
function notify() {
|
|
1016
|
+
for (var i = 0; i < listeners.length; i++) listeners[i]();
|
|
1017
|
+
}
|
|
1018
|
+
function applyDescriptor(d, writable) {
|
|
1019
|
+
revision = typeof d.revision === "number" ? d.revision : void 0;
|
|
1020
|
+
snapshot = {
|
|
1021
|
+
status: "ready",
|
|
1022
|
+
value: bridgeDescriptorPlainValue(d),
|
|
1023
|
+
writable,
|
|
1024
|
+
mode: "bridge"
|
|
1025
|
+
};
|
|
1026
|
+
}
|
|
1027
|
+
function request(path, body) {
|
|
1028
|
+
return fetch(path, {
|
|
1029
|
+
method: "POST",
|
|
1030
|
+
headers: { "content-type": "application/json" },
|
|
1031
|
+
body: JSON.stringify(body ?? {})
|
|
1032
|
+
}).then(function(r) {
|
|
1033
|
+
if (!r.ok) throw new Error("bridge " + path + " HTTP " + r.status);
|
|
1034
|
+
return r.json();
|
|
1035
|
+
});
|
|
1036
|
+
}
|
|
1037
|
+
function retryOrFail() {
|
|
1038
|
+
if (retriesLeft > 0) {
|
|
1039
|
+
retriesLeft -= 1;
|
|
1040
|
+
inflight = void 0;
|
|
1041
|
+
setTimeout(function() {
|
|
1042
|
+
refresh();
|
|
1043
|
+
}, 1500);
|
|
1044
|
+
return true;
|
|
1045
|
+
}
|
|
1046
|
+
snapshot = {
|
|
1047
|
+
status: "unavailable",
|
|
1048
|
+
value: void 0,
|
|
1049
|
+
writable: false,
|
|
1050
|
+
mode: "bridge"
|
|
1051
|
+
};
|
|
1052
|
+
return false;
|
|
1053
|
+
}
|
|
1054
|
+
function refresh() {
|
|
1055
|
+
if (inflight !== void 0) return inflight;
|
|
1056
|
+
inflight = request(BRIDGE_ROUTES.describe, {}).then(function(body) {
|
|
1057
|
+
if (body && body.ok && body.value && body.value.descriptor !== void 0) {
|
|
1058
|
+
retriesLeft = 4;
|
|
1059
|
+
applyDescriptor(body.value.descriptor, body.value.writable !== false);
|
|
1060
|
+
} else if (!(body && body.code && (body.code === "settings-unavailable" || body.code === "ns-not-registered") && retryOrFail())) snapshot = {
|
|
1061
|
+
status: "unavailable",
|
|
1062
|
+
value: void 0,
|
|
1063
|
+
writable: false,
|
|
1064
|
+
mode: "bridge"
|
|
1065
|
+
};
|
|
1066
|
+
inflight = void 0;
|
|
1067
|
+
notify();
|
|
1068
|
+
}, function() {
|
|
1069
|
+
retryOrFail();
|
|
1070
|
+
inflight = void 0;
|
|
1071
|
+
notify();
|
|
1072
|
+
});
|
|
1073
|
+
return inflight;
|
|
1074
|
+
}
|
|
1075
|
+
refresh();
|
|
1076
|
+
return {
|
|
1077
|
+
subscribe: function(listener) {
|
|
1078
|
+
listeners.push(listener);
|
|
1079
|
+
return function() {
|
|
1080
|
+
var i = listeners.indexOf(listener);
|
|
1081
|
+
if (i >= 0) listeners.splice(i, 1);
|
|
1082
|
+
};
|
|
1083
|
+
},
|
|
1084
|
+
getSnapshot: function() {
|
|
1085
|
+
return snapshot;
|
|
1086
|
+
},
|
|
1087
|
+
set: function(field, value) {
|
|
1088
|
+
return request(BRIDGE_ROUTES.mutate, {
|
|
1089
|
+
ops: [{
|
|
1090
|
+
op: "set",
|
|
1091
|
+
path: [field],
|
|
1092
|
+
value
|
|
1093
|
+
}],
|
|
1094
|
+
expectedRevision: revision
|
|
1095
|
+
}).then(function(body) {
|
|
1096
|
+
if (body && body.ok && body.value && body.value.descriptor !== void 0) {
|
|
1097
|
+
applyDescriptor(body.value.descriptor, snapshot.writable);
|
|
1098
|
+
notify();
|
|
1099
|
+
return true;
|
|
1100
|
+
}
|
|
1101
|
+
if (body && body.code === "settings-conflict") refresh();
|
|
1102
|
+
return false;
|
|
1103
|
+
});
|
|
1104
|
+
}
|
|
1105
|
+
};
|
|
1106
|
+
}
|
|
950
1107
|
function mountFamilySettingsCard(ctx) {
|
|
951
1108
|
var forms = typeof ctx.get === "function" ? ctx.get("configForms") : void 0;
|
|
952
|
-
|
|
953
|
-
|
|
1109
|
+
var scope = forms && typeof forms.get === "function" ? forms.get("dsh-browser-cdp") : void 0;
|
|
1110
|
+
if (!scope) scope = makeBridgeScope();
|
|
954
1111
|
ctx.slots.inject("dsh-family.tab", function() {
|
|
955
1112
|
return ctx.slots.register({
|
|
956
1113
|
name: "dsh-family.tab",
|
|
@@ -967,8 +1124,8 @@ function mountFamilySettingsCard(ctx) {
|
|
|
967
1124
|
}
|
|
968
1125
|
function mountPluginsPageCard(ctx) {
|
|
969
1126
|
var forms = typeof ctx.get === "function" ? ctx.get("configForms") : void 0;
|
|
970
|
-
|
|
971
|
-
|
|
1127
|
+
var scope = forms && typeof forms.get === "function" ? forms.get("dsh-browser-cdp") : void 0;
|
|
1128
|
+
if (!scope) scope = makeBridgeScope();
|
|
972
1129
|
ctx.slots.inject("plugins.bundle.config", function() {
|
|
973
1130
|
return ctx.slots.register({
|
|
974
1131
|
name: "plugins.bundle.config",
|
|
@@ -1950,10 +2107,17 @@ function FamLinks(props) {
|
|
|
1950
2107
|
} }, errText) : null));
|
|
1951
2108
|
}
|
|
1952
2109
|
function apply(ctx) {
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
2110
|
+
var mounts = [
|
|
2111
|
+
["family settings tab", mountFamilySettingsCard],
|
|
2112
|
+
["plugins-page config card", mountPluginsPageCard],
|
|
2113
|
+
["picks dock", mountPicksDockCard],
|
|
2114
|
+
["picks badge", mountPicksBadge]
|
|
2115
|
+
];
|
|
2116
|
+
for (var mi = 0; mi < mounts.length; mi++) try {
|
|
2117
|
+
mounts[mi][1](ctx);
|
|
2118
|
+
} catch (e) {
|
|
2119
|
+
console.warn("[dsh-browser-cdp] mount failed:", mounts[mi][0], e && e.message ? e.message : String(e));
|
|
2120
|
+
}
|
|
1957
2121
|
var betterSidebarService;
|
|
1958
2122
|
try {
|
|
1959
2123
|
betterSidebarService = typeof ctx.get === "function" ? ctx.get("betterSidebar") : void 0;
|
|
@@ -3780,7 +3944,7 @@ function createPickControl(onState, deliver) {
|
|
|
3780
3944
|
}
|
|
3781
3945
|
function LivePreviewController(ctx) {
|
|
3782
3946
|
this.ctx = ctx;
|
|
3783
|
-
this.store =
|
|
3947
|
+
this.store = ensureSnapshotStoreCreator()(this._initialState());
|
|
3784
3948
|
this.frameCache = /* @__PURE__ */ new Map();
|
|
3785
3949
|
this.pageMeta = /* @__PURE__ */ new Map();
|
|
3786
3950
|
this.lastList = [];
|
package/lib/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { f as stopLocalBrowser, l as launchLocalBrowser } from "./launcher-BadIUjAx.js";
|
|
2
|
+
import { createRequire } from "node:module";
|
|
2
3
|
import { defineTool } from "@deepseek-ai/dsh-tools";
|
|
3
4
|
import { constants, createReadStream, createWriteStream, existsSync, readdirSync } from "node:fs";
|
|
4
5
|
import { homedir, tmpdir } from "node:os";
|
|
@@ -3226,6 +3227,236 @@ function installEgoBrowserSettings(ctx, config) {
|
|
|
3226
3227
|
}
|
|
3227
3228
|
};
|
|
3228
3229
|
}
|
|
3230
|
+
function installSettingsAuto(ctx, config) {
|
|
3231
|
+
const legacySettings = ctx.settings;
|
|
3232
|
+
const legacyModule = (() => {
|
|
3233
|
+
try {
|
|
3234
|
+
return createRequire(import.meta.url)("@deepseek-ai/dsh-settings");
|
|
3235
|
+
} catch {
|
|
3236
|
+
return;
|
|
3237
|
+
}
|
|
3238
|
+
})();
|
|
3239
|
+
if (typeof legacyModule.installSettingsSection === "function" && typeof legacyModule.settingsNamespace === "function") {
|
|
3240
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
3241
|
+
let current = derefVolatileConfig(config);
|
|
3242
|
+
const notify = () => {
|
|
3243
|
+
for (const listener of [...listeners]) listener();
|
|
3244
|
+
};
|
|
3245
|
+
const ns = legacyModule.settingsNamespace("dsh-browser-cdp");
|
|
3246
|
+
legacyModule.installSettingsSection(ctx, ns, Config$1, current, {
|
|
3247
|
+
setSource: (source) => {
|
|
3248
|
+
current = derefVolatileConfig((typeof source === "function" ? source() : source) ?? {});
|
|
3249
|
+
},
|
|
3250
|
+
onChange: () => {
|
|
3251
|
+
notify();
|
|
3252
|
+
}
|
|
3253
|
+
});
|
|
3254
|
+
return {
|
|
3255
|
+
source: () => current,
|
|
3256
|
+
onChange: (cb) => {
|
|
3257
|
+
listeners.add(cb);
|
|
3258
|
+
return () => {
|
|
3259
|
+
listeners.delete(cb);
|
|
3260
|
+
};
|
|
3261
|
+
}
|
|
3262
|
+
};
|
|
3263
|
+
}
|
|
3264
|
+
if (legacySettings && typeof legacySettings.installSection === "function") {
|
|
3265
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
3266
|
+
let current = derefVolatileConfig(config);
|
|
3267
|
+
const notify = () => {
|
|
3268
|
+
for (const listener of [...listeners]) listener();
|
|
3269
|
+
};
|
|
3270
|
+
legacySettings.installSection(ctx, "dsh-browser-cdp", Config$1, current, {
|
|
3271
|
+
setSource: (source) => {
|
|
3272
|
+
current = derefVolatileConfig((typeof source === "function" ? source() : source) ?? {});
|
|
3273
|
+
},
|
|
3274
|
+
onChange: () => {
|
|
3275
|
+
notify();
|
|
3276
|
+
}
|
|
3277
|
+
});
|
|
3278
|
+
return {
|
|
3279
|
+
source: () => current,
|
|
3280
|
+
onChange: (cb) => {
|
|
3281
|
+
listeners.add(cb);
|
|
3282
|
+
return () => {
|
|
3283
|
+
listeners.delete(cb);
|
|
3284
|
+
};
|
|
3285
|
+
}
|
|
3286
|
+
};
|
|
3287
|
+
}
|
|
3288
|
+
return installEgoBrowserSettings(ctx, config);
|
|
3289
|
+
}
|
|
3290
|
+
const SETTINGS_BRIDGE_NS = "dsh-browser-cdp";
|
|
3291
|
+
function bridgeSendJson(res, code, body) {
|
|
3292
|
+
res.writeHead(code, {
|
|
3293
|
+
"content-type": "application/json; charset=utf-8",
|
|
3294
|
+
"cache-control": "no-cache"
|
|
3295
|
+
});
|
|
3296
|
+
res.end(JSON.stringify(body));
|
|
3297
|
+
}
|
|
3298
|
+
function bridgeReadJson(req) {
|
|
3299
|
+
return new Promise((resolve$1, reject) => {
|
|
3300
|
+
const chunks = [];
|
|
3301
|
+
let size = 0;
|
|
3302
|
+
req.on("data", (chunk) => {
|
|
3303
|
+
const buf = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk);
|
|
3304
|
+
size += buf.length;
|
|
3305
|
+
if (size > 256 * 1024) {
|
|
3306
|
+
reject(/* @__PURE__ */ new Error("bridge body too large"));
|
|
3307
|
+
if (typeof req.resume === "function") req.resume();
|
|
3308
|
+
return;
|
|
3309
|
+
}
|
|
3310
|
+
chunks.push(buf);
|
|
3311
|
+
});
|
|
3312
|
+
req.on("end", () => {
|
|
3313
|
+
const raw = Buffer.concat(chunks).toString("utf8");
|
|
3314
|
+
if (raw === "") {
|
|
3315
|
+
resolve$1({});
|
|
3316
|
+
return;
|
|
3317
|
+
}
|
|
3318
|
+
try {
|
|
3319
|
+
resolve$1(JSON.parse(raw));
|
|
3320
|
+
} catch (e) {
|
|
3321
|
+
reject(e instanceof Error ? e : new Error(String(e)));
|
|
3322
|
+
}
|
|
3323
|
+
});
|
|
3324
|
+
req.on("error", reject);
|
|
3325
|
+
});
|
|
3326
|
+
}
|
|
3327
|
+
function bridgeDescribeNs(svc, ns) {
|
|
3328
|
+
return svc.describe({ redactSecrets: true }).find((d) => d.ns === ns);
|
|
3329
|
+
}
|
|
3330
|
+
/**
|
|
3331
|
+
* 注册 /api/dsh-browser-cdp/settings/{describe,mutate} 两端点(kind:'exact')。
|
|
3332
|
+
* 宿主 settings 服务经惰性 ctx.get 取(cordis get 永不 throw;服务未解析时
|
|
3333
|
+
* describe 回 settings-unavailable,client 桥按瞬态重试)。webServer 缺席的
|
|
3334
|
+
* 宿主(TUI/headless)整段 no-op。
|
|
3335
|
+
*/
|
|
3336
|
+
function registerSettingsBridge(wctx, ctx) {
|
|
3337
|
+
const ws = wctx;
|
|
3338
|
+
if (!ws || typeof ws.register !== "function") return;
|
|
3339
|
+
const c = ctx;
|
|
3340
|
+
const getSettingsSvc = () => {
|
|
3341
|
+
try {
|
|
3342
|
+
return typeof c?.get === "function" ? c.get("settings") : void 0;
|
|
3343
|
+
} catch {
|
|
3344
|
+
return;
|
|
3345
|
+
}
|
|
3346
|
+
};
|
|
3347
|
+
ws.register({
|
|
3348
|
+
kind: "exact",
|
|
3349
|
+
path: `/api/${SETTINGS_BRIDGE_NS}/settings/describe`,
|
|
3350
|
+
handler: (req, res) => {
|
|
3351
|
+
if (req.method !== "POST") {
|
|
3352
|
+
bridgeSendJson(res, 405, {
|
|
3353
|
+
ok: false,
|
|
3354
|
+
code: "method-not-allowed"
|
|
3355
|
+
});
|
|
3356
|
+
return;
|
|
3357
|
+
}
|
|
3358
|
+
const svc = getSettingsSvc();
|
|
3359
|
+
if (!svc || typeof svc.describe !== "function") {
|
|
3360
|
+
bridgeSendJson(res, 200, {
|
|
3361
|
+
ok: false,
|
|
3362
|
+
code: "settings-unavailable",
|
|
3363
|
+
message: "settings service not resolved yet"
|
|
3364
|
+
});
|
|
3365
|
+
return;
|
|
3366
|
+
}
|
|
3367
|
+
try {
|
|
3368
|
+
const descriptor = bridgeDescribeNs(svc, SETTINGS_BRIDGE_NS);
|
|
3369
|
+
if (descriptor === void 0) {
|
|
3370
|
+
bridgeSendJson(res, 200, {
|
|
3371
|
+
ok: false,
|
|
3372
|
+
code: "ns-not-registered",
|
|
3373
|
+
message: `settings namespace "${SETTINGS_BRIDGE_NS}" is not registered`
|
|
3374
|
+
});
|
|
3375
|
+
return;
|
|
3376
|
+
}
|
|
3377
|
+
bridgeSendJson(res, 200, {
|
|
3378
|
+
ok: true,
|
|
3379
|
+
value: {
|
|
3380
|
+
descriptor,
|
|
3381
|
+
writable: svc.writable !== false
|
|
3382
|
+
}
|
|
3383
|
+
});
|
|
3384
|
+
} catch (e) {
|
|
3385
|
+
bridgeSendJson(res, 200, {
|
|
3386
|
+
ok: false,
|
|
3387
|
+
code: "internal",
|
|
3388
|
+
message: e instanceof Error ? e.message : String(e)
|
|
3389
|
+
});
|
|
3390
|
+
}
|
|
3391
|
+
}
|
|
3392
|
+
});
|
|
3393
|
+
ws.register({
|
|
3394
|
+
kind: "exact",
|
|
3395
|
+
path: `/api/${SETTINGS_BRIDGE_NS}/settings/mutate`,
|
|
3396
|
+
handler: (req, res) => {
|
|
3397
|
+
if (req.method !== "POST") {
|
|
3398
|
+
bridgeSendJson(res, 405, {
|
|
3399
|
+
ok: false,
|
|
3400
|
+
code: "method-not-allowed"
|
|
3401
|
+
});
|
|
3402
|
+
return;
|
|
3403
|
+
}
|
|
3404
|
+
const svc = getSettingsSvc();
|
|
3405
|
+
if (!svc || typeof svc.mutate !== "function") {
|
|
3406
|
+
bridgeSendJson(res, 200, {
|
|
3407
|
+
ok: false,
|
|
3408
|
+
code: "settings-unavailable",
|
|
3409
|
+
message: "settings service mutate not available"
|
|
3410
|
+
});
|
|
3411
|
+
return;
|
|
3412
|
+
}
|
|
3413
|
+
bridgeReadJson(req).then((body) => {
|
|
3414
|
+
const ops = body?.ops;
|
|
3415
|
+
if (!(Array.isArray(ops) && ops.every((op) => op !== null && typeof op === "object" && (op.op === "set" || op.op === "unset")))) {
|
|
3416
|
+
bridgeSendJson(res, 200, {
|
|
3417
|
+
ok: false,
|
|
3418
|
+
code: "settings-rejected",
|
|
3419
|
+
message: "malformed bridge mutate ops"
|
|
3420
|
+
});
|
|
3421
|
+
return;
|
|
3422
|
+
}
|
|
3423
|
+
const expectedRevision = typeof body.expectedRevision === "number" ? body.expectedRevision : void 0;
|
|
3424
|
+
Promise.resolve(svc.mutate(SETTINGS_BRIDGE_NS, ops, expectedRevision)).then(() => {
|
|
3425
|
+
const descriptor = bridgeDescribeNs(svc, SETTINGS_BRIDGE_NS);
|
|
3426
|
+
if (descriptor === void 0) {
|
|
3427
|
+
bridgeSendJson(res, 200, {
|
|
3428
|
+
ok: false,
|
|
3429
|
+
code: "internal",
|
|
3430
|
+
message: `namespace "${SETTINGS_BRIDGE_NS}" disposed after mutate`
|
|
3431
|
+
});
|
|
3432
|
+
return;
|
|
3433
|
+
}
|
|
3434
|
+
bridgeSendJson(res, 200, {
|
|
3435
|
+
ok: true,
|
|
3436
|
+
value: { descriptor }
|
|
3437
|
+
});
|
|
3438
|
+
}).catch((e) => {
|
|
3439
|
+
const msg = e instanceof Error ? e.message : String(e);
|
|
3440
|
+
bridgeSendJson(res, 200, e instanceof Error && /conflict|revision/i.test(msg) ? {
|
|
3441
|
+
ok: false,
|
|
3442
|
+
code: "settings-conflict",
|
|
3443
|
+
message: msg
|
|
3444
|
+
} : {
|
|
3445
|
+
ok: false,
|
|
3446
|
+
code: "internal",
|
|
3447
|
+
message: msg
|
|
3448
|
+
});
|
|
3449
|
+
});
|
|
3450
|
+
}).catch((e) => {
|
|
3451
|
+
bridgeSendJson(res, 200, {
|
|
3452
|
+
ok: false,
|
|
3453
|
+
code: "bad-request",
|
|
3454
|
+
message: e instanceof Error ? e.message : String(e)
|
|
3455
|
+
});
|
|
3456
|
+
});
|
|
3457
|
+
}
|
|
3458
|
+
});
|
|
3459
|
+
}
|
|
3229
3460
|
|
|
3230
3461
|
//#endregion
|
|
3231
3462
|
//#region src/ffmpeg-manifest.ts
|
|
@@ -6593,7 +6824,11 @@ const messageOf = (error) => error instanceof Error ? error.message : String(err
|
|
|
6593
6824
|
//#endregion
|
|
6594
6825
|
//#region src/index.ts
|
|
6595
6826
|
const name = "dsh-browser-cdp";
|
|
6596
|
-
const inject = [
|
|
6827
|
+
const inject = [
|
|
6828
|
+
"tools",
|
|
6829
|
+
"subprocess",
|
|
6830
|
+
"settings"
|
|
6831
|
+
];
|
|
6597
6832
|
const Config = Config$1;
|
|
6598
6833
|
/** Vendored ego-linux CLI shipped inside this plugin (runtime/ego-linux/bin/). */
|
|
6599
6834
|
const VENDORED_EGO_BIN = fileURLToPath(new URL("../runtime/ego-linux/bin/ego-browser.mjs", import.meta.url));
|
|
@@ -7082,7 +7317,7 @@ function defineEgoTool(ctx, cfg, opts) {
|
|
|
7082
7317
|
});
|
|
7083
7318
|
}
|
|
7084
7319
|
function apply(ctx, config = {}) {
|
|
7085
|
-
const bridge =
|
|
7320
|
+
const bridge = installSettingsAuto(ctx, config);
|
|
7086
7321
|
const ffmpegManager = getSharedFfmpegInstallationManager();
|
|
7087
7322
|
const initialFfmpegConfig = resolveConfig(bridge.source());
|
|
7088
7323
|
ffmpegManager.check({
|
|
@@ -7333,6 +7568,11 @@ function apply(ctx, config = {}) {
|
|
|
7333
7568
|
} catch (err) {
|
|
7334
7569
|
ctx.logger?.warn?.(`dsh-browser-cdp: capability gateway init failed: ${err?.message ?? err}`);
|
|
7335
7570
|
}
|
|
7571
|
+
try {
|
|
7572
|
+
registerSettingsBridge(wctx, ctx);
|
|
7573
|
+
} catch (err) {
|
|
7574
|
+
ctx.logger?.warn?.(`dsh-browser-cdp: settings bridge init failed: ${err?.message ?? err}`);
|
|
7575
|
+
}
|
|
7336
7576
|
});
|
|
7337
7577
|
ctx.effect?.(() => {
|
|
7338
7578
|
if (cfg.idleTimeoutMin <= 0) return;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-browser-cdp",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "1.1.5",
|
|
4
4
|
"description": "dsh-browser-cdp: DSH browser plugin — attach to a running Chrome/Edge over CDP (no bundled browser needed); structured browser-automation tools (30+ bcdp_*) that drive the vendored ego runtime through ctx.subprocess, plus a realtime watch panel (live SSE screencast + direct mouse interaction + download capture + human-verification notice). Web shell: floating watch panel without dsh-better-sidebar, sidebar tab with it. Headless/TUI hosts: tools-only. [DSH 0.2.0-rc.1+ line: declarative settings via Config .volatile() fields; for DSH 0.1.2-rc.1 ~ 0.1.7 use the 0.17.x line]",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./lib/index.js",
|
|
@@ -21,31 +21,46 @@
|
|
|
21
21
|
],
|
|
22
22
|
"dsh": {
|
|
23
23
|
"engines": {
|
|
24
|
-
"dsh": ">=0.
|
|
24
|
+
"dsh": ">=0.1.0-0 <0.3.0-0"
|
|
25
25
|
},
|
|
26
26
|
"bundle": {
|
|
27
27
|
"patch": "./cordis.patch.yml"
|
|
28
28
|
},
|
|
29
29
|
"client": {
|
|
30
30
|
"platform": "web",
|
|
31
|
-
"inject": [
|
|
31
|
+
"inject": [
|
|
32
|
+
"@deepseek-ai/dsh-client-locale"
|
|
33
|
+
]
|
|
34
|
+
},
|
|
35
|
+
"compatibility": {
|
|
36
|
+
"dshReleases": {
|
|
37
|
+
"0.1.2-rc.1": "compatible",
|
|
38
|
+
"0.1.5-rc.1": "compatible",
|
|
39
|
+
"0.1.5-rc.2": "compatible",
|
|
40
|
+
"0.1.5-rc.3": "compatible",
|
|
41
|
+
"0.1.7-rc.1": "compatible",
|
|
42
|
+
"0.1.7-rc.2": "compatible",
|
|
43
|
+
"0.2.0-rc.1": "compatible",
|
|
44
|
+
"0.2.0-rc.2": "compatible"
|
|
45
|
+
}
|
|
32
46
|
}
|
|
33
47
|
},
|
|
34
48
|
"scripts": {
|
|
35
49
|
"typecheck": "tsc -p tsconfig.json && tsc -p tsconfig.client.json",
|
|
36
50
|
"test": "vitest run",
|
|
37
|
-
"build": "tsdown -c tsdown.config.ts"
|
|
51
|
+
"build": "tsdown -c tsdown.config.ts",
|
|
52
|
+
"prepack": "npm run build"
|
|
38
53
|
},
|
|
39
54
|
"dependencies": {
|
|
40
55
|
"@deepseek-ai/schemastery": "^3.18.4"
|
|
41
56
|
},
|
|
42
57
|
"peerDependencies": {
|
|
43
|
-
"@deepseek-ai/dsh-client-locale": ">=0.
|
|
44
|
-
"@deepseek-ai/dsh-client-store": ">=0.
|
|
45
|
-
"@deepseek-ai/dsh-client-ui-settings-plugins": ">=0.
|
|
46
|
-
"@deepseek-ai/dsh-client-ui-slots": ">=0.
|
|
47
|
-
"@deepseek-ai/dsh-settings": ">=0.
|
|
48
|
-
"@deepseek-ai/dsh-tools": ">=0.
|
|
58
|
+
"@deepseek-ai/dsh-client-locale": ">=0.1.0-0 <0.3.0-0",
|
|
59
|
+
"@deepseek-ai/dsh-client-store": ">=0.1.0-0 <0.3.0-0",
|
|
60
|
+
"@deepseek-ai/dsh-client-ui-settings-plugins": ">=0.1.0-0 <0.3.0-0",
|
|
61
|
+
"@deepseek-ai/dsh-client-ui-slots": ">=0.1.0-0 <0.3.0-0",
|
|
62
|
+
"@deepseek-ai/dsh-settings": ">=0.1.0-0 <0.3.0-0",
|
|
63
|
+
"@deepseek-ai/dsh-tools": ">=0.1.0-0 <0.3.0-0",
|
|
49
64
|
"react": "^18.2.0"
|
|
50
65
|
},
|
|
51
66
|
"peerDependenciesMeta": {
|
|
@@ -66,9 +81,6 @@
|
|
|
66
81
|
},
|
|
67
82
|
"@deepseek-ai/dsh-tools": {
|
|
68
83
|
"optional": true
|
|
69
|
-
},
|
|
70
|
-
"react": {
|
|
71
|
-
"optional": true
|
|
72
84
|
}
|
|
73
85
|
},
|
|
74
86
|
"devDependencies": {
|
|
@@ -86,7 +98,7 @@
|
|
|
86
98
|
},
|
|
87
99
|
"engines": {
|
|
88
100
|
"node": ">=22",
|
|
89
|
-
"dsh": ">=0.
|
|
101
|
+
"dsh": ">=0.1.0-0 <0.3.0-0"
|
|
90
102
|
},
|
|
91
103
|
"license": "MIT",
|
|
92
104
|
"repository": {
|
|
@@ -94,6 +106,6 @@
|
|
|
94
106
|
"url": "git+https://github.com/drscrewdriver/dsh-browser-cdp.git"
|
|
95
107
|
},
|
|
96
108
|
"publishConfig": {
|
|
97
|
-
"tag": "dsh-
|
|
109
|
+
"tag": "dsh-1.1.0"
|
|
98
110
|
}
|
|
99
111
|
}
|