* 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)
| 449 | * /pty-restart and /pty-dispose. Returns true on agent ack. |
| 450 | */ |
| 451 | async 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. */ |
| 470 | function extractToken(req: Request): string | null { |
no test coverage detected