The PolyClaw Trading macOS runner is a native Swift package that lives underDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/deniszidbaev-cmyk/polyclaw-trading/llms.txt
Use this file to discover all available pages before exploring further.
Sources/PolyclawMacCore/ and Sources/PolyclawMac/. It replaces shell-specific workspace discovery, process launching, OpenClaw gateway startup, TUI retries, and the isolated Kilo worker loop with a single compiled CLI — no Python interpreter, no shell quoting edge cases, no external runtime required to start the system. The trading and risk logic stays entirely in Python; the Swift layer is purely a process supervisor and safe environment loader.
What the Runner Does
Thepolyclaw-mac binary handles everything that previously required per-shell scripts:
- Workspace discovery — resolves the checkout path from the current directory or the
OPENCLAW_WORKSPACEenvironment variable - Safe
.env.localloading — reads key/value pairs without echoing sensitive values to the terminal - Process launching — starts the Python pipeline, OpenClaw gateway, OpenClaw TUI, and the Kilo worker loop as managed subprocesses
- TUI retry logic — handles gateway startup races without manual
sleephacks in shell scripts - Kilo worker isolation — stores the Kilo profile under
runtime/kilo-worker-*so it never disturbs the primary~/.local/share/kiloprofile - Dry-run pinning — the
dry-runcommand forcesLIVE_TRADING=0andALLOW_REDEEM=0even if the inherited environment or.env.localsays otherwise
runtime/ remain the language boundary between the Swift runner and the Python modules. This design means trading stages can be individually migrated to Swift later without changing the inter-process contract.
Package Structure
The Swift package (Package.swift) targets macOS 13+ and produces three products:
PolyclawMacCore— reusable library: dotenv safety, process handling, workspace resolutionpolyclaw-mac— the operator CLIpolyclaw-mac-selftest— dependency-free self-test executable covering CLI parsing, dry-run pinning, and workspace discovery
Installation
Install Xcode Command Line Tools
The Swift compiler is part of the Xcode command line tools. If you already have Xcode installed, you may already have them. Otherwise:Confirm the installation by checking the Swift version:
Run the self-test
Before building the release binary, run the built-in self-test. It requires no secrets and no network access:This runs the dependency-free Swift self-tests for CLI parsing, dry-run pinning, and workspace discovery. All tests must pass before proceeding.
Build the release binary
.build/release/polyclaw-mac. You can invoke it from the repository root without adding it to PATH:PATH:Available Commands
Workspace Discovery
The runner resolves the checkout path in this order:- The
OPENCLAW_WORKSPACEenvironment variable, if set - The current working directory
OPENCLAW_WORKSPACE is recommended when running the binary from launchd, cron, or any context where the working directory is not guaranteed to be the repository root.
Environment Loading
The runner reads.env.local from the resolved workspace directory. Values are loaded without being echoed to the terminal or written to any log. The runner prefers .venv/uv for Python resolution, matching the same preference order as the native shell launchers.
Log Output
Pipeline output is written toruntime/macos-runner.log inside the resolved workspace. You can tail it while the runner is active:
Dry-Run Safety Guarantee
Therun command (without live --confirm-live) unconditionally pins:
.env.local or the inherited shell environment. There is no configuration that can make polyclaw-mac run send a live order.
Language Boundary
The Swift runner and the Python modules communicate exclusively through versioned JSON files underruntime/. The runner never inspects, parses, or modifies trade logic. This clean boundary means:
- Trading stages can be migrated to Swift independently, one at a time
- Any Python stage can be replaced or tested in isolation without rebuilding the runner
- The full contract is documented in
runtime/README.md