forked from NVIDIA/OpenShell
-
Notifications
You must be signed in to change notification settings - Fork 2
feat: Add Google Cloud Vertex AI provider support #22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
itdove
wants to merge
19
commits into
LobsterTrap:midstream
Choose a base branch
from
itdove:vertex-claude
base: midstream
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+700
−58
Open
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
5a030d0
feat(providers): add Vertex AI provider type
itdove dc36903
docs: clarify that cluster:build:full also starts the gateway
itdove a6cc6a4
docs: add Vertex AI provider to inference and provider docs
itdove 17bf434
feat(vertex): implement GCP OAuth authentication for Vertex AI
itdove 5ac42ba
fix(vertex): use separate thread for OAuth token generation
itdove f606dc3
feat(scripts): improve cleanup script with sandbox deletion and bette…
itdove d36e58b
feat(sandbox): inject Vertex AI credentials as actual environment var…
itdove 2dd3438
feat(vertex): auto-inject CLAUDE_CODE_USE_VERTEX for claude CLI
itdove bc3342d
feat(podman): increase default memory to 12 GB for better build perfo…
itdove b08de19
fix(scripts): update CLI installation command in setup script
itdove b56828e
fix(router): remove model field from Vertex AI request bodies
itdove 308dc5c
docs: add Vertex AI example with network policy
itdove 83a94b9
fix(build): handle Podman --push flag and array expansion
itdove b2d6545
feat(build): add Podman multi-arch support to docker-publish-multiarc…
itdove 8a27b2f
fix: apply cargo fmt formatting to vertex provider
itdove 8241dc7
refactor: remove OAuth token storage from Vertex provider
itdove 987b2a0
docs(vertex): improve ADC detection and troubleshooting docs
itdove c58f3c7
style(vertex): apply cargo fmt formatting
itdove c6a63ea
fix(docker): resolve DNF package dependency conflict in cluster build
itdove File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,3 +12,4 @@ pub mod nvidia; | |
| pub mod openai; | ||
| pub mod opencode; | ||
| pub mod outlook; | ||
| pub mod vertex; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,102 @@ | ||
| // SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| use crate::{ | ||
| DiscoveredProvider, ProviderDiscoverySpec, ProviderError, ProviderPlugin, RealDiscoveryContext, | ||
| discover_with_spec, | ||
| }; | ||
|
|
||
| pub struct VertexProvider; | ||
|
|
||
| pub const SPEC: ProviderDiscoverySpec = ProviderDiscoverySpec { | ||
| id: "vertex", | ||
| credential_env_vars: &["ANTHROPIC_VERTEX_PROJECT_ID"], | ||
| }; | ||
|
|
||
| // Additional config keys for Vertex AI | ||
| const VERTEX_CONFIG_KEYS: &[&str] = &["ANTHROPIC_VERTEX_REGION"]; | ||
|
|
||
| impl ProviderPlugin for VertexProvider { | ||
| fn id(&self) -> &'static str { | ||
| SPEC.id | ||
| } | ||
|
|
||
| fn discover_existing(&self) -> Result<Option<DiscoveredProvider>, ProviderError> { | ||
| let mut discovered = discover_with_spec(&SPEC, &RealDiscoveryContext)?; | ||
|
|
||
| // Add region config if present | ||
| if let Some(ref mut provider) = discovered { | ||
| for &key in VERTEX_CONFIG_KEYS { | ||
| if let Ok(value) = std::env::var(key) { | ||
| provider.config.insert(key.to_string(), value); | ||
| } | ||
| } | ||
|
|
||
| // Set CLAUDE_CODE_USE_VERTEX=1 to enable Vertex AI in claude CLI | ||
| // Must be in credentials (not config) to be injected into sandbox environment | ||
| provider | ||
| .credentials | ||
| .insert("CLAUDE_CODE_USE_VERTEX".to_string(), "1".to_string()); | ||
|
|
||
| // NOTE: We do NOT generate/store VERTEX_OAUTH_TOKEN here. | ||
| // OAuth tokens are short-lived (~1 hour) and storing them leads to stale token pollution. | ||
| // Instead, sandboxes generate fresh tokens on-demand from the uploaded ADC file | ||
| // (requires --upload ~/.config/gcloud/:.config/gcloud/ when creating sandbox). | ||
|
|
||
| // Warn if ADC doesn't exist on host | ||
| let adc_exists = | ||
| if let Ok(custom_path) = std::env::var("GOOGLE_APPLICATION_CREDENTIALS") { | ||
| std::path::Path::new(&custom_path).exists() | ||
| } else { | ||
| let default_path = format!( | ||
| "{}/.config/gcloud/application_default_credentials.json", | ||
| std::env::var("HOME").unwrap_or_default() | ||
| ); | ||
| std::path::Path::new(&default_path).exists() | ||
| }; | ||
|
|
||
| if !adc_exists { | ||
| eprintln!(); | ||
| eprintln!("⚠️ Warning: GCP Application Default Credentials not found"); | ||
| eprintln!(" Sandboxes will need ADC uploaded to generate OAuth tokens."); | ||
| eprintln!(); | ||
| eprintln!(" Configure ADC with:"); | ||
| eprintln!(" gcloud auth application-default login"); | ||
| eprintln!(); | ||
| eprintln!(" Or use a service account key:"); | ||
| eprintln!(" export GOOGLE_APPLICATION_CREDENTIALS=/path/to/key.json"); | ||
| eprintln!(); | ||
| eprintln!(" Then upload credentials when creating sandboxes:"); | ||
| eprintln!(" openshell sandbox create --provider vertex \\"); | ||
| eprintln!(" --upload ~/.config/gcloud/:.config/gcloud/"); | ||
| eprintln!(); | ||
| } | ||
| } | ||
|
|
||
| Ok(discovered) | ||
| } | ||
|
|
||
| fn credential_env_vars(&self) -> &'static [&'static str] { | ||
| SPEC.credential_env_vars | ||
| } | ||
| } | ||
|
|
||
| #[cfg(test)] | ||
| mod tests { | ||
| use super::SPEC; | ||
| use crate::discover_with_spec; | ||
| use crate::test_helpers::MockDiscoveryContext; | ||
|
|
||
| #[test] | ||
| fn discovers_vertex_env_credentials() { | ||
| let ctx = | ||
| MockDiscoveryContext::new().with_env("ANTHROPIC_VERTEX_PROJECT_ID", "my-gcp-project"); | ||
| let discovered = discover_with_spec(&SPEC, &ctx) | ||
| .expect("discovery") | ||
| .expect("provider"); | ||
| assert_eq!( | ||
| discovered.credentials.get("ANTHROPIC_VERTEX_PROJECT_ID"), | ||
| Some(&"my-gcp-project".to_string()) | ||
| ); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this isn't necessary,
misedoes that for you and the contributor guide already tells the contributor to run themisecommands