graff — a fast agentic coding harness in Zig: multi-provider, MCP, workflows, DGM evolution loop, TS/Python SDKs
Python
fix(#618): preserve signed computer-use bridge
Rach Pradhanf27c7c5dfc0f
diff --git a/docs/adr/0036-computer-use-keeps-the-signed-codex-bridge.md b/docs/adr/0036-computer-use-keeps-the-signed-codex-bridge.mdnew file mode 100644index 00000000..172398f6--- /dev/null+++ b/docs/adr/0036-computer-use-keeps-the-signed-codex-bridge.md@@ -0,0 +1,51 @@+# 0036. Computer Use keeps the signed Codex bridge++Status: accepted 2026-08-26++## Context++The OpenAI Computer Use plugin declares `bundledContentVariant: node-repl`.+Its skill imports `@oai/sky` through Codex's `node_repl`, but Graff previously+advertised only the plugin's raw MCP client. Both that client and a directly+spawned node_repl reached the macOS service and failed with `Sender process is+not authenticated`; the service authenticates the signed process chain.++Launching the same configured node_repl through the sibling signed `codex+sandbox` binary, with the Computer Use Unix socket explicitly allowed, passed+authentication. A live read-only call returned the installed app catalog; a+later locked-screen run returned the service's normal lock guard rather than+the sender-authentication error.++ADR 0023 rejects an embedded V8 / Code Mode runtime because RLM already owns+that product role. Weakening or spoofing the Computer Use check is not an+acceptable compatibility layer.++## Decision++On macOS, when an enabled Codex plugin selects the `node-repl` content+variant, do not advertise its raw Computer Use MCP launcher. Read the configured+node_repl executable from `~/.codex/config.toml`, accept only the ChatGPT+Resources `cua_node/bin/node_repl` layout, and synthesize one consent-gated+`node_repl` MCP server:++- the command is the sibling signed `codex` binary;+- `codex sandbox -P :danger-full-access` launches node_repl with only the+ Computer Use socket allowlisted;+- the environment contains the minimal trusted `@oai/sky` module/service+ paths and process basics; and+- the skill addendum maps `node_repl` calls to Graff's qualified+ `mcp__node_repl__js*` names without changing confirmation policy or image+ handling.++If the signed layout cannot be proven, retain the plugin-declared MCP fallback+for custom hosts. A Graff/global/project `node_repl` entry still wins.++## Consequences++- Computer Use is usable without adding a Graff-owned JS runtime or crossing+ the service's authentication boundary.+- Plugin MCP remains subject to the existing `/mcp trust` / `--yolo` consent+ gate (ADR 0007).+- This adapter is intentionally macOS/Codex-layout-specific. A future public+ cross-harness Computer Use protocol should replace it; an unsigned direct+ launcher should not.diff --git a/docs/adr/README.md b/docs/adr/README.mdindex 7d8f8072..97853e7f 100644--- a/docs/adr/README.md+++ b/docs/adr/README.md@@ -46,6 +46,7 @@ record only when you need the evidence or the edge cases.| [0033](0033-user-can-retire-a-standing-constraint.md) | Only the user retires a standing constraint: TTY `/never` picker (two confirms), ACP/`rm`, or an explicit override. The model cannot. || [0034](0034-remote-images-stay-native.md) | JSON/serve image inputs are a typed URL/base64 union, validated atomically and preserved as native provider vision blocks; never flatten pixels into prompt text. || [0035](0035-first-turn-skips-deferred-mcp-join.md) | First model call after a deferred MCP boot does not wait for the handshake; native tools run now, MCP catalogs merge on the next request. |+| [0036](0036-computer-use-keeps-the-signed-codex-bridge.md) | Codex Computer Use keeps its authenticated node_repl process chain: Graff launches it through the signed Codex sandbox wrapper, never embeds V8 or spoofs the service. |## When to write onediff --git a/docs/releases/v0.0.279.md b/docs/releases/v0.0.279.mdindex 3947a56d..af426fdb 100644--- a/docs/releases/v0.0.279.md+++ b/docs/releases/v0.0.279.md@@ -111,9 +111,23 @@ run on that turn; MCP catalogs merge on the next request. Live ACPstarts. The native app skips the demo fade-up/stagger on live rows andshows elapsed from start.+## Codex Computer Use bridge (#618, ADR 0036)++The bundled Computer Use skill's required `node_repl` tools are now present in+Graff. On macOS, Graff preserves the service's authentication boundary by+launching Codex's configured node_repl through the sibling signed `codex+sandbox` wrapper and allowlisting only the Computer Use Unix socket. It does+not embed V8 or spoof the service. The skill maps its calls to+`mcp__node_repl__js`, keeps the original confirmation policy, and continues to+hand `nodeRepl.emitImage(...)` results through Graff's native MCP image path.++The plugin's raw MCP launcher is no longer advertised when the signed bridge+is available; that path fails macOS sender authentication under a standalone+Graff parent. `/mcp trust` / `--yolo` consent is unchanged.+## TestsUnit suite grows by the ACP translator cases (`kindFor`, thought/textchunks, minted tool ids, EventSink) plus the #638 picker/retire,-#640 deadline, #581 pin-budget, and #643 paste-boundary cases. Floor-stays **1683** from the 278 ratchet (slack 25).+#640 deadline, #581 pin-budget, #643 paste-boundary, and #618 signed-bridge+cases. The release-cut floor advances to **1715** (slack 25).diff --git a/scripts/eval/tier1-manifest.json b/scripts/eval/tier1-manifest.jsonindex cc3c6283..6b7f49a6 100644--- a/scripts/eval/tier1-manifest.json+++ b/scripts/eval/tier1-manifest.json@@ -15,7 +15,7 @@"src/repl.zig","TUI/root.zig"],- "test_count_baseline": 1683,+ "test_count_baseline": 1715,"test_count_slack": 25,"required_invariants": [{diff --git a/src/codex_node_repl.zig b/src/codex_node_repl.zignew file mode 100644index 00000000..968b1629--- /dev/null+++ b/src/codex_node_repl.zig@@ -0,0 +1,205 @@+//! Codex Computer Use bridge for a standalone Graff process (#618).+//!+//! The bundled Computer Use skill is the `node-repl` content variant. Its+//! `@oai/sky` service authenticates the process chain on macOS, so starting+//! either node_repl or the plugin's direct MCP client under Graff fails with+//! "Sender process is not authenticated". Keep that boundary intact: launch+//! Codex's configured node_repl through the sibling, signed Codex sandbox+//! binary and expose its three MCP tools. This is deliberately not a generic+//! JavaScript runtime (ADR 0023); callers only invoke it for that plugin+//! variant, and the resulting MCP server still goes through normal consent.++const std = @import("std");+const builtin = @import("builtin");+const Io = std.Io;+const Allocator = std.mem.Allocator;+const Value = std.json.Value;++pub const server_name = "node_repl";++const node_suffix = "/cua_node/bin/node_repl";+const socket_rel = "Library/Group Containers/2DC432GLL2.com.openai.sky.CUAService/IPC";++fn join(arena: Allocator, a: []const u8, b: []const u8) ?[]const u8 {+ return std.fmt.allocPrint(arena, "{s}/{s}", .{ std.mem.trimEnd(u8, a, "/"), std.mem.trimStart(u8, b, "/") }) catch null;+}++fn stripComment(raw: []const u8) []const u8 {+ var quoted = false;+ var quote: u8 = 0;+ for (raw, 0..) |c, i| {+ if ((c == '\'' or c == '"') and (i == 0 or raw[i - 1] != '\\')) {+ if (!quoted) {+ quoted = true;+ quote = c;+ } else if (c == quote) quoted = false;+ } else if (c == '#' and !quoted) return std.mem.trim(u8, raw[0..i], " \t\r");+ }+ return std.mem.trim(u8, raw, " \t\r");+}++fn tableName(line: []const u8) ?[]const u8 {+ if (line.len < 3 or line[0] != '[' or line[line.len - 1] != ']') return null;+ return std.mem.trim(u8, line[1 .. line.len - 1], " \t");+}++fn nodeTable(name: []const u8) bool {+ return std.mem.eql(u8, name, "mcp_servers.node_repl") or+ std.mem.eql(u8, name, "mcp_servers.\"node_repl\"") or+ std.mem.eql(u8, name, "mcp_servers.'node_repl'");+}++/// Only accept a plain TOML string. Reject escapes rather than mis-resolving a+/// security-sensitive executable path with a half TOML parser.+fn stringValue(line: []const u8, key: []const u8) ?[]const u8 {+ const eq = std.mem.indexOfScalar(u8, line, '=') orelse return null;+ if (!std.mem.eql(u8, std.mem.trim(u8, line[0..eq], " \t"), key)) return null;+ const value = std.mem.trim(u8, line[eq + 1 ..], " \t");+ if (value.len < 2 or value[0] != value[value.len - 1] or (value[0] != '"' and value[0] != '\'')) return null;+ const inner = value[1 .. value.len - 1];+ if (std.mem.indexOfScalar(u8, inner, '\\') != null) return null;+ return inner;+}++fn configuredCommand(text: []const u8) ?[]const u8 {+ var in_node = false;+ var lines = std.mem.splitScalar(u8, text, '\n');+ while (lines.next()) |raw| {+ const line = stripComment(raw);+ if (line.len == 0) continue;+ if (tableName(line)) |name| {+ in_node = nodeTable(name);+ continue;+ }+ if (in_node) if (stringValue(line, "command")) |command| return command;+ }+ return null;+}++fn putString(arena: Allocator, object: *std.json.ObjectMap, key: []const u8, value: []const u8) bool {+ object.put(arena, key, .{ .string = arena.dupe(u8, value) catch return false }) catch return false;+ return true;+}++fn appendString(arena: Allocator, array: *std.json.Array, value: []const u8) bool {+ array.append(.{ .string = arena.dupe(u8, value) catch return false }) catch return false;+ return true;+}++fn serverFromCommand(io: Io, arena: Allocator, home: []const u8, project_dir: []const u8, node_command: []const u8) ?Value {+ if (builtin.os.tag != .macos or home.len == 0 or project_dir.len == 0) return null;+ if (!std.mem.endsWith(u8, node_command, node_suffix)) return null;+ const resources = node_command[0 .. node_command.len - node_suffix.len];+ if (resources.len == 0) return null;++ const codex = join(arena, resources, "codex") orelse return null;+ const node = join(arena, resources, "cua_node/bin/node") orelse return null;+ const modules = join(arena, resources, "cua_node/lib/node_modules") orelse return null;+ const codex_home = join(arena, home, ".codex") orelse return null;+ const computer_use_app = join(arena, codex_home, "computer-use/Codex Computer Use.app") orelse return null;+ const socket = join(arena, home, socket_rel) orelse return null;+ if ((Io.Dir.cwd().statFile(io, codex, .{}) catch null) == null or+ (Io.Dir.cwd().statFile(io, node_command, .{}) catch null) == null or+ (Io.Dir.cwd().statFile(io, node, .{}) catch null) == null) return null;++ var args = std.json.Array.init(arena);+ for ([_][]const u8{+ "sandbox", "-P", ":danger-full-access", "-C", project_dir,+ "--allow-unix-socket", socket, "--", node_command,+ }) |arg| if (!appendString(arena, &args, arg)) return null;++ const trusted_code = std.fmt.allocPrint(arena, "{s}:{s}", .{ codex_home, modules }) catch return null;+ var env: std.json.ObjectMap = .empty;+ const pairs = [_][2][]const u8{+ .{ "HOME", home },+ .{ "PATH", "/usr/bin:/bin:/usr/sbin:/sbin" },+ .{ "TMPDIR", "/tmp" },+ .{ "CODEX_HOME", codex_home },+ .{ "CODEX_CLI_PATH", codex },+ .{ "NODE_REPL_NODE_PATH", node },+ .{ "NODE_REPL_NODE_MODULE_DIRS", modules },+ .{ "NODE_REPL_TRUSTED_CODE_PATHS", trusted_code },+ .{ "NODE_REPL_TRUSTED_SERVICES", "{\"sky\":\"@oai/sky/service\"}" },+ .{ "NODE_REPL_NATIVE_PIPE_CONNECT_TIMEOUT_MS", "1000" },+ .{ "NODE_REPL_INSTRUCTIONS_USE_CASE_COMPUTER_USE", "Control desktop apps on macOS through Computer Use." },+ .{ "SKY_CUA_SERVICE_PATH", computer_use_app },+ };+ for (pairs) |pair| if (!putString(arena, &env, pair[0], pair[1])) return null;++ var cfg: std.json.ObjectMap = .empty;+ if (!putString(arena, &cfg, "command", codex)) return null;+ cfg.put(arena, "args", .{ .array = args }) catch return null;+ cfg.put(arena, "env", .{ .object = env }) catch return null;+ if (!putString(arena, &cfg, "cwd", project_dir)) return null;+ return .{ .object = cfg };+}++/// Fill `node_repl` only when Graff/user config did not already provide it.+/// True means a usable bridge already existed or was synthesized, so callers+/// should not advertise the plugin's unauthenticated direct client instead.+pub fn merge(io: Io, arena: Allocator, home: []const u8, project_dir: []const u8, servers: *std.json.ObjectMap, found: *bool) bool {+ if (servers.get(server_name) != null) return true;+ const config_path = join(arena, home, ".codex/config.toml") orelse return false;+ const text = Io.Dir.cwd().readFileAlloc(io, config_path, arena, .limited(1 << 20)) catch return false;+ const command = configuredCommand(text) orelse return false;+ const server = serverFromCommand(io, arena, home, project_dir, command) orelse return false;+ servers.put(arena, server_name, server) catch return false;+ found.* = true;+ return true;+}++const testing = std.testing;++test "configuredCommand reads only the node_repl MCP table (#618)" {+ const text =+ \\[mcp_servers.other]+ \\command = "/wrong"+ \\[mcp_servers."node_repl"] # selected+ \\args = []+ \\command = "/Applications/ChatGPT.app/Contents/Resources/cua_node/bin/node_repl"+ \\[mcp_servers.after]+ \\command = "/also-wrong"+ ;+ try testing.expectEqualStrings(+ "/Applications/ChatGPT.app/Contents/Resources/cua_node/bin/node_repl",+ configuredCommand(text).?,+ );+ try testing.expect(configuredCommand("[mcp_servers.node_repl]\ncommand = \"bad\\npath\"\n") == null);+}++test "serverFromCommand refuses a lookalike executable tree" {+ var arena_state = std.heap.ArenaAllocator.init(testing.allocator);+ defer arena_state.deinit();+ try testing.expect(serverFromCommand(testing.io, arena_state.allocator(), "/home/a", "/repo", "/tmp/node_repl") == null);+}++test "serverFromCommand builds the signed Codex sandbox bridge (#618)" {+ var tmp = testing.tmpDir(.{});+ defer tmp.cleanup();+ var arena_state = std.heap.ArenaAllocator.init(testing.allocator);+ defer arena_state.deinit();+ const arena = arena_state.allocator();+ var buf: [std.fs.max_path_bytes]u8 = undefined;+ const n = try tmp.dir.realPath(testing.io, &buf);+ const base = try arena.dupe(u8, buf[0..n]);+ const resources = join(arena, base, "ChatGPT.app/Contents/Resources").?;+ const node_dir = join(arena, resources, "cua_node/bin").?;+ try Io.Dir.cwd().createDirPath(testing.io, node_dir);+ const command = join(arena, resources, "cua_node/bin/node_repl").?;+ try Io.Dir.cwd().writeFile(testing.io, .{ .sub_path = command, .data = "" });+ try Io.Dir.cwd().writeFile(testing.io, .{ .sub_path = join(arena, resources, "cua_node/bin/node").?, .data = "" });+ try Io.Dir.cwd().writeFile(testing.io, .{ .sub_path = join(arena, resources, "codex").?, .data = "" });++ const home = join(arena, base, "home").?;+ const cfg = serverFromCommand(testing.io, arena, home, base, command).?.object;+ try testing.expectEqualStrings(join(arena, resources, "codex").?, cfg.get("command").?.string);+ try testing.expectEqualStrings(base, cfg.get("cwd").?.string);+ const args = cfg.get("args").?.array.items;+ try testing.expectEqualStrings("sandbox", args[0].string);+ try testing.expectEqualStrings(":danger-full-access", args[2].string);+ try testing.expectEqualStrings("--allow-unix-socket", args[5].string);+ try testing.expectEqualStrings(command, args[8].string);+ const env = cfg.get("env").?.object;+ try testing.expectEqualStrings("{\"sky\":\"@oai/sky/service\"}", env.get("NODE_REPL_TRUSTED_SERVICES").?.string);+ try testing.expect(std.mem.endsWith(u8, env.get("SKY_CUA_SERVICE_PATH").?.string, "Codex Computer Use.app"));+}diff --git a/src/main.zig b/src/main.zigindex ce1b54ee..e6f5c174 100644--- a/src/main.zig+++ b/src/main.zig@@ -55,6 +55,7 @@ const learn_store = @import("learn_store.zig");const learn_eval = @import("learn_eval.zig");const learn_cli = @import("learn_cli.zig");test { // unit_tests' root is main.zig only, so reference every split-out module or its tests silently never run+ _ = @import("codex_node_repl.zig");_ = pricing;_ = models_cache;_ = ansi;@@ -304,7 +305,6 @@ pub fn main(init: std.process.Init) !void {var stdin_buf: [64 * 1024]u8 = undefined;var stdin_reader = Io.File.stdin().reader(io, &stdin_buf);const in = &stdin_reader.interface;-var stdout_buf: [4096]u8 = undefined;var stdout_writer = Io.File.stdout().writer(io, &stdout_buf);const out = &stdout_writer.interface;diff --git a/src/mcp.zig b/src/mcp.zigindex b24f4168..d4db26d6 100644--- a/src/mcp.zig+++ b/src/mcp.zig@@ -245,13 +245,14 @@ pub const Registry = struct {/// time: some legacy SDK servers close stdout on an unrecognized/// pre-`initialize` message (`server/discover`), and the only fix is a/// fresh process — the closed one can't be un-closed.- fn spawnStdio(reg: *Registry, a: Allocator, argv: []const []const u8, env_map: ?*std.process.Environ.Map) !Transport {+ fn spawnStdio(reg: *Registry, a: Allocator, argv: []const []const u8, env_map: ?*std.process.Environ.Map, cwd: ?[]const u8) !Transport {var child = try std.process.spawn(reg.io, .{.argv = argv,.stdin = .pipe,.stdout = .pipe,.stderr = .ignore,.environ_map = env_map,+ .cwd = if (cwd) |path| .{ .path = path } else .inherit,});errdefer mcp_stdio.stopChild(reg.io, &child);const in_buf = try a.alloc(u8, 64 * 1024);@@ -282,6 +283,11 @@ pub const Registry = struct {// stdio child -- can spawn a fresh process with the same argv/env.var stdio_argv: std.ArrayList([]const u8) = .empty;var stdio_env_map: ?*std.process.Environ.Map = null;+ var stdio_cwd: ?[]const u8 = null;+ // Environ.Map owns its key/value copies with reg.gpa even though the+ // map struct itself is arena-backed. Spawn consumes the environment;+ // keep it through the possible probe respawn below, then release it.+ defer if (stdio_env_map) |map| map.deinit();if (url_v) |url| {if (url != .string) return error.BadMcpConfig;if (!validRemoteUrl(url.string)) return error.BadMcpUrl;@@ -320,6 +326,11 @@ pub const Registry = struct {}}+ if (cfg.get("cwd")) |cwd| {+ if (cwd != .string or cwd.string.len == 0) return error.BadMcpConfig;+ stdio_cwd = cwd.string;+ }+// Optional per-server env overlaid on the parent environment.if (cfg.get("env")) |env| {if (env != .object) return error.BadMcpConfig;@@ -333,7 +344,7 @@ pub const Registry = struct {stdio_env_map = m;}- server.* = .{ .name = name, .transport = try spawnStdio(reg, a, stdio_argv.items, stdio_env_map) };+ server.* = .{ .name = name, .transport = try spawnStdio(reg, a, stdio_argv.items, stdio_env_map, stdio_cwd) };}var registry_owns_server = false;@@ -375,7 +386,7 @@ pub const Registry = struct {.closed => {server.probe_fallback = .server_exited;mcp_stdio.stopChild(reg.io, &server.transport.stdio.child);- server.transport = try spawnStdio(reg, a, stdio_argv.items, stdio_env_map);+ server.transport = try spawnStdio(reg, a, stdio_argv.items, stdio_env_map, stdio_cwd);break :stdio_listed try mcp_rpc.connectStdio(server, a, a, reg.io);},}diff --git a/src/plugin_layout.zig b/src/plugin_layout.zigindex f96a801f..5a4aa6a7 100644--- a/src/plugin_layout.zig+++ b/src/plugin_layout.zig@@ -83,6 +83,15 @@ fn readManifest(io: Io, arena: Allocator, plugin_path: []const u8) ?Value {return null;}+/// Codex bundled plugins can select a host-provided content surface instead+/// of their raw MCP declaration. Computer Use uses this to require the signed+/// node_repl bridge (#618).+pub fn usesNodeRepl(io: Io, arena: Allocator, plugin_path: []const u8) bool {+ const manifest = readManifest(io, arena, plugin_path) orelse return false;+ const variant = manifest.object.get("bundledContentVariant") orelse return false;+ return variant == .string and std.mem.eql(u8, variant.string, "node-repl");+}+pub fn expandPlaceholders(arena: Allocator, text: []const u8, plugin_root: []const u8, project_dir: []const u8) []const u8 {if (std.mem.indexOf(u8, text, "${CLAUDE_") == null) return text;const step = std.mem.replaceOwned(u8, arena, text, "${CLAUDE_PLUGIN_ROOT}", plugin_root) catch text;@@ -110,13 +119,35 @@ fn expandValue(arena: Allocator, v: Value, plugin_root: []const u8, project_dir:};}-fn putServers(arena: Allocator, servers: *std.json.ObjectMap, found: *bool, v: ?Value) void {+fn prepareServer(arena: Allocator, plugin_root: []const u8, cfg: std.json.ObjectMap) ?Value {+ var out: std.json.ObjectMap = .empty;+ var it = cfg.iterator();+ while (it.next()) |e| out.put(arena, e.key_ptr.*, e.value_ptr.*) catch return null;++ // Plugin MCP commands are resolved from the plugin, not from whichever+ // repository launched graff. Codex's Computer Use package is the concrete+ // #618 witness: command `./bin/computer-use-client-launcher`, cwd `.`.+ if (out.get("cwd")) |cwd| {+ if (cwd != .string) return null;+ if (!std.fs.path.isAbsolute(cwd.string)) {+ const resolved = resolveRel(arena, plugin_root, cwd.string) orelse return null;+ out.put(arena, "cwd", .{ .string = resolved }) catch return null;+ }+ } else if (out.get("command")) |command| {+ if (command == .string and std.mem.startsWith(u8, command.string, "./"))+ out.put(arena, "cwd", .{ .string = plugin_root }) catch return null;+ }+ return .{ .object = out };+}++fn putServers(arena: Allocator, servers: *std.json.ObjectMap, found: *bool, v: ?Value, plugin_root: []const u8) void {const obj = if (v) |x| (if (x == .object) x.object else return) else return;var it = obj.iterator();while (it.next()) |e| {if (servers.get(e.key_ptr.*) != null) continue;if (e.value_ptr.* != .object) continue;- servers.put(arena, e.key_ptr.*, e.value_ptr.*) catch continue;+ const prepared = prepareServer(arena, plugin_root, e.value_ptr.*.object) orelse continue;+ servers.put(arena, e.key_ptr.*, prepared) catch continue;found.* = true;}}@@ -127,11 +158,11 @@ fn ingestText(arena: Allocator, servers: *std.json.ObjectMap, found: *bool, textconst expanded = expandValue(arena, parsed, plugin_root, project_dir);if (expanded != .object) return;if (expanded.object.get("mcpServers")) |inner| {- putServers(arena, servers, found, inner);+ putServers(arena, servers, found, inner, plugin_root);return;}// Inline `{ "name": { "command": ... } }` — Claude plugin.json shape.- putServers(arena, servers, found, expanded);+ putServers(arena, servers, found, expanded, plugin_root);}fn ingestFile(io: Io, arena: Allocator, servers: *std.json.ObjectMap, found: *bool, path: []const u8, plugin_root: []const u8, project_dir: []const u8) void {@@ -149,9 +180,9 @@ fn ingestMcpField(io: Io, arena: Allocator, servers: *std.json.ObjectMap, found:.object => {const expanded = expandValue(arena, field, plugin_path, project_dir);if (expanded.object.get("mcpServers")) |inner| {- putServers(arena, servers, found, inner);+ putServers(arena, servers, found, inner, plugin_path);} else {- putServers(arena, servers, found, expanded);+ putServers(arena, servers, found, expanded, plugin_path);}},else => {},@@ -339,6 +370,45 @@ test "mergeMcp: inline servers expand CLAUDE_PLUGIN_ROOT; extra file paths work"try testing.expect(std.mem.indexOf(u8, cmd, "${CLAUDE_") == null);}+test "mergeMcp: plugin-relative command and cwd resolve from the plugin (#618)" {+ var tmp = testing.tmpDir(.{});+ defer tmp.cleanup();+ var arena_state = std.heap.ArenaAllocator.init(testing.allocator);+ defer arena_state.deinit();+ const arena = arena_state.allocator();+ const io = testing.io;+ const base = try tmpBase(io, &tmp, arena);+ const plug = join(arena, base, "computer-use");+ try Io.Dir.cwd().createDirPath(io, plug);+ try Io.Dir.cwd().writeFile(io, .{ .sub_path = join(arena, plug, ".mcp.json"), .data = "{\"mcpServers\":{\"computer-use\":{\"command\":\"client\"}}}" });+ try Io.Dir.cwd().writeFile(io, .{ .sub_path = join(arena, plug, "mcp.json"), .data = "{\"mcpServers\":{\"relative\":{\"command\":\"./bin/server\",\"cwd\":\".\"}}}" });++ var servers: std.json.ObjectMap = .empty;+ var found = false;+ mergeMcp(io, arena, plug, base, &servers, &found);+ try testing.expect(found);+ try testing.expectEqual(@as(usize, 2), servers.count());+ const relative = servers.get("relative").?.object;+ try testing.expectEqualStrings("./bin/server", relative.get("command").?.string);+ try testing.expectEqualStrings(plug, relative.get("cwd").?.string);+}++test "usesNodeRepl reads the Codex bundled content variant (#618)" {+ var tmp = testing.tmpDir(.{});+ defer tmp.cleanup();+ var arena_state = std.heap.ArenaAllocator.init(testing.allocator);+ defer arena_state.deinit();+ const arena = arena_state.allocator();+ const base = try tmpBase(testing.io, &tmp, arena);+ const plug = join(arena, base, "computer-use");+ try Io.Dir.cwd().createDirPath(testing.io, join(arena, plug, ".codex-plugin"));+ try Io.Dir.cwd().writeFile(testing.io, .{+ .sub_path = join(arena, plug, ".codex-plugin/plugin.json"),+ .data = "{\"name\":\"computer-use\",\"bundledContentVariant\":\"node-repl\"}",+ });+ try testing.expect(usesNodeRepl(testing.io, arena, plug));+}+test "resolveRel refuses parent-directory escapes" {var arena_state = std.heap.ArenaAllocator.init(testing.allocator);defer arena_state.deinit();diff --git a/src/plugin_mcp_variant.zig b/src/plugin_mcp_variant.zignew file mode 100644index 00000000..1ae679ea--- /dev/null+++ b/src/plugin_mcp_variant.zig@@ -0,0 +1,30 @@+//! Host-specific MCP surfaces selected by plugin manifest variants.++const std = @import("std");+const Io = std.Io;+const Allocator = std.mem.Allocator;+const layout = @import("plugin_layout.zig");+const codex_node_repl = @import("codex_node_repl.zig");++/// Merge each plugin MCP declaration, replacing Codex's raw Computer Use+/// client with its signed node_repl content variant when available (#618).+pub fn merge(io: Io, arena: Allocator, home: []const u8, cwd: []const u8, plugs: anytype, servers: *std.json.ObjectMap, found: *bool) void {+ var node_repl_plugin: ?[]const u8 = null;+ for (plugs) |p| {+ if (!p.mcp) continue;+ if (@import("builtin").os.tag == .macos and+ std.ascii.eqlIgnoreCase(p.name, "computer-use") and+ layout.usesNodeRepl(io, arena, p.path))+ {+ node_repl_plugin = p.path;+ continue;+ }+ layout.mergeMcp(io, arena, p.path, cwd, servers, found);+ }+ if (node_repl_plugin) |path| {+ const bridged = codex_node_repl.merge(io, arena, home, cwd, servers, found);+ // Custom/non-Codex builds may make the plugin client callable. Keep+ // that declared fallback only when no signed bridge was available.+ if (!bridged) layout.mergeMcp(io, arena, path, cwd, servers, found);+ }+}diff --git a/src/plugins.zig b/src/plugins.zigindex 4f5a7797..f6f6d01e 100644--- a/src/plugins.zig+++ b/src/plugins.zig@@ -266,12 +266,10 @@ fn takeRel(io: Io, arena: Allocator, dir: Io.Dir, servers: *std.json.ObjectMap,pub fn mergeMcp(io: Io, arena: Allocator, home: []const u8, dir: Io.Dir, servers: *std.json.ObjectMap, found: *bool) void {if (off()) return;var buf: [std.fs.max_path_bytes]u8 = undefined;- const n = dir.realPath(io, &buf) catch 0;+ const n = dir.realPath(io, &buf) catch Io.Dir.cwd().realPathFile(io, ".", &buf) catch 0;const cwd = if (n > 0) buf[0..n] else null;const plugs = discover(io, arena, if (home.len > 0) home else null, dir);- for (plugs) |p| {- if (p.mcp) layout.mergeMcp(io, arena, p.path, cwd orelse "", servers, found);- }+ @import("plugin_mcp_variant.zig").merge(io, arena, home, cwd orelse "", plugs, servers, found);if (home.len > 0) {takeAbs(io, arena, servers, found, join(arena, home, ".claude.json"), cwd);takeAbs(io, arena, servers, found, join(arena, home, ".claude/settings.json"), null);diff --git a/src/skill_docs.zig b/src/skill_docs.zigindex 4bad93da..84cab771 100644--- a/src/skill_docs.zig+++ b/src/skill_docs.zig@@ -24,6 +24,7 @@ const ToolOutput = tools.ToolOutput;// Only the settings-file location, never the approval session (#422 ratchet).const policy = @import("harness_policy.zig");const plugins = @import("plugins.zig");+const runtime_adapter = @import("skill_runtime_adapter.zig");pub const Source = enum {builtin,@@ -319,6 +320,8 @@ fn render(gpa: Allocator, io: Io, sk: Skill) ![]u8 {var aw: Io.Writer.Allocating = .init(gpa);errdefer aw.deinit();try aw.writer.print("# skill: {s} ({s})\n\n", .{ sk.name, sk.source.label() });+ const adapter = runtime_adapter.prefix(sk.name, sk.source == .plugin);+ if (adapter.len > 0) try aw.writer.print("{s}\n\n", .{adapter});try aw.writer.writeAll(util.utf8Prefix(body, body_cap));if (body.len > body_cap)try aw.writer.print("\n\n[body truncated at {d} KB — read the rest from {s}]", .{ body_cap / 1024, sk.path });diff --git a/src/skill_runtime_adapter.zig b/src/skill_runtime_adapter.zignew file mode 100644index 00000000..c672ba90--- /dev/null+++ b/src/skill_runtime_adapter.zig@@ -0,0 +1,25 @@+//! Runtime-specific addenda for foreign skills whose documented backend is+//! not callable from a standalone graff process. The original skill stays on+//! disk and is still shown after this short, explicit override.++const std = @import("std");++pub const computer_use =+ \\## Graff runtime adapter+ \\+ \\Graff exposes this plugin's authenticated, signed Codex `node_repl` bridge through MCP-qualified tool names. Keep the bootstrap, confirmation policy, fresh-state workflow, and `nodeRepl.emitImage(...)` instructions below unchanged.+ \\+ \\- Where the skill says to use `node_repl`, call `mcp__node_repl__js`; use `mcp__node_repl__js_reset` and `mcp__node_repl__js_add_node_module_dir` for the two companion operations.+ \\- If those tools are absent, ask the user to run `/mcp trust` or restart with `--yolo`. Do not use the plugin's raw Computer Use MCP client or substitute OS event synthesis: the macOS service authenticates the signed Codex process chain.+;++pub fn prefix(name: []const u8, from_plugin: bool) []const u8 {+ if (from_plugin and std.ascii.eqlIgnoreCase(name, "computer-use")) return computer_use;+ return "";+}++test "only the plugin Computer Use skill receives the signed node_repl adapter" {+ try std.testing.expect(std.mem.indexOf(u8, prefix("computer-use", true), "mcp__node_repl__js") != null);+ try std.testing.expectEqualStrings("", prefix("computer-use", false));+ try std.testing.expectEqualStrings("", prefix("other", true));+}