onledgemem

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2026 License: MIT Imports: 9 Imported by: 0

README

Nowledge Mem Go SDK

Go client library for the Nowledge Mem REST API.

Installation

go get github.com/lib-x/nowledgemem-go

Quick Start

package main

import (
    "context"
    "fmt"
    "log"

    mem "github.com/lib-x/nowledgemem-go"
)

func main() {
    // Create client (defaults to http://127.0.0.1:14242)
    client := mem.NewClient()

    // Or with custom base URL
    // client := mem.NewClient(mem.WithBaseURL("http://my-host:14242"))

    ctx := context.Background()

    // Health check
    health, err := client.Health.Check(ctx)
    if err != nil {
        log.Fatal(err)
    }
    fmt.Println("Status:", health.Status)

    // List memories
    resp, err := client.Memories.List(ctx, &mem.ListMemoriesParams{
        Limit: 10,
    })
    if err != nil {
        log.Fatal(err)
    }
    for _, m := range resp.Memories {
        fmt.Printf("- %s: %s\n", m.ID, m.Title)
    }

    // Create a memory
    created, err := client.Memories.Create(ctx, &mem.CreateMemoryRequest{
        Content: "This is a test memory",
        Title:   strPtr("Test"),
    })
    if err != nil {
        log.Fatal(err)
    }
    fmt.Println("Created:", created.Memory.ID)

    // Search memories
    results, err := client.Memories.Search(ctx, &mem.SearchMemoriesRequest{
        Query: "test",
        Limit: 5,
    })
    if err != nil {
        log.Fatal(err)
    }
    for _, r := range results.Results {
        fmt.Printf("- %s (score: %.2f)\n", r.Title, r.Score)
    }

    // List threads
    threads, err := client.Threads.List(ctx, &mem.ListThreadsParams{Limit: 10})
    if err != nil {
        log.Fatal(err)
    }
    for _, t := range threads.Threads {
        fmt.Printf("- %s: %s\n", t.ID, t.Title)
    }

    // Browse Nowledge FS
    entries, err := client.FS.List(ctx, "/", 0, "")
    if err != nil {
        log.Fatal(err)
    }
    for _, e := range entries.Entries {
        fmt.Printf("  %s %s\n", e.Type, e.Name)
    }
}

func strPtr(s string) *string { return &s }

Services

Service Description
client.Memories CRUD, search, bulk operations, favorites, labels
client.Threads Thread management, search, session import
client.Spaces Space profiles and configuration
client.Labels Label CRUD
client.Entities Knowledge graph entities
client.Sources Library sources, ingestion
client.Health Health check, checkpoint
client.FS Path-based tree browsing (ls, cat, stat, find, grep, recall, write, delete)
client.Agent Background Intelligence triggers
client.Graph Graph analysis, augmentation, orphans

Configuration

// Custom base URL
client := mem.NewClient(mem.WithBaseURL("http://192.168.1.100:14242"))

// Custom HTTP client
client := mem.NewClient(mem.WithHTTPClient(&http.Client{Timeout: 60 * time.Second}))

// Custom timeout
client := mem.NewClient(mem.WithTimeout(60 * time.Second))

// Always close when done to release idle connections
defer client.Close()

Error Handling

The SDK returns *mem.APIError for API errors:

resp, err := client.Memories.Get(ctx, "nonexistent", "")
if err != nil {
    if apiErr, ok := err.(*mem.APIError); ok {
        fmt.Println("API error:", apiErr.Detail[0].Msg)
    }
}

License

MIT

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIError

type APIError struct {
	Detail []ErrorDetail `json:"detail"`
}

APIError represents an error response from the API.

func (*APIError) Error

func (e *APIError) Error() string

type AgentService

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

AgentService handles Background Intelligence operations.

func (*AgentService) Status

func (s *AgentService) Status(ctx context.Context) (*AgentStatus, error)

Status returns the agent's current status.

func (*AgentService) TriggerCommunityDetection

func (s *AgentService) TriggerCommunityDetection(ctx context.Context) error

TriggerCommunityDetection triggers community detection on the knowledge graph.

func (*AgentService) TriggerCrystallization

func (s *AgentService) TriggerCrystallization(ctx context.Context) error

TriggerCrystallization triggers a crystallization review.

func (*AgentService) TriggerDailyBriefing

func (s *AgentService) TriggerDailyBriefing(ctx context.Context) error

TriggerDailyBriefing triggers a daily briefing.

func (*AgentService) TriggerDecayRefresh

func (s *AgentService) TriggerDecayRefresh(ctx context.Context) error

TriggerDecayRefresh triggers a decay score refresh.

func (*AgentService) TriggerInsightDetection

func (s *AgentService) TriggerInsightDetection(ctx context.Context) error

TriggerInsightDetection triggers proactive insight detection.

func (*AgentService) TriggerKGExtraction

func (s *AgentService) TriggerKGExtraction(ctx context.Context, req *KGExtractionRequest) error

TriggerKGExtraction triggers knowledge graph extraction.

func (*AgentService) TriggerMemoryCompaction

func (s *AgentService) TriggerMemoryCompaction(ctx context.Context) error

TriggerMemoryCompaction triggers a memory compaction review.

type AgentStatus

type AgentStatus struct {
	Running         bool   `json:"running"`
	CurrentTask     string `json:"current_task,omitempty"`
	LastRunAt       string `json:"last_run_at,omitempty"`
	NextScheduledAt string `json:"next_scheduled_at,omitempty"`
}

AgentStatus is the response body for GET /agent/status.

type AppendMessagesResponse

type AppendMessagesResponse struct {
	Thread   Thread          `json:"thread"`
	Messages []ThreadMessage `json:"messages"`
}

AppendMessagesResponse is the response for POST /threads/{id}/append.

type AugmentationJob

type AugmentationJob struct {
	ID        string         `json:"id"`
	JobType   string         `json:"job_type"`
	Status    string         `json:"status"`
	Progress  float64        `json:"progress"`
	StartedAt string         `json:"started_at,omitempty"`
	EndedAt   string         `json:"ended_at,omitempty"`
	Error     string         `json:"error,omitempty"`
	Params    map[string]any `json:"params,omitempty"`
}

AugmentationJob represents an augmentation job.

type AugmentationState

