@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.
@@ -0,0 +1,376 @@
1
+ import { MacosAccessibilityService } from "./macos-accessibility.service.js";
2
+ import { execFile } from "node:child_process";
3
+ import { randomUUID } from "node:crypto";
4
+ import { promisify } from "node:util";
5
+ import { Worker } from "node:worker_threads";
6
+ //#region src/services/desktop/macos-desktop-host.service.ts
7
+ const open = promisify(execFile);
8
+ const HOST_OPERATION_TIMEOUT_MS = 2e4;
9
+ const APPLICATIONS = {
10
+ finder: { bundleId: "com.apple.finder" },
11
+ textedit: { bundleId: "com.apple.TextEdit" },
12
+ activity_monitor: { bundleId: "com.apple.ActivityMonitor" },
13
+ system_settings: { bundleId: "com.apple.systempreferences" },
14
+ chrome: { bundleId: "com.google.Chrome" },
15
+ wechat: { bundleId: "com.tencent.xinWeChat" }
16
+ };
17
+ /** Synchronous macOS operations, owned by the service and run in its Worker. */
18
+ var MacosDesktopHostOperations = class {
19
+ accessibility;
20
+ watches = /* @__PURE__ */ new Map();
21
+ eventListeners = /* @__PURE__ */ new Set();
22
+ constructor(options = {}) {
23
+ this.accessibility = options.accessibility ?? new MacosAccessibilityService();
24
+ this.openExternal = options.openExternal ?? openSystemSettings;
25
+ }
26
+ openExternal;
27
+ status = async () => ({
28
+ online: true,
29
+ platform: process.platform,
30
+ protocolVersion: 1,
31
+ supportedAccess: this.accessibility.supported ? [
32
+ "ui.read",
33
+ "ui.observe",
34
+ "ui.write",
35
+ "input.pointer",
36
+ "input.keyboard",
37
+ ...this.accessibility.getScreenCapturePermission() === "not_supported" ? [] : ["screen.capture-window"]
38
+ ] : [],
39
+ supportedOperations: this.accessibility.supported ? [
40
+ "host.status",
41
+ "host.application.resolve",
42
+ "host.permissions.get",
43
+ "host.permissions.request",
44
+ "host.permissions.openSettings",
45
+ "host.ui.snapshot",
46
+ "host.ui.observe",
47
+ "host.ui.unobserve",
48
+ "host.ui.action",
49
+ "host.input.click",
50
+ "host.input.typeText",
51
+ "host.input.pressKey",
52
+ ...this.accessibility.getScreenCapturePermission() === "not_supported" ? [] : ["host.screen.captureWindow"]
53
+ ] : ["host.status"],
54
+ permissions: this.permissions()
55
+ });
56
+ invoke = async (method, payload, _caller) => await this.invokeMethod(method, payload);
57
+ onEvent = (listener) => {
58
+ this.eventListeners.add(listener);
59
+ return () => this.eventListeners.delete(listener);
60
+ };
61
+ dispose = async () => {
62
+ for (const watchId of [...this.watches.keys()]) this.unobserve(watchId);
63
+ this.eventListeners.clear();
64
+ };
65
+ invokeMethod = async (method, payload) => {
66
+ if (method === "host.hello") return { protocolVersion: 1 };
67
+ if (method === "host.status") return await this.status();
68
+ if (method === "host.permissions.get") return this.permissions();
69
+ if (method === "host.permissions.request") return {
70
+ accessibility: this.accessibility.requestPermission(),
71
+ screenCapture: this.accessibility.requestScreenCapturePermission()
72
+ };
73
+ if (method === "host.permissions.openSettings") return await this.openSettings();
74
+ if (method === "host.application.resolve") return this.resolveTarget(asRecord(payload.target));
75
+ if (method === "host.ui.unobserve") return { stopped: this.unobserve(requiredString(payload.watchId, "watchId")) };
76
+ const bundleId = requiredString(asRecord(payload.target).bundleId, "target.bundleId");
77
+ const locator = readTargetLocator(payload.locator, bundleId);
78
+ if (method === "host.ui.snapshot") return await this.snapshot(bundleId, payload, locator);
79
+ if (method === "host.screen.captureWindow") return await this.captureWindow(bundleId, payload, locator);
80
+ if (method === "host.ui.action") return await this.performAction(bundleId, payload, locator);
81
+ if (method === "host.input.click") return await this.clickAt(bundleId, payload, locator);
82
+ if (method === "host.input.typeText") return await this.typeText(bundleId, payload, locator);
83
+ if (method === "host.input.pressKey") return await this.pressKey(bundleId, payload, locator);
84
+ if (method === "host.ui.observe") return this.observe(bundleId, payload);
85
+ throw hostError("operation_not_supported", `Desktop host method is not supported: ${method}`);
86
+ };
87
+ permissions = () => ({
88
+ accessibility: this.accessibility.getPermission(),
89
+ screenCapture: this.accessibility.getScreenCapturePermission()
90
+ });
91
+ openSettings = async () => {
92
+ await this.openExternal("x-apple.systempreferences:com.apple.preference.security?Privacy_Accessibility");
93
+ return { opened: true };
94
+ };
95
+ resolveTarget = (target) => {
96
+ const applicationId = requiredString(target.applicationId, "target.applicationId");
97
+ if (process.platform !== "darwin") throw hostError("unsupported_platform", `Desktop automation is not implemented for ${process.platform}.`);
98
+ const descriptor = APPLICATIONS[applicationId];
99
+ if (!descriptor) throw hostError("operation_not_supported", `Desktop application is not registered: ${applicationId}`);
100
+ this.accessibility.resolveApplication(descriptor.bundleId);
101
+ return {
102
+ platform: "darwin",
103
+ applicationId,
104
+ bundleId: descriptor.bundleId
105
+ };
106
+ };
107
+ snapshot = async (bundleId, payload, locator) => {
108
+ const resolved = await this.resolveExecutionTarget(bundleId, locator);
109
+ return {
110
+ ...this.accessibility.snapshot(bundleId, {
111
+ ...readSnapshotOptions(payload),
112
+ pid: resolved.pid
113
+ }),
114
+ targetLocator: resolved
115
+ };
116
+ };
117
+ captureWindow = async (bundleId, payload, locator) => {
118
+ const detail = payload.detail === "low" || payload.detail === "high" ? payload.detail : void 0;
119
+ const capture = await this.accessibility.captureApplicationWindow(bundleId, {
120
+ ...locator ? { pid: locator.pid } : {},
121
+ ...detail ? { detail } : {}
122
+ });
123
+ if (locator && capture.windowId !== locator.windowId) throw hostError("stale_target", "The target window changed after the state was captured. Refresh state before acting.");
124
+ const resolved = {
125
+ bundleId,
126
+ pid: capture.pid,
127
+ windowId: capture.windowId,
128
+ window: capture.window
129
+ };
130
+ const ocrText = detail ? this.accessibility.recognizeText(capture.data, { detail }) : this.accessibility.recognizeText(capture.data);
131
+ return {
132
+ target: resolved,
133
+ window: resolved.window,
134
+ ...ocrText ? { ocrText } : {},
135
+ image: {
136
+ type: "image",
137
+ mimeType: capture.mimeType,
138
+ data: capture.data,
139
+ ...capture.width && capture.height ? {
140
+ width: capture.width,
141
+ height: capture.height
142
+ } : {},
143
+ ...payload.detail === "low" || payload.detail === "high" ? { detail: payload.detail } : {}
144
+ }
145
+ };
146
+ };
147
+ performAction = async (bundleId, payload, locator) => {
148
+ const resolved = await this.resolveExecutionTarget(bundleId, locator);
149
+ const action = asRecord(payload.action);
150
+ return this.accessibility.performAction(bundleId, {
151
+ path: readPath(action.path),
152
+ type: requiredString(action.type, "action.type"),
153
+ ...typeof action.value === "string" ? { value: action.value } : {},
154
+ pid: resolved.pid,
155
+ windowId: resolved.windowId
156
+ });
157
+ };
158
+ clickAt = async (bundleId, payload, locator) => {
159
+ const resolved = await this.resolveExecutionTarget(bundleId, locator);
160
+ const coordinate = asRecord(payload.coordinate);
161
+ const x = requiredFiniteNumber(coordinate.x, "coordinate.x");
162
+ const y = requiredFiniteNumber(coordinate.y, "coordinate.y");
163
+ if (!contains(readCapturedWindow(payload.window), x, y)) throw hostError("operation_not_supported", "Pointer input must remain inside the captured target window.");
164
+ return this.accessibility.clickAt(bundleId, {
165
+ x,
166
+ y,
167
+ pid: resolved.pid,
168
+ windowId: resolved.windowId
169
+ });
170
+ };
171
+ typeText = async (bundleId, payload, locator) => {
172
+ const resolved = await this.resolveExecutionTarget(bundleId, locator);
173
+ return this.accessibility.typeText(bundleId, {
174
+ text: requiredString(payload.text, "text"),
175
+ pid: resolved.pid,
176
+ windowId: resolved.windowId
177
+ });
178
+ };
179
+ pressKey = async (bundleId, payload, locator) => {
180
+ const resolved = await this.resolveExecutionTarget(bundleId, locator);
181
+ return this.accessibility.pressKey(bundleId, {
182
+ key: requiredString(payload.key, "key"),
183
+ ...payload.modifiers === void 0 ? {} : { modifiers: readKeyModifiers(payload.modifiers) },
184
+ pid: resolved.pid,
185
+ windowId: resolved.windowId
186
+ });
187
+ };
188
+ resolveExecutionTarget = async (bundleId, locator) => {
189
+ const resolved = locator ? await this.accessibility.resolveCaptureWindow(bundleId, { pid: locator.pid }) : this.accessibility.resolveWindow(bundleId);
190
+ if (locator && resolved.windowId !== locator.windowId) throw hostError("stale_target", "The target window changed after the state was captured. Refresh state before acting.");
191
+ return {
192
+ bundleId,
193
+ pid: resolved.pid,
194
+ windowId: resolved.windowId,
195
+ window: resolved.window
196
+ };
197
+ };
198
+ observe = (bundleId, payload) => {
199
+ const watchId = randomUUID();
200
+ const snapshotOptions = readSnapshotOptions(payload);
201
+ const observer = this.accessibility.observe(bundleId, (nativeEvent) => {
202
+ if (!this.watches.has(watchId)) return;
203
+ const event = {
204
+ protocolVersion: 1,
205
+ type: "host.event",
206
+ watchId,
207
+ event: {
208
+ type: "snapshotChanged",
209
+ notification: nativeEvent.notification,
210
+ snapshot: this.accessibility.snapshot(bundleId, snapshotOptions),
211
+ occurredAt: (/* @__PURE__ */ new Date()).toISOString()
212
+ }
213
+ };
214
+ for (const listener of this.eventListeners) listener(event);
215
+ });
216
+ this.watches.set(watchId, observer);
217
+ return { watchId };
218
+ };
219
+ unobserve = (watchId) => {
220
+ const watch = this.watches.get(watchId);
221
+ if (!watch) return false;
222
+ this.watches.delete(watchId);
223
+ return watch.stop();
224
+ };
225
+ };
226
+ /**
227
+ * Kernel-facing host. The Worker is an internal service thread, not a separate
228
+ * process or daemon; it prevents synchronous AX calls from blocking 5174.
229
+ */
230
+ var MacosDesktopHostService = class {
231
+ worker = null;
232
+ listeners = /* @__PURE__ */ new Set();
233
+ pending = /* @__PURE__ */ new Map();
234
+ status = async () => await this.invoke("host.status", {}, {});
235
+ invoke = async (method, payload, caller) => await new Promise((resolve, reject) => {
236
+ const worker = this.requireWorker();
237
+ const requestId = randomUUID();
238
+ const timeout = setTimeout(() => {
239
+ const pending = this.pending.get(requestId);
240
+ if (!pending) return;
241
+ this.pending.delete(requestId);
242
+ this.resetWorker(pending.worker);
243
+ reject(hostError("host_operation_failed", "Desktop operation timed out; the service recovered its local worker."));
244
+ }, HOST_OPERATION_TIMEOUT_MS);
245
+ timeout.unref?.();
246
+ this.pending.set(requestId, {
247
+ resolve: (value) => resolve(value),
248
+ reject,
249
+ timeout,
250
+ worker
251
+ });
252
+ worker.postMessage({
253
+ type: "invoke",
254
+ requestId,
255
+ method,
256
+ payload,
257
+ caller
258
+ });
259
+ });
260
+ onEvent = (listener) => {
261
+ this.listeners.add(listener);
262
+ return () => this.listeners.delete(listener);
263
+ };
264
+ dispose = async () => await this.resetWorker();
265
+ requireWorker = () => {
266
+ if (this.worker) return this.worker;
267
+ const worker = new Worker(import.meta.url.endsWith(".ts") ? new URL("../../../dist/services/desktop/macos-desktop-host-worker.service.js", import.meta.url) : new URL("./macos-desktop-host-worker.service.js", import.meta.url));
268
+ worker.on("message", (message) => this.handleWorkerMessage(worker, message));
269
+ worker.on("error", (error) => this.rejectPending(worker, error));
270
+ worker.on("exit", (code) => {
271
+ if (this.worker === worker) this.worker = null;
272
+ if (code !== 0) this.rejectPending(worker, hostError("host_operation_failed", `Desktop worker exited unexpectedly (${code}).`));
273
+ });
274
+ this.worker = worker;
275
+ return worker;
276
+ };
277
+ handleWorkerMessage = (worker, message) => {
278
+ if (message.type === "event") {
279
+ if (this.worker !== worker) return;
280
+ for (const listener of this.listeners) listener(message.event);
281
+ return;
282
+ }
283
+ const pending = this.pending.get(message.requestId);
284
+ if (!pending || pending.worker !== worker) return;
285
+ this.pending.delete(message.requestId);
286
+ clearTimeout(pending.timeout);
287
+ if (message.type === "result") pending.resolve(message.result);
288
+ else pending.reject(Object.assign(new Error(message.error.message), message.error));
289
+ };
290
+ resetWorker = async (worker = this.worker) => {
291
+ if (!worker) return;
292
+ if (this.worker === worker) this.worker = null;
293
+ if (worker) await worker.terminate();
294
+ this.rejectPending(worker, hostError("desktop_host_unavailable", "Desktop worker is unavailable."));
295
+ };
296
+ rejectPending = (worker, error) => {
297
+ for (const [requestId, pending] of this.pending) {
298
+ if (pending.worker !== worker) continue;
299
+ this.pending.delete(requestId);
300
+ clearTimeout(pending.timeout);
301
+ pending.reject(error);
302
+ }
303
+ };
304
+ };
305
+ async function openSystemSettings(url) {
306
+ if (process.platform !== "darwin") throw hostError("unsupported_platform", "Opening Desktop settings is only supported on macOS.");
307
+ await open("open", [url]);
308
+ }
309
+ function asRecord(value) {
310
+ return value && typeof value === "object" && !Array.isArray(value) ? value : {};
311
+ }
312
+ function requiredString(value, field) {
313
+ if (typeof value !== "string" || !value.trim()) throw hostError("host_operation_failed", `${field} is required.`);
314
+ return value.trim();
315
+ }
316
+ function requiredFiniteNumber(value, field) {
317
+ if (typeof value !== "number" || !Number.isFinite(value)) throw hostError("host_operation_failed", `${field} must be finite.`);
318
+ return value;
319
+ }
320
+ function readKeyModifiers(value) {
321
+ if (!Array.isArray(value) || !value.every((modifier) => typeof modifier === "string")) throw hostError("host_operation_failed", "modifiers must be an array of strings.");
322
+ return value;
323
+ }
324
+ function readPath(value) {
325
+ if (!Array.isArray(value) || !value.every((item) => Number.isInteger(item) && item >= 0)) throw hostError("host_operation_failed", "action.path must contain non-negative integer indexes.");
326
+ return value;
327
+ }
328
+ function readSnapshotOptions(payload) {
329
+ return {
330
+ ...Number.isInteger(payload.maxDepth) ? { maxDepth: payload.maxDepth } : {},
331
+ ...Number.isInteger(payload.maxNodes) ? { maxNodes: payload.maxNodes } : {}
332
+ };
333
+ }
334
+ function readCapturedWindow(value) {
335
+ const window = asRecord(value);
336
+ const position = asRecord(window.position);
337
+ const size = asRecord(window.size);
338
+ return {
339
+ position: {
340
+ x: requiredFiniteNumber(position.x, "window.position.x"),
341
+ y: requiredFiniteNumber(position.y, "window.position.y")
342
+ },
343
+ size: {
344
+ width: requiredFiniteNumber(size.width, "window.size.width"),
345
+ height: requiredFiniteNumber(size.height, "window.size.height")
346
+ }
347
+ };
348
+ }
349
+ function contains(window, x, y) {
350
+ return x >= window.position.x && y >= window.position.y && x <= window.position.x + window.size.width && y <= window.position.y + window.size.height;
351
+ }
352
+ function hostError(code, message) {
353
+ const error = new Error(message);
354
+ Object.assign(error, { code });
355
+ return error;
356
+ }
357
+ function readTargetLocator(value, bundleId) {
358
+ if (!value || typeof value !== "object" || Array.isArray(value)) return void 0;
359
+ const locator = value;
360
+ if (locator.bundleId !== bundleId) return void 0;
361
+ const pid = locator.pid;
362
+ const windowId = locator.windowId;
363
+ if (!isPositiveInteger(pid) || !isPositiveInteger(windowId)) return void 0;
364
+ return {
365
+ bundleId,
366
+ pid,
367
+ windowId
368
+ };
369
+ }
370
+ function isPositiveInteger(value) {
371
+ return typeof value === "number" && Number.isInteger(value) && value > 0;
372
+ }
373
+ //#endregion
374
+ export { MacosDesktopHostOperations, MacosDesktopHostService };
375
+
376
+ //# sourceMappingURL=macos-desktop-host.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"macos-desktop-host.service.js","names":[],"sources":["../../../src/services/desktop/macos-desktop-host.service.ts"],"sourcesContent":["import { execFile } from \"node:child_process\";\nimport { randomUUID } from \"node:crypto\";\nimport { promisify } from \"node:util\";\nimport { Worker } from \"node:worker_threads\";\nimport type {\n DesktopHost,\n DesktopHostEventListener,\n} from \"@nextclaw/kernel\";\nimport type {\n DesktopCapabilityError,\n DesktopHostCaller,\n DesktopHostEvent,\n DesktopHostMethod,\n DesktopHostStatus,\n ResolvedDesktopApplicationTarget,\n} from \"@nextclaw/kernel\";\nimport { MacosAccessibilityService } from \"@nextclaw-service/services/desktop/macos-accessibility.service.js\";\n\nconst open = promisify(execFile);\n// A full-resolution Vision OCR can legitimately take around ten seconds. Keep\n// a bounded recovery path while leaving enough time for the 30-second REPL to\n// compose multiple read/action/read steps.\nconst HOST_OPERATION_TIMEOUT_MS = 20_000;\n\nconst APPLICATIONS: Record<string, { bundleId: string }> = {\n finder: { bundleId: \"com.apple.finder\" },\n textedit: { bundleId: \"com.apple.TextEdit\" },\n activity_monitor: { bundleId: \"com.apple.ActivityMonitor\" },\n system_settings: { bundleId: \"com.apple.systempreferences\" },\n chrome: { bundleId: \"com.google.Chrome\" },\n wechat: { bundleId: \"com.tencent.xinWeChat\" },\n};\n\ntype Watch = { stop: () => boolean };\ntype TargetLocator = { bundleId: string; pid: number; windowId: number };\ntype ResolvedExecutionTarget = TargetLocator & {\n window: { title?: string; position?: { x: number; y: number }; size?: { width: number; height?: number } };\n};\n\n/** Synchronous macOS operations, owned by the service and run in its Worker. */\nexport class MacosDesktopHostOperations {\n private readonly accessibility: MacosAccessibilityService;\n private readonly watches = new Map<string, Watch>();\n private readonly eventListeners = new Set<DesktopHostEventListener>();\n\n constructor(options: {\n accessibility?: MacosAccessibilityService;\n openExternal?: (url: string) => Promise<void>;\n } = {}) {\n this.accessibility = options.accessibility ?? new MacosAccessibilityService();\n this.openExternal = options.openExternal ?? openSystemSettings;\n }\n\n private readonly openExternal: (url: string) => Promise<void>;\n\n status = async (): Promise<DesktopHostStatus> => ({\n online: true,\n platform: process.platform,\n protocolVersion: 1,\n supportedAccess: (this.accessibility.supported\n ? [\"ui.read\", \"ui.observe\", \"ui.write\", \"input.pointer\", \"input.keyboard\",\n ...(this.accessibility.getScreenCapturePermission() === \"not_supported\" ? [] : [\"screen.capture-window\"])]\n : []) as DesktopHostStatus[\"supportedAccess\"],\n supportedOperations: (this.accessibility.supported\n ? [\"host.status\", \"host.application.resolve\", \"host.permissions.get\", \"host.permissions.request\",\n \"host.permissions.openSettings\", \"host.ui.snapshot\", \"host.ui.observe\", \"host.ui.unobserve\",\n \"host.ui.action\", \"host.input.click\", \"host.input.typeText\", \"host.input.pressKey\",\n ...(this.accessibility.getScreenCapturePermission() === \"not_supported\" ? [] : [\"host.screen.captureWindow\"])]\n : [\"host.status\"]) as DesktopHostStatus[\"supportedOperations\"],\n permissions: this.permissions(),\n });\n\n invoke = async <T>(\n method: DesktopHostMethod,\n payload: Record<string, unknown>,\n _caller: DesktopHostCaller,\n ): Promise<T> => await this.invokeMethod(method, payload) as T;\n\n onEvent = (listener: DesktopHostEventListener): (() => void) => {\n this.eventListeners.add(listener);\n return () => this.eventListeners.delete(listener);\n };\n\n dispose = async (): Promise<void> => {\n for (const watchId of [...this.watches.keys()]) this.unobserve(watchId);\n this.eventListeners.clear();\n };\n\n private invokeMethod = async (method: DesktopHostMethod, payload: Record<string, unknown>): Promise<unknown> => {\n if (method === \"host.hello\") return { protocolVersion: 1 };\n if (method === \"host.status\") return await this.status();\n if (method === \"host.permissions.get\") return this.permissions();\n if (method === \"host.permissions.request\") return {\n accessibility: this.accessibility.requestPermission(),\n screenCapture: this.accessibility.requestScreenCapturePermission(),\n };\n if (method === \"host.permissions.openSettings\") return await this.openSettings();\n if (method === \"host.application.resolve\") return this.resolveTarget(asRecord(payload.target));\n if (method === \"host.ui.unobserve\") return { stopped: this.unobserve(requiredString(payload.watchId, \"watchId\")) };\n\n const bundleId = requiredString(asRecord(payload.target).bundleId, \"target.bundleId\");\n const locator = readTargetLocator(payload.locator, bundleId);\n if (method === \"host.ui.snapshot\") return await this.snapshot(bundleId, payload, locator);\n if (method === \"host.screen.captureWindow\") return await this.captureWindow(bundleId, payload, locator);\n if (method === \"host.ui.action\") return await this.performAction(bundleId, payload, locator);\n if (method === \"host.input.click\") return await this.clickAt(bundleId, payload, locator);\n if (method === \"host.input.typeText\") return await this.typeText(bundleId, payload, locator);\n if (method === \"host.input.pressKey\") return await this.pressKey(bundleId, payload, locator);\n if (method === \"host.ui.observe\") return this.observe(bundleId, payload);\n throw hostError(\"operation_not_supported\", `Desktop host method is not supported: ${method}`);\n };\n\n private permissions = () => ({\n accessibility: this.accessibility.getPermission(),\n screenCapture: this.accessibility.getScreenCapturePermission(),\n });\n\n private openSettings = async (): Promise<{ opened: true }> => {\n await this.openExternal(\"x-apple.systempreferences:com.apple.preference.security?Privacy_Accessibility\");\n return { opened: true };\n };\n\n private resolveTarget = (target: Record<string, unknown>): ResolvedDesktopApplicationTarget => {\n const applicationId = requiredString(target.applicationId, \"target.applicationId\");\n if (process.platform !== \"darwin\") {\n throw hostError(\"unsupported_platform\", `Desktop automation is not implemented for ${process.platform}.`);\n }\n const descriptor = APPLICATIONS[applicationId];\n if (!descriptor) throw hostError(\"operation_not_supported\", `Desktop application is not registered: ${applicationId}`);\n this.accessibility.resolveApplication(descriptor.bundleId);\n return { platform: \"darwin\", applicationId, bundleId: descriptor.bundleId };\n };\n\n private snapshot = async (\n bundleId: string,\n payload: Record<string, unknown>,\n locator?: TargetLocator,\n ) => {\n const resolved = await this.resolveExecutionTarget(bundleId, locator);\n return {\n ...this.accessibility.snapshot(bundleId, { ...readSnapshotOptions(payload), pid: resolved.pid }),\n targetLocator: resolved,\n };\n };\n\n private captureWindow = async (\n bundleId: string,\n payload: Record<string, unknown>,\n locator?: TargetLocator,\n ) => {\n const detail = payload.detail === \"low\" || payload.detail === \"high\" ? payload.detail : undefined;\n const capture = await this.accessibility.captureApplicationWindow(bundleId, {\n ...(locator ? { pid: locator.pid } : {}),\n ...(detail ? { detail } : {}),\n });\n if (locator && capture.windowId !== locator.windowId) {\n throw hostError(\"stale_target\", \"The target window changed after the state was captured. Refresh state before acting.\");\n }\n const resolved: ResolvedExecutionTarget = {\n bundleId,\n pid: capture.pid,\n windowId: capture.windowId,\n window: capture.window,\n };\n const ocrText = detail\n ? this.accessibility.recognizeText(capture.data, { detail })\n : this.accessibility.recognizeText(capture.data);\n return {\n target: resolved,\n window: resolved.window,\n ...(ocrText ? { ocrText } : {}),\n image: {\n type: \"image\",\n mimeType: capture.mimeType,\n data: capture.data,\n ...(capture.width && capture.height ? { width: capture.width, height: capture.height } : {}),\n ...(payload.detail === \"low\" || payload.detail === \"high\" ? { detail: payload.detail } : {}),\n },\n };\n };\n\n private performAction = async (bundleId: string, payload: Record<string, unknown>, locator?: TargetLocator) => {\n const resolved = await this.resolveExecutionTarget(bundleId, locator);\n const action = asRecord(payload.action);\n return this.accessibility.performAction(bundleId, {\n path: readPath(action.path),\n type: requiredString(action.type, \"action.type\") as \"setValue\" | \"press\" | \"confirm\",\n ...(typeof action.value === \"string\" ? { value: action.value } : {}),\n pid: resolved.pid,\n windowId: resolved.windowId,\n });\n };\n\n private clickAt = async (bundleId: string, payload: Record<string, unknown>, locator?: TargetLocator) => {\n const resolved = await this.resolveExecutionTarget(bundleId, locator);\n const coordinate = asRecord(payload.coordinate);\n const x = requiredFiniteNumber(coordinate.x, \"coordinate.x\");\n const y = requiredFiniteNumber(coordinate.y, \"coordinate.y\");\n const window = readCapturedWindow(payload.window);\n if (!contains(window, x, y)) throw hostError(\"operation_not_supported\", \"Pointer input must remain inside the captured target window.\");\n return this.accessibility.clickAt(bundleId, { x, y, pid: resolved.pid, windowId: resolved.windowId });\n };\n\n private typeText = async (bundleId: string, payload: Record<string, unknown>, locator?: TargetLocator) => {\n const resolved = await this.resolveExecutionTarget(bundleId, locator);\n return this.accessibility.typeText(bundleId, {\n text: requiredString(payload.text, \"text\"),\n pid: resolved.pid,\n windowId: resolved.windowId,\n });\n };\n\n private pressKey = async (bundleId: string, payload: Record<string, unknown>, locator?: TargetLocator) => {\n const resolved = await this.resolveExecutionTarget(bundleId, locator);\n return this.accessibility.pressKey(bundleId, {\n key: requiredString(payload.key, \"key\"),\n ...(payload.modifiers === undefined ? {} : { modifiers: readKeyModifiers(payload.modifiers) }),\n pid: resolved.pid,\n windowId: resolved.windowId,\n });\n };\n\n private resolveExecutionTarget = async (bundleId: string, locator?: TargetLocator): Promise<ResolvedExecutionTarget> => {\n const resolved = locator\n ? await this.accessibility.resolveCaptureWindow(bundleId, { pid: locator.pid })\n : this.accessibility.resolveWindow(bundleId);\n if (locator && resolved.windowId !== locator.windowId) {\n throw hostError(\"stale_target\", \"The target window changed after the state was captured. Refresh state before acting.\");\n }\n return { bundleId, pid: resolved.pid, windowId: resolved.windowId, window: resolved.window };\n };\n\n private observe = (bundleId: string, payload: Record<string, unknown>): { watchId: string } => {\n const watchId = randomUUID();\n const snapshotOptions = readSnapshotOptions(payload);\n const observer = this.accessibility.observe(bundleId, (nativeEvent) => {\n if (!this.watches.has(watchId)) return;\n const event: DesktopHostEvent = {\n protocolVersion: 1,\n type: \"host.event\",\n watchId,\n event: {\n type: \"snapshotChanged\",\n notification: nativeEvent.notification,\n snapshot: this.accessibility.snapshot(bundleId, snapshotOptions),\n occurredAt: new Date().toISOString(),\n },\n };\n for (const listener of this.eventListeners) listener(event);\n });\n this.watches.set(watchId, observer);\n return { watchId };\n };\n\n private unobserve = (watchId: string): boolean => {\n const watch = this.watches.get(watchId);\n if (!watch) return false;\n this.watches.delete(watchId);\n return watch.stop();\n };\n}\n\ntype WorkerMessage =\n | { type: \"result\"; requestId: string; result: unknown }\n | { type: \"error\"; requestId: string; error: DesktopCapabilityError }\n | { type: \"event\"; event: DesktopHostEvent };\n\n/**\n * Kernel-facing host. The Worker is an internal service thread, not a separate\n * process or daemon; it prevents synchronous AX calls from blocking 5174.\n */\nexport class MacosDesktopHostService implements DesktopHost {\n private worker: Worker | null = null;\n private readonly listeners = new Set<DesktopHostEventListener>();\n private readonly pending = new Map<string, {\n resolve: (value: unknown) => void;\n reject: (error: Error) => void;\n timeout: NodeJS.Timeout;\n worker: Worker;\n }>();\n\n status = async (): Promise<DesktopHostStatus> =>\n await this.invoke<DesktopHostStatus>(\"host.status\", {}, {});\n\n invoke = async <T>(\n method: DesktopHostMethod,\n payload: Record<string, unknown>,\n caller: DesktopHostCaller,\n ): Promise<T> => await new Promise<T>((resolve, reject) => {\n const worker = this.requireWorker();\n const requestId = randomUUID();\n const timeout = setTimeout(() => {\n const pending = this.pending.get(requestId);\n if (!pending) return;\n this.pending.delete(requestId);\n void this.resetWorker(pending.worker);\n reject(hostError(\"host_operation_failed\", \"Desktop operation timed out; the service recovered its local worker.\"));\n }, HOST_OPERATION_TIMEOUT_MS);\n timeout.unref?.();\n this.pending.set(requestId, { resolve: (value) => resolve(value as T), reject, timeout, worker });\n worker.postMessage({ type: \"invoke\", requestId, method, payload, caller });\n });\n\n onEvent = (listener: DesktopHostEventListener): (() => void) => {\n this.listeners.add(listener);\n return () => this.listeners.delete(listener);\n };\n\n dispose = async (): Promise<void> => await this.resetWorker();\n\n private requireWorker = (): Worker => {\n if (this.worker) return this.worker;\n const workerUrl = import.meta.url.endsWith(\".ts\")\n ? new URL(\"../../../dist/services/desktop/macos-desktop-host-worker.service.js\", import.meta.url)\n : new URL(\"./macos-desktop-host-worker.service.js\", import.meta.url);\n const worker = new Worker(workerUrl);\n worker.on(\"message\", (message: WorkerMessage) => this.handleWorkerMessage(worker, message));\n worker.on(\"error\", (error) => this.rejectPending(worker, error));\n worker.on(\"exit\", (code) => {\n if (this.worker === worker) this.worker = null;\n if (code !== 0) this.rejectPending(worker, hostError(\"host_operation_failed\", `Desktop worker exited unexpectedly (${code}).`));\n });\n this.worker = worker;\n return worker;\n };\n\n private handleWorkerMessage = (worker: Worker, message: WorkerMessage): void => {\n if (message.type === \"event\") {\n if (this.worker !== worker) return;\n for (const listener of this.listeners) listener(message.event);\n return;\n }\n const pending = this.pending.get(message.requestId);\n if (!pending || pending.worker !== worker) return;\n this.pending.delete(message.requestId);\n clearTimeout(pending.timeout);\n if (message.type === \"result\") pending.resolve(message.result);\n else pending.reject(Object.assign(new Error(message.error.message), message.error));\n };\n\n private resetWorker = async (worker = this.worker): Promise<void> => {\n if (!worker) return;\n if (this.worker === worker) this.worker = null;\n if (worker) await worker.terminate();\n this.rejectPending(worker, hostError(\"desktop_host_unavailable\", \"Desktop worker is unavailable.\"));\n };\n\n private rejectPending = (worker: Worker, error: Error): void => {\n for (const [requestId, pending] of this.pending) {\n if (pending.worker !== worker) continue;\n this.pending.delete(requestId);\n clearTimeout(pending.timeout);\n pending.reject(error);\n }\n };\n}\n\nasync function openSystemSettings(url: string): Promise<void> {\n if (process.platform !== \"darwin\") throw hostError(\"unsupported_platform\", \"Opening Desktop settings is only supported on macOS.\");\n await open(\"open\", [url]);\n}\n\nfunction asRecord(value: unknown): Record<string, unknown> {\n return value && typeof value === \"object\" && !Array.isArray(value) ? value as Record<string, unknown> : {};\n}\n\nfunction requiredString(value: unknown, field: string): string {\n if (typeof value !== \"string\" || !value.trim()) throw hostError(\"host_operation_failed\", `${field} is required.`);\n return value.trim();\n}\n\nfunction requiredFiniteNumber(value: unknown, field: string): number {\n if (typeof value !== \"number\" || !Number.isFinite(value)) throw hostError(\"host_operation_failed\", `${field} must be finite.`);\n return value;\n}\n\nfunction readKeyModifiers(value: unknown): string[] {\n if (!Array.isArray(value) || !value.every((modifier) => typeof modifier === \"string\")) {\n throw hostError(\"host_operation_failed\", \"modifiers must be an array of strings.\");\n }\n return value;\n}\n\nfunction readPath(value: unknown): number[] {\n if (!Array.isArray(value) || !value.every((item) => Number.isInteger(item) && item >= 0)) {\n throw hostError(\"host_operation_failed\", \"action.path must contain non-negative integer indexes.\");\n }\n return value as number[];\n}\n\nfunction readSnapshotOptions(payload: Record<string, unknown>): { maxDepth?: number; maxNodes?: number } {\n return {\n ...(Number.isInteger(payload.maxDepth) ? { maxDepth: payload.maxDepth as number } : {}),\n ...(Number.isInteger(payload.maxNodes) ? { maxNodes: payload.maxNodes as number } : {}),\n };\n}\n\nfunction readCapturedWindow(value: unknown): { position: { x: number; y: number }; size: { width: number; height: number } } {\n const window = asRecord(value);\n const position = asRecord(window.position);\n const size = asRecord(window.size);\n return {\n position: { x: requiredFiniteNumber(position.x, \"window.position.x\"), y: requiredFiniteNumber(position.y, \"window.position.y\") },\n size: { width: requiredFiniteNumber(size.width, \"window.size.width\"), height: requiredFiniteNumber(size.height, \"window.size.height\") },\n };\n}\n\nfunction contains(window: { position: { x: number; y: number }; size: { width: number; height: number } }, x: number, y: number): boolean {\n return x >= window.position.x && y >= window.position.y && x <= window.position.x + window.size.width && y <= window.position.y + window.size.height;\n}\n\nfunction hostError(code: DesktopCapabilityError[\"code\"], message: string): Error {\n const error = new Error(message);\n Object.assign(error, { code });\n return error;\n}\n\nfunction readTargetLocator(value: unknown, bundleId: string): TargetLocator | undefined {\n if (!value || typeof value !== \"object\" || Array.isArray(value)) return undefined;\n const locator = value as Record<string, unknown>;\n if (locator.bundleId !== bundleId) return undefined;\n const pid = locator.pid;\n const windowId = locator.windowId;\n if (!isPositiveInteger(pid) || !isPositiveInteger(windowId)) return undefined;\n return { bundleId, pid, windowId };\n}\n\nfunction isPositiveInteger(value: unknown): value is number {\n return typeof value === \"number\" && Number.isInteger(value) && value > 0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AAM;GAAE,OAAO,qBAAqB,KAAK,OAAO,oBAAoB;GAAE,QAAQ,qBAAqB,KAAK,QAAQ,qBAAqB;GAAE;EACxI;;AAGH,SAAS,SAAS,QAAyF,GAAW,GAAoB;AACxI,QAAO,KAAK,OAAO,SAAS,KAAK,KAAK,OAAO,SAAS,KAAK,KAAK,OAAO,SAAS,IAAI,OAAO,KAAK,SAAS,KAAK,OAAO,SAAS,IAAI,OAAO,KAAK;;AAGhJ,SAAS,UAAU,MAAsC,SAAwB;CAC/E,MAAM,QAAQ,IAAI,MAAM,QAAQ;AAChC,QAAO,OAAO,OAAO,EAAE,MAAM,CAAC;AAC9B,QAAO;;AAGT,SAAS,kBAAkB,OAAgB,UAA6C;AACtF,KAAI,CAAC,SAAS,OAAO,UAAU,YAAY,MAAM,QAAQ,MAAM,CAAE,QAAO,KAAA;CACxE,MAAM,UAAU;AAChB,KAAI,QAAQ,aAAa,SAAU,QAAO,KAAA;CAC1C,MAAM,MAAM,QAAQ;CACpB,MAAM,WAAW,QAAQ;AACzB,KAAI,CAAC,kBAAkB,IAAI,IAAI,CAAC,kBAAkB,SAAS,CAAE,QAAO,KAAA;AACpE,QAAO;EAAE;EAAU;EAAK;EAAU;;AAGpC,SAAS,kBAAkB,OAAiC;AAC1D,QAAO,OAAO,UAAU,YAAY,OAAO,UAAU,MAAM,IAAI,QAAQ"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nextclaw/service",
3
- "version": "0.3.47",
3
+ "version": "0.3.49",
4
4
  "private": false,
