來源:src/moreright/useMoreRight.tsx
目前存在的是外部 build 的 stub 實作,真正的 hook 是「internal only」(只存在於 Anthropic 內部 monorepo)。
// Stub for external builds — the real hook is internal only.
export function useMoreRight(_args: {
enabled: boolean;
setMessages: ...;
inputValue: string;
setInputValue: ...;
setToolJSX: ...;
}): {
onBeforeQuery: async () => true, // stub:永遠允許
onTurnComplete: async () => {}, // stub:無操作
render: () => null // stub:不渲染
}從 stub 的 type signature 可以推斷真實功能:
| 參數/返回值 | 推斷功能 |
|---|---|
enabled: boolean |
可被動態開關 |
setMessages |
能直接修改對話訊息列表 |
inputValue / setInputValue |
能讀取和修改使用者輸入框 |
setToolJSX |
能注入工具 UI 元件 |
onBeforeQuery(input, all, n) |
返回 boolean:決定是否允許查詢繼續 |
onTurnComplete(all, aborted) |
turn 完成後的回調 |
render() |
渲染額外 UI 元件 |
推斷:Moreright 是一個「更多右側功能」的擴展 hook,可能在 UI 右側提供額外面板或功能(可能是 Ant 內部的特殊 UI 層)。onBeforeQuery 能攔截並拒絕查詢,說明它有過濾/審查能力。
來源:src/utils/teleport/(6 個檔案)
Teleport 是「從本機傳送到 Claude.ai 遠端 session(CCR)」的底層機制,也是 UltraPlan 的基礎設施。
來源:src/utils/teleport/environments.ts
type EnvironmentKind = 'anthropic_cloud' | 'byoc' | 'bridge'| 環境類型 | 說明 |
|---|---|
anthropic_cloud |
Anthropic 雲端 CCR 容器 |
byoc |
Bring Your Own Cloud(用戶自有雲)CCR Beta(ccr-byoc-2025-07-29) |
bridge |
Bridge 模式(透過 bridge 連接) |
Environment API:/v1/environment_providers(需要 OAuth + 組織 UUID)
來源:src/utils/teleport/gitBundle.ts
當建立遠端 CCR session 時,可以將本機 Git repo 打包上傳,讓遠端 container 有完整的程式碼上下文。
Bundle 策略(三層 fallback):
--all:完整 bundle(含所有 refs、branches、tags)HEAD:只有當前分支完整歷史(捨棄側分支)squashed-root:單一 parentless commit(僅快照,無歷史),用於超大 repo
預設 bundle 大小上限:100 MB(可透過 tengu_ccr_bundle_max_bytes 調整)
WIP 處理:
git stash create建立臨時 stash- 將 stash 打包進 bundle(
refs/seed/stash) - 上傳後清除 ref(不污染使用者 repo)
來源:src/utils/teleport/api.ts
const TELEPORT_RETRY_DELAYS = [2000, 4000, 8000, 16000] // 指數退避,4 次重試5xx 錯誤自動重試,4xx 錯誤立即失敗。
來源:src/constants/product.ts
// URL 格式:https://claude.ai/code/{sessionId}
function getRemoteSessionUrl(sessionId: string, ingressUrl?: string): string支援三種環境:
- Production:
https://claude.ai - Staging:
https://claude-ai.staging.ant.dev - Local:
http://localhost:4000
環境偵測:Session ID 包含 _staging_ / _local_ 子字串,或 ingress URL 包含對應關鍵字。
src/utils/teleport/environmentSelection.ts — 提供環境選擇界面,讓使用者在 anthropic_cloud、byoc 之間選擇。
來源:src/utils/deepLink/(5 個檔案)
claude-cli://open?q={prompt}&cwd={path}&repo={owner/repo}
安全驗證:
- 協議必須是
claude-cli:// - hostname 必須是
open cwd必須是絕對路徑cwd不得包含控制字符(ASCII 0x00-0x1F, 0x7F)repo必須符合owner/repo格式(防止路徑遍歷)q不得包含控制字符(防止命令注入)q最大長度:5000 字符cwd最大長度:4096 字符
Unicode 清理:使用 partiallySanitizeUnicode() 移除隱藏 Unicode 字符(防止 ASCII smuggling / 隱藏 prompt injection)
OS 呼叫 claude --handle-uri <url>
→ parseDeepLink(url)
→ resolveCwd(action)
→ 優先序:explicit cwd > repo 本機路徑 > 家目錄
→ readLastFetchTime(cwd) (git FETCH_HEAD 年齡,預算計算用)
→ launchInTerminal(process.execPath, { query, cwd, repo, lastFetchMs })
// 偵測方式:__CFBundleIdentifier === MACOS_BUNDLE_ID
async function handleUrlSchemeLaunch(): Promise<number | null>LaunchServices 啟動時 __CFBundleIdentifier 會被設為我們的 bundle ID。透過 url-handler-napi 的 waitForUrlEvent(5000) 取得 URL。
支援的終端(按優先順序):
macOS:
- iTerm2(
com.googlecode.iterm2) - Ghostty(
com.mitchellh.ghostty) - Kitty(
net.kovidgoyal.kitty) - Alacritty(
org.alacritty) - WezTerm(
com.github.wez.wezterm) - Terminal.app(
com.apple.Terminal,回退)
Linux: ghostty → kitty → alacritty → wezterm → gnome-terminal → konsole → xfce4-terminal → mate-terminal → tilix → xterm
Windows: Windows Terminal(wt.exe) → PowerShell → cmd.exe
偵測邏輯:
- 讀取
config.deepLinkTerminal(使用者存儲的偏好,在無 TTY 的 LaunchServices context 中是唯一可用信號) - 檢查
TERM_PROGRAM環境變數 - 掃描運行中的進程
- 掃描已安裝的 App bundle
macOS:
- Bundle ID:
MACOS_BUNDLE_ID - 使用
.appbundle +Info.plist的CFBundleURLTypes - 透過 LaunchServices 系統級 URL scheme 處理
Linux:
.desktop文件 +xdg-mime/update-desktop-database
Windows:
- 登錄表
HKCU\Software\Classes\claude-cli\...
- Moreright 的 onBeforeQuery 返回 boolean → 這是一個攔截閘門,ant 內部版本可能有輸入審查或特殊路由邏輯
- DeepLink 的
q長度限制與 Windows cmd.exe 相關:5000 字符是根據 cmd.exe 的 8191 字符命令行上限計算得出的實用安全上限 - Git Bundle 三層 fallback:確保即使超大 repo 也能以「快照」模式上傳,讓遠端 session 有基本上下文
- BYOC beta:
ccr-byoc-2025-07-29表明「Bring Your Own Cloud」是一個正在開發中的付費功能