Add /background commands (when background agent is configured) (#4407)

Co-authored-by: Bryan Morgan <bryanmorgan@google.com>
This commit is contained in:
Tommaso Sciortino
2025-07-18 15:38:04 -07:00
committed by GitHub
parent 04bbc60b97
commit 003609239f
12 changed files with 563 additions and 3 deletions

View File

@@ -45,6 +45,10 @@ import {
DEFAULT_GEMINI_FLASH_MODEL,
} from './models.js';
import { ClearcutLogger } from '../telemetry/clearcut-logger/clearcut-logger.js';
import {
BackgroundAgentManager,
loadBackgroundAgentManager,
} from '../background/backgroundManager.js';
export enum ApprovalMode {
DEFAULT = 'default',
@@ -127,6 +131,7 @@ export interface ConfigParameters {
toolCallCommand?: string;
mcpServerCommand?: string;
mcpServers?: Record<string, MCPServerConfig>;
backgroundAgents?: Record<string, MCPServerConfig>;
userMemory?: string;
geminiMdFileCount?: number;
approvalMode?: ApprovalMode;
@@ -158,6 +163,7 @@ export interface ConfigParameters {
export class Config {
private toolRegistry!: ToolRegistry;
private backgroundAgentManager?: BackgroundAgentManager;
private readonly sessionId: string;
private contentGeneratorConfig!: ContentGeneratorConfig;
private readonly embeddingModel: string;
@@ -172,6 +178,7 @@ export class Config {
private readonly toolCallCommand: string | undefined;
private readonly mcpServerCommand: string | undefined;
private readonly mcpServers: Record<string, MCPServerConfig> | undefined;
private readonly backgroundAgents?: Record<string, MCPServerConfig>;
private userMemory: string;
private geminiMdFileCount: number;
private approvalMode: ApprovalMode;
@@ -224,6 +231,7 @@ export class Config {
this.toolCallCommand = params.toolCallCommand;
this.mcpServerCommand = params.mcpServerCommand;
this.mcpServers = params.mcpServers;
this.backgroundAgents = params.backgroundAgents;
this.userMemory = params.userMemory ?? '';
this.geminiMdFileCount = params.geminiMdFileCount ?? 0;
this.approvalMode = params.approvalMode ?? ApprovalMode.DEFAULT;
@@ -281,6 +289,10 @@ export class Config {
if (this.getCheckpointingEnabled()) {
await this.getGitService();
}
this.backgroundAgentManager = await loadBackgroundAgentManager(
this.backgroundAgents,
this.debugMode,
);
this.toolRegistry = await this.createToolRegistry();
}
@@ -406,6 +418,10 @@ export class Config {
return this.mcpServers;
}
getBackgroundAgentManager(): BackgroundAgentManager | undefined {
return this.backgroundAgentManager;
}
getUserMemory(): string {
return this.userMemory;
}