Skip to content

Open source CapCut alternative.

TypeScript

refactor(app): remove unfed app.search/app.openOrFocus tools

David Le58a75501c148
diff --git a/apps/Donkey/Sources/DonkeyHarness/GenericHarnessBuiltInToolExecutors.swift b/apps/Donkey/Sources/DonkeyHarness/GenericHarnessBuiltInToolExecutors.swift
index 446755d2..d9c16b9f 100644
--- a/apps/Donkey/Sources/DonkeyHarness/GenericHarnessBuiltInToolExecutors.swift
+++ b/apps/Donkey/Sources/DonkeyHarness/GenericHarnessBuiltInToolExecutors.swift
@@ -20,31 +20,6 @@ public struct HarnessMemoryEntry: Codable, Equatable, Sendable {
}
}
-public struct HarnessAppLookupEntry: Codable, Equatable, Sendable {
- public var id: String
- public var name: String
- public var bundleIdentifier: String?
- public var path: String?
- public var isInstalled: Bool
- public var metadata: [String: String]
-
- public init(
- id: String,
- name: String,
- bundleIdentifier: String? = nil,
- path: String? = nil,
- isInstalled: Bool = true,
- metadata: [String: String] = [:]
- ) {
- self.id = id
- self.name = name
- self.bundleIdentifier = bundleIdentifier
- self.path = path
- self.isInstalled = isInstalled
- self.metadata = metadata
- }
-}
-
public enum HarnessGeneratedScriptLanguage: String, Codable, Equatable, Sendable {
case appleScript
case shell
@@ -206,7 +181,6 @@ public actor HarnessGeneratedScriptStore {
public struct HarnessBuiltInToolServices: Sendable {
public var memoryEntries: [HarnessMemoryEntry]
- public var appEntries: [HarnessAppLookupEntry]
public var skillRegistry: HarnessSkillRegistry?
public var generatedScripts: HarnessGeneratedScriptStore
public var applicationLearningStore: HarnessApplicationLearningStore
@@ -220,7 +194,6 @@ public struct HarnessBuiltInToolServices: Sendable {
public init(
memoryEntries: [HarnessMemoryEntry] = [],
- appEntries: [HarnessAppLookupEntry] = [],
skillRegistry: HarnessSkillRegistry? = nil,
generatedScripts: HarnessGeneratedScriptStore = HarnessGeneratedScriptStore(),
applicationLearningStore: HarnessApplicationLearningStore = HarnessApplicationLearningStore(),
@@ -231,7 +204,6 @@ public struct HarnessBuiltInToolServices: Sendable {
commandExecutor: (@Sendable (HarnessToolExecutionContext) async -> HarnessToolResult?)? = nil
) {
self.memoryEntries = memoryEntries
- self.appEntries = appEntries
self.skillRegistry = skillRegistry
self.generatedScripts = generatedScripts
self.applicationLearningStore = applicationLearningStore
@@ -280,10 +252,6 @@ public enum BuiltInHarnessToolExecutors {
return await scriptValidate(context, services: services)
case "skill.script.execute":
return await scriptExecute(context, services: services, executor: services.skillScriptExecutor)
- case "app.search":
- return appSearch(context, services: services)
- case "app.openOrFocus":
- return appOpenOrFocus(context, services: services)
case "screen.observe":
return screenObserve(context)
case "elements.get":
@@ -630,78 +598,6 @@ public enum BuiltInHarnessToolExecutors {
)
}
- // MARK: - App Search & Focus
-
- private static func appSearch(
- _ context: HarnessToolExecutionContext,
- services: HarnessBuiltInToolServices
- ) -> HarnessToolResult {
- guard let query = trimmed(context.call.input["query"] ?? context.call.input["target"]) else {
- return invalidInput(context, "app.search requires a non-empty query.")
- }
- let queryTokens = tokens(in: query)
- let appMatches = services.appEntries
- .filter { entry in
- Self.matches(
- tokens: queryTokens,
- values: [entry.id, entry.name, entry.bundleIdentifier ?? "", entry.path ?? ""] + Array(entry.metadata.values)
- )
- }
- .prefix(10)
- let facts = Dictionary<String, String>(
- uniqueKeysWithValues: appMatches.map { entry in
- ("app.search.match.\(entry.id)", entry.name)
- }
- )
- return success(
- context,
- summary: "Found \(appMatches.count) app/item match(es).",
- facts: facts.merging([
- "app.search.query": query,
- "app.search.ids": appMatches.map(\.id).joined(separator: ","),
- "lastAcceptedTool": context.call.name
- ]) { current, _ in current },
- metadata: [
- "resultCount": String(appMatches.count),
- "targetIDs": appMatches.map(\.id).joined(separator: ",")
- ]
- )
- }
-
- private static func appOpenOrFocus(
- _ context: HarnessToolExecutionContext,
- services: HarnessBuiltInToolServices
- ) -> HarnessToolResult {
- guard let targetID = trimmed(context.call.input["targetID"]) else {
- return invalidInput(context, "app.openOrFocus requires a targetID.")
- }
- guard let target = services.appEntries.first(where: { appMatchesTarget($0, targetID: targetID) }) else {
- return failed(context, "App/item target was not found: \(targetID)", reason: "targetNotFound")
- }
- guard target.isInstalled else {
- return failed(context, "App/item target is not installed: \(target.name)", reason: "targetUnavailable")
- }
- return HarnessToolResult(
- callID: context.call.id,
- toolName: context.call.name,
- status: .succeeded,
- summary: "Focused \(target.name).",
- observations: HarnessObservationDelta(
- focusedApp: target.name,
- facts: [
- "focusedApp.id": target.id,
- "focusedApp.bundleIdentifier": target.bundleIdentifier ?? "",
- "lastAcceptedTool": context.call.name
- ]
- ),
- metadata: target.metadata.merging([
- "targetID": target.id,
- "bundleIdentifier": target.bundleIdentifier ?? "",
- "path": target.path ?? ""
- ]) { current, _ in current }
- )
- }
-
// MARK: - Screen & Elements
private static func screenObserve(_ context: HarnessToolExecutionContext) -> HarnessToolResult {
@@ -1475,11 +1371,6 @@ public enum BuiltInHarnessToolExecutors {
}
}
- private static func appMatchesTarget(_ entry: HarnessAppLookupEntry, targetID: String) -> Bool {
- [entry.id, entry.name, entry.bundleIdentifier ?? "", entry.path ?? ""]
- .contains { normalized($0) == normalized(targetID) }
- }
-
private static func actionAllowed(_ action: String, elementActions: [String]) -> Bool {
let normalizedAction = normalized(action)
let aliases: [String: Set<String>] = [
diff --git a/apps/Donkey/Sources/DonkeyHarness/GenericHarnessToolRegistry.swift b/apps/Donkey/Sources/DonkeyHarness/GenericHarnessToolRegistry.swift
index f2085de0..f14c48d1 100644
--- a/apps/Donkey/Sources/DonkeyHarness/GenericHarnessToolRegistry.swift
+++ b/apps/Donkey/Sources/DonkeyHarness/GenericHarnessToolRegistry.swift
@@ -262,25 +262,6 @@ public enum BuiltInHarnessToolCatalog {
"directModelScriptExecution": "false"
]
),
- descriptor(
- "app.search",
- pluginID: "core.computer-use",
- summary: "Search installed apps, running apps, files, folders, default handlers, and capability catalog entries.",
- input: ["query": "Structured app/item/capability query."],
- output: ["matches": "Ranked local apps/items/capabilities."],
- permissions: [.appLookup],
- safety: .readOnly
- ),
- descriptor(
- "app.openOrFocus",
- pluginID: "core.computer-use",
- summary: "Open or focus a validated local app or item.",
- input: ["targetID": "Resolved app or local item target."],
- output: ["focusedApp": "Focused application after the action."],
- permissions: [.appControl],
- safety: .reversible,
- verification: ["focused app or opened local item is observed"]
- ),
descriptor(
"screen.observe",
pluginID: "core.computer-use",
diff --git a/apps/Donkey/Tests/DonkeyRuntimeTests/GenericHarnessTests.swift b/apps/Donkey/Tests/DonkeyRuntimeTests/GenericHarnessTests.swift
index 9eb486e3..0ab0e677 100644
--- a/apps/Donkey/Tests/DonkeyRuntimeTests/GenericHarnessTests.swift
+++ b/apps/Donkey/Tests/DonkeyRuntimeTests/GenericHarnessTests.swift
@@ -614,7 +614,7 @@ struct GenericHarnessTests {
}
@Test
- func builtInExecutorsRetrieveMemoryAndResolveApps() async {
+ func builtInExecutorsRetrieveMemory() async {
let registry = BuiltInHarnessToolCatalog.registryWithBuiltInExecutors(
services: HarnessBuiltInToolServices(
memoryEntries: [
@@ -623,14 +623,6 @@ struct GenericHarnessTests {
summary: "Calendar is the preferred scheduling app.",
value: "Use Calendar for schedule lookups."
)
- ],
- appEntries: [
- HarnessAppLookupEntry(
- id: "com.apple.iCal",
- name: "Calendar",
- bundleIdentifier: "com.apple.iCal",
- path: "/System/Applications/Calendar.app"
- )
]
)
)
@@ -641,24 +633,9 @@ struct GenericHarnessTests {
worldModel: HarnessWorldModel(),
grantedPermissions: [.memory]
)
- let appSearch = await registry.execute(
- HarnessToolCall(id: "app-search-call", name: "app.search", input: ["query": "calendar"]),
- taskID: "task-tools",
- worldModel: HarnessWorldModel(),
- grantedPermissions: [.appLookup]
- )
- let open = await registry.execute(
- HarnessToolCall(id: "app-open-call", name: "app.openOrFocus", input: ["targetID": "com.apple.iCal"]),
- taskID: "task-tools",
- worldModel: HarnessWorldModel(),
- grantedPermissions: [.appControl]
- )
#expect(memory.status == .succeeded)
#expect(memory.observations.facts["memory.retrieve.count"] == "1")
- #expect(appSearch.metadata["targetIDs"] == "com.apple.iCal")
- #expect(open.observations.focusedApp == "Calendar")
- #expect(open.observations.facts["focusedApp.bundleIdentifier"] == "com.apple.iCal")
}
@Test