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

@astropods/adapter-core

v0.6.0

Published

Framework-agnostic bridge between TypeScript agents and the Astropods messaging service.

Downloads

2,115

Readme

@astropods/adapter-core

Framework-agnostic bridge between TypeScript agents and the Astropods messaging service.

Installation

bun add @astropods/adapter-core
# or
npm install @astropods/adapter-core

Usage

If you're using a supported framework, use the pre-built adapter package instead (e.g. @astropods/adapter-mastra). Use this package directly to connect a custom or unsupported framework.

Implement the AgentAdapter interface, then call serve():

import { serve } from "@astropods/adapter-core";
import type { AgentAdapter } from "@astropods/adapter-core";

const adapter: AgentAdapter = {
  name: "My Agent",
  async stream(prompt, hooks, options) {
    try {
      hooks.onChunk("Hello!");
      hooks.onFinish();
    } catch (err) {
      hooks.onError(err as Error);
    }
  },
  getConfig() {
    return { systemPrompt: "You are a helpful assistant.", tools: [] };
  },
};

serve(adapter);

serve() blocks until SIGINT or SIGTERM. Under ast dev, GRPC_SERVER_ADDR is injected automatically.

API

AgentAdapter

| Member | Description | |--------|-------------| | name: string | Display name used in logs and registration | | stream(prompt, hooks, options): Promise<void> | Stream a response, invoking hooks as the agent progresses | | streamAudio?(audio, hooks, options): Promise<void> | Optional — handle voice input | | getConfig(): AgentConfig | Return { systemPrompt, tools } for playground display | | onFeedback?(event): void \| Promise<void> | Optional — receive inbound platform feedback (thumbs up/down, comments, button clicks) |

StreamHooks

Call these inside stream() as the agent produces output:

| Method | When to call | |--------|-------------| | onChunk(text) | Each text token or fragment from the LLM | | onStatusUpdate({ status }) | Agent state change — valid values: THINKING, SEARCHING, GENERATING, PROCESSING, ANALYZING, CUSTOM | | onFinish() | Response complete — call exactly once per request | | onError(error) | Error occurred — call instead of onFinish |

StreamOptions

Per-request context passed to stream():

| Field | Description | |-------|-------------| | conversationId | Stable ID for the conversation thread | | userId | ID of the user who sent the message | | platformContext? | PlatformContext \| undefined — platform-specific fields (channel, thread, workspace, event kind). undefined for messages from non-platform sources (playground, direct gRPC). |

Using platformContext

PlatformContext exposes the source-event fields adapters often need to branch on — the channel and thread to reply into, the workspace, the bot's own user ID, and an eventKind enum that distinguishes a DM from an @-mention from a thread reply without having to inspect message content.

import type { AgentAdapter, PlatformContext } from "@astropods/adapter-core";

const adapter: AgentAdapter = {
  name: "My Agent",
  async stream(prompt, hooks, { platformContext }) {
    if (platformContext?.eventKind === "EVENT_KIND_APP_MENTION") {
      hooks.onChunk(`You @-mentioned me in ${platformContext.channelName ?? platformContext.channelId}.`);
    } else {
      hooks.onChunk("Hello!");
    }
    hooks.onFinish();
  },
  getConfig() {
    return { systemPrompt: "", tools: [] };
  },
};

Always null-check first — platformContext is undefined for messages from the playground or direct gRPC clients. See PlatformContext for the full field list.

serve(adapter, options?)

Connects the adapter to the messaging service and blocks until shutdown.

import { serve } from "@astropods/adapter-core";

// Override the gRPC address (default: GRPC_SERVER_ADDR env var or localhost:9090)
serve(adapter, { serverAddress: "astro-messaging:9090" });

MessagingBridge

serve() is a thin wrapper around MessagingBridge. Use it directly if you need lifecycle control:

import { MessagingBridge } from "@astropods/adapter-core";

const bridge = new MessagingBridge(adapter);
await bridge.start();

HTTP outbound instrumentation

@astropods/adapter-core/instrument patches globalThis.fetch so every outbound HTTP request becomes an OpenTelemetry CLIENT span. Spans are sent to ${OTEL_EXPORTER_OTLP_ENDPOINT}/v1/traces. When that env var is unset, the import is a no-op.

Import it once, before any code that issues fetch — typically the first line of your entry point:

import "@astropods/adapter-core/instrument";
// ...the rest of your imports

Or call it explicitly:

import { instrumentHttp } from "@astropods/adapter-core";

instrumentHttp();

Both forms are idempotent and share a tracer provider with other Astropods adapters in the same process.