feat: Add complete Agentic Compaction & Pipeline System
- Context Compaction System with token counting and summarization - Deterministic State Machine for flow control (no LLM decisions) - Parallel Execution Engine (up to 12 concurrent sessions) - Event-Driven Coordination via Event Bus - Agent Workspace Isolation (tools, memory, identity, files) - YAML Workflow Integration (OpenClaw/Lobster compatible) - Claude Code integration layer - Complete demo UI with real-time visualization - Comprehensive documentation and README Components: - agent-system/: Context management, token counting, subagent spawning - pipeline-system/: State machine, parallel executor, event bus, workflows - skills/: AI capabilities (LLM, ASR, TTS, VLM, image generation, etc.) - src/app/: Next.js demo application Total: ~100KB of production-ready TypeScript code
This commit is contained in:
206
pipeline-system/index.ts
Normal file
206
pipeline-system/index.ts
Normal file
@@ -0,0 +1,206 @@
|
||||
/**
|
||||
* Deterministic Multi-Agent Pipeline System
|
||||
*
|
||||
* A comprehensive system for building deterministic, parallel, event-driven
|
||||
* multi-agent pipelines that integrate with Claude Code and OpenClaw.
|
||||
*
|
||||
* Key Features:
|
||||
* - Deterministic orchestration (state machine, not LLM decision)
|
||||
* - Parallel execution (up to 12 concurrent agent sessions)
|
||||
* - Event-driven coordination (agents finish → next triggers)
|
||||
* - Full agent capabilities (tools, memory, identity, workspace)
|
||||
*
|
||||
* @module pipeline-system
|
||||
*/
|
||||
|
||||
// Core
|
||||
export {
|
||||
DeterministicStateMachine,
|
||||
StateMachineRegistry,
|
||||
stateMachineRegistry
|
||||
} from './core/state-machine';
|
||||
export type {
|
||||
State,
|
||||
StateStatus,
|
||||
Transition,
|
||||
Condition,
|
||||
RetryConfig,
|
||||
StateMachineDefinition,
|
||||
StateMachineInstance,
|
||||
StateTransition,
|
||||
Event,
|
||||
ErrorHandling
|
||||
} from './core/state-machine';
|
||||
|
||||
// Engine
|
||||
export {
|
||||
ParallelExecutionEngine,
|
||||
defaultExecutor
|
||||
} from './engine/parallel-executor';
|
||||
export type {
|
||||
AgentRole,
|
||||
TaskStatus,
|
||||
WorkerStatus,
|
||||
AgentSession,
|
||||
AgentIdentity,
|
||||
PipelineTask,
|
||||
Worker,
|
||||
ExecutionConfig,
|
||||
ExecutionResult
|
||||
} from './engine/parallel-executor';
|
||||
|
||||
// Events
|
||||
export {
|
||||
EventBus,
|
||||
EventChain,
|
||||
PipelineEventTypes,
|
||||
defaultEventBus
|
||||
} from './events/event-bus';
|
||||
export type {
|
||||
PipelineEvent,
|
||||
EventHandler,
|
||||
EventFilter,
|
||||
Subscription,
|
||||
EventBusConfig,
|
||||
EventBusStats,
|
||||
EventPriority
|
||||
} from './events/event-bus';
|
||||
|
||||
// Workspace
|
||||
export {
|
||||
WorkspaceManager,
|
||||
WorkspaceFactory,
|
||||
defaultWorkspaceFactory
|
||||
} from './workspace/agent-workspace';
|
||||
export type {
|
||||
Permission,
|
||||
WorkspaceConfig,
|
||||
ResourceLimits,
|
||||
MountPoint,
|
||||
AgentTool,
|
||||
ToolContext,
|
||||
ToolResult,
|
||||
MemoryStore
|
||||
} from './workspace/agent-workspace';
|
||||
|
||||
// Workflows
|
||||
export {
|
||||
WorkflowParser,
|
||||
WorkflowRegistry,
|
||||
CODE_PIPELINE_WORKFLOW,
|
||||
PARALLEL_PROJECTS_WORKFLOW,
|
||||
HUMAN_APPROVAL_WORKFLOW,
|
||||
defaultWorkflowRegistry
|
||||
} from './workflows/yaml-workflow';
|
||||
export type {
|
||||
YAMLWorkflow,
|
||||
YAMLState,
|
||||
YAMLTransition,
|
||||
YAMLCondition,
|
||||
YAMLRetryConfig,
|
||||
YAMLLoopConfig
|
||||
} from './workflows/yaml-workflow';
|
||||
|
||||
// Integrations
|
||||
export {
|
||||
PipelineOrchestrator,
|
||||
createCodePipeline,
|
||||
createParallelPipeline,
|
||||
runWorkflow,
|
||||
defaultOrchestrator
|
||||
} from './integrations/claude-code';
|
||||
export type {
|
||||
PipelineConfig,
|
||||
ProjectConfig,
|
||||
TaskConfig,
|
||||
PipelineResult,
|
||||
ProjectResult,
|
||||
TaskResult,
|
||||
AgentMessage
|
||||
} from './integrations/claude-code';
|
||||
|
||||
// Version
|
||||
export const VERSION = '1.0.0';
|
||||
|
||||
/**
|
||||
* Quick Start Example:
|
||||
*
|
||||
* ```typescript
|
||||
* import {
|
||||
* PipelineOrchestrator,
|
||||
* createCodePipeline,
|
||||
* runWorkflow
|
||||
* } from './pipeline-system';
|
||||
*
|
||||
* // Option 1: Simple code pipeline
|
||||
* const pipelineId = await createCodePipeline([
|
||||
* {
|
||||
* id: 'project-1',
|
||||
* name: 'My Project',
|
||||
* tasks: [
|
||||
* { type: 'implement', description: 'Create auth module', role: 'programmer' },
|
||||
* { type: 'review', description: 'Review auth module', role: 'reviewer' },
|
||||
* { type: 'test', description: 'Test auth module', role: 'tester' }
|
||||
* ]
|
||||
* }
|
||||
* ]);
|
||||
*
|
||||
* // Option 2: Run predefined workflow
|
||||
* const workflowId = await runWorkflow('code-pipeline', {
|
||||
* projectId: 'my-project',
|
||||
* requirements: 'Build REST API'
|
||||
* });
|
||||
*
|
||||
* // Option 3: Custom configuration
|
||||
* const orchestrator = new PipelineOrchestrator();
|
||||
* await orchestrator.initialize();
|
||||
*
|
||||
* const customPipelineId = await orchestrator.createPipeline({
|
||||
* name: 'Custom Pipeline',
|
||||
* projects: [...],
|
||||
* roles: ['programmer', 'reviewer', 'tester'],
|
||||
* maxConcurrency: 12
|
||||
* });
|
||||
*
|
||||
* // Subscribe to events
|
||||
* orchestrator.onEvent('agent.completed', (event) => {
|
||||
* console.log('Agent completed:', event.payload);
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* ## Architecture
|
||||
*
|
||||
* ```
|
||||
* ┌─────────────────────────────────────────────────────────────────┐
|
||||
* │ Pipeline Orchestrator │
|
||||
* │ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │
|
||||
* │ │ State Machine│ │Event Bus │ │ Parallel Exec│ │
|
||||
* │ │ (Deterministic│ │(Coordination)│ │ (Concurrency)│ │
|
||||
* │ └──────────────┘ └──────────────┘ └──────────────┘ │
|
||||
* │ │ │ │ │
|
||||
* │ ┌──────┴────────────────┴─────────────────┴──────┐ │
|
||||
* │ │ Agent Workspaces │ │
|
||||
* │ │ ┌─────────┐ ┌─────────┐ ┌─────────┐ │ │
|
||||
* │ │ │Programmer│ │Reviewer │ │ Tester │ │ │
|
||||
* │ │ │Workspace │ │Workspace│ │Workspace│ │ │
|
||||
* │ │ │ • Tools │ │ • Tools │ │ • Tools │ │ │
|
||||
* │ │ │ • Memory │ │ • Memory│ │ • Memory│ │ │
|
||||
* │ │ │ • Files │ │ • Files │ │ • Files │ │ │
|
||||
* │ │ └─────────┘ └─────────┘ └─────────┘ │ │
|
||||
* │ └────────────────────────────────────────────────┘ │
|
||||
* └─────────────────────────────────────────────────────────────────┘
|
||||
* │
|
||||
* ▼
|
||||
* ┌─────────────────────────────────────────────────────────────────┐
|
||||
* │ LLM Provider (ZAI SDK) │
|
||||
* └─────────────────────────────────────────────────────────────────┘
|
||||
* ```
|
||||
*
|
||||
* ## Key Principles
|
||||
*
|
||||
* 1. **Deterministic Flow**: State machines control the pipeline, not LLM decisions
|
||||
* 2. **Event-Driven**: Agents communicate through events, enabling loose coupling
|
||||
* 3. **Parallel Execution**: Multiple agents work concurrently with resource isolation
|
||||
* 4. **Workspace Isolation**: Each agent has its own tools, memory, and file space
|
||||
* 5. **YAML Workflows**: Define pipelines declaratively, compatible with Lobster
|
||||
*/
|
||||
Reference in New Issue
Block a user