Skip to content

Open source CapCut alternative.

TypeScript

Replace local app dry run with evidence-backed action plan

David Leef0ade241734
diff --git a/apps/Donkey/Sources/Donkey/PointerPromptCommandHandler.swift b/apps/Donkey/Sources/Donkey/PointerPromptCommandHandler.swift
index aef89991..b6cdb0dc 100644
--- a/apps/Donkey/Sources/Donkey/PointerPromptCommandHandler.swift
+++ b/apps/Donkey/Sources/Donkey/PointerPromptCommandHandler.swift
@@ -282,16 +282,6 @@ struct LocalAppPointerPromptCommandHandler: PointerPromptCommandHandling {
trace: localModelResult.trace,
latencyMS: parseLatencyMS
)
- if let projectedVisualizationPlan = LocalAppTaskAgentVisualizationBuilder.projectedPlan(
- command: commandRedaction.redactedText,
- traceID: traceID,
- resolution: resolution
- ) {
- await reportAgentVisualization(
- groundAgentVisualizationPlan(projectedVisualizationPlan),
- context: context
- )
- }
let semanticMemoryResults = await retrieveSemanticMemory(
command: commandRedaction.redactedText,
resolution: resolution
@@ -434,15 +424,6 @@ struct LocalAppPointerPromptCommandHandler: PointerPromptCommandHandling {
await spawnProgressChanged(update)
}
- private func reportAgentVisualization(
- _ plan: AgentVisualizationPlan,
- context: PointerPromptCommandContext?
- ) async {
- guard let agentVisualizationChanged = context?.agentVisualizationChanged else { return }
-
- await agentVisualizationChanged(plan)
- }
-
private func groundAgentVisualizationPlan(_ plan: AgentVisualizationPlan) -> AgentVisualizationPlan {
let candidates = MacWindowResolver().enumerateCandidates()
guard !candidates.isEmpty else { return plan }
@@ -633,8 +614,8 @@ struct LocalAppPointerPromptCommandHandler: PointerPromptCommandHandling {
private func decisionDescription(_ decision: ActionEngineCommandDecision) -> String {
switch decision {
- case .projectedDryRun:
- return "projectedDryRun"
+ case .skippedNoLiveInput:
+ return "skippedNoLiveInput"
case .executedLive:
return "executedLive"
case .denied(let reason):
diff --git a/apps/Donkey/Sources/DonkeyContracts/AgentVisualizationContracts.swift b/apps/Donkey/Sources/DonkeyContracts/AgentVisualizationContracts.swift
index 2f138c9f..04b9b6d7 100644
--- a/apps/Donkey/Sources/DonkeyContracts/AgentVisualizationContracts.swift
+++ b/apps/Donkey/Sources/DonkeyContracts/AgentVisualizationContracts.swift
@@ -21,7 +21,7 @@ public enum AgentVisualizationStepKind: String, Codable, Equatable, Sendable {
public enum AgentVisualizationGroundingSource: String, Codable, Equatable, Sendable {
case modelPlan
- case dryRun
+ case evidenceBackedActionPlan
case accessibility
case windowMetadata
case localUIUnderstanding
@@ -150,16 +150,18 @@ public struct AgentVisualizationPlan: Codable, Equatable, Sendable, Identifiable
public func cursorOverlayRequest() -> PointerCoachCursorGuideRequest? {
guard metadata["cursorGuideEligible"] != "false" else { return nil }
- let cursorSteps = steps.prefix(8).enumerated().map { index, step in
- PointerCoachCursorGuideStep(
+ let cursorSteps = Array(steps.compactMap { step -> PointerCoachCursorGuideStep? in
+ guard let target = cursorPoint(for: step) else { return nil }
+
+ return PointerCoachCursorGuideStep(
id: step.id,
label: step.label,
- target: cursorPoint(for: step, index: index),
+ target: target,
travelDuration: step.travelDuration,
holdDuration: step.holdDuration,
metadata: cursorStepMetadata(for: step)
)
- }
+ }.prefix(8))
guard !cursorSteps.isEmpty else { return nil }
return PointerCoachCursorGuideRequest(
@@ -177,7 +179,7 @@ public struct AgentVisualizationPlan: Codable, Equatable, Sendable, Identifiable
)
}
- private func cursorPoint(for step: AgentVisualizationStep, index: Int) -> CGPoint {
+ private func cursorPoint(for step: AgentVisualizationStep) -> CGPoint? {
if let point = step.target?.point,
point.space == .normalizedTarget {
return CGPoint(
@@ -194,7 +196,7 @@ public struct AgentVisualizationPlan: Codable, Equatable, Sendable, Identifiable
)
}
- return Self.fallbackPoint(index: index)
+ return nil
}
private func cursorStepMetadata(for step: AgentVisualizationStep) -> [String: String] {
@@ -213,13 +215,4 @@ public struct AgentVisualizationPlan: Codable, Equatable, Sendable, Identifiable
}
return metadata
}
-
- private static func fallbackPoint(index: Int) -> CGPoint {
- let lane = Double(index % 4)
- let row = Double(index / 4)
- return CGPoint(
- x: min(0.82, 0.28 + lane * 0.16),
- y: min(0.86, 0.20 + row * 0.18)
- )
- }
}
diff --git a/apps/Donkey/Sources/DonkeyContracts/TaskIntentContracts.swift b/apps/Donkey/Sources/DonkeyContracts/TaskIntentContracts.swift
index 72b332e9..bbc571b7 100644
--- a/apps/Donkey/Sources/DonkeyContracts/TaskIntentContracts.swift
+++ b/apps/Donkey/Sources/DonkeyContracts/TaskIntentContracts.swift
@@ -221,7 +221,7 @@ public enum LocalAppTaskWorkflowStage: String, Codable, CaseIterable, Equatable,
case parseIntent
case resolveApp
case observe
- case dryRun
+ case evidencePlan = "evidence-plan"
case approval
case execute
case verify
@@ -331,7 +331,7 @@ public struct LocalAppTaskDefinition: Codable, Equatable, Sendable {
}
public enum LocalAppTaskStepStatus: String, Codable, Equatable, Sendable {
- case projected
+ case needsEvidence = "needs-evidence"
case blocked
case verified
}
@@ -368,7 +368,7 @@ public struct LocalAppTaskObservation: Codable, Equatable, Sendable {
}
}
-public struct LocalAppTaskDryRunStep: Codable, Equatable, Sendable {
+public struct LocalAppEvidenceBackedActionStep: Codable, Equatable, Sendable {
public var id: String
public var role: LocalAppTaskStepRole
public var status: LocalAppTaskStepStatus
@@ -390,21 +390,21 @@ public struct LocalAppTaskDryRunStep: Codable, Equatable, Sendable {
}
}
-public struct LocalAppTaskDryRunPlan: Codable, Equatable, Sendable {
+public struct LocalAppEvidenceBackedActionPlan: Codable, Equatable, Sendable {
public var intent: TaskIntent
public var targetApp: LocalAppTarget
- public var steps: [LocalAppTaskDryRunStep]
+ public var steps: [LocalAppEvidenceBackedActionStep]
public var terminalState: LocalAppTaskTerminalState
- public var canAttemptGuardedLive: Bool
+ public var canExecuteGuardedActions: Bool
public var verificationConfidence: Double
public var metadata: [String: String]
public init(
intent: TaskIntent,
targetApp: LocalAppTarget,
- steps: [LocalAppTaskDryRunStep],
+ steps: [LocalAppEvidenceBackedActionStep],
terminalState: LocalAppTaskTerminalState,
- canAttemptGuardedLive: Bool,
+ canExecuteGuardedActions: Bool,
verificationConfidence: Double,
metadata: [String: String] = [:]
) {
@@ -412,7 +412,7 @@ public struct LocalAppTaskDryRunPlan: Codable, Equatable, Sendable {
self.targetApp = targetApp
self.steps = steps
self.terminalState = terminalState
- self.canAttemptGuardedLive = canAttemptGuardedLive
+ self.canExecuteGuardedActions = canExecuteGuardedActions
self.verificationConfidence = min(max(verificationConfidence, 0), 1)
self.metadata = metadata
}
diff --git a/apps/Donkey/Sources/DonkeyRuntime/ActionEngineGuardrails.swift b/apps/Donkey/Sources/DonkeyRuntime/ActionEngineGuardrails.swift
index 0c4a84f4..24f75208 100644
--- a/apps/Donkey/Sources/DonkeyRuntime/ActionEngineGuardrails.swift
+++ b/apps/Donkey/Sources/DonkeyRuntime/ActionEngineGuardrails.swift
@@ -51,7 +51,7 @@ public struct ActionEngineCommand: Codable, Equatable, Sendable {
}
public enum ActionEngineCommandDecision: Codable, Equatable, Sendable {
- case projectedDryRun
+ case skippedNoLiveInput
case executedLive
case denied(reason: String)
}
@@ -182,7 +182,7 @@ public actor ActionEngineGuardrail {
heldCommandIDs.removeAll()
return appendTrace(
command: command,
- decision: .projectedDryRun,
+ decision: .skippedNoLiveInput,
focusGuardPassed: true,
permissionDecision: .allow,
rateLimited: false,
@@ -256,7 +256,7 @@ public actor ActionEngineGuardrail {
return appendTrace(
command: command,
- decision: .projectedDryRun,
+ decision: .skippedNoLiveInput,
executed: false,
focusGuardPassed: true,
permissionDecision: permissionDecision,
diff --git a/apps/Donkey/Sources/DonkeyRuntime/AgentVisualizationRuntime.swift b/apps/Donkey/Sources/DonkeyRuntime/AgentVisualizationRuntime.swift
index 3b455a97..fa9c7bb7 100644
--- a/apps/Donkey/Sources/DonkeyRuntime/AgentVisualizationRuntime.swift
+++ b/apps/Donkey/Sources/DonkeyRuntime/AgentVisualizationRuntime.swift
@@ -2,97 +2,34 @@ import DonkeyContracts
import Foundation
public enum LocalAppTaskAgentVisualizationBuilder {
- public static func projectedPlan(
- command: String,
- traceID: String,
- resolution: LocalAppTaskCatalogResolution
- ) -> AgentVisualizationPlan? {
- guard resolution.status == .resolved,
- let definition = resolution.definition
- else {
- return nil
- }
-
- let workflowSteps = definition.workflowSteps.isEmpty
- ? fallbackWorkflowSteps(for: definition)
- : definition.workflowSteps
- let steps = workflowSteps.enumerated().map { index, workflowStep in
- projectedStep(
- from: workflowStep,
- index: index,
- definition: definition
- )
- }
- guard !steps.isEmpty else { return nil }
-
- var metadata = [
- "source": "local-app-projected-workflow",
- "targetApp": definition.targetApp.appName,
- "taskType": definition.taskType,
- "resolution.status": resolution.status.rawValue,
- "realPointerMoved": "false",
- "cursorGuideEligible": "false",
- "grounding.source": AgentVisualizationGroundingSource.dryRun.rawValue,
- "workflowStage": "preExecution"
- ].merging(resolution.metadata) { current, _ in current }
-
- if let intent = resolution.intent {
- metadata["intent.id"] = intent.intentID
- metadata["intent.confidence"] = String(intent.confidence)
- metadata["intent.entityNames"] = intent.entities.keys.sorted().joined(separator: ",")
- }
- if !command.isEmpty {
- metadata["command.present"] = "true"
- }
-
- return AgentVisualizationPlan(
- id: "agent-visualization-\(traceID)-projected",
- title: "Working in \(definition.targetApp.appName)",
- executionMode: .live,
- sourceTraceID: traceID,
- steps: steps,
- verification: AgentVisualizationVerificationReport(
- status: .unverified,
- summary: "Execution is still in progress.",
- confidence: 0,
- evidenceCount: 0,
- metadata: ["workflowStage": "preExecution"]
- ),
- metadata: metadata
- )
- }
-
public static func plan(
for result: LocalAppTaskLiveRunResult,
sourceTraceID: String? = nil
) -> AgentVisualizationPlan? {
guard let definition = result.resolution.definition else { return nil }
- let evidencePlan = result.finalPlan ?? result.initialPlan
+ let evidencePlan = result.finalActionPlan ?? result.initialActionPlan
let initialStepsByID = Dictionary(
- uniqueKeysWithValues: (result.initialPlan?.steps ?? []).map { ($0.id, $0) }
+ uniqueKeysWithValues: (result.initialActionPlan?.steps ?? []).map { ($0.id, $0) }
)
- var steps = (evidencePlan?.steps ?? []).enumerated().map { index, dryRunStep in
+ var steps = (evidencePlan?.steps ?? []).map { actionPlanStep in
visualizationStep(
- from: dryRunStep,
- index: index,
+ from: actionPlanStep,
definition: definition,
- fallbackStep: initialStepsByID[dryRunStep.id],
- actionTrace: matchingTrace(for: dryRunStep, in: result.actionTraces)
+ fallbackStep: initialStepsByID[actionPlanStep.id],
+ actionTrace: matchingTrace(for: actionPlanStep, in: result.actionTraces)
)
}
- let dryRunStepIDs = Set((evidencePlan?.steps ?? []).map(\.id))
+ let actionPlanStepIDs = Set((evidencePlan?.steps ?? []).map(\.id))
let extraTraceSteps = result.actionTraces
.filter { trace in
guard let workflowStepID = trace.command.metadata["workflowStepID"] else { return true }
- return !dryRunStepIDs.contains(workflowStepID)
+ return !actionPlanStepIDs.contains(workflowStepID)
}
- .enumerated()
- .map { offset, trace in
+ .map { trace in
actionTraceStep(
trace,
- index: steps.count + offset,
definition: definition
)
}
@@ -101,12 +38,7 @@ public enum LocalAppTaskAgentVisualizationBuilder {
guard !steps.isEmpty else { return nil }
let verification = verificationReport(for: result)
- let controllerAutomationOnly = !result.actionTraces.isEmpty &&
- result.actionTraces.allSatisfy { $0.command.kind == .controller }
- let hasGroundedElementTargets = steps.contains { step in
- step.target?.metadata["control.bounds.space"] == HotLoopCoordinateSpace.normalizedTarget.rawValue
- }
- let cursorGuideEligible = controllerAutomationOnly == false || hasGroundedElementTargets
+ let cursorGuideEligible = steps.contains(where: hasCursorTarget)
return AgentVisualizationPlan(
id: "agent-visualization-\(result.traceID)",
title: title(for: result, definition: definition),
@@ -120,7 +52,7 @@ public enum LocalAppTaskAgentVisualizationBuilder {
"taskType": definition.taskType,
"realPointerMoved": "false",
"cursorGuideEligible": String(cursorGuideEligible),
- "cursorGuide.reason": cursorGuideEligible ? "" : "controllerAutomationNoElementTargets",
+ "cursorGuide.reason": cursorGuideEligible ? "" : "noGroundedTargets",
"actionTraceCount": String(result.actionTraces.count),
"workflowStageCount": String(result.workflowProgress.stages.count)
].merging(result.metadata.filter { key, _ in
@@ -129,47 +61,16 @@ public enum LocalAppTaskAgentVisualizationBuilder {
)
}
- private static func projectedStep(
- from step: LocalAppTaskWorkflowStepDefinition,
- index: Int,
- definition: LocalAppTaskDefinition
- ) -> AgentVisualizationStep {
- let metadata = step.metadata.merging([
- "workflow.stepID": step.id,
- "workflow.stepRole": step.role.rawValue,
- "targetApp": definition.targetApp.appName,
- "projection.status": LocalAppTaskStepStatus.projected.rawValue
- ]) { current, _ in current }
-
- return AgentVisualizationStep(
- id: step.id,
- kind: kind(for: step.role),
- label: label(for: step.role, summary: step.summary),
- target: AgentVisualizationStepTarget(
- point: targetPoint(for: step.role, index: index),
- description: step.summary,
- controlID: step.metadata["controlID"],
- source: .dryRun,
- confidence: 0.58,
- metadata: metadata
- ),
- travelDuration: duration(for: step.role).travel,
- holdDuration: duration(for: step.role).hold,
- metadata: metadata
- )
- }
-
private static func visualizationStep(
- from step: LocalAppTaskDryRunStep,
- index: Int,
+ from step: LocalAppEvidenceBackedActionStep,
definition: LocalAppTaskDefinition,
- fallbackStep: LocalAppTaskDryRunStep?,
+ fallbackStep: LocalAppEvidenceBackedActionStep?,
actionTrace: ActionEngineCommandTrace?
) -> AgentVisualizationStep {
var metadata = step.metadata.merging([
- "dryRun.stepID": step.id,
- "dryRun.stepRole": step.role.rawValue,
- "dryRun.stepStatus": step.status.rawValue,
+ "evidencePlan.stepID": step.id,
+ "evidencePlan.stepRole": step.role.rawValue,
+ "evidencePlan.stepStatus": step.status.rawValue,
"targetApp": definition.targetApp.appName
]) { current, _ in current }
@@ -183,26 +84,26 @@ public enum LocalAppTaskAgentVisualizationBuilder {
}) { current, _ in current }
}
let groundedBounds = LocalAppObservationGeometry.normalizedStepBounds(metadata: metadata)
- let groundedPoint = centerPoint(for: groundedBounds)
- let actionTracePoint = centerPoint(for: actionTrace?.command.targetBounds)
+ let actionTraceBounds = normalizedBounds(actionTrace?.command.targetBounds)
let targetSource = groundingSource(
metadata["control.source"],
- fallback: actionTrace == nil ? .dryRun : .actionTrace
+ fallback: actionTrace == nil ? .evidenceBackedActionPlan : .actionTrace
+ )
+ let target = stepTarget(
+ point: centerPoint(for: groundedBounds) ?? centerPoint(for: actionTraceBounds),
+ bounds: groundedBounds ?? actionTraceBounds,
+ description: step.summary,
+ controlID: step.metadata["controlID"],
+ source: groundedBounds == nil ? (actionTraceBounds == nil ? nil : .actionTrace) : targetSource,
+ confidence: groundedBounds == nil ? confidence(for: step.status, actionTrace: actionTrace) : 0.9,
+ metadata: metadata
)
return AgentVisualizationStep(
id: step.id,
kind: kind(for: step.role),
label: label(for: step),
- target: AgentVisualizationStepTarget(
- point: groundedPoint ?? actionTracePoint ?? targetPoint(for: step.role, index: index),
- bounds: groundedBounds ?? normalizedBounds(actionTrace?.command.targetBounds),
- description: step.summary,
- controlID: step.metadata["controlID"],
- source: groundedBounds == nil ? (actionTrace == nil ? .dryRun : .actionTrace) : targetSource,
- confidence: groundedBounds == nil ? confidence(for: step.status, actionTrace: actionTrace) : 0.9,
- metadata: metadata
- ),
+ target: target,
travelDuration: duration(for: step.role).travel,
holdDuration: duration(for: step.role).hold,
metadata: metadata
@@ -211,7 +112,6 @@ public enum LocalAppTaskAgentVisualizationBuilder {
private static func actionTraceStep(
_ trace: ActionEngineCommandTrace,
- index: Int,
definition: LocalAppTaskDefinition
) -> AgentVisualizationStep {
let role = trace.command.metadata["workflowStepRole"] ?? "custom"
@@ -224,9 +124,9 @@ public enum LocalAppTaskAgentVisualizationBuilder {
id: trace.command.id,
kind: kind(forActionTraceRole: role),
label: label,
- target: AgentVisualizationStepTarget(
- point: centerPoint(for: trace.command.targetBounds) ?? fallbackPoint(index: index),
- bounds: trace.command.targetBounds,
+ target: stepTarget(
+ point: centerPoint(for: normalizedBounds(trace.command.targetBounds)),
+ bounds: normalizedBounds(trace.command.targetBounds),
description: trace.command.metadata["workflowStepID"] ?? trace.command.id,
controlID: trace.command.metadata["controlID"],
source: .actionTrace,
@@ -240,7 +140,7 @@ public enum LocalAppTaskAgentVisualizationBuilder {
}
private static func matchingTrace(
- for step: LocalAppTaskDryRunStep,
+ for step: LocalAppEvidenceBackedActionStep,
in traces: [ActionEngineCommandTrace]
) -> ActionEngineCommandTrace? {
traces.first { trace in
@@ -263,10 +163,10 @@ public enum LocalAppTaskAgentVisualizationBuilder {
status = .failed
}
- let verificationStep = result.finalPlan?.steps.first(where: { $0.role == .verifyResult })
- ?? result.initialPlan?.steps.first(where: { $0.role == .verifyResult })
- let confidence = result.finalPlan?.verificationConfidence
- ?? result.initialPlan?.verificationConfidence
+ let verificationStep = result.finalActionPlan?.steps.first(where: { $0.role == .verifyResult })
+ ?? result.initialActionPlan?.steps.first(where: { $0.role == .verifyResult })
+ let confidence = result.finalActionPlan?.verificationConfidence
+ ?? result.initialActionPlan?.verificationConfidence
?? 0
return AgentVisualizationVerificationReport(
status: status,
@@ -289,7 +189,7 @@ public enum LocalAppTaskAgentVisualizationBuilder {
return "Worked in \(definition.targetApp.appName)"
}
- private static func label(for step: LocalAppTaskDryRunStep) -> String {
+ private static func label(for step: LocalAppEvidenceBackedActionStep) -> String {
label(for: step.role, summary: step.summary)
}
@@ -359,8 +259,8 @@ public enum LocalAppTaskAgentVisualizationBuilder {
switch status {
case .verified:
return 0.84
- case .projected:
- return 0.58
+ case .needsEvidence:
+ return 0.35
case .blocked:
return 0.2
}
@@ -379,34 +279,6 @@ public enum LocalAppTaskAgentVisualizationBuilder {
}
}
- private static func targetPoint(
- for role: LocalAppTaskStepRole,
- index: Int
- ) -> HotLoopPoint {
- switch role {
- case .parseIntent:
- return point(0.50, 0.16)
- case .launchOrFocusApp:
- return point(0.50, 0.24)
- case .observeApp:
- return point(0.50, 0.34)
- case .focusControl:
- return point(0.40, 0.44)
- case .enterText:
- return point(0.50, 0.54)
- case .submit:
- return point(0.62, 0.62)
- case .verifyResult:
- return point(0.50, 0.74)
- case .custom:
- return fallbackPoint(index: index)
- }
- }
-
- private static func fallbackPoint(index: Int) -> HotLoopPoint {
- point(min(0.82, 0.28 + Double(index % 4) * 0.16), min(0.86, 0.20 + Double(index / 4) * 0.18))
- }
-
private static func centerPoint(for rect: HotLoopRect?) -> HotLoopPoint? {
guard let rect,
rect.space == .normalizedTarget else {
@@ -428,6 +300,40 @@ public enum LocalAppTaskAgentVisualizationBuilder {
return rect
}
+ private static func stepTarget(
+ point: HotLoopPoint?,
+ bounds: HotLoopRect?,
+ description: String,
+ controlID: String?,
+ source: AgentVisualizationGroundingSource?,
+ confidence: Double,
+ metadata: [String: String]
+ ) -> AgentVisualizationStepTarget? {
+ let usableBounds = normalizedBounds(bounds)
+ guard let source,
+ point != nil || usableBounds != nil
+ else {
+ return nil
+ }
+
+ return AgentVisualizationStepTarget(
+ point: point,
+ bounds: usableBounds,
+ description: description,
+ controlID: controlID,
+ source: source,
+ confidence: confidence,
+ metadata: metadata
+ )
+ }
+
+ private static func hasCursorTarget(_ step: AgentVisualizationStep) -> Bool {
+ if step.target?.point?.space == .normalizedTarget {
+ return true
+ }
+ return step.target?.bounds?.space == .normalizedTarget
+ }
+
private static func groundingSource(
_ value: String?,
fallback: AgentVisualizationGroundingSource
@@ -444,23 +350,6 @@ public enum LocalAppTaskAgentVisualizationBuilder {
HotLoopPoint(x: min(max(x, 0.04), 0.96), y: min(max(y, 0.06), 0.94), space: .normalizedTarget)
}
- private static func fallbackWorkflowSteps(
- for definition: LocalAppTaskDefinition
- ) -> [LocalAppTaskWorkflowStepDefinition] {
- [
- LocalAppTaskWorkflowStepDefinition(
- id: "observe",
- role: .observeApp,
- summary: "Observe \(definition.targetApp.appName)"
- ),
- LocalAppTaskWorkflowStepDefinition(
- id: "verify",
- role: .verifyResult,
- summary: "Verify the result"
- )
- ]
- }
-
private static func actionTraceMetadata(_ trace: ActionEngineCommandTrace) -> [String: String] {
[
"actionTrace.commandID": trace.command.id,
@@ -474,8 +363,8 @@ public enum LocalAppTaskAgentVisualizationBuilder {
private static func decisionDescription(_ decision: ActionEngineCommandDecision) -> String {
switch decision {
- case .projectedDryRun:
- return "projectedDryRun"
+ case .skippedNoLiveInput:
+ return "skippedNoLiveInput"
case .executedLive:
return "executedLive"
case .denied(let reason):
@@ -504,7 +393,7 @@ public struct AgentVisualizationGrounder: Sendable {
}
var grounded = plan
- grounded.steps = grounded.steps.enumerated().map { index, step in
+ grounded.steps = grounded.steps.map { step in
var copy = step
let targetMetadata = [
"target.windowID": String(target.windowID),
@@ -520,14 +409,6 @@ public struct AgentVisualizationGrounder: Sendable {
if var stepTarget = copy.target {
stepTarget.metadata = stepTarget.metadata.merging(targetMetadata) { current, _ in current }
copy.target = stepTarget
- } else {
- copy.target = AgentVisualizationStepTarget(
- point: normalizedCenter(for: target, metadata: plan.metadata) ?? fallbackPoint(index: index),
- description: target.title ?? target.appName ?? "target window",
- source: .windowMetadata,
- confidence: 0.68,
- metadata: targetMetadata
- )
}
copy.metadata = copy.metadata.merging(targetMetadata) { current, _ in current }
return copy
@@ -595,33 +476,6 @@ public struct AgentVisualizationGrounder: Sendable {
}
}
- private func normalizedCenter(
- for target: MacWindowTargetCandidate,
- metadata: [String: String]
- ) -> HotLoopPoint? {
- guard let screenWidth = Double(metadata["screen.width"] ?? ""),
- let screenHeight = Double(metadata["screen.height"] ?? ""),
- screenWidth > 0,
- screenHeight > 0
- else {
- return nil
- }
-
- return HotLoopPoint(
- x: min(max((target.bounds.x + target.bounds.width / 2) / screenWidth, 0.04), 0.96),
- y: min(max((target.bounds.y + target.bounds.height / 2) / screenHeight, 0.06), 0.94),
- space: .normalizedTarget
- )
- }
-
- private func fallbackPoint(index: Int) -> HotLoopPoint {
- HotLoopPoint(
- x: min(0.82, 0.28 + Double(index % 4) * 0.16),
- y: min(0.86, 0.20 + Double(index / 4) * 0.18),
- space: .normalizedTarget
- )
- }
-
private func normalize(_ value: String) -> String {
value
.lowercased()
diff --git a/apps/Donkey/Sources/DonkeyRuntime/DocumentFormFillApprovalLiveRunner.swift b/apps/Donkey/Sources/DonkeyRuntime/DocumentFormFillApprovalLiveRunner.swift
index e4d26c19..f5a2af33 100644
--- a/apps/Donkey/Sources/DonkeyRuntime/DocumentFormFillApprovalLiveRunner.swift
+++ b/apps/Donkey/Sources/DonkeyRuntime/DocumentFormFillApprovalLiveRunner.swift
@@ -126,7 +126,7 @@ public struct DocumentFormFillApprovalLiveRunner: Sendable {
)
let trace = await engine.handle(command, permissionPolicy: permissionPolicy)
traces.append(trace)
- guard trace.executed || trace.decision == .projectedDryRun else {
+ guard trace.executed || trace.decision == .skippedNoLiveInput else {
break
}
}
diff --git a/apps/Donkey/Sources/DonkeyRuntime/GuardedLiveActionSmoke.swift b/apps/Donkey/Sources/DonkeyRuntime/GuardedLiveActionSmoke.swift
index cb33f36d..f02b31c7 100644
--- a/apps/Donkey/Sources/DonkeyRuntime/GuardedLiveActionSmoke.swift
+++ b/apps/Donkey/Sources/DonkeyRuntime/GuardedLiveActionSmoke.swift
@@ -96,10 +96,10 @@ public struct GuardedLiveActionSmokeRunner: Sendable {
commandTrace: trace,
metadata: reportMetadata(latencyReport)
)
- case .projectedDryRun:
+ case .skippedNoLiveInput:
return GuardedLiveActionSmokeResult(
status: .skipped,
- reason: "action engine projected dry-run instead of live input",
+ reason: "action engine skipped live input",
commandTrace: trace,
metadata: reportMetadata(latencyReport)
)
diff --git a/apps/Donkey/Sources/DonkeyRuntime/LocalAppTaskAdapter.swift b/apps/Donkey/Sources/DonkeyRuntime/LocalAppTaskAdapter.swift
index b0168a31..3a689464 100644
--- a/apps/Donkey/Sources/DonkeyRuntime/LocalAppTaskAdapter.swift
+++ b/apps/Donkey/Sources/DonkeyRuntime/LocalAppTaskAdapter.swift
@@ -24,16 +24,16 @@ public struct LocalAppTaskAdapter: Sendable {
)
}
- public func dryRunPlan(
+ public func evidenceBackedActionPlan(
for intent: TaskIntent,
observation: LocalAppTaskObservation? = nil
- ) -> LocalAppTaskDryRunPlan {
+ ) -> LocalAppEvidenceBackedActionPlan {
guard supports(intent), intent.needsConfirmation == false else {
- return LocalAppTaskDryRunPlan(
+ return LocalAppEvidenceBackedActionPlan(
intent: intent,
targetApp: definition.targetApp,
steps: [
- LocalAppTaskDryRunStep(
+ LocalAppEvidenceBackedActionStep(
id: "parse-intent",
role: .parseIntent,
status: .blocked,
@@ -42,26 +42,28 @@ public struct LocalAppTaskAdapter: Sendable {
)
],
terminalState: .failedSafe,
- canAttemptGuardedLive: false,
+ canExecuteGuardedActions: false,
verificationConfidence: 0,
metadata: planMetadata
)
}
let verification = verificationStatus(for: intent, observation: observation)
- let steps = resolvedWorkflowSteps(
+ let steps = evidenceBackedWorkflowSteps(
intent: intent,
observation: observation,
verification: verification
)
+ let canExecuteGuardedActions = definition.metadata["guardedLiveDefault"] != "reviewOnly"
+ && verification.terminalState != .failedSafe
+ && steps.allSatisfy(Self.hasRequiredPreActionEvidence)
- return LocalAppTaskDryRunPlan(
+ return LocalAppEvidenceBackedActionPlan(
intent: intent,
targetApp: definition.targetApp,
steps: steps,
terminalState: verification.terminalState,
- canAttemptGuardedLive: definition.metadata["guardedLiveDefault"] != "reviewOnly"
- && verification.terminalState != .failedSafe,
+ canExecuteGuardedActions: canExecuteGuardedActions,
verificationConfidence: verification.confidence,
metadata: planMetadata
)
@@ -200,6 +202,7 @@ public struct LocalAppTaskAdapter: Sendable {
"appName": definition.targetApp.appName,
"bundleIdentifier": definition.targetApp.bundleIdentifier ?? "",
"guardedLiveRequiresInputPolicy": "true",
+ "evidenceContract": "pre-action-controls-require-accessibility-or-local-ui-understanding-bounds",
"defaultOSInputBackendAvailable": "true",
"defaultOSInputBackend": definition.metadata["automationBackend"] == "appleScript"
? "mac-apple-script"
@@ -207,14 +210,14 @@ public struct LocalAppTaskAdapter: Sendable {
].merging(definition.metadata) { current, _ in current }
}
- private func resolvedWorkflowSteps(
+ private func evidenceBackedWorkflowSteps(
intent: TaskIntent,
observation: LocalAppTaskObservation?,
verification: LocalAppTaskVerificationResult
- ) -> [LocalAppTaskDryRunStep] {
+ ) -> [LocalAppEvidenceBackedActionStep] {
if definition.workflowSteps.isEmpty {
return [
- LocalAppTaskDryRunStep(
+ LocalAppEvidenceBackedActionStep(
id: "parse-intent",
role: .parseIntent,
status: .verified,
@@ -230,7 +233,7 @@ public struct LocalAppTaskAdapter: Sendable {
if let stepControlID = step.metadata["controlID"] {
activeControlID = stepControlID
}
- return LocalAppTaskDryRunStep(
+ return LocalAppEvidenceBackedActionStep(
id: step.id,
role: step.role,
status: status(for: step, observation: observation, verificationStatus: verification.status),
@@ -255,17 +258,21 @@ public struct LocalAppTaskAdapter: Sendable {
case .parseIntent:
return .verified
case .launchOrFocusApp:
- return observation?.appIsFocused == true ? .verified : .projected
+ return observation?.appIsFocused == true ? .verified : .needsEvidence
case .observeApp:
- return observation == nil ? .projected : .verified
+ return observation == nil ? .needsEvidence : .verified
case .focusControl:
if let controlID = step.metadata["controlID"],
- observation?.availableControls[controlID] == true {
+ let observation,
+ LocalAppObservationGeometry.hasNormalizedControlBounds(
+ controlID: controlID,
+ metadata: observation.metadata
+ ) {
return .verified
}
- return .projected
+ return .needsEvidence
case .enterText, .submit, .custom:
- return .projected
+ return .needsEvidence
case .verifyResult:
return verificationStatus
}
@@ -322,6 +329,15 @@ public struct LocalAppTaskAdapter: Sendable {
return metadata
}
+ private static func hasRequiredPreActionEvidence(_ step: LocalAppEvidenceBackedActionStep) -> Bool {
+ switch step.role {
+ case .parseIntent, .launchOrFocusApp, .observeApp, .focusControl:
+ return step.status == .verified
+ case .enterText, .submit, .verifyResult, .custom:
+ return true
+ }
+ }
+
private func verificationStatus(
for intent: TaskIntent,
observation: LocalAppTaskObservation?
diff --git a/apps/Donkey/Sources/DonkeyRuntime/LocalAppTaskLiveRunner.swift b/apps/Donkey/Sources/DonkeyRuntime/LocalAppTaskLiveRunner.swift
index 40bed0b5..37af7ecb 100644
--- a/apps/Donkey/Sources/DonkeyRuntime/LocalAppTaskLiveRunner.swift
+++ b/apps/Donkey/Sources/DonkeyRuntime/LocalAppTaskLiveRunner.swift
@@ -17,8 +17,8 @@ public struct LocalAppTaskLiveRunResult: Equatable, Sendable {
public var traceID: String
public var status: LocalAppTaskLiveRunStatus
public var resolution: LocalAppTaskCatalogResolution
- public var initialPlan: LocalAppTaskDryRunPlan?
- public var finalPlan: LocalAppTaskDryRunPlan?
+ public var initialActionPlan: LocalAppEvidenceBackedActionPlan?
+ public var finalActionPlan: LocalAppEvidenceBackedActionPlan?
public var observation: LocalAppTaskObservation?
public var documentFormFillPlan: DocumentFormFillPlan?
public var actionTraces: [ActionEngineCommandTrace]
@@ -30,8 +30,8 @@ public struct LocalAppTaskLiveRunResult: Equatable, Sendable {
traceID: String,
status: LocalAppTaskLiveRunStatus,
resolution: LocalAppTaskCatalogResolution,
- initialPlan: LocalAppTaskDryRunPlan? = nil,
- finalPlan: LocalAppTaskDryRunPlan? = nil,
+ initialActionPlan: LocalAppEvidenceBackedActionPlan? = nil,
+ finalActionPlan: LocalAppEvidenceBackedActionPlan? = nil,
observation: LocalAppTaskObservation? = nil,
documentFormFillPlan: DocumentFormFillPlan? = nil,
actionTraces: [ActionEngineCommandTrace] = [],
@@ -42,8 +42,8 @@ public struct LocalAppTaskLiveRunResult: Equatable, Sendable {
self.traceID = traceID
self.status = status
self.resolution = resolution
- self.initialPlan = initialPlan
- self.finalPlan = finalPlan
+ self.initialActionPlan = initialActionPlan
+ self.finalActionPlan = finalActionPlan
self.observation = observation
self.documentFormFillPlan = documentFormFillPlan
self.actionTraces = actionTraces
@@ -228,7 +228,7 @@ public struct LocalAppTaskLiveRunner: Sendable {
summary: "Captured local app task context",
metadata: ["observer": "local-app-task-context"]
)
- stepTracker.start(.dryRun, summary: "Planning review-first document form fill")
+ stepTracker.start(.evidencePlan, summary: "Building review-first evidence-backed action plan")
let documentPlan = documentFormFillPlanner.plan(
intent: intent,
definition: definition,
@@ -249,11 +249,11 @@ public struct LocalAppTaskLiveRunner: Sendable {
"documentFormFillPlan.status": documentPlan.status.rawValue
]
)
- let initialPlan = adapter.dryRunPlan(for: intent, observation: observation)
+ let initialActionPlan = adapter.evidenceBackedActionPlan(for: intent, observation: observation)
stepTracker.complete(
- .dryRun,
+ .evidencePlan,
summary: "Built review-first document form-fill plan",
- metadata: ["terminalState": initialPlan.terminalState.rawValue]
+ metadata: ["terminalState": initialActionPlan.terminalState.rawValue]
)
stepTracker.wait(
.approval,
@@ -272,8 +272,8 @@ public struct LocalAppTaskLiveRunner: Sendable {
traceID: traceID,
status: .needsUserReview,
resolution: resolution,
- initialPlan: initialPlan,
- finalPlan: initialPlan,
+ initialActionPlan: initialActionPlan,
+ finalActionPlan: initialActionPlan,
observation: observation,
documentFormFillPlan: documentPlan,
workflowProgress: progress,
@@ -316,29 +316,29 @@ public struct LocalAppTaskLiveRunner: Sendable {
"appIsFocused": String(launchObservation.appIsFocused)
]
)
- stepTracker.start(.dryRun, summary: "Projecting guarded local-app workflow")
- let initialPlan = adapter.dryRunPlan(for: intent, observation: launchObservation)
- guard initialPlan.canAttemptGuardedLive else {
+ stepTracker.start(.evidencePlan, summary: "Building evidence-backed action plan")
+ let initialActionPlan = adapter.evidenceBackedActionPlan(for: intent, observation: launchObservation)
+ guard initialActionPlan.canExecuteGuardedActions else {
stepTracker.block(
- .dryRun,
- summary: "Dry-run plan blocked live input",
- metadata: ["terminalState": initialPlan.terminalState.rawValue]
+ .evidencePlan,
+ summary: "Evidence-backed action plan blocked live input",
+ metadata: ["terminalState": initialActionPlan.terminalState.rawValue]
)
- stepTracker.skip(.approval, summary: "No approval requested for blocked dry run")
- stepTracker.skip(.execute, summary: "Execution skipped because dry run blocked")
- stepTracker.skip(.verify, summary: "Verification skipped because dry run blocked")
+ stepTracker.skip(.approval, summary: "No approval requested for blocked evidence plan")
+ stepTracker.skip(.execute, summary: "Execution skipped because evidence was incomplete")
+ stepTracker.skip(.verify, summary: "Verification skipped because evidence was incomplete")
let progress = stepTracker.snapshot()
- await coordinator?.pause(reason: "Local app task dry-run plan blocked live input")
+ await coordinator?.pause(reason: "Local app task evidence-backed action plan blocked live input")
return LocalAppTaskLiveRunResult(
command: command,
traceID: traceID,
- status: status(for: initialPlan.terminalState),
+ status: status(for: initialActionPlan.terminalState),
resolution: resolution,
- initialPlan: initialPlan,
+ initialActionPlan: initialActionPlan,
observation: launchObservation,
workflowProgress: progress,
metadata: runMetadata.merging([
- "reason": "dryRunPlanBlocked",
+ "reason": "evidencePlanBlocked",
"latency.totalMS": Self.formatLatency(Self.uptimeMilliseconds() - runStartedAt)
], uniquingKeysWith: { current, _ in current }).merging(
Self.workflowProgressMetadata(progress),
@@ -347,18 +347,18 @@ public struct LocalAppTaskLiveRunner: Sendable {
)
}
stepTracker.complete(
- .dryRun,
- summary: "Dry-run plan allows guarded live execution",
- metadata: ["terminalState": initialPlan.terminalState.rawValue]
+ .evidencePlan,
+ summary: "Evidence-backed action plan allows guarded live execution",
+ metadata: ["terminalState": initialActionPlan.terminalState.rawValue]
)
if LocalAppTaskVerificationPolicy.mode(for: definition) == .openedLocalItem,
- initialPlan.terminalState == .completed {
+ initialActionPlan.terminalState == .completed {
stepTracker.skip(.approval, summary: "No review gate required for opened local item")
stepTracker.skip(.execute, summary: "Local item was opened through NSWorkspace")
stepTracker.complete(
.verify,
summary: "Local item open request confirmed",
- metadata: ["terminalState": initialPlan.terminalState.rawValue]
+ metadata: ["terminalState": initialActionPlan.terminalState.rawValue]
)
await coordinator?.complete(reason: "Local item opened")
let progress = stepTracker.snapshot()
@@ -367,8 +367,8 @@ public struct LocalAppTaskLiveRunner: Sendable {
traceID: traceID,
status: .completed,
resolution: resolution,
- initialPlan: initialPlan,
- finalPlan: initialPlan,
+ initialActionPlan: initialActionPlan,
+ finalActionPlan: initialActionPlan,
observation: launchObservation,
workflowProgress: progress,
metadata: runMetadata.merging([
@@ -417,7 +417,7 @@ public struct LocalAppTaskLiveRunner: Sendable {
)
accessibilityActionMS += Self.uptimeMilliseconds() - actionStartedAt
actionTraces.append(trace)
- guard trace.executed || trace.decision == .projectedDryRun else {
+ guard trace.executed || trace.decision == .skippedNoLiveInput else {
break
}
}
@@ -427,7 +427,7 @@ public struct LocalAppTaskLiveRunner: Sendable {
let engine = actionEngineFactory(definition)
let accessibilityHandledStepIDs: Set<String> = Set(actionTraces.compactMap { trace -> String? in
- guard trace.executed || trace.decision == ActionEngineCommandDecision.projectedDryRun else { return nil }
+ guard trace.executed || trace.decision == ActionEngineCommandDecision.skippedNoLiveInput else { return nil }
return workflowStepID(from: trace.command)
})
runMetadata["accessibilityHandledStepIDs"] = accessibilityHandledStepIDs.sorted().joined(separator: ",")
@@ -483,7 +483,7 @@ public struct LocalAppTaskLiveRunner: Sendable {
actionTraces.append(trace)
}
- guard trace.executed || trace.decision == ActionEngineCommandDecision.projectedDryRun else {
+ guard trace.executed || trace.decision == ActionEngineCommandDecision.skippedNoLiveInput else {
stepTracker.fail(
.execute,
summary: "Guarded local-app action was denied",
@@ -505,7 +505,7 @@ public struct LocalAppTaskLiveRunner: Sendable {
Self.uptimeMilliseconds() - observationStartedAt
)
let verificationStartedAt = Self.uptimeMilliseconds()
- let finalPlan = adapter.dryRunPlan(for: intent, observation: finalObservation)
+ let finalActionPlan = adapter.evidenceBackedActionPlan(for: intent, observation: finalObservation)
runMetadata["latency.verificationMS"] = Self.formatLatency(
Self.uptimeMilliseconds() - verificationStartedAt
)
@@ -516,8 +516,8 @@ public struct LocalAppTaskLiveRunner: Sendable {
traceID: traceID,
status: .failedSafe,
resolution: resolution,
- initialPlan: initialPlan,
- finalPlan: finalPlan,
+ initialActionPlan: initialActionPlan,
+ finalActionPlan: finalActionPlan,
observation: finalObservation,
actionTraces: actionTraces,
workflowProgress: progress,
@@ -550,7 +550,7 @@ public struct LocalAppTaskLiveRunner: Sendable {
summary: "Guarded local-app actions completed",
metadata: [
"executedCommandCount": String(actionTraces.filter(\.executed).count),
- "projectedCommandCount": String(actionTraces.filter { $0.decision == .projectedDryRun }.count)
+ "skippedNoLiveInputCommandCount": String(actionTraces.filter { $0.decision == .skippedNoLiveInput }.count)
]
)
@@ -569,29 +569,29 @@ public struct LocalAppTaskLiveRunner: Sendable {
let finalObservation = await appController.observe(definition: definition)
runMetadata["latency.observationMS"] = Self.formatLatency(Self.uptimeMilliseconds() - observationStartedAt)
let verificationStartedAt = Self.uptimeMilliseconds()
- let finalPlan = adapter.dryRunPlan(for: intent, observation: finalObservation)
+ let finalActionPlan = adapter.evidenceBackedActionPlan(for: intent, observation: finalObservation)
runMetadata["latency.verificationMS"] = Self.formatLatency(Self.uptimeMilliseconds() - verificationStartedAt)
runMetadata["latency.totalMS"] = Self.formatLatency(Self.uptimeMilliseconds() - runStartedAt)
- if let verificationStep = finalPlan.steps.first(where: { $0.role == .verifyResult }) {
+ if let verificationStep = finalActionPlan.steps.first(where: { $0.role == .verifyResult }) {
runMetadata["verification.summary"] = verificationStep.summary
runMetadata["verification.status"] = verificationStep.status.rawValue
for (key, value) in verificationStep.metadata {
runMetadata["verification.\(key)"] = value
}
}
- let status = status(for: finalPlan.terminalState)
+ let status = status(for: finalActionPlan.terminalState)
if status == .completed {
stepTracker.complete(
.verify,
summary: "Local app task result verified",
- metadata: ["terminalState": finalPlan.terminalState.rawValue]
+ metadata: ["terminalState": finalActionPlan.terminalState.rawValue]
)
await coordinator?.complete(reason: "Local app task completed")
} else {
stepTracker.block(
.verify,
summary: "Local app task needs user review after verification",
- metadata: ["terminalState": finalPlan.terminalState.rawValue]
+ metadata: ["terminalState": finalActionPlan.terminalState.rawValue]
)
await coordinator?.pause(reason: "Local app task needs user review")
}
@@ -601,14 +601,14 @@ public struct LocalAppTaskLiveRunner: Sendable {
traceID: traceID,
status: status,
resolution: resolution,
- initialPlan: initialPlan,
- finalPlan: finalPlan,
+ initialActionPlan: initialActionPlan,
+ finalActionPlan: finalActionPlan,
observation: finalObservation,
actionTraces: actionTraces,
workflowProgress: progress,
metadata: runMetadata.merging([
"executedCommandCount": String(actionTraces.filter(\.executed).count),
- "projectedCommandCount": String(actionTraces.filter { $0.decision == .projectedDryRun }.count)
+ "skippedNoLiveInputCommandCount": String(actionTraces.filter { $0.decision == .skippedNoLiveInput }.count)
], uniquingKeysWith: { current, _ in current }).merging(
Self.workflowProgressMetadata(progress),
uniquingKeysWith: { current, _ in current }
@@ -769,8 +769,8 @@ public struct LocalAppTaskLiveRunner: Sendable {
switch decision {
case .denied(let reason):
return reason
- case .projectedDryRun:
- return "projectedDryRun"
+ case .skippedNoLiveInput:
+ return "skippedNoLiveInput"
case .executedLive:
return "executedLive"
}
@@ -868,8 +868,8 @@ public struct LocalAppTaskLiveRunner: Sendable {
private static func decisionDescription(_ decision: ActionEngineCommandDecision) -> String {
switch decision {
- case .projectedDryRun:
- return "projectedDryRun"
+ case .skippedNoLiveInput:
+ return "skippedNoLiveInput"
case .executedLive:
return "executedLive"
case .denied(let reason):
@@ -972,7 +972,7 @@ public struct MacLocalAppTaskController: LocalAppTaskAppControlling {
return nil
}
let discovered = accessibilityIndex?.firstControl(matching: controlID) != nil
- return (controlID, discovered || step.metadata["key"] != nil || visibleText != nil)
+ return (controlID, discovered)
}
)
diff --git a/apps/Donkey/Sources/DonkeyRuntime/LocalAppTaskStepTracker.swift b/apps/Donkey/Sources/DonkeyRuntime/LocalAppTaskStepTracker.swift
index 032de3bc..78dc5779 100644
--- a/apps/Donkey/Sources/DonkeyRuntime/LocalAppTaskStepTracker.swift
+++ b/apps/Donkey/Sources/DonkeyRuntime/LocalAppTaskStepTracker.swift
@@ -101,8 +101,8 @@ public struct LocalAppTaskStepTracker: Sendable {
return "Resolve task and target app"
case .observe:
return "Observe target app state"
- case .dryRun:
- return "Project guarded workflow"
+ case .evidencePlan:
+ return "Build evidence-backed action plan"
case .approval:
return "Check user review or approval boundary"
case .execute:
diff --git a/apps/Donkey/Tests/DonkeyRuntimeTests/ActionEngineGuardrailTests.swift b/apps/Donkey/Tests/DonkeyRuntimeTests/ActionEngineGuardrailTests.swift
index 9edd2a4c..ceaeecb3 100644
--- a/apps/Donkey/Tests/DonkeyRuntimeTests/ActionEngineGuardrailTests.swift
+++ b/apps/Donkey/Tests/DonkeyRuntimeTests/ActionEngineGuardrailTests.swift
@@ -18,7 +18,7 @@ struct ActionEngineGuardrailTests {
}
@Test
- func allowedInputProjectsDryRunWithoutLiveExecution() async {
+ func allowedInputSkipsWhenLiveExecutionIsDisabled() async {
let engine = ActionEngineGuardrail()
let policy = ToolCallPolicy(deniedCapabilities: [])
@@ -27,7 +27,7 @@ struct ActionEngineGuardrailTests {
permissionPolicy: policy
)
- #expect(trace.decision == .projectedDryRun)
+ #expect(trace.decision == .skippedNoLiveInput)
#expect(trace.executed == false)
#expect(trace.liveInputEnabled == false)
#expect(trace.focusGuardPassed == true)
diff --git a/apps/Donkey/Tests/DonkeyRuntimeTests/AgentVisualizationCursorPathFeedbackTests.swift b/apps/Donkey/Tests/DonkeyRuntimeTests/AgentVisualizationCursorPathFeedbackTests.swift
index 968c6b8c..0c632ebe 100644
--- a/apps/Donkey/Tests/DonkeyRuntimeTests/AgentVisualizationCursorPathFeedbackTests.swift
+++ b/apps/Donkey/Tests/DonkeyRuntimeTests/AgentVisualizationCursorPathFeedbackTests.swift
@@ -116,7 +116,7 @@ struct AgentVisualizationCursorPathFeedbackTests {
target: AgentVisualizationStepTarget(
point: HotLoopPoint(x: 0.30, y: 0.22, space: .normalizedTarget),
description: "A",
- source: .dryRun,
+ source: .evidenceBackedActionPlan,
confidence: 0.8
),
travelDuration: 0.4,
@@ -129,7 +129,7 @@ struct AgentVisualizationCursorPathFeedbackTests {
target: AgentVisualizationStepTarget(
point: HotLoopPoint(x: 0.44, y: 0.22, space: .normalizedTarget),
description: "B",
- source: .dryRun,
+ source: .evidenceBackedActionPlan,
confidence: 0.8
),
travelDuration: 0.4,
@@ -142,7 +142,7 @@ struct AgentVisualizationCursorPathFeedbackTests {
target: AgentVisualizationStepTarget(
point: HotLoopPoint(x: 0.58, y: 0.22, space: .normalizedTarget),
description: "C",
- source: .dryRun,
+ source: .evidenceBackedActionPlan,
confidence: 0.8
),
travelDuration: 0.4,
diff --git a/apps/Donkey/Tests/DonkeyRuntimeTests/AgentVisualizationRuntimeTests.swift b/apps/Donkey/Tests/DonkeyRuntimeTests/AgentVisualizationRuntimeTests.swift
index 48823fdd..31903827 100644
--- a/apps/Donkey/Tests/DonkeyRuntimeTests/AgentVisualizationRuntimeTests.swift
+++ b/apps/Donkey/Tests/DonkeyRuntimeTests/AgentVisualizationRuntimeTests.swift
@@ -6,55 +6,80 @@ import Testing
@Suite
struct AgentVisualizationRuntimeTests {
@Test
- func resolvedLocalTaskBuildsProjectedLiveVisualizationBeforeExecution() throws {
+ func localAppRunWithoutGroundedTargetsDoesNotCreateCursorPlayback() throws {
let definition = localAppDefinition()
let intent = taskIntent(definition: definition)
- let plan = try #require(LocalAppTaskAgentVisualizationBuilder.projectedPlan(
+ let actionPlan = LocalAppEvidenceBackedActionPlan(
+ intent: intent,
+ targetApp: definition.targetApp,
+ steps: definition.workflowSteps.map { step in
+ LocalAppEvidenceBackedActionStep(
+ id: step.id,
+ role: step.role,
+ status: step.id == "verify" ? .verified : .needsEvidence,
+ summary: step.summary,
+ metadata: step.metadata
+ )
+ },
+ terminalState: .completed,
+ canExecuteGuardedActions: true,
+ verificationConfidence: 0.82
+ )
+ let result = LocalAppTaskLiveRunResult(
command: "create a table in Numbers",
traceID: "trace-projected-visualization",
+ status: .completed,
resolution: LocalAppTaskCatalogResolution(
status: .resolved,
intent: intent,
definition: definition,
availability: LocalAppAvailability(target: definition.targetApp, isInstalled: true),
metadata: ["resolutionSource": "test"]
- )
- ))
+ ),
+ initialActionPlan: actionPlan,
+ finalActionPlan: actionPlan,
+ observation: LocalAppTaskObservation(appIsRunning: true, appIsFocused: true, confidence: 0.8)
+ )
+ let plan = try #require(LocalAppTaskAgentVisualizationBuilder.plan(for: result))
#expect(plan.executionMode == .live)
- #expect(plan.verification.status == .unverified)
+ #expect(plan.verification.status == .verified)
#expect(plan.usesRealPointer == false)
- #expect(plan.metadata["source"] == "local-app-projected-workflow")
- #expect(plan.metadata["workflowStage"] == "preExecution")
+ #expect(plan.metadata["source"] == "local-app-live-runner")
#expect(plan.metadata["cursorGuideEligible"] == "false")
+ #expect(plan.metadata["cursorGuide.reason"] == "noGroundedTargets")
#expect(plan.cursorOverlayRequest() == nil)
#expect(plan.steps.map(\.kind).contains(.observe))
#expect(plan.steps.map(\.kind).contains(.enterText))
- #expect(plan.steps.first?.target?.source == .dryRun)
- #expect(plan.steps.first?.metadata["workflow.stepID"] == "launch")
+ #expect(plan.steps.allSatisfy { $0.target == nil })
+ #expect(plan.steps.first?.metadata["evidencePlan.stepID"] == "launch")
}
@Test
func localAppRunBuildsLiveVisualizationPlanWithoutMovingRealPointer() throws {
let definition = localAppDefinition()
let intent = taskIntent(definition: definition)
- let dryRunPlan = LocalAppTaskDryRunPlan(
+ let actionPlan = LocalAppEvidenceBackedActionPlan(
intent: intent,
targetApp: definition.targetApp,
steps: definition.workflowSteps.map { step in
- LocalAppTaskDryRunStep(
+ LocalAppEvidenceBackedActionStep(
id: step.id,
role: step.role,
- status: step.id == "verify" ? .verified : .projected,
+ status: step.id == "verify" ? .verified : .needsEvidence,
summary: step.summary,
metadata: step.metadata
)
},
terminalState: .completed,
- canAttemptGuardedLive: true,
+ canExecuteGuardedActions: true,
verificationConfidence: 0.82
)
- let trace = actionTrace(commandID: "intent-set-text", workflowStepID: "set-text")
+ let trace = actionTrace(
+ commandID: "intent-set-text",
+ workflowStepID: "set-text",
+ targetBounds: HotLoopRect(x: 0.35, y: 0.48, width: 0.3, height: 0.08, space: .normalizedTarget)
+ )
let result = LocalAppTaskLiveRunResult(
command: "create a table in Numbers",
traceID: "trace-visual-live",
@@ -65,8 +90,8 @@ struct AgentVisualizationRuntimeTests {
definition: definition,
availability: LocalAppAvailability(target: definition.targetApp, isInstalled: true)
),
- initialPlan: dryRunPlan,
- finalPlan: dryRunPlan,
+ initialActionPlan: actionPlan,
+ finalActionPlan: actionPlan,
observation: LocalAppTaskObservation(appIsRunning: true, appIsFocused: true, confidence: 0.8),
actionTraces: [trace]
)
@@ -79,6 +104,7 @@ struct AgentVisualizationRuntimeTests {
#expect(plan.verification.status == .verified)
#expect(plan.steps.map(\.kind).contains(.enterText))
#expect(plan.steps.first(where: { $0.id == "set-text" })?.metadata["actionTrace.executed"] == "true")
+ #expect(cursorRequest.steps.map(\.id) == ["set-text"])
#expect(cursorRequest.metadata["realPointerMoved"] == "false")
#expect(cursorRequest.metadata["agentVisualization.executionMode"] == "live")
}
@@ -109,7 +135,7 @@ struct AgentVisualizationRuntimeTests {
confidence: 0.9,
metadata: observationMetadata
)
- let dryRunPlan = adapter.dryRunPlan(for: intent, observation: observation)
+ let actionPlan = adapter.evidenceBackedActionPlan(for: intent, observation: observation)
let result = LocalAppTaskLiveRunResult(
command: "create a table in Numbers",
traceID: "trace-grounded-control",
@@ -120,8 +146,8 @@ struct AgentVisualizationRuntimeTests {
definition: definition,
availability: LocalAppAvailability(target: definition.targetApp, isInstalled: true)
),
- initialPlan: dryRunPlan,
- finalPlan: dryRunPlan,
+ initialActionPlan: actionPlan,
+ finalActionPlan: actionPlan,
observation: observation
)
@@ -206,7 +232,7 @@ struct AgentVisualizationRuntimeTests {
target: AgentVisualizationStepTarget(
point: HotLoopPoint(x: 0.38, y: 0.46, space: .normalizedTarget),
description: "first cell",
- source: .dryRun,
+ source: .evidenceBackedActionPlan,
confidence: 0.58
)
)
@@ -233,6 +259,40 @@ struct AgentVisualizationRuntimeTests {
#expect(grounded.steps.first?.target?.point?.x == 0.38)
}
+ @Test
+ func windowMetadataGroundingDoesNotInventCursorTargets() throws {
+ let plan = AgentVisualizationPlan(
+ title: "Worked in Numbers",
+ executionMode: .live,
+ sourceTraceID: "trace-no-target-grounding",
+ steps: [
+ AgentVisualizationStep(
+ id: "observe",
+ kind: .observe,
+ label: "Checking the screen"
+ )
+ ],
+ metadata: ["targetApp": "Numbers"]
+ )
+
+ let grounded = AgentVisualizationGrounder().ground(
+ plan: plan,
+ targetAppName: "Numbers",
+ candidates: [
+ window(
+ appName: "Numbers",
+ title: "Untitled",
+ safetyStatus: .allowed,
+ reasons: []
+ )
+ ]
+ )
+
+ #expect(grounded.steps.first?.metadata["target.windowID"] == "44")
+ #expect(grounded.steps.first?.target == nil)
+ #expect(grounded.cursorOverlayRequest() == nil)
+ }
+
@Test
func unsafeWindowsBlockScreenshotGrounding() throws {
let plan = AgentVisualizationPlan(
@@ -327,7 +387,8 @@ struct AgentVisualizationRuntimeTests {
private func actionTrace(
commandID: String,
- workflowStepID: String
+ workflowStepID: String,
+ targetBounds: HotLoopRect? = nil
) -> ActionEngineCommandTrace {
let command = ActionEngineCommand(
id: commandID,
@@ -335,6 +396,7 @@ struct AgentVisualizationRuntimeTests {
targetID: "local-app-task-local-app-interaction",
kind: .key,
issuedAt: timestamp(10),
+ targetBounds: targetBounds,
key: "Item\tValue",
metadata: [
"workflowStepID": workflowStepID,
diff --git a/apps/Donkey/Tests/DonkeyRuntimeTests/LocalAppTaskTests.swift b/apps/Donkey/Tests/DonkeyRuntimeTests/LocalAppTaskTests.swift
index a6195ef4..a9bd059e 100644
--- a/apps/Donkey/Tests/DonkeyRuntimeTests/LocalAppTaskTests.swift
+++ b/apps/Donkey/Tests/DonkeyRuntimeTests/LocalAppTaskTests.swift
@@ -111,8 +111,8 @@ struct LocalAppTaskTests {
#expect(intent.metadata["requiresDocumentContext"] == "true")
let plan = LocalAppTaskAdapter(definition: BuiltInLocalAppTaskDefinitions.documentFormFill)
- .dryRunPlan(for: intent)
- #expect(plan.canAttemptGuardedLive == false)
+ .evidenceBackedActionPlan(for: intent)
+ #expect(plan.canExecuteGuardedActions == false)
#expect(plan.metadata["guardedLiveDefault"] == "reviewOnly")
#expect(plan.steps.map(\.role).contains(.custom))
}
@@ -152,13 +152,13 @@ struct LocalAppTaskTests {
}
@Test
- func genericAdapterProjectsDryRunStepsAndGuardedKeyboardTemplates() throws {
+ func genericAdapterBuildsEvidenceBackedActionPlanAndGuardedKeyboardTemplates() throws {
let intent = weatherIntent(rawCity: "SF", city: "San Francisco")
let localAdapter = adapter()
- let plan = localAdapter.dryRunPlan(for: intent)
+ let plan = localAdapter.evidenceBackedActionPlan(for: intent)
#expect(plan.terminalState == .needsUserReview)
- #expect(plan.canAttemptGuardedLive == true)
+ #expect(plan.canExecuteGuardedActions == false)
#expect(plan.verificationConfidence == 0)
#expect(plan.steps.map(\.role) == [
.parseIntent,
@@ -191,14 +191,15 @@ struct LocalAppTaskTests {
func genericAdapterVerifiesObservedVisibleText() throws {
let intent = weatherIntent(rawCity: "SF", city: "San Francisco")
let localAdapter = adapter()
- let plan = localAdapter.dryRunPlan(
+ let plan = localAdapter.evidenceBackedActionPlan(
for: intent,
observation: LocalAppTaskObservation(
appIsRunning: true,
appIsFocused: true,
availableControls: ["search": true],
visibleText: ["city": "San Francisco, CA"],
- confidence: 0.91
+ confidence: 0.91,
+ metadata: groundedControlMetadata()
)
)
@@ -227,7 +228,7 @@ struct LocalAppTaskTests {
let intent = try #require(resolution.intent)
let definition = try #require(resolution.definition)
let localAdapter = LocalAppTaskAdapter(definition: definition)
- let plan = localAdapter.dryRunPlan(
+ let plan = localAdapter.evidenceBackedActionPlan(
for: intent,
observation: LocalAppTaskObservation(
appIsRunning: true,
@@ -245,14 +246,15 @@ struct LocalAppTaskTests {
func mediaPlaybackAdapterPlaysFirstSearchResultAndDoesNotRequireVisibleText() throws {
let intent = mediaPlaybackIntent(rawQuery: "justin bieber", query: "justin bieber")
let localAdapter = LocalAppTaskAdapter(definition: BuiltInLocalAppTaskDefinitions.mediaPlayback)
- let plan = localAdapter.dryRunPlan(
+ let plan = localAdapter.evidenceBackedActionPlan(
for: intent,
observation: LocalAppTaskObservation(
appIsRunning: true,
appIsFocused: true,
availableControls: ["search": true],
visibleText: [:],
- confidence: 0.68
+ confidence: 0.68,
+ metadata: groundedControlMetadata()
)
)
@@ -312,13 +314,14 @@ struct LocalAppTaskTests {
let intent = try #require(resolution.intent)
let definition = try #require(resolution.definition)
let localAdapter = LocalAppTaskAdapter(definition: definition)
- let plan = localAdapter.dryRunPlan(
+ let plan = localAdapter.evidenceBackedActionPlan(
for: intent,
observation: LocalAppTaskObservation(
appIsRunning: true,
appIsFocused: true,
availableControls: ["search": true],
- confidence: 0.7
+ confidence: 0.7,
+ metadata: groundedControlMetadata()
)
)
@@ -419,7 +422,7 @@ struct LocalAppTaskTests {
let resolvedIntent = try #require(resolution.intent)
let definition = try #require(resolution.definition)
let localAdapter = LocalAppTaskAdapter(definition: definition)
- let plan = localAdapter.dryRunPlan(
+ let plan = localAdapter.evidenceBackedActionPlan(
for: resolvedIntent,
observation: LocalAppTaskObservation(
appIsRunning: true,
@@ -482,7 +485,7 @@ struct LocalAppTaskTests {
let definition = try #require(resolution.definition)
let intent = try #require(resolution.intent)
- let plan = catalog.adapter(for: definition).dryRunPlan(for: intent)
+ let plan = catalog.adapter(for: definition).evidenceBackedActionPlan(for: intent)
#expect(plan.steps.map(\.role).contains(.verifyResult))
let mediaResolution = catalog.resolve(intent: mediaPlaybackIntent(rawQuery: "Coldplay", query: "Coldplay"))
@@ -819,14 +822,16 @@ struct LocalAppTaskTests {
appIsRunning: true,
appIsFocused: true,
availableControls: ["search": true],
- confidence: 0.5
+ confidence: 0.5,
+ metadata: groundedControlMetadata()
),
finalObservation: LocalAppTaskObservation(
appIsRunning: true,
appIsFocused: true,
availableControls: ["search": true],
visibleText: ["city": "San Francisco, CA"],
- confidence: 0.92
+ confidence: 0.92,
+ metadata: groundedControlMetadata()
)
)
let catalog = LocalAppTaskCatalog(
@@ -854,7 +859,7 @@ struct LocalAppTaskTests {
)
#expect(result.status == .completed)
- #expect(result.finalPlan?.terminalState == .completed)
+ #expect(result.finalActionPlan?.terminalState == .completed)
#expect(result.actionTraces.count == 4)
#expect(result.actionTraces.allSatisfy { $0.executed })
#expect(await backend.executedKeys() == ["Command+F", "San Francisco", "Return", "Return"])
@@ -862,7 +867,7 @@ struct LocalAppTaskTests {
#expect(controller.observeCount == 1)
#expect(result.workflowProgress.state(for: .parseIntent)?.status == .completed)
#expect(result.workflowProgress.state(for: .resolveApp)?.status == .completed)
- #expect(result.workflowProgress.state(for: .dryRun)?.status == .completed)
+ #expect(result.workflowProgress.state(for: .evidencePlan)?.status == .completed)
#expect(result.workflowProgress.state(for: .approval)?.status == .skipped)
#expect(result.workflowProgress.state(for: .execute)?.status == .completed)
#expect(result.workflowProgress.state(for: .verify)?.status == .completed)
@@ -877,14 +882,16 @@ struct LocalAppTaskTests {
appIsRunning: true,
appIsFocused: true,
availableControls: ["search": true],
- confidence: 0.5
+ confidence: 0.5,
+ metadata: groundedControlMetadata()
),
finalObservation: LocalAppTaskObservation(
appIsRunning: true,
appIsFocused: true,
availableControls: ["search": true],
visibleText: [:],
- confidence: 0.72
+ confidence: 0.72,
+ metadata: groundedControlMetadata()
)
)
let catalog = LocalAppTaskCatalog(
@@ -931,14 +938,16 @@ struct LocalAppTaskTests {
appIsRunning: true,
appIsFocused: true,
availableControls: ["search": true],
- confidence: 0.5
+ confidence: 0.5,
+ metadata: groundedControlMetadata()
),
finalObservation: LocalAppTaskObservation(
appIsRunning: true,
appIsFocused: true,
availableControls: ["search": true],
visibleText: ["city": "San Francisco, CA"],
- confidence: 0.92
+ confidence: 0.92,
+ metadata: groundedControlMetadata()
)
)
let coordinator = RunCoordinator()
@@ -1276,6 +1285,23 @@ struct LocalAppTaskTests {
)
}
+ private func groundedControlMetadata(controlID: String = "search") -> [String: String] {
+ var metadata = LocalAppObservationGeometry.targetBoundsMetadata(
+ WindowTargetBounds(x: 100, y: 120, width: 900, height: 700)
+ )
+ metadata.merge(
+ LocalAppObservationGeometry.controlMetadata(
+ controlID: controlID,
+ frame: HotLoopRect(x: 140, y: 180, width: 320, height: 44, space: .screen),
+ source: .accessibility,
+ label: "Search",
+ kind: .searchField,
+ confidence: 0.86
+ )
+ ) { current, _ in current }
+ return metadata
+ }
+
private func temporaryStoreDirectory() -> URL {
FileManager.default.temporaryDirectory
.appendingPathComponent("donkey-task-memory-\(UUID().uuidString)", isDirectory: true)
diff --git a/docs/guides/agent-harness.md b/docs/guides/agent-harness.md
index 8aeae0bd..0d0b87aa 100644
--- a/docs/guides/agent-harness.md
+++ b/docs/guides/agent-harness.md
@@ -261,15 +261,17 @@ task-intent parsing.
The harness is allowed to coordinate execution, but it should not bypass the
runtime safety model. Local-app work flows through typed contracts, catalog
-resolution, observation, dry-run projection, guardrails, and verification before
-or during live control.
+resolution, observation, evidence-backed action planning, guardrails, and
+verification before or during live control.
Local-app workflow progress is tracked outside prompt/context text. Each run
records typed stage state for intent parsing, task/app resolution, observation,
-dry-run projection, approval/review, guarded execution, and verification. The
-runner can derive projected agent visualization steps before live execution and
-verified visualization steps from runtime state plus action traces. The model
-can be told about this state, but the runner owns it.
+internal planning, approval/review, guarded execution, and verification.
+Evidence planning remains a background runtime concern: the handler should not
+publish a pre-execution visualization for normal live work. The runner derives
+agent visualization steps from observed evidence and action traces, and cursor
+playback requires Accessibility, screenshot-understanding, or action-trace
+targets. The model can be told about this state, but the runner owns it.
Live input remains guarded. The action engine checks permission policy, target
focus, rate limits, hold duration, and backend evidence before issuing input.
diff --git a/docs/guides/decision-system.md b/docs/guides/decision-system.md
index 5b9637d7..a833d6d9 100644
--- a/docs/guides/decision-system.md
+++ b/docs/guides/decision-system.md
@@ -86,18 +86,21 @@ The catalog resolves dynamic targets through the agent memory store, Spotlight/a
- every planned tool is in the allowlist
- the plan can be represented as guarded workflow steps
-The live runner then owns launch/focus, observation, dry-run projection, guarded
-execution, verification, and agent visualization evidence. Accessibility and
-keyboard input run through action-engine guardrails. AppleScript may be used
-only when supplied by typed task metadata or validated generated artifacts;
-free-form planner text is never direct input.
+The live runner then owns launch/focus, observation, evidence-backed action
+planning, guarded execution, verification, and agent visualization evidence.
+Accessibility and keyboard input run through action-engine guardrails.
+AppleScript may be used only when supplied by typed task metadata or validated
+generated artifacts; free-form planner text is never direct input.
Agent visualization is evidence-derived, not a separate command path for real
-work. Normal local-app tasks emit a projected `AgentVisualizationPlan` before
-execution, then may emit a verified plan from dry-run steps, observations, and
-action traces. Visual-only demonstration requests use the same plan shape with
-`executionMode=visualOnly` and no live input. In both cases, the overlay cursor
-is a visualization surface only and does not move the real macOS pointer.
+work. Normal local-app tasks may emit a final plan from evidence-backed action
+steps, observations, and action traces after the runner has evidence; they do
+not publish a pre-execution visualization from intent resolution. Cursor
+playback only uses steps with grounded control bounds or action targets, so
+background planning does not animate to invented points. Visual-only
+demonstration requests use the same plan shape with `executionMode=visualOnly`
+and no live input. In both cases, the overlay cursor is a visualization surface
+only and does not move the real macOS pointer.
## Learning Boundary
diff --git a/docs/guides/pointer-prompt-overlay.md b/docs/guides/pointer-prompt-overlay.md
index d17efc6e..93a465d4 100644
--- a/docs/guides/pointer-prompt-overlay.md
+++ b/docs/guides/pointer-prompt-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 may create a projected `AgentVisualizationPlan` once the workflow is resolved, but cursor playback waits for runtime evidence such as dry-run steps, observations, and action traces 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 screenshot-understanding 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 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 screenshot-understanding 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.
- 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.
@@ -47,7 +47,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 loaded from agent memory; Weather, Music, and Preview definitions are benchmark fixtures unless a generated/user-reviewed definition for them is present in memory.
- For scriptable apps, prefer app-native AppleScript task commands before falling back to Accessibility or keyboard input. Submit steps with an explicit structured `controlID` may execute as an Accessibility `AXPress` against button-like controls, with the control bounds carried into action traces. Bounded screenshots may supplement observation/verification according to task metadata, but screenshots remain context evidence and do not directly drive input.
-- 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 dry run is based on an observation, preserve target-window geometry and control bounds on the dry-run 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.
- Task actions in the notch, including follow-up submission and pause/resume, must cross the model/controller command boundary with the selected task ID.
- Pointer prompt command handling should emit actionable `com.donkey.app` route/result logs for submitted commands, routing decisions, intent resolution, local action traces, unsupported requests, unavailable apps, and final task status. Action trace logs should state the backend, input mode, whether an element click happened, the control or bounds target, and that the overlay pointer is visual-only.
@@ -64,7 +64,7 @@ Manually verify:
- With multiple spawned cursors visible, clicking a cursor selects it; double-Command still opens the centered prompt, and the submitted typed or voice turn routes to the selected/latest cursor's task without opening the inline label editor.
- Open requests for installed apps, files, and folders launch or open the local item; missing local items show a not-found result and log the lookup provider/reason.
- LLM-classified visual-only prompts complete as visualization turns and show the animated cursor with typed labels without moving the real pointer.
-- Normal local-app tasks can produce visualization steps for planning, observing, navigating, acting, and verifying. The visualization should target observed control centers from Accessibility or screenshot understanding when those bounds exist, and must not claim completion unless the runtime verification state supports it.
+- Normal local-app tasks can produce final visualization steps for observed, navigated, acted, and verified runtime work. Planning stays in the background. Cursor playback should target observed control centers from Accessibility, screenshot understanding, or action traces when those bounds exist, omit ungrounded steps, and must not claim completion unless the runtime verification state supports it.
- The prompt supports wrapping, Shift-Return newline insertion, Return submission, Escape dismissal, outside-click dismissal, and dragging from non-input areas.
- File drops on the notch attach to the active or most recent task.