@agentium/transport 3.1.0 → 3.1.2
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/a2a/a2a-server.d.ts +9 -0
- package/dist/a2a/a2a-server.d.ts.map +1 -0
- package/dist/a2a/agent-card.d.ts +17 -0
- package/dist/a2a/agent-card.d.ts.map +1 -0
- package/dist/a2a/types.d.ts +11 -0
- package/dist/a2a/types.d.ts.map +1 -0
- package/dist/express/admin-router.d.ts +36 -0
- package/dist/express/admin-router.d.ts.map +1 -0
- package/dist/express/file-upload.d.ts +9 -0
- package/dist/express/file-upload.d.ts.map +1 -0
- package/dist/express/gateway.d.ts +16 -0
- package/dist/express/gateway.d.ts.map +1 -0
- package/dist/express/jwt-middleware.d.ts +10 -0
- package/dist/express/jwt-middleware.d.ts.map +1 -0
- package/dist/express/mcp-manager.d.ts +52 -0
- package/dist/express/mcp-manager.d.ts.map +1 -0
- package/dist/express/middleware.d.ts +7 -0
- package/dist/express/middleware.d.ts.map +1 -0
- package/dist/express/rbac-middleware.d.ts +7 -0
- package/dist/express/rbac-middleware.d.ts.map +1 -0
- package/dist/express/router-factory.d.ts +3 -0
- package/dist/express/router-factory.d.ts.map +1 -0
- package/dist/express/swagger.d.ts +30 -0
- package/dist/express/swagger.d.ts.map +1 -0
- package/dist/express/types.d.ts +91 -0
- package/dist/express/types.d.ts.map +1 -0
- package/dist/express/ui-stream.d.ts +78 -0
- package/dist/express/ui-stream.d.ts.map +1 -0
- package/dist/index.d.ts +32 -523
- package/dist/index.d.ts.map +1 -0
- package/dist/socketio/browser-gateway.d.ts +62 -0
- package/dist/socketio/browser-gateway.d.ts.map +1 -0
- package/dist/socketio/gateway.d.ts +3 -0
- package/dist/socketio/gateway.d.ts.map +1 -0
- package/dist/socketio/handlers.d.ts +2 -0
- package/dist/socketio/handlers.d.ts.map +1 -0
- package/dist/socketio/types.d.ts +33 -0
- package/dist/socketio/types.d.ts.map +1 -0
- package/dist/socketio/vision-gateway.d.ts +9 -0
- package/dist/socketio/vision-gateway.d.ts.map +1 -0
- package/dist/socketio/voice-gateway.d.ts +9 -0
- package/dist/socketio/voice-gateway.d.ts.map +1 -0
- package/dist/sse-event-log.d.ts +54 -0
- package/dist/sse-event-log.d.ts.map +1 -0
- package/package.json +4 -4
- package/dist/index.d.cts +0 -523
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/socketio/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,aAAa,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAEvG,MAAM,WAAW,cAAc;IAC7B;;;;;;;;;;;OAWG;IACH,QAAQ,CAAC,EAAE,QAAQ,GAAG,KAAK,CAAC;IAC5B;;;OAGG;IACH,KAAK,CAAC,EAAE,QAAQ,EAAE,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,GAAG,aAAa,CAAC,CAAC;IAC/C,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IAC7B,EAAE,EAAE,GAAG,CAAC;IACR,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,GAAG,CAAC,EAAE,KAAK,KAAK,IAAI,KAAK,IAAI,CAAC;IACpE,sDAAsD;IACtD,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,uDAAuD;IACvD,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACtC,yFAAyF;IACzF,QAAQ,CAAC,EAAE,OAAO,EAAE,CAAC;CACtB"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { VisionAgent } from "@agentium/core";
|
|
2
|
+
export interface VisionGatewayOptions {
|
|
3
|
+
agents: Record<string, VisionAgent>;
|
|
4
|
+
io: any;
|
|
5
|
+
namespace?: string;
|
|
6
|
+
authMiddleware?: (socket: any, next: (err?: Error) => void) => void;
|
|
7
|
+
}
|
|
8
|
+
export declare function createVisionGateway(opts: VisionGatewayOptions): void;
|
|
9
|
+
//# sourceMappingURL=vision-gateway.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vision-gateway.d.ts","sourceRoot":"","sources":["../../src/socketio/vision-gateway.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAElD,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IACpC,EAAE,EAAE,GAAG,CAAC;IACR,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,GAAG,CAAC,EAAE,KAAK,KAAK,IAAI,KAAK,IAAI,CAAC;CACrE;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,oBAAoB,GAAG,IAAI,CA6IpE"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { VoiceAgent } from "@agentium/core";
|
|
2
|
+
export interface VoiceGatewayOptions {
|
|
3
|
+
agents: Record<string, VoiceAgent>;
|
|
4
|
+
io: any;
|
|
5
|
+
namespace?: string;
|
|
6
|
+
authMiddleware?: (socket: any, next: (err?: Error) => void) => void;
|
|
7
|
+
}
|
|
8
|
+
export declare function createVoiceGateway(opts: VoiceGatewayOptions): void;
|
|
9
|
+
//# sourceMappingURL=voice-gateway.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"voice-gateway.d.ts","sourceRoot":"","sources":["../../src/socketio/voice-gateway.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAEjD,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IACnC,EAAE,EAAE,GAAG,CAAC;IACR,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,GAAG,CAAC,EAAE,KAAK,KAAK,IAAI,KAAK,IAAI,CAAC;CACrE;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,mBAAmB,GAAG,IAAI,CAgKlE"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Per-run in-memory ring buffer of SSE events. Each event gets a monotonically
|
|
3
|
+
* increasing numeric `id` so clients can pass `Last-Event-ID` on reconnect and
|
|
4
|
+
* replay missed events.
|
|
5
|
+
*
|
|
6
|
+
* Storage is intentionally in-process; for multi-instance deployments, plug a
|
|
7
|
+
* Redis-backed implementation behind the same interface.
|
|
8
|
+
*/
|
|
9
|
+
export interface SSEEvent {
|
|
10
|
+
/** Monotonic numeric ID. */
|
|
11
|
+
id: number;
|
|
12
|
+
/** Optional `event:` line value. Default omitted. */
|
|
13
|
+
event?: string;
|
|
14
|
+
/** Payload (will be JSON-stringified into the `data:` field). */
|
|
15
|
+
payload: unknown;
|
|
16
|
+
/** Wall-clock time the event was recorded. */
|
|
17
|
+
recordedAt: number;
|
|
18
|
+
}
|
|
19
|
+
export interface SSEEventLog {
|
|
20
|
+
/** Record a new event and return its assigned id. */
|
|
21
|
+
record(runId: string, event: Omit<SSEEvent, "id" | "recordedAt">): SSEEvent;
|
|
22
|
+
/** Return events for a run with id greater than `afterId`. */
|
|
23
|
+
since(runId: string, afterId: number): SSEEvent[];
|
|
24
|
+
/** All events for a run. */
|
|
25
|
+
all(runId: string): SSEEvent[];
|
|
26
|
+
/** Mark a run completed (frees buffers after `ttlMs`). */
|
|
27
|
+
finalize(runId: string): void;
|
|
28
|
+
/** Remove a run's buffer immediately. */
|
|
29
|
+
drop(runId: string): void;
|
|
30
|
+
}
|
|
31
|
+
export interface InMemoryEventLogConfig {
|
|
32
|
+
/** Max events kept per run. Oldest evicted when exceeded. Default: 1024. */
|
|
33
|
+
maxEventsPerRun?: number;
|
|
34
|
+
/** Milliseconds after finalize before a run's buffer is dropped. Default: 300_000 (5min). */
|
|
35
|
+
ttlMs?: number;
|
|
36
|
+
}
|
|
37
|
+
export declare class InMemoryEventLog implements SSEEventLog {
|
|
38
|
+
private buffers;
|
|
39
|
+
private nextIds;
|
|
40
|
+
private finalizeTimers;
|
|
41
|
+
private maxEvents;
|
|
42
|
+
private ttlMs;
|
|
43
|
+
constructor(config?: InMemoryEventLogConfig);
|
|
44
|
+
record(runId: string, event: Omit<SSEEvent, "id" | "recordedAt">): SSEEvent;
|
|
45
|
+
since(runId: string, afterId: number): SSEEvent[];
|
|
46
|
+
all(runId: string): SSEEvent[];
|
|
47
|
+
finalize(runId: string): void;
|
|
48
|
+
drop(runId: string): void;
|
|
49
|
+
}
|
|
50
|
+
/** Format an `SSEEvent` for the wire. */
|
|
51
|
+
export declare function formatSSEEvent(ev: SSEEvent): string;
|
|
52
|
+
/** Process-wide default log so multiple endpoints can share one buffer. */
|
|
53
|
+
export declare const defaultEventLog: InMemoryEventLog;
|
|
54
|
+
//# sourceMappingURL=sse-event-log.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sse-event-log.d.ts","sourceRoot":"","sources":["../src/sse-event-log.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,WAAW,QAAQ;IACvB,4BAA4B;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,qDAAqD;IACrD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,iEAAiE;IACjE,OAAO,EAAE,OAAO,CAAC;IACjB,8CAA8C;IAC9C,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,WAAW;IAC1B,qDAAqD;IACrD,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,QAAQ,EAAE,IAAI,GAAG,YAAY,CAAC,GAAG,QAAQ,CAAC;IAC5E,8DAA8D;IAC9D,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,QAAQ,EAAE,CAAC;IAClD,4BAA4B;IAC5B,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,QAAQ,EAAE,CAAC;IAC/B,0DAA0D;IAC1D,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,yCAAyC;IACzC,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B;AAED,MAAM,WAAW,sBAAsB;IACrC,4EAA4E;IAC5E,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,6FAA6F;IAC7F,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,qBAAa,gBAAiB,YAAW,WAAW;IAClD,OAAO,CAAC,OAAO,CAAiC;IAChD,OAAO,CAAC,OAAO,CAA6B;IAC5C,OAAO,CAAC,cAAc,CAAqC;IAC3D,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,KAAK,CAAS;gBAEV,MAAM,GAAE,sBAA2B;IAK/C,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,QAAQ,EAAE,IAAI,GAAG,YAAY,CAAC,GAAG,QAAQ;IAW3E,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,QAAQ,EAAE;IAKjD,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,QAAQ,EAAE;IAI9B,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAS7B,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;CAO1B;AAED,yCAAyC;AACzC,wBAAgB,cAAc,CAAC,EAAE,EAAE,QAAQ,GAAG,MAAM,CAMnD;AAED,2EAA2E;AAC3E,eAAO,MAAM,eAAe,kBAAyB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agentium/transport",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.2",
|
|
4
4
|
"description": "HTTP and WebSocket transport layer for Agentium agents",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
@@ -35,8 +35,8 @@
|
|
|
35
35
|
"dist"
|
|
36
36
|
],
|
|
37
37
|
"scripts": {
|
|
38
|
-
"build": "tsup src/index.ts --format esm,cjs --
|
|
39
|
-
"dev": "tsup src/index.ts --format esm,cjs --
|
|
38
|
+
"build": "tsup src/index.ts --format esm,cjs --shims --clean && tsc -p tsconfig.build.json --emitDeclarationOnly --declaration --pretty false",
|
|
39
|
+
"dev": "tsup src/index.ts --format esm,cjs --shims --watch",
|
|
40
40
|
"prepublishOnly": "npm run build"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"typescript": "^5.6.0"
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
|
-
"@agentium/core": "^3.1.
|
|
48
|
+
"@agentium/core": "^3.1.2",
|
|
49
49
|
"@types/express": "^4.0.0 || ^5.0.0",
|
|
50
50
|
"express": "^4.0.0 || ^5.0.0",
|
|
51
51
|
"multer": ">=2.0.0",
|
package/dist/index.d.cts
DELETED
|
@@ -1,523 +0,0 @@
|
|
|
1
|
-
import { Agent, A2AAgentCard, MCPToolProviderConfig, ToolDef, MCPToolProvider, Registry, Servable, ServableAgent, Team, Workflow, Toolkit, EventBus, VisionAgent, VoiceAgent } from '@agentium/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 Agentium 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
|
-
interface RbacConfig {
|
|
131
|
-
scopeField?: string;
|
|
132
|
-
defaultScopes?: Record<string, string[]>;
|
|
133
|
-
agentScopes?: Record<string, string[]>;
|
|
134
|
-
}
|
|
135
|
-
declare function createRbacMiddleware(config?: RbacConfig): (req: any, res: any, next: any) => any;
|
|
136
|
-
|
|
137
|
-
interface JwtConfig {
|
|
138
|
-
secret: string;
|
|
139
|
-
algorithm?: string;
|
|
140
|
-
issuer?: string;
|
|
141
|
-
audience?: string;
|
|
142
|
-
extractFrom?: "header" | "cookie";
|
|
143
|
-
cookieName?: string;
|
|
144
|
-
}
|
|
145
|
-
declare function createJwtMiddleware(config: JwtConfig): (req: any, res: any, next: any) => any;
|
|
146
|
-
|
|
147
|
-
interface SwaggerOptions {
|
|
148
|
-
/** Enable Swagger UI at /docs. Default: false */
|
|
149
|
-
enabled?: boolean;
|
|
150
|
-
/** API title shown in Swagger UI */
|
|
151
|
-
title?: string;
|
|
152
|
-
/** API description shown in Swagger UI */
|
|
153
|
-
description?: string;
|
|
154
|
-
/** API version string */
|
|
155
|
-
version?: string;
|
|
156
|
-
/** Route prefix used in path generation (e.g. "/api") */
|
|
157
|
-
routePrefix?: string;
|
|
158
|
-
/** Server URLs for the spec */
|
|
159
|
-
servers?: Array<{
|
|
160
|
-
url: string;
|
|
161
|
-
description?: string;
|
|
162
|
-
}>;
|
|
163
|
-
/** Path to serve Swagger UI. Default: "/docs" */
|
|
164
|
-
docsPath?: string;
|
|
165
|
-
/** Path to serve the raw OpenAPI JSON spec. Default: "/docs/spec.json" */
|
|
166
|
-
specPath?: string;
|
|
167
|
-
}
|
|
168
|
-
interface RouterOptions {
|
|
169
|
-
/**
|
|
170
|
-
* Use a Registry for live auto-discovery. The router creates dynamic routes
|
|
171
|
-
* that resolve agents/teams/workflows at request time — any instance created
|
|
172
|
-
* after the router is mounted is automatically available.
|
|
173
|
-
*
|
|
174
|
-
* When omitted, falls back to the global registry from `@agentium/core`.
|
|
175
|
-
* Pass `false` to disable registry-based routing entirely (use explicit maps only).
|
|
176
|
-
*
|
|
177
|
-
* @example
|
|
178
|
-
* createAgentRouter({ cors: true });
|
|
179
|
-
* new Agent({ name: "bot", model: openai("gpt-4o") }); // immediately routable
|
|
180
|
-
*/
|
|
181
|
-
registry?: Registry | false;
|
|
182
|
-
/**
|
|
183
|
-
* Auto-discover agents, teams, and workflows from a mixed array.
|
|
184
|
-
* Each item is classified by its `.kind` and keyed by `.name`.
|
|
185
|
-
*/
|
|
186
|
-
serve?: Servable[];
|
|
187
|
-
agents?: Record<string, Agent | ServableAgent>;
|
|
188
|
-
teams?: Record<string, Team>;
|
|
189
|
-
workflows?: Record<string, Workflow<any>>;
|
|
190
|
-
middleware?: any[];
|
|
191
|
-
/** Swagger / OpenAPI configuration */
|
|
192
|
-
swagger?: SwaggerOptions;
|
|
193
|
-
/** File upload configuration for multi-modal inputs */
|
|
194
|
-
fileUpload?: boolean | FileUploadOptions;
|
|
195
|
-
/** CORS configuration. Pass true or '*' for permissive, a string for a single origin, or an array for multiple origins. */
|
|
196
|
-
cors?: string | string[] | boolean;
|
|
197
|
-
/** Rate limiting configuration. Pass true for defaults (100 req/min), or an object to customize. */
|
|
198
|
-
rateLimit?: {
|
|
199
|
-
windowMs?: number;
|
|
200
|
-
max?: number;
|
|
201
|
-
} | boolean;
|
|
202
|
-
/** Named tool library exposed via GET /tools. Tools from toolkits are auto-collected. */
|
|
203
|
-
toolLibrary?: Record<string, ToolDef>;
|
|
204
|
-
/** Toolkit instances whose tools are exposed via GET /tools. Merged with toolLibrary. */
|
|
205
|
-
toolkits?: Toolkit[];
|
|
206
|
-
/**
|
|
207
|
-
* Enable admin routes under `/admin` for managing MCP servers and the toolkit catalog.
|
|
208
|
-
* Pass `true` to use defaults, or provide an MCPManager instance to share state.
|
|
209
|
-
*/
|
|
210
|
-
admin?: boolean | {
|
|
211
|
-
mcpManager?: MCPManager;
|
|
212
|
-
middleware?: any[];
|
|
213
|
-
};
|
|
214
|
-
/**
|
|
215
|
-
* Enable schedule management routes under `/schedules`.
|
|
216
|
-
* Pass an AgentQueue instance from `@agentium/queue`.
|
|
217
|
-
*/
|
|
218
|
-
scheduler?: any;
|
|
219
|
-
/**
|
|
220
|
-
* MetricsExporter instance from `@agentium/observability` for `/metrics` endpoints.
|
|
221
|
-
*/
|
|
222
|
-
metricsExporter?: any;
|
|
223
|
-
/**
|
|
224
|
-
* JWT authentication middleware. Verifies tokens and attaches decoded payload to `req.user`.
|
|
225
|
-
* Requires `jsonwebtoken` package.
|
|
226
|
-
*/
|
|
227
|
-
jwt?: JwtConfig;
|
|
228
|
-
/**
|
|
229
|
-
* Role-based access control. Checks `req.user.scopes` against required scopes per route.
|
|
230
|
-
* Requires `jwt` to be configured first.
|
|
231
|
-
*/
|
|
232
|
-
rbac?: RbacConfig;
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
interface RemoteEndpoint {
|
|
236
|
-
baseUrl: string;
|
|
237
|
-
agents?: string[];
|
|
238
|
-
teams?: string[];
|
|
239
|
-
workflows?: string[];
|
|
240
|
-
headers?: Record<string, string>;
|
|
241
|
-
healthPath?: string;
|
|
242
|
-
}
|
|
243
|
-
interface GatewayConfig {
|
|
244
|
-
locals?: RouterOptions;
|
|
245
|
-
remotes: RemoteEndpoint[];
|
|
246
|
-
healthCheckIntervalMs?: number;
|
|
247
|
-
}
|
|
248
|
-
declare function createGatewayRouter(config: GatewayConfig): any;
|
|
249
|
-
|
|
250
|
-
declare function errorHandler(options?: {
|
|
251
|
-
logger?: Pick<Console, "error">;
|
|
252
|
-
}): (err: any, _req: any, res: any, _next: any) => void;
|
|
253
|
-
declare function requestLogger(options?: {
|
|
254
|
-
logger?: Pick<Console, "log">;
|
|
255
|
-
}): (req: any, _res: any, next: any) => void;
|
|
256
|
-
|
|
257
|
-
declare function createAgentRouter(opts: RouterOptions): any;
|
|
258
|
-
|
|
259
|
-
interface OpenAPISpec {
|
|
260
|
-
openapi: string;
|
|
261
|
-
info: {
|
|
262
|
-
title: string;
|
|
263
|
-
description: string;
|
|
264
|
-
version: string;
|
|
265
|
-
};
|
|
266
|
-
servers?: Array<{
|
|
267
|
-
url: string;
|
|
268
|
-
description?: string;
|
|
269
|
-
}>;
|
|
270
|
-
paths: Record<string, Record<string, unknown>>;
|
|
271
|
-
components: {
|
|
272
|
-
schemas: Record<string, unknown>;
|
|
273
|
-
securitySchemes?: Record<string, unknown>;
|
|
274
|
-
};
|
|
275
|
-
security?: Array<Record<string, string[]>>;
|
|
276
|
-
tags: Array<{
|
|
277
|
-
name: string;
|
|
278
|
-
description: string;
|
|
279
|
-
}>;
|
|
280
|
-
}
|
|
281
|
-
declare function generateOpenAPISpec(routerOpts: RouterOptions, swaggerOpts?: SwaggerOptions): OpenAPISpec;
|
|
282
|
-
|
|
283
|
-
/**
|
|
284
|
-
* Vercel AI SDK UI Message Stream adapter.
|
|
285
|
-
*
|
|
286
|
-
* Converts the chunks emitted by `agent.stream(...)` into the line-delimited
|
|
287
|
-
* JSON protocol consumed by Vercel's `useChat` / `createAgentUIStreamResponse`.
|
|
288
|
-
*
|
|
289
|
-
* Spec: https://ai-sdk.dev/docs/ai-sdk-ui/stream-protocol
|
|
290
|
-
*/
|
|
291
|
-
interface AgentUIStreamOptions {
|
|
292
|
-
/** sessionId forwarded to `agent.run` / `agent.stream`. */
|
|
293
|
-
sessionId?: string;
|
|
294
|
-
/** userId forwarded to `agent.run` / `agent.stream`. */
|
|
295
|
-
userId?: string;
|
|
296
|
-
/** Optional per-request API key override. */
|
|
297
|
-
apiKey?: string;
|
|
298
|
-
/** Optional abort signal to cancel the run. */
|
|
299
|
-
signal?: AbortSignal;
|
|
300
|
-
}
|
|
301
|
-
interface AgentLikeChunk {
|
|
302
|
-
type?: string;
|
|
303
|
-
text?: string;
|
|
304
|
-
delta?: string;
|
|
305
|
-
toolCallId?: string;
|
|
306
|
-
toolName?: string;
|
|
307
|
-
arguments?: unknown;
|
|
308
|
-
args?: unknown;
|
|
309
|
-
input?: unknown;
|
|
310
|
-
output?: unknown;
|
|
311
|
-
result?: unknown;
|
|
312
|
-
finishReason?: string;
|
|
313
|
-
usage?: {
|
|
314
|
-
promptTokens?: number;
|
|
315
|
-
completionTokens?: number;
|
|
316
|
-
totalTokens?: number;
|
|
317
|
-
};
|
|
318
|
-
error?: string | {
|
|
319
|
-
message?: string;
|
|
320
|
-
};
|
|
321
|
-
reasoning?: string;
|
|
322
|
-
thinking?: string;
|
|
323
|
-
}
|
|
324
|
-
interface AgentLike {
|
|
325
|
-
stream(input: string, opts?: {
|
|
326
|
-
sessionId?: string;
|
|
327
|
-
userId?: string;
|
|
328
|
-
apiKey?: string;
|
|
329
|
-
signal?: AbortSignal;
|
|
330
|
-
}): AsyncIterable<AgentLikeChunk>;
|
|
331
|
-
}
|
|
332
|
-
/**
|
|
333
|
-
* Render an `agent.stream()` source as a Vercel-compatible UI message stream.
|
|
334
|
-
*
|
|
335
|
-
* The returned `ReadableStream<Uint8Array>` can be wrapped in a `Response`
|
|
336
|
-
* (web / edge / fetch) or piped to a Node `ServerResponse`.
|
|
337
|
-
*/
|
|
338
|
-
declare function agentUIStream(agent: Agent | AgentLike, input: string, options?: AgentUIStreamOptions): ReadableStream<Uint8Array>;
|
|
339
|
-
/**
|
|
340
|
-
* Create a `Response` whose body streams Vercel UI messages. Use as the return
|
|
341
|
-
* value of a Web / Edge / Next.js Route Handler.
|
|
342
|
-
*
|
|
343
|
-
* @example
|
|
344
|
-
* ```ts
|
|
345
|
-
* import { createAgentUIStreamResponse } from "@agentium/transport";
|
|
346
|
-
*
|
|
347
|
-
* export async function POST(req: Request) {
|
|
348
|
-
* const { input, sessionId } = await req.json();
|
|
349
|
-
* return createAgentUIStreamResponse(agent, input, { sessionId });
|
|
350
|
-
* }
|
|
351
|
-
* ```
|
|
352
|
-
*/
|
|
353
|
-
declare function createAgentUIStreamResponse(agent: Agent | AgentLike, input: string, options?: AgentUIStreamOptions): Response;
|
|
354
|
-
/**
|
|
355
|
-
* Pipe a Vercel UI message stream into a Node `ServerResponse` (Express style).
|
|
356
|
-
*/
|
|
357
|
-
declare function pipeAgentUIStreamToResponse(agent: Agent | AgentLike, input: string, res: any, options?: AgentUIStreamOptions): Promise<void>;
|
|
358
|
-
|
|
359
|
-
/**
|
|
360
|
-
* Minimal interface for a BrowserAgent — avoids a hard dependency on @agentium/browser.
|
|
361
|
-
* Any object that matches this shape (e.g. a real BrowserAgent) works.
|
|
362
|
-
*/
|
|
363
|
-
interface BrowserAgentLike {
|
|
364
|
-
name: string;
|
|
365
|
-
eventBus: EventBus;
|
|
366
|
-
run(task: string, opts?: {
|
|
367
|
-
startUrl?: string;
|
|
368
|
-
apiKey?: string;
|
|
369
|
-
sessionId?: string;
|
|
370
|
-
}): Promise<{
|
|
371
|
-
result: string;
|
|
372
|
-
success: boolean;
|
|
373
|
-
finalUrl: string;
|
|
374
|
-
durationMs: number;
|
|
375
|
-
videoPath?: string;
|
|
376
|
-
steps: Array<{
|
|
377
|
-
index: number;
|
|
378
|
-
action: unknown;
|
|
379
|
-
screenshot: Buffer;
|
|
380
|
-
pageUrl: string;
|
|
381
|
-
pageTitle: string;
|
|
382
|
-
dom?: string;
|
|
383
|
-
}>;
|
|
384
|
-
}>;
|
|
385
|
-
}
|
|
386
|
-
interface BrowserGatewayOptions {
|
|
387
|
-
/** Named BrowserAgent instances. Clients select one via agentName. */
|
|
388
|
-
agents: Record<string, BrowserAgentLike>;
|
|
389
|
-
/** Socket.IO server instance */
|
|
390
|
-
io: any;
|
|
391
|
-
/** Socket.IO namespace. Default: "/agentium-browser" */
|
|
392
|
-
namespace?: string;
|
|
393
|
-
/** Optional auth middleware applied to the namespace */
|
|
394
|
-
authMiddleware?: (socket: any, next: (err?: Error) => void) => void;
|
|
395
|
-
/**
|
|
396
|
-
* Stream screenshots to the client in real-time.
|
|
397
|
-
* Default: true. Disable for bandwidth-constrained clients.
|
|
398
|
-
*/
|
|
399
|
-
streamScreenshots?: boolean;
|
|
400
|
-
}
|
|
401
|
-
/**
|
|
402
|
-
* Create a Socket.IO gateway that streams BrowserAgent execution in real-time.
|
|
403
|
-
*
|
|
404
|
-
* ## Client → Server events
|
|
405
|
-
* - `browser.start` — kick off a browser task
|
|
406
|
-
* - `browser.stop` — cancel a running task
|
|
407
|
-
*
|
|
408
|
-
* ## Server → Client events
|
|
409
|
-
* - `browser.started` — task accepted
|
|
410
|
-
* - `browser.screenshot` — live screenshot (base64 PNG)
|
|
411
|
-
* - `browser.action` — action about to execute
|
|
412
|
-
* - `browser.step` — full step with screenshot + DOM
|
|
413
|
-
* - `browser.done` — task finished (result, success, duration, video)
|
|
414
|
-
* - `browser.error` — error occurred
|
|
415
|
-
* - `browser.stopped` — task was cancelled
|
|
416
|
-
*/
|
|
417
|
-
declare function createBrowserGateway(opts: BrowserGatewayOptions): void;
|
|
418
|
-
|
|
419
|
-
interface GatewayOptions {
|
|
420
|
-
/**
|
|
421
|
-
* Use a Registry for live auto-discovery. The gateway resolves agents/teams
|
|
422
|
-
* at event time — any instance created after the gateway starts is automatically
|
|
423
|
-
* reachable.
|
|
424
|
-
*
|
|
425
|
-
* When omitted, falls back to the global registry from `@agentium/core`.
|
|
426
|
-
* Pass `false` to disable registry-based lookup (use explicit maps only).
|
|
427
|
-
*
|
|
428
|
-
* @example
|
|
429
|
-
* createAgentGateway({ io });
|
|
430
|
-
* new Agent({ name: "bot", model: openai("gpt-4o") }); // immediately reachable
|
|
431
|
-
*/
|
|
432
|
-
registry?: Registry | false;
|
|
433
|
-
/**
|
|
434
|
-
* Auto-discover agents and teams from a mixed array.
|
|
435
|
-
* Each item is classified by its `.kind` and keyed by `.name`.
|
|
436
|
-
*/
|
|
437
|
-
serve?: Servable[];
|
|
438
|
-
agents?: Record<string, Agent | ServableAgent>;
|
|
439
|
-
teams?: Record<string, Team>;
|
|
440
|
-
io: any;
|
|
441
|
-
namespace?: string;
|
|
442
|
-
authMiddleware?: (socket: any, next: (err?: Error) => void) => void;
|
|
443
|
-
/** Max requests per minute per socket. Default: 60 */
|
|
444
|
-
maxRequestsPerMinute?: number;
|
|
445
|
-
/** Named tool library exposed via tools.list event. */
|
|
446
|
-
toolLibrary?: Record<string, ToolDef>;
|
|
447
|
-
/** Toolkit instances whose tools are exposed via tools.list. Merged with toolLibrary. */
|
|
448
|
-
toolkits?: Toolkit[];
|
|
449
|
-
}
|
|
450
|
-
|
|
451
|
-
declare function createAgentGateway(opts: GatewayOptions): void;
|
|
452
|
-
|
|
453
|
-
interface VisionGatewayOptions {
|
|
454
|
-
agents: Record<string, VisionAgent>;
|
|
455
|
-
io: any;
|
|
456
|
-
namespace?: string;
|
|
457
|
-
authMiddleware?: (socket: any, next: (err?: Error) => void) => void;
|
|
458
|
-
}
|
|
459
|
-
declare function createVisionGateway(opts: VisionGatewayOptions): void;
|
|
460
|
-
|
|
461
|
-
interface VoiceGatewayOptions {
|
|
462
|
-
agents: Record<string, VoiceAgent>;
|
|
463
|
-
io: any;
|
|
464
|
-
namespace?: string;
|
|
465
|
-
authMiddleware?: (socket: any, next: (err?: Error) => void) => void;
|
|
466
|
-
}
|
|
467
|
-
declare function createVoiceGateway(opts: VoiceGatewayOptions): void;
|
|
468
|
-
|
|
469
|
-
/**
|
|
470
|
-
* Per-run in-memory ring buffer of SSE events. Each event gets a monotonically
|
|
471
|
-
* increasing numeric `id` so clients can pass `Last-Event-ID` on reconnect and
|
|
472
|
-
* replay missed events.
|
|
473
|
-
*
|
|
474
|
-
* Storage is intentionally in-process; for multi-instance deployments, plug a
|
|
475
|
-
* Redis-backed implementation behind the same interface.
|
|
476
|
-
*/
|
|
477
|
-
interface SSEEvent {
|
|
478
|
-
/** Monotonic numeric ID. */
|
|
479
|
-
id: number;
|
|
480
|
-
/** Optional `event:` line value. Default omitted. */
|
|
481
|
-
event?: string;
|
|
482
|
-
/** Payload (will be JSON-stringified into the `data:` field). */
|
|
483
|
-
payload: unknown;
|
|
484
|
-
/** Wall-clock time the event was recorded. */
|
|
485
|
-
recordedAt: number;
|
|
486
|
-
}
|
|
487
|
-
interface SSEEventLog {
|
|
488
|
-
/** Record a new event and return its assigned id. */
|
|
489
|
-
record(runId: string, event: Omit<SSEEvent, "id" | "recordedAt">): SSEEvent;
|
|
490
|
-
/** Return events for a run with id greater than `afterId`. */
|
|
491
|
-
since(runId: string, afterId: number): SSEEvent[];
|
|
492
|
-
/** All events for a run. */
|
|
493
|
-
all(runId: string): SSEEvent[];
|
|
494
|
-
/** Mark a run completed (frees buffers after `ttlMs`). */
|
|
495
|
-
finalize(runId: string): void;
|
|
496
|
-
/** Remove a run's buffer immediately. */
|
|
497
|
-
drop(runId: string): void;
|
|
498
|
-
}
|
|
499
|
-
interface InMemoryEventLogConfig {
|
|
500
|
-
/** Max events kept per run. Oldest evicted when exceeded. Default: 1024. */
|
|
501
|
-
maxEventsPerRun?: number;
|
|
502
|
-
/** Milliseconds after finalize before a run's buffer is dropped. Default: 300_000 (5min). */
|
|
503
|
-
ttlMs?: number;
|
|
504
|
-
}
|
|
505
|
-
declare class InMemoryEventLog implements SSEEventLog {
|
|
506
|
-
private buffers;
|
|
507
|
-
private nextIds;
|
|
508
|
-
private finalizeTimers;
|
|
509
|
-
private maxEvents;
|
|
510
|
-
private ttlMs;
|
|
511
|
-
constructor(config?: InMemoryEventLogConfig);
|
|
512
|
-
record(runId: string, event: Omit<SSEEvent, "id" | "recordedAt">): SSEEvent;
|
|
513
|
-
since(runId: string, afterId: number): SSEEvent[];
|
|
514
|
-
all(runId: string): SSEEvent[];
|
|
515
|
-
finalize(runId: string): void;
|
|
516
|
-
drop(runId: string): void;
|
|
517
|
-
}
|
|
518
|
-
/** Format an `SSEEvent` for the wire. */
|
|
519
|
-
declare function formatSSEEvent(ev: SSEEvent): string;
|
|
520
|
-
/** Process-wide default log so multiple endpoints can share one buffer. */
|
|
521
|
-
declare const defaultEventLog: InMemoryEventLog;
|
|
522
|
-
|
|
523
|
-
export { type A2AServerOptions, type AdminRouterOptions, type AgentUIStreamOptions, type BrowserGatewayOptions, type FileUploadOptions, type GatewayConfig, type GatewayOptions, InMemoryEventLog, type InMemoryEventLogConfig, type JwtConfig, MCPManager, type MCPServerEntry, type MCPServerSummary, type RbacConfig, type RemoteEndpoint, type RouterOptions, type SSEEvent, type SSEEventLog, type SwaggerOptions, type VisionGatewayOptions, type VoiceGatewayOptions, agentUIStream, buildMultiModalInput, createA2AServer, createAdminRouter, createAgentGateway, createAgentRouter, createAgentUIStreamResponse, createBrowserGateway, createFileUploadMiddleware, createGatewayRouter, createJwtMiddleware, createRbacMiddleware, createVisionGateway, createVoiceGateway, defaultEventLog, errorHandler, formatSSEEvent, generateAgentCard, generateMultiAgentCard, generateOpenAPISpec, pipeAgentUIStreamToResponse, requestLogger };
|