sdk

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoArcInstance = errors.New("no arc instance configured for org")

ErrNoArcInstance is returned (wrapped) when the caller's organization has no Arc instance configured. Memtrace deployments are multi-tenant; an administrator must run `memtrace org add-arc <org_id>` before that organization can read or write memories. Use errors.Is to test.

if errors.Is(err, sdk.ErrNoArcInstance) {
    // surface a clearer message to the user
}

Functions

This section is empty.

Types

type APIError

type APIError struct {
	StatusCode int
	Message    string
}

APIError is the typed error returned by every Client method on a non-2xx response. It exposes the HTTP status code and the server's `error` message so callers can branch on either. APIError wraps ErrNoArcInstance when the server reports a missing Arc instance, so errors.Is(err, ErrNoArcInstance) works without the caller needing to know about APIError.

func (*APIError) Error

func (e *APIError) Error() string

func (*APIError) Unwrap

func (e *APIError) Unwrap() error

Unwrap reports ErrNoArcInstance for 503 responses whose body matches the server's "no arc instance" string, so callers can write errors.Is(err, ErrNoArcInstance).

type AddMemoryRequest

type AddMemoryRequest struct {
	AgentID    string                 `json:"agent_id"`
	SessionID  string                 `json:"session_id,omitempty"`
	MemoryType string                 `json:"memory_type"`
	EventType  string                 `json:"event_type"`
	Content    string                 `json:"content"`
	Metadata   map[string]interface{} `json:"metadata,omitempty"`
	Tags       []string               `json:"tags,omitempty"`
	DedupKey   string                 `json:"dedup_key,omitempty"`
	Importance float64                `json:"importance,omitempty"`
	ParentID   string                 `json:"parent_id,omitempty"`
}

AddMemoryRequest is the request body for adding a memory

type Agent

type Agent struct {
	ID           string                 `json:"id"`
	OrgID        string                 `json:"org_id"`
	Name         string                 `json:"name"`
	Description  string                 `json:"description,omitempty"`
	Config       map[string]interface{} `json:"config,omitempty"`
	CreatedAt    time.Time              `json:"created_at"`
	LastActiveAt *time.Time             `json:"last_active_at,omitempty"`
}

Agent represents a registered agent

type AgentStats

type AgentStats struct {
	AgentID        string         `json:"agent_id"`
	MemoryCount    int            `json:"memory_count"`
	Memories24h    int            `json:"memories_24h"`
	Errors24h      int            `json:"errors_24h"`
	SessionCount   int            `json:"session_count"`
	ActiveSessions int            `json:"active_sessions"`
	LastActiveAt   *time.Time     `json:"last_active_at,omitempty"`
	MemoryTypes    map[string]int `json:"memory_types"`
}

AgentStats represents memory statistics for an agent

type Client

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

Client is the memtrace Go SDK client

func New

func New(baseURL, apiKey string) *Client

New creates a new memtrace client

func (*Client) AddMemories

func (c *Client) AddMemories(ctx context.Context, memories []*AddMemoryRequest) ([]Memory, error)

AddMemories stores multiple memories in a batch

func (*Client) AddMemory

func (c *Client) AddMemory(ctx context.Context, req *AddMemoryRequest) (*Memory, error)

AddMemory stores a new memory

func (*Client) CloseSession

func (c *Client) CloseSession(ctx context.Context, id string) (*Session, error)

CloseSession closes a session

func (*Client) CreateSession

func (c *Client) CreateSession(ctx context.Context, req *CreateSessionRequest) (*Session, error)

CreateSession starts a new session

func (*Client) Decide

func (c *Client) Decide(ctx context.Context, agentID, decision, reasoning string) (*Memory, error)

Decide logs a decision with reasoning

func (*Client) GetAgent

func (c *Client) GetAgent(ctx context.Context, id string) (*Agent, error)

GetAgent returns an agent by ID

func (*Client) GetAgentStats

func (c *Client) GetAgentStats(ctx context.Context, id string) (*AgentStats, error)

GetAgentStats returns memory stats for an agent

func (*Client) GetSession

func (c *Client) GetSession(ctx context.Context, id string) (*Session, error)

GetSession returns a session by ID

func (*Client) GetSessionContext

func (c *Client) GetSessionContext(ctx context.Context, id string, opts *ContextOptions) (*SessionContext, error)

GetSessionContext returns LLM-formatted session context

func (*Client) ListMemories

func (c *Client) ListMemories(ctx context.Context, opts *ListOptions) (*MemoryList, error)

ListMemories lists memories with filters

func (*Client) Recall

func (c *Client) Recall(ctx context.Context, agentID string, since string) (*MemoryList, error)

