Open source CapCut alternative.
TypeScript
Let the planner act on low-risk local-app requests instead of over-confirming
David Le2d9a13da2a2f
diff --git a/apps/Donkey/Sources/DonkeyAI/HostedTaskIntentParsingAdapter.swift b/apps/Donkey/Sources/DonkeyAI/HostedTaskIntentParsingAdapter.swiftindex 0496977b..dd833f66 100644--- a/apps/Donkey/Sources/DonkeyAI/HostedTaskIntentParsingAdapter.swift+++ b/apps/Donkey/Sources/DonkeyAI/HostedTaskIntentParsingAdapter.swift@@ -395,16 +395,18 @@ public struct HostedTaskIntentParsingAdapter: TaskIntentParsingAdapter {private static let instructions = ["You are the first model boundary for Donkey's generic agent harness. Decide how the harness should handle the user turn before any tool-specific executor is selected.","Return strict JSON only using the generic harness planning schema.",- "First decide whether Command should be answered conversationally, should ask a clarification, or should use a supported tool path.",+ "Donkey is a capable Mac agent that can operate any application and item on the Mac. Default to acting: be broad in what you accept and specific in what you do. For an under-specified but low-risk, reversible request, choose reasonable, concrete specifics yourself and proceed — do not ask the user to fill in details you can sensibly decide.",+ "First decide whether Command should be answered conversationally, should ask a clarification, or should use a supported tool path. Prefer acting via a tool path over clarification whenever the action is safe and reversible.","Choose conversation for greetings, questions, brainstorming, explanations, status requests, malformed requests, or any turn that does not require external action.",- "Choose clarification when the user wants action but a specific required detail is missing or the action is dangerously ambiguous.",- "Choose localAppTask only when the user is asking Donkey to operate a supported local app or local item and all three are clear: action, destination or target app/item, and enough payload to execute safely.",+ "Choose clarification only when acting could be destructive, irreversible, costly, or sent/shared externally AND the user's intent is genuinely ambiguous, or when a required target is unknown and cannot be reasonably inferred. Never ask for clarification merely because a request is casual, broad, or under-specified (for example \"play some coldplay\", \"open my notes\", \"make it bigger\") — resolve those by picking concrete specifics and acting.",+ "Choose localAppTask whenever the user wants Donkey to operate a local app or item and you can identify the action and a target app or item. If payload specifics are under-specified (which song, which note, which result), pick concrete, reasonable defaults and proceed rather than requiring the user to supply every detail.","Always fill structuredIntent, ambiguityRisk, contextNeeds, planSteps, verificationCriteria, fallbacks, clarificationPolicy, and metadata.","If Command is conversation, set structuredIntent.route conversation, taskType \"none\", targetAppName \"none\", empty entities and normalizedEntities, confidence 0, needsConfirmation false, no planSteps with toolName values, and metadata.responseMode \"conversation\" with metadata.assistantResponse containing a brief natural-language reply.",- "If Command needs clarification before tool use, set structuredIntent.route clarification, taskType \"none\", targetAppName \"none\" unless a target is already known, needsConfirmation true, ambiguityRisk.shouldAskBeforeActing true, clarificationPolicy.shouldAsk true, and include one specific question.",+ "If Command genuinely needs clarification (only per the narrow criteria above), set structuredIntent.route clarification, taskType \"none\", targetAppName \"none\" unless a target is already known, needsConfirmation true, ambiguityRisk.shouldAskBeforeActing true, clarificationPolicy.shouldAsk true, and include one specific question naming exactly what you need.","For supported local app actions, set structuredIntent.route localAppTask, choose only a provided taskType and target app, and 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.",- "Use ambiguityRisk for safe, recoverable, or dangerous ambiguity. Dangerous ambiguity and missing required details must set structuredIntent.needsConfirmation true, ambiguityRisk.shouldAskBeforeActing true, and clarificationPolicy.shouldAsk true with a specific question.",+ "Use ambiguityRisk to classify the action. Set structuredIntent.needsConfirmation true, ambiguityRisk.shouldAskBeforeActing true, and clarificationPolicy.shouldAsk true with a specific question ONLY for genuinely dangerous, destructive, irreversible, costly, or externally-sent actions whose intent is ambiguous. For safe, reversible actions — including broad or casual ones — set needsConfirmation false and act.",+ "When a request is broad or casual but the action is low-risk and reversible, resolve the vagueness yourself with a concrete, specific choice and act: set structuredIntent.route localAppTask and structuredIntent.needsConfirmation false. Use loaded app skill guidance to make the choice when present (for example pick a representative song for \"play some coldplay\"). Do not treat resolvable vagueness as a missing required detail.","Use contextNeeds for app lookup, memory lookup, screen observation, element discovery, or skill lookup needed before or during execution.","Use planSteps for the generic harness plan. Each executable step must name one available toolName, with toolInputs filled from structured entities and tool schemas. Keep inputEntity/controlID/focusKey for local UI compatibility when those tools need them. Non-executable reasoning steps should use an empty toolName.","Use verificationCriteria for what proves success, fallbacks for safe recovery choices, and clarificationPolicy for when Donkey should stop and ask.",diff --git a/apps/Donkey/Sources/DonkeyAI/TaskIntentWireCodec.swift b/apps/Donkey/Sources/DonkeyAI/TaskIntentWireCodec.swiftindex 517a88b9..c085b333 100644--- a/apps/Donkey/Sources/DonkeyAI/TaskIntentWireCodec.swift+++ b/apps/Donkey/Sources/DonkeyAI/TaskIntentWireCodec.swift@@ -108,7 +108,10 @@ enum TaskIntentWireCodec {"additionalProperties": ["type": "string"]],"confidence": ["type": "number", "minimum": 0, "maximum": 1],- "needsConfirmation": ["type": "boolean"],+ "needsConfirmation": [+ "type": "boolean",+ "description": "Set true ONLY when the action is destructive, irreversible, costly, or sent/shared externally AND its intent is ambiguous. Set false for safe, reversible actions — including broad or casual requests you resolved by choosing concrete specifics yourself (e.g. playing a representative song). Do not set true just because a request was casual or under-specified."+ ],"actionPlan": actionPlanSchema,"metadata": ["type": "object",@@ -199,7 +202,10 @@ enum TaskIntentWireCodec {"additionalProperties": ["type": "string"]],"confidence": ["type": "number", "minimum": 0, "maximum": 1],- "needsConfirmation": ["type": "boolean"]+ "needsConfirmation": [+ "type": "boolean",+ "description": "Set true ONLY when the action is destructive, irreversible, costly, or sent/shared externally AND its intent is ambiguous. Set false for safe, reversible actions — including broad or casual requests you resolved by choosing concrete specifics yourself (e.g. playing a representative song). Do not set true just because a request was casual or under-specified."+ ]]],"ambiguityRisk": [@@ -590,7 +596,10 @@ enum TaskIntentWireCodec {guard !toolName.isEmpty else { return nil }return LocalAppActionPlanTool(rawValue: toolName)}- let inputEntity = firstNonEmpty(planSteps.map(\.inputEntity)) ?? ""+ // Planners often carry the text to enter in a step's toolInputs (e.g. toolInputs.query)+ // and leave the per-step inputEntity blank. Fall back to the conventional "query" entity so+ // text-input plans still resolve their value from entities instead of looking up a blank key.+ let inputEntity = firstNonEmpty(planSteps.map(\.inputEntity)) ?? "query"let controlID = firstNonEmpty(planSteps.map(\.controlID)) ?? ""let focusKey = firstNonEmpty(planSteps.map(\.focusKey)) ?? ""var verificationTools = tools.filter(LocalAppActionPlan.isVerificationTool)diff --git a/apps/Donkey/Sources/DonkeyRuntime/LocalAppTaskCatalog.swift b/apps/Donkey/Sources/DonkeyRuntime/LocalAppTaskCatalog.swiftindex 17ac6464..46f7ab97 100644--- a/apps/Donkey/Sources/DonkeyRuntime/LocalAppTaskCatalog.swift+++ b/apps/Donkey/Sources/DonkeyRuntime/LocalAppTaskCatalog.swift@@ -849,12 +849,25 @@ public struct LocalAppTaskCatalog: Sendable {}if intent.needsConfirmation {- return LocalAppTaskCatalogResolution(- status: .needsConfirmation,- intent: intent,- definition: definition,- metadata: ["reason": intent.metadata["missingEntity"] ?? "needsConfirmation"]- )+ // The planner's confirmation request is advisory for safe, reversible actions. Donkey is+ // an act-first Mac agent: it only hard-stops to confirm when the planner classified the+ // action as genuinely high-risk/dangerous, or when a required detail is actually missing.+ // Otherwise it proceeds and relies on the per-tool permission and guardrail gates at+ // execution time for real safety.+ let riskLevel = intent.metadata["genericHarness.risk.level"]?.lowercased() ?? ""+ let ambiguityClass = intent.metadata["genericHarness.ambiguity.class"]?.lowercased() ?? ""+ let hasMissingEntity = !(intent.metadata["missingEntity"] ?? "").isEmpty+ let mustConfirm = hasMissingEntity+ || riskLevel == "high"+ || ambiguityClass == "dangerous"+ if mustConfirm {+ return LocalAppTaskCatalogResolution(+ status: .needsConfirmation,+ intent: intent,+ definition: definition,+ metadata: ["reason": intent.metadata["missingEntity"] ?? "needsConfirmation"]+ )+ }}let availability = availabilityProvider.availability(for: definition.targetApp)