You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: snapshot/advanced.html
+113-1Lines changed: 113 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -1215,7 +1215,119 @@ <h2>OpenTelemetry</h2>
1215
1215
<td>Whether to capture message content</td></tr></tbody>
1216
1216
</table>
1217
1217
1218
-
<p>See <ahref="apidocs/com/github/copilot/sdk/json/TelemetryConfig.html">TelemetryConfig</a> Javadoc for details.</p><hr/></section><section><aid="Next_Steps"></a>
1218
+
<p>See <ahref="apidocs/com/github/copilot/sdk/json/TelemetryConfig.html">TelemetryConfig</a> Javadoc for details.</p><hr/></section><section><aid="Slash_Commands"></a>
1219
+
<h2>Slash Commands</h2>
1220
+
<p>Register custom slash commands that users can invoke from the CLI TUI with <code>/commandname</code>.</p><section><aid="Registering_Commands"></a>
1221
+
<h3>Registering Commands</h3>
1222
+
1223
+
<preclass="prettyprint"><codeclass="language-java">var config = new SessionConfig()
.setDescription("Deploy the current branch")
1229
+
.setHandler(context -> {
1230
+
System.out.println("Deploying with args: " + context.getArgs());
1231
+
// perform deployment ...
1232
+
return CompletableFuture.completedFuture(null);
1233
+
}),
1234
+
new CommandDefinition()
1235
+
.setName("rollback")
1236
+
.setDescription("Roll back the last deployment")
1237
+
.setHandler(context -> {
1238
+
// perform rollback ...
1239
+
return CompletableFuture.completedFuture(null);
1240
+
})
1241
+
));
1242
+
1243
+
try (CopilotClient client = new CopilotClient()) {
1244
+
client.start().get();
1245
+
var session = client.createSession(config).get();
1246
+
// Users can now type /deploy or /rollback in the TUI
1247
+
}
1248
+
</code></pre>
1249
+
<p>Each <code>CommandDefinition</code> requires a <code>name</code> (without the leading <code>/</code>), an optional <code>description</code> shown in the TUI's command completion UI, and a <code>CommandHandler</code> that is invoked when the user executes the command.</p>
1250
+
<p>The <code>CommandContext</code> passed to the handler provides:</p>
1251
+
<ul>
1252
+
1253
+
<li><code>getSessionId()</code> — the ID of the session where the command was invoked</li>
1254
+
<li><code>getCommand()</code> — the full command text (e.g., <code>/deploy production</code>)</li>
1255
+
<li><code>getCommandName()</code> — command name without the leading <code>/</code> (e.g., <code>deploy</code>)</li>
1256
+
<li><code>getArgs()</code> — the argument string after the command name (e.g., <code>production</code>)</li>
var content = Map.of("confirmed", true);
1274
+
return CompletableFuture.completedFuture(
1275
+
new ElicitationResult()
1276
+
.setAction(ElicitationResultAction.ACCEPT)
1277
+
.setContent(content)
1278
+
);
1279
+
});
1280
+
</code></pre>
1281
+
<p>When <code>onElicitationRequest</code> is set, the SDK reports elicitation as a supported capability and the server will route elicitation requests to your handler.</p></section><section><aid="Session_Capabilities"></a>
1282
+
<h3>Session Capabilities</h3>
1283
+
<p>After <code>createSession</code> or <code>resumeSession</code>, check <code>session.getCapabilities()</code> to see what the host supports:</p>
if (caps.getUi() != null && Boolean.TRUE.equals(caps.getUi().getElicitation())) {
1289
+
System.out.println("Elicitation is supported");
1290
+
}
1291
+
</code></pre>
1292
+
<p>Capabilities are updated in real time when a <code>capabilities.changed</code> event is received.</p></section><section><aid="Outgoing_Elicitation_via_session.getUi.28.29"></a>
1293
+
<h3>Outgoing Elicitation via <code>session.getUi()</code></h3>
1294
+
<p>If the host reports elicitation support, you can call the convenience methods on <code>session.getUi()</code>:</p>
<p>All <code>getUi()</code> methods throw <code>IllegalStateException</code> if the host does not support elicitation. Always check capabilities first.</p><hr/></section></section><section><aid="Getting_Session_Metadata_by_ID"></a>
1319
+
<h2>Getting Session Metadata by ID</h2>
1320
+
<p>Retrieve metadata for a specific session without listing all sessions:</p>
System.out.println("Session not found");
1328
+
}
1329
+
</code></pre>
1330
+
<p>This is more efficient than <code>listSessions()</code> when you already know the session ID, as it performs a direct O(1) lookup instead of scanning all sessions.</p><hr/></section><section><aid="Next_Steps"></a>
0 commit comments