1+ import ChatBasic
12import ChatTab
23import CopilotForXcodeKit
34import Foundation
@@ -6,6 +7,8 @@ import Preferences
67public protocol BuiltinExtension : CopilotForXcodeExtensionCapability {
78 /// An id that let the extension manager determine whether the extension is in use.
89 var suggestionServiceId : BuiltInSuggestionFeatureProvider { get }
10+ /// An identifier for the extension.
11+ var extensionIdentifier : String { get }
912
1013 /// All chat builders provided by this extension.
1114 var chatTabTypes : [ any ChatTab . Type ] { get }
@@ -21,3 +24,41 @@ public extension BuiltinExtension {
2124 var chatTabTypes : [ any ChatTab . Type ] { [ ] }
2225}
2326
27+ // MAKR: - ChatService
28+
29+ /// A temporary protocol for ChatServiceType. Migrate it to CopilotForXcodeKit when finished.
30+ public protocol BuiltinExtensionChatServiceType : ChatServiceType {
31+ typealias Message = ChatMessage
32+
33+ func sendMessage(
34+ _ message: String ,
35+ history: [ Message ] ,
36+ references: [ RetrievedContent ] ,
37+ workspace: WorkspaceInfo
38+ ) async -> AsyncThrowingStream < String , Error >
39+ }
40+
41+ public struct RetrievedContent {
42+ public var document : ChatMessage . Reference
43+ public var priority : Int
44+
45+ public init ( document: ChatMessage . Reference , priority: Int ) {
46+ self . document = document
47+ self . priority = priority
48+ }
49+ }
50+
51+ public enum ChatServiceMemoryMutation : Codable {
52+ public typealias Message = ChatMessage
53+
54+ /// Add a new message to the end of memory.
55+ /// If an id is not provided, a new id will be generated.
56+ /// If an id is provided, and a message with the same id exists the message with the same
57+ /// id will be updated.
58+ case appendMessage( id: String ? , role: Message . Role , text: String )
59+ /// Update the message with the given id.
60+ case updateMessage( id: String , role: Message . Role , text: String )
61+ /// Stream the content into a message with the given id.
62+ case streamIntoMessage( id: String , role: Message . Role ? , text: String ? )
63+ }
64+
0 commit comments