This process will be simplified in the future. For now, you can follow these steps to run your TypeScript agent locally.
- Make sure you installed NEAR AI CLI and you have a named NEAR Account. You can create one with Meteor Wallet. No funds are required.
- Install the dependencies
cd ts_runner/ts_agent && npm install
- Perform
nearai login
to have a valid NEAR signature in~/.nearai/config.json
. - Update the agent code at
/ts_runner/ts_agent/agents/agent.ts
as you need. Keep the first line asimport {env} from 'ts-agent-runner';
and use methods from theenv
object to use NEAR AI Agent Framework (completions, etc). More methods are coming in the nearest future. - Run the agent:
npm run build && npm run start agents/agent.ts
- If you want to provide ENV variables, you can provide them as arguments:
npm run build && CDP_API_KEY_NAME=name CDP_API_KEY_PRIVATE_KEY="key" npm run start agents/agent.ts
This is valid only for local development. On NEAR AI Runner we have NEAR AI HUB secrets for this purpose.
- Create a new agent
- Copy the
agent.ts
you built to the agent folder - Make sure to set framework to
ts
in the metadata.json - Deploy the agent (Doc above) has the details)
Example of the agent: cdp-agent
Metadata example:
{
"category": "agent",
"name": "cdp-agent",
"description": "Coinbase Agent",
"tags": ["coinbase", "cdp"],
"details": {
"agent":{
"framework": "ts"
}
},
"show_entry": true,
"version": "0.01"
}