@hmharness/cli 0.23.7 → 0.23.8
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/dist/main.js +15 -2
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -1013,7 +1013,7 @@ flags:
|
|
|
1013
1013
|
await mkdir(scratch, { recursive: true });
|
|
1014
1014
|
try {
|
|
1015
1015
|
const { runExploration } = await import('@hmharness/cognitive');
|
|
1016
|
-
const { TerminalEnvironment, HarmonyOsEnvironment, Arc3Environment, Arc3RestBridge } = await import('@hmharness/environments');
|
|
1016
|
+
const { TerminalEnvironment, HarmonyOsEnvironment, Arc3Environment, Arc3RestBridge, BrowserEnvironment, CdpActBridge } = await import('@hmharness/environments');
|
|
1017
1017
|
let env;
|
|
1018
1018
|
if (envId === 'harmonyos')
|
|
1019
1019
|
env = new HarmonyOsEnvironment({ timeoutMs: 20_000 });
|
|
@@ -1021,8 +1021,21 @@ flags:
|
|
|
1021
1021
|
env = new Arc3Environment({ bridge: new Arc3RestBridge() });
|
|
1022
1022
|
else if (envId === 'terminal')
|
|
1023
1023
|
env = new TerminalEnvironment({ workspaceDir: scratch, timeoutMs: 15_000 });
|
|
1024
|
+
else if (envId === 'browser') {
|
|
1025
|
+
// CDP-native act bridge — explore an OWNED debug browser, never the
|
|
1026
|
+
// user's default one. Launch e.g.:
|
|
1027
|
+
// chrome --headless=new --remote-debugging-port=9222 --user-data-dir=<tmp> about:blank
|
|
1028
|
+
const cdpBase = rest.find((a) => a.startsWith('--cdp='))?.slice(6) ?? 'http://127.0.0.1:9222';
|
|
1029
|
+
const bridge = new CdpActBridge({ cdpBase });
|
|
1030
|
+
if (!(await bridge.up())) {
|
|
1031
|
+
stdout.write(`环境 browser 需要可达的 CDP 调试浏览器(${cdpBase})。\n`);
|
|
1032
|
+
stdout.write(DIM(' 启动示例: chrome --headless=new --remote-debugging-port=9222 --user-data-dir=<临时目录> about:blank\n'));
|
|
1033
|
+
return;
|
|
1034
|
+
}
|
|
1035
|
+
env = new BrowserEnvironment({ cdpBase, act: (a, tabId) => bridge.act(a, tabId) });
|
|
1036
|
+
}
|
|
1024
1037
|
if (!env) {
|
|
1025
|
-
stdout.write(`环境 '${envId}' 暂不支持 headless 探索(terminal | harmonyos | arc3)\n`);
|
|
1038
|
+
stdout.write(`环境 '${envId}' 暂不支持 headless 探索(terminal | harmonyos | arc3 | browser)\n`);
|
|
1026
1039
|
return;
|
|
1027
1040
|
}
|
|
1028
1041
|
const summary = await runExploration(home, {
|
package/package.json
CHANGED