ObjectStackObjectStack

Knowledge Source — AI Protocol reference

Knowledge Source — the governed metadata type knowledge_source: what the knowledge service indexes, from which object, and through which adapter.

Knowledge Source — the governed metadata type knowledge_source (ADR-0161 K4): what the knowledge service indexes, from which object, and through which adapter.

One schema for every door (ADR-0005, ADR-0161 K4 point 3): a *.knowledge-source.ts file in a package, a save through Studio or MCP, and a registration in code all parse with KnowledgeSourceSchema.

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

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

TypeScript Usage

import { KnowledgeRefreshPolicySchema, KnowledgeSourceSchema, KnowledgeSplitSchema, KnowledgeSplitStrategySchema, ObjectKnowledgeSourceSchema } from '@objectstack/spec/ai';
import type { KnowledgeRefreshPolicy, KnowledgeSource, KnowledgeSplit, KnowledgeSplitStrategy, ObjectKnowledgeSource } from '@objectstack/spec/ai';

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

KnowledgeRefreshPolicy

Properties

PropertyTypeRequiredDescription
onRecordChangebooleanoptional (default: true)Sync the index from record events (default true); false leaves the index to an external indexer
cronneveroptional[REMOVED] knowledge_source.refresh.cron was removed in @objectstack/spec 19.0.0 (ADR-0161 K6) — it was parsed and reached no engine: nothing ever scheduled a reindex from it. Delete the key. To rebuild on a schedule, call reindexSource from a flow or a job; keeping the index correct between events is the service's reconcile pass. A source registered in code (KnowledgeServicePlugin({ sources }), registerSource) is in no stack collection, so os migrate meta lists no edit for it: make this edit in the registration itself. Run os migrate meta --from 18 to list the mechanical edits for existing sources; --write applies the ones it can prove, and you apply the rest by hand.

KnowledgeSource

Properties

PropertyTypeRequiredDescription
namestring✅Source machine name (snake_case) — what search_knowledge lists and its sourceIds argument names
idneveroptional[REMOVED] knowledge_source.id was removed in @objectstack/spec 19.0.0 (ADR-0161 K6) — a knowledge source is a metadata item, and an item is identified by name; use name. Rename the key; the value is unchanged, so the source's index is found again and is not rebuilt, except for a source whose id began with an underscore: name refuses the underscore, so that source takes a new name, is built again under it, and its old index is dropped with dropSource; the upgrade entry knowledge-source-registration-governed says how, and its notices still apply after the conversion. A source registered in code (KnowledgeServicePlugin({ sources }), registerSource) is in no stack collection, so os migrate meta lists no edit for it: make this edit in the registration itself. Run os migrate meta --from 18 to list the mechanical edits for existing sources; --write applies the ones it can prove, and you apply the rest by hand.
labelstring✅
descriptionstringoptional
adapterstringoptionalAdapter id; omitted means the deployment's store (pgvector on PostgreSQL, turso otherwise), else the only adapter registered
adapterConfigneveroptional[REMOVED] knowledge_source.adapterConfig was removed in @objectstack/spec 19.0.0 (ADR-0161 K6) — no adapter read it: its one reader was the retired RAGFlow adapter. Delete the key. An adapter takes its settings as options of the plugin that mounts it. A source registered in code (KnowledgeServicePlugin({ sources }), registerSource) is in no stack collection, so os migrate meta lists no edit for it: make this edit in the registration itself. Run os migrate meta --from 18 to list the mechanical edits for existing sources; --write applies the ones it can prove, and you apply the rest by hand.
source{ kind: Enum<'object'>; object: string; content: string[]; metadataFields?: string[]; … }✅
embeddingneveroptional[REMOVED] knowledge_source.embedding was removed in @objectstack/spec 19.0.0 (ADR-0161 K6) — it was never read: no service and no adapter chose a model from it. Delete the key. The embedder is configured once for the deployment, and every source is embedded by it. A source registered in code (KnowledgeServicePlugin({ sources }), registerSource) is in no stack collection, so os migrate meta lists no edit for it: make this edit in the registration itself. Run os migrate meta --from 18 to list the mechanical edits for existing sources; --write applies the ones it can prove, and you apply the rest by hand.
vectorStoreneveroptional[REMOVED] knowledge_source.vectorStore was removed in @objectstack/spec 19.0.0 (ADR-0161 K6) — it was never read: no service and no adapter chose a store from it. Delete the key. The store is the adapter the deployment installs, named by adapter. A source registered in code (KnowledgeServicePlugin({ sources }), registerSource) is in no stack collection, so os migrate meta lists no edit for it: make this edit in the registration itself. Run os migrate meta --from 18 to list the mechanical edits for existing sources; --write applies the ones it can prove, and you apply the rest by hand.
refresh{ onRecordChange?: boolean }optional (default: {})Refresh / sync configuration; omitted parses to {}
aiExposedbooleanoptional (default: true)
_lockEnum<'none' | 'no-overlay' | 'no-delete' | 'full'>optionalItem-level lock — controls overlay & delete (ADR-0010).
_lockReasonstringoptionalHuman-readable reason shown when a write is refused by _lock.
_lockSourceEnum<'artifact' | 'package' | 'env-forced'>optionalLayer that set _lock (artifact | package | env-forced).
_provenanceEnum<'package' | 'org' | 'env-forced' | 'platform'>optionalOrigin of the item (package | org | env-forced | platform).
_packageIdstringoptionalOwning package machine id.
_packageVersionstringoptionalOwning package version.
_lockDocsUrlstringoptionalOptional documentation link surfaced next to _lockReason.

