{"id":112672,"plugin_id":"plugin_asdk_app_6af301f5f7c08191b8b2f2581e9bb44d","kind":"skill","collection_source":"plugin_package","comparison_source":null,"observed_at":"2026-11-24T06:10:59.144Z","digest":"0d0864fd92ce8578f97ddbae4aed977ae0e82b732ca967ca49325ed1816159ad","against":null,"payload":{"description":"Stream Vercel AI SDK chat answers over Hibira channels with @hibira-io/ai-sdk so they survive reloads and dropped connections and reach every tab. Use when building a useChat UI, resumable AI chat, background generation, or streaming an agent's progress to a page.","included_files":[],"name":"ai-streaming","skill_md_contents":"---\nname: ai-streaming\ndescription: Stream Vercel AI SDK chat answers over Hibira channels with @hibira-io/ai-sdk so they survive reloads and dropped connections and reach every tab. Use when building a useChat UI, resumable AI chat, background generation, or streaming an agent's progress to a page.\n---\n\n# Streaming AI answers over Hibira\n\n`@hibira-io/ai-sdk` is a `ChatTransport` for the Vercel AI SDK (versions 5, 6 and 7; v7 needs Node 22+). The API route answers at once, generation runs in the background, and chunks travel over a private Hibira channel. Any `useChat` works (React, Vue, Svelte, Angular).\n\nWhat it gives: answers survive dropped connections, `useChat({ resume: true })` picks up an answer still being written after a reload (no Redis or stream store), and every tab subscribed to the chat sees it. Resume needs **channel history**, on Hobby plans and up, turned on in the app's settings.\n\n```sh\nnpm install @hibira-io/ai-sdk pusher-js pusher\n```\n\n## Client\n\n```tsx\n'use client';\nimport { useChat } from '@ai-sdk/react';\nimport Pusher from 'pusher-js';\nimport { HibiraChatTransport } from '@hibira-io/ai-sdk';\n\nconst pusher = new Pusher(process.env.NEXT_PUBLIC_HIBIRA_KEY!, {\n  cluster: 'hkg',\n  wsHost: 'ws.hibira.io',\n  forceTLS: true,\n  channelAuthorization: { endpoint: '/api/hibira/auth', transport: 'ajax' },\n});\nconst transport = new HibiraChatTransport({ pusher, api: '/api/chat' });\n\nconst { messages, sendMessage, status } = useChat({ id, messages: initialMessages, transport, resume: true });\n```\n\nThe transport subscribes to `private-ai-chat-{chatId}` (override with `channel: (chatId) => ...`). Laravel Echo users pass `echo.connector.pusher`.\n\n## Server\n\nIn the chat route, start `streamText` and hand its UI message stream to `publishUIMessageStream` from `@hibira-io/ai-sdk/server` with a server-side `pusher` client; in Next.js wrap the work in `after()` so the route returns at once. Read the package README for the exact signature of the installed version rather than guessing.\n\n## Rules\n\n- Add an auth route (`/api/hibira/auth`) that checks the user owns the chat before signing `private-ai-chat-{chatId}`; otherwise anyone could read another user's answers.\n- The app secret stays on the server.\n- For plain agent progress (not `useChat`), publish small events with the server SDK or the MCP tool `publish_event`; keep each event small (the payload limit is 4 KB on Free and 10 KB or more on paid plans).\n- For tool calls that need a person's OK, see the `agent-approvals` skill.\n"},"changes":[],"summary":"First saved snapshot. No earlier version is available for comparison.","summary_kind":"deterministic","summary_metadata":{}}