1- # Bundled CLI Setup
1+ # Default Setup ( Bundled CLI)
22
3- Package the Copilot CLI alongside your application so users don't need to install or configure anything separately. Your app ships with everything it needs.
3+ The Node.js, Python, and .NET SDKs include the Copilot CLI as a dependency — your app ships with everything it needs, with no extra installation or configuration required .
44
5- ** Best for:** Desktop apps, standalone tools, Electron apps, distributable CLI utilities .
5+ ** Best for:** Most applications — desktop apps, standalone tools, CLI utilities, prototypes, and more .
66
77## How It Works
88
9- Instead of relying on a globally installed CLI, you include the CLI binary in your application bundle . The SDK points to your bundled copy via the ` cliPath ` option .
9+ When you install the SDK, the Copilot CLI binary is included automatically . The SDK starts it as a child process and communicates over stdio. There's nothing extra to configure .
1010
1111``` mermaid
1212flowchart TB
13- subgraph Bundle["Your Distributed App "]
13+ subgraph Bundle["Your Application "]
1414 App["Application Code"]
1515 SDK["SDK Client"]
16- CLIBin["Copilot CLI Binary<br/>(bundled )"]
16+ CLIBin["Copilot CLI Binary<br/>(included with SDK )"]
1717 end
1818
1919 App --> SDK
20- SDK -- "cliPath" -- > CLIBin
20+ SDK --> CLIBin
2121 CLIBin -- "API calls" --> Copilot["☁️ GitHub Copilot"]
2222
2323 style Bundle fill:#0d1117,stroke:#58a6ff,color:#c9d1d9
2424```
2525
2626** Key characteristics:**
27- - CLI binary ships with your app — no separate install needed
28- - You control the exact CLI version your app uses
27+ - CLI binary is included with the SDK — no separate install needed
28+ - The SDK manages the CLI version to ensure compatibility
2929- Users authenticate through your app (or use env vars / BYOK)
3030- Sessions are managed per-user on their machine
3131
32- ## Architecture: Bundled vs. Installed
33-
34- ``` mermaid
35- flowchart LR
36- subgraph Installed["Standard Setup"]
37- A1["Your App"] --> SDK1["SDK"]
38- SDK1 --> CLI1["Global CLI<br/>(/usr/local/bin/copilot)"]
39- end
40-
41- subgraph Bundled["Bundled Setup"]
42- A2["Your App"] --> SDK2["SDK"]
43- SDK2 --> CLI2["Bundled CLI<br/>(./vendor/copilot)"]
44- end
45-
46- style Installed fill:#161b22,stroke:#8b949e,color:#c9d1d9
47- style Bundled fill:#0d1117,stroke:#3fb950,color:#c9d1d9
48- ```
49-
50- ## Setup
51-
52- ### 1. Include the CLI in Your Project
53-
54- The CLI is distributed as part of the ` @github/copilot ` npm package. You can also obtain platform-specific binaries for your distribution pipeline.
55-
56- ``` bash
57- # The CLI is available from the @github/copilot package
58- npm install @github/copilot
59- ```
60-
61- ### 2. Point the SDK to Your Bundled CLI
32+ ## Quick Start
6233
6334<details open >
6435<summary ><strong >Node.js / TypeScript</strong ></summary >
6536
6637``` typescript
6738import { CopilotClient } from " @github/copilot-sdk" ;
68- import path from " path" ;
6939
70- const client = new CopilotClient ({
71- // Point to the CLI binary in your app bundle
72- cliPath: path .join (__dirname , " vendor" , " copilot" ),
73- });
40+ const client = new CopilotClient ();
7441
7542const session = await client .createSession ({ model: " gpt-4.1" });
7643const response = await session .sendAndWait ({ prompt: " Hello!" });
@@ -87,11 +54,8 @@ await client.stop();
8754``` python
8855from copilot import CopilotClient
8956from copilot.session import PermissionHandler
90- from pathlib import Path
9157
92- client = CopilotClient({
93- " cli_path" : str (Path(__file__ ).parent / " vendor" / " copilot" ),
94- })
58+ client = CopilotClient()
9559await client.start()
9660
9761session = await client.create_session(on_permission_request = PermissionHandler.approve_all, model = " gpt-4.1" )
@@ -106,6 +70,8 @@ await client.stop()
10670<details >
10771<summary ><strong >Go</strong ></summary >
10872
73+ > ** Note:** The Go SDK does not bundle the CLI. You must install the CLI separately or set ` CLIPath ` to point to an existing binary. See [ Local CLI Setup] ( ./local-cli.md ) for details.
74+
10975<!-- docs-validate: hidden -->
11076``` go
11177package main
@@ -120,9 +86,7 @@ import (
12086func main () {
12187 ctx := context.Background ()
12288
123- client := copilot.NewClient (&copilot.ClientOptions {
124- CLIPath: " ./vendor/copilot" ,
125- })
89+ client := copilot.NewClient (nil )
12690 if err := client.Start (ctx); err != nil {
12791 log.Fatal (err)
12892 }
@@ -138,9 +102,7 @@ func main() {
138102<!-- /docs-validate: hidden -->
139103
140104``` go
141- client := copilot.NewClient (&copilot.ClientOptions {
142- CLIPath :" ./vendor/copilot" ,
143- })
105+ client := copilot.NewClient (nil )
144106if err := client.Start (ctx); err != nil {
145107 log.Fatal (err)
146108}
@@ -159,11 +121,7 @@ if d, ok := response.Data.(*copilot.AssistantMessageData); ok {
159121<summary ><strong >.NET</strong ></summary >
160122
161123``` csharp
162- var client = new CopilotClient (new CopilotClientOptions
163- {
164- CliPath = Path .Combine (AppContext .BaseDirectory , " vendor" , " copilot" ),
165- });
166-
124+ await using var client = new CopilotClient ();
167125await using var session = await client .CreateSessionAsync (
168126 new SessionConfig { Model = " gpt-4.1" });
169127
@@ -206,7 +164,7 @@ client.stop().get();
206164
207165## Authentication Strategies
208166
209- When bundling, you need to decide how your users will authenticate. Here are the common patterns:
167+ You need to decide how your users will authenticate. Here are the common patterns:
210168
211169``` mermaid
212170flowchart TB
@@ -225,13 +183,11 @@ flowchart TB
225183
226184### Option A: User's Signed-In Credentials (Simplest)
227185
228- The user signs in to the CLI once, and your bundled app uses those credentials. No extra code needed — this is the default behavior.
186+ The user signs in to the CLI once, and your app uses those credentials. No extra code needed — this is the default behavior.
229187
230188``` typescript
231- const client = new CopilotClient ({
232- cliPath: path .join (__dirname , " vendor" , " copilot" ),
233- // Default: uses signed-in user credentials
234- });
189+ const client = new CopilotClient ();
190+ // Default: uses signed-in user credentials
235191```
236192
237193### Option B: Token via Environment Variable
@@ -240,7 +196,6 @@ Ship your app with instructions to set a token, or set it programmatically:
240196
241197``` typescript
242198const client = new CopilotClient ({
243- cliPath: path .join (__dirname , " vendor" , " copilot" ),
244199 env: {
245200 COPILOT_GITHUB_TOKEN: getUserToken (), // Your app provides the token
246201 },
@@ -252,9 +207,7 @@ const client = new CopilotClient({
252207If you manage your own model provider keys, users don't need GitHub accounts at all:
253208
254209``` typescript
255- const client = new CopilotClient ({
256- cliPath: path .join (__dirname , " vendor" , " copilot" ),
257- });
210+ const client = new CopilotClient ();
258211
259212const session = await client .createSession ({
260213 model: " gpt-4.1" ,
@@ -270,12 +223,10 @@ See the **[BYOK guide](../auth/byok.md)** for full details.
270223
271224## Session Management
272225
273- Bundled apps typically want named sessions so users can resume conversations:
226+ Apps typically want named sessions so users can resume conversations:
274227
275228``` typescript
276- const client = new CopilotClient ({
277- cliPath: path .join (__dirname , " vendor" , " copilot" ),
278- });
229+ const client = new CopilotClient ();
279230
280231// Create a session tied to the user's project
281232const sessionId = ` project-${projectName } ` ;
@@ -291,90 +242,6 @@ const resumed = await client.resumeSession(sessionId);
291242
292243Session state persists at ` ~/.copilot/session-state/{sessionId}/ ` .
293244
294- ## Distribution Patterns
295-
296- ### Desktop App (Electron, Tauri)
297-
298- ``` mermaid
299- flowchart TB
300- subgraph Electron["Desktop App Package"]
301- UI["App UI"] --> Main["Main Process"]
302- Main --> SDK["SDK Client"]
303- SDK --> CLI["Copilot CLI<br/>(in app resources)"]
304- end
305- CLI --> Cloud["☁️ GitHub Copilot"]
306-
307- style Electron fill:#0d1117,stroke:#58a6ff,color:#c9d1d9
308- ```
309-
310- Include the CLI binary in your app's resources directory:
311-
312- ``` typescript
313- import { app } from " electron" ;
314- import path from " path" ;
315-
316- const cliPath = path .join (
317- app .isPackaged ? process .resourcesPath : __dirname ,
318- " copilot"
319- );
320-
321- const client = new CopilotClient ({ cliPath });
322- ```
323-
324- ### CLI Tool
325-
326- For distributable CLI tools, resolve the path relative to your binary:
327-
328- ``` typescript
329- import { fileURLToPath } from " url" ;
330- import path from " path" ;
331-
332- const __dirname = path .dirname (fileURLToPath (import .meta .url ));
333- const cliPath = path .join (__dirname , " .." , " vendor" , " copilot" );
334-
335- const client = new CopilotClient ({ cliPath });
336- ```
337-
338- ## Platform-Specific Binaries
339-
340- When distributing for multiple platforms, include the correct binary for each:
341-
342- ```
343- my-app/
344- ├── vendor/
345- │ ├── copilot-darwin-arm64 # macOS Apple Silicon
346- │ ├── copilot-darwin-x64 # macOS Intel
347- │ ├── copilot-linux-x64 # Linux x64
348- │ └── copilot-win-x64.exe # Windows x64
349- └── src/
350- └── index.ts
351- ```
352-
353- ``` typescript
354- import os from " os" ;
355-
356- function getCLIPath(): string {
357- const platform = process .platform ; // "darwin", "linux", "win32"
358- const arch = os .arch (); // "arm64", "x64"
359- const ext = platform === " win32" ? " .exe" : " " ;
360- const name = ` copilot-${platform }-${arch }${ext } ` ;
361- return path .join (__dirname , " vendor" , name );
362- }
363-
364- const client = new CopilotClient ({
365- cliPath: getCLIPath (),
366- });
367- ```
368-
369- ## Limitations
370-
371- | Limitation | Details |
372- | ------------| ---------|
373- | ** Bundle size** | CLI binary adds to your app's distribution size |
374- | ** Updates** | You manage CLI version updates in your release cycle |
375- | ** Platform builds** | Need separate binaries for each OS/architecture |
376- | ** Single user** | Each bundled CLI instance serves one user |
377-
378245## When to Move On
379246
380247| Need | Next Guide |
0 commit comments