-
Notifications
You must be signed in to change notification settings - Fork 45
Expand file tree
/
Copy pathFastModeConfig.ts
More file actions
61 lines (53 loc) · 2.09 KB
/
Copy pathFastModeConfig.ts
File metadata and controls
61 lines (53 loc) · 2.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import type {SessionConfigOption} from "@agentclientprotocol/sdk";
import type * as acp from "@agentclientprotocol/sdk";
import type {ServiceTier} from "./app-server";
import type {Model} from "./app-server/v2";
export const FAST_MODE_CONFIG_ID = "fast-mode";
export const FAST_MODE_CATEGORY = "model_config";
export const FAST_MODE_ON = "on";
export const FAST_MODE_OFF = "off";
const FAST_MODE_DESCRIPTION = "1.5x speed, increased usage";
export function modelSupportsFast(model: Model | undefined): boolean {
return model?.additionalSpeedTiers?.includes("fast") ?? false;
}
export function resolveFastServiceTier(fastModeEnabled: boolean, currentModelSupportsFast: boolean): ServiceTier | null {
return fastModeEnabled && currentModelSupportsFast ? "fast" : null;
}
export function isFastServiceTier(serviceTier: string | null | undefined): boolean {
return serviceTier === "fast" || serviceTier === "priority";
}
export function clientSupportsBooleanConfigOptions(clientCapabilities?: acp.ClientCapabilities | null): boolean {
return clientCapabilities?.session?.configOptions?.boolean != null;
}
export function createFastModeConfigOption(fastModeEnabled: boolean, useBooleanConfigOption = false): SessionConfigOption {
if (useBooleanConfigOption) {
return {
id: FAST_MODE_CONFIG_ID,
name: "Fast mode",
description: FAST_MODE_DESCRIPTION,
category: FAST_MODE_CATEGORY,
type: "boolean",
currentValue: fastModeEnabled,
};
}
return {
id: FAST_MODE_CONFIG_ID,
name: "Fast mode",
description: FAST_MODE_DESCRIPTION,
category: FAST_MODE_CATEGORY,
type: "select",
currentValue: fastModeEnabled ? FAST_MODE_ON : FAST_MODE_OFF,
options: [
{
value: FAST_MODE_OFF,
name: "Off",
description: "Default speed, normal usage",
},
{
value: FAST_MODE_ON,
name: "On",
description: FAST_MODE_DESCRIPTION,
},
],
};
}