import type { IncomingMessage, ServerResponse } from 'node:http'; import type { Duplex } from 'node:stream'; export interface DebugTerminalManager { /** 处理 HTTP 请求;返回 true 表示已接管(调用方 return)。假定调用方已过 auth gate。 */ handleHttp: (req: IncomingMessage, res: ServerResponse, url: URL) => boolean; /** 处理 WS upgrade;返回 true 表示已接管。本模块内部自校验 token + 管理身份。 */ handleUpgrade: (req: IncomingMessage, socket: Duplex, head: Buffer) => boolean; /** 关掉所有终端(dashboard 退出时)。 */ shutdown: () => void; } export interface DebugTerminalDeps { /** 返回当前有效的管理 token,用于 WS upgrade 的 cookie 校验。 */ getActiveToken: () => string | null; /** * 本请求是否解析成 **legacy-dashboard 管理身份**——与 `/api/debug-terminal` 的 * HTTP 门禁(dashboard.ts 的 `legacyAuthed`)同一条口径。 * * 为什么只比 cookie 不够:中心化平台的隧道会**剥掉浏览器自己的 Cookie 头、注入本机 * 活跃 cookie** 来证明「我是这台机器的跳板」,真实用户权限另外放在 `X-Botmux-Role` * 里。所以「cookie == 活跃 token」只说明请求经过了平台隧道,**不说明发起人是本机 * owner**——平台上的 teammate / guest(甚至平台 owner 这种本不该有宿主 shell 的身份) * 都能满足它。而这条 WS 的另一头是可任意执行命令的裸 bash,必须与 HTTP 入口同档。 * 必填(不给默认值):漏接线会在类型层就报错,而不是静默 fail-open。 */ isLegacyManagementRequest: (req: IncomingMessage) => boolean; /** 默认工作目录候选(bot 配置的工作目录等);取第一个存在的,否则 homedir。 */ defaultWorkingDirs?: () => string[]; } export declare function createDebugTerminalManager(deps: DebugTerminalDeps): DebugTerminalManager; //# sourceMappingURL=debug-terminal.d.ts.map