@wmxia/mcp-bridge 0.0.0-stage → 0.1.1
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 +110 -2
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +99 -0
- package/dist/cli.js.map +1 -0
- package/dist/mcpServer.d.ts +8 -0
- package/dist/mcpServer.js +147 -0
- package/dist/mcpServer.js.map +1 -0
- package/dist/protocol.d.ts +181 -0
- package/dist/protocol.js +56 -0
- package/dist/protocol.js.map +1 -0
- package/dist/wsHub.d.ts +86 -0
- package/dist/wsHub.js +861 -0
- package/dist/wsHub.js.map +1 -0
- package/package.json +54 -4
package/dist/wsHub.d.ts
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { EventEmitter } from 'node:events';
|
|
2
|
+
import { type ExtensionCapabilities } from './protocol.js';
|
|
3
|
+
export interface ToolCallResponse {
|
|
4
|
+
isError?: boolean;
|
|
5
|
+
errorCode?: string;
|
|
6
|
+
content: unknown;
|
|
7
|
+
meta?: {
|
|
8
|
+
shopDomain?: string | null;
|
|
9
|
+
demoMode?: boolean;
|
|
10
|
+
entitlementNotice?: string;
|
|
11
|
+
truncated?: boolean;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
export interface ResourceReadResponse {
|
|
15
|
+
isError?: boolean;
|
|
16
|
+
errorCode?: string;
|
|
17
|
+
mimeType?: string;
|
|
18
|
+
text?: string;
|
|
19
|
+
errorMessage?: string;
|
|
20
|
+
}
|
|
21
|
+
export interface BridgeStatusSnapshot {
|
|
22
|
+
role: 'leader' | 'follower' | 'starting' | 'stopped';
|
|
23
|
+
host: string;
|
|
24
|
+
port: number;
|
|
25
|
+
extensionConnected: boolean;
|
|
26
|
+
capabilities: ExtensionCapabilities | null;
|
|
27
|
+
followerCount: number;
|
|
28
|
+
bridgeVersion: string;
|
|
29
|
+
}
|
|
30
|
+
export interface BridgeHubOptions {
|
|
31
|
+
token: string;
|
|
32
|
+
port?: number;
|
|
33
|
+
host?: string;
|
|
34
|
+
allowedOrigins?: string[];
|
|
35
|
+
callTimeoutMs?: number;
|
|
36
|
+
clientName?: string;
|
|
37
|
+
logger?: (msg: string) => void;
|
|
38
|
+
}
|
|
39
|
+
export declare class WmxBridgeHub extends EventEmitter {
|
|
40
|
+
private readonly tokenHash;
|
|
41
|
+
private readonly host;
|
|
42
|
+
private readonly port;
|
|
43
|
+
private readonly allowedOrigins;
|
|
44
|
+
private readonly callTimeoutMs;
|
|
45
|
+
private readonly clientName;
|
|
46
|
+
private readonly log;
|
|
47
|
+
private role;
|
|
48
|
+
private httpServer;
|
|
49
|
+
private extWss;
|
|
50
|
+
private agentWss;
|
|
51
|
+
private extSocket;
|
|
52
|
+
private extCapabilities;
|
|
53
|
+
private readonly followerSockets;
|
|
54
|
+
private leaderSocket;
|
|
55
|
+
private followerReconnectTimer;
|
|
56
|
+
private closed;
|
|
57
|
+
private readonly pendingCalls;
|
|
58
|
+
private readonly pendingReads;
|
|
59
|
+
constructor(options: BridgeHubOptions);
|
|
60
|
+
getStatus(): BridgeStatusSnapshot;
|
|
61
|
+
start(): Promise<void>;
|
|
62
|
+
close(): Promise<void>;
|
|
63
|
+
callTool(name: string, args?: Record<string, unknown>, options?: {
|
|
64
|
+
clientName?: string;
|
|
65
|
+
onProgress?: (progress: {
|
|
66
|
+
progress: number;
|
|
67
|
+
total?: number;
|
|
68
|
+
message?: string;
|
|
69
|
+
}) => void;
|
|
70
|
+
signal?: AbortSignal;
|
|
71
|
+
}): Promise<ToolCallResponse>;
|
|
72
|
+
readResource(uri: string, clientName?: string): Promise<ResourceReadResponse>;
|
|
73
|
+
private tryStartAsLeader;
|
|
74
|
+
private handleExtensionConnection;
|
|
75
|
+
private handleAuthenticatedExtensionMessage;
|
|
76
|
+
private handleFollowerConnection;
|
|
77
|
+
private broadcastExtensionState;
|
|
78
|
+
private connectAsFollower;
|
|
79
|
+
private scheduleFollowerFailover;
|
|
80
|
+
private dispatchToolToExtension;
|
|
81
|
+
private dispatchToolToLeader;
|
|
82
|
+
private dispatchResourceToExtension;
|
|
83
|
+
private dispatchResourceToLeader;
|
|
84
|
+
private rejectAllPending;
|
|
85
|
+
private sendJson;
|
|
86
|
+
}
|