Simplify streaming code for code assist server (#4619)

This commit is contained in:
Tommaso Sciortino
2025-07-21 13:44:43 -07:00
committed by GitHub
parent f95674e646
commit d7a57d85a3
10 changed files with 36 additions and 133 deletions

View File

@@ -22,12 +22,17 @@ export class ProjectIdRequiredError extends Error {
}
}
export interface UserData {
projectId: string;
userTier: UserTierId;
}
/**
*
* @param projectId the user's project id, if any
* @returns the user's actual project id
*/
export async function setupUser(client: OAuth2Client): Promise<string> {
export async function setupUser(client: OAuth2Client): Promise<UserData> {
let projectId = process.env.GOOGLE_CLOUD_PROJECT || undefined;
const caServer = new CodeAssistServer(client, projectId);
@@ -64,7 +69,10 @@ export async function setupUser(client: OAuth2Client): Promise<string> {
await new Promise((f) => setTimeout(f, 5000));
lroRes = await caServer.onboardUser(onboardReq);
}
return lroRes.response?.cloudaicompanionProject?.id || '';
return {
projectId: lroRes.response?.cloudaicompanionProject?.id || '',
userTier: tier.id,
};
}
function getOnboardTier(res: LoadCodeAssistResponse): GeminiUserTier {