import Anthropic from "@anthropic-ai/sdk";
import { betaZodTool } from "@anthropic-ai/sdk/helpers/beta/zod";
import { z } from "zod";
import { stophySearch } from "./stophy";
const client = new Anthropic();
const webSearch = betaZodTool({
name: "web_search",
description: "Search the web. Returns the top results as JSON.",
inputSchema: z.object({ query: z.string().describe("What to search for") }),
run: async ({ query }) => stophySearch(query),
});
const message = await client.beta.messages.toolRunner({
model: "claude-sonnet-5-5",
max_tokens: 16000,
tools: [webSearch],
messages: [{ role: "user", content: "What changed in the latest Bun release?" }],
});
for (const block of message.content) {
if (block.type === "text") console.log(block.text);
}