Open source CapCut alternative.
TypeScript
Add harness agent path visualization
David Leb4bb34f8d01c
diff --git a/apps/Donkey/Sources/Donkey/UserQuerySpawnOverlayController.swift b/apps/Donkey/Sources/Donkey/UserQuerySpawnOverlayController.swiftindex 9a182685..bba63835 100644--- a/apps/Donkey/Sources/Donkey/UserQuerySpawnOverlayController.swift+++ b/apps/Donkey/Sources/Donkey/UserQuerySpawnOverlayController.swift@@ -352,7 +352,9 @@ final class UserQuerySpawnOverlayController {private func animateSurfaceTravel(_ surface: UserQuerySpawnSurface,to destination: CGPoint,- on screen: NSScreen+ on screen: NSScreen,+ preRotateDuration: TimeInterval = 0,+ travelDuration: TimeInterval = UserQuerySpawnOverlayViewModel.travelDuration) {surface.travelWorkItem?.cancel()surface.screen = screen@@ -380,10 +382,18 @@ final class UserQuerySpawnOverlayController {on: screen)- NSAnimationContext.runAnimationGroup { context in- context.duration = UserQuerySpawnOverlayViewModel.travelDuration- context.timingFunction = CAMediaTimingFunction(controlPoints: 0.45, 0.05, 0.3, 1)- surface.panel.animator().setFrame(destinationGlobalFrame, display: true)+ let startTravel = DispatchWorkItem { [weak surface] in+ guard let surface else { return }+ NSAnimationContext.runAnimationGroup { context in+ context.duration = travelDuration+ context.timingFunction = CAMediaTimingFunction(controlPoints: 0.45, 0.05, 0.3, 1)+ surface.panel.animator().setFrame(destinationGlobalFrame, display: true)+ }+ }+ if preRotateDuration > 0 {+ DispatchQueue.main.asyncAfter(deadline: .now() + preRotateDuration, execute: startTravel)+ } else {+ startTravel.perform()}let workItem = DispatchWorkItem { [weak self, weak surface] in@@ -402,7 +412,7 @@ final class UserQuerySpawnOverlayController {}surface.travelWorkItem = workItemDispatchQueue.main.asyncAfter(- deadline: .now() + UserQuerySpawnOverlayViewModel.travelDuration + 0.03,+ deadline: .now() + preRotateDuration + travelDuration + 0.03,execute: workItem)updateMouseEventPassthrough(for: surface)@@ -436,7 +446,7 @@ final class UserQuerySpawnOverlayController {}surface.guideWorkItems.append(workItem)DispatchQueue.main.asyncAfter(deadline: .now() + delay, execute: workItem)- delay += UserQuerySpawnOverlayViewModel.travelDuration + step.holdDuration+ delay += step.preRotateDuration + step.travelDuration + step.holdDuration}let completionWorkItem = DispatchWorkItem { [weak self, weak surface] in@@ -480,9 +490,17 @@ final class UserQuerySpawnOverlayController {surface.viewModel.update(state: state,destination: destination,- screenSize: screen.frame.size+ screenSize: screen.frame.size,+ preRotateDuration: step.preRotateDuration,+ travelDuration: step.travelDuration+ )+ animateSurfaceTravel(+ surface,+ to: destination,+ on: screen,+ preRotateDuration: step.preRotateDuration,+ travelDuration: step.travelDuration)- animateSurfaceTravel(surface, to: destination, on: screen)}private func guideDestination(diff --git a/apps/Donkey/Sources/DonkeyContracts/AgentPathTraceContracts.swift b/apps/Donkey/Sources/DonkeyContracts/AgentPathTraceContracts.swiftnew file mode 100644index 00000000..629c459d--- /dev/null+++ b/apps/Donkey/Sources/DonkeyContracts/AgentPathTraceContracts.swift@@ -0,0 +1,215 @@+import Foundation++public enum AgentPathStepKind: String, Codable, Equatable, Sendable {+ case plan+ case navigateApp+ case observe+ case targetControl+ case act+ case verify+ case recover+}++public enum AgentPathStepStatus: String, Codable, Equatable, Sendable {+ case planned+ case observed+ case executed+ case verified+ case blocked+ case skipped+}++public struct AgentPathStep: Codable, Equatable, Sendable, Identifiable {+ public var id: String+ public var phaseID: String+ public var kind: AgentPathStepKind+ public var label: String+ public var targetApp: String?+ public var bundleIdentifier: String?+ public var windowID: String?+ public var point: HotLoopPoint?+ public var bounds: HotLoopRect?+ public var controlID: String?+ public var source: AgentVisualizationGroundingSource+ public var status: AgentPathStepStatus+ public var travelDuration: TimeInterval+ public var holdDuration: TimeInterval+ public var preRotateDuration: TimeInterval+ public var metadata: [String: String]++ public init(+ id: String = UUID().uuidString,+ phaseID: String = "",+ kind: AgentPathStepKind,+ label: String,+ targetApp: String? = nil,+ bundleIdentifier: String? = nil,+ windowID: String? = nil,+ point: HotLoopPoint? = nil,+ bounds: HotLoopRect? = nil,+ controlID: String? = nil,+ source: AgentVisualizationGroundingSource,+ status: AgentPathStepStatus = .planned,+ travelDuration: TimeInterval = 0.9,+ holdDuration: TimeInterval = 1.2,+ preRotateDuration: TimeInterval = 0.12,+ metadata: [String: String] = [:]+ ) {+ self.id = id+ self.phaseID = phaseID+ self.kind = kind+ self.label = label+ self.targetApp = targetApp+ self.bundleIdentifier = bundleIdentifier+ self.windowID = windowID+ self.point = point+ self.bounds = bounds+ self.controlID = controlID+ self.source = source+ self.status = status+ self.travelDuration = max(0.1, travelDuration)+ self.holdDuration = max(0.4, holdDuration)+ self.preRotateDuration = min(max(preRotateDuration, 0), 0.6)+ self.metadata = metadata+ }++ public var hasGroundedTarget: Bool {+ if let point, point.space == .normalizedTarget { return true }+ if let bounds, bounds.space == .normalizedTarget, bounds.hasPositiveArea { return true }+ return false+ }+}++public struct AgentPathTrace: Codable, Equatable, Sendable, Identifiable {+ public var id: String+ public var taskID: String+ public var title: String+ public var sourceTraceID: String+ public var steps: [AgentPathStep]+ public var metadata: [String: String]++ public init(+ id: String = UUID().uuidString,+ taskID: String,+ title: String,+ sourceTraceID: String,+ steps: [AgentPathStep],+ metadata: [String: String] = [:]+ ) {+ self.id = id+ self.taskID = taskID+ self.title = title+ self.sourceTraceID = sourceTraceID+ self.steps = steps+ self.metadata = metadata+ }++ public var groundedSteps: [AgentPathStep] {+ steps.filter(\.hasGroundedTarget)+ }++ public func visualizationPlan() -> AgentVisualizationPlan? {+ let visualSteps = groundedSteps.map { step in+ AgentVisualizationStep(+ id: step.id,+ kind: step.visualizationKind,+ label: step.label,+ target: AgentVisualizationStepTarget(+ point: step.point,+ bounds: step.bounds,+ description: step.label,+ controlID: step.controlID,+ source: step.source,+ confidence: step.visualizationConfidence,+ metadata: step.visualizationMetadata+ ),+ travelDuration: step.travelDuration,+ holdDuration: step.holdDuration,+ metadata: step.visualizationMetadata+ )+ }+ guard !visualSteps.isEmpty else { return nil }++ return AgentVisualizationPlan(+ id: "agent-path-\(id)",+ title: title,+ executionMode: .live,+ sourceTraceID: sourceTraceID,+ steps: visualSteps,+ verification: AgentVisualizationVerificationReport(+ status: steps.contains { $0.status == .blocked } ? .blocked : .unverified,+ summary: "Agent path trace contains \(visualSteps.count) grounded step(s).",+ confidence: visualSteps.isEmpty ? 0 : 0.9,+ evidenceCount: visualSteps.count,+ metadata: [+ "agentPath.traceID": id,+ "agentPath.stepCount": String(steps.count),+ "agentPath.groundedStepCount": String(visualSteps.count)+ ]+ ),+ metadata: metadata.merging([+ "source": "agent-path-trace",+ "agentPath.traceID": id,+ "agentPath.taskID": taskID,+ "agentPath.stepCount": String(steps.count),+ "agentPath.groundedStepCount": String(visualSteps.count),+ "realPointerMoved": "false",+ "cursorGuideEligible": "true"+ ]) { current, _ in current }+ )+ }+}++private extension AgentPathStep {+ var visualizationKind: AgentVisualizationStepKind {+ switch kind {+ case .plan:+ return .plan+ case .navigateApp:+ return .navigate+ case .observe:+ return .observe+ case .targetControl:+ return .focusControl+ case .act:+ return .moveToTarget+ case .verify:+ return .verify+ case .recover:+ return .recover+ }+ }++ var visualizationConfidence: Double {+ switch status {+ case .verified, .executed:+ return 0.95+ case .observed:+ return 0.9+ case .planned:+ return 0.78+ case .skipped:+ return 0.35+ case .blocked:+ return 0.2+ }+ }++ var visualizationMetadata: [String: String] {+ var values = metadata.merging([+ "agentPath.phaseID": phaseID,+ "agentPath.kind": kind.rawValue,+ "agentPath.status": status.rawValue,+ "agentPath.source": source.rawValue,+ "targetApp": targetApp ?? "",+ "bundleIdentifier": bundleIdentifier ?? "",+ "windowID": windowID ?? "",+ "realPointerMoved": "false",+ "preRotateDuration": String(preRotateDuration)+ ]) { current, _ in current }+ if let controlID {+ values["controlID"] = controlID+ }+ return values+ }+}diff --git a/apps/Donkey/Sources/DonkeyContracts/AgentVisualizationContracts.swift b/apps/Donkey/Sources/DonkeyContracts/AgentVisualizationContracts.swiftindex 8a3fb087..02bb6851 100644--- a/apps/Donkey/Sources/DonkeyContracts/AgentVisualizationContracts.swift+++ b/apps/Donkey/Sources/DonkeyContracts/AgentVisualizationContracts.swift@@ -156,6 +156,7 @@ public struct AgentVisualizationPlan: Codable, Equatable, Sendable, Identifiableid: step.id,label: step.label,target: target,+ preRotateDuration: Self.preRotateDuration(for: step),travelDuration: step.travelDuration,holdDuration: step.holdDuration,metadata: cursorStepMetadata(for: step)@@ -214,4 +215,11 @@ public struct AgentVisualizationPlan: Codable, Equatable, Sendable, Identifiable}return metadata}++ private static func preRotateDuration(for step: AgentVisualizationStep) -> TimeInterval {+ guard let value = Double(step.metadata["preRotateDuration"] ?? "") else {+ return 0.12+ }+ return min(max(value, 0), 0.6)+ }}diff --git a/apps/Donkey/Sources/DonkeyContracts/AgentVisualizationCursorPathSampler.swift b/apps/Donkey/Sources/DonkeyContracts/AgentVisualizationCursorPathSampler.swiftindex 89f78461..fe518be4 100644--- a/apps/Donkey/Sources/DonkeyContracts/AgentVisualizationCursorPathSampler.swift+++ b/apps/Donkey/Sources/DonkeyContracts/AgentVisualizationCursorPathSampler.swift@@ -3,6 +3,7 @@ import Foundationpublic enum AgentVisualizationCursorPathPhase: String, Codable, Equatable, Sendable {case idle+ case preRotatecase travelcase holdcase complete@@ -73,14 +74,35 @@ public enum AgentVisualizationCursorPathSampler {var remaining = elapsedvar origin = point(request.origin, in: screenSize)+ var previousAngle: Double = 0for (index, step) in request.steps.enumerated() {let target = point(step.target, metadata: step.metadata, screenFrame: screenFrame)+ let travelAngle = angle(from: origin, to: target)+ if step.preRotateDuration > 0,+ remaining <= step.preRotateDuration {+ let linearProgress = min(max(remaining / step.preRotateDuration, 0), 1)+ let easedProgress = eased(linearProgress)+ return AgentVisualizationCursorPathSample(+ position: origin,+ angle: interpolatedAngle(from: previousAngle, to: travelAngle, progress: easedProgress),+ visibleLabel: "",+ isHolding: false,+ phase: .preRotate,+ stepIndex: index,+ stepID: step.id,+ elapsedInPhase: max(0, remaining),+ linearProgress: linearProgress,+ easedProgress: easedProgress+ )+ }++ remaining -= step.preRotateDurationif remaining <= step.travelDuration {let linearProgress = min(max(remaining / step.travelDuration, 0), 1)let easedProgress = eased(linearProgress)return AgentVisualizationCursorPathSample(position: curvedPoint(from: origin, to: target, progress: easedProgress),- angle: angle(from: origin, to: target),+ angle: travelAngle,visibleLabel: "",isHolding: false,phase: .travel,@@ -97,7 +119,7 @@ public enum AgentVisualizationCursorPathSampler {let wobble = sin(remaining * 8) * 1.8return AgentVisualizationCursorPathSample(position: CGPoint(x: target.x + wobble, y: target.y),- angle: angle(from: origin, to: target),+ angle: travelAngle,visibleLabel: step.label,isHolding: true,phase: .hold,@@ -113,6 +135,7 @@ public enum AgentVisualizationCursorPathSampler {}remaining -= step.holdDuration+ previousAngle = travelAngleorigin = target}@@ -190,6 +213,18 @@ public enum AgentVisualizationCursorPathSampler {return 1 - pow(1 - t, 3)}+ public static func interpolatedAngle(+ from origin: Double,+ to target: Double,+ progress: Double+ ) -> Double {+ let clampedProgress = min(max(progress, 0), 1)+ var delta = target - origin+ while delta > 180 { delta -= 360 }+ while delta < -180 { delta += 360 }+ return origin + delta * clampedProgress+ }+private static func targetBounds(from metadata: [String: String]) -> WindowTargetBounds? {guard let x = Double(metadata["target.bounds.x"] ?? ""),let y = Double(metadata["target.bounds.y"] ?? ""),diff --git a/apps/Donkey/Sources/DonkeyContracts/UserQueryContracts.swift b/apps/Donkey/Sources/DonkeyContracts/UserQueryContracts.swiftindex 714eee59..44dabcef 100644--- a/apps/Donkey/Sources/DonkeyContracts/UserQueryContracts.swift+++ b/apps/Donkey/Sources/DonkeyContracts/UserQueryContracts.swift@@ -280,6 +280,7 @@ public struct PointerCoachCursorGuideStep: Equatable, Sendable, Identifiable {public var id: Stringpublic var label: Stringpublic var target: CGPoint+ public var preRotateDuration: TimeIntervalpublic var travelDuration: TimeIntervalpublic var holdDuration: TimeIntervalpublic var metadata: [String: String]@@ -288,6 +289,7 @@ public struct PointerCoachCursorGuideStep: Equatable, Sendable, Identifiable {id: String = UUID().uuidString,label: String,target: CGPoint,+ preRotateDuration: TimeInterval = 0.12,travelDuration: TimeInterval = 0.9,holdDuration: TimeInterval = 1.8,metadata: [String: String] = [:]@@ -295,6 +297,7 @@ public struct PointerCoachCursorGuideStep: Equatable, Sendable, Identifiable {self.id = idself.label = labelself.target = target+ self.preRotateDuration = min(max(preRotateDuration, 0), 0.6)self.travelDuration = max(0.1, travelDuration)self.holdDuration = max(0.4, holdDuration)self.metadata = metadatadiff --git a/apps/Donkey/Sources/DonkeyHarness/GenericHarnessToolRegistry.swift b/apps/Donkey/Sources/DonkeyHarness/GenericHarnessToolRegistry.swiftindex f0a7befe..662c69f6 100644--- a/apps/Donkey/Sources/DonkeyHarness/GenericHarnessToolRegistry.swift+++ b/apps/Donkey/Sources/DonkeyHarness/GenericHarnessToolRegistry.swift@@ -322,6 +322,27 @@ public enum BuiltInHarnessToolCatalog {safety: .guardedInput,requiredContext: ["focused target"]),+ descriptor(+ "agent.path.visualize",+ pluginID: "core.agent-path",+ summary: "Prepare a visual-only pointer path from grounded harness evidence without performing input.",+ input: [+ "stepsJSON": "JSON array of AgentPathStep values with grounded normalizedTarget point or bounds.",+ "title": "Short label for the visual path.",+ "sourceTraceID": "Trace id that produced the path."+ ],+ output: [+ "agentPath.traceJSON": "Encoded AgentPathTrace.",+ "agentVisualization.planJSON": "Encoded AgentVisualizationPlan for pointer playback."+ ],+ permissions: [],+ safety: .readOnly,+ requiredContext: ["grounded app, window, control, or action evidence"],+ verification: [+ "realPointerMoved=false",+ "ungrounded steps block instead of inventing motion"+ ]+ ),descriptor("automation.applescript.generate",pluginID: "core.automation",diff --git a/apps/Donkey/Sources/DonkeyRuntime/AppHarnessGenericLifecycle.swift b/apps/Donkey/Sources/DonkeyRuntime/AppHarnessGenericLifecycle.swiftindex e69770c8..17fc0e0d 100644--- a/apps/Donkey/Sources/DonkeyRuntime/AppHarnessGenericLifecycle.swift+++ b/apps/Donkey/Sources/DonkeyRuntime/AppHarnessGenericLifecycle.swift@@ -3,7 +3,8 @@ import DonkeyHarnessimport Foundationpublic enum AppHarnessGenericLifecycleToolNames {- public static let localAppTools: [String] = LocalAppActionPlanTool.allCases.map(\.rawValue)+ public static let agentPathVisualize = "agent.path.visualize"+ public static let localAppTools: [String] = (LocalAppActionPlanTool.allCases.map(\.rawValue) + [agentPathVisualize]).sorted()}public struct AppHarnessGenericLifecyclePreparedTurn: Equatable, Sendable {diff --git a/apps/Donkey/Sources/DonkeyUI/UserQuerySpawnOverlayView.swift b/apps/Donkey/Sources/DonkeyUI/UserQuerySpawnOverlayView.swiftindex 758ca07c..b13f4724 100644--- a/apps/Donkey/Sources/DonkeyUI/UserQuerySpawnOverlayView.swift+++ b/apps/Donkey/Sources/DonkeyUI/UserQuerySpawnOverlayView.swift@@ -230,7 +230,9 @@ public final class UserQuerySpawnOverlayViewModel: ObservableObject {state: UserQuerySpawnState,origin: CGPoint,destination: CGPoint,- screenSize: CGSize+ screenSize: CGSize,+ preRotateDuration: TimeInterval = 0,+ travelDuration: TimeInterval = UserQuerySpawnOverlayViewModel.travelDuration) {animationGeneration += 1self.state = state@@ -239,10 +241,11 @@ public final class UserQuerySpawnOverlayViewModel: ObservableObject {self.screenSize = screenSizeself.opacity = 0self.isHolding = false- self.cursorAngleDegrees = UserQuerySpawnGeometry.angleDegrees(+ let travelAngle = UserQuerySpawnGeometry.angleDegrees(from: origin,to: destination)+ self.cursorAngleDegrees = travelAngleself.terminalTailAngleDegrees = 0self.isWorking = falseself.viewportOrigin = .zero@@ -261,17 +264,30 @@ public final class UserQuerySpawnOverlayViewModel: ObservableObject {withAnimation(.easeOut(duration: 0.12)) {self.opacity = 1}- self.finishTravelAfterDelay(generation: generation, finalPosition: destination)+ self.finishTravelAfterDelay(+ generation: generation,+ finalPosition: destination,+ delay: preRotateDuration + travelDuration+ )}}public func update(state: UserQuerySpawnState,destination: CGPoint,- screenSize: CGSize+ screenSize: CGSize,+ preRotateDuration: TimeInterval = 0,+ travelDuration: TimeInterval = UserQuerySpawnOverlayViewModel.travelDuration) {guard self.state?.id == state.id else {- show(state: state, origin: position, destination: destination, screenSize: screenSize)+ show(+ state: state,+ origin: position,+ destination: destination,+ screenSize: screenSize,+ preRotateDuration: preRotateDuration,+ travelDuration: travelDuration+ )return}@@ -308,10 +324,17 @@ public final class UserQuerySpawnOverlayViewModel: ObservableObject {animationGeneration += 1let generation = animationGeneration- cursorAngleDegrees = UserQuerySpawnGeometry.angleDegrees(+ let travelAngle = UserQuerySpawnGeometry.angleDegrees(from: position,to: destination)+ if preRotateDuration > 0 {+ withAnimation(.easeInOut(duration: preRotateDuration)) {+ cursorAngleDegrees = travelAngle+ }+ } else {+ cursorAngleDegrees = travelAngle+ }terminalTailAngleDegrees = 0self.destination = destinationself.isHolding = false@@ -319,7 +342,11 @@ public final class UserQuerySpawnOverlayViewModel: ObservableObject {withAnimation(.easeOut(duration: 0.12)) {self.opacity = 1}- finishTravelAfterDelay(generation: generation, finalPosition: destination)+ finishTravelAfterDelay(+ generation: generation,+ finalPosition: destination,+ delay: preRotateDuration + travelDuration+ )}public func fadeOut() {@@ -431,8 +458,12 @@ public final class UserQuerySpawnOverlayViewModel: ObservableObject {labelLayoutChanged?()}- private func finishTravelAfterDelay(generation: Int, finalPosition: CGPoint) {- DispatchQueue.main.asyncAfter(deadline: .now() + Self.travelDuration) { [weak self] in+ private func finishTravelAfterDelay(+ generation: Int,+ finalPosition: CGPoint,+ delay: TimeInterval = UserQuerySpawnOverlayViewModel.travelDuration+ ) {+ DispatchQueue.main.asyncAfter(deadline: .now() + delay) { [weak self] inguard let self, self.animationGeneration == generation else { return }self.position = finalPositiondiff --git a/apps/Donkey/Tests/DonkeyRuntimeTests/AgentVisualizationCursorPathFeedbackTests.swift b/apps/Donkey/Tests/DonkeyRuntimeTests/AgentVisualizationCursorPathFeedbackTests.swiftindex 0c632ebe..f14bf0c4 100644--- a/apps/Donkey/Tests/DonkeyRuntimeTests/AgentVisualizationCursorPathFeedbackTests.swift+++ b/apps/Donkey/Tests/DonkeyRuntimeTests/AgentVisualizationCursorPathFeedbackTests.swift@@ -120,7 +120,8 @@ struct AgentVisualizationCursorPathFeedbackTests {confidence: 0.8),travelDuration: 0.4,- holdDuration: 0.4+ holdDuration: 0.4,+ metadata: ["preRotateDuration": "0"]),AgentVisualizationStep(id: "focus",@@ -133,7 +134,8 @@ struct AgentVisualizationCursorPathFeedbackTests {confidence: 0.8),travelDuration: 0.4,- holdDuration: 0.4+ holdDuration: 0.4,+ metadata: ["preRotateDuration": "0"]),AgentVisualizationStep(id: "verify",@@ -146,7 +148,8 @@ struct AgentVisualizationCursorPathFeedbackTests {confidence: 0.8),travelDuration: 0.4,- holdDuration: 0.4+ holdDuration: 0.4,+ metadata: ["preRotateDuration": "0"])],metadata: ["realPointerMoved": "false"]@@ -216,6 +219,7 @@ struct AgentVisualizationCursorPathFeedbackTests {id: "point-a",label: "Point A",target: CGPoint(x: 0.30, y: 0.60),+ preRotateDuration: 0,travelDuration: 1.0,holdDuration: 0.5),@@ -223,6 +227,7 @@ struct AgentVisualizationCursorPathFeedbackTests {id: "point-b",label: "Point B",target: CGPoint(x: 0.80, y: 0.20),+ preRotateDuration: 0,travelDuration: 2.0,holdDuration: 0.5)@@ -231,6 +236,44 @@ struct AgentVisualizationCursorPathFeedbackTests {)}+ @Test+ func samplerRotatesTowardTargetBeforeTravel() {+ let request = PointerCoachCursorGuideRequest(+ id: "pre-rotate",+ title: "Pre Rotate",+ origin: CGPoint(x: 0.10, y: 0.20),+ steps: [+ PointerCoachCursorGuideStep(+ id: "target",+ label: "Target",+ target: CGPoint(x: 0.30, y: 0.60),+ preRotateDuration: 0.2,+ travelDuration: 1.0,+ holdDuration: 0.5+ )+ ],+ metadata: ["realPointerMoved": "false"]+ )+ let screen = CGSize(width: 1_000, height: 500)+ let rotating = AgentVisualizationCursorPathSampler.sample(+ request: request,+ elapsed: 0.1,+ screenSize: screen+ )+ let traveling = AgentVisualizationCursorPathSampler.sample(+ request: request,+ elapsed: 0.21,+ screenSize: screen+ )++ expectPoint(rotating.position, x: 100, y: 100)+ #expect(rotating.phase == .preRotate)+ #expect(rotating.stepID == "target")+ #expect(abs(rotating.angle) > 1)+ #expect(traveling.phase == .travel)+ #expect(traveling.position.x > rotating.position.x)+ }+private func expectPoint(_ point: CGPoint,x: Double,diff --git a/apps/Donkey/Tests/DonkeyRuntimeTests/GenericHarnessTests.swift b/apps/Donkey/Tests/DonkeyRuntimeTests/GenericHarnessTests.swiftindex 816eb075..628e19bf 100644--- a/apps/Donkey/Tests/DonkeyRuntimeTests/GenericHarnessTests.swift+++ b/apps/Donkey/Tests/DonkeyRuntimeTests/GenericHarnessTests.swift@@ -60,6 +60,106 @@ struct GenericHarnessTests {let learningExplore = descriptors.first { $0.name == "application.learning.proposeExploration" }#expect(learningExplore?.requiredPermissions == [.accessibility])#expect(learningExplore?.verificationHints.contains { $0.contains("technical roles/actions") } == true)++ let agentPath = descriptors.first { $0.name == "agent.path.visualize" }+ #expect(agentPath?.pluginID == "core.agent-path")+ #expect(agentPath?.requiredPermissions == [])+ #expect(agentPath?.safetyClass == .readOnly)+ #expect(agentPath?.verificationHints.contains("realPointerMoved=false") == true)+ }++ @Test+ func agentPathVisualizeToolReturnsVisualOnlyPlanForGroundedSteps() async throws {+ let coordinator = HarnessTaskCoordinator()+ let runtime = GenericHarnessRuntime(+ coordinator: coordinator,+ registry: BuiltInHarnessToolCatalog.registryWithBuiltInExecutors()+ )+ let task = await coordinator.createTask(+ id: "task-agent-path",+ threadID: "thread-agent-path",+ goal: "show the path"+ )+ let steps = [+ AgentPathStep(+ id: "open-source",+ phaseID: "source",+ kind: .navigateApp,+ label: "Open source app",+ targetApp: "Source",+ point: HotLoopPoint(x: 0.20, y: 0.30, space: .normalizedTarget),+ source: .windowMetadata+ ),+ AgentPathStep(+ id: "act-destination",+ phaseID: "destination",+ kind: .act,+ label: "Use destination",+ targetApp: "Destination",+ bounds: HotLoopRect(x: 0.60, y: 0.40, width: 0.20, height: 0.10, space: .normalizedTarget),+ source: .actionTrace,+ status: .executed+ )+ ]+ let stepsJSON = try jsonString(steps)++ let result = await runtime.executeToolCall(+ taskID: task.id,+ call: HarnessToolCall(+ id: "path-call",+ name: "agent.path.visualize",+ input: [+ "title": "Show path",+ "stepsJSON": stepsJSON,+ "sourceTraceID": "trace-path"+ ]+ )+ )++ let toolResult = try #require(result?.toolResult)+ #expect(toolResult.status == .succeeded)+ #expect(toolResult.metadata["realPointerMoved"] == "false")+ let planText = try #require(toolResult.metadata["agentVisualization.planJSON"])+ let plan = try JSONDecoder().decode(AgentVisualizationPlan.self, from: Data(planText.utf8))+ #expect(plan.metadata["realPointerMoved"] == "false")+ #expect(plan.steps.map(\.id) == ["open-source", "act-destination"])+ #expect(plan.cursorOverlayRequest()?.steps.first?.preRotateDuration == 0.12)+ }++ @Test+ func agentPathVisualizeToolBlocksUngroundedSteps() async throws {+ let coordinator = HarnessTaskCoordinator()+ let runtime = GenericHarnessRuntime(+ coordinator: coordinator,+ registry: BuiltInHarnessToolCatalog.registryWithBuiltInExecutors()+ )+ let task = await coordinator.createTask(+ id: "task-agent-path-blocked",+ threadID: "thread-agent-path-blocked",+ goal: "show the path"+ )+ let stepsJSON = try jsonString([+ AgentPathStep(+ id: "missing-geometry",+ kind: .act,+ label: "Missing geometry",+ source: .modelPlan+ )+ ])++ let result = await runtime.executeToolCall(+ taskID: task.id,+ call: HarnessToolCall(+ id: "path-call-blocked",+ name: "agent.path.visualize",+ input: ["stepsJSON": stepsJSON]+ )+ )++ let toolResult = try #require(result?.toolResult)+ #expect(toolResult.status == .failed)+ #expect(toolResult.metadata["reason"] == "ungroundedAgentPathStep")+ #expect(toolResult.metadata["realPointerMoved"] == "false")}@Test@@ -1627,4 +1727,11 @@ struct GenericHarnessTests {#expect(compacted.metadata["compactor"] == "smart-priority-v1")#expect(compacted.compactionRecords.contains { $0.itemKind == .recentEvent && $0.droppedCount > 0 })}++ private func jsonString<T: Encodable>(_ value: T) throws -> String {+ let encoder = JSONEncoder()+ encoder.outputFormatting = [.sortedKeys]+ let data = try encoder.encode(value)+ return String(decoding: data, as: UTF8.self)+ }}diff --git a/docs/guides/agent-harness.md b/docs/guides/agent-harness.mdindex 1cd49c5d..91439936 100644--- a/docs/guides/agent-harness.md+++ b/docs/guides/agent-harness.md@@ -117,6 +117,10 @@ the target app is focused. The harness needs post-action evidence such as aguarded command trace, visible text, selected state, app-reported result, orscreenshot-backed observation.+Pointer playback is separate from input. It may rotate, travel, hold, and label+the path the agent planned or observed, while AX, AppleScript, keyboard input,+or guarded coordinate fallback perform the real work.+## AppleScript And ScriptsAppleScript is a tool path, not a hardcoded helper path. Generation creates adiff --git a/docs/guides/user-query-overlay.md b/docs/guides/user-query-overlay.mdindex 85b8f719..39738d5d 100644--- a/docs/guides/user-query-overlay.md+++ b/docs/guides/user-query-overlay.md@@ -23,7 +23,7 @@ quick local-app actions:- Keep prompt submissions, voice transcripts, and follow-ups on the same agent-harness path: task-thread routing, context assembly, conversational response, clarification, review, catalog-backed action parsing, task validation, and guarded local-app execution when a turn is actionable.- Resolve model-classified local-item requests against local apps, files, and folders by querying the current Mac with the SQLite-backed agent memory store, Spotlight/`mdfind`, and bounded filesystem fallback. If the requested local item cannot be found, keep the task safe and report that it was not found instead of falling back to a vague clarification.- Handle scriptable app tasks as guarded AppleScript automation when possible. Commands may use task metadata, generated source, or compact templates; completion is verified through generic task verification policy instead of requiring visible result text for every app.-- Visualize agent work with the spawned task cursor when a submitted turn already has one. Normal local-app tasks keep planning in the background and may create a final `AgentVisualizationPlan` only from runtime evidence such as evidence-backed action steps, observations, and action traces. Cursor playback uses only grounded control bounds or action targets, so it does not animate to invented coordinates. Visual-only demonstration turns use the same plan shape without live input. Local-app visualizations use observed Accessibility or action-trace control bounds when available, convert target-window-normalized element centers into the active overlay screen's pixel coordinates, and only then move the overlay cursor. Donkey moves the overlay cursor along curved paths and shows compact labels next to it while keeping the real mouse untouched. A separate visualization-only cursor is only a fallback when no spawned cursor is available to attach to.+- Visualize agent work with the spawned task cursor when a submitted turn already has one. Normal local-app tasks keep planning in the background and may create an `AgentVisualizationPlan` from the harness `agent.path.visualize` tool or from runtime evidence such as evidence-backed action steps, observations, and action traces. Cursor playback uses only grounded control bounds or action targets, so it does not animate to invented coordinates. Visual-only demonstration turns use the same plan shape without live input. Local-app visualizations use observed Accessibility or action-trace control bounds when available, convert target-window-normalized element centers into the active overlay screen's pixel coordinates, and only then move the overlay cursor. Before each travel segment, the pointer rotates toward the direction of travel; it then moves along a curved path and shows compact labels while keeping the real mouse untouched. A separate visualization-only cursor is only a fallback when no spawned cursor is available to attach to.- Maintain a background agent memory store in Application Support. The store records resolved and missing local-item lookups, prewarms apps, stores runtime task definitions, keeps metadata such as kind/path/bundle ID/source/task/action, indexes records with SQLite FTS5 plus local vectors, and passes a bounded set of matching hints into the agent harness memory section for classifier and model consideration. Protected file folders such as Desktop, Documents, and Downloads stay lazy and are searched only when a user-requested local-item lookup needs them. See `docs/guides/decision-system.md` for how those hints feed typed model decisions and guarded local-app plans.- Persist task threads as searchable Core Data conversations with event history, task assets, and per-run runtime coordination for any action work attached to the thread.- Keep the overlay non-invasive. Permission setup requests Accessibility, screenshot, and microphone access with user-visible reasons, but the overlay itself does not capture the screen or synthesize input directly. Bounded screenshots and Accessibility reads are used only by guarded local-app workflows.@@ -69,7 +69,7 @@ quick local-app actions:- Voice capture and transcription remain separate. The controller records bounded local audio and publishes levels; transcription is model-backed through the hosted agent-harness boundary before transcript text enters the turn path.- Local item prewarming must run off the main actor and must not eagerly scan protected user folders. Agent memory is stored in SQLite under Application Support and uses FTS5 plus deterministic local embeddings for retrieval; JSONL is only an explicit export/debug format. Cached local-item hits must still point to an existing path or bundle before they are used as an execution target. Runtime task definitions are the generic open/local-app interaction seeds plus generated or user-reviewed definitions loaded from memory.- For scriptable apps, prefer app-native AppleScript task commands before falling back to Accessibility, AI visual targets, or keyboard input. Submit steps with an explicit structured `controlID` may execute as an Accessibility `AXPress` against button-like controls, or as a guarded coordinate click against an AI visual target when Accessibility is unavailable. Control bounds are carried into action traces.-- Agent visualization overlays are non-interactive, non-activating panels. They may point, explain, and replay what the agent is doing or would do, but they do not synthesize mouse movement. Live keyboard or Accessibility actions remain separate guarded runtime actions. When a local-app action plan is based on an observation, preserve target-window geometry and control bounds on the evidence-backed steps so cursor replay can use pixel-grounded element positions instead of invented coordinates.+- Agent visualization overlays are non-interactive, non-activating panels. They may point, explain, and replay what the agent is doing or would do, but they do not synthesize mouse movement. Live keyboard or Accessibility actions remain separate guarded runtime actions. When a local-app action plan is based on an observation, preserve target-window geometry and control bounds on the evidence-backed steps so cursor replay can use pixel-grounded element positions instead of invented coordinates. Harness path playback should flow through `agent.path.visualize`, which returns a visual plan only after every waypoint is grounded.- The developer UI inspection overlay is separate from agent visualization. Itis a transparent, non-activating, click-through, keyboard-pass-through AppKitpanel at a lower window level than Donkey's interactive UI. It renders