Skip to content

Commit 498f62f

Browse files
committed
tweak: make sure to clear lowercase authorization header
1 parent fd289b6 commit 498f62f

1 file changed

Lines changed: 27 additions & 4 deletions

File tree

index.mjs

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,23 @@ export async function CopilotAuthPlugin({ client }) {
99
"Editor-Plugin-Version": "copilot-chat/0.32.4",
1010
"Copilot-Integration-Id": "vscode-chat",
1111
};
12-
const RESPONSES_API_ALTERNATE_INPUT_TYPES = ["file_search_call", "computer_call", "computer_call_output", "web_search_call", "function_call", "function_call_output", "image_generation_call", "code_interpreter_call", "local_shell_call", "local_shell_call_output", "mcp_list_tools", "mcp_approval_request", "mcp_approval_response", "mcp_call", "reasoning"];
12+
const RESPONSES_API_ALTERNATE_INPUT_TYPES = [
13+
"file_search_call",
14+
"computer_call",
15+
"computer_call_output",
16+
"web_search_call",
17+
"function_call",
18+
"function_call_output",
19+
"image_generation_call",
20+
"code_interpreter_call",
21+
"local_shell_call",
22+
"local_shell_call_output",
23+
"mcp_list_tools",
24+
"mcp_approval_request",
25+
"mcp_approval_response",
26+
"mcp_call",
27+
"reasoning",
28+
];
1329

1430
function normalizeDomain(url) {
1531
return url.replace(/^https?:\/\//, "").replace(/\/$/, "");
@@ -106,14 +122,18 @@ export async function CopilotAuthPlugin({ client }) {
106122
);
107123
}
108124

109-
if(body?.input) {
125+
if (body?.input) {
110126
const lastInput = body.input[body.input.length - 1];
111127

112128
const isAssistant = lastInput?.role === "assistant";
113-
const hasAgentType = lastInput?.type ? RESPONSES_API_ALTERNATE_INPUT_TYPES.includes(lastInput.type) : false;
129+
const hasAgentType = lastInput?.type
130+
? RESPONSES_API_ALTERNATE_INPUT_TYPES.includes(lastInput.type)
131+
: false;
114132
isAgentCall = isAssistant || hasAgentType;
115133

116-
isVisionRequest = Array.isArray(lastInput?.content) && lastInput.content.some((part) => part.type === "input_image");
134+
isVisionRequest =
135+
Array.isArray(lastInput?.content) &&
136+
lastInput.content.some((part) => part.type === "input_image");
117137
}
118138
} catch {}
119139
const headers = {
@@ -126,7 +146,10 @@ export async function CopilotAuthPlugin({ client }) {
126146
if (isVisionRequest) {
127147
headers["Copilot-Vision-Request"] = "true";
128148
}
149+
129150
delete headers["x-api-key"];
151+
delete headers["authorization"];
152+
130153
return fetch(input, {
131154
...init,
132155
headers,

0 commit comments

Comments
 (0)