import { getErrorMessage } from '../../utils'; export { getErrorMessage }; /** * Generate an idempotency key for a single logical tool invocation. * Callers generate it once per call (not per HTTP attempt) so that retries * of the same underlying request (see `RetryStrategy.withRetry`) resend an * identical value, letting the API de-duplicate repeated side effects * (e.g. Slack messages, alarm triggers). */ export declare function newIdempotencyKey(): string; type McpContentItem = { type: 'text'; text: string; } | { type: 'image'; data: string; mimeType: string; }; export type McpToolResult = ReturnType | ReturnType | ReturnType | ReturnType; export declare function mcpTextResponse(text: string): { content: { type: "text"; text: string; }[]; }; /** * 任意の値を pretty-print した JSON テキストとして MCP レスポンスに変換する。 * `mcpTextResponse(JSON.stringify(value, null, 2))` の定型を統一する。 */ export declare function mcpJsonResponse(value: unknown): { content: { type: "text"; text: string; }[]; }; export declare function mcpErrorResponse(message: string): { content: { type: "text"; text: string; }[]; isError: true; }; export declare function mcpImageResponse(base64Data: string, mimeType: string): { content: { type: "image"; data: string; mimeType: string; }[]; }; /** * スクリーンショット Buffer を PNG base64 文字列に変換する。 * browser.ts / browser-local-server.ts 内の `buf.toString('base64')` を統一する。 */ export declare function screenshotToBase64(buf: Buffer): string; export declare function mcpTextImageResponse(text: string, base64Data: string, mimeType: string): { content: McpContentItem[]; }; /** * スクリーンショット Buffer を含む MCP レスポンス(PNG 固定)を生成する。 * `screenshotToBase64` + `mcpTextImageResponse(..., 'image/png')` の合成を統一する。 */ export declare function mcpScreenshotResponse(text: string, screenshot: Buffer): { content: McpContentItem[]; }; /** * MCP ツールハンドラのエラーハンドリングラッパー。 * ツール実装関数を受け取り、例外発生時に `mcpErrorResponse` へ変換して返す。 * AxiosError の場合はHTTPステータスとサーバーメッセージも含めた詳細なエラーを返す。 * * @example * server.tool('my_tool', schema, async (args) => * withMcpErrorHandling(async () => { * const data = await fetchSomething(args) * return mcpTextResponse(data) * }), * ) */ export declare function withMcpErrorHandling(fn: () => Promise): Promise; //# sourceMappingURL=mcp-response.d.ts.map