Skip to content

Commit c035934

Browse files
committed
refactor: use single variable for versions
1 parent 06d25ae commit c035934

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

src/lib/api-config.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,23 @@ export const standardHeaders = () => ({
77
accept: "application/json",
88
})
99

10+
const COPILOT_VERSION = "0.26.7"
11+
const EDITOR_PLUGIN_VERSION = `copilot-chat/${COPILOT_VERSION}`
12+
const USER_AGENT = `GitHubCopilotChat/${COPILOT_VERSION}`
13+
14+
const API_VERSION = "2025-04-01"
15+
1016
export const copilotBaseUrl = (state: State) =>
1117
`https://api.${state.accountType}.githubcopilot.com`
1218
export const copilotHeaders = (state: State) => ({
1319
Authorization: `Bearer ${state.copilotToken}`,
1420
"content-type": standardHeaders()["content-type"],
1521
"copilot-integration-id": "vscode-chat",
1622
"editor-version": `vscode/${state.vsCodeVersion}`,
17-
"editor-plugin-version": "copilot-chat/0.26.7",
18-
"user-agent": "GitHubCopilotChat/0.26.7",
23+
"editor-plugin-version": EDITOR_PLUGIN_VERSION,
24+
"user-agent": USER_AGENT,
1925
"openai-intent": "conversation-panel",
20-
"x-github-api-version": "2025-04-01",
26+
"x-github-api-version": API_VERSION,
2127
"x-request-id": randomUUID(),
2228
"x-vscode-user-agent-library-version": "electron-fetch",
2329
})
@@ -27,9 +33,9 @@ export const githubHeaders = (state: State) => ({
2733
...standardHeaders(),
2834
authorization: `token ${state.githubToken}`,
2935
"editor-version": `vscode/${state.vsCodeVersion}`,
30-
"editor-plugin-version": "copilot-chat/0.26.7",
31-
"user-agent": "GitHubCopilotChat/0.26.7",
32-
"x-github-api-version": "2025-04-01",
36+
"editor-plugin-version": EDITOR_PLUGIN_VERSION,
37+
"user-agent": USER_AGENT,
38+
"x-github-api-version": API_VERSION,
3339
"x-vscode-user-agent-library-version": "electron-fetch",
3440
})
3541

0 commit comments

Comments
 (0)