@celljs/ta-computer-use 4.7.0 → 4.8.0
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/extension/index.mjs
CHANGED
|
@@ -97,7 +97,9 @@ var GRACE_POLL_MS = 100;
|
|
|
97
97
|
var WAIT_MS = 3 * 60 * 1000;
|
|
98
98
|
var DESKTOP_PROBES = /display|x11|wayland|at-spi|accessib|session|desktop|automation|uia/i;
|
|
99
99
|
var MISSING_LIBRARY = /error while loading shared libraries: (\S+?):/;
|
|
100
|
-
|
|
100
|
+
function askMac(env = process.env) {
|
|
101
|
+
return /^zh/i.test(env.TA_LANGUAGE || env.LC_ALL || env.LANG || "") ? "Ta 正在请 macOS 允许 Cua Driver 使用这台 Mac:请在 Cua Driver 打开的窗口或“系统设置”里,打开“辅助功能”(用于点击和输入)和“屏幕录制”(用于查看窗口)中的 Cua Driver。开好后 Ta 会自动继续;点“停止”可放弃。" : "Ta is asking macOS to let Cua Driver use this Mac: turn Cua Driver on under Accessibility (to click and type) and Screen Recording (to see windows), in the window Cua Driver opened or in System Settings. Ta goes on by itself once you have; Stop gives up.";
|
|
102
|
+
}
|
|
101
103
|
var NO_ACCESSIBILITY = "Cua Driver has no Accessibility permission of macOS, which it needs to read and use apps: ask the user to turn Cua Driver on in System Settings → Privacy & Security → Accessibility (`/computer-use` in Ta opens it), then try again.";
|
|
102
104
|
var NO_SCREEN_RECORDING = "Cua Driver has no Screen Recording permission of macOS: it reads and uses apps, but takes no screenshots. Turn it on in System Settings → Privacy & Security → Screen & System Audio Recording.";
|
|
103
105
|
|
|
@@ -128,7 +130,7 @@ class CuaDriverAccess {
|
|
|
128
130
|
if (!state || state.accessibility && state.screenRecording) {
|
|
129
131
|
return { ready: true, notes: [], known: state !== undefined };
|
|
130
132
|
}
|
|
131
|
-
notify(
|
|
133
|
+
notify(askMac());
|
|
132
134
|
if (!state.pending) {
|
|
133
135
|
this.options.openSettings?.(state.accessibility ? "Privacy_ScreenCapture" : "Privacy_Accessibility");
|
|
134
136
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@celljs/ta-computer-use",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.8.0",
|
|
4
4
|
"description": "A pi package for Ta: the desktop apps of this computer, used in the background through Cua Driver, which starts only when the agent first needs it",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pi-package"
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { describe, expect, it } from 'bun:test';
|
|
2
|
-
import {
|
|
2
|
+
import { askMac, CuaDriverAccess, type CuaDriverRun, NO_ACCESSIBILITY, NO_SCREEN_RECORDING } from './cua-driver-access';
|
|
3
3
|
|
|
4
4
|
const permissions = (accessibility: boolean, screenRecording: boolean): CuaDriverRun => ({
|
|
5
5
|
code: 0,
|
|
@@ -33,6 +33,13 @@ function mac(answers: CuaDriverRun[], waitMs = 1000, graceMs = 0) {
|
|
|
33
33
|
return { access, calls, opened, notes, notify: (text: string) => notes.push(text), looks: () => looks };
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
+
describe('askMac', () => {
|
|
37
|
+
it("speaks the language of Ta's pages", () => {
|
|
38
|
+
expect(askMac({ TA_LANGUAGE: 'zh-CN', LANG: 'en_US.UTF-8' })).toContain('辅助功能');
|
|
39
|
+
expect(askMac({ LANG: 'en_US.UTF-8' })).toContain('Accessibility');
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
|
|
36
43
|
describe('CuaDriverAccess on macOS', () => {
|
|
37
44
|
it('goes on at once when both permissions are on', async () => {
|
|
38
45
|
const m = mac([permissions(true, true)]);
|
|
@@ -45,7 +52,7 @@ describe('CuaDriverAccess on macOS', () => {
|
|
|
45
52
|
// The daemon answers nothing but permissions_pending while its guide is open, at either step.
|
|
46
53
|
const m = mac([PENDING, PENDING, PENDING, permissions(true, true)]);
|
|
47
54
|
expect(await m.access.check(m.notify)).toEqual({ ready: true, notes: [], known: true });
|
|
48
|
-
expect(m.notes).toEqual([
|
|
55
|
+
expect(m.notes).toEqual([askMac()]);
|
|
49
56
|
expect(m.opened).toEqual([]);
|
|
50
57
|
expect(m.looks()).toBe(3);
|
|
51
58
|
});
|
package/src/cua-driver-access.ts
CHANGED
|
@@ -50,8 +50,12 @@ const WAIT_MS = 3 * 60 * 1000;
|
|
|
50
50
|
const DESKTOP_PROBES = /display|x11|wayland|at-spi|accessib|session|desktop|automation|uia/i;
|
|
51
51
|
const MISSING_LIBRARY = /error while loading shared libraries: (\S+?):/;
|
|
52
52
|
|
|
53
|
-
|
|
54
|
-
|
|
53
|
+
/** What the user reads while Ta waits for the permissions: in the language of Ta's pages (`TA_LANGUAGE`) or the computer's. */
|
|
54
|
+
export function askMac(env: NodeJS.ProcessEnv = process.env): string {
|
|
55
|
+
return /^zh/i.test(env.TA_LANGUAGE || env.LC_ALL || env.LANG || '')
|
|
56
|
+
? 'Ta 正在请 macOS 允许 Cua Driver 使用这台 Mac:请在 Cua Driver 打开的窗口或“系统设置”里,打开“辅助功能”(用于点击和输入)和“屏幕录制”(用于查看窗口)中的 Cua Driver。开好后 Ta 会自动继续;点“停止”可放弃。'
|
|
57
|
+
: 'Ta is asking macOS to let Cua Driver use this Mac: turn Cua Driver on under Accessibility (to click and type) and Screen Recording (to see windows), in the window Cua Driver opened or in System Settings. Ta goes on by itself once you have; Stop gives up.';
|
|
58
|
+
}
|
|
55
59
|
export const NO_ACCESSIBILITY =
|
|
56
60
|
'Cua Driver has no Accessibility permission of macOS, which it needs to read and use apps: ask the user to turn Cua Driver on in System Settings → Privacy & Security → Accessibility (`/computer-use` in Ta opens it), then try again.';
|
|
57
61
|
export const NO_SCREEN_RECORDING =
|
|
@@ -96,7 +100,7 @@ export class CuaDriverAccess {
|
|
|
96
100
|
if (!state || (state.accessibility && state.screenRecording)) {
|
|
97
101
|
return { ready: true, notes: [], known: state !== undefined };
|
|
98
102
|
}
|
|
99
|
-
notify(
|
|
103
|
+
notify(askMac());
|
|
100
104
|
if (!state.pending) {
|
|
101
105
|
// The guide was closed before: System Settings, where Cua Driver is listed since it asked once.
|
|
102
106
|
this.options.openSettings?.(state.accessibility ? 'Privacy_ScreenCapture' : 'Privacy_Accessibility');
|