forked from RooCodeInc/Roo-Code
-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathexperiments.ts
More file actions
33 lines (25 loc) · 1.05 KB
/
experiments.ts
File metadata and controls
33 lines (25 loc) · 1.05 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
import { ExperimentId } from "../schemas"
import { AssertEqual, Equals, Keys, Values } from "../utils/type-fu"
export type { ExperimentId }
export const EXPERIMENT_IDS = {
POWER_STEERING: "powerSteering",
} as const satisfies Record<string, ExperimentId>
type _AssertExperimentIds = AssertEqual<Equals<ExperimentId, Values<typeof EXPERIMENT_IDS>>>
type ExperimentKey = Keys<typeof EXPERIMENT_IDS>
interface ExperimentConfig {
enabled: boolean
}
export const experimentConfigsMap: Record<ExperimentKey, ExperimentConfig> = {
POWER_STEERING: { enabled: false },
}
export const experimentDefault = Object.fromEntries(
Object.entries(experimentConfigsMap).map(([_, config]) => [
EXPERIMENT_IDS[_ as keyof typeof EXPERIMENT_IDS] as ExperimentId,
config.enabled,
]),
) as Record<ExperimentId, boolean>
export const experiments = {
get: (id: ExperimentKey): ExperimentConfig | undefined => experimentConfigsMap[id],
isEnabled: (experimentsConfig: Record<ExperimentId, boolean>, id: ExperimentId) =>
experimentsConfig[id] ?? experimentDefault[id],
} as const