@copylee/dsh-computer-use 0.2.1 → 0.2.2
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 +2 -1
- package/helper/CuHelper.cs +31 -7
- package/lib/client.js +28 -2
- package/lib/index.js +130 -8
- package/lib/types/computer.d.ts +12 -0
- package/lib/types/index.d.ts +2 -0
- package/lib/types/text.d.ts +12 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
| 悬浮卡片 | 操控期间 DeepSeek Harness 窗口缩成右下角置顶卡片,结束后自动恢复原尺寸、位置和最大化 / 最小化状态(也可选最小化或不动)。卡片只给你看:AI 的截图里看到的是卡片下面的内容(通过 Windows 放大镜接口截图时把卡片排除在外,不闪烁;该接口不可用时退回为截图瞬间让卡片透明约 20 毫秒),点击和滚动也直接穿透卡片,卡片不会挪位置 |
|
|
16
16
|
| 暂停与停止 | 你亲手按 **Esc** 暂停(AI 停在下一步之前),再按 Esc 或点“继续”恢复,对话不会被中断;点“停止”才结束本轮。插件自己发出的 Esc 不会误触发 |
|
|
17
17
|
| 你随时可以插手 | 你用键盘打字时 AI 自动暂停,停手 1.5 秒后继续(单按 Shift / Ctrl 等修饰键不算);你切换或打开了别的窗口,AI 下一步不会盲目执行,而是先看新截图再决定。你只是点进 DSH 卡片看对话时不算切换,AI 的按键会自动回到它正在操作的窗口。鼠标移动不会触发,避免误触 |
|
|
18
|
-
|
|
|
18
|
+
| 文字输入 | Unicode 直接输入,不受输入法状态影响。短文字逐字打出来;长文本默认“流式”:按段落逐段粘贴(代码块不拆开),看得到一段段出现,又不会被 Typora、Obsidian、Word 的自动补全打乱。可在设置里改成逐字输入或一次粘贴。剪贴板文本统一为 CRLF,不丢换行 |
|
|
19
19
|
| 不弄乱剪贴板 | 插件写入剪贴板的内容不进 Windows 剪贴板历史(Win+V)和云剪贴板;粘贴后按原样恢复你的剪贴板(图片、文件也保留);AI 用 `clipboard` 工具写过剪贴板的,本轮结束后自动还原(期间你自己复制了新内容则不动) |
|
|
20
20
|
| 打开应用 | `open_application` 同时搜索开始菜单和桌面快捷方式(含公共桌面),便携软件也能按名字打开 |
|
|
21
21
|
| 看不见图的模型 | `ui_elements` 用 Windows UI Automation 列出可点击元素和坐标,纯文本模型也能用 |
|
|
@@ -74,6 +74,7 @@ dsh plugin --profile web add @copylee/dsh-computer-use@latest
|
|
|
74
74
|
| 等待稳定 | 400 ms | 动作后至少等这么久,之后画面静止即截图(最多约 2.5 秒) |
|
|
75
75
|
| 截图最长边 / 总像素 / JPEG 质量 | 1366 / 1.15MP / 70 | 越大越清晰、越费 token |
|
|
76
76
|
| 检测到你在操作时让出控制 | 开 | 键盘输入暂停、窗口被切换时重新看屏幕 |
|
|
77
|
+
| 文字输入方式 | 流式 | 流式(长文本逐段出现)/ 逐字输入(最像打字,最慢)/ 一次粘贴(最快) |
|
|
77
78
|
| 键盘静止多久后恢复 | 1500 ms | |
|
|
78
79
|
| 禁止操控的应用 | 空 | 名称或 exe,如 `alipay` |
|
|
79
80
|
|
package/helper/CuHelper.cs
CHANGED
|
@@ -266,8 +266,10 @@ namespace DshComputerUse
|
|
|
266
266
|
case "scroll": using (new PassThrough()) return Input.Scroll(r);
|
|
267
267
|
case "keys": return Input.Keys(r);
|
|
268
268
|
case "key_state": return Input.KeyState(r);
|
|
269
|
-
case "type": return Input.Type(Args.Str(r, "text", ""), Args.Int(r, "chunkDelay", 8));
|
|
270
|
-
case "
|
|
269
|
+
case "type": return Input.Type(Args.Str(r, "text", ""), Args.Int(r, "chunkDelay", 8), Args.Int(r, "charDelay", 0));
|
|
270
|
+
case "clipboard_hold": Clip.Hold(); return null;
|
|
271
|
+
case "clipboard_release": Clip.Release(); return null;
|
|
272
|
+
case "paste": return Input.Paste(Args.Str(r, "text", ""), Args.Bool(r, "restore", true), Args.Int(r, "waitMs", 250));
|
|
271
273
|
case "windows": return Windows.List();
|
|
272
274
|
case "foreground": return Windows.Describe(Native.GetForegroundWindow());
|
|
273
275
|
case "window_at": return Windows.At(Args.Int(r, "x", 0), Args.Int(r, "y", 0));
|
|
@@ -660,10 +662,12 @@ namespace DshComputerUse
|
|
|
660
662
|
return null;
|
|
661
663
|
}
|
|
662
664
|
|
|
663
|
-
|
|
665
|
+
/** charDelay > 0: one character at a time, like a person typing; otherwise fast batches. */
|
|
666
|
+
public static object Type(string text, int chunkDelay, int charDelay)
|
|
664
667
|
{
|
|
665
668
|
var batch = new List<Native.INPUT>();
|
|
666
|
-
|
|
669
|
+
int pause = charDelay > 0 ? charDelay : chunkDelay;
|
|
670
|
+
Action flush = delegate { if (batch.Count == 0) return; Send(batch); batch.Clear(); if (pause > 0) Thread.Sleep(pause); };
|
|
667
671
|
for (int i = 0; i < text.Length; i++)
|
|
668
672
|
{
|
|
669
673
|
char c = text[i];
|
|
@@ -671,13 +675,14 @@ namespace DshComputerUse
|
|
|
671
675
|
if (c == '\n') { flush(); batch.Add(Key(0x0D, false)); batch.Add(Key(0x0D, true)); flush(); continue; }
|
|
672
676
|
if (c == '\t') { batch.Add(Key(0x09, false)); batch.Add(Key(0x09, true)); continue; }
|
|
673
677
|
batch.Add(Unicode(c, false)); batch.Add(Unicode(c, true));
|
|
674
|
-
if (
|
|
678
|
+
if (char.IsHighSurrogate(c)) continue;
|
|
679
|
+
if (charDelay > 0 || batch.Count >= 40) flush();
|
|
675
680
|
}
|
|
676
681
|
flush();
|
|
677
682
|
return null;
|
|
678
683
|
}
|
|
679
684
|
|
|
680
|
-
public static object Paste(string text, bool restore)
|
|
685
|
+
public static object Paste(string text, bool restore, int waitMs)
|
|
681
686
|
{
|
|
682
687
|
// Keep every format the user had (images, files, rich text), not just text.
|
|
683
688
|
DataObject previous = null;
|
|
@@ -687,7 +692,7 @@ namespace DshComputerUse
|
|
|
687
692
|
Send(new List<Native.INPUT> { Key(0x11, false), Key(0x56, false) });
|
|
688
693
|
Thread.Sleep(30);
|
|
689
694
|
Send(new List<Native.INPUT> { Key(0x56, true), Key(0x11, true) });
|
|
690
|
-
Thread.Sleep(
|
|
695
|
+
Thread.Sleep(Math.Max(60, waitMs)); // the app reads the clipboard asynchronously
|
|
691
696
|
if (restore) { try { Clip.Put(previous); } catch (Exception) { } }
|
|
692
697
|
return null;
|
|
693
698
|
}
|
|
@@ -764,6 +769,25 @@ namespace DshComputerUse
|
|
|
764
769
|
throw new Exception("clipboard is busy");
|
|
765
770
|
}
|
|
766
771
|
|
|
772
|
+
/** The user's clipboard, kept aside while a streamed paste runs. */
|
|
773
|
+
static DataObject held;
|
|
774
|
+
static bool holding;
|
|
775
|
+
|
|
776
|
+
public static void Hold()
|
|
777
|
+
{
|
|
778
|
+
if (holding) return;
|
|
779
|
+
held = Snapshot();
|
|
780
|
+
holding = true;
|
|
781
|
+
}
|
|
782
|
+
|
|
783
|
+
public static void Release()
|
|
784
|
+
{
|
|
785
|
+
if (!holding) return;
|
|
786
|
+
var data = held;
|
|
787
|
+
held = null; holding = false;
|
|
788
|
+
Put(data);
|
|
789
|
+
}
|
|
790
|
+
|
|
767
791
|
public static void Set(string text, bool isPrivate)
|
|
768
792
|
{
|
|
769
793
|
text = Normalize(text);
|
package/lib/client.js
CHANGED
|
@@ -43,7 +43,8 @@ window.__ModuleLoader__.load({
|
|
|
43
43
|
jpegQuality: 70,
|
|
44
44
|
blockedApps: [],
|
|
45
45
|
pauseOnUserInput: true,
|
|
46
|
-
userIdleMs: 1500
|
|
46
|
+
userIdleMs: 1500,
|
|
47
|
+
typingMode: "stream"
|
|
47
48
|
};
|
|
48
49
|
/** Unwrap `.volatile()` refs (`{ get() }`) and fall back to defaults for bad values. */
|
|
49
50
|
function resolveConfig(raw) {
|
|
@@ -66,6 +67,7 @@ window.__ModuleLoader__.load({
|
|
|
66
67
|
jpegQuality: num("jpegQuality", 30, 100),
|
|
67
68
|
pauseOnUserInput: bool("pauseOnUserInput"),
|
|
68
69
|
userIdleMs: num("userIdleMs", 300, 1e4),
|
|
70
|
+
typingMode: out.typingMode === "stream" || out.typingMode === "type" || out.typingMode === "paste" ? out.typingMode : DEFAULTS.typingMode,
|
|
69
71
|
blockedApps: Array.isArray(out.blockedApps) ? out.blockedApps.filter((item) => typeof item === "string" && item.trim() !== "") : []
|
|
70
72
|
};
|
|
71
73
|
}
|
|
@@ -316,6 +318,7 @@ window.__ModuleLoader__.load({
|
|
|
316
318
|
overlay: s.overlay,
|
|
317
319
|
overlayLabel: s.overlayLabel,
|
|
318
320
|
hostWindow: s.hostWindow,
|
|
321
|
+
typingMode: s.typingMode,
|
|
319
322
|
pauseOnUserInput: s.pauseOnUserInput,
|
|
320
323
|
userIdleMs: String(s.userIdleMs),
|
|
321
324
|
autoScreenshot: s.autoScreenshot,
|
|
@@ -346,6 +349,7 @@ window.__ModuleLoader__.load({
|
|
|
346
349
|
overlay: d.overlay,
|
|
347
350
|
overlayLabel: d.overlayLabel.trim() || DEFAULTS.overlayLabel,
|
|
348
351
|
hostWindow: d.hostWindow,
|
|
352
|
+
typingMode: d.typingMode,
|
|
349
353
|
pauseOnUserInput: d.pauseOnUserInput,
|
|
350
354
|
userIdleMs: Math.round(Number(d.userIdleMs)),
|
|
351
355
|
autoScreenshot: d.autoScreenshot,
|
|
@@ -761,7 +765,29 @@ window.__ModuleLoader__.load({
|
|
|
761
765
|
}), h("span", { style: {
|
|
762
766
|
...S.hint,
|
|
763
767
|
fontWeight: 400
|
|
764
|
-
} }, "操控结束后自动恢复原尺寸和位置。"))
|
|
768
|
+
} }, "操控结束后自动恢复原尺寸和位置。")), h("div", { style: S.label }, "文字输入方式", h(Select, {
|
|
769
|
+
label: "文字输入方式",
|
|
770
|
+
disabled,
|
|
771
|
+
value: draft.typingMode,
|
|
772
|
+
options: [
|
|
773
|
+
{
|
|
774
|
+
value: "stream",
|
|
775
|
+
label: "流式:长文本逐段出现(推荐)"
|
|
776
|
+
},
|
|
777
|
+
{
|
|
778
|
+
value: "type",
|
|
779
|
+
label: "逐字输入:像人打字,最慢"
|
|
780
|
+
},
|
|
781
|
+
{
|
|
782
|
+
value: "paste",
|
|
783
|
+
label: "一次粘贴:最快"
|
|
784
|
+
}
|
|
785
|
+
],
|
|
786
|
+
onChange: (value) => edit("typingMode", value)
|
|
787
|
+
}), h("span", { style: {
|
|
788
|
+
...S.hint,
|
|
789
|
+
fontWeight: 400
|
|
790
|
+
} }, "短文字都会逐字打出来。长文本逐字输入在 Typora、Obsidian、Word 等编辑器里可能被自动补全括号、自动续列表打乱;流式按段落粘贴,既看得到过程又不会乱。")))), h("section", { style: S.card }, h("h3", { style: S.cardTitle }, "让出控制"), h(ToggleRow, {
|
|
765
791
|
title: "检测到你在操作时暂停",
|
|
766
792
|
hint: "你用键盘打字时 AI 等你停手;你切换了窗口时 AI 先重新看屏幕。鼠标移动不会触发。",
|
|
767
793
|
checked: draft.pauseOnUserInput,
|
package/lib/index.js
CHANGED
|
@@ -445,12 +445,67 @@ function parseModifiers(text) {
|
|
|
445
445
|
return parseKeys(text.replace(/\s+/g, "")).flat();
|
|
446
446
|
}
|
|
447
447
|
//#endregion
|
|
448
|
+
//#region lib/types/text.js
|
|
449
|
+
/**
|
|
450
|
+
* Split text for streamed entry: paste block by block so the user watches it
|
|
451
|
+
* appear, while each block still goes in literally (typing Markdown key by key
|
|
452
|
+
* into Typora / Obsidian / Word trips their auto-formatting).
|
|
453
|
+
*
|
|
454
|
+
* Blocks end after a blank-line separator, never inside a ``` / ~~~ fence and
|
|
455
|
+
* never inside a paragraph (a half-pasted **bold** or link may not re-render).
|
|
456
|
+
* Joining the blocks gives back the original text exactly.
|
|
457
|
+
*/
|
|
458
|
+
function splitBlocks(text, minChars = 80) {
|
|
459
|
+
const lines = text.split(/(?<=\n)/);
|
|
460
|
+
const blocks = [];
|
|
461
|
+
let current = "";
|
|
462
|
+
let fence;
|
|
463
|
+
let previousBlank = false;
|
|
464
|
+
for (const line of lines) {
|
|
465
|
+
const bare = line.replace(/\r?\n$/, "");
|
|
466
|
+
const marker = /^\s*(```+|~~~+)/.exec(bare)?.[1];
|
|
467
|
+
if (marker !== void 0) {
|
|
468
|
+
if (fence === void 0) fence = marker[0].repeat(marker.length);
|
|
469
|
+
else if (marker.startsWith(fence)) fence = void 0;
|
|
470
|
+
}
|
|
471
|
+
const blank = bare.trim() === "";
|
|
472
|
+
if (fence === void 0 && !blank && previousBlank && current.length >= minChars) {
|
|
473
|
+
blocks.push(current);
|
|
474
|
+
current = "";
|
|
475
|
+
}
|
|
476
|
+
current += line;
|
|
477
|
+
if (marker === void 0 || fence !== void 0) previousBlank = blank && fence === void 0;
|
|
478
|
+
else previousBlank = false;
|
|
479
|
+
}
|
|
480
|
+
if (current !== "") blocks.push(current);
|
|
481
|
+
return blocks;
|
|
482
|
+
}
|
|
483
|
+
/** Pieces of at most ~`size` characters, broken after whitespace where possible (for paced typing). */
|
|
484
|
+
function typingPieces(text, size = 60) {
|
|
485
|
+
const out = [];
|
|
486
|
+
let rest = text;
|
|
487
|
+
while (rest.length > size) {
|
|
488
|
+
let cut = Math.max(rest.lastIndexOf(" ", size), rest.lastIndexOf("\n", size));
|
|
489
|
+
if (cut < size / 2) cut = size;
|
|
490
|
+
else cut += 1;
|
|
491
|
+
if (/[\uD800-\uDBFF]/.test(rest[cut - 1] ?? "")) cut += 1;
|
|
492
|
+
out.push(rest.slice(0, cut));
|
|
493
|
+
rest = rest.slice(cut);
|
|
494
|
+
}
|
|
495
|
+
if (rest !== "") out.push(rest);
|
|
496
|
+
return out;
|
|
497
|
+
}
|
|
498
|
+
//#endregion
|
|
448
499
|
//#region lib/types/computer.js
|
|
449
500
|
/**
|
|
450
501
|
* The computer-use engine behind the tools: one coordinate space (the latest
|
|
451
502
|
* screenshot of the current display), access checks against the window that
|
|
452
503
|
* will receive the input, overlay status, and post-action screenshots.
|
|
453
504
|
*/
|
|
505
|
+
/** Visible typing pace (ms per character). */
|
|
506
|
+
const CHAR_DELAY_MS = 12;
|
|
507
|
+
/** Text longer than this is pasted (stream / paste modes). */
|
|
508
|
+
const PASTE_OVER = 200;
|
|
454
509
|
const ACTIONS = [
|
|
455
510
|
"screenshot",
|
|
456
511
|
"left_click",
|
|
@@ -853,12 +908,7 @@ var Computer = class Computer {
|
|
|
853
908
|
const text = input.text ?? "";
|
|
854
909
|
if (text === "") throw new Error("type needs text.");
|
|
855
910
|
await this.checkKeyboard(call, "type into");
|
|
856
|
-
|
|
857
|
-
text,
|
|
858
|
-
restore: true
|
|
859
|
-
});
|
|
860
|
-
else await this.helper.call("type", { text }, 6e4);
|
|
861
|
-
return { text: `Typed ${text.length} characters.` };
|
|
911
|
+
return { text: await this.enterText(text, call) };
|
|
862
912
|
}
|
|
863
913
|
case "key": {
|
|
864
914
|
const combos = parseKeys(input.text ?? "");
|
|
@@ -878,6 +928,59 @@ var Computer = class Computer {
|
|
|
878
928
|
}
|
|
879
929
|
}
|
|
880
930
|
}
|
|
931
|
+
/**
|
|
932
|
+
* Enter text the way the settings ask. Long text is pasted (literally: typing
|
|
933
|
+
* Markdown key by key trips editors' auto-formatting); in stream mode block
|
|
934
|
+
* by block so the user watches it appear. Between pieces the user can pause
|
|
935
|
+
* (Esc / typing); if another window comes to the front meanwhile, stop.
|
|
936
|
+
*/
|
|
937
|
+
async enterText(text, call) {
|
|
938
|
+
const mode = this.settings().typingMode;
|
|
939
|
+
if (mode === "paste" && text.length > PASTE_OVER) {
|
|
940
|
+
await this.helper.call("paste", {
|
|
941
|
+
text,
|
|
942
|
+
restore: true
|
|
943
|
+
});
|
|
944
|
+
return `Typed ${text.length} characters (pasted).`;
|
|
945
|
+
}
|
|
946
|
+
if (mode === "stream" && text.length > PASTE_OVER) {
|
|
947
|
+
const blocks = splitBlocks(text);
|
|
948
|
+
await this.helper.call("clipboard_hold");
|
|
949
|
+
try {
|
|
950
|
+
await this.pieces(blocks, call, async (block, i) => {
|
|
951
|
+
await this.overlay.status(`输入中 ${i + 1}/${blocks.length}`);
|
|
952
|
+
await this.helper.call("paste", {
|
|
953
|
+
text: block,
|
|
954
|
+
restore: false,
|
|
955
|
+
waitMs: 220
|
|
956
|
+
});
|
|
957
|
+
});
|
|
958
|
+
} finally {
|
|
959
|
+
await this.helper.call("clipboard_release").catch(() => {});
|
|
960
|
+
}
|
|
961
|
+
return `Typed ${text.length} characters (streamed in ${blocks.length} blocks).`;
|
|
962
|
+
}
|
|
963
|
+
const delay = mode === "paste" ? 0 : CHAR_DELAY_MS;
|
|
964
|
+
await this.pieces(typingPieces(text), call, (part) => this.helper.call("type", {
|
|
965
|
+
text: part,
|
|
966
|
+
charDelay: delay
|
|
967
|
+
}, 12e4).then(() => {}));
|
|
968
|
+
return `Typed ${text.length} characters.`;
|
|
969
|
+
}
|
|
970
|
+
/** Run `step` per piece; between pieces yield to the user and make sure the target window is still in front. */
|
|
971
|
+
async pieces(items, call, step) {
|
|
972
|
+
const target = await this.foreground().catch(() => void 0);
|
|
973
|
+
let done = 0;
|
|
974
|
+
for (const [index, item] of items.entries()) {
|
|
975
|
+
if (call.signal.aborted) throw new Error("Cancelled.");
|
|
976
|
+
if (index > 0 && await this.overlay.yieldToUser(call.signal, this.settings().pauseOnUserInput)) {
|
|
977
|
+
const now = await this.foreground().catch(() => void 0);
|
|
978
|
+
if (target && now && now.hwnd !== target.hwnd) throw new Error(`Stopped after ${done} of ${items.join("").length} characters: the user paused and ${now.exe} is now in front. Check the screen and continue from where the text stops.`);
|
|
979
|
+
}
|
|
980
|
+
await step(item, index);
|
|
981
|
+
done += item.length;
|
|
982
|
+
}
|
|
983
|
+
}
|
|
881
984
|
/** Release a mouse button left down by an aborted run. */
|
|
882
985
|
async releaseHeld() {
|
|
883
986
|
if (!this.heldButton) return;
|
|
@@ -1335,7 +1438,7 @@ ${mode === "per-app" ? "- Before acting on an app, call request_access once with
|
|
|
1335
1438
|
- If the target window is small or partly covered by other windows, maximize it (windows maximize) or minimize what is in the way (windows minimize works for any window) instead of working around it.
|
|
1336
1439
|
- Prefer reliable keyboard shortcuts (ctrl+l for a browser address bar, ctrl+s, alt+F4, ctrl+t). Click the center of targets. When text is too small to read, zoom once on a generous region that contains everything you need (zooming step by step wastes calls).
|
|
1337
1440
|
- Actions return a fresh screenshot taken once the screen stops changing (page loads included, up to a few seconds), so you rarely need wait. If something is still loading, use wait: it also returns a screenshot, so never follow it with a separate screenshot call.
|
|
1338
|
-
-
|
|
1441
|
+
- When the user asks you to write something in an app, enter it there with type, even long or multi-line Markdown: the user watches it appear (long text is streamed in paragraph by paragraph, literally, without the editor's auto-formatting getting in the way). Do not write the file from a shell and reopen it instead, and do not put text on the clipboard with shell commands (Set-Clipboard, clip): that clutters the user's clipboard history.
|
|
1339
1442
|
- Office apps: F12 opens the classic Save As dialog, where you can type a full path in the file name box.
|
|
1340
1443
|
- Be efficient: every tool call costs the user several seconds. Put predictable sequences (click a field, type, press Return; open a menu and pick an item you can already see) into one computer_batch. Avoid shell commands for things you can see on screen.
|
|
1341
1444
|
- To see more of a page or list, scroll (action "scroll" with coordinate over the area, scroll_direction, scroll_amount 5-10) instead of hunting with zoom; for long web pages Page Down / End keys also work.
|
|
@@ -1359,7 +1462,8 @@ const DEFAULTS = {
|
|
|
1359
1462
|
jpegQuality: 70,
|
|
1360
1463
|
blockedApps: [],
|
|
1361
1464
|
pauseOnUserInput: true,
|
|
1362
|
-
userIdleMs: 1500
|
|
1465
|
+
userIdleMs: 1500,
|
|
1466
|
+
typingMode: "stream"
|
|
1363
1467
|
};
|
|
1364
1468
|
/** Unwrap `.volatile()` refs (`{ get() }`) and fall back to defaults for bad values. */
|
|
1365
1469
|
function resolveConfig(raw) {
|
|
@@ -1382,6 +1486,7 @@ function resolveConfig(raw) {
|
|
|
1382
1486
|
jpegQuality: num("jpegQuality", 30, 100),
|
|
1383
1487
|
pauseOnUserInput: bool("pauseOnUserInput"),
|
|
1384
1488
|
userIdleMs: num("userIdleMs", 300, 1e4),
|
|
1489
|
+
typingMode: out.typingMode === "stream" || out.typingMode === "type" || out.typingMode === "paste" ? out.typingMode : DEFAULTS.typingMode,
|
|
1385
1490
|
blockedApps: Array.isArray(out.blockedApps) ? out.blockedApps.filter((item) => typeof item === "string" && item.trim() !== "") : []
|
|
1386
1491
|
};
|
|
1387
1492
|
}
|
|
@@ -7838,6 +7943,23 @@ const Config = z.object({
|
|
|
7838
7943
|
"zh-CN": { $description: "操控期间 DeepSeek Harness 窗口怎么摆放(结束后自动恢复原尺寸和位置)" },
|
|
7839
7944
|
"en-US": { $description: "What to do with the DeepSeek Harness window while controlling (restored afterwards)" }
|
|
7840
7945
|
}),
|
|
7946
|
+
typingMode: z.union([
|
|
7947
|
+
z.const("stream").i18n({
|
|
7948
|
+
"zh-CN": { $description: "流式:长文本按段落逐段粘贴,看得到一段段出现(推荐)" },
|
|
7949
|
+
"en-US": { $description: "Stream: paste long text paragraph by paragraph (recommended)" }
|
|
7950
|
+
}),
|
|
7951
|
+
z.const("type").i18n({
|
|
7952
|
+
"zh-CN": { $description: "逐字输入:像人打字,慢;Markdown 编辑器里可能被自动格式化打乱" },
|
|
7953
|
+
"en-US": { $description: "Type key by key: like a person, slow; Markdown editors may auto-format it" }
|
|
7954
|
+
}),
|
|
7955
|
+
z.const("paste").i18n({
|
|
7956
|
+
"zh-CN": { $description: "一次粘贴:最快" },
|
|
7957
|
+
"en-US": { $description: "Paste at once: fastest" }
|
|
7958
|
+
})
|
|
7959
|
+
]).default("stream").volatile().i18n({
|
|
7960
|
+
"zh-CN": { $description: "文字输入方式" },
|
|
7961
|
+
"en-US": { $description: "How text is entered" }
|
|
7962
|
+
}),
|
|
7841
7963
|
autoScreenshot: z.boolean().default(true).volatile().i18n({
|
|
7842
7964
|
"zh-CN": { $description: "每次操作后自动回传截图(省去一轮调用)" },
|
|
7843
7965
|
"en-US": { $description: "Return a screenshot after every action (saves a round trip)" }
|
package/lib/types/computer.d.ts
CHANGED
|
@@ -17,7 +17,10 @@ export interface Settings {
|
|
|
17
17
|
pauseOnUserInput: boolean;
|
|
18
18
|
/** How long the keyboard must be quiet before resuming. */
|
|
19
19
|
userIdleMs: number;
|
|
20
|
+
/** How text is entered: stream = paste block by block, type = key by key, paste = at once. */
|
|
21
|
+
typingMode: TypingMode;
|
|
20
22
|
}
|
|
23
|
+
export type TypingMode = 'stream' | 'type' | 'paste';
|
|
21
24
|
export interface WindowInfo extends WindowLike {
|
|
22
25
|
hwnd: number;
|
|
23
26
|
pid: number;
|
|
@@ -132,6 +135,15 @@ export declare class Computer {
|
|
|
132
135
|
static statusOf(input: ActionInput): string;
|
|
133
136
|
/** Run one action. Returns text plus an image for screenshot/zoom. */
|
|
134
137
|
run(input: ActionInput, call: CallContext): Promise<ActionOutcome>;
|
|
138
|
+
/**
|
|
139
|
+
* Enter text the way the settings ask. Long text is pasted (literally: typing
|
|
140
|
+
* Markdown key by key trips editors' auto-formatting); in stream mode block
|
|
141
|
+
* by block so the user watches it appear. Between pieces the user can pause
|
|
142
|
+
* (Esc / typing); if another window comes to the front meanwhile, stop.
|
|
143
|
+
*/
|
|
144
|
+
private enterText;
|
|
145
|
+
/** Run `step` per piece; between pieces yield to the user and make sure the target window is still in front. */
|
|
146
|
+
private pieces;
|
|
135
147
|
/** Release a mouse button left down by an aborted run. */
|
|
136
148
|
releaseHeld(): Promise<void>;
|
|
137
149
|
/**
|
package/lib/types/index.d.ts
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
import type { Context } from '@deepseek-ai/cordis';
|
|
8
8
|
import z from '@deepseek-ai/schemastery';
|
|
9
9
|
import { type AccessMode } from './access.js';
|
|
10
|
+
import { type TypingMode } from './computer.js';
|
|
10
11
|
import { type HostWindowMode } from './overlay.js';
|
|
11
12
|
export { DEFAULTS, ENTRY_ID, resolveConfig } from './settings.js';
|
|
12
13
|
export declare const name = "@copylee/dsh-computer-use";
|
|
@@ -26,6 +27,7 @@ export interface Config {
|
|
|
26
27
|
blockedApps?: string[];
|
|
27
28
|
pauseOnUserInput?: boolean;
|
|
28
29
|
userIdleMs?: number;
|
|
30
|
+
typingMode?: TypingMode;
|
|
29
31
|
}
|
|
30
32
|
export declare const Config: z<Config>;
|
|
31
33
|
export declare function apply(ctx: Context, config?: Config): void;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Split text for streamed entry: paste block by block so the user watches it
|
|
3
|
+
* appear, while each block still goes in literally (typing Markdown key by key
|
|
4
|
+
* into Typora / Obsidian / Word trips their auto-formatting).
|
|
5
|
+
*
|
|
6
|
+
* Blocks end after a blank-line separator, never inside a ``` / ~~~ fence and
|
|
7
|
+
* never inside a paragraph (a half-pasted **bold** or link may not re-render).
|
|
8
|
+
* Joining the blocks gives back the original text exactly.
|
|
9
|
+
*/
|
|
10
|
+
export declare function splitBlocks(text: string, minChars?: number): string[];
|
|
11
|
+
/** Pieces of at most ~`size` characters, broken after whitespace where possible (for paced typing). */
|
|
12
|
+
export declare function typingPieces(text: string, size?: number): string[];
|
package/package.json
CHANGED