# IO Subsystem

The IO Subsystem is SRE's gateway to the outside world. It provides a set of unified, connector-based services for all input and output operations. This ensures that the core agent logic remains decoupled from the specific implementation details of any external data source or sink.

All services within the IO subsystem are accessed via the `SRE.IO` namespace.

## Core IO Services

### Storage

The Storage service provides a generic interface for block storage operations (reading, writing, and listing files). It is the primary way agents persist and retrieve data like documents, logs, and other artifacts.

- Interface: `IStorageConnector`
- Service Access: `ConnectorService.getStorageConnector()`
- Common Connectors: `LocalStorageConnector`, `S3StorageConnector`

### VectorDB

The VectorDB service provides an interface for storing and querying vector embeddings, which is essential for semantic search, RAG (Retrieval-Augmented Generation), and long-term memory for agents.

- Interface: `IVectorDBConnector`
- Service Access: `ConnectorService.getVectorDBConnector()`
- Common Connectors: `PineconeConnector`, `MilvusConnector`, `RAMVecConnector` (for in-memory operations)

### NKV (Named Key-Value)

The NKV service provides a simple interface for a namespaced key-value store, suitable for metadata, session information, or other non-hierarchical data.

- Interface: `INKVRequest`
- Service Access: `ConnectorService.getNKVConnector()`
- Common Connectors: `NKVRAM`, `NKVRedis`, `NKVLocalStorage`

#### Key Methods

- `get(namespace, key)`: Retrieve a value.
- `set(namespace, key, value)`: Store a value.
- `list(namespace)`: List all keys in a namespace.
- `delete(namespace, key)`: Remove a key.

### CLI (Command Line Interface)

The CLI service parses and manages command-line arguments passed to the SRE process. It provides a standard way to access runtime flags and parameters.

- Interface: `CLIConnector`
- Service Access: `ConnectorService.getCLIConnector()`
- Default Implementation: `CLIConnector`

#### Usage

    const cli = ConnectorService.getCLIConnector();
    const args = cli.get(['mode', 'port']);
    // args = { mode: 'dev', port: 3000 }

### Router

The Router service handles HTTP requests. Note: SRE typically does not handle HTTP requests directly (this is usually the role of the embedding application). This connector is primarily used to serve temporary files or expose internal endpoints when necessary.

- Interface: `RouterConnector`
- Service Access: `ConnectorService.getRouterConnector()`
- Common Connectors: `ExpressRouter`, `NullRouter`