import { c as _c } from "react-compiler-runtime"; import { getSentinelCategory } from '@ant/computer-use-mcp/sentinelApps'; import type { CuPermissionRequest, CuPermissionResponse } from '@ant/computer-use-mcp/types'; import { DEFAULT_GRANT_FLAGS } from '@ant/computer-use-mcp/types'; import figures from 'figures'; import * as React from 'react'; import { useMemo, useState } from 'react'; import { Box, Text } from '../../../ink.js'; import { execFileNoThrow } from '../../../utils/execFileNoThrow.js'; import { plural } from '../../../utils/stringUtils.js'; import type { OptionWithDescription } from '../../CustomSelect/select.js'; import { Select } from '../../CustomSelect/select.js'; import { Dialog } from '../../design-system/Dialog.js'; type ComputerUseApprovalProps = { request: CuPermissionRequest; onDone: (response: CuPermissionResponse) => void; }; const DENY_ALL_RESPONSE: CuPermissionResponse = { granted: [], denied: [], flags: DEFAULT_GRANT_FLAGS }; /** * Two-panel dispatcher. When `request.tccState` is present, macOS permissions * (Accessibility / Screen Recording) are missing and the app list is * irrelevant — show a TCC panel that opens System Settings. Otherwise show the * app allowlist + grant-flags panel. */ export function ComputerUseApproval(t0) { const $ = _c(3); const { request, onDone } = t0; let t1; if ($[0] !== onDone || $[1] !== request) { t1 = request.tccState ? onDone(DENY_ALL_RESPONSE)} /> : ; $[0] = onDone; $[1] = request; $[2] = t1; } else { t1 = $[2]; } return t1; } // ── TCC panel ───────────────────────────────────────────────────────────── type TccOption = 'open_accessibility' | 'open_screen_recording' | 'retry'; function ComputerUseTccPanel(t0) { const $ = _c(26); const { tccState, onDone } = t0; let opts; if ($[0] !== tccState.accessibility || $[1] !== tccState.screenRecording) { opts = []; if (!tccState.accessibility) { let t1; if ($[3] === Symbol.for("react.memo_cache_sentinel")) { t1 = { label: "Open System Settings \u2192 Accessibility", value: "open_accessibility" }; $[3] = t1; } else { t1 = $[3]; } opts.push(t1); } if (!tccState.screenRecording) { let t1; if ($[4] === Symbol.for("react.memo_cache_sentinel")) { t1 = { label: "Open System Settings \u2192 Screen Recording", value: "open_screen_recording" }; $[4] = t1; } else { t1 = $[4]; } opts.push(t1); } let t1; if ($[5] === Symbol.for("react.memo_cache_sentinel")) { t1 = { label: "Try again", value: "retry" }; $[5] = t1; } else { t1 = $[5]; } opts.push(t1); $[0] = tccState.accessibility; $[1] = tccState.screenRecording; $[2] = opts; } else { opts = $[2]; } const options = opts; let t1; if ($[6] !== onDone) { t1 = function onChange(value) { switch (value) { case "open_accessibility": { execFileNoThrow("open", ["x-apple.systempreferences:com.apple.preference.security?Privacy_Accessibility"], { useCwd: false }); return; } case "open_screen_recording": { execFileNoThrow("open", ["x-apple.systempreferences:com.apple.preference.security?Privacy_ScreenCapture"], { useCwd: false }); return; } case "retry": { onDone(); return; } } }; $[6] = onDone; $[7] = t1; } else { t1 = $[7]; } const onChange = t1; const t2 = tccState.accessibility ? `${figures.tick} granted` : `${figures.cross} not granted`; let t3; if ($[8] !== t2) { t3 = Accessibility:{" "}{t2}; $[8] = t2; $[9] = t3; } else { t3 = $[9]; } const t4 = tccState.screenRecording ? `${figures.tick} granted` : `${figures.cross} not granted`; let t5; if ($[10] !== t4) { t5 = Screen Recording:{" "}{t4}; $[10] = t4; $[11] = t5; } else { t5 = $[11]; } let t6; if ($[12] !== t3 || $[13] !== t5) { t6 = {t3}{t5}; $[12] = t3; $[13] = t5; $[14] = t6; } else { t6 = $[14]; } let t7; if ($[15] === Symbol.for("react.memo_cache_sentinel")) { t7 = Grant the missing permissions in System Settings, then select "Try again". macOS may require you to restart OpenClaude after granting Screen Recording.; $[15] = t7; } else { t7 = $[15]; } let t8; if ($[16] !== onChange || $[17] !== onDone || $[18] !== options) { t8 = ; $[35] = options; $[36] = t17; $[37] = t18; $[38] = t19; } else { t19 = $[38]; } let t20; if ($[39] !== t12 || $[40] !== t14 || $[41] !== t15 || $[42] !== t16 || $[43] !== t19) { t20 = {t12}{t14}{t15}{t16}{t19}; $[39] = t12; $[40] = t14; $[41] = t15; $[42] = t16; $[43] = t19; $[44] = t20; } else { t20 = $[44]; } let t21; if ($[45] !== t11 || $[46] !== t20) { t21 = {t20}; $[45] = t11; $[46] = t20; $[47] = t21; } else { t21 = $[47]; } return t21; } function _temp4(flag) { return {" "}· {flag}; } function _temp3(k_0) { return [k_0, true] as const; } function _temp2(a_2) { return { bundleId: a_2.resolved?.bundleId ?? a_2.requestedName, reason: a_2.resolved ? "user_denied" as const : "not_installed" as const }; } function _temp(a) { return a.resolved && !a.alreadyGranted ? [a.resolved.bundleId] : []; }