type AugmentationState struct {
	Running    bool             `json:"running"`
	CurrentJob *AugmentationJob `json:"current_job,omitempty"`
	LastRun    string           `json:"last_run,omitempty"`
}

AugmentationState is the response body for GET /graph/augmentation/state.

type BatchIngestRequest

type BatchIngestRequest struct {
	FilePaths []string `json:"file_paths"`
	SpaceID   string   `json:"space_id,omitempty"`
}

BatchIngestRequest is the request body for POST /sources/ingest/batch.

type BatchIngestResponse

type BatchIngestResponse struct {
	Sources []Source `json:"sources"`
	Failed  []string `json:"failed,omitempty"`
}

BatchIngestResponse is the response body for POST /sources/ingest/batch.

type BulkDeleteRequest

type BulkDeleteRequest struct {
	MemoryIDs []string `json:"memory_ids,omitempty"`
	SpaceID   string   `json:"space_id,omitempty"`
}

BulkDeleteRequest is the request for POST /memories/bulk/delete.

type BulkDeleteResponse

type BulkDeleteResponse struct {
	Deleted int `json:"deleted"`
	Failed  int `json:"failed"`
}

BulkDeleteResponse is the response for POST /memories/bulk/delete.

type BulkMovePreviewRequest

type BulkMovePreviewRequest struct {
	MemoryIDs []string `json:"memory_ids,omitempty"`
	FromSpace string   `json:"from_space,omitempty"`
	ToSpace   string   `json:"to_space"`
}

BulkMovePreviewRequest is the request for POST /memories/bulk/move/preview.

type BulkMovePreviewResponse

type BulkMovePreviewResponse struct {
	WillMove  int      `json:"will_move"`
	Conflicts []string `json:"conflicts,omitempty"`
}

BulkMovePreviewResponse is the response for POST /memories/bulk/move/preview.

type BulkMoveRequest

type BulkMoveRequest struct {
	MemoryIDs []string `json:"memory_ids,omitempty"`
	FromSpace string   `json:"from_space,omitempty"`
	ToSpace   string   `json:"to_space"`
}

BulkMoveRequest is the request for POST /memories/bulk/move.

type BulkMoveResponse

type BulkMoveResponse struct {
	Moved  int `json:"moved"`
	Failed int `json:"failed"`
}

BulkMoveResponse is the response for POST /memories/bulk/move.

type CleanupOrphansResponse

type CleanupOrphansResponse struct {
	Removed int `json:"removed"`
}

CleanupOrphansResponse is the response body for DELETE /graph/orphans.

type Client

type Client struct {

	// Services provides access to API resource operations.
	Memories *MemoriesService
	Threads  *ThreadsService
	Spaces   *SpacesService
	Labels   *LabelsService
	Entities *EntitiesService
	Sources  *SourcesService
	Health   *HealthService
	FS       *FSService
	Agent    *AgentService
	Graph    *GraphService
	// contains filtered or unexported fields
}

Client is the Nowledge Mem API client.

Create a client with NewClient:

client := onledgemem.NewClient()
client := onledgemem.NewClient(onledgemem.WithBaseURL("http://host:14242"))

func NewClient

func NewClient(opts ...Option) *Client

NewClient creates a new Nowledge Mem API client.

Example
package main

import (
	"context"
	"fmt"
	"log"

	mem "github.com/lib-x/nowledgemem-go"
)

func main() {
	// Create a client with default settings (http://127.0.0.1:14242)
	client := mem.NewClient()
	defer client.Close()

	ctx := context.Background()

	// Health check
	health, err := client.Health.Check(ctx)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println("Status:", health.Status)

	// List memories
	resp, err := client.Memories.List(ctx, &mem.ListMemoriesParams{
		Limit: 5,
	})
	if err != nil {
		log.Fatal(err)
	}
	for _, m := range resp.Memories {
		fmt.Printf("- %s: %s\n", m.ID, m.Title)
	}
}
Example (WithOptions)
package main

import (
	"context"
	"fmt"
	"log"
	"time"

	mem "github.com/lib-x/nowledgemem-go"
)

func main() {
	// Create a client with custom base URL and timeout
	client := mem.NewClient(
		mem.WithBaseURL("http://192.168.1.100:14242"),
		mem.WithTimeout(60*time.Second),
	)
	defer client.Close()

	ctx := context.Background()

	// Create a memory
	created, err := client.Memories.Create(ctx, &mem.CreateMemoryRequest{
		Content: "Remember to review the API design",
		Title:   strPtr("API Review"),
	})
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println("Created memory:", created.Memory.ID)

	// Search memories
	results, err := client.Memories.Search(ctx, &mem.SearchMemoriesRequest{
		Query: "API design",
		Limit: 5,
	})
	if err != nil {
		log.Fatal(err)
	}
	for _, r := range results.Results {
		fmt.Printf("- %s (score: %.2f)\n", r.Title, r.Score)
	}
}

func strPtr(s string) *string { return &s }

func (*Client) BaseURL

func (c *Client) BaseURL() *url.URL

BaseURL returns the client's base URL.

func (*Client) Close

func (c *Client) Close()

Close closes idle HTTP connections. Call this when done with the client.

type Community

type Community struct {
	ID           string   `json:"id"`
	Name         string   `json:"name"`
	Description  string   `json:"description,omitempty"`
	Size         int      `json:"size"`
	SampleMemIDs []string `json:"sample_mem_ids,omitempty"`
}

Community represents a knowledge community.

type ContentStoreInfo

type ContentStoreInfo struct {
	State                       string `json:"state"`
	DBPath                      string `json:"db_path"`
	SQLiteReady                 bool   `json:"sqlite_ready"`
	SchemaVersion               int    `json:"schema_version"`
	SchemaMinSupportedVersion   int    `json:"schema_min_supported_version"`
	SchemaMigrationCount        int    `json:"schema_migration_count"`
	ThreadMessageOwner          string `json:"thread_message_owner"`
	CutoverReady                bool   `json:"cutover_ready"`
	CutoverCompleted            bool   `json:"cutover_completed"`
	LegacyGraphCleanupCompleted bool   `json:"legacy_graph_cleanup_completed"`
	SQLiteMessageCount          int    `json:"sqlite_message_count"`
	SQLiteThreadCount           int    `json:"sqlite_thread_count"`
	SQLiteAnchorCount           int    `json:"sqlite_anchor_count"`
	LegacyKuzuMessageCount      int    `json:"legacy_kuzu_message_count"`
	LastError                   string `json:"last_error"`
	UpdatedAt                   string `json:"updated_at"`
}

