Skip to content

Commit 1b8f166

Browse files
committed
Simplifies codebase with agentLoop from agent-core
1 parent a413484 commit 1b8f166

File tree

12 files changed

+135
-350
lines changed

12 files changed

+135
-350
lines changed

package-lock.json

Lines changed: 70 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
"dist"
2525
],
2626
"dependencies": {
27+
"@enso-labs/agent-core": "^0.0.1-rc6",
28+
"@langchain/anthropic": "^0.3.26",
2729
"@langchain/core": "^0.3.66",
2830
"@langchain/ollama": "^0.2.3",
2931
"@langchain/openai": "^0.6.2",

source/config/llm.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ export class ChatModels {
44
public static readonly OPENAI_GPT_4_1_NANO = 'openai:gpt-4.1-nano';
55
public static readonly OPENAI_GPT_4_1_MINI = 'openai:gpt-4.1-mini';
66
public static readonly OPENAI_GPT_4_5 = 'openai:gpt-4.5';
7+
public static readonly OPENAI_GPT_5_NANO = 'openai:gpt-5-nano';
8+
public static readonly OPENAI_GPT_5_MINI = 'openai:gpt-5-mini';
9+
public static readonly OPENAI_GPT_5 = 'openai:gpt-5';
710
public static readonly OPENAI_O3 = 'openai:o3';
811
// public static readonly OPENAI_O3_PRO = "openai:o3-pro";
912
public static readonly OPENAI_O4_MINI = 'openai:o4-mini';

source/providers/AppProvider/index.tsx

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,11 @@ import {useInput, useApp} from 'ink';
99
import {AppState} from '../../entities/state.js';
1010
import {ChatModels} from '../../config/llm.js';
1111
import {getConfigManager} from '../../utils/config.js';
12-
import {agentLoop, initializeAgent, AgentResponse} from '../../utils/agent.js';
12+
import {initializeAgent, AgentResponse} from '../../utils/agent.js';
13+
import {agentLoop} from "@enso-labs/agent-core"
1314
import {promises as fs} from 'fs';
15+
import { toolsArray } from '../../utils/tools/index.js';
16+
import { Tool } from '@langchain/core/tools';
1417

1518
const configManager = getConfigManager();
1619
export const AppContext = createContext({});
@@ -179,11 +182,12 @@ export default function AppProvider({children}: {children: React.ReactNode}) {
179182

180183
try {
181184
const config = await configManager.load();
182-
const response: AgentResponse = await agentLoop(
183-
userInput,
184-
agentState,
185-
config.selectedModel as ChatModels,
186-
);
185+
const response: AgentResponse = await agentLoop({
186+
prompt: userInput,
187+
model: config.selectedModel as string,
188+
tools: toolsArray as Tool[],
189+
state: agentState,
190+
});
187191

188192
setState(prev => {
189193
// Get only the NEW events since last interaction
@@ -203,7 +207,7 @@ export default function AppProvider({children}: {children: React.ReactNode}) {
203207
const newHistoryItems = [...prev.history];
204208

205209
// Add each new tool event individually with output
206-
newToolEvents.forEach(event => {
210+
newToolEvents.forEach((event: any) => {
207211
const toolOutput = event.content ? ` → ${event.content}` : '';
208212
newHistoryItems.push(
209213
`🛠️ Tool: ${event.intent} ${event.metadata?.icon} ${toolOutput}`,

source/services/agent-service.ts

Lines changed: 0 additions & 11 deletions
This file was deleted.
Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import {ThreadState} from '../memory.js';
2-
import {agentLoop} from '../agent.js';
1+
import {agentLoop} from '@enso-labs/agent-core';
32
import ChatModels from '../../config/llm.js';
43
import {toolsArray} from '../tools/index.js';
54
import {Tool} from 'langchain/tools';
@@ -21,24 +20,11 @@ describe.skip('Agent Utilities', () => {
2120
handleEnv();
2221
});
2322
it('should be able to create an agent', async () => {
24-
const state: ThreadState = {
25-
thread: {
26-
usage: {
27-
prompt_tokens: 0,
28-
completion_tokens: 0,
29-
total_tokens: 0,
30-
},
31-
events: [],
32-
},
33-
};
34-
console.log(state);
35-
const result = await agentLoop(
36-
'What is current dir?',
37-
state,
38-
ChatModels.OPENAI_GPT_4_1_NANO,
39-
toolsArray as Tool[],
40-
);
23+
const result = await agentLoop({
24+
prompt: 'What is current dir?',
25+
model: ChatModels.OPENAI_GPT_4_1_NANO,
26+
tools: toolsArray as Tool[],
27+
});
4128
expect(result).toBeDefined();
42-
// expect(result.content).toBe('Hello');
4329
});
4430
});

0 commit comments

Comments
 (0)