👾 Open Computer Use – Open-Source Alternative to Codex Computer Use
Swift accessibilityai-agentai-agentsclaude-codecodexcodex-computer-usecomputer-usecomputer-use-agentcross-platformcuadesktop-automationgemini-cligui-automationmacosmcpmodel-context-protocolopen-computer-useopen-computer-use-mcpopenai-codexopencode
Fix npm auth mode selection
Leo43c6a0ae622c
diff --git a/docs/histories/2026-04/20260417-2218-fix-npm-auth-mode-selection.md b/docs/histories/2026-04/20260417-2218-fix-npm-auth-mode-selection.mdnew file mode 100644index 0000000..714c154--- /dev/null+++ b/docs/histories/2026-04/20260417-2218-fix-npm-auth-mode-selection.md@@ -0,0 +1,25 @@+## [2026-04-17 22:18] | Task: 修正 npm 发布认证模式选择++### 📥 User Request++> GitHub Action 要能通过 git tag 真正把包发出去;如果中间发现问题,就继续修到发布成功为止。++### 🔧 What Changed++- **修正包仓库元数据**:把 npm staging 包里生成的 `repository.url` 从 `git+https://...git` 改成和 GitHub 仓库精确一致的 `https://github.com/iFurySt/open-codex-computer-use`。+- **强制 token fallback 真正生效**:在 `publish-packages.mjs` 里,当 `NODE_AUTH_TOKEN` 已经存在时,主动清掉 GitHub Actions 暴露给 npm CLI 的 OIDC 环境变量,避免 npm 继续优先走 Trusted Publishing。++### 🧠 Design Intent (Why)++这次联调暴露出两条认证路径会互相干扰:++1. npm CLI 在 GitHub Actions 中检测到 OIDC 环境后,会优先尝试 Trusted Publishing。+2. 仓库里生成的包 `repository.url` 不够“精确匹配”,可能导致 Trusted Publishing 侧校验失败。+3. 即便 workflow 已经注入 `NODE_AUTH_TOKEN`,如果不显式屏蔽 OIDC 环境,npm 也不一定会真的走 token 路径。++所以这里不是单纯“再补一个 secret”就够,而是要明确把“包元数据”和“认证模式选择”两层都收紧,避免发布过程中继续落到错误的认证分支。++### 📌 Key Files++- `scripts/npm/build-packages.mjs`+- `scripts/npm/publish-packages.mjs`diff --git a/scripts/npm/build-packages.mjs b/scripts/npm/build-packages.mjsindex 5f43426..dca7eb1 100644--- a/scripts/npm/build-packages.mjs+++ b/scripts/npm/build-packages.mjs@@ -251,7 +251,7 @@ function renderPackageJson(packageName, version) {homepage: "https://github.com/iFurySt/open-codex-computer-use",repository: {type: "git",- url: "git+https://github.com/iFurySt/open-codex-computer-use.git",+ url: "https://github.com/iFurySt/open-codex-computer-use",},bugs: {url: "https://github.com/iFurySt/open-codex-computer-use/issues",diff --git a/scripts/npm/publish-packages.mjs b/scripts/npm/publish-packages.mjsindex cc09726..83bd3e0 100644--- a/scripts/npm/publish-packages.mjs+++ b/scripts/npm/publish-packages.mjs@@ -121,11 +121,20 @@ function main() {if (options.dryRun) {args.push("--dry-run");}- run("npm", args, {- env: {- ...process.env,- },- });+ const npmEnv = {+ ...process.env,+ };++ // npm prefers GitHub Actions OIDC when the runner exposes it. If we+ // explicitly provided an npm token fallback, clear the OIDC env so publish+ // actually uses the token path.+ if (process.env.NODE_AUTH_TOKEN) {+ delete npmEnv.ACTIONS_ID_TOKEN_REQUEST_URL;+ delete npmEnv.ACTIONS_ID_TOKEN_REQUEST_TOKEN;+ delete npmEnv.NPM_ID_TOKEN;+ }++ run("npm", args, { env: npmEnv });}}