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.
- package/README.md +166 -132
- package/bin/societyai.js +19 -0
- package/dist/__tests__/builders/builders-coverage.test.d.ts +2 -0
- package/dist/__tests__/builders/builders-coverage.test.d.ts.map +1 -0
- package/dist/__tests__/builders/builders-coverage.test.js +338 -0
- package/dist/__tests__/builders/builders-coverage.test.js.map +1 -0
- package/dist/__tests__/builders/society-builder-coverage.test.d.ts +2 -0
- package/dist/__tests__/builders/society-builder-coverage.test.d.ts.map +1 -0
- package/dist/__tests__/builders/society-builder-coverage.test.js +66 -0
- package/dist/__tests__/builders/society-builder-coverage.test.js.map +1 -0
- package/dist/__tests__/capabilities/memory.test.d.ts +2 -0
- package/dist/__tests__/capabilities/memory.test.d.ts.map +1 -0
- package/dist/__tests__/capabilities/memory.test.js +79 -0
- package/dist/__tests__/capabilities/memory.test.js.map +1 -0
- package/dist/__tests__/capabilities/tools.test.d.ts +2 -0
- package/dist/__tests__/capabilities/tools.test.d.ts.map +1 -0
- package/dist/__tests__/capabilities/tools.test.js +167 -0
- package/dist/__tests__/capabilities/tools.test.js.map +1 -0
- package/dist/__tests__/capabilities/vector-store.test.d.ts +2 -0
- package/dist/__tests__/capabilities/vector-store.test.d.ts.map +1 -0
- package/dist/__tests__/capabilities/vector-store.test.js +180 -0
- package/dist/__tests__/capabilities/vector-store.test.js.map +1 -0
- package/dist/__tests__/core/context.test.d.ts +2 -0
- package/dist/__tests__/core/context.test.d.ts.map +1 -0
- package/dist/__tests__/core/context.test.js +69 -0
- package/dist/__tests__/core/context.test.js.map +1 -0
- package/dist/__tests__/core/errors.test.d.ts +2 -0
- package/dist/__tests__/core/errors.test.d.ts.map +1 -0
- package/dist/__tests__/core/errors.test.js +228 -0
- package/dist/__tests__/core/errors.test.js.map +1 -0
- package/dist/__tests__/core/middleware.test.d.ts +2 -0
- package/dist/__tests__/core/middleware.test.d.ts.map +1 -0
- package/dist/__tests__/core/middleware.test.js +118 -0
- package/dist/__tests__/core/middleware.test.js.map +1 -0
- package/dist/__tests__/core/persistence.test.d.ts +2 -0
- package/dist/__tests__/core/persistence.test.d.ts.map +1 -0
- package/dist/__tests__/core/persistence.test.js +125 -0
- package/dist/__tests__/core/persistence.test.js.map +1 -0
- package/dist/__tests__/e2e/func-integration.test.d.ts +2 -0
- package/dist/__tests__/e2e/func-integration.test.d.ts.map +1 -0
- package/dist/__tests__/e2e/func-integration.test.js +112 -0
- package/dist/__tests__/e2e/func-integration.test.js.map +1 -0
- package/dist/__tests__/e2e/human-loop.test.d.ts +2 -0
- package/dist/__tests__/e2e/human-loop.test.d.ts.map +1 -0
- package/dist/__tests__/e2e/human-loop.test.js +106 -0
- package/dist/__tests__/e2e/human-loop.test.js.map +1 -0
- package/dist/__tests__/e2e/society-complete.test.d.ts +2 -0
- package/dist/__tests__/e2e/society-complete.test.d.ts.map +1 -0
- package/dist/__tests__/e2e/society-complete.test.js +51 -0
- package/dist/__tests__/e2e/society-complete.test.js.map +1 -0
- package/dist/__tests__/engine/collaborative.test.d.ts +2 -0
- package/dist/__tests__/engine/collaborative.test.d.ts.map +1 -0
- package/dist/__tests__/engine/collaborative.test.js +348 -0
- package/dist/__tests__/engine/collaborative.test.js.map +1 -0
- package/dist/__tests__/engine/execution-engine-refactor.test.d.ts +2 -0
- package/dist/__tests__/engine/execution-engine-refactor.test.d.ts.map +1 -0
- package/dist/__tests__/engine/execution-engine-refactor.test.js +324 -0
- package/dist/__tests__/engine/execution-engine-refactor.test.js.map +1 -0
- package/dist/__tests__/engine/execution-engine.test.d.ts +2 -0
- package/dist/__tests__/engine/execution-engine.test.d.ts.map +1 -0
- package/dist/__tests__/engine/execution-engine.test.js +104 -0
- package/dist/__tests__/engine/execution-engine.test.js.map +1 -0
- package/dist/__tests__/engine/graph-advanced.test.d.ts +2 -0
- package/dist/__tests__/engine/graph-advanced.test.d.ts.map +1 -0
- package/dist/__tests__/engine/graph-advanced.test.js +358 -0
- package/dist/__tests__/engine/graph-advanced.test.js.map +1 -0
- package/dist/__tests__/examples/getting-started.test.d.ts +2 -0
- package/dist/__tests__/examples/getting-started.test.d.ts.map +1 -0
- package/dist/__tests__/examples/getting-started.test.js +27 -0
- package/dist/__tests__/examples/getting-started.test.js.map +1 -0
- package/dist/__tests__/execution/graph-visualizer.test.d.ts +2 -0
- package/dist/__tests__/execution/graph-visualizer.test.d.ts.map +1 -0
- package/dist/__tests__/execution/graph-visualizer.test.js +44 -0
- package/dist/__tests__/execution/graph-visualizer.test.js.map +1 -0
- package/dist/__tests__/execution/trace-hooks.test.d.ts +2 -0
- package/dist/__tests__/execution/trace-hooks.test.d.ts.map +1 -0
- package/dist/__tests__/execution/trace-hooks.test.js +83 -0
- package/dist/__tests__/execution/trace-hooks.test.js.map +1 -0
- package/dist/__tests__/execution_types_coverage.test.d.ts +2 -0
- package/dist/__tests__/execution_types_coverage.test.d.ts.map +1 -0
- package/dist/__tests__/execution_types_coverage.test.js +139 -0
- package/dist/__tests__/execution_types_coverage.test.js.map +1 -0
- package/dist/__tests__/integration/advanced-graph.test.d.ts +2 -0
- package/dist/__tests__/integration/advanced-graph.test.d.ts.map +1 -0
- package/dist/__tests__/integration/advanced-graph.test.js +96 -0
- package/dist/__tests__/integration/advanced-graph.test.js.map +1 -0
- package/dist/__tests__/integration/global-context.test.d.ts +2 -0
- package/dist/__tests__/integration/global-context.test.d.ts.map +1 -0
- package/dist/__tests__/integration/global-context.test.js +73 -0
- package/dist/__tests__/integration/global-context.test.js.map +1 -0
- package/dist/__tests__/integration/property-based.test.d.ts +2 -0
- package/dist/__tests__/integration/property-based.test.d.ts.map +1 -0
- package/dist/__tests__/integration/property-based.test.js +216 -0
- package/dist/__tests__/integration/property-based.test.js.map +1 -0
- package/dist/__tests__/integration/resiliency.test.d.ts +2 -0
- package/dist/__tests__/integration/resiliency.test.d.ts.map +1 -0
- package/dist/__tests__/integration/resiliency.test.js +146 -0
- package/dist/__tests__/integration/resiliency.test.js.map +1 -0
- package/dist/__tests__/integration/society-flow.test.d.ts +2 -0
- package/dist/__tests__/integration/society-flow.test.d.ts.map +1 -0
- package/dist/__tests__/integration/society-flow.test.js +69 -0
- package/dist/__tests__/integration/society-flow.test.js.map +1 -0
- package/dist/__tests__/observability/events.test.d.ts +2 -0
- package/dist/__tests__/observability/events.test.d.ts.map +1 -0
- package/dist/__tests__/observability/events.test.js +82 -0
- package/dist/__tests__/observability/events.test.js.map +1 -0
- package/dist/__tests__/utils/loop-json.test.d.ts +2 -0
- package/dist/__tests__/utils/loop-json.test.d.ts.map +1 -0
- package/dist/__tests__/utils/loop-json.test.js +112 -0
- package/dist/__tests__/utils/loop-json.test.js.map +1 -0
- package/dist/__tests__/utils/mock-model.d.ts +17 -0
- package/dist/__tests__/utils/mock-model.d.ts.map +1 -0
- package/dist/__tests__/utils/mock-model.js +45 -0
- package/dist/__tests__/utils/mock-model.js.map +1 -0
- package/dist/__tests__/utils/property-testing.d.ts +28 -0
- package/dist/__tests__/utils/property-testing.d.ts.map +1 -0
- package/dist/__tests__/utils/property-testing.js +220 -0
- package/dist/__tests__/utils/property-testing.js.map +1 -0
- package/dist/__tests__/utils/retry-worker-pool.test.d.ts +2 -0
- package/dist/__tests__/utils/retry-worker-pool.test.d.ts.map +1 -0
- package/dist/__tests__/utils/retry-worker-pool.test.js +198 -0
- package/dist/__tests__/utils/retry-worker-pool.test.js.map +1 -0
- package/dist/adapters/index.d.ts +3 -0
- package/dist/adapters/index.d.ts.map +1 -0
- package/dist/adapters/index.js +8 -0
- package/dist/adapters/index.js.map +1 -0
- package/dist/adapters/storage-postgres.d.ts +27 -0
- package/dist/adapters/storage-postgres.d.ts.map +1 -0
- package/dist/adapters/storage-postgres.js +109 -0
- package/dist/adapters/storage-postgres.js.map +1 -0
- package/dist/adapters/storage-redis.d.ts +25 -0
- package/dist/adapters/storage-redis.d.ts.map +1 -0
- package/dist/adapters/storage-redis.js +57 -0
- package/dist/adapters/storage-redis.js.map +1 -0
- package/dist/agents/agent-executor.d.ts +22 -0
- package/dist/agents/agent-executor.d.ts.map +1 -0
- package/dist/agents/agent-executor.js +183 -0
- package/dist/agents/agent-executor.js.map +1 -0
- package/dist/agents/society-executor.d.ts +11 -0
- package/dist/agents/society-executor.d.ts.map +1 -0
- package/dist/agents/society-executor.js +187 -0
- package/dist/agents/society-executor.js.map +1 -0
- package/dist/bin/inspect.d.ts +3 -0
- package/dist/bin/inspect.d.ts.map +1 -0
- package/dist/bin/inspect.js +99 -0
- package/dist/bin/inspect.js.map +1 -0
- package/dist/builders/agent-builder.d.ts +11 -4
- package/dist/builders/agent-builder.d.ts.map +1 -1
- package/dist/builders/agent-builder.js +18 -0
- package/dist/builders/agent-builder.js.map +1 -1
- package/dist/builders/builder.d.ts +3 -2
- package/dist/builders/builder.d.ts.map +1 -1
- package/dist/builders/builder.js +10 -9
- package/dist/builders/builder.js.map +1 -1
- package/dist/builders/role-builder.d.ts +2 -2
- package/dist/builders/role-builder.d.ts.map +1 -1
- package/dist/builders/society-builder.d.ts +102 -0
- package/dist/builders/society-builder.d.ts.map +1 -0
- package/dist/builders/society-builder.js +345 -0
- package/dist/builders/society-builder.js.map +1 -0
- package/dist/capabilities/memory.d.ts +3 -0
- package/dist/capabilities/memory.d.ts.map +1 -1
- package/dist/capabilities/memory.js +25 -2
- package/dist/capabilities/memory.js.map +1 -1
- package/dist/capabilities/self-correcting-validator.d.ts +50 -0
- package/dist/capabilities/self-correcting-validator.d.ts.map +1 -0
- package/dist/capabilities/self-correcting-validator.js +236 -0
- package/dist/capabilities/self-correcting-validator.js.map +1 -0
- package/dist/capabilities/tools.d.ts +2 -13
- package/dist/capabilities/tools.d.ts.map +1 -1
- package/dist/capabilities/tools.js +5 -1
- package/dist/capabilities/tools.js.map +1 -1
- package/dist/capabilities/validation.d.ts +5 -0
- package/dist/capabilities/validation.d.ts.map +1 -1
- package/dist/capabilities/validation.js +128 -21
- package/dist/capabilities/validation.js.map +1 -1
- package/dist/capabilities/vector-store.d.ts +61 -0
- package/dist/capabilities/vector-store.d.ts.map +1 -0
- package/dist/capabilities/vector-store.js +154 -0
- package/dist/capabilities/vector-store.js.map +1 -0
- package/dist/core/config.d.ts +3 -3
- package/dist/core/config.d.ts.map +1 -1
- package/dist/core/errors.d.ts +26 -2
- package/dist/core/errors.d.ts.map +1 -1
- package/dist/core/errors.js +78 -4
- package/dist/core/errors.js.map +1 -1
- package/dist/core/middleware.d.ts +6 -5
- package/dist/core/middleware.d.ts.map +1 -1
- package/dist/core/middleware.js +9 -0
- package/dist/core/middleware.js.map +1 -1
- package/dist/core/persistence.d.ts +37 -0
- package/dist/core/persistence.d.ts.map +1 -0
- package/dist/core/persistence.js +115 -0
- package/dist/core/persistence.js.map +1 -0
- package/dist/core/society.d.ts +55 -0
- package/dist/core/society.d.ts.map +1 -0
- package/dist/core/society.js +316 -0
- package/dist/core/society.js.map +1 -0
- package/dist/core/types.d.ts +50 -137
- package/dist/core/types.d.ts.map +1 -1
- package/dist/core/types.js +0 -16
- package/dist/core/types.js.map +1 -1
- package/dist/execution/engine/execution-engine.d.ts +110 -0
- package/dist/execution/engine/execution-engine.d.ts.map +1 -0
- package/dist/execution/engine/execution-engine.js +721 -0
- package/dist/execution/engine/execution-engine.js.map +1 -0
- package/dist/execution/engine-as-model.d.ts +29 -0
- package/dist/execution/engine-as-model.d.ts.map +1 -0
- package/dist/execution/engine-as-model.js +85 -0
- package/dist/execution/engine-as-model.js.map +1 -0
- package/dist/execution/graph-visualizer.d.ts +6 -0
- package/dist/execution/graph-visualizer.d.ts.map +1 -0
- package/dist/execution/graph-visualizer.js +76 -0
- package/dist/execution/graph-visualizer.js.map +1 -0
- package/dist/index.d.ts +12 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +30 -34
- package/dist/index.js.map +1 -1
- package/dist/observability/events.d.ts +19 -23
- package/dist/observability/events.d.ts.map +1 -1
- package/dist/observability/events.js +18 -20
- package/dist/observability/events.js.map +1 -1
- package/dist/utils/json.d.ts +2 -0
- package/dist/utils/json.d.ts.map +1 -0
- package/dist/utils/json.js +54 -0
- package/dist/utils/json.js.map +1 -0
- package/dist/utils/loop-controller.d.ts +12 -0
- package/dist/utils/loop-controller.d.ts.map +1 -0
- package/dist/utils/loop-controller.js +30 -0
- package/dist/utils/loop-controller.js.map +1 -0
- package/dist/utils/worker-pool.d.ts +10 -0
- package/dist/utils/worker-pool.d.ts.map +1 -1
- package/dist/utils/worker-pool.js +55 -1
- package/dist/utils/worker-pool.js.map +1 -1
- package/package.json +25 -8
- package/CHANGELOG.md +0 -111
- package/docs/ARCHITECTURE.md +0 -358
- package/docs/README.md +0 -214
- package/docs/advanced.md +0 -628
- package/docs/aggregation-strategies.md +0 -926
- package/docs/api-reference.md +0 -771
- package/docs/context-system.md +0 -642
- package/docs/event-system.md +0 -1047
- package/docs/examples.md +0 -585
- package/docs/getting-started.md +0 -564
- package/docs/graph-execution.md +0 -389
- package/docs/memory-system.md +0 -497
- package/docs/metrics-observability.md +0 -560
- package/docs/middleware-system.md +0 -1038
- package/docs/pipeline-patterns.md +0 -761
- package/docs/structured-output.md +0 -612
- package/docs/tool-calling.md +0 -491
- package/docs/workflows.md +0 -740
- package/examples/README.md +0 -88
- package/examples/complete-integration.ts +0 -53
- package/examples/getting-started.ts +0 -145
- package/examples/graph-workflow.ts +0 -41
- package/examples/memory-system.ts +0 -24
- package/examples/metrics-tracking.ts +0 -32
- package/examples/structured-output.ts +0 -24
- package/examples/tool-calling.ts +0 -41
- package/examples/utils.ts +0 -20
package/README.md
CHANGED
|
@@ -5,43 +5,69 @@
|
|
|
5
5
|
[](https://www.typescriptlang.org/)
|
|
6
6
|
[](package.json)
|
|
7
7
|
|
|
8
|
-
**SocietyAI** is a powerful TypeScript library for
|
|
9
|
-
multi-agent
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
- **
|
|
24
|
-
|
|
25
|
-
- **
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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
|
-
|
|
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
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
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
|
-
###
|
|
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
|
-
|
|
124
|
+
const model = new OpenAIModel(process.env.OPENAI_API_KEY);
|
|
125
|
+
|
|
126
|
+
// Create the Society
|
|
60
127
|
const result = await Society.create()
|
|
61
|
-
.withId('
|
|
128
|
+
.withId('blog-team')
|
|
129
|
+
|
|
130
|
+
// -- Define Agents --
|
|
62
131
|
.addAgent((agent) =>
|
|
63
132
|
agent
|
|
64
|
-
.withId('
|
|
133
|
+
.withId('writer')
|
|
65
134
|
.withRole((role) =>
|
|
66
135
|
role
|
|
67
|
-
.
|
|
68
|
-
.withSystemPrompt('You
|
|
136
|
+
.withName('Technical Writer')
|
|
137
|
+
.withSystemPrompt('You are an expert in concise technical writing.')
|
|
69
138
|
)
|
|
70
|
-
.withModel(
|
|
139
|
+
.withModel(model)
|
|
71
140
|
)
|
|
72
|
-
.
|
|
73
|
-
|
|
74
|
-
.withId('
|
|
75
|
-
.
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
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
|
-
|
|
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
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
182
|
+
## ๐ Documentation
|
|
134
183
|
|
|
135
|
-
|
|
184
|
+
Explore detailed documentation in the `/docs` folder:
|
|
136
185
|
|
|
137
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
##
|
|
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
|
-
|
|
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
|
|
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
|
package/bin/societyai.js
ADDED
|
@@ -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 @@
|
|
|
1
|
+
{"version":3,"file":"builders-coverage.test.d.ts","sourceRoot":"","sources":["../../../src/__tests__/builders/builders-coverage.test.ts"],"names":[],"mappings":""}
|