# TRAE

> Import Trae Agent, legacy IDE, TraeCode, and TraeWork histories and memories.

Hansard's `trae` source reads the open-source Trae Agent CLI's trajectories,
legacy IDE history, and TraeCode/TraeWork desktop history databases. Each
format retains its own source label.

## Source IDs

| Source | Use it for                                                     |
| ------ | -------------------------------------------------------------- |
| `trae` | Agent trajectories, legacy IDE stores, TraeCode, and TraeWork. |

## How the import works

Trae Agent records a task and its LLM interactions in one trajectory file.
Each agent step can repeat a response already stored in the interaction list.
Hansard matches those mirrors before counting model usage or tools, then
retains the original file for inspection. A new task written to the same
trajectory path has a new identity derived from its recorded start time.

Desktop applications keep messages and agent execution records in SQLite.
Hansard reads a coherent snapshot and copies an explicit set of history
tables into the archive. Credentials and unrelated application settings stay
outside those copies. Legacy IDE chat lists are read from allowlisted
workspace keys. Desktop model selections and context counters are retained
as metadata because they do not establish inference models or billed usage.

## Import and keep current

**Conversation history**

```sh
hansard import --source trae --since all
hansard config sources enable trae
```

Agent discovery looks for `trajectories/trajectory_*.json` under the current
directory and common project roots. `HANSARD_TRAE_AGENT_ROOTS` narrows that
search; `HANSARD_TRAE_AGENT_FILES` selects custom trajectory files directly.
Discovery is limited to five directory levels and 20,000 directories.

Desktop discovery checks the Trae, Trae CN, TRAE SOLO, and TRAE SOLO CN app
data directories. `HANSARD_TRAE_APP_ROOTS` overrides those directories;
`HANSARD_TRAE_DATABASES` selects database files directly. All path overrides
accept a path-separated list.

Current desktop databases use SQLCipher 4. Supply `TRAE_DB_KEY` and install
SQLCipher, or select an unlocked snapshot using `HANSARD_TRAE_DATABASES`.
`HANSARD_TRAE_SQLCIPHER` selects the SQLCipher executable. The importer sends
the key through standard input, opens the source read-only, and archives only
allowlisted history tables. It never archives the key or extracts one from a
running application. Snapshot input is limited to 512 MiB; projected history
is limited to 128 MiB and 100,000 rows.

**Memories and instructions**

```sh
hansard memory backup
```

Backup includes local rules, knowledge Markdown, and core database memories.
Database memories retain project scope when the project path is available and
remain read-only. Manage their content in TRAE. Skill folders are not memories
and are not backed up.

## Review the import in the app

1. When the import finishes, open **Conversations** and select **Filter & sort**.
2. Set **Source** to **TRAE** and set **Time** to the window you imported. Use **Folder** to narrow the list when you use this harness in several projects.
3. Select a conversation to check its messages, tool calls, files, commits, model, and token usage.

To keep archiving new sessions from a local harness, open **Settings → Imports**. **Automatic** follows every supported harness installed on this computer. **Custom** lets you turn individual harnesses on or off. Cloud sources and account exports never run from here; each needs its own import command. If a conversation you expect is missing after you reset the filters, run the import command on this page again with `--explain-skips` where the source supports it.

Review tool arguments, numbered string edits, child-session links, and memory
scopes. Agent request usage can be checked in Stats. Desktop token estimates
describe visible text when recorded inference counters are unavailable.

## What Hansard preserves

- Agent task prompts, responses, tool arguments and results, request models,
  available input/output/cache usage, and original trajectory files.
- Desktop messages, reasoning, tools, linked agent runs, and history tables.
- Legacy chat lists, explicit response models, and recorded tool details.
- Local rules, knowledge Markdown, and read-only database memories.

Agent steps can mirror LLM interactions; Hansard counts those responses once.
A new task written to the same trajectory file has a new archive identity.
Desktop model selections remain configuration metadata. Context-window token
counters do not become inference usage. Scheduled prompts and delegated runs
do not add human activity.

## Known limitations

Remote-only histories have no independent importer. Locally cached server
history and internal context records are preserved raw and reported as
unmapped records. Structured resurrection backups are not yet decoded.
Referenced images and snapshot files may lack original bytes. Legacy
messages without timestamps retain session order without invented timing.

Authenticated model calls, native desktop edits and delegation, and cloud
acceptance remain pending. Synthetic database and trajectory checks do not
establish those forms of provider acceptance.

## Refresh an existing archive

Re-run `hansard import --source trae --since all` after a parser update. The
import is idempotent and updates continued sessions in place. Supply the same
database access settings when importing an encrypted desktop store again.
