MCPcopy Index your code
hub / github.com/github/copilot-sdk / updateSessionOptionsForMode

Method updateSessionOptionsForMode

nodejs/src/client.ts:1249–1287  ·  view source on GitHub ↗

* Mode-specific options applied via session.options.update after create/resume. * * In empty mode, defaults the four overridable feature flags to safe values * (caller values from `config` win). `installedPlugins=[]` is unconditional * in empty mode — apps that need custom plugin

(
        session: CopilotSession,
        config: SessionConfigBase
    )

Source from the content-addressed store, hash-verified

1247 * in empty mode — apps that need custom plugins should switch modes.
1248 */
1249 private async updateSessionOptionsForMode(
1250 session: CopilotSession,
1251 config: SessionConfigBase
1252 ): Promise<void> {
1253 const patch: SessionUpdateOptionsParams = {};
1254 if (this.options.mode === "empty") {
1255 patch.skipCustomInstructions = config.skipCustomInstructions ?? true;
1256 patch.customAgentsLocalOnly = config.customAgentsLocalOnly ?? true;
1257 patch.coauthorEnabled = config.coauthorEnabled ?? false;
1258 patch.manageScheduleEnabled = config.manageScheduleEnabled ?? false;
1259 patch.installedPlugins = [];
1260 } else {
1261 if (config.skipCustomInstructions !== undefined)
1262 patch.skipCustomInstructions = config.skipCustomInstructions;
1263 if (config.customAgentsLocalOnly !== undefined)
1264 patch.customAgentsLocalOnly = config.customAgentsLocalOnly;
1265 if (config.coauthorEnabled !== undefined)
1266 patch.coauthorEnabled = config.coauthorEnabled;
1267 if (config.manageScheduleEnabled !== undefined)
1268 patch.manageScheduleEnabled = config.manageScheduleEnabled;
1269 }
1270 if (Object.keys(patch).length === 0) {
1271 return;
1272 }
1273 try {
1274 await session.rpc.options.update(patch);
1275 } catch (e) {
1276 // The runtime session exists but the post-create options
1277 // patch failed — best-effort disconnect so we don't leak
1278 // it (in empty mode it would otherwise keep running with
1279 // permissive defaults).
1280 try {
1281 await session.disconnect();
1282 } catch {
1283 // Swallow: original error is the one the caller needs.
1284 }
1285 throw e;
1286 }
1287 }
1288
1289 async createSession(config: SessionConfig): Promise<CopilotSession> {
1290 if (!this.connection) {

Callers 2

createSessionMethod · 0.95
resumeSessionMethod · 0.95

Calls 2

updateMethod · 0.45
disconnectMethod · 0.45

Tested by

no test coverage detected