Skip to content

Commit 0a0ea50

Browse files
committed
feat!: new account type option
1 parent 544d0a3 commit 0a0ea50

File tree

3 files changed

+17
-26
lines changed

3 files changed

+17
-26
lines changed

README.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,7 @@ The following command line options are available for the `start` command:
7777
| -------------- | ----------------------------------------------------------------------------- | ------- | ----- |
7878
| --port | Port to listen on | 4141 | -p |
7979
| --verbose | Enable verbose logging | false | -v |
80-
| --business | Use a business plan GitHub account | false | none |
81-
| --enterprise | Use an enterprise plan GitHub account | false | none |
80+
| --account-type | Account type to use (individual, business, enterprise) | individual | -a |
8281
| --manual | Enable manual request approval | false | none |
8382
| --rate-limit | Rate limit in seconds between requests | none | -r |
8483
| --wait | Wait instead of error when rate limit is hit | false | -w |
@@ -102,10 +101,10 @@ npx copilot-api@latest start
102101
npx copilot-api@latest start --port 8080 --verbose
103102

104103
# Use with a business plan GitHub account
105-
npx copilot-api@latest start --business
104+
npx copilot-api@latest start --account-type business
106105

107106
# Use with an enterprise plan GitHub account
108-
npx copilot-api@latest start --enterprise
107+
npx copilot-api@latest start --account-type enterprise
109108

110109
# Enable manual approval for each request
111110
npx copilot-api@latest start --manual
@@ -147,9 +146,8 @@ bun run start
147146
- Consider using free models (e.g., Gemini, Mistral, Openrouter) as the `weak-model`
148147
- Use architect mode sparingly
149148
- Disable `yes-always` in your aider configuration
150-
- Be mindful that Claude 3.7 thinking mode consumes more tokens
151149
- Enable the `--manual` flag to review and approve each request before processing
152-
- If you have a GitHub business or enterprise plan account with Copilot, use the `--business` or `--enterprise` flag respectively
150+
- If you have a GitHub business or enterprise plan account with Copilot, use the `--account-type` flag (e.g., `--account-type business`). See the [official documentation](https://docs.github.com/en/enterprise-cloud@latest/copilot/managing-copilot/managing-github-copilot-in-your-organization/managing-access-to-github-copilot-in-your-organization/managing-github-copilot-access-to-your-organizations-network#configuring-copilot-subscription-based-network-routing-for-your-enterprise-or-organization) for more details.
153151

154152
### Manual Request Approval
155153

src/lib/api-config.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ const USER_AGENT = `GitHubCopilotChat/${COPILOT_VERSION}`
1414
const API_VERSION = "2025-04-01"
1515

1616
export const copilotBaseUrl = (state: State) =>
17-
`https://api.${state.accountType}.githubcopilot.com`
17+
state.accountType === "individual" ?
18+
"https://api.githubcopilot.com"
19+
: `https://api.${state.accountType}.githubcopilot.com`
1820
export const copilotHeaders = (state: State, vision: boolean = false) => {
1921
const headers: Record<string, string> = {
2022
Authorization: `Bearer ${state.copilotToken}`,

src/main.ts

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ import { server } from "./server"
1515
interface RunServerOptions {
1616
port: number
1717
verbose: boolean
18-
business: boolean
19-
enterprise: boolean
18+
accountType: string
2019
manual: boolean
2120
rateLimit?: number
2221
rateLimitWait: boolean
@@ -29,12 +28,9 @@ export async function runServer(options: RunServerOptions): Promise<void> {
2928
consola.info("Verbose logging enabled")
3029
}
3130

32-
if (options.business) {
33-
state.accountType = "business"
34-
consola.info("Using business plan GitHub account")
35-
} else if (options.enterprise) {
36-
state.accountType = "enterprise"
37-
consola.info("Using enterprise plan GitHub account")
31+
state.accountType = options.accountType
32+
if (options.accountType !== "individual") {
33+
consola.info(`Using ${options.accountType} plan GitHub account`)
3834
}
3935

4036
state.manualApprove = options.manual
@@ -81,15 +77,11 @@ const start = defineCommand({
8177
default: false,
8278
description: "Enable verbose logging",
8379
},
84-
business: {
85-
type: "boolean",
86-
default: false,
87-
description: "Use a business plan GitHub account",
88-
},
89-
enterprise: {
90-
type: "boolean",
91-
default: false,
92-
description: "Use an enterprise plan GitHub account",
80+
"account-type": {
81+
alias: "a",
82+
type: "string",
83+
default: "individual",
84+
description: "Account type to use (individual, business, enterprise)",
9385
},
9486
manual: {
9587
type: "boolean",
@@ -126,8 +118,7 @@ const start = defineCommand({
126118
return runServer({
127119
port,
128120
verbose: args.verbose,
129-
business: args.business,
130-
enterprise: args.enterprise,
121+
accountType: args["account-type"],
131122
manual: args.manual,
132123
rateLimit,
133124
rateLimitWait: Boolean(args.wait),

0 commit comments

Comments
 (0)