Agents Knowledge Store

Classes

Classes

KnowledgeStoreClient

Main client for interacting with the knowledge store

Constructor

constructor(config: KnowledgeStoreConfig)

Parameters:

ParameterTypeRequiredDescription
configKnowledgeStoreConfigYes- Configuration for the knowledge store

Methods

isConnected

Check if connected to Redis

isConnected(): Promise<boolean>

Returns:

Promise<boolean> -

disconnect

Disconnect from Redis

disconnect(): Promise<void>

Returns:

Promise<void> -

create

Create a new knowledge item

create(item: CreateKnowledgeItem): Promise<OperationResult<KnowledgeItem>>

Parameters:

ParameterTypeRequiredDescription
itemCreateKnowledgeItemYes- Knowledge item to create

Returns:

Promise<OperationResult<KnowledgeItem>> - Operation result with created item

Examples:

const result = await client.create({
  type: KnowledgeType.DIRECTIVE,
  namespace: 'project-123',
  title: 'Always use TypeScript',
  content: 'All code in this project must be written in TypeScript',
  metadata: {
    source: 'team-lead',
    priority: KnowledgePriority.CRITICAL,
    tags: ['code-standards', 'typescript']
  }
});

get

Get a knowledge item by ID

get(namespace: string, id: string, trackAccess?: boolean | undefined): Promise<OperationResult<KnowledgeItem>>

Parameters:

ParameterTypeRequiredDescription
namespacestringYes- Namespace of the item
idstringYes- ID of the item
trackAccessboolean | undefinedNo- Whether to increment access count (default: use config)

Returns:

Promise<OperationResult<KnowledgeItem>> - Operation result with the item

update

Update a knowledge item

update(namespace: string, id: string, updates: UpdateKnowledgeItem): Promise<OperationResult<KnowledgeItem>>

Parameters:

ParameterTypeRequiredDescription
namespacestringYes- Namespace of the item
idstringYes- ID of the item
updatesUpdateKnowledgeItemYes- Fields to update

Returns:

Promise<OperationResult<KnowledgeItem>> - Operation result with updated item

delete

Delete a knowledge item

delete(namespace: string, id: string): Promise<OperationResult<void>>

Parameters:

ParameterTypeRequiredDescription
namespacestringYes- Namespace of the item
idstringYes- ID of the item

Returns:

Promise<OperationResult<void>> - Operation result

Search for knowledge items

search(options?: SearchOptions): Promise<SearchResults<KnowledgeItem>>

Parameters:

ParameterTypeRequiredDescription
optionsSearchOptionsNo- Search options

Returns:

Promise<SearchResults<KnowledgeItem>> - Search results with pagination

Examples:

const results = await client.search({
  query: 'typescript',
  filter: {
    type: KnowledgeType.DIRECTIVE,
    priority: [KnowledgePriority.HIGH, KnowledgePriority.CRITICAL],
    tags: ['code-standards']
  },
  limit: 10,
  sortBy: 'priority',
  sortOrder: 'desc'
});

Semantic search using vector similarity

semanticSearch(options: SemanticSearchOptions): Promise<SearchResults<KnowledgeItem>>

Parameters:

ParameterTypeRequiredDescription
optionsSemanticSearchOptionsYes- Semantic search options with embedding vector

Returns:

Promise<SearchResults<KnowledgeItem>> - Search results with similarity scores

Examples:

const embedding = await generateEmbedding('code quality best practices');
const results = await client.semanticSearch({
  embedding,
  threshold: 0.8,
  limit: 5
});

getStats

Get statistics about the knowledge store

getStats(namespace?: string | undefined): Promise<KnowledgeStats>

Parameters:

ParameterTypeRequiredDescription
namespacestring | undefinedNo- Optional namespace to filter stats

Returns:

Promise<KnowledgeStats> - Knowledge store statistics

batchCreate

Create multiple knowledge items in a batch

batchCreate(items: CreateKnowledgeItem[]): Promise<BatchOperationResult<KnowledgeItem>>

Parameters:

ParameterTypeRequiredDescription
itemsCreateKnowledgeItem[]Yes- Array of items to create

Returns:

Promise<BatchOperationResult<KnowledgeItem>> - Batch operation result

batchDelete

Delete multiple knowledge items in a batch

batchDelete(items: { namespace: string; id: string; }[]): Promise<BatchOperationResult<void>>

Parameters:

ParameterTypeRequiredDescription
items{ namespace: string; id: string; }[]Yes- Array of {namespace, id} to delete

Returns:

Promise<BatchOperationResult<void>> - Batch operation result

KnowledgeStoreError

Custom error for knowledge store operations

Constructor

constructor(code: KnowledgeErrorCode, message: string, details?: any)

Parameters:

ParameterTypeRequiredDescription
codeKnowledgeErrorCodeYes
messagestringYes
detailsanyNo
Previous
Types