Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/core/src/code_assist/codeAssist.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ describe('codeAssist', () => {
expect(setupUser).toHaveBeenCalledWith(
mockAuthClient,
mockValidationHandler,
httpOptions,
);
expect(MockedCodeAssistServer).toHaveBeenCalledWith(
mockAuthClient,
Expand Down Expand Up @@ -93,6 +94,7 @@ describe('codeAssist', () => {
expect(setupUser).toHaveBeenCalledWith(
mockAuthClient,
mockValidationHandler,
httpOptions,
);
expect(MockedCodeAssistServer).toHaveBeenCalledWith(
mockAuthClient,
Expand Down
6 changes: 5 additions & 1 deletion packages/core/src/code_assist/codeAssist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ export async function createCodeAssistContentGenerator(
authType === AuthType.COMPUTE_ADC
) {
const authClient = await getOauthClient(authType, config);
const userData = await setupUser(authClient, config.getValidationHandler());
const userData = await setupUser(
authClient,
config.getValidationHandler(),
httpOptions,
);
return new CodeAssistServer(
authClient,
userData.projectId,
Expand Down
21 changes: 21 additions & 0 deletions packages/core/src/code_assist/setup.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,27 @@ describe('setupUser for existing user', () => {
);
});

it('should pass httpOptions to CodeAssistServer when provided', async () => {
vi.stubEnv('GOOGLE_CLOUD_PROJECT', 'test-project');
mockLoad.mockResolvedValue({
currentTier: mockPaidTier,
});
const httpOptions = {
headers: {
'User-Agent': 'GeminiCLI/1.0.0/gemini-2.0-flash (darwin; arm64)',
},
};
await setupUser({} as OAuth2Client, undefined, httpOptions);
expect(CodeAssistServer).toHaveBeenCalledWith(
{},
'test-project',
httpOptions,
'',
undefined,
undefined,
);
});

it('should ignore GOOGLE_CLOUD_PROJECT when project from server is set', async () => {
vi.stubEnv('GOOGLE_CLOUD_PROJECT', 'test-project');
mockLoad.mockResolvedValue({
Expand Down
4 changes: 3 additions & 1 deletion packages/core/src/code_assist/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import type {
OnboardUserRequest,
} from './types.js';
import { UserTierId, IneligibleTierReasonCode } from './types.js';
import type { HttpOptions } from './server.js';
import { CodeAssistServer } from './server.js';
import type { AuthClient } from 'google-auth-library';
import type { ValidationHandler } from '../fallback/types.js';
Expand Down Expand Up @@ -77,6 +78,7 @@ export interface UserData {
export async function setupUser(
client: AuthClient,
validationHandler?: ValidationHandler,
httpOptions: HttpOptions = {},
): Promise<UserData> {
const projectId =
process.env['GOOGLE_CLOUD_PROJECT'] ||
Expand All @@ -85,7 +87,7 @@ export async function setupUser(
const caServer = new CodeAssistServer(
client,
projectId,
{},
httpOptions,
'',
undefined,
undefined,
Expand Down
Loading