
Security News
White House Authorizes Private Companies to Conduct Offensive Cyber Operations
A new federal program will let vetted U.S. cybersecurity firms help investigate and disrupt foreign cybercrime groups under government direction.
@agenite/agent
Advanced tools
A powerful and flexible TypeScript library for building AI agents with advanced tool integration and state management capabilities.
npm install @agenite/agent
import { Agent } from '@agenite/agent';
import { OllamaProvider } from '@agenite/ollama';
// Create a simple calculator tool
const calculatorTool = new Tool({
name: 'calculator',
description: 'Perform basic math operations',
execute: async ({ input }) => {
// Tool implementation
return { success: true, data: result.toString() };
},
});
// Initialize the agent
const agent = new Agent({
name: 'math-buddy',
provider: new OllamaProvider({ model: 'llama2' }),
tools: [calculatorTool],
instructions: 'You are a helpful math assistant.',
});
// Execute the agent
const result = await agent.execute({
messages: [{ role: 'user', content: [{ type: 'text', text: 'What is 1234 * 5678?' }] }],
});
The main class that orchestrates interactions between the LLM and tools. It handles:
Tools are functions that agents can use to perform specific tasks. Each tool has:
LLM providers that handle the actual language model interactions:
The agent execution is broken down into steps:
llm-call - Handles LLM interactionstool-call - Manages tool executiontool-result - Processes tool resultsagent-call - Handles nested agent executionconst customReducer = {
messages: (newValue, previousValue) => [
...(previousValue || []),
...(newValue || []),
],
runningTotal: (newValue, previousValue) =>
(previousValue || 0) + (newValue || 0),
};
const agent = new Agent({
name: 'stateful-calculator',
provider,
tools: [calculatorTool],
stateReducer: customReducer,
initialState: {
runningTotal: 0,
},
instructions:
'You are a helpful math assistant that maintains a running total.',
});
// Specialist agents
const calculatorAgent = new Agent({
name: 'calculator-specialist',
provider,
tools: [calculatorTool],
description: 'Specializes in mathematical calculations',
});
const weatherAgent = new Agent({
name: 'weather-specialist',
provider,
tools: [weatherTool],
description: 'Provides weather information',
});
// Coordinator agent
const coordinatorAgent = new Agent({
name: 'coordinator',
provider,
agents: [calculatorAgent, weatherAgent],
instructions:
'Coordinate between specialist agents to solve complex problems.',
});
const agent = new Agent({
name: 'streaming-agent',
provider,
tools: [calculatorTool],
middlewares: [
executionContextInjector(),
// Add custom middleware here
],
});
const iterator = agent.iterate({
messages: [{ role: 'user', content: [{ type: 'text', text: 'Your query here' }] }],
stream: true,
});
for await (const chunk of iterator) {
switch (chunk.type) {
case 'agenite.llm-call.streaming':
console.log(chunk.content);
break;
case 'agenite.tool-call.params':
console.log('Using tool:', chunk.toolUseBlocks);
break;
case 'agenite.tool-result':
console.log('Tool result:', chunk.result);
break;
}
}
new Agent({
name: string;
provider: LLMProvider;
tools?: Tool[];
instructions?: string;
description?: string;
agents?: Agent[];
stateReducer?: CustomStateReducer;
initialState?: Partial<StateFromReducer<CustomStateReducer>>;
steps?: Steps;
middlewares?: Middlewares;
})
execute({
messages: BaseMessage[];
stream?: boolean;
context?: Record<string, unknown>;
}): Promise<ExecutionResult>
iterate({
messages: BaseMessage[];
stream?: boolean;
context?: Record<string, unknown>;
}): AsyncIterator<StreamChunk>
Check out the examples directory for more detailed examples:
basic/ - Simple examples showing core functionality
simple-chat.ts - Basic chat agent with calculator tooladvanced/ - More complex examples
nested-agents.ts - Agent composition and delegationstateful-agent.ts - Maintaining conversation statestreaming-agent.ts - Real-time response streamingmulti-tool-agent.ts - Using multiple toolsContributions are welcome! Please feel free to submit a Pull Request.
MIT
FAQs
Simple and maintainable agent library
The npm package @agenite/agent receives a total of 62 weekly downloads. As such, @agenite/agent popularity was classified as not popular.
We found that @agenite/agent demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
A new federal program will let vetted U.S. cybersecurity firms help investigate and disrupt foreign cybercrime groups under government direction.

Research
/Security News
The campaign amassed more than 75,000 installs by targeting Russian-speaking users seeking access to blocked services.

Company News
Open source maintainers are under more pressure than ever. We're raising our open source program from the Team plan to the Business plan, free.