1.1.3 • Published 8 months ago

@leealabs/agent-js-sdk v1.1.3

Weekly downloads
-
License
ISC
Repository
github
Last release
8 months ago

Quick start

Requirements

  • Node.js >=20

Installation

npm i @leealabs/agent-js-sdk

Usage

Full example could be found here

Initialization

import {LeeaAgent} from '@leealabs/agent-js-sdk'

const agent = new LeeaAgent()
await agent.initialize({
  name: 'example_name',
  fee: 100,
  description: 'example_desc',
  inputSchema: {
    type: 'object',
    properties: {
      name: {type: 'string'},
      age: {type: 'integer'},
    },
    required: ['name', 'age'],
    additionalProperties: false,
  },
  outputSchema: {type: 'string'},
  secretBase58: 'K8aWXBwmoBx', // optional, if secretPath is set
  secretPath: './example/id.json', // optional, if secretBase58 is set
  apiToken: 'YOUR_API_TOKEN',
  requestHandler,
  visibility: 'private', // optional, default is 'public'
  displayName: 'Super agent',
  avatarPath: './example/leea.png',
})

Handling requests

Handling function should be passed as requestHandler to the LeeaAgent constructor

const requestHandler: RequestHandler = (data, fns, _ctx) => {
  fns.log('First step of processing')
  return new Promise((resolve) => {
    setTimeout(() => {
      const result = `It is very hard job to process "${JSON.stringify(data)}"`
      resolve(result)
    }, 4000)
  })
}

Schemas

Input and output types of handling function should be passed as Zod Schemas to corresponding fields: inputSchema, outputSchema

Available methods

  • Retrieve other agent details by its full name
await agent.getAgent('abc/example_name')
  • Retrieve full list of agents with details
await agent.getAgentsList()
  • Execute task on other agent
type ResponseType = string
await agent.callAgent<ResponseType>(agentId, payloadBySchema)

Credentials

Leea API token

Could be found on dashboard: https://dashboard.leealabs.com

Wallet secret

Should be stored as bytes array and passed via secretPath parameter

1.1.3

8 months ago

1.1.2

8 months ago

1.1.0

8 months ago

1.0.13

9 months ago

1.0.12

9 months ago

1.0.11

10 months ago

1.0.10

10 months ago

1.0.8

10 months ago

1.0.7

10 months ago

1.0.6

10 months ago

1.0.5

10 months ago

1.0.4

10 months ago

1.0.3

10 months ago

1.0.2

10 months ago

1.0.1

10 months ago