network-ai 3.0.0
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/LICENSE +21 -0
- package/QUICKSTART.md +260 -0
- package/README.md +604 -0
- package/SKILL.md +568 -0
- package/dist/adapters/adapter-registry.d.ts +94 -0
- package/dist/adapters/adapter-registry.d.ts.map +1 -0
- package/dist/adapters/adapter-registry.js +355 -0
- package/dist/adapters/adapter-registry.js.map +1 -0
- package/dist/adapters/agno-adapter.d.ts +112 -0
- package/dist/adapters/agno-adapter.d.ts.map +1 -0
- package/dist/adapters/agno-adapter.js +140 -0
- package/dist/adapters/agno-adapter.js.map +1 -0
- package/dist/adapters/autogen-adapter.d.ts +67 -0
- package/dist/adapters/autogen-adapter.d.ts.map +1 -0
- package/dist/adapters/autogen-adapter.js +141 -0
- package/dist/adapters/autogen-adapter.js.map +1 -0
- package/dist/adapters/base-adapter.d.ts +51 -0
- package/dist/adapters/base-adapter.d.ts.map +1 -0
- package/dist/adapters/base-adapter.js +103 -0
- package/dist/adapters/base-adapter.js.map +1 -0
- package/dist/adapters/crewai-adapter.d.ts +72 -0
- package/dist/adapters/crewai-adapter.d.ts.map +1 -0
- package/dist/adapters/crewai-adapter.js +148 -0
- package/dist/adapters/crewai-adapter.js.map +1 -0
- package/dist/adapters/custom-adapter.d.ts +74 -0
- package/dist/adapters/custom-adapter.d.ts.map +1 -0
- package/dist/adapters/custom-adapter.js +142 -0
- package/dist/adapters/custom-adapter.js.map +1 -0
- package/dist/adapters/dspy-adapter.d.ts +70 -0
- package/dist/adapters/dspy-adapter.d.ts.map +1 -0
- package/dist/adapters/dspy-adapter.js +127 -0
- package/dist/adapters/dspy-adapter.js.map +1 -0
- package/dist/adapters/haystack-adapter.d.ts +83 -0
- package/dist/adapters/haystack-adapter.d.ts.map +1 -0
- package/dist/adapters/haystack-adapter.js +149 -0
- package/dist/adapters/haystack-adapter.js.map +1 -0
- package/dist/adapters/index.d.ts +47 -0
- package/dist/adapters/index.d.ts.map +1 -0
- package/dist/adapters/index.js +56 -0
- package/dist/adapters/index.js.map +1 -0
- package/dist/adapters/langchain-adapter.d.ts +51 -0
- package/dist/adapters/langchain-adapter.d.ts.map +1 -0
- package/dist/adapters/langchain-adapter.js +134 -0
- package/dist/adapters/langchain-adapter.js.map +1 -0
- package/dist/adapters/llamaindex-adapter.d.ts +89 -0
- package/dist/adapters/llamaindex-adapter.d.ts.map +1 -0
- package/dist/adapters/llamaindex-adapter.js +135 -0
- package/dist/adapters/llamaindex-adapter.js.map +1 -0
- package/dist/adapters/mcp-adapter.d.ts +90 -0
- package/dist/adapters/mcp-adapter.d.ts.map +1 -0
- package/dist/adapters/mcp-adapter.js +200 -0
- package/dist/adapters/mcp-adapter.js.map +1 -0
- package/dist/adapters/openai-assistants-adapter.d.ts +94 -0
- package/dist/adapters/openai-assistants-adapter.d.ts.map +1 -0
- package/dist/adapters/openai-assistants-adapter.js +130 -0
- package/dist/adapters/openai-assistants-adapter.js.map +1 -0
- package/dist/adapters/openclaw-adapter.d.ts +21 -0
- package/dist/adapters/openclaw-adapter.d.ts.map +1 -0
- package/dist/adapters/openclaw-adapter.js +140 -0
- package/dist/adapters/openclaw-adapter.js.map +1 -0
- package/dist/adapters/semantic-kernel-adapter.d.ts +73 -0
- package/dist/adapters/semantic-kernel-adapter.d.ts.map +1 -0
- package/dist/adapters/semantic-kernel-adapter.js +123 -0
- package/dist/adapters/semantic-kernel-adapter.js.map +1 -0
- package/dist/index.d.ts +379 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1428 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/blackboard-validator.d.ts +205 -0
- package/dist/lib/blackboard-validator.d.ts.map +1 -0
- package/dist/lib/blackboard-validator.js +756 -0
- package/dist/lib/blackboard-validator.js.map +1 -0
- package/dist/lib/locked-blackboard.d.ts +174 -0
- package/dist/lib/locked-blackboard.d.ts.map +1 -0
- package/dist/lib/locked-blackboard.js +654 -0
- package/dist/lib/locked-blackboard.js.map +1 -0
- package/dist/lib/swarm-utils.d.ts +136 -0
- package/dist/lib/swarm-utils.d.ts.map +1 -0
- package/dist/lib/swarm-utils.js +510 -0
- package/dist/lib/swarm-utils.js.map +1 -0
- package/dist/security.d.ts +269 -0
- package/dist/security.d.ts.map +1 -0
- package/dist/security.js +713 -0
- package/dist/security.js.map +1 -0
- package/package.json +84 -0
- package/scripts/blackboard.py +819 -0
- package/scripts/check_permission.py +331 -0
- package/scripts/revoke_token.py +243 -0
- package/scripts/swarm_guard.py +1140 -0
- package/scripts/validate_token.py +97 -0
- package/types/agent-adapter.d.ts +244 -0
- package/types/openclaw-core.d.ts +52 -0
package/README.md
ADDED
|
@@ -0,0 +1,604 @@
|
|
|
1
|
+
# Network-AI: Multi-Agent Orchestration Framework
|
|
2
|
+
|
|
3
|
+
**The plug-and-play AI agent orchestrator for TypeScript/Node.js -- connect 12 agent frameworks with zero glue code**
|
|
4
|
+
|
|
5
|
+
[](https://github.com/jovanSAPFIONEER/Network-AI/releases)
|
|
6
|
+
[](https://nodejs.org)
|
|
7
|
+
[](https://typescriptlang.org)
|
|
8
|
+
[](https://python.org)
|
|
9
|
+
[](LICENSE)
|
|
10
|
+
[](https://agentskills.io)
|
|
11
|
+
[](#testing)
|
|
12
|
+
[](#adapter-system)
|
|
13
|
+
|
|
14
|
+
> **Legacy Users:** This skill works with **Clawdbot** and **Moltbot** (now OpenClaw). If you're searching for *Moltbot Security*, *Clawdbot Swarm*, or *Moltbot multi-agent* -- you're in the right place!
|
|
15
|
+
|
|
16
|
+
Network-AI is a framework-agnostic multi-agent orchestrator that connects LLM agents across **12 frameworks** -- LangChain, AutoGen, CrewAI, OpenAI Assistants, LlamaIndex, Semantic Kernel, Haystack, DSPy, Agno, MCP, OpenClaw, and custom adapters. It provides shared blackboard coordination, built-in security (AES-256, HMAC tokens, rate limiting), content quality gates with hallucination detection, and agentic workflow patterns (parallel execution, voting, chaining). Zero dependencies per adapter -- bring your own framework SDK and start building multi-agent systems in minutes.
|
|
17
|
+
|
|
18
|
+
**Why Network-AI?**
|
|
19
|
+
- **Framework-agnostic** -- Not locked to one LLM provider or agent SDK
|
|
20
|
+
- **Production security** -- Encryption, audit trails, rate limiting built in
|
|
21
|
+
- **Swarm intelligence** -- Parallel execution, voting, chain-of-agents patterns
|
|
22
|
+
- **Zero config** -- Works out of the box with `createSwarmOrchestrator()`
|
|
23
|
+
|
|
24
|
+
## Hello World -- Get Running in 60 Seconds
|
|
25
|
+
|
|
26
|
+
```typescript
|
|
27
|
+
import { createSwarmOrchestrator, CustomAdapter } from './index';
|
|
28
|
+
|
|
29
|
+
// 1. Create an adapter and register your agent
|
|
30
|
+
const adapter = new CustomAdapter();
|
|
31
|
+
adapter.registerHandler('greeter', async (payload) => {
|
|
32
|
+
return { result: `Hello, ${payload.params.name}! Your task: ${payload.action}` };
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
// 2. Create the orchestrator
|
|
36
|
+
const orchestrator = createSwarmOrchestrator({
|
|
37
|
+
adapters: [{ adapter }],
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
// 3. Use the blackboard to coordinate
|
|
41
|
+
orchestrator.blackboard.write('status', { ready: true }, 'greeter');
|
|
42
|
+
|
|
43
|
+
// 4. Execute your agent through the adapter
|
|
44
|
+
const result = await adapter.executeAgent('greeter', {
|
|
45
|
+
action: 'welcome',
|
|
46
|
+
params: { name: 'World' },
|
|
47
|
+
}, { agentId: 'greeter' });
|
|
48
|
+
|
|
49
|
+
console.log(result.data); // "Hello, World! Your task: welcome"
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
That's it. No config files, no setup wizards. Add more agents, swap frameworks, layer on security -- all optional.
|
|
53
|
+
|
|
54
|
+
## Why This Exists -- The Multi-Agent Race Condition Problem
|
|
55
|
+
|
|
56
|
+
Most agent frameworks let you run multiple AI agents in parallel. None of them protect you when those agents write to the same resource at the same time.
|
|
57
|
+
|
|
58
|
+
**The "Bank Run" scenario:**
|
|
59
|
+
|
|
60
|
+
```
|
|
61
|
+
Agent A reads balance: $10,000
|
|
62
|
+
Agent B reads balance: $10,000 (same moment)
|
|
63
|
+
Agent A writes balance: $10,000 - $7,000 = $3,000
|
|
64
|
+
Agent B writes balance: $10,000 - $6,000 = $4,000 <-- Agent A's write is gone
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Both agents thought they had $10,000. Both spent from it. You just lost $3,000 to a race condition. This isn't theoretical -- it happens any time two LLM agents hit a shared database, file, or API concurrently.
|
|
68
|
+
|
|
69
|
+
**This is a split-brain problem.** Without concurrency control, your agents will:
|
|
70
|
+
- **Corrupt shared state** -- Two agents overwrite each other's blackboard entries
|
|
71
|
+
- **Double-spend budgets** -- Token costs exceed limits because agents don't see each other's spending
|
|
72
|
+
- **Produce contradictory outputs** -- Agent A says "approved", Agent B says "denied", both write to the same key
|
|
73
|
+
|
|
74
|
+
**How Network-AI prevents this:**
|
|
75
|
+
|
|
76
|
+
```typescript
|
|
77
|
+
// Atomic commit -- no other agent can read or write "account:balance" during this operation
|
|
78
|
+
const blackboard = new LockedBlackboard('.');
|
|
79
|
+
const changeId = blackboard.proposeChange('account:balance', { amount: 7000, type: 'debit' }, 'agent-a');
|
|
80
|
+
blackboard.validateChange(changeId); // Checks for conflicts
|
|
81
|
+
blackboard.commitChange(changeId); // Atomic write with file-system mutex
|
|
82
|
+
|
|
83
|
+
// Budget tracking -- hard ceiling on token spend
|
|
84
|
+
// Even if 5 agents run in parallel, total spend cannot exceed the budget
|
|
85
|
+
python scripts/swarm_guard.py budget-init --task-id "task_001" --budget 10000
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Network-AI wraps your agent swarm with **file-system mutexes**, **atomic commits**, and **token budget ceilings** so race conditions, double-spends, and split-brain writes simply cannot happen. This works with any framework -- LangChain, CrewAI, AutoGen, or anything else connected through the adapter system.
|
|
89
|
+
|
|
90
|
+
## Features
|
|
91
|
+
|
|
92
|
+
### Core Orchestration (Multi-Agent Coordination)
|
|
93
|
+
- **Agent-to-Agent Handoffs** -- Delegate tasks between sessions using OpenClaw's `sessions_send`
|
|
94
|
+
- **Permission Wall (AuthGuardian)** -- Gate access to sensitive APIs with justification-based approval
|
|
95
|
+
- **Shared Blackboard** -- Markdown-based coordination state for agent communication
|
|
96
|
+
- **Parallel Execution Patterns** -- Merge, vote, chain, and first-success synthesis strategies
|
|
97
|
+
- **Task Decomposition** -- Automatic breaking of complex tasks into parallel subtasks
|
|
98
|
+
|
|
99
|
+
### Plug-and-Play Adapter System (v3.0) -- 12 AI Agent Frameworks
|
|
100
|
+
- **AdapterRegistry** -- Route agents to the right framework automatically
|
|
101
|
+
- **OpenClaw Adapter** -- Native OpenClaw skill execution via `callSkill`
|
|
102
|
+
- **LangChain Adapter** -- Supports Runnables (`.invoke()`) and plain functions
|
|
103
|
+
- **AutoGen Adapter** -- Supports `.run()` and `.generateReply()` agents
|
|
104
|
+
- **CrewAI Adapter** -- Individual agents and full crew orchestration
|
|
105
|
+
- **MCP Adapter** -- Model Context Protocol tool handlers
|
|
106
|
+
- **LlamaIndex Adapter** -- Query engines, chat engines, and agent runners
|
|
107
|
+
- **Semantic Kernel Adapter** -- Microsoft SK kernels, functions, and planners
|
|
108
|
+
- **OpenAI Assistants Adapter** -- Assistants API with thread management
|
|
109
|
+
- **Haystack Adapter** -- Pipelines, agents, and components
|
|
110
|
+
- **DSPy Adapter** -- Modules, programs, and predictors
|
|
111
|
+
- **Agno Adapter** -- Agents, teams, and functions (formerly Phidata)
|
|
112
|
+
- **Custom Adapter** -- Register any function or HTTP endpoint as an agent
|
|
113
|
+
- **BaseAdapter** -- Extend to write your own adapter in minutes
|
|
114
|
+
|
|
115
|
+
### Content Quality Gate (AI Safety)
|
|
116
|
+
- **BlackboardValidator (Layer 1)** -- Rule-based validation at ~159K-1M ops/sec
|
|
117
|
+
- **QualityGateAgent (Layer 2)** -- AI-assisted review with quarantine system
|
|
118
|
+
- **Hallucination Detection** -- Catches vague, unsupported, or fabricated content
|
|
119
|
+
- **Dangerous Code Detection** -- Blocks `eval()`, `exec()`, `rm -rf`, and other risky patterns
|
|
120
|
+
- **Placeholder Rejection** -- Rejects TODO/FIXME/stub content from entering the blackboard
|
|
121
|
+
|
|
122
|
+
### Security Module (Defense-in-Depth)
|
|
123
|
+
- **HMAC-Signed Tokens** -- Cryptographic token generation with expiration
|
|
124
|
+
- **Input Sanitization** -- XSS, injection, path traversal, and prototype pollution prevention
|
|
125
|
+
- **Rate Limiting** -- Per-agent request throttling with lockout on failed auth
|
|
126
|
+
- **AES-256-GCM Encryption** -- Encrypt sensitive blackboard entries at rest
|
|
127
|
+
- **Privilege Escalation Prevention** -- Trust-ceiling enforcement
|
|
128
|
+
- **Cryptographic Audit Logs** -- Tamper-evident signed audit trail with chain continuation
|
|
129
|
+
- **Secure Gateway** -- Integrated security layer wrapping all operations
|
|
130
|
+
|
|
131
|
+
### Operational Safety
|
|
132
|
+
- **Swarm Guard** -- Prevents "Handoff Tax" (wasted tokens) and detects silent agent failures
|
|
133
|
+
- **Atomic Commits** -- File-system mutexes prevent split-brain in concurrent writes
|
|
134
|
+
- **Cost Awareness** -- Token budget tracking with automatic SafetyShutdown
|
|
135
|
+
- **Budget-Aware Handoffs** -- `intercept-handoff` command wraps `sessions_send` with budget checks
|
|
136
|
+
|
|
137
|
+
## Project Structure
|
|
138
|
+
|
|
139
|
+
```
|
|
140
|
+
Network-AI/
|
|
141
|
+
|-- index.ts # Core orchestrator (SwarmOrchestrator, SharedBlackboard, AuthGuardian, TaskDecomposer)
|
|
142
|
+
|-- security.ts # Security module (tokens, encryption, rate limiting, audit)
|
|
143
|
+
|-- setup.ts # Developer setup & installation checker
|
|
144
|
+
|-- package.json # NPM manifest & scripts
|
|
145
|
+
|-- tsconfig.json # TypeScript configuration
|
|
146
|
+
|-- skill.json # OpenClaw skill metadata
|
|
147
|
+
|-- SKILL.md # OpenClaw skill definition (frontmatter + instructions)
|
|
148
|
+
|-- QUICKSTART.md # 5-minute getting-started guide
|
|
149
|
+
|-- requirements.txt # Python dependencies
|
|
150
|
+
|-- swarm-blackboard.md # Runtime blackboard state (auto-generated)
|
|
151
|
+
|-- adapters/ # Plug-and-play agent framework adapters (12 frameworks)
|
|
152
|
+
| |-- index.ts # Barrel exports for all adapters
|
|
153
|
+
| |-- base-adapter.ts # Abstract base class for adapters
|
|
154
|
+
| |-- adapter-registry.ts # Multi-adapter routing & discovery
|
|
155
|
+
| |-- openclaw-adapter.ts # OpenClaw skill adapter
|
|
156
|
+
| |-- langchain-adapter.ts # LangChain adapter (Runnables & functions)
|
|
157
|
+
| |-- autogen-adapter.ts # AutoGen adapter (.run() & .generateReply())
|
|
158
|
+
| |-- crewai-adapter.ts # CrewAI adapter (agents & crews)
|
|
159
|
+
| |-- mcp-adapter.ts # MCP tool handler adapter
|
|
160
|
+
| |-- custom-adapter.ts # Custom function/HTTP agent adapter
|
|
161
|
+
| |-- llamaindex-adapter.ts # LlamaIndex adapter (query/chat engines, agent runners)
|
|
162
|
+
| |-- semantic-kernel-adapter.ts # Microsoft Semantic Kernel adapter
|
|
163
|
+
| |-- openai-assistants-adapter.ts # OpenAI Assistants API adapter
|
|
164
|
+
| |-- haystack-adapter.ts # deepset Haystack adapter (pipelines, agents)
|
|
165
|
+
| |-- dspy-adapter.ts # Stanford DSPy adapter (modules, programs)
|
|
166
|
+
| |-- agno-adapter.ts # Agno adapter (agents, teams -- formerly Phidata)
|
|
167
|
+
|-- types/ # TypeScript type definitions
|
|
168
|
+
| |-- agent-adapter.d.ts # Universal adapter interfaces (IAgentAdapter, AgentPayload, etc.)
|
|
169
|
+
| |-- openclaw-core.d.ts # OpenClaw-specific type stubs
|
|
170
|
+
|-- lib/ # TypeScript utilities
|
|
171
|
+
| |-- swarm-utils.ts # Node.js helper functions
|
|
172
|
+
| |-- locked-blackboard.ts # Atomic commits with file-system mutexes
|
|
173
|
+
| |-- blackboard-validator.ts # Content quality gate (BlackboardValidator + QualityGateAgent)
|
|
174
|
+
|-- scripts/ # Python helper scripts
|
|
175
|
+
| |-- check_permission.py # AuthGuardian permission checker
|
|
176
|
+
| |-- validate_token.py # Token validation
|
|
177
|
+
| |-- revoke_token.py # Token revocation
|
|
178
|
+
| |-- blackboard.py # Shared state management (with atomic commits)
|
|
179
|
+
| |-- swarm_guard.py # Handoff tax, failure prevention, & budget tracking
|
|
180
|
+
|-- references/ # Detailed documentation
|
|
181
|
+
| |-- adapter-system.md # Adapter architecture & writing custom adapters
|
|
182
|
+
| |-- auth-guardian.md # Permission system details
|
|
183
|
+
| |-- blackboard-schema.md # Data structures
|
|
184
|
+
| |-- trust-levels.md # Agent trust configuration
|
|
185
|
+
| |-- mcp-roadmap.md # MCP networking implementation plan
|
|
186
|
+
|-- test-standalone.ts # Core orchestrator tests (79 tests)
|
|
187
|
+
|-- test-security.ts # Security module tests (33 tests)
|
|
188
|
+
|-- test-adapters.ts # Adapter system tests (139 tests)
|
|
189
|
+
|-- test-ai-quality.ts # AI quality gate demo
|
|
190
|
+
|-- test.ts # Full integration test suite
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
## Quick Start
|
|
194
|
+
|
|
195
|
+
See [QUICKSTART.md](QUICKSTART.md) for a 5-minute getting-started guide.
|
|
196
|
+
|
|
197
|
+
## Installation
|
|
198
|
+
|
|
199
|
+
### For Development
|
|
200
|
+
|
|
201
|
+
```bash
|
|
202
|
+
git clone https://github.com/jovanSAPFIONEER/Network-AI
|
|
203
|
+
cd Network-AI
|
|
204
|
+
npm install # TypeScript dependencies
|
|
205
|
+
pip install -r requirements.txt # Python scripts (optional -- uses stdlib)
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
### Verify Installation
|
|
209
|
+
|
|
210
|
+
```bash
|
|
211
|
+
npm run setup:check # Check all files and dependencies
|
|
212
|
+
npm run setup -- --list # List all 12 available adapters
|
|
213
|
+
npm run setup:example # Generate a starter example.ts
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
### For OpenClaw Users
|
|
217
|
+
|
|
218
|
+
Copy this skill into your OpenClaw workspace:
|
|
219
|
+
|
|
220
|
+
```bash
|
|
221
|
+
cp -r Network-AI ~/.openclaw/workspace/skills/swarm-orchestrator
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
Or install via ClawHub (when available):
|
|
225
|
+
|
|
226
|
+
```bash
|
|
227
|
+
openclaw skills install swarm-orchestrator
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
## Usage
|
|
231
|
+
|
|
232
|
+
### TypeScript / Node.js API
|
|
233
|
+
|
|
234
|
+
#### Basic Setup
|
|
235
|
+
|
|
236
|
+
```typescript
|
|
237
|
+
import {
|
|
238
|
+
SwarmOrchestrator,
|
|
239
|
+
SharedBlackboard,
|
|
240
|
+
AuthGuardian,
|
|
241
|
+
createSwarmOrchestrator,
|
|
242
|
+
} from './index';
|
|
243
|
+
|
|
244
|
+
// Quick start with defaults
|
|
245
|
+
const orchestrator = createSwarmOrchestrator();
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
#### Using Adapters (Plug-and-Play)
|
|
249
|
+
|
|
250
|
+
```typescript
|
|
251
|
+
import {
|
|
252
|
+
createSwarmOrchestrator,
|
|
253
|
+
AdapterRegistry,
|
|
254
|
+
CustomAdapter,
|
|
255
|
+
LangChainAdapter,
|
|
256
|
+
} from './index';
|
|
257
|
+
|
|
258
|
+
// Create adapters
|
|
259
|
+
const custom = new CustomAdapter();
|
|
260
|
+
custom.registerHandler('my-agent', async (payload) => {
|
|
261
|
+
return { result: 'done' };
|
|
262
|
+
});
|
|
263
|
+
|
|
264
|
+
const langchain = new LangChainAdapter();
|
|
265
|
+
langchain.registerRunnable('researcher', myLangChainRunnable);
|
|
266
|
+
|
|
267
|
+
// Create orchestrator with adapters
|
|
268
|
+
const orchestrator = createSwarmOrchestrator({
|
|
269
|
+
adapters: [
|
|
270
|
+
{ adapter: custom },
|
|
271
|
+
{ adapter: langchain },
|
|
272
|
+
],
|
|
273
|
+
});
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
#### Blackboard & Permissions
|
|
277
|
+
|
|
278
|
+
```typescript
|
|
279
|
+
const blackboard = new SharedBlackboard('.');
|
|
280
|
+
blackboard.write('task:analysis', { status: 'running' }, 'orchestrator');
|
|
281
|
+
const data = blackboard.read('task:analysis');
|
|
282
|
+
|
|
283
|
+
const auth = new AuthGuardian();
|
|
284
|
+
const grant = auth.requestPermission('data_analyst', 'DATABASE', 'read',
|
|
285
|
+
'Need customer order history for sales report');
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
### Python Scripts
|
|
289
|
+
|
|
290
|
+
#### 1. Initialize Budget (First!)
|
|
291
|
+
|
|
292
|
+
```bash
|
|
293
|
+
python scripts/swarm_guard.py budget-init --task-id "task_001" --budget 10000
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
#### 2. Budget-Aware Handoffs
|
|
297
|
+
|
|
298
|
+
```bash
|
|
299
|
+
python scripts/swarm_guard.py intercept-handoff \
|
|
300
|
+
--task-id "task_001" \
|
|
301
|
+
--from orchestrator \
|
|
302
|
+
--to data_analyst \
|
|
303
|
+
--message "Analyze Q4 revenue data"
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
Output (if allowed):
|
|
307
|
+
```
|
|
308
|
+
HANDOFF ALLOWED: orchestrator -> data_analyst
|
|
309
|
+
Tokens spent: 156
|
|
310
|
+
Budget remaining: 9,844
|
|
311
|
+
Handoff #1 (remaining: 2)
|
|
312
|
+
-> Proceed with sessions_send
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
#### 3. Check Permissions
|
|
316
|
+
|
|
317
|
+
```bash
|
|
318
|
+
python scripts/check_permission.py \
|
|
319
|
+
--agent data_analyst \
|
|
320
|
+
--resource DATABASE \
|
|
321
|
+
--justification "Need customer order history for sales report"
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
Output:
|
|
325
|
+
```
|
|
326
|
+
GRANTED
|
|
327
|
+
Token: grant_85364b44d987...
|
|
328
|
+
Expires: 2026-02-04T15:30:00Z
|
|
329
|
+
Restrictions: read_only, max_records:100
|
|
330
|
+
```
|
|
331
|
+
|
|
332
|
+
#### 4. Use the Blackboard
|
|
333
|
+
|
|
334
|
+
```bash
|
|
335
|
+
# Write
|
|
336
|
+
python scripts/blackboard.py write "task:analysis" '{"status": "running"}'
|
|
337
|
+
|
|
338
|
+
# Read
|
|
339
|
+
python scripts/blackboard.py read "task:analysis"
|
|
340
|
+
|
|
341
|
+
# Atomic commit workflow (for multi-agent safety)
|
|
342
|
+
python scripts/blackboard.py propose "chg_001" "key" '{"value": 1}'
|
|
343
|
+
python scripts/blackboard.py validate "chg_001"
|
|
344
|
+
python scripts/blackboard.py commit "chg_001"
|
|
345
|
+
|
|
346
|
+
# List all keys
|
|
347
|
+
python scripts/blackboard.py list
|
|
348
|
+
```
|
|
349
|
+
|
|
350
|
+
#### 5. Check Budget Status
|
|
351
|
+
|
|
352
|
+
```bash
|
|
353
|
+
python scripts/swarm_guard.py budget-check --task-id "task_001"
|
|
354
|
+
python scripts/swarm_guard.py budget-report --task-id "task_001"
|
|
355
|
+
```
|
|
356
|
+
|
|
357
|
+
## Adapter System
|
|
358
|
+
|
|
359
|
+
The adapter system lets you plug any agent framework into the orchestrator. Each adapter implements the `IAgentAdapter` interface.
|
|
360
|
+
|
|
361
|
+
| Adapter | Framework | Agent Registration | Dependencies |
|
|
362
|
+
|---------|-----------|-------------------|-------------|
|
|
363
|
+
| `OpenClawAdapter` | OpenClaw | `registerSkill(name, skillRef)` | openclaw-core |
|
|
364
|
+
| `LangChainAdapter` | LangChain | `registerRunnable(name, runnable)` or `registerFunction(name, fn)` | None (BYOC) |
|
|
365
|
+
| `AutoGenAdapter` | AutoGen | `registerAgent(name, agent)` -- supports `.run()` and `.generateReply()` | None (BYOC) |
|
|
366
|
+
| `CrewAIAdapter` | CrewAI | `registerAgent(name, agent)` or `registerCrew(name, crew)` | None (BYOC) |
|
|
367
|
+
| `MCPAdapter` | MCP | `registerTool(name, handler)` | None (BYOC) |
|
|
368
|
+
| `LlamaIndexAdapter` | LlamaIndex | `registerQueryEngine()`, `registerChatEngine()`, `registerAgentRunner()` | None (BYOC) |
|
|
369
|
+
| `SemanticKernelAdapter` | Semantic Kernel | `registerKernel()`, `registerFunction()` | None (BYOC) |
|
|
370
|
+
| `OpenAIAssistantsAdapter` | OpenAI Assistants | `registerAssistant(name, config)` | None (BYOC) |
|
|
371
|
+
| `HaystackAdapter` | Haystack | `registerPipeline()`, `registerAgent()`, `registerComponent()` | None (BYOC) |
|
|
372
|
+
| `DSPyAdapter` | DSPy | `registerModule()`, `registerProgram()`, `registerPredictor()` | None (BYOC) |
|
|
373
|
+
| `AgnoAdapter` | Agno | `registerAgent()`, `registerTeam()`, `registerFunction()` | None (BYOC) |
|
|
374
|
+
| `CustomAdapter` | Any | `registerHandler(name, fn)` or `registerHttpAgent(name, config)` | None |
|
|
375
|
+
|
|
376
|
+
> **BYOC** = Bring Your Own Client. All adapters (except OpenClaw) are self-contained with zero npm dependencies. You provide your framework's SDK objects and the adapter wraps them.
|
|
377
|
+
|
|
378
|
+
### Writing a Custom Adapter
|
|
379
|
+
|
|
380
|
+
Extend `BaseAdapter`:
|
|
381
|
+
|
|
382
|
+
```typescript
|
|
383
|
+
import { BaseAdapter } from './adapters/base-adapter';
|
|
384
|
+
import type { AgentPayload, AgentResult } from './types/agent-adapter';
|
|
385
|
+
|
|
386
|
+
class MyAdapter extends BaseAdapter {
|
|
387
|
+
readonly name = 'my-framework';
|
|
388
|
+
|
|
389
|
+
async executeAgent(agentId: string, payload: AgentPayload): Promise<AgentResult> {
|
|
390
|
+
// Your framework-specific logic here
|
|
391
|
+
return { success: true, output: 'result', metadata: { adapter: this.name } };
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
async listAgents() { return []; }
|
|
395
|
+
async isAgentAvailable(id: string) { return true; }
|
|
396
|
+
}
|
|
397
|
+
```
|
|
398
|
+
|
|
399
|
+
See [references/adapter-system.md](references/adapter-system.md) for the full adapter architecture guide.
|
|
400
|
+
|
|
401
|
+
## Permission System
|
|
402
|
+
|
|
403
|
+
The AuthGuardian evaluates requests using:
|
|
404
|
+
|
|
405
|
+
| Factor | Weight | Description |
|
|
406
|
+
|--------|--------|-------------|
|
|
407
|
+
| Justification | 40% | Quality of business reason |
|
|
408
|
+
| Trust Level | 30% | Agent's established trust |
|
|
409
|
+
| Risk Assessment | 30% | Resource sensitivity + scope |
|
|
410
|
+
|
|
411
|
+
**Approval threshold: 0.5**
|
|
412
|
+
|
|
413
|
+
### Resource Types
|
|
414
|
+
|
|
415
|
+
| Resource | Base Risk | Default Restrictions |
|
|
416
|
+
|----------|-----------|---------------------|
|
|
417
|
+
| `DATABASE` | 0.5 | `read_only`, `max_records:100` |
|
|
418
|
+
| `PAYMENTS` | 0.7 | `read_only`, `no_pii_fields`, `audit_required` |
|
|
419
|
+
| `EMAIL` | 0.4 | `rate_limit:10_per_minute` |
|
|
420
|
+
| `FILE_EXPORT` | 0.6 | `anonymize_pii`, `local_only` |
|
|
421
|
+
|
|
422
|
+
## Security Module
|
|
423
|
+
|
|
424
|
+
The security module ([security.ts](security.ts)) provides defense-in-depth protections:
|
|
425
|
+
|
|
426
|
+
| Component | Class | Purpose |
|
|
427
|
+
|-----------|-------|---------|
|
|
428
|
+
| Token Manager | `SecureTokenManager` | HMAC-signed tokens with expiration |
|
|
429
|
+
| Input Sanitizer | `InputSanitizer` | XSS, injection, traversal prevention |
|
|
430
|
+
| Rate Limiter | `RateLimiter` | Per-agent request throttling + lockout |
|
|
431
|
+
| Encryptor | `DataEncryptor` | AES-256-GCM encryption for sensitive data |
|
|
432
|
+
| Permission Hardener | `PermissionHardener` | Trust-ceiling & privilege escalation prevention |
|
|
433
|
+
| Audit Logger | `SecureAuditLogger` | Cryptographically signed audit entries |
|
|
434
|
+
| Gateway | `SecureSwarmGateway` | Integrated security layer wrapping all ops |
|
|
435
|
+
|
|
436
|
+
## Agent Trust Levels
|
|
437
|
+
|
|
438
|
+
| Agent | Trust | Role |
|
|
439
|
+
|-------|-------|------|
|
|
440
|
+
| `orchestrator` | 0.9 | Primary coordinator |
|
|
441
|
+
| `risk_assessor` | 0.85 | Compliance specialist |
|
|
442
|
+
| `data_analyst` | 0.8 | Data processing |
|
|
443
|
+
| `strategy_advisor` | 0.7 | Business strategy |
|
|
444
|
+
| Unknown | 0.5 | Default |
|
|
445
|
+
|
|
446
|
+
## Handoff Protocol
|
|
447
|
+
|
|
448
|
+
Format messages for delegation:
|
|
449
|
+
|
|
450
|
+
```
|
|
451
|
+
[HANDOFF]
|
|
452
|
+
Instruction: Analyze monthly sales by product category
|
|
453
|
+
Context: Using database export from ./data/sales_export.csv
|
|
454
|
+
Constraints: Focus on top 5 categories only
|
|
455
|
+
Expected Output: JSON summary with category, revenue, growth_pct
|
|
456
|
+
[/HANDOFF]
|
|
457
|
+
```
|
|
458
|
+
|
|
459
|
+
## Testing
|
|
460
|
+
|
|
461
|
+
Run all test suites:
|
|
462
|
+
|
|
463
|
+
```bash
|
|
464
|
+
# All tests at once
|
|
465
|
+
npm run test:all
|
|
466
|
+
|
|
467
|
+
# Core orchestrator tests (79 tests)
|
|
468
|
+
npm test
|
|
469
|
+
|
|
470
|
+
# Security module tests (33 tests)
|
|
471
|
+
npm run test:security
|
|
472
|
+
|
|
473
|
+
# Adapter system tests (139 tests)
|
|
474
|
+
npm run test:adapters
|
|
475
|
+
|
|
476
|
+
# Full integration tests
|
|
477
|
+
npx ts-node test.ts
|
|
478
|
+
```
|
|
479
|
+
|
|
480
|
+
Test Python scripts:
|
|
481
|
+
|
|
482
|
+
```bash
|
|
483
|
+
# Test permission system
|
|
484
|
+
python scripts/check_permission.py --agent orchestrator --resource PAYMENTS \
|
|
485
|
+
--justification "Generating monthly revenue report for management" --json
|
|
486
|
+
|
|
487
|
+
# Test blackboard
|
|
488
|
+
python scripts/blackboard.py write "test:key" '{"value": 123}' --ttl 60
|
|
489
|
+
python scripts/blackboard.py read "test:key"
|
|
490
|
+
|
|
491
|
+
# Test TTL cleanup
|
|
492
|
+
python scripts/revoke_token.py --list-expired
|
|
493
|
+
python scripts/revoke_token.py --cleanup
|
|
494
|
+
```
|
|
495
|
+
|
|
496
|
+
**Test results (251 total):**
|
|
497
|
+
- `test-standalone.ts` -- 79 passed (blackboard, auth, integration, persistence, parallelization, coding domain, quality gate)
|
|
498
|
+
- `test-security.ts` -- 33 passed (tokens, sanitization, rate limiting, encryption, permissions, audit)
|
|
499
|
+
- `test-adapters.ts` -- 139 passed (12 adapters: Custom, LangChain, AutoGen, CrewAI, MCP, LlamaIndex, Semantic Kernel, OpenAI Assistants, Haystack, DSPy, Agno + registry routing, integration, edge cases)
|
|
500
|
+
|
|
501
|
+
## Audit Trail
|
|
502
|
+
|
|
503
|
+
Logged events: `permission_granted`, `permission_denied`, `permission_revoked`, `ttl_cleanup`, `result_validated`
|
|
504
|
+
|
|
505
|
+
The security module's `SecureAuditLogger` produces cryptographically signed entries that can be verified for tamper detection.
|
|
506
|
+
|
|
507
|
+
## Documentation
|
|
508
|
+
|
|
509
|
+
- [QUICKSTART.md](QUICKSTART.md) -- 5-minute getting-started guide
|
|
510
|
+
- [SKILL.md](SKILL.md) -- Main skill instructions (includes Orchestrator protocol)
|
|
511
|
+
- [references/adapter-system.md](references/adapter-system.md) -- Adapter architecture & writing custom adapters
|
|
512
|
+
- [references/auth-guardian.md](references/auth-guardian.md) -- Permission system details
|
|
513
|
+
- [references/blackboard-schema.md](references/blackboard-schema.md) -- Data structures
|
|
514
|
+
- [references/trust-levels.md](references/trust-levels.md) -- Trust configuration
|
|
515
|
+
- [references/mcp-roadmap.md](references/mcp-roadmap.md) -- MCP networking implementation plan
|
|
516
|
+
|
|
517
|
+
## Configuration
|
|
518
|
+
|
|
519
|
+
### Modify Trust Levels
|
|
520
|
+
|
|
521
|
+
Edit `scripts/check_permission.py`:
|
|
522
|
+
|
|
523
|
+
```python
|
|
524
|
+
DEFAULT_TRUST_LEVELS = {
|
|
525
|
+
"orchestrator": 0.9,
|
|
526
|
+
"my_new_agent": 0.75, # Add your agent
|
|
527
|
+
}
|
|
528
|
+
```
|
|
529
|
+
|
|
530
|
+
### Adjust Token TTL
|
|
531
|
+
|
|
532
|
+
```python
|
|
533
|
+
GRANT_TOKEN_TTL_MINUTES = 5 # Change as needed
|
|
534
|
+
```
|
|
535
|
+
|
|
536
|
+
## Exports
|
|
537
|
+
|
|
538
|
+
The module exports everything needed for programmatic use:
|
|
539
|
+
|
|
540
|
+
```typescript
|
|
541
|
+
// Core classes
|
|
542
|
+
import SwarmOrchestrator, { SharedBlackboard, AuthGuardian, TaskDecomposer } from './index';
|
|
543
|
+
import { BlackboardValidator, QualityGateAgent } from './index';
|
|
544
|
+
|
|
545
|
+
// Factory
|
|
546
|
+
import { createSwarmOrchestrator } from './index';
|
|
547
|
+
|
|
548
|
+
// Adapters (all 12)
|
|
549
|
+
import {
|
|
550
|
+
AdapterRegistry, BaseAdapter,
|
|
551
|
+
OpenClawAdapter, LangChainAdapter, AutoGenAdapter,
|
|
552
|
+
CrewAIAdapter, MCPAdapter, CustomAdapter,
|
|
553
|
+
LlamaIndexAdapter, SemanticKernelAdapter, OpenAIAssistantsAdapter,
|
|
554
|
+
HaystackAdapter, DSPyAdapter, AgnoAdapter,
|
|
555
|
+
} from './index';
|
|
556
|
+
|
|
557
|
+
// Types
|
|
558
|
+
import type {
|
|
559
|
+
IAgentAdapter, AgentPayload, AgentContext, AgentResult, AgentInfo,
|
|
560
|
+
AdapterConfig, AdapterCapabilities,
|
|
561
|
+
TaskPayload, HandoffMessage, PermissionGrant, SwarmState,
|
|
562
|
+
AgentStatus, ParallelTask, ParallelExecutionResult, SynthesisStrategy,
|
|
563
|
+
} from './index';
|
|
564
|
+
```
|
|
565
|
+
|
|
566
|
+
## License
|
|
567
|
+
|
|
568
|
+
MIT License -- See [LICENSE](LICENSE)
|
|
569
|
+
|
|
570
|
+
## Contributing
|
|
571
|
+
|
|
572
|
+
1. Fork the repository
|
|
573
|
+
2. Create a feature branch
|
|
574
|
+
3. Make your changes
|
|
575
|
+
4. Run all tests (`npm run test:all`)
|
|
576
|
+
5. Submit a pull request
|
|
577
|
+
|
|
578
|
+
---
|
|
579
|
+
|
|
580
|
+
**Compatible with 12 agent frameworks: OpenClaw, LangChain, AutoGen, CrewAI, MCP, LlamaIndex, Semantic Kernel, OpenAI Assistants, Haystack, DSPy, Agno, and any custom adapter**
|
|
581
|
+
|
|
582
|
+
## Related Concepts
|
|
583
|
+
|
|
584
|
+
Network-AI fits into the broader AI agent ecosystem:
|
|
585
|
+
|
|
586
|
+
- **Multi-Agent Systems** -- Coordinate multiple AI agents working together on complex tasks
|
|
587
|
+
- **Agentic AI** -- Build autonomous agents that reason, plan, and execute using LLMs
|
|
588
|
+
- **Swarm Intelligence** -- Parallel execution patterns with voting, merging, and chain strategies
|
|
589
|
+
- **Model Context Protocol (MCP)** -- Standard protocol support for LLM tool integration
|
|
590
|
+
- **Agent-to-Agent (A2A)** -- Inter-agent communication via shared blackboard and handoff protocol
|
|
591
|
+
- **Context Engineering** -- Manage and share context across agent boundaries
|
|
592
|
+
- **Agentic Workflows** -- Task decomposition, parallel processing, and synthesis pipelines
|
|
593
|
+
- **LLM Orchestration** -- Route tasks to the right agent framework automatically
|
|
594
|
+
|
|
595
|
+
If you're using LangGraph, Dify, Flowise, PraisonAI, AutoGen/AG2, CrewAI, or any other agent framework, Network-AI can integrate with it through the adapter system.
|
|
596
|
+
|
|
597
|
+
---
|
|
598
|
+
|
|
599
|
+
<details>
|
|
600
|
+
<summary>Keywords (for search)</summary>
|
|
601
|
+
|
|
602
|
+
ai-agents, agentic-ai, multi-agent, multi-agent-systems, multi-agent-system, agent-framework, ai-agent-framework, agentic-framework, agentic-workflow, llm, llm-agents, llm-agent, large-language-models, generative-ai, genai, orchestration, ai-orchestration, swarm, swarm-intelligence, autonomous-agents, agents, ai, typescript, nodejs, mcp, model-context-protocol, a2a, agent-to-agent, function-calling, tool-integration, context-engineering, rag, ai-safety, multi-agents-collaboration, multi-agents, aiagents, aiagentframework, plug-and-play, adapter-registry, blackboard-pattern, agent-coordination, agent-handoffs, token-permissions, budget-tracking, cost-awareness, atomic-commits, hallucination-detection, content-quality-gate, OpenClaw, Clawdbot, Moltbot, Clawdbot Swarm, Moltbot Security, Moltbot multi-agent, OpenClaw skills, AgentSkills, LangChain adapter, LangGraph, AutoGen adapter, AG2, CrewAI adapter, MCP adapter, LlamaIndex adapter, Semantic Kernel adapter, OpenAI Assistants adapter, Haystack adapter, DSPy adapter, Agno adapter, Phidata adapter, Dify, Flowise, PraisonAI, custom-adapter, AES-256 encryption, HMAC tokens, rate limiting, input sanitization, privilege escalation prevention, agentic-rag, deep-research, workflow-orchestration, ai-assistant, ai-tools, developer-tools, open-source
|
|
603
|
+
|
|
604
|
+
</details>
|