File size: 1,781 Bytes
1f21206 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 | import { api } from './client'
export type ComputerUseStatus = {
platform: string
supported: boolean
python: {
installed: boolean
version: string | null
path: string | null
source: 'custom' | 'system' | 'venv' | null
error: 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 = {
enabled: boolean
authorizedApps: AuthorizedApp[]
grantFlags: {
clipboardRead: boolean
clipboardWrite: boolean
systemKeyCombos: boolean
}
pythonPath: string | null
}
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 })
},
}
|