Skip to content

Pool Gemini subscriptions through Prism - #32

Merged
ygpark80 merged 2 commits into
mainfrom
fix/gemini-subscription-pool
Aug 29, 2026
Merged

Pool Gemini subscriptions through Prism#32
ygpark80 merged 2 commits into
mainfrom
fix/gemini-subscription-pool

Conversation

@ygpark80

@ygpark80 ygpark80 commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

User description

Summary

  • import the active Antigravity subscription login from the OS keyring into Prism
  • run the official Gemini CLI through Prism account rotation instead of invoking Agy directly
  • show every registered Gemini account and subscription quota
  • support explicit Circles profiles and Gemini account selection

Verification

  • go test -mod=vendor ./...
  • go test -mod=vendor -race ./...
  • go vet -mod=vendor ./...
  • live dev import, account listing, quota lookup, and official Gemini CLI response through Prism

CodeAnt-AI Description

Pool Gemini subscription accounts through Prism

What Changed

  • Import the active Antigravity subscription login from the operating system keyring with prism gemini auth import
  • Run the official Gemini CLI through Prism’s gateway instead of invoking Antigravity directly
  • Rotate automatically across registered Gemini subscription accounts, or select one with --account
  • Support named Prism profiles with Gemini commands and usage checks
  • Show quota information for every registered Gemini account and keep Code Assist OAuth login available separately
  • Reject missing, corrupt, stale, or incomplete Antigravity logins with actionable errors

Impact

✅ Gemini requests rotate across subscription accounts
✅ Fewer subscription setup steps
✅ Clearer Gemini account and quota visibility

💡 Usage Guide

Checking Your Pull Request

Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.

Talking to CodeAnt AI

Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:

@codeant-ai ask: Your question here

This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.

Example

@codeant-ai ask: Can you suggest a safer alternative to storing this secret?

Preserve Org Learnings with CodeAnt

You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:

@codeant-ai: Your feedback here

This helps CodeAnt AI learn and adapt to your team's coding style and standards.

Example

@codeant-ai: Do not flag unused imports.

Retrigger review

Ask CodeAnt AI to review the PR again, by typing:

@codeant-ai: review

Check Your Repository Health

To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.

@codeant-ai

codeant-ai Bot commented Aug 29, 2026

Copy link
Copy Markdown

🤖 CodeAnt AI — Review Status

Status Commit Started (UTC) Finished (UTC)
✅ Reviewed your PR 4d00a83 Aug 29, 2026 · 08:57 09:01

@codeant-ai

codeant-ai Bot commented Aug 29, 2026

Copy link
Copy Markdown

Thanks for using CodeAnt! 🎉

We're free for open-source projects. if you're enjoying it, help us grow by sharing.

Share on X ·
Reddit ·
LinkedIn

@coderabbitai

coderabbitai Bot commented Aug 29, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: d59077ff-6b67-42f1-b628-cd29cb608b6f


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codeant-ai codeant-ai Bot added the size:XXL This PR changes 1000+ lines, ignoring generated files label Aug 29, 2026
Comment thread internal/cli/gemini.go
Comment on lines +159 to +204
for index := 0; index < len(args); index++ {
argument := args[index]
switch {
case argument == "--":
return options, account, append(passthrough, args[index:]...), nil
case argument == "--profile":
if options.profileSet {
return commonOptions{}, "", nil, errors.New("--profile may be specified only once")
}
index++
if index >= len(args) || strings.TrimSpace(args[index]) == "" || args[index] == "--" {
return commonOptions{}, "", nil, errors.New("--profile requires a value")
}
options.profile = strings.TrimSpace(args[index])
options.profileSet = true
case strings.HasPrefix(argument, "--profile="):
if options.profileSet {
return commonOptions{}, "", nil, errors.New("--profile may be specified only once")
}
options.profile = strings.TrimSpace(strings.TrimPrefix(argument, "--profile="))
if options.profile == "" {
return commonOptions{}, "", nil, errors.New("--profile requires a value")
}
options.profileSet = true
case argument == "--account":
if account != "" {
return commonOptions{}, "", nil, errors.New("--account may be specified only once")
}
index++
if index >= len(args) || strings.TrimSpace(args[index]) == "" || args[index] == "--" {
return commonOptions{}, "", nil, errors.New("--account requires a value")
}
account = strings.TrimSpace(args[index])
case strings.HasPrefix(argument, "--account="):
if account != "" {
return commonOptions{}, "", nil, errors.New("--account may be specified only once")
}
account = strings.TrimSpace(strings.TrimPrefix(argument, "--account="))
if account == "" {
return commonOptions{}, "", nil, errors.New("--account requires a value")
}
default:
passthrough = append(passthrough, argument)
}
filtered = append(filtered, entry)
}
return filtered
}

