Skip to content
中文

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';
js
/** @typedef {import('@jangts/agent-core/kits/knowledge').KnowledgePublicationOptions} KnowledgePublicationOptions */

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>

Type parameters ​

Type parameterConstraintDefault type
App——

Field structure ​

FieldTypeRequiredDescription
storeKnowledgePublicationStoreRequiredRead-only. See the type definition and usage context.
requiredReadsreadonly KnowledgeRead[] | undefinedOptionalRead-only. Reads that must succeed against every compiled document set, proving sections still exist.
maxReadCharsnumber | undefinedOptionalRead-only. Per-read character budget applied by the catalog compiler.
maxCandidatesnumber | undefinedOptionalRead-only. Maximum pending candidates retained; defaults to 32 and must be a positive integer.
candidateRetentionMsnumber | undefinedOptionalRead-only. Candidate retention window; defaults to seven days.
now(() => number) | undefinedOptionalRead-only. Clock override for timestamps and expiry; defaults to Date.now.
authorize(operation: (typeof knowledgePublicationOperations)[number], context: OperationContext<App>) => MaybePromise<void>RequiredGuards one operation before any read or write.
verifySources(sources: readonly KnowledgeSourceReference[], context: OperationContext<App>) => MaybePromise<void>RequiredValidate real provenance/revisions/visibility. A model's source list is not a grant.

Member index ​

MemberPurpose
authorizeGuards one operation before any read or write.
verifySourcesValidate 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>

Guards one operation before any read or write.

ParameterTypePassingDescription
operation"reject" | "propose" | "publish"Required—
contextOperationContext<App>Required—
Fields of context
FieldTypeRequiredDescription
appunknown extends App ? App : Readonly<App>RequiredRead-only. See the type definition and usage context.
loggerSubFlowLog | undefinedOptionalRead-only. Explicit optional recorder for this operation; never inferred from diagnostics.
signalAbortSignalRequiredRead-only. Non-optional cancellation signal; never undefined once execution has started.
diagnosticsDiagnosticContext | undefinedOptionalRead-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>

Validate real provenance/revisions/visibility. A model's source list is not a grant.

ParameterTypePassingDescription
sourcesreadonly KnowledgeSourceReference[]Required—
contextOperationContext<App>Required—
Fields of context
FieldTypeRequiredDescription
appunknown extends App ? App : Readonly<App>RequiredRead-only. See the type definition and usage context.
loggerSubFlowLog | undefinedOptionalRead-only. Explicit optional recorder for this operation; never inferred from diagnostics.
signalAbortSignalRequiredRead-only. Non-optional cancellation signal; never undefined once execution has started.
diagnosticsDiagnosticContext | undefinedOptionalRead-only. Diagnostic scope of the enclosing call, when recording is enabled.

Returns: MaybePromise<void>.

Awaited value: void.

Examples ​

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);
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);

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);
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);

API reference, usage examples and developer guides.