You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: nodejs/README.md
+60-3Lines changed: 60 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -55,9 +55,10 @@ new CopilotClient(options?: CopilotClientOptions)
55
55
56
56
**Options:**
57
57
58
-
-`cliPath?: string` - Path to CLI executable (default: "copilot" from PATH)
58
+
-`cliPath?: string` - Path to CLI executable (default: "copilot" from PATH). Mutually exclusive with `acquisition`.
59
59
-`cliArgs?: string[]` - Extra arguments prepended before SDK-managed flags (e.g. `["./dist-cli/index.js"]` when using `node`)
60
-
-`cliUrl?: string` - URL of existing CLI server to connect to (e.g., `"localhost:8080"`, `"http://127.0.0.1:9000"`, or just `"8080"`). When provided, the client will not spawn a CLI process.
60
+
-`cliUrl?: string` - URL of existing CLI server to connect to (e.g., `"localhost:8080"`, `"http://127.0.0.1:9000"`, or just `"8080"`). When provided, the client will not spawn a CLI process. Mutually exclusive with `acquisition`.
61
+
-`acquisition?: AcquisitionOptions` - Auto-download CLI if not present. See [CLI Acquisition](#cli-acquisition). Mutually exclusive with `cliPath` and `cliUrl`.
61
62
-`port?: number` - Server port (default: 0 for random)
62
63
-`useStdio?: boolean` - Use stdio transport instead of TCP (default: true)
- GitHub Copilot CLI installed and in PATH (or provide custom `cliPath`)
649
+
- GitHub Copilot CLI installed and in PATH, or:
650
+
- Provide a custom `cliPath`, or
651
+
- Use `acquisition` to auto-download the CLI (see below)
652
+
653
+
## CLI Acquisition
654
+
655
+
The SDK can automatically download and manage the Copilot CLI for you. This is useful when you can't rely on the CLI being pre-installed.
656
+
657
+
```typescript
658
+
const client =newCopilotClient({
659
+
acquisition: {
660
+
downloadDir: "~/.myapp/copilot-cli", // Where to store CLI versions
661
+
},
662
+
});
663
+
664
+
awaitclient.start(); // Downloads CLI if needed, then starts
665
+
```
666
+
667
+
### How it works
668
+
669
+
1.**Check existing downloads**: Looks for any CLI version in `downloadDir` that is both >= your `minVersion` (if specified) and protocol-compatible with this SDK.
670
+
671
+
2.**If a suitable version exists**: Uses the highest compatible version. No download needed.
672
+
673
+
3.**If no suitable version exists**: Downloads the CLI version this SDK was built for.
674
+
675
+
This means SDK upgrades don't force re-downloads — your existing CLI is reused as long as it still works.
676
+
677
+
### Options
678
+
679
+
```typescript
680
+
interfaceAcquisitionOptions {
681
+
// Required: Directory for CLI downloads. Should be app-specific.
682
+
downloadDir:string;
683
+
684
+
// Optional: Minimum CLI version required (e.g., "0.0.405").
685
+
// If your existing version is lower, a new version will be downloaded.
686
+
minVersion?:string;
687
+
688
+
// Optional: Progress callback for download updates.
0 commit comments