Add mediated automation surface#79
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 527d2e34a4
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| @MainActor | ||
| func perform() async throws -> some IntentResult & ReturnsValue<String> { | ||
| let data = try BrokerAutomation.performResponseData( |
There was a problem hiding this comment.
Avoid running broker request synchronously on MainActor
Calling BrokerAutomation.performResponseData from an @MainActor perform() can deadlock the non-demo credential flow: AppleAuthenticationServicesBroker.login enqueues work onto DispatchQueue.main and then blocks on a semaphore, so when the caller is already on the main actor/thread the enqueued block cannot run and the request times out. This makes Shortcuts login/fill fail in normal (non-APW_DEMO) use.
Useful? React with 👍 / 👎.
| <command name="request login" code="APWalgon" description="Request a login credential through the APW broker. The user still approves the credential picker before credential material is returned."> | ||
| <direct-parameter type="text" description="The HTTPS URL to request."/> |
There was a problem hiding this comment.
Wire AppleScript commands to an implementation
This commit publishes custom AppleScript verbs in the sdef, but there is no corresponding command handler path in the APW app target to execute broker automation for these events (no NSScriptCommand subclass/selector wiring, and main.swift only launches runBrokerAppMain()). As shipped, request login/request fill Apple events have terminology but no executable bridge to BrokerAutomation, so the new AppleScript surface is non-functional.
Useful? React with 👍 / 👎.
pheidon
left a comment
There was a problem hiding this comment.
Approved from Pheidon sweep. Mediated automation surface is covered by native automation config tests and green PR Fast CI, Rust, lint, secrets, and Swift checks.
2e99fe6 to
4289405
Compare
4289405 to
65feadf
Compare
65feadf to
27992b9
Compare
pheidon
left a comment
There was a problem hiding this comment.
Second-pass approval after Hephaestus repair: current head has green required checks, the prior connector comments are stale against older commits, and the branch is no longer blocked by failing CI. Approved for merge readiness pending GitHub merge-state refresh.
Start the broker from an AppKit-backed bundled launch so AppleScript command classes can be dispatched from the app's scripting definition. Keep AppleScript broker requests off the main thread while pumping the run loop, preserving credential UI dispatch for non-demo requests.
Document that the AppleScript direct parameters are routed to the concrete NSScriptCommand bridge classes added for broker automation.
27992b9 to
2e6d6dc
Compare
Summary
BrokerAutomationrequest/response path for mediatedloginandfillautomation.MainActor.NSScriptCommandimplementations that callBrokerAutomation.servelaunches underNSApplicationso Cocoa scripting can dispatch the SDEF command classes while the broker socket server runs on a background thread.Closes #50.
Verification
bash scripts/test-native-automation-config.shbash scripts/ci/run-fast-checks.shswift test --package-path native-app --filter BrokerCoreTests/testAutomation(outside sandbox; SwiftPM/Xcode need user cache access)swift test --package-path native-app(outside sandbox; 18 tests passed)./scripts/build-native-app.sh(outside sandbox; Swift emits the existing AuthenticationServices exhaustive-switch warning)plutil -p native-app/dist/APW.app/Contents/Info.plistconfirmedNSAppleScriptEnabled=trueandOSAScriptingDefinition=APW.sdeftest -f native-app/dist/APW.app/Contents/Resources/APW.sdefxmllint --noout native-app/Resources/APW.sdefsdp -fh -o /private/tmp/apw-sdef.h native-app/Resources/APW.sdefnm -m native-app/dist/APW.app/Contents/MacOS/APW | rg 'APWRequest(Login|Fill)Command|BrokerApplicationDelegate'git diff --checkNotes