agent-protocol
TypeScript icon, indicating that this package has built-in type declarations

1.0.5 • Public • Published

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()

See the [https://github.com/AI-Engineer-Foundation/agent-protocol/tree/main/packages/sdk/js/examples](examples folder) for running in serverless environments.

Docs

You can find more info and examples in the docs.

Contributing

git clone https://github.com/AI-Engineers-Foundation/agent-protocol
cd agent-protocol/packages/sdk/js
npm install
npm run build

Package Sidebar

Install

npm i agent-protocol

Weekly Downloads

56

Version

1.0.5

License

MIT

Unpacked Size

76.5 kB

Total Files

5

Last publish

Collaborators

  • jzanecook
  • aiedotfoundation