"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.deriveInjector = deriveInjector;
exports.deriveTerminalRefGetter = deriveTerminalRefGetter;
exports.deriveBroadcast = deriveBroadcast;
const terminal_manager_1 = require("../terminal-manager");
const terminal_paste_1 = require("../terminal-paste");
const track_flow_ws_1 = require("../track-flow-ws");
// v3 工作轨 LLM 节点把 prompt 注入 CLI PTY。复用 chat 输入的 paste 路径
// （bracketed-paste + body/CR 200ms 拆分），绕开 Ink TUI 把 paste body + \r 折叠
// 成 `[Pasted text +N lines]` attachment。v1 任务流系统已在 v-h 删除。
function deriveInjector(projectId) {
    return (text) => {
        (0, terminal_paste_1.writeTerminalInputSplit)(projectId, (0, terminal_paste_1.buildPaste)(text));
    };
}
// v-h: dispatcher 用它检测 PTY crash —— 注入后 PTY 实例换了说明 terminal-manager
// 重启了 PTY，prompt 落空，立即 fail 不再傻等超时。
function deriveTerminalRefGetter(projectId) {
    return () => terminal_manager_1.terminalManager.getTerminalRef(projectId);
}
function deriveBroadcast(projectId) {
    return (event, payload) => {
        (0, track_flow_ws_1.broadcastFlowEvent)(projectId, event, payload);
    };
}
//# sourceMappingURL=_flow-injector.js.map