返回 DeepSeek-Reasonix
preset.go
根目录 / internal / agentpreset / preset.go
1 // Package agentpreset keeps retired session-role values readable. Every
2 // recognized value now folds to standard; delivery no longer changes runtime
3 // behavior.
4 package agentpreset
5
6 import (
7 "fmt"
8 "strings"
9 )
10
11 // AgentPreset is the session role label.
12 type AgentPreset string
13
14 const (
15 // Standard is the 默认 (standard) floor: the adaptive policy unchanged.
16 Standard AgentPreset = "standard"
17 // Delivery is retained only as a legacy input value.
18 Delivery AgentPreset = "delivery"
19 )
20
21 // Normalize maps free-form and legacy values onto the canonical label. Light
22 // and its aliases fold to Standard; unknown values are an error so no new
23 // vocabulary can appear.
24 func Normalize(raw string) (AgentPreset, error) {
25 switch strings.ToLower(strings.TrimSpace(raw)) {
26 case "", string(Standard), string(Delivery), "deliver", "quality", "balanced", "full", "normal",
27 "light", "economy", "eco", "save", "saving", "low", "lite", "minimal":
28 return Standard, nil
29 default:
30 return "", fmt.Errorf("unknown retired role setting %q", raw)
31 }
32 }
33
34 // LegacyTokenMode returns the deprecated dual-write tokenMode value older
35 // clients expect next to a persisted preset. It is a wire-compat mapping only.
36 func LegacyTokenMode(p AgentPreset) string {
37 return "full"
38 }
39
40 // FromLegacyTokenMode maps a persisted or CLI tokenMode onto a preset label.
41 func FromLegacyTokenMode(mode string) AgentPreset {
42 p, err := Normalize(mode)
43 if err != nil {
44 return Standard
45 }
46 return p
47 }
48
49 // FloorNotice is printed once when a legacy mode value is folded.
50 const FloorNotice = "The preset setting has been retired. Recognized legacy values now use standard execution."
51
52 // String returns the canonical identifier.
53 func (p AgentPreset) String() string {
54 return string(p)
55 }
56
56 lines GO