Skip to content

Commit 8174ee1

Browse files
committed
patch
1 parent d7c610e commit 8174ee1

35 files changed

Lines changed: 240 additions & 240 deletions

docs/design/01_Overview.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,23 +19,23 @@ The agent-swarm-kit follows a layered architecture centered around a dependency
1919

2020
### High-Level System Flow
2121

22-
![Mermaid Diagram](./diagrams\1_Overview_0.svg)
22+
![Mermaid Diagram](./diagrams/1_Overview_0.svg)
2323

2424
## Core Components
2525

2626
### Agent Execution Engine
2727

2828
The `ClientAgent` class serves as the core execution engine for individual agents, handling message processing, tool calls, and AI model interactions:
2929

30-
![Mermaid Diagram](./diagrams\1_Overview_2.svg)
30+
![Mermaid Diagram](./diagrams/1_Overview_2.svg)
3131

3232
The `ClientAgent` implements sophisticated execution patterns including tool call validation, model recovery strategies, and event-driven communication through subjects for handling agent state changes, tool outputs, and error conditions.
3333

3434
### Session Management
3535

3636
The session layer manages client connections and message flow through the swarm system:
3737

38-
![Mermaid Diagram](./diagrams\1_Overview_3.svg)
38+
![Mermaid Diagram](./diagrams/1_Overview_3.svg)
3939

4040
The `ClientSession` enforces policy validation for both input and output messages, coordinates with the swarm for agent execution, and provides event-driven messaging capabilities for real-time client communication.
4141

@@ -55,7 +55,7 @@ The swarm maintains a navigation stack that allows agents to call each other and
5555

5656
The system processes messages through a well-defined pipeline that ensures proper validation, execution, and output handling:
5757

58-
![Mermaid Diagram](./diagrams\1_Overview_4.svg)
58+
![Mermaid Diagram](./diagrams/1_Overview_4.svg)
5959

6060
This flow demonstrates the coordination between layers and the sophisticated tool execution pipeline that handles both simple completions and complex multi-tool workflows.
6161

docs/design/02_Getting_Started.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ The library provides a dependency injection-based architecture where agents, too
2323

2424
Agent-swarm-kit uses a layered service architecture built around a central dependency injection container. The system orchestrates multiple AI agents that can communicate, share tools, and maintain conversation history.
2525

26-
![Mermaid Diagram](./diagrams\2_Getting_Started_0.svg)
26+
![Mermaid Diagram](./diagrams/2_Getting_Started_0.svg)
2727

2828
## Core Concepts
2929

@@ -43,7 +43,7 @@ Sessions manage client connections, conversation history, and agent state for in
4343

4444
The typical workflow involves four steps: define components, assemble swarm, create session, and process messages.
4545

46-
![Mermaid Diagram](./diagrams\2_Getting_Started_1.svg)
46+
![Mermaid Diagram](./diagrams/2_Getting_Started_1.svg)
4747

4848
## Quick Start Example
4949

docs/design/03_Core_Components.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ The agent execution engine consists of two primary components: `ClientAgent` for
1515

1616
`ClientAgent` is the core execution engine that processes incoming messages, executes tool calls, and generates AI completions. It implements the `IAgent` interface and serves as the primary orchestrator for agent behavior.
1717

18-
![Mermaid Diagram](./diagrams\3_Core_Components_0.svg)
18+
![Mermaid Diagram](./diagrams/3_Core_Components_0.svg)
1919

2020
**Key responsibilities:**
2121
- **Message Execution**: Processes user and tool messages through `execute()` method
@@ -30,7 +30,7 @@ The `ClientAgent` uses a queued execution model to prevent overlapping operation
3030

3131
`ClientHistory` manages conversation history for agents, providing filtered message arrays optimized for AI completion contexts and maintaining message persistence.
3232

33-
![Mermaid Diagram](./diagrams\3_Core_Components_1.svg)
33+
![Mermaid Diagram](./diagrams/3_Core_Components_1.svg)
3434

3535
**Key features:**
3636
- **Message Filtering**: Applies agent-specific filters to scope relevant messages
@@ -47,7 +47,7 @@ The history system supports both raw message access and agent-optimized arrays t
4747

4848
`ClientSession` orchestrates communication between clients, agents, and swarms while enforcing policies and managing message flows. It implements the `ISession` interface and serves as the primary coordination layer.
4949

50-
![Mermaid Diagram](./diagrams\3_Core_Components_2.svg)
50+
![Mermaid Diagram](./diagrams/3_Core_Components_2.svg)
5151

5252
**Core capabilities:**
5353
- **Message Execution**: Coordinates agent execution with policy validation
@@ -66,7 +66,7 @@ The service infrastructure provides the foundation for component lifecycle manag
6666

