societyai 0.0.2 โ†’ 0.0.4

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.
Files changed (262) hide show
  1. package/README.md +166 -132
  2. package/bin/societyai.js +19 -0
  3. package/dist/__tests__/builders/builders-coverage.test.d.ts +2 -0
  4. package/dist/__tests__/builders/builders-coverage.test.d.ts.map +1 -0
  5. package/dist/__tests__/builders/builders-coverage.test.js +338 -0
  6. package/dist/__tests__/builders/builders-coverage.test.js.map +1 -0
  7. package/dist/__tests__/builders/society-builder-coverage.test.d.ts +2 -0
  8. package/dist/__tests__/builders/society-builder-coverage.test.d.ts.map +1 -0
  9. package/dist/__tests__/builders/society-builder-coverage.test.js +66 -0
  10. package/dist/__tests__/builders/society-builder-coverage.test.js.map +1 -0
  11. package/dist/__tests__/capabilities/memory.test.d.ts +2 -0
  12. package/dist/__tests__/capabilities/memory.test.d.ts.map +1 -0
  13. package/dist/__tests__/capabilities/memory.test.js +79 -0
  14. package/dist/__tests__/capabilities/memory.test.js.map +1 -0
  15. package/dist/__tests__/capabilities/tools.test.d.ts +2 -0
  16. package/dist/__tests__/capabilities/tools.test.d.ts.map +1 -0
  17. package/dist/__tests__/capabilities/tools.test.js +167 -0
  18. package/dist/__tests__/capabilities/tools.test.js.map +1 -0
  19. package/dist/__tests__/capabilities/vector-store.test.d.ts +2 -0
  20. package/dist/__tests__/capabilities/vector-store.test.d.ts.map +1 -0
  21. package/dist/__tests__/capabilities/vector-store.test.js +180 -0
  22. package/dist/__tests__/capabilities/vector-store.test.js.map +1 -0
  23. package/dist/__tests__/core/context.test.d.ts +2 -0
  24. package/dist/__tests__/core/context.test.d.ts.map +1 -0
  25. package/dist/__tests__/core/context.test.js +69 -0
  26. package/dist/__tests__/core/context.test.js.map +1 -0
  27. package/dist/__tests__/core/errors.test.d.ts +2 -0
  28. package/dist/__tests__/core/errors.test.d.ts.map +1 -0
  29. package/dist/__tests__/core/errors.test.js +228 -0
  30. package/dist/__tests__/core/errors.test.js.map +1 -0
  31. package/dist/__tests__/core/middleware.test.d.ts +2 -0
  32. package/dist/__tests__/core/middleware.test.d.ts.map +1 -0
  33. package/dist/__tests__/core/middleware.test.js +118 -0
  34. package/dist/__tests__/core/middleware.test.js.map +1 -0
  35. package/dist/__tests__/core/persistence.test.d.ts +2 -0
  36. package/dist/__tests__/core/persistence.test.d.ts.map +1 -0
  37. package/dist/__tests__/core/persistence.test.js +125 -0
  38. package/dist/__tests__/core/persistence.test.js.map +1 -0
  39. package/dist/__tests__/e2e/func-integration.test.d.ts +2 -0
  40. package/dist/__tests__/e2e/func-integration.test.d.ts.map +1 -0
  41. package/dist/__tests__/e2e/func-integration.test.js +112 -0
  42. package/dist/__tests__/e2e/func-integration.test.js.map +1 -0
  43. package/dist/__tests__/e2e/human-loop.test.d.ts +2 -0
  44. package/dist/__tests__/e2e/human-loop.test.d.ts.map +1 -0
  45. package/dist/__tests__/e2e/human-loop.test.js +106 -0
  46. package/dist/__tests__/e2e/human-loop.test.js.map +1 -0
  47. package/dist/__tests__/e2e/society-complete.test.d.ts +2 -0
  48. package/dist/__tests__/e2e/society-complete.test.d.ts.map +1 -0
  49. package/dist/__tests__/e2e/society-complete.test.js +51 -0
  50. package/dist/__tests__/e2e/society-complete.test.js.map +1 -0
  51. package/dist/__tests__/engine/collaborative.test.d.ts +2 -0
  52. package/dist/__tests__/engine/collaborative.test.d.ts.map +1 -0
  53. package/dist/__tests__/engine/collaborative.test.js +348 -0
  54. package/dist/__tests__/engine/collaborative.test.js.map +1 -0
  55. package/dist/__tests__/engine/execution-engine-refactor.test.d.ts +2 -0
  56. package/dist/__tests__/engine/execution-engine-refactor.test.d.ts.map +1 -0
  57. package/dist/__tests__/engine/execution-engine-refactor.test.js +324 -0
  58. package/dist/__tests__/engine/execution-engine-refactor.test.js.map +1 -0
  59. package/dist/__tests__/engine/execution-engine.test.d.ts +2 -0
  60. package/dist/__tests__/engine/execution-engine.test.d.ts.map +1 -0
  61. package/dist/__tests__/engine/execution-engine.test.js +104 -0
  62. package/dist/__tests__/engine/execution-engine.test.js.map +1 -0
  63. package/dist/__tests__/engine/graph-advanced.test.d.ts +2 -0
  64. package/dist/__tests__/engine/graph-advanced.test.d.ts.map +1 -0
  65. package/dist/__tests__/engine/graph-advanced.test.js +358 -0
  66. package/dist/__tests__/engine/graph-advanced.test.js.map +1 -0
  67. package/dist/__tests__/examples/getting-started.test.d.ts +2 -0
  68. package/dist/__tests__/examples/getting-started.test.d.ts.map +1 -0
  69. package/dist/__tests__/examples/getting-started.test.js +27 -0
  70. package/dist/__tests__/examples/getting-started.test.js.map +1 -0
  71. package/dist/__tests__/execution/graph-visualizer.test.d.ts +2 -0
  72. package/dist/__tests__/execution/graph-visualizer.test.d.ts.map +1 -0
  73. package/dist/__tests__/execution/graph-visualizer.test.js +44 -0
  74. package/dist/__tests__/execution/graph-visualizer.test.js.map +1 -0
  75. package/dist/__tests__/execution/trace-hooks.test.d.ts +2 -0
  76. package/dist/__tests__/execution/trace-hooks.test.d.ts.map +1 -0
  77. package/dist/__tests__/execution/trace-hooks.test.js +83 -0
  78. package/dist/__tests__/execution/trace-hooks.test.js.map +1 -0
  79. package/dist/__tests__/execution_types_coverage.test.d.ts +2 -0
  80. package/dist/__tests__/execution_types_coverage.test.d.ts.map +1 -0
  81. package/dist/__tests__/execution_types_coverage.test.js +139 -0
  82. package/dist/__tests__/execution_types_coverage.test.js.map +1 -0
  83. package/dist/__tests__/integration/advanced-graph.test.d.ts +2 -0
  84. package/dist/__tests__/integration/advanced-graph.test.d.ts.map +1 -0
  85. package/dist/__tests__/integration/advanced-graph.test.js +96 -0
  86. package/dist/__tests__/integration/advanced-graph.test.js.map +1 -0
  87. package/dist/__tests__/integration/global-context.test.d.ts +2 -0
  88. package/dist/__tests__/integration/global-context.test.d.ts.map +1 -0
  89. package/dist/__tests__/integration/global-context.test.js +73 -0
  90. package/dist/__tests__/integration/global-context.test.js.map +1 -0
  91. package/dist/__tests__/integration/property-based.test.d.ts +2 -0
  92. package/dist/__tests__/integration/property-based.test.d.ts.map +1 -0
  93. package/dist/__tests__/integration/property-based.test.js +216 -0
  94. package/dist/__tests__/integration/property-based.test.js.map +1 -0
  95. package/dist/__tests__/integration/resiliency.test.d.ts +2 -0
  96. package/dist/__tests__/integration/resiliency.test.d.ts.map +1 -0
  97. package/dist/__tests__/integration/resiliency.test.js +146 -0
  98. package/dist/__tests__/integration/resiliency.test.js.map +1 -0
  99. package/dist/__tests__/integration/society-flow.test.d.ts +2 -0
  100. package/dist/__tests__/integration/society-flow.test.d.ts.map +1 -0
  101. package/dist/__tests__/integration/society-flow.test.js +69 -0
  102. package/dist/__tests__/integration/society-flow.test.js.map +1 -0
  103. package/dist/__tests__/observability/events.test.d.ts +2 -0
  104. package/dist/__tests__/observability/events.test.d.ts.map +1 -0
  105. package/dist/__tests__/observability/events.test.js +82 -0
  106. package/dist/__tests__/observability/events.test.js.map +1 -0
  107. package/dist/__tests__/utils/loop-json.test.d.ts +2 -0
  108. package/dist/__tests__/utils/loop-json.test.d.ts.map +1 -0
  109. package/dist/__tests__/utils/loop-json.test.js +112 -0
  110. package/dist/__tests__/utils/loop-json.test.js.map +1 -0
  111. package/dist/__tests__/utils/mock-model.d.ts +17 -0
  112. package/dist/__tests__/utils/mock-model.d.ts.map +1 -0
  113. package/dist/__tests__/utils/mock-model.js +45 -0
  114. package/dist/__tests__/utils/mock-model.js.map +1 -0
  115. package/dist/__tests__/utils/property-testing.d.ts +28 -0
  116. package/dist/__tests__/utils/property-testing.d.ts.map +1 -0
  117. package/dist/__tests__/utils/property-testing.js +220 -0
  118. package/dist/__tests__/utils/property-testing.js.map +1 -0
  119. package/dist/__tests__/utils/retry-worker-pool.test.d.ts +2 -0
  120. package/dist/__tests__/utils/retry-worker-pool.test.d.ts.map +1 -0
  121. package/dist/__tests__/utils/retry-worker-pool.test.js +198 -0
  122. package/dist/__tests__/utils/retry-worker-pool.test.js.map +1 -0
  123. package/dist/adapters/index.d.ts +3 -0
  124. package/dist/adapters/index.d.ts.map +1 -0
  125. package/dist/adapters/index.js +8 -0
  126. package/dist/adapters/index.js.map +1 -0
  127. package/dist/adapters/storage-postgres.d.ts +27 -0
  128. package/dist/adapters/storage-postgres.d.ts.map +1 -0
  129. package/dist/adapters/storage-postgres.js +109 -0
  130. package/dist/adapters/storage-postgres.js.map +1 -0
  131. package/dist/adapters/storage-redis.d.ts +25 -0
  132. package/dist/adapters/storage-redis.d.ts.map +1 -0
  133. package/dist/adapters/storage-redis.js +57 -0
  134. package/dist/adapters/storage-redis.js.map +1 -0
  135. package/dist/agents/agent-executor.d.ts +22 -0
  136. package/dist/agents/agent-executor.d.ts.map +1 -0
  137. package/dist/agents/agent-executor.js +183 -0
  138. package/dist/agents/agent-executor.js.map +1 -0
  139. package/dist/agents/society-executor.d.ts +11 -0
  140. package/dist/agents/society-executor.d.ts.map +1 -0
  141. package/dist/agents/society-executor.js +187 -0
  142. package/dist/agents/society-executor.js.map +1 -0
  143. package/dist/bin/inspect.d.ts +3 -0
  144. package/dist/bin/inspect.d.ts.map +1 -0
  145. package/dist/bin/inspect.js +99 -0
  146. package/dist/bin/inspect.js.map +1 -0
  147. package/dist/builders/agent-builder.d.ts +11 -4
  148. package/dist/builders/agent-builder.d.ts.map +1 -1
  149. package/dist/builders/agent-builder.js +18 -0
  150. package/dist/builders/agent-builder.js.map +1 -1
  151. package/dist/builders/builder.d.ts +3 -2
  152. package/dist/builders/builder.d.ts.map +1 -1
  153. package/dist/builders/builder.js +10 -9
  154. package/dist/builders/builder.js.map +1 -1
  155. package/dist/builders/role-builder.d.ts +2 -2
  156. package/dist/builders/role-builder.d.ts.map +1 -1
  157. package/dist/builders/society-builder.d.ts +102 -0
  158. package/dist/builders/society-builder.d.ts.map +1 -0
  159. package/dist/builders/society-builder.js +345 -0
  160. package/dist/builders/society-builder.js.map +1 -0
  161. package/dist/capabilities/memory.d.ts +3 -0
  162. package/dist/capabilities/memory.d.ts.map +1 -1
  163. package/dist/capabilities/memory.js +25 -2
  164. package/dist/capabilities/memory.js.map +1 -1
  165. package/dist/capabilities/self-correcting-validator.d.ts +50 -0
  166. package/dist/capabilities/self-correcting-validator.d.ts.map +1 -0
  167. package/dist/capabilities/self-correcting-validator.js +236 -0
  168. package/dist/capabilities/self-correcting-validator.js.map +1 -0
  169. package/dist/capabilities/tools.d.ts +2 -13
  170. package/dist/capabilities/tools.d.ts.map +1 -1
  171. package/dist/capabilities/tools.js +5 -1
  172. package/dist/capabilities/tools.js.map +1 -1
  173. package/dist/capabilities/validation.d.ts +5 -0
  174. package/dist/capabilities/validation.d.ts.map +1 -1
  175. package/dist/capabilities/validation.js +128 -21
  176. package/dist/capabilities/validation.js.map +1 -1
  177. package/dist/capabilities/vector-store.d.ts +61 -0
  178. package/dist/capabilities/vector-store.d.ts.map +1 -0
  179. package/dist/capabilities/vector-store.js +154 -0
  180. package/dist/capabilities/vector-store.js.map +1 -0
  181. package/dist/core/config.d.ts +3 -3
  182. package/dist/core/config.d.ts.map +1 -1
  183. package/dist/core/errors.d.ts +26 -2
  184. package/dist/core/errors.d.ts.map +1 -1
  185. package/dist/core/errors.js +78 -4
  186. package/dist/core/errors.js.map +1 -1
  187. package/dist/core/middleware.d.ts +6 -5
  188. package/dist/core/middleware.d.ts.map +1 -1
  189. package/dist/core/middleware.js +9 -0
  190. package/dist/core/middleware.js.map +1 -1
  191. package/dist/core/persistence.d.ts +37 -0
  192. package/dist/core/persistence.d.ts.map +1 -0
  193. package/dist/core/persistence.js +115 -0
  194. package/dist/core/persistence.js.map +1 -0
  195. package/dist/core/society.d.ts +55 -0
  196. package/dist/core/society.d.ts.map +1 -0
  197. package/dist/core/society.js +316 -0
  198. package/dist/core/society.js.map +1 -0
  199. package/dist/core/types.d.ts +50 -137
  200. package/dist/core/types.d.ts.map +1 -1
  201. package/dist/core/types.js +0 -16
  202. package/dist/core/types.js.map +1 -1
  203. package/dist/execution/engine/execution-engine.d.ts +110 -0
  204. package/dist/execution/engine/execution-engine.d.ts.map +1 -0
  205. package/dist/execution/engine/execution-engine.js +721 -0
  206. package/dist/execution/engine/execution-engine.js.map +1 -0
  207. package/dist/execution/engine-as-model.d.ts +29 -0
  208. package/dist/execution/engine-as-model.d.ts.map +1 -0
  209. package/dist/execution/engine-as-model.js +85 -0
  210. package/dist/execution/engine-as-model.js.map +1 -0
  211. package/dist/execution/graph-visualizer.d.ts +6 -0
  212. package/dist/execution/graph-visualizer.d.ts.map +1 -0
  213. package/dist/execution/graph-visualizer.js +76 -0
  214. package/dist/execution/graph-visualizer.js.map +1 -0
  215. package/dist/index.d.ts +12 -11
  216. package/dist/index.d.ts.map +1 -1
  217. package/dist/index.js +30 -34
  218. package/dist/index.js.map +1 -1
  219. package/dist/observability/events.d.ts +19 -23
  220. package/dist/observability/events.d.ts.map +1 -1
  221. package/dist/observability/events.js +18 -20
  222. package/dist/observability/events.js.map +1 -1
  223. package/dist/utils/json.d.ts +2 -0
  224. package/dist/utils/json.d.ts.map +1 -0
  225. package/dist/utils/json.js +54 -0
  226. package/dist/utils/json.js.map +1 -0
  227. package/dist/utils/loop-controller.d.ts +12 -0
  228. package/dist/utils/loop-controller.d.ts.map +1 -0
  229. package/dist/utils/loop-controller.js +30 -0
  230. package/dist/utils/loop-controller.js.map +1 -0
  231. package/dist/utils/worker-pool.d.ts +10 -0
  232. package/dist/utils/worker-pool.d.ts.map +1 -1
  233. package/dist/utils/worker-pool.js +55 -1
  234. package/dist/utils/worker-pool.js.map +1 -1
  235. package/package.json +25 -8
  236. package/CHANGELOG.md +0 -111
  237. package/docs/ARCHITECTURE.md +0 -358
  238. package/docs/README.md +0 -214
  239. package/docs/advanced.md +0 -628
  240. package/docs/aggregation-strategies.md +0 -926
  241. package/docs/api-reference.md +0 -771
  242. package/docs/context-system.md +0 -642
  243. package/docs/event-system.md +0 -1047
  244. package/docs/examples.md +0 -585
  245. package/docs/getting-started.md +0 -564
  246. package/docs/graph-execution.md +0 -389
  247. package/docs/memory-system.md +0 -497
  248. package/docs/metrics-observability.md +0 -560
  249. package/docs/middleware-system.md +0 -1038
  250. package/docs/pipeline-patterns.md +0 -761
  251. package/docs/structured-output.md +0 -612
  252. package/docs/tool-calling.md +0 -491
  253. package/docs/workflows.md +0 -740
  254. package/examples/README.md +0 -88
  255. package/examples/complete-integration.ts +0 -53
  256. package/examples/getting-started.ts +0 -145
  257. package/examples/graph-workflow.ts +0 -41
  258. package/examples/memory-system.ts +0 -24
  259. package/examples/metrics-tracking.ts +0 -32
  260. package/examples/structured-output.ts +0 -24
  261. package/examples/tool-calling.ts +0 -41
  262. package/examples/utils.ts +0 -20
