@radaros/transport 0.3.21 → 0.3.22
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/dist/index.cjs +2032 -0
- package/dist/index.d.cts +333 -0
- package/package.json +9 -6
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
import { Agent, A2AAgentCard, MCPToolProviderConfig, ToolDef, MCPToolProvider, Registry, Servable, Team, Workflow, Toolkit, EventBus, VoiceAgent } from '@radaros/core';
|
|
2
|
+
|
|
3
|
+
interface A2AServerOptions {
|
|
4
|
+
agents: Record<string, Agent>;
|
|
5
|
+
basePath?: string;
|
|
6
|
+
provider?: {
|
|
7
|
+
organization: string;
|
|
8
|
+
url?: string;
|
|
9
|
+
};
|
|
10
|
+
version?: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Mount an A2A-compliant server on an Express app.
|
|
15
|
+
*
|
|
16
|
+
* - Serves `/.well-known/agent.json` with the Agent Card
|
|
17
|
+
* - Handles JSON-RPC 2.0 requests at the basePath for message/send, message/stream, tasks/get, tasks/cancel
|
|
18
|
+
*/
|
|
19
|
+
declare function createA2AServer(app: any, opts: A2AServerOptions): void;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Generate an A2A Agent Card from a RadarOS Agent.
|
|
23
|
+
* The card is served at /.well-known/agent.json per the A2A spec.
|
|
24
|
+
*/
|
|
25
|
+
declare function generateAgentCard(agent: Agent, serverUrl: string, provider?: {
|
|
26
|
+
organization: string;
|
|
27
|
+
url?: string;
|
|
28
|
+
}, version?: string): A2AAgentCard;
|
|
29
|
+
/**
|
|
30
|
+
* Generate a combined Agent Card that lists multiple agents as skills.
|
|
31
|
+
*/
|
|
32
|
+
declare function generateMultiAgentCard(agents: Record<string, Agent>, serverUrl: string, provider?: {
|
|
33
|
+
organization: string;
|
|
34
|
+
url?: string;
|
|
35
|
+
}, version?: string): A2AAgentCard;
|
|
36
|
+
|
|
37
|
+
interface MCPServerEntry {
|
|
38
|
+
id: string;
|
|
39
|
+
config: MCPToolProviderConfig;
|
|
40
|
+
provider: MCPToolProvider;
|
|
41
|
+
status: "disconnected" | "connecting" | "connected" | "error";
|
|
42
|
+
error?: string;
|
|
43
|
+
toolCount: number;
|
|
44
|
+
connectedAt?: Date;
|
|
45
|
+
}
|
|
46
|
+
interface MCPServerSummary {
|
|
47
|
+
id: string;
|
|
48
|
+
name: string;
|
|
49
|
+
transport: string;
|
|
50
|
+
url?: string;
|
|
51
|
+
command?: string;
|
|
52
|
+
status: string;
|
|
53
|
+
toolCount: number;
|
|
54
|
+
error?: string;
|
|
55
|
+
connectedAt?: string;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Manages multiple MCP server connections at runtime.
|
|
59
|
+
* Servers can be added/removed/connected/disconnected dynamically,
|
|
60
|
+
* and their tools can be collected for injection into agents.
|
|
61
|
+
*/
|
|
62
|
+
declare class MCPManager {
|
|
63
|
+
private servers;
|
|
64
|
+
/** Add a server config. Auto-generates an id from the name if not provided. */
|
|
65
|
+
add(config: MCPToolProviderConfig, id?: string): MCPServerSummary;
|
|
66
|
+
/** Connect a server by id. Discovers tools on success. */
|
|
67
|
+
connect(id: string): Promise<MCPServerSummary>;
|
|
68
|
+
/** Disconnect a server by id. */
|
|
69
|
+
disconnect(id: string): Promise<MCPServerSummary>;
|
|
70
|
+
/** Remove a server entirely. Disconnects first if connected. */
|
|
71
|
+
remove(id: string): Promise<void>;
|
|
72
|
+
/** Get all tools from all connected servers, merged into one array. */
|
|
73
|
+
getAllTools(): Promise<ToolDef[]>;
|
|
74
|
+
/** Get tools from a specific server. */
|
|
75
|
+
getTools(id: string): Promise<ToolDef[]>;
|
|
76
|
+
/** List all registered servers. */
|
|
77
|
+
list(): MCPServerSummary[];
|
|
78
|
+
/** Get a single server summary. */
|
|
79
|
+
get(id: string): MCPServerSummary;
|
|
80
|
+
has(id: string): boolean;
|
|
81
|
+
/** Disconnect all servers. */
|
|
82
|
+
closeAll(): Promise<void>;
|
|
83
|
+
private getEntry;
|
|
84
|
+
private summarize;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
interface AdminRouterOptions {
|
|
88
|
+
/** Shared MCPManager instance. If omitted, a new one is created. */
|
|
89
|
+
mcpManager?: MCPManager;
|
|
90
|
+
/**
|
|
91
|
+
* Express middleware for authentication/authorization.
|
|
92
|
+
* **IMPORTANT**: These endpoints can add MCP servers and execute tools.
|
|
93
|
+
* Always add auth middleware in production.
|
|
94
|
+
*/
|
|
95
|
+
middleware?: any[];
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Creates an Express sub-router with admin endpoints for managing
|
|
99
|
+
* MCP servers and the toolkit catalog at runtime.
|
|
100
|
+
*
|
|
101
|
+
* Mount under a prefix: `app.use("/admin", createAdminRouter())`
|
|
102
|
+
*
|
|
103
|
+
* Routes:
|
|
104
|
+
* GET /mcp — list MCP servers
|
|
105
|
+
* POST /mcp — add + connect an MCP server
|
|
106
|
+
* GET /mcp/:id — single server details
|
|
107
|
+
* POST /mcp/:id/connect — connect a server
|
|
108
|
+
* POST /mcp/:id/disconnect — disconnect
|
|
109
|
+
* DELETE /mcp/:id — remove a server
|
|
110
|
+
* GET /mcp/:id/tools — tools from a specific server
|
|
111
|
+
* GET /mcp/tools — all tools across connected servers
|
|
112
|
+
*
|
|
113
|
+
* GET /toolkits — list toolkit catalog
|
|
114
|
+
* GET /toolkits/:id — single toolkit meta
|
|
115
|
+
* POST /toolkits/:id — instantiate a toolkit with config
|
|
116
|
+
*/
|
|
117
|
+
declare function createAdminRouter(opts?: AdminRouterOptions): {
|
|
118
|
+
router: any;
|
|
119
|
+
mcpManager: MCPManager;
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
interface FileUploadOptions {
|
|
123
|
+
maxFileSize?: number;
|
|
124
|
+
maxFiles?: number;
|
|
125
|
+
allowedMimeTypes?: string[];
|
|
126
|
+
}
|
|
127
|
+
declare function createFileUploadMiddleware(opts?: FileUploadOptions): any;
|
|
128
|
+
declare function buildMultiModalInput(body: any, files?: any[]): string | any[];
|
|
129
|
+
|
|
130
|
+
declare function errorHandler(options?: {
|
|
131
|
+
logger?: Pick<Console, "error">;
|
|
132
|
+
}): (err: any, _req: any, res: any, _next: any) => void;
|
|
133
|
+
declare function requestLogger(options?: {
|
|
134
|
+
logger?: Pick<Console, "log">;
|
|
135
|
+
}): (req: any, _res: any, next: any) => void;
|
|
136
|
+
|
|
137
|
+
interface SwaggerOptions {
|
|
138
|
+
/** Enable Swagger UI at /docs. Default: false */
|
|
139
|
+
enabled?: boolean;
|
|
140
|
+
/** API title shown in Swagger UI */
|
|
141
|
+
title?: string;
|
|
142
|
+
/** API description shown in Swagger UI */
|
|
143
|
+
description?: string;
|
|
144
|
+
/** API version string */
|
|
145
|
+
version?: string;
|
|
146
|
+
/** Route prefix used in path generation (e.g. "/api") */
|
|
147
|
+
routePrefix?: string;
|
|
148
|
+
/** Server URLs for the spec */
|
|
149
|
+
servers?: Array<{
|
|
150
|
+
url: string;
|
|
151
|
+
description?: string;
|
|
152
|
+
}>;
|
|
153
|
+
/** Path to serve Swagger UI. Default: "/docs" */
|
|
154
|
+
docsPath?: string;
|
|
155
|
+
/** Path to serve the raw OpenAPI JSON spec. Default: "/docs/spec.json" */
|
|
156
|
+
specPath?: string;
|
|
157
|
+
}
|
|
158
|
+
interface RouterOptions {
|
|
159
|
+
/**
|
|
160
|
+
* Use a Registry for live auto-discovery. The router creates dynamic routes
|
|
161
|
+
* that resolve agents/teams/workflows at request time — any instance created
|
|
162
|
+
* after the router is mounted is automatically available.
|
|
163
|
+
*
|
|
164
|
+
* When omitted, falls back to the global registry from `@radaros/core`.
|
|
165
|
+
* Pass `false` to disable registry-based routing entirely (use explicit maps only).
|
|
166
|
+
*
|
|
167
|
+
* @example
|
|
168
|
+
* createAgentRouter({ cors: true });
|
|
169
|
+
* new Agent({ name: "bot", model: openai("gpt-4o") }); // immediately routable
|
|
170
|
+
*/
|
|
171
|
+
registry?: Registry | false;
|
|
172
|
+
/**
|
|
173
|
+
* Auto-discover agents, teams, and workflows from a mixed array.
|
|
174
|
+
* Each item is classified by its `.kind` and keyed by `.name`.
|
|
175
|
+
*/
|
|
176
|
+
serve?: Servable[];
|
|
177
|
+
agents?: Record<string, Agent>;
|
|
178
|
+
teams?: Record<string, Team>;
|
|
179
|
+
workflows?: Record<string, Workflow<any>>;
|
|
180
|
+
middleware?: any[];
|
|
181
|
+
/** Swagger / OpenAPI configuration */
|
|
182
|
+
swagger?: SwaggerOptions;
|
|
183
|
+
/** File upload configuration for multi-modal inputs */
|
|
184
|
+
fileUpload?: boolean | FileUploadOptions;
|
|
185
|
+
/** CORS configuration. Pass true or '*' for permissive, a string for a single origin, or an array for multiple origins. */
|
|
186
|
+
cors?: string | string[] | boolean;
|
|
187
|
+
/** Rate limiting configuration. Pass true for defaults (100 req/min), or an object to customize. */
|
|
188
|
+
rateLimit?: {
|
|
189
|
+
windowMs?: number;
|
|
190
|
+
max?: number;
|
|
191
|
+
} | boolean;
|
|
192
|
+
/** Named tool library exposed via GET /tools. Tools from toolkits are auto-collected. */
|
|
193
|
+
toolLibrary?: Record<string, ToolDef>;
|
|
194
|
+
/** Toolkit instances whose tools are exposed via GET /tools. Merged with toolLibrary. */
|
|
195
|
+
toolkits?: Toolkit[];
|
|
196
|
+
/**
|
|
197
|
+
* Enable admin routes under `/admin` for managing MCP servers and the toolkit catalog.
|
|
198
|
+
* Pass `true` to use defaults, or provide an MCPManager instance to share state.
|
|
199
|
+
*/
|
|
200
|
+
admin?: boolean | {
|
|
201
|
+
mcpManager?: MCPManager;
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
declare function createAgentRouter(opts: RouterOptions): any;
|
|
206
|
+
|
|
207
|
+
interface OpenAPISpec {
|
|
208
|
+
openapi: string;
|
|
209
|
+
info: {
|
|
210
|
+
title: string;
|
|
211
|
+
description: string;
|
|
212
|
+
version: string;
|
|
213
|
+
};
|
|
214
|
+
servers?: Array<{
|
|
215
|
+
url: string;
|
|
216
|
+
description?: string;
|
|
217
|
+
}>;
|
|
218
|
+
paths: Record<string, Record<string, unknown>>;
|
|
219
|
+
components: {
|
|
220
|
+
schemas: Record<string, unknown>;
|
|
221
|
+
securitySchemes?: Record<string, unknown>;
|
|
222
|
+
};
|
|
223
|
+
security?: Array<Record<string, string[]>>;
|
|
224
|
+
tags: Array<{
|
|
225
|
+
name: string;
|
|
226
|
+
description: string;
|
|
227
|
+
}>;
|
|
228
|
+
}
|
|
229
|
+
declare function generateOpenAPISpec(routerOpts: RouterOptions, swaggerOpts?: SwaggerOptions): OpenAPISpec;
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* Minimal interface for a BrowserAgent — avoids a hard dependency on @radaros/browser.
|
|
233
|
+
* Any object that matches this shape (e.g. a real BrowserAgent) works.
|
|
234
|
+
*/
|
|
235
|
+
interface BrowserAgentLike {
|
|
236
|
+
name: string;
|
|
237
|
+
eventBus: EventBus;
|
|
238
|
+
run(task: string, opts?: {
|
|
239
|
+
startUrl?: string;
|
|
240
|
+
apiKey?: string;
|
|
241
|
+
sessionId?: string;
|
|
242
|
+
}): Promise<{
|
|
243
|
+
result: string;
|
|
244
|
+
success: boolean;
|
|
245
|
+
finalUrl: string;
|
|
246
|
+
durationMs: number;
|
|
247
|
+
videoPath?: string;
|
|
248
|
+
steps: Array<{
|
|
249
|
+
index: number;
|
|
250
|
+
action: unknown;
|
|
251
|
+
screenshot: Buffer;
|
|
252
|
+
pageUrl: string;
|
|
253
|
+
pageTitle: string;
|
|
254
|
+
dom?: string;
|
|
255
|
+
}>;
|
|
256
|
+
}>;
|
|
257
|
+
}
|
|
258
|
+
interface BrowserGatewayOptions {
|
|
259
|
+
/** Named BrowserAgent instances. Clients select one via agentName. */
|
|
260
|
+
agents: Record<string, BrowserAgentLike>;
|
|
261
|
+
/** Socket.IO server instance */
|
|
262
|
+
io: any;
|
|
263
|
+
/** Socket.IO namespace. Default: "/radaros-browser" */
|
|
264
|
+
namespace?: string;
|
|
265
|
+
/** Optional auth middleware applied to the namespace */
|
|
266
|
+
authMiddleware?: (socket: any, next: (err?: Error) => void) => void;
|
|
267
|
+
/**
|
|
268
|
+
* Stream screenshots to the client in real-time.
|
|
269
|
+
* Default: true. Disable for bandwidth-constrained clients.
|
|
270
|
+
*/
|
|
271
|
+
streamScreenshots?: boolean;
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* Create a Socket.IO gateway that streams BrowserAgent execution in real-time.
|
|
275
|
+
*
|
|
276
|
+
* ## Client → Server events
|
|
277
|
+
* - `browser.start` — kick off a browser task
|
|
278
|
+
* - `browser.stop` — cancel a running task
|
|
279
|
+
*
|
|
280
|
+
* ## Server → Client events
|
|
281
|
+
* - `browser.started` — task accepted
|
|
282
|
+
* - `browser.screenshot` — live screenshot (base64 PNG)
|
|
283
|
+
* - `browser.action` — action about to execute
|
|
284
|
+
* - `browser.step` — full step with screenshot + DOM
|
|
285
|
+
* - `browser.done` — task finished (result, success, duration, video)
|
|
286
|
+
* - `browser.error` — error occurred
|
|
287
|
+
* - `browser.stopped` — task was cancelled
|
|
288
|
+
*/
|
|
289
|
+
declare function createBrowserGateway(opts: BrowserGatewayOptions): void;
|
|
290
|
+
|
|
291
|
+
interface GatewayOptions {
|
|
292
|
+
/**
|
|
293
|
+
* Use a Registry for live auto-discovery. The gateway resolves agents/teams
|
|
294
|
+
* at event time — any instance created after the gateway starts is automatically
|
|
295
|
+
* reachable.
|
|
296
|
+
*
|
|
297
|
+
* When omitted, falls back to the global registry from `@radaros/core`.
|
|
298
|
+
* Pass `false` to disable registry-based lookup (use explicit maps only).
|
|
299
|
+
*
|
|
300
|
+
* @example
|
|
301
|
+
* createAgentGateway({ io });
|
|
302
|
+
* new Agent({ name: "bot", model: openai("gpt-4o") }); // immediately reachable
|
|
303
|
+
*/
|
|
304
|
+
registry?: Registry | false;
|
|
305
|
+
/**
|
|
306
|
+
* Auto-discover agents and teams from a mixed array.
|
|
307
|
+
* Each item is classified by its `.kind` and keyed by `.name`.
|
|
308
|
+
*/
|
|
309
|
+
serve?: Servable[];
|
|
310
|
+
agents?: Record<string, Agent>;
|
|
311
|
+
teams?: Record<string, Team>;
|
|
312
|
+
io: any;
|
|
313
|
+
namespace?: string;
|
|
314
|
+
authMiddleware?: (socket: any, next: (err?: Error) => void) => void;
|
|
315
|
+
/** Max requests per minute per socket. Default: 60 */
|
|
316
|
+
maxRequestsPerMinute?: number;
|
|
317
|
+
/** Named tool library exposed via tools.list event. */
|
|
318
|
+
toolLibrary?: Record<string, ToolDef>;
|
|
319
|
+
/** Toolkit instances whose tools are exposed via tools.list. Merged with toolLibrary. */
|
|
320
|
+
toolkits?: Toolkit[];
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
declare function createAgentGateway(opts: GatewayOptions): void;
|
|
324
|
+
|
|
325
|
+
interface VoiceGatewayOptions {
|
|
326
|
+
agents: Record<string, VoiceAgent>;
|
|
327
|
+
io: any;
|
|
328
|
+
namespace?: string;
|
|
329
|
+
authMiddleware?: (socket: any, next: (err?: Error) => void) => void;
|
|
330
|
+
}
|
|
331
|
+
declare function createVoiceGateway(opts: VoiceGatewayOptions): void;
|
|
332
|
+
|
|
333
|
+
export { type A2AServerOptions, type AdminRouterOptions, type BrowserGatewayOptions, type FileUploadOptions, type GatewayOptions, MCPManager, type MCPServerEntry, type MCPServerSummary, type RouterOptions, type SwaggerOptions, type VoiceGatewayOptions, buildMultiModalInput, createA2AServer, createAdminRouter, createAgentGateway, createAgentRouter, createBrowserGateway, createFileUploadMiddleware, createVoiceGateway, errorHandler, generateAgentCard, generateMultiAgentCard, generateOpenAPISpec, requestLogger };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@radaros/transport",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.22",
|
|
4
4
|
"description": "HTTP and WebSocket transport layer for RadarOS agents",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -17,20 +17,23 @@
|
|
|
17
17
|
"transport"
|
|
18
18
|
],
|
|
19
19
|
"type": "module",
|
|
20
|
-
"main": "./dist/index.
|
|
20
|
+
"main": "./dist/index.cjs",
|
|
21
|
+
"module": "./dist/index.js",
|
|
21
22
|
"types": "./dist/index.d.ts",
|
|
22
23
|
"exports": {
|
|
23
24
|
".": {
|
|
25
|
+
"types": "./dist/index.d.ts",
|
|
24
26
|
"import": "./dist/index.js",
|
|
25
|
-
"
|
|
27
|
+
"require": "./dist/index.cjs",
|
|
28
|
+
"default": "./dist/index.js"
|
|
26
29
|
}
|
|
27
30
|
},
|
|
28
31
|
"files": [
|
|
29
32
|
"dist"
|
|
30
33
|
],
|
|
31
34
|
"scripts": {
|
|
32
|
-
"build": "tsup src/index.ts --format esm --dts --clean",
|
|
33
|
-
"dev": "tsup src/index.ts --format esm --dts --watch",
|
|
35
|
+
"build": "tsup src/index.ts --format esm,cjs --dts --clean",
|
|
36
|
+
"dev": "tsup src/index.ts --format esm,cjs --dts --watch",
|
|
34
37
|
"prepublishOnly": "npm run build"
|
|
35
38
|
},
|
|
36
39
|
"devDependencies": {
|
|
@@ -39,7 +42,7 @@
|
|
|
39
42
|
"typescript": "^5.6.0"
|
|
40
43
|
},
|
|
41
44
|
"peerDependencies": {
|
|
42
|
-
"@radaros/core": "^0.3.
|
|
45
|
+
"@radaros/core": "^0.3.22",
|
|
43
46
|
"@types/express": "^4.0.0 || ^5.0.0",
|
|
44
47
|
"express": "^4.0.0 || ^5.0.0",
|
|
45
48
|
"multer": ">=2.0.0",
|