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:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user