Open source CapCut alternative.
TypeScript
feat(site): show "donkey vision" wordmark on the Donkey Vision page
David Le5a8b42db6c27
diff --git a/apps/Donkey/Sources/Donkey/UserQueryCommandHandler.swift b/apps/Donkey/Sources/Donkey/UserQueryCommandHandler.swiftindex bd246c98..1d799341 100644--- a/apps/Donkey/Sources/Donkey/UserQueryCommandHandler.swift+++ b/apps/Donkey/Sources/Donkey/UserQueryCommandHandler.swift@@ -79,7 +79,7 @@ protocol UserQueryCommandHandling: Sendable {) async -> UserQueryCommandHandlingResultfunc pauseCommand(taskID: String) async -> Boolfunc resumeCommand(taskID: String) async -> Bool- func approvePermissionGate(taskID: String) async -> Bool+ func approvePermissionGate(taskID: String, alwaysAllow: Bool) async -> Bool}extension UserQueryCommandHandling {@@ -194,9 +194,10 @@ struct LocalAppUserQueryCommandHandler: UserQueryCommandHandling {) != nil}- func approvePermissionGate(taskID: String) async -> Bool {+ func approvePermissionGate(taskID: String, alwaysAllow: Bool) async -> Bool {await genericHarnessLifecycle.approvePermissionGate(taskID: taskID,+ decision: alwaysAllow ? .allowAlways : .allow,reason: "User query approved pending permissions") != nil}@@ -682,7 +683,11 @@ struct LocalAppUserQueryCommandHandler: UserQueryCommandHandling {"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 ?? ""+ "genericHarness.pendingQuestion": runStep?.task.pendingContinuation?.question ?? "",+ "genericHarness.shellConsent.command": runStep?.task.pendingContinuation?.metadata["shell.command"] ?? "",+ "genericHarness.shellConsent.tier": runStep?.task.pendingContinuation?.metadata["shell.tier"] ?? "",+ "genericHarness.shellConsent.reason": runStep?.task.pendingContinuation?.metadata["shell.reason"] ?? "",+ "genericHarness.shellConsent.allowAlways": runStep?.task.pendingContinuation?.metadata["shell.allowAlways"] ?? ""]}}diff --git a/apps/Donkey/Sources/Donkey/UserQueryOverlayModel.swift b/apps/Donkey/Sources/Donkey/UserQueryOverlayModel.swiftindex 7b84579e..56b07699 100644--- a/apps/Donkey/Sources/Donkey/UserQueryOverlayModel.swift+++ b/apps/Donkey/Sources/Donkey/UserQueryOverlayModel.swift@@ -462,7 +462,7 @@ final class UserQueryOverlayModel: ObservableObject, UserQueryIntentSink {}}- func approvePermissionGate(id taskID: String) {+ func approvePermissionGate(id taskID: String, alwaysAllow: Bool = false) {guard let task = task(withID: taskID),task.status == .waitingForPermission else {return@@ -477,7 +477,7 @@ final class UserQueryOverlayModel: ObservableObject, UserQueryIntentSink {promptState.promptText = task.titlesyncPrimaryTaskPausedFlag()Task { [weak self, commandHandler] in- let approved = await commandHandler.approvePermissionGate(taskID: taskID)+ let approved = await commandHandler.approvePermissionGate(taskID: taskID, alwaysAllow: alwaysAllow)await MainActor.run {guard let self else { return }if approved {diff --git a/apps/Donkey/Sources/DonkeyHarness/GenericHarnessCoordinator.swift b/apps/Donkey/Sources/DonkeyHarness/GenericHarnessCoordinator.swiftindex 525dcb44..d2e355b7 100644--- a/apps/Donkey/Sources/DonkeyHarness/GenericHarnessCoordinator.swift+++ b/apps/Donkey/Sources/DonkeyHarness/GenericHarnessCoordinator.swift@@ -279,14 +279,16 @@ public actor HarnessTaskCoordinator {taskID: String,missingPermissions: [HarnessPermission],pendingToolCall: HarnessToolCall,- reason: String = "Task needs permission"+ reason: String = "Task needs permission",+ metadata: [String: String] = [:]) async -> HarnessTaskState? {await mutate(taskID: taskID, status: .waitingForPermission, summary: reason) { task intask.pendingContinuation = HarnessPendingContinuation(stage: .permissionGate,reason: reason,missingPermissions: missingPermissions,- pendingToolCall: pendingToolCall+ pendingToolCall: pendingToolCall,+ metadata: metadata)}}diff --git a/apps/Donkey/Sources/DonkeyHarness/GenericHarnessRuntime.swift b/apps/Donkey/Sources/DonkeyHarness/GenericHarnessRuntime.swiftindex 1402c7ff..af163fb0 100644--- a/apps/Donkey/Sources/DonkeyHarness/GenericHarnessRuntime.swift+++ b/apps/Donkey/Sources/DonkeyHarness/GenericHarnessRuntime.swift@@ -185,7 +185,8 @@ public struct GenericHarnessRuntime: Sendable {guard let stoppedTask = await coordinator.waitForPermission(taskID: taskID,missingPermissions: result.missingPermissions,- pendingToolCall: call+ pendingToolCall: call,+ metadata: result.metadata) else {return nil}diff --git a/apps/Donkey/Sources/DonkeyRuntime/AppHarnessGenericLifecycle.swift b/apps/Donkey/Sources/DonkeyRuntime/AppHarnessGenericLifecycle.swiftindex 06d2c31b..b1db01d2 100644--- a/apps/Donkey/Sources/DonkeyRuntime/AppHarnessGenericLifecycle.swift+++ b/apps/Donkey/Sources/DonkeyRuntime/AppHarnessGenericLifecycle.swift@@ -2,6 +2,15 @@ import DonkeyContractsimport DonkeyHarnessimport Foundation+/// How the user answered a permission/consent gate. `allow` covers a one-time+/// approval (category permission grant, or shell allow-once); `allowAlways`+/// persists a standing shell-command rule and is offered only for non-highRisk+/// commands.+public enum HarnessGateApproval: String, Sendable {+ case allow+ case allowAlways+}+public struct AppHarnessGenericLifecyclePreparedTurn: Equatable, Sendable {public var thread: HarnessThreadpublic var task: HarnessTaskState@@ -142,14 +151,32 @@ public struct AppHarnessGenericLifecycle: Sendable {}@discardableResult- public func approvePermissionGate(taskID: String, reason: String) async -> HarnessTaskState? {+ public func approvePermissionGate(+ taskID: String,+ decision: HarnessGateApproval = .allow,+ reason: String+ ) async -> HarnessTaskState? {guard let task = await coordinator.task(id: taskID),task.status == .waitingForPermission,- let continuation = task.pendingContinuation,- !continuation.missingPermissions.isEmpty else {+ let continuation = task.pendingContinuation else {return nil}+ // Shell-command consent: persist an always-allow rule or grant a single+ // use, then resume so the loop re-issues the command and the executor+ // finds it allowed.+ if continuation.metadata["gate"] == "shellConsent" {+ let signature = continuation.metadata["shell.signature"] ?? ""+ let tier = ShellRiskTier(rawValue: continuation.metadata["shell.tier"] ?? "") ?? .reversibleWrite+ if decision == .allowAlways, tier != .highRisk {+ await ShellPermissionPolicyStore.shared.allowAlways(signature, tier: tier)+ } else {+ await ShellPermissionPolicyStore.shared.grantOnce(taskID: taskID, signature: signature)+ }+ return await coordinator.resume(taskID: taskID, reason: reason)+ }++ guard !continuation.missingPermissions.isEmpty else { return nil }return await coordinator.grantPermissions(taskID: taskID,permissions: Set(continuation.missingPermissions),diff --git a/apps/Donkey/Sources/DonkeyRuntime/DonkeyCommandBackends.swift b/apps/Donkey/Sources/DonkeyRuntime/DonkeyCommandBackends.swiftindex d0e094bd..c33aa284 100644--- a/apps/Donkey/Sources/DonkeyRuntime/DonkeyCommandBackends.swift+++ b/apps/Donkey/Sources/DonkeyRuntime/DonkeyCommandBackends.swift@@ -228,50 +228,6 @@ public enum DonkeyCommandBackends {/// Max stdout characters returned to the model.private static let shellOutputMaxLength = 4_000- /// Executables that are unsafe in any position. Matched against the leading- /// token of each pipeline/command segment (path-stripped, dequoted), so a- /// bare `rm file`, `/bin/rm`, or a denied command inside `$(…)` is caught —- /// unlike substring matching, which both missed these and false-positived on- /// benign text.- private static let shellDeniedExecutables: Set<String> = [- "sudo", "su", "doas",- "rm", "rmdir", "mv", "dd", "mkfs", "fdisk", "diskutil", "shred", "srm",- "chmod", "chown", "chflags",- "shutdown", "reboot", "halt", "killall", "pkill", "kill",- "launchctl", "csrutil", "spctl", "nvram", "pmset",- "scp", "sftp", "ssh", "telnet", "nc", "ncat", "curl", "wget",- "eval", "source", "security"- ]-- /// Dangerous regardless of position (shell-level constructs / sensitive- /// redirect targets / privilege-escalation phrases).- private static let shellDeniedSubstrings: [String] = [- "do shell script", ":(){", "| sh", "|sh", "| bash", "|bash",- "> /dev", ">/dev", "> /system", ">/system", "> /usr", ">/usr",- "> /etc", ">/etc", "defaults delete"- ]-- /// Returns the matched unsafe token if the command should be refused, else nil.- static func unsafeShellReason(_ command: String) -> String? {- let lowered = command.lowercased()- for substring in shellDeniedSubstrings where lowered.contains(substring) {- return substring.trimmingCharacters(in: .whitespaces)- }- // Split into command segments on shell separators and substitution- // boundaries, then check each segment's leading executable.- let separators = CharacterSet(charactersIn: ";|&\n`(")- for segment in lowered.components(separatedBy: separators) {- let trimmedSegment = segment.trimmingCharacters(in: .whitespaces)- guard let firstToken = trimmedSegment.split(separator: " ").first.map(String.init) else { continue }- let executable = (firstToken.split(separator: "/").last.map(String.init) ?? firstToken)- .trimmingCharacters(in: CharacterSet(charactersIn: "\\'\"$"))- if shellDeniedExecutables.contains(executable) {- return executable- }- }- return nil- }-private static func shellExec(_ context: HarnessToolExecutionContext) async -> HarnessToolResult {guard let command = trimmed(context.call.input["command"]) ?? trimmed(context.call.input["cmd"]) else {return invalidInput(context, "shell_exec requires a one-line `command`.")@@ -282,12 +238,15 @@ public enum DonkeyCommandBackends {guard command.count <= shellCommandMaxLength else {return invalidInput(context, "shell_exec command is too long.")}- if let blocked = unsafeShellReason(command) {- return failed(- context,- "Refused an unsafe shell command (matched \"\(blocked)\").",- reason: "blockedCommand"- )++ // Classify by risk tier. Reads run immediately; anything that changes+ // state needs consent (allow-once / always-allow) unless it was already+ // granted. Nothing is silently refused.+ let classification = ShellCommandClassifier.classify(command)+ if classification.tier != .read {+ if let gate = await consentGate(context, command: command, classification: classification) {+ return gate+ }}let result = await Task.detached(priority: .userInitiated) {@@ -318,6 +277,45 @@ public enum DonkeyCommandBackends {)}+ /// Returns nil when the command is already allowed (run it), or a+ /// `waitingForPermission` gate result the runtime turns into an allow-once /+ /// always-allow prompt. `highRisk` commands can only be allowed once.+ private static func consentGate(+ _ context: HarnessToolExecutionContext,+ command: String,+ classification: ShellCommandClassification+ ) async -> HarnessToolResult? {+ let store = ShellPermissionPolicyStore.shared+ let signature = classification.signature++ var allowed = false+ if classification.tier != .highRisk {+ allowed = await store.isAlwaysAllowed(signature)+ }+ if !allowed {+ allowed = await store.consumeOnce(taskID: context.taskID, signature: signature)+ }+ if allowed { return nil }++ let allowAlways = classification.tier != .highRisk+ let reason = classification.reason.map { " (\($0))" } ?? ""+ return HarnessToolResult(+ callID: context.call.id,+ toolName: context.call.name,+ status: .waitingForPermission,+ summary: "Needs your approval to run `\(command)`\(reason).",+ metadata: [+ "executor": "donkeyCommandLayer",+ "gate": "shellConsent",+ "shell.command": command,+ "shell.signature": signature,+ "shell.tier": classification.tier.rawValue,+ "shell.reason": classification.reason ?? "",+ "shell.allowAlways": allowAlways ? "true" : "false"+ ]+ )+ }+private struct ShellResult: Sendable {var exitCode: Int32var stdout: Stringdiff --git a/apps/Donkey/Sources/DonkeyRuntime/ShellCommandClassifier.swift b/apps/Donkey/Sources/DonkeyRuntime/ShellCommandClassifier.swiftnew file mode 100644index 00000000..adf04bf5--- /dev/null+++ b/apps/Donkey/Sources/DonkeyRuntime/ShellCommandClassifier.swift@@ -0,0 +1,331 @@+import Foundation++/// Risk tiers for a `shell_exec` command. The tier decides whether the command+/// runs silently, prompts for allow-once/always-allow consent, or prompts every+/// time and can never be blanket-allowed.+///+/// This replaces the old all-or-nothing denylist: nothing is silently refused,+/// but anything that changes state asks first. The classifier matches **argv+/// tokens** (executable, subcommand, flags) — typed/technical fields of a+/// structured command string — never natural-language user intent.+public enum ShellRiskTier: String, Codable, Sendable, Comparable {+ /// Read-only inspection. Runs immediately, no prompt.+ case read+ /// A reversible change to app or system state. Prompts once; the user may+ /// "allow once" or "always allow" the command signature.+ case reversibleWrite+ /// Destructive, privileged, or network-egress. Prompts every time and is+ /// never eligible for "always allow".+ case highRisk++ private var order: Int {+ switch self {+ case .read: return 0+ case .reversibleWrite: return 1+ case .highRisk: return 2+ }+ }++ public static func < (lhs: ShellRiskTier, rhs: ShellRiskTier) -> Bool {+ lhs.order < rhs.order+ }+}++/// The result of classifying a one-line shell command.+public struct ShellCommandClassification: Sendable, Equatable {+ /// The most restrictive tier across every segment of the command.+ public var tier: ShellRiskTier+ /// A normalized `executable [subcommand]` signature that a prompt and an+ /// "always allow" rule key on (e.g. `defaults write`, `open`, `mdfind`).+ /// Taken from the segment that set the overall tier.+ public var signature: String+ /// Short, human-readable reason the deciding segment landed in its tier,+ /// surfaced in the consent prompt (e.g. "deletes files").+ public var reason: String?++ public init(tier: ShellRiskTier, signature: String, reason: String? = nil) {+ self.tier = tier+ self.signature = signature+ self.reason = reason+ }+}++/// Classifies `shell_exec` commands into risk tiers by inspecting argv tokens.+public enum ShellCommandClassifier {++ // MARK: - Public API++ /// Classify a one-line command. The overall tier is the most restrictive+ /// across all pipeline/substitution segments (so `mdfind x | xargs rm`+ /// classifies as `highRisk`), and the returned signature/reason come from+ /// the segment that set that tier.+ public static func classify(_ command: String) -> ShellCommandClassification {+ let lowered = command.lowercased()++ // Shell-level constructs that are dangerous regardless of which segment+ // they appear in (pipe-to-shell, fork bomb, sensitive redirect targets,+ // AppleScript `do shell script` escape hatch).+ for (needle, reason) in highRiskSubstrings where lowered.contains(needle) {+ return ShellCommandClassification(tier: .highRisk, signature: needle.trimmingCharacters(in: .whitespaces), reason: reason)+ }++ // Split into command segments on shell separators and substitution+ // boundaries, then classify each segment's effective executable. The+ // overall tier is the most restrictive segment; the signature/reason+ // come from the first segment that reached that tier.+ var worst: ShellCommandClassification?+ let separators = CharacterSet(charactersIn: ";|&\n`(")+ for rawSegment in command.components(separatedBy: separators) {+ let tokens = tokenize(rawSegment)+ guard !tokens.isEmpty else { continue }+ let classified = classifySegment(tokens)+ if worst == nil || classified.tier > worst!.tier {+ worst = classified+ }+ }++ // Empty/whitespace command: nothing to run, treat as a no-op read.+ return worst ?? ShellCommandClassification(tier: .read, signature: "", reason: nil)+ }++ // MARK: - Segment classification++ /// Classify one already-tokenized segment by its effective executable and+ /// subcommand. Wrapper commands (xargs/env/time/...) are unwrapped to the+ /// command they invoke so `xargs rm` is judged on `rm`.+ private static func classifySegment(_ tokens: [String]) -> ShellCommandClassification {+ var tokens = tokens+ var executable = normalizedExecutable(tokens.removeFirst())++ // Unwrap argument-runner wrappers to the real command they execute.+ var unwrapGuard = 0+ while wrapperExecutables.contains(executable), unwrapGuard < 4 {+ // Skip wrapper flags/assignments (e.g. `env FOO=bar cmd`, `xargs -n1 cmd`).+ while let next = tokens.first, next.hasPrefix("-") || next.contains("=") {+ tokens.removeFirst()+ }+ guard !tokens.isEmpty else { break }+ executable = normalizedExecutable(tokens.removeFirst())+ unwrapGuard += 1+ }++ let firstArg = tokens.first.map { $0.lowercased() }++ if let reason = highRiskExecutables[executable] {+ return ShellCommandClassification(tier: .highRisk, signature: executable, reason: reason)+ }++ // Per-tool subcommand/flag refinement (read vs write of the same tool).+ if let refined = refine(executable: executable, tokens: tokens, firstArg: firstArg) {+ return refined+ }++ if readExecutables.contains(executable) {+ return ShellCommandClassification(tier: .read, signature: executable, reason: nil)+ }+ if let reason = reversibleWriteExecutables[executable] {+ return ShellCommandClassification(tier: .reversibleWrite, signature: executable, reason: reason)+ }++ // Unknown executable: don't auto-run and don't block — prompt once.+ return ShellCommandClassification(tier: .reversibleWrite, signature: executable, reason: "unrecognized command")+ }++ /// Tool-specific refinement: the same executable can be a read or a write+ /// depending on its subcommand or flags.+ private static func refine(executable: String, tokens: [String], firstArg: String?) -> ShellCommandClassification? {+ switch executable {+ case "defaults":+ switch firstArg {+ case "read", "read-type", "domains", "find", "export":+ return ShellCommandClassification(tier: .read, signature: "defaults read", reason: nil)+ case "delete":+ return ShellCommandClassification(tier: .highRisk, signature: "defaults delete", reason: "removes preference keys")+ case "write", "rename", "import":+ let sig = "defaults \(firstArg ?? "write")"+ if referencesSensitiveDomain(tokens) {+ return ShellCommandClassification(tier: .highRisk, signature: sig, reason: "changes a security/privacy setting")+ }+ return ShellCommandClassification(tier: .reversibleWrite, signature: sig, reason: "changes an app preference")+ default:+ return ShellCommandClassification(tier: .reversibleWrite, signature: "defaults", reason: "changes a preference")+ }+ case "pmset":+ // `-g`/`-G` are read-only queries (battery, assertions, etc.).+ if tokens.contains("-g") || tokens.contains("-G") {+ return ShellCommandClassification(tier: .read, signature: "pmset -g", reason: nil)+ }+ return ShellCommandClassification(tier: .reversibleWrite, signature: "pmset", reason: "changes power settings")+ case "networksetup":+ if let firstArg, firstArg.hasPrefix("-get") || firstArg.hasPrefix("-list") {+ return ShellCommandClassification(tier: .read, signature: "networksetup \(firstArg)", reason: nil)+ }+ if let firstArg, firstArg.hasPrefix("-set") {+ return ShellCommandClassification(tier: .reversibleWrite, signature: "networksetup \(firstArg)", reason: "changes a network setting")+ }+ return ShellCommandClassification(tier: .reversibleWrite, signature: "networksetup", reason: "changes a network setting")+ case "scutil":+ // `scutil --get`/`scutil` queries are read; `--set` mutates.+ if tokens.contains("--set") {+ return ShellCommandClassification(tier: .reversibleWrite, signature: "scutil --set", reason: "changes a system identity setting")+ }+ return ShellCommandClassification(tier: .read, signature: "scutil", reason: nil)+ case "plutil":+ if tokens.contains("-convert") || tokens.contains("-replace") || tokens.contains("-insert") || tokens.contains("-remove") {+ return ShellCommandClassification(tier: .reversibleWrite, signature: "plutil", reason: "rewrites a plist")+ }+ return ShellCommandClassification(tier: .read, signature: "plutil -p", reason: nil)+ case "sed":+ if tokens.contains(where: { $0 == "-i" || $0.hasPrefix("-i") }) {+ return ShellCommandClassification(tier: .reversibleWrite, signature: "sed -i", reason: "edits a file in place")+ }+ return ShellCommandClassification(tier: .read, signature: "sed", reason: nil)+ default:+ return nil+ }+ }++ // MARK: - Tokenization++ /// Split a segment into whitespace-separated tokens. Leading environment+ /// assignments (e.g. `FOO=bar cmd`) are dropped so the executable is found.+ private static func tokenize(_ segment: String) -> [String] {+ var tokens = segment+ .split(whereSeparator: { $0 == " " || $0 == "\t" })+ .map(String.init)+ while let first = tokens.first, first.contains("="), !first.hasPrefix("-"), isLeadingAssignment(first) {+ tokens.removeFirst()+ }+ return tokens+ }++ private static func isLeadingAssignment(_ token: String) -> Bool {+ // NAME=VALUE with a valid env-var name on the left.+ guard let eq = token.firstIndex(of: "=") else { return false }+ let name = token[token.startIndex..<eq]+ return !name.isEmpty && name.allSatisfy { $0.isLetter || $0.isNumber || $0 == "_" }+ && (name.first?.isNumber == false)+ }++ /// Path-strip and dequote a token down to its bare executable name.+ private static func normalizedExecutable(_ token: String) -> String {+ let dequoted = token.trimmingCharacters(in: CharacterSet(charactersIn: "\\'\"$"))+ let lastPathComponent = dequoted.split(separator: "/").last.map(String.init) ?? dequoted+ return lastPathComponent.lowercased()+ }++ private static func referencesSensitiveDomain(_ tokens: [String]) -> Bool {+ let joined = tokens.joined(separator: " ").lowercased()+ return sensitiveDomainNeedles.contains { joined.contains($0) }+ }++ // MARK: - Tables++ /// Commands that run another command passed as arguments; classification+ /// unwraps to that inner command.+ private static let wrapperExecutables: Set<String> = [+ "xargs", "env", "time", "nice", "nohup", "command", "builtin", "stdbuf", "timeout", "caffeinate"+ ]++ /// Read-only inspection tools — safe to run without a prompt. Tools whose+ /// read/write split depends on a subcommand (defaults, pmset, networksetup,+ /// scutil, plutil, sed) are handled in `refine` and intentionally absent here.+ private static let readExecutables: Set<String> = [+ "ls", "cat", "head", "tail", "grep", "egrep", "fgrep", "rg", "find", "mdfind", "mdls",+ "which", "type", "whereis", "echo", "printf", "date", "cal", "df", "du", "pwd", "whoami",+ "id", "uname", "hostname", "sw_vers", "system_profiler", "ioreg", "vm_stat", "uptime",+ "stat", "file", "wc", "sort", "uniq", "cut", "tr", "awk", "basename", "dirname", "realpath",+ "pbpaste", "pgrep", "ps", "top", "lsof", "networkquality", "sysctl", "json_pp",+ "jq", "true", "false", "test", "seq", "md5", "shasum", "base64", "xxd", "od",+ "host", "dig", "arp", "ifconfig", "route", "last", "w", "finger", "groups"+ ]++ /// Reversible state changes — prompt once, eligible for "always allow".+ private static let reversibleWriteExecutables: [String: String] = [+ "open": "opens a file or app",+ "osascript": "runs an automation script",+ "killall": "quits an app by name",+ "pbcopy": "writes to the clipboard",+ "sips": "edits or converts an image",+ "mkdir": "creates a directory",+ "touch": "creates or updates a file",+ "ln": "creates a link",+ "cp": "copies a file",+ "mv": "moves or renames a file",+ "caffeinate": "keeps the Mac awake",+ "say": "speaks text aloud",+ "tee": "writes output to a file",+ "screencapture": "captures the screen to a file",+ "afplay": "plays an audio file"+ ]++ /// Destructive / privileged / network-egress — prompt every time, never+ /// eligible for "always allow". Value is the reason shown in the prompt.+ private static let highRiskExecutables: [String: String] = [+ "sudo": "runs with elevated privileges",+ "su": "switches user",+ "doas": "runs with elevated privileges",+ "rm": "deletes files",+ "rmdir": "deletes directories",+ "dd": "writes raw disk data",+ "mkfs": "formats a filesystem",+ "newfs_hfs": "formats a filesystem",+ "fdisk": "edits disk partitions",+ "gpt": "edits disk partitions",+ "diskutil": "modifies disks or volumes",+ "shred": "irreversibly wipes files",+ "srm": "irreversibly wipes files",+ "chmod": "changes file permissions",+ "chown": "changes file ownership",+ "chflags": "changes file flags",+ "shutdown": "shuts down the Mac",+ "reboot": "restarts the Mac",+ "halt": "halts the Mac",+ "kill": "sends a signal to a process",+ "pkill": "kills processes by pattern",+ "launchctl": "changes system services",+ "csrutil": "changes System Integrity Protection",+ "spctl": "changes security assessment policy",+ "nvram": "changes firmware variables",+ "fdesetup": "changes FileVault",+ "security": "accesses the keychain",+ "scp": "transfers files over the network",+ "sftp": "transfers files over the network",+ "ssh": "opens a remote shell",+ "telnet": "opens a remote connection",+ "nc": "opens a raw network connection",+ "ncat": "opens a raw network connection",+ "curl": "transfers data over the network",+ "wget": "downloads from the network",+ "eval": "evaluates a constructed command",+ "source": "sources a script into the shell"+ ]++ /// Whole-command shell constructs that are high-risk wherever they appear.+ private static let highRiskSubstrings: [(String, String)] = [+ ("| sh", "pipes output into a shell"),+ ("|sh", "pipes output into a shell"),+ ("| bash", "pipes output into a shell"),+ ("|bash", "pipes output into a shell"),+ ("| zsh", "pipes output into a shell"),+ ("|zsh", "pipes output into a shell"),+ (":(){", "fork bomb"),+ ("do shell script", "AppleScript shell escape"),+ ("> /dev", "writes to a device file"),+ (">/dev", "writes to a device file"),+ ("> /system", "writes under /System"),+ (">/system", "writes under /System"),+ ("> /usr", "writes under /usr"),+ (">/usr", "writes under /usr"),+ ("> /etc", "writes under /etc"),+ (">/etc", "writes under /etc")+ ]++ /// Preference domains / phrases that make a `defaults`/settings write+ /// security- or privacy-sensitive (kept high-risk, no "always allow").+ private static let sensitiveDomainNeedles: [String] = [+ "com.apple.tcc", "com.apple.access", "com.apple.screensaver.askforpassword",+ "filevault", "fdesetup", "com.apple.security", "com.apple.loginwindow",+ "password", "com.apple.applicationaccess", "com.apple.mobiledevice"+ ]+}diff --git a/apps/Donkey/Sources/DonkeyRuntime/ShellPermissionPolicyStore.swift b/apps/Donkey/Sources/DonkeyRuntime/ShellPermissionPolicyStore.swiftnew file mode 100644index 00000000..240060ed--- /dev/null+++ b/apps/Donkey/Sources/DonkeyRuntime/ShellPermissionPolicyStore.swift@@ -0,0 +1,108 @@+import Foundation++/// Remembers shell-command consent decisions.+///+/// Two layers:+/// - **Always-allow** rules, keyed on a command signature (e.g. `defaults write`,+/// `open`), persisted to disk so they survive across runs — the "always allow"+/// choice. `highRisk` signatures are never written here.+/// - A transient **allow-once** ledger held only in memory: when the user picks+/// "allow once", the deciding command's signature is granted a single use for+/// that task and consumed the next time the executor runs it, so it can never+/// silently become a standing rule.+public actor ShellPermissionPolicyStore {+ public static let shared = ShellPermissionPolicyStore()++ private let storeURL: URL+ private var alwaysAllowed: Set<String>+ private var loaded = false+ /// One-shot grants keyed `"taskID\u{1}signature"`, consumed on first use.+ private var onceGrants: Set<String> = []++ public init(storeURL: URL? = nil) {+ self.storeURL = storeURL ?? Self.defaultStoreURL()+ self.alwaysAllowed = []+ }++ private static func defaultStoreURL() -> URL {+ FileManager.default.urls(for: .applicationSupportDirectory, in: .userDomainMask)[0]+ .appendingPathComponent("Donkey", isDirectory: true)+ .appendingPathComponent("HarnessStore", isDirectory: true)+ .appendingPathComponent("shell-permissions.json")+ }++ // MARK: - Always-allow (persistent)++ public func isAlwaysAllowed(_ signature: String) -> Bool {+ load()+ return alwaysAllowed.contains(signature)+ }++ /// Persist a standing "always allow" rule. Refuses `highRisk` signatures —+ /// those must be re-consented every time.+ public func allowAlways(_ signature: String, tier: ShellRiskTier) {+ guard tier != .highRisk, !signature.isEmpty else { return }+ load()+ guard !alwaysAllowed.contains(signature) else { return }+ alwaysAllowed.insert(signature)+ save()+ }++ public func revokeAlways(_ signature: String) {+ load()+ guard alwaysAllowed.contains(signature) else { return }+ alwaysAllowed.remove(signature)+ save()+ }++ public func allAlwaysAllowed() -> Set<String> {+ load()+ return alwaysAllowed+ }++ // MARK: - Allow-once (transient)++ public func grantOnce(taskID: String, signature: String) {+ guard !signature.isEmpty else { return }+ onceGrants.insert(Self.onceKey(taskID: taskID, signature: signature))+ }++ /// Returns true and removes the grant if a one-shot allowance exists for this+ /// task + signature; false otherwise.+ public func consumeOnce(taskID: String, signature: String) -> Bool {+ let key = Self.onceKey(taskID: taskID, signature: signature)+ guard onceGrants.contains(key) else { return false }+ onceGrants.remove(key)+ return true+ }++ private static func onceKey(taskID: String, signature: String) -> String {+ "\(taskID)\u{1}\(signature)"+ }++ // MARK: - Persistence++ private func load() {+ guard !loaded else { return }+ loaded = true+ guard let data = try? Data(contentsOf: storeURL),+ let decoded = try? JSONDecoder().decode(PersistedPolicy.self, from: data) else {+ return+ }+ alwaysAllowed = Set(decoded.alwaysAllowedSignatures)+ }++ private func save() {+ let payload = PersistedPolicy(alwaysAllowedSignatures: alwaysAllowed.sorted())+ guard let data = try? JSONEncoder().encode(payload) else { return }+ try? FileManager.default.createDirectory(+ at: storeURL.deletingLastPathComponent(),+ withIntermediateDirectories: true+ )+ try? data.write(to: storeURL, options: .atomic)+ }++ private struct PersistedPolicy: Codable {+ var alwaysAllowedSignatures: [String]+ }+}diff --git a/site/src/app/_components/landing/TopNav.tsx b/site/src/app/_components/landing/TopNav.tsxindex 100cc74f..db5c1be1 100644--- a/site/src/app/_components/landing/TopNav.tsx+++ b/site/src/app/_components/landing/TopNav.tsx@@ -14,6 +14,9 @@ const NAV_ICON_SIZE = 59;type Props = {homeHref?: string;+ // Wordmark next to the logo. Donkey Vision is its own B2B product, so that+ // page overrides the default "donkey" with "donkey vision".+ wordmark?: string;// Log in + Sign up cluster. Hidden when an authToggle is supplied.showAuthLinks?: boolean;// The Download pill belongs to the main landing page only.@@ -24,6 +27,7 @@ type Props = {export function TopNav({homeHref = "/",+ wordmark = "donkey",showAuthLinks = true,showDownload = false,authToggle,@@ -70,7 +74,7 @@ export function TopNav({className="block h-full w-full object-cover"/></div>- <span className="text-2xl font-semibold">donkey</span>+ <span className="text-2xl font-semibold">{wordmark}</span></Link><div className="flex items-center gap-[10px] md:gap-4">{isSignedIn ? (diff --git a/site/src/app/donkeyvision/page.tsx b/site/src/app/donkeyvision/page.tsxindex a081e15f..53dc27cd 100644--- a/site/src/app/donkeyvision/page.tsx+++ b/site/src/app/donkeyvision/page.tsx@@ -66,7 +66,7 @@ export default function DonkeyVisionPage() {type="application/ld+json"dangerouslySetInnerHTML={{ __html: JSON.stringify(structuredData) }}/>- <TopNav />+ <TopNav wordmark="donkey vision" /><HeroSection /><ProofSection /><VisionCompareSection />