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 🙏

© 2024 – Pkg Stats / Ryan Hefner

aagent.js-lib

v0.0.2

Published

It is library to work with Autonomous Agents on Obyte

Downloads

3

Readme

What's it?

It is CLI and library to work with Autonomous Agents on Obyte

Quick start

You can create a new project using CLI

npm i -g aagent.js
aagent init folder

Or add to an existing project

yarn add aagent.js-lib
require('headless-obyte');
const eventBus = require('ocore/event_bus');
const { AA, AAs } = require('aagent.js-lib');

Library

AA

Example:

require('headless-obyte');
const eventBus = require('ocore/event_bus');

const { AA } = require('aagent.js-lib');

eventBus.on('headless_wallet_ready', () => {
    const aa = new AA('address');

    aa.events.on('new_request', (request) => {
        console.error('new request', request);
    });

    aa.events.on('new_response', (err, response, vars) => {
        console.error('new response', response, vars);
    });

    aa.events.on('new_aa_definition', (definition) => {
        console.error('new aa definition', definition);
    });

    aa.events.on('new_aa_definition_saved', (definition) => {
        console.error('new aa definition saved', definition);
    });

    aa.newResponseFilter((err, params, vars) => {        
        return true;
      }, (err, params, vars) => {
        console.error(err, params, vars);
      });

});

AA class contains the following methods:

All events are applied to the specified address in the constructor.

constructor
const aa = new AA('address')

one argument - aa_address(string)

static method getAAVars:

AA.getAAVars('address');

will return variables from AA.

Event handlers:

The handler triggers an event, passes it to the first function, and if it returns true, calls the second function. You can use them to process specific data(like a router). More about arguments in events.

aa.addRequestEventHandler((request, body) => {
    return true;
  }, (request, body) => {
    console.error(request, body);
  });
aa.addResponseEventHandler((err, params, vars, body) => {
    return true;
  }, (err, params, vars, body) => {
    console.error(err, params, vars, body);
  });
aa.addDefinitionEventHandler((definition, body) => {
    return true;
  }, (definition, body) => {
    console.error(definition, body);
  });
aa.addDefinitionSavedEventHandler((definition, body) => {
    return true;
  }, (definition, body) => {
    console.error(definition, body);
  });

And events:

new_request
aa.events.on('new_request', (request, body) => {
  console.error('new request', request, body);
});

Arguments:

  • request - {address: aa_address, messages: unit.messages}
  • body - raw body from event
new_response
aa.events.on('new_response', (err, params, vars, body) => {
  console.error('new response', err, params, vars, body);
});

Arguments:

  • err - if bounced return error message
  • params - { address: aa_address, response: body.response }
  • vars - new vars from AA
  • body - raw body from event
new_aa_definition
aa.events.on('new_aa_definition', (definition, body) => {
  console.error('new aa definition', definition, body);
});

Arguments:

  • definition - definition from messages
  • body - raw body from event
new_aa_definition_saved
aa.events.on('new_aa_definition_saved', (definition, body) => {
  console.error('new aa definition saved', definition, body);
});

This event can be triggered twice with the same data (architectural features), please consider this. Arguments:

  • definition - definition from messages
  • body - raw body from event

AAs

All events applies to the specified addresses in the constructor.

constructor
const aas = new AAs(['address', 'address2'])

one argument - aa_addresses - array[string]

aas.addAddress('address');

Adds a new address and subscribes to it

static method getAAVars:

AAs.getAAVars('address');

will return variables from AA.

This class supports only: Methods: addRequestEventHandler, addResponseEventHandler Events: new_request, new_response Arguments are identical to AA class

If you want to start developing on Obyte and you need help, write to us on discord or on telegram: @xJeneK