Skip to content

Replace hand-rolled executable resolution with the which package - #8

Merged
xxchan merged 1 commit into
mainfrom
resolve-via-which
Aug 30, 2026
Merged

xxchan merged 1 commit into
mainfrom
resolve-via-which

Conversation

@xxchan

@xxchan xxchan commented Aug 30, 2026

Copy link
Copy Markdown
Member

必要性

resolve.ts 之前自己实现 PATH 解析:非 Windows 上 spawn 一次 which 二进制,Windows 上 spawn powershell.exe 跑 Get-Command(外加 .ps1 兄弟文件回退、OAR_RESOLVE_TARGET 环境变量传参、15s 冷启动超时)。这是两条子进程路径 + 一个只为测试存在的注入缝(ExecFileSyncLike/ExecutableResolveOptions)。

[email protected] 用纯 JS 做同样的 PATH+PATHEXT 遍历,不 spawn 任何进程,所以平台分支、注入缝、以及专门钉住 powershell 传参方式的回归测试全部消失。94 行 → 6 行。

实证

  • CI 计时(run 33302243904)里 installation.test.ts 在 Windows 上要 5112ms(mac 427ms / ubuntu 224ms),差额就是 powershell 冷启动。换成纯 JS 解析后这块应该掉到与其它平台同量级。
  • 本地全量检查通过:lint ✓、typecheck ✓、vitest 29 files / 101 tests passed | 3/16 skipped(基线 102,少的 1 个正是被删掉的 powershell 缝测试——它的被测对象已不存在)。

变更

  • resolve.ts:整体替换为 which.sync(name, { nothrow: true }) 包装(94 行 → 6 行)
  • executable/index.ts:删掉 ExecFileSyncLike/ExecutableResolveOptions 类型导出
  • tests/process.test.ts:删掉 powershell 注入缝回归测试,收窄 import
  • packages/oar/package.json + lockfile:which@^2.0.2(dep)、@types/which@^2.0.2(devDep)

🤖 Generated with Claude Code

resolveExecutable shelled out to `which` on POSIX and spawned powershell
Get-Command on Windows (with a .ps1-sibling fallback and a 15s timeout for
cold runners — installation.test.ts paid ~5s per Windows CI run for it).
The which package does the same PATH+PATHEXT walk in pure JS with no child
process, so the platform branches, the env-var handoff, and the
ExecFileSyncLike/ExecutableResolveOptions test seam all disappear, along
with the powershell regression test that existed only to pin that seam.

Co-Authored-By: Claude Fable 5 <[email protected]>
@xxchan
xxchan merged commit b523f66 into main Aug 30, 2026
13 checks passed
@xxchan
xxchan deleted the resolve-via-which branch October 3, 2026 07:50
stamp-build Bot added a commit that referenced this pull request Nov 11, 2026
<!-- stamp:review:v1 -->
<sup><img src="https://api.raft.build/api/avatars/pixel/bXVn.svg" width="16" height="16" align="absmiddle" alt=""> <b>Cindy</b> from open-agent-runtime opened this pull request through Stamp</sup><br><sup><a href="https://stamp.build/review?receipt=prc_721b47cf35cd6b34f746ca38e595ce01"><picture><source media="(prefers-color-scheme: dark)" srcset="https://stamp.build/assets/brand/stamp-glyph-dark.d907ffcadb44.svg"><img src="https://stamp.build/assets/brand/stamp-glyph-light.58a2c10ed108.svg" width="13" height="12" align="absmiddle" alt=""></picture> View in Stamp →</a></sup>

---
<!-- /stamp:review:v1 -->

Cursor now accepts `SessionOptions.mcpServers`, so every OAR runtime except Pi Durable can take MCP servers per session. Antigravity still refuses entries that carry credentials. Raft needs this to attach its managed MCP through OAR on every runtime (#oar-raft:fb90875b, Raft task #8).

## Change

- `cursorMcpServers` maps the list to the SDK's `mcpServers` record. Stdio entries become `{type: "stdio", command, args, env}` and http entries become `{type: "http", url, headers}`. The record is sent on `Agent.create` and again on `Agent.resume`.
- Names are checked before the SDK is loaded (empty, repeated, reserved), the same as on every other runtime.
- The Cursor session now opens through `withSessionCredentials`, like the other runtimes. Entry `env` and header values are redacted from records, errors and control answers. Before this, Cursor sessions had no session credential redactor, because they took no credentials.
- Docs: the `cursor.md` session MCP section is rewritten, and `runtime-matrix.md` drops the refusal and adds a Cursor row to the MCP table.

## Evidence

`experiments/cursor-mcp.ts` was run twice on xxwork by the Otter in #all (SDK 1.3.1, Linux x64, `gpt-5.4-nano`, an existing login). The run used one stdio and one http entry of the repo's echo MCP server, each with a synthetic credential.

```json
{"open":{"status":"finished","stdio":true,"http":true,"toolCallDeltaNamesEcho":true,"credentialLeaked":false},"resume":{"status":"finished","stdio":true,"http":true,"toolCallDeltaNamesEcho":true,"credentialLeaked":false}}
```

- Raw deltas: `tool-call-started/completed` carry `toolCall.args.toolName: "echo"`, and `providerIdentifier` is `echo` or `remote`.
- Each echo carried the fingerprint of its entry's credential, so `env` and the `Authorization` header reached the servers.
- After both runs, neither credential was found as plain text in Cursor's local storage: `~/.cursor` (agent `index.db`, `store.db`, WAL), `~/.config/cursor`, and its caches. Antigravity is different: it keeps them, which is why it still refuses credentialed entries.
- Not observed: whether the SDK sends a local agent's entries to Cursor's servers, any other encoding on disk, and macOS/Windows. The docs say so.

Unit tests: `tests/cursor/cursor-mcp-servers.test.ts` covers mapping on create and resume, absent or empty lists, refused names, and redaction of a credential echoed in an SDK error. `tests/refused-session-options.test.ts` lists are updated. `pnpm run check` is green.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Cindy <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant