### Initialize KaibanJS Project
Source: https://github.com/kaiban-ai/KaibanJS
Run this command in your project directory to set up KaibanJS. This command handles the installation of necessary dependencies and the creation of initial configuration files for your Kaiban Board.
```shell
npx kaibanjs@latest init
```
--------------------------------
### Basic KaibanJS Workflow Example
Source: https://github.com/kaiban-ai/KaibanJS
A comprehensive example demonstrating the fundamental steps to define an Agent, create a Task, set up a Team, and start a workflow using KaibanJS. This snippet illustrates how to configure agents with roles and goals, assign tasks, and manage the execution flow, including error handling.
```JavaScript
// Define an agent
const researchAgent = new Agent({
name: 'Researcher',
role: 'Information Gatherer',
goal: 'Find relevant information on a given topic'
});
// Create a task
const researchTask = new Task({
description: 'Research recent AI developments',
agent: researchAgent
});
// Set up a team
const team = new Team({
name: 'AI Research Team',
agents: [researchAgent],
tasks: [researchTask],
env: { OPENAI_API_KEY: 'your-api-key-here' }
});
// Start the workflow
team
.start()
.then((output) => {
console.log('Workflow completed:', output.result);
})
.catch((error) => {
console.error('Workflow error:', error);
});
```
--------------------------------
### Install KaibanJS via npm
Source: https://github.com/kaiban-ai/KaibanJS
This command installs the KaibanJS library using the Node Package Manager (npm). It's the essential first step for manually setting up KaibanJS in your development environment.
```shell
npm install kaibanjs
```
--------------------------------
### Install KaibanJS via npm
Source: https://github.com/kaiban-ai/KaibanJS
Instructions for installing the KaibanJS library using the npm package manager. This command adds KaibanJS to your project's dependencies.
```npm
npm install kaibanjs
```
--------------------------------
### Basic Kaiban.js Workflow Setup with Agent, Task, and Team
Source: https://github.com/kaiban-ai/KaibanJS
This example illustrates the fundamental steps to create and run a simple AI workflow using the `kaibanjs` library. It shows how to define an `Agent` with a specific name, role, and goal, create a `Task` assigned to that agent, and then assemble them into a `Team`. The snippet also demonstrates how to initiate the team's workflow using the `.start()` method and handle its asynchronous output or potential errors, including setting environment variables like `OPENAI_API_KEY`.
```javascript
// Define an agent
const researchAgent = new Agent({
name: 'Researcher',
role: 'Information Gatherer',
goal: 'Find relevant information on a given topic',
});
// Create a task
const researchTask = new Task({
description: 'Research recent AI developments',
agent: researchAgent,
});
// Set up a team
const team = new Team({
name: 'AI Research Team',
agents: [researchAgent],
tasks: [researchTask],
env: { OPENAI_API_KEY: 'your-api-key-here' },
});
// Start the workflow
team
.start()
.then((output) => {
console.log('Workflow completed:', output.result);
})
.catch((error) => {
console.error('Workflow error:', error);
});
```
--------------------------------
### Start Kaiban Board
Source: https://github.com/kaiban-ai/KaibanJS
Execute this command to start or restart your Kaiban Board. This command launches the development server, allowing you to access and interact with your KaibanJS application in your browser, reflecting any recent configuration changes.
```shell
npm run kaiban
```
--------------------------------
### Initialize KaibanJS Project
Source: https://github.com/kaiban-ai/KaibanJS
Run this command in your project directory to set up KaibanJS. This initializer fetches the latest version and prepares your environment with necessary files and configurations for a new KaibanJS application.
```shell
npx kaibanjs@latest init
```
--------------------------------
### Integrate KaibanJS State Management with React
Source: https://github.com/kaiban-ai/KaibanJS
Provides a simplified example of how to integrate KaibanJS's Redux-inspired state management into a React application, demonstrating the use of `myAgentsTeam.useStore()` to access and manage agent and workflow states.
```javascript
import myAgentsTeam from './agenticTeam';
const KaibanJSComponent = () => {
const useTeamStore = myAgentsTeam.useStore();
const { agents, workflowResult } = useTeamStore((state) => ({
agents: state.agents,
workflowResult: state.workflowResult,
}));
return (
);
};
```
--------------------------------
### Create New Vite React Project
Source: https://docs.kaibanjs.com/llms-full.txt
Initial setup commands for creating a new Vite project with a React template, navigating into the project directory, installing dependencies, and starting the development server.
```bash
npm create vite@latest kaibanjs-react-demo -- --template react
cd kaibanjs-react-demo
npm install
npm run dev
```
--------------------------------
### Creating and Starting a JavaScript AI Team
Source: https://docs.kaibanjs.com/llms-full.txt
This example demonstrates how to define agents with specific roles and goals, create tasks for these agents, and then assemble and start a `Team` instance. It shows the setup of initial inputs and environment variables, and how to handle the team's workflow status and results.
```js
// Define agents with specific roles and goals
const profileAnalyst = new Agent({
name: 'Mary',
role: 'Profile Analyst',
goal: 'Extract structured information from conversational user input.',
background: 'Data Processor',
tools: []
});
const resumeWriter = new Agent({
name: 'Alex Mercer',
role: 'Resume Writer',
goal: `Craft compelling, well-structured resumes
that effectively showcase job seekers qualifications and achievements.`,
background: `Extensive experience in recruiting,
copywriting, and human resources, enabling
effective resume design that stands out to employers.`,
tools: []
});
// Define the tasks for each agent
const processingTask = new Task({
description: `Extract relevant details such as name,
experience, skills, and job history from the user's 'aboutMe' input.
aboutMe: {aboutMe}`,
expectedOutput: 'Structured data ready to be used for a resume creation.',
agent: profileAnalyst
});
const resumeCreationTask = new Task({
description: `Utilize the structured data to create
a detailed and attractive resume.
Enrich the resume content by inferring additional details from the provided information.
Include sections such as a personal summary, detailed work experience, skills, and educational background.`,
expectedOutput: `A professionally formatted resume in markdown format,
ready for submission to potential employers.`,
agent: resumeWriter
});
// Create and start the team
const team = new Team({
name: 'Resume Creation Team',
agents: [profileAnalyst, resumeWriter],
tasks: [processingTask, resumeCreationTask],
inputs: { aboutMe: `My name is David Llaca.
JavaScript Developer for 5 years.
I worked for three years at Disney,
where I developed user interfaces for their primary landing pages
using React, NextJS, and Redux. Before Disney,
I was a Junior Front-End Developer at American Airlines,
where I worked with Vue and Tailwind.
I earned a Bachelor of Science in Computer Science from FIU in 2018,
and I completed a JavaScript bootcamp that same year.` }, // Initial input for the first task
env: {OPENAI_API_KEY: 'your-open-ai-api-key'}, // Environment variables for the team
insights: `
Resume Success Metrics (2023):
1. Format Impact: STAR format results in 89% interview rate
2. Professional Titles: Using Mr./Ms. increases callbacks by 100%
3. Content Structure: 4-6 bullet points per role optimal
4. Keywords: "Implemented" + metrics = 76% success rate
5. Experience Focus: Last 10 years most relevant to employers
`
});
// Listen to the workflow status changes
// team.onWorkflowStatusChange((status) => {
// console.log("Workflow status:", status);
// });
team.start()
.then((output) => {
console.log("Workflow status:", output.status);
console.log("Result:", output.result);
})
.catch((error) => {
console.error("Workflow encountered an error:", error);
});
```
--------------------------------
### Integrate Tools with Agents
Source: https://github.com/kaiban-ai/KaibanJS
Demonstrates how to define and integrate a `Tool` with an `Agent` in KaibanJS. This example shows the creation of a `Tavily Search Results` tool and its assignment to an agent, enabling the agent to perform specialized external actions like search.
```JavaScript
import { Agent, Tool } from 'kaibanjs';
const tavilySearchResults = new Tool({
name: 'Tavily Search Results',
maxResults: 1,
apiKey: 'ENV_TRAVILY_API_KEY'
});
const peterAtlas = new Agent({
name: 'Peter Atlas'
});
```
--------------------------------
### Configure KaibanJS Agents with Multiple LLM Providers
Source: https://github.com/kaiban-ai/KaibanJS
This JavaScript example demonstrates how to initialize multiple `Agent` instances in KaibanJS, each configured to use a different Large Language Model (LLM) provider and model. It showcases a scenario where agents collaborate on feature specification development, with each agent assigned a specific role and goal, leveraging distinct AI models for optimized efficiency and cost-effectiveness.
```JavaScript
import { Agent } from 'kaibanjs';
const emma = new Agent({
name: 'Emma',
role: 'Initial Drafting',
goal: 'Outline core functionalities',
llmConfig: {
provider: 'google',
model: 'gemini-1.5-pro',
},
});
const lucas = new Agent({
name: 'Lucas',
role: 'Technical Specification',
goal: 'Draft detailed technical specifications',
llmConfig: {
provider: 'anthropic',
model: 'claude-3-5-sonnet-20240620',
},
});
const mia = new Agent({
name: 'Mia',
role: 'Final Review',
goal: 'Ensure accuracy and completeness of the final document',
llmConfig: {
provider: 'openai',
model: 'gpt-4o',
},
});
```
--------------------------------
### Create a new Next.js project and start development server
Source: https://context7_llms
Commands to initialize a new Next.js application, navigate into its directory, and start the local development server. This snippet also includes important notes on selecting default options during the `create-next-app` setup process to align with the tutorial's requirements.
```bash
npx create-next-app kaibanjs-next-example
cd kaibanjs-next-example
# Start the development server
npm run dev
```
--------------------------------
### Example Usage of Team start() Method
Source: https://docs.kaibanjs.com/llms-full.txt
Illustrates how to call the `team.start()` method and handle its promise-based output. The example demonstrates checking for 'FINISHED' and 'BLOCKED' statuses, and catching potential errors during workflow execution to manage different workflow outcomes.
```js
team.start()
.then((output) => {
if (output.status === 'FINISHED') {
console.log("Workflow completed. Final result:", output.result);
} else if (output.status === 'BLOCKED') {
console.log("Workflow is blocked");
// Handle blocked state (e.g., request human intervention)
}
})
.catch((error) => {
console.error("Workflow encountered an error:", error);
});
```
--------------------------------
### KaibanJS Developer's Statement
Source: https://github.com/kaiban-ai/KaibanJS
A simple JavaScript snippet illustrating the core motivation behind KaibanJS: to provide a robust AI framework for JavaScript developers, eliminating the need to learn Python for meaningful AI work.
```javascript
const writtenBy = `Another JS Dev Who Doesn't Want to Learn Python to do meaningful AI Stuff.`;
console.log(writtenBy);
```
--------------------------------
### Define KaibanJS Agents with Diverse LLM Providers
Source: https://github.com/kaiban-ai/KaibanJS
Shows how to configure individual KaibanJS agents to utilize different Large Language Model (LLM) providers and specific models (e.g., Google, Anthropic, OpenAI), allowing for specialized and cost-effective AI capabilities within a single team.
```javascript
import { Agent } from 'kaibanjs';
const emma = new Agent({
name: 'Emma',
role: 'Initial Drafting',
goal: 'Outline core functionalities',
llmConfig: {
provider: 'google',
model: 'gemini-1.5-pro',
},
});
const lucas = new Agent({
name: 'Lucas',
role: 'Technical Specification',
goal: 'Draft detailed technical specifications',
llmConfig: {
provider: 'anthropic',
model: 'claude-3-5-sonnet-20240620',
},
});
const mia = new Agent({
name: 'Mia',
role: 'Final Review',
goal: 'Ensure accuracy and completeness of the final document',
llmConfig: {
provider: 'openai',
model: 'gpt-4o',
},
});
```
--------------------------------
### Example Usage of Team Start Method
Source: https://context7_llms
Illustrates how to call the `team.start()` method and handle its promise-based output. This example demonstrates checking for 'FINISHED' and 'BLOCKED' statuses, as well as catching errors during workflow execution.
```javascript
team.start()
.then((output) => {
if (output.status === 'FINISHED') {
console.log("Workflow completed. Final result:", output.result);
} else if (output.status === 'BLOCKED') {
console.log("Workflow is blocked");
// Handle blocked state (e.g., request human intervention)
}
})
.catch((error) => {
console.error("Workflow encountered an error:", error);
});
```
--------------------------------
### Configure OpenAI API Key
Source: https://github.com/kaiban-ai/KaibanJS
After initializing your project, add your OpenAI API key to the `.env` file. This key is crucial for enabling AI service integration within your KaibanJS application. Remember to replace 'your-api-key-here' with your actual API key.
```dotenv
VITE_OPENAI_API_KEY=your-api-key-here
```
--------------------------------
### Configure OpenAI API Key
Source: https://github.com/kaiban-ai/KaibanJS
Add your OpenAI API key to the '.env' file in your project's root directory. This key is crucial for KaibanJS to authenticate and interact with OpenAI services, enabling AI agent functionalities.
```env
VITE_OPENAI_API_KEY=your-api-key-here
```
--------------------------------
### Initialize Kaiban.js Agents with Roles and Goals
Source: https://github.com/kaiban-ai/KaibanJS
This snippet demonstrates how to import the `Agent` class from the `kaibanjs` library and initialize multiple `Agent` instances. Each agent is configured with a unique name, role, goal, and background, representing different personas within a team for collaborative AI applications.
```javascript
import { Agent } from 'kaibanjs';
const daveLoper = new Agent({
name: 'Dave Loper',
role: 'Developer',
goal: 'Write and review code',
background: 'Experienced in JavaScript, React, and Node.js',
});
const ella = new Agent({
name: 'Ella',
role: 'Product Manager',
goal: 'Define product vision and manage roadmap',
background: 'Skilled in market analysis and product strategy',
});
const quinn = new Agent({
name: 'Quinn',
role: 'QA Specialist',
goal: 'Ensure quality and consistency',
background: 'Expert in testing, automation, and bug tracking',
});
```
--------------------------------
### Clone and Setup Kaiban LLM Proxy
Source: https://docs.kaibanjs.com/how-to/API%20Key%20Management
Instructions to clone the Kaiban LLM Proxy repository from GitHub, navigate into the project directory, install its Node.js dependencies, and start the development server. This allows for local exploration and modification of the proxy.
```Bash
git clone https://github.com/kaiban-ai/kaiban-llm-proxy.git
cd kaiban-llm-proxy
npm install
npm run dev
```
--------------------------------
### Initialize a New KaibanJS Project
Source: https://www.npmjs.com/package/kaibanjs
This command runs the KaibanJS initializer, setting up the necessary project structure and configuration files in your current directory to get started with KaibanJS.
```Shell
npx kaibanjs@latest init
```
--------------------------------
### Creating and Starting an Agent Team in JavaScript
Source: https://context7_llms
This example demonstrates how to define agents with specific roles and goals, create tasks for these agents, and then assemble and start a `Team` object. It shows how to pass initial inputs and environment variables, and how to handle the workflow output, including success and error scenarios.
```js
// Define agents with specific roles and goals
const profileAnalyst = new Agent({
name: 'Mary',
role: 'Profile Analyst',
goal: 'Extract structured information from conversational user input.',
background: 'Data Processor',
tools: []
});
const resumeWriter = new Agent({
name: 'Alex Mercer',
role: 'Resume Writer',
goal: `Craft compelling, well-structured resumes
that effectively showcase job seekers qualifications and achievements.`,
background: `Extensive experience in recruiting,
copywriting, and human resources, enabling
effective resume design that stands out to employers.`,
tools: []
});
// Define the tasks for each agent
const processingTask = new Task({
description: `Extract relevant details such as name,
experience, skills, and job history from the user's 'aboutMe' input.
aboutMe: {aboutMe}`,
expectedOutput: 'Structured data ready to be used for a resume creation.',
agent: profileAnalyst
});
const resumeCreationTask = new Task({
description: `Utilize the structured data to create
a detailed and attractive resume.
Enrich the resume content by inferring additional details from the provided information.
Include sections such as a personal summary, detailed work experience, skills, and educational background.`,
expectedOutput: `A professionally formatted resume in markdown format,
ready for submission to potential employers.`,
agent: resumeWriter
});
// Create and start the team
const team = new Team({
name: 'Resume Creation Team',
agents: [profileAnalyst, resumeWriter],
tasks: [processingTask, resumeCreationTask],
inputs: { aboutMe: `My name is David Llaca.
JavaScript Developer for 5 years.
I worked for three years at Disney,
where I developed user interfaces for their primary landing pages
using React, NextJS, and Redux. Before Disney,
I was a Junior Front-End Developer at American Airlines,
where I worked with Vue and Tailwind.
I earned a Bachelor of Science in Computer Science from FIU in 2018,
and I completed a JavaScript bootcamp that same year.` }, // Initial input for the first task
env: {OPENAI_API_KEY: 'your-open-ai-api-key'}, // Environment variables for the team
insights: `
Resume Success Metrics (2023):
1. Format Impact: STAR format results in 89% interview rate
2. Professional Titles: Using Mr./Ms. increases callbacks by 100%
3. Content Structure: 4-6 bullet points per role optimal
4. Keywords: "Implemented" + metrics = 76% success rate
5. Experience Focus: Last 10 years most relevant to employers
`
});
// Listen to the workflow status changes
// team.onWorkflowStatusChange((status) => {
// console.log("Workflow status:", status);
// });
team.start()
.then((output) => {
console.log("Workflow status:", output.status);
console.log("Result:", output.result);
})
.catch((error) => {
console.error("Workflow encountered an error:", error);
});
```
--------------------------------
### Clone and Run Kaiban LLM Proxy
Source: https://docs.kaibanjs.com/llms-full.txt
Instructions to clone the Kaiban LLM Proxy repository from GitHub, navigate into the project directory, install its dependencies using npm, and start the development server. This allows users to set up and explore the proxy locally for development or modification.
```bash
git clone https://github.com/kaiban-ai/kaiban-llm-proxy.git
cd kaiban-llm-proxy
npm install
npm run dev
```
--------------------------------
### Full KaibanJS Team Implementation with Customer Service Insights
Source: https://docs.kaibanjs.com/llms-full.txt
This comprehensive example illustrates a complete KaibanJS multi-agent system setup for customer service. It defines agents, tasks, and a team, integrating structured customer support history and usage patterns as `insights` to enable personalized support solutions. It also shows how to start the team workflow and handle output or errors.
```javascript
import { Agent, Task, Team } from 'kaibanjs';
// Define agents
const analysisAgent = new Agent({
name: 'Alice',
role: 'Customer Profile Analyst',
goal: 'Analyze customer history and identify key patterns',
background: 'Customer Behavior Analysis',
});
const supportAgent = new Agent({
name: 'Bob',
role: 'Support Specialist',
goal: 'Provide personalized support solutions',
background: 'Customer Service and Problem Resolution',
});
// Define tasks
const analysisTask = new Task({
description: 'Analyze customer profile and recent interactions',
expectedOutput: 'Detailed analysis of customer needs and patterns',
agent: analysisAgent,
});
const supportTask = new Task({
description: 'Create personalized support plan based on analysis',
expectedOutput: 'Support plan with specific recommendations',
agent: supportAgent,
isDeliverable: true,
});
// Create team with insights
const team = new Team({
name: 'Customer Support Team',
agents: [analysisAgent, supportAgent],
tasks: [analysisTask, supportTask],
insights: `
Customer: John Smith (ID: CS-45678)
Support History (Last 90 Days):
1. Ticket #T-892: Login issues with mobile app
- Resolution: Guided through app reinstallation
- Satisfaction: 4/5
2. Ticket #T-923: Billing inquiry
- Resolution: Explained premium features
- Satisfaction: 5/5
Usage Patterns:
- Primary platform: Mobile (iOS)
- Feature usage: Heavy user of analytics dashboard
- Login frequency: Daily
- Subscription: Premium tier
Previous Feedback:
- Appreciates quick responses
- Prefers video tutorials over text
- Has mentioned interest in API access
`,
env: { OPENAI_API_KEY: process.env.OPENAI_API_KEY }
});
// Start the workflow
team.start()
.then(output => {
console.log('Support plan:', output.result);
})
.catch(error => {
console.error('Error:', error);
});
```
--------------------------------
### Create Vite React Project
Source: https://context7_llms
Commands to initialize a new Vite project with a React template, navigate into the project directory, install initial dependencies, and start the development server.
```bash
npm create vite@latest kaibanjs-react-demo -- --template react
cd kaibanjs-react-demo
npm install
# Start the development server
npm run dev
```
--------------------------------
### Initialize NodeJS Project and Install Dependencies
Source: https://context7_llms
Steps to set up a new Node.js project, including creating a project directory, initializing npm, and installing necessary dependencies like 'kaibanjs', '@langchain/community', and 'dotenv'.
```bash
# Create a new directory for your project
mkdir kaibanjs-node-demo
cd kaibanjs-node-demo
# Initialize a new Node.js project
npm init -y
# Install necessary dependencies
npm install kaibanjs @langchain/community dotenv
```
--------------------------------
### Import KaibanJS Modules
Source: https://github.com/kaiban-ai/KaibanJS
Demonstrates how to import the core KaibanJS modules (Agent, Task, Team) into your JavaScript files. Includes examples for both ES6 import syntax (for modern frameworks like Next.js/React) and CommonJS syntax (for Node.js environments).
```JavaScript
// Using ES6 import syntax for NextJS, React, etc.
import { Agent, Task, Team } from 'kaibanjs';
```
```Node.js
// Using CommonJS syntax for NodeJS
const { Agent, Task, Team } = require('kaibanjs');
```
--------------------------------
### Importing Kaiban.js Modules (ES6 & CommonJS)
Source: https://github.com/kaiban-ai/KaibanJS
This snippet demonstrates how to import the core `Agent`, `Task`, and `Team` classes from the `kaibanjs` library. It provides examples for both ES6 import syntax, suitable for modern JavaScript environments like Next.js or React, and CommonJS `require` syntax, typically used in Node.js applications. This covers the initial setup required to access the library's functionalities.
```javascript
// Using ES6 import syntax for NextJS, React, etc.
import { Agent, Task, Team } from 'kaibanjs';
```
```javascript
// Using CommonJS syntax for NodeJS
const { Agent, Task, Team } = require('kaibanjs');
```
--------------------------------
### Initialize KaibanJS Node.js Project
Source: https://docs.kaibanjs.com/llms-full.txt
Commands to create a new directory, navigate into it, initialize a Node.js project, and install necessary dependencies for a KaibanJS application.
```bash
mkdir kaibanjs-node-demo
cd kaibanjs-node-demo
npm init -y
npm install kaibanjs @langchain/community dotenv
```
--------------------------------
### Configure Team Memory in KaibanJS
Source: https://github.com/kaiban-ai/KaibanJS
This example demonstrates how to configure memory management for a Team in KaibanJS. It shows two configurations: one enabling automatic memory access for all previous task results, and another disabling it for explicit result management, allowing for fine-grained control over workflow context.
```JavaScript
const team = new Team({
name: 'Content Creation Team',
agents: [researcher, writer, editor],
tasks: [researchTask, writingTask, editingTask],
memory: true, // Enable automatic access to all previous task results
});
// Or disable memory for explicit result management
const performanceTeam = new Team({
name: 'High-Performance Team',
agents: [analyst, processor],
tasks: [analysisTask, processingTask],
memory: false, // Require explicit result references
});
```
--------------------------------
### Install KaibanJS Tools Package
Source: https://docs.kaibanjs.com/llms-full.txt
Instructions for installing the `@kaibanjs/tools` npm package, which provides access to various KaibanJS tools like Exa Search and Wolfram Alpha. This is the first step before using any of the tools in your project.
```bash
npm install @kaibanjs/tools
```
--------------------------------
### Create a new Next.js project
Source: https://docs.kaibanjs.com/llms-full.txt
Commands to initialize a new Next.js application, navigate into its directory, and start the development server. This sets up the foundational structure for the project.
```bash
npx create-next-app kaibanjs-next-example
cd kaibanjs-next-example
# Start the development server
npm run dev
```
--------------------------------
### Install AI SDK and Groq Provider Packages
Source: https://console.groq.com/docs/quickstart
This command demonstrates how to install the necessary `ai` and `@ai-sdk/groq` packages using `pnpm`. These packages are essential for building applications that leverage the AI SDK with Groq's language models.
```shell
pnpm add ai @ai-sdk/groq
```
--------------------------------
### Initialize KaibanJS Project with npx
Source: https://kaibanjs.com/
Quickly set up a new KaibanJS project using the `npx` command, which handles initial configuration and file generation directly from the command line.
```Terminal
npx kaibanjs@latest init
```
--------------------------------
### Implement Task Result Passing with KaibanJS
Source: https://github.com/kaiban-ai/KaibanJS
Enable sophisticated workflows by passing results between tasks, allowing agents to build upon each other's work. This feature is essential for creating complex, multi-step processes where each task's output becomes input for subsequent tasks. In this example, a content creation team demonstrates how tasks can share and build upon results, creating a seamless workflow from research to final content production.
```javascript
import { Agent, Task, Team } from 'kaibanjs';
// Define tasks with result passing
const researchTask = new Task({
description: 'Research the topic: {topic}',
expectedOutput: 'Key research points in JSON format',
agent: researcher,
});
const writingTask = new Task({
description: `Write an article using this research data: {taskResult:task1}\n Focus on key insights and maintain professional tone.`,
expectedOutput: 'Draft article in markdown format',
agent: writer,
});
const editingTask = new Task({
description: `Edit and improve this article: {taskResult:task2}\n Enhance clarity and engagement.`,
expectedOutput: 'Final polished article',
agent: editor,
});
// Create a team with the tasks
const team = new Team({
name: 'Content Creation Team',
agents: [researcher, writer, editor],
tasks: [researchTask, writingTask, editingTask],
inputs: { topic: 'AI Trends 2024' },
});
```
--------------------------------
### Initialize KaibanJS Project
Source: https://docs.kaibanjs.com/llms-full.txt
Runs the KaibanJS initializer command to set up a new Kaiban Board in the current project directory, preparing it for AI-powered workflows.
```bash
npx kaibanjs@latest init
```
--------------------------------
### React Component for Initiating Agent Workflow and Displaying Agents
Source: https://github.com/kaiban-ai/KaibanJS
This React JSX snippet demonstrates how to integrate KaibanJS agent team functionality into a UI. It includes a button to start a team workflow and dynamically renders a list of agents with their names, roles, and statuses, showcasing basic UI interaction with KaibanJS.
```jsx
);
};
export default KaibanJSComponent;
```
--------------------------------
### Configure Team-Level Memory in KaibanJS
Source: https://github.com/kaiban-ai/KaibanJS
Illustrates how to enable or disable automatic access to previous task results at the team level in KaibanJS, providing control over context flow and optimizing performance in multi-agent systems.
```javascript
const team = new Team({
name: 'Content Creation Team',
agents: [researcher, writer, editor],
tasks: [researchTask, writingTask, editingTask],
memory: true, // Enable automatic access to all previous task results
});
// Or disable memory for explicit result management
const performanceTeam = new Team({
name: 'High-Performance Team',
agents: [analyst, processor],
tasks: [analysisTask, processingTask],
memory: false, // Require explicit result references
});
```
--------------------------------
### Initialize KaibanJS Project
Source: https://context7_llms
This command initializes KaibanJS in your project directory, setting up the necessary files and opening the Kaiban Board in your browser. It's the first step to begin developing with KaibanJS.
```bash
npx kaibanjs@latest init
```
--------------------------------
### Restart Kaiban Board
Source: https://github.com/kaiban-ai/KaibanJS
Execute this command to restart your Kaiban Board. It's typically required after making changes to configuration files, such as adding or modifying API keys, to ensure the new settings are applied.
```shell
npm run kaiban
```
--------------------------------
### Log Developer Sentiment in JavaScript
Source: https://github.com/kaiban-ai/KaibanJS
A simple JavaScript snippet that declares a string constant expressing a developer's preference for JavaScript in AI and then logs this string to the console. It serves as a lighthearted statement about KaibanJS's mission.
```JavaScript
const writtenBy = `Another JS Dev Who Doesn't Want to Learn Python to do meaningful AI Stuff.`;
console.log(writtenBy);
```
--------------------------------
### Start KaibanJS Next.js Development Server
Source: https://docs.kaibanjs.com/llms-full.txt
This command initiates the development server for the Next.js application, making it accessible via a local URL. It's the first step to run the KaibanJS-powered AI news blogging project.
```bash
npm run dev
```
--------------------------------
### Initialize KaibanJS Project via CLI
Source: https://www.kaibanjs.com/
This command quickly sets up a new KaibanJS project, preparing the necessary files and configurations for development.
```Terminal
npx kaibanjs@latest init
```
--------------------------------
### JavaScript Splash Screen and Performance Monitoring Setup
Source: https://stackblitz.com/~/github.com/kaiban-ai/kaibanjs-next-example
Initializes a splash screen iframe for loading indication and sets up a global event listener to capture and mark performance events received via `window.postMessage`. The splash screen is styled to cover the entire viewport and fade out.
```javascript
const splash = document.createElement('iframe');
splash.src = `https://ide-corp.staticblitz.com/3b0b7194bc6b567c2eaf4c96a5759098469dcf59/splash.html`;
splash.id = "monaco-parts-splash";
splash.style = ` height: 100%; width: 100%; position: fixed; z-index: 10000; border: none; inset: 0; transition: opacity 0.8s ease; pointer-events: none; `;
document.documentElement.appendChild(splash);
window.addEventListener("message", ({ data }) => {
if (data.type === "performance") {
performance.mark(data.mark, {
startTime: Math.max(0, data.time - performance.timing.navigationStart)
});
}
});
```
--------------------------------
### Pass Task Results Between KaibanJS Agents
Source: https://github.com/kaiban-ai/KaibanJS
Demonstrates how to define sequential tasks within a KaibanJS team, where the output of one task (`taskResult:taskN`) automatically becomes the input for a subsequent task, enabling complex, multi-step workflows.
```javascript
import { Agent, Task, Team } from 'kaibanjs';
// Define tasks with result passing
const researchTask = new Task({
description: 'Research the topic: {topic}',
expectedOutput: 'Key research points in JSON format',
agent: researcher,
});
const writingTask = new Task({
description: `Write an article using this research data: {taskResult:task1}
Focus on key insights and maintain professional tone.`,
expectedOutput: 'Draft article in markdown format',
agent: writer,
});
const editingTask = new Task({
description: `Edit and improve this article: {taskResult:task2}
Enhance clarity and engagement.`,
expectedOutput: 'Final polished article',
agent: editor,
});
// Create a team with the tasks
const team = new Team({
name: 'Content Creation Team',
agents: [researcher, writer, editor],
tasks: [researchTask, writingTask, editingTask],
inputs: { topic: 'AI Trends 2024' },
});
```
--------------------------------
### KaibanJS Documentation Filesystem Layout
Source: https://docs.kaibanjs.com/llms-full.txt
This snippet illustrates the complete directory structure of the KaibanJS documentation, showing how various topics like core concepts, getting started guides, how-to articles, LLM integrations, and tool documentation are organized hierarchically.
```Plaintext
└── core-concepts
└── 01-Agents.md
└── 02-Tools.md
└── 03-Tasks.md
└── 04-Teams.md
└── 05-State Management.md
└── 06-Observability and Monitoring.md
└── 07-Human-in-the-Loop.md
└── 08-Memory.md
└── 09-Task-Orchestration.md
└── _category_.json
└── get-started
└── 01-Quick Start.md
└── 02-Core Concepts Overview.md
└── 03-The Kaiban Board.md
└── 04-Using the Kaiban Board.md
└── 05-Tutorial: React + AI Agents.md
└── 06-Tutorial: Node.js + AI Agents.md
└── 07-Tutorial: Next.js + AI Agents.md
└── 08-Telemetry.md
└── 09-Next Steps.md
└── _category_.json
└── image-1.png
└── image-2.png
└── image.png
└── how-to
└── 01-Custom Agent Prompts.md
└── 02-Multiple LLMs Support.md
└── 03-Integrating with JavaScript Frameworks.md
└── 04-Implementing RAG with KaibanJS.md
└── 05-Using Typescript.md
└── 06-API Key Management.md
└── 07-Deployment Options.md
└── 08-Using Team Insights.md
└── 09-Kanban-Tools.md
└── 10-Task-Result-Passing.md
└── 11-Structured-Output.md
└── 12-MCP-Adapter-Integration.md
└── _category_.json
└── llms-docs
└── 01-Overview.md
└── 02-Model Providers API Keys.md
└── _category_.json
└── built-in-models
└── 01-Overview.md
└── 02-OpenAI.md
└── 03-Anthropic.md
└── 04-Google.md
└── 05-Mistral.md
└── _category_.json
└── custom-integrations
└── 01-Overview.md
└── 02-Ollama.md
└── 03-Azure.md
└── 04-Cohere.md
└── 05-Groq.md
└── 06-OpenRouter.md
└── 07-LM-Studio.md
└── 08-Other Integrations.md
└── _category_.json
└── tools-docs
└── 01-Overview.md
└── _category_.json
└── custom-tools
└── 02-Create a Custom Tool.md
└── 04-Serper.md
└── 05-WolframAlpha.md
└── 06-Submit Your Tool.md
└── 07-Request a Tool.md
└── _category_.json
└── kaibanjs-tools
└── 02-Firecrawl.md
└── 03-Tavily.md
└── 04-Serper.md
└── 05-Exa.md
└── 06-WolframAlpha.md
└── 07-GithubIssues.md
└── 08-SimpleRAG.md
└── 09-WebsiteSearch.md
└── 10-PDFSearch.md
└── 11-TextFileSearch.md
└── 12-ZapierWebhook.md
└── 13-MakeWebhook.md
└── 14-JinaUrlToMarkdown.md
└── 20-Contributing.md
└── _category_.json
└── langchain-tools
└── 02-SearchApi.md
└── 03-DallE.md
└── 04-TavilySearchResults.md
└── 05-More Tools.md
└── _category_.json
└── use-cases
└── 01-Sports News Reporting.md
└── 02-Trip Planning.md
└── 03-Resume Creation.md
└── 04-Company Research.md
└── 05-Hardware Optimization for PC Games.md
└── 06-GitHub-Release-Social-Media-Team.md
└── 07-AI-Driven Reddit Comment Generator.md
└── 08-Marketing Reports & Ads Optimization.md
└── 09-Automating Metadata Extraction and Discord Publishing.md
└── 10-SSL Security Analysis.md
└── 11-Automated LinkedIn Content Creation.md
└── _category_.json
```
--------------------------------
### Install KaibanJS Tools Package
Source: https://docs.kaibanjs.com/llms-full.txt
Provides the command-line instruction to install the KaibanJS tools package, which includes the ZapierWebhook tool, using npm.
```bash
npm install @kaibanjs/tools
```
--------------------------------
### Define Role-Based Agents
Source: https://github.com/kaiban-ai/KaibanJS
Illustrates how to define multiple specialized AI agents using the `Agent` class in KaibanJS. Each agent is configured with a unique name, role, goal, and background, showcasing the concept of role-based agent design for collaborative tasks.
```JavaScript
import { Agent } from 'kaibanjs';
const daveLoper = new Agent({
name: 'Dave Loper',
role: 'Developer',
goal: 'Write and review code',
background: 'Experienced in JavaScript, React, and Node.js'
});
const ella = new Agent({
name: 'Ella',
role: 'Product Manager',
goal: 'Define product vision and manage roadmap',
background: 'Skilled in market analysis and product strategy'
});
const quinn = new Agent({
name: 'Quinn',
role: 'QA Specialist',
goal: 'Ensure quality and consistency',
background: 'Expert in testing, automation, and bug tracking'
});
```
--------------------------------
### KaibanJS Application File Metadata Configuration
Source: https://github.com/kaiban-ai/KaibanJS
This JSON snippet represents internal application data, likely used for managing file metadata such as `CODE_OF_CONDUCT.md` and `LICENSE`, and configuring paths for web workers and feature flags within the KaibanJS application.
```JSON
main","path":"CODE_OF_CONDUCT.md","preferredFileType":"code_of_conduct","tabName":"Code of conduct","richText":null,"loaded":false,"timedOut":false,"errorMessage":null,"headerInfo":{"toc":null,"siteNavLoginPath":"/login?return_to=https%3A%2F%2Fgithub.com%2Fkaiban-ai%2FKaibanJS"}},{"displayName":"LICENSE","repoName":"KaibanJS","refName":"main","path":"LICENSE","preferredFileType":"license","tabName":"MIT","richText":null,"loaded":false,"timedOut":false,"errorMessage":null,"headerInfo":{"toc":null,"siteNavLoginPath":"/login?return_to=https%3A%2F%2Fgithub.com%2Fkaiban-ai%2FKaibanJS"}}],"overviewFilesProcessingTime":0}},"appPayload":{"helpUrl":"https://docs.github.com","findFileWorkerPath":"/assets-cdn/worker/find-file-worker-263cab1760dd.js","findInFileWorkerPath":"/assets-cdn/worker/find-in-file-worker-1b17b3e7786a.js","githubDevUrl":null,"enabled_features":{"copilot_workspace":null,"code_nav_ui_events":false,"react_blob_overlay":false,"accessible_code_button":true}}}}
```
--------------------------------
### Initialize KaibanJS Framework
Source: https://www.kaibanjs.com/share/VyfPFnQHiKxtr2BUkY9F
This snippet shows the initial setup call for the KaibanJS framework, pushing a zero-indexed instruction to its internal queue.
```javascript
KaibanJS(self.__next_f=self.__next_f||[]).push([0]);
```
--------------------------------
### Start Kaiban Board Application
Source: https://docs.kaibanjs.com/llms-full.txt
This command initiates the Kaiban Board application, making it accessible for use. It's a standard npm script execution.
```Shell
npm run kaiban
```
--------------------------------
### Configure and Use Wolfram Alpha Tool
Source: https://docs.kaibanjs.com/llms-full.txt
This example demonstrates how to initialize the WolframAlphaTool with an App ID, create an agent that uses it, and set up a team for scientific computing tasks, enabling complex mathematical and scientific problem-solving.
```javascript
import { WolframAlphaTool } from '@kaibanjs/tools';
// Configure Wolfram tool
const wolframTool = new WolframAlphaTool({
appId: 'your-wolfram-app-id'
});
// Create computation agent
const mathScientist = new Agent({
name: 'Euler',
role: 'Mathematical and Scientific Analyst',
goal: 'Solve complex mathematical and scientific problems',
background: 'Advanced Mathematics and Scientific Computing',
tools: [wolframTool]
});
// Create a team
const team = new Team({
name: 'Scientific Computing Team',
agents: [mathScientist],
tasks: [/* your tasks */],
inputs: {
query: 'Calculate the orbital period of Mars around the Sun'
}
});
```