set up basic workflow execution

This commit is contained in:
Ramnique Singh 2025-11-07 11:42:10 +05:30
parent 7758139893
commit c004bc5eb6
24 changed files with 794 additions and 298 deletions

View file

@ -152,7 +152,7 @@ export async function startCopilot(): Promise<void> {
}
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
console.log("Rowboat Copilot (type 'exit' to quit)");
console.log("XRowboat Copilot (type 'exit' to quit)");
const debugMode = process.argv.includes("--debug") || process.env.COPILOT_DEBUG === "1";
const conversationHistory: ConversationMessage[] = [];

View file

@ -407,13 +407,23 @@ export async function executeCommand(cmd: ChatCommandT): Promise<CommandOutcome>
}
case "list_mcp_servers": {
const config = readMcpConfig();
const servers = config.mcpServers;
const servers = Object.keys(config.mcpServers);
const list: string[] = [];
for (const server of servers) {
if ('url' in config.mcpServers[server]) {
list.push(`${server}${config.mcpServers[server].url}`);
} else {
list.push(`${server}${config.mcpServers[server].command}`);
}
}
return asCommandOutcome({
headline:
servers.length === 0
? "No MCP servers configured."
: `Found ${servers.length} MCP server${servers.length === 1 ? "" : "s"}.`,
list: servers.map((server) => `${server.name}${server.url}`),
list,
data: servers,
});
}
@ -427,16 +437,14 @@ export async function executeCommand(cmd: ChatCommandT): Promise<CommandOutcome>
});
}
const config = readMcpConfig();
const withoutExisting = config.mcpServers.filter(
(server) => server.name !== serverConfig.name
);
const updated = {
mcpServers: [...withoutExisting, { ...serverConfig }],
config.mcpServers[serverConfig.name] = {
url: serverConfig.url,
headers: {},
};
writeMcpConfig(updated);
writeMcpConfig(config);
return asCommandOutcome({
headline: `MCP server "${serverConfig.name}" saved.`,
data: updated.mcpServers,
data: config.mcpServers,
});
}
case "remove_mcp_server": {
@ -449,16 +457,14 @@ export async function executeCommand(cmd: ChatCommandT): Promise<CommandOutcome>
});
}
const config = readMcpConfig();
const remaining = config.mcpServers.filter(
(server) => server.name !== name
);
const removed = remaining.length !== config.mcpServers.length;
writeMcpConfig({ mcpServers: remaining });
delete config.mcpServers[name];
writeMcpConfig(config);
const removed = name in config.mcpServers;
return asCommandOutcome({
headline: removed
? `MCP server "${name}" removed.`
: `MCP server "${name}" was not registered.`,
data: remaining,
data: config.mcpServers,
});
}
case "run_workflow": {

View file

@ -10,7 +10,7 @@ export function mcpConfigPath(): string {
export function readMcpConfig(): z.infer<typeof McpServerConfig> {
const p = mcpConfigPath();
if (!fs.existsSync(p)) return { mcpServers: [] };
if (!fs.existsSync(p)) return { mcpServers: {} };
const raw = fs.readFileSync(p, "utf8");
return McpServerConfig.parse(JSON.parse(raw));
}