Skip to content

👾 Open Computer Use – Open-Source Alternative to Codex Computer Use

Package Open Computer Use for npm

Leoa62f980c0ec7
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
new file mode 100644
index 0000000..1f789ad
--- /dev/null
+++ b/.github/workflows/release.yml
@@ -0,0 +1,54 @@
+name: release
+
+on:
+ workflow_dispatch:
+ inputs:
+ publish_to_npm:
+ description: "Publish the staged npm packages to npmjs.org"
+ required: true
+ default: false
+ type: boolean
+ npm_tag:
+ description: "npm dist-tag to use when publish_to_npm is enabled"
+ required: true
+ default: latest
+ type: string
+
+permissions:
+ contents: read
+
+jobs:
+ package-npm:
+ runs-on: macos-14
+
+ steps:
+ - name: Check out repository
+ uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd
+
+ - name: Set up Node.js
+ uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020
+ with:
+ node-version: "22"
+ registry-url: "https://registry.npmjs.org"
+
+ - name: Build npm release artifacts
+ run: npm run npm:pack
+
+ - name: Upload npm release artifacts
+ uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
+ with:
+ name: npm-release-artifacts
+ path: |
+ dist/release/npm/*.tgz
+ dist/release/release-manifest.json
+ if-no-files-found: error
+
+ - name: Publish packages to npm
+ if: ${{ inputs.publish_to_npm }}
+ env:
+ NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
+ run: |
+ node ./scripts/npm/publish-packages.mjs \
+ --skip-build \
+ --out-dir dist/release/npm-staging \
+ --tag "${{ inputs.npm_tag }}"
diff --git a/Makefile b/Makefile
index c83d9d4..0f9c174 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
PROJECT ?=
SLUG ?=
-.PHONY: init build app test smoke check-docs check-repo ci release-package new-history new-plan
+.PHONY: init build app test smoke check-docs check-repo ci release-package npm-build npm-publish new-history new-plan
init:
@if [ -z "$(PROJECT)" ]; then echo "用法: make init PROJECT=项目名"; exit 1; fi
@@ -32,6 +32,12 @@ ci:
release-package:
./scripts/release-package.sh
+npm-build:
+ node ./scripts/npm/build-packages.mjs
+
+npm-publish:
+ node ./scripts/npm/publish-packages.mjs
+
new-history:
@if [ -z "$(SLUG)" ]; then echo "用法: make new-history SLUG=变更名"; exit 1; fi
./scripts/new-history.sh "$(SLUG)"
diff --git a/README.md b/README.md
index 8b06bed..b9dc6b9 100644
--- a/README.md
+++ b/README.md
@@ -21,7 +21,84 @@
- `press_key`
- `set_value`
-## 快速开始
+## npm 一键安装
+
+现在可以直接用 npm 安装预编译包,不需要用户自己先装好 Swift/Xcode 再编译:
+
+```bash
+npm install -g open-computer-use
+```
+
+下面三个包名都可以安装到同一套内容:
+
+- `open-computer-use`
+- `open-computer-use-mcp`
+- `open-codex-computer-use-mcp`
+
+安装任意一个后,都会同时提供这三个命令别名:
+
+```bash
+# 检查当前权限状态,确认 Accessibility / Screen Recording 是否已经授权
+open-computer-use doctor
+
+# 以 stdio MCP server 模式启动,给 Claude Desktop / Cursor / Cline / 自定义 client 连接
+open-computer-use mcp
+
+# 安装到本机 Codex 插件系统,作为 repo-local / local marketplace plugin 使用
+open-computer-use install-codex-plugin
+```
+
+如果你是把它当普通 stdio MCP server 配到自己的 client 里,用法基本就是:
+
+1. 全局安装一个包:
+
+```bash
+npm install -g open-computer-use
+```
+
+2. 在你的 MCP client 配置里加一段 JSON:
+
+```json
+{
+ "mcpServers": {
+ "open-computer-use": {
+ "command": "open-computer-use",
+ "args": ["mcp"]
+ }
+ }
+}
+```
+
+3. 第一次实际调用前,给宿主终端或 app 授予 macOS `Accessibility` 和 `Screen Recording` 权限。
+
+也就是说,如果只是通过 MCP 使用,它现在就是“`npm install -g` + 一段配置 + 首次授权”这条路径。
+
+如果你的 client 也采用 `mcpServers` 这类 stdio MCP 配置结构,上面这段 JSON 可以直接作为起点。
+
+如果你想默认关闭点击时的软件 cursor overlay,也可以这样写:
+
+```json
+{
+ "mcpServers": {
+ "open-computer-use": {
+ "command": "open-computer-use",
+ "args": ["mcp"],
+ "env": {
+ "OPEN_COMPUTER_USE_VISUAL_CURSOR": "0"
+ }
+ }
+ }
+}
+```
+
+说明:
+
+- npm 包内已经携带预编译的 `Open Computer Use.app`,当前面向 macOS 14+。
+- 包内 `.app` 是 universal binary,同时支持 Apple Silicon 与 Intel Mac。
+- 真正执行前,宿主终端或 app 仍然需要被授予 `Accessibility` 与 `Screen Recording` 权限。
+- `open-computer-use install-codex-plugin` 会把 npm 包自身注册到本机 Codex 插件系统,不需要源码仓库路径。
+
+## 从源码运行
环境要求:
@@ -41,7 +118,13 @@ swift build
```bash
./scripts/build-open-computer-use-app.sh debug
-open dist/OpenComputerUse.app
+open "dist/Open Computer Use.app"
+```
+
+如果你要产出可分发的 universal app,可以显式传:
+
+```bash
+./scripts/build-open-computer-use-app.sh --configuration release --arch universal
```
启动 MCP server:
@@ -62,9 +145,9 @@ OPEN_COMPUTER_USE_VISUAL_CURSOR=0 .build/debug/OpenComputerUse mcp
./scripts/install-codex-plugin.sh
```
-这会把当前仓库注册成一个 repo-local marketplace,并启用插件 `open-computer-use`。脚本会在缺少打包产物时自动构建 `dist/OpenComputerUse.app`,写入 `~/.codex/config.toml`,并移除旧的直连 MCP 配置,避免同一组 tools 被重复注册。安装后重启 Codex 即可看到插件入口。
+这会把当前仓库注册成一个 repo-local marketplace,并启用插件 `open-computer-use`。脚本会在缺少打包产物时自动构建 `dist/Open Computer Use.app`,写入 `~/.codex/config.toml`,并移除旧的直连 MCP 配置,避免同一组 tools 被重复注册。安装后重启 Codex 即可看到插件入口。
它还会把插件包和已构建的 app 同步到 `~/.codex/plugins/cache/open-computer-use-local/open-computer-use/<version>/`,这样 Codex 实际加载的是本机插件缓存,而不是直接从源码仓库路径启动。
-如果你之前给旧的 `OpenCodexComputerUse.app` 授过 `Accessibility` / `Screen Recording` 权限,切到 `OpenComputerUse.app` 后需要在系统设置里重新授权一次。
+如果你之前给旧的 `OpenCodexComputerUse.app` 或 `OpenComputerUse.app` 授过 `Accessibility` / `Screen Recording` 权限,切到 `Open Computer Use.app` 后通常需要在系统设置里重新授权一次。
本地验证:
@@ -162,6 +245,8 @@ https://chatgpt.com/backend-api/codex/responses
端到端 smoke runner,会真实拉起 fixture 和 MCP server,对 9 个 tools 做回归。
- `scripts/build-open-computer-use-app.sh`
生成最小可运行的 `.app` bundle,便于真实授权与本地 UI 验证。
+- `scripts/npm/`
+ 生成三个 npm 包名对应的 staging 目录,并提供 dry-run / publish 脚本。
- `scripts/computer-use-cli`
一个独立 Go 模块,用来探测官方 bundled `computer-use` 和普通 stdio MCP server;默认会对官方 Sky client 走 `codex app-server` 代理,避免 caller signing / launch constraint 问题。
- `plugins/open-computer-use`
@@ -178,6 +263,20 @@ https://chatgpt.com/backend-api/codex/responses
- fixture app 为了提供稳定回归,会额外导出一份合成状态,并接受测试专用 command bridge。
- 当前不复刻官方闭源 app 的签名边界、私有 IPC、完整 overlay choreography 和插件自安装逻辑。
+## npm 发布
+
+仓库现在提供了三层 npm 相关入口:
+
+```bash
+node ./scripts/npm/build-packages.mjs
+./scripts/release-package.sh
+node ./scripts/npm/publish-packages.mjs
+```
+
+- `build-packages.mjs` 会构建 universal app 并 stage 三个 npm 包目录到 `dist/npm/`。
+- `release-package.sh` 会额外把它们打成 `dist/release/npm/*.tgz`,并生成 `dist/release/release-manifest.json`。
+- `.github/workflows/release.yml` 支持在 GitHub Actions 里手动触发打包,并可在配置 `NPM_TOKEN` secret 后直接发布到 npm。
+
## 许可证
[MIT](./LICENSE)
diff --git a/apps/OpenComputerUseSmokeSuite/Sources/OpenComputerUseSmokeSuite/main.swift b/apps/OpenComputerUseSmokeSuite/Sources/OpenComputerUseSmokeSuite/main.swift
index 665de19..70ec4c9 100644
--- a/apps/OpenComputerUseSmokeSuite/Sources/OpenComputerUseSmokeSuite/main.swift
+++ b/apps/OpenComputerUseSmokeSuite/Sources/OpenComputerUseSmokeSuite/main.swift
@@ -34,7 +34,7 @@ final class MCPClient {
_ = try request(method: "initialize", params: [
"clientInfo": [
"name": "OpenComputerUseSmokeSuite",
- "version": "0.1.2",
+ "version": "0.1.4",
],
"capabilities": [:],
"protocolVersion": "2025-03-26",
diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.md
index a445274..e5d555f 100644
--- a/docs/ARCHITECTURE.md
+++ b/docs/ARCHITECTURE.md
@@ -19,7 +19,7 @@
- software cursor overlay
- fixture test bridge
- `scripts/`
- 仓库级自动化命令,包括 smoke test、`.app` 打包入口,以及 `scripts/computer-use-cli/` 这个用于探测官方 bundled `computer-use` 的 Go helper。
+ 仓库级自动化命令,包括 smoke test、`.app` 打包入口、npm 分发脚本,以及 `scripts/computer-use-cli/` 这个用于探测官方 bundled `computer-use` 的 Go helper。
- `docs/`
逆向分析、执行计划、history 和项目约束。
@@ -30,7 +30,7 @@
- `OpenComputerUse` 默认 app 模式会拉起 `PermissionOnboardingApp`。
- app bundle 以 `LSUIElement` agent-style 形态运行,默认不在 Dock 暴露常驻图标,但仍可按需显示权限窗口。
- 主窗口负责渲染 `Accessibility` / `Screen & System Audio Recording` 两类权限卡片、`Allow` / `Done` 状态和 relaunch 后的状态收敛。
-- 辅助 drag panel 会跳转到对应的 `System Settings` 页面,并提供 app bundle 拖拽 tile。
+- 辅助 drag panel 会跳转到对应的 `System Settings` 页面,并把 app bundle 拖拽 tile 锚到该窗口右侧内容区的底边;它不再跟随 `Accessibility` 列表里的 `Add` / `Remove` 控件,避免页面局部布局变化导致 panel 漂移。
- 权限状态优先基于 TCC 持久授权记录判断,避免 CLI 子进程与 GUI app 对授权状态看到不一致的结果。
### 2. MCP 层
@@ -56,6 +56,7 @@
- `click` 在执行真实动作前后,会额外驱动一层透明 `SoftwareCursorOverlay` window:移动阶段走曲线动画,点击阶段做 pulse,动作结束后只保留一小段停驻与轻微 sway,随后自动淡出。
- overlay 的 visual style 优先在运行时从本机官方 `Codex Computer Use.app` 的 `Package_ComputerUse.bundle` / `Package_SlimCore.bundle` 读取 `SoftwareCursor` 资产并做一次本地处理;如果本机没有这份 bundle,则回退到仓库内的矢量样式。
- overlay 的层级不再固定 `.floating`;现在会跟随 snapshot 命中的目标 window id / layer,把自己排到该目标 window 之上,而不是粗暴压到所有前台 app 最上层。
+- overlay 的曲线路径不再只按固定 Bezier 模板生成;当 snapshot 带有目标 `windowID` 时,会对多组控制点候选做窗口命中采样,优先选“采样点仍落在目标 window 上”的路径,并在动画/idle 期间持续校验目标 window 是否还存在。
- 动作型 tools 对普通 app 采用“非侵入优先,HID 兜底”策略:
- `AXUIElementPerformAction`
- `AXUIElementSetAttributeValue`
@@ -83,6 +84,8 @@
- 单元测试:`swift test`
- 端到端 smoke:`./scripts/run-tool-smoke-tests.sh`
- app 打包:`./scripts/build-open-computer-use-app.sh debug`
+- npm staging:`node ./scripts/npm/build-packages.mjs`
+- release tgz:`./scripts/release-package.sh`
- 对比样本:`artifacts/tool-comparisons/20260417-focus-behavior/`
- 手工诊断:
- `.build/debug/OpenComputerUse doctor`
diff --git a/docs/CICD.md b/docs/CICD.md
index 4d6b0f9..058540e 100644
--- a/docs/CICD.md
+++ b/docs/CICD.md
@@ -2,17 +2,16 @@
这个模板自带一套不依赖具体语言栈的 CI/CD 骨架。
-## 默认包含的内容
+## 当前 release 入口
-- `ci.yml`:仓库级检查,覆盖 docs、repo hygiene、Markdown 和 shell 脚本校验。
-- `supply-chain-security.yml`:依赖变更检查、OSV 扫描、SBOM 生成和 Scorecard 分析。
-- `release.yml`:手动触发的 release 流水线,用来打包仓库级制品、生成 provenance,并创建 GitHub Release。
+- `scripts/release-package.sh`:构建 universal `Open Computer Use.app`,stage 三个 npm 包目录,并产出 `dist/release/npm/*.tgz` 与 `dist/release/release-manifest.json`。
+- `.github/workflows/release.yml`:手动触发的 release 流水线,会调用仓库内的 npm release 打包逻辑,并可在配置 `NPM_TOKEN` secret 后直接发布到 npm。
## 设计原则
这套默认流水线的目标,是在项目真正成形前先把交付链路搭起来,而不是假装已经知道未来项目该怎么 build 和 deploy。
-当新项目的技术栈确定后,你应该把 `scripts/release-package.sh` 里的占位打包逻辑替换成真实构建产物,而不是另起一套平行流程。
+当新项目的技术栈确定后,你应该继续在 `scripts/release-package.sh` 这条真实构建链路上扩展,而不是另起一套平行流程。
所有 GitHub Actions 都已经 pin 到 commit SHA。后续升级 action 时,也要继续保持这个约束。
@@ -20,7 +19,7 @@
1. 保留 `ci.yml`,作为仓库的基础门禁。
2. 在 `scripts/ci.sh` 里继续叠加项目自己的验证命令。
-3. 用真实构建产物替换 `scripts/release-package.sh`。
+3. 在 `scripts/release-package.sh` 已有的真实构建基础上继续扩展 release 产物。
4. 技术栈和环境稳定后,再补具体的部署 job。
5. 即使交付方式变化,SBOM 和 provenance 这类供应链能力也建议保留。
@@ -28,9 +27,10 @@
当前 release 流水线会产出:
-- `release-manifest.json`
-- `repo-metadata.tgz`
-- `sbom.spdx.json`
-- 对 release artifact 生成的 GitHub artifact attestation
+- `dist/release/release-manifest.json`
+- `dist/release/npm/open-computer-use-<version>.tgz`
+- `dist/release/npm/open-computer-use-mcp-<version>.tgz`
+- `dist/release/npm/open-codex-computer-use-mcp-<version>.tgz`
+- GitHub Actions 中上传的 npm release artifact
-也就是说,即使项目还没进入真实部署阶段,这个模板也已经把“可追溯的制品封装”这一步准备好了。
+也就是说,即使项目还没进入更复杂的部署阶段,仓库现在也已经具备了一条真实可复用的 npm 制品封装链路。
diff --git a/docs/exec-plans/completed/20260417-2115-npm-distribution.md b/docs/exec-plans/completed/20260417-2115-npm-distribution.md
new file mode 100644
index 0000000..c07f519
--- /dev/null
+++ b/docs/exec-plans/completed/20260417-2115-npm-distribution.md
@@ -0,0 +1,77 @@
+# npm 分发与发布执行计划
+
+## 目标
+
+让 `open-computer-use` 这套本地 macOS `computer-use` MCP server 能以 npm 形式直接分发,用户可以通过 `open-computer-use`、`open-computer-use-mcp` 或 `open-codex-computer-use-mcp` 任一包名完成安装,并拿到可直接运行的预编译产物与 Codex 插件安装入口。
+
+## 范围
+
+- 包含:
+ - 为仓库补一套真实可发布的 npm 打包与发布脚本。
+ - 产出可直接安装的预编译 `.app` 分发物,而不是只发源码。
+ - 支持三个 npm 包名发布到同一套内容。
+ - 更新 README、release 打包脚本、history 等仓库文档。
+- 不包含:
+ - 完整的 code signing / notarization。
+ - 自动修改用户系统权限设置。
+ - Windows / Linux 支持。
+
+## 背景
+
+- 相关文档:
+ - `docs/ARCHITECTURE.md`
+ - `docs/CICD.md`
+ - `docs/SECURITY.md`
+ - `docs/SUPPLY_CHAIN_SECURITY.md`
+- 相关代码路径:
+ - `scripts/build-open-computer-use-app.sh`
+ - `scripts/release-package.sh`
+ - `scripts/install-codex-plugin.sh`
+ - `plugins/open-computer-use/`
+- 已知约束:
+ - 当前仓库主体是 Swift 可执行程序,不是 Node 项目。
+ - 现有 release 打包脚本还是占位实现,不代表真实构建产物。
+ - npm 分发要尽量降低门槛,不能要求用户本地再装一套 Swift 构建链。
+
+## 风险
+
+- 风险:只发布源码 wrapper,会把安装门槛继续留给用户。
+- 缓解方式:npm 包里直接携带预编译 `.app` 和 CLI wrapper。
+
+- 风险:如果只发单架构二进制,会让一部分 macOS 用户安装后不可用。
+- 缓解方式:优先尝试产出 universal macOS binary;如果做不到,至少在 npm 元数据中显式限制平台。
+
+- 风险:Codex 插件安装仍依赖源码仓库路径,会削弱 npm 包价值。
+- 缓解方式:让 npm 包自身包含插件目录和安装脚本,能独立完成安装。
+
+## 里程碑
+
+1. 调研与方案收敛。
+2. 分阶段实现。
+3. 验证、交付与收尾。
+
+## 验证方式
+
+- 命令:
+ - `./scripts/build-open-computer-use-app.sh release --arch universal`
+ - `node ./scripts/npm/build-packages.mjs`
+ - `npm pack --dry-run`
+ - `swift test`
+- 手工检查:
+ - 解包后确认任一 npm 包都包含 `dist/Open Computer Use.app`、CLI alias 和 Codex 插件目录。
+ - 本地通过包内命令执行 `doctor` / `mcp`。
+- 观测检查:
+ - npm publish 前确认每个包名已 stage 为独立目录,版本一致。
+
+## 进度记录
+
+- [x] 里程碑 1
+- [x] 里程碑 2
+- [x] 里程碑 3
+
+## 决策记录
+
+- 2026-04-17:npm 分发不走“安装时本地编译”,而是优先走“发布时预编译、安装时直接可用”的方案,目的是把 Swift/Xcode 门槛从最终用户侧移到发布链路。
+- 2026-04-17:`.app` 分发物改成 universal binary,同时覆盖 `arm64` 与 `x86_64`,避免 npm 包把 Intel Mac 用户挡在门外。
+- 2026-04-17:npm 包内部保留一份最小仓库镜像,包括 `.agents/plugins/marketplace.json`、`plugins/open-computer-use/`、`dist/Open Computer Use.app` 与 `scripts/install-codex-plugin.sh`,这样包本身就能独立完成 Codex 插件安装。
+- 2026-04-17:新增 `.github/workflows/release.yml`,后续 GitHub Actions 沿用仓库内 `scripts/release-package.sh` 和 `scripts/npm/publish-packages.mjs` 这条真实构建链路,而不是另起一套发布脚本。
diff --git a/docs/histories/2026-04/20260417-2126-npm-distribution-and-publish.md b/docs/histories/2026-04/20260417-2126-npm-distribution-and-publish.md
new file mode 100644
index 0000000..8a0d6e2
--- /dev/null
+++ b/docs/histories/2026-04/20260417-2126-npm-distribution-and-publish.md
@@ -0,0 +1,38 @@
+## [2026-04-17 21:26] | Task: 打通 npm 分发并发布
+
+### 🤖 Execution Context
+* **Agent ID**: `codex`
+* **Base Model**: `GPT-5`
+* **Runtime**: `Codex CLI`
+
+### 📥 User Query
+> 帮我把这个打包成可以发到 npm 的,一键安装 `open-computer-use-mcp`、`open-codex-computer-use-mcp` 或 `open-computer-use` 都可以;现在的打包门槛太高。并直接发到用户的 npmjs,后续改成 GitHub Actions 发。
+
+### 🛠 Changes Overview
+**Scope:** `scripts/`、`.github/workflows/`、`docs/`、`README.md`、`package.json`
+
+**Key Actions:**
+- **实现 npm 分发链路**:新增 `scripts/npm/build-packages.mjs` 与 `scripts/npm/publish-packages.mjs`,可 stage 和发布三个包名对应的 npm 包。
+- **升级 app 打包**:扩展 `scripts/build-open-computer-use-app.sh`,支持构建 universal `Open Computer Use.app`,用于 npm 预编译分发。
+- **让 npm 包可独立安装到 Codex**:npm 包内携带插件目录、marketplace 配置和 `install-codex-plugin.sh`,安装后可直接执行 `open-computer-use install-codex-plugin`。
+- **替换 release 占位产物**:把 `scripts/release-package.sh` 从仓库元数据打包改成真实 npm tgz 产物输出,并生成 release manifest。
+- **补 GitHub Actions 骨架**:新增 `.github/workflows/release.yml`,支持手动打包和用 `NPM_TOKEN` 发布到 npm。
+- **实际发布到 npm**:发布 `[email protected]`、`[email protected]`、`[email protected]`。
+
+### 🧠 Design Intent (Why)
+这次改动的核心是把“用户安装成本”从终端用户侧转移到发布侧。与其要求每个用户都有 Swift/Xcode 构建环境,不如在发布时直接产出 universal `.app` 并塞进 npm 包,让安装后就能跑、就能装进 Codex 插件系统。这样既保留仓库内真实构建链路,也让后续 GitHub Actions 能复用同一套脚本。
+
+### 📁 Files Modified
+- `.github/workflows/release.yml`
+- `Makefile`
+- `README.md`
+- `docs/ARCHITECTURE.md`
+- `docs/CICD.md`
+- `docs/exec-plans/completed/20260417-2115-npm-distribution.md`
+- `package.json`
+- `scripts/build-open-computer-use-app.sh`
+- `scripts/ci.sh`
+- `scripts/install-codex-plugin.sh`
+- `scripts/npm/build-packages.mjs`
+- `scripts/npm/publish-packages.mjs`
+- `scripts/release-package.sh`
diff --git a/docs/histories/2026-04/20260417-2132-add-mcp-json-config-to-readme.md b/docs/histories/2026-04/20260417-2132-add-mcp-json-config-to-readme.md
new file mode 100644
index 0000000..b263d7b
--- /dev/null
+++ b/docs/histories/2026-04/20260417-2132-add-mcp-json-config-to-readme.md
@@ -0,0 +1,25 @@
+## [2026-04-17 21:32] | Task: 补 README 里的 MCP JSON 配置示例
+
+### 🤖 Execution Context
+* **Agent ID**: `codex`
+* **Base Model**: `GPT-5`
+* **Runtime**: `Codex CLI`
+
+### 📥 User Query
+> README 要加一个标准 MCP JSON 配置示例,明确告诉用户是不是 `npm install -g open-computer-use` 再加一段配置就能用了。
+
+### 🛠 Changes Overview
+**Scope:** `README.md`、`scripts/npm/build-packages.mjs`
+
+**Key Actions:**
+- **补仓库 README**:新增“全局安装 + `mcpServers` JSON + 首次授权”的标准使用路径。
+- **补 npm 包 README 模板**:让后续通过 npm 发布的新版本也自动带上相同的 MCP 配置示例。
+- **补可选环境变量示例**:给出关闭 visual cursor overlay 的 JSON 配置写法。
+- **补命令注释**:在 `doctor`、`mcp`、`install-codex-plugin` 命令上方加一行说明,降低首次上手理解成本。
+
+### 🧠 Design Intent (Why)
+对于 MCP server 来说,用户最需要的是一段可以直接粘贴进 client 配置的 JSON,而不是先理解仓库结构或插件安装逻辑。把这条路径放到 README 前面,可以直接回答“装完以后怎么配”这个问题,也更符合实际使用习惯。
+
+### 📁 Files Modified
+- `README.md`
+- `scripts/npm/build-packages.mjs`
diff --git a/docs/histories/2026-04/20260417-2138-bump-open-computer-use-to-0.1.3.md b/docs/histories/2026-04/20260417-2138-bump-open-computer-use-to-0.1.3.md
new file mode 100644
index 0000000..d4cbe36
--- /dev/null
+++ b/docs/histories/2026-04/20260417-2138-bump-open-computer-use-to-0.1.3.md
@@ -0,0 +1,29 @@
+## [2026-04-17 21:38] | Task: 发布 0.1.3
+
+### 🤖 Execution Context
+* **Agent ID**: `codex`
+* **Base Model**: `GPT-5`
+* **Runtime**: `Codex CLI`
+
+### 📥 User Query
+> 可以,加个版本发
+
+### 🛠 Changes Overview
+**Scope:** `plugins/`、`packages/`、`apps/`、`scripts/`、`docs/`
+
+**Key Actions:**
+- **统一版本号**:把插件 manifest、MCP server version、smoke suite client version 和 `computer-use-cli` 版本统一 bump 到 `0.1.3`。
+- **更新文档示例**:把 CLI 文档里引用插件缓存目录的版本路径从 `0.1.2` 更新到 `0.1.3`。
+- **准备发布**:让 npm 分发链路基于新的插件版本号生成 `0.1.3` 包并发布。
+
+### 🧠 Design Intent (Why)
+上一轮 README 改动需要同步到 npm 页面,最直接的方式就是做一次 patch release。把版本来源保持单点一致,可以避免 npm 包、MCP server 自报版本和插件缓存路径样例之间再次漂移。
+
+### 📁 Files Modified
+- `apps/OpenComputerUseSmokeSuite/Sources/OpenComputerUseSmokeSuite/main.swift`
+- `docs/references/codex-computer-use-cli.md`
+- `packages/OpenComputerUseKit/Sources/OpenComputerUseKit/MCPServer.swift`
+- `packages/OpenComputerUseKit/Tests/OpenComputerUseKitTests/OpenComputerUseKitTests.swift`
+- `plugins/open-computer-use/.codex-plugin/plugin.json`
+- `scripts/computer-use-cli/README.md`
+- `scripts/computer-use-cli/main.go`
diff --git a/docs/histories/2026-04/20260417-2148-fix-npm-bin-symlink-launcher.md b/docs/histories/2026-04/20260417-2148-fix-npm-bin-symlink-launcher.md
new file mode 100644
index 0000000..04caa9e
--- /dev/null
+++ b/docs/histories/2026-04/20260417-2148-fix-npm-bin-symlink-launcher.md
@@ -0,0 +1,23 @@
+## [2026-04-17 21:48] | Task: 修复 npm 全局 symlink 启动路径
+
+### 🤖 Execution Context
+* **Agent ID**: `codex`
+* **Base Model**: `GPT-5`
+* **Runtime**: `Codex CLI`
+
+### 📥 User Query
+> `open-computer-use` 在 Codex 里作为 MCP 启动失败,握手阶段连接提前关闭,想知道为什么。
+
+### 🛠 Changes Overview
+**Scope:** `scripts/npm/build-packages.mjs`
+
+**Key Actions:**
+- **定位根因**:确认全局安装后的 `/opt/homebrew/bin/open-computer-use` 是 symlink,而 launcher 用 `BASH_SOURCE[0]` 直接算包根目录,导致把包根误判成 `/opt/homebrew`。
+- **修复 launcher 模板**:让 npm 包生成的 `bin/open-computer-use` 先解析 symlink,再推导 `package_root`,兼容 Homebrew 风格的全局 npm bin 路径。
+- **本机临时修复**:同步修补当前已安装的全局 launcher,并把 `~/.codex/config.toml` 改成真实脚本路径,立即恢复当前环境可用性。
+
+### 🧠 Design Intent (Why)
+全局 npm 安装最常见的入口就是系统 bin 目录里的 symlink。如果 launcher 不能正确解析 symlink,发布到 npm 的包在默认安装路径上就会直接失效。这个问题比单纯文档问题更严重,必须在生成模板上修掉,而不是只靠配置绕过去。
+
+### 📁 Files Modified
+- `scripts/npm/build-packages.mjs`
diff --git a/docs/histories/2026-04/20260417-2154-bump-open-computer-use-to-0.1.4.md b/docs/histories/2026-04/20260417-2154-bump-open-computer-use-to-0.1.4.md
new file mode 100644
index 0000000..78e7ba3
--- /dev/null
+++ b/docs/histories/2026-04/20260417-2154-bump-open-computer-use-to-0.1.4.md
@@ -0,0 +1,29 @@
+## [2026-04-17 21:54] | Task: 发布 0.1.4
+
+### 🤖 Execution Context
+* **Agent ID**: `codex`
+* **Base Model**: `GPT-5`
+* **Runtime**: `Codex CLI`
+
+### 📥 User Query
+> 0.1.4 重新发
+
+### 🛠 Changes Overview
+**Scope:** `plugins/`、`packages/`、`apps/`、`scripts/`、`docs/`
+
+**Key Actions:**
+- **统一版本号**:把插件 manifest、MCP server version、smoke suite client version 和 `computer-use-cli` 版本统一 bump 到 `0.1.4`。
+- **更新文档示例**:把 CLI 文档里引用插件缓存目录的版本路径从 `0.1.3` 更新到 `0.1.4`。
+- **准备重新发布**:基于已经修好的 npm symlink launcher 模板重新生成并发布 `0.1.4` 包。
+
+### 🧠 Design Intent (Why)
+`0.1.3` 虽然已经把新 bundle 名称和图标带出去了,但 npm 全局 symlink 启动路径仍有 bug。发一个新的 patch release,能把 launcher 修复正式同步到 npm,而不是继续依赖本机热修。
+
+### 📁 Files Modified
+- `apps/OpenComputerUseSmokeSuite/Sources/OpenComputerUseSmokeSuite/main.swift`
+- `docs/references/codex-computer-use-cli.md`
+- `packages/OpenComputerUseKit/Sources/OpenComputerUseKit/MCPServer.swift`
+- `packages/OpenComputerUseKit/Tests/OpenComputerUseKitTests/OpenComputerUseKitTests.swift`
+- `plugins/open-computer-use/.codex-plugin/plugin.json`
+- `scripts/computer-use-cli/README.md`
+- `scripts/computer-use-cli/main.go`
diff --git a/docs/references/codex-computer-use-cli.md b/docs/references/codex-computer-use-cli.md
index 89091b7..7f5a65d 100644
--- a/docs/references/codex-computer-use-cli.md
+++ b/docs/references/codex-computer-use-cli.md
@@ -76,7 +76,7 @@ go run . call list_apps --transport app-server
cd scripts/computer-use-cli
go run . call list_apps \
--transport direct \
- --server-bin ~/.codex/plugins/cache/open-computer-use-local/open-computer-use/0.1.2/scripts/launch-open-computer-use.sh
+ --server-bin ~/.codex/plugins/cache/open-computer-use-local/open-computer-use/0.1.4/scripts/launch-open-computer-use.sh
```
## 什么时候不要再重试 direct
diff --git a/package.json b/package.json
new file mode 100644
index 0000000..fd1f1ac
--- /dev/null
+++ b/package.json
@@ -0,0 +1,10 @@
+{
+ "name": "open-computer-use-repo-tools",
+ "private": true,
+ "type": "module",
+ "scripts": {
+ "npm:build": "node ./scripts/npm/build-packages.mjs",
+ "npm:pack": "./scripts/release-package.sh",
+ "npm:publish": "node ./scripts/npm/publish-packages.mjs"
+ }
+}
diff --git a/packages/OpenComputerUseKit/Sources/OpenComputerUseKit/MCPServer.swift b/packages/OpenComputerUseKit/Sources/OpenComputerUseKit/MCPServer.swift
index 773209b..3ec5355 100644
--- a/packages/OpenComputerUseKit/Sources/OpenComputerUseKit/MCPServer.swift
+++ b/packages/OpenComputerUseKit/Sources/OpenComputerUseKit/MCPServer.swift
@@ -54,7 +54,7 @@ public final class StdioMCPServer {
"protocolVersion": "2025-03-26",
"serverInfo": [
"name": "open-computer-use",
- "version": "0.1.2",
+ "version": "0.1.4",
],
"capabilities": [
"tools": [
diff --git a/packages/OpenComputerUseKit/Tests/OpenComputerUseKitTests/OpenComputerUseKitTests.swift b/packages/OpenComputerUseKit/Tests/OpenComputerUseKitTests/OpenComputerUseKitTests.swift
index 4d69c8b..e67ee36 100644
--- a/packages/OpenComputerUseKit/Tests/OpenComputerUseKitTests/OpenComputerUseKitTests.swift
+++ b/packages/OpenComputerUseKit/Tests/OpenComputerUseKitTests/OpenComputerUseKitTests.swift
@@ -15,7 +15,7 @@ final class OpenComputerUseKitTests: XCTestCase {
func testInitializeResponseContainsToolsCapability() throws {
let server = StdioMCPServer(service: ComputerUseService())
- let response = server.handle(line: #"{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-03-26","clientInfo":{"name":"test","version":"0.1.2"},"capabilities":{}}}"#)
+ let response = server.handle(line: #"{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-03-26","clientInfo":{"name":"test","version":"0.1.4"},"capabilities":{}}}"#)
XCTAssertNotNil(response)
XCTAssertTrue(response!.contains(#""name":"open-computer-use""#))
XCTAssertTrue(response!.contains(#""tools":{"listChanged":false}"#))
@@ -24,7 +24,7 @@ final class OpenComputerUseKitTests: XCTestCase {
func testInitializeResponseContainsComputerUseInstructions() throws {
let server = StdioMCPServer(service: ComputerUseService())
let response = try XCTUnwrap(
- server.handle(line: #"{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-03-26","clientInfo":{"name":"test","version":"0.1.2"},"capabilities":{}}}"#)
+ server.handle(line: #"{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-03-26","clientInfo":{"name":"test","version":"0.1.4"},"capabilities":{}}}"#)
)
let data = try XCTUnwrap(response.data(using: .utf8))
let json = try XCTUnwrap(JSONSerialization.jsonObject(with: data) as? [String: Any])
@@ -138,6 +138,23 @@ final class OpenComputerUseKitTests: XCTestCase {
XCTAssertNotEqual(midpoint.y, 70)
}
+ func testCursorMotionPathSupportsStraightVariantForConservativeFallback() {
+ let straightPath = CursorMotionPath(
+ start: CGPoint(x: 10, y: 20),
+ end: CGPoint(x: 210, y: 120),
+ curveDirection: 0,
+ curveScale: 0
+ )
+
+ XCTAssertEqual(straightPath.curveScale, 0)
+ XCTAssertEqual(straightPath.point(at: 0), CGPoint(x: 10, y: 20))
+ XCTAssertEqual(straightPath.point(at: 1), CGPoint(x: 210, y: 120))
+
+ let midpoint = straightPath.point(at: 0.5)
+ XCTAssertEqual(midpoint.x, 110, accuracy: 0.001)
+ XCTAssertEqual(midpoint.y, 70, accuracy: 0.001)
+ }
+
private func makeSnapshot(treeLines: [String], focusedSummary: String?, selectedText: String? = nil) -> AppSnapshot {
AppSnapshot(
app: RunningAppDescriptor(
diff --git a/plugins/open-computer-use/.codex-plugin/plugin.json b/plugins/open-computer-use/.codex-plugin/plugin.json
index d52fbad..7eaa083 100644
--- a/plugins/open-computer-use/.codex-plugin/plugin.json
+++ b/plugins/open-computer-use/.codex-plugin/plugin.json
@@ -1,6 +1,6 @@
{
"name": "open-computer-use",
- "version": "0.1.2",
+ "version": "0.1.4",
"description": "Open-source macOS Computer Use MCP server packaged as a Codex plugin.",
"author": {
"name": "Leo",
diff --git a/scripts/ci.sh b/scripts/ci.sh
index a177e5f..ae9885e 100755
--- a/scripts/ci.sh
+++ b/scripts/ci.sh
@@ -12,4 +12,8 @@ while IFS= read -r file; do
bash -n "$file"
done < <(find "${repo_root}/scripts" -type f -name '*.sh' | sort)
+while IFS= read -r file; do
+ node --check "$file"
+done < <(find "${repo_root}/scripts" -type f -name '*.mjs' | sort)
+
echo "基础 CI 检查通过"
diff --git a/scripts/computer-use-cli/README.md b/scripts/computer-use-cli/README.md
index 0a57604..52967fb 100644
--- a/scripts/computer-use-cli/README.md
+++ b/scripts/computer-use-cli/README.md
@@ -85,7 +85,7 @@ Example working invocation against `open-computer-use`:
```bash
go run . list-tools \
--transport direct \
- --server-bin ~/.codex/plugins/cache/open-computer-use-local/open-computer-use/0.1.2/scripts/launch-open-computer-use.sh
+ --server-bin ~/.codex/plugins/cache/open-computer-use-local/open-computer-use/0.1.4/scripts/launch-open-computer-use.sh
```
Example working invocation against the official bundled `computer-use`:
diff --git a/scripts/computer-use-cli/main.go b/scripts/computer-use-cli/main.go
index 4777549..dc82e5e 100644
--- a/scripts/computer-use-cli/main.go
+++ b/scripts/computer-use-cli/main.go
@@ -21,7 +21,7 @@ import (
const (
cliName = "computer-use-cli"
- cliVersion = "0.1.2"
+ cliVersion = "0.1.4"
defaultTimeout = 60 * time.Second
pluginRootEnvVar = "COMPUTER_USE_PLUGIN_ROOT"
serverBinEnvVar = "COMPUTER_USE_SERVER_BIN"
diff --git a/scripts/npm/build-packages.mjs b/scripts/npm/build-packages.mjs
new file mode 100644
index 0000000..d5f5eb7
--- /dev/null
+++ b/scripts/npm/build-packages.mjs
@@ -0,0 +1,362 @@
+#!/usr/bin/env node
+
+import { spawnSync } from "node:child_process";
+import {
+ chmodSync,
+ cpSync,
+ existsSync,
+ mkdirSync,
+ readFileSync,
+ readdirSync,
+ rmSync,
+ statSync,
+ unlinkSync,
+ writeFileSync,
+} from "node:fs";
+import path from "node:path";
+import { fileURLToPath } from "node:url";
+
+const __dirname = path.dirname(fileURLToPath(import.meta.url));
+const repoRoot = path.resolve(__dirname, "..", "..");
+const defaultOutDir = path.join(repoRoot, "dist", "npm");
+const appBundleName = "Open Computer Use.app";
+const appExecutableName = "OpenComputerUse";
+const packageNames = [
+ "open-computer-use",
+ "open-computer-use-mcp",
+ "open-codex-computer-use-mcp",
+];
+
+function parseArgs(argv) {
+ const options = {
+ arch: "universal",
+ configuration: "release",
+ outDir: defaultOutDir,
+ packageNames: [...packageNames],
+ skipBuild: false,
+ };
+
+ for (let index = 0; index < argv.length; index += 1) {
+ const arg = argv[index];
+
+ switch (arg) {
+ case "--arch":
+ options.arch = argv[index + 1];
+ index += 1;
+ break;
+ case "--configuration":
+ options.configuration = argv[index + 1];
+ index += 1;
+ break;
+ case "--out-dir":
+ options.outDir = path.resolve(repoRoot, argv[index + 1]);
+ index += 1;
+ break;
+ case "--package":
+ options.packageNames = [argv[index + 1]];
+ index += 1;
+ break;
+ case "--skip-build":
+ options.skipBuild = true;
+ break;
+ case "-h":
+ case "--help":
+ printHelp();
+ process.exit(0);
+ default:
+ throw new Error(`Unknown argument: ${arg}`);
+ }
+ }
+
+ for (const packageName of options.packageNames) {
+ if (!packageNames.includes(packageName)) {
+ throw new Error(`Unsupported package name: ${packageName}`);
+ }
+ }
+
+ return options;
+}
+
+function printHelp() {
+ process.stdout.write(`Usage: node ./scripts/npm/build-packages.mjs [options]
+
+Options:
+ --configuration debug|release
+ --arch native|arm64|x86_64|universal
+ --out-dir <dir>
+ --package <package-name>
+ --skip-build
+`);
+}
+
+function run(command, args, options = {}) {
+ const result = spawnSync(command, args, {
+ cwd: repoRoot,
+ stdio: "inherit",
+ ...options,
+ });
+
+ if (result.status !== 0) {
+ throw new Error(`${command} ${args.join(" ")} failed with exit code ${result.status ?? "unknown"}`);
+ }
+}
+
+function readJSON(filePath) {
+ return JSON.parse(readFileSync(filePath, "utf-8"));
+}
+
+function removeJunkFiles(targetPath) {
+ if (!existsSync(targetPath)) {
+ return;
+ }
+
+ const entryStat = statSync(targetPath);
+ if (entryStat.isDirectory()) {
+ for (const entry of readdirSync(targetPath)) {
+ removeJunkFiles(path.join(targetPath, entry));
+ }
+ return;
+ }
+
+ if (path.basename(targetPath) === ".DS_Store") {
+ unlinkSync(targetPath);
+ }
+}
+
+function ensureBuilt(configuration, arch) {
+ run(path.join(repoRoot, "scripts", "build-open-computer-use-app.sh"), [
+ "--configuration",
+ configuration,
+ "--arch",
+ arch,
+ ]);
+}
+
+function writeExecutable(filePath, content) {
+ writeFileSync(filePath, content, "utf-8");
+ chmodSync(filePath, 0o755);
+}
+
+function renderLauncher() {
+ return `#!/usr/bin/env bash
+set -euo pipefail
+
+script_path="\${BASH_SOURCE[0]}"
+while [[ -L "\${script_path}" ]]; do
+ script_dir="$(cd "$(dirname "\${script_path}")" && pwd)"
+ script_path="$(readlink "\${script_path}")"
+ if [[ "\${script_path}" != /* ]]; then
+ script_path="\${script_dir}/\${script_path}"
+ fi
+done
+package_root="$(cd "$(dirname "\${script_path}")/.." && pwd)"
+app_binary="\${package_root}/dist/${appBundleName}/Contents/MacOS/${appExecutableName}"
+install_script="\${package_root}/scripts/install-codex-plugin.sh"
+
+if [[ "\${1:-}" == "install-codex-plugin" ]]; then
+ shift
+ exec "\${install_script}" "$@"
+fi
+
+if [[ ! -x "\${app_binary}" ]]; then
+ echo "open-computer-use could not find a runnable app bundle at \${app_binary}." >&2
+ exit 1
+fi
+
+exec "\${app_binary}" "$@"
+`;
+}
+
+function renderPostinstall(packageName) {
+ return `#!/usr/bin/env node
+const lines = [
+ "",
+ "Installed ${packageName}.",
+ "Commands: open-computer-use, open-computer-use-mcp, open-codex-computer-use-mcp",
+ "Start MCP: open-computer-use mcp",
+ "Grant permissions / diagnose: open-computer-use doctor",
+ "Install into Codex plugin cache: open-computer-use install-codex-plugin",
+ "",
+];
+for (const line of lines) {
+ console.log(line);
+}
+`;
+}
+
+function renderReadme(packageName, version) {
+ return `# ${packageName}
+
+Prebuilt macOS npm distribution for the open-source **Open Computer Use** MCP server.
+
+This package bundles a ready-to-run \`${appBundleName}\`, the Codex plugin metadata, and three global command aliases:
+
+- \`open-computer-use\`
+- \`open-computer-use-mcp\`
+- \`open-codex-computer-use-mcp\`
+
+## Install
+
+\`\`\`bash
+npm install -g ${packageName}
+\`\`\`
+
+## MCP config
+
+If your MCP client accepts a stdio-style \`mcpServers\` JSON config, this is the default setup:
+
+\`\`\`json
+{
+ "mcpServers": {
+ "open-computer-use": {
+ "command": "open-computer-use",
+ "args": ["mcp"]
+ }
+ }
+}
+\`\`\`
+
+If you want the server without the visual cursor overlay:
+
+\`\`\`json
+{
+ "mcpServers": {
+ "open-computer-use": {
+ "command": "open-computer-use",
+ "args": ["mcp"],
+ "env": {
+ "OPEN_COMPUTER_USE_VISUAL_CURSOR": "0"
+ }
+ }
+ }
+}
+\`\`\`
+
+In practice, using this package as MCP is: global install, add the JSON config, then grant macOS \`Accessibility\` and \`Screen Recording\` permission to the host terminal or app on first use.
+
+## Use
+
+\`\`\`bash
+# Check permissions and diagnose whether Accessibility / Screen Recording are granted
+open-computer-use doctor
+
+# Start the stdio MCP server for Claude Desktop, Cursor, Cline, or another MCP client
+open-computer-use mcp
+
+# Install this package into the local Codex plugin marketplace/cache
+open-computer-use install-codex-plugin
+\`\`\`
+
+## Notes
+
+- Version: \`${version}\`
+- Platform: macOS 14+
+- Architectures: \`arm64\` and \`x64\` via a universal app bundle
+- The host terminal or app still needs macOS \`Accessibility\` and \`Screen Recording\` permissions
+
+Source repository: https://github.com/iFurySt/open-codex-computer-use
+`;
+}
+
+function renderPackageJson(packageName, version) {
+ return {
+ name: packageName,
+ version,
+ description: "Prebuilt macOS Computer Use MCP server with Codex plugin installer.",
+ license: "MIT",
+ homepage: "https://github.com/iFurySt/open-codex-computer-use",
+ repository: {
+ type: "git",
+ url: "git+https://github.com/iFurySt/open-codex-computer-use.git",
+ },
+ bugs: {
+ url: "https://github.com/iFurySt/open-codex-computer-use/issues",
+ },
+ keywords: [
+ "computer-use",
+ "codex",
+ "mcp",
+ "macos",
+ "automation",
+ ],
+ os: ["darwin"],
+ cpu: ["arm64", "x64"],
+ preferGlobal: true,
+ publishConfig: {
+ access: "public",
+ },
+ bin: {
+ "open-computer-use": "bin/open-computer-use",
+ "open-computer-use-mcp": "bin/open-computer-use-mcp",
+ "open-codex-computer-use-mcp": "bin/open-codex-computer-use-mcp",
+ },
+ scripts: {
+ postinstall: "node ./scripts/postinstall.mjs",
+ },
+ files: [
+ ".agents/plugins/marketplace.json",
+ "bin/",
+ `dist/${appBundleName}/`,
+ "plugins/open-computer-use/.codex-plugin/",
+ "plugins/open-computer-use/.mcp.json",
+ "plugins/open-computer-use/assets/",
+ "plugins/open-computer-use/scripts/",
+ "scripts/install-codex-plugin.sh",
+ "scripts/postinstall.mjs",
+ "README.md",
+ "LICENSE",
+ ],
+ };
+}
+
+function stagePackage(packageName, version, outDir) {
+ const packageRoot = path.join(outDir, packageName);
+ rmSync(packageRoot, { recursive: true, force: true });
+
+ mkdirSync(path.join(packageRoot, ".agents", "plugins"), { recursive: true });
+ mkdirSync(path.join(packageRoot, "bin"), { recursive: true });
+ mkdirSync(path.join(packageRoot, "dist"), { recursive: true });
+ mkdirSync(path.join(packageRoot, "plugins"), { recursive: true });
+ mkdirSync(path.join(packageRoot, "scripts"), { recursive: true });
+
+ cpSync(path.join(repoRoot, ".agents", "plugins", "marketplace.json"), path.join(packageRoot, ".agents", "plugins", "marketplace.json"));
+ cpSync(path.join(repoRoot, "dist", appBundleName), path.join(packageRoot, "dist", appBundleName), {
+ recursive: true,
+ });
+ cpSync(path.join(repoRoot, "plugins", "open-computer-use"), path.join(packageRoot, "plugins", "open-computer-use"), {
+ recursive: true,
+ });
+ cpSync(path.join(repoRoot, "scripts", "install-codex-plugin.sh"), path.join(packageRoot, "scripts", "install-codex-plugin.sh"));
+ cpSync(path.join(repoRoot, "LICENSE"), path.join(packageRoot, "LICENSE"));
+
+ writeExecutable(path.join(packageRoot, "bin", "open-computer-use"), renderLauncher());
+ writeExecutable(path.join(packageRoot, "bin", "open-computer-use-mcp"), renderLauncher());
+ writeExecutable(path.join(packageRoot, "bin", "open-codex-computer-use-mcp"), renderLauncher());
+ writeFileSync(path.join(packageRoot, "scripts", "postinstall.mjs"), renderPostinstall(packageName), "utf-8");
+ writeFileSync(path.join(packageRoot, "README.md"), renderReadme(packageName, version), "utf-8");
+ writeFileSync(path.join(packageRoot, "package.json"), `${JSON.stringify(renderPackageJson(packageName, version), null, 2)}\n`, "utf-8");
+
+ chmodSync(path.join(packageRoot, "scripts", "install-codex-plugin.sh"), 0o755);
+ removeJunkFiles(packageRoot);
+}
+
+function main() {
+ const options = parseArgs(process.argv.slice(2));
+ const pluginManifestPath = path.join(repoRoot, "plugins", "open-computer-use", ".codex-plugin", "plugin.json");
+ const { version } = readJSON(pluginManifestPath);
+
+ if (!options.skipBuild) {
+ ensureBuilt(options.configuration, options.arch);
+ }
+
+ rmSync(options.outDir, { recursive: true, force: true });
+ mkdirSync(options.outDir, { recursive: true });
+
+ for (const packageName of options.packageNames) {
+ stagePackage(packageName, version, options.outDir);
+ }
+
+ process.stdout.write(`${options.outDir}\n`);
+}
+
+main();
diff --git a/scripts/npm/publish-packages.mjs b/scripts/npm/publish-packages.mjs
new file mode 100644
index 0000000..bfa96f4
--- /dev/null
+++ b/scripts/npm/publish-packages.mjs
@@ -0,0 +1,131 @@
+#!/usr/bin/env node
+
+import { spawnSync } from "node:child_process";
+import path from "node:path";
+import { fileURLToPath } from "node:url";
+
+const __dirname = path.dirname(fileURLToPath(import.meta.url));
+const repoRoot = path.resolve(__dirname, "..", "..");
+
+function printHelp() {
+ process.stdout.write(`Usage: node ./scripts/npm/publish-packages.mjs [options]
+
+Options:
+ --configuration debug|release
+ --arch native|arm64|x86_64|universal
+ --out-dir <dir>
+ --package <package-name>
+ --tag <dist-tag>
+ --dry-run
+ --skip-build
+ --provenance
+`);
+}
+
+function parseArgs(argv) {
+ const options = {
+ buildArgs: [],
+ dryRun: false,
+ outDir: path.join(repoRoot, "dist", "npm"),
+ provenance: false,
+ tag: "",
+ };
+
+ for (let index = 0; index < argv.length; index += 1) {
+ const arg = argv[index];
+ switch (arg) {
+ case "--configuration":
+ case "--arch":
+ case "--package":
+ case "--out-dir":
+ options.buildArgs.push(arg, argv[index + 1]);
+ if (arg === "--out-dir") {
+ options.outDir = path.resolve(repoRoot, argv[index + 1]);
+ }
+ index += 1;
+ break;
+ case "--skip-build":
+ options.buildArgs.push(arg);
+ break;
+ case "--tag":
+ options.tag = argv[index + 1];
+ index += 1;
+ break;
+ case "--dry-run":
+ options.dryRun = true;
+ break;
+ case "--provenance":
+ options.provenance = true;
+ break;
+ case "-h":
+ case "--help":
+ printHelp();
+ process.exit(0);
+ default:
+ throw new Error(`Unknown argument: ${arg}`);
+ }
+ }
+
+ return options;
+}
+
+function run(command, args, options = {}) {
+ const result = spawnSync(command, args, {
+ cwd: repoRoot,
+ stdio: "inherit",
+ ...options,
+ });
+
+ if (result.status !== 0) {
+ throw new Error(`${command} ${args.join(" ")} failed with exit code ${result.status ?? "unknown"}`);
+ }
+}
+
+function main() {
+ const options = parseArgs(process.argv.slice(2));
+
+ if (!options.dryRun && !process.env.NODE_AUTH_TOKEN) {
+ throw new Error("NODE_AUTH_TOKEN is required for npm publish.");
+ }
+
+ run("node", [path.join(repoRoot, "scripts", "npm", "build-packages.mjs"), ...options.buildArgs]);
+
+ const packageDirsResult = spawnSync(
+ "find",
+ [options.outDir, "-mindepth", "1", "-maxdepth", "1", "-type", "d"],
+ {
+ cwd: repoRoot,
+ encoding: "utf-8",
+ }
+ );
+
+ if (packageDirsResult.status !== 0) {
+ throw new Error(`Failed to enumerate staged packages in ${options.outDir}`);
+ }
+
+ const packageDirs = packageDirsResult.stdout
+ .split("\n")
+ .map((line) => line.trim())
+ .filter(Boolean)
+ .sort();
+
+ for (const packageDir of packageDirs) {
+ const args = ["publish", packageDir, "--access", "public"];
+ if (options.tag) {
+ args.push("--tag", options.tag);
+ }
+ if (options.provenance) {
+ args.push("--provenance");
+ }
+ if (options.dryRun) {
+ args.push("--dry-run");
+ }
+ run("npm", args, {
+ env: {
+ ...process.env,
+ },
+ });
+ }
+}
+
+main();
diff --git a/scripts/release-package.sh b/scripts/release-package.sh
index 9199d21..4c0f81a 100755
--- a/scripts/release-package.sh
+++ b/scripts/release-package.sh
@@ -4,22 +4,56 @@ set -euo pipefail
repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
dist_dir="${repo_root}/dist"
+release_dir="${dist_dir}/release"
+staging_dir="${release_dir}/npm-staging"
+tarball_dir="${release_dir}/npm"
-rm -rf "${dist_dir}"
-mkdir -p "${dist_dir}"
+rm -rf "${release_dir}"
+mkdir -p "${tarball_dir}"
-cat > "${dist_dir}/release-manifest.json" <<EOF
-{
- "repository": "${GITHUB_REPOSITORY:-local}",
- "git_sha": "${GITHUB_SHA:-$(git -C "${repo_root}" rev-parse HEAD 2>/dev/null || echo unknown)}",
- "generated_at_utc": "$(date -u +"%Y-%m-%dT%H:%M:%SZ")",
- "artifact": "repo-metadata.tgz",
- "note": "Replace scripts/release-package.sh with the real project build packaging when the stack is known."
+node "${repo_root}/scripts/npm/build-packages.mjs" \
+ --configuration release \
+ --arch universal \
+ --out-dir "${staging_dir}"
+
+while IFS= read -r package_dir; do
+ npm pack "${package_dir}" --pack-destination "${tarball_dir}" >/dev/null
+done < <(find "${staging_dir}" -mindepth 1 -maxdepth 1 -type d | sort)
+
+python3 - "${release_dir}/release-manifest.json" "${repo_root}" "${tarball_dir}" <<'PY'
+import json
+import os
+import sys
+from datetime import datetime, timezone
+from pathlib import Path
+
+manifest_path = Path(sys.argv[1])
+repo_root = Path(sys.argv[2])
+tarball_dir = Path(sys.argv[3])
+
+artifacts = []
+for tarball in sorted(tarball_dir.glob("*.tgz")):
+ artifacts.append({
+ "name": tarball.name,
+ "size_bytes": tarball.stat().st_size,
+ })
+
+manifest = {
+ "repository": os.environ.get("GITHUB_REPOSITORY", "local"),
+ "git_sha": os.environ.get("GITHUB_SHA") or __import__("subprocess").check_output(
+ ["git", "-C", str(repo_root), "rev-parse", "HEAD"],
+ text=True,
+ ).strip(),
+ "generated_at_utc": datetime.now(timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ"),
+ "artifacts": artifacts,
+ "distribution": {
+ "type": "npm",
+ "package_count": len(artifacts),
+ "staging_dir": str(tarball_dir.relative_to(repo_root)),
+ },
}
-EOF
-tar -czf "${dist_dir}/repo-metadata.tgz" \
- -C "${repo_root}" \
- AGENTS.md README.md CONTRIBUTING.md LICENSE docs scripts .github Makefile
+manifest_path.write_text(json.dumps(manifest, indent=2) + "\n", encoding="utf-8")
+PY
-echo "${dist_dir}/repo-metadata.tgz"
+echo "${release_dir}"