// tools/define-ui-contract/agent-interaction-contract.ts
// SPEC-016a criterion 3: Interaction Contract for AI agent specs.
// Agents interact via channels (chat, email, dashboard, notifications) not UI components.
import { generateAgentInteractionContract, formatInteractionContractAsMarkdown, isAgentSpec, } from '../../engine/agent-spec-generator.js';
export { isAgentSpec };
/**
 * Returns true if the spec/knowledge is for an AI agent project.
 * Agents need an Interaction Contract instead of a standard UI contract.
 */
export function isAgentInteractionContract(knowledge, spec) {
    if (spec && isAgentSpec(spec)) {
        return true;
    }
    if (!knowledge) {
        return false;
    }
    const agentSignals = [
        '@anthropic-ai/sdk',
        '@mastra/core',
        'langgraph',
        'crewai',
        'autogen',
        'openai',
    ];
    return knowledge.stack.some((s) => agentSignals.some((sig) => s.toLowerCase().includes(sig)));
}
/**
 * Generate the Interaction Contract for an agent spec.
 * Criteria 3: channels (chat/email/dashboard/notifications), response formats, escalation rules.
 */
export function generateAgentInteractionContractMarkdown(spec, knowledge) {
    const contract = generateAgentInteractionContract(spec.title, `${spec.title} ${spec.tags.join(' ')}`);
    const markdown = formatInteractionContractAsMarkdown(contract, spec.title);
    const lang = knowledge?.language ?? 'typescript';
    const suffix = lang === 'python' ? 'py' : 'ts';
    const appendix = [
        '',
        '### Agent Interaction Contract Notes',
        '',
        '> This replaces the standard UI Contract for AI agent projects.',
        '> Agents interact through channels and events, not visual components.',
        '',
        '**Key differences from UI Contract:**',
        '- No component tree — agents communicate via message channels',
        '- No loading states — agents use progress updates and streaming',
        '- No error states — agents use escalation and graceful degradation',
        '',
        '### Suggested Files',
        '',
        `- \`src/agents/channels/chat.${suffix}\` — Chat channel handler`,
        `- \`src/agents/channels/notifications.${suffix}\` — Notification dispatcher`,
        `- \`src/agents/escalation.${suffix}\` — Escalation rules and routing`,
    ];
    return markdown + '\n' + appendix.join('\n');
}
//# sourceMappingURL=agent-interaction-contract.js.map