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

@ai_kit/server

v1.0.6

Published

HTTP server harness for AI Kit agents and workflows

Readme

@ai_kit/server

@ai_kit/server exposes a thin HTTP facade over the agents and workflows defined in @ai_kit/core. It wraps a Hono application that can be embedded inside your own runtime or started directly via the bundled CLI script.

Quick start

import { Agent, createWorkflow } from "@ai_kit/core";
import { ServerKit } from "@ai_kit/server";
import { serve } from "@hono/node-server";

const echoAgent = new Agent({
  name: "echo",
  model: /* configure an ai-sdk LanguageModel here */ {} as any,
});

const workflow = createWorkflow({
  id: "demo",
  description: "Echoes input data",
  steps: [],
});

const server = new ServerKit({
  agents: { echo: echoAgent },
  workflows: { demo: workflow },
});

await server.listen({ port: 8787 });

Need a ready-made project? Scaffold one with the template:

npx @ai_kit/create-ai-kit server-kit

The server registers the following endpoints:

  • GET /api/agents — list registered agents.
  • POST /api/agents/:id/generate — synchronously invoke Agent.generate.
  • POST /api/agents/:id/stream — stream the result of Agent.stream.
  • GET /api/workflows — list registered workflows.
  • POST /api/workflows/:id/run — execute a workflow to completion.
  • POST /api/workflows/:id/stream — stream workflow events (Server-Sent Events).
  • POST /api/workflows/:id/runs/:runId/resume — resume a suspended workflow run that awaits human input.

See src/ServerKit.ts for the complete implementation and error-handling behaviour.

Calling the server from ClientKit

Reach these endpoints from any JavaScript runtime with @ai_kit/client-kit:

import { ClientKit } from "@ai_kit/client-kit";

const client = new ClientKit({
  baseUrl: "https://agents.internal.aidalinfo.fr",
  headers: { Authorization: `Bearer ${process.env.SERVER_TOKEN}` },
});

const generation = await client.generateAgent("support", {
  prompt: "What changed this week?",
  runtime: {
    metadata: { tenant: "aidalinfo" },
    ctx: { locale: "fr-FR" },
  },
});

const run = await client.runWorkflow("enrich-ticket", {
  inputData: { contactId: "123" },
  metadata: { requestId: "run_abc" },
  runtime: {
    metadata: { tenant: "aidalinfo" },
    ctx: { locale: "fr-FR" },
  },
});

runtime / runtimeContext payloads merge their metadata/ctx with the top-level fields so you can reuse shared values while overriding per request.

Middleware

ServerKit lets you register Hono middleware the same way Mastra does: pass either plain middleware functions or { handler, path } tuples via the server.middleware option. Path-scoped entries accept any string your Hono app would use (e.g. /api/*). The legacy top-level middleware field still works but is deprecated.

const server = new ServerKit({
  agents: { echo: echoAgent },
  workflows: { demo: workflow },
  server: {
    middleware: [
      {
        path: "/api/*",
        handler: async (c, next) => {
          const authHeader = c.req.header("authorization");
          if (!authHeader) {
            return new Response("Unauthorized", { status: 401 });
          }

          await next();
        },
      },
      async (c, next) => {
        console.log(`${c.req.method} ${c.req.url}`);
        await next();
      },
    ],
  },
});

Swagger / OpenAPI documentation

ServerKit can expose an autogenerated OpenAPI document and Swagger UI that mirrors the endpoints above. Swagger is enabled by default in non-production environments and can be configured via the swagger option:

const server = new ServerKit({
  agents: { echo: echoAgent },
  workflows: { demo: workflow },
  swagger: {
    enabled: true,
    route: "/docs",
    title: "Demo API",
  },
});

When enabled, the UI is served from route (default /swagger) and the raw spec is available from <route>.json.

The bundled CLI also accepts --swagger / --no-swagger flags to force-enable or disable the documentation regardless of NODE_ENV.

Langfuse telemetry

Enable Langfuse directly from the ServerKit configuration:

const server = new ServerKit({
  agents: { echo: echoAgent },
  telemetry: {
    enabled: true,
  },
});
  • telemetry accepts either true/false or the full set of ensureLangfuseTelemetry options if you want to customize the exporter.
  • Set the environment variables LANGFUSE_PUBLIC_KEY, LANGFUSE_SECRET_KEY (and optionally LANGFUSE_BASE_URL) for the exporter to authenticate.
  • The CLI exposes --telemetry / --no-telemetry flags to toggle the option quickly.