6767
Connection services manage the instantiation and lifecycle of core components using memoization for efficient reuse.
6868

69-
![Mermaid Diagram](./diagrams\3_Core_Components_3.svg)
69+
![Mermaid Diagram](./diagrams/3_Core_Components_3.svg)
7070

7171
**Service responsibilities:**
7272
- **AgentConnectionService**: Creates and manages `ClientAgent` instances with tool and completion dependencies
@@ -80,7 +80,7 @@ Each connection service uses `memoize` from functools-kit to cache instances by
8080

8181
Public services provide the external API layer with context management and method scoping around connection services.
8282

83-
![Mermaid Diagram](./diagrams\3_Core_Components_4.svg)
83+
![Mermaid Diagram](./diagrams/3_Core_Components_4.svg)
8484

8585
**Public service features:**
8686
- **Context Scoping**: Wraps all operations with `MethodContextService.runInContext()` for proper context management
@@ -95,7 +95,7 @@ The public services layer provides a clean separation between external API and i
9595

9696
The core components work together through a well-defined integration pattern that ensures proper message flow, state management, and error handling.
9797

98-
![Mermaid Diagram](./diagrams\3_Core_Components_5.svg)
98+
![Mermaid Diagram](./diagrams/3_Core_Components_5.svg)
9999

100100
**Integration patterns:**
101101
- **Layered Delegation**: Public services delegate to connection services which manage component instances

docs/design/04_Client_Agent.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@ The `ClientAgent` implements the `IAgent` interface and serves as the primary ex
1515

1616
### ClientAgent Class Structure
1717

18-
![Mermaid Diagram](./diagrams\4_Client_Agent_0.svg)
18+
![Mermaid Diagram](./diagrams/4_Client_Agent_0.svg)
1919

2020
## Execution Lifecycle
2121

2222
The `ClientAgent` follows a structured execution lifecycle with queued processing to prevent overlapping executions. The system supports both stateful execution (via `execute`) and stateless completion (via `run`).
2323

2424
### Execution Flow Diagram
2525

26-
![Mermaid Diagram](./diagrams\4_Client_Agent_1.svg)
26+
![Mermaid Diagram](./diagrams/4_Client_Agent_1.svg)
2727

2828
### Queued Execution Pattern
2929

@@ -42,7 +42,7 @@ The `ClientAgent` handles tool execution through a sophisticated orchestration s
4242

4343
### Tool Resolution and Execution
4444

45-
![Mermaid Diagram](./diagrams\4_Client_Agent_2.svg)
45+
![Mermaid Diagram](./diagrams/4_Client_Agent_2.svg)
4646

4747
### Tool Abort Controller
4848

@@ -71,7 +71,7 @@ The `ClientAgent` integrates closely with the history system to maintain convers
7171

7272
### Message Flow and History Integration
7373

74-
![Mermaid Diagram](./diagrams\4_Client_Agent_3.svg)
74+
![Mermaid Diagram](./diagrams/4_Client_Agent_3.svg)
7575

7676
### History Filtering and Context Management
7777

