knowledge

package
v0.42.0 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CreateMemoryRequest

type CreateMemoryRequest struct {
	AgentID  string                 `json:"agent_id"`
	Title    string                 `json:"title"`
	Content  string                 `json:"content"`
	Source   string                 `json:"source"`
	Metadata map[string]interface{} `json:"metadata,omitempty"`
}

CreateMemoryRequest is the request body for POST /memory.

type EntityBrief

type EntityBrief struct {
	ID   string `json:"id"`
	Name string `json:"name"`
	Type string `json:"type"`
}

EntityBrief is a lightweight entity reference from the ontology graph.

type Excluder

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

Excluder determines whether a file path should be excluded from sync, based on .gitignore patterns and built-in exclusion rules.

func NewExcluder

func NewExcluder(gitignorePath string) (*Excluder, error)

NewExcluder creates an Excluder by parsing the given .gitignore file. If the file does not exist, only built-in exclusions are applied.

func (*Excluder) IsExcluded

func (e *Excluder) IsExcluded(path string) bool

IsExcluded returns true if the given path should be excluded from sync.

type FileWatcher

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

FileWatcher polls a directory tree for file changes at a regular interval.

func NewFileWatcher

func NewFileWatcher(dir string, interval time.Duration, onChange func(path string), excluder *Excluder) *FileWatcher

NewFileWatcher creates a new polling-based file watcher. The default poll interval is 500ms. An optional excluder filters out paths that should be ignored during scanning.

func (*FileWatcher) Start

func (w *FileWatcher) Start(ctx context.Context) error

Start begins polling the directory tree. It blocks until the context is cancelled or Stop is called.

func (*FileWatcher) Stop

func (w *FileWatcher) Stop()

Stop cancels the polling loop started by Start.

type GraphContext

type GraphContext struct {
	CommunityID   string `json:"community_id,omitempty"`
	CommunityName string `json:"community_name,omitempty"`
}

GraphContext holds community detection context from the knowledge graph.

type KnowledgeSearcher

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

KnowledgeSearcher queries the backend Knowledge Hub API. It uses workspace-scoped endpoints matching the Platform backend routes.

func NewKnowledgeSearcher

func NewKnowledgeSearcher(backendURL, authToken, workspaceID string) *KnowledgeSearcher

NewKnowledgeSearcher creates a new KnowledgeSearcher with a 5-second timeout.

func (*KnowledgeSearcher) Search

func (ks *KnowledgeSearcher) Search(ctx context.Context, query string) ([]SearchResult, error)

Search queries the workspace-scoped Knowledge Hub search API. Endpoint: POST /api/v1/workspaces/{workspaceId}/knowledge/search

func (*KnowledgeSearcher) SetAuthToken

func (ks *KnowledgeSearcher) SetAuthToken(token string)

SetAuthToken updates the bearer token used for knowledge search requests.

type MemoryContextResponse

type MemoryContextResponse struct {
	Entries    []MemoryEntry `json:"entries"`
	TokensUsed int           `json:"tokens_used"`
}

MemoryContextResponse is the API response for GET /memory/context.

type MemoryEntry

type MemoryEntry struct {
	ID      string `json:"id"`
	Title   string `json:"title"`
	Content string `json:"content"`
	Layer   string `json:"layer"`
	Source  string `json:"source,omitempty"`
}

MemoryEntry represents a single memory entry from the Platform.

type MemorySearcher

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

MemorySearcher queries the backend Agent Memory API.

func NewMemorySearcher

func NewMemorySearcher(backendURL, authToken, workspaceID string) *MemorySearcher

NewMemorySearcher creates a new MemorySearcher with a 5-second timeout.

func (*MemorySearcher) CreateMemory

func (ms *MemorySearcher) CreateMemory(ctx context.Context, req CreateMemoryRequest) error

CreateMemory creates an L1 memory entry on the Platform. POST /api/v1/workspaces/{workspaceId}/memory Non-blocking by convention: returns error but caller should log and continue.

func (*MemorySearcher) GetContext

func (ms *MemorySearcher) GetContext(ctx context.Context, agentID, description string) ([]MemoryEntry, error)

GetContext queries GET /api/v1/workspaces/{workspaceId}/memory/context with agent_id, token_budget, top_k, and keywords derived from description.

func (*MemorySearcher) SetAuthToken

func (ms *MemorySearcher) SetAuthToken(token string)

SetAuthToken updates the bearer token used for memory API requests.

type SearchResult

type SearchResult struct {
	ID             string  `json:"id"`
	Title          string  `json:"title"`
	Content        string  `json:"content"`
	Category       string  `json:"category"`
	RelevanceScore float64 `json:"relevance_score"`
	QualityScore   float64 `json:"quality_score"`
	SourceType     string  `json:"source_type"`

	// Graph RAG enrichment (optional — empty for workspaces without KG).
	GraphContext    *GraphContext `json:"graph_context,omitempty"`
	RelatedEntities []EntityBrief `json:"related_entities,omitempty"`
	ParentTitle     string        `json:"parent_title,omitempty"`
	FreshnessFactor float64       `json:"freshness_factor,omitempty"`

	// Score is a convenience alias for RelevanceScore used by populateKnowledge.
	Score float64 `json:"-"`
}

SearchResult represents a single knowledge search result. Fields align with the Platform's KnowledgeSearchResult response.

Jump to

Keyboard shortcuts

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