@replit/river 0.12.6 → 0.13.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 +4 -1
- package/dist/{builder-c593de11.d.ts → builder-169fbf7f.d.ts} +16 -7
- package/dist/{chunk-AFLZ6INU.js → chunk-CBRQM65K.js} +29 -10
- package/dist/{chunk-IIBVKYDB.js → chunk-CDH7QSB4.js} +39 -1
- package/dist/{chunk-XFFS4UOD.js → chunk-MGGIUH5O.js} +7 -7
- package/dist/{chunk-VLBVQX5H.js → chunk-NPXAAD7M.js} +1 -1
- package/dist/{chunk-4SDJ5VN4.js → chunk-R2IMXRVU.js} +150 -116
- package/dist/{connection-ba37d174.d.ts → connection-ab681c08.d.ts} +1 -1
- package/dist/{messageFraming-b200ef25.d.ts → connection-dd789651.d.ts} +17 -2
- package/dist/{index-54e0f99c.d.ts → index-21c1b21d.d.ts} +29 -13
- package/dist/router/index.cjs +31 -13
- package/dist/router/index.d.cts +5 -5
- package/dist/router/index.d.ts +5 -5
- package/dist/router/index.js +2 -2
- package/dist/transport/impls/uds/client.cjs +143 -121
- package/dist/transport/impls/uds/client.d.cts +2 -3
- package/dist/transport/impls/uds/client.d.ts +2 -3
- package/dist/transport/impls/uds/client.js +5 -6
- package/dist/transport/impls/uds/server.cjs +151 -127
- package/dist/transport/impls/uds/server.d.cts +2 -3
- package/dist/transport/impls/uds/server.d.ts +2 -3
- package/dist/transport/impls/uds/server.js +4 -5
- package/dist/transport/impls/ws/client.cjs +147 -123
- package/dist/transport/impls/ws/client.d.cts +4 -4
- package/dist/transport/impls/ws/client.d.ts +4 -4
- package/dist/transport/impls/ws/client.js +7 -7
- package/dist/transport/impls/ws/server.cjs +151 -127
- package/dist/transport/impls/ws/server.d.cts +2 -2
- package/dist/transport/impls/ws/server.d.ts +2 -2
- package/dist/transport/impls/ws/server.js +4 -4
- package/dist/transport/index.cjs +202 -167
- package/dist/transport/index.d.cts +1 -1
- package/dist/transport/index.d.ts +1 -1
- package/dist/transport/index.js +3 -3
- package/dist/util/testHelpers.cjs +294 -16
- package/dist/util/testHelpers.d.cts +2 -2
- package/dist/util/testHelpers.d.ts +2 -2
- package/dist/util/testHelpers.js +30 -8
- package/package.json +1 -9
- package/dist/chunk-PBPXYLI6.js +0 -44
- package/dist/chunk-Q7GL34DZ.js +0 -47
- package/dist/connection-1f9971d8.d.ts +0 -17
- package/dist/connection-24d878ac.d.ts +0 -18
- package/dist/transport/impls/stdio/client.cjs +0 -904
- package/dist/transport/impls/stdio/client.d.cts +0 -27
- package/dist/transport/impls/stdio/client.d.ts +0 -27
- package/dist/transport/impls/stdio/client.js +0 -42
- package/dist/transport/impls/stdio/server.cjs +0 -879
- package/dist/transport/impls/stdio/server.d.cts +0 -25
- package/dist/transport/impls/stdio/server.d.ts +0 -25
- package/dist/transport/impls/stdio/server.js +0 -33
|
@@ -1,879 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// transport/impls/stdio/server.ts
|
|
21
|
-
var server_exports = {};
|
|
22
|
-
__export(server_exports, {
|
|
23
|
-
StdioServerTransport: () => StdioServerTransport
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(server_exports);
|
|
26
|
-
|
|
27
|
-
// transport/transport.ts
|
|
28
|
-
var import_value = require("@sinclair/typebox/value");
|
|
29
|
-
|
|
30
|
-
// transport/message.ts
|
|
31
|
-
var import_typebox = require("@sinclair/typebox");
|
|
32
|
-
var import_nanoid = require("nanoid");
|
|
33
|
-
var TransportMessageSchema = (t) => import_typebox.Type.Object({
|
|
34
|
-
id: import_typebox.Type.String(),
|
|
35
|
-
from: import_typebox.Type.String(),
|
|
36
|
-
to: import_typebox.Type.String(),
|
|
37
|
-
seq: import_typebox.Type.Integer(),
|
|
38
|
-
ack: import_typebox.Type.Integer(),
|
|
39
|
-
serviceName: import_typebox.Type.Optional(import_typebox.Type.Union([import_typebox.Type.String(), import_typebox.Type.Null()])),
|
|
40
|
-
procedureName: import_typebox.Type.Optional(import_typebox.Type.Union([import_typebox.Type.String(), import_typebox.Type.Null()])),
|
|
41
|
-
streamId: import_typebox.Type.String(),
|
|
42
|
-
controlFlags: import_typebox.Type.Integer(),
|
|
43
|
-
payload: t
|
|
44
|
-
});
|
|
45
|
-
var ControlMessageAckSchema = import_typebox.Type.Object({
|
|
46
|
-
type: import_typebox.Type.Literal("ACK")
|
|
47
|
-
});
|
|
48
|
-
var ControlMessageCloseSchema = import_typebox.Type.Object({
|
|
49
|
-
type: import_typebox.Type.Literal("CLOSE")
|
|
50
|
-
});
|
|
51
|
-
var PROTOCOL_VERSION = "v1";
|
|
52
|
-
var ControlMessageHandshakeRequestSchema = import_typebox.Type.Object({
|
|
53
|
-
type: import_typebox.Type.Literal("HANDSHAKE_REQ"),
|
|
54
|
-
protocolVersion: import_typebox.Type.Literal(PROTOCOL_VERSION),
|
|
55
|
-
instanceId: import_typebox.Type.String()
|
|
56
|
-
});
|
|
57
|
-
var ControlMessageHandshakeResponseSchema = import_typebox.Type.Object({
|
|
58
|
-
type: import_typebox.Type.Literal("HANDSHAKE_RESP"),
|
|
59
|
-
status: import_typebox.Type.Union([
|
|
60
|
-
import_typebox.Type.Object({
|
|
61
|
-
ok: import_typebox.Type.Literal(true),
|
|
62
|
-
instanceId: import_typebox.Type.String()
|
|
63
|
-
}),
|
|
64
|
-
import_typebox.Type.Object({
|
|
65
|
-
ok: import_typebox.Type.Literal(false),
|
|
66
|
-
reason: import_typebox.Type.Union([import_typebox.Type.Literal("VERSION_MISMATCH")])
|
|
67
|
-
})
|
|
68
|
-
])
|
|
69
|
-
});
|
|
70
|
-
var ControlMessagePayloadSchema = import_typebox.Type.Union([
|
|
71
|
-
ControlMessageCloseSchema,
|
|
72
|
-
ControlMessageAckSchema,
|
|
73
|
-
ControlMessageHandshakeRequestSchema,
|
|
74
|
-
ControlMessageHandshakeResponseSchema
|
|
75
|
-
]);
|
|
76
|
-
var OpaqueTransportMessageSchema = TransportMessageSchema(
|
|
77
|
-
import_typebox.Type.Unknown()
|
|
78
|
-
);
|
|
79
|
-
function bootResponseMessage(from, instanceId, to, ok) {
|
|
80
|
-
return {
|
|
81
|
-
id: (0, import_nanoid.nanoid)(),
|
|
82
|
-
from,
|
|
83
|
-
to,
|
|
84
|
-
seq: 0,
|
|
85
|
-
ack: 0,
|
|
86
|
-
streamId: (0, import_nanoid.nanoid)(),
|
|
87
|
-
controlFlags: 0,
|
|
88
|
-
payload: ok ? {
|
|
89
|
-
type: "HANDSHAKE_RESP",
|
|
90
|
-
status: {
|
|
91
|
-
ok: true,
|
|
92
|
-
instanceId
|
|
93
|
-
}
|
|
94
|
-
} : {
|
|
95
|
-
type: "HANDSHAKE_RESP",
|
|
96
|
-
status: {
|
|
97
|
-
ok: false,
|
|
98
|
-
reason: "VERSION_MISMATCH"
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
};
|
|
102
|
-
}
|
|
103
|
-
function isAck(controlFlag) {
|
|
104
|
-
return (controlFlag & 1 /* AckBit */) === 1 /* AckBit */;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
// logging/index.ts
|
|
108
|
-
var log;
|
|
109
|
-
|
|
110
|
-
// transport/events.ts
|
|
111
|
-
var EventDispatcher = class {
|
|
112
|
-
eventListeners = {};
|
|
113
|
-
numberOfListeners(eventType) {
|
|
114
|
-
return this.eventListeners[eventType]?.size ?? 0;
|
|
115
|
-
}
|
|
116
|
-
addEventListener(eventType, handler) {
|
|
117
|
-
if (!this.eventListeners[eventType]) {
|
|
118
|
-
this.eventListeners[eventType] = /* @__PURE__ */ new Set();
|
|
119
|
-
}
|
|
120
|
-
this.eventListeners[eventType]?.add(handler);
|
|
121
|
-
}
|
|
122
|
-
removeEventListener(eventType, handler) {
|
|
123
|
-
const handlers = this.eventListeners[eventType];
|
|
124
|
-
if (handlers) {
|
|
125
|
-
this.eventListeners[eventType]?.delete(handler);
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
dispatchEvent(eventType, event) {
|
|
129
|
-
const handlers = this.eventListeners[eventType];
|
|
130
|
-
if (handlers) {
|
|
131
|
-
for (const handler of handlers) {
|
|
132
|
-
handler(event);
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
};
|
|
137
|
-
|
|
138
|
-
// transport/session.ts
|
|
139
|
-
var import_nanoid2 = require("nanoid");
|
|
140
|
-
var nanoid2 = (0, import_nanoid2.customAlphabet)("1234567890abcdefghijklmnopqrstuvxyz", 6);
|
|
141
|
-
var unsafeId = () => nanoid2();
|
|
142
|
-
var Connection = class {
|
|
143
|
-
debugId;
|
|
144
|
-
constructor() {
|
|
145
|
-
this.debugId = `conn-${unsafeId()}`;
|
|
146
|
-
}
|
|
147
|
-
};
|
|
148
|
-
var HEARTBEAT_INTERVAL_MS = 1e3;
|
|
149
|
-
var HEARTBEATS_TILL_DEAD = 2;
|
|
150
|
-
var SESSION_DISCONNECT_GRACE_MS = 5e3;
|
|
151
|
-
var Session = class {
|
|
152
|
-
codec;
|
|
153
|
-
/**
|
|
154
|
-
* The buffer of messages that have been sent but not yet acknowledged.
|
|
155
|
-
*/
|
|
156
|
-
sendBuffer = [];
|
|
157
|
-
/**
|
|
158
|
-
* The active connection associated with this session
|
|
159
|
-
*/
|
|
160
|
-
connection;
|
|
161
|
-
from;
|
|
162
|
-
to;
|
|
163
|
-
/**
|
|
164
|
-
* The unique ID of this session.
|
|
165
|
-
*/
|
|
166
|
-
debugId;
|
|
167
|
-
/**
|
|
168
|
-
* Number of messages we've sent along this session (excluding handshake)
|
|
169
|
-
*/
|
|
170
|
-
seq = 0;
|
|
171
|
-
/**
|
|
172
|
-
* Number of unique messages we've received this session (excluding handshake)
|
|
173
|
-
*/
|
|
174
|
-
ack = 0;
|
|
175
|
-
/**
|
|
176
|
-
* The grace period between when the inner connection is disconnected
|
|
177
|
-
* and when we should consider the entire session disconnected.
|
|
178
|
-
*/
|
|
179
|
-
disconnectionGrace;
|
|
180
|
-
/**
|
|
181
|
-
* Number of heartbeats we've sent without a response.
|
|
182
|
-
*/
|
|
183
|
-
heartbeatMisses;
|
|
184
|
-
/**
|
|
185
|
-
* The interval for sending heartbeats.
|
|
186
|
-
*/
|
|
187
|
-
heartbeat;
|
|
188
|
-
constructor(codec, from, connectedTo, conn) {
|
|
189
|
-
this.debugId = `sess-${unsafeId()}`;
|
|
190
|
-
this.from = from;
|
|
191
|
-
this.to = connectedTo;
|
|
192
|
-
this.connection = conn;
|
|
193
|
-
this.codec = codec;
|
|
194
|
-
this.heartbeatMisses = 0;
|
|
195
|
-
this.heartbeat = setInterval(
|
|
196
|
-
() => this.sendHeartbeat(),
|
|
197
|
-
HEARTBEAT_INTERVAL_MS
|
|
198
|
-
);
|
|
199
|
-
}
|
|
200
|
-
/**
|
|
201
|
-
* Sends a message over the session's connection.
|
|
202
|
-
* If the connection is not ready or the message fails to send, the message can be buffered for retry unless skipped.
|
|
203
|
-
*
|
|
204
|
-
* @param msg The partial message to be sent, which will be constructed into a full message.
|
|
205
|
-
* @param skipRetry Optional. If true, the message will not be buffered for retry on failure. This should only be used for
|
|
206
|
-
* ack hearbeats, which contain information that can already be found in the other buffered messages.
|
|
207
|
-
* @returns The full transport ID of the message that was attempted to be sent.
|
|
208
|
-
*/
|
|
209
|
-
send(msg, skipRetry) {
|
|
210
|
-
const fullMsg = this.constructMsg(msg);
|
|
211
|
-
log?.debug(`${this.from} -- sending ${JSON.stringify(fullMsg)}`);
|
|
212
|
-
if (this.connection) {
|
|
213
|
-
const ok = this.connection.send(this.codec.toBuffer(fullMsg));
|
|
214
|
-
if (ok)
|
|
215
|
-
return fullMsg.id;
|
|
216
|
-
log?.info(
|
|
217
|
-
`${this.from} -- failed to send ${fullMsg.id} to ${fullMsg.to}, connection (id: ${this.connection.debugId}) is probably dead`
|
|
218
|
-
);
|
|
219
|
-
} else {
|
|
220
|
-
log?.info(
|
|
221
|
-
`${this.from} -- failed to send ${fullMsg.id} to ${fullMsg.to}, connection not ready yet`
|
|
222
|
-
);
|
|
223
|
-
}
|
|
224
|
-
if (skipRetry)
|
|
225
|
-
return fullMsg.id;
|
|
226
|
-
this.addToSendBuff(fullMsg);
|
|
227
|
-
log?.info(
|
|
228
|
-
`${this.from} -- buffering msg ${fullMsg.id} until connection is healthy again`
|
|
229
|
-
);
|
|
230
|
-
return fullMsg.id;
|
|
231
|
-
}
|
|
232
|
-
sendHeartbeat() {
|
|
233
|
-
if (this.heartbeatMisses >= HEARTBEATS_TILL_DEAD) {
|
|
234
|
-
if (this.connection) {
|
|
235
|
-
log?.info(
|
|
236
|
-
`${this.from} -- closing connection (id: ${this.connection.debugId}) to ${this.to} due to inactivity`
|
|
237
|
-
);
|
|
238
|
-
this.closeStaleConnection(this.connection);
|
|
239
|
-
}
|
|
240
|
-
return;
|
|
241
|
-
}
|
|
242
|
-
this.send(
|
|
243
|
-
{
|
|
244
|
-
streamId: "heartbeat",
|
|
245
|
-
controlFlags: 1 /* AckBit */,
|
|
246
|
-
payload: {
|
|
247
|
-
type: "ACK"
|
|
248
|
-
}
|
|
249
|
-
},
|
|
250
|
-
true
|
|
251
|
-
);
|
|
252
|
-
this.heartbeatMisses++;
|
|
253
|
-
}
|
|
254
|
-
resetBufferedMessages() {
|
|
255
|
-
this.sendBuffer = [];
|
|
256
|
-
this.seq = 0;
|
|
257
|
-
this.ack = 0;
|
|
258
|
-
}
|
|
259
|
-
sendBufferedMessages() {
|
|
260
|
-
if (!this.connection) {
|
|
261
|
-
const msg = `${this.from} -- tried sending buffered messages without a connection (if you hit this code path something is seriously wrong)`;
|
|
262
|
-
log?.error(msg);
|
|
263
|
-
throw new Error(msg);
|
|
264
|
-
}
|
|
265
|
-
for (const msg of this.sendBuffer) {
|
|
266
|
-
log?.debug(`${this.from} -- resending ${JSON.stringify(msg)}`);
|
|
267
|
-
const ok = this.connection.send(this.codec.toBuffer(msg));
|
|
268
|
-
if (!ok) {
|
|
269
|
-
const msg2 = `${this.from} -- failed to send buffered message to ${this.to} in session (id: ${this.debugId}) (if you hit this code path something is seriously wrong)`;
|
|
270
|
-
log?.error(msg2);
|
|
271
|
-
throw new Error(msg2);
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
updateBookkeeping(ack, seq) {
|
|
276
|
-
this.sendBuffer = this.sendBuffer.filter((unacked) => unacked.seq > ack);
|
|
277
|
-
this.ack = seq + 1;
|
|
278
|
-
}
|
|
279
|
-
addToSendBuff(msg) {
|
|
280
|
-
this.sendBuffer.push(msg);
|
|
281
|
-
log?.debug(
|
|
282
|
-
`${this.from} -- send buff to ${this.to} now tracking ${this.sendBuffer.length} messages`
|
|
283
|
-
);
|
|
284
|
-
}
|
|
285
|
-
closeStaleConnection(conn) {
|
|
286
|
-
if (!this.connection || this.connection !== conn)
|
|
287
|
-
return;
|
|
288
|
-
log?.info(
|
|
289
|
-
`${this.from} -- closing old inner connection (id: ${this.connection.debugId}) from session (id: ${this.debugId}) to ${this.to}`
|
|
290
|
-
);
|
|
291
|
-
this.connection.close();
|
|
292
|
-
this.connection = void 0;
|
|
293
|
-
}
|
|
294
|
-
replaceWithNewConnection(newConn) {
|
|
295
|
-
this.closeStaleConnection(this.connection);
|
|
296
|
-
this.cancelGrace();
|
|
297
|
-
this.connection = newConn;
|
|
298
|
-
}
|
|
299
|
-
beginGrace(cb) {
|
|
300
|
-
this.disconnectionGrace = setTimeout(() => {
|
|
301
|
-
this.close();
|
|
302
|
-
cb();
|
|
303
|
-
}, SESSION_DISCONNECT_GRACE_MS);
|
|
304
|
-
}
|
|
305
|
-
// called on reconnect of the underlying session
|
|
306
|
-
cancelGrace() {
|
|
307
|
-
this.heartbeatMisses = 0;
|
|
308
|
-
clearTimeout(this.disconnectionGrace);
|
|
309
|
-
}
|
|
310
|
-
// closed when we want to discard the whole session
|
|
311
|
-
// (i.e. shutdown or session disconnect)
|
|
312
|
-
close() {
|
|
313
|
-
this.closeStaleConnection(this.connection);
|
|
314
|
-
this.cancelGrace();
|
|
315
|
-
this.resetBufferedMessages();
|
|
316
|
-
clearInterval(this.heartbeat);
|
|
317
|
-
}
|
|
318
|
-
get connected() {
|
|
319
|
-
return this.connection !== void 0;
|
|
320
|
-
}
|
|
321
|
-
get nextExpectedSeq() {
|
|
322
|
-
return this.ack;
|
|
323
|
-
}
|
|
324
|
-
constructMsg(partialMsg) {
|
|
325
|
-
const msg = {
|
|
326
|
-
...partialMsg,
|
|
327
|
-
id: unsafeId(),
|
|
328
|
-
to: this.to,
|
|
329
|
-
from: this.from,
|
|
330
|
-
seq: this.seq,
|
|
331
|
-
ack: this.ack
|
|
332
|
-
};
|
|
333
|
-
this.seq++;
|
|
334
|
-
return msg;
|
|
335
|
-
}
|
|
336
|
-
inspectSendBuffer() {
|
|
337
|
-
return this.sendBuffer;
|
|
338
|
-
}
|
|
339
|
-
};
|
|
340
|
-
|
|
341
|
-
// codec/json.ts
|
|
342
|
-
var encoder = new TextEncoder();
|
|
343
|
-
var decoder = new TextDecoder();
|
|
344
|
-
function uint8ArrayToBase64(uint8Array) {
|
|
345
|
-
let binary = "";
|
|
346
|
-
uint8Array.forEach((byte) => {
|
|
347
|
-
binary += String.fromCharCode(byte);
|
|
348
|
-
});
|
|
349
|
-
return btoa(binary);
|
|
350
|
-
}
|
|
351
|
-
function base64ToUint8Array(base64) {
|
|
352
|
-
const binaryString = atob(base64);
|
|
353
|
-
const uint8Array = new Uint8Array(binaryString.length);
|
|
354
|
-
for (let i = 0; i < binaryString.length; i++) {
|
|
355
|
-
uint8Array[i] = binaryString.charCodeAt(i);
|
|
356
|
-
}
|
|
357
|
-
return uint8Array;
|
|
358
|
-
}
|
|
359
|
-
var NaiveJsonCodec = {
|
|
360
|
-
toBuffer: (obj) => {
|
|
361
|
-
return encoder.encode(
|
|
362
|
-
JSON.stringify(obj, function replacer(key) {
|
|
363
|
-
const val = this[key];
|
|
364
|
-
if (val instanceof Uint8Array) {
|
|
365
|
-
return { $t: uint8ArrayToBase64(val) };
|
|
366
|
-
} else {
|
|
367
|
-
return val;
|
|
368
|
-
}
|
|
369
|
-
})
|
|
370
|
-
);
|
|
371
|
-
},
|
|
372
|
-
fromBuffer: (buff) => {
|
|
373
|
-
try {
|
|
374
|
-
const parsed = JSON.parse(
|
|
375
|
-
decoder.decode(buff),
|
|
376
|
-
function reviver(_key, val) {
|
|
377
|
-
if (val?.$t) {
|
|
378
|
-
return base64ToUint8Array(val.$t);
|
|
379
|
-
} else {
|
|
380
|
-
return val;
|
|
381
|
-
}
|
|
382
|
-
}
|
|
383
|
-
);
|
|
384
|
-
if (typeof parsed === "object")
|
|
385
|
-
return parsed;
|
|
386
|
-
return null;
|
|
387
|
-
} catch {
|
|
388
|
-
return null;
|
|
389
|
-
}
|
|
390
|
-
}
|
|
391
|
-
};
|
|
392
|
-
|
|
393
|
-
// transport/transport.ts
|
|
394
|
-
var import_nanoid3 = require("nanoid");
|
|
395
|
-
|
|
396
|
-
// util/stringify.ts
|
|
397
|
-
function coerceErrorString(err) {
|
|
398
|
-
if (err instanceof Error) {
|
|
399
|
-
return err.message;
|
|
400
|
-
}
|
|
401
|
-
return `[coerced to error] ${String(err)}`;
|
|
402
|
-
}
|
|
403
|
-
|
|
404
|
-
// transport/transport.ts
|
|
405
|
-
var DEFAULT_RECONNECT_JITTER_MAX_MS = 500;
|
|
406
|
-
var DEFAULT_RECONNECT_INTERVAL_MS = 250;
|
|
407
|
-
var defaultTransportOptions = {
|
|
408
|
-
retryIntervalMs: DEFAULT_RECONNECT_INTERVAL_MS,
|
|
409
|
-
retryJitterMs: DEFAULT_RECONNECT_JITTER_MAX_MS,
|
|
410
|
-
retryAttemptsMax: 5,
|
|
411
|
-
codec: NaiveJsonCodec
|
|
412
|
-
};
|
|
413
|
-
var Transport = class {
|
|
414
|
-
/**
|
|
415
|
-
* Unique per instance of the transport.
|
|
416
|
-
* This allows us to distinguish reconnects to different
|
|
417
|
-
* transports.
|
|
418
|
-
*/
|
|
419
|
-
instanceId = (0, import_nanoid3.nanoid)();
|
|
420
|
-
connectedInstanceIds = /* @__PURE__ */ new Map();
|
|
421
|
-
/**
|
|
422
|
-
* A flag indicating whether the transport has been destroyed.
|
|
423
|
-
* A destroyed transport will not attempt to reconnect and cannot be used again.
|
|
424
|
-
*/
|
|
425
|
-
state;
|
|
426
|
-
/**
|
|
427
|
-
* The {@link Codec} used to encode and decode messages.
|
|
428
|
-
*/
|
|
429
|
-
codec;
|
|
430
|
-
/**
|
|
431
|
-
* The client ID of this transport.
|
|
432
|
-
*/
|
|
433
|
-
clientId;
|
|
434
|
-
/**
|
|
435
|
-
* The map of {@link Session}s managed by this transport.
|
|
436
|
-
*/
|
|
437
|
-
sessions;
|
|
438
|
-
/**
|
|
439
|
-
* The map of {@link Connection}s managed by this transport.
|
|
440
|
-
*/
|
|
441
|
-
get connections() {
|
|
442
|
-
return new Map(
|
|
443
|
-
[...this.sessions].map(([client, session]) => [client, session.connection]).filter((entry) => entry[1] !== void 0)
|
|
444
|
-
);
|
|
445
|
-
}
|
|
446
|
-
/**
|
|
447
|
-
* The event dispatcher for handling events of type EventTypes.
|
|
448
|
-
*/
|
|
449
|
-
eventDispatcher;
|
|
450
|
-
/**
|
|
451
|
-
* The options for this transport.
|
|
452
|
-
*/
|
|
453
|
-
options;
|
|
454
|
-
/**
|
|
455
|
-
* Creates a new Transport instance.
|
|
456
|
-
* This should also set up {@link onConnect}, and {@link onDisconnect} listeners.
|
|
457
|
-
* @param codec The codec used to encode and decode messages.
|
|
458
|
-
* @param clientId The client ID of this transport.
|
|
459
|
-
*/
|
|
460
|
-
constructor(clientId, providedOptions) {
|
|
461
|
-
this.options = { ...defaultTransportOptions, ...providedOptions };
|
|
462
|
-
this.eventDispatcher = new EventDispatcher();
|
|
463
|
-
this.sessions = /* @__PURE__ */ new Map();
|
|
464
|
-
this.codec = this.options.codec;
|
|
465
|
-
this.clientId = clientId;
|
|
466
|
-
this.state = "open";
|
|
467
|
-
}
|
|
468
|
-
/**
|
|
469
|
-
* Called when a new connection is established
|
|
470
|
-
* and we know the identity of the connected client.
|
|
471
|
-
* @param conn The connection object.
|
|
472
|
-
*/
|
|
473
|
-
onConnect(conn, connectedTo, instanceId) {
|
|
474
|
-
this.eventDispatcher.dispatchEvent("connectionStatus", {
|
|
475
|
-
status: "connect",
|
|
476
|
-
conn
|
|
477
|
-
});
|
|
478
|
-
let oldSession = this.sessions.get(connectedTo);
|
|
479
|
-
const lastInstanceId = this.connectedInstanceIds.get(connectedTo);
|
|
480
|
-
if (oldSession && lastInstanceId !== void 0 && lastInstanceId !== instanceId) {
|
|
481
|
-
log?.warn(
|
|
482
|
-
`${this.clientId} -- handshake from ${connectedTo} is a different instance (got: ${instanceId}, last connected to: ${lastInstanceId}), starting a new session`
|
|
483
|
-
);
|
|
484
|
-
oldSession.close();
|
|
485
|
-
this.deleteSession(oldSession);
|
|
486
|
-
oldSession = void 0;
|
|
487
|
-
}
|
|
488
|
-
this.connectedInstanceIds.set(connectedTo, instanceId);
|
|
489
|
-
if (oldSession === void 0) {
|
|
490
|
-
const newSession = this.createSession(connectedTo, conn);
|
|
491
|
-
log?.info(
|
|
492
|
-
`${this.clientId} -- new connection (id: ${conn.debugId}) for new session (id: ${newSession.debugId}) to ${connectedTo}`
|
|
493
|
-
);
|
|
494
|
-
return newSession;
|
|
495
|
-
}
|
|
496
|
-
log?.info(
|
|
497
|
-
`${this.clientId} -- new connection (id: ${conn.debugId}) for existing session (id: ${oldSession.debugId}) to ${connectedTo}`
|
|
498
|
-
);
|
|
499
|
-
oldSession.replaceWithNewConnection(conn);
|
|
500
|
-
oldSession.sendBufferedMessages();
|
|
501
|
-
return oldSession;
|
|
502
|
-
}
|
|
503
|
-
createSession(connectedTo, conn) {
|
|
504
|
-
const session = new Session(
|
|
505
|
-
this.codec,
|
|
506
|
-
this.clientId,
|
|
507
|
-
connectedTo,
|
|
508
|
-
conn
|
|
509
|
-
);
|
|
510
|
-
this.sessions.set(session.to, session);
|
|
511
|
-
this.eventDispatcher.dispatchEvent("sessionStatus", {
|
|
512
|
-
status: "connect",
|
|
513
|
-
session
|
|
514
|
-
});
|
|
515
|
-
return session;
|
|
516
|
-
}
|
|
517
|
-
deleteSession(session) {
|
|
518
|
-
this.sessions.delete(session.to);
|
|
519
|
-
log?.info(
|
|
520
|
-
`${this.clientId} -- session ${session.debugId} disconnect from ${session.to}`
|
|
521
|
-
);
|
|
522
|
-
this.eventDispatcher.dispatchEvent("sessionStatus", {
|
|
523
|
-
status: "disconnect",
|
|
524
|
-
session
|
|
525
|
-
});
|
|
526
|
-
}
|
|
527
|
-
/**
|
|
528
|
-
* The downstream implementation needs to call this when a connection is closed.
|
|
529
|
-
* @param conn The connection object.
|
|
530
|
-
* @param connectedTo The peer we are connected to.
|
|
531
|
-
*/
|
|
532
|
-
onDisconnect(conn, connectedTo) {
|
|
533
|
-
this.eventDispatcher.dispatchEvent("connectionStatus", {
|
|
534
|
-
status: "disconnect",
|
|
535
|
-
conn
|
|
536
|
-
});
|
|
537
|
-
const session = this.sessions.get(connectedTo);
|
|
538
|
-
if (!session)
|
|
539
|
-
return;
|
|
540
|
-
session.connection = void 0;
|
|
541
|
-
session.beginGrace(() => this.deleteSession(session));
|
|
542
|
-
}
|
|
543
|
-
/**
|
|
544
|
-
* Parses a message from a Uint8Array into a {@link OpaqueTransportMessage}.
|
|
545
|
-
* @param msg The message to parse.
|
|
546
|
-
* @returns The parsed message, or null if the message is malformed or invalid.
|
|
547
|
-
*/
|
|
548
|
-
parseMsg(msg) {
|
|
549
|
-
const parsedMsg = this.codec.fromBuffer(msg);
|
|
550
|
-
if (parsedMsg === null) {
|
|
551
|
-
const decodedBuffer = new TextDecoder().decode(msg);
|
|
552
|
-
log?.error(
|
|
553
|
-
`${this.clientId} -- received malformed msg, killing conn: ${decodedBuffer}`
|
|
554
|
-
);
|
|
555
|
-
return null;
|
|
556
|
-
}
|
|
557
|
-
if (!import_value.Value.Check(OpaqueTransportMessageSchema, parsedMsg)) {
|
|
558
|
-
log?.error(
|
|
559
|
-
`${this.clientId} -- received invalid msg: ${JSON.stringify(
|
|
560
|
-
parsedMsg
|
|
561
|
-
)}`
|
|
562
|
-
);
|
|
563
|
-
return null;
|
|
564
|
-
}
|
|
565
|
-
return {
|
|
566
|
-
...parsedMsg,
|
|
567
|
-
serviceName: parsedMsg.serviceName === null ? void 0 : parsedMsg.serviceName,
|
|
568
|
-
procedureName: parsedMsg.procedureName === null ? void 0 : parsedMsg.procedureName
|
|
569
|
-
};
|
|
570
|
-
}
|
|
571
|
-
/**
|
|
572
|
-
* Called when a message is received by this transport.
|
|
573
|
-
* You generally shouldn't need to override this in downstream transport implementations.
|
|
574
|
-
* @param msg The received message.
|
|
575
|
-
*/
|
|
576
|
-
handleMsg(msg) {
|
|
577
|
-
if (this.state !== "open")
|
|
578
|
-
return;
|
|
579
|
-
const session = this.sessions.get(msg.from);
|
|
580
|
-
if (!session) {
|
|
581
|
-
const err = `${this.clientId} -- (invariant violation) no existing session for ${msg.from}`;
|
|
582
|
-
log?.error(err);
|
|
583
|
-
return;
|
|
584
|
-
}
|
|
585
|
-
session.cancelGrace();
|
|
586
|
-
log?.debug(`${this.clientId} -- received msg: ${JSON.stringify(msg)}`);
|
|
587
|
-
if (msg.seq !== session.nextExpectedSeq) {
|
|
588
|
-
log?.warn(
|
|
589
|
-
`${this.clientId} -- received out-of-order msg (got: ${msg.seq}, wanted: ${session.nextExpectedSeq}), discarding: ${JSON.stringify(
|
|
590
|
-
msg
|
|
591
|
-
)}`
|
|
592
|
-
);
|
|
593
|
-
return;
|
|
594
|
-
}
|
|
595
|
-
if (!isAck(msg.controlFlags)) {
|
|
596
|
-
this.eventDispatcher.dispatchEvent("message", msg);
|
|
597
|
-
}
|
|
598
|
-
session.updateBookkeeping(msg.ack, msg.seq);
|
|
599
|
-
}
|
|
600
|
-
/**
|
|
601
|
-
* Adds a listener to this transport.
|
|
602
|
-
* @param the type of event to listen for
|
|
603
|
-
* @param handler The message handler to add.
|
|
604
|
-
*/
|
|
605
|
-
addEventListener(type, handler) {
|
|
606
|
-
this.eventDispatcher.addEventListener(type, handler);
|
|
607
|
-
}
|
|
608
|
-
/**
|
|
609
|
-
* Removes a listener from this transport.
|
|
610
|
-
* @param the type of event to unlisten on
|
|
611
|
-
* @param handler The message handler to remove.
|
|
612
|
-
*/
|
|
613
|
-
removeEventListener(type, handler) {
|
|
614
|
-
this.eventDispatcher.removeEventListener(type, handler);
|
|
615
|
-
}
|
|
616
|
-
/**
|
|
617
|
-
* Sends a message over this transport, delegating to the appropriate connection to actually
|
|
618
|
-
* send the message.
|
|
619
|
-
* @param msg The message to send.
|
|
620
|
-
* @returns The ID of the sent message or undefined if it wasn't sent
|
|
621
|
-
*/
|
|
622
|
-
send(to, msg) {
|
|
623
|
-
if (this.state === "destroyed") {
|
|
624
|
-
const err = "transport is destroyed, cant send";
|
|
625
|
-
log?.error(`${this.clientId} -- ` + err + `: ${JSON.stringify(msg)}`);
|
|
626
|
-
throw new Error(err);
|
|
627
|
-
} else if (this.state === "closed") {
|
|
628
|
-
log?.info(
|
|
629
|
-
`${this.clientId} -- transport closed when sending, discarding : ${JSON.stringify(
|
|
630
|
-
msg
|
|
631
|
-
)}`
|
|
632
|
-
);
|
|
633
|
-
return void 0;
|
|
634
|
-
}
|
|
635
|
-
let session = this.sessions.get(to);
|
|
636
|
-
if (!session) {
|
|
637
|
-
session = this.createSession(to, void 0);
|
|
638
|
-
log?.info(
|
|
639
|
-
`${this.clientId} -- no session for ${to}, created a new one (id: ${session.debugId})`
|
|
640
|
-
);
|
|
641
|
-
}
|
|
642
|
-
return session.send(msg);
|
|
643
|
-
}
|
|
644
|
-
// control helpers
|
|
645
|
-
sendCloseStream(to, streamId) {
|
|
646
|
-
return this.send(to, {
|
|
647
|
-
streamId,
|
|
648
|
-
controlFlags: 4 /* StreamClosedBit */,
|
|
649
|
-
payload: {
|
|
650
|
-
type: "CLOSE"
|
|
651
|
-
}
|
|
652
|
-
});
|
|
653
|
-
}
|
|
654
|
-
/**
|
|
655
|
-
* Default close implementation for transports. You should override this in the downstream
|
|
656
|
-
* implementation if you need to do any additional cleanup and call super.close() at the end.
|
|
657
|
-
* Closes the transport. Any messages sent while the transport is closed will be silently discarded.
|
|
658
|
-
*/
|
|
659
|
-
close() {
|
|
660
|
-
this.state = "closed";
|
|
661
|
-
for (const session of this.sessions.values()) {
|
|
662
|
-
session.close();
|
|
663
|
-
this.deleteSession(session);
|
|
664
|
-
}
|
|
665
|
-
log?.info(`${this.clientId} -- manually closed transport`);
|
|
666
|
-
}
|
|
667
|
-
/**
|
|
668
|
-
* Default destroy implementation for transports. You should override this in the downstream
|
|
669
|
-
* implementation if you need to do any additional cleanup and call super.destroy() at the end.
|
|
670
|
-
* Destroys the transport. Any messages sent while the transport is destroyed will throw an error.
|
|
671
|
-
*/
|
|
672
|
-
destroy() {
|
|
673
|
-
this.state = "destroyed";
|
|
674
|
-
for (const session of this.sessions.values()) {
|
|
675
|
-
session.close();
|
|
676
|
-
this.deleteSession(session);
|
|
677
|
-
}
|
|
678
|
-
log?.info(`${this.clientId} -- manually destroyed transport`);
|
|
679
|
-
}
|
|
680
|
-
};
|
|
681
|
-
var ServerTransport = class extends Transport {
|
|
682
|
-
constructor(clientId, providedOptions) {
|
|
683
|
-
super(clientId, providedOptions);
|
|
684
|
-
log?.info(
|
|
685
|
-
`${this.clientId} -- initiated server transport (instance id: ${this.instanceId}, protocol: ${PROTOCOL_VERSION})`
|
|
686
|
-
);
|
|
687
|
-
}
|
|
688
|
-
handleConnection(conn) {
|
|
689
|
-
let session = void 0;
|
|
690
|
-
const client = () => session?.to ?? "unknown";
|
|
691
|
-
const bootHandler = this.receiveWithBootSequence(
|
|
692
|
-
conn,
|
|
693
|
-
(establishedSession) => {
|
|
694
|
-
session = establishedSession;
|
|
695
|
-
conn.removeDataListener(bootHandler);
|
|
696
|
-
conn.addDataListener((data) => {
|
|
697
|
-
const parsed = this.parseMsg(data);
|
|
698
|
-
if (!parsed) {
|
|
699
|
-
conn.close();
|
|
700
|
-
return;
|
|
701
|
-
}
|
|
702
|
-
this.handleMsg(parsed);
|
|
703
|
-
});
|
|
704
|
-
}
|
|
705
|
-
);
|
|
706
|
-
conn.addDataListener(bootHandler);
|
|
707
|
-
conn.addCloseListener(() => {
|
|
708
|
-
if (!session)
|
|
709
|
-
return;
|
|
710
|
-
log?.info(
|
|
711
|
-
`${this.clientId} -- connection (id: ${conn.debugId}) to ${client()} disconnected`
|
|
712
|
-
);
|
|
713
|
-
this.onDisconnect(conn, session.to);
|
|
714
|
-
});
|
|
715
|
-
conn.addErrorListener((err) => {
|
|
716
|
-
if (!session)
|
|
717
|
-
return;
|
|
718
|
-
log?.warn(
|
|
719
|
-
`${this.clientId} -- connection (id: ${conn.debugId}) to ${client()} got an error: ${coerceErrorString(err)}`
|
|
720
|
-
);
|
|
721
|
-
});
|
|
722
|
-
}
|
|
723
|
-
receiveWithBootSequence(conn, sessionCb) {
|
|
724
|
-
const bootHandler = (data) => {
|
|
725
|
-
const parsed = this.parseMsg(data);
|
|
726
|
-
if (!parsed) {
|
|
727
|
-
conn.close();
|
|
728
|
-
return;
|
|
729
|
-
}
|
|
730
|
-
if (!import_value.Value.Check(ControlMessageHandshakeRequestSchema, parsed.payload)) {
|
|
731
|
-
const responseMsg2 = bootResponseMessage(
|
|
732
|
-
this.clientId,
|
|
733
|
-
this.instanceId,
|
|
734
|
-
parsed.from,
|
|
735
|
-
false
|
|
736
|
-
);
|
|
737
|
-
conn.send(this.codec.toBuffer(responseMsg2));
|
|
738
|
-
log?.warn(
|
|
739
|
-
`${this.clientId} -- received invalid handshake msg: ${JSON.stringify(
|
|
740
|
-
parsed
|
|
741
|
-
)}`
|
|
742
|
-
);
|
|
743
|
-
return;
|
|
744
|
-
}
|
|
745
|
-
const instanceId = parsed.payload.instanceId;
|
|
746
|
-
log?.debug(
|
|
747
|
-
`${this.clientId} -- handshake from ${parsed.from} ok (instance id: ${instanceId}), responding with handshake success`
|
|
748
|
-
);
|
|
749
|
-
const responseMsg = bootResponseMessage(
|
|
750
|
-
this.clientId,
|
|
751
|
-
this.instanceId,
|
|
752
|
-
parsed.from,
|
|
753
|
-
true
|
|
754
|
-
);
|
|
755
|
-
conn.send(this.codec.toBuffer(responseMsg));
|
|
756
|
-
sessionCb(this.onConnect(conn, parsed.from, instanceId));
|
|
757
|
-
};
|
|
758
|
-
return bootHandler;
|
|
759
|
-
}
|
|
760
|
-
};
|
|
761
|
-
|
|
762
|
-
// transport/transforms/messageFraming.ts
|
|
763
|
-
var import_node_stream = require("stream");
|
|
764
|
-
var Uint32LengthPrefixFraming = class extends import_node_stream.Transform {
|
|
765
|
-
receivedBuffer;
|
|
766
|
-
maxBufferSizeBytes;
|
|
767
|
-
constructor({ maxBufferSizeBytes, ...options }) {
|
|
768
|
-
super(options);
|
|
769
|
-
this.maxBufferSizeBytes = maxBufferSizeBytes;
|
|
770
|
-
this.receivedBuffer = Buffer.alloc(0);
|
|
771
|
-
}
|
|
772
|
-
_transform(chunk, _encoding, cb) {
|
|
773
|
-
if (this.receivedBuffer.byteLength + chunk.byteLength > this.maxBufferSizeBytes) {
|
|
774
|
-
const err = new Error(
|
|
775
|
-
`buffer overflow: ${this.receivedBuffer.byteLength}B > ${this.maxBufferSizeBytes}B`
|
|
776
|
-
);
|
|
777
|
-
this.emit("error", err);
|
|
778
|
-
cb(err);
|
|
779
|
-
return;
|
|
780
|
-
}
|
|
781
|
-
this.receivedBuffer = Buffer.concat([this.receivedBuffer, chunk]);
|
|
782
|
-
while (this.receivedBuffer.length > 4) {
|
|
783
|
-
const claimedMessageLength = this.receivedBuffer.readUInt32BE(0) + 4;
|
|
784
|
-
if (this.receivedBuffer.length >= claimedMessageLength) {
|
|
785
|
-
const message = this.receivedBuffer.subarray(4, claimedMessageLength);
|
|
786
|
-
this.push(message);
|
|
787
|
-
this.receivedBuffer = this.receivedBuffer.subarray(claimedMessageLength);
|
|
788
|
-
} else {
|
|
789
|
-
break;
|
|
790
|
-
}
|
|
791
|
-
}
|
|
792
|
-
cb();
|
|
793
|
-
}
|
|
794
|
-
_flush(cb) {
|
|
795
|
-
if (this.receivedBuffer.length) {
|
|
796
|
-
this.emit("error", new Error("got incomplete message while flushing"));
|
|
797
|
-
}
|
|
798
|
-
this.receivedBuffer = Buffer.alloc(0);
|
|
799
|
-
cb();
|
|
800
|
-
}
|
|
801
|
-
_destroy(error, callback) {
|
|
802
|
-
this.receivedBuffer = Buffer.alloc(0);
|
|
803
|
-
super._destroy(error, callback);
|
|
804
|
-
}
|
|
805
|
-
};
|
|
806
|
-
function createLengthEncodedStream(options) {
|
|
807
|
-
return new Uint32LengthPrefixFraming({
|
|
808
|
-
maxBufferSizeBytes: options?.maxBufferSizeBytes ?? 16 * 1024 * 1024
|
|
809
|
-
// 16MB
|
|
810
|
-
});
|
|
811
|
-
}
|
|
812
|
-
var MessageFramer = {
|
|
813
|
-
createFramedStream: createLengthEncodedStream,
|
|
814
|
-
write: (buf) => {
|
|
815
|
-
const lengthPrefix = Buffer.alloc(4);
|
|
816
|
-
lengthPrefix.writeUInt32BE(buf.length, 0);
|
|
817
|
-
return Buffer.concat([lengthPrefix, buf]);
|
|
818
|
-
}
|
|
819
|
-
};
|
|
820
|
-
|
|
821
|
-
// transport/impls/stdio/connection.ts
|
|
822
|
-
var StreamConnection = class extends Connection {
|
|
823
|
-
input;
|
|
824
|
-
output;
|
|
825
|
-
framer;
|
|
826
|
-
constructor(input, output) {
|
|
827
|
-
super();
|
|
828
|
-
this.framer = MessageFramer.createFramedStream();
|
|
829
|
-
this.input = input.pipe(this.framer);
|
|
830
|
-
this.output = output;
|
|
831
|
-
}
|
|
832
|
-
addDataListener(cb) {
|
|
833
|
-
this.input.on("data", cb);
|
|
834
|
-
}
|
|
835
|
-
removeDataListener(cb) {
|
|
836
|
-
this.input.off("data", cb);
|
|
837
|
-
}
|
|
838
|
-
addCloseListener(cb) {
|
|
839
|
-
this.input.on("close", cb);
|
|
840
|
-
this.output.on("close", cb);
|
|
841
|
-
}
|
|
842
|
-
addErrorListener(cb) {
|
|
843
|
-
this.input.on("error", cb);
|
|
844
|
-
this.output.on("error", cb);
|
|
845
|
-
}
|
|
846
|
-
send(payload) {
|
|
847
|
-
if (!this.output.writable)
|
|
848
|
-
return false;
|
|
849
|
-
return this.output.write(MessageFramer.write(payload));
|
|
850
|
-
}
|
|
851
|
-
close() {
|
|
852
|
-
this.output.end();
|
|
853
|
-
this.input.unpipe(this.framer);
|
|
854
|
-
this.framer.destroy();
|
|
855
|
-
}
|
|
856
|
-
};
|
|
857
|
-
|
|
858
|
-
// transport/impls/stdio/server.ts
|
|
859
|
-
var StdioServerTransport = class extends ServerTransport {
|
|
860
|
-
input = process.stdin;
|
|
861
|
-
output = process.stdout;
|
|
862
|
-
/**
|
|
863
|
-
* Constructs a new StdioServerTransport instance.
|
|
864
|
-
* @param clientId - The ID of the client associated with this transport.
|
|
865
|
-
* @param input - The readable stream to use as input. Defaults to process.stdin.
|
|
866
|
-
* @param output - The writable stream to use as output. Defaults to process.stdout.
|
|
867
|
-
*/
|
|
868
|
-
constructor(clientId, input = process.stdin, output = process.stdout, providedOptions) {
|
|
869
|
-
super(clientId, providedOptions);
|
|
870
|
-
this.input = input;
|
|
871
|
-
this.output = output;
|
|
872
|
-
const conn = new StreamConnection(this.input, this.output);
|
|
873
|
-
this.handleConnection(conn);
|
|
874
|
-
}
|
|
875
|
-
};
|
|
876
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
877
|
-
0 && (module.exports = {
|
|
878
|
-
StdioServerTransport
|
|
879
|
-
});
|