# Scripts *[Version française](README.fr.md)* ## `launch-ori.applescript` — start the sandbox and open ori-desktop One gesture instead of two commands: the script starts (or restarts) the `ori` sandbox, waits until the ori server answers, then opens the desktop app. What it does, in order: 1. Finds the repository root from its own location (`/scripts/…`). Set the `repoDirOverride` property at the top of the file if you move it elsewhere. 2. Checks that `ori-desktop/build/bin/ori-desktop.app` exists; otherwise shows how to build it (`cd ori-desktop && wails build && xattr -cr build/bin/ori-desktop.app`). 3. If `sbx ls -q` already lists a sandbox named `ori`, restarts it with `sbx run -d --name ori`. Otherwise creates it: ```bash sbx run -d claude . --template k33g/ori:0.0.1 --kit ./kits/ori --name ori -p 5555:8888 ``` 4. Polls `http://localhost:5555/healthz` every 2 s, up to 90 s (`healthTimeoutSeconds`). If the server never answers it still opens the app and tells you where to look: `sbx exec ori cat /var/log/sbx-kit-startup.log`. 5. Opens `ori-desktop.app`, which auto-connects to the server URL it remembered last time (`~/Library/Application Support/ori-desktop/settings.json`, key `serverUrl`). Set it to `http://localhost:5555` on the first connection screen. Template, kit, ports, sandbox name and timeout are `property` lines at the top of the script. ### Run it from a terminal ```bash osascript scripts/launch-ori.applescript ``` ### Make it double-clickable Compile the script into an application bundle: ```bash osacompile -o "scripts/Launch Ori.app" scripts/launch-ori.applescript ``` - Double-click `scripts/Launch Ori.app` in the Finder, drag it to the Dock, or launch it from Spotlight ("Launch Ori"). - The `.app` is a build artefact and is gitignored (`scripts/*.app/`). Rebuild it after every edit of the `.applescript`. - Built locally, it carries no quarantine attribute, so Gatekeeper does not block it. macOS may ask once for permission to show notifications. - Progress is reported with notifications; a hard failure (app not built, `sbx run` failing, usually because Docker Desktop is not running) opens an alert dialog. ### Why these choices - **Finder launches get a minimal `PATH`** without `/opt/homebrew/bin`, so the script exports it before every shell command. - **`sbx run -d`** (detached) returns as soon as the sandbox exists, and exempts it from sbx's 30 s auto-stop. The kit then starts the ori server asynchronously, hence the health poll before opening the app. - **Restart instead of recreate** when the sandbox exists: re-running the create command would collide on the name, and `sbx rm` + create would lose the sandbox's Claude session. ### Test the handlers without creating a sandbox ```bash osacompile -o /tmp/launch-ori.scpt scripts/launch-ori.applescript osascript -e 'set s to load script POSIX file "/tmp/launch-ori.scpt" set s'"'"'s healthTimeoutSeconds to 4 return s'"'"'s waitForServer("http://localhost:5555")' # false unless something answers on :5555 ```