# Dart SDK

Using SurrealDB Agent Memory from Dart and Flutter applications.

The SurrealDB Agent Memory client ships in the [`surrealdb`](https://github.com/surrealdb/surrealdb.dart) package on pub, as a standalone import that does not depend on the database driver. It works in any Dart project and on every Flutter target (Android, iOS, web, and desktop).

> [!NOTE]
> `Spectron` was the project name for SurrealDB Agent Memory. These type names
> will be renamed in a future release.

## Installation

Add the package to `pubspec.yaml`:

```yaml
dependencies:
  surrealdb:
```

```bash
dart pub get
# or, in a Flutter project
flutter pub get
```

## Client construction

Import the SurrealDB Agent Memory entry point directly. The client is pinned to one context and talks to SurrealDB Agent Memory's REST API over HTTPS:

```dart
import 'package:surrealdb/spectron.dart';

final client = Spectron(
  endpoint: 'https://api.spectron.example',
  context: 'acme-prod',
  apiKey: 'sp-your-key',
);
```

Importing `package:surrealdb/spectron.dart` pulls in only the SurrealDB Agent Memory client, not the SurrealDB database driver.

## Remember, recall, and chat

```dart
await client.remember('I was promoted to CTO', scopes: 'user/tobie');

final hits = await client.recall("What is Tobie's role?", k: 10);

await for (final chunk in client.chatStream('Tell me a story')) {
  stdout.write(chunk.delta);
}

client.close();
```

`scopes` accepts a slash-path string or a list of paths. Register paths with `spectron scopes create` before first use.

The client covers the rest of the SurrealDB Agent Memory end-user surface (documents, sessions, entities, and governance) over the same REST API. See the [REST API](/docs/agent-memory/integrations/surfaces/rest.md) for the full contract.