Nested Shape: KnowledgeSource.source

PropertyTypeRequiredDescription
kindEnum<'object'>✅What the source indexes; object is the one kind
objectstring✅Short object name to index
contentstring[]✅Fields whose text is indexed, in order; every name is listed (no wildcard)
contentFieldsneveroptional[REMOVED] knowledge_source.source.contentFields was removed in @objectstack/spec 19.0.0 (ADR-0161 K6) — the key is spelled content now that a source is a metadata item; use content. Rename the key; the value (a list of field names) is unchanged, except that a '*' member is no longer accepted and is replaced by the field names it stood for. A source registered in code (KnowledgeServicePlugin({ sources }), registerSource) is in no stack collection, so os migrate meta lists no edit for it: make this edit in the registration itself. Run os migrate meta --from 18 to list the mechanical edits for existing sources; --write applies the ones it can prove, and you apply the rest by hand.
metadataFieldsstring[]optional (default: [])
documentBystringoptionalField linking each record to its parent document (a lookup or master_detail listed in metadataFields); record-level search answers one hit per parent
whereRecord<string, any>optional
split{ strategy: Enum<'whole' | 'recursive' | 'markdown'>; maxChars?: integer; minChars?: integer }optionalHow the service cuts this object's documents into passages; omitted means recursive

Nested Shape: KnowledgeSource.refresh

PropertyTypeRequiredDescription
onRecordChangebooleanoptional (default: true)Sync the index from record events (default true); false leaves the index to an external indexer
cronneveroptional[REMOVED] knowledge_source.refresh.cron was removed in @objectstack/spec 19.0.0 (ADR-0161 K6) — it was parsed and reached no engine: nothing ever scheduled a reindex from it. Delete the key. To rebuild on a schedule, call reindexSource from a flow or a job; keeping the index correct between events is the service's reconcile pass. A source registered in code (KnowledgeServicePlugin({ sources }), registerSource) is in no stack collection, so os migrate meta lists no edit for it: make this edit in the registration itself. Run os migrate meta --from 18 to list the mechanical edits for existing sources; --write applies the ones it can prove, and you apply the rest by hand.

KnowledgeSplit

Properties

PropertyTypeRequiredDescription
strategyEnum<'whole' | 'recursive' | 'markdown'>✅Split strategy: whole, recursive or markdown
maxCharsintegeroptionalLongest passage in characters; wins over the settings default, the embedder limit can lower it
minCharsintegeroptionalAdjacent pieces shorter than this are merged up to it (default 200); under markdown, only in a section that does not fit, since a section that fits is one passage; a value above the effective maxChars reads as maxChars

KnowledgeSplitStrategy

Allowed Values

  • whole
  • recursive
  • markdown

ObjectKnowledgeSource

Properties

PropertyTypeRequiredDescription
kindEnum<'object'>✅What the source indexes; object is the one kind
objectstring✅Short object name to index
contentstring[]✅Fields whose text is indexed, in order; every name is listed (no wildcard)
contentFieldsneveroptional[REMOVED] knowledge_source.source.contentFields was removed in @objectstack/spec 19.0.0 (ADR-0161 K6) — the key is spelled content now that a source is a metadata item; use content. Rename the key; the value (a list of field names) is unchanged, except that a '*' member is no longer accepted and is replaced by the field names it stood for. A source registered in code (KnowledgeServicePlugin({ sources }), registerSource) is in no stack collection, so os migrate meta lists no edit for it: make this edit in the registration itself. Run os migrate meta --from 18 to list the mechanical edits for existing sources; --write applies the ones it can prove, and you apply the rest by hand.
metadataFieldsstring[]optional (default: [])
documentBystringoptionalField linking each record to its parent document (a lookup or master_detail listed in metadataFields); record-level search answers one hit per parent
whereRecord<string, any>optional
split{ strategy: Enum<'whole' | 'recursive' | 'markdown'>; maxChars?: integer; minChars?: integer }optionalHow the service cuts this object's documents into passages; omitted means recursive

Nested Shape: ObjectKnowledgeSource.split

PropertyTypeRequiredDescription
strategyEnum<'whole' | 'recursive' | 'markdown'>✅Split strategy: whole, recursive or markdown
maxCharsintegeroptionalLongest passage in characters; wins over the settings default, the embedder limit can lower it
minCharsintegeroptionalAdjacent pieces shorter than this are merged up to it (default 200); under markdown, only in a section that does not fit, since a section that fits is one passage; a value above the effective maxChars reads as maxChars

On this page