constants.go 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. // Package geminicli provides helpers for interacting with Gemini CLI tools.
  2. package geminicli
  3. import "time"
  4. const (
  5. AIStudioBaseURL = "https://generativelanguage.googleapis.com"
  6. GeminiCliBaseURL = "https://cloudcode-pa.googleapis.com"
  7. AuthorizeURL = "https://accounts.google.com/o/oauth2/v2/auth"
  8. TokenURL = "https://oauth2.googleapis.com/token"
  9. // AIStudioOAuthRedirectURI is the default redirect URI used for AI Studio OAuth.
  10. // This matches the "copy/paste callback URL" flow used by OpenAI OAuth in this project.
  11. // Note: You still need to register this redirect URI in your Google OAuth client
  12. // unless you use an OAuth client type that permits localhost redirect URIs.
  13. AIStudioOAuthRedirectURI = "http://localhost:1455/auth/callback"
  14. // DefaultScopes for Code Assist (includes cloud-platform for API access plus userinfo scopes)
  15. // Required by Google's Code Assist API.
  16. DefaultCodeAssistScopes = "https://www.googleapis.com/auth/cloud-platform https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile"
  17. // DefaultScopes for AI Studio (uses generativelanguage API with OAuth)
  18. // Reference: https://ai.google.dev/gemini-api/docs/oauth
  19. // For regular Google accounts, supports API calls to generativelanguage.googleapis.com
  20. // Note: Google Auth platform currently documents the OAuth scope as
  21. // https://www.googleapis.com/auth/generative-language.retriever (often with cloud-platform).
  22. DefaultAIStudioScopes = "https://www.googleapis.com/auth/cloud-platform https://www.googleapis.com/auth/generative-language.retriever"
  23. // DefaultGoogleOneScopes (DEPRECATED, no longer used)
  24. // Google One now always uses the built-in Gemini CLI client with DefaultCodeAssistScopes.
  25. // This constant is kept for backward compatibility but is not actively used.
  26. DefaultGoogleOneScopes = "https://www.googleapis.com/auth/cloud-platform https://www.googleapis.com/auth/generative-language.retriever https://www.googleapis.com/auth/drive.readonly https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile"
  27. // GeminiCLIRedirectURI is the redirect URI used by Gemini CLI for Code Assist OAuth.
  28. GeminiCLIRedirectURI = "https://codeassist.google.com/authcode"
  29. // GeminiCLIOAuthClientID/Secret are the public OAuth client credentials used by Google Gemini CLI.
  30. // They enable the "login without creating your own OAuth client" experience, but Google may
  31. // restrict which scopes are allowed for this client.
  32. GeminiCLIOAuthClientID = "681255809395-oo8ft2oprdrnp9e3aqf6av3hmdib135j.apps.googleusercontent.com"
  33. GeminiCLIOAuthClientSecret = "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"
  34. // GeminiCLIOAuthClientSecretEnv is the environment variable name for the built-in client secret.
  35. GeminiCLIOAuthClientSecretEnv = "GEMINI_CLI_OAUTH_CLIENT_SECRET"
  36. SessionTTL = 30 * time.Minute
  37. // GeminiCLIUserAgent mimics Gemini CLI to maximize compatibility with internal endpoints.
  38. GeminiCLIUserAgent = "GeminiCLI/0.1.5 (Windows; AMD64)"
  39. )