@clipboard-health/clearance

中文文档
1.10.15发布于 2026/11/05MITTypeScriptES Module近 30 天下载 3094

Localhost HTTP/HTTPS egress proxy with hostname allow-listing, plus a macOS Safehouse integration for sandboxed agent processes.

原始使用文档
文档目录9 节
  1. Install
  2. Raw proxy usage
  3. Allow-host files
  4. Configuration reference
  5. Managed proxy: clearance-ensure
  6. Lifecycle subcommands
  7. Safehouse integration (macOS)
  8. Manual setup
  9. Hacking on clearance

clearance

A local HTTP/HTTPS forward proxy that gates network egress against a hostname allowlist. Built for deny-by-default sandboxes — coding agents, CI workers, isolated build steps — where you want one choke point the sandbox can permit, with every other route to the network closed.

The proxy ships with zero compiled-in opinions about which hosts to allow. Bring your own list — either inline via env or by pointing at one or more plain-text files. Teams typically check those files into their repo so everyone shares the same baseline.

Install

npm install -g @clipboard-health/clearance

This installs two binaries: clearance (the proxy) and clearance-ensure (idempotent daemon launcher).

Raw proxy usage

CLEARANCE_ALLOW_HOSTS=api.example.com clearance

Then point tools at http://127.0.0.1:19999 with HTTP_PROXY and HTTPS_PROXY.

By default the proxy listens on 127.0.0.1:19999, allows destination port 443, and blocks private, loopback, link-local, multicast, documentation, and other non-public IP ranges after DNS resolution.

If neither CLEARANCE_ALLOW_HOSTS nor CLEARANCE_ALLOW_HOSTS_FILES is set, the proxy refuses to start.

Allow-host files

A file is a plain-text list of hosts, one per line. Blank lines are ignored, # introduces a comment to end-of-line, and trailing dots / wildcard prefixes (*.example.com) are normalized.

# AI agents
api.openai.com
api.anthropic.com

# Source code
github.com
api.github.com
*.githubusercontent.com

Point at one or more files via CLEARANCE_ALLOW_HOSTS_FILES using your platform's PATH delimiter — : on macOS/Linux, ; on Windows. The values from CLEARANCE_ALLOW_HOSTS, all referenced files, and any duplicates are concatenated and deduped.

CLEARANCE_ALLOW_HOSTS_FILES="$REPO/clearance-allow-hosts:$HOME/.config/clearance/personal-hosts" \
  clearance

This is how teams share a baseline: check a team-allow-hosts file into your repo, and let individuals layer a personal file on top via the same env var.

Configuration reference

