0.1.2 • Published 8 months ago

cbrzn-agent-protocol v0.1.2

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

Agent Communication Protocol - JavaScript/TypeScript SDK

This SDK implements the Agent Communication Protocol in JavaScript/TypeScript and allows you to easily wrap your agent in a webserver compatible with the protocol - you only need to define an agent task handler.

Installation

npm install agent-protocol

Then add the following code to your agent:

Typescript

import Agent, {
  type StepHandler,
  type StepInput,
  type StepResult,
  type TaskInput,
} from 'agent-protocol'

async function taskHandler(taskInput: TaskInput | null): Promise<StepHandler> {
  console.log(`task: ${taskInput}`)

  async function stepHandler(stepInput: StepInput | null): Promise<StepResult> {
    console.log(`step: ${stepInput}`)
    return {
      output: stepInput,
    }
  }

  return stepHandler
}

Agent.handleTask(taskHandler).start()

Docs

You can find more info and examples in the docs.