Skip to content

Commit 5ffe1c5

Browse files
committed
Add experimental commands API and related structures across multiple languages
1 parent 0f8d9d4 commit 5ffe1c5

10 files changed

Lines changed: 224 additions & 1 deletion

File tree

dotnet/src/Generated/Rpc.cs

Lines changed: 27 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

go/rpc/zrpc.go

Lines changed: 25 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) Microsoft Corporation. All rights reserved.
3+
*--------------------------------------------------------------------------------------------*/
4+
5+
// AUTO-GENERATED FILE - DO NOT EDIT
6+
// Generated from: api.schema.json
7+
8+
package com.github.copilot.generated.rpc;
9+
10+
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
11+
import com.fasterxml.jackson.annotation.JsonInclude;
12+
import com.fasterxml.jackson.annotation.JsonProperty;
13+
import com.github.copilot.CopilotExperimental;
14+
import java.util.List;
15+
import javax.annotation.processing.Generated;
16+
17+
/**
18+
* Slash commands available in the session, after applying any include/exclude filters.
19+
*
20+
* @apiNote This method is experimental and may change in a future version.
21+
* @since 1.0.0
22+
*/
23+
@CopilotExperimental
24+
@javax.annotation.processing.Generated("copilot-sdk-codegen")
25+
@JsonInclude(JsonInclude.Include.NON_NULL)
26+
@JsonIgnoreProperties(ignoreUnknown = true)
27+
public record CommandsListResult(
28+
/** Commands available in this session */
29+
@JsonProperty("commands") List<SlashCommandInfo> commands
30+
) {
31+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) Microsoft Corporation. All rights reserved.
3+
*--------------------------------------------------------------------------------------------*/
4+
5+
// AUTO-GENERATED FILE - DO NOT EDIT
6+
// Generated from: api.schema.json
7+
8+
package com.github.copilot.generated.rpc;
9+
10+
import com.github.copilot.CopilotExperimental;
11+
import java.util.concurrent.CompletableFuture;
12+
import javax.annotation.processing.Generated;
13+
14+
/**
15+
* API methods for the {@code commands} namespace.
16+
*
17+
* @since 1.0.0
18+
*/
19+
@javax.annotation.processing.Generated("copilot-sdk-codegen")
20+
public final class ServerCommandsApi {
21+
22+
private final RpcCaller caller;
23+
24+
/** @param caller the RPC transport function */
25+
ServerCommandsApi(RpcCaller caller) {
26+
this.caller = caller;
27+
}
28+
29+
/**
30+
* Slash commands available in the session, after applying any include/exclude filters.
31+
*
32+
* @apiNote This method is experimental and may change in a future version.
33+
* @since 1.0.0
34+
*/
35+
@CopilotExperimental
36+
public CompletableFuture<CommandsListResult> list() {
37+
return caller.invoke("commands.list", java.util.Map.of(), CommandsListResult.class);
38+
}
39+
40+
}

