Skip to content

Open source CapCut alternative.

TypeScript

Route pointer prompt through generic harness

David Lea7c2601a09b6
diff --git a/apps/Donkey/Package.swift b/apps/Donkey/Package.swift
index 7a2a86a1..17b8444e 100644
--- a/apps/Donkey/Package.swift
+++ b/apps/Donkey/Package.swift
@@ -38,7 +38,10 @@ let package = Package(
),
.target(
name: "DonkeyRuntime",
- dependencies: ["DonkeyContracts"],
+ dependencies: [
+ "DonkeyContracts",
+ "DonkeyHarness"
+ ],
resources: [
.process("Resources")
],
@@ -62,6 +65,7 @@ let package = Package(
dependencies: [
"DonkeyAI",
"DonkeyContracts",
+ "DonkeyHarness",
"DonkeyRuntime",
"DonkeyUI",
.product(name: "Sparkle", package: "Sparkle")
diff --git a/apps/Donkey/Sources/Donkey/PointerPromptCommandHandler.swift b/apps/Donkey/Sources/Donkey/PointerPromptCommandHandler.swift
index 144cf884..fb1c444b 100644
--- a/apps/Donkey/Sources/Donkey/PointerPromptCommandHandler.swift
+++ b/apps/Donkey/Sources/Donkey/PointerPromptCommandHandler.swift
@@ -1,5 +1,6 @@
import DonkeyAI
import DonkeyContracts
+import DonkeyHarness
import DonkeyRuntime
import Foundation
import OSLog
@@ -71,6 +72,7 @@ struct LocalAppPointerPromptCommandHandler: PointerPromptCommandHandling {
var redactor: AIHarnessRedactor
var memoryRetriever: SemanticRunMemoryRetriever
var coordinatorRegistry: PointerPromptRunCoordinatorRegistry
+ var genericHarnessLifecycle: AppHarnessGenericLifecycle
var memoryStore: SQLiteAgentMemoryStore?
var agentVisualizationPlanResolver: any AgentVisualizationPlanResolving
@@ -81,6 +83,7 @@ struct LocalAppPointerPromptCommandHandler: PointerPromptCommandHandling {
redactor: AIHarnessRedactor = AIHarnessRedactor(),
memoryRetriever: SemanticRunMemoryRetriever = SemanticRunMemoryRetriever(),
coordinatorRegistry: PointerPromptRunCoordinatorRegistry = PointerPromptRunCoordinatorRegistry(),
+ genericHarnessLifecycle: AppHarnessGenericLifecycle = AppHarnessGenericLifecycle(),
memoryStore: SQLiteAgentMemoryStore? = .shared,
agentVisualizationPlanResolver: any AgentVisualizationPlanResolving = DisabledAgentVisualizationPlanResolver()
) {
@@ -96,6 +99,7 @@ struct LocalAppPointerPromptCommandHandler: PointerPromptCommandHandling {
)
self.redactor = redactor
self.memoryRetriever = memoryRetriever
+ self.genericHarnessLifecycle = genericHarnessLifecycle
self.memoryStore = memoryStore
self.agentVisualizationPlanResolver = agentVisualizationPlanResolver
}
@@ -172,10 +176,18 @@ struct LocalAppPointerPromptCommandHandler: PointerPromptCommandHandling {
traceID: String,
taskID: String
) async -> PointerPromptCommandHandlingResult {
+ let harnessRequest = Self.harnessRequest(command: command, context: context)
let routing = appHarnessRouter.route(
- request: Self.harnessRequest(command: command, context: context),
+ request: harnessRequest,
traceID: traceID
)
+ let genericPreparedTurn = await genericHarnessLifecycle.preparePointerPromptTurn(
+ request: harnessRequest,
+ pointerTask: context?.task,
+ traceID: traceID,
+ availableToolNames: Self.genericHarnessToolNames(),
+ grantedPermissions: Self.pointerPromptGrantedPermissions
+ )
logRouting(command: command, traceID: traceID, taskID: taskID, routing: routing)
switch routing.outcome.decision.kind {
case .respond:
@@ -186,11 +198,16 @@ struct LocalAppPointerPromptCommandHandler: PointerPromptCommandHandling {
summary: routing.outcome.assistantResponse ?? "Tell me what local app task you want to work on.",
taskLabel: nil,
traceID: traceID,
- metadata: Self.contextPacketMetadata(routing.contextPacket, outcome: routing.outcome),
+ metadata: Self.contextPacketMetadata(routing.contextPacket, outcome: routing.outcome)
+ .merging(Self.genericHarnessMetadata(preparedTurn: genericPreparedTurn)) { current, _ in current },
documentReviewRequest: nil,
agentVisualizationPlan: nil,
cursorOverlayRequest: nil
)
+ _ = await genericHarnessLifecycle.coordinator.complete(
+ taskID: genericPreparedTurn.task.id,
+ reason: "Pointer prompt routed to conversation response"
+ )
logHandlingResult(result, stage: "conversation", hint: routingHint(for: routing))
return result
case .askClarification:
@@ -201,11 +218,17 @@ struct LocalAppPointerPromptCommandHandler: PointerPromptCommandHandling {
summary: routing.outcome.assistantResponse ?? "What detail should I use?",
taskLabel: nil,
traceID: traceID,
- metadata: Self.contextPacketMetadata(routing.contextPacket, outcome: routing.outcome),
+ metadata: Self.contextPacketMetadata(routing.contextPacket, outcome: routing.outcome)
+ .merging(Self.genericHarnessMetadata(preparedTurn: genericPreparedTurn)) { current, _ in current },
documentReviewRequest: nil,
agentVisualizationPlan: nil,
cursorOverlayRequest: nil
)
+ _ = await genericHarnessLifecycle.coordinator.waitForUser(
+ taskID: genericPreparedTurn.task.id,
+ question: result.summary,
+ reason: "Pointer prompt routing needs clarification"
+ )
logHandlingResult(result, stage: "routing", hint: routingHint(for: routing))
return result
case .noOp:
@@ -216,11 +239,16 @@ struct LocalAppPointerPromptCommandHandler: PointerPromptCommandHandling {
summary: "",
taskLabel: nil,
traceID: traceID,
- metadata: Self.contextPacketMetadata(routing.contextPacket, outcome: routing.outcome),
+ metadata: Self.contextPacketMetadata(routing.contextPacket, outcome: routing.outcome)
+ .merging(Self.genericHarnessMetadata(preparedTurn: genericPreparedTurn)) { current, _ in current },
documentReviewRequest: nil,
agentVisualizationPlan: nil,
cursorOverlayRequest: nil
)
+ _ = await genericHarnessLifecycle.coordinator.complete(
+ taskID: genericPreparedTurn.task.id,
+ reason: "Pointer prompt empty turn"
+ )
logHandlingResult(result, stage: "empty", hint: "Empty command; no action was run.")
return result
case .openReview, .runLocalTask:
@@ -283,7 +311,9 @@ struct LocalAppPointerPromptCommandHandler: PointerPromptCommandHandling {
"semanticMemory.recordIDs": semanticMemoryResults.map(\.record.id).joined(separator: ","),
"semanticMemory.targetID": semanticMemoryTargetID(for: resolution) ?? "",
"memoryProposal.decisionCount": String(memoryProposalDecisions.count)
- ].merging(Self.contextMetadata(context)) { current, _ in current }
+ ]
+ .merging(Self.contextMetadata(context)) { current, _ in current }
+ .merging(Self.genericHarnessMetadata(preparedTurn: genericPreparedTurn)) { current, _ in current }
await coordinator.recordToolEvent(
capability: .model,
@@ -329,6 +359,10 @@ struct LocalAppPointerPromptCommandHandler: PointerPromptCommandHandling {
agentVisualizationPlan: nil,
cursorOverlayRequest: nil
)
+ _ = await genericHarnessLifecycle.coordinator.complete(
+ taskID: taskID,
+ reason: "Pointer prompt conversation response"
+ )
await coordinatorRegistry.finish(taskID: taskID)
logHandlingResult(
handlingResult,
@@ -338,11 +372,55 @@ struct LocalAppPointerPromptCommandHandler: PointerPromptCommandHandling {
return handlingResult
}
- let result = await taskLiveRunner.run(
+ _ = await genericHarnessLifecycle.planLocalTaskRun(
+ taskID: taskID,
+ resolution: resolution,
+ fallbackGoal: commandRedaction.redactedText,
+ traceID: traceID
+ )
+ let localRunResults = PointerPromptHarnessLocalRunResultStore()
+ let registry = BuiltInHarnessToolCatalog.registryWithStubExecutors()
+ let harnessTaskLiveRunner = taskLiveRunner
+ await registry.register(
+ HarnessTool(
+ descriptor: AppHarnessGenericLifecycle.localTaskRunDescriptor()
+ ) { toolContext in
+ let localResult = await harnessTaskLiveRunner.run(
+ command: commandRedaction.redactedText,
+ traceID: traceID,
+ resolution: resolution,
+ metadata: modelMetadata.merging([
+ "genericHarness.taskID": toolContext.taskID,
+ "genericHarness.toolCallID": toolContext.call.id
+ ]) { current, _ in current }
+ )
+ await localRunResults.store(localResult, callID: toolContext.call.id)
+ return Self.harnessToolResult(
+ for: localResult,
+ call: toolContext.call
+ )
+ }
+ )
+ let genericRuntime = GenericHarnessRuntime(
+ coordinator: genericHarnessLifecycle.coordinator,
+ registry: registry
+ )
+ let runStep = await genericRuntime.executeNextPlannedStep(taskID: taskID)
+ let result = await localRunResults.firstResult() ?? LocalAppTaskLiveRunResult(
command: commandRedaction.redactedText,
traceID: traceID,
+ status: .failedSafe,
resolution: resolution,
- metadata: modelMetadata
+ metadata: [
+ "reason": "genericHarnessMissingLocalRunResult",
+ "genericHarness.stoppedForGate": String(runStep?.stoppedForGate ?? false)
+ ]
+ )
+ let finalized = await finalizeGenericHarnessTask(
+ taskID: taskID,
+ result: result,
+ runStep: runStep,
+ runtime: genericRuntime
)
logActionTraces(for: result)
@@ -354,12 +432,18 @@ struct LocalAppPointerPromptCommandHandler: PointerPromptCommandHandling {
status: result.status,
threadStatus: threadStatus(for: result),
decision: routing.outcome.decision,
- summary: summary(for: result),
+ summary: summary(for: result, runStep: runStep),
taskLabel: taskLabel(for: result),
traceID: traceID,
metadata: result.metadata.merging(
Self.contextPacketMetadata(routing.contextPacket, outcome: routing.outcome)
- ) { current, _ in current },
+ ) { current, _ in current }
+ .merging(Self.genericHarnessMetadata(
+ preparedTurn: genericPreparedTurn,
+ runStep: runStep,
+ verificationStep: finalized.verificationStep,
+ recoveryStep: finalized.recoveryStep
+ )) { current, _ in current },
documentReviewRequest: documentReviewRequest(
traceID: traceID,
result: result
@@ -377,17 +461,91 @@ struct LocalAppPointerPromptCommandHandler: PointerPromptCommandHandling {
}
func pauseCommand(taskID: String) async -> Bool {
- await coordinatorRegistry.pause(
+ let genericPaused = await genericHarnessLifecycle.pauseTask(
+ taskID: taskID,
+ reason: "Pointer prompt paused task"
+ ) != nil
+ let oldRunnerPaused = await coordinatorRegistry.pause(
taskID: taskID,
reason: "Pointer prompt paused task"
)
+ return genericPaused || oldRunnerPaused
}
func resumeCommand(taskID: String) async -> Bool {
- await coordinatorRegistry.resume(
+ let genericResumed = await genericHarnessLifecycle.resumeTask(
+ taskID: taskID,
+ reason: "Pointer prompt resumed task"
+ ) != nil
+ let oldRunnerResumed = await coordinatorRegistry.resume(
taskID: taskID,
reason: "Pointer prompt resumed task"
)
+ return genericResumed || oldRunnerResumed
+ }
+
+ private func finalizeGenericHarnessTask(
+ taskID: String,
+ result: LocalAppTaskLiveRunResult,
+ runStep: HarnessStepExecutionResult?,
+ runtime: GenericHarnessRuntime
+ ) async -> PointerPromptGenericFinalizeResult {
+ switch result.status {
+ case .completed:
+ let verificationStep = await runtime.executeNextPlannedStep(taskID: taskID)
+ if verificationStep?.toolResult?.status == .failed {
+ let recoveryStep = await recoverGenericHarnessTask(
+ taskID: taskID,
+ reason: verificationStep?.toolResult?.summary ?? "Verification failed",
+ traceID: result.traceID,
+ runtime: runtime
+ )
+ _ = await genericHarnessLifecycle.coordinator.failSafe(
+ taskID: taskID,
+ reason: "Pointer prompt verification failed"
+ )
+ return PointerPromptGenericFinalizeResult(
+ verificationStep: verificationStep,
+ recoveryStep: recoveryStep
+ )
+ }
+
+ _ = await genericHarnessLifecycle.coordinator.complete(
+ taskID: taskID,
+ reason: "Pointer prompt local task completed"
+ )
+ return PointerPromptGenericFinalizeResult(verificationStep: verificationStep)
+ case .needsUserReview, .needsConfirmation, .unsupportedCommand:
+ return PointerPromptGenericFinalizeResult()
+ case .appUnavailable, .failedSafe:
+ let recoveryStep = await recoverGenericHarnessTask(
+ taskID: taskID,
+ reason: summary(for: result, runStep: runStep),
+ traceID: result.traceID,
+ runtime: runtime
+ )
+ _ = await genericHarnessLifecycle.coordinator.failSafe(
+ taskID: taskID,
+ reason: summary(for: result, runStep: runStep)
+ )
+ return PointerPromptGenericFinalizeResult(
+ recoveryStep: recoveryStep
+ )
+ }
+ }
+
+ private func recoverGenericHarnessTask(
+ taskID: String,
+ reason: String,
+ traceID: String,
+ runtime: GenericHarnessRuntime
+ ) async -> HarnessStepExecutionResult? {
+ _ = await genericHarnessLifecycle.planRecovery(
+ taskID: taskID,
+ reason: reason,
+ traceID: traceID
+ )
+ return await runtime.executeNextPlannedStep(taskID: taskID)
}
private func groundAgentVisualizationPlan(_ plan: AgentVisualizationPlan) -> AgentVisualizationPlan {
@@ -720,6 +878,18 @@ struct LocalAppPointerPromptCommandHandler: PointerPromptCommandHandling {
}
}
+ private func summary(
+ for result: LocalAppTaskLiveRunResult,
+ runStep: HarnessStepExecutionResult?
+ ) -> String {
+ if let question = runStep?.task.pendingContinuation?.question,
+ !question.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty {
+ return question
+ }
+
+ return summary(for: result)
+ }
+
private func threadStatus(for result: LocalAppTaskLiveRunResult) -> PointerPromptTaskStatus {
switch result.status {
case .completed:
@@ -831,6 +1001,69 @@ struct LocalAppPointerPromptCommandHandler: PointerPromptCommandHandling {
.sorted()
}
+ private static var pointerPromptGrantedPermissions: Set<HarnessPermission> {
+ [.conversation, .userPrompt, .verification, .lifecycle]
+ }
+
+ private static func genericHarnessToolNames() -> [String] {
+ (BuiltInHarnessToolCatalog.descriptors.map(\.name) + [
+ AppHarnessGenericLifecycleToolNames.localAppRun
+ ]).sorted()
+ }
+
+ private static func harnessToolResult(
+ for result: LocalAppTaskLiveRunResult,
+ call: HarnessToolCall
+ ) -> HarnessToolResult {
+ let toolStatus: HarnessToolResultStatus
+ let question: String?
+ switch result.status {
+ case .completed:
+ toolStatus = .succeeded
+ question = nil
+ case .needsUserReview:
+ toolStatus = .waitingForUser
+ question = "Review the proposed changes before I continue."
+ case .needsConfirmation:
+ toolStatus = .waitingForUser
+ question = "What detail should I use?"
+ case .unsupportedCommand:
+ toolStatus = .waitingForUser
+ question = "What local app task should I run?"
+ case .appUnavailable, .failedSafe:
+ toolStatus = .failed
+ question = nil
+ }
+
+ return HarnessToolResult(
+ callID: call.id,
+ toolName: call.name,
+ status: toolStatus,
+ summary: "Local app task \(result.status.rawValue).",
+ observations: HarnessObservationDelta(
+ focusedApp: result.resolution.availability?.target.appName,
+ facts: [
+ "localApp.status": result.status.rawValue,
+ "localApp.resolutionStatus": result.resolution.status.rawValue,
+ "localApp.taskType": result.resolution.intent?.taskType
+ ?? result.resolution.definition?.taskType
+ ?? "",
+ "localApp.targetApp": result.resolution.intent?.targetApp.appName
+ ?? result.resolution.definition?.targetApp.appName
+ ?? result.resolution.availability?.target.appName
+ ?? ""
+ ].merging(result.metadata) { current, _ in current },
+ uncertainty: result.status == .completed ? [] : [result.status.rawValue]
+ ),
+ question: question,
+ metadata: [
+ "executor": "LocalAppTaskLiveRunner",
+ "localApp.status": result.status.rawValue,
+ "traceID": result.traceID
+ ]
+ )
+ }
+
private static func harnessRequest(
command: String,
context: PointerPromptCommandContext?
@@ -865,6 +1098,29 @@ struct LocalAppPointerPromptCommandHandler: PointerPromptCommandHandling {
]
}
+ private static func genericHarnessMetadata(
+ preparedTurn: AppHarnessGenericLifecyclePreparedTurn,
+ runStep: HarnessStepExecutionResult? = nil,
+ verificationStep: HarnessStepExecutionResult? = nil,
+ recoveryStep: HarnessStepExecutionResult? = nil
+ ) -> [String: String] {
+ [
+ "genericHarness.threadID": preparedTurn.thread.id,
+ "genericHarness.taskID": preparedTurn.task.id,
+ "genericHarness.taskStatus": (runStep?.task.status ?? preparedTurn.task.status).rawValue,
+ "genericHarness.context.promptCharacters": String(preparedTurn.compactedContext.promptText.count),
+ "genericHarness.context.eventCount": String(preparedTurn.compactedContext.events.count),
+ "genericHarness.context.assetCount": String(preparedTurn.compactedContext.assets.count),
+ "genericHarness.context.activeTaskCount": String(preparedTurn.compactedContext.activeTasks.count),
+ "genericHarness.context.compactionRecordCount": String(preparedTurn.compactedContext.compactionRecords.count),
+ "genericHarness.runToolStatus": runStep?.toolResult?.status.rawValue ?? "",
+ "genericHarness.runStoppedForGate": runStep.map { String($0.stoppedForGate) } ?? "",
+ "genericHarness.verificationToolStatus": verificationStep?.toolResult?.status.rawValue ?? "",
+ "genericHarness.recoveryToolStatus": recoveryStep?.toolResult?.status.rawValue ?? "",
+ "genericHarness.pendingQuestion": runStep?.task.pendingContinuation?.question ?? ""
+ ]
+ }
+
private static func contextMetadata(_ context: PointerPromptCommandContext?) -> [String: String] {
guard let context else { return [:] }
@@ -877,6 +1133,31 @@ struct LocalAppPointerPromptCommandHandler: PointerPromptCommandHandling {
}
}
+private struct PointerPromptGenericFinalizeResult: Equatable, Sendable {
+ var verificationStep: HarnessStepExecutionResult?
+ var recoveryStep: HarnessStepExecutionResult?
+
+ init(
+ verificationStep: HarnessStepExecutionResult? = nil,
+ recoveryStep: HarnessStepExecutionResult? = nil
+ ) {
+ self.verificationStep = verificationStep
+ self.recoveryStep = recoveryStep
+ }
+}
+
+private actor PointerPromptHarnessLocalRunResultStore {
+ private var resultsByCallID: [String: LocalAppTaskLiveRunResult] = [:]
+
+ func store(_ result: LocalAppTaskLiveRunResult, callID: String) {
+ resultsByCallID[callID] = result
+ }
+
+ func firstResult() -> LocalAppTaskLiveRunResult? {
+ resultsByCallID.values.first
+ }
+}
+
actor PointerPromptRunCoordinatorRegistry {
private var coordinators: [String: RunCoordinator] = [:]
diff --git a/apps/Donkey/Sources/DonkeyHarness/GenericHarnessCoordinator.swift b/apps/Donkey/Sources/DonkeyHarness/GenericHarnessCoordinator.swift
index 03f10bb3..f6ea9289 100644
--- a/apps/Donkey/Sources/DonkeyHarness/GenericHarnessCoordinator.swift
+++ b/apps/Donkey/Sources/DonkeyHarness/GenericHarnessCoordinator.swift
@@ -158,6 +158,15 @@ public actor HarnessTaskCoordinator {
}
}
+ public func updateContext(
+ taskID: String,
+ context: HarnessContextSnapshot
+ ) -> HarnessTaskState? {
+ mutate(taskID: taskID, summary: "Context updated") { task in
+ task.context = context
+ }
+ }
+
public func updatePlan(
taskID: String,
plan: HarnessPlan
@@ -186,6 +195,12 @@ public actor HarnessTaskCoordinator {
}
}
+ public func startRunning(taskID: String, reason: String = "Task running") -> HarnessTaskState? {
+ mutate(taskID: taskID, status: .running, summary: reason) { task in
+ task.pendingContinuation = nil
+ }
+ }
+
public func cancel(taskID: String, reason: String = "Task cancelled") -> HarnessTaskState? {
mutate(taskID: taskID, status: .cancelled, summary: reason) { task in
task.pendingContinuation = nil
@@ -343,4 +358,3 @@ public actor HarnessTaskCoordinator {
eventsByTaskID[taskID] = events
}
}
-
diff --git a/apps/Donkey/Sources/DonkeyHarness/GenericHarnessRuntime.swift b/apps/Donkey/Sources/DonkeyHarness/GenericHarnessRuntime.swift
index 3aff0f53..2e6d3f6c 100644
--- a/apps/Donkey/Sources/DonkeyHarness/GenericHarnessRuntime.swift
+++ b/apps/Donkey/Sources/DonkeyHarness/GenericHarnessRuntime.swift
@@ -122,6 +122,36 @@ public struct GenericHarnessRuntime: Sendable {
)
}
+ if result.status == .waitingForUser {
+ guard let stoppedTask = await coordinator.waitForUser(
+ taskID: taskID,
+ question: result.question ?? "What detail should I use?",
+ pendingToolCall: call
+ ) else {
+ return nil
+ }
+ return HarnessStepExecutionResult(
+ task: stoppedTask,
+ toolResult: result,
+ stoppedForGate: true
+ )
+ }
+
+ if result.status == .waitingForPermission {
+ guard let stoppedTask = await coordinator.waitForPermission(
+ taskID: taskID,
+ missingPermissions: result.missingPermissions,
+ pendingToolCall: call
+ ) else {
+ return nil
+ }
+ return HarnessStepExecutionResult(
+ task: stoppedTask,
+ toolResult: result,
+ stoppedForGate: true
+ )
+ }
+
guard let updatedTask = await coordinator.recordToolResult(
taskID: taskID,
call: call,
@@ -151,4 +181,3 @@ public struct GenericHarnessRuntime: Sendable {
return await executeToolCall(taskID: taskID, call: call)
}
}
-
diff --git a/apps/Donkey/Sources/DonkeyRuntime/AppHarnessGenericLifecycle.swift b/apps/Donkey/Sources/DonkeyRuntime/AppHarnessGenericLifecycle.swift
new file mode 100644
index 00000000..029129f2
--- /dev/null
+++ b/apps/Donkey/Sources/DonkeyRuntime/AppHarnessGenericLifecycle.swift
@@ -0,0 +1,442 @@
+import DonkeyContracts
+import DonkeyHarness
+import Foundation
+
+public enum AppHarnessGenericLifecycleToolNames {
+ public static let localAppRun = "pointer-prompt.local-app.run"
+}
+
+public struct AppHarnessGenericLifecyclePreparedTurn: Equatable, Sendable {
+ public var thread: HarnessThread
+ public var task: HarnessTaskState
+ public var compactedContext: HarnessCompactedThreadContext
+
+ public init(
+ thread: HarnessThread,
+ task: HarnessTaskState,
+ compactedContext: HarnessCompactedThreadContext
+ ) {
+ self.thread = thread
+ self.task = task
+ self.compactedContext = compactedContext
+ }
+}
+
+public struct AppHarnessGenericLifecycle: Sendable {
+ public var threadStore: any HarnessThreadStoring
+ public var coordinator: HarnessTaskCoordinator
+ public var compactor: HarnessThreadCompactor
+
+ public init(
+ threadStore: any HarnessThreadStoring = InMemoryHarnessThreadStore(),
+ coordinator: HarnessTaskCoordinator = HarnessTaskCoordinator(),
+ compactor: HarnessThreadCompactor = HarnessThreadCompactor()
+ ) {
+ self.threadStore = threadStore
+ self.coordinator = coordinator
+ self.compactor = compactor
+ }
+
+ public func preparePointerPromptTurn(
+ request: AppHarnessTurnRequest,
+ pointerTask: PointerPromptNotchTask?,
+ traceID: String,
+ availableToolNames: [String],
+ grantedPermissions: Set<HarnessPermission> = []
+ ) async -> AppHarnessGenericLifecyclePreparedTurn {
+ let threadID = request.turn.taskID ?? pointerTask?.id ?? traceID
+ let taskID = pointerTask?.id ?? request.turn.taskID ?? threadID
+ let title = pointerTask?.title ?? request.turn.text
+ let now = Date()
+ let existingThread = await threadStore.thread(id: threadID)
+ let activeTaskIDs = Array(Set((existingThread?.activeTaskIDs ?? []) + [taskID])).sorted()
+ let thread = HarnessThread(
+ id: threadID,
+ title: existingThread?.title ?? title,
+ status: .running,
+ activeTaskIDs: activeTaskIDs,
+ createdAt: existingThread?.createdAt ?? now,
+ updatedAt: now,
+ metadata: (existingThread?.metadata ?? [:]).merging([
+ "source": "pointerPrompt",
+ "traceID": traceID
+ ]) { current, _ in current }
+ )
+ await threadStore.upsertThread(thread)
+ await mirrorPointerPromptEvents(
+ request.recentEvents,
+ threadID: threadID,
+ taskID: taskID
+ )
+ await mirrorPointerPromptAssets(
+ request.assets,
+ threadID: threadID,
+ taskID: taskID
+ )
+ await appendCurrentTurnIfNeeded(
+ request.turn,
+ threadID: threadID,
+ taskID: taskID
+ )
+
+ let context = HarnessContextSnapshot(
+ turn: request.turn,
+ threadID: threadID,
+ memory: request.memory,
+ availableToolNames: availableToolNames,
+ policy: request.policy,
+ metadata: [
+ "traceID": traceID,
+ "source": "pointerPrompt"
+ ]
+ )
+ let task = await loadOrCreateTask(
+ taskID: taskID,
+ threadID: threadID,
+ goal: request.turn.text,
+ context: context,
+ grantedPermissions: grantedPermissions
+ )
+ let events = await threadStore.events(threadID: threadID)
+ let assets = await threadStore.assets(threadID: threadID)
+ let activeTasks = await coordinator.activeTasks()
+ .filter { $0.threadID == threadID }
+ let compactedContext = compactor.compact(
+ thread: thread,
+ currentTurn: request.turn,
+ events: events,
+ assets: assets,
+ activeTasks: activeTasks
+ )
+
+ return AppHarnessGenericLifecyclePreparedTurn(
+ thread: thread,
+ task: task,
+ compactedContext: compactedContext
+ )
+ }
+
+ @discardableResult
+ public func planLocalTaskRun(
+ taskID: String,
+ resolution: LocalAppTaskCatalogResolution,
+ fallbackGoal: String,
+ traceID: String
+ ) async -> HarnessTaskState? {
+ let intent = Self.intentAnalysis(
+ for: resolution,
+ fallbackGoal: fallbackGoal
+ )
+ _ = await coordinator.updateIntent(taskID: taskID, intent: intent)
+ let plan = HarnessPlan(
+ goal: intent.goal,
+ steps: [
+ HarnessPlanStep(
+ id: "run-local-app-task",
+ summary: "Run the resolved local app task through the generic harness executor.",
+ toolCall: HarnessToolCall(
+ id: "local-app-run-\(traceID)",
+ name: AppHarnessGenericLifecycleToolNames.localAppRun,
+ input: [
+ "resolutionStatus": resolution.status.rawValue,
+ "taskType": resolution.intent?.taskType ?? resolution.definition?.taskType ?? "",
+ "targetApp": resolution.intent?.targetApp.appName
+ ?? resolution.definition?.targetApp.appName
+ ?? resolution.availability?.target.appName
+ ?? ""
+ ],
+ metadata: [
+ "adapter": "pointerPrompt",
+ "traceID": traceID
+ ]
+ ),
+ expectedObservation: "Local app task reaches a terminal or waiting state."
+ ),
+ HarnessPlanStep(
+ id: "verify-local-app-task",
+ summary: "Verify the local app task result.",
+ toolCall: HarnessToolCall(
+ id: "local-app-verify-\(traceID)",
+ name: "state.verify",
+ input: ["criteria": "Use the local app task result status and verification metadata."],
+ metadata: [
+ "adapter": "pointerPrompt",
+ "traceID": traceID
+ ]
+ ),
+ expectedObservation: "Verification records success criteria or evidence."
+ )
+ ],
+ successCriteria: ["Resolved local app result is completed or handed to a user gate."],
+ fallbackPolicy: ["If execution needs review or missing detail, stop at the user gate."],
+ clarificationPolicy: ["Ask a specific follow-up question when the resolved task is incomplete."],
+ confidence: intent.confidence,
+ metadata: [
+ "planner": "genericHarnessPointerPromptBridge",
+ "traceID": traceID,
+ "resolution.status": resolution.status.rawValue
+ ]
+ )
+ _ = await coordinator.updatePlan(taskID: taskID, plan: plan)
+ return await coordinator.startRunning(
+ taskID: taskID,
+ reason: "Pointer prompt task planned through generic harness"
+ )
+ }
+
+ @discardableResult
+ public func planRecovery(
+ taskID: String,
+ reason: String,
+ traceID: String
+ ) async -> HarnessTaskState? {
+ guard let task = await coordinator.task(id: taskID) else { return nil }
+
+ let plan = HarnessPlan(
+ goal: task.goal,
+ steps: [
+ HarnessPlanStep(
+ id: "recover-local-app-task",
+ summary: "Recover from an unsuccessful pointer-prompt local app task.",
+ toolCall: HarnessToolCall(
+ id: "local-app-recover-\(traceID)",
+ name: "run.recover",
+ input: ["reason": reason],
+ metadata: [
+ "adapter": "pointerPrompt",
+ "traceID": traceID
+ ]
+ ),
+ expectedObservation: "Recovery records a safe fallback or updated task evidence."
+ )
+ ],
+ successCriteria: ["Recovery stops safely or prepares a future continuation."],
+ fallbackPolicy: ["If recovery cannot proceed, leave the task failed safe."],
+ clarificationPolicy: ["Ask only if a specific missing user detail would let the task continue."],
+ confidence: task.intent?.confidence ?? 0,
+ metadata: [
+ "planner": "genericHarnessPointerPromptRecovery",
+ "traceID": traceID,
+ "recovery.reason": reason
+ ]
+ )
+ _ = await coordinator.updatePlan(taskID: taskID, plan: plan)
+ return await coordinator.startRunning(
+ taskID: taskID,
+ reason: "Pointer prompt recovery planned through generic harness"
+ )
+ }
+
+ public func taskState(taskID: String) async -> HarnessTaskState? {
+ await coordinator.task(id: taskID)
+ }
+
+ @discardableResult
+ public func pauseTask(taskID: String, reason: String) async -> HarnessTaskState? {
+ await coordinator.pause(taskID: taskID, reason: reason)
+ }
+
+ @discardableResult
+ public func resumeTask(taskID: String, reason: String) async -> HarnessTaskState? {
+ await coordinator.resume(taskID: taskID, reason: reason)
+ }
+
+ public static func localTaskRunDescriptor() -> HarnessToolDescriptor {
+ HarnessToolDescriptor(
+ name: AppHarnessGenericLifecycleToolNames.localAppRun,
+ pluginID: "pointer-prompt.migration",
+ summary: "Execute a resolved pointer-prompt local app task as one generic harness step.",
+ inputSchema: [
+ "resolutionStatus": "Resolved, waiting, unsupported, or unavailable local app task status.",
+ "taskType": "Resolved local app task type.",
+ "targetApp": "Resolved local app target name."
+ ],
+ outputSchema: ["status": "Local app task terminal status and metadata."],
+ requiredPermissions: [],
+ safetyClass: .guardedInput,
+ requiredContext: ["structured intent", "local app task resolution", "generic harness task"],
+ verificationHints: ["Run state.verify after this step records its terminal evidence."],
+ metadata: [
+ "migrationBridge": "true",
+ "legacyBackend": "LocalAppTaskLiveRunner"
+ ]
+ )
+ }
+
+ private func loadOrCreateTask(
+ taskID: String,
+ threadID: String,
+ goal: String,
+ context: HarnessContextSnapshot,
+ grantedPermissions: Set<HarnessPermission>
+ ) async -> HarnessTaskState {
+ guard let existing = await coordinator.task(id: taskID) else {
+ return await coordinator.createTask(
+ id: taskID,
+ threadID: threadID,
+ goal: goal,
+ context: context,
+ grantedPermissions: grantedPermissions
+ )
+ }
+
+ if existing.status == .waitingForUser,
+ let response = context.turn?.text,
+ !response.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty {
+ _ = await coordinator.provideUserResponse(
+ taskID: taskID,
+ response: response
+ )
+ } else if context.turn?.isFollowUp == true {
+ _ = await coordinator.interrupt(
+ taskID: taskID,
+ newGoal: goal,
+ turn: context.turn,
+ reason: "Pointer prompt follow-up changed course"
+ )
+ _ = await coordinator.resume(
+ taskID: taskID,
+ reason: "Pointer prompt follow-up resumed task"
+ )
+ } else if !existing.status.canExecuteTools {
+ _ = await coordinator.resume(
+ taskID: taskID,
+ reason: "Pointer prompt resumed task"
+ )
+ }
+
+ return await coordinator.updateContext(
+ taskID: taskID,
+ context: context
+ ) ?? existing
+ }
+
+ private func mirrorPointerPromptEvents(
+ _ pointerEvents: [PointerPromptTaskEvent],
+ threadID: String,
+ taskID: String
+ ) async {
+ let existingIDs = Set(await threadStore.events(threadID: threadID).map(\.id))
+ for event in pointerEvents where !existingIDs.contains(event.id) {
+ await threadStore.appendEvent(
+ HarnessThreadEvent(
+ id: event.id,
+ threadID: threadID,
+ taskID: taskID,
+ role: HarnessThreadEventRole(pointerPromptRole: event.role),
+ text: event.text,
+ sequence: event.sequence,
+ createdAt: event.createdAt,
+ metadata: ["source": "pointerPromptTaskStore"]
+ )
+ )
+ }
+ }
+
+ private func mirrorPointerPromptAssets(
+ _ pointerAssets: [PointerPromptTaskAsset],
+ threadID: String,
+ taskID: String
+ ) async {
+ let existingIDs = Set(await threadStore.assets(threadID: threadID).map(\.id))
+ for asset in pointerAssets where !existingIDs.contains(asset.id) {
+ await threadStore.appendAsset(
+ HarnessThreadAsset(
+ id: asset.id,
+ threadID: threadID,
+ taskID: taskID,
+ eventID: asset.eventID,
+ displayName: asset.displayName,
+ contentType: asset.contentType,
+ urlString: asset.urlString,
+ byteCount: asset.byteCount,
+ createdAt: asset.createdAt,
+ metadata: [
+ "source": "pointerPromptTaskStore",
+ "assetSource": asset.source.rawValue
+ ]
+ )
+ )
+ }
+ }
+
+ private func appendCurrentTurnIfNeeded(
+ _ turn: AppHarnessTurn,
+ threadID: String,
+ taskID: String
+ ) async {
+ let events = await threadStore.events(threadID: threadID)
+ let hasCurrentTurn = events.contains { event in
+ event.metadata["turnID"] == turn.id
+ || (event.role == .user && event.text == turn.text)
+ }
+ guard !hasCurrentTurn else { return }
+
+ await threadStore.appendEvent(
+ HarnessThreadEvent(
+ id: "turn-\(turn.id)",
+ threadID: threadID,
+ taskID: taskID,
+ role: .user,
+ text: turn.text,
+ sequence: (events.map(\.sequence).max() ?? -1) + 1,
+ createdAt: turn.createdAt,
+ metadata: [
+ "source": "genericHarnessTurn",
+ "turnID": turn.id
+ ]
+ )
+ )
+ }
+
+ private static func intentAnalysis(
+ for resolution: LocalAppTaskCatalogResolution,
+ fallbackGoal: String
+ ) -> HarnessIntentAnalysis {
+ let taskType = resolution.intent?.taskType ?? resolution.definition?.taskType
+ let targetApp = resolution.intent?.targetApp.appName
+ ?? resolution.definition?.targetApp.appName
+ ?? resolution.availability?.target.appName
+ let goalParts = [
+ taskType,
+ targetApp.map { "in \($0)" }
+ ].compactMap { $0 }
+ let goal = goalParts.isEmpty ? fallbackGoal : goalParts.joined(separator: " ")
+ let missingInformation: [String]
+ if resolution.status == .needsConfirmation {
+ missingInformation = [resolution.metadata["reason"] ?? "more detail"]
+ } else {
+ missingInformation = []
+ }
+ return HarnessIntentAnalysis(
+ goal: goal,
+ entities: resolution.intent?.normalizedEntities ?? resolution.intent?.entities ?? [:],
+ ambiguityClass: resolution.status == .needsConfirmation ? .recoverable : .safe,
+ riskLevel: .medium,
+ missingInformation: missingInformation,
+ shouldAskBeforeActing: resolution.status == .needsConfirmation,
+ confidence: resolution.intent?.confidence ?? 0,
+ metadata: [
+ "resolution.status": resolution.status.rawValue,
+ "taskType": taskType ?? "",
+ "targetApp": targetApp ?? "",
+ "intentID": resolution.intent?.intentID ?? ""
+ ].merging(resolution.metadata) { current, _ in current }
+ )
+ }
+}
+
+private extension HarnessThreadEventRole {
+ init(pointerPromptRole: PointerPromptTaskEventRole) {
+ switch pointerPromptRole {
+ case .user:
+ self = .user
+ case .assistant:
+ self = .assistant
+ case .system:
+ self = .system
+ case .tool:
+ self = .tool
+ }
+ }
+}
diff --git a/apps/Donkey/Tests/DonkeyRuntimeTests/GenericHarnessTests.swift b/apps/Donkey/Tests/DonkeyRuntimeTests/GenericHarnessTests.swift
index 011d4ca2..7c852e93 100644
--- a/apps/Donkey/Tests/DonkeyRuntimeTests/GenericHarnessTests.swift
+++ b/apps/Donkey/Tests/DonkeyRuntimeTests/GenericHarnessTests.swift
@@ -1,5 +1,6 @@
import DonkeyContracts
import DonkeyHarness
+import DonkeyRuntime
import Foundation
import Testing
@@ -361,6 +362,225 @@ struct GenericHarnessTests {
#expect(second?.task.toolHistory.map(\.call.id) == ["observe-call", "verify-call"])
}
+ @Test
+ func pointerPromptLifecycleMirrorsThreadAndCreatesGenericTask() async {
+ let store = InMemoryHarnessThreadStore()
+ let coordinator = HarnessTaskCoordinator()
+ let lifecycle = AppHarnessGenericLifecycle(
+ threadStore: store,
+ coordinator: coordinator
+ )
+ let task = PointerPromptNotchTask(
+ id: "pointer-task-1",
+ title: "Open Calendar",
+ detail: "Running",
+ commandText: "open calendar",
+ status: .running,
+ accentIndex: 0
+ )
+ let request = AppHarnessTurnRequest(
+ turn: AppHarnessTurn(
+ id: "turn-1",
+ text: "open calendar",
+ source: .typedPrompt,
+ taskID: task.id
+ ),
+ recentEvents: [
+ PointerPromptTaskEvent(
+ id: "event-1",
+ taskID: task.id,
+ role: .user,
+ text: "open calendar",
+ sequence: 0
+ )
+ ],
+ assets: [
+ PointerPromptTaskAsset(
+ id: "asset-1",
+ taskID: task.id,
+ source: .userUploaded,
+ displayName: "brief.txt",
+ contentType: "text/plain",
+ urlString: "file:///tmp/brief.txt"
+ )
+ ],
+ policy: ["localInput": "guarded"]
+ )
+
+ let prepared = await lifecycle.preparePointerPromptTurn(
+ request: request,
+ pointerTask: task,
+ traceID: "trace-1",
+ availableToolNames: [AppHarnessGenericLifecycleToolNames.localAppRun],
+ grantedPermissions: [.verification]
+ )
+
+ #expect(prepared.thread.id == task.id)
+ #expect(prepared.thread.activeTaskIDs == [task.id])
+ #expect(prepared.task.id == task.id)
+ #expect(prepared.task.context.turn?.id == "turn-1")
+ #expect(prepared.task.context.availableToolNames == [AppHarnessGenericLifecycleToolNames.localAppRun])
+ #expect(prepared.task.grantedPermissions == [.verification])
+ #expect(prepared.compactedContext.events.map(\.id) == ["event-1"])
+ #expect(prepared.compactedContext.assets.map(\.id) == ["asset-1"])
+ #expect(prepared.compactedContext.promptText.contains("Current turn: open calendar"))
+ }
+
+ @Test
+ func pointerPromptLifecyclePlansLocalRunAndStopsForExecutorUserGate() async {
+ let coordinator = HarnessTaskCoordinator()
+ let lifecycle = AppHarnessGenericLifecycle(coordinator: coordinator)
+ let task = await coordinator.createTask(
+ id: "pointer-task-gate",
+ threadID: "thread-gate",
+ goal: "send a message",
+ grantedPermissions: [.verification]
+ )
+ let intent = TaskIntent(
+ intentID: "intent-1",
+ taskType: "local_app_interaction",
+ targetApp: LocalAppTarget(appName: "Messages"),
+ entities: ["recipient": "Alex"],
+ normalizedEntities: ["recipient": "Alex"],
+ confidence: 0.8,
+ parserSource: .onlineModel
+ )
+ let resolution = LocalAppTaskCatalogResolution(
+ status: .needsConfirmation,
+ intent: intent,
+ metadata: ["reason": "missing message"]
+ )
+ _ = await lifecycle.planLocalTaskRun(
+ taskID: task.id,
+ resolution: resolution,
+ fallbackGoal: "send a message",
+ traceID: "trace-gate"
+ )
+ let registry = BuiltInHarnessToolCatalog.registryWithStubExecutors()
+ await registry.register(
+ HarnessTool(descriptor: AppHarnessGenericLifecycle.localTaskRunDescriptor()) { context in
+ HarnessToolResult(
+ callID: context.call.id,
+ toolName: context.call.name,
+ status: .waitingForUser,
+ summary: "Need the message text.",
+ question: "What should I send?"
+ )
+ }
+ )
+ let runtime = GenericHarnessRuntime(
+ coordinator: coordinator,
+ registry: registry
+ )
+
+ let result = await runtime.executeNextPlannedStep(taskID: task.id)
+
+ #expect(result?.stoppedForGate == true)
+ #expect(result?.task.status == .waitingForUser)
+ #expect(result?.task.pendingContinuation?.question == "What should I send?")
+ #expect(result?.task.pendingContinuation?.pendingToolCall?.name == AppHarnessGenericLifecycleToolNames.localAppRun)
+ #expect(result?.toolResult?.status == .waitingForUser)
+ }
+
+ @Test
+ func pointerPromptLifecycleConsumesPendingContinuationOnFollowUpTurn() async {
+ let coordinator = HarnessTaskCoordinator()
+ let lifecycle = AppHarnessGenericLifecycle(coordinator: coordinator)
+ let task = await coordinator.createTask(
+ id: "pointer-task-answer",
+ threadID: "pointer-task-answer",
+ goal: "send a message"
+ )
+ _ = await coordinator.waitForUser(
+ taskID: task.id,
+ question: "What should I send?",
+ pendingToolCall: HarnessToolCall(
+ id: "pending-run",
+ name: AppHarnessGenericLifecycleToolNames.localAppRun
+ )
+ )
+ let pointerTask = PointerPromptNotchTask(
+ id: task.id,
+ title: "Send Message",
+ detail: "Waiting",
+ status: .waitingForClarification,
+ accentIndex: 0
+ )
+ let request = AppHarnessTurnRequest(
+ turn: AppHarnessTurn(
+ id: "turn-answer",
+ text: "Tell Alex I am running late",
+ source: .followUp,
+ taskID: task.id,
+ isFollowUp: true
+ )
+ )
+
+ let prepared = await lifecycle.preparePointerPromptTurn(
+ request: request,
+ pointerTask: pointerTask,
+ traceID: "trace-answer",
+ availableToolNames: [AppHarnessGenericLifecycleToolNames.localAppRun]
+ )
+
+ #expect(prepared.task.status == .resuming)
+ #expect(prepared.task.pendingContinuation == nil)
+ #expect(prepared.task.worldModel.facts["lastUserClarification"] == "Tell Alex I am running late")
+ #expect(prepared.compactedContext.activeTasks.first?.status == .resuming)
+ }
+
+ @Test
+ func pointerPromptLifecyclePauseResumeUsesGenericTaskState() async {
+ let coordinator = HarnessTaskCoordinator()
+ let lifecycle = AppHarnessGenericLifecycle(coordinator: coordinator)
+ let task = await coordinator.createTask(
+ id: "pointer-task-pause",
+ threadID: "thread-pause",
+ goal: "open an app"
+ )
+
+ let paused = await lifecycle.pauseTask(
+ taskID: task.id,
+ reason: "User paused from notch"
+ )
+ let resumed = await lifecycle.resumeTask(
+ taskID: task.id,
+ reason: "User resumed from notch"
+ )
+
+ #expect(paused?.status == .paused)
+ #expect(resumed?.status == .resuming)
+ #expect(resumed?.pendingContinuation == nil)
+ }
+
+ @Test
+ func pointerPromptLifecyclePlansRecoveryAsGenericToolStep() async {
+ let coordinator = HarnessTaskCoordinator()
+ let lifecycle = AppHarnessGenericLifecycle(coordinator: coordinator)
+ let task = await coordinator.createTask(
+ id: "pointer-task-recover",
+ threadID: "thread-recover",
+ goal: "open an app",
+ grantedPermissions: [.lifecycle]
+ )
+ _ = await lifecycle.planRecovery(
+ taskID: task.id,
+ reason: "App not found",
+ traceID: "trace-recover"
+ )
+ let runtime = GenericHarnessRuntime(
+ coordinator: coordinator,
+ registry: BuiltInHarnessToolCatalog.registryWithStubExecutors()
+ )
+
+ let result = await runtime.executeNextPlannedStep(taskID: task.id)
+
+ #expect(result?.toolResult?.toolName == "run.recover")
+ #expect(result?.toolResult?.status == .succeeded)
+ #expect(result?.task.toolHistory.map(\.call.name) == ["run.recover"])
+ #expect(result?.task.plan?.metadata["planner"] == "genericHarnessPointerPromptRecovery")
+ }
+
@Test
func threadStorePersistsThreadsEventsAndAssetsByThreadID() async {
let store = InMemoryHarnessThreadStore()
diff --git a/docs/guides/agent-harness.md b/docs/guides/agent-harness.md
index 60bf3f21..92498234 100644
--- a/docs/guides/agent-harness.md
+++ b/docs/guides/agent-harness.md
@@ -17,6 +17,13 @@ The existing pointer-prompt and local-app runner code still exists while the
product migrates onto the generic harness. New work should build toward the
generic contracts and avoid expanding the older app-specific paths.
+Pointer-prompt local-app execution now enters the generic lifecycle before it
+uses the older live-runner backend. The supported boundary is that thread
+context, task state, planning, execution gates, verification, recovery,
+pause/resume, and clarification continuations are owned by the generic harness.
+The migration bridge still delegates concrete desktop work to the older runner;
+keep new lifecycle behavior on the generic side of that bridge.
+
## Core Model
Every task has its own durable state:
diff --git a/plans/master-plan.md b/plans/master-plan.md
index 1923d60c..24e5e4ed 100644
--- a/plans/master-plan.md
+++ b/plans/master-plan.md
@@ -21,37 +21,33 @@ even when there are no active tasks.
## Current Sequence
-1. Route pointer-prompt execution through the generic harness lifecycle. Replace
- the old direct local-app command path with thread load/create, task
- load/create, context compaction, planning, one-tool execution, verification,
- recovery, and stop/resume gates.
-2. Back the generic harness thread store with durable local storage. Persist
+1. Back the generic harness thread store with durable local storage. Persist
threads, events, assets, task snapshots, pending continuations, summaries,
compacted-context metadata, and active task ids through the generic store
contract instead of UI-specific persistence.
-3. Replace old task-intent model schemas as the primary planning output. Hosted
+2. Replace old task-intent model schemas as the primary planning output. Hosted
model boundaries should produce structured intent, ambiguity/risk,
context needs, plan steps, verification criteria, fallbacks, and
clarification policy for the generic harness.
-4. Implement real generic tool executors. Cover memory lookup, app lookup,
+3. Implement real generic tool executors. Cover memory lookup, app lookup,
screen observation, element discovery, guarded element actions, text and
keyboard input, AppleScript generation/execution, verification, and lifecycle
operations behind the registry.
-5. Make smart compaction central for every model and planner call. Preserve the
+4. Make smart compaction central for every model and planner call. Preserve the
current turn, active task state, pending gates, summaries, recent useful
events, assets, and tool traces while storing bulky screenshots, full
Accessibility trees, script source, and long outputs as artifacts.
-6. Move app-specific behavior into skills. Music, Notes, Numbers, browser
+5. Move app-specific behavior into skills. Music, Notes, Numbers, browser
workflows, app knowledge, and future app-specific behavior should live in
skill packs, plugin/catalog data, generated artifacts, or memory instead of
core Swift prompt branches.
-7. Build the application-learning task. It should safely explore an app, capture
+6. Build the application-learning task. It should safely explore an app, capture
screenshots and Accessibility trees, distill surfaces/workflows, generate
scripts where useful, validate them, and save a reusable skill pack.
-8. Wire pause, resume, interruption, clarification, and permission gates into
- the UI. The notch/task UI should control generic harness tasks and show the
- exact pending question, approval, paused state, or changed-course state.
-9. Delete old app-specific paths once the generic path covers them. Remove
+7. Wire interruption and permission gates into the UI. The notch/task UI should
+ control generic harness tasks and show the exact pending approval or
+ changed-course state.
+8. Delete old app-specific paths once the generic path covers them. Remove
hardcoded Music/Notes/Numbers/media/weather-style prompt rules, catalog
special cases, repair logic, and demo-only workflow branches.