KnowledgeCatalogOptions
KIT · interface · Type contract
Catalog construction options.
Import
ts
import type { KnowledgeCatalogOptions } from '@jangts/agent-core/kits/knowledge';1
js
/** @typedef {import('@jangts/agent-core/kits/knowledge').KnowledgeCatalogOptions} KnowledgeCatalogOptions */1
Other public entry points:@jangts/agent-core/types, @jangts/agent-core/kits/knowledge, @jangts/agent-core/kits.
Definition
ts
interface KnowledgeCatalogOptions1
Field structure
| Field | Type | Required | Description |
|---|---|---|---|
maxChars | number | undefined | Optional | Read-only. Maximum characters per read; exceeding it throws a RangeError. |
observe | ((snapshot: KnowledgeSnapshot) => void | Promise<void>) | undefined | Optional | Read-only. Observer invoked with every produced snapshot. |
Examples
- Knowledge: documents, sections, and evidence snapshots: One document contract supports plain objects and anchored text; a selection yields an evidence snapshot with an explicit version.
First read one plain-object document
Beginner · Node.js
ts
import { Knowledge } from '@jangts/agent-core/kits/knowledge';
const catalog = Knowledge.defineKnowledgeCatalog([
{ id: 'manual', revision: '1', parts: ['Agent Core 支持普通 Workflow 节点。'] },
]);
const snapshot = catalog.read({ documentId: 'manual', selection: { mode: 'document' } });
console.log(snapshot.content, snapshot.revision);1
2
3
4
5
6
2
3
4
5
6
js
import { Knowledge } from '@jangts/agent-core/kits/knowledge';
const catalog = Knowledge.defineKnowledgeCatalog([
{ id: 'manual', revision: '1', parts: ['Agent Core 支持普通 Workflow 节点。'] },
]);
const snapshot = catalog.read({ documentId: 'manual', selection: { mode: 'document' } });
console.log(snapshot.content, snapshot.revision);1
2
3
4
5
6
2
3
4
5
6
Add sections and a budget to the same read
Configuration · Node.js
ts
import { Knowledge } from '@jangts/agent-core/kits/knowledge';
const catalog = Knowledge.defineKnowledgeCatalog([
{ id: 'manual', revision: '2', parts: [
{ id: 'start', parts: ['先运行一个节点。', { id: 'advanced', parts: ['再增加模型和工具。'] }] },
] },
], { maxChars: 2000 });
console.log(catalog.sectionIds('manual'));
const snapshot = catalog.read({ documentId: 'manual', selection: { mode: 'subtree', sectionIds: ['start'] } });
console.log(snapshot.content, snapshot.id);1
2
3
4
5
6
7
8
9
2
3
4
5
6
7
8
9
js
import { Knowledge } from '@jangts/agent-core/kits/knowledge';
const catalog = Knowledge.defineKnowledgeCatalog([
{ id: 'manual', revision: '2', parts: [
{ id: 'start', parts: ['先运行一个节点。', { id: 'advanced', parts: ['再增加模型和工具。'] }] },
] },
], { maxChars: 2000 });
console.log(catalog.sectionIds('manual'));
const snapshot = catalog.read({ documentId: 'manual', selection: { mode: 'subtree', sectionIds: ['start'] } });
console.log(snapshot.content, snapshot.id);1
2
3
4
5
6
7
8
9
2
3
4
5
6
7
8
9