func parseGeminiOptions(args []string) (string, []string, error) {
account, passthrough, err := parseClaudeOptions(args)
if err != nil {
return "", nil, err
}
return account, passthrough, nil
return options, account, passthrough, nil

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: parseGeminiOptions consumes every --profile and --account token before --, regardless of whether it is intended for the Gemini CLI. For example, a prompt or another CLI argument whose value is --profile will be interpreted as Prism's profile flag and removed from the child process arguments, causing valid Gemini CLI invocations to fail or behave differently. Restrict Prism option parsing to the owned option position or require -- before passthrough arguments. [logic error]

Severity Level: Major ⚠️
- ❌ Gemini prompt invocations collide with Prism-owned flags.
- ⚠️ Official CLI arguments can be silently removed.

Use CodeAnt Skill Fix in Cursor Fix in VSCode Claude

Prompt for AI Agent 🤖
This is a comment left during a code review.

**Path:** internal/cli/gemini.go
**Line:** 159:204
**Comment:**
	*Logic Error: `parseGeminiOptions` consumes every `--profile` and `--account` token before `--`, regardless of whether it is intended for the Gemini CLI. For example, a prompt or another CLI argument whose value is `--profile` will be interpreted as Prism's profile flag and removed from the child process arguments, causing valid Gemini CLI invocations to fail or behave differently. Restrict Prism option parsing to the owned option position or require `--` before passthrough arguments.

Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
👍 | 👎

Comment on lines +40 to +43
encoded, err := readSecret()
if err != nil {
return Bundle{}, errors.New("Antigravity login was not found; sign in with 'agy' first")
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: All keyring failures are reported as a missing login. Permission failures, an unavailable Secret Service or D-Bus session, and other backend errors are therefore converted into incorrect recovery instructions telling the user to sign in with agy, even when a valid login exists. Preserve or wrap the underlying error and only use the missing-login message for keyring.ErrNotFound. [possible bug]

Severity Level: Major ⚠️
- ❌ Valid Antigravity imports fail under keyring outages.
- ⚠️ Recovery instructions incorrectly request reauthentication.

Use CodeAnt Skill Fix in Cursor Fix in VSCode Claude

Prompt for AI Agent 🤖
This is a comment left during a code review.

**Path:** internal/gemini/antigravity.go
**Line:** 40:43
**Comment:**
	*Possible Bug: All keyring failures are reported as a missing login. Permission failures, an unavailable Secret Service or D-Bus session, and other backend errors are therefore converted into incorrect recovery instructions telling the user to sign in with `agy`, even when a valid login exists. Preserve or wrap the underlying error and only use the missing-login message for `keyring.ErrNotFound`.

Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
👍 | 👎

Comment on lines +82 to +91
return Bundle{
AccessToken: login.Token.AccessToken,
RefreshToken: login.Token.RefreshToken,
ProjectID: projectID,
Email: email,
Alias: alias,
ExpiresAt: login.Token.Expiry.UnixMilli(),
AuthMethod: "antigravity",
UserAgent: "antigravity/cli/" + version,
}, nil

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: Imported Gemini bundles omit AccountID, even though the normal Gemini OAuth flow populates it with the Code Assist project ID. The saved Antigravity credential therefore has a different identity shape and may not be deduplicated or associated correctly by Prism; populate the same account identifier when constructing the imported bundle. [api mismatch]

Severity Level: Major ⚠️
- ⚠️ Imported accounts omit Gemini account identity.
- ⚠️ Deduplication may differ from OAuth accounts.

Use CodeAnt Skill Fix in Cursor Fix in VSCode Claude

Prompt for AI Agent 🤖
This is a comment left during a code review.

**Path:** internal/gemini/antigravity.go
**Line:** 82:91
**Comment:**
	*Api Mismatch: Imported Gemini bundles omit `AccountID`, even though the normal Gemini OAuth flow populates it with the Code Assist project ID. The saved Antigravity credential therefore has a different identity shape and may not be deduplicated or associated correctly by Prism; populate the same account identifier when constructing the imported bundle.

Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
👍 | 👎

@ygpark80
ygpark80 merged commit 119af56 into main Aug 29, 2026
1 check passed
@ygpark80
ygpark80 deleted the fix/gemini-subscription-pool branch August 29, 2026 09:00
Comment on lines +41 to +44
func (h *defaultHandler) PathExists(path ObjectPath) bool {
_, ok := h.objects[path]
return ok
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: PathExists reads the shared object map without taking the handler read lock, even though callers use it while exports and unexports can concurrently add or delete entries. This creates a data race and can produce inconsistent check-then-add or check-then-delete behavior. [race condition]

Severity Level: Major ⚠️
- ❌ Concurrent export operations can trigger map races.
- ⚠️ Dynamic interface registration may observe inconsistent state.

Use CodeAnt Skill Fix in Cursor Fix in VSCode Claude

Prompt for AI Agent 🤖
This is a comment left during a code review.

**Path:** vendor/github.com/godbus/dbus/v5/default_handler.go
**Line:** 41:44
**Comment:**
	*Race Condition: `PathExists` reads the shared object map without taking the handler read lock, even though callers use it while exports and unexports can concurrently add or delete entries. This creates a data race and can produce inconsistent check-then-add or check-then-delete behavior.

Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
👍 | 👎

Comment on lines +55 to +56
if after, ok := strings.CutPrefix(string(obj), p); ok {
name, _, _ := strings.Cut(after, "/")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: introspectPath iterates over h.objects without holding the handler lock, while AddObject and DeleteObject mutate the same map under that lock. Concurrent introspection and export/unexport operations can trigger a Go concurrent map iteration/write panic and are reported by the race detector. [race condition]

Severity Level: Critical 🚨
- ❌ Concurrent introspection can crash the D-Bus process.
- ⚠️ Runtime export and unexport operations become unsafe.

Use CodeAnt Skill Fix in Cursor Fix in VSCode Claude

Prompt for AI Agent 🤖
This is a comment left during a code review.

**Path:** vendor/github.com/godbus/dbus/v5/default_handler.go
**Line:** 55:56
**Comment:**
	*Race Condition: `introspectPath` iterates over `h.objects` without holding the handler lock, while `AddObject` and `DeleteObject` mutate the same map under that lock. Concurrent introspection and export/unexport operations can trigger a Go concurrent map iteration/write panic and are reported by the race detector.

Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
👍 | 👎

Comment on lines +153 to +155
if hlen+t.rdr.BodyLen+16 > 1<<27 {
return nil, InvalidMessageError("message is too long")
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: The message-size check performs the addition using uint32 values before comparing with the 128 MiB limit. Malicious header and body lengths can overflow that sum, bypass the limit, and then cause make([]byte, t.rdr.BodyLen) or the subsequent read to allocate or process an excessively large message. [possible bug]

Severity Level: Critical 🚨
- ❌ Malformed D-Bus messages can bypass size limits.
- ❌ Excessive allocations can terminate the process through memory exhaustion.

Use CodeAnt Skill Fix in Cursor Fix in VSCode Claude

Prompt for AI Agent 🤖
This is a comment left during a code review.

**Path:** vendor/github.com/godbus/dbus/v5/transport_unix.go
**Line:** 153:155
**Comment:**
	*Possible Bug: The message-size check performs the addition using `uint32` values before comparing with the 128 MiB limit. Malicious header and body lengths can overflow that sum, bypass the limit, and then cause `make([]byte, t.rdr.BodyLen)` or the subsequent read to allocate or process an excessively large message.

Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
👍 | 👎

Comment on lines +205 to +209
fds, err := syscall.ParseUnixRights(&scms[0])
if err != nil {
return nil, err
}
dec.Reset(r, order, fds)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: File descriptors parsed from ancillary data are not closed on any subsequent error path, including unsupported FD passing, invalid body decoding, or invalid FD indices. A peer can repeatedly send malformed messages with descriptors and exhaust the process file-descriptor limit. [resource leak]

Severity Level: Critical 🚨
- ❌ Malformed FD messages can exhaust process descriptors.
- ⚠️ Subsequent D-Bus connections and file operations may fail.

Use CodeAnt Skill Fix in Cursor Fix in VSCode Claude

Prompt for AI Agent 🤖
This is a comment left during a code review.

**Path:** vendor/github.com/godbus/dbus/v5/transport_unix.go
**Line:** 205:209
**Comment:**
	*Resource Leak: File descriptors parsed from ancillary data are not closed on any subsequent error path, including unsupported FD passing, invalid body decoding, or invalid FD indices. A peer can repeatedly send malformed messages with descriptors and exhaust the process file-descriptor limit.

Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
👍 | 👎

@codeant-ai

codeant-ai Bot commented Aug 29, 2026

Copy link
Copy Markdown

CodeAnt Nitpicks

2 code suggestions

1. Valid single-type signatures are reported as non-single while invalid signatures may be reported as single.

Incorrect condition logic · vendor/github.com/godbus/dbus/v5/sig.go:158-160


2. Prompt handling leaks registered D-Bus signal channels across operations.

Resource leak · vendor/github.com/zalando/go-keyring/secret_service/secret_service.go:200-203

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XXL This PR changes 1000+ lines, ignoring generated files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant