ObjectStackObjectStack

Knowledge Source — AI Protocol reference

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

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'✅
prefixstring✅Storage prefix
mimeTypesstring[]optional (default: [])

HttpKnowledgeSource

Properties

PropertyTypeRequiredDescription
kind'http'✅
urlsstring[]✅
userAgentstringoptional

KnowledgeRefreshPolicy

Properties

PropertyTypeRequiredDescription
onRecordChangebooleanoptional (default: true)
cronstring | { dialect: 'cron'; source?: string; ast?: any; meta?: object }optionalCron-dialect expression for a periodic full reindex. A bare string is shorthand for { dialect: 'cron', source }; the parse enforces a non-empty string or an expression envelope and normalizes to the envelope — cron syntax is not checked here, and no engine evaluates this slot: the verdict belongs to whatever external scheduler you hand the value to. service-knowledge does not schedule it: the value is surfaced so an automation flow / external scheduler can trigger reindexSource.

KnowledgeSource

Properties

PropertyTypeRequiredDescription
idstring✅Snake_case source id
labelstring✅
descriptionstringoptional
adapterstring✅Adapter id
adapterConfigRecord<string, any>optional (default: {})
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' | …>; collection: string; endpoint?: string; secretRef?: string; … }optional
refresh{ onRecordChange?: boolean; cron?: string | object }optionalRefresh / sync configuration; omitted parses to {} (the runtime default — the published input-shape JSON Schema cannot state it beside cron's transform).
aiExposedbooleanoptional (default: true)

Nested Shape: KnowledgeSource.source[kind='object']

PropertyTypeRequiredDescription
kind'object'✅
objectstring✅Short object name to index
contentFieldsstring[]✅Fields contributing to document content
metadataFieldsstring[]optional (default: [])
whereRecord<string, any>optional

Nested Shape: KnowledgeSource.source[kind='file']

PropertyTypeRequiredDescription
kind'file'✅
prefixstring✅Storage prefix
mimeTypesstring[]optional (default: [])

Nested Shape: KnowledgeSource.embedding

PropertyTypeRequiredDescription
providerEnum<'openai' | 'cohere' | 'azure_openai' | 'huggingface' | 'local' | 'custom'>✅
modelstring✅Provider-specific model identifier
dimensionsinteger✅Embedding vector dimensions
endpointstringoptionalCustom endpoint URL
secretRefstringoptionalReference to stored API key secret

Nested Shape: KnowledgeSource.vectorStore

PropertyTypeRequiredDescription
providerEnum<'pgvector' | 'chroma' | 'qdrant' | 'pinecone' | 'weaviate' | 'milvus' | 'redis' | …>✅
collectionstring✅Collection / index / namespace name
endpointstringoptionalConnection string or endpoint URL
secretRefstringoptionalReference to stored credential secret
dimensionsintegeroptional

Nested Shape: KnowledgeSource.refresh

PropertyTypeRequiredDescription
onRecordChangebooleanoptional (default: true)
cronstring | { dialect: 'cron'; source?: string; ast?: any; meta?: object }optionalCron-dialect expression for a periodic full reindex. A bare string is shorthand for { dialect: 'cron', source }; the parse enforces a non-empty string or an expression envelope and normalizes to the envelope — cron syntax is not checked here, and no engine evaluates this slot: the verdict belongs to whatever external scheduler you hand the value to. service-knowledge does not schedule it: the value is surfaced so an automation flow / external scheduler can trigger reindexSource.

KnowledgeSourceKind

Union Options

This schema accepts one of the following structures:

Option 1

Properties

PropertyTypeRequiredDescription
kind'object'✅
objectstring✅Short object name to index
contentFieldsstring[]✅Fields contributing to document content
metadataFieldsstring[]optional (default: [])
whereRecord<string, any>optional

Option 2

Properties

PropertyTypeRequiredDescription
kind'file'✅
prefixstring✅Storage prefix
mimeTypesstring[]optional (default: [])

Option 3

Properties

PropertyTypeRequiredDescription
kind'http'✅
urlsstring[]✅
userAgentstringoptional


ObjectKnowledgeSource

Properties

PropertyTypeRequiredDescription
kind'object'✅
objectstring✅Short object name to index
contentFieldsstring[]✅Fields contributing to document content
metadataFieldsstring[]optional (default: [])
whereRecord<string, any>optional

On this page