Recall retrieves recent memories for an agent

func (*Client) RegisterAgent

func (c *Client) RegisterAgent(ctx context.Context, req *RegisterAgentRequest) (*Agent, error)

RegisterAgent registers a new agent

func (*Client) Remember

func (c *Client) Remember(ctx context.Context, agentID, content string) (*Memory, error)

Remember stores an episodic memory (quick add)

func (*Client) SearchMemories

func (c *Client) SearchMemories(ctx context.Context, query *SearchQuery) (*SearchResult, error)

SearchMemories searches memories with structured filters

type ContextOptions

type ContextOptions struct {
	MaxTokens    int      `json:"max_tokens,omitempty"`
	IncludeTypes []string `json:"include_types,omitempty"`
	Since        string   `json:"since,omitempty"`
}

ContextOptions controls how session context is formatted

type CreateSessionRequest

type CreateSessionRequest struct {
	AgentID  string                 `json:"agent_id"`
	Metadata map[string]interface{} `json:"metadata,omitempty"`
}

CreateSessionRequest is the request body for creating a session

type ListOptions

type ListOptions struct {
	AgentID    string `json:"agent_id,omitempty"`
	SessionID  string `json:"session_id,omitempty"`
	MemoryType string `json:"memory_type,omitempty"`
	EventType  string `json:"event_type,omitempty"`
	Tags       string `json:"tags,omitempty"`
	Since      string `json:"since,omitempty"`
	Until      string `json:"until,omitempty"`
	Limit      int    `json:"limit,omitempty"`
	Offset     int    `json:"offset,omitempty"`
	Order      string `json:"order,omitempty"`
}

ListOptions defines filters for listing memories

type Memory

type Memory struct {
	Time       time.Time              `json:"time"`
	OrgID      string                 `json:"org_id"`
	AgentID    string                 `json:"agent_id"`
	SessionID  string                 `json:"session_id,omitempty"`
	MemoryType string                 `json:"memory_type"`
	EventType  string                 `json:"event_type"`
	Content    string                 `json:"content"`
	Metadata   map[string]interface{} `json:"metadata,omitempty"`
	Tags       []string               `json:"tags,omitempty"`
	DedupKey   string                 `json:"dedup_key,omitempty"`
	Importance float64                `json:"importance,omitempty"`
	ParentID   string                 `json:"parent_id,omitempty"`
}

Memory represents a stored memory event

type MemoryList

type MemoryList struct {
	Memories []Memory `json:"memories"`
	Count    int      `json:"count"`
	HasMore  bool     `json:"has_more"`
}

MemoryList is the response for listing memories

type RegisterAgentRequest

type RegisterAgentRequest struct {
	Name        string                 `json:"name"`
	Description string                 `json:"description,omitempty"`
	Config      map[string]interface{} `json:"config,omitempty"`
}

RegisterAgentRequest is the request body for registering an agent

type SearchQuery

type SearchQuery struct {
	AgentID         string   `json:"agent_id,omitempty"`
	SessionID       string   `json:"session_id,omitempty"`
	MemoryTypes     []string `json:"memory_types,omitempty"`
	EventTypes      []string `json:"event_types,omitempty"`
	Tags            []string `json:"tags,omitempty"`
	ContentContains string   `json:"content_contains,omitempty"`
	Since           string   `json:"since,omitempty"`
	Until           string   `json:"until,omitempty"`
	MinImportance   float64  `json:"min_importance,omitempty"`
	Limit           int      `json:"limit,omitempty"`
	Order           string   `json:"order,omitempty"`
}

SearchQuery is the request body for searching memories

type SearchResult

type SearchResult struct {
	Results     []Memory `json:"results"`
	Count       int      `json:"count"`
	QueryTimeMS int64    `json:"query_time_ms"`
}

SearchResult is the response for searching memories

type Session

type Session struct {
	ID        string                 `json:"id"`
	OrgID     string                 `json:"org_id"`
	AgentID   string                 `json:"agent_id"`
	Status    string                 `json:"status"`
	Metadata  map[string]interface{} `json:"metadata,omitempty"`
	CreatedAt time.Time              `json:"created_at"`
	UpdatedAt time.Time              `json:"updated_at"`
	ClosedAt  *time.Time             `json:"closed_at,omitempty"`
}

Session represents a bounded context for agent work

type SessionContext

type SessionContext struct {
	SessionID   string `json:"session_id"`
	Context     string `json:"context"`
	MemoryCount int    `json:"memory_count"`
}

SessionContext is the LLM-ready context for a session

Jump to

Keyboard shortcuts

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