loki-mode 5.58.2 → 6.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -121,12 +121,62 @@ provider_get_tier_param() {
121
121
  fi
122
122
  }
123
123
 
124
+ # Dynamic model resolution (v6.0.0)
125
+ # Resolves a capability tier to a concrete model name at runtime.
126
+ # Respects LOKI_MAX_TIER to cap cost (e.g., maxTier=sonnet prevents opus usage).
127
+ # Capability aliases: "best" -> planning tier, "fast" -> fast tier, "balanced" -> development tier
128
+ resolve_model_for_tier() {
129
+ local tier="$1"
130
+
131
+ # Handle capability aliases
132
+ case "$tier" in
133
+ best) tier="planning" ;;
134
+ balanced) tier="development" ;;
135
+ cheap) tier="fast" ;;
136
+ esac
137
+
138
+ local max_tier="${LOKI_MAX_TIER:-}"
139
+ local model=""
140
+
141
+ # Resolve tier to model
142
+ case "$tier" in
143
+ planning) model="$PROVIDER_MODEL_PLANNING" ;;
144
+ development) model="$PROVIDER_MODEL_DEVELOPMENT" ;;
145
+ fast) model="$PROVIDER_MODEL_FAST" ;;
146
+ *) model="$PROVIDER_MODEL_DEVELOPMENT" ;;
147
+ esac
148
+
149
+ # Apply maxTier ceiling if set
150
+ if [ -n "$max_tier" ]; then
151
+ case "$max_tier" in
152
+ haiku)
153
+ # Cap everything to haiku/fast
154
+ model="$PROVIDER_MODEL_FAST"
155
+ ;;
156
+ sonnet)
157
+ # Cap planning to development
158
+ if [ "$tier" = "planning" ]; then
159
+ model="$PROVIDER_MODEL_DEVELOPMENT"
160
+ fi
161
+ ;;
162
+ opus)
163
+ # No cap needed, opus is max
164
+ ;;
165
+ esac
166
+ fi
167
+
168
+ echo "$model"
169
+ }
170
+
124
171
  # Tier-aware invocation (Claude supports model selection via --model flag)
125
172
  provider_invoke_with_tier() {
126
173
  local tier="$1"
127
174
  local prompt="$2"
128
175
  shift 2
129
176
  local model
130
- model=$(provider_get_tier_param "$tier")
131
- claude --dangerously-skip-permissions --model "$model" -p "$prompt" "$@"
177
+ model=$(resolve_model_for_tier "$tier")
178
+ # Extract short name for Task tool (opus/sonnet/haiku)
179
+ local short_model
180
+ short_model=$(echo "$model" | sed 's/claude-\([a-z]*\).*/\1/')
181
+ claude --dangerously-skip-permissions --model "$short_model" -p "$prompt" "$@"
132
182
  }
@@ -113,15 +113,50 @@ provider_get_tier_param() {
113
113
  esac
114
114
  }
115
115
 
116
+ # Dynamic model resolution (v6.0.0)
117
+ # Resolves a capability tier to a concrete effort level at runtime.
118
+ # Codex uses a single model with effort parameter, so maxTier maps to effort cap.
119
+ resolve_model_for_tier() {
120
+ local tier="$1"
121
+
122
+ # Handle capability aliases
123
+ case "$tier" in
124
+ best) tier="planning" ;;
125
+ balanced) tier="development" ;;
126
+ cheap) tier="fast" ;;
127
+ esac
128
+
129
+ local max_tier="${LOKI_MAX_TIER:-}"
130
+ local effort=""
131
+
132
+ case "$tier" in
133
+ planning) effort="$PROVIDER_EFFORT_PLANNING" ;;
134
+ development) effort="$PROVIDER_EFFORT_DEVELOPMENT" ;;
135
+ fast) effort="$PROVIDER_EFFORT_FAST" ;;
136
+ *) effort="$PROVIDER_EFFORT_DEVELOPMENT" ;;
137
+ esac
138
+
139
+ # Apply maxTier ceiling (maps to effort levels)
140
+ if [ -n "$max_tier" ]; then
141
+ case "$max_tier" in
142
+ haiku|low) effort="low" ;;
143
+ sonnet|high)
144
+ if [ "$effort" = "xhigh" ]; then effort="high"; fi
145
+ ;;
146
+ opus|xhigh) ;; # No cap
147
+ esac
148
+ fi
149
+
150
+ echo "$effort"
151
+ }
152
+
116
153
  # Tier-aware invocation
117
- # Note: Codex CLI does not support effort CLI flags
118
- # Effort must be configured via environment: CODEX_MODEL_REASONING_EFFORT
119
- # This function sets the env var before invocation
154
+ # Codex CLI uses CODEX_MODEL_REASONING_EFFORT env var for effort control
120
155
  provider_invoke_with_tier() {
121
156
  local tier="$1"
122
157
  local prompt="$2"
123
158
  shift 2
124
159
  local effort
125
- effort=$(provider_get_tier_param "$tier")
160
+ effort=$(resolve_model_for_tier "$tier")
126
161
  CODEX_MODEL_REASONING_EFFORT="$effort" codex exec --full-auto "$prompt" "$@"
127
162
  }
@@ -139,6 +139,48 @@ provider_get_tier_param() {
139
139
  esac
140
140
  }
141
141
 
142
+ # Dynamic model resolution (v6.0.0)
143
+ # Resolves a capability tier to a concrete model name at runtime.
144
+ # Respects LOKI_MAX_TIER to cap cost.
145
+ resolve_model_for_tier() {
146
+ local tier="$1"
147
+
148
+ # Handle capability aliases
149
+ case "$tier" in
150
+ best) tier="planning" ;;
151
+ balanced) tier="development" ;;
152
+ cheap) tier="fast" ;;
153
+ esac
154
+
155
+ local max_tier="${LOKI_MAX_TIER:-}"
156
+ local model=""
157
+
158
+ case "$tier" in
159
+ planning) model="$PROVIDER_MODEL_PLANNING" ;;
160
+ development) model="$PROVIDER_MODEL_DEVELOPMENT" ;;
161
+ fast) model="$PROVIDER_MODEL_FAST" ;;
162
+ *) model="$PROVIDER_MODEL_DEVELOPMENT" ;;
163
+ esac
164
+
165
+ # Apply maxTier ceiling
166
+ if [ -n "$max_tier" ]; then
167
+ case "$max_tier" in
168
+ haiku|flash)
169
+ model="$PROVIDER_MODEL_FAST"
170
+ ;;
171
+ sonnet|pro)
172
+ # Cap planning to development (pro)
173
+ if [ "$tier" = "planning" ]; then
174
+ model="$PROVIDER_MODEL_DEVELOPMENT"
175
+ fi
176
+ ;;
177
+ opus) ;; # No cap
178
+ esac
179
+ fi
180
+
181
+ echo "$model"
182
+ }
183
+
142
184
  # Tier-aware invocation with rate limit fallback
143
185
  # Uses --model flag to specify model
144
186
  # Falls back to flash model if pro hits rate limit
@@ -148,9 +190,8 @@ provider_invoke_with_tier() {
148
190
  local prompt="$2"
149
191
  shift 2
150
192
 
151
- # Select model based on tier
152
- local model="$PROVIDER_MODEL"
153
- [[ "$tier" == "fast" ]] && model="$PROVIDER_MODEL_FAST"
193
+ local model
194
+ model=$(resolve_model_for_tier "$tier")
154
195
 
155
196
  echo "[loki] Using tier: $tier, model: $model" >&2
156
197