-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Expand file tree
/
Copy pathTypes.cs
More file actions
387 lines (318 loc) · 11.3 KB
/
Copy pathTypes.cs
File metadata and controls
387 lines (318 loc) · 11.3 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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
*--------------------------------------------------------------------------------------------*/
using System.Text.Json.Serialization;
using Microsoft.Extensions.AI;
using Microsoft.Extensions.Logging;
namespace GitHub.Copilot.SDK;
public enum ConnectionState
{
Disconnected,
Connecting,
Connected,
Error
}
public class CopilotClientOptions
{
public string? CliPath { get; set; }
public string[]? CliArgs { get; set; }
public string? Cwd { get; set; }
public int Port { get; set; }
public bool UseStdio { get; set; } = true;
public string? CliUrl { get; set; }
public string LogLevel { get; set; } = "info";
public bool AutoStart { get; set; } = true;
public bool AutoRestart { get; set; } = true;
public IReadOnlyDictionary<string, string>? Environment { get; set; }
public ILogger? Logger { get; set; }
}
public class ToolBinaryResult
{
[JsonPropertyName("data")]
public string Data { get; set; } = string.Empty;
[JsonPropertyName("mimeType")]
public string MimeType { get; set; } = string.Empty;
[JsonPropertyName("type")]
public string Type { get; set; } = string.Empty;
[JsonPropertyName("description")]
public string? Description { get; set; }
}
public class ToolResultObject
{
[JsonPropertyName("textResultForLlm")]
public string TextResultForLlm { get; set; } = string.Empty;
[JsonPropertyName("binaryResultsForLlm")]
public List<ToolBinaryResult>? BinaryResultsForLlm { get; set; }
[JsonPropertyName("resultType")]
public string ResultType { get; set; } = "success";
[JsonPropertyName("error")]
public string? Error { get; set; }
[JsonPropertyName("sessionLog")]
public string? SessionLog { get; set; }
[JsonPropertyName("toolTelemetry")]
public Dictionary<string, object>? ToolTelemetry { get; set; }
}
public class ToolInvocation
{
public string SessionId { get; set; } = string.Empty;
public string ToolCallId { get; set; } = string.Empty;
public string ToolName { get; set; } = string.Empty;
public object? Arguments { get; set; }
}
public delegate Task<object?> ToolHandler(ToolInvocation invocation);
public class PermissionRequest
{
[JsonPropertyName("kind")]
public string Kind { get; set; } = string.Empty;
[JsonPropertyName("toolCallId")]
public string? ToolCallId { get; set; }
[JsonExtensionData]
public Dictionary<string, object>? ExtensionData { get; set; }
}
public class PermissionRequestResult
{
[JsonPropertyName("kind")]
public string Kind { get; set; } = string.Empty;
[JsonPropertyName("rules")]
public List<object>? Rules { get; set; }
}
public class PermissionInvocation
{
public string SessionId { get; set; } = string.Empty;
}
public delegate Task<PermissionRequestResult> PermissionHandler(PermissionRequest request, PermissionInvocation invocation);
public enum SystemMessageMode
{
Append,
Replace
}
public class SystemMessageConfig
{
public SystemMessageMode? Mode { get; set; }
public string? Content { get; set; }
}
public class ProviderConfig
{
[JsonPropertyName("type")]
public string? Type { get; set; }
[JsonPropertyName("wireApi")]
public string? WireApi { get; set; }
[JsonPropertyName("baseUrl")]
public string BaseUrl { get; set; } = string.Empty;
[JsonPropertyName("apiKey")]
public string? ApiKey { get; set; }
/// <summary>
/// Bearer token for authentication. Sets the Authorization header directly.
/// Use this for services requiring bearer token auth instead of API key.
/// Takes precedence over ApiKey when both are set.
/// </summary>
[JsonPropertyName("bearerToken")]
public string? BearerToken { get; set; }
[JsonPropertyName("azure")]
public AzureOptions? Azure { get; set; }
}
public class AzureOptions
{
[JsonPropertyName("apiVersion")]
public string? ApiVersion { get; set; }
}
// ============================================================================
// MCP Server Configuration Types
// ============================================================================
/// <summary>
/// Configuration for a local/stdio MCP server.
/// </summary>
public class McpLocalServerConfig
{
/// <summary>
/// List of tools to include from this server. Empty list means none. Use "*" for all.
/// </summary>
[JsonPropertyName("tools")]
public List<string> Tools { get; set; } = new();
/// <summary>
/// Server type. Defaults to "local".
/// </summary>
[JsonPropertyName("type")]
public string? Type { get; set; }
/// <summary>
/// Optional timeout in milliseconds for tool calls to this server.
/// </summary>
[JsonPropertyName("timeout")]
public int? Timeout { get; set; }
/// <summary>
/// Command to run the MCP server.
/// </summary>
[JsonPropertyName("command")]
public string Command { get; set; } = string.Empty;
/// <summary>
/// Arguments to pass to the command.
/// </summary>
[JsonPropertyName("args")]
public List<string> Args { get; set; } = new();
/// <summary>
/// Environment variables to pass to the server.
/// </summary>
[JsonPropertyName("env")]
public Dictionary<string, string>? Env { get; set; }
/// <summary>
/// Working directory for the server process.
/// </summary>
[JsonPropertyName("cwd")]
public string? Cwd { get; set; }
}
/// <summary>
/// Configuration for a remote MCP server (HTTP or SSE).
/// </summary>
public class McpRemoteServerConfig
{
/// <summary>
/// List of tools to include from this server. Empty list means none. Use "*" for all.
/// </summary>
[JsonPropertyName("tools")]
public List<string> Tools { get; set; } = new();
/// <summary>
/// Server type. Must be "http" or "sse".
/// </summary>
[JsonPropertyName("type")]
public string Type { get; set; } = "http";
/// <summary>
/// Optional timeout in milliseconds for tool calls to this server.
/// </summary>
[JsonPropertyName("timeout")]
public int? Timeout { get; set; }
/// <summary>
/// URL of the remote server.
/// </summary>
[JsonPropertyName("url")]
public string Url { get; set; } = string.Empty;
/// <summary>
/// Optional HTTP headers to include in requests.
/// </summary>
[JsonPropertyName("headers")]
public Dictionary<string, string>? Headers { get; set; }
}
// ============================================================================
// Custom Agent Configuration Types
// ============================================================================
/// <summary>
/// Configuration for a custom agent.
/// </summary>
public class CustomAgentConfig
{
/// <summary>
/// Unique name of the custom agent.
/// </summary>
[JsonPropertyName("name")]
public string Name { get; set; } = string.Empty;
/// <summary>
/// Display name for UI purposes.
/// </summary>
[JsonPropertyName("displayName")]
public string? DisplayName { get; set; }
/// <summary>
/// Description of what the agent does.
/// </summary>
[JsonPropertyName("description")]
public string? Description { get; set; }
/// <summary>
/// List of tool names the agent can use. Null for all tools.
/// </summary>
[JsonPropertyName("tools")]
public List<string>? Tools { get; set; }
/// <summary>
/// The prompt content for the agent.
/// </summary>
[JsonPropertyName("prompt")]
public string Prompt { get; set; } = string.Empty;
/// <summary>
/// MCP servers specific to this agent.
/// </summary>
[JsonPropertyName("mcpServers")]
public Dictionary<string, object>? McpServers { get; set; }
/// <summary>
/// Whether the agent should be available for model inference.
/// </summary>
[JsonPropertyName("infer")]
public bool? Infer { get; set; }
}
public class SessionConfig
{
public string? SessionId { get; set; }
public string? Model { get; set; }
/// <summary>
/// Override the default configuration directory location.
/// When specified, the session will use this directory for storing config and state.
/// </summary>
public string? ConfigDir { get; set; }
public ICollection<AIFunction>? Tools { get; set; }
public SystemMessageConfig? SystemMessage { get; set; }
public List<string>? AvailableTools { get; set; }
public List<string>? ExcludedTools { get; set; }
public ProviderConfig? Provider { get; set; }
/// <summary>
/// Handler for permission requests from the server.
/// When provided, the server will call this handler to request permission for operations.
/// </summary>
public PermissionHandler? OnPermissionRequest { get; set; }
/// <summary>
/// Enable streaming of assistant message and reasoning chunks.
/// When true, assistant.message_delta and assistant.reasoning_delta events
/// with deltaContent are sent as the response is generated.
/// </summary>
public bool Streaming { get; set; }
/// <summary>
/// MCP server configurations for the session.
/// Keys are server names, values are server configurations (McpLocalServerConfig or McpRemoteServerConfig).
/// </summary>
public Dictionary<string, object>? McpServers { get; set; }
/// <summary>
/// Custom agent configurations for the session.
/// </summary>
public List<CustomAgentConfig>? CustomAgents { get; set; }
}
public class ResumeSessionConfig
{
public ICollection<AIFunction>? Tools { get; set; }
public ProviderConfig? Provider { get; set; }
/// <summary>
/// Handler for permission requests from the server.
/// When provided, the server will call this handler to request permission for operations.
/// </summary>
public PermissionHandler? OnPermissionRequest { get; set; }
/// <summary>
/// Enable streaming of assistant message and reasoning chunks.
/// When true, assistant.message_delta and assistant.reasoning_delta events
/// with deltaContent are sent as the response is generated.
/// </summary>
public bool Streaming { get; set; }
/// <summary>
/// MCP server configurations for the session.
/// Keys are server names, values are server configurations (McpLocalServerConfig or McpRemoteServerConfig).
/// </summary>
public Dictionary<string, object>? McpServers { get; set; }
/// <summary>
/// Custom agent configurations for the session.
/// </summary>
public List<CustomAgentConfig>? CustomAgents { get; set; }
}
public class MessageOptions
{
public string Prompt { get; set; } = string.Empty;
public List<UserMessageDataAttachmentsItem>? Attachments { get; set; }
public string? Mode { get; set; }
}
public delegate void SessionEventHandler(SessionEvent sessionEvent);
public class SessionMetadata
{
public string SessionId { get; set; } = string.Empty;
public DateTime StartTime { get; set; }
public DateTime ModifiedTime { get; set; }
public string? Summary { get; set; }
public bool IsRemote { get; set; }
}
public class PingResponse
{
public string Message { get; set; } = string.Empty;
public long Timestamp { get; set; }
public int? ProtocolVersion { get; set; }
}