import type { ChatCompletionTool } from "openai/resources/chat/completions"; import z from "zod"; import { bot } from "../core"; import { compactProfile, resolvePostUri } from "./bsky"; export const validator = z.object({ post: z.string().describe("The at:// URI or bsky.app URL of the post."), limit: z.number().int().min(1).max(50).optional().describe( "Number of accounts to return. Defaults to 20.", ), }); export const definition: ChatCompletionTool = { type: "function", function: { name: "get_reposts", description: "Lists the accounts that reposted a post.", parameters: z.toJSONSchema(validator), }, }; export async function handler(args: z.infer) { const uri = await resolvePostUri(args.post); const { data } = await bot.agent.get("app.bsky.feed.getRepostedBy", { params: { uri: uri as any, limit: args.limit ?? 20 }, }); return data.repostedBy.map(compactProfile); }