ContentStoreInfo holds content store status.

type CreateLabelRequest

type CreateLabelRequest struct {
	Name        string `json:"name"`
	Color       string `json:"color,omitempty"`
	Description string `json:"description,omitempty"`
}

CreateLabelRequest is the request body for POST /labels.

type CreateMemoryRequest

type CreateMemoryRequest struct {
	ID              *string        `json:"id,omitempty"`
	Content         string         `json:"content"`
	Title           *string        `json:"title,omitempty"`
	SourceThreadID  *string        `json:"source_thread_id,omitempty"`
	SourceMsgRange  map[string]int `json:"source_message_range,omitempty"`
	Source          *string        `json:"source,omitempty"`
	Importance      *float64       `json:"importance,omitempty"`
	Confidence      *float64       `json:"confidence,omitempty"`
	Labels          []string       `json:"labels,omitempty"`
	SpaceID         *string        `json:"space_id,omitempty"`
	Metadata        map[string]any `json:"metadata,omitempty"`
	EventStart      *string        `json:"event_start,omitempty"`
	EventEnd        *string        `json:"event_end,omitempty"`
	TemporalContext *string        `json:"temporal_context,omitempty"`
	UnitType        *string        `json:"unit_type,omitempty"`
}

CreateMemoryRequest is the request body for POST /memories.

type CreateMemoryResponse

type CreateMemoryResponse struct {
	Memory               Memory   `json:"memory"`
	ExtractedEntities    []Entity `json:"extracted_entities,omitempty"`
	AssignedLabels       []string `json:"assigned_labels,omitempty"`
	CreatedRelationships int      `json:"created_relationships,omitempty"`
	Action               string   `json:"action,omitempty"`
	Warnings             []string `json:"warnings,omitempty"`
}

CreateMemoryResponse is the response body for POST /memories.

type CreateSpaceRequest

type CreateSpaceRequest struct {
	Name                 string `json:"name"`
	Description          string `json:"description,omitempty"`
	Icon                 string `json:"icon,omitempty"`
	Instructions         string `json:"instructions,omitempty"`
	DefaultRetrievalMode string `json:"defaultRetrievalMode,omitempty"`
}

CreateSpaceRequest is the request body for POST /spaces.

type CreateThreadRequest

type CreateThreadRequest struct {
	ThreadID     string                 `json:"thread_id"`
	Title        *string                `json:"title,omitempty"`
	Messages     []MessageCreateRequest `json:"messages"`
	Participants []string               `json:"participants,omitempty"`
	Source       *string                `json:"source,omitempty"`
	SpaceID      string                 `json:"space_id,omitempty"`
	Project      *string                `json:"project,omitempty"`
	Workspace    *string                `json:"workspace,omitempty"`
	ToolVersion  *string                `json:"tool_version,omitempty"`
	ImportDate   *string                `json:"import_date,omitempty"`
	Metadata     map[string]any         `json:"metadata,omitempty"`
}

CreateThreadRequest is the request body for POST /threads.

type CreateThreadResponse

type CreateThreadResponse struct {
	Thread                  Thread          `json:"thread"`
	Messages                []ThreadMessage `json:"messages,omitempty"`
	CreatedRelationships    int             `json:"created_relationships,omitempty"`
	AutoGeneratedSummary    string          `json:"auto_generated_summary,omitempty"`
	ExtractedMemories       []Memory        `json:"extracted_memories,omitempty"`
	AutoExtractionPerformed bool            `json:"auto_extraction_performed,omitempty"`
}

CreateThreadResponse is the response body for POST /threads.

type DeleteMemoryParams

type DeleteMemoryParams struct {
	CascadeDelete bool   `json:"cascade_delete,omitempty"`
	SpaceID       string `json:"space_id,omitempty"`
}

DeleteMemoryParams are query parameters for DELETE /memories/{id}.

type DeleteMemoryResponse

type DeleteMemoryResponse struct {
	Message              string `json:"message"`
	DeletedRelationships int    `json:"deleted_relationships,omitempty"`
	DeletedEntities      int    `json:"deleted_entities,omitempty"`
}

DeleteMemoryResponse is the response body for DELETE /memories/{id}.

type EntitiesService

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

EntitiesService handles entity operations.

func (*EntitiesService) GetRelationships

func (s *EntitiesService) GetRelationships(ctx context.Context, entityID string) (*EntityRelationships, error)

GetRelationships returns all connected entities and memories for an entity.

func (*EntitiesService) List

func (s *EntitiesService) List(ctx context.Context, params *ListEntitiesParams) ([]Entity, error)

List returns entities with optional filtering.

func (*EntitiesService) ListWithStats

func (s *EntitiesService) ListWithStats(ctx context.Context, params *ListEntitiesParams) ([]EntityWithStats, error)

ListWithStats returns entities sorted by mention count with stats.

type Entity

type Entity struct {
	ID                 string         `json:"id"`
	NodeType           string         `json:"node_type,omitempty"`
	CreatedAt          *time.Time     `json:"created_at,omitempty"`
	UpdatedAt          *time.Time     `json:"updated_at,omitempty"`
	Metadata           map[string]any `json:"metadata,omitempty"`
	Name               string         `json:"name"`
	EntityType         string         `json:"entity_type,omitempty"`
	Description        string         `json:"description,omitempty"`
	Aliases            []string       `json:"aliases,omitempty"`
	Confidence         float64        `json:"confidence,omitempty"`
	EntityCreated      string         `json:"entity_created,omitempty"`
	EntityEnded        string         `json:"entity_ended,omitempty"`
	TemporalPrecision  string         `json:"temporal_precision,omitempty"`
	TemporalConfidence float64        `json:"temporal_confidence,omitempty"`
	TemporalContext    string         `json:"temporal_context,omitempty"`
}

Entity represents an entity node in the knowledge graph.

type EntityRelationships

type EntityRelationships struct {
	Entity          Entity           `json:"entity"`
	RelatedEntities []Entity         `json:"related_entities,omitempty"`
	RelatedMemories []MemoryListItem `json:"related_memories,omitempty"`
}

