Skip to content

Commit 1e27740

Browse files
EvanBoyleCopilot
andcommitted
Expose loadCliConfig in Node SDK
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent ea90f07 commit 1e27740

3 files changed

Lines changed: 52 additions & 0 deletions

File tree

nodejs/src/client.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -616,6 +616,7 @@ export class CopilotClient {
616616
customAgents: config.customAgents,
617617
agent: config.agent,
618618
configDir: config.configDir,
619+
loadCliConfig: config.loadCliConfig,
619620
skillDirectories: config.skillDirectories,
620621
disabledSkills: config.disabledSkills,
621622
infiniteSessions: config.infiniteSessions,
@@ -722,6 +723,7 @@ export class CopilotClient {
722723
envValueMode: "direct",
723724
customAgents: config.customAgents,
724725
agent: config.agent,
726+
loadCliConfig: config.loadCliConfig,
725727
skillDirectories: config.skillDirectories,
726728
disabledSkills: config.disabledSkills,
727729
infiniteSessions: config.infiniteSessions,

nodejs/src/types.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -736,6 +736,15 @@ export interface SessionConfig {
736736
*/
737737
configDir?: string;
738738

739+
/**
740+
* When true, the runtime loads CLI-style extensibility from the current environment.
741+
* This includes merged MCP config, default GitHub MCP behavior, skills, custom agents,
742+
* installed plugins, and other config-backed session options.
743+
* Explicit per-request settings are merged on top of discovered config.
744+
* @default false
745+
*/
746+
loadCliConfig?: boolean;
747+
739748
/**
740749
* Tools exposed to the CLI server
741750
*/
@@ -865,6 +874,7 @@ export type ResumeSessionConfig = Pick<
865874
| "hooks"
866875
| "workingDirectory"
867876
| "configDir"
877+
| "loadCliConfig"
868878
| "mcpServers"
869879
| "customAgents"
870880
| "agent"

nodejs/test/client.test.ts

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,46 @@ describe("CopilotClient", () => {
9797
spy.mockRestore();
9898
});
9999

100+
it("forwards loadCliConfig in session.create request", async () => {
101+
const client = new CopilotClient();
102+
await client.start();
103+
onTestFinished(() => client.forceStop());
104+
105+
const spy = vi.spyOn((client as any).connection!, "sendRequest");
106+
await client.createSession({ loadCliConfig: true, onPermissionRequest: approveAll });
107+
108+
expect(spy).toHaveBeenCalledWith(
109+
"session.create",
110+
expect.objectContaining({ loadCliConfig: true })
111+
);
112+
spy.mockRestore();
113+
});
114+
115+
it("forwards loadCliConfig in session.resume request", async () => {
116+
const client = new CopilotClient();
117+
await client.start();
118+
onTestFinished(() => client.forceStop());
119+
120+
const session = await client.createSession({ onPermissionRequest: approveAll });
121+
const spy = vi
122+
.spyOn((client as any).connection!, "sendRequest")
123+
.mockImplementation(async (method: string, params: any) => {
124+
if (method === "session.resume") return { sessionId: params.sessionId };
125+
throw new Error(`Unexpected method: ${method}`);
126+
});
127+
128+
await client.resumeSession(session.sessionId, {
129+
loadCliConfig: true,
130+
onPermissionRequest: approveAll,
131+
});
132+
133+
expect(spy).toHaveBeenCalledWith(
134+
"session.resume",
135+
expect.objectContaining({ sessionId: session.sessionId, loadCliConfig: true })
136+
);
137+
spy.mockRestore();
138+
});
139+
100140
it("sends session.model.switchTo RPC with correct params", async () => {
101141
const client = new CopilotClient();
102142
await client.start();

0 commit comments

Comments
 (0)