UNPKG

@tanstack/ai

Version:

Type-safe TypeScript AI SDK for streaming chat, tool calling, agents, structured outputs, and multimodal generation.

31 lines (30 loc) 1.11 kB
function validateCapabilities(middlewares, adapter) { const provided = /* @__PURE__ */ new Set(); for (const mw of middlewares) { for (const handle of mw.provides ?? []) provided.add(handle); } const providedNames = () => { const names = [...provided].map((h) => h.capabilityName); return names.length ? names.join(", ") : "none"; }; for (const handle of adapter.requires ?? []) { if (!provided.has(handle)) { throw new Error( `Adapter "${adapter.name}" requires capability "${handle.capabilityName}". Provided capabilities: ${providedNames()}. Add a middleware that provides "${handle.capabilityName}".` ); } } for (const mw of middlewares) { for (const handle of mw.requires ?? []) { if (!provided.has(handle)) { throw new Error( `Middleware "${mw.name ?? "unnamed"}" requires capability "${handle.capabilityName}". Provided capabilities: ${providedNames()}. Add a middleware that provides "${handle.capabilityName}".` ); } } } } export { validateCapabilities }; //# sourceMappingURL=validate.js.map