diff --git a/.gitignore b/.gitignore index 183138f9..942ae053 100644 --- a/.gitignore +++ b/.gitignore @@ -48,3 +48,5 @@ _bmad-output/* # macOS .DS_Store ._* +/.idea/ +/data/ diff --git a/internal/watcher/synthesizer/file.go b/internal/watcher/synthesizer/file.go index ef0eb8c9..c80ebc66 100644 --- a/internal/watcher/synthesizer/file.go +++ b/internal/watcher/synthesizer/file.go @@ -86,12 +86,19 @@ func (s *FileSynthesizer) Synthesize(ctx *SynthesisContext) ([]*coreauth.Auth, e } } + disabled, _ := metadata["disabled"].(bool) + status := coreauth.StatusActive + if disabled { + status = coreauth.StatusDisabled + } + a := &coreauth.Auth{ ID: id, Provider: provider, Label: label, Prefix: prefix, - Status: coreauth.StatusActive, + Status: status, + Disabled: disabled, Attributes: map[string]string{ "source": full, "path": full, diff --git a/sdk/auth/filestore.go b/sdk/auth/filestore.go index 77b24db4..0bb7ff7d 100644 --- a/sdk/auth/filestore.go +++ b/sdk/auth/filestore.go @@ -68,6 +68,7 @@ func (s *FileTokenStore) Save(ctx context.Context, auth *cliproxyauth.Auth) (str return "", err } case auth.Metadata != nil: + auth.Metadata["disabled"] = auth.Disabled raw, errMarshal := json.Marshal(auth.Metadata) if errMarshal != nil { return "", fmt.Errorf("auth filestore: marshal metadata failed: %w", errMarshal) @@ -214,12 +215,18 @@ func (s *FileTokenStore) readAuthFile(path, baseDir string) (*cliproxyauth.Auth, return nil, fmt.Errorf("stat file: %w", err) } id := s.idFor(path, baseDir) + disabled, _ := metadata["disabled"].(bool) + status := cliproxyauth.StatusActive + if disabled { + status = cliproxyauth.StatusDisabled + } auth := &cliproxyauth.Auth{ ID: id, Provider: provider, FileName: id, Label: s.labelFor(metadata), - Status: cliproxyauth.StatusActive, + Status: status, + Disabled: disabled, Attributes: map[string]string{"path": path}, Metadata: metadata, CreatedAt: info.ModTime(), diff --git a/sdk/cliproxy/service.go b/sdk/cliproxy/service.go index 0ace4d31..ee224db5 100644 --- a/sdk/cliproxy/service.go +++ b/sdk/cliproxy/service.go @@ -681,6 +681,10 @@ func (s *Service) registerModelsForAuth(a *coreauth.Auth) { if a == nil || a.ID == "" { return } + if a.Disabled { + GlobalModelRegistry().UnregisterClient(a.ID) + return + } authKind := strings.ToLower(strings.TrimSpace(a.Attributes["auth_kind"])) if authKind == "" { if kind, _ := a.AccountInfo(); strings.EqualFold(kind, "api_key") {