ex-mcp
TypeScript icon, indicating that this package has built-in type declarations

0.1.6 • Public • Published

Airtrain Node.js Library

Airtrain is a lightweight agent and LLM framework for building, testing, and monitoring AI systems. This is the official Node.js implementation of Airtrain.

Features

  • 🔄 Cross-platform: JavaScript/TypeScript implementation of Airtrain, compatible with the Python version
  • 🧩 Modular: Build AI agents from composable skills with a simple, consistent API
  • 💾 Secure credentials: Robust credential management for API keys and secrets
  • 📊 Telemetry: Built-in telemetry for monitoring and improving your AI systems
  • 🚀 Model Integrations: Support for multiple model providers including Fireworks AI
  • 🛠 Type-Safe: Fully typed with TypeScript for better developer experience

Installation

npm install airtrain

Quick Start

import { Skill, telemetry } from 'airtrain';
import { FireworksClient } from 'airtrain/integrations/fireworks';

// Initialize with your API key (or use environment variables)
const client = new FireworksClient({
  apiKey: process.env.FIREWORKS_API_KEY
});

// Create a skill
const answerQuestion = new Skill({
  name: "answerQuestion",
  description: "Answers general knowledge questions",
  execute: async ({ input }) => {
    const response = await client.createChatCompletion([
      { role: "system", content: "You are a helpful assistant." },
      { role: "user", content: input }
    ]);
    
    return response.choices[0]?.message?.content || "No response from model";
  }
});

// Use the skill
async function main() {
  const result = await answerQuestion.process("What is the capital of France?");
  console.log(result);
}

main().catch(console.error);

Key Components

Schemas

The library uses Zod for validation:

import { BaseSchema } from 'airtrain';
import { z } from 'zod';

// Define a schema for your skill's input
const MyInputSchema = BaseSchema.extend({
  question: z.string().nonempty(),
  context: z.string().optional()
});

// Type inference works automatically
type MyInput = z.infer<typeof MyInputSchema>;

Credentials

Securely manage API keys and other sensitive information:

import { Credentials } from 'airtrain';

// Create credentials manager
const credentials = new Credentials({
  configPath: './config',
  encryptionKey: process.env.ENCRYPTION_KEY
});

// Save an API key
await credentials.set('fireworks', { apiKey: 'your-api-key' });

// Use the credentials
const apiKey = (await credentials.get('fireworks')).apiKey;

Skills

Build modular, reusable components:

import { Skill } from 'airtrain';
import { z } from 'zod';

const translator = new Skill({
  name: "translator",
  description: "Translates text to another language",
  input_schema: z.object({
    text: z.string(),
    target_language: z.string()
  }),
  execute: async ({ input }) => {
    // Implementation using your preferred LLM
    return translatedText;
  }
});

Integrations

The library includes integrations with popular LLM providers:

  • Fireworks AI: High-performance, cost-effective LLMs
    import { FireworksClient } from 'airtrain/integrations/fireworks';
    
    const client = new FireworksClient({
      apiKey: process.env.FIREWORKS_API_KEY,
      defaultModel: "accounts/fireworks/models/llama-v3-70b-instruct"
    });
    
    const response = await client.createChatCompletion([
      { role: "user", content: "Hello!" }
    ]);

Examples

Explore the examples directory for detailed usage examples:

  • Basic skills: How to create and use skills
  • Fireworks integration: Chat, streaming, function calling examples
  • Credential management: Secure storage and retrieval of credentials

Development

Setup

# Clone the repository
git clone <repository-url>
cd airtrain-node

# Install dependencies
npm install

# Build the project
npm run build

Testing

# Run tests
npm test

# Run with coverage
npm run test:coverage

Publishing to NPM

The library includes a dedicated script for publishing to NPM:

# Create a .env file with your NPM token
cp .env.example .env
# Edit the .env file to add your NPM_TOKEN

# Run the publishing script
npm run publish-npm

The script will:

  1. Validate your package.json
  2. Check git status and branch
  3. Let you choose a version bump (patch, minor, major)
  4. Build and test the package
  5. Publish to NPM with your token

For a dry run (without actually publishing):

npm run publish-npm -- --dry-run

License

MIT

Contributing

Contributions are welcome! Please see CONTRIBUTING.md for details.

Package Sidebar

Install

npm i ex-mcp

Weekly Downloads

0

Version

0.1.6

License

MIT

Unpacked Size

2.92 MB

Total Files

299

Last publish

Collaborators

  • diedfindingusername