5
5
  "description": "NextClaw long-running service host and runtime lifecycle.",
6
6
  "type": "module",
@@ -42,31 +42,31 @@
42
42
  "chokidar": "^3.6.0",
43
43
  "commander": "^12.1.0",
44
44
  "jszip": "^3.10.1",
45
- "@nextclaw/channel-extension-dingtalk": "0.2.35",
46
- "@nextclaw/channel-extension-discord": "0.2.35",
47
- "@nextclaw/channel-extension-feishu": "0.2.29",
48
- "@nextclaw/channel-extension-qq": "0.2.28",
49
- "@nextclaw/channel-extension-slack": "0.2.35",
50
- "@nextclaw/channel-extension-email": "0.2.35",
51
- "@nextclaw/channel-extension-telegram": "0.2.35",
52
- "@nextclaw/channel-extension-wecom": "0.2.35",
53
- "@nextclaw/channel-extension-weixin": "0.2.29",
54
- "@nextclaw/channel-extension-whatsapp": "0.2.35",
55
- "@nextclaw/client-sdk": "0.7.6",
56
- "@nextclaw/kernel": "0.10.2",
57
- "@nextclaw/ncp": "0.10.0",
58
- "@nextclaw/ncp-mcp": "0.2.36",
45
+ "@nextclaw/channel-extension-dingtalk": "0.2.37",
46
+ "@nextclaw/channel-extension-feishu": "0.2.30",
47
+ "@nextclaw/channel-extension-qq": "0.2.29",
48
+ "@nextclaw/channel-extension-slack": "0.2.37",
49
+ "@nextclaw/channel-extension-discord": "0.2.37",
50
+ "@nextclaw/channel-extension-email": "0.2.37",
51
+ "@nextclaw/channel-extension-telegram": "0.2.37",
52
+ "@nextclaw/channel-extension-whatsapp": "0.2.37",
53
+ "@nextclaw/channel-extension-wecom": "0.2.37",
54
+ "@nextclaw/client-sdk": "0.8.0",
55
+ "@nextclaw/channel-extension-weixin": "0.2.30",
56
+ "@nextclaw/kernel": "0.11.0",
57
+ "@nextclaw/core": "0.17.11",
58
+ "@nextclaw/mcp": "0.3.38",
59
59
  "@nextclaw/ncp-agent-runtime": "0.4.21",
