From 1e277409e3a0112576d004a1b9a06409bef8dfc9 Mon Sep 17 00:00:00 2001 From: Evan Boyle Date: Fri, 13 Mar 2026 22:21:29 -0700 Subject: [PATCH] Expose loadCliConfig in Node SDK Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- nodejs/src/client.ts | 2 ++ nodejs/src/types.ts | 10 ++++++++++ nodejs/test/client.test.ts | 40 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 52 insertions(+) diff --git a/nodejs/src/client.ts b/nodejs/src/client.ts index b8e7b31d..351df3c2 100644 --- a/nodejs/src/client.ts +++ b/nodejs/src/client.ts @@ -616,6 +616,7 @@ export class CopilotClient { customAgents: config.customAgents, agent: config.agent, configDir: config.configDir, + loadCliConfig: config.loadCliConfig, skillDirectories: config.skillDirectories, disabledSkills: config.disabledSkills, infiniteSessions: config.infiniteSessions, @@ -722,6 +723,7 @@ export class CopilotClient { envValueMode: "direct", customAgents: config.customAgents, agent: config.agent, + loadCliConfig: config.loadCliConfig, skillDirectories: config.skillDirectories, disabledSkills: config.disabledSkills, infiniteSessions: config.infiniteSessions, diff --git a/nodejs/src/types.ts b/nodejs/src/types.ts index 9576b692..e037094b 100644 --- a/nodejs/src/types.ts +++ b/nodejs/src/types.ts @@ -736,6 +736,15 @@ export interface SessionConfig { */ configDir?: string; + /** + * When true, the runtime loads CLI-style extensibility from the current environment. + * This includes merged MCP config, default GitHub MCP behavior, skills, custom agents, + * installed plugins, and other config-backed session options. + * Explicit per-request settings are merged on top of discovered config. + * @default false + */ + loadCliConfig?: boolean; + /** * Tools exposed to the CLI server */ @@ -865,6 +874,7 @@ export type ResumeSessionConfig = Pick< | "hooks" | "workingDirectory" | "configDir" + | "loadCliConfig" | "mcpServers" | "customAgents" | "agent" diff --git a/nodejs/test/client.test.ts b/nodejs/test/client.test.ts index 3d13d27f..12917057 100644 --- a/nodejs/test/client.test.ts +++ b/nodejs/test/client.test.ts @@ -97,6 +97,46 @@ describe("CopilotClient", () => { spy.mockRestore(); }); + it("forwards loadCliConfig in session.create request", async () => { + const client = new CopilotClient(); + await client.start(); + onTestFinished(() => client.forceStop()); + + const spy = vi.spyOn((client as any).connection!, "sendRequest"); + await client.createSession({ loadCliConfig: true, onPermissionRequest: approveAll }); + + expect(spy).toHaveBeenCalledWith( + "session.create", + expect.objectContaining({ loadCliConfig: true }) + ); + spy.mockRestore(); + }); + + it("forwards loadCliConfig in session.resume request", async () => { + const client = new CopilotClient(); + await client.start(); + onTestFinished(() => client.forceStop()); + + const session = await client.createSession({ onPermissionRequest: approveAll }); + const spy = vi + .spyOn((client as any).connection!, "sendRequest") + .mockImplementation(async (method: string, params: any) => { + if (method === "session.resume") return { sessionId: params.sessionId }; + throw new Error(`Unexpected method: ${method}`); + }); + + await client.resumeSession(session.sessionId, { + loadCliConfig: true, + onPermissionRequest: approveAll, + }); + + expect(spy).toHaveBeenCalledWith( + "session.resume", + expect.objectContaining({ sessionId: session.sessionId, loadCliConfig: true }) + ); + spy.mockRestore(); + }); + it("sends session.model.switchTo RPC with correct params", async () => { const client = new CopilotClient(); await client.start();