()
| 124 | |
| 125 | |
| 126 | def resolve_auth_db_path() -> Path: |
| 127 | candidates = [] |
| 128 | env_database_path = os.environ.get("DATABASE_PATH") |
| 129 | if env_database_path: |
| 130 | candidates.append(Path(env_database_path)) |
| 131 | |
| 132 | candidates.extend( |
| 133 | [ |
| 134 | WORKSPACE / "vendor" / "claudecodeui-1.25.2" / "server" / "database" / "auth.db", |
| 135 | Path.home() / ".cloudcli" / "auth.db", |
| 136 | Path.home() / ".codex" / "auth.db", |
| 137 | ] |
| 138 | ) |
| 139 | |
| 140 | best_path = candidates[0] |
| 141 | best_score = -1 |
| 142 | seen: set[str] = set() |
| 143 | for candidate in candidates: |
| 144 | normalized = str(candidate.resolve()) if candidate.exists() else str(candidate) |
| 145 | if normalized in seen: |
| 146 | continue |
| 147 | seen.add(normalized) |
| 148 | score, _tables = inspect_auth_db(candidate) |
| 149 | if score > best_score: |
| 150 | best_path = candidate |
| 151 | best_score = score |
| 152 | |
| 153 | return best_path |
| 154 | |
| 155 | |
| 156 | AUTH_DB_PATH = resolve_auth_db_path() |
no test coverage detected