| 724 | } |
| 725 | |
| 726 | function buildHeaders( |
| 727 | providerType: OpenAICompatibleProviderType, |
| 728 | authToken: string | undefined, |
| 729 | defaultHeaders: Record<string, string>, |
| 730 | extraHeaders?: Record<string, string>, |
| 731 | ): Headers { |
| 732 | const headers = new Headers({ |
| 733 | ...defaultHeaders, |
| 734 | 'content-type': 'application/json', |
| 735 | ...(providerType === 'github-models' |
| 736 | ? { |
| 737 | Accept: 'application/vnd.github+json', |
| 738 | 'X-GitHub-Api-Version': '2022-11-28', |
| 739 | } |
| 740 | : providerType === 'github-copilot' |
| 741 | ? { |
| 742 | Accept: 'application/json', |
| 743 | 'Editor-Version': `claude-code/${MACRO.VERSION}`, |
| 744 | 'Editor-Plugin-Version': `claude-code/${MACRO.VERSION}`, |
| 745 | } |
| 746 | : {}), |
| 747 | ...(extraHeaders ?? {}), |
| 748 | }) |
| 749 | if (authToken) { |
| 750 | headers.set('Authorization', `Bearer ${authToken}`) |
| 751 | } |
| 752 | return headers |
| 753 | } |
| 754 | |
| 755 | function buildSignal( |
| 756 | signal: AbortSignal | undefined, |