Skip to content

Commit 5140e83

Browse files
authored
feat(copilot): edit headers for better rate limit avoidance (anomalyco#321)
1 parent 100d621 commit 5140e83

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

packages/opencode/src/auth/github-copilot.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export namespace AuthGithubCopilot {
3737
headers: {
3838
Accept: "application/json",
3939
"Content-Type": "application/json",
40-
"User-Agent": "GithubCopilot/1.155.0",
40+
"User-Agent": "GitHubCopilotChat/0.26.7",
4141
},
4242
body: JSON.stringify({
4343
client_id: CLIENT_ID,
@@ -60,7 +60,7 @@ export namespace AuthGithubCopilot {
6060
headers: {
6161
Accept: "application/json",
6262
"Content-Type": "application/json",
63-
"User-Agent": "GithubCopilot/1.155.0",
63+
"User-Agent": "GitHubCopilotChat/0.26.7",
6464
},
6565
body: JSON.stringify({
6666
client_id: CLIENT_ID,
@@ -101,9 +101,9 @@ export namespace AuthGithubCopilot {
101101
headers: {
102102
Accept: "application/json",
103103
Authorization: `Bearer ${info.refresh}`,
104-
"User-Agent": "GithubCopilot/1.155.0",
105-
"Editor-Version": "vscode/1.85.1",
106-
"Editor-Plugin-Version": "copilot/1.155.0",
104+
"User-Agent": "GitHubCopilotChat/0.26.7",
105+
"Editor-Version": "vscode/1.99.3",
106+
"Editor-Plugin-Version": "copilot-chat/0.26.7",
107107
},
108108
})
109109

packages/opencode/src/provider/provider.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,11 @@ export namespace Provider {
8989
const headers = {
9090
...init.headers,
9191
Authorization: `Bearer ${token}`,
92-
"User-Agent": "GithubCopilot/1.155.0",
93-
"Editor-Version": "vscode/1.85.1",
94-
"Editor-Plugin-Version": "copilot/1.155.0",
92+
"User-Agent": "GitHubCopilotChat/0.26.7",
93+
"Editor-Version": "vscode/1.99.3",
94+
"Editor-Plugin-Version": "copilot-chat/0.26.7",
95+
"Copilot-Integration-Id": "vscode-chat",
96+
"Openai-Intent": "conversation-edits",
9597
}
9698
delete headers["x-api-key"]
9799
return fetch(input, {

0 commit comments

Comments
 (0)