EntityRelationships holds an entity's connected nodes.

type EntityWithStats

type EntityWithStats struct {
	Entity       Entity `json:"entity"`
	MentionCount int    `json:"mention_count"`
}

EntityWithStats wraps an Entity with mention count.

type ErrorDetail

type ErrorDetail struct {
	Loc   []string       `json:"loc"`
	Msg   string         `json:"msg"`
	Type  string         `json:"type"`
	Input any            `json:"input,omitempty"`
	Ctx   map[string]any `json:"ctx,omitempty"`
}

ErrorDetail is a single validation error.

type FSCatResponse

type FSCatResponse struct {
	Path        string         `json:"path"`
	Body        string         `json:"body"`
	Frontmatter map[string]any `json:"frontmatter,omitempty"`
	TotalLines  int            `json:"total_lines,omitempty"`
}

FSCatResponse is the response body for GET /fs/cat.

type FSDeleteRequest

type FSDeleteRequest struct {
	Path string `json:"path"`
}

FSDeleteRequest is the request body for POST /fs/delete.

type FSEntry

type FSEntry struct {
	Path  string `json:"path"`
	Name  string `json:"name"`
	Type  string `json:"type"`
	Size  int64  `json:"size,omitempty"`
	IsDir bool   `json:"is_dir,omitempty"`
}

FSEntry represents a file/directory in the Nowledge FS tree.

type FSGrepMatch

type FSGrepMatch struct {
	Path string `json:"path"`
	Line int    `json:"line"`
	Text string `json:"text"`
}

FSGrepMatch represents a single grep match.

type FSGrepResponse

type FSGrepResponse struct {
	Matches []FSGrepMatch `json:"matches"`
}

FSGrepResponse is the response body for GET /fs/grep.

type FSListResponse

type FSListResponse struct {
	Entries []FSEntry `json:"entries"`
	Cursor  string    `json:"cursor,omitempty"`
	HasMore bool      `json:"has_more,omitempty"`
}

FSListResponse is the response body for GET /fs/ls.

type FSSearchResponse

type FSSearchResponse struct {
	Paths []string `json:"paths"`
}

FSSearchResponse is the response body for GET /fs/find, /fs/recall.

type FSService

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

FSService handles Nowledge FS operations (path-based tree browsing).

func (*FSService) Cat

func (s *FSService) Cat(ctx context.Context, path string, line, lines int) (*FSCatResponse, error)

Cat reads a rendered file body and frontmatter.

func (*FSService) CatString

func (s *FSService) CatString(ctx context.Context, path string) (string, error)

CatString is a convenience method that returns just the body text.

func (*FSService) Delete

func (s *FSService) Delete(ctx context.Context, path string) error

Delete deletes a file at the given path.

func (*FSService) Find

func (s *FSService) Find(ctx context.Context, path, fileType, label string) (*FSSearchResponse, error)

Find performs structural search (type, label, date, mention constraints).

func (*FSService) Grep

func (s *FSService) Grep(ctx context.Context, path, query string) (*FSGrepResponse, error)

Grep performs literal exact-string search.

func (*FSService) List

func (s *FSService) List(ctx context.Context, path string, limit int, cursor string) (*FSListResponse, error)

List lists a directory in the FS tree.

func (*FSService) LsPaths

func (s *FSService) LsPaths(ctx context.Context, path string) ([]string, error)

LsPaths is a convenience method that returns just the entry paths.

func (*FSService) Recall

func (s *FSService) Recall(ctx context.Context, path, query string, k int) (*FSSearchResponse, error)

Recall performs semantic search that returns paths.

func (*FSService) Stat

func (s *FSService) Stat(ctx context.Context, path string) (*FSStatResponse, error)

Stat reads metadata without loading the body.

func (*FSService) Write

func (s *FSService) Write(ctx context.Context, path, body string) error

Write updates a file at the given path.

type FSStatResponse

type FSStatResponse struct {
	Path      string         `json:"path"`
	Type      string         `json:"type"`
	Size      int64          `json:"size"`
	CreatedAt string         `json:"created_at,omitempty"`
	UpdatedAt string         `json:"updated_at,omitempty"`
	Metadata  map[string]any `json:"metadata,omitempty"`
}

FSStatResponse is the response body for GET /fs/stat.

type FSWriteRequest

type FSWriteRequest struct {
	Path string `json:"path"`
	Body string `json:"body"`
}

FSWriteRequest is the request body for POST /fs/write.

type GraphAnalysis

type GraphAnalysis struct {
	NodeCount        int                `json:"node_count"`
	EdgeCount        int                `json:"edge_count"`
	CommunityCount   int                `json:"community_count"`
	Communities      []Community        `json:"communities,omitempty"`
	CentralityScores map[string]float64 `json:"centrality_scores,omitempty"`
}

GraphAnalysis is the response body for GET /graph/analysis.

type GraphHealthResponse

type GraphHealthResponse struct {
	Status    string `json:"status"`
	AlgoReady bool   `json:"algo_ready"`
}

GraphHealthResponse is the response body for GET /graph/health.

type GraphService

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

GraphService handles knowledge graph operations.

func (*GraphService) Analysis

func (s *GraphService) Analysis(ctx context.Context) (*GraphAnalysis, error)

Analysis returns comprehensive graph analysis including community and centrality metrics.

func (*GraphService) AugmentationState

func (s *GraphService) AugmentationState(ctx context.Context) (*AugmentationState, error)

AugmentationState returns current augmentation status and parameters.

func (*GraphService) CleanupOrphans

func (s *GraphService) CleanupOrphans(ctx context.Context) (*CleanupOrphansResponse, error)

CleanupOrphans removes orphaned entities from the graph.

func (*GraphService) FindOrphans

func (s *GraphService) FindOrphans(ctx context.Context) ([]Entity, error)

FindOrphans finds entities with no relationships.

func (*GraphService) Health

Health checks graph analysis service and algo extensions.

func (*GraphService) JobStatus

func (s *GraphService) JobStatus(ctx context.Context, jobID string) (*AugmentationJob, error)

JobStatus checks progress of a specific augmentation job.

func (*GraphService) ListJobs

