export function summarizeDeliveredUserContent(content) {
    if (typeof content === 'string') {
        return { charCount: content.length, imageCount: 0 };
    }
    if (!Array.isArray(content)) {
        return { charCount: 0, imageCount: 0 };
    }
    const textParts = [];
    let imageCount = 0;
    for (const part of content) {
        if (!part || typeof part !== 'object') {
            continue;
        }
        const typedPart = part;
        if (typedPart.type === 'text' && typeof typedPart.text === 'string') {
            textParts.push(typedPart.text);
        }
        else if (typedPart.type === 'image') {
            imageCount++;
        }
    }
    return { charCount: textParts.join('').length, imageCount };
}
export function buildRunAgentMetadata(options) {
    return {
        ...(options.conversationId
            ? { conversationId: options.conversationId, thread_id: options.conversationId }
            : {}),
        platform: 'cli',
        char_count: options.charCount,
        message_length: options.charCount,
        image_count: options.imageCount,
        has_workbook_context: Boolean(options.workbookDetails),
        workbook_count: options.workbookDetails?.workbooks?.length ?? 0,
        workbook_scope_mode: options.workbookDetails?.scopeMode,
        ...(options.userMessageId
            ? { user_message_id: options.userMessageId, turnId: options.userMessageId }
            : {})
    };
}
export function emitRunAgent(observability, metadata) {
    observability?.info?.({
        module: 'agent',
        event: 'run_agent',
        analyticsEvent: true,
        data: metadata
    });
}
//# sourceMappingURL=run-agent-observability.js.map