UNPKG

comfyui-mcp

Version:

Local-first, agent-native control plane for ComfyUI — MCP server + autonomous sidebar agent that drives your live graph in natural language on ANY LLM: Claude/ChatGPT/Gemini on your subscription (no API key), free local models via Ollama (fully offline),

58 lines • 2.37 kB
import { requireOptionalDep } from "../utils/optional-dep.js"; let registryPromise = null; export async function getRegistry() { if (!registryPromise) { registryPromise = (async () => { const [ai, anthropic, google, openai] = await Promise.all([ requireOptionalDep("ai", { feature: "embedded-agent-panel POC", installHint: "npm install ai @ai-sdk/anthropic @ai-sdk/google @ai-sdk/openai", }), requireOptionalDep("@ai-sdk/anthropic", { feature: "Anthropic provider for the agent POC", installHint: "npm install @ai-sdk/anthropic", }), requireOptionalDep("@ai-sdk/google", { feature: "Google provider for the agent POC", installHint: "npm install @ai-sdk/google", }), requireOptionalDep("@ai-sdk/openai", { feature: "OpenAI provider for the agent POC", installHint: "npm install @ai-sdk/openai", }), ]); return ai.createProviderRegistry({ anthropic: anthropic.anthropic, openai: openai.openai, google: google.google, }); })(); } return registryPromise; } const DEFAULT_MODEL = "anthropic:claude-sonnet-4-5"; function allowedModels() { const set = new Set([DEFAULT_MODEL]); const envDefault = process.env.COMFYUI_MCP_AGENT_MODEL?.trim(); if (envDefault) set.add(envDefault); const extra = process.env.COMFYUI_MCP_AGENT_ALLOWED_MODELS; if (extra) { for (const m of extra.split(",")) { const t = m.trim(); if (t) set.add(t); } } return set; } export async function resolveModel(id) { const registry = await getRegistry(); const fallback = process.env.COMFYUI_MCP_AGENT_MODEL?.trim() || DEFAULT_MODEL; const requested = id?.trim(); const modelId = requested && allowedModels().has(requested) ? requested : fallback; // languageModel()'s strict template-literal type doesn't cover arbitrary // ids; we widen at the call site since we already gated by allowlist. return registry.languageModel(modelId); } //# sourceMappingURL=provider-registry.js.map