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

@cuylabs/agent-core

v4.4.0

Published

Embeddable AI agent infrastructure — execution, sessions, tools, skills, dispatch, tracing

Readme

@cuylabs/agent-core

Composable AI agent harness with pluggable execution control.

@cuylabs/agent-core is the in-process execution kernel for AI agents. It owns the Agent API, streaming execution, tool and model semantics, middleware and lifecycle hooks, sessions, prompt construction, tracing, and the reusable task/turn/workflow primitives that runtime packages build on for durability, hosting, and scheduling.

Package Boundary

Use @cuylabs/agent-core when you want:

  • Agent creation and chat() / send() APIs
  • tool definition and execution
  • model hooks, tool hooks, and lifecycle middleware
  • sessions, storage, branching, and prompt construction
  • tracing, MCP, skills, profiles, and dispatch-based child-agent tools
  • execution-facing task/turn/workflow helpers from @cuylabs/agent-core/execution

This package does not own outer orchestration or hosting:

  • use @cuylabs/agent-runtime for the backend-agnostic orchestration contract — it defines the interfaces for scheduling, dispatch, workload lifecycle, and execution stores that runtime backends implement
  • use @cuylabs/agent-runtime-dapr for a concrete backend that implements those contracts with Dapr workflows, state stores, and pub/sub
  • use @cuylabs/agent-server for a transport-neutral local server with session management, turn execution, and streamed event fanout over WebSocket / stdio
  • use @cuylabs/agent-http for an AI SDK chat-stream HTTP adapter

@cuylabs/agent-core includes the default local execution host. Non-local tool environments should live in separate packages so the execution semantics and host implementations stay decoupled.

Core Capabilities

  • Streaming agent execution with structured events
  • Type-safe tools with Zod schemas
  • Middleware for model input/output, stream chunks, tool calls, and lifecycle hooks
  • Session persistence with branching support
  • Prompt pipeline and dynamic prompt sections
  • Skills and built-in dispatch-based child-agent delegation
  • OpenTelemetry tracing
  • MCP integration
  • EventBus — pluggable pub/sub with history replay and backpressure
  • AgentSignal — typed inter-agent signalling within teams
  • Runtime-facing task, turn, and workflow primitives for durable adapters

Installation

npm install @cuylabs/agent-core
# or
pnpm add @cuylabs/agent-core

You will also need at least one AI SDK provider:

npm install @ai-sdk/openai
# or @ai-sdk/anthropic, @ai-sdk/google

For OpenAI-compatible endpoints, add:

npm install @ai-sdk/openai-compatible

Quick Start

import { createAgent, Tool } from "@cuylabs/agent-core";
import { openai } from "@ai-sdk/openai";
import { z } from "zod";

const greet = Tool.define("greet", {
  description: "Greet a user by name",
  parameters: z.object({
    name: z.string(),
  }),
  execute: async ({ name }) => ({
    title: "Greeting",
    output: `Hello, ${name}!`,
    metadata: {},
  }),
});

const agent = createAgent({
  name: "assistant",
  model: openai("gpt-4o"),
  tools: [greet],
  systemPrompt: "You are a helpful assistant.",
});

for await (const event of agent.chat("session-1", "Say hi to Ada")) {
  switch (event.type) {
    case "text-delta":
      process.stdout.write(event.text);
      break;
    case "tool-start":
      console.log(`calling ${event.toolName}`);
      break;
    case "tool-result":
      console.log(`tool result:`, event.result);
      break;
    case "complete":
      console.log("\ndone");
      break;
  }
}

Focused Imports

The root export is available, but focused subpath imports mirror the package structure when you want clearer boundaries:

import { createAgent, Tool } from "@cuylabs/agent-core";
import type { AgentMiddleware } from "@cuylabs/agent-core/middleware";
import { Inference } from "@cuylabs/agent-core/inference";
import { createAgentTaskRunner } from "@cuylabs/agent-core/execution";
import { localHost } from "@cuylabs/agent-core/tool/host";
import { createPromptBuilder } from "@cuylabs/agent-core/prompt";
import { withinScope } from "@cuylabs/agent-core/scope";
import { createSkillRegistry } from "@cuylabs/agent-core/skill";
import { createSubAgentTools } from "@cuylabs/agent-core/subagents";
import { createMCPManager } from "@cuylabs/agent-core/mcp";
import { createEventBus } from "@cuylabs/agent-core/events";
import type { AgentSignal } from "@cuylabs/agent-core/signal";

Additional focused entrypoints are available for tool, tracking, storage, reasoning, models, mcp, inference, tool/host, scope, dispatch, subagents, events, and signal.

For non-local tool execution environments, install a dedicated host package and pass its host instance through the same host option.

Relationship To The Runtime Packages

The layering is:

agent-core
  -> agent-runtime
    -> agent-runtime-dapr
  • agent-core owns live agent execution
  • agent-runtime owns generic workload scheduling and dispatch
  • agent-runtime-dapr adds Dapr-backed durability and host integration

If you need durable orchestration, agent-core already exposes the task and turn surfaces those packages build on:

  • createAgentTaskRunner(...)
  • task execution observers and checkpoints
  • turn-step helpers such as prepareModelStep(...) and runToolBatch(...)
  • workflow-safe state/planning helpers

Learn More

Start with the package docs:

Runnable examples live in examples/README.md.

License

Apache-2.0