@kitn.ai/ui
Version:
Framework-agnostic, Shadow-DOM web components for building AI chat interfaces — works in React, Vue, Angular, Svelte, or plain HTML. Authored in SolidJS.
28 lines (23 loc) • 1.26 kB
text/typescript
import type { Integration } from '../types';
const mastra: Integration = {
id: 'mastra',
title: 'Mastra',
category: 'harness',
language: 'ts',
streamFormat: 'openai-sse',
envVars: ['MASTRA_URL'],
routeTemplates: {
express: `// POST /api/chat — your server proxies a Mastra agent to the browser
import { MastraClient } from '@mastra/client-js';
const mastra = new MastraClient({ baseUrl: process.env.MASTRA_URL });
const stream = await mastra.getAgent('supportAgent').stream({ messages });
for await (const delta of stream.textStream) {
res.write(\`data: \${JSON.stringify({ choices: [{ delta: { content: delta } }] })}\\n\\n\`);
}
res.write('data: [DONE]\\n\\n');`,
},
streamMapping: "Mastra agents speak Vercel AI SDK v5 and expose stream.textStream (async iterable of string deltas). Iterate textStream and emit data: {choices:[{delta:{content}}]} frames; close with data: [DONE]. kai-chat's SSE reader handles it. For tool calls and reasoning, convert the agent to a UI message stream with @mastra/ai-sdk.",
runNote: 'Set MASTRA_URL to your Mastra server base URL (mastra dev exposes POST /api/agents/:agentId/stream on port 4111). Install @mastra/client-js.',
docsSlug: 'integrations/harnesses',
};
export default mastra;