network-ai 4.0.12 → 4.0.14
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/QUICKSTART.md +170 -0
- package/README.md +120 -1031
- package/SKILL.md +4 -4
- package/bin/mcp-server.ts +3 -3
- package/dist/bin/mcp-server.d.ts +1 -1
- package/dist/bin/mcp-server.js +3 -3
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/lib/mcp-transport-sse.js +1 -1
- package/package.json +1 -1
package/QUICKSTART.md
CHANGED
|
@@ -258,3 +258,173 @@ Your App
|
|
|
258
258
|
---
|
|
259
259
|
|
|
260
260
|
**Questions?** Open an issue at [github.com/jovanSAPFIONEER/Network-AI](https://github.com/jovanSAPFIONEER/Network-AI)
|
|
261
|
+
|
|
262
|
+
---
|
|
263
|
+
|
|
264
|
+
## PowerShell (Windows)
|
|
265
|
+
|
|
266
|
+
All commands work in PowerShell. The only difference from bash is environment variable syntax.
|
|
267
|
+
|
|
268
|
+
```powershell
|
|
269
|
+
# Set your API key for the current session
|
|
270
|
+
$env:OPENAI_API_KEY = "sk-..."
|
|
271
|
+
|
|
272
|
+
# Or copy the template and fill it in
|
|
273
|
+
Copy-Item .env.example .env
|
|
274
|
+
|
|
275
|
+
# Run examples (no API key needed)
|
|
276
|
+
npx ts-node examples/01-hello-swarm.ts
|
|
277
|
+
npx ts-node examples/02-fsm-pipeline.ts
|
|
278
|
+
npx ts-node examples/03-parallel-agents.ts
|
|
279
|
+
|
|
280
|
+
# Interactive example launcher
|
|
281
|
+
npx ts-node run.ts
|
|
282
|
+
|
|
283
|
+
# Run tests
|
|
284
|
+
npm test
|
|
285
|
+
npm run test:all
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
To persist `OPENAI_API_KEY` across sessions, add it to your PowerShell profile or set it via *System Properties → Environment Variables*.
|
|
289
|
+
|
|
290
|
+
---
|
|
291
|
+
|
|
292
|
+
## Python Scripts CLI
|
|
293
|
+
|
|
294
|
+
The Python scripts in `scripts/` implement the local governance layer. All run locally — no network calls.
|
|
295
|
+
|
|
296
|
+
### Budget (always initialise first)
|
|
297
|
+
|
|
298
|
+
```bash
|
|
299
|
+
python scripts/swarm_guard.py budget-init --task-id "task_001" --budget 10000
|
|
300
|
+
python scripts/swarm_guard.py budget-check --task-id "task_001"
|
|
301
|
+
python scripts/swarm_guard.py budget-report --task-id "task_001"
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
### Budget-Aware Handoffs
|
|
305
|
+
|
|
306
|
+
```bash
|
|
307
|
+
python scripts/swarm_guard.py intercept-handoff \
|
|
308
|
+
--task-id "task_001" \
|
|
309
|
+
--from orchestrator \
|
|
310
|
+
--to data_analyst \
|
|
311
|
+
--message "Analyze Q4 revenue data"
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
### Blackboard
|
|
315
|
+
|
|
316
|
+
```bash
|
|
317
|
+
# Write
|
|
318
|
+
python scripts/blackboard.py write "task:analysis" '{"status": "running"}'
|
|
319
|
+
|
|
320
|
+
# Read
|
|
321
|
+
python scripts/blackboard.py read "task:analysis"
|
|
322
|
+
|
|
323
|
+
# Atomic commit workflow
|
|
324
|
+
python scripts/blackboard.py propose "chg_001" "key" '{"value": 1}'
|
|
325
|
+
python scripts/blackboard.py validate "chg_001"
|
|
326
|
+
python scripts/blackboard.py commit "chg_001"
|
|
327
|
+
|
|
328
|
+
# List all keys
|
|
329
|
+
python scripts/blackboard.py list
|
|
330
|
+
```
|
|
331
|
+
|
|
332
|
+
### Permissions
|
|
333
|
+
|
|
334
|
+
```bash
|
|
335
|
+
# Request permission
|
|
336
|
+
python scripts/check_permission.py \
|
|
337
|
+
--agent data_analyst \
|
|
338
|
+
--resource DATABASE \
|
|
339
|
+
--justification "Need customer order history for Q4 report"
|
|
340
|
+
|
|
341
|
+
# View active grants
|
|
342
|
+
python scripts/check_permission.py --active-grants
|
|
343
|
+
python scripts/check_permission.py --active-grants --agent data_analyst --json
|
|
344
|
+
|
|
345
|
+
# Audit summary
|
|
346
|
+
python scripts/check_permission.py --audit-summary
|
|
347
|
+
python scripts/check_permission.py --audit-summary --last 50 --json
|
|
348
|
+
```
|
|
349
|
+
|
|
350
|
+
### Token Management
|
|
351
|
+
|
|
352
|
+
```bash
|
|
353
|
+
python scripts/revoke_token.py --list-expired
|
|
354
|
+
python scripts/revoke_token.py --cleanup
|
|
355
|
+
python scripts/validate_token.py --token "grant_85364b44..."
|
|
356
|
+
```
|
|
357
|
+
|
|
358
|
+
---
|
|
359
|
+
|
|
360
|
+
## Fan-Out / Fan-In Pattern
|
|
361
|
+
|
|
362
|
+
```typescript
|
|
363
|
+
import { LockedBlackboard } from 'network-ai';
|
|
364
|
+
|
|
365
|
+
const board = new LockedBlackboard('.', logger, { conflictResolution: 'first-commit-wins' });
|
|
366
|
+
const pillars = ['reliability', 'security', 'cost', 'operations', 'performance'];
|
|
367
|
+
|
|
368
|
+
// Fan-out: each agent writes to its own section independently
|
|
369
|
+
for (const pillar of pillars) {
|
|
370
|
+
const id = board.propose(`eval:${pillar}`, { score: Math.random(), findings: [] }, pillar);
|
|
371
|
+
board.validate(id, 'orchestrator');
|
|
372
|
+
board.commit(id);
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
// Fan-in: orchestrator reads all results and synthesises
|
|
376
|
+
const results = pillars.map(p => ({ pillar: p, ...board.read(`eval:${p}`) }));
|
|
377
|
+
const id = board.propose('eval:summary', {
|
|
378
|
+
overall: results.reduce((s, r) => s + r.score, 0) / results.length,
|
|
379
|
+
pillars: results,
|
|
380
|
+
}, 'orchestrator');
|
|
381
|
+
board.validate(id, 'orchestrator');
|
|
382
|
+
board.commit(id);
|
|
383
|
+
```
|
|
384
|
+
|
|
385
|
+
---
|
|
386
|
+
|
|
387
|
+
## Configuration
|
|
388
|
+
|
|
389
|
+
### Modify Trust Levels
|
|
390
|
+
|
|
391
|
+
Edit `scripts/check_permission.py`:
|
|
392
|
+
|
|
393
|
+
```python
|
|
394
|
+
DEFAULT_TRUST_LEVELS = {
|
|
395
|
+
"orchestrator": 0.9,
|
|
396
|
+
"my_new_agent": 0.75, # add your agent
|
|
397
|
+
}
|
|
398
|
+
GRANT_TOKEN_TTL_MINUTES = 5
|
|
399
|
+
```
|
|
400
|
+
|
|
401
|
+
---
|
|
402
|
+
|
|
403
|
+
## Module Exports
|
|
404
|
+
|
|
405
|
+
```typescript
|
|
406
|
+
// Core classes
|
|
407
|
+
import SwarmOrchestrator, {
|
|
408
|
+
SharedBlackboard, AuthGuardian, TaskDecomposer,
|
|
409
|
+
BlackboardValidator, QualityGateAgent,
|
|
410
|
+
} from 'network-ai';
|
|
411
|
+
|
|
412
|
+
// Factory
|
|
413
|
+
import { createSwarmOrchestrator } from 'network-ai';
|
|
414
|
+
|
|
415
|
+
// All 12 adapters
|
|
416
|
+
import {
|
|
417
|
+
AdapterRegistry, BaseAdapter,
|
|
418
|
+
OpenClawAdapter, LangChainAdapter, AutoGenAdapter,
|
|
419
|
+
CrewAIAdapter, MCPAdapter, CustomAdapter,
|
|
420
|
+
LlamaIndexAdapter, SemanticKernelAdapter, OpenAIAssistantsAdapter,
|
|
421
|
+
HaystackAdapter, DSPyAdapter, AgnoAdapter,
|
|
422
|
+
} from 'network-ai';
|
|
423
|
+
|
|
424
|
+
// Types
|
|
425
|
+
import type {
|
|
426
|
+
IAgentAdapter, AgentPayload, AgentContext, AgentResult, AgentInfo,
|
|
427
|
+
AdapterConfig, TaskPayload, HandoffMessage, PermissionGrant, SwarmState,
|
|
428
|
+
ParallelTask, ParallelExecutionResult, SynthesisStrategy,
|
|
429
|
+
} from 'network-ai';
|
|
430
|
+
```
|