Skip to content

Open source CapCut alternative.

TypeScript

Fix conversational intent handling

David Le8b4ac1ac8ef9
diff --git a/apps/Donkey/Sources/Donkey/PointerPromptCommandHandler.swift b/apps/Donkey/Sources/Donkey/PointerPromptCommandHandler.swift
index 72e4b801..b15e61fd 100644
--- a/apps/Donkey/Sources/Donkey/PointerPromptCommandHandler.swift
+++ b/apps/Donkey/Sources/Donkey/PointerPromptCommandHandler.swift
@@ -120,10 +120,6 @@ struct LocalAppPointerPromptCommandHandler: PointerPromptCommandHandling {
taskID: taskID
)
}
- await reportSpawnProgress(
- PointerPromptSpawnProgressUpdate(label: "Showing you"),
- context: context
- )
let result = PointerPromptCommandHandlingResult(
status: .completed,
threadStatus: .chatting,
@@ -178,10 +174,6 @@ struct LocalAppPointerPromptCommandHandler: PointerPromptCommandHandling {
logRouting(command: command, traceID: traceID, taskID: taskID, routing: routing)
switch routing.outcome.decision.kind {
case .respond:
- await reportSpawnProgress(
- PointerPromptSpawnProgressUpdate(label: "Answering"),
- context: context
- )
let result = PointerPromptCommandHandlingResult(
status: .completed,
threadStatus: .chatting,
@@ -197,10 +189,6 @@ struct LocalAppPointerPromptCommandHandler: PointerPromptCommandHandling {
logHandlingResult(result, stage: "conversation", hint: routingHint(for: routing))
return result
case .askClarification:
- await reportSpawnProgress(
- PointerPromptSpawnProgressUpdate(label: "Waiting for detail"),
- context: context
- )
let result = PointerPromptCommandHandlingResult(
status: .needsConfirmation,
threadStatus: .waitingForClarification,
@@ -231,10 +219,6 @@ struct LocalAppPointerPromptCommandHandler: PointerPromptCommandHandling {
logHandlingResult(result, stage: "empty", hint: "Empty command; no action was run.")
return result
case .openReview, .runLocalTask:
- await reportSpawnProgress(
- PointerPromptSpawnProgressUpdate(label: "Finding destination"),
- context: context
- )
break
}
@@ -265,16 +249,6 @@ struct LocalAppPointerPromptCommandHandler: PointerPromptCommandHandling {
)
let resolution = localModelResult.resolution
let parseLatencyMS = Self.uptimeMilliseconds() - parseStartedAt
- if let definition = resolution.definition {
- await reportSpawnProgress(
- PointerPromptSpawnProgressUpdate(
- label: "Opening \(definition.targetApp.appName)",
- targetHint: Self.spawnTargetHint(for: definition.targetApp),
- phase: .holding
- ),
- context: context
- )
- }
logModelResolution(
command: commandRedaction.redactedText,
traceID: traceID,
@@ -320,10 +294,6 @@ struct LocalAppPointerPromptCommandHandler: PointerPromptCommandHandling {
)
if Self.shouldRespondWithoutLocalTask(resolution) {
- await reportSpawnProgress(
- PointerPromptSpawnProgressUpdate(label: "Answering"),
- context: context
- )
let response = Self.conversationResponse(for: resolution)
let decision = AppHarnessDecision(
kind: .respond,
@@ -415,15 +385,6 @@ struct LocalAppPointerPromptCommandHandler: PointerPromptCommandHandling {
)
}
- private func reportSpawnProgress(
- _ update: PointerPromptSpawnProgressUpdate,
- context: PointerPromptCommandContext?
- ) async {
- guard let spawnProgressChanged = context?.spawnProgressChanged else { return }
-
- await spawnProgressChanged(update)
- }
-
private func groundAgentVisualizationPlan(_ plan: AgentVisualizationPlan) -> AgentVisualizationPlan {
let candidates = MacWindowResolver().enumerateCandidates()
guard !candidates.isEmpty else { return plan }
@@ -435,15 +396,6 @@ struct LocalAppPointerPromptCommandHandler: PointerPromptCommandHandling {
)
}
- private static func spawnTargetHint(for target: LocalAppTarget) -> PointerPromptSpawnTargetHint {
- PointerPromptSpawnTargetHint(
- appName: target.appName,
- bundleIdentifier: target.bundleIdentifier,
- titleContains: target.titleContains,
- metadata: target.metadata
- )
- }
-
private func logRouting(
command: String,
traceID: String,
@@ -684,7 +636,7 @@ struct LocalAppPointerPromptCommandHandler: PointerPromptCommandHandling {
return "The hosted command parser is not available right now, so I couldn't safely run that action."
}
}
- return "I couldn't find a supported local action for that yet."
+ return "I can help, but I need a clearer request before opening an app."
}
private func retrieveSemanticMemory(
diff --git a/apps/Donkey/Sources/DonkeyAI/LocalGenerateTaskIntentAdapter.swift b/apps/Donkey/Sources/DonkeyAI/LocalGenerateTaskIntentAdapter.swift
index fc49d4a7..c1666e0b 100644
--- a/apps/Donkey/Sources/DonkeyAI/LocalGenerateTaskIntentAdapter.swift
+++ b/apps/Donkey/Sources/DonkeyAI/LocalGenerateTaskIntentAdapter.swift
@@ -147,6 +147,19 @@ public struct ProcessBackedLocalLLMTaskIntentAdapter: TaskIntentParsingAdapter {
sourceModelCallID: "model-call-\(request.sourceTraceID)",
parserName: "local-llm-sidecar-v1"
) else {
+ if let noTaskMetadata = try? TaskIntentWireCodec.noTaskMetadata(
+ response.outputText,
+ parserName: "local-llm-sidecar-v1"
+ ) {
+ return self.result(
+ entry: entry,
+ request: request,
+ status: .completed,
+ validationStatus: "noTaskIntent",
+ latencyMS: result.latencyMS,
+ metadata: responseMetadata.merging(noTaskMetadata) { _, new in new }
+ )
+ }
return self.result(
entry: entry,
request: request,
@@ -410,15 +423,7 @@ public struct LocalGenerateTaskIntentAdapter: TaskIntentParsingAdapter {
}
guard (200..<300).contains(response.statusCode),
- let outputText = try Self.outputText(from: data),
- let intent = try TaskIntentWireCodec.decodeIntent(
- outputText,
- definitions: request.taskDefinitions,
- originalCommand: request.command,
- appFinderCatalog: request.appFinderCatalog,
- sourceModelCallID: "model-call-\(request.sourceTraceID)",
- parserName: "local-generate-task-intent-v1"
- )
+ let outputText = try Self.outputText(from: data)
else {
return result(
entry: entry,
@@ -430,6 +435,44 @@ public struct LocalGenerateTaskIntentAdapter: TaskIntentParsingAdapter {
)
}
+ let baseMetadata = httpMetadata(
+ response: response,
+ data: data,
+ fallbackFromModelID: fallbackFromModelID
+ )
+ guard let intent = try TaskIntentWireCodec.decodeIntent(
+ outputText,
+ definitions: request.taskDefinitions,
+ originalCommand: request.command,
+ appFinderCatalog: request.appFinderCatalog,
+ sourceModelCallID: "model-call-\(request.sourceTraceID)",
+ parserName: "local-generate-task-intent-v1"
+ ) else {
+ if let noTaskMetadata = try? TaskIntentWireCodec.noTaskMetadata(
+ outputText,
+ parserName: "local-generate-task-intent-v1"
+ ) {
+ return result(
+ entry: entry,
+ request: request,
+ status: .completed,
+ validationStatus: "noTaskIntent",
+ latencyMS: latencyMS,
+ metadata: baseMetadata
+ .merging(noTaskMetadata) { _, new in new }
+ .merging(["local.provider": "ollama"]) { current, _ in current }
+ )
+ }
+ return result(
+ entry: entry,
+ request: request,
+ status: .invalidOutput,
+ validationStatus: "invalid",
+ latencyMS: latencyMS,
+ metadata: baseMetadata
+ )
+ }
+
return TaskIntentAdapterResult(
intent: intent,
trace: trace(
@@ -626,10 +669,10 @@ public struct LocalGenerateTaskIntentAdapter: TaskIntentParsingAdapter {
"You are Donkey's local task-intent boundary. Return strict JSON only; do not include reasoning.",
"First decide whether Command is an executable local-app task or a conversation turn.",
"Executable local-app task means all three are clear: action, destination or target app/item, and enough payload to execute safely.",
- "If Command is a question, conversation, malformed request, or lacks a real executable payload, do not invent one. Return the closest supported task with confidence below 0.55, needsConfirmation=false, metadata.responseMode=conversation, and metadata.assistantResponse with a brief natural-language reply.",
+ "If Command is a question, greeting, conversation, malformed request, or lacks a real executable payload, do not invent one. Return taskType \"none\", targetAppName \"none\", empty entities and normalizedEntities, confidence 0, needsConfirmation=false, actionPlan.tools=[], and metadata.responseMode=conversation with metadata.assistantResponse containing a brief natural-language reply.",
"If Command is an executable local task with one ordinary missing detail, set needsConfirmation=true and include missingEntity in metadata.",
- "If Command is executable, choose by capability and target app, not exact wording. Use only provided task definitions; do not invent task types, unsupported entities, or actions.",
- "If no capability fits, return the closest supported task with confidence below 0.55.",
+ "If Command is executable, choose by capability and target app, not exact wording. Use only the provided task definitions; do not invent task types, unsupported entities, or actions.",
+ "If no capability fits, choose conversation with taskType \"none\" and a helpful metadata.assistantResponse rather than a failed local-action message.",
"For dynamic local-item capabilities, app/file/folder names may come from the request, relevant local cache, or default-app inference; the catalog will verify availability before execution.",
"For write/create document requests: if the requested content is malformed or not meaningful enough to type, choose conversation; do not fabricate a document payload just to make the task executable.",
"For local_app_interaction, select the most likely local app for the user's goal, set entities.goal, and when text must be entered set entities.query plus normalizedEntities.query.",
@@ -651,7 +694,8 @@ public struct LocalGenerateTaskIntentAdapter: TaskIntentParsingAdapter {
"Example website output shape: {\"taskType\":\"local_app_interaction\",\"targetAppName\":\"Safari\",\"entities\":{\"appName\":\"Safari\",\"goal\":\"open requested website\",\"query\":\"https://example.org\"},\"normalizedEntities\":{\"appName\":\"Safari\",\"goal\":\"open requested website\",\"query\":\"https://example.org\"},\"confidence\":0.9,\"needsConfirmation\":false,\"actionPlan\":{\"tools\":[\"app.openOrFocus\",\"app.observe\",\"ui.focusAddressBar\",\"ui.setText\",\"ui.pressReturn\",\"app.verifyCommand\"],\"inputEntity\":\"query\",\"controlID\":\"addressBar\",\"focusKey\":\"Command+L\",\"verification\":\"commandAttempted\"},\"metadata\":{}}",
"Writing output shape: targetAppName=Notes, entities.appName=Notes, entities.goal=write requested text, entities.query=<the actual final text to type>, actionPlan.tools=[app.openOrFocus, app.observe, ui.newDocument, ui.setText, app.verifyCommand], inputEntity=query, controlID=editor.",
"Table output shape: targetAppName=Numbers, entities.appName=Numbers, entities.goal=create requested table, entities.query=<tab-separated rows for the requested table>, actionPlan.tools=[app.openOrFocus, app.observe, ui.newDocument, ui.setText, app.verifyCommand], inputEntity=query, controlID=editor.",
- "Example malformed request output shape: {\"taskType\":\"local_app_interaction\",\"targetAppName\":\"Notes\",\"entities\":{\"appName\":\"Notes\",\"goal\":\"unclear local writing request\"},\"normalizedEntities\":{\"appName\":\"Notes\",\"goal\":\"unclear local writing request\"},\"confidence\":0.2,\"needsConfirmation\":false,\"actionPlan\":{\"tools\":[],\"inputEntity\":\"query\",\"controlID\":\"\",\"focusKey\":\"\",\"verification\":\"commandAttempted\"},\"metadata\":{\"responseMode\":\"conversation\",\"assistantResponse\":\"I can help, but I need a clearer thing to write before opening an app.\"}}",
+ "Conversation output shape: {\"taskType\":\"none\",\"targetAppName\":\"none\",\"entities\":{},\"normalizedEntities\":{},\"confidence\":0,\"needsConfirmation\":false,\"actionPlan\":{\"tools\":[],\"inputEntity\":\"\",\"controlID\":\"\",\"focusKey\":\"\",\"verification\":\"commandAttempted\"},\"metadata\":{\"responseMode\":\"conversation\",\"assistantResponse\":\"Hi! What would you like to work on?\"}}",
+ "Example malformed request output shape: {\"taskType\":\"none\",\"targetAppName\":\"none\",\"entities\":{},\"normalizedEntities\":{},\"confidence\":0,\"needsConfirmation\":false,\"actionPlan\":{\"tools\":[],\"inputEntity\":\"\",\"controlID\":\"\",\"focusKey\":\"\",\"verification\":\"commandAttempted\"},\"metadata\":{\"responseMode\":\"conversation\",\"assistantResponse\":\"I can help, but I need a clearer thing to write before opening an app.\"}}",
"For every other task type, actionPlan.tools must be empty.",
"For AppleScript-backed capabilities, include compact appleScript.source or appleScript.template metadata only when the provided action is insufficient; prefer task metadata and normalized entities for speed.",
"App finder catalog entries are installed local apps with descriptions, support status, capabilities, and control profiles.",
@@ -800,18 +844,31 @@ public struct HostedTaskIntentParsingAdapter: TaskIntentParsingAdapter {
parserName: "hosted-responses-v1",
parserSource: .onlineModel
) else {
+ let baseMetadata = Self.outputDiagnostics(for: outputText)
+ .merging([
+ "provider": "donkeyBackend",
+ "privacy.store": "false"
+ ]) { current, _ in current }
+ guard let noTaskMetadata = try? TaskIntentWireCodec.noTaskMetadata(
+ outputText,
+ parserName: "hosted-responses-v1"
+ ) else {
+ return result(
+ entry: entry,
+ request: request,
+ status: .invalidOutput,
+ validationStatus: "invalid",
+ latencyMS: latencyMS,
+ metadata: baseMetadata
+ )
+ }
return result(
entry: entry,
request: request,
status: .completed,
validationStatus: "noTaskIntent",
latencyMS: latencyMS,
- metadata: Self.outputDiagnostics(for: outputText)
- .merging([
- "reason": "noSupportedTaskIntent",
- "responseMode": "conversation",
- "assistantResponse": "I couldn't find a supported local action for that yet."
- ]) { current, _ in current }
+ metadata: baseMetadata.merging(noTaskMetadata) { _, new in new }
)
}
@@ -901,7 +958,7 @@ public struct HostedTaskIntentParsingAdapter: TaskIntentParsingAdapter {
"Return strict JSON only.",
"First decide whether Command is an executable local-app task or a conversation turn.",
"Executable local-app task means all three are clear: action, destination or target app/item, and enough payload to execute safely.",
- "If Command is conversation, a question, malformed, or lacks a real executable payload, return taskType \"none\", targetAppName \"none\", empty entities, confidence 0, needsConfirmation false, an empty actionPlan, and metadata.responseMode \"conversation\".",
+ "If Command is a greeting, conversation, question, malformed request, or lacks a real executable payload, return taskType \"none\", targetAppName \"none\", empty entities and normalizedEntities, confidence 0, needsConfirmation false, actionPlan.tools empty, and metadata.responseMode \"conversation\" with metadata.assistantResponse containing a brief natural-language reply.",
"For supported actions, choose only a provided taskType and target app. Fill entities and normalizedEntities with the concrete values needed by required entity rules.",
"Use the generic local_app_interaction task type for executable local app requests that need a model-planned app workflow and do not have a more specific provided task type.",
"When App finder catalog JSON is non-empty and you use local_app_interaction, choose the target app only from a catalog entry with supportStatus supported and a matching capability. Set metadata.appFinder.selectedAppID to the exact appID, metadata.appFinder.selectedCapabilityID to the capability id, and metadata.appFinder.controlProfile to one declared control profile. Never select candidate, unsupported, or denied entries for execution.",
@@ -913,6 +970,7 @@ public struct HostedTaskIntentParsingAdapter: TaskIntentParsingAdapter {
"For writing in Notes, choose Notes, make query the complete text to type, and use ui.newDocument, ui.setText, app.verifyCommand.",
"For spreadsheet or table creation, choose Numbers, put compact tab-separated table content in query, and use ui.newDocument, ui.setText, app.verifyCommand.",
"For every other task type, actionPlan.tools must be empty.",
+ "If no supported capability fits, choose taskType \"none\" with a helpful conversational assistantResponse rather than a generic local-action failure.",
"Do not invent task types, unsupported entities, unsupported tools, app scripts, or direct input outside the schema."
].joined(separator: " ")
@@ -1081,7 +1139,7 @@ public struct LocalModelTaskIntentResolver: Sendable {
if result.trace.validationStatus == "noTaskIntent" {
metadata["reason"] = "noSupportedTaskIntent"
metadata["responseMode"] = "conversation"
- metadata["assistantResponse"] = "I couldn't find a supported local action for that yet."
+ metadata["assistantResponse"] = TaskIntentWireCodec.defaultConversationAssistantResponse
}
for key in ["responseMode", "assistantResponse"] {
if let value = result.trace.metadata[key], !value.isEmpty {
@@ -1173,6 +1231,8 @@ private func taskIntentAppFinderCatalogJSON(_ entries: [LocalAppFinderCatalogEnt
}
private enum TaskIntentWireCodec {
+ static let defaultConversationAssistantResponse = "I'm here. What would you like to work on?"
+
static func jsonSchema(taskDefinitions: [LocalAppTaskDefinition]) -> [String: Any] {
let allowsDynamicTargets = taskDefinitions.contains { definition in
definition.metadata["dynamicTarget"] == "true"
@@ -1371,6 +1431,24 @@ private enum TaskIntentWireCodec {
)
}
+ static func noTaskMetadata(
+ _ outputText: String,
+ parserName: String
+ ) throws -> [String: String]? {
+ let wire = try decodeWire(from: outputText)
+ guard wire.taskType == "none" else { return nil }
+
+ var metadata = wire.metadata
+ metadata["parser"] = parserName
+ metadata["reason"] = nonEmpty(metadata["reason"]) ?? "noSupportedTaskIntent"
+ metadata["responseMode"] = "conversation"
+ metadata["assistantResponse"] = nonEmpty(metadata["assistantResponse"])
+ ?? defaultConversationAssistantResponse
+ metadata["taskType"] = "none"
+ metadata["targetApp"] = wire.targetAppName
+ return metadata
+ }
+
private static func decodeWire(from outputText: String) throws -> TaskIntentWire {
var lastError: Error?
for candidate in jsonObjectCandidates(in: outputText) {
@@ -1434,6 +1512,11 @@ private enum TaskIntentWireCodec {
return candidates.filter { seen.insert($0).inserted }
}
+ private static func nonEmpty(_ value: String?) -> String? {
+ let trimmed = value?.trimmingCharacters(in: .whitespacesAndNewlines) ?? ""
+ return trimmed.isEmpty ? nil : trimmed
+ }
+
private static func normalizedEntities(
from wire: TaskIntentWire,
definition: LocalAppTaskDefinition
diff --git a/apps/Donkey/Sources/DonkeyUI/PointerPromptSpawnOverlayView.swift b/apps/Donkey/Sources/DonkeyUI/PointerPromptSpawnOverlayView.swift
index 1bb87e35..9d754b36 100644
--- a/apps/Donkey/Sources/DonkeyUI/PointerPromptSpawnOverlayView.swift
+++ b/apps/Donkey/Sources/DonkeyUI/PointerPromptSpawnOverlayView.swift
@@ -85,6 +85,14 @@ public final class PointerPromptSpawnOverlayViewModel: ObservableObject {
isLabelEditing || !draftText.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty
}
+ private var isAwaitingResponse: Bool {
+ guard let state else { return false }
+
+ return state.phase != .fading &&
+ state.label.trimmingCharacters(in: .whitespacesAndNewlines) ==
+ state.commandText.trimmingCharacters(in: .whitespacesAndNewlines)
+ }
+
public var hasScreenSize: Bool {
screenSize.width > 0 && screenSize.height > 0
}
@@ -270,6 +278,7 @@ public final class PointerPromptSpawnOverlayViewModel: ObservableObject {
let previousLabel = self.state?.label
let previousLabelSize = labelSize()
let previousScreenSize = self.screenSize
+ let wasAwaitingResponse = isAwaitingResponse
self.state = state
self.screenSize = screenSize
if isHolding,
@@ -284,6 +293,15 @@ public final class PointerPromptSpawnOverlayViewModel: ObservableObject {
fadeOut()
return
}
+ if isHolding,
+ wasAwaitingResponse,
+ !isAwaitingResponse {
+ animationGeneration += 1
+ terminalTailAngleDegrees = 0
+ withAnimation(.easeOut(duration: 0.12)) {
+ isWorking = true
+ }
+ }
guard !freezesMovement else { return }
guard distance(from: self.destination, to: destination) > 1 else { return }
@@ -458,6 +476,10 @@ public final class PointerPromptSpawnOverlayViewModel: ObservableObject {
withAnimation(.easeOut(duration: 0.12)) {
self.terminalTailAngleDegrees = 0
+ }
+ if self.isAwaitingResponse {
+ self.playTerminalTailAnimation(generation: generation)
+ } else {
self.isWorking = true
}
}
diff --git a/apps/Donkey/Tests/DonkeyRuntimeTests/AIHarnessAdapterTests.swift b/apps/Donkey/Tests/DonkeyRuntimeTests/AIHarnessAdapterTests.swift
index 2485c5fc..c15ee894 100644
--- a/apps/Donkey/Tests/DonkeyRuntimeTests/AIHarnessAdapterTests.swift
+++ b/apps/Donkey/Tests/DonkeyRuntimeTests/AIHarnessAdapterTests.swift
@@ -395,6 +395,8 @@ struct AIHarnessAdapterTests {
#expect((body["prompt"] as? String)?.contains("set_text_input_contract=inputEntityValueIsExactTextToEnter") == true)
#expect((body["prompt"] as? String)?.contains("action, destination or target app/item") == true)
#expect((body["prompt"] as? String)?.contains("metadata.responseMode=conversation") == true)
+ #expect((body["prompt"] as? String)?.contains("metadata.assistantResponse") == true)
+ #expect((body["prompt"] as? String)?.contains("taskType \"none\"") == true)
#expect((body["prompt"] as? String)?.contains("triggers=") == false)
#expect((body["prompt"] as? String)?.contains("metadata=") == false)
}
@@ -532,6 +534,41 @@ struct AIHarnessAdapterTests {
let instructions = try #require(parameters["instructions"] as? String)
#expect(instructions.contains("local_app_interaction"))
#expect(instructions.contains("media playback"))
+ #expect(instructions.contains("metadata.assistantResponse"))
+ }
+
+ @Test
+ func hostedTaskIntentAdapterPreservesNoTaskConversationResponse() async throws {
+ let httpClient = FakeAIHTTPClient(
+ data: responseData(
+ outputText: """
+ {"taskType":"none","targetAppName":"none","entities":{},"normalizedEntities":{},"confidence":0,"needsConfirmation":false,"actionPlan":{"tools":[],"inputEntity":"","controlID":"","focusKey":"","verification":"commandAttempted"},"metadata":{"responseMode":"conversation","assistantResponse":"Hi there! What would you like to work on?"}}
+ """
+ ),
+ statusCode: 200
+ )
+ let adapter = HostedTaskIntentParsingAdapter(
+ configuration: DonkeyBackendInferenceConfiguration(
+ baseURL: URL(string: "https://donkey.example")!,
+ clientID: "client-1"
+ ),
+ httpClient: httpClient
+ )
+
+ let result = await adapter.parseTaskIntent(
+ TaskIntentAdapterRequest(
+ command: "hi there",
+ taskDefinitions: BuiltInLocalAppTaskDefinitions.benchmarkFixtures,
+ sourceTraceID: "trace-hosted-greeting"
+ )
+ )
+
+ #expect(result.intent == nil)
+ #expect(result.trace.status == .completed)
+ #expect(result.trace.validationStatus == "noTaskIntent")
+ #expect(result.trace.metadata["responseMode"] == "conversation")
+ #expect(result.trace.metadata["assistantResponse"] == "Hi there! What would you like to work on?")
+ #expect(result.trace.metadata["provider"] == "donkeyBackend")
}
@Test
@@ -1165,6 +1202,43 @@ struct AIHarnessAdapterTests {
#expect(result.trace.status == .completed)
}
+ @Test
+ func localModelTaskIntentResolverPreservesHostedNoTaskConversationForGreeting() async {
+ let adapter = HostedTaskIntentParsingAdapter(
+ configuration: DonkeyBackendInferenceConfiguration(
+ baseURL: URL(string: "https://donkey.example")!,
+ clientID: "client-1"
+ ),
+ httpClient: FakeAIHTTPClient(
+ data: responseData(
+ outputText: """
+ {"taskType":"none","targetAppName":"none","entities":{},"normalizedEntities":{},"confidence":0,"needsConfirmation":false,"actionPlan":{"tools":[],"inputEntity":"","controlID":"","focusKey":"","verification":"commandAttempted"},"metadata":{"responseMode":"conversation","assistantResponse":"Hi there! What would you like to work on?"}}
+ """
+ ),
+ statusCode: 200
+ )
+ )
+ let resolver = LocalModelTaskIntentResolver(
+ catalog: LocalAppTaskCatalog(
+ taskDefinitions: BuiltInLocalAppTaskDefinitions.benchmarkFixtures,
+ availabilityProvider: StaticLocalAppAvailabilityProvider(installedBundleIdentifiers: [])
+ ),
+ adapter: adapter
+ )
+
+ let result = await resolver.resolve(
+ command: "hi there",
+ sourceTraceID: "trace-hosted-no-task-greeting"
+ )
+
+ #expect(result.resolution.status == .needsConfirmation)
+ #expect(result.resolution.intent == nil)
+ #expect(result.resolution.metadata["reason"] == "noSupportedTaskIntent")
+ #expect(result.resolution.metadata["responseMode"] == "conversation")
+ #expect(result.resolution.metadata["assistantResponse"] == "Hi there! What would you like to work on?")
+ #expect(result.trace.validationStatus == "noTaskIntent")
+ }
+
@Test
func localModelTaskIntentResolverAcceptsClosestLowConfidenceClassification() async {
let httpClient = FakeAIHTTPClient(
diff --git a/apps/Donkey/Tests/DonkeyRuntimeTests/PointerPromptCopyTests.swift b/apps/Donkey/Tests/DonkeyRuntimeTests/PointerPromptCopyTests.swift
index 512384d9..c1c290b2 100644
--- a/apps/Donkey/Tests/DonkeyRuntimeTests/PointerPromptCopyTests.swift
+++ b/apps/Donkey/Tests/DonkeyRuntimeTests/PointerPromptCopyTests.swift
@@ -20,7 +20,7 @@ struct PointerPromptCopyTests {
@Test
func composerPlaceholderDoesNotReuseTaskOrResultText() {
#expect(
- PointerPromptCopy.composerPlaceholder(for: "I couldn't find a supported local action for that yet.") ==
+ PointerPromptCopy.composerPlaceholder(for: "I can help, but I need a clearer request before opening an app.") ==
PointerPromptCopy.defaultPromptPlaceholder
)
#expect(
diff --git a/apps/Donkey/Tests/DonkeyRuntimeTests/PointerPromptSpawnGeometryTests.swift b/apps/Donkey/Tests/DonkeyRuntimeTests/PointerPromptSpawnGeometryTests.swift
index e0afd361..ae8c46b8 100644
--- a/apps/Donkey/Tests/DonkeyRuntimeTests/PointerPromptSpawnGeometryTests.swift
+++ b/apps/Donkey/Tests/DonkeyRuntimeTests/PointerPromptSpawnGeometryTests.swift
@@ -138,7 +138,7 @@ struct PointerPromptSpawnGeometryTests {
}
@Test @MainActor
- func spawnOverlayRunsTerminalTailAnimationBeforeWorkingPulse() async throws {
+ func spawnOverlayWagsTailUntilResponseLabelArrives() async throws {
let viewModel = PointerPromptSpawnOverlayViewModel()
let origin = CGPoint(x: 600, y: -24)
let destination = CGPoint(x: 420, y: 282)
@@ -170,6 +170,20 @@ struct PointerPromptSpawnGeometryTests {
)
try await Task.sleep(nanoseconds: workingDelay)
+ #expect(!viewModel.isWorking)
+
+ viewModel.update(
+ state: PointerPromptSpawnState(
+ id: "spawn-1",
+ commandText: "hi there",
+ label: "Hi! What would you like to work on?",
+ accentIndex: 1,
+ phase: .holding
+ ),
+ destination: destination,
+ screenSize: CGSize(width: 1200, height: 800)
+ )
+
#expect(viewModel.isWorking)
#expect(abs(viewModel.terminalTailAngleDegrees) < 0.0001)
}
diff --git a/docs/guides/decision-system.md b/docs/guides/decision-system.md
index c938709b..121b0e51 100644
--- a/docs/guides/decision-system.md
+++ b/docs/guides/decision-system.md
@@ -32,6 +32,10 @@ The model returns strict JSON, not free-form instructions. The result is decoded
For dynamic local-item capabilities, the app or item name comes from the typed model output. For dynamic local-app interactions, the app name is accepted only when it can be matched to a supplied app-finder catalog entry with `supportStatus=supported` and a selected declared capability. Catalog and memory matching happen after typed output exists, so lookup is scoped to structured fields such as `targetAppName`, `entities.appName`, `metadata.appFinder.selectedAppID`, or a resolved target id. That inference is not execution authority; the catalog still resolves and verifies the target before any action runs.
The `TaskIntent` wire format always includes an `actionPlan` object. Non-planned task types must return an empty `actionPlan.tools` array; non-empty action plans are accepted only for task definitions that explicitly opt into model-planned local-app interaction.
+Conversational turns use `taskType: "none"` with an empty action plan,
+`metadata.responseMode=conversation`, and `metadata.assistantResponse`; the
+resolver preserves that response instead of turning it into an unsupported local
+action failure.
## Generic Local-App Interaction
diff --git a/docs/guides/pointer-prompt-overlay.md b/docs/guides/pointer-prompt-overlay.md
index 394a7510..0cb1a689 100644
--- a/docs/guides/pointer-prompt-overlay.md
+++ b/docs/guides/pointer-prompt-overlay.md
@@ -18,7 +18,7 @@ quick local-app actions:
- When a typed prompt or notch follow-up is submitted, show a task spawn cue: the notch arrow rotates toward the exit direction, moves out of the notch, and a Donkey cursor overlay travels onto the desktop.
- Spawned cursors travel to a known safe visible target window when one is available. Otherwise they hold about 250 px below the notch near screen center as a loading/thinking state, then retarget if the destination becomes visible.
- Multiple spawned cursors can be present at the same time. The newest spawned cursor is selected by default, and clicking a cursor or its label selects it as the current agent.
-- A stationary spawned cursor shows the submitted turn first, then compact progress or response text in its label. Labels render complete words and wrap to their measured size instead of revealing partial typewriter text or clipping at the panel edge. Conversational responses, clarifications, review waits, failures, and other attention states stay visible so the user can read them and follow up; completed action-only cursors may fade out. Spawn labels expand wider on hover when that reduces wrapping, and select the cursor on click. Clicking a tasked label turns the same agent-colored surface into an inline editor with the agent message above and a lighter color-matched user input area below; Return submits the typed follow-up to that spawn's task, Shift-Return inserts a newline, Escape returns to the label, and clicking outside the editor closes it.
+- A stationary spawned cursor shows the submitted turn while Donkey is waiting on routing, model, or runtime work; it uses the cursor tail animation as the waiting state instead of replacing the label with interim text. When a response, clarification, review wait, failure, or other attention state is available, that result text replaces the label and stays visible so the user can read it and follow up; completed action-only cursors may fade out. Labels render complete words and wrap to their measured size instead of revealing partial typewriter text or clipping at the panel edge. Spawn labels expand wider on hover when that reduces wrapping, and select the cursor on click. Clicking a tasked label turns the same agent-colored surface into an inline editor with the agent message above and a lighter color-matched user input area below; Return submits the typed follow-up to that spawn's task, Shift-Return inserts a newline, Escape returns to the label, and clicking outside the editor closes it.
- Double-Command always opens the centered prompt, even when spawned cursors are visible. If a spawned cursor is selected, centered typed or voice input attaches to that task behind the scenes; otherwise Donkey uses the latest interactable spawned cursor before falling back to follow-up resolution.
- 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.
@@ -83,7 +83,7 @@ Manually verify:
- First launch shows the permission setup after sign-in, explains Accessibility, Screenshots, and Microphone before requesting them, enables Continue only when all three are ready, and does not trigger Desktop/Documents/Downloads prompts during startup.
- Double-Command release opens a centered focused text prompt; double-Command hold opens the same prompt with voice active; typed text shows a primary send button and a secondary microphone affordance; unrelated Command use does not activate the overlay.
- Typed, voice, and follow-up submissions create or update durable task threads, answer non-actionable conversation without showing action failure, show action status in the notch when work runs, and preserve per-task pause/resume behavior.
-- Typed prompt and notch follow-up submissions show the spawn sequence: notch cue, desktop cursor emergence, direct travel to a known target or fallback holding point, typed submitted-turn label, typed progress/response label, retargeting when the target becomes visible, persistent labels for conversational or attention states, and fade-out only for completed action-only turns.
+- Typed prompt and notch follow-up submissions show the spawn sequence: notch cue, desktop cursor emergence, direct travel to a known target or fallback holding point, typed submitted-turn label with tail-wag waiting animation, final response/result label, retargeting when the target becomes visible, persistent labels for conversational or attention states, and fade-out only for completed action-only turns.
- Stationary spawn labels render complete text without typewriter clipping, wrap to fit available width, select the cursor on click, and transition in place into a same-styled inline editor for tasked follow-ups without clipping the carried-over label.
- 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.
diff --git a/scripts/local-runtime-runners/donkey_runtime_runner.py b/scripts/local-runtime-runners/donkey_runtime_runner.py
index 8e99a27b..3dfb4fbc 100644
--- a/scripts/local-runtime-runners/donkey_runtime_runner.py
+++ b/scripts/local-runtime-runners/donkey_runtime_runner.py
@@ -788,9 +788,10 @@ def compact_task_intent_prompt(
"Return only compact JSON with string values.",
"<|im_end|>",
"<|im_start|>user",
- "Classify this Mac command into one local app action.",
+ "Classify this Mac command into an executable local app action or no action.",
"Choose appName from: " + ", ".join(app_names),
"Prefer a concrete app name. Do not choose Local App when Music, Safari, Notes, or Numbers fits.",
+ "If this is not an executable local app action, set appName to none, query to empty, and confidence to 0.",
f"Command: {command}",
"JSON keys: appName, goal, query, confidence.",
"For music playback, appName is Music and query is the artist/song.",
@@ -1386,10 +1387,10 @@ def task_intent_prompt(
"You are Donkey's local task-intent boundary. Return strict JSON only; do not include reasoning.",
"First decide whether Command is an executable local-app task or a conversation turn.",
"Executable local-app task means all three are clear: action, destination or target app/item, and enough payload to execute safely.",
- "If Command is a question, conversation, malformed request, or lacks a real executable payload, do not invent one. Return the closest supported task with confidence below 0.55, needsConfirmation=false, metadata.responseMode=conversation, and metadata.assistantResponse with a brief natural-language reply.",
+ "If Command is a question, greeting, conversation, malformed request, or lacks a real executable payload, do not invent one. Return taskType \"none\", targetAppName \"none\", empty entities and normalizedEntities, confidence 0, needsConfirmation=false, actionPlan.tools=[], and metadata.responseMode=conversation with metadata.assistantResponse containing a brief natural-language reply.",
"If Command is an executable local task with one ordinary missing detail, set needsConfirmation=true and include missingEntity in metadata.",
- "If Command is executable, choose by capability and target app, not exact wording. Use only provided task definitions; do not invent task types, unsupported entities, or actions.",
- "If no capability fits, return the closest supported task with confidence below 0.55.",
+ "If Command is executable, choose by capability and target app, not exact wording. Use only the provided task definitions; do not invent task types, unsupported entities, or actions.",
+ "If no capability fits, choose conversation with taskType \"none\" and a helpful metadata.assistantResponse rather than a failed local-action message.",
"For dynamic local-item capabilities, app/file/folder names may come from the request, relevant local cache, or default-app inference; the catalog will verify availability before execution.",
"For write/create document requests: if the requested content is malformed or not meaningful enough to type, choose conversation; do not fabricate a document payload just to make the task executable.",
"For local_app_interaction, select the most likely local app for the user's goal, set entities.goal, and when text must be entered set entities.query plus normalizedEntities.query.",
@@ -1412,7 +1413,8 @@ def task_intent_prompt(
'Example website output shape: {"taskType":"local_app_interaction","targetAppName":"Safari","entities":{"appName":"Safari","goal":"open requested website","query":"https://example.org"},"normalizedEntities":{"appName":"Safari","goal":"open requested website","query":"https://example.org"},"confidence":0.9,"needsConfirmation":false,"actionPlan":{"tools":["app.openOrFocus","app.observe","ui.focusAddressBar","ui.setText","ui.pressReturn","app.verifyCommand"],"inputEntity":"query","controlID":"addressBar","focusKey":"Command+L","verification":"commandAttempted"},"metadata":{}}',
"Writing output shape: targetAppName=Notes, entities.appName=Notes, entities.goal=write requested text, entities.query=<the actual final text to type>, actionPlan.tools=[app.openOrFocus, app.observe, ui.newDocument, ui.setText, app.verifyCommand], inputEntity=query, controlID=editor.",
"Table output shape: targetAppName=Numbers, entities.appName=Numbers, entities.goal=create requested table, entities.query=<tab-separated rows for the requested table>, actionPlan.tools=[app.openOrFocus, app.observe, ui.newDocument, ui.setText, app.verifyCommand], inputEntity=query, controlID=editor.",
- 'Example malformed request output shape: {"taskType":"local_app_interaction","targetAppName":"Notes","entities":{"appName":"Notes","goal":"unclear local writing request"},"normalizedEntities":{"appName":"Notes","goal":"unclear local writing request"},"confidence":0.2,"needsConfirmation":false,"actionPlan":{"tools":[],"inputEntity":"query","controlID":"","focusKey":"","verification":"commandAttempted"},"metadata":{"responseMode":"conversation","assistantResponse":"I can help, but I need a clearer thing to write before opening an app."}}',
+ 'Conversation output shape: {"taskType":"none","targetAppName":"none","entities":{},"normalizedEntities":{},"confidence":0,"needsConfirmation":false,"actionPlan":{"tools":[],"inputEntity":"","controlID":"","focusKey":"","verification":"commandAttempted"},"metadata":{"responseMode":"conversation","assistantResponse":"Hi! What would you like to work on?"}}',
+ 'Example malformed request output shape: {"taskType":"none","targetAppName":"none","entities":{},"normalizedEntities":{},"confidence":0,"needsConfirmation":false,"actionPlan":{"tools":[],"inputEntity":"","controlID":"","focusKey":"","verification":"commandAttempted"},"metadata":{"responseMode":"conversation","assistantResponse":"I can help, but I need a clearer thing to write before opening an app."}}',
"For every other task type, actionPlan.tools must be empty.",
"App finder catalog entries are installed local apps with descriptions, support status, capabilities, and control profiles.",
"When App finder catalog JSON is non-empty and you use local_app_interaction, choose the target app only from a catalog entry with supportStatus=supported and a matching capability.",