package/README.md CHANGED
@@ -5,43 +5,69 @@
5
5
  [![TypeScript](https://img.shields.io/badge/TypeScript-5.9-blue.svg)](https://www.typescriptlang.org/)
6
6
  [![Zero Dependencies](https://img.shields.io/badge/dependencies-0-brightgreen.svg)](package.json)
7
7
 
8
- **SocietyAI** is a powerful TypeScript library for creating collaborative
9
- multi-agent AI systems with advanced DAG-based orchestration. Build
10
- sophisticated workflows where AI agents with different roles and capabilities
11
- work together through dependency graphs, conditional routing, and pluggable
12
- execution strategies.
13
-
14
- The library is **fully configurable**, **model-agnostic**, and
15
- **domain-independent** - use it for software development, research, content
16
- creation, business analysis, or any domain where multiple perspectives add
17
- value.
18
-
19
- ## ๐ŸŽฏ Design Principles
20
-
21
- - **Model-Agnostic**: Works with any AI model (OpenAI, Anthropic, Google, local
22
- models, or custom APIs)
23
- - **Domain-Independent**: No hardcoded prompts or business logic - fully
24
- configurable for any use case
25
- - **Zero Runtime Dependencies**: Pure TypeScript with no external runtime
26
- dependencies
27
- - **Fluent Builder API**: Intuitive chainable interfaces for configuring agents,
28
- roles, and workflows
29
- - **DAG Orchestration**: Directed Acyclic Graph scheduling with topological sort
30
- for optimal execution
8
+ **SocietyAI** is a powerful TypeScript/Node.js library for orchestrating
9
+ collaborative multi-agent systems. It allows you to build sophisticated
10
+ workflows where AI agents, equipped with specific roles and capabilities,
11
+ collaborate through a graph-based execution engine (DAG & Cycles).
12
+
13
+ The library is **fully model-agnostic**, **domain-independent**, and designed to
14
+ be modular.
15
+
16
+ ## ๐ŸŽฏ Why SocietyAI?
17
+
18
+ - **Model-Agnostic**: Works with any LLM (OpenAI, Anthropic, Mistral, Local,
19
+ etc.). You implement the interface, you control the call.
20
+ - **Graph Orchestration**: Native support for DAGs (Directed Acyclic Graphs) as
21
+ well as feedback loops and recursive structures.
22
+ - **Zero Runtime Dependencies**: The core is pure TypeScript.
23
+ - **Fluent API**: An intuitive builder (`Society.create()`) to quickly define
24
+ agents and workflows.
25
+ - **Type-Safe**: Fully typed for a robust development experience.
26
+ - **Two API Levels**: Choose between high-level (quick) or low-level (powerful)
27
+ depending on your needs.
28
+
29
+ > ๐Ÿ“š **New to SocietyAI?** Check out the [Documentation](docs/README.md) for
30
+ > architectural insights and best practices.
31
31
 
32
32
  ## โœจ Key Features
33
33
 
34
- ### Core Capabilities
34
+ - **๐Ÿค– Multi-Agent System**: Define roles, personalities, and contexts for each
35
+ agent.
36
+ - **๐Ÿ”„ Flexible Workflows**: Sequential, Parallel, Collaborative (debate between
37
+ agents), and Conditional.
38
+ - **๐Ÿง  Memory & Context**: Native management of short/long-term memory and
39
+ type-safe Context Injection.
40
+ - **๐Ÿ’พ Persistence & Recovery**: Save execution state, handle crashes, and
41
+ resume workflows seamlessly.
42
+ - **๐Ÿ“ก Observability**: Full event-driven system to track every thought, action,
43
+ and state change.
44
+ - **๐Ÿ™‹ Human-in-the-Loop**: Pause workflows for human validation or input and
45
+ resume automatically.
46
+ - **โšก Execution Strategies**: The engine transforms your configuration into an
47
+ optimized execution graph.
48
+ - **๐Ÿ› ๏ธ Extensible**: Middleware system, Custom Tools (Function Calling), and
49
+ Validation.
35
50
 
36
- - **๐Ÿค– Multi-Agent System**: Define custom roles, behaviors, and capabilities
37
- - **๐Ÿ”„ DAG Workflows**: Dependency-based execution with automatic scheduling
38
- - **๐ŸŽฏ Conditional Routing**: Dynamic workflow branching based on runtime
39
- results
40
- - **โšก Execution Strategies**: Pluggable sequential and parallel execution
41
- patterns
42
- - **๐Ÿง  Memory System**: Multi-level context management
43
- - **๐Ÿ› ๏ธ Tool Calling**: External function integration with validation
44
- - **๐Ÿ“Š Full Observability**: Structured logging, metrics, and events
51
+ ## ๐Ÿงช Testing
52
+
53
+ SocietyAI comes with a comprehensive test suite using **Jest**.
54
+
55
+ ### Running Tests
56
+
57
+ ```bash
58
+ # Run all tests
59
+ npm test
60
+
61
+ # Run with coverage report
62
+ npm run test -- --coverage
63
+ ```
64
+
65
+ ### Coverage Areas
66
+
67
+ - **Core Logic**: Execution engine, graph traversal, and state management.
68
+ - **Capabilities**: Tool execution, memory system, and schema validation.
69
+ - **Builders**: Fluent API configuration and validation.
70
+ - **Observability**: Event system and logging.
45
71
 
46
72
  ## ๐Ÿš€ Quick Start
47
73
 
@@ -51,130 +77,138 @@ value.
51
77
  npm install societyai
52
78
  ```
53
79
 
54
- ### Basic Example
80
+ ### 1. Connect Your Model
81
+
82
+ SocietyAI does not depend on any specific SDK library. You simply need to adapt
83
+ your model to the `AIModel` interface. Here is a minimal example for OpenAI:
84
+
85
+ ```typescript
86
+ import { AIModel } from 'societyai';
87
+ import OpenAI from 'openai'; // Install openai separately
88
+
89
+ export class OpenAIModel implements AIModel {
90
+ private client: OpenAI;
91
+ private modelName: string;
92
+
93
+ constructor(apiKey: string, model: string = 'gpt-4') {
94
+ this.client = new OpenAI({ apiKey });
95
+ this.modelName = model;
96
+ }
97
+
98
+ name(): string {
99
+ return this.modelName;
100
+ }
101
+
102
+ supportsPromptType(type: string): boolean {
103
+ return true;
104
+ }
105
+
106
+ async process(prompt: unknown): Promise<string> {
107
+ const response = await this.client.chat.completions.create({
108
+ model: this.modelName,
109
+ messages: [{ role: 'user', content: String(prompt) }],
110
+ });
111
+ return response.choices[0].message.content || '';
112
+ }
113
+ }
114
+ ```
115
+
116
+ ### 2. Create Your First Society
117
+
118
+ This example creates a small team to write and review an article.
55
119
 
56
120
  ```typescript
57
121
  import { Society } from 'societyai';
122
+ import { OpenAIModel } from './my-model-impl'; // Your implementation above
58
123
 
59
- // Create a society with agents and workflow
124
+ const model = new OpenAIModel(process.env.OPENAI_API_KEY);
125
+
126
+ // Create the Society
60
127
  const result = await Society.create()
61
- .withId('data-pipeline')
128
+ .withId('blog-team')
129
+
130
+ // -- Define Agents --
62
131
  .addAgent((agent) =>
63
132
  agent
64
- .withId('analyst')
133
+ .withId('writer')
65
134
  .withRole((role) =>
66
135
  role
67
- .withId('data-analyst')
68
- .withSystemPrompt('You analyze data and provide insights')
136
+ .withName('Technical Writer')
137
+ .withSystemPrompt('You are an expert in concise technical writing.')
69
138
  )
70
- .withModel(yourAIModel)
139
+ .withModel(model)
71
140
  )
72
- .addStep((step) =>
73
- step
74
- .withId('extract')
75
- .withAgents(['analyst'])
76
- .withInstructions('Extract key information')
77
- .sequential()
78
- )
79
- .addStep((step) =>
80
- step
81
- .withId('transform')
82
- .dependsOn('extract') // DAG dependency
83
- .withAgents(['analyst'])
84
- .withInstructions('Transform data format')
141
+ .addAgent((agent) =>
142
+ agent
143
+ .withId('editor')
144
+ .withRole((role) =>
145
+ role
146
+ .withName('Editor in Chief')
147
+ .withSystemPrompt('You correct style and verify clarity.')
148
+ )
149
+ .withModel(model)
85
150
  )
86
- .execute('Process this input data');
87
- ```
88
-
89
- ## ๐Ÿ“š Documentation
90
-
91
- ### Core Documentation
92
-
93
- - **[Getting Started](./docs/getting-started.md)** - Comprehensive guide
94
- - **[Architecture](./docs/ARCHITECTURE.md)** - System design and DAG
95
- orchestration
96
- - **[API Reference](./docs/api-reference.md)** - Complete API documentation
97
- - **[Documentation Index](./docs/README.md)** - Full documentation catalog
98
-
99
- ### Feature Guides
100
151
 
101
- - [Workflows](./docs/workflows.md) - Building and executing workflows
102
- - [Tool Calling](./docs/tool-calling.md) - External tool integration
103
- - [Memory System](./docs/memory-system.md) - Context management
104
- - [Metrics & Observability](./docs/metrics-observability.md) - Monitoring
152
+ // -- Define Workflow --
105
153
 
106
- ### Reference
107
-
108
- - [Examples](./docs/examples.md) - Code examples
109
- - [Changelog](./CHANGELOG.md) - Version history
154
+ // Task 1: The writer writes
155
+ .addTask((task) =>
156
+ task
157
+ .withId('draft')
158
+ .withAgents(['writer'])
159
+ .withInstructions('Write a paragraph about the benefits of TypeScript.')
160
+ .sequential()
161
+ )
110
162
 
111
- ## ๐Ÿ—๏ธ Architecture
163
+ // Task 2: The editor reviews (explicitly depends on 'draft')
164
+ .addTask((task) =>
165
+ task
166
+ .withId('review')
167
+ .dependsOn('draft')
168
+ .withAgents(['editor'])
169
+ .withInstructions(
170
+ 'Review the previous text, correct mistakes, and improve the tone.'
171
+ )
172
+ .sequential()
173
+ )
112
174
 
113
- SocietyAI features a modular architecture with DAG-based workflow orchestration:
175
+ // Execute
176
+ .execute('Start Project');
114
177
 
178
+ console.log('Final Result:', result.output);
179
+ console.log('History:', result.taskResults);
115
180
  ```
116
- Builders โ†’ Orchestrator โ†’ Strategies
117
- โ†“
118
- DAG Scheduler
119
- โ†“
120
- Conditional Router
121
- โ†“
122
- Execution
123
- ```
124
-
125
- **Key Components:**
126
-
127
- - **Builders**: Fluent API for workflow construction
128
- - **Orchestrator**: Central coordinator delegating to strategies
129
- - **Scheduler**: Topological sort for optimal execution order
130
- - **Router**: Conditional branching based on runtime conditions
131
- - **Strategies**: Pluggable sequential/parallel execution
132
181
 
133
- See [Architecture Guide](./docs/ARCHITECTURE.md) for details.
182
+ ## ๐Ÿ“š Documentation
134
183
 
135
- ## ๐Ÿงช Testing
184
+ Explore detailed documentation in the `/docs` folder:
136
185
 
137
- Run tests:
186
+ - **[1. Basics](./docs/1-basics/)**: Getting Started and Core Concepts.
187
+ - **[2. Building Societies](./docs/2-building-societies/)**: Agents, Roles,
188
+ Context, and Configuration.
189
+ - **[3. Capabilities](./docs/3-capabilities/)**: Tools, Memory, Validation, and
190
+ Persistence.
191
+ - **[4. Advanced](./docs/4-advanced/)**: Loops, Middleware, and Observability.
192
+ - **[5. Architecture](./docs/5-architecture/)**: Execution Engine, DAGs, and
193
+ Patterns.
194
+ - **[Reference](./docs/reference/)**: API Index and Decision Guides.
138
195
 
139
- ```bash
140
- npm test # Run all tests
141
- npm run test:watch # Watch mode
142
- npm run test:coverage # Coverage report
143
- ```
196
+ Recent Highlights:
144
197
 
145
- Current test coverage: **47.52%** (151 tests passing)
198
+ - [Context Management](./docs/2-building-societies/context.md) for dependency
199
+ injection.
200
+ - [Observability System](./docs/4-advanced/observability.md) for full event
201
+ tracking.
202
+ - [Memory & RAG](./docs/3-capabilities/memory.md) for long-term state.
203
+ - [Structured Validation](./docs/3-capabilities/validation.md) for reliable JSON
204
+ outputs.
205
+ - [Execution Engine](./docs/5-architecture/execution-engine.md) deep dive.
146
206
 
147
- ## ๐Ÿ› ๏ธ Development
148
-
149
- ```bash
150
- npm run build # Build project
151
- npm run watch # Development watch mode
152
- npm run lint # Lint code
153
- npm run format # Format code
154
- npm run validate # Full validation (lint + test + build)
155
- ```
207
+ ## ๐Ÿค Contribution
156
208
 
157
- ## ๐Ÿค Contributing
158
-
159
- Contributions welcome! See [CONTRIBUTING.md](./CONTRIBUTING.md) for guidelines.
160
-
161
- 1. Fork the repository
162
- 2. Create feature branch (`git checkout -b feature/amazing-feature`)
163
- 3. Commit changes (`git commit -m 'Add amazing feature'`)
164
- 4. Push branch (`git push origin feature/amazing-feature`)
165
- 5. Open Pull Request
209
+ Contributions are welcome! Feel free to open an issue or a Pull Request on the
210
+ GitHub repository.
166
211
 
167
212
  ## ๐Ÿ“„ License
168
213
 
169
- MIT License - see [LICENSE](./LICENSE) file for details.
170
-
171
- ## ๐Ÿ”— Links
172
-
173
- - **Documentation**: [docs/](./docs/)
174
- - **npm Package**: [societyai](https://www.npmjs.com/package/societyai)
175
- - **Issues**:
176
- [GitHub Issues](https://github.com/benoitpetit/societyai-package/issues)
177
-
178
- ---
179
-
180
- **Made with โค๏ธ by devbyben**
214
+ MIT
@@ -0,0 +1,19 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * SocietyAI CLI (Future)
5
+ *
6
+ * This file is a placeholder for future CLI functionality.
7
+ * Currently, SocietyAI is used as a library.
8
+ */
9
+
10
+ console.log('SocietyAI v' + require('../package.json').version);
11
+ console.log('');
12
+ console.log('SocietyAI is a library for building multi-agent AI systems.');
13
+ console.log('');
14
+ console.log('Get started:');
15
+ console.log(' npm install societyai');
16
+ console.log('');
17
+ console.log('Documentation:');
18
+ console.log(' https://github.com/benoitpetit/societyai#readme');
19
+ console.log('');
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=builders-coverage.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"builders-coverage.test.d.ts","sourceRoot":"","sources":["../../../src/__tests__/builders/builders-coverage.test.ts"],"names":[],"mappings":""}