Repository navigation
System.ArgumentOutOfRangeException: The value must be greater than or equal to zero and less than the console's buffer size in that dimension #5194
Description
Prerequisites
- Write a descriptive title.
- Make sure you are able to repro it on the latest released version
- Search the existing issues, especially the pinned issues.
Exception report
Oops, something went wrong. Please report this bug with the details below.
Report on GitHub: https://github.com/lzybkr/PSReadLine/issues/new
-----------------------------------------------------------------------
Last 200 Keys:
l o g i c Space + Space " Space } " ; Enter
Space Space Space Space Space Space a w a i t Space f s . w r i t e F i l e ( p a t h . j o i n ( d i r , Space a r g s . n a m e Space + Space " . j s " ) , Space c o d e , Space " u t f 8 " ) ; Enter
Space Space Space Space Space Space r e t u r n Space " S k i l l Space " Space + Space a r g s . n a m e Space + Space " Space t e r s i m p a n . " ; Enter
Space Space Space Space d e f a u l t : Space t h r o w Space n e w Space E r r o r ( " T o o l Space t i d a k Space d i t e m u k a n " ) ; Enter
Space Space } Enter
} '
Exception:
System.ArgumentOutOfRangeException: The value must be greater than or equal to zero and less than the console's buffer size in that dimension.
Parameter name: top
Actual value was -33.
at System.Console.SetCursorPosition(Int32 left, Int32 top)
at Microsoft.PowerShell.PSConsoleReadLine.ReallyRender(RenderData renderData, String defaultColor)
at Microsoft.PowerShell.PSConsoleReadLine.ForceRender()
at Microsoft.PowerShell.PSConsoleReadLine.Insert(Char c)
at Microsoft.PowerShell.PSConsoleReadLine.SelfInsert(Nullable`1 key, Object arg)
at Microsoft.PowerShell.PSConsoleReadLine.ProcessOneKey(ConsoleKeyInfo key, Dictionary`2 dispatchTable, Boolean ignoreIfNoAction, Object arg)
at Microsoft.PowerShell.PSConsoleReadLine.InputLoop()
at Microsoft.PowerShell.PSConsoleReadLine.ReadLine(Runspace runspace, EngineIntrinsics engineIntrinsics)Screenshot
Environment data
PS Version: 5.1.19041.2364
PS HostName: ConsoleHost (Windows Terminal)
PSReadLine Version: 2.0.0-beta2
PSReadLine EditMode: Windows
OS: 10.0.19041.1 (WinBuild.160101.0800)
BufferWidth: 147
BufferHeight: 35Steps to reproduce
Set-Content -Path "src/tools/registry.js" -Value 'import fs from "node:fs/promises";
import path from "node:path";
import { pathToFileURL } from "node:url";
const workspace = path.resolve(process.env.NYX_WORKSPACE ?? "./workspace");
export const getTools = async () => {
const baseTools = [
{ type: "function", function: { name: "write_file", parameters: { type: "object", properties: { path: { type: "string" }, content: { type: "string" } }, required: ["path", "content"] } } },
{ type: "function", function: { name: "read_file", parameters: { type: "object", properties: { path: { type: "string" } }, required: ["path"] } } },
{ type: "function", function: { name: "web_search", parameters: { type: "object", properties: { query: { type: "string" } }, required: ["query"] } } },
{ type: "function", function: { name: "web_fetch", parameters: { type: "object", properties: { url: { type: "string" } }, required: ["url"] } } },
{ type: "function", function: { name: "save_skill", parameters: { type: "object", properties: { name: { type: "string" }, logic: { type: "string" } }, required: ["name", "logic"] } } }
];
const skillDir = path.join(workspace, "skills");
try {
const files = await fs.readdir(skillDir);
for (const file of files) {
if (file.endsWith(".js")) {
const mod = await import(pathToFileURL(path.join(skillDir, file)).href);
if (mod.definition) baseTools.push(mod.definition);
}
}
} catch (e) {}
return baseTools;
};
export async function executeTool(name, args) {
await fs.mkdir(workspace, { recursive: true });
const skillPath = path.join(workspace, "skills", name + ".js");
try {
const mod = await import(pathToFileURL(skillPath).href);
if (mod.execute) return await mod.execute(args);
} catch (e) {}
switch (name) {
case "write_file":
const target = path.resolve(workspace, args.path);
await fs.mkdir(path.dirname(target), { recursive: true });
await fs.writeFile(target, args.content, "utf8");
return "File tersimpan: " + args.path;
case "read_file":
return await fs.readFile(path.resolve(workspace, args.path), "utf8");
case "web_search":
const resSearch = await fetch(process.env.NINEROUTER_URL + "/v1/web/search", { method: "POST", headers: { "Authorization": "Bearer " + process.env.NINEROUTER_KEY, "Content-Type": "application/json" }, body: JSON.stringify({ query: args.query }) });
return JSON.stringify(await resSearch.json());
case "web_fetch":
const resFetch = await fetch(process.env.NINEROUTER_URL + "/v1/web/fetch", { method: "POST", headers: { "Authorization": "Bearer " + process.env.NINEROUTER_KEY, "Content-Type": "application/json" }, body: JSON.stringify({ url: args.url }) });
const data = await resFetch.json();
return data.markdown || "Gagal fetch";
case "save_skill":
const dir = path.join(workspace, "skills");
await fs.mkdir(dir, { recursive: true });
const code = "export const definition = { type: "function", function: { name: "" + args.name + "", parameters: { type: "object", properties: {}, required: [] } } }; export const execute = async () => { " + args.logic + " }";
await fs.writeFile(path.join(dir, args.name + ".js"), code, "utf8");
return "Skill " + args.name + " tersimpan.";
default: throw new Error("Tool tidak ditemukan");
}
}'
Expected behavior
??
Actual behavior
erorrrrrr
Activity
github-actions commentedon Aug 16, 2026
This issue was already fixed (see #1306). Please upgrade to the 2.3.5 version of PSReadLine from PowerShell Gallery.
See the upgrading section for instructions. Please let us know if you run into the same issue with the latest version.