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
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
Validate Grant Token
|
|
4
|
+
|
|
5
|
+
Check if a permission grant token is valid and not expired.
|
|
6
|
+
|
|
7
|
+
Usage:
|
|
8
|
+
python validate_token.py TOKEN
|
|
9
|
+
|
|
10
|
+
Example:
|
|
11
|
+
python validate_token.py grant_a1b2c3d4e5f6
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
import argparse
|
|
15
|
+
import json
|
|
16
|
+
import sys
|
|
17
|
+
from datetime import datetime, timezone
|
|
18
|
+
from pathlib import Path
|
|
19
|
+
from typing import Any
|
|
20
|
+
|
|
21
|
+
GRANTS_FILE = Path(__file__).parent.parent / "data" / "active_grants.json"
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def validate_token(token: str) -> dict[str, Any]:
|
|
25
|
+
"""Validate a grant token and return its details."""
|
|
26
|
+
if not GRANTS_FILE.exists():
|
|
27
|
+
return {
|
|
28
|
+
"valid": False,
|
|
29
|
+
"reason": "No grants file found"
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
try:
|
|
33
|
+
grants = json.loads(GRANTS_FILE.read_text())
|
|
34
|
+
except json.JSONDecodeError:
|
|
35
|
+
return {
|
|
36
|
+
"valid": False,
|
|
37
|
+
"reason": "Invalid grants file"
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if token not in grants:
|
|
41
|
+
return {
|
|
42
|
+
"valid": False,
|
|
43
|
+
"reason": "Token not found"
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
grant = grants[token]
|
|
47
|
+
|
|
48
|
+
# Check expiration
|
|
49
|
+
expires_at = grant.get("expires_at")
|
|
50
|
+
if expires_at:
|
|
51
|
+
try:
|
|
52
|
+
expiry = datetime.fromisoformat(str(expires_at).replace("Z", "+00:00"))
|
|
53
|
+
now = datetime.now(timezone.utc)
|
|
54
|
+
|
|
55
|
+
if now > expiry:
|
|
56
|
+
return {
|
|
57
|
+
"valid": False,
|
|
58
|
+
"reason": "Token has expired",
|
|
59
|
+
"expired_at": expires_at
|
|
60
|
+
}
|
|
61
|
+
except Exception:
|
|
62
|
+
pass
|
|
63
|
+
|
|
64
|
+
return {
|
|
65
|
+
"valid": True,
|
|
66
|
+
"grant": grant
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
def main():
|
|
71
|
+
parser = argparse.ArgumentParser(description="Validate a permission grant token")
|
|
72
|
+
parser.add_argument("token", help="Grant token to validate")
|
|
73
|
+
parser.add_argument("--json", action="store_true", help="Output as JSON")
|
|
74
|
+
|
|
75
|
+
args = parser.parse_args()
|
|
76
|
+
result = validate_token(args.token)
|
|
77
|
+
|
|
78
|
+
if args.json:
|
|
79
|
+
print(json.dumps(result, indent=2))
|
|
80
|
+
else:
|
|
81
|
+
if result["valid"]:
|
|
82
|
+
grant = result["grant"]
|
|
83
|
+
print("✅ Token is VALID")
|
|
84
|
+
print(f" Agent: {grant.get('agent_id')}")
|
|
85
|
+
print(f" Resource: {grant.get('resource_type')}")
|
|
86
|
+
print(f" Scope: {grant.get('scope', 'N/A')}")
|
|
87
|
+
print(f" Expires: {grant.get('expires_at')}")
|
|
88
|
+
print(f" Restrictions: {', '.join(grant.get('restrictions', []))}")
|
|
89
|
+
else:
|
|
90
|
+
print("❌ Token is INVALID")
|
|
91
|
+
print(f" Reason: {result.get('reason')}")
|
|
92
|
+
|
|
93
|
+
sys.exit(0 if result["valid"] else 1)
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
if __name__ == "__main__":
|
|
97
|
+
main()
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Universal Agent Adapter Interface
|
|
3
|
+
*
|
|
4
|
+
* This is the core contract that makes the SwarmOrchestrator plug-and-play
|
|
5
|
+
* with ANY agent system. Each framework (OpenClaw, LangChain, AutoGen, CrewAI,
|
|
6
|
+
* MCP, or custom agents) implements this interface via an adapter.
|
|
7
|
+
*
|
|
8
|
+
* The SwarmOrchestrator never talks to a specific framework directly —
|
|
9
|
+
* it talks through this universal interface.
|
|
10
|
+
*
|
|
11
|
+
* @module AgentAdapter
|
|
12
|
+
* @version 1.0.0
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
// ============================================================================
|
|
16
|
+
// CORE TYPES — The universal language all adapters speak
|
|
17
|
+
// ============================================================================
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Payload sent to an agent for execution.
|
|
21
|
+
* Framework adapters translate this into their native format.
|
|
22
|
+
*/
|
|
23
|
+
export interface AgentPayload {
|
|
24
|
+
/** The action or task to perform */
|
|
25
|
+
action: string;
|
|
26
|
+
/** Parameters for the action */
|
|
27
|
+
params: Record<string, unknown>;
|
|
28
|
+
/** Optional handoff context from the orchestrator */
|
|
29
|
+
handoff?: {
|
|
30
|
+
handoffId: string;
|
|
31
|
+
sourceAgent: string;
|
|
32
|
+
targetAgent: string;
|
|
33
|
+
taskType: 'delegate' | 'collaborate' | 'validate';
|
|
34
|
+
instruction: string;
|
|
35
|
+
context?: Record<string, unknown>;
|
|
36
|
+
constraints?: string[];
|
|
37
|
+
expectedOutput?: string;
|
|
38
|
+
metadata?: Record<string, unknown>;
|
|
39
|
+
};
|
|
40
|
+
/** Shared state snapshot from the blackboard */
|
|
41
|
+
blackboardSnapshot?: Record<string, unknown>;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Universal execution context for agent operations
|
|
46
|
+
*/
|
|
47
|
+
export interface AgentContext {
|
|
48
|
+
/** The agent initiating the request */
|
|
49
|
+
agentId: string;
|
|
50
|
+
/** Unique task identifier */
|
|
51
|
+
taskId?: string;
|
|
52
|
+
/** Session identifier for multi-turn interactions */
|
|
53
|
+
sessionId?: string;
|
|
54
|
+
/** Arbitrary metadata from the host system */
|
|
55
|
+
metadata?: Record<string, unknown>;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Universal result returned from agent execution.
|
|
60
|
+
* Framework adapters normalize their native results into this shape.
|
|
61
|
+
*/
|
|
62
|
+
export interface AgentResult {
|
|
63
|
+
/** Whether execution succeeded */
|
|
64
|
+
success: boolean;
|
|
65
|
+
/** Result data (any shape — adapters normalize this) */
|
|
66
|
+
data?: unknown;
|
|
67
|
+
/** Error information if execution failed */
|
|
68
|
+
error?: {
|
|
69
|
+
code: string;
|
|
70
|
+
message: string;
|
|
71
|
+
recoverable: boolean;
|
|
72
|
+
suggestedAction?: string;
|
|
73
|
+
/** Framework-specific error details */
|
|
74
|
+
nativeError?: unknown;
|
|
75
|
+
};
|
|
76
|
+
/** Execution metadata */
|
|
77
|
+
metadata?: {
|
|
78
|
+
/** Time taken in milliseconds */
|
|
79
|
+
executionTimeMs?: number;
|
|
80
|
+
/** Which adapter handled this */
|
|
81
|
+
adapter?: string;
|
|
82
|
+
/** Framework-specific trace data */
|
|
83
|
+
trace?: Record<string, unknown>;
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Information about a discoverable agent
|
|
89
|
+
*/
|
|
90
|
+
export interface AgentInfo {
|
|
91
|
+
/** Unique agent identifier */
|
|
92
|
+
id: string;
|
|
93
|
+
/** Human-readable name */
|
|
94
|
+
name: string;
|
|
95
|
+
/** Agent description */
|
|
96
|
+
description?: string;
|
|
97
|
+
/** Which adapter provides this agent */
|
|
98
|
+
adapter: string;
|
|
99
|
+
/** What the agent can do */
|
|
100
|
+
capabilities?: string[];
|
|
101
|
+
/** Current availability */
|
|
102
|
+
status: 'available' | 'busy' | 'offline' | 'unknown';
|
|
103
|
+
/** Framework-specific metadata */
|
|
104
|
+
metadata?: Record<string, unknown>;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Configuration passed to an adapter during initialization
|
|
109
|
+
*/
|
|
110
|
+
export interface AdapterConfig {
|
|
111
|
+
/** Working directory for file-based operations */
|
|
112
|
+
workspacePath?: string;
|
|
113
|
+
/** Framework-specific connection/API settings */
|
|
114
|
+
connection?: {
|
|
115
|
+
url?: string;
|
|
116
|
+
apiKey?: string;
|
|
117
|
+
headers?: Record<string, string>;
|
|
118
|
+
timeout?: number;
|
|
119
|
+
};
|
|
120
|
+
/** Adapter-specific options */
|
|
121
|
+
options?: Record<string, unknown>;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Capabilities an adapter can declare support for
|
|
126
|
+
*/
|
|
127
|
+
export interface AdapterCapabilities {
|
|
128
|
+
/** Can stream partial results */
|
|
129
|
+
streaming: boolean;
|
|
130
|
+
/** Can run multiple agents concurrently */
|
|
131
|
+
parallel: boolean;
|
|
132
|
+
/** Supports two-way agent communication */
|
|
133
|
+
bidirectional: boolean;
|
|
134
|
+
/** Can discover agents at runtime */
|
|
135
|
+
discovery: boolean;
|
|
136
|
+
/** Supports authentication/trust levels */
|
|
137
|
+
authentication: boolean;
|
|
138
|
+
/** Supports stateful multi-turn sessions */
|
|
139
|
+
statefulSessions: boolean;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// ============================================================================
|
|
143
|
+
// ADAPTER INTERFACE — The contract every adapter must implement
|
|
144
|
+
// ============================================================================
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* The core adapter interface. Every agent system (OpenClaw, LangChain, etc.)
|
|
148
|
+
* implements this to plug into the SwarmOrchestrator.
|
|
149
|
+
*
|
|
150
|
+
* Minimal implementation requires: name, version, initialize, executeAgent
|
|
151
|
+
* Everything else has sensible defaults in BaseAdapter.
|
|
152
|
+
*/
|
|
153
|
+
export interface IAgentAdapter {
|
|
154
|
+
/** Unique adapter identifier (e.g., "openclaw", "langchain", "autogen") */
|
|
155
|
+
readonly name: string;
|
|
156
|
+
/** Adapter version */
|
|
157
|
+
readonly version: string;
|
|
158
|
+
/** What this adapter can do */
|
|
159
|
+
readonly capabilities: AdapterCapabilities;
|
|
160
|
+
|
|
161
|
+
// --- Lifecycle ---
|
|
162
|
+
|
|
163
|
+
/** Initialize the adapter with configuration */
|
|
164
|
+
initialize(config: AdapterConfig): Promise<void>;
|
|
165
|
+
/** Gracefully shut down the adapter */
|
|
166
|
+
shutdown(): Promise<void>;
|
|
167
|
+
/** Check if the adapter is ready */
|
|
168
|
+
isReady(): boolean;
|
|
169
|
+
|
|
170
|
+
// --- Agent Execution (REQUIRED) ---
|
|
171
|
+
|
|
172
|
+
/** Execute a task on an agent — this is the core operation */
|
|
173
|
+
executeAgent(
|
|
174
|
+
agentId: string,
|
|
175
|
+
payload: AgentPayload,
|
|
176
|
+
context: AgentContext
|
|
177
|
+
): Promise<AgentResult>;
|
|
178
|
+
|
|
179
|
+
// --- Agent Discovery (optional) ---
|
|
180
|
+
|
|
181
|
+
/** List all agents available through this adapter */
|
|
182
|
+
listAgents(): Promise<AgentInfo[]>;
|
|
183
|
+
/** Check if a specific agent is available */
|
|
184
|
+
isAgentAvailable(agentId: string): Promise<boolean>;
|
|
185
|
+
|
|
186
|
+
// --- Health ---
|
|
187
|
+
|
|
188
|
+
/** Health check for the adapter and its backing system */
|
|
189
|
+
healthCheck(): Promise<{ healthy: boolean; details?: string }>;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
// ============================================================================
|
|
193
|
+
// REGISTRY TYPES — Managing multiple adapters
|
|
194
|
+
// ============================================================================
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* Route a request to the right adapter based on agent ID patterns
|
|
198
|
+
*/
|
|
199
|
+
export interface AdapterRoute {
|
|
200
|
+
/** Glob or regex pattern to match agent IDs (e.g., "lc:*", "autogen:*") */
|
|
201
|
+
pattern: string;
|
|
202
|
+
/** Which adapter handles matching agents */
|
|
203
|
+
adapterName: string;
|
|
204
|
+
/** Priority if multiple routes match (higher = preferred) */
|
|
205
|
+
priority?: number;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* Configuration for the adapter registry
|
|
210
|
+
*/
|
|
211
|
+
export interface RegistryConfig {
|
|
212
|
+
/** Default adapter to use when no route matches */
|
|
213
|
+
defaultAdapter?: string;
|
|
214
|
+
/** Routing rules to map agent IDs to adapters */
|
|
215
|
+
routes?: AdapterRoute[];
|
|
216
|
+
/** Enable automatic agent discovery across all adapters */
|
|
217
|
+
enableDiscovery?: boolean;
|
|
218
|
+
/** How often to refresh agent discovery (ms) */
|
|
219
|
+
discoveryIntervalMs?: number;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
// ============================================================================
|
|
223
|
+
// EVENT TYPES — For adapter lifecycle hooks
|
|
224
|
+
// ============================================================================
|
|
225
|
+
|
|
226
|
+
export type AdapterEventType =
|
|
227
|
+
| 'adapter:registered'
|
|
228
|
+
| 'adapter:initialized'
|
|
229
|
+
| 'adapter:shutdown'
|
|
230
|
+
| 'adapter:error'
|
|
231
|
+
| 'agent:execution:start'
|
|
232
|
+
| 'agent:execution:complete'
|
|
233
|
+
| 'agent:execution:error'
|
|
234
|
+
| 'agent:discovered'
|
|
235
|
+
| 'agent:unavailable';
|
|
236
|
+
|
|
237
|
+
export interface AdapterEvent {
|
|
238
|
+
type: AdapterEventType;
|
|
239
|
+
adapter: string;
|
|
240
|
+
timestamp: string;
|
|
241
|
+
data?: unknown;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
export type AdapterEventHandler = (event: AdapterEvent) => void;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type declarations for openclaw-core
|
|
3
|
+
* This is a stub module for the OpenClaw framework
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
declare module 'openclaw-core' {
|
|
7
|
+
/**
|
|
8
|
+
* Base interface for all OpenClaw skills
|
|
9
|
+
*/
|
|
10
|
+
export interface OpenClawSkill {
|
|
11
|
+
name: string;
|
|
12
|
+
version: string;
|
|
13
|
+
execute(
|
|
14
|
+
action: string,
|
|
15
|
+
params: Record<string, unknown>,
|
|
16
|
+
context: SkillContext
|
|
17
|
+
): Promise<SkillResult>;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Context provided to skill execution
|
|
22
|
+
*/
|
|
23
|
+
export interface SkillContext {
|
|
24
|
+
agentId: string;
|
|
25
|
+
taskId?: string;
|
|
26
|
+
sessionId?: string;
|
|
27
|
+
metadata?: Record<string, unknown>;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Result returned from skill execution
|
|
32
|
+
*/
|
|
33
|
+
export interface SkillResult {
|
|
34
|
+
success: boolean;
|
|
35
|
+
data?: unknown;
|
|
36
|
+
error?: {
|
|
37
|
+
code: string;
|
|
38
|
+
message: string;
|
|
39
|
+
recoverable: boolean;
|
|
40
|
+
suggestedAction?: string;
|
|
41
|
+
trace?: Record<string, unknown>;
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Call another skill within the OpenClaw ecosystem
|
|
47
|
+
*/
|
|
48
|
+
export function callSkill(
|
|
49
|
+
skillName: string,
|
|
50
|
+
params: Record<string, unknown>
|
|
51
|
+
): Promise<SkillResult>;
|
|
52
|
+
}
|