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 { FileKnowledgeSource, HttpKnowledgeSource, KnowledgeRefreshPolicy, KnowledgeSource, KnowledgeSourceKind, ObjectKnowledgeSource } from '@objectstack/spec/ai';
import type { FileKnowledgeSource, HttpKnowledgeSource, KnowledgeRefreshPolicy, KnowledgeSource, KnowledgeSourceKind, ObjectKnowledgeSource } from '@objectstack/spec/ai';
// Validate data
const result = FileKnowledgeSource.parse(data);FileKnowledgeSource
Properties
| Property | Type | Required | Description |
|---|---|---|---|
| kind | string | ✅ | |
| prefix | string | ✅ | Storage prefix |
| mimeTypes | string[] | optional |
HttpKnowledgeSource
Properties
| Property | Type | Required | Description |
|---|---|---|---|
| kind | string | ✅ | |
| urls | string[] | ✅ | |
| userAgent | string | optional |
KnowledgeRefreshPolicy
Properties
| Property | Type | Required | Description |
|---|---|---|---|
| onRecordChange | boolean | optional | |
| cron | string | optional |
KnowledgeSource
Properties
| Property | Type | Required | Description |
|---|---|---|---|
| id | string | ✅ | Snake_case source id |
| label | string | ✅ | |
| description | string | optional | |
| adapter | string | ✅ | Adapter id |
| adapterConfig | Record<string, any> | optional | |
| source | Object | Object | Object | ✅ | |
| embedding | Object | optional | |
| vectorStore | Object | optional | |
| refresh | Object | optional | |
| aiExposed | boolean | optional |
KnowledgeSourceKind
Union Options
This schema accepts one of the following structures:
Option 1
Properties
| Property | Type | Required | Description |
|---|---|---|---|
| kind | string | ✅ | |
| object | string | ✅ | Short object name to index |
| contentFields | string[] | ✅ | Fields contributing to document content |
| metadataFields | string[] | optional | |
| where | Record<string, any> | optional |
Option 2
Properties
| Property | Type | Required | Description |
|---|---|---|---|
| kind | string | ✅ | |
| prefix | string | ✅ | Storage prefix |
| mimeTypes | string[] | optional |
Option 3
Properties
| Property | Type | Required | Description |
|---|---|---|---|
| kind | string | ✅ | |
| urls | string[] | ✅ | |
| userAgent | string | optional |
ObjectKnowledgeSource
Properties
| Property | Type | Required | Description |
|---|---|---|---|
| kind | string | ✅ | |
| object | string | ✅ | Short object name to index |
| contentFields | string[] | ✅ | Fields contributing to document content |
| metadataFields | string[] | optional | |
| where | Record<string, any> | optional |