openclaw-protocol-bridge 1.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/README.md +567 -0
- package/config/platforms.example.json +93 -0
- package/config/platforms.json +93 -0
- package/dist/adapters/a2a.d.ts +67 -0
- package/dist/adapters/a2a.d.ts.map +1 -0
- package/dist/adapters/a2a.js +256 -0
- package/dist/adapters/a2a.js.map +1 -0
- package/dist/adapters/base.d.ts +85 -0
- package/dist/adapters/base.d.ts.map +1 -0
- package/dist/adapters/base.js +71 -0
- package/dist/adapters/base.js.map +1 -0
- package/dist/adapters/mcp.d.ts +39 -0
- package/dist/adapters/mcp.d.ts.map +1 -0
- package/dist/adapters/mcp.js +197 -0
- package/dist/adapters/mcp.js.map +1 -0
- package/dist/cli/index.d.ts +6 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +259 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/server.d.ts +6 -0
- package/dist/cli/server.d.ts.map +1 -0
- package/dist/cli/server.js +161 -0
- package/dist/cli/server.js.map +1 -0
- package/dist/core/bridge.d.ts +99 -0
- package/dist/core/bridge.d.ts.map +1 -0
- package/dist/core/bridge.js +387 -0
- package/dist/core/bridge.js.map +1 -0
- package/dist/core/types.d.ts +257 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/core/types.js +48 -0
- package/dist/core/types.js.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +34 -0
- package/dist/index.js.map +1 -0
- package/examples/basic-usage.ts +142 -0
- package/examples/middleware-example.ts +131 -0
- package/package.json +88 -0
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Protocol Bridge - Core Type Definitions
|
|
3
|
+
* The TCP/IP of Agent Standards
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Supported protocol types
|
|
7
|
+
*/
|
|
8
|
+
export type ProtocolType = 'mcp' | 'a2a' | 'acp' | 'langchain' | 'autogpt' | 'crewai' | 'custom';
|
|
9
|
+
/**
|
|
10
|
+
* Message types
|
|
11
|
+
*/
|
|
12
|
+
export type MessageType = 'request' | 'response' | 'event' | 'error' | 'heartbeat';
|
|
13
|
+
/**
|
|
14
|
+
* Routing strategies
|
|
15
|
+
*/
|
|
16
|
+
export type RoutingStrategy = 'capability-based' | 'round-robin' | 'least-loaded' | 'priority' | 'custom';
|
|
17
|
+
/**
|
|
18
|
+
* Authentication methods
|
|
19
|
+
*/
|
|
20
|
+
export type AuthMethod = 'none' | 'jwt' | 'oauth' | 'apikey' | 'mtls';
|
|
21
|
+
/**
|
|
22
|
+
* Agent identity
|
|
23
|
+
*/
|
|
24
|
+
export interface AgentIdentity {
|
|
25
|
+
id: string;
|
|
26
|
+
protocol: ProtocolType;
|
|
27
|
+
name?: string;
|
|
28
|
+
version?: string;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Agent capabilities
|
|
32
|
+
*/
|
|
33
|
+
export interface AgentCapability {
|
|
34
|
+
name: string;
|
|
35
|
+
description?: string;
|
|
36
|
+
inputSchema?: any;
|
|
37
|
+
outputSchema?: any;
|
|
38
|
+
cost?: number;
|
|
39
|
+
latency?: number;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Agent registration info
|
|
43
|
+
*/
|
|
44
|
+
export interface AgentInfo extends AgentIdentity {
|
|
45
|
+
capabilities: AgentCapability[];
|
|
46
|
+
endpoint: string;
|
|
47
|
+
transport: 'http' | 'websocket' | 'grpc';
|
|
48
|
+
metadata?: Record<string, any>;
|
|
49
|
+
status: 'active' | 'inactive' | 'degraded';
|
|
50
|
+
lastSeen?: Date;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Universal message format
|
|
54
|
+
* All protocols are translated to/from this format
|
|
55
|
+
*/
|
|
56
|
+
export interface UniversalMessage {
|
|
57
|
+
id: string;
|
|
58
|
+
timestamp: Date;
|
|
59
|
+
from: AgentIdentity;
|
|
60
|
+
to: AgentIdentity;
|
|
61
|
+
type: MessageType;
|
|
62
|
+
action: string;
|
|
63
|
+
payload: any;
|
|
64
|
+
metadata?: MessageMetadata;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Message metadata
|
|
68
|
+
*/
|
|
69
|
+
export interface MessageMetadata {
|
|
70
|
+
correlationId?: string;
|
|
71
|
+
priority?: 'low' | 'normal' | 'high' | 'critical';
|
|
72
|
+
timeout?: number;
|
|
73
|
+
retry?: boolean;
|
|
74
|
+
maxRetries?: number;
|
|
75
|
+
ttl?: number;
|
|
76
|
+
headers?: Record<string, string>;
|
|
77
|
+
[key: string]: any;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Message response
|
|
81
|
+
*/
|
|
82
|
+
export interface MessageResponse {
|
|
83
|
+
messageId: string;
|
|
84
|
+
status: 'success' | 'error' | 'timeout' | 'rejected';
|
|
85
|
+
data?: any;
|
|
86
|
+
error?: {
|
|
87
|
+
code: string;
|
|
88
|
+
message: string;
|
|
89
|
+
details?: any;
|
|
90
|
+
};
|
|
91
|
+
metadata?: Record<string, any>;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Protocol adapter configuration
|
|
95
|
+
*/
|
|
96
|
+
export interface ProtocolConfig {
|
|
97
|
+
enabled: boolean;
|
|
98
|
+
version?: string;
|
|
99
|
+
adapters?: string[];
|
|
100
|
+
options?: Record<string, any>;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Bridge configuration
|
|
104
|
+
*/
|
|
105
|
+
export interface BridgeConfig {
|
|
106
|
+
server?: {
|
|
107
|
+
port: number;
|
|
108
|
+
host: string;
|
|
109
|
+
cors?: {
|
|
110
|
+
enabled: boolean;
|
|
111
|
+
origins: string[];
|
|
112
|
+
};
|
|
113
|
+
};
|
|
114
|
+
protocols: {
|
|
115
|
+
[key in ProtocolType]?: ProtocolConfig;
|
|
116
|
+
};
|
|
117
|
+
routing: {
|
|
118
|
+
strategy: RoutingStrategy;
|
|
119
|
+
fallback: boolean;
|
|
120
|
+
timeout: number;
|
|
121
|
+
retryPolicy?: RetryPolicy;
|
|
122
|
+
};
|
|
123
|
+
discovery: {
|
|
124
|
+
enabled: boolean;
|
|
125
|
+
interval?: number;
|
|
126
|
+
ttl?: number;
|
|
127
|
+
};
|
|
128
|
+
security: {
|
|
129
|
+
authentication: AuthMethod;
|
|
130
|
+
encryption?: {
|
|
131
|
+
enabled: boolean;
|
|
132
|
+
algorithm?: string;
|
|
133
|
+
};
|
|
134
|
+
allowedOrigins?: string[];
|
|
135
|
+
jwtSecret?: string;
|
|
136
|
+
apiKeys?: string[];
|
|
137
|
+
};
|
|
138
|
+
monitoring: {
|
|
139
|
+
metrics: boolean;
|
|
140
|
+
logging: LogLevel;
|
|
141
|
+
healthCheck: boolean;
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Retry policy
|
|
146
|
+
*/
|
|
147
|
+
export interface RetryPolicy {
|
|
148
|
+
maxRetries: number;
|
|
149
|
+
initialDelay: number;
|
|
150
|
+
maxDelay: number;
|
|
151
|
+
backoffMultiplier: number;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Log levels
|
|
155
|
+
*/
|
|
156
|
+
export type LogLevel = 'debug' | 'info' | 'warn' | 'error';
|
|
157
|
+
/**
|
|
158
|
+
* Discovery query
|
|
159
|
+
*/
|
|
160
|
+
export interface DiscoveryQuery {
|
|
161
|
+
capabilities?: string[];
|
|
162
|
+
protocols?: ProtocolType[];
|
|
163
|
+
maxCost?: number;
|
|
164
|
+
maxLatency?: number;
|
|
165
|
+
metadata?: Record<string, any>;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Metrics data
|
|
169
|
+
*/
|
|
170
|
+
export interface BridgeMetrics {
|
|
171
|
+
totalMessages: number;
|
|
172
|
+
successRate: number;
|
|
173
|
+
averageLatency: number;
|
|
174
|
+
protocolStats: {
|
|
175
|
+
[protocol: string]: {
|
|
176
|
+
sent: number;
|
|
177
|
+
received: number;
|
|
178
|
+
errors: number;
|
|
179
|
+
averageLatency: number;
|
|
180
|
+
};
|
|
181
|
+
};
|
|
182
|
+
agentStats: {
|
|
183
|
+
registered: number;
|
|
184
|
+
active: number;
|
|
185
|
+
inactive: number;
|
|
186
|
+
};
|
|
187
|
+
uptime: number;
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Health status
|
|
191
|
+
*/
|
|
192
|
+
export interface HealthStatus {
|
|
193
|
+
status: 'healthy' | 'degraded' | 'unhealthy';
|
|
194
|
+
uptime: number;
|
|
195
|
+
protocols: {
|
|
196
|
+
[protocol: string]: 'active' | 'degraded' | 'inactive';
|
|
197
|
+
};
|
|
198
|
+
agents: {
|
|
199
|
+
registered: number;
|
|
200
|
+
active: number;
|
|
201
|
+
inactive: number;
|
|
202
|
+
};
|
|
203
|
+
lastCheck: Date;
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Route information
|
|
207
|
+
*/
|
|
208
|
+
export interface RouteInfo {
|
|
209
|
+
from: AgentIdentity;
|
|
210
|
+
to: AgentIdentity;
|
|
211
|
+
via?: AgentIdentity[];
|
|
212
|
+
strategy: RoutingStrategy;
|
|
213
|
+
estimatedLatency?: number;
|
|
214
|
+
cost?: number;
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Translation context
|
|
218
|
+
*/
|
|
219
|
+
export interface TranslationContext {
|
|
220
|
+
sourceProtocol: ProtocolType;
|
|
221
|
+
targetProtocol: ProtocolType;
|
|
222
|
+
message: UniversalMessage;
|
|
223
|
+
options?: Record<string, any>;
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Middleware function
|
|
227
|
+
*/
|
|
228
|
+
export type MiddlewareFunction = (message: UniversalMessage, next: (message: UniversalMessage) => Promise<MessageResponse>) => Promise<MessageResponse>;
|
|
229
|
+
/**
|
|
230
|
+
* Event types
|
|
231
|
+
*/
|
|
232
|
+
export type BridgeEvent = 'agent:registered' | 'agent:unregistered' | 'agent:status_changed' | 'message:sent' | 'message:received' | 'message:routed' | 'message:failed' | 'protocol:connected' | 'protocol:disconnected' | 'bridge:started' | 'bridge:stopped';
|
|
233
|
+
/**
|
|
234
|
+
* Event handler
|
|
235
|
+
*/
|
|
236
|
+
export type EventHandler = (event: BridgeEvent, data: any) => void | Promise<void>;
|
|
237
|
+
/**
|
|
238
|
+
* Error types
|
|
239
|
+
*/
|
|
240
|
+
export declare class BridgeError extends Error {
|
|
241
|
+
code: string;
|
|
242
|
+
details?: any | undefined;
|
|
243
|
+
constructor(code: string, message: string, details?: any | undefined);
|
|
244
|
+
}
|
|
245
|
+
export declare class ProtocolError extends BridgeError {
|
|
246
|
+
constructor(protocol: ProtocolType, message: string, details?: any);
|
|
247
|
+
}
|
|
248
|
+
export declare class RoutingError extends BridgeError {
|
|
249
|
+
constructor(message: string, details?: any);
|
|
250
|
+
}
|
|
251
|
+
export declare class TranslationError extends BridgeError {
|
|
252
|
+
constructor(message: string, details?: any);
|
|
253
|
+
}
|
|
254
|
+
export declare class AuthenticationError extends BridgeError {
|
|
255
|
+
constructor(message: string, details?: any);
|
|
256
|
+
}
|
|
257
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/core/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,WAAW,GAAG,SAAS,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAEjG;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,SAAS,GAAG,UAAU,GAAG,OAAO,GAAG,OAAO,GAAG,WAAW,CAAC;AAEnF;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,kBAAkB,GAAG,aA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
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Protocol Bridge - Core Type Definitions
|
|
4
|
+
* The TCP/IP of Agent Standards
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.AuthenticationError = exports.TranslationError = exports.RoutingError = exports.ProtocolError = exports.BridgeError = void 0;
|
|
8
|
+
/**
|
|
9
|
+
* Error types
|
|
10
|
+
*/
|
|
11
|
+
class BridgeError extends Error {
|
|
12
|
+
constructor(code, message, details) {
|
|
13
|
+
super(message);
|
|
14
|
+
this.code = code;
|
|
15
|
+
this.details = details;
|
|
16
|
+
this.name = 'BridgeError';
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
exports.BridgeError = BridgeError;
|
|
20
|
+
class ProtocolError extends BridgeError {
|
|
21
|
+
constructor(protocol, message, details) {
|
|
22
|
+
super(`PROTOCOL_ERROR_${protocol.toUpperCase()}`, message, details);
|
|
23
|
+
this.name = 'ProtocolError';
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
exports.ProtocolError = ProtocolError;
|
|
27
|
+
class RoutingError extends BridgeError {
|
|
28
|
+
constructor(message, details) {
|
|
29
|
+
super('ROUTING_ERROR', message, details);
|
|
30
|
+
this.name = 'RoutingError';
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
exports.RoutingError = RoutingError;
|
|
34
|
+
class TranslationError extends BridgeError {
|
|
35
|
+
constructor(message, details) {
|
|
36
|
+
super('TRANSLATION_ERROR', message, details);
|
|
37
|
+
this.name = 'TranslationError';
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
exports.TranslationError = TranslationError;
|
|
41
|
+
class AuthenticationError extends BridgeError {
|
|
42
|
+
constructor(message, details) {
|
|
43
|
+
super('AUTH_ERROR', message, details);
|
|
44
|
+
this.name = 'AuthenticationError';
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
exports.AuthenticationError = AuthenticationError;
|
|
48
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/core/types.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AA8QH;;GAEG;AACH,MAAa,WAAY,SAAQ,KAAK;IACpC,YACS,IAAY,EACnB,OAAe,EACR,OAAa;QAEpB,KAAK,CAAC,OAAO,CAAC,CAAC;QAJR,SAAI,GAAJ,IAAI,CAAQ;QAEZ,YAAO,GAAP,OAAO,CAAM;QAGpB,IAAI,CAAC,IAAI,GAAG,aAAa,CAAC;IAC5B,CAAC;CACF;AATD,kCASC;AAED,MAAa,aAAc,SAAQ,WAAW;IAC5C,YAAY,QAAsB,EAAE,OAAe,EAAE,OAAa;QAChE,KAAK,CAAC,kBAAkB,QAAQ,CAAC,WAAW,EAAE,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;QACpE,IAAI,CAAC,IAAI,GAAG,eAAe,CAAC;IAC9B,CAAC;CACF;AALD,sCAKC;AAED,MAAa,YAAa,SAAQ,WAAW;IAC3C,YAAY,OAAe,EAAE,OAAa;QACxC,KAAK,CAAC,eAAe,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;QACzC,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC;IAC7B,CAAC;CACF;AALD,oCAKC;AAED,MAAa,gBAAiB,SAAQ,WAAW;IAC/C,YAAY,OAAe,EAAE,OAAa;QACxC,KAAK,CAAC,mBAAmB,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;QAC7C,IAAI,CAAC,IAAI,GAAG,kBAAkB,CAAC;IACjC,CAAC;CACF;AALD,4CAKC;AAED,MAAa,mBAAoB,SAAQ,WAAW;IAClD,YAAY,OAAe,EAAE,OAAa;QACxC,KAAK,CAAC,YAAY,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;QACtC,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAC;IACpC,CAAC;CACF;AALD,kDAKC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Protocol Bridge - Main Entry Point
|
|
3
|
+
* The TCP/IP of Agent Standards
|
|
4
|
+
*/
|
|
5
|
+
export { ProtocolBridge } from './core/bridge';
|
|
6
|
+
export { BaseAdapter } from './adapters/base';
|
|
7
|
+
export { MCPAdapter } from './adapters/mcp';
|
|
8
|
+
export { A2AAdapter } from './adapters/a2a';
|
|
9
|
+
export * from './core/types';
|
|
10
|
+
export { ProtocolBridge as default } from './core/bridge';
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAE5C,cAAc,cAAc,CAAC;AAG7B,OAAO,EAAE,cAAc,IAAI,OAAO,EAAE,MAAM,eAAe,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Protocol Bridge - Main Entry Point
|
|
4
|
+
* The TCP/IP of Agent Standards
|
|
5
|
+
*/
|
|
6
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
7
|
+
if (k2 === undefined) k2 = k;
|
|
8
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
9
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
10
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
11
|
+
}
|
|
12
|
+
Object.defineProperty(o, k2, desc);
|
|
13
|
+
}) : (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
o[k2] = m[k];
|
|
16
|
+
}));
|
|
17
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
18
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
19
|
+
};
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
exports.default = exports.A2AAdapter = exports.MCPAdapter = exports.BaseAdapter = exports.ProtocolBridge = void 0;
|
|
22
|
+
var bridge_1 = require("./core/bridge");
|
|
23
|
+
Object.defineProperty(exports, "ProtocolBridge", { enumerable: true, get: function () { return bridge_1.ProtocolBridge; } });
|
|
24
|
+
var base_1 = require("./adapters/base");
|
|
25
|
+
Object.defineProperty(exports, "BaseAdapter", { enumerable: true, get: function () { return base_1.BaseAdapter; } });
|
|
26
|
+
var mcp_1 = require("./adapters/mcp");
|
|
27
|
+
Object.defineProperty(exports, "MCPAdapter", { enumerable: true, get: function () { return mcp_1.MCPAdapter; } });
|
|
28
|
+
var a2a_1 = require("./adapters/a2a");
|
|
29
|
+
Object.defineProperty(exports, "A2AAdapter", { enumerable: true, get: function () { return a2a_1.A2AAdapter; } });
|
|
30
|
+
__exportStar(require("./core/types"), exports);
|
|
31
|
+
// Default export
|
|
32
|
+
var bridge_2 = require("./core/bridge");
|
|
33
|
+
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return bridge_2.ProtocolBridge; } });
|
|
34
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;AAEH,wCAA+C;AAAtC,wGAAA,cAAc,OAAA;AACvB,wCAA8C;AAArC,mGAAA,WAAW,OAAA;AACpB,sCAA4C;AAAnC,iGAAA,UAAU,OAAA;AACnB,sCAA4C;AAAnC,iGAAA,UAAU,OAAA;AAEnB,+CAA6B;AAE7B,iBAAiB;AACjB,wCAA0D;AAAjD,iGAAA,cAAc,OAAW"}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Protocol Bridge - Basic Usage Example
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { ProtocolBridge, BridgeConfig, AgentInfo } from 'openclaw-protocol-bridge';
|
|
6
|
+
|
|
7
|
+
async function main() {
|
|
8
|
+
// 1. Create bridge configuration
|
|
9
|
+
const config: BridgeConfig = {
|
|
10
|
+
protocols: {
|
|
11
|
+
mcp: {
|
|
12
|
+
enabled: true,
|
|
13
|
+
version: '2025-11-25',
|
|
14
|
+
},
|
|
15
|
+
a2a: {
|
|
16
|
+
enabled: true,
|
|
17
|
+
version: '1.0',
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
routing: {
|
|
21
|
+
strategy: 'capability-based',
|
|
22
|
+
fallback: true,
|
|
23
|
+
timeout: 30000,
|
|
24
|
+
},
|
|
25
|
+
discovery: {
|
|
26
|
+
enabled: true,
|
|
27
|
+
},
|
|
28
|
+
security: {
|
|
29
|
+
authentication: 'none',
|
|
30
|
+
},
|
|
31
|
+
monitoring: {
|
|
32
|
+
metrics: true,
|
|
33
|
+
logging: 'info',
|
|
34
|
+
healthCheck: true,
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
// 2. Initialize the bridge
|
|
39
|
+
console.log('Initializing Protocol Bridge...');
|
|
40
|
+
const bridge = new ProtocolBridge(config);
|
|
41
|
+
await bridge.initialize();
|
|
42
|
+
|
|
43
|
+
// 3. Register an MCP agent
|
|
44
|
+
console.log('\nRegistering MCP agent...');
|
|
45
|
+
const mcpAgent: AgentInfo = {
|
|
46
|
+
id: 'research-agent',
|
|
47
|
+
protocol: 'mcp',
|
|
48
|
+
name: 'Research Agent',
|
|
49
|
+
endpoint: 'http://localhost:3001',
|
|
50
|
+
transport: 'http',
|
|
51
|
+
capabilities: [
|
|
52
|
+
{
|
|
53
|
+
name: 'search',
|
|
54
|
+
description: 'Search the web for information',
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
name: 'summarize',
|
|
58
|
+
description: 'Summarize text content',
|
|
59
|
+
},
|
|
60
|
+
],
|
|
61
|
+
status: 'active',
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
await bridge.registerAgent(mcpAgent);
|
|
65
|
+
console.log('✓ MCP agent registered');
|
|
66
|
+
|
|
67
|
+
// 4. Register an A2A agent
|
|
68
|
+
console.log('\nRegistering A2A agent...');
|
|
69
|
+
const a2aAgent: AgentInfo = {
|
|
70
|
+
id: 'assistant-agent',
|
|
71
|
+
protocol: 'a2a',
|
|
72
|
+
name: 'Assistant Agent',
|
|
73
|
+
endpoint: 'http://localhost:3002',
|
|
74
|
+
transport: 'http',
|
|
75
|
+
capabilities: [
|
|
76
|
+
{
|
|
77
|
+
name: 'chat',
|
|
78
|
+
description: 'Conversational AI assistant',
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
name: 'task-planning',
|
|
82
|
+
description: 'Plan and break down complex tasks',
|
|
83
|
+
},
|
|
84
|
+
],
|
|
85
|
+
status: 'active',
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
await bridge.registerAgent(a2aAgent);
|
|
89
|
+
console.log('✓ A2A agent registered');
|
|
90
|
+
|
|
91
|
+
// 5. Send a message from A2A agent to MCP agent (cross-protocol)
|
|
92
|
+
console.log('\nSending cross-protocol message (A2A → MCP)...');
|
|
93
|
+
const result = await bridge.send({
|
|
94
|
+
from: {
|
|
95
|
+
id: 'assistant-agent',
|
|
96
|
+
protocol: 'a2a',
|
|
97
|
+
},
|
|
98
|
+
to: {
|
|
99
|
+
id: 'research-agent',
|
|
100
|
+
protocol: 'mcp',
|
|
101
|
+
},
|
|
102
|
+
action: 'search',
|
|
103
|
+
params: {
|
|
104
|
+
query: 'AI agent protocols 2026',
|
|
105
|
+
maxResults: 5,
|
|
106
|
+
},
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
console.log('✓ Message sent successfully');
|
|
110
|
+
console.log('Response:', JSON.stringify(result, null, 2));
|
|
111
|
+
|
|
112
|
+
// 6. Discover agents by capability
|
|
113
|
+
console.log('\nDiscovering agents with "search" capability...');
|
|
114
|
+
const agents = await bridge.discover({
|
|
115
|
+
capabilities: ['search'],
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
console.log(`Found ${agents.length} agent(s):`);
|
|
119
|
+
agents.forEach((agent) => {
|
|
120
|
+
console.log(` - ${agent.name} (${agent.protocol})`);
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
// 7. Get bridge metrics
|
|
124
|
+
console.log('\nBridge Metrics:');
|
|
125
|
+
const metrics = bridge.getMetrics();
|
|
126
|
+
console.log(JSON.stringify(metrics, null, 2));
|
|
127
|
+
|
|
128
|
+
// 8. Check health
|
|
129
|
+
console.log('\nHealth Check:');
|
|
130
|
+
const health = await bridge.getHealth();
|
|
131
|
+
console.log(JSON.stringify(health, null, 2));
|
|
132
|
+
|
|
133
|
+
// 9. Shutdown
|
|
134
|
+
console.log('\nShutting down bridge...');
|
|
135
|
+
await bridge.shutdown();
|
|
136
|
+
console.log('✓ Bridge shut down successfully');
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
main().catch((error) => {
|
|
140
|
+
console.error('Error:', error);
|
|
141
|
+
process.exit(1);
|
|
142
|
+
});
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Protocol Bridge - Middleware Example
|
|
3
|
+
* Shows how to add middleware for logging, authentication, etc.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { ProtocolBridge, BridgeConfig, UniversalMessage, MessageResponse } from 'openclaw-protocol-bridge';
|
|
7
|
+
|
|
8
|
+
async function main() {
|
|
9
|
+
const config: BridgeConfig = {
|
|
10
|
+
protocols: {
|
|
11
|
+
mcp: { enabled: true },
|
|
12
|
+
a2a: { enabled: true },
|
|
13
|
+
},
|
|
14
|
+
routing: {
|
|
15
|
+
strategy: 'capability-based',
|
|
16
|
+
fallback: true,
|
|
17
|
+
timeout: 30000,
|
|
18
|
+
},
|
|
19
|
+
discovery: { enabled: false },
|
|
20
|
+
security: { authentication: 'none' },
|
|
21
|
+
monitoring: {
|
|
22
|
+
metrics: true,
|
|
23
|
+
logging: 'info',
|
|
24
|
+
healthCheck: true,
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const bridge = new ProtocolBridge(config);
|
|
29
|
+
await bridge.initialize();
|
|
30
|
+
|
|
31
|
+
// Middleware 1: Logging
|
|
32
|
+
bridge.use(async (message: UniversalMessage, next) => {
|
|
33
|
+
console.log(`[LOG] Message: ${message.from.id} → ${message.to.id} (${message.action})`);
|
|
34
|
+
const startTime = Date.now();
|
|
35
|
+
|
|
36
|
+
const response = await next(message);
|
|
37
|
+
|
|
38
|
+
const latency = Date.now() - startTime;
|
|
39
|
+
console.log(`[LOG] Response: ${response.status} (${latency}ms)`);
|
|
40
|
+
|
|
41
|
+
return response;
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
// Middleware 2: Authentication
|
|
45
|
+
bridge.use(async (message: UniversalMessage, next) => {
|
|
46
|
+
// Check if message has auth token
|
|
47
|
+
const authToken = message.metadata?.headers?.['Authorization'];
|
|
48
|
+
|
|
49
|
+
if (!authToken) {
|
|
50
|
+
console.log('[AUTH] No auth token provided');
|
|
51
|
+
return {
|
|
52
|
+
messageId: message.id,
|
|
53
|
+
status: 'error',
|
|
54
|
+
error: {
|
|
55
|
+
code: 'UNAUTHORIZED',
|
|
56
|
+
message: 'Authentication required',
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
console.log('[AUTH] Token validated');
|
|
62
|
+
return await next(message);
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
// Middleware 3: Rate Limiting
|
|
66
|
+
const requestCounts = new Map<string, number>();
|
|
67
|
+
|
|
68
|
+
bridge.use(async (message: UniversalMessage, next) => {
|
|
69
|
+
const agentId = message.from.id;
|
|
70
|
+
const count = requestCounts.get(agentId) || 0;
|
|
71
|
+
|
|
72
|
+
if (count >= 10) {
|
|
73
|
+
console.log(`[RATE LIMIT] Agent ${agentId} exceeded rate limit`);
|
|
74
|
+
return {
|
|
75
|
+
messageId: message.id,
|
|
76
|
+
status: 'error',
|
|
77
|
+
error: {
|
|
78
|
+
code: 'RATE_LIMIT_EXCEEDED',
|
|
79
|
+
message: 'Too many requests',
|
|
80
|
+
},
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
requestCounts.set(agentId, count + 1);
|
|
85
|
+
|
|
86
|
+
// Reset after 1 minute
|
|
87
|
+
setTimeout(() => {
|
|
88
|
+
requestCounts.delete(agentId);
|
|
89
|
+
}, 60000);
|
|
90
|
+
|
|
91
|
+
return await next(message);
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
// Middleware 4: Metrics Collection
|
|
95
|
+
bridge.use(async (message: UniversalMessage, next) => {
|
|
96
|
+
const response = await next(message);
|
|
97
|
+
|
|
98
|
+
// Add custom metrics
|
|
99
|
+
if (!response.metadata) {
|
|
100
|
+
response.metadata = {};
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
response.metadata.processedBy = 'bridge';
|
|
104
|
+
response.metadata.protocolTranslation = `${message.from.protocol}→${message.to.protocol}`;
|
|
105
|
+
|
|
106
|
+
return response;
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
console.log('✓ Middleware configured');
|
|
110
|
+
console.log('Bridge is ready with 4 middleware layers:');
|
|
111
|
+
console.log(' 1. Logging');
|
|
112
|
+
console.log(' 2. Authentication');
|
|
113
|
+
console.log(' 3. Rate Limiting');
|
|
114
|
+
console.log(' 4. Metrics Collection');
|
|
115
|
+
|
|
116
|
+
// Test sending a message
|
|
117
|
+
try {
|
|
118
|
+
await bridge.send({
|
|
119
|
+
from: { id: 'agent-a', protocol: 'mcp' },
|
|
120
|
+
to: { id: 'agent-b', protocol: 'a2a' },
|
|
121
|
+
action: 'test',
|
|
122
|
+
params: {},
|
|
123
|
+
});
|
|
124
|
+
} catch (error) {
|
|
125
|
+
console.error('Expected error (no agents registered):', error);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
await bridge.shutdown();
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
main().catch(console.error);
|