(passedObject = {})
| 63 | } |
| 64 | |
| 65 | function pauseSession(passedObject = {}) { |
| 66 | registeredVariables = passedObject |
| 67 | recorder.session.start('pause') |
| 68 | pauseSessionOpen = true |
| 69 | |
| 70 | if (externalHandler) { |
| 71 | store.onPause = true |
| 72 | return externalHandler({ registeredVariables }).then(() => { |
| 73 | store.onPause = false |
| 74 | recorder.session.restore('pause') |
| 75 | pauseSessionOpen = false |
| 76 | }) |
| 77 | } |
| 78 | |
| 79 | if (!next) { |
| 80 | let vars = Object.keys(registeredVariables).join(', ') |
| 81 | if (vars) vars = `(vars: ${vars})` |
| 82 | |
| 83 | output.print(colors.yellow(' Interactive shell started')) |
| 84 | output.print(colors.yellow(' Use JavaScript syntax to try steps in action')) |
| 85 | output.print(colors.yellow(` - Press ${colors.bold('ENTER')} to run the next step`)) |
| 86 | output.print(colors.yellow(` - Press ${colors.bold('TAB')} twice to see all available commands`)) |
| 87 | output.print(colors.yellow(` - Type ${colors.bold('exit')} + Enter to exit the interactive shell`)) |
| 88 | output.print(colors.yellow(` - Prefix ${colors.bold('=>')} to run js commands ${colors.bold(vars)}`)) |
| 89 | |
| 90 | if (aiAssistant.isEnabled) { |
| 91 | output.print(colors.blue(` ${colors.bold('AI is enabled! (experimental)')} Write what you want and make AI run it`)) |
| 92 | output.print(colors.blue(' Please note, only HTML fragments with interactive elements are sent to AI provider')) |
| 93 | output.print(colors.blue(' Ideas: ask it to fill forms for you or to click')) |
| 94 | } |
| 95 | } |
| 96 | |
| 97 | rl = readline.createInterface({ |
| 98 | input: process.stdin, |
| 99 | output: process.stdout, |
| 100 | terminal: true, |
| 101 | completer, |
| 102 | history: history.load(), |
| 103 | historySize: 50, // Adjust the history size as needed |
| 104 | }) |
| 105 | |
| 106 | store.onPause = true |
| 107 | rl.on('line', parseInput) |
| 108 | rl.on('close', () => { |
| 109 | if (!next) console.log('Exiting interactive shell....') |
| 110 | store.onPause = false |
| 111 | }) |
| 112 | return new Promise(resolve => { |
| 113 | finish = resolve |
| 114 | return askForStep() |
| 115 | }) |
| 116 | } |
| 117 | |
| 118 | async function parseInput(cmd) { |
| 119 | rl.pause() |
no test coverage detected