Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions dotnet/src/Client.cs
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,7 @@ public async Task<CopilotSession> CreateSessionAsync(SessionConfig config, Cance
config.CustomAgents,
config.Agent,
config.ConfigDir,
config.EnableConfigDiscovery,
config.SkillDirectories,
config.DisabledSkills,
config.InfiniteSessions,
Expand Down Expand Up @@ -618,6 +619,7 @@ public async Task<CopilotSession> ResumeSessionAsync(string sessionId, ResumeSes
hasHooks ? true : null,
config.WorkingDirectory,
config.ConfigDir,
config.EnableConfigDiscovery,
config.DisableResume is true ? true : null,
config.Streaming is true ? true : null,
config.McpServers,
Expand Down Expand Up @@ -1640,6 +1642,7 @@ internal record CreateSessionRequest(
List<CustomAgentConfig>? CustomAgents,
string? Agent,
string? ConfigDir,
bool? EnableConfigDiscovery,
List<string>? SkillDirectories,
List<string>? DisabledSkills,
InfiniteSessionConfig? InfiniteSessions,
Expand Down Expand Up @@ -1686,6 +1689,7 @@ internal record ResumeSessionRequest(
bool? Hooks,
string? WorkingDirectory,
string? ConfigDir,
bool? EnableConfigDiscovery,
bool? DisableResume,
bool? Streaming,
Dictionary<string, object>? McpServers,
Expand Down
28 changes: 28 additions & 0 deletions dotnet/src/Types.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1603,6 +1603,7 @@ protected SessionConfig(SessionConfig? other)
CustomAgents = other.CustomAgents is not null ? [.. other.CustomAgents] : null;
Agent = other.Agent;
DisabledSkills = other.DisabledSkills is not null ? [.. other.DisabledSkills] : null;
EnableConfigDiscovery = other.EnableConfigDiscovery;
ExcludedTools = other.ExcludedTools is not null ? [.. other.ExcludedTools] : null;
Hooks = other.Hooks;
InfiniteSessions = other.InfiniteSessions;
Expand Down Expand Up @@ -1660,6 +1661,19 @@ protected SessionConfig(SessionConfig? other)
/// </summary>
public string? ConfigDir { get; set; }

/// <summary>
/// When <see langword="true"/>, automatically discovers MCP server configurations
/// (e.g. <c>.mcp.json</c>, <c>.vscode/mcp.json</c>) and skill directories from
/// the working directory and merges them with any explicitly provided
/// <see cref="McpServers"/> and <see cref="SkillDirectories"/>, with explicit
/// values taking precedence on name collision.
/// <para>
/// Custom instruction files (<c>.github/copilot-instructions.md</c>, <c>AGENTS.md</c>, etc.)
/// are always loaded from the working directory regardless of this setting.
/// </para>
/// </summary>
public bool? EnableConfigDiscovery { get; set; }

/// <summary>
/// Custom tool functions available to the language model during the session.
/// </summary>
Expand Down Expand Up @@ -1817,6 +1831,7 @@ protected ResumeSessionConfig(ResumeSessionConfig? other)
Agent = other.Agent;
DisabledSkills = other.DisabledSkills is not null ? [.. other.DisabledSkills] : null;
DisableResume = other.DisableResume;
EnableConfigDiscovery = other.EnableConfigDiscovery;
ExcludedTools = other.ExcludedTools is not null ? [.. other.ExcludedTools] : null;
Hooks = other.Hooks;
InfiniteSessions = other.InfiniteSessions;
Expand Down Expand Up @@ -1929,6 +1944,19 @@ protected ResumeSessionConfig(ResumeSessionConfig? other)
/// </summary>
public string? ConfigDir { get; set; }

/// <summary>
/// When <see langword="true"/>, automatically discovers MCP server configurations
/// (e.g. <c>.mcp.json</c>, <c>.vscode/mcp.json</c>) and skill directories from
/// the working directory and merges them with any explicitly provided
/// <see cref="McpServers"/> and <see cref="SkillDirectories"/>, with explicit
/// values taking precedence on name collision.
/// <para>
/// Custom instruction files (<c>.github/copilot-instructions.md</c>, <c>AGENTS.md</c>, etc.)
/// are always loaded from the working directory regardless of this setting.
/// </para>
/// </summary>
public bool? EnableConfigDiscovery { get; set; }

/// <summary>
/// When true, the session.resume event is not emitted.
/// Default: false (resume event is emitted).
Expand Down
6 changes: 6 additions & 0 deletions go/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,9 @@ func (c *Client) CreateSession(ctx context.Context, config *SessionConfig) (*Ses
req.ClientName = config.ClientName
req.ReasoningEffort = config.ReasoningEffort
req.ConfigDir = config.ConfigDir
if config.EnableConfigDiscovery {
req.EnableConfigDiscovery = Bool(true)
}
req.Tools = config.Tools
wireSystemMessage, transformCallbacks := extractTransformCallbacks(config.SystemMessage)
req.SystemMessage = wireSystemMessage
Expand Down Expand Up @@ -754,6 +757,9 @@ func (c *Client) ResumeSessionWithOptions(ctx context.Context, sessionID string,
}
req.WorkingDirectory = config.WorkingDirectory
req.ConfigDir = config.ConfigDir
if config.EnableConfigDiscovery {
req.EnableConfigDiscovery = Bool(true)
}
if config.DisableResume {
req.DisableResume = Bool(true)
}
Expand Down
126 changes: 71 additions & 55 deletions go/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,13 @@ type SessionConfig struct {
// ConfigDir overrides the default configuration directory location.
// When specified, the session will use this directory for storing config and state.
ConfigDir string
// EnableConfigDiscovery, when true, automatically discovers MCP server configurations
// (e.g. .mcp.json, .vscode/mcp.json) and skill directories from the working directory
// and merges them with any explicitly provided MCPServers and SkillDirectories, with
// explicit values taking precedence on name collision.
// Custom instruction files (.github/copilot-instructions.md, AGENTS.md, etc.) are
// always loaded from the working directory regardless of this setting.
EnableConfigDiscovery bool
// Tools exposes caller-implemented tools to the CLI
Tools []Tool
// SystemMessage configures system message customization
Expand Down Expand Up @@ -692,6 +699,13 @@ type ResumeSessionConfig struct {
WorkingDirectory string
// ConfigDir overrides the default configuration directory location.
ConfigDir string
// EnableConfigDiscovery, when true, automatically discovers MCP server configurations
// (e.g. .mcp.json, .vscode/mcp.json) and skill directories from the working directory
// and merges them with any explicitly provided MCPServers and SkillDirectories, with
// explicit values taking precedence on name collision.
// Custom instruction files (.github/copilot-instructions.md, AGENTS.md, etc.) are
// always loaded from the working directory regardless of this setting.
EnableConfigDiscovery bool
// Streaming enables 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.
Expand Down Expand Up @@ -889,33 +903,34 @@ type SessionLifecycleHandler func(event SessionLifecycleEvent)

// createSessionRequest is the request for session.create
type createSessionRequest struct {
Model string `json:"model,omitempty"`
SessionID string `json:"sessionId,omitempty"`
ClientName string `json:"clientName,omitempty"`
ReasoningEffort string `json:"reasoningEffort,omitempty"`
Tools []Tool `json:"tools,omitempty"`
SystemMessage *SystemMessageConfig `json:"systemMessage,omitempty"`
AvailableTools []string `json:"availableTools"`
ExcludedTools []string `json:"excludedTools,omitempty"`
Provider *ProviderConfig `json:"provider,omitempty"`
ModelCapabilities *rpc.ModelCapabilitiesOverride `json:"modelCapabilities,omitempty"`
RequestPermission *bool `json:"requestPermission,omitempty"`
RequestUserInput *bool `json:"requestUserInput,omitempty"`
Hooks *bool `json:"hooks,omitempty"`
WorkingDirectory string `json:"workingDirectory,omitempty"`
Streaming *bool `json:"streaming,omitempty"`
MCPServers map[string]MCPServerConfig `json:"mcpServers,omitempty"`
EnvValueMode string `json:"envValueMode,omitempty"`
CustomAgents []CustomAgentConfig `json:"customAgents,omitempty"`
Agent string `json:"agent,omitempty"`
ConfigDir string `json:"configDir,omitempty"`
SkillDirectories []string `json:"skillDirectories,omitempty"`
DisabledSkills []string `json:"disabledSkills,omitempty"`
InfiniteSessions *InfiniteSessionConfig `json:"infiniteSessions,omitempty"`
Commands []wireCommand `json:"commands,omitempty"`
RequestElicitation *bool `json:"requestElicitation,omitempty"`
Traceparent string `json:"traceparent,omitempty"`
Tracestate string `json:"tracestate,omitempty"`
Model string `json:"model,omitempty"`
SessionID string `json:"sessionId,omitempty"`
ClientName string `json:"clientName,omitempty"`
ReasoningEffort string `json:"reasoningEffort,omitempty"`
Tools []Tool `json:"tools,omitempty"`
SystemMessage *SystemMessageConfig `json:"systemMessage,omitempty"`
AvailableTools []string `json:"availableTools"`
ExcludedTools []string `json:"excludedTools,omitempty"`
Provider *ProviderConfig `json:"provider,omitempty"`
ModelCapabilities *rpc.ModelCapabilitiesOverride `json:"modelCapabilities,omitempty"`
RequestPermission *bool `json:"requestPermission,omitempty"`
RequestUserInput *bool `json:"requestUserInput,omitempty"`
Hooks *bool `json:"hooks,omitempty"`
WorkingDirectory string `json:"workingDirectory,omitempty"`
Streaming *bool `json:"streaming,omitempty"`
MCPServers map[string]MCPServerConfig `json:"mcpServers,omitempty"`
EnvValueMode string `json:"envValueMode,omitempty"`
CustomAgents []CustomAgentConfig `json:"customAgents,omitempty"`
Agent string `json:"agent,omitempty"`
ConfigDir string `json:"configDir,omitempty"`
EnableConfigDiscovery *bool `json:"enableConfigDiscovery,omitempty"`
SkillDirectories []string `json:"skillDirectories,omitempty"`
DisabledSkills []string `json:"disabledSkills,omitempty"`
InfiniteSessions *InfiniteSessionConfig `json:"infiniteSessions,omitempty"`
Commands []wireCommand `json:"commands,omitempty"`
RequestElicitation *bool `json:"requestElicitation,omitempty"`
Traceparent string `json:"traceparent,omitempty"`
Tracestate string `json:"tracestate,omitempty"`
}

// wireCommand is the wire representation of a command (name + description only, no handler).
Expand All @@ -933,34 +948,35 @@ type createSessionResponse struct {

// resumeSessionRequest is the request for session.resume
type resumeSessionRequest struct {
SessionID string `json:"sessionId"`
ClientName string `json:"clientName,omitempty"`
Model string `json:"model,omitempty"`
ReasoningEffort string `json:"reasoningEffort,omitempty"`
Tools []Tool `json:"tools,omitempty"`
SystemMessage *SystemMessageConfig `json:"systemMessage,omitempty"`
AvailableTools []string `json:"availableTools"`
ExcludedTools []string `json:"excludedTools,omitempty"`
Provider *ProviderConfig `json:"provider,omitempty"`
ModelCapabilities *rpc.ModelCapabilitiesOverride `json:"modelCapabilities,omitempty"`
RequestPermission *bool `json:"requestPermission,omitempty"`
RequestUserInput *bool `json:"requestUserInput,omitempty"`
Hooks *bool `json:"hooks,omitempty"`
WorkingDirectory string `json:"workingDirectory,omitempty"`
ConfigDir string `json:"configDir,omitempty"`
DisableResume *bool `json:"disableResume,omitempty"`
Streaming *bool `json:"streaming,omitempty"`
MCPServers map[string]MCPServerConfig `json:"mcpServers,omitempty"`
EnvValueMode string `json:"envValueMode,omitempty"`
CustomAgents []CustomAgentConfig `json:"customAgents,omitempty"`
Agent string `json:"agent,omitempty"`
SkillDirectories []string `json:"skillDirectories,omitempty"`
DisabledSkills []string `json:"disabledSkills,omitempty"`
InfiniteSessions *InfiniteSessionConfig `json:"infiniteSessions,omitempty"`
Commands []wireCommand `json:"commands,omitempty"`
RequestElicitation *bool `json:"requestElicitation,omitempty"`
Traceparent string `json:"traceparent,omitempty"`
Tracestate string `json:"tracestate,omitempty"`
SessionID string `json:"sessionId"`
ClientName string `json:"clientName,omitempty"`
Model string `json:"model,omitempty"`
ReasoningEffort string `json:"reasoningEffort,omitempty"`
Tools []Tool `json:"tools,omitempty"`
SystemMessage *SystemMessageConfig `json:"systemMessage,omitempty"`
AvailableTools []string `json:"availableTools"`
ExcludedTools []string `json:"excludedTools,omitempty"`
Provider *ProviderConfig `json:"provider,omitempty"`
ModelCapabilities *rpc.ModelCapabilitiesOverride `json:"modelCapabilities,omitempty"`
RequestPermission *bool `json:"requestPermission,omitempty"`
RequestUserInput *bool `json:"requestUserInput,omitempty"`
Hooks *bool `json:"hooks,omitempty"`
WorkingDirectory string `json:"workingDirectory,omitempty"`
ConfigDir string `json:"configDir,omitempty"`
EnableConfigDiscovery *bool `json:"enableConfigDiscovery,omitempty"`
DisableResume *bool `json:"disableResume,omitempty"`
Streaming *bool `json:"streaming,omitempty"`
MCPServers map[string]MCPServerConfig `json:"mcpServers,omitempty"`
EnvValueMode string `json:"envValueMode,omitempty"`
CustomAgents []CustomAgentConfig `json:"customAgents,omitempty"`
Agent string `json:"agent,omitempty"`
SkillDirectories []string `json:"skillDirectories,omitempty"`
DisabledSkills []string `json:"disabledSkills,omitempty"`
InfiniteSessions *InfiniteSessionConfig `json:"infiniteSessions,omitempty"`
Commands []wireCommand `json:"commands,omitempty"`
RequestElicitation *bool `json:"requestElicitation,omitempty"`
Traceparent string `json:"traceparent,omitempty"`
Tracestate string `json:"tracestate,omitempty"`
}

// resumeSessionResponse is the response from session.resume
Expand Down
2 changes: 2 additions & 0 deletions nodejs/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -742,6 +742,7 @@ export class CopilotClient {
customAgents: config.customAgents,
agent: config.agent,
configDir: config.configDir,
enableConfigDiscovery: config.enableConfigDiscovery,
skillDirectories: config.skillDirectories,
disabledSkills: config.disabledSkills,
infiniteSessions: config.infiniteSessions,
Expand Down Expand Up @@ -873,6 +874,7 @@ export class CopilotClient {
hooks: !!(config.hooks && Object.values(config.hooks).some(Boolean)),
workingDirectory: config.workingDirectory,
configDir: config.configDir,
enableConfigDiscovery: config.enableConfigDiscovery,
streaming: config.streaming,
mcpServers: config.mcpServers,
envValueMode: "direct",
Expand Down
14 changes: 14 additions & 0 deletions nodejs/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1074,6 +1074,19 @@ export interface SessionConfig {
*/
configDir?: string;

/**
* When true, automatically discovers MCP server configurations (e.g. `.mcp.json`,
* `.vscode/mcp.json`) and skill directories from the working directory and merges
* them with any explicitly provided `mcpServers` and `skillDirectories`, with
* explicit values taking precedence on name collision.
*
* Note: custom instruction files (`.github/copilot-instructions.md`, `AGENTS.md`, etc.)
* are always loaded from the working directory regardless of this setting.
*
* @default false
*/
enableConfigDiscovery?: boolean;

/**
* Tools exposed to the CLI server
*/
Expand Down Expand Up @@ -1226,6 +1239,7 @@ export type ResumeSessionConfig = Pick<
| "hooks"
| "workingDirectory"
| "configDir"
| "enableConfigDiscovery"
| "mcpServers"
| "customAgents"
| "agent"
Expand Down
Loading
Loading