@orkestrel/mcp 0.0.21 → 0.0.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -85,6 +85,18 @@ var DEFAULT_MCP_SESSION_CAPACITY = 1024;
|
|
|
85
85
|
* this bounds the replay log paired with it.
|
|
86
86
|
*/
|
|
87
87
|
var DEFAULT_MCP_SESSION_TTL = 3e5;
|
|
88
|
+
/**
|
|
89
|
+
* The default bound in milliseconds on one unconfirmed write to a stdio client transport's
|
|
90
|
+
* child `stdin` — the `delivery` a `createStdioClientTransport` caller who supplies none gets.
|
|
91
|
+
*
|
|
92
|
+
* @remarks
|
|
93
|
+
* Ten seconds. The load-bearing property is the ordering, not the magnitude: this bound stays
|
|
94
|
+
* BELOW {@link import('@orkestrel/mcp').DEFAULT_MCP_REQUEST_TIMEOUT}, so a write the child never
|
|
95
|
+
* reads fails as an undeliverable message while the request that carried it is still open,
|
|
96
|
+
* rather than being masked by that request's own deadline expiring first. Override per
|
|
97
|
+
* transport with `delivery`; an explicit `0` there removes the bound.
|
|
98
|
+
*/
|
|
99
|
+
var DEFAULT_MCP_DELIVERY = 1e4;
|
|
88
100
|
//#endregion
|
|
89
101
|
//#region src/server/helpers.ts
|
|
90
102
|
/**
|
|
@@ -1381,9 +1393,10 @@ var WebSocketClientTransport = class {
|
|
|
1381
1393
|
* - **Outbound (`send`).** `send(message)` writes one newline-terminated `JSON.stringify`d line
|
|
1382
1394
|
* through the supervisor's `send` and AWAITS its answer, so this promise settles only after the
|
|
1383
1395
|
* host reports the line handled rather than the moment the write is queued. The supervisor never
|
|
1384
|
-
* rejects — it answers `false` for a channel that was closed, destroyed, or ended,
|
|
1385
|
-
* that failed
|
|
1386
|
-
*
|
|
1396
|
+
* rejects — it answers `false` for a channel that was closed, destroyed, or ended, for a write
|
|
1397
|
+
* that failed, or for one that remained unconfirmed through `delivery`. A call made without a
|
|
1398
|
+
* live child rejects as not connected; a `false` answer from a live child rejects as unable to
|
|
1399
|
+
* deliver. The supervisor does not disclose which cause produced that answer.
|
|
1387
1400
|
* - **`close()`** runs the supervisor's bounded termination and teardown, then fires `close` once
|
|
1388
1401
|
* (idempotent). That teardown reaches the child's TERMINAL MOMENT, where the supervisor freezes
|
|
1389
1402
|
* `evidence`, ends `lines`, and settles `exit` together, so this transport needs no release of
|
|
@@ -1423,6 +1436,7 @@ var StdioClientTransport = class {
|
|
|
1423
1436
|
#command;
|
|
1424
1437
|
#args;
|
|
1425
1438
|
#env;
|
|
1439
|
+
#delivery;
|
|
1426
1440
|
#process = void 0;
|
|
1427
1441
|
#closing = void 0;
|
|
1428
1442
|
#closed = false;
|
|
@@ -1431,6 +1445,7 @@ var StdioClientTransport = class {
|
|
|
1431
1445
|
this.#command = options.command;
|
|
1432
1446
|
this.#args = options.args ?? [];
|
|
1433
1447
|
this.#env = options.env;
|
|
1448
|
+
this.#delivery = options.delivery ?? 1e4;
|
|
1434
1449
|
}
|
|
1435
1450
|
get emitter() {
|
|
1436
1451
|
return this.#emitter;
|
|
@@ -1462,6 +1477,7 @@ var StdioClientTransport = class {
|
|
|
1462
1477
|
},
|
|
1463
1478
|
workspace: process.cwd(),
|
|
1464
1479
|
grace: _orkestrel_process.PROCESS_GRACE,
|
|
1480
|
+
delivery: this.#delivery,
|
|
1465
1481
|
writable: true
|
|
1466
1482
|
});
|
|
1467
1483
|
this.#process = child;
|
|
@@ -1469,9 +1485,20 @@ var StdioClientTransport = class {
|
|
|
1469
1485
|
child.exit.then((exit) => this.#onExit(child, exit));
|
|
1470
1486
|
this.#pump(child);
|
|
1471
1487
|
}
|
|
1488
|
+
/**
|
|
1489
|
+
* Sends one newline-delimited JSON-RPC message to the live child.
|
|
1490
|
+
*
|
|
1491
|
+
* @param message - The message to write to the child's `stdin`
|
|
1492
|
+
* @returns Resolves when the supervisor confirms the write
|
|
1493
|
+
* @throws Thrown with `stdio transport is not connected` when no live child is available before
|
|
1494
|
+
* the write
|
|
1495
|
+
* @throws Thrown with `stdio transport could not deliver the message` when a live child's write
|
|
1496
|
+
* resolves `false`
|
|
1497
|
+
*/
|
|
1472
1498
|
async send(message) {
|
|
1473
1499
|
const child = this.#closed ? void 0 : this.#process;
|
|
1474
|
-
if (
|
|
1500
|
+
if (child === void 0) throw new Error("stdio transport is not connected");
|
|
1501
|
+
if (!await child.send(JSON.stringify(message))) throw new Error("stdio transport could not deliver the message");
|
|
1475
1502
|
}
|
|
1476
1503
|
async close() {
|
|
1477
1504
|
if (this.#closed && this.#closing === void 0) return;
|
|
@@ -1865,10 +1892,14 @@ function createWebSocketClientTransport(options) {
|
|
|
1865
1892
|
* inherits it. Each JSON-RPC message the client `send`s is written as one
|
|
1866
1893
|
* newline-terminated line to the child's `stdin`; each decoded reply line from the
|
|
1867
1894
|
* child's `stdout` is surfaced on the transport's `message` event for the client's
|
|
1868
|
-
* id correlation.
|
|
1895
|
+
* id correlation. That write is bounded: a child that stays alive without ever reading
|
|
1896
|
+
* its `stdin` fills the pipe, and `options.delivery` is how long the unconfirmed write
|
|
1897
|
+
* waits before the `send` rejects. An omitted `delivery` selects {@link
|
|
1898
|
+
* import('./constants.js').DEFAULT_MCP_DELIVERY}; an explicit `0` removes the bound.
|
|
1869
1899
|
*
|
|
1870
1900
|
* @param options - `command` (the executable to spawn; REQUIRED), optional `args`,
|
|
1871
|
-
* and optional `
|
|
1901
|
+
* optional `env`, and an optional `delivery` bound in milliseconds on an unconfirmed
|
|
1902
|
+
* `stdin` write; see {@link StdioClientTransportOptions}
|
|
1872
1903
|
* @returns A working {@link StdioClientTransportInterface} over a child process's stdio,
|
|
1873
1904
|
* whose `evidence` carries the supervised child's bounded stderr tail
|
|
1874
1905
|
*
|
|
@@ -2107,6 +2138,7 @@ function createMCPSession(options) {
|
|
|
2107
2138
|
};
|
|
2108
2139
|
}
|
|
2109
2140
|
//#endregion
|
|
2141
|
+
exports.DEFAULT_MCP_DELIVERY = DEFAULT_MCP_DELIVERY;
|
|
2110
2142
|
exports.DEFAULT_MCP_KEEPALIVE_INTERVAL = DEFAULT_MCP_KEEPALIVE_INTERVAL;
|
|
2111
2143
|
exports.DEFAULT_MCP_PATH = DEFAULT_MCP_PATH;
|
|
2112
2144
|
exports.DEFAULT_MCP_SESSION_CAPACITY = DEFAULT_MCP_SESSION_CAPACITY;
|