> ## Documentation Index
> Fetch the complete documentation index at: https://icrl.dev/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# TrajectoryDatabase

> TypeScript trajectory store with pluggable storage and semantic search

## Constructor

```ts theme={null}
new TrajectoryDatabase(
  storage: StorageAdapter,
  embedder: Embedder,
  options?: TrajectoryDatabaseOptions
)
```

`TrajectoryDatabaseOptions` includes:

* `maxEmbedChars` (default: 2000) — maximum characters for embedding text

## Load

```ts theme={null}
await db.load();
```

Load trajectories and index from storage. Must be called before other operations.

## Core Methods

```ts theme={null}
await db.add(trajectory);
db.get(id);
db.getAll();
await db.remove(id);
db.size;
```

## Search

```ts theme={null}
db.search(query, (k = 3));
db.searchSteps(query, (k = 3));
```

* `search` — trajectory-level retrieval by goal similarity
* `searchSteps` — step-level retrieval for in-context examples

## Retrieval Feedback

```ts theme={null}
await db.recordRetrieval(trajectoryId, ledToSuccess);
db.getCurationMetadata(trajectoryId);
```

## Storage Access

```ts theme={null}
db.getStorage();
db.getEmbedder();
```