func (s *GraphService) ListJobs(ctx context.Context, limit int) ([]AugmentationJob, error)

ListJobs lists recent augmentation jobs.

func (*GraphService) StartAugmentation

func (s *GraphService) StartAugmentation(ctx context.Context, req *StartAugmentationRequest) (*AugmentationJob, error)

StartAugmentation starts a background job (community detection, PageRank).

type HealthCheck

type HealthCheck struct {
	Status                    string            `json:"status"`
	Version                   string            `json:"version"`
	Timestamp                 *time.Time        `json:"timestamp,omitempty"`
	DatabaseConnected         bool              `json:"database_connected"`
	ServicesReady             bool              `json:"services_ready"`
	BufferPoolExhausted       bool              `json:"buffer_pool_exhausted"`
	BufferPoolAutoEscalatedMB int               `json:"buffer_pool_auto_escalated_mb"`
	BufferPoolCurrentMB       int               `json:"buffer_pool_current_mb"`
	BufferPoolNextStartMB     int               `json:"buffer_pool_next_start_mb"`
	BufferPoolRestartRequired bool              `json:"buffer_pool_restart_required"`
	BufferPoolRestartReason   string            `json:"buffer_pool_restart_reason"`
	BufferPoolAutoMode        bool              `json:"buffer_pool_auto_mode"`
	BufferPoolSource          string            `json:"buffer_pool_source"`
	BufferPoolAutoFloorMB     int               `json:"buffer_pool_auto_floor_mb"`
	BufferPoolAutoCapMB       int               `json:"buffer_pool_auto_cap_mb"`
	PluginUpdates             []PluginUpdate    `json:"plugin_updates,omitempty"`
	ContentStore              *ContentStoreInfo `json:"content_store,omitempty"`
}

HealthCheck is the response body for GET /health.

type HealthService

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

HealthService handles health check operations.

func (*HealthService) Check

func (s *HealthService) Check(ctx context.Context) (*HealthCheck, error)

Check performs a health check.

func (*HealthService) ForceCheckpoint

func (s *HealthService) ForceCheckpoint(ctx context.Context) error

ForceCheckpoint forces a database checkpoint to flush WAL to disk.

type IngestByPathRequest

type IngestByPathRequest struct {
	FilePath string `json:"file_path"`
	SpaceID  string `json:"space_id,omitempty"`
}

IngestByPathRequest is the request body for POST /sources/ingest/file-path.

type IngestFileRequest

type IngestFileRequest struct {
	SpaceID string `json:"space_id,omitempty"`
}

IngestFileRequest is the request body for POST /sources/ingest/file.

type IngestURLRequest

type IngestURLRequest struct {
	URL     string `json:"url"`
	SpaceID string `json:"space_id,omitempty"`
}

IngestURLRequest is the request body for POST /sources/ingest/url.

type KGExtractionRequest

type KGExtractionRequest struct {
	MemoryIDs []string `json:"memory_ids,omitempty"`
	Scope     string   `json:"scope,omitempty"`
}

KGExtractionRequest is the request body for POST /agent/trigger/kg-extraction.

type Label

type Label struct {
	ID          string `json:"id"`
	Name        string `json:"name"`
	Color       string `json:"color,omitempty"`
	Description string `json:"description,omitempty"`
	CreatedAt   string `json:"created_at,omitempty"`
	UpdatedAt   string `json:"updated_at,omitempty"`
	UsageCount  int    `json:"usage_count,omitempty"`
}

Label represents a label/tag.

type LabelsService

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

LabelsService handles label operations.

func (*LabelsService) Create

func (s *LabelsService) Create(ctx context.Context, req *CreateLabelRequest) (*Label, error)

Create creates a new label.

func (*LabelsService) Delete

func (s *LabelsService) Delete(ctx context.Context, labelID string) error

Delete deletes a label and all its relationships.

func (*LabelsService) Get

func (s *LabelsService) Get(ctx context.Context, labelID string) (*Label, error)

Get returns a specific label by ID.

func (*LabelsService) List

func (s *LabelsService) List(ctx context.Context, params *ListLabelsParams) ([]Label, error)

List returns all labels with usage counts.

func (*LabelsService) Update

func (s *LabelsService) Update(ctx context.Context, labelID string, req *UpdateLabelRequest) (*Label, error)

Update updates an existing label.

type ListEntitiesParams

type ListEntitiesParams struct {
	Limit        int    `json:"limit,omitempty"`
	EntityType   string `json:"entity_type,omitempty"`
	IncludeStats bool   `json:"include_stats,omitempty"`
}

ListEntitiesParams are query parameters for GET /entities.

type ListLabelsParams

type ListLabelsParams struct {
	Limit     int    `json:"limit,omitempty"`
	OrderBy   string `json:"order_by,omitempty"`
	OrderDesc bool   `json:"order_desc,omitempty"`
}

ListLabelsParams are query parameters for GET /labels.

type ListMemoriesParams

type ListMemoriesParams struct {
	Limit         int     `json:"limit,omitempty"`
	Offset        int     `json:"offset,omitempty"`
	State         string  `json:"state,omitempty"`
	ImportanceMin float64 `json:"importance_min,omitempty"`
	SpaceID       string  `json:"space_id,omitempty"`
	IsCrystal     *bool   `json:"is_crystal,omitempty"`
}

ListMemoriesParams are query parameters for GET /memories.

type ListMemoriesResponse

type ListMemoriesResponse struct {
	Memories   []MemoryListItem `json:"memories"`
	Pagination Pagination       `json:"pagination"`
}

ListMemoriesResponse is the response body for GET /memories.

type ListSourcesParams

type ListSourcesParams struct {
	Limit          int    `json:"limit,omitempty"`
	Offset         int    `json:"offset,omitempty"`
	SourceType     string `json:"source_type,omitempty"`
	LifecycleState string `json:"lifecycle_state,omitempty"`
	SpaceID        string `json:"space_id,omitempty"`
}

ListSourcesParams are query parameters for GET /sources.

type ListSourcesResponse

type ListSourcesResponse struct {
	Sources []Source `json:"sources"`
	Total   int      `json:"total"`
}

ListSourcesResponse is the response body for GET /sources.

type ListSpacesResponse

type ListSpacesResponse struct {
	Enabled bool    `json:"enabled"`
	Spaces  []Space `json:"spaces"`
}

