mirror of
https://gitlab.com/soapbox-pub/shakespeare.git
synced 2026-12-05 16:23:36 +00:00
35 lines
994 B
TypeScript
35 lines
994 B
TypeScript
import { z } from "zod";
|
|
|
|
import type { Tool, ToolResult } from "./Tool";
|
|
import { NostrbookClient } from "../NostrbookClient";
|
|
|
|
interface NostrReadProtocolParams {
|
|
doc: 'index' | 'event' | 'filter' | 'client' | 'relay';
|
|
}
|
|
|
|
export class NostrReadProtocolTool implements Tool<NostrReadProtocolParams> {
|
|
private nostrbookClient: NostrbookClient;
|
|
|
|
readonly description = "Read Nostr protocol basics";
|
|
|
|
readonly inputSchema = z.object({
|
|
doc: z.enum(['index', 'event', 'filter', 'client', 'relay']),
|
|
});
|
|
|
|
constructor() {
|
|
this.nostrbookClient = new NostrbookClient({
|
|
baseUrl: 'https://nostrbook.dev',
|
|
});
|
|
}
|
|
|
|
async execute(args: NostrReadProtocolParams): Promise<ToolResult> {
|
|
const { doc } = args;
|
|
|
|
try {
|
|
const text = await this.nostrbookClient.readProtocol(doc);
|
|
return { content: text };
|
|
} catch (error) {
|
|
throw new Error(`Error reading protocol doc "${doc}": ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
}
|
|
}
|
|
} |