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

Method startCLIServer

nodejs/src/client.ts:2169–2392  ·  view source on GitHub ↗

* Start the CLI server process

()

Source from the content-addressed store, hash-verified

2167 * Start the CLI server process
2168 */
2169 private async startCLIServer(): Promise<void> {
2170 return new Promise((resolve, reject) => {
2171 // Clear stderr buffer for fresh capture
2172 this.stderrBuffer = "";
2173
2174 const args = [...this.connectionExtraArgs, "--headless", "--no-auto-update"];
2175
2176 if (this.options.logLevel) {
2177 args.push("--log-level", this.options.logLevel);
2178 }
2179
2180 // Choose transport mode based on the resolved connection config.
2181 if (this.connectionConfig.kind === "stdio") {
2182 args.push("--stdio");
2183 } else if (this.connectionConfig.kind === "tcp") {
2184 const requestedPort = this.connectionConfig.port ?? 0;
2185 if (requestedPort > 0) {
2186 args.push("--port", requestedPort.toString());
2187 }
2188 }
2189
2190 // Add auth-related flags
2191 if (this.options.gitHubToken) {
2192 args.push("--auth-token-env", "COPILOT_SDK_AUTH_TOKEN");
2193 }
2194 if (!this.options.useLoggedInUser) {
2195 args.push("--no-auto-login");
2196 }
2197
2198 if (
2199 this.options.sessionIdleTimeoutSeconds !== undefined &&
2200 this.options.sessionIdleTimeoutSeconds > 0
2201 ) {
2202 args.push(
2203 "--session-idle-timeout",
2204 this.options.sessionIdleTimeoutSeconds.toString()
2205 );
2206 }
2207
2208 if (this.options.enableRemoteSessions) {
2209 args.push("--remote");
2210 }
2211
2212 // Suppress debug/trace output that might pollute stdout
2213 const envWithoutNodeDebug = { ...this.resolvedEnv };
2214 delete envWithoutNodeDebug.NODE_DEBUG;
2215
2216 // Set auth token in environment if provided
2217 if (this.options.gitHubToken) {
2218 envWithoutNodeDebug.COPILOT_SDK_AUTH_TOKEN = this.options.gitHubToken;
2219 }
2220
2221 if (this.effectiveConnectionToken) {
2222 envWithoutNodeDebug.COPILOT_CONNECTION_TOKEN = this.effectiveConnectionToken;
2223 }
2224
2225 if (this.options.baseDirectory) {
2226 envWithoutNodeDebug.COPILOT_HOME = this.options.baseDirectory;

Callers 1

startMethod · 0.95

Calls 6

StringFunction · 0.85
getNodeExecPathFunction · 0.85
toStringMethod · 0.80
pushMethod · 0.45
onMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected