ObjectStackObjectStack

Knowledge Document — AI Protocol reference

Knowledge Document / Chunk / Hit — canonical shapes shared by every IKnowledgeAdapter implementation.

Knowledge Document / Chunk / Hit — canonical shapes shared by every IKnowledgeAdapter implementation.

The framework does not prescribe chunk strategy or vector format. Adapters are free to chunk however they like; the framework only requires they round-trip these shapes when talking to the IKnowledgeService.

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

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

TypeScript Usage

import { KnowledgeChunkSchema, KnowledgeDocumentSchema, KnowledgeHitSchema } from '@objectstack/spec/ai';
import type { KnowledgeChunk, KnowledgeDocument, KnowledgeHit } from '@objectstack/spec/ai';

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

KnowledgeChunk

Properties

PropertyTypeRequiredDescription
idstring✅
documentIdstring✅
indexinteger✅
contentstring✅
metadataRecord<string, any>optional

KnowledgeDocument

Properties

PropertyTypeRequiredDescription
idstring✅Document id
sourceIdstring✅Owning KnowledgeSource id
sourceRecordIdstringoptional
contentstring✅
titlestringoptional
metadataRecord<string, any>optional (default: {})
permissionsstring[]optional

KnowledgeHit

Properties

PropertyTypeRequiredDescription
chunkIdstring✅
documentIdstring✅
sourceIdstring✅
sourceRecordIdstringoptional
scorenumber✅
snippetstring✅
titlestringoptional
metadataRecord<string, any>optional (default: {})

On this page