@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.
@@ -336,10 +336,14 @@ export declare function createReadableStream<T>(pull: (controller: ReadableStrea
336
336
  * inherits it. Each JSON-RPC message the client `send`s is written as one
337
337
  * newline-terminated line to the child's `stdin`; each decoded reply line from the
338
338
  * child's `stdout` is surfaced on the transport's `message` event for the client's
339
- * id correlation.
339
+ * id correlation. That write is bounded: a child that stays alive without ever reading
340
+ * its `stdin` fills the pipe, and `options.delivery` is how long the unconfirmed write
341
+ * waits before the `send` rejects. An omitted `delivery` selects {@link
342
+ * import('./constants.js').DEFAULT_MCP_DELIVERY}; an explicit `0` removes the bound.
340
343
  *
341
344
  * @param options - `command` (the executable to spawn; REQUIRED), optional `args`,
342
- * and optional `env`; see {@link StdioClientTransportOptions}
345
+ * optional `env`, and an optional `delivery` bound in milliseconds on an unconfirmed
346
+ * `stdin` write; see {@link StdioClientTransportOptions}
343
347
  * @returns A working {@link StdioClientTransportInterface} over a child process's stdio,
344
348
  * whose `evidence` carries the supervised child's bounded stderr tail
345
349
  *
@@ -498,6 +502,19 @@ export declare function createWebSocketServer(mcp: MCPDispatcherInterface, optio
498
502
  */
499
503
  export declare function decodeEvent(data: string): JSONRPCMessage | undefined;
500
504
 
505
+ /**
506
+ * The default bound in milliseconds on one unconfirmed write to a stdio client transport's
507
+ * child `stdin` — the `delivery` a `createStdioClientTransport` caller who supplies none gets.
508
+ *
509
+ * @remarks
510
+ * Ten seconds. The load-bearing property is the ordering, not the magnitude: this bound stays
511
+ * BELOW {@link import('@orkestrel/mcp').DEFAULT_MCP_REQUEST_TIMEOUT}, so a write the child never
512
+ * reads fails as an undeliverable message while the request that carried it is still open,
513
+ * rather than being masked by that request's own deadline expiring first. Override per
514
+ * transport with `delivery`; an explicit `0` there removes the bound.
515
+ */
516
+ export declare const DEFAULT_MCP_DELIVERY = 10000;
517
+
501
518
  /**
502
519
  * The default interval in milliseconds between SSE keepalive comments on held-open MCP
503
520
  * responses.
@@ -1262,9 +1279,10 @@ export declare const SSE_KEEPALIVE_COMMENT = "keepalive";
1262
1279
  * - **Outbound (`send`).** `send(message)` writes one newline-terminated `JSON.stringify`d line
1263
1280
  * through the supervisor's `send` and AWAITS its answer, so this promise settles only after the
1264
1281
  * host reports the line handled rather than the moment the write is queued. The supervisor never
1265
- * rejects — it answers `false` for a channel that was closed, destroyed, or ended, and for a write
1266
- * that failed so a `false` answer REJECTS here with the same not-connected error a transport
1267
- * that was never started raises. A dead peer surfaces at the caller instead of vanishing.
1282
+ * rejects — it answers `false` for a channel that was closed, destroyed, or ended, for a write
1283
+ * that failed, or for one that remained unconfirmed through `delivery`. A call made without a
1284
+ * live child rejects as not connected; a `false` answer from a live child rejects as unable to
1285
+ * deliver. The supervisor does not disclose which cause produced that answer.
1268
1286
  * - **`close()`** runs the supervisor's bounded termination and teardown, then fires `close` once
1269
1287
  * (idempotent). That teardown reaches the child's TERMINAL MOMENT, where the supervisor freezes
1270
1288
  * `evidence`, ends `lines`, and settles `exit` together, so this transport needs no release of
@@ -1307,6 +1325,16 @@ export declare class StdioClientTransport implements StdioClientTransportInterfa
1307
1325
  get duplex(): boolean;
1308
1326
  get evidence(): string | undefined;
1309
1327
  start(): Promise<void>;
1328
+ /**
1329
+ * Sends one newline-delimited JSON-RPC message to the live child.
1330
+ *
1331
+ * @param message - The message to write to the child's `stdin`
1332
+ * @returns Resolves when the supervisor confirms the write
1333
+ * @throws Thrown with `stdio transport is not connected` when no live child is available before
1334
+ * the write
1335
+ * @throws Thrown with `stdio transport could not deliver the message` when a live child's write
1336
+ * resolves `false`
1337
+ */
1310
1338
  send(message: JSONRPCMessage_2): Promise<void>;
1311
1339
  close(): Promise<void>;
1312
1340
  }
@@ -1391,11 +1419,34 @@ export declare interface StdioClientTransportInterface extends MCPClientTranspor
1391
1419
  * OMITTED the child inherits the full `process.env`, when PROVIDED each named key overrides
1392
1420
  * the inherited value while every unlisted key is still inherited. This transport cannot
1393
1421
  * REPLACE the inherited environment entirely — the supervisor always merges over the parent.
1422
+ * - `delivery` — the bound in milliseconds on one unconfirmed write to the child's `stdin`;
1423
+ * an explicit `0` opts out. Defaults to {@link import('./constants.js').DEFAULT_MCP_DELIVERY}.
1394
1424
  */
1395
1425
  export declare interface StdioClientTransportOptions {
1396
1426
  readonly command: string;
1397
1427
  readonly args?: readonly string[];
1398
1428
  readonly env?: Readonly<Record<string, string>>;
1429
+ /**
1430
+ * Bounds the wait on one unconfirmed `send` write to the child's `stdin`, in milliseconds.
1431
+ *
1432
+ * @remarks
1433
+ * A full pipe is the case this bounds: a live child that never reads its `stdin` leaves the
1434
+ * kernel unable to confirm the write, and the supervisor holds that write open. When the
1435
+ * window elapses the supervisor answers that write `false`, which this transport surfaces as
1436
+ * a rejection, so the caller learns the message did not land instead of waiting on a peer
1437
+ * that will never read it. Default: {@link import('./constants.js').DEFAULT_MCP_DELIVERY}.
1438
+ *
1439
+ * An explicit `0` opts out: the bound is off, and an unconfirmed write stays pending until
1440
+ * the channel faults or teardown settles it. Omission does NOT opt out here, which is where
1441
+ * this option diverges from the supervisor's own `delivery` on {@link
1442
+ * import('@orkestrel/process').ProcessOptions} — omitted THERE disables the bound, omitted
1443
+ * HERE selects the default.
1444
+ *
1445
+ * An out-of-range value surfaces at `start()` rather than at construction. This transport
1446
+ * forwards the value verbatim and adds no validator of its own, so the supervisor's own timer
1447
+ * range is what rejects it, at the moment it spawns the child.
1448
+ */
1449
+ readonly delivery?: number;
1399
1450
  }
1400
1451
 
1401
1452
  /**
@@ -336,10 +336,14 @@ export declare function createReadableStream<T>(pull: (controller: ReadableStrea
336
336
  * inherits it. Each JSON-RPC message the client `send`s is written as one
337
337
  * newline-terminated line to the child's `stdin`; each decoded reply line from the
338
338
  * child's `stdout` is surfaced on the transport's `message` event for the client's
339
- * id correlation.
339
+ * id correlation. That write is bounded: a child that stays alive without ever reading
340
+ * its `stdin` fills the pipe, and `options.delivery` is how long the unconfirmed write
341
+ * waits before the `send` rejects. An omitted `delivery` selects {@link
342
+ * import('./constants.js').DEFAULT_MCP_DELIVERY}; an explicit `0` removes the bound.
340
343
  *
341
344
  * @param options - `command` (the executable to spawn; REQUIRED), optional `args`,
342
- * and optional `env`; see {@link StdioClientTransportOptions}
345
+ * optional `env`, and an optional `delivery` bound in milliseconds on an unconfirmed
346
+ * `stdin` write; see {@link StdioClientTransportOptions}
343
347
  * @returns A working {@link StdioClientTransportInterface} over a child process's stdio,
344
348
  * whose `evidence` carries the supervised child's bounded stderr tail
345
349
  *
@@ -498,6 +502,19 @@ export declare function createWebSocketServer(mcp: MCPDispatcherInterface, optio
498
502
  */
499
503
  export declare function decodeEvent(data: string): JSONRPCMessage | undefined;
500
504
 
505
+ /**
506
+ * The default bound in milliseconds on one unconfirmed write to a stdio client transport's
507
+ * child `stdin` — the `delivery` a `createStdioClientTransport` caller who supplies none gets.
508
+ *
509
+ * @remarks
510
+ * Ten seconds. The load-bearing property is the ordering, not the magnitude: this bound stays
511
+ * BELOW {@link import('@orkestrel/mcp').DEFAULT_MCP_REQUEST_TIMEOUT}, so a write the child never
512
+ * reads fails as an undeliverable message while the request that carried it is still open,
513
+ * rather than being masked by that request's own deadline expiring first. Override per
514
+ * transport with `delivery`; an explicit `0` there removes the bound.
515
+ */
516
+ export declare const DEFAULT_MCP_DELIVERY = 10000;
517
+
501
518
  /**
502
519
  * The default interval in milliseconds between SSE keepalive comments on held-open MCP
503
520
  * responses.
@@ -1262,9 +1279,10 @@ export declare const SSE_KEEPALIVE_COMMENT = "keepalive";
1262
1279
  * - **Outbound (`send`).** `send(message)` writes one newline-terminated `JSON.stringify`d line
1263
1280
  * through the supervisor's `send` and AWAITS its answer, so this promise settles only after the
1264
1281
  * host reports the line handled rather than the moment the write is queued. The supervisor never
1265
- * rejects — it answers `false` for a channel that was closed, destroyed, or ended, and for a write
1266
- * that failed so a `false` answer REJECTS here with the same not-connected error a transport
1267
- * that was never started raises. A dead peer surfaces at the caller instead of vanishing.
1282
+ * rejects — it answers `false` for a channel that was closed, destroyed, or ended, for a write
1283
+ * that failed, or for one that remained unconfirmed through `delivery`. A call made without a
1284
+ * live child rejects as not connected; a `false` answer from a live child rejects as unable to
1285
+ * deliver. The supervisor does not disclose which cause produced that answer.
1268
1286
  * - **`close()`** runs the supervisor's bounded termination and teardown, then fires `close` once
1269
1287
  * (idempotent). That teardown reaches the child's TERMINAL MOMENT, where the supervisor freezes
1270
1288
  * `evidence`, ends `lines`, and settles `exit` together, so this transport needs no release of
@@ -1307,6 +1325,16 @@ export declare class StdioClientTransport implements StdioClientTransportInterfa
1307
1325
  get duplex(): boolean;
1308
1326
  get evidence(): string | undefined;
1309
1327
  start(): Promise<void>;
1328
+ /**
1329
+ * Sends one newline-delimited JSON-RPC message to the live child.
1330
+ *
1331
+ * @param message - The message to write to the child's `stdin`
1332
+ * @returns Resolves when the supervisor confirms the write
1333
+ * @throws Thrown with `stdio transport is not connected` when no live child is available before
1334
+ * the write
1335
+ * @throws Thrown with `stdio transport could not deliver the message` when a live child's write
1336
+ * resolves `false`
1337
+ */
1310
1338
  send(message: JSONRPCMessage_2): Promise<void>;
1311
1339
  close(): Promise<void>;
1312
1340
  }
@@ -1391,11 +1419,34 @@ export declare interface StdioClientTransportInterface extends MCPClientTranspor
1391
1419
  * OMITTED the child inherits the full `process.env`, when PROVIDED each named key overrides
1392
1420
  * the inherited value while every unlisted key is still inherited. This transport cannot
1393
1421
  * REPLACE the inherited environment entirely — the supervisor always merges over the parent.
1422
+ * - `delivery` — the bound in milliseconds on one unconfirmed write to the child's `stdin`;
1423
+ * an explicit `0` opts out. Defaults to {@link import('./constants.js').DEFAULT_MCP_DELIVERY}.
1394
1424
  */
1395
1425
  export declare interface StdioClientTransportOptions {
1396
1426
  readonly command: string;
1397
1427
  readonly args?: readonly string[];
1398
1428
  readonly env?: Readonly<Record<string, string>>;
1429
+ /**
1430
+ * Bounds the wait on one unconfirmed `send` write to the child's `stdin`, in milliseconds.
1431
+ *
1432
+ * @remarks
1433
+ * A full pipe is the case this bounds: a live child that never reads its `stdin` leaves the
1434
+ * kernel unable to confirm the write, and the supervisor holds that write open. When the
1435
+ * window elapses the supervisor answers that write `false`, which this transport surfaces as
1436
+ * a rejection, so the caller learns the message did not land instead of waiting on a peer
1437
+ * that will never read it. Default: {@link import('./constants.js').DEFAULT_MCP_DELIVERY}.
1438
+ *
1439
+ * An explicit `0` opts out: the bound is off, and an unconfirmed write stays pending until
1440
+ * the channel faults or teardown settles it. Omission does NOT opt out here, which is where
1441
+ * this option diverges from the supervisor's own `delivery` on {@link
1442
+ * import('@orkestrel/process').ProcessOptions} — omitted THERE disables the bound, omitted
1443
+ * HERE selects the default.
1444
+ *
1445
+ * An out-of-range value surfaces at `start()` rather than at construction. This transport
1446
+ * forwards the value verbatim and adds no validator of its own, so the supervisor's own timer
1447
+ * range is what rejects it, at the moment it spawns the child.
1448
+ */
1449
+ readonly delivery?: number;
1399
1450
  }
1400
1451
 
1401
1452
  /**
@@ -84,6 +84,18 @@ var DEFAULT_MCP_SESSION_CAPACITY = 1024;
84
84
  * this bounds the replay log paired with it.
85
85
  */
86
86
  var DEFAULT_MCP_SESSION_TTL = 3e5;
87
+ /**
88
+ * The default bound in milliseconds on one unconfirmed write to a stdio client transport's
89
+ * child `stdin` — the `delivery` a `createStdioClientTransport` caller who supplies none gets.
90
+ *
91
+ * @remarks
92
+ * Ten seconds. The load-bearing property is the ordering, not the magnitude: this bound stays
93
+ * BELOW {@link import('@orkestrel/mcp').DEFAULT_MCP_REQUEST_TIMEOUT}, so a write the child never
94
+ * reads fails as an undeliverable message while the request that carried it is still open,
95
+ * rather than being masked by that request's own deadline expiring first. Override per
96
+ * transport with `delivery`; an explicit `0` there removes the bound.
97
+ */
98
+ var DEFAULT_MCP_DELIVERY = 1e4;
87
99
  //#endregion
88
100
  //#region src/server/helpers.ts
89
101
  /**
@@ -1380,9 +1392,10 @@ var WebSocketClientTransport = class {
1380
1392
  * - **Outbound (`send`).** `send(message)` writes one newline-terminated `JSON.stringify`d line
1381
1393
  * through the supervisor's `send` and AWAITS its answer, so this promise settles only after the
1382
1394
  * host reports the line handled rather than the moment the write is queued. The supervisor never
1383
- * rejects — it answers `false` for a channel that was closed, destroyed, or ended, and for a write
1384
- * that failed so a `false` answer REJECTS here with the same not-connected error a transport
1385
- * that was never started raises. A dead peer surfaces at the caller instead of vanishing.
1395
+ * rejects — it answers `false` for a channel that was closed, destroyed, or ended, for a write
1396
+ * that failed, or for one that remained unconfirmed through `delivery`. A call made without a
1397
+ * live child rejects as not connected; a `false` answer from a live child rejects as unable to
1398
+ * deliver. The supervisor does not disclose which cause produced that answer.
1386
1399
  * - **`close()`** runs the supervisor's bounded termination and teardown, then fires `close` once
1387
1400
  * (idempotent). That teardown reaches the child's TERMINAL MOMENT, where the supervisor freezes
1388
1401
  * `evidence`, ends `lines`, and settles `exit` together, so this transport needs no release of
@@ -1422,6 +1435,7 @@ var StdioClientTransport = class {
1422
1435
  #command;
1423
1436
  #args;
1424
1437
  #env;
1438
+ #delivery;
1425
1439
  #process = void 0;
1426
1440
  #closing = void 0;
1427
1441
  #closed = false;
@@ -1430,6 +1444,7 @@ var StdioClientTransport = class {
1430
1444
  this.#command = options.command;
1431
1445
  this.#args = options.args ?? [];
1432
1446
  this.#env = options.env;
1447
+ this.#delivery = options.delivery ?? 1e4;
1433
1448
  }
1434
1449
  get emitter() {
1435
1450
  return this.#emitter;
@@ -1461,6 +1476,7 @@ var StdioClientTransport = class {
1461
1476
  },
1462
1477
  workspace: process.cwd(),
1463
1478
  grace: PROCESS_GRACE,
1479
+ delivery: this.#delivery,
1464
1480
  writable: true
1465
1481
  });
1466
1482
  this.#process = child;
@@ -1468,9 +1484,20 @@ var StdioClientTransport = class {
1468
1484
  child.exit.then((exit) => this.#onExit(child, exit));
1469
1485
  this.#pump(child);
1470
1486
  }
1487
+ /**
1488
+ * Sends one newline-delimited JSON-RPC message to the live child.
1489
+ *
1490
+ * @param message - The message to write to the child's `stdin`
1491
+ * @returns Resolves when the supervisor confirms the write
1492
+ * @throws Thrown with `stdio transport is not connected` when no live child is available before
1493
+ * the write
1494
+ * @throws Thrown with `stdio transport could not deliver the message` when a live child's write
1495
+ * resolves `false`
1496
+ */
1471
1497
  async send(message) {
1472
1498
  const child = this.#closed ? void 0 : this.#process;
1473
- if (!(child === void 0 ? false : await child.send(JSON.stringify(message)))) throw new Error("stdio transport is not connected");
1499
+ if (child === void 0) throw new Error("stdio transport is not connected");
1500
+ if (!await child.send(JSON.stringify(message))) throw new Error("stdio transport could not deliver the message");
1474
1501
  }
1475
1502
  async close() {
1476
1503
  if (this.#closed && this.#closing === void 0) return;
@@ -1864,10 +1891,14 @@ function createWebSocketClientTransport(options) {
1864
1891
  * inherits it. Each JSON-RPC message the client `send`s is written as one
1865
1892
  * newline-terminated line to the child's `stdin`; each decoded reply line from the
1866
1893
  * child's `stdout` is surfaced on the transport's `message` event for the client's
1867
- * id correlation.
1894
+ * id correlation. That write is bounded: a child that stays alive without ever reading
1895
+ * its `stdin` fills the pipe, and `options.delivery` is how long the unconfirmed write
1896
+ * waits before the `send` rejects. An omitted `delivery` selects {@link
1897
+ * import('./constants.js').DEFAULT_MCP_DELIVERY}; an explicit `0` removes the bound.
1868
1898
  *
1869
1899
  * @param options - `command` (the executable to spawn; REQUIRED), optional `args`,
1870
- * and optional `env`; see {@link StdioClientTransportOptions}
1900
+ * optional `env`, and an optional `delivery` bound in milliseconds on an unconfirmed
1901
+ * `stdin` write; see {@link StdioClientTransportOptions}
1871
1902
  * @returns A working {@link StdioClientTransportInterface} over a child process's stdio,
1872
1903
  * whose `evidence` carries the supervised child's bounded stderr tail
1873
1904
  *
@@ -2106,6 +2137,6 @@ function createMCPSession(options) {
2106
2137
  };
2107
2138
  }
2108
2139
  //#endregion
2109
- export { DEFAULT_MCP_KEEPALIVE_INTERVAL, DEFAULT_MCP_PATH, DEFAULT_MCP_SESSION_CAPACITY, DEFAULT_MCP_SESSION_TTL, HTTPClientTransport, HTTPDisconnect, MCPSession, MCP_METHOD_HEADER, MCP_NAME_HEADER, MCP_PROTOCOL_VERSION_HEADER, MCP_SESSION_HEADER, MCP_WEBSOCKET_SUBPROTOCOL, SSE_BUFFERING_DISABLED, SSE_BUFFERING_HEADER, SSE_KEEPALIVE_COMMENT, StdioClientTransport, StdioServerTransport, WebSocketClientTransport, WebSocketServerTransport, acceptsEventStream, allowsOrigin, bridgeMessageTransport, createHTTPClientTransport, createMCPContinuation, createMCPPostHandler, createMCPRoutes, createMCPSession, createReadableStream, createStdioClientTransport, createStdioServer, createWebSocketClientTransport, createWebSocketServer, decodeEvent, dispatchLines, extractLines, inferHeaderIssue, inferLegacyVersion, inferStatus, readEventStream, readLastEventId, readSessionHeader, rejectUnknownSession, sendEventStream, upgradeRequestPath };
2140
+ export { DEFAULT_MCP_DELIVERY, DEFAULT_MCP_KEEPALIVE_INTERVAL, DEFAULT_MCP_PATH, DEFAULT_MCP_SESSION_CAPACITY, DEFAULT_MCP_SESSION_TTL, HTTPClientTransport, HTTPDisconnect, MCPSession, MCP_METHOD_HEADER, MCP_NAME_HEADER, MCP_PROTOCOL_VERSION_HEADER, MCP_SESSION_HEADER, MCP_WEBSOCKET_SUBPROTOCOL, SSE_BUFFERING_DISABLED, SSE_BUFFERING_HEADER, SSE_KEEPALIVE_COMMENT, StdioClientTransport, StdioServerTransport, WebSocketClientTransport, WebSocketServerTransport, acceptsEventStream, allowsOrigin, bridgeMessageTransport, createHTTPClientTransport, createMCPContinuation, createMCPPostHandler, createMCPRoutes, createMCPSession, createReadableStream, createStdioClientTransport, createStdioServer, createWebSocketClientTransport, createWebSocketServer, decodeEvent, dispatchLines, extractLines, inferHeaderIssue, inferLegacyVersion, inferStatus, readEventStream, readLastEventId, readSessionHeader, rejectUnknownSession, sendEventStream, upgradeRequestPath };
2110
2141
 
2111
2142
  //# sourceMappingURL=index.js.map