import { resolvePathUnderWorkspace } from "./tool-paths.js";
import { readdir } from "fs/promises";
import { Type } from "@sinclair/typebox";
//#region src/agent/tools/list-dir.ts
const ListDirSchema = Type.Object({ path: Type.String({ description: "The directory path to list" }) });
function createListDirTool(workspace) {
	return {
		name: "list_dir",
		description: "List the contents of a directory. Relative paths are under the current agent workspace.",
		parameters: ListDirSchema,
		label: "📁 List Directory",
		async execute(_toolCallId, params, _signal) {
			try {
				return {
					content: [{
						type: "text",
						text: (await readdir(resolvePathUnderWorkspace(params.path, workspace), { withFileTypes: true })).map((e) => {
							return `${e.isDirectory() ? "d" : e.isFile() ? "f" : "?"} ${e.name}`;
						}).join("\n") || "(empty)"
					}],
					details: {}
				};
			} catch (error) {
				return {
					content: [{
						type: "text",
						text: `Error listing directory: ${error instanceof Error ? error.message : String(error)}`
					}],
					details: {}
				};
			}
		}
	};
}
const listDirTool = createListDirTool(process.cwd());
//#endregion
export { createListDirTool, listDirTool };

//# sourceMappingURL=list-dir.js.map