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

@meshagent/meshagent-agents

v0.44.13

Published

Agent chat sessions and clients for Meshagent TypeScript applications.

Readme

meshagent-agents-ts

TypeScript agent chat session and transport helpers for Meshagent applications.

It provides:

  • Agent message constants and JSON models for the Meshagent agent protocol.
  • Chat clients and thread sessions for sending turns over Meshagent room messaging.
  • Dataset helpers for thread lists and generated images.

Install

npm install @meshagent/meshagent-agents @meshagent/meshagent

In this repository workspace the package is available from meshagent-agents-ts.

Imports

import {
  AgentMessage,
  MessagingChatClient,
  ImagesDataset,
  DatasetThreadStorageRepository,
  TurnStart,
  agentInputContent,
} from "@meshagent/meshagent-agents";

Agent Messages

Every protocol message is represented by a class with toJson() and can be parsed with AgentMessage.fromJson(...).

import {
  AgentMessage,
  TurnStart,
  agentInputContent,
} from "@meshagent/meshagent-agents";

const message = new TurnStart({
  threadId: "dataset://threads/example",
  content: agentInputContent({
    text: "Summarize this file.",
    attachments: ["dataset://assets/files/report.pdf"],
  }),
  provider: "openai",
  model: "gpt-5.4",
});

const wirePayload = message.toJson();
const parsed = AgentMessage.fromJson(wirePayload);

The package exports the message type constants as well, for example agentTurnStartType, agentThreadStartedType, and agentToolCallApprovalRequestedType.

Chat Client

MessagingChatClient sends and receives agent protocol messages through a Meshagent RoomClient messaging channel. The target agent participant must advertise supports_agent_messages: true; optionally pass agentName to select one named agent.

import {
  MessagingChatClient,
  agentTextContentDeltaType,
} from "@meshagent/meshagent-agents";
import type { RoomClient } from "@meshagent/meshagent";

const room: RoomClient = /* create and start your room client */;

const chat = new MessagingChatClient({ room, agentName: "assistant" });
await chat.start();

const { session, threadPath, realtimeConnection } = await chat.startThread({
  message: "Create a project plan.",
  attachments: [],
  provider: "openai",
  model: "gpt-5.4",
});

console.log(threadPath, realtimeConnection);

await session.sendText({
  text: "Make it shorter and include risks.",
  attachments: [],
});

for await (const event of chat.events) {
  if (event.message.type === agentTextContentDeltaType) {
    const delta = event.message as typeof event.message & { text: string };
    process.stdout.write(delta.text);
  }
}

You can also open an existing thread directly:

const session = chat.openThread("dataset://threads/existing");

await session.sendText({
  text: "Continue from the last answer.",
  attachments: [],
});

await session.interruptTurn("turn-id");
await session.changeModel({ provider: "openai", model: "gpt-5.4" });
await session.close();

ChatThreadSession tracks local pending inputs in session.pendingInputs. Pending input state is updated when accepted, started, steered, rejected, ended, or cleared messages arrive from the agent.

Custom Transports

Use BaseChatClient if you want to send agent messages through another transport. Implement sendAgentMessage(...) and feed inbound messages back through handleAgentMessage(...).

import {
  AgentMessage,
  BaseChatClient,
} from "@meshagent/meshagent-agents";

class MyChatClient extends BaseChatClient {
  async sendAgentMessage(
    message: AgentMessage,
    options: { attachment?: Uint8Array } = {},
  ): Promise<void> {
    await sendOverMyTransport(message.toJson(), options.attachment);
  }
}

const client = new MyChatClient();
const session = client.openThread("dataset://threads/custom");

Thread List Storage

DatasetThreadStorageRepository stores thread list metadata in a Meshagent dataset table. The URL format is dataset://[namespace...]/table.

import {
  DatasetThreadStorageRepository,
  ThreadListEntry,
} from "@meshagent/meshagent-agents";

const threads = new DatasetThreadStorageRepository({
  room,
  path: "dataset://agents/default/threads",
});

await threads.open();

await threads.addOrUpdateThread(new ThreadListEntry({
  path: "dataset://threads/thread-1",
  name: "Planning",
  createdAt: new Date().toISOString(),
  modifiedAt: new Date().toISOString(),
}));

console.log(threads.entries());

await threads.renameThread("dataset://threads/thread-1", "Launch Planning");
await threads.deleteThread("dataset://threads/thread-1");
await threads.close();

Image Dataset

ImagesDataset creates and writes to an images table with binary image data and metadata. ImageDatasetClient can read image records by ID or by dataset://.../images?id=... URI.

import {
  ImagesDataset,
  ImageDatasetClient,
} from "@meshagent/meshagent-agents";

const images = new ImagesDataset({
  room,
  namespace: ["agents", "default"],
});

const saved = await images.save({
  data: pngBytes,
  mimeType: "image/png",
  createdBy: "assistant",
  annotations: { prompt: "blue product sketch" },
});

const record = await images.readRecord(saved.id);
console.log(record?.mimeType, record?.data.byteLength);

const ref = ImageDatasetClient.datasetUriReference(
  `dataset://agents/default/images?id=${saved.id}`,
);
console.log(ref.namespace, ref.table, ref.id);

Development

npm run build
npm test

The build emits ESM, Node CommonJS, and browser CommonJS outputs under dist/.