1: <?php
2:
3: declare(strict_types=1);
4:
5: /**
6: * This file is part of the Nexus MCP SDK package.
7: *
8: * (c) 2026 John Paul E. Balandan, CPA <paulbalandan@gmail.com>
9: *
10: * For the full copyright and license information, please view
11: * the LICENSE file that was distributed with this source code.
12: */
13:
14: namespace Nexus\Mcp\Core\Transport;
15:
16: /**
17: * A transport whose peer runs as a process it owns, and which reports that the peer stopped serving
18: * without the shutdown having been requested.
19: */
20: interface SupervisableTransportInterface extends TransportInterface
21: {
22: /**
23: * Registers a listener invoked with the peer's exit code when the transport tears down without
24: * `close()` having been called, whether the peer exited on its own or stopped serving and was
25: * killed. Calling `close()` notifies nobody.
26: *
27: * The reporting instance is spent once this fires: a supervisor respawns by building a fresh
28: * transport, not by restarting this one. The exit code is null when the peer ended without
29: * reporting a status.
30: *
31: * @param \Closure(null|int): void $listener
32: */
33: public function onUnexpectedExit(\Closure $listener): SubscriptionInterface;
34: }
35: