feat: Created a demo TypeScript tool and a get_current_weather function in TypeScript

This commit is contained in:
2026-04-09 13:18:41 -06:00
parent 4caa035528
commit 11334149b0
2 changed files with 77 additions and 0 deletions
@@ -0,0 +1,24 @@
#!/usr/bin/env tsx
import { appendFileSync, mkdirSync } from "fs";
import { dirname } from "path";
/**
* Get the current weather in a given location
* @param location - The city and optionally the state or country (e.g., "London", "San Francisco, CA").
*/
export async function run(location: string): string {
const encoded = encodeURIComponent(location);
const url = `https://wttr.in/${encoded}?format=4`;
const resp = await fetch(url);
const data = await resp.text();
const dest = process.env["LLM_OUTPUT"] ?? "/dev/stdout";
if (dest !== "-" && dest !== "/dev/stdout") {
mkdirSync(dirname(dest), { recursive: true });
appendFileSync(dest, data, "utf-8");
}
return data;
}