forked from github/copilot-sdk-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSessionUiApi.java
More file actions
85 lines (78 loc) · 3.02 KB
/
SessionUiApi.java
File metadata and controls
85 lines (78 loc) · 3.02 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
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
*--------------------------------------------------------------------------------------------*/
package com.github.copilot.sdk.json;
import java.util.concurrent.CompletableFuture;
/**
* Provides UI methods for eliciting information from the user during a session.
* <p>
* All methods on this interface throw {@link IllegalStateException} if the host
* does not report elicitation support via
* {@link com.github.copilot.sdk.CopilotSession#getCapabilities()}. Check
* {@code session.getCapabilities().getUi()?.getElicitation() == true} before
* calling.
*
* <h2>Example Usage</h2>
*
* <pre>{@code
* if (Boolean.TRUE
* .equals(session.getCapabilities().getUi() != null && session.getCapabilities().getUi().getElicitation())) {
* boolean confirmed = session.getUi().confirm("Are you sure?").get();
* }
* }</pre>
*
* @see com.github.copilot.sdk.CopilotSession#getUi()
* @since 1.0.0
*/
public interface SessionUiApi {
/**
* Shows a generic elicitation dialog with a custom schema.
*
* @param params
* the elicitation parameters including message and schema
* @return a future that resolves with the {@link ElicitationResult}
* @throws IllegalStateException
* if the host does not support elicitation
*/
CompletableFuture<ElicitationResult> elicitation(ElicitationParams params);
/**
* Shows a confirmation dialog and returns the user's boolean answer.
* <p>
* Returns {@code false} if the user declines or cancels.
*
* @param message
* the message to display
* @return a future that resolves to {@code true} if the user confirmed
* @throws IllegalStateException
* if the host does not support elicitation
*/
CompletableFuture<Boolean> confirm(String message);
/**
* Shows a selection dialog with the given options.
* <p>
* Returns the selected value, or {@code null} if the user declines/cancels.
*
* @param message
* the message to display
* @param options
* the options to present
* @return a future that resolves to the selected string, or {@code null}
* @throws IllegalStateException
* if the host does not support elicitation
*/
CompletableFuture<String> select(String message, String[] options);
/**
* Shows a text input dialog.
* <p>
* Returns the entered text, or {@code null} if the user declines/cancels.
*
* @param message
* the message to display
* @param options
* optional input field options, or {@code null}
* @return a future that resolves to the entered string, or {@code null}
* @throws IllegalStateException
* if the host does not support elicitation
*/
CompletableFuture<String> input(String message, InputOptions options);
}