mirror of
https://github.com/NanmiCoder/claude-code-haha.git
synced 2026-10-10 20:03:13 +08:00
166fe5b676
- ensureRuntimeFiles() 改为始终同步源文件而非仅缺失时复制 - pre-authorized apps 增加 tier: 'full',与现有 allowedApps 合并而非替换 - normalizeOsPermissions() 将 screenRecording: null 视为非阻塞 - config 路径改为 cc-haha/computer-use-config.json - mac_helper.py 改进鼠标点击与坐标处理
56 lines
2.1 KiB
TypeScript
56 lines
2.1 KiB
TypeScript
import type {
|
|
ComputerUseHostAdapter,
|
|
Logger,
|
|
} from '../../vendor/computer-use-mcp/types.js'
|
|
import { format } from 'util'
|
|
import { logForDebugging } from '../debug.js'
|
|
import { COMPUTER_USE_MCP_SERVER_NAME } from './common.js'
|
|
import { createCliExecutor } from './executor.js'
|
|
import { getChicagoEnabled, getChicagoSubGates } from './gates.js'
|
|
import { normalizeOsPermissions } from './permissions.js'
|
|
import { callPythonHelper } from './pythonBridge.js'
|
|
|
|
class DebugLogger implements Logger {
|
|
silly(message: string, ...args: unknown[]): void {
|
|
logForDebugging(format(message, ...args), { level: 'debug' })
|
|
}
|
|
debug(message: string, ...args: unknown[]): void {
|
|
logForDebugging(format(message, ...args), { level: 'debug' })
|
|
}
|
|
info(message: string, ...args: unknown[]): void {
|
|
logForDebugging(format(message, ...args), { level: 'info' })
|
|
}
|
|
warn(message: string, ...args: unknown[]): void {
|
|
logForDebugging(format(message, ...args), { level: 'warn' })
|
|
}
|
|
error(message: string, ...args: unknown[]): void {
|
|
logForDebugging(format(message, ...args), { level: 'error' })
|
|
}
|
|
}
|
|
|
|
let cached: ComputerUseHostAdapter | undefined
|
|
|
|
export function getComputerUseHostAdapter(): ComputerUseHostAdapter {
|
|
if (cached) return cached
|
|
cached = {
|
|
serverName: COMPUTER_USE_MCP_SERVER_NAME,
|
|
logger: new DebugLogger(),
|
|
executor: createCliExecutor({
|
|
getMouseAnimationEnabled: () => getChicagoSubGates().mouseAnimation,
|
|
getHideBeforeActionEnabled: () => getChicagoSubGates().hideBeforeAction,
|
|
}),
|
|
ensureOsPermissions: async () => {
|
|
const rawPerms = await callPythonHelper<{ accessibility: boolean; screenRecording: boolean | null }>('check_permissions', {})
|
|
const perms = normalizeOsPermissions(rawPerms)
|
|
return perms.granted
|
|
? { granted: true as const }
|
|
: { granted: false as const, accessibility: perms.accessibility, screenRecording: perms.screenRecording }
|
|
},
|
|
isDisabled: () => !getChicagoEnabled(),
|
|
getSubGates: getChicagoSubGates,
|
|
getAutoUnhideEnabled: () => true,
|
|
cropRawPatch: () => null,
|
|
}
|
|
return cached
|
|
}
|