Skip to content

Open source CapCut alternative.

TypeScript

refactor(app): rename harness thread->conversation and task->agent

David Leb7d1504cd45e
diff --git a/apps/Donkey/Sources/Donkey/GeminiLiveVoiceController.swift b/apps/Donkey/Sources/Donkey/GeminiLiveVoiceController.swift
index ecf5dee3..3046ce60 100644
--- a/apps/Donkey/Sources/Donkey/GeminiLiveVoiceController.swift
+++ b/apps/Donkey/Sources/Donkey/GeminiLiveVoiceController.swift
@@ -203,7 +203,7 @@ final class GeminiLiveVoiceController {
/// The task id consent grants and tool executions are keyed on for this
/// session-wide Live "task".
- static let liveTaskID = "gemini-live"
+ static let liveAgentID = "gemini-live"
/// Permissions the Live session's Command Layer tools run with.
static let liveGrantedPermissions: Set<HarnessPermission> = [.appControl, .input, .appLookup, .skillLookup]
@@ -249,7 +249,7 @@ final class GeminiLiveVoiceController {
let toolCall = HarnessToolCall(id: call.id, name: toolName, input: call.arguments)
let result = await registry.execute(
toolCall,
- taskID: Self.liveTaskID,
+ agentID: Self.liveAgentID,
worldModel: HarnessWorldModel(),
grantedPermissions: Self.liveGrantedPermissions
)
@@ -339,11 +339,11 @@ final class GeminiLiveVoiceController {
if alwaysAllow, classification.tier != .highRisk {
await ShellPermissionPolicyStore.shared.allowAlways(classification.signature, tier: classification.tier)
} else {
- await ShellPermissionPolicyStore.shared.grantOnce(taskID: Self.liveTaskID, signature: classification.signature)
+ await ShellPermissionPolicyStore.shared.grantOnce(agentID: Self.liveAgentID, signature: classification.signature)
}
let result = await registry.execute(
pending.call,
- taskID: Self.liveTaskID,
+ agentID: Self.liveAgentID,
worldModel: HarnessWorldModel(),
grantedPermissions: Self.liveGrantedPermissions
)
diff --git a/apps/Donkey/Sources/Donkey/UserQueryTaskStore.swift b/apps/Donkey/Sources/Donkey/UserQueryConversationStore.swift
similarity index 85%
rename from apps/Donkey/Sources/Donkey/UserQueryTaskStore.swift
rename to apps/Donkey/Sources/Donkey/UserQueryConversationStore.swift
index 56d575ba..3cc7e5bc 100644
--- a/apps/Donkey/Sources/Donkey/UserQueryTaskStore.swift
+++ b/apps/Donkey/Sources/Donkey/UserQueryConversationStore.swift
@@ -3,19 +3,19 @@ import CoreData
import Foundation
@MainActor
-protocol UserQueryTaskStoring {
- func loadRecentTasks(limit: Int) -> [UserQueryNotchTask]
- func searchTasks(matching query: String, limit: Int) -> [UserQueryNotchTask]
- func upsertTask(_ task: UserQueryNotchTask)
+protocol UserQueryConversationStoring {
+ func loadRecentTasks(limit: Int) -> [UserQueryConversation]
+ func searchTasks(matching query: String, limit: Int) -> [UserQueryConversation]
+ func upsertTask(_ task: UserQueryConversation)
func deleteTask(id: String)
- func loadEvents(taskID: String) -> [UserQueryTaskEvent]
- func appendEvent(_ event: UserQueryTaskEvent)
- func loadAssets(taskID: String) -> [UserQueryTaskAsset]
- func appendAsset(_ asset: UserQueryTaskAsset)
+ func loadEvents(conversationID: String) -> [UserQueryConversationEvent]
+ func appendEvent(_ event: UserQueryConversationEvent)
+ func loadAssets(conversationID: String) -> [UserQueryConversationAsset]
+ func appendAsset(_ asset: UserQueryConversationAsset)
}
@MainActor
-final class CoreDataUserQueryTaskStore: UserQueryTaskStoring {
+final class CoreDataUserQueryConversationStore: UserQueryConversationStoring {
private let context: NSManagedObjectContext?
init(
@@ -24,7 +24,7 @@ final class CoreDataUserQueryTaskStore: UserQueryTaskStoring {
context = Self.makeContext(storeURL: storeURL ?? Self.defaultStoreURL())
}
- func loadRecentTasks(limit: Int) -> [UserQueryNotchTask] {
+ func loadRecentTasks(limit: Int) -> [UserQueryConversation] {
guard let context else {
return []
}
@@ -42,7 +42,7 @@ final class CoreDataUserQueryTaskStore: UserQueryTaskStoring {
return managedTasks.compactMap(Self.task(from:))
}
- func searchTasks(matching query: String, limit: Int) -> [UserQueryNotchTask] {
+ func searchTasks(matching query: String, limit: Int) -> [UserQueryConversation] {
guard let context else {
return []
}
@@ -52,8 +52,8 @@ final class CoreDataUserQueryTaskStore: UserQueryTaskStoring {
return loadRecentTasks(limit: limit)
}
- let matchingEventTaskIDs = taskIDsWithMatchingEvents(trimmedQuery)
- let matchingAssetTaskIDs = taskIDsWithMatchingAssets(trimmedQuery)
+ let matchingEventTaskIDs = conversationIDsWithMatchingEvents(trimmedQuery)
+ let matchingAssetTaskIDs = conversationIDsWithMatchingAssets(trimmedQuery)
let request = NSFetchRequest<NSManagedObject>(entityName: Self.taskEntityName)
request.fetchLimit = limit
var predicates = [
@@ -79,7 +79,7 @@ final class CoreDataUserQueryTaskStore: UserQueryTaskStoring {
return managedTasks.compactMap(Self.task(from:))
}
- func upsertTask(_ task: UserQueryNotchTask) {
+ func upsertTask(_ task: UserQueryConversation) {
guard let context else { return }
let managedTask = Self.existingTask(id: task.id, in: context)
@@ -106,17 +106,17 @@ final class CoreDataUserQueryTaskStore: UserQueryTaskStoring {
if let managedTask = Self.existingTask(id: id, in: context) {
context.delete(managedTask)
}
- Self.deleteRows(entityName: Self.eventEntityName, taskIDKey: Self.eventTaskIDKey, taskID: id, in: context)
- Self.deleteRows(entityName: Self.assetEntityName, taskIDKey: Self.assetTaskIDKey, taskID: id, in: context)
+ Self.deleteRows(entityName: Self.eventEntityName, conversationIDKey: Self.eventTaskIDKey, conversationID: id, in: context)
+ Self.deleteRows(entityName: Self.assetEntityName, conversationIDKey: Self.assetTaskIDKey, conversationID: id, in: context)
try? context.save()
}
- func loadAssets(taskID: String) -> [UserQueryTaskAsset] {
+ func loadAssets(conversationID: String) -> [UserQueryConversationAsset] {
guard let context else { return [] }
let request = NSFetchRequest<NSManagedObject>(entityName: Self.assetEntityName)
- request.predicate = NSPredicate(format: "%K == %@", Self.assetTaskIDKey, taskID)
+ request.predicate = NSPredicate(format: "%K == %@", Self.assetTaskIDKey, conversationID)
request.sortDescriptors = [
NSSortDescriptor(key: Self.assetCreatedAtKey, ascending: true)
]
@@ -128,7 +128,7 @@ final class CoreDataUserQueryTaskStore: UserQueryTaskStoring {
return managedAssets.compactMap(Self.asset(from:))
}
- func appendAsset(_ asset: UserQueryTaskAsset) {
+ func appendAsset(_ asset: UserQueryConversationAsset) {
guard let context else { return }
let managedAsset = NSManagedObject(
@@ -136,7 +136,7 @@ final class CoreDataUserQueryTaskStore: UserQueryTaskStoring {
insertInto: context
)
managedAsset.setValue(asset.id, forKey: Self.assetIDKey)
- managedAsset.setValue(asset.taskID, forKey: Self.assetTaskIDKey)
+ managedAsset.setValue(asset.conversationID, forKey: Self.assetTaskIDKey)
managedAsset.setValue(asset.eventID, forKey: Self.assetEventIDKey)
managedAsset.setValue(asset.source.rawValue, forKey: Self.assetSourceKey)
managedAsset.setValue(asset.displayName, forKey: Self.assetDisplayNameKey)
@@ -148,11 +148,11 @@ final class CoreDataUserQueryTaskStore: UserQueryTaskStoring {
try? context.save()
}
- func loadEvents(taskID: String) -> [UserQueryTaskEvent] {
+ func loadEvents(conversationID: String) -> [UserQueryConversationEvent] {
guard let context else { return [] }
let request = NSFetchRequest<NSManagedObject>(entityName: Self.eventEntityName)
- request.predicate = NSPredicate(format: "%K == %@", Self.eventTaskIDKey, taskID)
+ request.predicate = NSPredicate(format: "%K == %@", Self.eventTaskIDKey, conversationID)
request.sortDescriptors = [
NSSortDescriptor(key: Self.eventSequenceKey, ascending: true),
NSSortDescriptor(key: Self.eventCreatedAtKey, ascending: true)
@@ -165,7 +165,7 @@ final class CoreDataUserQueryTaskStore: UserQueryTaskStoring {
return managedEvents.compactMap(Self.event(from:))
}
- func appendEvent(_ event: UserQueryTaskEvent) {
+ func appendEvent(_ event: UserQueryConversationEvent) {
guard let context else { return }
let managedEvent = NSManagedObject(
@@ -173,7 +173,7 @@ final class CoreDataUserQueryTaskStore: UserQueryTaskStoring {
insertInto: context
)
managedEvent.setValue(event.id, forKey: Self.eventIDKey)
- managedEvent.setValue(event.taskID, forKey: Self.eventTaskIDKey)
+ managedEvent.setValue(event.conversationID, forKey: Self.eventTaskIDKey)
managedEvent.setValue(event.role.rawValue, forKey: Self.eventRoleKey)
managedEvent.setValue(event.text, forKey: Self.eventTextKey)
managedEvent.setValue(Int64(event.sequence), forKey: Self.eventSequenceKey)
@@ -211,7 +211,7 @@ final class CoreDataUserQueryTaskStore: UserQueryTaskStoring {
private static func defaultStoreURL() -> URL {
FileManager.default.urls(for: .applicationSupportDirectory, in: .userDomainMask)[0]
.appendingPathComponent("Donkey", isDirectory: true)
- .appendingPathComponent("UserQueryTasks.sqlite")
+ .appendingPathComponent("UserQueryConversations.sqlite")
}
private static func model() -> NSManagedObjectModel {
@@ -291,12 +291,12 @@ final class CoreDataUserQueryTaskStore: UserQueryTaskStoring {
private static func deleteRows(
entityName: String,
- taskIDKey: String,
- taskID: String,
+ conversationIDKey: String,
+ conversationID: String,
in context: NSManagedObjectContext
) {
let request = NSFetchRequest<NSManagedObject>(entityName: entityName)
- request.predicate = NSPredicate(format: "%K == %@", taskIDKey, taskID)
+ request.predicate = NSPredicate(format: "%K == %@", conversationIDKey, conversationID)
guard let rows = try? context.fetch(request) else { return }
for row in rows {
context.delete(row)
@@ -310,7 +310,7 @@ final class CoreDataUserQueryTaskStore: UserQueryTaskStoring {
return try? context.fetch(request).first
}
- private func taskIDsWithMatchingEvents(_ query: String) -> [String] {
+ private func conversationIDsWithMatchingEvents(_ query: String) -> [String] {
guard let context else { return [] }
let request = NSFetchRequest<NSManagedObject>(entityName: Self.eventEntityName)
@@ -323,7 +323,7 @@ final class CoreDataUserQueryTaskStore: UserQueryTaskStoring {
return Array(Set(managedEvents.compactMap { $0.value(forKey: Self.eventTaskIDKey) as? String }))
}
- private func taskIDsWithMatchingAssets(_ query: String) -> [String] {
+ private func conversationIDsWithMatchingAssets(_ query: String) -> [String] {
guard let context else { return [] }
let request = NSFetchRequest<NSManagedObject>(entityName: Self.assetEntityName)
@@ -340,19 +340,19 @@ final class CoreDataUserQueryTaskStore: UserQueryTaskStoring {
return Array(Set(managedAssets.compactMap { $0.value(forKey: Self.assetTaskIDKey) as? String }))
}
- private static func task(from managedTask: NSManagedObject) -> UserQueryNotchTask? {
+ private static func task(from managedTask: NSManagedObject) -> UserQueryConversation? {
guard let id = managedTask.value(forKey: idKey) as? String,
let title = managedTask.value(forKey: titleKey) as? String,
let detail = managedTask.value(forKey: detailKey) as? String,
let rawStatus = managedTask.value(forKey: statusKey) as? String,
- let status = UserQueryTaskStatus(rawValue: rawStatus),
+ let status = UserQueryConversationStatus(rawValue: rawStatus),
let createdAt = managedTask.value(forKey: createdAtKey) as? Date,
let updatedAt = managedTask.value(forKey: updatedAtKey) as? Date else {
return nil
}
let accentIndex = (managedTask.value(forKey: accentIndexKey) as? NSNumber)?.intValue ?? 0
- return UserQueryNotchTask(
+ return UserQueryConversation(
id: id,
title: title,
detail: detail,
@@ -384,20 +384,20 @@ final class CoreDataUserQueryTaskStore: UserQueryTaskStoring {
return metadata
}
- private static func event(from managedEvent: NSManagedObject) -> UserQueryTaskEvent? {
+ private static func event(from managedEvent: NSManagedObject) -> UserQueryConversationEvent? {
guard let id = managedEvent.value(forKey: eventIDKey) as? String,
- let taskID = managedEvent.value(forKey: eventTaskIDKey) as? String,
+ let conversationID = managedEvent.value(forKey: eventTaskIDKey) as? String,
let rawRole = managedEvent.value(forKey: eventRoleKey) as? String,
- let role = UserQueryTaskEventRole(rawValue: rawRole),
+ let role = UserQueryConversationEventRole(rawValue: rawRole),
let text = managedEvent.value(forKey: eventTextKey) as? String,
let createdAt = managedEvent.value(forKey: eventCreatedAtKey) as? Date else {
return nil
}
let sequence = (managedEvent.value(forKey: eventSequenceKey) as? NSNumber)?.intValue ?? 0
- return UserQueryTaskEvent(
+ return UserQueryConversationEvent(
id: id,
- taskID: taskID,
+ conversationID: conversationID,
role: role,
text: text,
sequence: sequence,
@@ -405,11 +405,11 @@ final class CoreDataUserQueryTaskStore: UserQueryTaskStoring {
)
}
- private static func asset(from managedAsset: NSManagedObject) -> UserQueryTaskAsset? {
+ private static func asset(from managedAsset: NSManagedObject) -> UserQueryConversationAsset? {
guard let id = managedAsset.value(forKey: assetIDKey) as? String,
- let taskID = managedAsset.value(forKey: assetTaskIDKey) as? String,
+ let conversationID = managedAsset.value(forKey: assetTaskIDKey) as? String,
let rawSource = managedAsset.value(forKey: assetSourceKey) as? String,
- let source = UserQueryTaskAssetSource(rawValue: rawSource),
+ let source = UserQueryConversationAssetSource(rawValue: rawSource),
let displayName = managedAsset.value(forKey: assetDisplayNameKey) as? String,
let contentType = managedAsset.value(forKey: assetContentTypeKey) as? String,
let urlString = managedAsset.value(forKey: assetURLStringKey) as? String,
@@ -417,9 +417,9 @@ final class CoreDataUserQueryTaskStore: UserQueryTaskStoring {
return nil
}
- return UserQueryTaskAsset(
+ return UserQueryConversationAsset(
id: id,
- taskID: taskID,
+ conversationID: conversationID,
eventID: managedAsset.value(forKey: assetEventIDKey) as? String,
source: source,
displayName: displayName,
@@ -430,9 +430,9 @@ final class CoreDataUserQueryTaskStore: UserQueryTaskStoring {
)
}
- private static let taskEntityName = "UserQueryStoredTask"
- private static let eventEntityName = "UserQueryStoredTaskEvent"
- private static let assetEntityName = "UserQueryStoredTaskAsset"
+ private static let taskEntityName = "UserQueryStoredConversation"
+ private static let eventEntityName = "UserQueryStoredConversationEvent"
+ private static let assetEntityName = "UserQueryStoredConversationAsset"
private static let idKey = "id"
private static let titleKey = "title"
private static let detailKey = "detail"
@@ -443,13 +443,13 @@ final class CoreDataUserQueryTaskStore: UserQueryTaskStoring {
private static let updatedAtKey = "updatedAt"
private static let metadataJSONKey = "metadataJSON"
private static let eventIDKey = "id"
- private static let eventTaskIDKey = "taskID"
+ private static let eventTaskIDKey = "conversationID"
private static let eventRoleKey = "role"
private static let eventTextKey = "text"
private static let eventSequenceKey = "sequence"
private static let eventCreatedAtKey = "createdAt"
private static let assetIDKey = "id"
- private static let assetTaskIDKey = "taskID"
+ private static let assetTaskIDKey = "conversationID"
private static let assetEventIDKey = "eventID"
private static let assetSourceKey = "source"
private static let assetDisplayNameKey = "displayName"
diff --git a/apps/Donkey/Sources/Donkey/UserQueryOverlayController.swift b/apps/Donkey/Sources/Donkey/UserQueryOverlayController.swift
index acfd2c61..fc93161a 100644
--- a/apps/Donkey/Sources/Donkey/UserQueryOverlayController.swift
+++ b/apps/Donkey/Sources/Donkey/UserQueryOverlayController.swift
@@ -60,8 +60,8 @@ final class UserQueryOverlayController {
preferredSpawnID: preferredSpawnID
)
}
- spawnOverlayController.followUpSubmitted = { [weak self] spawnID, taskID, text in
- self?.model.submitSpawnFollowUp(spawnID: spawnID, taskID: taskID, text: text)
+ spawnOverlayController.followUpSubmitted = { [weak self] spawnID, conversationID, text in
+ self?.model.submitSpawnFollowUp(spawnID: spawnID, conversationID: conversationID, text: text)
}
spawnOverlayController.selected = { [weak self] spawnID in
self?.model.selectSpawn(id: spawnID)
@@ -685,32 +685,32 @@ final class UserQueryOverlayController {
assetsDropped: { [weak self] drafts in
self?.model.handleDroppedAssets(drafts)
},
- pauseRequested: { [weak self] taskID in
- self?.model.pauseTask(id: taskID)
+ pauseRequested: { [weak self] conversationID in
+ self?.model.pauseAgent(id: conversationID)
},
- resumeRequested: { [weak self] taskID in
- self?.model.resumeTask(id: taskID)
+ resumeRequested: { [weak self] conversationID in
+ self?.model.resumeAgent(id: conversationID)
},
- dismissRequested: { [weak self] taskID in
- self?.model.dismissTask(id: taskID)
+ dismissRequested: { [weak self] conversationID in
+ self?.model.dismissTask(id: conversationID)
},
- taskSelected: { [weak self] taskID in
- self?.restoreSpawnPointer(forTaskID: taskID)
+ taskSelected: { [weak self] conversationID in
+ self?.restoreSpawnPointer(forTaskID: conversationID)
},
- replyRequested: { [weak self] taskID in
+ replyRequested: { [weak self] conversationID in
guard let self else { return }
// A click focuses the row exactly as arrowing onto it does: highlight + pinned reply.
- self.model.focusNotchRow(taskID)
+ self.model.focusNotchRow(conversationID)
self.focusStatusComposerTextInputIfAvailable()
},
replyModeExited: { [weak self] in
self?.model.focusNotchRow(nil)
},
- approvePermissionRequested: { [weak self] taskID, alwaysAllow in
- self?.model.approvePermissionGate(id: taskID, alwaysAllow: alwaysAllow)
+ approvePermissionRequested: { [weak self] conversationID, alwaysAllow in
+ self?.model.approvePermissionGate(id: conversationID, alwaysAllow: alwaysAllow)
},
- denyPermissionRequested: { [weak self] taskID in
- self?.model.denyPermissionGate(id: taskID)
+ denyPermissionRequested: { [weak self] conversationID in
+ self?.model.denyPermissionGate(id: conversationID)
},
updateRequested: { [weak self] in
self?.openAvailableUpdate()
@@ -719,8 +719,8 @@ final class UserQueryOverlayController {
loginRequested: { [weak self] in
self?.model.requestLogin()
},
- reloadCreditsRequested: { [weak self] taskID in
- self?.model.reloadCredits(id: taskID)
+ reloadCreditsRequested: { [weak self] conversationID in
+ self?.model.reloadCredits(id: conversationID)
}
)
}
@@ -749,8 +749,8 @@ final class UserQueryOverlayController {
/// Brings back a pointer the user dismissed when its task is clicked in
/// the notch; the surface re-emerges and travels to its target again.
- private func restoreSpawnPointer(forTaskID taskID: String) {
- guard let spawnID = model.spawnStates.first(where: { $0.taskID == taskID })?.id else {
+ private func restoreSpawnPointer(forTaskID conversationID: String) {
+ guard let spawnID = model.spawnStates.first(where: { $0.conversationID == conversationID })?.id else {
return
}
@@ -1537,8 +1537,8 @@ private struct StatusPanelViewSnapshot: Equatable {
var notchCommandText: String
var notchCommandInputTextHeight: CGFloat
var isNotchCommandInputExpanded: Bool
- var notchTasks: [UserQueryNotchTask]
- var notchSurfacedTasks: [UserQueryNotchTask]
+ var notchTasks: [UserQueryConversation]
+ var notchSurfacedTasks: [UserQueryConversation]
var accentIndex: Int
var spawnState: UserQuerySpawnState?
var spawnStates: [UserQuerySpawnState]
diff --git a/apps/Donkey/Sources/Donkey/UserQueryOverlayModel.swift b/apps/Donkey/Sources/Donkey/UserQueryOverlayModel.swift
index bab43d62..41e1300e 100644
--- a/apps/Donkey/Sources/Donkey/UserQueryOverlayModel.swift
+++ b/apps/Donkey/Sources/Donkey/UserQueryOverlayModel.swift
@@ -30,7 +30,7 @@ final class UserQueryOverlayModel: ObservableObject, UserQueryIntentSink {
@Published private(set) var notchAccentIndex = 0
@Published private(set) var isCurrentTaskPaused = false
@Published private(set) var updateState: UserQueryUpdateState
- @Published private(set) var notchTasks: [UserQueryNotchTask]
+ @Published private(set) var notchTasks: [UserQueryConversation]
@Published private(set) var spawnStates: [UserQuerySpawnState] = []
@Published private(set) var selectedSpawnID: String?
/// Logged out: the notch renders a login call-to-action instead of the task surface. The app
@@ -49,13 +49,13 @@ final class UserQueryOverlayModel: ObservableObject, UserQueryIntentSink {
var onLiveAudioStreamingChanged: ((Bool) -> Void)?
private var commandHandler: any UserQueryCommandHandling
- private let taskStore: any UserQueryTaskStoring
+ private let taskStore: any UserQueryConversationStoring
private let followUpResolver: any UserQueryFollowUpResolving
private let voiceTranscriber: LocalVoiceTranscriptionAdapter
private let liveController: GeminiLiveVoiceController
private var updateChecker: any DonkeyUpdateChecking
private let appCatalogRefreshLoop: LocalAppDynamicCatalogRefreshLoop
- private var activeTaskIDs: Set<String> = []
+ private var activeAgentIDs: Set<String> = []
/// Resume requests made while a task's previous loop was still winding down (e.g. a quick Stop→Resume).
/// The resume is deferred here and fired by `handleCommandRunResult` once that loop ends, so two loops
/// never run on one task and the tap is never silently dropped.
@@ -82,13 +82,13 @@ final class UserQueryOverlayModel: ObservableObject, UserQueryIntentSink {
/// seed (`taskForSubmittedCommand`), which bypasses `updateTask`.
private static func clearRunMetadata(_ metadata: inout [String: String]) {
metadata[seenMetadataKey] = nil
- metadata[UserQueryNotchTask.streamingAnswerMetadataKey] = nil
+ metadata[UserQueryConversation.streamingAnswerMetadataKey] = nil
}
private var lastActiveTaskID: String?
/// The task/spawn the in-flight Gemini Live turn reports into, so the user
/// sees the same cursor-and-task feedback as a local pipeline run.
- private var liveTurn: (taskID: String, spawnID: String?)?
+ private var liveTurn: (conversationID: String, spawnID: String?)?
private var liveTurnWatchdog: Task<Void, Never>?
private static let notchTaskDisplayLimit = 12
private static let followUpCandidateLimit = 8
@@ -100,7 +100,7 @@ final class UserQueryOverlayModel: ObservableObject, UserQueryIntentSink {
init(
aiProvider: any AIHarnessSnapshotProviding = AIHarnessBoundary(),
commandHandler: any UserQueryCommandHandling = LocalAppUserQueryCommandHandler(),
- taskStore: any UserQueryTaskStoring = CoreDataUserQueryTaskStore(),
+ taskStore: any UserQueryConversationStoring = CoreDataUserQueryConversationStore(),
followUpResolver: any UserQueryFollowUpResolving = HostedTaskFollowUpResolver(),
voiceTranscriber: LocalVoiceTranscriptionAdapter = LocalVoiceTranscriptionAdapter(),
updateChecker: any DonkeyUpdateChecking = SparkleUpdateController(),
@@ -155,29 +155,29 @@ final class UserQueryOverlayModel: ObservableObject, UserQueryIntentSink {
/// Resume tasks that were actively running when the app last quit (see `restoredTasks`). Each runs as
/// an unattended BACKGROUND turn — the user may not be present — so it never raises an app or moves
/// the cursor; progress narrates into the task's own row. Fires once, at launch.
- private func autoResumeInterruptedTasks(_ taskIDs: [String]) {
- guard !taskIDs.isEmpty else { return }
+ private func autoResumeInterruptedTasks(_ conversationIDs: [String]) {
+ guard !conversationIDs.isEmpty else { return }
// Don't drive the harness while signed out — every planner step would 401. The interrupted
// tasks stay retryable and resume on the next launch (or manual retry) once signed in.
guard BackendSessionGate.shared.isAuthenticated else { return }
- for taskID in taskIDs {
- guard let context = commandContext(taskID: taskID, isFollowUp: false, source: .followUp, spawnID: nil) else {
+ for conversationID in conversationIDs {
+ guard let context = commandContext(conversationID: conversationID, isFollowUp: false, source: .followUp, spawnID: nil) else {
continue
}
- activeTaskIDs.insert(taskID)
+ activeAgentIDs.insert(conversationID)
Task { [weak self, commandHandler] in
- let result = await commandHandler.autoResumeCommand(taskID: taskID, context: context)
+ let result = await commandHandler.autoResumeCommand(conversationID: conversationID, context: context)
await MainActor.run {
guard let self else { return }
// No goal to resume, or the unattended run couldn't even start (no frontmost app,
// backend off): keep the task retryable rather than failing it, so the user can resume
// it later. Only a run that actually executed reports its real outcome.
if result == nil || result?.metadata["harness.abortReason"] != nil {
- self.activeTaskIDs.remove(taskID)
- self.updateTask(id: taskID, detail: "Interrupted — resume", status: .timedOut)
+ self.activeAgentIDs.remove(conversationID)
+ self.updateTask(id: conversationID, detail: "Interrupted — resume", status: .timedOut)
return
}
- self.handleCommandRunResult(taskID: taskID, spawnID: nil, isFollowUp: false, result: result!)
+ self.handleCommandRunResult(conversationID: conversationID, spawnID: nil, isFollowUp: false, result: result!)
}
}
}
@@ -205,8 +205,8 @@ final class UserQueryOverlayModel: ObservableObject, UserQueryIntentSink {
self.promptState.promptText = summary
guard let liveTurn = self.liveTurn else { return }
self.updateSpawn(id: liveTurn.spawnID, label: Self.collapsedDisplayText(for: summary), phase: .holding)
- self.updateTask(id: liveTurn.taskID, detail: summary, status: .running)
- self.appendTaskEvent(taskID: liveTurn.taskID, role: .system, text: summary)
+ self.updateTask(id: liveTurn.conversationID, detail: summary, status: .running)
+ self.appendAgentEvent(conversationID: liveTurn.conversationID, role: .system, text: summary)
self.restartLiveTurnWatchdog()
}
liveController.onResponse = { [weak self] answer in
@@ -214,7 +214,7 @@ final class UserQueryOverlayModel: ObservableObject, UserQueryIntentSink {
self.promptState.leadingSignalLevel = .ready
self.promptState.promptText = answer
guard let liveTurn = self.liveTurn else { return }
- self.appendTaskEvent(taskID: liveTurn.taskID, role: .assistant, text: answer)
+ self.appendAgentEvent(conversationID: liveTurn.conversationID, role: .assistant, text: answer)
self.finishLiveTurn(detail: answer, status: .completed)
}
liveController.onConsentNeeded = { [weak self] request in
@@ -288,7 +288,7 @@ final class UserQueryOverlayModel: ObservableObject, UserQueryIntentSink {
/// The notch "Reload credits" CTA was tapped on a credit-exhausted task. Open the billing page in
/// the browser (donkeyuse.com in prod, localhost in dev — the configured web base URL) so the user
/// can top up; the task stays on the row so it can be re-run once credits land.
- func reloadCredits(id taskID: String) {
+ func reloadCredits(id conversationID: String) {
let billingURL = DonkeyAuthConfiguration.current().webBaseURL
.appendingPathComponent("app/settings")
NSWorkspace.shared.open(billingURL)
@@ -398,10 +398,10 @@ final class UserQueryOverlayModel: ObservableObject, UserQueryIntentSink {
matchedTaskID: nil,
reservedAccentIndex: spawnID.flatMap { spawn(withID: $0)?.accentIndex }
)
- updateSpawn(id: spawnID, taskID: task.id, accentIndex: task.accentIndex)
- activeTaskIDs.insert(task.id)
+ updateSpawn(id: spawnID, conversationID: task.id, accentIndex: task.accentIndex)
+ activeAgentIDs.insert(task.id)
lastActiveTaskID = task.id
- appendTaskEvent(taskID: task.id, role: .user, text: text)
+ appendAgentEvent(conversationID: task.id, role: .user, text: text)
clearSubmissionInputs()
promptState.isActive = false
promptState.isVoiceInputActive = false
@@ -413,13 +413,13 @@ final class UserQueryOverlayModel: ObservableObject, UserQueryIntentSink {
}
/// Close out the in-flight Live turn's task and spawn.
- private func finishLiveTurn(detail: String?, status: UserQueryTaskStatus) {
+ private func finishLiveTurn(detail: String?, status: UserQueryConversationStatus) {
liveTurnWatchdog?.cancel()
liveTurnWatchdog = nil
guard let turn = liveTurn else { return }
liveTurn = nil
- updateTask(id: turn.taskID, detail: detail, status: status)
- activeTaskIDs.remove(turn.taskID)
+ updateTask(id: turn.conversationID, detail: detail, status: status)
+ activeAgentIDs.remove(turn.conversationID)
syncPrimaryTaskPausedFlag()
guard let spawnID = turn.spawnID, let index = spawnIndex(id: spawnID) else { return }
var spawnState = spawnStates[index]
@@ -463,7 +463,7 @@ final class UserQueryOverlayModel: ObservableObject, UserQueryIntentSink {
liveTurnWatchdog?.cancel()
updateSpawn(id: turn.spawnID, label: "Waiting for approval", phase: .holding)
updateTask(
- id: turn.taskID,
+ id: turn.conversationID,
detail: request.summary,
status: .waitingForPermission,
metadata: [
@@ -473,7 +473,7 @@ final class UserQueryOverlayModel: ObservableObject, UserQueryIntentSink {
"live.shellConsent": "true"
]
)
- appendTaskEvent(taskID: turn.taskID, role: .system, text: request.summary)
+ appendAgentEvent(conversationID: turn.conversationID, role: .system, text: request.summary)
promptState.leadingSignalLevel = .ready
promptState.promptText = request.summary
syncPrimaryTaskPausedFlag()
@@ -508,8 +508,8 @@ final class UserQueryOverlayModel: ObservableObject, UserQueryIntentSink {
if let replyTargetTaskID {
// An explicit Reply pins the answer to that task — never re-routed by the resolver.
matchedTaskID = replyTargetTaskID
- } else if let taskID = promptFollowUpTarget?.taskID {
- matchedTaskID = taskID
+ } else if let conversationID = promptFollowUpTarget?.conversationID {
+ matchedTaskID = conversationID
} else if candidates.isEmpty {
matchedTaskID = nil
} else {
@@ -520,9 +520,9 @@ final class UserQueryOverlayModel: ObservableObject, UserQueryIntentSink {
sourceTraceID: sourceTraceID
)
)
- if let taskID = resolution.taskID,
+ if let conversationID = resolution.conversationID,
resolution.confidence >= confidenceThreshold {
- matchedTaskID = taskID
+ matchedTaskID = conversationID
} else {
matchedTaskID = nil
}
@@ -539,20 +539,20 @@ final class UserQueryOverlayModel: ObservableObject, UserQueryIntentSink {
}
}
- func handleDroppedAssets(_ drafts: [UserQueryTaskAssetDraft]) {
+ func handleDroppedAssets(_ drafts: [UserQueryConversationAssetDraft]) {
guard !drafts.isEmpty else { return }
let targetTask = taskForDroppedAssets()
let assetNames = drafts.map(\.displayName)
let eventText = Self.assetUploadEventText(assetNames)
- let eventID = appendTaskEvent(taskID: targetTask.id, role: .user, text: eventText)
+ let eventID = appendAgentEvent(conversationID: targetTask.id, role: .user, text: eventText)
for draft in drafts {
let assetID = UUID().uuidString
taskStore.appendAsset(
Self.persistedAsset(
from: draft,
assetID: assetID,
- taskID: targetTask.id,
+ conversationID: targetTask.id,
eventID: eventID
)
)
@@ -587,10 +587,10 @@ final class UserQueryOverlayModel: ObservableObject, UserQueryIntentSink {
selectedSpawnID = spawnID
}
- func submitSpawnFollowUp(spawnID: String, taskID: String, text: String) {
+ func submitSpawnFollowUp(spawnID: String, conversationID: String, text: String) {
let trimmedText = text.trimmingCharacters(in: .whitespacesAndNewlines)
guard !trimmedText.isEmpty,
- taskIDForInteractableSpawn(id: spawnID) == taskID else {
+ conversationIDForInteractableSpawn(id: spawnID) == conversationID else {
return
}
@@ -604,7 +604,7 @@ final class UserQueryOverlayModel: ObservableObject, UserQueryIntentSink {
)
startCommandRun(
text: trimmedText,
- matchedTaskID: taskID,
+ matchedTaskID: conversationID,
source: .followUp,
spawnID: spawnID
)
@@ -623,7 +623,7 @@ final class UserQueryOverlayModel: ObservableObject, UserQueryIntentSink {
// the fresh/resume path below, which runs concurrently with any other in-flight task.
let matchedStatus = matchedTaskID.flatMap { task(withID: $0)?.status }
if let matchedTaskID, matchedStatus == .running || matchedStatus == .waitingForPermission {
- queueFollowUpIntoRunningTask(text: text, taskID: matchedTaskID, source: source, spawnID: spawnID)
+ queueFollowUpIntoRunningTask(text: text, conversationID: matchedTaskID, source: source, spawnID: spawnID)
return
}
runFreshOrResumedCommand(text: text, matchedTaskID: matchedTaskID, source: source, spawnID: spawnID)
@@ -633,28 +633,28 @@ final class UserQueryOverlayModel: ObservableObject, UserQueryIntentSink {
/// step; if the loop happens to finish first, fall back to resuming the task with the instruction.
private func queueFollowUpIntoRunningTask(
text: String,
- taskID: String,
+ conversationID: String,
source: AppHarnessTurnSource,
spawnID: String?
) {
- appendTaskEvent(taskID: taskID, role: .user, text: text)
- updateSpawn(id: spawnID, taskID: taskID)
+ appendAgentEvent(conversationID: conversationID, role: .user, text: text)
+ updateSpawn(id: spawnID, conversationID: conversationID)
clearSubmissionInputs()
- lastActiveTaskID = taskID
+ lastActiveTaskID = conversationID
promptState.isActive = false
promptState.isVoiceInputActive = false
promptState.leadingSignalLevel = .thinking
- promptState.promptText = task(withID: taskID)?.title ?? Self.collapsedDisplayText(for: text)
+ promptState.promptText = task(withID: conversationID)?.title ?? Self.collapsedDisplayText(for: text)
syncPrimaryTaskPausedFlag()
Task { [weak self, commandHandler] in
- let injected = await commandHandler.injectFollowUp(taskID: taskID, text: text)
+ let injected = await commandHandler.injectFollowUp(conversationID: conversationID, text: text)
guard !injected else { return }
// Race: the loop finished between the live check and the enqueue. Resume the task with the
// instruction instead. The user event is already recorded, so it is not appended again.
await MainActor.run {
self?.runFreshOrResumedCommand(
text: text,
- matchedTaskID: taskID,
+ matchedTaskID: conversationID,
source: source,
spawnID: spawnID,
appendUserEvent: false
@@ -679,13 +679,13 @@ final class UserQueryOverlayModel: ObservableObject, UserQueryIntentSink {
)
updateSpawn(
id: spawnID,
- taskID: task.id,
+ conversationID: task.id,
accentIndex: task.accentIndex
)
- activeTaskIDs.insert(task.id)
+ activeAgentIDs.insert(task.id)
lastActiveTaskID = task.id
if appendUserEvent {
- appendTaskEvent(taskID: task.id, role: .user, text: text)
+ appendAgentEvent(conversationID: task.id, role: .user, text: text)
}
clearSubmissionInputs()
promptState.isActive = false
@@ -693,7 +693,7 @@ final class UserQueryOverlayModel: ObservableObject, UserQueryIntentSink {
promptState.promptText = task.title
syncPrimaryTaskPausedFlag()
let context = commandContext(
- taskID: task.id,
+ conversationID: task.id,
isFollowUp: isFollowUp,
source: source,
spawnID: spawnID
@@ -702,7 +702,7 @@ final class UserQueryOverlayModel: ObservableObject, UserQueryIntentSink {
let result = await commandHandler.handleSubmittedCommand(text, context: context)
await MainActor.run {
self?.handleCommandRunResult(
- taskID: task.id,
+ conversationID: task.id,
spawnID: spawnID,
isFollowUp: isFollowUp,
result: result
@@ -714,21 +714,21 @@ final class UserQueryOverlayModel: ObservableObject, UserQueryIntentSink {
/// Apply a finished pipeline run to the task rail, prompt pill, cursor
/// replay, and spawn — shared by fresh submissions and post-approval resumes.
private func handleCommandRunResult(
- taskID: String,
+ conversationID: String,
spawnID: String?,
isFollowUp: Bool,
result: UserQueryCommandHandlingResult
) {
updateTask(
- id: taskID,
+ id: conversationID,
title: isFollowUp ? nil : result.taskLabel,
detail: result.summary,
status: Self.taskStatus(for: result),
metadata: result.metadata
)
- appendTaskEvent(taskID: taskID, role: .assistant, text: result.summary)
- activeTaskIDs.remove(taskID)
- refreshPromptStateAfterRunResult(taskID: taskID, result: result)
+ appendAgentEvent(conversationID: conversationID, role: .assistant, text: result.summary)
+ activeAgentIDs.remove(conversationID)
+ refreshPromptStateAfterRunResult(conversationID: conversationID, result: result)
let cursorOverlayRequest = result.cursorOverlayRequest
if let cursorOverlayRequest {
agentVisualizationPresenter?(cursorOverlayRequest, spawnID)
@@ -739,9 +739,9 @@ final class UserQueryOverlayModel: ObservableObject, UserQueryIntentSink {
minimumFadeDelay: cursorOverlayRequest.map(Self.visualizationPlaybackDuration)
)
// Honor a resume requested while this loop was still winding down (e.g. Stop→Resume): now that the
- // loop has ended and the task left activeTaskIDs, the resume can start without racing a live loop.
- if pendingResumeTaskIDs.remove(taskID) != nil {
- resumeTask(id: taskID)
+ // loop has ended and the task left activeAgentIDs, the resume can start without racing a live loop.
+ if pendingResumeTaskIDs.remove(conversationID) != nil {
+ resumeAgent(id: conversationID)
}
}
@@ -771,18 +771,18 @@ final class UserQueryOverlayModel: ObservableObject, UserQueryIntentSink {
return true
}
- /// Make `taskID` the focused thread — the shared effect of clicking a row and of arrowing onto it: it
+ /// Make `conversationID` the focused thread — the shared effect of clicking a row and of arrowing onto it: it
/// becomes the keyboard highlight and the reply target (its pointer lights, the composer takes its
/// accent, and the other rows dim). Passing nil (Escape, or leaving reply) clears both, the same as
/// clicking bare chrome.
- func focusNotchRow(_ taskID: String?) {
- selectedTaskID = taskID
- guard let taskID, task(withID: taskID) != nil else {
+ func focusNotchRow(_ conversationID: String?) {
+ selectedTaskID = conversationID
+ guard let conversationID, task(withID: conversationID) != nil else {
replyTargetTaskID = nil
return
}
- replyTargetTaskID = taskID
- lastActiveTaskID = taskID
+ replyTargetTaskID = conversationID
+ lastActiveTaskID = conversationID
}
func clearNotchSelection() {
@@ -793,28 +793,28 @@ final class UserQueryOverlayModel: ObservableObject, UserQueryIntentSink {
/// applies to the one answer (which also un-dims the rows), and dropped if the task is no longer
/// around (fall back to normal routing).
private func consumePendingReplyTarget() -> String? {
- guard let taskID = replyTargetTaskID else { return nil }
+ guard let conversationID = replyTargetTaskID else { return nil }
replyTargetTaskID = nil
// Drop the pin only if the task vanished between the tap and the submit (e.g. it was closed);
// otherwise the message is pinned to it whatever its current state (`startCommandRun` routes a
// running/permission-gated target into a queued follow-up, a stopped/terminal one resumes).
- return task(withID: taskID) != nil ? taskID : nil
+ return task(withID: conversationID) != nil ? conversationID : nil
}
- func pauseTask(id taskID: String) {
- guard task(withID: taskID)?.status == .running else { return }
+ func pauseAgent(id conversationID: String) {
+ guard task(withID: conversationID)?.status == .running else { return }
- activeTaskIDs.insert(taskID)
- lastActiveTaskID = taskID
- announceLifecycle(taskID: taskID, UserQueryActivity(kind: .paused), status: .paused)
+ activeAgentIDs.insert(conversationID)
+ lastActiveTaskID = conversationID
+ announceLifecycle(conversationID: conversationID, UserQueryActivity(kind: .paused), status: .paused)
syncPrimaryTaskPausedFlag()
Task { [commandHandler] in
- _ = await commandHandler.pauseCommand(taskID: taskID)
+ _ = await commandHandler.pauseCommand(conversationID: conversationID)
}
}
- func resumeTask(id taskID: String) {
- guard let task = task(withID: taskID),
+ func resumeAgent(id conversationID: String) {
+ guard let task = task(withID: conversationID),
[.paused, .interrupted, .timedOut, .needsAttention].contains(task.status) else {
return
}
@@ -823,35 +823,35 @@ final class UserQueryOverlayModel: ObservableObject, UserQueryIntentSink {
guard !task.commandText.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty else { return }
// If the task's previous loop is still winding down (e.g. just Stopped), defer the resume until it
// ends so two loops never run on one task; handleCommandRunResult fires the deferred resume.
- guard !activeTaskIDs.contains(taskID) else {
- pendingResumeTaskIDs.insert(taskID)
+ guard !activeAgentIDs.contains(conversationID) else {
+ pendingResumeTaskIDs.insert(conversationID)
return
}
- activeTaskIDs.insert(taskID)
- lastActiveTaskID = taskID
+ activeAgentIDs.insert(conversationID)
+ lastActiveTaskID = conversationID
// The live line falls back to the running activity ("Thinking"); the record logs "Resuming".
- announceLifecycle(taskID: taskID, UserQueryActivity(kind: .resumed), status: .running, liveDetail: "")
- updateSpawn(id: spawnStates.first { $0.taskID == taskID }?.id, resumesWork: true)
+ announceLifecycle(conversationID: conversationID, UserQueryActivity(kind: .resumed), status: .running, liveDetail: "")
+ updateSpawn(id: spawnStates.first { $0.conversationID == conversationID }?.id, resumesWork: true)
promptState.leadingSignalLevel = .thinking
promptState.promptText = task.title
syncPrimaryTaskPausedFlag()
// Pausing or a relaunch tears the loop down, so there is no suspended loop to continue in memory:
// re-run the task's existing goal as a fresh loop. The persisted world model and history carry the
// context forward, so it continues the work rather than starting over.
- let context = commandContext(taskID: taskID, isFollowUp: false, source: .followUp, spawnID: nil)
+ let context = commandContext(conversationID: conversationID, isFollowUp: false, source: .followUp, spawnID: nil)
Task { [weak self, commandHandler] in
- guard let result = await commandHandler.continueApprovedCommand(taskID: taskID, context: context) else {
+ guard let result = await commandHandler.continueApprovedCommand(conversationID: conversationID, context: context) else {
// Nothing to resume (e.g. the harness snapshot is gone): restore a retryable row rather
// than leaving it stuck on the optimistic "running" with no loop behind it.
await MainActor.run {
- self?.activeTaskIDs.remove(taskID)
- self?.updateTask(id: taskID, detail: "Couldn’t resume — tap to retry", status: .timedOut)
+ self?.activeAgentIDs.remove(conversationID)
+ self?.updateTask(id: conversationID, detail: "Couldn’t resume — tap to retry", status: .timedOut)
}
return
}
await MainActor.run {
- self?.handleCommandRunResult(taskID: taskID, spawnID: nil, isFollowUp: false, result: result)
+ self?.handleCommandRunResult(conversationID: conversationID, spawnID: nil, isFollowUp: false, result: result)
}
}
}
@@ -859,7 +859,7 @@ final class UserQueryOverlayModel: ObservableObject, UserQueryIntentSink {
/// The tasks the collapsed notch keeps surfaced as floating pointers: anything running, plus
/// terminal tasks (completed or failed) the user hasn't dismissed yet by expanding the notch. A
/// failure — like an auth error — holds the chin until acknowledged just as a completion does.
- var notchSurfacedTasks: [UserQueryNotchTask] {
+ var notchSurfacedTasks: [UserQueryConversation] {
notchTasks.filter { task in
task.status == .running ||
(Self.isSurfacedTerminalStatus(task.status) && !Self.isSeen(task))
@@ -878,44 +878,44 @@ final class UserQueryOverlayModel: ObservableObject, UserQueryIntentSink {
}
}
- private static func isSurfacedTerminalStatus(_ status: UserQueryTaskStatus) -> Bool {
+ private static func isSurfacedTerminalStatus(_ status: UserQueryConversationStatus) -> Bool {
status == .completed || status == .failed
}
- private static func isSeen(_ task: UserQueryNotchTask) -> Bool {
+ private static func isSeen(_ task: UserQueryConversation) -> Bool {
task.metadata[seenMetadataKey] == "true"
}
/// Closes a task: removes it from the notch list and tears down its pointer.
/// Offered only for stopped (paused/interrupted/failed) and completed tasks —
/// the same affordance the prototype calls "close".
- func dismissTask(id taskID: String) {
- guard let task = task(withID: taskID) else { return }
+ func dismissTask(id conversationID: String) {
+ guard let task = task(withID: conversationID) else { return }
guard task.status != .running else { return }
- notchTasks.removeAll { $0.id == taskID }
- activeTaskIDs.remove(taskID)
+ notchTasks.removeAll { $0.id == conversationID }
+ activeAgentIDs.remove(conversationID)
// Closing the targeted task ends reply mode so the remaining rows don't stay dimmed.
- if replyTargetTaskID == taskID {
+ if replyTargetTaskID == conversationID {
replyTargetTaskID = nil
}
- if selectedTaskID == taskID {
+ if selectedTaskID == conversationID {
selectedTaskID = nil
}
- if lastActiveTaskID == taskID {
+ if lastActiveTaskID == conversationID {
lastActiveTaskID = notchTasks.first?.id
}
- if let spawnID = spawnStates.first(where: { $0.taskID == taskID })?.id {
+ if let spawnID = spawnStates.first(where: { $0.conversationID == conversationID })?.id {
removeSpawn(id: spawnID)
}
// Drop the persisted row (and its events/assets) too, so the task does not
// reappear when the notch reloads recent tasks on the next launch.
- taskStore.deleteTask(id: taskID)
+ taskStore.deleteTask(id: conversationID)
syncPrimaryTaskPausedFlag()
}
- func approvePermissionGate(id taskID: String, alwaysAllow: Bool = false) {
- guard let task = task(withID: taskID),
+ func approvePermissionGate(id conversationID: String, alwaysAllow: Bool = false) {
+ guard let task = task(withID: conversationID),
task.status == .waitingForPermission else {
return
}
@@ -924,13 +924,13 @@ final class UserQueryOverlayModel: ObservableObject, UserQueryIntentSink {
// re-executes the held command and reports back via onActed/onResponse.
if task.metadata["live.shellConsent"] == "true" {
announceLifecycle(
- taskID: taskID,
+ conversationID: conversationID,
UserQueryActivity(kind: .resumed),
status: .running,
liveDetail: "",
metadata: [:]
)
- if let turn = liveTurn, turn.taskID == taskID {
+ if let turn = liveTurn, turn.conversationID == conversationID {
updateSpawn(id: turn.spawnID, label: UserQueryActivity.Kind.resumed.label, resumesWork: true)
restartLiveTurnWatchdog()
}
@@ -941,41 +941,41 @@ final class UserQueryOverlayModel: ObservableObject, UserQueryIntentSink {
return
}
- activeTaskIDs.insert(taskID)
- lastActiveTaskID = taskID
+ activeAgentIDs.insert(conversationID)
+ lastActiveTaskID = conversationID
// After approval the task simply resumes; the live line falls back to the running activity
// ("Thinking") rather than narrating an internal "approving permission" step.
- announceLifecycle(taskID: taskID, UserQueryActivity(kind: .resumed), status: .running, liveDetail: "")
+ announceLifecycle(conversationID: conversationID, UserQueryActivity(kind: .resumed), status: .running, liveDetail: "")
promptState.leadingSignalLevel = .thinking
promptState.promptText = task.title
syncPrimaryTaskPausedFlag()
- let spawnID = spawnStates.first { $0.taskID == taskID }?.id
+ let spawnID = spawnStates.first { $0.conversationID == conversationID }?.id
updateSpawn(id: spawnID, resumesWork: true)
- let context = commandContext(taskID: taskID, isFollowUp: true, spawnID: spawnID)
+ let context = commandContext(conversationID: conversationID, isFollowUp: true, spawnID: spawnID)
Task { [weak self, commandHandler] in
- let approved = await commandHandler.approvePermissionGate(taskID: taskID, alwaysAllow: alwaysAllow)
+ let approved = await commandHandler.approvePermissionGate(conversationID: conversationID, alwaysAllow: alwaysAllow)
guard approved else {
await MainActor.run {
guard let self else { return }
- self.updateTask(id: taskID, detail: "Approval unavailable", status: .needsAttention)
- self.activeTaskIDs.remove(taskID)
+ self.updateTask(id: conversationID, detail: "Approval unavailable", status: .needsAttention)
+ self.activeAgentIDs.remove(conversationID)
self.syncPrimaryTaskPausedFlag()
}
return
}
// The grant only recorded consent; the loop already exited at the
// gate. Re-run it so the approved command actually executes.
- let result = await commandHandler.continueApprovedCommand(taskID: taskID, context: context)
+ let result = await commandHandler.continueApprovedCommand(conversationID: conversationID, context: context)
await MainActor.run {
guard let self else { return }
guard let result else {
- self.updateTask(id: taskID, detail: "Could not resume the task", status: .needsAttention)
- self.activeTaskIDs.remove(taskID)
+ self.updateTask(id: conversationID, detail: "Could not resume the task", status: .needsAttention)
+ self.activeAgentIDs.remove(conversationID)
self.syncPrimaryTaskPausedFlag()
return
}
self.handleCommandRunResult(
- taskID: taskID,
+ conversationID: conversationID,
spawnID: spawnID,
isFollowUp: true,
result: result
@@ -987,8 +987,8 @@ final class UserQueryOverlayModel: ObservableObject, UserQueryIntentSink {
/// User denied a pending permission. The harness loop already exited at the consent gate, so this
/// stops the task into a resumable (paused) state — resuming re-runs it and asks again. A Live-path
/// consent is also told "no" so it stops re-trying.
- func denyPermissionGate(id taskID: String) {
- guard let task = task(withID: taskID),
+ func denyPermissionGate(id conversationID: String) {
+ guard let task = task(withID: conversationID),
task.status == .waitingForPermission else {
return
}
@@ -997,18 +997,18 @@ final class UserQueryOverlayModel: ObservableObject, UserQueryIntentSink {
Task { [liveController] in
await liveController.resolvePendingConsent(approved: false, alwaysAllow: false)
}
- if liveTurn?.taskID == taskID {
+ if liveTurn?.conversationID == conversationID {
finishLiveTurn(detail: "Permission denied", status: .paused)
return
}
}
announceLifecycle(
- taskID: taskID,
+ conversationID: conversationID,
UserQueryActivity(kind: .paused, summary: "Permission denied"),
status: .paused
)
- activeTaskIDs.remove(taskID)
+ activeAgentIDs.remove(conversationID)
syncPrimaryTaskPausedFlag()
}
@@ -1037,7 +1037,7 @@ final class UserQueryOverlayModel: ObservableObject, UserQueryIntentSink {
private func beginSpawn(
for text: String,
label: String? = nil,
- taskID: String? = nil,
+ conversationID: String? = nil,
accentIndex: Int? = nil
) -> String? {
guard Self.spawnPointersEnabled else { return nil }
@@ -1054,7 +1054,7 @@ final class UserQueryOverlayModel: ObservableObject, UserQueryIntentSink {
notchAccentIndex = spawnAccentIndex
let spawnState = UserQuerySpawnState(
id: spawnID,
- taskID: taskID,
+ conversationID: conversationID,
commandText: text,
label: labelText,
accentIndex: spawnAccentIndex,
@@ -1069,7 +1069,7 @@ final class UserQueryOverlayModel: ObservableObject, UserQueryIntentSink {
private func updateSpawn(
id spawnID: String?,
- taskID: String? = nil,
+ conversationID: String? = nil,
commandText: String? = nil,
label: String? = nil,
accentIndex: Int? = nil,
@@ -1086,8 +1086,8 @@ final class UserQueryOverlayModel: ObservableObject, UserQueryIntentSink {
if resumesWork {
spawnState.finishedAt = nil
}
- if let taskID {
- spawnState.taskID = taskID
+ if let conversationID {
+ spawnState.conversationID = conversationID
}
if let commandText {
spawnState.commandText = commandText
@@ -1184,7 +1184,7 @@ final class UserQueryOverlayModel: ObservableObject, UserQueryIntentSink {
private func latestInteractableSpawnID() -> String? {
spawnStates
.last {
- $0.taskID != nil && ($0.phase == .holding || $0.phase == .traveling)
+ $0.conversationID != nil && ($0.phase == .holding || $0.phase == .traveling)
}?
.id
}
@@ -1193,22 +1193,22 @@ final class UserQueryOverlayModel: ObservableObject, UserQueryIntentSink {
/// auto-attached to the latest task just because it is the most recent — that route is what made a
/// new command hijack a running task. Implicit follow-up matching is left entirely to the typed
/// follow-up resolver, which decides against task content rather than recency.
- private func promptSubmissionFollowUpTarget() -> (spawnID: String, taskID: String)? {
+ private func promptSubmissionFollowUpTarget() -> (spawnID: String, conversationID: String)? {
guard let selectedSpawnID,
- let taskID = taskIDForInteractableSpawn(id: selectedSpawnID) else {
+ let conversationID = conversationIDForInteractableSpawn(id: selectedSpawnID) else {
return nil
}
- return (selectedSpawnID, taskID)
+ return (selectedSpawnID, conversationID)
}
- private func taskIDForInteractableSpawn(id spawnID: String) -> String? {
+ private func conversationIDForInteractableSpawn(id spawnID: String) -> String? {
guard let spawn = spawn(withID: spawnID),
- let taskID = spawn.taskID,
+ let conversationID = spawn.conversationID,
spawn.phase == .holding || spawn.phase == .traveling else {
return nil
}
- return taskID
+ return conversationID
}
private func removeSpawn(id spawnID: String) {
@@ -1218,7 +1218,7 @@ final class UserQueryOverlayModel: ObservableObject, UserQueryIntentSink {
}
}
- private func prependTask(_ task: UserQueryNotchTask) {
+ private func prependTask(_ task: UserQueryConversation) {
notchTasks.removeAll { $0.id == task.id }
notchTasks.insert(task, at: 0)
if notchTasks.count > Self.notchTaskDisplayLimit {
@@ -1241,7 +1241,7 @@ final class UserQueryOverlayModel: ObservableObject, UserQueryIntentSink {
text: String,
matchedTaskID: String?,
reservedAccentIndex: Int? = nil
- ) -> UserQueryNotchTask {
+ ) -> UserQueryConversation {
if let matchedTaskID,
var task = task(withID: matchedTaskID) {
if let reservedAccentIndex {
@@ -1275,7 +1275,7 @@ final class UserQueryOverlayModel: ObservableObject, UserQueryIntentSink {
let nextAccentIndex = reservedAccentIndex.map(UserQueryAccentPalette.normalizedIndex)
?? nextRoundRobinAccentIndex()
notchAccentIndex = nextAccentIndex
- let task = UserQueryNotchTask(
+ let task = UserQueryConversation(
id: UUID().uuidString,
title: taskLabel,
detail: Self.runningSeedDetail,
@@ -1287,9 +1287,9 @@ final class UserQueryOverlayModel: ObservableObject, UserQueryIntentSink {
return task
}
- private func taskForDroppedAssets() -> UserQueryNotchTask {
+ private func taskForDroppedAssets() -> UserQueryConversation {
if let lastActiveTaskID,
- activeTaskIDs.contains(lastActiveTaskID),
+ activeAgentIDs.contains(lastActiveTaskID),
let task = task(withID: lastActiveTaskID) {
return task
}
@@ -1304,7 +1304,7 @@ final class UserQueryOverlayModel: ObservableObject, UserQueryIntentSink {
let nextAccentIndex = nextRoundRobinAccentIndex()
notchAccentIndex = nextAccentIndex
- let task = UserQueryNotchTask(
+ let task = UserQueryConversation(
id: UUID().uuidString,
title: "Uploaded assets",
detail: "Assets attached",
@@ -1316,31 +1316,31 @@ final class UserQueryOverlayModel: ObservableObject, UserQueryIntentSink {
return task
}
- private func task(withID taskID: String) -> UserQueryNotchTask? {
- if let task = notchTasks.first(where: { $0.id == taskID }) {
+ private func task(withID conversationID: String) -> UserQueryConversation? {
+ if let task = notchTasks.first(where: { $0.id == conversationID }) {
return task
}
return taskStore
.loadRecentTasks(limit: max(Self.notchTaskDisplayLimit, Self.followUpCandidateLimit) * 2)
- .first { $0.id == taskID }
+ .first { $0.id == conversationID }
}
private func commandContext(
- taskID: String,
+ conversationID: String,
isFollowUp: Bool,
source: AppHarnessTurnSource = .typedPrompt,
spawnID: String? = nil
) -> UserQueryCommandContext? {
- guard let task = task(withID: taskID) else { return nil }
+ guard let task = task(withID: conversationID) else { return nil }
return UserQueryCommandContext(
task: task,
- recentEvents: Array(taskStore.loadEvents(taskID: taskID).suffix(10)),
- assets: taskStore.loadAssets(taskID: taskID),
+ recentEvents: Array(taskStore.loadEvents(conversationID: conversationID).suffix(10)),
+ assets: taskStore.loadAssets(conversationID: conversationID),
isFollowUp: isFollowUp,
turnSource: source,
- spawnProgressChanged: runProgressHandler(taskID: taskID, spawnID: spawnID),
+ spawnProgressChanged: runProgressHandler(conversationID: conversationID, spawnID: spawnID),
agentVisualizationChanged: agentVisualizationHandler(for: spawnID)
)
}
@@ -1352,7 +1352,7 @@ final class UserQueryOverlayModel: ObservableObject, UserQueryIntentSink {
/// cursor label follows the same narration. Returned unconditionally (even with pointers disabled)
/// so the status line always advances past its "Thinking" seed.
private func runProgressHandler(
- taskID: String,
+ conversationID: String,
spawnID: String?
) -> (@MainActor @Sendable (UserQuerySpawnProgressUpdate) -> Void)? {
return { [weak self] update in
@@ -1361,13 +1361,13 @@ final class UserQueryOverlayModel: ObservableObject, UserQueryIntentSink {
// A streamed answer chunk accumulates onto the task's detail (the chin and the open row both
// read it), so the reply types itself out. It bypasses the label path below, which replaces.
if let answerDelta = update.answerDelta {
- self.appendStreamedAnswer(taskID: taskID, delta: answerDelta, spawnID: spawnID)
+ self.appendStreamedAnswer(conversationID: conversationID, delta: answerDelta, spawnID: spawnID)
return
}
let label = update.label?.trimmingCharacters(in: .whitespacesAndNewlines) ?? ""
- if !label.isEmpty, self.task(withID: taskID)?.status == .running {
- self.updateTask(id: taskID, detail: label)
+ if !label.isEmpty, self.task(withID: conversationID)?.status == .running {
+ self.updateTask(id: conversationID, detail: label)
}
if let spawnID {
self.updateSpawn(
@@ -1384,13 +1384,13 @@ final class UserQueryOverlayModel: ObservableObject, UserQueryIntentSink {
/// chunk clears the per-step "Thinking" status and flips the streaming flag so the chin shows the
/// growing answer instead of the prompt; later chunks accumulate onto it. No-op once the task has
/// left the running state (a late chunk after completion must not reopen the row's status line).
- private func appendStreamedAnswer(taskID: String, delta: String, spawnID: String?) {
- guard let task = task(withID: taskID), task.status == .running else { return }
- let isStreaming = task.metadata[UserQueryNotchTask.streamingAnswerMetadataKey] == "true"
+ private func appendStreamedAnswer(conversationID: String, delta: String, spawnID: String?) {
+ guard let task = task(withID: conversationID), task.status == .running else { return }
+ let isStreaming = task.metadata[UserQueryConversation.streamingAnswerMetadataKey] == "true"
let newDetail = isStreaming ? task.detail + delta : delta
var metadata = task.metadata
- metadata[UserQueryNotchTask.streamingAnswerMetadataKey] = "true"
- updateTask(id: taskID, detail: newDetail, metadata: metadata)
+ metadata[UserQueryConversation.streamingAnswerMetadataKey] = "true"
+ updateTask(id: conversationID, detail: newDetail, metadata: metadata)
if let spawnID {
updateSpawn(id: spawnID, label: newDetail)
}
@@ -1410,17 +1410,17 @@ final class UserQueryOverlayModel: ObservableObject, UserQueryIntentSink {
.loadRecentTasks(limit: Self.followUpCandidateLimit)
.map { task in
let recentEvents = taskStore
- .loadEvents(taskID: task.id)
+ .loadEvents(conversationID: task.id)
.suffix(6)
.map { event in
Self.truncated("\(event.role.rawValue): \(event.text)", maxLength: 220)
}
let assetNames = taskStore
- .loadAssets(taskID: task.id)
+ .loadAssets(conversationID: task.id)
.suffix(8)
.map(\.displayName)
return UserQueryFollowUpCandidate(
- taskID: task.id,
+ conversationID: task.id,
title: task.title,
detail: task.detail,
commandText: task.commandText,
@@ -1433,16 +1433,16 @@ final class UserQueryOverlayModel: ObservableObject, UserQueryIntentSink {
}
@discardableResult
- private func appendTaskEvent(taskID: String, role: UserQueryTaskEventRole, text: String) -> String? {
+ private func appendAgentEvent(conversationID: String, role: UserQueryConversationEventRole, text: String) -> String? {
let trimmedText = text.trimmingCharacters(in: .whitespacesAndNewlines)
guard !trimmedText.isEmpty else { return nil }
- let sequence = taskStore.loadEvents(taskID: taskID).count
+ let sequence = taskStore.loadEvents(conversationID: conversationID).count
let eventID = UUID().uuidString
taskStore.appendEvent(
- UserQueryTaskEvent(
+ UserQueryConversationEvent(
id: eventID,
- taskID: taskID,
+ conversationID: conversationID,
role: role,
text: trimmedText,
sequence: sequence
@@ -1456,25 +1456,25 @@ final class UserQueryOverlayModel: ObservableObject, UserQueryIntentSink {
/// same line to `thread.md` — so the conversation record stays the complete history we can render
/// back to the user. New transitions pass a different `UserQueryActivity` kind; nothing else moves.
private func announceLifecycle(
- taskID: String,
+ conversationID: String,
_ activity: UserQueryActivity,
- status: UserQueryTaskStatus,
+ status: UserQueryConversationStatus,
liveDetail: String? = nil,
metadata: [String: String]? = nil
) {
- updateTask(id: taskID, detail: liveDetail ?? activity.displayText, status: status, metadata: metadata)
+ updateTask(id: conversationID, detail: liveDetail ?? activity.displayText, status: status, metadata: metadata)
// In-app event store keeps plain text (structured data for the conversation view); thread.md
// gets the icon-prefixed markdown line.
- _ = appendTaskEvent(taskID: taskID, role: .system, text: activity.displayText)
- recordThreadActivity(taskID: taskID, activity)
+ _ = appendAgentEvent(conversationID: conversationID, role: .system, text: activity.displayText)
+ recordThreadActivity(conversationID: conversationID, activity)
}
/// Appends a typed activity line to the task's `thread.md` conversation record. The thread file
/// already exists from the run, so this only ever appends (off the main thread — small file IO).
- private func recordThreadActivity(taskID: String, _ activity: UserQueryActivity) {
+ private func recordThreadActivity(conversationID: String, _ activity: UserQueryActivity) {
let line = activity.transcriptLine
Task.detached {
- ThreadTranscript(id: taskID).systemEvent(line)
+ ConversationTranscript(id: conversationID).systemEvent(line)
}
}
@@ -1482,7 +1482,7 @@ final class UserQueryOverlayModel: ObservableObject, UserQueryIntentSink {
id: String,
title: String? = nil,
detail: String? = nil,
- status: UserQueryTaskStatus? = nil,
+ status: UserQueryConversationStatus? = nil,
metadata: [String: String]? = nil
) {
guard let index = notchTasks.firstIndex(where: { $0.id == id }) else { return }
@@ -1526,11 +1526,11 @@ final class UserQueryOverlayModel: ObservableObject, UserQueryIntentSink {
/// row the user can resume with a tap. The persisted `updatedAt` is preserved throughout so a row's
/// elapsed time stays the real run duration rather than the gap until the app was reopened.
static func restoredTasks(
- from tasks: [UserQueryNotchTask],
+ from tasks: [UserQueryConversation],
now: Date
- ) -> (tasks: [UserQueryNotchTask], autoResumeIDs: [String]) {
+ ) -> (tasks: [UserQueryConversation], autoResumeIDs: [String]) {
var autoResumeIDs: [String] = []
- let restored = tasks.map { task -> UserQueryNotchTask in
+ let restored = tasks.map { task -> UserQueryConversation in
switch task.status {
case .running:
// Actively running when the app quit. Resume on its own only if that was recent;
@@ -1561,24 +1561,24 @@ final class UserQueryOverlayModel: ObservableObject, UserQueryIntentSink {
}
private func refreshPromptStateAfterRunResult(
- taskID: String,
+ conversationID: String,
result: UserQueryCommandHandlingResult
) {
syncPrimaryTaskPausedFlag()
if promptState.isActive {
- if lastActiveTaskID == taskID {
+ if lastActiveTaskID == conversationID {
lastActiveTaskID = notchTasks.first?.id
}
return
}
- if let runningTask = notchTasks.first(where: { activeTaskIDs.contains($0.id) && $0.status == .running }) {
+ if let runningTask = notchTasks.first(where: { activeAgentIDs.contains($0.id) && $0.status == .running }) {
promptState.leadingSignalLevel = .thinking
promptState.promptText = runningTask.title
return
}
- if let pausedTask = notchTasks.first(where: { activeTaskIDs.contains($0.id) && $0.status == .paused }) {
+ if let pausedTask = notchTasks.first(where: { activeAgentIDs.contains($0.id) && $0.status == .paused }) {
promptState.leadingSignalLevel = .idle
promptState.promptText = pausedTask.title
return
@@ -1586,7 +1586,7 @@ final class UserQueryOverlayModel: ObservableObject, UserQueryIntentSink {
promptState.leadingSignalLevel = result.status == .completed ? .ready : .idle
promptState.promptText = result.taskLabel ?? result.summary
- if lastActiveTaskID == taskID {
+ if lastActiveTaskID == conversationID {
lastActiveTaskID = notchTasks.first?.id
}
}
@@ -1595,7 +1595,7 @@ final class UserQueryOverlayModel: ObservableObject, UserQueryIntentSink {
isCurrentTaskPaused = notchTasks.first?.status == .paused
}
- private static func taskStatus(for result: UserQueryCommandHandlingResult) -> UserQueryTaskStatus {
+ private static func taskStatus(for result: UserQueryCommandHandlingResult) -> UserQueryConversationStatus {
result.threadStatus
}
@@ -1673,26 +1673,26 @@ final class UserQueryOverlayModel: ObservableObject, UserQueryIntentSink {
}
private static func persistedAsset(
- from draft: UserQueryTaskAssetDraft,
+ from draft: UserQueryConversationAssetDraft,
assetID: String,
- taskID: String,
+ conversationID: String,
eventID: String?
- ) -> UserQueryTaskAsset {
+ ) -> UserQueryConversationAsset {
var storedURLString = draft.urlString
if let sourceURL = URL(string: draft.urlString),
sourceURL.isFileURL,
let destinationURL = copyAssetToApplicationSupport(
sourceURL: sourceURL,
- taskID: taskID,
+ conversationID: conversationID,
assetID: assetID,
displayName: draft.displayName
) {
storedURLString = destinationURL.absoluteString
}
- return UserQueryTaskAsset(
+ return UserQueryConversationAsset(
id: assetID,
- taskID: taskID,
+ conversationID: conversationID,
eventID: eventID,
source: draft.source,
displayName: draft.displayName,
@@ -1704,11 +1704,11 @@ final class UserQueryOverlayModel: ObservableObject, UserQueryIntentSink {
private static func copyAssetToApplicationSupport(
sourceURL: URL,
- taskID: String,
+ conversationID: String,
assetID: String,
displayName: String
) -> URL? {
- guard let assetsDirectory = taskAssetDirectory(taskID: taskID) else { return nil }
+ guard let assetsDirectory = taskAssetDirectory(conversationID: conversationID) else { return nil }
do {
try FileManager.default.createDirectory(
@@ -1730,7 +1730,7 @@ final class UserQueryOverlayModel: ObservableObject, UserQueryIntentSink {
}
}
- private static func taskAssetDirectory(taskID: String) -> URL? {
+ private static func taskAssetDirectory(conversationID: String) -> URL? {
guard let applicationSupportURL = FileManager.default.urls(
for: .applicationSupportDirectory,
in: .userDomainMask
@@ -1741,7 +1741,7 @@ final class UserQueryOverlayModel: ObservableObject, UserQueryIntentSink {
return applicationSupportURL
.appendingPathComponent("Donkey", isDirectory: true)
.appendingPathComponent("UserQueryAssets", isDirectory: true)
- .appendingPathComponent(safeAssetFileName(taskID), isDirectory: true)
+ .appendingPathComponent(safeAssetFileName(conversationID), isDirectory: true)
}
private static func safeAssetFileName(_ fileName: String) -> String {
diff --git a/apps/Donkey/Sources/DonkeyAI/LocalTaskFollowUpResolver.swift b/apps/Donkey/Sources/DonkeyAI/LocalTaskFollowUpResolver.swift
index 689a0a60..9b1041de 100644
--- a/apps/Donkey/Sources/DonkeyAI/LocalTaskFollowUpResolver.swift
+++ b/apps/Donkey/Sources/DonkeyAI/LocalTaskFollowUpResolver.swift
@@ -3,26 +3,26 @@ import DonkeyRuntime
import Foundation
public struct UserQueryFollowUpCandidate: Codable, Equatable, Sendable {
- public var taskID: String
+ public var conversationID: String
public var title: String
public var detail: String
public var commandText: String
- public var status: UserQueryTaskStatus
+ public var status: UserQueryConversationStatus
public var updatedAt: Date
public var recentEvents: [String]
public var assetNames: [String]
public init(
- taskID: String,
+ conversationID: String,
title: String,
detail: String,
commandText: String,
- status: UserQueryTaskStatus,
+ status: UserQueryConversationStatus,
updatedAt: Date,
recentEvents: [String] = [],
assetNames: [String] = []
) {
- self.taskID = taskID
+ self.conversationID = conversationID
self.title = title
self.detail = detail
self.commandText = commandText
@@ -57,13 +57,13 @@ public struct UserQueryFollowUpResolverRequest: Equatable, Sendable {
}
public struct UserQueryFollowUpResolverResult: Equatable, Sendable {
- public var taskID: String?
+ public var conversationID: String?
public var confidence: Double
public var reason: String
public var trace: AIModelCallTrace
- public init(taskID: String?, confidence: Double, reason: String, trace: AIModelCallTrace) {
- self.taskID = taskID
+ public init(conversationID: String?, confidence: Double, reason: String, trace: AIModelCallTrace) {
+ self.conversationID = conversationID
self.confidence = confidence
self.reason = reason
self.trace = trace
@@ -154,17 +154,17 @@ public struct HostedTaskFollowUpResolver: UserQueryFollowUpResolving {
}
let decision = try JSONDecoder().decode(LocalLLMTaskFollowUpDecision.self, from: decisionData)
- let validCandidateIDs = Set(request.candidates.map(\.taskID))
- let taskID = decision.isFollowUp && validCandidateIDs.contains(decision.taskID) ? decision.taskID : nil
+ let validCandidateIDs = Set(request.candidates.map(\.conversationID))
+ let conversationID = decision.isFollowUp && validCandidateIDs.contains(decision.conversationID) ? decision.conversationID : nil
return UserQueryFollowUpResolverResult(
- taskID: taskID,
+ conversationID: conversationID,
confidence: min(max(decision.confidence, 0), 1),
reason: decision.reason,
trace: trace(
entry: entry,
request: request,
status: .completed,
- validationStatus: taskID == nil ? "newTask" : "matchedTask",
+ validationStatus: conversationID == nil ? "newTask" : "matchedTask",
latencyMS: latencyMS,
metadata: [
"provider": "donkeyBackend",
@@ -230,7 +230,7 @@ public struct HostedTaskFollowUpResolver: UserQueryFollowUpResolving {
)
}
- private static let instructions = "Decide whether the current turn continues one of the candidate Donkey task threads. Set isFollowUp false and taskID empty when the turn should start a new task."
+ private static let instructions = "Decide whether the current turn continues one of the candidate Donkey task threads. Set isFollowUp false and conversationID empty when the turn should start a new task."
private static func schema(for candidates: [UserQueryFollowUpCandidate]) -> RemoteInferenceJSONValue {
.object([
@@ -238,15 +238,15 @@ public struct HostedTaskFollowUpResolver: UserQueryFollowUpResolving {
"additionalProperties": .bool(false),
"required": .array([
.string("isFollowUp"),
- .string("taskID"),
+ .string("conversationID"),
.string("confidence"),
.string("reason")
]),
"properties": .object([
"isFollowUp": .object(["type": .string("boolean")]),
- "taskID": .object([
+ "conversationID": .object([
"type": .string("string"),
- "enum": .array((candidates.map(\.taskID) + [""]).map(RemoteInferenceJSONValue.string))
+ "enum": .array((candidates.map(\.conversationID) + [""]).map(RemoteInferenceJSONValue.string))
]),
"confidence": .object([
"type": .string("number"),
@@ -318,7 +318,7 @@ public struct HostedTaskFollowUpResolver: UserQueryFollowUpResolving {
metadata: [String: String] = [:]
) -> UserQueryFollowUpResolverResult {
UserQueryFollowUpResolverResult(
- taskID: nil,
+ conversationID: nil,
confidence: 0,
reason: metadata["error"] ?? metadata["reason"] ?? "",
trace: trace(
@@ -359,7 +359,7 @@ public struct HostedTaskFollowUpResolver: UserQueryFollowUpResolving {
private struct LocalLLMTaskFollowUpDecision: Codable, Equatable, Sendable {
var isFollowUp: Bool
- var taskID: String
+ var conversationID: String
var confidence: Double
var reason: String
}
diff --git a/apps/Donkey/Sources/DonkeyContracts/AgentPathTraceContracts.swift b/apps/Donkey/Sources/DonkeyContracts/AgentPathTraceContracts.swift
index 629c459d..5262edde 100644
--- a/apps/Donkey/Sources/DonkeyContracts/AgentPathTraceContracts.swift
+++ b/apps/Donkey/Sources/DonkeyContracts/AgentPathTraceContracts.swift
@@ -82,7 +82,7 @@ public struct AgentPathStep: Codable, Equatable, Sendable, Identifiable {
public struct AgentPathTrace: Codable, Equatable, Sendable, Identifiable {
public var id: String
- public var taskID: String
+ public var agentID: String
public var title: String
public var sourceTraceID: String
public var steps: [AgentPathStep]
@@ -90,14 +90,14 @@ public struct AgentPathTrace: Codable, Equatable, Sendable, Identifiable {
public init(
id: String = UUID().uuidString,
- taskID: String,
+ agentID: String,
title: String,
sourceTraceID: String,
steps: [AgentPathStep],
metadata: [String: String] = [:]
) {
self.id = id
- self.taskID = taskID
+ self.agentID = agentID
self.title = title
self.sourceTraceID = sourceTraceID
self.steps = steps
@@ -150,7 +150,7 @@ public struct AgentPathTrace: Codable, Equatable, Sendable, Identifiable {
metadata: metadata.merging([
"source": "agent-path-trace",
"agentPath.traceID": id,
- "agentPath.taskID": taskID,
+ "agentPath.agentID": agentID,
"agentPath.stepCount": String(steps.count),
"agentPath.groundedStepCount": String(visualSteps.count),
"realPointerMoved": "false",
diff --git a/apps/Donkey/Sources/DonkeyContracts/AppHarnessContracts.swift b/apps/Donkey/Sources/DonkeyContracts/AppHarnessContracts.swift
index ae4b8cbe..998ce239 100644
--- a/apps/Donkey/Sources/DonkeyContracts/AppHarnessContracts.swift
+++ b/apps/Donkey/Sources/DonkeyContracts/AppHarnessContracts.swift
@@ -80,7 +80,7 @@ public struct AppHarnessTurn: Codable, Equatable, Sendable {
public var id: String
public var text: String
public var source: AppHarnessTurnSource
- public var taskID: String?
+ public var conversationID: String?
public var isFollowUp: Bool
public var createdAt: Date
@@ -88,14 +88,14 @@ public struct AppHarnessTurn: Codable, Equatable, Sendable {
id: String = UUID().uuidString,
text: String,
source: AppHarnessTurnSource,
- taskID: String? = nil,
+ conversationID: String? = nil,
isFollowUp: Bool = false,
createdAt: Date = Date()
) {
self.id = id
self.text = text
self.source = source
- self.taskID = taskID
+ self.conversationID = conversationID
self.isFollowUp = isFollowUp
self.createdAt = createdAt
}
diff --git a/apps/Donkey/Sources/DonkeyContracts/HarnessTraceContracts.swift b/apps/Donkey/Sources/DonkeyContracts/HarnessTraceContracts.swift
index e57fb501..a7839f45 100644
--- a/apps/Donkey/Sources/DonkeyContracts/HarnessTraceContracts.swift
+++ b/apps/Donkey/Sources/DonkeyContracts/HarnessTraceContracts.swift
@@ -9,7 +9,7 @@ public enum TraceModelCallKind: String, Codable, Equatable, Sendable {
/// A per-step planning call (the first sample or a feedback-driven retry).
case plannerStep
/// The background call that rewrites the compacted thread summary.
- case threadSummary
+ case conversationSummary
}
/// What came back from a model call. Distinguishes the failure shapes the planner already separates
@@ -79,7 +79,7 @@ public struct TraceModelCall: Sendable {
/// The recording surface the model boundaries depend on. The AI boundaries (`HostedHarnessStepPlanner`,
/// `HostedHarnessRequestUnderstanding`) hold only this protocol, so they record without importing the
/// runtime that writes files and stay testable with a recording double — the same split the harness
-/// uses for `HarnessThreadStoring`. The concrete `HarnessTurnTrace` lives in DonkeyRuntime and adds the
+/// uses for `HarnessConversationStoring`. The concrete `HarnessTurnTrace` lives in DonkeyRuntime and adds the
/// per-step and per-turn methods the handler calls directly.
///
/// A nil recorder means tracing is off; every call site treats it as optional so the hot path is
diff --git a/apps/Donkey/Sources/DonkeyContracts/RemoteInferenceContracts.swift b/apps/Donkey/Sources/DonkeyContracts/RemoteInferenceContracts.swift
index a6641fe8..b4937ef6 100644
--- a/apps/Donkey/Sources/DonkeyContracts/RemoteInferenceContracts.swift
+++ b/apps/Donkey/Sources/DonkeyContracts/RemoteInferenceContracts.swift
@@ -379,8 +379,8 @@ public struct RemoteInferenceDownloadedAsset: Codable, Equatable, Sendable {
self.byteCount = byteCount
}
- public func userQueryAssetDraft(displayName: String? = nil) -> UserQueryTaskAssetDraft {
- UserQueryTaskAssetDraft(
+ public func userQueryAssetDraft(displayName: String? = nil) -> UserQueryConversationAssetDraft {
+ UserQueryConversationAssetDraft(
source: .agentReturned,
displayName: displayName ?? fileURL.lastPathComponent,
contentType: contentType,
diff --git a/apps/Donkey/Sources/DonkeyContracts/UserQueryActivity.swift b/apps/Donkey/Sources/DonkeyContracts/UserQueryActivity.swift
index b40e0135..bf46c586 100644
--- a/apps/Donkey/Sources/DonkeyContracts/UserQueryActivity.swift
+++ b/apps/Donkey/Sources/DonkeyContracts/UserQueryActivity.swift
@@ -132,7 +132,7 @@ public extension UserQueryActivity.Kind {
public extension UserQueryActivity {
/// Maps a task's lifecycle status to an activity kind.
- static func kind(forStatus status: UserQueryTaskStatus) -> Kind {
+ static func kind(forStatus status: UserQueryConversationStatus) -> Kind {
switch status {
case .chatting: return .message
case .running: return .working
@@ -178,7 +178,7 @@ public extension UserQueryActivity {
/// The activity a task is currently surfacing. While running it prefers the live tool hint
/// (`activity.tool` metadata) so the line reads like the agent's current step; otherwise the
/// status drives the kind. The task's `detail` carries any specifics.
- static func current(for task: UserQueryNotchTask) -> UserQueryActivity {
+ static func current(for task: UserQueryConversation) -> UserQueryActivity {
let summary = task.detail.trimmingCharacters(in: .whitespacesAndNewlines)
let kind: Kind
if task.status == .running, let tool = task.metadata["activity.tool"], !tool.isEmpty {
diff --git a/apps/Donkey/Sources/DonkeyContracts/UserQueryContracts.swift b/apps/Donkey/Sources/DonkeyContracts/UserQueryContracts.swift
index b3ec8852..378a0f0b 100644
--- a/apps/Donkey/Sources/DonkeyContracts/UserQueryContracts.swift
+++ b/apps/Donkey/Sources/DonkeyContracts/UserQueryContracts.swift
@@ -234,7 +234,7 @@ public enum SignalLevel: String, Equatable, Sendable {
/// Well-known keys on a task's `metadata`. Shared so the harness side that writes them and the notch
/// UI that reads them never drift on a raw string literal.
-public enum UserQueryTaskMetadataKey {
+public enum UserQueryConversationMetadataKey {
/// Set to "true" on a task that failed because the account is out of credits. The notch shows a
/// "Reload credits" CTA banner for such a task.
public static let creditReloadRequired = "credits.reloadRequired"
diff --git a/apps/Donkey/Sources/DonkeyContracts/UserQueryTaskContracts.swift b/apps/Donkey/Sources/DonkeyContracts/UserQueryConversationContracts.swift
similarity index 77%
rename from apps/Donkey/Sources/DonkeyContracts/UserQueryTaskContracts.swift
rename to apps/Donkey/Sources/DonkeyContracts/UserQueryConversationContracts.swift
index cdb8825f..fd0780a5 100644
--- a/apps/Donkey/Sources/DonkeyContracts/UserQueryTaskContracts.swift
+++ b/apps/Donkey/Sources/DonkeyContracts/UserQueryConversationContracts.swift
@@ -1,6 +1,6 @@
import Foundation
-public enum UserQueryTaskStatus: String, Codable, Equatable, Sendable {
+public enum UserQueryConversationStatus: String, Codable, Equatable, Sendable {
case chatting
case running
case paused
@@ -14,7 +14,7 @@ public enum UserQueryTaskStatus: String, Codable, Equatable, Sendable {
case timedOut
}
-public extension UserQueryTaskStatus {
+public extension UserQueryConversationStatus {
/// The agent is blocked asking the user to respond (a clarification or a review). These are the only
/// states that surface a dedicated Reply button, since only here is the agent actively asking. Every
/// state is repliable by tapping the row (a running/permission-gated thread takes the reply as a
@@ -24,12 +24,12 @@ public extension UserQueryTaskStatus {
}
}
-public struct UserQueryNotchTask: Codable, Equatable, Identifiable, Sendable {
+public struct UserQueryConversation: Codable, Equatable, Identifiable, Sendable {
public var id: String
public var title: String
public var detail: String
public var commandText: String
- public var status: UserQueryTaskStatus
+ public var status: UserQueryConversationStatus
public var accentIndex: Int
public var createdAt: Date
public var updatedAt: Date
@@ -40,7 +40,7 @@ public struct UserQueryNotchTask: Codable, Equatable, Identifiable, Sendable {
title: String,
detail: String,
commandText: String = "",
- status: UserQueryTaskStatus,
+ status: UserQueryConversationStatus,
accentIndex: Int,
createdAt: Date = Date(),
updatedAt: Date = Date(),
@@ -58,7 +58,7 @@ public struct UserQueryNotchTask: Codable, Equatable, Identifiable, Sendable {
}
}
-public extension UserQueryNotchTask {
+public extension UserQueryConversation {
/// Metadata flag set while the assistant's final reply is streaming in token-by-token, so the chin
/// switches from echoing the prompt to showing the growing answer even though the task is still
/// running. Cleared implicitly once the task reaches a terminal status (which shows `detail` anyway).
@@ -82,31 +82,31 @@ public extension UserQueryNotchTask {
}
}
-public enum UserQueryTaskEventRole: String, Codable, Equatable, Sendable {
+public enum UserQueryConversationEventRole: String, Codable, Equatable, Sendable {
case user
case assistant
case system
case tool
}
-public struct UserQueryTaskEvent: Codable, Equatable, Identifiable, Sendable {
+public struct UserQueryConversationEvent: Codable, Equatable, Identifiable, Sendable {
public var id: String
- public var taskID: String
- public var role: UserQueryTaskEventRole
+ public var conversationID: String
+ public var role: UserQueryConversationEventRole
public var text: String
public var sequence: Int
public var createdAt: Date
public init(
id: String,
- taskID: String,
- role: UserQueryTaskEventRole,
+ conversationID: String,
+ role: UserQueryConversationEventRole,
text: String,
sequence: Int,
createdAt: Date = Date()
) {
self.id = id
- self.taskID = taskID
+ self.conversationID = conversationID
self.role = role
self.text = text
self.sequence = sequence
@@ -114,16 +114,16 @@ public struct UserQueryTaskEvent: Codable, Equatable, Identifiable, Sendable {
}
}
-public enum UserQueryTaskAssetSource: String, Codable, Equatable, Sendable {
+public enum UserQueryConversationAssetSource: String, Codable, Equatable, Sendable {
case userUploaded
case agentReturned
}
-public struct UserQueryTaskAsset: Codable, Equatable, Identifiable, Sendable {
+public struct UserQueryConversationAsset: Codable, Equatable, Identifiable, Sendable {
public var id: String
- public var taskID: String
+ public var conversationID: String
public var eventID: String?
- public var source: UserQueryTaskAssetSource
+ public var source: UserQueryConversationAssetSource
public var displayName: String
public var contentType: String
public var urlString: String
@@ -132,9 +132,9 @@ public struct UserQueryTaskAsset: Codable, Equatable, Identifiable, Sendable {
public init(
id: String,
- taskID: String,
+ conversationID: String,
eventID: String? = nil,
- source: UserQueryTaskAssetSource,
+ source: UserQueryConversationAssetSource,
displayName: String,
contentType: String,
urlString: String,
@@ -142,7 +142,7 @@ public struct UserQueryTaskAsset: Codable, Equatable, Identifiable, Sendable {
createdAt: Date = Date()
) {
self.id = id
- self.taskID = taskID
+ self.conversationID = conversationID
self.eventID = eventID
self.source = source
self.displayName = displayName
@@ -153,15 +153,15 @@ public struct UserQueryTaskAsset: Codable, Equatable, Identifiable, Sendable {
}
}
-public struct UserQueryTaskAssetDraft: Codable, Equatable, Sendable {
- public var source: UserQueryTaskAssetSource
+public struct UserQueryConversationAssetDraft: Codable, Equatable, Sendable {
+ public var source: UserQueryConversationAssetSource
public var displayName: String
public var contentType: String
public var urlString: String
public var byteCount: Int64?
public init(
- source: UserQueryTaskAssetSource = .userUploaded,
+ source: UserQueryConversationAssetSource = .userUploaded,
displayName: String,
contentType: String,
urlString: String,
diff --git a/apps/Donkey/Sources/DonkeyContracts/UserQuerySpawnContracts.swift b/apps/Donkey/Sources/DonkeyContracts/UserQuerySpawnContracts.swift
index 40df8d25..c899d00f 100644
--- a/apps/Donkey/Sources/DonkeyContracts/UserQuerySpawnContracts.swift
+++ b/apps/Donkey/Sources/DonkeyContracts/UserQuerySpawnContracts.swift
@@ -32,7 +32,7 @@ public struct UserQuerySpawnTargetHint: Codable, Equatable, Sendable {
public struct UserQuerySpawnState: Codable, Equatable, Identifiable, Sendable {
public var id: String
- public var taskID: String?
+ public var conversationID: String?
public var commandText: String
public var label: String
public var accentIndex: Int
@@ -47,7 +47,7 @@ public struct UserQuerySpawnState: Codable, Equatable, Identifiable, Sendable {
public init(
id: String = UUID().uuidString,
- taskID: String? = nil,
+ conversationID: String? = nil,
commandText: String,
label: String,
accentIndex: Int,
@@ -59,7 +59,7 @@ public struct UserQuerySpawnState: Codable, Equatable, Identifiable, Sendable {
finishedAt: Date? = nil
) {
self.id = id
- self.taskID = taskID
+ self.conversationID = conversationID
self.commandText = commandText
self.label = label
self.accentIndex = accentIndex
@@ -97,7 +97,7 @@ public struct UserQuerySpawnProgressUpdate: Equatable, Sendable {
public enum UserQuerySpawnLifecycle {
public static func keepsVisibleResult(
- for threadStatus: UserQueryTaskStatus
+ for threadStatus: UserQueryConversationStatus
) -> Bool {
switch threadStatus {
case .chatting,
diff --git a/apps/Donkey/Sources/DonkeyHarness/GenericHarnessApplicationLearning.swift b/apps/Donkey/Sources/DonkeyHarness/GenericHarnessApplicationLearning.swift
index fccd0165..073e6206 100644
--- a/apps/Donkey/Sources/DonkeyHarness/GenericHarnessApplicationLearning.swift
+++ b/apps/Donkey/Sources/DonkeyHarness/GenericHarnessApplicationLearning.swift
@@ -138,7 +138,7 @@ public struct HarnessApplicationProfile: Codable, Equatable, Sendable {
public struct HarnessApplicationLearningDraft: Codable, Equatable, Sendable {
public var id: String
- public var taskID: String
+ public var agentID: String
public var skillID: String
public var appName: String
public var bundleIdentifier: String?
@@ -152,7 +152,7 @@ public struct HarnessApplicationLearningDraft: Codable, Equatable, Sendable {
public init(
id: String,
- taskID: String,
+ agentID: String,
skillID: String,
appName: String,
bundleIdentifier: String? = nil,
@@ -165,7 +165,7 @@ public struct HarnessApplicationLearningDraft: Codable, Equatable, Sendable {
metadata: [String: String] = [:]
) {
self.id = id
- self.taskID = taskID
+ self.agentID = agentID
self.skillID = skillID
self.appName = appName
self.bundleIdentifier = bundleIdentifier
@@ -208,7 +208,7 @@ public actor HarnessApplicationLearningStore {
@discardableResult
public func begin(
draftID: String,
- taskID: String,
+ agentID: String,
skillID: String,
appName: String,
bundleIdentifier: String?,
@@ -218,7 +218,7 @@ public actor HarnessApplicationLearningStore {
) -> HarnessApplicationLearningDraft {
let draft = HarnessApplicationLearningDraft(
id: draftID,
- taskID: taskID,
+ agentID: agentID,
skillID: skillID,
appName: appName,
bundleIdentifier: bundleIdentifier,
diff --git a/apps/Donkey/Sources/DonkeyHarness/GenericHarnessBuiltInToolExecutors.swift b/apps/Donkey/Sources/DonkeyHarness/GenericHarnessBuiltInToolExecutors.swift
index 14110ee9..eee4023e 100644
--- a/apps/Donkey/Sources/DonkeyHarness/GenericHarnessBuiltInToolExecutors.swift
+++ b/apps/Donkey/Sources/DonkeyHarness/GenericHarnessBuiltInToolExecutors.swift
@@ -1144,8 +1144,8 @@ public enum BuiltInHarnessToolExecutors {
let trace = AgentPathTrace(
id: trimmed(context.call.input["traceID"] ?? context.call.input["agentPathTraceID"])
- ?? "agent-path-\(context.taskID)-\(context.call.id)",
- taskID: context.taskID,
+ ?? "agent-path-\(context.agentID)-\(context.call.id)",
+ agentID: context.agentID,
title: trimmed(context.call.input["title"]) ?? context.worldModel.facts["genericHarness.intent.goal"] ?? "Agent path",
sourceTraceID: trimmed(context.call.input["sourceTraceID"] ?? context.call.metadata["traceID"]) ?? context.call.id,
steps: steps,
@@ -1245,7 +1245,7 @@ public enum BuiltInHarnessToolExecutors {
input["generation.backend"] = outcome.metadata["generator"] ?? "dynamicAppleScriptGenerator"
}
let generatedContext = HarnessToolExecutionContext(
- taskID: context.taskID,
+ agentID: context.agentID,
call: HarnessToolCall(
id: context.call.id,
name: context.call.name,
@@ -1424,14 +1424,14 @@ public enum BuiltInHarnessToolExecutors {
return invalidInput(context, "application.learning.start requires a target app.")
}
let skillID = trimmed(context.call.input["skillID"]) ?? "learned-\(stableIDSeed(from: appName))"
- let draftID = trimmed(context.call.input["draftID"]) ?? "\(context.taskID)-\(skillID)"
+ let draftID = trimmed(context.call.input["draftID"]) ?? "\(context.agentID)-\(skillID)"
let learningGoal = trimmed(context.call.input["goal"]) ?? "Learn \(appName)."
let policy = trimmed(context.call.input["explorationPolicy"])
?? "Safe exploration only: observe, inspect Accessibility elements, open reversible menus/tabs/fields, and ask before destructive, send, purchase, or save-overwrite actions."
let draft = await services.applicationLearningStore.begin(
draftID: draftID,
- taskID: context.taskID,
+ agentID: context.agentID,
skillID: skillID,
appName: appName,
bundleIdentifier: trimmed(context.call.input["bundleIdentifier"]),
diff --git a/apps/Donkey/Sources/DonkeyHarness/GenericHarnessContracts.swift b/apps/Donkey/Sources/DonkeyHarness/GenericHarnessContracts.swift
index 13d1ee2c..ec1530e8 100644
--- a/apps/Donkey/Sources/DonkeyHarness/GenericHarnessContracts.swift
+++ b/apps/Donkey/Sources/DonkeyHarness/GenericHarnessContracts.swift
@@ -15,7 +15,7 @@ public enum HarnessStage: String, Codable, CaseIterable, Equatable, Sendable {
case lifecycle
}
-public enum HarnessTaskStatus: String, Codable, CaseIterable, Equatable, Sendable {
+public enum HarnessAgentStatus: String, Codable, CaseIterable, Equatable, Sendable {
case running
case paused
case waitingForUser
@@ -111,7 +111,7 @@ public struct HarnessIntentAnalysis: Codable, Equatable, Sendable {
public struct HarnessContextSnapshot: Codable, Equatable, Sendable {
public var turn: AppHarnessTurn?
- public var threadID: String?
+ public var conversationID: String?
public var memory: [String]
public var availableToolNames: [String]
public var availableSkillIDs: [String]
@@ -120,7 +120,7 @@ public struct HarnessContextSnapshot: Codable, Equatable, Sendable {
public init(
turn: AppHarnessTurn? = nil,
- threadID: String? = nil,
+ conversationID: String? = nil,
memory: [String] = [],
availableToolNames: [String] = [],
availableSkillIDs: [String] = [],
@@ -128,7 +128,7 @@ public struct HarnessContextSnapshot: Codable, Equatable, Sendable {
metadata: [String: String] = [:]
) {
self.turn = turn
- self.threadID = threadID
+ self.conversationID = conversationID
self.memory = memory
self.availableToolNames = availableToolNames
self.availableSkillIDs = availableSkillIDs
diff --git a/apps/Donkey/Sources/DonkeyHarness/GenericHarnessToolRegistry.swift b/apps/Donkey/Sources/DonkeyHarness/GenericHarnessToolRegistry.swift
index d96ad79d..1f3c748c 100644
--- a/apps/Donkey/Sources/DonkeyHarness/GenericHarnessToolRegistry.swift
+++ b/apps/Donkey/Sources/DonkeyHarness/GenericHarnessToolRegistry.swift
@@ -58,20 +58,20 @@ public struct HarnessToolDescriptor: Codable, Equatable, Sendable {
}
public struct HarnessToolExecutionContext: Sendable {
- public var taskID: String
+ public var agentID: String
public var call: HarnessToolCall
public var descriptor: HarnessToolDescriptor
public var worldModel: HarnessWorldModel
public var grantedPermissions: Set<HarnessPermission>
public init(
- taskID: String,
+ agentID: String,
call: HarnessToolCall,
descriptor: HarnessToolDescriptor,
worldModel: HarnessWorldModel,
grantedPermissions: Set<HarnessPermission>
) {
- self.taskID = taskID
+ self.agentID = agentID
self.call = call
self.descriptor = descriptor
self.worldModel = worldModel
@@ -117,7 +117,7 @@ public actor HarnessToolRegistry {
public func execute(
_ call: HarnessToolCall,
- taskID: String,
+ agentID: String,
worldModel: HarnessWorldModel,
grantedPermissions: Set<HarnessPermission>
) async -> HarnessToolResult {
@@ -150,7 +150,7 @@ public actor HarnessToolRegistry {
return await tool.execute(
HarnessToolExecutionContext(
- taskID: taskID,
+ agentID: agentID,
call: call,
descriptor: tool.descriptor,
worldModel: worldModel,
diff --git a/apps/Donkey/Sources/DonkeyRuntime/AppHarnessGenericLifecycle.swift b/apps/Donkey/Sources/DonkeyRuntime/AppHarnessGenericLifecycle.swift
index 8d622c51..fbbceee2 100644
--- a/apps/Donkey/Sources/DonkeyRuntime/AppHarnessGenericLifecycle.swift
+++ b/apps/Donkey/Sources/DonkeyRuntime/AppHarnessGenericLifecycle.swift
@@ -12,82 +12,82 @@ public enum HarnessGateApproval: String, Sendable {
}
public struct AppHarnessGenericLifecyclePreparedTurn: Equatable, Sendable {
- public var thread: HarnessThread
- public var task: HarnessTaskState
- public var compactedContext: HarnessCompactedThreadContext
+ public var conversation: HarnessConversation
+ public var agent: HarnessAgentState
+ public var compactedContext: HarnessCompactedConversationContext
public init(
- thread: HarnessThread,
- task: HarnessTaskState,
- compactedContext: HarnessCompactedThreadContext
+ conversation: HarnessConversation,
+ agent: HarnessAgentState,
+ compactedContext: HarnessCompactedConversationContext
) {
- self.thread = thread
- self.task = task
+ self.conversation = conversation
+ self.agent = agent
self.compactedContext = compactedContext
}
}
public struct AppHarnessGenericLifecycle: Sendable {
- public var threadStore: any HarnessThreadStoring
- public var coordinator: HarnessTaskCoordinator
- public var compactor: HarnessThreadCompactor
+ public var conversationStore: any HarnessConversationStoring
+ public var coordinator: HarnessAgentCoordinator
+ public var compactor: HarnessConversationCompactor
public init(
- threadStore: (any HarnessThreadStoring)? = nil,
- coordinator: HarnessTaskCoordinator? = nil,
- compactor: HarnessThreadCompactor = HarnessThreadCompactor()
+ conversationStore: (any HarnessConversationStoring)? = nil,
+ coordinator: HarnessAgentCoordinator? = nil,
+ compactor: HarnessConversationCompactor = HarnessConversationCompactor()
) {
- let resolvedThreadStore = threadStore ?? FileHarnessThreadStore()
- self.threadStore = resolvedThreadStore
- self.coordinator = coordinator ?? HarnessTaskCoordinator(threadStore: resolvedThreadStore)
+ let resolvedConversationStore = conversationStore ?? FileHarnessConversationStore()
+ self.conversationStore = resolvedConversationStore
+ self.coordinator = coordinator ?? HarnessAgentCoordinator(conversationStore: resolvedConversationStore)
self.compactor = compactor
}
public func prepareUserQueryTurn(
request: AppHarnessTurnRequest,
- pointerTask: UserQueryNotchTask?,
+ pointerTask: UserQueryConversation?,
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 conversationID = request.turn.conversationID ?? pointerTask?.id ?? traceID
+ let agentID = pointerTask?.id ?? request.turn.conversationID ?? conversationID
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,
+ let existingConversation = await conversationStore.conversation(id: conversationID)
+ let activeAgentIDs = Array(Set((existingConversation?.activeAgentIDs ?? []) + [agentID])).sorted()
+ let conversation = HarnessConversation(
+ id: conversationID,
+ title: existingConversation?.title ?? title,
status: .running,
- activeTaskIDs: activeTaskIDs,
- createdAt: existingThread?.createdAt ?? now,
+ activeAgentIDs: activeAgentIDs,
+ createdAt: existingConversation?.createdAt ?? now,
updatedAt: now,
- metadata: (existingThread?.metadata ?? [:]).merging([
+ metadata: (existingConversation?.metadata ?? [:]).merging([
"source": "userQuery",
"traceID": traceID
]) { current, _ in current }
)
- await threadStore.upsertThread(thread)
+ await conversationStore.upsertConversation(conversation)
await mirrorUserQueryEvents(
request.recentEvents,
- threadID: threadID,
- taskID: taskID
+ conversationID: conversationID,
+ agentID: agentID
)
await mirrorUserQueryAssets(
request.assets,
- threadID: threadID,
- taskID: taskID
+ conversationID: conversationID,
+ agentID: agentID
)
await appendCurrentTurnIfNeeded(
request.turn,
- threadID: threadID,
- taskID: taskID
+ conversationID: conversationID,
+ agentID: agentID
)
let context = HarnessContextSnapshot(
turn: request.turn,
- threadID: threadID,
+ conversationID: conversationID,
memory: request.memory,
availableToolNames: availableToolNames,
policy: request.policy,
@@ -96,28 +96,28 @@ public struct AppHarnessGenericLifecycle: Sendable {
"source": "userQuery"
]
)
- let task = await loadOrCreateTask(
- taskID: taskID,
- threadID: threadID,
+ let agent = await loadOrCreateAgent(
+ agentID: agentID,
+ conversationID: conversationID,
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 events = await conversationStore.events(conversationID: conversationID)
+ let assets = await conversationStore.assets(conversationID: conversationID)
+ let activeAgents = await coordinator.activeAgents()
+ .filter { $0.conversationID == conversationID }
let compactedContext = compactor.compact(
- thread: thread,
+ conversation: conversation,
currentTurn: request.turn,
events: events,
assets: assets,
- activeTasks: activeTasks
+ activeAgents: activeAgents
)
- await threadStore.appendCompactionSnapshot(
+ await conversationStore.appendCompactionSnapshot(
HarnessCompactionSnapshot(
- threadID: threadID,
- taskIDs: compactedContext.activeTasks.map(\.id),
+ conversationID: conversationID,
+ agentIDs: compactedContext.activeAgents.map(\.id),
eventIDs: compactedContext.events.map(\.id),
assetIDs: compactedContext.assets.map(\.id),
promptCharacterCount: compactedContext.promptText.count,
@@ -130,35 +130,35 @@ public struct AppHarnessGenericLifecycle: Sendable {
)
return AppHarnessGenericLifecyclePreparedTurn(
- thread: thread,
- task: task,
+ conversation: conversation,
+ agent: agent,
compactedContext: compactedContext
)
}
- public func taskState(taskID: String) async -> HarnessTaskState? {
- await coordinator.task(id: taskID)
+ public func agentState(agentID: String) async -> HarnessAgentState? {
+ await coordinator.agent(id: agentID)
}
@discardableResult
- public func pauseTask(taskID: String, reason: String) async -> HarnessTaskState? {
- await coordinator.pause(taskID: taskID, reason: reason)
+ public func pauseAgent(agentID: String, reason: String) async -> HarnessAgentState? {
+ await coordinator.pause(agentID: agentID, reason: reason)
}
@discardableResult
- public func resumeTask(taskID: String, reason: String) async -> HarnessTaskState? {
- await coordinator.resume(taskID: taskID, reason: reason)
+ public func resumeAgent(agentID: String, reason: String) async -> HarnessAgentState? {
+ await coordinator.resume(agentID: agentID, reason: reason)
}
@discardableResult
public func approvePermissionGate(
- taskID: String,
+ agentID: String,
decision: HarnessGateApproval = .allow,
reason: String
- ) async -> HarnessTaskState? {
- guard let task = await coordinator.task(id: taskID),
- task.status == .waitingForPermission,
- let continuation = task.pendingContinuation else {
+ ) async -> HarnessAgentState? {
+ guard let agent = await coordinator.agent(id: agentID),
+ agent.status == .waitingForPermission,
+ let continuation = agent.pendingContinuation else {
return nil
}
@@ -171,9 +171,9 @@ public struct AppHarnessGenericLifecycle: Sendable {
if decision == .allowAlways, tier != .highRisk {
await ShellPermissionPolicyStore.shared.allowAlways(signature, tier: tier)
} else {
- await ShellPermissionPolicyStore.shared.grantOnce(taskID: taskID, signature: signature)
+ await ShellPermissionPolicyStore.shared.grantOnce(agentID: agentID, signature: signature)
}
- return await coordinator.resume(taskID: taskID, reason: reason)
+ return await coordinator.resume(agentID: agentID, reason: reason)
}
// System (TCC) permission gate: the user approved in the notch, so NOW trigger the macOS
@@ -182,12 +182,12 @@ public struct AppHarnessGenericLifecycle: Sendable {
guard let permission = Self.systemPermission(from: continuation.metadata) else { return nil }
let granted = await SystemPermissionCoordinator.request(permission)
guard granted else { return nil }
- return await coordinator.resume(taskID: taskID, reason: reason)
+ return await coordinator.resume(agentID: agentID, reason: reason)
}
guard !continuation.missingPermissions.isEmpty else { return nil }
return await coordinator.grantPermissions(
- taskID: taskID,
+ agentID: agentID,
permissions: Set(continuation.missingPermissions),
reason: reason
)
@@ -209,17 +209,17 @@ public struct AppHarnessGenericLifecycle: Sendable {
}
}
- private func loadOrCreateTask(
- taskID: String,
- threadID: String,
+ private func loadOrCreateAgent(
+ agentID: String,
+ conversationID: 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,
+ ) async -> HarnessAgentState {
+ guard let existing = await coordinator.agent(id: agentID) else {
+ return await coordinator.createAgent(
+ id: agentID,
+ conversationID: conversationID,
goal: goal,
context: context,
grantedPermissions: grantedPermissions
@@ -230,48 +230,48 @@ public struct AppHarnessGenericLifecycle: Sendable {
let response = context.turn?.text,
!response.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty {
_ = await coordinator.provideUserResponse(
- taskID: taskID,
+ agentID: agentID,
response: response
)
} else if context.turn?.isFollowUp == true {
- // A follow-up to a task whose loop already stopped (a live loop picks the message up directly
+ // A follow-up to a agent whose loop already stopped (a live loop picks the message up directly
// and never reaches here): queue the instruction so the resumed loop folds it in, and resume.
// The original goal is preserved — the follow-up amends the work rather than replacing it,
// the deliberate opposite of the old interrupt-and-restart behavior.
if let followUpText = context.turn?.text,
!followUpText.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty {
- _ = await coordinator.enqueueUserMessage(taskID: taskID, text: followUpText)
+ _ = await coordinator.enqueueUserMessage(agentID: agentID, text: followUpText)
}
_ = await coordinator.resume(
- taskID: taskID,
- reason: "User query follow-up resumed task"
+ agentID: agentID,
+ reason: "User query follow-up resumed agent"
)
} else if !existing.status.canExecuteTools {
_ = await coordinator.resume(
- taskID: taskID,
- reason: "User query resumed task"
+ agentID: agentID,
+ reason: "User query resumed agent"
)
}
return await coordinator.updateContext(
- taskID: taskID,
+ agentID: agentID,
context: context
) ?? existing
}
private func mirrorUserQueryEvents(
- _ pointerEvents: [UserQueryTaskEvent],
- threadID: String,
- taskID: String
+ _ pointerEvents: [UserQueryConversationEvent],
+ conversationID: String,
+ agentID: String
) async {
- let existingIDs = Set(await threadStore.events(threadID: threadID).map(\.id))
+ let existingIDs = Set(await conversationStore.events(conversationID: conversationID).map(\.id))
for event in pointerEvents where !existingIDs.contains(event.id) {
- await threadStore.appendEvent(
- HarnessThreadEvent(
+ await conversationStore.appendEvent(
+ HarnessConversationEvent(
id: event.id,
- threadID: threadID,
- taskID: taskID,
- role: HarnessThreadEventRole(userQueryRole: event.role),
+ conversationID: conversationID,
+ agentID: agentID,
+ role: HarnessConversationEventRole(userQueryRole: event.role),
text: event.text,
sequence: event.sequence,
createdAt: event.createdAt,
@@ -282,17 +282,17 @@ public struct AppHarnessGenericLifecycle: Sendable {
}
private func mirrorUserQueryAssets(
- _ pointerAssets: [UserQueryTaskAsset],
- threadID: String,
- taskID: String
+ _ pointerAssets: [UserQueryConversationAsset],
+ conversationID: String,
+ agentID: String
) async {
- let existingIDs = Set(await threadStore.assets(threadID: threadID).map(\.id))
+ let existingIDs = Set(await conversationStore.assets(conversationID: conversationID).map(\.id))
for asset in pointerAssets where !existingIDs.contains(asset.id) {
- await threadStore.appendAsset(
- HarnessThreadAsset(
+ await conversationStore.appendAsset(
+ HarnessConversationAsset(
id: asset.id,
- threadID: threadID,
- taskID: taskID,
+ conversationID: conversationID,
+ agentID: agentID,
eventID: asset.eventID,
displayName: asset.displayName,
contentType: asset.contentType,
@@ -310,21 +310,21 @@ public struct AppHarnessGenericLifecycle: Sendable {
private func appendCurrentTurnIfNeeded(
_ turn: AppHarnessTurn,
- threadID: String,
- taskID: String
+ conversationID: String,
+ agentID: String
) async {
- let events = await threadStore.events(threadID: threadID)
+ let events = await conversationStore.events(conversationID: conversationID)
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(
+ await conversationStore.appendEvent(
+ HarnessConversationEvent(
id: "turn-\(turn.id)",
- threadID: threadID,
- taskID: taskID,
+ conversationID: conversationID,
+ agentID: agentID,
role: .user,
text: turn.text,
sequence: (events.map(\.sequence).max() ?? -1) + 1,
@@ -339,8 +339,8 @@ public struct AppHarnessGenericLifecycle: Sendable {
}
-private extension HarnessThreadEventRole {
- init(userQueryRole: UserQueryTaskEventRole) {
+private extension HarnessConversationEventRole {
+ init(userQueryRole: UserQueryConversationEventRole) {
switch userQueryRole {
case .user:
self = .user
diff --git a/apps/Donkey/Sources/DonkeyRuntime/AppHarnessTurnRequest.swift b/apps/Donkey/Sources/DonkeyRuntime/AppHarnessTurnRequest.swift
index b8abc524..439c7129 100644
--- a/apps/Donkey/Sources/DonkeyRuntime/AppHarnessTurnRequest.swift
+++ b/apps/Donkey/Sources/DonkeyRuntime/AppHarnessTurnRequest.swift
@@ -3,16 +3,16 @@ import Foundation
public struct AppHarnessTurnRequest: Equatable, Sendable {
public var turn: AppHarnessTurn
- public var recentEvents: [UserQueryTaskEvent]
- public var assets: [UserQueryTaskAsset]
+ public var recentEvents: [UserQueryConversationEvent]
+ public var assets: [UserQueryConversationAsset]
public var targetState: [String: String]
public var memory: [String]
public var policy: [String: String]
public init(
turn: AppHarnessTurn,
- recentEvents: [UserQueryTaskEvent] = [],
- assets: [UserQueryTaskAsset] = [],
+ recentEvents: [UserQueryConversationEvent] = [],
+ assets: [UserQueryConversationAsset] = [],
targetState: [String: String] = [:],
memory: [String] = [],
policy: [String: String] = [:]
diff --git a/apps/Donkey/Sources/DonkeyRuntime/ThreadTranscript.swift b/apps/Donkey/Sources/DonkeyRuntime/ConversationTranscript.swift
similarity index 95%
rename from apps/Donkey/Sources/DonkeyRuntime/ThreadTranscript.swift
rename to apps/Donkey/Sources/DonkeyRuntime/ConversationTranscript.swift
index acd3e1f5..86ff4c94 100644
--- a/apps/Donkey/Sources/DonkeyRuntime/ThreadTranscript.swift
+++ b/apps/Donkey/Sources/DonkeyRuntime/ConversationTranscript.swift
@@ -9,9 +9,9 @@ import Foundation
/// Durable metadata stays in Core Data; the *contents* live here in markdown, one folder per thread
/// under `~/Library/Application Support/Donkey/Threads/<id>/`:
///
-/// - `thread.md` — the full conversation, appended live (`tail -f` to watch it unfold).
+/// - `conversation.md` — the full conversation, appended live (`tail -f` to watch it unfold).
/// - `summary.md` — a compacted, structured summary of the thread.
-public final class ThreadTranscript: @unchecked Sendable {
+public final class ConversationTranscript: @unchecked Sendable {
/// Who a flat entry is from.
public enum Role: String, Sendable {
case user
@@ -28,7 +28,7 @@ public final class ThreadTranscript: @unchecked Sendable {
}
public let directory: URL
- private let threadURL: URL
+ private let conversationURL: URL
private let summaryURL: URL
private let lock = NSLock()
private let started = Date()
@@ -36,24 +36,24 @@ public final class ThreadTranscript: @unchecked Sendable {
public static func defaultRoot() -> URL {
FileManager.default.urls(for: .applicationSupportDirectory, in: .userDomainMask)[0]
.appendingPathComponent("Donkey", isDirectory: true)
- .appendingPathComponent("Threads", isDirectory: true)
+ .appendingPathComponent("Conversations", isDirectory: true)
}
public init(id: String, root: URL? = nil) {
let base = (root ?? Self.defaultRoot()).appendingPathComponent(Self.slug(id), isDirectory: true)
try? FileManager.default.createDirectory(at: base, withIntermediateDirectories: true)
self.directory = base
- self.threadURL = base.appendingPathComponent("thread.md")
+ self.conversationURL = base.appendingPathComponent("conversation.md")
self.summaryURL = base.appendingPathComponent("summary.md")
}
- public var threadPath: String { threadURL.path }
+ public var conversationPath: String { conversationURL.path }
/// Start the thread file with its header (only written once; later turns append).
public func begin(id: String, app: String) {
- guard !FileManager.default.fileExists(atPath: threadURL.path) else { return }
+ guard !FileManager.default.fileExists(atPath: conversationURL.path) else { return }
let header = """
- # Thread \(id)
+ # Conversation \(id)
- **App:** \(app.isEmpty ? "(system tools / none)" : app)
- **Started:** \(Self.stamp(started))
@@ -223,12 +223,12 @@ public final class ThreadTranscript: @unchecked Sendable {
private func write(_ text: String, append: Bool) {
lock.lock(); defer { lock.unlock() }
- if append, let handle = try? FileHandle(forWritingTo: threadURL) {
+ if append, let handle = try? FileHandle(forWritingTo: conversationURL) {
handle.seekToEndOfFile()
handle.write(Data(text.utf8))
try? handle.close()
} else {
- try? text.write(to: threadURL, atomically: true, encoding: .utf8)
+ try? text.write(to: conversationURL, atomically: true, encoding: .utf8)
}
}
diff --git a/apps/Donkey/Sources/DonkeyRuntime/DonkeyCommandBackends.swift b/apps/Donkey/Sources/DonkeyRuntime/DonkeyCommandBackends.swift
index 96a62dc1..27cb017c 100644
--- a/apps/Donkey/Sources/DonkeyRuntime/DonkeyCommandBackends.swift
+++ b/apps/Donkey/Sources/DonkeyRuntime/DonkeyCommandBackends.swift
@@ -596,7 +596,7 @@ public enum DonkeyCommandBackends {
allowed = await store.isAlwaysAllowed(signature)
}
if !allowed {
- allowed = await store.consumeOnce(taskID: context.taskID, signature: signature)
+ allowed = await store.consumeOnce(agentID: context.agentID, signature: signature)
}
if allowed { return nil }
diff --git a/apps/Donkey/Sources/DonkeyRuntime/HarnessTurnTrace.swift b/apps/Donkey/Sources/DonkeyRuntime/HarnessTurnTrace.swift
index 7091a292..8548eb04 100644
--- a/apps/Donkey/Sources/DonkeyRuntime/HarnessTurnTrace.swift
+++ b/apps/Donkey/Sources/DonkeyRuntime/HarnessTurnTrace.swift
@@ -5,7 +5,7 @@ import Foundation
/// run's whole decision path — what was sent to the model, what came back, which sensing modality each
/// step used, and where the time went — is traceable in the thread file.
///
-/// It owns no file of its own; it renders through the turn's `ThreadTranscript` (kept as the sole
+/// It owns no file of its own; it renders through the turn's `ConversationTranscript` (kept as the sole
/// writer of `thread.md`) and adds the timing the transcript can't see on its own. The model boundaries
/// hold this as `any HarnessTurnTracing` and only `recordModelCall`; the command handler holds the
/// concrete type and additionally drives `recordStep` / `recordTurnTiming`.
@@ -15,11 +15,11 @@ import Foundation
/// One-shot calls (understanding, the background summary) are recorded for visibility but never counted
/// toward a step, so they can't inflate the next step's timing.
///
-/// Concurrency mirrors `ThreadTranscript`: a `final class` with an `NSLock` guarding the small timing
+/// Concurrency mirrors `ConversationTranscript`: a `final class` with an `NSLock` guarding the small timing
/// accumulator, so it's callable synchronously from the planner's hot path and from the `@MainActor`
/// step callback without actor hops.
public final class HarnessTurnTrace: HarnessTurnTracing, @unchecked Sendable {
- private let transcript: ThreadTranscript
+ private let transcript: ConversationTranscript
private let now: @Sendable () -> RunTraceTimestamp
private let lock = NSLock()
@@ -32,7 +32,7 @@ public final class HarnessTurnTrace: HarnessTurnTracing, @unchecked Sendable {
/// `now` is the clock used to stamp when a step lands (for tool-time); it defaults to the real
/// wall+monotonic clock and is injectable so tests can drive deterministic durations.
public init(
- transcript: ThreadTranscript,
+ transcript: ConversationTranscript,
now: @escaping @Sendable () -> RunTraceTimestamp = RunTraceTimestamp.now
) {
self.transcript = transcript
@@ -126,7 +126,7 @@ public final class HarnessTurnTrace: HarnessTurnTracing, @unchecked Sendable {
switch kind {
case .understanding: return "understanding"
case .plannerStep: return "planner step"
- case .threadSummary: return "thread summary"
+ case .conversationSummary: return "thread summary"
}
}
diff --git a/apps/Donkey/Sources/DonkeyRuntime/LocalAppUserQueryHarnessServices.swift b/apps/Donkey/Sources/DonkeyRuntime/LocalAppUserQueryHarnessServices.swift
index b4cffdf7..33b76ba1 100644
--- a/apps/Donkey/Sources/DonkeyRuntime/LocalAppUserQueryHarnessServices.swift
+++ b/apps/Donkey/Sources/DonkeyRuntime/LocalAppUserQueryHarnessServices.swift
@@ -106,8 +106,8 @@ public enum LocalAppUserQueryHarnessServices {
?? context.call.input["entityValue"]
?? ""
let command = ActionEngineCommand(
- id: "\(context.taskID)-\(artifact.id)",
- traceID: context.call.metadata["traceID"] ?? context.taskID,
+ id: "\(context.agentID)-\(artifact.id)",
+ traceID: context.call.metadata["traceID"] ?? context.agentID,
targetID: context.call.input["targetID"] ?? artifact.ownerSkillID ?? artifact.id,
kind: .controller,
issuedAt: now(),
diff --git a/apps/Donkey/Sources/DonkeyRuntime/ShellPermissionPolicyStore.swift b/apps/Donkey/Sources/DonkeyRuntime/ShellPermissionPolicyStore.swift
index 240060ed..a7079479 100644
--- a/apps/Donkey/Sources/DonkeyRuntime/ShellPermissionPolicyStore.swift
+++ b/apps/Donkey/Sources/DonkeyRuntime/ShellPermissionPolicyStore.swift
@@ -16,7 +16,7 @@ public actor 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.
+ /// One-shot grants keyed `"agentID\u{1}signature"`, consumed on first use.
private var onceGrants: Set<String> = []
public init(storeURL: URL? = nil) {
@@ -62,22 +62,22 @@ public actor ShellPermissionPolicyStore {
// MARK: - Allow-once (transient)
- public func grantOnce(taskID: String, signature: String) {
+ public func grantOnce(agentID: String, signature: String) {
guard !signature.isEmpty else { return }
- onceGrants.insert(Self.onceKey(taskID: taskID, signature: signature))
+ onceGrants.insert(Self.onceKey(agentID: agentID, 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)
+ public func consumeOnce(agentID: String, signature: String) -> Bool {
+ let key = Self.onceKey(agentID: agentID, 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)"
+ private static func onceKey(agentID: String, signature: String) -> String {
+ "\(agentID)\u{1}\(signature)"
}
// MARK: - Persistence
diff --git a/apps/Donkey/Sources/DonkeyUI/UserQueryNotchStatusView.swift b/apps/Donkey/Sources/DonkeyUI/UserQueryNotchStatusView.swift
index 14747ca5..532d1618 100644
--- a/apps/Donkey/Sources/DonkeyUI/UserQueryNotchStatusView.swift
+++ b/apps/Donkey/Sources/DonkeyUI/UserQueryNotchStatusView.swift
@@ -26,8 +26,8 @@ public struct UserQueryNotchStatusView: View {
@Binding private var commandText: String
private let commandInputTextHeight: CGFloat
private let isCommandInputExpanded: Bool
- private let tasks: [UserQueryNotchTask]
- private let surfacedTasks: [UserQueryNotchTask]
+ private let tasks: [UserQueryConversation]
+ private let surfacedTasks: [UserQueryConversation]
/// While the user is replying to a specific task (tapped Reply), this is that task; the expanded
/// panel dims every other row so it's clear the next message continues this one thread.
private let replyTargetTaskID: String?
@@ -39,7 +39,7 @@ public struct UserQueryNotchStatusView: View {
private let commandSubmitted: @MainActor (String) -> Void
private let commandInputTextHeightChanged: @MainActor (CGFloat) -> Void
private let commandInputExpansionChanged: @MainActor (Bool) -> Void
- private let assetsDropped: @MainActor ([UserQueryTaskAssetDraft]) -> Void
+ private let assetsDropped: @MainActor ([UserQueryConversationAssetDraft]) -> Void
private let pauseRequested: @MainActor (String) -> Void
private let resumeRequested: @MainActor (String) -> Void
private let dismissRequested: @MainActor (String) -> Void
@@ -49,7 +49,7 @@ public struct UserQueryNotchStatusView: View {
private let replyRequested: @MainActor (String) -> Void
/// Tapping the notch chrome outside a row, control, or the composer while replying leaves reply mode.
private let replyModeExited: @MainActor () -> Void
- /// (taskID, alwaysAllow). `alwaysAllow` persists a standing rule for the
+ /// (conversationID, alwaysAllow). `alwaysAllow` persists a standing rule for the
/// command signature; it is only offered for non-highRisk shell consent.
private let approvePermissionRequested: @MainActor (String, Bool) -> Void
private let denyPermissionRequested: @MainActor (String) -> Void
@@ -74,8 +74,8 @@ public struct UserQueryNotchStatusView: View {
commandText: Binding<String>,
commandInputTextHeight: CGFloat,
isCommandInputExpanded: Bool,
- tasks: [UserQueryNotchTask] = [],
- surfacedTasks: [UserQueryNotchTask] = [],
+ tasks: [UserQueryConversation] = [],
+ surfacedTasks: [UserQueryConversation] = [],
replyTargetTaskID: String? = nil,
selectedTaskID: String? = nil,
accentIndex: Int,
@@ -83,7 +83,7 @@ public struct UserQueryNotchStatusView: View {
commandSubmitted: @escaping @MainActor (String) -> Void,
commandInputTextHeightChanged: @escaping @MainActor (CGFloat) -> Void,
commandInputExpansionChanged: @escaping @MainActor (Bool) -> Void,
- assetsDropped: @escaping @MainActor ([UserQueryTaskAssetDraft]) -> Void,
+ assetsDropped: @escaping @MainActor ([UserQueryConversationAssetDraft]) -> Void,
pauseRequested: @escaping @MainActor (String) -> Void,
resumeRequested: @escaping @MainActor (String) -> Void,
dismissRequested: @escaping @MainActor (String) -> Void,
@@ -437,7 +437,7 @@ public struct UserQueryNotchStatusView: View {
/// the task's `detail` carries the reply (set to `result.summary` on completion), so the chin shows
/// the response. A failure is flagged by the red warning icon in the right rail (see
/// `collapsedRightSlot`), not inline here.
- private func chinLine(for task: UserQueryNotchTask) -> some View {
+ private func chinLine(for task: UserQueryConversation) -> some View {
Text(chinText(for: task))
.font(.system(size: Self.chinFontSize, weight: .regular))
.foregroundStyle(Color.white.opacity(0.72))
@@ -445,7 +445,7 @@ public struct UserQueryNotchStatusView: View {
.truncationMode(.tail)
}
- private func chinText(for task: UserQueryNotchTask) -> String {
+ private func chinText(for task: UserQueryConversation) -> String {
task.chinDisplayText
}
@@ -454,7 +454,7 @@ public struct UserQueryNotchStatusView: View {
/// clock is anchored to the newest task's start, so a freshly added task shows first (the view
/// re-renders on the task change) and then yields to the others. When nothing is running, the most
/// recent undismissed completion keeps narrating its result instead of leaving the chin empty.
- private func rotatingChinTask(at date: Date) -> UserQueryNotchTask? {
+ private func rotatingChinTask(at date: Date) -> UserQueryConversation? {
if let errored = surfacedTasks.first(where: { $0.status == .failed }) {
return errored
}
@@ -730,8 +730,8 @@ public struct UserQueryNotchStatusView: View {
.clipShape(RoundedRectangle(cornerRadius: 8, style: .continuous))
.contentShape(RoundedRectangle(cornerRadius: 8, style: .continuous))
.onTapGesture {
- if let taskID = primaryTask?.id {
- taskSelected(taskID)
+ if let conversationID = primaryTask?.id {
+ taskSelected(conversationID)
}
}
}
@@ -764,14 +764,14 @@ public struct UserQueryNotchStatusView: View {
/// Trailing room a row's text leaves for the pinned top-right controls, by control set: a lone Close
/// (or Stop) button, or a Resume + Close pair. Permission rows carry their own banner controls.
- private func controlsReserve(for task: UserQueryNotchTask) -> CGFloat {
+ private func controlsReserve(for task: UserQueryConversation) -> CGFloat {
if task.status == .waitingForPermission { return 0 }
return rowShowsControlPair(task) ? 74 : 44
}
/// Whether a row shows a two-button pair (Resume + Close, or Reply + Close) vs a single Close/Stop —
/// mirrors `stateControls`, so the title/subtext reserve the right trailing room for the controls.
- private func rowShowsControlPair(_ task: UserQueryNotchTask) -> Bool {
+ private func rowShowsControlPair(_ task: UserQueryConversation) -> Bool {
switch task.status {
case .paused, .interrupted, .timedOut, .waitingForClarification, .waitingForReview:
return true
@@ -787,7 +787,7 @@ public struct UserQueryNotchStatusView: View {
/// Full opacity normally; while a reply is targeted, every row except the targeted one dims back so
/// the user sees which thread their next message answers.
- private func rowReplyDimOpacity(for task: UserQueryNotchTask) -> Double {
+ private func rowReplyDimOpacity(for task: UserQueryConversation) -> Double {
guard let replyTargetTaskID else { return 1 }
return task.id == replyTargetTaskID ? 1 : 0.5
}
@@ -796,11 +796,11 @@ public struct UserQueryNotchStatusView: View {
/// row dims for a reply, so every thread still waiting on the user reads at a glance. Broader than
/// `isAwaitingUserResponse` (which gates the Reply button): a permission request also waits on the
/// user and pulses for attention, but is answered with Approve / Deny rather than Reply.
- private func isWaitingOnUser(_ task: UserQueryNotchTask) -> Bool {
+ private func isWaitingOnUser(_ task: UserQueryConversation) -> Bool {
task.status.isAwaitingUserResponse || task.status == .waitingForPermission
}
- private func taskRow(_ task: UserQueryNotchTask) -> some View {
+ private func taskRow(_ task: UserQueryConversation) -> some View {
let isPermission = task.status == .waitingForPermission
// The reply dim is applied per-element rather than to the whole row so the pointer of a task that
// itself needs the user can stay lit while everything else recedes.
@@ -912,7 +912,7 @@ public struct UserQueryNotchStatusView: View {
/// Controls pinned to the row's top-right. Like the prototype, every task carries a real control:
/// running → stop; paused → resume + close; everything else → close, so any task can be deleted.
@ViewBuilder
- private func topRightControls(_ task: UserQueryNotchTask) -> some View {
+ private func topRightControls(_ task: UserQueryConversation) -> some View {
switch task.status {
case .waitingForPermission:
// The permission banner carries its own Approve / Deny; the row needs no extra control.
@@ -923,7 +923,7 @@ public struct UserQueryNotchStatusView: View {
}
@ViewBuilder
- private func stateControls(for task: UserQueryNotchTask) -> some View {
+ private func stateControls(for task: UserQueryConversation) -> some View {
switch task.status {
case .running:
// Stop = pause (same affordance the prototype uses for a running task).
@@ -954,7 +954,7 @@ public struct UserQueryNotchStatusView: View {
}
@ViewBuilder
- private func resumeAndCloseControls(for task: UserQueryNotchTask) -> some View {
+ private func resumeAndCloseControls(for task: UserQueryConversation) -> some View {
HStack(spacing: 6) {
NotchControlButton(systemName: "play.fill", label: "Resume", isEnabled: true) {
resumeRequested(task.id)
@@ -968,7 +968,7 @@ public struct UserQueryNotchStatusView: View {
/// A task waiting on the user gets Reply (answer the clarification / respond to the review) + Close.
/// Reply pins the composer to this task and focuses the input; the user's next message answers it.
@ViewBuilder
- private func replyAndCloseControls(for task: UserQueryNotchTask) -> some View {
+ private func replyAndCloseControls(for task: UserQueryConversation) -> some View {
HStack(spacing: 6) {
NotchTextButton(label: "Reply", isEnabled: true) {
replyRequested(task.id)
@@ -979,7 +979,7 @@ public struct UserQueryNotchStatusView: View {
}
}
- private func closeControl(for task: UserQueryNotchTask) -> some View {
+ private func closeControl(for task: UserQueryConversation) -> some View {
NotchControlButton(systemName: "xmark", label: "Close", isEnabled: true) {
dismissRequested(task.id)
}
@@ -988,7 +988,7 @@ public struct UserQueryNotchStatusView: View {
/// Live ticking time while running; a frozen total once the task has stopped or finished. Both use
/// the prototype's row time style (10px, 55% white) so every row's time matches regardless of status.
@ViewBuilder
- private func taskElapsedLabel(_ task: UserQueryNotchTask) -> some View {
+ private func taskElapsedLabel(_ task: UserQueryConversation) -> some View {
if task.status == .running {
TimelineView(.periodic(from: task.createdAt, by: 1)) { context in
taskElapsedText(Self.elapsedDescription(from: task.createdAt, to: context.date))
@@ -1009,7 +1009,7 @@ public struct UserQueryNotchStatusView: View {
/// A permission request banner below the task text: the request reads on the left, Approve / Deny
/// on the right. The system permission is only requested once the user taps Approve; Deny stops
/// the task — the harness never reaches the system without the user's go-ahead.
- private func permissionBanner(for task: UserQueryNotchTask) -> some View {
+ private func permissionBanner(for task: UserQueryConversation) -> some View {
HStack(spacing: 8) {
Text(permissionRequestText(task))
.font(.system(size: 12, weight: .regular))
@@ -1034,13 +1034,13 @@ public struct UserQueryNotchStatusView: View {
/// Whether this task failed for lack of credits and should show the reload CTA. Read from the typed
/// metadata flag the harness sets — never inferred from the narration text.
- private func showsReloadCreditsBanner(_ task: UserQueryNotchTask) -> Bool {
- task.metadata[UserQueryTaskMetadataKey.creditReloadRequired] == "true"
+ private func showsReloadCreditsBanner(_ task: UserQueryConversation) -> Bool {
+ task.metadata[UserQueryConversationMetadataKey.creditReloadRequired] == "true"
}
/// A reload CTA on a credit-exhausted task. Reuses the permission banner's button styling; tapping
/// it opens the billing page so the user can top up, then re-run the task (Close is still on the row).
- private func reloadCreditsBanner(for task: UserQueryNotchTask) -> some View {
+ private func reloadCreditsBanner(for task: UserQueryConversation) -> some View {
HStack(spacing: 8) {
Image(systemName: "creditcard")
.font(.system(size: 12, weight: .regular))
@@ -1068,7 +1068,7 @@ public struct UserQueryNotchStatusView: View {
/// What the user is actually approving — named by the concrete action, never the word "tools".
/// Prefers the shell command being requested, falls back to the gate's own reason, and never
/// surfaces the runtime's internal "stopped" placeholder.
- private func permissionRequestText(_ task: UserQueryNotchTask) -> String {
+ private func permissionRequestText(_ task: UserQueryConversation) -> String {
if let command = task.metadata["genericHarness.shellConsent.command"]?
.trimmingCharacters(in: .whitespacesAndNewlines), !command.isEmpty {
return "Allow Donkey to run \(command)"
@@ -1272,7 +1272,7 @@ public struct UserQueryNotchStatusView: View {
}
/// The surfaced failure currently holding the chin, if any — drives the right-rail warning glyph.
- private var surfacedErrorTask: UserQueryNotchTask? {
+ private var surfacedErrorTask: UserQueryConversation? {
surfacedTasks.first { $0.status == .failed }
}
@@ -1334,14 +1334,14 @@ public struct UserQueryNotchStatusView: View {
accentColor(for: primaryTask?.accentIndex ?? accentIndex)
}
- private var primaryTask: UserQueryNotchTask? {
+ private var primaryTask: UserQueryConversation? {
tasks.first
}
/// The task's status line, resolved through the centralized activity vocabulary so the notch and
/// the future conversation view speak the same language.
- private func taskStatusDescription(_ task: UserQueryNotchTask) -> String {
+ private func taskStatusDescription(_ task: UserQueryConversation) -> String {
UserQueryActivity.current(for: task).displayText
}
@@ -1674,15 +1674,15 @@ private struct DonkeyCursorMark: View {
private final class DroppedAssetCollector: @unchecked Sendable {
private let lock = NSLock()
- private var drafts: [UserQueryTaskAssetDraft] = []
+ private var drafts: [UserQueryConversationAssetDraft] = []
- func append(_ draft: UserQueryTaskAssetDraft) {
+ func append(_ draft: UserQueryConversationAssetDraft) {
lock.lock()
drafts.append(draft)
lock.unlock()
}
- func values() -> [UserQueryTaskAssetDraft] {
+ func values() -> [UserQueryConversationAssetDraft] {
lock.lock()
let snapshot = drafts
lock.unlock()
@@ -1711,7 +1711,7 @@ private enum DroppedAssetUtilities {
return nil
}
- static func assetDraft(for url: URL) -> UserQueryTaskAssetDraft? {
+ static func assetDraft(for url: URL) -> UserQueryConversationAssetDraft? {
guard url.isFileURL else { return nil }
let contentType = (try? url.resourceValues(forKeys: [.contentTypeKey]).contentType?.preferredMIMEType)
@@ -1719,7 +1719,7 @@ private enum DroppedAssetUtilities {
?? "application/octet-stream"
let attributes = try? FileManager.default.attributesOfItem(atPath: url.path)
let byteCount = (attributes?[.size] as? NSNumber)?.int64Value
- return UserQueryTaskAssetDraft(
+ return UserQueryConversationAssetDraft(
displayName: url.lastPathComponent,
contentType: contentType,
urlString: url.absoluteString,
diff --git a/apps/Donkey/Sources/DonkeyUI/UserQuerySpawnOverlayView.swift b/apps/Donkey/Sources/DonkeyUI/UserQuerySpawnOverlayView.swift
index 69637124..4bf0fa64 100644
--- a/apps/Donkey/Sources/DonkeyUI/UserQuerySpawnOverlayView.swift
+++ b/apps/Donkey/Sources/DonkeyUI/UserQuerySpawnOverlayView.swift
@@ -422,7 +422,7 @@ public final class UserQuerySpawnOverlayViewModel: ObservableObject {
public func beginInlineInput() {
guard let state,
- state.taskID != nil,
+ state.conversationID != nil,
!isLabelEditing else {
select()
return
@@ -460,7 +460,7 @@ public final class UserQuerySpawnOverlayViewModel: ObservableObject {
let trimmedText = draftText.trimmingCharacters(in: .whitespacesAndNewlines)
guard !trimmedText.isEmpty,
- let taskID = state.taskID else {
+ let conversationID = state.conversationID else {
cancelInlineInput()
return
}
@@ -470,7 +470,7 @@ public final class UserQuerySpawnOverlayViewModel: ObservableObject {
isLabelEditing = false
labelLayoutChanged?()
labelEditingChanged?(false)
- followUpSubmitted?(state.id, taskID, trimmedText)
+ followUpSubmitted?(state.id, conversationID, trimmedText)
}
public func updateDraftTextHeight(_ height: CGFloat) {
diff --git a/apps/Donkey/Tests/DonkeyRuntimeTests/AIHarnessAdapterTests.swift b/apps/Donkey/Tests/DonkeyRuntimeTests/AIHarnessAdapterTests.swift
index 12597299..cc4a77e3 100644
--- a/apps/Donkey/Tests/DonkeyRuntimeTests/AIHarnessAdapterTests.swift
+++ b/apps/Donkey/Tests/DonkeyRuntimeTests/AIHarnessAdapterTests.swift
@@ -215,7 +215,7 @@ struct AIHarnessAdapterTests {
@Test
func hostedFollowUpResolverLetsBackendSelectResponsesModel() async throws {
let httpClient = FakeAIHTTPClient(
- data: Data(#"{"output_text":"{\"isFollowUp\":true,\"taskID\":\"task-1\",\"confidence\":0.82,\"reason\":\"same task\"}"}"#.utf8),
+ data: Data(#"{"output_text":"{\"isFollowUp\":true,\"agentID\":\"task-1\",\"confidence\":0.82,\"reason\":\"same task\"}"}"#.utf8),
statusCode: 200
)
let resolver = HostedTaskFollowUpResolver(
@@ -231,7 +231,7 @@ struct AIHarnessAdapterTests {
text: "add that to it",
candidates: [
UserQueryFollowUpCandidate(
- taskID: "task-1",
+ conversationID: "task-1",
title: "Draft note",
detail: "Writing a note",
commandText: "write a note",
@@ -243,7 +243,7 @@ struct AIHarnessAdapterTests {
)
)
- #expect(result.taskID == "task-1")
+ #expect(result.conversationID == "task-1")
#expect(result.trace.provider == .donkeyBackend)
#expect(result.trace.modelID == AIModelRegistryEntry.backendSelectedModelID)
diff --git a/apps/Donkey/Tests/DonkeyRuntimeTests/AppCommandsCommandTests.swift b/apps/Donkey/Tests/DonkeyRuntimeTests/AppCommandsCommandTests.swift
index eba33bd5..310aecbe 100644
--- a/apps/Donkey/Tests/DonkeyRuntimeTests/AppCommandsCommandTests.swift
+++ b/apps/Donkey/Tests/DonkeyRuntimeTests/AppCommandsCommandTests.swift
@@ -10,7 +10,7 @@ struct AppCommandsCommandTests {
private func run(_ input: [String: String]) async -> HarnessToolResult? {
let descriptor = DonkeyCommandLayer.descriptors.first { $0.name == "app_commands" }!
let context = HarnessToolExecutionContext(
- taskID: "test",
+ agentID: "test",
call: HarnessToolCall(name: "app_commands", input: input),
descriptor: descriptor,
worldModel: HarnessWorldModel(),
diff --git a/apps/Donkey/Tests/DonkeyRuntimeTests/AppSkillCommandTests.swift b/apps/Donkey/Tests/DonkeyRuntimeTests/AppSkillCommandTests.swift
index 6cc4b9cc..022848f0 100644
--- a/apps/Donkey/Tests/DonkeyRuntimeTests/AppSkillCommandTests.swift
+++ b/apps/Donkey/Tests/DonkeyRuntimeTests/AppSkillCommandTests.swift
@@ -10,7 +10,7 @@ struct AppSkillCommandTests {
private func lookup(_ app: String) async -> HarnessToolResult? {
let descriptor = DonkeyCommandLayer.descriptors.first { $0.name == "app_skill" }!
let context = HarnessToolExecutionContext(
- taskID: "test",
+ agentID: "test",
call: HarnessToolCall(name: "app_skill", input: ["app": app]),
descriptor: descriptor,
worldModel: HarnessWorldModel(),
@@ -91,7 +91,7 @@ struct AppSkillCommandTests {
let descriptor = DonkeyCommandLayer.descriptors.first { $0.name == "skill_run" }!
func run(_ input: [String: String]) async -> HarnessToolResult? {
await DonkeyCommandBackends.makeExecutor()(HarnessToolExecutionContext(
- taskID: "test",
+ agentID: "test",
call: HarnessToolCall(name: "skill_run", input: input),
descriptor: descriptor,
worldModel: HarnessWorldModel(),
diff --git a/apps/Donkey/Tests/DonkeyRuntimeTests/AppleScriptCompileGateTests.swift b/apps/Donkey/Tests/DonkeyRuntimeTests/AppleScriptCompileGateTests.swift
index e673d3e7..36d45e26 100644
--- a/apps/Donkey/Tests/DonkeyRuntimeTests/AppleScriptCompileGateTests.swift
+++ b/apps/Donkey/Tests/DonkeyRuntimeTests/AppleScriptCompileGateTests.swift
@@ -38,7 +38,7 @@ struct AppleScriptCompileGateTests {
"goal": "do the thing"
]
),
- taskID: "task-compile-gate",
+ agentID: "task-compile-gate",
worldModel: HarnessWorldModel(),
grantedPermissions: [.appLookup]
)
@@ -55,7 +55,7 @@ struct AppleScriptCompileGateTests {
name: "automation.applescript.validate",
input: ["scriptArtifactID": artifactID, "targetApp": targetApp]
),
- taskID: "task-compile-gate",
+ agentID: "task-compile-gate",
worldModel: HarnessWorldModel(),
grantedPermissions: [.appLookup]
)
@@ -245,7 +245,7 @@ struct AppleScriptCompileGateTests {
"scriptSource": #"tell application "Music" to play track "{query}""#
]
),
- taskID: "task-template",
+ agentID: "task-template",
worldModel: HarnessWorldModel(),
grantedPermissions: [.skillLookup]
)
@@ -255,7 +255,7 @@ struct AppleScriptCompileGateTests {
name: "skill.script.validate",
input: ["scriptID": "play-template", "targetApp": "Music"]
),
- taskID: "task-template",
+ agentID: "task-template",
worldModel: HarnessWorldModel(),
grantedPermissions: [.skillLookup]
)
diff --git a/apps/Donkey/Tests/DonkeyRuntimeTests/AppleScriptPromotionTests.swift b/apps/Donkey/Tests/DonkeyRuntimeTests/AppleScriptPromotionTests.swift
index 364b8fc5..5c50d01a 100644
--- a/apps/Donkey/Tests/DonkeyRuntimeTests/AppleScriptPromotionTests.swift
+++ b/apps/Donkey/Tests/DonkeyRuntimeTests/AppleScriptPromotionTests.swift
@@ -57,7 +57,7 @@ struct AppleScriptPromotionTests {
"goal": "create the Groceries note"
]
),
- taskID: "task-promotion",
+ agentID: "task-promotion",
worldModel: HarnessWorldModel(),
grantedPermissions: [.appLookup]
)
@@ -67,7 +67,7 @@ struct AppleScriptPromotionTests {
name: "automation.applescript.validate",
input: ["scriptArtifactID": artifactID, "targetApp": "Notes"]
),
- taskID: "task-promotion",
+ agentID: "task-promotion",
worldModel: HarnessWorldModel(),
grantedPermissions: [.appLookup]
)
@@ -77,7 +77,7 @@ struct AppleScriptPromotionTests {
name: "automation.applescript.execute",
input: ["scriptArtifactID": artifactID, "targetApp": "Notes"]
),
- taskID: "task-promotion",
+ agentID: "task-promotion",
worldModel: HarnessWorldModel(),
grantedPermissions: [.appControl, .input]
)
@@ -213,7 +213,7 @@ struct AppleScriptPromotionTests {
name: "skill.script.execute",
input: ["scriptID": "builtin-script"]
),
- taskID: "task-builtin",
+ agentID: "task-builtin",
worldModel: HarnessWorldModel(),
grantedPermissions: [.appControl, .input]
)
diff --git a/apps/Donkey/Tests/DonkeyRuntimeTests/ThreadTranscriptTests.swift b/apps/Donkey/Tests/DonkeyRuntimeTests/ConversationTranscriptTests.swift
similarity index 94%
rename from apps/Donkey/Tests/DonkeyRuntimeTests/ThreadTranscriptTests.swift
rename to apps/Donkey/Tests/DonkeyRuntimeTests/ConversationTranscriptTests.swift
index 109884a4..aa3d7917 100644
--- a/apps/Donkey/Tests/DonkeyRuntimeTests/ThreadTranscriptTests.swift
+++ b/apps/Donkey/Tests/DonkeyRuntimeTests/ConversationTranscriptTests.swift
@@ -3,7 +3,7 @@ import Testing
@testable import DonkeyRuntime
@Suite
-struct ThreadTranscriptTests {
+struct ConversationTranscriptTests {
@Test
func stepRendersDecisionThenOutputAsOneBlock() throws {
let transcript = makeTranscript()
@@ -107,7 +107,7 @@ struct ThreadTranscriptTests {
transcript.response("Done — playlist created.")
let text = try threadText(transcript)
- #expect(text.contains("# Thread T1"))
+ #expect(text.contains("# Conversation T1"))
#expect(text.contains("👤 user · message"))
#expect(text.contains("create a playlist"))
#expect(text.contains("⚙️ system · event"))
@@ -179,13 +179,13 @@ struct ThreadTranscriptTests {
#expect(text.contains("\"tool\":\"ax.observe\""))
}
- private func makeTranscript() -> ThreadTranscript {
+ private func makeTranscript() -> ConversationTranscript {
let root = FileManager.default.temporaryDirectory
.appendingPathComponent("thread-transcript-tests-\(UUID().uuidString)", isDirectory: true)
- return ThreadTranscript(id: UUID().uuidString, root: root)
+ return ConversationTranscript(id: UUID().uuidString, root: root)
}
- private func threadText(_ transcript: ThreadTranscript) throws -> String {
- try String(contentsOfFile: transcript.threadPath, encoding: .utf8)
+ private func threadText(_ transcript: ConversationTranscript) throws -> String {
+ try String(contentsOfFile: transcript.conversationPath, encoding: .utf8)
}
}
diff --git a/apps/Donkey/Tests/DonkeyRuntimeTests/DictionaryGroundedAppleScriptTests.swift b/apps/Donkey/Tests/DonkeyRuntimeTests/DictionaryGroundedAppleScriptTests.swift
index 809800f3..d47d1cb1 100644
--- a/apps/Donkey/Tests/DonkeyRuntimeTests/DictionaryGroundedAppleScriptTests.swift
+++ b/apps/Donkey/Tests/DonkeyRuntimeTests/DictionaryGroundedAppleScriptTests.swift
@@ -48,7 +48,7 @@ struct DictionaryGroundedAppleScriptTests {
"goal": "create a note"
]
),
- taskID: "task-grounded",
+ agentID: "task-grounded",
worldModel: HarnessWorldModel(),
grantedPermissions: [.appLookup]
)
@@ -88,7 +88,7 @@ struct DictionaryGroundedAppleScriptTests {
"goal": "activate"
]
),
- taskID: "task-ungrounded",
+ agentID: "task-ungrounded",
worldModel: HarnessWorldModel(),
grantedPermissions: [.appLookup]
)
diff --git a/apps/Donkey/Tests/DonkeyRuntimeTests/HarnessStepPromptTests.swift b/apps/Donkey/Tests/DonkeyRuntimeTests/HarnessStepPromptTests.swift
index 8e9151fe..f529959e 100644
--- a/apps/Donkey/Tests/DonkeyRuntimeTests/HarnessStepPromptTests.swift
+++ b/apps/Donkey/Tests/DonkeyRuntimeTests/HarnessStepPromptTests.swift
@@ -6,8 +6,8 @@ import Testing
@Suite
struct HarnessStepPromptTests {
- private func task(goal: String) -> HarnessTaskState {
- HarnessTaskState(id: "t", threadID: "th", goal: goal, status: .running, worldModel: HarnessWorldModel())
+ private func task(goal: String) -> HarnessAgentState {
+ HarnessAgentState(id: "t", conversationID: "th", goal: goal, status: .running, worldModel: HarnessWorldModel())
}
/// The installed-skill catalog must reach the planner prompt verbatim, with routing instructions —
diff --git a/apps/Donkey/Tests/DonkeyRuntimeTests/HarnessTurnTraceTests.swift b/apps/Donkey/Tests/DonkeyRuntimeTests/HarnessTurnTraceTests.swift
index ce919b64..fd96272e 100644
--- a/apps/Donkey/Tests/DonkeyRuntimeTests/HarnessTurnTraceTests.swift
+++ b/apps/Donkey/Tests/DonkeyRuntimeTests/HarnessTurnTraceTests.swift
@@ -143,14 +143,14 @@ struct HarnessTurnTraceTests {
)
}
- private func makeTranscript() -> ThreadTranscript {
+ private func makeTranscript() -> ConversationTranscript {
let root = FileManager.default.temporaryDirectory
.appendingPathComponent("harness-turn-trace-tests-\(UUID().uuidString)", isDirectory: true)
- return ThreadTranscript(id: UUID().uuidString, root: root)
+ return ConversationTranscript(id: UUID().uuidString, root: root)
}
- private func threadText(_ transcript: ThreadTranscript) throws -> String {
- try String(contentsOfFile: transcript.threadPath, encoding: .utf8)
+ private func threadText(_ transcript: ConversationTranscript) throws -> String {
+ try String(contentsOfFile: transcript.conversationPath, encoding: .utf8)
}
}
diff --git a/apps/Donkey/Tests/DonkeyRuntimeTests/HostedHarnessStepPlannerTests.swift b/apps/Donkey/Tests/DonkeyRuntimeTests/HostedHarnessStepPlannerTests.swift
index 945c6293..4374f7cf 100644
--- a/apps/Donkey/Tests/DonkeyRuntimeTests/HostedHarnessStepPlannerTests.swift
+++ b/apps/Donkey/Tests/DonkeyRuntimeTests/HostedHarnessStepPlannerTests.swift
@@ -464,8 +464,8 @@ struct HostedHarnessStepPlannerTests {
)
}
- private func task(goal: String, toolHistory: [HarnessToolCallRecord]) -> HarnessTaskState {
- HarnessTaskState(threadID: "thread-1", goal: goal, toolHistory: toolHistory)
+ private func task(goal: String, toolHistory: [HarnessToolCallRecord]) -> HarnessAgentState {
+ HarnessAgentState(conversationID: "thread-1", goal: goal, toolHistory: toolHistory)
}
private func cannedDecision(tool: String) -> Data {
diff --git a/apps/Donkey/Tests/DonkeyRuntimeTests/MusicPlaybackToolsTests.swift b/apps/Donkey/Tests/DonkeyRuntimeTests/MusicPlaybackToolsTests.swift
index 7b5924aa..f7f68a60 100644
--- a/apps/Donkey/Tests/DonkeyRuntimeTests/MusicPlaybackToolsTests.swift
+++ b/apps/Donkey/Tests/DonkeyRuntimeTests/MusicPlaybackToolsTests.swift
@@ -523,7 +523,7 @@ struct MusicPlaybackToolsTests {
let tools = provider.makeTools()
let harnessTool = tools.first { $0.descriptor.name == tool }!
let context = HarnessToolExecutionContext(
- taskID: "task-1",
+ agentID: "task-1",
call: HarnessToolCall(name: tool, input: input),
descriptor: harnessTool.descriptor,
worldModel: HarnessWorldModel(),
diff --git a/apps/Donkey/Tests/DonkeyRuntimeTests/MusicPlaylistLiveE2ETests.swift b/apps/Donkey/Tests/DonkeyRuntimeTests/MusicPlaylistLiveE2ETests.swift
index 85d6d93f..a7623263 100644
--- a/apps/Donkey/Tests/DonkeyRuntimeTests/MusicPlaylistLiveE2ETests.swift
+++ b/apps/Donkey/Tests/DonkeyRuntimeTests/MusicPlaylistLiveE2ETests.swift
@@ -41,7 +41,7 @@ struct MusicPlaylistLiveE2ETests {
struct ScriptedPlaylistPlanner: HarnessNextStepPlanning {
let playlistName: String
- func planNextStep(for task: HarnessTaskState) async -> HarnessToolCall? {
+ func planNextStep(for task: HarnessAgentState, rollingContext: String?) async -> HarnessToolCall? {
let history = task.toolHistory
let searches = history.filter { $0.call.name == MusicPlaybackToolProvider.ToolName.search }
if searches.isEmpty {
@@ -106,25 +106,25 @@ struct MusicPlaylistLiveE2ETests {
// verification read unambiguous, and makes the playlist easy to find for manual cleanup.
let playlistName = "Best of 2000 (Donkey E2E \(stamp))"
- let coordinator = HarnessTaskCoordinator()
+ let coordinator = HarnessAgentCoordinator()
let registry = BuiltInHarnessToolCatalog.registryWithBuiltInExecutors()
let provider = MusicPlaybackToolProvider(service: MusicKitPlaybackService())
for tool in provider.makeTools() {
await registry.register(tool)
}
let runtime = GenericHarnessRuntime(coordinator: coordinator, registry: registry)
- let task = await coordinator.createTask(
+ let task = await coordinator.createAgent(
id: "live-music-e2e-\(stamp)",
- threadID: "t",
+ conversationID: "t",
goal: Self.command,
grantedPermissions: [.lifecycle]
)
// The same transcript wiring the real route uses, written under a temp root so the run
- // leaves a readable thread.md to inspect.
+ // leaves a readable conversation.md to inspect.
let root = FileManager.default.temporaryDirectory
.appendingPathComponent("donkey-live-music-e2e-\(stamp)", isDirectory: true)
- let transcript = ThreadTranscript(id: task.id, root: root)
+ let transcript = ConversationTranscript(id: task.id, root: root)
transcript.begin(id: task.id, app: "Music")
transcript.userMessage(Self.command)
transcript.planning(
@@ -134,7 +134,7 @@ struct MusicPlaylistLiveE2ETests {
successCriteria: "A library playlist named \"\(playlistName)\" exists and lists the 10 songs"
)
- let steps = await runtime.run(taskID: task.id, planner: ScriptedPlaylistPlanner(playlistName: playlistName)) { step in
+ let steps = await runtime.run(agentID: task.id, planner: ScriptedPlaylistPlanner(playlistName: playlistName)) { step in
guard let result = step.toolResult else { return }
transcript.step(
number: step.task.toolHistory.count,
@@ -147,9 +147,9 @@ struct MusicPlaylistLiveE2ETests {
)
}
- let finalTask = await coordinator.task(id: task.id)
- let threadText = (try? String(contentsOfFile: transcript.threadPath, encoding: .utf8)) ?? ""
- print("Live E2E thread (\(transcript.threadPath)):\n\(threadText)")
+ let finalTask = await coordinator.agent(id: task.id)
+ let threadText = (try? String(contentsOfFile: transcript.conversationPath, encoding: .utf8)) ?? ""
+ print("Live E2E conversation (\(transcript.conversationPath)):\n\(threadText)")
// The run completed end to end: one batched search + create + add + entries + run.complete.
#expect(
diff --git a/apps/Donkey/Tests/DonkeyRuntimeTests/RealtimeCursorVisualizationTests.swift b/apps/Donkey/Tests/DonkeyRuntimeTests/RealtimeCursorVisualizationTests.swift
index 2535c49a..f78d0b25 100644
--- a/apps/Donkey/Tests/DonkeyRuntimeTests/RealtimeCursorVisualizationTests.swift
+++ b/apps/Donkey/Tests/DonkeyRuntimeTests/RealtimeCursorVisualizationTests.swift
@@ -9,7 +9,7 @@ import Testing
struct RealtimeCursorVisualizationTests {
private func step(metadata: [String: String], status: HarnessToolResultStatus = .succeeded) -> HarnessStepExecutionResult {
HarnessStepExecutionResult(
- task: HarnessTaskState(threadID: "thread-1", goal: "do it"),
+ task: HarnessAgentState(conversationID: "thread-1", goal: "do it"),
toolResult: HarnessToolResult(
callID: "call-1",
toolName: "vision.click",
diff --git a/apps/Donkey/Tests/DonkeyRuntimeTests/ShellExecCommandTests.swift b/apps/Donkey/Tests/DonkeyRuntimeTests/ShellExecCommandTests.swift
index d481844b..fa876759 100644
--- a/apps/Donkey/Tests/DonkeyRuntimeTests/ShellExecCommandTests.swift
+++ b/apps/Donkey/Tests/DonkeyRuntimeTests/ShellExecCommandTests.swift
@@ -10,7 +10,7 @@ struct ShellExecCommandTests {
private func shellExec(_ command: String) async -> HarnessToolResult? {
let descriptor = DonkeyCommandLayer.descriptors.first { $0.name == "shell_exec" }!
let context = HarnessToolExecutionContext(
- taskID: "test",
+ agentID: "test",
call: HarnessToolCall(name: "shell_exec", input: ["command": command]),
descriptor: descriptor,
worldModel: HarnessWorldModel(),
diff --git a/apps/Donkey/Tests/DonkeyRuntimeTests/ShellPermissionPolicyStoreTests.swift b/apps/Donkey/Tests/DonkeyRuntimeTests/ShellPermissionPolicyStoreTests.swift
index 3a19d45d..5571383c 100644
--- a/apps/Donkey/Tests/DonkeyRuntimeTests/ShellPermissionPolicyStoreTests.swift
+++ b/apps/Donkey/Tests/DonkeyRuntimeTests/ShellPermissionPolicyStoreTests.swift
@@ -33,19 +33,19 @@ struct ShellPermissionPolicyStoreTests {
@Test
func allowOnceIsConsumedExactlyOnce() async {
let store = ShellPermissionPolicyStore(storeURL: temporaryStoreURL())
- await store.grantOnce(taskID: "t1", signature: "open")
- #expect(await store.consumeOnce(taskID: "t1", signature: "open") == true)
+ await store.grantOnce(agentID: "t1", signature: "open")
+ #expect(await store.consumeOnce(agentID: "t1", signature: "open") == true)
// Second use is gone.
- #expect(await store.consumeOnce(taskID: "t1", signature: "open") == false)
+ #expect(await store.consumeOnce(agentID: "t1", signature: "open") == false)
}
@Test
func allowOnceIsScopedToTaskAndSignature() async {
let store = ShellPermissionPolicyStore(storeURL: temporaryStoreURL())
- await store.grantOnce(taskID: "t1", signature: "open")
- #expect(await store.consumeOnce(taskID: "t2", signature: "open") == false)
- #expect(await store.consumeOnce(taskID: "t1", signature: "killall") == false)
- #expect(await store.consumeOnce(taskID: "t1", signature: "open") == true)
+ await store.grantOnce(agentID: "t1", signature: "open")
+ #expect(await store.consumeOnce(agentID: "t2", signature: "open") == false)
+ #expect(await store.consumeOnce(agentID: "t1", signature: "killall") == false)
+ #expect(await store.consumeOnce(agentID: "t1", signature: "open") == true)
}
@Test
diff --git a/apps/Donkey/Tests/DonkeyRuntimeTests/TaskFollowUpInjectionTests.swift b/apps/Donkey/Tests/DonkeyRuntimeTests/TaskFollowUpInjectionTests.swift
index e0c9edae..1c40366c 100644
--- a/apps/Donkey/Tests/DonkeyRuntimeTests/TaskFollowUpInjectionTests.swift
+++ b/apps/Donkey/Tests/DonkeyRuntimeTests/TaskFollowUpInjectionTests.swift
@@ -14,22 +14,22 @@ struct TaskFollowUpInjectionTests {
// into the world model, otherwise queue one follow-up and take a no-op step. Keying off the fact (not
// a call counter) keeps it a value type.
private struct InjectingPlanner: HarnessNextStepPlanning {
- let coordinator: HarnessTaskCoordinator
- let taskID: String
+ let coordinator: HarnessAgentCoordinator
+ let agentID: String
let injectText: String
- func planNextStep(for task: HarnessTaskState) async -> HarnessToolCall? {
- if task.worldModel.facts[HarnessTaskCoordinator.additionalInstructionsFactKey] != nil {
+ func planNextStep(for task: HarnessAgentState, rollingContext: String?) async -> HarnessToolCall? {
+ if task.worldModel.facts[HarnessAgentCoordinator.additionalInstructionsFactKey] != nil {
return HarnessToolCall(name: "run.complete", input: ["reason": "saw the follow-up"])
}
- await coordinator.enqueueUserMessage(taskID: taskID, text: injectText)
+ await coordinator.enqueueUserMessage(agentID: agentID, text: injectText)
return HarnessToolCall(name: "test.noop")
}
}
// Observe once, then complete — used to prove two loops run concurrently to completion.
private struct ObserveThenCompletePlanner: HarnessNextStepPlanning {
- func planNextStep(for task: HarnessTaskState) async -> HarnessToolCall? {
+ func planNextStep(for task: HarnessAgentState, rollingContext: String?) async -> HarnessToolCall? {
if task.worldModel.facts["observed"] == "true" {
return HarnessToolCall(name: "run.complete", input: ["reason": "done"])
}
@@ -61,105 +61,105 @@ struct TaskFollowUpInjectionTests {
@Test
func enqueueAndDrainFoldInTheInstructionWithoutTouchingTheGoalOrHistory() async {
- let coordinator = HarnessTaskCoordinator()
- _ = await coordinator.createTask(id: "t", threadID: "th", goal: "original goal")
+ let coordinator = HarnessAgentCoordinator()
+ _ = await coordinator.createAgent(id: "t", conversationID: "th", goal: "original goal")
// No live loop is running for this bare task, so enqueue reports false (the caller would resume).
- let live = await coordinator.enqueueUserMessage(taskID: "t", text: "also rename the file")
+ let live = await coordinator.enqueueUserMessage(agentID: "t", text: "also rename the file")
#expect(live == false)
- let drained = await coordinator.drainUserMessages(taskID: "t")
+ let drained = await coordinator.drainUserMessages(agentID: "t")
#expect(drained.map(\.text) == ["also rename the file"])
- let after = await coordinator.task(id: "t")
+ let after = await coordinator.agent(id: "t")
// The follow-up amends the work: the goal is preserved (not clobbered like interrupt would), the
// run is not restarted (no history), and the instruction is surfaced via the additive fact.
#expect(after?.goal == "original goal")
#expect(after?.toolHistory.isEmpty == true)
- #expect(after?.worldModel.facts[HarnessTaskCoordinator.additionalInstructionsFactKey] == "also rename the file")
+ #expect(after?.worldModel.facts[HarnessAgentCoordinator.additionalInstructionsFactKey] == "also rename the file")
// A second drain is empty — the queue cleared.
- let drainedAgain = await coordinator.drainUserMessages(taskID: "t")
+ let drainedAgain = await coordinator.drainUserMessages(agentID: "t")
#expect(drainedAgain.isEmpty)
}
@Test
func drainAccumulatesMultipleFollowUps() async {
- let coordinator = HarnessTaskCoordinator()
- _ = await coordinator.createTask(id: "t", threadID: "th", goal: "g")
- _ = await coordinator.enqueueUserMessage(taskID: "t", text: "first")
- _ = await coordinator.drainUserMessages(taskID: "t")
- _ = await coordinator.enqueueUserMessage(taskID: "t", text: "second")
- _ = await coordinator.drainUserMessages(taskID: "t")
-
- let after = await coordinator.task(id: "t")
- #expect(after?.worldModel.facts[HarnessTaskCoordinator.additionalInstructionsFactKey] == "first\nsecond")
+ let coordinator = HarnessAgentCoordinator()
+ _ = await coordinator.createAgent(id: "t", conversationID: "th", goal: "g")
+ _ = await coordinator.enqueueUserMessage(agentID: "t", text: "first")
+ _ = await coordinator.drainUserMessages(agentID: "t")
+ _ = await coordinator.enqueueUserMessage(agentID: "t", text: "second")
+ _ = await coordinator.drainUserMessages(agentID: "t")
+
+ let after = await coordinator.agent(id: "t")
+ #expect(after?.worldModel.facts[HarnessAgentCoordinator.additionalInstructionsFactKey] == "first\nsecond")
}
@Test
func enqueueOnUnknownTaskReportsNoLiveLoop() async {
- let coordinator = HarnessTaskCoordinator()
- let live = await coordinator.enqueueUserMessage(taskID: "missing", text: "x")
+ let coordinator = HarnessAgentCoordinator()
+ let live = await coordinator.enqueueUserMessage(agentID: "missing", text: "x")
#expect(live == false)
}
@Test
func enqueueReportsLiveLoopOnlyWhileARunIsMarked() async {
- let coordinator = HarnessTaskCoordinator()
- _ = await coordinator.createTask(id: "t", threadID: "th", goal: "g")
+ let coordinator = HarnessAgentCoordinator()
+ _ = await coordinator.createAgent(id: "t", conversationID: "th", goal: "g")
// Before any run: not live → caller resumes.
- #expect(await coordinator.enqueueUserMessage(taskID: "t", text: "a") == false)
+ #expect(await coordinator.enqueueUserMessage(agentID: "t", text: "a") == false)
// While a run is marked: live → caller injects and the loop drains it.
- await coordinator.beginRun(taskID: "t")
- #expect(await coordinator.enqueueUserMessage(taskID: "t", text: "b") == true)
+ await coordinator.beginRun(agentID: "t")
+ #expect(await coordinator.enqueueUserMessage(agentID: "t", text: "b") == true)
// endRunUnlessPending sees the queued messages and keeps the run alive (returns false).
- #expect(await coordinator.endRunUnlessPending(taskID: "t") == false)
- _ = await coordinator.drainUserMessages(taskID: "t")
+ #expect(await coordinator.endRunUnlessPending(agentID: "t") == false)
+ _ = await coordinator.drainUserMessages(agentID: "t")
// With the queue now empty, the run truly ends and a later enqueue reports not-live again.
- #expect(await coordinator.endRunUnlessPending(taskID: "t") == true)
- #expect(await coordinator.enqueueUserMessage(taskID: "t", text: "c") == false)
+ #expect(await coordinator.endRunUnlessPending(agentID: "t") == true)
+ #expect(await coordinator.enqueueUserMessage(agentID: "t", text: "c") == false)
}
@Test
func reopenForFollowUpRevivesACompletedTaskPreservingFacts() async {
- let coordinator = HarnessTaskCoordinator()
- _ = await coordinator.createTask(id: "t", threadID: "th", goal: "g")
- _ = await coordinator.drainUserMessages(taskID: "t") // no-op
- _ = await coordinator.enqueueUserMessage(taskID: "t", text: "late instruction")
- _ = await coordinator.drainUserMessages(taskID: "t") // folds into the fact
- _ = await coordinator.complete(taskID: "t")
+ let coordinator = HarnessAgentCoordinator()
+ _ = await coordinator.createAgent(id: "t", conversationID: "th", goal: "g")
+ _ = await coordinator.drainUserMessages(agentID: "t") // no-op
+ _ = await coordinator.enqueueUserMessage(agentID: "t", text: "late instruction")
+ _ = await coordinator.drainUserMessages(agentID: "t") // folds into the fact
+ _ = await coordinator.complete(agentID: "t")
// complete() clears the follow-up fact, so re-enqueue to simulate a fresh late arrival.
- _ = await coordinator.enqueueUserMessage(taskID: "t", text: "newer instruction")
- _ = await coordinator.drainUserMessages(taskID: "t")
+ _ = await coordinator.enqueueUserMessage(agentID: "t", text: "newer instruction")
+ _ = await coordinator.drainUserMessages(agentID: "t")
- await coordinator.reopenForFollowUp(taskID: "t")
- let task = await coordinator.task(id: "t")
+ await coordinator.reopenForFollowUp(agentID: "t")
+ let task = await coordinator.agent(id: "t")
#expect(task?.status == .running)
- #expect(task?.worldModel.facts[HarnessTaskCoordinator.additionalInstructionsFactKey] == "newer instruction")
+ #expect(task?.worldModel.facts[HarnessAgentCoordinator.additionalInstructionsFactKey] == "newer instruction")
}
@Test
func runningLoopFoldsInAFollowUpMidRunInsteadOfRestarting() async {
- let coordinator = HarnessTaskCoordinator()
+ let coordinator = HarnessAgentCoordinator()
let registry = BuiltInHarnessToolCatalog.registryWithBuiltInExecutors()
await registry.register(noopTool())
let runtime = GenericHarnessRuntime(coordinator: coordinator, registry: registry)
- let task = await coordinator.createTask(
+ let task = await coordinator.createAgent(
id: "task-inject",
- threadID: "thread-inject",
+ conversationID: "thread-inject",
goal: "tidy the desktop",
grantedPermissions: [.lifecycle]
)
- let planner = InjectingPlanner(coordinator: coordinator, taskID: task.id, injectText: "also empty the trash")
- let steps = await runtime.run(taskID: task.id, planner: planner, maxSteps: 10)
+ let planner = InjectingPlanner(coordinator: coordinator, agentID: task.id, injectText: "also empty the trash")
+ let steps = await runtime.run(agentID: task.id, planner: planner, maxSteps: 10)
// The queued instruction is delivered at the next loop iteration, so the run completes rather than
// stalling, and the original goal is untouched (the follow-up amended the work in place).
- let finalTask = await coordinator.task(id: task.id)
+ let finalTask = await coordinator.agent(id: task.id)
#expect(finalTask?.status == .completed)
#expect(finalTask?.goal == "tidy the desktop")
#expect(steps.last?.toolResult?.toolName == "run.complete")
@@ -167,20 +167,20 @@ struct TaskFollowUpInjectionTests {
@Test
func twoLoopsRunConcurrentlyOnOneCoordinatorWithoutCrossTalk() async {
- let coordinator = HarnessTaskCoordinator()
+ let coordinator = HarnessAgentCoordinator()
let registry = BuiltInHarnessToolCatalog.registryWithBuiltInExecutors()
await registry.register(observeTool())
let runtime = GenericHarnessRuntime(coordinator: coordinator, registry: registry)
- let taskA = await coordinator.createTask(id: "task-a", threadID: "thread-a", goal: "goal A", grantedPermissions: [.lifecycle])
- let taskB = await coordinator.createTask(id: "task-b", threadID: "thread-b", goal: "goal B", grantedPermissions: [.lifecycle])
+ let taskA = await coordinator.createAgent(id: "task-a", conversationID: "thread-a", goal: "goal A", grantedPermissions: [.lifecycle])
+ let taskB = await coordinator.createAgent(id: "task-b", conversationID: "thread-b", goal: "goal B", grantedPermissions: [.lifecycle])
let planner = ObserveThenCompletePlanner()
- async let runA = runtime.run(taskID: taskA.id, planner: planner, maxSteps: 5)
- async let runB = runtime.run(taskID: taskB.id, planner: planner, maxSteps: 5)
+ async let runA = runtime.run(agentID: taskA.id, planner: planner, maxSteps: 5)
+ async let runB = runtime.run(agentID: taskB.id, planner: planner, maxSteps: 5)
_ = await (runA, runB)
- let finalA = await coordinator.task(id: taskA.id)
- let finalB = await coordinator.task(id: taskB.id)
+ let finalA = await coordinator.agent(id: taskA.id)
+ let finalB = await coordinator.agent(id: taskB.id)
#expect(finalA?.status == .completed)
#expect(finalB?.status == .completed)
// Each task kept its own goal and history — no state bled between the concurrent loops.
@@ -193,11 +193,11 @@ struct TaskFollowUpInjectionTests {
// Keeps making progress (a new fact each step) so the stall guards never fire; it should hit the
// step ceiling and be marked timedOut (retryable), not failedSafe.
struct AlwaysProgressPlanner: HarnessNextStepPlanning {
- func planNextStep(for task: HarnessTaskState) async -> HarnessToolCall? {
+ func planNextStep(for task: HarnessAgentState, rollingContext: String?) async -> HarnessToolCall? {
HarnessToolCall(name: "test.progress", input: ["n": String(task.toolHistory.count)])
}
}
- let coordinator = HarnessTaskCoordinator()
+ let coordinator = HarnessAgentCoordinator()
let registry = BuiltInHarnessToolCatalog.registryWithBuiltInExecutors()
await registry.register(
HarnessTool(
@@ -213,38 +213,38 @@ struct TaskFollowUpInjectionTests {
}
)
let runtime = GenericHarnessRuntime(coordinator: coordinator, registry: registry)
- let task = await coordinator.createTask(id: "task-timeout", threadID: "t", goal: "go forever", grantedPermissions: [.lifecycle])
+ let task = await coordinator.createAgent(id: "task-timeout", conversationID: "t", goal: "go forever", grantedPermissions: [.lifecycle])
- _ = await runtime.run(taskID: task.id, planner: AlwaysProgressPlanner(), maxSteps: 3)
+ _ = await runtime.run(agentID: task.id, planner: AlwaysProgressPlanner(), maxSteps: 3)
- let finalTask = await coordinator.task(id: task.id)
+ let finalTask = await coordinator.agent(id: task.id)
#expect(finalTask?.status == .timedOut)
}
@Test
func aPlannerThatStopsWithoutALifecycleCallFailsSafe() async {
struct GivesUpPlanner: HarnessNextStepPlanning {
- func planNextStep(for task: HarnessTaskState) async -> HarnessToolCall? { nil }
+ func planNextStep(for task: HarnessAgentState, rollingContext: String?) async -> HarnessToolCall? { nil }
}
- let coordinator = HarnessTaskCoordinator()
+ let coordinator = HarnessAgentCoordinator()
let registry = BuiltInHarnessToolCatalog.registryWithBuiltInExecutors()
let runtime = GenericHarnessRuntime(coordinator: coordinator, registry: registry)
- let task = await coordinator.createTask(id: "task-giveup", threadID: "t", goal: "g", grantedPermissions: [.lifecycle])
+ let task = await coordinator.createAgent(id: "task-giveup", conversationID: "t", goal: "g", grantedPermissions: [.lifecycle])
- _ = await runtime.run(taskID: task.id, planner: GivesUpPlanner(), maxSteps: 5)
+ _ = await runtime.run(agentID: task.id, planner: GivesUpPlanner(), maxSteps: 5)
- let finalTask = await coordinator.task(id: task.id)
+ let finalTask = await coordinator.agent(id: task.id)
#expect(finalTask?.status == .failedSafe)
}
@Test
func timeOutMarksTheTaskRetryableAndClearsAnyGate() async {
- let coordinator = HarnessTaskCoordinator()
- _ = await coordinator.createTask(id: "t", threadID: "th", goal: "g")
+ let coordinator = HarnessAgentCoordinator()
+ _ = await coordinator.createAgent(id: "t", conversationID: "th", goal: "g")
// Leave a pending continuation behind to prove timeOut clears it.
- _ = await coordinator.waitForUser(taskID: "t", question: "which file?")
+ _ = await coordinator.waitForUser(agentID: "t", question: "which file?")
- let timedOut = await coordinator.timeOut(taskID: "t")
+ let timedOut = await coordinator.timeOut(agentID: "t")
#expect(timedOut?.status == .timedOut)
#expect(timedOut?.pendingContinuation == nil)
#expect(timedOut?.status.canExecuteTools == false)
@@ -254,8 +254,8 @@ struct TaskFollowUpInjectionTests {
@Test
func restoredTasksMapByStalenessAndState() {
let now = Date()
- func task(_ id: String, _ status: UserQueryTaskStatus, ageMinutes: Double) -> UserQueryNotchTask {
- UserQueryNotchTask(
+ func task(_ id: String, _ status: UserQueryConversationStatus, ageMinutes: Double) -> UserQueryConversation {
+ UserQueryConversation(
id: id,
title: id,
detail: "d",
@@ -280,7 +280,7 @@ struct TaskFollowUpInjectionTests {
// Only the recently-running task auto-resumes; it keeps running.
#expect(result.autoResumeIDs == ["recent"])
- func status(_ id: String) -> UserQueryTaskStatus? { result.tasks.first { $0.id == id }?.status }
+ func status(_ id: String) -> UserQueryConversationStatus? { result.tasks.first { $0.id == id }?.status }
#expect(status("recent") == .running)
#expect(status("stale") == .timedOut) // too old to auto-run → retryable row
#expect(status("waiting") == .waitingForClarification) // still asking the user → comes back as a Reply row
diff --git a/apps/Donkey/Tests/DonkeyRuntimeTests/UserQueryActivityTests.swift b/apps/Donkey/Tests/DonkeyRuntimeTests/UserQueryActivityTests.swift
index 377ac74d..7df60c5a 100644
--- a/apps/Donkey/Tests/DonkeyRuntimeTests/UserQueryActivityTests.swift
+++ b/apps/Donkey/Tests/DonkeyRuntimeTests/UserQueryActivityTests.swift
@@ -5,11 +5,11 @@ import Testing
@Suite
struct UserQueryActivityTests {
private func task(
- status: UserQueryTaskStatus,
+ status: UserQueryConversationStatus,
detail: String = "",
metadata: [String: String] = [:]
- ) -> UserQueryNotchTask {
- UserQueryNotchTask(
+ ) -> UserQueryConversation {
+ UserQueryConversation(
id: "t",
title: "Title",
detail: detail,
diff --git a/apps/Donkey/Tests/DonkeyRuntimeTests/UserQuerySpawnGeometryTests.swift b/apps/Donkey/Tests/DonkeyRuntimeTests/UserQuerySpawnGeometryTests.swift
index cb8b4b79..1c28006c 100644
--- a/apps/Donkey/Tests/DonkeyRuntimeTests/UserQuerySpawnGeometryTests.swift
+++ b/apps/Donkey/Tests/DonkeyRuntimeTests/UserQuerySpawnGeometryTests.swift
@@ -256,7 +256,7 @@ struct UserQuerySpawnGeometryTests {
let viewModel = UserQuerySpawnOverlayViewModel()
let state = UserQuerySpawnState(
id: "spawn-1",
- taskID: "task-1",
+ conversationID: "task-1",
commandText: "plan",
label: Array(repeating: "checking", count: 18).joined(separator: " "),
accentIndex: 1,
@@ -309,7 +309,7 @@ struct UserQuerySpawnGeometryTests {
let viewModel = UserQuerySpawnOverlayViewModel()
let state = UserQuerySpawnState(
id: "spawn-1",
- taskID: "task-1",
+ conversationID: "task-1",
commandText: "hi there",
label: "hi there",
accentIndex: 1,
@@ -318,9 +318,9 @@ struct UserQuerySpawnGeometryTests {
var submittedSpawnID: String?
var submittedTaskID: String?
var submittedText: String?
- viewModel.followUpSubmitted = { spawnID, taskID, text in
+ viewModel.followUpSubmitted = { spawnID, agentID, text in
submittedSpawnID = spawnID
- submittedTaskID = taskID
+ submittedTaskID = agentID
submittedText = text
}
@@ -349,7 +349,7 @@ struct UserQuerySpawnGeometryTests {
let viewModel = UserQuerySpawnOverlayViewModel()
let state = UserQuerySpawnState(
id: "spawn-1",
- taskID: "task-1",
+ conversationID: "task-1",
commandText: "hi there",
label: "hi there",
accentIndex: 1,