### Install tuistory with Bun Source: https://github.com/remorses/tuistory/blob/main/README.md This snippet shows how to add the tuistory package to your project using the Bun package manager. This is the primary method for installing the library. ```bash bun add tuistory ``` -------------------------------- ### Complete Test Example Source: https://context7.com/remorses/tuistory/llms.txt Demonstrates a full end-to-end test scenario for an interactive bash session, showcasing the typical testing workflow with Tuistory. ```APIDOC ## Complete Test Example ### Description A comprehensive example demonstrating a full end-to-end test scenario for an interactive bash session, showcasing the typical testing workflow. ### Example 1: Interactive Bash Session ```typescript import { launchTerminal } from 'tuistory' import { expect, test } from 'vitest' test('interactive bash session', async () => { const session = await launchTerminal({ command: 'bash', args: ['--norc', '--noprofile'], cols: 60, rows: 10, env: { PS1: '$ ', HOME: '/tmp', PATH: process.env.PATH }, }) // Type and execute a command await session.type('echo "testing tuistory"') await session.press('enter') // Assert on terminal output const text = await session.text() expect(text).toMatchInlineSnapshot(` "\n $ echo \"testing tuistory\"\n testing tuistory\n $" `) // Use waitForText for reliable assertions await session.type('echo "hello world"') await session.press('enter') const output = await session.waitForText('hello world') expect(output).toContain('hello world') // Clean exit await session.type('exit') await session.press('enter') session.close() }, 10000) ``` ### Example 2: TUI Application with Keyboard Navigation ```typescript import { launchTerminal } from 'tuistory' test('TUI application with keyboard navigation', async () => { const session = await launchTerminal({ command: 'my-tui-app', args: [], cols: 100, rows: 30, }) // Wait for app to be ready await session.waitForText('Welcome', { timeout: 15000 }) // Navigate with keyboard await session.press('down') await session.press('down') await session.press('enter') // Open command palette await session.press(['ctrl', 'p']) const menuText = await session.waitForText('Commands', { timeout: 5000 }) expect(menuText).toContain('Commands') // Close menu await session.press('esc') // Interrupt and exit await session.press(['ctrl', 'c']) session.close() }, 30000) ``` ``` -------------------------------- ### End-to-End Test: Interactive Bash Session with Tuistory Source: https://context7.com/remorses/tuistory/llms.txt A comprehensive example demonstrating a full end-to-end test scenario for an interactive bash session using Tuistory and Vitest. Shows typing commands, asserting output, and using `waitForText` for reliable assertions. ```typescript import { launchTerminal } from 'tuistory' import { expect, test } from 'vitest' test('interactive bash session', async () => { const session = await launchTerminal({ command: 'bash', args: ['--norc', '--noprofile'], cols: 60, rows: 10, env: { PS1: '$ ', HOME: '/tmp', PATH: process.env.PATH }, }) // Type and execute a command await session.type('echo "testing tuistory"') await session.press('enter') // Assert on terminal output const text = await session.text() expect(text).toMatchInlineSnapshot(` "\n $ echo \"testing tuistory\" testing tuistory $" `) // Use waitForText for reliable assertions await session.type('echo "hello world"') await session.press('enter') const output = await session.waitForText('hello world') expect(output).toContain('hello world') // Clean exit await session.type('exit') await session.press('enter') session.close() }, 10000) ``` -------------------------------- ### API: Get Terminal Text Content (TypeScript) Source: https://github.com/remorses/tuistory/blob/main/README.md Explains how to retrieve the current text content of the terminal session using the `text` method. It also shows how to filter the retrieved text based on styling attributes like bold or color. ```typescript const text = await session.text() // Filter by style const boldText = await session.text({ only: { bold: true } }) const coloredText = await session.text({ only: { foreground: '#ff0000' } }) ``` -------------------------------- ### Launch Terminal API Source: https://context7.com/remorses/tuistory/llms.txt Launches a new terminal session with the specified command and configuration options. Returns a `Session` object that provides methods to interact with and assert on the terminal. The session automatically waits for initial data from the PTY unless `waitForData: false` is specified. ```APIDOC ## POST /launchTerminal ### Description Launches a new terminal session with the specified command and configuration options. Returns a `Session` object that provides methods to interact with and assert on the terminal. ### Method POST ### Endpoint /launchTerminal ### Parameters #### Request Body - **command** (string) - Required - The command to execute in the terminal. - **args** (string[]) - Optional - Arguments for the command. - **cols** (number) - Optional - Number of columns for the terminal. - **rows** (number) - Optional - Number of rows for the terminal. - **cwd** (string) - Optional - Working directory for the terminal. - **env** (object) - Optional - Environment variables for the terminal session. - **waitForData** (boolean) - Optional - Whether to wait for initial PTY data (default: true). - **waitForDataTimeout** (number) - Optional - Timeout in milliseconds for waiting for initial data (default: 5000). ### Request Example ```json { "command": "my-cli", "args": ["--interactive"], "cols": 80, "rows": 24 } ``` ### Response #### Success Response (200) - **session** (object) - The Session object for interacting with the terminal. #### Response Example ```json { "session": { /* Session object details */ } } ``` ``` -------------------------------- ### End-to-End Test: TUI App Navigation with Tuistory Source: https://context7.com/remorses/tuistory/llms.txt Demonstrates testing a TUI application's keyboard navigation using Tuistory. Includes waiting for the app to be ready, navigating with key presses, interacting with menus, and handling interruptions. Uses Vitest for assertions. ```typescript import { launchTerminal } from 'tuistory' import { expect, test } from 'vitest' test('TUI application with keyboard navigation', async () => { const session = await launchTerminal({ command: 'my-tui-app', args: [], cols: 100, rows: 30, }) // Wait for app to be ready await session.waitForText('Welcome', { timeout: 15000 }) // Navigate with keyboard await session.press('down') await session.press('down') await session.press('enter') // Open command palette await session.press(['ctrl', 'p']) const menuText = await session.waitForText('Commands', { timeout: 5000 }) expect(menuText).toContain('Commands') // Close menu await session.press('esc') // Interrupt and exit await session.press(['ctrl', 'c']) session.close() }, 30000) ``` -------------------------------- ### Launch and Interact with a Terminal Session (TypeScript) Source: https://github.com/remorses/tuistory/blob/main/README.md Demonstrates launching a terminal session with a specified command and arguments, then interacting with it by typing commands, pressing keys, and asserting the output. It includes waiting for specific text and closing the session. ```typescript import { launchTerminal } from 'tuistory' const session = await launchTerminal({ command: 'claude', args: [], cols: 100, rows: 30, }) await session.waitForText('claude', { timeout: 10000 }) const initialText = await session.text() expect(initialText).toMatchInlineSnapshot(` "\n ╭──────────────────────────────────────────────────────────────────────────────────────────────────╮\n │ Welcome to Claude Code │\n ╰──────────────────────────────────────────────────────────────────────────────────────────────────╯\n " `) await session.type('/help') await session.press('enter') const helpText = await session.text() expect(helpText).toMatchInlineSnapshot(` "\n ▐▛███▜▌ Claude Code v2.0.53\n ▝▜█████▛▘ Opus 4.5 · Claude Max\n ▘▘ ▝▝ ~/my-project\n\n ────────────────────────────────────────────────────────────────────────────────────────────────────\n > Try \"create a util logging.py that...\"\n ────────────────────────────────────────────────────────────────────────────────────────────────────\n " `) await session.press(['ctrl', 'c']) session.close() ``` -------------------------------- ### Resize Terminal with session.resize() Source: https://context7.com/remorses/tuistory/llms.txt Dynamically resizes the terminal dimensions. Useful for testing responsive TUI layouts or applications that handle terminal resize events. Dependencies: 'tuistory'. ```typescript import { launchTerminal } from 'tuistory' const session = await launchTerminal({ command: 'my-tui-app', args: [], cols: 80, rows: 24, }) // Get initial layout const initialText = await session.text() // Resize to a larger terminal session.resize({ cols: 120, rows: 40 }) const largerText = await session.text() // Resize to a smaller terminal session.resize({ cols: 40, rows: 12 }) const smallerText = await session.text() session.close() ``` -------------------------------- ### API: Launch Terminal Session Configuration (TypeScript) Source: https://github.com/remorses/tuistory/blob/main/README.md Illustrates the various options available when launching a terminal session using `launchTerminal`. This includes setting the command, arguments, terminal dimensions, working directory, and environment variables. ```typescript const session = await launchTerminal({ command: 'my-cli', args: ['--flag'], cols: 80, rows: 24, cwd: '/path/to/dir', env: { MY_VAR: 'value' }, }) ``` -------------------------------- ### Wait for Text or Regex with session.waitForText() Source: https://context7.com/remorses/tuistory/llms.txt Waits for specific text or a regex pattern to appear in the terminal. Returns the terminal content when the pattern is found or throws an error on timeout. Dependencies: 'tuistory'. ```typescript import { launchTerminal } from 'tuistory' import { expect } from 'vitest' const session = await launchTerminal({ command: 'bash', args: ['--norc', '--noprofile'], cols: 60, rows: 10, env: { PS1: '$ ' }, }) // Wait for exact string await session.type('echo "hello world"') await session.press('enter') const text = await session.waitForText('hello world') expect(text).toContain('hello world') // Wait for regex pattern await session.type('echo "number 42"') await session.press('enter') const numberText = await session.waitForText(/number \d+/) expect(numberText).toMatch(/number \d+/) // Wait with custom timeout await session.type('sleep 3 && echo "done"') await session.press('enter') const doneText = await session.waitForText('done', { timeout: 10000 }) // Wait for application startup const session2 = await launchTerminal({ command: 'my-tui-app', args: [], cols: 100, rows: 30, }) await session2.waitForText('Welcome', { timeout: 15000 }) session.close() session2.close() ``` -------------------------------- ### Simulate Key Presses in Terminal with tuistory Source: https://context7.com/remorses/tuistory/llms.txt Simulates pressing single keys or key combinations (chords) in a terminal session using the `session.press` method from `tuistory`. This method supports special keys, modifiers (Ctrl, Alt, Shift, Meta), letters, digits, and punctuation, allowing for comprehensive interaction simulation. ```typescript import { launchTerminal } from 'tuistory' const session = await launchTerminal({ command: 'vim', args: ['test.txt'], cols: 80, rows: 24, }) // Single key presses await session.press('enter') // Enter/Return await session.press('esc') // Escape await session.press('tab') // Tab await session.press('space') // Space await session.press('backspace') // Backspace await session.press('delete') // Delete await session.press('up') // Arrow up await session.press('down') // Arrow down await session.press('left') // Arrow left await session.press('right') // Arrow right await session.press('home') // Home await session.press('end') // End await session.press('pageup') // Page Up await session.press('pagedown') // Page Down await session.press('f1') // Function keys f1-f12 // Key combinations with modifiers (ctrl, alt, shift, meta) await session.press(['ctrl', 'c']) // Ctrl+C (interrupt) await session.press(['ctrl', 's']) // Ctrl+S (save) await session.press(['ctrl', 'shift', 'p']) // Ctrl+Shift+P await session.press(['alt', 'f']) // Alt+F await session.press(['ctrl', 'x']) // Ctrl+X // Letters and digits await session.press('a') await session.press('5') session.close() ``` -------------------------------- ### Session Press API Source: https://context7.com/remorses/tuistory/llms.txt Presses a single key or a key combination (chord) in the terminal. Supports special keys, modifiers, letters, digits, and punctuation. ```APIDOC ## POST /session/:id/press ### Description Presses a single key or a key combination (chord) in the terminal. Supports special keys, modifiers, letters, digits, and punctuation. ### Method POST ### Endpoint /session/:id/press ### Parameters #### Path Parameters - **id** (string) - Required - The ID of the session to interact with. #### Request Body - **key** (string | string[]) - Required - The key or key combination to press. For key chords, pass an array with modifier keys and the main key (e.g., `['ctrl', 'c']`). ### Request Example ```json { "key": "enter" } ``` ```json { "key": ["ctrl", "s"] } ``` ### Response #### Success Response (200) - **success** (boolean) - Indicates if the operation was successful. #### Response Example ```json { "success": true } ``` ``` -------------------------------- ### Launch Terminal Session with tuistory Source: https://context7.com/remorses/tuistory/llms.txt Launches a new terminal session using the `launchTerminal` function from `tuistory`. This function takes command and configuration options, returning a `Session` object for interaction. It supports basic and advanced configurations including environment variables, working directory, and timeouts for initial data waiting. ```typescript import { launchTerminal } from 'tuistory' // Basic usage - launch a CLI application const session = await launchTerminal({ command: 'my-cli', args: ['--interactive'], cols: 80, rows: 24, }) // Advanced usage with environment and working directory const session = await launchTerminal({ command: 'bash', args: ['--norc', '--noprofile'], cols: 100, rows: 30, cwd: '/path/to/project', env: { PS1: '$ ', HOME: '/tmp', MY_CONFIG: 'test-value' }, waitForData: true, // Wait for initial PTY data (default: true) waitForDataTimeout: 5000, // Timeout for initial data wait (default: 5000ms) }) // Don't forget to close the session when done session.close() ``` -------------------------------- ### session.waitForData / session.waitIdle Source: https://context7.com/remorses/tuistory/llms.txt Provides low-level control for timing and synchronization within a terminal session. `waitForData` waits for incoming data, while `waitIdle` waits for a period of inactivity. ```APIDOC ## session.waitForData / session.waitIdle ### Description Low-level methods for controlling timing and synchronization. `waitForData` waits for any data from the PTY, while `waitIdle` waits for the terminal to become idle (no data for a period). ### Method `session.waitForData(options?: WaitForDataOptions)` `session.waitIdle(options?: WaitIdleOptions)` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters - `options` (object): Optional configuration for waiting. - `timeout` (number): The maximum time in milliseconds to wait. Defaults to Infinity. ### Request Example ```typescript // Manually wait for data with custom timeout await session.waitForData({ timeout: 3000 }); // Wait for terminal to become idle await session.waitIdle({ timeout: 500 }); // writeRaw and sendKey for non-blocking operations session.writeRaw('hello'); // Write without waiting session.sendKey('enter'); // Send key without waiting await session.waitIdle(); // Then wait for idle ``` ### Response #### Success Response (200) These methods do not return a value upon success, but indicate that the condition has been met. #### Response Example None ``` -------------------------------- ### Click on Text with session.click() Source: https://context7.com/remorses/tuistory/llms.txt Clicks on text matching a pattern in the terminal using mouse events. Useful for TUI applications that support mouse interaction. Throws an error if multiple matches are found (use `first: true` to click the first match). Dependencies: 'tuistory'. ```typescript import { launchTerminal } from 'tuistory' const session = await launchTerminal({ command: 'my-tui-app', args: [], cols: 100, rows: 30, }) // Click on unique text await session.waitForText('Submit') await session.click('Submit') // Click with regex pattern await session.click(/Button \d+/) // Click first match when multiple exist await session.waitForText('Option') await session.click('Option', { first: true }) // Click with timeout await session.click('Save', { timeout: 5000 }) // Click at specific coordinates await session.clickAt(10, 5) // x=10, y=5 (0-indexed) session.close() ``` -------------------------------- ### session.captureFrames Source: https://context7.com/remorses/tuistory/llms.txt Captures multiple terminal frames rapidly after sending input. This is useful for analyzing TUI application behavior, such as layout shifts or animations. ```APIDOC ## session.captureFrames ### Description Captures multiple terminal frames rapidly after sending input. Useful for detecting layout shifts, animations, or transitions in TUI applications. ### Method `session.captureFrames(key?: string | string[], options?: CaptureOptions)` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters - `key` (string | string[]): The key or key combination to press to trigger frame capture. Defaults to 'enter'. - `options` (object): Optional configuration for frame capture. - `frameCount` (number): The number of frames to capture. Defaults to 1. - `intervalMs` (number): The time in milliseconds between captures. Defaults to 0. ### Request Example ```typescript // Capture 5 frames after pressing enter (default) const frames = await session.captureFrames('enter'); // Capture with custom settings const detailedFrames = await session.captureFrames(['ctrl', 'n'], { frameCount: 10, intervalMs: 20, }); ``` ### Response #### Success Response (200) - `frames` (string[]): An array of captured terminal frames as strings. #### Response Example ```json { "frames": [ "Frame 1 content...", "Frame 2 content..." ] } ``` ``` -------------------------------- ### Simulate Typing in Terminal with tuistory Source: https://context7.com/remorses/tuistory/llms.txt Simulates typing input into a terminal session using the `session.type` method provided by `tuistory`. This method types characters with a delay and waits for the terminal to become idle. It is useful for entering commands and multi-line inputs. ```typescript import { launchTerminal } from 'tuistory' const session = await launchTerminal({ command: 'bash', args: ['--norc', '--noprofile'], cols: 60, rows: 10, env: { PS1: '$ ' }, }) // Type a command await session.type('echo "hello world"') await session.press('enter') // Type multi-line input await session.type('cat << EOF') await session.press('enter') await session.type('line 1') await session.press('enter') await session.type('line 2') await session.press('enter') await session.type('EOF') await session.press('enter') session.close() ``` -------------------------------- ### Control Terminal Timing and Synchronization with Tuistory Source: https://context7.com/remorses/tuistory/llms.txt Provides low-level methods for controlling terminal timing. `waitForData` waits for PTY data, and `waitIdle` waits for the terminal to be idle. Useful for manual timing control. Requires the 'tuistory' library. ```typescript import { launchTerminal } from 'tuistory' // Using waitForData: false to manually control timing const session = await launchTerminal({ command: 'cat', args: [], cols: 40, rows: 10, waitForData: false, // Don't wait for initial data }) // Manually wait for data with custom timeout await session.waitForData({ timeout: 3000 }) // Wait for terminal to become idle await session.waitIdle({ timeout: 500 }) // writeRaw and sendKey for non-blocking operations session.writeRaw('hello') // Write without waiting session.sendKey('enter') // Send key without waiting await session.waitIdle() // Then wait for idle session.close() ``` -------------------------------- ### Scroll Terminal with session.scrollUp() / session.scrollDown() Source: https://context7.com/remorses/tuistory/llms.txt Scrolls the terminal content using mouse wheel events. Useful for testing TUI applications with scrollable content like lists, logs, or text viewers. Dependencies: 'tuistory'. ```typescript import { launchTerminal } from 'tuistory' const session = await launchTerminal({ command: 'less', args: ['large-file.txt'], cols: 80, rows: 24, }) // Scroll down by 1 line (default) await session.scrollDown() // Scroll down by multiple lines await session.scrollDown(5) // Scroll up by 1 line await session.scrollUp() // Scroll up by multiple lines await session.scrollUp(3) // Scroll at specific coordinates (x, y) await session.scrollDown(1, 40, 12) // Scroll at center of terminal await session.scrollUp(2, 10, 5) // Scroll at position (10, 5) session.close() ``` -------------------------------- ### Capture Terminal Frames with Tuistory Source: https://context7.com/remorses/tuistory/llms.txt Captures multiple terminal frames rapidly after a key press. Useful for detecting layout shifts or animations. Supports custom frame counts and intervals. Requires the 'tuistory' library. ```typescript import { launchTerminal } from 'tuistory' const session = await launchTerminal({ command: 'my-animated-tui', args: [], cols: 80, rows: 24, }) // Capture 5 frames after pressing enter (default) const frames = await session.captureFrames('enter') console.log(`Captured ${frames.length} frames`) // Capture with custom settings const detailedFrames = await session.captureFrames(['ctrl', 'n'], { frameCount: 10, // Number of frames to capture intervalMs: 20, // Milliseconds between captures }) // Analyze frames for layout shifts for (let i = 0; i < detailedFrames.length; i++) { console.log(`Frame ${i}:`, detailedFrames[i].substring(0, 100)) } session.close() ``` -------------------------------- ### API: Press Keys in Terminal (TypeScript) Source: https://github.com/remorses/tuistory/blob/main/README.md Demonstrates pressing single keys or key chords (combinations like Ctrl+C) within the terminal session using the `press` method. It lists available keys and modifiers. ```typescript await session.press('enter') await session.press('tab') await session.press(['ctrl', 'c']) await session.press(['ctrl', 'shift', 'a']) ``` -------------------------------- ### API: Click Text Pattern in Terminal (TypeScript) Source: https://github.com/remorses/tuistory/blob/main/README.md Shows how to simulate a click action on text that matches a given pattern or regular expression within the terminal using the `click` method. This can be used to interact with clickable elements. ```typescript await session.click('Submit') await session.click(/Button \d+/, { first: true }) ``` -------------------------------- ### Session Type API Source: https://context7.com/remorses/tuistory/llms.txt Types a string character by character into the terminal with a small delay between keystrokes to simulate realistic human typing. This method waits for the terminal to become idle after typing completes. ```APIDOC ## POST /session/:id/type ### Description Types a string character by character into the terminal with a small delay between keystrokes. Waits for the terminal to become idle after typing completes. ### Method POST ### Endpoint /session/:id/type ### Parameters #### Path Parameters - **id** (string) - Required - The ID of the session to interact with. #### Request Body - **text** (string) - Required - The string to type into the terminal. ### Request Example ```json { "text": "echo \"hello world\"" } ``` ### Response #### Success Response (200) - **success** (boolean) - Indicates if the operation was successful. #### Response Example ```json { "success": true } ``` ``` -------------------------------- ### API: Type Text into Terminal (TypeScript) Source: https://github.com/remorses/tuistory/blob/main/README.md Shows how to simulate typing text into the active terminal session character by character using the `type` method. This is useful for inputting commands or data. ```typescript await session.type('hello world') ``` -------------------------------- ### Retrieve Terminal Text with session.text() Source: https://context7.com/remorses/tuistory/llms.txt Retrieves the current terminal text content. Supports filtering by text styles (bold, italic, underline, colors) and various timing options. Returns the terminal content as a string with a leading newline. Dependencies: 'tuistory'. ```typescript import { launchTerminal } from 'tuistory' import { expect } from 'vitest' const session = await launchTerminal({ command: 'echo', args: ['hello world'], cols: 40, rows: 10, }) // Basic text retrieval const text = await session.text() expect(text).toContain('hello world') // With timeout for waiting on content const textWithTimeout = await session.text({ timeout: 5000 }) // Filter by text style - get only bold text const boldText = await session.text({ only: { bold: true } }) // Filter by color - get text with specific foreground color const redText = await session.text({ only: { foreground: '#ff0000' } }) // Filter by multiple style attributes const styledText = await session.text({ only: { bold: true, italic: false, underline: true, foreground: '#00ff00', background: '#000000' } }) // Custom wait condition const textWhen = await session.text({ timeout: 3000, waitFor: (text) => text.includes('Ready') || text.includes('Done') }) // Trim trailing whitespace and empty lines const trimmedText = await session.text({ trimEnd: true }) // Get text immediately without waiting for idle (for capturing intermediate frames) const immediateText = await session.text({ immediate: true }) session.close() ``` -------------------------------- ### session.close Source: https://context7.com/remorses/tuistory/llms.txt Closes the terminal session, ensuring that the associated PTY process is terminated and all resources are properly released. ```APIDOC ## session.close ### Description Closes the terminal session, killing the PTY process and cleaning up resources. Always call this method when done with a session to prevent resource leaks. ### Method `session.close()` ### Parameters None ### Request Example ```typescript try { // ... perform operations on the session } finally { session.close(); } ``` ### Response #### Success Response (200) This method does not return a value. ``` -------------------------------- ### API: Wait for Specific Text in Terminal (TypeScript) Source: https://github.com/remorses/tuistory/blob/main/README.md Illustrates using the `waitForText` method to pause execution until a specific text pattern or regular expression appears in the terminal output. It also allows setting a timeout for the wait. ```typescript await session.waitForText('Ready') await session.waitForText(/Loading\.\.\./, { timeout: 10000 }) ``` -------------------------------- ### Session Close API Source: https://context7.com/remorses/tuistory/llms.txt Closes the terminal session. ```APIDOC ## POST /session/:id/close ### Description Closes the terminal session. ### Method POST ### Endpoint /session/:id/close ### Parameters #### Path Parameters - **id** (string) - Required - The ID of the session to close. ### Response #### Success Response (200) - **success** (boolean) - Indicates if the operation was successful. #### Response Example ```json { "success": true } ``` ``` -------------------------------- ### API: Close Terminal Session (TypeScript) Source: https://github.com/remorses/tuistory/blob/main/README.md Demonstrates the simple `close` method to terminate the active terminal session. This should be called when the testing is complete to clean up resources. ```typescript session.close() ``` -------------------------------- ### Close Tuistory Terminal Session Source: https://context7.com/remorses/tuistory/llms.txt Closes the terminal session, killing the PTY process and cleaning up resources. Essential for preventing resource leaks. Always call this method when done with a session. Requires the 'tuistory' library. ```typescript import { launchTerminal } from 'tuistory' const session = await launchTerminal({ command: 'my-app', args: [], cols: 80, rows: 24, }) try { await session.waitForText('Ready') await session.type('hello') await session.press('enter') const result = await session.text() // ... assertions } finally { // Always close the session session.close() } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.