ObjectStackObjectStack

Knowledge Source

Knowledge Source protocol schemas

Knowledge Source — declarative metadata describing what to index and which adapter to use.

A KnowledgeSource is the metadata-level equivalent of an IDataEngine driver binding: it pairs a logical source description (object/file/http) with the id of an IKnowledgeAdapter plugin that will actually do the work. The adapter resolves the id at runtime via IKnowledgeService.registerAdapter.

See content/docs/protocol/knowledge.mdx for the full design.

Source: packages/spec/src/ai/knowledge-source.zod.ts

TypeScript Usage

import { FileKnowledgeSourceSchema, HttpKnowledgeSourceSchema, KnowledgeRefreshPolicySchema, KnowledgeSourceSchema, KnowledgeSourceKindSchema, ObjectKnowledgeSourceSchema } from '@objectstack/spec/ai';
import type { FileKnowledgeSource, HttpKnowledgeSource, KnowledgeRefreshPolicy, KnowledgeSource, KnowledgeSourceKind, ObjectKnowledgeSource } from '@objectstack/spec/ai';

// Validate data
const result = FileKnowledgeSourceSchema.parse(data);

FileKnowledgeSource

Properties

PropertyTypeRequiredDescription
kind'file'
prefixstringStorage prefix
mimeTypesstring[]optional

HttpKnowledgeSource

Properties

PropertyTypeRequiredDescription
kind'http'
urlsstring[]
userAgentstringoptional

KnowledgeRefreshPolicy

Properties

PropertyTypeRequiredDescription
onRecordChangebooleanoptional
cronstringoptional

KnowledgeSource

Properties

PropertyTypeRequiredDescription
idstringSnake_case source id
labelstring
descriptionstringoptional
adapterstringAdapter id
adapterConfigRecord<string, any>optional
source{ kind: 'object'; object: string; contentFields: string[]; metadataFields?: string[]; … } | { kind: 'file'; prefix: string; mimeTypes?: string[] } | { kind: 'http'; urls: string[]; userAgent?: string }
embedding{ provider: Enum<'openai' | 'cohere' | 'azure_openai' | 'huggingface' | 'local' | 'custom'>; model: string; dimensions: integer; endpoint?: string; … }optional
vectorStore{ provider: Enum<'pgvector' | 'chroma' | 'qdrant' | 'pinecone' | 'weaviate' | 'milvus' | 'redis' | … +3 more>; collection: string; endpoint?: string; secretRef?: string; … }optional
refresh{ onRecordChange?: boolean; cron?: string }optional
aiExposedbooleanoptional

KnowledgeSourceKind

Union Options

This schema accepts one of the following structures:

Option 1

Properties

PropertyTypeRequiredDescription
kind'object'
objectstringShort object name to index
contentFieldsstring[]Fields contributing to document content
metadataFieldsstring[]optional
whereRecord<string, any>optional

Option 2

Properties

PropertyTypeRequiredDescription
kind'file'
prefixstringStorage prefix
mimeTypesstring[]optional

Option 3

Properties

PropertyTypeRequiredDescription
kind'http'
urlsstring[]
userAgentstringoptional


ObjectKnowledgeSource

Properties

PropertyTypeRequiredDescription
kind'object'
objectstringShort object name to index
contentFieldsstring[]Fields contributing to document content
metadataFieldsstring[]optional
whereRecord<string, any>optional

On this page