ListSpacesResponse is the response body for GET /spaces.

type ListThreadsParams

type ListThreadsParams struct {
	Limit   int    `json:"limit,omitempty"`
	Offset  int    `json:"offset,omitempty"`
	Source  string `json:"source,omitempty"`
	SpaceID string `json:"space_id,omitempty"`
}

ListThreadsParams are query parameters for GET /threads.

type ListThreadsResponse

type ListThreadsResponse struct {
	Threads    []ThreadListItem `json:"threads"`
	Pagination Pagination       `json:"pagination"`
}

ListThreadsResponse is the response body for GET /threads.

type MemoriesService

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

MemoriesService handles memory CRUD operations.

func (*MemoriesService) AssignLabel

func (s *MemoriesService) AssignLabel(ctx context.Context, memoryID, labelID string) error

AssignLabel assigns a label to a memory.

func (*MemoriesService) BulkDelete

BulkDelete deletes selected memories.

func (*MemoriesService) BulkMove

BulkMove moves selected memories into another space.

func (*MemoriesService) BulkMovePreview

BulkMovePreview previews a bulk move between spaces.

func (*MemoriesService) Create

Create creates a new memory with automatic entity extraction.

func (*MemoriesService) Delete

func (s *MemoriesService) Delete(ctx context.Context, memoryID string, params *DeleteMemoryParams) (*DeleteMemoryResponse, error)

Delete deletes a memory and optionally its relationships.

func (*MemoriesService) Export

func (s *MemoriesService) Export(ctx context.Context, memoryID, format string) ([]byte, error)

Export exports a memory in the specified format (markdown, json, etc).

func (*MemoriesService) Get

func (s *MemoriesService) Get(ctx context.Context, memoryID string, spaceID string) (*MemoryListItem, error)

Get retrieves a specific memory by ID.

func (*MemoriesService) GetLabels

func (s *MemoriesService) GetLabels(ctx context.Context, memoryID string) ([]Label, error)

GetLabels returns labels assigned to a memory.

func (*MemoriesService) List

List returns memories with filtering and pagination.

func (*MemoriesService) RemoveLabel

func (s *MemoriesService) RemoveLabel(ctx context.Context, memoryID, labelID string) error

RemoveLabel removes a label from a memory.

func (*MemoriesService) Search

Search performs a hybrid search across memories.

func (*MemoriesService) ToggleFavorite

func (s *MemoriesService) ToggleFavorite(ctx context.Context, memoryID string) (*ToggleFavoriteResponse, error)

ToggleFavorite toggles favorite status for a memory.

func (*MemoriesService) Update

func (s *MemoriesService) Update(ctx context.Context, memoryID string, updates map[string]any) (*MemoryListItem, error)

Update updates memory properties like importance, title, and content.

type Memory

type Memory struct {
	ID                 string         `json:"id"`
	NodeType           string         `json:"node_type,omitempty"`
	CreatedAt          *time.Time     `json:"created_at,omitempty"`
	UpdatedAt          *time.Time     `json:"updated_at,omitempty"`
	Metadata           map[string]any `json:"metadata,omitempty"`
	Content            string         `json:"content"`
	Title              string         `json:"title,omitempty"`
	Importance         float64        `json:"importance,omitempty"`
	Confidence         float64        `json:"confidence,omitempty"`
	PagerankScore      float64        `json:"pagerank_score,omitempty"`
	Embedding          []float64      `json:"embedding,omitempty"`
	SourceRange        map[string]int `json:"source_range,omitempty"`
	Source             string         `json:"source,omitempty"`
	SpaceID            string         `json:"space_id,omitempty"`
	SemanticField      string         `json:"semantic_field,omitempty"`
	ReindexNeeded      bool           `json:"reindex_needed,omitempty"`
	LastReindexedAt    *time.Time     `json:"last_reindexed_at,omitempty"`
	LastAccessedAt     *time.Time     `json:"last_accessed_at,omitempty"`
	AccessCount        int            `json:"access_count,omitempty"`
	Appearances        int            `json:"appearances,omitempty"`
	Clicks             int            `json:"clicks,omitempty"`
	TotalDwellTimeMs   int            `json:"total_dwell_time_ms,omitempty"`
	LastClickedAt      *time.Time     `json:"last_clicked_at,omitempty"`
	DecayScoreCached   float64        `json:"decay_score_cached,omitempty"`
	TemporalContext    string         `json:"temporal_context,omitempty"`
	TemporalType       string         `json:"temporal_type,omitempty"`
	EventStart         string         `json:"event_start,omitempty"`
	EventEnd           string         `json:"event_end,omitempty"`
	TemporalPrecision  string         `json:"temporal_precision,omitempty"`
	TemporalConfidence float64        `json:"temporal_confidence,omitempty"`
	UnitType           string         `json:"unit_type,omitempty"`
	IsLatest           bool           `json:"is_latest,omitempty"`
	Version            int            `json:"version,omitempty"`
	IsCrystal          bool           `json:"is_crystal,omitempty"`
	CrystalTitle       string         `json:"crystal_title,omitempty"`
	SourceUnitCount    int            `json:"source_unit_count,omitempty"`
	ExtractionMethod   string         `json:"extraction_method,omitempty"`
	LastEvaluatedAt    *time.Time     `json:"last_evaluated_at,omitempty"`
	ReviewStatus       string         `json:"review_status,omitempty"`
}

Memory represents a memory node in the knowledge base.

type MemoryListItem

type MemoryListItem struct {
	ID           string         `json:"id"`
	Title        string         `json:"title,omitempty"`
	Content      string         `json:"content,omitempty"`
	Source       string         `json:"source,omitempty"`
	Time         string         `json:"time,omitempty"`
	Rating       float64        `json:"rating,omitempty"`
	LabelIDs     []string       `json:"label_ids,omitempty"`
	IsFavorite   bool           `json:"is_favorite,omitempty"`
	SourceThread *SourceThread  `json:"source_thread,omitempty"`
	Confidence   float64        `json:"confidence,omitempty"`
	SpaceID      string         `json:"space_id,omitempty"`
	Metadata     map[string]any `json:"metadata,omitempty"`
}

MemoryListItem is the summary view returned by list endpoints.

type MessageCreateRequest

