# BashSession

**Kind:** Class

**Source:** [`atloria-monorepo/libs/agent-core/src/tools/bash-session.ts`](https://github.com/sherkety/atloria/blob/main/atloria-monorepo/libs/agent-core/src/tools/bash-session.ts#L48)

A persistent shell session that maintains cwd, env vars, and venv activation
across commands. Spawns a single bash process and sends commands via stdin,
reading output until a unique delimiter marker signals completion.

## Methods

| Method | Signature | Returns |
|---|---|---|
| `start` | `start()` | `Promise<void>` |
| `execute` | `execute(command: string, options: { timeout?: number })` | `Promise<BashResult>` |
| `getCwd` | `getCwd()` | `string` |
| `isDisposed` | `isDisposed()` | `boolean` |
| `isRunning` | `isRunning()` | `boolean` |
| `dispose` | `dispose()` | `void` |

## Where it refuses work

- `BashSession` stops the work with `Error` when `this.disposed` — “BashSession has been disposed”.
- `BashSession` stops the work with `Error` when `this.disposed || !this.process?.stdin || !this.process?.stdout` — “BashSession is not running. Call start() first or session was disposed.”.
- `BashSession` stops the work with an early return when `this.process`.
- `BashSession` stops the work with an early return when `settled`.
- `BashSession` stops the work with an early return when `this.disposed`.
- `BashSession` stops the work with an early return when `process.env.SHELL`.

## When something fails

- `BashSession` handles failure in 2 places: it discards it silently in all 2.
