import { resolveCommand } from './registry.js';
import { BOTMUX_SHELL_HINTS } from './shared-hints.js';
import { delay } from '../../utils/timing.js';
export function createHermesAdapter(pathOverride) {
    // resolvedBin is lazy: setup constructs adapters only to read static
    // modelChoices and must not shell out (see resolveCommand); the binary path
    // is a spawn-time concern.
    const rawBin = pathOverride ?? 'hermes';
    let cachedBin;
    return {
        id: 'hermes',
        get resolvedBin() { return (cachedBin ??= resolveCommand(rawBin)); },
        buildArgs({ sessionId, resume, disableCliBypass }) {
            const args = [];
            if (resume)
                args.push('--resume', sessionId);
            if (!disableCliBypass)
                args.push('--yolo', '--accept-hooks');
            args.push('--pass-session-id');
            return args;
        },
        buildResumeCommand({ sessionId }) {
            return `hermes --resume ${sessionId}`;
        },
        async writeInput(pty, content) {
            if (pty.sendText && pty.sendSpecialKeys) {
                pty.sendText(content);
                await delay(200);
                pty.sendSpecialKeys('Enter');
            }
            else {
                pty.write(content);
                await delay(1000);
                pty.write('\r');
            }
        },
        completionPattern: undefined,
        readyPattern: undefined,
        systemHints: BOTMUX_SHELL_HINTS,
        altScreen: false,
    };
}
export const create = createHermesAdapter;
//# sourceMappingURL=hermes.js.map