codex-computer-use-mcp 0.1.0 → 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/ARCHITECTURE.md +134 -0
- package/CONTRIBUTING.md +16 -10
- package/MIGRATION.md +77 -0
- package/PROOF.md +114 -67
- package/README.md +94 -116
- package/SECURITY.md +43 -22
- package/dist/audit.d.ts +15 -14
- package/dist/audit.js +1 -1
- package/dist/audit.js.map +1 -1
- package/dist/config.d.ts +8 -8
- package/dist/config.js +8 -103
- package/dist/config.js.map +1 -1
- package/dist/direct-broker.d.ts +57 -0
- package/dist/direct-broker.js +638 -0
- package/dist/direct-broker.js.map +1 -0
- package/dist/direct-service.d.ts +31 -0
- package/dist/direct-service.js +345 -0
- package/dist/direct-service.js.map +1 -0
- package/dist/lock.d.ts +1 -0
- package/dist/lock.js +32 -3
- package/dist/lock.js.map +1 -1
- package/dist/mcp-server.js +46 -105
- package/dist/mcp-server.js.map +1 -1
- package/dist/system.d.ts +0 -1
- package/dist/system.js +12 -37
- package/dist/system.js.map +1 -1
- package/dist/tools.d.ts +78 -0
- package/dist/tools.js +192 -0
- package/dist/tools.js.map +1 -0
- package/integrations/pi/README.md +41 -27
- package/integrations/pi/index.ts +110 -123
- package/integrations/pi/mcp.json.example +3 -3
- package/npm-shrinkwrap.json +3278 -48
- package/package.json +40 -13
- package/dist/policy.d.ts +0 -42
- package/dist/policy.js +0 -428
- package/dist/policy.js.map +0 -1
- package/dist/prompt.d.ts +0 -62
- package/dist/prompt.js +0 -119
- package/dist/prompt.js.map +0 -1
- package/dist/runner.d.ts +0 -55
- package/dist/runner.js +0 -494
- package/dist/runner.js.map +0 -1
- package/dist/service.d.ts +0 -17
- package/dist/service.js +0 -382
- package/dist/service.js.map +0 -1
package/dist/mcp-server.js
CHANGED
|
@@ -1,64 +1,18 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import crypto from "node:crypto";
|
|
3
2
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
4
3
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
import { COMPUTER_USE_TOOLS, MODEL } from "./policy.js";
|
|
9
|
-
import { defaultStateRoot, executeOperation, getStatus } from "./service.js";
|
|
10
|
-
const version = "0.1.0";
|
|
4
|
+
import { executeDirectTool, getDirectStatus } from "./direct-service.js";
|
|
5
|
+
import { DIRECT_TOOL_SCHEMAS, MUTATING_METHODS, OFFICIAL_METHODS, READ_ONLY_METHODS, } from "./tools.js";
|
|
6
|
+
const version = "0.2.0";
|
|
11
7
|
async function handleCli() {
|
|
12
8
|
const args = process.argv.slice(2);
|
|
13
9
|
if (args.length === 0)
|
|
14
10
|
return false;
|
|
15
11
|
if (args.length === 1 && args[0] === "--status") {
|
|
16
|
-
console.log(JSON.stringify(await
|
|
12
|
+
console.log(JSON.stringify(await getDirectStatus(), null, 2));
|
|
17
13
|
return true;
|
|
18
14
|
}
|
|
19
|
-
|
|
20
|
-
throw new Error("Usage: codex-computer-use-mcp [--status | --configure safe | --configure full-permissions --acknowledge-full-permissions]");
|
|
21
|
-
}
|
|
22
|
-
const requested = args[1];
|
|
23
|
-
if (requested === "full-permissions" && !args.includes("--acknowledge-full-permissions")) {
|
|
24
|
-
throw new Error("Refusing to enable full-permissions without --acknowledge-full-permissions. This broadly enables targeted operations that safe mode refuses; official OpenAI approvals and technical controls remain.");
|
|
25
|
-
}
|
|
26
|
-
const stateRoot = defaultStateRoot();
|
|
27
|
-
const previous = await loadConfig(stateRoot);
|
|
28
|
-
if (previous.permissionMode === requested) {
|
|
29
|
-
console.log(`Permission mode is already ${requested}.`);
|
|
30
|
-
return true;
|
|
31
|
-
}
|
|
32
|
-
await saveConfig(stateRoot, { version: 1, permissionMode: requested });
|
|
33
|
-
const audit = {
|
|
34
|
-
timestamp: new Date().toISOString(),
|
|
35
|
-
runId: crypto.randomUUID(),
|
|
36
|
-
operation: "configure",
|
|
37
|
-
permissionMode: requested,
|
|
38
|
-
app: null,
|
|
39
|
-
mutating: true,
|
|
40
|
-
cleanupRequested: false,
|
|
41
|
-
userConfirmed: requested === "full-permissions",
|
|
42
|
-
authorization: requested === "full-permissions" ? "full_permissions_config" : "none",
|
|
43
|
-
inputBytes: 0,
|
|
44
|
-
outcome: "ok",
|
|
45
|
-
durationMs: 0,
|
|
46
|
-
model: MODEL,
|
|
47
|
-
usage: { input: 0, cachedInput: 0, output: 0 },
|
|
48
|
-
computerUseCalls: 0,
|
|
49
|
-
computerUseMethods: [],
|
|
50
|
-
backgroundPreserved: null,
|
|
51
|
-
cleanupVerified: null,
|
|
52
|
-
};
|
|
53
|
-
try {
|
|
54
|
-
await appendAudit(stateRoot, audit);
|
|
55
|
-
}
|
|
56
|
-
catch {
|
|
57
|
-
await saveConfig(stateRoot, previous);
|
|
58
|
-
throw new Error("Permission mode change was rolled back because secure audit logging failed");
|
|
59
|
-
}
|
|
60
|
-
console.log(`Permission mode set to ${requested}.`);
|
|
61
|
-
return true;
|
|
15
|
+
throw new Error("Usage: codex-computer-use-mcp [--status]. The durable no-permissions interface has no alternate mode or configuration command.");
|
|
62
16
|
}
|
|
63
17
|
try {
|
|
64
18
|
if (await handleCli())
|
|
@@ -69,64 +23,51 @@ catch (error) {
|
|
|
69
23
|
process.exit(1);
|
|
70
24
|
}
|
|
71
25
|
const server = new McpServer({ name: "codex-computer-use-mcp", version }, { capabilities: { logging: {} } });
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
description: "Show the server permission mode, state/audit paths, signed model, approval boundary, and supported official Computer Use methods.",
|
|
111
|
-
annotations: {
|
|
112
|
-
readOnlyHint: true,
|
|
113
|
-
destructiveHint: false,
|
|
114
|
-
idempotentHint: true,
|
|
115
|
-
openWorldHint: false,
|
|
116
|
-
},
|
|
26
|
+
function titleFor(method) {
|
|
27
|
+
return method.split("_").map((part) => `${part.slice(0, 1).toUpperCase()}${part.slice(1)}`).join(" ");
|
|
28
|
+
}
|
|
29
|
+
function descriptionFor(method) {
|
|
30
|
+
return `Call the official signed Computer Use ${method} capability directly through the unrestricted no-permissions interface. Pi/the MCP client supplies the typed arguments; no wrapper approval prompt, mode gate, nested model, prompt, planner, or model-token usage is involved.`;
|
|
31
|
+
}
|
|
32
|
+
for (const method of OFFICIAL_METHODS) {
|
|
33
|
+
server.registerTool(method, {
|
|
34
|
+
title: titleFor(method),
|
|
35
|
+
description: descriptionFor(method),
|
|
36
|
+
inputSchema: DIRECT_TOOL_SCHEMAS[method],
|
|
37
|
+
annotations: {
|
|
38
|
+
readOnlyHint: READ_ONLY_METHODS.has(method),
|
|
39
|
+
destructiveHint: MUTATING_METHODS.has(method),
|
|
40
|
+
idempotentHint: method === "list_apps" || method === "get_app_state",
|
|
41
|
+
openWorldHint: false,
|
|
42
|
+
},
|
|
43
|
+
}, async (toolArgs, extra) => {
|
|
44
|
+
try {
|
|
45
|
+
const response = await executeDirectTool({ method, arguments: toolArgs }, { signal: extra.signal });
|
|
46
|
+
return {
|
|
47
|
+
content: response.content,
|
|
48
|
+
structuredContent: response.details,
|
|
49
|
+
isError: response.isError,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
catch (error) {
|
|
53
|
+
return {
|
|
54
|
+
content: [{ type: "text", text: error instanceof Error ? error.message : "Direct Computer Use failed" }],
|
|
55
|
+
isError: true,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
server.registerTool("computer_use_status", {
|
|
61
|
+
title: "Computer Use Status",
|
|
62
|
+
description: "Show direct-call architecture, permission mode, signed broker status, supported methods, and private audit path.",
|
|
63
|
+
annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
|
|
117
64
|
}, async () => {
|
|
118
65
|
try {
|
|
119
|
-
const status = await
|
|
120
|
-
return {
|
|
121
|
-
content: [{ type: "text", text: JSON.stringify(status, null, 2) }],
|
|
122
|
-
structuredContent: status,
|
|
123
|
-
};
|
|
66
|
+
const status = await getDirectStatus();
|
|
67
|
+
return { content: [{ type: "text", text: JSON.stringify(status, null, 2) }], structuredContent: status };
|
|
124
68
|
}
|
|
125
69
|
catch (error) {
|
|
126
|
-
return {
|
|
127
|
-
content: [{ type: "text", text: error instanceof Error ? error.message : "Could not read status" }],
|
|
128
|
-
isError: true,
|
|
129
|
-
};
|
|
70
|
+
return { content: [{ type: "text", text: error instanceof Error ? error.message : "Could not read status" }], isError: true };
|
|
130
71
|
}
|
|
131
72
|
});
|
|
132
73
|
const transport = new StdioServerTransport();
|
package/dist/mcp-server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp-server.js","sourceRoot":"","sources":["../src/mcp-server.ts"],"names":[],"mappings":";AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"mcp-server.js","sourceRoot":"","sources":["../src/mcp-server.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AAEjF,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACzE,OAAO,EACN,mBAAmB,EACnB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AC;gBACxG,OAAO,EAAE,IAAI;aACb,CAAC;QACH,CAAC;IACF,CAAC,CACD,CAAC;AACH,CAAC;AAED,MAAM,CAAC,YAAY,CAClB,qBAAqB,EACrB;IACC,KAAK,EAAE,qBAAqB;IAC5B,WAAW,EAAE,kHAAkH;IAC/H,WAAW,EAAE,EAAE,YAAY,EAAE,IAAI,EAAE,eAAe,EAAE,KAAK,EAAE,cAAc,EAAE,IAAI,EAAE,aAAa,EAAE,KAAK,EAAE;CACvG,EACD,KAAK,IAA6B,EAAE;IACnC,IAAI,CAAC;QACJ,MAAM,MAAM,GAAG,MAAM,eAAe,EAAE,CAAC;QACvC,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,iBAAiB,EAAE,MAAM,EAAE,CAAC;IAC1G,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAChB,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,uBAAuB,EAAE,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;IAC/H,CAAC;AACF,CAAC,CACD,CAAC;AAEF,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;AAC7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC"}
|
package/dist/system.d.ts
CHANGED
|
@@ -8,7 +8,6 @@ export interface ResolvedAppIdentity {
|
|
|
8
8
|
}
|
|
9
9
|
export declare function resolveAppIdentity(app: string): ResolvedAppIdentity;
|
|
10
10
|
export declare function resolveAppLeaseId(app: string): string;
|
|
11
|
-
export declare function ensureAppRunningInBackground(app: string, identity?: ResolvedAppIdentity): Promise<ResolvedAppIdentity>;
|
|
12
11
|
export interface TargetFrontmostWatcher {
|
|
13
12
|
becameFrontmost(bundleId: string): boolean;
|
|
14
13
|
healthy(): boolean;
|
package/dist/system.js
CHANGED
|
@@ -104,38 +104,6 @@ export function resolveAppIdentity(app) {
|
|
|
104
104
|
export function resolveAppLeaseId(app) {
|
|
105
105
|
return resolveAppIdentity(app).leaseId;
|
|
106
106
|
}
|
|
107
|
-
export async function ensureAppRunningInBackground(app, identity = resolveAppIdentity(app)) {
|
|
108
|
-
if (identity.bundleId) {
|
|
109
|
-
const found = spawnSync("/usr/bin/lsappinfo", ["find", `bundleID=${identity.bundleId}`], {
|
|
110
|
-
encoding: "utf8",
|
|
111
|
-
timeout: 3000,
|
|
112
|
-
});
|
|
113
|
-
if (found.status === 0 && (found.stdout ?? "").trim().startsWith("ASN:"))
|
|
114
|
-
return identity;
|
|
115
|
-
}
|
|
116
|
-
const selectorIsBundleId = /^[A-Za-z0-9-]+(?:\.[A-Za-z0-9-]+)+$/.test(app.trim());
|
|
117
|
-
const launchArgs = path.isAbsolute(app)
|
|
118
|
-
? ["-g", app]
|
|
119
|
-
: identity.bundleId || selectorIsBundleId
|
|
120
|
-
? ["-g", "-b", identity.bundleId ?? app.trim()]
|
|
121
|
-
: ["-g", "-a", app];
|
|
122
|
-
const launched = spawnSync("/usr/bin/open", launchArgs, { encoding: "utf8", timeout: 10_000 });
|
|
123
|
-
if (launched.status !== 0)
|
|
124
|
-
throw new Error("Could not launch the target app in the background");
|
|
125
|
-
for (let attempt = 0; attempt < 100; attempt++) {
|
|
126
|
-
const resolved = resolveAppIdentity(identity.bundleId ?? app);
|
|
127
|
-
if (resolved.bundleId) {
|
|
128
|
-
const found = spawnSync("/usr/bin/lsappinfo", ["find", `bundleID=${resolved.bundleId}`], {
|
|
129
|
-
encoding: "utf8",
|
|
130
|
-
timeout: 3000,
|
|
131
|
-
});
|
|
132
|
-
if (found.status === 0 && (found.stdout ?? "").trim().startsWith("ASN:"))
|
|
133
|
-
return resolved;
|
|
134
|
-
}
|
|
135
|
-
await new Promise((resolve) => setTimeout(resolve, 50));
|
|
136
|
-
}
|
|
137
|
-
throw new Error("Target app did not become available after background launch");
|
|
138
|
-
}
|
|
139
107
|
function bundleIdForAsn(asn, infoPath = "/usr/bin/lsappinfo") {
|
|
140
108
|
const info = spawnSync(infoPath, ["info", "-only", "bundleID", asn], {
|
|
141
109
|
encoding: "utf8",
|
|
@@ -167,33 +135,36 @@ export async function watchTargetFrontmost(listenerPath = "/usr/bin/lsappinfo",
|
|
|
167
135
|
};
|
|
168
136
|
const retryTimer = setInterval(resolvePending, 50);
|
|
169
137
|
retryTimer.unref();
|
|
138
|
+
const childRunning = () => proc.exitCode === null && proc.signalCode === null;
|
|
170
139
|
const markStopped = () => {
|
|
171
140
|
running = false;
|
|
172
141
|
clearInterval(retryTimer);
|
|
173
142
|
};
|
|
174
143
|
proc.stdout.setEncoding("utf8");
|
|
175
144
|
proc.stdout.on("data", (chunk) => {
|
|
176
|
-
buffer
|
|
145
|
+
buffer += chunk;
|
|
177
146
|
for (const match of buffer.matchAll(/ASN:0x[0-9a-f]+-0x[0-9a-f]+/gi)) {
|
|
178
147
|
const asn = match[0];
|
|
179
148
|
if (!observedAsns.has(asn))
|
|
180
149
|
unresolvedAsns.add(asn);
|
|
181
150
|
}
|
|
151
|
+
// Every complete ASN above has been consumed; retain only enough overlap for a token split across chunks.
|
|
152
|
+
buffer = buffer.slice(-128);
|
|
182
153
|
resolvePending();
|
|
183
154
|
});
|
|
184
155
|
proc.once("error", markStopped);
|
|
185
156
|
proc.once("close", markStopped);
|
|
186
157
|
await new Promise((resolve) => setTimeout(resolve, 75));
|
|
187
|
-
if (!running ||
|
|
158
|
+
if (!running || !childRunning())
|
|
188
159
|
throw new Error("Target focus-event monitor failed to start");
|
|
189
160
|
return {
|
|
190
161
|
becameFrontmost: (bundleId) => {
|
|
191
162
|
resolvePending();
|
|
192
163
|
return observedBundles.has(bundleId.toLowerCase());
|
|
193
164
|
},
|
|
194
|
-
healthy: () => running &&
|
|
165
|
+
healthy: () => running && childRunning(),
|
|
195
166
|
stop: async () => {
|
|
196
|
-
if (
|
|
167
|
+
if (childRunning()) {
|
|
197
168
|
proc.kill("SIGTERM");
|
|
198
169
|
await new Promise((resolve) => {
|
|
199
170
|
const timeout = setTimeout(resolve, 1000);
|
|
@@ -202,7 +173,7 @@ export async function watchTargetFrontmost(listenerPath = "/usr/bin/lsappinfo",
|
|
|
202
173
|
resolve();
|
|
203
174
|
});
|
|
204
175
|
});
|
|
205
|
-
if (
|
|
176
|
+
if (childRunning()) {
|
|
206
177
|
proc.kill("SIGKILL");
|
|
207
178
|
await new Promise((resolve) => {
|
|
208
179
|
const timeout = setTimeout(resolve, 500);
|
|
@@ -212,6 +183,10 @@ export async function watchTargetFrontmost(listenerPath = "/usr/bin/lsappinfo",
|
|
|
212
183
|
});
|
|
213
184
|
});
|
|
214
185
|
}
|
|
186
|
+
if (childRunning()) {
|
|
187
|
+
clearInterval(retryTimer);
|
|
188
|
+
throw new Error("Target focus-event monitor did not terminate");
|
|
189
|
+
}
|
|
215
190
|
}
|
|
216
191
|
clearInterval(retryTimer);
|
|
217
192
|
// Events may arrive only while SIGTERM is draining stdout. Resolve every queued ASN before returning.
|
package/dist/system.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"system.js","sourceRoot":"","sources":["../src/system.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAChE,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,MAAM,aAAa,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC;AAE1C,MAAM,UAAU,yBAAyB;IACxC,MAAM,KAAK,GAAG,SAAS,CAAC,oBAAoB,EAAE,CAAC,OAAO,CAAC,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AAG,EAAE,EAAE,OAAO,IAAI,CAAC,EAAE,CAAC;gBAC7E,cAAc,EAAE,CAAC;gBACjB,IAAI,cAAc,CAAC,IAAI,GAAG,CAAC;oBAAE,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;YACtF,CAAC;YACD,IAAI,cAAc,CAAC,IAAI,GAAG,CAAC;gBAAE,MAAM,IAAI,KAAK,CAAC,qDAAqD,CAAC,CAAC;QACrG,CAAC;KACD,CAAC;AACH,CAAC"}
|
package/dist/tools.d.ts
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const DIRECT_TOOL_SCHEMAS: {
|
|
3
|
+
readonly list_apps: z.ZodObject<{}, z.core.$strict>;
|
|
4
|
+
readonly get_app_state: z.ZodObject<{
|
|
5
|
+
app: z.ZodString;
|
|
6
|
+
}, z.core.$strict>;
|
|
7
|
+
readonly click: z.ZodObject<{
|
|
8
|
+
app: z.ZodString;
|
|
9
|
+
click_count: z.ZodOptional<z.ZodNumber>;
|
|
10
|
+
element_index: z.ZodOptional<z.ZodString>;
|
|
11
|
+
mouse_button: z.ZodOptional<z.ZodEnum<{
|
|
12
|
+
left: "left";
|
|
13
|
+
middle: "middle";
|
|
14
|
+
right: "right";
|
|
15
|
+
}>>;
|
|
16
|
+
x: z.ZodOptional<z.ZodNumber>;
|
|
17
|
+
y: z.ZodOptional<z.ZodNumber>;
|
|
18
|
+
}, z.core.$strict>;
|
|
19
|
+
readonly perform_secondary_action: z.ZodObject<{
|
|
20
|
+
app: z.ZodString;
|
|
21
|
+
element_index: z.ZodString;
|
|
22
|
+
action: z.ZodString;
|
|
23
|
+
}, z.core.$strict>;
|
|
24
|
+
readonly set_value: z.ZodObject<{
|
|
25
|
+
app: z.ZodString;
|
|
26
|
+
element_index: z.ZodString;
|
|
27
|
+
value: z.ZodString;
|
|
28
|
+
}, z.core.$strict>;
|
|
29
|
+
readonly select_text: z.ZodObject<{
|
|
30
|
+
app: z.ZodString;
|
|
31
|
+
element_index: z.ZodString;
|
|
32
|
+
text: z.ZodString;
|
|
33
|
+
prefix: z.ZodOptional<z.ZodString>;
|
|
34
|
+
selection: z.ZodOptional<z.ZodEnum<{
|
|
35
|
+
cursor_after: "cursor_after";
|
|
36
|
+
cursor_before: "cursor_before";
|
|
37
|
+
text: "text";
|
|
38
|
+
}>>;
|
|
39
|
+
suffix: z.ZodOptional<z.ZodString>;
|
|
40
|
+
}, z.core.$strict>;
|
|
41
|
+
readonly scroll: z.ZodObject<{
|
|
42
|
+
app: z.ZodString;
|
|
43
|
+
element_index: z.ZodString;
|
|
44
|
+
direction: z.ZodEnum<{
|
|
45
|
+
down: "down";
|
|
46
|
+
left: "left";
|
|
47
|
+
right: "right";
|
|
48
|
+
up: "up";
|
|
49
|
+
}>;
|
|
50
|
+
pages: z.ZodOptional<z.ZodNumber>;
|
|
51
|
+
}, z.core.$strict>;
|
|
52
|
+
readonly drag: z.ZodObject<{
|
|
53
|
+
app: z.ZodString;
|
|
54
|
+
from_x: z.ZodNumber;
|
|
55
|
+
from_y: z.ZodNumber;
|
|
56
|
+
to_x: z.ZodNumber;
|
|
57
|
+
to_y: z.ZodNumber;
|
|
58
|
+
}, z.core.$strict>;
|
|
59
|
+
readonly press_key: z.ZodObject<{
|
|
60
|
+
app: z.ZodString;
|
|
61
|
+
key: z.ZodString;
|
|
62
|
+
}, z.core.$strict>;
|
|
63
|
+
readonly type_text: z.ZodObject<{
|
|
64
|
+
app: z.ZodString;
|
|
65
|
+
text: z.ZodString;
|
|
66
|
+
}, z.core.$strict>;
|
|
67
|
+
};
|
|
68
|
+
export type DirectMethod = keyof typeof DIRECT_TOOL_SCHEMAS;
|
|
69
|
+
export type DirectToolArguments = Record<string, unknown>;
|
|
70
|
+
export declare const OFFICIAL_METHODS: readonly ("click" | "drag" | "get_app_state" | "list_apps" | "perform_secondary_action" | "press_key" | "scroll" | "select_text" | "set_value" | "type_text")[];
|
|
71
|
+
export declare const READ_ONLY_METHODS: Set<"click" | "drag" | "get_app_state" | "list_apps" | "perform_secondary_action" | "press_key" | "scroll" | "select_text" | "set_value" | "type_text">;
|
|
72
|
+
export declare const MUTATING_METHODS: Set<"click" | "drag" | "get_app_state" | "list_apps" | "perform_secondary_action" | "press_key" | "scroll" | "select_text" | "set_value" | "type_text">;
|
|
73
|
+
export declare function isDirectMethod(value: string): value is DirectMethod;
|
|
74
|
+
export declare function normalizeKeyExpression(value: string): string;
|
|
75
|
+
export declare function validateDirectArguments(method: DirectMethod, value: unknown): DirectToolArguments;
|
|
76
|
+
export declare function targetAppFor(method: DirectMethod, args: DirectToolArguments): string | undefined;
|
|
77
|
+
/** Exact upstream MCP schemas observed from the signed helper. Drift fails closed before dispatch. */
|
|
78
|
+
export declare const EXPECTED_OFFICIAL_INPUT_SCHEMAS: Readonly<Record<DirectMethod, unknown>>;
|
package/dist/tools.js
ADDED
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
const app = z.string().trim().min(1).max(500).describe("App name, full app path, or unambiguous bundle identifier");
|
|
3
|
+
const elementIndex = z.string().trim().min(1).max(200).describe("Element identifier from computer_use_get_app_state");
|
|
4
|
+
const coordinate = z.number().finite().min(0).max(1_000_000);
|
|
5
|
+
export const DIRECT_TOOL_SCHEMAS = {
|
|
6
|
+
list_apps: z.object({}).strict(),
|
|
7
|
+
get_app_state: z.object({ app }).strict(),
|
|
8
|
+
click: z
|
|
9
|
+
.object({
|
|
10
|
+
app,
|
|
11
|
+
click_count: z.number().int().min(1).max(10).optional(),
|
|
12
|
+
element_index: elementIndex.optional(),
|
|
13
|
+
mouse_button: z.enum(["left", "right", "middle"]).optional(),
|
|
14
|
+
x: coordinate.optional(),
|
|
15
|
+
y: coordinate.optional(),
|
|
16
|
+
})
|
|
17
|
+
.strict(),
|
|
18
|
+
perform_secondary_action: z
|
|
19
|
+
.object({ app, element_index: elementIndex, action: z.string().trim().min(1).max(200) })
|
|
20
|
+
.strict(),
|
|
21
|
+
set_value: z.object({ app, element_index: elementIndex, value: z.string().max(20_000) }).strict(),
|
|
22
|
+
select_text: z
|
|
23
|
+
.object({
|
|
24
|
+
app,
|
|
25
|
+
element_index: elementIndex,
|
|
26
|
+
text: z.string().min(1).max(20_000),
|
|
27
|
+
prefix: z.string().max(2_000).optional(),
|
|
28
|
+
selection: z.enum(["text", "cursor_before", "cursor_after"]).optional(),
|
|
29
|
+
suffix: z.string().max(2_000).optional(),
|
|
30
|
+
})
|
|
31
|
+
.strict(),
|
|
32
|
+
scroll: z
|
|
33
|
+
.object({
|
|
34
|
+
app,
|
|
35
|
+
element_index: elementIndex,
|
|
36
|
+
direction: z.enum(["up", "down", "left", "right"]),
|
|
37
|
+
pages: z.number().finite().positive().max(100).optional(),
|
|
38
|
+
})
|
|
39
|
+
.strict(),
|
|
40
|
+
drag: z
|
|
41
|
+
.object({ app, from_x: coordinate, from_y: coordinate, to_x: coordinate, to_y: coordinate })
|
|
42
|
+
.strict(),
|
|
43
|
+
press_key: z.object({ app, key: z.string().trim().min(1).max(100).describe("Official xdotool-style key name or combination, for example Meta_L+a, Return, or Escape") }).strict(),
|
|
44
|
+
type_text: z.object({ app, text: z.string().max(20_000) }).strict(),
|
|
45
|
+
};
|
|
46
|
+
export const OFFICIAL_METHODS = Object.freeze(Object.keys(DIRECT_TOOL_SCHEMAS));
|
|
47
|
+
export const READ_ONLY_METHODS = new Set(["list_apps", "get_app_state"]);
|
|
48
|
+
export const MUTATING_METHODS = new Set(OFFICIAL_METHODS.filter((method) => !READ_ONLY_METHODS.has(method)));
|
|
49
|
+
export function isDirectMethod(value) {
|
|
50
|
+
return OFFICIAL_METHODS.includes(value);
|
|
51
|
+
}
|
|
52
|
+
const KEY_ALIASES = {
|
|
53
|
+
cmd: "Meta_L",
|
|
54
|
+
command: "Meta_L",
|
|
55
|
+
meta: "Meta_L",
|
|
56
|
+
ctrl: "Control_L",
|
|
57
|
+
control: "Control_L",
|
|
58
|
+
shift: "Shift_L",
|
|
59
|
+
alt: "Alt_L",
|
|
60
|
+
option: "Alt_L",
|
|
61
|
+
enter: "Return",
|
|
62
|
+
return: "Return",
|
|
63
|
+
esc: "Escape",
|
|
64
|
+
escape: "Escape",
|
|
65
|
+
backspace: "BackSpace",
|
|
66
|
+
delete: "Delete",
|
|
67
|
+
pageup: "Page_Up",
|
|
68
|
+
pagedown: "Page_Down",
|
|
69
|
+
arrowup: "Up",
|
|
70
|
+
arrowdown: "Down",
|
|
71
|
+
arrowleft: "Left",
|
|
72
|
+
arrowright: "Right",
|
|
73
|
+
};
|
|
74
|
+
export function normalizeKeyExpression(value) {
|
|
75
|
+
return value
|
|
76
|
+
.split("+")
|
|
77
|
+
.map((part) => {
|
|
78
|
+
const trimmed = part.trim();
|
|
79
|
+
const alias = KEY_ALIASES[trimmed.toLowerCase()];
|
|
80
|
+
if (alias)
|
|
81
|
+
return alias;
|
|
82
|
+
return /^[A-Z]$/.test(trimmed) ? trimmed.toLowerCase() : trimmed;
|
|
83
|
+
})
|
|
84
|
+
.join("+");
|
|
85
|
+
}
|
|
86
|
+
export function validateDirectArguments(method, value) {
|
|
87
|
+
const parsed = DIRECT_TOOL_SCHEMAS[method].parse(value);
|
|
88
|
+
if (method === "press_key")
|
|
89
|
+
return { ...parsed, key: normalizeKeyExpression(parsed.key) };
|
|
90
|
+
return parsed;
|
|
91
|
+
}
|
|
92
|
+
export function targetAppFor(method, args) {
|
|
93
|
+
return method === "list_apps" ? undefined : args.app;
|
|
94
|
+
}
|
|
95
|
+
/** Exact upstream MCP schemas observed from the signed helper. Drift fails closed before dispatch. */
|
|
96
|
+
export const EXPECTED_OFFICIAL_INPUT_SCHEMAS = {
|
|
97
|
+
list_apps: { type: "object", properties: {}, additionalProperties: false },
|
|
98
|
+
get_app_state: {
|
|
99
|
+
type: "object",
|
|
100
|
+
properties: { app: { description: "App name, full app path, or unambiguous bundle identifier", type: "string" } },
|
|
101
|
+
required: ["app"],
|
|
102
|
+
additionalProperties: false,
|
|
103
|
+
},
|
|
104
|
+
click: {
|
|
105
|
+
type: "object",
|
|
106
|
+
properties: {
|
|
107
|
+
app: { description: "App name, full app path, or unambiguous bundle identifier", type: "string" },
|
|
108
|
+
click_count: { description: "Number of clicks. Defaults to 1", type: "integer" },
|
|
109
|
+
element_index: { description: "Element index to click", type: "string" },
|
|
110
|
+
mouse_button: { description: "Mouse button to click. Defaults to left.", enum: ["left", "right", "middle"], type: "string" },
|
|
111
|
+
x: { description: "X coordinate in screenshot pixel coordinates", type: "number" },
|
|
112
|
+
y: { description: "Y coordinate in screenshot pixel coordinates", type: "number" },
|
|
113
|
+
},
|
|
114
|
+
required: ["app"],
|
|
115
|
+
additionalProperties: false,
|
|
116
|
+
},
|
|
117
|
+
perform_secondary_action: {
|
|
118
|
+
type: "object",
|
|
119
|
+
properties: {
|
|
120
|
+
action: { description: "Secondary accessibility action name", type: "string" },
|
|
121
|
+
app: { description: "App name, full app path, or unambiguous bundle identifier", type: "string" },
|
|
122
|
+
element_index: { description: "Element identifier", type: "string" },
|
|
123
|
+
},
|
|
124
|
+
required: ["app", "element_index", "action"],
|
|
125
|
+
additionalProperties: false,
|
|
126
|
+
},
|
|
127
|
+
set_value: {
|
|
128
|
+
type: "object",
|
|
129
|
+
properties: {
|
|
130
|
+
app: { description: "App name, full app path, or unambiguous bundle identifier", type: "string" },
|
|
131
|
+
element_index: { description: "Element identifier", type: "string" },
|
|
132
|
+
value: { description: "Value to assign", type: "string" },
|
|
133
|
+
},
|
|
134
|
+
required: ["app", "element_index", "value"],
|
|
135
|
+
additionalProperties: false,
|
|
136
|
+
},
|
|
137
|
+
select_text: {
|
|
138
|
+
type: "object",
|
|
139
|
+
properties: {
|
|
140
|
+
app: { description: "App name or bundle identifier", type: "string" },
|
|
141
|
+
element_index: { description: "Text element identifier", type: "string" },
|
|
142
|
+
prefix: { description: "Optional text immediately before the target, used to disambiguate repeated matches", type: "string" },
|
|
143
|
+
selection: { description: "Whether to select the text or place the cursor before or after it. Defaults to text.", enum: ["text", "cursor_before", "cursor_after"], type: "string" },
|
|
144
|
+
suffix: { description: "Optional text immediately after the target, used to disambiguate repeated matches", type: "string" },
|
|
145
|
+
text: { description: "Target text as shown in the accessibility tree", type: "string" },
|
|
146
|
+
},
|
|
147
|
+
required: ["app", "element_index", "text"],
|
|
148
|
+
additionalProperties: false,
|
|
149
|
+
},
|
|
150
|
+
scroll: {
|
|
151
|
+
type: "object",
|
|
152
|
+
properties: {
|
|
153
|
+
app: { description: "App name, full app path, or unambiguous bundle identifier", type: "string" },
|
|
154
|
+
direction: { description: "Scroll direction: up, down, left, or right", type: "string" },
|
|
155
|
+
element_index: { description: "Element identifier", type: "string" },
|
|
156
|
+
pages: { description: "Number of pages to scroll. Fractional values are supported. Defaults to 1", type: "number" },
|
|
157
|
+
},
|
|
158
|
+
required: ["app", "element_index", "direction"],
|
|
159
|
+
additionalProperties: false,
|
|
160
|
+
},
|
|
161
|
+
drag: {
|
|
162
|
+
type: "object",
|
|
163
|
+
properties: {
|
|
164
|
+
app: { description: "App name, full app path, or unambiguous bundle identifier", type: "string" },
|
|
165
|
+
from_x: { description: "Start X coordinate", type: "number" },
|
|
166
|
+
from_y: { description: "Start Y coordinate", type: "number" },
|
|
167
|
+
to_x: { description: "End X coordinate", type: "number" },
|
|
168
|
+
to_y: { description: "End Y coordinate", type: "number" },
|
|
169
|
+
},
|
|
170
|
+
required: ["app", "from_x", "from_y", "to_x", "to_y"],
|
|
171
|
+
additionalProperties: false,
|
|
172
|
+
},
|
|
173
|
+
press_key: {
|
|
174
|
+
type: "object",
|
|
175
|
+
properties: {
|
|
176
|
+
app: { description: "App name, full app path, or unambiguous bundle identifier", type: "string" },
|
|
177
|
+
key: { description: "Key or key combination to press", type: "string" },
|
|
178
|
+
},
|
|
179
|
+
required: ["app", "key"],
|
|
180
|
+
additionalProperties: false,
|
|
181
|
+
},
|
|
182
|
+
type_text: {
|
|
183
|
+
type: "object",
|
|
184
|
+
properties: {
|
|
185
|
+
app: { description: "App name, full app path, or unambiguous bundle identifier", type: "string" },
|
|
186
|
+
text: { description: "Literal text to type", type: "string" },
|
|
187
|
+
},
|
|
188
|
+
required: ["app", "text"],
|
|
189
|
+
additionalProperties: false,
|
|
190
|
+
},
|
|
191
|
+
};
|
|
192
|
+
//# sourceMappingURL=tools.js.map
|