feat(cli): Partial threading of AgentLoopContext. (#22978)

This commit is contained in:
joshualitt
2026-03-19 09:02:13 -07:00
committed by GitHub
parent 5acaacad96
commit 39d3b0e28c
68 changed files with 608 additions and 421 deletions
+17 -12
View File
@@ -42,8 +42,8 @@ const authCommand: SlashCommand = {
args: string,
): Promise<MessageActionReturn> => {
const serverName = args.trim();
const { config } = context.services;
const agentContext = context.services.agentContext;
const config = agentContext?.config;
if (!config) {
return {
type: 'message',
@@ -138,7 +138,7 @@ const authCommand: SlashCommand = {
await mcpClientManager.restartServer(serverName);
}
// Update the client with the new tools
const geminiClient = config.getGeminiClient();
const geminiClient = context.services.agentContext?.geminiClient;
if (geminiClient?.isInitialized()) {
await geminiClient.setTools();
}
@@ -162,7 +162,8 @@ const authCommand: SlashCommand = {
}
},
completion: async (context: CommandContext, partialArg: string) => {
const { config } = context.services;
const agentContext = context.services.agentContext;
const config = agentContext?.config;
if (!config) return [];
const mcpServers = config.getMcpClientManager()?.getMcpServers() || {};
@@ -177,7 +178,8 @@ const listAction = async (
showDescriptions = false,
showSchema = false,
): Promise<void | MessageActionReturn> => {
const { config } = context.services;
const agentContext = context.services.agentContext;
const config = agentContext?.config;
if (!config) {
return {
type: 'message',
@@ -188,7 +190,7 @@ const listAction = async (
config.setUserInteractedWithMcp();
const toolRegistry = config.getToolRegistry();
const toolRegistry = agentContext.toolRegistry;
if (!toolRegistry) {
return {
type: 'message',
@@ -334,7 +336,8 @@ const reloadCommand: SlashCommand = {
action: async (
context: CommandContext,
): Promise<void | SlashCommandActionReturn> => {
const { config } = context.services;
const agentContext = context.services.agentContext;
const config = agentContext?.config;
if (!config) {
return {
type: 'message',
@@ -360,7 +363,7 @@ const reloadCommand: SlashCommand = {
await mcpClientManager.restart();
// Update the client with the new tools
const geminiClient = config.getGeminiClient();
const geminiClient = agentContext.geminiClient;
if (geminiClient?.isInitialized()) {
await geminiClient.setTools();
}
@@ -377,7 +380,8 @@ async function handleEnableDisable(
args: string,
enable: boolean,
): Promise<MessageActionReturn> {
const { config } = context.services;
const agentContext = context.services.agentContext;
const config = agentContext?.config;
if (!config) {
return {
type: 'message',
@@ -465,8 +469,8 @@ async function handleEnableDisable(
);
await mcpClientManager.restart();
}
if (config.getGeminiClient()?.isInitialized())
await config.getGeminiClient().setTools();
if (agentContext.geminiClient?.isInitialized())
await agentContext.geminiClient.setTools();
context.ui.reloadCommands();
return { type: 'message', messageType: 'info', content: msg };
@@ -477,7 +481,8 @@ async function getEnablementCompletion(
partialArg: string,
showEnabled: boolean,
): Promise<string[]> {
const { config } = context.services;
const agentContext = context.services.agentContext;
const config = agentContext?.config;
if (!config) return [];
const servers = Object.keys(
config.getMcpClientManager()?.getMcpServers() || {},