1
>
/*---------------------------------------------------------------------------------------------
anthropicBetas.ts
2
>
* Copyright (c) Microsoft Corporation. All rights reserved.
3
>
* Licensed under the MIT License. See License.txt in the project root for license information.
4
>
*--------------------------------------------------------------------------------------------*/
5
>
6
>
/**
7
>
* Mirror of {@link
8
>
* file://./../../../../../extensions/copilot/src/extension/chatSessions/claude/node/claudeLanguageModelServer.ts
9
>
* `extensions/copilot/.../claudeLanguageModelServer.ts`}'s `filterSupportedBetas`
10
>
* + `SUPPORTED_ANTHROPIC_BETAS` allowlist.
11
>
*
12
>
* **Keep in sync with the extension copy.** When CAPI gains support for
13
>
* a new Anthropic beta, add it here. The filter is applied at the
14
>
* inbound `POST /v1/messages` boundary on the `anthropic-beta` header
15
>
* before forwarding to {@link ICopilotApiService.messages}.
16
>
*/
17
>
18
>
/**
19
>
* Beta identifiers (without date suffix) that CAPI is known to honor.
20
>
* The match is prefix + `-`, so an entry like `'context-management'`
21
>
* accepts `'context-management-2025-06-27'` but rejects
22
>
* `'context-management'` (no date) — date-suffix discipline.
23
>
*/
24
>
const SUPPORTED_ANTHROPIC_BETAS: readonly string[] = [
25
>
'interleaved-thinking',
26
>
'context-management',
27
>
'advanced-tool-use',
28
>
];
29
>
30
>
/**
31
>
* Filters a comma-separated `anthropic-beta` header value to only include
32
>
* betas that match {@link SUPPORTED_ANTHROPIC_BETAS}. Entries are matched by
33
>
* prefix so that e.g. `'context-management'` allows `'context-management-2025-06-27'`.
34
>
*
35
>
* Returns the filtered comma-separated string, or `undefined` if no betas matched.
36
>
* Callers must omit the outbound header entirely when this returns `undefined`
37
>
* — never forward an empty string.
38
>
*/
39
>
export function filterSupportedBetas(headerValue: string): string | undefined {
40
const filtered = headerValue
41
.split(',')