Skip to content

Open source CapCut alternative.

TypeScript

Update local runner

David Le00c3618df76a
diff --git a/apps/Donkey/Sources/Donkey/LocalRuntimeOnboardingWindowController.swift b/apps/Donkey/Sources/Donkey/LocalRuntimeOnboardingWindowController.swift
index 5ee549a6..a3429a6a 100644
--- a/apps/Donkey/Sources/Donkey/LocalRuntimeOnboardingWindowController.swift
+++ b/apps/Donkey/Sources/Donkey/LocalRuntimeOnboardingWindowController.swift
@@ -37,7 +37,7 @@ final class LocalRuntimeOnboardingWindowController: NSWindowController {
final class LocalRuntimeOnboardingModel: ObservableObject {
@Published private(set) var state: LocalRuntimeSetupViewState = .checking
@Published private(set) var summary = "Checking Donkey setup..."
- @Published private(set) var detail = "Donkey uses local model runtimes for voice, screenshots, and UI understanding."
+ @Published private(set) var detail = "Donkey uses local model runtimes for command parsing, voice, screenshots, and UI understanding."
private let manager: LocalModelRuntimeSetupManager
private var retryRuntimeIDs: [LocalModelRuntimeID] = []
diff --git a/apps/Donkey/Sources/Donkey/PointerPromptCommandHandler.swift b/apps/Donkey/Sources/Donkey/PointerPromptCommandHandler.swift
index 272a7189..19e5c694 100644
--- a/apps/Donkey/Sources/Donkey/PointerPromptCommandHandler.swift
+++ b/apps/Donkey/Sources/Donkey/PointerPromptCommandHandler.swift
@@ -54,15 +54,7 @@ struct LocalAppPointerPromptCommandHandler: PointerPromptCommandHandling {
command: command,
sourceTraceID: traceID
)
- let localModelResolution = localModelResult.resolution
- let deterministicResolution = catalog.resolve(command: command)
- let shouldUseDeterministicFallback = localModelResolution.status == .unsupportedCommand
- && localModelResolution.metadata["reason"] == "localModelIntentUnavailable"
- && deterministicResolution.status != .unsupportedCommand
- let resolution = shouldUseDeterministicFallback
- ? deterministicResolution
- : localModelResolution
- let parserSource = shouldUseDeterministicFallback ? "deterministicFallback" : "localModel"
+ let resolution = localModelResult.resolution
let parseLatencyMS = Self.uptimeMilliseconds() - parseStartedAt
let modelObservability = AIModelObservabilityReportBuilder.build(from: [localModelResult.trace])
@@ -71,7 +63,7 @@ struct LocalAppPointerPromptCommandHandler: PointerPromptCommandHandling {
traceID: traceID,
resolution: resolution,
metadata: [
- "intentParser": parserSource,
+ "intentParser": "localModel",
"latency.commandParseMS": Self.formatLatency(parseLatencyMS),
"modelCallID": localModelResult.trace.id,
"modelCallStatus": localModelResult.trace.status.rawValue,
diff --git a/apps/Donkey/Sources/DonkeyAI/AIModelRegistry.swift b/apps/Donkey/Sources/DonkeyAI/AIModelRegistry.swift
index b7a11dca..4a8c887f 100644
--- a/apps/Donkey/Sources/DonkeyAI/AIModelRegistry.swift
+++ b/apps/Donkey/Sources/DonkeyAI/AIModelRegistry.swift
@@ -103,6 +103,24 @@ public struct AIModelRegistry: Codable, Equatable, Sendable {
public static let defaultHybridPlanner = AIModelRegistry(
entries: [
+ AIModelRegistryEntry(
+ id: "local-runtime-task-intent-qwen3",
+ role: .taskIntent,
+ provider: .localRuntime,
+ modelID: "qwen3:8b",
+ endpoint: URL(string: "local://qwen3:8b/task-intent")!,
+ capabilities: [.textInput, .structuredOutputs],
+ timeoutMS: 4_000,
+ promptVersion: "task-intent-v1",
+ evalStatus: .candidate,
+ docsURL: URL(string: "https://ollama.com/library/qwen3")!,
+ rollbackID: nil,
+ metadata: [
+ "local": "true",
+ "runtime": "donkey-local-llm-sidecar",
+ "sidecarEnvironmentVariable": "DONKEY_LOCAL_LLM_RUNNER"
+ ]
+ ),
AIModelRegistryEntry(
id: "ollama-task-intent-local",
role: .taskIntent,
diff --git a/apps/Donkey/Sources/DonkeyAI/OllamaTaskIntentAdapter.swift b/apps/Donkey/Sources/DonkeyAI/OllamaTaskIntentAdapter.swift
index 72327bb1..795a5e5f 100644
--- a/apps/Donkey/Sources/DonkeyAI/OllamaTaskIntentAdapter.swift
+++ b/apps/Donkey/Sources/DonkeyAI/OllamaTaskIntentAdapter.swift
@@ -35,7 +35,185 @@ public struct TaskIntentAdapterResult: Equatable, Sendable {
}
}
-public struct OllamaTaskIntentAdapter: Sendable {
+public protocol TaskIntentParsingAdapter: Sendable {
+ func parseTaskIntent(_ request: TaskIntentAdapterRequest) async -> TaskIntentAdapterResult
+}
+
+public struct ProcessBackedLocalLLMTaskIntentAdapter: TaskIntentParsingAdapter {
+ public static let schemaID = "task_intent_v1"
+
+ public var router: AIModelRouter
+ public var sidecarRunner: any LocalJSONSidecarRunning
+ public var encoder: JSONEncoder
+ public var decoder: JSONDecoder
+
+ public init(
+ router: AIModelRouter = AIModelRouter(registry: .defaultHybridPlanner),
+ sidecarRunner: any LocalJSONSidecarRunning = ProcessBackedLocalJSONSidecarRunner(),
+ encoder: JSONEncoder = JSONEncoder(),
+ decoder: JSONDecoder = JSONDecoder()
+ ) {
+ self.router = router
+ self.sidecarRunner = sidecarRunner
+ self.encoder = encoder
+ self.decoder = decoder
+ }
+
+ public func parseTaskIntent(
+ _ request: TaskIntentAdapterRequest
+ ) async -> TaskIntentAdapterResult {
+ let entry: AIModelRegistryEntry
+ do {
+ entry = try router.route(request.routeRequest.limitingProviders([.localRuntime]))
+ } catch {
+ return result(
+ entry: nil,
+ request: request,
+ status: .invalidOutput,
+ validationStatus: "routingFailed",
+ latencyMS: nil,
+ metadata: ["error": String(describing: error)]
+ )
+ }
+
+ let input = LocalLLMTaskIntentSidecarRequest(
+ command: request.command,
+ taskDefinitions: request.taskDefinitions,
+ sourceTraceID: request.sourceTraceID,
+ modelID: entry.modelID,
+ metadata: [
+ "schemaID": Self.schemaID,
+ "promptVersion": entry.promptVersion
+ ]
+ )
+ let result = await sidecarRunner.run(
+ LocalJSONSidecarRequest(
+ environmentVariableName: "DONKEY_LOCAL_LLM_RUNNER",
+ inputData: (try? encoder.encode(input)) ?? Data(),
+ timeoutMS: entry.timeoutMS,
+ metadata: [
+ "sidecar.role": "taskIntent",
+ "modelID": entry.modelID
+ ]
+ )
+ )
+
+ guard result.status == .completed else {
+ return self.result(
+ entry: entry,
+ request: request,
+ status: result.status == .timedOut ? .timeout : .providerOutage,
+ validationStatus: "notValidated",
+ latencyMS: result.latencyMS,
+ metadata: result.metadata.merging([
+ "sidecar.stderr": result.stderrText
+ ]) { current, _ in current }
+ )
+ }
+
+ do {
+ let response = try decoder.decode(LocalLLMTaskIntentSidecarResponse.self, from: result.outputData)
+ guard let intent = try TaskIntentWireCodec.decodeIntent(
+ response.outputText,
+ definitions: request.taskDefinitions,
+ sourceModelCallID: "model-call-\(request.sourceTraceID)",
+ parserName: "local-llm-sidecar-v1"
+ ) else {
+ return self.result(
+ entry: entry,
+ request: request,
+ status: .invalidOutput,
+ validationStatus: "invalid",
+ latencyMS: result.latencyMS,
+ metadata: result.metadata.merging(response.metadata) { current, _ in current }
+ )
+ }
+
+ return TaskIntentAdapterResult(
+ intent: intent,
+ trace: trace(
+ entry: entry,
+ request: request,
+ status: .completed,
+ validationStatus: "schemaDecoded",
+ latencyMS: result.latencyMS,
+ metadata: result.metadata.merging(response.metadata) { current, _ in current }
+ )
+ )
+ } catch {
+ return self.result(
+ entry: entry,
+ request: request,
+ status: .invalidOutput,
+ validationStatus: "invalid",
+ latencyMS: result.latencyMS,
+ metadata: result.metadata.merging([
+ "error": String(describing: error)
+ ]) { current, _ in current }
+ )
+ }
+ }
+
+ private func result(
+ entry: AIModelRegistryEntry?,
+ request: TaskIntentAdapterRequest,
+ status: AIModelCallStatus,
+ validationStatus: String,
+ latencyMS: Double?,
+ metadata: [String: String] = [:]
+ ) -> TaskIntentAdapterResult {
+ TaskIntentAdapterResult(
+ intent: nil,
+ trace: trace(
+ entry: entry,
+ request: request,
+ status: status,
+ validationStatus: validationStatus,
+ latencyMS: latencyMS,
+ metadata: metadata
+ )
+ )
+ }
+
+ private func trace(
+ entry: AIModelRegistryEntry?,
+ request: TaskIntentAdapterRequest,
+ status: AIModelCallStatus,
+ validationStatus: String,
+ latencyMS: Double?,
+ metadata: [String: String] = [:]
+ ) -> AIModelCallTrace {
+ AIModelCallTrace(
+ id: "model-call-\(request.sourceTraceID)",
+ role: entry?.role ?? .taskIntent,
+ provider: entry?.provider ?? .localRuntime,
+ modelID: entry?.modelID ?? "unrouted",
+ promptVersion: entry?.promptVersion ?? "unrouted",
+ schemaID: Self.schemaID,
+ latencyMS: latencyMS,
+ timeoutMS: entry?.timeoutMS ?? 0,
+ status: status,
+ validationStatus: validationStatus,
+ sourceTraceID: request.sourceTraceID,
+ metadata: metadata
+ )
+ }
+}
+
+private struct LocalLLMTaskIntentSidecarRequest: Codable, Equatable, Sendable {
+ var command: String
+ var taskDefinitions: [LocalAppTaskDefinition]
+ var sourceTraceID: String
+ var modelID: String
+ var metadata: [String: String]
+}
+
+private struct LocalLLMTaskIntentSidecarResponse: Codable, Equatable, Sendable {
+ var outputText: String
+ var metadata: [String: String]
+}
+
+public struct OllamaTaskIntentAdapter: TaskIntentParsingAdapter {
public static let schemaID = "task_intent_v1"
public var router: AIModelRouter
@@ -85,7 +263,8 @@ public struct OllamaTaskIntentAdapter: Sendable {
let intent = try TaskIntentWireCodec.decodeIntent(
outputText,
definitions: request.taskDefinitions,
- sourceModelCallID: "model-call-\(request.sourceTraceID)"
+ sourceModelCallID: "model-call-\(request.sourceTraceID)",
+ parserName: "ollama-task-intent-v1"
)
else {
return result(entry: entry, request: request, status: .invalidOutput, validationStatus: "invalid", latencyMS: latencyMS)
@@ -228,11 +407,11 @@ public struct OllamaTaskIntentAdapter: Sendable {
public struct LocalModelTaskIntentResolver: Sendable {
public var catalog: LocalAppTaskCatalog
- public var adapter: OllamaTaskIntentAdapter
+ public var adapter: any TaskIntentParsingAdapter
public init(
catalog: LocalAppTaskCatalog,
- adapter: OllamaTaskIntentAdapter = OllamaTaskIntentAdapter()
+ adapter: any TaskIntentParsingAdapter = ProcessBackedLocalLLMTaskIntentAdapter()
) {
self.catalog = catalog
self.adapter = adapter
@@ -309,7 +488,8 @@ private enum TaskIntentWireCodec {
static func decodeIntent(
_ outputText: String,
definitions: [LocalAppTaskDefinition],
- sourceModelCallID: String
+ sourceModelCallID: String,
+ parserName: String
) throws -> TaskIntent? {
let data = Data(outputText.utf8)
let wire = try JSONDecoder().decode(TaskIntentWire.self, from: data)
@@ -324,7 +504,7 @@ private enum TaskIntentWireCodec {
rule.required && normalizedEntities[rule.name] == nil
}
var metadata = wire.metadata.merging(definition.metadata) { current, _ in current }
- metadata["parser"] = "ollama-task-intent-v1"
+ metadata["parser"] = parserName
if let missingRequiredEntity {
metadata["missingEntity"] = missingRequiredEntity.name
}
diff --git a/apps/Donkey/Sources/DonkeyRuntime/LocalAppTaskLiveRunner.swift b/apps/Donkey/Sources/DonkeyRuntime/LocalAppTaskLiveRunner.swift
index 341e774e..f2454214 100644
--- a/apps/Donkey/Sources/DonkeyRuntime/LocalAppTaskLiveRunner.swift
+++ b/apps/Donkey/Sources/DonkeyRuntime/LocalAppTaskLiveRunner.swift
@@ -466,11 +466,21 @@ public struct MacLocalAppTaskController: LocalAppTaskAppControlling {
public func observe(definition: LocalAppTaskDefinition) async -> LocalAppTaskObservation {
let runningApplication = runningApplication(for: definition.targetApp)
let isFocused = NSWorkspace.shared.frontmostApplication?.bundleIdentifier == definition.targetApp.bundleIdentifier
- let accessibilityIndex = accessibilityControlIndex(for: definition, runningApplication: runningApplication)
- let visibleText = accessibilityIndex?.visibleText ?? accessibilityVisibleText(for: runningApplication)
let verificationKey = definition.metadata["verificationTextKey"]
?? definition.verificationEntityName
?? "visibleText"
+ async let screenshotObservationTask: LocalAppTaskObservation? = shouldIncludeScreenshotUnderstanding(
+ definition: definition
+ )
+ ? screenshotUnderstandingObservation(
+ definition: definition,
+ runningApplication: runningApplication,
+ isFocused: isFocused,
+ verificationKey: verificationKey
+ )
+ : nil
+ let accessibilityIndex = accessibilityControlIndex(for: definition, runningApplication: runningApplication)
+ let visibleText = accessibilityIndex?.visibleText ?? accessibilityVisibleText(for: runningApplication)
var controls: [String: Bool] = Dictionary(
uniqueKeysWithValues: definition.workflowSteps.compactMap { step in
guard step.role == .focusControl,
@@ -503,19 +513,11 @@ public struct MacLocalAppTaskController: LocalAppTaskAppControlling {
]
)
- guard shouldUseScreenshotUnderstanding(
- definition: definition,
- observation: accessibilityObservation
- ) else {
+ guard shouldIncludeScreenshotUnderstanding(definition: definition) else {
return accessibilityObservation
}
- guard let screenshotObservation = await screenshotUnderstandingObservation(
- definition: definition,
- runningApplication: runningApplication,
- isFocused: isFocused,
- verificationKey: verificationKey
- ) else {
+ guard let screenshotObservation = await screenshotObservationTask else {
var metadata = accessibilityObservation.metadata
metadata["screenshotUnderstanding.status"] = "unavailable"
return LocalAppTaskObservation(
@@ -543,20 +545,10 @@ public struct MacLocalAppTaskController: LocalAppTaskAppControlling {
)
}
- private func shouldUseScreenshotUnderstanding(
- definition: LocalAppTaskDefinition,
- observation: LocalAppTaskObservation
+ private func shouldIncludeScreenshotUnderstanding(
+ definition: LocalAppTaskDefinition
) -> Bool {
- guard definition.observationStrategies.contains(.screenshotForLocalModel) else {
- return false
- }
-
- let expectedControls = definition.workflowSteps.compactMap { step -> String? in
- guard step.role == .focusControl else { return nil }
- return step.metadata["controlID"]
- }
- let missingExpectedControl = expectedControls.contains { observation.availableControls[$0] != true }
- return observation.visibleText.isEmpty || missingExpectedControl || observation.confidence < 0.7
+ definition.observationStrategies.contains(.screenshotForLocalModel)
}
@MainActor
diff --git a/apps/Donkey/Sources/DonkeyRuntime/LocalModelRuntimeSetup.swift b/apps/Donkey/Sources/DonkeyRuntime/LocalModelRuntimeSetup.swift
index 488b6cfa..3b563ae0 100644
--- a/apps/Donkey/Sources/DonkeyRuntime/LocalModelRuntimeSetup.swift
+++ b/apps/Donkey/Sources/DonkeyRuntime/LocalModelRuntimeSetup.swift
@@ -5,6 +5,7 @@ public enum LocalModelRuntimeID: String, Codable, CaseIterable, Equatable, Senda
case parakeetTranscriber = "parakeet-transcriber"
case yoloSegmenter = "yolo-segmenter"
case uiUnderstander = "ui-understander"
+ case localLLM = "local-llm"
}
public enum LocalModelRuntimeInstallState: String, Codable, Equatable, Sendable {
@@ -375,6 +376,24 @@ public struct LocalModelRuntimeSetupManager: Sendable {
"Donkey records bin/donkey-ui-understander in Application Support."
],
metadata: ["sidecar.role": "uiUnderstanding"]
+ ),
+ LocalModelRuntimeSpec(
+ id: .localLLM,
+ displayName: "Local command parser LLM",
+ environmentVariableName: "DONKEY_LOCAL_LLM_RUNNER",
+ expectedExecutableRelativePath: "bin/donkey-local-llm",
+ modelName: "qwen3:8b",
+ downloadPageURL: URL(string: "https://ollama.com/library/qwen3"),
+ installSteps: [
+ "Click Set Up in Donkey after installing the app.",
+ "Donkey asks the local LLM runner to download and cache qwen3:8b.",
+ "Donkey records bin/donkey-local-llm in Application Support."
+ ],
+ metadata: [
+ "sidecar.role": "localLLM",
+ "modelWeights.provider": "ollama",
+ "modelWeights.ollamaModel": "qwen3:8b"
+ ]
)
]
@@ -651,7 +670,13 @@ public struct LocalModelRuntimeSetupManager: Sendable {
let requestData = try Self.encoder().encode(
LocalModelRuntimeHealthRequest(
operation: "healthCheck",
- protocolVersion: installation.sidecarProtocolVersion ?? "v1"
+ protocolVersion: installation.sidecarProtocolVersion ?? "v1",
+ runtimeID: runtimeID.rawValue,
+ runtimeVersion: installation.runtimeVersion,
+ modelID: installation.modelID ?? status.spec.modelName,
+ cacheDirectory: modelCacheDirectory(for: installation).path,
+ metadata: status.spec.metadata
+ .merging(installation.metadata) { _, new in new }
)
)
let runner = ProcessBackedLocalJSONSidecarRunner(
@@ -937,6 +962,11 @@ public struct LocalModelRuntimeSetupManager: Sendable {
private struct LocalModelRuntimeHealthRequest: Codable, Equatable, Sendable {
var operation: String
var protocolVersion: String
+ var runtimeID: String?
+ var runtimeVersion: String?
+ var modelID: String?
+ var cacheDirectory: String?
+ var metadata: [String: String]?
}
private struct LocalModelRuntimeHealthResponse: Codable, Equatable, Sendable {
diff --git a/apps/Donkey/Tests/DonkeyRuntimeTests/AIHarnessAdapterTests.swift b/apps/Donkey/Tests/DonkeyRuntimeTests/AIHarnessAdapterTests.swift
index caba69cd..01bfdd28 100644
--- a/apps/Donkey/Tests/DonkeyRuntimeTests/AIHarnessAdapterTests.swift
+++ b/apps/Donkey/Tests/DonkeyRuntimeTests/AIHarnessAdapterTests.swift
@@ -79,9 +79,9 @@ struct AIHarnessAdapterTests {
)
)
- #expect(selected.id == "ollama-task-intent-local")
+ #expect(selected.id == "local-runtime-task-intent-qwen3")
#expect(selected.role == .taskIntent)
- #expect(selected.provider == .ollama)
+ #expect(selected.provider == .localRuntime)
}
@Test
@@ -298,6 +298,39 @@ struct AIHarnessAdapterTests {
#expect((body["prompt"] as? String)?.contains("Use only the provided task definitions") == true)
}
+ @Test
+ func processBackedLocalLLMTaskIntentAdapterDecodesValidatedIntent() async throws {
+ let adapter = ProcessBackedLocalLLMTaskIntentAdapter(
+ router: AIModelRouter(registry: .defaultHybridPlanner),
+ sidecarRunner: FakeSidecarRunner(
+ result: LocalJSONSidecarResult(
+ status: .completed,
+ outputData: Data("""
+ {"outputText":"{\\"taskType\\":\\"media_playback\\",\\"targetAppName\\":\\"Music\\",\\"entities\\":{\\"query\\":\\"cold play\\"},\\"normalizedEntities\\":{\\"query\\":\\"Cold Play\\"},\\"confidence\\":0.91,\\"needsConfirmation\\":false,\\"metadata\\":{\\"source\\":\\"test\\"}}","metadata":{"local.provider":"ollama-sidecar"}}
+ """.utf8),
+ latencyMS: 14,
+ metadata: ["sidecar.role": "taskIntent"]
+ )
+ )
+ )
+
+ let result = await adapter.parseTaskIntent(
+ TaskIntentAdapterRequest(
+ command: "play cold play",
+ taskDefinitions: BuiltInLocalAppTaskDefinitions.defaults,
+ sourceTraceID: "trace-local-llm"
+ )
+ )
+
+ #expect(result.intent?.taskType == "media_playback")
+ #expect(result.intent?.targetApp.appName == "Music")
+ #expect(result.intent?.normalizedEntities["query"] == "Cold Play")
+ #expect(result.intent?.metadata["parser"] == "local-llm-sidecar-v1")
+ #expect(result.trace.provider == .localRuntime)
+ #expect(result.trace.status == .completed)
+ #expect(result.trace.metadata["local.provider"] == "ollama-sidecar")
+ }
+
@Test
func localModelTaskIntentResolverValidatesAgainstCatalogAvailability() async {
let httpClient = FakeAIHTTPClient(
diff --git a/apps/Donkey/Tests/DonkeyRuntimeTests/LocalModelRuntimeSetupTests.swift b/apps/Donkey/Tests/DonkeyRuntimeTests/LocalModelRuntimeSetupTests.swift
index acd1403b..39b7ac84 100644
--- a/apps/Donkey/Tests/DonkeyRuntimeTests/LocalModelRuntimeSetupTests.swift
+++ b/apps/Donkey/Tests/DonkeyRuntimeTests/LocalModelRuntimeSetupTests.swift
@@ -12,11 +12,13 @@ struct LocalModelRuntimeSetupTests {
let manager = try LocalModelRuntimeSetupManager(baseDirectory: root)
let instructions = manager.instructions()
- #expect(instructions.count == 3)
+ #expect(instructions.count == 4)
#expect(instructions.map(\.spec.id).contains(.parakeetTranscriber))
+ #expect(instructions.map(\.spec.id).contains(.localLLM))
#expect(instructions.first { $0.spec.id == .parakeetTranscriber }?.spec.environmentVariableName == "DONKEY_PARAKEET_TRANSCRIBER")
#expect(instructions.first { $0.spec.id == .yoloSegmenter }?.spec.environmentVariableName == "DONKEY_YOLO_SEGMENTER")
#expect(instructions.first { $0.spec.id == .uiUnderstander }?.spec.environmentVariableName == "DONKEY_UI_UNDERSTANDER")
+ #expect(instructions.first { $0.spec.id == .localLLM }?.spec.environmentVariableName == "DONKEY_LOCAL_LLM_RUNNER")
#expect(instructions.first?.spec.installSteps.first?.contains("Set Up") == true)
}
@@ -300,6 +302,43 @@ struct LocalModelRuntimeSetupTests {
#expect(report.modelID == "nvidia/parakeet-tdt-0.6b-v3")
}
+ @Test
+ func prepareModelWeightsRunsSidecarPreparationProtocol() async throws {
+ let root = temporaryDirectory()
+ let download = temporaryDirectory()
+ defer {
+ try? FileManager.default.removeItem(at: root)
+ try? FileManager.default.removeItem(at: download)
+ }
+ let executable = try makeModelPreparationExecutable(
+ root: download,
+ relativePath: "bin/donkey-ui-understander",
+ runtimeID: "ui-understander",
+ modelID: "local-ui-understander"
+ )
+ let manager = try LocalModelRuntimeSetupManager(baseDirectory: root)
+ try manager.registerExecutable(
+ runtimeID: .uiUnderstander,
+ executableURL: executable,
+ downloadedDirectory: download,
+ runtimeVersion: "1.0.0",
+ modelID: "local-ui-understander",
+ sidecarProtocolVersion: "v1",
+ metadata: [
+ "modelWeights.downloadURL": "https://example.test/ui/model.bin",
+ "modelWeights.sha256": "abc",
+ "modelWeights.filename": "ui.bin"
+ ]
+ )
+
+ let report = try await manager.prepareModelWeights(runtimeID: .uiUnderstander)
+
+ #expect(report.state == .prepared)
+ #expect(report.modelID == "local-ui-understander")
+ #expect(report.cacheDirectory?.contains("/ModelWeights/ui-understander/local-ui-understander") == true)
+ #expect(report.metadata["modelWeights.status"] == "downloaded")
+ }
+
private func makeExecutable(
root: URL,
relativePath: String
@@ -367,6 +406,36 @@ struct LocalModelRuntimeSetupTests {
return url
}
+ private func makeModelPreparationExecutable(
+ root: URL,
+ relativePath: String,
+ runtimeID: String,
+ modelID: String
+ ) throws -> URL {
+ let script = """
+ #!/bin/sh
+ REQUEST="$(cat)"
+ CACHE="$(printf '%s' "$REQUEST" | sed -n 's/.*"cacheDirectory"[[:space:]]*:[[:space:]]*"\\([^"]*\\)".*/\\1/p' | head -n 1)"
+ mkdir -p "$CACHE"
+ printf '{"status":"ok","runtimeID":"\(runtimeID)","modelID":"\(modelID)","cacheDirectory":"%s","metadata":{"modelWeights.status":"downloaded"}}' "$CACHE"
+ """
+ let url = relativePath
+ .split(separator: "/")
+ .reduce(root) { partialURL, component in
+ partialURL.appendingPathComponent(String(component), isDirectory: false)
+ }
+ try FileManager.default.createDirectory(
+ at: url.deletingLastPathComponent(),
+ withIntermediateDirectories: true
+ )
+ try Data(script.utf8).write(to: url)
+ try FileManager.default.setAttributes(
+ [.posixPermissions: 0o755],
+ ofItemAtPath: url.path
+ )
+ return url
+ }
+
private func temporaryDirectory() -> URL {
FileManager.default.temporaryDirectory
.appendingPathComponent("donkey-runtime-setup-tests-\(UUID().uuidString)", isDirectory: true)
diff --git a/docs/README.md b/docs/README.md
index 254deae4..13d2a93f 100644
--- a/docs/README.md
+++ b/docs/README.md
@@ -4,7 +4,7 @@ This folder is the product and engineering source of truth for capabilities that
Plans describe what we might build. Guides describe what Donkey currently supports and how to maintain it.
-There is an active milestone plan in `plans/master-plan.md`. It tracks the unfinished work needed before the fast local navigation and AI-harness roadmap can be considered complete: generic local-app task knowledge, local JSON/JSONL task-definition loading, installed-app/task resolution, local-model command parsing with catalog validation, local task-context intake, Accessibility control discovery and action planning, review-first document form-fill planning, Parakeet-only local voice transcription, YOLO screenshot segmentation and local UI-understanding sidecar boundaries, post-install local runtime setup without bundled model weights, semantic memory/redaction/model-observability scaffolding, local navigation, guarded input, result verification, latency reporting, and optional slow planner recovery. Weather lookup, media playback, and document form-fill are benchmark definitions for this generic system, not source-specific architectures.
+There is an active milestone plan in `plans/master-plan.md`. It tracks the unfinished work needed before the fast local navigation and AI-harness roadmap can be considered complete: generic local-app task knowledge, local JSON/JSONL task-definition loading, installed-app/task resolution, local-model command parsing with catalog validation, local task-context intake, Accessibility control discovery and action planning, review-first document form-fill planning, Parakeet-only local voice transcription, YOLO screenshot segmentation and local UI-understanding sidecar boundaries, post-install local runtime setup without bundled model weights, setup-managed command-parser LLM weight download, semantic memory/redaction/model-observability scaffolding, local navigation, guarded input, result verification, latency reporting, and optional slow planner recovery. Weather lookup, media playback, and document form-fill are benchmark definitions for this generic system, not source-specific architectures.
## Product Guides
diff --git a/docs/guides/install-donkey.md b/docs/guides/install-donkey.md
index 6031c0e9..d7966c91 100644
--- a/docs/guides/install-donkey.md
+++ b/docs/guides/install-donkey.md
@@ -16,10 +16,27 @@ To launch the packaged app:
open dist/Donkey.app
```
-The package script also creates Donkey-compatible bootstrap sidecar runtime packages under `dist/LocalRuntimePackages` and embeds them into:
+The package script also creates Donkey-compatible sidecar runner packages under `dist/LocalRuntimePackages` and embeds them into:
```text
dist/Donkey.app/Contents/Resources/LocalRuntimePackages/
```
-On first launch, Donkey shows one setup button for local runtimes. Setup installs the bundled sidecar packages first, verifies their manifests/checksums, registers them in Application Support, and health-checks them. The bundled packages do not include model weights; they are the installation surface for the sidecar runners. If setup fails, clicking the same button retries failed or not-yet-attempted runtimes while keeping completed installs.
+On first launch, Donkey shows one setup button for local runtimes. Setup installs the bundled sidecar packages first, verifies their manifests/checksums, 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.
+
+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.
+
+Configure model-weight URLs when packaging:
+
+```bash
+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
+```
+
+If a model URL/backend is missing for a file-backed sidecar, Ollama is unavailable for the local LLM sidecar, or Parakeet's local Python backend is missing, setup or runtime calls fail clearly with a retryable needs-attention state instead of pretending the runtime is usable.
diff --git a/docs/guides/minimal-run-coordinator.md b/docs/guides/minimal-run-coordinator.md
index 2e07bc69..4817fbbe 100644
--- a/docs/guides/minimal-run-coordinator.md
+++ b/docs/guides/minimal-run-coordinator.md
@@ -34,7 +34,7 @@ Donkey also supports reflex latency reports and a synthetic replay benchmark. `R
Donkey also supports the first fast local-navigation dry-run slice end to end through the dry-run reflex loop. `LocalNavigationMetadataFrameSource` can turn macOS window candidate metadata and optional browser-tab metadata supplied by callers into metadata-only hot-loop frames. `LocalNavigationDryRunPerceptionAdapter` and `LocalNavigationDryRunWorldStateProjector` keep the local-navigation path swappable while preserving the no-remote-model fallback. `LocalNavigationControllerPolicy` can choose traceable dry-run semantic actions such as `focusWindow`, `activateCandidate`, `switchTab`, `wait`, or `observe` from typed state. This slice is metadata-only and side-effect free by default; guarded live-action smoke requires an injected backend, and richer visual inference remains future work.
-Donkey also supports the first generic local-app task catalog, intent, live runner, and local task-definition loading boundary. `TaskIntent` can represent a parsed task, target app, normalized entities, parser source, confidence, and confirmation state. `LocalAppTaskDefinition` describes app-task knowledge as data: target app metadata, deterministic trigger terms, required entities and aliases, workflow steps, observation strategies, and verification rules. `LocalAppTaskDefinitionLoader` can load additional JSON or JSONL task definitions from `~/Library/Application Support/Donkey/TaskDefinitions/` and merge them with built-ins, so new use cases do not require Swift source changes. `LocalAppTaskCatalog` resolves validated intents against known task definitions, checks target-app availability through an injected provider, and exposes built-in definitions such as Weather lookup, Music playback, and PDF/document form-fill as data rather than source-specific adapters. `OllamaTaskIntentAdapter` is the supported primary command parser: it sends the user command and available task definitions to a local Ollama-compatible structured-output model, decodes a `TaskIntent`, and validates it against the catalog before execution can proceed. `LocalAppTaskIntentParser` remains a deterministic fallback and test scaffold for known commands, not the preferred command-understanding path. `LocalAppTaskAdapter` can build a target-app local-navigation metadata request, project dry-run workflow steps, emit guarded keyboard command templates, and verify observed visible text against the requested entity. `LocalAppAccessibilityControlDiscovery` can index controls and form fields from bounded Accessibility snapshots, and `MacAccessibilityActionEngineInputBackend` can execute guarded `AXPress` and `AXSetValue` commands when Accessibility is trusted, focus guard passes, and input policy allows it. `ProcessBackedLocalUIUnderstandingAdapter` can call a local JSON sidecar from `DONKEY_UI_UNDERSTANDER` for bounded screenshot/crop context and return visible text, controls, form fields, and confidence as a `LocalAppTaskObservation`; those results feed observation only and never direct input actions. `LocalAppTaskLiveRunner` can launch or focus the resolved app, prefer discovered Accessibility commands when available, fall back to guarded keyboard templates, observe visible Accessibility text when trusted, and return a final verification plan. Review-only tasks, such as document form-fill with external data, resolve into a local context snapshot and `DocumentFormFillPlanner` review plan. A user-facing document approval UI is intentionally out of scope for this slice; live form filling remains review/planning code until a separate product decision enables it.
+Donkey also supports the first generic local-app task catalog, intent, live runner, and local task-definition loading boundary. `TaskIntent` can represent a parsed task, target app, normalized entities, parser source, confidence, and confirmation state. `LocalAppTaskDefinition` describes app-task knowledge as data: target app metadata, deterministic trigger terms, required entities and aliases, workflow steps, observation strategies, and verification rules. `LocalAppTaskDefinitionLoader` can load additional JSON or JSONL task definitions from `~/Library/Application Support/Donkey/TaskDefinitions/` and merge them with built-ins, so new use cases do not require Swift source changes. `LocalAppTaskCatalog` resolves validated intents against known task definitions, checks target-app availability through an injected provider, and exposes built-in definitions such as Weather lookup, Music playback, and PDF/document form-fill as data rather than source-specific adapters. `ProcessBackedLocalLLMTaskIntentAdapter` is the submitted-command parser: it sends the user command and available task definitions to the app-managed `DONKEY_LOCAL_LLM_RUNNER` sidecar, decodes a `TaskIntent`, and validates it against the catalog before execution can proceed. `OllamaTaskIntentAdapter` remains available for adapter-level tests and compatibility, while `LocalAppTaskIntentParser` remains deterministic validator and benchmark scaffold code rather than a user-command fallback. `LocalAppTaskAdapter` can build a target-app local-navigation metadata request, project dry-run workflow steps, emit guarded keyboard command templates, and verify observed visible text against the requested entity. `LocalAppAccessibilityControlDiscovery` can index controls and form fields from bounded Accessibility snapshots, and `MacAccessibilityActionEngineInputBackend` can execute guarded `AXPress` and `AXSetValue` commands when Accessibility is trusted, focus guard passes, and input policy allows it. `ProcessBackedLocalUIUnderstandingAdapter` can call a local JSON sidecar from `DONKEY_UI_UNDERSTANDER` for bounded screenshot/crop context and return visible text, controls, form fields, and confidence as a `LocalAppTaskObservation`; those results feed observation only and never direct input actions. `LocalAppTaskLiveRunner` can launch or focus the resolved app, prefer discovered Accessibility commands when available, fall back to guarded keyboard templates, observe visible Accessibility text when trusted, include bounded screenshot understanding context when configured, and return a final verification plan. Review-only tasks, such as document form-fill with external data, resolve into a local context snapshot and `DocumentFormFillPlanner` review plan. A user-facing document approval UI is intentionally out of scope for this slice; live form filling remains review/planning code until a separate product decision enables it.
Donkey also supports a guarded live-action smoke boundary for local-navigation behavior. `GuardedLiveActionSmokeRunner` requires an end-to-end dry-run result, a latency report with p95 evidence, a non-fallback latest action, explicit input policy allowance, and a passing action-engine focus guard before mapping semantic local-navigation actions to typed action-engine commands. The smoke path records replayable action traces and can execute only through an injected backend.
@@ -44,11 +44,11 @@ Donkey also supports the first slow-planner sidecar beside the dry-run reflex lo
Donkey also supports the first AI harness model registry and router boundary. `AIModelRegistry` stores model roles, providers, literal model ids, endpoints, capabilities, timeouts, prompt versions, eval status, docs URLs, and rollback ids as registry data. `AIModelRouter` routes slow-path jobs by job type, risk, privacy mode, latency tolerance, capabilities, failed-model history, and allowed providers. Privacy-sensitive planner routes prefer local Ollama-compatible entries when they are available. Privacy-sensitive voice-transcription routes prefer local runtime entries and select NVIDIA Parakeet TDT 0.6B v3 only; Whisper fallback has been removed. `ProcessBackedParakeetTranscriptionRuntime` calls a local JSON stdin/stdout sidecar from `DONKEY_PARAKEET_TRANSCRIBER`, and missing configuration or nonzero exits fail clearly instead of silently falling back. `LocalVoiceTranscriptionAdapter` accepts bounded local audio buffers, routes to the selected local runtime model, returns transcript text plus timing/confidence trace metadata, and marks transcripts as inputs to the normal command parser rather than actions. Literal provider model ids should stay in registry entries, not planner/controller logic.
-Donkey also supports a reusable local JSON sidecar runner for local model processes. `ProcessBackedLocalJSONSidecarRunner` reads executable paths from environment variables first, then from Donkey's app-managed local runtime registry, validates executability, sends request JSON on stdin, captures stdout/stderr, records exit status and latency metadata, and returns explicit unavailable or failed statuses. Current model sidecars use `DONKEY_YOLO_SEGMENTER`, `DONKEY_PARAKEET_TRANSCRIBER`, and `DONKEY_UI_UNDERSTANDER`.
+Donkey also supports a reusable local JSON sidecar runner for local model processes. `ProcessBackedLocalJSONSidecarRunner` reads executable paths from environment variables first, then from Donkey's app-managed local runtime registry, validates executability, sends request JSON on stdin, captures stdout/stderr, records exit status and latency metadata, and returns explicit unavailable or failed statuses. Current model sidecars use `DONKEY_LOCAL_LLM_RUNNER`, `DONKEY_YOLO_SEGMENTER`, `DONKEY_PARAKEET_TRANSCRIBER`, and `DONKEY_UI_UNDERSTANDER`. Submitted pointer-prompt commands parse through the local LLM sidecar and validated `TaskIntent` schema; the deterministic parser remains available as a validator and benchmark utility, not as the submitted-command fallback.
-Donkey's live local-app observation path uses Accessibility and bounded screenshots only. `MacLocalAppTaskController` first reads Accessibility controls and visible text when trusted. If required controls or verification text are missing, it 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 never emits direct input actions.
+Donkey'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 bootstrap sidecar runtime packages and embeds them in `Donkey.app/Contents/Resources/LocalRuntimePackages/`. `LocalModelRuntimeSetupManager` describes the required Parakeet, YOLO26, and UI-understanding 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, caches verified package files under Application Support, and records executable paths in `~/Library/Application Support/Donkey/LocalModelRuntimes/runtime-installations.json`. 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, 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. Developer launch arguments can print setup instructions, show install status, or register a downloaded runtime folder.
+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. `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, 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 prepares Ollama weights by pulling `qwen3:8b` by default; the Parakeet runner can prepare a Hugging Face snapshot and calls NVIDIA NeMo for transcription when available; YOLO and UI-understanding packages expose the same protocol and explicit backend-missing states. 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. Developer launch arguments can print setup instructions, show install status, 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.
@@ -109,7 +109,7 @@ This is a coordination, in-memory reflex trace, hot-loop contract, deterministic
- Use monotonic timestamps for latency math. Wall-clock timestamps are for human labels and trace correlation only.
- Use latency reports for any p50/p95/p99 claim. Reports should include dropped frames, stale actions, tick rates, and worst traces.
- Keep local-navigation decisions typed and side-effect free until the guarded live-action slice. Metadata projectors may use window, browser-tab, and Accessibility facts when available, but controllers should emit semantic actions only.
-- Keep local-model task intents separate from planner hints. A supported local command should first parse to a validated `TaskIntent` through the local Ollama-compatible command parser; deterministic parsing is only a fallback/validator path, and slow planner output may only help app-knowledge lookup or recovery after validation.
+- Keep local-model task intents separate from planner hints. A supported local command should first parse to a validated `TaskIntent` through the app-managed local LLM sidecar; deterministic parsing is only validator/benchmark support, and slow planner output may only help app-knowledge lookup or recovery after validation.
- Keep local-app task adapter output inspectable before live control. Dry-run steps should show the normalized entities, target app identity, observation boundary, guarded command templates, and verification status before the live runner is allowed to launch, focus, type, or submit.
- Keep local task definitions data-driven. Built-ins are examples; local JSON/JSONL definitions in Application Support are the extension point for more apps and workflows.
- Keep document form filling review-first. Field detection, data mapping, proposed values, unmapped required fields, unused data keys, and approval IDs must be inspectable before any live fill action is enabled.
@@ -139,7 +139,7 @@ From `apps/Donkey/`:
swift test
```
-The runtime tests should cover lifecycle ordering, abort and timeout safety, latest-session queue drops, tool permission denial, event-store ordering, context compaction, reflex trace latency math, bounded in-memory reflex trace retention, reflex event publication, hot-loop contract Codable round trips, coordinate conversion, stale-signal marking, deterministic dry-run trace publication, queue-depth-1 dropped-frame counting, bounded target-window frame capture, target-frame safety and overlap refusal, target-frame no-artifact/no-encoding metadata, cheap perception signal projection, recorded off-the-shelf vision evidence projection, screenshot segmentation model-candidate selection, YOLO sidecar decoding and unavailable states, local UI-understanding observation decoding, local runtime setup instructions/status/registration, manifest-backed runtime download, checksum/signature enforcement, managed package cache install, health recheck, app-managed sidecar executable resolution, controller confidence/staleness fallback, controller p95 replay timing under 20ms, local-navigation metadata projection and action selection, local-navigation browser-tab metadata projection, loop-integrated local-navigation dry-run action selection, local-model task intent request shaping and validation, deterministic local-app task parsing fallback and alias expansion, local task-definition loading, local-app catalog resolution and app availability checks, local task-context intake, Accessibility control discovery, document form-fill review planning, local-app navigation request construction, generic dry-run step projection, guarded keyboard and Accessibility command templates, observed visible-text verification, guarded local-navigation live-smoke gating and trace evidence, abort/timeout release traces, slow-planner trigger/snapshot/validated-hint publication, planner-latency isolation from reflex reports, action-engine permission/focus/rate/hold/release guardrails, latency report percentiles, component latency fields, replay benchmark formatting, planner hint validation/expiry/latest-selection, model registry routing, Parakeet-only local voice-transcription routing, Parakeet sidecar decoding and unavailable states, local JSON sidecar missing-env/nonzero-exit states, OpenAI Responses request shaping and failure handling, semantic memory retrieval, remote-bound redaction, model-call observability, provider-decoded memory proposal approval, memory approval/storage/list/delete/context snapshots, replay/eval metric aggregation and model update checklist fields, artifact path validation, trace folder layout, JSONL event persistence, summary updates, deterministic window resolver behavior through fixture providers, candidate-list label snapshots, screenshot artifact metadata, bounded Accessibility serialization, missing Accessibility trust partial events, unsafe target refusal, overlap-sensitive capture refusal, manual capture event ordering through persisted coordinator events, and debug launch-argument parsing/formatting.
+The runtime tests should cover lifecycle ordering, abort and timeout safety, latest-session queue drops, tool permission denial, event-store ordering, context compaction, reflex trace latency math, bounded in-memory reflex trace retention, reflex event publication, hot-loop contract Codable round trips, coordinate conversion, stale-signal marking, deterministic dry-run trace publication, queue-depth-1 dropped-frame counting, bounded target-window frame capture, target-frame safety and overlap refusal, target-frame no-artifact/no-encoding metadata, cheap perception signal projection, recorded off-the-shelf vision evidence projection, screenshot segmentation model-candidate selection, YOLO sidecar decoding and unavailable states, local UI-understanding observation decoding, local runtime setup instructions/status/registration, manifest-backed runtime download, checksum/signature enforcement, managed package cache install, health recheck, app-managed sidecar executable resolution, controller confidence/staleness fallback, controller p95 replay timing under 20ms, local-navigation metadata projection and action selection, local-navigation browser-tab metadata projection, loop-integrated local-navigation dry-run action selection, local-model task intent request shaping and validation, deterministic local-app task parser validation and alias expansion, local task-definition loading, local-app catalog resolution and app availability checks, local task-context intake, Accessibility control discovery, document form-fill review planning, local-app navigation request construction, generic dry-run step projection, guarded keyboard and Accessibility command templates, observed visible-text verification, guarded local-navigation live-smoke gating and trace evidence, abort/timeout release traces, slow-planner trigger/snapshot/validated-hint publication, planner-latency isolation from reflex reports, action-engine permission/focus/rate/hold/release guardrails, latency report percentiles, component latency fields, replay benchmark formatting, planner hint validation/expiry/latest-selection, model registry routing, Parakeet-only local voice-transcription routing, Parakeet sidecar decoding and unavailable states, local JSON sidecar missing-env/nonzero-exit states, OpenAI Responses request shaping and failure handling, semantic memory retrieval, remote-bound redaction, model-call observability, provider-decoded memory proposal approval, memory approval/storage/list/delete/context snapshots, replay/eval metric aggregation and model update checklist fields, artifact path validation, trace folder layout, JSONL event persistence, summary updates, deterministic window resolver behavior through fixture providers, candidate-list label snapshots, screenshot artifact metadata, bounded Accessibility serialization, missing Accessibility trust partial events, unsafe target refusal, overlap-sensitive capture refusal, manual capture event ordering through persisted coordinator events, and debug launch-argument parsing/formatting.
Manual smoke commands:
diff --git a/plans/22-local-runtime-onboarding.md b/plans/22-local-runtime-onboarding.md
index 088e4b90..e444db74 100644
--- a/plans/22-local-runtime-onboarding.md
+++ b/plans/22-local-runtime-onboarding.md
@@ -157,8 +157,11 @@ Already supported:
- `LocalModelRuntimeSetupManager` runtime specs, setup instructions, registration, status, and app-managed executable resolution.
- First-run local runtime setup window with one setup button that drives download, validation, install, registration, and health checks.
-- Package-time bundled bootstrap sidecar runtime packages embedded under `Donkey.app/Contents/Resources/LocalRuntimePackages/`.
+- Package-time bundled sidecar runner packages embedded under `Donkey.app/Contents/Resources/LocalRuntimePackages/`.
+- Shared packaged runner entrypoint for local LLM, Parakeet, YOLO, and UI-understanding sidecars, with real backend hooks and explicit missing-backend states instead of hardcoded fake runtime output.
- Setup manager installation from bundled package manifests before remote manifest download.
+- Setup-time `prepareModelWeights` sidecar operation that downloads/caches configured model files into Application Support before health checks.
+- Setup-managed `local-llm` sidecar for the command parser; it pulls `qwen3:8b` through Ollama by default and submitted commands route through this sidecar.
- Manifest-backed package download and managed cache install under Application Support.
- SHA-256 package file validation and required signature metadata.
- Sidecar health-check protocol through the existing JSON process runner.
@@ -170,7 +173,7 @@ Already supported:
Still needed:
-- Replace bootstrap sidecar packages with real model-weight runner packages.
+- Package or bootstrap the remaining local backend dependencies behind the one setup button: NVIDIA NeMo/Python for Parakeet, Ultralytics-compatible execution for YOLO, a real local UI-understanding backend, and either an accepted Ollama prerequisite or a self-contained local LLM runner.
- Finalize cryptographic signature verification with release signing keys.
- Settings-menu entry to reopen the setup window after first launch.
- Behind-the-scenes upgrade/repair/remove flows.
diff --git a/plans/master-plan.md b/plans/master-plan.md
index 2889eabb..ee436894 100644
--- a/plans/master-plan.md
+++ b/plans/master-plan.md
@@ -56,16 +56,16 @@ The normal Weather benchmark path should work without a remote model call. A tin
## Supported Boundary
-- Runtime shell: minimal run coordination, ordered events, bounded context assembly, local run artifacts, manual target context capture, first-run local runtime setup UI, package-time bundled bootstrap sidecar runtime packages, manifest-backed runtime install/download/cache/registration in Application Support, sidecar health recheck, in-memory reflex trace retention, and stage-split latency reports are supported.
-- Fast navigation hot path: typed frame/world-state/action contracts, deterministic dry-run loop, bounded target-window frame source, cheap metadata perception, recorded off-the-shelf detector/template/OCR/segmentation evidence projection, screenshot segmentation model-candidate catalog and runner boundary with Ultralytics YOLO26 nano segmentation (`yolo26n-seg.pt`), process-backed YOLO sidecar decoding through `DONKEY_YOLO_SEGMENTER` or app-managed runtime registration, local UI-understanding sidecar decoding through `DONKEY_UI_UNDERSTANDER` or app-managed runtime registration, swappable world-state projection, deterministic controller, loop-integrated metadata-only local-navigation dry-run action selection, optional caller-supplied browser-tab metadata, dry-run action projection, generic local-app task intent contracts, data-driven task definitions, local JSON/JSONL task-definition loading, Ollama-compatible local-model command parsing to validated `TaskIntent`, deterministic parsing as fallback/validator, catalog command resolution, target-app availability checks, local task-context intake, Accessibility control discovery, document form-fill review planning, generic dry-run task adaptation, local-navigation request construction, step projection, guarded keyboard and Accessibility command templates, macOS app launch/focus, guarded macOS keyboard input, guarded `AXPress`/`AXSetValue` backend, pointer-prompt typed command submission, Accessibility visible-text observation when trusted, bounded screenshot UI-understanding observation when Accessibility is insufficient, visible-text verification, component latency reporting, and built-in task definitions for Weather lookup, media playback, and document form-fill are supported. This is not yet a complete live fast-navigation agent: model binaries are user-downloaded after app install rather than bundled, and there is no manually verified live command-to-result Weather trace yet.
+- Runtime shell: minimal run coordination, ordered events, bounded context assembly, local run artifacts, manual target context capture, first-run local runtime setup UI, package-time bundled sidecar runner packages, manifest-backed runtime install/download/cache/registration in Application Support, sidecar health recheck, in-memory reflex trace retention, and stage-split latency reports are supported.
+- Fast navigation hot path: typed frame/world-state/action contracts, deterministic dry-run loop, bounded target-window frame source, cheap metadata perception, recorded off-the-shelf detector/template/OCR/segmentation evidence projection, screenshot segmentation model-candidate catalog and runner boundary with Ultralytics YOLO26 nano segmentation (`yolo26n-seg.pt`), process-backed YOLO sidecar decoding through `DONKEY_YOLO_SEGMENTER` or app-managed runtime registration, local UI-understanding sidecar decoding through `DONKEY_UI_UNDERSTANDER` or app-managed runtime registration, swappable world-state projection, deterministic controller, loop-integrated metadata-only local-navigation dry-run action selection, optional caller-supplied browser-tab metadata, dry-run action projection, generic local-app task intent contracts, data-driven task definitions, local JSON/JSONL task-definition loading, local-LLM sidecar command parsing to validated `TaskIntent`, deterministic parsing as validator/benchmark code, catalog command resolution, target-app availability checks, local task-context intake, Accessibility control discovery, document form-fill review planning, generic dry-run task adaptation, local-navigation request construction, step projection, guarded keyboard and Accessibility command templates, macOS app launch/focus, guarded macOS keyboard input, guarded `AXPress`/`AXSetValue` backend, pointer-prompt typed command submission, Accessibility visible-text observation when trusted, bounded screenshot UI-understanding observation captured as parallel observation context when configured, visible-text verification, background component latency reporting, and built-in task definitions for Weather lookup, media playback, and document form-fill are supported. This is not yet a complete live fast-navigation agent: model weights and local backend dependencies are user-downloaded/prepared after app install rather than bundled.
- Safety boundary: action-engine command contracts, permission/focus/rate/hold/release guardrails, guarded live-action smoke with injected backends, the narrow macOS keyboard backend for local-app tasks, the narrow macOS Accessibility backend for discovered nodes, and replayable command traces are supported.
-- Slow AI boundary: local-model task-intent parsing, Parakeet-only local voice-transcription model routing and process-backed sidecar tracing through `DONKEY_PARAKEET_TRANSCRIBER` or app-managed runtime registration, pointer-prompt microphone buffers feeding the Parakeet runtime before command parsing, structured planner hints, validation/expiry/latest-valid selection, loop-adjacent slow-planner trigger/snapshot sidecar, model registry/router, OpenAI Responses and Ollama-compatible planner adapters, provider-backed local/online planner fallback, source-linked memory, bounded semantic memory retrieval contracts, remote-bound redaction hooks, aggregate model-call observability reports, provider-decoded memory proposal handling through the deterministic approver, and replay/eval scaffolding are supported as optional sidecar pieces. NVIDIA Parakeet TDT 0.6B v3 is the selected local voice-transcription default with no Whisper fallback. This is not yet the complete AI harness because live sidecar binaries still need machine-local installation/benchmark evidence.
+- Slow AI boundary: local-model task-intent parsing, Parakeet-only local voice-transcription model routing and process-backed sidecar tracing through `DONKEY_PARAKEET_TRANSCRIBER` or app-managed runtime registration, pointer-prompt microphone buffers feeding the Parakeet runtime before command parsing, structured planner hints, validation/expiry/latest-valid selection, loop-adjacent slow-planner trigger/snapshot sidecar, model registry/router, OpenAI Responses and Ollama-compatible planner adapters, provider-backed local/online planner fallback, source-linked memory, bounded semantic memory retrieval contracts, remote-bound redaction hooks, aggregate model-call observability reports, provider-decoded memory proposal handling through the deterministic approver, and replay/eval scaffolding are supported as optional sidecar pieces. NVIDIA Parakeet TDT 0.6B v3 is the selected local voice-transcription default with no Whisper fallback. This is not yet the complete AI harness because Parakeet/YOLO/UI-understanding backend dependency packaging still needs product hardening.
- Source of truth: detailed supported behavior lives in `docs/guides/minimal-run-coordinator.md`; active unfinished work lives in this plan and its primary/supporting plans.
## Non-Negotiable Rules
- No remote model call, chat LLM call, or general VLM call may be required for a reflex tick.
-- Common app commands must prefer deterministic or local intent parsing before remote planning.
+- Common app commands must use local intent parsing before remote planning; deterministic parsing is validator/benchmark support, not the submitted-command fallback.
- The reflex path uses latest-frame-wins queues; stale frames are dropped and counted.
- The controller consumes typed world state, not raw screenshots.
- The action engine owns OS input; controller policies emit semantic commands only.
@@ -82,16 +82,16 @@ Recent commits completed these pieces:
- `0e21088`: OpenAI Responses adapter, planner hint contracts, model registry/router scaffolding.
- `9bebfbb`: slow-planner sidecar trigger/snapshot/hint bus and guarded live-action smoke boundary.
- recent slice: Ollama-compatible local planner adapter, provider-backed local/online slow planner fallback, and explicit slow-planner completion tests.
-- current slice: generic local-app task catalog, local-model command parser, deterministic fallback parser, app availability check, and dry-run adapter boundary, with Weather lookup represented as built-in benchmark data.
+- current slice: generic local-app task catalog, local-model command parser, deterministic parser validator, app availability check, and dry-run adapter boundary, with Weather lookup represented as built-in benchmark data.
- `d6e48c9`: archived plans, which was premature for this milestone.
-The code now includes the first generic local-app task catalog, local JSON/JSONL task-definition loader, local task context provider, Accessibility control discovery/action planning, document form-fill review planner, Ollama-compatible local-model command parser, deterministic fallback parser, app availability check, dry-run adapter boundary, local-app live runner, macOS launch/focus, keyboard-input and Accessibility-input backends, pointer-prompt typed and voice command wiring, sample app-task definitions across weather/media/document domains, YOLO26 screenshot segmentation model-candidate metadata and process-backed sidecar backend, local UI-understanding sidecar adapter wired into live observation over bounded screenshots, Parakeet-only local voice-transcription routing and sidecar runtime, shared JSON sidecar runner, first-run local runtime setup UI, package-time bundled bootstrap sidecar runtime packages, manifest-backed runtime install/download/cache/registration, checksum/signature metadata enforcement, sidecar health recheck, semantic memory retrieval contracts, redaction hooks, aggregate model-call observability, provider-decoded memory proposal handling, expanded latency reporting, and a package script that produces `dist/Donkey.app`. It does not yet include real model-weight runner packages or a manually verified live command-to-result Weather trace.
+The code now includes the first generic local-app task catalog, local JSON/JSONL task-definition loader, local task context provider, Accessibility control discovery/action planning, document form-fill review planner, local-LLM sidecar command parser, deterministic parser retained as validator/benchmark code, app availability check, dry-run adapter boundary, local-app live runner, macOS launch/focus, keyboard-input and Accessibility-input backends, pointer-prompt typed and voice command wiring, sample app-task definitions across weather/media/document domains, YOLO26 screenshot segmentation model-candidate metadata and process-backed sidecar backend, local UI-understanding sidecar adapter wired into live observation over bounded screenshots, Parakeet-only local voice-transcription routing and sidecar runtime, shared JSON sidecar runner, first-run local runtime setup UI, package-time bundled sidecar runner packages, setup-time model-weight download/cache operation including Ollama `qwen3:8b` for the local command-parser LLM, manifest-backed runtime install/download/cache/registration, checksum/signature metadata enforcement, sidecar health recheck, semantic memory retrieval contracts, redaction hooks, aggregate model-call observability, provider-decoded memory proposal handling, expanded latency reporting, and a package script that produces `dist/Donkey.app`. It does not yet include fully bundled Python/native backend environments for Parakeet, YOLO, and UI understanding, real UI-understanding model internals, a self-contained non-Ollama LLM runner, or release-key cryptographic signature verification.
## What Should Be Done Next
-1. Replace the bundled bootstrap sidecar packages with real model-weight runner packages, finalize release-key cryptographic signature verification, keep first-run setup to one app-managed button, add behind-the-scenes repair/remove flows, then run real machine-local sidecar binaries registered by the app-managed installer for YOLO, Parakeet, and UI understanding.
-2. Manually verify the packaged app from `dist/Donkey.app` on the first Weather command path, then record the live command-to-result trace and stage metrics.
-3. Record metric samples for weather/media/document tasks using the existing metadata fields for command parse, launch/focus, observation, Accessibility action, keyboard action, verification, YOLO segmentation, UI-understanding, and Parakeet transcription. Improve benchmarking later.
+1. Package or bootstrap the remaining local backend dependencies behind the one setup button: Parakeet needs its local NVIDIA NeMo/Python backend, YOLO needs an Ultralytics-compatible backend and model cache, UI understanding needs a real local model backend, and the command-parser LLM needs either an accepted Ollama prerequisite or a self-contained runner.
+2. Finalize release-key cryptographic signature verification, add behind-the-scenes repair/remove flows, and keep setup retryable without exposing per-runtime customization.
+3. Keep metric collection as background system behavior using the existing metadata fields for command parse, launch/focus, observation, Accessibility action, keyboard action, verification, YOLO segmentation, UI-understanding, and Parakeet transcription.
4. Keep the current dry-run/guarded-live safety boundary: local or online LLM output can only become validated intent, task definitions, app-knowledge updates, observation summaries, transcripts, memory proposals, or planner hints, never direct input.
## Completion Gates