/**
 * Copyright 2025 Vybestack LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
/**
 * Helper type guards for content blocks
 */
export const ContentBlockGuards = {
    isTextBlock: (block) => block.type === 'text',
    isToolCallBlock: (block) => block.type === 'tool_call',
    isToolResponseBlock: (block) => block.type === 'tool_response',
    isMediaBlock: (block) => block.type === 'media',
    isThinkingBlock: (block) => block.type === 'thinking',
    isCodeBlock: (block) => block.type === 'code',
};
/**
 * Helper to create IContent instances
 */
export const ContentFactory = {
    createUserMessage: (text, metadata) => ({
        speaker: 'human',
        blocks: [{ type: 'text', text }],
        metadata,
    }),
    createAIMessage: (blocks, metadata) => ({
        speaker: 'ai',
        blocks,
        metadata,
    }),
    createToolResponse: (callId, toolName, result, error, metadata) => ({
        speaker: 'tool',
        blocks: [
            {
                type: 'tool_response',
                callId,
                toolName,
                result,
                error,
            },
        ],
        metadata,
    }),
};
/**
 * Validation helpers
 */
export const ContentValidation = {
    /**
     * Check if content has meaningful content (not empty)
     */
    hasContent: (content) => {
        if (!content.blocks || content.blocks.length === 0) {
            return false;
        }
        return content.blocks.some((block) => {
            switch (block.type) {
                case 'text':
                    return block.text.trim().length > 0;
                case 'tool_call':
                case 'tool_response':
                case 'media':
                case 'code':
                    return true;
                case 'thinking':
                    return block.thought.trim().length > 0;
                default:
                    return false;
            }
        });
    },
    /**
     * Check if content is valid for inclusion in history
     */
    isValid: (content) => {
        // Must have a valid speaker
        if (!['human', 'ai', 'tool'].includes(content.speaker)) {
            return false;
        }
        // Must have at least one block
        if (!content.blocks || content.blocks.length === 0) {
            return false;
        }
        // Tool responses must have tool_response blocks
        if (content.speaker === 'tool') {
            const hasToolResponse = content.blocks.some((b) => b.type === 'tool_response');
            if (!hasToolResponse) {
                return false;
            }
        }
        return true;
    },
};
//# sourceMappingURL=IContent.js.map