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";
|
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 = {
|
type ACPAgentClientOptions = {
|
||||||
provider: string;
|
provider: string;
|
||||||
logger: Logger;
|
logger: Logger;
|
||||||
@@ -391,7 +396,7 @@ export class ACPAgentClient implements AgentClient {
|
|||||||
|
|
||||||
async listModels(options?: ListModelsOptions): Promise<AgentModelDefinition[]> {
|
async listModels(options?: ListModelsOptions): Promise<AgentModelDefinition[]> {
|
||||||
const cwd = options?.cwd ?? process.cwd();
|
const cwd = options?.cwd ?? process.cwd();
|
||||||
const probe = await this.spawnProcess(undefined);
|
const probe = await this.spawnProcess(PROBE_ENV);
|
||||||
try {
|
try {
|
||||||
const response = await probe.connection.newSession({
|
const response = await probe.connection.newSession({
|
||||||
cwd,
|
cwd,
|
||||||
@@ -411,7 +416,7 @@ export class ACPAgentClient implements AgentClient {
|
|||||||
|
|
||||||
async listModes(options?: ListModesOptions): Promise<AgentMode[]> {
|
async listModes(options?: ListModesOptions): Promise<AgentMode[]> {
|
||||||
const cwd = options?.cwd ?? process.cwd();
|
const cwd = options?.cwd ?? process.cwd();
|
||||||
const probe = await this.spawnProcess(undefined);
|
const probe = await this.spawnProcess(PROBE_ENV);
|
||||||
try {
|
try {
|
||||||
const response = await probe.connection.newSession({
|
const response = await probe.connection.newSession({
|
||||||
cwd,
|
cwd,
|
||||||
@@ -432,7 +437,7 @@ export class ACPAgentClient implements AgentClient {
|
|||||||
async listPersistedAgents(
|
async listPersistedAgents(
|
||||||
options?: ListPersistedAgentsOptions,
|
options?: ListPersistedAgentsOptions,
|
||||||
): Promise<PersistedAgentDescriptor[]> {
|
): Promise<PersistedAgentDescriptor[]> {
|
||||||
const probe = await this.spawnProcess(undefined);
|
const probe = await this.spawnProcess(PROBE_ENV);
|
||||||
try {
|
try {
|
||||||
if (!probe.initialize.agentCapabilities?.sessionCapabilities?.list) {
|
if (!probe.initialize.agentCapabilities?.sessionCapabilities?.list) {
|
||||||
return [];
|
return [];
|
||||||
|
|||||||
Reference in New Issue
Block a user