KnowledgeCandidate
KIT · interface · Type contract
A proposed document awaiting publish or reject.
Import
ts
import type { KnowledgeCandidate } from '@jangts/agent-core/kits/knowledge';js
/** @typedef {import('@jangts/agent-core/kits/knowledge').KnowledgeCandidate} KnowledgeCandidate */Other public entry points:@jangts/agent-core/types, @jangts/agent-core/structs, @jangts/agent-core/kits/knowledge, @jangts/agent-core/kits.
Definition
ts
interface KnowledgeCandidateField structure
| Field | Type | Required | Description |
|---|---|---|---|
id | string | Required | Read-only. Candidate id, generated by the Kit. |
baseRevision | number | Required | Read-only. Record revision the candidate was proposed against, used for stale-proposal detection. |
document | KnowledgeDocument | Required | Read-only. Complete document that would replace the published revision with the same id. |
sources | readonly KnowledgeSourceReference[] | Required | Read-only. Provenance the candidate depends on; verified by the App, never trusted from the model. |
createdAtMs | number | Required | Read-only. See the type definition and usage context. |
expiresAtMs | number | Required | Read-only. Instant after which the candidate is discarded. |
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
ts
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 });
}js
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.
ts
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);
}js
export async function publish(publication, candidateId, context) {
const record = await publication.read(context);
return publication.publish({ revision: record.revision, candidateId }, context);
}