-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathResumeSessionConfig.java
More file actions
169 lines (152 loc) · 4.58 KB
/
ResumeSessionConfig.java
File metadata and controls
169 lines (152 loc) · 4.58 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
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
*--------------------------------------------------------------------------------------------*/
package com.github.copilot.sdk.json;
import java.util.List;
import java.util.Map;
import com.fasterxml.jackson.annotation.JsonInclude;
/**
* Configuration for resuming an existing Copilot session.
* <p>
* This class provides options for configuring a resumed session, including tool
* registration, provider configuration, and streaming. All setter methods
* return {@code this} for method chaining.
*
* <h2>Example Usage</h2>
*
* <pre>{@code
* var config = new ResumeSessionConfig().setStreaming(true).setTools(List.of(myTool));
*
* var session = client.resumeSession(sessionId, config).get();
* }</pre>
*
* @see com.github.copilot.sdk.CopilotClient#resumeSession(String,
* ResumeSessionConfig)
*/
@JsonInclude(JsonInclude.Include.NON_NULL)
public class ResumeSessionConfig {
private List<ToolDefinition> tools;
private ProviderConfig provider;
private PermissionHandler onPermissionRequest;
private boolean streaming;
private Map<String, Object> mcpServers;
private List<CustomAgentConfig> customAgents;
/**
* Gets the custom tools for this session.
*
* @return the list of tool definitions
*/
public List<ToolDefinition> getTools() {
return tools;
}
/**
* Sets custom tools that the assistant can invoke during the session.
*
* @param tools
* the list of tool definitions
* @return this config for method chaining
* @see ToolDefinition
*/
public ResumeSessionConfig setTools(List<ToolDefinition> tools) {
this.tools = tools;
return this;
}
/**
* Gets the custom API provider configuration.
*
* @return the provider configuration
*/
public ProviderConfig getProvider() {
return provider;
}
/**
* Sets a custom API provider for BYOK scenarios.
*
* @param provider
* the provider configuration
* @return this config for method chaining
* @see ProviderConfig
*/
public ResumeSessionConfig setProvider(ProviderConfig provider) {
this.provider = provider;
return this;
}
/**
* Gets the permission request handler.
*
* @return the permission handler
*/
public PermissionHandler getOnPermissionRequest() {
return onPermissionRequest;
}
/**
* Sets a handler for permission requests from the assistant.
*
* @param onPermissionRequest
* the permission handler
* @return this config for method chaining
* @see PermissionHandler
*/
public ResumeSessionConfig setOnPermissionRequest(PermissionHandler onPermissionRequest) {
this.onPermissionRequest = onPermissionRequest;
return this;
}
/**
* Returns whether streaming is enabled.
*
* @return {@code true} if streaming is enabled
*/
public boolean isStreaming() {
return streaming;
}
/**
* Sets whether to enable streaming of response chunks.
*
* @param streaming
* {@code true} to enable streaming
* @return this config for method chaining
*/
public ResumeSessionConfig setStreaming(boolean streaming) {
this.streaming = streaming;
return this;
}
/**
* Gets the MCP server configurations.
*
* @return the MCP servers map
*/
public Map<String, Object> getMcpServers() {
return mcpServers;
}
/**
* Sets MCP (Model Context Protocol) server configurations.
*
* @param mcpServers
* the MCP servers configuration map
* @return this config for method chaining
*/
public ResumeSessionConfig setMcpServers(Map<String, Object> mcpServers) {
this.mcpServers = mcpServers;
return this;
}
/**
* Gets the custom agent configurations.
*
* @return the list of custom agent configurations
*/
public List<CustomAgentConfig> getCustomAgents() {
return customAgents;
}
/**
* Sets custom agent configurations.
*
* @param customAgents
* the list of custom agent configurations
* @return this config for method chaining
* @see CustomAgentConfig
*/
public ResumeSessionConfig setCustomAgents(List<CustomAgentConfig> customAgents) {
this.customAgents = customAgents;
return this;
}
}