KnowledgePublicationOptions
KIT · interface · Type contract
App-owned guards, store and limits for a publication workflow.
Import
ts
import type { KnowledgePublicationOptions } from '@jangts/agent-core/kits/knowledge';1
js
/** @typedef {import('@jangts/agent-core/kits/knowledge').KnowledgePublicationOptions} KnowledgePublicationOptions */1
Other public entry points:@jangts/agent-core/types, @jangts/agent-core/structs, @jangts/agent-core/kits/knowledge, @jangts/agent-core/kits.
Definition
ts
interface KnowledgePublicationOptions<App>1
Type parameters
| Type parameter | Constraint | Default type |
|---|---|---|
App | — | — |
Field structure
| Field | Type | Required | Description |
|---|---|---|---|
store | KnowledgePublicationStore | Required | Read-only. See the type definition and usage context. |
requiredReads | readonly KnowledgeRead[] | undefined | Optional | Read-only. Reads that must succeed against every compiled document set, proving sections still exist. |
maxReadChars | number | undefined | Optional | Read-only. Per-read character budget applied by the catalog compiler. |
maxCandidates | number | undefined | Optional | Read-only. Maximum pending candidates retained; defaults to 32 and must be a positive integer. |
candidateRetentionMs | number | undefined | Optional | Read-only. Candidate retention window; defaults to seven days. |
now | (() => number) | undefined | Optional | Read-only. Clock override for timestamps and expiry; defaults to Date.now. |
authorize | (operation: (typeof knowledgePublicationOperations)[number], context: OperationContext<App>) => MaybePromise<void> | Required | Guards one operation before any read or write. |
verifySources | (sources: readonly KnowledgeSourceReference[], context: OperationContext<App>) => MaybePromise<void> | Required | Validate real provenance/revisions/visibility. A model's source list is not a grant. |
Member index
| Member | Purpose |
|---|---|
authorize | Guards one operation before any read or write. |
verifySources | Validate real provenance/revisions/visibility. A model's source list is not a grant. |
Member details
authorize
Guards one operation before any read or write.
ts
KnowledgePublicationOptions.authorize(operation: (typeof knowledgePublicationOperations)[number], context: OperationContext<App>): MaybePromise<void>1
Guards one operation before any read or write.
| Parameter | Type | Passing | Description |
|---|---|---|---|
operation | "reject" | "propose" | "publish" | Required | — |
context | OperationContext<App> | Required | — |
Fields of context
| Field | Type | Required | Description |
|---|---|---|---|
app | unknown extends App ? App : Readonly<App> | Required | Read-only. See the type definition and usage context. |
logger | SubFlowLog | undefined | Optional | Read-only. Explicit optional recorder for this operation; never inferred from diagnostics. |
signal | AbortSignal | Required | Read-only. Non-optional cancellation signal; never undefined once execution has started. |
diagnostics | DiagnosticContext | undefined | Optional | Read-only. Diagnostic scope of the enclosing call, when recording is enabled. |
Returns: MaybePromise<void>.
Awaited value: void.
verifySources
Validate real provenance/revisions/visibility. A model's source list is not a grant.
ts
KnowledgePublicationOptions.verifySources(sources: readonly KnowledgeSourceReference[], context: OperationContext<App>): MaybePromise<void>1
Validate real provenance/revisions/visibility. A model's source list is not a grant.
| Parameter | Type | Passing | Description |
|---|---|---|---|
sources | readonly KnowledgeSourceReference[] | Required | — |
context | OperationContext<App> | Required | — |
Fields of context
| Field | Type | Required | Description |
|---|---|---|---|
app | unknown extends App ? App : Readonly<App> | Required | Read-only. See the type definition and usage context. |
logger | SubFlowLog | undefined | Optional | Read-only. Explicit optional recorder for this operation; never inferred from diagnostics. |
signal | AbortSignal | Required | Read-only. Non-optional cancellation signal; never undefined once execution has started. |
diagnostics | DiagnosticContext | undefined | Optional | Read-only. Diagnostic scope of the enclosing call, when recording is enabled. |
Returns: MaybePromise<void>.
Awaited value: void.
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.
- Knowledge candidates: compilation checks and explicit publication: Candidate preparation and publication reuse the Knowledge compiler, and the real store commits official documents through CAS.
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
Related policy source
- Selection, budget, and snapshot identity
- Text section parsing and tree compilation
- Document candidate compilation, source checks, and CAS publication