Skip to content

Commit 7436167

Browse files
Enhance workflow package and create WorkflowDrivenAgent (kaiban-ai#245)
Enhance workflow package with UUID generation and agent status management - Added a `generateUUID` function to provide a consistent UUID generation method across environments. - Updated the `Agent` class to support `WorkflowDrivenAgent` and handle new workflow agent statuses. - Integrated `WORKFLOW_AGENT_STATUS_enum` for improved status tracking of workflow agents. - Updated package dependencies in `package.json` and `package-lock.json` to include `@kaibanjs/workflow` and other necessary packages. - Adjusted various files to ensure compatibility with the new workflow features.
2 parents 17bf1ab + c1af791 commit 7436167

File tree

60 files changed

+13182
-240
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+13182
-240
lines changed

README.md

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -517,6 +517,67 @@ For more details on how to utilize observability features in KaibanJS, please vi
517517

518518
</details>
519519

520+
<details style="margin-bottom:10px;">
521+
<summary><b style="color:black;">WorkflowDrivenAgent</b></summary>
522+
523+
<p style="margin-top:10px;">
524+
The `WorkflowDrivenAgent` is a specialized agent that executes workflows instead of using LLM-based reasoning. This agent maintains workflow state and can handle suspension and resumption operations for long-running workflows, providing a deterministic approach to task execution.
525+
526+
In this example, a `WorkflowDrivenAgent` is created to execute a workflow that processes data through defined steps, allowing for complex multi-step operations without LLM calls.
527+
528+
</p>
529+
530+
```js
531+
import { Agent } from 'kaibanjs';
532+
import { createStep, createWorkflow } from '@kaibanjs/workflow';
533+
import { z } from 'zod';
534+
535+
// Create workflow steps
536+
const processStep = createStep({
537+
id: 'process',
538+
inputSchema: z.object({ data: z.string() }),
539+
outputSchema: z.object({ result: z.string() }),
540+
execute: async ({ inputData }) => {
541+
const { data } = inputData as { data: string };
542+
return { result: data.toUpperCase() };
543+
},
544+
});
545+
546+
// Create the workflow
547+
const workflow = createWorkflow({
548+
id: 'example-workflow',
549+
inputSchema: z.object({ data: z.string() }),
550+
outputSchema: z.object({ result: z.string() }),
551+
});
552+
553+
workflow.then(processStep);
554+
workflow.commit();
555+
556+
// Create the agent using the Agent wrapper
557+
const agent = new Agent({
558+
type: 'WorkflowDrivenAgent',
559+
name: 'Workflow Agent',
560+
workflow: workflow,
561+
});
562+
563+
// Use the agent in a team
564+
const team = new Team({
565+
name: 'Workflow Team',
566+
agents: [agent],
567+
tasks: [
568+
new Task({
569+
description: 'Process the input data using workflow',
570+
expectedOutput: 'Processed data result',
571+
agent: agent,
572+
}),
573+
],
574+
});
575+
```
576+
577+
_The `WorkflowDrivenAgent` integrates seamlessly with the existing team system, supports workflows with suspension for manual intervention, and provides detailed logging for workflow events. For more information, visit the [WorkflowDrivenAgent documentation](https://github.com/kaiban-ai/KaibanJS/tree/main/packages/workflow/src/examples/kaibanjs-integration-readme.md)._
578+
579+
</details>
580+
520581
## Documentation
521582

522583
- [Official Documentation](https://docs.kaibanjs.com/category/get-started)

jest.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ module.exports = {
1414
'^kaibanjs$': '<rootDir>/dist/bundle.cjs',
1515
},
1616
testTimeout: 300000, // Sets global timeout to 10 seconds for all tests
17+
noStackTrace: true,
1718
verbose: true, // Make Jest more verbose
1819
silent: false, // Ensure Jest is not silent (though this is not directly related to console.log output)
1920
// testMatch: ['**/tests/e2e/**/eventPlanningTeam.test.js'], // Run tests only in the specific directory

0 commit comments

Comments
 (0)