cc-haha/desktop/src/api/computerUse.ts
程序员阿江(Relakkes) 166fe5b676 fix: Computer Use 点击功能修复
- ensureRuntimeFiles() 改为始终同步源文件而非仅缺失时复制
- pre-authorized apps 增加 tier: 'full',与现有 allowedApps 合并而非替换
- normalizeOsPermissions() 将 screenRecording: null 视为非阻塞
- config 路径改为 cc-haha/computer-use-config.json
- mac_helper.py 改进鼠标点击与坐标处理
2026-04-15 14:18:37 +08:00

77 lines
1.6 KiB
TypeScript

import { api } from './client'
export type ComputerUseStatus = {
platform: string
supported: boolean
python: {
installed: boolean
version: string | null
path: string | null
}
venv: {
created: boolean
path: string
}
dependencies: {
installed: boolean
requirementsFound: boolean
}
permissions: {
accessibility: boolean | null
screenRecording: boolean | null
}
}
export type SetupStep = {
name: string
ok: boolean
message: string
}
export type SetupResult = {
success: boolean
steps: SetupStep[]
}
export type InstalledApp = {
bundleId: string
displayName: string
path: string
}
export type AuthorizedApp = {
bundleId: string
displayName: string
authorizedAt: string
}
export type ComputerUseConfig = {
authorizedApps: AuthorizedApp[]
grantFlags: {
clipboardRead: boolean
clipboardWrite: boolean
systemKeyCombos: boolean
}
}
export const computerUseApi = {
getStatus() {
return api.get<ComputerUseStatus>('/api/computer-use/status')
},
runSetup() {
return api.post<SetupResult>('/api/computer-use/setup', undefined, { timeout: 300_000 })
},
getInstalledApps() {
return api.get<{ apps: InstalledApp[] }>('/api/computer-use/apps')
},
getAuthorizedApps() {
return api.get<ComputerUseConfig>('/api/computer-use/authorized-apps')
},
setAuthorizedApps(config: Partial<ComputerUseConfig>) {
return api.put<{ ok: true }>('/api/computer-use/authorized-apps', config)
},
openSettings(pane: 'Privacy_ScreenCapture' | 'Privacy_Accessibility') {
return api.post<{ ok: true }>('/api/computer-use/open-settings', { pane })
},
}