Buckets:
| #!/usr/bin/env python3 | |
| """Expose OpenAI's native Linux Computer Use runtime over stdio MCP.""" | |
| import json | |
| import os | |
| from pathlib import Path | |
| import stat | |
| import sys | |
| def main(): | |
| native_root = Path(__file__).resolve().parent | |
| runtime = native_root / "runtime" | |
| modules = runtime / "lib/node_modules" | |
| node = runtime / "bin/node" | |
| repl = runtime / "bin/node_repl" | |
| helper = modules / "@oai/sky/bin/linux/sky_linux_x64" | |
| helper_launcher = native_root / "sky-helper.py" | |
| desktop = native_root / "desktop/run.py" | |
| for required in (node, repl, helper, helper_launcher, modules, desktop, native_root / "linux-api.md"): | |
| if not required.exists(): | |
| raise SystemExit(f"Native Computer Use runtime is missing: {required}") | |
| # The persistent filesystem can restore file contents without executable | |
| # mode bits when the task environment refreshes. Repair only this bundle's | |
| # known native executables, all extracted from the official Linux package. | |
| for executable in (node, repl, helper, helper_launcher): | |
| if not os.access(executable, os.X_OK): | |
| executable.chmod(stat.S_IMODE(executable.stat().st_mode) | 0o111) | |
| if "--inside-display" not in sys.argv: | |
| os.execv(sys.executable, [ | |
| sys.executable, str(desktop), "--", | |
| sys.executable, str(Path(__file__).resolve()), "--inside-display", | |
| ]) | |
| api = (native_root / "linux-api.md").read_text().split("---", 2)[-1].strip() | |
| description = ( | |
| "Operate this host's virtual Linux desktop using OpenAI's native @oai/sky runtime. " | |
| "The persistent JavaScript session has `sky` initialized. Start by capturing and " | |
| "viewing a screenshot, then use coordinates from the image for input. " | |
| "Desktop size is 1280 by 800 pixels. This is an X11 desktop with Openbox and xterm. " | |
| "Use `await nodeRepl.emitImage((await sky.get_screenshot())[0].data_url)` " | |
| "to display screenshots. Variables persist between calls.\n\n" + api | |
| ) | |
| env = os.environ.copy() | |
| env.update({ | |
| "CODEX_CLI_PATH": "/opt/npm-global/bin/codex", | |
| "OAI_SKY_LINUX_BIN": str(helper_launcher), | |
| "NODE_REPL_NODE_PATH": str(node), | |
| "NODE_REPL_NODE_MODULE_DIRS": str(modules), | |
| "NODE_REPL_TRUSTED_CODE_PATHS": str(modules), | |
| "NODE_REPL_TRUSTED_SERVICES": json.dumps({"sky": "@oai/sky/service"}), | |
| "NODE_REPL_JS_BANNER": 'globalThis.sky = (await import("@oai/sky")).sky;', | |
| "NODE_REPL_TOOL_OVERRIDES": json.dumps({ | |
| "server_instructions": ( | |
| "Native Computer Use for this host's virtual Linux desktop. " | |
| "Use the js tool and the initialized sky API to capture the screen and operate its UI." | |
| ), | |
| "tools": { | |
| "js": { | |
| "description": description, | |
| "field_descriptions": {"code": "JavaScript using the initialized native Linux sky API."}, | |
| }, | |
| }, | |
| }), | |
| }) | |
| os.execve(str(repl), [str(repl)], env) | |
| if __name__ == "__main__": | |
| main() | |
Xet Storage Details
- Size:
- 3.11 kB
- Xet hash:
- 1a804d4583e93f3aa687381888a93b69ca856f7dcc7fad7d5b548bae0832c17a
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.