60
- "@nextclaw/core": "0.17.9",
60
+ "@nextclaw/ncp": "0.10.0",
61
+ "@nextclaw/ncp-mcp": "0.2.38",
61
62
  "@nextclaw/ncp-toolkit": "0.6.23",
62
63
  "@nextclaw/nextclaw-hermes-acp-bridge": "0.3.21",
63
- "@nextclaw/mcp": "0.3.36",
64
+ "@nextclaw/nextclaw-ncp-runtime-stdio-client": "0.3.38",
65
+ "@nextclaw/remote": "0.3.46",
66
+ "@nextclaw/runtime": "0.4.37",
64
67
  "@nextclaw/nextclaw-ncp-runtime-http-client": "0.3.22",
65
- "@nextclaw/nextclaw-ncp-runtime-stdio-client": "0.3.36",
66
- "@nextclaw/remote": "0.3.44",
67
- "@nextclaw/runtime": "0.4.35",
68
- "@nextclaw/server": "0.18.2",
69
- "@nextclaw/shared": "0.4.28"
68
+ "@nextclaw/server": "0.19.0",
69
+ "@nextclaw/shared": "0.4.29"
70
70
  },
71
71
  "devDependencies": {
72
72
  "@types/node": "^20.17.6",
@@ -76,7 +76,7 @@
76
76
  "vitest": "^4.1.2"
77
77
  },
78
78
  "scripts": {
79
- "build": "tsdown \"src/**/*.ts\" \"!src/**/*.test.ts\" \"!src/**/tests/**\" --dts.sourcemap --clean --target es2022 --no-fixedExtension --unbundle",
79
+ "build": "tsdown \"src/**/*.ts\" \"!src/**/*.test.ts\" \"!src/**/tests/**\" --dts.sourcemap --clean --target es2022 --no-fixedExtension --unbundle && node ../../scripts/desktop/macos-keyboard-input.build.mjs",
80
80
  "lint": "eslint .",
81
81
  "tsc": "tsc -p tsconfig.json",
82
82
  "test": "vitest"