@@ -88,7 +88,7 @@ The `ClientAgent` implements a robust error recovery system through the `_resurr
8888

8989
### Resurrection Strategies
9090

91-
![Mermaid Diagram](./diagrams\4_Client_Agent_4.svg)
91+
![Mermaid Diagram](./diagrams/4_Client_Agent_4.svg)
9292

9393
### Error Types and Handling
9494

@@ -107,7 +107,7 @@ The `ClientAgent` uses `Subject` instances from `functools-kit` for asynchronous
107107

108108
### Subject-Based Coordination System
109109

110-
![Mermaid Diagram](./diagrams\4_Client_Agent_5.svg)
110+
![Mermaid Diagram](./diagrams/4_Client_Agent_5.svg)
111111

112112
### Asynchronous Tool Execution
113113

@@ -132,7 +132,7 @@ The `ClientAgent` integrates with multiple services through dependency injection
132132

133133
### Service Dependencies
134134

135-
![Mermaid Diagram](./diagrams\4_Client_Agent_6.svg)
135+
![Mermaid Diagram](./diagrams/4_Client_Agent_6.svg)
136136

137137
### Lifecycle Management
138138

docs/design/05_Swarm_Management.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,27 +15,27 @@ A swarm is a collection of agents organized under a single orchestration unit th
1515

1616
### Swarm Component Structure
1717

18-
![Mermaid Diagram](./diagrams\5_Swarm_Management_0.svg)
18+
![Mermaid Diagram](./diagrams/5_Swarm_Management_0.svg)
1919

2020
### Swarm Schema and Configuration
2121

2222
Swarms are defined using the `ISwarmSchema` interface, which specifies the agent collection, default agent, and behavioral configuration:
2323

24-
![Mermaid Diagram](./diagrams\5_Swarm_Management_1.svg)
24+
![Mermaid Diagram](./diagrams/5_Swarm_Management_1.svg)
2525

2626
## Agent Navigation and Routing
2727

2828
The swarm manages navigation between agents through a navigation stack and active agent tracking. This allows for complex conversation flows where different agents handle different aspects of a conversation.
2929

3030
### Navigation Stack Management
3131

32-
![Mermaid Diagram](./diagrams\5_Swarm_Management_2.svg)
32+
![Mermaid Diagram](./diagrams/5_Swarm_Management_2.svg)
3333

3434
### Agent Resolution and Error Handling
3535

3636
The swarm uses a `NoopAgent` fallback mechanism when requested agents are not found in the swarm configuration:
3737

38-
![Mermaid Diagram](./diagrams\5_Swarm_Management_3.svg)
38+
![Mermaid Diagram](./diagrams/5_Swarm_Management_3.svg)
3939

4040
The `NoopAgent` class provides a safety mechanism that logs attempts to use non-existent agents while delegating operations to the default agent.
4141

@@ -45,46 +45,46 @@ The swarm maintains an active agent that handles incoming messages and executes
4545

4646
### Active Agent Resolution
4747

48-
![Mermaid Diagram](./diagrams\5_Swarm_Management_4.svg)
48+
![Mermaid Diagram](./diagrams/5_Swarm_Management_4.svg)
4949

5050
## Message Flow and Output Handling
5151

5252
Swarms coordinate message flow between agents and manage output emission to external consumers through a subject-based event system.
5353

5454
### Message Execution Flow
5555

56-
![Mermaid Diagram](./diagrams\5_Swarm_Management_5.svg)
56+
![Mermaid Diagram](./diagrams/5_Swarm_Management_5.svg)
5757

5858
### Output Subject Management
5959

6060
The `ClientSwarm` uses Subject patterns for asynchronous output handling and coordination:
6161

62-
![Mermaid Diagram](./diagrams\5_Swarm_Management_6.svg)
62+
![Mermaid Diagram](./diagrams/5_Swarm_Management_6.svg)
6363

6464
## Integration with Service Layer
6565

6666
Swarms integrate with the service architecture through connection services, validation services, and schema services to provide a complete orchestration platform.
6767

6868
### Service Layer Integration
6969

70-
![Mermaid Diagram](./diagrams\5_Swarm_Management_7.svg)
70+
![Mermaid Diagram](./diagrams/5_Swarm_Management_7.svg)
7171

7272
### Persistence and State Management
7373

7474
Swarms support persistence of navigation state and active agent information:
7575

76-
![Mermaid Diagram](./diagrams\5_Swarm_Management_8.svg)
76+
![Mermaid Diagram](./diagrams/5_Swarm_Management_8.svg)
7777

7878
## Configuration and Lifecycle
7979

8080
Swarms are configured through schema definitions and managed through service lifecycle patterns including initialization, memoization, and disposal.
8181

8282
### Swarm Lifecycle Management
8383

84-
![Mermaid Diagram](./diagrams\5_Swarm_Management_9.svg)
84+
![Mermaid Diagram](./diagrams/5_Swarm_Management_9.svg)
8585

8686
### Validation and Error Recovery
8787

8888
Swarms include validation mechanisms for agent availability and navigation consistency:
8989

90-
![Mermaid Diagram](./diagrams\5_Swarm_Management_10.svg)
90+
![Mermaid Diagram](./diagrams/5_Swarm_Management_10.svg)

docs/design/06_Session_and_Chat_Management.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,31 +13,31 @@ For information about individual agent execution within sessions, see [Client Ag
1313

1414
Chat management provides a high-level abstraction over sessions with automatic lifecycle management, inactivity detection, and cleanup. The `ChatUtils` class manages multiple `ChatInstance` objects, each wrapping a session with timeout handling and callback support.
1515

16-
![Mermaid Diagram](./diagrams\6_Session_and_Chat_Management_0.svg)
16+
![Mermaid Diagram](./diagrams/6_Session_and_Chat_Management_0.svg)
1717

1818
The chat layer handles client lifecycle automatically through `beginChat`, `sendMessage`, and `dispose` operations, with configurable callbacks for monitoring chat events and custom chat adapters.
1919

2020
## Chat Instance Lifecycle
2121

2222
Chat instances manage their lifecycle automatically with inactivity detection and cleanup. The `ChatInstance` class wraps sessions with timeout handling, callback support, and automatic disposal based on activity patterns.
2323

24-
![Mermaid Diagram](./diagrams\6_Session_and_Chat_Management_2.svg)
24+
![Mermaid Diagram](./diagrams/6_Session_and_Chat_Management_2.svg)
2525

2626
The lifecycle includes automatic cleanup through `INACTIVITY_CHECK` (60 seconds) and `INACTIVITY_TIMEOUT` (15 minutes) constants, with callback hooks for monitoring chat state changes.
2727

2828
## Session Lifecycle
2929

3030
Sessions follow a managed lifecycle from creation through disposal, with automatic resource tracking and cleanup. The `SessionConnectionService` uses memoization to cache session instances, while validation services track active sessions for proper resource management.
3131

32-
![Mermaid Diagram](./diagrams\6_Session_and_Chat_Management_3.svg)
32+
![Mermaid Diagram](./diagrams/6_Session_and_Chat_Management_3.svg)
3333

3434
The lifecycle includes initialization callbacks, active message processing, and disposal with proper cleanup. Session validation services ensure that resources are properly tracked and prevent memory leaks in long-running applications.
3535

3636
## Message Processing Flow
3737

3838
Sessions handle bidirectional message flow with policy validation, agent execution, and event emission. The `emit` method sends messages to clients via swarms, while `execute` processes incoming messages through agents and returns responses.
3939

40-
![Mermaid Diagram](./diagrams\6_Session_and_Chat_Management_4.svg)
40+
![Mermaid Diagram](./diagrams/6_Session_and_Chat_Management_4.svg)
4141

4242
All message flows include policy validation checkpoints. When validation fails, sessions automatically substitute ban messages and log policy violations through the event system.
4343

@@ -89,7 +89,7 @@ The session schema extends `ISwarmSessionCallbacks` to provide lifecycle hooks f
8989

9090
Sessions coordinate agent execution through swarms, managing the handoff between session-level message processing and agent-level tool execution. The `execute` method delegates to swarm agents while maintaining session context and policy enforcement.
9191

92-
![Mermaid Diagram](./diagrams\6_Session_and_Chat_Management_5.svg)
92+
![Mermaid Diagram](./diagrams/6_Session_and_Chat_Management_5.svg)
9393

9494
Sessions maintain execution context across agent transitions, ensuring proper client identification and session state preservation during complex multi-agent workflows.
9595

@@ -117,6 +117,6 @@ Event types include `"emit"`, `"execute"`, `"connect"`, and `"dispose"` with ses
117117

118118
Sessions implement comprehensive resource management with automatic cleanup, validation tracking, and memoization clearing. The disposal process ensures proper resource release and prevents memory leaks in long-running applications.
119119

120-
![Mermaid Diagram](./diagrams\6_Session_and_Chat_Management_6.svg)
120+
![Mermaid Diagram](./diagrams/6_Session_and_Chat_Management_6.svg)
121121

122122
The disposal process includes validation service cleanup, callback execution, and memoization clearing to ensure complete resource release. Sessions automatically handle cleanup of associated agents, histories, and event subscriptions.

docs/design/07_Model_Context_Protocol_MCP.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ The MCP system follows a layered architecture that separates tool definition, co
1515

1616
### MCP System Architecture
1717

18-
![Mermaid Diagram](./diagrams\7_Model_Context_Protocol_MCP_0.svg)
18+
![Mermaid Diagram](./diagrams/7_Model_Context_Protocol_MCP_0.svg)
1919

2020
## Core Components
2121

@@ -71,7 +71,7 @@ The `ClientMCP` class provides the primary implementation of the MCP protocol wi
7171

7272
### MCP Implementation Flow
7373

74-
![Mermaid Diagram](./diagrams\7_Model_Context_Protocol_MCP_1.svg)
74+
![Mermaid Diagram](./diagrams/7_Model_Context_Protocol_MCP_1.svg)
7575

7676
The `ClientMCP` constructor initializes the MCP with parameters and triggers the `onInit` callback. Tools are fetched and cached using a memoized function keyed by client ID.
7777

@@ -118,7 +118,7 @@ The `MCPPublicService` provides a context-aware public API that wraps MCP operat
118118

119119
### Tool Call Processing
120120

121-
![Mermaid Diagram](./diagrams\7_Model_Context_Protocol_MCP_2.svg)
121+
![Mermaid Diagram](./diagrams/7_Model_Context_Protocol_MCP_2.svg)
122122

123123
When a tool returns a string output, it's automatically committed to the agent using `commitToolOutput`. If the tool call is marked as the last in a sequence (`dto.isLast`), the agent execution continues. Error handling stops tool execution and flushes the agent buffer.
124124

0 commit comments

Comments
 (0)