Skip to content

Commit 8992b48

Browse files
committed
Fix macOS CI: grant AppleScript access to Terminal.app via TCC
1 parent 14e340f commit 8992b48

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

.github/workflows/macos-terminal-test.yml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,18 @@ jobs:
2424
- name: Install PowerShell
2525
run: brew install powershell/tap/powershell
2626

27+
- name: Grant AppleScript access to Terminal.app
28+
run: |
29+
# Pre-authorize osascript to control Terminal.app via TCC database
30+
# GitHub Actions runner has sudo access
31+
sudo sqlite3 /Library/Application\ Support/com.apple.TCC/TCC.db \
32+
"INSERT OR REPLACE INTO access (service, client, client_type, auth_value, auth_reason, auth_version, indirect_object_identifier_type, indirect_object_identifier, flags, last_modified) VALUES ('kTCCServiceAppleEvents', '/usr/bin/osascript', 1, 2, 0, 1, 0, 'com.apple.Terminal', 0, strftime('%s','now'));" 2>&1 || true
33+
# Also allow the runner agent
34+
RUNNER_PATH=$(which Runner.Listener 2>/dev/null || echo "/Users/runner/runners/*/bin/Runner.Listener")
35+
sudo sqlite3 /Library/Application\ Support/com.apple.TCC/TCC.db \
36+
"INSERT OR REPLACE INTO access (service, client, client_type, auth_value, auth_reason, auth_version, indirect_object_identifier_type, indirect_object_identifier, flags, last_modified) VALUES ('kTCCServiceAppleEvents', '/usr/bin/osascript', 1, 2, 0, 1, 1, 'com.apple.Terminal', 0, strftime('%s','now'));" 2>&1 || true
37+
echo "TCC database updated"
38+
2739
- name: Build and setup module
2840
run: |
2941
dotnet build PowerShell.MCP -c Release --no-incremental
@@ -90,9 +102,10 @@ jobs:
90102
$response = Send-JsonRpc '{"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"start_powershell_console","arguments":{"reason":"issue38 test","banner":"Issue #38 E2E Test"}}}' 60000
91103
Write-Host "Response: $($response.Substring(0, [Math]::Min(200, $response.Length)))..."
92104
93-
if ($response -match '"error"') {
105+
if ($response -match '"error"' -or $response -match 'Failed to start') {
94106
Write-Host "ERROR in start_powershell_console response:" -ForegroundColor Red
95107
Write-Host $response
108+
screencapture -x /tmp/screenshot-error.png 2>$null
96109
throw "start_powershell_console failed"
97110
}
98111
Write-Host "Terminal.app console started" -ForegroundColor Green

0 commit comments

Comments
 (0)