@lushly-dev/afd-client 1.0.0 → 2.1.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/README.md +217 -34
- package/dist/backoff.d.ts +20 -0
- package/dist/backoff.d.ts.map +1 -0
- package/dist/backoff.js +42 -0
- package/dist/backoff.js.map +1 -0
- package/dist/client-errors.d.ts +39 -0
- package/dist/client-errors.d.ts.map +1 -0
- package/dist/client-errors.js +163 -0
- package/dist/client-errors.js.map +1 -0
- package/dist/client-events.d.ts +23 -0
- package/dist/client-events.d.ts.map +1 -0
- package/dist/client-events.js +47 -0
- package/dist/client-events.js.map +1 -0
- package/dist/client.d.ts +89 -31
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +364 -452
- package/dist/client.js.map +1 -1
- package/dist/direct-timeout.d.ts +22 -0
- package/dist/direct-timeout.d.ts.map +1 -0
- package/dist/direct-timeout.js +54 -0
- package/dist/direct-timeout.js.map +1 -0
- package/dist/direct-transport.d.ts +72 -0
- package/dist/direct-transport.d.ts.map +1 -0
- package/dist/direct-transport.js +231 -0
- package/dist/direct-transport.js.map +1 -0
- package/dist/direct-types.d.ts +108 -0
- package/dist/direct-types.d.ts.map +1 -0
- package/dist/direct-types.js +5 -0
- package/dist/direct-types.js.map +1 -0
- package/dist/direct-validation.d.ts +1 -1
- package/dist/direct-validation.d.ts.map +1 -1
- package/dist/direct-validation.js +4 -1
- package/dist/direct-validation.js.map +1 -1
- package/dist/direct.d.ts +62 -192
- package/dist/direct.d.ts.map +1 -1
- package/dist/direct.js +116 -450
- package/dist/direct.js.map +1 -1
- package/dist/handlers.d.ts.map +1 -1
- package/dist/handlers.js +24 -21
- package/dist/handlers.js.map +1 -1
- package/dist/handoff.d.ts +19 -6
- package/dist/handoff.d.ts.map +1 -1
- package/dist/handoff.js +112 -88
- package/dist/handoff.js.map +1 -1
- package/dist/index.d.ts +12 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -5
- package/dist/index.js.map +1 -1
- package/dist/mcp-session.d.ts +37 -0
- package/dist/mcp-session.d.ts.map +1 -0
- package/dist/mcp-session.js +159 -0
- package/dist/mcp-session.js.map +1 -0
- package/dist/mcp-stream.d.ts +59 -0
- package/dist/mcp-stream.d.ts.map +1 -0
- package/dist/mcp-stream.js +215 -0
- package/dist/mcp-stream.js.map +1 -0
- package/dist/request-abort.d.ts +3 -0
- package/dist/request-abort.d.ts.map +1 -0
- package/dist/request-abort.js +18 -0
- package/dist/request-abort.js.map +1 -0
- package/dist/result-parsing.d.ts +27 -0
- package/dist/result-parsing.d.ts.map +1 -0
- package/dist/result-parsing.js +107 -0
- package/dist/result-parsing.js.map +1 -0
- package/dist/sse-parser.d.ts +70 -0
- package/dist/sse-parser.d.ts.map +1 -0
- package/dist/sse-parser.js +159 -0
- package/dist/sse-parser.js.map +1 -0
- package/dist/transport.d.ts +53 -6
- package/dist/transport.d.ts.map +1 -1
- package/dist/transport.js +193 -40
- package/dist/transport.js.map +1 -1
- package/dist/types.d.ts +40 -10
- package/dist/types.d.ts.map +1 -1
- package/dist/unknown-tool.d.ts +28 -8
- package/dist/unknown-tool.d.ts.map +1 -1
- package/dist/unknown-tool.js +51 -52
- package/dist/unknown-tool.js.map +1 -1
- package/package.json +7 -7
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Typed event subscription for `McpClient`.
|
|
3
|
+
*/
|
|
4
|
+
import type { McpClientEvents } from './types.js';
|
|
5
|
+
/**
|
|
6
|
+
* Event emitter base of `McpClient`. Handlers run in subscription order; one that throws is
|
|
7
|
+
* logged and does not stop the others.
|
|
8
|
+
*/
|
|
9
|
+
export declare class McpClientEventEmitter {
|
|
10
|
+
private readonly eventHandlers;
|
|
11
|
+
/**
|
|
12
|
+
* Subscribe to an event.
|
|
13
|
+
*
|
|
14
|
+
* @returns A function that unsubscribes the handler
|
|
15
|
+
*/
|
|
16
|
+
on<K extends keyof McpClientEvents>(event: K, handler: McpClientEvents[K]): () => void;
|
|
17
|
+
/**
|
|
18
|
+
* Emit an event to a snapshot of the handlers, so a handler that subscribes or unsubscribes
|
|
19
|
+
* while the event is delivered does not make others run twice or be skipped.
|
|
20
|
+
*/
|
|
21
|
+
protected emit<K extends keyof McpClientEvents>(event: K, ...args: Parameters<McpClientEvents[K]>): void;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=client-events.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client-events.d.ts","sourceRoot":"","sources":["../src/client-events.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAIlD;;;GAGG;AACH,qBAAa,qBAAqB;IACjC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAQ5B;IAEF;;;;OAIG;IACH,EAAE,CAAC,CAAC,SAAS,MAAM,eAAe,EAAE,KAAK,EAAE,CAAC,EAAE,OAAO,EAAE,eAAe,CAAC,CAAC,CAAC,GAAG,MAAM,IAAI;IAWtF;;;OAGG;IACH,SAAS,CAAC,IAAI,CAAC,CAAC,SAAS,MAAM,eAAe,EAC7C,KAAK,EAAE,CAAC,EACR,GAAG,IAAI,EAAE,UAAU,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,GACrC,IAAI;CASP"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Typed event subscription for `McpClient`.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Event emitter base of `McpClient`. Handlers run in subscription order; one that throws is
|
|
6
|
+
* logged and does not stop the others.
|
|
7
|
+
*/
|
|
8
|
+
export class McpClientEventEmitter {
|
|
9
|
+
eventHandlers = {
|
|
10
|
+
stateChange: [],
|
|
11
|
+
connected: [],
|
|
12
|
+
disconnected: [],
|
|
13
|
+
reconnecting: [],
|
|
14
|
+
error: [],
|
|
15
|
+
message: [],
|
|
16
|
+
toolsChanged: [],
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Subscribe to an event.
|
|
20
|
+
*
|
|
21
|
+
* @returns A function that unsubscribes the handler
|
|
22
|
+
*/
|
|
23
|
+
on(event, handler) {
|
|
24
|
+
this.eventHandlers[event].push(handler);
|
|
25
|
+
return () => {
|
|
26
|
+
const index = this.eventHandlers[event].indexOf(handler);
|
|
27
|
+
if (index > -1) {
|
|
28
|
+
this.eventHandlers[event].splice(index, 1);
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Emit an event to a snapshot of the handlers, so a handler that subscribes or unsubscribes
|
|
34
|
+
* while the event is delivered does not make others run twice or be skipped.
|
|
35
|
+
*/
|
|
36
|
+
emit(event, ...args) {
|
|
37
|
+
for (const handler of [...this.eventHandlers[event]]) {
|
|
38
|
+
try {
|
|
39
|
+
handler(...args);
|
|
40
|
+
}
|
|
41
|
+
catch (error) {
|
|
42
|
+
console.error(`Error in event handler for '${event}':`, error);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=client-events.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client-events.js","sourceRoot":"","sources":["../src/client-events.ts"],"names":[],"mappings":"AAAA;;GAEG;AAMH;;;GAGG;AACH,MAAM,OAAO,qBAAqB;IAChB,aAAa,GAAa;QAC1C,WAAW,EAAE,EAAE;QACf,SAAS,EAAE,EAAE;QACb,YAAY,EAAE,EAAE;QAChB,YAAY,EAAE,EAAE;QAChB,KAAK,EAAE,EAAE;QACT,OAAO,EAAE,EAAE;QACX,YAAY,EAAE,EAAE;KAChB,CAAC;IAEF;;;;OAIG;IACH,EAAE,CAAkC,KAAQ,EAAE,OAA2B;QACxE,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAExC,OAAO,GAAG,EAAE;YACX,MAAM,KAAK,GAAG,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;YACzD,IAAI,KAAK,GAAG,CAAC,CAAC,EAAE,CAAC;gBAChB,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;YAC5C,CAAC;QACF,CAAC,CAAC;IACH,CAAC;IAED;;;OAGG;IACO,IAAI,CACb,KAAQ,EACR,GAAG,IAAoC;QAEvC,KAAK,MAAM,OAAO,IAAI,CAAC,GAAG,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC;YACtD,IAAI,CAAC;gBACH,OAA6D,CAAC,GAAG,IAAI,CAAC,CAAC;YACzE,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBAChB,OAAO,CAAC,KAAK,CAAC,+BAA+B,KAAK,IAAI,EAAE,KAAK,CAAC,CAAC;YAChE,CAAC;QACF,CAAC;IACF,CAAC;CACD"}
|
package/dist/client.d.ts
CHANGED
|
@@ -2,13 +2,27 @@
|
|
|
2
2
|
* @fileoverview MCP Client implementation
|
|
3
3
|
*/
|
|
4
4
|
import type { BatchCommand, BatchOptions, BatchResult, CommandResult, McpInitializeResult, McpTool, McpToolCallResult, PipelineOptions, PipelineRequest, PipelineResult, PipelineStep, StreamCallbacks, StreamChunk, StreamOptions } from '@lushly-dev/afd-core';
|
|
5
|
-
import
|
|
5
|
+
import { McpClientEventEmitter } from './client-events.js';
|
|
6
|
+
import type { ClientStatus, McpClientConfig } from './types.js';
|
|
7
|
+
/** Options for a single `request()` or `callTool()`. */
|
|
8
|
+
export interface RequestOptions {
|
|
9
|
+
/** Request timeout in milliseconds. Default: the client's `timeout`. */
|
|
10
|
+
timeout?: number;
|
|
11
|
+
/** Cancel this request and signal in-process execution to stop. */
|
|
12
|
+
signal?: AbortSignal;
|
|
13
|
+
}
|
|
6
14
|
/**
|
|
7
|
-
*
|
|
15
|
+
* Extra time `batch()` and `pipe()` wait beyond the server-side deadline in their options, so
|
|
16
|
+
* the server's own timeout result can arrive before the client gives up.
|
|
8
17
|
*/
|
|
9
|
-
|
|
18
|
+
export declare const SERVER_DEADLINE_MARGIN_MS = 5000;
|
|
10
19
|
/**
|
|
11
|
-
* MCP Client for
|
|
20
|
+
* MCP Client for AFD servers (`createMcpServer()` from `@lushly-dev/afd-server`) and in-process
|
|
21
|
+
* registries.
|
|
22
|
+
*
|
|
23
|
+
* It speaks the AFD server's HTTP transport (`/sse` + `POST /message`, `POST /stream/<command>`).
|
|
24
|
+
* It does not implement the MCP Streamable HTTP transport or read the legacy SSE `endpoint`
|
|
25
|
+
* event, so it cannot talk to servers built on the official MCP SDK.
|
|
12
26
|
*
|
|
13
27
|
* @example
|
|
14
28
|
* ```typescript
|
|
@@ -20,13 +34,14 @@ type EventHandler<T extends (...args: never[]) => void> = T;
|
|
|
20
34
|
* const tools = await client.listTools();
|
|
21
35
|
*
|
|
22
36
|
* // Call a tool
|
|
23
|
-
* const result = await client.call('document
|
|
37
|
+
* const result = await client.call('document-create', { title: 'Test' });
|
|
24
38
|
*
|
|
25
39
|
* await client.disconnect();
|
|
26
40
|
* ```
|
|
27
41
|
*/
|
|
28
|
-
export declare class McpClient {
|
|
42
|
+
export declare class McpClient extends McpClientEventEmitter {
|
|
29
43
|
private readonly config;
|
|
44
|
+
private readonly registry;
|
|
30
45
|
private transport;
|
|
31
46
|
private state;
|
|
32
47
|
private serverInfo;
|
|
@@ -35,14 +50,23 @@ export declare class McpClient {
|
|
|
35
50
|
private connectedAt;
|
|
36
51
|
private reconnectAttempts;
|
|
37
52
|
private pendingRequests;
|
|
38
|
-
private
|
|
53
|
+
private activeStreams;
|
|
54
|
+
private intentionalDisconnect;
|
|
55
|
+
private connectionGeneration;
|
|
56
|
+
private connectionController;
|
|
57
|
+
private readonly reconnectWait;
|
|
58
|
+
private reconnectPromise;
|
|
59
|
+
private reconnectGeneration;
|
|
39
60
|
constructor(config: McpClientConfig);
|
|
40
61
|
/**
|
|
41
|
-
* Connect to the MCP server.
|
|
62
|
+
* Connect to the MCP server. Resolves, and `connected` is emitted, once the server is
|
|
63
|
+
* initialized and the tools list has been fetched (a failed tools refresh leaves the list
|
|
64
|
+
* empty but does not fail the connection).
|
|
42
65
|
*/
|
|
43
66
|
connect(): Promise<McpInitializeResult>;
|
|
44
67
|
/**
|
|
45
|
-
* Disconnect from the MCP server.
|
|
68
|
+
* Disconnect from the MCP server. Pending requests reject and active streams end with a
|
|
69
|
+
* `STREAM_CANCELLED` error chunk.
|
|
46
70
|
*/
|
|
47
71
|
disconnect(): Promise<void>;
|
|
48
72
|
/**
|
|
@@ -70,18 +94,21 @@ export declare class McpClient {
|
|
|
70
94
|
*
|
|
71
95
|
* @param name - Tool name
|
|
72
96
|
* @param args - Tool arguments
|
|
97
|
+
* @param options - Request options such as `timeout`
|
|
73
98
|
*/
|
|
74
|
-
callTool(name: string, args?: Record<string, unknown
|
|
99
|
+
callTool(name: string, args?: Record<string, unknown>, options?: RequestOptions): Promise<McpToolCallResult>;
|
|
75
100
|
/**
|
|
76
101
|
* Call a command and return a CommandResult.
|
|
77
102
|
*
|
|
78
103
|
* This is the preferred method for AFD - it wraps the MCP response
|
|
79
|
-
* in a standardized CommandResult.
|
|
104
|
+
* in a standardized CommandResult. It never rejects: a JSON-RPC error becomes a failure with
|
|
105
|
+
* a matching AFD code (`INVALID_INPUT` for -32602, `SESSION_NOT_FOUND` for -32001, ...), a
|
|
106
|
+
* timeout becomes `TIMEOUT`, and a connection problem `CONNECTION_ERROR` or `NOT_CONNECTED`.
|
|
80
107
|
*
|
|
81
108
|
* @param name - Command/tool name
|
|
82
109
|
* @param args - Command arguments
|
|
83
110
|
*/
|
|
84
|
-
call<T = unknown>(name: string, args?: Record<string, unknown
|
|
111
|
+
call<T = unknown>(name: string, args?: Record<string, unknown>, options?: RequestOptions): Promise<CommandResult<T>>;
|
|
85
112
|
/**
|
|
86
113
|
* Execute multiple commands in a single batch request.
|
|
87
114
|
*
|
|
@@ -89,6 +116,12 @@ export declare class McpClient {
|
|
|
89
116
|
* succeeds if at least one command succeeds, with aggregated
|
|
90
117
|
* confidence scores and detailed timing information.
|
|
91
118
|
*
|
|
119
|
+
* The request waits for `options.timeout` (the server-side batch deadline) plus
|
|
120
|
+
* {@link SERVER_DEADLINE_MARGIN_MS}, and never less than the client's `timeout`. If no result
|
|
121
|
+
* arrives (timeout or connection failure), the server may already have run some commands, so
|
|
122
|
+
* the result is an `OUTCOME_UNKNOWN` failure with `retryable: false`, no per-command results
|
|
123
|
+
* and zero success and failure counts.
|
|
124
|
+
*
|
|
92
125
|
* @param commands - Array of commands to execute
|
|
93
126
|
* @param options - Batch execution options
|
|
94
127
|
* @returns BatchResult with individual command results
|
|
@@ -96,9 +129,9 @@ export declare class McpClient {
|
|
|
96
129
|
* @example
|
|
97
130
|
* ```typescript
|
|
98
131
|
* const result = await client.batch([
|
|
99
|
-
* {
|
|
100
|
-
* {
|
|
101
|
-
* {
|
|
132
|
+
* { command: 'todo-create', input: { title: 'First' } },
|
|
133
|
+
* { command: 'todo-create', input: { title: 'Second' } },
|
|
134
|
+
* { command: 'todo-list', input: {} }
|
|
102
135
|
* ], { stopOnError: false });
|
|
103
136
|
*
|
|
104
137
|
* console.log(`${result.summary.successCount}/${result.summary.total} succeeded`);
|
|
@@ -112,8 +145,14 @@ export declare class McpClient {
|
|
|
112
145
|
* Pipelines enable declarative composition of commands where the output
|
|
113
146
|
* of one becomes the input of the next via variable resolution.
|
|
114
147
|
*
|
|
148
|
+
* The request waits for `timeoutMs` (the server-side pipeline deadline) plus
|
|
149
|
+
* {@link SERVER_DEADLINE_MARGIN_MS}, and never less than the client's `timeout`. If no result
|
|
150
|
+
* arrives (timeout or connection failure), earlier steps may already have run, so the result
|
|
151
|
+
* carries an `OUTCOME_UNKNOWN` error (`retryable: false`) on a single pipeline-level entry
|
|
152
|
+
* (`index: -1`) instead of a status for each step.
|
|
153
|
+
*
|
|
115
154
|
* @param stepsOrRequest - Array of pipeline steps or full PipelineRequest
|
|
116
|
-
* @param options - Optional pipeline options
|
|
155
|
+
* @param options - Optional pipeline options (used with an array of steps)
|
|
117
156
|
* @returns Pipeline result with aggregated metadata
|
|
118
157
|
*
|
|
119
158
|
* @example
|
|
@@ -139,6 +178,19 @@ export declare class McpClient {
|
|
|
139
178
|
* containing progress updates, incremental data, completion,
|
|
140
179
|
* or error information.
|
|
141
180
|
*
|
|
181
|
+
* The last chunk is always a `complete` or `error` chunk. The client makes the error chunk
|
|
182
|
+
* itself when the stream ends early (`STREAM_TRUNCATED`), `options.timeout` passes
|
|
183
|
+
* (`STREAM_TIMEOUT`), the caller's signal or `disconnect()` stops it (`STREAM_CANCELLED`),
|
|
184
|
+
* one event exceeds `maxStreamEventSize` (`STREAM_EVENT_TOO_LARGE`), or the client is not
|
|
185
|
+
* connected (`NOT_CONNECTED`).
|
|
186
|
+
*
|
|
187
|
+
* Over HTTP it posts to `<base>/stream/<command>`, where `<base>` is the client URL without
|
|
188
|
+
* a trailing `/sse`, `/message` or `/messages`, in the client's MCP session: the request
|
|
189
|
+
* carries the `Mcp-Session-Id` from `initialize`, so the stream sees the session's active
|
|
190
|
+
* context (`afd-context-enter`). If the server has expired that session (404), the client
|
|
191
|
+
* starts a new one and retries once, as it does for other requests. With
|
|
192
|
+
* `transport: 'direct'` it runs the command in process through core's `executeStream()`.
|
|
193
|
+
*
|
|
142
194
|
* @param name - Command name to execute
|
|
143
195
|
* @param args - Command arguments
|
|
144
196
|
* @param options - Stream options (abort signal, timeout)
|
|
@@ -146,7 +198,7 @@ export declare class McpClient {
|
|
|
146
198
|
*
|
|
147
199
|
* @example
|
|
148
200
|
* ```typescript
|
|
149
|
-
* for await (const chunk of client.stream('llm
|
|
201
|
+
* for await (const chunk of client.stream('llm-generate', { prompt: 'Hello' })) {
|
|
150
202
|
* if (chunk.type === 'progress') {
|
|
151
203
|
* console.log(`Progress: ${(chunk.progress * 100).toFixed(0)}%`);
|
|
152
204
|
* } else if (chunk.type === 'data') {
|
|
@@ -174,7 +226,7 @@ export declare class McpClient {
|
|
|
174
226
|
*
|
|
175
227
|
* @example
|
|
176
228
|
* ```typescript
|
|
177
|
-
* await client.streamWithCallbacks('llm
|
|
229
|
+
* await client.streamWithCallbacks('llm-generate', { prompt: 'Hello' }, {
|
|
178
230
|
* onProgress: (chunk) => console.log(`${(chunk.progress * 100).toFixed(0)}% - ${chunk.message}`),
|
|
179
231
|
* onData: (chunk) => process.stdout.write(String(chunk.data)),
|
|
180
232
|
* onComplete: (chunk) => console.log('Done!', chunk.data),
|
|
@@ -183,25 +235,32 @@ export declare class McpClient {
|
|
|
183
235
|
* ```
|
|
184
236
|
*/
|
|
185
237
|
streamWithCallbacks<T = unknown>(name: string, args: Record<string, unknown> | undefined, callbacks: StreamCallbacks<T>, options?: StreamOptions): Promise<void>;
|
|
186
|
-
/**
|
|
187
|
-
* Combine two AbortSignals into one.
|
|
188
|
-
*/
|
|
189
|
-
private combineSignals;
|
|
190
238
|
/**
|
|
191
239
|
* Send a raw MCP request and wait for response.
|
|
240
|
+
*
|
|
241
|
+
* @throws NotConnectedError when not connected; RequestTimeoutError when no response arrives
|
|
242
|
+
* in time; JsonRpcResponseError when the server answers with a JSON-RPC error;
|
|
243
|
+
* HttpStatusError for another non-2xx HTTP status
|
|
192
244
|
*/
|
|
193
|
-
request<T = unknown>(method: string, params?: Record<string, unknown
|
|
194
|
-
/**
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
245
|
+
request<T = unknown>(method: string, params?: Record<string, unknown>, options?: RequestOptions): Promise<T>;
|
|
246
|
+
/** A request timeout that outlasts a server-side deadline by the margin. */
|
|
247
|
+
private timeoutWithMargin;
|
|
248
|
+
private initialize;
|
|
249
|
+
private createConnectionTransport;
|
|
250
|
+
private assertCurrent;
|
|
198
251
|
/**
|
|
199
|
-
*
|
|
252
|
+
* Connect, initialize and refresh tools. An initial connection reports its failure through
|
|
253
|
+
* the `error` event and the rejection; reconnection attempts report nothing themselves, and
|
|
254
|
+
* the reconnect loop emits one `error` when it gives up.
|
|
200
255
|
*/
|
|
201
|
-
private
|
|
202
|
-
private
|
|
256
|
+
private establishConnection;
|
|
257
|
+
private runReconnectLoop;
|
|
203
258
|
private setState;
|
|
204
259
|
private handleMessage;
|
|
260
|
+
/**
|
|
261
|
+
* Forward transport errors of the current, established connection. While connecting or
|
|
262
|
+
* reconnecting, failures are reported by `connect()` and the reconnect loop instead.
|
|
263
|
+
*/
|
|
205
264
|
private handleError;
|
|
206
265
|
private handleClose;
|
|
207
266
|
private attemptReconnect;
|
|
@@ -214,5 +273,4 @@ export declare class McpClient {
|
|
|
214
273
|
* @returns New McpClient instance
|
|
215
274
|
*/
|
|
216
275
|
export declare function createClient(config: McpClientConfig): McpClient;
|
|
217
|
-
export {};
|
|
218
276
|
//# sourceMappingURL=client.d.ts.map
|
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AACA;;GAEG;AAEH,OAAO,KAAK,EACX,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,aAAa,EACb,mBAAmB,EAEnB,OAAO,EACP,iBAAiB,EAEjB,eAAe,EACf,eAAe,EACf,cAAc,EACd,YAAY,EACZ,eAAe,EACf,WAAW,EACX,aAAa,EACb,MAAM,sBAAsB,CAAC;AAkB9B,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAwB3D,OAAO,KAAK,EACX,YAAY,EAEZ,eAAe,EAGf,MAAM,YAAY,CAAC;AAUpB,wDAAwD;AACxD,MAAM,WAAW,cAAc;IAC9B,wEAAwE;IACxE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,mEAAmE;IACnE,MAAM,CAAC,EAAE,W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