Skip to content

Commit 6e8e0b0

Browse files
Merge branch 'router-for-me:main' into main
2 parents 36228c2 + 7ebd8f0 commit 6e8e0b0

9 files changed

Lines changed: 103 additions & 23 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ The Plus release stays in lockstep with the mainline features.
1010

1111
## Differences from the Mainline
1212

13-
[![z.ai](https://assets.router-for.me/english-5.png)](https://z.ai/subscribe?ic=8JVLJQFSKB)
13+
[![z.ai](https://assets.router-for.me/english-5-0.jpg)](https://z.ai/subscribe?ic=8JVLJQFSKB)
1414

1515
## New Features (Plus Enhanced)
1616

README_CN.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
## 与主线版本版本差异
1212

13-
[![bigmodel.cn](https://assets.router-for.me/chinese-5.png)](https://www.bigmodel.cn/claude-code?ic=RRVJPB5SII)
13+
[![bigmodel.cn](https://assets.router-for.me/chinese-5-0.jpg)](https://www.bigmodel.cn/claude-code?ic=RRVJPB5SII)
1414

1515
## 新增功能 (Plus 增强版)
1616

internal/api/handlers/management/auth_files.go

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616
"net/url"
1717
"os"
1818
"path/filepath"
19+
"runtime"
1920
"sort"
2021
"strconv"
2122
"strings"
@@ -698,17 +699,20 @@ func (h *Handler) authIDForPath(path string) string {
698699
if path == "" {
699700
return ""
700701
}
701-
if h == nil || h.cfg == nil {
702-
return path
703-
}
704-
authDir := strings.TrimSpace(h.cfg.AuthDir)
705-
if authDir == "" {
706-
return path
702+
id := path
703+
if h != nil && h.cfg != nil {
704+
authDir := strings.TrimSpace(h.cfg.AuthDir)
705+
if authDir != "" {
706+
if rel, errRel := filepath.Rel(authDir, path); errRel == nil && rel != "" {
707+
id = rel
708+
}
709+
}
707710
}
708-
if rel, err := filepath.Rel(authDir, path); err == nil && rel != "" {
709-
return rel
711+
// On Windows, normalize ID casing to avoid duplicate auth entries caused by case-insensitive paths.
712+
if runtime.GOOS == "windows" {
713+
id = strings.ToLower(id)
710714
}
711-
return path
715+
return id
712716
}
713717

714718
func (h *Handler) registerAuthFromFile(ctx context.Context, path string, data []byte) error {

internal/translator/antigravity/claude/antigravity_claude_request.go

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -441,9 +441,19 @@ func ConvertClaudeRequestToAntigravity(modelName string, inputRawJSON []byte, _
441441
out, _ = sjson.Set(out, "request.generationConfig.thinkingConfig.includeThoughts", true)
442442
}
443443
case "adaptive", "auto":
444-
// Keep adaptive/auto as a high level sentinel; ApplyThinking resolves it
445-
// to model-specific max capability.
446-
out, _ = sjson.Set(out, "request.generationConfig.thinkingConfig.thinkingLevel", "high")
444+
// Adaptive/auto thinking:
445+
// - If output_config.effort is present, pass it through as thinkingLevel.
446+
// - Otherwise, default to "high".
447+
// ApplyThinking later normalizes/clamps and may convert level → budget per target model.
448+
effort := ""
449+
if v := gjson.GetBytes(rawJSON, "output_config.effort"); v.Exists() && v.Type == gjson.String {
450+
effort = strings.ToLower(strings.TrimSpace(v.String()))
451+
}
452+
if effort != "" {
453+
out, _ = sjson.Set(out, "request.generationConfig.thinkingConfig.thinkingLevel", effort)
454+
} else {
455+
out, _ = sjson.Set(out, "request.generationConfig.thinkingConfig.thinkingLevel", "high")
456+
}
447457
out, _ = sjson.Set(out, "request.generationConfig.thinkingConfig.includeThoughts", true)
448458
}
449459
}

internal/watcher/synthesizer/file.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"fmt"
66
"os"
77
"path/filepath"
8+
"runtime"
89
"strconv"
910
"strings"
1011
"time"
@@ -72,6 +73,10 @@ func (s *FileSynthesizer) Synthesize(ctx *SynthesisContext) ([]*coreauth.Auth, e
7273
if rel, errRel := filepath.Rel(ctx.AuthDir, full); errRel == nil && rel != "" {
7374
id = rel
7475
}
76+
// On Windows, normalize ID casing to avoid duplicate auth entries caused by case-insensitive paths.
77+
if runtime.GOOS == "windows" {
78+
id = strings.ToLower(id)
79+
}
7580

7681
proxyURL := ""
7782
if p, ok := metadata["proxy_url"].(string); ok {

sdk/auth/filestore.go

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"net/url"
1111
"os"
1212
"path/filepath"
13+
"runtime"
1314
"strings"
1415
"sync"
1516
"time"
@@ -266,14 +267,17 @@ func (s *FileTokenStore) readAuthFile(path, baseDir string) (*cliproxyauth.Auth,
266267
}
267268

268269
func (s *FileTokenStore) idFor(path, baseDir string) string {
269-
if baseDir == "" {
270-
return path
270+
id := path
271+
if baseDir != "" {
272+
if rel, errRel := filepath.Rel(baseDir, path); errRel == nil && rel != "" {
273+
id = rel
274+
}
271275
}
272-
rel, err := filepath.Rel(baseDir, path)
273-
if err != nil {
274-
return path
276+
// On Windows, normalize ID casing to avoid duplicate auth entries caused by case-insensitive paths.
277+
if runtime.GOOS == "windows" {
278+
id = strings.ToLower(id)
275279
}
276-
return rel
280+
return id
277281
}
278282

279283
func (s *FileTokenStore) resolveAuthPath(auth *cliproxyauth.Auth) (string, error) {

sdk/cliproxy/auth/conductor.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -463,9 +463,14 @@ func (m *Manager) Update(ctx context.Context, auth *Auth) (*Auth, error) {
463463
return nil, nil
464464
}
465465
m.mu.Lock()
466-
if existing, ok := m.auths[auth.ID]; ok && existing != nil && !auth.indexAssigned && auth.Index == "" {
467-
auth.Index = existing.Index
468-
auth.indexAssigned = existing.indexAssigned
466+
if existing, ok := m.auths[auth.ID]; ok && existing != nil {
467+
if !auth.indexAssigned && auth.Index == "" {
468+
auth.Index = existing.Index
469+
auth.indexAssigned = existing.indexAssigned
470+
}
471+
if len(auth.ModelStates) == 0 && len(existing.ModelStates) > 0 {
472+
auth.ModelStates = existing.ModelStates
473+
}
469474
}
470475
auth.EnsureIndex()
471476
m.auths[auth.ID] = auth.Clone()
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
package auth
2+
3+
import (
4+
"context"
5+
"testing"
6+
)
7+
8+
func TestManager_Update_PreservesModelStates(t *testing.T) {
9+
m := NewManager(nil, nil, nil)
10+
11+
model := "test-model"
12+
backoffLevel := 7
13+
14+
if _, errRegister := m.Register(context.Background(), &Auth{
15+
ID: "auth-1",
16+
Provider: "claude",
17+
Metadata: map[string]any{"k": "v"},
18+
ModelStates: map[string]*ModelState{
19+
model: {
20+
Quota: QuotaState{BackoffLevel: backoffLevel},
21+
},
22+
},
23+
}); errRegister != nil {
24+
t.Fatalf("register auth: %v", errRegister)
25+
}
26+
27+
if _, errUpdate := m.Update(context.Background(), &Auth{
28+
ID: "auth-1",
29+
Provider: "claude",
30+
Metadata: map[string]any{"k": "v2"},
31+
}); errUpdate != nil {
32+
t.Fatalf("update auth: %v", errUpdate)
33+
}
34+
35+
updated, ok := m.GetByID("auth-1")
36+
if !ok || updated == nil {
37+
t.Fatalf("expected auth to be present")
38+
}
39+
if len(updated.ModelStates) == 0 {
40+
t.Fatalf("expected ModelStates to be preserved")
41+
}
42+
state := updated.ModelStates[model]
43+
if state == nil {
44+
t.Fatalf("expected model state to be present")
45+
}
46+
if state.Quota.BackoffLevel != backoffLevel {
47+
t.Fatalf("expected BackoffLevel to be %d, got %d", backoffLevel, state.Quota.BackoffLevel)
48+
}
49+
}

sdk/cliproxy/service.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,9 @@ func (s *Service) applyCoreAuthAddOrUpdate(ctx context.Context, auth *coreauth.A
301301
auth.CreatedAt = existing.CreatedAt
302302
auth.LastRefreshedAt = existing.LastRefreshedAt
303303
auth.NextRefreshAfter = existing.NextRefreshAfter
304+
if len(auth.ModelStates) == 0 && len(existing.ModelStates) > 0 {
305+
auth.ModelStates = existing.ModelStates
306+
}
304307
op = "update"
305308
_, err = s.coreManager.Update(ctx, auth)
306309
} else {

0 commit comments

Comments
 (0)