@copylee/dsh-computer-use 0.7.5 → 0.7.7
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/README.md +8 -0
- package/helper/host.ps1 +10 -0
- package/lib/index.js +42 -1
- package/lib/types/helper-client.d.ts +3 -0
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -6,6 +6,14 @@
|
|
|
6
6
|
|
|
7
7
|
仅支持 Windows。
|
|
8
8
|
|
|
9
|
+

|
|
10
|
+
|
|
11
|
+
上图是一次真实操作的录屏(只录了被操控的记事本窗口):AI 打开记事本并逐行输入文字。下图是对话里看到的过程,以及设置页。
|
|
12
|
+
|
|
13
|
+
| 对话中的操作过程 | 设置页 |
|
|
14
|
+
|---|---|
|
|
15
|
+
|  |  |
|
|
16
|
+
|
|
9
17
|
## 功能
|
|
10
18
|
|
|
11
19
|
| 功能 | 说明 |
|
package/helper/host.ps1
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# Runs the compiled helper inside the signed powershell.exe, for machines where
|
|
2
|
+
# Smart App Control (or another code-integrity policy) refuses to start the
|
|
3
|
+
# unsigned cu-helper.exe. Loading the assembly from bytes maps no executable
|
|
4
|
+
# image, so the policy has nothing to check. stdin / stdout stay the helper's
|
|
5
|
+
# JSON pipes: nothing here may write to stdout.
|
|
6
|
+
param([Parameter(Mandatory = $true)][string]$HelperExe)
|
|
7
|
+
$ErrorActionPreference = 'Stop'
|
|
8
|
+
$assembly = [Reflection.Assembly]::Load([IO.File]::ReadAllBytes($HelperExe))
|
|
9
|
+
$code = $assembly.EntryPoint.Invoke($null, [object[]]@(, [string[]]@()))
|
|
10
|
+
exit [int]$code
|
package/lib/index.js
CHANGED
|
@@ -1403,6 +1403,24 @@ async function ensureHelperExe(source = helperSourcePath()) {
|
|
|
1403
1403
|
throw error;
|
|
1404
1404
|
}
|
|
1405
1405
|
}
|
|
1406
|
+
/**
|
|
1407
|
+
* Set once the unsigned exe has been refused: Smart App Control blocks it with
|
|
1408
|
+
* ERROR_ACCESS_DISABLED_BY_POLICY, which libuv reports as UNKNOWN. From then on
|
|
1409
|
+
* the same assembly runs inside the signed powershell.exe (helper/host.ps1).
|
|
1410
|
+
*/
|
|
1411
|
+
let hostedHelper = false;
|
|
1412
|
+
const POLICY_CODES = /* @__PURE__ */ new Set([
|
|
1413
|
+
"UNKNOWN",
|
|
1414
|
+
"EACCES",
|
|
1415
|
+
"EPERM"
|
|
1416
|
+
]);
|
|
1417
|
+
function isPolicyBlock(error) {
|
|
1418
|
+
return POLICY_CODES.has(String(error?.code)) && error.syscall?.startsWith("spawn") === true;
|
|
1419
|
+
}
|
|
1420
|
+
function powershellPath() {
|
|
1421
|
+
const windir = process.env.SystemRoot ?? process.env.windir ?? "C:\\Windows";
|
|
1422
|
+
return join(windir, "System32", "WindowsPowerShell", "v1.0", "powershell.exe");
|
|
1423
|
+
}
|
|
1406
1424
|
var HelperClient = class {
|
|
1407
1425
|
log;
|
|
1408
1426
|
child;
|
|
@@ -1469,7 +1487,30 @@ var HelperClient = class {
|
|
|
1469
1487
|
}
|
|
1470
1488
|
async start() {
|
|
1471
1489
|
const exe = await ensureHelperExe();
|
|
1472
|
-
|
|
1490
|
+
if (!hostedHelper) try {
|
|
1491
|
+
return await this.launch(exe, []);
|
|
1492
|
+
} catch (error) {
|
|
1493
|
+
if (!isPolicyBlock(error)) throw error;
|
|
1494
|
+
this.log(`starting cu-helper.exe was refused (${error.code ?? "unknown"}); running it inside powershell.exe instead`);
|
|
1495
|
+
hostedHelper = true;
|
|
1496
|
+
}
|
|
1497
|
+
try {
|
|
1498
|
+
return await this.launch(powershellPath(), [
|
|
1499
|
+
"-NoProfile",
|
|
1500
|
+
"-NonInteractive",
|
|
1501
|
+
"-STA",
|
|
1502
|
+
"-ExecutionPolicy",
|
|
1503
|
+
"Bypass",
|
|
1504
|
+
"-File",
|
|
1505
|
+
helperAssetPath("host.ps1"),
|
|
1506
|
+
exe
|
|
1507
|
+
]);
|
|
1508
|
+
} catch (error) {
|
|
1509
|
+
throw new Error(`The computer-use helper could not be started (${error instanceof Error ? error.message : String(error)}). Windows refused to run the helper this plugin compiles (cu-helper.exe), and running it inside powershell.exe failed too. Smart App Control or another application control policy is the usual cause: see Event Viewer > Applications and Services Logs > Microsoft > Windows > CodeIntegrity > Operational.`);
|
|
1510
|
+
}
|
|
1511
|
+
}
|
|
1512
|
+
async launch(command, args) {
|
|
1513
|
+
const child = spawn(command, args, {
|
|
1473
1514
|
stdio: [
|
|
1474
1515
|
"pipe",
|
|
1475
1516
|
"pipe",
|
|
@@ -12,6 +12,8 @@ export declare function helperAssetPath(name: string): string;
|
|
|
12
12
|
export declare function helperSourcePath(): string;
|
|
13
13
|
/** Compile the helper if this source version has no cached exe yet; returns the exe path. */
|
|
14
14
|
export declare function ensureHelperExe(source?: string): Promise<string>;
|
|
15
|
+
/** For the smoke script: run the helper inside powershell.exe from the start. */
|
|
16
|
+
export declare function useHostedHelper(on?: boolean): void;
|
|
15
17
|
export declare class HelperClient implements HelperLike {
|
|
16
18
|
private readonly log;
|
|
17
19
|
private child;
|
|
@@ -27,5 +29,6 @@ export declare class HelperClient implements HelperLike {
|
|
|
27
29
|
private kill;
|
|
28
30
|
private ensure;
|
|
29
31
|
private start;
|
|
32
|
+
private launch;
|
|
30
33
|
private handle;
|
|
31
34
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@copylee/dsh-computer-use",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.7",
|
|
4
4
|
"description": "DeepSeek Harness Computer Use 插件(Windows):让 AI 看屏幕、点鼠标、敲键盘操控电脑;控制时屏幕泛起橙色光晕并显示“DeepSeek Harness 正在操控你的电脑”,按 Esc 暂停 / 继续。",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": "copylee",
|
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
"lib/client.js",
|
|
31
31
|
"lib/types/**/*.d.ts",
|
|
32
32
|
"helper/CuHelper.cs",
|
|
33
|
+
"helper/host.ps1",
|
|
33
34
|
"helper/deepseek-white.png",
|
|
34
35
|
"helper/deepseek-black.png",
|
|
35
36
|
"helper/skills/*.md",
|