VariableDefaultNotes
CLEARANCE_ALLOW_HOSTS(unset)Comma- or whitespace-separated exact hosts and wildcard suffixes.
CLEARANCE_ALLOW_HOSTS_FILES(unset)PATH-delimited paths (: macOS/Linux, ; Windows) to plain-text host files (# comments, blank lines).
CLEARANCE_ALLOW_PORTS443Comma- or whitespace-separated TCP ports.
CLEARANCE_LISTEN_HOST127.0.0.1Bind host.
CLEARANCE_PORT19999Bind port.
CLEARANCE_DNS_TTL_MS60000In-process DNS cache TTL.
CLEARANCE_IDLE_TIMEOUT_MS120000Socket idle timeout.
CLEARANCE_MAX_SOCKETS1024Inbound connection cap and outbound HTTP agent cap.
CLEARANCE_ALLOW_PRIVATE_IPS(unset)Set to 1 to disable private/non-public IP blocking for local testing.

Managed proxy: clearance-ensure

clearance-ensure checks 127.0.0.1:19999; if no proxy is listening it spawns one detached using the same env vars and waits for it to bind. Logs live at ${XDG_CACHE_HOME:-$HOME/.cache}/clearance/clearance.log, pid at …/clearance.pid.

CLEARANCE_ALLOW_HOSTS_FILES="$REPO/clearance-allow-hosts" clearance-ensure

Lifecycle subcommands

clearance-ensure accepts an optional subcommand. With none, it defaults to start (the idempotent launch above). All subcommands discover the running proxy through the pidfile.

CommandBehavior
clearance-ensureDefault start: launch the proxy if nothing is already listening.
clearance-ensure startSame as the bare invocation.
clearance-ensure stopSignal the pidfile process to terminate, wait for the port to close, and remove the pidfile.
clearance-ensure restartstop the existing proxy (if any), then start a fresh one. Use this to pick up edited host files.
clearance-ensure statusReport whether the proxy is listening and its pid. Exits non-zero when it is not running.

To pick up edited allow-host files, restart in one step:

CLEARANCE_ALLOW_HOSTS_FILES="$REPO/clearance-allow-hosts" clearance-ensure restart

Safehouse integration (macOS)

Safehouse uses macOS sandbox profiles, so this section is for macOS hosts only. Safehouse allows network access by default for agent compatibility. To force a wrapped agent through this proxy, run the proxy outside Safehouse, then append a Safehouse profile that denies direct remote egress while leaving localhost open for http://127.0.0.1:19999.

The package ships a safehouse-clearance wrapper plus the matching clearance.env and clearance-only.sb profile. After a global install, the wrapper lives at $(npm root -g)/@clipboard-health/clearance/safehouse/safehouse-clearance. It ensures the proxy is running, then execs safehouse with the env file and sandbox profile alongside it. It does not parse or rewrite your arguments — anything you pass is forwarded verbatim, so put any safehouse flags before the agent command:

SAFEHOUSE_CLEARANCE="$(npm root -g)/@clipboard-health/clearance/safehouse/safehouse-clearance"

"$SAFEHOUSE_CLEARANCE" \
  --enable=cloud-credentials --env-pass=AWS_PROFILE,AWS_REGION \
  -- codex --dangerously-bypass-approvals-and-sandbox

For day-to-day agent use, configure your allow-host files and add shell aliases:

SAFEHOUSE="$(npm root -g)/@clipboard-health/clearance/safehouse"
export CLEARANCE_ALLOW_HOSTS_FILES="$HOME/code/<your-repo>/clearance-allow-hosts:$HOME/.config/clearance/personal-allow-hosts"

alias codex-proxy="$SAFEHOUSE/safehouse-clearance codex --dangerously-bypass-approvals-and-sandbox"
alias claude-proxy="$SAFEHOUSE/safehouse-claude-proxy"

safehouse-claude-proxy runs Claude through Safehouse with --permission-mode auto. When launched from a cmux terminal, it preserves cmux's Claude shim by forwarding the cmux session environment and granting read-only access to the cmux app/socket state and generated Codex hooks. The integration also grants cmux's existing Sentry cache write access so diagnostics cannot corrupt hook JSON output. It points the shim at the real Claude binary so the shim does not recurse through itself.

The integration does not grant connections to cmux's control socket: resolveSafehouseCmuxIntegration().socketProfile is always undefined. That socket can create terminals and run commands outside Safehouse, so granting access for status hooks would also let sandboxed code bypass its restrictions. Hooks that require the socket remain blocked. Restoring them requires a host-side relay that accepts only the required hook operations for the assigned workspace; consumers must not append a profile granting the control socket.

The cmux environment pass-through is an explicit reviewed allowlist. If a cmux update adds new CMUX_* variables to its Claude wrapper contract, safehouse-claude-proxy prints a warning naming the unreviewed variables instead of automatically passing every CMUX_* value through the sandbox.

For AWS SSO work, log in on the host first, then layer the safehouse cloud credentials flag through the wrapper:

aws sso login --profile <profile>
AWS_PROFILE=<profile> "$SAFEHOUSE/safehouse-clearance" \
  --enable=cloud-credentials --env-pass=AWS_PROFILE,AWS_REGION,AWS_SDK_LOAD_CONFIG,AWS_CONFIG_FILE,AWS_SHARED_CREDENTIALS_FILE,AWS_CA_BUNDLE \
  -- codex --dangerously-bypass-approvals-and-sandbox

Make sure your allow-host file includes the AWS endpoints you need (typically *.amazonaws.com, *.api.aws, *.awsapps.com, *.ecr.aws).

Manual setup

If you'd rather not depend on the bundled assets, you can build the same setup by hand.

mkdir -p ~/.config/agent-safehouse
cat > ~/.config/agent-safehouse/clearance-only.sb <<'SB'
;; Force remote network egress through the local clearance while keeping
;; localhost available for local-only agent workflows.
(deny network-outbound
  (remote ip "*:*")
  (remote tcp "*:*")
  (remote udp "*:*"))

(allow network-outbound
  (remote ip "localhost:*")
  (remote tcp "localhost:*")
  (remote udp "localhost:*"))
SB
cat > ~/.config/agent-safehouse/clearance.env <<'ENV'
HTTP_PROXY="http://127.0.0.1:19999"
HTTPS_PROXY="http://127.0.0.1:19999"
ALL_PROXY="http://127.0.0.1:19999"
NO_PROXY="localhost,127.0.0.1,::1"

http_proxy="${HTTP_PROXY}"
https_proxy="${HTTPS_PROXY}"
all_proxy="${ALL_PROXY}"
no_proxy="${NO_PROXY}"
ENV

Then run the wrapped command with Safehouse:

safehouse \
  --env="$HOME/.config/agent-safehouse/clearance.env" \
  --append-profile="$HOME/.config/agent-safehouse/clearance-only.sb" \
  -- <agent-command>

Do not pass API-key environment variables just for proxying. The env file only supplies proxy settings; agents should continue to use their normal auth/config stores.

Quick checks:

# Should use the proxy and usually return 401 without auth.
safehouse --env="$HOME/.config/agent-safehouse/clearance.env" \
  --append-profile="$HOME/.config/agent-safehouse/clearance-only.sb" \
  -- curl -I https://api.openai.com/v1/models

# Should fail because this bypasses the proxy and tries direct egress.
safehouse --env="$HOME/.config/agent-safehouse/clearance.env" \
  --append-profile="$HOME/.config/agent-safehouse/clearance-only.sb" \
  -- curl --noproxy '*' -I https://api.openai.com/v1/models

# Should be denied by the proxy unless example.com is in your allow-host list.
safehouse --env="$HOME/.config/agent-safehouse/clearance.env" \
  --append-profile="$HOME/.config/agent-safehouse/clearance-only.sb" \
  -- curl -I https://example.com

Hacking on clearance

For developers working on the package itself, the source lives in ClipboardHealth/core-utils. After npm install in the repo, the bin scripts dispatch through a runCli helper that detects no compiled JS and re-execs node with --conditions @clipboard-health/source, so the proxy runs straight from TypeScript source — no build step:

cd ~/dev/c/core-utils
CLEARANCE_ALLOW_HOSTS=api.example.com node ./packages/clearance/bin/run.js

Requires Node ≥ 24.3 (native .ts type stripping enabled by default).

版本与发布记录

@clipboard-health/clearance 共发布 93 个版本,首次发布于 2026/05/13;过去 12 个月发布了 93 个版本。

版本发布日期距今
1.10.15latest2026/11/054 天前
1.10.142026/11/055 天前
1.10.132026/11/045 天前
1.10.122026/10/3110 天前
1.10.112026/10/2812 天前
1.10.102026/10/2813 天前

关于 @clipboard-health/clearance 的常见问题

@clipboard-health/clearance 是什么?

Localhost HTTP/HTTPS egress proxy with hostname allow-listing, plus a macOS Safehouse integration for sandboxed agent processes.

如何安装 @clipboard-health/clearance?

在项目目录运行 npm install @clipboard-health/clearance,或使用 pnpm add / yarn add / bun add。它还提供命令行工具 clearance、clearance-ensure,可以用 npx clearance 直接运行。

@clipboard-health/clearance 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@clipboard-health/clearance 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@clipboard-health/clearance 可以商用吗?

@clipboard-health/clearance 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@clipboard-health/clearance 的下载量有多少?

根据 npm 官方下载统计,@clipboard-health/clearance 在 2026/10/10 – 2026/11/08 这 30 天内被下载 3,094 次,日均约 103 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@clipboard-health/clearance 还在维护吗?

最新版本 1.10.15 发布于 2026/11/05(4 天前);至今共发布 93 个版本,其中过去 12 个月发布了 93 个;首次发布于 2026/05/13。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。