Open History to see the last commit
1import type { RuntimeMode } from "@t3tools/contracts";
2
3export const RUNTIME_MODE_CHOICES: ReadonlyArray<{
4 readonly mode: RuntimeMode;
5 readonly label: string;
6 readonly description: string;
7}> = [
8 {
9 mode: "approval-required",
10 label: "Supervised",
11 description: "Ask before commands and file changes.",
12 },
13 {
14 mode: "auto-accept-edits",
15 label: "Auto-accept edits",
16 description: "Auto-approve edits, ask before other actions.",
17 },
18 {
19 mode: "auto",
20 label: "Auto",
21 description: "Supported providers approve routine actions; others still ask.",
22 },
23 {
24 mode: "full-access",
25 label: "Full access",
26 description: "Allow commands and edits without prompts.",
27 },
28];
29
30export function runtimeModeChoicesForSupportedModes(
31 supportedRuntimeModes: ReadonlyArray<RuntimeMode> | undefined,
32) {
33 return supportedRuntimeModes && supportedRuntimeModes.length > 0
34 ? RUNTIME_MODE_CHOICES.filter((choice) => supportedRuntimeModes.includes(choice.mode))
35 : RUNTIME_MODE_CHOICES;
36}
37
38export function compatibleRuntimeModeForChoices(
39 runtimeMode: RuntimeMode,
40 choices: ReadonlyArray<{ readonly mode: RuntimeMode }>,
41): RuntimeMode {
42 return choices.some((choice) => choice.mode === runtimeMode)
43 ? runtimeMode
44 : (choices[0]?.mode ?? runtimeMode);
45}
46
47export { selectableProviderOptionChoices as selectableChoices } from "@t3tools/client-runtime/model-traits";