@skynetxbt/core
TypeScript icon, indicating that this package has built-in type declarations

1.3.6 • Public • Published

Skynet Agent Framework

A powerful framework for creating AI agents with flows and plugins.

Installation

npm install @skynet/agent

Quick Start

Create a Simple Agent

import { createAgent, AgentConfig } from '@skynet/agent'

const config: AgentConfig = {
  id: {
    generation: 1,
    familyCode: 'TEST',
    serialNumber: '001'
  },
  type: 'MAIN',
  brain: {
    provider: 'openai',
    config: {
      model: 'gpt-4'
    },
    // Optional: Override default system prompt
    systemPrompt: `You are a specialized AI agent focused on blockchain analysis.
Your primary goal is to analyze market trends and identify opportunities.
You should always prioritize risk management and provide clear reasoning for your decisions.`
  }
}

const agent = await createAgent(config)
await agent.start()

Create a Custom Flow

import { createFlow, BaseFlow, FlowContext } from '@skynet/agent'

// Method 1: Using createFlow helper
const simpleFlow = createFlow(
  'simple-flow',
  'A simple example flow',
  ['my-plugin'],
  async (context: FlowContext) => {
    // Flow logic here
    console.log('Executing simple flow')
  }
)

// Method 2: Extending BaseFlow
class CustomFlow extends BaseFlow {
  constructor() {
    super(
      'custom-flow',
      'A more complex flow',
      ['plugin1', 'plugin2'],
      {
        step1: {
          plugin: 'plugin1',
          command: 'doSomething',
          args: []
        }
      }
    )
  }

  async execute(context: FlowContext) {
    // Complex flow logic here
  }
}

Create a Custom Plugin

import { IPlugin } from '@skynet/agent'
import { EventEmitter } from 'events'

export class CustomPlugin extends EventEmitter implements IPlugin {
  name = 'custom-plugin'
  
  async initialize() {
    // Plugin initialization
  }

  async cleanup() {
    // Cleanup resources
  }

  // Custom plugin methods
  async doSomething() {
    return 'result'
  }
}

Features

  • 🤖 Easy agent creation and management
  • 🔄 Flow-based task execution
  • 🔌 Plugin system for extensibility
  • 🧬 Trait-based agent personalities
  • 🔗 Blockchain integration
  • 🧠 LLM integration with customizable system prompts
  • 📦 Type-safe APIs

Customizing Agent Behavior

System Prompts

You can customize your agent's behavior by providing a custom system prompt:

const agent = await createAgent({
  // ... other config
  brain: {
    provider: 'openai',
    config: { model: 'gpt-4' },
    systemPrompt: `You are a specialized trading agent with the following traits:
    1. Risk-averse: Always prioritize capital preservation
    2. Data-driven: Make decisions based on quantitative analysis
    3. Transparent: Explain your reasoning clearly
    4. Methodical: Follow a strict trading strategy`
  }
})

The system prompt helps define the agent's:

  • Role and personality
  • Decision-making criteria
  • Communication style
  • Operating constraints
  • Specialized knowledge or focus areas

If not provided, the agent will use a default system prompt appropriate for its type and traits.

Architecture

The framework follows a modular architecture:

  • Agents: Core entities that execute flows and manage plugins
  • Flows: Define sequences of actions using plugins
  • Plugins: Provide specific functionalities (e.g., blockchain, API integrations)
  • Traits: Define agent personalities and behaviors
  • LLM: Integration with language models for decision making

Shuting Down agent for Devs

 curl -X POST http://localhost:3010/kill -H "Content-Type: application/json" -d '{"shutdownKey": "hello"}'

Contributing

  1. Fork the repository
  2. Create your feature branch
  3. Commit your changes
  4. Push to the branch
  5. Create a Pull Request

Package Sidebar

Install

npm i @skynetxbt/core

Weekly Downloads

1,230

Version

1.3.6

License

none

Unpacked Size

270 kB

Total Files

94

Last publish

Collaborators

  • mitrasish
  • 0xarpit