@anishroy/pulse
v0.0.2
Published
Realtime for apps and agents: typed events, presence and durable AI streams, with React hooks and components.
Readme
@anishroy/pulse
Realtime for apps and agents: typed events, presence and durable AI streams (plain text or AG-UI), each over one connection per channel. React hooks and components included.
npm install @anishroy/pulse// On your server (PULSE_SECRET_KEY and PULSE_URL from the environment)
import { Pulse } from "@anishroy/pulse/server"
const rt = new Pulse()
await rt.publish("orders:42", "order.status", { status: "shipped" })
const token = await rt.token({
user: { id: "u1", name: "Ana" },
channels: ["orders:*"],
})// In React
import { PulseProvider, useEvent } from "@anishroy/pulse/react"
export function Layout({ children }) {
return (
<PulseProvider url="https://api.pulse.anishroy.com" auth="/api/pulse/token">
{children}
</PulseProvider>
)
}
function OrderStatus() {
const order = useEvent("orders:42", "order.status")
return <p>{order?.status ?? "Waiting…"}</p>
}| Import | For |
| ------------------------------- | ------------------------------------------------------ |
| @anishroy/pulse/server | Tokens, publishing, reading history, AI streams |
| @anishroy/pulse/client | The browser client, without React |
| @anishroy/pulse/react | Hooks: useEvent, usePresence, useStream and more |
| @anishroy/pulse/ui | Components: LiveCursors, AgentThread and more |
| @anishroy/pulse/ui/styles.css | The components' styles |
| @anishroy/pulse/agent | Stream text and AG-UI events folded into state |
| @anishroy/pulse/ai-sdk | PulseChatTransport, for the AI SDK's useChat |
| @anishroy/pulse/cursor | Cursor smoothing, with no framework |
| @anishroy/pulse | defineSchema, PulseError, LIMITS |
React is an optional peer dependency: only /react and /ui need it.
Docs: pulse.anishroy.com/docs
