Skip to content
Agentmart
Submit a tool

streaming-chat

Implement or debug NDJSON streaming chat for service integrations in MultimateAi.

Skill by NarihitoM

IndexedMIT★ 9
Write a review

Chalk Labs

Need help deploying streaming-chat?

Chalk Labs sets up agents like this inside real teams: connected to your tools, tested on your data, with a human in the loop where it matters.

Book a call

Install

Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.

npx agentmarket install skill/narihitom-streaming-chat

Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.

Get the weekly diff

The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.

We use your email only for this newsletter. Privacy

About

Implement or debug NDJSON streaming chat for service integrations in MultimateAi. Use when: wiring up chat endpoints, handling SSE/NDJSON event types, fixing streaming bugs, adding a new chat feature that sends messages and receives typed events.

No reviews yet. Installed it? Reviews come from verified installers only. How reviews work

Permissions

What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.

Tools
No tools found
Secrets
None asked for
Install scripts
None found

Network hosts it talks to 1

  • codeload.github.com · found in install command

Files it touches

  • ~/.claude/skills/streaming-chat

What's inside

Skill name
streaming-chat
Description
Implement or debug NDJSON streaming chat for service integrations in MultimateAi. Use when: wiring up chat endpoints, handling SSE/NDJSON event types, fixing streaming bugs, adding a new chat feature that sends messages and receives typed events.
License
MIT
Instructions
159 lines in SKILL.md · view on GitHub

Before installing

  • Instructions call the network

Files (1)

  • SKILL.md

SKILL.md (first lines)

# Streaming Chat — NDJSON Pattern

## When to Use

- Adding a new service with a chat interface (messages in, typed events out)
- Debugging a streaming endpoint that hangs or drops events
- Understanding the `type: "text" | "thinking" | "status" | "tool_approval_request" | "image" | "error"` event model

## Architecture

All chat features (Chat, Telegram, Slack, Notion, Google Sheets, Google Docs, n8n) use an identical streaming pattern:

```
React Component
  → Zustand store (sending, sessionmessage, provider, model)
    → API function (native fetch + ReadableStream)
      → Backend SSE endpoint (NDJSON over HTTP)
        → callbacks: onChunk, onThinking, onStatus, onApproval, onImage
```

## Streaming API Pattern

Every chat feature's `api/api.ts` must define a `sendmessage` function with these callbacks:

```typescript
sendmessage: async (
  params: SendMessageParams,
  onChunk: (chunk: string, title?: string) => void,
  onThinking?: (chunk: string) => void,
  onStatus?: (data: StatusData) => void,
  onApproval?: (data: ApprovalData) => void,
  onImage?: (url: string) => void,
) => { ... }
```

### NDJSON Event Types

| `type`                  | Callback                 | Payload              | Description                                                |
| ----------------------- | ------------------------ | -------------------- | ---------------------------------------------------------- |
| `text`                  | `onChunk(chunk, title?)` | `{ chunk, title? }`  | Streamed response text. `title` appears on the first chunk |
| `thinking`              | `onThinking(chunk)`      | `{ chunk }`          | Model thinking/reasoning tokens                            |
| `status`                | `onStatus(data)`         | `{ type, data }`     | Status updates (e.g., "searching...", "processing...")     |
| `chain`                 | `onStatus(data)`         | `{ type, data }`     | Agent chain step events (same handler as status)           |
| `tool_approval_request` | `onApproval(data)`       | `{ tool, args, id }` | Human-in-the-loop tool approval request                    |
| `image`                 | `onImage(url)`           | `{ url }`            | Generated image URL                                        |
| `error`                 | throws Error             | `{ message }`        | Fatal error — stop streaming                               |

### Complete Implementation

```typescript
import { fetchurl } from "@/shared/config/fetchconfig";

export const myserviceauth = {
  sendmessage: async (
    credentials: Record<string, any>,
    onChunk: (chunk: string, title?: string) => void,
    onThinking?: (chunk: string) => void,
    onStatus?: (data: any) => void,
    onApproval?: (data: any) => void,
    onImage?: (url: string) => void,
  ) => {
    const response = await fetch(`${fetchurl}/api/myservice/chat`, {
      method: "POST",
      headers: {
        "Content-Type": "application/json",
        Authorization: `Bearer ${await window.api.getToken()}`,
      },
      body: JSON.stringify(credentials),
    });

    if (!response.ok) {
      throw new Error(`HTTP ${response.status}: ${response.statusText}`);
    }

    const reader = response.body!.getReader();
    const decoder = new TextDecoder();

    while (true) {
      const { done, value } = await reader.read();
      if (done) break;

      const text = decoder.decode(value, { stream: true });
      const lines = text.trim().split("\n");

      for (const line of lines) {
        if (!line) continue;
        const data = JSON.parse(line);

        switch (data.type) {
          case "text":
            onChunk(data.chunk, data.title);
            break;
          case "thinking":
            onThinking?.(data.chunk);
            break;
          case "status":
          case "chain":
            onStatus?.(data);
            break;
          case "tool_approval_request":
            onApproval?.(data);
            break;
          case "image":
            onImage?.(data.url);
            break;
          case "error":
            throw new Error(data.message);
        }
      }
    }
  },
};
```

## Hook Integration Pattern

The streaming function is called from a component, usually via a custom hook or inline. The pattern is:

```typescript

From NarihitoM/MultimateAi, MIT.

Signals

Stars
9
Forks
1
Open issues
0
Last commit (this folder)
Jul 23, 2026 (3 months ago)

From GitHub (fetched Oct 24, 2026).

Details

License
MIT
First seen
Oct 24, 2026
Last checked
Oct 24, 2026

More from NarihitoM

Done for you

Rather not set it up yourself?

Chalk Labs scopes, builds and runs agents for your team: the task audit, the eval harness, the integrations and the weekly ops report. Fixed scope, priced before we start.

See how we build AI agents →Read the case studies

Chalk Labs is a two-founder AI and growth studio. We build AI agents, CRMs and MVPs for Web3 and AI companies, and have shipped 50+ product and token launches.

launches shipped
50+
launches shipped
media placements
500+
media placements
founders on every account
2
founders on every account

Press we've placed: Forbes · CoinDesk · Decrypt · Cointelegraph · The Block

Rahil Jain, Co-founder, Chalk Labs. Ex-Goldman Sachs engineer. You talk to the person who builds it.

Get streaming-chat running in your business

Tell us what you want to automate. A founder replies within one working day with a plan, not a pitch deck.

Goes to the Chalk Labs founders, not the newsletter. Privacy

Need help deploying streaming-chat?

CallGet help
Cite this page

streaming-chat skill. Agent Mart. https://agentmart.dev/skills/narihitom-streaming-chat (last updated 2026-10-24)