The Agent Catalyst provides a versatile JavaScript API for programmatically managing and executing agent-based workflows. This API allows you to define, compile, and run workflows directly in JavaScript or TypeScript applications.
Installation
Install the Agent Catalyst core package using your preferred package manager:
bash# Using npmnpminstall@agentsystem/core# Using yarnyarnadd@agentsystem/core# Using bunbunadd@agentsystem/core
Usage
Workflow Compilation
In Agent Catalyst, a workflow is represented by an AgentWorkflow instance. It encapsulates structure, metadata, and execution logic. Use the AgentWorkflow.compileSync method to create a workflow instance from a Markdown string:
javascriptimport{AgentEnvironment,AgentWorkflow}from'@agentsystem/core';// Initialize an environment with configured agent handlersconstenv=newAgentEnvironment({agents:{ // Configure agent handlers here (e.g., text generation, data processing)}});constmarkdown=`# Joke GeneratorTell me the corniest dad joke you can think of.<GenText as="joke" model="openai:gpt-4" />`;constagentWorkflow=AgentWorkflow.compileSync(markdown,env);
Workflow Execution
Workflows are executed step-by-step using the AgentExecutionController. This controller provides real-time events to track progress, handle errors, and manage outputs.
Features of the Execution Controller
Event Emission:
step: Triggered at the start of each workflow step.
complete: Triggered when the workflow finishes successfully.
error: Triggered when an error occurs during execution.
Fine-Grained Control:
Pause: Temporarily halt execution at any point.
Rewind: Rollback to previous steps for re-execution.
Examples
Basic Workflow Execution
Dynamic Input Handling
Why Use the Agent Catalyst JavaScript API?
Flexibility: Execute workflows dynamically within any JavaScript or TypeScript application.
Real-Time Monitoring: Track progress, handle errors, and retrieve results as they occur.
Advanced Control: Pause, rewind, or resume workflows as needed.
Seamless Integration: Directly interact with agent-based systems and external tools.
The Agent Catalyst’s JavaScript API empowers developers to integrate autonomous agent-driven workflows into their applications, enabling robust automation, data processing, and decision-making capabilities.