fix: Copilot Premium Requests (#595)

This commit is contained in:
Mark Huggins 2025-07-02 12:04:53 -04:00 committed by GitHub
parent 2799a96032
commit b89d4a16fd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -99,11 +99,25 @@ export namespace Provider {
})
info.access = tokens.access
}
let isAgentCall = false
try {
const body =
typeof init.body === "string"
? JSON.parse(init.body)
: init.body
if (body?.messages) {
isAgentCall = body.messages.some(
(msg: any) =>
msg.role && ["tool", "assistant"].includes(msg.role),
)
}
} catch {}
const headers = {
...init.headers,
...copilot.HEADERS,
Authorization: `Bearer ${info.access}`,
"Openai-Intent": "conversation-edits",
"X-Initiator": isAgentCall ? "agent" : "user",
}
delete headers["x-api-key"]
return fetch(input, {