"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.registerIntegrationsTools = void 0;
const v3_1 = require("zod/v3");
const logger_1 = require("../../utils/logger");
const log = (0, logger_1.createLogger)('mcp-integrations');
const jsonResponse = (payload) => ({
    content: [{ type: 'text', text: JSON.stringify(payload) }],
});
const fetchPinterestArgs = {
    url: v3_1.z
        .string()
        .describe("A Pinterest pin URL (e.g. https://www.pinterest.com/pin/<id>/) or board URL (https://www.pinterest.com/<user>/<board>/), including the user's secret boards."),
};
/**
 * Register the guarded `fetch_pinterest` tool. Pass the wrapped (auth-guarded)
 * McpServer so an unauthenticated call returns AUTH_REQUIRED before this runs.
 * Returns normalized pin/board data, or the soft `{ status: 'not_connected',
 * connectUrl }` payload when the user has not connected Pinterest — never a
 * hard block.
 */
const registerIntegrationsTools = (mcp, deps) => {
    mcp.tool('fetch_pinterest', 'Fetch authenticated Pinterest data (pins + boards, including the user\'s secret boards) for a shared Pinterest link, using the user\'s connected Pinterest account. Returns normalized pins (image URLs, dominant color, title, description) for synthesis. If the user has not connected Pinterest, returns { status: "not_connected", connectUrl } — nudge the user with the connect URL and fall back to your existing public-link handling.', fetchPinterestArgs, async (args) => {
        try {
            const result = await deps.integrationsClient.fetchPinterest(args.url);
            return jsonResponse(result);
        }
        catch (error) {
            log.warn('fetch_pinterest tool error:', error);
            return jsonResponse({
                status: 'error',
                message: error instanceof Error ? error.message : 'Unknown error',
            });
        }
    });
};
exports.registerIntegrationsTools = registerIntegrationsTools;
//# sourceMappingURL=tools.js.map