cortico-world-agent-speed 0.2.0 → 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/CHANGELOG.md +64 -0
- package/LICENSE +0 -14
- package/README.md +29 -11
- package/THIRD_PARTY_NOTICES.md +69 -0
- package/activity.d.ts +15 -0
- package/activity.js +88 -3
- package/describe.json +806 -0
- package/dist/webui.css +2 -0
- package/dist/webui.css.map +7 -0
- package/dist/webui.js +2 -0
- package/dist/webui.js.map +7 -0
- package/host/app-store.cjs +68 -0
- package/host/cursor.cjs +67 -0
- package/host/electron-main.cjs +666 -0
- package/host/input-shape.cjs +63 -0
- package/host/mouse-lease.cjs +77 -0
- package/host/overlay.cjs +139 -0
- package/host/portrait.cjs +52 -0
- package/host/preload.cjs +60 -14
- package/host/renderer-gone.cjs +24 -0
- package/host/windows.cjs +251 -0
- package/package.json +27 -7
- package/scripts/build-webui.mjs +40 -0
- package/scripts/speech-bank/build.py +166 -0
- package/scripts/speech-bank/dicts.py +76 -0
- package/src/ENV_PROMPT.en.md +51 -0
- package/src/ENV_PROMPT.md +51 -0
- package/src/asr/address.ts +25 -0
- package/src/asr/hotkey.ts +335 -0
- package/src/asr/result.ts +51 -0
- package/src/asr/segmenter.ts +269 -0
- package/src/asr/sherpa.ts +280 -0
- package/src/asr/simplify.ts +38 -0
- package/src/asr/system-recognizer.ts +292 -0
- package/src/asr/system-sapi.ps1 +173 -0
- package/src/asr/transcription-api.ts +176 -0
- package/src/chat.ts +212 -0
- package/src/config.ts +481 -0
- package/src/cua/ENV_PROMPT.en.md +29 -0
- package/src/cua/ENV_PROMPT.md +29 -0
- package/src/cua/config.ts +88 -0
- package/src/cua/cua.ts +712 -0
- package/src/cua/engine/darwin.ts +410 -0
- package/src/cua/engine/display.ts +55 -0
- package/src/cua/engine/fail.ts +15 -0
- package/src/cua/engine/foreground.ts +8 -0
- package/src/cua/engine/image.ts +57 -0
- package/src/cua/engine/keys.ts +70 -0
- package/src/cua/engine/linux-keys.ts +29 -0
- package/src/cua/engine/linux.ts +343 -0
- package/src/cua/engine/mac-keys.ts +57 -0
- package/src/cua/engine/user-activity.ts +54 -0
- package/src/cua/engine/wait-idle.ts +31 -0
- package/src/cua/engine/win32.ts +299 -0
- package/src/cua/engine-child.ts +274 -0
- package/src/cua/engine-ipc.ts +140 -0
- package/src/cua/i18n/de.ts +53 -0
- package/src/cua/i18n/en.ts +63 -0
- package/src/cua/i18n/es-419.ts +53 -0
- package/src/cua/i18n/fr.ts +53 -0
- package/src/cua/i18n/index.ts +26 -0
- package/src/cua/i18n/it.ts +53 -0
- package/src/cua/i18n/ja.ts +53 -0
- package/src/cua/i18n/ko.ts +53 -0
- package/src/cua/i18n/pt-BR.ts +53 -0
- package/src/cua/i18n/ru.ts +59 -0
- package/src/cua/i18n/zh-Hant.ts +53 -0
- package/src/cua/i18n/zh.ts +59 -0
- package/src/cua/model-text.ts +252 -0
- package/src/cua/terminal.ts +31 -0
- package/src/cua/tools.ts +153 -0
- package/src/definition.ts +146 -0
- package/src/host-reason.ts +32 -0
- package/src/i18n/de.ts +409 -0
- package/src/i18n/en.ts +443 -0
- package/src/i18n/es-419.ts +409 -0
- package/src/i18n/fr.ts +409 -0
- package/src/i18n/index.ts +56 -0
- package/src/i18n/it.ts +409 -0
- package/src/i18n/ja.ts +409 -0
- package/src/i18n/ko.ts +409 -0
- package/src/i18n/pt-BR.ts +409 -0
- package/src/i18n/ru.ts +415 -0
- package/src/i18n/zh-Hant.ts +409 -0
- package/src/i18n/zh.ts +440 -0
- package/src/index.ts +15 -0
- package/src/model-text.ts +344 -0
- package/src/moves.ts +101 -0
- package/src/pack-import.ts +361 -0
- package/src/packs.ts +449 -0
- package/src/runtime/download.ts +29 -0
- package/src/runtime/store.ts +293 -0
- package/src/script.ts +202 -0
- package/src/self.ts +247 -0
- package/src/server.ts +479 -0
- package/src/speech/data/CMUDICT-LICENSE +33 -0
- package/src/speech/data/IPADIC-COPYING +71 -0
- package/src/speech/data/UNICODE-LICENSE +39 -0
- package/src/speech/data/en.tsv.gz +0 -0
- package/src/speech/data/ja-ipadic.tsv.gz +0 -0
- package/src/speech/data/ja-unihan.tsv.gz +0 -0
- package/src/speech/data/zh.json +1 -0
- package/src/speech/index.ts +204 -0
- package/src/speech/ipa.ts +83 -0
- package/src/speech/japanese.ts +105 -0
- package/src/speech/jukujikun.ts +22 -0
- package/src/speech/korean.ts +35 -0
- package/src/speech/lang.ts +151 -0
- package/src/speech/rules.ts +72 -0
- package/src/speech/syllable.ts +76 -0
- package/src/status.ts +164 -0
- package/src/tools.ts +110 -0
- package/src/webui/api-rows.css +2 -0
- package/src/webui/api-rows.ts +44 -0
- package/src/webui/client.ts +451 -0
- package/src/webui/dress-dialog.css +14 -0
- package/src/webui/dress-dialog.ts +117 -0
- package/src/webui/dress-panel.ts +160 -0
- package/src/webui/key-capture.ts +60 -0
- package/src/webui/shared/modal.css +13 -0
- package/src/webui/shared/modal.ts +77 -0
- package/src/webui/shared/problem.css +15 -0
- package/src/webui/shared/problem.ts +217 -0
- package/src/webui/shared/strings.ts +5 -0
- package/src/webui/style.css +50 -0
- package/src/window-host.ts +116 -0
- package/src/world.ts +2926 -0
- package/web/activity-motion.js +117 -0
- package/web/appearance.js +60 -0
- package/web/body-host.js +257 -0
- package/web/coo/coo.js +384 -0
- package/web/coo/figure.js +15 -0
- package/web/coo/figure.json +1224 -0
- package/web/dist/dress-dialog.css +1 -0
- package/web/dist/dress-dialog.js +1 -0
- package/web/drag-row.js +49 -0
- package/web/drag.js +149 -0
- package/web/dress.css +170 -0
- package/web/dress.html +37 -0
- package/web/dress.js +786 -0
- package/web/figure-frame.html +16 -0
- package/web/figure-frame.js +128 -0
- package/web/frame-loop.js +55 -0
- package/web/hints.js +77 -0
- package/web/i18n/de.js +170 -0
- package/web/i18n/en.js +177 -0
- package/web/i18n/es-419.js +170 -0
- package/web/i18n/fr.js +170 -0
- package/web/i18n/it.js +170 -0
- package/web/i18n/ja.js +170 -0
- package/web/i18n/ko.js +170 -0
- package/web/i18n/pt-BR.js +170 -0
- package/web/i18n/ru.js +170 -0
- package/web/i18n/zh-Hant.js +170 -0
- package/web/i18n/zh.js +175 -0
- package/web/i18n.js +54 -0
- package/{renderer/vendor → web}/kit/body.js +31 -58
- package/web/looks.js +70 -0
- package/web/mic-worklet.js +36 -0
- package/web/mic.js +117 -0
- package/web/motion-frames.js +80 -0
- package/web/motion-level.js +40 -0
- package/web/new-year-2027.svg +238 -0
- package/web/overlay.html +16 -0
- package/web/overlay.js +100 -0
- package/web/pet-app.js +3000 -0
- package/web/pet.css +642 -0
- package/web/pet.html +21 -0
- package/web/scale-slider.js +259 -0
- package/web/show-hide.js +49 -0
- package/web/sound.js +245 -0
- package/web/speech/zh.json +1 -0
- package/web/speech/zh.ogg +0 -0
- package/web/speech.js +197 -0
- package/web/stage.js +160 -0
- package/web/swap-motion.js +119 -0
- package/web/ui.js +195 -0
- package/host/launch.js +0 -187
- package/host/library.cjs +0 -638
- package/host/main.cjs +0 -389
- package/index.js +0 -93
- package/renderer/index.html +0 -22
- package/renderer/pet-sandbox.html +0 -11
- package/renderer/pet.css +0 -38
- package/renderer/pet.js +0 -251
- package/renderer/vendor/activity-motion.js +0 -101
- package/renderer/vendor/figure-frame.js +0 -115
- package/renderer/vendor/pack.css +0 -2
- /package/{renderer/vendor → web}/kit/rig.js +0 -0
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { Translation } from 'cortico/core/language.ts';
|
|
2
|
+
import type { CuaText } from './index.ts';
|
|
3
|
+
|
|
4
|
+
const pluralRules = new Intl.PluralRules('ru');
|
|
5
|
+
const plural = (n: number, one: string, few: string, many: string) => {
|
|
6
|
+
const form = pluralRules.select(n);
|
|
7
|
+
return form === 'one' ? one : form === 'many' ? many : few;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
const ru: Translation<CuaText> = {
|
|
11
|
+
ask: {
|
|
12
|
+
eachTurn: (who: string) => `${who} хочет воспользоваться вашим компьютером: смотреть на экран и управлять мышью и клавиатурой. Можно в этот раз?`,
|
|
13
|
+
once: (who: string, minutes: number) => `${who} хочет управлять вашей мышью и клавиатурой. Можно на ${minutes} ${plural(minutes, 'минуту', 'минуты', 'минут')}?`,
|
|
14
|
+
acting: (who: string) => `${who} хочет управлять вашей мышью и клавиатурой. Можно в этот раз?`,
|
|
15
|
+
caption: 'Управление компьютером',
|
|
16
|
+
yes: 'Да',
|
|
17
|
+
no: 'В этот раз нет',
|
|
18
|
+
terminal: {
|
|
19
|
+
type: (who: string, window: string, text: string, minutes: number) => `${who} хочет ввести в окне терминала «${window}»:\n${text}\nВведённое может выполниться как команда. После согласия ввод и клавиши в окнах терминала и win+r не спрашиваются ${minutes} мин. Можно?`,
|
|
20
|
+
key: (who: string, window: string, keys: string, minutes: number) => `${who} хочет нажать ${keys} в окне терминала «${window}». После согласия ввод и клавиши в окнах терминала и win+r не спрашиваются ${minutes} мин. Можно?`,
|
|
21
|
+
runBox: (who: string, keys: string, minutes: number) => `${who} хочет нажать ${keys}, чтобы открыть окно «Выполнить»: оно может запускать программы и команды. После согласия ввод и клавиши в окнах терминала и win+r не спрашиваются ${minutes} мин. Можно?`,
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
|
|
25
|
+
preflight: {
|
|
26
|
+
noDisplay: 'Управление компьютером в Linux требует X11 (или XWayland под Wayland): переменная DISPLAY не задана.',
|
|
27
|
+
unsupported: 'Управление компьютером работает только в Windows, macOS и Linux.',
|
|
28
|
+
},
|
|
29
|
+
|
|
30
|
+
console: {
|
|
31
|
+
engine: 'Движок ввода',
|
|
32
|
+
screen: (w: number, h: number) => `Экран ${w}×${h}`,
|
|
33
|
+
onDemand: 'Запускается по необходимости',
|
|
34
|
+
exited: (code: number | null) => `Процесс движка завершился (код выхода ${code})`,
|
|
35
|
+
allowed: 'Разрешено',
|
|
36
|
+
viewOnly: 'Только просмотр',
|
|
37
|
+
asking: 'Спрашивает',
|
|
38
|
+
levels: { 'ask-each-turn': 'Каждый ход', 'ask-before-acting': 'Перед действием', 'ask-once': (minutes: number) => `Раз в ${minutes} мин`, 'never-ask': 'Никогда' },
|
|
39
|
+
},
|
|
40
|
+
|
|
41
|
+
config: {
|
|
42
|
+
group: 'Управление компьютером',
|
|
43
|
+
enabled: { title: 'Включить управление компьютером' },
|
|
44
|
+
risksConfirmed: { title: "Риски подтверждены", description: "Риски подтверждены при включении управления компьютером или при добавлении его в кнопки при наведении; если включено, эта кнопка включает управление компьютером сразу." },
|
|
45
|
+
control: { title: 'Разрешить мышь и клавиатуру', description: 'Если выключено, только скриншоты и список окон.' },
|
|
46
|
+
permission: { title: 'Когда спрашивать вас', description: 'ask-each-turn: перед просмотром экрана или действием, каждый ход; ask-before-acting: смотреть можно свободно, спрашивает перед использованием мыши и клавиатуры каждый ход; ask-once: смотреть можно свободно, спрашивает один раз перед использованием мыши и клавиатуры, и после согласия не спрашивает в течение срока «Согласие действует»; never-ask: никогда не спрашивает. Пока параметр «Отключить вопрос перед терминалом и окном „Выполнить“» выключен, при любой настройке перед вводом или нажатием клавиш в окне терминала и перед win+r спрашивает отдельно один раз; согласие действует в течение срока «Согласие действует».' },
|
|
47
|
+
grantMinutes: { title: 'Согласие действует', suffix: 'мин', description: 'Для ask-once и для отдельного вопроса об окнах терминала.' },
|
|
48
|
+
skipTerminalAsk: { title: 'Отключить вопрос перед терминалом и окном «Выполнить»', description: 'Если включено, перед вводом или нажатием клавиш в окне терминала и перед win+r отдельного вопроса нет: действует «Когда спрашивать вас», как для любого другого ввода. При never-ask Coo может выполнять команды, не спрашивая вас.' },
|
|
49
|
+
userIdleMs: { title: 'Не мешать в течение', description: 'После того как вы пользовались мышью или клавиатурой, ждёт, пока они пробудут в покое столько времени.' },
|
|
50
|
+
maxYieldWaitMs: { title: 'Максимальное ожидание вас', description: 'Если по истечении этого времени вы всё ещё пользуетесь мышью или клавиатурой, действие не выполняется. При 0 ожидания нет.' },
|
|
51
|
+
maxWidth: { title: 'Максимальная ширина скриншота' },
|
|
52
|
+
maxHeight: { title: 'Максимальная высота скриншота' },
|
|
53
|
+
quality: { title: 'Качество скриншота' },
|
|
54
|
+
afterAction: { title: 'Скриншот после каждого действия' },
|
|
55
|
+
settleMs: { title: 'Пауза перед скриншотом' },
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
export default ru;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { Translation } from 'cortico/core/language.ts';
|
|
2
|
+
import type { CuaText } from './index.ts';
|
|
3
|
+
|
|
4
|
+
const zhHant: Translation<CuaText> = {
|
|
5
|
+
ask: {
|
|
6
|
+
eachTurn: (who: string) => `${who} 想使用你的電腦:查看螢幕、操作滑鼠和鍵盤。這一次可以嗎?`,
|
|
7
|
+
once: (who: string, minutes: number) => `${who} 想操作你的滑鼠和鍵盤。接下來 ${minutes} 分鐘內都可以嗎?`,
|
|
8
|
+
acting: (who: string) => `${who} 想操作你的滑鼠和鍵盤。這一次可以嗎?`,
|
|
9
|
+
caption: '電腦操作',
|
|
10
|
+
yes: '可以',
|
|
11
|
+
no: '這次不行',
|
|
12
|
+
terminal: {
|
|
13
|
+
type: (who: string, window: string, text: string, minutes: number) => `${who} 想在命令列視窗「${window}」裡輸入:\n${text}\n輸入的內容可能作為命令執行。同意後 ${minutes} 分鐘內,在命令列視窗裡輸入、按鍵和按 win+r 不再詢問。可以嗎?`,
|
|
14
|
+
key: (who: string, window: string, keys: string, minutes: number) => `${who} 想在命令列視窗「${window}」裡按 ${keys}。同意後 ${minutes} 分鐘內,在命令列視窗裡輸入、按鍵和按 win+r 不再詢問。可以嗎?`,
|
|
15
|
+
runBox: (who: string, keys: string, minutes: number) => `${who} 想按 ${keys} 開啟執行視窗,執行視窗能啟動程式或執行命令。同意後 ${minutes} 分鐘內,在命令列視窗裡輸入、按鍵和按 win+r 不再詢問。可以嗎?`,
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
|
|
19
|
+
preflight: {
|
|
20
|
+
noDisplay: '電腦操作在 Linux 上需要 X11(或 Wayland 下的 XWayland):沒有設定 DISPLAY。',
|
|
21
|
+
unsupported: '電腦操作只支援 Windows、macOS 和 Linux。',
|
|
22
|
+
},
|
|
23
|
+
|
|
24
|
+
console: {
|
|
25
|
+
engine: '操作引擎',
|
|
26
|
+
screen: (w: number, h: number) => `螢幕 ${w}×${h}`,
|
|
27
|
+
onDemand: '需要時啟動',
|
|
28
|
+
exited: (code: number | null) => `引擎處理程序結束(結束代碼 ${code})`,
|
|
29
|
+
allowed: '允許',
|
|
30
|
+
viewOnly: '只查看',
|
|
31
|
+
asking: '詢問',
|
|
32
|
+
levels: { 'ask-each-turn': '每輪', 'ask-before-acting': '動手前', 'ask-once': (minutes: number) => `每 ${minutes} 分鐘一次`, 'never-ask': '不詢問' },
|
|
33
|
+
},
|
|
34
|
+
|
|
35
|
+
config: {
|
|
36
|
+
group: '電腦操作',
|
|
37
|
+
enabled: { title: '啟用電腦操作' },
|
|
38
|
+
risksConfirmed: { title: "已確認風險說明", description: "開啟電腦操作或把它加進懸停按鈕時已確認過風險說明;開啟時,懸停按鈕可以直接開啟電腦操作。" },
|
|
39
|
+
control: { title: '允許操作滑鼠和鍵盤', description: '關閉後只能截圖和列出視窗。' },
|
|
40
|
+
permission: { title: '詢問時機', description: 'ask-each-turn:每輪查看螢幕或操作前都詢問;ask-before-acting:查看螢幕不詢問,每輪操作滑鼠鍵盤前詢問;ask-once:查看螢幕不詢問,操作前詢問一次,同意後在「同意有效期」內不再詢問;never-ask:從不詢問。沒有開啟「關閉使用終端和執行前的詢問」時,無論選哪一檔,在命令列視窗裡輸入或按鍵、按 win+r 之前,都會單獨詢問一次,同意後在「同意有效期」內不再詢問。' },
|
|
41
|
+
grantMinutes: { title: '同意有效期', suffix: '分鐘', description: '對 ask-once 和命令列視窗的單獨詢問有效。' },
|
|
42
|
+
skipTerminalAsk: { title: '關閉使用命令列視窗和執行前的詢問', description: '開啟後,在命令列視窗裡輸入或按鍵、按 win+r 之前不再單獨詢問,和其他操作一樣按「詢問時機」詢問。詢問時機是 never-ask 時,Coo 能不經詢問執行命令。' },
|
|
43
|
+
userIdleMs: { title: '讓位時長', description: '你操作滑鼠或鍵盤後,需靜止這麼久才繼續操作。' },
|
|
44
|
+
maxYieldWaitMs: { title: '讓位最多等待', description: '等這麼久你還沒停手,這次操作就不執行。設為 0 時不等待。' },
|
|
45
|
+
maxWidth: { title: '截圖最大寬度' },
|
|
46
|
+
maxHeight: { title: '截圖最大高度' },
|
|
47
|
+
quality: { title: '截圖品質' },
|
|
48
|
+
afterAction: { title: '操作後附上截圖' },
|
|
49
|
+
settleMs: { title: '截圖前等待' },
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export default zhHant;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 简体中文:电脑操作给人看的文字。键与 en.ts 相同;繁体中文缺的顶层键读这里。
|
|
3
|
+
* 征求同意的问句与系统对话框按应用语言;控制台的配置项与状态灯按控制台请求的语言。
|
|
4
|
+
* 给 bot 读的文字(包括引擎的报错)不在这里(model-text.ts)。
|
|
5
|
+
*/
|
|
6
|
+
export default {
|
|
7
|
+
/** 用电脑前征求同意:who 是 bot 的名字 */
|
|
8
|
+
ask: {
|
|
9
|
+
eachTurn: (who: string) => `${who} 想使用你的电脑:查看屏幕、操作鼠标和键盘。这一次可以吗?`,
|
|
10
|
+
once: (who: string, minutes: number) => `${who} 想操作你的鼠标和键盘。接下来 ${minutes} 分钟内都可以吗?`,
|
|
11
|
+
acting: (who: string) => `${who} 想操作你的鼠标和键盘。这一次可以吗?`,
|
|
12
|
+
/** 两个按钮:桌宠气泡和系统对话框共用;caption 是系统对话框的标题(桌宠页不在时才弹) */
|
|
13
|
+
caption: '电脑操作',
|
|
14
|
+
yes: '可以',
|
|
15
|
+
no: '这次不行',
|
|
16
|
+
/** 在命令行窗口里操作、按 win+r 之前单独询问:window 是前台窗口标题,keys 是 speed_pet_cua_key 的写法 */
|
|
17
|
+
terminal: {
|
|
18
|
+
type: (who: string, window: string, text: string, minutes: number) => `${who} 想在命令行窗口「${window}」里输入:\n${text}\n输入的内容可能作为命令执行。同意后 ${minutes} 分钟内,在命令行窗口里输入、按键和按 win+r 不再询问。可以吗?`,
|
|
19
|
+
key: (who: string, window: string, keys: string, minutes: number) => `${who} 想在命令行窗口「${window}」里按 ${keys}。同意后 ${minutes} 分钟内,在命令行窗口里输入、按键和按 win+r 不再询问。可以吗?`,
|
|
20
|
+
runBox: (who: string, keys: string, minutes: number) => `${who} 想按 ${keys} 打开运行框,运行框能启动程序或执行命令。同意后 ${minutes} 分钟内,在命令行窗口里输入、按键和按 win+r 不再询问。可以吗?`,
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
|
|
24
|
+
/** 这个系统能不能用电脑操作 */
|
|
25
|
+
preflight: {
|
|
26
|
+
noDisplay: '电脑操作在 Linux 上需要 X11(或 Wayland 下的 XWayland):没有找到 DISPLAY。',
|
|
27
|
+
unsupported: '电脑操作只支持 Windows、macOS 和 Linux。',
|
|
28
|
+
},
|
|
29
|
+
|
|
30
|
+
/** 控制台:桌宠 World 页上操作引擎的状态灯 */
|
|
31
|
+
console: {
|
|
32
|
+
engine: '操作引擎',
|
|
33
|
+
screen: (w: number, h: number) => `屏幕 ${w}×${h}`,
|
|
34
|
+
onDemand: '按需启动',
|
|
35
|
+
exited: (code: number | null) => `引擎进程退出(退出码 ${code})`,
|
|
36
|
+
allowed: '允许',
|
|
37
|
+
viewOnly: '只查看',
|
|
38
|
+
asking: '询问',
|
|
39
|
+
levels: { 'ask-each-turn': '每轮', 'ask-before-acting': '动手前', 'ask-once': (minutes: number) => `${minutes} 分钟一次`, 'never-ask': '不询问' },
|
|
40
|
+
},
|
|
41
|
+
|
|
42
|
+
/** 控制台的配置项 */
|
|
43
|
+
config: {
|
|
44
|
+
group: '电脑操作',
|
|
45
|
+
enabled: { title: '启用电脑操作' },
|
|
46
|
+
risksConfirmed: { title: "已确认风险说明", description: "打开电脑操作或把它加进悬停按钮时已确认过风险说明;开着时,悬停按钮可以直接打开电脑操作。" },
|
|
47
|
+
control: { title: '允许操作鼠标和键盘', description: '关闭后只能截图和列出窗口。' },
|
|
48
|
+
permission: { title: '询问时机', description: 'ask-each-turn:每轮查看屏幕或操作前都询问;ask-before-acting:查看屏幕不询问,每轮操作鼠标键盘前询问;ask-once:查看屏幕不询问,操作前询问一次,同意后在「同意有效期」内不再询问;never-ask:从不询问。没有打开「关闭使用终端和运行前的询问」时,无论选哪一档,在命令行窗口里输入或按键、按 win+r 之前,都会单独询问一次,同意后在「同意有效期」内不再询问。' },
|
|
49
|
+
grantMinutes: { title: '同意有效期', suffix: '分钟', description: '对 ask-once 和命令行窗口的单独询问有效。' },
|
|
50
|
+
skipTerminalAsk: { title: '关闭使用命令行窗口和运行前的询问', description: '打开后,在命令行窗口里输入或按键、按 win+r 之前不再单独询问,和其他操作一样按「询问时机」询问。询问时机是 never-ask 时,Coo 能不经询问执行命令。' },
|
|
51
|
+
userIdleMs: { title: '让位时长', description: '你操作鼠标或键盘后,需静止这么久才继续操作。' },
|
|
52
|
+
maxYieldWaitMs: { title: '让位最多等待', description: '等这么久你还没停手,这次操作就不执行。设为 0 时不等待。' },
|
|
53
|
+
maxWidth: { title: '截图最大宽' },
|
|
54
|
+
maxHeight: { title: '截图最大高' },
|
|
55
|
+
quality: { title: '截图质量' },
|
|
56
|
+
afterAction: { title: '操作后附截图' },
|
|
57
|
+
settleMs: { title: '截图前等待' },
|
|
58
|
+
},
|
|
59
|
+
};
|
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the bot reads from computer use (receipts and environment prompt values), in Chinese and in
|
|
3
|
+
* English; `en: typeof zh` keeps the two tables' keys and signatures the same. The embedding app
|
|
4
|
+
* picks the language (`CuaOptions.modelLanguage`), Chinese when it does not. Window titles go into
|
|
5
|
+
* these lines as they came; the engine's errors are worded here from their codes (`engineErrors`).
|
|
6
|
+
*/
|
|
7
|
+
import type { PermissionLevel } from './config.ts';
|
|
8
|
+
import type { EngineErrorCode } from './engine/fail.ts';
|
|
9
|
+
import type { YieldDiagnostics } from './engine-ipc.ts';
|
|
10
|
+
|
|
11
|
+
export type ModelLanguage = 'zh' | 'en';
|
|
12
|
+
|
|
13
|
+
type Button = 'left' | 'right' | 'middle';
|
|
14
|
+
|
|
15
|
+
const BUTTON_ZH: Record<Button, string> = { left: '左键', right: '右键', middle: '中键' };
|
|
16
|
+
|
|
17
|
+
const zh = {
|
|
18
|
+
notRun: (tool: string, why: string) => `[${tool} 没执行] ${why}`,
|
|
19
|
+
failed: (tool: string, why: string) => `[${tool} 失败] ${why}`,
|
|
20
|
+
askAgain: '下一轮再用会重新询问。',
|
|
21
|
+
interruptedBeforeAct: '收到打断时还没开始操作。',
|
|
22
|
+
interruptedAsking: '收到打断时还在等使用者回答能不能用电脑。',
|
|
23
|
+
askTimedOut: '问了使用者能不能用电脑,没有等到回应,这一轮不能用。',
|
|
24
|
+
terminalRefused: '使用者这一轮没有允许在命令行窗口里输入或按键,也没有允许按 win+r。',
|
|
25
|
+
refused: (level: PermissionLevel) => `使用者这一轮没有允许${level === 'ask-each-turn' ? '用电脑' : '动鼠标键盘'}。`,
|
|
26
|
+
worldStopped: 'World 已停止',
|
|
27
|
+
switchedOff: '电脑操作已关闭',
|
|
28
|
+
/** `code` absent: a clean exit. */
|
|
29
|
+
engineExited: (code?: number | null) => (code === undefined ? '引擎进程已退出' : `引擎进程退出(退出码 ${code})`),
|
|
30
|
+
engineTimeout: '引擎没有在期限内应答',
|
|
31
|
+
/** What the engine's error codes say; `args` as the engine sent them. */
|
|
32
|
+
engineErrors: {
|
|
33
|
+
macScreenPermission: () => '没有「屏幕录制」权限:在「系统设置 → 隐私与安全性 → 录屏与系统录音」里打开 Coopanion,再重启它;已经开着的话,先用「−」把 Coopanion 移出列表再加回来:更新后的新版本不认旧授权',
|
|
34
|
+
macInputPermission: () => '没有「辅助功能」权限:在「系统设置 → 隐私与安全性 → 辅助功能」里打开 Coopanion,再重启它;已经开着的话,先用「−」把 Coopanion 移出列表再加回来:更新后的新版本不认旧授权',
|
|
35
|
+
macNoKey: (vk) => `Mac 键盘上没有这个键(虚拟键码 ${vk})`,
|
|
36
|
+
x11Display: () => '连不上 X11 显示(DISPLAY 没有设置?):电脑操作在 Linux 上需要 X11 或 XWayland',
|
|
37
|
+
linuxNoScreenshot: () => '截屏失败:X 服务器给不出屏幕画面(Wayland 下的 XWayland 常见),也没有找到截屏工具。请安装 grim、spectacle、scrot 或 ImageMagick 之一,或者改用 X11 会话',
|
|
38
|
+
linuxPixelFormat: (bits) => `截屏失败:不支持的像素格式(${bits} 位)`,
|
|
39
|
+
linuxNoKey: (vk) => `这个键盘布局里没有这个键(虚拟键码 ${vk})`,
|
|
40
|
+
linuxNoXdotool: () => '打字需要 xdotool:请先安装(Debian/Ubuntu: sudo apt install xdotool)',
|
|
41
|
+
winBitBlt: () => 'BitBlt 失败(可能被更高权限的窗口挡住)',
|
|
42
|
+
winGetDIBits: (lines, height) => `GetDIBits 只取到 ${lines}/${height} 行`,
|
|
43
|
+
winSendInput: (sent, total) => `SendInput 只送出 ${sent}/${total} 个事件(可能被更高权限的窗口挡住)`,
|
|
44
|
+
winSetCursorPos: (x, y) => `SetCursorPos(${x}, ${y}) 失败(可能被更高权限的窗口挡住)`,
|
|
45
|
+
layoutChanged: () => '显示器变了(接上、拔掉、挪动或改了缩放),这次没有操作;先重新截图,再按新截图的坐标操作',
|
|
46
|
+
noDisplay: (n, total) => `没有显示器 ${n},现在有 ${total} 块`,
|
|
47
|
+
} as Record<EngineErrorCode, (...args: Array<string | number | undefined>) => string>,
|
|
48
|
+
|
|
49
|
+
screenshot: (lead: string, w: number, h: number, view: string, cursor: string, foreground: string | null, seen: boolean) =>
|
|
50
|
+
`${lead}截图 ${w}×${h}(${view});鼠标${cursor};前台窗口「${foreground === null ? '无' : foreground || '标题不可用'}」。` + (seen ? '' : '\n当前模型不接收图片,只能读到这段文字。'),
|
|
51
|
+
screenshotFallback: (w: number, h: number) => `屏幕截图 ${w}×${h}`,
|
|
52
|
+
/** What a screenshot shows when there is one display. */
|
|
53
|
+
viewOne: (pw: number, ph: number) => `屏幕 ${pw}×${ph}`,
|
|
54
|
+
/** What a screenshot shows among several displays, and the others. */
|
|
55
|
+
viewOf: (n: number, total: number, pw: number, ph: number, primary: boolean, others: string) => `显示器 ${n}/${total},${pw}×${ph}${primary ? ',主显示器' : ''};另有显示器 ${others}`,
|
|
56
|
+
displayBrief: (n: number, pw: number, ph: number, primary: boolean) => `${n}(${pw}×${ph}${primary ? ',主显示器' : ''})`,
|
|
57
|
+
cursorAt: (p: string) => `在 ${p}`,
|
|
58
|
+
cursorOn: (n: number) => `在显示器 ${n} 上`,
|
|
59
|
+
cursorNowhere: '不在任何显示器上',
|
|
60
|
+
displayBad: (n: unknown, total: number) => `没有显示器 ${String(n)};现在有 ${total} 块,编号 1–${total}。`,
|
|
61
|
+
zoomed: (w: number, h: number, x: number, y: number, rw: number, rh: number) => `放大图 ${w}×${h}:截图里 (${x}, ${y}) 起 ${rw}×${rh} 的一块,从屏幕重新截取,不大于截图尺寸上限时不缩小。点击等操作仍用截图坐标。`,
|
|
62
|
+
zoomFallback: (w: number, h: number) => `局部放大图 ${w}×${h}`,
|
|
63
|
+
zoomBad: 'x、y 要在截图范围内,width、height 要是正数',
|
|
64
|
+
zoomNoShot: '还没有截图:先用 speed_pet_cua_screenshot 截一张,放大的区域用那张截图的坐标',
|
|
65
|
+
listSep: '、',
|
|
66
|
+
viewOnly: '这台电脑的设置只允许看,不允许操作鼠标键盘(worlds.agent-speed.cua.control 关着)。',
|
|
67
|
+
yielded: (seconds: number) => `等了 ${seconds} 秒,输入信号仍未满静止时长,本次操作未执行。`,
|
|
68
|
+
yieldDetails: (activity: YieldDiagnostics, foreground: string | null, app: string | null) => {
|
|
69
|
+
const signals = activity.blockedBy.map((s) => s === 'systemInput' ? '系统最后输入时间' : '指针位移').join('、');
|
|
70
|
+
const source = activity.blockedBy.includes('systemInput') && activity.pointerMovement.count === 0
|
|
71
|
+
? '未检测到近期指针位移,具体输入设备未知,可能是键盘、滚轮或其他输入设备。' : '';
|
|
72
|
+
return `阻挡信号:${signals}。${source}`
|
|
73
|
+
+ `让位检查命中:系统输入 ${activity.systemInput.count} 次(最后 tick ${activity.systemInput.lastTick ?? '无'}),指针位移 ${activity.pointerMovement.count} 次(最后 tick ${activity.pointerMovement.lastTick ?? '无'});次数是采样检查次数。`
|
|
74
|
+
+ `前台窗口「${foreground === null ? '无' : foreground || '标题不可用'}」,程序「${app ?? '未知'}」。`;
|
|
75
|
+
},
|
|
76
|
+
cancelledWaiting: (seconds: string) => `等用户停手 ${seconds} 秒时收到打断,没有发出输入。`,
|
|
77
|
+
waitedFirst: (seconds: string) => `(先等用户停手 ${seconds} 秒)`,
|
|
78
|
+
after: (line: string, cursor: string, foreground: string | null) => `${line} 鼠标${cursor};前台窗口「${foreground === null ? '无' : foreground || '标题不可用'}」。`,
|
|
79
|
+
noForeground: '现在没有窗口在接收键盘输入;要打字先截图看看。',
|
|
80
|
+
noShotInterrupted: '收到打断,没有截图。',
|
|
81
|
+
|
|
82
|
+
notNumbers: 'x、y 要是数字',
|
|
83
|
+
offShot: (x: number, y: number, maxX: number, maxY: number) => `(${x}, ${y}) 不在截图范围内(0–${maxX}, 0–${maxY})`,
|
|
84
|
+
clicked: (x: unknown, y: unknown, button: Button, count: 1 | 2 | 3) =>
|
|
85
|
+
`已在 (${x}, ${y}) ${BUTTON_ZH[button]}${{ 1: '单击', 2: '双击', 3: '三击' }[count]}。`,
|
|
86
|
+
moved: (x: unknown, y: unknown) => `鼠标已移到 (${x}, ${y})。`,
|
|
87
|
+
dragStart: (why: string) => `起点${why}`,
|
|
88
|
+
dragEnd: (why: string) => `终点${why}`,
|
|
89
|
+
dragged: (from: unknown[], to: unknown[]) => `已从 (${from[0]}, ${from[1]}) 拖到 (${to[0]}, ${to[1]})。`,
|
|
90
|
+
mouseDown: (x: unknown, y: unknown, button: Button) => `已在 (${x}, ${y}) 按下${BUTTON_ZH[button]},没有松开。`,
|
|
91
|
+
mouseUp: (button: Button) => `已松开${BUTTON_ZH[button]}。`,
|
|
92
|
+
scrollNone: 'down 和 right 都是 0。',
|
|
93
|
+
scrolled: (x: unknown, y: unknown, down: number, right: number) => {
|
|
94
|
+
const parts = [down ? `${down > 0 ? '向下' : '向上'} ${Math.abs(down)} 格` : '', right ? `${right > 0 ? '向右' : '向左'} ${Math.abs(right)} 格` : ''].filter(Boolean);
|
|
95
|
+
return `已在 (${x}, ${y}) 滚动${parts.join('、')}。`;
|
|
96
|
+
},
|
|
97
|
+
typeEmpty: 'text 是空的。',
|
|
98
|
+
typedPart: (typed: number, total: number, by: 'cancel' | 'user') => `只输入了 ${typed}/${total} 个字符:${by === 'cancel' ? '收到打断' : '用户开始操作'},停了下来。`,
|
|
99
|
+
typed: (total: number) => `已输入 ${total} 个字符。`,
|
|
100
|
+
keyBad: (why: string) => `${why}。`,
|
|
101
|
+
keyUnknown: (name: string) => `不认识的键「${name}」`,
|
|
102
|
+
keyNone: '没有给出按键',
|
|
103
|
+
pressed: (spec: string) => `已按 ${spec}。`,
|
|
104
|
+
holdOneChord: 'hold 只配一个键或一个组合键(用 + 连接),不能用空格分成几步。',
|
|
105
|
+
held: (spec: string, seconds: number) => `已按住 ${spec} ${seconds} 秒后松开。`,
|
|
106
|
+
heldPart: (spec: string, held: string, seconds: number) => `按住 ${spec} ${held}/${seconds} 秒时收到打断,已松开。`,
|
|
107
|
+
minimized: '最小化',
|
|
108
|
+
offScreen: '不在任何显示器上',
|
|
109
|
+
onDisplay: (n: number) => `在显示器 ${n}`,
|
|
110
|
+
windowLine: (handle: string, foreground: boolean, title: string, where: string) => `- ${handle}${foreground ? ' [前台]' : ''} 「${title}」 ${where}`,
|
|
111
|
+
windows: (n: number, lines: string[]) => `可见窗口 ${n} 个(最近一张截图那块显示器上的窗口位置用截图坐标;前面的在上层):\n${lines.join('\n')}`,
|
|
112
|
+
focusEmpty: 'window 是空的。',
|
|
113
|
+
focusMissing: (key: string) => `没有标题包含「${key}」的可见窗口。`,
|
|
114
|
+
focused: (title: string) => `已把「${title}」切到前台。`,
|
|
115
|
+
focusedElsewhere: (n: number) => `它在显示器 ${n},要看它就截那块显示器。`,
|
|
116
|
+
focusRefused: (title: string, foreground: string | null) => `尝试切换到「${title}」,系统没有让它到前台;现在前台是「${foreground === null ? '无' : foreground || '标题不可用'}」。`,
|
|
117
|
+
waitInterrupted: (waited: string, seconds: number) => `等了 ${waited}/${seconds} 秒时收到打断,没有截图。`,
|
|
118
|
+
waited: (seconds: number) => `等了 ${seconds} 秒。`,
|
|
119
|
+
waitNoLook: (seconds: number) => `等了 ${seconds} 秒。这一轮使用者还没允许看屏幕,所以没有截图;要看就用 speed_pet_cua_screenshot,会先问使用者。`,
|
|
120
|
+
|
|
121
|
+
/** `{{cua.displays}}`, when there is more than one display. */
|
|
122
|
+
displays: (n: number, list: string) => `这台电脑接了 ${n} 块显示器:${list}。截图一次截一块:\`speed_pet_cua_screenshot\` 不带 display 时截上次看的那块,第一次截前台窗口所在的那块;要看别的显示器就带上编号。新打开的窗口可能出现在另一块显示器上,\`speed_pet_cua_windows\` 会写明每个窗口在哪块。`,
|
|
123
|
+
keysMac: '这是 Mac:复制粘贴、全选、保存用 cmd(cmd+c、cmd+v、cmd+a、cmd+s),切换应用用 cmd+tab。',
|
|
124
|
+
keysOther: '复制粘贴、全选、保存用 ctrl(ctrl+c、ctrl+v、ctrl+a、ctrl+s),切换窗口用 alt+tab。',
|
|
125
|
+
control: (allowed: boolean): string => (allowed ? '允许操作鼠标和键盘' : '只允许截图和列窗口,不能操作鼠标键盘'),
|
|
126
|
+
permission: (level: PermissionLevel, grantMinutes: number) => ({
|
|
127
|
+
'ask-each-turn': '每一轮第一次截图或操作之前,使用者会被问一次能不能用电脑。使用者没同意,这一轮的电脑操作工具都不执行;不要换别的工具绕过去,等使用者开口。',
|
|
128
|
+
'ask-before-acting': '截图和列窗口不用先问。每一轮第一次动鼠标或键盘之前,使用者会被问一次;使用者没同意,这一轮的输入工具都不执行,截图照常;不要换别的工具绕过去,等使用者开口。',
|
|
129
|
+
'ask-once': `截图和列窗口不用先问。动鼠标或键盘之前会问使用者一次,同意后 ${grantMinutes} 分钟内不再问;使用者没同意,这一轮的输入工具都不执行,截图照常;不要换别的工具绕过去,等使用者开口。`,
|
|
130
|
+
'never-ask': '看屏幕和动鼠标键盘都不用先问使用者,工具直接执行。',
|
|
131
|
+
})[level],
|
|
132
|
+
terminal: (grantMinutes: number) => `在命令行窗口里打字或按键,以及按 win+r 打开运行框之前,不管上面的询问设置,都会单独问使用者一次,同意后 ${grantMinutes} 分钟内不再问;使用者没同意,这一轮这些步骤都不执行。`,
|
|
133
|
+
terminalSkipped: '在命令行窗口里打字或按键、按 win+r 打开运行框,和别的输入一样按上面的询问设置,没有单独的询问。',
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
const en: typeof zh = {
|
|
137
|
+
notRun: (tool, why) => `[${tool} not run] ${why}`,
|
|
138
|
+
failed: (tool, why) => `[${tool} failed] ${why}`,
|
|
139
|
+
askAgain: ' The person is asked again the next time it is used in a later turn.',
|
|
140
|
+
interruptedBeforeAct: 'Interrupted before anything was done.',
|
|
141
|
+
interruptedAsking: 'Interrupted while still waiting for the person to answer whether you may use the computer.',
|
|
142
|
+
askTimedOut: 'Asked the person whether you may use the computer; no answer came, so not this turn.',
|
|
143
|
+
terminalRefused: 'The person did not allow typing or keys in a terminal window, or win+r, this turn.',
|
|
144
|
+
refused: (level) => `The person did not allow ${level === 'ask-each-turn' ? 'computer use' : 'mouse and keyboard input'} this turn.`,
|
|
145
|
+
worldStopped: 'The World stopped',
|
|
146
|
+
switchedOff: 'Computer use was switched off',
|
|
147
|
+
engineExited: (code) => (code === undefined ? 'The engine process exited' : `The engine process exited (exit code ${code})`),
|
|
148
|
+
engineTimeout: 'The engine did not answer in time',
|
|
149
|
+
engineErrors: {
|
|
150
|
+
macScreenPermission: () => 'No Screen Recording permission: turn Coopanion on under System Settings → Privacy & Security → Screen & System Audio Recording, then restart it. If it is on already, remove Coopanion from the list with "−" and add it back: an updated version does not inherit the old permission',
|
|
151
|
+
macInputPermission: () => 'No Accessibility permission: turn Coopanion on under System Settings → Privacy & Security → Accessibility, then restart it. If it is on already, remove Coopanion from the list with "−" and add it back: an updated version does not inherit the old permission',
|
|
152
|
+
macNoKey: (vk) => `A Mac keyboard has no such key (virtual-key code ${vk})`,
|
|
153
|
+
x11Display: () => 'Cannot connect to the X11 display (is DISPLAY set?): computer use on Linux needs X11 or XWayland',
|
|
154
|
+
linuxNoScreenshot: () => 'Screenshot failed: the X server gives no screen image (common with XWayland under Wayland) and no screenshot tool was found. Install one of grim, spectacle, scrot or ImageMagick, or switch to an X11 session',
|
|
155
|
+
linuxPixelFormat: (bits) => `Screenshot failed: unsupported pixel format (${bits} bits)`,
|
|
156
|
+
linuxNoKey: (vk) => `The keyboard layout has no such key (virtual-key code ${vk})`,
|
|
157
|
+
linuxNoXdotool: () => 'Typing needs xdotool: install it first (Debian/Ubuntu: sudo apt install xdotool)',
|
|
158
|
+
winBitBlt: () => 'BitBlt failed (a window with higher privileges may be in the way)',
|
|
159
|
+
winGetDIBits: (lines, height) => `GetDIBits returned only ${lines}/${height} lines`,
|
|
160
|
+
winSendInput: (sent, total) => `SendInput sent only ${sent}/${total} events (a window with higher privileges may be in the way)`,
|
|
161
|
+
winSetCursorPos: (x, y) => `SetCursorPos(${x}, ${y}) failed (a window with higher privileges may be in the way)`,
|
|
162
|
+
layoutChanged: () => 'The displays changed (one was connected, disconnected, moved or rescaled), so nothing was done; take a new screenshot and use its coordinates',
|
|
163
|
+
noDisplay: (n, total) => `There is no display ${n}; there are ${total}`,
|
|
164
|
+
},
|
|
165
|
+
|
|
166
|
+
screenshot: (lead, w, h, view, cursor, foreground, seen) =>
|
|
167
|
+
`${lead}Screenshot ${w}×${h} (${view}); mouse ${cursor}; foreground window "${foreground === null ? 'none' : foreground || 'title unavailable'}".` + (seen ? '' : '\nThe current model does not take images; this text is all it gets.'),
|
|
168
|
+
screenshotFallback: (w, h) => `screenshot ${w}×${h}`,
|
|
169
|
+
viewOne: (pw, ph) => `screen ${pw}×${ph}`,
|
|
170
|
+
viewOf: (n, total, pw, ph, primary, others) => `display ${n} of ${total}, ${pw}×${ph}${primary ? ', the main display' : ''}; other displays: ${others}`,
|
|
171
|
+
displayBrief: (n, pw, ph, primary) => `${n} (${pw}×${ph}${primary ? ', main' : ''})`,
|
|
172
|
+
cursorAt: (p) => `at ${p}`,
|
|
173
|
+
cursorOn: (n) => `on display ${n}`,
|
|
174
|
+
cursorNowhere: 'on no display',
|
|
175
|
+
displayBad: (n, total) => `There is no display ${String(n)}; there are ${total}, numbered 1–${total}.`,
|
|
176
|
+
zoomed: (w, h, x, y, rw, rh) => `Zoomed image ${w}×${h}: the ${rw}×${rh} block at (${x}, ${y}) of the screenshot, captured again from the screen, unscaled while no larger than the screenshot size limit. Clicks and other actions still take screenshot coordinates.`,
|
|
177
|
+
zoomFallback: (w, h) => `zoomed image ${w}×${h}`,
|
|
178
|
+
zoomBad: 'x and y must be inside the screenshot, width and height positive',
|
|
179
|
+
zoomNoShot: 'No screenshot yet: take one with speed_pet_cua_screenshot and give the region in its coordinates',
|
|
180
|
+
listSep: ', ',
|
|
181
|
+
viewOnly: 'This computer\'s settings allow looking only, no mouse or keyboard input (worlds.agent-speed.cua.control is off).',
|
|
182
|
+
yielded: (seconds) => `Waited ${seconds} seconds; input signals were still within the idle period, so the action was not performed. `,
|
|
183
|
+
yieldDetails: (activity, foreground, app) => {
|
|
184
|
+
const signals = activity.blockedBy.map((s) => s === 'systemInput' ? 'system last-input time' : 'pointer displacement').join(' and ');
|
|
185
|
+
const source = activity.blockedBy.includes('systemInput') && activity.pointerMovement.count === 0
|
|
186
|
+
? 'No recent pointer displacement was detected; the input device is unknown and may be the keyboard, wheel or another input device. ' : '';
|
|
187
|
+
return `Blocking signals: ${signals}. ${source}`
|
|
188
|
+
+ `Blocking checks: system input ${activity.systemInput.count} (last tick ${activity.systemInput.lastTick ?? 'none'}), pointer displacement ${activity.pointerMovement.count} (last tick ${activity.pointerMovement.lastTick ?? 'none'}); counts are sampled checks. `
|
|
189
|
+
+ `Foreground window "${foreground === null ? 'none' : foreground || 'title unavailable'}", program "${app ?? 'unknown'}".`;
|
|
190
|
+
},
|
|
191
|
+
cancelledWaiting: (seconds) => `Interrupted after waiting ${seconds} seconds for the person to stop; no input was sent.`,
|
|
192
|
+
waitedFirst: (seconds) => ` (after waiting ${seconds} seconds for the person to stop)`,
|
|
193
|
+
after: (line, cursor, foreground) => `${line} Mouse ${cursor}; foreground window "${foreground === null ? 'none' : foreground || 'title unavailable'}".`,
|
|
194
|
+
noForeground: ' No window is taking keyboard input now; take a screenshot before typing.',
|
|
195
|
+
noShotInterrupted: ' Interrupted, so no screenshot.',
|
|
196
|
+
|
|
197
|
+
notNumbers: 'x and y must be numbers',
|
|
198
|
+
offShot: (x, y, maxX, maxY) => `(${x}, ${y}) is outside the screenshot (0–${maxX}, 0–${maxY})`,
|
|
199
|
+
clicked: (x, y, button, count) => `${{ 1: 'Clicked', 2: 'Double-clicked', 3: 'Triple-clicked' }[count]} the ${button} button at (${x}, ${y}).`,
|
|
200
|
+
moved: (x, y) => `Moved the mouse to (${x}, ${y}).`,
|
|
201
|
+
dragStart: (why) => `start: ${why}`,
|
|
202
|
+
dragEnd: (why) => `end: ${why}`,
|
|
203
|
+
dragged: (from, to) => `Dragged from (${from[0]}, ${from[1]}) to (${to[0]}, ${to[1]}).`,
|
|
204
|
+
mouseDown: (x, y, button) => `Pressed the ${button} button at (${x}, ${y}) and left it down.`,
|
|
205
|
+
mouseUp: (button) => `Released the ${button} button.`,
|
|
206
|
+
scrollNone: 'down and right are both 0.',
|
|
207
|
+
scrolled: (x, y, down, right) => {
|
|
208
|
+
const notches = (n: number) => `${Math.abs(n)} notch${Math.abs(n) === 1 ? '' : 'es'}`;
|
|
209
|
+
const parts = [down ? `${down > 0 ? 'down' : 'up'} ${notches(down)}` : '', right ? `${right > 0 ? 'right' : 'left'} ${notches(right)}` : ''].filter(Boolean);
|
|
210
|
+
return `Scrolled ${parts.join(' and ')} at (${x}, ${y}).`;
|
|
211
|
+
},
|
|
212
|
+
typeEmpty: 'text is empty.',
|
|
213
|
+
typedPart: (typed, total, by) => `Typed only ${typed}/${total} characters: stopped because ${by === 'cancel' ? 'of an interrupt' : 'the person started using the computer'}.`,
|
|
214
|
+
typed: (total) => `Typed ${total} character${total === 1 ? '' : 's'}.`,
|
|
215
|
+
keyBad: (why) => `${why}.`,
|
|
216
|
+
keyUnknown: (name) => `unknown key "${name}"`,
|
|
217
|
+
keyNone: 'no keys given',
|
|
218
|
+
pressed: (spec) => `Pressed ${spec}.`,
|
|
219
|
+
holdOneChord: 'With hold, keys must be one key or one combination joined with +, not steps separated by spaces.',
|
|
220
|
+
held: (spec, seconds) => `Held ${spec} down for ${seconds} seconds, then released the keys.`,
|
|
221
|
+
heldPart: (spec, held, seconds) => `Interrupted after holding ${spec} down for ${held}/${seconds} seconds; the keys are released.`,
|
|
222
|
+
minimized: 'minimized',
|
|
223
|
+
offScreen: 'on no display',
|
|
224
|
+
onDisplay: (n) => `on display ${n}`,
|
|
225
|
+
windowLine: (handle, foreground, title, where) => `- ${handle}${foreground ? ' [foreground]' : ''} "${title}" ${where}`,
|
|
226
|
+
windows: (n, lines) => `${n} visible window${n === 1 ? '' : 's'} (positions in screenshot coordinates for windows on the display of the latest screenshot; topmost first):\n${lines.join('\n')}`,
|
|
227
|
+
focusEmpty: 'window is empty.',
|
|
228
|
+
focusMissing: (key) => `No visible window has "${key}" in its title.`,
|
|
229
|
+
focused: (title) => `Brought "${title}" to the foreground.`,
|
|
230
|
+
focusedElsewhere: (n) => ` It is on display ${n}; take a screenshot of that display to see it.`,
|
|
231
|
+
focusRefused: (title, foreground) => `Tried to switch to "${title}", but the system did not bring it to the foreground; the foreground window is "${foreground === null ? 'none' : foreground || 'title unavailable'}".`,
|
|
232
|
+
waitInterrupted: (waited, seconds) => `Interrupted after waiting ${waited}/${seconds} seconds; no screenshot.`,
|
|
233
|
+
waited: (seconds) => `Waited ${seconds} seconds.`,
|
|
234
|
+
waitNoLook: (seconds) => `Waited ${seconds} seconds. The person has not allowed looking at the screen this turn, so there is no screenshot; speed_pet_cua_screenshot asks them first.`,
|
|
235
|
+
|
|
236
|
+
displays: (n, list) => ` This computer has ${n} displays: ${list}. A screenshot shows one display: \`speed_pet_cua_screenshot\` without display shows the one looked at last, at first the one holding the foreground window; give its number to see another. A newly opened window may appear on another display; \`speed_pet_cua_windows\` says which display each window is on.`,
|
|
237
|
+
keysMac: 'This is a Mac: copy, paste, select all and save use cmd (cmd+c, cmd+v, cmd+a, cmd+s), and cmd+tab switches apps.',
|
|
238
|
+
keysOther: 'Copy, paste, select all and save use ctrl (ctrl+c, ctrl+v, ctrl+a, ctrl+s), and alt+tab switches windows.',
|
|
239
|
+
control: (allowed) => (allowed ? 'mouse and keyboard input is allowed' : 'only screenshots and window lists are allowed, no mouse or keyboard input'),
|
|
240
|
+
permission: (level, grantMinutes) => ({
|
|
241
|
+
'ask-each-turn': 'Before the first screenshot or action of each turn, the person is asked once whether you may use the computer. If they do not agree, none of the computer-use tools run this turn; do not route around it with other tools, wait for the person to speak.',
|
|
242
|
+
'ask-before-acting': 'Screenshots and window lists need no asking. Before the first mouse or keyboard input of each turn, the person is asked once; if they do not agree, none of the input tools run this turn, while screenshots still work; do not route around it with other tools, wait for the person to speak.',
|
|
243
|
+
'ask-once': `Screenshots and window lists need no asking. Before mouse or keyboard input the person is asked once, and after a yes not again for ${grantMinutes} minutes; if they do not agree, none of the input tools run this turn, while screenshots still work; do not route around it with other tools, wait for the person to speak.`,
|
|
244
|
+
'never-ask': 'Looking at the screen and using the mouse and keyboard need no asking; the tools run directly.',
|
|
245
|
+
})[level],
|
|
246
|
+
terminal: (grantMinutes) => `Before typing or pressing keys in a terminal window, and before win+r opens the Run box, the person is asked once more whatever the setting above, and after a yes not again for ${grantMinutes} minutes; if they do not agree, none of these steps run this turn.`,
|
|
247
|
+
terminalSkipped: 'Typing or pressing keys in a terminal window, and win+r opening the Run box, follow the setting above like any other input, with no separate question.',
|
|
248
|
+
};
|
|
249
|
+
|
|
250
|
+
export type ModelText = typeof zh;
|
|
251
|
+
|
|
252
|
+
export const MODEL_TEXT: Record<ModelLanguage, ModelText> = { zh, en };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Steps that work in a terminal, which the person grants on their own (cua.ts): typing or a key
|
|
3
|
+
* while a terminal window is in front, and the Run box shortcut on Windows.
|
|
4
|
+
*/
|
|
5
|
+
import type { KeyCode } from './engine/keys.ts';
|
|
6
|
+
|
|
7
|
+
const WIN = 0x5B;
|
|
8
|
+
const R = 0x52;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Terminals and shells by program name, lowercase and without `.exe`: what Windows and Linux report
|
|
12
|
+
* for the process, the app name on macOS. Linux cuts a name at 15 characters (gnome-terminal-server).
|
|
13
|
+
*/
|
|
14
|
+
const TERMINALS = new Set([
|
|
15
|
+
'cmd', 'powershell', 'powershell_ise', 'pwsh', 'windowsterminal', 'wt', 'conhost', 'openconsole', 'wsl', 'bash', 'mintty', 'putty',
|
|
16
|
+
'terminal', 'iterm', 'iterm2', 'warp', 'ghostty', 'hyper', 'tabby', 'alacritty', 'kitty', 'wezterm', 'wezterm-gui',
|
|
17
|
+
'gnome-terminal-', 'kgx', 'ptyxis', 'konsole', 'xterm', 'uxterm', 'urxvt', 'rxvt', 'st', 'foot', 'tilix', 'terminator',
|
|
18
|
+
'xfce4-terminal', 'mate-terminal', 'lxterminal', 'qterminal', 'terminology', 'deepin-terminal', 'yakuake', 'guake',
|
|
19
|
+
]);
|
|
20
|
+
|
|
21
|
+
/** Whether the program `app` (ScreenInfo.foregroundApp) is a terminal or a shell. */
|
|
22
|
+
export function isTerminal(app: string | null | undefined): boolean {
|
|
23
|
+
if (!app) return false;
|
|
24
|
+
const name = app.toLowerCase().replace(/\.exe$/, '');
|
|
25
|
+
return TERMINALS.has(name) || TERMINALS.has(name.slice(0, 15));
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** Whether `chords` press Win+R, which opens the Run box on Windows. */
|
|
29
|
+
export function opensRunBox(chords: KeyCode[][], platform: NodeJS.Platform): boolean {
|
|
30
|
+
return platform === 'win32' && chords.some((c) => c.length === 2 && c.some((k) => k.vk === WIN) && c.some((k) => k.vk === R));
|
|
31
|
+
}
|
package/src/cua/tools.ts
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool declarations; `Cua.tools()` binds the handlers. Coordinates are pixels of the latest screenshot,
|
|
3
|
+
* on the display it shows.
|
|
4
|
+
* Descriptions are English whatever the model-text language.
|
|
5
|
+
*/
|
|
6
|
+
import type { ToolDef } from 'cortico/core/types.ts';
|
|
7
|
+
|
|
8
|
+
const shot = { type: 'boolean', description: 'Attach a screenshot afterwards; defaults to the configuration (attach). Leave it out only for a step whose result you do not need to see; after a step that may open a window or dialog, look before typing.' };
|
|
9
|
+
const button = { type: 'string', enum: ['left', 'right', 'middle'], description: 'Default left' };
|
|
10
|
+
const xy = {
|
|
11
|
+
x: { type: 'integer', minimum: 0, description: 'Horizontal position, in pixels of the latest screenshot' },
|
|
12
|
+
y: { type: 'integer', minimum: 0, description: 'Vertical position, in pixels of the latest screenshot' },
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
/** The longest hold of `speed_pet_cua_key`, in seconds: the longest wait of `speed_pet_cua_wait`. */
|
|
16
|
+
export const MAX_HOLD_SECONDS = 30;
|
|
17
|
+
|
|
18
|
+
/** While computer use is off: the way to its switch. */
|
|
19
|
+
export const CUA_OFF_TOOL_DECLS: ReadonlyArray<Omit<ToolDef, 'handler'>> = [
|
|
20
|
+
{
|
|
21
|
+
name: 'speed_pet_cua_open_settings',
|
|
22
|
+
tags: ['act'],
|
|
23
|
+
description: 'Computer use is off. Open the settings window at its switch, where the person reads what turning it on risks and can turn it on. Only after the person has agreed to open it.',
|
|
24
|
+
parameters: { type: 'object', properties: {}, required: [] },
|
|
25
|
+
},
|
|
26
|
+
];
|
|
27
|
+
|
|
28
|
+
export const CUA_TOOL_DECLS: ReadonlyArray<Omit<ToolDef, 'handler'>> = [
|
|
29
|
+
{
|
|
30
|
+
name: 'speed_pet_cua_screenshot',
|
|
31
|
+
tags: ['read', 'snapshot'],
|
|
32
|
+
description: 'Capture one display. Returns the scaled image (with the mouse pointer drawn on it), its size and the display\'s, the other displays, the pointer position and the title of the foreground window. Later coordinates are pixels of this screenshot.',
|
|
33
|
+
parameters: {
|
|
34
|
+
type: 'object',
|
|
35
|
+
properties: { display: { type: 'integer', minimum: 1, description: 'Display number, 1 = leftmost; omitted: the display looked at last, at first the one holding the foreground window' } },
|
|
36
|
+
required: [],
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
name: 'speed_pet_cua_zoom',
|
|
41
|
+
tags: ['read', 'snapshot'],
|
|
42
|
+
description: 'Capture a region of the latest screenshot\'s display again from the screen, for small text or icons the scaled screenshot blurs; the region is unscaled while no larger than the screenshot size limit. The region is given in screenshot pixels; the zoomed image is for reading only.',
|
|
43
|
+
parameters: {
|
|
44
|
+
type: 'object',
|
|
45
|
+
properties: {
|
|
46
|
+
...xy,
|
|
47
|
+
width: { type: 'integer', minimum: 1, description: 'Width in screenshot pixels' },
|
|
48
|
+
height: { type: 'integer', minimum: 1, description: 'Height in screenshot pixels' },
|
|
49
|
+
},
|
|
50
|
+
required: ['x', 'y', 'width', 'height'],
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
name: 'speed_pet_cua_click',
|
|
55
|
+
tags: ['act'],
|
|
56
|
+
description: 'Move the mouse to (x, y) and click.',
|
|
57
|
+
parameters: {
|
|
58
|
+
type: 'object',
|
|
59
|
+
properties: {
|
|
60
|
+
...xy,
|
|
61
|
+
button,
|
|
62
|
+
clicks: { type: 'integer', minimum: 1, maximum: 3, description: '1 single click (default), 2 double click, 3 triple click' },
|
|
63
|
+
screenshot: shot,
|
|
64
|
+
},
|
|
65
|
+
required: ['x', 'y'],
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
name: 'speed_pet_cua_move',
|
|
70
|
+
tags: ['act'],
|
|
71
|
+
description: 'Only move the mouse to (x, y), without clicking; for hovering to bring up a tooltip or a menu.',
|
|
72
|
+
parameters: { type: 'object', properties: { ...xy, screenshot: shot }, required: ['x', 'y'] },
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
name: 'speed_pet_cua_drag',
|
|
76
|
+
tags: ['act'],
|
|
77
|
+
description: 'Hold the left button down, drag from `from` to `to`, and release. Both points are on the display of the latest screenshot.',
|
|
78
|
+
parameters: {
|
|
79
|
+
type: 'object',
|
|
80
|
+
properties: {
|
|
81
|
+
from: { type: 'array', items: { type: 'integer' }, minItems: 2, maxItems: 2, description: '[x, y] start' },
|
|
82
|
+
to: { type: 'array', items: { type: 'integer' }, minItems: 2, maxItems: 2, description: '[x, y] end' },
|
|
83
|
+
screenshot: shot,
|
|
84
|
+
},
|
|
85
|
+
required: ['from', 'to'],
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
name: 'speed_pet_cua_mouse_down',
|
|
90
|
+
tags: ['act'],
|
|
91
|
+
description: 'Move the mouse to (x, y) and press a button, leaving it down. It stays down until speed_pet_cua_mouse_up or the end of the turn; speed_pet_cua_move meanwhile drags with it.',
|
|
92
|
+
parameters: { type: 'object', properties: { ...xy, button, screenshot: shot }, required: ['x', 'y'] },
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
name: 'speed_pet_cua_mouse_up',
|
|
96
|
+
tags: ['act'],
|
|
97
|
+
description: 'Release a mouse button where the pointer is.',
|
|
98
|
+
parameters: { type: 'object', properties: { button, screenshot: shot }, required: [] },
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
name: 'speed_pet_cua_scroll',
|
|
102
|
+
tags: ['act'],
|
|
103
|
+
description: 'Move the mouse to (x, y) and turn the wheel. Positive down scrolls down, negative up; positive right scrolls right. Units are wheel notches.',
|
|
104
|
+
parameters: {
|
|
105
|
+
type: 'object',
|
|
106
|
+
properties: {
|
|
107
|
+
...xy,
|
|
108
|
+
down: { type: 'integer', minimum: -30, maximum: 30 },
|
|
109
|
+
right: { type: 'integer', minimum: -30, maximum: 30 },
|
|
110
|
+
screenshot: shot,
|
|
111
|
+
},
|
|
112
|
+
required: ['x', 'y'],
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
name: 'speed_pet_cua_type',
|
|
117
|
+
tags: ['act'],
|
|
118
|
+
description: 'Type text at the current input focus (any language, whatever state the input method is in); \\n presses Enter once. Click where the text goes first.',
|
|
119
|
+
parameters: { type: 'object', properties: { text: { type: 'string', maxLength: 2000 }, screenshot: shot }, required: ['text'] },
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
name: 'speed_pet_cua_key',
|
|
123
|
+
tags: ['act'],
|
|
124
|
+
description: 'Press a key or a key combination. Join keys pressed together with +, and separate keys pressed one after another with spaces: "ctrl+s", "alt+f4", "ctrl+a delete", "enter", "win". With hold, keys is one key or one combination, kept down that many seconds and then released.',
|
|
125
|
+
parameters: {
|
|
126
|
+
type: 'object',
|
|
127
|
+
properties: {
|
|
128
|
+
keys: { type: 'string' },
|
|
129
|
+
hold: { type: 'number', minimum: 0, maximum: MAX_HOLD_SECONDS, description: `Seconds to keep the keys down, ${MAX_HOLD_SECONDS} at most; omitted: press and release at once` },
|
|
130
|
+
screenshot: shot,
|
|
131
|
+
},
|
|
132
|
+
required: ['keys'],
|
|
133
|
+
},
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
name: 'speed_pet_cua_windows',
|
|
137
|
+
tags: ['read'],
|
|
138
|
+
description: 'List the visible top-level windows: title, which display each is on (with its position in screenshot coordinates when that is the display of the latest screenshot), whether minimized, and which one is in the foreground.',
|
|
139
|
+
parameters: { type: 'object', properties: {}, required: [] },
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
name: 'speed_pet_cua_focus',
|
|
143
|
+
tags: ['act'],
|
|
144
|
+
description: 'Bring a window to the foreground (restoring it first if minimized). window is a handle from speed_pet_cua_windows, or part of its title.',
|
|
145
|
+
parameters: { type: 'object', properties: { window: { type: 'string' }, screenshot: shot }, required: ['window'] },
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
name: 'speed_pet_cua_wait',
|
|
149
|
+
tags: ['read'],
|
|
150
|
+
description: 'Wait a number of seconds (30 at most) for the screen to load, then take a screenshot. Waiting needs no permission from the person; while looking at the screen is not yet allowed this turn, it waits without a screenshot.',
|
|
151
|
+
parameters: { type: 'object', properties: { seconds: { type: 'number', minimum: 0, maximum: 30 } }, required: ['seconds'] },
|
|
152
|
+
},
|
|
153
|
+
];
|