Skip to content

Commit 02d7035

Browse files
authored
Merge pull request #10 from autonomys/new-features
Agent Core Update - Add Chat Node config and Web Cli Docker
2 parents 49f8c2b + 8dc2d2a commit 02d7035

File tree

8 files changed

+120
-39
lines changed

8 files changed

+120
-39
lines changed

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,18 @@ You can run multiple characters simultaneously, each with their own configuratio
116116
- Run its own API server on the specified port
117117
- Execute tasks according to its unique schedule and personality
118118

119+
## Web Cli With Docker
120+
Web Cli is a modern web-based interface for interacting with your agent. You can have web cli as a container by runnint the command below:
121+
122+
```bash
123+
docker run -d \
124+
-p <HOST_LOCAL_PORT>:<CONTAINER_PORT> \
125+
-e PORT=<CONTAINER_PORT> \
126+
-e RUNTIME_API_URL="<YOUR_API_URL>" \
127+
-e RUNTIME_API_TOKEN="<YOUR_API_TOKEN>" \
128+
--name autonomys-web-cli \
129+
ghcr.io/autonomys/autonomys-agents/web-cli:latest
130+
```
119131

120132
## Docker Deployment
121133

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "autonomys-agent-template",
3-
"version": "0.6.0",
3+
"version": "0.6.5",
44
"description": "template repository for autonomys-agents",
55
"type": "module",
66
"main": "dist/src/index.js",
@@ -27,7 +27,7 @@
2727
"generate-certs": "tsx scripts/generate-certs.ts"
2828
},
2929
"dependencies": {
30-
"@autonomys/agent-core": "^0.2.4",
30+
"@autonomys/agent-core": "^0.3.1",
3131
"yargs": "^17.7.2"
3232
},
3333
"devDependencies": {

src/config/api.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import { CreateApiServerParams, OrchestratorRunnerOptions } from '@autonomys/agent-core';
2+
3+
import { chatAppInstance } from './chatNode.js';
4+
import { ConfigInstance } from './types.js';
5+
6+
export const createAgentApi = (configInstance: ConfigInstance) => {
7+
const { config } = configInstance;
8+
const { apiSecurityConfig, API_PORT } = config;
9+
10+
const apiConfig: OrchestratorRunnerOptions['apiConfig'] = {
11+
apiEnabled: true,
12+
authFlag: apiSecurityConfig.ENABLE_AUTH,
13+
authToken: apiSecurityConfig.API_TOKEN,
14+
allowedOrigins: apiSecurityConfig.CORS_ALLOWED_ORIGINS,
15+
port: API_PORT,
16+
};
17+
return apiConfig;
18+
};
19+
20+
export const createApiServerConfig = (configInstance: ConfigInstance) => {
21+
const { config, characterName } = configInstance;
22+
const { characterConfig } = config;
23+
const { characterPath } = characterConfig;
24+
const { apiSecurityConfig, API_PORT } = config;
25+
26+
const serverApiServerParams: CreateApiServerParams = {
27+
characterName,
28+
dataPath: characterPath,
29+
authFlag: apiSecurityConfig.ENABLE_AUTH,
30+
authToken: apiSecurityConfig.API_TOKEN ?? '',
31+
apiPort: API_PORT,
32+
allowedOrigins: apiSecurityConfig.CORS_ALLOWED_ORIGINS,
33+
chatAppInstance: chatAppInstance(configInstance),
34+
};
35+
36+
return serverApiServerParams;
37+
};

src/config/chatNode.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import {
2+
type ChatWorkflow,
3+
createChatNodeConfig,
4+
createChatWorkflow,
5+
createDefaultChatTools,
6+
createPromptTemplate,
7+
LLMConfiguration,
8+
} from '@autonomys/agent-core';
9+
10+
import { ConfigInstance } from './types.js';
11+
12+
export const chatAppInstance = (configInstance: ConfigInstance): ChatWorkflow => {
13+
const { config, characterName } = configInstance;
14+
const { characterConfig } = config;
15+
const { characterPath } = characterConfig;
16+
17+
const modelConfig: LLMConfiguration = {
18+
model: 'claude-3-5-haiku-latest',
19+
provider: 'anthropic',
20+
temperature: 0.5,
21+
};
22+
const tools = createDefaultChatTools(characterPath);
23+
const promptTemplate = createPromptTemplate(characterName);
24+
const chatNodeConfig = createChatNodeConfig({ modelConfig, tools, promptTemplate });
25+
const chatAppInstance = createChatWorkflow(chatNodeConfig);
26+
return chatAppInstance;
27+
};

src/config/orchestrator.ts

Lines changed: 3 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,19 @@
11
import {
22
createAllSchedulerTools,
3-
createApiServer,
4-
CreateApiServerParams,
53
createPrompts,
64
OrchestratorRunnerOptions,
75
} from '@autonomys/agent-core';
86

7+
import { createAgentApi } from './api.js';
98
import { createExperienceConfig } from './experiences.js';
109
import { ConfigInstance, Tools } from './types.js';
1110

1211
export const createOrchestratorConfig = async (configInstance: ConfigInstance, tools: Tools) => {
13-
const { config, characterName } = configInstance;
12+
const { config } = configInstance;
1413
const { characterConfig } = config;
1514
const { characterPath } = characterConfig;
1615

17-
const createApi = () => {
18-
const { apiSecurityConfig, llmConfig, API_PORT } = config;
19-
20-
const apiConfig: OrchestratorRunnerOptions['apiConfig'] = {
21-
apiEnabled: true,
22-
authFlag: apiSecurityConfig.ENABLE_AUTH,
23-
authToken: apiSecurityConfig.API_TOKEN,
24-
allowedOrigins: apiSecurityConfig.CORS_ALLOWED_ORIGINS,
25-
port: API_PORT,
26-
};
27-
28-
const serverApiServerParams: CreateApiServerParams = {
29-
characterName,
30-
dataPath: characterPath,
31-
llmConfig,
32-
authFlag: apiConfig.authFlag ?? false,
33-
authToken: apiConfig.authToken ?? '',
34-
apiPort: apiConfig.port ?? 3000,
35-
allowedOrigins: apiConfig.allowedOrigins ?? [],
36-
};
37-
38-
createApiServer(serverApiServerParams);
39-
return apiConfig;
40-
};
41-
42-
const apiConfig = config.ENABLE_API ? createApi() : undefined;
16+
const apiConfig = createAgentApi(configInstance);
4317

4418
const { experienceConfig, monitoringConfig } = await createExperienceConfig(configInstance);
4519
const prompts = await createPrompts(characterConfig);
@@ -52,7 +26,6 @@ export const createOrchestratorConfig = async (configInstance: ConfigInstance, t
5226
characterDataPathConfig: {
5327
dataPath: characterPath,
5428
},
55-
llmConfig: config.llmConfig,
5629
modelConfigurations: config.orchestratorConfig.model_configurations,
5730
tools: [...schedulerTools, ...tools],
5831
};

src/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import {
2+
createApiServer,
23
createLogger,
34
createOrchestratorRunner,
45
getConfig,
@@ -10,6 +11,7 @@ import {
1011
} from '@autonomys/agent-core';
1112

1213
import { createAgentRunnerOptions } from './agent.js';
14+
import { createApiServerConfig } from './config/api.js';
1315

1416
const configInstance = await getConfig();
1517
if (!configInstance) {
@@ -36,6 +38,8 @@ const orchestratorRunner = (() => {
3638

3739
// Main function to run the application
3840
const main = async () => {
41+
const apiServerConfig = createApiServerConfig(configInstance);
42+
const _apiServer = createApiServer(apiServerConfig);
3943
try {
4044
const logger = createLogger('app');
4145
logger.info('Initializing orchestrator runner...');

src/tools.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ import {
44
createTwitterApi,
55
} from '@autonomys/agent-core';
66

7+
import { createAgentApi } from './config/api.js';
78
import { createExperienceConfig } from './config/experiences.js';
89
import { ConfigInstance } from './config/types.js';
9-
1010
const schedulerTools = createAllSchedulerTools();
1111

1212
// Define custom tool creators
@@ -15,7 +15,7 @@ export const createTwitterTool = async (configInstance: ConfigInstance) => {
1515
if (!twitterConfig || !twitterConfig.USERNAME || !twitterConfig.PASSWORD) {
1616
return undefined;
1717
}
18-
18+
const apiConfig = createAgentApi(configInstance);
1919
const twitterApi = await createTwitterApi(
2020
twitterConfig.USERNAME,
2121
twitterConfig.PASSWORD,
@@ -29,6 +29,7 @@ export const createTwitterTool = async (configInstance: ConfigInstance) => {
2929
experienceConfig,
3030
monitoringConfig,
3131
modelConfigurations: twitterConfig.model_configurations,
32+
apiConfig,
3233
});
3334
return twitterAgent;
3435
};

yarn.lock

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,16 +55,17 @@ __metadata:
5555
languageName: node
5656
linkType: hard
5757

58-
"@autonomys/agent-core@npm:^0.2.4":
59-
version: 0.2.4
60-
resolution: "@autonomys/agent-core@npm:0.2.4"
58+
"@autonomys/agent-core@npm:^0.3.1":
59+
version: 0.3.1
60+
resolution: "@autonomys/agent-core@npm:0.3.1"
6161
dependencies:
6262
"@autonomys/auto-dag-data": "npm:1.4.17"
6363
"@autonomys/auto-drive": "npm:1.4.17"
6464
"@autonomys/auto-utils": "npm:1.4.17"
6565
"@langchain/anthropic": "npm:0.3.17"
6666
"@langchain/community": "npm:0.3.40"
6767
"@langchain/core": "npm:0.3.44"
68+
"@langchain/deepseek": "npm:^0.0.1"
6869
"@langchain/groq": "npm:0.2.0"
6970
"@langchain/langgraph": "npm:0.2.63"
7071
"@langchain/mcp-adapters": "npm:^0.4.2"
@@ -95,7 +96,7 @@ __metadata:
9596
xml2js: "npm:^0.6.2"
9697
zod: "npm:^3.22.4"
9798
zod-to-json-schema: "npm:^3.24.1"
98-
checksum: 10c0/f249629b61a91cb407e39e1ab5bb7d15d7245c21dba544e13d6e02f04f4b7a1b817163cb568c65d72405a3a7c3908bdf5782dc94819acce755bd0e1317e825d5
99+
checksum: 10c0/6bb81d5a7b8b63193af69123c4c0fe20b03e61a74773ecd8fa8abb9f58574b76724dd913c9c003a8b0435eb213a8f9c7a8ab828ed0f3cbd82bb0ad9ab9f1e09b
99100
languageName: node
100101
linkType: hard
101102

@@ -1189,6 +1190,18 @@ __metadata:
11891190
languageName: node
11901191
linkType: hard
11911192

1193+
"@langchain/deepseek@npm:^0.0.1":
1194+
version: 0.0.1
1195+
resolution: "@langchain/deepseek@npm:0.0.1"
1196+
dependencies:
1197+
"@langchain/openai": "npm:^0.4.2"
1198+
zod: "npm:^3.24.1"
1199+
peerDependencies:
1200+
"@langchain/core": ">=0.3.0 <0.4.0"
1201+
checksum: 10c0/d4412a1e380ccc12f35169fde6541484f14ba08bb317d44d103fab3592f26e25b8c24c8d0553d30b1a90cd43f82a565623221211a77f0ac892d076df25984f4d
1202+
languageName: node
1203+
linkType: hard
1204+
11921205
"@langchain/groq@npm:0.2.0":
11931206
version: 0.2.0
11941207
resolution: "@langchain/groq@npm:0.2.0"
@@ -1297,6 +1310,20 @@ __metadata:
12971310
languageName: node
12981311
linkType: hard
12991312

1313+
"@langchain/openai@npm:^0.4.2":
1314+
version: 0.4.9
1315+
resolution: "@langchain/openai@npm:0.4.9"
1316+
dependencies:
1317+
js-tiktoken: "npm:^1.0.12"
1318+
openai: "npm:^4.87.3"
1319+
zod: "npm:^3.22.4"
1320+
zod-to-json-schema: "npm:^3.22.3"
1321+
peerDependencies:
1322+
"@langchain/core": ">=0.3.39 <0.4.0"
1323+
checksum: 10c0/456db6d039fad521caf9c2dab547075120d1156282c9eb891430b83f34d617121f4d97fda2be7954558910ddac8d235effe6071a002b93e60f460111318466d2
1324+
languageName: node
1325+
linkType: hard
1326+
13001327
"@langchain/openai@npm:~0.3.0":
13011328
version: 0.3.17
13021329
resolution: "@langchain/openai@npm:0.3.17"
@@ -3071,7 +3098,7 @@ __metadata:
30713098
version: 0.0.0-use.local
30723099
resolution: "autonomys-agent-template@workspace:."
30733100
dependencies:
3074-
"@autonomys/agent-core": "npm:^0.2.4"
3101+
"@autonomys/agent-core": "npm:^0.3.1"
30753102
"@eslint/js": "npm:^9.18.0"
30763103
"@typescript-eslint/eslint-plugin": "npm:^8.29.0"
30773104
"@typescript-eslint/parser": "npm:^8.29.0"

0 commit comments

Comments
 (0)