importer

package
v0.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 11, 2026 License: AGPL-3.0 Imports: 18 Imported by: 0

Documentation

Overview

Package importer bulk-loads memories exported from other memory systems (agentmemory, mem0, mnemory) or memini's own format. The local backend embeds content and writes to the store, preserving source IDs and timestamps; the remote backend POSTs to a running memini's REST API.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Sources

func Sources() []string

Sources lists the supported import sources, sorted.

Types

type Importer

type Importer struct {
	// contains filtered or unexported fields
}

Importer bulk-loads records via a configured backend.

func NewLocal

func NewLocal(st store.Store, e embed.Embedder) *Importer

NewLocal builds an Importer that embeds and writes directly to the store.

func NewRemote

func NewRemote(c *RemoteClient) *Importer

NewRemote builds an Importer that POSTs records to a remote memini server.

func (*Importer) Import

func (im *Importer) Import(ctx context.Context, recs []Record, opts Options) (Report, error)

Import writes records, skipping empty-content ones and continuing past per-record failures (collected in the Report).

type Options

type Options struct {
	// DefaultNamespace scopes records whose source carried no namespace.
	DefaultNamespace string
	// BatchSize bounds how many records are written per batch.
	BatchSize int
}

Options tune an import run.

type Record

type Record struct {
	ID         string
	Namespace  string
	Tier       memory.Tier
	Content    string
	Summary    string
	Tags       []string
	Metadata   map[string]any
	Importance float64
	CreatedAt  time.Time  // zero -> import time
	UpdatedAt  time.Time  // zero -> CreatedAt
	ExpiresAt  *time.Time // nil -> tier default measured from CreatedAt
}

Record is the portable, source-agnostic shape every adapter produces.

func LoadClaudeCode added in v0.0.4

func LoadClaudeCode(path string) (recs []Record, warns []string, err error)

LoadClaudeCode reads a single transcript .jsonl, or walks a directory (a project dir, or ~/.claude/projects) for *.jsonl files. Per-file parse errors become warnings rather than aborting the whole walk.

func Parse

func Parse(src Source, data []byte) ([]Record, error)

Parse converts a source export (raw JSON) into portable Records.

type RemoteClient

type RemoteClient struct {
	// contains filtered or unexported fields
}

RemoteClient writes records to a running memini via its REST API (POST /v1/memories).

func NewRemoteClient

func NewRemoteClient(baseURL, token, nsHeader string) *RemoteClient

NewRemoteClient targets a memini server at baseURL (e.g. https://memini.example.com), authenticating with token (optional) and scoping each record via nsHeader.

type Report

type Report struct {
	Total    int      `json:"total"`
	Imported int      `json:"imported"`
	Skipped  int      `json:"skipped"` // dropped before write (empty content)
	Errors   []string `json:"errors,omitempty"`
}

Report summarizes an import run.

type Source

type Source string

Source identifies the export format of the data being imported.

const (
	// SourceMemini is memini's own export shape (a JSON array of Records).
	SourceMemini Source = "memini"
	// SourceAgentMemory is rohitg00/agentmemory's export bundle.
	SourceAgentMemory Source = "agentmemory"
	// SourceMem0 is mem0ai/mem0's get_all / export output.
	SourceMem0 Source = "mem0"
	// SourceMnemory is fpytloun/mnemory's export output.
	SourceMnemory Source = "mnemory"
	// SourceClaudeCode is a Claude Code session transcript (JSONL), reconstructed
	// into per-exchange episodic memories.
	SourceClaudeCode Source = "claude-code"
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL