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 🙏

© 2025 – Pkg Stats / Ryan Hefner

nestjs-a2a

v0.0.1

Published

NestJS module for creating Google Agent to Agent Server

Downloads

51

Readme

nestjs-a2a

A NestJS library for implementing Google's Agent-to-Agent (A2A) protocol.

Description

nestjs-a2a is a library designed to simplify the implementation of Google's Agent-to-Agent (A2A) protocol in NestJS applications. It provides a set of utilities, decorators, and interfaces to make building A2A-compatible agents seamless and type-safe.

Installation

npm install nestjs-a2a
# or
yarn add nestjs-a2a
# or
pnpm add nestjs-a2a

Quick Start

import { Module } from '@nestjs/common';
import { AgentToAgentModule } from 'nestjs-a2a';

@Module({
  imports: [
    AgentToAgentModule.register({
      card: {
        name: 'My Agent',
        description: 'A sample A2A agent',
        version: '1.0.0',
        capabilities: {
          streaming: true,
        },
        provider: {
          organization: 'My Organization',
          url: 'https://myorganization.com',
        },
      },
    }),
  ],
})
export class AppModule {}

Features

  • Complete implementation of Google's Agent-to-Agent (A2A) protocol
  • Type-safe communication between agents
  • Easy-to-use decorators for defining agent skills
  • Support for streaming responses
  • Automatic skill discovery and registration
  • JSON-RPC 2.0 compliant API
  • Built-in task state management

Creating Agent Skills

Use the @Skill decorator to define agent skills:

import { Injectable } from '@nestjs/common';
import {
  InputMode,
  OutputMode,
  Skill,
  TaskYieldUpdate,
  Task,
  TaskState,
  PartType,
  MessageRole,
} from 'nestjs-a2a';

@Injectable()
export class GreetingService {
  @Skill({
    id: 'greeting',
    name: 'Greeting',
    description: 'Greet the user',
    examples: ['Hello', 'Hi', 'Good morning'],
    inputModes: [InputMode.TEXT],
    outputModes: [OutputMode.TEXT],
    tags: ['greeting'],
  })
  async *greet(): AsyncGenerator<TaskYieldUpdate, Task | void, unknown> {
    yield {
      state: TaskState.WORKING,
      message: {
        role: MessageRole.AGENT,
        parts: [
          {
            type: PartType.TEXT,
            text: 'Hello! How can I help you today?',
          },
        ],
      },
    };

    yield {
      state: TaskState.COMPLETED,
    };
  }
}

API Documentation

AgentToAgentModule

The main module for integrating A2A functionality into your NestJS application.

Static Methods

  • register(options: AgentToAgentModuleOptions): Register the module with static options
  • registerAsync(options: AgentToAgentAsyncModuleOptions): Register the module with async options

Configuration Options

interface AgentToAgentModuleOptions {
  // Agent card information
  card: Omit<AgentCard, 'skills'>;

  // Optional custom task store implementation
  taskStore?: TaskStore;

  // Optional base path for the A2A endpoints (default: '/a2a')
  basePath?: string;

  // Optional guards for securing A2A endpoints
  guards?: CanActivate[];

  // Optional function to select a skill based on the task
  selectSkill?: (task: Task) => Promise<string> | string;
}

Decorators

  • @Skill(config: AgentSkill): Marks a method as an agent skill handler

Examples

Check the example directory for a complete working example of an A2A agent implementation.

# Run the example
pnpm start:example

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Continuous Integration

This project uses GitHub Actions for continuous integration:

  • All pull requests and pushes to the main branch are automatically tested
  • Code quality checks including linting and type checking are performed
  • Test coverage is reported

Deployment

Deployment to npm is automated using GitHub Actions and semantic-release:

  1. Create and push a new tag following semantic versioning (e.g., v1.0.0)
  2. GitHub Actions will automatically build, test, and publish the package to npm
  3. A GitHub Release will be created with release notes
# Example: Creating and pushing a new tag
git tag v1.0.0
git push origin v1.0.0

License

This project is licensed under the MIT License - see the LICENSE.md file for details.

Contact

Thieu Quan Ngoc - [email protected] - @thestupd

Website: https://stupd.dev

Resources