-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Expand file tree
/
Copy pathGitHubCopilotRequest+Conversation.swift
More file actions
172 lines (145 loc) · 4.72 KB
/
GitHubCopilotRequest+Conversation.swift
File metadata and controls
172 lines (145 loc) · 4.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
import CopilotForXcodeKit
import Foundation
import LanguageServerProtocol
import SuggestionBasic
import ConversationServiceProvider
import JSONRPC
import Logger
enum ConversationSource: String, Codable {
case panel, inline
}
public struct Reference: Codable, Equatable, Hashable {
public var type: String = "file"
public let uri: String
public let position: Position?
public let visibleRange: SuggestionBasic.CursorRange?
public let selection: SuggestionBasic.CursorRange?
public let openedAt: String?
public let activeAt: String?
}
struct ConversationCreateParams: Codable {
var workDoneToken: String
var turns: [TurnSchema]
var capabilities: Capabilities
var textDocument: Doc?
var references: [Reference]?
var computeSuggestions: Bool?
var source: ConversationSource?
var workspaceFolder: String?
var workspaceFolders: [WorkspaceFolder]?
var ignoredSkills: [String]?
var model: String?
var chatMode: String?
var needToolCallConfirmation: Bool?
var userLanguage: String?
struct Capabilities: Codable {
var skills: [String]
var allSkills: Bool?
}
}
// MARK: Conversation Progress
public enum ConversationProgressKind: String, Codable {
case begin, report, end
}
protocol BaseConversationProgress: Codable {
var kind: ConversationProgressKind { get }
var conversationId: String { get }
var turnId: String { get }
}
public struct ConversationProgressBegin: BaseConversationProgress {
public let kind: ConversationProgressKind
public let conversationId: String
public let turnId: String
}
public struct ConversationProgressReport: BaseConversationProgress {
public let kind: ConversationProgressKind
public let conversationId: String
public let turnId: String
public let reply: String?
public let references: [Reference]?
public let steps: [ConversationProgressStep]?
public let editAgentRounds: [AgentRound]?
}
public struct ConversationProgressEnd: BaseConversationProgress {
public let kind: ConversationProgressKind
public let conversationId: String
public let turnId: String
public let error: CopilotLanguageServerError?
public let followUp: ConversationFollowUp?
public let suggestedTitle: String?
}
enum ConversationProgressContainer: Decodable {
case begin(ConversationProgressBegin)
case report(ConversationProgressReport)
case end(end: ConversationProgressEnd)
enum CodingKeys: String, CodingKey {
case kind
}
init(from decoder: Decoder) throws {
do {
let container = try decoder.container(keyedBy: CodingKeys.self)
let kind = try container.decode(ConversationProgressKind.self, forKey: .kind)
switch kind {
case .begin:
let begin = try ConversationProgressBegin(from: decoder)
self = .begin(begin)
case .report:
let report = try ConversationProgressReport(from: decoder)
self = .report(report)
case .end:
let end = try ConversationProgressEnd(from: decoder)
self = .end(end: end)
}
} catch {
Logger.gitHubCopilot.error("Error decoding ConversationProgressContainer: \(error)")
throw error
}
}
}
// MARK: Conversation rating
struct ConversationRatingParams: Codable {
var turnId: String
var rating: ConversationRating
var doc: Doc?
var source: ConversationSource?
}
// MARK: Conversation turn
struct TurnCreateParams: Codable {
var workDoneToken: String
var conversationId: String
var turnId: String?
var message: MessageContent
var textDocument: Doc?
var ignoredSkills: [String]?
var references: [Reference]?
var model: String?
var workspaceFolder: String?
var workspaceFolders: [WorkspaceFolder]?
var chatMode: String?
var needToolCallConfirmation: Bool?
}
// MARK: Copy
struct CopyCodeParams: Codable {
var turnId: String
var codeBlockIndex: Int
var copyType: CopyKind
var copiedCharacters: Int
var totalCharacters: Int
var copiedText: String
var doc: Doc?
var source: ConversationSource?
}
// MARK: Conversation context
public struct ConversationContextParams: Codable {
public var conversationId: String
public var turnId: String
public var skillId: String
}
public typealias ConversationContextRequest = JSONRPCRequest<ConversationContextParams>
// MARK: Watched Files
public struct WatchedFilesParams: Codable {
public var workspaceFolder: WorkspaceFolder
public var excludeGitignoredFiles: Bool
public var excludeIDEIgnoredFiles: Bool
}
public typealias WatchedFilesRequest = JSONRPCRequest<WatchedFilesParams>