function formatAsText(messages) {
    const sections = [];
    for (const msg of messages) {
        if (msg.role === 'system') {
            sections.push(`--- system ---\n${msg.content}`);
        }
        else if (msg.role === 'user') {
            const text = msg.content
                .filter((p) => p.type === 'text')
                .map((p) => p.text)
                .join('');
            sections.push(`--- user ---\n${text}`);
        }
    }
    return sections.join('\n\n');
}
export function stubModel() {
    const model = {
        specificationVersion: 'v3',
        provider: 'specverse-stub',
        modelId: 'stub',
        supportedUrls: {},
        async doGenerate(opts) {
            const text = '// SPECVERSE_AI_PROVIDER=stub — no LLM was called.\n' +
                '// The ambient runtime (MCP client, agent, or user) is expected to\n' +
                '// execute the prompt below. To enable real generation, set\n' +
                '// SPECVERSE_AI_PROVIDER to one of: claude-cli, anthropic, openai-compatible.\n' +
                '\n' +
                formatAsText(opts.prompt);
            return {
                content: [{ type: 'text', text }],
                finishReason: { unified: 'stop', raw: undefined },
                usage: {
                    inputTokens: { total: 0, noCache: 0, cacheRead: 0, cacheWrite: 0 },
                    outputTokens: { total: 0, text: 0, reasoning: 0 },
                },
                warnings: [],
            };
        },
        async doStream(opts) {
            const result = await model.doGenerate(opts);
            const text = result.content
                .filter((c) => c.type === 'text')
                .map((c) => c.text)
                .join('');
            const parts = [
                { type: 'text-start', id: 'stub' },
                { type: 'text-delta', id: 'stub', delta: text },
                { type: 'text-end', id: 'stub' },
                { type: 'finish', finishReason: { unified: 'stop', raw: undefined }, usage: result.usage },
            ];
            const stream = new ReadableStream({
                start(controller) {
                    for (const part of parts)
                        controller.enqueue(part);
                    controller.close();
                },
            });
            return { stream };
        },
    };
    return model;
}
//# sourceMappingURL=stub.js.map