fix(server): suppress browser popups from ACP probes
Pass NO_BROWSER=true when probing ACP agents for models, modes, and persisted sessions. Gemini CLI's ACP newSession handler calls refreshAuth inline and will open a Google OAuth URL in the browser when no valid cached token is present — every snapshot warm-up triggered this on navigation. Real agent sessions still use their own launchContext.env, so interactive auth continues to work when actually starting an agent.
This commit is contained in:
@@ -107,6 +107,11 @@ const ACP_CLIENT_CAPABILITIES: ACPClientCapabilities = {
|
||||
|
||||
const COPILOT_AUTOPILOT_MODE = "https://agentclientprotocol.com/protocol/session-modes#autopilot";
|
||||
|
||||
// Suppress interactive auth side-effects (e.g. Gemini CLI opening a Google
|
||||
// sign-in URL in the browser) when probing an ACP agent for models/modes.
|
||||
// NO_BROWSER is honored by Gemini CLI; other ACP agents ignore it.
|
||||
const PROBE_ENV: Record<string, string> = { NO_BROWSER: "true" };
|
||||
|
||||
type ACPAgentClientOptions = {
|
||||
provider: string;
|
||||
logger: Logger;
|
||||
@@ -391,7 +396,7 @@ export class ACPAgentClient implements AgentClient {
|
||||
|
||||
async listModels(options?: ListModelsOptions): Promise<AgentModelDefinition[]> {
|
||||
const cwd = options?.cwd ?? process.cwd();
|
||||
const probe = await this.spawnProcess(undefined);
|
||||
const probe = await this.spawnProcess(PROBE_ENV);
|
||||
try {
|
||||
const response = await probe.connection.newSession({
|
||||
cwd,
|
||||
@@ -411,7 +416,7 @@ export class ACPAgentClient implements AgentClient {
|
||||
|
||||
async listModes(options?: ListModesOptions): Promise<AgentMode[]> {
|
||||
const cwd = options?.cwd ?? process.cwd();
|
||||
const probe = await this.spawnProcess(undefined);
|
||||
const probe = await this.spawnProcess(PROBE_ENV);
|
||||
try {
|
||||
const response = await probe.connection.newSession({
|
||||
cwd,
|
||||
@@ -432,7 +437,7 @@ export class ACPAgentClient implements AgentClient {
|
||||
async listPersistedAgents(
|
||||
options?: ListPersistedAgentsOptions,
|
||||
): Promise<PersistedAgentDescriptor[]> {
|
||||
const probe = await this.spawnProcess(undefined);
|
||||
const probe = await this.spawnProcess(PROBE_ENV);
|
||||
try {
|
||||
if (!probe.initialize.agentCapabilities?.sessionCapabilities?.list) {
|
||||
return [];
|
||||
|
||||
Reference in New Issue
Block a user