Threads AI

importThread / import_thread

Stores a bundle written by thread.export, or a bare .jsonl export, and returns a handle on its leaf branch.

Everything is validated before anything is written: the log, every recorded model request, each bundled file against the manifest's hash and length, and the destination's thread tombstones, so a thread deleted here is never brought back. A failure there leaves the store exactly unchanged. Then the artifacts are stored, and all the rows in one transaction, so the rows are all or nothing; a crash in between can leave artifact files no row names, which are harmless (content-addressed, never read without a ref) and reused by a retry. A bare .jsonl needs its artifacts already in the store.

Import from @threads/core (TypeScript) or threads (Python).

function importThread(store: Store, path: string): Promise<Result<Thread>>

Parameters

storeStorerequired

The store to import into. See Store.

pathstringrequired

A bundle directory, or a bare .jsonl export.

Returns

Thread

Returns an error value with one of these codes: bundle_incomplete, invalid_line, prev_hash_mismatch, seq_mismatch, seq_conflict, invalid_transition, unsupported_format, unsupported_critical_event, log_corrupt, artifact_missing, artifact_corrupt, branch_exists, branch_not_found, schedule_conflict, secret_in_stored_bytes, io_error.

Edit on GitHub

On this page