From 24446a4dc42120fe352e9774f7cdf849507a6be2 Mon Sep 17 00:00:00 2001 From: hkfires <10558748+hkfires@users.noreply.github.com> Date: Wed, 29 Oct 2025 21:49:35 +0800 Subject: [PATCH] feat(cliproxy): skip persisting runtime-only websocket auths --- sdk/cliproxy/auth/manager.go | 5 +++++ sdk/cliproxy/service.go | 15 ++++++++------- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/sdk/cliproxy/auth/manager.go b/sdk/cliproxy/auth/manager.go index 2cf7c77e..1e3f4197 100644 --- a/sdk/cliproxy/auth/manager.go +++ b/sdk/cliproxy/auth/manager.go @@ -872,6 +872,11 @@ func (m *Manager) persist(ctx context.Context, auth *Auth) error { if m.store == nil || auth == nil { return nil } + if auth.Attributes != nil { + if v := strings.ToLower(strings.TrimSpace(auth.Attributes["runtime_only"])); v == "true" { + return nil + } + } // Skip persistence when metadata is absent (e.g., runtime-only auths). if auth.Metadata == nil { return nil diff --git a/sdk/cliproxy/service.go b/sdk/cliproxy/service.go index eeccccab..27a40cc9 100644 --- a/sdk/cliproxy/service.go +++ b/sdk/cliproxy/service.go @@ -210,13 +210,14 @@ func (s *Service) wsOnConnected(channelID string) { } now := time.Now().UTC() auth := &coreauth.Auth{ - ID: channelID, // keep channel identifier as ID - Provider: "aistudio", // logical provider for switch routing - Label: channelID, // display original channel id - Status: coreauth.StatusActive, - CreatedAt: now, - UpdatedAt: now, - Metadata: map[string]any{"email": channelID}, // inject email inline + ID: channelID, // keep channel identifier as ID + Provider: "aistudio", // logical provider for switch routing + Label: channelID, // display original channel id + Status: coreauth.StatusActive, + CreatedAt: now, + UpdatedAt: now, + Attributes: map[string]string{"runtime_only": "true"}, + Metadata: map[string]any{"email": channelID}, // metadata drives logging and usage tracking } log.Infof("websocket provider connected: %s", channelID) s.applyCoreAuthAddOrUpdate(context.Background(), auth)