societyai 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +111 -0
- package/LICENSE +21 -0
- package/README.md +879 -0
- package/dist/builder.d.ts +181 -0
- package/dist/builder.d.ts.map +1 -0
- package/dist/builder.js +667 -0
- package/dist/builder.js.map +1 -0
- package/dist/config.d.ts +43 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +11 -0
- package/dist/config.js.map +1 -0
- package/dist/context.d.ts +107 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/context.js +319 -0
- package/dist/context.js.map +1 -0
- package/dist/errors.d.ts +31 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +85 -0
- package/dist/errors.js.map +1 -0
- package/dist/events.d.ts +219 -0
- package/dist/events.d.ts.map +1 -0
- package/dist/events.js +395 -0
- package/dist/events.js.map +1 -0
- package/dist/graph.d.ts +104 -0
- package/dist/graph.d.ts.map +1 -0
- package/dist/graph.js +366 -0
- package/dist/graph.js.map +1 -0
- package/dist/index.d.ts +28 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +113 -0
- package/dist/index.js.map +1 -0
- package/dist/logger.d.ts +13 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/logger.js +78 -0
- package/dist/logger.js.map +1 -0
- package/dist/memory.d.ts +146 -0
- package/dist/memory.d.ts.map +1 -0
- package/dist/memory.js +353 -0
- package/dist/memory.js.map +1 -0
- package/dist/metrics.d.ts +143 -0
- package/dist/metrics.d.ts.map +1 -0
- package/dist/metrics.js +271 -0
- package/dist/metrics.js.map +1 -0
- package/dist/middleware.d.ts +147 -0
- package/dist/middleware.d.ts.map +1 -0
- package/dist/middleware.js +484 -0
- package/dist/middleware.js.map +1 -0
- package/dist/models.d.ts +32 -0
- package/dist/models.d.ts.map +1 -0
- package/dist/models.js +211 -0
- package/dist/models.js.map +1 -0
- package/dist/patterns.d.ts +6 -0
- package/dist/patterns.d.ts.map +1 -0
- package/dist/patterns.js +68 -0
- package/dist/patterns.js.map +1 -0
- package/dist/pipeline.d.ts +84 -0
- package/dist/pipeline.d.ts.map +1 -0
- package/dist/pipeline.js +569 -0
- package/dist/pipeline.js.map +1 -0
- package/dist/retry.d.ts +5 -0
- package/dist/retry.d.ts.map +1 -0
- package/dist/retry.js +70 -0
- package/dist/retry.js.map +1 -0
- package/dist/society.d.ts +94 -0
- package/dist/society.d.ts.map +1 -0
- package/dist/society.js +721 -0
- package/dist/society.js.map +1 -0
- package/dist/strategies.d.ts +55 -0
- package/dist/strategies.d.ts.map +1 -0
- package/dist/strategies.js +678 -0
- package/dist/strategies.js.map +1 -0
- package/dist/tools.d.ts +88 -0
- package/dist/tools.d.ts.map +1 -0
- package/dist/tools.js +366 -0
- package/dist/tools.js.map +1 -0
- package/dist/types.d.ts +213 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +19 -0
- package/dist/types.js.map +1 -0
- package/dist/validation.d.ts +64 -0
- package/dist/validation.d.ts.map +1 -0
- package/dist/validation.js +334 -0
- package/dist/validation.js.map +1 -0
- package/dist/worker-pool.d.ts +17 -0
- package/dist/worker-pool.d.ts.map +1 -0
- package/dist/worker-pool.js +80 -0
- package/dist/worker-pool.js.map +1 -0
- package/docs/README.md +468 -0
- package/docs/advanced.md +616 -0
- package/docs/aggregation-strategies.md +926 -0
- package/docs/api-reference.md +771 -0
- package/docs/architecture.md +648 -0
- package/docs/context-system.md +642 -0
- package/docs/event-system.md +1047 -0
- package/docs/examples.md +576 -0
- package/docs/getting-started.md +564 -0
- package/docs/graph-execution.md +389 -0
- package/docs/memory-system.md +497 -0
- package/docs/metrics-observability.md +560 -0
- package/docs/middleware-system.md +1038 -0
- package/docs/migration.md +296 -0
- package/docs/pipeline-patterns.md +761 -0
- package/docs/structured-output.md +612 -0
- package/docs/tool-calling.md +491 -0
- package/docs/workflows.md +740 -0
- package/examples/README.md +234 -0
- package/examples/advanced-patterns.ts +115 -0
- package/examples/complete-integration.ts +327 -0
- package/examples/graph-workflow.ts +161 -0
- package/examples/memory-system.ts +155 -0
- package/examples/metrics-tracking.ts +243 -0
- package/examples/structured-output.ts +231 -0
- package/examples/tool-calling.ts +163 -0
- package/package.json +94 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export declare class WorkerPool {
|
|
2
|
+
private maxWorkers;
|
|
3
|
+
private running;
|
|
4
|
+
private queue;
|
|
5
|
+
private stopped;
|
|
6
|
+
private signal?;
|
|
7
|
+
constructor(maxWorkers?: number, signal?: AbortSignal);
|
|
8
|
+
submit<T>(fn: () => Promise<T>): Promise<T>;
|
|
9
|
+
private processNext;
|
|
10
|
+
waitAll(): Promise<void>;
|
|
11
|
+
stop(): void;
|
|
12
|
+
get stats(): {
|
|
13
|
+
running: number;
|
|
14
|
+
queued: number;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=worker-pool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"worker-pool.d.ts","sourceRoot":"","sources":["../src/worker-pool.ts"],"names":[],"mappings":"AAMA,qBAAa,UAAU;IACrB,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,OAAO,CAAK;IACpB,OAAO,CAAC,KAAK,CAA4B;IACzC,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,MAAM,CAAC,CAAc;gBAEjB,UAAU,SAAI,EAAE,MAAM,CAAC,EAAE,WAAW;IAe1C,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;IAqCjD,OAAO,CAAC,WAAW;IAqBb,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAa9B,IAAI,IAAI,IAAI;IAQZ,IAAI,KAAK,IAAI;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAK/C;CACF"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WorkerPool = void 0;
|
|
4
|
+
class WorkerPool {
|
|
5
|
+
constructor(maxWorkers = 5, signal) {
|
|
6
|
+
this.running = 0;
|
|
7
|
+
this.queue = [];
|
|
8
|
+
this.stopped = false;
|
|
9
|
+
this.maxWorkers = maxWorkers > 0 ? maxWorkers : 5;
|
|
10
|
+
this.signal = signal;
|
|
11
|
+
if (this.signal) {
|
|
12
|
+
this.signal.addEventListener('abort', () => {
|
|
13
|
+
this.stop();
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
async submit(fn) {
|
|
18
|
+
if (this.stopped) {
|
|
19
|
+
throw new Error('Worker pool has been stopped');
|
|
20
|
+
}
|
|
21
|
+
if (this.signal?.aborted) {
|
|
22
|
+
throw new Error('Operation cancelled');
|
|
23
|
+
}
|
|
24
|
+
return new Promise((resolve, reject) => {
|
|
25
|
+
const wrappedFn = async () => {
|
|
26
|
+
try {
|
|
27
|
+
const result = await fn();
|
|
28
|
+
resolve(result);
|
|
29
|
+
return result;
|
|
30
|
+
}
|
|
31
|
+
catch (error) {
|
|
32
|
+
reject(error);
|
|
33
|
+
throw error;
|
|
34
|
+
}
|
|
35
|
+
finally {
|
|
36
|
+
this.running--;
|
|
37
|
+
this.processNext();
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
const task = {
|
|
41
|
+
fn: wrappedFn,
|
|
42
|
+
};
|
|
43
|
+
this.queue.push(task);
|
|
44
|
+
this.processNext();
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
processNext() {
|
|
48
|
+
if (this.stopped || this.signal?.aborted) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
while (this.running < this.maxWorkers && this.queue.length > 0) {
|
|
52
|
+
const task = this.queue.shift();
|
|
53
|
+
if (task) {
|
|
54
|
+
this.running++;
|
|
55
|
+
void task.fn().catch(() => {
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
async waitAll() {
|
|
61
|
+
while (this.running > 0 || this.queue.length > 0) {
|
|
62
|
+
await new Promise((resolve) => setTimeout(resolve, 10));
|
|
63
|
+
if (this.signal?.aborted) {
|
|
64
|
+
throw new Error('Operation cancelled');
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
stop() {
|
|
69
|
+
this.stopped = true;
|
|
70
|
+
this.queue = [];
|
|
71
|
+
}
|
|
72
|
+
get stats() {
|
|
73
|
+
return {
|
|
74
|
+
running: this.running,
|
|
75
|
+
queued: this.queue.length,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
exports.WorkerPool = WorkerPool;
|
|
80
|
+
//# sourceMappingURL=worker-pool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"worker-pool.js","sourceRoot":"","sources":["../src/worker-pool.ts"],"names":[],"mappings":"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"}
|
package/docs/README.md
ADDED
|
@@ -0,0 +1,468 @@
|
|
|
1
|
+
# SocietyAI Documentation
|
|
2
|
+
|
|
3
|
+
Complete documentation for the SocietyAI library - a powerful TypeScript framework for building collaborative multi-agent AI systems.
|
|
4
|
+
|
|
5
|
+
## 📚 Documentation Guide
|
|
6
|
+
|
|
7
|
+
### For Beginners
|
|
8
|
+
|
|
9
|
+
Start here if you're new to SocietyAI:
|
|
10
|
+
|
|
11
|
+
1. **[Getting Started](./getting-started.md)** - Installation, setup, and your first workflow
|
|
12
|
+
2. **[Architecture Overview](./architecture.md)** - Core concepts and design principles
|
|
13
|
+
3. **[Examples Index](./examples.md)** - Browse all code examples
|
|
14
|
+
|
|
15
|
+
### Core Features
|
|
16
|
+
|
|
17
|
+
Build your own multi-agent systems:
|
|
18
|
+
|
|
19
|
+
4. **[Workflows](./workflows.md)** - Sequential, parallel, collaborative, and conditional patterns
|
|
20
|
+
5. **[Graph Execution](./graph-execution.md)** - DAG/Cyclic workflows with complex logic and loops
|
|
21
|
+
6. **[Pipeline Patterns](./pipeline-patterns.md)** - Chain, scatter-gather, router, splitter, saga patterns
|
|
22
|
+
7. **[Aggregation Strategies](./aggregation-strategies.md)** - Consensus, voting, weighted, best-of, custom strategies
|
|
23
|
+
|
|
24
|
+
### Data & State Management
|
|
25
|
+
|
|
26
|
+
Manage data flow and state:
|
|
27
|
+
|
|
28
|
+
8. **[Tool Calling](./tool-calling.md)** - External tools and APIs integration
|
|
29
|
+
9. **[Memory System](./memory-system.md)** - Multi-level context management
|
|
30
|
+
10. **[Context System](./context-system.md)** - Type-safe state sharing with tokens and providers
|
|
31
|
+
11. **[Structured Output](./structured-output.md)** - JSON Schema validation with automatic retry
|
|
32
|
+
|
|
33
|
+
### Observability & Performance
|
|
34
|
+
|
|
35
|
+
Monitor and optimize:
|
|
36
|
+
|
|
37
|
+
12. **[Event System](./event-system.md)** - Lifecycle events, progress tracking, debugging
|
|
38
|
+
13. **[Metrics & Observability](./metrics-observability.md)** - Token counting, cost estimation, profiling
|
|
39
|
+
14. **[Middleware System](./middleware-system.md)** - Logging, caching, retry, circuit breaker, rate limiting
|
|
40
|
+
|
|
41
|
+
### Reference & Advanced
|
|
42
|
+
|
|
43
|
+
Complete documentation:
|
|
44
|
+
|
|
45
|
+
15. **[API Reference](./api-reference.md)** - Complete API documentation
|
|
46
|
+
16. **[Advanced Features](./advanced.md)** - Error handling, timeout, cancellation, performance
|
|
47
|
+
17. **[Migration Guide](./migration.md)** - Upgrading from legacy API
|
|
48
|
+
|
|
49
|
+
## 🚀 Quick Links
|
|
50
|
+
|
|
51
|
+
| Topic | Document | Description |
|
|
52
|
+
| ---------------------- | ---------------------------------------------------------- | -------------------------------------------- |
|
|
53
|
+
| **Installation** | [Getting Started](./getting-started.md#installation) | How to install SocietyAI |
|
|
54
|
+
| **First Workflow** | [Getting Started](./getting-started.md#your-first-society) | Create your first multi-agent system |
|
|
55
|
+
| **Core Concepts** | [Architecture](./architecture.md#core-components) | Understanding roles, agents, workflows |
|
|
56
|
+
| **Execution Types** | [Workflows](./workflows.md#execution-types) | Sequential, parallel, collaborative patterns |
|
|
57
|
+
| **Graph Workflows** | [Graph Execution](./graph-execution.md) | Complex DAG/Cyclic workflows |
|
|
58
|
+
| **Pipeline Patterns** | [Pipeline Patterns](./pipeline-patterns.md) | Pre-built execution patterns |
|
|
59
|
+
| **Aggregation** | [Aggregation Strategies](./aggregation-strategies.md) | Combining multiple agent results |
|
|
60
|
+
| **Tool Integration** | [Tool Calling](./tool-calling.md) | External tools and APIs |
|
|
61
|
+
| **Context Management** | [Memory System](./memory-system.md) | Multi-level memory for agents |
|
|
62
|
+
| **State Sharing** | [Context System](./context-system.md) | Type-safe dependency injection |
|
|
63
|
+
| **Output Validation** | [Structured Output](./structured-output.md) | JSON Schema validation |
|
|
64
|
+
| **Event Monitoring** | [Event System](./event-system.md) | Lifecycle and progress events |
|
|
65
|
+
| **Metrics Tracking** | [Metrics & Observability](./metrics-observability.md) | Performance and cost monitoring |
|
|
66
|
+
| **Middleware** | [Middleware System](./middleware-system.md) | Cross-cutting concerns |
|
|
67
|
+
| **Error Handling** | [Advanced](./advanced.md#error-handling) | Robust error handling strategies |
|
|
68
|
+
| **API Reference** | [API Reference](./api-reference.md) | Complete API documentation |
|
|
69
|
+
| **Code Examples** | [Examples](./examples.md) | Browse all example code |
|
|
70
|
+
|
|
71
|
+
## 📖 Documentation Structure
|
|
72
|
+
|
|
73
|
+
```
|
|
74
|
+
docs/
|
|
75
|
+
├── README.md # This file - Documentation index
|
|
76
|
+
├── getting-started.md # Installation and basics
|
|
77
|
+
├── architecture.md # Core concepts and design
|
|
78
|
+
├── workflows.md # Workflow patterns
|
|
79
|
+
├── graph-execution.md # Graph-based workflows
|
|
80
|
+
├── pipeline-patterns.md # Pipeline patterns (NEW)
|
|
81
|
+
├── aggregation-strategies.md # Result aggregation (NEW)
|
|
82
|
+
├── tool-calling.md # Tool integration
|
|
83
|
+
├── memory-system.md # Multi-level memory
|
|
84
|
+
├── context-system.md # Context & state (NEW)
|
|
85
|
+
├── structured-output.md # Output validation
|
|
86
|
+
├── event-system.md # Event system (NEW)
|
|
87
|
+
├── metrics-observability.md # Metrics & tracking
|
|
88
|
+
├── middleware-system.md # Middleware (NEW)
|
|
89
|
+
├── api-reference.md # Complete API documentation
|
|
90
|
+
├── advanced.md # Advanced features
|
|
91
|
+
├── migration.md # Migration from legacy API
|
|
92
|
+
└── examples.md # Examples index
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
├── migration.md # Migration from legacy API
|
|
96
|
+
└── examples.md # Examples index
|
|
97
|
+
|
|
98
|
+
````
|
|
99
|
+
|
|
100
|
+
## 🎯 Learn by Use Case
|
|
101
|
+
|
|
102
|
+
### I want to...
|
|
103
|
+
|
|
104
|
+
**Create a simple multi-agent system**
|
|
105
|
+
→ [Getting Started](./getting-started.md) → [Simple Example](./getting-started.md#your-first-society)
|
|
106
|
+
|
|
107
|
+
**Build complex workflows with conditional logic**
|
|
108
|
+
→ [Graph Execution](./graph-execution.md) → [Conditional Branching](./graph-execution.md#conditional-branching)
|
|
109
|
+
|
|
110
|
+
**Run agents in parallel and aggregate results**
|
|
111
|
+
→ [Pipeline Patterns](./pipeline-patterns.md) → [Scatter-Gather Pattern](./pipeline-patterns.md#scatter-gather-pattern)
|
|
112
|
+
|
|
113
|
+
**Use pre-built orchestration patterns**
|
|
114
|
+
→ [Pipeline Patterns](./pipeline-patterns.md) → [Built-in Pipelines](./pipeline-patterns.md#built-in-pipelines)
|
|
115
|
+
|
|
116
|
+
**Combine multiple agent results intelligently**
|
|
117
|
+
→ [Aggregation Strategies](./aggregation-strategies.md) → [Voting & Consensus](./aggregation-strategies.md#voting-strategy)
|
|
118
|
+
|
|
119
|
+
**Give agents access to tools and APIs**
|
|
120
|
+
→ [Tool Calling](./tool-calling.md) → [Tool Integration](./tool-calling.md#integration-with-agents)
|
|
121
|
+
|
|
122
|
+
**Manage conversation context and memory**
|
|
123
|
+
→ [Memory System](./memory-system.md) → [Memory Management](./memory-system.md#complete-memory-system)
|
|
124
|
+
|
|
125
|
+
**Share state between agents type-safely**
|
|
126
|
+
→ [Context System](./context-system.md) → [Context Providers](./context-system.md#context-provider)
|
|
127
|
+
|
|
128
|
+
**Validate AI-generated JSON automatically**
|
|
129
|
+
→ [Structured Output](./structured-output.md) → [JSON Schema Validation](./structured-output.md#automatic-retry-with-error-feedback)
|
|
130
|
+
|
|
131
|
+
**Monitor workflow execution in real-time**
|
|
132
|
+
→ [Event System](./event-system.md) → [Progress Tracking](./event-system.md#progress-tracking)
|
|
133
|
+
|
|
134
|
+
**Track costs and performance metrics**
|
|
135
|
+
→ [Metrics & Observability](./metrics-observability.md) → [Cost Tracking](./metrics-observability.md#cost-comparison)
|
|
136
|
+
|
|
137
|
+
**Add logging, caching, or retry logic**
|
|
138
|
+
→ [Middleware System](./middleware-system.md) → [Built-in Middlewares](./middleware-system.md#built-in-middlewares)
|
|
139
|
+
|
|
140
|
+
**Have agents debate and reach consensus**
|
|
141
|
+
→ [Pipeline Patterns](./pipeline-patterns.md) → [Debate Pattern](./pipeline-patterns.md#multi-perspective-debate-pattern)
|
|
142
|
+
|
|
143
|
+
**Implement self-correcting agents**
|
|
144
|
+
→ [Pipeline Patterns](./pipeline-patterns.md) → [Self-Correction Pattern](./pipeline-patterns.md#self-correction-pattern)
|
|
145
|
+
|
|
146
|
+
## 🔧 Feature Matrix
|
|
147
|
+
|
|
148
|
+
| Feature | Document | Status |
|
|
149
|
+
|---------|----------|--------|
|
|
150
|
+
| **Fluent Builder API** | [Getting Started](./getting-started.md) | ✅ Stable |
|
|
151
|
+
| **Sequential Workflows** | [Workflows](./workflows.md) | ✅ Stable |
|
|
152
|
+
| **Parallel Execution** | [Workflows](./workflows.md) | ✅ Stable |
|
|
153
|
+
| **Collaborative Agents** | [Workflows](./workflows.md) | ✅ Stable |
|
|
154
|
+
| **Graph-based Workflows** | [Graph Execution](./graph-execution.md) | ✅ Stable |
|
|
155
|
+
| **Pipeline Patterns** | [Pipeline Patterns](./pipeline-patterns.md) | ✅ Stable |
|
|
156
|
+
| **Aggregation Strategies** | [Aggregation Strategies](./aggregation-strategies.md) | ✅ Stable |
|
|
157
|
+
| **Tool Calling** | [Tool Calling](./tool-calling.md) | ✅ Stable |
|
|
158
|
+
| **Memory System** | [Memory System](./memory-system.md) | ✅ Stable |
|
|
159
|
+
| **Context System** | [Context System](./context-system.md) | ✅ Stable |
|
|
160
|
+
| **Structured Output** | [Structured Output](./structured-output.md) | ✅ Stable |
|
|
161
|
+
| **Event System** | [Event System](./event-system.md) | ✅ Stable |
|
|
162
|
+
| **Metrics Tracking** | [Metrics & Observability](./metrics-observability.md) | ✅ Stable |
|
|
163
|
+
| **Middleware System** | [Middleware System](./middleware-system.md) | ✅ Stable |
|
|
164
|
+
| **Error Handling** | [Advanced](./advanced.md) | ✅ Stable |
|
|
165
|
+
| **Retry Mechanisms** | [Advanced](./advanced.md) | ✅ Stable |
|
|
166
|
+
|
|
167
|
+
## 📚 By Skill Level
|
|
168
|
+
|
|
169
|
+
### Beginner
|
|
170
|
+
- [Getting Started](./getting-started.md) - Setup and first workflow
|
|
171
|
+
- [Architecture](./architecture.md) - Core concepts
|
|
172
|
+
- [Workflows](./workflows.md) - Basic patterns
|
|
173
|
+
- [Examples](./examples.md) - Code examples
|
|
174
|
+
|
|
175
|
+
### Intermediate
|
|
176
|
+
- [Graph Execution](./graph-execution.md) - Complex workflows
|
|
177
|
+
- [Pipeline Patterns](./pipeline-patterns.md) - Pre-built patterns
|
|
178
|
+
- [Aggregation Strategies](./aggregation-strategies.md) - Result combination
|
|
179
|
+
- [Tool Calling](./tool-calling.md) - External integrations
|
|
180
|
+
- [Memory System](./memory-system.md) - Context management
|
|
181
|
+
|
|
182
|
+
### Advanced
|
|
183
|
+
- [Context System](./context-system.md) - Dependency injection
|
|
184
|
+
- [Event System](./event-system.md) - Event-driven architecture
|
|
185
|
+
- [Middleware System](./middleware-system.md) - Cross-cutting concerns
|
|
186
|
+
- [Metrics & Observability](./metrics-observability.md) - Production monitoring
|
|
187
|
+
- [Advanced Features](./advanced.md) - Performance tuning
|
|
188
|
+
|
|
189
|
+
## 🎓 Learning Paths
|
|
190
|
+
|
|
191
|
+
### Path 1: Building Your First Society
|
|
192
|
+
1. [Getting Started](./getting-started.md)
|
|
193
|
+
2. [Architecture](./architecture.md)
|
|
194
|
+
3. [Workflows](./workflows.md)
|
|
195
|
+
4. [Examples](./examples.md)
|
|
196
|
+
|
|
197
|
+
### Path 2: Advanced Orchestration
|
|
198
|
+
1. [Pipeline Patterns](./pipeline-patterns.md)
|
|
199
|
+
2. [Graph Execution](./graph-execution.md)
|
|
200
|
+
3. [Aggregation Strategies](./aggregation-strategies.md)
|
|
201
|
+
4. [Advanced Features](./advanced.md)
|
|
202
|
+
|
|
203
|
+
### Path 3: Production-Ready Systems
|
|
204
|
+
1. [Context System](./context-system.md)
|
|
205
|
+
2. [Event System](./event-system.md)
|
|
206
|
+
3. [Middleware System](./middleware-system.md)
|
|
207
|
+
4. [Metrics & Observability](./metrics-observability.md)
|
|
208
|
+
5. [Advanced Features](./advanced.md)
|
|
209
|
+
|
|
210
|
+
### Path 4: Data & Integration
|
|
211
|
+
1. [Tool Calling](./tool-calling.md)
|
|
212
|
+
2. [Memory System](./memory-system.md)
|
|
213
|
+
3. [Structured Output](./structured-output.md)
|
|
214
|
+
4. [Context System](./context-system.md)
|
|
215
|
+
→ [Workflows](./workflows.md) → [Collaborative Execution](./workflows.md#collaborative-execution)
|
|
216
|
+
|
|
217
|
+
**Handle errors properly**
|
|
218
|
+
→ [Advanced](./advanced.md) → [Error Handling](./advanced.md#error-handling)
|
|
219
|
+
|
|
220
|
+
**Integrate with OpenAI/Anthropic**
|
|
221
|
+
→ [Examples](./examples.md) → [Tool Calling Example](./examples.md#tool-calling-tool-callingts)
|
|
222
|
+
|
|
223
|
+
**Monitor execution**
|
|
224
|
+
→ [Metrics & Observability](./metrics-observability.md) → [Real-Time Monitoring](./metrics-observability.md#real-time-monitoring)
|
|
225
|
+
|
|
226
|
+
**Optimize performance**
|
|
227
|
+
→ [Advanced](./advanced.md) → [Performance](./advanced.md#performance-optimization)
|
|
228
|
+
|
|
229
|
+
**Test my workflows**
|
|
230
|
+
→ [Advanced](./advanced.md) → [Testing](./advanced.md#testing)
|
|
231
|
+
|
|
232
|
+
**Deploy to production**
|
|
233
|
+
→ [Advanced](./advanced.md) → [Production](./advanced.md#production-deployment)
|
|
234
|
+
|
|
235
|
+
**Migrate from old API**
|
|
236
|
+
→ [Migration Guide](./migration.md)
|
|
237
|
+
|
|
238
|
+
## 💡 Key Concepts
|
|
239
|
+
|
|
240
|
+
### 1. Roles
|
|
241
|
+
|
|
242
|
+
Define agent behavior with system prompts, capabilities, and constraints.
|
|
243
|
+
|
|
244
|
+
```typescript
|
|
245
|
+
const role = RoleBuilder.create().withSystemPrompt('You are a data analyst').build();
|
|
246
|
+
````
|
|
247
|
+
|
|
248
|
+
**Read more**: [Architecture - AgentRole](./architecture.md#2-agentrole)
|
|
249
|
+
|
|
250
|
+
### 2. Agents
|
|
251
|
+
|
|
252
|
+
Combine roles with AI models to create functional agents.
|
|
253
|
+
|
|
254
|
+
```typescript
|
|
255
|
+
const agent = AgentBuilder.create().withRole(role).withModel(model).build();
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
**Read more**: [Architecture - AgentConfig](./architecture.md#3-agentconfig)
|
|
259
|
+
|
|
260
|
+
### 3. Graph Execution
|
|
261
|
+
|
|
262
|
+
Build complex workflows with DAG or cyclic graphs using 8 node types.
|
|
263
|
+
|
|
264
|
+
```typescript
|
|
265
|
+
const graph = GraphBuilder.create()
|
|
266
|
+
.addNode('start', NodeType.START)
|
|
267
|
+
.addNode('agent', NodeType.AGENT, { agentId: 'analyst' })
|
|
268
|
+
.addNode('condition', NodeType.CONDITION, { condition: (ctx) => ctx.data.needsReview })
|
|
269
|
+
.addNode('end', NodeType.END)
|
|
270
|
+
.addEdge('start', 'agent')
|
|
271
|
+
.addEdge('agent', 'condition')
|
|
272
|
+
.addEdge('condition', 'end', false) // if false
|
|
273
|
+
.build();
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
**Read more**: [Graph Execution](./graph-execution.md)
|
|
277
|
+
|
|
278
|
+
### 4. Tool Calling
|
|
279
|
+
|
|
280
|
+
Give agents access to external tools and APIs.
|
|
281
|
+
|
|
282
|
+
```typescript
|
|
283
|
+
const tool = ToolBuilder.create()
|
|
284
|
+
.withName('get_weather')
|
|
285
|
+
.withDescription('Get weather for a location')
|
|
286
|
+
.withParameter('location', 'string', 'City name', true)
|
|
287
|
+
.withExecutor(async ({ location }) => fetchWeather(location))
|
|
288
|
+
.build();
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
**Read more**: [Tool Calling](./tool-calling.md)
|
|
292
|
+
|
|
293
|
+
### 5. Memory System
|
|
294
|
+
|
|
295
|
+
Manage context with multi-level memory (short-term, long-term, entity).
|
|
296
|
+
|
|
297
|
+
```typescript
|
|
298
|
+
const memory = MemoryBuilder.create()
|
|
299
|
+
.withShortTermMemory({ maxSize: 10, decayRate: 0.1 })
|
|
300
|
+
.withLongTermMemory({ maxSize: 100, similarityThreshold: 0.7 })
|
|
301
|
+
.withEntityMemory({ maxEntities: 50 })
|
|
302
|
+
.build();
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
**Read more**: [Memory System](./memory-system.md)
|
|
306
|
+
|
|
307
|
+
### 6. Structured Output
|
|
308
|
+
|
|
309
|
+
Validate AI outputs against JSON schemas with automatic retry.
|
|
310
|
+
|
|
311
|
+
```typescript
|
|
312
|
+
const validator = new StructuredOutputValidator({
|
|
313
|
+
type: 'object',
|
|
314
|
+
properties: {
|
|
315
|
+
name: { type: 'string' },
|
|
316
|
+
age: { type: 'number', minimum: 0 },
|
|
317
|
+
},
|
|
318
|
+
required: ['name', 'age'],
|
|
319
|
+
});
|
|
320
|
+
|
|
321
|
+
const result = await validator.validateAndRetry(generator, 3);
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
**Read more**: [Structured Output](./structured-output.md)
|
|
325
|
+
|
|
326
|
+
### 7. Metrics & Observability
|
|
327
|
+
|
|
328
|
+
Track performance, tokens, costs, and custom metrics.
|
|
329
|
+
|
|
330
|
+
```typescript
|
|
331
|
+
const tracker = MetricsBuilder.create()
|
|
332
|
+
.withTokenTracking()
|
|
333
|
+
.withCostTracking(CommonCostConfigs['gpt-4'])
|
|
334
|
+
.withCustomMetrics(['api_calls'])
|
|
335
|
+
.build();
|
|
336
|
+
|
|
337
|
+
tracker.start('workflow-1');
|
|
338
|
+
// ... execute workflow ...
|
|
339
|
+
const snapshot = tracker.end('workflow-1');
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
**Read more**: [Metrics & Observability](./metrics-observability.md)
|
|
343
|
+
|
|
344
|
+
## 🎓 Learning Path
|
|
345
|
+
|
|
346
|
+
### Level 1: Basics (30 minutes)
|
|
347
|
+
|
|
348
|
+
1. [Install and setup](./getting-started.md#installation)
|
|
349
|
+
2. [Create your first workflow](./getting-started.md#your-first-society)
|
|
350
|
+
3. [Understand core concepts](./getting-started.md#understanding-the-basics)
|
|
351
|
+
|
|
352
|
+
### Level 2: Intermediate (1 hour)
|
|
353
|
+
|
|
354
|
+
1. [Learn workflow patterns](./workflows.md#common-patterns)
|
|
355
|
+
2. [Build graph-based workflows](./graph-execution.md#basic-graph-example)
|
|
356
|
+
3. [Add tool calling](./tool-calling.md#basic-tool-creation)
|
|
357
|
+
4. [Try different execution types](./workflows.md#execution-types)
|
|
358
|
+
|
|
359
|
+
### Level 3: Advanced (2 hours)
|
|
360
|
+
|
|
361
|
+
1. [Implement memory system](./memory-system.md#complete-memory-system)
|
|
362
|
+
2. [Add output validation](./structured-output.md#automatic-retry-with-error-feedback)
|
|
363
|
+
3. [Setup metrics tracking](./metrics-observability.md#complete-example)
|
|
364
|
+
4. [Master error handling](./advanced.md#error-handling)
|
|
365
|
+
5. [Optimize performance](./advanced.md#performance-optimization)
|
|
366
|
+
|
|
367
|
+
### Level 4: Production (3+ hours)
|
|
368
|
+
|
|
369
|
+
1. [Build complex workflows](./graph-execution.md#conditional-branching)
|
|
370
|
+
2. [Integrate all features](./examples.md#complete-integration-complete-integrationts)
|
|
371
|
+
3. [Implement observability](./metrics-observability.md#opentelemetry-export)
|
|
372
|
+
4. [Deploy to production](./advanced.md#production-deployment)
|
|
373
|
+
|
|
374
|
+
## 📝 API Quick Reference
|
|
375
|
+
|
|
376
|
+
| Builder/Class | Purpose | Documentation |
|
|
377
|
+
| --------------------------- | ------------------------ | ---------------------------------------------------------- |
|
|
378
|
+
| `RoleBuilder` | Define agent roles | [API Ref](./api-reference.md#rolebuilder) |
|
|
379
|
+
| `AgentBuilder` | Create agents | [API Ref](./api-reference.md#agentbuilder) |
|
|
380
|
+
| `GraphBuilder` | Build graph workflows | [Graph Execution](./graph-execution.md) |
|
|
381
|
+
| `ToolBuilder` | Define tools | [Tool Calling](./tool-calling.md) |
|
|
382
|
+
| `ToolRegistry` | Manage tools | [Tool Calling](./tool-calling.md#toolregistry) |
|
|
383
|
+
| `ToolExecutor` | Execute tools | [Tool Calling](./tool-calling.md#toolexecutor) |
|
|
384
|
+
| `MemoryBuilder` | Configure memory | [Memory System](./memory-system.md) |
|
|
385
|
+
| `MemorySystem` | Unified memory interface | [Memory System](./memory-system.md#complete-memory-system) |
|
|
386
|
+
| `StructuredOutputValidator` | Validate JSON outputs | [Structured Output](./structured-output.md) |
|
|
387
|
+
| `StructuredOutputBuilder` | Build validators | [Structured Output](./structured-output.md) |
|
|
388
|
+
| `MetricsTracker` | Track workflow metrics | [Metrics & Observability](./metrics-observability.md) |
|
|
389
|
+
| `MetricsBuilder` | Configure metrics | [Metrics & Observability](./metrics-observability.md) |
|
|
390
|
+
| `TokenCounter` | Count/estimate tokens | [Metrics & Observability](./metrics-observability.md) |
|
|
391
|
+
| `PerformanceProfiler` | Profile performance | [Metrics & Observability](./metrics-observability.md) |
|
|
392
|
+
| `StepBuilder` | Define workflow steps | [API Ref](./api-reference.md#stepbuilder) |
|
|
393
|
+
| `WorkflowConfigBuilder` | Build workflows | [API Ref](./api-reference.md#workflowconfigbuilder) |
|
|
394
|
+
| `DefaultWorkflowExecutor` | Execute workflows | [API Ref](./api-reference.md#defaultworkflowexecutor) |
|
|
395
|
+
| `StandardModelBase` | Create AI models | [API Ref](./api-reference.md#standardmodelbase) |
|
|
396
|
+
| `MessageBus` | Agent communication | [API Ref](./api-reference.md#messagebus) |
|
|
397
|
+
|
|
398
|
+
## 🌟 Feature Highlights
|
|
399
|
+
|
|
400
|
+
### Graph Execution
|
|
401
|
+
|
|
402
|
+
- **8 Node Types**: START, END, AGENT, PARALLEL, AGGREGATE, CONDITION, TRANSFORM, LOOP
|
|
403
|
+
- **Complex Workflows**: DAG and cyclic graphs with conditional branching
|
|
404
|
+
- **Parallel Processing**: Run multiple agents simultaneously
|
|
405
|
+
- See: [Graph Execution Guide](./graph-execution.md)
|
|
406
|
+
|
|
407
|
+
### Tool Calling
|
|
408
|
+
|
|
409
|
+
- **External Integration**: Connect agents to APIs and tools
|
|
410
|
+
- **Parameter Validation**: JSON Schema validation for tool parameters
|
|
411
|
+
- **Built-in Tools**: Calculator, string manipulation, storage
|
|
412
|
+
- See: [Tool Calling Guide](./tool-calling.md)
|
|
413
|
+
|
|
414
|
+
### Memory System
|
|
415
|
+
|
|
416
|
+
- **Multi-Level**: Short-term, long-term, and entity memory
|
|
417
|
+
- **Auto-Summarization**: Automatic compression of old memories
|
|
418
|
+
- **RAG Integration**: Semantic search for long-term memories
|
|
419
|
+
- See: [Memory System Guide](./memory-system.md)
|
|
420
|
+
|
|
421
|
+
### Structured Output
|
|
422
|
+
|
|
423
|
+
- **JSON Schema**: Industry-standard validation
|
|
424
|
+
- **Auto-Retry**: Re-prompt agents with error feedback
|
|
425
|
+
- **Complex Types**: Nested objects, arrays, patterns, enums
|
|
426
|
+
- See: [Structured Output Guide](./structured-output.md)
|
|
427
|
+
|
|
428
|
+
### Metrics & Observability
|
|
429
|
+
|
|
430
|
+
- **Cost Tracking**: Automatic cost calculation for major AI models
|
|
431
|
+
- **Token Counting**: Estimate and count tokens
|
|
432
|
+
- **OpenTelemetry**: Export traces in industry-standard format
|
|
433
|
+
- See: [Metrics & Observability Guide](./metrics-observability.md)
|
|
434
|
+
|
|
435
|
+
## 🤝 Getting Help
|
|
436
|
+
|
|
437
|
+
- **Questions**: [GitHub Discussions](https://github.com/benoitpetit/societyai-package/discussions)
|
|
438
|
+
- **Bugs**: [GitHub Issues](https://github.com/benoitpetit/societyai-package/issues)
|
|
439
|
+
- **Examples**: See [Examples Index](./examples.md) (examples folder coming soon)
|
|
440
|
+
- **API Docs**: [API Reference](./api-reference.md)
|
|
441
|
+
|
|
442
|
+
## 🔗 External Resources
|
|
443
|
+
|
|
444
|
+
- **npm Package**: [societyai](https://www.npmjs.com/package/societyai)
|
|
445
|
+
- **GitHub**: [societyai-package](https://github.com/benoitpetit/societyai-package) (main repository)
|
|
446
|
+
- **Changelog**: [CHANGELOG.md](../CHANGELOG.md)
|
|
447
|
+
- **License**: [MIT](../LICENSE)
|
|
448
|
+
|
|
449
|
+
## 📋 Document Status
|
|
450
|
+
|
|
451
|
+
| Document | Status | Last Updated |
|
|
452
|
+
| ----------------------- | ----------- | ------------ |
|
|
453
|
+
| Getting Started | ✅ Complete | 2026-01-24 |
|
|
454
|
+
| Architecture | ✅ Complete | 2026-01-24 |
|
|
455
|
+
| Workflows | ✅ Complete | 2026-01-24 |
|
|
456
|
+
| Graph Execution | ✅ Complete | 2026-01-24 |
|
|
457
|
+
| Tool Calling | ✅ Complete | 2026-01-24 |
|
|
458
|
+
| Memory System | ✅ Complete | 2026-01-24 |
|
|
459
|
+
| Structured Output | ✅ Complete | 2026-01-24 |
|
|
460
|
+
| Metrics & Observability | ✅ Complete | 2026-01-24 |
|
|
461
|
+
| API Reference | ✅ Complete | 2026-01-24 |
|
|
462
|
+
| Advanced Features | ✅ Complete | 2026-01-24 |
|
|
463
|
+
| Migration Guide | ✅ Complete | 2026-01-24 |
|
|
464
|
+
| Examples Index | ✅ Complete | 2026-01-24 |
|
|
465
|
+
|
|
466
|
+
---
|
|
467
|
+
|
|
468
|
+
**Start Learning**: [Getting Started →](./getting-started.md)
|