"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.createStatusSetTool = void 0;
const ai_1 = require("ai");
const toolDefinitions_1 = require("../../utils/tools/toolDefinitions");
/**
 * Validates that a string is a single emoji character
 * Uses Unicode property escapes to match emoji characters
 */
function isValidEmoji(str) {
    // Check if string contains exactly one character (handles multi-byte emojis)
    const chars = [...str];
    if (chars.length !== 1) {
        return false;
    }
    // Check if it's an emoji using Unicode properties
    const emojiRegex = /^[\p{Emoji_Presentation}\p{Extended_Pictographic}]$/u;
    return emojiRegex.test(str);
}
/**
 * Status set tool factory for AI assistant
 * Creates a tool that allows the AI to set status indicator showing current activity
 * @param config Required configuration (not used for this tool, but required by interface)
 */
const createStatusSetTool = () => {
    return (0, ai_1.tool)({
        description: toolDefinitions_1.TOOL_DEFINITIONS.status_set.description,
        inputSchema: toolDefinitions_1.TOOL_DEFINITIONS.status_set.schema,
        execute: ({ emoji, message }) => {
            // Validate emoji
            if (!isValidEmoji(emoji)) {
                return Promise.resolve({
                    success: false,
                    error: "emoji must be a single emoji character",
                });
            }
            // Tool execution is a no-op on the backend
            // The status is tracked by StreamingMessageAggregator and displayed in the frontend
            return Promise.resolve({
                success: true,
                emoji,
                message,
            });
        },
    });
};
exports.createStatusSetTool = createStatusSetTool;
//# sourceMappingURL=status_set.js.map