codex-computer-use-mcp 0.1.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/dist/lock.js ADDED
@@ -0,0 +1,108 @@
1
+ import crypto from "node:crypto";
2
+ import { spawn } from "node:child_process";
3
+ import { mkdir, open, readFile, rename, rm } from "node:fs/promises";
4
+ import path from "node:path";
5
+ export class AppBusyError extends Error {
6
+ owner;
7
+ constructor(app, owner) {
8
+ super(`${app} is already leased by another native-app task; concurrent same-app access is blocked`);
9
+ this.name = "AppBusyError";
10
+ this.owner = owner;
11
+ }
12
+ }
13
+ function lockKey(value) {
14
+ return crypto.createHash("sha256").update(value).digest("hex");
15
+ }
16
+ async function readOwner(ownerPath) {
17
+ try {
18
+ return JSON.parse(await readFile(ownerPath, "utf8"));
19
+ }
20
+ catch {
21
+ return undefined;
22
+ }
23
+ }
24
+ async function publishOwner(ownerPath, owner) {
25
+ const temporary = `${ownerPath}.${process.pid}.${owner.runId}.tmp`;
26
+ const handle = await open(temporary, "wx", 0o600);
27
+ try {
28
+ await handle.writeFile(`${JSON.stringify(owner)}\n`, "utf8");
29
+ await handle.sync();
30
+ }
31
+ finally {
32
+ await handle.close();
33
+ }
34
+ try {
35
+ await rename(temporary, ownerPath);
36
+ }
37
+ finally {
38
+ await rm(temporary, { force: true });
39
+ }
40
+ }
41
+ export async function acquireAppLock(stateDir, app, runId, _staleAfterMs = 10 * 60_000) {
42
+ const locksDir = path.join(stateDir, "locks");
43
+ await mkdir(locksDir, { recursive: true, mode: 0o700 });
44
+ const key = lockKey(app);
45
+ const lockPath = path.join(locksDir, `${key}.lock`);
46
+ const ownerPath = path.join(locksDir, `${key}.owner.json`);
47
+ const owner = {
48
+ runId,
49
+ pid: process.pid,
50
+ app: `selector-sha256:${key.slice(0, 16)}`,
51
+ startedAt: new Date().toISOString(),
52
+ };
53
+ // lockf is a kernel advisory lock: acquisition is atomic and a crashed owner releases it automatically.
54
+ // The static shell command emits readiness only after lockf owns the file, then blocks on stdin.
55
+ const proc = spawn("/usr/bin/lockf", ["-t", "0", lockPath, "/bin/sh", "-c", 'printf "LOCKED\\n"; /bin/cat >/dev/null'], { stdio: ["pipe", "pipe", "ignore"], shell: false });
56
+ const acquired = await new Promise((resolve, reject) => {
57
+ let output = "";
58
+ let settled = false;
59
+ const finish = (value) => {
60
+ if (settled)
61
+ return;
62
+ settled = true;
63
+ resolve(value);
64
+ };
65
+ proc.once("error", (error) => {
66
+ if (settled)
67
+ return;
68
+ settled = true;
69
+ reject(error);
70
+ });
71
+ proc.once("close", () => finish(false));
72
+ proc.stdout.setEncoding("utf8");
73
+ proc.stdout.on("data", (chunk) => {
74
+ output += chunk;
75
+ if (output.includes("LOCKED\n"))
76
+ finish(true);
77
+ });
78
+ });
79
+ if (!acquired) {
80
+ proc.stdin.destroy();
81
+ throw new AppBusyError(app, await readOwner(ownerPath));
82
+ }
83
+ try {
84
+ await publishOwner(ownerPath, owner);
85
+ }
86
+ catch (error) {
87
+ proc.stdin.end();
88
+ await new Promise((resolve) => proc.once("close", () => resolve()));
89
+ throw error;
90
+ }
91
+ let released = false;
92
+ return {
93
+ path: lockPath,
94
+ owner,
95
+ async release() {
96
+ if (released)
97
+ return;
98
+ released = true;
99
+ proc.stdin.end();
100
+ if (proc.exitCode === null)
101
+ await new Promise((resolve) => proc.once("close", () => resolve()));
102
+ const current = await readOwner(ownerPath);
103
+ if (current?.runId === runId)
104
+ await rm(ownerPath, { force: true });
105
+ },
106
+ };
107
+ }
108
+ //# sourceMappingURL=lock.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lock.js","sourceRoot":"","sources":["../src/lock.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC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GAAG,EAAE,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;QAC1E,MAAM,KAAK,CAAC;IACb,CAAC;IACD,IAAI,QAAQ,GAAG,KAAK,CAAC;IACrB,OAAO;QACN,IAAI,EAAE,QAAQ;QACd,KAAK;QACL,KAAK,CAAC,OAAO;YACZ,IAAI,QAAQ;gBAAE,OAAO;YACrB,QAAQ,GAAG,IAAI,CAAC;YAChB,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC;YACjB,IAAI,IAAI,CAAC,QAAQ,KAAK,IAAI;gBAAE,MAAM,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;YACtG,MAAM,OAAO,GAAG,MAAM,SAAS,CAAC,SAAS,CAAC,CAAC;YAC3C,IAAI,OAAO,EAAE,KAAK,KAAK,KAAK;gBAAE,MAAM,EAAE,CAAC,SAAS,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;QACpE,CAAC;KACD,CAAC;AACH,CAAC"}
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
@@ -0,0 +1,134 @@
1
+ #!/usr/bin/env node
2
+ import crypto from "node:crypto";
3
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
4
+ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
5
+ import { z } from "zod";
6
+ import { appendAudit } from "./audit.js";
7
+ import { loadConfig, saveConfig } from "./config.js";
8
+ import { COMPUTER_USE_TOOLS, MODEL } from "./policy.js";
9
+ import { defaultStateRoot, executeOperation, getStatus } from "./service.js";
10
+ const version = "0.1.0";
11
+ async function handleCli() {
12
+ const args = process.argv.slice(2);
13
+ if (args.length === 0)
14
+ return false;
15
+ if (args.length === 1 && args[0] === "--status") {
16
+ console.log(JSON.stringify(await getStatus(), null, 2));
17
+ return true;
18
+ }
19
+ if (args[0] !== "--configure" || (args[1] !== "safe" && args[1] !== "full-permissions")) {
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;
62
+ }
63
+ try {
64
+ if (await handleCli())
65
+ process.exit(0);
66
+ }
67
+ catch (error) {
68
+ console.error(error instanceof Error ? error.message : "Invalid command");
69
+ process.exit(1);
70
+ }
71
+ const server = new McpServer({ name: "codex-computer-use-mcp", version }, { capabilities: { logging: {} } });
72
+ const operationSchema = {
73
+ mode: z.enum(["list", "inspect", "act", "dictionary_lookup"]).describe("safe mode permits only list; inspect, act, and dictionary_lookup require explicitly acknowledged broad full-permissions mode"),
74
+ app: z.string().max(500).optional().describe("App name, bundle identifier, or app-bundle path"),
75
+ task: z.string().max(4000).optional().describe("Concrete target-app task for act mode"),
76
+ query: z.string().max(200).optional().describe("Local word or phrase for dictionary_lookup; never include secrets or private/customer content"),
77
+ cleanup: z.boolean().optional().describe("Restore transient state and verify cleanup"),
78
+ cleanup_instructions: z.string().max(2000).optional().describe("Optional cleanup postcondition"),
79
+ required_capabilities: z.array(z.enum(COMPUTER_USE_TOOLS)).max(8).optional().describe("Computer Use methods that must genuinely be exercised"),
80
+ };
81
+ server.registerTool("background_computer_use", {
82
+ title: "Background Computer Use",
83
+ description: "Use the official signed Codex Computer Use broker for native macOS apps. Safe mode is deliberately list-only because target checks are observable only after signed-client dispatch. Explicit full-permissions enables inspect/act/dictionary operations with broad wrapper authorization; it never bypasses first-party OpenAI app approvals, sensitive-action prompts, macOS privacy controls, signing checks, focus telemetry, locks, timeouts, cleanup verification, or sanitized audit logging. Calls consume separate Codex usage.",
84
+ inputSchema: operationSchema,
85
+ annotations: {
86
+ readOnlyHint: false,
87
+ destructiveHint: true,
88
+ idempotentHint: false,
89
+ openWorldHint: false,
90
+ },
91
+ }, async (args, extra) => {
92
+ try {
93
+ const response = await executeOperation(args, { signal: extra.signal });
94
+ return {
95
+ content: [{ type: "text", text: response.text }],
96
+ structuredContent: response.details,
97
+ isError: response.isError,
98
+ };
99
+ }
100
+ catch (error) {
101
+ const message = error instanceof Error ? error.message : "Computer Use failed";
102
+ return {
103
+ content: [{ type: "text", text: message }],
104
+ isError: true,
105
+ };
106
+ }
107
+ });
108
+ server.registerTool("background_computer_use_status", {
109
+ title: "Background Computer Use Status",
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
+ },
117
+ }, async () => {
118
+ try {
119
+ const status = await getStatus();
120
+ return {
121
+ content: [{ type: "text", text: JSON.stringify(status, null, 2) }],
122
+ structuredContent: status,
123
+ };
124
+ }
125
+ catch (error) {
126
+ return {
127
+ content: [{ type: "text", text: error instanceof Error ? error.message : "Could not read status" }],
128
+ isError: true,
129
+ };
130
+ }
131
+ });
132
+ const transport = new StdioServerTransport();
133
+ await server.connect(transport);
134
+ //# sourceMappingURL=mcp-server.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcp-server.js","sourceRoot":"","sources":["../src/mcp-server.ts"],"names":[],"mappings":";AACA,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AAEjF,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,WAAW,EAAoB,MAAM,YAAY,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,kBAAkB,EAAE,KAAK,EAAuB,MAAM,aAAa,CAAC;AAC7E,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE7E,MAAM,OAAO,GAAG,OAAO,CAAC;AAExB,KAAK,UAAU,SAAS;IACtB,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACnC,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IACpC,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,UAAU,EAAE,CAAC;QAChD,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,SAAS,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;QACxD,OA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IACJ,CAAC;AACH,CAAC,CACF,CAAC;AAEF,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;AAC7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC"}
@@ -0,0 +1,42 @@
1
+ export declare const MODEL = "gpt-5.6-sol";
2
+ export declare const MODEL_REASONING = "xhigh";
3
+ export type ReasoningEffort = "low" | "high" | "xhigh";
4
+ export declare const COMPUTER_USE_TOOLS: readonly ["list_apps", "get_app_state", "click", "perform_secondary_action", "set_value", "select_text", "scroll", "drag", "press_key", "type_text"];
5
+ export type ComputerUseTool = (typeof COMPUTER_USE_TOOLS)[number];
6
+ export type Mode = "list" | "inspect" | "act" | "dictionary_lookup";
7
+ export type PermissionMode = "safe" | "full-permissions";
8
+ export declare const DICTIONARY_BUNDLE_ID = "com.apple.Dictionary";
9
+ export declare const DICTIONARY_NEUTRAL_QUERY = "dictionary";
10
+ export interface NativeAppInput {
11
+ mode: Mode;
12
+ app?: string;
13
+ task?: string;
14
+ query?: string;
15
+ cleanup?: boolean;
16
+ cleanup_instructions?: string;
17
+ required_capabilities?: ComputerUseTool[];
18
+ }
19
+ export interface ValidatedRequest {
20
+ mode: Mode;
21
+ permissionMode: PermissionMode;
22
+ app?: string;
23
+ task?: string;
24
+ query?: string;
25
+ cleanup: boolean;
26
+ cleanupInstructions?: string;
27
+ requiredCapabilities: ComputerUseTool[];
28
+ mutating: boolean;
29
+ maxComputerUseCalls: number;
30
+ reasoningEffort: ReasoningEffort;
31
+ }
32
+ export declare class PolicyError extends Error {
33
+ constructor(message: string);
34
+ }
35
+ export declare function validateRequest(input: NativeAppInput, permissionMode?: PermissionMode): ValidatedRequest;
36
+ export declare function allowedToolsForRequest(request: ValidatedRequest): ComputerUseTool[];
37
+ export declare function isDictionaryAlwaysAllowed(request: ValidatedRequest, resolvedBundleId: string | undefined, verifiedSystemDictionary: boolean): boolean;
38
+ export declare function requiresPiConfirmation(request: ValidatedRequest, resolvedBundleId: string | undefined, verifiedSystemDictionary: boolean): boolean;
39
+ export declare function validateResolvedAppIdentity(request: ValidatedRequest, resolvedBundleId: string | undefined, verifiedSystemDictionary: boolean): void;
40
+ export type ComputerUseArgumentValidator = (tool: string, args: Record<string, unknown>) => string | undefined;
41
+ export declare function createDictionaryArgumentValidator(query: string): ComputerUseArgumentValidator;
42
+ export declare function validateObservedMethods(request: ValidatedRequest, methods: string[]): void;