refactor(tools): narrow optional values

Avoid non-null assertions in tool and doctor code by preserving narrowed locals through each use site.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
YeonGyu-Kim
2026-05-15 16:31:13 +09:00
parent d92e78c956
commit 0a3d1875f7
5 changed files with 27 additions and 15 deletions
+3 -2
View File
@@ -13,10 +13,11 @@ export function normalizeArgs(args: LookAtArgsWithAlias): LookAtArgs {
}
export function validateArgs(args: LookAtArgs): string | null {
const hasFilePath = Boolean(args.file_path && args.file_path.length > 0)
const filePath = args.file_path
const hasFilePath = Boolean(filePath && filePath.length > 0)
const hasImageData = Boolean(args.image_data && args.image_data.length > 0)
if (hasFilePath && /^https?:\/\//i.test(args.file_path!)) {
if (filePath && /^https?:\/\//i.test(filePath)) {
return "Error: Remote URLs are not supported for file_path. Download the file first or use a local path."
}
if (!hasFilePath && !hasImageData) {