type MessageCreateRequest struct {
	Content string `json:"content"`
	Role    string `json:"role"`
}

MessageCreateRequest is a message in a create-thread request.

type Option

type Option func(*Client)

Option configures the client.

func WithBaseURL

func WithBaseURL(rawURL string) Option

WithBaseURL overrides the default base URL.

func WithHTTPClient

func WithHTTPClient(hc *http.Client) Option

WithHTTPClient overrides the default HTTP client.

func WithTimeout

func WithTimeout(d time.Duration) Option

WithTimeout overrides the default HTTP timeout.

type Pagination

type Pagination struct {
	Limit   int  `json:"limit"`
	Offset  int  `json:"offset"`
	Total   int  `json:"total"`
	HasMore bool `json:"has_more"`
}

Pagination holds pagination metadata.

type PluginUpdate

type PluginUpdate struct {
	ID               string `json:"id"`
	Name             string `json:"name"`
	InstalledVersion string `json:"installed_version"`
	AvailableVersion string `json:"available_version"`
}

PluginUpdate represents an available plugin update.

type SearchMemoriesRequest

type SearchMemoriesRequest struct {
	Query      string   `json:"query"`
	SpaceID    string   `json:"space_id,omitempty"`
	Limit      int      `json:"limit,omitempty"`
	Offset     int      `json:"offset,omitempty"`
	Labels     []string `json:"labels,omitempty"`
	SourceType string   `json:"source_type,omitempty"`
}

SearchMemoriesRequest is the request body for POST /memories/search.

type SearchMemoriesResponse

type SearchMemoriesResponse struct {
	Results []SearchResult `json:"results"`
	Total   int            `json:"total"`
	Query   string         `json:"query"`
}

SearchMemoriesResponse is the response body for POST /memories/search.

type SearchResult

type SearchResult struct {
	ID      string  `json:"id"`
	Title   string  `json:"title,omitempty"`
	Content string  `json:"content,omitempty"`
	Score   float64 `json:"score"`
	SpaceID string  `json:"space_id,omitempty"`
	Source  string  `json:"source,omitempty"`
}

SearchResult is a single search result.

type Source

type Source struct {
	ID             string         `json:"id"`
	SourceType     string         `json:"source_type,omitempty"`
	OriginalName   string         `json:"original_name,omitempty"`
	MimeType       string         `json:"mime_type,omitempty"`
	FilePath       string         `json:"file_path,omitempty"`
	ParsedPath     string         `json:"parsed_path,omitempty"`
	SourceURL      string         `json:"source_url,omitempty"`
	SHA256         string         `json:"sha256,omitempty"`
	SizeBytes      int64          `json:"size_bytes,omitempty"`
	Version        int            `json:"version,omitempty"`
	SpaceID        string         `json:"space_id,omitempty"`
	LifecycleState string         `json:"lifecycle_state,omitempty"`
	ChunkCount     int            `json:"chunk_count,omitempty"`
	MemoryCount    int            `json:"memory_count,omitempty"`
	SectionTree    string         `json:"section_tree,omitempty"`
	Summary        string         `json:"summary,omitempty"`
	ErrorMessage   string         `json:"error_message,omitempty"`
	CreatedAt      string         `json:"created_at,omitempty"`
	UpdatedAt      string         `json:"updated_at,omitempty"`
	Metadata       map[string]any `json:"metadata,omitempty"`
	LabelIDs       []string       `json:"label_ids,omitempty"`
}

Source represents a library source (file, URL, etc.).

type SourceThread

type SourceThread struct {
	ID      string `json:"id"`
	Title   string `json:"title,omitempty"`
	SpaceID string `json:"space_id,omitempty"`
}

SourceThread is a lightweight thread reference attached to a memory.

type SourcesService

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

SourcesService handles source/library operations.

func (*SourcesService) BatchIngest

BatchIngest ingests a batch of files.

func (*SourcesService) Delete

func (s *SourcesService) Delete(ctx context.Context, sourceID string) error

Delete deletes a source and its search index records.

func (*SourcesService) Get

func (s *SourcesService) Get(ctx context.Context, sourceID string) (*Source, error)

Get returns source detail with related memories and revision chain.

func (*SourcesService) GetContent

func (s *SourcesService) GetContent(ctx context.Context, sourceID string) (string, error)

GetContent reads the parsed markdown content of a source.

func (*SourcesService) IngestByPath

func (s *SourcesService) IngestByPath(ctx context.Context, req *IngestByPathRequest) (*Source, error)

IngestByPath ingests a file by local filesystem path.

func (*SourcesService) IngestFile

func (s *SourcesService) IngestFile(ctx context.Context, req *IngestFileRequest) (*Source, error)

IngestFile ingests a file through the full source pipeline.

func (*SourcesService) IngestURL

func (s *SourcesService) IngestURL(ctx context.Context, req *IngestURLRequest) (*Source, error)

IngestURL fetches a URL and ingests through the source pipeline.

func (*SourcesService) List

List returns sources with optional filtering and pagination.

func (*SourcesService) Search

func (s *SourcesService) Search(ctx context.Context, query string, limit int) ([]Source, error)

Search performs full-text search across source names and content.

func (*SourcesService) Update

func (s *SourcesService) Update(ctx context.Context, sourceID string, req *UpdateSourceRequest) (*Source, error)

Update updates source lifecycle state.

type Space

type Space struct {
	ID                   string      `json:"id"`
	Key                  string      `json:"key,omitempty"`
	Name                 string      `json:"name,omitempty"`
	Aliases              []string    `json:"aliases,omitempty"`
	Description          string      `json:"description,omitempty"`
	Icon                 string      `json:"icon,omitempty"`
	Instructions         string      `json:"instructions,omitempty"`
	SharedSpaceIDs       []string    `json:"sharedSpaceIds,omitempty"`
	DefaultRetrievalMode string      `json:"defaultRetrievalMode,omitempty"`
	Usage                *SpaceUsage `json:"usage,omitempty"`
	Observed             bool        `json:"observed,omitempty"`
	HasProfile           bool        `json:"hasProfile,omitempty"`
}

Space represents a space profile.

type SpaceUsage

