@nextclaw/service 0.3.47 → 0.3.49
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/controllers/commands/session/session-command.controller.d.ts +5 -1
- package/dist/controllers/commands/session/session-command.controller.d.ts.map +1 -1
- package/dist/controllers/commands/session/session-command.controller.js +16 -0
- package/dist/controllers/commands/session/session-command.controller.js.map +1 -1
- package/dist/managers/service-gateway.manager.d.ts +2 -0
- package/dist/managers/service-gateway.manager.d.ts.map +1 -1
- package/dist/managers/service-gateway.manager.js +5 -1
- package/dist/managers/service-gateway.manager.js.map +1 -1
- package/dist/services/desktop/macos-accessibility.service.d.ts +280 -0
- package/dist/services/desktop/macos-accessibility.service.d.ts.map +1 -0
- package/dist/services/desktop/macos-accessibility.service.js +203 -0
- package/dist/services/desktop/macos-accessibility.service.js.map +1 -0
- package/dist/services/desktop/macos-desktop-host-worker.service.d.ts +1 -0
- package/dist/services/desktop/macos-desktop-host-worker.service.js +35 -0
- package/dist/services/desktop/macos-desktop-host-worker.service.js.map +1 -0
- package/dist/services/desktop/macos-desktop-host.service.d.ts +52 -0
- package/dist/services/desktop/macos-desktop-host.service.d.ts.map +1 -0
- package/dist/services/desktop/macos-desktop-host.service.js +376 -0
- package/dist/services/desktop/macos-desktop-host.service.js.map +1 -0
- package/package.json +23 -23
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
import { existsSync } from "node:fs";
|
|
3
|
+
import { execFileSync } from "node:child_process";
|
|
4
|
+
import { dirname, join } from "node:path";
|
|
5
|
+
import { fileURLToPath } from "node:url";
|
|
6
|
+
//#region src/services/desktop/macos-accessibility.service.ts
|
|
7
|
+
const moduleDirectory = dirname(fileURLToPath(import.meta.url));
|
|
8
|
+
var MacosAccessibilityService = class {
|
|
9
|
+
adapter;
|
|
10
|
+
constructor(options = {}) {
|
|
11
|
+
this.options = options;
|
|
12
|
+
}
|
|
13
|
+
get supported() {
|
|
14
|
+
return process.platform === "darwin" && this.loadAdapter() !== null;
|
|
15
|
+
}
|
|
16
|
+
getPermission = () => this.withAdapter((adapter) => adapter.isTrusted(false) ? "granted" : "not_granted");
|
|
17
|
+
requestPermission = () => this.withAdapter((adapter) => adapter.isTrusted(true) ? "granted" : "not_granted");
|
|
18
|
+
getScreenCapturePermission = () => this.withAdapter((adapter) => adapter.isScreenCaptureTrusted?.() ? "granted" : "not_supported");
|
|
19
|
+
requestScreenCapturePermission = () => this.withAdapter((adapter) => adapter.requestScreenCapturePermission?.() ? "granted" : "not_supported");
|
|
20
|
+
resolveApplication = (bundleId) => {
|
|
21
|
+
const application = this.requireAdapter().resolveApplication(bundleId);
|
|
22
|
+
if (!application) throw createMacosAccessibilityError("target_not_running", `${bundleId} is not running.`);
|
|
23
|
+
return application;
|
|
24
|
+
};
|
|
25
|
+
snapshot = (bundleId, options = {}) => {
|
|
26
|
+
this.requirePermission();
|
|
27
|
+
return this.requireAdapter().snapshot(bundleId, {
|
|
28
|
+
maxDepth: clampInteger(options.maxDepth, 1, 32, 12),
|
|
29
|
+
maxNodes: clampInteger(options.maxNodes, 1, 2e3, 500),
|
|
30
|
+
...options.pid === void 0 ? {} : { pid: options.pid }
|
|
31
|
+
});
|
|
32
|
+
};
|
|
33
|
+
observe = (bundleId, onEvent) => {
|
|
34
|
+
this.requirePermission();
|
|
35
|
+
const adapter = this.requireAdapter();
|
|
36
|
+
const watchId = adapter.observe(bundleId, onEvent);
|
|
37
|
+
let stopped = false;
|
|
38
|
+
return { stop: () => {
|
|
39
|
+
if (stopped) return false;
|
|
40
|
+
stopped = true;
|
|
41
|
+
return adapter.unobserve(watchId);
|
|
42
|
+
} };
|
|
43
|
+
};
|
|
44
|
+
performAction = (bundleId, input) => {
|
|
45
|
+
this.requirePermission();
|
|
46
|
+
if (!Array.isArray(input.path) || !input.path.every((index) => Number.isInteger(index) && index >= 0)) throw createMacosAccessibilityError("host_operation_failed", "Accessibility element path is invalid.");
|
|
47
|
+
return this.requireAdapter().performAction(bundleId, input);
|
|
48
|
+
};
|
|
49
|
+
clickAt = (bundleId, input) => {
|
|
50
|
+
this.requirePermission();
|
|
51
|
+
if (!Number.isFinite(input.x) || !Number.isFinite(input.y)) throw createMacosAccessibilityError("host_operation_failed", "Pointer coordinates are invalid.");
|
|
52
|
+
const clickAt = this.requireAdapter().clickAt;
|
|
53
|
+
if (!clickAt) throw createMacosAccessibilityError("operation_not_supported", "macOS pointer input is unavailable.");
|
|
54
|
+
return clickAt(bundleId, input);
|
|
55
|
+
};
|
|
56
|
+
typeText = (bundleId, input) => {
|
|
57
|
+
this.requirePermission();
|
|
58
|
+
if (!input.text) throw createMacosAccessibilityError("operation_not_supported", "Typing requires non-empty text.");
|
|
59
|
+
const typeText = this.requireAdapter().typeText;
|
|
60
|
+
if (!typeText) throw createMacosAccessibilityError("operation_not_supported", "macOS keyboard input is unavailable.");
|
|
61
|
+
return typeText(bundleId, input);
|
|
62
|
+
};
|
|
63
|
+
pressKey = (bundleId, input) => {
|
|
64
|
+
this.requirePermission();
|
|
65
|
+
const key = input.key.trim();
|
|
66
|
+
if (!isSupportedKey(key) || !isSupportedModifiers(input.modifiers)) throw createMacosAccessibilityError("operation_not_supported", "Keyboard key or modifiers are not supported.");
|
|
67
|
+
if (this.options.adapter?.pressKey) return this.options.adapter.pressKey(bundleId, {
|
|
68
|
+
...input,
|
|
69
|
+
key
|
|
70
|
+
});
|
|
71
|
+
const helper = this.resolveKeyboardInputHelper();
|
|
72
|
+
if (!helper || input.pid === void 0) throw createMacosAccessibilityError("operation_not_supported", "macOS key input helper is unavailable.");
|
|
73
|
+
try {
|
|
74
|
+
execFileSync(helper, [
|
|
75
|
+
bundleId,
|
|
76
|
+
String(input.pid),
|
|
77
|
+
key,
|
|
78
|
+
input.modifiers?.join(",") ?? ""
|
|
79
|
+
], {
|
|
80
|
+
stdio: "ignore",
|
|
81
|
+
timeout: 5e3
|
|
82
|
+
});
|
|
83
|
+
return { succeeded: true };
|
|
84
|
+
} catch {
|
|
85
|
+
throw createMacosAccessibilityError("host_operation_failed", "macOS key input helper did not complete.");
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
resolveWindow = (bundleId, options = {}) => {
|
|
89
|
+
const resolveWindow = this.requireAdapter().resolveWindow;
|
|
90
|
+
if (!resolveWindow) throw createMacosAccessibilityError("operation_not_supported", "macOS window capture is unavailable.");
|
|
91
|
+
return resolveWindow(bundleId, options);
|
|
92
|
+
};
|
|
93
|
+
resolveCaptureWindow = async (bundleId, options = {}) => {
|
|
94
|
+
this.requireScreenCapturePermission();
|
|
95
|
+
const resolveCaptureWindow = this.requireAdapter().resolveCaptureWindow;
|
|
96
|
+
if (!resolveCaptureWindow) throw createMacosAccessibilityError("operation_not_supported", "macOS window capture is unavailable.");
|
|
97
|
+
return await resolveCaptureWindow(bundleId, options);
|
|
98
|
+
};
|
|
99
|
+
captureWindow = async (windowId, options = {}) => {
|
|
100
|
+
if (!Number.isInteger(windowId) || windowId <= 0) throw createMacosAccessibilityError("host_operation_failed", "Window identifier is invalid.");
|
|
101
|
+
this.requireScreenCapturePermission();
|
|
102
|
+
const captureWindow = this.requireAdapter().captureWindow;
|
|
103
|
+
if (!captureWindow) throw createMacosAccessibilityError("operation_not_supported", "Native macOS window capture is unavailable.");
|
|
104
|
+
return await captureWindow(windowId, options);
|
|
105
|
+
};
|
|
106
|
+
captureApplicationWindow = async (bundleId, options = {}) => {
|
|
107
|
+
this.requireScreenCapturePermission();
|
|
108
|
+
const captureApplicationWindow = this.requireAdapter().captureApplicationWindow;
|
|
109
|
+
if (!captureApplicationWindow) throw createMacosAccessibilityError("operation_not_supported", "Native macOS window capture is unavailable.");
|
|
110
|
+
return await captureApplicationWindow(bundleId, options);
|
|
111
|
+
};
|
|
112
|
+
recognizeText = (imageData, options = {}) => {
|
|
113
|
+
this.requireScreenCapturePermission();
|
|
114
|
+
const recognizeText = this.requireAdapter().recognizeText;
|
|
115
|
+
if (!recognizeText) throw createMacosAccessibilityError("operation_not_supported", "On-device text recognition is unavailable.");
|
|
116
|
+
return recognizeText(imageData, options);
|
|
117
|
+
};
|
|
118
|
+
withAdapter = (getPermission) => {
|
|
119
|
+
const adapter = this.loadAdapter();
|
|
120
|
+
return adapter ? getPermission(adapter) : "not_supported";
|
|
121
|
+
};
|
|
122
|
+
requirePermission = () => {
|
|
123
|
+
if (this.getPermission() !== "granted") throw createMacosAccessibilityError("permission_not_granted", "NextClaw needs macOS Accessibility permission.", "open_settings");
|
|
124
|
+
};
|
|
125
|
+
requireScreenCapturePermission = () => {
|
|
126
|
+
if (this.getScreenCapturePermission() !== "granted") throw createMacosAccessibilityError("permission_not_granted", "NextClaw needs macOS Screen Recording permission.", "open_settings");
|
|
127
|
+
};
|
|
128
|
+
requireAdapter = () => {
|
|
129
|
+
const adapter = this.loadAdapter();
|
|
130
|
+
if (!adapter) throw createMacosAccessibilityError("unsupported_platform", "macOS Accessibility is unavailable.");
|
|
131
|
+
return adapter;
|
|
132
|
+
};
|
|
133
|
+
loadAdapter = () => {
|
|
134
|
+
if (this.adapter !== void 0) return this.adapter;
|
|
135
|
+
if (this.options.adapter) return this.adapter = this.options.adapter;
|
|
136
|
+
if (process.platform !== "darwin") return this.adapter = null;
|
|
137
|
+
const candidates = [
|
|
138
|
+
this.options.nativeModulePath,
|
|
139
|
+
process.env.NEXTCLAW_MACOS_ACCESSIBILITY_MODULE,
|
|
140
|
+
join(moduleDirectory, "..", "..", "native", "macos-accessibility.node"),
|
|
141
|
+
join(moduleDirectory, "..", "..", "..", "build", "native", "macos-accessibility.node"),
|
|
142
|
+
join(process.resourcesPath ?? "", "native", "macos-accessibility.node"),
|
|
143
|
+
join(moduleDirectory, "..", "..", "..", "..", "..", "apps", "desktop", "build", "native-app-resources", "native", "macos-accessibility.node")
|
|
144
|
+
].filter((value) => Boolean(value?.trim()));
|
|
145
|
+
const require = createRequire(import.meta.url);
|
|
146
|
+
for (const candidate of candidates) {
|
|
147
|
+
if (!existsSync(candidate)) continue;
|
|
148
|
+
try {
|
|
149
|
+
return this.adapter = require(candidate);
|
|
150
|
+
} catch {}
|
|
151
|
+
}
|
|
152
|
+
return this.adapter = null;
|
|
153
|
+
};
|
|
154
|
+
resolveKeyboardInputHelper = () => {
|
|
155
|
+
return [
|
|
156
|
+
this.options.keyboardInputHelperPath,
|
|
157
|
+
process.env.NEXTCLAW_MACOS_KEYBOARD_INPUT_HELPER,
|
|
158
|
+
join(moduleDirectory, "..", "..", "..", "build", "native", "macos-keyboard-input"),
|
|
159
|
+
join(process.resourcesPath ?? "", "native", "macos-keyboard-input"),
|
|
160
|
+
join(moduleDirectory, "..", "..", "..", "..", "..", "apps", "desktop", "build", "native-app-resources", "native", "macos-keyboard-input")
|
|
161
|
+
].filter((value) => Boolean(value?.trim())).find((candidate) => existsSync(candidate)) ?? null;
|
|
162
|
+
};
|
|
163
|
+
};
|
|
164
|
+
function clampInteger(value, min, max, fallback) {
|
|
165
|
+
return Number.isInteger(value) ? Math.min(max, Math.max(min, value)) : fallback;
|
|
166
|
+
}
|
|
167
|
+
const SUPPORTED_KEYS = new Set([
|
|
168
|
+
..."abcdefghijklmnopqrstuvwxyz0123456789",
|
|
169
|
+
"Enter",
|
|
170
|
+
"Escape",
|
|
171
|
+
"Tab",
|
|
172
|
+
"Space",
|
|
173
|
+
"Backspace",
|
|
174
|
+
"Delete",
|
|
175
|
+
"ArrowUp",
|
|
176
|
+
"ArrowDown",
|
|
177
|
+
"ArrowLeft",
|
|
178
|
+
"ArrowRight"
|
|
179
|
+
]);
|
|
180
|
+
const SUPPORTED_KEY_MODIFIERS = new Set([
|
|
181
|
+
"command",
|
|
182
|
+
"control",
|
|
183
|
+
"option",
|
|
184
|
+
"shift"
|
|
185
|
+
]);
|
|
186
|
+
function isSupportedKey(key) {
|
|
187
|
+
return SUPPORTED_KEYS.has(key);
|
|
188
|
+
}
|
|
189
|
+
function isSupportedModifiers(modifiers) {
|
|
190
|
+
return modifiers === void 0 || Array.isArray(modifiers) && modifiers.every((modifier) => SUPPORTED_KEY_MODIFIERS.has(modifier)) && new Set(modifiers).size === modifiers.length;
|
|
191
|
+
}
|
|
192
|
+
function createMacosAccessibilityError(code, message, action) {
|
|
193
|
+
const error = new Error(message);
|
|
194
|
+
Object.assign(error, {
|
|
195
|
+
code,
|
|
196
|
+
...action ? { recovery: { action } } : {}
|
|
197
|
+
});
|
|
198
|
+
return error;
|
|
199
|
+
}
|
|
200
|
+
//#endregion
|
|
201
|
+
export { MacosAccessibilityService };
|
|
202
|
+
|
|
203
|
+
//# sourceMappingURL=macos-accessibility.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"macos-accessibility.service.js","names":[],"sources":["../../../src/services/desktop/macos-accessibility.service.ts"],"sourcesContent":["import { execFileSync } from \"node:child_process\";\nimport { existsSync } from \"node:fs\";\nimport { createRequire } from \"node:module\";\nimport { dirname, join } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\nconst moduleDirectory = dirname(fileURLToPath(import.meta.url));\n\nexport type MacosAccessibilityNode = {\n role?: string;\n subrole?: string;\n title?: string;\n value?: string;\n description?: string;\n identifier?: string;\n enabled?: boolean;\n focused?: boolean;\n position?: { x: number; y: number };\n size?: { width: number; height: number };\n children?: MacosAccessibilityNode[];\n};\n\ntype NativeMacosAccessibilityAdapter = {\n isTrusted: (prompt: boolean) => boolean;\n isScreenCaptureTrusted?: () => boolean;\n requestScreenCapturePermission?: () => boolean;\n recognizeText?: (imageData: string, options?: { detail?: \"low\" | \"high\" }) => string;\n resolveApplication: (bundleId: string) => { bundleId: string; pid: number; name: string } | null;\n snapshot: (bundleId: string, options?: { maxDepth?: number; maxNodes?: number; pid?: number }) => MacosAccessibilityNode;\n observe: (bundleId: string, callback: (event: { notification?: string }) => void) => string;\n unobserve: (watchId: string) => boolean;\n performAction: (bundleId: string, input: {\n path: number[];\n type: \"setValue\" | \"press\" | \"confirm\";\n value?: string;\n pid?: number;\n windowId?: number;\n }) => { succeeded: boolean; verified?: boolean; observedValue?: string };\n clickAt?: (bundleId: string, input: { x: number; y: number; pid?: number; windowId?: number }) => { succeeded: boolean };\n typeText?: (bundleId: string, input: { text: string; pid?: number; windowId?: number }) => { succeeded: boolean };\n pressKey?: (bundleId: string, input: { key: string; modifiers?: string[]; pid?: number; windowId?: number }) => { succeeded: boolean };\n resolveWindow?: (bundleId: string, options?: { pid?: number }) => {\n pid: number;\n windowId: number;\n window: { title?: string; position?: { x: number; y: number }; size?: { width: number; height?: number } };\n };\n resolveCaptureWindow?: (bundleId: string, options?: { pid?: number }) => Promise<{\n pid: number;\n windowId: number;\n window: { title?: string; position?: { x: number; y: number }; size?: { width: number; height?: number } };\n }>;\n captureWindow?: (windowId: number, options?: { detail?: \"low\" | \"high\" }) => Promise<{ mimeType: \"image/png\"; data: string; width?: number; height?: number }>;\n captureApplicationWindow?: (bundleId: string, options?: { pid?: number; detail?: \"low\" | \"high\" }) => Promise<{\n pid: number;\n windowId: number;\n window: { title?: string; position?: { x: number; y: number }; size?: { width: number; height?: number } };\n mimeType: \"image/png\";\n data: string;\n width?: number;\n height?: number;\n }>;\n};\n\ntype Permission = \"granted\" | \"not_granted\" | \"not_supported\";\n\nexport class MacosAccessibilityService {\n // The adapter is loaded by the isolated Host Worker. Recreating that worker\n // is therefore sufficient to pick up the foreground capture native artifact.\n private adapter: NativeMacosAccessibilityAdapter | null | undefined;\n\n constructor(private readonly options: {\n adapter?: NativeMacosAccessibilityAdapter;\n nativeModulePath?: string;\n keyboardInputHelperPath?: string;\n } = {}) {}\n\n get supported(): boolean {\n return process.platform === \"darwin\" && this.loadAdapter() !== null;\n }\n\n getPermission = (): Permission => this.withAdapter((adapter) =>\n adapter.isTrusted(false) ? \"granted\" : \"not_granted\",\n );\n\n requestPermission = (): Permission => this.withAdapter((adapter) =>\n adapter.isTrusted(true) ? \"granted\" : \"not_granted\",\n );\n\n getScreenCapturePermission = (): Permission => this.withAdapter((adapter) =>\n adapter.isScreenCaptureTrusted?.() ? \"granted\" : \"not_supported\",\n );\n\n requestScreenCapturePermission = (): Permission => this.withAdapter((adapter) =>\n adapter.requestScreenCapturePermission?.() ? \"granted\" : \"not_supported\",\n );\n\n resolveApplication = (bundleId: string): { bundleId: string; pid: number; name: string } => {\n const application = this.requireAdapter().resolveApplication(bundleId);\n if (!application) throw createMacosAccessibilityError(\"target_not_running\", `${bundleId} is not running.`);\n return application;\n };\n\n snapshot = (bundleId: string, options: { maxDepth?: number; maxNodes?: number; pid?: number } = {}): MacosAccessibilityNode => {\n this.requirePermission();\n return this.requireAdapter().snapshot(bundleId, {\n maxDepth: clampInteger(options.maxDepth, 1, 32, 12),\n // AX calls are synchronous CoreFoundation calls. Keep the default small\n // enough that a complex app cannot stall the long-running service.\n maxNodes: clampInteger(options.maxNodes, 1, 2_000, 500),\n ...(options.pid === undefined ? {} : { pid: options.pid }),\n });\n };\n\n observe = (bundleId: string, onEvent: (event: { notification?: string }) => void): { stop: () => boolean } => {\n this.requirePermission();\n const adapter = this.requireAdapter();\n const watchId = adapter.observe(bundleId, onEvent);\n let stopped = false;\n return { stop: () => {\n if (stopped) return false;\n stopped = true;\n return adapter.unobserve(watchId);\n } };\n };\n\n performAction = (bundleId: string, input: {\n path: number[];\n type: \"setValue\" | \"press\" | \"confirm\";\n value?: string;\n pid?: number;\n windowId?: number;\n }): { succeeded: boolean; verified?: boolean; observedValue?: string } => {\n this.requirePermission();\n if (!Array.isArray(input.path) || !input.path.every((index) => Number.isInteger(index) && index >= 0)) {\n throw createMacosAccessibilityError(\"host_operation_failed\", \"Accessibility element path is invalid.\");\n }\n return this.requireAdapter().performAction(bundleId, input);\n };\n\n clickAt = (bundleId: string, input: { x: number; y: number; pid?: number; windowId?: number }): { succeeded: boolean } => {\n this.requirePermission();\n if (!Number.isFinite(input.x) || !Number.isFinite(input.y)) {\n throw createMacosAccessibilityError(\"host_operation_failed\", \"Pointer coordinates are invalid.\");\n }\n const clickAt = this.requireAdapter().clickAt;\n if (!clickAt) throw createMacosAccessibilityError(\"operation_not_supported\", \"macOS pointer input is unavailable.\");\n return clickAt(bundleId, input);\n };\n\n typeText = (bundleId: string, input: { text: string; pid?: number; windowId?: number }): { succeeded: boolean } => {\n this.requirePermission();\n if (!input.text) {\n throw createMacosAccessibilityError(\"operation_not_supported\", \"Typing requires non-empty text.\");\n }\n const typeText = this.requireAdapter().typeText;\n if (!typeText) throw createMacosAccessibilityError(\"operation_not_supported\", \"macOS keyboard input is unavailable.\");\n return typeText(bundleId, input);\n };\n\n pressKey = (bundleId: string, input: { key: string; modifiers?: string[]; pid?: number; windowId?: number }): { succeeded: boolean } => {\n this.requirePermission();\n const key = input.key.trim();\n if (!isSupportedKey(key) || !isSupportedModifiers(input.modifiers)) {\n throw createMacosAccessibilityError(\"operation_not_supported\", \"Keyboard key or modifiers are not supported.\");\n }\n // Unit tests inject an adapter. Production input runs outside the AX worker:\n // Quartz physical-key events can abort a non-GUI worker process on macOS.\n if (this.options.adapter?.pressKey) return this.options.adapter.pressKey(bundleId, { ...input, key });\n const helper = this.resolveKeyboardInputHelper();\n if (!helper || input.pid === undefined) {\n throw createMacosAccessibilityError(\"operation_not_supported\", \"macOS key input helper is unavailable.\");\n }\n try {\n execFileSync(helper, [bundleId, String(input.pid), key, input.modifiers?.join(\",\") ?? \"\"], {\n stdio: \"ignore\",\n timeout: 5_000,\n });\n return { succeeded: true };\n } catch {\n throw createMacosAccessibilityError(\"host_operation_failed\", \"macOS key input helper did not complete.\");\n }\n };\n\n resolveWindow = (bundleId: string, options: { pid?: number } = {}): {\n pid: number;\n windowId: number;\n window: { title?: string; position?: { x: number; y: number }; size?: { width: number; height?: number } };\n } => {\n const resolveWindow = this.requireAdapter().resolveWindow;\n if (!resolveWindow) throw createMacosAccessibilityError(\"operation_not_supported\", \"macOS window capture is unavailable.\");\n return resolveWindow(bundleId, options);\n };\n\n resolveCaptureWindow = async (bundleId: string, options: { pid?: number } = {}): Promise<{\n pid: number;\n windowId: number;\n window: { title?: string; position?: { x: number; y: number }; size?: { width: number; height?: number } };\n }> => {\n this.requireScreenCapturePermission();\n const resolveCaptureWindow = this.requireAdapter().resolveCaptureWindow;\n if (!resolveCaptureWindow) throw createMacosAccessibilityError(\"operation_not_supported\", \"macOS window capture is unavailable.\");\n return await resolveCaptureWindow(bundleId, options);\n };\n\n captureWindow = async (\n windowId: number,\n options: { detail?: \"low\" | \"high\" } = {},\n ): Promise<{ mimeType: \"image/png\"; data: string; width?: number; height?: number }> => {\n if (!Number.isInteger(windowId) || windowId <= 0) {\n throw createMacosAccessibilityError(\"host_operation_failed\", \"Window identifier is invalid.\");\n }\n this.requireScreenCapturePermission();\n const captureWindow = this.requireAdapter().captureWindow;\n if (!captureWindow) throw createMacosAccessibilityError(\"operation_not_supported\", \"Native macOS window capture is unavailable.\");\n return await captureWindow(windowId, options);\n };\n\n captureApplicationWindow = async (\n bundleId: string,\n options: { pid?: number; detail?: \"low\" | \"high\" } = {},\n ): Promise<{\n pid: number;\n windowId: number;\n window: { title?: string; position?: { x: number; y: number }; size?: { width: number; height?: number } };\n mimeType: \"image/png\";\n data: string;\n width?: number;\n height?: number;\n }> => {\n this.requireScreenCapturePermission();\n const captureApplicationWindow = this.requireAdapter().captureApplicationWindow;\n if (!captureApplicationWindow) throw createMacosAccessibilityError(\"operation_not_supported\", \"Native macOS window capture is unavailable.\");\n return await captureApplicationWindow(bundleId, options);\n };\n\n recognizeText = (imageData: string, options: { detail?: \"low\" | \"high\" } = {}): string => {\n this.requireScreenCapturePermission();\n const recognizeText = this.requireAdapter().recognizeText;\n if (!recognizeText) throw createMacosAccessibilityError(\"operation_not_supported\", \"On-device text recognition is unavailable.\");\n return recognizeText(imageData, options);\n };\n\n private withAdapter = (getPermission: (adapter: NativeMacosAccessibilityAdapter) => Permission): Permission => {\n const adapter = this.loadAdapter();\n return adapter ? getPermission(adapter) : \"not_supported\";\n };\n\n private requirePermission = (): void => {\n if (this.getPermission() !== \"granted\") {\n throw createMacosAccessibilityError(\"permission_not_granted\", \"NextClaw needs macOS Accessibility permission.\", \"open_settings\");\n }\n };\n\n private requireScreenCapturePermission = (): void => {\n if (this.getScreenCapturePermission() !== \"granted\") {\n throw createMacosAccessibilityError(\"permission_not_granted\", \"NextClaw needs macOS Screen Recording permission.\", \"open_settings\");\n }\n };\n\n private requireAdapter = (): NativeMacosAccessibilityAdapter => {\n const adapter = this.loadAdapter();\n if (!adapter) throw createMacosAccessibilityError(\"unsupported_platform\", \"macOS Accessibility is unavailable.\");\n return adapter;\n };\n\n private loadAdapter = (): NativeMacosAccessibilityAdapter | null => {\n if (this.adapter !== undefined) return this.adapter;\n if (this.options.adapter) return this.adapter = this.options.adapter;\n if (process.platform !== \"darwin\") return this.adapter = null;\n const candidates = [\n this.options.nativeModulePath,\n process.env.NEXTCLAW_MACOS_ACCESSIBILITY_MODULE,\n join(moduleDirectory, \"..\", \"..\", \"native\", \"macos-accessibility.node\"),\n join(moduleDirectory, \"..\", \"..\", \"..\", \"build\", \"native\", \"macos-accessibility.node\"),\n join((process as NodeJS.Process & { resourcesPath?: string }).resourcesPath ?? \"\", \"native\", \"macos-accessibility.node\"),\n join(moduleDirectory, \"..\", \"..\", \"..\", \"..\", \"..\", \"apps\", \"desktop\", \"build\", \"native-app-resources\", \"native\", \"macos-accessibility.node\"),\n ].filter((value): value is string => Boolean(value?.trim()));\n const require = createRequire(import.meta.url);\n for (const candidate of candidates) {\n if (!existsSync(candidate)) continue;\n try {\n return this.adapter = require(candidate) as NativeMacosAccessibilityAdapter;\n } catch {\n // The next governed artifact location may match this runtime's ABI.\n }\n }\n return this.adapter = null;\n };\n\n private resolveKeyboardInputHelper = (): string | null => {\n const candidates = [\n this.options.keyboardInputHelperPath,\n process.env.NEXTCLAW_MACOS_KEYBOARD_INPUT_HELPER,\n join(moduleDirectory, \"..\", \"..\", \"..\", \"build\", \"native\", \"macos-keyboard-input\"),\n join((process as NodeJS.Process & { resourcesPath?: string }).resourcesPath ?? \"\", \"native\", \"macos-keyboard-input\"),\n join(moduleDirectory, \"..\", \"..\", \"..\", \"..\", \"..\", \"apps\", \"desktop\", \"build\", \"native-app-resources\", \"native\", \"macos-keyboard-input\"),\n ].filter((value): value is string => Boolean(value?.trim()));\n return candidates.find((candidate) => existsSync(candidate)) ?? null;\n };\n}\n\nfunction clampInteger(value: number | undefined, min: number, max: number, fallback: number): number {\n return Number.isInteger(value) ? Math.min(max, Math.max(min, value!)) : fallback;\n}\n\nconst SUPPORTED_KEYS = new Set([\n ...\"abcdefghijklmnopqrstuvwxyz0123456789\",\n \"Enter\", \"Escape\", \"Tab\", \"Space\", \"Backspace\", \"Delete\",\n \"ArrowUp\", \"ArrowDown\", \"ArrowLeft\", \"ArrowRight\",\n]);\nconst SUPPORTED_KEY_MODIFIERS = new Set([\"command\", \"control\", \"option\", \"shift\"]);\n\nfunction isSupportedKey(key: string): boolean {\n return SUPPORTED_KEYS.has(key);\n}\n\nfunction isSupportedModifiers(modifiers: string[] | undefined): boolean {\n return modifiers === undefined || (\n Array.isArray(modifiers) &&\n modifiers.every((modifier) => SUPPORTED_KEY_MODIFIERS.has(modifier)) &&\n new Set(modifiers).size === modifiers.length\n );\n}\n\nfunction createMacosAccessibilityError(\n code: string,\n message: string,\n action?: \"open_settings\",\n): Error {\n const error = new Error(message);\n Object.assign(error, { code, ...(action ? { recovery: { action } } : {}) });\n return error;\n}\n"],"mappings":";;;;;;AAMA,MAAM,kBAAkB,QAAQ,cAAc,OAAO,KAAK,IAAI,CAAC;AA2D/D,IAAa,4BAAb,MAAuC;CAGrC;CAEA,YAAY,UAIR,EAAE,EAAE;AAJqB,OAAA,UAAA;;CAM7B,IAAI,YAAqB;AACvB,SAAO,QAAQ,aAAa,YAAY,KAAK,aAAa,KAAK;;CAGjE,sBAAkC,KAAK,aAAa,YAClD,QAAQ,UAAU,MAAM,GAAG,YAAY,cACxC;CAED,0BAAsC,KAAK,aAAa,YACtD,QAAQ,UAAU,KAAK,GAAG,YAAY,cACvC;CAED,mCAA+C,KAAK,aAAa,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E,MAAM,iBAAiB,IAAI,IAAI;CAC7B,GAAG;CACH;CAAS;CAAU;CAAO;CAAS;CAAa;CAChD;CAAW;CAAa;CAAa;CACtC,CAAC;AACF,MAAM,0BAA0B,IAAI,IAAI;CAAC;CAAW;CAAW;CAAU;CAAQ,CAAC;AAElF,SAAS,eAAe,KAAsB;AAC5C,QAAO,eAAe,IAAI,IAAI;;AAGhC,SAAS,qBAAqB,WAA0C;AACtE,QAAO,cAAc,KAAA,KACnB,MAAM,QAAQ,UAAU,IACxB,UAAU,OAAO,aAAa,wBAAwB,IAAI,SAAS,CAAC,IACpE,IAAI,IAAI,UAAU,CAAC,SAAS,UAAU;;AAI1C,SAAS,8BACP,MACA,SACA,QACO;CACP,MAAM,QAAQ,IAAI,MAAM,QAAQ;AAChC,QAAO,OAAO,OAAO;EAAE;EAAM,GAAI,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,GAAG,EAAE;EAAG,CAAC;AAC3E,QAAO"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { MacosDesktopHostOperations } from "./macos-desktop-host.service.js";
|
|
2
|
+
import { parentPort } from "node:worker_threads";
|
|
3
|
+
//#region src/services/desktop/macos-desktop-host-worker.service.ts
|
|
4
|
+
const port = parentPort;
|
|
5
|
+
if (!port) throw new Error("Desktop Worker requires a parent port.");
|
|
6
|
+
const host = new MacosDesktopHostOperations();
|
|
7
|
+
host.onEvent((event) => port.postMessage({
|
|
8
|
+
type: "event",
|
|
9
|
+
event
|
|
10
|
+
}));
|
|
11
|
+
port.on("message", async (request) => {
|
|
12
|
+
if (request.type !== "invoke") return;
|
|
13
|
+
try {
|
|
14
|
+
port.postMessage({
|
|
15
|
+
type: "result",
|
|
16
|
+
requestId: request.requestId,
|
|
17
|
+
result: await host.invoke(request.method, request.payload, request.caller)
|
|
18
|
+
});
|
|
19
|
+
} catch (error) {
|
|
20
|
+
const value = error;
|
|
21
|
+
port.postMessage({
|
|
22
|
+
type: "error",
|
|
23
|
+
requestId: request.requestId,
|
|
24
|
+
error: {
|
|
25
|
+
code: typeof value.code === "string" ? value.code : "host_operation_failed",
|
|
26
|
+
message: typeof value.message === "string" ? value.message : "Desktop operation failed.",
|
|
27
|
+
...value.recovery ? { recovery: value.recovery } : {}
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
//#endregion
|
|
33
|
+
export {};
|
|
34
|
+
|
|
35
|
+
//# sourceMappingURL=macos-desktop-host-worker.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"macos-desktop-host-worker.service.js","names":[],"sources":["../../../src/services/desktop/macos-desktop-host-worker.service.ts"],"sourcesContent":["import { parentPort } from \"node:worker_threads\";\nimport { MacosDesktopHostOperations } from \"@nextclaw-service/services/desktop/macos-desktop-host.service.js\";\n\nconst port = parentPort;\nif (!port) throw new Error(\"Desktop Worker requires a parent port.\");\n\nconst host = new MacosDesktopHostOperations();\nhost.onEvent((event) => port.postMessage({ type: \"event\", event }));\nport.on(\"message\", async (request: {\n type: \"invoke\";\n requestId: string;\n method: Parameters<typeof host.invoke>[0];\n payload: Record<string, unknown>;\n caller: Parameters<typeof host.invoke>[2];\n}) => {\n if (request.type !== \"invoke\") return;\n try {\n port.postMessage({\n type: \"result\",\n requestId: request.requestId,\n result: await host.invoke(request.method, request.payload, request.caller),\n });\n } catch (error) {\n const value = error as { code?: unknown; message?: unknown; recovery?: unknown };\n port.postMessage({\n type: \"error\",\n requestId: request.requestId,\n error: {\n code: typeof value.code === \"string\" ? value.code : \"host_operation_failed\",\n message: typeof value.message === \"string\" ? value.message : \"Desktop operation failed.\",\n ...(value.recovery ? { recovery: value.recovery } : {}),\n },\n });\n }\n});\n"],"mappings":";;;AAGA,MAAM,OAAO;AACb,IAAI,CAAC,KAAM,OAAM,IAAI,MAAM,yCAAyC;AAEpE,MAAM,OAAO,IAAI,4BAA4B;AAC7C,KAAK,SAAS,UAAU,KAAK,YAAY;CAAE,MAAM;CAAS;CAAO,CAAC,CAAC;AACnE,KAAK,GAAG,WAAW,OAAO,YAMpB;AACJ,KAAI,QAAQ,SAAS,SAAU;AAC/B,KAAI;AACF,OAAK,YAAY;GACf,MAAM;GACN,WAAW,QAAQ;GACnB,QAAQ,MAAM,KAAK,OAAO,QAAQ,QAAQ,QAAQ,SAAS,QAAQ,OAAO;GAC3E,CAAC;UACK,OAAO;EACd,MAAM,QAAQ;AACd,OAAK,YAAY;GACf,MAAM;GACN,WAAW,QAAQ;GACnB,OAAO;IACL,MAAM,OAAO,MAAM,SAAS,WAAW,MAAM,OAAO;IACpD,SAAS,OAAO,MAAM,YAAY,WAAW,MAAM,UAAU;IAC7D,GAAI,MAAM,WAAW,EAAE,UAAU,MAAM,UAAU,GAAG,EAAE;IACvD;GACF,CAAC;;EAEJ"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { MacosAccessibilityService } from "./macos-accessibility.service.js";
|
|
2
|
+
import { DesktopHost, DesktopHostCaller, DesktopHostEventListener, DesktopHostMethod, DesktopHostStatus } from "@nextclaw/kernel";
|
|
3
|
+
|
|
4
|
+
//#region src/services/desktop/macos-desktop-host.service.d.ts
|
|
5
|
+
/** Synchronous macOS operations, owned by the service and run in its Worker. */
|
|
6
|
+
declare class MacosDesktopHostOperations {
|
|
7
|
+
private readonly accessibility;
|
|
8
|
+
private readonly watches;
|
|
9
|
+
private readonly eventListeners;
|
|
10
|
+
constructor(options?: {
|
|
11
|
+
accessibility?: MacosAccessibilityService;
|
|
12
|
+
openExternal?: (url: string) => Promise<void>;
|
|
13
|
+
});
|
|
14
|
+
private readonly openExternal;
|
|
15
|
+
status: () => Promise<DesktopHostStatus>;
|
|
16
|
+
invoke: <T>(method: DesktopHostMethod, payload: Record<string, unknown>, _caller: DesktopHostCaller) => Promise<T>;
|
|
17
|
+
onEvent: (listener: DesktopHostEventListener) => (() => void);
|
|
18
|
+
dispose: () => Promise<void>;
|
|
19
|
+
private invokeMethod;
|
|
20
|
+
private permissions;
|
|
21
|
+
private openSettings;
|
|
22
|
+
private resolveTarget;
|
|
23
|
+
private snapshot;
|
|
24
|
+
private captureWindow;
|
|
25
|
+
private performAction;
|
|
26
|
+
private clickAt;
|
|
27
|
+
private typeText;
|
|
28
|
+
private pressKey;
|
|
29
|
+
private resolveExecutionTarget;
|
|
30
|
+
private observe;
|
|
31
|
+
private unobserve;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Kernel-facing host. The Worker is an internal service thread, not a separate
|
|
35
|
+
* process or daemon; it prevents synchronous AX calls from blocking 5174.
|
|
36
|
+
*/
|
|
37
|
+
declare class MacosDesktopHostService implements DesktopHost {
|
|
38
|
+
private worker;
|
|
39
|
+
private readonly listeners;
|
|
40
|
+
private readonly pending;
|
|
41
|
+
status: () => Promise<DesktopHostStatus>;
|
|
42
|
+
invoke: <T>(method: DesktopHostMethod, payload: Record<string, unknown>, caller: DesktopHostCaller) => Promise<T>;
|
|
43
|
+
onEvent: (listener: DesktopHostEventListener) => (() => void);
|
|
44
|
+
dispose: () => Promise<void>;
|
|
45
|
+
private requireWorker;
|
|
46
|
+
private handleWorkerMessage;
|
|
47
|
+
private resetWorker;
|
|
48
|
+
private rejectPending;
|
|
49
|
+
}
|
|
50
|
+
//#endregion
|
|
51
|
+
export { MacosDesktopHostOperations, MacosDesktopHostService };
|
|
52
|
+
//# sourceMappingURL=macos-desktop-host.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"macos-desktop-host.service.d.ts","names":[],"sources":["../../../src/services/desktop/macos-desktop-host.service.ts"],"mappings":";;;;;cAwCa,0BAAA;EAAA,iBACM,aAAA;EAAA,iBACA,OAAA;EAAA,iBACA,cAAA;cAEL,OAAA;IACV,aAAA,GAAgB,yBAAA;IAChB,YAAA,IAAgB,GAAA,aAAgB,OAAA;EAAA;EAAA,iBAMjB,YAAA;EAEjB,MAAA,QAAmB,OAAA,CAAQ,iBAAA;EAiB3B,MAAA,MACE,MAAA,EAAQ,iBAAA,EACR,OAAA,EAAS,MAAA,mBACT,OAAA,EAAS,iBAAA,KACR,OAAA,CAAQ,CAAA;EAEX,OAAA,GAAW,QAAA,EAAU,wBAAA;EAKrB,OAAA,QAAoB,OAAA;EAAA,QAKZ,YAAA;EAAA,QAwBA,WAAA;EAAA,QAKA,YAAA;EAAA,QAKA,aAAA;EAAA,QAWA,QAAA;EAAA,QAYA,aAAA;EAAA,QAoCA,aAAA;EAAA,QAYA,OAAA;EAAA,QAUA,QAAA;EAAA,QASA,QAAA;EAAA,QAUA,sBAAA;EAAA,QAUA,OAAA;EAAA,QAsBA,SAAA;AAAA;;;;;cAiBG,uBAAA,YAAmC,WAAA;EAAA,QACtC,MAAA;EAAA,iBACS,SAAA;EAAA,iBACA,OAAA;EAOjB,MAAA,QAAmB,OAAA,CAAQ,iBAAA;EAG3B,MAAA,MACE,MAAA,EAAQ,iBAAA,EACR,OAAA,EAAS,MAAA,mBACT,MAAA,EAAQ,iBAAA,KACP,OAAA,CAAQ,CAAA;EAeX,OAAA,GAAW,QAAA,EAAU,wBAAA;EAKrB,OAAA,QAAoB,OAAA;EAAA,QAEZ,aAAA;EAAA,QAgBA,mBAAA;EAAA,QAcA,WAAA;EAAA,QAOA,aAAA;AAAA"}
|