app

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2026 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Overview

Package app wires config, stores, embedders and indexers into the running service shared by the REST API, the MCP server and the CLI.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type App

type App struct {
	Config *config.Config
	Logger *slog.Logger
	// contains filtered or unexported fields
}

func New

func New(ctx context.Context, cfg *config.Config, logger *slog.Logger) (*App, error)

New builds the runtime: opens every KB's store and constructs sources. It does NOT wait for embedding backends; call WaitReady from serve/index.

func (*App) Close

func (a *App) Close()

func (*App) DeleteDocument

func (a *App) DeleteDocument(ctx context.Context, kbName, id string) error

DeleteDocument removes a managed document from a writable KB.

func (*App) KB

func (a *App) KB(name string) (*KB, error)

KB fetches one knowledge base's runtime.

func (*App) KBNames

func (a *App) KBNames() []string

KBNames lists knowledge bases, sorted.

func (*App) Readiness

func (a *App) Readiness() map[string]error

Readiness returns a copy of the per-KB readiness map.

func (*App) Search

func (a *App) Search(ctx context.Context, kbName, query string, opts SearchOpts) ([]Hit, error)

Search runs a hybrid query against one KB. MinScore filters on the normalized relevance (0..1).

func (*App) SearchAll

func (a *App) SearchAll(ctx context.Context, query string, opts SearchOpts) ([]Hit, error)

SearchAll queries every KB and merges results by relevance.

func (*App) SetReady

func (a *App) SetReady(kbName string, err error)

SetReady records a KB's readiness state (nil = ready).

func (*App) StoreDocument

func (a *App) StoreDocument(ctx context.Context, kbName, title, content string, metadata map[string]string) (string, error)

StoreDocument writes agent-provided content into a writable KB and indexes it synchronously. The returned id follows the strands memory convention.

type Hit

type Hit struct {
	store.Hit
	KnowledgeBase string  `json:"knowledge_base"`
	Relevance     float64 `json:"relevance"`
	// RerankScore is the cross-encoder score when reranking ordered the
	// results, and is nil (omitted) when fusion did. Exposed alongside
	// fts_rank/vec_rank so a caller can tell which path won without a second
	// query — the visibility #14 asked for.
	RerankScore *float64 `json:"rerank_score,omitempty"`
}

Hit is a search result with a normalized relevance score in [0,1].

type KB

type KB struct {
	Config   *config.KnowledgeBase
	Store    store.Store
	Embedder *inference.Embedder
	Reranker *inference.Reranker // nil when reranking is disabled
	Indexer  *pipeline.Indexer
	Sources  []source.Source
}

KB is one knowledge base's runtime.

type SearchOpts added in v0.2.0

type SearchOpts struct {
	Limit    int
	MinScore float64
	// Rerank overrides the KB default: nil = rerank when the KB has a
	// reranker configured; &false disables it for this request; &true is a
	// no-op when no reranker exists.
	Rerank *bool
	// MaxPerDoc caps how many chunks of the same document appear in the
	// results. 0 = the default cap (2); negative = no cap.
	MaxPerDoc int
	// Filter keeps only documents whose metadata contains every given
	// key/value pair (AND semantics).
	Filter map[string]string
}

SearchOpts tunes one search request. Zero values mean "use defaults".

Jump to

Keyboard shortcuts

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