npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@deltakit/core

v0.1.2

Published

DeltaKit core library

Downloads

32

Readme

@deltakit/core

Framework-agnostic core for building streaming chat UIs over Server-Sent Events (SSE). Provides type-safe message structures, an SSE stream parser, and a converter for OpenAI Agents SDK history. Zero runtime dependencies.

Installation

npm install @deltakit/core

If you're using React, install @deltakit/react instead -- it re-exports everything from @deltakit/core.

Quick Start

import { parseSSEStream } from "@deltakit/core";

const response = await fetch("/api/chat", {
  method: "POST",
  body: JSON.stringify({ message: "Hello" }),
});

for await (const event of parseSSEStream(response.body!)) {
  switch (event.type) {
    case "text_delta":
      process.stdout.write(event.delta);
      break;
    case "tool_call":
      console.log("Tool call:", event.tool_name);
      break;
    case "tool_result":
      console.log("Result:", event.output);
      break;
  }
}

API

parseSSEStream(stream, signal?)

Async generator that converts a raw ReadableStream<Uint8Array> (from fetch().body) into parsed JSON events. Handles chunked data, skips malformed lines, and terminates on data: [DONE].

async function* parseSSEStream(
  stream: ReadableStream<Uint8Array>,
  signal?: AbortSignal,
): AsyncGenerator<SSEEvent>

fromOpenAiAgents(items)

Converts OpenAI Agents SDK response items into DeltaKit Message[] format. Handles all item types including messages, tool calls (function_call, web_search_call, code_interpreter_call, etc.), reasoning, and tool outputs.

import { fromOpenAiAgents } from "@deltakit/core";

const history = await fetch("/api/chat/history").then((r) => r.json());
const messages = fromOpenAiAgents(history);

Types

Messages

interface Message<TPart extends { type: string } = ContentPart> {
  id: string;
  role: "user" | "assistant";
  parts: TPart[];
}

Content Parts

| Type | Description | |------|-------------| | TextPart | { type: "text", text: string } | | ToolCallPart | { type: "tool_call", tool_name, argument, callId?, result? } | | ReasoningPart | { type: "reasoning", text: string } | | ContentPart | Union of all built-in part types |

SSE Events

| Type | Description | |------|-------------| | TextDeltaEvent | { type: "text_delta", delta: string } | | ToolCallEvent | { type: "tool_call", tool_name, argument, call_id? } | | ToolResultEvent | { type: "tool_result", call_id, output } | | SSEEvent | Union of all built-in event types |

Both ContentPart and SSEEvent are extensible via generics for custom types.

SSE Protocol

DeltaKit expects your backend to stream events in standard SSE format:

data: {"type":"text_delta","delta":"Hello"}

data: {"type":"text_delta","delta":" world!"}

data: [DONE]

Documentation

Full documentation, guides, and examples at deltakit.dev.

License

MIT