type SpaceUsage struct {
	Memories         int  `json:"memories"`
	Threads          int  `json:"threads"`
	Sources          int  `json:"sources"`
	HasWorkingMemory bool `json:"hasWorkingMemory"`
}

SpaceUsage holds usage statistics for a space.

type SpacesService

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

SpacesService handles space operations.

func (*SpacesService) Create

func (s *SpacesService) Create(ctx context.Context, req *CreateSpaceRequest) (*Space, error)

Create creates a space profile.

func (*SpacesService) Delete

func (s *SpacesService) Delete(ctx context.Context, spaceID string) error

Delete removes an empty space profile.

func (*SpacesService) Get

func (s *SpacesService) Get(ctx context.Context, spaceID string) (*Space, error)

Get reads one space profile by name, alias, or hidden key.

func (*SpacesService) List

List returns the shared space roster.

func (*SpacesService) Update

func (s *SpacesService) Update(ctx context.Context, spaceID string, req *UpdateSpaceRequest) (*Space, error)

Update updates a space profile.

type StartAugmentationRequest

type StartAugmentationRequest struct {
	JobType string         `json:"job_type"`
	Params  map[string]any `json:"params,omitempty"`
}

StartAugmentationRequest is the request body for POST /graph/augmentation/start.

type Thread

type Thread struct {
	ID           string         `json:"id"`
	NodeType     string         `json:"node_type,omitempty"`
	CreatedAt    *time.Time     `json:"created_at,omitempty"`
	UpdatedAt    *time.Time     `json:"updated_at,omitempty"`
	Metadata     map[string]any `json:"metadata,omitempty"`
	ThreadID     string         `json:"thread_id"`
	Title        string         `json:"title,omitempty"`
	Summary      string         `json:"summary,omitempty"`
	MessageCount int            `json:"message_count,omitempty"`
	Participants []string       `json:"participants,omitempty"`
	Source       string         `json:"source,omitempty"`
	SpaceID      string         `json:"space_id,omitempty"`
	Project      string         `json:"project,omitempty"`
	Workspace    string         `json:"workspace,omitempty"`
	ToolVersion  string         `json:"tool_version,omitempty"`
	ImportDate   *time.Time     `json:"import_date,omitempty"`
}

Thread represents a conversation thread.

type ThreadListItem

type ThreadListItem struct {
	ID         string `json:"id"`
	Title      string `json:"title,omitempty"`
	Summary    string `json:"summary,omitempty"`
	Source     string `json:"source,omitempty"`
	Messages   int    `json:"messages,omitempty"`
	Date       string `json:"date,omitempty"`
	IsFavorite bool   `json:"is_favorite,omitempty"`
	SpaceID    string `json:"space_id,omitempty"`
}

ThreadListItem is the summary view returned by list endpoints.

type ThreadMessage

type ThreadMessage struct {
	ID         string         `json:"id"`
	NodeType   string         `json:"node_type,omitempty"`
	CreatedAt  *time.Time     `json:"created_at,omitempty"`
	UpdatedAt  *time.Time     `json:"updated_at,omitempty"`
	Metadata   map[string]any `json:"metadata,omitempty"`
	Content    string         `json:"content"`
	Role       string         `json:"role"`
	OrderIndex int            `json:"order_index,omitempty"`
	Timestamp  *time.Time     `json:"timestamp,omitempty"`
	TokenCount int            `json:"token_count,omitempty"`
}

ThreadMessage represents a single message in a thread.

type ThreadSummary

type ThreadSummary struct {
	ID      string `json:"id"`
	Title   string `json:"title"`
	Summary string `json:"summary"`
}

ThreadSummary is a lightweight thread summary.

type ThreadsService

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

ThreadsService handles thread operations.

func (*ThreadsService) AppendMessages

func (s *ThreadsService) AppendMessages(ctx context.Context, threadID string, messages []MessageCreateRequest) (*AppendMessagesResponse, error)

AppendMessages appends messages to an existing thread.

func (*ThreadsService) BulkDelete

func (s *ThreadsService) BulkDelete(ctx context.Context, threadIDs []string) (*BulkDeleteResponse, error)

BulkDelete deletes multiple threads at once.

func (*ThreadsService) Create

Create creates a new thread with messages.

func (*ThreadsService) Delete

func (s *ThreadsService) Delete(ctx context.Context, threadID string) error

Delete deletes a thread and optionally its extracted memories.

func (*ThreadsService) Get

func (s *ThreadsService) Get(ctx context.Context, threadID string) (*Thread, error)

Get retrieves a thread with messages and pagination.

func (*ThreadsService) List

List returns threads with filtering and pagination.

func (*ThreadsService) Search

func (s *ThreadsService) Search(ctx context.Context, query string, limit int) ([]ThreadListItem, error)

Search performs full thread search with message matching.

func (*ThreadsService) Summaries

func (s *ThreadsService) Summaries(ctx context.Context) ([]ThreadSummary, error)

Summaries returns all thread titles and summaries.

func (*ThreadsService) ToggleFavorite

func (s *ThreadsService) ToggleFavorite(ctx context.Context, threadID string) (*ToggleFavoriteResponse, error)

ToggleFavorite toggles favorite status for a thread.

type ToggleFavoriteResponse

type ToggleFavoriteResponse struct {
	IsFavorite bool `json:"is_favorite"`
}

ToggleFavoriteResponse is the response for POST /memories/{id}/favorite.

type UpdateLabelRequest

type UpdateLabelRequest struct {
	Name        string `json:"name,omitempty"`
	Color       string `json:"color,omitempty"`
	Description string `json:"description,omitempty"`
}

UpdateLabelRequest is the request body for PUT /labels/{id}.

type UpdateSourceRequest

type UpdateSourceRequest struct {
	LifecycleState string `json:"lifecycle_state,omitempty"`
}

UpdateSourceRequest is the request body for PATCH /sources/{id}.

type UpdateSpaceRequest

type UpdateSpaceRequest struct {
	Name                 *string `json:"name,omitempty"`
	Description          *string `json:"description,omitempty"`
	Icon                 *string `json:"icon,omitempty"`
	Instructions         *string `json:"instructions,omitempty"`
	DefaultRetrievalMode *string `json:"defaultRetrievalMode,omitempty"`
}

UpdateSpaceRequest is the request body for PATCH /spaces/{id}.

Jump to

Keyboard shortcuts

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