screenhand 0.1.1 → 0.2.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/README.md +458 -93
- package/dist/.audit-log.jsonl +55 -0
- package/dist/.screenhand/memory/.lock +1 -0
- package/dist/.screenhand/memory/actions.jsonl +85 -0
- package/dist/.screenhand/memory/errors.jsonl +5 -0
- package/dist/.screenhand/memory/errors.jsonl.bak +4 -0
- package/dist/.screenhand/memory/state.json +35 -0
- package/dist/.screenhand/memory/state.json.bak +35 -0
- package/dist/.screenhand/memory/strategies.jsonl +12 -0
- package/dist/agent/cli.js +73 -0
- package/dist/agent/loop.js +258 -0
- package/dist/config.js +9 -0
- package/dist/index.js +56 -0
- package/dist/logging/timeline-logger.js +29 -0
- package/dist/mcp/mcp-stdio-server.js +448 -0
- package/dist/mcp/server.js +347 -0
- package/dist/mcp-desktop.js +2731 -0
- package/dist/mcp-entry.js +59 -0
- package/dist/memory/recall.js +160 -0
- package/dist/memory/research.js +98 -0
- package/dist/memory/seeds.js +89 -0
- package/dist/memory/session.js +161 -0
- package/dist/memory/store.js +391 -0
- package/dist/memory/types.js +4 -0
- package/dist/monitor/codex-monitor.js +377 -0
- package/dist/monitor/task-queue.js +84 -0
- package/dist/monitor/types.js +49 -0
- package/dist/native/bridge-client.js +174 -0
- package/dist/native/macos-bridge-client.js +5 -0
- package/dist/npm-publish-helper.js +117 -0
- package/dist/npm-token-cdp.js +113 -0
- package/dist/npm-token-create.js +135 -0
- package/dist/npm-token-finish.js +126 -0
- package/dist/playbook/engine.js +193 -0
- package/dist/playbook/index.js +4 -0
- package/dist/playbook/recorder.js +519 -0
- package/dist/playbook/runner.js +392 -0
- package/dist/playbook/store.js +166 -0
- package/dist/playbook/types.js +4 -0
- package/dist/runtime/accessibility-adapter.js +377 -0
- package/dist/runtime/app-adapter.js +48 -0
- package/dist/runtime/applescript-adapter.js +283 -0
- package/dist/runtime/ax-role-map.js +80 -0
- package/dist/runtime/browser-adapter.js +36 -0
- package/dist/runtime/cdp-chrome-adapter.js +505 -0
- package/dist/runtime/composite-adapter.js +205 -0
- package/dist/runtime/executor.js +250 -0
- package/dist/runtime/locator-cache.js +12 -0
- package/dist/runtime/planning-loop.js +47 -0
- package/dist/runtime/service.js +372 -0
- package/dist/runtime/session-manager.js +28 -0
- package/dist/runtime/state-observer.js +105 -0
- package/dist/runtime/vision-adapter.js +208 -0
- package/dist/scripts/codex-monitor-daemon.js +335 -0
- package/dist/scripts/supervisor-daemon.js +272 -0
- package/dist/scripts/worker-daemon.js +228 -0
- package/dist/src/agent/cli.js +82 -0
- package/dist/src/agent/loop.js +274 -0
- package/{src/config.ts → dist/src/config.js} +5 -10
- package/{src/index.ts → dist/src/index.js} +32 -52
- package/dist/src/jobs/manager.js +237 -0
- package/dist/src/jobs/runner.js +683 -0
- package/dist/src/jobs/store.js +102 -0
- package/dist/src/jobs/types.js +30 -0
- package/dist/src/jobs/worker.js +97 -0
- package/dist/src/logging/timeline-logger.js +45 -0
- package/dist/src/mcp/mcp-stdio-server.js +464 -0
- package/dist/src/mcp/server.js +363 -0
- package/dist/src/mcp-entry.js +60 -0
- package/dist/src/memory/recall.js +170 -0
- package/dist/src/memory/research.js +104 -0
- package/dist/src/memory/seeds.js +101 -0
- package/dist/src/memory/service.js +421 -0
- package/dist/src/memory/session.js +169 -0
- package/dist/src/memory/store.js +422 -0
- package/dist/src/memory/types.js +17 -0
- package/dist/src/monitor/codex-monitor.js +382 -0
- package/dist/src/monitor/task-queue.js +97 -0
- package/dist/src/monitor/types.js +62 -0
- package/dist/src/native/bridge-client.js +190 -0
- package/{src/native/macos-bridge-client.ts → dist/src/native/macos-bridge-client.js} +0 -1
- package/dist/src/playbook/engine.js +201 -0
- package/dist/src/playbook/index.js +20 -0
- package/dist/src/playbook/recorder.js +535 -0
- package/dist/src/playbook/runner.js +408 -0
- package/dist/src/playbook/store.js +183 -0
- package/dist/src/playbook/types.js +17 -0
- package/dist/src/runtime/accessibility-adapter.js +393 -0
- package/dist/src/runtime/app-adapter.js +64 -0
- package/dist/src/runtime/applescript-adapter.js +299 -0
- package/dist/src/runtime/ax-role-map.js +96 -0
- package/dist/src/runtime/browser-adapter.js +52 -0
- package/dist/src/runtime/cdp-chrome-adapter.js +521 -0
- package/dist/src/runtime/composite-adapter.js +221 -0
- package/dist/src/runtime/execution-contract.js +159 -0
- package/dist/src/runtime/executor.js +266 -0
- package/{src/runtime/locator-cache.ts → dist/src/runtime/locator-cache.js} +10 -15
- package/dist/src/runtime/planning-loop.js +63 -0
- package/dist/src/runtime/service.js +388 -0
- package/dist/src/runtime/session-manager.js +60 -0
- package/dist/src/runtime/state-observer.js +121 -0
- package/dist/src/runtime/vision-adapter.js +224 -0
- package/dist/src/supervisor/locks.js +186 -0
- package/dist/src/supervisor/supervisor.js +403 -0
- package/dist/src/supervisor/types.js +30 -0
- package/dist/src/test-mcp-protocol.js +154 -0
- package/dist/src/types.js +17 -0
- package/dist/src/util/atomic-write.js +118 -0
- package/dist/test-mcp-protocol.js +138 -0
- package/dist/types.js +1 -0
- package/package.json +18 -4
- package/.claude/commands/automate.md +0 -28
- package/.claude/commands/debug-ui.md +0 -19
- package/.claude/commands/screenshot.md +0 -15
- package/.github/FUNDING.yml +0 -1
- package/.github/ISSUE_TEMPLATE/bug_report.md +0 -27
- package/.github/ISSUE_TEMPLATE/feature_request.md +0 -20
- package/.mcp.json +0 -8
- package/DESKTOP_MCP_GUIDE.md +0 -92
- package/SECURITY.md +0 -44
- package/docs/architecture.md +0 -47
- package/install-skills.sh +0 -19
- package/mcp-bridge.ts +0 -271
- package/mcp-desktop.ts +0 -1221
- package/native/macos-bridge/Package.swift +0 -21
- package/native/macos-bridge/Sources/AccessibilityBridge.swift +0 -261
- package/native/macos-bridge/Sources/AppManagement.swift +0 -129
- package/native/macos-bridge/Sources/CoreGraphicsBridge.swift +0 -242
- package/native/macos-bridge/Sources/ObserverBridge.swift +0 -120
- package/native/macos-bridge/Sources/VisionBridge.swift +0 -80
- package/native/macos-bridge/Sources/main.swift +0 -345
- package/native/windows-bridge/AppManagement.cs +0 -234
- package/native/windows-bridge/InputBridge.cs +0 -436
- package/native/windows-bridge/Program.cs +0 -265
- package/native/windows-bridge/ScreenCapture.cs +0 -329
- package/native/windows-bridge/UIAutomationBridge.cs +0 -571
- package/native/windows-bridge/WindowsBridge.csproj +0 -17
- package/playbooks/devpost.json +0 -186
- package/playbooks/instagram.json +0 -41
- package/playbooks/instagram_v2.json +0 -201
- package/playbooks/x_v1.json +0 -211
- package/scripts/devpost-live-loop.mjs +0 -421
- package/src/logging/timeline-logger.ts +0 -55
- package/src/mcp/server.ts +0 -449
- package/src/memory/recall.ts +0 -191
- package/src/memory/research.ts +0 -146
- package/src/memory/seeds.ts +0 -123
- package/src/memory/session.ts +0 -201
- package/src/memory/store.ts +0 -434
- package/src/memory/types.ts +0 -69
- package/src/native/bridge-client.ts +0 -239
- package/src/runtime/accessibility-adapter.ts +0 -487
- package/src/runtime/app-adapter.ts +0 -169
- package/src/runtime/applescript-adapter.ts +0 -376
- package/src/runtime/ax-role-map.ts +0 -102
- package/src/runtime/browser-adapter.ts +0 -129
- package/src/runtime/cdp-chrome-adapter.ts +0 -676
- package/src/runtime/composite-adapter.ts +0 -274
- package/src/runtime/executor.ts +0 -396
- package/src/runtime/planning-loop.ts +0 -81
- package/src/runtime/service.ts +0 -448
- package/src/runtime/session-manager.ts +0 -50
- package/src/runtime/state-observer.ts +0 -136
- package/src/runtime/vision-adapter.ts +0 -297
- package/src/types.ts +0 -297
- package/tests/bridge-client.test.ts +0 -176
- package/tests/browser-stealth.test.ts +0 -210
- package/tests/composite-adapter.test.ts +0 -64
- package/tests/mcp-server.test.ts +0 -151
- package/tests/memory-recall.test.ts +0 -339
- package/tests/memory-research.test.ts +0 -159
- package/tests/memory-seeds.test.ts +0 -120
- package/tests/memory-store.test.ts +0 -392
- package/tests/types.test.ts +0 -92
- package/tsconfig.check.json +0 -17
- package/tsconfig.json +0 -19
- package/vitest.config.ts +0 -8
|
@@ -1,239 +0,0 @@
|
|
|
1
|
-
// Copyright (C) 2025 Clazro Technology Private Limited
|
|
2
|
-
// SPDX-License-Identifier: AGPL-3.0-only
|
|
3
|
-
//
|
|
4
|
-
// This file is part of ScreenHand.
|
|
5
|
-
//
|
|
6
|
-
// ScreenHand is free software: you can redistribute it and/or modify
|
|
7
|
-
// it under the terms of the GNU Affero General Public License as
|
|
8
|
-
// published by the Free Software Foundation, version 3.
|
|
9
|
-
//
|
|
10
|
-
// ScreenHand is distributed in the hope that it will be useful,
|
|
11
|
-
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
-
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
-
// GNU Affero General Public License for more details.
|
|
14
|
-
//
|
|
15
|
-
// You should have received a copy of the GNU Affero General Public License
|
|
16
|
-
// along with ScreenHand. If not, see <https://www.gnu.org/licenses/>.
|
|
17
|
-
|
|
18
|
-
import { spawn, type ChildProcess } from "node:child_process";
|
|
19
|
-
import { EventEmitter } from "node:events";
|
|
20
|
-
import path from "node:path";
|
|
21
|
-
import { createInterface } from "node:readline";
|
|
22
|
-
|
|
23
|
-
interface JsonRpcRequest {
|
|
24
|
-
id: number;
|
|
25
|
-
method: string;
|
|
26
|
-
params?: Record<string, unknown>;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
interface JsonRpcResponse {
|
|
30
|
-
id: number;
|
|
31
|
-
result?: unknown;
|
|
32
|
-
error?: { code: number; message: string };
|
|
33
|
-
event?: Record<string, unknown>;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
interface PendingRequest {
|
|
37
|
-
resolve: (value: unknown) => void;
|
|
38
|
-
reject: (error: Error) => void;
|
|
39
|
-
timer: ReturnType<typeof setTimeout>;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Per-method timeout overrides (ms).
|
|
44
|
-
* Methods not listed here use the default 10s timeout.
|
|
45
|
-
*/
|
|
46
|
-
const METHOD_TIMEOUTS: Record<string, number> = {
|
|
47
|
-
"app.launch": 30_000,
|
|
48
|
-
"cg.captureScreen": 15_000,
|
|
49
|
-
"cg.captureWindow": 15_000,
|
|
50
|
-
"vision.ocr": 20_000,
|
|
51
|
-
"vision.findText": 20_000,
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Resolves the correct native bridge binary path for the current platform.
|
|
56
|
-
*/
|
|
57
|
-
function defaultBinaryPath(): string {
|
|
58
|
-
const base = import.meta.dirname ?? process.cwd();
|
|
59
|
-
|
|
60
|
-
if (process.platform === "win32") {
|
|
61
|
-
return path.resolve(
|
|
62
|
-
base,
|
|
63
|
-
"../../native/windows-bridge/bin/Release/net8.0-windows/windows-bridge.exe",
|
|
64
|
-
);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
// macOS (default)
|
|
68
|
-
return path.resolve(
|
|
69
|
-
base,
|
|
70
|
-
"../../native/macos-bridge/.build/release/macos-bridge",
|
|
71
|
-
);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* Platform-aware native bridge client.
|
|
76
|
-
* Spawns the correct bridge binary (macOS Swift or Windows C#) based on the OS,
|
|
77
|
-
* communicating via the same JSON-RPC-over-stdio protocol.
|
|
78
|
-
*
|
|
79
|
-
* Drop-in replacement for the original MacOSBridgeClient.
|
|
80
|
-
*/
|
|
81
|
-
export class BridgeClient extends EventEmitter {
|
|
82
|
-
private process: ChildProcess | null = null;
|
|
83
|
-
private nextId = 1;
|
|
84
|
-
private pending = new Map<number, PendingRequest>();
|
|
85
|
-
private readonly binaryPath: string;
|
|
86
|
-
private restarting = false;
|
|
87
|
-
private started = false;
|
|
88
|
-
|
|
89
|
-
constructor(binaryPath?: string) {
|
|
90
|
-
super();
|
|
91
|
-
this.binaryPath = binaryPath ?? defaultBinaryPath();
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
async start(): Promise<void> {
|
|
95
|
-
if (this.started) return;
|
|
96
|
-
await this.spawn();
|
|
97
|
-
this.started = true;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
async stop(): Promise<void> {
|
|
101
|
-
this.started = false;
|
|
102
|
-
if (this.process) {
|
|
103
|
-
this.process.kill();
|
|
104
|
-
this.process = null;
|
|
105
|
-
}
|
|
106
|
-
// Reject all pending
|
|
107
|
-
for (const [id, pending] of this.pending) {
|
|
108
|
-
clearTimeout(pending.timer);
|
|
109
|
-
pending.reject(new Error("Bridge stopped"));
|
|
110
|
-
this.pending.delete(id);
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
async call<T = unknown>(method: string, params?: Record<string, unknown>, timeoutMs?: number): Promise<T> {
|
|
115
|
-
const effectiveTimeout = timeoutMs ?? METHOD_TIMEOUTS[method] ?? 10_000;
|
|
116
|
-
if (!this.process || this.process.exitCode !== null) {
|
|
117
|
-
await this.restart();
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
const id = this.nextId++;
|
|
121
|
-
const request: JsonRpcRequest = { id, method };
|
|
122
|
-
if (params) {
|
|
123
|
-
request.params = params;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
return new Promise<T>((resolve, reject) => {
|
|
127
|
-
const timer = setTimeout(() => {
|
|
128
|
-
this.pending.delete(id);
|
|
129
|
-
reject(new Error(`Bridge call "${method}" timed out after ${effectiveTimeout}ms`));
|
|
130
|
-
}, effectiveTimeout);
|
|
131
|
-
|
|
132
|
-
this.pending.set(id, {
|
|
133
|
-
resolve: resolve as (value: unknown) => void,
|
|
134
|
-
reject,
|
|
135
|
-
timer,
|
|
136
|
-
});
|
|
137
|
-
|
|
138
|
-
const line = JSON.stringify(request) + "\n";
|
|
139
|
-
this.process!.stdin!.write(line);
|
|
140
|
-
});
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
async ping(): Promise<{ pong: boolean; pid: number; accessible: boolean }> {
|
|
144
|
-
return this.call("ping");
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
async checkPermissions(): Promise<{ trusted: boolean }> {
|
|
148
|
-
return this.call("check_permissions");
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
private async spawn(): Promise<void> {
|
|
152
|
-
const child = spawn(this.binaryPath, [], {
|
|
153
|
-
stdio: ["pipe", "pipe", "pipe"],
|
|
154
|
-
});
|
|
155
|
-
|
|
156
|
-
child.on("error", (err) => {
|
|
157
|
-
this.emit("error", err);
|
|
158
|
-
if (this.started) {
|
|
159
|
-
this.restart().catch(() => {});
|
|
160
|
-
}
|
|
161
|
-
});
|
|
162
|
-
|
|
163
|
-
child.on("exit", (code) => {
|
|
164
|
-
this.emit("exit", code);
|
|
165
|
-
if (this.started && !this.restarting) {
|
|
166
|
-
this.restart().catch(() => {});
|
|
167
|
-
}
|
|
168
|
-
});
|
|
169
|
-
|
|
170
|
-
// Parse stdout line by line
|
|
171
|
-
const rl = createInterface({ input: child.stdout! });
|
|
172
|
-
rl.on("line", (line) => {
|
|
173
|
-
this.handleLine(line);
|
|
174
|
-
});
|
|
175
|
-
|
|
176
|
-
// Log stderr
|
|
177
|
-
child.stderr?.on("data", (data: Buffer) => {
|
|
178
|
-
this.emit("stderr", data.toString());
|
|
179
|
-
});
|
|
180
|
-
|
|
181
|
-
this.process = child;
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
private handleLine(line: string): void {
|
|
185
|
-
let response: JsonRpcResponse;
|
|
186
|
-
try {
|
|
187
|
-
response = JSON.parse(line) as JsonRpcResponse;
|
|
188
|
-
} catch {
|
|
189
|
-
return; // Ignore malformed lines
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
// Event (streaming notification from observer)
|
|
193
|
-
if (response.event) {
|
|
194
|
-
this.emit("ax-event", response.event);
|
|
195
|
-
return;
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
// Response to a pending request
|
|
199
|
-
const pending = this.pending.get(response.id);
|
|
200
|
-
if (!pending) return;
|
|
201
|
-
|
|
202
|
-
this.pending.delete(response.id);
|
|
203
|
-
clearTimeout(pending.timer);
|
|
204
|
-
|
|
205
|
-
if (response.error) {
|
|
206
|
-
pending.reject(new Error(response.error.message));
|
|
207
|
-
} else {
|
|
208
|
-
pending.resolve(response.result);
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
private async restart(): Promise<void> {
|
|
213
|
-
if (this.restarting) return;
|
|
214
|
-
this.restarting = true;
|
|
215
|
-
|
|
216
|
-
// Reject all pending requests
|
|
217
|
-
for (const [id, pending] of this.pending) {
|
|
218
|
-
clearTimeout(pending.timer);
|
|
219
|
-
pending.reject(new Error("Bridge process crashed, restarting"));
|
|
220
|
-
this.pending.delete(id);
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
try {
|
|
224
|
-
if (this.process) {
|
|
225
|
-
this.process.kill();
|
|
226
|
-
this.process = null;
|
|
227
|
-
}
|
|
228
|
-
await this.spawn();
|
|
229
|
-
this.emit("restart");
|
|
230
|
-
} finally {
|
|
231
|
-
this.restarting = false;
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
/**
|
|
237
|
-
* @deprecated Use BridgeClient instead. This alias exists for backward compatibility.
|
|
238
|
-
*/
|
|
239
|
-
export const MacOSBridgeClient = BridgeClient;
|