java/src/generated/java/com/github/copilot/generated/rpc/ServerRpc.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ public final class ServerRpc {
4343
public final ServerAgentsApi agents;
4444
/** API methods for the {@code instructions} namespace. */
4545
public final ServerInstructionsApi instructions;
46+
/** API methods for the {@code commands} namespace. */
47+
public final ServerCommandsApi commands;
4648
/** API methods for the {@code user} namespace. */
4749
public final ServerUserApi user;
4850
/** API methods for the {@code runtime} namespace. */
@@ -72,6 +74,7 @@ public ServerRpc(RpcCaller caller) {
7274
this.skills = new ServerSkillsApi(caller);
7375
this.agents = new ServerAgentsApi(caller);
7476
this.instructions = new ServerInstructionsApi(caller);
77+
this.commands = new ServerCommandsApi(caller);
7578
this.user = new ServerUserApi(caller);
7679
this.runtime = new ServerRuntimeApi(caller);
7780
this.sessionFs = new ServerSessionFsApi(caller);

nodejs/src/generated/rpc.ts

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

nodejs/test/e2e/rpc_server.e2e.test.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,26 @@ describe("Server-scoped RPC", async () => {
187187
}
188188
});
189189

190+
it("should call rpc commands list with well-known session-start commands", async () => {
191+
await client.start();
192+
const result = await client.rpc.commands.list();
193+
expect(result.commands).toBeDefined();
194+
expect(result.commands.length).toBeGreaterThan(0);
195+
196+
const names = result.commands.map((command) => command.name);
197+
// Well-known commands that work as the first message in a new session.
198+
expect(names).toContain("plan");
199+
expect(names).toContain("env");
200+
// Commands that require an active session must not be listed.
201+
expect(names).not.toContain("compact");
202+
expect(names).not.toContain("usage");
203+
204+
for (const command of result.commands) {
205+
expect(command.name).toBeTruthy();
206+
expect(command.kind).toBe("builtin");
207+
}
208+
});
209+
190210
it("should call rpc sessionFs setProvider with typed result", async () => {
191211
const fsClient = createClientWithEnv({});
192212
await fsClient.start();

python/copilot/generated/rpc.py

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rust/src/generated/api_types.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ pub mod rpc_methods {
9292
pub const INSTRUCTIONS_DISCOVER: &str = "instructions.discover";
9393
/// `instructions.getDiscoveryPaths`
9494
pub const INSTRUCTIONS_GETDISCOVERYPATHS: &str = "instructions.getDiscoveryPaths";
95+
/// `commands.list`
96+
pub const COMMANDS_LIST: &str = "commands.list";
9597
/// `user.settings.reload`
9698
pub const USER_SETTINGS_RELOAD: &str = "user.settings.reload";
9799
/// `user.settings.get`
@@ -15476,6 +15478,21 @@ pub struct InstructionsGetDiscoveryPathsResult {
1547615478
pub paths: Vec<InstructionDiscoveryPath>,
1547715479
}
1547815480

15481+
/// Slash commands available in the session, after applying any include/exclude filters.
15482+
///
15483+
/// <div class="warning">
15484+
///
15485+
/// **Experimental.** This type is part of an experimental wire-protocol surface
15486+
/// and may change or be removed in future SDK or CLI releases.
15487+
///
15488+
/// </div>
15489+
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
15490+
#[serde(rename_all = "camelCase")]
15491+
pub struct CommandsListResult {
15492+
/// Commands available in this session
15493+
pub commands: Vec<SlashCommandInfo>,
15494+
}
15495+
1547915496
/// Result of opening a session.
1548015497
///
1548115498
/// <div class="warning">

rust/src/generated/rpc.rs

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,13 @@ impl<'a> ClientRpc<'a> {
4343
}
4444
}
4545

46+
/// `commands.*` sub-namespace.
47+
pub fn commands(&self) -> ClientRpcCommands<'a> {
48+
ClientRpcCommands {
49+
client: self.client,
50+
}
51+
}
52+
4653
/// `instructions.*` sub-namespace.
4754
pub fn instructions(&self) -> ClientRpcInstructions<'a> {
4855
ClientRpcInstructions {
@@ -457,6 +464,38 @@ impl<'a> ClientRpcAgents<'a> {
457464
}
458465
}
459466

467+
/// `commands.*` RPCs.
468+
#[derive(Clone, Copy)]
469+
pub struct ClientRpcCommands<'a> {
470+
pub(crate) client: &'a Client,
471+
}
472+
473+
impl<'a> ClientRpcCommands<'a> {
474+
/// Lists the well-known built-in slash commands that work as the first message in a new session (e.g. /plan, /env), without requiring an active session. Commands that depend on session state, authentication, or a synced session are omitted.
475+
///
476+
/// Wire method: `commands.list`.
477+
///
478+
/// # Returns
479+
///
480+
/// Slash commands available in the session, after applying any include/exclude filters.
481+
///
482+
/// <div class="warning">
483+
///
484+
/// **Experimental.** This API is part of an experimental wire-protocol surface
485+
/// and may change or be removed in future SDK or CLI releases. Pin both the
486+
/// SDK and CLI versions if your code depends on it.
487+
///
488+
/// </div>
489+
pub async fn list(&self) -> Result<CommandList, Error> {
490+
let wire_params = serde_json::json!({});
491+
let _value = self
492+
.client
493+
.call(rpc_methods::COMMANDS_LIST, Some(wire_params))
494+
.await?;
495+
Ok(serde_json::from_value(_value)?)
496+
}
497+
}
498+
460499
/// `instructions.*` RPCs.
461500
#[derive(Clone, Copy)]
462501
pub struct ClientRpcInstructions<'a> {

0 commit comments

Comments
 (0)