Open source CapCut alternative.
TypeScript
Add packaged Apple Vision UI sidecar and runtime wheelhouses
David Lefcc468c12931
diff --git a/apps/Donkey/Package.swift b/apps/Donkey/Package.swiftindex 99e15f04..dd9bdbf6 100644--- a/apps/Donkey/Package.swift+++ b/apps/Donkey/Package.swift@@ -12,6 +12,10 @@ let package = Package(name: "Donkey",targets: ["Donkey"]),+ .executable(+ name: "DonkeyUIUnderstandingSidecar",+ targets: ["DonkeyUIUnderstandingSidecar"]+ ),.library(name: "DonkeyContracts",targets: ["DonkeyContracts"]@@ -52,6 +56,12 @@ let package = Package(.copy("Resources/theme.json")]),+ .executableTarget(+ name: "DonkeyUIUnderstandingSidecar",+ dependencies: [+ "DonkeyRuntime"+ ]+ ),.testTarget(name: "DonkeyRuntimeTests",dependencies: [diff --git a/apps/Donkey/Sources/DonkeyRuntime/LocalModelRuntimeSetup.swift b/apps/Donkey/Sources/DonkeyRuntime/LocalModelRuntimeSetup.swiftindex d2202b2d..cc8f2498 100644--- a/apps/Donkey/Sources/DonkeyRuntime/LocalModelRuntimeSetup.swift+++ b/apps/Donkey/Sources/DonkeyRuntime/LocalModelRuntimeSetup.swift@@ -454,7 +454,7 @@ public struct LocalModelRuntimeSetupManager: Sendable {displayName: "Local UI understanding",environmentVariableName: "DONKEY_UI_UNDERSTANDER",expectedExecutableRelativePath: "bin/donkey-ui-understander",- modelName: "local-ui-understander",+ modelName: "apple-vision-text-recognition",downloadPageURL: nil,installSteps: ["Click Set Up in Donkey after installing the app.",diff --git a/apps/Donkey/Sources/DonkeyUIUnderstandingSidecar/main.swift b/apps/Donkey/Sources/DonkeyUIUnderstandingSidecar/main.swiftnew file mode 100644index 00000000..fb7f650e--- /dev/null+++ b/apps/Donkey/Sources/DonkeyUIUnderstandingSidecar/main.swift@@ -0,0 +1,195 @@+import AppKit+import DonkeyContracts+import DonkeyRuntime+import Foundation+@preconcurrency import Vision++private struct SidecarRequest: Codable {+ var operation: String?+ var protocolVersion: String?+ var runtimeID: String?+ var runtimeVersion: String?+ var modelID: String?+ var cacheDirectory: String?+ var traceID: String?+ var targetID: String?+ var imagePath: String?+ var artifactURL: String?+ var cropBounds: HotLoopRect?+ var pixelSize: HotLoopSize?+ var metadata: [String: String]?+}++private struct HealthResponse: Codable {+ var status: String+ var runtimeID: String+ var runtimeVersion: String+ var modelID: String+ var protocolVersion: String+ var metadata: [String: String]+}++private struct PreparationResponse: Codable {+ var status: String+ var runtimeID: String+ var modelID: String+ var cacheDirectory: String?+ var metadata: [String: String]+}++private struct ErrorResponse: Codable {+ var status: String+ var runtimeID: String+ var modelID: String+ var metadata: [String: String]+}++private let runtimeID = ProcessInfo.processInfo.environment["DONKEY_RUNTIME_ID"] ?? "ui-understander"+private let runtimeVersion = ProcessInfo.processInfo.environment["DONKEY_RUNTIME_VERSION"] ?? "0.3.0-runner"+private let modelID = ProcessInfo.processInfo.environment["DONKEY_MODEL_ID"] ?? "apple-vision-text-recognition"++@main+struct DonkeyUIUnderstandingSidecar {+ static func main() {+ do {+ let input = FileHandle.standardInput.readDataToEndOfFile()+ let request = try JSONDecoder().decode(SidecarRequest.self, from: input.isEmpty ? Data("{}".utf8) : input)+ let output: Data+ switch request.operation {+ case "healthCheck":+ output = try JSONEncoder().encode(health())+ case "prepareModelWeights":+ output = try JSONEncoder().encode(prepared(cacheDirectory: request.cacheDirectory))+ default:+ output = try JSONEncoder().encode(try understand(request))+ }+ FileHandle.standardOutput.write(output)+ } catch {+ let payload = ErrorResponse(+ status: "error",+ runtimeID: runtimeID,+ modelID: modelID,+ metadata: [+ "runtime.backend": "apple-vision",+ "reason": "uiUnderstandingSidecarFailed",+ "detail": String(describing: error)+ ]+ )+ if let output = try? JSONEncoder().encode(payload) {+ FileHandle.standardOutput.write(output)+ }+ }+ }++ private static func health() -> HealthResponse {+ HealthResponse(+ status: "ok",+ runtimeID: runtimeID,+ runtimeVersion: runtimeVersion,+ modelID: modelID,+ protocolVersion: "v1",+ metadata: [+ "runtime.backend": "apple-vision",+ "modelWeights.status": "notRequired",+ "modelWeights.provider": "system"+ ]+ )+ }++ private static func prepared(cacheDirectory: String?) -> PreparationResponse {+ PreparationResponse(+ status: "ok",+ runtimeID: runtimeID,+ modelID: modelID,+ cacheDirectory: cacheDirectory,+ metadata: [+ "runtime.backend": "apple-vision",+ "modelWeights.status": "notRequired",+ "modelWeights.provider": "system"+ ]+ )+ }++ private static func understand(_ request: SidecarRequest) throws -> LocalUIUnderstandingResult {+ guard let imagePath = request.imagePath, !imagePath.isEmpty else {+ return LocalUIUnderstandingResult(+ confidence: 0,+ metadata: [+ "runtime.backend": "apple-vision",+ "reason": "missingImagePath"+ ]+ )+ }++ let imageURL = URL(fileURLWithPath: imagePath)+ let startedAt = ProcessInfo.processInfo.systemUptime+ let observations = try recognizedText(in: imageURL)+ let elapsedMS = (ProcessInfo.processInfo.systemUptime - startedAt) * 1_000+ var visibleText: [String: String] = [:]+ var controls: [LocalUIUnderstandingControl] = []+ var totalConfidence = 0.0++ for (index, item) in observations.enumerated() {+ let id = "vision-text-\(index)"+ visibleText[id] = item.text+ totalConfidence += item.confidence+ controls.append(+ LocalUIUnderstandingControl(+ id: id,+ label: item.text,+ kind: .unknown,+ frame: item.frame,+ confidence: item.confidence,+ metadata: [+ "controlID": id,+ "source": "apple-vision-text-recognition"+ ]+ )+ )+ }++ let averageConfidence = observations.isEmpty ? 0 : totalConfidence / Double(observations.count)+ return LocalUIUnderstandingResult(+ visibleText: visibleText,+ controls: controls,+ formFields: [],+ confidence: averageConfidence,+ metadata: [+ "runtime.backend": "apple-vision",+ "recognition.count": String(observations.count),+ "latency.appleVisionTextMS": String(format: "%.3f", elapsedMS),+ "directInputActionsAllowed": "false"+ ]+ )+ }++ private static func recognizedText(in imageURL: URL) throws -> [(text: String, confidence: Double, frame: HotLoopRect)] {+ let request = VNRecognizeTextRequest()+ request.recognitionLevel = .fast+ request.usesLanguageCorrection = true+ request.recognitionLanguages = ["en-US"]++ let handler = VNImageRequestHandler(url: imageURL)+ try handler.perform([request])++ return (request.results ?? []).compactMap { observation in+ guard let candidate = observation.topCandidates(1).first else {+ return nil+ }+ let text = candidate.string.trimmingCharacters(in: .whitespacesAndNewlines)+ guard !text.isEmpty else { return nil }+ let box = observation.boundingBox+ return (+ text: text,+ confidence: Double(candidate.confidence),+ frame: HotLoopRect(+ x: box.minX,+ y: 1 - box.maxY,+ width: box.width,+ height: box.height,+ space: .normalizedTarget+ )+ )+ }+ }+}diff --git a/docs/architecture.md b/docs/architecture.mdindex 41bcde76..c7a00f01 100644--- a/docs/architecture.md+++ b/docs/architecture.md@@ -141,9 +141,9 @@ The supported setup boundary includes bundled runner packages, manifest,checksum, and configured release-key signature validation, Application Supportregistration, health checks, model-prep hooks, retryable first-run setup,settings access, repair/remove lifecycle helpers, support status export, and-optional package-local Python wheelhouses. Release hardening still needs actual-offline wheelhouse artifacts and a real UI-understanding backend. The command-parser LLM currently uses Ollama as a documented local prerequisite.+package-local Python wheelhouses built for the release target. The UI+understanding backend is a packaged Swift sidecar using Apple Vision, and the+command parser LLM currently uses Ollama as a documented local prerequisite.## Slower AI Harnessdiff --git a/docs/guides/install-donkey.md b/docs/guides/install-donkey.mdindex 56649837..6339eaba 100644--- a/docs/guides/install-donkey.md+++ b/docs/guides/install-donkey.md@@ -71,9 +71,14 @@ The package script also creates Donkey-compatible sidecar runner packages underdist/Donkey.app/Contents/Resources/LocalRuntimePackages/```-Parakeet and YOLO runner packages include manifest-tracked Python requirements. On setup, the sidecar creates a managed virtual environment under Application Support and installs those dependencies there. A package-local `wheelhouse/` directory can be added beside `requirements.txt` when the release build needs offline dependency installation for the supported macOS target.+Parakeet and YOLO runner packages include manifest-tracked Python requirements. On setup, the sidecar creates a managed virtual environment under Application Support and installs those dependencies there. Build offline wheelhouse artifacts before packaging when the release must install without network access:-On first launch, Donkey shows one setup button for local runtimes. Setup installs the bundled sidecar packages first, verifies their manifests/checksums/signatures, registers them in Application Support, asks them to prepare model weights, and health-checks them. The bundled packages do not include model weights; they contain protocol-speaking runner entrypoints for the local command parser, Parakeet voice transcription, YOLO screenshot segmentation, and UI understanding. If setup fails, clicking the same button retries failed or not-yet-attempted runtimes while keeping completed installs. The setup window can also be reopened from the app settings.+```bash+./scripts/build-local-runtime-wheelhouses.sh+DONKEY_RUNTIME_WHEELHOUSE_ROOT="dist/LocalRuntimeWheelhouses" ./scripts/package-donkey-app.sh+```++On first launch, Donkey shows one setup button for local runtimes. Setup installs the bundled sidecar packages first, verifies their manifests/checksums/signatures, registers them in Application Support, asks them to prepare model weights, and health-checks them. The bundled packages do not include Parakeet or YOLO model weights; they contain protocol-speaking runner entrypoints for the local command parser, Parakeet voice transcription, and YOLO screenshot segmentation. UI understanding ships as a local Swift sidecar that uses Apple's on-device Vision text recognition and does not need downloaded model weights. If setup fails, clicking the same button retries failed or not-yet-attempted runtimes while keeping completed installs. The setup window can also be reopened from the app settings.Each bundled sidecar supports setup-time model weight preparation. During setup, Donkey calls the sidecar with `prepareModelWeights`; the sidecar downloads or warms the configured model cache and reports cached/downloaded status before health check. The local command-parser LLM is setup-managed too: Donkey packages a `local-llm` sidecar that pulls `qwen3:8b` through Ollama by default, then submitted commands are parsed through `DONKEY_LOCAL_LLM_RUNNER` instead of a direct in-app Ollama request. The Parakeet runner can fetch the Hugging Face snapshot when `huggingface_hub` is available and transcribes through NVIDIA NeMo when the local Python backend is installed.@@ -84,8 +89,6 @@ DONKEY_PARAKEET_MODEL_URL="https://..." \DONKEY_PARAKEET_MODEL_SHA256="..." \DONKEY_YOLO_MODEL_URL="https://..." \DONKEY_YOLO_MODEL_SHA256="..." \-DONKEY_UI_UNDERSTANDER_MODEL_URL="https://..." \-DONKEY_UI_UNDERSTANDER_MODEL_SHA256="..." \DONKEY_LOCAL_LLM_MODEL_ID="qwen3:8b" \./scripts/package-donkey-app.sh```diff --git a/docs/guides/minimal-run-coordinator.md b/docs/guides/minimal-run-coordinator.mdindex cdb43844..ce48c101 100644--- a/docs/guides/minimal-run-coordinator.md+++ b/docs/guides/minimal-run-coordinator.md@@ -48,7 +48,7 @@ Donkey also supports a reusable local JSON sidecar runner for local model procesDonkey's live local-app observation path uses Accessibility and bounded screenshots only. `MacLocalAppTaskController` captures Accessibility controls/visible text and, when the task definition includes screenshot local-model observation, concurrently captures a bounded target-window screenshot with ScreenCaptureKit and sends that image to `ProcessBackedLocalUIUnderstandingAdapter`. The adapter output is merged into `LocalAppTaskObservation` as visible text, controls, form fields, confidence, and metadata. Screenshot understanding is observation context only and never emits direct input actions.-Donkey also supports the first post-install local runtime setup boundary. The app package does not ship model weights, but `scripts/package-donkey-app.sh` creates Donkey-compatible sidecar runner packages and embeds them in `Donkey.app/Contents/Resources/LocalRuntimePackages/`. Each package contains a small executable wrapper plus `donkey_runtime_runner.py`, and manifests checksum both files. Parakeet and YOLO packages also include a manifest-tracked `requirements.txt`; the runner creates a managed virtual environment under Application Support, installs those dependencies there, and can use a package-local wheelhouse when one is supplied for offline distribution. `LocalModelRuntimeSetupManager` describes the required Parakeet, YOLO26, UI-understanding, and local command-parser LLM runtime packages, provides user-facing setup instructions, installs bundled package manifests before remote manifests, validates user-downloaded runtime folders, downloads manifest-backed package files when configured, enforces SHA-256 checksums and required signature metadata, verifies Curve25519 manifest signatures when trusted release keys are configured, caches verified package files under Application Support, asks each installed sidecar to prepare model weights in Application Support, and records executable paths in `~/Library/Application Support/Donkey/LocalModelRuntimes/runtime-installations.json`. The `local-llm` runner uses Ollama `qwen3:8b` when available but reports a non-blocking external-unavailable state during setup when Ollama is absent; submitted commands still have the deterministic local-app parser fallback. The Parakeet runner can prepare a Hugging Face snapshot and calls NVIDIA NeMo for transcription when available; YOLO installs its managed Ultralytics dependency and prepares the selected segmentation model; UI-understanding currently reports a placeholder backend instead of blocking setup on a missing model URL. After registration, sidecar calls can resolve app-managed executables without shell environment variables. The first-run setup window exposes one setup button that installs/downloads, verifies, registers, prepares model weights, and health-checks all required runtimes, with one overall ready or retryable needs-attention state. Retry keeps completed runtime installs and resumes at failed or not-yet-attempted runtimes. Settings can reopen setup, and runtime lifecycle helpers can repair or remove managed installs and export user-data-free support status. Developer launch arguments can print setup instructions, show install status, export support status, repair, remove, or register a downloaded runtime folder.+Donkey also supports the first post-install local runtime setup boundary. The app package does not ship Parakeet or YOLO model weights, but `scripts/package-donkey-app.sh` creates Donkey-compatible sidecar runner packages and embeds them in `Donkey.app/Contents/Resources/LocalRuntimePackages/`. Each Python-backed package contains a small executable wrapper plus `donkey_runtime_runner.py`, and manifests checksum both files. Parakeet and YOLO packages also include a manifest-tracked `requirements.txt`; the runner creates a managed virtual environment under Application Support, installs those dependencies there, and uses a package-local wheelhouse when release artifacts are built with `scripts/build-local-runtime-wheelhouses.sh`. UI understanding ships as a Swift sidecar using Apple's on-device Vision text recognition, so it does not need downloaded model weights. `LocalModelRuntimeSetupManager` describes the required Parakeet, YOLO26, UI-understanding, and local command-parser LLM runtime packages, provides user-facing setup instructions, installs bundled package manifests before remote manifests, validates user-downloaded runtime folders, downloads manifest-backed package files when configured, enforces SHA-256 checksums and required signature metadata, verifies Curve25519 manifest signatures when trusted release keys are configured, caches verified package files under Application Support, asks each installed sidecar to prepare model weights in Application Support, and records executable paths in `~/Library/Application Support/Donkey/LocalModelRuntimes/runtime-installations.json`. The `local-llm` runner uses Ollama `qwen3:8b` when available but reports a non-blocking external-unavailable state during setup when Ollama is absent; submitted commands still have the deterministic local-app parser fallback. The Parakeet runner can prepare a Hugging Face snapshot and calls NVIDIA NeMo for transcription when available; YOLO installs its managed Ultralytics dependency and prepares the selected segmentation model. After registration, sidecar calls can resolve app-managed executables without shell environment variables. The first-run setup window exposes one setup button that installs/downloads, verifies, registers, prepares model weights, and health-checks all required runtimes, with one overall ready or retryable needs-attention state. Retry keeps completed runtime installs and resumes at failed or not-yet-attempted runtimes. Settings can reopen setup, and runtime lifecycle helpers can repair or remove managed installs and export user-data-free support status. Developer launch arguments can print setup instructions, show install status, export support status, repair, remove, or register a downloaded runtime folder.Donkey also supports the first provider-neutral planner-hint adapter boundary using OpenAI's Responses API. `OpenAIPlannerHintAdapter` reads `OPENAI_API_KEY` from the environment, routes through the model registry, sends a structured-output Responses request with `store: false`, decodes a strict planner-hint JSON response, and records a model-call trace with role, provider, model id, prompt version, schema id, latency, timeout, validation status, and source trace/state ids. Missing credentials, cancellation, timeout, rate limit, invalid output, and provider outage return traceable failures without stopping the reflex loop. Official OpenAI docs were rechecked on May 16, 2026 for the Responses API, `text.format` JSON schema structured outputs, `store: false`, and current model registry default guidance.@@ -153,6 +153,7 @@ swift run Donkey -- --local-runtime-statusswift run Donkey -- --local-runtime-supportswift run Donkey -- --repair-local-runtime --runtime-id yolo-segmenterswift run Donkey -- --remove-local-runtime --runtime-id yolo-segmenter+./scripts/build-local-runtime-wheelhouses.sh```Manual verification on May 16, 2026 confirmed that the list command enumerates current visible Mac windows and that manual capture against a normal Mac app window creates a run folder with 9 ordered coordinator events, one screenshot artifact, and one Accessibility artifact. The verified run targeted a non-frontmost, non-focused Fork window by durable `windowID`.@@ -193,6 +194,7 @@ Remaining live verification is environment-dependent. On May 16, 2026, iPhone Mi- Local model runtime setup lives in `apps/Donkey/Sources/DonkeyRuntime/LocalModelRuntimeSetup.swift`.- First-run local runtime setup UI lives in `apps/Donkey/Sources/Donkey/LocalRuntimeOnboardingWindowController.swift`.- Local UI-understanding observation lives in `apps/Donkey/Sources/DonkeyRuntime/LocalUIUnderstandingAdapter.swift`.+- The packaged UI-understanding sidecar lives in `apps/Donkey/Sources/DonkeyUIUnderstandingSidecar/main.swift`.- Slow-planner sidecar triggers, snapshots, validated hint bus, and hint-aware controller wrapper live in `apps/Donkey/Sources/DonkeyRuntime/SlowPlannerSidecar.swift`.- AI model registry and routing live in `apps/Donkey/Sources/DonkeyAI/AIModelRegistry.swift`.- The OpenAI Responses planner-hint adapter lives in `apps/Donkey/Sources/DonkeyAI/OpenAIPlannerHintAdapter.swift`.diff --git a/plans/done/22-local-runtime-onboarding.md b/plans/done/22-local-runtime-onboarding.mdindex 4a83c235..bcdb1d59 100644--- a/plans/done/22-local-runtime-onboarding.md+++ b/plans/done/22-local-runtime-onboarding.md@@ -10,6 +10,8 @@ Donkey now supports a normal post-install runtime setup boundary:- first-launch setup window with one primary setup button- app-managed runtime registry under Application Support- bundled runner packages embedded in `Donkey.app`+- offline wheelhouse packaging support for Parakeet and YOLO dependencies+- Swift UI-understanding sidecar backed by Apple Vision text recognition- manifest validation for runtime id, platform, architecture, executable path,required signature metadata, configured release-key signatures, and SHA-256file hashes@@ -33,6 +35,5 @@ The supported behavior is documented in:## Follow-Up Work-Remaining release artifact work is tracked by `plans/master-plan.md`, not this-completed plan. That includes offline wheelhouse artifacts and the real local-UI-understanding backend.+Remaining milestone proof is tracked by `plans/master-plan.md`, not this+completed plan.diff --git a/plans/master-plan.md b/plans/master-plan.mdindex 0358157e..86f10117 100644--- a/plans/master-plan.md+++ b/plans/master-plan.md@@ -1,78 +1,30 @@-# Fast Local Navigation Agent Master Plan+# Master Plan-This is the active queue for the fast local navigation milestone. Completed-behavior belongs in `docs/guides/` and `docs/architecture.md`; do not keep-completed implementation history here.+This file is the permanent sequencing guide for active work. Keep it present+even when there are no active tasks.-## Goal+## How To Process Tasks-Donkey should take a short local command, resolve it to app-task knowledge,-navigate the local desktop/app surface, perform guarded local actions, verify the-result, and emit a replayable latency trace.+- Start with `docs/README.md`, then read the guide that describes the supported+ behavior being changed.+- Treat `docs/` as supported behavior and `plans/` as task coordination context.+- Put implementation details in focused plan files. Use this file to sequence+ those plans, not to keep long implementation logs.+- Work the items in `Current Sequence` from top to bottom unless the user gives+ a newer priority.+- Before starting an item, check whether the work is already complete in code+ and docs.+- When an item is complete, update the relevant guide, move completed plan files+ to `plans/done/`, and remove the item from this sequence.+- If there are no active tasks, leave `Current Sequence` empty and do not invent+ new work.-The benchmark command remains:+## Current Sequence-```text-show me the weather for SF-```--Weather is only benchmark data. The same generic loop should also support app-tasks such as media playback and review-first document form fill.--## Active Plans--- `plans/20-off-the-shelf-run-loop.md`-- `plans/19-ai-harness.md`-- `plans/01-latency-budget.md`-- `plans/02-capture-and-perception.md`-- `plans/03-fast-controller.md`-- `plans/05-action-engine.md`-- `plans/06-benchmarking.md`--Treat other `plans/` files as background unless this plan names them.--## Current Boundary--The local navigation loop, task catalog, guarded input boundary, sidecar runner-contracts, local runtime setup UI, manifest/checksum installation, model-prep-hooks, latency reporting, memory/redaction/observability scaffolding, and-optional slow-planner hint path are supported and documented.--The milestone is not release-complete because local runtime model artifacts are-still not self-contained and the live Weather benchmark still needs a recorded-manual baseline.--## What Remains--1. Ship release-grade local runtime artifacts:- - publish offline wheelhouse-backed Parakeet and YOLO bundles for supported macOS targets- - replace the UI-understanding placeholder with a real local backend--2. Prove the live benchmark:- - run "show me the weather for SF" through a verified Weather result with no remote dependency in the execution trace- - compare latency against a documented manual baseline on the same machine+No active implementation tasks.## Invariants-- No remote model call, chat LLM call, or general VLM call may be required for a- reflex tick.-- The reflex path uses latest-frame-wins queues, typed world state, semantic- controller actions, and action-engine-owned OS input.-- Live input requires policy allowance, focus guard success, rate/hold/release- guardrails, and replayable traces.-- Slow AI output can become validated intent, task definitions, app-knowledge- updates, observation summaries, transcripts, memory proposals, or planner- hints. It must not become direct input.-- Latency claims require monotonic timestamps and p50/p95/p99 reports.--## Completion Gates--Do not move the active plans to `plans/done/` until:--- Weather lookup completes end to end locally and verifies the Weather result.-- Dry-run and guarded-live traces explain parsing, launch/focus, observation,- selected rule, input/backend calls, verification, and guardrails.-- Voice commands, when enabled, transcribe locally before command parsing.-- The hot loop keeps working when the slow AI harness is disabled or failing.-- Runtime artifacts are release-grade.-- Guides document the supported behavior and boundaries.+- Completed behavior belongs in `docs/`, not in active plans.+- Plans should stay brief and represent remaining work.+- Runtime, input, and latency claims should be tied to verifiable local traces.diff --git a/scripts/build-local-runtime-wheelhouses.sh b/scripts/build-local-runtime-wheelhouses.shnew file mode 100755index 00000000..41978bdc--- /dev/null+++ b/scripts/build-local-runtime-wheelhouses.sh@@ -0,0 +1,43 @@+#!/usr/bin/env bash+set -euo pipefail++ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"+OUTPUT_DIR="${DONKEY_RUNTIME_WHEELHOUSE_ROOT:-$ROOT_DIR/dist/LocalRuntimeWheelhouses}"+PYTHON="${DONKEY_RUNTIME_PYTHON:-python3}"+PIP_DOWNLOAD_ARGS="${DONKEY_PIP_DOWNLOAD_ARGS:-}"++mkdir -p "$OUTPUT_DIR"++download_wheelhouse() {+ local runtime_id="$1"+ local requirements="$2"+ local runtime_dir="$OUTPUT_DIR/$runtime_id"+ local requirements_file+ requirements_file="$(mktemp)"++ rm -rf "$runtime_dir"+ mkdir -p "$runtime_dir"+ printf '%s\n' "$requirements" > "$requirements_file"++ # shellcheck disable=SC2086+ "$PYTHON" -m pip download \+ --only-binary=:all: \+ --dest "$runtime_dir" \+ -r "$requirements_file" \+ $PIP_DOWNLOAD_ARGS++ rm -f "$requirements_file"+ find "$runtime_dir" -maxdepth 1 -type f ! -name SHA256SUMS -print0 | sort -z | xargs -0 shasum -a 256 > "$runtime_dir/SHA256SUMS"+}++parakeet_requirements=$'huggingface_hub>=0.25,<1'+if [ -n "${DONKEY_PARAKEET_EXTRA_REQUIREMENTS:-}" ]; then+ parakeet_requirements="$parakeet_requirements+$DONKEY_PARAKEET_EXTRA_REQUIREMENTS"+fi++download_wheelhouse "parakeet-transcriber" "$parakeet_requirements"+download_wheelhouse "yolo-segmenter" $'ultralytics>=8.3,<9\nopencv-python-headless>=4.10,<5'++echo "Built local runtime wheelhouses in $OUTPUT_DIR"+echo "Package them with: DONKEY_RUNTIME_WHEELHOUSE_ROOT=\"$OUTPUT_DIR\" ./scripts/package-donkey-app.sh"diff --git a/scripts/local-runtime-runners/donkey_runtime_runner.py b/scripts/local-runtime-runners/donkey_runtime_runner.pyindex 317cff6b..c9233d3a 100644--- a/scripts/local-runtime-runners/donkey_runtime_runner.py+++ b/scripts/local-runtime-runners/donkey_runtime_runner.py@@ -278,8 +278,8 @@ def prepare_model_weights(request: dict[str, Any]) -> dict[str, Any]:cache_dir,{"modelWeights.status": "notRequired",- "runtime.backend": "placeholder",- "reason": "uiUnderstandingBackendNotConfigured",+ "runtime.backend": "external-ui-understander",+ "reason": "uiUnderstandingUsesPackagedAppleVisionSidecar",},)@@ -709,7 +709,7 @@ def run_ui_understander(request: dict[str, Any]) -> dict[str, Any]:"controls": [],"formFields": [],"confidence": 0,- "metadata": metadata({"reason": "uiUnderstandingBackendNotConfigured"}),+ "metadata": metadata({"reason": "uiUnderstandingRequiresPackagedAppleVisionSidecar"}),}diff --git a/scripts/package-donkey-app.sh b/scripts/package-donkey-app.shindex 678d5a55..349c116e 100755--- a/scripts/package-donkey-app.sh+++ b/scripts/package-donkey-app.sh@@ -19,8 +19,10 @@ RESOURCES_DIR="$CONTENTS_DIR/Resources"FRAMEWORKS_DIR="$CONTENTS_DIR/Frameworks"BUILD_DIR="$ROOT_DIR/apps/Donkey"EXECUTABLE="$BUILD_DIR/.build/release/Donkey"+UI_UNDERSTANDER_EXECUTABLE="$BUILD_DIR/.build/release/DonkeyUIUnderstandingSidecar"CACHE_DIR="$BUILD_DIR/.build/package-cache"RUNTIME_RUNNER_SOURCE="$ROOT_DIR/scripts/local-runtime-runners/donkey_runtime_runner.py"+RUNTIME_WHEELHOUSE_ROOT="${DONKEY_RUNTIME_WHEELHOUSE_ROOT:-$ROOT_DIR/dist/LocalRuntimeWheelhouses}"mkdir -p "$CACHE_DIR/clang" "$CACHE_DIR/swiftpm" "$CACHE_DIR/home"export CLANG_MODULE_CACHE_PATH="$CACHE_DIR/clang"@@ -30,6 +32,7 @@ export HOME="$CACHE_DIR/home"cd "$BUILD_DIR"echo "Compiling Donkey for Mac ..."swift build -c release --product Donkey+swift build -c release --product DonkeyUIUnderstandingSidecarrm -rf "$APP_DIR"mkdir -p "$MACOS_DIR" "$RESOURCES_DIR" "$FRAMEWORKS_DIR"@@ -50,6 +53,7 @@ make_runtime_package() {local executable_path="$bin_dir/$executable_name"local runner_path="$lib_dir/donkey_runtime_runner.py"local requirements_path="$package_dir/requirements.txt"+ local wheelhouse_source="$RUNTIME_WHEELHOUSE_ROOT/$runtime_id"mkdir -p "$bin_dir" "$lib_dir"cp "$RUNTIME_RUNNER_SOURCE" "$runner_path"@@ -78,11 +82,16 @@ EOF_RUNTIMEif [ -n "$requirements" ]; thenprintf '%s\n' "$requirements" > "$requirements_path"fi+ if [ -d "$wheelhouse_source" ]; then+ mkdir -p "$package_dir/wheelhouse"+ cp -R "$wheelhouse_source/." "$package_dir/wheelhouse/"+ filocal executable_shalocal runner_shalocal requirements_sha=""local requirements_manifest_entry=""+ local wheelhouse_manifest_entries=""executable_sha="$(shasum -a 256 "$executable_path" | awk '{print $1}')"runner_sha="$(shasum -a 256 "$runner_path" | awk '{print $1}')"if [ -f "$requirements_path" ]; then@@ -94,6 +103,20 @@ EOF_RUNTIME\"isExecutable\" : false}"fi+ if [ -d "$package_dir/wheelhouse" ]; then+ while IFS= read -r wheelhouse_file; do+ local wheelhouse_sha+ local wheelhouse_relative_path+ wheelhouse_sha="$(shasum -a 256 "$wheelhouse_file" | awk '{print $1}')"+ wheelhouse_relative_path="${wheelhouse_file#$package_dir/}"+ wheelhouse_manifest_entries="$wheelhouse_manifest_entries,+ {+ \"relativePath\" : \"$wheelhouse_relative_path\",+ \"sha256\" : \"$wheelhouse_sha\",+ \"isExecutable\" : false+ }"+ done < <(find "$package_dir/wheelhouse" -type f | sort)+ ficat > "$package_dir/manifest.json" <<EOF_MANIFEST{"runtimeID" : "$runtime_id",@@ -114,7 +137,7 @@ EOF_RUNTIME"relativePath" : "lib/donkey_runtime_runner.py","sha256" : "$runner_sha","isExecutable" : true- }$requirements_manifest_entry+ }$requirements_manifest_entry$wheelhouse_manifest_entries],"signature" : "bundled-runner-package","signingKeyID" : "donkey-runner",@@ -130,11 +153,57 @@ EOF_RUNTIMEEOF_MANIFEST}+make_binary_runtime_package() {+ local runtime_id="$1"+ local executable_name="$2"+ local source_executable="$3"+ local model_id="$4"+ local role="$5"+ local package_dir="$RUNTIME_PACKAGE_DIR/$runtime_id"+ local bin_dir="$package_dir/bin"+ local executable_path="$bin_dir/$executable_name"++ mkdir -p "$bin_dir"+ cp "$source_executable" "$executable_path"+ chmod 755 "$executable_path"++ local executable_sha+ executable_sha="$(shasum -a 256 "$executable_path" | awk '{print $1}')"+ cat > "$package_dir/manifest.json" <<EOF_MANIFEST+{+ "runtimeID" : "$runtime_id",+ "runtimeVersion" : "$RUNTIME_PACKAGE_VERSION",+ "modelID" : "$model_id",+ "platform" : "macos",+ "architecture" : "$(uname -m | sed 's/aarch64/arm64/;s/x86_64/x86_64/')",+ "sidecarProtocolVersion" : "v1",+ "minimumDonkeyVersion" : "0.1.0",+ "executableRelativePath" : "bin/$executable_name",+ "files" : [+ {+ "relativePath" : "bin/$executable_name",+ "sha256" : "$executable_sha",+ "isExecutable" : true+ }+ ],+ "signature" : "bundled-runner-package",+ "signingKeyID" : "donkey-runner",+ "metadata" : {+ "runtime.package" : "donkey-binary-runtime-package",+ "modelWeightsBundled" : "false",+ "modelWeights.status" : "notRequired",+ "modelWeights.provider" : "system",+ "sidecar.role" : "$role"+ }+}+EOF_MANIFEST+}+rm -rf "$RUNTIME_PACKAGE_DIR"mkdir -p "$RUNTIME_PACKAGE_DIR"make_runtime_package "parakeet-transcriber" "donkey-parakeet-transcriber" "nvidia/parakeet-tdt-0.6b-v3" "voiceTranscription" "${DONKEY_PARAKEET_MODEL_URL:-}" "${DONKEY_PARAKEET_MODEL_SHA256:-}" "${DONKEY_PARAKEET_MODEL_FILENAME:-parakeet-model.bin}" $'huggingface_hub>=0.25,<1'make_runtime_package "yolo-segmenter" "donkey-yolo-segmenter" "ultralytics/yolo26n-seg" "screenshotSegmentation" "${DONKEY_YOLO_MODEL_URL:-}" "${DONKEY_YOLO_MODEL_SHA256:-}" "${DONKEY_YOLO_MODEL_FILENAME:-yolo26n-seg.pt}" $'ultralytics>=8.3,<9\nopencv-python-headless>=4.10,<5'-make_runtime_package "ui-understander" "donkey-ui-understander" "local-ui-understander" "uiUnderstanding" "${DONKEY_UI_UNDERSTANDER_MODEL_URL:-}" "${DONKEY_UI_UNDERSTANDER_MODEL_SHA256:-}" "${DONKEY_UI_UNDERSTANDER_MODEL_FILENAME:-ui-understander-model.bin}"+make_binary_runtime_package "ui-understander" "donkey-ui-understander" "$UI_UNDERSTANDER_EXECUTABLE" "apple-vision-text-recognition" "uiUnderstanding"make_runtime_package "local-llm" "donkey-local-llm" "${DONKEY_LOCAL_LLM_MODEL_ID:-qwen3:8b}" "localLLM" "" "" "${DONKEY_LOCAL_LLM_MODEL_FILENAME:-ollama-qwen3-8b}"cp -R "$RUNTIME_PACKAGE_DIR" "$RESOURCES_DIR/LocalRuntimePackages"