KnowledgePublication
KIT · interface · Type contract
Compiled publication workflow.
Import
import type { KnowledgePublication } from '@jangts/agent-core/kits/knowledge';/** @typedef {import('@jangts/agent-core/kits/knowledge').KnowledgePublication} KnowledgePublication */Other public entry points:@jangts/agent-core/types, @jangts/agent-core/structs, @jangts/agent-core/kits/knowledge, @jangts/agent-core/kits.
Definition
interface KnowledgePublication<App>Type parameters
| Type parameter | Constraint | Default type |
|---|---|---|
App | — | — |
Field structure
| Field | Type | Required | Description |
|---|---|---|---|
read | (context: OperationContext<App>) => Promise<KnowledgePublicationRecord> | Required | Returns the current record, with expired candidates already pruned. |
propose | (request: { revision: number; document: KnowledgeDocument; sources: readonly KnowledgeSourceReference[]; }, context: OperationContext<App>) => Promise<KnowledgePublicationRecord> | Required | Adds a candidate based on revision; fails when the record moved on. |
publish | (request: { revision: number; candidateId: string; }, context: OperationContext<App>) => Promise<KnowledgePublicationRecord> | Required | Publishes one candidate and removes it from the pending list. |
reject | (request: { revision: number; candidateId: string; }, context: OperationContext<App>) => Promise<KnowledgePublicationRecord> | Required | Discards one candidate without touching the published documents. |
Member index
| Member | Purpose |
|---|---|
read | Returns the current record, with expired candidates already pruned. |
propose | Adds a candidate based on revision; fails when the record moved on. |
publish | Publishes one candidate and removes it from the pending list. |
reject | Discards one candidate without touching the published documents. |
Member details
read
Returns the current record, with expired candidates already pruned.
KnowledgePublication.read(context: OperationContext<App>): Promise<KnowledgePublicationRecord>Returns the current record, with expired candidates already pruned.
| Parameter | Type | Passing | Description |
|---|---|---|---|
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: Promise<KnowledgePublicationRecord>.
Awaited value: KnowledgePublicationRecord.
Return value structure
| Field | Type | Required | Description |
|---|---|---|---|
revision | number | Required | Read-only. Monotonic record revision; every accepted mutation increments it. |
publishedRevision | number | Required | Read-only. Revision number of the currently published document set. |
documents | readonly KnowledgeDocument[] | Required | Read-only. Published documents, in catalog order. |
candidates | readonly KnowledgeCandidate[] | Required | Read-only. Pending candidates; expired entries are removed before use. |
propose
Adds a candidate based on revision; fails when the record moved on.
KnowledgePublication.propose(request: { revision: number; document: KnowledgeDocument; sources: readonly KnowledgeSourceReference[]; }, context: OperationContext<App>): Promise<KnowledgePublicationRecord>Adds a candidate based on revision; fails when the record moved on.
| Parameter | Type | Passing | Description |
|---|---|---|---|
request | { revision: number; document: KnowledgeDocument; sources: readonly KnowledgeSourceReference[]; } | Required | — |
context | OperationContext<App> | Required | — |
Fields of request
| Field | Type | Required | Description |
|---|---|---|---|
revision | number | Required | See the type definition and usage context. |
document | KnowledgeDocument | Required | See the type definition and usage context. |
sources | readonly KnowledgeSourceReference[] | Required | See the type definition and usage context. |
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: Promise<KnowledgePublicationRecord>.
Awaited value: KnowledgePublicationRecord.
Return value structure
| Field | Type | Required | Description |
|---|---|---|---|
revision | number | Required | Read-only. Monotonic record revision; every accepted mutation increments it. |
publishedRevision | number | Required | Read-only. Revision number of the currently published document set. |
documents | readonly KnowledgeDocument[] | Required | Read-only. Published documents, in catalog order. |
candidates | readonly KnowledgeCandidate[] | Required | Read-only. Pending candidates; expired entries are removed before use. |
publish
Publishes one candidate and removes it from the pending list.
KnowledgePublication.publish(request: { revision: number; candidateId: string; }, context: OperationContext<App>): Promise<KnowledgePublicationRecord>Publishes one candidate and removes it from the pending list.
| Parameter | Type | Passing | Description |
|---|---|---|---|
request | { revision: number; candidateId: string; } | Required | — |
context | OperationContext<App> | Required | — |
Fields of request
| Field | Type | Required | Description |
|---|---|---|---|
revision | number | Required | See the type definition and usage context. |
candidateId | string | Required | See the type definition and usage context. |
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: Promise<KnowledgePublicationRecord>.
Awaited value: KnowledgePublicationRecord.
Return value structure
| Field | Type | Required | Description |
|---|---|---|---|
revision | number | Required | Read-only. Monotonic record revision; every accepted mutation increments it. |
publishedRevision | number | Required | Read-only. Revision number of the currently published document set. |
documents | readonly KnowledgeDocument[] | Required | Read-only. Published documents, in catalog order. |
candidates | readonly KnowledgeCandidate[] | Required | Read-only. Pending candidates; expired entries are removed before use. |
reject
Discards one candidate without touching the published documents.
KnowledgePublication.reject(request: { revision: number; candidateId: string; }, context: OperationContext<App>): Promise<KnowledgePublicationRecord>Discards one candidate without touching the published documents.
| Parameter | Type | Passing | Description |
|---|---|---|---|
request | { revision: number; candidateId: string; } | Required | — |
context | OperationContext<App> | Required | — |
Fields of request
| Field | Type | Required | Description |
|---|---|---|---|
revision | number | Required | See the type definition and usage context. |
candidateId | string | Required | See the type definition and usage context. |
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: Promise<KnowledgePublicationRecord>.
Awaited value: KnowledgePublicationRecord.
Return value structure
| Field | Type | Required | Description |
|---|---|---|---|
revision | number | Required | Read-only. Monotonic record revision; every accepted mutation increments it. |
publishedRevision | number | Required | Read-only. Revision number of the currently published document set. |
documents | readonly KnowledgeDocument[] | Required | Read-only. Published documents, in catalog order. |
candidates | readonly KnowledgeCandidate[] | Required | Read-only. Pending candidates; expired entries are removed before use. |
Examples
- Knowledge candidates: compilation checks and explicit publication: Candidate preparation and publication reuse the Knowledge compiler, and the real store commits official documents through CAS.
Bind document storage and source authorization
Beginner · Node.js
import { defineKnowledgePublication } from '@jangts/agent-core/kits/knowledge';
import type { KnowledgePublicationOptions } from '@jangts/agent-core/kits/knowledge';
export function publication<App>(store: KnowledgePublicationOptions<App>['store'],
authorize: KnowledgePublicationOptions<App>['authorize'],
verifySources: KnowledgePublicationOptions<App>['verifySources']) {
return defineKnowledgePublication({ store, authorize, verifySources, maxReadChars: 12000 });
}import { defineKnowledgePublication } from '@jangts/agent-core/kits/knowledge';
export function publication(store, authorize, verifySources) {
return defineKnowledgePublication({ store, authorize, verifySources, maxReadChars: 12000 });
}Publish an approved candidate document set
Configuration · Node.js
Call this after the App's real approval flow. Source changes, expired candidates, or version conflicts reject the commit.
import type { KnowledgePublication } from '@jangts/agent-core/kits/knowledge';
import type { OperationContext } from '@jangts/agent-core';
export async function publish<App>(publication: KnowledgePublication<App>, candidateId: string,
context: OperationContext<App>) {
const record = await publication.read(context);
return publication.publish({ revision: record.revision, candidateId }, context);
}export async function publish(publication, candidateId, context) {
const record = await publication.read(context);
return publication.publish({ revision: record.revision, candidateId }, context);
}