API for interacting with Agent
npm install jzanecook-e2b-sdk-testThis was developed with the following dependencies:
- _node v18.16.0_
- _ts-node v10.9.1_
- _prettier 3.0.0_
- _pnpm 8.6.9_
During development, you should be able to simply import the Agent from src/index.ts and run using ts-node.
The minimal example is below. This creates a simple agent which performs no tasks itself, but does create the agent API.
``typescript
import Agent from "@e2b/agent-sdk";
import { StepResult, StepHandler } from "@e2b/agent-sdk";
const taskHandler = async (taskInput: any | null): Promise
console.log(task: ${taskInput});
const stepHandler = async (stepInput: any | null): Promise
console.log(step: ${stepInput});
return {
output: stepInput,
};
};
return stepHandler;
};
const agent = new Agent(taskHandler).start();
`
Run ts-node on the example above and you should see the following:
``
Agent listening at http://localhost:8000
You can then experiment with the SDK via CURL, as the examples below:
`bash`
$ curl -X POST -H "Content-Type: application/json" -d '{ "input": "This is a test of the emergency broadcast system." }' http://localhost:8000/agent/tasks # Create a new Task for the agent
`bash``
$ curl -X GET -H "Content-Type: application/json" http://localhost:8000/agent/tasks # Get tasks
Feel free to ask questions on our Discord, or sign up for the newsletter for updates!