MCPcopy
hub / github.com/garrytan/gstack / restartPtySession

Function restartPtySession

browse/src/server.ts:451–467  ·  view source on GitHub ↗

* Ask the terminal-agent to dispose the PtySession bound to `sessionId`. * Scoped to one caller's session — sibling tabs/agents untouched. Used by * /pty-restart and /pty-dispose. Returns true on agent ack.

(sessionId: string)

Source from the content-addressed store, hash-verified

449 * /pty-restart and /pty-dispose. Returns true on agent ack.
450 */
451async function restartPtySession(sessionId: string): Promise<boolean> {
452 const port = readTerminalPort();
453 const internal = readTerminalInternalToken();
454 if (!port || !internal) return false;
455 try {
456 const resp = await fetch(`http://127.0.0.1:${port}/internal/restart`, {
457 method: 'POST',
458 headers: {
459 'Content-Type': 'application/json',
460 'Authorization': `Bearer ${internal}`,
461 },
462 body: JSON.stringify({ sessionId }),
463 signal: AbortSignal.timeout(5000),
464 });
465 return resp.ok;
466 } catch { return false; }
467}
468
469/** Extract bearer token from request. Returns the token string or null. */
470function extractToken(req: Request): string | null {

Callers 1

makeFetchHandlerFunction · 0.85

Calls 3

readTerminalPortFunction · 0.85
fetchFunction · 0.70

Tested by

no test coverage detected